rapidoc 12.0.0 → 12.1.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/README.md +127 -25
- package/dist/rapidoc-flow-min.js +580 -0
- package/dist/rapidoc-flow-min.js.LICENSE.txt +171 -0
- package/dist/rapidoc-min.js +541 -1309
- package/dist/rapidoc-min.js.LICENSE.txt +381 -0
- package/package.json +21 -18
- package/src/README.md +150 -0
- package/src/components/README.md +91 -0
- package/src/components/api-request.ts +43 -0
- package/src/components/api-response.ts +9 -4
- package/src/components/schema-base-element.ts +18 -4
- package/src/components/schema-table.ts +58 -13
- package/src/components/schema-tree.ts +7 -0
- package/src/components/tag-input.ts +5 -9
- package/src/flow.js +3 -0
- package/src/rapi-flow.ts +1178 -0
- package/src/rapidoc-mini.ts +27 -6
- package/src/rapidoc.ts +108 -62
- package/src/styles/README.md +96 -0
- package/src/styles/css-bundle.js +2 -2
- package/src/styles/endpoint-styles.js +6 -1
- package/src/styles/flow-styles.js +248 -0
- package/src/styles/nav-styles.js +39 -15
- package/src/styles/schema-styles.js +13 -5
- package/src/styles/theme-tokens.js +2 -2
- package/src/templates/README.md +89 -0
- package/src/templates/api-response-template.js +14 -10
- package/src/templates/callback-template.js +1 -1
- package/src/templates/downloads-template.js +12 -27
- package/src/templates/endpoint-template.js +15 -24
- package/src/templates/expanded-endpoint-template.js +8 -4
- package/src/templates/focused-endpoint-template.js +4 -3
- package/src/templates/navbar-template.js +20 -11
- package/src/templates/request-body-template.js +29 -7
- package/src/templates/request-params-template.js +15 -4
- package/src/templates/security-scheme-template.js +11 -2
- package/src/templates/server-template.js +3 -2
- package/src/utils/README.md +146 -0
- package/src/utils/arazzo/README.md +119 -0
- package/src/utils/arazzo/components.js +15 -0
- package/src/utils/arazzo/graph.js +269 -0
- package/src/utils/arazzo/index.js +52 -0
- package/src/utils/arazzo/operations.js +106 -0
- package/src/utils/arazzo/parse.js +196 -0
- package/src/utils/arazzo/refs.js +40 -0
- package/src/utils/arazzo/svg.js +707 -0
- package/src/utils/curl-utils.js +5 -2
- package/src/utils/highlighter.js +3 -0
- package/src/utils/mcp/README.md +155 -0
- package/src/utils/mcp/common.js +45 -346
- package/src/utils/mcp/manifest.js +382 -0
- package/src/utils/mcp/project/server.ts +53 -0
- package/src/utils/mcp/project.js +88 -0
- package/src/utils/mcp/runtime.js +289 -0
- package/src/utils/mcp/schema.js +98 -0
- package/src/utils/mcp/workflow-runtime.js +374 -0
- package/src/utils/mcp/workflows.js +240 -0
- package/src/utils/mcp/zip.js +102 -0
- package/src/utils/mcp-generator.js +29 -125
- package/src/utils/mock-interceptor.js +134 -85
- package/src/utils/request-utils.js +61 -0
- package/src/utils/schema-utils.js +33 -6
- package/src/utils/slugger.js +5 -7
- package/src/utils/spec-parser.js +190 -164
- package/src/utils/url-utils.js +36 -1
- package/dist/rapidoc-static-min.js +0 -13542
- package/src/static/index.d.ts +0 -149
- package/src/static/index.js +0 -62
- package/src/static/navigation.js +0 -497
- package/src/static/render.js +0 -490
- package/src/static/serializer.js +0 -216
- package/src/utils/mcp/generators/csharp.js +0 -242
- package/src/utils/mcp/generators/go.js +0 -298
- package/src/utils/mcp/generators/java.js +0 -330
- package/src/utils/mcp/generators/python.js +0 -248
- package/src/utils/mcp/generators/rust.js +0 -281
- package/src/utils/mcp/generators/typescript.js +0 -290
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @license
|
|
3
|
+
* rapidoc v12.1.0
|
|
4
|
+
* (c) 2026 Mrinmoy Majumdar <mrin9@yahoo.com>
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
* Bundled third-party code and its licenses: rapidoc-flow-min.js.LICENSE.txt
|
|
7
|
+
*/
|
|
8
|
+
var gt=globalThis,Yt=gt.ShadowRoot&&(gt.ShadyCSS===void 0||gt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Qt=Symbol(),Dr=new WeakMap,Ur=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==Qt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(Yt&&e===void 0){let r=t!==void 0&&t.length===1;r&&(e=Dr.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Dr.set(t,e))}return e}toString(){return this.cssText}},zr=e=>new Ur(typeof e=="string"?e:e+"",void 0,Qt),Xt=(e,...t)=>new Ur(e.length===1?e[0]:t.reduce((r,s,n)=>r+(i=>{if(i._$cssResult$===!0)return i.cssText;if(typeof i=="number")return i;throw Error("Value passed to 'css' function must be a 'css' function result: "+i+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]),e,Qt),Pn=(e,t)=>{if(Yt)e.adoptedStyleSheets=t.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(let r of t){let s=document.createElement("style"),n=gt.litNonce;n!==void 0&&s.setAttribute("nonce",n),s.textContent=r.cssText,e.appendChild(s)}},Kr=Yt?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let r="";for(let s of t.cssRules)r+=s.cssText;return zr(r)})(e):e,{is:Rn,defineProperty:Bn,getOwnPropertyDescriptor:Dn,getOwnPropertyNames:Un,getOwnPropertySymbols:zn,getPrototypeOf:Kn}=Object,yt=globalThis,Hr=yt.trustedTypes,Hn=Hr?Hr.emptyScript:"",Fn=yt.reactiveElementPolyfillSupport,Xe=(e,t)=>e,bt={toAttribute(e,t){switch(t){case Boolean:e=e?Hn:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=e!==null;break;case Number:r=e===null?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch{r=null}}return r}},Zt=(e,t)=>!Rn(e,t),Fr={attribute:!0,type:String,converter:bt,reflect:!1,useDefault:!1,hasChanged:Zt};Symbol.metadata??=Symbol("metadata"),yt.litPropertyMetadata??=new WeakMap;var Te=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Fr){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let r=Symbol(),s=this.getPropertyDescriptor(e,r,t);s!==void 0&&Bn(this.prototype,e,s)}}static getPropertyDescriptor(e,t,r){let{get:s,set:n}=Dn(this.prototype,e)??{get(){return this[t]},set(i){this[t]=i}};return{get:s,set(i){let o=s?.call(this);n?.call(this,i),this.requestUpdate(e,o,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Fr}static _$Ei(){if(this.hasOwnProperty(Xe("elementProperties")))return;let e=Kn(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Xe("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Xe("properties"))){let t=this.properties,r=[...Un(t),...zn(t)];for(let s of r)this.createProperty(s,t[s])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[r,s]of t)this.elementProperties.set(r,s)}this._$Eh=new Map;for(let[t,r]of this.elementProperties){let s=this._$Eu(t,r);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let s of r)t.unshift(Kr(s))}else e!==void 0&&t.push(Kr(e));return t}static _$Eu(e,t){let r=t.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let r of t.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Pn(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$ET(e,t){let r=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,r);if(s!==void 0&&r.reflect===!0){let n=(r.converter?.toAttribute===void 0?bt:r.converter).toAttribute(t,r.type);this._$Em=e,n==null?this.removeAttribute(s):this.setAttribute(s,n),this._$Em=null}}_$AK(e,t){let r=this.constructor,s=r._$Eh.get(e);if(s!==void 0&&this._$Em!==s){let n=r.getPropertyOptions(s),i=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute===void 0?bt:n.converter;this._$Em=s;let o=i.fromAttribute(t,n.type);this[s]=o??this._$Ej?.get(s)??o,this._$Em=null}}requestUpdate(e,t,r,s=!1,n){if(e!==void 0){let i=this.constructor;if(s===!1&&(n=this[e]),r??=i.getPropertyOptions(e),!((r.hasChanged??Zt)(n,t)||r.useDefault&&r.reflect&&n===this._$Ej?.get(e)&&!this.hasAttribute(i._$Eu(e,r))))return;this.C(e,t,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:r,reflect:s,wrapped:n},i){r&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,i??t??this[e]),n!==!0||i!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[s,n]of this._$Ep)this[s]=n;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[s,n]of r){let{wrapped:i}=n,o=this[s];i!==!0||this._$AL.has(s)||o===void 0||this.C(s,void 0,n,o)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(t)):this._$EM()}catch(r){throw e=!1,this._$EM(),r}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};Te.elementStyles=[],Te.shadowRootOptions={mode:"open"},Te[Xe("elementProperties")]=new Map,Te[Xe("finalized")]=new Map,Fn?.({ReactiveElement:Te}),(yt.reactiveElementVersions??=[]).push("2.1.2");var er=globalThis,Wr=e=>e,wt=er.trustedTypes,Vr=wt?wt.createPolicy("lit-html",{createHTML:e=>e}):void 0,Jr="$lit$",be=`lit$${Math.random().toFixed(9).slice(2)}$`,Gr="?"+be,Wn=`<${Gr}>`,$e=document,Ze=()=>$e.createComment(""),et=e=>e===null||typeof e!="object"&&typeof e!="function",tr=Array.isArray,Vn=e=>tr(e)||typeof e?.[Symbol.iterator]=="function",rr=`[
|
|
9
|
+
\f\r]`,tt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Yr=/-->/g,Qr=/>/g,xe=RegExp(`>|${rr}(?:([^\\s"'>=/]+)(${rr}*=${rr}*(?:[^
|
|
10
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),Xr=/'/g,Zr=/"/g,es=/^(?:script|style|textarea|title)$/i,E=(e=>(t,...r)=>({_$litType$:e,strings:t,values:r}))(1),Se=Symbol.for("lit-noChange"),C=Symbol.for("lit-nothing"),ts=new WeakMap,Ae=$e.createTreeWalker($e,129);function rs(e,t){if(!tr(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Vr===void 0?t:Vr.createHTML(t)}var Jn=(e,t)=>{let r=e.length-1,s=[],n,i=t===2?"<svg>":t===3?"<math>":"",o=tt;for(let a=0;a<r;a++){let l=e[a],c,f,u=-1,d=0;for(;d<l.length&&(o.lastIndex=d,f=o.exec(l),f!==null);)d=o.lastIndex,o===tt?f[1]==="!--"?o=Yr:f[1]===void 0?f[2]===void 0?f[3]!==void 0&&(o=xe):(es.test(f[2])&&(n=RegExp("</"+f[2],"g")),o=xe):o=Qr:o===xe?f[0]===">"?(o=n??tt,u=-1):f[1]===void 0?u=-2:(u=o.lastIndex-f[2].length,c=f[1],o=f[3]===void 0?xe:f[3]==='"'?Zr:Xr):o===Zr||o===Xr?o=xe:o===Yr||o===Qr?o=tt:(o=xe,n=void 0);let y=o===xe&&e[a+1].startsWith("/>")?" ":"";i+=o===tt?l+Wn:u>=0?(s.push(c),l.slice(0,u)+Jr+l.slice(u)+be+y):l+be+(u===-2?a:y)}return[rs(e,i+(e[r]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]},sr=class _n{constructor({strings:t,_$litType$:r},s){let n;this.parts=[];let i=0,o=0,a=t.length-1,l=this.parts,[c,f]=Jn(t,r);if(this.el=_n.createElement(c,s),Ae.currentNode=this.el.content,r===2||r===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(n=Ae.nextNode())!==null&&l.length<a;){if(n.nodeType===1){if(n.hasAttributes())for(let u of n.getAttributeNames())if(u.endsWith(Jr)){let d=f[o++],y=n.getAttribute(u).split(be),g=/([.?@])?(.*)/.exec(d);l.push({type:1,index:i,name:g[2],strings:y,ctor:g[1]==="."?Yn:g[1]==="?"?Qn:g[1]==="@"?Xn:vt}),n.removeAttribute(u)}else u.startsWith(be)&&(l.push({type:6,index:i}),n.removeAttribute(u));if(es.test(n.tagName)){let u=n.textContent.split(be),d=u.length-1;if(d>0){n.textContent=wt?wt.emptyScript:"";for(let y=0;y<d;y++)n.append(u[y],Ze()),Ae.nextNode(),l.push({type:2,index:++i});n.append(u[d],Ze())}}}else if(n.nodeType===8)if(n.data===Gr)l.push({type:2,index:i});else{let u=-1;for(;(u=n.data.indexOf(be,u+1))!==-1;)l.push({type:7,index:i}),u+=be.length-1}i++}}static createElement(t,r){let s=$e.createElement("template");return s.innerHTML=t,s}};function je(e,t,r=e,s){if(t===Se)return t;let n=s===void 0?r._$Cl:r._$Co?.[s],i=et(t)?void 0:t._$litDirective$;return n?.constructor!==i&&(n?._$AO?.(!1),i===void 0?n=void 0:(n=new i(e),n._$AT(e,r,s)),s===void 0?r._$Cl=n:(r._$Co??=[])[s]=n),n!==void 0&&(t=je(e,n._$AS(e,t.values),n,s)),t}var Gn=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:r}=this._$AD,s=(e?.creationScope??$e).importNode(t,!0);Ae.currentNode=s;let n=Ae.nextNode(),i=0,o=0,a=r[0];for(;a!==void 0;){if(i===a.index){let l;a.type===2?l=new nr(n,n.nextSibling,this,e):a.type===1?l=new a.ctor(n,a.name,a.strings,this,e):a.type===6&&(l=new Zn(n,this,e)),this._$AV.push(l),a=r[++o]}i!==a?.index&&(n=Ae.nextNode(),i++)}return Ae.currentNode=$e,s}p(e){let t=0;for(let r of this._$AV)r!==void 0&&(r.strings===void 0?r._$AI(e[t]):(r._$AI(e,r,t),t+=r.strings.length-2)),t++}},nr=class Nn{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,r,s,n){this.type=2,this._$AH=C,this._$AN=void 0,this._$AA=t,this._$AB=r,this._$AM=s,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,r=this._$AM;return r!==void 0&&t?.nodeType===11&&(t=r.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,r=this){t=je(this,t,r),et(t)?t===C||t==null||t===""?(this._$AH!==C&&this._$AR(),this._$AH=C):t!==this._$AH&&t!==Se&&this._(t):t._$litType$===void 0?t.nodeType===void 0?Vn(t)?this.k(t):this._(t):this.T(t):this.$(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==C&&et(this._$AH)?this._$AA.nextSibling.data=t:this.T($e.createTextNode(t)),this._$AH=t}$(t){let{values:r,_$litType$:s}=t,n=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=sr.createElement(rs(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===n)this._$AH.p(r);else{let i=new Gn(n,this),o=i.u(this.options);i.p(r),this.T(o),this._$AH=i}}_$AC(t){let r=ts.get(t.strings);return r===void 0&&ts.set(t.strings,r=new sr(t)),r}k(t){tr(this._$AH)||(this._$AH=[],this._$AR());let r=this._$AH,s,n=0;for(let i of t)n===r.length?r.push(s=new Nn(this.O(Ze()),this.O(Ze()),this,this.options)):s=r[n],s._$AI(i),n++;n<r.length&&(this._$AR(s&&s._$AB.nextSibling,n),r.length=n)}_$AR(t=this._$AA.nextSibling,r){for(this._$AP?.(!1,!0,r);t!==this._$AB;){let s=Wr(t).nextSibling;Wr(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},vt=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,s,n){this.type=1,this._$AH=C,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=C}_$AI(e,t=this,r,s){let n=this.strings,i=!1;if(n===void 0)e=je(this,e,t,0),i=!et(e)||e!==this._$AH&&e!==Se,i&&(this._$AH=e);else{let o=e,a,l;for(e=n[0],a=0;a<n.length-1;a++)l=je(this,o[r+a],t,a),l===Se&&(l=this._$AH[a]),i||=!et(l)||l!==this._$AH[a],l===C?e=C:e!==C&&(e+=(l??"")+n[a+1]),this._$AH[a]=l}i&&!s&&this.j(e)}j(e){e===C?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},Yn=class extends vt{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===C?void 0:e}},Qn=class extends vt{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==C)}},Xn=class extends vt{constructor(e,t,r,s,n){super(e,t,r,s,n),this.type=5}_$AI(e,t=this){if((e=je(this,e,t,0)??C)===Se)return;let r=this._$AH,s=e===C&&r!==C||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,n=e!==C&&(r===C||s);s&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},Zn=class{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){je(this,e)}},ei=er.litHtmlPolyfillSupport;ei?.(sr,nr),(er.litHtmlVersions??=[]).push("3.3.3");var ti=(e,t,r)=>{let s=r?.renderBefore??t,n=s._$litPart$;if(n===void 0){let i=r?.renderBefore??null;s._$litPart$=n=new nr(t.insertBefore(Ze(),i),i,void 0,r??{})}return n._$AI(e),n},ir=globalThis,rt=class extends Te{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ti(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Se}};rt._$litElement$=!0,rt.finalized=!0,ir.litElementHydrateSupport?.({LitElement:rt});var ri=ir.litElementPolyfillSupport;ri?.({LitElement:rt}),(ir.litElementVersions??=[]).push("4.2.2");var si=e=>(t,r)=>{r===void 0?customElements.define(e,t):r.addInitializer(()=>{customElements.define(e,t)})},ni={attribute:!0,type:String,converter:bt,reflect:!1,hasChanged:Zt},ii=(e=ni,t,r)=>{let{kind:s,metadata:n}=r,i=globalThis.litPropertyMetadata.get(n);if(i===void 0&&globalThis.litPropertyMetadata.set(n,i=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),i.set(r.name,e),s==="accessor"){let{name:o}=r;return{set(a){let l=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,l,e,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,e,a),a}}}if(s==="setter"){let{name:o}=r;return function(a){let l=this[o];t.call(this,a),this.requestUpdate(o,l,e,!0,a)}}throw Error("Unsupported decorator location: "+s)};function ee(e){return(t,r)=>typeof r=="object"?ii(e,t,r):((s,n,i)=>{let o=n.hasOwnProperty(i);return n.constructor.createProperty(i,s),o?Object.getOwnPropertyDescriptor(n,i):void 0})(e,t,r)}function X(e){return ee({...e,state:!0,attribute:!1})}var oi={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},ai=e=>(...t)=>({_$litDirective$:e,values:t}),li=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r){this._$Ct=e,this._$AM=t,this._$Ci=r}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},or=class extends li{constructor(e){if(super(e),this.it=C,e.type!==oi.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===C||e==null)return this._t=void 0,this.it=e;if(e===Se)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};or.directiveName="unsafeHTML",or.resultType=1;var ar=class extends or{};ar.directiveName="unsafeSVG",ar.resultType=2;var ci=ai(ar),lr="ember",ss={ember:{dark:`
|
|
11
|
+
--primary: #f76b39;
|
|
12
|
+
--primary-foreground: #000000;
|
|
13
|
+
`,light:`
|
|
14
|
+
--primary: #f76b39;
|
|
15
|
+
--primary-foreground: #000000;
|
|
16
|
+
`},carbon:{dark:`
|
|
17
|
+
--primary: #fafafa;
|
|
18
|
+
--primary-foreground: #18181b;
|
|
19
|
+
--ring: #a1a1aa;
|
|
20
|
+
--background: #121214;
|
|
21
|
+
--foreground: #e4e4e7;
|
|
22
|
+
`,light:`
|
|
23
|
+
--primary: #18181b;
|
|
24
|
+
--primary-foreground: #fafafa;
|
|
25
|
+
--ring: #52525b;
|
|
26
|
+
--background: #ffffff;
|
|
27
|
+
--foreground: #18181b;
|
|
28
|
+
`},cobalt:{dark:`
|
|
29
|
+
--primary: #7aa2d6;
|
|
30
|
+
--primary-foreground: #0f1a2a;
|
|
31
|
+
--background: #1e2530;
|
|
32
|
+
--foreground: #b4bcc8;
|
|
33
|
+
--card: #181e27;
|
|
34
|
+
--card-foreground: #ced5df;
|
|
35
|
+
`,light:`
|
|
36
|
+
--primary: #3a6cb0;
|
|
37
|
+
--primary-foreground: #ffffff;
|
|
38
|
+
--background: #ffffff;
|
|
39
|
+
--foreground: #243244;
|
|
40
|
+
--card: color-mix(in srgb, var(--background) 94%, var(--foreground));
|
|
41
|
+
--card-foreground: color-mix(in srgb, var(--foreground) 90%, #000000);
|
|
42
|
+
`},jade:{dark:`
|
|
43
|
+
--primary: #00d390;
|
|
44
|
+
--primary-foreground: #0b1f17;
|
|
45
|
+
--background: #1d232a;
|
|
46
|
+
--foreground: #a6adbb;
|
|
47
|
+
--card: #181e25;
|
|
48
|
+
--card-foreground: #c8cfd9;
|
|
49
|
+
`,light:`
|
|
50
|
+
--primary: #047857;
|
|
51
|
+
--primary-foreground: #ffffff;
|
|
52
|
+
--background: #ffffff;
|
|
53
|
+
--foreground: #1a2e26;
|
|
54
|
+
--card: color-mix(in srgb, var(--background) 94%, var(--foreground));
|
|
55
|
+
--card-foreground: color-mix(in srgb, var(--foreground) 90%, #000000);
|
|
56
|
+
`},indigo:{dark:`
|
|
57
|
+
--primary: #818cf8;
|
|
58
|
+
--primary-foreground: #1e1b4b;
|
|
59
|
+
--background: #0f0e1c;
|
|
60
|
+
--foreground: #e4e2f5;
|
|
61
|
+
`,light:`
|
|
62
|
+
--primary: #4f46e5;
|
|
63
|
+
--primary-foreground: #ffffff;
|
|
64
|
+
--background: #ffffff;
|
|
65
|
+
--foreground: #1e1b3a;
|
|
66
|
+
`}},ns=Object.keys(ss);function ui(e,{dark:t,light:r}){let s=n=>{let i=n?`[color-scheme='${n}']`:"",o=[`:host([theme='${e}']${i})`];return e==="ember"&&o.push(`:host(:not([theme])${i})`),o.join(`,
|
|
67
|
+
`)};return`
|
|
68
|
+
/* --------- ${e.toUpperCase()}${e==="ember"?" (default)":""} --------- */
|
|
69
|
+
${s()} {${t}}
|
|
70
|
+
${s("light")} {${r}}
|
|
71
|
+
@media (prefers-color-scheme: light) {
|
|
72
|
+
${s("system")} {${r}}
|
|
73
|
+
}
|
|
74
|
+
`}var fi=zr(Object.entries(ss).map(([e,t])=>ui(e,t)).join(""));function is(e){return!e||typeof e!="string"?!1:/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e.trim())}function os(e){if(!e||typeof e!="string")return{theme:lr};let t=e.trim(),r=t.toLowerCase();return ns.includes(r)?{theme:r}:is(t)?{theme:t}:{theme:lr}}function pi(e){if(!e||typeof e!="string")return!1;let t=e.trim().replace(/^#/,"");if(t.length===3&&(t=t.split("").map(r=>r+r).join("")),t.length===6||t.length===8){let r=parseInt(t.slice(0,2),16),s=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);return(r*299+s*587+n*114)/1e3>=128}return!1}function as(e,t){if(!e||!e.style)return;if(typeof t!="string"||ns.includes(t.trim().toLowerCase())||!is(t)){e.style.removeProperty("--primary"),e.style.removeProperty("--primary-foreground");return}let r=t.trim();e.style.setProperty("--primary",r);let s=pi(r)?"#000000":"#ffffff";e.style.setProperty("--primary-foreground",s)}var di=Xt`:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Roboto Mono", monospace;--heading-font:var(--font-sans);--heading-weight:600;--heading-line-height:1.25;--heading-letter-spacing:normal;--heading-color:var(--foreground);--heading-margin-top:1.5em;--heading-margin-bottom:.5em;--h1-font-size:2rem;--h2-font-size:1.5rem;--h3-font-size:1.25rem;--h4-font-size:1rem;--h5-font-size:.875rem;--h6-font-size:.8125rem;--label-heading-font-size:var(--font-size-small);--line-height:1.6;--paragraph-spacing:1em;--radius:.25rem;--font-size-xs:11px;--font-size-small:12px;--font-size-description:13px;--font-size-mono:13px;--font-size-regular:14px;--resp-area-height:400px;--table-schema-key-width:240px;--table-schema-key-text-overflow:ellipsis;--table-schema-key-whitespace:nowrap;--scroll-margin-top:120px;--param-label-width:12rem;--param-gap:.5rem;--param-row-gap:.25rem;--param-padding:.5rem;--auth-scheme-padding:.75rem;--value-list-gap:.375rem;--value-list-row-gap:.125rem;--value-list-label-gap:.25rem;--ring:var(--primary);--focus-shadow:0 0 0 1px transparent, 0 0 0 2px color-mix(in srgb, var(--ring) 40%, transparent);--selection-bg:color-mix(in srgb, var(--primary) 25%, transparent);--selection-fg:var(--foreground);--sidebar-width:18.75rem;--sidebar-item-padding:.4375rem 1rem .4375rem .625rem;--sidebar-logo-max-height:60px;--sidebar:var(--background);--sidebar-foreground:var(--foreground);--sidebar-primary:var(--primary);--sidebar-accent-foreground:var(--foreground);--sidebar-border:var(--border);--sidebar-ring:var(--ring)}:host([radius=none]){--radius:0px}:host([radius=sm]),:host(:not([radius])){--radius:.25rem}:host([radius=md]){--radius:.375rem}:host([radius=lg]){--radius:.5rem}:host([radius=full]){--radius:9999px}:host([scale=sm]){--font-size-xs:11px;--font-size-small:11px;--font-size-description:12px;--font-size-mono:12px;--font-size-regular:13px;--sidebar-width:17rem}:host([scale=default]),:host(:not([scale])){--font-size-xs:11px;--font-size-small:12px;--font-size-description:13px;--font-size-mono:13px;--font-size-regular:14px;--sidebar-width:18.75rem}:host([scale=lg]){--font-size-xs:12px;--font-size-small:14px;--font-size-description:15px;--font-size-mono:15px;--font-size-regular:16px;--sidebar-width:21rem}:host([nav-item-spacing=compact]){--sidebar-item-padding:.3125rem 1rem .3125rem .625rem}:host([nav-item-spacing=default]),:host(:not([nav-item-spacing])){--sidebar-item-padding:.4375rem 1rem .4375rem .625rem}:host([nav-item-spacing=relaxed]){--sidebar-item-padding:.625rem 1rem .625rem .625rem}:host,:host([color-scheme=dark]),:host([color-scheme=system]),:host(:not([color-scheme])){--background:#1f1f23;--foreground:#d4d4d8;--card:color-mix(in srgb, var(--background) 92%, var(--foreground));--card-foreground:color-mix(in srgb, var(--foreground) 90%, #fff);--muted:color-mix(in srgb, var(--background) 86%, var(--foreground));--muted-foreground:color-mix(in srgb, var(--foreground) 65%, var(--background));--border:color-mix(in srgb, var(--background) 85%, var(--foreground));--sidebar-accent:color-mix(in srgb, var(--background) 88%, var(--foreground));--input:oklch(from var(--border) calc(l + .05) c h);--input-background:color-mix(in srgb, var(--background) 80%, #000);--method-get:#5c98f9;--method-post:#68cc97;--method-put:#f59e0b;--method-delete:#f75252;--method-patch:#a78bfa;--method-head:#eab308;--method-options:#06b6d4;--method-trace:#ec4899;--method-query:#818cf8;--method-default:#64748b;--method-badge-fg:#000;--destructive:#ef4444;--blue:#3b82f6;--green:#10b981;--orange:#f59e0b;--red:#ef4444;--purple:#8b5cf6;--yellow:#eab308;--pink:#ec4899;--brown:#d97706;--syntax-comment:#8b949e;--syntax-keyword:#ff7b72;--syntax-operator:#c9d1d9;--syntax-string:#a5d6ff;--syntax-constant:#79c0ff;--syntax-function:#d2a8ff;--syntax-type:#d2a8ff;--syntax-variable:#ffa657;--syntax-property:#79c0ff;--syntax-tag:#7ee787;--syntax-selector:#d2a8ff;--syntax-inserted:#7ee787;--syntax-deleted:#ff7b72;--code-bg:var(--input-background)}:host([color-scheme=light]){--background:#fff;--foreground:#27272a;--card:color-mix(in srgb, var(--background) 94%, var(--foreground));--card-foreground:color-mix(in srgb, var(--foreground) 90%, #000);--muted:color-mix(in srgb, var(--background) 94%, var(--foreground));--muted-foreground:color-mix(in srgb, var(--foreground) 60%, var(--background));--border:color-mix(in srgb, var(--background) 85%, var(--foreground));--sidebar-accent:color-mix(in srgb, var(--background) 92%, var(--foreground));--input:color-mix(in srgb, var(--border) 75%, var(--foreground));--input-background:var(--background);--method-get:#2563eb;--method-post:#047857;--method-put:#c2410c;--method-delete:#b91c1c;--method-patch:#7c3aed;--method-head:#b45309;--method-options:#0e7490;--method-trace:#be185d;--method-query:#4f46e5;--method-default:#475569;--method-badge-fg:#fff;--destructive:#dc2626;--blue:#2768f4;--green:#059669;--orange:#d97706;--red:#dc2626;--purple:#7c3aed;--yellow:#b45309;--pink:#db2777;--brown:#92400e;--syntax-comment:#6e7781;--syntax-keyword:#cf222e;--syntax-operator:#24292f;--syntax-string:#0a3069;--syntax-constant:#0550ae;--syntax-function:#8250df;--syntax-type:#8250df;--syntax-variable:#953800;--syntax-property:#0550ae;--syntax-tag:#116329;--syntax-selector:#8250df;--syntax-inserted:#116329;--syntax-deleted:#cf222e;--code-bg:color-mix(in srgb, var(--background) 96%, var(--foreground))}@media (prefers-color-scheme:light){:host([color-scheme=system]){--background:#fff;--foreground:#27272a;--card:color-mix(in srgb, var(--background) 94%, var(--foreground));--card-foreground:color-mix(in srgb, var(--foreground) 90%, #000);--muted:color-mix(in srgb, var(--background) 94%, var(--foreground));--muted-foreground:color-mix(in srgb, var(--foreground) 60%, var(--background));--border:color-mix(in srgb, var(--background) 85%, var(--foreground));--sidebar-accent:color-mix(in srgb, var(--background) 92%, var(--foreground));--input:color-mix(in srgb, var(--border) 75%, var(--foreground));--input-background:var(--background);--method-get:#2563eb;--method-post:#047857;--method-put:#c2410c;--method-delete:#b91c1c;--method-patch:#7c3aed;--method-head:#b45309;--method-options:#0e7490;--method-trace:#be185d;--method-query:#4f46e5;--method-default:#475569;--method-badge-fg:#fff;--destructive:#dc2626;--blue:#2768f4;--green:#059669;--orange:#d97706;--red:#dc2626;--purple:#7c3aed;--yellow:#b45309;--pink:#db2777;--brown:#92400e;--syntax-comment:#6e7781;--syntax-keyword:#cf222e;--syntax-operator:#24292f;--syntax-string:#0a3069;--syntax-constant:#0550ae;--syntax-function:#8250df;--syntax-type:#8250df;--syntax-variable:#953800;--syntax-property:#0550ae;--syntax-tag:#116329;--syntax-selector:#8250df;--syntax-inserted:#116329;--syntax-deleted:#cf222e;--code-bg:color-mix(in srgb, var(--background) 96%, var(--foreground))}}${fi}`,hi=Xt`.rf-svg{max-width:100%;height:auto;font-family:var(--font-sans);font-size:var(--font-size-description);display:block;overflow:visible}.rf-node rect{fill:var(--card);stroke:var(--border);stroke-width:1.25px}.rf-io rect{fill:var(--muted)}.rf-title{fill:color-mix(in srgb, var(--primary) 65%, var(--foreground));font-weight:600;font-size:var(--font-size-regular)}.rf-sub{fill:var(--muted-foreground)}.rf-io-title,.rf-criteria{fill:var(--muted-foreground);font-size:var(--font-size-xs);text-transform:uppercase;letter-spacing:.04em}.rf-criteria{text-transform:none;letter-spacing:normal}.rf-path,.rf-method,.rf-unresolved{font-family:var(--font-mono);font-size:var(--font-size-small)}.rf-path{fill:var(--foreground)}.rf-method{fill:var(--method-default);font-weight:700}.rf-method-get{fill:var(--method-get)}.rf-method-post{fill:var(--method-post)}.rf-method-put{fill:var(--method-put)}.rf-method-delete{fill:var(--method-delete)}.rf-method-patch{fill:var(--method-patch)}.rf-method-head{fill:var(--method-head)}.rf-method-options{fill:var(--method-options)}.rf-method-trace{fill:var(--method-trace)}.rf-method-query{fill:var(--method-query)}.rf-unresolved{fill:var(--muted-foreground);font-style:italic}.rf-jump{cursor:pointer;outline:none}.rf-jump:hover .rf-step-name,.rf-tag.rf-jump:hover,.rf-tag.rf-jump:focus-visible{text-decoration:underline}.rf-clickable{cursor:pointer;outline:none}.rf-clickable:hover rect,.rf-clickable:focus-visible rect,.rf-selected rect{stroke:var(--primary);stroke-width:2px}.rf-seq{fill:none;stroke:var(--muted-foreground);stroke-width:1.25px}.rf-head-seq{fill:var(--muted-foreground)}.rf-data{fill:none;stroke:var(--primary);stroke-width:1.5px;stroke-dasharray:5 4}.rf-head-data{fill:var(--primary)}.rf-data.rf-to-output{stroke:var(--muted-foreground)}.rf-head-output{fill:var(--muted-foreground)}.rf-sep{fill:none;stroke:var(--border);stroke-width:1px}.rf-row{font-size:var(--font-size-small)}.rf-in-name,.rf-out-name,.rf-bind-name,.rf-bind-val,.rf-act-when,.rf-act-then{fill:var(--foreground)}.rf-bind-name,.rf-bind-val,.rf-kw,.rf-in-type,.rf-in-default,.rf-in-enum{font-family:var(--font-mono)}.rf-in-type,.rf-in-default,.rf-in-enum,.rf-out-from,.rf-out-kind,.rf-act-name,.rf-more,.rf-tag,.rf-sec-title{fill:var(--muted-foreground)}.rf-kw,.rf-out-kind{font-weight:600}.rf-step-name,.rf-kw-step,.rf-tag.rf-out-step,.rf-row.rf-linked .rf-out-name{fill:color-mix(in srgb, var(--primary) 65%, var(--foreground))}.rf-tag.rf-out-step{font-size:var(--font-size-small);font-weight:600}.rf-step.rf-linked rect{stroke:var(--primary);stroke-width:2px}.rf-data.rf-linked{stroke-width:2.5px}.rf-step.rf-running rect{stroke:var(--primary);stroke-width:2px;stroke-dasharray:6 4;animation:1s linear infinite rf-march}@keyframes rf-march{to{stroke-dashoffset:-20px}}.rf-io .rf-sep{stroke:var(--muted-foreground);stroke-opacity:.35}.rf-out-from{font-family:var(--font-mono)}.rf-kw-input{fill:var(--blue)}.rf-kw-value,.rf-kw-expression{fill:var(--muted-foreground)}.rf-req{fill:var(--destructive);font-size:var(--font-size-xs);font-weight:600}.rf-more,.rf-tag,.rf-sec-title{font-size:var(--font-size-xs)}.rf-sec-title{text-transform:uppercase;letter-spacing:.04em}.rf-check-type{fill:var(--muted-foreground)}.rf-check-type,.rf-check{font-family:var(--font-mono)}.rf-check{fill:var(--foreground)}.rf-data-label rect{fill:var(--background);stroke:var(--primary);stroke-width:1px}.rf-data-label text{fill:var(--foreground);font-size:var(--font-size-xs)}.rf-goto{fill:none;stroke-width:1.5px}.rf-goto.rf-success{stroke:var(--green)}.rf-goto.rf-failure{stroke:var(--destructive)}.rf-head-success{fill:var(--green)}.rf-head-failure{fill:var(--destructive)}`,mi=class{constructor(e){this.host=e,this.active=!1,this.resolved="",this.observer=null,this.media=null,this.onPageChange=()=>this.apply(),e.addController(this)}hostConnected(){this.host.colorScheme==="auto"?this.enable():this.active&&(this.watch(!0),this.apply())}hostDisconnected(){this.watch(!1)}hostUpdate(){let e=this.host.colorScheme;e==="auto"?this.enable():this.active&&e!==this.resolved&&(this.active=!1,this.watch(!1))}enable(){this.active=!0,this.watch(!0),this.apply()}apply(){if(!this.active||typeof window>"u")return;let e=gi(this.host);this.resolved=e,this.host.colorScheme!==e&&(this.host.colorScheme=e),this.host.getAttribute("color-scheme")!==e&&this.host.setAttribute("color-scheme",e)}watch(e){this.observer?.disconnect(),this.observer=null,this.media?.removeEventListener("change",this.onPageChange),this.media=null,e&&typeof window<"u"&&(this.observer=new MutationObserver(this.onPageChange),this.observer.observe(document.documentElement,{attributes:!0}),document.body&&this.observer.observe(document.body,{attributes:!0}),this.media=window.matchMedia("(prefers-color-scheme: light)"),this.media.addEventListener("change",this.onPageChange))}};function gi(e){let t=e.parentElement||e.getRootNode().host||document.documentElement,r=getComputedStyle(t).colorScheme||"",s=/\bdark\b/.test(r);return s===/\blight\b/.test(r)?window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark":s?"dark":"light"}var yi=`/**
|
|
75
|
+
* RapiDoc MCP workflow runtime: runs the compiled Arazzo workflows of a manifest (see
|
|
76
|
+
* workflows.js) on top of runtime.js: runtime expressions, success criteria, success and failure
|
|
77
|
+
* actions (end, goto, retry) and outputs. Kept apart from runtime.js so dist/rapidoc-min.js,
|
|
78
|
+
* which exports operation tools only, carries no Arazzo code; dist/rapidoc-flow-min.js and
|
|
79
|
+
* @rapidoc/mcp include it.
|
|
80
|
+
*
|
|
81
|
+
* This file is copied verbatim into exported MCP server projects that have workflows as
|
|
82
|
+
* \`workflow-runtime.js\`, so it imports only \`./runtime.js\`.
|
|
83
|
+
*/
|
|
84
|
+
import { createMcpRuntime } from "./runtime.js";
|
|
85
|
+
|
|
86
|
+
function serialize(value) {
|
|
87
|
+
if (typeof value === "string") return value;
|
|
88
|
+
if (value && typeof value === "object") return JSON.stringify(value);
|
|
89
|
+
return String(value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function errorResult(text) {
|
|
93
|
+
return { isError: true, content: [{ type: "text", text }] };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ---- Arazzo runtime expressions ----
|
|
97
|
+
|
|
98
|
+
/** RFC 6901 JSON pointer lookup; "" is the whole value. */
|
|
99
|
+
function pointer(value, path) {
|
|
100
|
+
if (!path) return value;
|
|
101
|
+
let node = value;
|
|
102
|
+
for (const raw of path.split("/").slice(1)) {
|
|
103
|
+
const key = raw.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
104
|
+
if (node === null || typeof node !== "object") return undefined;
|
|
105
|
+
node = node[key];
|
|
106
|
+
}
|
|
107
|
+
return node;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function walk(value, keys) {
|
|
111
|
+
let node = value;
|
|
112
|
+
for (const key of keys) {
|
|
113
|
+
if (node === null || typeof node !== "object") return undefined;
|
|
114
|
+
node = node[key];
|
|
115
|
+
}
|
|
116
|
+
return node;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* One Arazzo runtime expression against the step context: \`$inputs.x\`, \`$steps.id.outputs.x\`,
|
|
121
|
+
* \`$statusCode\`, \`$response.body\` (\`#/pointer\`), \`$response.header.Name\`, \`$request.body\`,
|
|
122
|
+
* \`$request.header.Name\`, \`$url\`, \`$method\`.
|
|
123
|
+
*/
|
|
124
|
+
export function evaluateExpression(expr, ctx) {
|
|
125
|
+
const m = String(expr).match(/^\\$([A-Za-z]+)((?:\\.[^.#\\s]+)*)(?:#(.*))?$/);
|
|
126
|
+
if (!m) return undefined;
|
|
127
|
+
const [, root, dotted, ptr] = m;
|
|
128
|
+
const keys = dotted ? dotted.slice(1).split(".") : [];
|
|
129
|
+
switch (root) {
|
|
130
|
+
case "inputs":
|
|
131
|
+
return walk(ctx.inputs || {}, keys);
|
|
132
|
+
case "steps":
|
|
133
|
+
return walk(ctx.steps || {}, keys);
|
|
134
|
+
case "statusCode":
|
|
135
|
+
return ctx.response?.status;
|
|
136
|
+
case "url":
|
|
137
|
+
return ctx.request?.url;
|
|
138
|
+
case "method":
|
|
139
|
+
return ctx.request?.method;
|
|
140
|
+
case "response":
|
|
141
|
+
case "request": {
|
|
142
|
+
const msg = ctx[root];
|
|
143
|
+
if (!msg) return undefined;
|
|
144
|
+
const [part, ...rest] = keys;
|
|
145
|
+
if (part === "body") return walk(pointer(msg.body, ptr || ""), rest);
|
|
146
|
+
if (part === "header" || part === "headers") {
|
|
147
|
+
const name = rest.join(".").toLowerCase();
|
|
148
|
+
const headers = msg.headers || {};
|
|
149
|
+
const hit = Object.keys(headers).find((h) => h.toLowerCase() === name);
|
|
150
|
+
return hit === undefined ? undefined : headers[hit];
|
|
151
|
+
}
|
|
152
|
+
if (part === "query" || part === "path") return walk(msg[part] || {}, rest);
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
default:
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const WHOLE_EXPRESSION = /^\\$[A-Za-z][^\\s{}]*$/;
|
|
161
|
+
|
|
162
|
+
/** A parameter or payload value with its expressions filled in; \`{$expr}\` inside text is interpolated. */
|
|
163
|
+
export function resolveValue(value, ctx) {
|
|
164
|
+
if (typeof value === "string") {
|
|
165
|
+
if (WHOLE_EXPRESSION.test(value)) return evaluateExpression(value, ctx);
|
|
166
|
+
return value.replace(/\\{(\\$[^{}]+)\\}/g, (_, expr) => {
|
|
167
|
+
const v = evaluateExpression(expr, ctx);
|
|
168
|
+
return v === undefined || v === null ? "" : serialize(v);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (Array.isArray(value)) return value.map((v) => resolveValue(v, ctx));
|
|
172
|
+
if (value && typeof value === "object") {
|
|
173
|
+
const out = {};
|
|
174
|
+
for (const [k, v] of Object.entries(value)) out[k] = resolveValue(v, ctx);
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ---- Simple conditions: \`$statusCode == 200 && $response.body#/status != 'placed'\` ----
|
|
181
|
+
|
|
182
|
+
function tokenize(condition) {
|
|
183
|
+
const tokens = [];
|
|
184
|
+
const re =
|
|
185
|
+
/\\s*(?:(&&|\\|\\||==|!=|<=|>=|<|>|!|\\(|\\))|('(?:[^'\\\\]|\\\\.)*'|"(?:[^"\\\\]|\\\\.)*")|(-?\\d+(?:\\.\\d+)?)|(\\$[^\\s()&|=!<>]+)|(true|false|null))/y;
|
|
186
|
+
let last = 0;
|
|
187
|
+
for (;;) {
|
|
188
|
+
re.lastIndex = last;
|
|
189
|
+
const m = re.exec(condition);
|
|
190
|
+
if (!m) break;
|
|
191
|
+
last = re.lastIndex;
|
|
192
|
+
if (m[1]) tokens.push({ op: m[1] });
|
|
193
|
+
else if (m[2]) tokens.push({ value: m[2].slice(1, -1).replace(/\\\\(.)/g, "$1") });
|
|
194
|
+
else if (m[3]) tokens.push({ value: Number(m[3]) });
|
|
195
|
+
else if (m[4]) tokens.push({ expr: m[4] });
|
|
196
|
+
else if (m[5]) tokens.push({ value: m[5] === "true" ? true : m[5] === "false" ? false : null });
|
|
197
|
+
}
|
|
198
|
+
if (condition.slice(last).trim()) throw new Error(\`Cannot parse condition "\${condition}"\`);
|
|
199
|
+
return tokens;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** \`==\` in a simple condition: null and a missing value are the same; numbers and strings compare as text. */
|
|
203
|
+
function looseEquals(a, b) {
|
|
204
|
+
if (a === b) return true;
|
|
205
|
+
const missing = (v) => v === null || v === undefined;
|
|
206
|
+
if (missing(a) || missing(b)) return missing(a) && missing(b);
|
|
207
|
+
if (typeof a === "object" || typeof b === "object")
|
|
208
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
209
|
+
return String(a) === String(b);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Evaluates a simple Arazzo condition. Throws when it cannot be parsed. */
|
|
213
|
+
export function evaluateCondition(condition, ctx) {
|
|
214
|
+
const tokens = tokenize(condition);
|
|
215
|
+
let i = 0;
|
|
216
|
+
const peek = () => tokens[i];
|
|
217
|
+
const takeOp = (...ops) => (peek()?.op && ops.includes(peek().op) ? tokens[i++].op : null);
|
|
218
|
+
const unary = () => {
|
|
219
|
+
if (takeOp("!")) return !unary();
|
|
220
|
+
if (takeOp("(")) {
|
|
221
|
+
const v = or();
|
|
222
|
+
if (!takeOp(")")) throw new Error(\`Missing ) in "\${condition}"\`);
|
|
223
|
+
return v;
|
|
224
|
+
}
|
|
225
|
+
const t = tokens[i++];
|
|
226
|
+
if (!t || t.op) throw new Error(\`Unexpected \${t ? t.op : "end"} in "\${condition}"\`);
|
|
227
|
+
return t.expr !== undefined ? evaluateExpression(t.expr, ctx) : t.value;
|
|
228
|
+
};
|
|
229
|
+
const cmp = () => {
|
|
230
|
+
const left = unary();
|
|
231
|
+
const op = takeOp("==", "!=", "<=", ">=", "<", ">");
|
|
232
|
+
if (!op) return left;
|
|
233
|
+
const right = unary();
|
|
234
|
+
if (op === "==") return looseEquals(left, right);
|
|
235
|
+
if (op === "!=") return !looseEquals(left, right);
|
|
236
|
+
const [a, b] = [Number(left), Number(right)];
|
|
237
|
+
if (op === "<") return a < b;
|
|
238
|
+
if (op === ">") return a > b;
|
|
239
|
+
if (op === "<=") return a <= b;
|
|
240
|
+
return a >= b;
|
|
241
|
+
};
|
|
242
|
+
const and = () => {
|
|
243
|
+
let v = cmp();
|
|
244
|
+
while (takeOp("&&")) v = cmp() && v;
|
|
245
|
+
return v;
|
|
246
|
+
};
|
|
247
|
+
const or = () => {
|
|
248
|
+
let v = and();
|
|
249
|
+
while (takeOp("||")) v = and() || v;
|
|
250
|
+
return v;
|
|
251
|
+
};
|
|
252
|
+
const result = or();
|
|
253
|
+
if (i < tokens.length) throw new Error(\`Unexpected \${tokens[i].op ?? "token"} in "\${condition}"\`);
|
|
254
|
+
return Boolean(result);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Sets the value at a JSON pointer inside a payload (an Arazzo request body replacement). */
|
|
258
|
+
function replaceAt(payload, target, value) {
|
|
259
|
+
const keys = String(target)
|
|
260
|
+
.split("/")
|
|
261
|
+
.slice(1)
|
|
262
|
+
.map((k) => k.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
263
|
+
if (!keys.length) return value;
|
|
264
|
+
const root = Array.isArray(payload) ? [...payload] : { ...payload };
|
|
265
|
+
let node = root;
|
|
266
|
+
for (const [i, key] of keys.entries()) {
|
|
267
|
+
if (i === keys.length - 1) {
|
|
268
|
+
node[key] = value;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
const next = node[key];
|
|
272
|
+
node[key] = Array.isArray(next) ? [...next] : { ...next };
|
|
273
|
+
node = node[key];
|
|
274
|
+
}
|
|
275
|
+
return root;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const MAX_STEP_RUNS = 1000;
|
|
279
|
+
|
|
280
|
+
function evaluateAll(criteria, ctx) {
|
|
281
|
+
return (criteria || []).every((c) => {
|
|
282
|
+
try {
|
|
283
|
+
return evaluateCondition(c.condition, ctx);
|
|
284
|
+
} catch {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Runs a workflow tool. Pass as createMcpRuntime's \`runWorkflow\` option, or use
|
|
292
|
+
* createMcpWorkflowRuntime().
|
|
293
|
+
*
|
|
294
|
+
* @param {object} runtime from createMcpRuntime()
|
|
295
|
+
* @param {object} tool a manifest tool with \`workflow\`
|
|
296
|
+
* @param {object} args the workflow inputs
|
|
297
|
+
* @param {object} [hooks]
|
|
298
|
+
* @param {Function} [hooks.onStepStart] gets \`{ workflowId, stepId, attempt }\` before each request
|
|
299
|
+
* @param {Function} [hooks.onStep] gets \`{ workflowId, stepId, attempt, outcome, request,
|
|
300
|
+
* response, outputs, failedCriterion, action }\` after each step run
|
|
301
|
+
* @param {(ms: number) => Promise<void>} [hooks.sleep] waits between retries (default setTimeout)
|
|
302
|
+
* @param {Function} [hooks.requestHeaders] gets \`{ workflowId, stepId, attempt, operation }\` and
|
|
303
|
+
* returns extra headers for that request (a mock's \`Prefer: code=503\`, say), or nothing
|
|
304
|
+
* @returns {Promise<object>} the MCP result: the workflow's outputs as \`structuredContent\`, or an
|
|
305
|
+
* error result naming the step, the failed criterion and the response
|
|
306
|
+
*/
|
|
307
|
+
export async function runWorkflow(runtime, tool, args, hooks = {}) {
|
|
308
|
+
const workflow = runtime.manifest.workflows?.[tool.workflow];
|
|
309
|
+
if (!workflow) return errorResult(\`Workflow "\${tool.workflow}" is not in the manifest\`);
|
|
310
|
+
const sleep = hooks.sleep || ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
311
|
+
const inputs = args || {};
|
|
312
|
+
const required = (workflow.inputs?.required || []).filter((name) => inputs[name] === undefined);
|
|
313
|
+
if (required.length) return errorResult(\`Missing input \${required.join(", ")}\`);
|
|
314
|
+
|
|
315
|
+
const steps = workflow.steps;
|
|
316
|
+
const indexOf = (stepId) => steps.findIndex((s) => s.stepId === stepId);
|
|
317
|
+
const stepsCtx = {};
|
|
318
|
+
const attempts = new Map();
|
|
319
|
+
let index = 0;
|
|
320
|
+
let runs = 0;
|
|
321
|
+
while (index >= 0 && index < steps.length) {
|
|
322
|
+
if (++runs > MAX_STEP_RUNS) {
|
|
323
|
+
return errorResult(\`Workflow \${workflow.workflowId} ran more than \${MAX_STEP_RUNS} steps\`);
|
|
324
|
+
}
|
|
325
|
+
const step = steps[index];
|
|
326
|
+
const attempt = (attempts.get(step.stepId) || 0) + 1;
|
|
327
|
+
attempts.set(step.stepId, attempt);
|
|
328
|
+
const ctx = { inputs, steps: stepsCtx };
|
|
329
|
+
const stepArgs = {};
|
|
330
|
+
for (const p of step.parameters || []) stepArgs[p.name] = resolveValue(p.value, ctx);
|
|
331
|
+
if (step.requestBody) {
|
|
332
|
+
let payload = resolveValue(step.requestBody.payload, ctx);
|
|
333
|
+
for (const r of step.requestBody.replacements || []) {
|
|
334
|
+
payload = replaceAt(payload, r.target, resolveValue(r.value, ctx));
|
|
335
|
+
}
|
|
336
|
+
stepArgs.body = payload;
|
|
337
|
+
}
|
|
338
|
+
const event = { workflowId: workflow.workflowId, stepId: step.stepId, attempt };
|
|
339
|
+
hooks.onStepStart?.(event);
|
|
340
|
+
const headers = hooks.requestHeaders?.({ ...event, operation: step.operation });
|
|
341
|
+
const sent = await runtime.execute(step.operation, stepArgs, headers ? { headers } : {});
|
|
342
|
+
const stepCtx = {
|
|
343
|
+
...ctx,
|
|
344
|
+
request: sent.request && {
|
|
345
|
+
url: sent.request.url,
|
|
346
|
+
method: sent.request.method,
|
|
347
|
+
headers: sent.request.headers,
|
|
348
|
+
body: stepArgs.body,
|
|
349
|
+
},
|
|
350
|
+
response: sent.response && {
|
|
351
|
+
status: sent.response.status,
|
|
352
|
+
headers: sent.headers,
|
|
353
|
+
body: sent.data === undefined ? sent.text : sent.data,
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
let failedCriterion = sent.error ? sent.error.content[0].text : "";
|
|
357
|
+
// Without criteria of its own, a step succeeds on a 2xx response
|
|
358
|
+
if (!failedCriterion && !(step.successCriteria || []).length && !sent.response.ok) {
|
|
359
|
+
failedCriterion = \`HTTP \${sent.response.status}\`;
|
|
360
|
+
}
|
|
361
|
+
if (!failedCriterion) {
|
|
362
|
+
for (const c of step.successCriteria || []) {
|
|
363
|
+
let ok;
|
|
364
|
+
try {
|
|
365
|
+
ok = evaluateCondition(c.condition, stepCtx);
|
|
366
|
+
} catch (err) {
|
|
367
|
+
ok = false;
|
|
368
|
+
failedCriterion = err.message;
|
|
369
|
+
}
|
|
370
|
+
if (!ok) {
|
|
371
|
+
failedCriterion ||= c.condition;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const outcome = failedCriterion ? "failure" : "success";
|
|
377
|
+
let outputs;
|
|
378
|
+
if (outcome === "success") {
|
|
379
|
+
outputs = {};
|
|
380
|
+
for (const [name, expr] of Object.entries(step.outputs || {})) {
|
|
381
|
+
outputs[name] = resolveValue(expr, stepCtx);
|
|
382
|
+
}
|
|
383
|
+
stepsCtx[step.stepId] = { outputs };
|
|
384
|
+
}
|
|
385
|
+
const candidates = outcome === "success" ? step.onSuccess : step.onFailure;
|
|
386
|
+
const action = (candidates || []).find((a) => evaluateAll(a.criteria, stepCtx));
|
|
387
|
+
hooks.onStep?.({
|
|
388
|
+
workflowId: workflow.workflowId,
|
|
389
|
+
stepId: step.stepId,
|
|
390
|
+
attempt,
|
|
391
|
+
outcome,
|
|
392
|
+
request: stepCtx.request,
|
|
393
|
+
response: stepCtx.response,
|
|
394
|
+
outputs,
|
|
395
|
+
failedCriterion: failedCriterion || undefined,
|
|
396
|
+
action: action ? { type: action.type, name: action.name, stepId: action.stepId } : null,
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
const failure = (why) =>
|
|
400
|
+
errorResult(
|
|
401
|
+
\`Workflow \${workflow.workflowId} failed at step \${step.stepId}: \${why}\` +
|
|
402
|
+
(stepCtx.response
|
|
403
|
+
? \`\\nHTTP \${stepCtx.response.status}\\n\${serialize(stepCtx.response.body)}\`
|
|
404
|
+
: ""),
|
|
405
|
+
);
|
|
406
|
+
if (outcome === "success") {
|
|
407
|
+
if (!action) index++;
|
|
408
|
+
else if (action.type === "end") break;
|
|
409
|
+
else if (action.type === "goto") index = indexOf(action.stepId);
|
|
410
|
+
else index++;
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
if (!action || action.type === "end") return failure(failedCriterion);
|
|
414
|
+
if (action.type === "goto") {
|
|
415
|
+
index = indexOf(action.stepId);
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
// retry
|
|
419
|
+
const target = action.stepId ? indexOf(action.stepId) : index;
|
|
420
|
+
const key = \`\${step.stepId}:\${action.name}\`;
|
|
421
|
+
const tried = (attempts.get(key) || 0) + 1;
|
|
422
|
+
attempts.set(key, tried);
|
|
423
|
+
if (tried > (action.retryLimit ?? 1)) {
|
|
424
|
+
return failure(\`\${failedCriterion} (after \${action.retryLimit ?? 1} retries)\`);
|
|
425
|
+
}
|
|
426
|
+
if (action.retryAfter) await sleep(action.retryAfter * 1000);
|
|
427
|
+
index = target;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const outputs = {};
|
|
431
|
+
for (const [name, expr] of Object.entries(workflow.outputs || {})) {
|
|
432
|
+
outputs[name] = resolveValue(expr, { inputs, steps: stepsCtx });
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
content: [{ type: "text", text: JSON.stringify(outputs, null, 2) }],
|
|
436
|
+
structuredContent: outputs,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** createMcpRuntime() with workflow support plugged in; \`options.sleep\` waits between retries. */
|
|
441
|
+
export function createMcpWorkflowRuntime(manifest, options = {}) {
|
|
442
|
+
return createMcpRuntime(manifest, {
|
|
443
|
+
...options,
|
|
444
|
+
runWorkflow: (runtime, tool, args, hooks) =>
|
|
445
|
+
runWorkflow(runtime, tool, args, { sleep: options.sleep, ...hooks }),
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
`,cr=Symbol.for("yaml.alias"),ur=Symbol.for("yaml.document"),we=Symbol.for("yaml.map"),ls=Symbol.for("yaml.pair"),ae=Symbol.for("yaml.scalar"),Le=Symbol.for("yaml.seq"),te=Symbol.for("yaml.node.type"),Me=e=>!!e&&typeof e=="object"&&e[te]===cr,kt=e=>!!e&&typeof e=="object"&&e[te]===ur,st=e=>!!e&&typeof e=="object"&&e[te]===we,W=e=>!!e&&typeof e=="object"&&e[te]===ls,B=e=>!!e&&typeof e=="object"&&e[te]===ae,nt=e=>!!e&&typeof e=="object"&&e[te]===Le;function V(e){if(e&&typeof e=="object")switch(e[te]){case we:case Le:return!0}return!1}function J(e){if(e&&typeof e=="object")switch(e[te]){case cr:case we:case ae:case Le:return!0}return!1}var cs=e=>(B(e)||V(e))&&!!e.anchor,Ie=Symbol("break visit"),bi=Symbol("skip children"),it=Symbol("remove node");function qe(e,t){let r=wi(t);kt(e)?Pe(null,e.contents,r,Object.freeze([e]))===it&&(e.contents=null):Pe(null,e,r,Object.freeze([]))}qe.BREAK=Ie,qe.SKIP=bi,qe.REMOVE=it;function Pe(e,t,r,s){let n=vi(e,t,r,s);if(J(n)||W(n))return ki(e,s,n),Pe(e,n,r,s);if(typeof n!="symbol"){if(V(t)){s=Object.freeze(s.concat(t));for(let i=0;i<t.items.length;++i){let o=Pe(i,t.items[i],r,s);if(typeof o=="number")i=o-1;else{if(o===Ie)return Ie;o===it&&(t.items.splice(i,1),--i)}}}else if(W(t)){s=Object.freeze(s.concat(t));let i=Pe("key",t.key,r,s);if(i===Ie)return Ie;i===it&&(t.key=null);let o=Pe("value",t.value,r,s);if(o===Ie)return Ie;o===it&&(t.value=null)}}return n}function wi(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?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):e}function vi(e,t,r,s){if(typeof r=="function")return r(e,t,s);if(st(t))return r.Map?.(e,t,s);if(nt(t))return r.Seq?.(e,t,s);if(W(t))return r.Pair?.(e,t,s);if(B(t))return r.Scalar?.(e,t,s);if(Me(t))return r.Alias?.(e,t,s)}function ki(e,t,r){let s=t[t.length-1];if(V(s))s.items[e]=r;else if(W(s))e==="key"?s.key=r:s.value=r;else if(kt(s))s.contents=r;else{let n=Me(s)?"alias":"scalar";throw Error(`Cannot replace node with ${n} parent`)}}var $i={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},xi=e=>e.replace(/[!,[\]{}]/g,t=>$i[t]),Re=class ge{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},ge.defaultYaml,t),this.tags=Object.assign({},ge.defaultTags,r)}clone(){let t=new ge(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new ge(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:ge.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},ge.defaultTags)}return t}add(t,r){this.atNextDocument&&=(this.yaml={explicit:ge.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},ge.defaultTags),!1);let s=t.trim().split(/[ \t]+/),n=s.shift();switch(n){case"%TAG":{if(s.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;let[i,o]=s;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[i]=s;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return r(6,`Unsupported YAML version ${i}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,s,n]=t.match(/^(.*!)([^!]*)$/s);n||r(`The ${t} tag has no suffix`);let i=this.tags[s];if(i)try{return i+decodeURIComponent(n)}catch(o){return r(String(o)),null}return s==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,s]of Object.entries(this.tags))if(t.startsWith(s))return r+xi(t.substring(s.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),n;if(t&&s.length>0&&J(t.contents)){let i={};qe(t.contents,(o,a)=>{J(a)&&a.tag&&(i[a.tag]=!0)}),n=Object.keys(i)}else n=[];for(let[i,o]of s)i==="!!"&&o==="tag:yaml.org,2002:"||t&&!n.some(a=>a.startsWith(o))||r.push(`%TAG ${i} ${o}`);return r.join(`
|
|
449
|
+
`)}};Re.defaultYaml={explicit:!1,version:"1.2"},Re.defaultTags={"!!":"tag:yaml.org,2002:"};function us(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function fs(e){let t=new Set;return qe(e,{Value(r,s){s.anchor&&t.add(s.anchor)}}),t}function ps(e,t){for(let r=1;;++r){let s=`${e}${r}`;if(!t.has(s))return s}}function Si(e,t){let r=[],s=new Map,n=null;return{onAnchor:i=>{r.push(i),n??=fs(e);let o=ps(t,n);return n.add(o),o},setAnchors:()=>{for(let i of r){let o=s.get(i);if(typeof o=="object"&&o.anchor&&(B(o.node)||V(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:s}}function Be(e,t,r,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let n=0,i=s.length;n<i;++n){let o=s[n],a=Be(e,s,String(n),o);a===void 0?delete s[n]:a!==o&&(s[n]=a)}else if(s instanceof Map)for(let n of Array.from(s.keys())){let i=s.get(n),o=Be(e,s,n,i);o===void 0?s.delete(n):o!==i&&s.set(n,o)}else if(s instanceof Set)for(let n of Array.from(s)){let i=Be(e,s,n,n);i===void 0?s.delete(n):i!==n&&(s.delete(n),s.add(i))}else for(let[n,i]of Object.entries(s)){let o=Be(e,s,n,i);o===void 0?delete s[n]:o!==i&&(s[n]=o)}return e.call(t,r,s)}function re(e,t,r){if(Array.isArray(e))return e.map((s,n)=>re(s,String(n),r));if(e&&typeof e.toJSON=="function"){if(!r||!cs(e))return e.toJSON(t,r);let s={aliasCount:0,count:1,res:void 0};r.anchors.set(e,s),r.onCreate=i=>{s.res=i,delete r.onCreate};let n=e.toJSON(t,r);return r.onCreate&&r.onCreate(n),n}return typeof e=="bigint"&&!r?.keep?Number(e):e}var fr=class{constructor(e){Object.defineProperty(this,te,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:r,onAnchor:s,reviver:n}={}){if(!kt(e))throw TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},o=re(this,"",i);if(typeof s=="function")for(let{count:a,res:l}of i.anchors.values())s(l,a);return typeof n=="function"?Be(n,{"":o},"",o):o}},pr=class extends fr{constructor(e){super(cr),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 r;t?.aliasResolveCache?r=t.aliasResolveCache:(r=[],qe(e,{Node:(n,i)=>{(Me(i)||cs(i))&&r.push(i)}}),t&&(t.aliasResolveCache=r));let s;for(let n of r){if(n===this)break;n.anchor===this.source&&(s=n)}if(s&&t){let{anchors:n,doc:i,maxAliasCount:o}=t,a=n.get(s);if(a||=(re(s,null,t),n.get(s)),a?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=$t(i,s,n)),a.count*a.aliasCount>o))throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return s}toJSON(e,t){if(!t)return{source:this.source};let r=this.resolve(t.doc,t);if(!r){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(s)}return t.anchors.get(r).res}toString(e,t,r){let s=`*${this.source}`;if(e){if(us(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let n=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(n)}if(e.implicitKey)return`${s} `}return s}};function $t(e,t,r){if(Me(t)){let s=t.resolve(e),n=r&&s&&r.get(s);return n?n.count*n.aliasCount:0}if(V(t)){let s=0;for(let n of t.items){let i=$t(e,n,r);i>s&&(s=i)}return s}if(W(t)){let s=$t(e,t.key,r),n=$t(e,t.value,r);return Math.max(s,n)}return 1}var ds=e=>!e||typeof e!="function"&&typeof e!="object",N=class extends fr{constructor(e){super(ae),this.value=e}toJSON(e,t){return t?.keep?this.value:re(this.value,e,t)}toString(){return String(this.value)}};N.BLOCK_FOLDED="BLOCK_FOLDED",N.BLOCK_LITERAL="BLOCK_LITERAL",N.PLAIN="PLAIN",N.QUOTE_DOUBLE="QUOTE_DOUBLE",N.QUOTE_SINGLE="QUOTE_SINGLE";var Ai="tag:yaml.org,2002:";function Ii(e,t,r){if(t){let s=r.filter(i=>i.tag===t),n=s.find(i=>!i.format)??s[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find(s=>s.identify?.(e)&&!s.format)}function ot(e,t,r){if(kt(e)&&(e=e.contents),J(e))return e;if(W(e)){let u=r.schema[we].createNode?.(r.schema,null,r);return u.items.push(e),u}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:n,onTagObj:i,schema:o,sourceObjects:a}=r,l;if(s&&e&&typeof e=="object"){if(l=a.get(e),l)return l.anchor??(l.anchor=n(e)),new pr(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=Ai+t.slice(2));let c=Ii(e,t,o.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let u=new N(e);return l&&(l.node=u),u}c=e instanceof Map?o[we]:Symbol.iterator in Object(e)?o[Le]:o[we]}i&&(i(c),delete r.onTagObj);let f=c?.createNode?c.createNode(r.schema,e,r):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(r.schema,e,r):new N(e);return t?f.tag=t:c.default||(f.tag=c.tag),l&&(l.node=f),f}function xt(e,t,r){let s=r;for(let n=t.length-1;n>=0;--n){let i=t[n];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=s,s=o}else s=new Map([[i,s]])}return ot(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var at=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,hs=class extends fr{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(r=>J(r)||W(r)?r.clone(e):r),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(at(e))this.add(t);else{let[r,...s]=e,n=this.get(r,!0);if(V(n))n.addIn(s,t);else if(n===void 0&&this.schema)this.set(r,xt(this.schema,s,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let s=this.get(t,!0);if(V(s))return s.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...s]=e,n=this.get(r,!0);return s.length===0?!t&&B(n)?n.value:n:V(n)?n.getIn(s,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!W(t))return!1;let r=t.value;return r==null||e&&B(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let s=this.get(t,!0);return V(s)?s.hasIn(r):!1}setIn(e,t){let[r,...s]=e;if(s.length===0)this.set(r,t);else{let n=this.get(r,!0);if(V(n))n.setIn(s,t);else if(n===void 0&&this.schema)this.set(r,xt(this.schema,s,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}},Ei=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function pe(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Ee=(e,t,r)=>e.endsWith(`
|
|
450
|
+
`)?pe(r,t):r.includes(`
|
|
451
|
+
`)?`
|
|
452
|
+
`+pe(r,t):(e.endsWith(" ")?"":" ")+r,ms="flow",Oi="block",Ci="quoted";function St(e,t,r="flow",{indentAtStart:s,lineWidth:n=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!n||n<0)return e;n<i&&(i=0);let l=Math.max(1+i,1+n-t.length);if(e.length<=l)return e;let c=[],f={},u=n-t.length;typeof s=="number"&&(s>n-Math.max(2,i)?c.push(0):u=n-s);let d,y,g=!1,p=-1,h=-1,w=-1;r==="block"&&(p=gs(e,p,t.length),p!==-1&&(u=p+l));for(let b;b=e[p+=1];){if(r==="quoted"&&b==="\\"){switch(h=p,e[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}w=p}if(b===`
|
|
453
|
+
`)r==="block"&&(p=gs(e,p,t.length)),u=p+t.length+l,d=void 0;else{if(b===" "&&y&&y!==" "&&y!==`
|
|
454
|
+
`&&y!==" "){let S=e[p+1];S&&S!==" "&&S!==`
|
|
455
|
+
`&&S!==" "&&(d=p)}if(p>=u)if(d)c.push(d),u=d+l,d=void 0;else if(r==="quoted"){for(;y===" "||y===" ";)y=b,b=e[p+=1],g=!0;let S=p>w+1?p-2:h-1;if(f[S])return e;c.push(S),f[S]=!0,u=S+l,d=void 0}else g=!0}y=b}if(g&&a&&a(),c.length===0)return e;o&&o();let $=e.slice(0,c[0]);for(let b=0;b<c.length;++b){let S=c[b],k=c[b+1]||e.length;S===0?$=`
|
|
456
|
+
${t}${e.slice(0,k)}`:(r==="quoted"&&f[S]&&($+=`${e[S]}\\`),$+=`
|
|
457
|
+
${t}${e.slice(S+1,k)}`)}return $}function gs(e,t,r){let s=t,n=t+1,i=e[n];for(;i===" "||i===" ";)if(t<n+r)i=e[++t];else{do i=e[++t];while(i&&i!==`
|
|
458
|
+
`);s=t,n=t+1,i=e[n]}return s}var At=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),It=e=>/^(%|---|\.\.\.)/m.test(e);function _i(e,t,r){if(!t||t<0)return!1;let s=t-r,n=e.length;if(n<=s)return!1;for(let i=0,o=0;i<n;++i)if(e[i]===`
|
|
459
|
+
`){if(i-o>s)return!0;if(o=i+1,n-o<=s)return!1}return!0}function lt(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:s}=t,n=t.options.doubleQuotedMinMultiLineLength,i=t.indent||(It(e)?" ":""),o="",a=0;for(let l=0,c=r[l];c;c=r[++l])if(c===" "&&r[l+1]==="\\"&&r[l+2]==="n"&&(o+=r.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(r[l+1]){case"u":{o+=r.slice(a,l);let f=r.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=r.substr(l,6)}l+=5,a=l+1}break;case"n":if(s||r[l+2]==='"'||r.length<n)l+=1;else{for(o+=r.slice(a,l)+`
|
|
460
|
+
|
|
461
|
+
`;r[l+2]==="\\"&&r[l+3]==="n"&&r[l+4]!=='"';)o+=`
|
|
462
|
+
`,l+=2;o+=i,r[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+r.slice(a):r,s?o:St(o,i,Ci,At(t,!1))}function dr(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
463
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return lt(e,t);let r=t.indent||(It(e)?" ":""),s="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
464
|
+
${r}`)+"'";return t.implicitKey?s:St(s,r,ms,At(t,!1))}function De(e,t){let{singleQuote:r}=t.options,s;if(r===!1)s=lt;else{let n=e.includes('"'),i=e.includes("'");s=n&&!i?dr:i&&!n?lt:r?dr:lt}return s(e,t)}var hr;try{hr=RegExp(`(^|(?<!
|
|
465
|
+
))
|
|
466
|
+
+(?!
|
|
467
|
+
|$)`,"g")}catch{hr=/\n+(?!\n|$)/g}function Et({comment:e,type:t,value:r},s,n,i){let{blockQuote:o,commentString:a,lineWidth:l}=s.options;if(!o||/\n[\t ]+$/.test(r))return De(r,s);let c=s.indent||(s.forceBlockIndent||It(r)?" ":""),f=o==="literal"?!0:o==="folded"||t===N.BLOCK_FOLDED?!1:t===N.BLOCK_LITERAL||!_i(r,l,c.length);if(!r)return f?`|
|
|
468
|
+
`:`>
|
|
469
|
+
`;let u,d;for(d=r.length;d>0;--d){let S=r[d-1];if(S!==`
|
|
470
|
+
`&&S!==" "&&S!==" ")break}let y=r.substring(d),g=y.indexOf(`
|
|
471
|
+
`);g===-1?u="-":r===y||g!==y.length-1?(u="+",i&&i()):u="",y&&=(r=r.slice(0,-y.length),y[y.length-1]===`
|
|
472
|
+
`&&(y=y.slice(0,-1)),y.replace(hr,`$&${c}`));let p=!1,h,w=-1;for(h=0;h<r.length;++h){let S=r[h];if(S===" ")p=!0;else if(S===`
|
|
473
|
+
`)w=h;else break}let $=r.substring(0,w<h?w+1:h);$&&=(r=r.substring($.length),$.replace(/\n+/g,`$&${c}`));let b=(p?c?"2":"1":"")+u;if(e&&(b+=" "+a(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let S=r.replace(/\n+/g,`
|
|
474
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),k=!1,x=At(s,!0);o!=="folded"&&t!==N.BLOCK_FOLDED&&(x.onOverflow=()=>{k=!0});let I=St(`${$}${S}${y}`,c,Oi,x);if(!k)return`>${b}
|
|
475
|
+
${c}${I}`}return r=r.replace(/\n+/g,`$&${c}`),`|${b}
|
|
476
|
+
${c}${$}${r}${y}`}function Ni(e,t,r,s){let{type:n,value:i}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=t;if(a&&i.includes(`
|
|
477
|
+
`)||f&&/[[\]{},]/.test(i))return De(i,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
|
|
478
|
+
`)?De(i,t):Et(e,t,r,s);if(!a&&!f&&n!==N.PLAIN&&i.includes(`
|
|
479
|
+
`))return Et(e,t,r,s);if(It(i)){if(l==="")return t.forceBlockIndent=!0,Et(e,t,r,s);if(a&&l===c)return De(i,t)}let u=i.replace(/\n+/g,`$&
|
|
480
|
+
${l}`);if(o){let d=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(u),{compat:y,tags:g}=t.doc.schema;if(g.some(d)||y?.some(d))return De(i,t)}return a?u:St(u,l,ms,At(t,!1))}function mr(e,t,r,s){let{implicitKey:n,inFlow:i}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;a!==N.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=N.QUOTE_DOUBLE);let l=f=>{switch(f){case N.BLOCK_FOLDED:case N.BLOCK_LITERAL:return n||i?De(o.value,t):Et(o,t,r,s);case N.QUOTE_DOUBLE:return lt(o.value,t);case N.QUOTE_SINGLE:return dr(o.value,t);case N.PLAIN:return Ni(o,t,r,s);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:u}=t.options,d=n&&f||u;if(c=l(d),c===null)throw Error(`Unsupported default string type ${d}`)}return c}function ys(e,t){let r=Object.assign({blockQuote:!0,commentString:Ei,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),s;switch(r.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:s,options:r}}function Ti(e,t){if(t.tag){let n=e.filter(i=>i.tag===t.tag);if(n.length>0)return n.find(i=>i.format===t.format)??n[0]}let r,s;if(B(t)){s=t.value;let n=e.filter(i=>i.identify?.(s));if(n.length>1){let i=n.filter(o=>o.test);i.length>0&&(n=i)}r=n.find(i=>i.format===t.format)??n.find(i=>!i.format)}else s=t,r=e.find(n=>n.nodeClass&&s instanceof n.nodeClass);if(!r){let n=s?.constructor?.name??(s===null?"null":typeof s);throw Error(`Tag not resolved for ${n} value`)}return r}function ji(e,t,{anchors:r,doc:s}){if(!s.directives)return"";let n=[],i=(B(e)||V(e))&&e.anchor;i&&us(i)&&(r.add(i),n.push(`&${i}`));let o=e.tag??(t.default?null:t.tag);return o&&n.push(s.directives.tagString(o)),n.join(" ")}function Ue(e,t,r,s){if(W(e))return e.toString(t,r,s);if(Me(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let n,i=J(e)?e:t.doc.createNode(e,{onTagObj:l=>n=l});n??=Ti(t.doc.schema.tags,i);let o=ji(i,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let a=typeof n.stringify=="function"?n.stringify(i,t,r,s):B(i)?mr(i,t,r,s):i.toString(t,r,s);return o?B(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
481
|
+
${t.indent}${a}`:a}function Li({key:e,value:t},r,s,n){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=r,d=J(e)&&e.comment||null;if(u){if(d)throw Error("With simple keys, key nodes cannot have comments");if(V(e)||!J(e)&&typeof e=="object")throw Error("With simple keys, collection cannot be used as a key value")}let y=!u&&(!e||d&&t==null&&!r.inFlow||V(e)||(B(e)?e.type===N.BLOCK_FOLDED||e.type===N.BLOCK_LITERAL:typeof e=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!y&&(u||!i),indent:a+l});let g=!1,p=!1,h=Ue(e,r,()=>g=!0,()=>p=!0);if(!y&&!r.inFlow&&h.length>1024){if(u)throw Error("With simple keys, single line scalar must not span more than 1024 characters");y=!0}if(r.inFlow){if(i||t==null)return g&&s&&s(),h===""?"?":y?`? ${h}`:h}else if(i&&!u||t==null&&y)return h=`? ${h}`,d&&!g?h+=Ee(h,r.indent,c(d)):p&&n&&n(),h;g&&(d=null),y?(d&&(h+=Ee(h,r.indent,c(d))),h=`? ${h}
|
|
482
|
+
${a}:`):(h=`${h}:`,d&&(h+=Ee(h,r.indent,c(d))));let w,$,b;J(t)?(w=!!t.spaceBefore,$=t.commentBefore,b=t.comment):(w=!1,$=null,b=null,t&&typeof t=="object"&&(t=o.createNode(t))),r.implicitKey=!1,!y&&!d&&B(t)&&(r.indentAtStart=h.length+1),p=!1,!f&&l.length>=2&&!r.inFlow&&!y&&nt(t)&&!t.flow&&!t.tag&&!t.anchor&&(r.indent=r.indent.substring(2));let S=!1,k=Ue(t,r,()=>S=!0,()=>p=!0),x=" ";if(d||w||$){if(x=w?`
|
|
483
|
+
`:"",$){let I=c($);x+=`
|
|
484
|
+
${pe(I,r.indent)}`}k===""&&!r.inFlow?x===`
|
|
485
|
+
`&&b&&(x=`
|
|
486
|
+
|
|
487
|
+
`):x+=`
|
|
488
|
+
${r.indent}`}else if(!y&&V(t)){let I=k[0],A=k.indexOf(`
|
|
489
|
+
`),q=A!==-1,T=r.inFlow??t.flow??t.items.length===0;if(q||!T){let j=!1;if(q&&(I==="&"||I==="!")){let F=k.indexOf(" ");I==="&"&&F!==-1&&F<A&&k[F+1]==="!"&&(F=k.indexOf(" ",F+1)),(F===-1||A<F)&&(j=!0)}j||(x=`
|
|
490
|
+
${r.indent}`)}}else(k===""||k[0]===`
|
|
491
|
+
`)&&(x="");return h+=x+k,r.inFlow?S&&s&&s():b&&!S?h+=Ee(h,r.indent,c(b)):p&&n&&n(),h}function Pa(e,t){}var Ot="<<",de={identify:e=>e===Ot||typeof e=="symbol"&&e.description===Ot,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new N(Symbol(Ot)),{addToJSMap:bs}),stringify:()=>Ot},Mi=(e,t)=>(de.identify(t)||B(t)&&(!t.type||t.type===N.PLAIN)&&de.identify(t.value))&&e?.doc.schema.tags.some(r=>r.tag===de.tag&&r.default);function bs(e,t,r){let s=ws(e,r);if(nt(s))for(let n of s.items)gr(e,t,n);else if(Array.isArray(s))for(let n of s)gr(e,t,n);else gr(e,t,s)}function gr(e,t,r){let s=ws(e,r);if(!st(s))throw Error("Merge sources must be maps or map aliases");let n=s.toJSON(null,e,Map);for(let[i,o]of n)t instanceof Map?t.has(i)||t.set(i,o):t instanceof Set?t.add(i):Object.prototype.hasOwnProperty.call(t,i)||Object.defineProperty(t,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function ws(e,t){return e&&Me(t)?t.resolve(e.doc,e):t}function vs(e,t,{key:r,value:s}){if(J(r)&&r.addToJSMap)r.addToJSMap(e,t,s);else if(Mi(e,r))bs(e,t,s);else{let n=re(r,"",e);if(t instanceof Map)t.set(n,re(s,n,e));else if(t instanceof Set)t.add(n);else{let i=qi(r,n,e),o=re(s,i,e);i in t?Object.defineProperty(t,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[i]=o}}return t}function qi(e,t,r){if(t===null)return"";if(typeof t!="object")return String(t);if(J(e)&&r?.doc){let s=ys(r.doc,{});s.anchors=new Set;for(let i of r.anchors.keys())s.anchors.add(i.anchor);s.inFlow=!0,s.inStringifyKey=!0;let n=e.toString(s);if(!r.mapKeyWarned){let i=JSON.stringify(n);i.length>40&&(i=i.substring(0,36)+'..."'),r.doc.options.logLevel,`${i}`,r.mapKeyWarned=!0}return n}return JSON.stringify(t)}function yr(e,t,r){return new Z(ot(e,void 0,r),ot(t,void 0,r))}var Z=class Tn{constructor(t,r=null){Object.defineProperty(this,te,{value:ls}),this.key=t,this.value=r}clone(t){let{key:r,value:s}=this;return J(r)&&(r=r.clone(t)),J(s)&&(s=s.clone(t)),new Tn(r,s)}toJSON(t,r){return vs(r,r?.mapAsMap?new Map:{},this)}toString(t,r,s){return t?.doc?Li(this,t,r,s):JSON.stringify(this)}};function ks(e,t,r){return(t.inFlow??e.flow?Ri:Pi)(e,t,r)}function Pi({comment:e,items:t},r,{blockItemPrefix:s,flowChars:n,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=r,f=Object.assign({},r,{indent:i,type:null}),u=!1,d=[];for(let g=0;g<t.length;++g){let p=t[g],h=null;if(J(p))!u&&p.spaceBefore&&d.push(""),Ct(r,d,p.commentBefore,u),p.comment&&(h=p.comment);else if(W(p)){let $=J(p.key)?p.key:null;$&&(!u&&$.spaceBefore&&d.push(""),Ct(r,d,$.commentBefore,u))}u=!1;let w=Ue(p,f,()=>h=null,()=>u=!0);h&&(w+=Ee(w,i,c(h))),u&&h&&(u=!1),d.push(s+w)}let y;if(d.length===0)y=n.start+n.end;else{y=d[0];for(let g=1;g<d.length;++g){let p=d[g];y+=p?`
|
|
492
|
+
${l}${p}`:`
|
|
493
|
+
`}}return e?(y+=`
|
|
494
|
+
`+pe(c(e),l),a&&a()):u&&o&&o(),y}function Ri({items:e},t,{flowChars:r,itemIndent:s}){let{indent:n,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=t;s+=i;let l=Object.assign({},t,{indent:s,inFlow:!0,type:null}),c=!1,f=0,u=[];for(let g=0;g<e.length;++g){let p=e[g],h=null;if(J(p))p.spaceBefore&&u.push(""),Ct(t,u,p.commentBefore,!1),p.comment&&(h=p.comment);else if(W(p)){let $=J(p.key)?p.key:null;$&&($.spaceBefore&&u.push(""),Ct(t,u,$.commentBefore,!1),$.comment&&(c=!0));let b=J(p.value)?p.value:null;b?(b.comment&&(h=b.comment),b.commentBefore&&(c=!0)):p.value==null&&$?.comment&&(h=$.comment)}h&&(c=!0);let w=Ue(p,l,()=>h=null);c||=u.length>f||w.includes(`
|
|
495
|
+
`),g<e.length-1?w+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||=u.reduce(($,b)=>$+b.length+2,2)+(w.length+2)>t.options.lineWidth),c&&(w+=",")),h&&(w+=Ee(w,s,a(h))),u.push(w),f=u.length}let{start:d,end:y}=r;if(u.length===0)return d+y;if(!c){let g=u.reduce((p,h)=>p+h.length+2,2);c=t.options.lineWidth>0&&g>t.options.lineWidth}if(c){let g=d;for(let p of u)g+=p?`
|
|
496
|
+
${i}${n}${p}`:`
|
|
497
|
+
`;return`${g}
|
|
498
|
+
${n}${y}`}return`${d}${o}${u.join(" ")}${o}${y}`}function Ct({indent:e,options:{commentString:t}},r,s,n){if(s&&n&&(s=s.replace(/^\n+/,"")),s){let i=pe(t(s),e);r.push(i.trimStart())}}function Oe(e,t){let r=B(t)?t.value:t;for(let s of e)if(W(s)&&(s.key===t||s.key===r||B(s.key)&&s.key.value===r))return s}var se=class extends hs{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(we,e),this.items=[]}static from(e,t,r){let{keepUndefined:s,replacer:n}=r,i=new this(e),o=(a,l)=>{if(typeof n=="function")l=n.call(t,a,l);else if(Array.isArray(n)&&!n.includes(a))return;(l!==void 0||s)&&i.items.push(yr(a,l,r))};if(t instanceof Map)for(let[a,l]of t)o(a,l);else if(t&&typeof t=="object")for(let a of Object.keys(t))o(a,t[a]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,t){let r;r=W(e)?e:!e||typeof e!="object"||!("key"in e)?new Z(e,e?.value):new Z(e.key,e.value);let s=Oe(this.items,r.key),n=this.schema?.sortMapEntries;if(s){if(!t)throw Error(`Key ${r.key} already set`);B(s.value)&&ds(r.value)?s.value.value=r.value:s.value=r.value}else if(n){let i=this.items.findIndex(o=>n(r,o)<0);i===-1?this.items.push(r):this.items.splice(i,0,r)}else this.items.push(r)}delete(e){let t=Oe(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let r=Oe(this.items,e)?.value;return(!t&&B(r)?r.value:r)??void 0}has(e){return!!Oe(this.items,e)}set(e,t){this.add(new Z(e,t),!0)}toJSON(e,t,r){let s=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(s);for(let n of this.items)vs(t,s,n);return s}toString(e,t,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!W(s))throw Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),ks(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}},ze={collection:"map",default:!0,nodeClass:se,tag:"tag:yaml.org,2002:map",resolve(e,t){return st(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,r)=>se.from(e,t,r)},Ce=class extends hs{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Le,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=_t(e);return typeof t=="number"&&this.items.splice(t,1).length>0}get(e,t){let r=_t(e);if(typeof r!="number")return;let s=this.items[r];return!t&&B(s)?s.value:s}has(e){let t=_t(e);return typeof t=="number"&&t<this.items.length}set(e,t){let r=_t(e);if(typeof r!="number")throw Error(`Expected a valid index, not ${e}.`);let s=this.items[r];B(s)&&ds(t)?s.value=t:this.items[r]=t}toJSON(e,t){let r=[];t?.onCreate&&t.onCreate(r);let s=0;for(let n of this.items)r.push(re(n,String(s++),t));return r}toString(e,t,r){return e?ks(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,t,r){let{replacer:s}=r,n=new this(e);if(t&&Symbol.iterator in Object(t)){let i=0;for(let o of t){if(typeof s=="function"){let a=t instanceof Set?o:String(i++);o=s.call(t,a,o)}n.items.push(ot(o,void 0,r))}}return n}};function _t(e){let t=B(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}var Ke={collection:"seq",default:!0,nodeClass:Ce,tag:"tag:yaml.org,2002:seq",resolve(e,t){return nt(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,r)=>Ce.from(e,t,r)},Nt={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,r,s){return t=Object.assign({actualString:!0},t),mr(e,t,r,s)}},Tt={identify:e=>e==null,createNode:()=>new N(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new N(null),stringify:({source:e},t)=>typeof e=="string"&&Tt.test.test(e)?e:t.options.nullStr},br={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new N(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){return e&&br.test.test(e)&&t===(e[0]==="t"||e[0]==="T")?e:t?r.options.trueStr:r.options.falseStr}};function ie({format:e,minFractionDigits:t,tag:r,value:s}){if(typeof s=="bigint")return String(s);let n=typeof s=="number"?s:Number(s);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let i=Object.is(s,-0)?"-0":JSON.stringify(s);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let o=i.indexOf(".");o<0&&(o=i.length,i+=".");let a=t-(i.length-o-1);for(;a-- >0;)i+="0"}return i}var $s={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]==="-"?-1/0:1/0,stringify:ie},xs={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():ie(e)}},Ss={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 N(parseFloat(e)),r=e.indexOf(".");return r!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-r-1),t},stringify:ie},jt=e=>typeof e=="bigint"||Number.isInteger(e),wr=(e,t,r,{intAsBigInt:s})=>s?BigInt(e):parseInt(e.substring(t),r);function As(e,t,r){let{value:s}=e;return jt(s)&&s>=0?r+s.toString(t):ie(e)}var Is={identify:e=>jt(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>wr(e,2,8,r),stringify:e=>As(e,8,"0o")},Es={identify:jt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>wr(e,0,10,r),stringify:ie},Os={identify:e=>jt(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>wr(e,2,16,r),stringify:e=>As(e,16,"0x")},Bi=[ze,Ke,Nt,Tt,br,Is,Es,Os,$s,xs,Ss];function Cs(e){return typeof e=="bigint"||Number.isInteger(e)}var Lt=({value:e})=>JSON.stringify(e),Di=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Lt},{identify:e=>e==null,createNode:()=>new N(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Lt},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Lt},{identify:Cs,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>Cs(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:Lt}],Ui=[ze,Ke].concat(Di,{default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),vr={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof atob=="function"){let r=atob(e.replace(/[\n\r]/g,"")),s=new Uint8Array(r.length);for(let n=0;n<r.length;++n)s[n]=r.charCodeAt(n);return s}return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},s,n,i){if(!r)return"";let o=r,a;if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??=N.BLOCK_LITERAL,t!==N.QUOTE_DOUBLE){let l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(a.length/l),f=Array(c);for(let u=0,d=0;u<c;++u,d+=l)f[u]=a.substr(d,l);a=f.join(t===N.BLOCK_LITERAL?`
|
|
499
|
+
`:" ")}return mr({comment:e,type:t,value:a},s,n,i)}};function _s(e,t){if(nt(e))for(let r=0;r<e.items.length;++r){let s=e.items[r];if(!W(s)){if(st(s)){s.items.length>1&&t("Each pair must have its own sequence indicator");let n=s.items[0]||new Z(new N(null));if(s.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${s.commentBefore}
|
|
500
|
+
${n.key.commentBefore}`:s.commentBefore),s.comment){let i=n.value??n.key;i.comment=i.comment?`${s.comment}
|
|
501
|
+
${i.comment}`:s.comment}s=n}e.items[r]=W(s)?s:new Z(s)}}else t("Expected a sequence for this tag");return e}function Ns(e,t,r){let{replacer:s}=r,n=new Ce(e);n.tag="tag:yaml.org,2002:pairs";let i=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof s=="function"&&(o=s.call(t,String(i++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;n.items.push(yr(a,l,r))}return n}var kr={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:_s,createNode:Ns},Mt=class jn extends Ce{constructor(){super(),this.add=se.prototype.add.bind(this),this.delete=se.prototype.delete.bind(this),this.get=se.prototype.get.bind(this),this.has=se.prototype.has.bind(this),this.set=se.prototype.set.bind(this),this.tag=jn.tag}toJSON(t,r){if(!r)return super.toJSON(t);let s=new Map;r?.onCreate&&r.onCreate(s);for(let n of this.items){let i,o;if(W(n)?(i=re(n.key,"",r),o=re(n.value,i,r)):i=re(n,"",r),s.has(i))throw Error("Ordered maps must not include duplicate keys");s.set(i,o)}return s}static from(t,r,s){let n=Ns(t,r,s),i=new this;return i.items=n.items,i}};Mt.tag="tag:yaml.org,2002:omap";var $r={collection:"seq",identify:e=>e instanceof Map,nodeClass:Mt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=_s(e,t),s=[];for(let{key:n}of r.items)B(n)&&(s.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):s.push(n.value));return Object.assign(new Mt,r)},createNode:(e,t,r)=>Mt.from(e,t,r)};function Ts({value:e,source:t},r){return t&&(e?js:Ls).test.test(t)?t:e?r.options.trueStr:r.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 N(!0),stringify:Ts},Ls={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 N(!1),stringify:Ts},zi={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]==="-"?-1/0:1/0,stringify:ie},Ki={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():ie(e)}},Hi={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 N(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let s=e.substring(r+1).replace(/_/g,"");s[s.length-1]==="0"&&(t.minFractionDigits=s.length)}return t},stringify:ie},ct=e=>typeof e=="bigint"||Number.isInteger(e);function qt(e,t,r,{intAsBigInt:s}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),s){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let i=parseInt(e,r);return n==="-"?-1*i:i}function xr(e,t,r){let{value:s}=e;if(ct(s)){let n=s.toString(t);return s<0?"-"+r+n.substr(1):r+n}return ie(e)}var Fi={identify:ct,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>qt(e,2,2,r),stringify:e=>xr(e,2,"0b")},Wi={identify:ct,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>qt(e,1,8,r),stringify:e=>xr(e,8,"0")},Vi={identify:ct,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>qt(e,0,10,r),stringify:ie},Ji={identify:ct,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>qt(e,2,16,r),stringify:e=>xr(e,16,"0x")},Pt=class Ln extends se{constructor(t){super(t),this.tag=Ln.tag}add(t){let r;r=W(t)?t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?new Z(t.key,null):new Z(t,null),Oe(this.items,r.key)||this.items.push(r)}get(t,r){let s=Oe(this.items,t);return!r&&W(s)?B(s.key)?s.key.value:s.key:s}set(t,r){if(typeof r!="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let s=Oe(this.items,t);s&&!r?this.items.splice(this.items.indexOf(s),1):!s&&r&&this.items.push(new Z(t))}toJSON(t,r){return super.toJSON(t,r,Set)}toString(t,r,s){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),r,s);throw Error("Set items must all have null values")}static from(t,r,s){let{replacer:n}=s,i=new this(t);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof n=="function"&&(o=n.call(r,o,o)),i.items.push(yr(o,null,s));return i}};Pt.tag="tag:yaml.org,2002:set";var Sr={collection:"map",identify:e=>e instanceof Set,nodeClass:Pt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>Pt.from(e,t,r),resolve(e,t){if(st(e)){if(e.hasAllNullValues(!0))return Object.assign(new Pt,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};function Ar(e,t){let r=e[0],s=r==="-"||r==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),i=s.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return r==="-"?n(-1)*i:i}function Ms(e){let{value:t}=e,r=o=>o;if(typeof t=="bigint")r=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return ie(e);let s="";t<0&&(s="-",t*=r(-1));let n=r(60),i=[t%n];return t<60?i.unshift(0):(t=(t-i[0])/n,i.unshift(t%n),t>=60&&(t=(t-i[0])/n,i.unshift(t))),s+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var qs={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:r})=>Ar(e,r),stringify:Ms},Ps={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=>Ar(e,!1),stringify:Ms},Rt={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(Rt.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,s,n,i,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(r,s-1,n,i||0,o||0,a||0,l),f=t[8];if(f&&f!=="Z"){let u=Ar(f,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},Rs=[ze,Ke,Nt,Tt,js,Ls,Fi,Wi,Vi,Ji,zi,Ki,Hi,vr,de,$r,kr,Sr,qs,Ps,Rt],Bs=new Map([["core",Bi],["failsafe",[ze,Ke,Nt]],["json",Ui],["yaml11",Rs],["yaml-1.1",Rs]]),Ds={binary:vr,bool:br,float:Ss,floatExp:xs,floatNaN:$s,floatTime:Ps,int:Es,intHex:Os,intOct:Is,intTime:qs,map:ze,merge:de,null:Tt,omap:$r,pairs:kr,seq:Ke,set:Sr,timestamp:Rt},Gi={"tag:yaml.org,2002:binary":vr,"tag:yaml.org,2002:merge":de,"tag:yaml.org,2002:omap":$r,"tag:yaml.org,2002:pairs":kr,"tag:yaml.org,2002:set":Sr,"tag:yaml.org,2002:timestamp":Rt};function Ir(e,t,r){let s=Bs.get(t);if(s&&!e)return r&&!s.includes(de)?s.concat(de):s.slice();let n=s;if(!n)if(Array.isArray(e))n=[];else{let i=Array.from(Bs.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${i} or define customTags array`)}if(Array.isArray(e))for(let i of e)n=n.concat(i);else typeof e=="function"&&(n=e(n.slice()));return r&&(n=n.concat(de)),n.reduce((i,o)=>{let a=typeof o=="string"?Ds[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Ds).map(f=>JSON.stringify(f)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}return i.includes(a)||i.push(a),i},[])}var Yi=(e,t)=>e.key<t.key?-1:+(e.key>t.key),Qi=class Mn{constructor({compat:t,customTags:r,merge:s,resolveKnownTags:n,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?Ir(t,"compat"):t?Ir(null,t):null,this.name=typeof i=="string"&&i||"core",this.knownTags=n?Gi:{},this.tags=Ir(r,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,we,{value:ze}),Object.defineProperty(this,ae,{value:Nt}),Object.defineProperty(this,Le,{value:Ke}),this.sortMapEntries=typeof o=="function"?o:o===!0?Yi:null}clone(){let t=Object.create(Mn.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function Xi(e,t){let r=[],s=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);l?(r.push(l),s=!0):e.directives.docStart&&(s=!0)}s&&r.push("---");let n=ys(e,t),{commentString:i}=n.options;if(e.commentBefore){r.length!==1&&r.unshift("");let l=i(e.commentBefore);r.unshift(pe(l,""))}let o=!1,a=null;if(e.contents){if(J(e.contents)){if(e.contents.spaceBefore&&s&&r.push(""),e.contents.commentBefore){let f=i(e.contents.commentBefore);r.push(pe(f,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Ue(e.contents,n,()=>a=null,l);a&&(c+=Ee(c,"",i(a))),(c[0]==="|"||c[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${c}`:r.push(c)}else r.push(Ue(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=i(e.comment);l.includes(`
|
|
502
|
+
`)?(r.push("..."),r.push(pe(l,""))):r.push(`... ${l}`)}else r.push("...");else{let l=e.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&r[r.length-1]!==""&&r.push(""),r.push(pe(i(l),"")))}return r.join(`
|
|
503
|
+
`)+`
|
|
504
|
+
`}var Us=class qn{constructor(t,r,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,te,{value:ur});let n=null;typeof r=="function"||Array.isArray(r)?n=r:s===void 0&&r&&(s=r,r=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=i;let{version:o}=i;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Re({version:o}),this.setSchema(o,s),this.contents=t===void 0?null:this.createNode(t,n,s)}clone(){let t=Object.create(qn.prototype,{[te]:{value:ur}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=J(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){He(this.contents)&&this.contents.add(t)}addIn(t,r){He(this.contents)&&this.contents.addIn(t,r)}createAlias(t,r){if(!t.anchor){let s=fs(this);t.anchor=!r||s.has(r)?ps(r||"a",s):r}return new pr(t.anchor)}createNode(t,r,s){let n;if(typeof r=="function")t=r.call({"":t},"",t),n=r;else if(Array.isArray(r)){let h=r.filter(w=>typeof w=="number"||w instanceof String||w instanceof Number).map(String);h.length>0&&(r=r.concat(h)),n=r}else s===void 0&&r&&(s=r,r=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=s??{},{onAnchor:u,setAnchors:d,sourceObjects:y}=Si(this,o||"a"),g={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:y},p=ot(t,f,g);return a&&V(p)&&(p.flow=!0),d(),p}createPair(t,r,s={}){return new Z(this.createNode(t,null,s),this.createNode(r,null,s))}delete(t){return He(this.contents)?this.contents.delete(t):!1}deleteIn(t){return at(t)?this.contents!=null&&(this.contents=null,!0):He(this.contents)?this.contents.deleteIn(t):!1}get(t,r){return V(this.contents)?this.contents.get(t,r):void 0}getIn(t,r){return at(t)?!r&&B(this.contents)?this.contents.value:this.contents:V(this.contents)?this.contents.getIn(t,r):void 0}has(t){return V(this.contents)?this.contents.has(t):!1}hasIn(t){return at(t)?this.contents!==void 0:V(this.contents)?this.contents.hasIn(t):!1}set(t,r){this.contents==null?this.contents=xt(this.schema,[t],r):He(this.contents)&&this.contents.set(t,r)}setIn(t,r){at(t)?this.contents=r:this.contents==null?this.contents=xt(this.schema,Array.from(t),r):He(this.contents)&&this.contents.setIn(t,r)}setSchema(t,r={}){typeof t=="number"&&(t=String(t));let s;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Re({version:"1.1"}),s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new Re({version:t}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{let n=JSON.stringify(t);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(s)this.schema=new Qi(Object.assign(s,r));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:r,mapAsMap:s,maxAliasCount:n,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!t,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},l=re(this.contents,r??"",a);if(typeof i=="function")for(let{count:c,res:f}of a.anchors.values())i(f,c);return typeof o=="function"?Be(o,{"":l},"",l):l}toJSON(t,r){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:r})}toString(t={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let r=JSON.stringify(t.indent);throw Error(`"indent" option must be a positive integer, not ${r}`)}return Xi(this,t)}};function He(e){if(V(e))return!0;throw Error("Expected a YAML collection as document contents")}var zs=class extends Error{constructor(e,t,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=t}},ut=class extends zs{constructor(e,t,r){super("YAMLParseError",e,t,r)}},Zi=class extends zs{constructor(e,t,r){super("YAMLWarning",e,t,r)}},Ks=(e,t)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(a=>t.linePos(a));let{line:s,col:n}=r.linePos[0];r.message+=` at line ${s}, column ${n}`;let i=n-1,o=e.substring(t.lineStarts[s-1],t.lineStarts[s]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),s>1&&/^ *$/.test(o.substring(0,i))){let a=e.substring(t.lineStarts[s-2],t.lineStarts[s-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
505
|
+
`),o=a+o}if(/[^ ]/.test(o)){let a=1,l=r.linePos[1];l?.line===s&&l.col>n&&(a=Math.max(1,Math.min(l.col-n,80-i)));let c=" ".repeat(i)+"^".repeat(a);r.message+=`:
|
|
506
|
+
|
|
507
|
+
${o}
|
|
508
|
+
${c}
|
|
509
|
+
`}};function Fe(e,{flow:t,indicator:r,next:s,offset:n,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,u="",d="",y=!1,g=!1,p=null,h=null,w=null,$=null,b=null,S=null,k=null;for(let A of e)switch(g&&=(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma"&&i(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),!1),p&&=(c&&A.type!=="comment"&&A.type!=="newline"&&i(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),null),A.type){case"space":!t&&(r!=="doc-start"||s?.type!=="flow-collection")&&A.source.includes(" ")&&(p=A),f=!0;break;case"comment":{f||i(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let q=A.source.substring(1)||" ";u?u+=d+q:u=q,d="",c=!1;break}case"newline":c?u?u+=A.source:S&&r==="seq-item-ind"||(l=!0):d+=A.source,c=!0,y=!0,(h||w)&&($=A),f=!0;break;case"anchor":h&&i(A,"MULTIPLE_ANCHORS","A node can have at most one anchor"),A.source.endsWith(":")&&i(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=A,k??=A.offset,c=!1,f=!1,g=!0;break;case"tag":w&&i(A,"MULTIPLE_TAGS","A node can have at most one tag"),w=A,k??=A.offset,c=!1,f=!1,g=!0;break;case r:(h||w)&&i(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`),S&&i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${t??"collection"}`),S=A,c=r==="seq-item-ind"||r==="explicit-key-ind",f=!1;break;case"comma":if(t){b&&i(A,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),b=A,c=!1,f=!1;break}default:i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),c=!1,f=!1}let x=e[e.length-1],I=x?x.offset+x.source.length:n;return g&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&i(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(c&&p.indent<=o||s?.type==="block-map"||s?.type==="block-seq")&&i(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:S,spaceBefore:l,comment:u,hasNewline:y,anchor:h,tag:w,newlineAfterProp:$,end:I,start:k??I}}function ft(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
|
|
510
|
+
`))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 r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(ft(t.key)||ft(t.value))return!0}return!1;default:return!0}}function Er(e,t,r){if(t?.type==="flow-collection"){let s=t.end[0];s.indent===e&&(s.source==="]"||s.source==="}")&&ft(t)&&r(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Hs(e,t,r){let{uniqueKeys:s}=e.options;if(s===!1)return!1;let n=typeof s=="function"?s:(i,o)=>i===o||B(i)&&B(o)&&i.value===o.value;return t.some(i=>n(i.key,r))}var Fs="All mapping items must start at the same column";function eo({composeNode:e,composeEmptyNode:t},r,s,n,i){let o=new(i?.nodeClass??se)(r.schema);r.atRoot&&=!1;let a=s.offset,l=null;for(let c of s.items){let{start:f,key:u,sep:d,value:y}=c,g=Fe(f,{indicator:"explicit-key-ind",next:u??d?.[0],offset:a,onError:n,parentIndent:s.indent,startOnNewline:!0}),p=!g.found;if(p){if(u&&(u.type==="block-seq"?n(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==s.indent&&n(a,"BAD_INDENT",Fs)),!g.anchor&&!g.tag&&!d){l=g.end,g.comment&&(o.comment?o.comment+=`
|
|
511
|
+
`+g.comment:o.comment=g.comment);continue}(g.newlineAfterProp||ft(u))&&n(u??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else g.found?.indent!==s.indent&&n(a,"BAD_INDENT",Fs);r.atKey=!0;let h=g.end,w=u?e(r,u,g,n):t(r,h,f,null,g,n);r.schema.compat&&Er(s.indent,u,n),r.atKey=!1,Hs(r,o.items,w)&&n(h,"DUPLICATE_KEY","Map keys must be unique");let $=Fe(d??[],{indicator:"map-value-ind",next:y,offset:w.range[2],onError:n,parentIndent:s.indent,startOnNewline:!u||u.type==="block-scalar"});if(a=$.end,$.found){p&&(y?.type==="block-map"&&!$.hasNewline&&n(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&g.start<$.found.offset-1024&&n(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let b=y?e(r,y,$,n):t(r,a,d,null,$,n);r.schema.compat&&Er(s.indent,y,n),a=b.range[2];let S=new Z(w,b);r.options.keepSourceTokens&&(S.srcToken=c),o.items.push(S)}else{p&&n(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),$.comment&&(w.comment?w.comment+=`
|
|
512
|
+
`+$.comment:w.comment=$.comment);let b=new Z(w);r.options.keepSourceTokens&&(b.srcToken=c),o.items.push(b)}}return l&&l<a&&n(l,"IMPOSSIBLE","Map comment with trailing content"),o.range=[s.offset,a,l??a],o}function to({composeNode:e,composeEmptyNode:t},r,s,n,i){let o=new(i?.nodeClass??Ce)(r.schema);r.atRoot&&=!1,r.atKey&&=!1;let a=s.offset,l=null;for(let{start:c,value:f}of s.items){let u=Fe(c,{indicator:"seq-item-ind",next:f,offset:a,onError:n,parentIndent:s.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||f)f?.type==="block-seq"?n(u.end,"BAD_INDENT","All sequence items must start at the same column"):n(a,"MISSING_CHAR","Sequence item without - indicator");else{l=u.end,u.comment&&(o.comment=u.comment);continue}let d=f?e(r,f,u,n):t(r,u.end,c,null,u,n);r.schema.compat&&Er(s.indent,f,n),a=d.range[2],o.items.push(d)}return o.range=[s.offset,a,l??a],o}function pt(e,t,r,s){let n="";if(e){let i=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{r&&!i&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=l),i=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:n,offset:t}}var Or="Block collections are not allowed within flow collections",Cr=e=>e&&(e.type==="block-map"||e.type==="block-seq");function ro({composeNode:e,composeEmptyNode:t},r,s,n,i){let o=s.start.source==="{",a=o?"flow map":"flow sequence",l=new(i?.nodeClass??(o?se:Ce))(r.schema);l.flow=!0;let c=r.atRoot;c&&(r.atRoot=!1),r.atKey&&=!1;let f=s.offset+s.start.source.length;for(let p=0;p<s.items.length;++p){let h=s.items[p],{start:w,key:$,sep:b,value:S}=h,k=Fe(w,{flow:a,indicator:"explicit-key-ind",next:$??b?.[0],offset:f,onError:n,parentIndent:s.indent,startOnNewline:!1});if(!k.found){if(!k.anchor&&!k.tag&&!b&&!S){p===0&&k.comma?n(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):p<s.items.length-1&&n(k.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),k.comment&&(l.comment?l.comment+=`
|
|
513
|
+
`+k.comment:l.comment=k.comment),f=k.end;continue}!o&&r.options.strict&&ft($)&&n($,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(p===0)k.comma&&n(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(k.comma||n(k.start,"MISSING_CHAR",`Missing , between ${a} items`),k.comment){let x="";e:for(let I of w)switch(I.type){case"comma":case"space":break;case"comment":x=I.source.substring(1);break e;default:break e}if(x){let I=l.items[l.items.length-1];W(I)&&(I=I.value??I.key),I.comment?I.comment+=`
|
|
514
|
+
`+x:I.comment=x,k.comment=k.comment.substring(x.length+1)}}if(!o&&!b&&!k.found){let x=S?e(r,S,k,n):t(r,k.end,b,null,k,n);l.items.push(x),f=x.range[2],Cr(S)&&n(x.range,"BLOCK_IN_FLOW",Or)}else{r.atKey=!0;let x=k.end,I=$?e(r,$,k,n):t(r,x,w,null,k,n);Cr($)&&n(I.range,"BLOCK_IN_FLOW",Or),r.atKey=!1;let A=Fe(b??[],{flow:a,indicator:"map-value-ind",next:S,offset:I.range[2],onError:n,parentIndent:s.indent,startOnNewline:!1});if(A.found){if(!o&&!k.found&&r.options.strict){if(b)for(let j of b){if(j===A.found)break;if(j.type==="newline"){n(j,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}k.start<A.found.offset-1024&&n(A.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?n(S,"MISSING_CHAR",`Missing space after : in ${a}`):n(A.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let q=S?e(r,S,A,n):A.found?t(r,A.end,b,null,A,n):null;q?Cr(S)&&n(q.range,"BLOCK_IN_FLOW",Or):A.comment&&(I.comment?I.comment+=`
|
|
515
|
+
`+A.comment:I.comment=A.comment);let T=new Z(I,q);if(r.options.keepSourceTokens&&(T.srcToken=h),o){let j=l;Hs(r,j.items,I)&&n(x,"DUPLICATE_KEY","Map keys must be unique"),j.items.push(T)}else{let j=new se(r.schema);j.flow=!0,j.items.push(T);let F=(q??I).range;j.range=[I.range[0],F[1],F[2]],l.items.push(j)}f=q?q.range[2]:A.end}}let u=o?"}":"]",[d,...y]=s.end,g=f;if(d?.source===u)g=d.offset+d.source.length;else{let p=a[0].toUpperCase()+a.substring(1),h=c?`${p} must end with a ${u}`:`${p} in block collection must be sufficiently indented and end with a ${u}`;n(f,c?"MISSING_CHAR":"BAD_INDENT",h),d&&d.source.length!==1&&y.unshift(d)}if(y.length>0){let p=pt(y,g,r.options.strict,n);p.comment&&(l.comment?l.comment+=`
|
|
516
|
+
`+p.comment:l.comment=p.comment),l.range=[s.offset,g,p.offset]}else l.range=[s.offset,g,g];return l}function _r(e,t,r,s,n,i){let o=r.type==="block-map"?eo(e,t,r,s,i):r.type==="block-seq"?to(e,t,r,s,i):ro(e,t,r,s,i),a=o.constructor;return n==="!"||n===a.tagName?(o.tag=a.tagName,o):(n&&(o.tag=n),o)}function so(e,t,r,s,n){let i=s.tag,o=i?t.directives.tagName(i.source,d=>n(i,"TAG_RESOLVE_FAILED",d)):null;if(r.type==="block-seq"){let{anchor:d,newlineAfterProp:y}=s,g=d&&i?d.offset>i.offset?d:i:d??i;g&&(!y||y.offset<g.offset)&&n(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===se.tagName&&a==="map"||o===Ce.tagName&&a==="seq")return _r(e,t,r,n,o);let l=t.schema.tags.find(d=>d.tag===o&&d.collection===a);if(!l){let d=t.schema.knownTags[o];if(d?.collection===a)t.schema.tags.push(Object.assign({},d,{default:!1})),l=d;else return d?n(i,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),_r(e,t,r,n,o)}let c=_r(e,t,r,n,o,l),f=l.resolve?.(c,d=>n(i,"TAG_RESOLVE_FAILED",d),t.options)??c,u=J(f)?f:new N(f);return u.range=c.range,u.tag=o,l?.format&&(u.format=l.format),u}function no(e,t,r){let s=t.offset,n=io(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[s,s,s]};let i=n.mode===">"?N.BLOCK_FOLDED:N.BLOCK_LITERAL,o=t.source?oo(t.source):[],a=o.length;for(let p=o.length-1;p>=0;--p){let h=o[p][1];if(h===""||h==="\r")a=p;else break}if(a===0){let p=n.chomp==="+"&&o.length>0?`
|
|
517
|
+
`.repeat(Math.max(1,o.length-1)):"",h=s+n.length;return t.source&&(h+=t.source.length),{value:p,type:i,comment:n.comment,range:[s,h,h]}}let l=t.indent+n.indent,c=t.offset+n.length,f=0;for(let p=0;p<a;++p){let[h,w]=o[p];if(w===""||w==="\r")n.indent===0&&h.length>l&&(l=h.length);else{h.length<l&&r(c+h.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(l=h.length),f=p,l===0&&!e.atRoot&&r(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=h.length+w.length+1}for(let p=o.length-1;p>=a;--p)o[p][0].length>l&&(a=p+1);let u="",d="",y=!1;for(let p=0;p<f;++p)u+=o[p][0].slice(l)+`
|
|
518
|
+
`;for(let p=f;p<a;++p){let[h,w]=o[p];c+=h.length+w.length+1;let $=w[w.length-1]==="\r";if($&&(w=w.slice(0,-1)),w&&h.length<l){let b=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(c-w.length-($?2:1),"BAD_INDENT",b),h=""}i===N.BLOCK_LITERAL?(u+=d+h.slice(l)+w,d=`
|
|
519
|
+
`):h.length>l||w[0]===" "?(d===" "?d=`
|
|
520
|
+
`:!y&&d===`
|
|
521
|
+
`&&(d=`
|
|
522
|
+
|
|
523
|
+
`),u+=d+h.slice(l)+w,d=`
|
|
524
|
+
`,y=!0):w===""?d===`
|
|
525
|
+
`?u+=`
|
|
526
|
+
`:d=`
|
|
527
|
+
`:(u+=d+w,d=" ",y=!1)}switch(n.chomp){case"-":break;case"+":for(let p=a;p<o.length;++p)u+=`
|
|
528
|
+
`+o[p][0].slice(l);u[u.length-1]!==`
|
|
529
|
+
`&&(u+=`
|
|
530
|
+
`);break;default:u+=`
|
|
531
|
+
`}let g=s+n.length+t.source.length;return{value:u,type:i,comment:n.comment,range:[s,g,g]}}function io({offset:e,props:t},r,s){if(t[0].type!=="block-scalar-header")return s(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],i=n[0],o=0,a="",l=-1;for(let d=1;d<n.length;++d){let y=n[d];if(!a&&(y==="-"||y==="+"))a=y;else{let g=Number(y);!o&&g?o=g:l===-1&&(l=e+d)}}l!==-1&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let c=!1,f="",u=n.length;for(let d=1;d<t.length;++d){let y=t[d];switch(y.type){case"space":c=!0;case"newline":u+=y.source.length;break;case"comment":r&&!c&&s(y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=y.source.length,f=y.source.substring(1);break;case"error":s(y,"UNEXPECTED_TOKEN",y.message),u+=y.source.length;break;default:{s(y,"UNEXPECTED_TOKEN",`Unexpected token in block scalar header: ${y.type}`);let g=y.source;g&&typeof g=="string"&&(u+=g.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:u}}function oo(e){let t=e.split(/\n( *)/),r=t[0],s=r.match(/^( *)/),n=[s?.[1]?[s[1],r.slice(s[1].length)]:["",r]];for(let i=1;i<t.length;i+=2)n.push([t[i],t[i+1]]);return n}function ao(e,t,r){let{offset:s,type:n,source:i,end:o}=e,a,l,c=(d,y,g)=>r(s+d,y,g);switch(n){case"scalar":a=N.PLAIN,l=lo(i,c);break;case"single-quoted-scalar":a=N.QUOTE_SINGLE,l=co(i,c);break;case"double-quoted-scalar":a=N.QUOTE_DOUBLE,l=uo(i,c);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[s,s+i.length,s+i.length]}}let f=s+i.length,u=pt(o,f,t,r);return{value:l,type:a,comment:u.comment,range:[s,f,u.offset]}}function lo(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":r=`block scalar indicator ${e[0]}`;break;case"@":case"`":r=`reserved character ${e[0]}`}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),Ws(e)}function co(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),Ws(e.slice(1,-1)).replace(/''/g,"'")}function Ws(e){let t=/(.*?)\r?\n/sy,r=t.exec(e);if(!r)return e;let s,n;try{s=RegExp("(?<![ ])[ ]+$"),n=RegExp("^[ ]+|(?<![ ])[ ]+$","g")}catch{s=/[ \t]+$/,n=/^[ \t]+|[ \t]+$/g}let i=r[1].replace(s,""),o=" ",a=t.lastIndex;for(;r=t.exec(e);){let c=r[1].replace(n,"");c===""?o===`
|
|
532
|
+
`?i+=o:o=`
|
|
533
|
+
`:(i+=o+c,o=" "),a=t.lastIndex}let l=/[ \t]*(.*)/sy;return l.lastIndex=a,r=l.exec(e),i+o+(r?.[1]??"")}function uo(e,t){let r="";for(let s=1;s<e.length-1;++s){let n=e[s];if(n!=="\r"||e[s+1]!==`
|
|
534
|
+
`)if(n===`
|
|
535
|
+
`){let{fold:i,offset:o}=fo(e,s);r+=i,s=o}else if(n==="\\"){let i=e[++s],o=po[i];if(o)r+=o;else if(i===`
|
|
536
|
+
`)for(i=e[s+1];i===" "||i===" ";)i=e[++s+1];else if(i==="\r"&&e[s+1]===`
|
|
537
|
+
`)for(i=e[++s+1];i===" "||i===" ";)i=e[++s+1];else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;r+=ho(e,s+1,a,t),s+=a}else{let a=e.substr(s-1,2);t(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(n===" "||n===" "){let i=s,o=e[s+1];for(;o===" "||o===" ";)o=e[++s+1];o!==`
|
|
538
|
+
`&&(o!=="\r"||e[s+2]!==`
|
|
539
|
+
`)&&(r+=s>i?e.slice(i,s+1):n)}else r+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}function fo(e,t){let r="",s=e[t+1];for(;(s===" "||s===" "||s===`
|
|
540
|
+
`||s==="\r")&&(s!=="\r"||e[t+2]===`
|
|
541
|
+
`);)s===`
|
|
542
|
+
`&&(r+=`
|
|
543
|
+
`),t+=1,s=e[t+1];return r||=" ",{fold:r,offset:t}}var po={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
544
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function ho(e,t,r,s){let n=e.substr(t,r),i=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(i)}catch{let o=e.substr(t-2,r+2);return s(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${o}`),o}}function Vs(e,t,r,s){let{value:n,type:i,comment:o,range:a}=t.type==="block-scalar"?no(e,t,s):ao(t,e.options.strict,s),l=r?e.directives.tagName(r.source,u=>s(r,"TAG_RESOLVE_FAILED",u)):null,c;c=e.options.stringKeys&&e.atKey?e.schema[ae]:l?mo(e.schema,n,l,r,s):t.type==="scalar"?go(e,n,t,s):e.schema[ae];let f;try{let u=c.resolve(n,d=>s(r??t,"TAG_RESOLVE_FAILED",d),e.options);f=B(u)?u:new N(u)}catch(u){let d=u instanceof Error?u.message:String(u);s(r??t,"TAG_RESOLVE_FAILED",d),f=new N(n)}return f.range=a,f.source=n,i&&(f.type=i),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function mo(e,t,r,s,n){if(r==="!")return e[ae];let i=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(t))return a;let o=e.knownTags[r];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[ae])}function go({atKey:e,directives:t,schema:r},s,n,i){let o=r.tags.find(a=>(a.default===!0||e&&a.default==="key")&&a.test?.test(s))||r[ae];if(r.compat){let a=r.compat.find(l=>l.default&&l.test?.test(s))??r[ae];o.tag!==a.tag&&i(n,"TAG_RESOLVE_FAILED",`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(a.tag)}`,!0)}return o}function yo(e,t,r){if(t){r??=t.length;for(let s=r-1;s>=0;--s){let n=t[s];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++s];n?.type==="space";)e+=n.source.length,n=t[++s];break}}return e}var bo={composeNode:Js,composeEmptyNode:Nr};function Js(e,t,r,s){let n=e.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=r,c,f=!0;switch(t.type){case"alias":c=wo(e,t,s),(a||l)&&s(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":c=Vs(e,t,l,s),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=so(bo,e,t,r,s),a&&(c.anchor=a.source.substring(1))}catch(u){s(t,"RESOURCE_EXHAUSTION",u instanceof Error?u.message:String(u))}break;default:s(t,"UNEXPECTED_TOKEN",t.type==="error"?t.message:`Unsupported token (type: ${t.type})`),f=!1}return c??=Nr(e,t.offset,void 0,null,r,s),a&&c.anchor===""&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),n&&e.options.stringKeys&&(!B(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(c.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?c.comment=o:c.commentBefore=o),e.options.keepSourceTokens&&f&&(c.srcToken=t),c}function Nr(e,t,r,s,{spaceBefore:n,comment:i,anchor:o,tag:a,end:l},c){let f=Vs(e,{type:"scalar",offset:yo(t,r,s),indent:-1,source:""},a,c);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(f.spaceBefore=!0),i&&(f.comment=i,f.range[2]=l),f}function wo({options:e},{offset:t,source:r,end:s},n){let i=new pr(r.substring(1));i.source===""&&n(t,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+r.length,a=pt(s,o,e.strict,n);return i.range=[t,o,a.offset],a.comment&&(i.comment=a.comment),i}function vo(e,t,{offset:r,start:s,value:n,end:i},o){let a=new Us(void 0,Object.assign({_directives:t},e)),l={atKey:!1,atRoot:!0,directives:a.directives,options:a.options,schema:a.schema},c=Fe(s,{indicator:"doc-start",next:n??i?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});c.found&&(a.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!c.hasNewline&&o(c.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),a.contents=n?Js(l,n,c,o):Nr(l,c.end,s,null,c,o);let f=a.contents.range[2],u=pt(i,f,!1,o);return u.comment&&(a.comment=u.comment),a.range=[r,f,u.offset],a}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:r}=e;return[t,t+(typeof r=="string"?r.length:1)]}function Gs(e){let t="",r=!1,s=!1;for(let n=0;n<e.length;++n){let i=e[n];switch(i[0]){case"#":t+=(t===""?"":s?`
|
|
545
|
+
|
|
546
|
+
`:`
|
|
547
|
+
`)+(i.substring(1)||" "),r=!0,s=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(s=!0),r=!1}}return{comment:t,afterEmptyLine:s}}var ko=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,s,n)=>{let i=dt(t);n?this.warnings.push(new Zi(i,r,s)):this.errors.push(new ut(i,r,s))},this.directives=new Re({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:s}=Gs(this.prelude);if(r){let n=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
548
|
+
${r}`:r;else if(s||e.directives.docStart||!n)e.commentBefore=r;else if(V(n)&&!n.flow&&n.items.length>0){let i=n.items[0];W(i)&&(i=i.key);let o=i.commentBefore;i.commentBefore=o?`${r}
|
|
549
|
+
${o}`:r}else{let i=n.commentBefore;n.commentBefore=i?`${r}
|
|
550
|
+
${i}`:r}}if(t){for(let n=0;n<this.errors.length;++n)e.errors.push(this.errors[n]);for(let n=0;n<this.warnings.length;++n)e.warnings.push(this.warnings[n])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Gs(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let s of e)yield*this.next(s);yield*this.end(t,r)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,r,s)=>{let n=dt(e);n[0]+=t,this.onError(n,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=vo(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new ut(dt(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){this.errors.push(new ut(dt(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=pt(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
|
|
551
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new ut(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 r=new Us(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,t,t],this.decorate(r,!1),yield r}}},Tr=Symbol("break visit"),$o=Symbol("skip children"),Ys=Symbol("remove item");function We(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),Qs(Object.freeze([]),e,t)}We.BREAK=Tr,We.SKIP=$o,We.REMOVE=Ys,We.itemAtPath=(e,t)=>{let r=e;for(let[s,n]of t){let i=r?.[s];if(i&&"items"in i)r=i.items[n];else return}return r},We.parentCollection=(e,t)=>{let r=We.itemAtPath(e,t.slice(0,-1)),s=t[t.length-1][0],n=r?.[s];if(n&&"items"in n)return n;throw Error("Parent collection not found")};function Qs(e,t,r){let s=r(t,e);if(typeof s=="symbol")return s;for(let n of["key","value"]){let i=t[n];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=Qs(Object.freeze(e.concat([[n,o]])),i.items[o],r);if(typeof a=="number")o=a-1;else{if(a===Tr)return Tr;a===Ys&&(i.items.splice(o,1),--o)}}typeof s=="function"&&n==="key"&&(s=s(t,e))}}return typeof s=="function"?s(t,e):s}function xo(e){switch(e){case"\uFEFF":return"byte-order-mark";case"":return"doc-mode";case"":return"flow-error-end";case"":return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
552
|
+
`:case`\r
|
|
553
|
+
`: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" ":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}function oe(e){switch(e){case void 0:case" ":case`
|
|
554
|
+
`:case"\r":case" ":return!0;default:return!1}}var Xs=new Set("0123456789ABCDEFabcdef"),So=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Bt=new Set(",[]{}"),Ao=new Set(` ,[]{}
|
|
555
|
+
\r `),jr=e=>!e||Ao.has(e),Io=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";for(;r&&(t||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
|
|
556
|
+
`||t==="\r"&&this.buffer[e+1]===`
|
|
557
|
+
`}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let r=0;for(;t===" ";)t=this.buffer[++r+e];if(t==="\r"){let s=this.buffer[r+e+1];if(s===`
|
|
558
|
+
`||!s&&!this.atEnd)return e+r+1}return t===`
|
|
559
|
+
`||r>=this.indentNext||!t&&!this.atEnd?e+r:-1}if(t==="-"||t==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&oe(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
560
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&--e,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]==="\uFEFF"&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,r=e.indexOf("#");for(;r!==-1;){let n=e[r-1];if(n===" "||n===" "){t=r-1;break}r=e.indexOf("#",r+1)}for(;;){let n=e[t-1];if(n===" "||n===" ")--t;else break}let s=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),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"",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==="...")&&oe(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!oe(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&oe(t)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"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(jr),"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,r=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=r=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&s[0]!=="#"||r===0&&(s.startsWith("---")||s.startsWith("..."))&&oe(s[3]))&&(r!==this.indentNext-1||this.flowLevel!==1||s[0]!=="]"&&s[0]!=="}"))return this.flowLevel=0,yield"",yield*this.parseLineStart();let n=0;for(;s[n]===",";)n+=yield*this.pushCount(1),n+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(n+=yield*this.pushIndicators(),s[n]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-n),"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,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(jr),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||oe(i)||i===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let n=0;for(;this.buffer[t-1-n]==="\\";)n+=1;if(n%2==0)break;t=this.buffer.indexOf('"',t+1)}let r=this.buffer.substring(0,t),s=r.indexOf(`
|
|
561
|
+
`,this.pos);if(s!==-1){for(;s!==-1;){let n=this.continueScalar(s+1);if(n===-1)break;s=r.indexOf(`
|
|
562
|
+
`,n)}s!==-1&&(t=s-(r[s-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>oe(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,r;e:for(let n=this.pos;r=this.buffer[n];++n)switch(r){case" ":t+=1;break;case`
|
|
563
|
+
`:e=n,t=0;break;case"\r":{let i=this.buffer[n+1];if(!i&&!this.atEnd)return this.setNext("block-scalar");if(i===`
|
|
564
|
+
`)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let n=this.continueScalar(e+1);if(n===-1)break;e=this.buffer.indexOf(`
|
|
565
|
+
`,n)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;for(r=this.buffer[s];r===" ";)r=this.buffer[++s];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
|
|
566
|
+
`;)r=this.buffer[++s];e=s-1}else if(!this.blockScalarKeep)do{let n=e-1,i=this.buffer[n];i==="\r"&&(i=this.buffer[--n]);let o=n;for(;i===" ";)i=this.buffer[--n];if(i===`
|
|
567
|
+
`&&n>=this.pos&&n+1+t>o)e=n;else break}while(!0);return yield"",yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,r=this.pos-1,s;for(;s=this.buffer[++r];)if(s===":"){let n=this.buffer[r+1];if(oe(n)||e&&Bt.has(n))break;t=r}else if(oe(s)){let n=this.buffer[r+1];if(s==="\r"&&(n===`
|
|
568
|
+
`?(r+=1,s=`
|
|
569
|
+
`,n=this.buffer[r+1]):t=r),n==="#"||e&&Bt.has(n))break;if(s===`
|
|
570
|
+
`){let i=this.continueScalar(r+1);if(i===-1)break;r=Math.max(r,i-2)}}else{if(e&&Bt.has(s))break;t=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield"",yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(t&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(jr),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(oe(r)||t&&Bt.has(r)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+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];for(;!oe(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(So.has(t))t=this.buffer[++e];else if(t==="%"&&Xs.has(this.buffer[e+1])&&Xs.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
571
|
+
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
572
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,r;do r=this.buffer[++t];while(r===" "||e&&r===" ");let s=t-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=t),s}*pushUntil(e){let t=this.pos,r=this.buffer[t];for(;!e(r);)r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},Eo=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,r=this.lineStarts.length;for(;t<r;){let n=t+r>>1;this.lineStarts[n]<e?t=n+1:r=n}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let s=this.lineStarts[t-1];return{line:t,col:e-s+1}}}};function ve(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function Zs(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 en(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 Dt(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 Ve(e){if(e.length===0)return[];let t=e.length;e:for(;--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}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function Ut(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function tn(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!ve(t.start,"explicit-key-ind")&&!ve(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,en(t.value)?t.value.end?Ut(t.value.end,t.sep):t.value.end=t.sep:Ut(t.start,t.sep),delete t.sep)}var Oo=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Io,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,t))yield*this.next(r);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=xo(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source})}else{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 r=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in r?r.indent:0:t.type==="flow-collection"&&r.type==="document"&&(t.indent=0),t.type==="flow-collection"&&tn(t),r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let s=r.items[r.items.length-1];if(s.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(s.sep)s.value=t;else{Object.assign(s,{key:t,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=r.items[r.items.length-1];s.value?r.items.push({start:[],value:t}):s.value=t;break}case"flow-collection":{let s=r.items[r.items.length-1];!s||s.value?r.items.push({start:[],key:t,sep:[]}):s.sep?s.value=t:Object.assign(s,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let s=t.items[t.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&Zs(s.start)===-1&&(t.indent===0||s.start.every(n=>n.type!=="comment"||n.indent<t.indent))&&(r.type==="document"?r.end=s.start:r.items.push({start:s.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":Zs(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=Ve(Dt(this.peek(2))),r;e.end?(r=e.end,r.push(this.sourceToken),delete e.end):r=[this.sourceToken];let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}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(`
|
|
573
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
574
|
+
`,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 r="end"in t.value?t.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Ut(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,s=r&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",n=[];if(s&&t.sep&&!t.value){let i=[];for(let o=0;o<t.sep.length;++o){let a=t.sep[o];switch(a.type){case"newline":i.push(o);break;case"space":break;case"comment":a.indent>e.indent&&(i.length=0);break;default:i.length=0}}i.length>=2&&(n=t.sep.splice(i[1]))}switch(this.type){case"anchor":case"tag":s||t.value?(n.push(this.sourceToken),e.items.push({start:n}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):s||t.value?(n.push(this.sourceToken),e.items.push({start:n,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ve(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]});else if(en(t.key)&&!ve(t.sep,"newline")){let i=Ve(t.start),o=t.key,a=t.sep;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:o,sep:a}]})}else n.length>0?t.sep=t.sep.concat(n,this.sourceToken):t.sep.push(this.sourceToken);else if(ve(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=Ve(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||s?e.items.push({start:n,key:null,sep:[this.sourceToken]}):ve(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);s||t.value?(e.items.push({start:n,key:i,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(i):(Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0);return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ve(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 r&&e.items.push({start:n});this.stack.push(i);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 r="end"in t.value?t.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else 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 r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Ut(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||ve(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:s,sep:[]}):t.sep?this.stack.push(s):Object.assign(t,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let s=Ve(Dt(r));tn(e);let n=e.end.splice(1,e.end.length);n.push(this.sourceToken);let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
575
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
576
|
+
`,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=Ve(Dt(e));return t.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Ve(Dt(e));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function Co(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Eo||null,prettyErrors:t}}function _o(e,t={}){let{lineCounter:r,prettyErrors:s}=Co(t),n=new Oo(r?.addNewLine),i=new ko(t),o=null;for(let a of i.compose(n.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new ut(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&r&&(o.errors.forEach(Ks(e,r)),o.warnings.forEach(Ks(e,r))),o}function No(e,t,r){let s;typeof t=="function"?s=t:r===void 0&&t&&typeof t=="object"&&(r=t);let n=_o(e,r);if(!n)return null;if(n.warnings.forEach(i=>(n.options.logLevel,void 0)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:s},r))}var To=/\$(inputs|steps|workflows)\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+))?)?/g;function Lr(e,t,r){if(typeof e=="string")for(let s of e.matchAll(To)){let[n,i,o,a,l]=s,c;c=i==="inputs"?{kind:"input",name:o,expr:n}:i==="steps"&&a==="outputs"&&l?{kind:"step",stepId:o,name:l,expr:n}:i==="steps"?{kind:"step",stepId:o,name:"",expr:n}:a==="outputs"&&l?{kind:"workflow",workflowId:o,name:l,expr:n}:{kind:"workflow",workflowId:o,name:"",expr:n},r.has(n)||(r.add(n),t.push(c))}else if(Array.isArray(e))for(let s of e)Lr(s,t,r);else if(e&&typeof e=="object")for(let s of Object.values(e))Lr(s,t,r)}function Je(e){let t=[];return Lr(e,t,new Set),t}function ht(e,t,r){if(!t||typeof t.reference!="string")return t;let s=t.reference.match(/^\$components\.([A-Za-z]+)\.([A-Za-z0-9_.-]+)$/);if(!s||s[1]!==r)return null;let n=e?.components?.[r]?.[s[2]];return n?{...n,...t.value===void 0?{}:{value:t.value}}:null}var jo=new Set(["end","goto","retry"]),Lo=new Set(["openapi","arazzo","asyncapi"]);function rn(e){if(e&&typeof e=="object")return e;let t=String(e??"").trim();if(!t)throw Error("The document is empty");let r=t.startsWith("{")?JSON.parse(t):No(t);if(!r||typeof r!="object")throw Error("The document is not an object");return r}function P(e,t,r){return{level:e,path:t,message:r}}function zt(e,t,r,s,n,i,o){t!==void 0&&(Array.isArray(t)?t.forEach((a,l)=>{let c=`${s}[${l}]`,f=ht(e,a,r);f?jo.has(f.type)?(f.type==="retry"&&r==="successActions"&&o.push(P("error",`${c}.type`,"retry is only allowed on failure")),f.stepId&&f.workflowId&&o.push(P("error",c,"has both stepId and workflowId")),f.type==="goto"&&!f.stepId&&!f.workflowId&&o.push(P("error",c,"goto needs a stepId or a workflowId")),f.stepId&&!n.has(f.stepId)&&o.push(P("error",`${c}.stepId`,`no step "${f.stepId}"`)),f.workflowId&&!f.workflowId.startsWith("$")&&!i.has(f.workflowId)&&o.push(P("error",`${c}.workflowId`,`no workflow "${f.workflowId}"`))):o.push(P("error",`${c}.type`,"must be end, goto or retry")):o.push(P("error",c,`unresolved reference ${a?.reference}`))}):o.push(P("error",s,"must be a list of actions")))}function Mo(e){let t=[];if(!e||typeof e!="object")return[P("error","","not an object")];typeof e.arazzo=="string"&&/^1\.\d+(\.\d+)?/.test(e.arazzo)||t.push(P("error","arazzo","must be an Arazzo 1.x version string")),e.info?.title||t.push(P("error","info.title","is required")),e.info?.version||t.push(P("error","info.version","is required"));let r=Array.isArray(e.sourceDescriptions)?e.sourceDescriptions:[];r.length||t.push(P("error","sourceDescriptions","needs at least one source"));let s=new Set;r.forEach((o,a)=>{let l=`sourceDescriptions[${a}]`;o?.name?s.has(o.name)?t.push(P("error",`${l}.name`,"is a duplicate")):s.add(o.name):t.push(P("error",`${l}.name`,"is required")),o?.url||t.push(P("error",`${l}.url`,"is required")),o?.type&&!Lo.has(o.type)&&t.push(P("warning",`${l}.type`,`unknown type "${o.type}"`))});let n=Array.isArray(e.workflows)?e.workflows:[];n.length||t.push(P("error","workflows","needs at least one workflow"));let i=new Set;return n.forEach((o,a)=>{o?.workflowId?i.has(o.workflowId)?t.push(P("error",`workflows[${a}].workflowId`,"is a duplicate")):i.add(o.workflowId):t.push(P("error",`workflows[${a}].workflowId`,"is required"))}),n.forEach((o,a)=>{let l=`workflows[${a}]`,c=Array.isArray(o?.steps)?o.steps:[];c.length||t.push(P("error",`${l}.steps`,"needs at least one step"));let f=new Set;c.forEach((u,d)=>{let y=`${l}.steps[${d}]`;u?.stepId?f.has(u.stepId)?t.push(P("error",`${y}.stepId`,"is a duplicate")):f.add(u.stepId):t.push(P("error",`${y}.stepId`,"is required")),["operationId","operationPath","workflowId"].filter(g=>u?.[g]).length!==1&&t.push(P("error",y,"needs exactly one of operationId, operationPath or workflowId")),u?.workflowId&&!u.workflowId.startsWith("$")&&!i.has(u.workflowId)&&t.push(P("error",`${y}.workflowId`,`no workflow "${u.workflowId}"`))}),(o?.dependsOn||[]).forEach((u,d)=>{!String(u).startsWith("$")&&!i.has(u)&&t.push(P("error",`${l}.dependsOn[${d}]`,`no workflow "${u}"`))}),zt(e,o?.successActions,"successActions",`${l}.successActions`,f,i,t),zt(e,o?.failureActions,"failureActions",`${l}.failureActions`,f,i,t),c.forEach((u,d)=>{let y=`${l}.steps[${d}]`;zt(e,u?.onSuccess,"successActions",`${y}.onSuccess`,f,i,t),zt(e,u?.onFailure,"failureActions",`${y}.onFailure`,f,i,t);for(let g of Je([u?.parameters,u?.requestBody]))g.kind==="step"&&!f.has(g.stepId)&&t.push(P("error",y,`refers to unknown step "${g.stepId}"`))});for(let u of Je(o?.outputs))u.kind==="step"&&!f.has(u.stepId)&&t.push(P("error",`${l}.outputs`,`refers to unknown step "${u.stepId}"`))}),t}var qo=["get","put","post","delete","options","head","patch","trace","query"];function Mr(e){let t=new Map,r=new Map;for(let[s,n]of Object.entries(e?.paths||{}))if(n&&typeof n=="object")for(let i of qo){let o=n[i];if(!o||typeof o!="object")continue;let a={operationId:o.operationId||"",method:i,path:s,summary:o.summary||""},l=o.security??e.security;l!==void 0&&(a.security=l),o.operationId&&t.set(o.operationId,a),r.set(`${i} ${s}`,a)}return{byId:t,byPath:r}}function qr(e){let t=new Map,r=new Map;for(let s of e?.tags||[])for(let n of s?.paths||[]){if(!n?.method||!n.path||n.isWebhook)continue;let i=n.method.toLowerCase(),o={operationId:n.operationId||"",method:i,path:n.path,summary:n.summary||""};n.security!==void 0&&(o.security=n.security);let a=`${i} ${n.path}`;r.has(a)||(n.operationId&&t.set(n.operationId,o),r.set(a,o))}return{byId:t,byPath:r}}function Po(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}function sn(e,t){if(!t?.size)return null;if(e.operationId){let r="",s=e.operationId,n=s.match(/^\$sourceDescriptions\.([A-Za-z0-9_-]+)\.(.+)$/);n&&([,r,s]=n);for(let[i,o]of t){if(r&&i!==r)continue;let a=o.byId.get(s);if(a)return{source:i,...a}}return null}if(e.operationPath){let r=e.operationPath.match(/^\{\$sourceDescriptions\.([A-Za-z0-9_-]+)\.url\}#(.*)$/);if(!r)return null;let[,s,n]=r,i=n.split("/").slice(1).map(Po);if(i.length!==3||i[0]!=="paths")return null;let o=t.get(s)?.byPath.get(`${i[2].toLowerCase()} ${i[1]}`);return o?{source:s,...o}:null}return null}function nn(e){return(Array.isArray(e)?e:[]).filter(t=>t&&typeof t.condition=="string").map(t=>({condition:t.condition,context:t.context||"",type:typeof t.type=="string"?t.type:t.type?.type||"simple"}))}function Kt(e,t,r,s,n){return(Array.isArray(t)?t:[]).map(i=>ht(e,i,r)).filter(i=>i&&["end","goto","retry"].includes(i.type)).map(i=>{let o=nn(i.criteria);return{outcome:s,type:i.type,name:i.name||"",stepId:i.stepId||"",workflowId:i.workflowId||"",retryAfter:i.retryAfter,retryLimit:i.retryLimit,criteria:o,conditional:o.length>0,inherited:n}})}function on(e,t){let r=new Set(e.map(i=>i.name).filter(Boolean)),s=[...e,...t.filter(i=>!i.name||!r.has(i.name))],n=s.findIndex(i=>!i.conditional);return s.map((i,o)=>({...i,shadowed:n>=0&&o>n}))}function Ro(e,t){let r=typeof t?.$ref=="string"&&t.$ref.match(/^#\/components\/inputs\/(.+)$/),s=r?e?.components?.inputs?.[r[1]]:t,n=new Set(Array.isArray(s?.required)?s.required:[]);return Object.entries(s?.properties||{}).map(([i,o])=>({name:i,type:o?.type?[].concat(o.type).join(" | "):o?.enum?"enum":"",format:o?.format||"",required:n.has(i),default:o?.default,enum:Array.isArray(o?.enum)?o.enum:void 0,description:o?.description||""}))}function Bo(e,t){return(Array.isArray(t)?t:[]).map(r=>ht(e,r,"parameters")).filter(r=>r&&r.name).map(r=>({name:r.name,in:r.in||"",value:r.value}))}function an(e){if(typeof e=="string"){let t=e.trim(),r=t.match(/^\$inputs\.([A-Za-z0-9_-]+)$/);return r?{kind:"input",name:r[1],text:r[1]}:(r=t.match(/^\$steps\.([A-Za-z0-9_-]+)\.outputs\.([A-Za-z0-9_-]+)$/),r?{kind:"step",stepId:r[1],name:r[2],text:`${r[1]}.${r[2]}`}:t.includes("$")?{kind:"expression",text:t}:{kind:"value",text:t})}return{kind:"value",text:e===void 0?"":JSON.stringify(e)}}function ln(e,t,r){for(let[s,n]of Object.entries(e)){let i=`${t}.${s}`;n&&typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length?ln(n,i,r):r.push({name:i,in:"body",value:n})}}function Do(e,t){let r=e.map(n=>({name:n.name,in:n.in,value:n.value})),s=t?.payload;s&&typeof s=="object"&&!Array.isArray(s)?ln(s,"body",r):s!=null&&r.push({name:"body",in:"body",value:s});for(let n of t?.replacements||[])n?.target&&r.push({name:`body ${n.target}`,in:"body",value:n.value});return r.map(n=>{let i=Je(n.value).filter(o=>o.kind==="step");return{...n,source:an(n.value),fromSteps:[...new Set(i.map(o=>o.stepId))],fromOutputs:i.filter(o=>o.name).map(o=>({stepId:o.stepId,name:o.name}))}})}var Uo=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`:e[0];function zo(e,t){let r=[];return e.forEach((s,n)=>{for(let i of["success","failure"]){let o=s.actions.filter(d=>d.outcome===i),a=o.filter(d=>d.shadowed);if(!a.length)continue;let l=o.find(d=>!d.conditional),c=a.map(d=>d.name||`an unnamed ${d.type}`),f=a.every(d=>d.inherited)?"the workflow's ":"",u=a.length>1?"never run":"never runs";r.push({level:"warning",path:`workflows[${t}].steps[${n}].${i==="failure"?"onFailure":"onSuccess"}`,message:`${s.stepId}: ${f}${Uo(c)} ${u}, because ${l?.name||"an action"} has no criteria and always matches first`})}}),r}function cn(e,t,r,s){let n=e.find(i=>i.from===t&&i.to===r);n?n.labels.includes(s)||n.labels.push(s):e.push({from:t,to:r,labels:[s]})}function Ko(e,t,r={}){let s=Array.isArray(e?.workflows)?e.workflows:[],n=t?s.find(p=>p?.workflowId===t):s[0];if(!n)return null;let i=Array.isArray(n.steps)?n.steps:[],o=new Set(i.map(p=>p?.stepId).filter(Boolean)),a=Kt(e,n.successActions,"successActions","success",!0),l=Kt(e,n.failureActions,"failureActions","failure",!0),c=[],f=i.map(p=>{let h=Kt(e,p.onSuccess,"successActions","success",!1),w=Kt(e,p.onFailure,"failureActions","failure",!1),$=p.workflowId?null:sn(p,r.sources),b=Je([p.parameters,p.requestBody]);for(let x of b)x.kind==="step"&&x.name&&x.stepId!==p.stepId&&o.has(x.stepId)&&cn(c,x.stepId,p.stepId,x.name);let S=nn(p.successCriteria),k=Bo(e,p.parameters);return{stepId:p.stepId||"",description:p.description||"",kind:p.workflowId?"workflow":"operation",workflowId:p.workflowId||"",operationRef:p.operationId||p.operationPath||"",operation:$,inputs:b.filter(x=>x.kind==="input").map(x=>x.name),outputs:Object.keys(p.outputs||{}),outputExprs:Object.entries(p.outputs||{}).map(([x,I])=>({name:x,expr:I})),parameters:k,requestBody:p.requestBody||null,bindings:Do(k,p.requestBody),criteria:S,successCriteria:S.length,actions:[...on(h,a),...on(w,l)]}}),u=Ro(e,n.inputs),d=Object.entries(n.outputs||{}).map(([p,h])=>{let w=Je(h).find($=>$.kind==="step");return w&&o.has(w.stepId)&&cn(c,w.stepId,"outputs",p),{name:p,stepId:w?.stepId||"",output:w?.name||"",source:an(h),expr:typeof h=="string"?h:JSON.stringify(h)}}),y=new Map,g=(p,h)=>{p&&h&&y.set(p,(y.get(p)||new Set).add(h))};for(let p of f)for(let h of p.bindings)for(let w of h.fromOutputs)g(w.stepId,w.name);for(let p of d)g(p.stepId,p.output);for(let p of f){let h=y.get(p.stepId)||new Set;p.usedOutputs=p.outputExprs.filter(w=>h.has(w.name))}return{workflowId:n.workflowId||"",summary:n.summary||"",description:n.description||"",inputs:u.map(p=>p.name),inputDetails:u,workflowActions:[...a,...l],operationsKnown:!!r.sources?.size,outputs:d,steps:f,dataEdges:c,warnings:zo(f,s.indexOf(n))}}var Ho=320,Fo=360,Wo=560,D=16,Ht=18,Vo=52,un=40,Pr=20,mt=16,fn=30,Jo=18,pn=10,le=7.2,G=7.4,ce=6.4;function Q(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ue(e,t){let r=String(e??"");return t<2?"":r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Go(e){let t=e.match(/^\$statusCode\s*==\s*(\d+)$/);return t?`status ${t[1]}`:e}function Yo(e,t=0,r=0){let s=e.criteria||[],n;n=s.length?s.map(o=>Go(o.condition)).join(" and "):r>0?"otherwise":e.outcome==="failure"?t>1?"checks fail":t?"check fails":"request fails":t>1?"checks pass":t?"check passes":"request succeeds";let i;return e.type==="end"?i="stop the workflow":e.type==="goto"?i=e.stepId?`go to ${e.stepId}`:`run workflow ${e.workflowId}`:(i="retry",e.retryLimit&&(i+=` ${e.retryLimit}\xD7`),e.retryAfter&&(i+=`, ${e.retryAfter}s apart`),e.stepId&&(i+=` from ${e.stepId}`)),{when:n,does:i,name:e.name||"",tag:e.inherited?"workflow":""}}function dn(e){let t=[],r=[...e].sort((s,n)=>s.span[1]-s.span[0]-(n.span[1]-n.span[0]));for(let s of r){let n=0;for(;(t[n]||[]).some(i=>s.span[0]<i.span[1]&&i.span[0]<s.span[1]);)n++;(t[n]||=[]).push(s),s.lane=n}return t.length}function he(e,t){return Math.ceil(String(e).length*t)}var z=(e,t,r,s={})=>({text:String(e),cls:t,w:r,...s});function hn(e){let t=0;return{starts:e.parts.map(r=>{t=r.x===void 0?t+(r.dx||0):r.x;let s=t;return t+=he(r.text,r.w),s}),end:t}}var mn=e=>e.tag?he(e.tag,e.tagW||ce)+16:0;function Qo(e,t){let{starts:r}=hn(e),s=e.parts.at(-1);if(!s)return;let n=t-D-mn(e)-r.at(-1);s.text=ue(s.text,Math.floor(n/s.w))}function gn(e,t,r,s,n=!1){let i=n&&e.fromStep,o=e.fromStep?` data-from-step="${Q(e.fromStep)}"`:"",a=i?"rf-row rf-jump":"rf-row",l=e.parts.map(u=>{let d=u.x===void 0?u.dx?` dx="${u.dx}"`:"":` x="${t+u.x}"`;return`<tspan class="${u.cls}"${d}>${Q(u.text)}</tspan>`}).join(""),c=e.tag?`<text class="${e.tagCls||"rf-tag"}${i?" rf-jump":""}" x="${t+r-D}" y="${s}" text-anchor="end"${o}${i?` tabindex="0" role="link" aria-label="${Q(`Go to step ${e.fromStep}`)}"`:""}>${Q(e.tag)}</text>`:"",f=e.tip?`<title>${Q(e.tip)}</title>`:"";return`${e.rule?`<path class="rf-sep" d="M${t} ${s-13}H${t+r}"/>`:""}<text class="${a}" y="${s}"${o}>${f}${l}</text>${c}`}var yn={input:"input",step:"step",value:"fixed",expression:"expr"},bn=6*G;function Xo(e,t){let r=z(yn[e.kind],`rf-kw rf-kw-${e.kind}`,G,{x:t});return e.kind==="step"?[r,z(e.stepId,"rf-step-name",G,{x:t+bn}),z(`.${e.name}`,"rf-bind-val",G)]:[r,z(e.text,"rf-bind-val",G,{x:t+bn})]}function Zo(e){let t=typeof e=="string"?e:JSON.stringify(e),r=t.match(/^\$response\.(body|header)(?:#(.*)|\.(.+))?$/);return r?`response ${r[1]}${r[2]||r[3]?` ${r[2]||r[3]}`:""}`:t==="$statusCode"?"status code":t}function ea(e){if(!e.usedOutputs.length)return[];let t=Math.min(24,Math.max(4,...e.usedOutputs.map(i=>i.name.length))),r=D+t*G+12,s=[{parts:[z("Outputs","rf-sec-title",ce,{x:D})]},...e.usedOutputs.map(i=>({departs:i.name,tip:typeof i.expr=="string"?i.expr:JSON.stringify(i.expr),parts:[z(ue(i.name,t),"rf-bind-name",G,{x:D}),z(Zo(i.expr),"rf-out-from",G,{x:r})]}))],n=e.outputExprs.length-e.usedOutputs.length;return n&&s.push({parts:[z(`+${n} unused`,"rf-more",ce,{x:D})]}),s}function ta(e){return e.criteria.length?[{parts:[z("Checks","rf-sec-title",ce,{x:D})]},...e.criteria.map(t=>({parts:[...t.type==="simple"?[]:[z(`${t.type}${t.context?` on ${t.context}`:""}:`,"rf-check-type",G,{x:D})],z(t.condition,"rf-check",G,t.type==="simple"?{x:D}:{dx:8})]}))]:[]}function ra(e){return["success","failure"].map(t=>{let r=e.actions.filter(o=>o.outcome===t&&!o.shadowed);if(!r.length)return[];let s=r.map((o,a)=>Yo(o,e.criteria.length,a)),n=Math.min(34,Math.max(...s.map(o=>o.when.length))),i=D+n*le+12;return[{parts:[z(`On ${t} \xB7 first match runs`,"rf-sec-title",ce,{x:D})]},...r.map((o,a)=>({action:o,tag:s[a].tag,parts:[z(ue(s[a].when,n),"rf-act-when",le,{x:D}),z(`\u2192 ${s[a].does}`,"rf-act-then",le,{x:i}),...s[a].name?[z(`(${s[a].name})`,"rf-act-name",le,{dx:8})]:[]]}))]}).filter(t=>t.length)}function sa(e){let t=Math.min(22,Math.max(4,...e.inputDetails.map(n=>n.name.length))),r=D+t*le+16,s=[];for(let n of e.inputDetails){let i=[z(ue(n.name,t),"rf-in-name",le,{x:D})],o=n.enum?.length?n.type.replace("string","enum"):n.type,a=o?`${o}${n.format?` (${n.format})`:""}`:"any";if(i.push(z(a,"rf-in-type",G,{x:r})),n.required&&i.push(z("required","rf-req",ce,{dx:8})),n.default!==void 0){let l=typeof n.default=="string"?n.default:JSON.stringify(n.default);i.push(z(`= ${l}`,"rf-in-default",G,{dx:8}))}if(s.push({parts:i,tip:n.description}),n.enum?.length){let l=n.enum.map(c=>typeof c=="string"?c:JSON.stringify(c));s.push({parts:[z(l.join(" | "),"rf-in-enum",G,{x:r})]})}}return s}function na(e){let t=e.bindings.slice(0,pn),r=Math.min(18,Math.max(4,...t.map(o=>o.name.length))),s=D+r*G+12,n=t.map(o=>({arrivals:o.fromOutputs,fromStep:o.fromSteps[0],parts:[z(ue(o.name,r),"rf-bind-name",G,{x:D}),...Xo(o.source,s)]})),i=e.bindings.slice(pn);return i.length&&n.push({arrivals:i.flatMap(o=>o.fromOutputs),parts:[z(`+${i.length} more in the step details`,"rf-more",ce,{x:D})]}),n}function ia(e){let t=new Map;for(let r of e.outputs){let s=r.source||{kind:"expression",text:r.expr},n=r.stepId?`step:${r.stepId}`:`kind:${s.kind}`;t.has(n)||t.set(n,{stepId:r.stepId,title:r.stepId||yn[s.kind],items:[]}),t.get(n).items.push({...r,source:s})}return[...t.values()].sort((r,s)=>+!r.stepId-+!s.stepId).flatMap((r,s)=>r.items.map((n,i)=>{let o="";return o=n.source.kind==="step"?n.output&&n.output!==n.name?`\u2190 ${n.output}`:"":`${n.source.kind==="value"?"=":"\u2190"} ${n.source.text}`,{fromStep:r.stepId,rule:s>0&&i===0,...i===0?{tag:r.title,tagCls:r.stepId?"rf-tag rf-out-step":"rf-tag",tagW:r.stepId?le:ce,arrivals:r.items.filter(a=>a.stepId&&a.output).map(a=>({stepId:a.stepId,name:a.output}))}:{},parts:[z(n.name,"rf-out-name",le,{x:D}),...o?[z(o,"rf-out-from",G,{dx:8})]:[]]}}))}function oa(e){let t=e.operation,r=t?he(t.method,G)+8+he(t.path,G):he(e.workflowId||e.operationRef,G)+90;return Math.max(he(e.stepId,le)+90,r)+32}function aa(e,t={}){if(!e)return{svg:"",legend:[]};let{idPrefix:r="rf",interactive:s=!1}=t,n=t.view!=="compact",i=new Set,o=[];e.inputs.length&&o.push({key:"inputs",kind:"io",title:"Inputs",rows:sa(e)});for(let m of e.steps)if(n)o.push({key:m.stepId,kind:"step",step:m,sections:[na(m),ta(m),...ra(m),ea(m)].filter(v=>v.length)});else{let v=m.actions.filter(O=>!O.inherited&&!O.shadowed&&O.type==="goto"&&O.stepId);o.push({key:m.stepId,kind:"step",step:m,gotos:v,sections:[]})}e.outputs.length&&o.push({key:"outputs",kind:"io",title:"Outputs",rows:ia(e)});let a=new Map(o.map((m,v)=>[m.key,v])),l=m=>m.kind==="io"?m.rows:m.sections.flat(),c=o.flatMap(m=>[...l(m).map(v=>hn(v).end+mn(v)+D),m.kind==="step"&&n?oa(m.step):0]),f=Math.min(Wo,Math.max(n?Fo:Ho,...c));for(let m of o)for(let v of l(m))Qo(v,f);let u=Math.floor((f-32)/le);for(let m of o){if(m.kind==="io"){m.rows.forEach((O,_)=>O.by=40+_*Ht),m.h=34+m.rows.length*Ht;continue}if(!n){m.h=Math.max(60,fn+m.gotos.length*8+4);continue}let v=Vo;m.separators=[];for(let O of m.sections){let _=v+6;m.separators.push(_),O.forEach((L,K)=>L.by=_+18+K*Ht),v=_+18+(O.length-1)*Ht+6}m.h=Math.max(60,v+8)}let d=new Map,y=(m,v,O,_,L)=>{let K=o[v].key==="outputs",ne=`${m}\0${K}\0${O}`,fe=d.get(ne)||{from:m,label:O,output:K,targets:[],departs:new Set};fe.targets.some(H=>H.node===v&&H.by===_)||fe.targets.push({node:v,by:_}),L&&fe.departs.add(L),d.set(ne,fe)};if(n)o.forEach((m,v)=>{for(let O of l(m))for(let _ of O.arrivals||[]){let L=a.get(_.stepId);L!==void 0&&L<v&&y(L,v,"",O.by,_.name)}});else for(let m of e.dataEdges)if(!(!a.has(m.from)||!a.has(m.to)||a.get(m.from)>=a.get(m.to)))if(m.to==="outputs"){let v=l(o[a.get("outputs")]).find(O=>O.arrivals?.some(_=>_.stepId===m.from));y(a.get(m.from),a.get(m.to),"",v?.by)}else y(a.get(m.from),a.get(m.to),ue(m.labels.join(", "),28),void 0);let g=[...d.values()].map(m=>{let v=m.targets.sort((O,_)=>O.node-_.node||(O.by??0)-(_.by??0));return{...m,targets:v,span:[m.from,v.at(-1).node]}}),p=dn(g),h=[];o.forEach((m,v)=>{if(m.kind!=="step")return;let O=n?l(m).filter(_=>_.action).map(_=>({action:_.action,by:_.by})):m.gotos.map((_,L)=>({action:_,by:fn+L*8+4}));for(let _ of O){let L=_.action.type==="goto"?_.action.stepId:"";if(!L||!a.has(L)||L===m.key)continue;let K=a.get(L);h.push({..._,from:v,to:K,span:[Math.min(v,K),Math.max(v,K)]})}});let w=dn(h),$=mt+(w?w*Pr+8:0),b=$+f,S=m=>b+20+m*Pr,k=Math.max(8,...g.map(m=>m.label?he(m.label,ce)+14:0)),x=(p?S(p-1)+k:b)+mt,I=mt;for(let m of o)m.y=I,m.cy=I+m.h/2,I+=m.h+un;let A=I-un+mt,q=new Map,T=(m,v,O)=>{let _=o[m];if(v==="in"&&O!==void 0)return _.y+O-4;let L=`${m}:${v}`,K=q.get(L)||0;return q.set(L,K+1),n&&v==="out"?_.y+18+K*8:v==="in"?_.cy-6-K*8:_.cy+6+K*8},j=[],F=(m,v)=>`<marker id="${r}-${m}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" class="${v}"/></marker>`;j.push(`<svg xmlns="http://www.w3.org/2000/svg" class="rf-svg rf-${n?"expanded":"compact"}" viewBox="0 0 ${x} ${A}" width="${x}" height="${A}" role="group" aria-label="${Q(`Workflow ${e.workflowId}`)}">`,`<defs>${F("seq","rf-head-seq")}${F("data","rf-head-data")}${F("output","rf-head-output")}${F("success","rf-head-success")}${F("failure","rf-head-failure")}</defs>`);let ke=m=>m.kind==="step"&&m.step.actions.some(v=>v.outcome==="success"&&!v.conditional&&(v.type==="end"||v.type==="goto"));for(let m=0;m+1<o.length;m++){if(o[m+1].kind==="step"&&ke(o[m]))continue;let v=$+f/2;i.add("seq"),j.push(`<path class="rf-seq" d="M${v} ${o[m].y+o[m].h}V${o[m+1].y-2}" marker-end="url(#${r}-seq)"/>`)}let M=[];for(let m of g){let v=S(m.lane),O=m.output?"rf-data rf-to-output":"rf-data",_=m.output?"output":"data";i.add(_);let L=m.targets.map(Y=>T(Y.node,"in",Y.by)),K=o[m.from],ne=n?l(K).filter(Y=>Y.departs&&m.departs.has(Y.departs)).map(Y=>K.y+Y.by-4):[];ne.length||ne.push(T(m.from,"out"));let fe=Math.min(...ne),H=` data-from-step="${Q(K.key)}"`;for(let Y of ne)j.push(`<path class="${O}"${H} d="M${b} ${Y}H${v}"/>`);j.push(`<path class="${O}"${H} d="M${v} ${fe}V${Math.max(...L)}"/>`);for(let Y of L)j.push(`<path class="${O}"${H} d="M${v} ${Y}H${b+2}" marker-end="url(#${r}-${_})"/>`);if(!m.label)continue;let Ne=he(m.label,ce)+12,ye=(fe+L[0])/2-9;for(;M.some(Y=>v<Y.x+Y.w&&Y.x<v+Ne&&ye<Y.y+20&&Y.y<ye+20);)ye+=20;M.push({x:v,y:ye,w:Ne}),j.push(`<g class="rf-data-label"><rect x="${v+4}" y="${ye}" width="${Ne}" height="18" rx="9"/><text x="${v+10}" y="${ye+13}">${Q(m.label)}</text></g>`)}for(let m of h){let v=o[m.from],O=o[m.to],_=mt+(w-1-m.lane)*Pr+4,L=v.y+m.by-4,K=$,ne=O.y+Jo/2;i.add(m.action.outcome),j.push(`<path class="rf-goto rf-${m.action.outcome}" d="M${K} ${L}H${_}V${ne}H${$-2}" marker-end="url(#${r}-${m.action.outcome})"/>`)}for(let m of o){if(m.kind==="io"){j.push(`<g class="rf-node rf-io rf-${m.key}"><rect x="${$}" y="${m.y}" width="${f}" height="${m.h}" rx="8"/>`,`<text class="rf-io-title" x="${$+D}" y="${m.y+20}">${m.title}</text>`,m.key==="outputs"&&e.outputs.some(H=>H.stepId)?`<text class="rf-io-title" x="${$+f-D}" y="${m.y+20}" text-anchor="end">From step</text>`:"",...m.rows.map(H=>gn(H,$,f,m.y+H.by,s)),"</g>");continue}let v=m.step,O=v.operation,_=s&&(O||v.kind==="workflow"),L;if(v.kind==="workflow")L=`<text class="rf-sub" x="${$+D}" y="${m.y+44}">workflow \u25B8 ${Q(ue(v.workflowId,u-11))}</text>`;else if(O){let H=O.method.toUpperCase(),Ne=he(H,G)+8,ye=Math.floor((f-32-Ne)/G);L=`<text class="rf-method rf-method-${O.method}" x="${$+D}" y="${m.y+44}">${H}</text><text class="rf-path" x="${$+D+Ne}" y="${m.y+44}">${Q(ue(O.path,ye))}</text>`}else{let H=e.operationsKnown?" (not found)":"";L=`<text class="rf-sub rf-unresolved" x="${$+D}" y="${m.y+44}">${Q(ue(v.operationRef,u-H.length))}${H}</text>`}let K=[v.description,O?.summary,v.inputs.length?`Inputs: ${v.inputs.join(", ")}`:"",v.outputs.length?`Outputs: ${v.outputs.join(", ")}`:""].filter(Boolean).join(`
|
|
577
|
+
`),ne=O?`${v.stepId}: ${O.method.toUpperCase()} ${O.path}`:v.stepId,fe=_?` tabindex="0" role="button" aria-label="${Q(ne)}"`:"";j.push(`<g class="rf-node rf-step${_?" rf-clickable":""}" data-step-id="${Q(v.stepId)}"${fe}>`,K?`<title>${Q(K)}</title>`:"",`<rect x="${$}" y="${m.y}" width="${f}" height="${m.h}" rx="8"/>`,`<text class="rf-title" x="${$+D}" y="${m.y+24}">${Q(ue(v.stepId,u-10))}</text>`,L,v.successCriteria&&!n?`<text class="rf-criteria" x="${b-12}" y="${m.y+24}" text-anchor="end">${v.successCriteria} check${v.successCriteria>1?"s":""}</text>`:"",...(m.separators||[]).map(H=>`<path class="rf-sep" d="M${$} ${m.y+H}H${b}"/>`),...m.sections.flat().map(H=>gn(H,$,f,m.y+H.by,s)),"</g>")}return j.push("</svg>"),{svg:j.join(""),legend:["seq","data","output","success","failure"].filter(m=>i.has(m))}}function la(e){let t=new TextEncoder().encode(e),r="";for(let s of t)r+=String.fromCharCode(s);return btoa(r)}function Ge(e){return typeof e=="string"?e:e&&typeof e=="object"?JSON.stringify(e):String(e)}function ca(e){try{return JSON.parse(e)}catch{return}}function ua(e,t,r,s){if(!Array.isArray(e)||!e.length)return;let n=e.find(i=>Object.keys(i).every(o=>r[o]!==void 0));if(!n){if(e.some(i=>!Object.keys(i).length))return;n=e[0]}for(let i of Object.keys(n)){let o=t?.[i],a=r[i];if(!o||a===void 0)continue;let l=typeof a=="string"?a:a?.token||a?.accessToken;if(o.type==="apiKey"){let c=Ge(a);o.in==="query"?s.query.set(o.name,c):o.in==="cookie"?s.cookies.push(`${o.name}=${encodeURIComponent(c)}`):s.headers[o.name||"Authorization"]=c}else if(o.type==="http"&&String(o.scheme).toLowerCase()==="basic"){let c=typeof a=="string"?a:`${a?.username??""}:${a?.password??""}`;s.headers.Authorization=`Basic ${la(c)}`}else l&&(s.headers.Authorization=`Bearer ${l}`)}}function fa(e,t,r={},s={}){let n=e.sources?.[t.source]||{},i=String(s.baseUrls?.[t.source]||n.baseUrl||"").replace(/\/$/,""),o={},a=new URLSearchParams,l=[],c=t.path||"",f;for(let g of t.params||[]){let p=r[g.arg||g.name];if(p!=null)if(g.in==="path")c=c.split(`{${g.name}}`).join(encodeURIComponent(Ge(p)));else if(g.in==="query")for(let h of Array.isArray(p)?p:[p])a.append(g.name,Ge(h));else g.in==="header"?o[g.name]=Ge(p):g.in==="cookie"?l.push(`${g.name}=${encodeURIComponent(Ge(p))}`):g.in==="body"&&(f={contentType:g.contentType||"application/json",value:p})}let u=c.match(/\{[^}]+\}/g);if(u)throw Error(`Missing path parameter ${u.join(", ")}`);ua(t.security,n.securitySchemes,s.credentials||{},{headers:o,query:a,cookies:l});let d={url:i+c,method:t.method||"GET",headers:o},y=a.toString();if(y&&(d.url+=(d.url.includes("?")?"&":"?")+y),l.length&&(o.Cookie=l.join("; ")),Object.keys(o).some(g=>g.toLowerCase()==="accept")||(o.Accept="application/json"),f)if(f.contentType==="application/x-www-form-urlencoded"){let g=new URLSearchParams;for(let[p,h]of Object.entries(f.value||{}))g.append(p,Ge(h));d.body=g.toString(),o["Content-Type"]=f.contentType}else d.body=typeof f.value=="string"?f.value:JSON.stringify(f.value),o["Content-Type"]=f.contentType.startsWith("multipart/")?"application/json":f.contentType;return d}function Ye(e){return{isError:!0,content:[{type:"text",text:e}]}}function pa(e,t={}){let r=t.fetch||globalThis.fetch,s={credentials:t.credentials||{},baseUrls:t.baseUrls||{}},n=new Map((e.tools||[]).map(l=>[l.name,l])),i=new Map((e.resources||[]).map(l=>[l.uri,l]));async function o(l,c,f={}){let u;try{u=fa(e,l,c,s),f.headers&&(u.headers={...u.headers,...f.headers})}catch(p){return{error:Ye(p.message)}}let d;try{d=await r(u.url,{method:u.method,headers:u.headers,body:u.body})}catch(p){return{request:u,error:Ye(`Request failed: ${p.message}`)}}let y=await d.text(),g={};return typeof d.headers?.forEach=="function"&&d.headers.forEach((p,h)=>g[h]=p),{request:u,response:d,headers:g,text:y,data:ca(y)}}let a={manifest:e,execute:o,listTools(){return[...n.values()].map(({name:l,description:c,inputSchema:f,annotations:u})=>({name:l,description:c,inputSchema:f,annotations:u}))},listResources(){return[...i.values()].map(({name:l,uri:c,description:f,mimeType:u})=>({name:l,uri:c,description:f,mimeType:u}))},async callTool(l,c={},f={}){let u=n.get(l);if(!u)return Ye(`Unknown tool "${l}"`);if(u.workflow)return t.runWorkflow?t.runWorkflow(a,u,c,f):Ye(`Tool "${l}" is a workflow; this runtime was created without workflow support`);if(!u.operation)return Ye(`Tool "${l}" has nothing to run`);let{error:d,response:y,text:g,data:p}=await o(u.operation,c||{});if(d)return d;let h=p===void 0?g:JSON.stringify(p,null,2);if(!y.ok)return Ye(`HTTP ${y.status}${y.statusText?` ${y.statusText}`:""}
|
|
578
|
+
${h}`);let w={content:[{type:"text",text:h}]};return p&&typeof p=="object"&&!Array.isArray(p)&&(w.structuredContent=p),w},async readResource(l){let c=i.get(l);if(!c)throw Error(`Unknown resource "${l}"`);let{error:f,response:u,text:d}=await o(c.operation,{});if(f)throw Error(f.content[0].text);if(!u.ok)throw Error(`HTTP ${u.status} reading ${l}: ${d}`);return{contents:[{uri:l,mimeType:c.mimeType||"application/json",text:d}]}}};return a}var da=new Set(["authorization","cookie","set-cookie","x-api-key","api-key","apikey","api_key","user-agent","host","content-length","accept","accept-encoding","connection"]);function Ft(e){return e?e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9_]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"").toLowerCase():"tool"}function Qe(e,t=300){if(!e||typeof e!="string")return"";let r=e.replace(/<[^>]*>/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[`*_~#<>]/g,"").replace(/\s+/g," ").trim();return r.length<=t?r:r.slice(0,t-3)+"..."}function ha(e,t){return Ft(`${e}_${t.split("/").filter(Boolean).map(r=>r.startsWith("{")&&r.endsWith("}")?`by_${r.slice(1,-1)}`:r).join("_")}`)}var ma=new Set(["type","title","description","default","enum","const","format","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","maxItems","minItems","uniqueItems","maxProperties","minProperties","required"]),ga=new Set(["items","additionalProperties","not"]),ya=new Set(["allOf","anyOf","oneOf"]);function wn(e,t){if(typeof t=="string"&&t.startsWith("#/"))return t.slice(2).split("/").map(r=>decodeURIComponent(r).replace(/~1/g,"/").replace(/~0/g,"~")).reduce((r,s)=>r&&typeof r=="object"?r[s]:void 0,e)}function me(e,t,r=new Set){if(!e||typeof e!="object")return{};if(e.$ref){let i=wn(t,e.$ref);return!i||typeof i!="object"?{description:`See ${e.$ref}`}:me(i,t,r)}if(r.has(e))return e.type?{type:e.type}:{};r.add(e);let s={},n=!1;for(let[i,o]of Object.entries(e))if(i==="properties"&&o&&typeof o=="object"){s.properties={};for(let[a,l]of Object.entries(o))l?.readOnly!==!0&&(s.properties[a]=me(l,t,r))}else ga.has(i)?s[i]=typeof o=="object"?me(o,t,r):o:ya.has(i)&&Array.isArray(o)?s[i]=o.map(a=>me(a,t,r)):i==="nullable"?n=o===!0:ma.has(i)&&(s[i]=o);r.delete(e),s.properties&&Array.isArray(s.required)&&(s.required=s.required.filter(i=>i in s.properties),s.required.length||delete s.required);for(let[i,o]of[["exclusiveMinimum","minimum"],["exclusiveMaximum","maximum"]])typeof s[i]=="boolean"&&(s[i]&&s[o]!==void 0?(s[i]=s[o],delete s[o]):delete s[i]);return n&&s.type&&![].concat(s.type).includes("null")&&(s.type=[].concat(s.type,"null")),s}var ba=new Set(["path","query","header","cookie"]),wa=new Set(["end","goto","retry"]);function vn(e,t,r){let s=[];for(let[n,i]of(Array.isArray(e)?e:[]).entries()){if(!i||typeof i.condition!="string")continue;let o=typeof i.type=="string"?i.type:i.type?.type||"simple";o==="simple"?s.push({condition:i.condition}):r.push(`${t}[${n}]: criterion type ${o} is not supported, only simple conditions`)}return s}function Wt(e,t,r,s,n,i){let o=[];for(let[a,l]of(Array.isArray(t)?t:[]).entries()){let c=ht(e,l,r);if(!c||!wa.has(c.type))continue;let f=`${s}[${a}]`;if(c.workflowId){i.push(`${f}: ${c.type} to another workflow is not supported`);continue}if(c.stepId&&!n.has(c.stepId)){i.push(`${f}: no step "${c.stepId}"`);continue}let u={name:c.name||"",type:c.type,criteria:vn(c.criteria,f,i)};c.stepId&&(u.stepId=c.stepId),c.type==="retry"&&(u.retryLimit=Number.isFinite(c.retryLimit)?c.retryLimit:1,u.retryAfter=Number.isFinite(c.retryAfter)?c.retryAfter:0),o.push(u)}return o}function kn(e,t){let r=new Set(e.map(s=>s.name).filter(Boolean));return[...e,...t.filter(s=>!s.name||!r.has(s.name))]}function Vt(e,t,r){for(let s of Je(e))s.kind==="workflow"&&r.push(`${t}: ${s.expr} refers to another workflow, which is not supported`)}function va(e,t,r,s,n,i){let o=`steps.${t.stepId}`;if(t.workflowId)return i.push(`${o}: calls workflow "${t.workflowId}", which is not supported`),null;let a=sn(t,s);if(!a){let g=t.operationId||t.operationPath||"(no operation)";return i.push(`${o}: operation ${g} was not found in ${[...s.keys()].join(", ")||"any source"}`),null}let l=[],c=[];for(let[g,p]of(Array.isArray(t.parameters)?t.parameters:[]).entries()){let h=ht(e,p,"parameters");h?.name&&(ba.has(h.in)?(l.push({name:h.name,in:h.in}),c.push({name:h.name,in:h.in,value:h.value}),Vt(h.value,`${o}.parameters[${g}]`,i)):i.push(`${o}.parameters[${g}]: "in" must be path, query, header or cookie`))}let f=null;if(t.requestBody&&typeof t.requestBody=="object"){let g=t.requestBody.contentType||"application/json";f={contentType:g,payload:t.requestBody.payload??null},Array.isArray(t.requestBody.replacements)&&(f.replacements=t.requestBody.replacements.filter(p=>p&&typeof p.target=="string").map(p=>({target:p.target,value:p.value}))),l.push({name:"body",in:"body",contentType:g}),Vt(t.requestBody,`${o}.requestBody`,i)}let u=Wt(e,t.onSuccess,"successActions",`${o}.onSuccess`,n,i),d=Wt(e,t.onFailure,"failureActions",`${o}.onFailure`,n,i),y={};for(let[g,p]of Object.entries(t.outputs||{}))y[g]=p,Vt(p,`${o}.outputs.${g}`,i);return{stepId:t.stepId,description:t.description||"",operation:{source:a.source,method:a.method.toUpperCase(),path:a.path,params:l,security:Array.isArray(a.security)?a.security.filter(g=>g&&typeof g=="object"):[]},parameters:c,requestBody:f,successCriteria:vn(t.successCriteria,`${o}.successCriteria`,i),onSuccess:kn(u,r.successActions),onFailure:kn(d,r.failureActions),outputs:y}}function ka(e,t={}){let r=t.sources||new Map,s=[],n={},i=Array.isArray(e?.workflows)?e.workflows:[];for(let[o,a]of i.entries()){if(!a?.workflowId)continue;let l=[],c=Array.isArray(a.steps)?a.steps:[],f=new Set(c.map(h=>h?.stepId).filter(Boolean)),u={successActions:Wt(e,a.successActions,"successActions","successActions",f,l),failureActions:Wt(e,a.failureActions,"failureActions","failureActions",f,l)},d=c.filter(h=>h?.stepId).map(h=>va(e,h,u,r,f,l)).filter(Boolean);d.length||l.push("has no runnable step");let y={};for(let[h,w]of Object.entries(a.outputs||{}))y[h]=w,Vt(w,`outputs.${h}`,l);if(l.length){t.onProblem?.({level:"error",path:`workflows[${o}]`,message:`workflow ${a.workflowId} is left out of the MCP export: ${l.join("; ")}`});continue}let g=a.inputs?me(a.inputs,e):{type:"object",properties:{}};g.type||="object",g.properties||={};let p=d.map(h=>h.operation.method);s.push({name:Ft(a.workflowId),description:Qe(a.summary||a.description||a.workflowId),inputSchema:g,annotations:{readOnlyHint:p.every(h=>h==="GET"),destructiveHint:p.some(h=>["PUT","PATCH","DELETE"].includes(h)),idempotentHint:!1},workflow:a.workflowId}),n[a.workflowId]={workflowId:a.workflowId,summary:a.summary||"",description:a.description||"",inputs:g,steps:d,outputs:y}}return{tools:s,workflows:n}}var $a=["get","put","post","delete","options","head","patch","trace","query"],xa=["/reference","/currencies","/countries","/tiers","/categories","/status","/schema"],Sa=["type","description","in","name","scheme","bearerFormat","openIdConnectUrl"];function $n(e){return"specLoadError"in e||Array.isArray(e.tags)&&e.tags.some(t=>Array.isArray(t?.paths))}function Rr(e,t){for(let r=0;r<10&&typeof e?.$ref=="string"&&e.$ref.startsWith("#/");r++){let s=t;for(let n of e.$ref.slice(2).split("/")){let i=decodeURIComponent(n).replace(/~1/g,"/").replace(/~0/g,"~");s=s?.[i]}if(!s||typeof s!="object")return e;e=s}return e}function Aa(e,t){let r=[];if(t){for(let n of e.tags||[])for(let i of n.paths||[])r.push({method:String(i.method||"get").toLowerCase(),path:i.path||"",operationId:i.rawOperation?.operationId||"",summary:i.summary||"",description:i.description||"",deprecated:i.deprecated===!0,isWebhook:i.isWebhook===!0,internal:i.xInternal===!0||i.xHidden===!0,parameters:Array.isArray(i.parameters)?i.parameters:[],requestBody:i.requestBody||null,security:i.security,tag:n.name||""});return r}let s=n=>Array.isArray(n)?n.map(i=>Rr(i,e)):[];for(let[n,i]of Object.entries(e.paths||{})){let o=Rr(i,e);if(!o||typeof o!="object")continue;let a=s(o.parameters);for(let l of $a){let c=o[l];if(!c||typeof c!="object")continue;let f=s(c.parameters),u=a.filter(d=>!f.some(y=>y?.name===d?.name&&y?.in===d?.in)).concat(f);r.push({method:l,path:n,operationId:c.operationId||"",summary:c.summary||"",description:c.description||"",deprecated:c.deprecated===!0,isWebhook:!1,internal:c["x-internal"]===!0||c["x-hidden"]===!0||o["x-internal"]===!0||o["x-hidden"]===!0,parameters:u,requestBody:Rr(c.requestBody,e)||null,security:c.security??e.security,tag:Array.isArray(c.tags)&&c.tags[0]||""})}}return r}function xn(e,t){let r={},s=(n,i)=>{if(!i||typeof i!="object"||!i.type)return;let o={};for(let a of Sa)i[a]!==void 0&&(o[a]=i[a]);i.type==="oauth2"&&i.flows&&typeof i.flows=="object"&&(o.flows=i.flows),r[n]=o};if(t)for(let n of e.securitySchemes||[])n?.securitySchemeId&&n.securitySchemeId!=="_rapidoc_api_key"&&s(n.securitySchemeId,n.type==="apiKey"?n:{...n,in:void 0,name:void 0});else{let n=e.components?.securitySchemes||e.securityDefinitions||{};for(let[i,o]of Object.entries(n))s(i,o?.$ref?wn(e,o.$ref):o)}return r}function Sn(e,t){let r=e.servers?.[0];if(r?.url){let s=String(r.url);for(let[n,i]of Object.entries(r.variables||{}))s=s.split(`{${n}}`).join(String(i?.default??i?.enum?.[0]??""));return s}return!t&&e.host?`${e.schemes?.[0]||"https"}://${e.host}${e.basePath||""}`:"http://localhost"}function An(e,t){if(e.schema)return me(e.schema,t);if(e.content&&typeof e.content=="object"){let s=Object.values(e.content)[0];if(s?.schema)return me(s.schema,t)}let r={};for(let s of["type","format","enum","items","default","minimum","maximum","pattern"])e[s]!==void 0&&(r[s]=e[s]);return r.type?me(r,t):{type:"string"}}function Ia(e){let t=e?.content;if(!t||typeof t!="object")return null;let r=Object.keys(t),s=r.find(n=>n==="application/json")||r.find(n=>n.endsWith("+json"))||r.find(n=>n==="application/x-www-form-urlencoded")||r.find(n=>n==="multipart/form-data")||r[0];return s?{contentType:s,schema:t[s]?.schema}:null}function Ea(e,t={}){let r=e&&typeof e=="object"?e:{},s=$n(r),{includeInternal:n=!1,includeDeprecated:i=!1,includeOperations:o=!0}=t,a=r.info||{},l=a.title||"OpenAPI MCP Server",c=typeof t.arazzo=="string"?JSON.parse(t.arazzo):t.arazzo,f=(c?.sourceDescriptions||[]).find(b=>b?.name&&(!b.type||b.type==="openapi")),u=t.sourceName||f?.name||"api",d=xn(r,s),y=new Set(Object.values(d).filter(b=>b.type==="apiKey"&&b.name).map(b=>`${b.in||"header"}:${String(b.name).toLowerCase()}`)),g=[],p=[],h=new Map;for(let b of o?Aa(r,s):[]){if(b.isWebhook||b.internal&&!n||b.deprecated&&!i)continue;let S={},k=[],x=[];for(let M of b.parameters){if(!M?.name)continue;let m=M.in||"query",v=String(M.name).toLowerCase();if(m==="header"&&da.has(v)||y.has(`${m}:${v}`))continue;if(m==="body"){let L=An(M,r);M.description&&(L.description=Qe(M.description)),S.body=L,M.required&&k.push("body"),x.push({name:"body",in:"body",contentType:"application/json"});continue}if(m==="formData")continue;let O=M.name;O in S&&(O=`${M.name}_${m}`);let _=An(M,r);M.description&&(_.description=Qe(M.description)),S[O]=_,(M.required||m==="path")&&k.push(O),x.push(O===M.name?{name:M.name,in:m}:{name:M.name,in:m,arg:O})}let I=Ia(b.requestBody);if(I){let M=I.schema?me(I.schema,r):{type:"object"};b.requestBody.description&&(M.description=Qe(b.requestBody.description)),S.body=M,b.requestBody.required&&k.push("body"),x.push({name:"body",in:"body",contentType:I.contentType})}let A={type:"object",properties:S};k.length&&(A.required=k);let q=Ft(b.operationId||ha(b.method,b.path)),T=h.get(q)||0;h.set(q,T+1),T&&(q=`${q}_${T+1}`);let j=Qe(b.summary||b.description||`${b.method.toUpperCase()} ${b.path}`),F={source:u,method:b.method.toUpperCase(),path:b.path,params:x,security:Array.isArray(b.security)?b.security.filter(M=>M&&typeof M=="object"):[]},ke=b.method==="get";ke&&!k.length&&xa.some(M=>b.path.includes(M))?p.push({name:q,uri:`reference://${q.replace(/^get_/,"").replace(/_/g,"-")}`,description:j,mimeType:"application/json",operation:F}):g.push({name:q,description:j,inputSchema:A,annotations:{readOnlyHint:ke,destructiveHint:["put","patch","delete"].includes(b.method),idempotentHint:["get","put","delete"].includes(b.method)},operation:F})}let w={},$={[u]:{baseUrl:Sn(r,s),securitySchemes:d}};if(c&&typeof c=="object"){let b=new Map([[u,s?qr(r):Mr(r)]]);for(let[k,x]of Object.entries(t.sources||{})){if(k===u||!x||typeof x!="object")continue;let I=$n(x);b.set(k,I?qr(x):Mr(x)),$[k]={baseUrl:Sn(x,I),securitySchemes:xn(x,I)}}let S=ka(c,{sources:b,onProblem:t.onProblem});for(let k of S.tools){let x=h.get(k.name)||0;h.set(k.name,x+1),g.push(x?{...k,name:`${k.name}_${x+1}`}:k)}Object.assign(w,S.workflows)}return{manifestVersion:1,server:{name:Ft(t.serverName||l),version:a.version||"1.0.0",description:Qe(a.description||"")},sources:$,tools:g,resources:p,workflows:w}}function In(e){return typeof e=="string"?e:e&&typeof e=="object"?JSON.stringify(e):String(e)}function Jt(e){return{isError:!0,content:[{type:"text",text:e}]}}function Oa(e,t){if(!t)return e;let r=e;for(let s of t.split("/").slice(1)){let n=s.replace(/~1/g,"/").replace(/~0/g,"~");if(typeof r!="object"||!r)return;r=r[n]}return r}function Gt(e,t){let r=e;for(let s of t){if(typeof r!="object"||!r)return;r=r[s]}return r}function Br(e,t){let r=String(e).match(/^\$([A-Za-z]+)((?:\.[^.#\s]+)*)(?:#(.*))?$/);if(!r)return;let[,s,n,i]=r,o=n?n.slice(1).split("."):[];switch(s){case"inputs":return Gt(t.inputs||{},o);case"steps":return Gt(t.steps||{},o);case"statusCode":return t.response?.status;case"url":return t.request?.url;case"method":return t.request?.method;case"response":case"request":{let a=t[s];if(!a)return;let[l,...c]=o;if(l==="body")return Gt(Oa(a.body,i||""),c);if(l==="header"||l==="headers"){let f=c.join(".").toLowerCase(),u=a.headers||{},d=Object.keys(u).find(y=>y.toLowerCase()===f);return d===void 0?void 0:u[d]}return l==="query"||l==="path"?Gt(a[l]||{},c):void 0}default:return}}var Ca=/^\$[A-Za-z][^\s{}]*$/;function _e(e,t){if(typeof e=="string")return Ca.test(e)?Br(e,t):e.replace(/\{(\$[^{}]+)\}/g,(r,s)=>{let n=Br(s,t);return n==null?"":In(n)});if(Array.isArray(e))return e.map(r=>_e(r,t));if(e&&typeof e=="object"){let r={};for(let[s,n]of Object.entries(e))r[s]=_e(n,t);return r}return e}function _a(e){let t=[],r=/\s*(?:(&&|\|\||==|!=|<=|>=|<|>|!|\(|\))|('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?)|(\$[^\s()&|=!<>]+)|(true|false|null))/y,s=0;for(;;){r.lastIndex=s;let n=r.exec(e);if(!n)break;s=r.lastIndex,n[1]?t.push({op:n[1]}):n[2]?t.push({value:n[2].slice(1,-1).replace(/\\(.)/g,"$1")}):n[3]?t.push({value:Number(n[3])}):n[4]?t.push({expr:n[4]}):n[5]&&t.push({value:n[5]==="true"||n[5]!=="false"&&null})}if(e.slice(s).trim())throw Error(`Cannot parse condition "${e}"`);return t}function En(e,t){if(e===t)return!0;let r=s=>s==null;return r(e)||r(t)?r(e)&&r(t):typeof e=="object"||typeof t=="object"?JSON.stringify(e)===JSON.stringify(t):String(e)===String(t)}function On(e,t){let r=_a(e),s=0,n=()=>r[s],i=(...u)=>n()?.op&&u.includes(n().op)?r[s++].op:null,o=()=>{if(i("!"))return!o();if(i("(")){let d=c();if(!i(")"))throw Error(`Missing ) in "${e}"`);return d}let u=r[s++];if(!u||u.op)throw Error(`Unexpected ${u?u.op:"end"} in "${e}"`);return u.expr===void 0?u.value:Br(u.expr,t)},a=()=>{let u=o(),d=i("==","!=","<=",">=","<",">");if(!d)return u;let y=o();if(d==="==")return En(u,y);if(d==="!=")return!En(u,y);let[g,p]=[Number(u),Number(y)];return d==="<"?g<p:d===">"?g>p:d==="<="?g<=p:g>=p},l=()=>{let u=a();for(;i("&&");)u=a()&&u;return u},c=()=>{let u=l();for(;i("||");)u=l()||u;return u},f=c();if(s<r.length)throw Error(`Unexpected ${r[s].op??"token"} in "${e}"`);return!!f}function Na(e,t,r){let s=String(t).split("/").slice(1).map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~"));if(!s.length)return r;let n=Array.isArray(e)?[...e]:{...e},i=n;for(let[o,a]of s.entries()){if(o===s.length-1){i[a]=r;break}let l=i[a];i[a]=Array.isArray(l)?[...l]:{...l},i=i[a]}return n}var Cn=1e3;function Ta(e,t){return(e||[]).every(r=>{try{return On(r.condition,t)}catch{return!1}})}async function ja(e,t,r,s={}){let n=e.manifest.workflows?.[t.workflow];if(!n)return Jt(`Workflow "${t.workflow}" is not in the manifest`);let i=s.sleep||(p=>new Promise(h=>setTimeout(h,p))),o=r||{},a=(n.inputs?.required||[]).filter(p=>o[p]===void 0);if(a.length)return Jt(`Missing input ${a.join(", ")}`);let l=n.steps,c=p=>l.findIndex(h=>h.stepId===p),f={},u=new Map,d=0,y=0;for(;d>=0&&d<l.length;){if(++y>Cn)return Jt(`Workflow ${n.workflowId} ran more than ${Cn} steps`);let p=l[d],h=(u.get(p.stepId)||0)+1;u.set(p.stepId,h);let w={inputs:o,steps:f},$={};for(let m of p.parameters||[])$[m.name]=_e(m.value,w);if(p.requestBody){let m=_e(p.requestBody.payload,w);for(let v of p.requestBody.replacements||[])m=Na(m,v.target,_e(v.value,w));$.body=m}let b={workflowId:n.workflowId,stepId:p.stepId,attempt:h};s.onStepStart?.(b);let S=s.requestHeaders?.({...b,operation:p.operation}),k=await e.execute(p.operation,$,S?{headers:S}:{}),x={...w,request:k.request&&{url:k.request.url,method:k.request.method,headers:k.request.headers,body:$.body},response:k.response&&{status:k.response.status,headers:k.headers,body:k.data===void 0?k.text:k.data}},I=k.error?k.error.content[0].text:"";if(I||(p.successCriteria||[]).length||k.response.ok||(I=`HTTP ${k.response.status}`),!I)for(let m of p.successCriteria||[]){let v;try{v=On(m.condition,x)}catch(O){v=!1,I=O.message}if(!v){I||=m.condition;break}}let A=I?"failure":"success",q;if(A==="success"){q={};for(let[m,v]of Object.entries(p.outputs||{}))q[m]=_e(v,x);f[p.stepId]={outputs:q}}let T=((A==="success"?p.onSuccess:p.onFailure)||[]).find(m=>Ta(m.criteria,x));s.onStep?.({workflowId:n.workflowId,stepId:p.stepId,attempt:h,outcome:A,request:x.request,response:x.response,outputs:q,failedCriterion:I||void 0,action:T?{type:T.type,name:T.name,stepId:T.stepId}:null});let j=m=>Jt(`Workflow ${n.workflowId} failed at step ${p.stepId}: ${m}`+(x.response?`
|
|
579
|
+
HTTP ${x.response.status}
|
|
580
|
+
${In(x.response.body)}`:""));if(A==="success"){if(!T)d++;else{if(T.type==="end")break;T.type==="goto"?d=c(T.stepId):d++}continue}if(!T||T.type==="end")return j(I);if(T.type==="goto"){d=c(T.stepId);continue}let F=T.stepId?c(T.stepId):d,ke=`${p.stepId}:${T.name}`,M=(u.get(ke)||0)+1;if(u.set(ke,M),M>(T.retryLimit??1))return j(`${I} (after ${T.retryLimit??1} retries)`);T.retryAfter&&await i(T.retryAfter*1e3),d=F}let g={};for(let[p,h]of Object.entries(n.outputs||{}))g[p]=_e(h,{inputs:o,steps:f});return{content:[{type:"text",text:JSON.stringify(g,null,2)}],structuredContent:g}}function La(e,t={}){return pa(e,{...t,runWorkflow:(r,s,n,i)=>ja(r,s,n,{sleep:t.sleep,...i})})}function U(e,t,r,s){var n=arguments.length,i=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(n<3?o(i):n>3?o(t,r,i):o(t,r))||i);return n>3&&i&&Object.defineProperty(t,r,i),i}var Ma=0,R=class extends rt{constructor(...e){super(...e),this.arazzoUrl="",this.specUrl="",this.workflowId="",this.for="",this.theme=lr,this.colorScheme="dark",this.view="expanded",this.showViewToggle="true",this.allowRun="true",this.serverUrl="",this.doc=null,this.sources=new Map,this.problems=[],this.loading=!1,this.loadError="",this.selectedStepId="",this.specObjects=new Map,this.runState="idle",this.runInputs={},this.statusCodes={},this.mockStrategy="cycle",this.manualCredentials={},this.runningStepId="",this.trace=[],this.runResult=null,this.runProblem="",this.loadId=0,this.specDoc=null,this.onSpecLoaded=()=>this.useRapiDocSpec(),this.linkedStepId="",this.idPrefix=`rf${++Ma}`,this._autoColorScheme=new mi(this)}static{this.styles=[di,hi,Xt`:host{color:var(--foreground);background:var(--background);font-family:var(--font-sans);font-size:var(--font-size-regular);line-height:var(--line-height);padding:1rem 1.25rem;display:block}.flow-header{flex-wrap:wrap;align-items:baseline;gap:.5rem 1rem;margin-bottom:.25rem;display:flex}.flow-title{font-size:var(--h4-font-size);font-weight:var(--heading-weight);color:var(--heading-color);margin:0}.flow-id{font-family:var(--font-mono);font-size:var(--font-size-small);color:var(--muted-foreground)}.flow-controls{flex-wrap:wrap;align-items:center;gap:.5rem;margin-left:auto;display:flex}.view-toggle{border:1px solid var(--input);border-radius:var(--radius);display:inline-flex;overflow:hidden}.view-toggle button{font:inherit;font-size:var(--font-size-small);color:var(--muted-foreground);background:var(--input-background);cursor:pointer;border:0;padding:.25rem .625rem}.view-toggle button+button{border-left:1px solid var(--input)}.view-toggle button[aria-pressed=true]{color:var(--primary-foreground);background:var(--primary)}.view-toggle button:focus-visible{outline:2px solid var(--ring);outline-offset:-2px}select{font:inherit;font-size:var(--font-size-small);color:var(--foreground);background:var(--input-background);border:1px solid var(--input);border-radius:var(--radius);padding:.25rem .5rem}.flow-description{color:var(--muted-foreground);font-size:var(--font-size-description);margin:0 0 .75rem}.flow-diagram{overflow-x:auto}.flow-message{color:var(--muted-foreground);font-size:var(--font-size-description)}.flow-problems{font-size:var(--font-size-small);color:var(--destructive);margin:.75rem 0 0;padding-left:1.25rem}.run-button{font:inherit;font-size:var(--font-size-small);color:var(--primary-foreground);background:var(--primary);border:1px solid var(--primary);border-radius:var(--radius);cursor:pointer;padding:.25rem .75rem}.run-button:disabled{opacity:.6;cursor:default}.run-clear{font:inherit;font-size:var(--font-size-small);color:var(--muted-foreground);background:var(--input-background);border:1px solid var(--input);border-radius:var(--radius);cursor:pointer;padding:.25rem .75rem}.flow-run{font-size:var(--font-size-description);margin-top:1rem}.flow-run h3{font-size:var(--h5-font-size);font-weight:var(--heading-weight);color:var(--heading-color);margin:1rem 0 .5rem}.flow-run h4{font-size:var(--font-size-small);font-weight:var(--heading-weight);color:var(--muted-foreground);margin:.5rem 0 .25rem}.flow-run pre{background:var(--muted);border-radius:var(--radius);font-family:var(--font-mono);font-size:var(--font-size-small);white-space:pre-wrap;word-break:break-word;margin:0;padding:.5rem;overflow-x:auto}.flow-run .muted{color:var(--muted-foreground)}.run-inputs{border:1px solid var(--border);border-radius:var(--radius);background:var(--card);margin:0 0 .75rem;padding:.5rem .75rem;container-type:inline-size}.run-inputs h3{font-size:var(--font-size-small);font-weight:var(--heading-weight);color:var(--muted-foreground);margin:.25rem 0 .5rem}.run-inputs p{margin:.25rem 0 .5rem}.run-field{font-size:var(--font-size-small);grid-template-columns:minmax(8rem,14rem) minmax(0,1fr);align-items:center;column-gap:1rem;margin:.5rem 0;display:grid}.run-field-label{text-align:right;flex-direction:column;min-width:0;display:flex}.run-field-name,.run-field-type{overflow-wrap:anywhere;margin:1px 0;line-height:1.35}.run-field-name{color:var(--foreground);font-family:var(--font-mono)}.run-field-type{color:var(--muted-foreground);font-family:var(--font-sans)}.run-field-required{color:var(--destructive)}.run-inputs .run-field :is(input,select){font-family:var(--font-mono);padding:.75em;line-height:1.25}@container (width<=28rem){.run-field{grid-template-columns:minmax(0,1fr);row-gap:.25rem}.run-field-label{text-align:start;flex-flow:wrap;gap:.5rem}}.run-inputs input,.run-inputs select{font:inherit;font-size:var(--font-size-small);color:var(--foreground);background:var(--input-background);border:1px solid var(--input);border-radius:var(--radius);min-width:0;padding:.25rem .5rem}.run-mock{margin-top:.75rem}.run-mock summary{cursor:pointer;font-weight:600}.run-mock summary .muted{margin-left:.5rem;font-weight:400}.run-mock-rows{margin-top:.25rem}.run-inputs .run-mock-strategy{align-items:center;gap:.5rem;margin-top:.5rem;display:flex}.run-mock-strategy select{flex:none;width:auto}.run-actions{gap:.5rem;margin-top:.75rem;display:flex}.run-trace{margin:0;padding:0;list-style:none}.run-trace li{border:1px solid var(--border);border-radius:var(--radius);background:var(--card);margin-bottom:.375rem}.run-trace li.trace-failure{border-color:var(--destructive)}.run-trace summary{cursor:pointer;flex-wrap:wrap;align-items:baseline;gap:.25rem .75rem;padding:.375rem .75rem;display:flex}.run-trace details[open] summary{border-bottom:1px solid var(--border)}.run-trace details>:not(summary){margin-left:.75rem;margin-right:.75rem}.run-trace details>pre:last-child{margin-bottom:.75rem}.trace-step{font-weight:600}.trace-request{font-family:var(--font-mono);font-size:var(--font-size-small);color:var(--muted-foreground);word-break:break-all}.trace-success .trace-outcome{color:var(--green)}.trace-failure .trace-outcome,.run-problem,.run-error{color:var(--destructive)}.flow-problems .warning{color:var(--muted-foreground)}code,pre{font-family:var(--font-mono);font-size:var(--font-size-small)}.flow-legend{font-size:var(--font-size-xs);color:var(--muted-foreground);flex-wrap:wrap;gap:.25rem 1rem;margin:.75rem 0 0;padding:0;list-style:none;display:flex}.flow-legend li{align-items:center;gap:.375rem;display:flex}.flow-legend svg{overflow:visible}`]}connectedCallback(){super.connectedCallback(),this.theme=os(this.theme).theme,this.getAttribute("theme")||this.setAttribute("theme",this.theme),"dark, light, system, auto,".includes(`${this.colorScheme},`)||(this.colorScheme="dark"),this.getAttribute("color-scheme")||this.setAttribute("color-scheme",this.colorScheme),as(this,this.theme),this.doc&&(this.watchRapiDoc(),this.useRapiDocSpec())}disconnectedCallback(){super.disconnectedCallback(),this.specDoc?.removeEventListener("spec-loaded",this.onSpecLoaded),this.specDoc=null}updated(e){if(e.has("theme")){let t=os(this.theme).theme;t!==this.theme&&(this.theme=t),as(this,this.theme)}(e.has("arazzoUrl")||e.has("specUrl")||e.has("for"))&&this.load(),this.linkedStepId=""}async load(){let e=++this.loadId;if(!this.arazzoUrl)this.doc=null;else{this.loading=!0,this.loadError="";try{let t=new URL(this.arazzoUrl,document.baseURI).href,r=rn(await this.fetchText(t));this.watchRapiDoc();let s=Mo(r),n=new Map,i=new Map,o=(r.sourceDescriptions||[]).filter(a=>a?.name&&a?.url&&(!a.type||a.type==="openapi"));if(await Promise.all(o.map(async(a,l)=>{if(l===0&&this.specDoc)return;let c=l===0&&this.specUrl?this.specUrl:a.url;try{let f=rn(await this.fetchText(new URL(c,l===0&&this.specUrl?document.baseURI:t).href));n.set(a.name,Mr(f)),i.set(a.name,f)}catch(f){s.push({level:"warning",path:`sourceDescriptions.${a.name}`,message:`could not load ${c}: ${f.message}`})}})),e!==this.loadId)return;this.doc=r,this.sources=n,this.specObjects=i,this.problems=s,this.resetRun(),this.useRapiDocSpec(),this.dispatchEvent(new CustomEvent("flow-loaded",{detail:{doc:r,problems:s},bubbles:!0,composed:!0}))}catch(t){if(e!==this.loadId)return;this.doc=null,this.loadError=t.message}finally{e===this.loadId&&(this.loading=!1)}}}async fetchText(e){let t=await fetch(e);if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.text()}get arazzoDocument(){return this.doc}get workflowRuntimeSource(){return yi}get workflowIds(){return(this.doc?.workflows||[]).map(e=>e?.workflowId).filter(Boolean)}get graph(){if(!this.doc)return null;let e=this.workflowIds,t=e.includes(this.workflowId)?this.workflowId:e[0];return Ko(this.doc,t,{sources:this.sources})}watchRapiDoc(){let e=this.specUrl?null:this.findRapiDoc();e!==this.specDoc&&(this.specDoc?.removeEventListener("spec-loaded",this.onSpecLoaded),this.specDoc=e,e?.addEventListener("spec-loaded",this.onSpecLoaded))}useRapiDocSpec(){let e=(this.doc?.sourceDescriptions||[]).find(r=>r?.name&&r?.url&&(!r.type||r.type==="openapi")),t=this.specDoc?.resolvedSpec;e&&t&&(this.sources=new Map(this.sources).set(e.name,qr(t)))}findRapiDoc(){return this.for?this.getRootNode().getElementById?.(this.for)||document.getElementById(this.for):null}selectStep(e){let t=this.graph,r=t?.steps.find(o=>o.stepId===e);if(!r)return;this.selectedStepId=e;let s=r.operation;if(this.dispatchEvent(new CustomEvent("step-click",{detail:{workflowId:t.workflowId,stepId:e,operation:s,workflowRef:r.workflowId},bubbles:!0,composed:!0})),r.kind==="workflow"&&this.workflowIds.includes(r.workflowId)){this.workflowId=r.workflowId;return}let n=this.findRapiDoc();if(!s||!n?.resolvedSpec)return;let i=(n.resolvedSpec.tags||[]).flatMap(o=>o.paths||[]).find(o=>s.operationId&&o.operationId===s.operationId||o.method===s.method&&o.path===s.path);i?.elementId&&n.scrollToPath(i.elementId)}onDiagramEvent(e){if(e instanceof KeyboardEvent&&e.key!=="Enter"&&e.key!==" ")return;let t=e.target?.closest?.(".rf-jump, .rf-clickable");if(t)if(e.preventDefault(),t.classList.contains("rf-jump")){let r=t.getAttribute("data-from-step")||"";this.selectStep(r),this.updateComplete.then(()=>{let s=`.rf-step[data-step-id="${CSS.escape(r)}"]`,n=this.renderRoot.querySelector(s);n&&this.scrollToCenter(n.getBoundingClientRect())})}else this.selectStep(t.getAttribute("data-step-id")||"")}onDiagramHover(e){let t=e.type==="mouseleave"?null:e.target?.closest?.("[data-step-id], [data-from-step]"),r=t?.getAttribute("data-step-id")||t?.getAttribute("data-from-step")||"";if(r===this.linkedStepId)return;this.linkedStepId=r;let s=this.renderRoot.querySelector(".flow-diagram svg");if(!s||(s.querySelectorAll(".rf-linked").forEach(i=>i.classList.remove("rf-linked")),!r))return;let n=CSS.escape(r);s.querySelectorAll(`[data-step-id="${n}"], [data-from-step="${n}"]`).forEach(i=>i.classList.add("rf-linked"))}scrollToCenter(e){let t=i=>i.parentElement||i.getRootNode().host||null,r=t(this);for(;r;){let{overflowY:i}=getComputedStyle(r);if(/(auto|scroll)/.test(i)&&r.scrollHeight>r.clientHeight)break;r=t(r)}let s=r?r.getBoundingClientRect():{top:0,height:window.innerHeight},n=e.top-s.top-(s.height-Math.min(e.height,s.height))/2;(r||window).scrollBy({top:n,behavior:"smooth"})}setView(e){e!==this.view&&(this.view=e,this.dispatchEvent(new CustomEvent("view-change",{detail:{view:e},bubbles:!0,composed:!0})))}resetRun(){this.runState="idle",this.runningStepId="",this.trace=[],this.runResult=null,this.runProblem="";let e={};for(let t of this.graph?.inputDetails||[])t.default!==void 0&&(e[t.name]=typeof t.default=="string"?t.default:JSON.stringify(t.default));this.runInputs=e}credentialsFromRapiDoc(e){let t={};for(let r of e?.resolvedSpec?.securitySchemes||[]){let s=r?.finalKeyValue;s&&r.securitySchemeId&&(r.type==="apiKey"?t[r.securitySchemeId]=s:/^basic /i.test(s)?t[r.securitySchemeId]=atob(s.slice(6)):t[r.securitySchemeId]=s.replace(/^(bearer|mac)\s+/i,""))}return t}prepareRun(e){let t=this.findRapiDoc(),r=(this.doc.sourceDescriptions||[]).find(l=>l?.name&&(!l.type||l.type==="openapi")),s=this.specDoc?.resolvedSpec||this.specObjects.get(r?.name);if(!s)return{problem:"the OpenAPI document of the first source is not loaded"};let n=[],i=Ea(s,{arazzo:this.doc,sources:Object.fromEntries(this.specObjects),onProblem:l=>n.push(l)}),o=i.tools.find(l=>l.workflow===e.workflowId);if(!o){let l=n.find(c=>c.message.includes(`workflow ${e.workflowId} `));return{problem:l?l.message.replace(/^workflow \S+ is left out of the MCP export: /,""):"this workflow cannot be run"}}let a=this.serverUrl||t?.selectedServer?.computedUrl;return{runtime:La(i,{credentials:{...this.typedCredentials(),...this.credentialsFromRapiDoc(t)},baseUrls:a?{[r.name]:a}:{}}),tool:o}}coerceInputs(e){let t={};for(let r of e.inputDetails){let s=this.runInputs[r.name];if(s===void 0||s==="")continue;let n=String(r.type||"string"),i=s;if(/^(integer|number)/.test(n))i=Number(s);else if(n.startsWith("boolean"))i=s==="true";else if(/^(object|array)/.test(n))try{i=JSON.parse(s)}catch{i=s}t[r.name]=i}return t}async executeRun(e){let t=this.prepareRun(e);if(this.runningStepId="",this.trace=[],this.runResult=null,this.runProblem="",!t.runtime){this.runProblem=t.problem,this.runState="done";return}let r=this.coerceInputs(e);this.runState="running";let s=this.findRapiDoc(),n=s?.mockServer==="true",i=this.statusCodesByStep(e),o=Object.values(i).some(f=>f.includes(",")),a=n&&Object.keys(i).length&&{code:s.mockServerStatusCode,strategy:s.mockServerStatusStrategy};if(a){let f={};for(let u of e.steps){let d=u.operation;d&&i[u.stepId]&&(f[`${d.method.toUpperCase()} ${d.path}`]=i[u.stepId])}i["*"]&&(f["*"]=i["*"]),s.mockServerStatusCode=f,s.mockServerStatusStrategy=o?this.mockStrategy:"first",await s.updateComplete}let l=(f,u)=>{let d=f.split(",").map(y=>y.trim()).filter(Boolean);return d.length?this.mockStrategy==="random"&&d.length>1?d[Math.floor(Math.random()*d.length)]:d[(u-1)%d.length]:""},c=await t.runtime.callTool(t.tool.name,r,{onStepStart:f=>this.runningStepId=f.stepId,onStep:f=>{this.runningStepId="",this.trace=[...this.trace,{...f,mocked:n}]},requestHeaders:n?void 0:f=>{let u=l(i[f.stepId]||i["*"]||"",f.attempt);return u?{Prefer:`code=${u}`}:void 0}});a&&(s.mockServerStatusCode=a.code,s.mockServerStatusStrategy=a.strategy),this.runResult=c,this.runState="done",this.dispatchEvent(new CustomEvent("workflow-run",{detail:{workflowId:e.workflowId,inputs:r,result:c,trace:this.trace},bubbles:!0,composed:!0}))}standaloneSchemes(){if(this.findRapiDoc())return[];let e=new Map;for(let t of this.specObjects.values()){let r=t?.components?.securitySchemes||t?.securityDefinitions||{};for(let[s,n]of Object.entries(r))n&&typeof n=="object"&&n.type&&!e.has(s)&&e.set(s,{id:s,type:n.type,scheme:n.scheme,in:n.in,name:n.name})}return[...e.values()]}typedCredentials(){let e={};for(let[t,r]of Object.entries(this.manualCredentials)){if(!r)continue;let s=this.standaloneSchemes().find(n=>n.id===t);e[t]=s?.type==="http"&&String(s.scheme).toLowerCase()==="basic"?r:r.replace(/^bearer\s+/i,"")}return e}field(e,t,r,{required:s=!1,mono:n=!0}={}){return E`<label class="run-field"><span class="run-field-label"><span class="run-field-name" style="${n?"":"font-family: var(--font-sans)"}">${s?E`<span class="run-field-required" title="Required">*</span>`:C}${e} </span>${t?E`<span class="run-field-type">${t}</span>`:C} </span>${r}</label>`}renderCredentials(){let e=this.standaloneSchemes();if(!e.length)return C;let t=r=>r.type==="apiKey"?`API key (${r.in||"header"} ${r.name})`:r.type==="http"&&String(r.scheme).toLowerCase()==="basic"?"user:password":"token";return E`<h3>Credentials <span class="muted">kept in this page only</span></h3>${e.map(r=>this.field(r.id,r.type,E`<input type="password" name="${`credential-${r.id}`}" autocomplete="off" .value="${this.manualCredentials[r.id]??""}" placeholder="${t(r)}" @input="${s=>this.manualCredentials={...this.manualCredentials,[r.id]:s.target.value}}">`))}`}statusCodesByStep(e){let t={},r=new Set(e.steps.map(s=>s.stepId));for(let[s,n]of Object.entries(this.statusCodes||{})){let i=String(n??"").trim();i&&(s==="*"||r.has(s))&&(t[s]=i)}return t}renderStatusCodes(e){let t=this.findRapiDoc()?.mockServer==="true",r=(i,o)=>this.statusCodes={...this.statusCodes,[i]:o},s=Object.values(this.statusCodes||{}).some(i=>String(i).includes(",")),n=e.steps.filter(i=>i.operation);return E`<details class="run-mock" ?open="${t||Object.keys(this.statusCodesByStep(e)).length>0}"><summary>Mock Response Status <span class="muted">${t?"the in-browser mock answers with":"sent as Prefer: code= (rapidoc mock)"}</span></summary><div class="run-mock-rows">${this.field("Every step","empty: success response",E`<input name="mock-status" inputmode="numeric" .value="${this.statusCodes?.["*"]??""}" placeholder="e.g. 404, or 503, 200" @input="${i=>r("*",i.target.value)}">`,{mono:!1})} ${n.map(i=>this.field(i.stepId,`${i.operation.method.toUpperCase()} ${i.operation.path}`,E`<input name="${`mock-status-${i.stepId}`}" inputmode="numeric" .value="${this.statusCodes?.[i.stepId]??""}" placeholder="Same as every step" @input="${o=>r(i.stepId,o.target.value)}">`))}</div>${s?E`<label class="run-mock-strategy"><span class="muted">Several codes are used</span> <select aria-label="How the codes are used" @change="${i=>this.mockStrategy=i.target.value}"><option value="cycle" ?selected="${this.mockStrategy==="cycle"}">in turn, per step</option><option value="random" ?selected="${this.mockStrategy==="random"}">at random</option></select></label>`:C}</details>`}renderInputsForm(e){let t=(s,n)=>this.runInputs={...this.runInputs,[s]:n},r=this.runState==="running";return E`<form class="run-inputs" part="run-inputs" @submit="${s=>{s.preventDefault(),r||this.executeRun(e)}}">${this.renderCredentials()} ${e.inputDetails.length?E`<h3>Inputs</h3>`:E`<p class="muted">This workflow takes no inputs.</p>`} ${e.inputDetails.map(s=>this.field(s.name,s.type,s.enum?E`<select name="${s.name}" @change="${n=>t(s.name,n.target.value)}"><option value="" ?selected="${!this.runInputs[s.name]}"></option>${s.enum.map(n=>E`<option value="${String(n)}" ?selected="${String(n)===this.runInputs[s.name]}">${String(n)}</option>`)}</select>`:E`<input name="${s.name}" .value="${this.runInputs[s.name]??""}" placeholder="${s.description||""}" ?required="${s.required}" @input="${n=>t(s.name,n.target.value)}">`,{required:s.required}))} ${this.renderStatusCodes(e)}<div class="run-actions"><button type="submit" class="run-button" part="run-button" ?disabled="${r}">${r?"Running\u2026":"\u25B6 Run workflow"}</button> ${this.runState==="done"?E`<button type="button" class="run-clear" @click="${()=>this.resetRun()}">Clear</button>`:C}</div></form>`}renderTraceEntry(e,t){let r=s=>{let n=typeof s=="string"?s:JSON.stringify(s,null,2);return n&&n.length>4e3?`${n.slice(0,4e3)}\u2026`:n};return E`<li class="trace-${e.outcome}"><details ?open="${e.outcome==="failure"}"><summary><span class="trace-step">${t+1}. ${e.stepId}</span> ${e.attempt>1?E`<span class="muted">attempt ${e.attempt}</span>`:C} <span class="trace-request">${e.request?.method} ${e.request?.url}</span> <span class="trace-status">${e.response?`HTTP ${e.response.status}`:"no response"}${e.mocked?E`<span class="muted">mocked</span>`:C}</span> <span class="trace-outcome">${e.outcome==="success"?"\u2713":"\u2717"}</span> ${e.failedCriterion?E`<code>${e.failedCriterion}</code>`:C} ${e.action?E`<span class="muted">→ ${e.action.type}${e.action.stepId?` ${e.action.stepId}`:""}</span>`:C}</summary>${e.request?.body===void 0?C:E`<h4>Request body</h4><pre>${r(e.request.body)}</pre>`} ${e.response?E`<h4>Response</h4><pre>${r(e.response.body)}</pre>`:C} ${e.outputs&&Object.keys(e.outputs).length?E`<h4>Outputs</h4><pre>${r(e.outputs)}</pre>`:C}</details></li>`}renderRun(e){return this.allowRun==="false"?C:E`<section class="flow-run" part="run"><h3>Run</h3>${this.renderInputsForm(e)} ${this.trace.length?E`<h4>Log</h4><ol class="run-trace">${this.trace.map((t,r)=>this.renderTraceEntry(t,r))}</ol>`:C} ${this.runProblem?E`<p class="run-problem">Cannot run this workflow: ${this.runProblem}</p>`:C} ${this.runResult?this.runResult.isError?E`<pre class="run-error">${this.runResult.content[0].text}</pre>`:E`<h4>Outputs</h4><pre class="run-outputs">${this.runResult.content[0].text}</pre>`:C}</section>`}renderViewToggle(){if(this.showViewToggle==="false")return C;let e=this.view==="compact"?"compact":"expanded",t=(r,s)=>E`<button type="button" aria-pressed="${e===r?"true":"false"}" @click="${()=>this.setView(r)}">${s}</button>`;return E`<div class="view-toggle" part="view-toggle" role="group" aria-label="Diagram view">${t("compact","Compact")}${t("expanded","Expanded")}</div>`}renderLegend(e){if(!e.length)return C;let t=(s,n,i=!1)=>E`<svg width="28" height="10" aria-hidden="true"><path class="${s}" d="M1 5H23" stroke-dasharray="${i?"5 4":"none"}/"><path class="rf-head-${n}" d="M22 1L28 5L22 9z"/></path></svg>`,r={seq:E`${t("rf-seq","seq")}next step`,data:E`${t("rf-data","data",!0)}value passed to a later step`,output:E`${t("rf-data rf-to-output","output",!0)}value passed to the outputs`,success:E`${t("rf-goto rf-success","success")}goto on success`,failure:E`${t("rf-goto rf-failure","failure")}goto on failure`};return E`<ul class="flow-legend" part="legend" aria-label="Legend">${e.map(s=>E`<li>${r[s]}</li>`)}</ul>`}render(){if(this.loadError)return E`<p class="flow-message" part="message">Could not load the workflows: ${this.loadError}</p>`;if(!this.doc)return this.loading?E`<p class="flow-message" part="message">Loading workflows…</p>`:C;let e=this.graph,t=this.workflowIds,r=aa(e,{view:this.view==="compact"?"compact":"expanded",idPrefix:this.idPrefix,interactive:!0}),s=r.svg,n=new Map;this.selectedStepId&&n.set(this.selectedStepId,["rf-selected"]),this.runningStepId&&n.set(this.runningStepId,[...n.get(this.runningStepId)||[],"rf-running"]);for(let[o,a]of n){let l=Q(o).replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s=s.replace(RegExp(`class="rf-node rf-step( rf-clickable)?" data-step-id="${l}"`),(c,f)=>`class="rf-node rf-step${f||""} ${a.join(" ")}" data-step-id="${Q(o)}"`)}let i=this.problems.filter(o=>o.level==="error"||o.path.startsWith("sourceDescriptions"));return E`${e?E`<div class="flow-header" part="header"><h2 class="flow-title" part="title">${e.summary||e.workflowId}</h2>${e.summary?E`<span class="flow-id">${e.workflowId}</span>`:C}<div class="flow-controls">${t.length>1?E`<select part="select" aria-label="Workflow" .value="${e.workflowId}" @change="${o=>{this.workflowId=o.target.value,this.selectedStepId="",this.resetRun()}}">${t.map(o=>E`<option value="${o}" ?selected="${o===e.workflowId}">${o}</option>`)}</select>`:C} ${this.renderViewToggle()}</div></div>${e.description?E`<p class="flow-description" part="description">${e.description}</p>`:C}<div class="flow-diagram" part="diagram" @click="${this.onDiagramEvent}" @keydown="${this.onDiagramEvent}" @mouseover="${this.onDiagramHover}" @mouseleave="${this.onDiagramHover}">${ci(s)}</div>${this.renderLegend(r.legend)} ${this.renderRun(e)}`:E`<p class="flow-message" part="message">No workflow to show.</p>`} ${i.length?E`<ul class="flow-problems" part="problems">${i.map(o=>E`<li class="${o.level}">${o.path?E`<code>${o.path}</code>`:C}${o.message}</li>`)}</ul>`:C}`}};U([ee({type:String,attribute:"arazzo-url"})],R.prototype,"arazzoUrl",void 0),U([ee({type:String,attribute:"spec-url"})],R.prototype,"specUrl",void 0),U([ee({type:String,attribute:"workflow-id"})],R.prototype,"workflowId",void 0),U([ee({type:String,attribute:"for"})],R.prototype,"for",void 0),U([ee({type:String,reflect:!0})],R.prototype,"theme",void 0),U([ee({type:String,attribute:"color-scheme",reflect:!0})],R.prototype,"colorScheme",void 0),U([ee({type:String,reflect:!0})],R.prototype,"view",void 0),U([ee({type:String,attribute:"show-view-toggle"})],R.prototype,"showViewToggle",void 0),U([ee({type:String,attribute:"allow-run"})],R.prototype,"allowRun",void 0),U([ee({type:String,attribute:"server-url"})],R.prototype,"serverUrl",void 0),U([X()],R.prototype,"doc",void 0),U([X()],R.prototype,"sources",void 0),U([X()],R.prototype,"problems",void 0),U([X()],R.prototype,"loading",void 0),U([X()],R.prototype,"loadError",void 0),U([X()],R.prototype,"selectedStepId",void 0),U([X()],R.prototype,"runState",void 0),U([X()],R.prototype,"runInputs",void 0),U([ee({type:Object,attribute:!1})],R.prototype,"statusCodes",void 0),U([X()],R.prototype,"mockStrategy",void 0),U([X()],R.prototype,"manualCredentials",void 0),U([X()],R.prototype,"runningStepId",void 0),U([X()],R.prototype,"trace",void 0),U([X()],R.prototype,"runResult",void 0),U([X()],R.prototype,"runProblem",void 0),R=U([si("rapi-flow")],R);var qa=R;export{qa as default};
|