@blue-labs/language 1.29.0 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Xt=Object.defineProperty;var Qt=(s,e,t)=>e in s?Xt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var h=(s,e,t)=>Qt(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("big.js"),c=require("@blue-labs/shared-utils"),u=require("zod"),er=require("bs58"),A=require("radash"),tr=require("js-sha256"),rr=require("crypto"),sr=require("base32.js"),Z=require("js-yaml"),ot=s=>s&&s.__esModule?s:{default:s},le=ot(er),we=ot(rr);class w extends j{constructor(e){super(e)}}class T extends j{constructor(e){super(e)}}class nr{static get(e,t,r,n=!0){if(c.isNullable(t)||!t.startsWith("/"))throw new Error(`Invalid path: ${t}`);if(t==="/"){const o=e.getValue();return n&&o!==void 0?o:e}const i=t.substring(1).split("/");return this.getRecursive(e,i,0,r,n)}static getRecursive(e,t,r,n,i){if(r===t.length-1&&!i)return this.getNodeForSegment(e,t[r],n,!1);if(r===t.length){const a=e.getValue();return i&&a!==void 0?a:e}const o=t[r],l=this.getNodeForSegment(e,o,n,!0);if(l)return this.getRecursive(l,t,r+1,n,i)}static getNodeForSegment(e,t,r,n){let i;const o=e.getProperties();if(o&&t in o)i=o[t];else switch(t){case"name":{const l=e.getName();i=new d().setValue(l??null);break}case"description":{const l=e.getDescription();i=new d().setValue(l??null);break}case"type":i=e.getType();break;case"itemType":i=e.getItemType();break;case"keyType":i=e.getKeyType();break;case"valueType":i=e.getValueType();break;case"value":{const l=e.getValue();i=new d().setValue(l??null);break}case"blueId":{const l=e.getBlueId();i=new d().setValue(l??null);break}case"blue":i=e.getBlue();break;case"items":{const l=e.getItems();i=new d().setItems(l);break}case"properties":{const l=e.getProperties();i=new d().setProperties(l);break}case"contracts":{const l=e.getContracts();i=new d().setContracts(l);break}default:{if(/^\d+$/.test(t)){const l=parseInt(t,10),a=e.getItems();a&&l>=0&&l<a.length?i=a[l]:i=void 0}else i=void 0;break}}if(i)return n&&r?this.link(i,r):i}static link(e,t){const r=t(e);return c.isNonNullable(r)?r:e}}const q="name",X="description",pe="type",ze="itemType",Ue="keyType",_e="valueType",be="value",Ze="items",_="blueId",ke="blue",ir=[q,X,pe,ze,Ue,_e,be,Ze,_,ke],or="Text",lr="Double",ar="Integer",cr="Boolean",ur="List",dr="Dictionary",Ye=[or,lr,ar,cr],lt=[...Ye,ur,dr],k="F92yo19rCcbBoBSpUA5LRxpfDejJDAaP1PRxxbWAraVP",Y="68ryJtnmui4j5rCZWUnkZ3DChtmEb7Z9F8atn1mBSM3L",J="DHmxTkFbXePZHCHCYmQr2dSzcNLcryFVjXVHkdQrrZr8",K="EL6AjrbJsxTWRTPzY8WR8Y2zAMXRbydQj83PcZwuAHbo",at="G8wmfjEqugPEEXByMYWJXiEdbLToPRWNQEekNxrxfQWB",ct="294NBTj2mFRL3RB4kDRUSckwGg7Kzj6T8CTAFeR1kcSA",ut=[k,Y,J,K],ue=[...ut,at,ct];Object.fromEntries(lt.map((s,e)=>[s,ue[e]]));const hr=Object.fromEntries(ue.map((s,e)=>[s,lt[e]])),P=class P{constructor(e){h(this,"name");h(this,"description");h(this,"type");h(this,"itemType");h(this,"keyType");h(this,"valueType");h(this,"value");h(this,"items");h(this,"properties");h(this,"blueId");h(this,"blue");h(this,"inlineValue",!1);this.name=e}getName(){return this.name}setName(e){return this.name=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getType(){return this.type}setType(e){return typeof e=="string"?this.type=new P().setValue(e).setInlineValue(!0):this.type=e,this}getItemType(){return this.itemType}setItemType(e){return typeof e=="string"?this.itemType=new P().setValue(e).setInlineValue(!0):this.itemType=e,this}getKeyType(){return this.keyType}setKeyType(e){return typeof e=="string"?this.keyType=new P().setValue(e).setInlineValue(!0):this.keyType=e,this}getValueType(){return this.valueType}setValueType(e){return typeof e=="string"?this.valueType=new P().setValue(e).setInlineValue(!0):this.valueType=e,this}getValue(){var t;const e=(t=this.type)==null?void 0:t.getBlueId();if(c.isNonNullable(e)&&c.isNonNullable(this.value)){if(e===J&&typeof this.value=="string")return new T(this.value);if(e===Y&&typeof this.value=="string"){const r=new w(this.value),n=parseFloat(r.toString());return new w(n.toString())}else if(e===K&&typeof this.value=="string")return this.value.toLowerCase()==="true"}return this.value}setValue(e){return typeof e=="number"?e%1===0?this.value=new T(e.toString()):this.value=new w(e.toString()):this.value=e,this}getItems(){return this.items}setItems(e){return this.items=e,this}addItems(...e){return this.items||(this.items=[]),this.items.push(...e),this}getProperties(){return this.properties}setProperties(e){return this.properties=e,this}addProperty(e,t){return this.properties||(this.properties={}),this.properties[e]=t,this}removeProperty(e){return this.properties&&delete this.properties[e],this}getContractsProperty(){var e;return(e=this.properties)==null?void 0:e.contracts}getContracts(){var e;return(e=this.getContractsProperty())==null?void 0:e.getProperties()}setContracts(e){return c.isNullable(e)?this.removeProperty("contracts"):this.addProperty("contracts",new P().setProperties(e)),this}addContract(e,t){const r=this.getContractsProperty();return c.isNullable(r)?this.addProperty("contracts",new P().addProperty(e,t)):r.addProperty(e,t),this}removeContract(e){const t=this.getContractsProperty();if(t){t.removeProperty(e);const r=t.getProperties();r&&Object.keys(r).length===0&&this.removeProperty("contracts")}return this}getBlueId(){return this.blueId}setBlueId(e){return this.blueId=e,this}getBlue(){return this.blue}setBlue(e){return this.blue=e,this}isInlineValue(){return this.inlineValue}setInlineValue(e){return this.inlineValue=e,this}isResolved(){return!1}get(e,t){return nr.get(this,e,t)}getAsNode(e){const t=this.get(e);if(t instanceof P)return t;throw new Error(`Value at path ${e} is not a BlueNode: ${t}`)}getAsInteger(e){const t=this.get(e);if(t instanceof T||t instanceof w)return t.toNumber();throw new Error(`Value at path ${e} is not a BigInteger or BigDecimal: ${t}`)}clone(){var t,r,n,i,o,l;const e=new P(this.name);return e.description=this.description,e.type=(t=this.type)==null?void 0:t.clone(),e.itemType=(r=this.itemType)==null?void 0:r.clone(),e.keyType=(n=this.keyType)==null?void 0:n.clone(),e.valueType=(i=this.valueType)==null?void 0:i.clone(),e.value=this.value,e.items=(o=this.items)==null?void 0:o.map(a=>a.clone()),this.properties&&(e.properties=Object.fromEntries(Object.entries(this.properties).map(([a,p])=>[a,p.clone()]))),e.blueId=this.blueId,e.blue=(l=this.blue)==null?void 0:l.clone(),e.inlineValue=this.inlineValue,e}toString(){return`BlueNode{name='${this.name}', description='${this.description}', type=${this.type}, itemType=${this.itemType}, keyType=${this.keyType}, valueType=${this.valueType}, value=${this.value}, items=${this.items}, properties=${this.properties}, blueId='${this.blueId}', blue=${this.blue}, inlineValue=${this.inlineValue}}`}};h(P,"INTEGER",new P("Integer"));let d=P;class U{static isPotentialBlueId(e){if(!e||e.length===0||!this.BLUE_ID_PATTERN.test(e))return!1;const t=e.split("#"),r=t[0],n=r.length;if(n<this.MIN_BLUE_ID_LENGTH||n>this.MAX_BLUE_ID_LENGTH)return!1;try{if(le.default.decode(r).length!==32)return!1}catch{return!1}if(t.length>1)try{if(Number(t[1])<0)return!1}catch{return!1}return!0}}h(U,"MIN_BLUE_ID_LENGTH",41),h(U,"MAX_BLUE_ID_LENGTH",45),h(U,"BLUE_ID_PATTERN",/^[1-9A-HJ-NP-Za-km-z]{41,45}(?:#\d+)?$/);const pr=u.z.string().max(U.MAX_BLUE_ID_LENGTH,{message:"Blue Id has a maximum length of 45 characters"}).min(U.MIN_BLUE_ID_LENGTH,{message:"Blue Id has a minimum length of 41 characters"}).refine(s=>{try{return le.default.decode(s),!0}catch{return!1}},{message:"Blue Id must be a valid Base58 string"}),Q=u.z.lazy(()=>u.z.record(u.z.unknown()).and(u.z.object({blueId:u.z.string().optional(),name:u.z.string().optional(),description:u.z.string().optional(),type:Q.optional(),value:u.z.union([u.z.string(),u.z.number(),u.z.boolean()]).optional().nullable(),items:u.z.array(Q).optional()}))),de=u.z.object({blueId:u.z.string().optional(),name:u.z.string().optional(),description:u.z.string().optional(),type:Q.optional()}),fr=de.extend({value:u.z.string().optional()}),gr=de.extend({value:u.z.number().optional()}),yr=de.extend({value:u.z.boolean().optional()}),mr=de.extend({items:u.z.array(u.z.string()).optional()}),Ir=s=>Q.safeParse(s).success,dt=s=>c.isNonNullable(s)&&"blueId"in s&&c.isNonNullable(s.blueId),br=s=>c.isNonNullable(s)&&"name"in s&&c.isNonNullable(s.name),ht=s=>c.isNonNullable(s)&&"items"in s&&c.isNonNullable(s.items),pt=s=>c.isNonNullable(s)&&"type"in s&&c.isNonNullable(s.type),ft=s=>c.isNonNullable(s)&&"value"in s&&c.isNonNullable(s.value),Nr=(s,e)=>s.required({type:!0}).safeParse(e).success,D=s=>s instanceof j,x=s=>D(s)&&s instanceof T,fe=s=>D(s)&&s instanceof w,Tr=u.z.lazy(()=>u.z.record(ae)),Br=u.z.lazy(()=>u.z.union([u.z.array(ae),u.z.array(ae).readonly()])),ae=u.z.lazy(()=>u.z.union([c.jsonPrimitiveSchema,Tr,Br,u.z.instanceof(j)])),Je=s=>A.isObject(s)&&!A.isArray(s)&&!c.isReadonlyArray(s)&&!D(s),Ke=s=>A.isArray(s)||c.isReadonlyArray(s),vr=s=>Ke(s)||Je(s)||D(s)||c.isJsonPrimitive(s);class f{static deserialize(e){return f.handleNode(e)}static handleNode(e){if(e===void 0)throw new Error("This is not a valid JSON-like value. Found 'undefined' as a value.");if(Je(e)){const t=new d,r={};return Object.entries(e).forEach(([n,i])=>{switch(n){case q:if(i==null)t.setName(void 0);else{if(typeof i!="string")throw new Error(`The ${q} field must be a string.`);t.setName(i)}break;case X:if(i==null)t.setDescription(void 0);else{if(typeof i!="string")throw new Error(`The ${X} field must be a string.`);t.setDescription(i)}break;case pe:t.setType(f.handleNode(i));break;case ze:t.setItemType(f.handleNode(i));break;case Ue:t.setKeyType(f.handleNode(i));break;case _e:t.setValueType(f.handleNode(i));break;case be:t.setValue(f.handleValue(i));break;case _:if(typeof i!="string")throw new Error(`The ${_} field must be a string.`);t.setBlueId(i);break;case Ze:t.setItems(f.handleArray(i));break;case ke:t.setBlue(f.handleNode(i));break;default:r[n]=f.handleNode(i);break}}),Object.keys(r).length>0&&t.setProperties(r),t}else{if(Ke(e))return new d().setItems(f.handleArray(e));{const t=e;return new d().setValue(f.handleValue(t)).setInlineValue(!0)}}}static handleValue(e){if(e==null)return null;if(typeof e=="string")return e;if(typeof e=="number"||D(e))if(x(e)||Number.isSafeInteger(e)){const t=new T(e.toString()),r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER;return t.lt(r)?new T(r.toString()):t.gt(n)?new T(n.toString()):t}else{const t=parseFloat(e.toString());return new w(t.toString())}else if(typeof e=="boolean")return e;throw new Error(`Can't handle node: ${JSON.stringify(e)}`)}static handleArray(e){if(e!=null){if(A.isObject(e)&&!Array.isArray(e))return[f.handleNode(e)];if(Array.isArray(e))return e.map(f.handleNode);throw new Error("Expected an array node")}}}function wr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ee,rt;function Er(){return rt||(rt=1,Ee=function s(e){if(typeof e=="number"&&isNaN(e))throw new Error("NaN is not allowed");if(typeof e=="number"&&!isFinite(e))throw new Error("Infinity is not allowed");return e===null||typeof e!="object"?JSON.stringify(e):e.toJSON instanceof Function?s(e.toJSON()):Array.isArray(e)?`[${e.reduce((n,i,o)=>`${n}${o===0?"":","}${s(i===void 0||typeof i=="symbol"?null:i)}`,"")}]`:`{${Object.keys(e).sort().reduce((r,n)=>{if(e[n]===void 0||typeof e[n]=="symbol")return r;const i=r.length===0?"":",";return`${r}${i}${s(n)}:${s(e[n])}`},"")}}`}),Ee}var Pr=Er();const Sr=wr(Pr);class gt{static canonicalize(e){return Sr(e)}}const Pe=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,ye=class ye{constructor(){h(this,"browserCrypto");this.browserCrypto=this.initBrowserCrypto()}static getInstance(){return this.instance||(this.instance=new ye),this.instance}initBrowserCrypto(){return Pe?null:"crypto"in globalThis?globalThis.crypto:null}hasNodeCrypto(){return Pe&&!!we.default&&typeof we.default.createHash=="function"}getBrowserCrypto(){return this.browserCrypto}getNodeCrypto(){return Pe?we.default:null}};h(ye,"instance");let Oe=ye;class yt{constructor(){h(this,"cryptoEnv",Oe.getInstance())}applySync(e){const t=this.canonicalizeInput(e),r=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):this.sha256SyncBrowser(t);return le.default.encode(new Uint8Array(r))}async apply(e){const t=this.canonicalizeInput(e),r=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):await this.sha256Async(t);return le.default.encode(new Uint8Array(r))}canonicalizeInput(e){const t=gt.canonicalize(e);if(typeof t!="string")throw new Error("Canonized value must be a string");return t}sha256Sync(e){const t=this.cryptoEnv.getNodeCrypto();if(!t)throw new Error("Synchronous SHA-256 is not available in this environment");return t.createHash("sha256").update(e).digest()}sha256SyncBrowser(e){return tr.sha256.arrayBuffer(e)}async sha256Async(e){if(this.cryptoEnv.hasNodeCrypto())return this.sha256Sync(e);const t=this.cryptoEnv.getBrowserCrypto();if(!t)throw new Error("crypto is not available in this environment");const n=new TextEncoder().encode(e);return t.subtle.digest("SHA-256",n)}}class g{static get(e,t="official"){var tt;const r=e.getValue(),n=this.handleValue(r);if(n!==void 0&&t==="simple")return n;const i=(tt=e.getItems())==null?void 0:tt.map(W=>g.get(W,t));if(i!==void 0&&t==="simple")return i;const o=e.getName(),l=e.getDescription();if(t==="original"&&o===void 0&&l===void 0){if(n!==void 0)return n;if(i!==void 0)return i}const a={};o!==void 0&&(a[q]=o),l!==void 0&&(a[X]=l);const p=e.getType();if(t==="official"&&r!==void 0&&p===void 0){const W=this.inferTypeBlueId(r);W!==null&&(a[pe]={[_]:W})}else p!==void 0&&(a[pe]=g.get(p,t));const I=e.getItemType();I!==void 0&&(a[ze]=g.get(I,t));const y=e.getKeyType();y!==void 0&&(a[Ue]=g.get(y,t));const m=e.getValueType();m!==void 0&&(a[_e]=g.get(m,t)),n!==void 0&&(a[be]=n),i!==void 0&&(a[Ze]=i);const b=e.getBlueId();b!==void 0&&(a[_]=b);const L=e.getBlue();L!==void 0&&(a[ke]=L);const G=e.getProperties();return G!==void 0&&Object.entries(G).forEach(([W,qt])=>{a[W]=g.get(qt,t)}),a}static handleValue(e){if(D(e)){if(x(e)){const t=new j(Number.MIN_SAFE_INTEGER.toString()),r=new j(Number.MAX_SAFE_INTEGER.toString());if(e.lt(t)||e.gt(r))return e.toString()}return e.toNumber()}return e}static inferTypeBlueId(e){return typeof e=="string"?k:D(e)?x(e)?J:Y:typeof e=="boolean"?K:null}}const Ar=s=>c.isJsonPrimitive(s)&&c.isNonNullable(s),M=class M{constructor(e){h(this,"hashProvider");this.hashProvider=e}static calculateBlueId(e){if(Array.isArray(e)){const r=e.map(n=>g.get(n));return M.INSTANCE.calculate(r)}const t=g.get(e);return M.INSTANCE.calculate(t)}static calculateBlueIdSync(e){if(Array.isArray(e)){const r=e.map(n=>g.get(n));return M.INSTANCE.calculateSync(r)}const t=g.get(e);return M.INSTANCE.calculateSync(t)}calculate(e){const t=this.cleanStructure(e);if(t===void 0)throw new Error("Object after cleaning cannot be null or undefined.");return this.internalCalculate(t,!1)}calculateSync(e){const t=this.cleanStructure(e);if(t===void 0)throw new Error("Object after cleaning cannot be null or undefined.");return this.internalCalculate(t,!0)}internalCalculate(e,t){return Ar(e)||D(e)?this.applyHash(e.toString(),t):Array.isArray(e)||c.isReadonlyArray(e)?this.calculateList(e,t):this.calculateMap(e,t)}calculateMap(e,t){if(e[_]!==void 0)return e[_];const n=Object.keys(e).map(o=>{const l=e[o];if([q,be,X].includes(o))return t?[o,l]:Promise.resolve([o,l]);{const a=this.internalCalculate(l,t);return t?[o,{blueId:a}]:Promise.resolve(a).then(p=>[o,{blueId:p}])}}),i=o=>{const l={};for(const[a,p]of o)l[a]=p;return this.applyHash(l,t)};return t?i(n):Promise.all(n).then(i)}calculateList(e,t){if(e.length===0)throw new Error("Cannot calculate BlueId for an empty list.");let r=this.internalCalculate(e[0],t);const n=(i,o)=>t?this.applyHash([{blueId:i},{blueId:o}],!0):Promise.all([i,o]).then(([l,a])=>this.applyHash([{blueId:l},{blueId:a}],!1));for(let i=1;i<e.length;i++){const o=this.internalCalculate(e[i],t);r=n(r,o)}return r}applyHash(e,t){return t?this.hashProvider.applySync(e):this.hashProvider.apply(e)}cleanStructure(e){if(e!=null){if(c.isJsonPrimitive(e)||D(e))return e;if(Array.isArray(e)||c.isReadonlyArray(e)){const t=e.map(r=>this.cleanStructure(r)).filter(c.isNonNullable);return t.length>0?t:void 0}else if(typeof e=="object"){const t={};for(const r in e){const n=this.cleanStructure(e[r]);n!=null&&(t[r]=n)}return Object.keys(t).length>0?t:void 0}else return e}}};h(M,"INSTANCE",new M(new yt));let N=M;class Cr{static convert(e){const t=le.default.decode(e),r=new Uint8Array(2+t.length);r[0]=18,r[1]=32,r.set(t,2);const n=new Uint8Array(2+r.length);return n[0]=1,n[1]=85,n.set(r,2),"b"+new sr.Encoder({type:"rfc4648",lc:!0}).write(n).finalize().replace(/=/g,"")}}class V{static transform(e,t){const r=t(e.clone()),n=r.getType();n!==void 0&&r.setType(V.transform(n,t));const i=r.getItemType();i!==void 0&&r.setItemType(V.transform(i,t));const o=r.getKeyType();o!==void 0&&r.setKeyType(V.transform(o,t));const l=r.getValueType();l!==void 0&&r.setValueType(V.transform(l,t));const a=r.getItems();if(a!==void 0){const I=a.map(y=>V.transform(y,t));r.setItems(I)}const p=r.getProperties();if(p!==void 0){const I=Object.keys(p).reduce((y,m)=>(y[m]=V.transform(p[m],t),y),{});r.setProperties(I)}return r}}const $=s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof d),O=s=>s instanceof T||s instanceof w,Vr=s=>s.replace(/~1/g,"/").replace(/~0/g,"~");function re(s){if(s==="/")return[];if(!s.startsWith("/"))throw new Error(`Path must start with '/': ${s}`);return s.split("/").slice(1).map(Vr)}function ee(s){if(s==="-")return-1;const e=typeof s=="number"?s:parseInt(s,10);if(isNaN(e))throw new Error(`Invalid array index (NaN) from '${s}'`);if(!Number.isFinite(e))throw new Error(`Invalid array index '${s}' results in non-finite number ${e}`);return e}function mt(s,e,t,r=!0){switch(e){case"name":return t?r?s.getName()??null:s:s.getName();case"description":return t?r?s.getDescription():s:s.getDescription();case"type":return s.getType();case"itemType":return s.getItemType();case"keyType":return s.getKeyType();case"valueType":return s.getValueType();case"value":return t?r?s.getValue()??null:s:s.getValue();case"blueId":return t?r?s.getBlueId()??null:s:s.getBlueId();case"blue":return s.getBlue();case"items":return s.getItems();case"properties":return s.getProperties();case"contracts":return s.getContracts();default:return}}function st(s,e,t=!0){if(s instanceof d){const r=mt(s,e,!0,t);if(r!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties","contracts"].includes(e))return r;if(/^-?\d+$/.test(e)&&e!=="-"){const i=s.getItems(),o=parseInt(e,10);return i&&o>=0&&o<i.length?i[o]:void 0}const n=s.getProperties();return n&&e in n?n[e]:void 0}if(Array.isArray(s)){if(e==="-")return;const r=ee(e);return r>=0&&r<s.length?s[r]:void 0}if($(s))return s[e]}function se(s,e){if(e.length===0)return{parent:s,key:"value",actualTarget:s.getValue()??s};let t=s;for(let n=0;n<e.length-1;++n){const i=e[n],o=st(t,i);if(o===void 0)throw new Error(`Cannot resolve '/${e.slice(0,n+1).join("/")}'`);t=o}const r=e[e.length-1];if(t instanceof d){const n=st(t,r,!1);if((typeof n!="object"||n===null||O(n))&&!(n instanceof d)&&!Array.isArray(n)&&["name","description","value","blueId"].includes(r))return{parent:t,key:r,actualTarget:n}}return Array.isArray(t)&&r==="-"?{parent:t,key:"-"}:t instanceof d&&t.getItems()&&r==="-"?{parent:t,key:"-"}:{parent:t,key:Array.isArray(t)?ee(r):r}}function Ge(s,e){var t;if(s instanceof d){const r=e,n=mt(s,r,!1);if(n!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties","contracts"].includes(r))return n;if(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e)){const i=s.getItems(),o=typeof e=="number"?e:parseInt(e,10);if(i&&o>=0&&o<i.length)return i[o]}return(t=s.getProperties())==null?void 0:t[r]}return Array.isArray(s)||$(s)?s[e]:s}function v(s){if(s instanceof d)return s;if(s===null||typeof s=="string"||typeof s=="number"||typeof s=="boolean"||O(s))return f.deserialize(s);const e=Fe(s);return f.deserialize(e)}function Fe(s){if(s===void 0)return null;if(s===null||typeof s!="object")return s;if(Array.isArray(s))return s.map(Fe);const e={};for(const[t,r]of Object.entries(s))e[t]=Fe(r);return e}function We(s,e,t){if(s instanceof d){const r=e;switch(r){case"name":s.setName(t);return;case"description":s.setDescription(t);return;case"type":s.setType(t instanceof d||typeof t=="string"||t===void 0?t:v(t));return;case"itemType":s.setItemType(t instanceof d||typeof t=="string"||t===void 0?t:v(t));return;case"keyType":s.setKeyType(t instanceof d||typeof t=="string"||t===void 0?t:v(t));return;case"valueType":s.setValueType(t instanceof d||typeof t=="string"||t===void 0?t:v(t));return;case"value":{const n=t;s.setValue(n===void 0?null:n);return}case"blueId":s.setBlueId(t);return;case"blue":s.setBlue(t instanceof d||t===void 0?t:v(t));return;case"items":s.setItems(t);return;case"properties":s.setProperties(t);return;case"contracts":s.setContracts(t);return;default:{if(t===void 0){const n=s.getProperties();n&&r in n&&delete n[r]}else s.getProperties()||s.setProperties({}),s.addProperty(r,t instanceof d?t:v(t));return}}}Array.isArray(s)?s.splice(ee(e),1):$(s)&&(t===void 0?delete s[e]:s[e]=t)}function Dr(s,e,t,r){let n=-1;if(e!=="-"&&(n=typeof e=="number"?e:parseInt(e,10),isNaN(n)))throw new Error(`Invalid numeric key for BlueNode item operation: ${e}`);if(n<-1)throw new Error(`Invalid array index for BlueNode items: ${n}`);let i=s.getItems();if(i||(i=[],s.setItems(i)),!r&&n!==-1&&n>i.length)throw new Error(`ADD operation failed: Target array index '${n}' is greater than array length ${i.length}.`);if(e==="-")i.push(t);else if(r){if(n>=0)if(n<i.length)i[n]=t;else{for(let o=i.length;o<n;o++)i.push(f.deserialize(null));i.push(t)}}else i.splice(n,0,t)}function ge(s,e,t,r){if(Array.isArray(s)){const n=e==="-"?s.length:ee(e);if(!r&&n>s.length)throw new Error(`ADD operation failed: Target array index '${n}' is greater than array length ${s.length}. Path involving key '${e}'.`);if(n<0&&e!=="-")throw new Error(`Invalid negative array index: ${e}`);const i=v(t);if(r){if(n>=0&&n<s.length)s[n]=i;else if(n>=s.length){for(let o=s.length;o<n;o++)s.push(f.deserialize(null));s.push(i)}}else s.splice(n,0,i);return}if(s instanceof d){e==="-"||typeof e=="number"&&!isNaN(e)||typeof e=="string"&&/^\d+$/.test(e)?Dr(s,e,v(t),r):We(s,e,t);return}if($(s)){s[e]=v(t);return}throw new Error(`Cannot insert into parent of type ${typeof s}`)}function Or(s,e){if(Array.isArray(s)){const t=ee(e);t===-1&&e==="-"?s.length>0&&s.pop():t>=0&&t<s.length&&s.splice(t,1);return}if(s instanceof d){if(typeof e=="number"||typeof e=="string"&&/^-?\d+$/.test(e)){const t=s.getItems();if(t){const r=ee(e);r===-1&&e==="-"?t.length>0&&t.pop():r>=0&&r<t.length&&t.splice(r,1),t.length===0&&s.setItems(void 0);return}}We(s,e,void 0)}else $(s)&&delete s[e]}function Me(s){if(s instanceof d)return s.clone();if(Array.isArray(s))return s.map(t=>Me(t));if($(s)){const e={};return Object.keys(s).forEach(t=>{e[t]=Me(s[t])}),e}return s}function z(s,e){if(s===e||s instanceof d&&(s.isInlineValue()||s.getValue()!==void 0)&&z(s.getValue()??null,e)||e instanceof d&&(e.isInlineValue()||e.getValue()!==void 0)&&z(s,e.getValue()??null))return!0;if(s instanceof d&&e instanceof d||O(s)&&O(e)||O(s)&&typeof e=="number"||typeof s=="number"&&O(e))return s.toString()===e.toString();if(Array.isArray(s)&&Array.isArray(e))return s.length===e.length&&s.every((t,r)=>z(t,e[r]));if($(s)&&$(e)){const t=Object.keys(s),r=Object.keys(e);return t.length===r.length&&t.every(n=>z(s[n],e[n]))}return!1}function It(s,e){const{parent:t,key:r}=se(s,re(e));return Ge(t,r)}function bt(s,e,t){const r=re(e);if(r.length===0&&e==="/"){const o=v(t);s.setValue(o.getValue()??null),o.getItems()?s.setItems(o.getItems()):s.setItems(void 0);return}const{parent:n,key:i}=se(s,r);ge(n,i,t,!0)}function Fr(s,e,t){const r=re(e);if(r.length===0&&e==="/"){if(s.getItems()&&Array.isArray(t)){const o=v(t);o.getItems()?(s.setItems(o.getItems()),s.setValue(null)):(s.setValue(o.getValue()??null),s.setItems(void 0))}else{const o=v(t);s.setValue(o.getValue()??null),o.getItems()&&s.setItems(o.getItems())}return!0}const{parent:n,key:i}=se(s,r);return ge(n,i,t,!1),!0}function Mr(s,e,t){const r=re(e);if(r.length===0&&e==="/"){const l=v(t);return s.setValue(l.getValue()??null),l.getItems()?s.setItems(l.getItems()):s.setItems(void 0),!0}const{parent:n,key:i,actualTarget:o}=se(s,r);if(o!==void 0&&n instanceof d)We(n,i,t);else{const l=Ge(n,i),a=Array.isArray(n)||n instanceof d&&n.getItems()&&(typeof i=="number"||typeof i=="string"&&/^\d+$/.test(i));if(l===void 0){if(a)throw new Error(`REPLACE failed: Target array index '${i.toString()}' is out of bounds or does not exist at path '${e}'.`);ge(n,i,t,!0)}else ge(n,i,t,!0)}return!0}function Nt(s,e){const t=re(e);if(t.length===0&&e==="/")return s.setValue(null),s.setItems(void 0),s.setProperties(void 0),!0;const{parent:r,key:n}=se(s,t);return Or(r,n),!0}function Rr(s,e,t){const r=Me(It(s,e));return bt(s,t,r),!0}function jr(s,e,t){const r=re(e),{parent:n,key:i}=se(s,r),o=Ge(n,i);if(o===void 0)throw new Error(`MOVE failed: 'from' location '${e}' does not exist.`);return Nt(s,e)?(bt(s,t,o),!0):!1}function xr(s,e,t){const r=It(s,e);let n=t;if(r instanceof d)if((t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||O(t))&&(r.isInlineValue()||r.getValue()!==void 0)){if(!z(r.getValue()??null,t))throw new Error(`TEST failed at '${e}': Expected ${JSON.stringify(t)}, got ${JSON.stringify(r.getValue()??null)}`);return!0}else typeof t=="object"&&!(t instanceof d)&&(n=v(t));else if(O(r)&&typeof t=="number")r instanceof T?n=new T(t.toString()):r instanceof w&&(n=new w(t.toString()));else if((r===null||typeof r=="string"||typeof r=="number"||typeof r=="boolean")&&O(t)){const i=t;!z(r,i.toString())&&(typeof r=="number"&&parseFloat(i.toString()))}if(!z(r,n)){const i=r instanceof d?r.toString():JSON.stringify(r),o=n instanceof d?n.toString():JSON.stringify(n);throw new Error(`TEST failed at '${e}': Expected ${o}, got ${i}`)}return!0}function $r(s,e){switch(e.op){case"add":return Fr(s,e.path,e.val);case"replace":return Mr(s,e.path,e.val);case"remove":return Nt(s,e.path);case"copy":return Rr(s,e.from,e.path);case"move":return jr(s,e.from,e.path);case"test":return xr(s,e.path,e.val)}}function Lr(s,e,t=!1){const r=t?s:s.clone();return $r(r,e),r}const Se=Symbol.for("zod-schema-annotations");function zr(){if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global;if(typeof window<"u")return window;if(typeof self<"u")return self;throw new Error("Unable to locate global object")}function Tt(){const s=zr();return Se in s||(s[Se]=new WeakMap),s[Se]}function ne(s,e){const t=Tt(),r=t.get(s)||{};return t.set(s,{...r,...e}),s}const C=s=>Tt().get(s),Bt=s=>e=>{const t=C(e);return ne(e,{...t,blueDescription:s})},vt=s=>{const e=C(s);return c.isNonNullable(e)&&A.isString(e.blueDescription)?e.blueDescription:null},Ur=s=>Bt(s)(u.z.string().optional()),_r=u.z.union([u.z.string(),u.z.boolean()]),wt=s=>e=>{const t=C(e);return ne(e,{...t,blueId:s})},Et=s=>{const e=C(s),t=_r.safeParse(e==null?void 0:e.blueId);return t.success?t.data:null},Zr=s=>wt(s??!0)(u.z.string()),Pt=s=>e=>{const t=C(e);return ne(e,{...t,blueName:s})},St=s=>{const e=C(s);return c.isNonNullable(e)&&A.isString(e.blueName)?e.blueName:null},kr=s=>{const e=u.z.string().optional();return Pt(s)(e)},At=()=>s=>{const e=C(s);return ne(s,{...e,blueNode:!0})},Ct=s=>{const e=C(s);return c.isNonNullable(e)&&c.isNonNullable(e.blueNode)&&e.blueNode===!0?e.blueNode:null},He=s=>!!Ct(s),Yr=()=>{const s=u.z.instanceof(d);return At()(s)},Re="extendedFrom",Vt=({schema:s,baseSchema:e})=>{const t=C(s)||{};return ne(s,{...t,[Re]:e})},Dt=s=>{const e=C(s);return c.isNonNullable(e)&&e[Re]?e[Re]:null},qe=(s,e)=>{const t=Dt(s);return c.isNullable(t)?!1:(t==null?void 0:t._def)===(e==null?void 0:e._def)?!0:qe(t,e)},Jr=s=>new Proxy(s,{get(e,t,r){return t==="extend"?function(...n){const i=e.extend(...n);return Vt({schema:i,baseSchema:e})}:Reflect.get(e,t,r)}}),Kr=u.z.object({value:u.z.array(u.z.string()).optional(),defaultValue:u.z.string().optional()}),Ot=s=>{const e=C(s),t=Kr.passthrough().safeParse(e==null?void 0:e.typeBlueId);return t.success?t.data:null},Gr=s=>e=>{const t=C(e),r=typeof s=="string"?{value:[s]}:s,n=Jr(e);return ne(n,{...t,typeBlueId:{...(t==null?void 0:t.typeBlueId)||{},...r}})};class Ne{static resolveBlueId(e){var i;const t=Ot(e);if(c.isNullable(t))return null;const r=t.defaultValue;if(c.isNonNullable(r))return r;const n=(i=t.value)==null?void 0:i[0];return c.isNonNullable(n)?n:Ne.getRepositoryBlueId(t,e)}static getRepositoryBlueId(e,t){throw new Error("Not implemented")}}class S{static isTypeOf(e,t,r){var o;const n=Ne.resolveBlueId(t),i=(o=e.getType())==null?void 0:o.getBlueId();if(c.isNullable(n)||c.isNullable(i))return!1;if(n===i)return!0;if(r!=null&&r.checkSchemaExtensions&&c.isNonNullable(r.typeSchemaResolver)){const l=r.typeSchemaResolver.resolveSchema(e);return S.checkSchemaExtension(l,t)}return!1}static checkSchemaExtension(e,t){if(!c.isNonNullable(e))return!1;const r=S.unwrapSchema(e),n=S.unwrapSchema(t);return qe(r,n)}static isWrapperType(e){return e instanceof u.ZodOptional||e instanceof u.ZodNullable||e instanceof u.ZodReadonly||e instanceof u.ZodBranded||e instanceof u.ZodEffects||e instanceof u.ZodLazy}static unwrapSchema(e){return He(e)?e:S.isWrapperType(e)?e instanceof u.ZodEffects?S.unwrapSchema(e.innerType()):e instanceof u.ZodLazy?S.unwrapSchema(e.schema):S.unwrapSchema(e.unwrap()):e}}class Ft{constructor(e){h(this,"blueIdMap",new Map);this.registerSchemas(e)}registerSchemas(e){for(const t of e)this.registerSchema(t)}registerSchema(e){const t=Ne.resolveBlueId(e);if(c.isNonNullable(t)){if(this.blueIdMap.has(t))throw new Error(`Duplicate BlueId value: ${t}`);this.blueIdMap.set(t,e)}}resolveSchema(e){const t=this.getEffectiveBlueId(e);return c.isNullable(t)?null:this.blueIdMap.get(t)}getEffectiveBlueId(e){const t=e.getType();return c.isNonNullable(t)&&c.isNonNullable(t.getBlueId())?t.getBlueId():c.isNonNullable(t)?N.calculateBlueIdSync(t):null}getBlueIdMap(){return new Map(this.blueIdMap)}}const B={NAME:"name",DESCRIPTION:"description",TYPE:"type",BLUE_ID:"blue_id",KEY_TYPE:"key_type",VALUE_TYPE:"value_type",ITEM_TYPE:"item_type",VALUE:"value",PROPERTIES:"properties",BLUE:"blue",ITEMS:"items"};class Te{static isEmptyNode(e){return this.hasFieldsAndMayHaveFields(e)}static hasBlueIdOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([B.BLUE_ID]))}static hasItemsOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([B.ITEMS]))}static isValidValueNode(e){const t=e.getValue(),r=e.getProperties(),n=e.getItems();return c.isNonNullable(t)&&c.isNullable(r)&&c.isNullable(n)}static textNode(e){return new d().setType(new d().setBlueId(k)).setValue(e)}static integerNode(e){const t=e instanceof T?e:new T(e.toString());return new d().setType(new d().setBlueId(J)).setValue(t)}static doubleNode(e){const t=e instanceof w?e:new w(e.toString());return new d().setType(new d().setBlueId(Y)).setValue(t)}static booleanNode(e){return new d().setType(new d().setBlueId(K)).setValue(e)}static hasFieldsAndMayHaveFields(e,t=new Set,r=new Set){for(const n of Object.values(B)){const i=c.isNonNullable(this.getFieldValue(e,n));if(t.has(n)){if(!i)return!1}else if(!r.has(n)){if(i)return!1}}return!0}static getFieldValue(e,t){switch(t){case B.NAME:return e.getName();case B.TYPE:return e.getType();case B.VALUE:return e.getValue();case B.DESCRIPTION:return e.getDescription();case B.PROPERTIES:return e.getProperties();case B.BLUE:return e.getBlue();case B.ITEMS:return e.getItems();case B.KEY_TYPE:return e.getKeyType();case B.VALUE_TYPE:return e.getValueType();case B.ITEM_TYPE:return e.getItemType();case B.BLUE_ID:return e.getBlueId();default:throw new Error(`Unknown field: ${t}`)}}}class Be{}function nt(s,e){const t=s.split(e),r=[...t].reverse().findIndex(i=>i!==""),n=r===-1?0:t.length-r;return t.slice(0,n)}class Xe extends Be{constructor(t,r){super();h(this,"allowedPaths");h(this,"maxDepth");h(this,"currentPath",[]);this.allowedPaths=t,this.maxDepth=r}shouldExtendPathSegment(t){if(this.currentPath.length>=this.maxDepth)return!1;const r=this.normalizePath(this.getCurrentFullPath()+"/"+t);return this.isAllowedPath(r)}shouldMergePathSegment(t){return this.shouldExtendPathSegment(t)}isAllowedPath(t){for(const r of this.allowedPaths)if(this.matchesAllowedPath(r,t))return!0;return!1}matchesAllowedPath(t,r){const n=nt(t,"/"),i=nt(r,"/");if(i.length>n.length)return!1;for(let o=1;o<i.length;o++)if(n[o]!=="*"&&n[o]!==i[o])return!1;return!0}enterPathSegment(t){this.currentPath.push(t)}exitPathSegment(){this.currentPath.length>0&&this.currentPath.pop()}getCurrentFullPath(){return"/"+this.currentPath.join("/")}normalizePath(t){return"/"+t.split("/").filter(r=>r!=="").join("/")}static withMaxDepth(t){const r=new it().setMaxDepth(t);for(let n=1;n<=t;n++){const i="/"+Array(n).fill("*").join("/");r.addPath(i)}return r.build()}static withSinglePath(t){return new it().addPath(t).build()}}class it{constructor(){h(this,"allowedPaths",new Set);h(this,"maxDepth",Number.MAX_SAFE_INTEGER)}addPath(e){return this.allowedPaths.add(e),this}setMaxDepth(e){return this.maxDepth=e,this}build(){return new Xe(this.allowedPaths,this.maxDepth)}}class Wr extends Be{shouldExtendPathSegment(){return!0}shouldMergePathSegment(){return!0}enterPathSegment(){}exitPathSegment(){}}class Qe extends Be{constructor(t){super();h(this,"limits");this.limits=t}shouldExtendPathSegment(t,r){return this.limits.every(n=>n.shouldExtendPathSegment(t,r))}shouldMergePathSegment(t,r){return this.limits.every(n=>n.shouldMergePathSegment(t,r))}enterPathSegment(t,r){this.limits.forEach(n=>{n.enterPathSegment(t,r)})}exitPathSegment(){this.limits.forEach(t=>{t.exitPathSegment()})}static of(...t){return new Qe(t)}}const H=new Wr;function Ae(s,e){const t=s.getType();if(t===void 0)return;const r=t.getBlueId();if(r!==void 0){if(ue.includes(r)){const i=hr[r];return new d().setBlueId(r).setName(i)}const n=e.fetchByBlueId(r);if(!n||n.length===0)return;if(n.length>1)throw new Error(`Expected a single node for type with blueId '${r}', but found multiple.`);return n[0]}return t}function E(s,e,t){const r=N.calculateBlueIdSync(s),n=N.calculateBlueIdSync(e);if(r===n)return!0;if(r&&ue.includes(r)){let o=e;for(;o!==void 0;){if(N.calculateBlueIdSync(o)===r)return!0;o=Ae(o,t)}return!1}let i=Ae(s,t);for(;i!==void 0;){if(N.calculateBlueIdSync(i)===n)return!0;i=Ae(i,t)}return!1}function Hr(s,e){return ut.some(t=>{const r=new d().setBlueId(t);return E(s,r,e)})}function qr(s,e){const t=new d().setBlueId(k);return E(s,t,e)}function Xr(s,e){const t=new d().setBlueId(J);return E(s,t,e)}function Qr(s,e){const t=new d().setBlueId(Y);return E(s,t,e)}function es(s,e){const t=new d().setBlueId(K);return E(s,t,e)}function ts(s){return(s==null?void 0:s.getBlueId())===at}function rs(s){return(s==null?void 0:s.getBlueId())===ct}function ss(s,e){return Ye.some(t=>{const r=new d().setName(t);return E(s,r,e)})}function ns(s,e){for(const t of Ye){const r=new d().setName(t);if(E(s,r,e))return t}throw new Error(`Cannot determine the basic type for node of type "${s.getName()||"unknown"}".`)}const is=s=>s instanceof u.ZodOptional||s instanceof u.ZodNullable||s instanceof u.ZodReadonly||s instanceof u.ZodBranded||s instanceof u.ZodEffects||s instanceof u.ZodLazy,os=s=>s instanceof u.ZodString||s instanceof u.ZodNumber||s instanceof u.ZodBoolean||s instanceof u.ZodBigInt;class Mt{static convertValue(e,t){var i;const r=(i=e.getType())==null?void 0:i.getBlueId(),n=e.getValue();return c.isNullable(n)?os(t)&&Te.isValidValueNode(e)?this.getDefaultPrimitiveValue(t):n:k===r?this.convertFromString(String(n),t):Y===r||n instanceof w?this.convertFromBigDecimal(new w(n==null?void 0:n.toString()),t):J===r||n instanceof T?this.convertFromBigInteger(new T(n==null?void 0:n.toString()),t):K===r||typeof n=="boolean"?this.convertFromBoolean(!!n,t):this.convertFromString(String(n),t)}static convertFromString(e,t){if(!t||t instanceof u.ZodString||t instanceof u.ZodEnum||t instanceof u.ZodNativeEnum)return e;if(t instanceof u.ZodNumber)return Number(e);if(t instanceof u.ZodBoolean)return e.toLowerCase()==="true";if(t instanceof u.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert String to ${t._def.typeName}`)}static convertFromBigDecimal(e,t){if(t instanceof u.ZodNumber)return e.toNumber();if(t instanceof u.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBigInteger(e,t){if(t instanceof u.ZodNumber)return e.toNumber();if(t instanceof u.ZodBigInt)return BigInt(e.toString());if(t instanceof u.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBoolean(e,t){if(!t||t instanceof u.ZodBoolean)return e;if(t instanceof u.ZodString)return e.toString();if(t instanceof u.ZodNumber)return Number(e);if(t instanceof u.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert Boolean to ${t._def.typeName}`)}static getDefaultPrimitiveValue(e){if(!e)return null;if(e instanceof u.ZodNumber)return 0;if(e instanceof u.ZodBoolean)return!1;if(e instanceof u.ZodString)return"";throw new Error(`Unsupported primitive type: ${e._def.typeName}`)}}class ls{convert(e,t){return Mt.convertValue(e,t)}}class as{constructor(e){this.nodeToObjectConverter=e}convert(e,t){return this.convertFields(e,t)}convertFields(e,t){if(t instanceof u.ZodIntersection){const r=t._def.left,n=t._def.right,i=this.convert(e,r),o=this.convert(e,n);return{...i,...o}}if(t instanceof u.ZodUnion)throw new Error("Union not supported");if(t instanceof u.ZodObject)return Object.keys(t.shape).reduce((n,i)=>{const o=e.getProperties(),l=t.shape[i],a=Et(l);if(c.isNonNullable(a)){const b=A.isString(a)?a:i,L=o==null?void 0:o[b],G=L?N.calculateBlueIdSync(L):void 0;return n[i]=G,n}const p=St(l);if(c.isNonNullable(p)){const b=o==null?void 0:o[p];return n[i]=b==null?void 0:b.getName(),n}const I=vt(l);if(c.isNonNullable(I)){const b=o==null?void 0:o[I];return n[i]=b==null?void 0:b.getDescription(),n}if(i==="name"){const b=e.getName();return n[i]=b,n}if(i==="description"){const b=e.getDescription();return n[i]=b,n}const y=o==null?void 0:o[i];if(c.isNullable(y))return n;const m=this.nodeToObjectConverter.convert(y,l);return n[i]=m,n},{});throw new Error("Unknown schema type, "+t._def.typeName)}}class cs{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=e.getItems();if(!r)return;const n=t.element;return r.map(o=>this.nodeToObjectConverter.convert(o,n))}}class us{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=e.getItems();if(!r)return;const n=t._def.valueType,i=r.map(o=>this.nodeToObjectConverter.convert(o,n));return new Set(i)}}class ds{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=t.keySchema,n=t.valueSchema,i=new Map,o=e.getName();c.isNonNullable(o)&&i.set(q,o);const l=e.getDescription();c.isNonNullable(l)&&i.set(X,l);const a=e.getProperties();return c.isNonNullable(a)&&Object.entries(a).forEach(([p,I])=>{const y=new d().setValue(p);y.setType(new d().setBlueId(k));const m=Mt.convertValue(y,r),b=this.nodeToObjectConverter.convert(I,n);i.set(m,b)}),t instanceof u.ZodRecord?Object.fromEntries(i):i}}class hs{convert(e){return g.get(e)}}class ps{convert(e){return g.get(e)}}class fs{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=e.getItems();if(!r)return;const n=t.items;return r.map((o,l)=>this.nodeToObjectConverter.convert(o,n[l]))}}const gs=u.z.union([u.z.literal("ZodString"),u.z.literal("ZodNumber"),u.z.literal("ZodBoolean"),u.z.literal("ZodBigInt"),u.z.literal("ZodArray"),u.z.literal("ZodSet"),u.z.literal("ZodMap"),u.z.literal("ZodRecord"),u.z.literal("ZodObject"),u.z.literal("ZodEnum"),u.z.literal("ZodNativeEnum"),u.z.literal("ZodUnknown"),u.z.literal("ZodAny"),u.z.literal("ZodTuple")]);class ys{constructor(e){h(this,"converters",new Map);h(this,"complexObjectConverter");this.nodeToObjectConverter=e,this.registerConverters(),this.complexObjectConverter=new as(this.nodeToObjectConverter)}registerConverters(){const e=new ls,t=new cs(this.nodeToObjectConverter),r=new fs(this.nodeToObjectConverter),n=new us(this.nodeToObjectConverter),i=new ds(this.nodeToObjectConverter);this.converters.set("ZodString",e),this.converters.set("ZodNumber",e),this.converters.set("ZodBoolean",e),this.converters.set("ZodBigInt",e),this.converters.set("ZodEnum",e),this.converters.set("ZodNativeEnum",e),this.converters.set("ZodUnknown",new hs),this.converters.set("ZodAny",new ps),this.converters.set("ZodArray",t),this.converters.set("ZodTuple",r),this.converters.set("ZodSet",n),this.converters.set("ZodMap",i),this.converters.set("ZodRecord",i),this.converters.set("ZodObject",this.complexObjectConverter)}getConverter(e){const t=this.getSchemaTypeName(e);return this.converters.get(t)??this.complexObjectConverter}getSchemaTypeName(e){if(is(e))return e instanceof u.ZodEffects?this.getSchemaTypeName(e.innerType()):e instanceof u.ZodLazy?this.getSchemaTypeName(e.schema):this.getSchemaTypeName(e.unwrap());const t=e._def.typeName;try{return gs.parse(t)}catch{throw new Error(`Schema type name ${t} is not supported`)}}}class ms{constructor(e){h(this,"converterFactory");this.typeSchemaResolver=e,this.converterFactory=new ys(this)}convert(e,t){var o;const r=(o=this.typeSchemaResolver)==null?void 0:o.resolveSchema(e),n=S.unwrapSchema(t);if(He(n))return e;let i=n;return S.checkSchemaExtension(r,n)&&c.isNonNullable(r)&&(i=r),this.convertWithType(e,i)}convertWithType(e,t){return this.converterFactory.getConverter(t).convert(e,t)}}class he{fetchFirstByBlueId(e){const t=this.fetchByBlueId(e);return t&&t.length>0?t[0]:null}}function Is(s){return new class extends he{fetchByBlueId(e){return s(e)}}}class bs extends he{constructor(t){super();h(this,"nodeProviders");this.nodeProviders=t}fetchByBlueId(t){for(const r of this.nodeProviders){const n=r.fetchByBlueId(t);if(n&&n.length>0)return n}return[]}fetchFirstByBlueId(t){for(const r of this.nodeProviders){const n=r.fetchFirstByBlueId(t);if(n)return n}return null}getNodeProviders(){return this.nodeProviders}}const Ce=Z.types.float.options,Ns={...Ce,construct:s=>{const e=s.replace(/_/g,"").toLowerCase();if(!c.isPreciseNumberString(e))return new w(e);if(Ce.construct)return Ce.construct(s)}},Ts=new Z.Type("tag:yaml.org,2002:float",Ns),Ve=Z.types.int.options,Bs={...Ve,construct:s=>{let e=s;if(e.indexOf("_")!==-1&&(e=e.replace(/_/g,"")),!c.isPreciseNumberString(e))return new T(e);if(Ve.construct)return Ve.construct(s)}},vs=new Z.Type("tag:yaml.org,2002:int",Bs),Rt=Z.CORE_SCHEMA.extend({implicit:[Ts,vs]}),F=s=>{const e=Z.load(s,{schema:Rt});return e===void 0?void 0:e},ws=s=>Z.dump(s,{schema:Rt,replacer:(e,t)=>{if(D(t)){if(x(t)){const r=new j(Number.MIN_SAFE_INTEGER.toString()),n=new j(Number.MAX_SAFE_INTEGER.toString());if(t.lt(r)||t.gt(n))return t.toString()}return t.toNumber()}return t}}),jt=`- type:
1
+ "use strict";var Qt=Object.defineProperty;var er=(s,e,t)=>e in s?Qt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var h=(s,e,t)=>er(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("big.js"),c=require("@blue-labs/shared-utils"),u=require("zod"),tr=require("bs58"),A=require("radash"),rr=require("js-sha256"),sr=require("crypto"),nr=require("base32.js"),Z=require("js-yaml"),ot=s=>s&&s.__esModule?s:{default:s},le=ot(tr),we=ot(sr);class w extends j{constructor(e){super(e)}}class T extends j{constructor(e){super(e)}}class ir{static get(e,t,r,n=!0){if(c.isNullable(t)||!t.startsWith("/"))throw new Error(`Invalid path: ${t}`);if(t==="/"){const o=e.getValue();return n&&o!==void 0?o:e}const i=t.substring(1).split("/");return this.getRecursive(e,i,0,r,n)}static getRecursive(e,t,r,n,i){if(r===t.length-1&&!i)return this.getNodeForSegment(e,t[r],n,!1);if(r===t.length){const a=e.getValue();return i&&a!==void 0?a:e}const o=t[r],l=this.getNodeForSegment(e,o,n,!0);if(l)return this.getRecursive(l,t,r+1,n,i)}static getNodeForSegment(e,t,r,n){let i;const o=e.getProperties();if(o&&t in o)i=o[t];else switch(t){case"name":{const l=e.getName();i=new d().setValue(l??null);break}case"description":{const l=e.getDescription();i=new d().setValue(l??null);break}case"type":i=e.getType();break;case"itemType":i=e.getItemType();break;case"keyType":i=e.getKeyType();break;case"valueType":i=e.getValueType();break;case"value":{const l=e.getValue();i=new d().setValue(l??null);break}case"blueId":{const l=e.getBlueId();i=new d().setValue(l??null);break}case"blue":i=e.getBlue();break;case"items":{const l=e.getItems();i=new d().setItems(l);break}case"properties":{const l=e.getProperties();i=new d().setProperties(l);break}case"contracts":{const l=e.getContracts();i=new d().setContracts(l);break}default:{if(/^\d+$/.test(t)){const l=parseInt(t,10),a=e.getItems();a&&l>=0&&l<a.length?i=a[l]:i=void 0}else i=void 0;break}}if(i)return n&&r?this.link(i,r):i}static link(e,t){const r=t(e);return c.isNonNullable(r)?r:e}}const q="name",X="description",pe="type",ze="itemType",Ue="keyType",_e="valueType",be="value",Ze="items",_="blueId",ke="blue",or=[q,X,pe,ze,Ue,_e,be,Ze,_,ke],lr="Text",ar="Double",cr="Integer",ur="Boolean",dr="List",hr="Dictionary",Ye=[lr,ar,cr,ur],lt=[...Ye,dr,hr],k="F92yo19rCcbBoBSpUA5LRxpfDejJDAaP1PRxxbWAraVP",Y="68ryJtnmui4j5rCZWUnkZ3DChtmEb7Z9F8atn1mBSM3L",J="DHmxTkFbXePZHCHCYmQr2dSzcNLcryFVjXVHkdQrrZr8",K="EL6AjrbJsxTWRTPzY8WR8Y2zAMXRbydQj83PcZwuAHbo",at="G8wmfjEqugPEEXByMYWJXiEdbLToPRWNQEekNxrxfQWB",ct="294NBTj2mFRL3RB4kDRUSckwGg7Kzj6T8CTAFeR1kcSA",ut=[k,Y,J,K],ue=[...ut,at,ct];Object.fromEntries(lt.map((s,e)=>[s,ue[e]]));const pr=Object.fromEntries(ue.map((s,e)=>[s,lt[e]])),P=class P{constructor(e){h(this,"name");h(this,"description");h(this,"type");h(this,"itemType");h(this,"keyType");h(this,"valueType");h(this,"value");h(this,"items");h(this,"properties");h(this,"blueId");h(this,"blue");h(this,"inlineValue",!1);this.name=e}getName(){return this.name}setName(e){return this.name=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getType(){return this.type}setType(e){return typeof e=="string"?this.type=new P().setValue(e).setInlineValue(!0):this.type=e,this}getItemType(){return this.itemType}setItemType(e){return typeof e=="string"?this.itemType=new P().setValue(e).setInlineValue(!0):this.itemType=e,this}getKeyType(){return this.keyType}setKeyType(e){return typeof e=="string"?this.keyType=new P().setValue(e).setInlineValue(!0):this.keyType=e,this}getValueType(){return this.valueType}setValueType(e){return typeof e=="string"?this.valueType=new P().setValue(e).setInlineValue(!0):this.valueType=e,this}getValue(){var t;const e=(t=this.type)==null?void 0:t.getBlueId();if(c.isNonNullable(e)&&c.isNonNullable(this.value)){if(e===J&&typeof this.value=="string")return new T(this.value);if(e===Y&&typeof this.value=="string"){const r=new w(this.value),n=parseFloat(r.toString());return new w(n.toString())}else if(e===K&&typeof this.value=="string")return this.value.toLowerCase()==="true"}return this.value}setValue(e){return typeof e=="number"?e%1===0?this.value=new T(e.toString()):this.value=new w(e.toString()):this.value=e,this}getItems(){return this.items}setItems(e){return this.items=e,this}addItems(...e){return this.items||(this.items=[]),this.items.push(...e),this}getProperties(){return this.properties}setProperties(e){return this.properties=e,this}addProperty(e,t){return this.properties||(this.properties={}),this.properties[e]=t,this}removeProperty(e){return this.properties&&delete this.properties[e],this}getContractsProperty(){var e;return(e=this.properties)==null?void 0:e.contracts}getContracts(){var e;return(e=this.getContractsProperty())==null?void 0:e.getProperties()}setContracts(e){return c.isNullable(e)?this.removeProperty("contracts"):this.addProperty("contracts",new P().setProperties(e)),this}addContract(e,t){const r=this.getContractsProperty();return c.isNullable(r)?this.addProperty("contracts",new P().addProperty(e,t)):r.addProperty(e,t),this}removeContract(e){const t=this.getContractsProperty();if(t){t.removeProperty(e);const r=t.getProperties();r&&Object.keys(r).length===0&&this.removeProperty("contracts")}return this}getBlueId(){return this.blueId}setBlueId(e){return this.blueId=e,this}getBlue(){return this.blue}setBlue(e){return this.blue=e,this}isInlineValue(){return this.inlineValue}setInlineValue(e){return this.inlineValue=e,this}isResolved(){return!1}get(e,t){return ir.get(this,e,t)}getAsNode(e){const t=this.get(e);if(t instanceof P)return t;throw new Error(`Value at path ${e} is not a BlueNode: ${t}`)}getAsInteger(e){const t=this.get(e);if(t instanceof T||t instanceof w)return t.toNumber();throw new Error(`Value at path ${e} is not a BigInteger or BigDecimal: ${t}`)}clone(){var t,r,n,i,o,l;const e=new P(this.name);return e.description=this.description,e.type=(t=this.type)==null?void 0:t.clone(),e.itemType=(r=this.itemType)==null?void 0:r.clone(),e.keyType=(n=this.keyType)==null?void 0:n.clone(),e.valueType=(i=this.valueType)==null?void 0:i.clone(),e.value=this.value,e.items=(o=this.items)==null?void 0:o.map(a=>a.clone()),this.properties&&(e.properties=Object.fromEntries(Object.entries(this.properties).map(([a,p])=>[a,p.clone()]))),e.blueId=this.blueId,e.blue=(l=this.blue)==null?void 0:l.clone(),e.inlineValue=this.inlineValue,e}toString(){return`BlueNode{name='${this.name}', description='${this.description}', type=${this.type}, itemType=${this.itemType}, keyType=${this.keyType}, valueType=${this.valueType}, value=${this.value}, items=${this.items}, properties=${this.properties}, blueId='${this.blueId}', blue=${this.blue}, inlineValue=${this.inlineValue}}`}};h(P,"INTEGER",new P("Integer"));let d=P;class U{static isPotentialBlueId(e){if(!e||e.length===0||!this.BLUE_ID_PATTERN.test(e))return!1;const t=e.split("#"),r=t[0],n=r.length;if(n<this.MIN_BLUE_ID_LENGTH||n>this.MAX_BLUE_ID_LENGTH)return!1;try{if(le.default.decode(r).length!==32)return!1}catch{return!1}if(t.length>1)try{if(Number(t[1])<0)return!1}catch{return!1}return!0}}h(U,"MIN_BLUE_ID_LENGTH",41),h(U,"MAX_BLUE_ID_LENGTH",45),h(U,"BLUE_ID_PATTERN",/^[1-9A-HJ-NP-Za-km-z]{41,45}(?:#\d+)?$/);const fr=u.z.string().max(U.MAX_BLUE_ID_LENGTH,{message:"Blue Id has a maximum length of 45 characters"}).min(U.MIN_BLUE_ID_LENGTH,{message:"Blue Id has a minimum length of 41 characters"}).refine(s=>{try{return le.default.decode(s),!0}catch{return!1}},{message:"Blue Id must be a valid Base58 string"}),Q=u.z.lazy(()=>u.z.record(u.z.unknown()).and(u.z.object({blueId:u.z.string().optional(),name:u.z.string().optional(),description:u.z.string().optional(),type:Q.optional(),value:u.z.union([u.z.string(),u.z.number(),u.z.boolean()]).optional().nullable(),items:u.z.array(Q).optional()}))),de=u.z.object({blueId:u.z.string().optional(),name:u.z.string().optional(),description:u.z.string().optional(),type:Q.optional()}),gr=de.extend({value:u.z.string().optional()}),yr=de.extend({value:u.z.number().optional()}),mr=de.extend({value:u.z.boolean().optional()}),Ir=de.extend({items:u.z.array(u.z.string()).optional()}),br=s=>Q.safeParse(s).success,dt=s=>c.isNonNullable(s)&&"blueId"in s&&c.isNonNullable(s.blueId),Nr=s=>c.isNonNullable(s)&&"name"in s&&c.isNonNullable(s.name),ht=s=>c.isNonNullable(s)&&"items"in s&&c.isNonNullable(s.items),pt=s=>c.isNonNullable(s)&&"type"in s&&c.isNonNullable(s.type),ft=s=>c.isNonNullable(s)&&"value"in s&&c.isNonNullable(s.value),Tr=(s,e)=>s.required({type:!0}).safeParse(e).success,D=s=>s instanceof j,x=s=>D(s)&&s instanceof T,fe=s=>D(s)&&s instanceof w,Br=u.z.lazy(()=>u.z.record(ae)),vr=u.z.lazy(()=>u.z.union([u.z.array(ae),u.z.array(ae).readonly()])),ae=u.z.lazy(()=>u.z.union([c.jsonPrimitiveSchema,Br,vr,u.z.instanceof(j)])),Je=s=>A.isObject(s)&&!A.isArray(s)&&!c.isReadonlyArray(s)&&!D(s),Ke=s=>A.isArray(s)||c.isReadonlyArray(s),wr=s=>Ke(s)||Je(s)||D(s)||c.isJsonPrimitive(s);class f{static deserialize(e){return f.handleNode(e)}static handleNode(e){if(e===void 0)throw new Error("This is not a valid JSON-like value. Found 'undefined' as a value.");if(Je(e)){const t=new d,r={};return Object.entries(e).forEach(([n,i])=>{switch(n){case q:if(i==null)t.setName(void 0);else{if(typeof i!="string")throw new Error(`The ${q} field must be a string.`);t.setName(i)}break;case X:if(i==null)t.setDescription(void 0);else{if(typeof i!="string")throw new Error(`The ${X} field must be a string.`);t.setDescription(i)}break;case pe:t.setType(f.handleNode(i));break;case ze:t.setItemType(f.handleNode(i));break;case Ue:t.setKeyType(f.handleNode(i));break;case _e:t.setValueType(f.handleNode(i));break;case be:t.setValue(f.handleValue(i));break;case _:if(typeof i!="string")throw new Error(`The ${_} field must be a string.`);t.setBlueId(i);break;case Ze:t.setItems(f.handleArray(i));break;case ke:t.setBlue(f.handleNode(i));break;default:r[n]=f.handleNode(i);break}}),Object.keys(r).length>0&&t.setProperties(r),t}else{if(Ke(e))return new d().setItems(f.handleArray(e));{const t=e;return new d().setValue(f.handleValue(t)).setInlineValue(!0)}}}static handleValue(e){if(e==null)return null;if(typeof e=="string")return e;if(typeof e=="number"||D(e))if(x(e)||Number.isSafeInteger(e)){const t=new T(e.toString()),r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER;return t.lt(r)?new T(r.toString()):t.gt(n)?new T(n.toString()):t}else{const t=parseFloat(e.toString());return new w(t.toString())}else if(typeof e=="boolean")return e;throw new Error(`Can't handle node: ${JSON.stringify(e)}`)}static handleArray(e){if(e!=null){if(A.isObject(e)&&!Array.isArray(e))return[f.handleNode(e)];if(Array.isArray(e))return e.map(f.handleNode);throw new Error("Expected an array node")}}}function Er(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ee,rt;function Pr(){return rt||(rt=1,Ee=function s(e){if(typeof e=="number"&&isNaN(e))throw new Error("NaN is not allowed");if(typeof e=="number"&&!isFinite(e))throw new Error("Infinity is not allowed");return e===null||typeof e!="object"?JSON.stringify(e):e.toJSON instanceof Function?s(e.toJSON()):Array.isArray(e)?`[${e.reduce((n,i,o)=>`${n}${o===0?"":","}${s(i===void 0||typeof i=="symbol"?null:i)}`,"")}]`:`{${Object.keys(e).sort().reduce((r,n)=>{if(e[n]===void 0||typeof e[n]=="symbol")return r;const i=r.length===0?"":",";return`${r}${i}${s(n)}:${s(e[n])}`},"")}}`}),Ee}var Sr=Pr();const Ar=Er(Sr);class gt{static canonicalize(e){return Ar(e)}}const Pe=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,ye=class ye{constructor(){h(this,"browserCrypto");this.browserCrypto=this.initBrowserCrypto()}static getInstance(){return this.instance||(this.instance=new ye),this.instance}initBrowserCrypto(){return Pe?null:"crypto"in globalThis?globalThis.crypto:null}hasNodeCrypto(){return Pe&&!!we.default&&typeof we.default.createHash=="function"}getBrowserCrypto(){return this.browserCrypto}getNodeCrypto(){return Pe?we.default:null}};h(ye,"instance");let Oe=ye;class yt{constructor(){h(this,"cryptoEnv",Oe.getInstance())}applySync(e){const t=this.canonicalizeInput(e),r=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):this.sha256SyncBrowser(t);return le.default.encode(new Uint8Array(r))}async apply(e){const t=this.canonicalizeInput(e),r=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):await this.sha256Async(t);return le.default.encode(new Uint8Array(r))}canonicalizeInput(e){const t=gt.canonicalize(e);if(typeof t!="string")throw new Error("Canonized value must be a string");return t}sha256Sync(e){const t=this.cryptoEnv.getNodeCrypto();if(!t)throw new Error("Synchronous SHA-256 is not available in this environment");return t.createHash("sha256").update(e).digest()}sha256SyncBrowser(e){return rr.sha256.arrayBuffer(e)}async sha256Async(e){if(this.cryptoEnv.hasNodeCrypto())return this.sha256Sync(e);const t=this.cryptoEnv.getBrowserCrypto();if(!t)throw new Error("crypto is not available in this environment");const n=new TextEncoder().encode(e);return t.subtle.digest("SHA-256",n)}}class g{static get(e,t="official"){var tt;const r=e.getValue(),n=this.handleValue(r);if(n!==void 0&&t==="simple")return n;const i=(tt=e.getItems())==null?void 0:tt.map(W=>g.get(W,t));if(i!==void 0&&t==="simple")return i;const o=e.getName(),l=e.getDescription();if(t==="original"&&o===void 0&&l===void 0){if(n!==void 0)return n;if(i!==void 0)return i}const a={};o!==void 0&&(a[q]=o),l!==void 0&&(a[X]=l);const p=e.getType();if(t==="official"&&r!==void 0&&p===void 0){const W=this.inferTypeBlueId(r);W!==null&&(a[pe]={[_]:W})}else p!==void 0&&(a[pe]=g.get(p,t));const I=e.getItemType();I!==void 0&&(a[ze]=g.get(I,t));const y=e.getKeyType();y!==void 0&&(a[Ue]=g.get(y,t));const m=e.getValueType();m!==void 0&&(a[_e]=g.get(m,t)),n!==void 0&&(a[be]=n),i!==void 0&&(a[Ze]=i);const b=e.getBlueId();b!==void 0&&(a[_]=b);const L=e.getBlue();L!==void 0&&(a[ke]=L);const G=e.getProperties();return G!==void 0&&Object.entries(G).forEach(([W,Xt])=>{a[W]=g.get(Xt,t)}),a}static handleValue(e){if(D(e)){if(x(e)){const t=new j(Number.MIN_SAFE_INTEGER.toString()),r=new j(Number.MAX_SAFE_INTEGER.toString());if(e.lt(t)||e.gt(r))return e.toString()}return e.toNumber()}return e}static inferTypeBlueId(e){return typeof e=="string"?k:D(e)?x(e)?J:Y:typeof e=="boolean"?K:null}}const Cr=s=>c.isJsonPrimitive(s)&&c.isNonNullable(s),M=class M{constructor(e){h(this,"hashProvider");this.hashProvider=e}static calculateBlueId(e){if(Array.isArray(e)){const r=e.map(n=>g.get(n));return M.INSTANCE.calculate(r)}const t=g.get(e);return M.INSTANCE.calculate(t)}static calculateBlueIdSync(e){if(Array.isArray(e)){const r=e.map(n=>g.get(n));return M.INSTANCE.calculateSync(r)}const t=g.get(e);return M.INSTANCE.calculateSync(t)}calculate(e){const t=this.cleanStructure(e);if(t===void 0)throw new Error("Object after cleaning cannot be null or undefined.");return this.internalCalculate(t,!1)}calculateSync(e){const t=this.cleanStructure(e);if(t===void 0)throw new Error("Object after cleaning cannot be null or undefined.");return this.internalCalculate(t,!0)}internalCalculate(e,t){return Cr(e)||D(e)?this.applyHash(e.toString(),t):Array.isArray(e)||c.isReadonlyArray(e)?this.calculateList(e,t):this.calculateMap(e,t)}calculateMap(e,t){if(e[_]!==void 0)return e[_];const n=Object.keys(e).map(o=>{const l=e[o];if([q,be,X].includes(o))return t?[o,l]:Promise.resolve([o,l]);{const a=this.internalCalculate(l,t);return t?[o,{blueId:a}]:Promise.resolve(a).then(p=>[o,{blueId:p}])}}),i=o=>{const l={};for(const[a,p]of o)l[a]=p;return this.applyHash(l,t)};return t?i(n):Promise.all(n).then(i)}calculateList(e,t){if(e.length===0)throw new Error("Cannot calculate BlueId for an empty list.");let r=this.internalCalculate(e[0],t);const n=(i,o)=>t?this.applyHash([{blueId:i},{blueId:o}],!0):Promise.all([i,o]).then(([l,a])=>this.applyHash([{blueId:l},{blueId:a}],!1));for(let i=1;i<e.length;i++){const o=this.internalCalculate(e[i],t);r=n(r,o)}return r}applyHash(e,t){return t?this.hashProvider.applySync(e):this.hashProvider.apply(e)}cleanStructure(e){if(e!=null){if(c.isJsonPrimitive(e)||D(e))return e;if(Array.isArray(e)||c.isReadonlyArray(e)){const t=e.map(r=>this.cleanStructure(r)).filter(c.isNonNullable);return t.length>0?t:void 0}else if(typeof e=="object"){const t={};for(const r in e){const n=this.cleanStructure(e[r]);n!=null&&(t[r]=n)}return Object.keys(t).length>0?t:void 0}else return e}}};h(M,"INSTANCE",new M(new yt));let N=M;class Vr{static convert(e){const t=le.default.decode(e),r=new Uint8Array(2+t.length);r[0]=18,r[1]=32,r.set(t,2);const n=new Uint8Array(2+r.length);return n[0]=1,n[1]=85,n.set(r,2),"b"+new nr.Encoder({type:"rfc4648",lc:!0}).write(n).finalize().replace(/=/g,"")}}class V{static transform(e,t){const r=t(e.clone()),n=r.getType();n!==void 0&&r.setType(V.transform(n,t));const i=r.getItemType();i!==void 0&&r.setItemType(V.transform(i,t));const o=r.getKeyType();o!==void 0&&r.setKeyType(V.transform(o,t));const l=r.getValueType();l!==void 0&&r.setValueType(V.transform(l,t));const a=r.getItems();if(a!==void 0){const I=a.map(y=>V.transform(y,t));r.setItems(I)}const p=r.getProperties();if(p!==void 0){const I=Object.keys(p).reduce((y,m)=>(y[m]=V.transform(p[m],t),y),{});r.setProperties(I)}return r}}const $=s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof d),O=s=>s instanceof T||s instanceof w,Dr=s=>s.replace(/~1/g,"/").replace(/~0/g,"~");function re(s){if(s==="/")return[];if(!s.startsWith("/"))throw new Error(`Path must start with '/': ${s}`);return s.split("/").slice(1).map(Dr)}function ee(s){if(s==="-")return-1;const e=typeof s=="number"?s:parseInt(s,10);if(isNaN(e))throw new Error(`Invalid array index (NaN) from '${s}'`);if(!Number.isFinite(e))throw new Error(`Invalid array index '${s}' results in non-finite number ${e}`);return e}function mt(s,e,t,r=!0){switch(e){case"name":return t?r?s.getName()??null:s:s.getName();case"description":return t?r?s.getDescription():s:s.getDescription();case"type":return s.getType();case"itemType":return s.getItemType();case"keyType":return s.getKeyType();case"valueType":return s.getValueType();case"value":return t?r?s.getValue()??null:s:s.getValue();case"blueId":return t?r?s.getBlueId()??null:s:s.getBlueId();case"blue":return s.getBlue();case"items":return s.getItems();case"properties":return s.getProperties();case"contracts":return s.getContracts();default:return}}function st(s,e,t=!0){if(s instanceof d){const r=mt(s,e,!0,t);if(r!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties","contracts"].includes(e))return r;if(/^-?\d+$/.test(e)&&e!=="-"){const i=s.getItems(),o=parseInt(e,10);return i&&o>=0&&o<i.length?i[o]:void 0}const n=s.getProperties();return n&&e in n?n[e]:void 0}if(Array.isArray(s)){if(e==="-")return;const r=ee(e);return r>=0&&r<s.length?s[r]:void 0}if($(s))return s[e]}function se(s,e){if(e.length===0)return{parent:s,key:"value",actualTarget:s.getValue()??s};let t=s;for(let n=0;n<e.length-1;++n){const i=e[n],o=st(t,i);if(o===void 0)throw new Error(`Cannot resolve '/${e.slice(0,n+1).join("/")}'`);t=o}const r=e[e.length-1];if(t instanceof d){const n=st(t,r,!1);if((typeof n!="object"||n===null||O(n))&&!(n instanceof d)&&!Array.isArray(n)&&["name","description","value","blueId"].includes(r))return{parent:t,key:r,actualTarget:n}}return Array.isArray(t)&&r==="-"?{parent:t,key:"-"}:t instanceof d&&t.getItems()&&r==="-"?{parent:t,key:"-"}:{parent:t,key:Array.isArray(t)?ee(r):r}}function Ge(s,e){var t;if(s instanceof d){const r=e,n=mt(s,r,!1);if(n!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties","contracts"].includes(r))return n;if(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e)){const i=s.getItems(),o=typeof e=="number"?e:parseInt(e,10);if(i&&o>=0&&o<i.length)return i[o]}return(t=s.getProperties())==null?void 0:t[r]}return Array.isArray(s)||$(s)?s[e]:s}function v(s){if(s instanceof d)return s;if(s===null||typeof s=="string"||typeof s=="number"||typeof s=="boolean"||O(s))return f.deserialize(s);const e=Fe(s);return f.deserialize(e)}function Fe(s){if(s===void 0)return null;if(s===null||typeof s!="object")return s;if(Array.isArray(s))return s.map(Fe);const e={};for(const[t,r]of Object.entries(s))e[t]=Fe(r);return e}function We(s,e,t){if(s instanceof d){const r=e;switch(r){case"name":s.setName(t);return;case"description":s.setDescription(t);return;case"type":s.setType(t instanceof d||typeof t=="string"||t===void 0?t:v(t));return;case"itemType":s.setItemType(t instanceof d||typeof t=="string"||t===void 0?t:v(t));return;case"keyType":s.setKeyType(t instanceof d||typeof t=="string"||t===void 0?t:v(t));return;case"valueType":s.setValueType(t instanceof d||typeof t=="string"||t===void 0?t:v(t));return;case"value":{const n=t;s.setValue(n===void 0?null:n);return}case"blueId":s.setBlueId(t);return;case"blue":s.setBlue(t instanceof d||t===void 0?t:v(t));return;case"items":s.setItems(t);return;case"properties":s.setProperties(t);return;case"contracts":s.setContracts(t);return;default:{if(t===void 0){const n=s.getProperties();n&&r in n&&delete n[r]}else s.getProperties()||s.setProperties({}),s.addProperty(r,t instanceof d?t:v(t));return}}}Array.isArray(s)?s.splice(ee(e),1):$(s)&&(t===void 0?delete s[e]:s[e]=t)}function Or(s,e,t,r){let n=-1;if(e!=="-"&&(n=typeof e=="number"?e:parseInt(e,10),isNaN(n)))throw new Error(`Invalid numeric key for BlueNode item operation: ${e}`);if(n<-1)throw new Error(`Invalid array index for BlueNode items: ${n}`);let i=s.getItems();if(i||(i=[],s.setItems(i)),!r&&n!==-1&&n>i.length)throw new Error(`ADD operation failed: Target array index '${n}' is greater than array length ${i.length}.`);if(e==="-")i.push(t);else if(r){if(n>=0)if(n<i.length)i[n]=t;else{for(let o=i.length;o<n;o++)i.push(f.deserialize(null));i.push(t)}}else i.splice(n,0,t)}function ge(s,e,t,r){if(Array.isArray(s)){const n=e==="-"?s.length:ee(e);if(!r&&n>s.length)throw new Error(`ADD operation failed: Target array index '${n}' is greater than array length ${s.length}. Path involving key '${e}'.`);if(n<0&&e!=="-")throw new Error(`Invalid negative array index: ${e}`);const i=v(t);if(r){if(n>=0&&n<s.length)s[n]=i;else if(n>=s.length){for(let o=s.length;o<n;o++)s.push(f.deserialize(null));s.push(i)}}else s.splice(n,0,i);return}if(s instanceof d){e==="-"||typeof e=="number"&&!isNaN(e)||typeof e=="string"&&/^\d+$/.test(e)?Or(s,e,v(t),r):We(s,e,t);return}if($(s)){s[e]=v(t);return}throw new Error(`Cannot insert into parent of type ${typeof s}`)}function Fr(s,e){if(Array.isArray(s)){const t=ee(e);t===-1&&e==="-"?s.length>0&&s.pop():t>=0&&t<s.length&&s.splice(t,1);return}if(s instanceof d){if(typeof e=="number"||typeof e=="string"&&/^-?\d+$/.test(e)){const t=s.getItems();if(t){const r=ee(e);r===-1&&e==="-"?t.length>0&&t.pop():r>=0&&r<t.length&&t.splice(r,1),t.length===0&&s.setItems(void 0);return}}We(s,e,void 0)}else $(s)&&delete s[e]}function Me(s){if(s instanceof d)return s.clone();if(Array.isArray(s))return s.map(t=>Me(t));if($(s)){const e={};return Object.keys(s).forEach(t=>{e[t]=Me(s[t])}),e}return s}function z(s,e){if(s===e||s instanceof d&&(s.isInlineValue()||s.getValue()!==void 0)&&z(s.getValue()??null,e)||e instanceof d&&(e.isInlineValue()||e.getValue()!==void 0)&&z(s,e.getValue()??null))return!0;if(s instanceof d&&e instanceof d||O(s)&&O(e)||O(s)&&typeof e=="number"||typeof s=="number"&&O(e))return s.toString()===e.toString();if(Array.isArray(s)&&Array.isArray(e))return s.length===e.length&&s.every((t,r)=>z(t,e[r]));if($(s)&&$(e)){const t=Object.keys(s),r=Object.keys(e);return t.length===r.length&&t.every(n=>z(s[n],e[n]))}return!1}function It(s,e){const{parent:t,key:r}=se(s,re(e));return Ge(t,r)}function bt(s,e,t){const r=re(e);if(r.length===0&&e==="/"){const o=v(t);s.setValue(o.getValue()??null),o.getItems()?s.setItems(o.getItems()):s.setItems(void 0);return}const{parent:n,key:i}=se(s,r);ge(n,i,t,!0)}function Mr(s,e,t){const r=re(e);if(r.length===0&&e==="/"){if(s.getItems()&&Array.isArray(t)){const o=v(t);o.getItems()?(s.setItems(o.getItems()),s.setValue(null)):(s.setValue(o.getValue()??null),s.setItems(void 0))}else{const o=v(t);s.setValue(o.getValue()??null),o.getItems()&&s.setItems(o.getItems())}return!0}const{parent:n,key:i}=se(s,r);return ge(n,i,t,!1),!0}function Rr(s,e,t){const r=re(e);if(r.length===0&&e==="/"){const l=v(t);return s.setValue(l.getValue()??null),l.getItems()?s.setItems(l.getItems()):s.setItems(void 0),!0}const{parent:n,key:i,actualTarget:o}=se(s,r);if(o!==void 0&&n instanceof d)We(n,i,t);else{const l=Ge(n,i),a=Array.isArray(n)||n instanceof d&&n.getItems()&&(typeof i=="number"||typeof i=="string"&&/^\d+$/.test(i));if(l===void 0){if(a)throw new Error(`REPLACE failed: Target array index '${i.toString()}' is out of bounds or does not exist at path '${e}'.`);ge(n,i,t,!0)}else ge(n,i,t,!0)}return!0}function Nt(s,e){const t=re(e);if(t.length===0&&e==="/")return s.setValue(null),s.setItems(void 0),s.setProperties(void 0),!0;const{parent:r,key:n}=se(s,t);return Fr(r,n),!0}function jr(s,e,t){const r=Me(It(s,e));return bt(s,t,r),!0}function xr(s,e,t){const r=re(e),{parent:n,key:i}=se(s,r),o=Ge(n,i);if(o===void 0)throw new Error(`MOVE failed: 'from' location '${e}' does not exist.`);return Nt(s,e)?(bt(s,t,o),!0):!1}function $r(s,e,t){const r=It(s,e);let n=t;if(r instanceof d)if((t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||O(t))&&(r.isInlineValue()||r.getValue()!==void 0)){if(!z(r.getValue()??null,t))throw new Error(`TEST failed at '${e}': Expected ${JSON.stringify(t)}, got ${JSON.stringify(r.getValue()??null)}`);return!0}else typeof t=="object"&&!(t instanceof d)&&(n=v(t));else if(O(r)&&typeof t=="number")r instanceof T?n=new T(t.toString()):r instanceof w&&(n=new w(t.toString()));else if((r===null||typeof r=="string"||typeof r=="number"||typeof r=="boolean")&&O(t)){const i=t;!z(r,i.toString())&&(typeof r=="number"&&parseFloat(i.toString()))}if(!z(r,n)){const i=r instanceof d?r.toString():JSON.stringify(r),o=n instanceof d?n.toString():JSON.stringify(n);throw new Error(`TEST failed at '${e}': Expected ${o}, got ${i}`)}return!0}function Lr(s,e){switch(e.op){case"add":return Mr(s,e.path,e.val);case"replace":return Rr(s,e.path,e.val);case"remove":return Nt(s,e.path);case"copy":return jr(s,e.from,e.path);case"move":return xr(s,e.from,e.path);case"test":return $r(s,e.path,e.val)}}function zr(s,e,t=!1){const r=t?s:s.clone();return Lr(r,e),r}const Se=Symbol.for("zod-schema-annotations");function Ur(){if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global;if(typeof window<"u")return window;if(typeof self<"u")return self;throw new Error("Unable to locate global object")}function Tt(){const s=Ur();return Se in s||(s[Se]=new WeakMap),s[Se]}function ne(s,e){const t=Tt(),r=t.get(s)||{};return t.set(s,{...r,...e}),s}const C=s=>Tt().get(s),Bt=s=>e=>{const t=C(e);return ne(e,{...t,blueDescription:s})},vt=s=>{const e=C(s);return c.isNonNullable(e)&&A.isString(e.blueDescription)?e.blueDescription:null},_r=s=>Bt(s)(u.z.string().optional()),Zr=u.z.union([u.z.string(),u.z.boolean()]),wt=s=>e=>{const t=C(e);return ne(e,{...t,blueId:s})},Et=s=>{const e=C(s),t=Zr.safeParse(e==null?void 0:e.blueId);return t.success?t.data:null},kr=s=>wt(s??!0)(u.z.string()),Pt=s=>e=>{const t=C(e);return ne(e,{...t,blueName:s})},St=s=>{const e=C(s);return c.isNonNullable(e)&&A.isString(e.blueName)?e.blueName:null},Yr=s=>{const e=u.z.string().optional();return Pt(s)(e)},At=()=>s=>{const e=C(s);return ne(s,{...e,blueNode:!0})},Ct=s=>{const e=C(s);return c.isNonNullable(e)&&c.isNonNullable(e.blueNode)&&e.blueNode===!0?e.blueNode:null},He=s=>!!Ct(s),Jr=()=>{const s=u.z.instanceof(d);return At()(s)},Re="extendedFrom",Vt=({schema:s,baseSchema:e})=>{const t=C(s)||{};return ne(s,{...t,[Re]:e})},Dt=s=>{const e=C(s);return c.isNonNullable(e)&&e[Re]?e[Re]:null},qe=(s,e)=>{const t=Dt(s);return c.isNullable(t)?!1:(t==null?void 0:t._def)===(e==null?void 0:e._def)?!0:qe(t,e)},Kr=s=>new Proxy(s,{get(e,t,r){return t==="extend"?function(...n){const i=e.extend(...n);return Vt({schema:i,baseSchema:e})}:Reflect.get(e,t,r)}}),Gr=u.z.object({value:u.z.array(u.z.string()).optional(),defaultValue:u.z.string().optional()}),Ot=s=>{const e=C(s),t=Gr.passthrough().safeParse(e==null?void 0:e.typeBlueId);return t.success?t.data:null},Wr=s=>e=>{const t=C(e),r=typeof s=="string"?{value:[s]}:s,n=Kr(e);return ne(n,{...t,typeBlueId:{...(t==null?void 0:t.typeBlueId)||{},...r}})};class Ne{static resolveBlueId(e){var i;const t=Ot(e);if(c.isNullable(t))return null;const r=t.defaultValue;if(c.isNonNullable(r))return r;const n=(i=t.value)==null?void 0:i[0];return c.isNonNullable(n)?n:Ne.getRepositoryBlueId(t,e)}static getRepositoryBlueId(e,t){throw new Error("Not implemented")}}class S{static isTypeOf(e,t,r){var o;const n=Ne.resolveBlueId(t),i=(o=e.getType())==null?void 0:o.getBlueId();if(c.isNullable(n)||c.isNullable(i))return!1;if(n===i)return!0;if(r!=null&&r.checkSchemaExtensions&&c.isNonNullable(r.typeSchemaResolver)){const l=r.typeSchemaResolver.resolveSchema(e);return S.checkSchemaExtension(l,t)}return!1}static checkSchemaExtension(e,t){if(!c.isNonNullable(e))return!1;const r=S.unwrapSchema(e),n=S.unwrapSchema(t);return qe(r,n)}static isWrapperType(e){return e instanceof u.ZodOptional||e instanceof u.ZodNullable||e instanceof u.ZodReadonly||e instanceof u.ZodBranded||e instanceof u.ZodEffects||e instanceof u.ZodLazy}static unwrapSchema(e){return He(e)?e:S.isWrapperType(e)?e instanceof u.ZodEffects?S.unwrapSchema(e.innerType()):e instanceof u.ZodLazy?S.unwrapSchema(e.schema):S.unwrapSchema(e.unwrap()):e}}class Ft{constructor(e){h(this,"blueIdMap",new Map);this.registerSchemas(e)}registerSchemas(e){for(const t of e)this.registerSchema(t)}registerSchema(e){const t=Ne.resolveBlueId(e);if(c.isNonNullable(t)){if(this.blueIdMap.has(t))throw new Error(`Duplicate BlueId value: ${t}`);this.blueIdMap.set(t,e)}}resolveSchema(e){const t=this.getEffectiveBlueId(e);return c.isNullable(t)?null:this.blueIdMap.get(t)}getEffectiveBlueId(e){const t=e.getType();return c.isNonNullable(t)&&c.isNonNullable(t.getBlueId())?t.getBlueId():c.isNonNullable(t)?N.calculateBlueIdSync(t):null}getBlueIdMap(){return new Map(this.blueIdMap)}}const B={NAME:"name",DESCRIPTION:"description",TYPE:"type",BLUE_ID:"blue_id",KEY_TYPE:"key_type",VALUE_TYPE:"value_type",ITEM_TYPE:"item_type",VALUE:"value",PROPERTIES:"properties",BLUE:"blue",ITEMS:"items"};class Te{static isEmptyNode(e){return this.hasFieldsAndMayHaveFields(e)}static hasBlueIdOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([B.BLUE_ID]))}static hasItemsOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([B.ITEMS]))}static isValidValueNode(e){const t=e.getValue(),r=e.getProperties(),n=e.getItems();return c.isNonNullable(t)&&c.isNullable(r)&&c.isNullable(n)}static textNode(e){return new d().setType(new d().setBlueId(k)).setValue(e)}static integerNode(e){const t=e instanceof T?e:new T(e.toString());return new d().setType(new d().setBlueId(J)).setValue(t)}static doubleNode(e){const t=e instanceof w?e:new w(e.toString());return new d().setType(new d().setBlueId(Y)).setValue(t)}static booleanNode(e){return new d().setType(new d().setBlueId(K)).setValue(e)}static hasFieldsAndMayHaveFields(e,t=new Set,r=new Set){for(const n of Object.values(B)){const i=c.isNonNullable(this.getFieldValue(e,n));if(t.has(n)){if(!i)return!1}else if(!r.has(n)){if(i)return!1}}return!0}static getFieldValue(e,t){switch(t){case B.NAME:return e.getName();case B.TYPE:return e.getType();case B.VALUE:return e.getValue();case B.DESCRIPTION:return e.getDescription();case B.PROPERTIES:return e.getProperties();case B.BLUE:return e.getBlue();case B.ITEMS:return e.getItems();case B.KEY_TYPE:return e.getKeyType();case B.VALUE_TYPE:return e.getValueType();case B.ITEM_TYPE:return e.getItemType();case B.BLUE_ID:return e.getBlueId();default:throw new Error(`Unknown field: ${t}`)}}}class Be{}function nt(s,e){const t=s.split(e),r=[...t].reverse().findIndex(i=>i!==""),n=r===-1?0:t.length-r;return t.slice(0,n)}class Xe extends Be{constructor(t,r){super();h(this,"allowedPaths");h(this,"maxDepth");h(this,"currentPath",[]);this.allowedPaths=t,this.maxDepth=r}shouldExtendPathSegment(t){if(this.currentPath.length>=this.maxDepth)return!1;const r=this.normalizePath(this.getCurrentFullPath()+"/"+t);return this.isAllowedPath(r)}shouldMergePathSegment(t){return this.shouldExtendPathSegment(t)}isAllowedPath(t){for(const r of this.allowedPaths)if(this.matchesAllowedPath(r,t))return!0;return!1}matchesAllowedPath(t,r){const n=nt(t,"/"),i=nt(r,"/");if(i.length>n.length)return!1;for(let o=1;o<i.length;o++)if(n[o]!=="*"&&n[o]!==i[o])return!1;return!0}enterPathSegment(t){this.currentPath.push(t)}exitPathSegment(){this.currentPath.length>0&&this.currentPath.pop()}getCurrentFullPath(){return"/"+this.currentPath.join("/")}normalizePath(t){return"/"+t.split("/").filter(r=>r!=="").join("/")}static withMaxDepth(t){const r=new it().setMaxDepth(t);for(let n=1;n<=t;n++){const i="/"+Array(n).fill("*").join("/");r.addPath(i)}return r.build()}static withSinglePath(t){return new it().addPath(t).build()}}class it{constructor(){h(this,"allowedPaths",new Set);h(this,"maxDepth",Number.MAX_SAFE_INTEGER)}addPath(e){return this.allowedPaths.add(e),this}setMaxDepth(e){return this.maxDepth=e,this}build(){return new Xe(this.allowedPaths,this.maxDepth)}}class Hr extends Be{shouldExtendPathSegment(){return!0}shouldMergePathSegment(){return!0}enterPathSegment(){}exitPathSegment(){}}class Qe extends Be{constructor(t){super();h(this,"limits");this.limits=t}shouldExtendPathSegment(t,r){return this.limits.every(n=>n.shouldExtendPathSegment(t,r))}shouldMergePathSegment(t,r){return this.limits.every(n=>n.shouldMergePathSegment(t,r))}enterPathSegment(t,r){this.limits.forEach(n=>{n.enterPathSegment(t,r)})}exitPathSegment(){this.limits.forEach(t=>{t.exitPathSegment()})}static of(...t){return new Qe(t)}}const H=new Hr;function Ae(s,e){const t=s.getType();if(t===void 0)return;const r=t.getBlueId();if(r!==void 0){if(ue.includes(r)){const i=pr[r];return new d().setBlueId(r).setName(i)}const n=e.fetchByBlueId(r);if(!n||n.length===0)return;if(n.length>1)throw new Error(`Expected a single node for type with blueId '${r}', but found multiple.`);return n[0]}return t}function E(s,e,t){const r=N.calculateBlueIdSync(s),n=N.calculateBlueIdSync(e);if(r===n)return!0;if(r&&ue.includes(r)){let o=e;for(;o!==void 0;){if(N.calculateBlueIdSync(o)===r)return!0;o=Ae(o,t)}return!1}let i=Ae(s,t);for(;i!==void 0;){if(N.calculateBlueIdSync(i)===n)return!0;i=Ae(i,t)}return!1}function qr(s,e){return ut.some(t=>{const r=new d().setBlueId(t);return E(s,r,e)})}function Xr(s,e){const t=new d().setBlueId(k);return E(s,t,e)}function Qr(s,e){const t=new d().setBlueId(J);return E(s,t,e)}function es(s,e){const t=new d().setBlueId(Y);return E(s,t,e)}function ts(s,e){const t=new d().setBlueId(K);return E(s,t,e)}function rs(s){return(s==null?void 0:s.getBlueId())===at}function ss(s){return(s==null?void 0:s.getBlueId())===ct}function ns(s,e){return Ye.some(t=>{const r=new d().setName(t);return E(s,r,e)})}function is(s,e){for(const t of Ye){const r=new d().setName(t);if(E(s,r,e))return t}throw new Error(`Cannot determine the basic type for node of type "${s.getName()||"unknown"}".`)}const os=s=>s instanceof u.ZodOptional||s instanceof u.ZodNullable||s instanceof u.ZodReadonly||s instanceof u.ZodBranded||s instanceof u.ZodEffects||s instanceof u.ZodLazy,ls=s=>s instanceof u.ZodString||s instanceof u.ZodNumber||s instanceof u.ZodBoolean||s instanceof u.ZodBigInt;class Mt{static convertValue(e,t){var i;const r=(i=e.getType())==null?void 0:i.getBlueId(),n=e.getValue();return c.isNullable(n)?ls(t)&&Te.isValidValueNode(e)?this.getDefaultPrimitiveValue(t):n:k===r?this.convertFromString(String(n),t):Y===r||n instanceof w?this.convertFromBigDecimal(new w(n==null?void 0:n.toString()),t):J===r||n instanceof T?this.convertFromBigInteger(new T(n==null?void 0:n.toString()),t):K===r||typeof n=="boolean"?this.convertFromBoolean(!!n,t):this.convertFromString(String(n),t)}static convertFromString(e,t){if(!t||t instanceof u.ZodString||t instanceof u.ZodEnum||t instanceof u.ZodNativeEnum)return e;if(t instanceof u.ZodNumber)return Number(e);if(t instanceof u.ZodBoolean)return e.toLowerCase()==="true";if(t instanceof u.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert String to ${t._def.typeName}`)}static convertFromBigDecimal(e,t){if(t instanceof u.ZodNumber)return e.toNumber();if(t instanceof u.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBigInteger(e,t){if(t instanceof u.ZodNumber)return e.toNumber();if(t instanceof u.ZodBigInt)return BigInt(e.toString());if(t instanceof u.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBoolean(e,t){if(!t||t instanceof u.ZodBoolean)return e;if(t instanceof u.ZodString)return e.toString();if(t instanceof u.ZodNumber)return Number(e);if(t instanceof u.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert Boolean to ${t._def.typeName}`)}static getDefaultPrimitiveValue(e){if(!e)return null;if(e instanceof u.ZodNumber)return 0;if(e instanceof u.ZodBoolean)return!1;if(e instanceof u.ZodString)return"";throw new Error(`Unsupported primitive type: ${e._def.typeName}`)}}class as{convert(e,t){return Mt.convertValue(e,t)}}class cs{constructor(e){this.nodeToObjectConverter=e}convert(e,t){return this.convertFields(e,t)}convertFields(e,t){if(t instanceof u.ZodIntersection){const r=t._def.left,n=t._def.right,i=this.convert(e,r),o=this.convert(e,n);return{...i,...o}}if(t instanceof u.ZodUnion)throw new Error("Union not supported");if(t instanceof u.ZodObject)return Object.keys(t.shape).reduce((n,i)=>{const o=e.getProperties(),l=t.shape[i],a=Et(l);if(c.isNonNullable(a)){const b=A.isString(a)?a:i,L=o==null?void 0:o[b],G=L?N.calculateBlueIdSync(L):void 0;return n[i]=G,n}const p=St(l);if(c.isNonNullable(p)){const b=o==null?void 0:o[p];return n[i]=b==null?void 0:b.getName(),n}const I=vt(l);if(c.isNonNullable(I)){const b=o==null?void 0:o[I];return n[i]=b==null?void 0:b.getDescription(),n}if(i==="name"){const b=e.getName();return n[i]=b,n}if(i==="description"){const b=e.getDescription();return n[i]=b,n}const y=o==null?void 0:o[i];if(c.isNullable(y))return n;const m=this.nodeToObjectConverter.convert(y,l);return n[i]=m,n},{});throw new Error("Unknown schema type, "+t._def.typeName)}}class us{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=e.getItems();if(!r)return;const n=t.element;return r.map(o=>this.nodeToObjectConverter.convert(o,n))}}class ds{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=e.getItems();if(!r)return;const n=t._def.valueType,i=r.map(o=>this.nodeToObjectConverter.convert(o,n));return new Set(i)}}class hs{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=t.keySchema,n=t.valueSchema,i=new Map,o=e.getName();c.isNonNullable(o)&&i.set(q,o);const l=e.getDescription();c.isNonNullable(l)&&i.set(X,l);const a=e.getProperties();return c.isNonNullable(a)&&Object.entries(a).forEach(([p,I])=>{const y=new d().setValue(p);y.setType(new d().setBlueId(k));const m=Mt.convertValue(y,r),b=this.nodeToObjectConverter.convert(I,n);i.set(m,b)}),t instanceof u.ZodRecord?Object.fromEntries(i):i}}class ps{convert(e){return g.get(e)}}class fs{convert(e){return g.get(e)}}class gs{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=e.getItems();if(!r)return;const n=t.items;return r.map((o,l)=>this.nodeToObjectConverter.convert(o,n[l]))}}const ys=u.z.union([u.z.literal("ZodString"),u.z.literal("ZodNumber"),u.z.literal("ZodBoolean"),u.z.literal("ZodBigInt"),u.z.literal("ZodArray"),u.z.literal("ZodSet"),u.z.literal("ZodMap"),u.z.literal("ZodRecord"),u.z.literal("ZodObject"),u.z.literal("ZodEnum"),u.z.literal("ZodNativeEnum"),u.z.literal("ZodUnknown"),u.z.literal("ZodAny"),u.z.literal("ZodTuple")]);class ms{constructor(e){h(this,"converters",new Map);h(this,"complexObjectConverter");this.nodeToObjectConverter=e,this.registerConverters(),this.complexObjectConverter=new cs(this.nodeToObjectConverter)}registerConverters(){const e=new as,t=new us(this.nodeToObjectConverter),r=new gs(this.nodeToObjectConverter),n=new ds(this.nodeToObjectConverter),i=new hs(this.nodeToObjectConverter);this.converters.set("ZodString",e),this.converters.set("ZodNumber",e),this.converters.set("ZodBoolean",e),this.converters.set("ZodBigInt",e),this.converters.set("ZodEnum",e),this.converters.set("ZodNativeEnum",e),this.converters.set("ZodUnknown",new ps),this.converters.set("ZodAny",new fs),this.converters.set("ZodArray",t),this.converters.set("ZodTuple",r),this.converters.set("ZodSet",n),this.converters.set("ZodMap",i),this.converters.set("ZodRecord",i),this.converters.set("ZodObject",this.complexObjectConverter)}getConverter(e){const t=this.getSchemaTypeName(e);return this.converters.get(t)??this.complexObjectConverter}getSchemaTypeName(e){if(os(e))return e instanceof u.ZodEffects?this.getSchemaTypeName(e.innerType()):e instanceof u.ZodLazy?this.getSchemaTypeName(e.schema):this.getSchemaTypeName(e.unwrap());const t=e._def.typeName;try{return ys.parse(t)}catch{throw new Error(`Schema type name ${t} is not supported`)}}}class Is{constructor(e){h(this,"converterFactory");this.typeSchemaResolver=e,this.converterFactory=new ms(this)}convert(e,t){var o;const r=(o=this.typeSchemaResolver)==null?void 0:o.resolveSchema(e),n=S.unwrapSchema(t);if(He(n))return e;let i=n;return S.checkSchemaExtension(r,n)&&c.isNonNullable(r)&&(i=r),this.convertWithType(e,i)}convertWithType(e,t){return this.converterFactory.getConverter(t).convert(e,t)}}class he{fetchFirstByBlueId(e){const t=this.fetchByBlueId(e);return t&&t.length>0?t[0]:null}}function bs(s){return new class extends he{fetchByBlueId(e){return s(e)}}}class Ns extends he{constructor(t){super();h(this,"nodeProviders");this.nodeProviders=t}fetchByBlueId(t){for(const r of this.nodeProviders){const n=r.fetchByBlueId(t);if(n&&n.length>0)return n}return[]}fetchFirstByBlueId(t){for(const r of this.nodeProviders){const n=r.fetchFirstByBlueId(t);if(n)return n}return null}getNodeProviders(){return this.nodeProviders}}const Ce=Z.types.float.options,Ts={...Ce,construct:s=>{const e=s.replace(/_/g,"").toLowerCase();if(!c.isPreciseNumberString(e))return new w(e);if(Ce.construct)return Ce.construct(s)}},Bs=new Z.Type("tag:yaml.org,2002:float",Ts),Ve=Z.types.int.options,vs={...Ve,construct:s=>{let e=s;if(e.indexOf("_")!==-1&&(e=e.replace(/_/g,"")),!c.isPreciseNumberString(e))return new T(e);if(Ve.construct)return Ve.construct(s)}},ws=new Z.Type("tag:yaml.org,2002:int",vs),Rt=Z.CORE_SCHEMA.extend({implicit:[Bs,ws]}),F=s=>{const e=Z.load(s,{schema:Rt});return e===void 0?void 0:e},Es=s=>Z.dump(s,{schema:Rt,replacer:(e,t)=>{if(D(t)){if(x(t)){const r=new j(Number.MIN_SAFE_INTEGER.toString()),n=new j(Number.MAX_SAFE_INTEGER.toString());if(t.lt(r)||t.gt(n))return t.toString()}return t.toNumber()}return t}}),jt=`- type:
2
2
  blueId: 27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo
3
3
  mappings:
4
4
  Text: F92yo19rCcbBoBSpUA5LRxpfDejJDAaP1PRxxbWAraVP
@@ -9,19 +9,19 @@
9
9
  Dictionary: 294NBTj2mFRL3RB4kDRUSckwGg7Kzj6T8CTAFeR1kcSA
10
10
  - type:
11
11
  blueId: FGYuTXwaoSKfZmpTysLTLsb8WzSqf43384rKZDkXhxD4
12
- `,Es=`name: Transformation
13
- description: TODO`,Ps=`name: Infer Basic Types For Untyped Values
12
+ `,Ps=`name: Transformation
13
+ description: TODO`,Ss=`name: Infer Basic Types For Untyped Values
14
14
  type:
15
15
  blueId: Ct1SGRGw1i47qjzm1ruiUdSZofeV6WevPTGuieVvbRS4
16
- description: This transformation infers type details for Text, Integer, Number and Boolean.`,Ss=`name: Replace Inline Types with BlueIds
16
+ description: This transformation infers type details for Text, Integer, Number and Boolean.`,As=`name: Replace Inline Types with BlueIds
17
17
  type:
18
18
  blueId: Ct1SGRGw1i47qjzm1ruiUdSZofeV6WevPTGuieVvbRS4
19
- description: This transformation replaces`,As=[jt,Es,Ps,Ss];class Cs extends he{constructor(){super();h(this,"blueIdToNodesMap",new Map);this.load()}fetchByBlueId(t){return this.blueIdToNodesMap.get(t)||[]}load(){for(const t of As){const r=F(t);if(r===void 0){console.error(`This content file is not valid YAML: ${t}`);continue}if(Array.isArray(r)){const n=r.map(o=>f.deserialize(o)),i=N.calculateBlueIdSync(n);this.blueIdToNodesMap.set(i,n)}else{const n=f.deserialize(r),i=N.calculateBlueIdSync(n);this.blueIdToNodesMap.set(i,[n])}}}}const me=class me extends he{constructor(){super();h(this,"nodeProvider");this.nodeProvider=new Cs}fetchByBlueId(t){return this.nodeProvider.fetchByBlueId(t)}};h(me,"INSTANCE",new me);let je=me;class De{constructor(e,t,r){this.blueId=e,this.content=t,this.isMultipleDocuments=r}}class R{static parseAndCalculateBlueId(e,t){let r;try{const l=F(e);if(l===void 0)throw new Error;r=l}catch{throw new Error("Failed to parse content as YAML or JSON")}let n,i;const o=Array.isArray(r)&&r.length>1;if(o){const l=r.map(a=>{const p=f.deserialize(a);return t(p)});n=N.calculateBlueIdSync(l),i=l.map(a=>g.get(a))}else{const l=f.deserialize(r),a=t(l);n=N.calculateBlueIdSync(a),i=g.get(a)}return new De(n,i,o)}static parseAndCalculateBlueIdForNode(e,t){const r=t(e),n=N.calculateBlueIdSync(r),i=g.get(r);return new De(n,i,!1)}static parseAndCalculateBlueIdForNodeList(e,t){if(!e||e.length===0)throw new Error("List of nodes cannot be null or empty");const r=e.map(t),n=N.calculateBlueIdSync(r),i=r.map(l=>g.get(l)),o=e.length>1;return new De(n,i,o)}static resolveThisReferences(e,t,r){return this.resolveThisReferencesRecursive(e,t,r)}static resolveThisReferencesRecursive(e,t,r){if(e&&typeof e=="object"&&!Array.isArray(e)){const n={};for(const[i,o]of Object.entries(e))typeof o=="string"?this.THIS_REFERENCE_PATTERN.test(o)?n[i]=this.resolveThisReference(o,t,r):n[i]=o:o&&typeof o=="object"?n[i]=this.resolveThisReferencesRecursive(o,t,r):n[i]=o;return n}else if(Array.isArray(e))return e.map(n=>typeof n=="string"?this.THIS_REFERENCE_PATTERN.test(n)?this.resolveThisReference(n,t,r):n:n&&typeof n=="object"?this.resolveThisReferencesRecursive(n,t,r):n);return e}static resolveThisReference(e,t,r){if(r){if(!e.startsWith("this#"))throw new Error("For multiple documents, 'this' references must include an index (e.g., 'this#0')");return t+e.substring(4)}else{if(e==="this")return t;throw new Error("For a single document, only 'this' is allowed as a reference, not 'this#<id>'")}}}h(R,"THIS_REFERENCE_PATTERN",/^this(#\d+)?$/);class Vs extends he{fetchByBlueId(e){const t=e.split("#")[0],r=this.fetchContentByBlueId(t);if(r==null)return null;const n=Array.isArray(r)&&r.length>1,i=R.resolveThisReferences(r,t,n);if(e.includes("#")){const o=e.split("#");if(o.length>1){const l=parseInt(o[1]);if(Array.isArray(i)&&l<i.length){const a=i[l],p=f.deserialize(a);return p.setBlueId(e),[p]}else if(l===0){const a=f.deserialize(i);return a.setBlueId(e),[a]}else return null}}if(Array.isArray(i))return i.map(o=>f.deserialize(o));{const o=f.deserialize(i);return o.setBlueId(t),[o]}}}class xt extends Vs{constructor(){super(...arguments);h(this,"nameToBlueIdsMap",new Map)}findNodeByName(t){const r=this.nameToBlueIdsMap.get(t);if(!r)return;if(r.length>1)throw new Error(`Multiple nodes found with name: ${t}`);const n=this.fetchByBlueId(r[0]);return n&&n.length>0?n[0]:void 0}findAllNodesByName(t){const r=this.nameToBlueIdsMap.get(t);if(!r)return[];const n=[];for(const i of r){const o=this.fetchByBlueId(i);o&&n.push(...o)}return n}addToNameMap(t,r){this.nameToBlueIdsMap.set(t,[...this.nameToBlueIdsMap.get(t)||[],r])}}const $t=s=>s instanceof d||Array.isArray(s)&&s.every(e=>e instanceof d)?s:A.isArray(s)?s.map(e=>f.deserialize(e)):f.deserialize(s),Lt=async s=>{const e=$t(s);return N.calculateBlueId(e)},Ds=s=>{const e=$t(s);return N.calculateBlueIdSync(e)},xe=async s=>{if(dt(s))return s;try{const e=ae.parse(s),t=await Lt(e);return{...s,blueId:t}}catch(e){throw new Error(`Failed enriching object with Blue ID: ${e}`)}},Os=s=>s==null?void 0:s.items,Fs=s=>s==null?void 0:s.value,Ms=s=>c.isNullable(s)?{}:A.omit(s,ir),Rs=s=>pt(s)?s.type.name??null:ft(s)?A.pascal(typeof s.value):ht(s)?"List":null,zt=s=>c.isNonNullable(s)&&Object.keys(A.omit(s,["blueId"])).length>0,js=s=>{try{const e=f.deserialize(s),t=g.get(e);return Q.parse(t)}catch(e){throw new Error(`Failed transforming JSON-like value to BlueObject: ${e}`)}},$e=async s=>{const{resolveFunction:e,signal:t=new AbortController().signal,omitItems:r}=s,n=s.count??s.items.length;let i=await A.map(s.items,async l=>await xe(l));const o=Math.max((i==null?void 0:i.length)-n,0);for(let l=i.length-1;l>=o;l--)if(!zt(i[l])){const a=await e(i[l],{signal:t});if(Array.isArray(a))return $e({...s,items:[...i.slice(0,l),...a,...i.slice(l+1)]});const p=await xe(a);if(r!=null&&r.includes(p.blueId))return $e({...s,items:[...i.slice(0,l),...i.slice(l+1)]});i=[...i.slice(0,l),p,...i.slice(l+1)]}return i};function ie(s){try{const e=new URL(s);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}class xs{process(e){return V.transform(e,this.inferType.bind(this))}inferType(e){const t=e.getType(),r=e.getValue();return c.isNullable(t)&&c.isNonNullable(r)&&(typeof r=="string"?e.setType(new d().setBlueId(k)):typeof r=="bigint"||x(r)?e.setType(new d().setBlueId(J)):fe(r)?e.setType(new d().setBlueId(Y)):typeof r=="boolean"&&e.setType(new d().setBlueId(K))),e}}const oe=class oe{constructor(e){h(this,"mappings",new Map);if(e instanceof d){const r=e.getProperties();if(r&&r[oe.MAPPINGS]){const i=r[oe.MAPPINGS].getProperties();i&&Object.entries(i).forEach(([o,l])=>{const a=l.getValue();typeof a=="string"&&this.mappings.set(o,a)})}}else this.mappings=e}process(e){return V.transform(e,this.transformNode.bind(this))}transformNode(e){const t=e.clone();return this.transformTypeField(t,t.getType()),this.transformTypeField(t,t.getItemType()),this.transformTypeField(t,t.getKeyType()),this.transformTypeField(t,t.getValueType()),t}transformTypeField(e,t){if(t&&t.isInlineValue()&&t.getValue()!==void 0){const r=String(t.getValue());if(this.mappings.has(r)){const n=this.mappings.get(r);if(n){const i=new d().setBlueId(n);t===e.getType()?e.setType(i):t===e.getItemType()?e.setItemType(i):t===e.getKeyType()?e.setKeyType(i):t===e.getValueType()&&e.setValueType(i)}}}}};h(oe,"MAPPINGS","mappings");let Le=oe;class $s{process(e){return V.transform(e,this.validateNode.bind(this)),e}validateNode(e){return this.validateTypeField(e,e.getType(),"type"),this.validateTypeField(e,e.getItemType(),"itemType"),this.validateTypeField(e,e.getKeyType(),"keyType"),this.validateTypeField(e,e.getValueType(),"valueType"),e}validateTypeField(e,t,r){if(t&&t.isInlineValue()&&t.getValue()!==void 0){const n=String(t.getValue());throw new Error(`Unknown type "${n}" found in ${r} field. No BlueId mapping exists for this type.`)}}}class et{constructor(e,t){h(this,"nodeProvider");h(this,"strategy");this.nodeProvider=ce.wrap(e),this.strategy=t||"THROW_EXCEPTION"}extend(e,t){this.extendNode(e,t,"")}extendNode(e,t,r,n=!1){if(!n){if(!t.shouldExtendPathSegment(r,e))return;t.enterPathSegment(r,e)}try{const i=e.getBlueId();if(i&&!ue.includes(i)){const m=this.fetchNode(e);if(m&&m.length>0)if(m.length===1){const b=m[0];this.mergeNodes(e,b)}else{const b=m.map(G=>G.clone()),L=new d().setItems(b);this.mergeNodes(e,L)}}const o=e.getType();o&&this.extendNode(o,t,"type",!0);const l=e.getItemType();l&&this.extendNode(l,t,"itemType",!0);const a=e.getKeyType();a&&this.extendNode(a,t,"keyType",!0);const p=e.getValueType();p&&this.extendNode(p,t,"valueType",!0);const I=e.getProperties();I&&Object.entries(I).forEach(([m,b])=>{this.extendNode(b,t,m,!1)});const y=e.getItems();if(y&&y.length>0){this.reconstructList(y);for(let m=0;m<y.length;m++)this.extendNode(y[m],t,String(m),!1)}}finally{n||t.exitPathSegment()}}reconstructList(e){for(;e.length>0;){const t=e[0],r=t==null?void 0:t.getBlueId();if(!r)break;const n=this.nodeProvider.fetchByBlueId(r);if(!n||n.length===1)break;e.shift(),e.unshift(...n)}}fetchNode(e){const t=e.getBlueId();if(!t){if(this.strategy==="RETURN_EMPTY")return null;throw new Error(`No blueId found for node: ${e.getName()}`)}const r=this.nodeProvider.fetchByBlueId(t);if(!r||r.length===0){if(this.strategy==="RETURN_EMPTY")return null;throw new Error(`No content found for blueId: ${e.getBlueId()}`)}return r}mergeNodes(e,t){e.setName(t.getName()),e.setDescription(t.getDescription()),e.setType(t.getType()),e.setItemType(t.getItemType()),e.setKeyType(t.getKeyType()),e.setValueType(t.getValueType());const r=t.getValue();c.isNonNullable(r)&&e.setValue(r),e.setItems(t.getItems()),e.setProperties(t.getProperties())}}class Ut{constructor(){h(this,"blueIdsCollections",[])}initialize(...e){this.blueIdsCollections=[...e]}registerBlueIds(...e){this.blueIdsCollections.push(...e)}generateMappingsYaml(e="27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo"){const t={};for(const n of this.blueIdsCollections)Object.assign(t,n);const r=Object.entries(t).map(([n,i])=>` ${n}: ${i}`).join(`
19
+ description: This transformation replaces`,Cs=[jt,Ps,Ss,As];class Vs extends he{constructor(){super();h(this,"blueIdToNodesMap",new Map);this.load()}fetchByBlueId(t){return this.blueIdToNodesMap.get(t)||[]}load(){for(const t of Cs){const r=F(t);if(r===void 0){console.error(`This content file is not valid YAML: ${t}`);continue}if(Array.isArray(r)){const n=r.map(o=>f.deserialize(o)),i=N.calculateBlueIdSync(n);this.blueIdToNodesMap.set(i,n)}else{const n=f.deserialize(r),i=N.calculateBlueIdSync(n);this.blueIdToNodesMap.set(i,[n])}}}}const me=class me extends he{constructor(){super();h(this,"nodeProvider");this.nodeProvider=new Vs}fetchByBlueId(t){return this.nodeProvider.fetchByBlueId(t)}};h(me,"INSTANCE",new me);let je=me;class De{constructor(e,t,r){this.blueId=e,this.content=t,this.isMultipleDocuments=r}}class R{static parseAndCalculateBlueId(e,t){let r;try{const l=F(e);if(l===void 0)throw new Error;r=l}catch{throw new Error("Failed to parse content as YAML or JSON")}let n,i;const o=Array.isArray(r)&&r.length>1;if(o){const l=r.map(a=>{const p=f.deserialize(a);return t(p)});n=N.calculateBlueIdSync(l),i=l.map(a=>g.get(a))}else{const l=f.deserialize(r),a=t(l);n=N.calculateBlueIdSync(a),i=g.get(a)}return new De(n,i,o)}static parseAndCalculateBlueIdForNode(e,t){const r=t(e),n=N.calculateBlueIdSync(r),i=g.get(r);return new De(n,i,!1)}static parseAndCalculateBlueIdForNodeList(e,t){if(!e||e.length===0)throw new Error("List of nodes cannot be null or empty");const r=e.map(t),n=N.calculateBlueIdSync(r),i=r.map(l=>g.get(l)),o=e.length>1;return new De(n,i,o)}static resolveThisReferences(e,t,r){return this.resolveThisReferencesRecursive(e,t,r)}static resolveThisReferencesRecursive(e,t,r){if(e&&typeof e=="object"&&!Array.isArray(e)){const n={};for(const[i,o]of Object.entries(e))typeof o=="string"?this.THIS_REFERENCE_PATTERN.test(o)?n[i]=this.resolveThisReference(o,t,r):n[i]=o:o&&typeof o=="object"?n[i]=this.resolveThisReferencesRecursive(o,t,r):n[i]=o;return n}else if(Array.isArray(e))return e.map(n=>typeof n=="string"?this.THIS_REFERENCE_PATTERN.test(n)?this.resolveThisReference(n,t,r):n:n&&typeof n=="object"?this.resolveThisReferencesRecursive(n,t,r):n);return e}static resolveThisReference(e,t,r){if(r){if(!e.startsWith("this#"))throw new Error("For multiple documents, 'this' references must include an index (e.g., 'this#0')");return t+e.substring(4)}else{if(e==="this")return t;throw new Error("For a single document, only 'this' is allowed as a reference, not 'this#<id>'")}}}h(R,"THIS_REFERENCE_PATTERN",/^this(#\d+)?$/);class Ds extends he{fetchByBlueId(e){const t=e.split("#")[0],r=this.fetchContentByBlueId(t);if(r==null)return null;const n=Array.isArray(r)&&r.length>1,i=R.resolveThisReferences(r,t,n);if(e.includes("#")){const o=e.split("#");if(o.length>1){const l=parseInt(o[1]);if(Array.isArray(i)&&l<i.length){const a=i[l],p=f.deserialize(a);return p.setBlueId(e),[p]}else if(l===0){const a=f.deserialize(i);return a.setBlueId(e),[a]}else return null}}if(Array.isArray(i))return i.map(o=>f.deserialize(o));{const o=f.deserialize(i);return o.setBlueId(t),[o]}}}class xt extends Ds{constructor(){super(...arguments);h(this,"nameToBlueIdsMap",new Map)}findNodeByName(t){const r=this.nameToBlueIdsMap.get(t);if(!r)return;if(r.length>1)throw new Error(`Multiple nodes found with name: ${t}`);const n=this.fetchByBlueId(r[0]);return n&&n.length>0?n[0]:void 0}findAllNodesByName(t){const r=this.nameToBlueIdsMap.get(t);if(!r)return[];const n=[];for(const i of r){const o=this.fetchByBlueId(i);o&&n.push(...o)}return n}addToNameMap(t,r){this.nameToBlueIdsMap.set(t,[...this.nameToBlueIdsMap.get(t)||[],r])}}const $t=s=>s instanceof d||Array.isArray(s)&&s.every(e=>e instanceof d)?s:A.isArray(s)?s.map(e=>f.deserialize(e)):f.deserialize(s),Lt=async s=>{const e=$t(s);return N.calculateBlueId(e)},Os=s=>{const e=$t(s);return N.calculateBlueIdSync(e)},xe=async s=>{if(dt(s))return s;try{const e=ae.parse(s),t=await Lt(e);return{...s,blueId:t}}catch(e){throw new Error(`Failed enriching object with Blue ID: ${e}`)}},Fs=s=>s==null?void 0:s.items,Ms=s=>s==null?void 0:s.value,Rs=s=>c.isNullable(s)?{}:A.omit(s,or),js=s=>pt(s)?s.type.name??null:ft(s)?A.pascal(typeof s.value):ht(s)?"List":null,zt=s=>c.isNonNullable(s)&&Object.keys(A.omit(s,["blueId"])).length>0,xs=s=>{try{const e=f.deserialize(s),t=g.get(e);return Q.parse(t)}catch(e){throw new Error(`Failed transforming JSON-like value to BlueObject: ${e}`)}},$e=async s=>{const{resolveFunction:e,signal:t=new AbortController().signal,omitItems:r}=s,n=s.count??s.items.length;let i=await A.map(s.items,async l=>await xe(l));const o=Math.max((i==null?void 0:i.length)-n,0);for(let l=i.length-1;l>=o;l--)if(!zt(i[l])){const a=await e(i[l],{signal:t});if(Array.isArray(a))return $e({...s,items:[...i.slice(0,l),...a,...i.slice(l+1)]});const p=await xe(a);if(r!=null&&r.includes(p.blueId))return $e({...s,items:[...i.slice(0,l),...i.slice(l+1)]});i=[...i.slice(0,l),p,...i.slice(l+1)]}return i};function ie(s){try{const e=new URL(s);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}class $s{process(e){return V.transform(e,this.inferType.bind(this))}inferType(e){const t=e.getType(),r=e.getValue();return c.isNullable(t)&&c.isNonNullable(r)&&(typeof r=="string"?e.setType(new d().setBlueId(k)):typeof r=="bigint"||x(r)?e.setType(new d().setBlueId(J)):fe(r)?e.setType(new d().setBlueId(Y)):typeof r=="boolean"&&e.setType(new d().setBlueId(K))),e}}const oe=class oe{constructor(e){h(this,"mappings",new Map);if(e instanceof d){const r=e.getProperties();if(r&&r[oe.MAPPINGS]){const i=r[oe.MAPPINGS].getProperties();i&&Object.entries(i).forEach(([o,l])=>{const a=l.getValue();typeof a=="string"&&this.mappings.set(o,a)})}}else this.mappings=e}process(e){return V.transform(e,this.transformNode.bind(this))}transformNode(e){const t=e.clone();return this.transformTypeField(t,t.getType()),this.transformTypeField(t,t.getItemType()),this.transformTypeField(t,t.getKeyType()),this.transformTypeField(t,t.getValueType()),t}transformTypeField(e,t){if(t&&t.isInlineValue()&&t.getValue()!==void 0){const r=String(t.getValue());if(this.mappings.has(r)){const n=this.mappings.get(r);if(n){const i=new d().setBlueId(n);t===e.getType()?e.setType(i):t===e.getItemType()?e.setItemType(i):t===e.getKeyType()?e.setKeyType(i):t===e.getValueType()&&e.setValueType(i)}}}}};h(oe,"MAPPINGS","mappings");let Le=oe;class Ls{process(e){return V.transform(e,this.validateNode.bind(this)),e}validateNode(e){return this.validateTypeField(e,e.getType(),"type"),this.validateTypeField(e,e.getItemType(),"itemType"),this.validateTypeField(e,e.getKeyType(),"keyType"),this.validateTypeField(e,e.getValueType(),"valueType"),e}validateTypeField(e,t,r){if(t&&t.isInlineValue()&&t.getValue()!==void 0){const n=String(t.getValue());throw new Error(`Unknown type "${n}" found in ${r} field. No BlueId mapping exists for this type.`)}}}class et{constructor(e,t){h(this,"nodeProvider");h(this,"strategy");this.nodeProvider=ce.wrap(e),this.strategy=t||"THROW_EXCEPTION"}extend(e,t){this.extendNode(e,t,"")}extendNode(e,t,r,n=!1){if(!n){if(!t.shouldExtendPathSegment(r,e))return;t.enterPathSegment(r,e)}try{const i=e.getBlueId();if(i&&!ue.includes(i)){const m=this.fetchNode(e);if(m&&m.length>0)if(m.length===1){const b=m[0];this.mergeNodes(e,b)}else{const b=m.map(G=>G.clone()),L=new d().setItems(b);this.mergeNodes(e,L)}}const o=e.getType();o&&this.extendNode(o,t,"type",!0);const l=e.getItemType();l&&this.extendNode(l,t,"itemType",!0);const a=e.getKeyType();a&&this.extendNode(a,t,"keyType",!0);const p=e.getValueType();p&&this.extendNode(p,t,"valueType",!0);const I=e.getProperties();I&&Object.entries(I).forEach(([m,b])=>{this.extendNode(b,t,m,!1)});const y=e.getItems();if(y&&y.length>0){this.reconstructList(y);for(let m=0;m<y.length;m++)this.extendNode(y[m],t,String(m),!1)}}finally{n||t.exitPathSegment()}}reconstructList(e){for(;e.length>0;){const t=e[0],r=t==null?void 0:t.getBlueId();if(!r)break;const n=this.nodeProvider.fetchByBlueId(r);if(!n||n.length===1)break;e.shift(),e.unshift(...n)}}fetchNode(e){const t=e.getBlueId();if(!t){if(this.strategy==="RETURN_EMPTY")return null;throw new Error(`No blueId found for node: ${e.getName()}`)}const r=this.nodeProvider.fetchByBlueId(t);if(!r||r.length===0){if(this.strategy==="RETURN_EMPTY")return null;throw new Error(`No content found for blueId: ${e.getBlueId()}`)}return r}mergeNodes(e,t){e.setName(t.getName()),e.setDescription(t.getDescription()),e.setType(t.getType()),e.setItemType(t.getItemType()),e.setKeyType(t.getKeyType()),e.setValueType(t.getValueType());const r=t.getValue();c.isNonNullable(r)&&e.setValue(r),e.setItems(t.getItems()),e.setProperties(t.getProperties())}}class Ut{constructor(){h(this,"blueIdsCollections",[])}initialize(...e){this.blueIdsCollections=[...e]}registerBlueIds(...e){this.blueIdsCollections.push(...e)}generateMappingsYaml(e="27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo"){const t={};for(const n of this.blueIdsCollections)Object.assign(t,n);const r=Object.entries(t).map(([n,i])=>` ${n}: ${i}`).join(`
20
20
  `);return`- type:
21
21
  blueId: ${e}
22
22
  mappings:
23
- ${r}`}getAllBlueIds(){const e={};for(const t of this.blueIdsCollections)Object.assign(e,t);return e}getAllBlueIdNames(){return Object.keys(this.getAllBlueIds())}clear(){this.blueIdsCollections=[]}getCollectionCount(){return this.blueIdsCollections.length}getTotalBlueIdCount(){return Object.keys(this.getAllBlueIds()).length}}const Ie=class Ie{constructor(e={}){h(this,"processorProvider");h(this,"nodeProvider");h(this,"defaultSimpleBlue",null);h(this,"blueIdsMappingGenerator");const{nodeProvider:t,processorProvider:r,blueIdsMappingGenerator:n}=e;if(!t)throw new Error("NodeProvider is required");this.nodeProvider=ce.wrap(t),this.processorProvider=r||Ie.getStandardProvider(),this.blueIdsMappingGenerator=n||new Ut,this.loadDefaultSimpleBlue()}preprocess(e){return this.preprocessWithOptions(e,null)}preprocessWithDefaultBlue(e){return this.preprocessWithOptions(e,this.defaultSimpleBlue)}preprocessWithOptions(e,t){let r=e.clone(),n=r.getBlue();if(!n&&t&&(n=t.clone()),n){new et(this.nodeProvider).extend(n,Xe.withSinglePath("/*"));const i=n.getItems();if(i&&i.length>0){for(const o of i){const l=this.processorProvider.getProcessor(o);if(l)r=l.process(r);else throw new Error(`No processor found for transformation: ${o}`)}r.setBlue(void 0)}r=new $s().process(r)}return r}static getStandardProvider(){return{getProcessor(e){var i;const t="27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo",r="FGYuTXwaoSKfZmpTysLTLsb8WzSqf43384rKZDkXhxD4",n=(i=e.getType())==null?void 0:i.getBlueId();if(t===n)return new Le(e);if(r===n)return new xs}}}enrichDefaultBlue(e){const t=this.blueIdsMappingGenerator.generateMappingsYaml();return`
23
+ ${r}`}getAllBlueIds(){const e={};for(const t of this.blueIdsCollections)Object.assign(e,t);return e}getAllBlueIdNames(){return Object.keys(this.getAllBlueIds())}clear(){this.blueIdsCollections=[]}getCollectionCount(){return this.blueIdsCollections.length}getTotalBlueIdCount(){return Object.keys(this.getAllBlueIds()).length}}const Ie=class Ie{constructor(e={}){h(this,"processorProvider");h(this,"nodeProvider");h(this,"defaultSimpleBlue",null);h(this,"blueIdsMappingGenerator");const{nodeProvider:t,processorProvider:r,blueIdsMappingGenerator:n}=e;if(!t)throw new Error("NodeProvider is required");this.nodeProvider=ce.wrap(t),this.processorProvider=r||Ie.getStandardProvider(),this.blueIdsMappingGenerator=n||new Ut,this.loadDefaultSimpleBlue()}preprocess(e){return this.preprocessWithOptions(e,null)}preprocessWithDefaultBlue(e){return this.preprocessWithOptions(e,this.defaultSimpleBlue)}preprocessWithOptions(e,t){let r=e.clone(),n=r.getBlue();if(!n&&t&&(n=t.clone()),n){new et(this.nodeProvider).extend(n,Xe.withSinglePath("/*"));const i=n.getItems();if(i&&i.length>0){for(const o of i){const l=this.processorProvider.getProcessor(o);if(l)r=l.process(r);else throw new Error(`No processor found for transformation: ${o}`)}r.setBlue(void 0)}r=new Ls().process(r)}return r}static getStandardProvider(){return{getProcessor(e){var i;const t="27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo",r="FGYuTXwaoSKfZmpTysLTLsb8WzSqf43384rKZDkXhxD4",n=(i=e.getType())==null?void 0:i.getBlueId();if(t===n)return new Le(e);if(r===n)return new $s}}}enrichDefaultBlue(e){const t=this.blueIdsMappingGenerator.generateMappingsYaml();return`
24
24
  ${e}
25
25
  ${t}
26
- `}loadDefaultSimpleBlue(){const e=this.enrichDefaultBlue(jt);try{const t=F(e);if(t)this.defaultSimpleBlue=f.deserialize(t);else throw new Error("Failed to parse default Blue content")}catch(t){throw new Error(`Error loading default Blue: ${t}`)}}};h(Ie,"DEFAULT_BLUE_BLUE_ID","FREHAAGDZSzpnoTUoCQ86bBmxbVCULMjvx9JZM6fyqT1");let te=Ie;class Ls extends xt{constructor(t){super();h(this,"blueIdToContentMap",new Map);h(this,"blueIdToMultipleDocumentsMap",new Map);h(this,"preprocessor");const r=new te({nodeProvider:this});this.preprocessor=n=>r.preprocessWithDefaultBlue(n),this.loadRepositories(t)}loadRepositories(t){for(const r of t)if(r.contents)for(const[n,i]of Object.entries(r.contents))this.processContent(i,n)}processContent(t,r){Array.isArray(t)?this.processMultipleDocuments(t,r):this.processSingleDocument(t,r)}processSingleDocument(t,r){const n=f.deserialize(t),i=R.parseAndCalculateBlueIdForNode(n,this.preprocessor),o=r||i.blueId;this.blueIdToContentMap.set(o,i.content),this.blueIdToMultipleDocumentsMap.set(o,!1);const l=n.getName();l&&this.addToNameMap(l,o)}processMultipleDocuments(t,r){const n=t.map(l=>{const a=f.deserialize(l);return this.preprocessor(a)}),i=R.parseAndCalculateBlueIdForNodeList(n,l=>l),o=r||i.blueId;this.blueIdToContentMap.set(o,i.content),this.blueIdToMultipleDocumentsMap.set(o,!0),n.forEach((l,a)=>{const p=`${o}#${a}`,I=g.get(l),y=N.calculateBlueIdSync(l);this.blueIdToContentMap.set(y,I),this.blueIdToMultipleDocumentsMap.set(y,!1);const m=l.getName();m&&this.addToNameMap(m,p)})}fetchContentByBlueId(t){const r=this.blueIdToContentMap.get(t),n=this.blueIdToMultipleDocumentsMap.get(t);return r!==void 0&&n!==void 0?R.resolveThisReferences(r,t,n):null}getBlueIds(){return Array.from(this.blueIdToContentMap.keys())}hasBlueId(t){const r=t.split("#")[0];return this.blueIdToContentMap.has(r)}}class ce{static wrap(e,t){const r=[je.INSTANCE];if(t&&t.length>0){const n=new Ls(t);r.push(n)}return r.push(e),new bs(r)}}class zs{constructor(e,t){h(this,"preprocessingAliases",new Map);h(this,"urlContentFetcher");e&&(this.preprocessingAliases=new Map(e)),this.urlContentFetcher=t}process(e){const t=this.getBlueNodeValue(e);if(t){const r=e.clone();if(this.preprocessingAliases.has(t))return this.handleAliasValue(r,t);if(U.isPotentialBlueId(t))return this.handleBlueId(r,t);throw ie(t)?new Error(`URL '${t}' detected. Use the async version of this method to fetch the content.`):new Error(`Invalid blue value: ${t}`)}return e}async processAsync(e){const t=this.getBlueNodeValue(e);if(t){const r=e.clone();if(this.preprocessingAliases.has(t))return this.handleAliasValue(r,t);if(U.isPotentialBlueId(t))return this.handleBlueId(r,t);if(ie(t)&&this.urlContentFetcher)try{const n=await this.fetchFromUrl(t);return n&&r.setBlue(new d().setItems(n)),r}catch(n){throw n instanceof Error?new Error(`Failed to fetch from URL '${t}'.
27
- ${n.message}`):n}else throw ie(t)?new Error(`UrlContentFetcher not provided for URL: ${t}`):new Error(`Invalid blue value: ${t}`)}return e}getBlueNodeValue(e){const t=e.getBlue(),r=t==null?void 0:t.getValue();return r&&typeof r=="string"?r:null}handleAliasValue(e,t){return e.setBlue(new d().setBlueId(this.preprocessingAliases.get(t))),e}handleBlueId(e,t){return e.setBlue(new d().setBlueId(t)),e}async fetchFromUrl(e){if(!this.urlContentFetcher)throw new Error(`UrlContentFetcher not provided for URL: ${e}`);return await this.urlContentFetcher.fetchAndCache(e)}getPreprocessingAliases(){return new Map(this.preprocessingAliases)}setPreprocessingAliases(e){return this.preprocessingAliases=new Map(e),this}addPreprocessingAliases(e){return e.forEach((t,r)=>{this.preprocessingAliases.set(r,t)}),this}setUrlContentFetcher(e){return this.urlContentFetcher=e,this}getUrlContentFetcher(){return this.urlContentFetcher}}const Us={fetchUrl:async s=>{throw new Error(`You must provide a custom UrlFetchStrategy to fetch content from URL: ${s}`)}};class _s{constructor(e){h(this,"cache",new Map);h(this,"fetchStrategy");h(this,"enabled",!1);h(this,"allowedDomains",[]);this.fetchStrategy=e||Us}validateUrl(e){if(!ie(e))throw new Error(`Invalid URL: ${e}`);return!0}isDomainAllowed(e){if(this.allowedDomains.length===0)return!0;try{const t=new URL(e);return this.allowedDomains.some(r=>t.hostname===r||t.hostname.endsWith(`.${r}`))}catch{return!1}}getFromCache(e){try{return this.validateUrl(e),this.cache.get(e)||[]}catch{return[]}}async fetchAndCache(e){if(this.validateUrl(e),!this.enabled)throw new Error("URL fetching is disabled. Enable it using the enableFetching method.");if(!this.isDomainAllowed(e))throw new Error(`Domain not allowed for URL: ${e}.`);let t;try{t=await this.fetchStrategy.fetchUrl(e)}catch(l){throw new Error(`Error fetching from URL: ${e}`,{cause:l})}const{data:r,contentType:n}=t;let i;if(n.includes("application/json")||n.includes("text/yaml")||n.includes("application/yaml")||n.includes("text/plain"))i=F(r);else throw new Error(`Unsupported content type from URL: ${n}`);if(i===void 0)throw new Error(`Failed to parse content from URL: ${e}`);let o;return Array.isArray(i)?o=i.map(l=>f.deserialize(l)):o=[f.deserialize(i)],this.cache.set(e,o),o}prefetchUrl(e,t){try{this.validateUrl(e),this.cache.set(e,t)}catch{}}clearCache(){this.cache.clear()}setFetchStrategy(e){return this.fetchStrategy=e,this}getFetchStrategy(){return this.fetchStrategy}enableFetching(){return this.enabled=!0,this.allowedDomains=[],this}enableFetchingForDomains(e){return this.enabled=!0,this.allowedDomains=[...e],this}disableFetching(){return this.enabled=!1,this}isFetchingEnabled(){return this.enabled}getAllowedDomains(){return[...this.allowedDomains]}allowDomain(e){return this.allowedDomains.includes(e)||this.allowedDomains.push(e),this}disallowDomain(e){return this.allowedDomains=this.allowedDomains.filter(t=>t!==e),this}clearAllowedDomains(){return this.allowedDomains=[],this}}class _t{reverse(e){const t=new d;return this.reverseNode(t,e,e.getType()),t}reverseNode(e,t,r){this.isIdenticalToType(t,r)||(this.reverseBasicProperties(e,t,r),this.reverseTypeReferences(e,t,r),this.reverseItems(e,t,r),this.reverseProperties(e,t,r))}isIdenticalToType(e,t){return c.isNonNullable(e.getBlueId())&&c.isNonNullable(t==null?void 0:t.getBlueId())&&e.getBlueId()===t.getBlueId()}reverseBasicProperties(e,t,r){const n=t.getValue();c.isNonNullable(n)&&(c.isNullable(r)||c.isNullable(r.getValue()))&&e.setValue(n),c.isNonNullable(t.getName())&&(c.isNullable(r)||t.getName()!==r.getName())&&e.setName(t.getName()),c.isNonNullable(t.getDescription())&&(c.isNullable(r)||t.getDescription()!==r.getDescription())&&e.setDescription(t.getDescription()),c.isNonNullable(t.getBlueId())&&(c.isNullable(r)||t.getBlueId()!==r.getBlueId())&&e.setBlueId(t.getBlueId())}reverseTypeReferences(e,t,r){const n=(i,o)=>{const l=i(t),a=r?i(r):void 0,p=l==null?void 0:l.getBlueId();c.isNonNullable(p)&&(c.isNullable(a==null?void 0:a.getBlueId())||p!==a.getBlueId())&&o(e,new d().setBlueId(p))};n(i=>i.getType(),(i,o)=>i.setType(o)),n(i=>i.getItemType(),(i,o)=>i.setItemType(o)),n(i=>i.getKeyType(),(i,o)=>i.setKeyType(o)),n(i=>i.getValueType(),(i,o)=>i.setValueType(o))}reverseItems(e,t,r){const n=t.getItems();if(c.isNullable(n))return;const i=r==null?void 0:r.getItems(),o=[];if(c.isNonNullable(i)&&i.length>0){const a=N.calculateBlueIdSync(i);o.push(new d().setBlueId(a))}const l=(i==null?void 0:i.length)||0;for(let a=l;a<n.length;a++){const p=new d;this.reverseNode(p,n[a],void 0),o.push(p)}o.length>0&&e.setItems(o)}reverseProperties(e,t,r){const n=t.getProperties();if(c.isNullable(n))return;const i={};for(const[o,l]of Object.entries(n)){const a=this.getInheritedProperty(o,t,r),p=new d;this.reverseNode(p,l,a),Te.isEmptyNode(p)||(i[o]=p)}Object.keys(i).length>0&&e.setProperties(i)}getInheritedProperty(e,t,r){var o,l,a;const n=(o=r==null?void 0:r.getProperties())==null?void 0:o[e],i=(a=(l=t.getType())==null?void 0:l.getProperties())==null?void 0:a[e];if(!(c.isNullable(n)&&c.isNullable(i)))return c.isNullable(n)?i:c.isNullable(i)?n:this.mergeNodes(n,i)}mergeNodes(e,t){const r=e.clone(),n=t.getValue();c.isNonNullable(n)&&r.setValue(n);const i=t.getType();c.isNonNullable(i)&&r.setType(i.clone());const o=t.getItemType();c.isNonNullable(o)&&r.setItemType(o.clone());const l=t.getKeyType();c.isNonNullable(l)&&r.setKeyType(l.clone());const a=t.getValueType();c.isNonNullable(a)&&r.setValueType(a.clone());const p=t.getProperties();if(c.isNonNullable(p)){const y=r.getProperties()||{};for(const[m,b]of Object.entries(p))y[m]=b.clone();r.setProperties(y)}const I=t.getItems();return c.isNonNullable(I)&&r.setItems(I.map(y=>y.clone())),r}}class ve extends d{constructor(e){super(e.getName()),this.createFrom(e)}isResolved(){return!0}getMinimalNode(){return new _t().reverse(this)}getMinimalBlueId(){const e=this.getMinimalNode();return N.calculateBlueIdSync(e)}clone(){const e=super.clone();return new ve(e)}createFrom(e){e.getName()!==this.getName()&&this.setName(e.getName()),this.setDescription(e.getDescription()).setType(e.getType()).setItemType(e.getItemType()).setKeyType(e.getKeyType()).setValueType(e.getValueType()).setItems(e.getItems()).setProperties(e.getProperties()).setBlueId(e.getBlueId()).setBlue(e.getBlue()).setInlineValue(e.isInlineValue());const t=e.getValue();t!==void 0&&this.setValue(t)}}class Zt{resolveWithoutLimits(e){return this.resolve(e,H)}}class kt extends Zt{constructor(t,r){super();h(this,"mergingProcessor");h(this,"nodeProvider");this.mergingProcessor=t,this.nodeProvider=ce.wrap(r)}merge(t,r,n){if(c.isNonNullable(r.getBlue()))throw new Error('Document contains "blue" attribute. Preprocess document before merging.');let i=t;const o=r.getType();if(c.isNonNullable(o)){const l=o.clone();c.isNonNullable(l.getBlueId())&&new et(this.nodeProvider).extend(l,Xe.withSinglePath("/"));const a=this.resolve(l,n),p=r.clone().setType(a);return i=this.merge(i,l,n),this.mergeObject(i,p,n)}return this.mergeObject(i,r,n)}mergeObject(t,r,n){let i=this.mergingProcessor.process(t,r,this.nodeProvider);const o=r.getItems();c.isNonNullable(o)&&(i=this.mergeChildren(i,o,n));const l=r.getProperties();return c.isNonNullable(l)&&Object.entries(l).forEach(([a,p])=>{n.shouldMergePathSegment(a,p)&&(n.enterPathSegment(a,p),i=this.mergeProperty(i,a,p,n),n.exitPathSegment())}),c.isNonNullable(r.getBlueId())&&(i=i.clone().setBlueId(r.getBlueId())),this.mergingProcessor.postProcess&&(i=this.mergingProcessor.postProcess(i,r,this.nodeProvider)),i}mergeChildren(t,r,n){const i=t.getItems();if(c.isNullable(i)){const l=r.filter((a,p)=>n.shouldMergePathSegment(String(p),a)).map(a=>{n.enterPathSegment(String(r.indexOf(a)),a);const p=this.resolve(a,n);return n.exitPathSegment(),p});return t.clone().setItems(l)}else if(r.length<i.length)throw new Error(`Subtype of element must not have more items (${i.length}) than the element itself (${r.length}).`);const o=[...i];for(let l=0;l<r.length;l++){if(!n.shouldMergePathSegment(String(l),r[l]))continue;if(n.enterPathSegment(String(l),r[l]),l>=o.length){o.push(r[l]),n.exitPathSegment();continue}const a=N.calculateBlueIdSync(r[l]),p=N.calculateBlueIdSync(o[l]);if(a!==p)throw new Error(`Mismatched items at index ${l}: source item has blueId '${a}', but target item has blueId '${p}'.`);n.exitPathSegment()}return t.clone().setItems(o)}mergeProperty(t,r,n,i){const o=this.resolve(n,i),l=t.clone();c.isNullable(l.getProperties())&&l.setProperties({});const a=l.getProperties()[r];return a===void 0?l.getProperties()[r]=o:l.getProperties()[r]=this.mergeObject(a,o,i),l}resolve(t,r){const n=new d,o=this.merge(n,t,r).clone().setName(t.getName()).setDescription(t.getDescription()).setBlueId(t.getBlueId());return new ve(o)}}class Yt{constructor(e){h(this,"mergingProcessors");this.mergingProcessors=e}process(e,t,r){return this.mergingProcessors.reduce((n,i)=>i.process(n,t,r),e)}postProcess(e,t,r){return this.mergingProcessors.reduce((n,i)=>i.postProcess?i.postProcess(n,t,r):n,e)}}class Jt{process(e,t){const r=t.getValue();if(c.isNonNullable(r)){const n=e.getValue();if(c.isNullable(n))return e.clone().setValue(r);if(!Zs(r,n))throw new Error(`Node values conflict. Source node value: ${r}, target node value: ${n}`)}return e}}const Zs=(s,e)=>x(s)&&x(e)||fe(s)&&fe(e)?s.eq(e):s===e;class Kt{process(e,t,r){const n=e.getType(),i=t.getType();let o=e;if(n===void 0)o=e.clone().setType(i);else if(i!==void 0){if(!E(i,n,r)){const a=g.get(i),p=g.get(n);throw new Error(`The source type '${JSON.stringify(a)}' is not a subtype of the target type '${JSON.stringify(p)}'.`)}o=e.clone().setType(i)}return o}}class Gt{process(e,t,r){if(t.getItemType()!==void 0&&!ts(t.getType()))throw new Error("Source node with itemType must have a List type");const n=e.getItemType(),i=t.getItemType();let o=e;if(n===void 0)i!==void 0&&(o=e.clone().setItemType(i));else if(i!==void 0){if(!E(i,n,r)){const I=g.get(i),y=g.get(n);throw new Error(`The source item type '${JSON.stringify(I)}' is not a subtype of the target item type '${JSON.stringify(y)}'.`)}o=e.clone().setItemType(i)}const l=o.getItemType(),a=t.getItems();if(l!==void 0&&a!==void 0)for(const p of a){const I=p.getType();if(I!==void 0&&!E(I,l,r)){const y=g.get(I),m=g.get(l);throw new Error(`Item of type '${JSON.stringify(y)}' is not a subtype of the list's item type '${JSON.stringify(m)}'.`)}}return o}}class Wt{process(e,t,r){if((t.getKeyType()!==void 0||t.getValueType()!==void 0)&&!rs(t.getType()))throw new Error("Source node with keyType or valueType must have a Dictionary type");let n=this.processKeyType(e,t,r);n=this.processValueType(n,t,r);const i=n.getKeyType(),o=n.getValueType(),l=t.getProperties();return(i!==void 0||o!==void 0)&&l!==void 0&&Object.entries(l).forEach(([a,p])=>{i!==void 0&&this.validateKeyType(a,i,r),o!==void 0&&this.validateValueType(p,o,r)}),n}processKeyType(e,t,r){const n=e.getKeyType(),i=t.getKeyType();if(n===void 0){if(i!==void 0)return this.validateBasicKeyType(i,r),e.clone().setKeyType(i)}else if(i!==void 0){if(this.validateBasicKeyType(i,r),!E(i,n,r)){const l=g.get(i),a=g.get(n);throw new Error(`The source key type '${JSON.stringify(l)}' is not a subtype of the target key type '${JSON.stringify(a)}'.`)}return e.clone().setKeyType(i)}return e}processValueType(e,t,r){const n=e.getValueType(),i=t.getValueType();if(n===void 0){if(i!==void 0)return e.clone().setValueType(i)}else if(i!==void 0){if(!E(i,n,r)){const l=g.get(i),a=g.get(n);throw new Error(`The source value type '${JSON.stringify(l)}' is not a subtype of the target value type '${JSON.stringify(a)}'.`)}return e.clone().setValueType(i)}return e}validateBasicKeyType(e,t){if(!Hr(e,t))throw new Error("Dictionary key type must be a basic type")}validateKeyType(e,t,r){if(!qr(t,r))if(Xr(t,r)){const n=Number.parseInt(e,10);if(Number.isNaN(n)||n.toString()!==e)throw new Error(`Key '${e}' is not a valid Integer.`)}else if(Qr(t,r)){const n=Number.parseFloat(e);if(Number.isNaN(n))throw new Error(`Key '${e}' is not a valid Number.`)}else if(es(t,r)){if(e.toLowerCase()!=="true"&&e.toLowerCase()!=="false")throw new Error(`Key '${e}' is not a valid Boolean.`)}else throw new Error(`Unsupported key type: ${t.getName()||"unknown"}`)}validateValueType(e,t,r){const n=e.getType();if(n!==void 0&&!E(n,t,r)){const i=g.get(n),o=g.get(t);throw new Error(`Value of type '${JSON.stringify(i)}' is not a subtype of the dictionary's value type '${JSON.stringify(o)}'.`)}}}class Ht{process(e){return e}postProcess(e,t,r){const n=e.getType();if(n!==void 0&&ss(n,r)){const i=e.getItems(),o=e.getProperties();if(i!==void 0&&i.length>0||o!==void 0&&Object.keys(o).length>0){const l=ns(n,r),a=n.getName()||"unknown";throw new Error(`Node of type "${a}" (which extends basic type "${l}") must not have items, properties or contracts.`)}}return e}}const ks=Object.freeze(Object.defineProperty({__proto__:null,BasicTypesVerifier:Ht,DictionaryProcessor:Wt,ListProcessor:Gt,SequentialMergingProcessor:Yt,TypeAssigner:Kt,ValuePropagator:Jt},Symbol.toStringTag,{value:"Module"}));function Ys(){return new Yt([new Jt,new Kt,new Gt,new Wt,new Ht])}class Js{constructor(e={}){h(this,"nodeProvider");h(this,"typeSchemaResolver");h(this,"blueDirectivePreprocessor");h(this,"urlContentFetcher");h(this,"blueIdsMappingGenerator");h(this,"globalLimits",H);h(this,"mergingProcessor");h(this,"repositories");h(this,"prepareForBlueIdCalculation",async e=>e instanceof d||Array.isArray(e)&&e.every(t=>t instanceof d)?e:Array.isArray(e)?await Promise.all(e.map(r=>this.jsonValueToNodeAsync(r))):this.jsonValueToNodeAsync(e));h(this,"calculateBlueId",async e=>{const t=await this.prepareForBlueIdCalculation(e);return N.calculateBlueId(t)});h(this,"prepareForBlueIdCalculationSync",e=>e instanceof d||Array.isArray(e)&&e.every(t=>t instanceof d)?e:Array.isArray(e)?e.map(t=>this.jsonValueToNode(t)):this.jsonValueToNode(e));var a;const{nodeProvider:t,typeSchemaResolver:r=null,urlFetchStrategy:n,repositories:i,mergingProcessor:o}=e;this.repositories=i;const l=Is(()=>[]);if(this.nodeProvider=ce.wrap(t||l,i),this.typeSchemaResolver=r??new Ft([]),this.mergingProcessor=o??Ys(),this.urlContentFetcher=new _s(n),this.blueDirectivePreprocessor=new zs(void 0,this.urlContentFetcher),this.blueIdsMappingGenerator=new Ut,i)for(const{schemas:p,blueIds:I}of i)(a=this.typeSchemaResolver)==null||a.registerSchemas(p),this.blueIdsMappingGenerator.registerBlueIds(I)}nodeToJson(e,t="official"){return g.get(e,t)}nodeToSchemaOutput(e,t){return new ms(this.typeSchemaResolver).convert(e,t)}resolve(e,t=H){const r=this.combineWithGlobalLimits(t);return new kt(this.mergingProcessor,this.nodeProvider).resolve(e,r)}reverse(e){return new _t().reverse(e)}extend(e,t){const r=this.combineWithGlobalLimits(t);new et(this.nodeProvider).extend(e,r)}jsonValueToNode(e){return this.preprocess(f.deserialize(e))}async jsonValueToNodeAsync(e){return this.preprocessAsync(f.deserialize(e))}yamlToNode(e){const t=F(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNode(t)}async yamlToNodeAsync(e){const t=F(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNodeAsync(t)}calculateBlueIdSync(e){const t=this.prepareForBlueIdCalculationSync(e);return N.calculateBlueIdSync(t)}addPreprocessingAliases(e){this.blueDirectivePreprocessor.addPreprocessingAliases(e)}preprocess(e){const t=this.blueDirectivePreprocessor.process(e);return new te({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}async preprocessAsync(e){const t=await this.blueDirectivePreprocessor.processAsync(e);return new te({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}transform(e,t){return V.transform(e,t)}getNodeProvider(){return this.nodeProvider}setNodeProvider(e){return this.nodeProvider=ce.wrap(e,this.repositories),this}getTypeSchemaResolver(){return this.typeSchemaResolver}setTypeSchemaResolver(e){return this.typeSchemaResolver=e,this}getUrlContentFetcher(){return this.urlContentFetcher}setUrlFetchStrategy(e){return this.urlContentFetcher.setFetchStrategy(e),this}enablePreprocessingDirectivesFetchForUrls(){return this.urlContentFetcher.enableFetching(),this}enablePreprocessingDirectivesFetchForDomains(e){return this.urlContentFetcher.enableFetchingForDomains(e),this}allowUrlFetchingForDomain(e){return this.urlContentFetcher.allowDomain(e),this}disallowUrlFetchingForDomain(e){return this.urlContentFetcher.disallowDomain(e),this}getAllowedUrlFetchingDomains(){return this.urlContentFetcher.getAllowedDomains()}disablePreprocessingDirectivesFetchForUrls(){return this.urlContentFetcher.disableFetching(),this}isPreprocessingDirectivesFetchForUrlsEnabled(){return this.urlContentFetcher.isFetchingEnabled()}getPreprocessingAliases(){return this.blueDirectivePreprocessor.getPreprocessingAliases()}setPreprocessingAliases(e){return this.blueDirectivePreprocessor.setPreprocessingAliases(e),this}registerBlueIds(...e){return this.blueIdsMappingGenerator.registerBlueIds(...e),this}getAllRegisteredBlueIds(){return this.blueIdsMappingGenerator.getAllBlueIds()}getAllBlueIdNames(){return this.blueIdsMappingGenerator.getAllBlueIdNames()}getBlueIdsMappingGenerator(){return this.blueIdsMappingGenerator}isTypeOf(e,t,r){return S.isTypeOf(e,t,{checkSchemaExtensions:r==null?void 0:r.checkSchemaExtensions,typeSchemaResolver:this.typeSchemaResolver})}setGlobalLimits(e){return this.globalLimits=e??H,this}getGlobalLimits(){return this.globalLimits}combineWithGlobalLimits(e){return this.globalLimits==H?e:e==H?this.globalLimits:Qe.of(this.globalLimits,e)}}class Ks extends xt{constructor(t=[]){super();h(this,"blueIdToContentMap",new Map);h(this,"blueIdToMultipleDocumentsMap",new Map);h(this,"preprocessor");const r=new te({nodeProvider:this});this.preprocessor=n=>r.preprocessWithDefaultBlue(n),t.forEach(n=>this.processNode(n))}processNode(t){Te.hasItemsOnly(t)?this.processNodeWithItems(t):this.processSingleNode(t)}processSingleNode(t){const r=R.parseAndCalculateBlueIdForNode(t,this.preprocessor);this.blueIdToContentMap.set(r.blueId,r.content),this.blueIdToMultipleDocumentsMap.set(r.blueId,r.isMultipleDocuments);const n=t.getName();n&&this.addToNameMap(n,r.blueId)}processNodeWithItems(t){const r=t.getItems();if(!r)return;this.processNodeList(r);const n=R.parseAndCalculateBlueIdForNodeList(r,this.preprocessor);this.blueIdToContentMap.set(n.blueId,n.content),this.blueIdToMultipleDocumentsMap.set(n.blueId,!0),r.forEach((i,o)=>{const l=i.getName();l&&this.addToNameMap(l,`${n.blueId}#${o}`)})}processNodeList(t){const r=N.calculateBlueIdSync(t),n=t.map(i=>g.get(i));this.blueIdToContentMap.set(r,n),this.blueIdToMultipleDocumentsMap.set(r,!0)}fetchContentByBlueId(t){const r=this.blueIdToContentMap.get(t),n=this.blueIdToMultipleDocumentsMap.get(t);return r!==void 0&&n!==void 0?R.resolveThisReferences(r,t,n):null}addSingleNodes(...t){t.forEach(r=>this.processNode(r))}addSingleDocs(...t){t.forEach(r=>{const n=F(r);if(n!==void 0){const i=f.deserialize(n);this.processNode(i)}})}getBlueIdByName(t){const r=this.nameToBlueIdsMap.get(t);if(!r||r.length===0)throw new Error(`No node with name "${t}"`);return r[0]}getNodeByName(t){const r=this.findNodeByName(t);if(!r)throw new Error(`No node with name "${t}"`);return r}addListAndItsItemsFromNodes(t){this.processNodeList(t),t.forEach(r=>this.processNode(r))}addListAndItsItemsFromDoc(t){const r=F(t);if(r!==void 0){const i=f.deserialize(r).getItems();i&&this.addListAndItsItems(i)}}addListAndItsItems(t){Array.isArray(t)?this.addListAndItsItemsFromNodes(t):this.addListAndItsItemsFromDoc(t)}addList(t){this.processNodeList(t)}}exports.Base58Sha256Provider=yt;exports.BasicNodeProvider=Ks;exports.Blue=Js;exports.BlueIdCalculator=N;exports.BlueIdToCid=Cr;exports.BlueNode=d;exports.BlueNodeTypeSchema=S;exports.JsonCanonicalizer=gt;exports.Limits=Be;exports.Merger=kt;exports.MergingProcessors=ks;exports.NodeResolver=Zt;exports.Nodes=Te;exports.ResolvedBlueNode=ve;exports.TypeSchemaResolver=Ft;exports.applyBlueNodePatch=Lr;exports.baseBlueObjectSchema=de;exports.blueDescriptionField=Ur;exports.blueIdField=Zr;exports.blueIdSchema=pr;exports.blueNameField=kr;exports.blueNodeField=Yr;exports.blueObjectBooleanValueSchema=yr;exports.blueObjectNumberValueSchema=gr;exports.blueObjectSchema=Q;exports.blueObjectStringListItemsSchema=mr;exports.blueObjectStringValueSchema=fr;exports.calculateBlueId=Lt;exports.calculateBlueIdSync=Ds;exports.enrichWithBlueId=xe;exports.getBlueDescriptionAnnotation=vt;exports.getBlueIdAnnotation=Et;exports.getBlueNameAnnotation=St;exports.getBlueNodeAnnotation=Ct;exports.getBlueObjectItems=Os;exports.getBlueObjectProperties=Ms;exports.getBlueObjectTypeLabel=Rs;exports.getBlueObjectValue=Fs;exports.getExtendedFromSchemaAnnotation=Dt;exports.getTypeBlueIdAnnotation=Ot;exports.hasBlueObjectBlueIdDefined=dt;exports.hasBlueObjectItemsDefined=ht;exports.hasBlueObjectNameDefined=br;exports.hasBlueObjectTypeDefined=pt;exports.hasBlueObjectValueDefined=ft;exports.isBigDecimalNumber=fe;exports.isBigIntegerNumber=x;exports.isBigNumber=D;exports.isBlueNodeSchema=He;exports.isBlueObject=Ir;exports.isBlueObjectResolved=zt;exports.isGivenBlueObjectTypeSchema=Nr;exports.isJsonBlueArray=Ke;exports.isJsonBlueObject=Je;exports.isJsonBlueValue=vr;exports.isSchemaExtendedFrom=qe;exports.isUrl=ie;exports.jsonBlueValueSchema=ae;exports.normalizeToBlueObject=js;exports.resolveBlueObjectItems=$e;exports.withBlueDescription=Bt;exports.withBlueId=wt;exports.withBlueName=Pt;exports.withBlueNode=At;exports.withExtendedFromSchema=Vt;exports.withTypeBlueId=Gr;exports.yamlBlueDump=ws;exports.yamlBlueParse=F;
26
+ `}loadDefaultSimpleBlue(){const e=this.enrichDefaultBlue(jt);try{const t=F(e);if(t)this.defaultSimpleBlue=f.deserialize(t);else throw new Error("Failed to parse default Blue content")}catch(t){throw new Error(`Error loading default Blue: ${t}`)}}};h(Ie,"DEFAULT_BLUE_BLUE_ID","FREHAAGDZSzpnoTUoCQ86bBmxbVCULMjvx9JZM6fyqT1");let te=Ie;class zs extends xt{constructor(t){super();h(this,"blueIdToContentMap",new Map);h(this,"blueIdToMultipleDocumentsMap",new Map);h(this,"preprocessor");const r=new te({nodeProvider:this});this.preprocessor=n=>r.preprocessWithDefaultBlue(n),this.loadRepositories(t)}loadRepositories(t){for(const r of t)if(r.contents)for(const[n,i]of Object.entries(r.contents))this.processContent(i,n)}processContent(t,r){Array.isArray(t)?this.processMultipleDocuments(t,r):this.processSingleDocument(t,r)}processSingleDocument(t,r){const n=f.deserialize(t),i=R.parseAndCalculateBlueIdForNode(n,this.preprocessor),o=r||i.blueId;this.blueIdToContentMap.set(o,i.content),this.blueIdToMultipleDocumentsMap.set(o,!1);const l=n.getName();l&&this.addToNameMap(l,o)}processMultipleDocuments(t,r){const n=t.map(l=>{const a=f.deserialize(l);return this.preprocessor(a)}),i=R.parseAndCalculateBlueIdForNodeList(n,l=>l),o=r||i.blueId;this.blueIdToContentMap.set(o,i.content),this.blueIdToMultipleDocumentsMap.set(o,!0),n.forEach((l,a)=>{const p=`${o}#${a}`,I=g.get(l),y=N.calculateBlueIdSync(l);this.blueIdToContentMap.set(y,I),this.blueIdToMultipleDocumentsMap.set(y,!1);const m=l.getName();m&&this.addToNameMap(m,p)})}fetchContentByBlueId(t){const r=this.blueIdToContentMap.get(t),n=this.blueIdToMultipleDocumentsMap.get(t);return r!==void 0&&n!==void 0?R.resolveThisReferences(r,t,n):null}getBlueIds(){return Array.from(this.blueIdToContentMap.keys())}hasBlueId(t){const r=t.split("#")[0];return this.blueIdToContentMap.has(r)}}class ce{static wrap(e,t){const r=[je.INSTANCE];if(t&&t.length>0){const n=new zs(t);r.push(n)}return r.push(e),new Ns(r)}}class Us{constructor(e,t){h(this,"preprocessingAliases",new Map);h(this,"urlContentFetcher");e&&(this.preprocessingAliases=new Map(e)),this.urlContentFetcher=t}process(e){const t=this.getBlueNodeValue(e);if(t){const r=e.clone();if(this.preprocessingAliases.has(t))return this.handleAliasValue(r,t);if(U.isPotentialBlueId(t))return this.handleBlueId(r,t);throw ie(t)?new Error(`URL '${t}' detected. Use the async version of this method to fetch the content.`):new Error(`Invalid blue value: ${t}`)}return e}async processAsync(e){const t=this.getBlueNodeValue(e);if(t){const r=e.clone();if(this.preprocessingAliases.has(t))return this.handleAliasValue(r,t);if(U.isPotentialBlueId(t))return this.handleBlueId(r,t);if(ie(t)&&this.urlContentFetcher)try{const n=await this.fetchFromUrl(t);return n&&r.setBlue(new d().setItems(n)),r}catch(n){throw n instanceof Error?new Error(`Failed to fetch from URL '${t}'.
27
+ ${n.message}`):n}else throw ie(t)?new Error(`UrlContentFetcher not provided for URL: ${t}`):new Error(`Invalid blue value: ${t}`)}return e}getBlueNodeValue(e){const t=e.getBlue(),r=t==null?void 0:t.getValue();return r&&typeof r=="string"?r:null}handleAliasValue(e,t){return e.setBlue(new d().setBlueId(this.preprocessingAliases.get(t))),e}handleBlueId(e,t){return e.setBlue(new d().setBlueId(t)),e}async fetchFromUrl(e){if(!this.urlContentFetcher)throw new Error(`UrlContentFetcher not provided for URL: ${e}`);return await this.urlContentFetcher.fetchAndCache(e)}getPreprocessingAliases(){return new Map(this.preprocessingAliases)}setPreprocessingAliases(e){return this.preprocessingAliases=new Map(e),this}addPreprocessingAliases(e){return e.forEach((t,r)=>{this.preprocessingAliases.set(r,t)}),this}setUrlContentFetcher(e){return this.urlContentFetcher=e,this}getUrlContentFetcher(){return this.urlContentFetcher}}const _s={fetchUrl:async s=>{throw new Error(`You must provide a custom UrlFetchStrategy to fetch content from URL: ${s}`)}};class Zs{constructor(e){h(this,"cache",new Map);h(this,"fetchStrategy");h(this,"enabled",!1);h(this,"allowedDomains",[]);this.fetchStrategy=e||_s}validateUrl(e){if(!ie(e))throw new Error(`Invalid URL: ${e}`);return!0}isDomainAllowed(e){if(this.allowedDomains.length===0)return!0;try{const t=new URL(e);return this.allowedDomains.some(r=>t.hostname===r||t.hostname.endsWith(`.${r}`))}catch{return!1}}getFromCache(e){try{return this.validateUrl(e),this.cache.get(e)||[]}catch{return[]}}async fetchAndCache(e){if(this.validateUrl(e),!this.enabled)throw new Error("URL fetching is disabled. Enable it using the enableFetching method.");if(!this.isDomainAllowed(e))throw new Error(`Domain not allowed for URL: ${e}.`);let t;try{t=await this.fetchStrategy.fetchUrl(e)}catch(l){throw new Error(`Error fetching from URL: ${e}`,{cause:l})}const{data:r,contentType:n}=t;let i;if(n.includes("application/json")||n.includes("text/yaml")||n.includes("application/yaml")||n.includes("text/plain"))i=F(r);else throw new Error(`Unsupported content type from URL: ${n}`);if(i===void 0)throw new Error(`Failed to parse content from URL: ${e}`);let o;return Array.isArray(i)?o=i.map(l=>f.deserialize(l)):o=[f.deserialize(i)],this.cache.set(e,o),o}prefetchUrl(e,t){try{this.validateUrl(e),this.cache.set(e,t)}catch{}}clearCache(){this.cache.clear()}setFetchStrategy(e){return this.fetchStrategy=e,this}getFetchStrategy(){return this.fetchStrategy}enableFetching(){return this.enabled=!0,this.allowedDomains=[],this}enableFetchingForDomains(e){return this.enabled=!0,this.allowedDomains=[...e],this}disableFetching(){return this.enabled=!1,this}isFetchingEnabled(){return this.enabled}getAllowedDomains(){return[...this.allowedDomains]}allowDomain(e){return this.allowedDomains.includes(e)||this.allowedDomains.push(e),this}disallowDomain(e){return this.allowedDomains=this.allowedDomains.filter(t=>t!==e),this}clearAllowedDomains(){return this.allowedDomains=[],this}}class _t{reverse(e){const t=new d;return this.reverseNode(t,e,e.getType()),t}reverseNode(e,t,r){this.isIdenticalToType(t,r)||(this.reverseBasicProperties(e,t,r),this.reverseTypeReferences(e,t,r),this.reverseItems(e,t,r),this.reverseProperties(e,t,r))}isIdenticalToType(e,t){return c.isNonNullable(e.getBlueId())&&c.isNonNullable(t==null?void 0:t.getBlueId())&&e.getBlueId()===t.getBlueId()}reverseBasicProperties(e,t,r){const n=t.getValue();c.isNonNullable(n)&&(c.isNullable(r)||c.isNullable(r.getValue()))&&e.setValue(n),c.isNonNullable(t.getName())&&(c.isNullable(r)||t.getName()!==r.getName())&&e.setName(t.getName()),c.isNonNullable(t.getDescription())&&(c.isNullable(r)||t.getDescription()!==r.getDescription())&&e.setDescription(t.getDescription()),c.isNonNullable(t.getBlueId())&&(c.isNullable(r)||t.getBlueId()!==r.getBlueId())&&e.setBlueId(t.getBlueId())}reverseTypeReferences(e,t,r){const n=(i,o)=>{const l=i(t),a=r?i(r):void 0,p=l==null?void 0:l.getBlueId();c.isNonNullable(p)&&(c.isNullable(a==null?void 0:a.getBlueId())||p!==a.getBlueId())&&o(e,new d().setBlueId(p))};n(i=>i.getType(),(i,o)=>i.setType(o)),n(i=>i.getItemType(),(i,o)=>i.setItemType(o)),n(i=>i.getKeyType(),(i,o)=>i.setKeyType(o)),n(i=>i.getValueType(),(i,o)=>i.setValueType(o))}reverseItems(e,t,r){const n=t.getItems();if(c.isNullable(n))return;const i=r==null?void 0:r.getItems(),o=[];if(c.isNonNullable(i)&&i.length>0){const a=N.calculateBlueIdSync(i);o.push(new d().setBlueId(a))}const l=(i==null?void 0:i.length)||0;for(let a=l;a<n.length;a++){const p=new d;this.reverseNode(p,n[a],void 0),o.push(p)}o.length>0&&e.setItems(o)}reverseProperties(e,t,r){const n=t.getProperties();if(c.isNullable(n))return;const i={};for(const[o,l]of Object.entries(n)){const a=this.getInheritedProperty(o,t,r),p=new d;this.reverseNode(p,l,a),Te.isEmptyNode(p)||(i[o]=p)}Object.keys(i).length>0&&e.setProperties(i)}getInheritedProperty(e,t,r){var o,l,a;const n=(o=r==null?void 0:r.getProperties())==null?void 0:o[e],i=(a=(l=t.getType())==null?void 0:l.getProperties())==null?void 0:a[e];if(!(c.isNullable(n)&&c.isNullable(i)))return c.isNullable(n)?i:c.isNullable(i)?n:this.mergeNodes(n,i)}mergeNodes(e,t){const r=e.clone(),n=t.getValue();c.isNonNullable(n)&&r.setValue(n);const i=t.getType();c.isNonNullable(i)&&r.setType(i.clone());const o=t.getItemType();c.isNonNullable(o)&&r.setItemType(o.clone());const l=t.getKeyType();c.isNonNullable(l)&&r.setKeyType(l.clone());const a=t.getValueType();c.isNonNullable(a)&&r.setValueType(a.clone());const p=t.getProperties();if(c.isNonNullable(p)){const y=r.getProperties()||{};for(const[m,b]of Object.entries(p))y[m]=b.clone();r.setProperties(y)}const I=t.getItems();return c.isNonNullable(I)&&r.setItems(I.map(y=>y.clone())),r}}class ve extends d{constructor(e){super(e.getName()),this.createFrom(e)}isResolved(){return!0}getMinimalNode(){return new _t().reverse(this)}getMinimalBlueId(){const e=this.getMinimalNode();return N.calculateBlueIdSync(e)}clone(){const e=super.clone();return new ve(e)}createFrom(e){e.getName()!==this.getName()&&this.setName(e.getName()),this.setDescription(e.getDescription()).setType(e.getType()).setItemType(e.getItemType()).setKeyType(e.getKeyType()).setValueType(e.getValueType()).setItems(e.getItems()).setProperties(e.getProperties()).setBlueId(e.getBlueId()).setBlue(e.getBlue()).setInlineValue(e.isInlineValue());const t=e.getValue();t!==void 0&&this.setValue(t)}}class Zt{resolveWithoutLimits(e){return this.resolve(e,H)}}class kt extends Zt{constructor(t,r){super();h(this,"mergingProcessor");h(this,"nodeProvider");this.mergingProcessor=t,this.nodeProvider=ce.wrap(r)}merge(t,r,n){if(c.isNonNullable(r.getBlue()))throw new Error('Document contains "blue" attribute. Preprocess document before merging.');let i=t;const o=r.getType();if(c.isNonNullable(o)){const l=o.clone();c.isNonNullable(l.getBlueId())&&new et(this.nodeProvider).extend(l,Xe.withSinglePath("/"));const a=this.resolve(l,n),p=r.clone().setType(a);return i=this.merge(i,l,n),this.mergeObject(i,p,n)}return this.mergeObject(i,r,n)}mergeObject(t,r,n){let i=this.mergingProcessor.process(t,r,this.nodeProvider);const o=r.getItems();c.isNonNullable(o)&&(i=this.mergeChildren(i,o,n));const l=r.getProperties();return c.isNonNullable(l)&&Object.entries(l).forEach(([a,p])=>{n.shouldMergePathSegment(a,p)&&(n.enterPathSegment(a,p),i=this.mergeProperty(i,a,p,n),n.exitPathSegment())}),c.isNonNullable(r.getBlueId())&&(i=i.clone().setBlueId(r.getBlueId())),this.mergingProcessor.postProcess&&(i=this.mergingProcessor.postProcess(i,r,this.nodeProvider)),i}mergeChildren(t,r,n){const i=t.getItems();if(c.isNullable(i)){const l=r.filter((a,p)=>n.shouldMergePathSegment(String(p),a)).map(a=>{n.enterPathSegment(String(r.indexOf(a)),a);const p=this.resolve(a,n);return n.exitPathSegment(),p});return t.clone().setItems(l)}else if(r.length<i.length)throw new Error(`Subtype of element must not have more items (${i.length}) than the element itself (${r.length}).`);const o=[...i];for(let l=0;l<r.length;l++){if(!n.shouldMergePathSegment(String(l),r[l]))continue;if(n.enterPathSegment(String(l),r[l]),l>=o.length){o.push(r[l]),n.exitPathSegment();continue}const a=N.calculateBlueIdSync(r[l]),p=N.calculateBlueIdSync(o[l]);if(a!==p)throw new Error(`Mismatched items at index ${l}: source item has blueId '${a}', but target item has blueId '${p}'.`);n.exitPathSegment()}return t.clone().setItems(o)}mergeProperty(t,r,n,i){const o=this.resolve(n,i),l=t.clone();c.isNullable(l.getProperties())&&l.setProperties({});const a=l.getProperties()[r];return a===void 0?l.getProperties()[r]=o:l.getProperties()[r]=this.mergeObject(a,o,i),l}resolve(t,r){const n=new d,o=this.merge(n,t,r).clone().setName(t.getName()).setDescription(t.getDescription()).setBlueId(t.getBlueId());return new ve(o)}}class Yt{constructor(e){h(this,"mergingProcessors");this.mergingProcessors=e}process(e,t,r){return this.mergingProcessors.reduce((n,i)=>i.process(n,t,r),e)}postProcess(e,t,r){return this.mergingProcessors.reduce((n,i)=>i.postProcess?i.postProcess(n,t,r):n,e)}}class Jt{process(e,t){const r=t.getValue();if(c.isNonNullable(r)){const n=e.getValue();if(c.isNullable(n))return e.clone().setValue(r);if(!ks(r,n))throw new Error(`Node values conflict. Source node value: ${r}, target node value: ${n}`)}return e}}const ks=(s,e)=>x(s)&&x(e)||fe(s)&&fe(e)?s.eq(e):s===e;class Kt{process(e,t,r){const n=e.getType(),i=t.getType();let o=e;if(n===void 0)o=e.clone().setType(i);else if(i!==void 0){if(!E(i,n,r)){const a=g.get(i),p=g.get(n);throw new Error(`The source type '${JSON.stringify(a)}' is not a subtype of the target type '${JSON.stringify(p)}'.`)}o=e.clone().setType(i)}return o}}class Gt{process(e,t,r){if(t.getItemType()!==void 0&&!rs(t.getType()))throw new Error("Source node with itemType must have a List type");const n=e.getItemType(),i=t.getItemType();let o=e;if(n===void 0)i!==void 0&&(o=e.clone().setItemType(i));else if(i!==void 0){if(!E(i,n,r)){const I=g.get(i),y=g.get(n);throw new Error(`The source item type '${JSON.stringify(I)}' is not a subtype of the target item type '${JSON.stringify(y)}'.`)}o=e.clone().setItemType(i)}const l=o.getItemType(),a=t.getItems();if(l!==void 0&&a!==void 0)for(const p of a){const I=p.getType();if(I!==void 0&&!E(I,l,r)){const y=g.get(I),m=g.get(l);throw new Error(`Item of type '${JSON.stringify(y)}' is not a subtype of the list's item type '${JSON.stringify(m)}'.`)}}return o}}class Wt{process(e,t,r){if((t.getKeyType()!==void 0||t.getValueType()!==void 0)&&!ss(t.getType()))throw new Error("Source node with keyType or valueType must have a Dictionary type");let n=this.processKeyType(e,t,r);n=this.processValueType(n,t,r);const i=n.getKeyType(),o=n.getValueType(),l=t.getProperties();return(i!==void 0||o!==void 0)&&l!==void 0&&Object.entries(l).forEach(([a,p])=>{i!==void 0&&this.validateKeyType(a,i,r),o!==void 0&&this.validateValueType(p,o,r)}),n}processKeyType(e,t,r){const n=e.getKeyType(),i=t.getKeyType();if(n===void 0){if(i!==void 0)return this.validateBasicKeyType(i,r),e.clone().setKeyType(i)}else if(i!==void 0){if(this.validateBasicKeyType(i,r),!E(i,n,r)){const l=g.get(i),a=g.get(n);throw new Error(`The source key type '${JSON.stringify(l)}' is not a subtype of the target key type '${JSON.stringify(a)}'.`)}return e.clone().setKeyType(i)}return e}processValueType(e,t,r){const n=e.getValueType(),i=t.getValueType();if(n===void 0){if(i!==void 0)return e.clone().setValueType(i)}else if(i!==void 0){if(!E(i,n,r)){const l=g.get(i),a=g.get(n);throw new Error(`The source value type '${JSON.stringify(l)}' is not a subtype of the target value type '${JSON.stringify(a)}'.`)}return e.clone().setValueType(i)}return e}validateBasicKeyType(e,t){if(!qr(e,t))throw new Error("Dictionary key type must be a basic type")}validateKeyType(e,t,r){if(!Xr(t,r))if(Qr(t,r)){const n=Number.parseInt(e,10);if(Number.isNaN(n)||n.toString()!==e)throw new Error(`Key '${e}' is not a valid Integer.`)}else if(es(t,r)){const n=Number.parseFloat(e);if(Number.isNaN(n))throw new Error(`Key '${e}' is not a valid Number.`)}else if(ts(t,r)){if(e.toLowerCase()!=="true"&&e.toLowerCase()!=="false")throw new Error(`Key '${e}' is not a valid Boolean.`)}else throw new Error(`Unsupported key type: ${t.getName()||"unknown"}`)}validateValueType(e,t,r){const n=e.getType();if(n!==void 0&&!E(n,t,r)){const i=g.get(n),o=g.get(t);throw new Error(`Value of type '${JSON.stringify(i)}' is not a subtype of the dictionary's value type '${JSON.stringify(o)}'.`)}}}class Ht{process(e){return e}postProcess(e,t,r){const n=e.getType();if(n!==void 0&&ns(n,r)){const i=e.getItems(),o=e.getProperties();if(i!==void 0&&i.length>0||o!==void 0&&Object.keys(o).length>0){const l=is(n,r),a=n.getName()||"unknown";throw new Error(`Node of type "${a}" (which extends basic type "${l}") must not have items, properties or contracts.`)}}return e}}class qt{process(e,t){let r=e;const n=t.getName(),i=e.getName();n!==void 0&&i===void 0&&(r=r.clone().setName(n));const o=t.getDescription(),l=r.getDescription();return o!==void 0&&l===void 0&&(r=r.clone().setDescription(o)),r}}const Ys=Object.freeze(Object.defineProperty({__proto__:null,BasicTypesVerifier:Ht,DictionaryProcessor:Wt,ListProcessor:Gt,MetadataPropagator:qt,SequentialMergingProcessor:Yt,TypeAssigner:Kt,ValuePropagator:Jt},Symbol.toStringTag,{value:"Module"}));function Js(){return new Yt([new Jt,new Kt,new Gt,new Wt,new qt,new Ht])}class Ks{constructor(e={}){h(this,"nodeProvider");h(this,"typeSchemaResolver");h(this,"blueDirectivePreprocessor");h(this,"urlContentFetcher");h(this,"blueIdsMappingGenerator");h(this,"globalLimits",H);h(this,"mergingProcessor");h(this,"repositories");h(this,"prepareForBlueIdCalculation",async e=>e instanceof d||Array.isArray(e)&&e.every(t=>t instanceof d)?e:Array.isArray(e)?await Promise.all(e.map(r=>this.jsonValueToNodeAsync(r))):this.jsonValueToNodeAsync(e));h(this,"calculateBlueId",async e=>{const t=await this.prepareForBlueIdCalculation(e);return N.calculateBlueId(t)});h(this,"prepareForBlueIdCalculationSync",e=>e instanceof d||Array.isArray(e)&&e.every(t=>t instanceof d)?e:Array.isArray(e)?e.map(t=>this.jsonValueToNode(t)):this.jsonValueToNode(e));var a;const{nodeProvider:t,typeSchemaResolver:r=null,urlFetchStrategy:n,repositories:i,mergingProcessor:o}=e;this.repositories=i;const l=bs(()=>[]);if(this.nodeProvider=ce.wrap(t||l,i),this.typeSchemaResolver=r??new Ft([]),this.mergingProcessor=o??Js(),this.urlContentFetcher=new Zs(n),this.blueDirectivePreprocessor=new Us(void 0,this.urlContentFetcher),this.blueIdsMappingGenerator=new Ut,i)for(const{schemas:p,blueIds:I}of i)(a=this.typeSchemaResolver)==null||a.registerSchemas(p),this.blueIdsMappingGenerator.registerBlueIds(I)}nodeToJson(e,t="official"){return g.get(e,t)}nodeToSchemaOutput(e,t){return new Is(this.typeSchemaResolver).convert(e,t)}resolve(e,t=H){const r=this.combineWithGlobalLimits(t);return new kt(this.mergingProcessor,this.nodeProvider).resolve(e,r)}reverse(e){return new _t().reverse(e)}extend(e,t){const r=this.combineWithGlobalLimits(t);new et(this.nodeProvider).extend(e,r)}jsonValueToNode(e){return this.preprocess(f.deserialize(e))}async jsonValueToNodeAsync(e){return this.preprocessAsync(f.deserialize(e))}yamlToNode(e){const t=F(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNode(t)}async yamlToNodeAsync(e){const t=F(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNodeAsync(t)}calculateBlueIdSync(e){const t=this.prepareForBlueIdCalculationSync(e);return N.calculateBlueIdSync(t)}addPreprocessingAliases(e){this.blueDirectivePreprocessor.addPreprocessingAliases(e)}preprocess(e){const t=this.blueDirectivePreprocessor.process(e);return new te({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}async preprocessAsync(e){const t=await this.blueDirectivePreprocessor.processAsync(e);return new te({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}transform(e,t){return V.transform(e,t)}getNodeProvider(){return this.nodeProvider}setNodeProvider(e){return this.nodeProvider=ce.wrap(e,this.repositories),this}getTypeSchemaResolver(){return this.typeSchemaResolver}setTypeSchemaResolver(e){return this.typeSchemaResolver=e,this}getUrlContentFetcher(){return this.urlContentFetcher}setUrlFetchStrategy(e){return this.urlContentFetcher.setFetchStrategy(e),this}enablePreprocessingDirectivesFetchForUrls(){return this.urlContentFetcher.enableFetching(),this}enablePreprocessingDirectivesFetchForDomains(e){return this.urlContentFetcher.enableFetchingForDomains(e),this}allowUrlFetchingForDomain(e){return this.urlContentFetcher.allowDomain(e),this}disallowUrlFetchingForDomain(e){return this.urlContentFetcher.disallowDomain(e),this}getAllowedUrlFetchingDomains(){return this.urlContentFetcher.getAllowedDomains()}disablePreprocessingDirectivesFetchForUrls(){return this.urlContentFetcher.disableFetching(),this}isPreprocessingDirectivesFetchForUrlsEnabled(){return this.urlContentFetcher.isFetchingEnabled()}getPreprocessingAliases(){return this.blueDirectivePreprocessor.getPreprocessingAliases()}setPreprocessingAliases(e){return this.blueDirectivePreprocessor.setPreprocessingAliases(e),this}registerBlueIds(...e){return this.blueIdsMappingGenerator.registerBlueIds(...e),this}getAllRegisteredBlueIds(){return this.blueIdsMappingGenerator.getAllBlueIds()}getAllBlueIdNames(){return this.blueIdsMappingGenerator.getAllBlueIdNames()}getBlueIdsMappingGenerator(){return this.blueIdsMappingGenerator}isTypeOf(e,t,r){return S.isTypeOf(e,t,{checkSchemaExtensions:r==null?void 0:r.checkSchemaExtensions,typeSchemaResolver:this.typeSchemaResolver})}setGlobalLimits(e){return this.globalLimits=e??H,this}getGlobalLimits(){return this.globalLimits}combineWithGlobalLimits(e){return this.globalLimits==H?e:e==H?this.globalLimits:Qe.of(this.globalLimits,e)}}class Gs extends xt{constructor(t=[]){super();h(this,"blueIdToContentMap",new Map);h(this,"blueIdToMultipleDocumentsMap",new Map);h(this,"preprocessor");const r=new te({nodeProvider:this});this.preprocessor=n=>r.preprocessWithDefaultBlue(n),t.forEach(n=>this.processNode(n))}processNode(t){Te.hasItemsOnly(t)?this.processNodeWithItems(t):this.processSingleNode(t)}processSingleNode(t){const r=R.parseAndCalculateBlueIdForNode(t,this.preprocessor);this.blueIdToContentMap.set(r.blueId,r.content),this.blueIdToMultipleDocumentsMap.set(r.blueId,r.isMultipleDocuments);const n=t.getName();n&&this.addToNameMap(n,r.blueId)}processNodeWithItems(t){const r=t.getItems();if(!r)return;this.processNodeList(r);const n=R.parseAndCalculateBlueIdForNodeList(r,this.preprocessor);this.blueIdToContentMap.set(n.blueId,n.content),this.blueIdToMultipleDocumentsMap.set(n.blueId,!0),r.forEach((i,o)=>{const l=i.getName();l&&this.addToNameMap(l,`${n.blueId}#${o}`)})}processNodeList(t){const r=N.calculateBlueIdSync(t),n=t.map(i=>g.get(i));this.blueIdToContentMap.set(r,n),this.blueIdToMultipleDocumentsMap.set(r,!0)}fetchContentByBlueId(t){const r=this.blueIdToContentMap.get(t),n=this.blueIdToMultipleDocumentsMap.get(t);return r!==void 0&&n!==void 0?R.resolveThisReferences(r,t,n):null}addSingleNodes(...t){t.forEach(r=>this.processNode(r))}addSingleDocs(...t){t.forEach(r=>{const n=F(r);if(n!==void 0){const i=f.deserialize(n);this.processNode(i)}})}getBlueIdByName(t){const r=this.nameToBlueIdsMap.get(t);if(!r||r.length===0)throw new Error(`No node with name "${t}"`);return r[0]}getNodeByName(t){const r=this.findNodeByName(t);if(!r)throw new Error(`No node with name "${t}"`);return r}addListAndItsItemsFromNodes(t){this.processNodeList(t),t.forEach(r=>this.processNode(r))}addListAndItsItemsFromDoc(t){const r=F(t);if(r!==void 0){const i=f.deserialize(r).getItems();i&&this.addListAndItsItems(i)}}addListAndItsItems(t){Array.isArray(t)?this.addListAndItsItemsFromNodes(t):this.addListAndItsItemsFromDoc(t)}addList(t){this.processNodeList(t)}}exports.Base58Sha256Provider=yt;exports.BasicNodeProvider=Gs;exports.Blue=Ks;exports.BlueIdCalculator=N;exports.BlueIdToCid=Vr;exports.BlueNode=d;exports.BlueNodeTypeSchema=S;exports.JsonCanonicalizer=gt;exports.Limits=Be;exports.Merger=kt;exports.MergingProcessors=Ys;exports.NodeResolver=Zt;exports.Nodes=Te;exports.ResolvedBlueNode=ve;exports.TypeSchemaResolver=Ft;exports.applyBlueNodePatch=zr;exports.baseBlueObjectSchema=de;exports.blueDescriptionField=_r;exports.blueIdField=kr;exports.blueIdSchema=fr;exports.blueNameField=Yr;exports.blueNodeField=Jr;exports.blueObjectBooleanValueSchema=mr;exports.blueObjectNumberValueSchema=yr;exports.blueObjectSchema=Q;exports.blueObjectStringListItemsSchema=Ir;exports.blueObjectStringValueSchema=gr;exports.calculateBlueId=Lt;exports.calculateBlueIdSync=Os;exports.enrichWithBlueId=xe;exports.getBlueDescriptionAnnotation=vt;exports.getBlueIdAnnotation=Et;exports.getBlueNameAnnotation=St;exports.getBlueNodeAnnotation=Ct;exports.getBlueObjectItems=Fs;exports.getBlueObjectProperties=Rs;exports.getBlueObjectTypeLabel=js;exports.getBlueObjectValue=Ms;exports.getExtendedFromSchemaAnnotation=Dt;exports.getTypeBlueIdAnnotation=Ot;exports.hasBlueObjectBlueIdDefined=dt;exports.hasBlueObjectItemsDefined=ht;exports.hasBlueObjectNameDefined=Nr;exports.hasBlueObjectTypeDefined=pt;exports.hasBlueObjectValueDefined=ft;exports.isBigDecimalNumber=fe;exports.isBigIntegerNumber=x;exports.isBigNumber=D;exports.isBlueNodeSchema=He;exports.isBlueObject=br;exports.isBlueObjectResolved=zt;exports.isGivenBlueObjectTypeSchema=Tr;exports.isJsonBlueArray=Ke;exports.isJsonBlueObject=Je;exports.isJsonBlueValue=wr;exports.isSchemaExtendedFrom=qe;exports.isUrl=ie;exports.jsonBlueValueSchema=ae;exports.normalizeToBlueObject=xs;exports.resolveBlueObjectItems=$e;exports.withBlueDescription=Bt;exports.withBlueId=wt;exports.withBlueName=Pt;exports.withBlueNode=At;exports.withExtendedFromSchema=Vt;exports.withTypeBlueId=Wr;exports.yamlBlueDump=Es;exports.yamlBlueParse=F;