typebulb 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -17
- package/description.md +1 -1
- package/dist/agents/claude/client.js +19 -3
- package/dist/agents/claude/styles.css +4 -3
- package/dist/index.js +196 -170
- package/dist/render.js +19 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
`),t=0;if(e[t]?.trim()!=="---")return null;t++;let s=[];for(;t<e.length&&e[t]?.trim()!=="---";)s.push(e[t]),t++;if(e[t]?.trim()!=="---")return null;t++;let n=
|
|
5
|
-
`))}else t++}return{frontmatter:n,files:i}}catch{return null}}function
|
|
6
|
-
>/]`,i);if(s&&console.log("[xml-utils] start:",o),o===-1)return;let a=r.slice(o+e.length),c=
|
|
7
|
-
>]`),
|
|
8
|
-
`)}};Ot.defaultYaml={explicit:!1,version:"1.2"};Ot.defaultTags={"!!":"tag:yaml.org,2002:"};ja.Directives=Ot});var
|
|
9
|
-
`)?
|
|
3
|
+
var Od=Object.create;var kn=Object.defineProperty;var Nd=Object.getOwnPropertyDescriptor;var Cd=Object.getOwnPropertyNames;var Rd=Object.getPrototypeOf,Id=Object.prototype.hasOwnProperty;var Nr=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var N=(r,e)=>()=>(r&&(e=r(r=0)),e);var v=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),_d=(r,e)=>{for(var t in e)kn(r,t,{get:e[t],enumerable:!0})},Ld=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Cd(e))!Id.call(r,n)&&n!==t&&kn(r,n,{get:()=>e[n],enumerable:!(s=Nd(e,n))||s.enumerable});return r};var $d=(r,e,t)=>(t=r!=null?Od(Rd(r)):{},Ld(e||!r||!r.__esModule?kn(t,"default",{value:r,enumerable:!0}):t,r));function wa(r){return!!r?.startsWith("typebulb")}var Tn,Pn,Cr=N(()=>{Tn={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"}},Pn=["code","css","html","data","infer","insight","config","notes"]});function On(r){return r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1).replace(/\\"/g,'"'):r.startsWith("'")&&r.endsWith("'")?r.slice(1,-1):r}var Rr=N(()=>{});function Ir(r){try{let e=r.split(`
|
|
4
|
+
`),t=0;if(e[t]?.trim()!=="---")return null;t++;let s=[];for(;t<e.length&&e[t]?.trim()!=="---";)s.push(e[t]),t++;if(e[t]?.trim()!=="---")return null;t++;let n=Jd(s);if(!n)return null;let i=new Map;for(;t<e.length;){let a=e[t]?.trim()?.match(/^\*\*(.+)\*\*$/);if(a){let c=a[1].trim();for(t++;t<e.length&&e[t]?.trim()==="";)t++;let l=e[t]?.match(/^(`{3,})(\w*)\s*$/);if(!l){t++;continue}let f=l[1];t++;let u=[];for(;t<e.length&&!e[t]?.match(new RegExp(`^${f}\\s*$`));)u.push(e[t]),t++;t++,i.set(c,u.join(`
|
|
5
|
+
`))}else t++}return{frontmatter:n,files:i}}catch{return null}}function Jd(r){let e={};for(let t of r){let s=t.indexOf(":");if(s===-1)continue;let n=t.slice(0,s).trim(),i=t.slice(s+1).trim();switch(n){case"format":e.format=i;break;case"name":e.name=On(i);break}}return!wa(e.format)||!e.name?null:e}function va(r){let e=Object.fromEntries(Pn.map(t=>[t,r.files.get(Tn[t].path)||""]));return{name:r.frontmatter.name,...e}}var Sa=N(()=>{Cr();Rr()});var ka=N(()=>{Cr();Rr()});function xa(r){if(!r.trim())return{};try{return JSON.parse(r)}catch{return{}}}var Ea=N(()=>{});var Aa=N(()=>{});function Nn(r,e,t){let n=new RegExp(e).exec(r.slice(t));return n?t+n.index:-1}var Ta=N(()=>{});function At(r,e,t){let n=new RegExp(e).exec(r.slice(t));return n?t+n.index+n[0].length-1:-1}var Pa=N(()=>{});function _r(r,e){let t=new RegExp(e,"g"),s=r.match(t);return s?s.length:0}var Oa=N(()=>{});function Tt(r,e,t){let s=t&&t.debug||!1,n=!(t&&typeof t.nested===!1),i=t&&t.startIndex||0;s&&console.log("[xml-utils] starting findTagByName with",e," and ",t);let o=Nn(r,`<${e}[
|
|
6
|
+
>/]`,i);if(s&&console.log("[xml-utils] start:",o),o===-1)return;let a=r.slice(o+e.length),c=At(a,"^[^<]*[ /]>",0),l=c!==-1&&a[c-1]==="/";if(s&&console.log("[xml-utils] selfClosing:",l),l===!1)if(n){let p=0,g=1,h=0;for(;(c=At(a,"[ /]"+e+">",p))!==-1;){let y=a.substring(p,c+1);if(g+=_r(y,"<"+e+`[
|
|
7
|
+
>]`),h+=_r(y,"</"+e+">"),h>=g)break;p=c}}else c=At(a,"[ /]"+e+">",0);let f=o+e.length+c+1;if(s&&console.log("[xml-utils] end:",f),f===-1)return;let u=r.slice(o,f),d;return l?d=null:d=u.slice(u.indexOf(">")+1,u.lastIndexOf("<")),{inner:d,outer:u,start:o,end:f}}var Cn=N(()=>{Ta();Pa();Oa()});var Rn=N(()=>{Cn()});var In=N(()=>{Rn()});var Na=N(()=>{In()});var Ca=N(()=>{});var Ra=N(()=>{Aa();Cn();Rn();Na();In();Ca()});var P=v(M=>{"use strict";var _n=Symbol.for("yaml.alias"),Ia=Symbol.for("yaml.document"),Lr=Symbol.for("yaml.map"),_a=Symbol.for("yaml.pair"),Ln=Symbol.for("yaml.scalar"),$r=Symbol.for("yaml.seq"),fe=Symbol.for("yaml.node.type"),Yd=r=>!!r&&typeof r=="object"&&r[fe]===_n,Hd=r=>!!r&&typeof r=="object"&&r[fe]===Ia,Gd=r=>!!r&&typeof r=="object"&&r[fe]===Lr,zd=r=>!!r&&typeof r=="object"&&r[fe]===_a,La=r=>!!r&&typeof r=="object"&&r[fe]===Ln,Qd=r=>!!r&&typeof r=="object"&&r[fe]===$r;function $a(r){if(r&&typeof r=="object")switch(r[fe]){case Lr:case $r:return!0}return!1}function Xd(r){if(r&&typeof r=="object")switch(r[fe]){case _n:case Lr:case Ln:case $r:return!0}return!1}var Zd=r=>(La(r)||$a(r))&&!!r.anchor;M.ALIAS=_n;M.DOC=Ia;M.MAP=Lr;M.NODE_TYPE=fe;M.PAIR=_a;M.SCALAR=Ln;M.SEQ=$r;M.hasAnchor=Zd;M.isAlias=Yd;M.isCollection=$a;M.isDocument=Hd;M.isMap=Gd;M.isNode=Xd;M.isPair=zd;M.isScalar=La;M.isSeq=Qd});var Pt=v($n=>{"use strict";var $=P(),J=Symbol("break visit"),Ma=Symbol("skip children"),ae=Symbol("remove node");function Mr(r,e){let t=Da(e);$.isDocument(r)?Xe(null,r.contents,t,Object.freeze([r]))===ae&&(r.contents=null):Xe(null,r,t,Object.freeze([]))}Mr.BREAK=J;Mr.SKIP=Ma;Mr.REMOVE=ae;function Xe(r,e,t,s){let n=Ba(r,e,t,s);if($.isNode(n)||$.isPair(n))return qa(r,s,n),Xe(r,n,t,s);if(typeof n!="symbol"){if($.isCollection(e)){s=Object.freeze(s.concat(e));for(let i=0;i<e.items.length;++i){let o=Xe(i,e.items[i],t,s);if(typeof o=="number")i=o-1;else{if(o===J)return J;o===ae&&(e.items.splice(i,1),i-=1)}}}else if($.isPair(e)){s=Object.freeze(s.concat(e));let i=Xe("key",e.key,t,s);if(i===J)return J;i===ae&&(e.key=null);let o=Xe("value",e.value,t,s);if(o===J)return J;o===ae&&(e.value=null)}}return n}async function Dr(r,e){let t=Da(e);$.isDocument(r)?await Ze(null,r.contents,t,Object.freeze([r]))===ae&&(r.contents=null):await Ze(null,r,t,Object.freeze([]))}Dr.BREAK=J;Dr.SKIP=Ma;Dr.REMOVE=ae;async function Ze(r,e,t,s){let n=await Ba(r,e,t,s);if($.isNode(n)||$.isPair(n))return qa(r,s,n),Ze(r,n,t,s);if(typeof n!="symbol"){if($.isCollection(e)){s=Object.freeze(s.concat(e));for(let i=0;i<e.items.length;++i){let o=await Ze(i,e.items[i],t,s);if(typeof o=="number")i=o-1;else{if(o===J)return J;o===ae&&(e.items.splice(i,1),i-=1)}}}else if($.isPair(e)){s=Object.freeze(s.concat(e));let i=await Ze("key",e.key,t,s);if(i===J)return J;i===ae&&(e.key=null);let o=await Ze("value",e.value,t,s);if(o===J)return J;o===ae&&(e.value=null)}}return n}function Da(r){return typeof r=="object"&&(r.Collection||r.Node||r.Value)?Object.assign({Alias:r.Node,Map:r.Node,Scalar:r.Node,Seq:r.Node},r.Value&&{Map:r.Value,Scalar:r.Value,Seq:r.Value},r.Collection&&{Map:r.Collection,Seq:r.Collection},r):r}function Ba(r,e,t,s){if(typeof t=="function")return t(r,e,s);if($.isMap(e))return t.Map?.(r,e,s);if($.isSeq(e))return t.Seq?.(r,e,s);if($.isPair(e))return t.Pair?.(r,e,s);if($.isScalar(e))return t.Scalar?.(r,e,s);if($.isAlias(e))return t.Alias?.(r,e,s)}function qa(r,e,t){let s=e[e.length-1];if($.isCollection(s))s.items[r]=t;else if($.isPair(s))r==="key"?s.key=t:s.value=t;else if($.isDocument(s))s.contents=t;else{let n=$.isAlias(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}$n.visit=Mr;$n.visitAsync=Dr});var Mn=v(ja=>{"use strict";var Fa=P(),ep=Pt(),tp={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},rp=r=>r.replace(/[!,[\]{}]/g,e=>tp[e]),Ot=class r{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},r.defaultYaml,e),this.tags=Object.assign({},r.defaultTags,t)}clone(){let e=new r(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new r(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:r.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},r.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:r.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},r.defaultTags),this.atNextDocument=!1);let s=e.trim().split(/[ \t]+/),n=s.shift();switch(n){case"%TAG":{if(s.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;let[i,o]=s;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[i]=s;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return t(6,`Unsupported YAML version ${i}`,o),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}let[,s,n]=e.match(/^(.*!)([^!]*)$/s);n||t(`The ${e} tag has no suffix`);let i=this.tags[s];if(i)try{return i+decodeURIComponent(n)}catch(o){return t(String(o)),null}return s==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,s]of Object.entries(this.tags))if(e.startsWith(s))return t+rp(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),n;if(e&&s.length>0&&Fa.isNode(e.contents)){let i={};ep.visit(e.contents,(o,a)=>{Fa.isNode(a)&&a.tag&&(i[a.tag]=!0)}),n=Object.keys(i)}else n=[];for(let[i,o]of s)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(a=>a.startsWith(o)))&&t.push(`%TAG ${i} ${o}`);return t.join(`
|
|
8
|
+
`)}};Ot.defaultYaml={explicit:!1,version:"1.2"};Ot.defaultTags={"!!":"tag:yaml.org,2002:"};ja.Directives=Ot});var Br=v(Nt=>{"use strict";var Ua=P(),sp=Pt();function np(r){if(/[\x00-\x19\s,[\]{}]/.test(r)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(r)}`;throw new Error(t)}return!0}function Ja(r){let e=new Set;return sp.visit(r,{Value(t,s){s.anchor&&e.add(s.anchor)}}),e}function Ka(r,e){for(let t=1;;++t){let s=`${r}${t}`;if(!e.has(s))return s}}function ip(r,e){let t=[],s=new Map,n=null;return{onAnchor:i=>{t.push(i),n??(n=Ja(r));let o=Ka(e,n);return n.add(o),o},setAnchors:()=>{for(let i of t){let o=s.get(i);if(typeof o=="object"&&o.anchor&&(Ua.isScalar(o.node)||Ua.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:s}}Nt.anchorIsValid=np;Nt.anchorNames=Ja;Nt.createNodeAnchors=ip;Nt.findNewAnchor=Ka});var Dn=v(Va=>{"use strict";function Ct(r,e,t,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let n=0,i=s.length;n<i;++n){let o=s[n],a=Ct(r,s,String(n),o);a===void 0?delete s[n]:a!==o&&(s[n]=a)}else if(s instanceof Map)for(let n of Array.from(s.keys())){let i=s.get(n),o=Ct(r,s,n,i);o===void 0?s.delete(n):o!==i&&s.set(n,o)}else if(s instanceof Set)for(let n of Array.from(s)){let i=Ct(r,s,n,n);i===void 0?s.delete(n):i!==n&&(s.delete(n),s.add(i))}else for(let[n,i]of Object.entries(s)){let o=Ct(r,s,n,i);o===void 0?delete s[n]:o!==i&&(s[n]=o)}return r.call(e,t,s)}Va.applyReviver=Ct});var ye=v(Ya=>{"use strict";var op=P();function Wa(r,e,t){if(Array.isArray(r))return r.map((s,n)=>Wa(s,String(n),t));if(r&&typeof r.toJSON=="function"){if(!t||!op.hasAnchor(r))return r.toJSON(e,t);let s={aliasCount:0,count:1,res:void 0};t.anchors.set(r,s),t.onCreate=i=>{s.res=i,delete t.onCreate};let n=r.toJSON(e,t);return t.onCreate&&t.onCreate(n),n}return typeof r=="bigint"&&!t?.keep?Number(r):r}Ya.toJS=Wa});var qr=v(Ga=>{"use strict";var ap=Dn(),Ha=P(),cp=ye(),Bn=class{constructor(e){Object.defineProperty(this,Ha.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:t,maxAliasCount:s,onAnchor:n,reviver:i}={}){if(!Ha.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},a=cp.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof i=="function"?ap.applyReviver(i,{"":a},"",a):a}};Ga.NodeBase=Bn});var Rt=v(za=>{"use strict";var lp=Br(),up=Pt(),et=P(),fp=qr(),dp=ye(),qn=class extends fp.NodeBase{constructor(e){super(et.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let s;t?.aliasResolveCache?s=t.aliasResolveCache:(s=[],up.visit(e,{Node:(i,o)=>{(et.isAlias(o)||et.hasAnchor(o))&&s.push(o)}}),t&&(t.aliasResolveCache=s));let n;for(let i of s){if(i===this)break;i.anchor===this.source&&(n=i)}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:s,doc:n,maxAliasCount:i}=t,o=this.resolve(n,t);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=s.get(o);if(a||(dp.toJS(o,null,t),a=s.get(o)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Fr(n,o,s)),a.count*a.aliasCount>i)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,t,s){let n=`*${this.source}`;if(e){if(lp.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`${n} `}return n}};function Fr(r,e,t){if(et.isAlias(e)){let s=e.resolve(r),n=t&&s&&t.get(s);return n?n.count*n.aliasCount:0}else if(et.isCollection(e)){let s=0;for(let n of e.items){let i=Fr(r,n,t);i>s&&(s=i)}return s}else if(et.isPair(e)){let s=Fr(r,e.key,t),n=Fr(r,e.value,t);return Math.max(s,n)}return 1}za.Alias=qn});var _=v(Fn=>{"use strict";var pp=P(),hp=qr(),mp=ye(),gp=r=>!r||typeof r!="function"&&typeof r!="object",be=class extends hp.NodeBase{constructor(e){super(pp.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:mp.toJS(this.value,e,t)}toString(){return String(this.value)}};be.BLOCK_FOLDED="BLOCK_FOLDED";be.BLOCK_LITERAL="BLOCK_LITERAL";be.PLAIN="PLAIN";be.QUOTE_DOUBLE="QUOTE_DOUBLE";be.QUOTE_SINGLE="QUOTE_SINGLE";Fn.Scalar=be;Fn.isScalarValue=gp});var It=v(Xa=>{"use strict";var yp=Rt(),_e=P(),Qa=_(),bp="tag:yaml.org,2002:";function wp(r,e,t){if(e){let s=t.filter(i=>i.tag===e),n=s.find(i=>!i.format)??s[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return t.find(s=>s.identify?.(r)&&!s.format)}function vp(r,e,t){if(_e.isDocument(r)&&(r=r.contents),_e.isNode(r))return r;if(_e.isPair(r)){let u=t.schema[_e.MAP].createNode?.(t.schema,null,t);return u.items.push(r),u}(r instanceof String||r instanceof Number||r instanceof Boolean||typeof BigInt<"u"&&r instanceof BigInt)&&(r=r.valueOf());let{aliasDuplicateObjects:s,onAnchor:n,onTagObj:i,schema:o,sourceObjects:a}=t,c;if(s&&r&&typeof r=="object"){if(c=a.get(r),c)return c.anchor??(c.anchor=n(r)),new yp.Alias(c.anchor);c={anchor:null,node:null},a.set(r,c)}e?.startsWith("!!")&&(e=bp+e.slice(2));let l=wp(r,e,o.tags);if(!l){if(r&&typeof r.toJSON=="function"&&(r=r.toJSON()),!r||typeof r!="object"){let u=new Qa.Scalar(r);return c&&(c.node=u),u}l=r instanceof Map?o[_e.MAP]:Symbol.iterator in Object(r)?o[_e.SEQ]:o[_e.MAP]}i&&(i(l),delete t.onTagObj);let f=l?.createNode?l.createNode(t.schema,r,t):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(t.schema,r,t):new Qa.Scalar(r);return e?f.tag=e:l.default||(f.tag=l.tag),c&&(c.node=f),f}Xa.createNode=vp});var Ur=v(jr=>{"use strict";var Sp=It(),ce=P(),kp=qr();function jn(r,e,t){let s=t;for(let n=e.length-1;n>=0;--n){let i=e[n];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=s,s=o}else s=new Map([[i,s]])}return Sp.createNode(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:r,sourceObjects:new Map})}var Za=r=>r==null||typeof r=="object"&&!!r[Symbol.iterator]().next().done,Un=class extends kp.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(s=>ce.isNode(s)||ce.isPair(s)?s.clone(e):s),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Za(e))this.add(t);else{let[s,...n]=e,i=this.get(s,!0);if(ce.isCollection(i))i.addIn(n,t);else if(i===void 0&&this.schema)this.set(s,jn(this.schema,n,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${n}`)}}deleteIn(e){let[t,...s]=e;if(s.length===0)return this.delete(t);let n=this.get(t,!0);if(ce.isCollection(n))return n.deleteIn(s);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){let[s,...n]=e,i=this.get(s,!0);return n.length===0?!t&&ce.isScalar(i)?i.value:i:ce.isCollection(i)?i.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!ce.isPair(t))return!1;let s=t.value;return s==null||e&&ce.isScalar(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){let[t,...s]=e;if(s.length===0)return this.has(t);let n=this.get(t,!0);return ce.isCollection(n)?n.hasIn(s):!1}setIn(e,t){let[s,...n]=e;if(n.length===0)this.set(s,t);else{let i=this.get(s,!0);if(ce.isCollection(i))i.setIn(n,t);else if(i===void 0&&this.schema)this.set(s,jn(this.schema,n,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${n}`)}}};jr.Collection=Un;jr.collectionFromPath=jn;jr.isEmptyPath=Za});var _t=v(Jr=>{"use strict";var xp=r=>r.replace(/^(?!$)(?: $)?/gm,"#");function Jn(r,e){return/^\n+$/.test(r)?r.substring(1):e?r.replace(/^(?! *$)/gm,e):r}var Ep=(r,e,t)=>r.endsWith(`
|
|
9
|
+
`)?Jn(t,e):t.includes(`
|
|
10
10
|
`)?`
|
|
11
|
-
`+
|
|
12
|
-
`)t===
|
|
13
|
-
`&&
|
|
14
|
-
`&&
|
|
15
|
-
${e}${r.slice(0,
|
|
16
|
-
${e}${r.slice(
|
|
17
|
-
`);s=e,n=e+1,i=r[n]}return s}Lt.FOLD_BLOCK=
|
|
11
|
+
`+Jn(t,e):(r.endsWith(" ")?"":" ")+t;Jr.indentComment=Jn;Jr.lineComment=Ep;Jr.stringifyComment=xp});var tc=v(Lt=>{"use strict";var Ap="flow",Kn="block",Kr="quoted";function Tp(r,e,t="flow",{indentAtStart:s,lineWidth:n=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!n||n<0)return r;n<i&&(i=0);let c=Math.max(1+i,1+n-e.length);if(r.length<=c)return r;let l=[],f={},u=n-e.length;typeof s=="number"&&(s>n-Math.max(2,i)?l.push(0):u=n-s);let d,p,g=!1,h=-1,y=-1,k=-1;t===Kn&&(h=ec(r,h,e.length),h!==-1&&(u=h+c));for(let b;b=r[h+=1];){if(t===Kr&&b==="\\"){switch(y=h,r[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}k=h}if(b===`
|
|
12
|
+
`)t===Kn&&(h=ec(r,h,e.length)),u=h+e.length+c,d=void 0;else{if(b===" "&&p&&p!==" "&&p!==`
|
|
13
|
+
`&&p!==" "){let w=r[h+1];w&&w!==" "&&w!==`
|
|
14
|
+
`&&w!==" "&&(d=h)}if(h>=u)if(d)l.push(d),u=d+c,d=void 0;else if(t===Kr){for(;p===" "||p===" ";)p=b,b=r[h+=1],g=!0;let w=h>k+1?h-2:y-1;if(f[w])return r;l.push(w),f[w]=!0,u=w+c,d=void 0}else g=!0}p=b}if(g&&a&&a(),l.length===0)return r;o&&o();let m=r.slice(0,l[0]);for(let b=0;b<l.length;++b){let w=l[b],x=l[b+1]||r.length;w===0?m=`
|
|
15
|
+
${e}${r.slice(0,x)}`:(t===Kr&&f[w]&&(m+=`${r[w]}\\`),m+=`
|
|
16
|
+
${e}${r.slice(w+1,x)}`)}return m}function ec(r,e,t){let s=e,n=e+1,i=r[n];for(;i===" "||i===" ";)if(e<n+t)i=r[++e];else{do i=r[++e];while(i&&i!==`
|
|
17
|
+
`);s=e,n=e+1,i=r[n]}return s}Lt.FOLD_BLOCK=Kn;Lt.FOLD_FLOW=Ap;Lt.FOLD_QUOTED=Kr;Lt.foldFlowLines=Tp});var Mt=v(rc=>{"use strict";var Z=_(),we=tc(),Wr=(r,e)=>({indentAtStart:e?r.indent.length:r.indentAtStart,lineWidth:r.options.lineWidth,minContentWidth:r.options.minContentWidth}),Yr=r=>/^(%|---|\.\.\.)/m.test(r);function Pp(r,e,t){if(!e||e<0)return!1;let s=e-t,n=r.length;if(n<=s)return!1;for(let i=0,o=0;i<n;++i)if(r[i]===`
|
|
18
18
|
`){if(i-o>s)return!0;if(o=i+1,n-o<=s)return!1}return!0}function $t(r,e){let t=JSON.stringify(r);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:s}=e,n=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Yr(r)?" ":""),o="",a=0;for(let c=0,l=t[c];l;l=t[++c])if(l===" "&&t[c+1]==="\\"&&t[c+2]==="n"&&(o+=t.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(t[c+1]){case"u":{o+=t.slice(a,c);let f=t.substr(c+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+=t.substr(c,6)}c+=5,a=c+1}break;case"n":if(s||t[c+2]==='"'||t.length<n)c+=1;else{for(o+=t.slice(a,c)+`
|
|
19
19
|
|
|
20
20
|
`;t[c+2]==="\\"&&t[c+3]==="n"&&t[c+4]!=='"';)o+=`
|
|
21
|
-
`,c+=2;o+=i,t[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+t.slice(a):t,s?o:we.foldFlowLines(o,i,we.FOLD_QUOTED,Wr(e,!1))}function
|
|
21
|
+
`,c+=2;o+=i,t[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+t.slice(a):t,s?o:we.foldFlowLines(o,i,we.FOLD_QUOTED,Wr(e,!1))}function Vn(r,e){if(e.options.singleQuote===!1||e.implicitKey&&r.includes(`
|
|
22
22
|
`)||/[ \t]\n|\n[ \t]/.test(r))return $t(r,e);let t=e.indent||(Yr(r)?" ":""),s="'"+r.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
23
|
-
${t}`)+"'";return e.implicitKey?s:we.foldFlowLines(s,t,we.FOLD_FLOW,Wr(e,!1))}function
|
|
23
|
+
${t}`)+"'";return e.implicitKey?s:we.foldFlowLines(s,t,we.FOLD_FLOW,Wr(e,!1))}function tt(r,e){let{singleQuote:t}=e.options,s;if(t===!1)s=$t;else{let n=r.includes('"'),i=r.includes("'");n&&!i?s=Vn:i&&!n?s=$t:s=t?Vn:$t}return s(r,e)}var Wn;try{Wn=new RegExp(`(^|(?<!
|
|
24
24
|
))
|
|
25
25
|
+(?!
|
|
26
|
-
|$)`,"g")}catch{
|
|
26
|
+
|$)`,"g")}catch{Wn=/\n+(?!\n|$)/g}function Vr({comment:r,type:e,value:t},s,n,i){let{blockQuote:o,commentString:a,lineWidth:c}=s.options;if(!o||/\n[\t ]+$/.test(t))return tt(t,s);let l=s.indent||(s.forceBlockIndent||Yr(t)?" ":""),f=o==="literal"?!0:o==="folded"||e===Z.Scalar.BLOCK_FOLDED?!1:e===Z.Scalar.BLOCK_LITERAL?!0:!Pp(t,c,l.length);if(!t)return f?`|
|
|
27
27
|
`:`>
|
|
28
|
-
`;let u,d;for(d=t.length;d>0;--d){let
|
|
29
|
-
`&&
|
|
30
|
-
`);g===-1?u="-":t===
|
|
31
|
-
`&&(
|
|
32
|
-
`)
|
|
33
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),
|
|
34
|
-
${l}${
|
|
35
|
-
${l}${
|
|
36
|
-
`)||f&&/[[\]{},]/.test(i))return
|
|
37
|
-
`)?
|
|
38
|
-
`))return Vr(r,e,t,s);if(Yr(i)){if(c==="")return e.forceBlockIndent=!0,Vr(r,e,t,s);if(a&&c===l)return
|
|
39
|
-
${c}`);if(o){let d=
|
|
40
|
-
${e.indent}${a}`:a}
|
|
41
|
-
${a}:`):(y=`${y}:`,d&&(y+=
|
|
42
|
-
`:"",
|
|
43
|
-
${
|
|
44
|
-
`&&
|
|
45
|
-
|
|
46
|
-
`):
|
|
47
|
-
${t.indent}`}else if(!
|
|
48
|
-
`),O=
|
|
49
|
-
${t.indent}`)}}else(
|
|
50
|
-
`)&&(
|
|
51
|
-
${c}${
|
|
52
|
-
`}}return r?(
|
|
53
|
-
`+es.indentComment(l(r),c),a&&a()):u&&o&&o(),
|
|
54
|
-
`))&&(l=!0),u.push(
|
|
55
|
-
${i}${n}${
|
|
28
|
+
`;let u,d;for(d=t.length;d>0;--d){let x=t[d-1];if(x!==`
|
|
29
|
+
`&&x!==" "&&x!==" ")break}let p=t.substring(d),g=p.indexOf(`
|
|
30
|
+
`);g===-1?u="-":t===p||g!==p.length-1?(u="+",i&&i()):u="",p&&(t=t.slice(0,-p.length),p[p.length-1]===`
|
|
31
|
+
`&&(p=p.slice(0,-1)),p=p.replace(Wn,`$&${l}`));let h=!1,y,k=-1;for(y=0;y<t.length;++y){let x=t[y];if(x===" ")h=!0;else if(x===`
|
|
32
|
+
`)k=y;else break}let m=t.substring(0,k<y?k+1:y);m&&(t=t.substring(m.length),m=m.replace(/\n+/g,`$&${l}`));let w=(h?l?"2":"1":"")+u;if(r&&(w+=" "+a(r.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let x=t.replace(/\n+/g,`
|
|
33
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,T=Wr(s,!0);o!=="folded"&&e!==Z.Scalar.BLOCK_FOLDED&&(T.onOverflow=()=>{E=!0});let S=we.foldFlowLines(`${m}${x}${p}`,l,we.FOLD_BLOCK,T);if(!E)return`>${w}
|
|
34
|
+
${l}${S}`}return t=t.replace(/\n+/g,`$&${l}`),`|${w}
|
|
35
|
+
${l}${m}${t}${p}`}function Op(r,e,t,s){let{type:n,value:i}=r,{actualString:o,implicitKey:a,indent:c,indentStep:l,inFlow:f}=e;if(a&&i.includes(`
|
|
36
|
+
`)||f&&/[[\]{},]/.test(i))return tt(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
|
|
37
|
+
`)?tt(i,e):Vr(r,e,t,s);if(!a&&!f&&n!==Z.Scalar.PLAIN&&i.includes(`
|
|
38
|
+
`))return Vr(r,e,t,s);if(Yr(i)){if(c==="")return e.forceBlockIndent=!0,Vr(r,e,t,s);if(a&&c===l)return tt(i,e)}let u=i.replace(/\n+/g,`$&
|
|
39
|
+
${c}`);if(o){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:p,tags:g}=e.doc.schema;if(g.some(d)||p?.some(d))return tt(i,e)}return a?u:we.foldFlowLines(u,c,we.FOLD_FLOW,Wr(e,!1))}function Np(r,e,t,s){let{implicitKey:n,inFlow:i}=e,o=typeof r.value=="string"?r:Object.assign({},r,{value:String(r.value)}),{type:a}=r;a!==Z.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Z.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case Z.Scalar.BLOCK_FOLDED:case Z.Scalar.BLOCK_LITERAL:return n||i?tt(o.value,e):Vr(o,e,t,s);case Z.Scalar.QUOTE_DOUBLE:return $t(o.value,e);case Z.Scalar.QUOTE_SINGLE:return Vn(o.value,e);case Z.Scalar.PLAIN:return Op(o,e,t,s);default:return null}},l=c(a);if(l===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=n&&f||u;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}rc.stringifyString=Np});var Dt=v(Yn=>{"use strict";var Cp=Br(),ve=P(),Rp=_t(),Ip=Mt();function _p(r,e){let t=Object.assign({blockQuote:!0,commentString:Rp.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},r.schema.toStringOptions,e),s;switch(t.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:r,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:s,options:t}}function Lp(r,e){if(e.tag){let n=r.filter(i=>i.tag===e.tag);if(n.length>0)return n.find(i=>i.format===e.format)??n[0]}let t,s;if(ve.isScalar(e)){s=e.value;let n=r.filter(i=>i.identify?.(s));if(n.length>1){let i=n.filter(o=>o.test);i.length>0&&(n=i)}t=n.find(i=>i.format===e.format)??n.find(i=>!i.format)}else s=e,t=r.find(n=>n.nodeClass&&s instanceof n.nodeClass);if(!t){let n=s?.constructor?.name??(s===null?"null":typeof s);throw new Error(`Tag not resolved for ${n} value`)}return t}function $p(r,e,{anchors:t,doc:s}){if(!s.directives)return"";let n=[],i=(ve.isScalar(r)||ve.isCollection(r))&&r.anchor;i&&Cp.anchorIsValid(i)&&(t.add(i),n.push(`&${i}`));let o=r.tag??(e.default?null:e.tag);return o&&n.push(s.directives.tagString(o)),n.join(" ")}function Mp(r,e,t,s){if(ve.isPair(r))return r.toString(e,t,s);if(ve.isAlias(r)){if(e.doc.directives)return r.toString(e);if(e.resolvedAliases?.has(r))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(r):e.resolvedAliases=new Set([r]),r=r.resolve(e.doc)}let n,i=ve.isNode(r)?r:e.doc.createNode(r,{onTagObj:c=>n=c});n??(n=Lp(e.doc.schema.tags,i));let o=$p(i,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof n.stringify=="function"?n.stringify(i,e,t,s):ve.isScalar(i)?Ip.stringifyString(i,e,t,s):i.toString(e,t,s);return o?ve.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
40
|
+
${e.indent}${a}`:a}Yn.createStringifyContext=_p;Yn.stringify=Mp});var oc=v(ic=>{"use strict";var de=P(),sc=_(),nc=Dt(),Bt=_t();function Dp({key:r,value:e},t,s,n){let{allNullValues:i,doc:o,indent:a,indentStep:c,options:{commentString:l,indentSeq:f,simpleKeys:u}}=t,d=de.isNode(r)&&r.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(de.isCollection(r)||!de.isNode(r)&&typeof r=="object"){let T="With simple keys, collection cannot be used as a key value";throw new Error(T)}}let p=!u&&(!r||d&&e==null&&!t.inFlow||de.isCollection(r)||(de.isScalar(r)?r.type===sc.Scalar.BLOCK_FOLDED||r.type===sc.Scalar.BLOCK_LITERAL:typeof r=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!p&&(u||!i),indent:a+c});let g=!1,h=!1,y=nc.stringify(r,t,()=>g=!0,()=>h=!0);if(!p&&!t.inFlow&&y.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(t.inFlow){if(i||e==null)return g&&s&&s(),y===""?"?":p?`? ${y}`:y}else if(i&&!u||e==null&&p)return y=`? ${y}`,d&&!g?y+=Bt.lineComment(y,t.indent,l(d)):h&&n&&n(),y;g&&(d=null),p?(d&&(y+=Bt.lineComment(y,t.indent,l(d))),y=`? ${y}
|
|
41
|
+
${a}:`):(y=`${y}:`,d&&(y+=Bt.lineComment(y,t.indent,l(d))));let k,m,b;de.isNode(e)?(k=!!e.spaceBefore,m=e.commentBefore,b=e.comment):(k=!1,m=null,b=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!p&&!d&&de.isScalar(e)&&(t.indentAtStart=y.length+1),h=!1,!f&&c.length>=2&&!t.inFlow&&!p&&de.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let w=!1,x=nc.stringify(e,t,()=>w=!0,()=>h=!0),E=" ";if(d||k||m){if(E=k?`
|
|
42
|
+
`:"",m){let T=l(m);E+=`
|
|
43
|
+
${Bt.indentComment(T,t.indent)}`}x===""&&!t.inFlow?E===`
|
|
44
|
+
`&&b&&(E=`
|
|
45
|
+
|
|
46
|
+
`):E+=`
|
|
47
|
+
${t.indent}`}else if(!p&&de.isCollection(e)){let T=x[0],S=x.indexOf(`
|
|
48
|
+
`),O=S!==-1,U=t.inFlow??e.flow??e.items.length===0;if(O||!U){let H=!1;if(O&&(T==="&"||T==="!")){let R=x.indexOf(" ");T==="&"&&R!==-1&&R<S&&x[R+1]==="!"&&(R=x.indexOf(" ",R+1)),(R===-1||S<R)&&(H=!0)}H||(E=`
|
|
49
|
+
${t.indent}`)}}else(x===""||x[0]===`
|
|
50
|
+
`)&&(E="");return y+=E+x,t.inFlow?w&&s&&s():b&&!w?y+=Bt.lineComment(y,t.indent,l(b)):h&&n&&n(),y}ic.stringifyPair=Dp});var Gn=v(Hn=>{"use strict";var ac=Nr("process");function Bp(r,...e){r==="debug"&&console.log(...e)}function qp(r,e){(r==="debug"||r==="warn")&&(typeof ac.emitWarning=="function"?ac.emitWarning(e):console.warn(e))}Hn.debug=Bp;Hn.warn=qp});var Qr=v(zr=>{"use strict";var qt=P(),cc=_(),Hr="<<",Gr={identify:r=>r===Hr||typeof r=="symbol"&&r.description===Hr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new cc.Scalar(Symbol(Hr)),{addToJSMap:lc}),stringify:()=>Hr},Fp=(r,e)=>(Gr.identify(e)||qt.isScalar(e)&&(!e.type||e.type===cc.Scalar.PLAIN)&&Gr.identify(e.value))&&r?.doc.schema.tags.some(t=>t.tag===Gr.tag&&t.default);function lc(r,e,t){if(t=r&&qt.isAlias(t)?t.resolve(r.doc):t,qt.isSeq(t))for(let s of t.items)zn(r,e,s);else if(Array.isArray(t))for(let s of t)zn(r,e,s);else zn(r,e,t)}function zn(r,e,t){let s=r&&qt.isAlias(t)?t.resolve(r.doc):t;if(!qt.isMap(s))throw new Error("Merge sources must be maps or map aliases");let n=s.toJSON(null,r,Map);for(let[i,o]of n)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}zr.addMergeToJSMap=lc;zr.isMergeKey=Fp;zr.merge=Gr});var Xn=v(dc=>{"use strict";var jp=Gn(),uc=Qr(),Up=Dt(),fc=P(),Qn=ye();function Jp(r,e,{key:t,value:s}){if(fc.isNode(t)&&t.addToJSMap)t.addToJSMap(r,e,s);else if(uc.isMergeKey(r,t))uc.addMergeToJSMap(r,e,s);else{let n=Qn.toJS(t,"",r);if(e instanceof Map)e.set(n,Qn.toJS(s,n,r));else if(e instanceof Set)e.add(n);else{let i=Kp(t,n,r),o=Qn.toJS(s,i,r);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function Kp(r,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(fc.isNode(r)&&t?.doc){let s=Up.createStringifyContext(t.doc,{});s.anchors=new Set;for(let i of t.anchors.keys())s.anchors.add(i.anchor);s.inFlow=!0,s.inStringifyKey=!0;let n=r.toString(s);if(!t.mapKeyWarned){let i=JSON.stringify(n);i.length>40&&(i=i.substring(0,36)+'..."'),jp.warn(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return n}return JSON.stringify(e)}dc.addPairToJSMap=Jp});var Se=v(Zn=>{"use strict";var pc=It(),Vp=oc(),Wp=Xn(),Xr=P();function Yp(r,e,t){let s=pc.createNode(r,void 0,t),n=pc.createNode(e,void 0,t);return new Zr(s,n)}var Zr=class r{constructor(e,t=null){Object.defineProperty(this,Xr.NODE_TYPE,{value:Xr.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;return Xr.isNode(t)&&(t=t.clone(e)),Xr.isNode(s)&&(s=s.clone(e)),new r(t,s)}toJSON(e,t){let s=t?.mapAsMap?new Map:{};return Wp.addPairToJSMap(t,s,this)}toString(e,t,s){return e?.doc?Vp.stringifyPair(this,e,t,s):JSON.stringify(this)}};Zn.Pair=Zr;Zn.createPair=Yp});var ei=v(mc=>{"use strict";var Le=P(),hc=Dt(),es=_t();function Hp(r,e,t){return(e.inFlow??r.flow?zp:Gp)(r,e,t)}function Gp({comment:r,items:e},t,{blockItemPrefix:s,flowChars:n,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:c,options:{commentString:l}}=t,f=Object.assign({},t,{indent:i,type:null}),u=!1,d=[];for(let g=0;g<e.length;++g){let h=e[g],y=null;if(Le.isNode(h))!u&&h.spaceBefore&&d.push(""),ts(t,d,h.commentBefore,u),h.comment&&(y=h.comment);else if(Le.isPair(h)){let m=Le.isNode(h.key)?h.key:null;m&&(!u&&m.spaceBefore&&d.push(""),ts(t,d,m.commentBefore,u))}u=!1;let k=hc.stringify(h,f,()=>y=null,()=>u=!0);y&&(k+=es.lineComment(k,i,l(y))),u&&y&&(u=!1),d.push(s+k)}let p;if(d.length===0)p=n.start+n.end;else{p=d[0];for(let g=1;g<d.length;++g){let h=d[g];p+=h?`
|
|
51
|
+
${c}${h}`:`
|
|
52
|
+
`}}return r?(p+=`
|
|
53
|
+
`+es.indentComment(l(r),c),a&&a()):u&&o&&o(),p}function zp({items:r},e,{flowChars:t,itemIndent:s}){let{indent:n,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;s+=i;let c=Object.assign({},e,{indent:s,inFlow:!0,type:null}),l=!1,f=0,u=[];for(let g=0;g<r.length;++g){let h=r[g],y=null;if(Le.isNode(h))h.spaceBefore&&u.push(""),ts(e,u,h.commentBefore,!1),h.comment&&(y=h.comment);else if(Le.isPair(h)){let m=Le.isNode(h.key)?h.key:null;m&&(m.spaceBefore&&u.push(""),ts(e,u,m.commentBefore,!1),m.comment&&(l=!0));let b=Le.isNode(h.value)?h.value:null;b?(b.comment&&(y=b.comment),b.commentBefore&&(l=!0)):h.value==null&&m?.comment&&(y=m.comment)}y&&(l=!0);let k=hc.stringify(h,c,()=>y=null);g<r.length-1&&(k+=","),y&&(k+=es.lineComment(k,s,a(y))),!l&&(u.length>f||k.includes(`
|
|
54
|
+
`))&&(l=!0),u.push(k),f=u.length}let{start:d,end:p}=t;if(u.length===0)return d+p;if(!l){let g=u.reduce((h,y)=>h+y.length+2,2);l=e.options.lineWidth>0&&g>e.options.lineWidth}if(l){let g=d;for(let h of u)g+=h?`
|
|
55
|
+
${i}${n}${h}`:`
|
|
56
56
|
`;return`${g}
|
|
57
|
-
${n}${
|
|
58
|
-
`:" ")}return
|
|
57
|
+
${n}${p}`}else return`${d}${o}${u.join(" ")}${o}${p}`}function ts({indent:r,options:{commentString:e}},t,s,n){if(s&&n&&(s=s.replace(/^\n+/,"")),s){let i=es.indentComment(e(s),r);t.push(i.trimStart())}}mc.stringifyCollection=Hp});var xe=v(ri=>{"use strict";var Qp=ei(),Xp=Xn(),Zp=Ur(),ke=P(),rs=Se(),eh=_();function Ft(r,e){let t=ke.isScalar(e)?e.value:e;for(let s of r)if(ke.isPair(s)&&(s.key===e||s.key===t||ke.isScalar(s.key)&&s.key.value===t))return s}var ti=class extends Zp.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(ke.MAP,e),this.items=[]}static from(e,t,s){let{keepUndefined:n,replacer:i}=s,o=new this(e),a=(c,l)=>{if(typeof i=="function")l=i.call(t,c,l);else if(Array.isArray(i)&&!i.includes(c))return;(l!==void 0||n)&&o.items.push(rs.createPair(c,l,s))};if(t instanceof Map)for(let[c,l]of t)a(c,l);else if(t&&typeof t=="object")for(let c of Object.keys(t))a(c,t[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,t){let s;ke.isPair(e)?s=e:!e||typeof e!="object"||!("key"in e)?s=new rs.Pair(e,e?.value):s=new rs.Pair(e.key,e.value);let n=Ft(this.items,s.key),i=this.schema?.sortMapEntries;if(n){if(!t)throw new Error(`Key ${s.key} already set`);ke.isScalar(n.value)&&eh.isScalarValue(s.value)?n.value.value=s.value:n.value=s.value}else if(i){let o=this.items.findIndex(a=>i(s,a)<0);o===-1?this.items.push(s):this.items.splice(o,0,s)}else this.items.push(s)}delete(e){let t=Ft(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=Ft(this.items,e)?.value;return(!t&&ke.isScalar(n)?n.value:n)??void 0}has(e){return!!Ft(this.items,e)}set(e,t){this.add(new rs.Pair(e,t),!0)}toJSON(e,t,s){let n=s?new s:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(n);for(let i of this.items)Xp.addPairToJSMap(t,n,i);return n}toString(e,t,s){if(!e)return JSON.stringify(this);for(let n of this.items)if(!ke.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Qp.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}};ri.YAMLMap=ti;ri.findPair=Ft});var rt=v(yc=>{"use strict";var th=P(),gc=xe(),rh={collection:"map",default:!0,nodeClass:gc.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(r,e){return th.isMap(r)||e("Expected a mapping for this tag"),r},createNode:(r,e,t)=>gc.YAMLMap.from(r,e,t)};yc.map=rh});var Ee=v(bc=>{"use strict";var sh=It(),nh=ei(),ih=Ur(),ns=P(),oh=_(),ah=ye(),si=class extends ih.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ns.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=ss(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let s=ss(e);if(typeof s!="number")return;let n=this.items[s];return!t&&ns.isScalar(n)?n.value:n}has(e){let t=ss(e);return typeof t=="number"&&t<this.items.length}set(e,t){let s=ss(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[s];ns.isScalar(n)&&oh.isScalarValue(t)?n.value=t:this.items[s]=t}toJSON(e,t){let s=[];t?.onCreate&&t.onCreate(s);let n=0;for(let i of this.items)s.push(ah.toJS(i,String(n++),t));return s}toString(e,t,s){return e?nh.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:t}):JSON.stringify(this)}static from(e,t,s){let{replacer:n}=s,i=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let a of t){if(typeof n=="function"){let c=t instanceof Set?a:String(o++);a=n.call(t,c,a)}i.items.push(sh.createNode(a,void 0,s))}}return i}};function ss(r){let e=ns.isScalar(r)?r.value:r;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}bc.YAMLSeq=si});var st=v(vc=>{"use strict";var ch=P(),wc=Ee(),lh={collection:"seq",default:!0,nodeClass:wc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(r,e){return ch.isSeq(r)||e("Expected a sequence for this tag"),r},createNode:(r,e,t)=>wc.YAMLSeq.from(r,e,t)};vc.seq=lh});var jt=v(Sc=>{"use strict";var uh=Mt(),fh={identify:r=>typeof r=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:r=>r,stringify(r,e,t,s){return e=Object.assign({actualString:!0},e),uh.stringifyString(r,e,t,s)}};Sc.string=fh});var is=v(Ec=>{"use strict";var kc=_(),xc={identify:r=>r==null,createNode:()=>new kc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new kc.Scalar(null),stringify:({source:r},e)=>typeof r=="string"&&xc.test.test(r)?r:e.options.nullStr};Ec.nullTag=xc});var ni=v(Tc=>{"use strict";var dh=_(),Ac={identify:r=>typeof r=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:r=>new dh.Scalar(r[0]==="t"||r[0]==="T"),stringify({source:r,value:e},t){if(r&&Ac.test.test(r)){let s=r[0]==="t"||r[0]==="T";if(e===s)return r}return e?t.options.trueStr:t.options.falseStr}};Tc.boolTag=Ac});var nt=v(Pc=>{"use strict";function ph({format:r,minFractionDigits:e,tag:t,value:s}){if(typeof s=="bigint")return String(s);let n=typeof s=="number"?s:Number(s);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let i=Object.is(s,-0)?"-0":JSON.stringify(s);if(!r&&e&&(!t||t==="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}Pc.stringifyNumber=ph});var oi=v(os=>{"use strict";var hh=_(),ii=nt(),mh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:r=>r.slice(-3).toLowerCase()==="nan"?NaN:r[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:ii.stringifyNumber},gh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:r=>parseFloat(r),stringify(r){let e=Number(r.value);return isFinite(e)?e.toExponential():ii.stringifyNumber(r)}},yh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(r){let e=new hh.Scalar(parseFloat(r)),t=r.indexOf(".");return t!==-1&&r[r.length-1]==="0"&&(e.minFractionDigits=r.length-t-1),e},stringify:ii.stringifyNumber};os.float=yh;os.floatExp=gh;os.floatNaN=mh});var ci=v(cs=>{"use strict";var Oc=nt(),as=r=>typeof r=="bigint"||Number.isInteger(r),ai=(r,e,t,{intAsBigInt:s})=>s?BigInt(r):parseInt(r.substring(e),t);function Nc(r,e,t){let{value:s}=r;return as(s)&&s>=0?t+s.toString(e):Oc.stringifyNumber(r)}var bh={identify:r=>as(r)&&r>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(r,e,t)=>ai(r,2,8,t),stringify:r=>Nc(r,8,"0o")},wh={identify:as,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(r,e,t)=>ai(r,0,10,t),stringify:Oc.stringifyNumber},vh={identify:r=>as(r)&&r>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(r,e,t)=>ai(r,2,16,t),stringify:r=>Nc(r,16,"0x")};cs.int=wh;cs.intHex=vh;cs.intOct=bh});var Rc=v(Cc=>{"use strict";var Sh=rt(),kh=is(),xh=st(),Eh=jt(),Ah=ni(),li=oi(),ui=ci(),Th=[Sh.map,xh.seq,Eh.string,kh.nullTag,Ah.boolTag,ui.intOct,ui.int,ui.intHex,li.floatNaN,li.floatExp,li.float];Cc.schema=Th});var Lc=v(_c=>{"use strict";var Ph=_(),Oh=rt(),Nh=st();function Ic(r){return typeof r=="bigint"||Number.isInteger(r)}var ls=({value:r})=>JSON.stringify(r),Ch=[{identify:r=>typeof r=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:r=>r,stringify:ls},{identify:r=>r==null,createNode:()=>new Ph.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ls},{identify:r=>typeof r=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:r=>r==="true",stringify:ls},{identify:Ic,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(r,e,{intAsBigInt:t})=>t?BigInt(r):parseInt(r,10),stringify:({value:r})=>Ic(r)?r.toString():JSON.stringify(r)},{identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:r=>parseFloat(r),stringify:ls}],Rh={default:!0,tag:"",test:/^/,resolve(r,e){return e(`Unresolved plain scalar ${JSON.stringify(r)}`),r}},Ih=[Oh.map,Nh.seq].concat(Ch,Rh);_c.schema=Ih});var di=v($c=>{"use strict";var Ut=Nr("buffer"),fi=_(),_h=Mt(),Lh={identify:r=>r instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(r,e){if(typeof Ut.Buffer=="function")return Ut.Buffer.from(r,"base64");if(typeof atob=="function"){let t=atob(r.replace(/[\n\r]/g,"")),s=new Uint8Array(t.length);for(let n=0;n<t.length;++n)s[n]=t.charCodeAt(n);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),r},stringify({comment:r,type:e,value:t},s,n,i){if(!t)return"";let o=t,a;if(typeof Ut.Buffer=="function")a=o instanceof Ut.Buffer?o.toString("base64"):Ut.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=fi.Scalar.BLOCK_LITERAL),e!==fi.Scalar.QUOTE_DOUBLE){let c=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),l=Math.ceil(a.length/c),f=new Array(l);for(let u=0,d=0;u<l;++u,d+=c)f[u]=a.substr(d,c);a=f.join(e===fi.Scalar.BLOCK_LITERAL?`
|
|
58
|
+
`:" ")}return _h.stringifyString({comment:r,type:e,value:a},s,n,i)}};$c.binary=Lh});var ds=v(fs=>{"use strict";var us=P(),pi=Se(),$h=_(),Mh=Ee();function Mc(r,e){if(us.isSeq(r))for(let t=0;t<r.items.length;++t){let s=r.items[t];if(!us.isPair(s)){if(us.isMap(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");let n=s.items[0]||new pi.Pair(new $h.Scalar(null));if(s.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${s.commentBefore}
|
|
59
59
|
${n.key.commentBefore}`:s.commentBefore),s.comment){let i=n.value??n.key;i.comment=i.comment?`${s.comment}
|
|
60
|
-
${i.comment}`:s.comment}s=n}r.items[t]=us.isPair(s)?s:new fi.Pair(s)}}else e("Expected a sequence for this tag");return r}function Mc(r,e,t){let{replacer:s}=t,n=new Rh.YAMLSeq(r);n.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof s=="function"&&(o=s.call(e,String(i++),o));let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)a=l[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=o;n.items.push(fi.createPair(a,c,t))}return n}var _h={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:$c,createNode:Mc};fs.createPairs=Mc;fs.pairs=_h;fs.resolvePairs=$c});var hi=S(pi=>{"use strict";var Dc=P(),di=ye(),Kt=xe(),Lh=Ee(),qc=ds(),Le=class r extends Lh.YAMLSeq{constructor(){super(),this.add=Kt.YAMLMap.prototype.add.bind(this),this.delete=Kt.YAMLMap.prototype.delete.bind(this),this.get=Kt.YAMLMap.prototype.get.bind(this),this.has=Kt.YAMLMap.prototype.has.bind(this),this.set=Kt.YAMLMap.prototype.set.bind(this),this.tag=r.tag}toJSON(e,t){if(!t)return super.toJSON(e);let s=new Map;t?.onCreate&&t.onCreate(s);for(let n of this.items){let i,o;if(Dc.isPair(n)?(i=di.toJS(n.key,"",t),o=di.toJS(n.value,i,t)):i=di.toJS(n,"",t),s.has(i))throw new Error("Ordered maps must not include duplicate keys");s.set(i,o)}return s}static from(e,t,s){let n=qc.createPairs(e,t,s),i=new this;return i.items=n.items,i}};Le.tag="tag:yaml.org,2002:omap";var $h={collection:"seq",identify:r=>r instanceof Map,nodeClass:Le,default:!1,tag:"tag:yaml.org,2002:omap",resolve(r,e){let t=qc.resolvePairs(r,e),s=[];for(let{key:n}of t.items)Dc.isScalar(n)&&(s.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):s.push(n.value));return Object.assign(new Le,t)},createNode:(r,e,t)=>Le.from(r,e,t)};pi.YAMLOMap=Le;pi.omap=$h});var Kc=S(mi=>{"use strict";var Bc=_();function jc({value:r,source:e},t){return e&&(r?Fc:Uc).test.test(e)?e:r?t.options.trueStr:t.options.falseStr}var Fc={identify:r=>r===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Bc.Scalar(!0),stringify:jc},Uc={identify:r=>r===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Bc.Scalar(!1),stringify:jc};mi.falseTag=Uc;mi.trueTag=Fc});var Jc=S(ps=>{"use strict";var Mh=_(),gi=st(),Dh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:r=>r.slice(-3).toLowerCase()==="nan"?NaN:r[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:gi.stringifyNumber},qh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:r=>parseFloat(r.replace(/_/g,"")),stringify(r){let e=Number(r.value);return isFinite(e)?e.toExponential():gi.stringifyNumber(r)}},Bh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(r){let e=new Mh.Scalar(parseFloat(r.replace(/_/g,""))),t=r.indexOf(".");if(t!==-1){let s=r.substring(t+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:gi.stringifyNumber};ps.float=Bh;ps.floatExp=qh;ps.floatNaN=Dh});var Wc=S(Vt=>{"use strict";var Vc=st(),Jt=r=>typeof r=="bigint"||Number.isInteger(r);function hs(r,e,t,{intAsBigInt:s}){let n=r[0];if((n==="-"||n==="+")&&(e+=1),r=r.substring(e).replace(/_/g,""),s){switch(t){case 2:r=`0b${r}`;break;case 8:r=`0o${r}`;break;case 16:r=`0x${r}`;break}let o=BigInt(r);return n==="-"?BigInt(-1)*o:o}let i=parseInt(r,t);return n==="-"?-1*i:i}function yi(r,e,t){let{value:s}=r;if(Jt(s)){let n=s.toString(e);return s<0?"-"+t+n.substr(1):t+n}return Vc.stringifyNumber(r)}var jh={identify:Jt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(r,e,t)=>hs(r,2,2,t),stringify:r=>yi(r,2,"0b")},Fh={identify:Jt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(r,e,t)=>hs(r,1,8,t),stringify:r=>yi(r,8,"0")},Uh={identify:Jt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(r,e,t)=>hs(r,0,10,t),stringify:Vc.stringifyNumber},Kh={identify:Jt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(r,e,t)=>hs(r,2,16,t),stringify:r=>yi(r,16,"0x")};Vt.int=Uh;Vt.intBin=jh;Vt.intHex=Kh;Vt.intOct=Fh});var wi=S(bi=>{"use strict";var ys=P(),ms=Se(),gs=xe(),$e=class r extends gs.YAMLMap{constructor(e){super(e),this.tag=r.tag}add(e){let t;ys.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new ms.Pair(e.key,null):t=new ms.Pair(e,null),gs.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let s=gs.findPair(this.items,e);return!t&&ys.isPair(s)?ys.isScalar(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let s=gs.findPair(this.items,e);s&&!t?this.items.splice(this.items.indexOf(s),1):!s&&t&&this.items.push(new ms.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);throw new Error("Set items must all have null values")}static from(e,t,s){let{replacer:n}=s,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t)typeof n=="function"&&(o=n.call(t,o,o)),i.items.push(ms.createPair(o,null,s));return i}};$e.tag="tag:yaml.org,2002:set";var Jh={collection:"map",identify:r=>r instanceof Set,nodeClass:$e,default:!1,tag:"tag:yaml.org,2002:set",createNode:(r,e,t)=>$e.from(r,e,t),resolve(r,e){if(ys.isMap(r)){if(r.hasAllNullValues(!0))return Object.assign(new $e,r);e("Set items must all have null values")}else e("Expected a mapping for this tag");return r}};bi.YAMLSet=$e;bi.set=Jh});var Si=S(bs=>{"use strict";var Vh=st();function vi(r,e){let t=r[0],s=t==="-"||t==="+"?r.substring(1):r,n=o=>e?BigInt(o):Number(o),i=s.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return t==="-"?n(-1)*i:i}function Yc(r){let{value:e}=r,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Vh.stringifyNumber(r);let s="";e<0&&(s="-",e*=t(-1));let n=t(60),i=[e%n];return e<60?i.unshift(0):(e=(e-i[0])/n,i.unshift(e%n),e>=60&&(e=(e-i[0])/n,i.unshift(e))),s+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Wh={identify:r=>typeof r=="bigint"||Number.isInteger(r),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(r,e,{intAsBigInt:t})=>vi(r,t),stringify:Yc},Yh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:r=>vi(r,!1),stringify:Yc},Hc={identify:r=>r 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(r){let e=r.match(Hc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,s,n,i,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(t,s-1,n,i||0,o||0,a||0,c),f=e[8];if(f&&f!=="Z"){let u=vi(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:r})=>r?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};bs.floatTime=Yh;bs.intTime=Wh;bs.timestamp=Hc});var Qc=S(zc=>{"use strict";var Hh=tt(),Gh=is(),zh=rt(),Qh=Ft(),Xh=ui(),Gc=Kc(),ki=Jc(),ws=Wc(),Zh=Qr(),em=hi(),tm=ds(),rm=wi(),xi=Si(),sm=[Hh.map,zh.seq,Qh.string,Gh.nullTag,Gc.trueTag,Gc.falseTag,ws.intBin,ws.intOct,ws.int,ws.intHex,ki.floatNaN,ki.floatExp,ki.float,Xh.binary,Zh.merge,em.omap,tm.pairs,rm.set,xi.intTime,xi.floatTime,xi.timestamp];zc.schema=sm});var al=S(Ai=>{"use strict";var tl=tt(),nm=is(),rl=rt(),im=Ft(),om=ri(),Ei=ni(),Ti=oi(),am=Cc(),cm=_c(),sl=ui(),Wt=Qr(),nl=hi(),il=ds(),Xc=Qc(),ol=wi(),vs=Si(),Zc=new Map([["core",am.schema],["failsafe",[tl.map,rl.seq,im.string]],["json",cm.schema],["yaml11",Xc.schema],["yaml-1.1",Xc.schema]]),el={binary:sl.binary,bool:om.boolTag,float:Ei.float,floatExp:Ei.floatExp,floatNaN:Ei.floatNaN,floatTime:vs.floatTime,int:Ti.int,intHex:Ti.intHex,intOct:Ti.intOct,intTime:vs.intTime,map:tl.map,merge:Wt.merge,null:nm.nullTag,omap:nl.omap,pairs:il.pairs,seq:rl.seq,set:ol.set,timestamp:vs.timestamp},lm={"tag:yaml.org,2002:binary":sl.binary,"tag:yaml.org,2002:merge":Wt.merge,"tag:yaml.org,2002:omap":nl.omap,"tag:yaml.org,2002:pairs":il.pairs,"tag:yaml.org,2002:set":ol.set,"tag:yaml.org,2002:timestamp":vs.timestamp};function um(r,e,t){let s=Zc.get(e);if(s&&!r)return t&&!s.includes(Wt.merge)?s.concat(Wt.merge):s.slice();let n=s;if(!n)if(Array.isArray(r))n=[];else{let i=Array.from(Zc.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(r))for(let i of r)n=n.concat(i);else typeof r=="function"&&(n=r(n.slice()));return t&&(n=n.concat(Wt.merge)),n.reduce((i,o)=>{let a=typeof o=="string"?el[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(el).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return i.includes(a)||i.push(a),i},[])}Ai.coreKnownTags=lm;Ai.getTags=um});var Ni=S(cl=>{"use strict";var Pi=P(),fm=tt(),dm=rt(),pm=Ft(),Ss=al(),hm=(r,e)=>r.key<e.key?-1:r.key>e.key?1:0,Oi=class r{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:n,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?Ss.getTags(e,"compat"):e?Ss.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=n?Ss.coreKnownTags:{},this.tags=Ss.getTags(t,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,Pi.MAP,{value:fm.map}),Object.defineProperty(this,Pi.SCALAR,{value:pm.string}),Object.defineProperty(this,Pi.SEQ,{value:dm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?hm:null}clone(){let e=Object.create(r.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};cl.Schema=Oi});var ul=S(ll=>{"use strict";var mm=P(),Ci=Dt(),Yt=_t();function gm(r,e){let t=[],s=e.directives===!0;if(e.directives!==!1&&r.directives){let c=r.directives.toString(r);c?(t.push(c),s=!0):r.directives.docStart&&(s=!0)}s&&t.push("---");let n=Ci.createStringifyContext(r,e),{commentString:i}=n.options;if(r.commentBefore){t.length!==1&&t.unshift("");let c=i(r.commentBefore);t.unshift(Yt.indentComment(c,""))}let o=!1,a=null;if(r.contents){if(mm.isNode(r.contents)){if(r.contents.spaceBefore&&s&&t.push(""),r.contents.commentBefore){let f=i(r.contents.commentBefore);t.push(Yt.indentComment(f,""))}n.forceBlockIndent=!!r.comment,a=r.contents.comment}let c=a?void 0:()=>o=!0,l=Ci.stringify(r.contents,n,()=>a=null,c);a&&(l+=Yt.lineComment(l,"",i(a))),(l[0]==="|"||l[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${l}`:t.push(l)}else t.push(Ci.stringify(r.contents,n));if(r.directives?.docEnd)if(r.comment){let c=i(r.comment);c.includes(`
|
|
60
|
+
${i.comment}`:s.comment}s=n}r.items[t]=us.isPair(s)?s:new pi.Pair(s)}}else e("Expected a sequence for this tag");return r}function Dc(r,e,t){let{replacer:s}=t,n=new Mh.YAMLSeq(r);n.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof s=="function"&&(o=s.call(e,String(i++),o));let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)a=l[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=o;n.items.push(pi.createPair(a,c,t))}return n}var Dh={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Mc,createNode:Dc};fs.createPairs=Dc;fs.pairs=Dh;fs.resolvePairs=Mc});var gi=v(mi=>{"use strict";var Bc=P(),hi=ye(),Jt=xe(),Bh=Ee(),qc=ds(),$e=class r extends Bh.YAMLSeq{constructor(){super(),this.add=Jt.YAMLMap.prototype.add.bind(this),this.delete=Jt.YAMLMap.prototype.delete.bind(this),this.get=Jt.YAMLMap.prototype.get.bind(this),this.has=Jt.YAMLMap.prototype.has.bind(this),this.set=Jt.YAMLMap.prototype.set.bind(this),this.tag=r.tag}toJSON(e,t){if(!t)return super.toJSON(e);let s=new Map;t?.onCreate&&t.onCreate(s);for(let n of this.items){let i,o;if(Bc.isPair(n)?(i=hi.toJS(n.key,"",t),o=hi.toJS(n.value,i,t)):i=hi.toJS(n,"",t),s.has(i))throw new Error("Ordered maps must not include duplicate keys");s.set(i,o)}return s}static from(e,t,s){let n=qc.createPairs(e,t,s),i=new this;return i.items=n.items,i}};$e.tag="tag:yaml.org,2002:omap";var qh={collection:"seq",identify:r=>r instanceof Map,nodeClass:$e,default:!1,tag:"tag:yaml.org,2002:omap",resolve(r,e){let t=qc.resolvePairs(r,e),s=[];for(let{key:n}of t.items)Bc.isScalar(n)&&(s.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):s.push(n.value));return Object.assign(new $e,t)},createNode:(r,e,t)=>$e.from(r,e,t)};mi.YAMLOMap=$e;mi.omap=qh});var Kc=v(yi=>{"use strict";var Fc=_();function jc({value:r,source:e},t){return e&&(r?Uc:Jc).test.test(e)?e:r?t.options.trueStr:t.options.falseStr}var Uc={identify:r=>r===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Fc.Scalar(!0),stringify:jc},Jc={identify:r=>r===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Fc.Scalar(!1),stringify:jc};yi.falseTag=Jc;yi.trueTag=Uc});var Vc=v(ps=>{"use strict";var Fh=_(),bi=nt(),jh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:r=>r.slice(-3).toLowerCase()==="nan"?NaN:r[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:bi.stringifyNumber},Uh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:r=>parseFloat(r.replace(/_/g,"")),stringify(r){let e=Number(r.value);return isFinite(e)?e.toExponential():bi.stringifyNumber(r)}},Jh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(r){let e=new Fh.Scalar(parseFloat(r.replace(/_/g,""))),t=r.indexOf(".");if(t!==-1){let s=r.substring(t+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:bi.stringifyNumber};ps.float=Jh;ps.floatExp=Uh;ps.floatNaN=jh});var Yc=v(Vt=>{"use strict";var Wc=nt(),Kt=r=>typeof r=="bigint"||Number.isInteger(r);function hs(r,e,t,{intAsBigInt:s}){let n=r[0];if((n==="-"||n==="+")&&(e+=1),r=r.substring(e).replace(/_/g,""),s){switch(t){case 2:r=`0b${r}`;break;case 8:r=`0o${r}`;break;case 16:r=`0x${r}`;break}let o=BigInt(r);return n==="-"?BigInt(-1)*o:o}let i=parseInt(r,t);return n==="-"?-1*i:i}function wi(r,e,t){let{value:s}=r;if(Kt(s)){let n=s.toString(e);return s<0?"-"+t+n.substr(1):t+n}return Wc.stringifyNumber(r)}var Kh={identify:Kt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(r,e,t)=>hs(r,2,2,t),stringify:r=>wi(r,2,"0b")},Vh={identify:Kt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(r,e,t)=>hs(r,1,8,t),stringify:r=>wi(r,8,"0")},Wh={identify:Kt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(r,e,t)=>hs(r,0,10,t),stringify:Wc.stringifyNumber},Yh={identify:Kt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(r,e,t)=>hs(r,2,16,t),stringify:r=>wi(r,16,"0x")};Vt.int=Wh;Vt.intBin=Kh;Vt.intHex=Yh;Vt.intOct=Vh});var Si=v(vi=>{"use strict";var ys=P(),ms=Se(),gs=xe(),Me=class r extends gs.YAMLMap{constructor(e){super(e),this.tag=r.tag}add(e){let t;ys.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new ms.Pair(e.key,null):t=new ms.Pair(e,null),gs.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let s=gs.findPair(this.items,e);return!t&&ys.isPair(s)?ys.isScalar(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let s=gs.findPair(this.items,e);s&&!t?this.items.splice(this.items.indexOf(s),1):!s&&t&&this.items.push(new ms.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);throw new Error("Set items must all have null values")}static from(e,t,s){let{replacer:n}=s,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t)typeof n=="function"&&(o=n.call(t,o,o)),i.items.push(ms.createPair(o,null,s));return i}};Me.tag="tag:yaml.org,2002:set";var Hh={collection:"map",identify:r=>r instanceof Set,nodeClass:Me,default:!1,tag:"tag:yaml.org,2002:set",createNode:(r,e,t)=>Me.from(r,e,t),resolve(r,e){if(ys.isMap(r)){if(r.hasAllNullValues(!0))return Object.assign(new Me,r);e("Set items must all have null values")}else e("Expected a mapping for this tag");return r}};vi.YAMLSet=Me;vi.set=Hh});var xi=v(bs=>{"use strict";var Gh=nt();function ki(r,e){let t=r[0],s=t==="-"||t==="+"?r.substring(1):r,n=o=>e?BigInt(o):Number(o),i=s.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return t==="-"?n(-1)*i:i}function Hc(r){let{value:e}=r,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Gh.stringifyNumber(r);let s="";e<0&&(s="-",e*=t(-1));let n=t(60),i=[e%n];return e<60?i.unshift(0):(e=(e-i[0])/n,i.unshift(e%n),e>=60&&(e=(e-i[0])/n,i.unshift(e))),s+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var zh={identify:r=>typeof r=="bigint"||Number.isInteger(r),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(r,e,{intAsBigInt:t})=>ki(r,t),stringify:Hc},Qh={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:r=>ki(r,!1),stringify:Hc},Gc={identify:r=>r 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(r){let e=r.match(Gc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,s,n,i,o,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(t,s-1,n,i||0,o||0,a||0,c),f=e[8];if(f&&f!=="Z"){let u=ki(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:r})=>r?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};bs.floatTime=Qh;bs.intTime=zh;bs.timestamp=Gc});var Xc=v(Qc=>{"use strict";var Xh=rt(),Zh=is(),em=st(),tm=jt(),rm=di(),zc=Kc(),Ei=Vc(),ws=Yc(),sm=Qr(),nm=gi(),im=ds(),om=Si(),Ai=xi(),am=[Xh.map,em.seq,tm.string,Zh.nullTag,zc.trueTag,zc.falseTag,ws.intBin,ws.intOct,ws.int,ws.intHex,Ei.floatNaN,Ei.floatExp,Ei.float,rm.binary,sm.merge,nm.omap,im.pairs,om.set,Ai.intTime,Ai.floatTime,Ai.timestamp];Qc.schema=am});var cl=v(Oi=>{"use strict";var rl=rt(),cm=is(),sl=st(),lm=jt(),um=ni(),Ti=oi(),Pi=ci(),fm=Rc(),dm=Lc(),nl=di(),Wt=Qr(),il=gi(),ol=ds(),Zc=Xc(),al=Si(),vs=xi(),el=new Map([["core",fm.schema],["failsafe",[rl.map,sl.seq,lm.string]],["json",dm.schema],["yaml11",Zc.schema],["yaml-1.1",Zc.schema]]),tl={binary:nl.binary,bool:um.boolTag,float:Ti.float,floatExp:Ti.floatExp,floatNaN:Ti.floatNaN,floatTime:vs.floatTime,int:Pi.int,intHex:Pi.intHex,intOct:Pi.intOct,intTime:vs.intTime,map:rl.map,merge:Wt.merge,null:cm.nullTag,omap:il.omap,pairs:ol.pairs,seq:sl.seq,set:al.set,timestamp:vs.timestamp},pm={"tag:yaml.org,2002:binary":nl.binary,"tag:yaml.org,2002:merge":Wt.merge,"tag:yaml.org,2002:omap":il.omap,"tag:yaml.org,2002:pairs":ol.pairs,"tag:yaml.org,2002:set":al.set,"tag:yaml.org,2002:timestamp":vs.timestamp};function hm(r,e,t){let s=el.get(e);if(s&&!r)return t&&!s.includes(Wt.merge)?s.concat(Wt.merge):s.slice();let n=s;if(!n)if(Array.isArray(r))n=[];else{let i=Array.from(el.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(r))for(let i of r)n=n.concat(i);else typeof r=="function"&&(n=r(n.slice()));return t&&(n=n.concat(Wt.merge)),n.reduce((i,o)=>{let a=typeof o=="string"?tl[o]:o;if(!a){let c=JSON.stringify(o),l=Object.keys(tl).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return i.includes(a)||i.push(a),i},[])}Oi.coreKnownTags=pm;Oi.getTags=hm});var Ri=v(ll=>{"use strict";var Ni=P(),mm=rt(),gm=st(),ym=jt(),Ss=cl(),bm=(r,e)=>r.key<e.key?-1:r.key>e.key?1:0,Ci=class r{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:n,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?Ss.getTags(e,"compat"):e?Ss.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=n?Ss.coreKnownTags:{},this.tags=Ss.getTags(t,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,Ni.MAP,{value:mm.map}),Object.defineProperty(this,Ni.SCALAR,{value:ym.string}),Object.defineProperty(this,Ni.SEQ,{value:gm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?bm:null}clone(){let e=Object.create(r.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};ll.Schema=Ci});var fl=v(ul=>{"use strict";var wm=P(),Ii=Dt(),Yt=_t();function vm(r,e){let t=[],s=e.directives===!0;if(e.directives!==!1&&r.directives){let c=r.directives.toString(r);c?(t.push(c),s=!0):r.directives.docStart&&(s=!0)}s&&t.push("---");let n=Ii.createStringifyContext(r,e),{commentString:i}=n.options;if(r.commentBefore){t.length!==1&&t.unshift("");let c=i(r.commentBefore);t.unshift(Yt.indentComment(c,""))}let o=!1,a=null;if(r.contents){if(wm.isNode(r.contents)){if(r.contents.spaceBefore&&s&&t.push(""),r.contents.commentBefore){let f=i(r.contents.commentBefore);t.push(Yt.indentComment(f,""))}n.forceBlockIndent=!!r.comment,a=r.contents.comment}let c=a?void 0:()=>o=!0,l=Ii.stringify(r.contents,n,()=>a=null,c);a&&(l+=Yt.lineComment(l,"",i(a))),(l[0]==="|"||l[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${l}`:t.push(l)}else t.push(Ii.stringify(r.contents,n));if(r.directives?.docEnd)if(r.comment){let c=i(r.comment);c.includes(`
|
|
61
61
|
`)?(t.push("..."),t.push(Yt.indentComment(c,""))):t.push(`... ${c}`)}else t.push("...");else{let c=r.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||a)&&t[t.length-1]!==""&&t.push(""),t.push(Yt.indentComment(i(c),"")))}return t.join(`
|
|
62
62
|
`)+`
|
|
63
|
-
`}
|
|
63
|
+
`}ul.stringifyDocument=vm});var Ht=v(dl=>{"use strict";var Sm=Rt(),it=Ur(),G=P(),km=Se(),xm=ye(),Em=Ri(),Am=fl(),_i=Br(),Tm=Dn(),Pm=It(),Li=Mn(),$i=class r{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,G.NODE_TYPE,{value:G.DOC});let n=null;typeof t=="function"||Array.isArray(t)?n=t:s===void 0&&t&&(s=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=i;let{version:o}=i;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Li.Directives({version:o}),this.setSchema(o,s),this.contents=e===void 0?null:this.createNode(e,n,s)}clone(){let e=Object.create(r.prototype,{[G.NODE_TYPE]:{value:G.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=G.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){ot(this.contents)&&this.contents.add(e)}addIn(e,t){ot(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let s=_i.anchorNames(this);e.anchor=!t||s.has(t)?_i.findNewAnchor(t||"a",s):t}return new Sm.Alias(e.anchor)}createNode(e,t,s){let n;if(typeof t=="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let y=m=>typeof m=="number"||m instanceof String||m instanceof Number,k=t.filter(y).map(String);k.length>0&&(t=t.concat(k)),n=t}else s===void 0&&t&&(s=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:c,onTagObj:l,tag:f}=s??{},{onAnchor:u,setAnchors:d,sourceObjects:p}=_i.createNodeAnchors(this,o||"a"),g={aliasDuplicateObjects:i??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=Pm.createNode(e,f,g);return a&&G.isCollection(h)&&(h.flow=!0),d(),h}createPair(e,t,s={}){let n=this.createNode(e,null,s),i=this.createNode(t,null,s);return new km.Pair(n,i)}delete(e){return ot(this.contents)?this.contents.delete(e):!1}deleteIn(e){return it.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):ot(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return G.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return it.isEmptyPath(e)?!t&&G.isScalar(this.contents)?this.contents.value:this.contents:G.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return G.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return it.isEmptyPath(e)?this.contents!==void 0:G.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=it.collectionFromPath(this.schema,[e],t):ot(this.contents)&&this.contents.set(e,t)}setIn(e,t){it.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=it.collectionFromPath(this.schema,Array.from(e),t):ot(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Li.Directives({version:"1.1"}),s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Li.Directives({version:e}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(s)this.schema=new Em.Schema(Object.assign(s,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:n,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=xm.toJS(this.contents,t??"",a);if(typeof i=="function")for(let{count:l,res:f}of a.anchors.values())i(f,l);return typeof o=="function"?Tm.applyReviver(o,{"":c},"",c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}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 t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return Am.stringifyDocument(this,e)}};function ot(r){if(G.isCollection(r))return!0;throw new Error("Expected a YAML collection as document contents")}dl.Document=$i});var Qt=v(zt=>{"use strict";var Gt=class extends Error{constructor(e,t,s,n){super(),this.name=e,this.code=s,this.message=n,this.pos=t}},Mi=class extends Gt{constructor(e,t,s){super("YAMLParseError",e,t,s)}},Di=class extends Gt{constructor(e,t,s){super("YAMLWarning",e,t,s)}},Om=(r,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));let{line:s,col:n}=t.linePos[0];t.message+=` at line ${s}, column ${n}`;let i=n-1,o=r.substring(e.lineStarts[s-1],e.lineStarts[s]).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"),s>1&&/^ *$/.test(o.substring(0,i))){let a=r.substring(e.lineStarts[s-2],e.lineStarts[s-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
64
64
|
`),o=a+o}if(/[^ ]/.test(o)){let a=1,c=t.linePos[1];c?.line===s&&c.col>n&&(a=Math.max(1,Math.min(c.col-n,80-i)));let l=" ".repeat(i)+"^".repeat(a);t.message+=`:
|
|
65
65
|
|
|
66
66
|
${o}
|
|
67
67
|
${l}
|
|
68
|
-
`}};zt.YAMLError=Gt;zt.YAMLParseError=
|
|
69
|
-
`))return!0;if(r.end){for(let e of r.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of r.items){for(let t of e.start)if(t.type==="newline")return!0;if(e.sep){for(let t of e.sep)if(t.type==="newline")return!0}if(
|
|
70
|
-
`+
|
|
71
|
-
`+
|
|
72
|
-
`+
|
|
73
|
-
`+T:
|
|
74
|
-
`+O.comment:
|
|
75
|
-
`+y.comment:l.comment=y.comment),l.range=[s.offset,
|
|
76
|
-
`.repeat(Math.max(1,o.length-1)):"",y=s+n.length;return e.source&&(y+=e.source.length),{value:
|
|
77
|
-
`;for(let
|
|
78
|
-
`):y.length>c||
|
|
79
|
-
`:!
|
|
68
|
+
`}};zt.YAMLError=Gt;zt.YAMLParseError=Mi;zt.YAMLWarning=Di;zt.prettifyError=Om});var Xt=v(pl=>{"use strict";function Nm(r,{flow:e,indicator:t,next:s,offset:n,onError:i,parentIndent:o,startOnNewline:a}){let c=!1,l=a,f=a,u="",d="",p=!1,g=!1,h=null,y=null,k=null,m=null,b=null,w=null,x=null;for(let S of r)switch(g&&(S.type!=="space"&&S.type!=="newline"&&S.type!=="comma"&&i(S.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),h&&(l&&S.type!=="comment"&&S.type!=="newline"&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),S.type){case"space":!e&&(t!=="doc-start"||s?.type!=="flow-collection")&&S.source.includes(" ")&&(h=S),f=!0;break;case"comment":{f||i(S,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let O=S.source.substring(1)||" ";u?u+=d+O:u=O,d="",l=!1;break}case"newline":l?u?u+=S.source:(!w||t!=="seq-item-ind")&&(c=!0):d+=S.source,l=!0,p=!0,(y||k)&&(m=S),f=!0;break;case"anchor":y&&i(S,"MULTIPLE_ANCHORS","A node can have at most one anchor"),S.source.endsWith(":")&&i(S.offset+S.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=S,x??(x=S.offset),l=!1,f=!1,g=!0;break;case"tag":{k&&i(S,"MULTIPLE_TAGS","A node can have at most one tag"),k=S,x??(x=S.offset),l=!1,f=!1,g=!0;break}case t:(y||k)&&i(S,"BAD_PROP_ORDER",`Anchors and tags must be after the ${S.source} indicator`),w&&i(S,"UNEXPECTED_TOKEN",`Unexpected ${S.source} in ${e??"collection"}`),w=S,l=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){b&&i(S,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=S,l=!1,f=!1;break}default:i(S,"UNEXPECTED_TOKEN",`Unexpected ${S.type} token`),l=!1,f=!1}let E=r[r.length-1],T=E?E.offset+E.source.length:n;return g&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&i(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=o||s?.type==="block-map"||s?.type==="block-seq")&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:w,spaceBefore:c,comment:u,hasNewline:p,anchor:y,tag:k,newlineAfterProp:m,end:T,start:x??T}}pl.resolveProps=Nm});var ks=v(hl=>{"use strict";function Bi(r){if(!r)return null;switch(r.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(r.source.includes(`
|
|
69
|
+
`))return!0;if(r.end){for(let e of r.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of r.items){for(let t of e.start)if(t.type==="newline")return!0;if(e.sep){for(let t of e.sep)if(t.type==="newline")return!0}if(Bi(e.key)||Bi(e.value))return!0}return!1;default:return!0}}hl.containsNewline=Bi});var qi=v(ml=>{"use strict";var Cm=ks();function Rm(r,e,t){if(e?.type==="flow-collection"){let s=e.end[0];s.indent===r&&(s.source==="]"||s.source==="}")&&Cm.containsNewline(e)&&t(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}ml.flowIndentCheck=Rm});var Fi=v(yl=>{"use strict";var gl=P();function Im(r,e,t){let{uniqueKeys:s}=r.options;if(s===!1)return!1;let n=typeof s=="function"?s:(i,o)=>i===o||gl.isScalar(i)&&gl.isScalar(o)&&i.value===o.value;return e.some(i=>n(i.key,t))}yl.mapIncludes=Im});var xl=v(kl=>{"use strict";var bl=Se(),_m=xe(),wl=Xt(),Lm=ks(),vl=qi(),$m=Fi(),Sl="All mapping items must start at the same column";function Mm({composeNode:r,composeEmptyNode:e},t,s,n,i){let o=i?.nodeClass??_m.YAMLMap,a=new o(t.schema);t.atRoot&&(t.atRoot=!1);let c=s.offset,l=null;for(let f of s.items){let{start:u,key:d,sep:p,value:g}=f,h=wl.resolveProps(u,{indicator:"explicit-key-ind",next:d??p?.[0],offset:c,onError:n,parentIndent:s.indent,startOnNewline:!0}),y=!h.found;if(y){if(d&&(d.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==s.indent&&n(c,"BAD_INDENT",Sl)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(a.comment?a.comment+=`
|
|
70
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||Lm.containsNewline(d))&&n(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==s.indent&&n(c,"BAD_INDENT",Sl);t.atKey=!0;let k=h.end,m=d?r(t,d,h,n):e(t,k,u,null,h,n);t.schema.compat&&vl.flowIndentCheck(s.indent,d,n),t.atKey=!1,$m.mapIncludes(t,a.items,m)&&n(k,"DUPLICATE_KEY","Map keys must be unique");let b=wl.resolveProps(p??[],{indicator:"map-value-ind",next:g,offset:m.range[2],onError:n,parentIndent:s.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=b.end,b.found){y&&(g?.type==="block-map"&&!b.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&h.start<b.found.offset-1024&&n(m.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let w=g?r(t,g,b,n):e(t,c,p,null,b,n);t.schema.compat&&vl.flowIndentCheck(s.indent,g,n),c=w.range[2];let x=new bl.Pair(m,w);t.options.keepSourceTokens&&(x.srcToken=f),a.items.push(x)}else{y&&n(m.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(m.comment?m.comment+=`
|
|
71
|
+
`+b.comment:m.comment=b.comment);let w=new bl.Pair(m);t.options.keepSourceTokens&&(w.srcToken=f),a.items.push(w)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[s.offset,c,l??c],a}kl.resolveBlockMap=Mm});var Al=v(El=>{"use strict";var Dm=Ee(),Bm=Xt(),qm=qi();function Fm({composeNode:r,composeEmptyNode:e},t,s,n,i){let o=i?.nodeClass??Dm.YAMLSeq,a=new o(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let c=s.offset,l=null;for(let{start:f,value:u}of s.items){let d=Bm.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:s.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?n(d.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(a.comment=d.comment);continue}let p=u?r(t,u,d,n):e(t,d.end,f,null,d,n);t.schema.compat&&qm.flowIndentCheck(s.indent,u,n),c=p.range[2],a.items.push(p)}return a.range=[s.offset,c,l??c],a}El.resolveBlockSeq=Fm});var at=v(Tl=>{"use strict";function jm(r,e,t,s){let n="";if(r){let i=!1,o="";for(let a of r){let{source:c,type:l}=a;switch(l){case"space":i=!0;break;case"comment":{t&&!i&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=c.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=c),i=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}Tl.resolveEnd=jm});var Cl=v(Nl=>{"use strict";var Um=P(),Jm=Se(),Pl=xe(),Km=Ee(),Vm=at(),Ol=Xt(),Wm=ks(),Ym=Fi(),ji="Block collections are not allowed within flow collections",Ui=r=>r&&(r.type==="block-map"||r.type==="block-seq");function Hm({composeNode:r,composeEmptyNode:e},t,s,n,i){let o=s.start.source==="{",a=o?"flow map":"flow sequence",c=i?.nodeClass??(o?Pl.YAMLMap:Km.YAMLSeq),l=new c(t.schema);l.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let u=s.offset+s.start.source.length;for(let y=0;y<s.items.length;++y){let k=s.items[y],{start:m,key:b,sep:w,value:x}=k,E=Ol.resolveProps(m,{flow:a,indicator:"explicit-key-ind",next:b??w?.[0],offset:u,onError:n,parentIndent:s.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!w&&!x){y===0&&E.comma?n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):y<s.items.length-1&&n(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),E.comment&&(l.comment?l.comment+=`
|
|
72
|
+
`+E.comment:l.comment=E.comment),u=E.end;continue}!o&&t.options.strict&&Wm.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0)E.comma&&n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(E.comma||n(E.start,"MISSING_CHAR",`Missing , between ${a} items`),E.comment){let T="";e:for(let S of m)switch(S.type){case"comma":case"space":break;case"comment":T=S.source.substring(1);break e;default:break e}if(T){let S=l.items[l.items.length-1];Um.isPair(S)&&(S=S.value??S.key),S.comment?S.comment+=`
|
|
73
|
+
`+T:S.comment=T,E.comment=E.comment.substring(T.length+1)}}if(!o&&!w&&!E.found){let T=x?r(t,x,E,n):e(t,E.end,w,null,E,n);l.items.push(T),u=T.range[2],Ui(x)&&n(T.range,"BLOCK_IN_FLOW",ji)}else{t.atKey=!0;let T=E.end,S=b?r(t,b,E,n):e(t,T,m,null,E,n);Ui(b)&&n(S.range,"BLOCK_IN_FLOW",ji),t.atKey=!1;let O=Ol.resolveProps(w??[],{flow:a,indicator:"map-value-ind",next:x,offset:S.range[2],onError:n,parentIndent:s.indent,startOnNewline:!1});if(O.found){if(!o&&!E.found&&t.options.strict){if(w)for(let R of w){if(R===O.found)break;if(R.type==="newline"){n(R,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<O.found.offset-1024&&n(O.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else x&&("source"in x&&x.source?.[0]===":"?n(x,"MISSING_CHAR",`Missing space after : in ${a}`):n(O.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let U=x?r(t,x,O,n):O.found?e(t,O.end,w,null,O,n):null;U?Ui(x)&&n(U.range,"BLOCK_IN_FLOW",ji):O.comment&&(S.comment?S.comment+=`
|
|
74
|
+
`+O.comment:S.comment=O.comment);let H=new Jm.Pair(S,U);if(t.options.keepSourceTokens&&(H.srcToken=k),o){let R=l;Ym.mapIncludes(t,R.items,S)&&n(T,"DUPLICATE_KEY","Map keys must be unique"),R.items.push(H)}else{let R=new Pl.YAMLMap(t.schema);R.flow=!0,R.items.push(H);let Ie=(U??S).range;R.range=[S.range[0],Ie[1],Ie[2]],l.items.push(R)}u=U?U.range[2]:O.end}}let d=o?"}":"]",[p,...g]=s.end,h=u;if(p?.source===d)h=p.offset+p.source.length;else{let y=a[0].toUpperCase()+a.substring(1),k=f?`${y} must end with a ${d}`:`${y} in block collection must be sufficiently indented and end with a ${d}`;n(u,f?"MISSING_CHAR":"BAD_INDENT",k),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let y=Vm.resolveEnd(g,h,t.options.strict,n);y.comment&&(l.comment?l.comment+=`
|
|
75
|
+
`+y.comment:l.comment=y.comment),l.range=[s.offset,h,y.offset]}else l.range=[s.offset,h,h];return l}Nl.resolveFlowCollection=Hm});var Il=v(Rl=>{"use strict";var Gm=P(),zm=_(),Qm=xe(),Xm=Ee(),Zm=xl(),eg=Al(),tg=Cl();function Ji(r,e,t,s,n,i){let o=t.type==="block-map"?Zm.resolveBlockMap(r,e,t,s,i):t.type==="block-seq"?eg.resolveBlockSeq(r,e,t,s,i):tg.resolveFlowCollection(r,e,t,s,i),a=o.constructor;return n==="!"||n===a.tagName?(o.tag=a.tagName,o):(n&&(o.tag=n),o)}function rg(r,e,t,s,n){let i=s.tag,o=i?e.directives.tagName(i.source,d=>n(i,"TAG_RESOLVE_FAILED",d)):null;if(t.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=s,g=d&&i?d.offset>i.offset?d:i:d??i;g&&(!p||p.offset<g.offset)&&n(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===Qm.YAMLMap.tagName&&a==="map"||o===Xm.YAMLSeq.tagName&&a==="seq")return Ji(r,e,t,n,o);let c=e.schema.tags.find(d=>d.tag===o&&d.collection===a);if(!c){let d=e.schema.knownTags[o];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?n(i,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Ji(r,e,t,n,o)}let l=Ji(r,e,t,n,o,c),f=c.resolve?.(l,d=>n(i,"TAG_RESOLVE_FAILED",d),e.options)??l,u=Gm.isNode(f)?f:new zm.Scalar(f);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Rl.composeCollection=rg});var Vi=v(_l=>{"use strict";var Ki=_();function sg(r,e,t){let s=e.offset,n=ng(e,r.options.strict,t);if(!n)return{value:"",type:null,comment:"",range:[s,s,s]};let i=n.mode===">"?Ki.Scalar.BLOCK_FOLDED:Ki.Scalar.BLOCK_LITERAL,o=e.source?ig(e.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let y=o[h][1];if(y===""||y==="\r")a=h;else break}if(a===0){let h=n.chomp==="+"&&o.length>0?`
|
|
76
|
+
`.repeat(Math.max(1,o.length-1)):"",y=s+n.length;return e.source&&(y+=e.source.length),{value:h,type:i,comment:n.comment,range:[s,y,y]}}let c=e.indent+n.indent,l=e.offset+n.length,f=0;for(let h=0;h<a;++h){let[y,k]=o[h];if(k===""||k==="\r")n.indent===0&&y.length>c&&(c=y.length);else{y.length<c&&t(l+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=y.length),f=h,c===0&&!r.atRoot&&t(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=y.length+k.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>c&&(a=h+1);let u="",d="",p=!1;for(let h=0;h<f;++h)u+=o[h][0].slice(c)+`
|
|
77
|
+
`;for(let h=f;h<a;++h){let[y,k]=o[h];l+=y.length+k.length+1;let m=k[k.length-1]==="\r";if(m&&(k=k.slice(0,-1)),k&&y.length<c){let w=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;t(l-k.length-(m?2:1),"BAD_INDENT",w),y=""}i===Ki.Scalar.BLOCK_LITERAL?(u+=d+y.slice(c)+k,d=`
|
|
78
|
+
`):y.length>c||k[0]===" "?(d===" "?d=`
|
|
79
|
+
`:!p&&d===`
|
|
80
80
|
`&&(d=`
|
|
81
81
|
|
|
82
|
-
`),u+=d+y.slice(c)+
|
|
83
|
-
`,
|
|
82
|
+
`),u+=d+y.slice(c)+k,d=`
|
|
83
|
+
`,p=!0):k===""?d===`
|
|
84
84
|
`?u+=`
|
|
85
85
|
`:d=`
|
|
86
|
-
`:(u+=d+
|
|
87
|
-
`+o[
|
|
86
|
+
`:(u+=d+k,d=" ",p=!1)}switch(n.chomp){case"-":break;case"+":for(let h=a;h<o.length;++h)u+=`
|
|
87
|
+
`+o[h][0].slice(c);u[u.length-1]!==`
|
|
88
88
|
`&&(u+=`
|
|
89
89
|
`);break;default:u+=`
|
|
90
|
-
`}let g=s+n.length+e.source.length;return{value:u,type:i,comment:n.comment,range:[s,g,g]}}function
|
|
90
|
+
`}let g=s+n.length+e.source.length;return{value:u,type:i,comment:n.comment,range:[s,g,g]}}function ng({offset:r,props:e},t,s){if(e[0].type!=="block-scalar-header")return s(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],i=n[0],o=0,a="",c=-1;for(let d=1;d<n.length;++d){let p=n[d];if(!a&&(p==="-"||p==="+"))a=p;else{let g=Number(p);!o&&g?o=g:c===-1&&(c=r+d)}}c!==-1&&s(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,f="",u=n.length;for(let d=1;d<e.length;++d){let p=e[d];switch(p.type){case"space":l=!0;case"newline":u+=p.source.length;break;case"comment":t&&!l&&s(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":s(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{let g=`Unexpected token in block scalar header: ${p.type}`;s(p,"UNEXPECTED_TOKEN",g);let h=p.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:u}}function ig(r){let e=r.split(/\n( *)/),t=e[0],s=t.match(/^( *)/),i=[s?.[1]?[s[1],t.slice(s[1].length)]:["",t]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}_l.resolveBlockScalar=sg});var Yi=v($l=>{"use strict";var Wi=_(),og=at();function ag(r,e,t){let{offset:s,type:n,source:i,end:o}=r,a,c,l=(d,p,g)=>t(s+d,p,g);switch(n){case"scalar":a=Wi.Scalar.PLAIN,c=cg(i,l);break;case"single-quoted-scalar":a=Wi.Scalar.QUOTE_SINGLE,c=lg(i,l);break;case"double-quoted-scalar":a=Wi.Scalar.QUOTE_DOUBLE,c=ug(i,l);break;default:return t(r,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[s,s+i.length,s+i.length]}}let f=s+i.length,u=og.resolveEnd(o,f,e,t);return{value:c,type:a,comment:u.comment,range:[s,f,u.offset]}}function cg(r,e){let t="";switch(r[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${r[0]}`;break}case"@":case"`":{t=`reserved character ${r[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),Ll(r)}function lg(r,e){return(r[r.length-1]!=="'"||r.length===1)&&e(r.length,"MISSING_CHAR","Missing closing 'quote"),Ll(r.slice(1,-1)).replace(/''/g,"'")}function Ll(r){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
91
91
|
`,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
92
92
|
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let s=e.exec(r);if(!s)return r;let n=s[1],i=" ",o=e.lastIndex;for(t.lastIndex=o;s=t.exec(r);)s[1]===""?i===`
|
|
93
93
|
`?n+=i:i=`
|
|
94
|
-
`:(n+=i+s[1],i=" "),o=t.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,s=a.exec(r),n+i+(s?.[1]??"")}function
|
|
94
|
+
`:(n+=i+s[1],i=" "),o=t.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,s=a.exec(r),n+i+(s?.[1]??"")}function ug(r,e){let t="";for(let s=1;s<r.length-1;++s){let n=r[s];if(!(n==="\r"&&r[s+1]===`
|
|
95
95
|
`))if(n===`
|
|
96
|
-
`){let{fold:i,offset:o}=
|
|
96
|
+
`){let{fold:i,offset:o}=fg(r,s);t+=i,s=o}else if(n==="\\"){let i=r[++s],o=dg[i];if(o)t+=o;else if(i===`
|
|
97
97
|
`)for(i=r[s+1];i===" "||i===" ";)i=r[++s+1];else if(i==="\r"&&r[s+1]===`
|
|
98
|
-
`)for(i=r[++s+1];i===" "||i===" ";)i=r[++s+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];t+=
|
|
98
|
+
`)for(i=r[++s+1];i===" "||i===" ";)i=r[++s+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];t+=pg(r,s+1,a,e),s+=a}else{let a=r.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(n===" "||n===" "){let i=s,o=r[s+1];for(;o===" "||o===" ";)o=r[++s+1];o!==`
|
|
99
99
|
`&&!(o==="\r"&&r[s+2]===`
|
|
100
|
-
`)&&(t+=s>i?r.slice(i,s+1):n)}else t+=n}return(r[r.length-1]!=='"'||r.length===1)&&e(r.length,"MISSING_CHAR",'Missing closing "quote'),t}function
|
|
100
|
+
`)&&(t+=s>i?r.slice(i,s+1):n)}else t+=n}return(r[r.length-1]!=='"'||r.length===1)&&e(r.length,"MISSING_CHAR",'Missing closing "quote'),t}function fg(r,e){let t="",s=r[e+1];for(;(s===" "||s===" "||s===`
|
|
101
101
|
`||s==="\r")&&!(s==="\r"&&r[e+2]!==`
|
|
102
102
|
`);)s===`
|
|
103
103
|
`&&(t+=`
|
|
104
|
-
`),e+=1,s=r[e+1];return t||(t=" "),{fold:t,offset:e}}var
|
|
105
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
104
|
+
`),e+=1,s=r[e+1];return t||(t=" "),{fold:t,offset:e}}var dg={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
105
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function pg(r,e,t,s){let n=r.substr(e,t),o=n.length===t&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;if(isNaN(o)){let a=r.substr(e-2,t+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}$l.resolveFlowScalar=ag});var Bl=v(Dl=>{"use strict";var De=P(),Ml=_(),hg=Vi(),mg=Yi();function gg(r,e,t,s){let{value:n,type:i,comment:o,range:a}=e.type==="block-scalar"?hg.resolveBlockScalar(r,e,s):mg.resolveFlowScalar(e,r.options.strict,s),c=t?r.directives.tagName(t.source,u=>s(t,"TAG_RESOLVE_FAILED",u)):null,l;r.options.stringKeys&&r.atKey?l=r.schema[De.SCALAR]:c?l=yg(r.schema,n,c,t,s):e.type==="scalar"?l=bg(r,n,e,s):l=r.schema[De.SCALAR];let f;try{let u=l.resolve(n,d=>s(t??e,"TAG_RESOLVE_FAILED",d),r.options);f=De.isScalar(u)?u:new Ml.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);s(t??e,"TAG_RESOLVE_FAILED",d),f=new Ml.Scalar(n)}return f.range=a,f.source=n,i&&(f.type=i),c&&(f.tag=c),l.format&&(f.format=l.format),o&&(f.comment=o),f}function yg(r,e,t,s,n){if(t==="!")return r[De.SCALAR];let i=[];for(let a of r.tags)if(!a.collection&&a.tag===t)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=r.knownTags[t];return o&&!o.collection?(r.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),r[De.SCALAR])}function bg({atKey:r,directives:e,schema:t},s,n,i){let o=t.tags.find(a=>(a.default===!0||r&&a.default==="key")&&a.test?.test(s))||t[De.SCALAR];if(t.compat){let a=t.compat.find(c=>c.default&&c.test?.test(s))??t[De.SCALAR];if(o.tag!==a.tag){let c=e.tagString(o.tag),l=e.tagString(a.tag),f=`Value may be parsed as either ${c} or ${l}`;i(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}Dl.composeScalar=gg});var Fl=v(ql=>{"use strict";function wg(r,e,t){if(e){t??(t=e.length);for(let s=t-1;s>=0;--s){let n=e[s];switch(n.type){case"space":case"comment":case"newline":r-=n.source.length;continue}for(n=e[++s];n?.type==="space";)r+=n.source.length,n=e[++s];break}}return r}ql.emptyScalarPosition=wg});var Jl=v(Gi=>{"use strict";var vg=Rt(),Sg=P(),kg=Il(),jl=Bl(),xg=at(),Eg=Fl(),Ag={composeNode:Ul,composeEmptyNode:Hi};function Ul(r,e,t,s){let n=r.atKey,{spaceBefore:i,comment:o,anchor:a,tag:c}=t,l,f=!0;switch(e.type){case"alias":l=Tg(r,e,s),(a||c)&&s(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":l=jl.composeScalar(r,e,c,s),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":l=kg.composeCollection(Ag,r,e,t,s),a&&(l.anchor=a.source.substring(1));break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;s(e,"UNEXPECTED_TOKEN",u),l=Hi(r,e.offset,void 0,null,t,s),f=!1}}return a&&l.anchor===""&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),n&&r.options.stringKeys&&(!Sg.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&s(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(l.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?l.comment=o:l.commentBefore=o),r.options.keepSourceTokens&&f&&(l.srcToken=e),l}function Hi(r,e,t,s,{spaceBefore:n,comment:i,anchor:o,tag:a,end:c},l){let f={type:"scalar",offset:Eg.emptyScalarPosition(e,t,s),indent:-1,source:""},u=jl.composeScalar(r,f,a,l);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),i&&(u.comment=i,u.range[2]=c),u}function Tg({options:r},{offset:e,source:t,end:s},n){let i=new vg.Alias(t.substring(1));i.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&n(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+t.length,a=xg.resolveEnd(s,o,r.strict,n);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Gi.composeEmptyNode=Hi;Gi.composeNode=Ul});var Wl=v(Vl=>{"use strict";var Pg=Ht(),Kl=Jl(),Og=at(),Ng=Xt();function Cg(r,e,{offset:t,start:s,value:n,end:i},o){let a=Object.assign({_directives:e},r),c=new Pg.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=Ng.resolveProps(s,{indicator:"doc-start",next:n??i?.[0],offset:t,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Kl.composeNode(l,n,f,o):Kl.composeEmptyNode(l,f.end,s,null,f,o);let u=c.contents.range[2],d=Og.resolveEnd(i,u,!1,o);return d.comment&&(c.comment=d.comment),c.range=[t,u,d.offset],c}Vl.composeDoc=Cg});var Qi=v(Gl=>{"use strict";var Rg=Nr("process"),Ig=Mn(),_g=Ht(),Zt=Qt(),Yl=P(),Lg=Wl(),$g=at();function er(r){if(typeof r=="number")return[r,r+1];if(Array.isArray(r))return r.length===2?r:[r[0],r[1]];let{offset:e,source:t}=r;return[e,e+(typeof t=="string"?t.length:1)]}function Hl(r){let e="",t=!1,s=!1;for(let n=0;n<r.length;++n){let i=r[n];switch(i[0]){case"#":e+=(e===""?"":s?`
|
|
106
106
|
|
|
107
107
|
`:`
|
|
108
|
-
`)+(i.substring(1)||" "),t=!0,s=!1;break;case"%":r[n+1]?.[0]!=="#"&&(n+=1),t=!1;break;default:t||(s=!0),t=!1}}return{comment:e,afterEmptyLine:s}}var
|
|
109
|
-
${s}`:s;else if(n||e.directives.docStart||!i)e.commentBefore=s;else if(
|
|
108
|
+
`)+(i.substring(1)||" "),t=!0,s=!1;break;case"%":r[n+1]?.[0]!=="#"&&(n+=1),t=!1;break;default:t||(s=!0),t=!1}}return{comment:e,afterEmptyLine:s}}var zi=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,n,i)=>{let o=er(t);i?this.warnings.push(new Zt.YAMLWarning(o,s,n)):this.errors.push(new Zt.YAMLParseError(o,s,n))},this.directives=new Ig.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:s,afterEmptyLine:n}=Hl(this.prelude);if(s){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
109
|
+
${s}`:s;else if(n||e.directives.docStart||!i)e.commentBefore=s;else if(Yl.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];Yl.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${s}
|
|
110
110
|
${a}`:s}else{let o=i.commentBefore;i.commentBefore=o?`${s}
|
|
111
|
-
${o}`:s}}t?(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:
|
|
112
|
-
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Zt.YAMLParseError(er(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let s=Object.assign({_directives:this.directives},this.options),n=new
|
|
111
|
+
${o}`:s}}t?(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:Hl(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(let n of e)yield*this.next(n);yield*this.end(t,s)}*next(e){switch(Rg.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,s,n)=>{let i=er(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",s,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=Lg.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new Zt.YAMLParseError(er(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(s):this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){let s="Unexpected doc-end without preceding document";this.errors.push(new Zt.YAMLParseError(er(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;let t=$g.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let s=this.doc.comment;this.doc.comment=s?`${s}
|
|
112
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Zt.YAMLParseError(er(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let s=Object.assign({_directives:this.directives},this.options),n=new _g.Document(void 0,s);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,t,t],this.decorate(n,!1),yield n}}};Gl.Composer=zi});var Xl=v(xs=>{"use strict";var Mg=Vi(),Dg=Yi(),Bg=Qt(),zl=Mt();function qg(r,e=!0,t){if(r){let s=(n,i,o)=>{let a=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(t)t(a,i,o);else throw new Bg.YAMLParseError([a,a+1],i,o)};switch(r.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Dg.resolveFlowScalar(r,e,s);case"block-scalar":return Mg.resolveBlockScalar({options:{strict:e}},r,s)}}return null}function Fg(r,e){let{implicitKey:t=!1,indent:s,inFlow:n=!1,offset:i=-1,type:o="PLAIN"}=e,a=zl.stringifyString({type:o,value:r},{implicitKey:t,indent:s>0?" ".repeat(s):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:s,source:`
|
|
113
113
|
`}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
|
|
114
114
|
`),f=a.substring(0,l),u=a.substring(l+1)+`
|
|
115
|
-
`,d=[{type:"block-scalar-header",offset:i,indent:s,source:f}];return
|
|
116
|
-
`}),{type:"block-scalar",offset:i,indent:s,props:d,source:u}}case'"':return{type:"double-quoted-scalar",offset:i,indent:s,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:s,source:a,end:c};default:return{type:"scalar",offset:i,indent:s,source:a,end:c}}}function
|
|
115
|
+
`,d=[{type:"block-scalar-header",offset:i,indent:s,source:f}];return Ql(d,c)||d.push({type:"newline",offset:-1,indent:s,source:`
|
|
116
|
+
`}),{type:"block-scalar",offset:i,indent:s,props:d,source:u}}case'"':return{type:"double-quoted-scalar",offset:i,indent:s,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:i,indent:s,source:a,end:c};default:return{type:"scalar",offset:i,indent:s,source:a,end:c}}}function jg(r,e,t={}){let{afterKey:s=!1,implicitKey:n=!1,inFlow:i=!1,type:o}=t,a="indent"in r?r.indent:null;if(s&&typeof a=="number"&&(a+=2),!o)switch(r.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=r.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=zl.stringifyString({type:o,value:e},{implicitKey:n||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":Ug(r,c);break;case'"':Xi(r,c,"double-quoted-scalar");break;case"'":Xi(r,c,"single-quoted-scalar");break;default:Xi(r,c,"scalar")}}function Ug(r,e){let t=e.indexOf(`
|
|
117
117
|
`),s=e.substring(0,t),n=e.substring(t+1)+`
|
|
118
|
-
`;if(r.type==="block-scalar"){let i=r.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=s,r.source=n}else{let{offset:i}=r,o="indent"in r?r.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:s}];
|
|
119
|
-
`});for(let c of Object.keys(r))c!=="type"&&c!=="offset"&&delete r[c];Object.assign(r,{type:"block-scalar",indent:o,props:a,source:n})}}function
|
|
120
|
-
`};delete r.items,Object.assign(r,{type:t,source:e,end:[n]});break}default:{let s="indent"in r?r.indent:-1,n="end"in r&&Array.isArray(r.end)?r.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(r))i!=="type"&&i!=="offset"&&delete r[i];Object.assign(r,{type:t,indent:s,source:e,end:n})}}}xs.createScalarToken=
|
|
118
|
+
`;if(r.type==="block-scalar"){let i=r.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=s,r.source=n}else{let{offset:i}=r,o="indent"in r?r.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:s}];Ql(a,"end"in r?r.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
|
|
119
|
+
`});for(let c of Object.keys(r))c!=="type"&&c!=="offset"&&delete r[c];Object.assign(r,{type:"block-scalar",indent:o,props:a,source:n})}}function Ql(r,e){if(e)for(let t of e)switch(t.type){case"space":case"comment":r.push(t);break;case"newline":return r.push(t),!0}return!1}function Xi(r,e,t){switch(r.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":r.type=t,r.source=e;break;case"block-scalar":{let s=r.props.slice(1),n=e.length;r.props[0].type==="block-scalar-header"&&(n-=r.props[0].source.length);for(let i of s)i.offset+=n;delete r.props,Object.assign(r,{type:t,source:e,end:s});break}case"block-map":case"block-seq":{let n={type:"newline",offset:r.offset+e.length,indent:r.indent,source:`
|
|
120
|
+
`};delete r.items,Object.assign(r,{type:t,source:e,end:[n]});break}default:{let s="indent"in r?r.indent:-1,n="end"in r&&Array.isArray(r.end)?r.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(r))i!=="type"&&i!=="offset"&&delete r[i];Object.assign(r,{type:t,indent:s,source:e,end:n})}}}xs.createScalarToken=Fg;xs.resolveAsScalar=qg;xs.setScalarValue=jg});var eu=v(Zl=>{"use strict";var Jg=r=>"type"in r?As(r):Es(r);function As(r){switch(r.type){case"block-scalar":{let e="";for(let t of r.props)e+=As(t);return e+r.source}case"block-map":case"block-seq":{let e="";for(let t of r.items)e+=Es(t);return e}case"flow-collection":{let e=r.start.source;for(let t of r.items)e+=Es(t);for(let t of r.end)e+=t.source;return e}case"document":{let e=Es(r);if(r.end)for(let t of r.end)e+=t.source;return e}default:{let e=r.source;if("end"in r&&r.end)for(let t of r.end)e+=t.source;return e}}}function Es({start:r,key:e,sep:t,value:s}){let n="";for(let i of r)n+=i.source;if(e&&(n+=As(e)),t)for(let i of t)n+=i.source;return s&&(n+=As(s)),n}Zl.stringify=Jg});var nu=v(su=>{"use strict";var Zi=Symbol("break visit"),Kg=Symbol("skip children"),tu=Symbol("remove item");function Be(r,e){"type"in r&&r.type==="document"&&(r={start:r.start,value:r.value}),ru(Object.freeze([]),r,e)}Be.BREAK=Zi;Be.SKIP=Kg;Be.REMOVE=tu;Be.itemAtPath=(r,e)=>{let t=r;for(let[s,n]of e){let i=t?.[s];if(i&&"items"in i)t=i.items[n];else return}return t};Be.parentCollection=(r,e)=>{let t=Be.itemAtPath(r,e.slice(0,-1)),s=e[e.length-1][0],n=t?.[s];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function ru(r,e,t){let s=t(e,r);if(typeof s=="symbol")return s;for(let n of["key","value"]){let i=e[n];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=ru(Object.freeze(r.concat([[n,o]])),i.items[o],t);if(typeof a=="number")o=a-1;else{if(a===Zi)return Zi;a===tu&&(i.items.splice(o,1),o-=1)}}typeof s=="function"&&n==="key"&&(s=s(e,r))}}return typeof s=="function"?s(e,r):s}su.visit=Be});var Ts=v(K=>{"use strict";var eo=Xl(),Vg=eu(),Wg=nu(),to="\uFEFF",ro="",so="",no="",Yg=r=>!!r&&"items"in r,Hg=r=>!!r&&(r.type==="scalar"||r.type==="single-quoted-scalar"||r.type==="double-quoted-scalar"||r.type==="block-scalar");function Gg(r){switch(r){case to:return"<BOM>";case ro:return"<DOC>";case so:return"<FLOW_END>";case no:return"<SCALAR>";default:return JSON.stringify(r)}}function zg(r){switch(r){case to:return"byte-order-mark";case ro:return"doc-mode";case so:return"flow-error-end";case no:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
121
121
|
`:case`\r
|
|
122
|
-
`: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(r[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}
|
|
123
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
124
|
-
\r `),
|
|
122
|
+
`: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(r[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}K.createScalarToken=eo.createScalarToken;K.resolveAsScalar=eo.resolveAsScalar;K.setScalarValue=eo.setScalarValue;K.stringify=Vg.stringify;K.visit=Wg.visit;K.BOM=to;K.DOCUMENT=ro;K.FLOW_END=so;K.SCALAR=no;K.isCollection=Yg;K.isScalar=Hg;K.prettyToken=Gg;K.tokenType=zg});var ao=v(ou=>{"use strict";var tr=Ts();function ee(r){switch(r){case void 0:case" ":case`
|
|
123
|
+
`:case"\r":case" ":return!0;default:return!1}}var iu=new Set("0123456789ABCDEFabcdef"),Qg=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Ps=new Set(",[]{}"),Xg=new Set(` ,[]{}
|
|
124
|
+
\r `),io=r=>!r||Xg.has(r),oo=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,t=!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=!t;let s=this.next??"stream";for(;s&&(t||this.hasChars(1));)s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
|
|
125
125
|
`?!0:t==="\r"?this.buffer[e+1]===`
|
|
126
126
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let s=0;for(;t===" ";)t=this.buffer[++s+e];if(t==="\r"){let n=this.buffer[s+e+1];if(n===`
|
|
127
127
|
`||!n&&!this.atEnd)return e+s+1}return t===`
|
|
128
128
|
`||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&ee(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(`
|
|
129
|
-
`,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]===tr.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,s=e.indexOf("#");for(;s!==-1;){let i=e[s-1];if(i===" "||i===" "){t=s-1;break}else s=e.indexOf("#",s+1)}for(;;){let i=e[t-1];if(i===" "||i===" ")t-=1;else break}let n=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield tr.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 t=this.peek(3);if((t==="---"||t==="...")&&ee(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ee(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ee(t)){let s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);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(
|
|
129
|
+
`,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]===tr.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,s=e.indexOf("#");for(;s!==-1;){let i=e[s-1];if(i===" "||i===" "){t=s-1;break}else s=e.indexOf("#",s+1)}for(;;){let i=e[t-1];if(i===" "||i===" ")t-=1;else break}let n=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield tr.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 t=this.peek(3);if((t==="---"||t==="...")&&ee(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ee(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ee(t)){let s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);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(io),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,s=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=s=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((s!==-1&&s<this.indentNext&&n[0]!=="#"||s===0&&(n.startsWith("---")||n.startsWith("..."))&&ee(n[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield tr.FLOW_END,yield*this.parseLineStart();let i=0;for(;n[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),n[i]){case void 0:return"flow";case"#":return yield*this.pushCount(n.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(io),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ee(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),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let i=0;for(;this.buffer[t-1-i]==="\\";)i+=1;if(i%2===0)break;t=this.buffer.indexOf('"',t+1)}let s=this.buffer.substring(0,t),n=s.indexOf(`
|
|
130
130
|
`,this.pos);if(n!==-1){for(;n!==-1;){let i=this.continueScalar(n+1);if(i===-1)break;n=s.indexOf(`
|
|
131
131
|
`,i)}n!==-1&&(t=n-(s[n-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>ee(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,s;e:for(let i=this.pos;s=this.buffer[i];++i)switch(s){case" ":t+=1;break;case`
|
|
132
132
|
`:e=i,t=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
@@ -136,34 +136,39 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
|
|
|
136
136
|
`&&i>=this.pos&&i+1+t>a)e=i;else break}while(!0);return yield tr.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,s=this.pos-1,n;for(;n=this.buffer[++s];)if(n===":"){let i=this.buffer[s+1];if(ee(i)||e&&Ps.has(i))break;t=s}else if(ee(n)){let i=this.buffer[s+1];if(n==="\r"&&(i===`
|
|
137
137
|
`?(s+=1,n=`
|
|
138
138
|
`,i=this.buffer[s+1]):t=s),i==="#"||e&&Ps.has(i))break;if(n===`
|
|
139
|
-
`){let o=this.continueScalar(s+1);if(o===-1)break;s=Math.max(s,o-2)}}else{if(e&&Ps.has(n))break;t=s}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield tr.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let s=this.buffer.slice(this.pos,e);return s?(yield s,this.pos+=s.length,s.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(
|
|
139
|
+
`){let o=this.continueScalar(s+1);if(o===-1)break;s=Math.max(s,o-2)}}else{if(e&&Ps.has(n))break;t=s}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield tr.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let s=this.buffer.slice(this.pos,e);return s?(yield s,this.pos+=s.length,s.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(io))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,t=this.charAt(1);if(ee(t)||e&&Ps.has(t))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,t=this.buffer[e];for(;!ee(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(Qg.has(t))t=this.buffer[++e];else if(t==="%"&&iu.has(this.buffer[e+1])&&iu.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
140
140
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
141
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s===" ");let n=t-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=t),n}*pushUntil(e){let t=this.pos,s=this.buffer[t];for(;!e(s);)s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};
|
|
141
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s===" ");let n=t-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=t),n}*pushUntil(e){let t=this.pos,s=this.buffer[t];for(;!e(s);)s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};ou.Lexer=oo});var lo=v(au=>{"use strict";var co=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,s=this.lineStarts.length;for(;t<s;){let i=t+s>>1;this.lineStarts[i]<e?t=i+1:s=i}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let n=this.lineStarts[t-1];return{line:t,col:e-n+1}}}};au.LineCounter=co});var fo=v(du=>{"use strict";var Zg=Nr("process"),cu=Ts(),ey=ao();function Ae(r,e){for(let t=0;t<r.length;++t)if(r[t].type===e)return!0;return!1}function lu(r){for(let e=0;e<r.length;++e)switch(r[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function fu(r){switch(r?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Os(r){switch(r.type){case"document":return r.start;case"block-map":{let e=r.items[r.items.length-1];return e.sep??e.start}case"block-seq":return r.items[r.items.length-1].start;default:return[]}}function ct(r){if(r.length===0)return[];let e=r.length;e:for(;--e>=0;)switch(r[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;r[++e]?.type==="space";);return r.splice(e,r.length)}function uu(r){if(r.start.type==="flow-seq-start")for(let e of r.items)e.sep&&!e.value&&!Ae(e.start,"explicit-key-ind")&&!Ae(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,fu(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 uo=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 ey.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let s of this.lexer.lex(e,t))yield*this.next(s);t||(yield*this.end())}*next(e){if(this.source=e,Zg.env.LOG_TOKENS&&console.log("|",cu.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=cu.tokenType(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){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 s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,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 t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let s=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in s?s.indent:0:t.type==="flow-collection"&&s.type==="document"&&(t.indent=0),t.type==="flow-collection"&&uu(t),s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{let n=s.items[s.items.length-1];if(n.value){s.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=s.items[s.items.length-1];n.value?s.items.push({start:[],value:t}):n.value=t;break}case"flow-collection":{let n=s.items[s.items.length-1];!n||n.value?s.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&lu(n.start)===-1&&(t.indent===0||n.start.every(i=>i.type!=="comment"||i.indent<t.indent))&&(s.type==="document"?s.end=n.start:s.items.push({start:n.start}),t.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":{lu(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 t=this.startBlockValue(e);t?this.stack.push(t):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 t=Os(this.peek(2)),s=ct(t),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:n}]};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 t=this.source.indexOf(`
|
|
142
142
|
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
143
|
-
`,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,n=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",i=[];if(n&&t.sep&&!t.value){let o=[];for(let a=0;a<t.sep.length;++a){let c=t.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=t.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):n||t.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(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(
|
|
143
|
+
`,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,n=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",i=[];if(n&&t.sep&&!t.value){let o=[];for(let a=0;a<t.sep.length;++a){let c=t.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=t.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):n||t.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(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ae(t.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(fu(t.key)&&!Ae(t.sep,"newline")){let o=ct(t.start),a=t.key,c=t.sep;c.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:c}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else if(Ae(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=ct(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||n?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Ae(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{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);n||t.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(o):(Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!Ae(t.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 s&&e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||Ae(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{let s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){let n=Os(s),i=ct(n);uu(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 t=this.source.indexOf(`
|
|
144
144
|
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
145
|
-
`,t)+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 t=Os(e),s=
|
|
146
|
-
`),t=e.trim();if(
|
|
145
|
+
`,t)+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 t=Os(e),s=ct(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Os(e),s=ct(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(s=>s.type==="newline"||s.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())}}};du.Parser=uo});var yu=v(sr=>{"use strict";var pu=Qi(),ty=Ht(),rr=Qt(),ry=Gn(),sy=P(),ny=lo(),hu=fo();function mu(r){let e=r.prettyErrors!==!1;return{lineCounter:r.lineCounter||e&&new ny.LineCounter||null,prettyErrors:e}}function iy(r,e={}){let{lineCounter:t,prettyErrors:s}=mu(e),n=new hu.Parser(t?.addNewLine),i=new pu.Composer(e),o=Array.from(i.compose(n.parse(r)));if(s&&t)for(let a of o)a.errors.forEach(rr.prettifyError(r,t)),a.warnings.forEach(rr.prettifyError(r,t));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function gu(r,e={}){let{lineCounter:t,prettyErrors:s}=mu(e),n=new hu.Parser(t?.addNewLine),i=new pu.Composer(e),o=null;for(let a of i.compose(n.parse(r),!0,r.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new rr.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&t&&(o.errors.forEach(rr.prettifyError(r,t)),o.warnings.forEach(rr.prettifyError(r,t))),o}function oy(r,e,t){let s;typeof e=="function"?s=e:t===void 0&&e&&typeof e=="object"&&(t=e);let n=gu(r,t);if(!n)return null;if(n.warnings.forEach(i=>ry.warn(n.options.logLevel,i)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:s},t))}function ay(r,e,t){let s=null;if(typeof e=="function"||Array.isArray(e)?s=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){let n=Math.round(t);t=n<1?void 0:n>8?{indent:8}:{indent:n}}if(r===void 0){let{keepUndefined:n}=t??e??{};if(!n)return}return sy.isDocument(r)&&!s?r.toString(t):new ty.Document(r,s,t).toString(t)}sr.parse=oy;sr.parseAllDocuments=iy;sr.parseDocument=gu;sr.stringify=ay});var wu=v(C=>{"use strict";var cy=Qi(),ly=Ht(),uy=Ri(),po=Qt(),fy=Rt(),Te=P(),dy=Se(),py=_(),hy=xe(),my=Ee(),gy=Ts(),yy=ao(),by=lo(),wy=fo(),Ns=yu(),bu=Pt();C.Composer=cy.Composer;C.Document=ly.Document;C.Schema=uy.Schema;C.YAMLError=po.YAMLError;C.YAMLParseError=po.YAMLParseError;C.YAMLWarning=po.YAMLWarning;C.Alias=fy.Alias;C.isAlias=Te.isAlias;C.isCollection=Te.isCollection;C.isDocument=Te.isDocument;C.isMap=Te.isMap;C.isNode=Te.isNode;C.isPair=Te.isPair;C.isScalar=Te.isScalar;C.isSeq=Te.isSeq;C.Pair=dy.Pair;C.Scalar=py.Scalar;C.YAMLMap=hy.YAMLMap;C.YAMLSeq=my.YAMLSeq;C.CST=gy;C.Lexer=yy.Lexer;C.LineCounter=by.LineCounter;C.Parser=wy.Parser;C.parse=Ns.parse;C.parseAllDocuments=Ns.parseAllDocuments;C.parseDocument=Ns.parseDocument;C.stringify=Ns.stringify;C.visit=bu.visit;C.visitAsync=bu.visitAsync});function Sy(r){try{return JSON.parse(r.trim()),!0}catch{return!1}}function ky(r){let e=r.trim();if(!e.startsWith("<"))return!1;let t=e.match(vy);return t?Tt(e,t[1])!==null:!1}function xy(r){let e=r.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let t=vu.parse(e);return t!==null&&typeof t=="object"}catch{return!1}}function Su(r){return Sy(r)||ky(r)||xy(r)}var vu,vy,ho=N(()=>{Ra();vu=$d(wu(),1),vy=/<([a-zA-Z_][\w.-]*)/});function Ey(r){if(!r?.trim())return[];let e=r.replace(/\r\n/g,`
|
|
146
|
+
`),t=e.trim();if(Su(t))return[{text:t,startLine:1,endLine:e.split(`
|
|
147
147
|
`).length}];let s=e.split(`
|
|
148
148
|
`),n=[],i=0,o=-1,a=0,c=()=>{if(o>=i){let l=s.slice(i,o+1).join(`
|
|
149
|
-
`).trim();l&&n.push({text:l,startLine:i+1,endLine:o+1})}};for(let l=0;l<s.length;l++)s[l].trim()?(a>=2&&o>=i&&(c(),i=l),a=0,o=l):a++;return c(),n}function
|
|
150
|
-
\u2026[${r.length-
|
|
151
|
-
`):r==null?"":
|
|
152
|
-
`))>=0;){let c=r.partial.slice(0,n);if(r.partial=r.partial.slice(n+1),!c.trim())continue;let l;try{l=JSON.parse(c)}catch{continue}l&&l.uuid&&(r.entries.set(l.uuid,l),l.isSidechain||(s=l.uuid))}if(!s)return;let i=[],o=r.entries.get(s),a=!1;for(;o;){if(i.push(o),o.uuid===r.chainLastUuid){a=!0;break}o=o.parentUuid?r.entries.get(o.parentUuid):void 0}if(a)for(let c=i.length-2;c>=0;c--)
|
|
153
|
-
`),o=s.filter(c=>c.type==="tool_use").map(c=>({id:c.id??"",name:c.name??"",input:c.input??{}}));if(n||i||o.length){let c=Date.parse(r.timestamp??""),l=!isNaN(c)&&c>=e.sessionStartMs;e.buffer.push({type:"assistant",text:n,thinking:i,tools:o,live:l})}let a=r.message?.usage??r.usage;a&&(e.latest={in:a.input_tokens??0,out:a.output_tokens??0,cached:a.cache_read_input_tokens??0,cacheCreate:a.cache_creation_input_tokens??0},e.buffer.push({type:"usage",...e.latest}))}}async function
|
|
154
|
-
`)){if(!
|
|
155
|
-
`)){if(!l.trim())continue;let f;try{f=JSON.parse(l)}catch{continue}if(!f||
|
|
149
|
+
`).trim();l&&n.push({text:l,startLine:i+1,endLine:o+1})}};for(let l=0;l<s.length;l++)s[l].trim()?(a>=2&&o>=i&&(c(),i=l),a=0,o=l):a++;return c(),n}function mo(r){return Ey(r).map(e=>e.text)}var ku=N(()=>{ho()});var Cs=N(()=>{Cr();Sa();ka();Ea();ho();ku();Rr()});function Rs(r){return{...va(r),server:r.files.get("server.ts")??""}}var go=N(()=>{Cs();Cs();Cs()});import{join as Io,resolve as ab}from"path";import{homedir as cb}from"os";function zs(){let r=process.env.TYPEBULB_SERVERS_DIR;return r?Io(r,".."):Io(cb(),".typebulb")}function Ue(){return process.env.TYPEBULB_SERVERS_DIR||Io(zs(),"servers")}function q(r){let e=ab(r);return(process.platform==="win32"?e.toLowerCase():e).replace(/\\/g,"/")}function Xu(r,e){let t=q(r),s=q(e);return t.startsWith(s.endsWith("/")?s:s+"/")?!t.includes("/node_modules/"):!1}var vr=N(()=>{});import{readFileSync as lb,writeFileSync as ub,mkdirSync as fb}from"fs";import{join as db}from"path";function Zu(){return db(zs(),"trust.json")}function _o(){try{let r=JSON.parse(lb(Zu(),"utf8"));return new Set(Array.isArray(r)?r:[])}catch{return new Set}}function pb(r){fb(zs(),{recursive:!0}),ub(Zu(),JSON.stringify([...r]))}function Je(r){return _o().has(q(r))}function mt(r,e){let t=_o(),s=q(r);(e?t.has(s):!t.has(s))||(e?t.add(s):t.delete(s),pb(t))}function Lo(){return[..._o()]}var Sr=N(()=>{vr()});function bt(r){if(r.server.trim())return"server-side code (server.ts)";let e=r.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"))return"AI (your API keys)";if(/\btb\s*\.\s*server\s*\.\s*(?!log\b)\w/.test(e)||e.includes("/__api"))return"server-side code (server.ts)"}var en=N(()=>{});import{spawn as pf}from"child_process";import{readdir as _b,readFile as gf,writeFile as yf,unlink as xr,mkdir as Lb}from"fs/promises";import{mkdirSync as $b,writeFileSync as hf,appendFileSync as Mb,readFileSync as bf}from"fs";import*as ne from"path";import{fileURLToPath as Db}from"url";function Bo(r){return ne.join(Ue(),`${r}.json`)}function Er(r){return ne.join(Ue(),`${r}.log`)}function tn(r){let e=Er(r);try{$b(Ue(),{recursive:!0}),hf(e,"")}catch{return()=>{}}let t=process.stdout.write.bind(process.stdout),s=process.stderr.write.bind(process.stderr),n=0,i=!1,o=a=>{if(!i)try{let c=typeof a=="string"?Buffer.from(a,"utf8"):Buffer.from(a);if(Mb(e,c),n+=c.length,n>2*mf){let l=bf(e),f=l.subarray(Math.max(0,l.length-mf));hf(e,f),n=f.length}}catch{i=!0}};return process.stdout.write=((a,...c)=>(o(a),t(a,...c))),process.stderr.write=((a,...c)=>(o(a),s(a,...c))),()=>{process.stdout.write=t,process.stderr.write=s}}function wt(r,e=0){try{let t=bf(Er(r)),s=e>=0&&e<=t.length?e:0;return{text:t.subarray(s).toString("utf8"),offset:t.length}}catch{return{text:"",offset:0}}}function Bb(r){try{return process.kill(r,0),!0}catch(e){return e.code==="EPERM"}}async function rn(r){await Lb(Ue(),{recursive:!0}),await yf(Bo(r.pid),JSON.stringify(r))}async function wf(r,e){let t=Bo(r);try{let s=JSON.parse(await gf(t,"utf8"));if(s.denied===e)return;s.denied=e,await yf(t,JSON.stringify(s))}catch{}}async function Ar(r){await xr(Bo(r)).catch(()=>{}),await xr(Er(r)).catch(()=>{})}async function j(r){let e;try{e=await _b(Ue())}catch{return[]}let t=[];return await Promise.all(e.map(async n=>{if(!n.endsWith(".json"))return;let i=ne.join(Ue(),n),o;try{o=JSON.parse(await gf(i,"utf8"))}catch{await xr(i).catch(()=>{});return}o&&typeof o.pid=="number"&&Bb(o.pid)?t.push(o):(await xr(i).catch(()=>{}),o?.pid&&await xr(Er(o.pid)).catch(()=>{}))})),(r?t.filter(n=>n.agent==null&&Xu(n.file,r)):t).sort((n,i)=>n.startedAt-i.startedAt)}async function vt(r){try{process.kill(r,"SIGTERM")}catch{}await Ar(r)}function Fb(){return ne.join(ne.dirname(Db(import.meta.url)),"index.js")}function jb(r,e={}){return{command:process.execPath,args:[Fb(),...e.trust?["--trust"]:[],r,...e.open===!1?["--no-open"]:[]]}}async function sn(r,e={}){let t=e.cwd??process.cwd(),s=ne.resolve(t,r),n=(await j()).find(l=>l.file===s);if(n)return n;let{command:i,args:o}=jb(r,e);(process.platform==="win32"?pf("cmd",["/c","start","","/b",i,...o],{cwd:t,stdio:"ignore",windowsHide:!0}):pf(i,o,{cwd:t,detached:!0,stdio:"ignore"})).unref();let c=Date.now()+2e4;for(;Date.now()<c;){await qb(150);let l=(await j()).find(f=>f.file===s);if(l)return l}throw new Error(`Launched ${ne.basename(r)} but it did not register within 20s.`)}var mf,qb,We=N(()=>{vr();mf=1e6;qb=r=>new Promise(e=>setTimeout(e,r))});function yn(r){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(r),t=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return t?t[1].replace(/^["']|["']$/g,""):void 0}function Qo(r){return(yn(r)??"bulb").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"bulb"}var Xo=N(()=>{});import{readdirSync as pw,readFileSync as hw,statSync as mw}from"fs";import{join as Yf,basename as gw}from"path";function Hf(r,e,t){if(e>8)return t;let s;try{s=pw(r,{withFileTypes:!0})}catch{return t}for(let n of s)if(n.isDirectory()){if(n.name.startsWith(".")||n.name==="node_modules")continue;Hf(Yf(r,n.name),e+1,t)}else n.isFile()&&n.name.endsWith(".bulb.md")&&t.push(Yf(r,n.name));return t}function Zo(r){return Hf(r,0,[]).map(e=>{let t=0;try{t=mw(e).mtimeMs}catch{}let s;try{s=yn(hw(e,"utf8").slice(0,1024))}catch{}return{path:e,name:s??gw(e).replace(/\.bulb\.md$/,""),mtime:t}})}var Gf=N(()=>{Xo()});import{readFile as yw}from"fs/promises";async function ea(r){try{let e=Ir(await yw(r,"utf-8"));return e?bt(Rs(e)):void 0}catch{return}}var zf=N(()=>{go();en()});import{spawn as bw}from"child_process";import{basename as ww}from"path";function vw(){return process.env.TYPEBULB_EDITOR||"code"}function kw(r,e,t){return t==null?[e]:Sw.test(ww(r))?["-g",`${e}:${t}`]:[`+${t}`,e]}function xw(r,e){let t=vw();return{command:t,args:kw(t,r,e)}}function ta(r,e){let{command:t,args:s}=xw(r,e),n=bw(t,s,{shell:!0,detached:!0,stdio:"ignore"});n.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),n.unref()}var Sw,Qf=N(()=>{Sw=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});var Xf=N(()=>{We();Gf();zf();Xo();Qf();Sr()});var bn,Zf=N(()=>{bn=class{#e=new Map;accept(e,t){return this.#e.get(e)===t?!1:(this.#e.set(e,t),!0)}}});var bd={};_d(bd,{attach:()=>zw,blockToMarkdown:()=>aa,breakout:()=>Xw,capText:()=>Or,info:()=>Jw,isHiddenTurn:()=>ca,launchBulb:()=>rv,listBreakouts:()=>Zw,listBulbFiles:()=>tv,listSessions:()=>Gw,logEmbedError:()=>Ww,openFile:()=>Qw,poll:()=>Kw,predictTrustOf:()=>sv,readBulbLog:()=>iv,setBulbTrust:()=>nv,stopBreakout:()=>ev});import{existsSync as Et,openSync as sd,readSync as nd,closeSync as id,statSync as ze,readdirSync as na,watchFile as Ew,unwatchFile as ed,mkdirSync as od,writeFileSync as ad,readFileSync as ia,unlinkSync as Aw,rmSync as Tw}from"fs";import{join as B}from"path";import{homedir as Pw}from"os";function cd(r){return r?.message??String(r)}function Ow(r){return r.replace(/[^a-zA-Z0-9]/g,"-")}function ld(r){let e=oa(r);if(!Et(e))return[];let t;try{t=na(e)}catch{return[]}let s=[];for(let n of t){if(!n.endsWith(".jsonl"))continue;let i=B(e,n);try{let o=ze(i);o.isFile()&&s.push({sessionId:n.slice(0,-6),file:i,mtime:o.mtimeMs})}catch{}}return s}function vn(r){return B(r,Rw)}function fd(r,e){return B(vn(r),`${e}.lock`)}function _w(r,e){try{let t=fd(r,e);if(Date.now()-ze(t).mtimeMs>=ud)return!1;try{if(parseInt(ia(t,"utf8").trim(),10)===process.pid)return!1}catch{}return!0}catch{return!1}}function dd(r,e){if(e)try{od(vn(r),{recursive:!0}),ad(fd(r,e),String(process.pid))}catch(t){console.error("[lock] claim failed:",cd(t))}}function Lw(r){try{Tw(B(r,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function $w(r){let e=vn(r);if(!Et(e))return;let t;try{t=na(e)}catch{return}let s=Date.now();for(let n of t){if(!n.endsWith(".lock"))continue;let i=B(e,n);try{let o=ze(i);s-o.mtimeMs>Iw&&Aw(i)}catch{}}}function aa(r){let e=r?.type==="image"?r.source:void 0;return e?.type==="base64"&&e.data?``:""}function Or(r){return r.length>ra?r.slice(0,ra)+`
|
|
150
|
+
\u2026[${r.length-ra} more characters truncated]`:r}function sa(r){return typeof r=="string"?Or(r):Array.isArray(r)?r.map(e=>{if(typeof e=="string")return Or(e);let t=e;return typeof t?.text=="string"?Or(t.text):t?.content!=null?sa(t.content):aa(t)}).join(`
|
|
151
|
+
`):r==null?"":Or(JSON.stringify(r))}function pd(r){try{return ze(r),!1}catch(e){return e.code==="ENOENT"}}function hd(){let r=W;if(r.file&&!pd(r.file)){dd(r.cwd,r.sessionId);return}let e=Mw(r);e&&md(e)}function Mw(r){if(!r.everAttached)return Dw(r.cwd)??Bw(r.cwd,()=>!0)}function Dw(r){let e=vn(r);if(!Et(e))return;let t;try{t=na(e)}catch{return}let s;for(let i of t)if(i.endsWith(".lock"))try{let o=ze(B(e,i));if(Date.now()-o.mtimeMs>=ud||parseInt(ia(B(e,i),"utf8").trim(),10)!==process.pid)continue;(!s||o.mtimeMs>s.mtime)&&(s={sessionId:i.slice(0,-5),mtime:o.mtimeMs})}catch{}if(!s)return;let n=B(oa(r),`${s.sessionId}.jsonl`);if(!pd(n))return{sessionId:s.sessionId,file:n,mtime:s.mtime}}function Bw(r,e){return ld(r).sort((t,s)=>s.mtime-t.mtime).find(t=>!_w(r,t.sessionId)&&e(t))}function md(r){let e=W;if(e.file)try{ed(e.file)}catch{}e.file=r.file,e.sessionId=r.sessionId,e.everAttached=!0,e.partial="",e.offset=0,e.latest={in:0,out:0,cached:0,cacheCreate:0},e.entries=new Map,e.chainLastUuid=void 0,e.buffer.push({type:"cleared"}),e.buffer.push({type:"session",sessionId:r.sessionId}),dd(e.cwd,r.sessionId),td();try{ed(r.file)}catch{}Ew(r.file,{interval:200},()=>td())}function td(){let r=W;if(!r.file)return;let e;try{e=ze(r.file).size}catch{return}if(e<=r.offset)return;let t;try{t=sd(r.file,"r")}catch{return}try{let c=e-r.offset,l=Buffer.alloc(c),f=0;for(;f<c;){let u=nd(t,l,f,c-f,r.offset+f);if(!u)break;f+=u}r.offset+=f,r.partial+=l.subarray(0,f).toString("utf8")}finally{id(t)}let s,n;for(;(n=r.partial.indexOf(`
|
|
152
|
+
`))>=0;){let c=r.partial.slice(0,n);if(r.partial=r.partial.slice(n+1),!c.trim())continue;let l;try{l=JSON.parse(c)}catch{continue}l&&l.uuid&&(r.entries.set(l.uuid,l),l.isSidechain||(s=l.uuid))}if(!s)return;let i=[],o=r.entries.get(s),a=!1;for(;o;){if(i.push(o),o.uuid===r.chainLastUuid){a=!0;break}o=o.parentUuid?r.entries.get(o.parentUuid):void 0}if(a)for(let c=i.length-2;c>=0;c--)rd(i[c]);else{r.chainLastUuid!==void 0&&(r.buffer.push({type:"cleared"}),r.buffer.push({type:"session",sessionId:r.sessionId}),r.latest={in:0,out:0,cached:0,cacheCreate:0});for(let c=i.length-1;c>=0;c--)rd(i[c])}r.chainLastUuid=s}function gd(r){let e=r.trim();return!!e&&qw.some(t=>t.test(e))}function jw(r){return r.replace(Fw,"")}function wn(r){let e=jw(r).trim();return e&&!gd(e)?e:""}function yd(r){return r?.type==="text"&&typeof r.text=="string"?wn(r.text):""}function ca(r){return!!r.isSidechain||!!r.isMeta}function rd(r){try{Uw(r)}catch(e){console.error("[claude-bulb] skipped malformed entry:",cd(e))}}function Uw(r){if(ca(r))return;let e=W;if(r.type==="user"){let t=r.message?.content;if(typeof t=="string"){let s=wn(t);s&&e.buffer.push({type:"user",text:s})}else if(Array.isArray(t))for(let s of t)if(s?.type==="tool_result")e.buffer.push({type:"tool_result",id:s.tool_use_id??"",content:sa(s.content),isError:!!s.is_error});else{let n=yd(s)||aa(s);n&&e.buffer.push({type:"user",text:n})}}else if(r.type==="attachment"&&r.attachment?.type==="queued_command"){let t=wn(sa(r.attachment.prompt));t&&e.buffer.push({type:"user",text:t})}else if(r.type==="assistant"){let t=r.message?.content,s=Array.isArray(t)?t:[],n=s.filter(c=>c.type==="text").map(c=>c.text??"").filter(c=>!gd(c)).join(""),i=s.filter(c=>c.type==="thinking").map(c=>c.thinking??"").join(`
|
|
153
|
+
`),o=s.filter(c=>c.type==="tool_use").map(c=>({id:c.id??"",name:c.name??"",input:c.input??{}}));if(n||i||o.length){let c=Date.parse(r.timestamp??""),l=!isNaN(c)&&c>=e.sessionStartMs;e.buffer.push({type:"assistant",text:n,thinking:i,tools:o,live:l})}let a=r.message?.usage??r.usage;a&&(e.latest={in:a.input_tokens??0,out:a.output_tokens??0,cached:a.cache_read_input_tokens??0,cacheCreate:a.cache_creation_input_tokens??0},e.buffer.push({type:"usage",...e.latest}))}}async function Jw(){return{cwd:W.cwd,pid:process.pid}}async function Kw(r){let e=W;return hd(),{events:e.buffer.slice(r),cursor:e.buffer.length,working:Yw(e)}}async function Ww(r,e){Vw.accept(r,e)&&console.log(e)}function Yw(r){let e;for(let i of r.entries.values())(i.type==="user"||i.type==="assistant")&&(e=i);if(!e)return!1;if(e.type==="user")return!0;let s=(Array.isArray(e.message?.content)?e.message.content:[]).filter(i=>i.type==="tool_use").map(i=>i.id);if(s.length===0)return!1;let n=new Set;for(let i of r.entries.values()){let o=i.message?.content;if(Array.isArray(o))for(let a of o)a.type==="tool_result"&&a.tool_use_id&&n.add(a.tool_use_id)}return s.some(i=>i&&!n.has(i))}function Hw(r){let e;try{e=sd(r,"r")}catch{return""}try{let s=65536;try{s=ze(r).size}catch{}let n=(l,f)=>{if(f<=0)return"";let u=Buffer.alloc(f),d=nd(e,u,0,f,l);return u.subarray(0,d).toString("utf8")},i=(l,f,u)=>{let d="";for(let p of l.split(`
|
|
154
|
+
`)){if(!p.includes(`"${f}"`))continue;let g;try{g=JSON.parse(p)}catch{continue}let h=g?.[u];g?.type===f&&typeof h=="string"&&h&&(d=h)}return d},o=n(0,Math.min(65536,s)),a=s>65536?n(s-65536,65536):"",c=i(a,"custom-title","customTitle")||i(o,"custom-title","customTitle")||i(a,"ai-title","aiTitle")||i(o,"ai-title","aiTitle");if(c)return c.replace(/\s+/g," ").trim().slice(0,200);for(let l of o.split(`
|
|
155
|
+
`)){if(!l.trim())continue;let f;try{f=JSON.parse(l)}catch{continue}if(!f||ca(f)||f.type!=="user")continue;let u=f.message?.content,d="";typeof u=="string"?d=wn(u):Array.isArray(u)&&(d=u.map(yd).filter(Boolean).join(" "));let p=d.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{id(e)}}async function Gw(){return ld(W.cwd).sort((r,e)=>e.mtime-r.mtime).map(({sessionId:r,file:e,mtime:t})=>({sessionId:r,mtime:t,preview:Hw(e)}))}async function zw(r){let e=W,t=B(oa(e.cwd),`${r}.jsonl`);return Et(t)?t===e.file?{ok:!0}:(md({sessionId:r,file:t}),{ok:!0}):{ok:!1,error:"session not found"}}async function Qw(r,e){return ta(r,e),{ok:!0}}async function Xw(r){let e=W.cwd,t=B(e,"typebulbs");od(t,{recursive:!0});let s=Qo(r),n=`${s}.bulb.md`;for(let c=2;Et(B(t,n))&&ia(B(t,n),"utf8")!==r;c++)n=`${s}-${c}.bulb.md`;let i=B(t,n);Et(i)||ad(i,r);let o=B("typebulbs",n),a=await sn(o,{cwd:e,open:!0});return{ok:!0,file:o,pid:a.pid,url:a.url}}async function Zw(){return j(W.cwd)}async function ev(r){return await vt(r),{ok:!0}}async function tv(){return Zo(W.cwd).map(r=>({...r,trusted:Je(r.path)}))}async function rv(r,e){let t=W.cwd;e!=null&&mt(r,e);let s=await sn(r,{cwd:t,open:!0,trust:e});return{ok:!0,file:s.file,pid:s.pid,url:s.url,trust:!!s.trust}}async function sv(r){return{cap:await ea(r)}}async function nv(r,e){return mt(r,e),{ok:!0}}async function iv(r,e){return wt(r,e)}var Nw,Cw,oa,Rw,ud,Iw,ra,W,qw,Fw,Vw,wd=N(()=>{Xf();Zf();Nw=".typebulb",Cw=B(Pw(),".claude","projects"),oa=r=>B(Cw,Ow(r));Rw=`${Nw}/locks`,ud=5e3,Iw=6e4;ra=5e4;W={cwd:process.cwd(),sessionId:"",sessionStartMs:Date.now(),buffer:[],partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},everAttached:!1,entries:new Map};qw=[/\[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];Fw=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;Vw=new bn;Lw(W.cwd);$w(W.cwd);hd()});import*as Pd from"fs/promises";import*as ge from"path";import*as ua from"fs/promises";import{existsSync as Qe,readFileSync as Md}from"fs";import*as L from"path";import{pathToFileURL as Dd}from"url";import{resolve as En}from"resolve.exports";import{init as fa,parse as da}from"es-module-lexer";function pa(r,e){let t=L.join(r,"package.json");try{return JSON.parse(Md(t,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${t}`)}}var xn=["browser","import","default"],la=["node","import","default"];function ha(r){let e=r.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${r}')`);let t=r.slice(0,e).trim(),s=r.slice(e+1).trim();if(!t)throw new Error(`--replace missing package name (got '${r}')`);if(!s)throw new Error(`--replace missing path for '${t}'`);if(t.startsWith("@"))throw new Error(`--replace does not support scoped names yet; '${t}' is scoped`);return{name:t,dir:L.resolve(s)}}async function ma(r){let{name:e,dir:t}=r;if(!Qe(t))throw new Error(`--replace path for '${e}' does not exist: ${t}`);let s=pa(t,e),n=Bd(s,e),i=L.resolve(t,n);if(!Qe(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=L.dirname(i),a=`/local/${e}/${L.basename(i)}`,c=qd(s,t);return await Fd(e,i,o),{name:e,dir:t,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:c}}function Bd(r,e){if(r.exports!==void 0){let s;try{s=En(r,".",{browser:!0,conditions:xn})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${xn.join(", ")}): ${i instanceof Error?i.message:i}`)}let n=An(s);if(!n)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${xn.join(", ")}); too complex to override.`);return n}let t=r.module??r.main;if(!t)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return t}function qd(r,e){if(r.exports!==void 0)try{let s=En(r,".",{conditions:["types"]}),n=An(s);if(n){let i=L.resolve(e,n);if(Qe(i))return i}}catch{}let t=r.types??r.typings;if(t){let s=L.resolve(e,t);if(Qe(s))return s}}function An(r){if(typeof r=="string")return r;if(Array.isArray(r))return r.find(e=>typeof e=="string")}async function Fd(r,e,t){await fa;let s=L.normalize(t),n=new Set,i=[e];for(;i.length;){let o=i.shift();if(n.has(o))continue;n.add(o);let a;try{a=await ua.readFile(o,"utf8")}catch{continue}let c,l;try{[c,,,l]=da(a,o)}catch{continue}if(o===e&&!l)throw new Error(`override package '${r}' 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 c){if(f.d===-2)continue;let u=f.n;if(u&&!u.startsWith("node:")){if(u.startsWith("./")||u.startsWith("../")||u.startsWith("/")){let d=jd(o,u,s);d&&!n.has(d)&&i.push(d);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${r} externalizes '${u}'`)}}}}function jd(r,e,t){let s=e.replace(/[?#].*$/,""),n=L.resolve(L.dirname(r),s),i=[n,n+".js",n+".mjs",L.join(n,"index.js"),L.join(n,"index.mjs")];for(let o of i)if(L.normalize(o).startsWith(t)&&Qe(o))return o}function Ud(r,e,t){let s=pa(r,e),n;if(s.exports!==void 0)try{n=An(En(s,t,{conditions:la}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${t}' (conditions: ${la.join(", ")}): ${o instanceof Error?o.message:o}`)}else t==="."&&(n=s.main??s.module);if(!n)throw new Error(`--replace package '${e}' has no node export for '${t}'.`);let i=L.resolve(r,n);if(!Qe(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return Dd(i).href}async function ga(r,e){await fa;let t;try{[t]=da(r)}catch{return r}let s="",n=0;for(let i of t){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),c=Ud(e.dir,e.name,a);s+=r.slice(n,i.s)+c,n=i.e}return s+r.slice(n)}function ya(r){let e={subcommand:"run",file:"",port:3e3,watch:!0,open:!0,server:!1,trust:!1,noTrust:!1,follow:!1,help:!1,version:!1,callArgs:[],hasArgsFlag:!1},t=["call","check","predict","logs","stop","trust","untrust","skill","models"],s=r[0];if(s==="agent"||s?.startsWith("agent:")){e.subcommand="agent";let i=s.indexOf(":");if(i!==-1){let o=s.slice(i+1);o&&(e.agentTarget=o)}r=r.slice(1)}else s&&t.includes(s)&&(e.subcommand=s,r=r.slice(1));let n=[];for(let i=0;i<r.length;i++){let o=r[i];if(o==="--help"||o==="-h")e.help=!0;else if(o==="--version"||o==="-V")e.version=!0;else if(o==="--no-watch")e.watch=!1;else if(o==="--no-open")e.open=!1;else if(o==="--server")e.server=!0;else if(o==="--trust")e.trust=!0;else if(o==="--no-trust")e.noTrust=!0;else if(o==="--mode"){let a=r[++i];(!a||a.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),e.mode=a}else if(o==="--follow"||o==="-f")e.follow=!0;else if(o==="--bulbs")e.stopScope="bulbs";else if(o==="--agent")e.stopScope="agent";else if(o==="--global")e.stopScope="global";else if(o==="--lines"||o==="-n"){let a=parseInt(r[++i],10);(isNaN(a)||a<0)&&(console.error(`Invalid --lines value: ${r[i]}`),process.exit(1)),e.lines=a}else if(o==="--port"||o==="-p"){let a=r[++i],c=parseInt(a,10);isNaN(c)&&(console.error(`Invalid port: ${a}`),process.exit(1)),e.port=c}else if(o==="--replace"||o.startsWith("--replace=")){let a=o.startsWith("--replace=")?o.slice(10):r[++i]??"";try{let c=ha(a);if(e.local)throw new Error(`--replace can only be used once (got '${e.local.name}' and '${c.name}')`);e.local=c}catch(c){console.error(c instanceof Error?c.message:String(c)),process.exit(1)}}else if(o==="--args"||o.startsWith("--args=")){e.hasArgsFlag=!0;let a=o.startsWith("--args=")?o.slice(7):r[++i];a===void 0&&(console.error("Missing value for --args (a JSON array, or - to read it from stdin)"),process.exit(1)),e.argsJson=a}else o.startsWith("-")||(e.subcommand==="call"?n.push(o):e.file=o)}return e.subcommand==="call"&&(n.length<2&&(console.error("Usage: typebulb call <file> <fn> [arg\u2026]"),process.exit(1)),e.file=n[0],e.fn=n[1],e.callArgs=n.slice(2)),e}function ba(){console.log(`
|
|
156
156
|
typebulb - Local bulb runner for Typebulb
|
|
157
157
|
|
|
158
158
|
Usage:
|
|
159
159
|
typebulb [file.bulb.md] Run a bulb (defaults to .bulb.md in cwd)
|
|
160
160
|
typebulb agent Start here \u2014 tells the agent how to show a bulb inline
|
|
161
|
-
or build one locally; prints the
|
|
161
|
+
or build one locally; prints the mirror URL when one is
|
|
162
162
|
up. Always exits 0 (it's a status report, not a check).
|
|
163
|
-
typebulb agent:claude Open the agent
|
|
163
|
+
typebulb agent:claude Open the agent mirror (a browser view over a Claude
|
|
164
164
|
Code session; 'agent:<name>' selects which agent).
|
|
165
165
|
typebulb skill Print this README as an Agent Skill (stdout), for the
|
|
166
166
|
agent to read and copy into its own skills folder.
|
|
167
|
+
typebulb call <file> <fn> [\u2026] Invoke one server.ts export headlessly: prints
|
|
168
|
+
its return as JSON to stdout, logs/errors to
|
|
169
|
+
stderr. Gated by trust like --server. Args after
|
|
170
|
+
<fn> are JSON-or-string; --args '<json-array>'
|
|
171
|
+
(or --args - for stdin) is the escape hatch.
|
|
167
172
|
typebulb check [file.bulb.md] Type-check a bulb without running it
|
|
168
173
|
typebulb predict [file] Report the capability a bulb probably needs
|
|
169
174
|
(fs / AI / server.ts) without running it.
|
|
@@ -176,8 +181,8 @@ Usage:
|
|
|
176
181
|
typebulb stop [file|pid] Stop a running bulb server (no arg: list this
|
|
177
182
|
project's running servers; a pid/path stops any).
|
|
178
183
|
Batch flags: --bulbs (this project's bulbs, the
|
|
179
|
-
|
|
180
|
-
--global (every bulb +
|
|
184
|
+
mirror survives), --agent (this project's mirror),
|
|
185
|
+
--global (every bulb + mirror, all projects).
|
|
181
186
|
typebulb trust [file] Remember a bulb as Trusted, so a later run grants
|
|
182
187
|
fs/AI/server.ts without --trust (no arg: list the
|
|
183
188
|
remembered-trusted bulbs).
|
|
@@ -201,6 +206,9 @@ Options:
|
|
|
201
206
|
of .env / .env.local. Free-form name; loads no mode
|
|
202
207
|
file by default.
|
|
203
208
|
--server Run server.ts only, no web server (needs --trust)
|
|
209
|
+
--args <json-array> For 'call': the whole argument list as one JSON
|
|
210
|
+
array (strict). '--args -' reads it from stdin,
|
|
211
|
+
sidestepping shell quoting.
|
|
204
212
|
--replace <name>=<path> Replace a declared dependency with a local built
|
|
205
213
|
package folder instead of a CDN (dev only).
|
|
206
214
|
Applies to both run and check. Watched for
|
|
@@ -243,7 +251,7 @@ Examples:
|
|
|
243
251
|
typebulb my-editor.bulb.md
|
|
244
252
|
typebulb --no-watch --port 8080 my-editor.bulb.md
|
|
245
253
|
typebulb .
|
|
246
|
-
`)}ho();import*as Ce from"fs/promises";import*as Gs from"path";import{pathToFileURL as rb}from"url";import{transform as Sy}from"sucrase";function mo(r,e={}){let t=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:s}=Sy(r,{transforms:t,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:s}}catch(s){return{code:"",error:String(s)}}}var nr="https://esm.sh",ir="https://cdn.jsdelivr.net/npm/",go="https://data.jsdelivr.com/v1/package/npm/";function ku(r){let e=(r||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var A=class r{constructor(e,t,s){let n=typeof e=="string"?r.parse(e):e;this.name=n.name,this.version=ct(t??n.version),this.subpath=ct(s??n.subpath)}static parse(e){let t=ku(e||"");if(!t.length)return new r({name:""});if(t[0].startsWith("@")){let n=t[0],[i,o]=xu(t[1]??""),a=ct(t.slice(2).join("/"));return new r({name:`${n}/${i}`,version:o,subpath:a})}else{let[n,i]=xu(t[0]),o=ct(t.slice(1).join("/"));return new r({name:n,version:i,subpath:o})}}static fromUrl(e){try{let t=new URL(e),s=new URL(nr).host,n=new URL(ir).host;if(t.host===s){let i=ku(t.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return r.parse(o)}if(t.host===n){let i=t.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return r.parse(o)}return}catch{return}}static versionFromUrl(e){return r.fromUrl(e)?.version}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 r.parse(e).name}withVersion(e){return new r({name:this.name,version:ct(e),subpath:this.subpath})}withPreferredVersion(e,t){let s=e||t;return s?this.withVersion(s):this}static isBare(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;let t=e.toLowerCase();return!t.startsWith("http://")&&!t.startsWith("https://")}},ct=r=>r&&r.length?r:void 0,xu=r=>{let e=r.indexOf("@");return e<0?[r,void 0]:[r.slice(0,e),ct(r.slice(e+1))]};async function W(r){try{return await r()}catch{return}}var or=class{constructor(e,t){this.cache=e,this.http=t,this.esmHost=nr,this.jsDelivrBase=ir,this.jsDelivrMeta=go,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}normalizeRelative(e){let t=e||"";return t.startsWith("./")?t.slice(2):t.replace(/^\/+/,"")}ensureLeadingDotSlash(e){return e.startsWith("./")?e:`./${e}`}baseDir(e){let t=typeof e=="string"?new A(e):e;return`${this.jsDelivrBase}${t.name}${t.version?`@${t.version}`:""}/`}file(e,t){return new URL(this.normalizeRelative(t),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,t={}){let{target:s="es2022",bundle:n=!1,external:i}=t,o=new URLSearchParams({target:s});return n&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${this.esmHost}/${e}?${o.toString()}`}async pinEsmUrl(e,t="es2022"){let s=this.buildEsmUrl(e,{target:t}),n=await W(()=>this.http.head(s));return n?.ok?n.url||s:void 0}async resolveExactVersion(e){let t=Date.now(),s=this.pinCache.get(e);if(s&&t-s.ts<this.pinMs)return s.value;let n=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${this.esmHost}/${e}`]);return this.pinCache.set(e,{value:n,ts:t}),n}async tryResolveFromUrls(e){for(let t of e){let s=await W(()=>this.http.head(t)),n=this.parseVersionFromUrl(s?.url||t);if(n)return n}}async fetchVersionsIndex(e){if(await this.cache.isNegative(e))return;let t=await this.cache.getIndex(e);if(t&&Date.now()-t.updatedAt<this.versionsIndexMs)return{versions:t.versions,distTags:t.distTags};let s=await W(()=>this.http.getJson(`${this.jsDelivrMeta}${encodeURIComponent(e)}`));if(!s?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let n=s.distTags&&Object.keys(s.distTags).length?s.distTags:void 0;return await this.cache.setIndex(e,s.versions,n),s}parseVersionFromUrl(e){let t=A.fromUrl(e)?.version;return t&&/\d+\.\d+\.\d+/.test(t)?t:void 0}async fetchPackageMeta(e,t){let s=await this.cache.getMeta(e,t);if(s&&Date.now()-s.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:u,peerDependenciesMeta:d}=s;return{name:e,version:t,dependencies:f,peerDependencies:u,peerDependenciesMeta:d}}let n=this.packageJson(new A(`${e}@${t}`)),i=await W(()=>this.http.getJson(n));if(!i)return;let o=f=>f&&Object.keys(f).length?f:void 0,a=o(i.dependencies),c=o(i.peerDependencies),l=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,t,a,c,l),{name:e,version:t,dependencies:a,peerDependencies:c,peerDependenciesMeta:l}}};var Eu=r=>r.startsWith("@types/"),ar=r=>Object.keys(r?.peerDependencies||{}).filter(e=>!Eu(e)),yo=r=>Object.keys(r?.dependencies||{}).filter(e=>!Eu(e)),ky=r=>ar(r).filter(e=>!r?.peerDependenciesMeta?.[e]?.optional),cr=class{constructor(e){this.cdn=e}async resolve(e,t){let s=await this.fetchMeta(e),{allRoots:n,autoAddedPeers:i}=await this.expandWithPeers(s,t),o=this.computeFlags(n);return{allRoots:n,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:t,version:s})=>({name:t,version:s,meta:await this.cdn.fetchPackageMeta(t,s)})))}async expandWithPeers(e,t){let s=new Map(e.map(i=>[i.name,i])),n=[];for(let i of e)for(let o of ky(i.meta))!s.has(o)&&!n.some(a=>a.name===o)&&n.push({name:o,requiredBy:i.name});for(let{name:i,requiredBy:o}of n)try{let a=await t(i),c=await this.cdn.fetchPackageMeta(i,a);s.set(i,{name:i,version:a,meta:c})}catch(a){console.warn(`[typebulb] Failed to resolve peer "${i}" for "${o}":`,a)}return{allRoots:[...s.values()],autoAddedPeers:n.filter(i=>s.has(i.name))}}computeFlags(e){let t=new Set(e.flatMap(i=>ar(i.meta))),s=new Map;for(let i of e)for(let o of yo(i.meta))s.set(o,(s.get(o)||0)+1);let n=new Set([...s.entries()].filter(([,i])=>i>=2).map(([i])=>i));return new Map(e.map(i=>[i.name,{isPeerRoot:t.has(i.name),hasPeers:ar(i.meta).length>0,isSharedDep:n.has(i.name)}]))}};var lr=class{constructor(e,t,s){this.cache=e,this.cdn=t,this.semver=s}selectVersionFromIndex(e,t,s){return this.semver.selectBestVersion(e,{range:t,distTags:s})}async learnExactVersion(e){let t=await W(()=>this.cdn.fetchVersionsIndex(e));if(t?.versions?.length){let s=this.semver.selectBestVersion(t.versions,{distTags:t.distTags});if(s)return s}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,t){if(!t)return this.learnExactVersion(e);let s=await this.cache.getPinnedExact(e,t);if(s){if(this.semver.isExactVersion(s))return s;console.debug("[typebulb] cached version for",e,"is not exact (",s,"); re-resolving from registry")}let n=await W(()=>this.cdn.fetchVersionsIndex(e));if(n?.versions?.length){let o=this.selectVersionFromIndex(n.versions,t,n.distTags);if(o){if(this.semver.isExactVersion(o))return await this.cache.setPinnedExact(e,t,o),o}else{console.debug("[typebulb] refreshing version cache for",e,"(",t,"not in cached set \u2014 likely a new release)"),await this.cache.invalidateVersionsCache(e);let a=await W(()=>this.cdn.fetchVersionsIndex(e));if(a?.versions?.length){let c=this.selectVersionFromIndex(a.versions,t,a.distTags);if(c&&this.semver.isExactVersion(c))return await this.cache.setPinnedExact(e,t,c),c}}}let i=await this.cdn.resolveExactVersion(`${e}@${t}`);if(i&&this.semver.isExactVersion(i))return await this.cache.setPinnedExact(e,t,i),i}async effectivePackage(e,t){let s=new A(e),n=s.root(),i=t[n],o=i?await W(()=>this.cache.getPinnedExact(n,i))??await W(()=>this.resolveExactForRoot(n,i)):void 0;return{effectivePackage:o?s.withVersion(o).format():e,root:n,range:i,pinned:o}}};import{init as xy,parse as Ey}from"es-module-lexer";var lt=class r{constructor(e,t,s,n){this.version=e,this.cdn=t,this.peer=s,this.cache=n}extractImportsSync(e){let t=new Set;for(let s of r.importPatterns){s.lastIndex=0;for(let n of e.matchAll(s))A.isBare(n[1])&&t.add(n[1])}return Array.from(t)}async extractImports(e){let t=new Set,s=n=>{A.isBare(n)&&t.add(n)};try{await xy;let[n]=Ey(e);n.forEach(i=>s(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(t)}async buildImportMap(e,t,s){let n=(await this.extractImports(e)).filter(u=>!s?.has(A.rootOf(u))),i=[...new Set(n.map(A.rootOf))],o=await Promise.all(i.map(async u=>({name:u,version:await this.resolveVersion(u,t)}))),{allRoots:a,flags:c,autoAddedPeers:l}=await this.peer.resolve(o,u=>this.resolveVersion(u,t)),f=this.buildEntries([...n,...l.map(u=>u.name)],a,c,t);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,u])=>u)}}async resolveVersion(e,t){let s=t[e],n=s?`${e}@${s}`:e,i=await this.version.resolveExactForRoot(e,s);if(!i){let o=await W(()=>this.cdn.pinEsmUrl(n));if(!o)throw new Error(`Cannot resolve ${n}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);i=A.versionFromUrl(o),i&&s&&await W(()=>this.cache.setPinnedExact(e,s,i))}if(!i)throw new Error(`Cannot resolve ${n}: no concrete version found.`);return i}buildEntries(e,t,s,n){let i=new Map(t.map(g=>[g.name,g])),o=g=>{let p=i.get(A.rootOf(g));return new A(g).withPreferredVersion(p.version,n[p.name]).format()},a=new Set([...s.entries()].filter(([,g])=>g.isPeerRoot||g.isSharedDep).map(([g])=>g)),c=new Set(e.filter(g=>g!==A.rootOf(g)).map(A.rootOf)),l=[],f=new Set,u=new Set(e.filter(g=>g===A.rootOf(g))),d=new Set;for(let g of e){let p=A.rootOf(g),y=i.get(p),{isPeerRoot:x,hasPeers:k,isSharedDep:E}=s.get(p),m=c.has(p),b=g!==p,T=!(x||E)&&(m||!k),w=this.singletonDepsOf(y,a),O=b&&u.has(p);O&&d.add(p);let D=O?[...w,p]:w.length?w:void 0;l.push([g,this.cdn.buildEsmUrl(o(g),{bundle:T,external:D})]),f.add(g)}let h=new Set([...a,...d]);for(let g of h)i.has(g)&&(f.has(g)||l.push([g,this.cdn.buildEsmUrl(o(g),{})]),l.push([`${g}/`,`${this.cdn.esmHost}/${o(g)}/`]));return l}singletonDepsOf(e,t){return[...new Set([...ar(e.meta),...yo(e.meta)])].filter(s=>t.has(s))}};lt.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g];import{gt as Tu,satisfies as Ty,maxSatisfying as bo,major as Ay,prerelease as Py,rsort as Oy,valid as Ny}from"semver";var Rs=class{cmp(e,t){return e===t?0:Tu(e,t)?1:Tu(t,e)?-1:0}satisfies(e,t){return!e||!e.trim()?!0:!!Ty(t,e,{includePrerelease:!0})}pickMaxSatisfying(e,t){if(!e?.length)return;let s=bo(e,t,{includePrerelease:!0});return s===null?void 0:s}pickLatest(e){return e?.length?Oy(e)[0]:void 0}selectBestVersion(e,t){if(!e?.length)return;let s=t?.range?.trim()||"*",n=t?.preferStable??!0,i=t?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(s,i))return i;if(n){let a=bo(e,s,{includePrerelease:!1});if(a)return a}return bo(e,s,{includePrerelease:!0})??void 0}majorOf(e){return Ay(e)}isPrerelease(e){return Py(e)!==null}isExactVersion(e){return Ny(e)!==null}},qe=new Rs;function Au(r,e){let t=new or(r,e),s=new cr(t),n=new lr(r,t,qe);return{packageService:new lt(n,t,s,r),versionResolver:n,cdnClient:t,peerResolver:s}}import*as Fu from"fs/promises";import*as re from"path";var wo=[{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"}],vo=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];var Pu=`
|
|
254
|
+
`)}go();import*as Ce from"fs/promises";import*as Gs from"path";import{pathToFileURL as ob}from"url";import{transform as Ay}from"sucrase";function yo(r,e={}){let t=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:s}=Ay(r,{transforms:t,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:s}}catch(s){return{code:"",error:String(s)}}}var nr="https://esm.sh",ir="https://cdn.jsdelivr.net/npm/",bo="https://data.jsdelivr.com/v1/package/npm/";function xu(r){let e=(r||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var A=class r{constructor(e,t,s){let n=typeof e=="string"?r.parse(e):e;this.name=n.name,this.version=lt(t??n.version),this.subpath=lt(s??n.subpath)}static parse(e){let t=xu(e||"");if(!t.length)return new r({name:""});if(t[0].startsWith("@")){let n=t[0],[i,o]=Eu(t[1]??""),a=lt(t.slice(2).join("/"));return new r({name:`${n}/${i}`,version:o,subpath:a})}else{let[n,i]=Eu(t[0]),o=lt(t.slice(1).join("/"));return new r({name:n,version:i,subpath:o})}}static fromUrl(e){try{let t=new URL(e),s=new URL(nr).host,n=new URL(ir).host;if(t.host===s){let i=xu(t.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return r.parse(o)}if(t.host===n){let i=t.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return r.parse(o)}return}catch{return}}static versionFromUrl(e){return r.fromUrl(e)?.version}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 r.parse(e).name}withVersion(e){return new r({name:this.name,version:lt(e),subpath:this.subpath})}withPreferredVersion(e,t){let s=e||t;return s?this.withVersion(s):this}static isBare(e){if(!e||e.startsWith(".")||e.startsWith("/"))return!1;let t=e.toLowerCase();return!t.startsWith("http://")&&!t.startsWith("https://")}},lt=r=>r&&r.length?r:void 0,Eu=r=>{let e=r.indexOf("@");return e<0?[r,void 0]:[r.slice(0,e),lt(r.slice(e+1))]};async function V(r){try{return await r()}catch{return}}var or=class{constructor(e,t){this.cache=e,this.http=t,this.esmHost=nr,this.jsDelivrBase=ir,this.jsDelivrMeta=bo,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}normalizeRelative(e){let t=e||"";return t.startsWith("./")?t.slice(2):t.replace(/^\/+/,"")}ensureLeadingDotSlash(e){return e.startsWith("./")?e:`./${e}`}baseDir(e){let t=typeof e=="string"?new A(e):e;return`${this.jsDelivrBase}${t.name}${t.version?`@${t.version}`:""}/`}file(e,t){return new URL(this.normalizeRelative(t),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,t={}){let{target:s="es2022",bundle:n=!1,external:i}=t,o=new URLSearchParams({target:s});return n&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${this.esmHost}/${e}?${o.toString()}`}async pinEsmUrl(e,t="es2022"){let s=this.buildEsmUrl(e,{target:t}),n=await V(()=>this.http.head(s));return n?.ok?n.url||s:void 0}async resolveExactVersion(e){let t=Date.now(),s=this.pinCache.get(e);if(s&&t-s.ts<this.pinMs)return s.value;let n=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${this.esmHost}/${e}`]);return this.pinCache.set(e,{value:n,ts:t}),n}async tryResolveFromUrls(e){for(let t of e){let s=await V(()=>this.http.head(t)),n=this.parseVersionFromUrl(s?.url||t);if(n)return n}}async fetchVersionsIndex(e){if(await this.cache.isNegative(e))return;let t=await this.cache.getIndex(e);if(t&&Date.now()-t.updatedAt<this.versionsIndexMs)return{versions:t.versions,distTags:t.distTags};let s=await V(()=>this.http.getJson(`${this.jsDelivrMeta}${encodeURIComponent(e)}`));if(!s?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let n=s.distTags&&Object.keys(s.distTags).length?s.distTags:void 0;return await this.cache.setIndex(e,s.versions,n),s}parseVersionFromUrl(e){let t=A.fromUrl(e)?.version;return t&&/\d+\.\d+\.\d+/.test(t)?t:void 0}async fetchPackageMeta(e,t){let s=await this.cache.getMeta(e,t);if(s&&Date.now()-s.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:u,peerDependenciesMeta:d}=s;return{name:e,version:t,dependencies:f,peerDependencies:u,peerDependenciesMeta:d}}let n=this.packageJson(new A(`${e}@${t}`)),i=await V(()=>this.http.getJson(n));if(!i)return;let o=f=>f&&Object.keys(f).length?f:void 0,a=o(i.dependencies),c=o(i.peerDependencies),l=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,t,a,c,l),{name:e,version:t,dependencies:a,peerDependencies:c,peerDependenciesMeta:l}}};var Au=r=>r.startsWith("@types/"),ar=r=>Object.keys(r?.peerDependencies||{}).filter(e=>!Au(e)),wo=r=>Object.keys(r?.dependencies||{}).filter(e=>!Au(e)),Ty=r=>ar(r).filter(e=>!r?.peerDependenciesMeta?.[e]?.optional),cr=class{constructor(e){this.cdn=e}async resolve(e,t){let s=await this.fetchMeta(e),{allRoots:n,autoAddedPeers:i}=await this.expandWithPeers(s,t),o=this.computeFlags(n);return{allRoots:n,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:t,version:s})=>({name:t,version:s,meta:await this.cdn.fetchPackageMeta(t,s)})))}async expandWithPeers(e,t){let s=new Map(e.map(i=>[i.name,i])),n=[];for(let i of e)for(let o of Ty(i.meta))!s.has(o)&&!n.some(a=>a.name===o)&&n.push({name:o,requiredBy:i.name});for(let{name:i,requiredBy:o}of n)try{let a=await t(i),c=await this.cdn.fetchPackageMeta(i,a);s.set(i,{name:i,version:a,meta:c})}catch(a){console.warn(`[typebulb] Failed to resolve peer "${i}" for "${o}":`,a)}return{allRoots:[...s.values()],autoAddedPeers:n.filter(i=>s.has(i.name))}}computeFlags(e){let t=new Set(e.flatMap(i=>ar(i.meta))),s=new Map;for(let i of e)for(let o of wo(i.meta))s.set(o,(s.get(o)||0)+1);let n=new Set([...s.entries()].filter(([,i])=>i>=2).map(([i])=>i));return new Map(e.map(i=>[i.name,{isPeerRoot:t.has(i.name),hasPeers:ar(i.meta).length>0,isSharedDep:n.has(i.name)}]))}};var lr=class{constructor(e,t,s){this.cache=e,this.cdn=t,this.semver=s}selectVersionFromIndex(e,t,s){return this.semver.selectBestVersion(e,{range:t,distTags:s})}async learnExactVersion(e){let t=await V(()=>this.cdn.fetchVersionsIndex(e));if(t?.versions?.length){let s=this.semver.selectBestVersion(t.versions,{distTags:t.distTags});if(s)return s}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,t){if(!t)return this.learnExactVersion(e);let s=await this.cache.getPinnedExact(e,t);if(s){if(this.semver.isExactVersion(s))return s;console.debug("[typebulb] cached version for",e,"is not exact (",s,"); re-resolving from registry")}let n=await V(()=>this.cdn.fetchVersionsIndex(e));if(n?.versions?.length){let o=this.selectVersionFromIndex(n.versions,t,n.distTags);if(o){if(this.semver.isExactVersion(o))return await this.cache.setPinnedExact(e,t,o),o}else{console.debug("[typebulb] refreshing version cache for",e,"(",t,"not in cached set \u2014 likely a new release)"),await this.cache.invalidateVersionsCache(e);let a=await V(()=>this.cdn.fetchVersionsIndex(e));if(a?.versions?.length){let c=this.selectVersionFromIndex(a.versions,t,a.distTags);if(c&&this.semver.isExactVersion(c))return await this.cache.setPinnedExact(e,t,c),c}}}let i=await this.cdn.resolveExactVersion(`${e}@${t}`);if(i&&this.semver.isExactVersion(i))return await this.cache.setPinnedExact(e,t,i),i}async effectivePackage(e,t){let s=new A(e),n=s.root(),i=t[n],o=i?await V(()=>this.cache.getPinnedExact(n,i))??await V(()=>this.resolveExactForRoot(n,i)):void 0;return{effectivePackage:o?s.withVersion(o).format():e,root:n,range:i,pinned:o}}};import{init as Py,parse as Oy}from"es-module-lexer";var ut=class r{constructor(e,t,s,n){this.version=e,this.cdn=t,this.peer=s,this.cache=n}extractImportsSync(e){let t=new Set;for(let s of r.importPatterns){s.lastIndex=0;for(let n of e.matchAll(s))A.isBare(n[1])&&t.add(n[1])}return Array.from(t)}async extractImports(e){let t=new Set,s=n=>{A.isBare(n)&&t.add(n)};try{await Py;let[n]=Oy(e);n.forEach(i=>s(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(t)}async buildImportMap(e,t,s){let n=(await this.extractImports(e)).filter(u=>!s?.has(A.rootOf(u))),i=[...new Set(n.map(A.rootOf))],o=await Promise.all(i.map(async u=>({name:u,version:await this.resolveVersion(u,t)}))),{allRoots:a,flags:c,autoAddedPeers:l}=await this.peer.resolve(o,u=>this.resolveVersion(u,t)),f=this.buildEntries([...n,...l.map(u=>u.name)],a,c,t);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,u])=>u)}}async resolveVersion(e,t){let s=t[e],n=s?`${e}@${s}`:e,i=await this.version.resolveExactForRoot(e,s);if(!i){let o=await V(()=>this.cdn.pinEsmUrl(n));if(!o)throw new Error(`Cannot resolve ${n}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);i=A.versionFromUrl(o),i&&s&&await V(()=>this.cache.setPinnedExact(e,s,i))}if(!i)throw new Error(`Cannot resolve ${n}: no concrete version found.`);return i}buildEntries(e,t,s,n){let i=new Map(t.map(g=>[g.name,g])),o=g=>{let h=i.get(A.rootOf(g));return new A(g).withPreferredVersion(h.version,n[h.name]).format()},a=new Set([...s.entries()].filter(([,g])=>g.isPeerRoot||g.isSharedDep).map(([g])=>g)),c=new Set(e.filter(g=>g!==A.rootOf(g)).map(A.rootOf)),l=[],f=new Set,u=new Set(e.filter(g=>g===A.rootOf(g))),d=new Set;for(let g of e){let h=A.rootOf(g),y=i.get(h),{isPeerRoot:k,hasPeers:m,isSharedDep:b}=s.get(h),w=c.has(h),x=g!==h,T=!(k||b)&&(w||!m),S=this.singletonDepsOf(y,a),O=x&&u.has(h);O&&d.add(h);let U=O?[...S,h]:S.length?S:void 0;l.push([g,this.cdn.buildEsmUrl(o(g),{bundle:T,external:U})]),f.add(g)}let p=new Set([...a,...d]);for(let g of p)i.has(g)&&(f.has(g)||l.push([g,this.cdn.buildEsmUrl(o(g),{})]),l.push([`${g}/`,`${this.cdn.esmHost}/${o(g)}/`]));return l}singletonDepsOf(e,t){return[...new Set([...ar(e.meta),...wo(e.meta)])].filter(s=>t.has(s))}};ut.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g];import{gt as Tu,satisfies as Ny,maxSatisfying as vo,major as Cy,prerelease as Ry,rsort as Iy,valid as _y}from"semver";var Is=class{cmp(e,t){return e===t?0:Tu(e,t)?1:Tu(t,e)?-1:0}satisfies(e,t){return!e||!e.trim()?!0:!!Ny(t,e,{includePrerelease:!0})}pickMaxSatisfying(e,t){if(!e?.length)return;let s=vo(e,t,{includePrerelease:!0});return s===null?void 0:s}pickLatest(e){return e?.length?Iy(e)[0]:void 0}selectBestVersion(e,t){if(!e?.length)return;let s=t?.range?.trim()||"*",n=t?.preferStable??!0,i=t?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(s,i))return i;if(n){let a=vo(e,s,{includePrerelease:!1});if(a)return a}return vo(e,s,{includePrerelease:!0})??void 0}majorOf(e){return Cy(e)}isPrerelease(e){return Ry(e)!==null}isExactVersion(e){return _y(e)!==null}},qe=new Is;function Pu(r,e){let t=new or(r,e),s=new cr(t),n=new lr(r,t,qe);return{packageService:new ut(n,t,s,r),versionResolver:n,cdnClient:t,peerResolver:s}}import*as Uu from"fs/promises";import*as re from"path";var So=[{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"}],ko=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];var Ou=`
|
|
247
255
|
/**
|
|
248
256
|
* Get raw data chunk from the Data tab.
|
|
249
257
|
* @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
|
|
@@ -254,7 +262,7 @@ Examples:
|
|
|
254
262
|
* @param index - Chunk index (0-based)
|
|
255
263
|
* @throws If chunk is not valid JSON/JSON-ish
|
|
256
264
|
*/
|
|
257
|
-
json<T = unknown>(index: number): T;`,
|
|
265
|
+
json<T = unknown>(index: number): T;`,Nu=`
|
|
258
266
|
/**
|
|
259
267
|
* Get the insight data produced by the inference layer.
|
|
260
268
|
*
|
|
@@ -263,7 +271,7 @@ Examples:
|
|
|
263
271
|
*
|
|
264
272
|
* @returns The parsed insight JSON, or undefined if no insight is available
|
|
265
273
|
*/
|
|
266
|
-
insight<T = unknown>(): T | undefined;`,
|
|
274
|
+
insight<T = unknown>(): T | undefined;`,Cu=`
|
|
267
275
|
/**
|
|
268
276
|
* General-purpose AI call.
|
|
269
277
|
*
|
|
@@ -280,7 +288,7 @@ Examples:
|
|
|
280
288
|
model?: string;
|
|
281
289
|
/** Enable/disable web search. Default: on for BYOK, always off for free model. */
|
|
282
290
|
webSearch?: boolean;
|
|
283
|
-
}): Promise<{ text: string }>;`,
|
|
291
|
+
}): Promise<{ text: string }>;`,Ru=`
|
|
284
292
|
/**
|
|
285
293
|
* Returns AI models available to the current user.
|
|
286
294
|
* Models are filtered by the user's configured API keys.
|
|
@@ -295,7 +303,7 @@ Examples:
|
|
|
295
303
|
friendlyName: string;
|
|
296
304
|
/** Provider display name, e.g. "Anthropic" */
|
|
297
305
|
providerName: string;
|
|
298
|
-
}>>;`,
|
|
306
|
+
}>>;`,Ly="\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;",Iu=`
|
|
299
307
|
/**
|
|
300
308
|
* The mode this bulb is running in.
|
|
301
309
|
*
|
|
@@ -305,7 +313,7 @@ Examples:
|
|
|
305
313
|
* - \`'embedded'\` \u2014 Running as a bulb embedded inside another bulb (sandboxed,
|
|
306
314
|
* client-only: AI, filesystem, and server RPC are unavailable)
|
|
307
315
|
*/
|
|
308
|
-
mode: 'local' | 'editor' | 'published' | 'embedded';`,
|
|
316
|
+
mode: 'local' | 'editor' | 'published' | 'embedded';`,_u=`
|
|
309
317
|
/**
|
|
310
318
|
* Local filesystem access (CLI only).
|
|
311
319
|
*
|
|
@@ -319,7 +327,7 @@ Examples:
|
|
|
319
327
|
readBytes(path: string): Promise<Uint8Array>;
|
|
320
328
|
/** Write text or raw bytes to a file. Creates parent directories if needed. */
|
|
321
329
|
write(path: string, content: string | Uint8Array): Promise<boolean>;
|
|
322
|
-
}
|
|
330
|
+
};`,$y=`
|
|
323
331
|
/**
|
|
324
332
|
* Server-side function proxy. The built-in \`log\` prints to CLI stdout
|
|
325
333
|
* (falls back to console.log on web). On the server side, this object only
|
|
@@ -327,7 +335,7 @@ Examples:
|
|
|
327
335
|
*/
|
|
328
336
|
server: {
|
|
329
337
|
log(...args: any[]): Promise<void>;
|
|
330
|
-
};`,
|
|
338
|
+
};`,My=`
|
|
331
339
|
/**
|
|
332
340
|
* Async value inspector for tensor-like objects.
|
|
333
341
|
*
|
|
@@ -394,7 +402,7 @@ Examples:
|
|
|
394
402
|
*
|
|
395
403
|
* @returns The full canonical URL
|
|
396
404
|
*/
|
|
397
|
-
url(): Promise<string>;`,
|
|
405
|
+
url(): Promise<string>;`,Dy=`
|
|
398
406
|
/**
|
|
399
407
|
* Server-side function proxy.
|
|
400
408
|
*
|
|
@@ -402,30 +410,30 @@ Examples:
|
|
|
402
410
|
* \`tb.server.log(...)\` is a built-in that prints to CLI stdout (falls back to console.log on web).
|
|
403
411
|
* User exports override built-ins of the same name.
|
|
404
412
|
*/
|
|
405
|
-
server: Record<string, (...args: any[]) => Promise<any>>;`,
|
|
413
|
+
server: Record<string, (...args: any[]) => Promise<any>>;`,xo=`
|
|
406
414
|
/**
|
|
407
415
|
* Typebulb utilities namespace.
|
|
408
416
|
* Type \`tb.\` to discover available helpers.
|
|
409
417
|
*/
|
|
410
|
-
declare const tb: {${
|
|
418
|
+
declare const tb: {${Ou}${My}${Nu}${Dy}${Cu}${_u}${Ru}${Ly}${Iu}
|
|
411
419
|
};
|
|
412
|
-
`,
|
|
420
|
+
`,Eo=`
|
|
413
421
|
/**
|
|
414
422
|
* Typebulb utilities namespace (server-side).
|
|
415
423
|
* Type \`tb.\` to discover available helpers.
|
|
416
424
|
*/
|
|
417
|
-
declare const tb: {${
|
|
425
|
+
declare const tb: {${Ou}${Nu}${Cu}${_u}${$y}${Ru}${Iu}
|
|
418
426
|
};
|
|
419
|
-
`;var Be=class{constructor(e){this.store=e}async isNegative(e){let t=await _s(()=>this.store.get(e));return!!t&&t.until>Date.now()}async recordNegative(e){let s=((await _s(()=>this.store.get(e)))?.attempts||0)+1;await _s(()=>this.store.set(e,{until:Date.now()+Ly(s),attempts:s}))}async clearNegative(e){await _s(()=>this.store.delete(e))}};function Ly(r){return Math.min(9e5*Math.pow(2,Math.max(0,r-1)),864e5)}async function _s(r){try{return await r()}catch{return}}import jy from"p-limit";import{resolve as _u}from"resolve.exports";var ut=class{constructor(e){this.fetchDts=e}fetchDtsText(e){return this.tryUrls([e])}async tryUrls(e){for(let t of e){let s=await this.fetchDts(t);if(s&&(this.looksLikeDts(s.dts)||/\.(d\.ts|d\.mts)(?:[?#].*)?$/i.test(s.url)||/[?&]dts(?:[&#]|$)/i.test(s.url)))return s}}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)}};var Pe={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},ur=["index.d.ts","index.d.mts"],fr=/\.d\.(ts|mts)$/i;function xo(r){if(fr.test(r))return!0;try{return new URL(r,"file://").search.includes("dts")}catch{return r.includes("?")&&r.includes("dts")}}function Ls(r){return[`${r}.d.ts`,`${r}.d.mts`]}async function dr(r,{retries:e=2,timeoutMs:t=15e3,init:s}={}){for(let n=0;n<=e;n++){let i=new AbortController,o=setTimeout(()=>i.abort(),t);try{let a=await fetch(r,{...s,signal:i.signal});if($y(a.status)&&n<e)continue;return a}catch{if(n<e)continue;return}finally{clearTimeout(o)}}}function $y(r){return r===408||r===429||r>=500&&r<600}var pr=class extends ut{constructor(e,t){super(e),this.cdnClient=t}async loadPackageAtVersionedRoot(e,t){let s=this.cdnClient.packageJson(new A({name:e,version:t})),n=await dr(s);if(!n?.ok)return;let i;try{i=await n.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new A({name:e,version:t??i.version})),version:t}}extractPathFromResult(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.find(t=>typeof t=="string")}async tryUntilSuccess(e,t){for(let s of e){let n=await t(s);if(n)return n}}async resolveFromSelected(e,t){if(e.kind==="types"){let n=this.cdnClient.normalizeRelative(e.path);if(!n||n==="/"||n===".")return this.tryUntilSuccess([...ur],t);if(!fr.test(n)){let i=await this.tryUntilSuccess(this.declarationCandidatesFor(n),t);if(i)return i}return t(n)}let s=this.declarationCandidatesFor(e.path);return this.tryUntilSuccess([...ur,...s],t)}toResolutionResult(e){return{kind:fr.test(e)?"types":"probe",path:e}}resolveExportsPath(e,t){let s=t||".",n=e;try{let i=this.extractPathFromResult(_u(n,s,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(_u(n,s,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let t=A.parse(e),{pkg:s,baseDir:n}=await this.loadPackageAtVersionedRoot(t.name,t.version)||{};if(!s||!n)return;let i={name:t.name,version:t.version},o=new A(i).format(),a=new A({...i,subpath:t.subpath}).format(),c=u=>this.fetchCandidateFrom(n,t.name,u);if(t.subpath){let u=this.cdnClient.ensureLeadingDotSlash(t.subpath),d=this.resolveExportsPath(s,u);if(d){let g=await this.resolveFromSelected(this.toResolutionResult(d),c);if(g)return{...g,resolvedPkg:a}}let h=await this.tryUntilSuccess(this.declarationCandidatesFor(u),c);if(h)return{...h,resolvedPkg:a}}let l=s.types??s.typings;if(l){let u=await this.resolveFromSelected({kind:"types",path:l},c);if(u)return{...u,resolvedPkg:o}}let f=this.resolveExportsPath(s,".");if(f){let u=await this.resolveFromSelected(this.toResolutionResult(f),c);if(u)return{...u,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,t,s){let n=this.cdnClient.normalizeRelative(s),i=new URL(n,e).toString(),o=await this.fetchDtsText(i);return o?{dts:o.dts,url:o.url,resolvedPkg:t}:void 0}declarationCandidatesFor(e){if(!e||e==="./"||e==="/")return[...ur];let t=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),s=Ls(t),n=t.endsWith("/")?t:`${t}/`;return s.push(...Ls(`${n}index`)),s}};import{gunzipSync as My}from"fflate";var ft=class{async fetchAndExtract(e,t){let s=this.getTarballUrl(e,t),n=await dr(s,{timeoutMs:3e4});if(!n?.ok)return new Map;let i=new Uint8Array(await n.arrayBuffer());return this.extractDtsFiles(i)}getTarballUrl(e,t){return`https://registry.npmjs.org/${e.replace("/","%2F")}/-/${e.split("/").pop()}-${t}.tgz`}normalizeTarPath(e){let t=e.replace(/^package\//,""),s=t.indexOf("/");return s>0?t.substring(s+1):t}extractDtsFiles(e){let t=new Map;try{let s=My(e),n=new TextDecoder("utf-8"),i=0;for(;i<s.length-512;){let o=s.slice(i,i+512);if(o[0]===0)break;let a=o.slice(0,100),c=a.indexOf(0),l=n.decode(a.slice(0,c>0?c:100)).trim(),f=o.slice(124,136),u=n.decode(f).trim().replace(/\0/g,""),d=parseInt(u,8)||0,h=String.fromCharCode(o[156]);if(i+=512,(h==="0"||h==="\0")&&(l.endsWith(".d.ts")||l.endsWith(".d.mts"))){let g=s.slice(i,i+d);t.set(this.normalizeTarPath(l),n.decode(g))}i+=Math.ceil(d/512)*512}}catch{}return t}},Dy=new ft;var hr=class extends ut{constructor(e,t,s,n=new ft){super(e),this.cdnClient=t,this.cache=s,this.tarballFetcher=n}typesNameCandidates(e){let t=e.startsWith("@")?e.slice(1).replace("/","__"):e;return t.includes(".")?[t,t.split(".").join("-"),t.split(".").join("")]:[t]}selectTypesVersion(e,t,s){try{if(s){let i=qe.majorOf(s),o=e.filter(a=>qe.majorOf(a)===i);if(o.length)return o.sort((a,c)=>qe.cmp(c,a))[0]}let n=t?.latest;return n&&e.includes(n)?n:e[0]}catch{return e[0]}}async fetchFromVersionedRoot(e,t){let s=new A(e),n=s.version;if(!n)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(s.name,n)}catch{return}if(!i||i.size===0)return;for(let[a,c]of i.entries()){let l=this.cdnClient.file(e,a);try{await this.cache.setCachedFile(l,c)}catch{}}let o=t.subpath?[t.subpath+".d.ts",t.subpath+"/index.d.ts"]:["index.d.ts"];for(let a of o){let c=i.get(a);if(c)return{dts:c,url:this.cdnClient.file(e,a),resolvedPkg:t.subpath?new A(t).format():t.name}}}async resolve(e){let t=A.parse(e);if(t.name)for(let s of this.typesNameCandidates(t.name)){let n=`@types/${s}`,i;try{i=await this.cdnClient.fetchVersionsIndex(n)}catch{continue}if(!i?.versions?.length)continue;let o=this.selectTypesVersion(i.versions,i.distTags,t.version),a=await this.fetchFromVersionedRoot(`${n}@${o}`,t);if(a)return a}}};var mr=class{collectRelativeTypeRefs(e){return this.collectRefs(e).filter(t=>t.startsWith("./")||t.startsWith("../"))}collectBareModuleRefs(e){return this.collectRefs(e).filter(t=>this.isBare(t))}collectRefs(e){let t=new Set,s=(n,i)=>(t.add(n[i]),null);return this.matchAll(e,/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/,n=>s(n,2)),this.matchAll(e,/export\s*\*\s*from\s*['"]([^'"\n]+)['"]/,n=>s(n,1)),Array.from(t)}matchAll(e,t,s){let n=[];try{let i=new RegExp(t.source,"g"),o;for(;o=i.exec(e);){let a=s(o);a!==null&&n.push(a)}}catch{}return n}isBare(e){return!(e.startsWith("./")||e.startsWith("../")||e.startsWith("file:")||e.startsWith("http://")||e.startsWith("https://"))}};var Lu="file:///node_modules",gr=class{constructor(){this.epoch=0,this.listeners=new Set}getEpoch(){return this.epoch}bumpEpoch(){this.epoch+=1;for(let e of this.listeners)try{e(this.epoch)}catch{}return this.epoch}onEpochChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${Lu}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,t){let s=qy(t);return`${Lu}/${this.epochDir()}/${e}/${s}`}};function qy(r){let e=r||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}import{LRUCache as By}from"lru-cache";function Eo(r){let e=new By({ttl:1e4,max:500}),t=new Map;return async function(n){try{if(await r.isNegative(n))return;let i=e.get(n);if(i&&Date.now()-i<1e4)return;let o=await r.getCachedFile(n);if(o)return{dts:o,url:n};let a=t.get(n);if(a)return a;let c=(async()=>{let l=await fetch(n,{cache:"no-store"});if(!l.ok){l.status===404&&(e.set(n,Date.now()),await r.recordNegative(n));return}let f=await l.text(),u=l.url||n;return await r.clearNegative(n),await r.setCachedFile(u,f),{dts:f,url:u}})();return t.set(n,c),await c.finally(()=>t.delete(n))}catch{return}}}var $s=class{constructor(e){this.inFlight=new Map,this.scanner=new mr,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=Eo(e.cache),this.typescriptProvider=new pr(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new hr(this.fetchDts,e.cdnClient,e.cache),this.virtualFs=new gr}withInFlight(e,t){let s=this.inFlight.get(e);if(s)return s;let n=t().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,n),n}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}capArray(e,t){return e.length<=t?e:e.slice(0,t)}pushFileIfNew(e,t,s){e.some(n=>n.path===t)||e.push({path:t,content:s})}createStubDef(e){let t=this.virtualFs.pathForMain(e);return{pkg:e,mainPath:t,files:[{path:t,content:"export const _shim: any; export default _shim;"}],shims:[{module:e,path:t}]}}async trySubpathWithRootFallback(e,t){let s=new A(e);return s.subpath?this.fetchRootDts(s.name,t):void 0}async fetchViaProviders(e){for(let t of[this.typescriptProvider,this.definitelyTypedProvider])try{let s=await t.resolve(e);if(s?.dts)return s}catch{}}subpathsMatch(e,t){return new A(e).subpath===new A(t).subpath}async fetchRootDts(e,t){let{effectivePackage:s,root:n,pinned:i}=await this.versionResolver.effectivePackage(e,t),o=await this.cache.getCachedDts(s);if(o?.content){let c=o.url??this.cdnClient.file(i?`${n}@${i}`:n,"index.d.ts");return{dts:o.content,url:c,resolvedPkg:s}}let a;try{a=await this.fetchViaProviders(s)}catch{return}if(!(!a?.dts||!a.url)){try{await this.cache.setCachedFile(a.url,a.dts)}catch{}if(this.subpathsMatch(s,a.resolvedPkg||s)){try{await this.cache.setCachedDts(s,a.dts,a.url)}catch{}return a}}}extractPackageRootUrl(e){let t=e.pathname.match(/^(.+@[^/]+\/)/);return t?new URL(t[1],e.origin):new URL("./",e)}toVirtualPath(e,t,s){let n=t.pathname.startsWith(e.pathname)?t.pathname.slice(e.pathname.length):`__deps__/${encodeURIComponent(t.toString()).replace(/%/g,"_")}.d.ts`;return this.virtualFs.pathFor(s,n)}computeEntryPath(e,t){if(!e)return{mainPath:this.virtualFs.pathForMain(t),packageRootUrl:void 0};let s=new URL(e),n=this.extractPackageRootUrl(s);return{mainPath:this.toVirtualPath(n,s,t),packageRootUrl:n}}async expandRelativeRefs(e,t,s,n,i=new Set,o){if(!i.has(t)&&(i.add(t),!(i.size>Pe.maxRelativeTypeRefs)))try{let a=new URL(t),c=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let l=this.capArray(this.scanner.collectRelativeTypeRefs(e),Pe.maxRelativeTypeRefs);for(let f of l)await this.tryRelativeRef(f,c,o,s,n,i)}catch{}}async tryRelativeRef(e,t,s,n,i,o){try{let a=new URL(e,t),c=a.pathname+a.search,l=xo(c)?[c]:this.typescriptProvider.declarationCandidatesFor(c);for(let f of l){let d=new URL(f,a).toString();if(o.has(d))return;let h=await this.fetchDts(d);if(h?.dts){let g=this.toVirtualPath(s,new URL(h.url),n);this.pushFileIfNew(i,g,h.dts),await this.expandRelativeRefs(h.dts,h.url,n,i,o,s);return}}}catch{}}isDifferentPackage(e,t){return e===t?!1:new A(e).name!==new A(t).name}ambientlyDeclares(e,t){for(let s of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let n=s[1];if(n===t||n.endsWith("/*")&&t.startsWith(n.slice(0,-1)))return!0}return!1}markFileAmbient(e,t){let s=e.find(n=>n.path===t);s&&(s.ambient=!0)}async prefetchBareDeps(e,t,s,n,i){try{let o=this.capArray(this.scanner.collectBareModuleRefs(e),Pe.maxBareDeps).filter(l=>this.isDifferentPackage(l,t));if(!o.length)return;let a=new Set([t]),c=jy(Pe.prefetchConcurrency);await Promise.all(o.map(l=>c(()=>this.prefetchBareDepsRecursive(l,s,n,Pe.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,t,s,n,i,o){if(n<=0||i.has(e))return;i.add(e);let a=await this.fetchRootDts(e,o);if(!a?.dts)return;let c=a.resolvedPkg||e,l=this.virtualFs.pathForMain(c);this.pushFileIfNew(t,l,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(t,l):s.push({module:e,path:l}),a.url&&await this.expandRelativeRefs(a.dts,a.url,c,t);let f=this.capArray(this.scanner.collectBareModuleRefs(a.dts),Pe.maxBareDeps).filter(u=>!i.has(u));for(let u of f)await this.prefetchBareDepsRecursive(u,t,s,n-1,i,o)}async resolve(e,t,s){let n=await this.packageService.extractImports(e),i=s?[...n,...s]:n;return(await Promise.all(i.map(a=>this.resolveOne(a,t)))).filter(a=>!!a)}async resolveOne(e,t){let{effectivePackage:s}=await this.versionResolver.effectivePackage(e,t);return this.withInFlight(s,async()=>{let n=await this.fetchRootDts(e,t)??await this.trySubpathWithRootFallback(e,t);return n?this.buildDefFromContent(e,n,n.resolvedPkg||e,t):this.createStubDef(e)})}async buildDefFromContent(e,t,s,n){let{dts:i,url:o,resolvedPkg:a}=t,c=new A(a||s),l=c.version?`${c.name}@${c.version}`:c.name,{mainPath:f,packageRootUrl:u}=this.computeEntryPath(o,l),d=[{path:f,content:i}],h=[];o&&await this.expandRelativeRefs(i,o,l,d,void 0,u);let g=d.map(k=>k.content).join(`
|
|
420
|
-
`);await this.prefetchBareDeps(g,l,d,
|
|
421
|
-
`,"utf8")}async function
|
|
427
|
+
`;var Fe=class{constructor(e){this.store=e}async isNegative(e){let t=await _s(()=>this.store.get(e));return!!t&&t.until>Date.now()}async recordNegative(e){let s=((await _s(()=>this.store.get(e)))?.attempts||0)+1;await _s(()=>this.store.set(e,{until:Date.now()+By(s),attempts:s}))}async clearNegative(e){await _s(()=>this.store.delete(e))}};function By(r){return Math.min(9e5*Math.pow(2,Math.max(0,r-1)),864e5)}async function _s(r){try{return await r()}catch{return}}import Ky from"p-limit";import{resolve as Lu}from"resolve.exports";var ft=class{constructor(e){this.fetchDts=e}fetchDtsText(e){return this.tryUrls([e])}async tryUrls(e){for(let t of e){let s=await this.fetchDts(t);if(s&&(this.looksLikeDts(s.dts)||/\.(d\.ts|d\.mts)(?:[?#].*)?$/i.test(s.url)||/[?&]dts(?:[&#]|$)/i.test(s.url)))return s}}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)}};var Pe={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},ur=["index.d.ts","index.d.mts"],fr=/\.d\.(ts|mts)$/i;function Ao(r){if(fr.test(r))return!0;try{return new URL(r,"file://").search.includes("dts")}catch{return r.includes("?")&&r.includes("dts")}}function Ls(r){return[`${r}.d.ts`,`${r}.d.mts`]}async function dr(r,{retries:e=2,timeoutMs:t=15e3,init:s}={}){for(let n=0;n<=e;n++){let i=new AbortController,o=setTimeout(()=>i.abort(),t);try{let a=await fetch(r,{...s,signal:i.signal});if(qy(a.status)&&n<e)continue;return a}catch{if(n<e)continue;return}finally{clearTimeout(o)}}}function qy(r){return r===408||r===429||r>=500&&r<600}var pr=class extends ft{constructor(e,t){super(e),this.cdnClient=t}async loadPackageAtVersionedRoot(e,t){let s=this.cdnClient.packageJson(new A({name:e,version:t})),n=await dr(s);if(!n?.ok)return;let i;try{i=await n.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new A({name:e,version:t??i.version})),version:t}}extractPathFromResult(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.find(t=>typeof t=="string")}async tryUntilSuccess(e,t){for(let s of e){let n=await t(s);if(n)return n}}async resolveFromSelected(e,t){if(e.kind==="types"){let n=this.cdnClient.normalizeRelative(e.path);if(!n||n==="/"||n===".")return this.tryUntilSuccess([...ur],t);if(!fr.test(n)){let i=await this.tryUntilSuccess(this.declarationCandidatesFor(n),t);if(i)return i}return t(n)}let s=this.declarationCandidatesFor(e.path);return this.tryUntilSuccess([...ur,...s],t)}toResolutionResult(e){return{kind:fr.test(e)?"types":"probe",path:e}}resolveExportsPath(e,t){let s=t||".",n=e;try{let i=this.extractPathFromResult(Lu(n,s,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(Lu(n,s,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let t=A.parse(e),{pkg:s,baseDir:n}=await this.loadPackageAtVersionedRoot(t.name,t.version)||{};if(!s||!n)return;let i={name:t.name,version:t.version},o=new A(i).format(),a=new A({...i,subpath:t.subpath}).format(),c=u=>this.fetchCandidateFrom(n,t.name,u);if(t.subpath){let u=this.cdnClient.ensureLeadingDotSlash(t.subpath),d=this.resolveExportsPath(s,u);if(d){let g=await this.resolveFromSelected(this.toResolutionResult(d),c);if(g)return{...g,resolvedPkg:a}}let p=await this.tryUntilSuccess(this.declarationCandidatesFor(u),c);if(p)return{...p,resolvedPkg:a}}let l=s.types??s.typings;if(l){let u=await this.resolveFromSelected({kind:"types",path:l},c);if(u)return{...u,resolvedPkg:o}}let f=this.resolveExportsPath(s,".");if(f){let u=await this.resolveFromSelected(this.toResolutionResult(f),c);if(u)return{...u,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,t,s){let n=this.cdnClient.normalizeRelative(s),i=new URL(n,e).toString(),o=await this.fetchDtsText(i);return o?{dts:o.dts,url:o.url,resolvedPkg:t}:void 0}declarationCandidatesFor(e){if(!e||e==="./"||e==="/")return[...ur];let t=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),s=Ls(t),n=t.endsWith("/")?t:`${t}/`;return s.push(...Ls(`${n}index`)),s}};import{gunzipSync as Fy}from"fflate";var dt=class{async fetchAndExtract(e,t){let s=this.getTarballUrl(e,t),n=await dr(s,{timeoutMs:3e4});if(!n?.ok)return new Map;let i=new Uint8Array(await n.arrayBuffer());return this.extractDtsFiles(i)}getTarballUrl(e,t){return`https://registry.npmjs.org/${e.replace("/","%2F")}/-/${e.split("/").pop()}-${t}.tgz`}normalizeTarPath(e){let t=e.replace(/^package\//,""),s=t.indexOf("/");return s>0?t.substring(s+1):t}extractDtsFiles(e){let t=new Map;try{let s=Fy(e),n=new TextDecoder("utf-8"),i=0;for(;i<s.length-512;){let o=s.slice(i,i+512);if(o[0]===0)break;let a=o.slice(0,100),c=a.indexOf(0),l=n.decode(a.slice(0,c>0?c:100)).trim(),f=o.slice(124,136),u=n.decode(f).trim().replace(/\0/g,""),d=parseInt(u,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(l.endsWith(".d.ts")||l.endsWith(".d.mts"))){let g=s.slice(i,i+d);t.set(this.normalizeTarPath(l),n.decode(g))}i+=Math.ceil(d/512)*512}}catch{}return t}},jy=new dt;var hr=class extends ft{constructor(e,t,s,n=new dt){super(e),this.cdnClient=t,this.cache=s,this.tarballFetcher=n}typesNameCandidates(e){let t=e.startsWith("@")?e.slice(1).replace("/","__"):e;return t.includes(".")?[t,t.split(".").join("-"),t.split(".").join("")]:[t]}selectTypesVersion(e,t,s){try{if(s){let i=qe.majorOf(s),o=e.filter(a=>qe.majorOf(a)===i);if(o.length)return o.sort((a,c)=>qe.cmp(c,a))[0]}let n=t?.latest;return n&&e.includes(n)?n:e[0]}catch{return e[0]}}async fetchFromVersionedRoot(e,t){let s=new A(e),n=s.version;if(!n)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(s.name,n)}catch{return}if(!i||i.size===0)return;for(let[a,c]of i.entries()){let l=this.cdnClient.file(e,a);try{await this.cache.setCachedFile(l,c)}catch{}}let o=t.subpath?[t.subpath+".d.ts",t.subpath+"/index.d.ts"]:["index.d.ts"];for(let a of o){let c=i.get(a);if(c)return{dts:c,url:this.cdnClient.file(e,a),resolvedPkg:t.subpath?new A(t).format():t.name}}}async resolve(e){let t=A.parse(e);if(t.name)for(let s of this.typesNameCandidates(t.name)){let n=`@types/${s}`,i;try{i=await this.cdnClient.fetchVersionsIndex(n)}catch{continue}if(!i?.versions?.length)continue;let o=this.selectTypesVersion(i.versions,i.distTags,t.version),a=await this.fetchFromVersionedRoot(`${n}@${o}`,t);if(a)return a}}};var mr=class{collectRelativeTypeRefs(e){return this.collectRefs(e).filter(t=>t.startsWith("./")||t.startsWith("../"))}collectBareModuleRefs(e){return this.collectRefs(e).filter(t=>this.isBare(t))}collectRefs(e){let t=new Set,s=(n,i)=>(t.add(n[i]),null);return this.matchAll(e,/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/,n=>s(n,2)),this.matchAll(e,/export\s*\*\s*from\s*['"]([^'"\n]+)['"]/,n=>s(n,1)),Array.from(t)}matchAll(e,t,s){let n=[];try{let i=new RegExp(t.source,"g"),o;for(;o=i.exec(e);){let a=s(o);a!==null&&n.push(a)}}catch{}return n}isBare(e){return!(e.startsWith("./")||e.startsWith("../")||e.startsWith("file:")||e.startsWith("http://")||e.startsWith("https://"))}};var $u="file:///node_modules",gr=class{constructor(){this.epoch=0,this.listeners=new Set}getEpoch(){return this.epoch}bumpEpoch(){this.epoch+=1;for(let e of this.listeners)try{e(this.epoch)}catch{}return this.epoch}onEpochChange(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${$u}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,t){let s=Uy(t);return`${$u}/${this.epochDir()}/${e}/${s}`}};function Uy(r){let e=r||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}import{LRUCache as Jy}from"lru-cache";function To(r){let e=new Jy({ttl:1e4,max:500}),t=new Map;return async function(n){try{if(await r.isNegative(n))return;let i=e.get(n);if(i&&Date.now()-i<1e4)return;let o=await r.getCachedFile(n);if(o)return{dts:o,url:n};let a=t.get(n);if(a)return a;let c=(async()=>{let l=await fetch(n,{cache:"no-store"});if(!l.ok){l.status===404&&(e.set(n,Date.now()),await r.recordNegative(n));return}let f=await l.text(),u=l.url||n;return await r.clearNegative(n),await r.setCachedFile(u,f),{dts:f,url:u}})();return t.set(n,c),await c.finally(()=>t.delete(n))}catch{return}}}var $s=class{constructor(e){this.inFlight=new Map,this.scanner=new mr,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=To(e.cache),this.typescriptProvider=new pr(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new hr(this.fetchDts,e.cdnClient,e.cache),this.virtualFs=new gr}withInFlight(e,t){let s=this.inFlight.get(e);if(s)return s;let n=t().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,n),n}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}capArray(e,t){return e.length<=t?e:e.slice(0,t)}pushFileIfNew(e,t,s){e.some(n=>n.path===t)||e.push({path:t,content:s})}createStubDef(e){let t=this.virtualFs.pathForMain(e);return{pkg:e,mainPath:t,files:[{path:t,content:"export const _shim: any; export default _shim;"}],shims:[{module:e,path:t}]}}async trySubpathWithRootFallback(e,t){let s=new A(e);return s.subpath?this.fetchRootDts(s.name,t):void 0}async fetchViaProviders(e){for(let t of[this.typescriptProvider,this.definitelyTypedProvider])try{let s=await t.resolve(e);if(s?.dts)return s}catch{}}subpathsMatch(e,t){return new A(e).subpath===new A(t).subpath}async fetchRootDts(e,t){let{effectivePackage:s,root:n,pinned:i}=await this.versionResolver.effectivePackage(e,t),o=await this.cache.getCachedDts(s);if(o?.content){let c=o.url??this.cdnClient.file(i?`${n}@${i}`:n,"index.d.ts");return{dts:o.content,url:c,resolvedPkg:s}}let a;try{a=await this.fetchViaProviders(s)}catch{return}if(!(!a?.dts||!a.url)){try{await this.cache.setCachedFile(a.url,a.dts)}catch{}if(this.subpathsMatch(s,a.resolvedPkg||s)){try{await this.cache.setCachedDts(s,a.dts,a.url)}catch{}return a}}}extractPackageRootUrl(e){let t=e.pathname.match(/^(.+@[^/]+\/)/);return t?new URL(t[1],e.origin):new URL("./",e)}toVirtualPath(e,t,s){let n=t.pathname.startsWith(e.pathname)?t.pathname.slice(e.pathname.length):`__deps__/${encodeURIComponent(t.toString()).replace(/%/g,"_")}.d.ts`;return this.virtualFs.pathFor(s,n)}computeEntryPath(e,t){if(!e)return{mainPath:this.virtualFs.pathForMain(t),packageRootUrl:void 0};let s=new URL(e),n=this.extractPackageRootUrl(s);return{mainPath:this.toVirtualPath(n,s,t),packageRootUrl:n}}async expandRelativeRefs(e,t,s,n,i=new Set,o){if(!i.has(t)&&(i.add(t),!(i.size>Pe.maxRelativeTypeRefs)))try{let a=new URL(t),c=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let l=this.capArray(this.scanner.collectRelativeTypeRefs(e),Pe.maxRelativeTypeRefs);for(let f of l)await this.tryRelativeRef(f,c,o,s,n,i)}catch{}}async tryRelativeRef(e,t,s,n,i,o){try{let a=new URL(e,t),c=a.pathname+a.search,l=Ao(c)?[c]:this.typescriptProvider.declarationCandidatesFor(c);for(let f of l){let d=new URL(f,a).toString();if(o.has(d))return;let p=await this.fetchDts(d);if(p?.dts){let g=this.toVirtualPath(s,new URL(p.url),n);this.pushFileIfNew(i,g,p.dts),await this.expandRelativeRefs(p.dts,p.url,n,i,o,s);return}}}catch{}}isDifferentPackage(e,t){return e===t?!1:new A(e).name!==new A(t).name}ambientlyDeclares(e,t){for(let s of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let n=s[1];if(n===t||n.endsWith("/*")&&t.startsWith(n.slice(0,-1)))return!0}return!1}markFileAmbient(e,t){let s=e.find(n=>n.path===t);s&&(s.ambient=!0)}async prefetchBareDeps(e,t,s,n,i){try{let o=this.capArray(this.scanner.collectBareModuleRefs(e),Pe.maxBareDeps).filter(l=>this.isDifferentPackage(l,t));if(!o.length)return;let a=new Set([t]),c=Ky(Pe.prefetchConcurrency);await Promise.all(o.map(l=>c(()=>this.prefetchBareDepsRecursive(l,s,n,Pe.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,t,s,n,i,o){if(n<=0||i.has(e))return;i.add(e);let a=await this.fetchRootDts(e,o);if(!a?.dts)return;let c=a.resolvedPkg||e,l=this.virtualFs.pathForMain(c);this.pushFileIfNew(t,l,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(t,l):s.push({module:e,path:l}),a.url&&await this.expandRelativeRefs(a.dts,a.url,c,t);let f=this.capArray(this.scanner.collectBareModuleRefs(a.dts),Pe.maxBareDeps).filter(u=>!i.has(u));for(let u of f)await this.prefetchBareDepsRecursive(u,t,s,n-1,i,o)}async resolve(e,t,s){let n=await this.packageService.extractImports(e),i=s?[...n,...s]:n;return(await Promise.all(i.map(a=>this.resolveOne(a,t)))).filter(a=>!!a)}async resolveOne(e,t){let{effectivePackage:s}=await this.versionResolver.effectivePackage(e,t);return this.withInFlight(s,async()=>{let n=await this.fetchRootDts(e,t)??await this.trySubpathWithRootFallback(e,t);return n?this.buildDefFromContent(e,n,n.resolvedPkg||e,t):this.createStubDef(e)})}async buildDefFromContent(e,t,s,n){let{dts:i,url:o,resolvedPkg:a}=t,c=new A(a||s),l=c.version?`${c.name}@${c.version}`:c.name,{mainPath:f,packageRootUrl:u}=this.computeEntryPath(o,l),d=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,l,d,void 0,u);let g=d.map(m=>m.content).join(`
|
|
428
|
+
`);await this.prefetchBareDeps(g,l,d,p,n);let h=c.format(),y=e===h?[e]:[e,h],k=y.some(m=>this.ambientlyDeclares(i,m));return k?this.markFileAmbient(d,f):p.push(...y.map(m=>({module:m,path:f}))),{pkg:e,mainPath:f,files:d,shims:p,ambient:k}}};function Po(r){return new $s(r)}import*as le from"fs/promises";import*as pe from"path";import*as Bu from"os";import*as Oo from"fs/promises";import*as Mu from"crypto";function te(r){return Mu.createHash("sha1").update(r).digest("hex")}async function je(r){try{return JSON.parse(await Oo.readFile(r,"utf8"))}catch{return}}async function Ms(r){try{return await Oo.readFile(r,"utf8")}catch{return}}var Du=1,Oe=pe.join(Bu.homedir(),".typebulb","cache"),yr=pe.join(Oe,"packages"),br=pe.join(Oe,"proxy"),Ds=pe.join(Oe,"dts"),Vy=pe.join(Oe,"emit"),No;function I(){return No||(No=Wy()),No}function Bs(r,e){return pe.join(Vy,te(r),e)}async function Wy(){await le.mkdir(Oe,{recursive:!0});let r=pe.join(Oe,"version.json");if((await Yy(r))?.version===Du)return;let t=await le.readdir(Oe).catch(()=>[]);await Promise.all(t.map(s=>le.rm(pe.join(Oe,s),{recursive:!0,force:!0}))),await le.writeFile(r,JSON.stringify({version:Du})+`
|
|
429
|
+
`,"utf8")}async function Yy(r){try{let e=await le.readFile(r,"utf8");return JSON.parse(e)}catch{return}}import*as Ne from"fs/promises";import*as qu from"path";async function z(r,e){await Ne.mkdir(qu.dirname(r),{recursive:!0});let t=`${r}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await Ne.writeFile(t,e,"utf8"),await Ne.rename(t,r).catch(async s=>{throw await Ne.rm(t,{force:!0}).catch(()=>{}),s})}var pt=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=je(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,t){let s=await this.load();s.set(e,t),await this.persist(s)}async delete(e){let t=await this.load();t.delete(e)&&await this.persist(t)}async persist(e){await z(this.filePath,JSON.stringify(Object.fromEntries(e)))}};var Co=re.join(yr,"indexes"),Fu=re.join(yr,"pinned"),Hy=re.join(yr,"meta"),Gy=re.join(yr,"negative.json"),ht=Symbol("missing"),Fs=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new Fe(new pt(Gy));async getPinnedExact(e,t){let s=`${e}@${t}`,n=this.pinnedMem.get(s);if(n!==void 0)return n===ht?void 0:n;await I();let i=await Ms(re.join(Fu,te(s)+".txt"));return this.pinnedMem.set(s,i??ht),i}async setPinnedExact(e,t,s){let n=`${e}@${t}`;this.pinnedMem.set(n,s),await I(),await z(re.join(Fu,te(n)+".txt"),s)}async getIndex(e){let t=this.indexMem.get(e);if(t!==void 0)return t===ht?void 0:t;await I();let s=await je(re.join(Co,qs(e)+".json"));return this.indexMem.set(e,s??ht),s}async setIndex(e,t,s){let n={versions:t,distTags:s,updatedAt:Date.now()};this.indexMem.set(e,n),await I(),await z(re.join(Co,qs(e)+".json"),JSON.stringify(n))}async invalidateVersionsCache(e){this.indexMem.delete(e),await Uu.rm(re.join(Co,qs(e)+".json"),{force:!0})}async isNegative(e){return await I(),this.negativeCache.isNegative(e)}async recordNegative(e){await I(),await this.negativeCache.recordNegative(e)}async clearNegative(e){await this.negativeCache.clearNegative(e)}async getMeta(e,t){let s=`${e}@${t}`,n=this.metaMem.get(s);if(n!==void 0)return n===ht?void 0:n;await I();let i=await je(ju(e,t));return this.metaMem.set(s,i??ht),i}async setMeta(e,t,s,n,i){let o={dependencies:s,peerDependencies:n,peerDependenciesMeta:i,updatedAt:Date.now()};this.metaMem.set(`${e}@${t}`,o),await I(),await z(ju(e,t),JSON.stringify(o))}};function ju(r,e){return re.join(Hy,qs(r),encodeURIComponent(e)+".json")}function qs(r){return r.replace(/\//g,"__")}var Ju={async getJson(r){try{let e=await fetch(r,{redirect:"follow"});return e.ok?await e.json():void 0}catch{return}},async head(r){try{let e=await fetch(r,{method:"HEAD",redirect:"follow"});return{ok:e.ok,url:e.url}}catch{return}}};var zy=new Fs,{packageService:js,versionResolver:Ku,cdnClient:Vu,peerResolver:Lx}=Pu(zy,Ju);var Wu=`
|
|
422
430
|
(() => {
|
|
423
431
|
// Embedded (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
|
|
424
432
|
// bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
|
|
425
433
|
// otherwise fail with cryptic CORS/CSP errors. Detect it and fail clearly.
|
|
426
434
|
//
|
|
427
435
|
// The same sandboxed-iframe path also backs the CLI's default (untrusted) launch
|
|
428
|
-
// (
|
|
436
|
+
// (TB-Trust.md), where the right message names \`--trust\` rather
|
|
429
437
|
// than "no host bridge". The host injects window.__TB_EMBED_ERR__ to override the
|
|
430
438
|
// text; absent it, the nested-bulb wording applies.
|
|
431
439
|
const isEmbedded = window.parent !== window;
|
|
@@ -628,10 +636,11 @@ declare const tb: {${Pu}${Ou}${Nu}${Ru}${Iy}${Cu}${Iu}
|
|
|
628
636
|
};
|
|
629
637
|
}
|
|
630
638
|
})();
|
|
631
|
-
`;function Us(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var
|
|
639
|
+
`;function Us(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var Js=` *, *::before, *::after { box-sizing: border-box; }
|
|
640
|
+
canvas { max-width: 100%; }
|
|
632
641
|
body { margin: 0; display: flow-root; font-family: system-ui, -apple-system, sans-serif; }
|
|
633
642
|
html[data-theme="dark"] { color-scheme: dark; }
|
|
634
|
-
html[data-theme="light"] { color-scheme: light; }`;function
|
|
643
|
+
html[data-theme="light"] { color-scheme: light; }`;function Ks(r,e){let t=s=>s.replace(/<\/script/gi,"<\\/script");return` <script>
|
|
635
644
|
(function() {
|
|
636
645
|
try {
|
|
637
646
|
var KEY = ${t(JSON.stringify("tb-theme:"+r))};
|
|
@@ -666,19 +675,19 @@ declare const tb: {${Pu}${Ou}${Nu}${Ru}${Iy}${Cu}${Iu}
|
|
|
666
675
|
});
|
|
667
676
|
} catch (e) {}
|
|
668
677
|
})();
|
|
669
|
-
</script>`}function
|
|
670
|
-
html, body { height: 100%; }`,h
|
|
678
|
+
</script>`}function Yu(r){let{name:e,code:t,css:s,html:n,data:i,insight:o,importMap:a,watch:c,theme:l,embedded:f}=r,u=n.trim()||'<div id="app"></div>',d=f?"":`
|
|
679
|
+
html, body { height: 100%; }`,p=h=>h.replace(/<\/script/gi,"<\\/script"),g={imports:Xy(a.imports)};return`<!DOCTYPE html>
|
|
671
680
|
<html>
|
|
672
681
|
<head>
|
|
673
682
|
<meta charset="utf-8">
|
|
674
683
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
675
684
|
<title>${Us(e)} - typebulb</title>
|
|
676
|
-
${
|
|
685
|
+
${Ks(e,l)}
|
|
677
686
|
<script type="importmap">
|
|
678
687
|
${JSON.stringify(g,null,2)}
|
|
679
688
|
</script>
|
|
680
689
|
<style>
|
|
681
|
-
${
|
|
690
|
+
${Js}${d}
|
|
682
691
|
</style>
|
|
683
692
|
<style>
|
|
684
693
|
${s}
|
|
@@ -687,21 +696,22 @@ ${s}
|
|
|
687
696
|
<body>
|
|
688
697
|
${u}
|
|
689
698
|
|
|
690
|
-
${i.length>0?`<script>window.__TB_DATA__ = ${
|
|
691
|
-
${o?`<script>window.__TB_INSIGHT__ = ${
|
|
699
|
+
${i.length>0?`<script>window.__TB_DATA__ = ${p(JSON.stringify(i))};</script>`:""}
|
|
700
|
+
${o?`<script>window.__TB_INSIGHT__ = ${p(JSON.stringify(o))};</script>`:""}
|
|
692
701
|
${c?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
|
|
693
702
|
|
|
694
703
|
<script>
|
|
695
|
-
${
|
|
704
|
+
${Wu}
|
|
696
705
|
</script>
|
|
697
706
|
|
|
698
|
-
${
|
|
707
|
+
${Qy}
|
|
699
708
|
|
|
700
709
|
<script type="module">
|
|
701
|
-
${
|
|
710
|
+
${p(t)}
|
|
711
|
+
${f?"globalThis.__tbEntryRan = true; /* load-failure backstop \u2014 see embedProtocol */":""}
|
|
702
712
|
</script>
|
|
703
713
|
</body>
|
|
704
|
-
</html>`}var
|
|
714
|
+
</html>`}var Qy=`<script>
|
|
705
715
|
(function () {
|
|
706
716
|
if (window.parent === window) return;
|
|
707
717
|
var de = document.documentElement;
|
|
@@ -750,17 +760,25 @@ ${h(t)}
|
|
|
750
760
|
};
|
|
751
761
|
var update = function () { if (!raf) raf = requestAnimationFrame(apply); };
|
|
752
762
|
de.style.overflow = 'hidden';
|
|
763
|
+
var errorPosted = false;
|
|
764
|
+
var postError = function (message) { errorPosted = true; post({ __typebulbEmbed: true, kind: 'error', message: String(message) }); };
|
|
765
|
+
// Capture phase: a resource/module load failure (a <script>/<link>/<img> that 404s) does NOT
|
|
766
|
+
// bubble, so it reaches window only here, carrying the failing element as e.target (no message).
|
|
767
|
+
window.addEventListener('error', function (e) {
|
|
768
|
+
var t = e && e.target;
|
|
769
|
+
if (t && t !== window && (t.src || t.href)) postError('Failed to load ' + (t.src || t.href));
|
|
770
|
+
}, true);
|
|
753
771
|
window.addEventListener('error', function (e) {
|
|
754
772
|
var m = String((e && e.message) || (e && e.error) || 'Error');
|
|
755
773
|
// The benign "ResizeObserver loop completed\u2026" notice surfaces as a window error in
|
|
756
774
|
// some browsers; it's not a bulb fault, so don't forward it to the host as one.
|
|
757
775
|
if (m.indexOf('ResizeObserver') !== -1) return;
|
|
758
|
-
|
|
776
|
+
postError(m);
|
|
759
777
|
});
|
|
760
778
|
window.addEventListener('unhandledrejection', function (e) {
|
|
761
779
|
var r = e && e.reason;
|
|
762
780
|
var msg = r && r.message ? r.message : (r == null ? 'Unhandled rejection' : r);
|
|
763
|
-
|
|
781
|
+
postError(msg);
|
|
764
782
|
});
|
|
765
783
|
// Run at load (module mounted \u2192 real content, not the empty pre-mount body that would
|
|
766
784
|
// collapse the frame and snap back). Observe BOTH body (content growth) and the root
|
|
@@ -770,12 +788,18 @@ ${h(t)}
|
|
|
770
788
|
if (window.ResizeObserver) {
|
|
771
789
|
try { var ro = new ResizeObserver(update); ro.observe(document.body); ro.observe(de); } catch (e) {}
|
|
772
790
|
}
|
|
791
|
+
// Load-failure backstop: if the entry module never evaluated \u2014 its import graph failed to
|
|
792
|
+
// resolve (a 404'd dependency, which throws nothing catchable) \u2014 surface it. A module that
|
|
793
|
+
// only renders asynchronously still evaluates its top level, so this won't fire on a slow bulb.
|
|
794
|
+
if (!window.__tbEntryRan && !errorPosted) {
|
|
795
|
+
postError('Bulb failed to load: a module or dependency could not be fetched (see the browser console for the failing URL).');
|
|
796
|
+
}
|
|
773
797
|
});
|
|
774
798
|
})();
|
|
775
|
-
</script>`;function
|
|
776
|
-
`,"utf8"),await
|
|
777
|
-
`,"utf8"),{dir:e}}function
|
|
778
|
-
`);for(let i=0;i<n.length;i++){let o=n[i],a=i+1;for(let c of
|
|
799
|
+
</script>`;function Xy(r){let e={};for(let[t,s]of Object.entries(r))e[t]=s.startsWith("https://")?"/proxy/"+s:s;return e}import*as Ws from"fs/promises";import*as Vs from"path";import{existsSync as Hu,readFileSync as Zy}from"fs";import{execFile as eb}from"child_process";import{promisify as tb}from"util";import{satisfies as rb}from"semver";var sb=tb(eb);async function Ys(r,e,t){let n=r.map(o=>nb(o,t)).filter(o=>!ib(o,e));if(n.length===0)return;await Ws.mkdir(e,{recursive:!0});let i=Vs.join(e,"package.json");Hu(i)||await Ws.writeFile(i,JSON.stringify({name:"typebulb-server",private:!0})),console.log(` Installing: ${n.join(", ")}`),await sb("npm",["install","--no-audit","--no-fund",...n],{cwd:e,shell:!0})}function nb(r,e){if(!e||zu(r))return r;let t=e[r];return t?`${r}@${t}`:r}function ib(r,e){let t=Vs.join(e,"node_modules",Gu(r));if(!Hu(t))return!1;let s=zu(r);if(!s)return!0;try{let n=JSON.parse(Zy(Vs.join(t,"package.json"),"utf-8")).version;return rb(n,s)}catch{return!1}}function Hs(r){let e=new Set,t=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,s;for(;s=t.exec(r);){let n=s[1];if(n.includes(":"))continue;let i=n.startsWith("@")?n.split("/").slice(0,2).join("/"):n.split("/")[0];e.add(i)}return[...e]}function Gu(r){if(r.startsWith("@")){let t=r.indexOf("/");if(t<0)return r;let s=r.indexOf("@",t+1);return s<0?r:r.slice(0,s)}let e=r.indexOf("@");return e<0?r:r.slice(0,e)}function zu(r){let e=Gu(r);return r.length>e.length?r.slice(e.length+1):""}async function Qu(r){let t=(await Ce.readdir(r)).find(s=>s.endsWith(".bulb.md"));return t?Gs.join(r,t):null}async function se(r){let e=await Ce.readFile(r,"utf-8"),t=Ir(e);if(!t)throw new Error("Invalid .bulb.md file format");let s=Rs(t);return{bulb:s,config:xa(s.config)}}async function wr(r,e,t,s){let n=yo(r,{serverOnly:!0});if(n.error)throw new Error(`Server compilation error: ${n.error}`);let i=n.code;t&&(i=await ga(i,t));let o=Gs.join(e,".typebulb");await Ce.mkdir(o,{recursive:!0});let a=Hs(i);a.length>0&&await Ys(a,o,s);let c=Gs.join(o,"server.mjs");return await Ce.writeFile(c,i,"utf-8"),await import(`${ob(c).href}?t=${Date.now()}`)}async function Ro(r,e,t,s,n){let{bulb:i,config:o}=await se(r),a=mo(i.data),c=yo(i.code,{jsxImportSource:o.ts?.jsxImportSource});c.error&&console.error("Compilation error:",c.error);let{importMap:l}=await js.buildImportMap(c.code,o.dependencies??{},s?new Set([s.name]):void 0);s&&(l.imports[s.name]=s.entryUrl);let f=Yu({name:i.name,code:c.code,css:i.css,html:i.html,data:a,insight:i.insight,importMap:l,watch:e}),u=null;return i.server&&t&&(u=await wr(i.server,n,s,o.dependencies)),{html:f,bulb:i,serverExports:u}}Sr();import hb from"open";async function gt(r){await hb(r)}var ef=new Set(["claude"]);function tf(r){return ef.has(r)}function $o(){return[...ef]}import*as lf from"path";import{spawn as Rb}from"child_process";import*as F from"fs/promises";import*as D from"path";import*as yt from"path";var mb=yt.join(Ds,"pkg"),gb=yt.join(Ds,"files"),yb=yt.join(Ds,"negative.json"),Xs=class{pkgMem=new Map;fileMem=new Map;negativeCache=new Fe(new pt(yb));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await I();let t=await je(rf(e));return this.pkgMem.set(e,t),t}async setCachedDts(e,t,s){let n={content:t,url:s};this.pkgMem.set(e,n),await Qs(async()=>{await I(),await z(rf(e),JSON.stringify(n))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await I();let t=await Ms(sf(e));return this.fileMem.set(e,t),t}async setCachedFile(e,t){this.fileMem.set(e,t),await Qs(async()=>{await I(),await z(sf(e),t)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await Qs(async()=>{await I(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return Qs(()=>this.negativeCache.clearNegative(e))}};async function Qs(r){try{await r()}catch{}}function rf(r){return yt.join(mb,te(r)+".json")}function sf(r){return yt.join(gb,te(r)+".txt")}var Mo;function bb(){return Mo||(Mo=Po({cache:new Xs,cdnClient:Vu,packageService:js,versionResolver:Ku})),Mo}var nf="file:///node_modules/";async function of(r){let e=Bs(r.emitKey,"typecheck");await I(),await F.rm(e,{recursive:!0,force:!0}),await F.mkdir(e,{recursive:!0});let t=kb(r.jsxImportSource,r.dependencies),s=await bb().resolve(r.code,r.dependencies,t),n=r.local?.name,i=n?s.filter(f=>f.pkg!==n):s,o=new Set;for(let f of i)for(let u of f.files){let d=Zs(u.path);if(!d||o.has(d))continue;o.add(d);let p=D.join(e,"node_modules",d);await F.mkdir(D.dirname(p),{recursive:!0}),await F.writeFile(p,u.content,"utf8")}let a={};for(let f of i)for(let u of f.shims){let d=Zs(u.path);d&&(a[u.module]=[`./node_modules/${d}`])}for(let f of i){if(f.ambient)continue;let u=Zs(f.mainPath);u&&(a[f.pkg]=[`./node_modules/${u}`])}let c=new Set;for(let f of i)for(let u of f.files){if(!u.ambient)continue;let d=Zs(u.path);d&&c.add(`node_modules/${d}`)}if(r.local){delete a[r.local.name];let f=await xb(r.local,e);f?a[r.local.name]=[`./node_modules/${r.local.name}/${f}`]:console.warn(` local: '${r.local.name}' ships no type defs; check cannot type against it.`)}let l=wb(r.jsxImportSource,a,[...c]);return await F.writeFile(D.join(e,"tsconfig.json"),JSON.stringify(l,null,2)+`
|
|
800
|
+
`,"utf8"),await F.writeFile(D.join(e,"code.tsx"),r.code,"utf8"),await F.writeFile(D.join(e,"tb.d.ts"),xo,"utf8"),{dir:e}}function wb(r,e,t=[]){return{compilerOptions:{target:"es2023",module:"esnext",moduleResolution:"bundler",lib:vb([...So,...ko]),jsx:"react-jsx",jsxImportSource:r??"react",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0,baseUrl:".",paths:e},include:["code.tsx","tb.d.ts",...t]}}function vb(r){return r.filter(e=>!e.since).map(e=>Sb(e.name))}function Sb(r){return r.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 kb(r,e){let t=r??("react"in e?"react":void 0);return t?[`${t}/jsx-runtime`,`${t}/jsx-dev-runtime`]:[]}function Zs(r){if(!r.startsWith(nf))return;let e=r.slice(nf.length),t=e.indexOf("/");if(!(t<0))return e.slice(t+1)}async function xb(r,e){if(!r.typesAbs)return;let t=D.dirname(r.typesAbs),s=D.join(e,"node_modules",r.name);for(let n of await Eb(t)){let i=D.join(s,D.relative(t,n));await F.mkdir(D.dirname(i),{recursive:!0}),await F.copyFile(n,i)}return D.basename(r.typesAbs)}async function Eb(r){let e=[];async function t(s){let n=await F.readdir(s,{withFileTypes:!0});for(let i of n){let o=D.join(s,i.name);i.isDirectory()?await t(o):/\.d\.ts(\.map)?$/.test(i.name)&&e.push(o)}}return await t(r),e}import*as Q from"fs/promises";import*as he from"path";import{existsSync as Ab}from"fs";var Tb="^22";async function af(r){let e=Bs(r.emitKey,"typecheck-server");await I(),await Q.rm(e,{recursive:!0,force:!0}),await Q.mkdir(e,{recursive:!0});let t=he.join(r.bulbDir,".typebulb"),s=Hs(r.server).filter(o=>o!==r.local?.name);await Ys([`@types/node@${Tb}`,...s],t,r.dependencies);let n=he.join(t,"node_modules"),i=he.join(e,"node_modules");return await Ob(n,i),await Q.writeFile(he.join(e,"server.ts"),r.server,"utf8"),await Q.writeFile(he.join(e,"tb.d.ts"),Eo,"utf8"),await Q.writeFile(he.join(e,"tsconfig.json"),JSON.stringify(Pb(r.local),null,2)+`
|
|
801
|
+
`,"utf8"),{dir:e}}function Pb(r){let e={target:"es2023",module:"esnext",moduleResolution:"bundler",lib:["ES2023"],types:["node"],strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};if(r?.typesAbs){let t=i=>i.replace(/\\/g,"/"),s=t(he.dirname(r.typesAbs)),n=t(r.typesAbs).replace(/\.d\.ts$/,"");e.baseUrl=".",e.paths={[r.name]:[n],[`${r.name}/*`]:[`${s}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function Ob(r,e){if(!Ab(r)){await Q.mkdir(e,{recursive:!0});return}await Q.rm(e,{recursive:!0,force:!0});let t=process.platform==="win32"?"junction":"dir";await Q.symlink(r,e,t)}var Ke=["client"],Ve=["client","server"],Nb=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:Ke},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:Ve},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:Ke},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:Ke},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:Ke},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:Ve},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:Ve},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:Ve},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:Ve},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:Ve},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:Ve},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:Ke},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:Ke},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:Ke}];function Do(r,e){if(!r)return[];let{target:t}=e,s=[],n=r.split(`
|
|
802
|
+
`);for(let i=0;i<n.length;i++){let o=n[i],a=i+1;for(let c of Nb)c.targets.includes(t)&&c.pattern.test(o)&&s.push({type:c.type,severity:"error",message:Cb(c.type,a),lineNumber:a,lineContent:o})}return s}function Cb(r,e){return r==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
|
|
779
803
|
|
|
780
804
|
**CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
|
|
781
805
|
|
|
@@ -929,49 +953,49 @@ import { something } from 'module-name'
|
|
|
929
953
|
const something = require('module-name') // NOT SUPPORTED!
|
|
930
954
|
\`\`\`
|
|
931
955
|
|
|
932
|
-
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}async function
|
|
933
|
-
`))console.log(`${e} ${s}`);return r.length>0}function
|
|
956
|
+
**Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}async function uf(r,e){let{bulb:t,config:s}=await se(r);!t.code&&!t.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let n=!1;t.code&&(n=cf(Do(t.code,{target:"client"}),"client")||n),t.server&&(n=cf(Do(t.server,{target:"server"}),"server")||n);let i=[];if(t.code){let{dir:a}=await of({code:t.code,dependencies:s.dependencies??{},jsxImportSource:s.ts?.jsxImportSource,emitKey:r,local:e});i.push({role:"client",dir:a})}if(t.server){let{dir:a}=await af({server:t.server,bulbDir:lf.dirname(r),emitKey:r,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:s.dependencies});i.push({role:"server",dir:a})}for(let{role:a,dir:c}of i){let{stdout:l,exitCode:f}=await Ib(c);for(let u of l.split(/\r?\n/))u.trim()&&console.log(`${a} ${u}`);f!==0&&(n=!0)}n&&process.exit(1);let o=[t.code&&"code.tsx",t.server&&"server.ts"].filter(Boolean).join(", ");console.error(`\u2713 no issues (${o})`)}function cf(r,e){for(let t of r)for(let s of t.message.split(`
|
|
957
|
+
`))console.log(`${e} ${s}`);return r.length>0}function Ib(r){return new Promise(e=>{let t=Rb("npx",["tsc","--noEmit"],{cwd:r,shell:!0}),s="";t.stdout?.on("data",n=>{s+=n.toString()}),t.stderr?.on("data",n=>{s+=n.toString()}),t.on("close",n=>e({stdout:s,exitCode:n??1}))})}en();Sr();async function ff(r,e){let{bulb:t}=await se(r),s=bt(t);if(Je(r)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),s&&console.log(` (it uses ${s})`);return}s?(console.log(`This bulb appears to use ${s}; 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.)")}Sr();import*as kr from"path";async function df(r,e){if(!r){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let s=Lo();if(!s.length){console.log("No bulbs are remembered as trusted.");return}console.log("Trusted bulbs (run with fs/AI/server.ts without --trust):");for(let n of s)console.log(` ${n}`);return}let t=kr.resolve(r);t.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),mt(t,e),console.log(e?`Trusted ${kr.basename(t)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${kr.basename(t)} \u2014 runs Restricted.`),console.log(` ${t}`)}vr();We();import{readFileSync as Ub,existsSync as Jb}from"fs";import*as Ye from"path";import{fileURLToPath as Kb}from"url";function vf(){let r=Ye.dirname(Kb(import.meta.url));for(;!Jb(Ye.join(r,"package.json"));){let e=Ye.dirname(r);if(e===r)break;r=e}return r}function nn(){return Ye.join(vf(),"README.md")}function qo(){return Ye.join(vf(),"description.md")}function Vb(r){return`---
|
|
934
958
|
name: typebulb
|
|
935
|
-
description: ${
|
|
959
|
+
description: ${Ub(qo(),"utf8").trim().replace(/\s+/g," ")}
|
|
936
960
|
version: ${r}
|
|
937
|
-
---`}function
|
|
961
|
+
---`}function Wb(r){return`> Generated from typebulb v${r}. If \`npx typebulb --version\` reports a newer version, re-run \`npx typebulb skill\` to refresh this file.`}function Sf(r,e){return`${Vb(e)}
|
|
938
962
|
|
|
939
|
-
${
|
|
963
|
+
${Wb(e)}
|
|
940
964
|
|
|
941
965
|
${r.trim()}
|
|
942
|
-
`}async function
|
|
966
|
+
`}async function Fo(r,e){let t=q(r);return(await j()).find(s=>s.cwd!=null&&q(s.cwd)===t&&(e?s.agent===e:s.agent!=null))}async function kf(){let r=await Fo(process.cwd()),e=r?.agent,s=[e?`Mirror '${e}' is up at ${r?.url} \u2014 the embedded bulbs render live there.`:"No mirror is running \u2014 to render embedded bulbs live inline, start one with `npx typebulb agent:claude --no-open`; it prints a localhost link that opens the mirror.","","Agents: Read the bulb-authoring skill before writing a bulb \u2014 get it assembled as one SKILL.md with `npx typebulb skill`, or read its parts directly:",` - description: ${qo()}`,` - skill body (the README is the skill): ${nn()}`];process.stdout.write(s.join(`
|
|
943
967
|
`)+`
|
|
944
|
-
`)}import{readFileSync as
|
|
945
|
-
`)){let t=e.trim();if(!t||t.startsWith("#"))continue;let s=t.indexOf("=");if(s===-1)continue;let n=t.slice(0,s).trim(),i=t.slice(s+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[n,i]}}function
|
|
946
|
-
`)}async function Tf(r){if(
|
|
947
|
-
`+e)}function
|
|
968
|
+
`)}import{readFileSync as Yb,existsSync as Hb}from"fs";import*as me from"path";function Gb(r){return[...r?[`.env.${r}.local`,`.env.${r}`]:[],".env.local",".env"]}function ue(r,e=process.cwd()){let t={},s=[];for(let n of Gb(r)){let i;try{i=Yb(me.resolve(e,n),"utf-8")}catch{continue}s.push(n);for(let[o,a]of zb(i))process.env[o]===void 0&&(process.env[o]=a,t[o]=n)}return{mode:r,sources:t,loaded:s}}function*zb(r){for(let e of r.split(`
|
|
969
|
+
`)){let t=e.trim();if(!t||t.startsWith("#"))continue;let s=t.indexOf("=");if(s===-1)continue;let n=t.slice(0,s).trim(),i=t.slice(s+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[n,i]}}function Qb(r){let e=new Set,t=/process\.env\.([A-Za-z_$][\w$]*)|process\.env\[\s*['"]([^'"]+)['"]\s*\]/g;for(let s;s=t.exec(r);)e.add(s[1]??s[2]);return[...e]}function Re(r,e,t){let{sources:s,mode:n,loaded:i}=r,o=process.cwd(),a=me.dirname(e),c=`(mode: ${n??"none"})`,l=t?Qb(t):[],f=l.filter(p=>s[p]).map(p=>`${p} \u2190 ${s[p]}`);f.length?console.log(`env: ${f.join(", ")} ${c}`):i.length&&console.log(`env: loaded ${i.join(", ")} ${c}`),n&&!i.some(p=>p===`.env.${n}`||p===`.env.${n}.local`)&&console.log(`env: mode=${n} \u2014 no .env.${n} found; using .env`);let u=me.resolve(a)!==me.resolve(o);if(u)for(let p of[".env.local",".env"])Hb(me.join(a,p))&&console.log(`env: ${me.join(a,p)} present but not loaded (cwd is ${o})`);let d=l.filter(p=>process.env[p]===void 0);if(d.length){let p=u?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${d.join(", ")} but ${d.length>1?"they are":"it's"} unset${p}`)}}var kt={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"},Xb="https://api.typebulb.com/api/models",Zb=1440*60*1e3,St=null;async function on(){if(!St||Date.now()-St.fetchedAt>Zb){let r=await fetch(Xb);if(!r.ok)return St?xf(St.models):[];St={models:await r.json(),fetchedAt:Date.now()}}return xf(St.models)}function xf(r){let e=new Set(Object.entries(kt).filter(([,t])=>!!process.env[t]).map(([t])=>t));return r.filter(t=>e.has(t.provider))}function Ef(){return Object.values(kt).some(r=>!!process.env[r])}function Af(r,e,t){let s=Math.max(...r.map(o=>o.name.length)),n=Math.max(...r.map(o=>o.friendlyName.length)),i=["Models available to tb.ai (filtered by your .env keys):",""];for(let o of r)i.push(` ${o.name.padEnd(s)} ${o.friendlyName.padEnd(n)} (${o.provider})`);return i.push("","Pass an id as the `model` in tb.ai({ provider, model })."),e&&t&&i.push(`Default (from .env): ${e} / ${t}`),i.join(`
|
|
970
|
+
`)}async function Tf(r){if(ue(r),!Ef()){console.log("No AI provider keys found in this directory's .env. Set one of these to use tb.ai:");for(let[t,s]of Object.entries(kt))console.log(` ${s.padEnd(20)} (${t})`);console.log("Then re-run `typebulb models`.");return}let e=await on();if(e.length===0){console.log("Couldn't fetch the model catalog (offline?). tb.ai still works with any valid provider/model id for your keys.");return}console.log(Af(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL))}import*as Pf from"fs/promises";async function Of(r){let e=nn(),t;try{t=await Pf.readFile(e,"utf8")}catch{console.error(`Could not read the bundled README (expected at ${e}).`),process.exit(1)}process.stdout.write(Sf(t,r))}vr();We();import*as jo from"path";function ew(r,e,t){if(/^\d+$/.test(e))return r.find(n=>n.pid===parseInt(e,10));let s=r.filter(n=>n.agent===e);return s.length?(t?s.find(i=>i.cwd&&q(i.cwd)===q(t)):void 0)??s[0]:r.find(n=>q(n.file)===q(e))}function Nf(r,e){for(let t of r)e(` ${t.url} pid ${t.pid} ${t.trust?"trusted":"restricted"} ${t.file}`)}function Cf(r,e){if(!r.length){console.log("No running bulb servers.");return}console.log("Running bulb servers:"),Nf(r,t=>console.log(t)),console.log(`
|
|
971
|
+
`+e)}function Rf(r,e,t,s){let n=ew(r,e,s);if(n)return n;console.error(`No running server for '${e}'.`),r.length?(console.error(`Running servers (try \`typebulb ${t} <file|pid>\`):`),Nf(r,i=>console.error(i))):console.error("No bulb servers are running."),process.exit(1)}async function If(r,e){if(!r){Cf(await j(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let t=Rf(await j(),r,"logs",process.cwd()),s=wt(t.pid),n=s.text;if(e.lines&&e.lines>0){let i=n.split(`
|
|
948
972
|
`);i.length&&i[i.length-1]===""&&i.pop(),n=i.slice(-e.lines).join(`
|
|
949
973
|
`)}if(process.stdout.write(n),n&&!n.endsWith(`
|
|
950
974
|
`)&&process.stdout.write(`
|
|
951
|
-
`),e.follow){let i=s.offset,o=setInterval(()=>{let c=
|
|
975
|
+
`),e.follow){let i=s.offset,o=setInterval(()=>{let c=wt(t.pid,i);i=c.offset,c.text&&process.stdout.write(c.text)},500),a=()=>{clearInterval(o),process.exit(0)};process.on("SIGINT",a),process.on("SIGTERM",a),await new Promise(()=>{})}}async function _f(r){if(!r){Cf(await j(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=Rf(await j(),r,"stop",process.cwd());await vt(e.pid),console.log(`Stopped ${e.agent??jo.basename(e.file)} (pid ${e.pid}, ${e.url}).`)}async function Lf(r){let e=process.cwd(),t=r==="global"?await j():r==="bulbs"?await j(e):(await j()).filter(n=>n.agent!=null&&n.cwd!=null&&q(n.cwd)===q(e)),s=r==="global"?"server":r==="agent"?"mirror":"bulb";if(!t.length){console.log(r==="global"?"No running bulb servers.":`No running ${s}s for this project.`);return}await Promise.all(t.map(n=>vt(n.pid))),console.log(`Stopped ${t.length} ${s}${t.length===1?"":"s"}:`);for(let n of t)console.log(` ${n.url} pid ${n.pid} ${n.agent??jo.basename(n.file)}`)}import*as Kf from"fs/promises";import*as xt from"path";import{EventEmitter as Jf}from"events";en();import{Hono as iw}from"hono";import{serve as ow}from"@hono/node-server";import{streamSSE as aw}from"hono/streaming";import*as Ge from"fs/promises";import*as oe from"path";var X=class extends Error{constructor(e,t="unknown",s=!1){super(e),this.code=t,this.retryable=s}},ie=class{getPath(e,t){return this.path}parseStreamChunk(e){return this.checkAndThrowError(e),this.parseProviderStreamChunk(e)}isReasoningEnabled(e){return e?.reasoning!==void 0&&e.reasoning>0}extractSystemMessages(e,t=`
|
|
952
976
|
|
|
953
|
-
`){let s=e.filter(n=>n.role==="system").map(n=>n.content);return{system:s.length?s.join(t):void 0,conversationMessages:e.filter(n=>n.role!=="system")}}parseJsonError(e,t,s=!1){if(!e)return{message:`HTTP ${t}`};try{let n=JSON.parse(e);if(n.error&&typeof n.error=="object"){let i={message:n.error.message||`HTTP ${t}`,type:n.error.type};return s&&(i.code=n.error.code),i}return n.message?{message:n.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let t=e;if(t.type==="error"&&"message"in t){let s=t.code||"unknown";throw new X(t.message,s,!!t.retryable)}if(t.error)throw new X(this.extractErrorMessage(t.error))}extractErrorMessage(e){if(typeof e=="string")try{let t=JSON.parse(e);return t.error?.message||t.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}};var an=class extends
|
|
977
|
+
`){let s=e.filter(n=>n.role==="system").map(n=>n.content);return{system:s.length?s.join(t):void 0,conversationMessages:e.filter(n=>n.role!=="system")}}parseJsonError(e,t,s=!1){if(!e)return{message:`HTTP ${t}`};try{let n=JSON.parse(e);if(n.error&&typeof n.error=="object"){let i={message:n.error.message||`HTTP ${t}`,type:n.error.type};return s&&(i.code=n.error.code),i}return n.message?{message:n.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let t=e;if(t.type==="error"&&"message"in t){let s=t.code||"unknown";throw new X(t.message,s,!!t.retryable)}if(t.error)throw new X(this.extractErrorMessage(t.error))}extractErrorMessage(e){if(typeof e=="string")try{let t=JSON.parse(e);return t.error?.message||t.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}};var an=class extends ie{constructor(){super(...arguments),this.providerName="OpenAI",this.defaultBaseUrl="https://api.openai.com",this.path="/v1/responses",this.effortMap={0:"minimal",1:"low",2:"medium",3:"high"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,t,s,n){let i=this.convertMessagesToInput(e),o={model:t,input:i,stream:n};return s?.webSearch!==!1&&(o.tools=[{type:"web_search"}]),this.isReasoningEnabled(s)&&(o.reasoning={effort:this.effortMap[s.reasoning],summary:"auto"}),o}parseError(e,t){return this.parseJsonError(e,t,!0)}parseNonStreamingResponse(e){if(!this.isResponsesApiResponse(e))return{text:""};let t=e.output_text||"",s;if(e.output&&Array.isArray(e.output))for(let n of e.output)n.type==="reasoning"&&n.summary&&(s=n.summary.map(i=>i.text).join(`
|
|
954
978
|
`)),!t&&n.type==="message"&&n.content&&(t=n.content.filter(i=>i.type==="output_text").map(i=>i.text).join(""));return{text:t,reasoning:s}}parseProviderStreamChunk(e){if(!this.isResponsesApiEvent(e))return null;switch(e.type){case"error":return null;case"response.failed":{let n=e.response?.error,i=n?.message||"Response failed",o=n?.code==="insufficient_quota"||n?.code==="rate_limit_exceeded";throw new X(i,o?"rate_limit":"unknown",o)}case"response.output_text.delta":return{text:e.delta};case"response.reasoning_summary_text.delta":return{reasoning:e.delta};case"response.created":case"response.in_progress":case"response.output_item.added":case"response.output_item.done":case"response.content_part.added":case"response.content_part.done":case"response.output_text.done":case"response.output_text.annotation.added":case"response.reasoning_summary_text.done":case"response.completed":case"response.web_search_call.in_progress":case"response.web_search_call.searching":case"response.web_search_call.completed":return null;default:return null}}convertMessagesToInput(e){return e.map(t=>t.role==="system"?`System: ${t.content}`:t.role==="user"?`User: ${t.content}`:t.role==="assistant"?`Assistant: ${t.content}`:t.content).join(`
|
|
955
979
|
|
|
956
|
-
`)}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 cn=class extends
|
|
980
|
+
`)}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 cn=class extends ie{constructor(){super(...arguments),this.providerName="OpenRouter",this.defaultBaseUrl="https://openrouter.ai/api",this.path="/api/v1/chat/completions",this.effortMap={0:"low",1:"low",2:"medium",3:"high"}}buildHeaders(e,t){let s={Authorization:`Bearer ${e}`,"x-api-key":e,"Content-Type":"application/json",Accept:"application/json","X-Title":"Typebulb"};return t&&(s["HTTP-Referer"]=t,s.Referer=t,s.Origin=t),s}buildPayload(e,t,s,n){let i={model:t,messages:e,stream:n};return s?.webSearch===!0&&(i.plugins=[{id:"web"}]),this.isReasoningEnabled(s)&&(i.reasoning={effort:this.effortMap[s.reasoning]}),i}parseError(e,t){return this.parseJsonError(e,t,!0)}parseNonStreamingResponse(e){if(!this.hasChoices(e))return{text:""};let t=e,s=t.choices[0],n=s?.message?.content??s?.text??"",i=s?.message?.reasoning??t.reasoning;return{text:n,reasoning:i}}parseProviderStreamChunk(e){if(!this.hasChoices(e))return null;let t=e.choices[0];if(!t)return null;let s=t.delta||t.message;if(!s)return null;let n=s.content||void 0,i=s.reasoning||void 0;return!n&&!i?null:{text:n,reasoning:i}}hasChoices(e){return typeof e=="object"&&e!==null&&"choices"in e&&Array.isArray(e.choices)}};var ln=class extends ie{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,t,s,n){let{system:i,conversationMessages:o}=this.extractSystemMessages(e),a={model:t,max_tokens:this.getMaxTokens(t),messages:this.withLastMessageCached(o),stream:n};if(s?.webSearch!==!1&&(a.tools=[{type:"web_search_20250305",name:"web_search"}]),i&&(a.system=[{type:"text",text:i,cache_control:{type:"ephemeral"}}]),this.isReasoningEnabled(s)){let c=s.reasoning;if(this.isModernModel(t)){let l={0:"low",1:"low",2:"medium",3:"high"};a.thinking={type:"adaptive"},a.output_config={effort:l[c]}}else{let l={0:0,1:2048,2:4096,3:8192};a.thinking={type:"enabled",budget_tokens:l[c]}}}return a}parseError(e,t){return this.parseJsonError(e,t)}parseNonStreamingResponse(e){if(!this.isAnthropicResponse(e))return{text:""};let t=e.content.filter(n=>n.type==="text").map(n=>n.text).join(""),s=e.content.filter(n=>n.type==="thinking").map(n=>n.thinking).join(`
|
|
957
981
|
|
|
958
|
-
`);return{text:t,reasoning:s||void 0}}parseProviderStreamChunk(e){if(!this.isAnthropicEvent(e))return null;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||""}:null;case"message_start":case"content_block_start":case"content_block_stop":case"message_delta":case"message_stop":case"ping":return null;default:return null}}withLastMessageCached(e){let t=e.length-1;return e.map((s,n)=>n===t?{role:s.role,content:[{type:"text",text:s.content,cache_control:{type:"ephemeral"}}]}:s)}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 t=e.match(/^claude-\w+-(\d+)-(\d+)/);return!!t&&(+t[1]>4||+t[1]==4&&+t[2]>=6)}getMaxTokens(e){return this.isModernModel(e)?64e3:32e3}};var un=class extends
|
|
982
|
+
`);return{text:t,reasoning:s||void 0}}parseProviderStreamChunk(e){if(!this.isAnthropicEvent(e))return null;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||""}:null;case"message_start":case"content_block_start":case"content_block_stop":case"message_delta":case"message_stop":case"ping":return null;default:return null}}withLastMessageCached(e){let t=e.length-1;return e.map((s,n)=>n===t?{role:s.role,content:[{type:"text",text:s.content,cache_control:{type:"ephemeral"}}]}:s)}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 t=e.match(/^claude-\w+-(\d+)-(\d+)/);return!!t&&(+t[1]>4||+t[1]==4&&+t[2]>=6)}getMaxTokens(e){return this.isModernModel(e)?64e3:32e3}};var un=class extends ie{constructor(){super(...arguments),this.providerName="Gemini",this.defaultBaseUrl="https://generativelanguage.googleapis.com",this.path="/v1beta/models"}getPath(e,t){return`/v1beta/models/${e}:${t?"streamGenerateContent":"generateContent"}${t?"?alt=sse":""}`}buildHeaders(e){return{"Content-Type":"application/json","x-goog-api-key":e}}buildPayload(e,t,s,n){let{system:i,conversationMessages:o}=this.extractSystemMessages(e,`
|
|
959
983
|
`),c={contents:o.map(l=>({role:l.role==="assistant"?"model":"user",parts:[{text:l.content}]}))};return s?.webSearch!==!1&&(c.tools=[{google_search:{}}]),i&&(c.systemInstruction={role:"system",parts:[{text:i}]}),this.isReasoningEnabled(s)&&(c.generationConfig={temperature:.7+s.reasoning*.1}),c}parseError(e,t){if(!e)return{message:`HTTP ${t}`};try{let s=JSON.parse(e),n=Array.isArray(s)?s[0]?.error:s?.error;return n&&typeof n=="object"?{message:(n.message||`HTTP ${t}`).split(`
|
|
960
|
-
`)[0],type:n.status,code:n.code?.toString()}:s.message?{message:s.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let t=this.extractText(e)||"",s=e.candidates?.[0]?.finishReason,n="complete";return s==="MAX_TOKENS"?n="interrupted":(s==="SAFETY"||s==="RECITATION")&&(n="failed"),{text:t,status:n}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return null;let t=this.extractText(e);return t?{text:t}:null}isGeminiResponse(e){return typeof e=="object"&&e!==null&&"candidates"in e&&Array.isArray(e.candidates)}extractText(e){let t=e.candidates?.[0];if(t?.content?.parts)return t.content.parts.map(s=>s.text).filter(Boolean).join("")}checkGeminiError(e){if(typeof e=="object"&&e!==null&&"error"in e){let t=e.error,s;if(typeof t=="string")s=t;else if(typeof t=="object"&&t!==null){let n=t;s=n.message||n.status||"Gemini returned an error"}else s="Gemini returned an error";throw new X(s)}if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let t=e.promptFeedback.blockReason;throw new X(`Prompt blocked: ${t}`)}}};var
|
|
984
|
+
`)[0],type:n.status,code:n.code?.toString()}:s.message?{message:s.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let t=this.extractText(e)||"",s=e.candidates?.[0]?.finishReason,n="complete";return s==="MAX_TOKENS"?n="interrupted":(s==="SAFETY"||s==="RECITATION")&&(n="failed"),{text:t,status:n}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return null;let t=this.extractText(e);return t?{text:t}:null}isGeminiResponse(e){return typeof e=="object"&&e!==null&&"candidates"in e&&Array.isArray(e.candidates)}extractText(e){let t=e.candidates?.[0];if(t?.content?.parts)return t.content.parts.map(s=>s.text).filter(Boolean).join("")}checkGeminiError(e){if(typeof e=="object"&&e!==null&&"error"in e){let t=e.error,s;if(typeof t=="string")s=t;else if(typeof t=="object"&&t!==null){let n=t;s=n.message||n.status||"Gemini returned an error"}else s="Gemini returned an error";throw new X(s)}if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let t=e.promptFeedback.blockReason;throw new X(`Prompt blocked: ${t}`)}}};var tw=new Map([["openai",new an],["openrouter",new cn],["anthropic",new ln],["gemini",new un]]);function He(r){let e=tw.get(r);if(!e)throw new Error(`Unsupported protocol: ${r}`);return e}async function Uo(r,e){let t=He(r.protocol),s=t.getPath(e.model,e.stream),n=new URL(s,r.baseUrl).toString(),i=t.buildHeaders(r.apiKey,e.origin),o=t.buildPayload(e.messages,e.model,{reasoning:e.reasoning,webSearch:e.webSearch},e.stream);return e.modifyPayload?.(o),fetch(n,{method:"POST",headers:i,body:JSON.stringify(o),signal:e.signal})}async function Jo(r,e){let t=He(e),s=await r.text().catch(()=>""),{message:n}=t.parseError(s,r.status),i=r.status,o="unknown";return i===429?o="rate_limit":i===413&&(o="context_exceeded"),{code:o,message:n,retryable:i===429}}function $f(r){let e=r.indexOf(`\r
|
|
961
985
|
\r
|
|
962
986
|
`),t=r.indexOf(`
|
|
963
987
|
|
|
964
988
|
`);return e!==-1&&(t===-1||e<t)?{pos:e,len:4}:t!==-1?{pos:t,len:2}:{pos:-1,len:0}}function Ko(r){let t=r.split(/\r?\n/).filter(n=>n.startsWith("data:"));if(!t.length)return null;let s=t.map(n=>n.replace(/^data:\s?/,"")).join(`
|
|
965
|
-
`).trim();if(!s)return null;if(s==="[DONE]")return"done";try{return JSON.parse(s)}catch{return null}}async function
|
|
966
|
-
${c}`:"";return m.text(`Forbidden: this capability requires --trust.${
|
|
967
|
-
${f.name}`),console.log(` ${g}`),d!==e.port&&console.log(` (port ${e.port} was busy)`),e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(
|
|
989
|
+
`).trim();if(!s)return null;if(s==="[DONE]")return"done";try{return JSON.parse(s)}catch{return null}}async function Mf(r,e,t){let s=new TextDecoder,n="",i=!1,o=t?new Promise((a,c)=>{t.aborted&&c(new Error("Aborted")),t.addEventListener("abort",()=>c(new Error("Aborted")),{once:!0})}):null;for(;;){let a=o?await Promise.race([r.read(),o]):await r.read(),{done:c,value:l}=a;if(c){if(n.trim()){let d=Ko(n);d!==null&&d!=="done"&&e(d)}break}i=!0,n+=s.decode(l,{stream:!0});let{pos:f,len:u}=$f(n);for(;f!==-1;){let d=n.slice(0,f);n=n.slice(f+u);let p=Ko(d);if(p==="done"){n="";break}p!==null&&e(p),{pos:f,len:u}=$f(n)}}return{receivedAnyData:i}}async function Vo(r,e){let t=e??(r.headers.get("X-Provider-Protocol")||"openai"),s=He(t);if(!r.body)throw new Error("Response body is missing");let n=r.body.getReader(),i="";return await Mf(n,o=>{let a=s.parseStreamChunk(o);a?.text&&(i+=a.text)}),i}import*as Wo from"fs/promises";import*as Tr from"path";var fn=class{async get(e){let t=te(e),s=Tr.join(br,t+".bin"),n=Tr.join(br,t+".json");try{let[i,o]=await Promise.all([Wo.readFile(s),Wo.readFile(n,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,t){await I();let s=te(e),n=Tr.join(br,s+".bin"),i=Tr.join(br,s+".json"),o={url:e,contentType:t.contentType,cacheControl:t.cacheControl};await Promise.all([z(n,t.body),z(i,JSON.stringify(o))])}};We();var Yo={log:(...r)=>console.log(...r)};function dn(r,e){let t=r?.[e]??Yo[e];return typeof t=="function"?t:void 0}var rw=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,sw=/[?&]target=/,nw=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function Df(r,e=""){return rw.test(r)?!0:nw.test(r)&&sw.test(e)}var Ff="127.0.0.1",cw=new Set(["localhost","127.0.0.1","::1"]);function lw(r){if(r)try{return new URL(r.includes("://")?r:`http://${r}`).hostname}catch{return}}function Bf(r){let e=lw(r);return!!e&&cw.has(e)}function pn(r){return r instanceof Error?r.message:"Unknown error"}async function hn(r){let{getHtml:e,basePath:t,port:s,reloadEmitter:n,getServerExports:i,localOverride:o,trusted:a=!1,trustHint:c,staticAssets:l}=r,f=new iw;f.use("*",async(m,b)=>{if(!Bf(m.req.header("host")))return m.text("Forbidden: untrusted Host",403);await b()}),f.use("*",async(m,b)=>{await b(),m.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),m.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let u=["/__fs/*","/__api/*","/__ai"],d=async(m,b)=>{if(!a){let w=new URL(m.req.url).pathname,x=w.startsWith("/__fs")?"the filesystem":w==="/__ai"?"AI (your API keys)":"server-side code (server.ts)";wf(process.pid,x);let E=c?`
|
|
990
|
+
${c}`:"";return m.text(`Forbidden: this capability requires --trust.${E}`,403)}await b()},p=async(m,b)=>{let w=m.req.header("sec-fetch-site");if(w){if(w==="cross-site")return m.text("Forbidden: cross-site request",403)}else{let x=m.req.header("origin");if(x&&!Bf(x))return m.text("Forbidden: cross-origin request",403)}await b()};for(let m of u)f.use(m,d),f.use(m,p);f.use("/__log",p),f.post("/__log",async m=>{try{let{args:b}=await m.req.json();console.log(...b||[])}catch{}return m.json({ok:!0})}),f.get("/",m=>m.html(e())),f.post("/__fs/read",async m=>{try{let{path:b}=await m.req.json(),w=Go(b,t),x=await Ge.readFile(w);return new Response(new Uint8Array(x),{headers:{"Content-Type":"application/octet-stream"}})}catch(b){let w=pn(b);return m.json({error:w},400)}}),f.post("/__fs/write",async m=>{try{let b=m.req.query("path");if(!b)return m.json({error:"Missing path"},400);let w=Go(b,t);return await Ge.mkdir(oe.dirname(w),{recursive:!0}),await Ge.writeFile(w,Buffer.from(await m.req.arrayBuffer())),m.json({success:!0})}catch(b){let w=pn(b);return m.json({error:w},400)}}),f.post("/__api/:name",async m=>{try{let b=m.req.param("name"),w=dn(i?.(),b);if(!w)return m.json({error:`API function '${b}' not found`},404);let{args:x}=await m.req.json(),E=await w(...x||[]);return m.json({result:E})}catch(b){let w=pn(b);return m.json({error:w},500)}}),f.post("/__ai",async m=>{try{let{messages:b,system:w,reasoning:x,provider:E,model:T,webSearch:S}=await m.req.json();if(!b||!Array.isArray(b)||b.length===0)return m.json({message:"messages array is required",code:"unknown",retryable:!1},400);let O=uw(E,T);if(typeof O=="string")return m.json({message:O,code:"unknown",retryable:!1},400);let U=[...w?[{role:"system",content:w}]:[],...b.map(Ie=>({role:Ie.role,content:Ie.content}))],H=await Uo(O,{model:O.model,messages:U,stream:!0,reasoning:x??0,webSearch:S??!0});if(!H.ok){let Ie=await Jo(H,O.protocol);return m.json(Ie,H.status)}let R=await Vo(H,O.protocol);return R||console.warn("[tb.ai] Empty response from provider"),m.json({text:R})}catch(b){if(b instanceof X)return m.json({message:b.message,code:b.code,retryable:b.retryable},500);let w=pn(b);return m.json({message:w,code:"unknown",retryable:!1},500)}}),f.get("/__models",async m=>{try{let b=await on();return m.json(b)}catch{return m.json([],200)}});let g=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],h=new fn;f.get("/proxy/*",async m=>{let b=new URL(m.req.url),x=(b.pathname+b.search).slice(7),E=x.lastIndexOf("https://");return E===-1?m.text("Invalid proxy URL",400):y(m,x.slice(E))}),o&&qf(f,`/local/${o.name}/`,o.serveDir),l&&qf(f,l.mount,l.dir);async function y(m,b){let w;try{w=new URL(b)}catch{return m.text("Invalid URL",400)}if(w.protocol!=="https:")return m.text("HTTPS only",400);if(!g.includes(w.hostname))return m.text("Host not allowed",403);let x=await h.get(b);if(x)return new Response(x.body,{status:200,headers:Ho(x.contentType,x.cacheControl)});try{let E=await fetch(b,{headers:{Accept:m.req.header("Accept")||"*/*"},redirect:"follow"});if(!E.ok)return m.text(`Upstream ${E.status}`,E.status);let T=E.headers.get("Content-Type")||void 0,S=E.headers.get("Cache-Control")||void 0;if(E.body){let[O,U]=E.body.tee();return(async()=>{try{let H=await new Response(U).arrayBuffer();await h.set(b,{body:Buffer.from(H),contentType:T,cacheControl:S})}catch{}})(),new Response(O,{status:E.status,headers:Ho(T,S)})}return new Response(null,{status:E.status,headers:Ho(T,S)})}catch(E){return m.text(`Proxy fetch failed: ${E instanceof Error?E.message:E}`,502)}}n&&f.get("/__reload",m=>aw(m,async b=>{let w=()=>{b.writeSSE({event:"reload",data:""})};for(n.on("reload",w),b.onAbort(()=>{n.removeListener("reload",w)});;)await b.sleep(3e4)})),f.notFound(async m=>{if(m.req.method!=="GET")return m.text("Not Found",404);let b=new URL(m.req.url);return Df(b.pathname,b.search)?y(m,"https://esm.sh"+b.pathname+b.search):m.text("Not Found",404)});let k=ow({fetch:f.fetch,port:s,hostname:Ff});return{port:s,close:()=>k.close()}}function uw(r,e){let t=r??process.env.TB_AI_PROVIDER,s=e??process.env.TB_AI_MODEL;if(!t)return"No provider specified. Set TB_AI_PROVIDER in your .env file or pass provider in the tb.ai() call.";if(!s)return"No model specified. Set TB_AI_MODEL in your .env file or pass model in the tb.ai() call.";let n;try{n=He(t)}catch{return`Unknown provider '${t}'.`}let i=kt[t],o=process.env[i];return o?{apiKey:o,baseUrl:n.defaultBaseUrl,protocol:t,model:s,isFreeModel:!1}:`No API key for '${t}'. Set ${i} in your .env file.`}function Ho(r,e){let t=new Headers;return r&&t.set("Content-Type",r),e&&t.set("Cache-Control",e),t.set("Access-Control-Allow-Origin","*"),t.set("Cross-Origin-Resource-Policy","cross-origin"),t}function qf(r,e,t){r.get(`${e}*`,async s=>{let{pathname:n}=new URL(s.req.url);if(!n.startsWith(e))return s.text("Not Found",404);let i=decodeURIComponent(n.slice(e.length));try{let o=Go(i,t),a=await Ge.readFile(o);return new Response(a,{headers:{"Content-Type":fw(o)}})}catch{return s.text("Not Found",404)}})}function fw(r){switch(oe.extname(r).toLowerCase()){case".js":case".mjs":return"text/javascript";case".wasm":return"application/wasm";case".json":case".map":return"application/json";default:return"application/octet-stream"}}function Go(r,e){let t=oe.resolve(e,r),s=oe.normalize(e),n=oe.normalize(t);if(n!==s&&!n.startsWith(s+oe.sep))throw new Error("Path traversal detected - access denied");return t}async function Pr(r){let e=await import("net");return new Promise(t=>{let s=e.createServer();s.listen(r,Ff,()=>{let n=s.address(),i=typeof n=="object"&&n?n.port:r;s.close(()=>t(i))}),s.on("error",()=>{t(Pr(r+1))})})}import jf from"chokidar";var Uf={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function mn(r){let{bulbPath:e,emitter:t}=r,s=jf.watch(e,Uf);return s.on("change",()=>{t.emit("reload")}),()=>s.close()}function gn(r){let{dir:e,onChange:t,debounceMs:s=150}=r,n,i=jf.watch(e,Uf);return i.on("all",()=>{n&&clearTimeout(n),n=setTimeout(t,s)}),()=>{n&&clearTimeout(n),i.close()}}We();async function Vf(r,e,t,s,n){let i=process.cwd(),o=tn(process.pid),a=e.watch?new Jf:void 0,c=ue(e.mode);console.log(`Loading ${xt.basename(r)}...`);let{html:l,bulb:f,serverExports:u}=await Ro(r,e.watch,e.trust,s,n);Re(c,r,f.server);let d=await Pr(e.port),p=await hn({getHtml:()=>l,basePath:i,port:d,reloadEmitter:a,getServerExports:()=>u,localOverride:s?{name:s.name,serveDir:s.serveDir}:void 0,trusted:e.trust,trustHint:t}),g=`http://localhost:${d}`,h=e.trust?void 0:bt(f);await rn({pid:process.pid,port:d,url:g,file:r,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,predicted:h}),console.log(`
|
|
991
|
+
${f.name}`),console.log(` ${g}`),d!==e.port&&console.log(` (port ${e.port} was busy)`),e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(h?` trust: sandboxed \u2014 this bulb appears to use ${h}; re-run with --trust to enable it:
|
|
968
992
|
${t}
|
|
969
993
|
`:` trust: sandboxed \u2014 re-run with --trust to enable filesystem / AI / server.ts
|
|
970
994
|
`),e.watch&&console.log(` Watching for changes...
|
|
971
|
-
`);let y,
|
|
972
|
-
`)}catch(
|
|
973
|
-
`),a.emit("reload")}})}}e.open&&await
|
|
974
|
-
Shutting down...`),
|
|
995
|
+
`);let y,k;if(e.watch&&a){let b=new Jf;if(b.on("reload",async()=>{try{console.log("Recompiling...");let w=await Ro(r,!0,e.trust,s,n);l=w.html,u=w.serverExports,a.emit("reload"),console.log(`Done. Browser reloading...
|
|
996
|
+
`)}catch(w){console.error("Compile error:",w)}}),y=mn({bulbPath:r,emitter:b}),s){let{name:w,serveDir:x}=s;k=gn({dir:x,onChange:()=>{console.log(`Local package '${w}' changed. Browser reloading...
|
|
997
|
+
`),a.emit("reload")}})}}e.open&&await gt(g);let m=async()=>{console.log(`
|
|
998
|
+
Shutting down...`),p.close(),y?.(),k?.(),o(),await Ar(process.pid);let b=xt.join(xt.dirname(r),".typebulb","server.mjs");await Kf.rm(b,{force:!0}).catch(()=>{}),process.exit(0)};process.on("SIGINT",m),process.on("SIGTERM",m)}import{readFileSync as vd,copyFileSync as ov,existsSync as av}from"fs";import*as Y from"path";import{fileURLToPath as cv}from"url";import{EventEmitter as lv}from"events";We();var zo="/agents/claude/client.js",dw=`
|
|
975
999
|
(() => {
|
|
976
1000
|
const api = async (name, ...args) => {
|
|
977
1001
|
const resp = await fetch('/__api/' + name, {
|
|
@@ -1006,15 +1030,15 @@ Shutting down...`),h.close(),y?.(),x?.(),o(),await Er(process.pid);let E=xt.join
|
|
|
1006
1030
|
es.onerror = () => { es.close(); };
|
|
1007
1031
|
}
|
|
1008
1032
|
})();
|
|
1009
|
-
`;function
|
|
1033
|
+
`;function Wf(r){let{name:e,styles:t,mountHtml:s,watch:n,theme:i}=r;return`<!DOCTYPE html>
|
|
1010
1034
|
<html>
|
|
1011
1035
|
<head>
|
|
1012
1036
|
<meta charset="utf-8">
|
|
1013
1037
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1014
1038
|
<title>${Us(e)} - typebulb</title>
|
|
1015
|
-
${
|
|
1039
|
+
${Ks(e,i)}
|
|
1016
1040
|
<style>
|
|
1017
|
-
${
|
|
1041
|
+
${Js}
|
|
1018
1042
|
</style>
|
|
1019
1043
|
<style>
|
|
1020
1044
|
${t}
|
|
@@ -1026,16 +1050,18 @@ ${s}
|
|
|
1026
1050
|
${n?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
|
|
1027
1051
|
|
|
1028
1052
|
<script>
|
|
1029
|
-
${
|
|
1053
|
+
${dw}
|
|
1030
1054
|
</script>
|
|
1031
1055
|
|
|
1032
|
-
<script type="module" src="${
|
|
1056
|
+
<script type="module" src="${zo}"></script>
|
|
1033
1057
|
</body>
|
|
1034
|
-
</html>`}async function
|
|
1058
|
+
</html>`}async function Sd(r){let e=process.cwd(),t=tn(process.pid),s=r.watch?new lv:void 0,n=ue(r.mode),i=await Promise.resolve().then(()=>(wd(),bd));Re(n,Y.join(e,"mirror"));let o=Y.dirname(cv(import.meta.url)),a=Y.join(o,"agents","claude"),c=Y.join(o,"..","agents","claude"),l=Y.join(a,"styles.css"),f=Y.join(a,"index.html"),u=()=>Wf({name:"Claude Bulb",styles:vd(l,"utf8"),mountHtml:vd(f,"utf8"),watch:r.watch}),d=await Pr(r.port),p=await hn({getHtml:u,basePath:e,port:d,reloadEmitter:s,getServerExports:()=>i,trusted:!0,staticAssets:{mount:`${Y.posix.dirname(zo)}/`,dir:a}}),g=`http://localhost:${d}`;await rn({pid:process.pid,port:d,url:g,file:"agent:claude",cwd:e,startedAt:Date.now(),trust:!0,agent:"claude"}),console.log(`
|
|
1035
1059
|
Claude Bulb`),console.log(` ${g}`),d!==r.port&&console.log(` (port ${r.port} was busy)`),r.watch&&console.log(` Watching for changes...
|
|
1036
|
-
`);async function
|
|
1037
|
-
`),s.emit("reload")}catch(
|
|
1038
|
-
Shutting down...`),
|
|
1039
|
-
`);let c=new
|
|
1040
|
-
|
|
1041
|
-
|
|
1060
|
+
`);async function h(){await(await import("esbuild")).build({entryPoints:[Y.join(c,"client","index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:Y.join(a,"client.js")});for(let b of["styles.css","index.html"])ov(Y.join(c,b),Y.join(a,b))}let y;if(r.watch&&s){let m=av(c),b=!1;y=gn({dir:m?c:a,onChange:async()=>{if(!b){b=!0;try{m&&await h(),console.log(`Mirror rebuilt. Browser reloading...
|
|
1061
|
+
`),s.emit("reload")}catch(w){console.error("Mirror rebuild failed:",w instanceof Error?w.message:w)}finally{b=!1}}}})}r.open&&await gt(g);let k=async()=>{console.log(`
|
|
1062
|
+
Shutting down...`),p.close(),y?.(),t(),await Ar(process.pid),process.exit(0)};process.on("SIGINT",k),process.on("SIGTERM",k)}import*as kd from"path";import{EventEmitter as uv}from"events";async function xd(r,e,t,s,n){let i=ue(t),o=!1,a=async()=>{let{bulb:c,config:l}=await se(r);o||(Re(i,r,c.server),o=!0),await wr(c.server,n,s,l.dependencies)};if(console.log(`Running ${kd.basename(r)}...`),await a(),e){console.log(`Watching for changes...
|
|
1063
|
+
`);let c=new uv;c.on("reload",async()=>{try{console.log("Re-running..."),await a()}catch(l){console.error("Error:",l)}}),mn({bulbPath:r,emitter:c})}}import{Console as fv}from"node:console";async function Ed(r,e,t,s,n){yv();let i=ue(t),{bulb:o,config:a}=await se(r);o.server||Sn("This bulb has no **server.ts** block; nothing to call."),Re(i,r,o.server);let c;try{c=await wr(o.server,n,s,a.dependencies)}catch(p){Sn(p instanceof Error?p.message:String(p))}let l=dn(c,e.fn);if(!l){let p=[...Object.keys(c).filter(g=>typeof c[g]=="function"),...Object.keys(Yo)];Sn(`Function '${e.fn}' not found. Available: ${p.length?p.join(", "):"(none)"}.`)}let f=await dv(e),u;try{u=await l(...f)}catch(p){Sn(p instanceof Error?p.stack??p.message:String(p))}let d=mv(u);d!==void 0&&await bv(d+`
|
|
1064
|
+
`),process.exit(0)}async function dv(r){if(r.hasArgsFlag){let e=r.argsJson??"";return e==="-"&&(e=await wv()),hv(e)}return pv(r.positional)}function pv(r){return r.map(e=>{try{return JSON.parse(e)}catch{return e}})}function hv(r){let e;try{e=JSON.parse(r)}catch(t){throw new Error(`--args must be a JSON array: ${t instanceof Error?t.message:String(t)}`)}if(!Array.isArray(e))throw new Error(`--args must be a JSON array, got ${e===null?"null":typeof e}`);return e}function mv(r){if(r!==void 0)return JSON.stringify(r,gv,2)}function gv(r,e){return typeof e=="bigint"?e.toString():e}function Sn(r){process.stderr.write(r+`
|
|
1065
|
+
`),process.exit(1)}function yv(){let r=new fv(process.stderr,process.stderr);console.log=r.log.bind(r),console.info=r.info.bind(r),console.debug=r.debug.bind(r),console.dir=r.dir.bind(r)}function bv(r){return new Promise((e,t)=>{process.stdout.write(r,s=>s?t(s):e())})}async function wv(){let r=[];for await(let e of process.stdin)r.push(e);return Buffer.concat(r).toString("utf-8")}var Ad="0.13.2";function Td(r,e){r||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
|
|
1066
|
+
${e}`),process.exit(1))}async function vv(){let r=ya(process.argv.slice(2));if(r.version&&(console.log(`typebulb ${Ad}`),process.exit(0)),r.help&&(ba(),process.exit(0)),r.subcommand==="logs"){await If(r.file||void 0,{follow:r.follow,lines:r.lines});return}if(r.subcommand==="stop"){r.stopScope?await Lf(r.stopScope):await _f(r.file||void 0);return}if(r.subcommand==="skill"){await Of(Ad);return}if(r.subcommand==="models"){await Tf(r.mode);return}if(r.subcommand==="agent"){if(!r.agentTarget){await kf();return}tf(r.agentTarget)||(console.error(`Unknown agent '${r.agentTarget}'. Known: ${$o().join(", ")}.`),process.exit(1));let l=await Fo(process.cwd(),r.agentTarget);if(l){console.log(`Mirror '${r.agentTarget}' is already running for this project:
|
|
1067
|
+
${l.url}`),r.open&&await gt(l.url);return}await Sd(r);return}if(r.subcommand==="trust"||r.subcommand==="untrust"){await df(r.file||void 0,r.subcommand==="trust");return}let e;if(!r.file||r.file==="."){let l=await Qu(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=ge.resolve(r.file);await Pd.access(e).then(()=>!0,()=>!1)||($o().includes(r.file)&&(console.error(`To open the ${r.file} agent mirror, run: npx typebulb agent:${r.file}`),process.exit(1)),console.error(`File not found: ${e}`),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));let s=r.file&&r.file!=="."?r.file:ge.relative(process.cwd(),e)||ge.basename(e),n=`npx typebulb --trust ${s.includes(" ")?`"${s}"`:s}`;if(r.subcommand==="predict"){await ff(e,n);return}let i=!r.noTrust&&Je(e);i&&!r.trust&&console.log("trust: granted from memory (run `typebulb untrust` to revoke)"),r.trust=r.noTrust?!1:r.trust||i;let o;try{o=await se(e)}catch{}let a;if(r.local){o&&!(r.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${r.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&r.subcommand!=="call"&&(!o.bulb.code||r.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await ma(r.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.log(`replace: ${a.name} \u2192 ${ge.relative(process.cwd(),a.dir)||"."}`)}if(r.subcommand==="check"){await uf(e,a);return}let c=ge.dirname(e);if(r.subcommand==="call"){Td(r.trust,n),await Ed(e,{fn:r.fn,positional:r.callArgs,argsJson:r.argsJson,hasArgsFlag:r.hasArgsFlag},r.mode,a,c);return}if(o&&o.bulb.server&&(!o.bulb.code||r.server)){Td(r.trust,n),await xd(e,r.watch,r.mode,a,c);return}await Vf(e,r,n,a,c)}vv().catch(r=>{console.error("Error:",r.message),process.exit(1)});
|