typebulb 0.62.4 → 0.62.6
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 +3 -1
- package/SKILL.md +5 -3
- package/dist/agents/claude/client.js +35 -35
- package/dist/agents/codex/client.js +34 -34
- package/dist/agents/pi/client.js +35 -35
- package/dist/index.js +277 -273
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,176 +1,176 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
`),n=0;if(e[n]?.trim()!=="---")return{reason:
|
|
5
|
-
`)),a.set(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
|
|
6
|
-
`),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=
|
|
3
|
+
var fx=Object.create;var Vl=Object.defineProperty;var px=Object.getOwnPropertyDescriptor;var hx=Object.getOwnPropertyNames;var mx=Object.getPrototypeOf,gx=Object.prototype.hasOwnProperty;var Ii=(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),$i=(t,e)=>{for(var n in e)Vl(t,n,{get:e[n],enumerable:!0})},yx=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of hx(e))!gx.call(t,s)&&s!==n&&Vl(t,s,{get:()=>e[s],enumerable:!(r=px(e,s))||r.enumerable});return t};var bx=(t,e,n)=>(n=t!=null?fx(mx(t)):{},yx(e||!t||!t.__esModule?Vl(n,"default",{value:t,enumerable:!0}):n,t));import*as Bp from"fs/promises";import{existsSync as Jn,readFileSync as wx}from"fs";import*as le from"path";import{pathToFileURL as vx}from"url";import{resolve as Xl}from"resolve.exports";import{init as jp,parse as Fp}from"es-module-lexer";function Up(t,e){let n=le.join(t,"package.json");try{return JSON.parse(wx(n,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${n}`)}}function qp(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 Jp(t){let{name:e,dir:n}=t;if(!Jn(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=Up(n,e),s=Sx(r,e),i=le.resolve(n,s);if(!Jn(i))throw new Error(`--replace package '${e}' entry not found on disk: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);let o=le.dirname(i),a=`/local/${e}/${le.basename(i)}`,l=kx(r,n);return await xx(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function Sx(t,e){if(t.exports!==void 0){let r;try{r=Xl(t,".",{browser:!0,conditions:Gl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${Gl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=Ql(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${Gl.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 kx(t,e){if(t.exports!==void 0)try{let r=Xl(t,".",{conditions:["types"]}),s=Ql(r);if(s){let i=le.resolve(e,s);if(Jn(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=le.resolve(e,n);if(Jn(r))return r}}function Ql(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function xx(t,e,n){await jp;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 Bp.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=Fp(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=Ex(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 Ex(t,e,n){let r=e.replace(/[?#].*$/,""),s=le.resolve(le.dirname(t),r),i=[s,s+".js",s+".mjs",le.join(s,"index.js"),le.join(s,"index.mjs")];for(let o of i)if(le.normalize(o).startsWith(n)&&Jn(o))return o}function Ax(t,e,n){let r=Up(t,e),s;if(r.exports!==void 0)try{s=Ql(Xl(r,n,{conditions:Dp}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${Dp.join(", ")}): ${o instanceof Error?o.message:o}`)}else n==="."&&(s=r.main??r.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${n}'.`);let i=le.resolve(t,s);if(!Jn(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return vx(i).href}async function Wp(t,e){await jp;let n;try{[n]=Fp(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=Ax(e.dir,e.name,a);r+=t.slice(s,i.s)+l,s=i.e}return r+t.slice(s)}var Gl,Dp,Ni=S(()=>{"use strict";Gl=["browser","import","default"],Dp=["node","import","default"]});function Kp(t){return ze.find(e=>pe[e].path===t)}function zp(t){return!!t?.startsWith("typebulb")}var pe,ze,Hp,Li=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"}},ze=["code","css","html","data","infer","insight","config","notes"];Hp="typebulb/v1"});function Zl(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function ec(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Mi=S(()=>{});function Wn(t){let e=Vp(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function Ye(t){let e=Vp(t);return"bulb"in e?e.bulb:void 0}function Vp(t){try{let e=t.split(`
|
|
4
|
+
`),n=0;if(e[n]?.trim()!=="---")return{reason:Cx(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=_x(r);if(!zp(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(Yp);if(d){let u=d[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(Di);if(!p){l.push(`**${u}** has no code fence \u2014 block skipped`);continue}let h=p[1];n++;let m=n+1,g=[],b=tc(h);for(;n<e.length&&!e[n]?.match(b);)g.push(e[n]),n++;let C=n<e.length;n++,l.push(...Ox(u,g,C)),o.set(u,g.join(`
|
|
5
|
+
`)),a.set(u,m),c=n}else n++}return{bulb:{frontmatter:i,files:o,warnings:l,bodyEndLine:c,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function Cx(t,e){let n=Rx(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 Ox(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Yp);i&&Tx.has(i[1].trim())&&Px(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 Px(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(Di)}function _x(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=ec(i);break}}return e}function Gp(t){return Ye(t)?.warnings??[]}function Rx(t){let e=t.split(`
|
|
6
|
+
`),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=Ye(e.slice(r).join(`
|
|
7
7
|
`));if(s&&s.files.size>0){let i=r+s.bodyEndLine;n.push({start:r,end:i,source:e.slice(r,i).join(`
|
|
8
|
-
`)}),r=i}else r++}return n}function
|
|
8
|
+
`)}),r=i}else r++}return n}function Xp(t){let e=Object.fromEntries(ze.map(n=>[n,t.files.get(pe[n].path)||""]));return{name:t.frontmatter.name,...e}}var Yp,Di,Tx,tc,nc=S(()=>{Li();Mi();Yp=/^\*\*(.+)\*\*$/,Di=/^(`{3,})(\w*)\s*$/,Tx=new Set(ze.map(t=>pe[t].path)),tc=t=>new RegExp(`^${t}\\s*$`)});function Qp(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 Zp(t,e){let{path:n}=pe[t],r=n.split(".").pop(),s=Qp(e);return`**${n}**
|
|
9
9
|
|
|
10
10
|
${s}${r}
|
|
11
11
|
${e}
|
|
12
|
-
${s}`}function
|
|
13
|
-
`)}function
|
|
14
|
-
`),s=
|
|
12
|
+
${s}`}function eh(t){let e=ze.filter(n=>t[n]).map(n=>Zp(n,t[n]));return["---",`format: ${Hp}`,`name: ${Zl(t.name)}`,"---","",...e].join(`
|
|
13
|
+
`)}function th(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(Di);if(!s)continue;let i=tc(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 Hr(t,e,n){let r=t.split(`
|
|
14
|
+
`),s=th(r,pe[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
|
|
15
15
|
|
|
16
|
-
${
|
|
17
|
-
`;let i=
|
|
16
|
+
${Zp(e,n)}
|
|
17
|
+
`;let i=Qp(n),o=i.length>s.fence.length?i:s.fence;return[...r.slice(0,s.open),o+s.lang,...n.split(`
|
|
18
18
|
`),o,...r.slice(s.close+1)].join(`
|
|
19
|
-
`)}function
|
|
20
|
-
`),r=
|
|
19
|
+
`)}function nh(t,e){let n=t.split(`
|
|
20
|
+
`),r=th(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
|
|
23
|
-
>/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=
|
|
24
|
-
>]`),m+=
|
|
25
|
-
`)}};
|
|
26
|
-
`)?
|
|
22
|
+
`}var rh=S(()=>{Li();nc();Mi()});function zr(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function ih(t){switch(sh(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 oh(t){let e=sh(t);return e!==void 0&&$x.has(e)?e:void 0}function Lx(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function rc(t){let e=zr(t??"").description?.trim();if(!e)return Nx;let n=Lx(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var Ix,Bi,sh,$x,Nx,ah=S(()=>{Ix="https://assets.typebulb.com",Bi=(t,e)=>`${Ix}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,sh=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();$x=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);Nx="A Typebulb bulb."});var lh=S(()=>{});function sc(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var ch=S(()=>{});function Yr(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var uh=S(()=>{});function ji(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var dh=S(()=>{});function Vr(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=sc(t,`<${e}[
|
|
23
|
+
>/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=Yr(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=Yr(a,"[ /]"+e+">",p))!==-1;){let g=a.substring(p,l+1);if(h+=ji(g,"<"+e+`[
|
|
24
|
+
>]`),m+=ji(g,"</"+e+">"),m>=h)break;p=l}}else l=Yr(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 ic=S(()=>{ch();uh();dh()});var oc=S(()=>{ic()});var ac=S(()=>{oc()});var fh=S(()=>{ac()});var ph=S(()=>{});var hh=S(()=>{lh();ic();oc();fh();ac();ph()});var W=I(ge=>{"use strict";var lc=Symbol.for("yaml.alias"),mh=Symbol.for("yaml.document"),Fi=Symbol.for("yaml.map"),gh=Symbol.for("yaml.pair"),cc=Symbol.for("yaml.scalar"),Ui=Symbol.for("yaml.seq"),ft=Symbol.for("yaml.node.type"),Bx=t=>!!t&&typeof t=="object"&&t[ft]===lc,jx=t=>!!t&&typeof t=="object"&&t[ft]===mh,Fx=t=>!!t&&typeof t=="object"&&t[ft]===Fi,Ux=t=>!!t&&typeof t=="object"&&t[ft]===gh,yh=t=>!!t&&typeof t=="object"&&t[ft]===cc,qx=t=>!!t&&typeof t=="object"&&t[ft]===Ui;function bh(t){if(t&&typeof t=="object")switch(t[ft]){case Fi:case Ui:return!0}return!1}function Jx(t){if(t&&typeof t=="object")switch(t[ft]){case lc:case Fi:case cc:case Ui:return!0}return!1}var Wx=t=>(yh(t)||bh(t))&&!!t.anchor;ge.ALIAS=lc;ge.DOC=mh;ge.MAP=Fi;ge.NODE_TYPE=ft;ge.PAIR=gh;ge.SCALAR=cc;ge.SEQ=Ui;ge.hasAnchor=Wx;ge.isAlias=Bx;ge.isCollection=bh;ge.isDocument=jx;ge.isMap=Fx;ge.isNode=Jx;ge.isPair=Ux;ge.isScalar=yh;ge.isSeq=qx});var Gr=I(uc=>{"use strict";var ce=W(),Ae=Symbol("break visit"),wh=Symbol("skip children"),it=Symbol("remove node");function qi(t,e){let n=vh(e);ce.isDocument(t)?Kn(null,t.contents,n,Object.freeze([t]))===it&&(t.contents=null):Kn(null,t,n,Object.freeze([]))}qi.BREAK=Ae;qi.SKIP=wh;qi.REMOVE=it;function Kn(t,e,n,r){let s=Sh(t,e,n,r);if(ce.isNode(s)||ce.isPair(s))return kh(t,r,s),Kn(t,s,n,r);if(typeof s!="symbol"){if(ce.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Kn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===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=Kn("key",e.key,n,r);if(i===Ae)return Ae;i===it&&(e.key=null);let o=Kn("value",e.value,n,r);if(o===Ae)return Ae;o===it&&(e.value=null)}}return s}async function Ji(t,e){let n=vh(e);ce.isDocument(t)?await Hn(null,t.contents,n,Object.freeze([t]))===it&&(t.contents=null):await Hn(null,t,n,Object.freeze([]))}Ji.BREAK=Ae;Ji.SKIP=wh;Ji.REMOVE=it;async function Hn(t,e,n,r){let s=await Sh(t,e,n,r);if(ce.isNode(s)||ce.isPair(s))return kh(t,r,s),Hn(t,s,n,r);if(typeof s!="symbol"){if(ce.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Hn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===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 Hn("key",e.key,n,r);if(i===Ae)return Ae;i===it&&(e.key=null);let o=await Hn("value",e.value,n,r);if(o===Ae)return Ae;o===it&&(e.value=null)}}return s}function vh(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 Sh(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 kh(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`)}}uc.visit=qi;uc.visitAsync=Ji});var dc=I(Eh=>{"use strict";var xh=W(),Kx=Gr(),Hx={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},zx=t=>t.replace(/[!,[\]{}]/g,e=>Hx[e]),Xr=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+zx(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&&xh.isNode(e.contents)){let i={};Kx.visit(e.contents,(o,a)=>{xh.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
|
+
`)}};Xr.defaultYaml={explicit:!1,version:"1.2"};Xr.defaultTags={"!!":"tag:yaml.org,2002:"};Eh.Directives=Xr});var Wi=I(Qr=>{"use strict";var Ah=W(),Yx=Gr();function Vx(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 Th(t){let e=new Set;return Yx.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function Ch(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Gx(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=Th(t));let o=Ch(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(Ah.isScalar(o.node)||Ah.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}}Qr.anchorIsValid=Vx;Qr.anchorNames=Th;Qr.createNodeAnchors=Gx;Qr.findNewAnchor=Ch});var fc=I(Oh=>{"use strict";function Zr(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let s=0,i=r.length;s<i;++s){let o=r[s],a=Zr(t,r,String(s),o);a===void 0?delete r[s]:a!==o&&(r[s]=a)}else if(r instanceof Map)for(let s of Array.from(r.keys())){let i=r.get(s),o=Zr(t,r,s,i);o===void 0?r.delete(s):o!==i&&r.set(s,o)}else if(r instanceof Set)for(let s of Array.from(r)){let i=Zr(t,r,s,s);i===void 0?r.delete(s):i!==s&&(r.delete(s),r.add(i))}else for(let[s,i]of Object.entries(r)){let o=Zr(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}Oh.applyReviver=Zr});var Rt=I(_h=>{"use strict";var Xx=W();function Ph(t,e,n){if(Array.isArray(t))return t.map((r,s)=>Ph(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!Xx.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}_h.toJS=Ph});var Ki=I(Ih=>{"use strict";var Qx=fc(),Rh=W(),Zx=Rt(),pc=class{constructor(e){Object.defineProperty(this,Rh.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(!Rh.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=Zx.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?Qx.applyReviver(i,{"":a},"",a):a}};Ih.NodeBase=pc});var es=I($h=>{"use strict";var e0=Wi(),t0=Gr(),zn=W(),n0=Ki(),r0=Rt(),hc=class extends n0.NodeBase{constructor(e){super(zn.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],t0.visit(e,{Node:(i,o)=>{(zn.isAlias(o)||zn.hasAnchor(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let s;for(let i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:s,maxAliasCount:i}=n,o=this.resolve(s,n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=r.get(o);if(a||(r0.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=Hi(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(e0.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 Hi(t,e,n){if(zn.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(zn.isCollection(e)){let r=0;for(let s of e.items){let i=Hi(t,s,n);i>r&&(r=i)}return r}else if(zn.isPair(e)){let r=Hi(t,e.key,n),s=Hi(t,e.value,n);return Math.max(r,s)}return 1}$h.Alias=hc});var re=I(mc=>{"use strict";var s0=W(),i0=Ki(),o0=Rt(),a0=t=>!t||typeof t!="function"&&typeof t!="object",It=class extends i0.NodeBase{constructor(e){super(s0.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:o0.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";mc.Scalar=It;mc.isScalarValue=a0});var ts=I(Lh=>{"use strict";var l0=es(),ln=W(),Nh=re(),c0="tag:yaml.org,2002:";function u0(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 d0(t,e,n){if(ln.isDocument(t)&&(t=t.contents),ln.isNode(t))return t;if(ln.isPair(t)){let d=n.schema[ln.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 l0.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=c0+e.slice(2));let c=u0(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new Nh.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[ln.MAP]:Symbol.iterator in Object(t)?o[ln.SEQ]:o[ln.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 Nh.Scalar(t);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}Lh.createNode=d0});var Yi=I(zi=>{"use strict";var f0=ts(),ot=W(),p0=Ki();function gc(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return f0.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Mh=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,yc=class extends p0.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(Mh(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,gc(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,gc(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};zi.Collection=yc;zi.collectionFromPath=gc;zi.isEmptyPath=Mh});var ns=I(Vi=>{"use strict";var h0=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function bc(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var m0=(t,e,n)=>t.endsWith(`
|
|
26
|
+
`)?bc(n,e):n.includes(`
|
|
27
27
|
`)?`
|
|
28
|
-
`+
|
|
29
|
-
`)n===
|
|
30
|
-
`&&p!==" "){let
|
|
31
|
-
`&&
|
|
32
|
-
${e}${t.slice(0,$)}`:(n===
|
|
33
|
-
${e}${t.slice(
|
|
34
|
-
`);r=e,s=e+1,i=t[s]}return r}
|
|
35
|
-
`){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function
|
|
28
|
+
`+bc(n,e):(t.endsWith(" ")?"":" ")+n;Vi.indentComment=bc;Vi.lineComment=m0;Vi.stringifyComment=h0});var Bh=I(rs=>{"use strict";var g0="flow",wc="block",Gi="quoted";function y0(t,e,n="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let l=Math.max(1+i,1+s-e.length);if(t.length<=l)return t;let c=[],f={},d=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):d=s-r);let u,p,h=!1,m=-1,g=-1,b=-1;n===wc&&(m=Dh(t,m,e.length),m!==-1&&(d=m+l));for(let T;T=t[m+=1];){if(n===Gi&&T==="\\"){switch(g=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}b=m}if(T===`
|
|
29
|
+
`)n===wc&&(m=Dh(t,m,e.length)),d=m+e.length+l,u=void 0;else{if(T===" "&&p&&p!==" "&&p!==`
|
|
30
|
+
`&&p!==" "){let E=t[m+1];E&&E!==" "&&E!==`
|
|
31
|
+
`&&E!==" "&&(u=m)}if(m>=d)if(u)c.push(u),d=u+l,u=void 0;else if(n===Gi){for(;p===" "||p===" ";)p=T,T=t[m+=1],h=!0;let E=m>b+1?m-2:g-1;if(f[E])return t;c.push(E),f[E]=!0,d=E+l,u=void 0}else h=!0}p=T}if(h&&a&&a(),c.length===0)return t;o&&o();let C=t.slice(0,c[0]);for(let T=0;T<c.length;++T){let E=c[T],$=c[T+1]||t.length;E===0?C=`
|
|
32
|
+
${e}${t.slice(0,$)}`:(n===Gi&&f[E]&&(C+=`${t[E]}\\`),C+=`
|
|
33
|
+
${e}${t.slice(E+1,$)}`)}return C}function Dh(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}rs.FOLD_BLOCK=wc;rs.FOLD_FLOW=g0;rs.FOLD_QUOTED=Gi;rs.foldFlowLines=y0});var is=I(jh=>{"use strict";var Ve=re(),$t=Bh(),Qi=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Zi=t=>/^(%|---|\.\.\.)/m.test(t);function b0(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 ss(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Zi(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:$t.foldFlowLines(o,i,$t.FOLD_QUOTED,
|
|
39
|
-
`)||/[ \t]\n|\n[ \t]/.test(t))return
|
|
40
|
-
${n}`)+"'";return e.implicitKey?r:$t.foldFlowLines(r,n,$t.FOLD_FLOW,
|
|
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,Qi(e,!1))}function vc(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
|
|
39
|
+
`)||/[ \t]\n|\n[ \t]/.test(t))return ss(t,e);let n=e.indent||(Zi(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
40
|
+
${n}`)+"'";return e.implicitKey?r:$t.foldFlowLines(r,n,$t.FOLD_FLOW,Qi(e,!1))}function Yn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=ss;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=vc:i&&!s?r=ss:r=n?vc:ss}return r(t,e)}var Sc;try{Sc=new RegExp(`(^|(?<!
|
|
41
41
|
))
|
|
42
42
|
+(?!
|
|
43
|
-
|$)`,"g")}catch{
|
|
43
|
+
|$)`,"g")}catch{Sc=/\n+(?!\n|$)/g}function Xi({comment:t,type:e,value:n},r,s,i){let{blockQuote:o,commentString:a,lineWidth:l}=r.options;if(!o||/\n[\t ]+$/.test(n))return Yn(n,r);let c=r.indent||(r.forceBlockIndent||Zi(n)?" ":""),f=o==="literal"?!0:o==="folded"||e===Ve.Scalar.BLOCK_FOLDED?!1:e===Ve.Scalar.BLOCK_LITERAL?!0:!b0(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(
|
|
49
|
-
`)
|
|
50
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),
|
|
51
|
-
${c}${k}`}return n=n.replace(/\n+/g,`$&${c}`),`|${
|
|
52
|
-
${c}${
|
|
53
|
-
`)||f&&/[[\]{},]/.test(i))return
|
|
54
|
-
`)?
|
|
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
|
|
57
|
-
${e.indent}${a}`:a}
|
|
58
|
-
${a}:`):(g=`${g}:`,u&&(g+=
|
|
59
|
-
`:"",
|
|
60
|
-
${
|
|
61
|
-
`&&
|
|
62
|
-
|
|
63
|
-
`):
|
|
48
|
+
`&&(p=p.slice(0,-1)),p=p.replace(Sc,`$&${c}`));let m=!1,g,b=-1;for(g=0;g<n.length;++g){let $=n[g];if($===" ")m=!0;else if($===`
|
|
49
|
+
`)b=g;else break}let C=n.substring(0,b<g?b+1:g);C&&(n=n.substring(C.length),C=C.replace(/\n+/g,`$&${c}`));let E=(m?c?"2":"1":"")+d;if(t&&(E+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let $=n.replace(/\n+/g,`
|
|
50
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),P=!1,_=Qi(r,!0);o!=="folded"&&e!==Ve.Scalar.BLOCK_FOLDED&&(_.onOverflow=()=>{P=!0});let k=$t.foldFlowLines(`${C}${$}${p}`,c,$t.FOLD_BLOCK,_);if(!P)return`>${E}
|
|
51
|
+
${c}${k}`}return n=n.replace(/\n+/g,`$&${c}`),`|${E}
|
|
52
|
+
${c}${C}${n}${p}`}function w0(t,e,n,r){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&i.includes(`
|
|
53
|
+
`)||f&&/[[\]{},]/.test(i))return Yn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
|
|
54
|
+
`)?Yn(i,e):Xi(t,e,n,r);if(!a&&!f&&s!==Ve.Scalar.PLAIN&&i.includes(`
|
|
55
|
+
`))return Xi(t,e,n,r);if(Zi(i)){if(l==="")return e.forceBlockIndent=!0,Xi(t,e,n,r);if(a&&l===c)return Yn(i,e)}let d=i.replace(/\n+/g,`$&
|
|
56
|
+
${l}`);if(o){let u=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(d),{compat:p,tags:h}=e.doc.schema;if(h.some(u)||p?.some(u))return Yn(i,e)}return a?d:$t.foldFlowLines(d,l,$t.FOLD_FLOW,Qi(e,!1))}function v0(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!==Ve.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Ve.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case Ve.Scalar.BLOCK_FOLDED:case Ve.Scalar.BLOCK_LITERAL:return s||i?Yn(o.value,e):Xi(o,e,n,r);case Ve.Scalar.QUOTE_DOUBLE:return ss(o.value,e);case Ve.Scalar.QUOTE_SINGLE:return vc(o.value,e);case Ve.Scalar.PLAIN:return w0(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}jh.stringifyString=v0});var os=I(kc=>{"use strict";var S0=Wi(),Nt=W(),k0=ns(),x0=is();function E0(t,e){let n=Object.assign({blockQuote:!0,commentString:k0.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 A0(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 T0(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],i=(Nt.isScalar(t)||Nt.isCollection(t))&&t.anchor;i&&S0.anchorIsValid(i)&&(n.add(i),s.push(`&${i}`));let o=t.tag??(e.default?null:e.tag);return o&&s.push(r.directives.tagString(o)),s.join(" ")}function C0(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=A0(e.doc.schema.tags,i));let o=T0(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,n,r):Nt.isScalar(i)?x0.stringifyString(i,e,n,r):i.toString(e,n,r);return o?Nt.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
57
|
+
${e.indent}${a}`:a}kc.createStringifyContext=E0;kc.stringify=C0});var Jh=I(qh=>{"use strict";var pt=W(),Fh=re(),Uh=os(),as=ns();function O0({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===Fh.Scalar.BLOCK_FOLDED||t.type===Fh.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=Uh.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+=as.lineComment(g,n.indent,c(u)):m&&s&&s(),g;h&&(u=null),p?(u&&(g+=as.lineComment(g,n.indent,c(u))),g=`? ${g}
|
|
58
|
+
${a}:`):(g=`${g}:`,u&&(g+=as.lineComment(g,n.indent,c(u))));let b,C,T;pt.isNode(e)?(b=!!e.spaceBefore,C=e.commentBefore,T=e.comment):(b=!1,C=null,T=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!u&&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 E=!1,$=Uh.stringify(e,n,()=>E=!0,()=>m=!0),P=" ";if(u||b||C){if(P=b?`
|
|
59
|
+
`:"",C){let _=c(C);P+=`
|
|
60
|
+
${as.indentComment(_,n.indent)}`}$===""&&!n.inFlow?P===`
|
|
61
|
+
`&&T&&(P=`
|
|
62
|
+
|
|
63
|
+
`):P+=`
|
|
64
64
|
${n.indent}`}else if(!p&&pt.isCollection(e)){let _=$[0],k=$.indexOf(`
|
|
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||(
|
|
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||(P=`
|
|
66
66
|
${n.indent}`)}}else($===""||$[0]===`
|
|
67
|
-
`)&&(
|
|
67
|
+
`)&&(P="");return g+=P+$,n.inFlow?E&&r&&r():T&&!E?g+=as.lineComment(g,n.indent,c(T)):m&&s&&s(),g}qh.stringifyPair=O0});var Ec=I(xc=>{"use strict";var Wh=Ii("process");function P0(t,...e){t==="debug"&&console.log(...e)}function _0(t,e){(t==="debug"||t==="warn")&&(typeof Wh.emitWarning=="function"?Wh.emitWarning(e):console.warn(e))}xc.debug=P0;xc.warn=_0});var ro=I(no=>{"use strict";var ls=W(),Kh=re(),eo="<<",to={identify:t=>t===eo||typeof t=="symbol"&&t.description===eo,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Kh.Scalar(Symbol(eo)),{addToJSMap:Hh}),stringify:()=>eo},R0=(t,e)=>(to.identify(e)||ls.isScalar(e)&&(!e.type||e.type===Kh.Scalar.PLAIN)&&to.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===to.tag&&n.default);function Hh(t,e,n){if(n=t&&ls.isAlias(n)?n.resolve(t.doc):n,ls.isSeq(n))for(let r of n.items)Ac(t,e,r);else if(Array.isArray(n))for(let r of n)Ac(t,e,r);else Ac(t,e,n)}function Ac(t,e,n){let r=t&&ls.isAlias(n)?n.resolve(t.doc):n;if(!ls.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}no.addMergeToJSMap=Hh;no.isMergeKey=R0;no.merge=to});var Cc=I(Vh=>{"use strict";var I0=Ec(),zh=ro(),$0=os(),Yh=W(),Tc=Rt();function N0(t,e,{key:n,value:r}){if(Yh.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(zh.isMergeKey(t,n))zh.addMergeToJSMap(t,e,r);else{let s=Tc.toJS(n,"",t);if(e instanceof Map)e.set(s,Tc.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=L0(n,s,t),o=Tc.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 L0(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Yh.isNode(t)&&n?.doc){let r=$0.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)+'..."'),I0.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)}Vh.addPairToJSMap=N0});var Lt=I(Oc=>{"use strict";var Gh=ts(),M0=Jh(),D0=Cc(),so=W();function B0(t,e,n){let r=Gh.createNode(t,void 0,n),s=Gh.createNode(e,void 0,n);return new io(r,s)}var io=class t{constructor(e,n=null){Object.defineProperty(this,so.NODE_TYPE,{value:so.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return so.isNode(n)&&(n=n.clone(e)),so.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return D0.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?M0.stringifyPair(this,e,n,r):JSON.stringify(this)}};Oc.Pair=io;Oc.createPair=B0});var Pc=I(Qh=>{"use strict";var cn=W(),Xh=os(),oo=ns();function j0(t,e,n){return(e.inFlow??t.flow?U0:F0)(t,e,n)}function F0({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(cn.isNode(m))!d&&m.spaceBefore&&u.push(""),ao(n,u,m.commentBefore,d),m.comment&&(g=m.comment);else if(cn.isPair(m)){let C=cn.isNode(m.key)?m.key:null;C&&(!d&&C.spaceBefore&&u.push(""),ao(n,u,C.commentBefore,d))}d=!1;let b=Xh.stringify(m,f,()=>g=null,()=>d=!0);g&&(b+=oo.lineComment(b,i,c(g))),d&&g&&(d=!1),u.push(r+b)}let p;if(u.length===0)p=s.start+s.end;else{p=u[0];for(let h=1;h<u.length;++h){let m=u[h];p+=m?`
|
|
68
68
|
${l}${m}`:`
|
|
69
69
|
`}}return t?(p+=`
|
|
70
|
-
`+
|
|
71
|
-
`))&&(c=!0),d.push(
|
|
70
|
+
`+oo.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function U0({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(cn.isNode(m))m.spaceBefore&&d.push(""),ao(e,d,m.commentBefore,!1),m.comment&&(g=m.comment);else if(cn.isPair(m)){let C=cn.isNode(m.key)?m.key:null;C&&(C.spaceBefore&&d.push(""),ao(e,d,C.commentBefore,!1),C.comment&&(c=!0));let T=cn.isNode(m.value)?m.value:null;T?(T.comment&&(g=T.comment),T.commentBefore&&(c=!0)):m.value==null&&C?.comment&&(g=C.comment)}g&&(c=!0);let b=Xh.stringify(m,l,()=>g=null);h<t.length-1&&(b+=","),g&&(b+=oo.lineComment(b,r,a(g))),!c&&(d.length>f||b.includes(`
|
|
71
|
+
`))&&(c=!0),d.push(b),f=d.length}let{start:u,end:p}=n;if(d.length===0)return u+p;if(!c){let h=d.reduce((m,g)=>m+g.length+2,2);c=e.options.lineWidth>0&&h>e.options.lineWidth}if(c){let h=u;for(let m of d)h+=m?`
|
|
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 ao({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=oo.indentComment(e(r),t);n.push(i.trimStart())}}Qh.stringifyCollection=j0});var Dt=I(Rc=>{"use strict";var q0=Pc(),J0=Cc(),W0=Yi(),Mt=W(),lo=Lt(),K0=re();function cs(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 _c=class extends W0.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(lo.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 lo.Pair(e,e?.value):r=new lo.Pair(e.key,e.value);let s=cs(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);Mt.isScalar(s.value)&&K0.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=cs(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=cs(this.items,e)?.value;return(!n&&Mt.isScalar(s)?s.value:s)??void 0}has(e){return!!cs(this.items,e)}set(e,n){this.add(new lo.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)J0.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})),q0.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};Rc.YAMLMap=_c;Rc.findPair=cs});var Vn=I(em=>{"use strict";var H0=W(),Zh=Dt(),z0={collection:"map",default:!0,nodeClass:Zh.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return H0.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>Zh.YAMLMap.from(t,e,n)};em.map=z0});var Bt=I(tm=>{"use strict";var Y0=ts(),V0=Pc(),G0=Yi(),uo=W(),X0=re(),Q0=Rt(),Ic=class extends G0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(uo.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=co(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=co(e);if(typeof r!="number")return;let s=this.items[r];return!n&&uo.isScalar(s)?s.value:s}has(e){let n=co(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=co(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];uo.isScalar(s)&&X0.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(Q0.toJS(i,String(s++),n));return r}toString(e,n,r){return e?V0.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(Y0.createNode(a,void 0,r))}}return i}};function co(t){let e=uo.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}tm.YAMLSeq=Ic});var Gn=I(rm=>{"use strict";var Z0=W(),nm=Bt(),eE={collection:"seq",default:!0,nodeClass:nm.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Z0.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>nm.YAMLSeq.from(t,e,n)};rm.seq=eE});var us=I(sm=>{"use strict";var tE=is(),nE={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),tE.stringifyString(t,e,n,r)}};sm.string=nE});var fo=I(am=>{"use strict";var im=re(),om={identify:t=>t==null,createNode:()=>new im.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new im.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&om.test.test(t)?t:e.options.nullStr};am.nullTag=om});var $c=I(cm=>{"use strict";var rE=re(),lm={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new rE.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&lm.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};cm.boolTag=lm});var Xn=I(um=>{"use strict";function sE({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}um.stringifyNumber=sE});var Lc=I(po=>{"use strict";var iE=re(),Nc=Xn(),oE={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:Nc.stringifyNumber},aE={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():Nc.stringifyNumber(t)}},lE={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new iE.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:Nc.stringifyNumber};po.float=lE;po.floatExp=aE;po.floatNaN=oE});var Dc=I(mo=>{"use strict";var dm=Xn(),ho=t=>typeof t=="bigint"||Number.isInteger(t),Mc=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function fm(t,e,n){let{value:r}=t;return ho(r)&&r>=0?n+r.toString(e):dm.stringifyNumber(t)}var cE={identify:t=>ho(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Mc(t,2,8,n),stringify:t=>fm(t,8,"0o")},uE={identify:ho,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Mc(t,0,10,n),stringify:dm.stringifyNumber},dE={identify:t=>ho(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Mc(t,2,16,n),stringify:t=>fm(t,16,"0x")};mo.int=uE;mo.intHex=dE;mo.intOct=cE});var hm=I(pm=>{"use strict";var fE=Vn(),pE=fo(),hE=Gn(),mE=us(),gE=$c(),Bc=Lc(),jc=Dc(),yE=[fE.map,hE.seq,mE.string,pE.nullTag,gE.boolTag,jc.intOct,jc.int,jc.intHex,Bc.floatNaN,Bc.floatExp,Bc.float];pm.schema=yE});var ym=I(gm=>{"use strict";var bE=re(),wE=Vn(),vE=Gn();function mm(t){return typeof t=="bigint"||Number.isInteger(t)}var go=({value:t})=>JSON.stringify(t),SE=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:go},{identify:t=>t==null,createNode:()=>new bE.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:go},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:go},{identify:mm,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})=>mm(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:go}],kE={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},xE=[wE.map,vE.seq].concat(SE,kE);gm.schema=xE});var Uc=I(bm=>{"use strict";var ds=Ii("buffer"),Fc=re(),EE=is(),AE={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof ds.Buffer=="function")return ds.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 ds.Buffer=="function")a=o instanceof ds.Buffer?o.toString("base64"):ds.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=Fc.Scalar.BLOCK_LITERAL),e!==Fc.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===Fc.Scalar.BLOCK_LITERAL?`
|
|
75
|
+
`:" ")}return EE.stringifyString({comment:t,type:e,value:a},r,s,i)}};bm.binary=AE});var wo=I(bo=>{"use strict";var yo=W(),qc=Lt(),TE=re(),CE=Bt();function wm(t,e){if(yo.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!yo.isPair(r)){if(yo.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new qc.Pair(new TE.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]=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
|
-
`)?(n.push("..."),n.push(
|
|
77
|
+
${i.comment}`:r.comment}r=s}t.items[n]=yo.isPair(r)?r:new qc.Pair(r)}}else e("Expected a sequence for this tag");return t}function vm(t,e,n){let{replacer:r}=n,s=new CE.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(qc.createPair(a,l,n))}return s}var OE={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:wm,createNode:vm};bo.createPairs=vm;bo.pairs=OE;bo.resolvePairs=wm});var Kc=I(Wc=>{"use strict";var Sm=W(),Jc=Rt(),fs=Dt(),PE=Bt(),km=wo(),un=class t extends PE.YAMLSeq{constructor(){super(),this.add=fs.YAMLMap.prototype.add.bind(this),this.delete=fs.YAMLMap.prototype.delete.bind(this),this.get=fs.YAMLMap.prototype.get.bind(this),this.has=fs.YAMLMap.prototype.has.bind(this),this.set=fs.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(Sm.isPair(s)?(i=Jc.toJS(s.key,"",n),o=Jc.toJS(s.value,i,n)):i=Jc.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=km.createPairs(e,n,r),i=new this;return i.items=s.items,i}};un.tag="tag:yaml.org,2002:omap";var _E={collection:"seq",identify:t=>t instanceof Map,nodeClass:un,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=km.resolvePairs(t,e),r=[];for(let{key:s}of n.items)Sm.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new un,n)},createNode:(t,e,n)=>un.from(t,e,n)};Wc.YAMLOMap=un;Wc.omap=_E});var Cm=I(Hc=>{"use strict";var xm=re();function Em({value:t,source:e},n){return e&&(t?Am:Tm).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Am={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 xm.Scalar(!0),stringify:Em},Tm={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 xm.Scalar(!1),stringify:Em};Hc.falseTag=Tm;Hc.trueTag=Am});var Om=I(vo=>{"use strict";var RE=re(),zc=Xn(),IE={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:zc.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():zc.stringifyNumber(t)}},NE={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.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:zc.stringifyNumber};vo.float=NE;vo.floatExp=$E;vo.floatNaN=IE});var _m=I(hs=>{"use strict";var Pm=Xn(),ps=t=>typeof t=="bigint"||Number.isInteger(t);function So(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 Yc(t,e,n){let{value:r}=t;if(ps(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return Pm.stringifyNumber(t)}var LE={identify:ps,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>So(t,2,2,n),stringify:t=>Yc(t,2,"0b")},ME={identify:ps,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>So(t,1,8,n),stringify:t=>Yc(t,8,"0")},DE={identify:ps,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>So(t,0,10,n),stringify:Pm.stringifyNumber},BE={identify:ps,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>So(t,2,16,n),stringify:t=>Yc(t,16,"0x")};hs.int=DE;hs.intBin=LE;hs.intHex=BE;hs.intOct=ME});var Gc=I(Vc=>{"use strict";var Eo=W(),ko=Lt(),xo=Dt(),dn=class t extends xo.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;Eo.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new ko.Pair(e.key,null):n=new ko.Pair(e,null),xo.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=xo.findPair(this.items,e);return!n&&Eo.isPair(r)?Eo.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=xo.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new ko.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(ko.createPair(o,null,r));return i}};dn.tag="tag:yaml.org,2002:set";var jE={collection:"map",identify:t=>t instanceof Set,nodeClass:dn,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>dn.from(t,e,n),resolve(t,e){if(Eo.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new dn,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Vc.YAMLSet=dn;Vc.set=jE});var Qc=I(Ao=>{"use strict";var FE=Xn();function Xc(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 Rm(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return FE.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 UE={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})=>Xc(t,n),stringify:Rm},qE={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=>Xc(t,!1),stringify:Rm},Im={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Im.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,r-1,s,i||0,o||0,a||0,l),f=e[8];if(f&&f!=="Z"){let d=Xc(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$/,"")??""};Ao.floatTime=qE;Ao.intTime=UE;Ao.timestamp=Im});var Lm=I(Nm=>{"use strict";var JE=Vn(),WE=fo(),KE=Gn(),HE=us(),zE=Uc(),$m=Cm(),Zc=Om(),To=_m(),YE=ro(),VE=Kc(),GE=wo(),XE=Gc(),eu=Qc(),QE=[JE.map,KE.seq,HE.string,WE.nullTag,$m.trueTag,$m.falseTag,To.intBin,To.intOct,To.int,To.intHex,Zc.floatNaN,Zc.floatExp,Zc.float,zE.binary,YE.merge,VE.omap,GE.pairs,XE.set,eu.intTime,eu.floatTime,eu.timestamp];Nm.schema=QE});var Km=I(ru=>{"use strict";var jm=Vn(),ZE=fo(),Fm=Gn(),eA=us(),tA=$c(),tu=Lc(),nu=Dc(),nA=hm(),rA=ym(),Um=Uc(),ms=ro(),qm=Kc(),Jm=wo(),Mm=Lm(),Wm=Gc(),Co=Qc(),Dm=new Map([["core",nA.schema],["failsafe",[jm.map,Fm.seq,eA.string]],["json",rA.schema],["yaml11",Mm.schema],["yaml-1.1",Mm.schema]]),Bm={binary:Um.binary,bool:tA.boolTag,float:tu.float,floatExp:tu.floatExp,floatNaN:tu.floatNaN,floatTime:Co.floatTime,int:nu.int,intHex:nu.intHex,intOct:nu.intOct,intTime:Co.intTime,map:jm.map,merge:ms.merge,null:ZE.nullTag,omap:qm.omap,pairs:Jm.pairs,seq:Fm.seq,set:Wm.set,timestamp:Co.timestamp},sA={"tag:yaml.org,2002:binary":Um.binary,"tag:yaml.org,2002:merge":ms.merge,"tag:yaml.org,2002:omap":qm.omap,"tag:yaml.org,2002:pairs":Jm.pairs,"tag:yaml.org,2002:set":Wm.set,"tag:yaml.org,2002:timestamp":Co.timestamp};function iA(t,e,n){let r=Dm.get(e);if(r&&!t)return n&&!r.includes(ms.merge)?r.concat(ms.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(Dm.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(ms.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Bm[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Bm).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},[])}ru.coreKnownTags=sA;ru.getTags=iA});var ou=I(Hm=>{"use strict";var su=W(),oA=Vn(),aA=Gn(),lA=us(),Oo=Km(),cA=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,iu=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?Oo.getTags(e,"compat"):e?Oo.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?Oo.coreKnownTags:{},this.tags=Oo.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,su.MAP,{value:oA.map}),Object.defineProperty(this,su.SCALAR,{value:lA.string}),Object.defineProperty(this,su.SEQ,{value:aA.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?cA:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Hm.Schema=iu});var Ym=I(zm=>{"use strict";var uA=W(),au=os(),gs=ns();function dA(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=au.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(gs.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(uA.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let f=i(t.contents.commentBefore);n.push(gs.indentComment(f,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=au.stringify(t.contents,s,()=>a=null,l);a&&(c+=gs.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(au.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
|
|
78
|
+
`)?(n.push("..."),n.push(gs.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(gs.indentComment(i(l),"")))}return n.join(`
|
|
79
79
|
`)+`
|
|
80
|
-
`}
|
|
80
|
+
`}zm.stringifyDocument=dA});var ys=I(Vm=>{"use strict";var fA=es(),Qn=Yi(),Be=W(),pA=Lt(),hA=Rt(),mA=ou(),gA=Ym(),lu=Wi(),yA=fc(),bA=ts(),cu=dc(),uu=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Be.NODE_TYPE,{value:Be.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 cu.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,{[Be.NODE_TYPE]:{value:Be.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=Be.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Zn(this.contents)&&this.contents.add(e)}addIn(e,n){Zn(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=lu.anchorNames(this);e.anchor=!n||r.has(n)?lu.findNewAnchor(n||"a",r):n}return new fA.Alias(e.anchor)}createNode(e,n,r){let s;if(typeof n=="function")e=n.call({"":e},"",e),s=n;else if(Array.isArray(n)){let g=C=>typeof C=="number"||C instanceof String||C instanceof Number,b=n.filter(g).map(String);b.length>0&&(n=n.concat(b)),s=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=r??{},{onAnchor:d,setAnchors:u,sourceObjects:p}=lu.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},m=bA.createNode(e,f,h);return a&&Be.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 pA.Pair(s,i)}delete(e){return Zn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Qn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Zn(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return Be.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Qn.isEmptyPath(e)?!n&&Be.isScalar(this.contents)?this.contents.value:this.contents:Be.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return Be.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Qn.isEmptyPath(e)?this.contents!==void 0:Be.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Qn.collectionFromPath(this.schema,[e],n):Zn(this.contents)&&this.contents.set(e,n)}setIn(e,n){Qn.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=Qn.collectionFromPath(this.schema,Array.from(e),n):Zn(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new cu.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 cu.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 mA.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=hA.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"?yA.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 gA.stringifyDocument(this,e)}};function Zn(t){if(Be.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Vm.Document=uu});var vs=I(ws=>{"use strict";var bs=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},du=class extends bs{constructor(e,n,r){super("YAMLParseError",e,n,r)}},fu=class extends bs{constructor(e,n,r){super("YAMLWarning",e,n,r)}},wA=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:s}=n.linePos[0];n.message+=` at line ${r}, column ${s}`;let i=s-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(o.substring(0,i))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
81
81
|
`),o=a+o}if(/[^ ]/.test(o)){let a=1,l=n.linePos[1];l?.line===r&&l.col>s&&(a=Math.max(1,Math.min(l.col-s,80-i)));let c=" ".repeat(i)+"^".repeat(a);n.message+=`:
|
|
82
82
|
|
|
83
83
|
${o}
|
|
84
84
|
${c}
|
|
85
|
-
`}};
|
|
86
|
-
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(
|
|
87
|
-
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||
|
|
88
|
-
`+
|
|
89
|
-
`+
|
|
90
|
-
`+_:k.comment=_,
|
|
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}
|
|
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,
|
|
94
|
-
`;for(let m=f;m<a;++m){let[g,
|
|
95
|
-
`):g.length>l||
|
|
85
|
+
`}};ws.YAMLError=bs;ws.YAMLParseError=du;ws.YAMLWarning=fu;ws.prettifyError=wA});var Ss=I(Gm=>{"use strict";function vA(t,{flow:e,indicator:n,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,d="",u="",p=!1,h=!1,m=null,g=null,b=null,C=null,T=null,E=null,$=null;for(let k of t)switch(h&&(k.type!=="space"&&k.type!=="newline"&&k.type!=="comma"&&i(k.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h=!1),m&&(c&&k.type!=="comment"&&k.type!=="newline"&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),k.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&k.source.includes(" ")&&(m=k),f=!0;break;case"comment":{f||i(k,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let N=k.source.substring(1)||" ";d?d+=u+N:d=N,u="",c=!1;break}case"newline":c?d?d+=k.source:(!E||n!=="seq-item-ind")&&(l=!0):u+=k.source,c=!0,p=!0,(g||b)&&(C=k),f=!0;break;case"anchor":g&&i(k,"MULTIPLE_ANCHORS","A node can have at most one anchor"),k.source.endsWith(":")&&i(k.offset+k.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=k,$??($=k.offset),c=!1,f=!1,h=!0;break;case"tag":{b&&i(k,"MULTIPLE_TAGS","A node can have at most one tag"),b=k,$??($=k.offset),c=!1,f=!1,h=!0;break}case n:(g||b)&&i(k,"BAD_PROP_ORDER",`Anchors and tags must be after the ${k.source} indicator`),E&&i(k,"UNEXPECTED_TOKEN",`Unexpected ${k.source} in ${e??"collection"}`),E=k,c=n==="seq-item-ind"||n==="explicit-key-ind",f=!1;break;case"comma":if(e){T&&i(k,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),T=k,c=!1,f=!1;break}default:i(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),c=!1,f=!1}let P=t[t.length-1],_=P?P.offset+P.source.length:s;return h&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&i(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&i(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:T,found:E,spaceBefore:l,comment:d,hasNewline:p,anchor:g,tag:b,newlineAfterProp:C,end:_,start:$??_}}Gm.resolveProps=vA});var Po=I(Xm=>{"use strict";function pu(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(pu(e.key)||pu(e.value))return!0}return!1;default:return!0}}Xm.containsNewline=pu});var hu=I(Qm=>{"use strict";var SA=Po();function kA(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&SA.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Qm.flowIndentCheck=kA});var mu=I(eg=>{"use strict";var Zm=W();function xA(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Zm.isScalar(i)&&Zm.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}eg.mapIncludes=xA});var og=I(ig=>{"use strict";var tg=Lt(),EA=Dt(),ng=Ss(),AA=Po(),rg=hu(),TA=mu(),sg="All mapping items must start at the same column";function CA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??EA.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let l=r.offset,c=null;for(let f of r.items){let{start:d,key:u,sep:p,value:h}=f,m=ng.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",sg)),!m.anchor&&!m.tag&&!p){c=m.end,m.comment&&(a.comment?a.comment+=`
|
|
87
|
+
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||AA.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",sg);n.atKey=!0;let b=m.end,C=u?t(n,u,m,s):e(n,b,d,null,m,s);n.schema.compat&&rg.flowIndentCheck(r.indent,u,s),n.atKey=!1,TA.mapIncludes(n,a.items,C)&&s(b,"DUPLICATE_KEY","Map keys must be unique");let T=ng.resolveProps(p??[],{indicator:"map-value-ind",next:h,offset:C.range[2],onError:s,parentIndent:r.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=T.end,T.found){g&&(h?.type==="block-map"&&!T.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<T.found.offset-1024&&s(C.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let E=h?t(n,h,T,s):e(n,l,p,null,T,s);n.schema.compat&&rg.flowIndentCheck(r.indent,h,s),l=E.range[2];let $=new tg.Pair(C,E);n.options.keepSourceTokens&&($.srcToken=f),a.items.push($)}else{g&&s(C.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),T.comment&&(C.comment?C.comment+=`
|
|
88
|
+
`+T.comment:C.comment=T.comment);let E=new tg.Pair(C);n.options.keepSourceTokens&&(E.srcToken=f),a.items.push(E)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}ig.resolveBlockMap=CA});var lg=I(ag=>{"use strict";var OA=Bt(),PA=Ss(),_A=hu();function RA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??OA.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=PA.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&&_A.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}ag.resolveBlockSeq=RA});var er=I(cg=>{"use strict";function IA(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}}cg.resolveEnd=IA});var pg=I(fg=>{"use strict";var $A=W(),NA=Lt(),ug=Dt(),LA=Bt(),MA=er(),dg=Ss(),DA=Po(),BA=mu(),gu="Block collections are not allowed within flow collections",yu=t=>t&&(t.type==="block-map"||t.type==="block-seq");function jA({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?ug.YAMLMap:LA.YAMLSeq),c=new l(n.schema);c.flow=!0;let f=n.atRoot;f&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let d=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let b=r.items[g],{start:C,key:T,sep:E,value:$}=b,P=dg.resolveProps(C,{flow:a,indicator:"explicit-key-ind",next:T??E?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!P.found){if(!P.anchor&&!P.tag&&!E&&!$){g===0&&P.comma?s(P.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<r.items.length-1&&s(P.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),P.comment&&(c.comment?c.comment+=`
|
|
89
|
+
`+P.comment:c.comment=P.comment),d=P.end;continue}!o&&n.options.strict&&DA.containsNewline(T)&&s(T,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)P.comma&&s(P.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(P.comma||s(P.start,"MISSING_CHAR",`Missing , between ${a} items`),P.comment){let _="";e:for(let k of C)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];$A.isPair(k)&&(k=k.value??k.key),k.comment?k.comment+=`
|
|
90
|
+
`+_:k.comment=_,P.comment=P.comment.substring(_.length+1)}}if(!o&&!E&&!P.found){let _=$?t(n,$,P,s):e(n,P.end,E,null,P,s);c.items.push(_),d=_.range[2],yu($)&&s(_.range,"BLOCK_IN_FLOW",gu)}else{n.atKey=!0;let _=P.end,k=T?t(n,T,P,s):e(n,_,C,null,P,s);yu(T)&&s(k.range,"BLOCK_IN_FLOW",gu),n.atKey=!1;let N=dg.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:$,offset:k.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(N.found){if(!o&&!P.found&&n.options.strict){if(E)for(let q of E){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}}P.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,E,null,N,s):null;B?yu($)&&s(B.range,"BLOCK_IN_FLOW",gu):N.comment&&(k.comment?k.comment+=`
|
|
91
|
+
`+N.comment:k.comment=N.comment);let Z=new NA.Pair(k,B);if(n.options.keepSourceTokens&&(Z.srcToken=b),o){let q=c;BA.mapIncludes(n,q.items,k)&&s(_,"DUPLICATE_KEY","Map keys must be unique"),q.items.push(Z)}else{let q=new ug.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),b=f?`${g} must end with a ${u}`:`${g} in block collection must be sufficiently indented and end with a ${u}`;s(d,f?"MISSING_CHAR":"BAD_INDENT",b),p&&p.source.length!==1&&h.unshift(p)}if(h.length>0){let g=MA.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}fg.resolveFlowCollection=jA});var mg=I(hg=>{"use strict";var FA=W(),UA=re(),qA=Dt(),JA=Bt(),WA=og(),KA=lg(),HA=pg();function bu(t,e,n,r,s,i){let o=n.type==="block-map"?WA.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?KA.resolveBlockSeq(t,e,n,r,i):HA.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 zA(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===qA.YAMLMap.tagName&&a==="map"||o===JA.YAMLSeq.tagName&&a==="seq")return bu(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),bu(t,e,n,s,o)}let c=bu(t,e,n,s,o,l),f=l.resolve?.(c,u=>s(i,"TAG_RESOLVE_FAILED",u),e.options)??c,d=FA.isNode(f)?f:new UA.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}hg.composeCollection=zA});var vu=I(gg=>{"use strict";var wu=re();function YA(t,e,n){let r=e.offset,s=VA(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?wu.Scalar.BLOCK_FOLDED:wu.Scalar.BLOCK_LITERAL,o=e.source?GA(e.source):[],a=o.length;for(let m=o.length-1;m>=0;--m){let g=o[m][1];if(g===""||g==="\r")a=m;else break}if(a===0){let m=s.chomp==="+"&&o.length>0?`
|
|
93
|
+
`.repeat(Math.max(1,o.length-1)):"",g=r+s.length;return e.source&&(g+=e.source.length),{value:m,type:i,comment:s.comment,range:[r,g,g]}}let l=e.indent+s.indent,c=e.offset+s.length,f=0;for(let m=0;m<a;++m){let[g,b]=o[m];if(b===""||b==="\r")s.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&n(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(l=g.length),f=m,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+b.length+1}for(let m=o.length-1;m>=a;--m)o[m][0].length>l&&(a=m+1);let d="",u="",p=!1;for(let m=0;m<f;++m)d+=o[m][0].slice(l)+`
|
|
94
|
+
`;for(let m=f;m<a;++m){let[g,b]=o[m];c+=g.length+b.length+1;let C=b[b.length-1]==="\r";if(C&&(b=b.slice(0,-1)),b&&g.length<l){let E=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-b.length-(C?2:1),"BAD_INDENT",E),g=""}i===wu.Scalar.BLOCK_LITERAL?(d+=u+g.slice(l)+b,u=`
|
|
95
|
+
`):g.length>l||b[0]===" "?(u===" "?u=`
|
|
96
96
|
`:!p&&u===`
|
|
97
97
|
`&&(u=`
|
|
98
98
|
|
|
99
|
-
`),d+=u+g.slice(l)+
|
|
100
|
-
`,p=!0):
|
|
99
|
+
`),d+=u+g.slice(l)+b,u=`
|
|
100
|
+
`,p=!0):b===""?u===`
|
|
101
101
|
`?d+=`
|
|
102
102
|
`:u=`
|
|
103
|
-
`:(d+=u+
|
|
103
|
+
`:(d+=u+b,u=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let m=a;m<o.length;++m)d+=`
|
|
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 VA({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 GA(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}gg.resolveBlockScalar=YA});var ku=I(bg=>{"use strict";var Su=re(),XA=er();function QA(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=Su.Scalar.PLAIN,l=ZA(i,c);break;case"single-quoted-scalar":a=Su.Scalar.QUOTE_SINGLE,l=eT(i,c);break;case"double-quoted-scalar":a=Su.Scalar.QUOTE_DOUBLE,l=tT(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=XA.resolveEnd(o,f,e,n);return{value:l,type:a,comment:d.comment,range:[r,f,d.offset]}}function ZA(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}`),yg(t)}function eT(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),yg(t.slice(1,-1)).replace(/''/g,"'")}function yg(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 tT(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}=nT(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=rT[i];if(o)n+=o;else if(i===`
|
|
114
114
|
`)for(i=t[r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="\r"&&t[r+1]===`
|
|
115
|
-
`)for(i=t[++r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];n+=
|
|
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+=sT(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 nT(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 rT={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
122
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function sT(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)}bg.resolveFlowScalar=QA});var Sg=I(vg=>{"use strict";var fn=W(),wg=re(),iT=vu(),oT=ku();function aT(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?iT.resolveBlockScalar(t,e,r):oT.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[fn.SCALAR]:l?c=lT(t.schema,s,l,n,r):e.type==="scalar"?c=cT(t,s,e,r):c=t.schema[fn.SCALAR];let f;try{let d=c.resolve(s,u=>r(n??e,"TAG_RESOLVE_FAILED",u),t.options);f=fn.isScalar(d)?d:new wg.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);r(n??e,"TAG_RESOLVE_FAILED",u),f=new wg.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 lT(t,e,n,r,s){if(n==="!")return t[fn.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[fn.SCALAR])}function cT({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[fn.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[fn.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}vg.composeScalar=aT});var xg=I(kg=>{"use strict";function uT(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}kg.emptyScalarPosition=uT});var Tg=I(Eu=>{"use strict";var dT=es(),fT=W(),pT=mg(),Eg=Sg(),hT=er(),mT=xg(),gT={composeNode:Ag,composeEmptyNode:xu};function Ag(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=yT(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=Eg.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=pT.composeCollection(gT,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=xu(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&&(!fT.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 xu(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:mT.emptyScalarPosition(e,n,r),indent:-1,source:""},d=Eg.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 yT({options:t},{offset:e,source:n,end:r},s){let i=new dT.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=hT.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Eu.composeEmptyNode=xu;Eu.composeNode=Ag});var Pg=I(Og=>{"use strict";var bT=ys(),Cg=Tg(),wT=er(),vT=Ss();function ST(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new bT.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=vT.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?Cg.composeNode(c,s,f,o):Cg.composeEmptyNode(c,f.end,r,null,f,o);let d=l.contents.range[2],u=wT.resolveEnd(i,d,!1,o);return u.comment&&(l.comment=u.comment),l.range=[n,d,u.offset],l}Og.composeDoc=ST});var Tu=I(Ig=>{"use strict";var kT=Ii("process"),xT=dc(),ET=ys(),ks=vs(),_g=W(),AT=Pg(),TT=er();function xs(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 Rg(t){let e="",n=!1,r=!1;for(let s=0;s<t.length;++s){let i=t[s];switch(i[0]){case"#":e+=(e===""?"":r?`
|
|
123
123
|
|
|
124
124
|
`:`
|
|
125
|
-
`)+(i.substring(1)||" "),n=!0,r=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var
|
|
126
|
-
${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(
|
|
125
|
+
`)+(i.substring(1)||" "),n=!0,r=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var Au=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=xs(n);i?this.warnings.push(new ks.YAMLWarning(o,r,s)):this.errors.push(new ks.YAMLParseError(o,r,s))},this.directives=new xT.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=Rg(this.prelude);if(r){let i=e.contents;if(n)e.comment=e.comment?`${e.comment}
|
|
126
|
+
${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(_g.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];_g.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
|
|
127
127
|
${a}`:r}else{let o=i.commentBefore;i.commentBefore=o?`${r}
|
|
128
|
-
${o}`:r}}n?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
129
|
-
${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new
|
|
128
|
+
${o}`:r}}n?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Rg(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(kT.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=xs(e);i[0]+=n,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=AT.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 ks.YAMLParseError(xs(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 ks.YAMLParseError(xs(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=TT.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 ks.YAMLParseError(xs(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),s=new ET.Document(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,n,n],this.decorate(s,!1),yield s}}};Ig.Composer=Au});var Lg=I(_o=>{"use strict";var CT=vu(),OT=ku(),PT=vs(),$g=is();function _T(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 PT.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return OT.resolveFlowScalar(t,e,r);case"block-scalar":return CT.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function RT(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=$g.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
|
-
`,u=[{type:"block-scalar-header",offset:i,indent:r,source:f}];return
|
|
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
|
|
132
|
+
`,u=[{type:"block-scalar-header",offset:i,indent:r,source:f}];return Ng(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 IT(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=$g.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">":$T(t,l);break;case'"':Cu(t,l,"double-quoted-scalar");break;case"'":Cu(t,l,"single-quoted-scalar");break;default:Cu(t,l,"scalar")}}function $T(t,e){let n=e.indexOf(`
|
|
134
134
|
`),r=e.substring(0,n),s=e.substring(n+1)+`
|
|
135
|
-
`;if(t.type==="block-scalar"){let i=t.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=r,t.source=s}else{let{offset:i}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:r}];
|
|
136
|
-
`});for(let l of Object.keys(t))l!=="type"&&l!=="offset"&&delete t[l];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:s})}}function
|
|
137
|
-
`};delete t.items,Object.assign(t,{type:n,source:e,end:[s]});break}default:{let r="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(t))i!=="type"&&i!=="offset"&&delete t[i];Object.assign(t,{type:n,indent:r,source:e,end:s})}}}
|
|
135
|
+
`;if(t.type==="block-scalar"){let i=t.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=r,t.source=s}else{let{offset:i}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:r}];Ng(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 Ng(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 Cu(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})}}}_o.createScalarToken=RT;_o.resolveAsScalar=_T;_o.setScalarValue=IT});var Dg=I(Mg=>{"use strict";var NT=t=>"type"in t?Io(t):Ro(t);function Io(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=Io(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=Ro(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=Ro(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=Ro(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 Ro({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=Io(e)),n)for(let i of n)s+=i.source;return r&&(s+=Io(r)),s}Mg.stringify=NT});var Ug=I(Fg=>{"use strict";var Ou=Symbol("break visit"),LT=Symbol("skip children"),Bg=Symbol("remove item");function pn(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),jg(Object.freeze([]),t,e)}pn.BREAK=Ou;pn.SKIP=LT;pn.REMOVE=Bg;pn.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};pn.parentCollection=(t,e)=>{let n=pn.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 jg(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=jg(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===Ou)return Ou;a===Bg&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}Fg.visit=pn});var $o=I(Te=>{"use strict";var Pu=Lg(),MT=Dg(),DT=Ug(),_u="\uFEFF",Ru="",Iu="",$u="",BT=t=>!!t&&"items"in t,jT=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function FT(t){switch(t){case _u:return"<BOM>";case Ru:return"<DOC>";case Iu:return"<FLOW_END>";case $u:return"<SCALAR>";default:return JSON.stringify(t)}}function UT(t){switch(t){case _u:return"byte-order-mark";case Ru:return"doc-mode";case Iu:return"flow-error-end";case $u: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
|
|
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=Pu.createScalarToken;Te.resolveAsScalar=Pu.resolveAsScalar;Te.setScalarValue=Pu.setScalarValue;Te.stringify=MT.stringify;Te.visit=DT.visit;Te.BOM=_u;Te.DOCUMENT=Ru;Te.FLOW_END=Iu;Te.SCALAR=$u;Te.isCollection=BT;Te.isScalar=jT;Te.prettyToken=FT;Te.tokenType=UT});var Mu=I(Jg=>{"use strict";var Es=$o();function Ge(t){switch(t){case void 0:case" ":case`
|
|
140
|
+
`:case"\r":case" ":return!0;default:return!1}}var qg=new Set("0123456789ABCDEFabcdef"),qT=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),No=new Set(",[]{}"),JT=new Set(` ,[]{}
|
|
141
|
+
\r `),Nu=t=>!t||JT.has(t),Lu=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
|
|
142
142
|
`?!0:n==="\r"?this.buffer[e+1]===`
|
|
143
143
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let r=0;for(;n===" ";)n=this.buffer[++r+e];if(n==="\r"){let s=this.buffer[r+e+1];if(s===`
|
|
144
144
|
`||!s&&!this.atEnd)return e+r+1}return n===`
|
|
145
|
-
`||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&
|
|
146
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===
|
|
145
|
+
`||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&Ge(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]===Es.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 Es.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==="...")&&Ge(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&&!Ge(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===":")&&Ge(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(Nu),"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("..."))&&Ge(s[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield Es.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(Nu),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Ge(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let i=0;for(;this.buffer[n-1-i]==="\\";)i+=1;if(i%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),s=r.indexOf(`
|
|
147
147
|
`,this.pos);if(s!==-1){for(;s!==-1;){let i=this.continueScalar(s+1);if(i===-1)break;s=r.indexOf(`
|
|
148
|
-
`,i)}s!==-1&&(n=s-(r[s-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>
|
|
148
|
+
`,i)}s!==-1&&(n=s-(r[s-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>Ge(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,r;e:for(let i=this.pos;r=this.buffer[i];++i)switch(r){case" ":n+=1;break;case`
|
|
149
149
|
`:e=i,n=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
150
150
|
`)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
|
|
151
151
|
`,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;for(r=this.buffer[s];r===" ";)r=this.buffer[++s];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
|
|
152
152
|
`;)r=this.buffer[++s];e=s-1}else if(!this.blockScalarKeep)do{let i=e-1,o=this.buffer[i];o==="\r"&&(o=this.buffer[--i]);let a=i;for(;o===" ";)o=this.buffer[--i];if(o===`
|
|
153
|
-
`&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield
|
|
153
|
+
`&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield Es.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(Ge(i)||e&&No.has(i))break;n=r}else if(Ge(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&&No.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&&No.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield Es.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(Nu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(Ge(n)||e&&No.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(;!Ge(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(qT.has(n))n=this.buffer[++e];else if(n==="%"&&qg.has(this.buffer[e+1])&&qg.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
157
157
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
158
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let s=n-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=n),s}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};
|
|
158
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let s=n-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=n),s}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};Jg.Lexer=Lu});var Bu=I(Wg=>{"use strict";var Du=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}}}};Wg.LineCounter=Du});var Fu=I(Vg=>{"use strict";var WT=Ii("process"),Kg=$o(),KT=Mu();function jt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function Hg(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 Yg(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 Lo(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function tr(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function zg(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,Yg(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 ju=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 KT.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,WT.env.LOG_TOKENS&&console.log("|",Kg.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=Kg.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"&&zg(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&&Hg(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":{Hg(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=Lo(this.peek(2)),r=tr(n),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
|
|
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(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(
|
|
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(Yg(n.key)&&!jt(n.sep,"newline")){let o=tr(n.start),a=n.key,l=n.sep;l.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else i.length>0?n.sep=n.sep.concat(i,this.sourceToken):n.sep.push(this.sourceToken);else if(jt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=tr(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||s?e.items.push({start:i,key:null,sep:[this.sourceToken]}):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=Lo(r),i=tr(s);zg(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
|
|
161
161
|
`)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
|
|
162
|
-
`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n
|
|
163
|
-
`),n=e.trim();if(
|
|
162
|
+
`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=Lo(e),r=tr(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=Lo(e),r=tr(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Vg.Parser=ju});var ey=I(Ts=>{"use strict";var Gg=Tu(),HT=ys(),As=vs(),zT=Ec(),YT=W(),VT=Bu(),Xg=Fu();function Qg(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new VT.LineCounter||null,prettyErrors:e}}function GT(t,e={}){let{lineCounter:n,prettyErrors:r}=Qg(e),s=new Xg.Parser(n?.addNewLine),i=new Gg.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(As.prettifyError(t,n)),a.warnings.forEach(As.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Zg(t,e={}){let{lineCounter:n,prettyErrors:r}=Qg(e),s=new Xg.Parser(n?.addNewLine),i=new Gg.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 As.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(As.prettifyError(t,n)),o.warnings.forEach(As.prettifyError(t,n))),o}function XT(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=Zg(t,n);if(!s)return null;if(s.warnings.forEach(i=>zT.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 QT(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 YT.isDocument(t)&&!r?t.toString(n):new HT.Document(t,r,n).toString(n)}Ts.parse=XT;Ts.parseAllDocuments=GT;Ts.parseDocument=Zg;Ts.stringify=QT});var ny=I(H=>{"use strict";var ZT=Tu(),eC=ys(),tC=ou(),Uu=vs(),nC=es(),Ft=W(),rC=Lt(),sC=re(),iC=Dt(),oC=Bt(),aC=$o(),lC=Mu(),cC=Bu(),uC=Fu(),Mo=ey(),ty=Gr();H.Composer=ZT.Composer;H.Document=eC.Document;H.Schema=tC.Schema;H.YAMLError=Uu.YAMLError;H.YAMLParseError=Uu.YAMLParseError;H.YAMLWarning=Uu.YAMLWarning;H.Alias=nC.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=rC.Pair;H.Scalar=sC.Scalar;H.YAMLMap=iC.YAMLMap;H.YAMLSeq=oC.YAMLSeq;H.CST=aC;H.Lexer=lC.Lexer;H.LineCounter=cC.LineCounter;H.Parser=uC.Parser;H.parse=Mo.parse;H.parseAllDocuments=Mo.parseAllDocuments;H.parseDocument=Mo.parseDocument;H.stringify=Mo.stringify;H.visit=ty.visit;H.visitAsync=ty.visitAsync});function fC(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function pC(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(dC);return n?Vr(e,n[1])!==null:!1}function hC(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=ry.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function sy(t){return fC(t)||pC(t)||hC(t)}var ry,dC,qu=S(()=>{hh();ry=bx(ny(),1),dC=/<([a-zA-Z_][\w.-]*)/});function mC(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
|
|
163
|
+
`),n=e.trim();if(sy(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 Do(t){return mC(t).map(e=>e.text)}var iy,oy=S(()=>{qu();iy=`
|
|
167
167
|
|
|
168
168
|
|
|
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; }
|
|
169
|
+
`});function Bo(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ay=S(()=>{});var gC,yC,Ju,ly=S(()=>{gC=[["\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","-"]],yC=new Map(gC),Ju=yC});var cy,jo,Wu,uy=S(()=>{cy=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],jo={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:cy,nb:cy,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(jo))jo[t]=new Map(jo[t]);Wu=jo});function Ku(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=wC(e.locale),r=Ju,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Ju),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=bC(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var bC,wC,dy=S(()=>{ly();uy();bC=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},wC=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return Wu[e]||Wu[e.split("-")[0]]||void 0}});var vC,fy,py=S(()=>{vC=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],fy=vC});function Hu(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([...fy,...e.customReplacements]);t=Ku(t,{customReplacements:i,locale:e.locale})}else if(e.customReplacements.length>0)for(let[i,o]of e.customReplacements)t=t.replaceAll(i,o);e.decamelize&&(t=SC(t));let s=xC(e);return e.lowercase&&(t=e.locale?t.toLocaleLowerCase(e.locale):t.toLowerCase()),t=t.replaceAll(/([a-zA-Z\d]+)['\u2019]([ts])(\s|$)/g,"$1$2$3"),t=t.replace(s,e.separator),t=t.replaceAll("\\",""),e.separator&&(t=kC(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var SC,kC,xC,hy=S(()=>{ay();dy();py();SC=t=>t.replaceAll(/([A-Z]{2,})(\d+)/g,"$1 $2").replaceAll(/([a-z\d]+)([A-Z]{2,})/g,"$1 $2").replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").replaceAll(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,"$1 $2"),kC=(t,e)=>{let n=Bo(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},xC=t=>{let e=String.raw`a-z\d`;if(e+=t.lowercase?"":"A-Z",t.transliterate===!1&&(e+=String.raw`\p{L}\p{N}`),t.preserveCharacters.length>0)for(let r of t.preserveCharacters){if(r===t.separator)throw new Error(`The separator character \`${t.separator}\` cannot be included in preserved characters: ${t.preserveCharacters}`);e+=Bo(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function nr(t){return Hu(t)}var my=S(()=>{hy()});var rr,gy,yy=S(()=>{rr={local:"local",ide:"ide",published:"published",inline:"inline"},gy=Object.values(rr).map(t=>`'${t}'`).join(" | ")});var Cs,zu,by=S(()=>{Cs=` *, *::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; }`,zu=" html, body { height: 100%; }"});var wy,vy=S(()=>{wy=`(function () {
|
|
174
174
|
var W = window, D = document;
|
|
175
175
|
var TAIL_MS = 1500, TOL = 2, THROTTLE_MS = 200;
|
|
176
176
|
var SCROLL_KEYS = { ' ': 1, ArrowUp: 1, ArrowDown: 1, PageUp: 1, PageDown: 1, Home: 1, End: 1 };
|
|
@@ -238,7 +238,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
|
|
|
238
238
|
top: function () { disarm(); write(0); report(0); },
|
|
239
239
|
flush: flush
|
|
240
240
|
};
|
|
241
|
-
})();`});var
|
|
241
|
+
})();`});var Sy,ky=S(()=>{Sy=`(function () {
|
|
242
242
|
var W = window;
|
|
243
243
|
var rtData, rtInsight, rtHasInsight = false;
|
|
244
244
|
var applyData, applyInsight, send;
|
|
@@ -292,51 +292,51 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
|
|
|
292
292
|
return publish();
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
|
-
})();`});var te=S(()=>{
|
|
296
|
-
\u2026[${t.length-
|
|
297
|
-
`).map(i=>i.trim()).filter(Boolean),n=e[0];if(!n)return"";let r=n.length>300?n.slice(0,300).trimEnd()+"\u2026":n,s=e.length-1;return s>0?r+
|
|
298
|
-
`);o.partial&&a.shift();let l=[];for(let 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:
|
|
299
|
-
`))if(e.includes('"modelId"'))try{let n=JSON.parse(e).attachment?.identity?.modelId;if(n)return n}catch{}}function
|
|
300
|
-
`):t==null?"":Re(JSON.stringify(t))}function
|
|
295
|
+
})();`});var te=S(()=>{Li();nc();rh();ah();qu();oy();my();yy();by();vy();ky();Mi()});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 Ay(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 Ty(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function Cy(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 Vu(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var ee,Os,Ey,Ps=S(()=>{"use strict";ee=t=>typeof t=="string"?t:void 0,Os=t=>t.replace(/\u001b\[[0-9;]*m/g,""),Ey=t=>` (+${t} line${t===1?"":"s"})`});function Re(t){return t.length>Gu?t.slice(0,Gu)+`
|
|
296
|
+
\u2026[${t.length-Gu} more characters truncated]`:t}function je(t){let e=Os(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+Ey(s):r}var Gu,Ce,Fo,_s=S(()=>{"use strict";Ps();Gu=5e4,Ce=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;Fo=(t,e)=>``});import{closeSync as Oy,existsSync as EC,fstatSync as AC,openSync as Py,readdirSync as TC,readSync as _y,statSync as CC}from"fs";import{join as OC}from"path";function sr(t,e){let n;try{n=Py(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=_y(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{Oy(n)}}function Uo(t,e){let n;try{n=Py(t,"r")}catch{return}try{let r=AC(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=_y(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{Oy(n)}}function qo(t){if(!EC(t))return[];let e;try{e=TC(t)}catch{return[]}let n=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=OC(t,r);try{let i=CC(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Jo=S(()=>{"use strict"});var Ut,Wo=S(()=>{"use strict";Ut=class{ensureHarnessSupport(){}forRead(){return this}linker(){return{link(){}}}}});import{openSync as PC,readSync as _C,closeSync as RC,statSync as Ly,readdirSync as My,readFileSync as Dy,existsSync as IC}from"fs";import{join as hn}from"path";import{homedir as $C}from"os";function NC(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function MC(t,e,n){let r=hn(Xu(t,e),n,LC),s;try{s=My(r)}catch{return[]}let i=iO(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=hn(r,a),c;try{c=Ly(l)}catch{continue}let f=a.slice(0,-6),d={};try{d=JSON.parse(Dy(hn(r,`${f}.meta.json`),"utf8"))}catch{}let u=jC(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===DC?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 jC(t,e,n){let r=Ry.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of BC){let o=Uo(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:By(l),failing:!!c?.isApiErrorMessage,stopped:UC(l)},!(s.tokens===void 0&&o.partial))break}return s.model??=FC(t),Ry.set(t,{size:e,mtime:n,...s}),s}function FC(t){for(let e of(sr(t,256*1024)?.text??"").split(`
|
|
299
|
+
`))if(e.includes('"modelId"'))try{let n=JSON.parse(e).attachment?.identity?.modelId;if(n)return n}catch{}}function By(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(qC(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(!Zu(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 UC(t){let e;for(let s of t)(s.type==="user"||s.type==="assistant")&&(e=s);let n=e?.type==="user"&&!Zu(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 qC(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 Ho(t){let e=t?.type==="image"?t.source:void 0;return e?.type==="base64"&&e.data?Fo(e.data,e.media_type):""}function Rs(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?Rs(n.content):Ho(n)}).join(`
|
|
300
|
+
`):t==null?"":Re(JSON.stringify(t))}function jy(t){let e=t.trim();return!!e&&JC.some(n=>n.exec(e)?.index===0)}function WC(t){return!t.trim()||jy(t)}function HC(t){return t.replace(KC,"")}function zC(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=HC(t).trim();return e?zC(e)??(jy(e)?"":e):""}function zo(t){let e=YC.exec(t.trim());if(e)return{from:e[1],body:GC(e[2].replace(VC,""))}}function GC(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":
|
|
303
|
+
`):t}function Ko(t){let e=zo(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function XC(t){let e=t.message?.content;return typeof e=="string"&&!!zo(e)}function QC(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith(Iy)?e.slice(Iy.length).trim():void 0}function Qu(t){return t?.type==="text"&&typeof t.text=="string"?qt(t.text):""}function eO(t){let e=t.message?.content,n=t.type==="attachment"&&t.attachment?.type==="queued_command"?Rs(t.attachment.prompt):t.type==="user"&&t.isMeta&&!(Array.isArray(e)&&e.some(s=>s?.type==="tool_result"))?Rs(e):"";if(!n.includes("<task-notification>"))return[];let r=[];for(let[,s]of n.matchAll(ZC)){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 ed(t,e){if(typeof t=="string")return je(t);if(!t||typeof t!="object")return je(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=$y(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=$y(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":je(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"):je(e)}function Is(t){return!!t.isMeta}function sO(t){let e;try{e=PC(t,"r")}catch{return""}try{let r=65536;try{r=Ly(t).size}catch{}let s=(c,f)=>{if(f<=0)return"";let d=Buffer.alloc(f),u=_C(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||
|
|
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||Is(f)||f.type!=="user")continue;let d=f.message?.content,u="";typeof d=="string"?u=qt(d):Array.isArray(d)&&(u=d.map(Qu).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{RC(e)}}function Yo(t){let e=hn(t,"sessions"),n;try{n=My(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(Dy(hn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function Ny(t,e){return Yo(t).some(n=>n.sessionId===e)}function iO(t,e){let n=Yo(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 oO(t){return new Set(Yo(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var Zu,Xu,LC,DC,BC,Ry,JC,KC,YC,VC,Iy,ZC,tO,nO,rO,$y,ir,Vo=S(()=>{"use strict";_s();Jo();Wo();Ps();Zu=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");Xu=(t,e)=>hn(t,"projects",NC(e)),LC="subagents";DC="general-purpose",BC=[256*1024,4*1024*1024,64*1024*1024],Ry=new Map;JC=[/\[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];KC=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;YC=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,VC=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;Iy=`The coordinator sent a message while you were working:
|
|
307
|
+
`;ZC=/<task-notification>([\s\S]*?)<\/task-notification>/g;tO=/^(Command running in background with ID|Command did not complete within its \d+s timeout and was moved to the background|Async agent launched)/,nO=/\bID: ([A-Za-z0-9]+)/,rO=new Set(["TaskStop","KillShell"]),$y=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;ir=class extends Ut{constructor(n=hn($C(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return IC(this.root)}sessionsDir(n){return Xu(this.root,n)}listSessionFiles(n){return qo(Xu(this.root,n))}listChildren(n,r){return MC(this.root,n,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}sessionCwd(n){return Yo(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:Zu(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=QC(n);if(s)return{events:[Ko(s)]};let i=eO(n);if(i.length)return{events:i};if(Is(n)&&!XC(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(Ko(l))}else if(Array.isArray(a))for(let l of a)if(l?.type==="tool_result"){let c=Rs(l.content),f=l.is_error?/^Exit code (\d+)/.exec(c)?.[1]:void 0,d=n.toolUseResult,u=tO.test(c)||!!d&&typeof d=="object"&&!!d.backgroundTaskId;o.push({type:"tool_result",id:l.tool_use_id??"",content:c,isError:!!l.is_error,digest:ed(n.toolUseResult,c),exit:f===void 0?void 0:Number(f),background:u||void 0,task:u?nO.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=Qu(l)||Ho(l);c&&o.push(Ko(c))}return{events:o}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let a=qt(Rs(n.attachment.prompt));return a&&o.push(Ko(a)),{events:o}}if(n.type==="assistant"){let a=n.message?.content,l=Array.isArray(a)?a:[],c=l.filter(h=>h.type==="text").map(h=>h.text??"").filter(h=>!WC(h)).join(""),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(rO.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 By(n)}sessionAlive(n){return Ny(this.root,n)}sessionEnded(n){return!Ny(this.root,n)}sessionsWorking(n){return oO(this.root)}readPreview(n){return sO(n)}searchText(n){if(!n||Is(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(Qu).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 $s(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 Go(t){let e=[],n;for(;n=aO.exec(t);)n[1]&&e.push(n[1]),t=t.slice(n[0].length);return{dirs:e,rest:t}}function td(t){if(/>|\btee\b/.test($s(t).replace(/\d?>&\d|\d?>\s*(\/dev\/null|\$null|NUL)\b/gi,"")))return!1;let e=Ns(t);for(;e.length&&(dO.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"?uO.has(r.find(s=>!s.startsWith("-"))??""):n==="git"?cO.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)):lO.has(n)||/^get-/.test(n)}function Fy(t){let e=[...t.matchAll(/\$\(|`/g)].map(n=>t.slice(n.index+n[0].length));return ht(t).every(n=>td(n.text))&&e.every(n=>td(ht(n)[0]?.text??""))}function qy(t){if(/\bset\s+-\w*o\s+pipefail\b/.test($s(t)))return!1;let e=ht(ht(t,!1).at(-1)?.text??"");return e.length>1&&pO.has(Ns(e.at(-1).text)[0]?.toLowerCase()??"")}function nd(t){t=t.replace(hO,(s,i,o,a)=>`<<${i}${o}${i}${a} \u2026 ${o}`);let e=ht(t),n=e.findIndex(s=>!td(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 Jy(t){let e=[];for(let n of ht(t)){let r=Ns(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(/\/+$/,"")}/${Ty(l)}`:a})}return e}function Wy(t){let e=Hy(t),n=e.map(zy);return e.length&&n.every(r=>r!==void 0)?n:void 0}function Ky(t){let e=new Map,n=[];for(let r of Hy(t)){let s=/^\$([\w:]+)\s*=\s*(['"])([^'"]*)\2$/.exec(r);if(s){e.set(s[1].toLowerCase(),s[3]);continue}let i=zy(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 zy(t){let[e,...n]=ht(t).map(i=>i.text.trim());if(!e||!n.every(i=>bO.test(i)))return;let r=Ns(e);if(!mO.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(gO.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(yO.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}var $s,Ns,aO,lO,cO,uO,dO,fO,Uy,pO,hO,mO,gO,yO,bO,Hy,rd=S(()=>{"use strict";Ps();$s=t=>t.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g,e=>"_".repeat(e.length));Ns=t=>(t.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e),aO=/^\s*(?:(?:cd|set-location)\s+(?:-(?:literal)?path\s+)?("[^"]*"|'[^']*'|[^\s;&]+)|export\s+PATH=\S+)\s*(?:;|&&)\s*/i;lO=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"]),cO=new Set(["log","status","diff","show","blame","rev-parse","ls-files","grep","branch","remote"]),uO=new Set(["status","logs","get","models","slug","predict"]),dO=new Set(["if","then","else","elif","fi","do","done","while","until","!","{","}","(",")"]);fO=new Set(["grep","egrep","fgrep","rg","findstr","select-string"]),Uy=t=>fO.has(Ns(ht(t).at(-1)?.text??"")[0]?.toLowerCase()??""),pO=new Set(["tail","head","grep","egrep","fgrep","rg","sed","awk","sort","uniq","wc","cut","tr","tee","cat","less","findstr"]);hO=/<<-?\s*(['"]?)(\w+)\1([^\n]*)\n[\s\S]*?\n\s*\2\b/g;mO=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,gO=/^-(Path|LiteralPath)$/i,yO=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,bO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;Hy=t=>ht(t,!1).map(e=>e.text.trim())});import{spawn as wO,execFile as vO}from"child_process";import{promisify as SO}from"util";import{randomBytes as Vy}from"crypto";async function xO(){let t;try{t=(await kO("codex",["app-server","daemon","version"],{shell:!0,timeout:Gy})).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 Yy(t){let e=Buffer.from(t),n=Vy(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 Xy(){let t=await xO(),e=new sd(wO(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 id(){let t=await Xy();try{return(await t.call("thread/loaded/list",{})).data??[]}finally{t.close()}}async function Qy(t,e,n){let r=await Xy();try{await r.call("turn/start",{threadId:t,input:[],toolOutput:{name:e,output:n},turnTrigger:"typebulb"})}finally{r.close()}}var kO,Gy,sd,Zy=S(()=>{"use strict";kO=SO(vO),Gy=15e3;sd=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: ${Vy(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"?
|
|
330
|
-
`),r=[];if(n.forEach((o,a)=>{let l=
|
|
331
|
-
`)}function Jt(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async 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}`))},Gy);this.#t.set(r,l=>{clearTimeout(a),i(l)}),this.proc.stdin.write(Yy(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(Yy(JSON.stringify({jsonrpc:"2.0",method:e})))}close(){this.proc.kill()}}});import{statSync as Xo,readdirSync as EO,existsSync as AO}from"fs";import{basename as eb,join as od,resolve as TO}from"path";import{homedir as tb}from"os";function OO(t){let e=t.trimStart();return CO.some(n=>e.startsWith(n))}function or(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&OO(n.text)?"":Re(n.text):n?.type==="input_image"&&typeof n.image_url=="string"&&n.image_url.startsWith("data:")?``:"").filter(Boolean).join(`
|
|
321
|
+
`):""}function PO(t){return typeof t=="string"?Re(t):or(t,!1)}function _O(t,e){let n=e??"",r=NO(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>ad(i.fn)&&Ls(i.arg)?Wy(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:nb(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}=rb(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:$O(l)}}}return Ls(o)?ad(i)?{name:t,input:IO(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:t,input:{script:n}}}return{name:t,input:nb(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",rb(o).diff]:ad(i)&&Ls(o)?["command",o.cmd??o.command]:[i,o]))}}function IO(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!RO.has(r))),n=t.command??t.cmd;return n===void 0?e:{command:n,...e}}function nb(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 $O(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 NO(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=cb(t,s);if(i<0)break;e.push({fn:r[1],arg:lb(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function lb(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return Zo(t,0)===t.length-1?ub(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,MO(t)])try{let s=JSON.parse(r);if(Ls(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==="`"?Zo(e,s):i==="{"?cb(e,s):-1;if(o>s)return lb(e.slice(s,o+1),"")}}return t}function cb(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=Zo(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function Zo(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 ub(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)):LO[i]??i)}function MO(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=Zo(t,i);if(l<0)return t;r+=JSON.stringify(ub(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 rb(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 DO(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:je(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=BO(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(jO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:je(r),exit:o}}function BO(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(Ls(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function FO(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 qO(t){let e,n,r;for(let s of UO){let i=Uo(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=db(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 db(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 ib(t){let n=sr(t,65536);if(n===void 0)return;let r=n.text.indexOf(`
|
|
325
|
+
`);if(r<0)return n.bytes>=65536?{cwd:"",subagent:!1}:void 0;try{let s=JSON.parse(n.text.slice(0,r)),i=s?.type==="session_meta"?s.payload:void 0;if(typeof i?.cwd!="string")return{cwd:"",subagent:!1};let o=typeof i.source=="object"?i.source?.subagent:void 0,a=JO(i,o),l=ab(n.text,r),c=a&&!l&&n.bytes>=65536?sr(t,ob):void 0,f=l??(c&&ab(c.text,r)),d=!!a&&!f&&(c??n).bytes<(c?ob:65536);return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:a,turn:f,modelPending:d}}catch{return{cwd:"",subagent:!1}}}function JO(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 ab(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 CO,Ls,ad,RO,LO,jO,Qo,sb,ld,ar,UO,ob,cd=S(()=>{"use strict";_s();Wo();Jo();rd();Zy();CO=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];Ls=t=>!!t&&typeof t=="object"&&!Array.isArray(t),ad=t=>t==="shell_command"||t==="exec_command",RO=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);LO={n:`
|
|
327
|
+
`,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};jO=t=>t?t.replace(/\r?\n$/,"").split(`
|
|
328
|
+
`).length:0;Qo=t=>{let e=TO(t);return process.platform==="win32"?e.toLowerCase():e},sb=12e4,ld=t=>t.slice(-36),ar=class t extends Ut{constructor(n=od(tb(),".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 id()).includes(ld(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 id()).includes(ld(n)))throw new Error("the Codex session is not loaded by its app server now");await Qy(ld(n),r,s)}detectsInstalled(){return AO(od(tb(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=Qo(n),s=[];for(let i of this.#f()){let o=0,a=0;try{let f=Xo(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=ib(i),l===void 0)continue;this.#n.set(i,l)}if(l.subagent||Qo(l.cwd)!==r)continue;let c=eb(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=Qo(n),i=new Map,o;for(let c of this.#f()){let f=0,d=0,u;try{let b=Xo(c);if(!b.isFile())continue;f=b.size,d=b.mtimeMs,u=b.birthtimeMs||void 0}catch{continue}let p=this.#n.get(c);if(p===void 0||p.modelPending){if(p=ib(c),p===void 0)continue;this.#n.set(c,p)}if(eb(c,".jsonl")===r&&(o=p.id),!p.spawn||Qo(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>=sb)continue;let l;try{let c=Xo(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=qO(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 EO(s).map(i=>od(s,i))}catch{return[]}};for(let s of r(this.root))for(let i of r(s))for(let o of r(i))for(let a of r(o))a.endsWith(".jsonl")&&n.push(a);return n}parseEntry(n){let r;try{r=JSON.parse(n)}catch{return null}return!r||typeof r.type!="string"?null:r}idOf(n){return n.ord===void 0&&(this.#l(n),n.ord=String(this.#t++),n.parent=this.#o,this.#o=n.ord),n.ord}#l(n){let r=n.payload;if(n.type==="session_meta"){if(++this.#u===1){let s=typeof r?.source=="object"?r.source?.subagent?.thread_spawn:void 0;this.#s=s?.agent_path,this.#e=!!s}}else this.#u=0,this.#e&&r?.type==="agent_message"&&r.recipient===this.#s&&(this.#e=!1);n.inherited=this.#e}parentOf(n){return n.parent}timestampOf(n){return n.timestamp}isSidechain(n,r){return r==="child"&&!!n.inherited}isLeafType(n){return!0}isRecoveryNoise(n){return!1}apply(n,r){let s=[],i=n.payload;if(!i)return{events:s};let o=()=>{let a=Date.parse(n.timestamp??"");return!isNaN(a)&&a>=r};if(n.type==="response_item"){if(i.type==="message"){if(i.role==="user"){let a=or(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=or(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=or(i.summary,!1);return a&&s.push({type:"assistant",text:"",thinking:a,tools:[],live:o()}),{events:s}}if(i.type==="custom_tool_call"||i.type==="function_call"){let a=i.call_id??"",{pending:l,...c}=i.type==="custom_tool_call"?_O(i.name??"",i.input):{name:i.name??"",input:FO(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,...DO(PO(i.output),l)}),{events:s}}return{events:s}}if(n.type==="event_msg"){if(i.type==="token_count"){let a=i.info?.last_token_usage;return a?{events:s,usage:db(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=Xo(r);s=this.#r(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<sb}readPreview(n){for(let r of(sr(n,256*1024)?.text??"").split(`
|
|
329
|
+
`))if(!(!r.includes('"user_message"')&&!r.includes('"UserMessage"')))try{let s=JSON.parse(r);if(s?.type!=="event_msg")continue;let i=s.payload,a=((i?.type==="user_message"?i.message:i?.type==="item_completed"&&i.item?.type==="UserMessage"?or(i.item.content,!0):void 0)??"").replace(/\s+/g," ").trim();if(a)return a.slice(0,200)}catch{}return""}searchText(n){if(n?.type!=="response_item"||n.payload?.type!=="message")return"";let r=n.payload.role;return r!=="user"&&r!=="assistant"?"":or(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},UO=[64*1024,1024*1024];ob=512*1024});import{realpathSync as WO}from"fs";import{createHash as KO}from"crypto";import{join as ea,resolve as HO}from"path";import{homedir as zO}from"os";function Ie(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?ea(t,".."):ea(zO(),".typebulb")}function mt(){fb||(fb=!0,console.error(`${Ie()} 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||ea(Ie(),"servers")}function pb(t){let e=se(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return ea(Ie(),"canvas",`${n}-${Ms(t)}.png`)}function Ms(t){return KO("sha1").update(se(t)).digest("hex").slice(0,8)}function se(t){let e=HO(t),n=e;try{n=WO.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function hb(t,e){let n=se(t),r=se(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var fb,Fe=S(()=>{"use strict";fb=!1});import*as yb from"net";import{mkdir as YO,readFile as VO,writeFile as bb}from"fs/promises";import{existsSync as GO}from"fs";import{join as wb}from"path";function kb(){return wb(Ie(),"blocks")}function ud(t){return wb(kb(),`${t}.json`)}function na(t){return new Promise(e=>{let n=yb.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function eP(t){for(let e=t;e<65535;e++)if(await na(e))return e;throw new Error(`No free port found above ${t}`)}async function dd(t){let{listBulbServers:e}=await Promise.resolve().then(()=>($e(),xb)),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 ra(t){try{let e=JSON.parse(await VO(ud(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function sa(t,e){try{return await bb(ud(t),JSON.stringify(e,null,2)),!0}catch{return mt(),!1}}async function tP(t){let e=se(t);try{await YO(kb(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<Sb;o++)n.push(vb+o*mn);let r=await Promise.all(n.map(async o=>({base:o,block:await ra(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 bb(ud(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await ra(o))?.cwd===e)return o;l.code!=="EEXIST"&&mt();continue}if(!GO(a.cwd))return await sa(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>mb(o.block)-mb(a.block))[0];if(i)return await sa(i.base,s)?i.base:void 0}function mb(t){return Object.values(t.slots).reduce((e,n)=>Math.max(e,n.usedAt??0),0)}async function nP(t,e){let n=await ra(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=gb(n),a=o.has(0)?QO:0;for(;a>ta&&o.has(a);)a--;return n.mirrors[e.agent]=a,await sa(t,n),a}let r=se(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=gb(n);for(s=ta;s<mn&&i.has(s);)s++;if(s>=mn){let o=Object.entries(n.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:ta,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await sa(t,n),s}function gb(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function lr(t,e){let n=await tP(e);return n===void 0?void 0:n+await nP(n,t)}async function gn(t){let e=se(t);for(let n=0;n<Sb;n++){let r=await ra(vb+n*mn);if(r?.cwd===e)return s=>r.slots[se(s)]?.usedAt??0}return()=>0}async function ia(t){if(t.explicit!==void 0)return await na(t.explicit)||await dd(t.explicit),t.target.kind==="bulb"&&await lr(t.target,t.cwd),{port:t.explicit};let e=await lr(t.target,t.cwd);if(e!==void 0){let r=e-e%mn,s=Date.now()+ZO;do{if(await na(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=ta;i<mn;i++){let o=r+i;if(o!==e&&await na(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await eP(XO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var vb,mn,Sb,XO,ta,QO,ZO,yn=S(()=>{"use strict";Fe();vb=20100,mn=100,Sb=19,XO=23e3,ta=1,QO=mn-1,ZO=3e3});var Oe,oa=S(()=>{"use strict";Oe="0.62.6"});var xb={};$i(xb,{agentViewerCommand:()=>$b,bulbServerCommand:()=>Ib,clearServerLog:()=>gd,findProjectViewer:()=>ca,isAlive:()=>Jt,isMirror:()=>be,isProjectBulb:()=>Sd,isProjectMirror:()=>dr,launchAgentViewer:()=>js,launchBulbServer:()=>vn,listBulbServers:()=>G,probePageCount:()=>xd,readServerLog:()=>Xe,readWaitCursor:()=>la,recordDenial:()=>vd,registerServer:()=>wd,relayOpen:()=>kd,runMarker:()=>yd,serverLogPath:()=>ur,serversForBulb:()=>wn,sliceRunLog:()=>bd,startServerLog:()=>Bs,stopBulbServer:()=>cr,stopServer:()=>yt,stopServersForBulb:()=>ua,typebulbBinPath:()=>fr,unregisterServer:()=>bn,writeWaitCursor:()=>Ds});import{spawn as Eb}from"child_process";import{readdir as rP,readFile as Cb,writeFile as Ob,unlink as fd,mkdir as sP}from"fs/promises";import{mkdirSync as Pb,writeFileSync as aa,appendFileSync as iP,readFileSync as pd}from"fs";import*as Ne from"path";import{fileURLToPath as oP}from"url";function hd(t){return Ne.join(gt(),`${t}.json`)}function ur(t){return Ne.join(gt(),`${t}.log`)}function md(t){return Ne.join(gt(),`${t}.wait.json`)}function _b(t){try{let e=JSON.parse(pd(md(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function la(t,e=""){let n=_b(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function Ds(t,e,n=""){try{Pb(gt(),{recursive:!0});let r=_b(t);r[n]=e,aa(md(t),JSON.stringify({cursors:r}))}catch{}}function Bs(t){let e=ur(t);try{Pb(gt(),{recursive:!0}),aa(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(iP(e,l),s+=l.length,s>2*Ab){let c=pd(e),f=c.subarray(Math.max(0,c.length-Ab));aa(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 gd(t){try{aa(ur(t),"")}catch{}}function Xe(t,e=0){try{let n=pd(ur(t)),r=e>=0&&e<=n.length?e:0;return{text:n.subarray(r).toString("utf8"),offset:n.length}}catch{return{text:"",offset:0}}}function yd(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function lP(t){let e=aP.exec(t);return e?Number(e[1]):void 0}function bd(t,e){let n=t.split(`
|
|
330
|
+
`),r=[];if(n.forEach((o,a)=>{let l=lP(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 wd(t){try{await sP(gt(),{recursive:!0}),await Ob(hd(t.pid),JSON.stringify({version:Oe,...t}))}catch{mt()}}async function vd(t,e){let n=hd(t);try{let r=JSON.parse(await Cb(n,"utf8"));if(r.denied===e)return;r.denied=e,await Ob(n,JSON.stringify(r))}catch{}}async function bn(t){await fd(hd(t)).catch(()=>{}),await fd(ur(t)).catch(()=>{}),await fd(md(t)).catch(()=>{})}function be(t){return t.agent!=null}function dr(t,e){return be(t)&&t.cwd!=null&&se(t.cwd)===se(e)}function Sd(t,e){return!be(t)&&hb(t.file,e)}async function G(t){let e;try{e=await rP(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 Cb(Ne.join(gt(),s),"utf8"))}catch{await bn(i);return}o&&typeof o.pid=="number"&&Jt(o.pid)?n.push(o):await bn(i)})),(t?n.filter(s=>Sd(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function ca(t,e){return(await G()).find(n=>dr(n,t)&&(e?n.agent===e:!0))}async function kd(t,e){let n=new URL(t).port,r=(await G()).filter(a=>String(a.port)!==n),s=r.filter(a=>dr(a,e)),i=r.filter(a=>Sd(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":`${Ne.basename(a.file)}'s page`};be(a)&&(o+=f??0)}catch{}return o>0?{where:"external"}:void 0}async function cr(t){try{process.kill(t,"SIGTERM")}catch{}await bn(t)}async function xd(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(cP)});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(Tb)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+Tb;for(;Jt(t.pid)&&Date.now()<i;)await Rb(100);return Jt(t.pid)?(await cr(t.pid),"killed"):(await bn(t.pid),{closed:r,stuck:s})}catch{return await cr(t.pid),"killed"}}function wn(t,e){let n=se(e);return t.filter(r=>!be(r)&&r.pid!==process.pid&&se(r.file)===n)}async function ua(t,e){let n=wn(await G(),t);for(let r of n)await yt(r,e!==void 0&&r.port===e?"keep":"close");return n}function uP(t,e,n){(process.platform==="win32"?Eb("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):Eb(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function fr(){return Ne.join(Ne.dirname(oP(import.meta.url)),"index.js")}function Ib(t,e={}){return{command:process.execPath,args:[fr(),...e.trust?["--trust"]:[],...e.noTrust?["--no-trust"]:[],...e.mode?["--mode",e.mode]:[],...e.watch===!1?["--no-watch"]:[],...e.replace?["--replace",e.replace]:[],t,...e.open===!1?["--no-open"]:[]]}}function $b(t){return{command:process.execPath,args:[fr(),`agent:${t}`,"--no-open"]}}async function Nb(t,e,n,r){let s=await t();if(s)return s;uP(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await Rb(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function vn(t,e={}){let n=e.cwd??process.cwd(),r=Ne.resolve(n,t),s=await lr({kind:"bulb",file:r},n),[i]=await ua(r,s),o={...e,mode:e.mode??i?.mode};return Nb(async()=>wn(await G(),r)[0],Ib(t,o),n,Ne.basename(t))}async function js(t,e=process.cwd()){return Nb(()=>ca(e,t),$b(t),e,`the ${t} mirror`)}var Ab,aP,Tb,cP,Rb,$e=S(()=>{"use strict";Fe();yn();oa();Ab=1e6;aP=/^── run (\d+) ── /;Tb=6e3,cP=500;Rb=t=>new Promise(e=>setTimeout(e,t))});function pr(t){return{...Xp(t),server:t.files.get("server.ts")??""}}function da(t){return!!t.server&&!t.code}var Fs=S(()=>{"use strict";te();te()});function fa(t){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(t),n=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return n?n[1].replace(/^["']|["']$/g,""):void 0}function Ed(t){return nr(fa(t)??"bulb")||"bulb"}var Ad=S(()=>{"use strict";te()});import{readdirSync as dP,readFileSync as fP,statSync as pP}from"fs";import{join as Lb,basename as hP}from"path";function Db(t,e,n){if(e>8)return n;let r;try{r=dP(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;Db(Lb(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push(Lb(t,s.name));return n}function mP(t,e){let n,r=!1;try{let s=fP(t,"utf8");n=fa(s.slice(0,1024));let i=Ye(s);r=!!i&&da(pr(i))}catch{}return{mtime:e,name:n??hP(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function pa(t){let e=new Map,n=Db(t,0,[]).map(r=>{let s=0;try{s=pP(r).mtimeMs}catch{}let i=s?Mb.get(r):void 0,o=i?.mtime===s?i:mP(r,s);return s&&e.set(r,o),{path:r,...o}});return Mb=e,n}var Mb,Bb=S(()=>{"use strict";te();Fs();Ad();Mb=new Map});function hr(t){if(t.server.trim())return"server-side code (server.ts)";let e=t.code;if(/\btb\s*\.\s*fs\b/.test(e)||e.includes("/__fs"))return"the filesystem";if(/\btb\s*\.\s*ai\b/.test(e)||e.includes("/__ai")||t.infer.trim()||/\btb\s*\.\s*infer\b/.test(e))return"AI (your API keys)";if(/\btb\s*\.\s*server\s*\.\s*\w/.test(e)||e.includes("/__api"))return"server-side code (server.ts)"}var ha=S(()=>{"use strict"});import{readFile as gP}from"fs/promises";async function Td(t){try{let e=Ye(await gP(t,"utf-8"));return e?hr(pr(e)):void 0}catch{return}}var jb=S(()=>{"use strict";Fs();ha()});function Cd(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==="/"&&yP.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
|
|
337
|
-
`),a=
|
|
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:
|
|
335
|
+
`;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=Fb(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function Fb(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=Fb(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var yP,Ub=S(()=>{yP=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function vP(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 qb(t){let e=[];for(let s of wP)for(let i of t.matchAll(s)){let o=vP(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 Jb(t){return qb(Cd(t)).map(e=>e.root)}function Us(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
|
|
337
|
+
`),a=Cd(t).split(`
|
|
338
|
+
`);for(let l=0;l<o.length;l++){let c=a[l],f=l+1+s;for(let d of bP)d.targets.includes(n)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:xP(d.type,f),lineNumber:f,lineContent:o[l]})}return n==="client"&&r&&i.push(...SP(a,o,r,s)),i}function SP(t,e,n,r){let s=new Set(Object.keys(n));return qb(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:kP(i,a),lineNumber:a,lineContent:e[o]}})}function kP(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 xP(t,e){return t==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
|
|
354
354
|
|
|
355
355
|
**CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
|
|
356
356
|
|
|
@@ -504,22 +504,22 @@ import { something } from 'module-name'
|
|
|
504
504
|
const something = require('module-name') // NOT SUPPORTED!
|
|
505
505
|
\`\`\`
|
|
506
506
|
|
|
507
|
-
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var
|
|
508
|
-
`)}var
|
|
507
|
+
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var Sn,kn,bP,wP,ma=S(()=>{Ub();Sn=["client"],kn=["client","server"],bP=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:Sn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:kn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:Sn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:Sn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:Sn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:kn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:kn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:kn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:kn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:kn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:kn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:Sn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:Sn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:Sn}],wP=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function Od(t){let e=Ye(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=Jb(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=Kp(c);d&&(l[d]=f)}return l.config=JSON.stringify(i,null,2),eh(l)}var Wb=S(()=>{"use strict";te();ma()});import{spawn as Kb}from"child_process";import{basename as EP}from"path";function AP(){return process.env.TYPEBULB_EDITOR||"code"}function CP(t,e,n){return n==null?[e]:TP.test(EP(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function OP(t,e){let n=AP();return{command:n,args:CP(n,t,e)}}function Pd(t,e){let{command:n,args:r}=OP(t,e),s=process.platform==="win32"?Kb("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):Kb(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var TP,Hb=S(()=>{"use strict";TP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as PP,writeFileSync as _P,mkdirSync as RP,statSync as IP}from"fs";import{join as $P}from"path";function _d(){return $P(Ie(),"trust.json")}function Rd(){try{let t=_d(),e=IP(t).mtimeMs;if(qs?.mtime!==e){let n=JSON.parse(PP(t,"utf8"));qs={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return qs.set}catch{return qs=void 0,new Set}}function NP(t){try{RP(Ie(),{recursive:!0}),_P(_d(),JSON.stringify([...t])),qs=void 0}catch(e){throw new Error(`can't write ${_d()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function xn(t){return Rd().has(se(t))}function mr(t,e){let n=new Set(Rd()),r=se(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),NP(n))}function Id(){return[...Rd()]}var qs,Js=S(()=>{"use strict";Fe()});function yr(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function $d(){return Ks}async function bt(){let[t,e]=await Promise.all([Yb(),UP()]);return FP([...qP(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function FP(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function zb(){let t;try{t=await fetch(LP,{signal:AbortSignal.timeout(DP)})}catch(e){Ks=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){Ks=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){Ks=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function UP(){if(Ws&&Date.now()-Ws.fetchedAt<=MP)return Ws.models;let t=await zb()??await zb();return t?(Ws={models:t,fetchedAt:Date.now()},Ks=void 0,t):Ws?.models??[]}async function Yb(){if(ga&&Date.now()-ga.fetchedAt<=BP)return ga.models;let t=yr(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let n=await fetch(new URL("/api/tags",t).toString(),{signal:AbortSignal.timeout(jP)});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 ga={models:e,fetchedAt:Date.now()},e}function qP(t){let e=new Set(Object.entries(gr).filter(([,n])=>!!process.env[n]).map(([n])=>n));return t.filter(n=>e.has(n.provider))}function Nd(){return Object.values(gr).some(t=>!!process.env[t])}async function ya(){return Nd()||process.env.TB_AI_BASE_URL||(await Yb()).length>0?"own":"none"}function Vb(t,e,n){let r=Math.max(...t.map(o=>o.name.length)),s=Math.max(...t.map(o=>o.friendlyName.length)),i=["Models available to tb.ai (filtered by your .env keys):",""];for(let o of t)i.push(` ${o.name.padEnd(r)} ${o.friendlyName.padEnd(s)} (${o.provider})`);return i.push("","Pass an id as the `model` in tb.ai({ provider, model })."),e&&n&&i.push(`Default (from .env): ${e} / ${n}`),i.join(`
|
|
508
|
+
`)}var gr,LP,MP,DP,BP,jP,Ws,ga,Ks,En=S(()=>{"use strict";gr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};LP="https://api.typebulb.com/api/models",MP=1440*60*1e3,DP=5e3,BP=60*1e3,jP=1500});var Gb,Xb,at,An=S(()=>{Gb=t=>t!=null&&t>=0&&t<=4?t:void 0,Xb=(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 Le,Qe,br=S(()=>{Le=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
|
|
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
|
|
510
|
+
`){let r=e.filter(s=>s.role==="system").map(s=>s.content);return{system:r.length?r.join(n):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e);return r.error&&typeof r.error=="object"?{message:r.error.message||`HTTP ${n}`,type:r.error.type}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let n=e;if(n.type==="error"&&"message"in n){let r=n.code||"unknown";throw new Le(n.message,r,!!n.retryable)}if(n.error){let r=n.error,s=typeof r=="object"&&r!==null?String(r.type??r.code??""):"",i=/rate_limit|too_many_requests/i.test(s),o=/overloaded|server_error|unavailable/i.test(s),a=/context_length/i.test(s);throw new Le(this.extractErrorMessage(n.error),i?"rate_limit":a?"context_exceeded":"unknown",i||o)}}extractErrorMessage(e){if(typeof e=="string")try{let n=JSON.parse(e);return n.error?.message||n.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}}});var ba,Ld=S(()=>{An();br();ba=class extends Qe{constructor(){super(...arguments),this.providerName="OpenAI",this.defaultBaseUrl="https://api.openai.com",this.path="/v1/responses",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let i=this.convertMessagesToInput(e),o={model:n,input:i,stream:s};if(r?.webSearch===!0&&(o.tools=[{type:"web_search"}]),r?.effort!==void 0){let a=this.effortMap[r.effort];o.reasoning=a==="none"?{effort:a}:{effort:a,summary:"auto"}}return r?.maxOutputTokens!==void 0&&(o.max_output_tokens=r.maxOutputTokens),o}parseNonStreamingResponse(e){if(!this.isResponsesApiResponse(e))return{text:""};let n=e.output_text||"",r;if(e.output&&Array.isArray(e.output))for(let s of e.output)s.type==="reasoning"&&s.summary&&(r=s.summary.map(i=>i.text).join(`
|
|
511
|
+
`)),!n&&s.type==="message"&&s.content&&(n=s.content.filter(i=>i.type==="output_text").map(i=>i.text).join(""));return{text:n,reasoning:r,usage:this.mapUsage(e.usage)}}parseProviderStreamChunk(e){if(this.isResponsesApiEvent(e))switch(e.type){case"response.failed":{let r=e.response?.error,s=r?.message||"Response failed",i=r?.code==="insufficient_quota"||r?.code==="rate_limit_exceeded";throw new Le(s,i?"rate_limit":"unknown",i)}case"response.output_text.delta":return{text:e.delta};case"response.reasoning_summary_text.delta":return{reasoning:e.delta};case"response.completed":{let n=this.mapUsage(e.response?.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(e)return 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
|
|
513
|
+
`)}isResponsesApiEvent(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"}isResponsesApiResponse(e){return typeof e=="object"&&e!==null&&e.object==="response"}}});var wr,wa=S(()=>{An();br();wr=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 Md,va,Dd=S(()=>{wa();Md={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},va=class extends wr{constructor(){super(...arguments),this.providerName="OpenRouter",this.defaultBaseUrl="https://openrouter.ai",this.path="/api/v1/chat/completions",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"x-api-key":e,"Content-Type":"application/json",Accept:"application/json",...Md}}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 Sa,Bd=S(()=>{An();br();Sa=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 ka,jd=S(()=>{An();br();ka=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
|
|
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 Le(`Prompt blocked: ${n}`)}}}});var xa,Fd=S(()=>{wa();xa=class extends wr{constructor(){super(...arguments),this.providerName="Ollama",this.defaultBaseUrl="http://localhost:11434",this.path="/chat/completions"}buildHeaders(e){let n={"Content-Type":"application/json",Accept:"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}buildPayload(e,n,r,s){return s?{model:n,messages:e,stream:s,stream_options:{include_usage:!0}}:{model:n,messages:e,stream:s}}}});function Tn(t){let e=JP.get(t);if(!e)throw new Error(`Unsupported protocol: ${t}`);return e}function WP(t,e){return t.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function Ud(t,e){let n=Tn(t.protocol),r=n.getPath(t.model,e.stream),s=WP(t.baseUrl,r),i=n.buildHeaders(t.apiKey),o=n.buildPayload(e.messages,t.model,{effort:e.effort,webSearch:e.webSearch,maxOutputTokens:e.maxOutputTokens},e.stream);return fetch(s,{method:"POST",headers:i,body:JSON.stringify(o),signal:e.signal})}function KP(t){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(t)}async function vr(t,e){let n=Tn(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||KP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var Qb,JP,qd=S(()=>{Ld();Dd();Bd();jd();Fd();Qb=new xa,JP=new Map([["openai",new ba],["openrouter",new va],["anthropic",new Sa],["gemini",new ka],["ollama",Qb],["openai-compat",Qb]])});function Zb(t){let e=t.indexOf(`\r
|
|
518
518
|
\r
|
|
519
519
|
`),n=t.indexOf(`
|
|
520
520
|
|
|
521
|
-
`);return e!==-1&&(n===-1||e<n)?{pos:e,len:4}:n!==-1?{pos:n,len:2}:{pos:-1,len:0}}function
|
|
522
|
-
`).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*
|
|
521
|
+
`);return e!==-1&&(n===-1||e<n)?{pos:e,len:4}:n!==-1?{pos:n,len:2}:{pos:-1,len:0}}function Jd(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*ew(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=Jd(s);d!==void 0&&d!=="done"&&(yield d)}return}n?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:f}=Zb(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+f);let u=Jd(d);if(u==="done")return;u!==void 0&&(yield u),{pos:c,len:f}=Zb(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function Wd(t,e){return(await Sr(t,e)).text}async function Sr(t,e){if(!t.body)throw new Error("Response body is missing");let n="",r;for await(let s of Cn(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*Cn(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=Tn(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of ew(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=Xb(i,l.usage))}let o=at(i);o&&(yield{kind:"usage",usage:o})}var tw=S(()=>{An();qd()});import{strToU8 as HP,strFromU8 as zP,deflateSync as YP,inflateSync as VP}from"fflate";function Hd(t,e){let n=[];if(n.push(`You are a data processor. Follow the instructions to analyze the provided data. Output valid JSON that the code can consume.
|
|
523
523
|
|
|
524
524
|
---
|
|
525
525
|
Instructions:
|
|
@@ -537,13 +537,13 @@ ${r}
|
|
|
537
537
|
</data>`)}return n.push(`
|
|
538
538
|
Output only valid JSON. No explanation, no markdown fences, just the JSON object. Every number must be a JSON literal \u2014 never an expression like 2 * pi; write the computed decimal instead.`),n.join(`
|
|
539
539
|
|
|
540
|
-
`)}function
|
|
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 Hs(t){try{return JSON.parse(t)}catch{return}}function nw(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 XP(t){let e=nw(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function QP(t){let e=nw(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 ZP(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 e_(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=ZP(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Hs(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function zd(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Hs(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=Hs(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=Hs(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of GP){let l=a(n);if(l!==void 0){let c=Hs(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=e_(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function Yd(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=YP(HP(n),{level:9}),s=n_(r),i=`${rw}:${s}`;return i.length>t_?"":"#"+Kd+i}catch{return""}}function Vd(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Kd))return;let n=e.slice(Kd.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==rw)return;let s=r_(n.slice(r+1)),i=JSON.parse(zP(VP(s)));if(!i||typeof i!="object")return;let o=i.i!==void 0,a=Array.isArray(i.d);if(!o&&!a)return;let l={};return o&&(l.insight=i.i,l.insightJson=JSON.stringify(i.i,null,2)),a&&(l.data=i.d),l}catch{return}}function n_(t){let e="";for(let n=0;n<t.length;n+=32768)e+=String.fromCharCode(...t.subarray(n,n+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function r_(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";let n=atob(e),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}var GP,Kd,rw,t_,sw=S(()=>{GP=[["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",XP],["arithmetic constants",QP]];Kd="tb=",rw="1",t_=6e4});var Wt=S(()=>{An();br();qd();tw();sw();wa();Bd();jd();Ld();Dd();Fd()});import{readFileSync as iw,existsSync as s_}from"fs";import*as lt from"path";function ow(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function we(t,e=process.cwd()){let n={},r=[];for(let s of ow(t)){let i;try{i=iw(lt.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of aw(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*aw(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 Ea(t,e=process.cwd()){for(let n of ow()){let r;try{r=iw(lt.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of aw(r))if(s===t)return i}return process.env[t]}function i_(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 lw(){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?i_(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"])s_(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=Tn(n)}catch{return`Unknown provider '${n}'.`}if(n==="ollama")return{apiKey:"",baseUrl:`${yr(process.env.OLLAMA_HOST??s.defaultBaseUrl)}/v1`,protocol:n,model:r,isFreeModel:!1};if(n==="openai-compat"){let a=process.env.TB_AI_BASE_URL;return a?{apiKey:process.env.TB_AI_API_KEY??"",baseUrl:a,protocol:n,model:r,isFreeModel:!1}:"No base URL for openai-compat. Set TB_AI_BASE_URL (the OpenAI-style base ending in /v1, e.g. http://localhost:1234/v1) in your .env file."}let i=gr[n];if(!i)return`Unknown provider '${n}'.`;let o=process.env[i];return o?{apiKey:o,baseUrl:s.defaultBaseUrl,protocol:n,model:r,isFreeModel:!1}:`No API key for '${n}'. Set ${i} \u2014 ${lw()}.`}function Ht(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return Ud(t,{messages:n,stream:!0,effort:Gb(e.effort),webSearch:e.webSearch,signal:e.signal})}var Aa=S(()=>{"use strict";Wt();Wt();Ze();En()});import{readFileSync as _F,existsSync as o_}from"fs";import*as kr from"path";import{fileURLToPath as a_}from"url";function l_(){let t=kr.dirname(a_(import.meta.url));for(;!o_(kr.join(t,"package.json"));){let e=kr.dirname(t);if(e===t)break;t=e}return t}function zs(){return kr.join(l_(),"SKILL.md")}var Gd=S(()=>{"use strict"});import{transform as c_}from"sucrase";function Xd(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=c_(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var cw=S(()=>{});function u_(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
|
|
542
542
|
`)[0]}`).join(`
|
|
543
|
-
`)}function
|
|
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
|
|
546
|
-
${
|
|
543
|
+
`)}function uw(t,e){let n=Us(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
|
|
544
|
+
${u_(n)}`)}var dw=S(()=>{"use strict";ma()});var zt,Ys,Qd,Vs=S(()=>{zt="https://esm.sh",Ys="https://cdn.jsdelivr.net/npm/",Qd="https://data.jsdelivr.com/v1/package/npm/"});function fw(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var F,xr,pw,Gs=S(()=>{Vs();F=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=xr(n??s.version),this.subpath=xr(r??s.subpath)}static parse(e){let n=fw(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=pw(n[1]??""),a=xr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=pw(n[0]),o=xr(n.slice(1).join("/"));return new t({name:s,version:i,subpath:o})}}static fromUrl(e){try{let n=new URL(e),r=new URL(zt).host,s=new URL(Ys).host;if(n.host===r){let i=fw(n.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return t.parse(o)}if(n.host===s){let i=n.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return t.parse(o)}return}catch{return}}format(){let e=this.version?`${this.name}@${this.version}`:this.name;return this.subpath?`${e}/${this.subpath}`:e}root(){return this.name}static rootOf(e){return t.parse(e).name}withVersion(e){return new t({name:this.name,version:xr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},xr=t=>t&&t.length?t:void 0,pw=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),xr(t.slice(e+1))]}});async function Pe(t){try{return await t()}catch{return}}var Ta=S(()=>{});function On(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Zd(t){return t.startsWith("./")?t:`./${t}`}var Xs,ef=S(()=>{Gs();Ta();Vs();Xs=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`${Ys}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(On(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(`${Qd}${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 hw,Qs,tf,d_,Zs,Ca=S(()=>{hw=t=>t.startsWith("@types/"),Qs=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!hw(e)),tf=t=>Object.keys(t?.dependencies||{}).filter(e=>!hw(e)),d_=t=>Qs(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Zs=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 d_(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=>Qs(i.meta))),r=new Map;for(let i of e)for(let o of tf(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:Qs(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var ei,nf=S(()=>{Gs();Ta();ei=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 f_,parse as p_}from"es-module-lexer";var Er,rf=S(()=>{Gs();Vs();Ca();Er=class t{constructor(e,n,r){this.version=e,this.cdn=n,this.peer=r}extractImportsSync(e){let n=new Set;for(let r of t.importPatterns){r.lastIndex=0;for(let s of e.matchAll(r))F.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{F.isBare(s)&&n.add(s)};try{await f_;let[s]=p_(e);s.forEach(i=>r(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(n)}async buildImportMap(e,n,r){let s=(await this.extractImports(e)).filter(d=>!r?.has(F.rootOf(d))),i=[...new Set(s.map(F.rootOf))],o=await Promise.all(i.map(async d=>({name:d,version:await this.resolveVersion(d,n)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,d=>this.resolveVersion(d,n)),f=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,d])=>d)}}async resolveVersion(e,n){let r=n[e],s=await this.version.resolveExactForRoot(e,r);if(!s)throw new Error(`Cannot resolve ${r?`${e}@${r}`:e}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);return s}buildEntries(e,n,r){let s=new Map(n.map(p=>[p.name,p])),i=p=>{let h=s.get(F.rootOf(p));return new F(p).withVersion(h.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==F.rootOf(p)).map(F.rootOf)),l=[],c=new Set,f=new Set(e.filter(p=>p===F.rootOf(p))),d=new Set;for(let p of e){let h=F.rootOf(p),m=s.get(h),{isPeerRoot:g,hasPeers:b,isSharedDep:C}=r.get(h),T=a.has(h),E=p!==h,P=!(g||C)&&(T||!b),_=this.singletonDepsOf(m,o),k=E&&f.has(h);k&&d.add(h);let N=k?[..._,h]:_.length?_:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:P,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([...Qs(e.meta),...tf(e.meta)])].filter(r=>n.has(r))}};Er.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as mw,satisfies as h_,maxSatisfying as gw,major as m_,valid as g_,validRange as y_}from"semver";var Oa,Pn,sf=S(()=>{Oa=class{cmp(e,n){return e===n?0:mw(e,n)?1:mw(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!h_(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=gw(e,r,{includePrerelease:!1});if(a)return a}return gw(e,r,{includePrerelease:!0})??void 0}majorOf(e){return m_(e)}isExactVersion(e){return g_(e)!==null}isRange(e){return y_(e)!==null}},Pn=new Oa});function b_(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var _n,yw=S(()=>{Ta();_n=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()+b_(r),attempts:r}))}async clearNegative(e){await Pe(()=>this.store.delete(e))}}});function bw(t,e){let n=new Xs(t,e),r=new Zs(n),s=new ei(t,n,Pn);return{packageService:new Er(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var vt=S(()=>{ef();Ca();nf();rf();sf();Gs();sf();Vs();ef();Ca();nf();rf();yw()});import*as of from"fs/promises";import*as ww from"crypto";function et(t){return ww.createHash("sha1").update(t).digest("hex")}async function St(t){try{return JSON.parse(await of.readFile(t,"utf8"))}catch{return}}async function Pa(t){try{return await of.readFile(t,"utf8")}catch{return}}var Ar=S(()=>{"use strict"});import*as Vt from"fs/promises";import*as kt from"path";import*as Sw from"os";function ne(){return af||(af=v_().catch(()=>mt())),af}function Ra(t,e){return kt.join(w_,et(t),e)}async function v_(){await Vt.mkdir(Yt,{recursive:!0});let t=kt.join(Yt,"version.json");if((await St(t))?.version===vw)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:vw})+`
|
|
545
|
+
`,"utf8")}var vw,Yt,ti,ni,_a,w_,af,Tr=S(()=>{"use strict";Ar();Fe();vw=1,Yt=kt.join(Sw.homedir(),".typebulb","cache"),ti=kt.join(Yt,"packages"),ni=kt.join(Yt,"proxy"),_a=kt.join(Yt,"dts"),w_=kt.join(Yt,"emit")});import*as Gt from"fs/promises";import*as kw from"path";async function Ue(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await Gt.mkdir(kw.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 ri=S(()=>{"use strict";Fe()});var Cr,lf=S(()=>{"use strict";ri();Ar();Cr=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 Ue(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as Aw from"fs/promises";import*as tt from"path";function Ew(t,e){return tt.join(S_,Ia(t),encodeURIComponent(e)+".json")}function Ia(t){return t.replace(/\//g,"__")}var cf,xw,S_,k_,$a,Tw=S(()=>{"use strict";vt();Tr();ri();lf();Ar();cf=tt.join(ti,"indexes"),xw=tt.join(ti,"pinned"),S_=tt.join(ti,"meta"),k_=tt.join(ti,"negative.json"),$a=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new _n(new Cr(k_));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await ne();let s=await Pa(tt.join(xw,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 Ue(tt.join(xw,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(cf,Ia(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 Ue(tt.join(cf,Ia(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await Aw.rm(tt.join(cf,Ia(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(Ew(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 Ue(Ew(e,n),JSON.stringify(o))}}});var Cw,Ow=S(()=>{"use strict";Cw={async getJson(t){try{let e=await fetch(t,{redirect:"follow"});return e.ok?await e.json():void 0}catch{return}},async head(t){try{let e=await fetch(t,{method:"HEAD",redirect:"follow"});return{ok:e.ok,url:e.url}}catch{return}}}});var x_,Na,Pw,_w,D2,uf=S(()=>{"use strict";vt();Tw();Ow();x_=new $a,{packageService:Na,versionResolver:Pw,cdnClient:_w,peerResolver:D2}=bw(x_,Cw)});function La(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Rw(){return` <script>
|
|
546
|
+
${wy}
|
|
547
547
|
(function () {
|
|
548
548
|
try {
|
|
549
549
|
var key = function () { return 'tb-scroll:' + location.pathname + location.search; };
|
|
@@ -556,7 +556,7 @@ ${yy}
|
|
|
556
556
|
});
|
|
557
557
|
} catch (e) {}
|
|
558
558
|
})();
|
|
559
|
-
</script>`}function
|
|
559
|
+
</script>`}function Ma(t,e){return` <script>
|
|
560
560
|
(function() {
|
|
561
561
|
try {
|
|
562
562
|
var KEY = ${xt(JSON.stringify("tb-theme:"+t))};
|
|
@@ -601,7 +601,7 @@ ${yy}
|
|
|
601
601
|
});
|
|
602
602
|
} catch (e) {}
|
|
603
603
|
})();
|
|
604
|
-
</script>`}var xt,
|
|
604
|
+
</script>`}var xt,Iw,df,E_,A_,Da,Or=S(()=>{"use strict";te();te();xt=t=>t.replace(/<\/script/gi,"<\\/script");Iw=30*6e4,df=1e3,E_=6e4,A_=3e4,Da=(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 <= ${E_}) return;
|
|
620
620
|
es.close();
|
|
621
|
-
backoff = Math.min(${
|
|
621
|
+
backoff = Math.min(${A_}, backoff ? backoff * 2 : ${df} * 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 $w,Nw=S(()=>{"use strict";Or();te();$w=`
|
|
638
638
|
(() => {
|
|
639
639
|
// Inline (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
|
|
640
640
|
// bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
|
|
@@ -1078,7 +1078,7 @@ ${yy}
|
|
|
1078
1078
|
},
|
|
1079
1079
|
|
|
1080
1080
|
// Environment ('inline' when running as a bulb-in-a-bulb)
|
|
1081
|
-
mode: isFramed ? '${
|
|
1081
|
+
mode: isFramed ? '${rr.inline}' : '${rr.local}',
|
|
1082
1082
|
|
|
1083
1083
|
// Theme accessor - delegates to the head-script engine (window.__tbTheme).
|
|
1084
1084
|
// Get: override slot ('dark'|'light'|undefined). Set applies + persists
|
|
@@ -1507,7 +1507,7 @@ ${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
|
+
${Da("tbStreamUrl")}
|
|
1511
1511
|
// Told to go, the page goes: it closes the tab, and where the browser refuses a script the close
|
|
1512
1512
|
// (a tab that wasn't script-opened and has history) it replaces itself with a note naming the
|
|
1513
1513
|
// reason. The note is a blob document, never a served route \u2014 a note that needs the server
|
|
@@ -1594,20 +1594,20 @@ ${La("tbStreamUrl")}
|
|
|
1594
1594
|
});
|
|
1595
1595
|
}
|
|
1596
1596
|
})();
|
|
1597
|
-
`});function
|
|
1598
|
-
`+
|
|
1597
|
+
`});function Lw(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
|
+
`+zu,g={imports:__(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>${La(e)} - typebulb</title>
|
|
1604
|
+
${Ma(e,l)}
|
|
1605
|
+
${c?"":Rw()}
|
|
1606
1606
|
<script type="importmap">
|
|
1607
1607
|
${JSON.stringify(g,null,2)}
|
|
1608
1608
|
</script>
|
|
1609
1609
|
<style>
|
|
1610
|
-
${
|
|
1610
|
+
${Cs}${m}
|
|
1611
1611
|
</style>
|
|
1612
1612
|
<style>
|
|
1613
1613
|
${r}
|
|
@@ -1623,20 +1623,20 @@ ${u?`<script>window.__TB_BULB__ = ${xt(JSON.stringify(u))};</script>`:""}
|
|
|
1623
1623
|
${p?`<script>window.__TB_COMPILE_ERROR__ = ${xt(JSON.stringify(p))};</script>`:""}
|
|
1624
1624
|
|
|
1625
1625
|
<script>
|
|
1626
|
-
${
|
|
1627
|
-
${
|
|
1626
|
+
${Sy}
|
|
1627
|
+
${$w}
|
|
1628
1628
|
</script>
|
|
1629
1629
|
|
|
1630
|
-
${
|
|
1630
|
+
${P_}
|
|
1631
1631
|
|
|
1632
|
-
${
|
|
1632
|
+
${C_(n,d)}
|
|
1633
1633
|
</body>
|
|
1634
|
-
</html>`}function
|
|
1635
|
-
`);return`<script type="module">${s}${
|
|
1636
|
-
</script>`}function
|
|
1634
|
+
</html>`}function C_(t,e){let n=["",...T_],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,xt(t)].join(`
|
|
1635
|
+
`);return`<script type="module">${s}${O_(e,s)}
|
|
1636
|
+
</script>`}function O_(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 __(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var T_,P_,Mw=S(()=>{"use strict";te();Nw();Or();T_=["globalThis.__tbEntryRan = true; /* import graph resolved \u2014 the load-failure backstop's signal (imports hoist above this line) */","await globalThis.__tbBoot; /* #tb= fragment restore, set by the shim when present (TB-Inference.md) */"];P_=`<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 @@ ${A_(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:
|
|
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=
|
|
1738
|
+
</script>`});import*as ja from"fs/promises";import*as Ba from"path";import{existsSync as Dw,readFileSync as R_}from"fs";import{execFile as I_}from"child_process";import{promisify as $_}from"util";import{builtinModules as N_}from"node:module";import{satisfies as L_}from"semver";async function Fa(t,e,n,r){let i=t.map(c=>j_(c,n)).filter(c=>!F_(c,e));if(i.length===0)return;let o=i.filter(c=>!B_.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 ja.mkdir(e,{recursive:!0});let a=Ba.join(e,"package.json");Dw(a)||await ja.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 M_("npm",["install",...l,...i],{cwd:e,shell:!0})}function j_(t,e){if(!e||F.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function F_(t,e){let{name:n,version:r}=F.parse(t),s=Ba.join(e,"node_modules",n);if(!Dw(s))return!1;if(!r)return!0;try{let i=JSON.parse(R_(Ba.join(s,"package.json"),"utf-8")).version;return L_(i,r)}catch{return!1}}function Ua(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);D_.has(i)||e.add(i)}return[...e]}var M_,D_,B_,ff=S(()=>{"use strict";vt();M_=$_(I_),D_=new Set(N_),B_=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as qe from"fs/promises";import*as Me from"path";function Pr(t,e){let n=Me.resolve(e,t),r=Me.normalize(e),s=Me.normalize(n);if(s!==r&&!s.startsWith(r+Me.sep))throw new Error("Path traversal detected - access denied");return n}async function si(t,e){return qe.readFile(Pr(t,e))}async function qa(t,e,n){let r=Pr(t,n);await qe.mkdir(Me.dirname(r),{recursive:!0}),await qe.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function Ja(t,e){let n=Pr(t,e),r=await qe.readdir(n,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await qe.stat(Me.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function Wa(t,e){let n=Pr(t,e);if(Me.normalize(n)===Me.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await qe.rm(n,{recursive:!0})}var pf=S(()=>{"use strict"});async function Bw(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 vr(n,e.protocol);throw new Error(r.message)}return{response:n,protocol:e.protocol}}async function U_(t){let{response:e,protocol:n}=await Bw(t);return Sr(e,n)}async function*q_(t){let{response:e,protocol:n}=await Bw(t);yield*Cn(e,n)}function jw(t){let e=Object.assign(U_,{stream:q_}),n={read:async r=>{let s=await si(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 si(r,t)),write:async(r,s)=>(await qa(r,s,t),!0),list:async(r=".")=>Ja(r,t),remove:async r=>(await Wa(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>bt(),aiAccess:ya,mode:rr.local})}var Fw=S(()=>{"use strict";Wt();te();Aa();En();pf()});import*as Xt from"fs/promises";import*as he from"path";import{pathToFileURL as J_}from"url";async function Uw(t){let n=(await Xt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?he.join(t,n):void 0}function _r(t){let e=he.resolve(t);return he.join(he.dirname(e),he.basename(e).replace(/\.bulb\.md$/,""))}function Rr(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=Wn(e),r=pr(n);return{bulb:r,config:zr(r.config),warnings:Gp(e),starts:n.starts}}function hf(t){let e=he.basename(t).replace(/\.bulb\.md$/i,"");return he.join(he.dirname(t),".typebulb",`${e}.server.mjs`)}async function ii(t,e,n,r){let s=Xd(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await Wp(i,n));let o=he.join(he.dirname(e),".typebulb");await Xt.mkdir(o,{recursive:!0});let a=Ua(i);a.length>0&&await Fa(a,o,r);let l=hf(e);return await Xt.writeFile(l,i,"utf-8"),jw(_r(e)),await import(`${J_(l).href}?t=${Date.now()}`)}async function mf(t,e,n,r){let{bulb:s,config:i,starts:o}=await nt(t),a=Do(s.data),l,c=h=>{l??=h instanceof Error?h.message:String(h)};try{uw(s.code,i.dependencies??{})}catch(h){c(h)}let f=Xd(s.code,{jsxImportSource:i.ts?.jsxImportSource});f.error&&c(f.error);let d={imports:{}};if(!l)try{({importMap:d}=await Na.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=Lw({name:s.name,code:l?"":f.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:_r(t),watch:e,source:{file:he.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:Ms(t),compileError:l}),p;return s.server&&n&&(p=await ii(s.server,t,r,i.dependencies)),{html:u,bulb:s,serverExports:p,buildError:l}}var Rn,Et=S(()=>{"use strict";Fs();cw();dw();uf();Mw();ff();Ni();Fe();Fw();Rn=t=>he.join(_r(t),"assets")});import*as De from"fs/promises";import*as Je from"path";import{createHash as W_}from"crypto";async function yf(t,e,n){let r=[...t],s=async()=>{for(let i=r.shift();i!==void 0;i=r.shift())await n(i)};await Promise.all(Array.from({length:Math.min(e,t.length)},s))}function Ir(t){try{return JSON.parse(t).error||t}catch{return t}}async function wf(t,e){try{let n=await fetch(oi(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});return n.ok?n.headers.get("content-type")?.includes("json")?{entries:await n.json()}:{error:"manifest response is not JSON \u2014 wrong origin?"}:{error:`manifest request failed (${n.status}): ${Ir(await n.text())}`}}catch(n){return{error:n instanceof Error?n.message:String(n)}}}function vf(t,e){we(e);let n=process.env.TYPEBULB_ORIGIN||K_;try{return za(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function za(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:Je.join(e,Ka(l,c))}}let r=Je.resolve(e,t),s=Rr(r);if(!s)throw new Error(`Not a conventional bulb path: ${t}
|
|
1741
|
+
A pull target must be a bulb URL, or a local file at typebulbs/u/<user>/<slug>.bulb.md \u2014 the path is its remote identity.`);return{origin:n,...s,dest:r}}async function H_(t,e){let n=await wf(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=Rn(t.dest),i=[],o=[],a=0;for(let l of r){let c=await De.readFile(Je.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):bf(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 z_(t,e,n){let r=Rn(t.dest),s=[],i=0;return await yf(e.toGet,4,async o=>{try{let a=await fetch(`${oi(t)}/${Ha(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=Je.join(r,...o.split("/"));await De.mkdir(Je.dirname(l),{recursive:!0}),await De.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 Ya(t,e={}){let n=await fetch(gf(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});if(!n.ok)return{kind:"http-error",status:n.status};let r=n.headers.get("content-type");if(!r?.includes("text/markdown"))return{kind:"not-markdown",contentType:r??void 0};let s=await n.text(),i;try{i=await De.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&Y_(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await De.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:c,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await H_(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await De.mkdir(Je.dirname(t.dest),{recursive:!0}),await De.writeFile(t.dest,s);let c=new Date(n.headers.get("last-modified")??"");isNaN(c.getTime())||await De.utimes(t.dest,new Date,c)}let l=a.kind==="plan"?await z_(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 Y_(t,e){let n=i=>i.replace(/\r\n/g,`
|
|
1742
|
+
`),r=Ye(n(t)),s=Ye(n(e));return!r||!s?n(t)===n(e):r.frontmatter.name===s.frontmatter.name&&ze.every(i=>(r.files.get(pe[i].path)||"")===(s.files.get(pe[i].path)||""))}async function Jw(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=vf(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await Ya(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=Je.relative(process.cwd(),n.dest)||n.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),qw(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),qw(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 qw(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 K_,Ka,gf,Ha,oi,bf,Va=S(()=>{"use strict";Ze();te();Et();K_="https://typebulb.com",Ka=(t,e)=>Je.join("typebulbs","u",t,`${e}.bulb.md`),gf=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,Ha=t=>t.split("/").map(encodeURIComponent).join("/"),oi=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;bf=t=>W_("md5").update(t).digest("hex")});import*as ct from"fs/promises";import*as ai from"path";async function Ww(t,e=""){let n=await ct.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await Ww(ai.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function V_(t,e){let n=e.timeoutMs??3e4,r=oi(t),s={Authorization:`Bearer ${e.token}`},i=Rn(t.dest);if(!await ct.stat(i).then(h=>h.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await Ww(i),a=await wf(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 yf(o,4,async h=>{let m=await ct.readFile(ai.join(i,...h.split("/")));if(c.get(h)===bf(m)){p++;return}let g=await fetch(`${r}/${Ha(h)}`,{method:"PUT",body:new Uint8Array(m),headers:s,signal:AbortSignal.timeout(n)});if(!g.ok)throw new Error(`upload of '${h}' refused (${g.status}): ${Ir(await g.text())}`);u++})}catch(h){return{kind:"sync-error",message:h instanceof Error?h.message:String(h)}}return{kind:"synced",uploaded:u,unchanged:p,toDelete:d,base:Bi(t.userSlug,t.slug)}}async function G_(t,e,n){let r=n.timeoutMs??3e4,s=oi(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${Ha(o)}`,{method:"DELETE",headers:{Authorization:`Bearer ${n.token}`},signal:AbortSignal.timeout(r)});if(!a.ok)return{deleted:i,error:`delete of '${o}' refused (${a.status}): ${Ir(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function Ga(t,e){let n=await ct.readFile(t.dest,"utf-8"),{mtime:r}=await ct.stat(t.dest),s=await V_(t,{token:e.token,timeoutMs:e.timeoutMs});if(s.kind==="sync-error")return{kind:"asset-error",message:s.message};let i=s.kind==="synced"?{uploaded:s.uploaded,unchanged:s.unchanged,deleted:[],base:s.base}:void 0,o={Authorization:`Bearer ${e.token}`,"Content-Type":"text/markdown; charset=utf-8"};e.force||(o["If-Unmodified-Since"]=r.toUTCString());let a=await fetch(gf(t),{method:"PUT",body:n,headers:o,signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0}),l=await a.text();if(a.status===409)return{kind:"conflict",message:Ir(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:Ir(l),assets:i};let c=JSON.parse(l);if(await ct.utimes(t.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let f=await G_(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 Kw(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=vf(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=ai.relative(process.cwd(),n.dest)||n.dest,o;try{o=await Ga(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
|
|
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 Sf=S(()=>{"use strict";te();Va();Et()});var In=S(()=>{"use strict";$e();Bb();yn();jb();Ad();Wb();Hb();Js();En();En();Aa();Gd();$e();Va();Sf();Ze();Fe()});import{existsSync as X_,mkdirSync as Q_,readFileSync as Z_,rmSync as eR,writeFileSync as tR}from"fs";import{homedir as nR}from"os";import*as $r from"path";function oR(){return iR.replace('"__TB_SKILL_PATH__"',JSON.stringify(zs())).replace('"__TB_BIN_PATH__"',JSON.stringify(fr()))}function Hw(){try{if(!X_(kf()))return}catch{return}try{let t=rR(),e=oR(),n;try{n=Z_(t,"utf8")}catch{}n!==e&&(Q_($r.dirname(t),{recursive:!0}),tR(t,e))}catch{}for(let t of sR())try{eR(t,{force:!0})}catch{}}var kf,rR,sR,iR,zw=S(()=>{"use strict";In();kf=()=>$r.join(nR(),".pi","agent"),rR=()=>$r.join(kf(),"extensions","typebulb.ts"),sR=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>$r.join(kf(),"extensions",t)),iR=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,Qt=S(()=>{"use strict";X=process.cwd()});import{spawn as
|
|
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,Xw
|
|
2019
|
+
`});function V(t){return t?.message??String(t)}var X,Qt=S(()=>{"use strict";X=process.cwd()});import{spawn as Yw}from"child_process";import{StringDecoder as aR}from"string_decoder";function pR(t,e){let n=new aR("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 lR,Vw,Gw,xf,Xw,cR,uR,dR,Qw,fR,Xa,Qa,Zw,ev=S(()=>{"use strict";Qt();lR=3e4,Vw=18e4,Gw="starting pi\u2026",xf=5e3,Xw=2e3,cR=2e3,uR=12e4,dR=8e3,Qw=15e3,fR=new Set(["get_state","get_commands","get_available_models","set_model","set_thinking_level","cycle_thinking_level","get_session_stats","compact","set_auto_compaction","get_fork_messages","fork","clone","set_session_name","export_html","bash","abort_bash"]),Xa=new Set;process.on("exit",()=>{for(let t of Xa)try{t.kill()}catch{}});Qa=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)=>Yw(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()+Vw,this.#r={text:Gw,kind:"info"},Xa.add(i),i.stdout&&pR(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-cR)}),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"),Xa.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===Gw&&(this.#r=null),this.#i&&(this.#i.until=Date.now()+Qw),!this.#o&&Date.now()<this.#e&&(this.#e=Date.now()+xf),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(!fR.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let n=await this.#h(e);if(n.success&&e.type==="set_model"){let r=n.data?.id;typeof r=="string"&&r&&(this.#w=r)}if(n.success&&(e.type==="fork"||e.type==="clone")){try{let s=(await this.#h({type:"get_state"})).data?.sessionFile;typeof s=="string"&&s&&(this.#m=s)}catch{}return{ok:!0,data:{...n.data??{},sessionFile:this.#m}}}return n.success?{ok:!0,data:n.data}:{ok:!1,error:n.error??`pi rejected ${e.type}`}}catch(n){return{ok:!1,error: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+xf),{ok:!0};let a;try{a=await this.#h(i)}catch(l){return{ok:!1,error:V(l)}}return a.success&&o(Date.now()+xf),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,Zw(Xw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,Zw(Xw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{Yw("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}Xa.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"?dR:Qw)})}#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?Vw:lR,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??uR),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()}},Zw=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as tv,readFileSync as hR,realpathSync as mR}from"fs";import{join as $n,dirname as iv,resolve as gR}from"path";import{homedir as nv}from"os";function bR(t,e){let n=$n(t,".pi");if(yR.some(s=>tv($n(n,s))))return!0;let r=$n(e,".agents","skills");for(let s=t;;){let i=$n(s,".agents","skills");if(i!==r&&tv(i))return!0;let o=iv(s);if(o===s)return!1;s=o}}function wR(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=iv(n);if(r===n)return!1;n=r}}function ov(t,e){try{let n=e?.agentDir??$n(nv(),".pi","agent"),r=rv(e?.home??process.env.HOME??nv()),s=rv(gR(t));if(!bR(s,r))return null;let i=sv($n(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||wR(sv($n(n,"trust.json")),s)?null:"pi has no trust decision for this project \u2014 running untrusted; run `pi` once in a terminal to grant it"}catch{return null}}var yR,rv,sv,av=S(()=>{"use strict";yR=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],rv=t=>{try{return mR(t)}catch{return t}},sv=t=>{try{return JSON.parse(hR(t,"utf8"))}catch{return{}}}});import{statSync as vR,openSync as SR,readSync as kR,closeSync as xR,existsSync as cv}from"fs";import{join as Za}from"path";import{homedir as Ef}from"os";import{execFile as ER}from"child_process";async function TR(t){let e=Za(Ef(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...cv(e)?[e]:[]]){let r=await new Promise(s=>{ER(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 CR(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function lv(t){return t.type==="message"?OR(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var AR,OR,Nr,Af=S(()=>{"use strict";_s();Jo();Wo();zw();ev();av();AR=Za(Ef(),".pi","agent","sessions");OR=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";Nr=class extends Ut{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return cv(Za(Ef(),".pi","agent"))}ensureHarnessSupport(){Hw()}createDriver(e,n){let r=new Qa(e,n),s=ov(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return TR(e)}sessionsDir(e){return Za(AR,CR(e))}listSessionFiles(e){return qo(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 lv(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:je(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)lv(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=SR(e,"r")}catch{return""}try{let s=65536;try{s=vR(e).size}catch{}let i=(d,u)=>{let p=Buffer.alloc(u),h=kR(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{xR(n)}}searchText(e){if(e?.type!=="message")return"";let n=e.message?.role;if(n!=="user"&&n!=="assistant")return"";let r=e.message?.content,s="";return typeof r=="string"?s=r:Array.isArray(r)&&(s=r.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(" ")),s.replace(/\s+/g," ").trim()}contentText(e){return typeof e=="string"?Re(e):Array.isArray(e)?e.map(n=>typeof n?.text=="string"?Re(n.text):n?.type==="image"&&n.data?Fo(n.data,n.mimeType):"").filter(Boolean).join(`
|
|
2029
|
+
`):""}}});var el,uv=S(()=>{"use strict";el=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as PR}from"child_process";import{promisify as _R}from"util";import{readFile as RR}from"fs/promises";import{resolve as dv,sep as IR}from"path";async function ve(t,e){let{stdout:n}=await $R("git",t,{cwd:e,maxBuffer:67108864});return n}async function Nn(){if(tl)return tl;try{tl=(await ve(["rev-parse","--show-toplevel"],X)).trim()}catch{}return tl}function NR(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function Cf(){let t=await Nn();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:NR(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 Of(t){let e=await Nn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await ve(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=dv(e,t);if(!s.startsWith(dv(e)+IR))return{ok:!1,error:"outside repository"};let i=await RR(s);return i.includes(0)?Tf("Binary file (not shown)",!1):Tf(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 Tf(r,!1)}catch(n){return{ok:!1,error:V(n)}}}var $R,fv,tl,Tf,Lr=S(()=>{"use strict";Qt();$R=_R(PR),fv=2e6;Tf=(t,e)=>({ok:!0,text:t.slice(0,fv),untracked:e,truncated:t.length>fv})});function li(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 Pf=S(()=>{"use strict"});function pv(){return LR.map(([t,e])=>wt(t,e)).filter(t=>typeof t!="string")}function hv(){return pv().length>0}async function nl(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of pv()){try{let i=await Ht(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await Wd(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var LR,_f=S(()=>{"use strict";Wt();In();LR=[["openrouter","anthropic/claude-haiku-5.5"],["anthropic","claude-haiku-5-5"],["openai","gpt-6-luna"]]});var rl,sl,At,il,Mr=S(()=>{"use strict";rl=".typebulb/paste",sl={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",il=t=>t.failing&&t.state!=="stopped"?"failing":t.state});import{existsSync as MR,mkdirSync as DR,writeFileSync as BR,readFileSync as jR}from"fs";import{join as ol}from"path";function mv(){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 qR(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function JR(t){let e=await nl(`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,UR)}`,FR);return e&&qR(e)||void 0}async function gv(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=ol(t,rl);try{DR(n,{recursive:!0})}catch(a){return{ok:!1,error:V(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${mv()}`,s=Object.keys(sl).find(a=>sl[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await JR(e.data)??`paste-${mv()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;MR(ol(n,o));a++)o=`${r}-${a}.${s}`;try{BR(ol(n,o),i)}catch(a){return{ok:!1,error:V(a)}}return{ok:!0,path:`${rl}/${o}`}}function yv(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=sl[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:jR(ol(t,rl,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var FR,UR,bv=S(()=>{"use strict";_f();Qt();Mr();FR=4e3,UR=4e3});async function Sv(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!hv())return HR;let r=e.trim()?vv+`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
|
+
`+KR(e.trim())+`
|
|
2033
2033
|
|
|
2034
2034
|
REPLY TO SUMMARIZE:
|
|
2035
|
-
`+n.slice(0,
|
|
2035
|
+
`+n.slice(0,wv):vv+n.slice(0,wv),s=await nl(r,WR,1);return s?{ok:!0,text:s}:zR}var WR,wv,vv,KR,HR,zR,kv=S(()=>{"use strict";_f();WR=2e4,wv=24e3,vv=`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
|
+
`,KR=(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
|
|
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
|
|
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)},HR={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},zR={ok:!1,error:"the model call failed or timed out"}});import{readFileSync as YR,statSync as VR}from"fs";function al(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 ll(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 xv(t,e,n){let r=t.forRead(),s;try{s=YR(e,"utf8")}catch{return[]}let{entries:i,add:o}=ll(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(...al(r,u,n,d).events)}catch{}return f}function cl(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-VR(r).mtimeMs<1e4}catch{return!1}}function ci(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var Rf=S(()=>{"use strict"});function GR(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 Ev(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 ui,If=S(()=>{"use strict";ui=(t,e)=>GR(t,{key:e,desc:!0})});function Pv(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:Ln(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,...QR(e,s,i,l,f)}}function QR(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>=XR&&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 Lf(t,e){if(Nf(t))return;let n=_v(t),r=t.background?t.endAt:t.doneAt,s=pi(t),i=!n&&(t.exit!==void 0?t.exit!==0&&!(t.exit===1&&s&&Uy(Go(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&&qy(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,...ZR(o)}}function ZR(t){let e=Os(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:Ln(e[0]??"",120),last:e.length>1?Ln(e.at(-1),120):""}}function nI(t,e,n=fi){let r=new Map,s=0;for(let o of t.calls){let a=pi(o),l=a&&Lf(o,e);if(!l)continue;let c=Ov(a).trim();if(Fy(c)){s++;continue}r.set(c,[...r.get(c)??[],l])}let i=[...r].map(([o,a])=>{let l=0;for(let d of a.filter(u=>!u.open&&!u.hidden).reverse()){if(!d.failed)break;l++}let c=$s(o),f=[eI.test(c)?"stops a process":"",tI.test(c)?"git write":""].filter(Boolean);return{cmd:Ln(nd(o),100),runs:a.length,open:a.filter(d=>d.open).length,failed:a.filter(d=>d.failed).length,hidden:a.filter(d=>d.hidden).length,streak:l,long:a.some(d=>(d.ms??0)>n)?`over ${n%6e4?`${Math.round(n/1e3)}s`:ue(n)}`:"",ms:a.reduce((d,u)=>d+(u.ms??0),0),tags:f,latest:a.at(-1)}}).sort((o,a)=>(a.latest.at??0)-(o.latest.at??0));return{runs:i.reduce((o,a)=>o+a.runs,0),failed:i.reduce((o,a)=>o+a.failed,0),lookups:s,groups:i}}function aI(t){let e=t.filter(Boolean),n=e.slice(Math.max(0,e.map(oI).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 Rv(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=Ay(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=(P,_={},k=!1)=>{let N=a(P);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=(P,_)=>{let k=a(P),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[P,_]of Object.entries(p)){if(P==="command"||P==="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=iI.some(P=>P in p);!h&&m&&g&&d(m,{},typeof p.content=="string");let b=ee(p.file_path)??ee(p.filePath);if(b&&!g&&!h){let P=l(b);P&&s.push({path:P,at:f})}let C=P=>Object.entries(p).filter(([_,k])=>typeof k=="string"&&(_===P||_.startsWith(`${P} (`))).map(([,_])=>_);if(c.name==="read")for(let P of C("path")){let _=l(P);_&&s.push({path:_,at:f})}let T=ee(p.workdir),E=P=>{let{dirs:_,rest:k}=Go(P);return{rest:k,at:N=>aI([e,T??"",..._,N].map(o))}};for(let P of[...C("command"),...C("cmd")]){let _=E(P);for(let k of Ky(_.rest)){let N=_.at(k),B=N&&l(N);B&&i.push({path:B,at:f})}}let $=pi(c);if($){let P=E($);for(let _ of Jy(P.rest)){let k=P.at(_.from),N=_.to&&P.at(_.to);k&&N?u(k,N):k&&!_.to&&d(k,{deleted:!0})}}}return{edited:[...n.values()],writes:r,reads:s,shellReads:i}}function Iv(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 $v(t,e,n,r,s,i,o,a=Mf,l=fi){let c=b=>`"${s.get(b)??b}"`,f=e.calls.filter(b=>!Nf(b)&&_v(b)).map(b=>({id:b.id,label:$f(b),short:Ln(ee(b.input?.description)??"",80)||$f(b),at:b.at,background:!!b.background,interrupted:!i||t.liveSince!==void 0&&(b.at??0)<t.liveSince,said:xI(Lf(b,o))})),d=new Map;for(let b of[...n.reads,...n.shellReads].sort((C,T)=>C.at-T.at)){let C=d.get(b.path)??{path:b.path,times:0,at:0};d.delete(b.path),d.set(b.path,{...C,times:C.times+1,at:Math.max(C.at,b.at)})}let u=t.state==="running"&&!f.length?e.calls.filter(b=>!Nf(b)).at(-1):void 0,p=u&&Lf(u),h=il(t),m=h==="done"?"finished":h,g=m==="finished"&&e.narration.at(-1)?.calls===e.calls.length;return{id:t.id,name:At(t),state:m,asOf:e.lastAt,activeMs:e.span,idleMs:e.idle,toolMs:e.toolMs,open:f,commands:lI(nI(e,o,l),f),files:n.edited.map(b=>{let C=a.since(b.path);return{...b,committed:!a.ignored(b.path)&&!a.uncommitted(b.path),ignored:a.ignored(b.path),also:(r.writers.get(b.path)??[]).filter(T=>T.id!==t.id&&T.at>C).map(T=>({name:s.get(T.id)??T.id,at:T.at})),blind:r.blind.filter(T=>T.path===b.path&&(T.by===t.id||T.over===t.id)&&T.overAt>C).map(T=>T.by===t.id?`\u26A0 written at ${Dr(T.at)} over ${c(T.over)}'s ${Dr(T.overAt)} write without reading it`:`\u26A0 ${c(T.by)} wrote over this agent's ${Dr(T.overAt)} write at ${Dr(T.at)} without reading it`)}}),read:[...d.values()].sort((b,C)=>b.at-C.at),narration:(g?e.narration.slice(0,-1):e.narration).map(b=>b.text),latest:u&&p?{id:u.id,label:$f(u),run:p}:void 0}}function lI(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 Lv(t,e){let n=t.state==="finished"?Mn(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 pI(t,e){if(!t.open.length)return[`Now: ${fI(t,e)}`,...t.latest?[`Latest: ${t.latest.label} \xB7 ${jv(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: ${Cv(t.open[0],e)}`,...n(t.open[0]," ")]:["Now:",...t.open.flatMap(r=>[` ${Cv(r,e)}`,...n(r," ")])]}function hI(t,e){let n=t.latest;return`latest: ${n.interrupted?"interrupted":n.open?`running ${ue(e-(n.at??e))}`:`${jv(n)}${n.ms!==void 0?` after ${ue(n.ms)}`:""}`}${t.streak>=2?`, failed ${t.streak} in a row`:""}`}function Mv(t,e){let n=[`Sub-agent "${t.name}" (${t.id}): ${dI(t,e)}${t.asOf?` \xB7 as of ${Dr(t.asOf)}`:""}`,""];n.push(...pI(t,e));let r=t.commands;n.push(`Commands: ${rI(r)}`);let{shown:s,more:i}=wI(r);for(let l of s){let c=kI(l);n.push(` ${l.cmd} \xD7${l.runs}${l.failed?`, ${l.failed} failed`:""}${c?` \xB7 ${c}`:""}`,` ${hI(l,e)}`);let f=[l.latest.first,l.latest.last].filter(Boolean).map(d=>`"${d}"`).join(" \u2026 ");f&&n.push(` ${f}`)}i&&n.push(` ${vI(i)}`),Bv(r).runs&&n.push(` ${SI(r)}`),t.activeMs&&n.push(`Time: ${yI(t,e)}`),t.narration.length&&n.push("Narration:",...t.narration.map(l=>` ${l}`)),n.push(`Files written: ${mI(t)}`);for(let l of t.files){let c=l.also.length?` also ${bI(l)}`:"";n.push(` ${EI(l)}${l.ignored?" (ignored)":l.committed?" (committed)":""}${c}`,...l.blind.map(f=>` ${f}`))}let{shown:o,earlier:a}=TI(t);return n.push(`Files read: ${t.read.length||"none"}`,...a?[` +${a} earlier`]:[],...o.map(l=>` ${AI(l)}`)),n.join(`
|
|
2061
|
+
`)}function gI(t,e){let n=t.toolMs+(Mn(t).some(r=>!r.background)?Nv(t,e):0);return{tools:n,model:Math.max(0,Df(t,e)-n)}}function Fv(t,e,n,r){let s=e.filter(di).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=>di(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=Mn(u)[0],h=u.state==="finished"?Mn(u).filter(E=>E.background):[],m=Lv(u,r).padEnd(8),g=h.length?h[0].short:p?`waiting ${ue(r-(p.at??r))} on ${p.short}`:"",b=cI(u),C=[g,b>=2?`failed ${b} in a row`:"",n.some(E=>E.blind.includes(u.id))?"\u26A0":""].filter(Boolean),T=u.parentId&&l.has(u.parentId)?" ".repeat(Math.max(0,u.depth-1)):"";o.push(` ${T}${u.id} ${m} ${`${ue(Df(u,r))} active`.padStart(10)} ${u.name}${C.length?` \xB7 ${C.join(" \xB7 ")}`:""}`)}let c=e.filter(u=>!l.has(u.id)),f=c.filter(u=>u.state==="stopped").length,d=[c.length-f?`${c.length-f} finished`:"",f?`${f} stopped`:""].filter(Boolean).join(", ");return c.length&&o.push(` ${a.length?"+":""}${d}, nothing to check`),o.push("","Run `typebulb status <id>` for one agent's report, or `typebulb babysit` in the background to be woken when an agent needs attention."),o.join(`
|
|
2062
|
+
`)}function Uv(t,e,n=!1,r=fi){let s=new Map,i=l=>`"${t.find(c=>c.id===l)?.name??l}"`,o=Math.max(0,...t.map(l=>l.asOf));t.length&&!n&&!t.some(di)&&e-o>=CI&&s.set("idle",`No agent running for ${ue(e-o)} (${t.length} agents).`);for(let l of t){if(l.state==="finished")for(let c of Mn(l).filter(f=>f.background&&e-(f.at??e)>=r))s.set(`background:${c.id}`,`${i(l.id)}: finished, background call running ${ue(e-(c.at??e))}: ${c.short}`);for(let c of l.commands.groups.filter(f=>f.streak>=2))s.set(`streak:${l.id}:${c.cmd}`,`${i(l.id)}: failed ${c.streak} in a row: ${c.cmd}`)}let a=t.flatMap(l=>Mn(l).filter(c=>!c.background&&e-(c.at??e)>=r).map(c=>({a:l,ms:e-(c.at??e)})));return new Set(a.map(l=>l.a.id)).size>=2&&s.set("waiting",`${new Set(a.map(l=>l.a.id)).size} agents waiting on calls at once: ${a.map(l=>`${i(l.a.id)} ${ue(l.ms)}`).join(", ")}`),s}var XR,Av,Tv,fi,Ln,Ov,pi,Dr,$f,_v,Nf,eI,tI,rI,sI,iI,oI,Mf,Mn,di,cI,Nv,Df,uI,dI,Cv,fI,mI,yI,bI,Dv,wI,vI,Bv,SI,kI,xI,jv,EI,AI,TI,CI,ul=S(()=>{"use strict";Mr();Ps();rd();XR=6e4,Av=8,Tv=30,fi=3*6e4,Ln=(t,e)=>(t=Os(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),Ov=t=>Go(t).rest,pi=t=>ee(t.input?.command)??ee(t.input?.cmd),Dr=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),$f=t=>{let e=pi(t);if(e)return Ln(nd(Ov(e).trim()),100);let n=Ln(Cy(t.input),80);return n?`${Vu(t.name)}: ${n}`:Vu(t.name)};_v=t=>t.result===void 0||!!t.background&&t.endAt===void 0,Nf=t=>!!t.refused&&pi(t)!==void 0;eI=/(^|[\s;|&(])(kill|pkill|killall|taskkill|stop-process)\b/i,tI=/\bgit\s+(-C\s+\S+\s+)?(commit|stash|checkout|reset|push|clean|restore|rebase|merge|cherry-pick|revert)(?![\w-])/;rI=t=>[t.runs?`${t.runs} run, ${t.failed} failed`:"",sI(t)].filter(Boolean).join(", ")||"none",sI=t=>t.lookups?`${t.lookups} ${t.lookups===1?"lookup":"lookups"}`:"",iI=["content","diff","new_string","new_source","edits"],oI=t=>/^([a-zA-Z]:)?\//.test(t);Mf={uncommitted:()=>!0,ignored:()=>!1,since:()=>0};Mn=t=>t.open.filter(e=>!e.interrupted),di=t=>t.state==="running"||Mn(t).length>0,cI=t=>Math.max(0,...t.commands.groups.map(e=>e.streak)),Nv=(t,e)=>t.state==="running"?Math.max(0,e-t.asOf):0,Df=(t,e)=>t.activeMs+Nv(t,e);uI=(t,e)=>({state:Lv(t,e),active:`${ue(Df(t,e))} active`,idle:t.idleMs?`${ue(t.idleMs)} idle`:""}),dI=(t,e)=>{let n=uI(t,e);return[n.state,n.active,n.idle].filter(Boolean).join(" \xB7 ")},Cv=(t,e)=>t.interrupted?`${t.label}: interrupted, its process has ended`:`${t.label}, ${ue(e-(t.at??e))}${t.background?" (background)":""}`,fI=(t,e)=>`nothing open, last entry ${ue(e-t.asOf)} ago`;mI=t=>{let e=t.files.filter(n=>!n.committed&&!n.ignored).length;return t.files.length?`${t.files.length} (${e} uncommitted)`:"none"};yI=(t,e)=>{let n=gI(t,e);return`${ue(n.tools)} in tools, ${ue(n.model)} in the model`},bI=t=>t.also.map(e=>`"${e.name}" ${Dr(e.at)}`).join(", "),Dv=t=>t.failed>0||!!t.long||t.runs>=3||t.tags.length>0,wI=t=>{let e=t.groups.filter(Dv);return{shown:e.slice(0,Av),more:Math.max(0,e.length-Av)}},vI=t=>`+${t} more like these`,Bv=t=>{let e=t.groups.filter(n=>!Dv(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)}},SI=(t,e=!0)=>{let n=Bv(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`},kI=t=>[...t.tags,t.long].filter(Boolean).join(", "),xI=t=>t?t.last||t.first:"",jv=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",EI=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path,AI=t=>t.times>1?`${t.path} \xD7${t.times}`:t.path,TI=t=>({shown:t.read.slice(-Tv),earlier:Math.max(0,t.read.length-Tv)});CI=5*6e4});import{openSync as OI,readSync as PI,closeSync as _I,fstatSync as RI,statSync as II,readFileSync as $I,writeFileSync as NI,mkdirSync as LI}from"fs";import{join as qv}from"path";function*pl(t,e){if(!t.listChildren)return;let n=t.callerSessionId?.(e),r=ui(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 Jv(t,e,s.sessionId,s.file,i))}}function Jv(t,e,n,r,s){let i=cl(t,n,e,r);return{sessionId:n,live:i,children:s.map(o=>({...o,state:ci(o,i)}))}}function hi(t,e){let n=t.callerSessionId?.(e);return{sessionId:n,cwd:n&&t.sessionCwd?.(n)||e}}function Wv(t,e){let n=hi(t,e);return n.sessionId?n:{sessionId:pl(t,e).next().value?.sessionId,cwd:e}}function hl(t,e,n){let r=t.listSessionFiles(e).find(s=>s.sessionId===n)?.file;return Jv(t,e,n,r,t.listChildren?.(e,n)??[])}function Kv(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 Zt(t,e){let n=qv(Ie(),"slow",t);if(e)try{LI(qv(n,".."),{recursive:!0}),NI(n,String(e))}catch{}let r=0;try{r=Number($I(n,"utf8"))}catch{}return e||r||fi}function MI(t,e,n){let r={size:-1,mtimeMs:-1};try{r=II(e)}catch{}let s=fl.get(e);if(s&&s.size===r.size&&s.mtime===r.mtimeMs&&s.cwd===n)return s;let i=Pv(xv(t,e,"child")),o={size:r.size,mtime:r.mtimeMs,cwd:n,d:i,touches:Rv(i,n)};return fl.set(e,o),o}function DI(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*dl?r(0,n):`${r(0,dl)}
|
|
2063
|
+
${r(n-dl,dl)}`}catch{return}finally{_I(e)}}async function Dn(t,e,n,r){let s=Ev([...n.children].sort((u,p)=>(u.started??u.mtime)-(p.started??p.mtime))),i=Zt(n.sessionId),o=s.map(u=>MI(t,u.file,e)),a=new Set(s.map(u=>u.file));for(let u of fl.keys())a.has(u)||fl.delete(u);let l=Iv(s.map((u,p)=>({id:u.id,writes:o[p].touches.writes,reads:o[p].touches.reads}))),c=await jI(e,Math.min(1/0,...[...l.writers.values()].flat().map(u=>u.at)),[...l.writers.keys()]),f=new Map(s.map(u=>[u.id,At(u)])),d=s.flatMap((u,p)=>r&&u.id!==r?[]:[{...$v(u,o[p].d,o[p].touches,l,f,n.live,DI,c,i),depth:u.depth,parentId:u.parentId}]);return{reports:d,files:r?[]:BI(d,l,c)}}function BI(t,e,n){let r=new Set(t.filter(di).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 jI(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
|
|
2066
|
-
`);if(
|
|
2067
|
-
`),y.thread);if(y.partial=y.partial.slice(
|
|
2068
|
-
`).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(x.map(async
|
|
2069
|
-
`)){if(!U.trim())continue;let j=t.parseEntry(U);if(!j)continue;let z=t.searchText(j);z&&
|
|
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
|
|
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 Mf}}var fl,dl,ml=S(()=>{"use strict";Lr();Rf();Mr();If();ul();In();fl=new Map;dl=4096});import{existsSync as Hv,openSync as FI,readSync as UI,closeSync as qI,statSync as mi,readdirSync as zv,watchFile as JI,unwatchFile as Yv,mkdirSync as WI,writeFileSync as KI,readFileSync as Bf,unlinkSync as HI,rmSync as zI}from"fs";import{stat as YI}from"fs/promises";import{dirname as VI,join as Bn,resolve as Vv}from"path";function ZI(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Br(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:ll(t),thread:"main"},n;function r(y,x){let v={offset:x,text:""},O;try{O=mi(y).size}catch{return v}if(O<=x)return v;let M;try{M=FI(y,"r")}catch{return v}try{let U=O-x,j=Buffer.alloc(U),z=0;for(;z<U;){let Q=UI(M,j,z,U-z,x+z);if(!Q)break;z+=Q}return{offset:x+z,text:j.subarray(0,z).toString("utf8")}}finally{qI(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(v=>v.file);if(!y.length)return[];let x=new Map(t.listSessionFiles(e.cwd).map(v=>[v.file,v.sessionId]));return y.map(v=>{let O=x.get(v.file);return{rec:v,sessionId:O??v.id,pending:O===void 0}})}let f=()=>c().filter(y=>y.pending&&y.rec.prompt!==void 0);async function d(y){s.delete(y),i===y&&(i=void 0);try{await y.d.dispose()}catch(x){console.error("[composer] dispose:",V(x))}}function u(){let y=a(),x=new Set(f().map(v=>v.rec));for(let v of[...s])v!==y&&(x.has(v)||v.d.streaming||v.d.queue||v.d.error||d(v))}function p(){for(let y of s)y.d.sessionFile&&y.file!==y.d.sessionFile&&(y.file=y.d.sessionFile);if(i&&!e.file&&i.file){let y=t.listSessionFiles(e.cwd).find(x=>x.file===i.file);y&&B(y)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(N(void 0,i.id),e.everAttached=!0)}let h=y=>Bn(y,XI),m=(y,x)=>Bn(h(y),`${x}.lock`);function g(y,x){try{let v=m(y,x);if(Date.now()-mi(v).mtimeMs>=Gv)return!1;try{let O=parseInt(Bf(v,"utf8").trim(),10);if(O===process.pid||!ZI(O))return!1}catch{}return!0}catch{return!1}}function b(y,x){if(x)try{WI(h(y),{recursive:!0}),KI(m(y,x),String(process.pid))}catch(v){console.error("[lock] claim failed:",V(v))}}function C(y){try{zI(Bn(y,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function T(y){let x=h(y);if(!Hv(x))return;let v;try{v=zv(x)}catch{return}let O=Date.now();for(let M of v){if(!M.endsWith(".lock"))continue;let U=Bn(x,M);try{let j=mi(U);O-j.mtimeMs>QI&&HI(U)}catch{}}}function E(y){try{return mi(y),!1}catch(x){return x.code==="ENOENT"}}function $(){let y=e;if(y.file&&!E(y.file)){b(y.cwd,y.sessionId);return}let x=P(y);x&&B(x)}function P(y){if(!y.everAttached)return _(y.cwd)??k(y.cwd,()=>!0)}function _(y){let x=h(y);if(!Hv(x))return;let v;try{v=zv(x)}catch{return}let O;for(let U of v)if(U.endsWith(".lock"))try{let j=mi(Bn(x,U));if(Date.now()-j.mtimeMs>=Gv||parseInt(Bf(Bn(x,U),"utf8").trim(),10)!==process.pid)continue;(!O||j.mtimeMs>O.mtime)&&(O={sessionId:U.slice(0,-5),mtime:j.mtimeMs})}catch{}if(!O)return;let M=t.listSessionFiles(y).find(U=>U.sessionId===O.sessionId);if(!(!M||E(M.file)))return M}function k(y,x){return t.listSessionFiles(y).sort((v,O)=>O.mtime-v.mtime).find(v=>!g(y,v.sessionId)&&x(v))}function N(y,x){let v=e;if(v.file)try{Yv(v.file)}catch{}v.file=y,v.sessionId=x,v.partial="",v.offset=0,v.latest={in:0,out:0,cached:0,cacheCreate:0},v.latestModel=null,v.index=ll(t),v.chainLastId=void 0,v.buffer.push({type:"cleared"}),v.buffer.push({type:"session",sessionId:x})}function B(y){let x=e;i=void 0,Ri(),n=y.file,N(y.file,y.sessionId),x.everAttached=!0,b(x.cwd,y.sessionId),Z(y.file)}function Z(y){if(ie(),!!y){try{Yv(y)}catch{}JI(y,{interval:200},()=>ie())}}function q(){Ri(),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 v=y.partial.lastIndexOf(`
|
|
2066
|
+
`);if(v<0)return;let O=y.index.add(y.partial.slice(0,v).split(`
|
|
2067
|
+
`),y.thread);if(y.partial=y.partial.slice(v+1),!O)return;let M=[],{entries:U}=y.index,j=U.get(O),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=O}function oe(y){let x=new Map;for(let v of y.values()){let O=t.parentOf(v);if(!O)continue;let M=x.get(O);M?M.push(v):x.set(O,[v])}return x}function ye(y,x,v){if(!y)return;let O=x.get(y);if(!O)return;let M=O.filter(Q=>!t.isSidechain(Q,e.thread));if(M.length<2)return;let U=M.filter(Q=>!v.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 v=[],O=[y];for(;O.length;){let j=O.pop();if(t.isSidechain(j,e.thread))continue;v.push(j);let z=x.get(t.idOf(j)??"");if(z)for(let Q of z)O.push(Q)}v.sort((j,z)=>(Date.parse(t.timestampOf(j)??"")||0)-(Date.parse(t.timestampOf(z)??"")||0));let M=[];for(let j of v)t.isRecoveryNoise(j)||M.push(...al(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:v,model:O,cost:M}=al(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(),O&&(e.latestModel=O),v&&(e.latest=v),(v||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 Nn();if(!y)return;let x=Vv(y).toLowerCase();for(let v=Vv(e.cwd);v.toLowerCase()!==x;){let O=VI(v);if(O===v)return;v=O;let M=t.listSessionFiles(v).length;if(M)return{dir:v,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 w=new el;async function A(y,x){e.thread!=="child"&&w.accept(y,x)&&console.log(x)}function R(){return cl(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 v=a();for(let j of s)j!==v&&j.d.dialog;let O=c().filter(j=>j.rec.d.streaming).map(j=>j.sessionId),M=L(),U=t.createDriver?{streaming:!!v?.d.streaming,foreign:!v&&M,draft:v?.d.draft??null,echo:v?.d.echo??null,status:v?.d.status??null,dialog:v?.d.dialog??null,queue:v?.d.queue??null,stats:v?.d.stats??null,model:v?.d.model??null,error:v?.d.error}:void 0;return{events:x.buffer.slice(y),cursor:x.buffer.length,working:!!v?.d.streaming||M,latestModel:x.latestModel,child:x.child?.id??null,composer:U,busy:O}}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:v=>{x.prompt===void 0&&(x.prompt=v)}}}async function He(y,x){if(!t.createDriver)return{ok:!1,error:"not supported"};let v=String(y??"").trim();if(!v)return{ok:!1,error:"empty message"};let O=await J();if(!O.ok)return O;let M=await O.d.send(v,x);return M.ok&&O.markSent(v),M}async function Y(y,x){let v=a();return v?v.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 O=await J();return O.ok?O.d.rpc(y):O}let v=a();return!v||v.d.error?{ok:!1,error:"not running"}:v.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 Kr(){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 an(){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 O=>{try{return{f:O,m:(await YI(Bn(e.cwd,O))).mtimeMs}}catch{return{f:O,m:0}}}))).sort((O,M)=>M.m-O.m).map(O=>O.f)}function _t(){for(let y of[...s])d(y)}async function zl(y){return t.createDriver?gv(e.cwd,y):{ok:!1,error:"not supported"}}async function Yl(y){return yv(e.cwd,String(y??""))}async function nx(y,x){return Sv(String(y??""),String(x??""))}async function rx(y){let x=t.listChildren?.(e.cwd,e.sessionId)??[],v=R(),{reports:[O]}=await Dn(t,e.cwd,{sessionId:e.sessionId,live:v,children:x.map(M=>({...M,state:ci(M,v)}))},y);return O?{ok:!0,report:O}:{ok:!1,error:"child not found"}}async function sx(){let y=t.sessionsWorking?.(e.cwd),x=t.listSessionFiles(e.cwd).map(({sessionId:O,file:M,mtime:U})=>({sessionId:O,mtime:U,preview:t.readPreview(M),working:y?.has(O)})),v=f().map(O=>({sessionId:O.sessionId,mtime:O.rec.startedAt,preview:O.rec.prompt??"",pending:!0}));return ui([...x,...v],O=>O.mtime)}let Lp=new Map;function Mp(y,x){let v=Lp.get(y);if(v&&v.mtime===x)return v.turns;let O=[],M="";try{M=Bf(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&&O.push({text:z,lower:z.toLowerCase()})}return Lp.set(y,{mtime:x,turns:O}),O}async function ix(y){let x=y.toLowerCase(),v=[],O=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=li(Mp(j,z),x),dt=(t.listChildren?.(e.cwd,U)??[]).map(fe=>({c:fe,hit:li(Mp(fe.file,fe.mtime),x)})).filter(fe=>fe.hit.hitCount);if(!(!Q.hitCount&&!dt.length)){for(let{c:fe,hit:ux}of ui(dt,dx=>dx.c.mtime))v.push({sessionId:U,mtime:fe.mtime,preview:At(fe),...ux,child:{id:fe.id,kind:fe.kind,depth:fe.depth}});if(v.push({sessionId:U,mtime:z,preview:t.readPreview(j),working:M?.has(U),...Q}),++O>=e$)break}}return v}async function ox(y){let x=e,v=t.listSessionFiles(x.cwd).find(O=>O.sessionId===y);if(!v){let O=f().find(M=>M.sessionId===y)?.rec;return O?((i!==O||x.sessionId!==O.id)&&(i=O,Ri(),n=void 0,N(void 0,O.id),x.everAttached=!0,u()),{ok:!0}):{ok:!1,error:"session not found"}}return v.file===x.file?{ok:!0}:(B(v),p(),u(),{ok:!0})}async function ax(){if(!t.listChildren||!e.sessionId)return[];let y=R();return t.listChildren(e.cwd,e.sessionId).map(x=>({...x,state:ci(x,y)}))}async function lx(y){let x=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let v=t.listChildren(x.cwd,x.sessionId).find(O=>O.id===y);return v?(x.thread="child",x.child=v,N(v.file,x.sessionId),Z(v.file),{ok:!0}):{ok:!1,error:"child not found"}}async function cx(){let y=n;return!Ri()||!y?{ok:!0}:(N(y,e.sessionId),Z(y),{ok:!0})}function Ri(){let y=e;return y.thread==="main"?!1:(y.thread="main",y.child=void 0,!0)}return C(e.cwd),T(e.cwd),$(),{info:xe,poll:K,logInlineStatus:A,listSessions:sx,searchSessions:ix,attach:ox,listChildren:ax,openChild:lx,closeChild:cx,composerSend:He,composerStop:_e,composerNew:Kr,composerFiles:an,composerUiRespond:Y,composerRpc:de,composerPaste:zl,composerPasteRead:Yl,summarizeTurn:nx,childStatus:rx,shutdownComposer:_t}}var GI,XI,Gv,QI,e$,gl=S(()=>{"use strict";Qt();uv();Lr();Pf();bv();kv();Rf();ml();If();Mr();GI=".typebulb",XI=`${GI}/locks`,Gv=5e3,QI=6e4;e$=50});import{existsSync as qf,mkdirSync as t$,readFileSync as Xv,writeFileSync as n$}from"fs";import{join as jn,isAbsolute as r$}from"path";async function Wf(t,e){let n=r$(t)?t:jn(X,t);return qf(n)?(Pd(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Kf(t){let e=X,n=Od(t),r=jn(e,"typebulbs");t$(r,{recursive:!0});let s=Ed(n),i=`${s}.bulb.md`;for(let c=2;qf(jn(r,i))&&Xv(jn(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=jn(r,i);qf(o)||n$(o,n);let a=jn("typebulbs",i),l=await vn(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Hf(){return G(X)}async function zf(t){let e=(await G()).find(n=>n.pid===t);return e?{ok:!0,outcome:await yt(e)}:(await cr(t),{ok:!0})}async function Yf(){let t=await gn(X);return pa(X).filter(e=>!e.serverOnly).map(e=>({...e,trusted:xn(e.path),lastRunAt:t(e.path)}))}async function Vf(t){let e=t.toLowerCase(),n=[];for(let r of pa(X).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Xv(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}=li(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Gf(t,e){let n=X;e!=null&&mr(t,e);let r=await vn(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function Xf(t){return{cap:await Td(t)}}async function Qf(t,e){return mr(t,e),{ok:!0}}async function Zf(t,e){return Xe(t,e)}async function ep(){return gi&&Date.now()-gi.fetchedAt<=i$?gi.samples:(jf??=o$().finally(()=>{jf=null}),jf)}async function o$(){try{let t=await fetch(`${s$}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(Zv)});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:rc(i.config)}));return gi={samples:s,fetchedAt:Date.now()},s}catch{return gi?.samples??[]}}async function tp(t){return Jf.test(t)?tS(Qv,"samples",t,!0):{ok:!1,error:"bad slug"}}async function rp(){let t=np();if(!t)return{bulbs:[]};let e=`${yl()}
|
|
2071
|
+
${t}`;return en?.key===e&&Date.now()-en.fetchedAt<=a$?{user:en.user,bulbs:en.bulbs}:(Ff??=l$(e,t).finally(()=>{Ff=null}),Ff)}async function Uf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(Zv)});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 l$(t,e){let n={Authorization:`Bearer ${e}`};try{let r=yl(),s;try{s=await Uf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await Uf(r,"/api/me",n)}let o=(await Uf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:rc(a.config)}));return en={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return en?.key===t?{user:en.user,bulbs:en.bulbs}:{bulbs:[]}}}async function sp(t,e,n=!1){return!Jf.test(e)||!Jf.test(t)?{ok:!1,error:"bad slug"}:tS(yl(),t,e,n)}async function tS(t,e,n,r){let s=Ka(e,n);try{let i=await Ya({origin:t,userSlug:e,slug:n,dest:jn(X,s)},{force:r,token:np(),timeoutMs:eS});return i.kind==="conflict"?{ok:!1,conflict:!0,error:"local file differs from the site copy"}:i.kind==="asset-conflict"?{ok:!1,conflict:!0,error:`local assets differ from the site copies (${i.paths.join(", ")})`}:i.kind==="http-error"?{ok:!1,error:`HTTP ${i.status}`}:i.kind==="not-markdown"?{ok:!1,error:`not a bulb (${i.contentType??"no content-type"})`}:{ok:!0,file:s,upToDate:i.kind==="up-to-date"}}catch(i){return{ok:!1,error:i?.message??String(i)}}}async function ip(t,e=!1){let n=np();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=za(t,X,yl()),s=await Ga(r,{token:n,force:e,timeoutMs:eS});return s.kind==="conflict"?{ok:!1,conflict:!0,error:s.message}:s.kind==="asset-error"?{ok:!1,error:`assets sync failed: ${s.message}`}:s.kind==="http-error"?{ok:!1,error:`HTTP ${s.status}: ${s.message}`}:{ok:!0,created:s.created,serverStripped:s.serverStripped}}catch(r){return{ok:!1,error:r?.message??String(r)}}}var s$,Qv,i$,Zv,eS,gi,jf,Jf,a$,en,Ff,yl,np,bl=S(()=>{"use strict";In();Qt();Pf();te();s$="https://api.typebulb.com",Qv="https://typebulb.com",i$=3600*1e3,Zv=5e3,eS=15e3,gi=null,jf=null;Jf=/^[a-z0-9][a-z0-9-]*$/,a$=300*1e3,en=null,Ff=null,yl=()=>Ea("TYPEBULB_ORIGIN",X)||Qv,np=()=>Ea("TYPEBULB_TOKEN",X)});import{readFileSync as lp,writeFileSync as rS,mkdirSync as c$,appendFileSync as sS,rmSync as nS}from"fs";import{join as Sl,dirname as u$}from"path";import{createServer as d$}from"http";function tn(t){try{return JSON.parse(lp(t,"utf8"))}catch{return null}}function vl(t,e){c$(u$(t),{recursive:!0}),rS(t,JSON.stringify(e,null,2)+`
|
|
2072
|
+
`)}function oS(t,e,n){let r=Sl(t,".gitignore"),s="";try{s=lp(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{sS(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 g$(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?wi="live":s>m$&&(wi="uncached")}function lS(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...Md},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function y$(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 cS(t){let e;try{e=JSON.parse(t)}catch{return t}bi=typeof e?.model=="string"?e.model:null,ut&&(e.model=ut),Un&&(e.provider=aS(Un));let n=/haiku/i.test(bi||"");return vi!=null&&!n&&(e.reasoning={effort:op[vi]}),delete e.thinking,e.output_config&&delete e.output_config.effort,y$(e),JSON.stringify(e)}function b$(){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 w$(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 yi(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 v$(t,e,n){if(!ut){yi(e,400,"invalid_request_error",h$);return}let r=process.env.OPENROUTER_API_KEY;if(!r){yi(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(cp,{method:"POST",headers:lS(t,r),body:cS(n),signal:s.signal})}catch(d){yi(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?b$():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});g$(p);let h=f(p);h&&e.write(h)}else e.write(Buffer.from(u))}}catch{}finally{e.writableEnded||e.end()}}async function S$(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(`${cp}/count_tokens`,{method:"POST",headers:lS(t,r),body:cS(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function k$(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){yi(e,404,"not_found_error",n);return}w$(t).then(r=>{if(n.includes("count_tokens"))return S$(t,e,r);if(n.includes("/v1/messages"))return v$(t,e,r);yi(e,404,"not_found_error",n)})}function x$(){return jr&&Fn?Promise.resolve(Fn):new Promise((t,e)=>{let n=d$(k$);n.on("error",e),n.listen(0,"127.0.0.1",()=>{jr=n,Fn=n.address().port,console.log(`[switcher] wire proxy listening on ${wl(Fn)}`),t(Fn)})})}function E$(){try{jr?.close()}catch{}jr=null,Fn=null}function A$(t,e){let n=kl(t),r=tn(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===wl(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=xl(t);if(!tn(i)){let a={};for(let l of iS)a[l]=l in s.env?s.env[l]:null;vl(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=wl(e),s.env.ANTHROPIC_AUTH_TOKEN=p$,vl(n,s),oS(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function T$(t,e,n){let r=xl(t),s=tn(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},vl(r,s)}function uS(t){let e=kl(t),n=xl(t),r=tn(n),s=tn(e);if(s?.env){let i=r?.snapshot||{};for(let o of iS){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{nS(e,{force:!0})}catch{}else vl(e,s)}try{nS(n,{force:!0})}catch{}}async function C$(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await bt()).filter(r=>r.provider==="openrouter"&&!up(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:$d()??void 0;return{hasKey:t,models:e,error:n}}async function O$(){if(jr&&ut)return{active:!0,managed:!0,model:ut,port:Fn,provider:Un,routedModel:bi,caching:wi,reasoning:vi,externalBaseUrl:null};let t=tn(kl(X))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:vi,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function dS(t,e){let n=await x$();return ut=t,Un=e,A$(X,n),n}async function P$({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(up(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 dS(t,dp[t]??null),bi=null,wi="unknown",T$(X,t,Un)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${V(e)}`}}return{ok:!0}}async function _$({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=op.length)?{ok:!1,error:`reasoning level must be 0\u2013${op.length-1} or null`}:(vi=t,{ok:!0,level:t})}async function R$(){return uS(X),ut=null,Un=null,bi=null,wi="unknown",{ok:!0}}async function I$({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=X,r=Sl(n,".env"),s="";try{s=lp(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))rS(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
|
+
`:"";sS(r,i+`OPENROUTER_API_KEY=${e}
|
|
2088
|
+
`)}}catch(i){return{ok:!1,error:V(i)}}return process.env.OPENROUTER_API_KEY=e,oS(n,[".env"],"# secrets"),{ok:!0}}function $$(){if(!(!jr&&!ut)){try{uS(X)}catch{}E$()}}function N$(t,e){return fS.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 L$(t){if(fS.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 M$(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=ap(e?.cache_read_input_tokens)||ap(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 D$({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(up(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:aS(a)}:i),d=await fetch(cp,{method:"POST",signal:l.signal,headers:s,body:f}),u=await d.json().catch(()=>({}));return{r:d,j:u}}finally{clearTimeout(c)}};try{let{r:a,j:l}=await o();if(!a.ok){let b=l?.error?.message||l?.message||JSON.stringify(l).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-n,error:N$(a.status,b),restriction:L$(b)}}let c=typeof l?.provider=="string"?l.provider:void 0,f=l?.content?.find?.(b=>b.type==="text")?.text??l?.content?.[0]?.text??"ok",d=ap(l?.usage?.cache_creation_input_tokens),{r:u,j:p}=await o(c),{works:h,read:m,note:g}=M$(u.ok,p?.usage,c);return h===!0&&c&&(dp[t]=c,ut===t&&(Un=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-n,provider:c,sample:String(f).trim().slice(0,60),cache:{works:h,created:d,read:m,note:g}}}catch(a){let l=V(a);return{ok:!0,callable:!1,ms:Date.now()-n,error:/abort/i.test(l)?"timed out (20s)":l}}}var f$,cp,p$,h$,iS,m$,op,kl,xl,wl,up,jr,Fn,ut,Un,bi,wi,vi,dp,ap,aS,fS,pS=S(()=>{"use strict";In();Qt();Wt();f$="https://openrouter.ai/api",cp=`${f$}/v1/messages`,p$="typebulb-proxy-managed",h$="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.",iS=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],m$=5e3,op=["low","medium","high"],kl=t=>Sl(t,".claude","settings.local.json"),xl=t=>Sl(t,".claude",".cc-switcher.json"),wl=t=>`http://127.0.0.1:${t}`;up=t=>/^anthropic\//i.test(t)||/claude/i.test(t),jr=null,Fn=null,ut=null,Un=null,bi=null,wi="unknown",vi=1,dp={},ap=t=>typeof t=="number"?t:0,aS=t=>({order:[t],allow_fallbacks:!1});fS=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=tn(xl(X)),n=e?.active?.model;if(!n)return;let s=(tn(kl(X))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await dS(n,e.active.provider??dp[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${wl(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",V(e))}})()});var mS={};$i(mS,{agentMessage:()=>zo,attach:()=>W$,blockToMarkdown:()=>Ho,breakout:()=>Kf,capText:()=>Re,childStatus:()=>G$,cleanUserText:()=>qt,clearSwitchModel:()=>R$,closeChild:()=>z$,composerPasteRead:()=>Y$,displayName:()=>B$,downloadSample:()=>tp,firstLineDigest:()=>je,git:()=>ve,gitChangedFiles:()=>Cf,gitDiff:()=>Of,info:()=>j$,isHiddenTurn:()=>Is,launchBulb:()=>Gf,listBreakouts:()=>Hf,listBulbFiles:()=>Yf,listChildren:()=>K$,listMyBulbs:()=>rp,listSamples:()=>ep,listSessions:()=>q$,listSwitchModels:()=>C$,logInlineStatus:()=>U$,openChild:()=>H$,openFile:()=>Wf,poll:()=>F$,predictTrustOf:()=>Xf,probeModel:()=>D$,pullRemoteBulb:()=>sp,pushLocalBulb:()=>ip,readBulbLog:()=>Zf,repoRoot:()=>Nn,saveOpenRouterKey:()=>I$,searchBulbs:()=>Vf,searchSessions:()=>J$,setBulbTrust:()=>Qf,setReasoning:()=>_$,setSwitchModel:()=>P$,shutdownSwitcher:()=>$$,stopBreakout:()=>zf,summarizeTurn:()=>V$,switchState:()=>O$,toolResultDigest:()=>ed});var hS,B$,j$,F$,U$,q$,J$,W$,K$,H$,z$,Y$,V$,G$,gS=S(()=>{"use strict";gl();Vo();bl();Lr();pS();Vo();_s();hS=new ir,B$=hS.displayName,{info:j$,poll:F$,logInlineStatus:U$,listSessions:q$,searchSessions:J$,attach:W$,listChildren:K$,openChild:H$,closeChild:z$,composerPasteRead:Y$,summarizeTurn:V$,childStatus:G$}=Br(hS)});var bS={};$i(bS,{attach:()=>r1,breakout:()=>Kf,childStatus:()=>c1,closeChild:()=>o1,composerPasteRead:()=>a1,displayName:()=>X$,downloadSample:()=>tp,git:()=>ve,gitChangedFiles:()=>Cf,gitDiff:()=>Of,info:()=>Q$,launchBulb:()=>Gf,listBreakouts:()=>Hf,listBulbFiles:()=>Yf,listChildren:()=>s1,listMyBulbs:()=>rp,listSamples:()=>ep,listSessions:()=>t1,logInlineStatus:()=>e1,openChild:()=>i1,openFile:()=>Wf,poll:()=>Z$,predictTrustOf:()=>Xf,pullRemoteBulb:()=>sp,pushLocalBulb:()=>ip,readBulbLog:()=>Zf,repoRoot:()=>Nn,searchBulbs:()=>Vf,searchSessions:()=>n1,setBulbTrust:()=>Qf,stopBreakout:()=>zf,summarizeTurn:()=>l1});var yS,X$,Q$,Z$,e1,t1,n1,r1,s1,i1,o1,a1,l1,c1,wS=S(()=>{"use strict";gl();cd();bl();Lr();yS=new ar,X$=yS.displayName,{info:Q$,poll:Z$,logInlineStatus:e1,listSessions:t1,searchSessions:n1,attach:r1,listChildren:s1,openChild:i1,closeChild:o1,composerPasteRead:a1,summarizeTurn:l1,childStatus:c1}=Br(yS)});import{readFileSync as u1,writeFileSync as d1,mkdirSync as f1}from"fs";import{homedir as p1}from"os";import*as El from"path";async function kS(){try{let t=await fetch(new URL("/api/tags",SS()).toString(),{signal:AbortSignal.timeout(h1)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function xS(t){let e;try{e=u1(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&&!fp(r)}}}catch{}return{json:void 0,unreadable:!0}}function fp(t){let e=t?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function m1(t){let e=fp(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 ES(){let{json:t,unreadable:e}=xS(vS());return e?{installed:[],configured:null}:{installed:await kS(),configured:m1(t)}}async function AS(){let t=await kS();return t.length?g1(vS(),t,SS()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function g1(t,e,n){let{json:r,unreadable:s}=xS(t);if(s)return{ok:!1,error:`could not parse ${t} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...fp(r)??{},ollama:{baseUrl:`${n}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{f1(El.dirname(t),{recursive:!0}),d1(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 h1,vS,SS,TS=S(()=>{"use strict";Qt();In();h1=1500,vS=()=>El.join(p1(),".pi","agent","models.json"),SS=()=>yr(process.env.OLLAMA_HOST??"http://localhost:11434")});var OS={};$i(OS,{attach:()=>x1,breakout:()=>Kf,closeChild:()=>T1,composerFiles:()=>_1,composerNew:()=>P1,composerPaste:()=>$1,composerPasteRead:()=>N1,composerRpc:()=>I1,composerSend:()=>C1,composerStop:()=>O1,composerUiRespond:()=>R1,displayName:()=>y1,downloadSample:()=>tp,git:()=>ve,gitChangedFiles:()=>Cf,gitDiff:()=>Of,info:()=>b1,launchBulb:()=>Gf,listBreakouts:()=>Hf,listBulbFiles:()=>Yf,listChildren:()=>E1,listMyBulbs:()=>rp,listSamples:()=>ep,listSessions:()=>S1,logInlineStatus:()=>v1,ollamaOffer:()=>ES,ollamaSync:()=>AS,openChild:()=>A1,openFile:()=>Wf,poll:()=>w1,predictTrustOf:()=>Xf,pullRemoteBulb:()=>sp,pushLocalBulb:()=>ip,readBulbLog:()=>Zf,repoRoot:()=>Nn,searchBulbs:()=>Vf,searchSessions:()=>k1,setBulbTrust:()=>Qf,shutdownComposer:()=>M1,stopBreakout:()=>zf,summarizeTurn:()=>L1});var CS,y1,b1,w1,v1,S1,k1,x1,E1,A1,T1,C1,O1,P1,_1,R1,I1,$1,N1,L1,M1,PS=S(()=>{"use strict";gl();Af();bl();Lr();TS();CS=new Nr,y1=CS.displayName,{info:b1,poll:w1,logInlineStatus:v1,listSessions:S1,searchSessions:k1,attach:x1,listChildren:E1,openChild:A1,closeChild:T1,composerSend:C1,composerStop:O1,composerNew:P1,composerFiles:_1,composerUiRespond:R1,composerRpc:I1,composerPaste:$1,composerPasteRead:N1,summarizeTurn:L1,shutdownComposer:M1}=Br(CS)});import*as tx from"fs/promises";import*as Ot from"path";Ni();te();function Yu(t){if(!ze.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${ze.join(", ")})`);return t}function xy(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=Yu(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}Vo();cd();Af();var Al={claude:{adapter:()=>new ir,server:()=>Promise.resolve().then(()=>(gS(),mS))},codex:{adapter:()=>new ar,server:()=>Promise.resolve().then(()=>(wS(),bS))},pi:{adapter:()=>new Nr,server:()=>Promise.resolve().then(()=>(PS(),OS))}};function _S(t){return t in Al}function Fr(){return Object.keys(Al)}function Ur(){return Object.fromEntries(Object.entries(Al).map(([t,e])=>[t,e.adapter]))}function RS(t){return Al[t].server()}var Si=Ur();function IS(){for(let t of Object.values(Si))try{t().ensureHarnessSupport()}catch{}}function rt(){for(let t of Object.keys(Si))try{if(Si[t]().detectsSelf())return t}catch{}}function $S(t){let e=Fr(),n=new Map(e.filter(i=>Si[i]).map(i=>[i,Si[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 hp=5e3;function pp(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function D1(t){let e=/^(\d+(?:\.\d+)?)([smh]?)$/.exec(t??""),n=e?Number(e[1])*{s:1e3,m:6e4,h:36e5,"":6e4}[e[2]]:0;return n>0?n:void 0}function NS(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==="--slow"){let l=D1(t[++o]);l===void 0&&(console.error(`Invalid --slow value: ${t[o]} (a duration, e.g. 90s, 8m, 1h)`),process.exit(1)),n.slowMs=l}else if(a==="--wait"||a.startsWith("--wait="))if(a.startsWith("--wait=")){let l=parseInt(a.slice(7),10);(isNaN(l)||l<=0)&&(console.error(`Invalid --wait value: ${a.slice(7)} (milliseconds)`),process.exit(1)),n.sendWaitMs=l}else n.sendWaitMs=hp;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=pp(()=>qp(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=pp(()=>Yu(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=pp(()=>xy(i.slice(1)))),n}function LS(){console.log(`
|
|
2090
2090
|
typebulb - Local bulb runner for Typebulb
|
|
2091
2091
|
|
|
2092
2092
|
Usage:
|
|
@@ -2187,6 +2187,7 @@ Usage:
|
|
|
2187
2187
|
at once), then print it and exit.
|
|
2188
2188
|
Run it in the background; the exit is your
|
|
2189
2189
|
wake-up. Run it again after handling it.
|
|
2190
|
+
Both take --slow (below).
|
|
2190
2191
|
|
|
2191
2192
|
Options:
|
|
2192
2193
|
-f, --follow Stream new log output until interrupted (logs)
|
|
@@ -2202,6 +2203,9 @@ Options:
|
|
|
2202
2203
|
changed since your last sync (push)
|
|
2203
2204
|
--timeout <sec> Give up after this long; exit 2 \u2014 bounds only a
|
|
2204
2205
|
manual (foreground) bulb wait, default 1800 (wait)
|
|
2206
|
+
--slow <dur> When a call is slow: listed in Status, and a wake
|
|
2207
|
+
once agents wait on it (default 3m). Kept for the
|
|
2208
|
+
session, the mirror's view included (status, babysit)
|
|
2205
2209
|
--wait[=ms] For 'send': bound the whole exchange \u2014 retry while
|
|
2206
2210
|
no page is connected (a hot reload's gap), then
|
|
2207
2211
|
hold for the handlers' replies (default 5000).
|
|
@@ -2274,7 +2278,7 @@ Examples:
|
|
|
2274
2278
|
typebulb my-editor.bulb.md
|
|
2275
2279
|
typebulb --no-watch my-editor.bulb.md
|
|
2276
2280
|
typebulb .
|
|
2277
|
-
`)}Et();
|
|
2281
|
+
`)}Et();Fs();Ni();Js();Et();import*as Ke from"path";import{spawn as dN,execSync as fN}from"child_process";import{createRequire as pN}from"module";import{existsSync as hN}from"fs";import*as Ee from"fs/promises";import*as Se from"path";var mp=[{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"}],gp=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function yp(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 B1=`
|
|
2278
2282
|
/**
|
|
2279
2283
|
* Get raw data chunk from the Data tab.
|
|
2280
2284
|
* @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
|
|
@@ -2285,7 +2289,7 @@ Examples:
|
|
|
2285
2289
|
* @param index - Chunk index (0-based)
|
|
2286
2290
|
* @throws If chunk is not valid JSON/JSON-ish
|
|
2287
2291
|
*/
|
|
2288
|
-
json<T = unknown>(index: number): T;`,
|
|
2292
|
+
json<T = unknown>(index: number): T;`,j1=`
|
|
2289
2293
|
/**
|
|
2290
2294
|
* Get the insight data produced by the inference layer.
|
|
2291
2295
|
*
|
|
@@ -2294,7 +2298,7 @@ Examples:
|
|
|
2294
2298
|
*
|
|
2295
2299
|
* @returns The parsed insight JSON, or undefined if no insight is available
|
|
2296
2300
|
*/
|
|
2297
|
-
insight<T = unknown>(): T | undefined;`,
|
|
2301
|
+
insight<T = unknown>(): T | undefined;`,F1=`
|
|
2298
2302
|
/**
|
|
2299
2303
|
* Replace the data this run is working on.
|
|
2300
2304
|
*
|
|
@@ -2317,7 +2321,7 @@ Examples:
|
|
|
2317
2321
|
*
|
|
2318
2322
|
* @param value - Any JSON-serializable value
|
|
2319
2323
|
*/
|
|
2320
|
-
setInsight(value: unknown): Promise<void>;`,
|
|
2324
|
+
setInsight(value: unknown): Promise<void>;`,MS=`options: {
|
|
2321
2325
|
messages: Array<{ role: "user" | "assistant"; content: string }>;
|
|
2322
2326
|
system?: string;
|
|
2323
2327
|
/** 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 +2332,7 @@ Examples:
|
|
|
2328
2332
|
webSearch?: boolean;
|
|
2329
2333
|
/** Abort the request. On abort the promise rejects / the stream ends. */
|
|
2330
2334
|
signal?: AbortSignal;
|
|
2331
|
-
}`,
|
|
2335
|
+
}`,DS=`
|
|
2332
2336
|
/** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
|
|
2333
2337
|
* \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
|
|
2334
2338
|
* the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
|
|
@@ -2340,10 +2344,10 @@ type AiChunk =
|
|
|
2340
2344
|
| { kind: "text"; text: string }
|
|
2341
2345
|
| { kind: "reasoning"; text: string }
|
|
2342
2346
|
| { kind: "usage"; usage: AiUsage };
|
|
2343
|
-
`,
|
|
2347
|
+
`,BS=`
|
|
2344
2348
|
/** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
|
|
2345
2349
|
type AiAccess = "own" | "courtesy" | "none";
|
|
2346
|
-
`,
|
|
2350
|
+
`,jS=`
|
|
2347
2351
|
/**
|
|
2348
2352
|
* General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
|
|
2349
2353
|
* returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
|
|
@@ -2353,7 +2357,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2353
2357
|
* @throws On rate limit, network error, or provider error
|
|
2354
2358
|
*/
|
|
2355
2359
|
ai: {
|
|
2356
|
-
(${
|
|
2360
|
+
(${MS}): Promise<{ text: string; usage?: AiUsage }>;
|
|
2357
2361
|
/**
|
|
2358
2362
|
* Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
|
|
2359
2363
|
* as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
|
|
@@ -2370,8 +2374,8 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2370
2374
|
* if (c.kind === "text") answer += c.text;
|
|
2371
2375
|
* }
|
|
2372
2376
|
*/
|
|
2373
|
-
stream(${
|
|
2374
|
-
};`,
|
|
2377
|
+
stream(${MS}): AsyncIterable<AiChunk>;
|
|
2378
|
+
};`,FS=`
|
|
2375
2379
|
/**
|
|
2376
2380
|
* Returns AI models available to the current user.
|
|
2377
2381
|
* Models are filtered by the user's configured API keys.
|
|
@@ -2401,7 +2405,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2401
2405
|
* \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
|
|
2402
2406
|
* model is the host's business and changes without your bulb changing.
|
|
2403
2407
|
*/
|
|
2404
|
-
aiAccess(): Promise<AiAccess>;`,
|
|
2408
|
+
aiAccess(): Promise<AiAccess>;`,U1="\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;",US=`
|
|
2405
2409
|
/**
|
|
2406
2410
|
* The mode this bulb is running in.
|
|
2407
2411
|
*
|
|
@@ -2411,7 +2415,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2411
2415
|
* - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
|
|
2412
2416
|
* (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
|
|
2413
2417
|
*/
|
|
2414
|
-
mode: ${
|
|
2418
|
+
mode: ${gy};`,qS=`
|
|
2415
2419
|
/**
|
|
2416
2420
|
* Local filesystem access (CLI only).
|
|
2417
2421
|
*
|
|
@@ -2432,7 +2436,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2432
2436
|
list(path?: string): Promise<Array<{ name: string; dir: boolean; mtime: number }>>;
|
|
2433
2437
|
/** 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
2438
|
remove(path: string): Promise<boolean>;
|
|
2435
|
-
};`,
|
|
2439
|
+
};`,JS=`
|
|
2436
2440
|
/**
|
|
2437
2441
|
* The bulb's folder \u2014 absolute path to \`<bulb-dir>/<filename-stem>/\`
|
|
2438
2442
|
*
|
|
@@ -2440,7 +2444,7 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2440
2444
|
* \`tb.fs\` already resolves relative paths against it, so bulb code writing
|
|
2441
2445
|
* its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.
|
|
2442
2446
|
*/
|
|
2443
|
-
readonly dir: string;`,
|
|
2447
|
+
readonly dir: string;`,q1=`
|
|
2444
2448
|
/**
|
|
2445
2449
|
* Async value inspector for tensor-like objects.
|
|
2446
2450
|
*
|
|
@@ -2493,49 +2497,49 @@ type AiAccess = "own" | "courtesy" | "none";
|
|
|
2493
2497
|
*
|
|
2494
2498
|
* @returns The full canonical URL
|
|
2495
2499
|
*/
|
|
2496
|
-
url(): Promise<string>;`,
|
|
2500
|
+
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;",W1="\n /**\n * Print to the CLI's stdout \u2014 the bulb's log channel, read back with `typebulb logs <file>`.\n *\n * Ungated: needs no `server.ts` block and no `--trust`, so a Restricted client-only bulb can\n * instrument itself. Args cross to the CLI as JSON; where no CLI serves the page (web, inline,\n * or a transport failure) it falls back to the browser console. Works in `server.ts` too (same\n * as `console.log` there).\n */\n log(...args: any[]): void;",K1="\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>>;",bp=`${DS}${BS}
|
|
2497
2501
|
/**
|
|
2498
2502
|
* Typebulb utilities namespace.
|
|
2499
2503
|
* Type \`tb.\` to discover available helpers.
|
|
2500
2504
|
*/
|
|
2501
|
-
declare const tb: {${
|
|
2505
|
+
declare const tb: {${B1}${q1}${j1}${F1}${W1}${K1}${J1}${jS}${qS}${JS}${FS}${U1}${US}
|
|
2502
2506
|
};
|
|
2503
|
-
`,
|
|
2507
|
+
`,H1=`
|
|
2504
2508
|
/**
|
|
2505
2509
|
* Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
|
|
2506
2510
|
* the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
|
|
2507
2511
|
*/
|
|
2508
|
-
log(...args: any[]): void;`,
|
|
2512
|
+
log(...args: any[]): void;`,wp=`${DS}${BS}
|
|
2509
2513
|
/**
|
|
2510
2514
|
* Typebulb utilities namespace (server-side).
|
|
2511
2515
|
* Type \`tb.\` to discover available helpers.
|
|
2512
2516
|
*/
|
|
2513
|
-
declare const tb: {${
|
|
2517
|
+
declare const tb: {${H1}${jS}${qS}${JS}${FS}${US}
|
|
2514
2518
|
};
|
|
2515
|
-
`;vt();import
|
|
2519
|
+
`;vt();import G1 from"p-limit";vt();import{resolve as KS}from"resolve.exports";var Tt={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},ki=["index.d.ts","index.d.mts"],vp=/\.d\.(ts|mts|cts)$/i;function Tl(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function WS(t){return[`${t}.d.ts`,`${t}.d.mts`]}function nn(t){if(!t||t==="./"||t==="/")return[...ki];let e=t.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=WS(e),r=e.endsWith("/")?e:`${e}/`;return n.push(...WS(`${r}index`)),n}async function qr(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(z1(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function z1(t){return t===408||t===429||t>=500&&t<600}var Cl=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)||Tl(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 qr(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=On(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...ki],n);if(!vp.test(o)){let a=await this.tryUntilSuccess(nn(o),n);if(a)return a}return n(o)}let s=nn(e.path),i=r?.subpath?[...s,...ki]:[...ki,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:vp.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(KS(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(KS(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=Zd(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(nn(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=On(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 Y1}from"fflate";var Ol=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await qr(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=Y1(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 Pl=class{constructor(e,n,r=new Ol){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=Pn.majorOf(r),o=e.filter(a=>Pn.majorOf(a)===i);if(o.length)return o.sort((a,l)=>Pn.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=nn(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 _l=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
2520
|
`).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://"))}};vt();var
|
|
2518
|
-
`);await this.prefetchBareDeps(h,c,u,p,s);let m=l.format(),g=e===m?[e]:[e,m],
|
|
2519
|
-
`,"utf8"),await Ee.writeFile(Se.join(e,"code.tsx"),t.code,"utf8"),await Ee.writeFile(Se.join(e,"tb.d.ts"),
|
|
2520
|
-
`,"utf8"),{dir:e}}function
|
|
2521
|
-
`))console.log(`${e} ${r}`);return t.length>0}function
|
|
2521
|
+
`),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 HS="file:///node_modules",Rl=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${HS}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=On(n);return`${HS}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as V1}from"lru-cache";function zS(t){let e=new V1({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 qr(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 xi=class{constructor(e){this.inFlight=new Map,this.scanner=new _l,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=zS(e.cache),this.typescriptProvider=new Cl(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new Pl(e.cdnClient,e.cache),this.virtualFs=new Rl}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=Tl(l)?[l]:nn(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=G1(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(C=>C.content).join(`
|
|
2522
|
+
`);await this.prefetchBareDeps(h,c,u,p,s);let m=l.format(),g=e===m?[e]:[e,m],b=g.some(C=>this.ambientlyDeclares(i,C));return b?this.markFileAmbient(u,f):p.push(...g.map(C=>({module:C,path:f}))),{pkg:e,mainPath:f,files:u,shims:p,ambient:b}}};uf();vt();Tr();ri();lf();Ar();import*as Jr from"path";var X1=Jr.join(_a,"pkg"),Q1=Jr.join(_a,"files"),Z1=Jr.join(_a,"negative.json"),$l=class{pkgMem=new Map;fileMem=new Map;negativeCache=new _n(new Cr(Z1));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await ne();let n=await St(YS(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 Il(async()=>{await ne(),await Ue(YS(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await ne();let n=await Pa(VS(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await Il(async()=>{await ne(),await Ue(VS(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await Il(async()=>{await ne(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return Il(()=>this.negativeCache.clearNegative(e))}};async function Il(t){try{await t()}catch{}}function YS(t){return Jr.join(X1,et(t)+".json")}function VS(t){return Jr.join(Q1,et(t)+".txt")}Tr();var Sp;function eN(){return Sp||(Sp=new xi({cache:new $l,cdnClient:_w,packageService:Na,versionResolver:Pw})),Sp}var GS="file:///node_modules/";async function XS(t){let e=Ra(t.emitKey,"typecheck");await ne(),await Ee.rm(e,{recursive:!0,force:!0}),await Ee.mkdir(e,{recursive:!0});let n=sN(t.jsxImportSource,t.dependencies),r=await eN().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=Nl(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=Nl(d.path);u&&(a[d.module]=[`./node_modules/${u}`])}for(let f of i){if(f.ambient)continue;let d=Nl(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=Nl(d.path);u&&l.add(`node_modules/${u}`)}if(t.local){delete a[t.local.name];let f=await iN(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=tN(t.jsxImportSource,a,[...l]);return await Ee.writeFile(Se.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
|
|
2523
|
+
`,"utf8"),await Ee.writeFile(Se.join(e,"code.tsx"),t.code,"utf8"),await Ee.writeFile(Se.join(e,"tb.d.ts"),bp,"utf8"),{dir:e}}var kp={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function tN(t,e,n=[]){return{compilerOptions:{...kp,lib:nN([...mp,...gp]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function nN(t){return yp(t).map(e=>rN(e.name))}function rN(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 sN(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function Nl(t){if(!t.startsWith(GS))return;let e=t.slice(GS.length),n=e.indexOf("/");if(!(n<0))return e.slice(n+1)}async function iN(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 oN(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 oN(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 We from"fs/promises";import*as Ct from"path";import{existsSync as aN}from"fs";Tr();ff();var lN="^22";async function QS(t){let e=Ra(t.emitKey,"typecheck-server");await ne(),await We.rm(e,{recursive:!0,force:!0}),await We.mkdir(e,{recursive:!0});let n=Ct.join(t.bulbDir,".typebulb"),r=Ua(t.server).filter(o=>o!==t.local?.name);await Fa([`@types/node@${lN}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=Ct.join(n,"node_modules"),i=Ct.join(e,"node_modules");return await uN(s,i),await We.writeFile(Ct.join(e,"server.ts"),t.server,"utf8"),await We.writeFile(Ct.join(e,"tb.d.ts"),wp,"utf8"),await We.writeFile(Ct.join(e,"tsconfig.json"),JSON.stringify(cN(t.local),null,2)+`
|
|
2524
|
+
`,"utf8"),{dir:e}}function cN(t){let e={...kp,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 uN(t,e){if(!aN(t)){await We.mkdir(e,{recursive:!0});return}await We.rm(e,{recursive:!0,force:!0});let n=process.platform==="win32"?"junction":"dir";await We.symlink(t,e,n)}ma();te();async function ek(t,e){let{bulb:n,config:r,warnings:s,starts:i}=await nt(t),o=Ke.basename(t),a=m=>i.get(m)??1;!n.code&&!n.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let l=!1,c=!1;for(let m of s)console.log(`structure ${m}`);s.length&&(l=!0);let f=Rr(Ke.resolve(t)),d=f?nr(n.name):"";f&&d&&d!==f.slug&&(console.log(`naming filename '${f.slug}.bulb.md' doesn't match the title '${n.name}' \u2014 its slug derives to '${d}'. Rename the file to '${d}.bulb.md', or change name: to suit the filename.`),c=!0),n.code&&(l=ZS(Us(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),n.server&&(l=ZS(Us(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let u=bN([process.cwd(),Ke.dirname(t)]);if(!u){let m=Ke.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 XS({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 QS({server:n.server,bulbDir:Ke.dirname(t),emitKey:t,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:r.dependencies});p.push({role:"server",dir:m})}for(let{role:m,dir:g}of p){let{stdout:b,exitCode:C}=await gN(u,g);for(let T of b.split(/\r?\n/))T.trim()&&console.log(`${m} ${mN(T,o,a)}`);C!==0&&(l=!0)}l&&process.exit(1);let h=[n.code&&"code.tsx",n.server&&"server.ts"].filter(Boolean).join(", ");console.error(c?`\u2713 type-checks (${h}) \u2014 see the naming warning above`:`\u2713 no issues (${h})`)}function ZS(t,e){for(let n of t)for(let r of n.message.split(`
|
|
2525
|
+
`))console.log(`${e} ${r}`);return t.length>0}function mN(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 gN(t,e){return new Promise(n=>{let r=dN(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 yN=pN(import.meta.url);function bN(t){let e=r=>{try{let s=yN.resolve("typescript/package.json",{paths:r}),i=Ke.join(Ke.dirname(s),"lib","tsc.js");return hN(i)?i:void 0}catch{return}},n=e(t);if(n)return n;try{let r=fN("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}Et();ha();Js();async function tk(t,e){let{bulb:n}=await nt(t),r=hr(n);if(xn(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.)")}Js();import*as Ei from"path";async function nk(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=Id();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=Ei.resolve(t);n.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{mr(n,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${Ei.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${Ei.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}$e();import*as ik from"readline";Gd();function xp(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 wN=5e3,Ll=()=>Math.round(performance.now()),rk=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function ok(t){let e=$S(process.cwd()),n=Ll();if("ambiguous"in e){let r=await vN(t,e.ambiguous);return r?sk(t,r,{boot:n,from:Ll()}):SN(t,e.ambiguous)}return sk(t,e.name,{boot:n,from:Ll()})}async function sk(t,e,n){let r,s;try{r=await js(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=Ll()-n.from,{lit:o,litLink:a,brand:l}=xp(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(zs())}`],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>wN?[` slow launch: boot ${rk(n.boot)} \xB7 mirror ${rk(i)}`]:[],u=[` ${l(`typebulb v${t}`)}`,...d,...f,""];process.stdout.write(u.join(`
|
|
2522
2526
|
`)+`
|
|
2523
|
-
`)}async function
|
|
2527
|
+
`)}async function vN(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=xp(!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
2528
|
`)+`
|
|
2525
|
-
`);let i=
|
|
2529
|
+
`);let i=ik.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 SN(t,e){let{lit:n,brand:r}=xp(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
2530
|
`)+`
|
|
2527
|
-
`)}Ze();
|
|
2528
|
-
`+e)}function
|
|
2531
|
+
`)}Ze();En();async function ak(t){we(t);let e=await bt();if(e.length>0){console.log(Vb(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!Nd()){console.log("No AI provider keys found in this directory's .env, and no local Ollama server detected."),console.log("Set one of these to use a cloud model with tb.ai:");for(let[n,r]of Object.entries(gr))console.log(` ${r.padEnd(20)} (${n})`);console.log("\u2026or start Ollama (http://localhost:11434, or set OLLAMA_HOST) for local models. Then re-run `typebulb models`.");return}console.log("Couldn't fetch the model catalog (offline?). tb.ai still works with any valid provider/model id for your keys.")}te();function lk(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=nr(t);e||(console.error(`'${t}' has no slug \u2014 a bulb name needs at least one letter or digit.`),process.exit(1)),console.log(e)}Fe();import*as dk from"path";import{valid as uk,lt as xN}from"semver";$e();var st={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},Ep=3e3,ck=1e4,kN=2500,Ml=class{attached=new Set;leaving=new Set;arrivalWaiters=new Set;goneWaiters=new Set;arrivalSubs=[];settledEmpty;dropAt=0;get count(){return this.attached.size}get lastDropAt(){return this.dropAt}[Symbol.iterator](){return this.attached[Symbol.iterator]()}add(e,n){this.attached.add(e);for(let s of[...this.arrivalWaiters])s(!0);let r={page:e,firstAttach:n,count:this.attached.size};for(let s of this.arrivalSubs)s(r)}closing(e){this.attached.delete(e)&&this.leaving.add(e)}dropped(e){if(this.leaving.delete(e)){this.drainIfGone();return}if(!this.attached.delete(e))return;let n=this.dropAt=Date.now();setTimeout(()=>{this.attached.size===0&&this.dropAt===n&&this.settledEmpty?.()},Ep).unref()}async closeAll(e){let n=[...this.attached];if(!n.length)return{told:0,gone:0};await Promise.all(n.map(s=>s.close(e).catch(()=>{}))),await this.whenGone(n,kN);let r=n.filter(s=>!this.leaving.has(s)).length;for(let s of n)this.leaving.delete(s);return{told:n.length,gone:r}}whenArrives(e){return this.attached.size>0?Promise.resolve(!0):e>0?new Promise(n=>{let r=i=>{clearTimeout(s),this.arrivalWaiters.delete(r),n(i)},s=setTimeout(()=>r(!1),e);s.unref(),this.arrivalWaiters.add(r)}):Promise.resolve(!1)}onArrival(e){this.arrivalSubs.push(e)}onSettledEmpty(e){this.settledEmpty=e}whenGone(e,n){return e.some(r=>this.leaving.has(r))?new Promise(r=>{let s=()=>{e.some(o=>this.leaving.has(o))||(clearTimeout(i),this.goneWaiters.delete(s),r())},i=setTimeout(()=>{this.goneWaiters.delete(s),r()},n);i.unref(),this.goneWaiters.add(s)}):Promise.resolve()}drainIfGone(){for(let e of[...this.goneWaiters])e()}};oa();function EN(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=>dr(o,n));return r&&i.find(o=>o.agent===r)||i[0]}return t.find(i=>se(i.file)===se(e))}var rn=t=>t.agent??dk.basename(t.file);function fk(t){return t===Oe?!1:t&&uk(t)&&uk(Oe)?xN(t,Oe):!0}function AN(t){return t===Oe?"":t?fk(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 TN(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 pk(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?TN(r,n[s]):""}${AN(r.version)} ${r.file}`))}async function Tp(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(xd));console.log("Running bulb servers:"),pk(t,r=>console.log(r),n),console.log(`
|
|
2532
|
+
`+e)}function Dl(t,e,n,r,s){let i=EN(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>\`):`),pk(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function hk(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await Tp(await G(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=Dl(await G(),t,"logs",process.cwd(),rt());if(e.clear){gd(n.pid),console.log(`Cleared log for ${rn(n)} (pid ${n.pid}).`);return}let r=Xe(n.pid),s=r.text;if(e.run!==void 0?(s=bd(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
2533
|
`);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
|
|
2530
2534
|
`)}if(process.stdout.write(s),s&&!s.endsWith(`
|
|
2531
2535
|
`)&&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
|
-
`);
|
|
2534
|
-
`):
|
|
2535
|
-
`).trimEnd()}function
|
|
2536
|
+
`),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 CN=t=>new Promise(e=>setTimeout(e,t));async function mk(t,e){if(!t){Tp(await G(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=Dl(await G(),t,"wait",process.cwd(),rt()),r=e.wake?await ON():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:la(n.pid,l)??(l?la(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,b="",C=[],T="",E=0,$=!1;for(;;){let P=d>=c,_=Xe(n.pid,d);if(d=_.offset,_.text){b+=_.text;let k=b.split(`
|
|
2537
|
+
`);b=k.pop()??"";let N=!1;for(let B of k)B.trim()&&(m&&P&&B.startsWith(st.disconnected)&&(N=!0),!(e.match&&!B.includes(e.match))&&(console.log(B),C.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){T=`the last page of ${rn(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`,console.error(T),E=3;break}}if(g&&Date.now()>=g)break;if(!o&&!g&&Date.now()>=u){T=`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${rn(n)} within ${a}s`,console.error(T),E=2;break}if(!Jt(n.pid)){g||(T=`server ${rn(n)} (pid ${n.pid}) exited while waiting`,console.error(T),E=3,$=!0);break}await CN(400)}if(r){console.error(`detected ${new Date().toISOString()}`);try{await r.adapter.wake(r.sessionId,"typebulb_wait",C.length?C.join(`
|
|
2538
|
+
`):T)}catch(P){console.error(`Not delivered: ${P instanceof Error?P.message:P}`),process.exit(4)}console.error(`accepted ${new Date().toISOString()}`)}$&&process.exit(3),i||Ds(n.pid,d,l),process.exit(E)}async function ON(){let t=rt(),e=t?Ur()[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 gk(t,e){if(e==="killed")return` \u2014 forced (${fk(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 yk(t){if(!t){await Tp(await G(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Dl(await G(),t,"stop",process.cwd(),rt()),n=await yt(e);console.log(`Stopped ${rn(e)} (pid ${e.pid}, ${e.url}).${gk(e,n)}`)}async function bk(t){let e=await Ap(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} ${rn(s)}${gk(s,r[i])}`))}async function Ap(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=>dr(r,e)&&(!n||r.agent===n))}async function wk(t,e){let n=process.cwd(),r=t?[Dl(await G(),t,"restart",n,rt())]:e?await Ap(e):[...await G(n),...await Ap("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 js(s.agent,s.cwd??n)):await vn(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} ${rn(s)} ${i} \u2192 v${Oe}`)}catch(o){console.log(` ${s.url} ${rn(s)} failed: ${o instanceof Error?o.message:o}`),process.exitCode=1}}}$e();Fe();yn();import*as Bl from"path";import*as vk from"http";import{mkdir as PN,writeFile as _N}from"fs/promises";async function Wr(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function Ai(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
|
|
2539
|
+
`).trimEnd()}function RN(t,e){return new Promise((n,r)=>{let s=new URL(t),i=vk.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 IN=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 Sk(t,e,n=0){e==="-"&&(e=Ai(await Wr()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=hp);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=Bl.resolve(t),o=wn(await G(),i)[0];if(!o){let h=(await gn(process.cwd()))(i);console.error(h?`No running server for '${t}' \u2014 it last ran ${IN(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 RN(`${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=pb(i);await PN(Bl.dirname(g),{recursive:!0}),await _N(g,Buffer.from(m.png,"base64"));let b=[m.via?`inside "${m.via}"`:"",m.backdrop?`backdrop ${m.backdrop}`:""].filter(Boolean);console.error(`canvas ${m.width}\xD7${m.height} \u2192 PNG${b.length?` (${b.join("; ")})`:""}`),console.log(g);return}let h;try{h=JSON.parse(u[0])}catch{h=void 0}console.log(typeof h=="string"?h:u[0])}else l.timedOut&&(r&&(console.error(`No reply to '${e}' within ${n/1e3}s \u2014 reload the page and retry.`),process.exit(1)),console.error(`(no reply within ${n/1e3}s \u2014 slow work needs a larger --wait=ms; a reply that NEVER comes is a done-promise that missed an exit, or a blocked main thread: tb:snapshot runs no page code, so its silence too means blocked)`))}Va();Sf();te();import*as kk from"fs/promises";async function xk(t,e){let n=await kk.readFile(t,"utf-8"),r=Wn(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
2540
|
`)?i:i+`
|
|
2537
|
-
`)}te();import*as
|
|
2538
|
-
`);if(
|
|
2541
|
+
`)}te();import*as Ti from"fs/promises";async function Tk(t,e){let n=await Ti.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Wr():await Ti.readFile(o,"utf-8")}catch(l){Ak(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:Ai(a),label:o==="-"?"stdin":o})}let s;try{s=$N(n,r)}catch(i){Ak(`${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 Ti.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 $N(t,e){let n=Wn(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=Ek(nh(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(f!==void 0&&Ai(f)===a){i.push(o);continue}r=Ek(Hr(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 Ek(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function Ak(t){console.error(t),process.exit(1)}Ze();ml();ul();Mr();function Cp(){let t=Ur(),e=rt();return{caller:e,adapters:(e?[e]:Object.keys(t)).map(n=>t[n]()).filter(n=>n.listChildren)}}async function Ok(t,e,n){we(e);let{caller:r,adapters:s}=Cp();if(!s.length){console.error(`Sub-agent status isn't supported for ${r} sessions.`),process.exitCode=1;return}let i;for(let o of s){let{sessionId:a,cwd:l}=hi(o,process.cwd());if(!t){let c=a?hl(o,l,a):pl(o,l).next().value;if(!c?.children.length){if(a){Zt(a,n),console.log("No sub-agents in this session yet.");return}continue}Zt(a??c.sessionId,n);let{reports:f,files:d}=await Dn(o,l,c);console.log(Fv(c.sessionId,f,d,Date.now()));return}for(let c of pl(o,l)){i??=c;let f=Kv(c,t);if(f.length){if(f.length>1){console.error(`Several agents match "${t}"; name one by its id:`);for(let d of f)console.error(` ${Ck(d)}`);process.exitCode=1;return}Zt(a??c.sessionId,n),console.log(Mv((await Dn(o,l,c,f[0].id)).reports[0],Date.now()));return}}}if(!i){console.log("No sub-agents in this project's sessions.");return}console.error(`No agent matches "${t}". The agents of session ${i.sessionId}:`);for(let o of i.children)console.error(` ${Ck(o)}`);process.exitCode=1}var Ck=t=>`${t.id} ${il(t).padEnd(7)} ${At(t)}`;Ze();Fe();$e();ml();ul();import{mkdirSync as NN,readFileSync as Pp,writeFileSync as Rk,rmSync as Pk}from"fs";import{join as Fl}from"path";var LN=1e4,MN=720*6e4,_k="typebulb_babysit";async function Ik(t,e){we(t);let{caller:n,adapters:r}=Cp(),s=r.map(p=>({adapter:p,...(p.wake?hi:Wv)(p,process.cwd())})).find(p=>p.sessionId);if(!s?.sessionId)return Op(r.length?r.some(p=>p.wake)?"Can't babysit: your own session couldn't be identified in this project, and a wake goes to no other.":"No session to babysit in this project.":`Babysitting sub-agents isn't supported for ${n} sessions.`);let{adapter:i,sessionId:o,cwd:a}=s;if(Zt(o,e),i.wake){let p=await i.wakeRoute(o);if(p.error)return Op(`Can't babysit: ${p.error}.`)}let l=Fl(Ie(),"babysit"),c=Fl(l,`${o}.json`);if(!DN(Fl(l,`${o}.lock`)))return Op("A babysit is already watching this session.");let f=[];try{f=JSON.parse(Pp(c,"utf8"))}catch{}let d=p=>{try{Rk(c,JSON.stringify(p))}catch{}};console.error(`Babysitting the sub-agents of session ${o}: this exits with a line when one needs attention.`);let u=Date.now()+MN;for(;Date.now()<u;){i.sessionEnded?.(o,a)&&jl(3,"The session this babysits has ended.");let{reports:p}=await Dn(i,a,hl(i,a,o)),h=Uv(p,Date.now(),!!i.sessionsWorking?.(a)?.has(o),Zt(o)),m=[...h].filter(([g])=>!f.includes(g));if(!m.length)f=[...h.keys()],d(f);else{let g=m.map(([,b])=>b).join(`
|
|
2542
|
+
`);if(i.wake){console.error(`detected ${new Date().toISOString()}`);try{await i.wake(o,_k,g)}catch(b){d([...h.keys()].filter(C=>!m.some(([T])=>T===C))),console.log(g),jl(4,`Not delivered: ${b instanceof Error?b.message:b}`)}console.error(`accepted ${new Date().toISOString()}`)}d([...h.keys()]),console.log(g),jl(0)}await new Promise(g=>setTimeout(g,LN))}i.wake&&await i.wake(o,_k,"typebulb babysit stopped after 12 hours with nothing to report; run it again to keep watching.").catch(()=>{}),jl(2,"Nothing needed attention; gave up.")}function Op(t){console.error(t),process.exitCode=1}function jl(t,e){e&&console.error(e),process.exit(t)}function DN(t){try{NN(Fl(t,".."),{recursive:!0})}catch{}for(let e=0;e<2;e++)try{return Rk(t,String(process.pid),{flag:"wx"}),process.on("exit",()=>{try{Number(Pp(t,"utf8"))===process.pid&&Pk(t)}catch{}}),!0}catch(n){if(n.code!=="EEXIST")return!0;let r=0;try{r=Number(Pp(t,"utf8"))}catch{}if(r&&r!==process.pid&&Jt(r))return!1;try{Pk(t)}catch{}}return!1}Ze();Et();te();ha();import*as on from"fs/promises";import*as qn from"path";import{EventEmitter as iL}from"events";Wt();te();import{Hono as JN}from"hono";import{serve as WN}from"@hono/node-server";import{streamSSE as KN}from"hono/streaming";import*as Ip from"fs/promises";import HN from"open";Tr();ri();Ar();import*as _p from"fs/promises";import*as Ci from"path";var Ul=class{async get(e){let n=et(e),r=Ci.join(ni,n+".bin"),s=Ci.join(ni,n+".json");try{let[i,o]=await Promise.all([_p.readFile(r),_p.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=Ci.join(ni,r+".bin"),i=Ci.join(ni,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([Ue(s,n.body),Ue(i,JSON.stringify(o))])}};var $k=`
|
|
2539
2543
|
const CSS = '\\n' +
|
|
2540
2544
|
/* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
|
|
2541
2545
|
chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
|
|
@@ -2918,22 +2922,22 @@ export function runInference(ctx) {
|
|
|
2918
2922
|
showConfirm();
|
|
2919
2923
|
document.body.appendChild(host);
|
|
2920
2924
|
}
|
|
2921
|
-
`;
|
|
2922
|
-
${u}`:"";return
|
|
2923
|
-
`+Y.slice(-4e3)),new
|
|
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
|
|
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:
|
|
2926
|
-
`):
|
|
2927
|
-
`):
|
|
2928
|
-
`):console.log(` ${
|
|
2925
|
+
`;Or();$e();En();Aa();Wt();import{stream as BN}from"hono/streaming";var jN="X-TB-Stream";function Oi(t){return t instanceof Le?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function ql(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(jN,"1"),BN(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:Oi(s)}))}finally{try{await r.return?.()}catch{}}})}var Jl={log:(...t)=>console.log(...t)};function Wl(t,e){let n=t?.[e]??(Object.hasOwn(Jl,e)?Jl[e]:void 0);return typeof n=="function"?n:void 0}function Kl(t){return t.constructor?.name==="AsyncGeneratorFunction"}pf();var FN=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,UN=/[?&]target=/,qN=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function Nk(t,e=""){return FN.test(t)?!0:qN.test(t)&&UN.test(e)}var zN="127.0.0.1",YN=new Set(["localhost","127.0.0.1","::1"]),jk=(t,e)=>!!t&&typeof t=="object"&&e in t,Lk=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),jk(t,"insight")&&(e.insight=t.insight),e},Mk=8*1024*1024,VN=0;function GN(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function Fk(t){let e=GN(t);return!!e&&YN.has(e)}function XN(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&Fk(e.host)}catch{return!1}}function QN(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function ZN(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function Pi(t){return t instanceof Error?t.message:"Unknown error"}var Dk=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,eL=2e3;async function Uk(t){let{getHtml:e,basePath:n,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:f,trusted:d=!1,trustHint:u,staticAssets:p,bulbAssets:h,sourceFile:m,bulbKey:g,onStop:b}=t,C=`${process.pid}-${++VN}-${Date.now()}`,T=r??n,E=new JN;E.use("*",async(w,A)=>{if(!Fk(w.req.header("host")))return w.text("Forbidden: untrusted Host",403);await A()}),E.use("*",async(w,A)=>{await A(),w.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),w.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let $=[["/__fs/*","the filesystem"],["/__api/*","server-side code (server.ts)"],["/__ai","AI (your API keys)"],["/__infer","AI (your API keys)"],["/__infer-save","the filesystem"]],P=async(w,A)=>{if(!d){let R=new URL(w.req.url).pathname,L=$.find(([K])=>K.endsWith("/*")?R.startsWith(K.slice(0,-2)):R===K)?.[1]??"server-side code (server.ts)";vd(process.pid,L);let D=u?`
|
|
2926
|
+
${u}`:"";return w.text(`Forbidden: this capability requires --trust.${D}`,403)}await A()},_=async(w,A)=>{let R=w.req.header("sec-fetch-site");if(R){if(R!=="same-origin")return w.text(`Forbidden: ${R} request`,403)}else{let L=w.req.header("origin");if(L&&!ZN(L,w.req.header("host")))return w.text("Forbidden: cross-origin request",403)}await A()};for(let[w]of $)E.use(w,P),E.use(w,_);E.use("/__log",_),E.post("/__log",async w=>{try{let{args:A}=await w.req.json();console.log(...A||[])}catch{}return w.json({ok:!0})});let k=new Ml,N=new Set,B=new Set,Z=Date.now();k.onArrival(({page:w,firstAttach:A,count:R})=>{o&&R===1&&console.log(st.connected),A&&R>1&&w.close("yielded").catch(()=>{})}),o&&k.onSettledEmpty(()=>console.log(st.disconnected));let q,ie=0,oe=async w=>{let A=Math.max(w.fresh?0:Z,k.lastDropAt);if(await k.whenArrives(Ep-(Date.now()-A)))return{how:"attached"};if(Date.now()-ie<eL)return{how:"none"};let R=`http://localhost:${s}#tb-relay`,L=await kd(R,n),D;return L?.where==="editor"?D={how:"editor",via:L.via}:(w.external==="force"||w.external==="follow"&&L?.where==="external")&&(await HN(R),D={how:"external"}),D?await k.whenArrives(ck)?D:{how:"unreached",via:Dk(D)}:(ie=Date.now(),{how:"none"})},ye=w=>k.count>0?Promise.resolve({how:"attached"}):q??=oe(w).finally(()=>{q=void 0});if(o){let w=0,A=new Map;E.use("/__send",_),E.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,He=J===0&&k.lastDropAt?Date.now()-k.lastDropAt:void 0,Y={clients:J,droppedMsAgo:He,...K?{opening:K.how,via:Dk(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=an=>{for(let _t of k)_t.send(an).catch(()=>{})};if(D<=0)return de({payload:L}),R.json(Y);let _e=++w,Kr=await new Promise(an=>{let _t={expected:J,received:0,results:[],errors:[],finish:Yl=>{clearTimeout(zl),A.delete(_e),an({results:_t.results,errors:_t.errors,timedOut:Yl})}},zl=setTimeout(()=>_t.finish(!0),D);A.set(_e,_t),de({id:_e,payload:L})});return R.json({...Y,...Kr})}),E.use("/__send-reply",_),E.post("/__send-reply",async R=>{try{let{id:L,results:D,errors:K}=await R.req.json(),J=A.get(L);J&&(J.results.push(...D??[]),J.errors.push(...K??[]),++J.received>=J.expected&&J.finish(!1))}catch{}return R.json({ok:!0})})}E.get("/",w=>w.html(e())),E.post("/__fs/read",async w=>{try{let{path:A}=await w.req.json(),R=await si(A,T);return new Response(new Uint8Array(R),{headers:{"Content-Type":"application/octet-stream"}})}catch(A){let R=Pi(A);return w.json({error:R},400)}}),E.post("/__fs/write",async w=>{try{let A=w.req.query("path");return A?(await qa(A,new Uint8Array(await w.req.arrayBuffer()),T),w.json({success:!0})):w.json({error:"Missing path"},400)}catch(A){let R=Pi(A);return w.json({error:R},400)}}),E.post("/__fs/list",async w=>{try{let{path:A}=await w.req.json();return w.json(await Ja(A??".",T))}catch(A){return w.json({error:Pi(A)},400)}}),E.post("/__fs/remove",async w=>{try{let{path:A}=await w.req.json();return await Wa(A,T),w.json({success:!0})}catch(A){return w.json({error:Pi(A)},400)}}),E.post("/__api/:name",async w=>{try{let A=w.req.param("name"),R=Wl(a?.(),A);if(!R)return w.json({error:`API function '${A}' not found`},404);let{args:L}=await w.req.json();if(Kl(R))return ql(w,R(...L||[]));let D=await R(...L||[]);return w.json({result:D})}catch(A){let R=Pi(A);return w.json({error:R},500)}}),E.post("/__ai",async w=>{try{let{messages:A,system:R,effort:L,provider:D,model:K,webSearch:J,stream:He}=await w.req.json();if(!A||!Array.isArray(A)||A.length===0)return w.json({message:"messages array is required",code:"unknown",retryable:!1},400);let Y=wt(D,K);if(typeof Y=="string")return w.json({message:Y,code:"unknown",retryable:!1},400);let de=await Ht(Y,{messages:A,system:R,effort:L,webSearch:J,signal:w.req.raw.signal});if(!de.ok){let an=await vr(de,Y.protocol);return w.json(an,de.status)}if(He)return ql(w,Cn(de,Y.protocol));let{text:_e,usage:Kr}=await Sr(de,Y.protocol);return _e||console.warn("[tb.ai] Empty response from provider"),w.json({text:_e,usage:Kr})}catch(A){return w.json(Oi(A),500)}}),E.post("/__infer",async w=>{try{let{data:A}=await w.req.json().catch(()=>({})),R=l?.();if(!R?.infer.trim())return w.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let L=wt();if(typeof L=="string")return w.json({message:L,code:"unknown",retryable:!1},400);let D=Array.isArray(A)?A.map(String):[],K=Hd(R,D),J=await Ht(L,{messages:[{role:"user",content:K}],signal:w.req.raw.signal});if(!J.ok){let Y=await vr(J,L.protocol);return w.json(Y,J.status)}let He=(async function*(){let Y="";for await(let _e of Cn(J,L.protocol))_e.kind!=="text"||!_e.text||(Y+=_e.text,yield{kind:"delta",text:_e.text});let de=zd(Y);if(de.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
|
|
2927
|
+
`+Y.slice(-4e3)),new Le("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 ql(w,He)}catch(A){return w.json(Oi(A),500)}}),E.post("/__infer-save",async w=>{try{if(!c)return w.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let A=Lk(await w.req.json().catch(()=>({})));return Object.keys(A).length?(await c(A.data,jk(A,"insight")?JSON.stringify(A.insight,null,2):void 0),w.json({ok:!0})):w.json({message:"Nothing to save \u2014 this page holds no runtime state.",code:"unknown",retryable:!1},400)}catch(A){return w.json(Oi(A),500)}}),E.get("/__infer-info",w=>{let A=l?.(),R=zr(A?.config??"").inference,L=Do(A?.data??""),D=!!A?.infer.trim(),K=wt();return typeof K=="string"?w.json({error:K,inference:R,data:L,hasInfer:D}):w.json({provider:K.protocol,model:K.model,inference:R,data:L,hasInfer:D})}),E.use("/__tb-decode",_),E.post("/__tb-decode",async w=>{let{hash:A}=await w.req.json().catch(()=>({})),R=typeof A=="string"?Vd(A):void 0;return w.json(R??{error:"invalid fragment"})}),E.use("/__tb-encode",_),E.post("/__tb-encode",async w=>{let A=Number(w.req.header("content-length"));if(Number.isFinite(A)&&A>Mk)return w.json({hash:""});let R=await w.req.text().catch(()=>"");if(R.length>Mk)return w.json({hash:""});let L;try{L=JSON.parse(R)}catch{return w.json({hash:""})}return w.json({hash:Yd(Lk(L))})}),E.get("/__infer-ui.js",w=>w.body($k,200,{"Content-Type":"text/javascript; charset=utf-8"})),E.get("/__models",async w=>{try{let A=await bt();return w.json(A)}catch{return w.json([],200)}}),E.get("/__ai-access",async w=>{try{return w.json(await ya())}catch{return w.json("none",200)}}),m&&E.get("/__source/*",async w=>{let A=await Ip.readFile(m,"utf-8").catch(()=>{});return A===void 0?w.text("Not Found",404):new Response(A,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let ke=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],ae=new Ul;E.get("/proxy/*",async w=>{let A=new URL(w.req.url),L=(A.pathname+A.search).slice(7),D=L.lastIndexOf("https://");return D===-1?w.text("Invalid proxy URL",400):xe(w,L.slice(D))}),f&&Bk(E,`/local/${f.name}/`,f.serveDir),p&&Bk(E,p.mount,p.dir),h&&E.get("/assets/*",async w=>{let{pathname:A}=new URL(w.req.url),R=A.slice(8),L;try{L=decodeURIComponent(R)}catch{return w.text("Not Found",404)}let D=oh(L);if(D)return w.text(`${D} is not an asset type: a bulb's code and markup live in the bulb; assets are media and data`,403);try{let J=await qk(L,h.dir,{"Cache-Control":"no-cache"});if(J)return J}catch{return w.text("Not Found",404)}let K=h.remoteBase;return K?w.redirect(K+R,302):w.text("Not Found",404)});async function xe(w,A){let R;try{R=new URL(A)}catch{return w.text("Invalid URL",400)}if(R.protocol!=="https:")return w.text("HTTPS only",400);if(!ke.includes(R.hostname))return w.text("Host not allowed",403);let L=await ae.get(A);if(L)return new Response(L.body,{status:200,headers:Rp(L.contentType,L.cacheControl)});try{let D=await fetch(A,{headers:{Accept:w.req.header("Accept")||"*/*"},redirect:"follow"});if(!D.ok)return w.text(`Upstream ${D.status}`,D.status);let K=D.headers.get("Content-Type")||void 0,J=D.headers.get("Cache-Control")||void 0;if(D.body){let[He,Y]=D.body.tee();return(async()=>{try{let de=await new Response(Y).arrayBuffer();await ae.set(A,{body:Buffer.from(de),contentType:K,cacheControl:J})}catch{}})(),new Response(He,{status:D.status,headers:Rp(K,J)})}return new Response(null,{status:D.status,headers:Rp(K,J)})}catch(D){return w.text(`Proxy fetch failed: ${D instanceof Error?D.message:D}`,502)}}(i||o)&&(E.get("/__reload",w=>KN(w,async A=>{let R=w.req.query("bulb")||void 0;if(g&&R&&R!==g){N.has(R)||(N.add(R),console.log(st.closed("foreign"))),await A.writeSSE({event:"close",data:"foreign"});return}let L=()=>{A.writeSSE({event:"reload",data:""})};i?.on("reload",L);let D=()=>i?.removeListener("reload",L),K=w.req.query("relay")||void 0,J={inEditor:QN(w.req.header("user-agent")),doc:K,open:Y=>A.writeSSE({event:"open-url",data:Y}),send:Y=>A.writeSSE({event:"message",data:JSON.stringify(Y)}),close:Y=>(D(),k.closing(J),console.log(st.closed(Y)),A.writeSSE({event:"close",data:Y}))},He=!!K&&!B.has(K);for(K&&B.add(K),k.add(J,He),A.onAbort(()=>{D(),k.dropped(J)}),await A.writeSSE({event:"hello",data:C,retry:df});!A.aborted;)await A.sleep(3e4)})),E.use("/__open",_),E.post("/__open",async w=>{let A="";try{A=String((await w.req.json()).url??"")}catch{}if(!XN(A))return w.json({error:"a local http URL is required"},400);let R=[...k].find(L=>L.inEditor);return await R?.open(A),w.json({opened:!!R,pages:k.count})})),E.use("/__stop",_),E.post("/__stop",async w=>{if(w.req.header("sec-fetch-site")||w.req.header("origin"))return w.text("Forbidden: browser request",403);let A="close";try{let L=await w.req.json();(L?.pages==="keep"||L?.pages==="close")&&(A=L.pages)}catch{}let R=A==="close"?await k.closeAll("stopped"):{told:0,gone:0};return b&&setTimeout(()=>{b({pages:A})},50),w.json({closed:R.gone,stuck:R.told-R.gone,exiting:!!b})}),E.get("/__pages",w=>w.json({pages:k.count})),E.notFound(async w=>{if(w.req.method!=="GET")return w.text("Not Found",404);let A=new URL(w.req.url);return Nk(A.pathname,A.search)?xe(w,"https://esm.sh"+A.pathname+A.search):w.text("Not Found",404)});let Pt=WN({fetch:E.fetch,port:s,hostname:zN});return Pt.listening||await new Promise((w,A)=>{let R=L=>A(L);Pt.once("error",R),Pt.once("listening",()=>{Pt.removeListener("error",R),w()})}),{port:s,close:()=>Pt.close(),requestPage:ye,closePages:w=>k.closeAll(w),pageCount:()=>k.count}}function Rp(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 Bk(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 qk(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function qk(t,e,n={}){let r=Pr(t,e),s=await Ip.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":ih(r),...n}})}$e();yn();async function Hl(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(`
|
|
2928
|
+
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 bn(process.pid),process.exit(0)}},h=await Uk({...r(e),onStop:p}).catch(async m=>{if(m?.code!=="EADDRINUSE")throw m;return dd(e)});return d=h,await wd(c),console.log(`
|
|
2929
|
+
${i}`),console.log(` ${l}`),n&&console.log(` ${n}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:l,pageCount:()=>h.pageCount(),async handOver({mode:m,fresh:g,replacedLive:b}){if(m==="none")return;let C={fresh:g,external:b?"never":m==="window"?"force":"follow"},T=await h.requestPage(C);T.how==="attached"?console.log(` Reusing the open browser tab.
|
|
2930
|
+
`):T.how==="editor"?console.log(` Opened in VS Code via ${T.via}.
|
|
2931
|
+
`):T.how==="external"?console.log(` Opened in your browser.
|
|
2932
|
+
`):console.log(` ${T.how==="unreached"?`Opened ${T.via?`in VS Code via ${T.via}`:"in your browser"}, but no page attached \u2014 is the browser it opened in still there?`: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
2933
|
Share ${l}, and wake on the arrival:
|
|
2930
2934
|
typebulb wait ${o} --match "${st.connected}"
|
|
2931
|
-
`)},onCleanup(m){f.push(m)}}}
|
|
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(
|
|
2935
|
+
`)},onCleanup(m){f.push(m)}}}yn();import tL from"chokidar";import Jk from"node:fs";import nL from"node:path";var rL={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function sn(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=tL.watch(e,rL);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 sL=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function Wk(t,e,n=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,n)};try{let i=Jk.watch(t,{recursive:!0},(o,a)=>{a&&sL(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=nL.join(t,"assets");return Jk.existsSync(i)?sn({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}$e();Fe();Or();async function Kk(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=Bs(process.pid),o=e.watch?new iL:void 0,a=we(e.mode),l=(await gn(process.cwd()))(t),c=await lr({kind:"bulb",file:t},process.cwd()),f=await ua(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<Iw,{port:u,note:p}=await ia({target:{kind:"bulb",file:t},cwd:process.cwd()});c!==void 0&&u!==c&&d&&(console.error(`
|
|
2936
|
+
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(yd(++h));m(),console.log(`Loading ${qn.basename(t)}...`);let{html:g,bulb:b,serverExports:C}=await mf(t,e.watch,e.trust,r);Kt(a,t,b.server);let T=Rn(t),E=Rr(qn.resolve(t)),$=e.trust?void 0:hr(b),{port:P,onCleanup:_,handOver:k,pageCount:N}=await Hl({port:u,portNote:p,displayName:b.name,stopLog:i,makeServerOptions:oe=>({getHtml:()=>g,basePath:s,fsBase:_r(t),port:oe,reloadEmitter:o,sendChannel:!0,getServerExports:()=>C,getBulbBlocks:()=>({infer:b.infer,insight:b.insight,code:b.code,config:b.config,data:b.data}),saveInferenceResult:async(ye,ke)=>{let ae=await on.readFile(t,"utf-8");ye!==void 0&&(ae=Hr(ae,"data",ye.join(iy))),ke!==void 0&&(ae=Hr(ae,"insight",ke)),await on.writeFile(t,ae)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:T,remoteBase:E&&Bi(E.userSlug,E.slug)},sourceFile:t,bulbKey:Ms(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:qn.relative(process.cwd(),t)||qn.basename(t)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log($?` trust: restricted \u2014 this bulb appears to use ${$}; re-run with --trust to enable it:
|
|
2933
2937
|
${n}
|
|
2934
2938
|
`:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
|
|
2935
2939
|
`),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=
|
|
2940
|
+
`);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=sn({target:t,onChange:()=>{let ae=++oe;ye=ye.then(async()=>{if(ae===oe)try{console.log("Recompiling...");let xe=await mf(t,!0,e.trust,r);g=xe.html,C=xe.serverExports,b=xe.bulb,xe.buildError||m(),q()}catch(xe){console.error("Recompile failed:",xe)}})}}),r){let{name:ae,serveDir:xe}=r;Z=sn({target:xe,events:"all",onChange:()=>ie(`Local package '${ae}' changed.`)})}let ke=_r(t);await on.stat(ke).then(ae=>ae.isDirectory()).catch(()=>!1)&&_(Wk(ke,()=>ie("Assets changed.")))}B&&_(B),Z&&_(Z),_(()=>on.rm(hf(t),{force:!0})),await k({mode:e.open,fresh:!d,replacedLive:f.some(oe=>oe.port===P)})}Ze();import{readFileSync as Np,copyFileSync as aL,existsSync as lL,writeFileSync as cL,renameSync as uL,rmSync as dL}from"fs";import*as me from"path";import{fileURLToPath as fL}from"url";import{EventEmitter as pL}from"events";import hL from"open";yn();$e();Or();var $p=t=>`/agents/${t}/client.js`,oL=`
|
|
2937
2941
|
(() => {
|
|
2938
2942
|
const api = async (name, ...args) => {
|
|
2939
2943
|
const resp = await fetch('/__api/' + name, {
|
|
@@ -2962,18 +2966,18 @@ Port ${c} is this bulb's, and a page of it may be waiting there, but something e
|
|
|
2962
2966
|
})
|
|
2963
2967
|
});
|
|
2964
2968
|
if (window.__TYPEBULB_WATCH__) {
|
|
2965
|
-
${
|
|
2969
|
+
${Da()}
|
|
2966
2970
|
}
|
|
2967
2971
|
})();
|
|
2968
|
-
`;function
|
|
2972
|
+
`;function Hk(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,l=$p(n);return`<!DOCTYPE html>
|
|
2969
2973
|
<html>
|
|
2970
2974
|
<head>
|
|
2971
2975
|
<meta charset="utf-8">
|
|
2972
2976
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2973
|
-
<title>${
|
|
2974
|
-
${
|
|
2977
|
+
<title>${La(e)} - typebulb</title>
|
|
2978
|
+
${Ma(e,a)}
|
|
2975
2979
|
<style>
|
|
2976
|
-
${
|
|
2980
|
+
${Cs}
|
|
2977
2981
|
</style>
|
|
2978
2982
|
<style>
|
|
2979
2983
|
${r}
|
|
@@ -2988,18 +2992,18 @@ ${i}
|
|
|
2988
2992
|
${o?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
|
|
2989
2993
|
|
|
2990
2994
|
<script>
|
|
2991
|
-
${
|
|
2995
|
+
${oL}
|
|
2992
2996
|
</script>
|
|
2993
2997
|
|
|
2994
2998
|
<script type="module" src="${l}"></script>
|
|
2995
2999
|
</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`;
|
|
3000
|
+
</html>`}async function zk(t){let e=process.cwd(),n=t.agentTarget;_S(n)||(console.error(`Unknown agent '${n}'. Known: ${Fr().join(", ")}.`),process.exit(1));let r=await ca(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
|
|
3001
|
+
${r.url}`),t.open==="window"&&await hL(r.url);return}let s=Bs(process.pid),i=t.watch?new pL:void 0,o=we(t.mode),a=await RS(n),l=a.displayName||`${n} mirror`;Kt(o,me.join(e,"mirror"));let c=me.dirname(fL(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=()=>Hk({name:l,agent:n,styles:Np(u,"utf8"),katex:Np(p,"utf8"),mountHtml:Np(h,"utf8"),watch:t.watch}),{port:g,note:b}=await ia({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:C,url:T,onCleanup:E,handOver:$,pageCount:P}=await Hl({port:g,portNote:b,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($p(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=lL(_);t.watch&&N&&console.log(` Watching for changes...
|
|
3002
|
+
`);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`;cL(ye,ie[0].contents);for(let ke=1;;ke++)try{uL(ye,oe);break}catch(ae){if(ke===10)throw dL(ye,{force:!0}),ae;await new Promise(xe=>setTimeout(xe,50))}for(let ke of["styles.css","index.html","typebulb.png","typebulb-inv.png"])aL(me.join(k,ke),me.join(f,ke))}let Z;if(t.watch&&N&&i){let q=!1;Z=sn({target:d,events:"all",onChange:async()=>{if(!q){q=!0;try{await B(),console.log(P()?`Mirror rebuilt. Reloading.
|
|
2999
3003
|
`:`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}),
|
|
3001
|
-
`);let a=0,l=Promise.resolve();
|
|
3002
|
-
`)}catch(u){
|
|
3003
|
-
`),
|
|
3004
|
-
`),process.exit(1)}function
|
|
3005
|
-
${e}`),process.exit(1))}async function
|
|
3004
|
+
`),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}),E(()=>a.shutdownSwitcher?.()),E(()=>a.shutdownComposer?.()),Z&&E(Z)}Ze();Et();import*as Yk from"path";async function Vk(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 ii(a.server,t,r,l.dependencies)};if(console.log(`Running ${Yk.basename(t)}...`),await o(),e){console.log(`Watching for changes...
|
|
3005
|
+
`);let a=0,l=Promise.resolve();sn({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 mL}from"node:console";$e();async function Qk(t,e,n,r){vL();try{let u=wn(await G(),t)[0];u&&(Ds(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||_i("This bulb has no **server.ts** block; nothing to call."),Kt(s,t,i.server);let a;try{a=await ii(i.server,t,r,o.dependencies)}catch(u){_i(u instanceof Error?u.message:String(u))}let l=Wl(a,e.fn);if(!l){let u=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Jl)];_i(`Function '${e.fn}' not found. Available: ${u.length?u.join(", "):"(none)"}.`)}let c=await gL(e);if(Kl(l)){try{for await(let u of l(...c))await Xk(JSON.stringify(u,Zk)+`
|
|
3006
|
+
`)}catch(u){_i(u instanceof Error?u.stack??u.message:String(u))}return Gk(0)}let f;try{f=await l(...c)}catch(u){_i(u instanceof Error?u.stack??u.message:String(u))}let d=wL(f);d!==void 0&&await Xk(d+`
|
|
3007
|
+
`),Gk(0)}function Gk(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function gL(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await Wr()),bL(e)}return yL(t.positional)}function yL(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function bL(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 wL(t){if(t!==void 0)return JSON.stringify(t,Zk,2)}function Zk(t,e){return typeof e=="bigint"?e.toString():e}function _i(t){process.stderr.write(t+`
|
|
3008
|
+
`),process.exit(1)}function vL(){let t=new mL(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 Xk(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}oa();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function ex(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
|
|
3009
|
+
${e}`),process.exit(1))}async function SL(){let t=NS(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${Oe}`),process.exit(0)),t.help&&(LS(),process.exit(0)),IS(),t.subcommand==="logs"){await hk(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await mk(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec,wake:t.wake});return}if(t.subcommand==="stop"){t.stopScope?await bk(t.stopScope):await yk(t.file||void 0);return}if(t.subcommand==="restart"){await wk(t.file||void 0,t.stopScope);return}if(t.subcommand==="babysit"){await Ik(t.mode,t.slowMs);return}if(t.subcommand==="send"){await Sk(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await ak(t.mode);return}if(t.subcommand==="slug"){lk(t.slugName);return}if(t.subcommand==="status"){await Ok(t.statusQuery,t.mode,t.slowMs);return}if(t.subcommand==="pull"){await Jw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await Kw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?zk(t):ok(Oe));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await nk(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let l=await Uw(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 tx.access(e).then(()=>!0,()=>!1)||(Fr().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 xk(e,t.blockKind);return}if(t.subcommand==="put"){await Tk(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 tk(e,s);return}let i=!t.noTrust&&xn(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 Jp(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 ek(e,a);return}if(t.subcommand==="call"){ex(t.trust,s),await Qk(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(da(o.bulb)||t.server)){ex(t.trust,s),await Vk(e,t.watch,t.mode,a);return}await Kk(e,t,s,a)}SL().catch(t=>{console.error("Error:",t.message),process.exit(1)});
|