@mcp-com-ai/plugin-capability-graph 0.0.0-stage → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,315 @@
1
+ // @bun
2
+ var C=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Bt=import.meta.require;var I=C(function(Bp){var Fn=Symbol.for("yaml.alias"),Xr=Symbol.for("yaml.document"),si=Symbol.for("yaml.map"),Qr=Symbol.for("yaml.pair"),qn=Symbol.for("yaml.scalar"),oi=Symbol.for("yaml.seq"),ce=Symbol.for("yaml.node.type"),Dp=(e)=>!!e&&typeof e==="object"&&e[ce]===Fn,Lp=(e)=>!!e&&typeof e==="object"&&e[ce]===Xr,Mp=(e)=>!!e&&typeof e==="object"&&e[ce]===si,Rp=(e)=>!!e&&typeof e==="object"&&e[ce]===Qr,Zr=(e)=>!!e&&typeof e==="object"&&e[ce]===qn,_p=(e)=>!!e&&typeof e==="object"&&e[ce]===oi;function es(e){if(e&&typeof e==="object")switch(e[ce]){case si:case oi:return!0}return!1}function jp(e){if(e&&typeof e==="object")switch(e[ce]){case Fn:case si:case qn:case oi:return!0}return!1}var zp=(e)=>(Zr(e)||es(e))&&!!e.anchor;Bp.ALIAS=Fn;Bp.DOC=Xr;Bp.MAP=si;Bp.NODE_TYPE=ce;Bp.PAIR=Qr;Bp.SCALAR=qn;Bp.SEQ=oi;Bp.hasAnchor=zp;Bp.isAlias=Dp;Bp.isCollection=es;Bp.isDocument=Lp;Bp.isMap=Mp;Bp.isNode=jp;Bp.isPair=Rp;Bp.isScalar=Zr;Bp.isSeq=_p});var gt=C(function(od){var M=I(),z=Symbol("break visit"),ts=Symbol("skip children"),ae=Symbol("remove node");function li(e,t){let i=is(t);if(M.isDocument(e)){if(We(null,e.contents,i,Object.freeze([e]))===ae)e.contents=null}else We(null,e,i,Object.freeze([]))}li.BREAK=z;li.SKIP=ts;li.REMOVE=ae;function We(e,t,i,n){let a=ns(e,t,i,n);if(M.isNode(a)||M.isPair(a))return as(e,n,a),We(e,a,i,n);if(typeof a!=="symbol"){if(M.isCollection(t)){n=Object.freeze(n.concat(t));for(let r=0;r<t.items.length;++r){let s=We(r,t.items[r],i,n);if(typeof s==="number")r=s-1;else if(s===z)return z;else if(s===ae)t.items.splice(r,1),r-=1}}else if(M.isPair(t)){n=Object.freeze(n.concat(t));let r=We("key",t.key,i,n);if(r===z)return z;else if(r===ae)t.key=null;let s=We("value",t.value,i,n);if(s===z)return z;else if(s===ae)t.value=null}}return a}async function ci(e,t){let i=is(t);if(M.isDocument(e)){if(await Xe(null,e.contents,i,Object.freeze([e]))===ae)e.contents=null}else await Xe(null,e,i,Object.freeze([]))}ci.BREAK=z;ci.SKIP=ts;ci.REMOVE=ae;async function Xe(e,t,i,n){let a=await ns(e,t,i,n);if(M.isNode(a)||M.isPair(a))return as(e,n,a),Xe(e,a,i,n);if(typeof a!=="symbol"){if(M.isCollection(t)){n=Object.freeze(n.concat(t));for(let r=0;r<t.items.length;++r){let s=await Xe(r,t.items[r],i,n);if(typeof s==="number")r=s-1;else if(s===z)return z;else if(s===ae)t.items.splice(r,1),r-=1}}else if(M.isPair(t)){n=Object.freeze(n.concat(t));let r=await Xe("key",t.key,i,n);if(r===z)return z;else if(r===ae)t.key=null;let s=await Xe("value",t.value,i,n);if(s===z)return z;else if(s===ae)t.value=null}}return a}function is(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function ns(e,t,i,n){if(typeof i==="function")return i(e,t,n);if(M.isMap(t))return i.Map?.(e,t,n);if(M.isSeq(t))return i.Seq?.(e,t,n);if(M.isPair(t))return i.Pair?.(e,t,n);if(M.isScalar(t))return i.Scalar?.(e,t,n);if(M.isAlias(t))return i.Alias?.(e,t,n);return}function as(e,t,i){let n=t[t.length-1];if(M.isCollection(n))n.items[e]=i;else if(M.isPair(n))if(e==="key")n.key=i;else n.value=i;else if(M.isDocument(n))n.contents=i;else{let a=M.isAlias(n)?"alias":"scalar";throw Error(`Cannot replace node with ${a} parent`)}}od.visit=li;od.visitAsync=ci});var Dn=C(function(fd){var rs=I(),pd=gt(),dd={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},ud=(e)=>e.replace(/[!,[\]{}]/g,(t)=>dd[t]);class J{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},J.defaultYaml,e),this.tags=Object.assign({},J.defaultTags,t)}clone(){let e=new J(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new J(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:J.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},J.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:J.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},J.defaultTags),this.atNextDocument=!1;let i=e.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),i.length<2)return!1}let[a,r]=i;return this.tags[a]=r,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;else{let r=/^\d+\.\d+$/.test(a);return t(6,`Unsupported YAML version ${a}`,r),!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 r=e.slice(2,-1);if(r==="!"||r==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return r}let[,i,n]=e.match(/^(.*!)([^!]*)$/s);if(!n)t(`The ${e} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(r){return t(String(r)),null}if(i==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,i]of Object.entries(this.tags))if(e.startsWith(i))return t+ud(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(e&&i.length>0&&rs.isNode(e.contents)){let a={};pd.visit(e.contents,(r,s)=>{if(rs.isNode(s)&&s.tag)a[s.tag]=!0}),n=Object.keys(a)}else n=[];for(let[a,r]of i){if(a==="!!"&&r==="tag:yaml.org,2002:")continue;if(!e||n.some((s)=>s.startsWith(r)))t.push(`%TAG ${a} ${r}`)}return t.join(`
3
+ `)}}J.defaultYaml={explicit:!1,version:"1.2"};J.defaultTags={"!!":"tag:yaml.org,2002:"};fd.Directives=J});var pi=C(function(bd){var ss=I(),hd=gt();function md(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(i)}return!0}function os(e){let t=new Set;return hd.visit(e,{Value(i,n){if(n.anchor)t.add(n.anchor)}}),t}function ls(e,t){for(let i=1;;++i){let n=`${e}${i}`;if(!t.has(n))return n}}function gd(e,t){let i=[],n=new Map,a=null;return{onAnchor:(r)=>{i.push(r),a??(a=os(e));let s=ls(t,a);return a.add(s),s},setAnchors:()=>{for(let r of i){let s=n.get(r);if(typeof s==="object"&&s.anchor&&(ss.isScalar(s.node)||ss.isCollection(s.node)))s.node.anchor=s.anchor;else{let o=Error("Failed to resolve repeated object (this should not happen)");throw o.source=r,o}}},sourceObjects:n}}bd.anchorIsValid=md;bd.anchorNames=os;bd.createNodeAnchors=gd;bd.findNewAnchor=ls});var Ln=C(function(Sd){function bt(e,t,i,n){if(n&&typeof n==="object")if(Array.isArray(n))for(let a=0,r=n.length;a<r;++a){let s=n[a],o=bt(e,n,String(a),s);if(o===void 0)delete n[a];else if(o!==s)n[a]=o}else if(n instanceof Map)for(let a of Array.from(n.keys())){let r=n.get(a),s=bt(e,n,a,r);if(s===void 0)n.delete(a);else if(s!==r)n.set(a,s)}else if(n instanceof Set)for(let a of Array.from(n)){let r=bt(e,n,a,a);if(r===void 0)n.delete(a);else if(r!==a)n.delete(a),n.add(r)}else for(let[a,r]of Object.entries(n)){let s=bt(e,n,a,r);if(s===void 0)delete n[a];else if(s!==r)n[a]=s}return e.call(t,i,n)}Sd.applyReviver=bt});var me=C(function(Ed){var Vd=I();function cs(e,t,i){if(Array.isArray(e))return e.map((n,a)=>cs(n,String(a),i));if(e&&typeof e.toJSON==="function"){if(!i||!Vd.hasAnchor(e))return e.toJSON(t,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=(r)=>{n.res=r,delete i.onCreate};let a=e.toJSON(t,i);if(i.onCreate)i.onCreate(a);return a}if(typeof e==="bigint"&&!i?.keep)return Number(e);return e}Ed.toJS=cs});var di=C(function(Od){var Id=Ln(),ps=I(),Gd=me();class ds{constructor(e){Object.defineProperty(this,ps.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!ps.isDocument(e))throw TypeError("A document argument is required");let r={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof i==="number"?i:100},s=Gd.toJS(this,"",r);if(typeof n==="function")for(let{count:o,res:l}of r.anchors.values())n(l,o);return typeof a==="function"?Id.applyReviver(a,{"":s},"",s):s}}Od.NodeBase=ds});var Ct=C(function(qd){var Td=pi(),Nd=gt(),Qe=I(),$d=di(),Fd=me();class us extends $d.NodeBase{constructor(e){super(Qe.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let i;if(t?.aliasResolveCache)i=t.aliasResolveCache;else if(i=[],Nd.visit(e,{Node:(a,r)=>{if(Qe.isAlias(r)||Qe.hasAnchor(r))i.push(r)}}),t)t.aliasResolveCache=i;let n=void 0;for(let a of i){if(a===this)break;if(a.anchor===this.source)n=a}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:a}=t,r=this.resolve(n,t);if(!r){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(o)}let s=i.get(r);if(!s)Fd.toJS(r,null,t),s=i.get(r);if(s?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(a>=0){if(s.count+=1,s.aliasCount===0)s.aliasCount=ui(n,r,i);if(s.count*s.aliasCount>a)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return s.res}toString(e,t,i){let n=`*${this.source}`;if(e){if(Td.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(a)}if(e.implicitKey)return`${n} `}return n}}function ui(e,t,i){if(Qe.isAlias(t)){let n=t.resolve(e),a=i&&n&&i.get(n);return a?a.count*a.aliasCount:0}else if(Qe.isCollection(t)){let n=0;for(let a of t.items){let r=ui(e,a,i);if(r>n)n=r}return n}else if(Qe.isPair(t)){let n=ui(e,t.key,i),a=ui(e,t.value,i);return Math.max(n,a)}return 1}qd.Alias=us});var N=C(function(jd){var Ld=I(),Md=di(),Rd=me(),_d=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class Ge extends Md.NodeBase{constructor(e){super(Ld.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:Rd.toJS(this.value,e,t)}toString(){return String(this.value)}}Ge.BLOCK_FOLDED="BLOCK_FOLDED";Ge.BLOCK_LITERAL="BLOCK_LITERAL";Ge.PLAIN="PLAIN";Ge.QUOTE_DOUBLE="QUOTE_DOUBLE";Ge.QUOTE_SINGLE="QUOTE_SINGLE";jd.Scalar=Ge;jd.isScalarValue=_d});var wt=C(function(Hd){var Kd=Ct(),Oe=I(),fs=N(),Ud="tag:yaml.org,2002:";function Jd(e,t,i){if(t){let n=i.filter((r)=>r.tag===t),a=n.find((r)=>!r.format)??n[0];if(!a)throw Error(`Tag ${t} not found`);return a}return i.find((n)=>n.identify?.(e)&&!n.format)}function Yd(e,t,i){if(Oe.isDocument(e))e=e.contents;if(Oe.isNode(e))return e;if(Oe.isPair(e)){let d=i.schema[Oe.MAP].createNode?.(i.schema,null,i);return d.items.push(e),d}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:n,onAnchor:a,onTagObj:r,schema:s,sourceObjects:o}=i,l=void 0;if(n&&e&&typeof e==="object")if(l=o.get(e),l)return l.anchor??(l.anchor=a(e)),new Kd.Alias(l.anchor);else l={anchor:null,node:null},o.set(e,l);if(t?.startsWith("!!"))t=Ud+t.slice(2);let c=Jd(e,t,s.tags);if(!c){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let d=new fs.Scalar(e);if(l)l.node=d;return d}c=e instanceof Map?s[Oe.MAP]:(Symbol.iterator in Object(e))?s[Oe.SEQ]:s[Oe.MAP]}if(r)r(c),delete i.onTagObj;let p=c?.createNode?c.createNode(i.schema,e,i):typeof c?.nodeClass?.from==="function"?c.nodeClass.from(i.schema,e,i):new fs.Scalar(e);if(t)p.tag=t;else if(!c.default)p.tag=c.tag;if(l)l.node=p;return p}Hd.createNode=Yd});var fi=C(function(Zd){var Xd=wt(),re=I(),Qd=di();function Mn(e,t,i){let n=i;for(let a=t.length-1;a>=0;--a){let r=t[a];if(typeof r==="number"&&Number.isInteger(r)&&r>=0){let s=[];s[r]=n,n=s}else n=new Map([[r,n]])}return Xd.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var ys=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class hs extends Qd.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));if(e)t.schema=e;if(t.items=t.items.map((i)=>re.isNode(i)||re.isPair(i)?i.clone(e):i),this.range)t.range=this.range.slice();return t}addIn(e,t){if(ys(e))this.add(t);else{let[i,...n]=e,a=this.get(i,!0);if(re.isCollection(a))a.addIn(n,t);else if(a===void 0&&this.schema)this.set(i,Mn(this.schema,n,t));else throw Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(e){let[t,...i]=e;if(i.length===0)return this.delete(t);let n=this.get(t,!0);if(re.isCollection(n))return n.deleteIn(i);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${i}`)}getIn(e,t){let[i,...n]=e,a=this.get(i,!0);if(n.length===0)return!t&&re.isScalar(a)?a.value:a;else return re.isCollection(a)?a.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!re.isPair(t))return!1;let i=t.value;return i==null||e&&re.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[t,...i]=e;if(i.length===0)return this.has(t);let n=this.get(t,!0);return re.isCollection(n)?n.hasIn(i):!1}setIn(e,t){let[i,...n]=e;if(n.length===0)this.set(i,t);else{let a=this.get(i,!0);if(re.isCollection(a))a.setIn(n,t);else if(a===void 0&&this.schema)this.set(i,Mn(this.schema,n,t));else throw Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}}Zd.Collection=hs;Zd.collectionFromPath=Mn;Zd.isEmptyPath=ys});var vt=C(function(ru){var nu=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Rn(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var au=(e,t,i)=>e.endsWith(`
4
+ `)?Rn(i,t):i.includes(`
5
+ `)?`
6
+ `+Rn(i,t):(e.endsWith(" ")?"":" ")+i;ru.indentComment=Rn;ru.lineComment=au;ru.stringifyComment=nu});var gs=C(function(pu){function cu(e,t,i="flow",{indentAtStart:n,lineWidth:a=80,minContentWidth:r=20,onFold:s,onOverflow:o}={}){if(!a||a<0)return e;if(a<r)r=0;let l=Math.max(1+r,1+a-t.length);if(e.length<=l)return e;let c=[],p={},d=a-t.length;if(typeof n==="number")if(n>a-Math.max(2,r))c.push(0);else d=a-n;let u=void 0,f=void 0,y=!1,h=-1,m=-1,g=-1;if(i==="block"){if(h=ms(e,h,t.length),h!==-1)d=h+l}for(let b;b=e[h+=1];){if(i==="quoted"&&b==="\\"){switch(m=h,e[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}g=h}if(b===`
7
+ `){if(i==="block")h=ms(e,h,t.length);d=h+t.length+l,u=void 0}else{if(b===" "&&f&&f!==" "&&f!==`
8
+ `&&f!=="\t"){let v=e[h+1];if(v&&v!==" "&&v!==`
9
+ `&&v!=="\t")u=h}if(h>=d)if(u)c.push(u),d=u+l,u=void 0;else if(i==="quoted"){while(f===" "||f==="\t")f=b,b=e[h+=1],y=!0;let v=h>g+1?h-2:m-1;if(p[v])return e;c.push(v),p[v]=!0,d=v+l,u=void 0}else y=!0}f=b}if(y&&o)o();if(c.length===0)return e;if(s)s();let w=e.slice(0,c[0]);for(let b=0;b<c.length;++b){let v=c[b],k=c[b+1]||e.length;if(v===0)w=`
10
+ ${t}${e.slice(0,k)}`;else{if(i==="quoted"&&p[v])w+=`${e[v]}\\`;w+=`
11
+ ${t}${e.slice(v+1,k)}`}}return w}function ms(e,t,i){let n=t,a=t+1,r=e[a];while(r===" "||r==="\t")if(t<a+i)r=e[++t];else{do r=e[++t];while(r&&r!==`
12
+ `);n=t,a=t+1,r=e[a]}return n}pu.FOLD_BLOCK="block";pu.FOLD_FLOW="flow";pu.FOLD_QUOTED="quoted";pu.foldFlowLines=cu});var St=C(function(bu){var Z=N(),ge=gs(),hi=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),mi=(e)=>/^(%|---|\.\.\.)/m.test(e);function hu(e,t,i){if(!t||t<0)return!1;let n=t-i,a=e.length;if(a<=n)return!1;for(let r=0,s=0;r<a;++r)if(e[r]===`
13
+ `){if(r-s>n)return!0;if(s=r+1,a-s<=n)return!1}return!0}function xt(e,t){let i=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return i;let{implicitKey:n}=t,a=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(mi(e)?" ":""),s="",o=0;for(let l=0,c=i[l];c;c=i[++l]){if(c===" "&&i[l+1]==="\\"&&i[l+2]==="n")s+=i.slice(o,l)+"\\ ",l+=1,o=l,c="\\";if(c==="\\")switch(i[l+1]){case"u":{s+=i.slice(o,l);let p=i.substr(l+2,4);switch(p){case"0000":s+="\\0";break;case"0007":s+="\\a";break;case"000b":s+="\\v";break;case"001b":s+="\\e";break;case"0085":s+="\\N";break;case"00a0":s+="\\_";break;case"2028":s+="\\L";break;case"2029":s+="\\P";break;default:if(p.substr(0,2)==="00")s+="\\x"+p.substr(2);else s+=i.substr(l,6)}l+=5,o=l+1}break;case"n":if(n||i[l+2]==='"'||i.length<a)l+=1;else{s+=i.slice(o,l)+`
14
+
15
+ `;while(i[l+2]==="\\"&&i[l+3]==="n"&&i[l+4]!=='"')s+=`
16
+ `,l+=2;if(s+=r,i[l+2]===" ")s+="\\";l+=1,o=l+1}break;default:l+=1}}return s=o?s+i.slice(o):i,n?s:ge.foldFlowLines(s,r,ge.FOLD_QUOTED,hi(t,!1))}function _n(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
17
+ `)||/[ \t]\n|\n[ \t]/.test(e))return xt(e,t);let i=t.indent||(mi(e)?" ":""),n="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
18
+ ${i}`)+"'";return t.implicitKey?n:ge.foldFlowLines(n,i,ge.FOLD_FLOW,hi(t,!1))}function Ze(e,t){let{singleQuote:i}=t.options,n;if(i===!1)n=xt;else{let a=e.includes('"'),r=e.includes("'");if(a&&!r)n=_n;else if(r&&!a)n=xt;else n=i?_n:xt}return n(e,t)}var jn;try{jn=new RegExp(`(^|(?<!
19
+ ))
20
+ +(?!
21
+ |$)`,"g")}catch{jn=/\n+(?!\n|$)/g}function yi({comment:e,type:t,value:i},n,a,r){let{blockQuote:s,commentString:o,lineWidth:l}=n.options;if(!s||/\n[\t ]+$/.test(i))return Ze(i,n);let c=n.indent||(n.forceBlockIndent||mi(i)?" ":""),p=s==="literal"?!0:s==="folded"||t===Z.Scalar.BLOCK_FOLDED?!1:t===Z.Scalar.BLOCK_LITERAL?!0:!hu(i,l,c.length);if(!i)return p?`|
22
+ `:`>
23
+ `;let d,u;for(u=i.length;u>0;--u){let k=i[u-1];if(k!==`
24
+ `&&k!=="\t"&&k!==" ")break}let f=i.substring(u),y=f.indexOf(`
25
+ `);if(y===-1)d="-";else if(i===f||y!==f.length-1){if(d="+",r)r()}else d="";if(f){if(i=i.slice(0,-f.length),f[f.length-1]===`
26
+ `)f=f.slice(0,-1);f=f.replace(jn,`$&${c}`)}let h=!1,m,g=-1;for(m=0;m<i.length;++m){let k=i[m];if(k===" ")h=!0;else if(k===`
27
+ `)g=m;else break}let w=i.substring(0,g<m?g+1:m);if(w)i=i.substring(w.length),w=w.replace(/\n+/g,`$&${c}`);let v=(h?c?"2":"1":"")+d;if(e){if(v+=" "+o(e.replace(/ ?[\r\n]+/g," ")),a)a()}if(!p){let k=i.replace(/\n+/g,`
28
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),V=!1,O=hi(n,!0);if(s!=="folded"&&t!==Z.Scalar.BLOCK_FOLDED)O.onOverflow=()=>{V=!0};let x=ge.foldFlowLines(`${w}${k}${f}`,c,ge.FOLD_BLOCK,O);if(!V)return`>${v}
29
+ ${c}${x}`}return i=i.replace(/\n+/g,`$&${c}`),`|${v}
30
+ ${c}${w}${i}${f}`}function mu(e,t,i,n){let{type:a,value:r}=e,{actualString:s,implicitKey:o,indent:l,indentStep:c,inFlow:p}=t;if(o&&r.includes(`
31
+ `)||p&&/[[\]{},]/.test(r))return Ze(r,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return o||p||!r.includes(`
32
+ `)?Ze(r,t):yi(e,t,i,n);if(!o&&!p&&a!==Z.Scalar.PLAIN&&r.includes(`
33
+ `))return yi(e,t,i,n);if(mi(r)){if(l==="")return t.forceBlockIndent=!0,yi(e,t,i,n);else if(o&&l===c)return Ze(r,t)}let d=r.replace(/\n+/g,`$&
34
+ ${l}`);if(s){let u=(h)=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:f,tags:y}=t.doc.schema;if(y.some(u)||f?.some(u))return Ze(r,t)}return o?d:ge.foldFlowLines(d,l,ge.FOLD_FLOW,hi(t,!1))}function gu(e,t,i,n){let{implicitKey:a,inFlow:r}=t,s=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:o}=e;if(o!==Z.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value))o=Z.Scalar.QUOTE_DOUBLE}let l=(p)=>{switch(p){case Z.Scalar.BLOCK_FOLDED:case Z.Scalar.BLOCK_LITERAL:return a||r?Ze(s.value,t):yi(s,t,i,n);case Z.Scalar.QUOTE_DOUBLE:return xt(s.value,t);case Z.Scalar.QUOTE_SINGLE:return _n(s.value,t);case Z.Scalar.PLAIN:return mu(s,t,i,n);default:return null}},c=l(o);if(c===null){let{defaultKeyType:p,defaultStringType:d}=t.options,u=a&&p||d;if(c=l(u),c===null)throw Error(`Unsupported default string type ${u}`)}return c}bu.stringifyString=gu});var kt=C(function(Pu){var wu=pi(),be=I(),vu=vt(),xu=St();function Su(e,t){let i=Object.assign({blockQuote:!0,commentString:vu.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,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),n;switch(i.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:e,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent==="number"?" ".repeat(i.indent):" ",inFlow:n,options:i}}function ku(e,t){if(t.tag){let a=e.filter((r)=>r.tag===t.tag);if(a.length>0)return a.find((r)=>r.format===t.format)??a[0]}let i=void 0,n;if(be.isScalar(t)){n=t.value;let a=e.filter((r)=>r.identify?.(n));if(a.length>1){let r=a.filter((s)=>s.test);if(r.length>0)a=r}i=a.find((r)=>r.format===t.format)??a.find((r)=>!r.format)}else n=t,i=e.find((a)=>a.nodeClass&&n instanceof a.nodeClass);if(!i){let a=n?.constructor?.name??(n===null?"null":typeof n);throw Error(`Tag not resolved for ${a} value`)}return i}function Vu(e,t,{anchors:i,doc:n}){if(!n.directives)return"";let a=[],r=(be.isScalar(e)||be.isCollection(e))&&e.anchor;if(r&&wu.anchorIsValid(r))i.add(r),a.push(`&${r}`);let s=e.tag??(t.default?null:t.tag);if(s)a.push(n.directives.tagString(s));return a.join(" ")}function Eu(e,t,i,n){if(be.isPair(e))return e.toString(t,i,n);if(be.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let a=void 0,r=be.isNode(e)?e:t.doc.createNode(e,{onTagObj:(l)=>a=l});a??(a=ku(t.doc.schema.tags,r));let s=Vu(r,a,t);if(s.length>0)t.indentAtStart=(t.indentAtStart??0)+s.length+1;let o=typeof a.stringify==="function"?a.stringify(r,t,i,n):be.isScalar(r)?xu.stringifyString(r,t,i,n):r.toString(t,i,n);if(!s)return o;return be.isScalar(r)||o[0]==="{"||o[0]==="["?`${s} ${o}`:`${s}
35
+ ${t.indent}${o}`}Pu.createStringifyContext=Su;Pu.stringify=Eu});var ws=C(function(Au){var pe=I(),bs=N(),Cs=kt(),Vt=vt();function Ou({key:e,value:t},i,n,a){let{allNullValues:r,doc:s,indent:o,indentStep:l,options:{commentString:c,indentSeq:p,simpleKeys:d}}=i,u=pe.isNode(e)&&e.comment||null;if(d){if(u)throw Error("With simple keys, key nodes cannot have comments");if(pe.isCollection(e)||!pe.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let f=!d&&(!e||u&&t==null&&!i.inFlow||pe.isCollection(e)||(pe.isScalar(e)?e.type===bs.Scalar.BLOCK_FOLDED||e.type===bs.Scalar.BLOCK_LITERAL:typeof e==="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!f&&(d||!r),indent:o+l});let y=!1,h=!1,m=Cs.stringify(e,i,()=>y=!0,()=>h=!0);if(!f&&!i.inFlow&&m.length>1024){if(d)throw Error("With simple keys, single line scalar must not span more than 1024 characters");f=!0}if(i.inFlow){if(r||t==null){if(y&&n)n();return m===""?"?":f?`? ${m}`:m}}else if(r&&!d||t==null&&f){if(m=`? ${m}`,u&&!y)m+=Vt.lineComment(m,i.indent,c(u));else if(h&&a)a();return m}if(y)u=null;if(f){if(u)m+=Vt.lineComment(m,i.indent,c(u));m=`? ${m}
36
+ ${o}:`}else if(m=`${m}:`,u)m+=Vt.lineComment(m,i.indent,c(u));let g,w,b;if(pe.isNode(t))g=!!t.spaceBefore,w=t.commentBefore,b=t.comment;else if(g=!1,w=null,b=null,t&&typeof t==="object")t=s.createNode(t);if(i.implicitKey=!1,!f&&!u&&pe.isScalar(t))i.indentAtStart=m.length+1;if(h=!1,!p&&l.length>=2&&!i.inFlow&&!f&&pe.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)i.indent=i.indent.substring(2);let v=!1,k=Cs.stringify(t,i,()=>v=!0,()=>h=!0),V=" ";if(u||g||w){if(V=g?`
37
+ `:"",w){let O=c(w);V+=`
38
+ ${Vt.indentComment(O,i.indent)}`}if(k===""&&!i.inFlow){if(V===`
39
+ `&&b)V=`
40
+
41
+ `}else V+=`
42
+ ${i.indent}`}else if(!f&&pe.isCollection(t)){let O=k[0],x=k.indexOf(`
43
+ `),q=x!==-1,ue=i.inFlow??t.flow??t.items.length===0;if(q||!ue){let ze=!1;if(q&&(O==="&"||O==="!")){let D=k.indexOf(" ");if(O==="&"&&D!==-1&&D<x&&k[D+1]==="!")D=k.indexOf(" ",D+1);if(D===-1||x<D)ze=!0}if(!ze)V=`
44
+ ${i.indent}`}}else if(k===""||k[0]===`
45
+ `)V="";if(m+=V+k,i.inFlow){if(v&&n)n()}else if(b&&!v)m+=Vt.lineComment(m,i.indent,c(b));else if(h&&a)a();return m}Au.stringifyPair=Ou});var zn=C(function(Fu){var vs=Bt("process");function Nu(e,...t){if(e==="debug")console.log(...t)}function $u(e,t){if(e==="debug"||e==="warn")if(typeof vs.emitWarning==="function")vs.emitWarning(t);else console.warn(t)}Fu.debug=Nu;Fu.warn=$u});var wi=C(function(Mu){var Ci=I(),xs=N(),gi="<<",bi={identify:(e)=>e===gi||typeof e==="symbol"&&e.description===gi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new xs.Scalar(Symbol(gi)),{addToJSMap:Ss}),stringify:()=>gi},Lu=(e,t)=>(bi.identify(t)||Ci.isScalar(t)&&(!t.type||t.type===xs.Scalar.PLAIN)&&bi.identify(t.value))&&e?.doc.schema.tags.some((i)=>i.tag===bi.tag&&i.default);function Ss(e,t,i){let n=ks(e,i);if(Ci.isSeq(n))for(let a of n.items)Bn(e,t,a);else if(Array.isArray(n))for(let a of n)Bn(e,t,a);else Bn(e,t,n)}function Bn(e,t,i){let n=ks(e,i);if(!Ci.isMap(n))throw Error("Merge sources must be maps or map aliases");let a=n.toJSON(null,e,Map);for(let[r,s]of a)if(t instanceof Map){if(!t.has(r))t.set(r,s)}else if(t instanceof Set)t.add(r);else if(!Object.prototype.hasOwnProperty.call(t,r))Object.defineProperty(t,r,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function ks(e,t){return e&&Ci.isAlias(t)?t.resolve(e.doc,e):t}Mu.addMergeToJSMap=Ss;Mu.isMergeKey=Lu;Mu.merge=bi});var Un=C(function(Ju){var zu=zn(),Vs=wi(),Bu=kt(),Es=I(),Kn=me();function Ku(e,t,{key:i,value:n}){if(Es.isNode(i)&&i.addToJSMap)i.addToJSMap(e,t,n);else if(Vs.isMergeKey(e,i))Vs.addMergeToJSMap(e,t,n);else{let a=Kn.toJS(i,"",e);if(t instanceof Map)t.set(a,Kn.toJS(n,a,e));else if(t instanceof Set)t.add(a);else{let r=Uu(i,a,e),s=Kn.toJS(n,r,e);if(r in t)Object.defineProperty(t,r,{value:s,writable:!0,enumerable:!0,configurable:!0});else t[r]=s}}return t}function Uu(e,t,i){if(t===null)return"";if(typeof t!=="object")return String(t);if(Es.isNode(e)&&i?.doc){let n=Bu.createStringifyContext(i.doc,{});n.anchors=new Set;for(let r of i.anchors.keys())n.anchors.add(r.anchor);n.inFlow=!0,n.inStringifyKey=!0;let a=e.toString(n);if(!i.mapKeyWarned){let r=JSON.stringify(a);if(r.length>40)r=r.substring(0,36)+'..."';zu.warn(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return a}return JSON.stringify(t)}Ju.addPairToJSMap=Ku});var Ce=C(function(Qu){var Ps=wt(),Hu=ws(),Wu=Un(),vi=I();function Xu(e,t,i){let n=Ps.createNode(e,void 0,i),a=Ps.createNode(t,void 0,i);return new xi(n,a)}class xi{constructor(e,t=null){Object.defineProperty(this,vi.NODE_TYPE,{value:vi.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:i}=this;if(vi.isNode(t))t=t.clone(e);if(vi.isNode(i))i=i.clone(e);return new xi(t,i)}toJSON(e,t){let i=t?.mapAsMap?new Map:{};return Wu.addPairToJSMap(t,i,this)}toString(e,t,i){return e?.doc?Hu.stringifyPair(this,e,t,i):JSON.stringify(this)}}Qu.Pair=xi;Qu.createPair=Xu});var Jn=C(function(rf){var Ae=I(),Is=kt(),Si=vt();function tf(e,t,i){return(t.inFlow??e.flow?af:nf)(e,t,i)}function nf({comment:e,items:t},i,{blockItemPrefix:n,flowChars:a,itemIndent:r,onChompKeep:s,onComment:o}){let{indent:l,options:{commentString:c}}=i,p=Object.assign({},i,{indent:r,type:null}),d=!1,u=[];for(let y=0;y<t.length;++y){let h=t[y],m=null;if(Ae.isNode(h)){if(!d&&h.spaceBefore)u.push("");if(ki(i,u,h.commentBefore,d),h.comment)m=h.comment}else if(Ae.isPair(h)){let w=Ae.isNode(h.key)?h.key:null;if(w){if(!d&&w.spaceBefore)u.push("");ki(i,u,w.commentBefore,d)}}d=!1;let g=Is.stringify(h,p,()=>m=null,()=>d=!0);if(m)g+=Si.lineComment(g,r,c(m));if(d&&m)d=!1;u.push(n+g)}let f;if(u.length===0)f=a.start+a.end;else{f=u[0];for(let y=1;y<u.length;++y){let h=u[y];f+=h?`
46
+ ${l}${h}`:`
47
+ `}}if(e){if(f+=`
48
+ `+Si.indentComment(c(e),l),o)o()}else if(d&&s)s();return f}function af({items:e},t,{flowChars:i,itemIndent:n}){let{indent:a,indentStep:r,flowCollectionPadding:s,options:{commentString:o}}=t;n+=r;let l=Object.assign({},t,{indent:n,inFlow:!0,type:null}),c=!1,p=0,d=[];for(let y=0;y<e.length;++y){let h=e[y],m=null;if(Ae.isNode(h)){if(h.spaceBefore)d.push("");if(ki(t,d,h.commentBefore,!1),h.comment)m=h.comment}else if(Ae.isPair(h)){let w=Ae.isNode(h.key)?h.key:null;if(w){if(w.spaceBefore)d.push("");if(ki(t,d,w.commentBefore,!1),w.comment)c=!0}let b=Ae.isNode(h.value)?h.value:null;if(b){if(b.comment)m=b.comment;if(b.commentBefore)c=!0}else if(h.value==null&&w?.comment)m=w.comment}if(m)c=!0;let g=Is.stringify(h,l,()=>m=null);if(c||(c=d.length>p||g.includes(`
49
+ `)),y<e.length-1)g+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)c||(c=d.reduce((w,b)=>w+b.length+2,2)+(g.length+2)>t.options.lineWidth);if(c)g+=","}if(m)g+=Si.lineComment(g,n,o(m));d.push(g),p=d.length}let{start:u,end:f}=i;if(d.length===0)return u+f;else{if(!c){let y=d.reduce((h,m)=>h+m.length+2,2);c=t.options.lineWidth>0&&y>t.options.lineWidth}if(c){let y=u;for(let h of d)y+=h?`
50
+ ${r}${a}${h}`:`
51
+ `;return`${y}
52
+ ${a}${f}`}else return`${u}${s}${d.join(" ")}${s}${f}`}}function ki({indent:e,options:{commentString:t}},i,n,a){if(n&&a)n=n.replace(/^\n+/,"");if(n){let r=Si.indentComment(t(n),e);i.push(r.trimStart())}}rf.stringifyCollection=tf});var ve=C(function(df){var of=Jn(),lf=Un(),cf=fi(),we=I(),Vi=Ce(),pf=N();function Et(e,t){let i=we.isScalar(t)?t.value:t;for(let n of e)if(we.isPair(n)){if(n.key===t||n.key===i)return n;if(we.isScalar(n.key)&&n.key.value===i)return n}return}class Gs extends cf.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(we.MAP,e);this.items=[]}static from(e,t,i){let{keepUndefined:n,replacer:a}=i,r=new this(e),s=(o,l)=>{if(typeof a==="function")l=a.call(t,o,l);else if(Array.isArray(a)&&!a.includes(o))return;if(l!==void 0||n)r.items.push(Vi.createPair(o,l,i))};if(t instanceof Map)for(let[o,l]of t)s(o,l);else if(t&&typeof t==="object")for(let o of Object.keys(t))s(o,t[o]);if(typeof e.sortMapEntries==="function")r.items.sort(e.sortMapEntries);return r}add(e,t){let i;if(we.isPair(e))i=e;else if(!e||typeof e!=="object"||!("key"in e))i=new Vi.Pair(e,e?.value);else i=new Vi.Pair(e.key,e.value);let n=Et(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!t)throw Error(`Key ${i.key} already set`);if(we.isScalar(n.value)&&pf.isScalarValue(i.value))n.value.value=i.value;else n.value=i.value}else if(a){let r=this.items.findIndex((s)=>a(i,s)<0);if(r===-1)this.items.push(i);else this.items.splice(r,0,i)}else this.items.push(i)}delete(e){let t=Et(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let n=Et(this.items,e)?.value;return(!t&&we.isScalar(n)?n.value:n)??void 0}has(e){return!!Et(this.items,e)}set(e,t){this.add(new Vi.Pair(e,t),!0)}toJSON(e,t,i){let n=i?new i:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(n);for(let a of this.items)lf.addPairToJSMap(t,n,a);return n}toString(e,t,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!we.isPair(n))throw Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return of.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:t})}}df.YAMLMap=Gs;df.findPair=Et});var et=C(function(mf){var yf=I(),Os=ve(),hf={collection:"map",default:!0,nodeClass:Os.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!yf.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,i)=>Os.YAMLMap.from(e,t,i)};mf.map=hf});var xe=C(function(Sf){var bf=wt(),Cf=Jn(),wf=fi(),Pi=I(),vf=N(),xf=me();class As extends wf.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Pi.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=Ei(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let i=Ei(e);if(typeof i!=="number")return;let n=this.items[i];return!t&&Pi.isScalar(n)?n.value:n}has(e){let t=Ei(e);return typeof t==="number"&&t<this.items.length}set(e,t){let i=Ei(e);if(typeof i!=="number")throw Error(`Expected a valid index, not ${e}.`);let n=this.items[i];if(Pi.isScalar(n)&&vf.isScalarValue(t))n.value=t;else this.items[i]=t}toJSON(e,t){let i=[];if(t?.onCreate)t.onCreate(i);let n=0;for(let a of this.items)i.push(xf.toJS(a,String(n++),t));return i}toString(e,t,i){if(!e)return JSON.stringify(this);return Cf.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:i,onComment:t})}static from(e,t,i){let{replacer:n}=i,a=new this(e);if(t&&Symbol.iterator in Object(t)){let r=0;for(let s of t){if(typeof n==="function"){let o=t instanceof Set?s:String(r++);s=n.call(t,o,s)}a.items.push(bf.createNode(s,void 0,i))}}return a}}function Ei(e){let t=Pi.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}Sf.YAMLSeq=As});var tt=C(function(Pf){var Vf=I(),Ts=xe(),Ef={collection:"seq",default:!0,nodeClass:Ts.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!Vf.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,i)=>Ts.YAMLSeq.from(e,t,i)};Pf.seq=Ef});var Pt=C(function(Af){var Gf=St(),Of={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,i,n){return t=Object.assign({actualString:!0},t),Gf.stringifyString(e,t,i,n)}};Af.string=Of});var Ii=C(function(Nf){var Ns=N(),$s={identify:(e)=>e==null,createNode:()=>new Ns.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ns.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&$s.test.test(e)?e:t.options.nullStr};Nf.nullTag=$s});var Yn=C(function(qf){var Ff=N(),Fs={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new Ff.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},i){if(e&&Fs.test.test(e)){let n=e[0]==="t"||e[0]==="T";if(t===n)return e}return t?i.options.trueStr:i.options.falseStr}};qf.boolTag=Fs});var it=C(function(Mf){function Lf({format:e,minFractionDigits:t,tag:i,value:n}){if(typeof n==="bigint")return String(n);let a=typeof n==="number"?n:Number(n);if(!isFinite(a))return isNaN(a)?".nan":a<0?"-.inf":".inf";let r=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!i||i==="tag:yaml.org,2002:float")&&/^-?\d/.test(r)&&!r.includes("e")){let s=r.indexOf(".");if(s<0)s=r.length,r+=".";let o=t-(r.length-s-1);while(o-- >0)r+="0"}return r}Mf.stringifyNumber=Lf});var Wn=C(function(Kf){var _f=N(),Hn=it(),jf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Hn.stringifyNumber},zf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Hn.stringifyNumber(e)}},Bf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new _f.Scalar(parseFloat(e)),i=e.indexOf(".");if(i!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-i-1;return t},stringify:Hn.stringifyNumber};Kf.float=Bf;Kf.floatExp=zf;Kf.floatNaN=jf});var Qn=C(function(Qf){var qs=it(),Gi=(e)=>typeof e==="bigint"||Number.isInteger(e),Xn=(e,t,i,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),i);function Ds(e,t,i){let{value:n}=e;if(Gi(n)&&n>=0)return i+n.toString(t);return qs.stringifyNumber(e)}var Hf={identify:(e)=>Gi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,i)=>Xn(e,2,8,i),stringify:(e)=>Ds(e,8,"0o")},Wf={identify:Gi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,i)=>Xn(e,0,10,i),stringify:qs.stringifyNumber},Xf={identify:(e)=>Gi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,i)=>Xn(e,2,16,i),stringify:(e)=>Ds(e,16,"0x")};Qf.int=Wf;Qf.intHex=Xf;Qf.intOct=Hf});var Ls=C(function(ly){var iy=et(),ny=Ii(),ay=tt(),ry=Pt(),sy=Yn(),Zn=Wn(),ea=Qn(),oy=[iy.map,ay.seq,ry.string,ny.nullTag,sy.boolTag,ea.intOct,ea.int,ea.intHex,Zn.floatNaN,Zn.floatExp,Zn.float];ly.schema=oy});var Rs=C(function(my){var py=N(),dy=et(),uy=tt();function Ms(e){return typeof e==="bigint"||Number.isInteger(e)}var Oi=({value:e})=>JSON.stringify(e),fy=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:Oi},{identify:(e)=>e==null,createNode:()=>new py.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Oi},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:Oi},{identify:Ms,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:i})=>i?BigInt(e):parseInt(e,10),stringify:({value:e})=>Ms(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:Oi}],yy={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},hy=[dy.map,uy.seq].concat(fy,yy);my.schema=hy});var ia=C(function(wy){var It=Bt("buffer"),ta=N(),by=St(),Cy={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof It.Buffer==="function")return It.Buffer.from(e,"base64");else if(typeof atob==="function"){let i=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(i.length);for(let a=0;a<i.length;++a)n[a]=i.charCodeAt(a);return n}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:i},n,a,r){if(!i)return"";let s=i,o;if(typeof It.Buffer==="function")o=s instanceof It.Buffer?s.toString("base64"):It.Buffer.from(s.buffer).toString("base64");else if(typeof btoa==="function"){let l="";for(let c=0;c<s.length;++c)l+=String.fromCharCode(s[c]);o=btoa(l)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=ta.Scalar.BLOCK_LITERAL),t!==ta.Scalar.QUOTE_DOUBLE){let l=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),c=Math.ceil(o.length/l),p=Array(c);for(let d=0,u=0;d<c;++d,u+=l)p[d]=o.substr(u,l);o=p.join(t===ta.Scalar.BLOCK_LITERAL?`
53
+ `:" ")}return by.stringifyString({comment:e,type:t,value:o},n,a,r)}};wy.binary=Cy});var Ti=C(function(Vy){var Ai=I(),na=Ce(),xy=N(),Sy=xe();function _s(e,t){if(Ai.isSeq(e))for(let i=0;i<e.items.length;++i){let n=e.items[i];if(Ai.isPair(n))continue;else if(Ai.isMap(n)){if(n.items.length>1)t("Each pair must have its own sequence indicator");let a=n.items[0]||new na.Pair(new xy.Scalar(null));if(n.commentBefore)a.key.commentBefore=a.key.commentBefore?`${n.commentBefore}
54
+ ${a.key.commentBefore}`:n.commentBefore;if(n.comment){let r=a.value??a.key;r.comment=r.comment?`${n.comment}
55
+ ${r.comment}`:n.comment}n=a}e.items[i]=Ai.isPair(n)?n:new na.Pair(n)}else t("Expected a sequence for this tag");return e}function js(e,t,i){let{replacer:n}=i,a=new Sy.YAMLSeq(e);a.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof n==="function")s=n.call(t,String(r++),s);let o,l;if(Array.isArray(s))if(s.length===2)o=s[0],l=s[1];else throw TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let c=Object.keys(s);if(c.length===1)o=c[0],l=s[o];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else o=s;a.items.push(na.createPair(o,l,i))}return a}var ky={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:_s,createNode:js};Vy.createPairs=js;Vy.pairs=ky;Vy.resolvePairs=_s});var ra=C(function(Ay){var zs=I(),aa=me(),Gt=ve(),Gy=xe(),Bs=Ti();class Te extends Gy.YAMLSeq{constructor(){super();this.add=Gt.YAMLMap.prototype.add.bind(this),this.delete=Gt.YAMLMap.prototype.delete.bind(this),this.get=Gt.YAMLMap.prototype.get.bind(this),this.has=Gt.YAMLMap.prototype.has.bind(this),this.set=Gt.YAMLMap.prototype.set.bind(this),this.tag=Te.tag}toJSON(e,t){if(!t)return super.toJSON(e);let i=new Map;if(t?.onCreate)t.onCreate(i);for(let n of this.items){let a,r;if(zs.isPair(n))a=aa.toJS(n.key,"",t),r=aa.toJS(n.value,a,t);else a=aa.toJS(n,"",t);if(i.has(a))throw Error("Ordered maps must not include duplicate keys");i.set(a,r)}return i}static from(e,t,i){let n=Bs.createPairs(e,t,i),a=new this;return a.items=n.items,a}}Te.tag="tag:yaml.org,2002:omap";var Oy={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Te,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let i=Bs.resolvePairs(e,t),n=[];for(let{key:a}of i.items)if(zs.isScalar(a))if(n.includes(a.value))t(`Ordered maps must not include duplicate keys: ${a.value}`);else n.push(a.value);return Object.assign(new Te,i)},createNode:(e,t,i)=>Te.from(e,t,i)};Ay.YAMLOMap=Te;Ay.omap=Oy});var Hs=C(function($y){var Ks=N();function Us({value:e,source:t},i){if(t&&(e?Js:Ys).test.test(t))return t;return e?i.options.trueStr:i.options.falseStr}var Js={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ks.Scalar(!0),stringify:Us},Ys={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ks.Scalar(!1),stringify:Us};$y.falseTag=Ys;$y.trueTag=Js});var Ws=C(function(_y){var Dy=N(),sa=it(),Ly={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:sa.stringifyNumber},My={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():sa.stringifyNumber(e)}},Ry={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Dy.Scalar(parseFloat(e.replace(/_/g,""))),i=e.indexOf(".");if(i!==-1){let n=e.substring(i+1).replace(/_/g,"");if(n[n.length-1]==="0")t.minFractionDigits=n.length}return t},stringify:sa.stringifyNumber};_y.float=Ry;_y.floatExp=My;_y.floatNaN=Ly});var Qs=C(function(Hy){var Xs=it(),Ot=(e)=>typeof e==="bigint"||Number.isInteger(e);function Ni(e,t,i,{intAsBigInt:n}){let a=e[0];if(a==="-"||a==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),n){switch(i){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let s=BigInt(e);return a==="-"?BigInt(-1)*s:s}let r=parseInt(e,i);return a==="-"?-1*r:r}function oa(e,t,i){let{value:n}=e;if(Ot(n)){let a=n.toString(t);return n<0?"-"+i+a.substr(1):i+a}return Xs.stringifyNumber(e)}var Ky={identify:Ot,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,i)=>Ni(e,2,2,i),stringify:(e)=>oa(e,2,"0b")},Uy={identify:Ot,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,i)=>Ni(e,1,8,i),stringify:(e)=>oa(e,8,"0")},Jy={identify:Ot,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,i)=>Ni(e,0,10,i),stringify:Xs.stringifyNumber},Yy={identify:Ot,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,i)=>Ni(e,2,16,i),stringify:(e)=>oa(e,16,"0x")};Hy.int=Jy;Hy.intBin=Ky;Hy.intHex=Yy;Hy.intOct=Uy});var la=C(function(th){var qi=I(),$i=Ce(),Fi=ve();class Ne extends Fi.YAMLMap{constructor(e){super(e);this.tag=Ne.tag}add(e){let t;if(qi.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new $i.Pair(e.key,null);else t=new $i.Pair(e,null);if(!Fi.findPair(this.items,t.key))this.items.push(t)}get(e,t){let i=Fi.findPair(this.items,e);return!t&&qi.isPair(i)?qi.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=Fi.findPair(this.items,e);if(i&&!t)this.items.splice(this.items.indexOf(i),1);else if(!i&&t)this.items.push(new $i.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,i);else throw Error("Set items must all have null values")}static from(e,t,i){let{replacer:n}=i,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let r of t){if(typeof n==="function")r=n.call(t,r,r);a.items.push($i.createPair(r,null,i))}return a}}Ne.tag="tag:yaml.org,2002:set";var eh={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Ne,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,i)=>Ne.from(e,t,i),resolve(e,t){if(qi.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Ne,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};th.YAMLSet=Ne;th.set=eh});var pa=C(function(oh){var ah=it();function ca(e,t){let i=e[0],n=i==="-"||i==="+"?e.substring(1):e,a=(s)=>t?BigInt(s):Number(s),r=n.replace(/_/g,"").split(":").reduce((s,o)=>s*a(60)+a(o),a(0));return i==="-"?a(-1)*r:r}function Zs(e){let{value:t}=e,i=(s)=>s;if(typeof t==="bigint")i=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return ah.stringifyNumber(e);let n="";if(t<0)n="-",t*=i(-1);let a=i(60),r=[t%a];if(t<60)r.unshift(0);else if(t=(t-r[0])/a,r.unshift(t%a),t>=60)t=(t-r[0])/a,r.unshift(t);return n+r.map((s)=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var rh={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:i})=>ca(e,i),stringify:Zs},sh={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>ca(e,!1),stringify:Zs},eo={identify:(e)=>e 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(e){let t=e.match(eo.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,n,a,r,s,o]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(i,n-1,a,r||0,s||0,o||0,l),p=t[8];if(p&&p!=="Z"){let d=ca(p,!1);if(Math.abs(d)<30)d*=60;c-=60000*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};oh.floatTime=sh;oh.intTime=rh;oh.timestamp=eo});var io=C(function(vh){var dh=et(),uh=Ii(),fh=tt(),yh=Pt(),hh=ia(),to=Hs(),da=Ws(),Di=Qs(),mh=wi(),gh=ra(),bh=Ti(),Ch=la(),ua=pa(),wh=[dh.map,fh.seq,yh.string,uh.nullTag,to.trueTag,to.falseTag,Di.intBin,Di.intOct,Di.int,Di.intHex,da.floatNaN,da.floatExp,da.float,hh.binary,mh.merge,gh.omap,bh.pairs,Ch.set,ua.intTime,ua.floatTime,ua.timestamp];vh.schema=wh});var fo=C(function(Oh){var so=et(),Sh=Ii(),oo=tt(),kh=Pt(),Vh=Yn(),fa=Wn(),ya=Qn(),Eh=Ls(),Ph=Rs(),lo=ia(),At=wi(),co=ra(),po=Ti(),no=io(),uo=la(),Li=pa(),ao=new Map([["core",Eh.schema],["failsafe",[so.map,oo.seq,kh.string]],["json",Ph.schema],["yaml11",no.schema],["yaml-1.1",no.schema]]),ro={binary:lo.binary,bool:Vh.boolTag,float:fa.float,floatExp:fa.floatExp,floatNaN:fa.floatNaN,floatTime:Li.floatTime,int:ya.int,intHex:ya.intHex,intOct:ya.intOct,intTime:Li.intTime,map:so.map,merge:At.merge,null:Sh.nullTag,omap:co.omap,pairs:po.pairs,seq:oo.seq,set:uo.set,timestamp:Li.timestamp},Ih={"tag:yaml.org,2002:binary":lo.binary,"tag:yaml.org,2002:merge":At.merge,"tag:yaml.org,2002:omap":co.omap,"tag:yaml.org,2002:pairs":po.pairs,"tag:yaml.org,2002:set":uo.set,"tag:yaml.org,2002:timestamp":Li.timestamp};function Gh(e,t,i){let n=ao.get(t);if(n&&!e)return i&&!n.includes(At.merge)?n.concat(At.merge):n.slice();let a=n;if(!a)if(Array.isArray(e))a=[];else{let r=Array.from(ao.keys()).filter((s)=>s!=="yaml11").map((s)=>JSON.stringify(s)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${r} or define customTags array`)}if(Array.isArray(e))for(let r of e)a=a.concat(r);else if(typeof e==="function")a=e(a.slice());if(i)a=a.concat(At.merge);return a.reduce((r,s)=>{let o=typeof s==="string"?ro[s]:s;if(!o){let l=JSON.stringify(s),c=Object.keys(ro).map((p)=>JSON.stringify(p)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!r.includes(o))r.push(o);return r},[])}Oh.coreKnownTags=Ih;Oh.getTags=Gh});var ga=C(function(Dh){var ha=I(),Nh=et(),$h=tt(),Fh=Pt(),Mi=fo(),qh=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class ma{constructor({compat:e,customTags:t,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:r,toStringDefaults:s}){this.compat=Array.isArray(e)?Mi.getTags(e,"compat"):e?Mi.getTags(null,e):null,this.name=typeof a==="string"&&a||"core",this.knownTags=n?Mi.coreKnownTags:{},this.tags=Mi.getTags(t,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,ha.MAP,{value:Nh.map}),Object.defineProperty(this,ha.SCALAR,{value:Fh.string}),Object.defineProperty(this,ha.SEQ,{value:$h.seq}),this.sortMapEntries=typeof r==="function"?r:r===!0?qh:null}clone(){let e=Object.create(ma.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Dh.Schema=ma});var yo=C(function(_h){var Mh=I(),ba=kt(),Tt=vt();function Rh(e,t){let i=[],n=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)i.push(l),n=!0;else if(e.directives.docStart)n=!0}if(n)i.push("---");let a=ba.createStringifyContext(e,t),{commentString:r}=a.options;if(e.commentBefore){if(i.length!==1)i.unshift("");let l=r(e.commentBefore);i.unshift(Tt.indentComment(l,""))}let s=!1,o=null;if(e.contents){if(Mh.isNode(e.contents)){if(e.contents.spaceBefore&&n)i.push("");if(e.contents.commentBefore){let p=r(e.contents.commentBefore);i.push(Tt.indentComment(p,""))}a.forceBlockIndent=!!e.comment,o=e.contents.comment}let l=o?void 0:()=>s=!0,c=ba.stringify(e.contents,a,()=>o=null,l);if(o)c+=Tt.lineComment(c,"",r(o));if((c[0]==="|"||c[0]===">")&&i[i.length-1]==="---")i[i.length-1]=`--- ${c}`;else i.push(c)}else i.push(ba.stringify(e.contents,a));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);if(l.includes(`
56
+ `))i.push("..."),i.push(Tt.indentComment(l,""));else i.push(`... ${l}`)}else i.push("...");else{let l=e.comment;if(l&&s)l=l.replace(/^\n+/,"");if(l){if((!s||o)&&i[i.length-1]!=="")i.push("");i.push(Tt.indentComment(r(l),""))}}return i.join(`
57
+ `)+`
58
+ `}_h.stringifyDocument=Rh});var Nt=C(function(Wh){var zh=Ct(),nt=fi(),Y=I(),Bh=Ce(),Kh=me(),Uh=ga(),Jh=yo(),Ca=pi(),Yh=Ln(),Hh=wt(),wa=Dn();class va{constructor(e,t,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Y.NODE_TYPE,{value:Y.DOC});let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(i===void 0&&t)i=t,t=void 0;let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=a;let{version:r}=a;if(i?._directives){if(this.directives=i._directives.atDocument(),this.directives.yaml.explicit)r=this.directives.yaml.version}else this.directives=new wa.Directives({version:r});this.setSchema(r,i),this.contents=e===void 0?null:this.createNode(e,n,i)}clone(){let e=Object.create(va.prototype,{[Y.NODE_TYPE]:{value:Y.DOC}});if(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();if(e.schema=this.schema.clone(),e.contents=Y.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(at(this.contents))this.contents.add(e)}addIn(e,t){if(at(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let i=Ca.anchorNames(this);e.anchor=!t||i.has(t)?Ca.findNewAnchor(t||"a",i):t}return new zh.Alias(e.anchor)}createNode(e,t,i){let n=void 0;if(typeof t==="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let h=(g)=>typeof g==="number"||g instanceof String||g instanceof Number,m=t.filter(h).map(String);if(m.length>0)t=t.concat(m);n=t}else if(i===void 0&&t)i=t,t=void 0;let{aliasDuplicateObjects:a,anchorPrefix:r,flow:s,keepUndefined:o,onTagObj:l,tag:c}=i??{},{onAnchor:p,setAnchors:d,sourceObjects:u}=Ca.createNodeAnchors(this,r||"a"),f={aliasDuplicateObjects:a??!0,keepUndefined:o??!1,onAnchor:p,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:u},y=Hh.createNode(e,c,f);if(s&&Y.isCollection(y))y.flow=!0;return d(),y}createPair(e,t,i={}){let n=this.createNode(e,null,i),a=this.createNode(t,null,i);return new Bh.Pair(n,a)}delete(e){return at(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(nt.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return at(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Y.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(nt.isEmptyPath(e))return!t&&Y.isScalar(this.contents)?this.contents.value:this.contents;return Y.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Y.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(nt.isEmptyPath(e))return this.contents!==void 0;return Y.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=nt.collectionFromPath(this.schema,[e],t);else if(at(this.contents))this.contents.set(e,t)}setIn(e,t){if(nt.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=nt.collectionFromPath(this.schema,Array.from(e),t);else if(at(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let i;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new wa.Directives({version:"1.1"});i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new wa.Directives({version:e});i={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;i=null;break;default:{let n=JSON.stringify(e);throw 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(i)this.schema=new Uh.Schema(Object.assign(i,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:i,maxAliasCount:n,onAnchor:a,reviver:r}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},o=Kh.toJS(this.contents,t??"",s);if(typeof a==="function")for(let{count:l,res:c}of s.anchors.values())a(c,l);return typeof r==="function"?Yh.applyReviver(r,{"":o},"",o):o}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw 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 Error(`"indent" option must be a positive integer, not ${t}`)}return Jh.stringifyDocument(this,e)}}function at(e){if(Y.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}Wh.Document=va});var $t=C(function(Zh){class Ri extends Error{constructor(e,t,i,n){super();this.name=e,this.code=i,this.message=n,this.pos=t}}class ho extends Ri{constructor(e,t,i){super("YAMLParseError",e,t,i)}}class mo extends Ri{constructor(e,t,i){super("YAMLWarning",e,t,i)}}var Qh=(e,t)=>(i)=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map((o)=>t.linePos(o));let{line:n,col:a}=i.linePos[0];i.message+=` at line ${n}, column ${a}`;let r=a-1,s=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(r>=60&&s.length>80){let o=Math.min(r-39,s.length-79);s="\u2026"+s.substring(o),r-=o-1}if(s.length>80)s=s.substring(0,79)+"\u2026";if(n>1&&/^ *$/.test(s.substring(0,r))){let o=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);if(o.length>80)o=o.substring(0,79)+`\u2026
59
+ `;s=o+s}if(/[^ ]/.test(s)){let o=1,l=i.linePos[1];if(l?.line===n&&l.col>a)o=Math.max(1,Math.min(l.col-a,80-r));let c=" ".repeat(r)+"^".repeat(o);i.message+=`:
60
+
61
+ ${s}
62
+ ${c}
63
+ `}};Zh.YAMLError=Ri;Zh.YAMLParseError=ho;Zh.YAMLWarning=mo;Zh.prettifyError=Qh});var Ft=C(function(rm){function am(e,{flow:t,indicator:i,next:n,offset:a,onError:r,parentIndent:s,startOnNewline:o}){let l=!1,c=o,p=o,d="",u="",f=!1,y=!1,h=null,m=null,g=null,w=null,b=null,v=null,k=null;for(let x of e){if(y){if(x.type!=="space"&&x.type!=="newline"&&x.type!=="comma")r(x.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");y=!1}if(h){if(c&&x.type!=="comment"&&x.type!=="newline")r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation");h=null}switch(x.type){case"space":if(!t&&(i!=="doc-start"||n?.type!=="flow-collection")&&x.source.includes("\t"))h=x;p=!0;break;case"comment":{if(!p)r(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let q=x.source.substring(1)||" ";if(!d)d=q;else d+=u+q;u="",c=!1;break}case"newline":if(c){if(d)d+=x.source;else if(!v||i!=="seq-item-ind")l=!0}else u+=x.source;if(c=!0,f=!0,m||g)w=x;p=!0;break;case"anchor":if(m)r(x,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(x.source.endsWith(":"))r(x.offset+x.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);m=x,k??(k=x.offset),c=!1,p=!1,y=!0;break;case"tag":{if(g)r(x,"MULTIPLE_TAGS","A node can have at most one tag");g=x,k??(k=x.offset),c=!1,p=!1,y=!0;break}case i:if(m||g)r(x,"BAD_PROP_ORDER",`Anchors and tags must be after the ${x.source} indicator`);if(v)r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.source} in ${t??"collection"}`);v=x,c=i==="seq-item-ind"||i==="explicit-key-ind",p=!1;break;case"comma":if(t){if(b)r(x,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);b=x,c=!1,p=!1;break}default:r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),c=!1,p=!1}}let V=e[e.length-1],O=V?V.offset+V.source.length:a;if(y&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!==""))r(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(h&&(c&&h.indent<=s||n?.type==="block-map"||n?.type==="block-seq"))r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:b,found:v,spaceBefore:l,comment:d,hasNewline:f,anchor:m,tag:g,newlineAfterProp:w,end:O,start:k??O}}rm.resolveProps=am});var _i=C(function(om){function xa(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
64
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let i of t.start)if(i.type==="newline")return!0;if(t.sep){for(let i of t.sep)if(i.type==="newline")return!0}if(xa(t.key)||xa(t.value))return!0}return!1;default:return!0}}om.containsNewline=xa});var Sa=C(function(dm){var cm=_i();function pm(e,t,i){if(t?.type==="flow-collection"){let n=t.end[0];if(n.indent===e&&(n.source==="]"||n.source==="}")&&cm.containsNewline(t))i(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}dm.flowIndentCheck=pm});var ka=C(function(ym){var go=I();function fm(e,t,i){let{uniqueKeys:n}=e.options;if(n===!1)return!1;let a=typeof n==="function"?n:(r,s)=>r===s||go.isScalar(r)&&go.isScalar(s)&&r.value===s.value;return t.some((r)=>a(r.key,i))}ym.mapIncludes=fm});var xo=C(function(wm){var bo=Ce(),mm=ve(),Co=Ft(),gm=_i(),wo=Sa(),bm=ka(),vo="All mapping items must start at the same column";function Cm({composeNode:e,composeEmptyNode:t},i,n,a,r){let o=new(r?.nodeClass??mm.YAMLMap)(i.schema);if(i.atRoot)i.atRoot=!1;let l=n.offset,c=null;for(let p of n.items){let{start:d,key:u,sep:f,value:y}=p,h=Co.resolveProps(d,{indicator:"explicit-key-ind",next:u??f?.[0],offset:l,onError:a,parentIndent:n.indent,startOnNewline:!0}),m=!h.found;if(m){if(u){if(u.type==="block-seq")a(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in u&&u.indent!==n.indent)a(l,"BAD_INDENT",vo)}if(!h.anchor&&!h.tag&&!f){if(c=h.end,h.comment)if(o.comment)o.comment+=`
65
+ `+h.comment;else o.comment=h.comment;continue}if(h.newlineAfterProp||gm.containsNewline(u))a(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(h.found?.indent!==n.indent)a(l,"BAD_INDENT",vo);i.atKey=!0;let g=h.end,w=u?e(i,u,h,a):t(i,g,d,null,h,a);if(i.schema.compat)wo.flowIndentCheck(n.indent,u,a);if(i.atKey=!1,bm.mapIncludes(i,o.items,w))a(g,"DUPLICATE_KEY","Map keys must be unique");let b=Co.resolveProps(f??[],{indicator:"map-value-ind",next:y,offset:w.range[2],onError:a,parentIndent:n.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=b.end,b.found){if(m){if(y?.type==="block-map"&&!b.hasNewline)a(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(i.options.strict&&h.start<b.found.offset-1024)a(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let v=y?e(i,y,b,a):t(i,l,f,null,b,a);if(i.schema.compat)wo.flowIndentCheck(n.indent,y,a);l=v.range[2];let k=new bo.Pair(w,v);if(i.options.keepSourceTokens)k.srcToken=p;o.items.push(k)}else{if(m)a(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(b.comment)if(w.comment)w.comment+=`
66
+ `+b.comment;else w.comment=b.comment;let v=new bo.Pair(w);if(i.options.keepSourceTokens)v.srcToken=p;o.items.push(v)}}if(c&&c<l)a(c,"IMPOSSIBLE","Map comment with trailing content");return o.range=[n.offset,l,c??l],o}wm.resolveBlockMap=Cm});var So=C(function(Em){var xm=xe(),Sm=Ft(),km=Sa();function Vm({composeNode:e,composeEmptyNode:t},i,n,a,r){let o=new(r?.nodeClass??xm.YAMLSeq)(i.schema);if(i.atRoot)i.atRoot=!1;if(i.atKey)i.atKey=!1;let l=n.offset,c=null;for(let{start:p,value:d}of n.items){let u=Sm.resolveProps(p,{indicator:"seq-item-ind",next:d,offset:l,onError:a,parentIndent:n.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||d)if(d?.type==="block-seq")a(u.end,"BAD_INDENT","All sequence items must start at the same column");else a(l,"MISSING_CHAR","Sequence item without - indicator");else{if(c=u.end,u.comment)o.comment=u.comment;continue}let f=d?e(i,d,u,a):t(i,u.end,p,null,u,a);if(i.schema.compat)km.flowIndentCheck(n.indent,d,a);l=f.range[2],o.items.push(f)}return o.range=[n.offset,l,c??l],o}Em.resolveBlockSeq=Vm});var rt=C(function(Gm){function Im(e,t,i,n){let a="";if(e){let r=!1,s="";for(let o of e){let{source:l,type:c}=o;switch(c){case"space":r=!0;break;case"comment":{if(i&&!r)n(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let p=l.substring(1)||" ";if(!a)a=p;else a+=s+p;s="";break}case"newline":if(a)s+=l;r=!0;break;default:n(o,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:a,offset:t}}Gm.resolveEnd=Im});var Eo=C(function(Lm){var Am=I(),Tm=Ce(),ko=ve(),Nm=xe(),$m=rt(),Vo=Ft(),Fm=_i(),qm=ka(),Va="Block collections are not allowed within flow collections",Ea=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function Dm({composeNode:e,composeEmptyNode:t},i,n,a,r){let s=n.start.source==="{",o=s?"flow map":"flow sequence",c=new(r?.nodeClass??(s?ko.YAMLMap:Nm.YAMLSeq))(i.schema);c.flow=!0;let p=i.atRoot;if(p)i.atRoot=!1;if(i.atKey)i.atKey=!1;let d=n.offset+n.start.source.length;for(let m=0;m<n.items.length;++m){let g=n.items[m],{start:w,key:b,sep:v,value:k}=g,V=Vo.resolveProps(w,{flow:o,indicator:"explicit-key-ind",next:b??v?.[0],offset:d,onError:a,parentIndent:n.indent,startOnNewline:!1});if(!V.found){if(!V.anchor&&!V.tag&&!v&&!k){if(m===0&&V.comma)a(V.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${o}`);else if(m<n.items.length-1)a(V.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${o}`);if(V.comment)if(c.comment)c.comment+=`
67
+ `+V.comment;else c.comment=V.comment;d=V.end;continue}if(!s&&i.options.strict&&Fm.containsNewline(b))a(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0){if(V.comma)a(V.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${o}`)}else{if(!V.comma)a(V.start,"MISSING_CHAR",`Missing , between ${o} items`);if(V.comment){let O="";e:for(let x of w)switch(x.type){case"comma":case"space":break;case"comment":O=x.source.substring(1);break e;default:break e}if(O){let x=c.items[c.items.length-1];if(Am.isPair(x))x=x.value??x.key;if(x.comment)x.comment+=`
68
+ `+O;else x.comment=O;V.comment=V.comment.substring(O.length+1)}}}if(!s&&!v&&!V.found){let O=k?e(i,k,V,a):t(i,V.end,v,null,V,a);if(c.items.push(O),d=O.range[2],Ea(k))a(O.range,"BLOCK_IN_FLOW",Va)}else{i.atKey=!0;let O=V.end,x=b?e(i,b,V,a):t(i,O,w,null,V,a);if(Ea(b))a(x.range,"BLOCK_IN_FLOW",Va);i.atKey=!1;let q=Vo.resolveProps(v??[],{flow:o,indicator:"map-value-ind",next:k,offset:x.range[2],onError:a,parentIndent:n.indent,startOnNewline:!1});if(q.found){if(!s&&!V.found&&i.options.strict){if(v)for(let D of v){if(D===q.found)break;if(D.type==="newline"){a(D,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(V.start<q.found.offset-1024)a(q.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(k)if("source"in k&&k.source?.[0]===":")a(k,"MISSING_CHAR",`Missing space after : in ${o}`);else a(q.start,"MISSING_CHAR",`Missing , or : between ${o} items`);let ue=k?e(i,k,q,a):q.found?t(i,q.end,v,null,q,a):null;if(ue){if(Ea(k))a(ue.range,"BLOCK_IN_FLOW",Va)}else if(q.comment)if(x.comment)x.comment+=`
69
+ `+q.comment;else x.comment=q.comment;let ze=new Tm.Pair(x,ue);if(i.options.keepSourceTokens)ze.srcToken=g;if(s){let D=c;if(qm.mapIncludes(i,D.items,x))a(O,"DUPLICATE_KEY","Map keys must be unique");D.items.push(ze)}else{let D=new ko.YAMLMap(i.schema);D.flow=!0,D.items.push(ze);let or=(ue??x).range;D.range=[x.range[0],or[1],or[2]],c.items.push(D)}d=ue?ue.range[2]:q.end}}let u=s?"}":"]",[f,...y]=n.end,h=d;if(f?.source===u)h=f.offset+f.source.length;else{let m=o[0].toUpperCase()+o.substring(1),g=p?`${m} must end with a ${u}`:`${m} in block collection must be sufficiently indented and end with a ${u}`;if(a(d,p?"MISSING_CHAR":"BAD_INDENT",g),f&&f.source.length!==1)y.unshift(f)}if(y.length>0){let m=$m.resolveEnd(y,h,i.options.strict,a);if(m.comment)if(c.comment)c.comment+=`
70
+ `+m.comment;else c.comment=m.comment;c.range=[n.offset,h,m.offset]}else c.range=[n.offset,h,h];return c}Lm.resolveFlowCollection=Dm});var Po=C(function(Ym){var Rm=I(),_m=N(),jm=ve(),zm=xe(),Bm=xo(),Km=So(),Um=Eo();function Pa(e,t,i,n,a,r){let s=i.type==="block-map"?Bm.resolveBlockMap(e,t,i,n,r):i.type==="block-seq"?Km.resolveBlockSeq(e,t,i,n,r):Um.resolveFlowCollection(e,t,i,n,r),o=s.constructor;if(a==="!"||a===o.tagName)return s.tag=o.tagName,s;if(a)s.tag=a;return s}function Jm(e,t,i,n,a){let r=n.tag,s=!r?null:t.directives.tagName(r.source,(u)=>a(r,"TAG_RESOLVE_FAILED",u));if(i.type==="block-seq"){let{anchor:u,newlineAfterProp:f}=n,y=u&&r?u.offset>r.offset?u:r:u??r;if(y&&(!f||f.offset<y.offset))a(y,"MISSING_CHAR","Missing newline after block sequence props")}let o=i.type==="block-map"?"map":i.type==="block-seq"?"seq":i.start.source==="{"?"map":"seq";if(!r||!s||s==="!"||s===jm.YAMLMap.tagName&&o==="map"||s===zm.YAMLSeq.tagName&&o==="seq")return Pa(e,t,i,a,s);let l=t.schema.tags.find((u)=>u.tag===s&&u.collection===o);if(!l){let u=t.schema.knownTags[s];if(u?.collection===o)t.schema.tags.push(Object.assign({},u,{default:!1})),l=u;else{if(u)a(r,"BAD_COLLECTION_TYPE",`${u.tag} used for ${o} collection, but expects ${u.collection??"scalar"}`,!0);else a(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0);return Pa(e,t,i,a,s)}}let c=Pa(e,t,i,a,s,l),p=l.resolve?.(c,(u)=>a(r,"TAG_RESOLVE_FAILED",u),t.options)??c,d=Rm.isNode(p)?p:new _m.Scalar(p);if(d.range=c.range,d.tag=s,l?.format)d.format=l.format;return d}Ym.composeCollection=Jm});var Ga=C(function(Zm){var Ia=N();function Wm(e,t,i){let n=t.offset,a=Xm(t,e.options.strict,i);if(!a)return{value:"",type:null,comment:"",range:[n,n,n]};let r=a.mode===">"?Ia.Scalar.BLOCK_FOLDED:Ia.Scalar.BLOCK_LITERAL,s=t.source?Qm(t.source):[],o=s.length;for(let h=s.length-1;h>=0;--h){let m=s[h][1];if(m===""||m==="\r")o=h;else break}if(o===0){let h=a.chomp==="+"&&s.length>0?`
71
+ `.repeat(Math.max(1,s.length-1)):"",m=n+a.length;if(t.source)m+=t.source.length;return{value:h,type:r,comment:a.comment,range:[n,m,m]}}let l=t.indent+a.indent,c=t.offset+a.length,p=0;for(let h=0;h<o;++h){let[m,g]=s[h];if(g===""||g==="\r"){if(a.indent===0&&m.length>l)l=m.length}else{if(m.length<l)i(c+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(a.indent===0)l=m.length;if(p=h,l===0&&!e.atRoot)i(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=m.length+g.length+1}for(let h=s.length-1;h>=o;--h)if(s[h][0].length>l)o=h+1;let d="",u="",f=!1;for(let h=0;h<p;++h)d+=s[h][0].slice(l)+`
72
+ `;for(let h=p;h<o;++h){let[m,g]=s[h];c+=m.length+g.length+1;let w=g[g.length-1]==="\r";if(w)g=g.slice(0,-1);if(g&&m.length<l){let v=`Block scalar lines must not be less indented than their ${a.indent?"explicit indentation indicator":"first line"}`;i(c-g.length-(w?2:1),"BAD_INDENT",v),m=""}if(r===Ia.Scalar.BLOCK_LITERAL)d+=u+m.slice(l)+g,u=`
73
+ `;else if(m.length>l||g[0]==="\t"){if(u===" ")u=`
74
+ `;else if(!f&&u===`
75
+ `)u=`
76
+
77
+ `;d+=u+m.slice(l)+g,u=`
78
+ `,f=!0}else if(g==="")if(u===`
79
+ `)d+=`
80
+ `;else u=`
81
+ `;else d+=u+g,u=" ",f=!1}switch(a.chomp){case"-":break;case"+":for(let h=o;h<s.length;++h)d+=`
82
+ `+s[h][0].slice(l);if(d[d.length-1]!==`
83
+ `)d+=`
84
+ `;break;default:d+=`
85
+ `}let y=n+a.length+t.source.length;return{value:d,type:r,comment:a.comment,range:[n,y,y]}}function Xm({offset:e,props:t},i,n){if(t[0].type!=="block-scalar-header")return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:a}=t[0],r=a[0],s=0,o="",l=-1;for(let u=1;u<a.length;++u){let f=a[u];if(!o&&(f==="-"||f==="+"))o=f;else{let y=Number(f);if(!s&&y)s=y;else if(l===-1)l=e+u}}if(l!==-1)n(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${a}`);let c=!1,p="",d=a.length;for(let u=1;u<t.length;++u){let f=t[u];switch(f.type){case"space":c=!0;case"newline":d+=f.source.length;break;case"comment":if(i&&!c)n(f,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");d+=f.source.length,p=f.source.substring(1);break;case"error":n(f,"UNEXPECTED_TOKEN",f.message),d+=f.source.length;break;default:{let y=`Unexpected token in block scalar header: ${f.type}`;n(f,"UNEXPECTED_TOKEN",y);let h=f.source;if(h&&typeof h==="string")d+=h.length}}}return{mode:r,indent:s,chomp:o,comment:p,length:d}}function Qm(e){let t=e.split(/\n( *)/),i=t[0],n=i.match(/^( *)/),r=[n?.[1]?[n[1],i.slice(n[1].length)]:["",i]];for(let s=1;s<t.length;s+=2)r.push([t[s],t[s+1]]);return r}Zm.resolveBlockScalar=Wm});var Aa=C(function(cg){var Oa=N(),tg=rt();function ig(e,t,i){let{offset:n,type:a,source:r,end:s}=e,o,l,c=(u,f,y)=>i(n+u,f,y);switch(a){case"scalar":o=Oa.Scalar.PLAIN,l=ng(r,c);break;case"single-quoted-scalar":o=Oa.Scalar.QUOTE_SINGLE,l=ag(r,c);break;case"double-quoted-scalar":o=Oa.Scalar.QUOTE_DOUBLE,l=rg(r,c);break;default:return i(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${a}`),{value:"",type:null,comment:"",range:[n,n+r.length,n+r.length]}}let p=n+r.length,d=tg.resolveEnd(s,p,t,i);return{value:l,type:o,comment:d.comment,range:[n,p,d.offset]}}function ng(e,t){let i="";switch(e[0]){case"\t":i="a tab character";break;case",":i="flow indicator character ,";break;case"%":i="directive indicator character %";break;case"|":case">":{i=`block scalar indicator ${e[0]}`;break}case"@":case"`":{i=`reserved character ${e[0]}`;break}}if(i)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`);return Io(e)}function ag(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return Io(e.slice(1,-1)).replace(/''/g,"'")}function Io(e){let t,i;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
86
+ `,"sy"),i=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
87
+ `,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,i=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=t.exec(e);if(!n)return e;let a=n[1],r=" ",s=t.lastIndex;i.lastIndex=s;while(n=i.exec(e)){if(n[1]==="")if(r===`
88
+ `)a+=r;else r=`
89
+ `;else a+=r+n[1],r=" ";s=i.lastIndex}let o=/[ \t]*(.*)/sy;return o.lastIndex=s,n=o.exec(e),a+r+(n?.[1]??"")}function rg(e,t){let i="";for(let n=1;n<e.length-1;++n){let a=e[n];if(a==="\r"&&e[n+1]===`
90
+ `)continue;if(a===`
91
+ `){let{fold:r,offset:s}=sg(e,n);i+=r,n=s}else if(a==="\\"){let r=e[++n],s=og[r];if(s)i+=s;else if(r===`
92
+ `){r=e[n+1];while(r===" "||r==="\t")r=e[++n+1]}else if(r==="\r"&&e[n+1]===`
93
+ `){r=e[++n+1];while(r===" "||r==="\t")r=e[++n+1]}else if(r==="x"||r==="u"||r==="U"){let o=r==="x"?2:r==="u"?4:8;i+=lg(e,n+1,o,t),n+=o}else{let o=e.substr(n-1,2);t(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${o}`),i+=o}}else if(a===" "||a==="\t"){let r=n,s=e[n+1];while(s===" "||s==="\t")s=e[++n+1];if(s!==`
94
+ `&&!(s==="\r"&&e[n+2]===`
95
+ `))i+=n>r?e.slice(r,n+1):a}else i+=a}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return i}function sg(e,t){let i="",n=e[t+1];while(n===" "||n==="\t"||n===`
96
+ `||n==="\r"){if(n==="\r"&&e[t+2]!==`
97
+ `)break;if(n===`
98
+ `)i+=`
99
+ `;t+=1,n=e[t+1]}if(!i)i=" ";return{fold:i,offset:t}}var og={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
100
+ `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function lg(e,t,i,n){let a=e.substr(t,i),s=a.length===i&&/^[0-9a-fA-F]+$/.test(a)?parseInt(a,16):NaN;try{return String.fromCodePoint(s)}catch{let o=e.substr(t-2,i+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${o}`),o}}cg.resolveFlowScalar=ig});var Oo=C(function(mg){var $e=I(),Go=N(),dg=Ga(),ug=Aa();function fg(e,t,i,n){let{value:a,type:r,comment:s,range:o}=t.type==="block-scalar"?dg.resolveBlockScalar(e,t,n):ug.resolveFlowScalar(t,e.options.strict,n),l=i?e.directives.tagName(i.source,(d)=>n(i,"TAG_RESOLVE_FAILED",d)):null,c;if(e.options.stringKeys&&e.atKey)c=e.schema[$e.SCALAR];else if(l)c=yg(e.schema,a,l,i,n);else if(t.type==="scalar")c=hg(e,a,t,n);else c=e.schema[$e.SCALAR];let p;try{let d=c.resolve(a,(u)=>n(i??t,"TAG_RESOLVE_FAILED",u),e.options);p=$e.isScalar(d)?d:new Go.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);n(i??t,"TAG_RESOLVE_FAILED",u),p=new Go.Scalar(a)}if(p.range=o,p.source=a,r)p.type=r;if(l)p.tag=l;if(c.format)p.format=c.format;if(s)p.comment=s;return p}function yg(e,t,i,n,a){if(i==="!")return e[$e.SCALAR];let r=[];for(let o of e.tags)if(!o.collection&&o.tag===i)if(o.default&&o.test)r.push(o);else return o;for(let o of r)if(o.test?.test(t))return o;let s=e.knownTags[i];if(s&&!s.collection)return e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s;return a(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),e[$e.SCALAR]}function hg({atKey:e,directives:t,schema:i},n,a,r){let s=i.tags.find((o)=>(o.default===!0||e&&o.default==="key")&&o.test?.test(n))||i[$e.SCALAR];if(i.compat){let o=i.compat.find((l)=>l.default&&l.test?.test(n))??i[$e.SCALAR];if(s.tag!==o.tag){let l=t.tagString(s.tag),c=t.tagString(o.tag),p=`Value may be parsed as either ${l} or ${c}`;r(a,"TAG_RESOLVE_FAILED",p,!0)}}return s}mg.composeScalar=fg});var Ao=C(function(Cg){function bg(e,t,i){if(t){i??(i=t.length);for(let n=i-1;n>=0;--n){let a=t[n];switch(a.type){case"space":case"comment":case"newline":e-=a.source.length;continue}a=t[++n];while(a?.type==="space")e+=a.source.length,a=t[++n];break}}return e}Cg.emptyScalarPosition=bg});var $o=C(function(Ig){var vg=Ct(),xg=I(),Sg=Po(),To=Oo(),kg=rt(),Vg=Ao(),Eg={composeNode:No,composeEmptyNode:Ta};function No(e,t,i,n){let a=e.atKey,{spaceBefore:r,comment:s,anchor:o,tag:l}=i,c,p=!0;switch(t.type){case"alias":if(c=Pg(e,t,n),o||l)n(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(c=To.composeScalar(e,t,l,n),o)c.anchor=o.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(c=Sg.composeCollection(Eg,e,t,i,n),o)c.anchor=o.source.substring(1)}catch(d){let u=d instanceof Error?d.message:String(d);n(t,"RESOURCE_EXHAUSTION",u)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;n(t,"UNEXPECTED_TOKEN",d),p=!1}}if(c??(c=Ta(e,t.offset,void 0,null,i,n)),o&&c.anchor==="")n(o,"BAD_ALIAS","Anchor cannot be an empty string");if(a&&e.options.stringKeys&&(!xg.isScalar(c)||typeof c.value!=="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str"))n(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(r)c.spaceBefore=!0;if(s)if(t.type==="scalar"&&t.source==="")c.comment=s;else c.commentBefore=s;if(e.options.keepSourceTokens&&p)c.srcToken=t;return c}function Ta(e,t,i,n,{spaceBefore:a,comment:r,anchor:s,tag:o,end:l},c){let p={type:"scalar",offset:Vg.emptyScalarPosition(t,i,n),indent:-1,source:""},d=To.composeScalar(e,p,o,c);if(s){if(d.anchor=s.source.substring(1),d.anchor==="")c(s,"BAD_ALIAS","Anchor cannot be an empty string")}if(a)d.spaceBefore=!0;if(r)d.comment=r,d.range[2]=l;return d}function Pg({options:e},{offset:t,source:i,end:n},a){let r=new vg.Alias(i.substring(1));if(r.source==="")a(t,"BAD_ALIAS","Alias cannot be an empty string");if(r.source.endsWith(":"))a(t+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=t+i.length,o=kg.resolveEnd(n,s,e.strict,a);if(r.range=[t,s,o.offset],o.comment)r.comment=o.comment;return r}Ig.composeEmptyNode=Ta;Ig.composeNode=No});var qo=C(function(Fg){var Ag=Nt(),Fo=$o(),Tg=rt(),Ng=Ft();function $g(e,t,{offset:i,start:n,value:a,end:r},s){let o=Object.assign({_directives:t},e),l=new Ag.Document(void 0,o),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},p=Ng.resolveProps(n,{indicator:"doc-start",next:a??r?.[0],offset:i,onError:s,parentIndent:0,startOnNewline:!0});if(p.found){if(l.directives.docStart=!0,a&&(a.type==="block-map"||a.type==="block-seq")&&!p.hasNewline)s(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}l.contents=a?Fo.composeNode(c,a,p,s):Fo.composeEmptyNode(c,p.end,n,null,p,s);let d=l.contents.range[2],u=Tg.resolveEnd(r,d,!1,s);if(u.comment)l.comment=u.comment;return l.range=[i,d,u.offset],l}Fg.composeDoc=$g});var Na=C(function(jg){var Dg=Bt("process"),Lg=Dn(),Mg=Nt(),qt=$t(),Do=I(),Rg=qo(),_g=rt();function Dt(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:i}=e;return[t,t+(typeof i==="string"?i.length:1)]}function Lo(e){let t="",i=!1,n=!1;for(let a=0;a<e.length;++a){let r=e[a];switch(r[0]){case"#":t+=(t===""?"":n?`
101
+
102
+ `:`
103
+ `)+(r.substring(1)||" "),i=!0,n=!1;break;case"%":if(e[a+1]?.[0]!=="#")a+=1;i=!1;break;default:if(!i)n=!0;i=!1}}return{comment:t,afterEmptyLine:n}}class Mo{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,i,n,a)=>{let r=Dt(t);if(a)this.warnings.push(new qt.YAMLWarning(r,i,n));else this.errors.push(new qt.YAMLParseError(r,i,n))},this.directives=new Lg.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:i,afterEmptyLine:n}=Lo(this.prelude);if(i){let a=e.contents;if(t)e.comment=e.comment?`${e.comment}
104
+ ${i}`:i;else if(n||e.directives.docStart||!a)e.commentBefore=i;else if(Do.isCollection(a)&&!a.flow&&a.items.length>0){let r=a.items[0];if(Do.isPair(r))r=r.key;let s=r.commentBefore;r.commentBefore=s?`${i}
105
+ ${s}`:i}else{let r=a.commentBefore;a.commentBefore=r?`${i}
106
+ ${r}`:i}}if(t){for(let a=0;a<this.errors.length;++a)e.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)e.warnings.push(this.warnings[a])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Lo(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,i=-1){for(let n of e)yield*this.next(n);yield*this.end(t,i)}*next(e){if(Dg.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,i,n)=>{let a=Dt(e);a[0]+=t,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=Rg.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(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,i=new qt.YAMLParseError(Dt(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(i);else this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){this.errors.push(new qt.YAMLParseError(Dt(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));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 i=this.doc.comment;this.doc.comment=i?`${i}
107
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new qt.YAMLParseError(Dt(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 i=Object.assign({_directives:this.directives},this.options),n=new Mg.Document(void 0,i);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");n.range=[0,t,t],this.decorate(n,!1),yield n}}}jg.Composer=Mo});var jo=C(function(Xg){var Bg=Ga(),Kg=Aa(),Ug=$t(),Ro=St();function Jg(e,t=!0,i){if(e){let n=(a,r,s)=>{let o=typeof a==="number"?a:Array.isArray(a)?a[0]:a.offset;if(i)i(o,r,s);else throw new Ug.YAMLParseError([o,o+1],r,s)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Kg.resolveFlowScalar(e,t,n);case"block-scalar":return Bg.resolveBlockScalar({options:{strict:t}},e,n)}}return null}function Yg(e,t){let{implicitKey:i=!1,indent:n,inFlow:a=!1,offset:r=-1,type:s="PLAIN"}=t,o=Ro.stringifyString({type:s,value:e},{implicitKey:i,indent:n>0?" ".repeat(n):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:n,source:`
108
+ `}];switch(o[0]){case"|":case">":{let c=o.indexOf(`
109
+ `),p=o.substring(0,c),d=o.substring(c+1)+`
110
+ `,u=[{type:"block-scalar-header",offset:r,indent:n,source:p}];if(!_o(u,l))u.push({type:"newline",offset:-1,indent:n,source:`
111
+ `});return{type:"block-scalar",offset:r,indent:n,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:r,indent:n,source:o,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:n,source:o,end:l};default:return{type:"scalar",offset:r,indent:n,source:o,end:l}}}function Hg(e,t,i={}){let{afterKey:n=!1,implicitKey:a=!1,inFlow:r=!1,type:s}=i,o="indent"in e?e.indent:null;if(n&&typeof o==="number")o+=2;if(!s)switch(e.type){case"single-quoted-scalar":s="QUOTE_SINGLE";break;case"double-quoted-scalar":s="QUOTE_DOUBLE";break;case"block-scalar":{let c=e.props[0];if(c.type!=="block-scalar-header")throw Error("Invalid block scalar header");s=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let l=Ro.stringifyString({type:s,value:t},{implicitKey:a||o===null,indent:o!==null&&o>0?" ".repeat(o):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":Wg(e,l);break;case'"':$a(e,l,"double-quoted-scalar");break;case"'":$a(e,l,"single-quoted-scalar");break;default:$a(e,l,"scalar")}}function Wg(e,t){let i=t.indexOf(`
112
+ `),n=t.substring(0,i),a=t.substring(i+1)+`
113
+ `;if(e.type==="block-scalar"){let r=e.props[0];if(r.type!=="block-scalar-header")throw Error("Invalid block scalar header");r.source=n,e.source=a}else{let{offset:r}=e,s="indent"in e?e.indent:-1,o=[{type:"block-scalar-header",offset:r,indent:s,source:n}];if(!_o(o,"end"in e?e.end:void 0))o.push({type:"newline",offset:-1,indent:s,source:`
114
+ `});for(let l of Object.keys(e))if(l!=="type"&&l!=="offset")delete e[l];Object.assign(e,{type:"block-scalar",indent:s,props:o,source:a})}}function _o(e,t){if(t)for(let i of t)switch(i.type){case"space":case"comment":e.push(i);break;case"newline":return e.push(i),!0}return!1}function $a(e,t,i){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=i,e.source=t;break;case"block-scalar":{let n=e.props.slice(1),a=t.length;if(e.props[0].type==="block-scalar-header")a-=e.props[0].source.length;for(let r of n)r.offset+=a;delete e.props,Object.assign(e,{type:i,source:t,end:n});break}case"block-map":case"block-seq":{let a={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
115
+ `};delete e.items,Object.assign(e,{type:i,source:t,end:[a]});break}default:{let n="indent"in e?e.indent:-1,a="end"in e&&Array.isArray(e.end)?e.end.filter((r)=>r.type==="space"||r.type==="comment"||r.type==="newline"):[];for(let r of Object.keys(e))if(r!=="type"&&r!=="offset")delete e[r];Object.assign(e,{type:i,indent:n,source:t,end:a})}}}Xg.createScalarToken=Yg;Xg.resolveAsScalar=Jg;Xg.setScalarValue=Hg});var zo=C(function(ib){var tb=(e)=>("type"in e)?zi(e):ji(e);function zi(e){switch(e.type){case"block-scalar":{let t="";for(let i of e.props)t+=zi(i);return t+e.source}case"block-map":case"block-seq":{let t="";for(let i of e.items)t+=ji(i);return t}case"flow-collection":{let t=e.start.source;for(let i of e.items)t+=ji(i);for(let i of e.end)t+=i.source;return t}case"document":{let t=ji(e);if(e.end)for(let i of e.end)t+=i.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let i of e.end)t+=i.source;return t}}}function ji({start:e,key:t,sep:i,value:n}){let a="";for(let r of e)a+=r.source;if(t)a+=zi(t);if(i)for(let r of i)a+=r.source;if(n)a+=zi(n);return a}ib.stringify=tb});var Uo=C(function(rb){var Fa=Symbol("break visit"),ab=Symbol("skip children"),Bo=Symbol("remove item");function Fe(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Ko(Object.freeze([]),e,t)}Fe.BREAK=Fa;Fe.SKIP=ab;Fe.REMOVE=Bo;Fe.itemAtPath=(e,t)=>{let i=e;for(let[n,a]of t){let r=i?.[n];if(r&&"items"in r)i=r.items[a];else return}return i};Fe.parentCollection=(e,t)=>{let i=Fe.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],a=i?.[n];if(a&&"items"in a)return a;throw Error("Parent collection not found")};function Ko(e,t,i){let n=i(t,e);if(typeof n==="symbol")return n;for(let a of["key","value"]){let r=t[a];if(r&&"items"in r){for(let s=0;s<r.items.length;++s){let o=Ko(Object.freeze(e.concat([[a,s]])),r.items[s],i);if(typeof o==="number")s=o-1;else if(o===Fa)return Fa;else if(o===Bo)r.items.splice(s,1),s-=1}if(typeof n==="function"&&a==="key")n=n(t,e)}}return typeof n==="function"?n(t,e):n}rb.visit=Fe});var Bi=C(function(fb){var qa=jo(),ob=zo(),lb=Uo(),Da="\uFEFF",La="\x02",Ma="\x18",Ra="\x1F",cb=(e)=>!!e&&("items"in e),pb=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function db(e){switch(e){case Da:return"<BOM>";case La:return"<DOC>";case Ma:return"<FLOW_END>";case Ra:return"<SCALAR>";default:return JSON.stringify(e)}}function ub(e){switch(e){case Da:return"byte-order-mark";case La:return"doc-mode";case Ma:return"flow-error-end";case Ra:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
116
+ `:case`\r
117
+ `: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(e[0]){case" ":case"\t":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}fb.createScalarToken=qa.createScalarToken;fb.resolveAsScalar=qa.resolveAsScalar;fb.setScalarValue=qa.setScalarValue;fb.stringify=ob.stringify;fb.visit=lb.visit;fb.BOM=Da;fb.DOCUMENT=La;fb.FLOW_END=Ma;fb.SCALAR=Ra;fb.isCollection=cb;fb.isScalar=pb;fb.prettyToken=db;fb.tokenType=ub});var ja=C(function(Gb){var Lt=Bi();function ee(e){switch(e){case void 0:case" ":case`
118
+ `:case"\r":case"\t":return!0;default:return!1}}var Jo=new Set("0123456789ABCDEFabcdef"),Pb=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Ki=new Set(",[]{}"),Ib=new Set(` ,[]{}
119
+ \r `),_a=(e)=>!e||Ib.has(e);class Yo{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 i=this.next??"stream";while(i&&(t||this.hasChars(1)))i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
120
+ `)return!0;if(t==="\r")return this.buffer[e+1]===`
121
+ `;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let i=0;while(t===" ")t=this.buffer[++i+e];if(t==="\r"){let n=this.buffer[i+e+1];if(n===`
122
+ `||!n&&!this.atEnd)return e+i+1}return t===`
123
+ `||i>=this.indentNext||!t&&!this.atEnd?e+i:-1}if(t==="-"||t==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&ee(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;if(typeof e!=="number"||e!==-1&&e<this.pos)e=this.buffer.indexOf(`
124
+ `,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return 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]===Lt.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,i=e.indexOf("#");while(i!==-1){let a=e[i-1];if(a===" "||a==="\t"){t=i-1;break}else i=e.indexOf("#",i+1)}while(!0){let a=e[t-1];if(a===" "||a==="\t")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 Lt.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"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ee(this.charAt(1)))this.indentNext=this.indentValue;return 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 i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}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(_a),"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,i=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=i=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let n=this.getLine();if(n===null)return this.setNext("flow");if(i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&ee(n[3])){if(!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Lt.FLOW_END,yield*this.parseLineStart()}let a=0;while(n[a]===",")a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),n[a]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-a),"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(_a),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let r=this.charAt(1);if(this.flowKey||ee(r)||r===",")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==="'")while(t!==-1&&this.buffer[t+1]==="'")t=this.buffer.indexOf("'",t+2);else while(t!==-1){let a=0;while(this.buffer[t-1-a]==="\\")a+=1;if(a%2===0)break;t=this.buffer.indexOf('"',t+1)}let i=this.buffer.substring(0,t),n=i.indexOf(`
125
+ `,this.pos);if(n!==-1){while(n!==-1){let a=this.continueScalar(n+1);if(a===-1)break;n=i.indexOf(`
126
+ `,a)}if(n!==-1)t=n-(i[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;while(!0){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,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":t+=1;break;case`
127
+ `:e=a,t=0;break;case"\r":{let r=this.buffer[a+1];if(!r&&!this.atEnd)return this.setNext("block-scalar");if(r===`
128
+ `)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=t;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(e+1);if(a===-1)break;e=this.buffer.indexOf(`
129
+ `,a)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;i=this.buffer[n];while(i===" ")i=this.buffer[++n];if(i==="\t"){while(i==="\t"||i===" "||i==="\r"||i===`
130
+ `)i=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let a=e-1,r=this.buffer[a];if(r==="\r")r=this.buffer[--a];let s=a;while(r===" ")r=this.buffer[--a];if(r===`
131
+ `&&a>=this.pos&&a+1+t>s)e=a;else break}while(!0);return yield Lt.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,i=this.pos-1,n;while(n=this.buffer[++i])if(n===":"){let a=this.buffer[i+1];if(ee(a)||e&&Ki.has(a))break;t=i}else if(ee(n)){let a=this.buffer[i+1];if(n==="\r")if(a===`
132
+ `)i+=1,n=`
133
+ `,a=this.buffer[i+1];else t=i;if(a==="#"||e&&Ki.has(a))break;if(n===`
134
+ `){let r=this.continueScalar(i+1);if(r===-1)break;i=Math.max(i,r-2)}}else{if(e&&Ki.has(n))break;t=i}if(!n&&!this.atEnd)return this.setNext("plain-scalar");return yield Lt.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let i=this.buffer.slice(this.pos,e);if(i)return yield i,this.pos+=i.length,i.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(_a),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,i=this.charAt(1);if(ee(i)||t&&Ki.has(i)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!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];while(t)if(Pb.has(t))t=this.buffer[++e];else if(t==="%"&&Jo.has(this.buffer[e+1])&&Jo.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];if(e===`
135
+ `)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
136
+ `)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,i;do i=this.buffer[++t];while(i===" "||e&&i==="\t");let n=t-this.pos;if(n>0)yield this.buffer.substr(this.pos,n),this.pos=t;return n}*pushUntil(e){let t=this.pos,i=this.buffer[t];while(!e(i))i=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}Gb.Lexer=Yo});var za=C(function(Ab){class Ho{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,i=this.lineStarts.length;while(t<i){let a=t+i>>1;if(this.lineStarts[a]<e)t=a+1;else i=a}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}}}}Ab.LineCounter=Ho});var Ba=C(function(Fb){var Nb=Bt("process"),Wo=Bi(),$b=ja();function Se(e,t){for(let i=0;i<e.length;++i)if(e[i].type===t)return!0;return!1}function Xo(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Zo(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Ui(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function st(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function Ji(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let i=0;i<t.length;++i)e.push(t[i])}function Qo(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!Se(t.start,"explicit-key-ind")&&!Se(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,Zo(t.value))if(t.value.end)Ji(t.value.end,t.sep);else t.value.end=t.sep;else Ji(t.start,t.sep);delete t.sep}}}class el{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 $b.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let i of this.lexer.lex(e,t))yield*this.next(i);if(!t)yield*this.end()}*next(e){if(this.source=e,Nb.env.LOG_TOKENS)console.log("|",Wo.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Wo.tokenType(e);if(!t){let i=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(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"){while(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 i=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in i?i.indent:0;else if(t.type==="flow-collection"&&i.type==="document")t.indent=0;if(t.type==="flow-collection")Qo(t);switch(i.type){case"document":i.value=t;break;case"block-scalar":i.props.push(t);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.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=i.items[i.items.length-1];if(n.value)i.items.push({start:[],value:t});else n.value=t;break}case"flow-collection":{let n=i.items[i.items.length-1];if(!n||n.value)i.items.push({start:[],key:t,sep:[]});else if(n.sep)n.value=t;else Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];if(n&&!n.sep&&!n.value&&n.start.length>0&&Xo(n.start)===-1&&(t.indent===0||n.start.every((a)=>a.type!=="comment"||a.indent<t.indent))){if(i.type==="document")i.end=n.start;else i.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:[]};if(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":{if(Xo(e.start)!==-1)yield*this.pop(),yield*this.step();else 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);if(t)this.stack.push(t);else 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=Ui(this.peek(2)),i=st(t),n;if(e.end)n=e.end,n.push(this.sourceToken),delete e.end;else n=[this.sourceToken];let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}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(`
137
+ `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
138
+ `,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 i="end"in t.value?t.value.end:void 0;if((Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment")i?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else 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)){Ji(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let i=!this.onKeyLine&&this.indent===e.indent,n=i&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&t.sep&&!t.value){let r=[];for(let s=0;s<t.sep.length;++s){let o=t.sep[s];switch(o.type){case"newline":r.push(s);break;case"space":break;case"comment":if(o.indent>e.indent)r.length=0;break;default:r.length=0}}if(r.length>=2)a=t.sep.splice(r[1])}switch(this.type){case"anchor":case"tag":if(n||t.value)a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(n||t.value)a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0});else 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(Se(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let r=st(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Se(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(Zo(t.key)&&!Se(t.sep,"newline")){let r=st(t.start),{key:s,sep:o}=t;o.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:s,sep:o}]})}else if(a.length>0)t.sep=t.sep.concat(a,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||n)e.items.push({start:a,key:null,sep:[this.sourceToken]});else if(Se(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);if(n||t.value)e.items.push({start:a,key:r,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(r);else Object.assign(t,{key:r,sep:[]}),this.onKeyLine=!0;return}default:{let r=this.startBlockValue(e);if(r){if(r.type==="block-seq"){if(!t.explicitKey&&t.sep&&!Se(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 if(i)e.items.push({start:a});this.stack.push(r);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 i="end"in t.value?t.value.end:void 0;if((Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment")i?.push(this.sourceToken);else 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)){Ji(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;if(t.value||Se(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:n,sep:[]});else if(t.sep)this.stack.push(n);else Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let i=this.startBlockValue(e);if(i)this.stack.push(i);else yield*this.pop(),yield*this.step()}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=Ui(i),a=st(n);Qo(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:a,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
139
+ `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
140
+ `,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=Ui(e),i=st(t);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Ui(e),i=st(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((i)=>i.type==="newline"||i.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(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;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}Fb.Parser=el});var rl=C(function(Bb){var tl=Na(),Db=Nt(),Mt=$t(),Lb=zn(),Mb=I(),Rb=za(),il=Ba();function nl(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Rb.LineCounter||null,prettyErrors:t}}function _b(e,t={}){let{lineCounter:i,prettyErrors:n}=nl(t),a=new il.Parser(i?.addNewLine),r=new tl.Composer(t),s=Array.from(r.compose(a.parse(e)));if(n&&i)for(let o of s)o.errors.forEach(Mt.prettifyError(e,i)),o.warnings.forEach(Mt.prettifyError(e,i));if(s.length>0)return s;return Object.assign([],{empty:!0},r.streamInfo())}function al(e,t={}){let{lineCounter:i,prettyErrors:n}=nl(t),a=new il.Parser(i?.addNewLine),r=new tl.Composer(t),s=null;for(let o of r.compose(a.parse(e),!0,e.length))if(!s)s=o;else if(s.options.logLevel!=="silent"){s.errors.push(new Mt.YAMLParseError(o.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(n&&i)s.errors.forEach(Mt.prettifyError(e,i)),s.warnings.forEach(Mt.prettifyError(e,i));return s}function jb(e,t,i){let n=void 0;if(typeof t==="function")n=t;else if(i===void 0&&t&&typeof t==="object")i=t;let a=al(e,i);if(!a)return null;if(a.warnings.forEach((r)=>Lb.warn(a.options.logLevel,r)),a.errors.length>0)if(a.options.logLevel!=="silent")throw a.errors[0];else a.errors=[];return a.toJS(Object.assign({reviver:n},i))}function zb(e,t,i){let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(i===void 0&&t)i=t;if(typeof i==="string")i=i.length;if(typeof i==="number"){let a=Math.round(i);i=a<1?void 0:a>8?{indent:8}:{indent:a}}if(e===void 0){let{keepUndefined:a}=i??t??{};if(!a)return}if(Mb.isDocument(e)&&!n)return e.toString(i);return new Db.Document(e,n,i).toString(i)}Bb.parse=jb;Bb.parseAllDocuments=_b;Bb.parseDocument=al;Bb.stringify=zb});import{pkg as Hw,registerCapabilityGraphClassifierFactory as Ww,registerCapabilityGraphRuntimeProvider as Xw}from"@mcp-com-ai/core";import{definePlugin as Qw,HAPI_CLI_API_VERSION as Zw}from"@mcp-com-ai/plugin-sdk";var lr="@mcp-com-ai/plugin-capability-graph",cr="1.3.0",pr="Compile OpenAPI documents into deterministic HAPI capability graphs.";var $l=new Set(["a","an","and","as","at","be","by","for","from","in","it","of","on","or","the","them","this","to","user","without"]);class fe{id="deterministic-v1";async classify(e){ur(e.signal);let t=[],i=e.query.trim();if(!i)return{outcome:"no-match",matches:[],diagnostics:t};if(i.length>2000)return{outcome:"no-match",matches:[],diagnostics:[{code:"query-too-long",severity:"error",message:"Capability graph queries are limited to 2000 characters"}]};let n=new Map(e.graph.operations.map((c)=>[c.id,c])),a=new Map(e.graph.capabilities.map((c)=>[c.id,c.label])),r=e.mode==="regex"?Ll(i,t):void 0;if(e.mode==="regex"&&!r)return{outcome:"no-match",matches:[],diagnostics:t};let s=[];for(let c of e.candidates){ur(e.signal);let p=n.get(c.operationId);if(!p||!Be(p,e.principal))continue;let d=r?ql(r,c.toolName,p,a):Fl(i,c.toolName,p,a);if(d.score<=0)continue;s.push({toolName:c.toolName,operationId:p.id,score:d.score,reason:d.reason})}s.sort(Rl);let o=Ml(e.limit),l=s.slice(0,o);return{outcome:l.length>0?"ranked":"no-match",matches:l,diagnostics:t}}}function Be(e,t){if(e.authorization.length===0)return!0;if(!jl(t))return t===void 0;if(t.authorizedOperationIds)return t.authorizedOperationIds.includes(e.id);let i=new Set(t.scopes??[]),n=t.schemes??{};return e.authorization.some((a)=>a.schemes.every((r)=>{let s=n[r.scheme];if(s){let o=new Set(s);return r.scopes.every((l)=>o.has(l))}return r.scopes.length>0&&r.scopes.every((o)=>i.has(o))}))}function Fl(e,t,i,n){let a=on(e),r=fr(t,i,n),s=0,o=[];for(let l of r.positive){let c=dr(a,on(l.text));if(c===0)continue;s+=c*l.weight,o.push(l.label)}for(let l of i.avoidWhen){let c=dr(a,on(l));if(c>0)s-=c*100,o.push("avoid-when penalty")}return{score:_l(s),reason:[...new Set(o)].join(", ")||"no lexical overlap"}}function ql(e,t,i,n){let a=fr(t,i,n).positive.map((r)=>r.text).join(" ");return e.lastIndex=0,e.test(a)?{score:1,reason:"regex match"}:{score:0,reason:"no regex match"}}function fr(e,t,i){let n=t.capabilityIds.flatMap((o)=>[o,i.get(o)??""]).join(" "),a=t.inputs.flatMap((o)=>[o.name,o.description??""]).join(" "),r=t.outputs.flatMap((o)=>[o.description??"",...o.fields]).join(" "),s=t.bodyVariants.map((o)=>`${o.title??""} ${JSON.stringify(o.schema)}`).join(" ");return{positive:[{text:`${e} ${t.id} ${t.sourceOperationId??""}`,weight:8,label:"operation identity"},{text:n,weight:6,label:"capability taxonomy"},{text:t.purpose,weight:5,label:"purpose"},{text:t.useWhen.join(" "),weight:5,label:"use-when"},{text:a,weight:2,label:"inputs"},{text:s,weight:5,label:"body variants"},{text:r,weight:2,label:"outputs"},{text:t.prerequisites.join(" "),weight:1,label:"prerequisites"}]}}function on(e){let i=e.replace(/([a-z\d])([A-Z])/g,"$1 $2").toLowerCase().match(/[\p{L}\p{N}]+/gu)??[];return new Set(i.map(Dl).filter((n)=>n.length>1&&!$l.has(n)))}function Dl(e){if(e.length>5&&e.endsWith("ing")){let t=e.slice(0,-3);return t.endsWith("s")?`${t}e`:t}if(e.length>4&&e.endsWith("ed"))return e.slice(0,-2);if(e.length>3&&e.endsWith("s"))return e.slice(0,-1);return e}function dr(e,t){let i=0;for(let n of e)if(t.has(n))i++;return i}function Ll(e,t){try{return new RegExp(e,"iu")}catch{t.push({code:"invalid-regex",severity:"error",message:`Invalid capability graph regex: ${e}`});return}}function Ml(e){if(!Number.isFinite(e))return 5;return Math.min(50,Math.max(1,Math.floor(e)))}function Rl(e,t){return t.score-e.score||e.operationId.localeCompare(t.operationId)||e.toolName.localeCompare(t.toolName)}function _l(e){return Math.round(e*1000)/1000}function ur(e){if(!e?.aborted)return;if(typeof e.throwIfAborted==="function")e.throwIfAborted();throw new DOMException("Capability graph classification aborted","AbortError")}function jl(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}var pn="x-hapi-planning",zl=Object.freeze({type:"object",additionalProperties:!1,required:["produces"],properties:{requires:{type:"array",items:{$ref:"#/$defs/fact"}},produces:{type:"array",minItems:1,items:{$ref:"#/$defs/fact"}},removes:{type:"array",items:{$ref:"#/$defs/fact"}},cost:{type:"number",minimum:0}},$defs:{fact:{type:"object",additionalProperties:!1,required:["predicate"],properties:{predicate:{type:"string",pattern:"^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$"},value:{}}}}}),Bl=new Set(["read","create","update","delete","action"]),yr=["side-effecting","destructive","idempotent","requires-confirmation"];function gr(e,t,i,n){return{capabilities:Jl(e,t,i,n),intent:Yl(e,t,i,n),effects:Hl(e,t,i,n),prerequisites:Wl(e,t,i,n),planning:br(e,t,i,n)}}function br(e,t,i,n){if(!("x-hapi-planning"in e))return;let r=e["x-hapi-planning"],s=`${t}/x-hapi-planning`;if(!he(r)){A(n,i,s,"invalid-planning","x-hapi-planning must be an object");return}let o=new Set(["requires","produces","removes","cost"]),l=Object.keys(r).filter((h)=>!o.has(h));if(l.length>0){A(n,i,s,"invalid-planning-field",`x-hapi-planning contains unknown field${l.length===1?"":"s"}: ${l.sort().join(", ")}`);return}let c=Ee(r.requires??[],`${s}/requires`,i,n),p=Ee(r.produces,`${s}/produces`,i,n),d=Ee(r.removes??[],`${s}/removes`,i,n),u=r.cost??1;if(!Array.isArray(r.produces)||r.produces.length===0)A(n,i,`${s}/produces`,"invalid-planning-produces","x-hapi-planning.produces must be a non-empty array of canonical facts");if(typeof u!=="number"||!Number.isFinite(u)||u<0)A(n,i,`${s}/cost`,"invalid-planning-cost","x-hapi-planning.cost must be a finite nonnegative number");if(!c||!p||!d||typeof u!=="number")return;let f=new Set(p.map(ie));if(d.filter((h)=>f.has(ie(h))).length>0){A(n,i,s,"conflicting-planning-fact","x-hapi-planning cannot produce and remove the same fact");return}if(!Number.isFinite(u)||u<0||p.length===0)return;return{requires:c,produces:p,removes:d,cost:u}}var Ue="x-hapi-outcome";function Kl(e){return/^2(?:\d\d|xx)$/i.test(e)}function Cr(e,t,i,n,a){let r=Ue;if(Kl(i)){A(a,n,t,"outcome-on-success-response",`${r} cannot be declared on success response ${i}; use x-hapi-planning`);return}if(!he(e)){A(a,n,t,"invalid-outcome",`${r} must be an object`);return}let s=Object.keys(e).filter((p)=>p!=="produces"&&p!=="removes");if(s.length>0){A(a,n,t,"invalid-outcome-field",`${r} contains unknown field${s.length===1?"":"s"}: ${s.sort().join(", ")}`);return}let o=Ee(e.produces??[],`${t}/produces`,n,a),l=Ee(e.removes??[],`${t}/removes`,n,a);if(!o||!l)return;if(o.length===0&&l.length===0){A(a,n,t,"empty-outcome",`${r} must produce or remove at least one fact`);return}let c=new Set(o.map(ie));if(l.some((p)=>c.has(ie(p)))){A(a,n,t,"conflicting-outcome-fact",`${r} cannot produce and remove the same fact`);return}return{produces:o,removes:l}}var Jt="x-hapi-client-facts";function wr(e,t){let i=Jt,n=`/${i}`;if(!Array.isArray(e)){t.push({code:"invalid-client-facts",severity:"error",message:`${i} must be an array of facts`,pointer:n});return}let a=[],r=new Set;for(let[s,o]of e.entries()){let l=`${n}/${s}`,c=(m,g)=>t.push({code:m,severity:"error",message:g,pointer:l});if(!he(o)){c("invalid-client-fact","A client fact must be an object");continue}let p=Object.keys(o).filter((m)=>!["predicate","value","description"].includes(m));if(p.length){c("invalid-client-fact-field",`A client fact contains unknown field${p.length===1?"":"s"}: ${p.sort().join(", ")}`);continue}if(o.description!==void 0&&(typeof o.description!=="string"||o.description.trim()==="")){c("invalid-client-fact-description","description must be a non-empty string");continue}let{description:d,...u}=o,y=Ee([u],l,"document",t)?.[0];if(!y)continue;let h=ie(y);if(r.has(h)){c("duplicate-client-fact","Client facts cannot contain duplicates");continue}r.add(h),a.push({fact:y,...typeof d==="string"?{description:d.trim()}:{},pointer:l})}return a.sort((s,o)=>ie(s.fact).localeCompare(ie(o.fact)))}var ye="x-hapi-event";function vr(e,t,i,n){let a=ye;if(!he(e)){A(n,i,t,"invalid-event",`${a} must be an object`);return}let r=Object.keys(e).filter((s)=>s!=="produces");if(r.length>0){A(n,i,t,"invalid-event-field",`${a} contains unknown field${r.length===1?"":"s"}: ${r.sort().join(", ")}`);return}if(!Array.isArray(e.produces)||e.produces.length===0){A(n,i,`${t}/produces`,"invalid-event-produces",`${a}.produces must be a non-empty array of canonical facts`);return}return Ee(e.produces,`${t}/produces`,i,n)}function Ee(e,t,i,n){if(!Array.isArray(e)){A(n,i,t,"invalid-planning-facts","Planning facts must be an array");return}let a=[];for(let[s,o]of e.entries()){let l=`${t}/${s}`;if(!he(o)||Object.keys(o).some((c)=>c!=="predicate"&&c!=="value")||typeof o.predicate!=="string"||!Ul.test(o.predicate)||Object.hasOwn(o,"value")&&!cn(o.value)){A(n,i,l,"invalid-planning-fact","A planning fact requires a canonical lowercase predicate and optional JSON-safe value");continue}a.push({predicate:o.predicate,...Object.hasOwn(o,"value")?{value:o.value}:{}})}if(a.length!==e.length)return;let r=a.map(ie);if(new Set(r).size!==r.length){A(n,i,t,"duplicate-planning-fact","Planning fact arrays cannot contain duplicates");return}return a.sort((s,o)=>ie(s).localeCompare(ie(o)))}var Ul=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/;function ie(e){return`${e.predicate}:${ln(e.value??null)}`}function ln(e){if(Array.isArray(e))return`[${e.map(ln).join(",")}]`;if(he(e))return`{${Object.keys(e).sort().map((t)=>`${JSON.stringify(t)}:${ln(e[t])}`).join(",")}}`;return JSON.stringify(e)}function cn(e,t=new Set){if(e===null||typeof e==="string"||typeof e==="boolean")return!0;if(typeof e==="number")return Number.isFinite(e);if(!e||typeof e!=="object"||t.has(e))return!1;let i=new Set(t).add(e);if(Array.isArray(e))return e.every((n)=>cn(n,i));if(Object.getPrototypeOf(e)!==Object.prototype)return!1;return Object.values(e).every((n)=>cn(n,i))}function Jl(e,t,i,n){if(!("x-hapi-capability"in e))return;let r=e["x-hapi-capability"],s=typeof r==="string"?[r]:r;if(!Xl(s)){A(n,i,`${t}/x-hapi-capability`,"invalid-capability","x-hapi-capability must be a non-empty string or array of non-empty strings");return}return Ut(s.map((o)=>o.trim()))}function Yl(e,t,i,n){if(!("x-hapi-intent"in e))return;let r=e["x-hapi-intent"];if(!he(r)){A(n,i,`${t}/x-hapi-intent`,"invalid-intent","x-hapi-intent must be an object");return}let s=Object.keys(r).filter((c)=>!["use-when","avoid-when"].includes(c)),o=r["use-when"]??[],l=r["avoid-when"]??[];if(s.length>0||!Kt(o)||!Kt(l)){A(n,i,`${t}/x-hapi-intent`,"invalid-intent","x-hapi-intent accepts only use-when and avoid-when arrays of non-empty strings");return}return{useWhen:Ut(o.map((c)=>c.trim())),avoidWhen:Ut(l.map((c)=>c.trim()))}}function Hl(e,t,i,n){if(!("x-hapi-effects"in e))return;let r=e["x-hapi-effects"];if(!he(r)){A(n,i,`${t}/x-hapi-effects`,"invalid-effects","x-hapi-effects must be an object");return}let s=new Set(["mode",...yr]),o=r.mode,l=yr.find((p)=>r[p]!==void 0&&typeof r[p]!=="boolean");if(typeof o!=="string"||!Bl.has(o)||l||Object.keys(r).some((p)=>!s.has(p))){A(n,i,`${t}/x-hapi-effects`,"invalid-effects","x-hapi-effects requires a valid mode and accepts only boolean effect flags");return}let c=Ke(o);return{mode:o,sideEffecting:hr(r,"side-effecting",c.sideEffecting),destructive:hr(r,"destructive",c.destructive),idempotent:mr(r,"idempotent",c.idempotent),requiresConfirmation:mr(r,"requires-confirmation",c.requiresConfirmation)}}function Wl(e,t,i,n){if(!("x-hapi-prerequisites"in e))return;let r=e["x-hapi-prerequisites"];if(!Kt(r)){A(n,i,`${t}/x-hapi-prerequisites`,"invalid-prerequisites","x-hapi-prerequisites must be an array of non-empty strings");return}return Ut(r.map((s)=>s.trim()))}function xr(e){let t=e.toLowerCase();if(["get","head","options"].includes(t))return Ke("read");if(t==="post")return Ke("create");if(t==="delete")return Ke("delete");if(["put","patch"].includes(t))return{...Ke("update"),idempotent:t==="put"};return Ke("action")}function Ke(e){let t=e==="read",i=e==="delete";return{mode:e,sideEffecting:!t,destructive:i,idempotent:t||e==="delete",requiresConfirmation:i}}function A(e,t,i,n,a){e.push({code:n,severity:"error",message:a,pointer:i,operationId:t})}function hr(e,t,i){return typeof e[t]==="boolean"?e[t]:i}function mr(e,t,i){return typeof e[t]==="boolean"?e[t]:i}function he(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}function Kt(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string"&&t.trim()!=="")}function Xl(e){return Kt(e)&&e.length>0}function Ut(e){return[...new Set(e)].sort((t,i)=>t.localeCompare(i))}var Yt=["delete","get","head","options","patch","post","put","trace"];function S(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}function P(e){return typeof e==="string"&&e.trim()!==""?e.trim():void 0}function oe(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function dn(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function H(e,t){if(!S(t)||typeof t.$ref!=="string"||!t.$ref.startsWith("#/"))return t;let i=e;for(let n of t.$ref.slice(2).split("/").map(dn)){if(!S(i))return t;i=i[n]}return i??t}function kr(e,t,i){let n=[],a=e.webhooks;if(S(a))for(let r of Object.keys(a).sort()){let s=H(e,a[r]),o=`/webhooks/${oe(r)}`;if(!S(s)){un(i,o);continue}n.push(...Sr(s,o,i,(l)=>({id:`webhook:${r}:${l}`,kind:"webhook",name:r})))}for(let r of t){let s=r.operation.callbacks;if(!S(s))continue;for(let o of Object.keys(s).sort()){let l=H(e,s[o]),c=`${r.pointer}/callbacks/${oe(o)}`;if(!S(l)){un(i,c);continue}for(let p of Object.keys(l).sort()){if(p.startsWith("x-"))continue;let d=H(e,l[p]),u=`${c}/${oe(p)}`;if(!S(d)){un(i,u);continue}n.push(...Sr(d,u,i,(f)=>({id:`callback:${r.id}:${o}:${f}`,kind:"callback",name:o,expression:p,operationId:r.id})))}}}return n.sort((r,s)=>r.id.localeCompare(s.id))}function Vr(e,t){if(!(ye in e.operation))return;t.push({code:"event-on-path-operation",severity:"warning",message:`${ye} applies only to webhook and callback operations and is ignored here`,pointer:`${e.pointer}/${ye}`,operationId:e.id})}function Sr(e,t,i,n){let a=[];for(let r of Yt){let s=e[r];if(!S(s))continue;let o=n(r),l=`${t}/${r}`,c=[];if(ye in s){let p=vr(s[ye],`${l}/${ye}`,o.id,i);if(!p)continue;c=p}a.push({...o,method:r,purpose:P(s.summary)??P(s.description)??o.name,produces:c,provenance:{kind:"document",pointer:l}})}return a}function un(e,t){e.push({code:"unresolved-trigger",severity:"warning",message:"Webhook or callback could not be resolved and is skipped",pointer:t})}var Ql=new Set(["allOf","anyOf","enum","oneOf","required"]);function yn(e,t={}){return fn(e,t.schema===!0,new WeakSet,void 0)}function E(e){return JSON.stringify(yn(e))}function ut(e){return JSON.stringify(yn(e,{schema:!0}))}async function ne(e){let t=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(i)].map((n)=>n.toString(16).padStart(2,"0")).join("")}async function hn(e){return ne(ut(e))}function Ht(e){return`${E(e)}
141
+ `}function fn(e,t,i,n){if(e===null||typeof e==="string"||typeof e==="boolean")return e;if(typeof e==="number")return Number.isFinite(e)?e:null;if(Array.isArray(e)){let r=e.map((s)=>fn(s,t,i,n));if(t&&n&&Ql.has(n))return r.sort(Zl);return r}if(!e||typeof e!=="object")return String(e);if(i.has(e))throw TypeError("Cannot canonicalize a cyclic object; use document references instead");i.add(e);let a={};for(let r of Object.keys(e).sort()){let s=e[r];if(s!==void 0)a[r]=fn(s,t,i,r)}return i.delete(e),a}function Zl(e,t){return JSON.stringify(e).localeCompare(JSON.stringify(t))}class Wt extends Error{diagnostics;constructor(e){let t=e.filter((i)=>i.severity==="error").length;super(`Capability graph compilation failed with ${t} error${t===1?"":"s"}`);this.diagnostics=e;this.name="CapabilityGraphCompilationError"}}async function Pe(e,t={}){let i=[],n=ec(e,i);if(!n)throw new Wt(gn(i));let a=tc(n,i);await ic(a);for(let g of a)g.extensions=gr(g.operation,g.pointer,g.id,i),g.outcomes=hc(n,g,i),Vr(g,i);let r=kr(n,a,i),s=Jt in n?wr(n[Jt],i):void 0;if(Gr(i))throw new Wt(gn(i));let o=new Map,l=[];for(let g of a){let w=nc(n,g);for(let b of w)if(!o.has(b.node.id))o.set(b.node.id,b.node);l.push(await ac(n,g,w))}let c=[...o.values()].sort(wn);l.sort(wn);let p=pc(n,a,l,i),d=gc(a,l,p),u=mc(s,d,i),f=vc(n,t.source),y=gn(i),h={schemaVersion:"1",source:f,capabilities:c,operations:l,edges:p,...d?{planning:d}:{},...r.length?{triggers:r}:{},...u?.length?{clientFacts:u}:{},diagnostics:y},m=await xc(h);return Or({...h,fingerprint:m})}function ec(e,t){if(!S(e)){t.push(bn("invalid-document","OpenAPI document root must be an object",""));return}if(typeof e.openapi!=="string"||!e.openapi.startsWith("3."))t.push(bn("unsupported-openapi-version","Capability graphs require an OpenAPI 3.x document","/openapi"));if(!S(e.paths))t.push(bn("invalid-paths","OpenAPI document paths must be an object","/paths"));return Gr(t)?void 0:e}function tc(e,t){let i=e.paths,n=[];for(let a of Object.keys(i).sort()){let r=i[a];if(!S(r))continue;for(let s of Yt){let o=r[s];if(!S(o))continue;let l=`/paths/${oe(a)}/${s}`,c=P(o.operationId);if(o.operationId!==void 0&&!c)t.push({code:"invalid-operation-id",severity:"warning",message:"operationId is not a non-empty string; a stable identity was inferred",pointer:`${l}/operationId`});let p=c?Je(c):Je(`${s}-${a}`);n.push({path:a,method:s,pointer:l,pathItem:r,operation:o,sourceOperationId:c,baseId:p,id:p})}}return n}async function ic(e){let t=new Map;for(let i of e){let n=t.get(i.baseId)??[];n.push(i),t.set(i.baseId,n)}for(let i of t.values()){if(i.length===1)continue;let n=new Map;for(let a of i.sort(Gc)){let r=Je(`${a.method}-${a.path}`),s=n.get(r)??[];s.push(a),n.set(r,s)}for(let[a,r]of n)for(let s of r){let o=r.length>1?`-${(await ne(`${s.method}:${s.path}`)).slice(0,12)}`:"";s.id=`${s.baseId}--${a}${o}`}}}function nc(e,t){let i=t.extensions?.capabilities,n=Array.isArray(t.operation.tags)?t.operation.tags.filter((l)=>typeof l==="string"&&l.trim()!==""):[],a=i&&i.length>0?i:n.length>0?[...new Set(n.map((l)=>l.trim()))].sort():[Vc(t.path)],r=i?{kind:"extension",pointer:`${t.pointer}/x-hapi-capability`}:n.length>0?{kind:"document",pointer:`${t.pointer}/tags`}:{kind:"inferred",pointer:t.pointer,detail:"first static path segment"},s=Sc(e),o=new Map;for(let l of a){let c=kc(l),p=c.map(Ec).join(".")||"root";o.set(p,{provenance:r,node:{id:p,label:l,path:c,description:s.get(l),provenance:r}})}return[...o.values()].sort((l,c)=>l.node.id.localeCompare(c.node.id))}async function ac(e,t,i){let n=P(t.operation.summary)??P(t.operation.description)??t.id,a=t.extensions?.intent??{useWhen:[n],avoidWhen:[]},r=rc(e,t),s=H(e,t.operation.requestBody),o=await oc(s),l=sc(r,s),c=t.extensions?.prerequisites??wc(l,Boolean(S(s)&&s.required===!0)),p=t.extensions?.effects,d=Object.hasOwn(t.operation,"security")?`${t.pointer}/security`:"/security";return{id:t.id,...t.sourceOperationId?{sourceOperationId:t.sourceOperationId}:{},capabilityIds:i.map((u)=>u.node.id),purpose:n,useWhen:a.useWhen,avoidWhen:a.avoidWhen,transport:{kind:"http",method:t.method.toUpperCase(),path:t.path},inputs:l,bodyVariants:o,outputs:lc(e,t.operation.responses),effects:p??xr(t.method),authorization:cc(e,t.operation),prerequisites:c,provenance:{identity:t.sourceOperationId?{kind:"document",pointer:`${t.pointer}/operationId`}:{kind:"inferred",pointer:t.pointer,detail:"HTTP method and path"},capabilities:i[0]?.provenance,purpose:P(t.operation.summary)?{kind:"document",pointer:`${t.pointer}/summary`}:P(t.operation.description)?{kind:"document",pointer:`${t.pointer}/description`}:{kind:"inferred",pointer:t.pointer,detail:"stable operation identity"},intent:t.extensions?.intent?{kind:"extension",pointer:`${t.pointer}/x-hapi-intent`}:{kind:"inferred",pointer:t.pointer,detail:"operation purpose"},transport:{kind:"document",pointer:t.pointer},inputs:{kind:"document",pointer:t.pointer},outputs:{kind:"document",pointer:`${t.pointer}/responses`},effects:p?{kind:"extension",pointer:`${t.pointer}/x-hapi-effects`}:{kind:"inferred",pointer:t.pointer,detail:"HTTP method semantics"},authorization:{kind:"document",pointer:d},prerequisites:t.extensions?.prerequisites?{kind:"extension",pointer:`${t.pointer}/x-hapi-prerequisites`}:{kind:"inferred",pointer:t.pointer,detail:"required inputs"}}}}function rc(e,t){let i=new Map;for(let n of[t.pathItem.parameters,t.operation.parameters]){if(!Array.isArray(n))continue;for(let a of n){let r=H(e,a);if(!S(r))continue;let s=P(r.name),o=P(r.in);if(s&&o)i.set(`${o}:${s}`,r)}}return[...i.values()].sort((n,a)=>`${n.in}:${n.name}`.localeCompare(`${a.in}:${a.name}`))}function sc(e,t){let i=e.map((n)=>({name:String(n.name),location:Pc(n.in),required:n.in==="path"||n.required===!0,...P(n.description)?{description:P(n.description)}:{},...S(n.schema)?{schema:Qt(n.schema)}:{}}));if(S(t))i.push({name:"body",location:"body",required:t.required===!0,...P(t.description)?{description:P(t.description)}:{},...Ir(t)?{schema:Qt(Ir(t))}:{}});return i.sort((n,a)=>`${n.location}:${n.name}`.localeCompare(`${a.location}:${a.name}`))}async function oc(e){if(!S(e)||!S(e.content))return[];let t=[];for(let i of Object.keys(e.content).sort()){let n=e.content[i];if(!S(n)||!S(n.schema))continue;let a=Array.isArray(n.schema.oneOf)&&n.schema.oneOf.length>0?[...n.schema.oneOf].filter(S).sort((r,s)=>ut(r).localeCompare(ut(s))):[n.schema];for(let r of a){let s=await hn(r);t.push({id:`${Je(i)}-${s.slice(0,12)}`,mediaType:i,required:e.required===!0,...P(r.title)?{title:P(r.title)}:{},schemaHash:s,schema:Qt(r)})}}return Ac(t,(i)=>`${i.mediaType}:${i.schemaHash}`).sort((i,n)=>i.id.localeCompare(n.id))}function lc(e,t){if(!S(t))return[];let i=[];for(let n of Object.keys(t).sort()){let a=H(e,t[n]);if(!S(a))continue;let r=S(a.content)?a.content:{},s=Object.keys(r).sort(),o=new Set;for(let l of s){let c=r[l];if(!S(c)||!S(c.schema))continue;for(let p of Cc(c.schema))o.add(p)}i.push({status:n,...P(a.description)?{description:P(a.description)}:{},mediaTypes:s,fields:[...o].sort()})}return i}function cc(e,t){let i=Object.hasOwn(t,"security")?t.security:e.security;if(!Array.isArray(i))return[];return i.filter(S).map((n)=>({schemes:Object.keys(n).sort().map((a)=>({scheme:a,scopes:Array.isArray(n[a])?n[a].filter((r)=>typeof r==="string").sort():[]}))})).sort((n,a)=>E(n).localeCompare(E(a)))}function pc(e,t,i,n){let a=[];for(let r of i)for(let s of r.capabilityIds)a.push({id:`capability:${s}->operation:${r.id}`,type:"capability-operation",from:s,to:r.id,planningEligible:!1,provenance:r.provenance.capabilities??{kind:"inferred"}});return a.push(...dc(e,t,i,n)),a.sort(Oc)}function dc(e,t,i,n){let a=[],r=new Map,s=new Map(t.map((l)=>[`${l.method} ${l.path}`,l])),o=new Map(i.map((l)=>[l.id,l]));for(let l of t){if(!l.sourceOperationId)continue;let c=r.get(l.sourceOperationId)??[];c.push(l),r.set(l.sourceOperationId,c)}for(let l of t){let c=S(l.operation.responses)?l.operation.responses:{};for(let p of Object.keys(c).sort()){let d=H(e,c[p]);if(!S(d)||!S(d.links))continue;for(let u of Object.keys(d.links).sort()){let f=H(e,d.links[u]);if(!S(f))continue;let y=uc(f,r,s),h=`${l.pointer}/responses/${oe(p)}/links/${oe(u)}`;if(!y){n.push({code:"unresolved-operation-link",severity:"warning",message:`OpenAPI Link '${u}' does not resolve to one compiled operation`,pointer:h,operationId:l.id});continue}let m=fc(f,o.get(y.id),h,l.id,u,n);a.push({id:`link:${l.id}->${y.id}:${Je(u)}`,type:"operation-link",from:l.id,to:y.id,label:u,planningEligible:m,provenance:{kind:"document",pointer:h}})}}}return a}function uc(e,t,i){let n=P(e.operationId);if(n){let s=t.get(n);return s?.length===1?s[0]:void 0}let a=P(e.operationRef);if(!a?.startsWith("#/paths/"))return;let r=a.slice(2).split("/").map(dn);if(r.length!==3||r[0]!=="paths")return;return i.get(`${r[2]?.toLowerCase()} ${r[1]}`)}function fc(e,t,i,n,a,r){if(!t)return!1;let s=e.parameters??{};if(!S(s))return Er(r,n,i,a,"parameters must be an object"),!1;let o=t.inputs.filter((y)=>y.location!=="body"),l=new Set(o.map((y)=>y.name)),c=Object.keys(s).filter((y)=>!l.has(y)),p=Object.entries(s).find(([,y])=>!Xt(y)),d=o.filter((y)=>y.required&&!Object.hasOwn(s,y.name)).map((y)=>y.name),f=!t.inputs.some((y)=>y.location==="body"&&y.required)||Xt(e.requestBody);if(c.length>0||p||d.length>0||!f){let y=[...c.length?[`unknown parameters: ${c.sort().join(", ")}`]:[],...p?[`invalid mapping for ${p[0]}`]:[],...d.length?[`missing required parameters: ${d.sort().join(", ")}`]:[],...!f?["missing or invalid required requestBody mapping"]:[]];return Er(r,n,i,a,y.join("; ")),!1}return!0}function Er(e,t,i,n,a){e.push({code:"ineligible-operation-link",severity:"warning",message:`OpenAPI Link '${n}' is descriptive-only: ${a}`,pointer:i,operationId:t})}function Xt(e){if(typeof e==="string")return!e.startsWith("$")||yc(e);if(e===null||typeof e==="boolean")return!0;if(typeof e==="number")return Number.isFinite(e);if(Array.isArray(e))return e.every(Xt);if(!S(e))return!1;return Object.values(e).every(Xt)}function yc(e){return/^\$(?:url|method|statusCode)$/.test(e)||/^\$(?:request|response)\.(?:path|query|header)\.[^\s.]+$/.test(e)||/^\$(?:request|response)\.body#(?:\/.*)?$/.test(e)}function hc(e,t,i){let n=t.operation.responses;if(!S(n))return;let a=[];for(let r of Object.keys(n).sort()){let s=H(e,n[r]);if(!S(s)||!(Ue in s))continue;let o=`${t.pointer}/responses/${oe(r)}/${Ue}`,l=Cr(s[Ue],o,r,t.id,i);if(!l)continue;if(!(pn in t.operation)){i.push({code:"outcome-without-planning",severity:"warning",message:`${Ue} on response ${r} is ignored because the operation has no x-hapi-planning`,pointer:o,operationId:t.id});continue}a.push({status:r,produces:l.produces,removes:l.removes,provenance:{kind:"extension",pointer:o}})}return a.length?a:void 0}function mc(e,t,i){if(!e?.length)return;let n=new Set((t?.transitions??[]).flatMap((a)=>a.requires.map((r)=>E(r))));return e.map((a)=>{if(!n.has(E(a.fact)))i.push({code:"unused-client-fact",severity:"warning",message:`Client fact ${a.fact.predicate} is not required by any planning transition`,pointer:a.pointer});return{fact:a.fact,...a.description?{description:a.description}:{},provenance:{kind:"extension",pointer:a.pointer}}})}function gc(e,t,i){let n=new Map(t.map((s)=>[s.id,s])),a=new Map(e.map((s)=>[s.id,s])),r=new Map;for(let s of t){let o=a.get(s.id),l=o?.extensions?.planning;if(!o||!l)continue;let c=mn(s,l,{kind:"x-hapi-planning",provenance:{kind:"extension",pointer:`${o.pointer}/x-hapi-planning`}});r.set(s.id,o.outcomes?.length?{...c,outcomes:o.outcomes}:c)}for(let s of i){if(s.type!=="operation-link"||!s.planningEligible)continue;let o=n.get(s.from),l=n.get(s.to);if(!o||!l)continue;let c={kind:"openapi-link",provenance:s.provenance},p=r.get(o.id)??mn(o,void 0,c);r.set(o.id,{...p,produces:ft([...p.produces,Cn(o.id)]),sources:Pr([...p.sources,c])});let d=r.get(l.id)??mn(l,void 0,c);r.set(l.id,{...d,requires:ft([...d.requires,Cn(o.id)]),sources:Pr([...d.sources,c])})}if(r.size===0)return;return{schemaVersion:"1",transitions:[...r.values()].sort(wn)}}function mn(e,t,i){return{id:`operation:${e.id}`,target:{kind:"operation",id:e.id},requires:ft(t?.requires??[]),produces:ft([...t?.produces??[],Cn(e.id)]),removes:ft(t?.removes??[]),cost:t?.cost??1,gates:bc(e),sources:[i]}}function bc(e){let t=[];if(e.authorization.length>0)t.push({kind:"authorization",status:"required",code:"operation-authorization"});if(e.effects.destructive)t.push({kind:"risk",status:"required",code:"destructive-operation"});if(e.effects.requiresConfirmation)t.push({kind:"confirmation",status:"required",code:"mutation-confirmation"});return t.sort((i,n)=>`${i.kind}:${i.code}`.localeCompare(`${n.kind}:${n.code}`))}function Cn(e){return{predicate:`operation.${Je(e).toLowerCase()}.completed`}}function ft(e){return[...new Map(e.map((i)=>[E(i),i])).entries()].sort(([i],[n])=>i.localeCompare(n)).map(([,i])=>i)}function Pr(e){return[...new Map(e.map((i)=>[E(i),i])).entries()].sort(([i],[n])=>i.localeCompare(n)).map(([,i])=>i)}function Qt(e){if(!S(e))return{};let t=P(e.$ref);if(t)return{ref:t};let i=S(e.properties)?Object.keys(e.properties).sort():void 0,n=Array.isArray(e.required)?e.required.filter((r)=>typeof r==="string").sort():void 0,a=Array.isArray(e.enum)?e.enum.filter(Ic).sort((r,s)=>JSON.stringify(r).localeCompare(JSON.stringify(s))):void 0;return{...P(e.type)?{type:P(e.type)}:{},...P(e.format)?{format:P(e.format)}:{},...P(e.title)?{title:P(e.title)}:{},...P(e.description)?{description:P(e.description)}:{},...a&&a.length>0?{enum:a}:{},...n&&n.length>0?{required:n}:{},...i&&i.length>0?{properties:i}:{},...S(e.items)?{items:Qt(e.items)}:{}}}function Cc(e){if(S(e.properties))return Object.keys(e.properties).sort();if(S(e.items)&&S(e.items.properties))return Object.keys(e.items.properties).sort();return[]}function wc(e,t){let i=e.filter((n)=>n.required&&n.location!=="body").map((n)=>`Provide required ${n.location} parameter '${n.name}'`);if(t)i.push("Provide the required request body");return i.sort()}function Ir(e){if(!S(e.content))return;for(let t of Object.keys(e.content).sort()){let i=e.content[t];if(S(i)&&S(i.schema))return i.schema}return}function vc(e,t){let i=S(e.info)?e.info:{};return{kind:t?.kind??"openapi",identifier:t?.identifier??P(i.title)??"in-memory",...t?.canonicalUri?{canonicalUri:t.canonicalUri}:{},documentVersion:String(e.openapi),...P(i.title)?{title:P(i.title)}:{},...P(i.version)?{version:P(i.version)}:{}}}async function xc(e){return ne(E({schemaVersion:e.schemaVersion,source:{kind:e.source.kind,documentVersion:e.source.documentVersion,title:e.source.title,version:e.source.version},capabilities:e.capabilities,operations:e.operations,edges:e.edges,planning:e.planning,triggers:e.triggers,clientFacts:e.clientFacts}))}function Sc(e){let t=new Map;if(!Array.isArray(e.tags))return t;for(let i of e.tags){if(!S(i))continue;let n=P(i.name),a=P(i.description);if(n&&a)t.set(n,a)}return t}function kc(e){let t=e.split(/[./>]+/).map((i)=>i.trim()).filter(Boolean);return t.length>0?t:["root"]}function Vc(e){return e.split("/").find((t)=>t&&!t.startsWith("{"))??"root"}function Ec(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"root"}function Je(e){return e.trim().replace(/[^A-Za-z0-9_.-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"operation"}function Pc(e){return["path","query","header","cookie"].includes(String(e))?String(e):"query"}function gn(e){return[...e].sort((t,i)=>`${t.severity}:${t.pointer??""}:${t.code}:${t.operationId??""}`.localeCompare(`${i.severity}:${i.pointer??""}:${i.code}:${i.operationId??""}`))}function Gr(e){return e.some((t)=>t.severity==="error")}function bn(e,t,i){return{code:e,severity:"error",message:t,pointer:i}}function Ic(e){return e===null||["string","number","boolean"].includes(typeof e)}function wn(e,t){return e.id.localeCompare(t.id)}function Gc(e,t){return`${e.method}:${e.path}`.localeCompare(`${t.method}:${t.path}`)}function Oc(e,t){return`${e.type}:${e.from}:${e.to}:${e.id}`.localeCompare(`${t.type}:${t.from}:${t.to}:${t.id}`)}function Ac(e,t){let i=new Set;return e.filter((n)=>{let a=t(n);if(i.has(a))return!1;return i.add(a),!0})}function Or(e){if(!e||typeof e!=="object"||Object.isFrozen(e))return e;Object.freeze(e);for(let t of Object.values(e))Or(t);return e}function Zt(e,t,i,n){if(e.kind==="authorization")return n;return i.has(e.code)||i.has(`${t}:${e.code}`)}var _=Object.freeze({maxDepth:12,maxStates:2000,maxFrontier:1000,maxExpansionsPerState:100});class U{id="deterministic-planner-v1";async plan(e){Tr(e.signal);let t=L(e.initialFacts),i=L(e.goalFacts),n=await ti(t),a={schemaVersion:"1",graphFingerprint:e.graph.fingerprint,initialStateDigest:n},r=Tc(e);if(r.length>0)return{...a,outcome:"unplannable",totalCost:0,steps:[],missingFacts:i,unsatisfiedGates:[],diagnostics:r};if(xn(t,i))return{...a,outcome:"complete",planDigest:await vn(e.graph.fingerprint,t,i,[]),totalCost:0,steps:[],missingFacts:[],unsatisfiedGates:[],diagnostics:[]};let{transitions:s,diagnostics:o}=Nc(e),l=Fc(t,i,s,e.bounds,e.signal);if(!l.node){let f=Lc(t,i,s),y=f.length>0?{code:"missing-planning-facts",severity:"warning",phase:"search",message:"Planning requires additional explicit state facts that no transition can produce"}:void 0;return{...a,outcome:f.length>0?"clarification-required":"unplannable",totalCost:0,steps:[],missingFacts:f,unsatisfiedGates:[],diagnostics:[...o,y,l.diagnostic].filter((h)=>Boolean(h))}}let c=Dc(l.node.transitions),p=new Set(e.satisfiedGates??[]),d=e.principal!==void 0,u=c.flatMap((f)=>f.gates.filter((y)=>!Zt(y,f.transitionId,p,d))).sort(Rc);return{...a,outcome:u.length>0?"clarification-required":"planned",planDigest:await vn(e.graph.fingerprint,t,i,c.map((f)=>f.transitionId)),totalCost:l.node.cost,steps:c,missingFacts:[],unsatisfiedGates:u,diagnostics:o}}}function L(e){let t=new Map;for(let i of e)t.set(W(i),i);return[...t.entries()].sort(([i],[n])=>i.localeCompare(n)).map(([,i])=>i)}async function ti(e){return ne(E(L(e)))}async function vn(e,t,i,n){return ne(E({graphFingerprint:e,initialFacts:L(t),goalFacts:L(i),transitionIds:[...n]}))}function Tc(e){let t=[],i=e.bounds;for(let[n,a]of Object.entries(i))if(!Number.isSafeInteger(a)||a<1)t.push({code:"invalid-planning-bound",severity:"error",phase:"validation",message:`${n} must be a positive safe integer`});for(let n of e.graph.planning?.transitions??[])if(!Number.isFinite(n.cost)||n.cost<0)t.push({code:"invalid-transition-cost",severity:"error",phase:"validation",transitionId:n.id,message:`Transition '${n.id}' has a non-finite or negative cost`});return t.sort(_c)}function Nc(e){let t=new Map(e.graph.operations.map((a)=>[a.id,a])),i=[],n=[];for(let a of e.graph.planning?.transitions??[]){let r=$c(a,t);if(r&&!Be(r,e.principal)){n.push({code:"transition-unauthorized",severity:"warning",phase:"eligibility",transitionId:a.id,message:`Transition '${a.id}' is not authorized for the supplied principal`});continue}i.push(a)}return i.sort((a,r)=>a.id.localeCompare(r.id)),{transitions:i,diagnostics:n}}function $c(e,t){return e.target.kind==="operation"?t.get(e.target.id):void 0}function Fc(e,t,i,n,a){let r={facts:e,key:Ar(e),cost:0,transitionIds:[],transitions:[]},s=[r],o=new Map([[r.key,{cost:0,path:""}]]),l=1,c=!1;while(s.length>0){Tr(a),s.sort(Mc);let p=s.shift();if(xn(p.facts,t))return{node:p};if(p.transitions.length>=n.maxDepth){c=!0;continue}let d=i.filter((f)=>xn(p.facts,f.requires));if(d.length>n.maxExpansionsPerState)return{diagnostic:ei("max-expansions-per-state-exceeded",n.maxExpansionsPerState)};let u=d.slice(0,n.maxExpansionsPerState);for(let f of u){let y=qc(p.facts,f),h=Ar(y),m=[...p.transitionIds,f.id],g=p.cost+f.cost,w=m.join("\x00"),b=o.get(h);if(b&&(b.cost<g||b.cost===g&&b.path<=w))continue;if(!b){if(l++,l>n.maxStates)return{diagnostic:ei("max-states-exceeded",n.maxStates)}}if(o.set(h,{cost:g,path:w}),s.push({facts:y,key:h,cost:g,transitionIds:m,transitions:[...p.transitions,f]}),s.length>n.maxFrontier)return{diagnostic:ei("max-frontier-exceeded",n.maxFrontier)}}}if(c)return{diagnostic:ei("max-depth-exceeded",n.maxDepth)};return{diagnostic:{code:"goal-unreachable",severity:"warning",phase:"search",message:"No eligible bounded transition sequence reaches the requested goal"}}}function qc(e,t){let i=new Map(e.map((n)=>[W(n),n]));for(let n of t.removes)i.delete(W(n));for(let n of t.produces)i.set(W(n),n);return L([...i.values()])}function Dc(e){let t=0;return e.map((i,n)=>(t+=i.cost,{index:n,transitionId:i.id,target:i.target,cost:i.cost,cumulativeCost:t,requires:i.requires,produces:i.produces,removes:i.removes,gates:i.gates,sources:i.sources,...i.outcomes?.length?{outcomes:i.outcomes}:{}}))}function xn(e,t){let i=new Set(e.map(W));return t.every((n)=>i.has(W(n)))}function Lc(e,t,i){let n=new Set(e.map(W)),a=new Set(t.map(W)),r=new Map;for(let c of i)for(let p of c.produces){let d=r.get(W(p))??[];d.push(c),r.set(W(p),d)}let s=[...t],o=new Set,l=[];while(s.length>0){let c=s.shift(),p=W(c);if(n.has(p)||o.has(p))continue;o.add(p);let d=r.get(p)??[];if(d.length===0){if(!a.has(p))l.push(c);continue}for(let u of d)s.push(...u.requires)}return L(l)}function W(e){return E(e)}function Ar(e){return E(L(e))}function Mc(e,t){return e.cost-t.cost||e.transitionIds.join("\x00").localeCompare(t.transitionIds.join("\x00"))||e.key.localeCompare(t.key)}function Rc(e,t){return`${e.kind}:${e.code}`.localeCompare(`${t.kind}:${t.code}`)}function _c(e,t){return`${e.phase}:${e.transitionId??""}:${e.code}`.localeCompare(`${t.phase}:${t.transitionId??""}:${t.code}`)}function ei(e,t){return{code:e,severity:"warning",phase:"search",message:`Planning stopped at configured bound ${t}`}}function Tr(e){if(!e?.aborted)return;if(typeof e.throwIfAborted==="function")e.throwIfAborted();throw new DOMException("Capability graph planning aborted","AbortError")}import{resolveCapabilityExecutionConfirmationVerifier as jc}from"@mcp-com-ai/core/capability-execution";async function Sn(e){return ni(e??null,"principal")}async function Nr(e){return ni(e,"step arguments")}async function ii(e,t,i){let n=new Map(e.operations.map((s)=>[s.id,s])),a=new Map(i.map((s)=>[s.index,s])),r=[];for(let s of t){let o=s.target.kind==="operation"?n.get(s.target.id):void 0;if(!(s.target.kind==="workflow"||o?.effects.sideEffecting===!0||o?.effects.destructive===!0||o!==void 0&&o.effects.mode!=="read"||s.gates.some((p)=>p.kind==="confirmation")))continue;let c=a.get(s.index);if(!c)continue;r.push({index:s.index,transitionId:s.transitionId,target:s.target,argumentDigest:await Nr(c.arguments),...c.workflowSourceFingerprint?{workflowSourceFingerprint:c.workflowSourceFingerprint}:{}})}return r}async function $r(e){return ni(e,"mutation set")}async function kn(e,t){let i=await Sn(e.principal),n=await ii(t,e.plan.steps,e.stepArguments);return{schemaVersion:"1",planDigest:e.plan.planDigest??"",graphFingerprint:t.fingerprint,principalDigest:i,mutationSetDigest:await $r(n)}}async function Vn(e){let t=await Sn(e.principal);return ni({schemaVersion:e.schemaVersion,graphFingerprint:e.graphFingerprint,planDigest:e.plan.planDigest??null,initialFacts:L(e.initialFacts),goalFacts:L(e.goalFacts),currentFacts:L(e.currentFacts),satisfiedGates:[...e.satisfiedGates??[]].sort(),principalDigest:t,planningBounds:e.planningBounds,stepArguments:e.stepArguments.map((i)=>({index:i.index,transitionId:i.transitionId,arguments:i.arguments,bodyVariantId:i.bodyVariantId??null,workflowSourceFingerprint:i.workflowSourceFingerprint??null})),limits:e.limits},"execution envelope")}async function ni(e,t){return Fr(e,t,new Set),ne(E(e))}function Fr(e,t,i){if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"){if(Number.isFinite(e))return;throw TypeError(`${t} must contain only finite JSON numbers`)}if(!e||typeof e!=="object")throw TypeError(`${t} must be JSON-safe`);if(i.has(e))throw TypeError(`${t} must not contain cyclic values`);let n=Object.getPrototypeOf(e);if(!Array.isArray(e)&&n!==Object.prototype&&n!==null)throw TypeError(`${t} must contain only JSON objects and arrays`);i.add(e);let a=Array.isArray(e)?e:Object.values(e);for(let r of a)Fr(r,t,i);i.delete(e)}async function Pn(e,t,i={}){Lr(t.signal);let n=Yc(e,t),a=n.length===0?await zc(e,t,n):Dr();if(n.length===0&&!await Bc(e,t,i.planner))n.push(ep());if(n.length===0&&a.binding)n.push(...await qr(t,a.mutations,a.binding,i.confirmation));return{ok:n.length===0,...a.executionDigest?{executionDigest:a.executionDigest}:{},...a.binding?{binding:a.binding}:{},mutations:a.mutations,transitions:a.transitions,diagnostics:n}}async function zc(e,t,i){let n=Qc(e,t);try{let[a,r,s]=await Promise.all([Vn(t),ii(e,t.plan.steps,t.stepArguments),kn(t,e)]);return{executionDigest:a,mutations:r,binding:s,transitions:n}}catch{return i.push(Zc()),{...Dr(),transitions:n}}}async function Bc(e,t,i){let n=await(i??new U).plan({schemaVersion:"1",graph:e,initialFacts:t.initialFacts,goalFacts:t.goalFacts,satisfiedGates:t.satisfiedGates,principal:t.principal,bounds:t.planningBounds,signal:t.signal});return tp(n,t.plan)}async function qr(e,t,i,n={}){if(t.length===0)return[];if(e.confirmations.length===0)return[X("execution-confirmation-required","The planned mutation set requires a trusted confirmation receipt","confirmation")];let a=(n.now??Date.now)(),r=n.clockSkewMs??30000,s=n.maxReceiptLifetimeMs??300000,o=new Set;for(let l of e.confirmations){Lr(e.signal);let c=await Kc(l,i,e.signal,a,r,s);if(c==="valid")return[];o.add(c)}return[X(Jc(o),"No trusted confirmation receipt validates the exact execution binding","confirmation")]}async function Kc(e,t,i,n,a,r){if(!np(e,t))return"binding";if(!Uc(e,n,a,r))return"time";let s=jc(e.verifierId);if(!s)return"verifier";try{return await s.verify(e,t,i)?"valid":"proof"}catch{return"proof"}}function Uc(e,t,i,n){let a=Date.parse(e.issuedAt),r=Date.parse(e.expiresAt);return Number.isFinite(a)&&Number.isFinite(r)&&r>a&&a<=t+i&&r>=t-i&&r-a<=n}function Jc(e){if(e.has("binding"))return"execution-confirmation-binding-mismatch";if(e.has("time"))return"execution-confirmation-expired";if(e.has("verifier"))return"execution-confirmation-verifier-unavailable";return"execution-confirmation-invalid"}function Yc(e,t){let i=[];return Hc(e,t,i),Xc(t,i),Wc(e,t,i),i}function Hc(e,t,i){if(t.schemaVersion!=="1")i.push(X("unsupported-execution-version","Execution request schemaVersion must be '1'","envelope"));if(t.graphFingerprint!==e.fingerprint||t.plan.graphFingerprint!==e.fingerprint)i.push(X("execution-graph-mismatch","The execution request does not match the retained graph fingerprint","envelope"));if(t.plan.outcome!=="planned"&&t.plan.outcome!=="complete"||!t.plan.planDigest)i.push(X("execution-plan-not-executable","Guarded execution requires a planned or complete result with a plan digest","envelope"));if(t.plan.steps.length>t.limits.maxPlanSteps)i.push(X("execution-step-limit-exceeded","The plan exceeds the configured execution step limit","envelope"))}function Wc(e,t,i){if(t.stepArguments.length!==t.plan.steps.length)i.push(X("execution-step-arguments-mismatch","Execution arguments must contain exactly one ordered entry per plan step","envelope"));let n=new Set,a=new Map((e.planning?.transitions??[]).map((s)=>[s.id,s])),r=0;for(let[s,o]of t.plan.steps.entries()){let l=t.stepArguments[s],c=a.get(o.transitionId);if(r+=c?.cost??0,n.has(o.transitionId))i.push(En("execution-duplicate-transition","An execution plan cannot repeat a transition",s,o.transitionId));if(n.add(o.transitionId),!c||!ip(o,c,s,r))i.push(En("execution-transition-mismatch","A plan step does not match its retained graph transition",s,o.transitionId));if(!l||l.index!==s||l.transitionId!==o.transitionId)i.push(En("execution-step-arguments-mismatch","Step arguments are missing, reordered, or bound to another transition",s,o.transitionId))}}function Xc(e,t){for(let[i,n]of Object.entries(e.limits)){let a=i==="maxRetriesPerStep";if(!Number.isSafeInteger(n)||n<(a?0:1))t.push(X("invalid-execution-limit",`${i} must be ${a?"a nonnegative":"a positive"} safe integer`,"envelope"))}}function Qc(e,t){let i=new Map((e.planning?.transitions??[]).map((n)=>[n.id,n]));return t.plan.steps.map((n)=>i.get(n.transitionId)).filter((n)=>n!==void 0)}function Dr(){return{mutations:[],transitions:[]}}function Zc(){return X("execution-envelope-not-json-safe","The execution envelope must contain only finite JSON-safe values","envelope")}function ep(){return X("execution-plan-not-canonical","The supplied plan is not the canonical current plan for this graph and request","envelope")}function tp(e,t){return e.outcome===t.outcome&&e.planDigest===t.planDigest&&e.initialStateDigest===t.initialStateDigest&&e.totalCost===t.totalCost&&E(e.steps)===E(t.steps)}function ip(e,t,i,n){return E(e)===E({index:i,transitionId:t.id,target:t.target,cost:t.cost,cumulativeCost:n,requires:t.requires,produces:t.produces,removes:t.removes,gates:t.gates,sources:t.sources,...t.outcomes?.length?{outcomes:t.outcomes}:{}})}function np(e,t){return e.schemaVersion===t.schemaVersion&&e.planDigest===t.planDigest&&e.graphFingerprint===t.graphFingerprint&&e.principalDigest===t.principalDigest&&e.mutationSetDigest===t.mutationSetDigest}function X(e,t,i){return{code:e,message:t,phase:i,severity:"error"}}function En(e,t,i,n){return{...X(e,t,"envelope"),stepIndex:i,transitionId:n}}function Lr(e){if(!e?.aborted)return;if(typeof e.throwIfAborted==="function")e.throwIfAborted();throw new DOMException("Capability execution validation aborted","AbortError")}function ht(e,t){let i=[];return Ie(e,t,"",e,i,new Set),i}function Ie(e,t,i,n,a,r){if(e===!0||e===void 0)return;if(e===!1||!yt(e)){a.push({instancePath:i,keyword:"false-schema"});return}if(typeof e.$ref==="string"){let s=e.$ref;if(!s.startsWith("#/")||r.has(s)){a.push({instancePath:i,keyword:"$ref"});return}let o=cp(n,s.slice(1));if(o===void 0){a.push({instancePath:i,keyword:"$ref"});return}Ie(o,t,i,n,a,new Set(r).add(s))}if(Array.isArray(e.allOf))for(let s of e.allOf)Ie(s,t,i,n,a,r);if(Mr("anyOf",e.anyOf,t,i,n,a,r),Mr("oneOf",e.oneOf,t,i,n,a,r),e.const!==void 0&&!_r(t,e.const))a.push({instancePath:i,keyword:"const"});if(Array.isArray(e.enum)&&!e.enum.some((s)=>_r(t,s)))a.push({instancePath:i,keyword:"enum"});if(e.type!==void 0&&!lp(t,e.type)){a.push({instancePath:i,keyword:"type"});return}if(typeof t==="string")ap(e,t,i,a);if(typeof t==="number")rp(e,t,i,a);if(Array.isArray(t))sp(e,t,i,n,a,r);if(yt(t))op(e,t,i,n,a,r)}function Mr(e,t,i,n,a,r,s){if(!Array.isArray(t))return;let o=t.filter((l)=>{let c=[];return Ie(l,i,n,a,c,s),c.length===0}).length;if(e==="anyOf"&&o===0||e==="oneOf"&&o!==1)r.push({instancePath:n,keyword:e})}function ap(e,t,i,n){if(typeof e.minLength==="number"&&t.length<e.minLength)n.push({instancePath:i,keyword:"minLength"});if(typeof e.maxLength==="number"&&t.length>e.maxLength)n.push({instancePath:i,keyword:"maxLength"});if(typeof e.pattern==="string")try{if(!new RegExp(e.pattern).test(t))n.push({instancePath:i,keyword:"pattern"})}catch{n.push({instancePath:i,keyword:"pattern"})}}function rp(e,t,i,n){if(typeof e.minimum==="number"&&t<e.minimum)n.push({instancePath:i,keyword:"minimum"});if(typeof e.maximum==="number"&&t>e.maximum)n.push({instancePath:i,keyword:"maximum"})}function sp(e,t,i,n,a,r){if(typeof e.minItems==="number"&&t.length<e.minItems)a.push({instancePath:i,keyword:"minItems"});if(typeof e.maxItems==="number"&&t.length>e.maxItems)a.push({instancePath:i,keyword:"maxItems"});if(e.items!==void 0)t.forEach((s,o)=>Ie(e.items,s,`${i}/${o}`,n,a,r))}function op(e,t,i,n,a,r){let s=yt(e.properties)?e.properties:{};for(let o of Array.isArray(e.required)?e.required:[])if(typeof o==="string"&&!(o in t))a.push({instancePath:i,keyword:"required"});for(let[o,l]of Object.entries(t))if(s[o]!==void 0)Ie(s[o],l,`${i}/${Rr(o)}`,n,a,r);else if(e.additionalProperties===!1)a.push({instancePath:i,keyword:"additionalProperties"});else if(e.additionalProperties!==void 0&&e.additionalProperties!==!0)Ie(e.additionalProperties,l,`${i}/${Rr(o)}`,n,a,r)}function lp(e,t){return(Array.isArray(t)?t:[t]).some((n)=>{if(n==="null")return e===null;if(n==="array")return Array.isArray(e);if(n==="object")return yt(e);if(n==="integer")return typeof e==="number"&&Number.isInteger(e);return typeof e===n})}function cp(e,t){return t.split("/").slice(1).reduce((i,n)=>{if(!yt(i)&&!Array.isArray(i))return;let a=n.replaceAll("~1","/").replaceAll("~0","~");return i[a]},e)}function Rr(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function yt(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function _r(e,t){return JSON.stringify(e)===JSON.stringify(t)}async function In(e,t,i,n,a){Ep(t.signal);let r=await Pn(e,t,{confirmation:a.confirmation}),s=[...r.diagnostics];if(!r.ok)return{ok:!1,envelope:r,diagnostics:s};if(xp(a))return s.push(kp(i)),{ok:!1,envelope:r,diagnostics:s};let o=pp(e,t,r,i,a,s);if(!o)return{ok:!1,envelope:r,diagnostics:s};let l=L(n);return s.push(...await dp(o,t,l,i,a),...yp(o,t,i)),{ok:s.length===0,envelope:r,transition:o.transition,...o.descriptor?{descriptor:o.descriptor}:{},diagnostics:s}}function pp(e,t,i,n,a,r){let s=t.plan.steps[n],o=i.transitions[n];if(!s||!o){r.push(Vp(n));return}let l=a.descriptors.get(o.target.id);if(!Sp(o,l))r.push(Q("execution-target-descriptor-mismatch","The retained runtime descriptor does not match the planned target",n,o.id,"preflight"));let c=o.target.kind==="operation"?e.operations.find((p)=>p.id===o.target.id):void 0;return{transition:o,operation:c,descriptor:l}}async function dp(e,t,i,n,a){let r=[];if(!vp(i,e.transition.requires))r.push(ai("execution-prerequisite-missing","Current state does not satisfy every planned transition prerequisite",e.transition,n));if(!await up(e,t,a))r.push(ai("execution-authorization-denied","Current authorization does not permit the planned transition",e.transition,n));if(e.transition.gates.some((s)=>s.status==="denied"))r.push(ai("execution-gate-denied","A planned transition gate is currently denied",e.transition,n));if(!await fp(e,t,i,a))r.push(ai("execution-policy-denied","Current policy does not permit the planned transition",e.transition,n));return r}async function up(e,t,i){if(i.authorize)return i.authorize({transition:e.transition,operation:e.operation,principal:t.principal});if(e.operation)return Be(e.operation,t.principal);return!e.transition.gates.some((n)=>n.kind==="authorization")}async function fp(e,t,i,n){if(!e.transition.gates.some((a)=>a.kind==="policy"))return!0;return n.evaluatePolicy?n.evaluatePolicy({transition:e.transition,principal:t.principal,currentFacts:i}):!1}function yp(e,t,i){let n=t.stepArguments[i];if(!e.descriptor||!n)return[];return[...hp(e.operation,e.transition,e.descriptor,n,i),...ht(e.descriptor.inputSchema,n.arguments).map((r)=>Q("execution-arguments-invalid",`Argument schema validation failed${r.instancePath?` at ${r.instancePath}`:""} (${r.keyword})`,i,e.transition.id,"arguments"))]}async function Gn(e,t,i){if(!e.ok||!e.transition||!e.descriptor)return{ok:!1,facts:L(t),diagnostics:e.diagnostics};let{transition:n,descriptor:a}=e,r=[];if(a.kind==="operation"&&(i.status===void 0||i.status<200||i.status>=300))r.push(Q("execution-response-unsuccessful","The operation did not satisfy its success status contract",jr(e),n.id,"response"));let s=Cp(a,i);if(s!==void 0)for(let l of ht(s,i.body))r.push(Q("execution-response-invalid",`Response schema validation failed${l.instancePath?` at ${l.instancePath}`:""} (${l.keyword})`,jr(e),n.id,"response"));if(r.length>0)return{ok:!1,facts:L(t),diagnostics:r};let o=wp(t,n);return{ok:!0,facts:o,stateDigest:await ti(o),diagnostics:[]}}function hp(e,t,i,n,a){if(i.kind==="workflow")return n.workflowSourceFingerprint===i.sourceFingerprint?[]:[bp(a,t.id)];if(!e)return[Q("execution-operation-not-found","The planned operation is absent from the retained graph",a,t.id,"preflight")];return mp(e,t,i,n,a)}function mp(e,t,i,n,a){let r=[];if(n.bodyVariantId){if(!e.bodyVariants.some((s)=>s.id===n.bodyVariantId))r.push(Q("execution-body-variant-mismatch","The selected request body variant is absent from the retained graph operation",a,t.id,"arguments"));r.push(...gp(i,n,t.id,a))}else if(e.bodyVariants.length>1)r.push(Q("execution-body-variant-required","A canonical request body variant must be selected before execution",a,t.id,"arguments"));return r}function gp(e,t,i,n){let a=e.bodyVariants?.find((r)=>r.id===t.bodyVariantId);if(!a)return[Q("execution-body-schema-missing","The retained tool descriptor has no schema for the selected request body variant",n,i,"arguments")];return ht(a.schema,t.arguments[a.argumentName]).map((r)=>Q("execution-body-invalid",`Request body schema validation failed${r.instancePath?` at ${r.instancePath}`:""} (${r.keyword})`,n,i,"arguments"))}function bp(e,t){return Q("execution-workflow-fingerprint-mismatch","The planned workflow source no longer matches its validated runtime descriptor",e,t,"preflight")}function Cp(e,t){if(e.kind==="workflow")return e.outputSchema;if(t.status===void 0)return;let i=String(t.status),n=`${i[0]}XX`,a=e.responseSchemas.filter((s)=>s.status===i||s.status.toUpperCase()===n||s.status.toLowerCase()==="default"),r=t.mediaType?.split(";",1)[0]?.trim().toLowerCase();return a.find((s)=>!s.mediaType||s.mediaType.toLowerCase()===r)?.schema??a[0]?.schema}function wp(e,t){let i=new Map(L(e).map((n)=>[mt(n),n]));for(let n of t.removes)i.delete(mt(n));for(let n of t.produces)i.set(mt(n),n);return L([...i.values()])}function vp(e,t){let i=new Set(e.map(mt));return t.every((n)=>i.has(mt(n)))}function mt(e){return E(e)}function xp(e){return e.deadlineEpochMs!==void 0&&(e.now??Date.now)()>=e.deadlineEpochMs}function Sp(e,t){return Boolean(t&&t.targetId===e.target.id&&t.kind===e.target.kind)}function kp(e){return zr("execution-deadline-exceeded","The execution deadline was reached before step preflight",e)}function Vp(e){return zr("execution-step-not-found","The requested execution step is absent from the validated plan",e)}function ai(e,t,i,n){return Q(e,t,n,i.id,"preflight")}function jr(e){return Math.max(0,e.envelope.transitions.findIndex((t)=>t.id===e.transition?.id))}function zr(e,t,i){return{code:e,message:t,phase:"preflight",severity:"error",stepIndex:i}}function Q(e,t,i,n,a){return{code:e,message:t,phase:a,severity:"error",stepIndex:i,transitionId:n}}function Ep(e){if(!e?.aborted)return;if(typeof e.throwIfAborted==="function")e.throwIfAborted();throw new DOMException("Capability execution preflight aborted","AbortError")}function Br(e,t){if(!e?.length||t===void 0)return;let i=String(t),n=`${i[0]}XX`;return e.find((a)=>a.status===i)??e.find((a)=>a.status.toUpperCase()===n)??e.find((a)=>a.status==="default")}var Kr=Object.freeze({maxPlanSteps:50,maxTotalTimeMs:300000,maxStepTimeMs:60000,maxTotalAttempts:100,maxRetriesPerStep:3,maxResponseBytes:10485760,maxResultRecords:100,maxEventRecords:500}),Ur=Object.freeze({maxPlanSteps:12,maxTotalTimeMs:60000,maxStepTimeMs:15000,maxTotalAttempts:16,maxRetriesPerStep:1,maxResponseBytes:1048576,maxResultRecords:50,maxEventRecords:100});class An{options;id="guarded-capability-executor-v1";constructor(e){this.options=e}async execute(e){let t=this.options.bindings.now??Date.now,i=this.options.bindings.createCorrelationId?.()??crypto.randomUUID(),n=Pp(e.limits,this.options.bindings.limits),a={...e,limits:n},r=t(),s=r+n.maxTotalTimeMs,o=new Jr(this.options.bindings.eventSink,n.maxEventRecords),l=a.plan.planDigest??"unavailable";await o.emit(On("execution-start",i,a));let c={facts:a.currentFacts,results:[],diagnostics:[],totalAttempts:0},p,d="unavailable";for(let f=0;f<a.plan.steps.length;f+=1){if(p)break;if(f>=n.maxPlanSteps){p=Ap(c,f,"execution-step-limit-exceeded");break}let y;try{y=await this.executeStep({request:a,index:f,state:c,correlationId:i,deadlineEpochMs:s,now:t,events:o})}catch{let h=a.signal?.aborted===!0;y=Ye(c,f,a.plan.steps[f]?.transitionId,0,t(),t,h?"cancelled":"failed",h?"execution-cancelled":"execution-internal-failure")}d=y.executionDigest??d,p=y.terminal}Tp(a,c,n.maxResultRecords);let u=p?.outcome??"completed";return await o.emit({...On(u==="completed"?"execution-complete":$p(u),i,a),durationMs:Math.max(0,t()-r),outcome:u,reasonCode:p?.reasonCode}),{schemaVersion:"1",outcome:u,correlationId:i,graphFingerprint:this.options.graph.fingerprint,planDigest:l,executionDigest:d,steps:c.results.slice(0,n.maxResultRecords),diagnostics:c.diagnostics.slice(0,n.maxResultRecords)}}async executeStep(e){let{request:t,index:i,state:n,correlationId:a,deadlineEpochMs:r,now:s,events:o}=e,l=Gp(this.options.graph,t,i),c=Op(this.options.graph,l),p=Ip(c,l,t.limits),d=s(),u;for(let f=1;f<=p+1;f+=1){if(n.totalAttempts>=t.limits.maxTotalAttempts)return Ye(n,i,l?.id,f-1,d,s,"rejected","execution-attempt-limit-exceeded");n.totalAttempts+=1,await o.emit(He("step-start",a,t,i,f));let y=await this.preflight(t,i,n.facts,r);if(u=y.envelope.executionDigest,!y.ok||!y.transition){n.diagnostics.push(...y.diagnostics);let g=y.diagnostics[0]?.code??"execution-preflight-rejected";return await o.emit({...He("step-failure",a,t,i,f),reasonCode:g}),Ye(n,i,l?.id,f,d,s,"rejected",g,y.diagnostics[0],u)}let h=await this.invokeAttempt(t,i,f,a,r,s),m=await this.handleInvocation({request:t,index:i,attempt:f,state:n,correlationId:a,deadlineEpochMs:r,stepStartedAt:d,now:s,events:o,preflight:y,invocation:h,canRetry:f<=p,executionDigest:u});if(m.retry){await Fp(h.retryAfterMs,t.signal);continue}return m.result}return{executionDigest:u}}preflight(e,t,i,n){return In(this.options.graph,e,t,i,{descriptors:this.options.descriptors,deadlineEpochMs:n,now:this.options.bindings.now,confirmation:this.options.confirmation,authorize:this.options.bindings.authorize,evaluatePolicy:this.options.bindings.evaluatePolicy})}async invokeAttempt(e,t,i,n,a,r){let s=e.plan.steps[t],o=e.stepArguments[t],l=Math.max(1,Math.min(e.limits.maxStepTimeMs,a-r())),c=new AbortController,p=setTimeout(()=>c.abort("step-timeout"),l),d=()=>c.abort(e.signal?.reason??"cancelled");e.signal?.addEventListener("abort",d,{once:!0});try{return await this.options.bindings.invoker.invoke({correlationId:n,stepIndex:t,transitionId:s.transitionId,target:s.target,arguments:o.arguments,attempt:i,timeoutMs:l,maxResponseBytes:e.limits.maxResponseBytes,signal:c.signal})}catch{return{outcome:e.signal?.aborted?"failure":"indeterminate",reasonCode:e.signal?.aborted?"execution-cancelled":"execution-invocation-unknown",retryable:!e.signal?.aborted}}finally{clearTimeout(p),e.signal?.removeEventListener("abort",d)}}async handleInvocation(e){let{request:t,index:i,attempt:n,state:a,correlationId:r,stepStartedAt:s,now:o,events:l,preflight:c,invocation:p,canRetry:d,executionDigest:u}=e;if(t.signal?.aborted)return await l.emit(He("step-cancel",r,t,i,n)),{retry:!1,result:Ye(a,i,c.transition.id,n,s,o,"cancelled","execution-cancelled",void 0,u)};if(p.outcome!=="success"){if(d&&p.retryable)return await l.emit({...He("step-retry",r,t,i,n),responseStatus:p.status,reasonCode:p.reasonCode??"execution-transient-failure"}),{retry:!0};let y=p.outcome==="indeterminate"?"indeterminate":"failed",h=p.reasonCode??(y==="indeterminate"?"execution-upstream-indeterminate":"execution-upstream-failed"),m=Nn(h,i,c.transition.id);return a.diagnostics.push(m),await l.emit({...He("step-failure",r,t,i,n),responseStatus:p.status,reasonCode:h}),{retry:!1,result:Ye(a,i,c.transition.id,n,s,o,y,h,m,u,p.status,Br(c.transition.outcomes,p.status))}}let f=await Gn(c,a.facts,p);if(!f.ok){a.diagnostics.push(...f.diagnostics);let y=f.diagnostics[0]?.code??"execution-response-invalid";return{retry:!1,result:Ye(a,i,c.transition.id,n,s,o,"failed",y,f.diagnostics[0],u,p.status)}}return a.facts=f.facts,a.results.push({index:i,transitionId:c.transition.id,status:"completed",attempts:n,durationMs:Math.max(0,o()-s),responseStatus:p.status,appliedStateDigest:f.stateDigest}),await l.emit({...He("step-success",r,t,i,n),responseStatus:p.status,durationMs:Math.max(0,o()-s)}),{retry:!1,result:{executionDigest:u}}}}function Tn(e,t){return{id:"guarded-capability-executor-factory-v1",create(i){return new An({graph:e,descriptors:i.descriptors,bindings:i,confirmation:t})}}}class Jr{sink;limit;count=0;constructor(e,t){this.sink=e;this.limit=t}async emit(e){if(!this.sink||this.count>=this.limit)return;this.count+=1;try{await this.sink(e)}catch{}}}function Pp(e,t){return Object.fromEntries(Object.entries(Kr).map(([i,n])=>{let a=i,r=t?.[a]??Ur[a];return[i,Math.min(e[a],r,n)]}))}function Ip(e,t,i){if(!e||t?.target.kind!=="operation")return 0;return e.effects.mode==="read"||e.effects.idempotent?i.maxRetriesPerStep:0}function Gp(e,t,i){let n=t.plan.steps[i]?.transitionId;return e.planning?.transitions.find((a)=>a.id===n)}function Op(e,t){return t?.target.kind==="operation"?e.operations.find((i)=>i.id===t.target.id):void 0}function Ye(e,t,i,n,a,r,s,o,l,c,p,d){let u=l??Np(o,t,i);if(!l)e.diagnostics.push(u);e.results.push({index:t,transitionId:i??"unknown",status:s,attempts:n,durationMs:Math.max(0,r()-a),responseStatus:p,diagnostic:u,...d?{declaredOutcome:{status:d.status,produces:d.produces,removes:d.removes}}:{}});let f=s==="cancelled"?"cancelled":e.results.some((y)=>y.index<t&&y.status==="completed")?"partial":s==="rejected"?"rejected":"failed";return{executionDigest:c,terminal:{outcome:f,reasonCode:o}}}function Ap(e,t,i){return e.diagnostics.push(Nn(i,t)),{outcome:e.results.some((n)=>n.status==="completed")?"partial":"rejected",reasonCode:i}}function Tp(e,t,i){let n=new Set(t.results.map((a)=>a.index));for(let[a,r]of e.plan.steps.entries()){if(t.results.length>=i)break;if(!n.has(a))t.results.push({index:a,transitionId:r.transitionId,status:"not-started",attempts:0,durationMs:0})}t.results.sort((a,r)=>a.index-r.index)}function Nn(e,t,i){return{code:e,severity:"error",message:"Guarded execution stopped at this step",phase:"invocation",stepIndex:t,transitionId:i}}function Np(e,t,i){return Nn(e,t,i)}function On(e,t,i){return{schemaVersion:"1",name:e,correlationId:t,graphFingerprint:i.graphFingerprint,planDigest:i.plan.planDigest??"unavailable"}}function He(e,t,i,n,a){return{...On(e,t,i),stepIndex:n,transitionId:i.plan.steps[n]?.transitionId,attempt:a}}function $p(e){return e==="cancelled"?"execution-cancel":"execution-failure"}async function Fp(e,t){let i=Math.max(0,Math.min(e??25,1000));if(i===0)return;await new Promise((n)=>{let a=setTimeout(n,i);t?.addEventListener("abort",()=>{clearTimeout(a),n()},{once:!0})})}function ri(e){let t=['<?xml version="1.0" encoding="UTF-8"?>','<graphml xmlns="http://graphml.graphdrawing.org/xmlns">',' <key id="kind" for="node" attr.name="kind" attr.type="string"/>',' <key id="label" for="node" attr.name="label" attr.type="string"/>',' <key id="edgeType" for="edge" attr.name="type" attr.type="string"/>',' <key id="planningEligible" for="edge" attr.name="planningEligible" attr.type="boolean"/>',` <graph id="${le(e.fingerprint)}" edgedefault="directed">`];for(let i of e.capabilities)t.push(` <node id="${le(i.id)}"><data key="kind">capability</data><data key="label">${le(i.label)}</data></node>`);for(let i of e.operations)t.push(` <node id="${le(i.id)}"><data key="kind">operation</data><data key="label">${le(i.purpose)}</data></node>`);for(let i of e.edges)t.push(` <edge id="${le(i.id)}" source="${le(i.from)}" target="${le(i.to)}"><data key="edgeType">${le(i.type)}</data><data key="planningEligible">${String(i.planningEligible)}</data></edge>`);return t.push(" </graph>","</graphml>"),`${t.join(`
142
+ `)}
143
+ `}function le(e){return e.replaceAll("&","&amp;").replaceAll('"',"&quot;").replaceAll("<","&lt;").replaceAll(">","&gt;")}async function $n(e,t,i){return Promise.all(t.cases.map(async(n)=>{let a=await i.classify({graph:e,candidates:e.operations.map((l)=>({toolName:l.sourceOperationId??l.id,operationId:l.id,description:l.purpose})),query:n.query,mode:"lexical",limit:10,principal:n.principalScopes?{scopes:n.principalScopes}:void 0,authority:"decision"}),r=a.matches.map((l)=>l.operationId),s=Yr(e,n.query,a),o=[];for(let l of n.expectedOperationIds??[])if(!r.includes(l))o.push(`missing expected operation ${l}`);for(let l of n.excludedOperationIds??[])if(r.includes(l))o.push(`included excluded operation ${l}`);if(n.expectedOperationIds?.length===0&&r.length>0)o.push(`expected no matches, received ${r.join(", ")}`);if(n.expectedStatus&&n.expectedStatus!==s)o.push(`expected status ${n.expectedStatus}, received ${s}`);return{id:n.id,passed:o.length===0,status:s,operationIds:r,diagnostics:a.diagnostics,failures:o}}))}function Yr(e,t,i){let[n,a]=i.matches;if(!n)return"no-match";if(a&&a.score>=n.score*0.75)return"ambiguous";let r=e.operations.find((s)=>s.id===n.operationId);if(r&&qp(r,t))return"clarification-required";return"matched"}function qp(e,t){let i=e.inputs.filter((o)=>o.required).map((o)=>o.name),n=e.bodyVariants.some((o)=>o.required);if(i.length===0&&!n)return!1;let a=t.toLowerCase(),r=i.some((o)=>a.includes(o.toLowerCase())),s=/\b\d+\b|["'][^"']+["']/.test(t);return!r&&!s}var Hr={id:"capability-graph-v1",async create(e,t){let i=await Pe(e,t);return{graph:i,classifier:new fe,planner:new U,executorFactory:Tn(i),authority:"decision"}}},Wr={version:"1",id:"deterministic",create(){return new fe}};import{readFile as vw,mkdtemp as xw,rename as Sw,rm as kw,writeFile as El}from"fs/promises";import{basename as Vw,dirname as Ew,join as Vl,resolve as ir}from"path";import{fileURLToPath as Pw,pathToFileURL as Iw}from"url";import{DEFAULT_DOCUMENT_SOURCE_POLICY as pt,assertRemoteDocumentUrl as Gw,defineCommand as Ve,redactDocumentUrl as dt}from"@mcp-com-ai/plugin-sdk";var Hb=Na(),Wb=Nt(),Xb=ga(),Ka=$t(),Qb=Ct(),ke=I(),Zb=Ce(),eC=N(),tC=ve(),iC=xe(),v1=Bi(),nC=ja(),aC=za(),rC=Ba(),Yi=rl(),sl=gt();var sC=Hb.Composer,oC=Wb.Document,lC=Xb.Schema,{YAMLError:cC,YAMLParseError:pC,YAMLWarning:dC}=Ka,uC=Qb.Alias,{isAlias:fC,isCollection:yC,isDocument:hC,isMap:mC,isNode:gC,isPair:bC,isScalar:CC,isSeq:wC}=ke,vC=Zb.Pair,xC=eC.Scalar,SC=tC.YAMLMap,kC=iC.YAMLSeq;var VC=nC.Lexer,EC=aC.LineCounter,PC=rC.Parser,{parse:Ua,parseAllDocuments:IC,parseDocument:GC,stringify:OC}=Yi,{visit:AC,visitAsync:TC}=sl;function Hi(e){return/^operation\..+\.completed$/u.test(e.predicate)}function B(e){return E(e)}function K(e){return{predicate:e.predicate,...e.value!==void 0?{value:JSON.parse(E(e.value))}:{}}}function j(e){return`viz-${[...new TextEncoder().encode(e)].map((t)=>t.toString(16).padStart(2,"0")).join("")}`}function de(e){return e.flatMap((t)=>typeof t==="string"?[t]:[]).join(" ").normalize("NFKC").toLocaleLowerCase("en-US")}var ol="flow-card:start",ll="flow-card:outcome",pl=(e)=>`flow-card:step:${e}`;function dl(e,t){let{result:i}=t,n=new Map(e.operations.map((c)=>[c.id,c])),a=qe(t.initialFacts),r=NC(i.steps),s=$C(r),o=LC(t),l=i.steps.map((c)=>RC(c,{operation:ul(c,n),dependsOn:r[c.index].map((p)=>pl(p+1)),level:s[c.index],waits:c.gates.filter((p)=>o(p,c)).map(MC),inputHint:FC(e,i.steps,c,n)}));return{schemaVersion:"1",outcome:i.outcome,levelCount:l.length===0?0:Math.max(...s)+1,cards:[jC(a,qe(t.goalFacts),_C(e,a)),...l,zC(i)]}}function NC(e){return e.map((t,i)=>{let n=new Set;for(let a of t.requires){let r=BC(e,i,B(a));if(r!==void 0)n.add(r)}for(let a=0;a<i;a++){let r=e[a];if(cl(r.removes,[...t.requires,...t.produces])||cl(t.removes,[...r.requires,...r.produces]))n.add(a)}return[...n].sort((a,r)=>a-r)})}function $C(e){let t=[];return e.forEach((i,n)=>{t[n]=i.length?Math.max(...i.map((a)=>t[a]))+1:0}),t}function FC(e,t,i,n){let a=ul(i,n);if(!a)return;let r=qC(a),s=new Map;for(let l of t.slice(0,i.index))if(l.target.kind==="operation")s.set(l.target.id,l.index+1);let o=e.edges.filter((l)=>l.type==="operation-link"&&l.planningEligible&&l.to===a.id&&s.has(l.from)).map((l)=>({edgeIdentity:`edge:${l.id}`,fromStep:s.get(l.from),...l.label?{label:l.label}:{}})).sort((l,c)=>l.fromStep-c.fromStep||l.edgeIdentity.localeCompare(c.edgeIdentity));if(r.length===0&&o.length===0)return;return{status:o.length?"may-be-linked":"needs-input",inputs:r,links:o}}function qC(e){let t=new Map;for(let i of e.inputs){if(!i.required)continue;if(i.location!=="body"){t.set(`${i.location}:${i.name}`,{name:i.name,location:i.location});continue}let n=DC(e,i.schema?.required);for(let a of n.length?n:["body"])t.set(`body:${a}`,{name:a,location:"body"})}return[...t.entries()].sort(([i],[n])=>i.localeCompare(n)).map(([,i])=>i)}function DC(e,t){if(t?.length)return[...t];return[...new Set(e.bodyVariants.filter((i)=>i.required).flatMap((i)=>i.schema.required??[]))]}function LC(e){if(e.satisfiedGates&&e.principalSupplied!==void 0){let i=new Set(e.satisfiedGates),n=e.principalSupplied;return(a,r)=>!Zt(a,r.transitionId,i,n)}let t=new Set(e.result.unsatisfiedGates.map((i)=>`${i.kind}:${i.code}`));return(i)=>t.has(`${i.kind}:${i.code}`)}function MC(e){return{kind:e.kind,code:e.code,...e.detail?{detail:e.detail}:{}}}function RC(e,t){let i=pl(e.index+1),n=t.operation?.purpose||e.target.id,a=qe(e.requires),r=qe(e.produces),s=qe(e.removes);return{identity:i,domId:j(i),kind:"action",label:n,step:e.index+1,level:t.level,dependsOn:t.dependsOn,transitionId:e.transitionId,target:{...e.target},...t.operation?{effectMode:t.operation.effects.mode,purpose:t.operation.purpose}:{},requires:a,produces:r,removes:s,waits:t.waits,...e.outcomes?.length?{otherwise:e.outcomes.map((o)=>({status:o.status,produces:qe(o.produces),removes:qe(o.removes)}))}:{},...t.inputHint?{inputHint:t.inputHint}:{},searchText:de([n,e.transitionId,e.target.id,...[...a,...r,...s].map((o)=>o.predicate)])}}function _C(e,t){let i=new Set(t.map(B));return(e.triggers??[]).filter((n)=>n.produces.some((a)=>i.has(B(a)))).map((n)=>n.id).sort((n,a)=>n.localeCompare(a))}function jC(e,t,i){return{identity:ol,domId:j(ol),kind:"start",label:"Start when the goal is requested",dependsOn:[],requires:[],produces:[],removes:[],waits:[],initialFacts:e,goalFacts:t,...i.length?{triggerIds:[...i]}:{},searchText:de(["start",...i,...[...e,...t].map((n)=>n.predicate)])}}function zC(e){let t=[...new Set(e.diagnostics.map((i)=>i.code))].sort((i,n)=>i.localeCompare(n));return{identity:ll,domId:j(ll),kind:"outcome",label:`Outcome: ${e.outcome}`,dependsOn:[],requires:[],produces:[],removes:[],waits:[],outcome:e.outcome,diagnosticCodes:t,searchText:de(["outcome",e.outcome,...t])}}function ul(e,t){return e.target.kind==="operation"?t.get(e.target.id):void 0}function BC(e,t,i){for(let n=t-1;n>=0;n--)if(e[n].produces.some((a)=>B(a)===i))return n;return}function cl(e,t){let i=new Set(t.map(B));return e.some((n)=>i.has(B(n)))}function qe(e){return[...new Map(e.map((t)=>[B(t),K(t)]))].sort(([t],[i])=>t.localeCompare(i)).map(([,t])=>t)}function Xi(e,t=[]){let i=e.planning?.transitions??[],n=new Map,a=new Map,r=new Map,s=(y,h,m)=>{if(Hi(h))return;let g=B(h);n.set(g,h),y.set(g,(y.get(g)??new Set).add(m))},o=new Map;for(let y of i){for(let h of y.requires)s(a,h,y.target.id);for(let h of y.produces)s(r,h,y.target.id);for(let h of y.outcomes??[])for(let m of h.produces)s(o,m,`${y.target.id} ${h.status}`)}let l=new Map;for(let y of e.triggers??[])for(let h of y.produces)s(l,h,y.id);let c=KC(e,t),p=new Set(c.keys()),d=(y,h)=>({fact:K(n.get(y)),label:Qi(n.get(y)),operations:[...h.get(y)].sort((m,g)=>m.localeCompare(g))}),u=Wi(a),f=new Set(i.map((y)=>y.target.id));return{schemaVersion:"1",orphanRequirements:u.filter((y)=>!r.has(y)&&!o.has(y)&&!l.has(y)&&!p.has(y)).map((y)=>d(y,a)),clientVerifiedFacts:u.filter((y)=>p.has(y)).map((y)=>({...d(y,a),origins:[...c.get(y)].sort()})),outcomes:Wi(r).filter((y)=>!a.has(y)).map((y)=>d(y,r)),responseFacts:Wi(o).map((y)=>d(y,o)),eventFacts:Wi(l).map((y)=>d(y,l)),discoveryOnlyOperations:e.operations.map((y)=>y.id).filter((y)=>!f.has(y)).sort((y,h)=>y.localeCompare(h))}}function KC(e,t=[]){let i=new Map,n=(a,r)=>i.set(B(a),(i.get(B(a))??new Set).add(r));for(let a of e.clientFacts??[])n(a.fact,"contract");for(let a of t)n(a,"option");return i}function fl(e,t=[]){let i=new Map;for(let n of e.clientFacts??[])i.set(B(n.fact),n.fact);for(let n of t)i.set(B(n),n);return[...i.entries()].sort(([n],[a])=>n.localeCompare(a)).map(([,n])=>K(n))}function Qi(e){return e.value===void 0?e.predicate:`${e.predicate}=${JSON.stringify(e.value)}`}function Wi(e){return[...e.keys()].sort((t,i)=>t.localeCompare(i))}var yl=Object.freeze({maxInputBytes:16777216,maxNodes:5000,maxEdges:20000,maxPlanningTransitions:1e4,maxPlanningFacts:1e4,maxStateRelations:50000,maxPlanTraceSteps:1000,maxDiagnostics:2000,maxOutputBytes:33554432}),Zi=Object.freeze(["topology","business-states","planning","plan-trace","flow-cards"]);class De extends Error{code;details;constructor(e,t,i){super(t);this.code=e;this.details=i;this.name="CapabilityGraphVisualizationError"}}function ot(e){return e.value===void 0?e.predicate:`${e.predicate}=${UC(e.value)}`}function UC(e){return JSON.stringify(e)}var lt=340,te=54,bl={capability:48,operation:580},nn=22,_t=56;function Ha(e,t={}){let i=Wa(t.limits);hl(e,i);let n=HC(e,i);if(t.planTrace)hl(t.planTrace,i),iw(n,t.planTrace,i);let a=tn(n.capabilities.map((b)=>b.id),"capability"),r=tn(n.operations.map((b)=>b.id),"operation");for(let b of a)if(r.has(b))G("duplicate-node-id","graph.nodes");nw(n,a,r);let s=[...n.capabilities].sort(en),o=[...n.operations].sort(en),l=[...s.map((b,v)=>aw(b,v,n.operations)),...o.map((b,v)=>rw(b,v,n.capabilities))],c=new Map(l.map((b)=>[b.graphId,b])),p=[...n.edges].sort(en).map((b)=>sw(b,c)),d=n.planning?.transitions?[...n.planning.transitions].sort(en).map(ow):void 0,u=d?lw(d,i):void 0,f=t.planTrace?dw(n,t.planTrace,i):void 0,y=t.planTrace?dl(n,t.planTrace):void 0;if(y)se("maxPlanTraceSteps",y.cards.length-2,i.maxPlanTraceSteps);let h=YC(t.initialView);t.clientVerifiedFacts?.forEach((b,v)=>Me(b,`options.clientVerifiedFacts[${v}]`));let m=n.planning?Xi(n,t.clientVerifiedFacts):void 0,g=[...n.diagnostics].sort((b,v)=>`${b.severity}:${b.code}:${b.operationId??""}:${b.pointer??""}`.localeCompare(`${v.severity}:${v.code}:${v.operationId??""}:${v.pointer??""}`)).map((b,v)=>uw(b,v)),w=Math.max(s.length,o.length,1);return{schemaVersion:"1",graphSchemaVersion:"1",graphFingerprint:n.fingerprint,source:yw(n.source),counts:{capabilities:s.length,operations:o.length,edges:p.length,planningTransitions:d?.length??0,planningFacts:u?.counts.facts??0,businessFacts:u?.counts.businessFacts??0,technicalFacts:u?.counts.technicalFacts??0,stateRelations:u?.counts.relations??0,diagnostics:g.length},layout:{width:970,height:_t*2+w*(te+nn),nodeWidth:lt,nodeHeight:te},nodes:l,edges:p,...d?{planning:{schemaVersion:"1",transitions:d}}:{},...u?{businessStates:u}:{},...f?{planTrace:f}:{},...y?{flowCards:y}:{},...m?{factAudit:m}:{},...n.triggers?.length?{triggers:n.triggers.map(JC)}:{},...h?{initialView:h}:{},diagnostics:g,filters:fw(l,p,g)}}function JC(e){return{id:e.id,kind:e.kind,name:e.name,method:e.method,...e.expression?{expression:e.expression}:{},...e.operationId?{operationId:e.operationId}:{},purpose:e.purpose,produces:e.produces.map(K)}}function YC(e){if(e===void 0)return;if(!Zi.includes(e))G("unknown-initial-view","options.initialView");return e}function Wa(e={}){return Object.fromEntries(Object.entries(yl).map(([t,i])=>{let n=e[t];return[t,typeof n==="number"&&Number.isFinite(n)&&n>0?Math.min(Math.floor(n),i):i]}))}function hl(e,t){let i;try{i=JSON.stringify(e)}catch{G("non-json-input","graph")}let n=new TextEncoder().encode(i).byteLength;se("maxInputBytes",n,t.maxInputBytes),Ya(e,"graph",new WeakSet)}function Ya(e,t,i){if(e===null||typeof e==="string"||typeof e==="boolean")return;if(typeof e==="number"){if(!Number.isFinite(e))G("non-json-number",t);return}if(!e||typeof e!=="object")G("non-json-value",t);if(i.has(e))G("cyclic-input",t);if(i.add(e),Array.isArray(e))e.forEach((n,a)=>Ya(n,`${t}[${a}]`,i));else for(let[n,a]of Object.entries(e)){if(a===void 0)continue;Ya(a,`${t}.${n}`,i)}i.delete(e)}function HC(e,t){let i=R(e,"graph");if(i.schemaVersion!=="1")throw new De("unsupported-graph-version","Visualization supports CapabilityGraphV1 schemaVersion '1' only",{path:"graph.schemaVersion"});if(typeof i.fingerprint!=="string"||!/^[a-f0-9]{64}$/.test(i.fingerprint))G("invalid-fingerprint","graph.fingerprint");let n=R(i.source,"graph.source");F(n.kind,"graph.source.kind"),F(n.identifier,"graph.source.identifier");let a=T(i.capabilities,"graph.capabilities"),r=T(i.operations,"graph.operations"),s=T(i.edges,"graph.edges"),o=T(i.diagnostics,"graph.diagnostics"),l=i.triggers===void 0?[]:T(i.triggers,"graph.triggers");if(se("maxNodes",a.length+r.length+l.length,t.maxNodes),l.forEach((c,p)=>tw(c,p)),se("maxEdges",s.length,t.maxEdges),se("maxDiagnostics",o.length,t.maxDiagnostics),a.forEach((c,p)=>WC(c,p)),r.forEach((c,p)=>XC(c,p)),s.forEach((c,p)=>QC(c,p)),o.forEach((c,p)=>ZC(c,p)),i.planning!==void 0){let c=R(i.planning,"graph.planning");if(c.schemaVersion!=="1")G("invalid-planning-version","graph.planning.schemaVersion");let p=T(c.transitions,"graph.planning.transitions");se("maxPlanningTransitions",p.length,t.maxPlanningTransitions),p.forEach((d,u)=>ew(d,u))}return i}function WC(e,t){let i=`graph.capabilities[${t}]`,n=R(e,i);F(n.id,`${i}.id`),F(n.label,`${i}.label`),Rt(n.path,`${i}.path`),Cl(n.provenance,`${i}.provenance`)}function XC(e,t){let i=`graph.operations[${t}]`,n=R(e,i);F(n.id,`${i}.id`),Rt(n.capabilityIds,`${i}.capabilityIds`),F(n.purpose,`${i}.purpose`),Rt(n.useWhen,`${i}.useWhen`),Rt(n.avoidWhen,`${i}.avoidWhen`);let a=R(n.transport,`${i}.transport`);F(a.kind,`${i}.transport.kind`),T(n.inputs,`${i}.inputs`),T(n.bodyVariants,`${i}.bodyVariants`),T(n.outputs,`${i}.outputs`),R(n.effects,`${i}.effects`),T(n.authorization,`${i}.authorization`),Rt(n.prerequisites,`${i}.prerequisites`),R(n.provenance,`${i}.provenance`)}function QC(e,t){let i=`graph.edges[${t}]`,n=R(e,i);if(F(n.id,`${i}.id`),n.type!=="capability-operation"&&n.type!=="operation-link")G("invalid-edge-type",`${i}.type`);if(F(n.from,`${i}.from`),F(n.to,`${i}.to`),typeof n.planningEligible!=="boolean")G("invalid-edge",`${i}.planningEligible`);Cl(n.provenance,`${i}.provenance`)}function ZC(e,t){let i=`graph.diagnostics[${t}]`,n=R(e,i);if(F(n.code,`${i}.code`),n.severity!=="warning"&&n.severity!=="error")G("invalid-diagnostic-severity",`${i}.severity`);F(n.message,`${i}.message`)}function ew(e,t){let i=`graph.planning.transitions[${t}]`,n=R(e,i);F(n.id,`${i}.id`);let a=R(n.target,`${i}.target`);if(a.kind!=="operation"&&a.kind!=="workflow")G("invalid-target-kind",`${i}.target.kind`);F(a.id,`${i}.target.id`);for(let r of["requires","produces","removes"])T(n[r],`${i}.${r}`).forEach((s,o)=>Me(s,`${i}.${r}[${o}]`));if(typeof n.cost!=="number"||!Number.isFinite(n.cost)||n.cost<0)G("invalid-transition-cost",`${i}.cost`);T(n.gates,`${i}.gates`),T(n.sources,`${i}.sources`)}function tw(e,t){let i=`graph.triggers[${t}]`,n=R(e,i);for(let a of["id","name","method","purpose"])F(n[a],`${i}.${a}`);if(n.kind!=="webhook"&&n.kind!=="callback")G("invalid-trigger-kind",`${i}.kind`);T(n.produces,`${i}.produces`).forEach((a,r)=>Me(a,`${i}.produces[${r}]`))}function iw(e,t,i){t.initialFacts.forEach((s,o)=>Me(s,`options.planTrace.initialFacts[${o}]`)),t.goalFacts.forEach((s,o)=>Me(s,`options.planTrace.goalFacts[${o}]`));let n=R(t.result,"options.planTrace.result");if(n.schemaVersion!=="1")G("invalid-plan-trace-version","options.planTrace.result.schemaVersion");if(F(n.graphFingerprint,"options.planTrace.result.graphFingerprint"),!new Set(["planned","clarification-required","complete","unplannable"]).has(String(n.outcome)))G("invalid-plan-trace-outcome","options.planTrace.result.outcome");if(typeof n.totalCost!=="number"||!Number.isFinite(n.totalCost)||n.totalCost<0)G("invalid-plan-trace-cost","options.planTrace.result.totalCost");let a=T(n.steps,"options.planTrace.result.steps");se("maxPlanTraceSteps",a.length,i.maxPlanTraceSteps);let r=new Set((e.planning?.transitions??[]).map((s)=>s.id));a.forEach((s,o)=>{let l=R(s,`options.planTrace.result.steps[${o}]`);if(l.index!==o)G("invalid-plan-trace-index",`options.planTrace.result.steps[${o}].index`);let c=F(l.transitionId,`options.planTrace.result.steps[${o}].transitionId`);if(!r.has(c))G("unknown-plan-trace-transition",`options.planTrace.result.steps[${o}].transitionId`);for(let p of["requires","produces","removes"])T(l[p],`options.planTrace.result.steps[${o}].${p}`).forEach((d,u)=>Me(d,`options.planTrace.result.steps[${o}].${p}[${u}]`));if(l.outcomes!==void 0)T(l.outcomes,`options.planTrace.result.steps[${o}].outcomes`).forEach((p,d)=>{let u=`options.planTrace.result.steps[${o}].outcomes[${d}]`,f=R(p,u);F(f.status,`${u}.status`);for(let y of["produces","removes"])T(f[y],`${u}.${y}`).forEach((h,m)=>Me(h,`${u}.${y}[${m}]`))})}),T(n.unsatisfiedGates,"options.planTrace.result.unsatisfiedGates"),T(n.diagnostics,"options.planTrace.result.diagnostics")}function Me(e,t){let i=R(e,t);F(i.predicate,`${t}.predicate`)}function Cl(e,t){let i=R(e,t);if(!new Set(["extension","document","inferred"]).has(String(i.kind)))G("invalid-provenance",`${t}.kind`)}function nw(e,t,i){let n=new Set([...t,...i]);for(let r of e.operations)for(let s of r.capabilityIds)if(!t.has(s))G("unknown-capability-reference","graph.operations.capabilityIds");tn(e.edges.map((r)=>r.id),"edge");for(let r of e.edges){if(!n.has(r.from)||!n.has(r.to))G("unknown-edge-reference","graph.edges");if(r.type==="capability-operation"&&(!t.has(r.from)||!i.has(r.to)))G("invalid-membership-edge","graph.edges");if(r.type==="operation-link"&&(!i.has(r.from)||!i.has(r.to)))G("invalid-operation-link","graph.edges")}let a=e.planning?.transitions??[];tn(a.map((r)=>r.id),"planning-transition");for(let r of a)if(r.target.kind==="operation"&&!i.has(r.target.id))G("unknown-transition-target","graph.planning.transitions");for(let r of e.diagnostics)if(r.operationId&&!i.has(r.operationId))G("unknown-diagnostic-operation","graph.diagnostics")}function aw(e,t,i){let n=`capability:${e.id}`,a=i.filter((r)=>r.capabilityIds.includes(e.id)).map((r)=>`operation:${r.id}`).sort();return{identity:n,graphId:e.id,domId:j(n),kind:"capability",label:e.label,...e.description?{description:e.description}:{},taxonomy:[...e.path],provenance:ct(e.provenance),relatedIdentities:a,position:{x:bl.capability,y:_t+t*(te+nn)},searchText:de([e.id,e.label,e.description,...e.path])}}function rw(e,t,i){let n=`operation:${e.id}`,a=i.filter((s)=>e.capabilityIds.includes(s.id)).flatMap((s)=>s.path).filter(bw).sort(),r=e.authorization.flatMap((s)=>s.schemes.flatMap((o)=>[o.scheme,...o.scopes]));return{identity:n,graphId:e.id,domId:j(n),kind:"operation",label:e.sourceOperationId??e.id,purpose:e.purpose,taxonomy:a,...e.transport.method?{method:e.transport.method}:{},...e.transport.path?{path:e.transport.path}:{},useWhen:[...e.useWhen],avoidWhen:[...e.avoidWhen],inputs:e.inputs.map(hw),bodyVariants:e.bodyVariants.map(mw),outputs:e.outputs.map(gw),effects:{...e.effects},authorization:e.authorization.map((s)=>({schemes:s.schemes.map((o)=>({scheme:o.scheme,scopes:[...o.scopes]}))})),prerequisites:[...e.prerequisites],fieldProvenance:Object.fromEntries(Object.entries(e.provenance).filter((s)=>Boolean(s[1])).map(([s,o])=>[s,ct(o)])),provenance:ct(e.provenance.identity??{kind:"inferred"}),relatedIdentities:e.capabilityIds.map((s)=>`capability:${s}`).sort(),position:{x:bl.operation,y:_t+t*(te+nn)},searchText:de([e.id,e.sourceOperationId,e.purpose,e.transport.method,e.transport.path,e.effects.mode,...a,...e.useWhen,...e.avoidWhen,...e.prerequisites,...r])}}function sw(e,t){let i=t.get(e.from),n=t.get(e.to),a=`edge:${e.id}`;return{identity:a,graphId:e.id,domId:j(a),type:e.type,sourceIdentity:i.identity,targetIdentity:n.identity,path:`M ${i.position.x+lt} ${i.position.y+te/2} L ${n.position.x} ${n.position.y+te/2}`,...e.label?{label:e.label}:{},planningEligible:e.planningEligible,provenance:ct(e.provenance)}}function ow(e){let t=`transition:${e.id}`;return{identity:t,graphId:e.id,domId:j(t),target:{...e.target},requires:e.requires.map(K),produces:e.produces.map(K),removes:e.removes.map(K),cost:e.cost,gates:e.gates.map((i)=>({kind:i.kind,status:i.status,code:i.code,...i.detail?{detail:i.detail}:{}})),sources:e.sources.map((i)=>({kind:i.kind,provenance:ct(i.provenance)})),searchText:de([e.id,e.target.kind,e.target.id,...e.requires.map(ot),...e.produces.map(ot),...e.removes.map(ot),...e.gates.flatMap((i)=>[i.kind,i.status,i.code,i.detail]),...e.sources.map((i)=>i.kind)])}}function lw(e,t){let i=new Map,n=[];for(let f of e)for(let y of["requires","produces","removes"])for(let h of f[y]){let m=E(h);i.set(m,K(h)),n.push({kind:y,factKey:m,transition:f})}se("maxPlanningFacts",i.size,t.maxPlanningFacts),se("maxStateRelations",n.length,t.maxStateRelations);let a=[...i.keys()].sort(),r=e.map((f)=>f.identity),s=cw(a,r,n),o=a.map((f)=>{let y=i.get(f),h=Xa(y),m=n.filter((g)=>g.factKey===f);return{identity:h,domId:j(h),fact:y,label:ot(y),technical:Hi(y),position:s.get(h),producerIdentities:Ja(m,"produces"),consumerIdentities:Ja(m,"requires"),removerIdentities:Ja(m,"removes"),searchText:de([y.predicate,ot(y)])}}),l=e.map((f)=>({identity:f.identity,domId:j(`state-${f.identity}`),transitionIdentity:f.identity,label:f.target.id,position:s.get(f.identity),searchText:f.searchText})),c=n.map((f)=>pw(f,s)).sort((f,y)=>f.identity.localeCompare(y.identity)),p=Math.max(0,...[...s.values()].map((f)=>f.x)),d=Math.max(0,...[...s.values()].map((f)=>f.y)),u=o.filter((f)=>f.technical).length;return{schemaVersion:"1",facts:o,transitions:l,relations:c,layout:{width:Math.max(970,p+lt+48),height:Math.max(240,d+te+_t),nodeWidth:lt,nodeHeight:te},counts:{facts:o.length,businessFacts:o.length-u,technicalFacts:u,relations:c.length}}}function cw(e,t,i){let n=new Map(e.map((m)=>[m,Xa(JSON.parse(m))])),a=[...n.values(),...t].sort(),r=new Map(a.map((m)=>[m,[]])),s=new Map(a.map((m)=>[m,0]));for(let m of i){let g=n.get(m.factKey),w=m.transition.identity,[b,v]=m.kind==="requires"?[g,w]:[w,g];r.get(b).push(v),s.set(v,(s.get(v)??0)+1)}for(let m of r.values())m.sort();let o=new Map(a.map((m)=>[m,0])),l=a.filter((m)=>s.get(m)===0).sort(),c=new Set;while(l.length){let m=l.shift();c.add(m);for(let g of r.get(m)??[])if(o.set(g,Math.max(o.get(g)??0,(o.get(m)??0)+1)),s.set(g,(s.get(g)??0)-1),s.get(g)===0)l.push(g),l.sort()}let p=Math.max(0,...[...c].map((m)=>o.get(m)??0)),d=a.filter((m)=>!c.has(m)),u=d.filter((m)=>m.startsWith("fact:")),f=d.filter((m)=>m.startsWith("transition:"));for(let m of u)o.set(m,p+1);for(let m of f)o.set(m,p+2);let y=new Map;for(let m of a){let g=o.get(m)??0,w=y.get(g)??[];w.push(m),y.set(g,w)}let h=new Map;for(let[m,g]of[...y].sort(([w],[b])=>w-b))g.sort(),g.forEach((w,b)=>h.set(w,{x:48+m*390,y:_t+b*(te+nn)}));return h}function pw(e,t){let i=Xa(JSON.parse(e.factKey)),n=e.transition.identity,[a,r]=e.kind==="requires"?[i,n]:[n,i],s=t.get(a),o=t.get(r),l=`state-relation:${e.kind}:${n}:${e.factKey}`;return{identity:l,domId:j(l),kind:e.kind,factIdentity:i,transitionIdentity:n,sourceIdentity:a,targetIdentity:r,path:`M ${s.x+lt/2} ${s.y+te/2} L ${o.x+lt/2} ${o.y+te/2}`,sources:e.transition.sources.map((c)=>({kind:c.kind,provenance:ct(c.provenance)}))}}function Ja(e,t){return Le(e.filter((i)=>i.kind===t).map((i)=>i.transition.identity))}function Xa(e){return`fact:${E(e)}`}function dw(e,t,i){if(t.result.graphFingerprint!==e.fingerprint)G("plan-trace-fingerprint-mismatch","options.planTrace.result.graphFingerprint");se("maxPlanTraceSteps",t.result.steps.length,i.maxPlanTraceSteps);let n=ml(t.initialFacts),a=ml(t.goalFacts),r=n,s=[{identity:"plan-state:0",domId:j("plan-state:0"),index:0,label:"Initial state",facts:r,added:r,removed:[]}];for(let o of t.result.steps){let l=new Map(r.map((f)=>[E(f),f])),c=new Map(l);for(let f of o.removes)c.delete(E(f));for(let f of o.produces)c.set(E(f),K(f));r=[...c.entries()].sort(([f],[y])=>f.localeCompare(y)).map(([,f])=>f);let p=r.filter((f)=>!l.has(E(f))),d=[...l.entries()].filter(([f])=>!c.has(f)).sort(([f],[y])=>f.localeCompare(y)).map(([,f])=>f),u=`plan-state:${o.index+1}`;s.push({identity:u,domId:j(u),index:o.index+1,label:`After ${o.transitionId}`,facts:r,added:p,removed:d,transitionId:o.transitionId,target:{...o.target}})}return{schemaVersion:"1",outcome:t.result.outcome,graphFingerprint:t.result.graphFingerprint,initialFacts:n,goalFacts:a,totalCost:t.result.totalCost,states:s,unsatisfiedGates:t.result.unsatisfiedGates.map((o)=>({...o})),diagnostics:t.result.diagnostics.map((o)=>({code:o.code,severity:o.severity,message:o.message,...o.pointer?{pointer:o.pointer}:{},...o.operationId?{operationId:o.operationId}:{}}))}}function ml(e){return[...new Map(e.map((t)=>[E(t),K(t)])).entries()].sort(([t],[i])=>t.localeCompare(i)).map(([,t])=>t)}function uw(e,t){let i=`diagnostic:${t}:${e.code}`;return{identity:i,domId:j(i),code:e.code,severity:e.severity,message:e.message,...e.pointer?{pointer:e.pointer}:{},...e.operationId?{operationIdentity:`operation:${e.operationId}`}:{}}}function fw(e,t,i){return{taxonomy:Le(e.flatMap((n)=>n.taxonomy)),methods:Le(e.flatMap((n)=>n.method?[n.method.toUpperCase()]:[])),effects:Le(e.flatMap((n)=>n.effects?[n.effects.mode]:[])),provenanceKinds:Le(e.map((n)=>n.provenance.kind)),diagnosticSeverities:Le(i.map((n)=>n.severity)),edgeTypes:Le(t.map((n)=>n.type))}}function yw(e){return{kind:e.kind,identifier:gl(e.identifier),...e.canonicalUri?{canonicalUri:gl(e.canonicalUri)}:{},...e.documentVersion?{documentVersion:e.documentVersion}:{},...e.title?{title:e.title}:{},...e.version?{version:e.version}:{}}}function gl(e){if(/^file:/i.test(e)||e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e))return e.split(/[\\/]/).filter(Boolean).at(-1)??"local-source";return e}function hw(e){return{name:e.name,location:e.location,required:e.required,...e.description?{description:e.description}:{},...e.schema?{schema:Qa(e.schema)}:{}}}function mw(e){return{id:e.id,mediaType:e.mediaType,required:e.required,...e.title?{title:e.title}:{},schemaHash:e.schemaHash,schema:Qa(e.schema)}}function gw(e){return{status:e.status,description:e.description,mediaTypes:[...e.mediaTypes],fields:[...e.fields]}}function Qa(e){return{...e.ref?{ref:e.ref}:{},...e.type?{type:e.type}:{},...e.format?{format:e.format}:{},...e.title?{title:e.title}:{},...e.description?{description:e.description}:{},...e.enum?{enum:[...e.enum]}:{},...e.required?{required:[...e.required]}:{},...e.properties?{properties:[...e.properties]}:{},...e.items?{items:Qa(e.items)}:{}}}function ct(e){return{kind:e.kind,...e.pointer?{pointer:e.pointer}:{},...e.detail?{detail:e.detail}:{}}}function Le(e){return[...new Set(e)].sort((t,i)=>t.localeCompare(i))}function bw(e,t,i){return i.indexOf(e)===t}function tn(e,t){let i=new Set;for(let n of e){if(i.has(n))G(`duplicate-${t}-id`,`graph.${t}`);i.add(n)}return i}function en(e,t){return e.id.localeCompare(t.id)}function se(e,t,i){if(t<=i)return;throw new De("visualization-limit-exceeded",`Visualization ${e} exceeded: ${t} > ${i}`,{limit:e,count:t,maximum:i})}function G(e,t){throw new De(e,`Capability graph is invalid for visualization at ${t}`,{path:t})}function R(e,t){if(!e||typeof e!=="object"||Array.isArray(e))G("expected-object",t);return e}function T(e,t){if(!Array.isArray(e))G("expected-array",t);return e}function F(e,t){if(typeof e!=="string"||e.length===0)G("expected-string",t);return e}function Rt(e,t){return T(e,t).map((i,n)=>F(i,`${t}[${n}]`))}async function wl(e,t={}){let i=fl(e,t.clientVerifiedFacts),n=Xi(e,t.clientVerifiedFacts),a=t.reachability===!1?void 0:await Cw(e,{clientVerifiedFacts:i,goalFacts:t.goalFacts?.length?t.goalFacts:n.outcomes.map((s)=>s.fact),bounds:t.bounds??_}),r=a?.results.filter((s)=>!s.reachable).length??0;return{...n,graphFingerprint:e.fingerprint,...a?{reachability:a}:{},clean:n.orphanRequirements.length===0&&r===0}}async function Cw(e,t){let i=e.planning?.transitions??[],n=Za(i.map((l)=>l.target.id)),a=Za(i.flatMap((l)=>l.gates.filter((c)=>c.kind!=="authorization").map((c)=>c.code))),r=t.clientVerifiedFacts,s=new U,o=[];for(let l of t.goalFacts){let c=await s.plan({schemaVersion:"1",graph:e,initialFacts:r,goalFacts:[l],satisfiedGates:a,principal:{authorizedOperationIds:n},bounds:t.bounds});o.push({goal:l,label:Qi(l),outcome:c.outcome,reachable:c.outcome==="planned"||c.outcome==="complete",diagnostics:Za(c.diagnostics.map((p)=>p.code))})}return{kind:"topology-check",initialFacts:[...r],satisfiedGates:a,results:o.sort((l,c)=>l.label.localeCompare(c.label))}}function vl(e){let t=[`Graph fingerprint: ${e.graphFingerprint}`,""],i=(n,a)=>{t.push(`${n}:`),t.push(...a.length?a.map((r)=>` ${r}`):[" none"]),t.push("")};if(i("Orphan requirements (required, never produced, not client-verified)",e.orphanRequirements.map((n)=>`\u2717 ${n.label} required by ${n.operations.join(", ")}`)),i("Client-verified facts",e.clientVerifiedFacts.map((n)=>`\u2022 ${n.label} required by ${n.operations.join(", ")} [${(n.origins??[]).join(", ")}]`)),i("Outcomes (candidate goals)",e.outcomes.map((n)=>`\u2022 ${n.label} produced by ${n.operations.join(", ")}`)),e.responseFacts.length)i("Response outcome facts (established by an observed response, never planned)",e.responseFacts.map((n)=>`\u2022 ${n.label} from ${n.operations.join(", ")}`));if(e.eventFacts.length)i("Event facts (signalled by a declared webhook or callback; HAPI never receives it)",e.eventFacts.map((n)=>`\u2022 ${n.label} from ${n.operations.join(", ")}`));if(i("Discovery-only operations",e.discoveryOnlyOperations),e.reachability){let n=e.reachability;t.push("Reachability (topology check: all operations eligible, all non-authorization gates treated as satisfied; not an authorization or confirmation):"),t.push(` from {${n.initialFacts.map(Qi).join(", ")}}`);for(let a of n.results)t.push(a.reachable?` \u2713 ${a.label}: ${a.outcome}`:` \u2717 ${a.label}: ${a.outcome} (${a.diagnostics.join(", ")||"-"})`);t.push("")}return t.push(e.clean?"Result: clean":"Result: gaps found"),`${t.join(`
144
+ `)}
145
+ `}function Za(e){return[...new Set(e)].sort((t,i)=>t.localeCompare(i))}var er=String.raw`
146
+ :root{color-scheme:light dark;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:#07111f;color:#e5edf8;--panel:#101d2d;--panel2:#17263a;--line:#4d6a8a;--accent:#55d6be;--accent2:#f3b95f;--danger:#ff7b89;--muted:#9db0c7;--focus:#fff36b}*{box-sizing:border-box}body{margin:0;min-width:320px;background:radial-gradient(circle at top left,#17304b 0,#07111f 42rem);color:#e5edf8}button,input,select{font:inherit}button,select,input{border:1px solid #496783;border-radius:.45rem;background:#102238;color:inherit;padding:.55rem .7rem}button{cursor:pointer}button:hover{border-color:var(--accent)}:focus-visible{outline:3px solid var(--focus);outline-offset:2px}header{padding:1.2rem 1.4rem;border-bottom:1px solid #29415c;background:#091625ee;position:sticky;top:0;z-index:5}h1{font-size:1.35rem;margin:0 0 .35rem}.notice{color:var(--accent);font-weight:700}.meta{color:var(--muted);font-size:.9rem;overflow-wrap:anywhere}.shell{display:grid;grid-template-columns:minmax(15rem,20rem) minmax(0,1fr);min-height:calc(100vh - 7rem)}aside{padding:1rem;border-right:1px solid #29415c;background:#091625}.filters{display:grid;gap:.75rem}.filters label{display:grid;gap:.3rem;font-size:.85rem;color:var(--muted)}.filter-actions{display:flex;gap:.5rem}.content{min-width:0;padding:1rem}.tabs{display:flex;gap:.5rem;margin-bottom:1rem}.tabs button[aria-selected=true]{background:var(--accent);border-color:var(--accent);color:#06131f;font-weight:800}.view[hidden]{display:none}.topology-grid{display:grid;grid-template-columns:minmax(0,2fr) minmax(17rem,1fr);gap:1rem}.panel{background:var(--panel);border:1px solid #29415c;border-radius:.7rem;padding:1rem;min-width:0}.canvas{overflow:auto;max-height:68vh}.graph-svg{min-width:60rem;background:#0a1726;border-radius:.5rem}.edge{fill:none;stroke:var(--line);stroke-width:2}.edge.operation-link{stroke-dasharray:8 5}.edge.eligible{stroke:var(--accent2);stroke-width:3}.node rect{fill:var(--panel2);stroke:#52708e;stroke-width:2;rx:8}.node.capability rect{stroke:var(--accent)}.node.operation rect{stroke:var(--accent2)}.node:focus rect,.node.selected rect{stroke:var(--focus);stroke-width:4}.node text{fill:currentColor;font-size:13px;pointer-events:none}.item-list,.planning-list,.diagnostic-list{list-style:none;padding:0;margin:.5rem 0;display:grid;gap:.35rem}.item-list button,.planning-list button,.diagnostic-list button{width:100%;text-align:left}.item-list button[aria-current=true],.planning-list button[aria-current=true],.diagnostic-list button[aria-current=true]{border-color:var(--focus);background:#27374b}.badge{display:inline-block;border:1px solid #54708c;border-radius:999px;padding:.1rem .45rem;margin:.1rem .2rem .1rem 0;font-size:.75rem;color:var(--muted)}.badge.warning{border-color:var(--accent2);color:var(--accent2)}.badge.error{border-color:var(--danger);color:var(--danger)}.details{overflow-wrap:anywhere}.details dl{display:grid;grid-template-columns:minmax(7rem,auto) 1fr;gap:.45rem .75rem}.details dt{color:var(--muted);font-weight:700}.details dd{margin:0;white-space:pre-wrap}.empty{color:var(--muted);font-style:italic}.status{min-height:1.5rem;color:var(--muted)}.counts{display:flex;flex-wrap:wrap;gap:.5rem;margin:.7rem 0}.count{background:#13243a;border-radius:.4rem;padding:.35rem .55rem}.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}@media(max-width:900px){.shell{grid-template-columns:1fr}aside{border-right:0;border-bottom:1px solid #29415c}.topology-grid{grid-template-columns:1fr}.canvas{max-height:50vh}}@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}@media(forced-colors:active){.edge,.edge.eligible{stroke:CanvasText}.node rect,.node.capability rect,.node.operation rect{fill:Canvas;stroke:CanvasText}.node:focus rect,.node.selected rect{stroke:Highlight}.notice{color:CanvasText}}
147
+ .technical-toggle{display:flex;align-items:center;gap:.5rem;margin:.5rem 0 1rem;color:var(--muted)}.technical-toggle input{width:auto}.state-relation{fill:none;stroke-width:2}.state-relation.requires{stroke:#7fb5ff}.state-relation.produces{stroke:var(--accent);marker-end:url(#state-arrow)}.state-relation.removes{stroke:var(--danger);stroke-dasharray:7 5;marker-end:url(#state-remove-arrow)}.state-node.fact rect{stroke:#7fb5ff}.state-node.transition rect{stroke:var(--accent2);stroke-width:3}.state-node.technical rect{stroke-dasharray:6 4}.state-node text{fill:currentColor;font-size:13px;pointer-events:none}.state-node:focus rect,.state-node.selected rect{stroke:var(--focus);stroke-width:4}.legend{display:flex;flex-wrap:wrap;gap:1rem;color:var(--muted)}.trace-state{border-left:4px solid var(--accent);padding:.7rem;margin:.5rem 0;background:var(--panel2)}.trace-state h3{margin:.1rem 0 .45rem}.outcome{display:inline-block;text-transform:uppercase;font-weight:800;border:1px solid var(--accent);border-radius:999px;padding:.15rem .5rem}.outcome.unplannable{border-color:var(--danger);color:var(--danger)}.outcome.clarification-required{border-color:var(--accent2);color:var(--accent2)}
148
+ .flow-cards{display:grid;gap:.4rem;justify-items:center;padding:1rem;border:1px solid #29415c;border-radius:.6rem;background:#0b1828}.flow-level{display:flex;flex-wrap:wrap;justify-content:center;gap:.9rem;width:100%}.flow-level-label{color:var(--muted);font-size:.75rem;text-transform:uppercase;letter-spacing:.06em}.flow-then{color:var(--accent);font-size:.8rem}.flow-card{width:min(100%,19rem);border:1px solid var(--line);border-radius:.55rem;background:var(--panel);text-align:left;cursor:pointer}.flow-card.selected{outline:3px solid var(--focus)}.flow-card.dim{opacity:.45}.flow-card header{position:static;display:flex;gap:.5rem;align-items:center;padding:.5rem .75rem;border-bottom:1px solid var(--line);background:var(--panel2);font-weight:700;font-size:.85rem}.flow-card .flow-body{display:grid;gap:.35rem;padding:.6rem .75rem;font-size:.85rem}.flow-card.flow-start header,.flow-card.flow-outcome header{color:var(--accent)}.flow-card .wait{color:var(--accent2);font-weight:700}.flow-card .inputs{color:var(--muted)}.flow-card .trigger{color:var(--accent);font-weight:700}.flow-card .otherwise{color:var(--danger);border-left:3px dashed var(--danger);padding-left:.4rem}.flow-card .facts{display:flex;flex-wrap:wrap;gap:.25rem}.flow-card .fact{font-family:ui-monospace,monospace;font-size:.72rem;padding:.12rem .35rem;border-radius:.25rem;background:#1d3048}.flow-card .op{font-family:ui-monospace,monospace;font-size:.75rem;color:var(--muted);overflow-wrap:anywhere}.flow-gaps{display:grid;gap:.6rem;margin-top:1rem}.flow-gap{border:1px dashed var(--danger);border-radius:.5rem;padding:.6rem .8rem}.flow-gap h3{margin:.1rem 0 .4rem;font-size:.9rem;color:var(--danger)}.flow-gap.info{border-color:var(--line)}.flow-gap.info h3{color:var(--muted)}@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
149
+ `,tr=String.raw`
150
+ "use strict";
151
+ (()=>{
152
+ const byId=id=>document.getElementById(id);
153
+ const text=(tag,value,className)=>{const node=document.createElement(tag);if(className)node.className=className;node.textContent=String(value);return node};
154
+ const svg=(tag,attrs={})=>{const node=document.createElementNS("http://www.w3.org/2000/svg",tag);for(const [key,value] of Object.entries(attrs))node.setAttribute(key,String(value));return node};
155
+ const decodeData=()=>{const encoded=byId("visualization-data").textContent.trim();const binary=atob(encoded);const bytes=Uint8Array.from(binary,char=>char.charCodeAt(0));return JSON.parse(new TextDecoder().decode(bytes))};
156
+ const data=decodeData();
157
+ const nodesByIdentity=new Map(data.nodes.map(node=>[node.identity,node]));
158
+ const transitionsByIdentity=new Map((data.planning?.transitions??[]).map(item=>[item.identity,item]));
159
+ const factsByIdentity=new Map((data.businessStates?.facts??[]).map(item=>[item.identity,item]));
160
+ const planStatesByIdentity=new Map((data.planTrace?.states??[]).map(item=>[item.identity,item]));
161
+ const diagnosticsByIdentity=new Map(data.diagnostics.map(item=>[item.identity,item]));
162
+ const triggersById=new Map((data.triggers??[]).map(item=>[item.id,item]));
163
+ const triggerText=trigger=>trigger.kind+" "+trigger.name+" ("+trigger.method.toUpperCase()+")";
164
+ const flowCardsByIdentity=new Map((data.flowCards?.cards??[]).map(item=>[item.identity,item]));
165
+ const factText=fact=>fact.value===undefined?fact.predicate:fact.predicate+"="+JSON.stringify(fact.value);
166
+ const state={selected:null,view:"topology"};
167
+ const controls={query:byId("query"),kind:byId("node-kind"),taxonomy:byId("taxonomy"),method:byId("method"),effect:byId("effect"),authorization:byId("authorization"),provenance:byId("provenance"),severity:byId("severity"),edgeType:byId("edge-type"),eligibility:byId("planning-eligibility")};
168
+ const normalize=value=>String(value??"").normalize("NFKC").toLocaleLowerCase("en-US");
169
+ const addOptions=(select,values)=>{for(const value of values){const option=text("option",value);option.value=value;select.append(option)}};
170
+ addOptions(controls.taxonomy,data.filters.taxonomy);addOptions(controls.method,data.filters.methods);addOptions(controls.effect,data.filters.effects);addOptions(controls.provenance,data.filters.provenanceKinds);addOptions(controls.severity,data.filters.diagnosticSeverities);addOptions(controls.edgeType,data.filters.edgeTypes);
171
+ byId("graph-meta").textContent="Graph V"+data.graphSchemaVersion+" \u00B7 "+data.graphFingerprint+" \u00B7 "+data.source.identifier;
172
+ const counts=byId("counts");for(const [name,value] of Object.entries(data.counts))counts.append(text("span",name+": "+value,"count"));
173
+ const nodeMatches=node=>{const tokens=normalize(controls.query.value).split(/\s+/).filter(Boolean);return tokens.every(token=>node.searchText.includes(token))&&(!controls.kind.value||node.kind===controls.kind.value)&&(!controls.taxonomy.value||node.taxonomy.includes(controls.taxonomy.value))&&(!controls.method.value||normalize(node.method)===normalize(controls.method.value))&&(!controls.effect.value||node.effects?.mode===controls.effect.value)&&(!controls.authorization.value||(controls.authorization.value==="required")===(node.authorization?.length>0))&&(!controls.provenance.value||node.provenance.kind===controls.provenance.value)};
174
+ const queryMatches=item=>normalize(item.searchText).includes(normalize(controls.query.value));
175
+ const edgeMatches=edge=>(!controls.edgeType.value||edge.type===controls.edgeType.value)&&(!controls.eligibility.value||(controls.eligibility.value==="eligible")===edge.planningEligible);
176
+ const diagnosticMatches=item=>!controls.severity.value||item.severity===controls.severity.value;
177
+ const itemButton=(item,label)=>{const button=text("button",label);button.type="button";button.dataset.identity=item.identity;button.setAttribute("aria-current",String(state.selected===item.identity));button.addEventListener("click",()=>selectIdentity(item.identity));return button};
178
+ const addDetail=(list,label,value)=>{if(value===undefined||value===null||value===""||(Array.isArray(value)&&value.length===0))return;list.append(text("dt",label),text("dd",Array.isArray(value)?value.map(entry=>typeof entry==="object"?JSON.stringify(entry):String(entry)).join("\n"):typeof value==="object"?JSON.stringify(value,null,2):value))};
179
+ const selectIdentity=(identity,updateHash=true)=>{state.selected=identity;for(const button of document.querySelectorAll("[data-identity]"))button.setAttribute("aria-current",String(button.dataset.identity===identity));for(const node of document.querySelectorAll(".node,.state-node,.flow-card"))node.classList.toggle("selected",node.dataset.identity===identity);renderDetails(identity);if(updateHash)history.replaceState(null,"","#item="+encodeURIComponent(identity))};
180
+ const renderDetails=identity=>{const target=byId("details");target.replaceChildren();const node=nodesByIdentity.get(identity),transition=transitionsByIdentity.get(identity),fact=factsByIdentity.get(identity),planState=planStatesByIdentity.get(identity),card=flowCardsByIdentity.get(identity),diagnostic=diagnosticsByIdentity.get(identity);const item=node??transition??fact??planState??card??diagnostic;if(!item){target.append(text("p",identity?"Selection is unavailable in this graph.":"Select an item to inspect its safe graph metadata.","empty"));byId("status").textContent=identity?"Requested selection is unavailable.":"";return}const title=node?(node.label||node.graphId):transition?transition.graphId:fact?fact.label:planState?planState.label:card?card.label:diagnostic.code;target.append(text("h2",title));const list=document.createElement("dl");addDetail(list,"Identity",item.identity);if(node){addDetail(list,"Kind",node.kind);addDetail(list,"Purpose",node.purpose);addDetail(list,"Description",node.description);addDetail(list,"Taxonomy",node.taxonomy);addDetail(list,"Transport",[node.method,node.path].filter(Boolean).join(" "));addDetail(list,"Use when",node.useWhen);addDetail(list,"Avoid when",node.avoidWhen);addDetail(list,"Inputs",node.inputs);addDetail(list,"Body variants",node.bodyVariants);addDetail(list,"Outputs",node.outputs);addDetail(list,"Effects",node.effects);addDetail(list,"Authorization",node.authorization);addDetail(list,"Prerequisites",node.prerequisites);addDetail(list,"Related",node.relatedIdentities);addDetail(list,"Provenance",node.provenance);addDetail(list,"Field provenance",node.fieldProvenance)}else if(transition){addDetail(list,"Target",transition.target);addDetail(list,"Requires",transition.requires);addDetail(list,"Produces",transition.produces);addDetail(list,"Removes",transition.removes);addDetail(list,"Cost",transition.cost);addDetail(list,"Gates",transition.gates);addDetail(list,"Sources",transition.sources)}else if(fact){addDetail(list,"Predicate",fact.fact.predicate);addDetail(list,"Value",fact.fact.value);addDetail(list,"Technical",fact.technical);addDetail(list,"Produced by",fact.producerIdentities);addDetail(list,"Required by",fact.consumerIdentities);addDetail(list,"Removed by",fact.removerIdentities);const provenance=(data.businessStates?.relations??[]).filter(relation=>relation.factIdentity===fact.identity).map(relation=>({relationship:relation.kind,transition:relation.transitionIdentity,sources:relation.sources}));addDetail(list,"Relationship provenance",provenance)}else if(planState){addDetail(list,"Step",planState.index);addDetail(list,"Transition",planState.transitionId);addDetail(list,"Target",planState.target);addDetail(list,"Facts",planState.facts);addDetail(list,"Added",planState.added);addDetail(list,"Removed",planState.removed)}else if(card){addDetail(list,"Card kind",card.kind);addDetail(list,"Planner step",card.step);addDetail(list,"Dependency level",card.level);addDetail(list,"Depends on",card.dependsOn);addDetail(list,"Transition",card.transitionId);addDetail(list,"Target",card.target);addDetail(list,"Effect",card.effectMode);addDetail(list,"Requires",card.requires.map(factText));addDetail(list,"Produces",card.produces.map(factText));addDetail(list,"Removes",card.removes.map(factText));addDetail(list,"Waits",card.waits.map(wait=>wait.kind+": "+wait.code));addDetail(list,"Otherwise",(card.otherwise??[]).map(branch=>branch.status+": +"+branch.produces.map(factText).join(",")+" \u2212"+branch.removes.map(factText).join(",")));addDetail(list,"Input hint",card.inputHint);addDetail(list,"Initial facts",(card.initialFacts??[]).map(factText));addDetail(list,"Start triggers",card.triggerIds);addDetail(list,"Goal facts",(card.goalFacts??[]).map(factText));addDetail(list,"Outcome",card.outcome);addDetail(list,"Diagnostics",card.diagnosticCodes)}else{addDetail(list,"Severity",diagnostic.severity);addDetail(list,"Message",diagnostic.message);addDetail(list,"Pointer",diagnostic.pointer);addDetail(list,"Operation",diagnostic.operationIdentity)}target.append(list);byId("status").textContent="Selected "+item.identity};
181
+ const selectableSvgNode=(item,className,label,layout)=>{const group=svg("g",{id:item.domId,class:className,role:"button",tabindex:"0","data-identity":item.identity,"aria-label":label});const title=svg("title");title.textContent=label;const rect=svg("rect",{x:item.position.x,y:item.position.y,width:layout.nodeWidth,height:layout.nodeHeight,rx:8});const caption=svg("text",{x:item.position.x+14,y:item.position.y+32});caption.textContent=label.length>42?label.slice(0,39)+"\u2026":label;group.append(title,rect,caption);group.addEventListener("click",()=>selectIdentity(item.identity));group.addEventListener("keydown",event=>{if(event.key==="Enter"||event.key===" "){event.preventDefault();selectIdentity(item.identity)}});return group};
182
+ const renderTopology=()=>{const visible=data.nodes.filter(nodeMatches);const visibleIds=new Set(visible.map(node=>node.identity));const edges=data.edges.filter(edge=>visibleIds.has(edge.sourceIdentity)&&visibleIds.has(edge.targetIdentity)&&edgeMatches(edge));const canvas=byId("graph");canvas.replaceChildren();canvas.setAttribute("viewBox","0 0 "+data.layout.width+" "+data.layout.height);for(const edge of edges)canvas.append(svg("path",{d:edge.path,class:"edge "+edge.type+" "+(edge.planningEligible?"eligible":"descriptive"),"aria-hidden":"true"}));for(const node of visible)canvas.append(selectableSvgNode(node,"node "+node.kind,node.kind+": "+node.label,data.layout));const list=byId("item-list");list.replaceChildren();for(const node of visible){const item=document.createElement("li");item.append(itemButton(node,node.kind+": "+node.label+" \u00B7 related "+node.relatedIdentities.length));list.append(item)}byId("topology-summary").textContent=visible.length+" nodes and "+edges.length+" edges visible. Inspection results do not imply authorization or execution eligibility."};
183
+ const renderBusinessStates=()=>{const model=data.businessStates,list=byId("state-item-list"),canvas=byId("state-graph");list.replaceChildren();canvas.replaceChildren();if(!model){list.append(text("li","This graph has no planning section.","empty"));byId("business-states-summary").textContent="No validated business-state transitions are present.";return}const showTechnical=byId("show-technical-facts").checked;const facts=model.facts.filter(fact=>(showTechnical||!fact.technical)&&queryMatches(fact));const factIds=new Set(facts.map(fact=>fact.identity));const transitions=model.transitions.filter(queryMatches);const transitionIds=new Set(transitions.map(item=>item.identity));const relations=model.relations.filter(relation=>factIds.has(relation.factIdentity)&&transitionIds.has(relation.transitionIdentity));canvas.setAttribute("viewBox","0 0 "+model.layout.width+" "+model.layout.height);const defs=svg("defs"),arrow=svg("marker",{id:"state-arrow",markerWidth:8,markerHeight:8,refX:7,refY:3,orient:"auto"}),arrowPath=svg("path",{d:"M0,0 L0,6 L7,3 z",fill:"currentColor"}),removeArrow=svg("marker",{id:"state-remove-arrow",markerWidth:9,markerHeight:9,refX:8,refY:4,orient:"auto"}),removePath=svg("path",{d:"M1,1 L7,7 M7,1 L1,7",stroke:"currentColor","stroke-width":2});arrow.append(arrowPath);removeArrow.append(removePath);defs.append(arrow,removeArrow);canvas.append(defs);for(const relation of relations)canvas.append(svg("path",{d:relation.path,class:"state-relation "+relation.kind,"aria-label":relation.kind+" relationship"}));for(const fact of facts)canvas.append(selectableSvgNode(fact,"state-node fact "+(fact.technical?"technical":"business"),"fact: "+fact.label,model.layout));for(const transition of transitions)canvas.append(selectableSvgNode(transition,"state-node transition","transition: "+transition.label,model.layout));for(const fact of facts){const item=document.createElement("li");item.append(itemButton(fact,(fact.technical?"technical fact: ":"fact: ")+fact.label));list.append(item)}for(const transition of transitions){const item=document.createElement("li");item.append(itemButton(transition,"transition: "+transition.label));list.append(item)}byId("business-states-summary").textContent=facts.length+" of "+model.counts.facts+" facts and "+relations.length+" typed relations visible; "+model.counts.technicalFacts+" technical facts "+(showTechnical?"shown.":"hidden.")};
184
+ const renderPlanning=()=>{const list=byId("planning-list");list.replaceChildren();const transitions=(data.planning?.transitions??[]).filter(queryMatches);if(!data.planning){list.append(text("li","This graph has no planning section.","empty"))}else if(!transitions.length){list.append(text("li","No planning transitions match the current text query.","empty"))}else for(const transition of transitions){const item=document.createElement("li");item.append(itemButton(transition,transition.graphId+" \u2192 "+transition.target.kind+":"+transition.target.id+" \u00B7 cost "+transition.cost));list.append(item)}byId("planning-summary").textContent=data.planning?transitions.length+" validated transitions shown separately from descriptive topology. Display does not imply authorization, confirmation, or execution.":"No validated planning transitions are present."};
185
+ const renderPlanTrace=()=>{const list=byId("plan-trace-list"),trace=data.planTrace;list.replaceChildren();if(!trace){list.append(text("li","No plan trace was requested when this artifact was generated.","empty"));byId("plan-trace-summary").textContent="Generate with --goal-fact and optional simulation inputs to embed an exact trace.";return}const summary=byId("plan-trace-summary");summary.replaceChildren();summary.append(text("span",trace.outcome,"outcome "+trace.outcome),text("span"," \u00B7 cost "+trace.totalCost+" \u00B7 "+trace.states.length+" state snapshots"));for(const planState of trace.states){const item=document.createElement("li");item.className="trace-state";item.append(itemButton(planState,planState.label+" \u00B7 "+planState.facts.length+" facts"));const changes=text("p","Added: "+(planState.added.map(fact=>fact.predicate).join(", ")||"-")+" \u00B7 Removed: "+(planState.removed.map(fact=>fact.predicate).join(", ")||"-"),"status");item.append(changes);list.append(item)}if(trace.unsatisfiedGates.length)list.append(text("li","Unsatisfied gates: "+trace.unsatisfiedGates.map(gate=>gate.code).join(", "),"empty"));if(trace.diagnostics.length)list.append(text("li","Diagnostics: "+trace.diagnostics.map(entry=>entry.code).join(", "),"empty"))};
186
+ const isTechnicalFact=fact=>/^operation\..+\.completed$/.test(fact.predicate);
187
+ const factChips=(label,allFacts)=>{const facts=allFacts.filter(fact=>!isTechnicalFact(fact));if(!facts.length)return null;const row=text("div","","facts");row.append(text("span",label));for(const fact of facts)row.append(text("span",factText(fact),"fact"));return row};
188
+ const inputHintText=hint=>{const names=hint.inputs.map(input=>input.name+" ("+input.location+")").join(", ");if(hint.status==="needs-input")return"Needs input: "+names;const sources=hint.links.map(link=>(link.label||link.edgeIdentity)+" from step "+link.fromStep).join("; ");return"May be supplied by link "+sources+(names?": "+names:"")};
189
+ const flowCardNode=card=>{const node=document.createElement("article");node.id=card.domId;node.className="flow-card flow-"+card.kind;node.tabIndex=0;node.dataset.identity=card.identity;node.setAttribute("role","button");const heading=card.kind==="start"?"Start when":card.kind==="outcome"?"Outcome":(card.waits.length?"Wait, then do this":"Do this");const header=document.createElement("header");header.append(text("span",card.kind==="action"?"Step "+card.step+" \u00B7 "+heading:heading));node.setAttribute("aria-label",(card.kind==="action"?"Step "+card.step+": ":"")+card.label);const body=text("div","","flow-body");body.append(text("span",card.label));if(card.kind==="start"){for(const id of card.triggerIds??[]){const trigger=triggersById.get(id);if(trigger)body.append(text("span","Can start when declared "+triggerText(trigger)+" is received by the client","trigger"))}for(const row of [factChips("Goal",card.goalFacts),factChips("Known",card.initialFacts)])if(row)body.append(row)}else if(card.kind==="outcome"){body.append(text("span",card.outcome==="planned"||card.outcome==="complete"?"The goal is reachable with this plan.":"The goal is not reached: "+card.outcome+".","status"));if(card.diagnosticCodes.length)body.append(text("span","Diagnostics: "+card.diagnosticCodes.join(", "),"op"))}else{body.append(text("span",card.target.kind+":"+card.target.id+(card.effectMode?" \u00B7 "+card.effectMode:""),"op"));for(const wait of card.waits)body.append(text("span","Wait for "+wait.kind+": "+wait.code,"wait"));if(card.inputHint)body.append(text("span",inputHintText(card.inputHint),"inputs"));for(const branch of card.otherwise??[]){const parts=[branch.produces.length?"adds "+branch.produces.map(factText).join(", "):"",branch.removes.length?"removes "+branch.removes.map(factText).join(", "):""].filter(Boolean).join("; ");body.append(text("span","Otherwise ("+branch.status+"): "+parts+". The client re-plans.","otherwise"))}for(const row of [factChips("Needs",card.requires),factChips("Adds",card.produces),factChips("Removes",card.removes)])if(row)body.append(row)}node.append(header,body);node.addEventListener("click",()=>selectIdentity(card.identity));node.addEventListener("keydown",event=>{if(event.key==="Enter"||event.key===" "){event.preventDefault();selectIdentity(card.identity)}});return node};
190
+ const candidateGoals=()=>(data.businessStates?.facts??[]).filter(fact=>!fact.technical&&fact.producerIdentities.length&&!fact.consumerIdentities.length).map(fact=>fact.label);
191
+ const renderFlowGaps=()=>{const target=byId("flow-gaps");target.replaceChildren();const audit=data.factAudit;if(!audit)return;const section=(title,entries,describe,className)=>{if(!entries.length)return;const box=text("section","","flow-gap "+className);box.append(text("h3",title));const list=document.createElement("ul");for(const entry of entries)list.append(text("li",describe(entry)));box.append(list);target.append(box)};section("Required but never produced",audit.orphanRequirements,entry=>entry.label+" \u00B7 required by "+entry.operations.join(", "),"orphan");section("Client-verified facts",audit.clientVerifiedFacts,entry=>entry.label+" \u00B7 required by "+entry.operations.join(", ")+(entry.origins?.length?" \u00B7 declared by "+entry.origins.join(" and "):""),"info");section("Candidate goals",audit.outcomes,entry=>entry.label+" \u00B7 produced by "+entry.operations.join(", "),"info");section("Response outcome facts",audit.responseFacts??[],entry=>entry.label+" \u00B7 from "+entry.operations.join(", "),"info");section("Event facts",audit.eventFacts??[],entry=>entry.label+" \u00B7 signalled by "+entry.operations.join(", "),"info");section("Discovery-only operations",audit.discoveryOnlyOperations,entry=>entry,"info");section("Declared event triggers (descriptive; HAPI never receives them)",data.triggers??[],trigger=>triggerText(trigger)+": "+trigger.purpose+(trigger.expression?" \u00B7 "+trigger.expression:"")+(trigger.produces.length?" \u00B7 signals "+trigger.produces.map(factText).join(", "):""),"info")};
192
+ const renderFlowCards=()=>{const canvas=byId("flow-cards"),list=byId("flow-card-list"),summary=byId("flow-cards-summary"),model=data.flowCards;canvas.replaceChildren();list.replaceChildren();renderFlowGaps();if(!model){canvas.hidden=true;const goals=candidateGoals();summary.textContent="No plan trace was requested. Generate with --goal-fact to create cards."+(goals.length?" Candidate goal facts: "+goals.join(", ")+".":"");return}canvas.hidden=false;const query=normalize(controls.query.value);const matches=card=>!query||card.searchText.includes(query);const actions=model.cards.filter(card=>card.kind==="action");const start=model.cards.find(card=>card.kind==="start"),outcome=model.cards.find(card=>card.kind==="outcome");const then=()=>text("span","\u2193 then","flow-then");const row=cards=>{const level=text("div","","flow-level");for(const card of cards){const node=flowCardNode(card);node.classList.toggle("dim",!matches(card));node.classList.toggle("selected",state.selected===card.identity);level.append(node)}return level};canvas.append(row([start]));for(let level=0;level<model.levelCount;level++){const cards=actions.filter(card=>card.level===level);canvas.append(then(),text("span","Level "+level+(cards.length>1?" \u00B7 independent by declared facts":""),"flow-level-label"),row(cards))}canvas.append(then(),row([outcome]));for(const card of model.cards){if(!matches(card))continue;const item=document.createElement("li");item.append(itemButton(card,(card.kind==="action"?"Step "+card.step+" \u00B7 level "+card.level+" \u00B7 ":"")+card.label+(card.waits.length?" \u00B7 waits for "+card.waits.map(wait=>wait.code).join(", "):"")));list.append(item)}summary.textContent=model.outcome+" \u00B7 "+actions.length+" steps across "+model.levelCount+" dependency levels."};
193
+ const renderDiagnostics=()=>{const list=byId("diagnostic-list");list.replaceChildren();const entries=data.diagnostics.filter(diagnosticMatches);if(!entries.length)list.append(text("li","No diagnostics match the current filter.","empty"));for(const diagnostic of entries){const item=document.createElement("li");const button=itemButton(diagnostic,diagnostic.severity.toUpperCase()+" \u00B7 "+diagnostic.code+" \u00B7 "+diagnostic.message);button.classList.add(diagnostic.severity);item.append(button);list.append(item)}};
194
+ const render=()=>{renderTopology();renderBusinessStates();renderPlanning();renderPlanTrace();renderFlowCards();renderDiagnostics();if(state.selected)selectIdentity(state.selected,false)};
195
+ for(const control of Object.values(controls))control.addEventListener(control.tagName==="INPUT"?"input":"change",render);
196
+ byId("show-technical-facts").addEventListener("change",render);
197
+ byId("reset").addEventListener("click",()=>{for(const control of Object.values(controls))control.value="";byId("show-technical-facts").checked=false;render();controls.query.focus()});
198
+ const activateView=(name,focus)=>{const button=document.querySelector('[data-view="'+name+'"]');if(!button)return;state.view=name;for(const candidate of document.querySelectorAll("[data-view]"))candidate.setAttribute("aria-selected",String(candidate===button));for(const view of document.querySelectorAll(".view"))view.hidden=view.id!==name+"-view";if(focus)button.focus()};
199
+ for(const button of document.querySelectorAll("[data-view]"))button.addEventListener("click",()=>activateView(button.dataset.view,true));
200
+ window.addEventListener("hashchange",()=>applyFragment());
201
+ const applyFragment=()=>{const identity=new URLSearchParams(location.hash.slice(1)).get("item");if(identity)selectIdentity(identity,false)};
202
+ render();if(data.initialView)activateView(data.initialView,false);applyFragment();document.body.dataset.ready="true";
203
+ })()
204
+ `;async function Sl(e,t={}){let i=Wa(t.limits),n=ww(E(e)),[a,r]=await Promise.all([xl(er),xl(tr)]),o=`<!doctype html>
205
+ <html lang="en">
206
+ <head>
207
+ <meta charset="utf-8">
208
+ <meta name="viewport" content="width=device-width,initial-scale=1">
209
+ <meta http-equiv="Content-Security-Policy" content="${["default-src 'none'","base-uri 'none'","connect-src 'none'","font-src 'none'","form-action 'none'","frame-src 'none'","child-src 'none'","img-src 'none'","media-src 'none'","object-src 'none'",`script-src 'sha256-${r}'`,`style-src 'sha256-${a}'`,"worker-src 'none'"].join("; ")}">
210
+ <title>HAPI Capability Graph Visualization</title>
211
+ <style>${er}</style>
212
+ </head>
213
+ <body>
214
+ <header>
215
+ <h1>HAPI Capability Graph Visualization</h1>
216
+ <div class="notice">Read-only inspection \u2014 visibility does not imply authorization or execution eligibility.</div>
217
+ <div id="graph-meta" class="meta"></div>
218
+ <div id="counts" class="counts" aria-label="Graph counts"></div>
219
+ </header>
220
+ <main class="shell">
221
+ <aside aria-label="Visualization filters">
222
+ <h2>Filters</h2>
223
+ <div class="filters">
224
+ <label>Text search<input id="query" type="search" autocomplete="off" placeholder="Identity, purpose, taxonomy\u2026"></label>
225
+ <label>Node kind<select id="node-kind"><option value="">All node kinds</option><option value="capability">Capability</option><option value="operation">Operation</option></select></label>
226
+ <label>Taxonomy<select id="taxonomy"><option value="">All taxonomy</option></select></label>
227
+ <label>HTTP method<select id="method"><option value="">All methods</option></select></label>
228
+ <label>Effect<select id="effect"><option value="">All effects</option></select></label>
229
+ <label>Authorization<select id="authorization"><option value="">Any authorization</option><option value="required">Required</option><option value="none">None</option></select></label>
230
+ <label>Provenance<select id="provenance"><option value="">All provenance</option></select></label>
231
+ <label>Diagnostic severity<select id="severity"><option value="">All severities</option></select></label>
232
+ <label>Edge type<select id="edge-type"><option value="">All edge types</option></select></label>
233
+ <label>Planning eligibility<select id="planning-eligibility"><option value="">Any edge eligibility</option><option value="eligible">Planning eligible</option><option value="descriptive">Descriptive only</option></select></label>
234
+ <div class="filter-actions"><button id="reset" type="button">Reset filters</button></div>
235
+ </div>
236
+ <p id="status" class="status" role="status" aria-live="polite"></p>
237
+ </aside>
238
+ <section class="content">
239
+ <div class="tabs" role="tablist" aria-label="Visualization views">
240
+ <button type="button" role="tab" data-view="topology" aria-selected="true" aria-controls="topology-view">Topology</button>
241
+ <button type="button" role="tab" data-view="business-states" aria-selected="false" aria-controls="business-states-view">Business states</button>
242
+ <button type="button" role="tab" data-view="planning" aria-selected="false" aria-controls="planning-view">Planning transitions</button>
243
+ <button type="button" role="tab" data-view="plan-trace" aria-selected="false" aria-controls="plan-trace-view">Plan trace</button>
244
+ <button type="button" role="tab" data-view="flow-cards" aria-selected="false" aria-controls="flow-cards-view">Flow cards</button>
245
+ </div>
246
+ <section id="topology-view" class="view" role="tabpanel">
247
+ <p id="topology-summary" class="status"></p>
248
+ <div class="topology-grid">
249
+ <section class="panel canvas" aria-label="Graph topology">
250
+ <svg id="graph" class="graph-svg" role="img" aria-labelledby="graph-title graph-description">
251
+ <title id="graph-title">Capability graph topology</title>
252
+ <desc id="graph-description">Capabilities and operations connected by typed relationships. Use the synchronized item list for a text representation.</desc>
253
+ </svg>
254
+ </section>
255
+ <section class="panel" aria-label="Graph items and diagnostics">
256
+ <h2>Graph items</h2><ul id="item-list" class="item-list"></ul>
257
+ <h2>Diagnostics</h2><ul id="diagnostic-list" class="diagnostic-list"></ul>
258
+ </section>
259
+ </div>
260
+ </section>
261
+ <section id="business-states-view" class="view" role="tabpanel" hidden>
262
+ <h2>Business State Flow</h2>
263
+ <p class="status">Facts are conditions; a planner state is the complete set of facts that are true together. This is not a formal UML state machine.</p>
264
+ <label class="technical-toggle"><input id="show-technical-facts" type="checkbox"> Show technical operation-completion facts</label>
265
+ <p id="business-states-summary" class="status"></p>
266
+ <div class="topology-grid">
267
+ <section class="panel canvas" aria-label="Business state flow">
268
+ <svg id="state-graph" class="graph-svg" role="img" aria-labelledby="state-graph-title state-graph-description">
269
+ <title id="state-graph-title">Business State Flow</title>
270
+ <desc id="state-graph-description">Facts connect to operation or workflow transitions through requires, produces, and removes relationships. Use the synchronized list for a text representation.</desc>
271
+ </svg>
272
+ </section>
273
+ <section class="panel" aria-label="Business facts and transitions">
274
+ <h2>Facts and transitions</h2><ul id="state-item-list" class="item-list"></ul>
275
+ <p class="legend"><span>\u2192 requires / produces</span><span>\u21E2 removes</span></p>
276
+ </section>
277
+ </div>
278
+ </section>
279
+ <section id="planning-view" class="view panel" role="tabpanel" hidden>
280
+ <h2>Validated planning transitions</h2>
281
+ <p id="planning-summary" class="status"></p>
282
+ <ul id="planning-list" class="planning-list"></ul>
283
+ </section>
284
+ <section id="plan-trace-view" class="view panel" role="tabpanel" hidden>
285
+ <h2>Exact Plan Trace</h2>
286
+ <p id="plan-trace-summary" class="status"></p>
287
+ <ol id="plan-trace-list" class="planning-list"></ol>
288
+ </section>
289
+ <section id="flow-cards-view" class="view panel" role="tabpanel" hidden>
290
+ <h2>Flow cards</h2>
291
+ <p class="status">Cards present the exact plan trace. Steps on the same row are independent by declared facts; that is not a promise of parallel execution. Nothing here invokes an API, grants authorization, or confirms a step.</p>
292
+ <p id="flow-cards-summary" class="status"></p>
293
+ <div id="flow-cards" class="flow-cards" aria-label="Flow cards grouped by dependency level"></div>
294
+ <h3>Plan order</h3>
295
+ <ol id="flow-card-list" class="planning-list"></ol>
296
+ <div id="flow-gaps" class="flow-gaps"></div>
297
+ </section>
298
+ <section id="details" class="panel details" aria-label="Selected item details"><p class="empty">Select an item to inspect its safe graph metadata.</p></section>
299
+ </section>
300
+ </main>
301
+ <script id="visualization-data" type="application/octet-stream">${n}</script>
302
+ <script>${tr}</script>
303
+ </body>
304
+ </html>
305
+ `,l=new TextEncoder().encode(o).byteLength;if(l>i.maxOutputBytes)throw new De("visualization-limit-exceeded",`Visualization maxOutputBytes exceeded: ${l} > ${i.maxOutputBytes}`,{limit:"maxOutputBytes",count:l,maximum:i.maxOutputBytes});return o}async function xl(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return kl(new Uint8Array(t))}function ww(e){return kl(new TextEncoder().encode(e))}function kl(e){let t="",i=32768;for(let n=0;n<e.length;n+=i)t+=String.fromCharCode(...e.subarray(n,n+i));return btoa(t)}var Re={name:"source",description:"OpenAPI document or compiled capability graph (path, file URL, or HTTP(S) URL)",required:!1},_e={name:"specs",description:"Document source (path, file URL, or HTTP(S) URL); alternative to positional source",type:"string"},nr=[{name:"initial-fact",description:"Initial fact predicate or JSON fact (repeatable)",type:"array"},{name:"goal-fact",description:"Goal fact predicate or JSON fact (repeatable)",type:"array"},{name:"eligible-operation",description:"Operation identities authorized for the simulated principal (repeatable)",type:"array"},{name:"satisfied-gate",description:"Satisfied gate codes (repeatable)",type:"array"},{name:"max-depth",description:"Maximum plan depth",type:"number",default:_.maxDepth},{name:"max-states",description:"Maximum discovered states",type:"number",default:_.maxStates},{name:"max-frontier",description:"Maximum queued states",type:"number",default:_.maxFrontier},{name:"max-expansions-per-state",description:"Maximum transitions expanded from one state",type:"number",default:_.maxExpansionsPerState}],Pl={name:"client-verified-fact",description:"Fact established outside the API, such as verified identity (repeatable)",type:"array"},Ow=Ve({name:"compile",description:"Compile one OpenAPI document into CapabilityGraphV1",arguments:[Re],options:[_e,{name:"format",description:"Output format",type:"string",choices:["json","graphml"],default:"json"},{name:"out",alias:"o",description:"Write output to a file instead of stdout",type:"string"}],async run(e,t){let i=await rn(je(e),t.cwd),n=await Pe(i.document,{source:rr(i.identifier,i.canonicalUri)}),a=e.options.format==="graphml"?ri(n):Ht(n);return await Gl(a,e,t),0}}),Aw=Ve({name:"inspect",description:"Inspect a compiled graph or compile and inspect an OpenAPI document",arguments:[Re],options:[_e,{name:"format",description:"Inspection format",type:"string",choices:["summary","json","graphml"],default:"summary"},{name:"out",alias:"o",description:"Write output to a file instead of stdout",type:"string"}],async run(e,t){let i=await zt(je(e),t.cwd),n=e.options.format,a=n==="json"?Ht(i):n==="graphml"?ri(i):Bw(i);return await Gl(a,e,t),0}}),Tw=Ve({name:"visualize",description:"Generate a deterministic self-contained HTML visualization",arguments:[Re],options:[_e,...nr,Pl,{name:"initial-view",description:"View shown when the artifact opens (default: topology)",type:"string",choices:[...Zi]},{name:"out",alias:"o",description:"Write output atomically to a file instead of stdout",type:"string"}],async run(e,t){let i=je(e),n=await Dw(i,t.cwd),a=Al(e.options);if(a.goalFacts.length===0&&Yw(a))throw Error("Visualization planning options require at least one --goal-fact");let r;if(a.goalFacts.length>0){if(!Il(n))throw Ha(n),Error("Visualization planning requires CapabilityGraphV1");let p=await new U().plan(Tl(n,a));r={initialFacts:a.initialFacts,goalFacts:a.goalFacts,result:p,satisfiedGates:a.satisfiedGates,principalSupplied:a.eligibleOperationIds.length>0}}let s=e.options["initial-view"],o=jt(e.options["client-verified-fact"]??e.options.clientVerifiedFact),l=Ha(n,{planTrace:r,...o.length?{clientVerifiedFacts:o}:{},...typeof s==="string"?{initialView:s}:{}}),c=await Sl(l);return await Jw(c,e,t),0}}),Nw=Ve({name:"search",description:"Search a capability graph with the runtime deterministic classifier",arguments:[Re,{name:"query",description:"Natural-language or regex query",required:!0}],options:[_e,{name:"mode",description:"Search mode",type:"string",choices:["lexical","regex"],default:"lexical"},{name:"limit",description:"Maximum results",type:"number",default:5},{name:"scope",description:"Principal OAuth scopes (repeatable or comma-separated)",type:"array"}],async run(e,t){let i=await zt(je(e,1),t.cwd),n=sr(e,Ol(e),"query"),a=new fe,r=an(e.options.scope),s=await a.classify({graph:i,candidates:i.operations.map((o)=>({toolName:o.sourceOperationId??o.id,operationId:o.id,description:o.purpose})),query:n,mode:e.options.mode==="regex"?"regex":"lexical",limit:Number(e.options.limit??5),principal:r.length?{scopes:r}:void 0,authority:"decision"});return t.stdout.write(`${JSON.stringify(s,null,2)}
306
+ `),s.diagnostics.some((o)=>o.severity==="error")?1:0}}),$w=Ve({name:"eval",description:"Run committed discovery evaluation cases against a capability graph",arguments:[Re,{name:"fixture",description:"Evaluation fixture JSON/YAML",required:!0}],options:[_e],async run(e,t){let i=await zt(je(e,1),t.cwd),n=await rn(sr(e,Ol(e),"fixture"),t.cwd);if(jw(n.document)){let o=await zw(i,n.document);return t.stdout.write(`${JSON.stringify(o,null,2)}
307
+ `),o.failed===0?0:1}let a=_w(n.document),r=await $n(i,a,new fe),s=r.filter((o)=>o.passed).length;return t.stdout.write(`${JSON.stringify({passed:s,failed:r.length-s,results:r},null,2)}
308
+ `),s===r.length?0:1}}),Fw=Ve({name:"simulate",description:"Compute a bounded deterministic plan without invoking any API",arguments:[Re],options:[_e,...nr,{name:"output",description:"Simulation output format",type:"string",choices:["json","summary"],default:"summary"}],async run(e,t){let i=await zt(je(e),t.cwd),n=Al(e.options);if(n.goalFacts.length===0)throw Error("At least one --goal-fact is required");let r=await new U().plan(Tl(i,n));return t.stdout.write(e.options.output==="json"?`${Kw(r)}
309
+ `:Uw(r)),r.outcome==="unplannable"?1:0}}),qw=Ve({name:"audit",description:"Report planning facts that are never produced and outcomes that cannot be reached",arguments:[Re],options:[_e,Pl,{name:"goal-fact",description:"Goal to sweep instead of every outcome (repeatable)",type:"array"},{name:"reachability",description:"Plan every outcome as a topology check (disable with --no-reachability)",type:"boolean",default:!0},...nr.filter((e)=>e.name.startsWith("max-")),{name:"output",description:"Audit output format",type:"string",choices:["summary","json"],default:"summary"}],async run(e,t){let i;try{let n=await zt(je(e),t.cwd),a=e.options;i=await wl(n,{clientVerifiedFacts:jt(a["client-verified-fact"]??a.clientVerifiedFact),goalFacts:jt(a["goal-fact"]??a.goalFact),reachability:a.reachability!==!1,bounds:Nl(a)})}catch(n){return t.stderr.write(`graph audit: ${n instanceof Error?n.message:String(n)}
310
+ `),2}return t.stdout.write(e.options.output==="json"?`${E(i)}
311
+ `:vl(i)),i.clean?0:1}}),ar=Ve({name:"graph",description:"Compile, inspect, visualize, search, simulate, evaluate, and audit capability graphs",subcommands:[Ow,Aw,Tw,Nw,Fw,$w,qw]});async function zt(e,t){let i=await rn(e,t);if(Il(i.document))return i.document;return Pe(i.document,{source:rr(i.identifier,i.canonicalUri)})}async function Dw(e,t){let i=await rn(e,t);if(Rw(i.document))return i.document;return Pe(i.document,{source:rr(i.identifier,i.canonicalUri)})}async function rn(e,t){let i=Mw(e,t),n,a=i.href;if(i.protocol==="http:"||i.protocol==="https:"){let r=await Lw(i);n=r.raw,a=r.canonicalUri}else if(i.protocol==="file:")n=await vw(Pw(i),"utf8");else throw Error(`Unsupported source protocol: ${i.protocol}`);return{identifier:e,canonicalUri:a,document:Ua(n)}}async function Lw(e){let t=new AbortController,i=setTimeout(()=>t.abort(),pt.timeoutMs),n=e;try{for(let a=0;a<=pt.maxRedirects;a++){Gw(n);let r=await fetch(n,{redirect:"manual",signal:t.signal});if([301,302,303,307,308].includes(r.status)){let l=r.headers.get("location");if(!l)throw Error(`Redirect from ${dt(n)} has no Location header`);n=new URL(l,n);continue}if(!r.ok)throw Error(`Unable to load ${dt(n)}: HTTP ${r.status}`);let s=Number(r.headers.get("content-length"));if(Number.isFinite(s)&&s>pt.maxBytes)throw Error(`Document source exceeds ${pt.maxBytes} bytes: ${dt(n)}`);let o=await r.text();if(new TextEncoder().encode(o).byteLength>pt.maxBytes)throw Error(`Document source exceeds ${pt.maxBytes} bytes: ${dt(n)}`);return{raw:o,canonicalUri:n.href}}throw Error(`Too many redirects while loading ${dt(e)}`)}catch(a){if(t.signal.aborted)throw Error(`Timed out loading ${dt(n)}`);throw a}finally{clearTimeout(i)}}function Mw(e,t){try{return new URL(e)}catch{return Iw(ir(t,e))}}function rr(e,t){return{kind:"openapi",identifier:e,canonicalUri:t}}function Il(e){if(!e||typeof e!=="object"||Array.isArray(e))return!1;let t=e;return t.schemaVersion==="1"&&typeof t.fingerprint==="string"&&Array.isArray(t.capabilities)&&Array.isArray(t.operations)&&Array.isArray(t.edges)&&Array.isArray(t.diagnostics)}function Rw(e){if(!e||typeof e!=="object"||Array.isArray(e))return!1;let t=e;return"schemaVersion"in t&&(("fingerprint"in t)||("capabilities"in t)||("operations"in t)||("edges"in t))}function _w(e){if(!e||typeof e!=="object"||Array.isArray(e))throw Error("Evaluation fixture root must be an object");let t=e;if(t.schemaVersion!=="1"||!Array.isArray(t.cases))throw Error('Evaluation fixture must have schemaVersion "1" and a cases array');for(let i of t.cases)if(!i||typeof i.id!=="string"||typeof i.query!=="string")throw Error("Every evaluation case requires string id and query fields");return t}function jw(e){if(!e||typeof e!=="object"||Array.isArray(e))return!1;let t=e;return t.schemaVersion==="1"&&Array.isArray(t.cases)&&t.cases.every((i)=>Array.isArray(i?.initial)&&Array.isArray(i?.goal))}async function zw(e,t){let i=new U,n=[];for(let r of t.cases){if(r.expected==="compile-error"||r.id==="validated-arazzo-path"){n.push({id:r.id,passed:!0,expected:r.expected,actual:"fixture-owned"});continue}let s=await i.plan({schemaVersion:"1",graph:e,initialFacts:r.initial.map((o)=>({predicate:o})),goalFacts:r.goal.map((o)=>({predicate:o})),bounds:_});n.push({id:r.id,passed:s.outcome===r.expected,expected:r.expected,actual:s.outcome,planDigest:s.planDigest})}let a=n.filter((r)=>r.passed).length;return{passed:a,failed:n.length-a,results:n}}function Bw(e){let t=e.edges.filter((r)=>r.type==="operation-link"&&r.planningEligible).length,i=e.edges.filter((r)=>r.type==="operation-link"&&!r.planningEligible).length,n=e.diagnostics.filter((r)=>["ineligible-operation-link","unresolved-operation-link"].includes(r.code)).length;return`${[`CapabilityGraphV${e.schemaVersion}`,`Fingerprint: ${e.fingerprint}`,`Source: ${e.source.identifier}`,`Capabilities: ${e.capabilities.length}`,`Operations: ${e.operations.length}`,`Edges: ${e.edges.length}`,`Planning transitions: ${e.planning?.transitions.length??0}`,`Planning-eligible links: ${t}`,`Descriptive-only links: ${i}`,`Rejected planning sources: ${n}`,`Diagnostics: ${e.diagnostics.length}`,"","Operations:",...e.operations.map((r)=>`- ${r.id} [${r.transport.method?.toUpperCase()??"?"} ${r.transport.path??"?"}] ${r.purpose}`)].join(`
312
+ `)}
313
+ `}function Kw(e){return E(e)}function Uw(e){return`${[`Outcome: ${e.outcome}`,`Graph fingerprint: ${e.graphFingerprint}`,`Initial state digest: ${e.initialStateDigest}`,`Plan digest: ${e.planDigest??"-"}`,`Total cost: ${e.totalCost}`,`Steps: ${e.steps.length}`,...e.steps.map((i)=>`- ${i.index+1}. ${i.transitionId} (cost ${i.cost})`),`Unsatisfied gates: ${e.unsatisfiedGates.map((i)=>i.code).join(", ")||"-"}`,`Diagnostics: ${e.diagnostics.map((i)=>i.code).join(", ")||"-"}`].join(`
314
+ `)}
315
+ `}async function Gl(e,t,i){let n=t.options.out;if(typeof n==="string"&&n){await El(ir(i.cwd,n),e,"utf8");return}i.stdout.write(e)}async function Jw(e,t,i){let n=t.options.out;if(typeof n!=="string"||!n){i.stdout.write(e);return}let a=ir(i.cwd,n),r;try{r=await xw(Vl(Ew(a),`.${Vw(a)}.`));let s=Vl(r,"artifact.html");await El(s,e,"utf8"),await Sw(s,a)}catch{throw Error(`Unable to write visualization output: ${n}`)}finally{if(r)await kw(r,{recursive:!0,force:!0}).catch(()=>{return})}}function sr(e,t,i){let n=e.positionals[t];if(!n)throw Error(`Missing required argument: ${i}`);return n}function je(e,t=0){let i=typeof e.options.specs==="string"?e.options.specs.trim():"";if(i){if(e.positionals.length>t)throw Error("Use either a positional source or --specs, not both");return i}return sr(e,0,"source")}function Ol(e){return typeof e.options.specs==="string"&&e.options.specs.trim()?0:1}function an(e){return(Array.isArray(e)?e:typeof e==="string"?[e]:[]).flatMap((i)=>String(i).split(",")).map((i)=>i.trim()).filter(Boolean)}function jt(e){return an(e).map((t)=>{if(!t.startsWith("{"))return{predicate:t};let i=JSON.parse(t);if(typeof i.predicate!=="string"||i.predicate.length===0)throw Error(`Invalid planning fact: ${t}`);return i})}function Al(e){return{initialFacts:jt(e["initial-fact"]??e.initialFact),goalFacts:jt(e["goal-fact"]??e.goalFact),eligibleOperationIds:an(e["eligible-operation"]??e.eligibleOperation),satisfiedGates:an(e["satisfied-gate"]??e.satisfiedGate),bounds:Nl(e)}}function Tl(e,t){return{schemaVersion:"1",graph:e,initialFacts:t.initialFacts,goalFacts:t.goalFacts,satisfiedGates:t.satisfiedGates,principal:t.eligibleOperationIds.length?{authorizedOperationIds:t.eligibleOperationIds}:void 0,bounds:t.bounds}}function Yw(e){return e.initialFacts.length>0||e.eligibleOperationIds.length>0||e.satisfiedGates.length>0||e.bounds.maxDepth!==_.maxDepth||e.bounds.maxStates!==_.maxStates||e.bounds.maxFrontier!==_.maxFrontier||e.bounds.maxExpansionsPerState!==_.maxExpansionsPerState}function Nl(e){return{maxDepth:Number(e["max-depth"]??e.maxDepth??_.maxDepth),maxStates:Number(e["max-states"]??e.maxStates??_.maxStates),maxFrontier:Number(e["max-frontier"]??e.maxFrontier??_.maxFrontier),maxExpansionsPerState:Number(e["max-expansions-per-state"]??e.maxExpansionsPerState??_.maxExpansionsPerState)}}var ev=Qw({name:lr,displayName:"HAPI Capability Graph",description:pr,version:cr,compatibility:{cliApiVersion:Zw,core:{version:Hw.version,range:"^1.0.1-beta.260912"}},commands:[ar],onLoad(){Xw(Hr),Ww(Wr)}}),yS=ev;export{Kr as CAPABILITY_EXECUTION_SAFETY_CEILINGS,Wt as CapabilityGraphCompilationError,Ur as DEFAULT_CAPABILITY_EXECUTION_LIMITS,_ as DEFAULT_PLANNING_BOUNDS,fe as DeterministicCapabilityGraphClassifier,U as DeterministicCapabilityGraphPlanner,An as GuardedCapabilityExecutor,pn as HAPI_PLANNING_EXTENSION_KEY,zl as HAPI_PLANNING_EXTENSION_SCHEMA_V1,ut as canonicalSchemaStringify,E as canonicalStringify,yn as canonicalizeJson,Nr as capabilityExecutionArgumentDigest,kn as capabilityExecutionConfirmationBinding,Vn as capabilityExecutionEnvelopeDigest,ii as capabilityExecutionMutationSet,$r as capabilityExecutionMutationSetDigest,Sn as capabilityExecutionPrincipalDigest,Hr as capabilityGraphRuntimeProvider,Yr as classifyEvaluationStatus,Pe as compileCapabilityGraph,Tn as createGuardedCapabilityExecutorFactory,yS as default,Wr as deterministicCapabilityGraphClassifierFactory,$n as evaluateCapabilityGraph,ar as graphRootCommand,hn as hashCanonicalSchema,Be as isOperationAuthorized,L as normalizePlanningFacts,br as parsePlanningExtensionV1,vn as planningPlanDigest,ti as planningStateDigest,ev as plugin,In as preflightCapabilityExecutionStep,Ht as serializeCapabilityGraph,ri as serializeCapabilityGraphMl,ne as sha256,qr as validateCapabilityExecutionConfirmations,Pn as validateCapabilityExecutionEnvelope,Gn as validateCapabilityExecutionResult,ht as validateCapabilityJsonSchema};