@blue-labs/language 3.3.1 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -103,7 +103,7 @@ const json = blue.nodeToJson(node, {
103
103
  - Resolve: `resolve(node, limits)` → `ResolvedBlueNode`.
104
104
  - IDs: `calculateBlueId(_)/calculateBlueIdSync(_)`.
105
105
  - Mapping: `nodeToJson(node, 'official'|'simple'|'original'|{ format, blueContext })`, `nodeToSchemaOutput(node, zod)`.
106
- - Type checks: `isTypeOf(node, zod)`, `isTypeOfNode(node, typeNode)`.
106
+ - Type checks: `isTypeOf(node, zod)`, `isTypeOfNode(node, typeNode)`, `isTypeOfBlueId(node, blueId)`.
107
107
  - Helpers: `extend(node, limits)`, `transform(node, fn)`, `reverse(node)`, `restoreInlineTypes(node)`.
108
108
  - Config: URL fetch allow-list (`enablePreprocessingDirectivesFetchForDomains([...])`), global limits, repositories.
109
109
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("big.js"),u=require("@blue-labs/shared-utils"),c=require("zod"),ur=require("bs58"),V=require("radash"),b=require("@blue-labs/repository-contract"),cr=require("js-sha256"),dr=require("crypto"),pr=require("base32.js"),W=require("js-yaml"),yt=s=>s&&s.__esModule?s:{default:s},ue=yt(ur),_e=yt(dr);class P extends _{constructor(e){super(e)}}class w extends _{constructor(e){super(e)}}const Z="name",G="description",H="type",fe="itemType",he="keyType",ye="valueType",ge="value",Pe="items",x="blueId",Ce="blue",Ge=[Z,G,H,fe,he,ye,ge,Pe,x,Ce],gt="Text",mt="Double",It="Integer",Tt="Boolean",bt="List",Nt="Dictionary",Ae=[gt,mt,It,Tt],He=[...Ae,bt,Nt],j="DLRQwz7MQeCrzjy9bohPNwtCxKEBbKaMK65KBrwjfG6K",L="7pwXmXYCJtWnd348c2JQGBkm9C4renmZRwxbfaypsx5y",U="5WNMiV9Knz63B4dVY5JtMyh3FB4FSGqv7ceScvuapdE1",z="4EzhSubEimSQD3zrYHRtobfPPWntUuhEz8YcdxHsi12u",We="6aehfNAxHLC1PHHoDr3tYtFH3RWNbiWdFancJ1bypXEY",qe="G7fBT9PSod1RfHLHkpafAGBDVAJMrMhAMY51ERcyXNrj",Xe=[j,L,U,z],q=[...Xe,We,qe],fr=Object.fromEntries(He.map((s,e)=>[s,q[e]])),Ve=Object.fromEntries(q.map((s,e)=>[s,He[e]])),hr=Object.freeze(Object.defineProperty({__proto__:null,BASIC_TYPES:Ae,BASIC_TYPE_BLUE_IDS:Xe,BOOLEAN_TYPE:Tt,BOOLEAN_TYPE_BLUE_ID:z,CORE_TYPES:He,CORE_TYPE_BLUE_IDS:q,CORE_TYPE_BLUE_ID_TO_NAME_MAP:Ve,CORE_TYPE_NAME_TO_BLUE_ID_MAP:fr,DICTIONARY_TYPE:Nt,DICTIONARY_TYPE_BLUE_ID:qe,DOUBLE_TYPE:mt,DOUBLE_TYPE_BLUE_ID:L,INTEGER_TYPE:It,INTEGER_TYPE_BLUE_ID:U,LIST_TYPE:bt,LIST_TYPE_BLUE_ID:We,OBJECT_BLUE:Ce,OBJECT_BLUE_ID:x,OBJECT_CONTRACTS:b.OBJECT_CONTRACTS,OBJECT_DESCRIPTION:G,OBJECT_ITEMS:Pe,OBJECT_ITEM_TYPE:fe,OBJECT_KEY_TYPE:he,OBJECT_MERGE_POLICY:b.OBJECT_MERGE_POLICY,OBJECT_NAME:Z,OBJECT_SCHEMA:b.OBJECT_SCHEMA,OBJECT_SPECIFIC_KEYS:Ge,OBJECT_TYPE:H,OBJECT_VALUE:ge,OBJECT_VALUE_TYPE:ye,TEXT_TYPE:gt,TEXT_TYPE_BLUE_ID:j},Symbol.toStringTag,{value:"Module"}));class yr{static get(e,t,r,n=!0){if(u.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 b.OBJECT_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 u.isNonNullable(r)?r:e}}class d{static INTEGER=new d("Integer");name;description;type;itemType;keyType;valueType;value;items;properties;blueId;blue;inlineValue=!1;constructor(e){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 d().setValue(e).setInlineValue(!0):this.type=e,this}getItemType(){return this.itemType}setItemType(e){return typeof e=="string"?this.itemType=new d().setValue(e).setInlineValue(!0):this.itemType=e,this}getKeyType(){return this.keyType}setKeyType(e){return typeof e=="string"?this.keyType=new d().setValue(e).setInlineValue(!0):this.keyType=e,this}getValueType(){return this.valueType}setValueType(e){return typeof e=="string"?this.valueType=new d().setValue(e).setInlineValue(!0):this.valueType=e,this}getValue(){const e=this.type?.getBlueId();if(u.isNonNullable(e)&&u.isNonNullable(this.value)){if(e===U&&typeof this.value=="string")return new w(this.value);if(e===L&&typeof this.value=="string"){const t=new P(this.value),r=parseFloat(t.toString());return new P(r.toString())}else if(e===z&&typeof this.value=="string")return this.value.toLowerCase()==="true"}return this.value}setValue(e){return typeof e=="number"?e%1===0?this.value=new w(e.toString()):this.value=new P(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(){return this.properties?.[b.OBJECT_CONTRACTS]}getContracts(){return this.getContractsProperty()?.getProperties()}setContracts(e){return u.isNullable(e)?this.removeProperty(b.OBJECT_CONTRACTS):this.addProperty(b.OBJECT_CONTRACTS,new d().setProperties(e)),this}addContract(e,t){const r=this.getContractsProperty();return u.isNullable(r)?this.addProperty(b.OBJECT_CONTRACTS,new d().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(b.OBJECT_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 yr.get(this,e,t)}getAsNode(e){const t=this.get(e);if(t instanceof d)return t;throw new Error(`Value at path ${e} is not a BlueNode: ${t}`)}getAsInteger(e){const t=this.get(e);if(t instanceof w||t instanceof P)return t.toNumber();throw new Error(`Value at path ${e} is not a BigInteger or BigDecimal: ${t}`)}clone(){const e=new d(this.name);return e.description=this.description,e.type=this.type?.clone(),e.itemType=this.itemType?.clone(),e.keyType=this.keyType?.clone(),e.valueType=this.valueType?.clone(),e.value=this.value,e.items=this.items?.map(t=>t.clone()),this.properties&&(e.properties=Object.fromEntries(Object.entries(this.properties).map(([t,r])=>[t,r.clone()]))),e.blueId=this.blueId,e.blue=this.blue?.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}}`}}class Ne{static MIN_BLUE_ID_LENGTH=41;static MAX_BLUE_ID_LENGTH=45;static BLUE_ID_PATTERN=/^[1-9A-HJ-NP-Za-km-z]{41,45}(?:#\d+)?$/;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(ue.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}}const gr=c.z.string().max(Ne.MAX_BLUE_ID_LENGTH,{message:"Blue Id has a maximum length of 45 characters"}).min(Ne.MIN_BLUE_ID_LENGTH,{message:"Blue Id has a minimum length of 41 characters"}).refine(s=>{try{return ue.default.decode(s),!0}catch{return!1}},{message:"Blue Id must be a valid Base58 string"}),te=c.z.lazy(()=>c.z.record(c.z.unknown()).and(c.z.object({blueId:c.z.string().optional(),name:c.z.string().optional(),description:c.z.string().optional(),type:te.optional(),value:c.z.union([c.z.string(),c.z.number(),c.z.boolean()]).optional().nullable(),items:c.z.array(te).optional()}))),me=c.z.object({blueId:c.z.string().optional(),name:c.z.string().optional(),description:c.z.string().optional(),type:te.optional()}),mr=me.extend({value:c.z.string().optional()}),Ir=me.extend({value:c.z.number().optional()}),Tr=me.extend({value:c.z.boolean().optional()}),br=me.extend({items:c.z.array(c.z.string()).optional()}),Nr=s=>te.safeParse(s).success,vt=s=>u.isNonNullable(s)&&"blueId"in s&&u.isNonNullable(s.blueId),vr=s=>u.isNonNullable(s)&&"name"in s&&u.isNonNullable(s.name),Bt=s=>u.isNonNullable(s)&&"items"in s&&u.isNonNullable(s.items),wt=s=>u.isNonNullable(s)&&"type"in s&&u.isNonNullable(s.type),Et=s=>u.isNonNullable(s)&&"value"in s&&u.isNonNullable(s.value),Br=(s,e)=>s.required({type:!0}).safeParse(e).success,C=s=>s instanceof _,F=s=>C(s)&&s instanceof w,ve=s=>C(s)&&s instanceof P,wr=c.z.lazy(()=>c.z.record(ce)),Er=c.z.lazy(()=>c.z.union([c.z.array(ce),c.z.array(ce).readonly()])),ce=c.z.lazy(()=>c.z.union([u.jsonPrimitiveSchema,wr,Er,c.z.instanceof(_)])),Qe=s=>V.isObject(s)&&!V.isArray(s)&&!u.isReadonlyArray(s)&&!C(s),et=s=>V.isArray(s)||u.isReadonlyArray(s),Sr=s=>et(s)||Qe(s)||C(s)||u.isJsonPrimitive(s);class g{static deserialize(e){return g.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(Qe(e)){const t=new d,r={};return Object.entries(e).forEach(([n,i])=>{switch(n){case Z:if(i==null)t.setName(void 0);else{if(typeof i!="string")throw new Error(`The ${Z} field must be a string.`);t.setName(i)}break;case G:if(i==null)t.setDescription(void 0);else{if(typeof i!="string")throw new Error(`The ${G} field must be a string.`);t.setDescription(i)}break;case H:t.setType(g.handleNode(i));break;case fe:t.setItemType(g.handleNode(i));break;case he:t.setKeyType(g.handleNode(i));break;case ye:t.setValueType(g.handleNode(i));break;case ge:t.setValue(g.handleValue(i));break;case x:if(typeof i!="string")throw new Error(`The ${x} field must be a string.`);t.setBlueId(i);break;case Pe:t.setItems(g.handleArray(i));break;case Ce:t.setBlue(g.handleNode(i));break;default:r[n]=g.handleNode(i);break}}),Object.keys(r).length>0&&t.setProperties(r),t}else{if(et(e))return new d().setItems(g.handleArray(e));{const t=e;return new d().setValue(g.handleValue(t)).setInlineValue(!0)}}}static handleValue(e){if(e==null)return null;if(typeof e=="string")return e;if(typeof e=="number"||C(e))if(F(e)||Number.isSafeInteger(e)){const t=new w(e.toString()),r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER;return t.lt(r)?new w(r.toString()):t.gt(n)?new w(n.toString()):t}else{const t=parseFloat(e.toString());return new P(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(V.isObject(e)&&!Array.isArray(e))return[g.handleNode(e)];if(Array.isArray(e))return e.map(g.handleNode);throw new Error("Expected an array node")}}}function Pr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var xe,ut;function Cr(){return ut||(ut=1,xe=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])}`},"")}}`}),xe}var Ar=Cr();const Vr=Pr(Ar);class Be{static canonicalize(e){return Vr(e)}}const Fe=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;class tt{static instance;browserCrypto;constructor(){this.browserCrypto=this.initBrowserCrypto()}static getInstance(){return this.instance||(this.instance=new tt),this.instance}initBrowserCrypto(){return Fe?null:"crypto"in globalThis?globalThis.crypto:null}hasNodeCrypto(){return Fe&&!!_e.default&&typeof _e.default.createHash=="function"}getBrowserCrypto(){return this.browserCrypto}getNodeCrypto(){return Fe?_e.default:null}}class St{cryptoEnv=tt.getInstance();applySync(e){const t=this.canonicalizeInput(e),r=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):this.sha256SyncBrowser(t);return ue.default.encode(r)}async apply(e){const t=this.canonicalizeInput(e),r=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):await this.sha256Async(t);return ue.default.encode(r)}canonicalizeInput(e){const t=Be.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");const r=t.createHash("sha256").update(e).digest();return new Uint8Array(r)}sha256SyncBrowser(e){return new Uint8Array(cr.sha256.arrayBuffer(e))}async sha256Async(e){if(this.cryptoEnv.hasNodeCrypto())return Promise.resolve(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),i=await t.subtle.digest("SHA-256",n);return new Uint8Array(i)}}class m{static get(e,t="official"){const r=e.getValue(),n=this.handleValue(r);if(n!==void 0&&t==="simple")return n;const i=e.getItems()?.map(Q=>m.get(Q,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[Z]=o),l!==void 0&&(a[G]=l);const p=e.getType();if(t==="official"&&r!==void 0&&p===void 0){const Q=this.inferTypeBlueId(r);Q!==null&&(a[H]={[x]:Q})}else p!==void 0&&(a[H]=m.get(p,t));const y=e.getItemType();y!==void 0&&(a[fe]=m.get(y,t));const f=e.getKeyType();f!==void 0&&(a[he]=m.get(f,t));const h=e.getValueType();h!==void 0&&(a[ye]=m.get(h,t)),n!==void 0&&(a[ge]=n),i!==void 0&&(a[Pe]=i);const T=e.getBlueId();T!==void 0&&(a[x]=T);const Y=e.getBlue();Y!==void 0&&(a[Ce]=Y);const X=e.getProperties();return X!==void 0&&Object.entries(X).forEach(([Q,ar])=>{a[Q]=m.get(ar,t)}),a}static handleValue(e){if(C(e)){if(F(e)){const t=new _(Number.MIN_SAFE_INTEGER.toString()),r=new _(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"?j:C(e)?F(e)?U:L:typeof e=="boolean"?z:null}}const Rr=s=>u.isJsonPrimitive(s)&&u.isNonNullable(s);class I{static INSTANCE=new I(new St);hashProvider;constructor(e){this.hashProvider=e}static calculateBlueId(e){if(Array.isArray(e)){const r=e.map(n=>m.get(n));return I.INSTANCE.calculate(r)}const t=m.get(e);return I.INSTANCE.calculate(t)}static calculateBlueIdSync(e){if(Array.isArray(e)){const r=e.map(n=>m.get(n));return I.INSTANCE.calculateSync(r)}const t=m.get(e);return I.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 Rr(e)||C(e)?this.applyHash(e.toString(),t):Array.isArray(e)||u.isReadonlyArray(e)?this.calculateList(e,t):this.calculateMap(e,t)}calculateMap(e,t){if(e[x]!==void 0)return e[x];const n=Object.keys(e).map(o=>{const l=e[o];if([Z,ge,G].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(u.isJsonPrimitive(e)||C(e))return e;if(Array.isArray(e)||u.isReadonlyArray(e)){const t=e.map(r=>this.cleanStructure(r)).filter(u.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}}}class Or{static convert(e){const t=ue.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 pr.Encoder({type:"rfc4648",lc:!0}).write(n).finalize().replace(/=/g,"")}}class B{static transform(e,t){const r=t(e.clone()),n=r.getType();n!==void 0&&r.setType(B.transform(n,t));const i=r.getItemType();i!==void 0&&r.setItemType(B.transform(i,t));const o=r.getKeyType();o!==void 0&&r.setKeyType(B.transform(o,t));const l=r.getValueType();l!==void 0&&r.setValueType(B.transform(l,t));const a=r.getItems();if(a!==void 0){const y=a.map(f=>B.transform(f,t));r.setItems(y)}const p=r.getProperties();if(p!==void 0){const y=Object.keys(p).reduce((f,h)=>(f[h]=B.transform(p[h],t),f),{});r.setProperties(y)}return r}}const $=s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof d),O=s=>s instanceof w||s instanceof P,Dr=s=>s.replace(/~1/g,"/").replace(/~0/g,"~");function ie(s){if(s==="/")return[];if(!s.startsWith("/"))throw new Error(`Path must start with '/': ${s}`);return s.split("/").slice(1).map(Dr)}function re(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 Pt(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 b.OBJECT_CONTRACTS:return s.getContracts();default:return}}function ct(s,e,t=!0){if(s instanceof d){const r=Pt(s,e,!0,t);if(r!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties",b.OBJECT_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=re(e);return r>=0&&r<s.length?s[r]:void 0}if($(s))return s[e]}function oe(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=ct(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=ct(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)?re(r):r}}function rt(s,e){if(s instanceof d){const t=e,r=Pt(s,t,!1);if(r!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties",b.OBJECT_CONTRACTS].includes(t))return r;if(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e)){const n=s.getItems(),i=typeof e=="number"?e:parseInt(e,10);if(n&&i>=0&&i<n.length)return n[i]}return s.getProperties()?.[t]}return Array.isArray(s)||$(s)?s[e]:s}function S(s){if(s instanceof d)return s;if(s===null||typeof s=="string"||typeof s=="number"||typeof s=="boolean"||O(s))return g.deserialize(s);const e=ze(s);return g.deserialize(e)}function ze(s){if(s===void 0)return null;if(s===null||typeof s!="object")return s;if(Array.isArray(s))return s.map(ze);const e={};for(const[t,r]of Object.entries(s))e[t]=ze(r);return e}function st(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:S(t));return;case"itemType":s.setItemType(t instanceof d||typeof t=="string"||t===void 0?t:S(t));return;case"keyType":s.setKeyType(t instanceof d||typeof t=="string"||t===void 0?t:S(t));return;case"valueType":s.setValueType(t instanceof d||typeof t=="string"||t===void 0?t:S(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:S(t));return;case"items":s.setItems(t);return;case"properties":s.setProperties(t);return;case b.OBJECT_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:S(t));return}}}Array.isArray(s)?s.splice(re(e),1):$(s)&&(t===void 0?delete s[e]:s[e]=t)}function Mr(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(g.deserialize(null));i.push(t)}}else i.splice(n,0,t)}function we(s,e,t,r){if(Array.isArray(s)){const n=e==="-"?s.length:re(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=S(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(g.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)?Mr(s,e,S(t),r):st(s,e,t);return}if($(s)){s[e]=S(t);return}throw new Error(`Cannot insert into parent of type ${typeof s}`)}function _r(s,e){if(Array.isArray(s)){const t=re(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=re(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}}st(s,e,void 0)}else $(s)&&delete s[e]}function Ye(s){if(s instanceof d)return s.clone();if(Array.isArray(s))return s.map(t=>Ye(t));if($(s)){const e={};return Object.keys(s).forEach(t=>{e[t]=Ye(s[t])}),e}return s}function K(s,e){if(s===e||s instanceof d&&(s.isInlineValue()||s.getValue()!==void 0)&&K(s.getValue()??null,e)||e instanceof d&&(e.isInlineValue()||e.getValue()!==void 0)&&K(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)=>K(t,e[r]));if($(s)&&$(e)){const t=Object.keys(s),r=Object.keys(e);return t.length===r.length&&t.every(n=>K(s[n],e[n]))}return!1}function Ct(s,e){const{parent:t,key:r}=oe(s,ie(e));return rt(t,r)}function At(s,e,t){const r=ie(e);if(r.length===0&&e==="/"){const o=S(t);s.setValue(o.getValue()??null),o.getItems()?s.setItems(o.getItems()):s.setItems(void 0);return}const{parent:n,key:i}=oe(s,r);we(n,i,t,!0)}function xr(s,e,t){const r=ie(e);if(r.length===0&&e==="/"){if(s.getItems()&&Array.isArray(t)){const o=S(t);o.getItems()?(s.setItems(o.getItems()),s.setValue(null)):(s.setValue(o.getValue()??null),s.setItems(void 0))}else{const o=S(t);s.setValue(o.getValue()??null),o.getItems()&&s.setItems(o.getItems())}return!0}const{parent:n,key:i}=oe(s,r);return we(n,i,t,!1),!0}function Fr(s,e,t){const r=ie(e);if(r.length===0&&e==="/"){const l=S(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}=oe(s,r);if(o!==void 0&&n instanceof d)st(n,i,t);else{const l=rt(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}'.`);we(n,i,t,!0)}else we(n,i,t,!0)}return!0}function Vt(s,e){const t=ie(e);if(t.length===0&&e==="/")return s.setValue(null),s.setItems(void 0),s.setProperties(void 0),!0;const{parent:r,key:n}=oe(s,t);return _r(r,n),!0}function $r(s,e,t){const r=Ye(Ct(s,e));return At(s,t,r),!0}function jr(s,e,t){const r=ie(e),{parent:n,key:i}=oe(s,r),o=rt(n,i);if(o===void 0)throw new Error(`MOVE failed: 'from' location '${e}' does not exist.`);return Vt(s,e)?(At(s,t,o),!0):!1}function Lr(s,e,t){const r=Ct(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(!K(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=S(t));else if(O(r)&&typeof t=="number")r instanceof w?n=new w(t.toString()):r instanceof P&&(n=new P(t.toString()));else if((r===null||typeof r=="string"||typeof r=="number"||typeof r=="boolean")&&O(t)){const i=t;!K(r,i.toString())&&(typeof r=="number"&&parseFloat(i.toString()))}if(!K(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 Ur(s,e){switch(e.op){case"add":return xr(s,e.path,e.val);case"replace":return Fr(s,e.path,e.val);case"remove":return Vt(s,e.path);case"copy":return $r(s,e.from,e.path);case"move":return jr(s,e.from,e.path);case"test":return Lr(s,e.path,e.val)}}function zr(s,e,t=!1){const r=t?s:s.clone();return Ur(r,e),r}const $e=Symbol.for("zod-schema-annotations");function Yr(){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 Rt(){const s=Yr();return $e in s||(s[$e]=new WeakMap),s[$e]}function Ie(s,e){const t=Rt(),r=t.get(s)||{};return t.set(s,{...r,...e}),s}const R=s=>Rt().get(s),Ot=s=>e=>{const t=R(e);return Ie(e,{...t,blueDescription:s})},Dt=s=>{const e=R(s);return u.isNonNullable(e)&&V.isString(e.blueDescription)?e.blueDescription:null},kr=s=>Ot(s)(c.z.string().optional()),Kr=c.z.union([c.z.string(),c.z.boolean()]),Mt=s=>e=>{const t=R(e);return Ie(e,{...t,blueId:s})},_t=s=>{const e=R(s),t=Kr.safeParse(e?.blueId);return t.success?t.data:null},Jr=s=>Mt(s??!0)(c.z.string()),xt=s=>e=>{const t=R(e);return Ie(e,{...t,blueName:s})},Ft=s=>{const e=R(s);return u.isNonNullable(e)&&V.isString(e.blueName)?e.blueName:null},Zr=s=>{const e=c.z.string().optional();return xt(s)(e)},$t=()=>s=>{const e=R(s);return Ie(s,{...e,blueNode:!0})},jt=s=>{const e=R(s);return u.isNonNullable(e)&&u.isNonNullable(e.blueNode)&&e.blueNode===!0?e.blueNode:null},nt=s=>!!jt(s),Gr=()=>{const s=c.z.instanceof(d);return $t()(s)},Hr=c.z.object({value:c.z.array(c.z.string()).optional(),defaultValue:c.z.string().optional()}),Lt=s=>{const e=R(s),t=Hr.passthrough().safeParse(e?.typeBlueId);return t.success?t.data:null},Wr=s=>e=>{const t=R(e),r=typeof s=="string"?{value:[s]}:s;return Ie(e,{...t,typeBlueId:{...t?.typeBlueId||{},...r}})};class de{static resolveBlueId(e){const t=Lt(e);if(u.isNullable(t))return null;const r=t.defaultValue;if(u.isNonNullable(r))return r;const n=t.value?.[0];return u.isNonNullable(n)?n:de.getRepositoryBlueId(t,e)}static getRepositoryBlueId(e,t){throw new Error("Not implemented")}}class A{static isTypeOf(e,t,r){const n=de.resolveBlueId(t),i=e.getType()?.getBlueId();if(u.isNullable(n)||u.isNullable(i))return!1;if(n===i)return!0;if(r?.checkSchemaExtensions&&u.isNonNullable(r.typeSchemaResolver)){const o=r.typeSchemaResolver.resolveSchema(e);return A.checkSchemaExtension(o,t,{typeSchemaResolver:r.typeSchemaResolver})}return!1}static checkSchemaExtension(e,t,r){if(!u.isNonNullable(e))return!1;const n=A.unwrapSchema(e),i=A.unwrapSchema(t);return u.isNonNullable(r?.typeSchemaResolver)?r.typeSchemaResolver.isSchemaExtendedFrom(n,i):!1}static isWrapperType(e){return e instanceof c.ZodOptional||e instanceof c.ZodNullable||e instanceof c.ZodReadonly||e instanceof c.ZodBranded||e instanceof c.ZodEffects||e instanceof c.ZodLazy}static unwrapSchema(e){return nt(e)?e:A.isWrapperType(e)?e instanceof c.ZodEffects?A.unwrapSchema(e.innerType()):e instanceof c.ZodLazy?A.unwrapSchema(e.schema):A.unwrapSchema(e.unwrap()):e}}function dt(s,e){const t=s.getType();if(t===void 0)return;const r=t.getBlueId();if(r!==void 0){if(q.includes(r)){const i=Ve[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 v(s,e,t){const r=I.calculateBlueIdSync(s),n=I.calculateBlueIdSync(e);if(r===n)return!0;if(r&&q.includes(r)){let a=e;for(;a!==void 0;){if(I.calculateBlueIdSync(a)===r)return!0;a=dt(a,t)}return!1}let i=s;const o=s.getBlueId();if(o){const a=t.fetchByBlueId(o);a&&a.length===1&&(i=a[0])}let l=i;for(;l!==void 0;){if(I.calculateBlueIdSync(l)===n)return!0;l=dt(l,t)}return!1}function qr(s,e){return Xe.some(t=>{const r=new d().setBlueId(t);return v(s,r,e)})}function Xr(s,e){const t=new d().setBlueId(j);return v(s,t,e)}function Qr(s,e){const t=new d().setBlueId(U);return v(s,t,e)}function es(s,e){const t=new d().setBlueId(L);return v(s,t,e)}function ts(s,e){const t=new d().setBlueId(z);return v(s,t,e)}function Ut(s,e){const t=new d().setBlueId(We);return v(s,t,e)}function zt(s,e){const t=new d().setBlueId(qe);return v(s,t,e)}function rs(s,e){return Ae.some(t=>{const r=new d().setName(t);return v(s,r,e)})}function ss(s,e){for(const t of Ae){const r=new d().setName(t);if(v(s,r,e))return t}throw new Error(`Cannot determine the basic type for node of type "${s.getName()||"unknown"}".`)}class Yt{blueIdMap=new Map;nodeProvider;constructor(e=[],t){this.nodeProvider=t?.nodeProvider??null,this.registerSchemas(e)}registerSchemas(e){for(const t of e)this.registerSchema(t)}registerSchema(e){const t=de.resolveBlueId(e);if(u.isNonNullable(t)){if(this.blueIdMap.has(t))throw new Error(`Duplicate BlueId value: ${t}`);this.blueIdMap.set(t,e)}}setNodeProvider(e){this.nodeProvider=e}resolveSchema(e){const t=this.getEffectiveBlueId(e);return u.isNullable(t)?null:this.blueIdMap.get(t)}isSchemaExtendedFrom(e,t){if(u.isNullable(e))return!1;const r=this.getBlueIdForSchema(e),n=this.getBlueIdForSchema(t);if(u.isNullable(r)||u.isNullable(n))return!1;if(r===n)return!0;if(u.isNonNullable(this.nodeProvider))try{const i=new d().setBlueId(r),o=new d().setBlueId(n);if(v(i,o,this.nodeProvider))return!0}catch{}return!1}getBlueIdForSchema(e){if(u.isNullable(e))return null;const t=de.resolveBlueId(e);if(u.isNonNullable(t))return t;for(const[r,n]of this.blueIdMap)if(n===e||n._def===e._def)return r;return null}getEffectiveBlueId(e){const t=e.getType();return u.isNonNullable(t)&&u.isNonNullable(t.getBlueId())?t.getBlueId():u.isNonNullable(t)?I.calculateBlueIdSync(t):null}getBlueIdMap(){return new Map(this.blueIdMap)}}const E={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 Re{static isEmptyNode(e){return this.hasFieldsAndMayHaveFields(e)}static hasBlueIdOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([E.BLUE_ID]))}static hasItemsOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([E.ITEMS]))}static isValidValueNode(e){const t=e.getValue(),r=e.getProperties(),n=e.getItems();return u.isNonNullable(t)&&u.isNullable(r)&&u.isNullable(n)}static textNode(e){return new d().setType(new d().setBlueId(j)).setValue(e)}static integerNode(e){const t=e instanceof w?e:new w(e.toString());return new d().setType(new d().setBlueId(U)).setValue(t)}static doubleNode(e){const t=e instanceof P?e:new P(e.toString());return new d().setType(new d().setBlueId(L)).setValue(t)}static booleanNode(e){return new d().setType(new d().setBlueId(z)).setValue(e)}static hasFieldsAndMayHaveFields(e,t=new Set,r=new Set){for(const n of Object.values(E)){const i=u.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 E.NAME:return e.getName();case E.TYPE:return e.getType();case E.VALUE:return e.getValue();case E.DESCRIPTION:return e.getDescription();case E.PROPERTIES:return e.getProperties();case E.BLUE:return e.getBlue();case E.ITEMS:return e.getItems();case E.KEY_TYPE:return e.getKeyType();case E.VALUE_TYPE:return e.getValueType();case E.ITEM_TYPE:return e.getItemType();case E.BLUE_ID:return e.getBlueId();default:throw new Error(`Unknown field: ${t}`)}}}class Oe{}class le{static convert(e){const t=new ke;return le.traverseNode(e,"",t),t.build()}static traverseNode(e,t,r){if(!e)return;const n=e.getProperties(),i=e.getItems(),o=n!==void 0&&Object.keys(n).length>0,l=i!==void 0&&i.length>0;if(!o&&!l){r.addPath(t===""?"/":t);return}if(n)for(const[a,p]of Object.entries(n)){const y=`${t}/${a}`;le.traverseNode(p,y,r)}if(i)for(let a=0;a<i.length;a++){const p=`${t}/${a}`;le.traverseNode(i[a],p,r)}}}function pt(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 De extends Oe{allowedPaths;maxDepth;currentPath=[];constructor(e,t){super(),this.allowedPaths=e,this.maxDepth=t}shouldExtendPathSegment(e){if(this.currentPath.length>=this.maxDepth)return!1;const t=this.normalizePath(this.getCurrentFullPath()+"/"+e);return this.isAllowedPath(t)}shouldMergePathSegment(e){return this.shouldExtendPathSegment(e)}isAllowedPath(e){for(const t of this.allowedPaths)if(this.matchesAllowedPath(t,e))return!0;return!1}matchesAllowedPath(e,t){const r=pt(e,"/"),n=pt(t,"/");if(n.length>r.length)return!1;for(let i=1;i<n.length;i++)if(r[i]!=="*"&&r[i]!==n[i])return!1;return!0}enterPathSegment(e){this.currentPath.push(e)}exitPathSegment(){this.currentPath.length>0&&this.currentPath.pop()}getCurrentFullPath(){return"/"+this.currentPath.join("/")}normalizePath(e){return"/"+e.split("/").filter(t=>t!=="").join("/")}static withMaxDepth(e){const t=new ke().setMaxDepth(e);for(let r=1;r<=e;r++){const n="/"+Array(r).fill("*").join("/");t.addPath(n)}return t.build()}static withSinglePath(e){return new ke().addPath(e).build()}static fromNode(e){return le.convert(e)}}class ke{allowedPaths=new Set;maxDepth=Number.MAX_SAFE_INTEGER;addPath(e){return this.allowedPaths.add(e),this}setMaxDepth(e){return this.maxDepth=e,this}build(){return new De(this.allowedPaths,this.maxDepth)}}class ns extends Oe{shouldExtendPathSegment(){return!0}shouldMergePathSegment(){return!0}enterPathSegment(){}exitPathSegment(){}}class Me extends Oe{limits;constructor(e){super(),this.limits=e}shouldExtendPathSegment(e,t){return this.limits.every(r=>r.shouldExtendPathSegment(e,t))}shouldMergePathSegment(e,t){return this.limits.every(r=>r.shouldMergePathSegment(e,t))}enterPathSegment(e,t){this.limits.forEach(r=>{r.enterPathSegment(e,t)})}exitPathSegment(){this.limits.forEach(e=>{e.exitPathSegment()})}static of(...e){return new Me(e)}}const k=new ns;class is{blue;constructor(e){this.blue=e}matchesType(e,t,r=k){const n=t.getType();if(this.matchesImplicitStructure(e,n))return!0;const i=De.fromNode(t),o=Me.of(r,i),l=this.extendAndResolve(e,o),a=this.blue.resolve(t,o);return this.verifyMatch(l,t,o)&&this.recursiveValueComparison(l,a)}extendAndResolve(e,t){const r=e.clone(),n=r.clone();this.blue.extend(n,t);const i=this.blue.resolve(n,t);return this.restoreMissingStructure(i,r),i}restoreMissingStructure(e,t){const r=t.getItems(),n=e.getItems();if(r&&r.length>0)if(!n||n.length===0)e.setItems(r.map(a=>a.clone()));else for(let a=0;a<Math.min(n.length,r.length);a++)this.restoreMissingStructure(n[a],r[a]);const i=t.getProperties();if(i){let a=e.getProperties();a||(a={},e.setProperties(a));for(const[p,y]of Object.entries(i)){const f=a[p];f===void 0?a[p]=y.clone():this.restoreMissingStructure(f,y)}}const o=t.getBlueId();e.getBlueId()===void 0&&o!==void 0&&e.setBlueId(o);const l=t.getValue();e.getValue()===void 0&&l!==void 0&&e.setValue(l)}verifyMatch(e,t,r){const n=t.getType();if(this.matchesImplicitStructure(e,n))return!0;const i=e.clone().setType(t.clone());try{this.blue.resolve(i,r)}catch{return!1}return!0}recursiveValueComparison(e,t){const r=t.getType(),n=this.matchesImplicitStructure(e,r);if(r&&!n){const f=e.getType();if(!f||!v(f,r,this.blue.getNodeProvider()))return!1}const i=t.getBlueId();if(!n&&i!==void 0){const f=e.getBlueId(),h=e.getType()?.getBlueId();if(f!==void 0){if(i!==f)return!1}else if(h===void 0||i!==h)return!1}const o=t.getValue();if(o!==void 0){const f=e.getValue();if(f===void 0)return!1;if(C(f)&&C(o)){if(!f.eq(o))return!1}else if(f!==o)return!1}const l=t.getItems();if(l!==void 0){const f=e.getItems()??[];for(let h=0;h<l.length;h++)if(h<f.length){if(!this.recursiveValueComparison(f[h],l[h]))return!1}else if(this.hasValueInNestedStructure(l[h]))return!1}const a=t.getItemType();if(a!==void 0){const f=e.getItems()??[];for(const h of f)if(!this.recursiveValueComparison(h,a))return!1}const p=t.getProperties();if(p!==void 0){const f=e.getProperties()??{};for(const[h,T]of Object.entries(p))if(h in f){if(!this.recursiveValueComparison(f[h],T))return!1}else if(this.hasValueInNestedStructure(T))return!1}const y=t.getValueType();if(y!==void 0){const f=Object.values(e.getProperties()??{});for(const h of f)if(!this.recursiveValueComparison(h,y))return!1}return!0}hasValueInNestedStructure(e){if(e.getValue()!==void 0)return!0;const t=e.getItems();if(t!==void 0){for(const n of t)if(this.hasValueInNestedStructure(n))return!0}const r=e.getProperties();if(r!==void 0){for(const n of Object.values(r))if(this.hasValueInNestedStructure(n))return!0}return!1}matchesImplicitStructure(e,t){return t===void 0||e.getType()!==void 0?!1:Ut(t,this.blue.getNodeProvider())?this.isImplicitListStructure(e):zt(t,this.blue.getNodeProvider())?this.isImplicitDictionaryStructure(e):!1}isImplicitListStructure(e){return e.getItems()!==void 0&&e.getValue()===void 0}isImplicitDictionaryStructure(e){return e.getProperties()!==void 0&&e.getValue()===void 0}}const os=s=>s instanceof c.ZodOptional||s instanceof c.ZodNullable||s instanceof c.ZodReadonly||s instanceof c.ZodBranded||s instanceof c.ZodEffects||s instanceof c.ZodLazy,ls=s=>s instanceof c.ZodString||s instanceof c.ZodNumber||s instanceof c.ZodBoolean||s instanceof c.ZodBigInt;class kt{static convertValue(e,t){const r=e.getType()?.getBlueId(),n=e.getValue();return u.isNullable(n)?ls(t)&&Re.isValidValueNode(e)?this.getDefaultPrimitiveValue(t):n:j===r?this.convertFromString(String(n),t):L===r||n instanceof P?this.convertFromBigDecimal(new P(n?.toString()),t):U===r||n instanceof w?this.convertFromBigInteger(new w(n?.toString()),t):z===r||typeof n=="boolean"?this.convertFromBoolean(!!n,t):this.convertFromString(String(n),t)}static convertFromString(e,t){if(!t||t instanceof c.ZodString||t instanceof c.ZodEnum||t instanceof c.ZodNativeEnum)return e;if(t instanceof c.ZodNumber)return Number(e);if(t instanceof c.ZodBoolean)return e.toLowerCase()==="true";if(t instanceof c.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert String to ${t._def.typeName}`)}static convertFromBigDecimal(e,t){if(t instanceof c.ZodNumber)return e.toNumber();if(t instanceof c.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBigInteger(e,t){if(t instanceof c.ZodNumber)return e.toNumber();if(t instanceof c.ZodBigInt)return BigInt(e.toString());if(t instanceof c.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBoolean(e,t){if(!t||t instanceof c.ZodBoolean)return e;if(t instanceof c.ZodString)return e.toString();if(t instanceof c.ZodNumber)return Number(e);if(t instanceof c.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert Boolean to ${t._def.typeName}`)}static getDefaultPrimitiveValue(e){if(!e)return null;if(e instanceof c.ZodNumber)return 0;if(e instanceof c.ZodBoolean)return!1;if(e instanceof c.ZodString)return"";throw new Error(`Unsupported primitive type: ${e._def.typeName}`)}}class as{convert(e,t){return kt.convertValue(e,t)}}class us{constructor(e){this.nodeToObjectConverter=e}convert(e,t){return this.convertFields(e,t)}convertFields(e,t){if(t instanceof c.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 c.ZodUnion)throw new Error("Union not supported");if(t instanceof c.ZodObject)return Object.keys(t.shape).reduce((n,i)=>{const o=e.getProperties(),l=t.shape[i],a=_t(l);if(u.isNonNullable(a)){const T=V.isString(a)?a:i,Y=o?.[T],X=Y?I.calculateBlueIdSync(Y):void 0;return n[i]=X,n}const p=Ft(l);if(u.isNonNullable(p)){const T=o?.[p];return n[i]=T?.getName(),n}const y=Dt(l);if(u.isNonNullable(y)){const T=o?.[y];return n[i]=T?.getDescription(),n}if(i==="name"){const T=e.getName();return n[i]=T,n}if(i==="description"){const T=e.getDescription();return n[i]=T,n}const f=o?.[i];if(u.isNullable(f))return n;const h=this.nodeToObjectConverter.convert(f,l);return n[i]=h,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 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 ps{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=t.keySchema,n=t.valueSchema,i=new Map,o=e.getName();u.isNonNullable(o)&&i.set(Z,o);const l=e.getDescription();u.isNonNullable(l)&&i.set(G,l);const a=e.getProperties();return u.isNonNullable(a)&&Object.entries(a).forEach(([p,y])=>{const f=new d().setValue(p);f.setType(new d().setBlueId(j));const h=kt.convertValue(f,r),T=this.nodeToObjectConverter.convert(y,n);i.set(h,T)}),t instanceof c.ZodRecord?Object.fromEntries(i):i}}class fs{convert(e){return m.get(e)}}class hs{convert(e){return m.get(e)}}class ys{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=c.z.union([c.z.literal("ZodString"),c.z.literal("ZodNumber"),c.z.literal("ZodBoolean"),c.z.literal("ZodBigInt"),c.z.literal("ZodArray"),c.z.literal("ZodSet"),c.z.literal("ZodMap"),c.z.literal("ZodRecord"),c.z.literal("ZodObject"),c.z.literal("ZodEnum"),c.z.literal("ZodNativeEnum"),c.z.literal("ZodUnknown"),c.z.literal("ZodAny"),c.z.literal("ZodTuple")]);class ms{constructor(e){this.nodeToObjectConverter=e,this.registerConverters(),this.complexObjectConverter=new us(this.nodeToObjectConverter)}converters=new Map;complexObjectConverter;registerConverters(){const e=new as,t=new cs(this.nodeToObjectConverter),r=new ys(this.nodeToObjectConverter),n=new ds(this.nodeToObjectConverter),i=new ps(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 fs),this.converters.set("ZodAny",new hs),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 c.ZodEffects?this.getSchemaTypeName(e.innerType()):e instanceof c.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 Is{constructor(e){this.typeSchemaResolver=e,this.converterFactory=new ms(this)}converterFactory;convert(e,t){const r=this.typeSchemaResolver?.resolveSchema(e),n=A.unwrapSchema(t);if(nt(n))return e;let i=n;return A.checkSchemaExtension(r,n,{typeSchemaResolver:this.typeSchemaResolver})&&u.isNonNullable(r)&&(i=r),this.convertWithType(e,i)}convertWithType(e,t){return this.converterFactory.getConverter(t).convert(e,t)}}class Kt{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 u.isNonNullable(e.getBlueId())&&u.isNonNullable(t?.getBlueId())&&e.getBlueId()===t.getBlueId()}reverseBasicProperties(e,t,r){const n=t.getValue();u.isNonNullable(n)&&(u.isNullable(r)||u.isNullable(r.getValue()))&&e.setValue(n),u.isNonNullable(t.getName())&&(u.isNullable(r)||t.getName()!==r.getName())&&e.setName(t.getName()),u.isNonNullable(t.getDescription())&&(u.isNullable(r)||t.getDescription()!==r.getDescription())&&e.setDescription(t.getDescription()),u.isNonNullable(t.getBlueId())&&(u.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?.getBlueId();u.isNonNullable(p)&&(u.isNullable(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(u.isNullable(n))return;const i=r?.getItems(),o=[];if(u.isNonNullable(i)&&i.length>0){const a=I.calculateBlueIdSync(i);o.push(new d().setBlueId(a))}const l=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(u.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),Re.isEmptyNode(p)||(i[o]=p)}Object.keys(i).length>0&&e.setProperties(i)}getInheritedProperty(e,t,r){const n=r?.getProperties()?.[e],i=t.getType()?.getProperties()?.[e];if(!(u.isNullable(n)&&u.isNullable(i)))return u.isNullable(n)?i:u.isNullable(i)?n:this.mergeNodes(n,i)}mergeNodes(e,t){const r=e.clone(),n=t.getValue();u.isNonNullable(n)&&r.setValue(n);const i=t.getType();u.isNonNullable(i)&&r.setType(i.clone());const o=t.getItemType();u.isNonNullable(o)&&r.setItemType(o.clone());const l=t.getKeyType();u.isNonNullable(l)&&r.setKeyType(l.clone());const a=t.getValueType();u.isNonNullable(a)&&r.setValueType(a.clone());const p=t.getProperties();if(u.isNonNullable(p)){const f=r.getProperties()||{};for(const[h,T]of Object.entries(p))f[h]=T.clone();r.setProperties(f)}const y=t.getItems();return u.isNonNullable(y)&&r.setItems(y.map(f=>f.clone())),r}}class se extends d{constructor(e){super(e.getName()),this.createFrom(e)}isResolved(){return!0}getMinimalNode(){return new Kt().reverse(this)}getMinimalBlueId(){const e=this.getMinimalNode();return I.calculateBlueIdSync(e)}clone(){const e=super.clone();return new se(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 Te{fetchFirstByBlueId(e){const t=this.fetchByBlueId(e);return t&&t.length>0?t[0]:null}}function Ts(s){return new class extends Te{fetchByBlueId(e){return s(e)}}}const je=W.types.float.options,bs={...je,construct:s=>{const e=s.replace(/_/g,"").toLowerCase();if(!u.isPreciseNumberString(e))return new P(e);if(je.construct)return je.construct(s)}},Ns=new W.Type("tag:yaml.org,2002:float",bs),Le=W.types.int.options,vs={...Le,construct:s=>{let e=s;if(e.indexOf("_")!==-1&&(e=e.replace(/_/g,"")),!u.isPreciseNumberString(e))return new w(e);if(Le.construct)return Le.construct(s)}},Bs=new W.Type("tag:yaml.org,2002:int",vs),Jt=W.CORE_SCHEMA.extend({implicit:[Ns,Bs]}),D=s=>{const e=W.load(s,{schema:Jt});return e===void 0?void 0:e},Zt=s=>W.dump(s,{schema:Jt,replacer:(e,t)=>{if(C(t)){if(F(t)){const r=new _(Number.MIN_SAFE_INTEGER.toString()),n=new _(Number.MAX_SAFE_INTEGER.toString());if(t.lt(r)||t.gt(n))return t.toString()}return t.toNumber()}return t}});class ws{static get(e,t={}){const{strategy:r="official"}=t,n=m.get(e,r);return Zt(n)}}class Es extends Te{nodeProviders;constructor(e){super(),this.nodeProviders=e}fetchByBlueId(e){for(const t of this.nodeProviders){const r=t.fetchByBlueId(e);if(r&&r.length>0)return r}return[]}fetchFirstByBlueId(e){for(const t of this.nodeProviders){const r=t.fetchFirstByBlueId(e);if(r)return r}return null}getNodeProviders(){return this.nodeProviders}}const Gt=`- type:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("big.js"),u=require("@blue-labs/shared-utils"),c=require("zod"),ur=require("bs58"),V=require("radash"),b=require("@blue-labs/repository-contract"),cr=require("js-sha256"),dr=require("crypto"),pr=require("base32.js"),W=require("js-yaml"),yt=s=>s&&s.__esModule?s:{default:s},ue=yt(ur),_e=yt(dr);class S extends _{constructor(e){super(e)}}class w extends _{constructor(e){super(e)}}const Z="name",G="description",H="type",fe="itemType",he="keyType",ye="valueType",ge="value",Se="items",x="blueId",Ce="blue",Ge=[Z,G,H,fe,he,ye,ge,Se,x,Ce],gt="Text",mt="Double",It="Integer",Tt="Boolean",bt="List",Nt="Dictionary",Ae=[gt,mt,It,Tt],He=[...Ae,bt,Nt],j="DLRQwz7MQeCrzjy9bohPNwtCxKEBbKaMK65KBrwjfG6K",L="7pwXmXYCJtWnd348c2JQGBkm9C4renmZRwxbfaypsx5y",U="5WNMiV9Knz63B4dVY5JtMyh3FB4FSGqv7ceScvuapdE1",z="4EzhSubEimSQD3zrYHRtobfPPWntUuhEz8YcdxHsi12u",We="6aehfNAxHLC1PHHoDr3tYtFH3RWNbiWdFancJ1bypXEY",qe="G7fBT9PSod1RfHLHkpafAGBDVAJMrMhAMY51ERcyXNrj",Xe=[j,L,U,z],q=[...Xe,We,qe],fr=Object.fromEntries(He.map((s,e)=>[s,q[e]])),Ve=Object.fromEntries(q.map((s,e)=>[s,He[e]])),hr=Object.freeze(Object.defineProperty({__proto__:null,BASIC_TYPES:Ae,BASIC_TYPE_BLUE_IDS:Xe,BOOLEAN_TYPE:Tt,BOOLEAN_TYPE_BLUE_ID:z,CORE_TYPES:He,CORE_TYPE_BLUE_IDS:q,CORE_TYPE_BLUE_ID_TO_NAME_MAP:Ve,CORE_TYPE_NAME_TO_BLUE_ID_MAP:fr,DICTIONARY_TYPE:Nt,DICTIONARY_TYPE_BLUE_ID:qe,DOUBLE_TYPE:mt,DOUBLE_TYPE_BLUE_ID:L,INTEGER_TYPE:It,INTEGER_TYPE_BLUE_ID:U,LIST_TYPE:bt,LIST_TYPE_BLUE_ID:We,OBJECT_BLUE:Ce,OBJECT_BLUE_ID:x,OBJECT_CONTRACTS:b.OBJECT_CONTRACTS,OBJECT_DESCRIPTION:G,OBJECT_ITEMS:Se,OBJECT_ITEM_TYPE:fe,OBJECT_KEY_TYPE:he,OBJECT_MERGE_POLICY:b.OBJECT_MERGE_POLICY,OBJECT_NAME:Z,OBJECT_SCHEMA:b.OBJECT_SCHEMA,OBJECT_SPECIFIC_KEYS:Ge,OBJECT_TYPE:H,OBJECT_VALUE:ge,OBJECT_VALUE_TYPE:ye,TEXT_TYPE:gt,TEXT_TYPE_BLUE_ID:j},Symbol.toStringTag,{value:"Module"}));class yr{static get(e,t,r,n=!0){if(u.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 b.OBJECT_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 u.isNonNullable(r)?r:e}}class d{static INTEGER=new d("Integer");name;description;type;itemType;keyType;valueType;value;items;properties;blueId;blue;inlineValue=!1;constructor(e){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 d().setValue(e).setInlineValue(!0):this.type=e,this}getItemType(){return this.itemType}setItemType(e){return typeof e=="string"?this.itemType=new d().setValue(e).setInlineValue(!0):this.itemType=e,this}getKeyType(){return this.keyType}setKeyType(e){return typeof e=="string"?this.keyType=new d().setValue(e).setInlineValue(!0):this.keyType=e,this}getValueType(){return this.valueType}setValueType(e){return typeof e=="string"?this.valueType=new d().setValue(e).setInlineValue(!0):this.valueType=e,this}getValue(){const e=this.type?.getBlueId();if(u.isNonNullable(e)&&u.isNonNullable(this.value)){if(e===U&&typeof this.value=="string")return new w(this.value);if(e===L&&typeof this.value=="string"){const t=new S(this.value),r=parseFloat(t.toString());return new S(r.toString())}else if(e===z&&typeof this.value=="string")return this.value.toLowerCase()==="true"}return this.value}setValue(e){return typeof e=="number"?e%1===0?this.value=new w(e.toString()):this.value=new S(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(){return this.properties?.[b.OBJECT_CONTRACTS]}getContracts(){return this.getContractsProperty()?.getProperties()}setContracts(e){return u.isNullable(e)?this.removeProperty(b.OBJECT_CONTRACTS):this.addProperty(b.OBJECT_CONTRACTS,new d().setProperties(e)),this}addContract(e,t){const r=this.getContractsProperty();return u.isNullable(r)?this.addProperty(b.OBJECT_CONTRACTS,new d().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(b.OBJECT_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 yr.get(this,e,t)}getAsNode(e){const t=this.get(e);if(t instanceof d)return t;throw new Error(`Value at path ${e} is not a BlueNode: ${t}`)}getAsInteger(e){const t=this.get(e);if(t instanceof w||t instanceof S)return t.toNumber();throw new Error(`Value at path ${e} is not a BigInteger or BigDecimal: ${t}`)}clone(){const e=new d(this.name);return e.description=this.description,e.type=this.type?.clone(),e.itemType=this.itemType?.clone(),e.keyType=this.keyType?.clone(),e.valueType=this.valueType?.clone(),e.value=this.value,e.items=this.items?.map(t=>t.clone()),this.properties&&(e.properties=Object.fromEntries(Object.entries(this.properties).map(([t,r])=>[t,r.clone()]))),e.blueId=this.blueId,e.blue=this.blue?.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}}`}}class Ne{static MIN_BLUE_ID_LENGTH=41;static MAX_BLUE_ID_LENGTH=45;static BLUE_ID_PATTERN=/^[1-9A-HJ-NP-Za-km-z]{41,45}(?:#\d+)?$/;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(ue.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}}const gr=c.z.string().max(Ne.MAX_BLUE_ID_LENGTH,{message:"Blue Id has a maximum length of 45 characters"}).min(Ne.MIN_BLUE_ID_LENGTH,{message:"Blue Id has a minimum length of 41 characters"}).refine(s=>{try{return ue.default.decode(s),!0}catch{return!1}},{message:"Blue Id must be a valid Base58 string"}),te=c.z.lazy(()=>c.z.record(c.z.unknown()).and(c.z.object({blueId:c.z.string().optional(),name:c.z.string().optional(),description:c.z.string().optional(),type:te.optional(),value:c.z.union([c.z.string(),c.z.number(),c.z.boolean()]).optional().nullable(),items:c.z.array(te).optional()}))),me=c.z.object({blueId:c.z.string().optional(),name:c.z.string().optional(),description:c.z.string().optional(),type:te.optional()}),mr=me.extend({value:c.z.string().optional()}),Ir=me.extend({value:c.z.number().optional()}),Tr=me.extend({value:c.z.boolean().optional()}),br=me.extend({items:c.z.array(c.z.string()).optional()}),Nr=s=>te.safeParse(s).success,vt=s=>u.isNonNullable(s)&&"blueId"in s&&u.isNonNullable(s.blueId),vr=s=>u.isNonNullable(s)&&"name"in s&&u.isNonNullable(s.name),Bt=s=>u.isNonNullable(s)&&"items"in s&&u.isNonNullable(s.items),wt=s=>u.isNonNullable(s)&&"type"in s&&u.isNonNullable(s.type),Et=s=>u.isNonNullable(s)&&"value"in s&&u.isNonNullable(s.value),Br=(s,e)=>s.required({type:!0}).safeParse(e).success,C=s=>s instanceof _,F=s=>C(s)&&s instanceof w,ve=s=>C(s)&&s instanceof S,wr=c.z.lazy(()=>c.z.record(ce)),Er=c.z.lazy(()=>c.z.union([c.z.array(ce),c.z.array(ce).readonly()])),ce=c.z.lazy(()=>c.z.union([u.jsonPrimitiveSchema,wr,Er,c.z.instanceof(_)])),Qe=s=>V.isObject(s)&&!V.isArray(s)&&!u.isReadonlyArray(s)&&!C(s),et=s=>V.isArray(s)||u.isReadonlyArray(s),Pr=s=>et(s)||Qe(s)||C(s)||u.isJsonPrimitive(s);class g{static deserialize(e){return g.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(Qe(e)){const t=new d,r={};return Object.entries(e).forEach(([n,i])=>{switch(n){case Z:if(i==null)t.setName(void 0);else{if(typeof i!="string")throw new Error(`The ${Z} field must be a string.`);t.setName(i)}break;case G:if(i==null)t.setDescription(void 0);else{if(typeof i!="string")throw new Error(`The ${G} field must be a string.`);t.setDescription(i)}break;case H:t.setType(g.handleNode(i));break;case fe:t.setItemType(g.handleNode(i));break;case he:t.setKeyType(g.handleNode(i));break;case ye:t.setValueType(g.handleNode(i));break;case ge:t.setValue(g.handleValue(i));break;case x:if(typeof i!="string")throw new Error(`The ${x} field must be a string.`);t.setBlueId(i);break;case Se:t.setItems(g.handleArray(i));break;case Ce:t.setBlue(g.handleNode(i));break;default:r[n]=g.handleNode(i);break}}),Object.keys(r).length>0&&t.setProperties(r),t}else{if(et(e))return new d().setItems(g.handleArray(e));{const t=e;return new d().setValue(g.handleValue(t)).setInlineValue(!0)}}}static handleValue(e){if(e==null)return null;if(typeof e=="string")return e;if(typeof e=="number"||C(e))if(F(e)||Number.isSafeInteger(e)){const t=new w(e.toString()),r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER;return t.lt(r)?new w(r.toString()):t.gt(n)?new w(n.toString()):t}else{const t=parseFloat(e.toString());return new S(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(V.isObject(e)&&!Array.isArray(e))return[g.handleNode(e)];if(Array.isArray(e))return e.map(g.handleNode);throw new Error("Expected an array node")}}}function Sr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var xe,ut;function Cr(){return ut||(ut=1,xe=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])}`},"")}}`}),xe}var Ar=Cr();const Vr=Sr(Ar);class Be{static canonicalize(e){return Vr(e)}}const Fe=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;class tt{static instance;browserCrypto;constructor(){this.browserCrypto=this.initBrowserCrypto()}static getInstance(){return this.instance||(this.instance=new tt),this.instance}initBrowserCrypto(){return Fe?null:"crypto"in globalThis?globalThis.crypto:null}hasNodeCrypto(){return Fe&&!!_e.default&&typeof _e.default.createHash=="function"}getBrowserCrypto(){return this.browserCrypto}getNodeCrypto(){return Fe?_e.default:null}}class Pt{cryptoEnv=tt.getInstance();applySync(e){const t=this.canonicalizeInput(e),r=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):this.sha256SyncBrowser(t);return ue.default.encode(r)}async apply(e){const t=this.canonicalizeInput(e),r=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):await this.sha256Async(t);return ue.default.encode(r)}canonicalizeInput(e){const t=Be.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");const r=t.createHash("sha256").update(e).digest();return new Uint8Array(r)}sha256SyncBrowser(e){return new Uint8Array(cr.sha256.arrayBuffer(e))}async sha256Async(e){if(this.cryptoEnv.hasNodeCrypto())return Promise.resolve(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),i=await t.subtle.digest("SHA-256",n);return new Uint8Array(i)}}class m{static get(e,t="official"){const r=e.getValue(),n=this.handleValue(r);if(n!==void 0&&t==="simple")return n;const i=e.getItems()?.map(Q=>m.get(Q,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[Z]=o),l!==void 0&&(a[G]=l);const p=e.getType();if(t==="official"&&r!==void 0&&p===void 0){const Q=this.inferTypeBlueId(r);Q!==null&&(a[H]={[x]:Q})}else p!==void 0&&(a[H]=m.get(p,t));const y=e.getItemType();y!==void 0&&(a[fe]=m.get(y,t));const f=e.getKeyType();f!==void 0&&(a[he]=m.get(f,t));const h=e.getValueType();h!==void 0&&(a[ye]=m.get(h,t)),n!==void 0&&(a[ge]=n),i!==void 0&&(a[Se]=i);const T=e.getBlueId();T!==void 0&&(a[x]=T);const Y=e.getBlue();Y!==void 0&&(a[Ce]=Y);const X=e.getProperties();return X!==void 0&&Object.entries(X).forEach(([Q,ar])=>{a[Q]=m.get(ar,t)}),a}static handleValue(e){if(C(e)){if(F(e)){const t=new _(Number.MIN_SAFE_INTEGER.toString()),r=new _(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"?j:C(e)?F(e)?U:L:typeof e=="boolean"?z:null}}const Or=s=>u.isJsonPrimitive(s)&&u.isNonNullable(s);class I{static INSTANCE=new I(new Pt);hashProvider;constructor(e){this.hashProvider=e}static calculateBlueId(e){if(Array.isArray(e)){const r=e.map(n=>m.get(n));return I.INSTANCE.calculate(r)}const t=m.get(e);return I.INSTANCE.calculate(t)}static calculateBlueIdSync(e){if(Array.isArray(e)){const r=e.map(n=>m.get(n));return I.INSTANCE.calculateSync(r)}const t=m.get(e);return I.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 Or(e)||C(e)?this.applyHash(e.toString(),t):Array.isArray(e)||u.isReadonlyArray(e)?this.calculateList(e,t):this.calculateMap(e,t)}calculateMap(e,t){if(e[x]!==void 0)return e[x];const n=Object.keys(e).map(o=>{const l=e[o];if([Z,ge,G].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(u.isJsonPrimitive(e)||C(e))return e;if(Array.isArray(e)||u.isReadonlyArray(e)){const t=e.map(r=>this.cleanStructure(r)).filter(u.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}}}class Rr{static convert(e){const t=ue.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 pr.Encoder({type:"rfc4648",lc:!0}).write(n).finalize().replace(/=/g,"")}}class B{static transform(e,t){const r=t(e.clone()),n=r.getType();n!==void 0&&r.setType(B.transform(n,t));const i=r.getItemType();i!==void 0&&r.setItemType(B.transform(i,t));const o=r.getKeyType();o!==void 0&&r.setKeyType(B.transform(o,t));const l=r.getValueType();l!==void 0&&r.setValueType(B.transform(l,t));const a=r.getItems();if(a!==void 0){const y=a.map(f=>B.transform(f,t));r.setItems(y)}const p=r.getProperties();if(p!==void 0){const y=Object.keys(p).reduce((f,h)=>(f[h]=B.transform(p[h],t),f),{});r.setProperties(y)}return r}}const $=s=>!!s&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof d),R=s=>s instanceof w||s instanceof S,Dr=s=>s.replace(/~1/g,"/").replace(/~0/g,"~");function ie(s){if(s==="/")return[];if(!s.startsWith("/"))throw new Error(`Path must start with '/': ${s}`);return s.split("/").slice(1).map(Dr)}function re(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 St(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 b.OBJECT_CONTRACTS:return s.getContracts();default:return}}function ct(s,e,t=!0){if(s instanceof d){const r=St(s,e,!0,t);if(r!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties",b.OBJECT_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=re(e);return r>=0&&r<s.length?s[r]:void 0}if($(s))return s[e]}function oe(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=ct(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=ct(t,r,!1);if((typeof n!="object"||n===null||R(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)?re(r):r}}function rt(s,e){if(s instanceof d){const t=e,r=St(s,t,!1);if(r!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties",b.OBJECT_CONTRACTS].includes(t))return r;if(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e)){const n=s.getItems(),i=typeof e=="number"?e:parseInt(e,10);if(n&&i>=0&&i<n.length)return n[i]}return s.getProperties()?.[t]}return Array.isArray(s)||$(s)?s[e]:s}function P(s){if(s instanceof d)return s;if(s===null||typeof s=="string"||typeof s=="number"||typeof s=="boolean"||R(s))return g.deserialize(s);const e=ze(s);return g.deserialize(e)}function ze(s){if(s===void 0)return null;if(s===null||typeof s!="object")return s;if(Array.isArray(s))return s.map(ze);const e={};for(const[t,r]of Object.entries(s))e[t]=ze(r);return e}function st(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:P(t));return;case"itemType":s.setItemType(t instanceof d||typeof t=="string"||t===void 0?t:P(t));return;case"keyType":s.setKeyType(t instanceof d||typeof t=="string"||t===void 0?t:P(t));return;case"valueType":s.setValueType(t instanceof d||typeof t=="string"||t===void 0?t:P(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:P(t));return;case"items":s.setItems(t);return;case"properties":s.setProperties(t);return;case b.OBJECT_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:P(t));return}}}Array.isArray(s)?s.splice(re(e),1):$(s)&&(t===void 0?delete s[e]:s[e]=t)}function Mr(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(g.deserialize(null));i.push(t)}}else i.splice(n,0,t)}function we(s,e,t,r){if(Array.isArray(s)){const n=e==="-"?s.length:re(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=P(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(g.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)?Mr(s,e,P(t),r):st(s,e,t);return}if($(s)){s[e]=P(t);return}throw new Error(`Cannot insert into parent of type ${typeof s}`)}function _r(s,e){if(Array.isArray(s)){const t=re(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=re(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}}st(s,e,void 0)}else $(s)&&delete s[e]}function Ye(s){if(s instanceof d)return s.clone();if(Array.isArray(s))return s.map(t=>Ye(t));if($(s)){const e={};return Object.keys(s).forEach(t=>{e[t]=Ye(s[t])}),e}return s}function K(s,e){if(s===e||s instanceof d&&(s.isInlineValue()||s.getValue()!==void 0)&&K(s.getValue()??null,e)||e instanceof d&&(e.isInlineValue()||e.getValue()!==void 0)&&K(s,e.getValue()??null))return!0;if(s instanceof d&&e instanceof d||R(s)&&R(e)||R(s)&&typeof e=="number"||typeof s=="number"&&R(e))return s.toString()===e.toString();if(Array.isArray(s)&&Array.isArray(e))return s.length===e.length&&s.every((t,r)=>K(t,e[r]));if($(s)&&$(e)){const t=Object.keys(s),r=Object.keys(e);return t.length===r.length&&t.every(n=>K(s[n],e[n]))}return!1}function Ct(s,e){const{parent:t,key:r}=oe(s,ie(e));return rt(t,r)}function At(s,e,t){const r=ie(e);if(r.length===0&&e==="/"){const o=P(t);s.setValue(o.getValue()??null),o.getItems()?s.setItems(o.getItems()):s.setItems(void 0);return}const{parent:n,key:i}=oe(s,r);we(n,i,t,!0)}function xr(s,e,t){const r=ie(e);if(r.length===0&&e==="/"){if(s.getItems()&&Array.isArray(t)){const o=P(t);o.getItems()?(s.setItems(o.getItems()),s.setValue(null)):(s.setValue(o.getValue()??null),s.setItems(void 0))}else{const o=P(t);s.setValue(o.getValue()??null),o.getItems()&&s.setItems(o.getItems())}return!0}const{parent:n,key:i}=oe(s,r);return we(n,i,t,!1),!0}function Fr(s,e,t){const r=ie(e);if(r.length===0&&e==="/"){const l=P(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}=oe(s,r);if(o!==void 0&&n instanceof d)st(n,i,t);else{const l=rt(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}'.`);we(n,i,t,!0)}else we(n,i,t,!0)}return!0}function Vt(s,e){const t=ie(e);if(t.length===0&&e==="/")return s.setValue(null),s.setItems(void 0),s.setProperties(void 0),!0;const{parent:r,key:n}=oe(s,t);return _r(r,n),!0}function $r(s,e,t){const r=Ye(Ct(s,e));return At(s,t,r),!0}function jr(s,e,t){const r=ie(e),{parent:n,key:i}=oe(s,r),o=rt(n,i);if(o===void 0)throw new Error(`MOVE failed: 'from' location '${e}' does not exist.`);return Vt(s,e)?(At(s,t,o),!0):!1}function Lr(s,e,t){const r=Ct(s,e);let n=t;if(r instanceof d)if((t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||R(t))&&(r.isInlineValue()||r.getValue()!==void 0)){if(!K(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=P(t));else if(R(r)&&typeof t=="number")r instanceof w?n=new w(t.toString()):r instanceof S&&(n=new S(t.toString()));else if((r===null||typeof r=="string"||typeof r=="number"||typeof r=="boolean")&&R(t)){const i=t;!K(r,i.toString())&&(typeof r=="number"&&parseFloat(i.toString()))}if(!K(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 Ur(s,e){switch(e.op){case"add":return xr(s,e.path,e.val);case"replace":return Fr(s,e.path,e.val);case"remove":return Vt(s,e.path);case"copy":return $r(s,e.from,e.path);case"move":return jr(s,e.from,e.path);case"test":return Lr(s,e.path,e.val)}}function zr(s,e,t=!1){const r=t?s:s.clone();return Ur(r,e),r}const $e=Symbol.for("zod-schema-annotations");function Yr(){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 Ot(){const s=Yr();return $e in s||(s[$e]=new WeakMap),s[$e]}function Ie(s,e){const t=Ot(),r=t.get(s)||{};return t.set(s,{...r,...e}),s}const O=s=>Ot().get(s),Rt=s=>e=>{const t=O(e);return Ie(e,{...t,blueDescription:s})},Dt=s=>{const e=O(s);return u.isNonNullable(e)&&V.isString(e.blueDescription)?e.blueDescription:null},kr=s=>Rt(s)(c.z.string().optional()),Kr=c.z.union([c.z.string(),c.z.boolean()]),Mt=s=>e=>{const t=O(e);return Ie(e,{...t,blueId:s})},_t=s=>{const e=O(s),t=Kr.safeParse(e?.blueId);return t.success?t.data:null},Jr=s=>Mt(s??!0)(c.z.string()),xt=s=>e=>{const t=O(e);return Ie(e,{...t,blueName:s})},Ft=s=>{const e=O(s);return u.isNonNullable(e)&&V.isString(e.blueName)?e.blueName:null},Zr=s=>{const e=c.z.string().optional();return xt(s)(e)},$t=()=>s=>{const e=O(s);return Ie(s,{...e,blueNode:!0})},jt=s=>{const e=O(s);return u.isNonNullable(e)&&u.isNonNullable(e.blueNode)&&e.blueNode===!0?e.blueNode:null},nt=s=>!!jt(s),Gr=()=>{const s=c.z.instanceof(d);return $t()(s)},Hr=c.z.object({value:c.z.array(c.z.string()).optional(),defaultValue:c.z.string().optional()}),Lt=s=>{const e=O(s),t=Hr.passthrough().safeParse(e?.typeBlueId);return t.success?t.data:null},Wr=s=>e=>{const t=O(e),r=typeof s=="string"?{value:[s]}:s;return Ie(e,{...t,typeBlueId:{...t?.typeBlueId||{},...r}})};class de{static resolveBlueId(e){const t=Lt(e);if(u.isNullable(t))return null;const r=t.defaultValue;if(u.isNonNullable(r))return r;const n=t.value?.[0];return u.isNonNullable(n)?n:de.getRepositoryBlueId(t,e)}static getRepositoryBlueId(e,t){throw new Error("Not implemented")}}class A{static isTypeOf(e,t,r){const n=de.resolveBlueId(t),i=e.getType()?.getBlueId();if(u.isNullable(n)||u.isNullable(i))return!1;if(n===i)return!0;if(r?.checkSchemaExtensions&&u.isNonNullable(r.typeSchemaResolver)){const o=r.typeSchemaResolver.resolveSchema(e);return A.checkSchemaExtension(o,t,{typeSchemaResolver:r.typeSchemaResolver})}return!1}static checkSchemaExtension(e,t,r){if(!u.isNonNullable(e))return!1;const n=A.unwrapSchema(e),i=A.unwrapSchema(t);return u.isNonNullable(r?.typeSchemaResolver)?r.typeSchemaResolver.isSchemaExtendedFrom(n,i):!1}static isWrapperType(e){return e instanceof c.ZodOptional||e instanceof c.ZodNullable||e instanceof c.ZodReadonly||e instanceof c.ZodBranded||e instanceof c.ZodEffects||e instanceof c.ZodLazy}static unwrapSchema(e){return nt(e)?e:A.isWrapperType(e)?e instanceof c.ZodEffects?A.unwrapSchema(e.innerType()):e instanceof c.ZodLazy?A.unwrapSchema(e.schema):A.unwrapSchema(e.unwrap()):e}}function dt(s,e){const t=s.getType();if(t===void 0)return;const r=t.getBlueId();if(r!==void 0){if(q.includes(r)){const i=Ve[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 v(s,e,t){const r=I.calculateBlueIdSync(s),n=I.calculateBlueIdSync(e);if(r===n)return!0;if(r&&q.includes(r)){let a=e;for(;a!==void 0;){if(I.calculateBlueIdSync(a)===r)return!0;a=dt(a,t)}return!1}let i=s;const o=s.getBlueId();if(o){const a=t.fetchByBlueId(o);a&&a.length===1&&(i=a[0])}let l=i;for(;l!==void 0;){if(I.calculateBlueIdSync(l)===n)return!0;l=dt(l,t)}return!1}function qr(s,e){return Xe.some(t=>{const r=new d().setBlueId(t);return v(s,r,e)})}function Xr(s,e){const t=new d().setBlueId(j);return v(s,t,e)}function Qr(s,e){const t=new d().setBlueId(U);return v(s,t,e)}function es(s,e){const t=new d().setBlueId(L);return v(s,t,e)}function ts(s,e){const t=new d().setBlueId(z);return v(s,t,e)}function Ut(s,e){const t=new d().setBlueId(We);return v(s,t,e)}function zt(s,e){const t=new d().setBlueId(qe);return v(s,t,e)}function rs(s,e){return Ae.some(t=>{const r=new d().setName(t);return v(s,r,e)})}function ss(s,e){for(const t of Ae){const r=new d().setName(t);if(v(s,r,e))return t}throw new Error(`Cannot determine the basic type for node of type "${s.getName()||"unknown"}".`)}class Yt{blueIdMap=new Map;nodeProvider;constructor(e=[],t){this.nodeProvider=t?.nodeProvider??null,this.registerSchemas(e)}registerSchemas(e){for(const t of e)this.registerSchema(t)}registerSchema(e){const t=de.resolveBlueId(e);if(u.isNonNullable(t)){if(this.blueIdMap.has(t))throw new Error(`Duplicate BlueId value: ${t}`);this.blueIdMap.set(t,e)}}setNodeProvider(e){this.nodeProvider=e}resolveSchema(e){const t=this.getEffectiveBlueId(e);return u.isNullable(t)?null:this.blueIdMap.get(t)}isSchemaExtendedFrom(e,t){if(u.isNullable(e))return!1;const r=this.getBlueIdForSchema(e),n=this.getBlueIdForSchema(t);if(u.isNullable(r)||u.isNullable(n))return!1;if(r===n)return!0;if(u.isNonNullable(this.nodeProvider))try{const i=new d().setBlueId(r),o=new d().setBlueId(n);if(v(i,o,this.nodeProvider))return!0}catch{}return!1}getBlueIdForSchema(e){if(u.isNullable(e))return null;const t=de.resolveBlueId(e);if(u.isNonNullable(t))return t;for(const[r,n]of this.blueIdMap)if(n===e||n._def===e._def)return r;return null}getEffectiveBlueId(e){const t=e.getType();return u.isNonNullable(t)&&u.isNonNullable(t.getBlueId())?t.getBlueId():u.isNonNullable(t)?I.calculateBlueIdSync(t):null}getBlueIdMap(){return new Map(this.blueIdMap)}}const E={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 Oe{static isEmptyNode(e){return this.hasFieldsAndMayHaveFields(e)}static hasBlueIdOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([E.BLUE_ID]))}static hasItemsOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([E.ITEMS]))}static isValidValueNode(e){const t=e.getValue(),r=e.getProperties(),n=e.getItems();return u.isNonNullable(t)&&u.isNullable(r)&&u.isNullable(n)}static textNode(e){return new d().setType(new d().setBlueId(j)).setValue(e)}static integerNode(e){const t=e instanceof w?e:new w(e.toString());return new d().setType(new d().setBlueId(U)).setValue(t)}static doubleNode(e){const t=e instanceof S?e:new S(e.toString());return new d().setType(new d().setBlueId(L)).setValue(t)}static booleanNode(e){return new d().setType(new d().setBlueId(z)).setValue(e)}static hasFieldsAndMayHaveFields(e,t=new Set,r=new Set){for(const n of Object.values(E)){const i=u.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 E.NAME:return e.getName();case E.TYPE:return e.getType();case E.VALUE:return e.getValue();case E.DESCRIPTION:return e.getDescription();case E.PROPERTIES:return e.getProperties();case E.BLUE:return e.getBlue();case E.ITEMS:return e.getItems();case E.KEY_TYPE:return e.getKeyType();case E.VALUE_TYPE:return e.getValueType();case E.ITEM_TYPE:return e.getItemType();case E.BLUE_ID:return e.getBlueId();default:throw new Error(`Unknown field: ${t}`)}}}class Re{}class le{static convert(e){const t=new ke;return le.traverseNode(e,"",t),t.build()}static traverseNode(e,t,r){if(!e)return;const n=e.getProperties(),i=e.getItems(),o=n!==void 0&&Object.keys(n).length>0,l=i!==void 0&&i.length>0;if(!o&&!l){r.addPath(t===""?"/":t);return}if(n)for(const[a,p]of Object.entries(n)){const y=`${t}/${a}`;le.traverseNode(p,y,r)}if(i)for(let a=0;a<i.length;a++){const p=`${t}/${a}`;le.traverseNode(i[a],p,r)}}}function pt(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 De extends Re{allowedPaths;maxDepth;currentPath=[];constructor(e,t){super(),this.allowedPaths=e,this.maxDepth=t}shouldExtendPathSegment(e){if(this.currentPath.length>=this.maxDepth)return!1;const t=this.normalizePath(this.getCurrentFullPath()+"/"+e);return this.isAllowedPath(t)}shouldMergePathSegment(e){return this.shouldExtendPathSegment(e)}isAllowedPath(e){for(const t of this.allowedPaths)if(this.matchesAllowedPath(t,e))return!0;return!1}matchesAllowedPath(e,t){const r=pt(e,"/"),n=pt(t,"/");if(n.length>r.length)return!1;for(let i=1;i<n.length;i++)if(r[i]!=="*"&&r[i]!==n[i])return!1;return!0}enterPathSegment(e){this.currentPath.push(e)}exitPathSegment(){this.currentPath.length>0&&this.currentPath.pop()}getCurrentFullPath(){return"/"+this.currentPath.join("/")}normalizePath(e){return"/"+e.split("/").filter(t=>t!=="").join("/")}static withMaxDepth(e){const t=new ke().setMaxDepth(e);for(let r=1;r<=e;r++){const n="/"+Array(r).fill("*").join("/");t.addPath(n)}return t.build()}static withSinglePath(e){return new ke().addPath(e).build()}static fromNode(e){return le.convert(e)}}class ke{allowedPaths=new Set;maxDepth=Number.MAX_SAFE_INTEGER;addPath(e){return this.allowedPaths.add(e),this}setMaxDepth(e){return this.maxDepth=e,this}build(){return new De(this.allowedPaths,this.maxDepth)}}class ns extends Re{shouldExtendPathSegment(){return!0}shouldMergePathSegment(){return!0}enterPathSegment(){}exitPathSegment(){}}class Me extends Re{limits;constructor(e){super(),this.limits=e}shouldExtendPathSegment(e,t){return this.limits.every(r=>r.shouldExtendPathSegment(e,t))}shouldMergePathSegment(e,t){return this.limits.every(r=>r.shouldMergePathSegment(e,t))}enterPathSegment(e,t){this.limits.forEach(r=>{r.enterPathSegment(e,t)})}exitPathSegment(){this.limits.forEach(e=>{e.exitPathSegment()})}static of(...e){return new Me(e)}}const k=new ns;class is{blue;constructor(e){this.blue=e}matchesType(e,t,r=k){const n=t.getType();if(this.matchesImplicitStructure(e,n))return!0;const i=De.fromNode(t),o=Me.of(r,i),l=this.extendAndResolve(e,o),a=this.blue.resolve(t,o);return this.verifyMatch(l,t,o)&&this.recursiveValueComparison(l,a)}extendAndResolve(e,t){const r=e.clone(),n=r.clone();this.blue.extend(n,t);const i=this.blue.resolve(n,t);return this.restoreMissingStructure(i,r),i}restoreMissingStructure(e,t){const r=t.getItems(),n=e.getItems();if(r&&r.length>0)if(!n||n.length===0)e.setItems(r.map(a=>a.clone()));else for(let a=0;a<Math.min(n.length,r.length);a++)this.restoreMissingStructure(n[a],r[a]);const i=t.getProperties();if(i){let a=e.getProperties();a||(a={},e.setProperties(a));for(const[p,y]of Object.entries(i)){const f=a[p];f===void 0?a[p]=y.clone():this.restoreMissingStructure(f,y)}}const o=t.getBlueId();e.getBlueId()===void 0&&o!==void 0&&e.setBlueId(o);const l=t.getValue();e.getValue()===void 0&&l!==void 0&&e.setValue(l)}verifyMatch(e,t,r){const n=t.getType();if(this.matchesImplicitStructure(e,n))return!0;const i=e.clone().setType(t.clone());try{this.blue.resolve(i,r)}catch{return!1}return!0}recursiveValueComparison(e,t){const r=t.getType(),n=this.matchesImplicitStructure(e,r);if(r&&!n){const f=e.getType();if(!f||!v(f,r,this.blue.getNodeProvider()))return!1}const i=t.getBlueId();if(!n&&i!==void 0){const f=e.getBlueId(),h=e.getType()?.getBlueId();if(f!==void 0){if(i!==f)return!1}else if(h===void 0||i!==h)return!1}const o=t.getValue();if(o!==void 0){const f=e.getValue();if(f===void 0)return!1;if(C(f)&&C(o)){if(!f.eq(o))return!1}else if(f!==o)return!1}const l=t.getItems();if(l!==void 0){const f=e.getItems()??[];for(let h=0;h<l.length;h++)if(h<f.length){if(!this.recursiveValueComparison(f[h],l[h]))return!1}else if(this.hasValueInNestedStructure(l[h]))return!1}const a=t.getItemType();if(a!==void 0){const f=e.getItems()??[];for(const h of f)if(!this.recursiveValueComparison(h,a))return!1}const p=t.getProperties();if(p!==void 0){const f=e.getProperties()??{};for(const[h,T]of Object.entries(p))if(h in f){if(!this.recursiveValueComparison(f[h],T))return!1}else if(this.hasValueInNestedStructure(T))return!1}const y=t.getValueType();if(y!==void 0){const f=Object.values(e.getProperties()??{});for(const h of f)if(!this.recursiveValueComparison(h,y))return!1}return!0}hasValueInNestedStructure(e){if(e.getValue()!==void 0)return!0;const t=e.getItems();if(t!==void 0){for(const n of t)if(this.hasValueInNestedStructure(n))return!0}const r=e.getProperties();if(r!==void 0){for(const n of Object.values(r))if(this.hasValueInNestedStructure(n))return!0}return!1}matchesImplicitStructure(e,t){return t===void 0||e.getType()!==void 0?!1:Ut(t,this.blue.getNodeProvider())?this.isImplicitListStructure(e):zt(t,this.blue.getNodeProvider())?this.isImplicitDictionaryStructure(e):!1}isImplicitListStructure(e){return e.getItems()!==void 0&&e.getValue()===void 0}isImplicitDictionaryStructure(e){return e.getProperties()!==void 0&&e.getValue()===void 0}}const os=s=>s instanceof c.ZodOptional||s instanceof c.ZodNullable||s instanceof c.ZodReadonly||s instanceof c.ZodBranded||s instanceof c.ZodEffects||s instanceof c.ZodLazy,ls=s=>s instanceof c.ZodString||s instanceof c.ZodNumber||s instanceof c.ZodBoolean||s instanceof c.ZodBigInt;class kt{static convertValue(e,t){const r=e.getType()?.getBlueId(),n=e.getValue();return u.isNullable(n)?ls(t)&&Oe.isValidValueNode(e)?this.getDefaultPrimitiveValue(t):n:j===r?this.convertFromString(String(n),t):L===r||n instanceof S?this.convertFromBigDecimal(new S(n?.toString()),t):U===r||n instanceof w?this.convertFromBigInteger(new w(n?.toString()),t):z===r||typeof n=="boolean"?this.convertFromBoolean(!!n,t):this.convertFromString(String(n),t)}static convertFromString(e,t){if(!t||t instanceof c.ZodString||t instanceof c.ZodEnum||t instanceof c.ZodNativeEnum)return e;if(t instanceof c.ZodNumber)return Number(e);if(t instanceof c.ZodBoolean)return e.toLowerCase()==="true";if(t instanceof c.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert String to ${t._def.typeName}`)}static convertFromBigDecimal(e,t){if(t instanceof c.ZodNumber)return e.toNumber();if(t instanceof c.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBigInteger(e,t){if(t instanceof c.ZodNumber)return e.toNumber();if(t instanceof c.ZodBigInt)return BigInt(e.toString());if(t instanceof c.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBoolean(e,t){if(!t||t instanceof c.ZodBoolean)return e;if(t instanceof c.ZodString)return e.toString();if(t instanceof c.ZodNumber)return Number(e);if(t instanceof c.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert Boolean to ${t._def.typeName}`)}static getDefaultPrimitiveValue(e){if(!e)return null;if(e instanceof c.ZodNumber)return 0;if(e instanceof c.ZodBoolean)return!1;if(e instanceof c.ZodString)return"";throw new Error(`Unsupported primitive type: ${e._def.typeName}`)}}class as{convert(e,t){return kt.convertValue(e,t)}}class us{constructor(e){this.nodeToObjectConverter=e}convert(e,t){return this.convertFields(e,t)}convertFields(e,t){if(t instanceof c.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 c.ZodUnion)throw new Error("Union not supported");if(t instanceof c.ZodObject)return Object.keys(t.shape).reduce((n,i)=>{const o=e.getProperties(),l=t.shape[i],a=_t(l);if(u.isNonNullable(a)){const T=V.isString(a)?a:i,Y=o?.[T],X=Y?I.calculateBlueIdSync(Y):void 0;return n[i]=X,n}const p=Ft(l);if(u.isNonNullable(p)){const T=o?.[p];return n[i]=T?.getName(),n}const y=Dt(l);if(u.isNonNullable(y)){const T=o?.[y];return n[i]=T?.getDescription(),n}if(i==="name"){const T=e.getName();return n[i]=T,n}if(i==="description"){const T=e.getDescription();return n[i]=T,n}const f=o?.[i];if(u.isNullable(f))return n;const h=this.nodeToObjectConverter.convert(f,l);return n[i]=h,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 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 ps{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const r=t.keySchema,n=t.valueSchema,i=new Map,o=e.getName();u.isNonNullable(o)&&i.set(Z,o);const l=e.getDescription();u.isNonNullable(l)&&i.set(G,l);const a=e.getProperties();return u.isNonNullable(a)&&Object.entries(a).forEach(([p,y])=>{const f=new d().setValue(p);f.setType(new d().setBlueId(j));const h=kt.convertValue(f,r),T=this.nodeToObjectConverter.convert(y,n);i.set(h,T)}),t instanceof c.ZodRecord?Object.fromEntries(i):i}}class fs{convert(e){return m.get(e)}}class hs{convert(e){return m.get(e)}}class ys{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=c.z.union([c.z.literal("ZodString"),c.z.literal("ZodNumber"),c.z.literal("ZodBoolean"),c.z.literal("ZodBigInt"),c.z.literal("ZodArray"),c.z.literal("ZodSet"),c.z.literal("ZodMap"),c.z.literal("ZodRecord"),c.z.literal("ZodObject"),c.z.literal("ZodEnum"),c.z.literal("ZodNativeEnum"),c.z.literal("ZodUnknown"),c.z.literal("ZodAny"),c.z.literal("ZodTuple")]);class ms{constructor(e){this.nodeToObjectConverter=e,this.registerConverters(),this.complexObjectConverter=new us(this.nodeToObjectConverter)}converters=new Map;complexObjectConverter;registerConverters(){const e=new as,t=new cs(this.nodeToObjectConverter),r=new ys(this.nodeToObjectConverter),n=new ds(this.nodeToObjectConverter),i=new ps(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 fs),this.converters.set("ZodAny",new hs),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 c.ZodEffects?this.getSchemaTypeName(e.innerType()):e instanceof c.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 Is{constructor(e){this.typeSchemaResolver=e,this.converterFactory=new ms(this)}converterFactory;convert(e,t){const r=this.typeSchemaResolver?.resolveSchema(e),n=A.unwrapSchema(t);if(nt(n))return e;let i=n;return A.checkSchemaExtension(r,n,{typeSchemaResolver:this.typeSchemaResolver})&&u.isNonNullable(r)&&(i=r),this.convertWithType(e,i)}convertWithType(e,t){return this.converterFactory.getConverter(t).convert(e,t)}}class Kt{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 u.isNonNullable(e.getBlueId())&&u.isNonNullable(t?.getBlueId())&&e.getBlueId()===t.getBlueId()}reverseBasicProperties(e,t,r){const n=t.getValue();u.isNonNullable(n)&&(u.isNullable(r)||u.isNullable(r.getValue()))&&e.setValue(n),u.isNonNullable(t.getName())&&(u.isNullable(r)||t.getName()!==r.getName())&&e.setName(t.getName()),u.isNonNullable(t.getDescription())&&(u.isNullable(r)||t.getDescription()!==r.getDescription())&&e.setDescription(t.getDescription()),u.isNonNullable(t.getBlueId())&&(u.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?.getBlueId();u.isNonNullable(p)&&(u.isNullable(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(u.isNullable(n))return;const i=r?.getItems(),o=[];if(u.isNonNullable(i)&&i.length>0){const a=I.calculateBlueIdSync(i);o.push(new d().setBlueId(a))}const l=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(u.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),Oe.isEmptyNode(p)||(i[o]=p)}Object.keys(i).length>0&&e.setProperties(i)}getInheritedProperty(e,t,r){const n=r?.getProperties()?.[e],i=t.getType()?.getProperties()?.[e];if(!(u.isNullable(n)&&u.isNullable(i)))return u.isNullable(n)?i:u.isNullable(i)?n:this.mergeNodes(n,i)}mergeNodes(e,t){const r=e.clone(),n=t.getValue();u.isNonNullable(n)&&r.setValue(n);const i=t.getType();u.isNonNullable(i)&&r.setType(i.clone());const o=t.getItemType();u.isNonNullable(o)&&r.setItemType(o.clone());const l=t.getKeyType();u.isNonNullable(l)&&r.setKeyType(l.clone());const a=t.getValueType();u.isNonNullable(a)&&r.setValueType(a.clone());const p=t.getProperties();if(u.isNonNullable(p)){const f=r.getProperties()||{};for(const[h,T]of Object.entries(p))f[h]=T.clone();r.setProperties(f)}const y=t.getItems();return u.isNonNullable(y)&&r.setItems(y.map(f=>f.clone())),r}}class se extends d{constructor(e){super(e.getName()),this.createFrom(e)}isResolved(){return!0}getMinimalNode(){return new Kt().reverse(this)}getMinimalBlueId(){const e=this.getMinimalNode();return I.calculateBlueIdSync(e)}clone(){const e=super.clone();return new se(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 Te{fetchFirstByBlueId(e){const t=this.fetchByBlueId(e);return t&&t.length>0?t[0]:null}}function Ts(s){return new class extends Te{fetchByBlueId(e){return s(e)}}}const je=W.types.float.options,bs={...je,construct:s=>{const e=s.replace(/_/g,"").toLowerCase();if(!u.isPreciseNumberString(e))return new S(e);if(je.construct)return je.construct(s)}},Ns=new W.Type("tag:yaml.org,2002:float",bs),Le=W.types.int.options,vs={...Le,construct:s=>{let e=s;if(e.indexOf("_")!==-1&&(e=e.replace(/_/g,"")),!u.isPreciseNumberString(e))return new w(e);if(Le.construct)return Le.construct(s)}},Bs=new W.Type("tag:yaml.org,2002:int",vs),Jt=W.CORE_SCHEMA.extend({implicit:[Ns,Bs]}),D=s=>{const e=W.load(s,{schema:Jt});return e===void 0?void 0:e},Zt=s=>W.dump(s,{schema:Jt,replacer:(e,t)=>{if(C(t)){if(F(t)){const r=new _(Number.MIN_SAFE_INTEGER.toString()),n=new _(Number.MAX_SAFE_INTEGER.toString());if(t.lt(r)||t.gt(n))return t.toString()}return t.toNumber()}return t}});class ws{static get(e,t={}){const{strategy:r="official"}=t,n=m.get(e,r);return Zt(n)}}class Es extends Te{nodeProviders;constructor(e){super(),this.nodeProviders=e}fetchByBlueId(e){for(const t of this.nodeProviders){const r=t.fetchByBlueId(e);if(r&&r.length>0)return r}return[]}fetchFirstByBlueId(e){for(const t of this.nodeProviders){const r=t.fetchFirstByBlueId(e);if(r)return r}return null}getNodeProviders(){return this.nodeProviders}}const Gt=`- type:
2
2
  blueId: 27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo
3
3
  mappings:
4
4
  Text: DLRQwz7MQeCrzjy9bohPNwtCxKEBbKaMK65KBrwjfG6K
@@ -9,14 +9,14 @@
9
9
  Dictionary: G7fBT9PSod1RfHLHkpafAGBDVAJMrMhAMY51ERcyXNrj
10
10
  - type:
11
11
  blueId: FGYuTXwaoSKfZmpTysLTLsb8WzSqf43384rKZDkXhxD4
12
- `,Ss=`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
16
  description: This transformation infers type details for Text, Integer, Number and Boolean.`,Cs=`name: Replace Inline Types with BlueIds
17
17
  type:
18
18
  blueId: Ct1SGRGw1i47qjzm1ruiUdSZofeV6WevPTGuieVvbRS4
19
- description: This transformation replaces`,As=[Gt,Ss,Ps,Cs];class Vs extends Te{blueIdToNodesMap=new Map;constructor(){super(),this.load()}fetchByBlueId(e){return this.blueIdToNodesMap.get(e)||[]}load(){for(const e of As){const t=D(e);if(t===void 0){console.error(`This content file is not valid YAML: ${e}`);continue}if(Array.isArray(t)){const r=t.map(i=>g.deserialize(i)),n=I.calculateBlueIdSync(r);this.blueIdToNodesMap.set(n,r)}else{const r=g.deserialize(t),n=I.calculateBlueIdSync(r);this.blueIdToNodesMap.set(n,[r])}}}}class it extends Te{static INSTANCE=new it;nodeProvider;constructor(){super(),this.nodeProvider=new Vs}fetchByBlueId(e){return this.nodeProvider.fetchByBlueId(e)}}class Ue{constructor(e,t,r){this.blueId=e,this.content=t,this.isMultipleDocuments=r}}class J{static THIS_REFERENCE_PATTERN=/^this(#\d+)?$/;static parseAndCalculateBlueId(e,t){let r;try{const l=D(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=g.deserialize(a);return t(p)});n=I.calculateBlueIdSync(l),i=l.map(a=>m.get(a))}else{const l=g.deserialize(r),a=t(l);n=I.calculateBlueIdSync(a),i=m.get(a)}return new Ue(n,i,o)}static parseAndCalculateBlueIdForNode(e,t){const r=t(e),n=I.calculateBlueIdSync(r),i=m.get(r);return new Ue(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=I.calculateBlueIdSync(r),i=r.map(l=>m.get(l)),o=e.length>1;return new Ue(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>'")}}}class Rs extends Te{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=J.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=g.deserialize(a);return p.setBlueId(e),[p]}else if(l===0){const a=g.deserialize(i);return a.setBlueId(e),[a]}else return null}}if(Array.isArray(i))return i.map(o=>g.deserialize(o));{const o=g.deserialize(i);return o.setBlueId(t),[o]}}}class Ht extends Rs{nameToBlueIdsMap=new Map;findNodeByName(e){const t=this.nameToBlueIdsMap.get(e);if(!t)return;if(t.length>1)throw new Error(`Multiple nodes found with name: ${e}`);const r=this.fetchByBlueId(t[0]);return r&&r.length>0?r[0]:void 0}findAllNodesByName(e){const t=this.nameToBlueIdsMap.get(e);if(!t)return[];const r=[];for(const n of t){const i=this.fetchByBlueId(n);i&&r.push(...i)}return r}addToNameMap(e,t){this.nameToBlueIdsMap.set(e,[...this.nameToBlueIdsMap.get(e)||[],t])}}const Wt=s=>s instanceof d||Array.isArray(s)&&s.every(e=>e instanceof d)?s:V.isArray(s)?s.map(e=>g.deserialize(e)):g.deserialize(s),qt=async s=>{const e=Wt(s);return I.calculateBlueId(e)},Os=s=>{const e=Wt(s);return I.calculateBlueIdSync(e)},Ke=async s=>{if(vt(s))return s;try{const e=ce.parse(s),t=await qt(e);return{...s,blueId:t}}catch(e){throw new Error(`Failed enriching object with Blue ID: ${e}`)}},Ds=s=>s?.items,Ms=s=>s?.value,_s=s=>u.isNullable(s)?{}:V.omit(s,Ge),xs=s=>wt(s)?s.type.name??null:Et(s)?V.pascal(typeof s.value):Bt(s)?"List":null,Xt=s=>u.isNonNullable(s)&&Object.keys(V.omit(s,["blueId"])).length>0,Fs=s=>{try{const e=g.deserialize(s),t=m.get(e);return te.parse(t)}catch(e){throw new Error(`Failed transforming JSON-like value to BlueObject: ${e}`)}},Je=async s=>{const{resolveFunction:e,signal:t=new AbortController().signal,omitItems:r}=s,n=s.count??s.items.length;let i=await V.map(s.items,async l=>await Ke(l));const o=Math.max(i?.length-n,0);for(let l=i.length-1;l>=o;l--)if(!Xt(i[l])){const a=await e(i[l],{signal:t});if(Array.isArray(a))return Je({...s,items:[...i.slice(0,l),...a,...i.slice(l+1)]});const p=await Ke(a);if(r?.includes(p.blueId))return Je({...s,items:[...i.slice(0,l),...i.slice(l+1)]});i=[...i.slice(0,l),p,...i.slice(l+1)]}return i};function ae(s){try{const e=new URL(s);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}class $s{process(e){return B.transform(e,this.inferType.bind(this))}inferType(e){const t=e.getType(),r=e.getValue();return u.isNullable(t)&&u.isNonNullable(r)&&(typeof r=="string"?e.setType(new d().setBlueId(j)):typeof r=="bigint"||F(r)?e.setType(new d().setBlueId(U)):ve(r)?e.setType(new d().setBlueId(L)):typeof r=="boolean"&&e.setType(new d().setBlueId(z))),e}}class Ee{static MAPPINGS="mappings";mappings=new Map;constructor(e){if(e instanceof d){const r=e.getProperties();if(r&&r[Ee.MAPPINGS]){const i=r[Ee.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 B.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)}}}}}class js{process(e){return B.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 ot{nodeProvider;strategy;constructor(e,t){this.nodeProvider=pe.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&&!q.includes(i)){const h=this.fetchNode(e);if(h&&h.length>0)if(h.length===1){const T=h[0];this.mergeNodes(e,T)}else{const T=h.map(X=>X.clone()),Y=new d().setItems(T);this.mergeNodes(e,Y)}}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 y=e.getProperties();y&&Object.entries(y).forEach(([h,T])=>{this.extendNode(T,t,h,!1)});const f=e.getItems();if(f&&f.length>0){this.reconstructList(f);for(let h=0;h<f.length;h++)this.extendNode(f[h],t,String(h),!1)}}finally{n||t.exitPathSegment()}}reconstructList(e){for(;e.length>0;){const r=e[0]?.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();u.isNonNullable(r)&&e.setValue(r),e.setItems(t.getItems()),e.setProperties(t.getProperties())}}class lt{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`,As=[Gt,Ps,Ss,Cs];class Vs extends Te{blueIdToNodesMap=new Map;constructor(){super(),this.load()}fetchByBlueId(e){return this.blueIdToNodesMap.get(e)||[]}load(){for(const e of As){const t=D(e);if(t===void 0){console.error(`This content file is not valid YAML: ${e}`);continue}if(Array.isArray(t)){const r=t.map(i=>g.deserialize(i)),n=I.calculateBlueIdSync(r);this.blueIdToNodesMap.set(n,r)}else{const r=g.deserialize(t),n=I.calculateBlueIdSync(r);this.blueIdToNodesMap.set(n,[r])}}}}class it extends Te{static INSTANCE=new it;nodeProvider;constructor(){super(),this.nodeProvider=new Vs}fetchByBlueId(e){return this.nodeProvider.fetchByBlueId(e)}}class Ue{constructor(e,t,r){this.blueId=e,this.content=t,this.isMultipleDocuments=r}}class J{static THIS_REFERENCE_PATTERN=/^this(#\d+)?$/;static parseAndCalculateBlueId(e,t){let r;try{const l=D(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=g.deserialize(a);return t(p)});n=I.calculateBlueIdSync(l),i=l.map(a=>m.get(a))}else{const l=g.deserialize(r),a=t(l);n=I.calculateBlueIdSync(a),i=m.get(a)}return new Ue(n,i,o)}static parseAndCalculateBlueIdForNode(e,t){const r=t(e),n=I.calculateBlueIdSync(r),i=m.get(r);return new Ue(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=I.calculateBlueIdSync(r),i=r.map(l=>m.get(l)),o=e.length>1;return new Ue(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>'")}}}class Os extends Te{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=J.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=g.deserialize(a);return p.setBlueId(e),[p]}else if(l===0){const a=g.deserialize(i);return a.setBlueId(e),[a]}else return null}}if(Array.isArray(i))return i.map(o=>g.deserialize(o));{const o=g.deserialize(i);return o.setBlueId(t),[o]}}}class Ht extends Os{nameToBlueIdsMap=new Map;findNodeByName(e){const t=this.nameToBlueIdsMap.get(e);if(!t)return;if(t.length>1)throw new Error(`Multiple nodes found with name: ${e}`);const r=this.fetchByBlueId(t[0]);return r&&r.length>0?r[0]:void 0}findAllNodesByName(e){const t=this.nameToBlueIdsMap.get(e);if(!t)return[];const r=[];for(const n of t){const i=this.fetchByBlueId(n);i&&r.push(...i)}return r}addToNameMap(e,t){this.nameToBlueIdsMap.set(e,[...this.nameToBlueIdsMap.get(e)||[],t])}}const Wt=s=>s instanceof d||Array.isArray(s)&&s.every(e=>e instanceof d)?s:V.isArray(s)?s.map(e=>g.deserialize(e)):g.deserialize(s),qt=async s=>{const e=Wt(s);return I.calculateBlueId(e)},Rs=s=>{const e=Wt(s);return I.calculateBlueIdSync(e)},Ke=async s=>{if(vt(s))return s;try{const e=ce.parse(s),t=await qt(e);return{...s,blueId:t}}catch(e){throw new Error(`Failed enriching object with Blue ID: ${e}`)}},Ds=s=>s?.items,Ms=s=>s?.value,_s=s=>u.isNullable(s)?{}:V.omit(s,Ge),xs=s=>wt(s)?s.type.name??null:Et(s)?V.pascal(typeof s.value):Bt(s)?"List":null,Xt=s=>u.isNonNullable(s)&&Object.keys(V.omit(s,["blueId"])).length>0,Fs=s=>{try{const e=g.deserialize(s),t=m.get(e);return te.parse(t)}catch(e){throw new Error(`Failed transforming JSON-like value to BlueObject: ${e}`)}},Je=async s=>{const{resolveFunction:e,signal:t=new AbortController().signal,omitItems:r}=s,n=s.count??s.items.length;let i=await V.map(s.items,async l=>await Ke(l));const o=Math.max(i?.length-n,0);for(let l=i.length-1;l>=o;l--)if(!Xt(i[l])){const a=await e(i[l],{signal:t});if(Array.isArray(a))return Je({...s,items:[...i.slice(0,l),...a,...i.slice(l+1)]});const p=await Ke(a);if(r?.includes(p.blueId))return Je({...s,items:[...i.slice(0,l),...i.slice(l+1)]});i=[...i.slice(0,l),p,...i.slice(l+1)]}return i};function ae(s){try{const e=new URL(s);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}class $s{process(e){return B.transform(e,this.inferType.bind(this))}inferType(e){const t=e.getType(),r=e.getValue();return u.isNullable(t)&&u.isNonNullable(r)&&(typeof r=="string"?e.setType(new d().setBlueId(j)):typeof r=="bigint"||F(r)?e.setType(new d().setBlueId(U)):ve(r)?e.setType(new d().setBlueId(L)):typeof r=="boolean"&&e.setType(new d().setBlueId(z))),e}}class Ee{static MAPPINGS="mappings";mappings=new Map;constructor(e){if(e instanceof d){const r=e.getProperties();if(r&&r[Ee.MAPPINGS]){const i=r[Ee.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 B.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)}}}}}class js{process(e){return B.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 ot{nodeProvider;strategy;constructor(e,t){this.nodeProvider=pe.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&&!q.includes(i)){const h=this.fetchNode(e);if(h&&h.length>0)if(h.length===1){const T=h[0];this.mergeNodes(e,T)}else{const T=h.map(X=>X.clone()),Y=new d().setItems(T);this.mergeNodes(e,Y)}}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 y=e.getProperties();y&&Object.entries(y).forEach(([h,T])=>{this.extendNode(T,t,h,!1)});const f=e.getItems();if(f&&f.length>0){this.reconstructList(f);for(let h=0;h<f.length;h++)this.extendNode(f[h],t,String(h),!1)}}finally{n||t.exitPathSegment()}}reconstructList(e){for(;e.length>0;){const r=e[0]?.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();u.isNonNullable(r)&&e.setValue(r),e.setItems(t.getItems()),e.setProperties(t.getProperties())}}class lt{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:
@@ -24,4 +24,4 @@ ${r}`}getAllBlueIds(){const e={};for(const t of this.blueIdsCollections)Object.a
24
24
  ${e}
25
25
  ${t}
26
26
  `}loadDefaultSimpleBlue(){try{const e=this.enrichDefaultBlue(Gt),t=D(e);if(t)this.defaultSimpleBlue=g.deserialize(t);else throw new Error("Failed to parse default Blue content")}catch(e){throw new Error(`Error loading default Blue: ${e}`)}}}class at extends Ht{blueIdToContentMap=new Map;blueIdToMultipleDocumentsMap=new Map;preprocessor;constructor(e){super();const t=new lt,r=at.collectAliasMappings(e);Object.keys(r).length>0&&t.registerBlueIds(r);const n=new ne({nodeProvider:this,blueIdsMappingGenerator:t});this.preprocessor=i=>n.preprocessWithDefaultBlue(i),this.loadRepositories(e)}static collectAliasMappings(e){const t={};for(const r of e)for(const n of Object.values(r.packages))for(const[i,o]of Object.entries(n.aliases)){const l=t[i];if(l&&l!==o)throw new Error(`Conflicting alias mapping for ${i}`);t[i]=o}return t}loadRepositories(e){for(const t of e)Object.values(t.packages).forEach(r=>{for(const[n,i]of Object.entries(r.contents))this.processContent(i,n)})}processContent(e,t){Array.isArray(e)?this.processMultipleDocuments(e,t):this.processSingleDocument(e,t)}processSingleDocument(e,t){const r=g.deserialize(e),n=J.parseAndCalculateBlueIdForNode(r,this.preprocessor),i=t||n.blueId;this.blueIdToContentMap.set(i,n.content),this.blueIdToMultipleDocumentsMap.set(i,!1);const o=r.getName();o&&this.addToNameMap(o,i)}processMultipleDocuments(e,t){const r=e.map(o=>{const l=g.deserialize(o);return this.preprocessor(l)}),n=J.parseAndCalculateBlueIdForNodeList(r,o=>o),i=t||n.blueId;this.blueIdToContentMap.set(i,n.content),this.blueIdToMultipleDocumentsMap.set(i,!0),r.forEach((o,l)=>{const a=`${i}#${l}`,p=m.get(o),y=I.calculateBlueIdSync(o);this.blueIdToContentMap.set(y,p),this.blueIdToMultipleDocumentsMap.set(y,!1);const f=o.getName();f&&this.addToNameMap(f,a)})}fetchContentByBlueId(e){const t=this.blueIdToContentMap.get(e),r=this.blueIdToMultipleDocumentsMap.get(e);return t!==void 0&&r!==void 0?J.resolveThisReferences(t,e,r):null}getBlueIds(){return Array.from(this.blueIdToContentMap.keys())}hasBlueId(e){const t=e.split("#")[0];return this.blueIdToContentMap.has(t)}}class pe{static wrap(e,t){const r=[it.INSTANCE];if(t&&t.length>0){const n=new at(t);r.push(n)}return r.push(e),new Es(r)}}class Ls{preprocessingAliases=new Map;urlContentFetcher;constructor(e,t){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(Ne.isPotentialBlueId(t))return this.handleBlueId(r,t);throw ae(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(Ne.isPotentialBlueId(t))return this.handleBlueId(r,t);if(ae(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 ae(t)?new Error(`UrlContentFetcher not provided for URL: ${t}`):new Error(`Invalid blue value: ${t}`)}return e}getBlueNodeValue(e){const r=e.getBlue()?.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 zs{cache=new Map;fetchStrategy;enabled=!1;allowedDomains=[];constructor(e){this.fetchStrategy=e||Us}validateUrl(e){if(!ae(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=D(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=>g.deserialize(l)):o=[g.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 Qt{resolveWithoutLimits(e){return this.resolve(e,k)}}class er extends Qt{mergingProcessor;nodeProvider;constructor(e,t){super(),this.mergingProcessor=e,this.nodeProvider=pe.wrap(t)}merge(e,t,r){if(u.isNonNullable(t.getBlue()))throw new Error('Document contains "blue" attribute. Preprocess document before merging.');let n=e;const i=t.getType();if(u.isNonNullable(i)){const o=i.clone();u.isNonNullable(o.getBlueId())&&new ot(this.nodeProvider).extend(o,De.withSinglePath("/"));const l=this.resolve(o,r),a=t.clone().setType(l);return n=this.merge(n,o,r),this.mergeObject(n,a,r)}return this.mergeObject(n,t,r)}mergeObject(e,t,r){let n=this.mergingProcessor.process(e,t,this.nodeProvider);const i=t.getItems();u.isNonNullable(i)&&(n=this.mergeChildren(n,i,r));const o=t.getProperties();return u.isNonNullable(o)&&Object.entries(o).forEach(([l,a])=>{r.shouldMergePathSegment(l,a)&&(r.enterPathSegment(l,a),n=this.mergeProperty(n,l,a,r),r.exitPathSegment())}),u.isNonNullable(t.getBlueId())&&(n=n.clone().setBlueId(t.getBlueId())),this.mergingProcessor.postProcess&&(n=this.mergingProcessor.postProcess(n,t,this.nodeProvider)),n}mergeChildren(e,t,r){const n=e.getItems();if(u.isNullable(n)){const o=t.filter((l,a)=>r.shouldMergePathSegment(String(a),l)).map(l=>{r.enterPathSegment(String(t.indexOf(l)),l);const a=this.resolve(l,r);return r.exitPathSegment(),a});return e.clone().setItems(o)}else if(t.length<n.length)throw new Error(`Subtype of element must not have more items (${n.length}) than the element itself (${t.length}).`);const i=[...n];for(let o=0;o<t.length;o++){if(!r.shouldMergePathSegment(String(o),t[o]))continue;if(r.enterPathSegment(String(o),t[o]),o>=i.length){i.push(t[o]),r.exitPathSegment();continue}const l=I.calculateBlueIdSync(t[o]),a=I.calculateBlueIdSync(i[o]);if(l!==a)throw new Error(`Mismatched items at index ${o}: source item has blueId '${l}', but target item has blueId '${a}'.`);r.exitPathSegment()}return e.clone().setItems(i)}mergeProperty(e,t,r,n){const i=this.resolve(r,n),o=e.clone();u.isNullable(o.getProperties())&&o.setProperties({});const l=o.getProperties()[t];return l===void 0?o.getProperties()[t]=i:o.getProperties()[t]=this.mergeObject(l,i,n),o}resolve(e,t){const r=new d,i=this.merge(r,e,t).clone().setName(e.getName()).setDescription(e.getDescription()).setBlueId(e.getBlueId());return new se(i)}}class tr{mergingProcessors;constructor(e){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 rr{process(e,t){const r=t.getValue();if(u.isNonNullable(r)){const n=e.getValue();if(u.isNullable(n))return e.clone().setValue(r);if(!Ys(r,n))throw new Error(`Node values conflict. Source node value: ${r}, target node value: ${n}`)}return e}}const Ys=(s,e)=>F(s)&&F(e)||ve(s)&&ve(e)?s.eq(e):s===e;class sr{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(!v(i,n,r)){const a=m.get(i),p=m.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 nr{process(e,t,r){const n=t.getItemType(),i=t.getType();if(n!==void 0&&i!==void 0&&!Ut(i,r))throw new Error("Source node with itemType must have a List type");const o=e.getItemType();let l=e;if(o===void 0)n!==void 0&&(l=e.clone().setItemType(n));else if(n!==void 0){if(!v(n,o,r)){const f=m.get(n),h=m.get(o);throw new Error(`The source item type '${JSON.stringify(f)}' is not a subtype of the target item type '${JSON.stringify(h)}'.`)}l=e.clone().setItemType(n)}const a=l.getItemType(),p=t.getItems();if(a!==void 0&&p!==void 0)for(const y of p){const f=y.getType();if(f!==void 0&&!v(f,a,r)){const h=m.get(f),T=m.get(a);throw new Error(`Item of type '${JSON.stringify(h)}' is not a subtype of the list's item type '${JSON.stringify(T)}'.`)}}return l}}class ir{process(e,t,r){const n=t.getKeyType(),i=t.getValueType(),o=t.getType();if((n!==void 0||i!==void 0)&&o!==void 0&&!zt(o,r))throw new Error("Source node with keyType or valueType must have a Dictionary type");let l=this.processKeyType(e,t,r);l=this.processValueType(l,t,r);const a=l.getKeyType(),p=l.getValueType(),y=t.getProperties();return(a!==void 0||p!==void 0)&&y!==void 0&&Object.entries(y).forEach(([f,h])=>{a!==void 0&&this.validateKeyType(f,a,r),p!==void 0&&this.validateValueType(h,p,r)}),l}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),!v(i,n,r)){const l=m.get(i),a=m.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(!v(i,n,r)){const l=m.get(i),a=m.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&&!v(n,t,r)){const i=m.get(n),o=m.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 or{process(e){return e}postProcess(e,t,r){const n=e.getType();if(n!==void 0&&rs(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=ss(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 lr{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 ks=Object.freeze(Object.defineProperty({__proto__:null,BasicTypesVerifier:or,DictionaryProcessor:ir,ListProcessor:nr,MetadataPropagator:lr,SequentialMergingProcessor:tr,TypeAssigner:sr,ValuePropagator:rr},Symbol.toStringTag,{value:"Module"}));function Ks(){return new tr([new rr,new sr,new nr,new ir,new lr,new or])}class Js{nodeProvider;blueIdToInlineValue=new Map;constructor(e){const{nodeProvider:t,blueIdsMappingGenerator:r}=e;this.nodeProvider=t,Object.entries(Ve).forEach(([i,o])=>{this.blueIdToInlineValue.set(i,o)});const n=r.getAllBlueIds();Object.entries(n).forEach(([i,o])=>{this.blueIdToInlineValue.has(o)||this.blueIdToInlineValue.set(o,i)})}restore(e){return B.transform(e,t=>this.restoreNode(t))}restoreNode(e){return this.restoreTypeField(e,()=>e.getType(),t=>e.setType(t)),this.restoreTypeField(e,()=>e.getItemType(),t=>e.setItemType(t)),this.restoreTypeField(e,()=>e.getKeyType(),t=>e.setKeyType(t)),this.restoreTypeField(e,()=>e.getValueType(),t=>e.setValueType(t)),e}restoreTypeField(e,t,r){const n=t();if(!n||n.isInlineValue()&&n.getValue()!==void 0)return;const i=n.getBlueId();if(!i)return;const o=this.resolveInlineValue(i,n);if(!o)return;const l=new d().setValue(o).setInlineValue(!0);r(l)}resolveInlineValue(e,t){const r=this.blueIdToInlineValue.get(e);if(r)return r;const n=t.getName();if(n)return this.blueIdToInlineValue.set(e,n),n;const o=this.nodeProvider.fetchFirstByBlueId(e)?.getName();if(o)return this.blueIdToInlineValue.set(e,o),o}}class Zs{runtimes;contents;aliases;constructor(e){const t=[];for(const r of e)t.push(Gs(r));this.runtimes=t,this.contents={},this.aliases={};for(const r of this.runtimes)on(this.contents,r.contents,r.name),nn(this.aliases,r.aliases,r.name)}getRuntimes(){return this.runtimes}getAliases(){return this.aliases}getContents(){return this.contents}findRuntimeByName(e){return this.runtimes.find(t=>t.name===e)}toCurrentBlueId(e){for(const t of this.runtimes){const r=t.toCurrentBlueIdIndex[e];if(r)return r}return e}getTypeAlias(e){const t=this.toCurrentBlueId(e),r=Ve[t];if(r)return r;for(const n of this.runtimes){const i=n.typeAliasByCurrentBlueId[t];if(i)return i}}findRuntimeByBlueId(e){const t=this.toCurrentBlueId(e);for(const r of this.runtimes){const n=r.types[t];if(n)return{runtime:r,currentBlueId:t,typeMeta:n,typeAlias:r.typeAliasByCurrentBlueId[t]}}}}function Gs(s){const e=Hs(s);return Object.values(s.packages).forEach(t=>{Ws(e,s,t)}),{name:s.name,repositoryVersions:s.repositoryVersions,repoVersionIndexById:e.repoVersionIndexById,aliases:e.aliases,types:e.types,toCurrentBlueIdIndex:e.toCurrentBlueIdIndex,contents:e.contents,schemas:e.schemas,currentRepoBlueId:e.currentRepoBlueId,typeAliasByCurrentBlueId:e.typeAliasByCurrentBlueId,typePackageByCurrentBlueId:e.typePackageByCurrentBlueId}}function Hs(s){const e=Object.fromEntries(s.repositoryVersions.map((r,n)=>[r,n])),t=s.repositoryVersions[s.repositoryVersions.length-1];return{aliases:{},types:{},toCurrentBlueIdIndex:{},contents:{},schemas:[],typeAliasByCurrentBlueId:{},typePackageByCurrentBlueId:{},packageNames:new Set,repoVersionIndexById:e,currentRepoBlueId:t}}function Ws(s,e,t){if(s.packageNames.has(t.name))throw new Error(`Duplicate package name detected: ${t.name}`);s.packageNames.add(t.name),qs(s,t),Xs(s,e,t),Qs(s,t),en(s,t)}function qs(s,e){Object.entries(e.aliases).forEach(([t,r])=>{if(s.aliases[t]&&s.aliases[t]!==r)throw new Error(`Conflicting alias mapping for ${t}`);s.aliases[t]=r})}function Xs(s,e,t){Object.entries(t.typesMeta).forEach(([r,n])=>{if(s.types[r])throw new Error(`Duplicate type mapping for BlueId ${r}`);const i=tn(n,e,r,t.name);if(s.types[r]=i,s.typePackageByCurrentBlueId[r]=t.name,s.typeAliasByCurrentBlueId[r]=`${t.name}/${n.name}`,i.status===b.BLUE_REPOSITORY_STATUS_STABLE&&!s.toCurrentBlueIdIndex[r]&&(s.toCurrentBlueIdIndex[r]=r),i.status===b.BLUE_REPOSITORY_STATUS_STABLE)for(const o of i.versions){const l=s.toCurrentBlueIdIndex[o.typeBlueId];if(l&&l!==r)throw new Error(`Conflicting toCurrentBlueIdIndex mapping for ${o.typeBlueId}`);s.toCurrentBlueIdIndex[o.typeBlueId]=r}})}function Qs(s,e){Object.entries(e.contents).forEach(([t,r])=>{s.contents[t]=r})}function en(s,e){s.schemas.push(...Object.values(e.schemas))}function tn(s,e,t,r){if(s.status===b.BLUE_REPOSITORY_STATUS_DEV)return rn(s,e,t,r),{...s,versions:s.versions?[...s.versions]:s.versions};const n=[...s.versions??[]].sort((o,l)=>o.repositoryVersionIndex-l.repositoryVersionIndex);if(n.length===0)throw new Error(`Stable type ${r}/${s.name} (${t}) must have at least one version entry`);const i=new Set;return n.forEach(o=>{if(o.repositoryVersionIndex<0||o.repositoryVersionIndex>=e.repositoryVersions.length)throw new Error(`Invalid repositoryVersionIndex ${o.repositoryVersionIndex} for ${r}/${s.name}`);if(i.has(o.repositoryVersionIndex))throw new Error(`Duplicate repositoryVersionIndex ${o.repositoryVersionIndex} for ${r}/${s.name}`);i.add(o.repositoryVersionIndex);for(const l of o.attributesAdded??[])sn(l,e.name,t,o.repositoryVersionIndex)}),{...s,versions:n}}function rn(s,e,t,r){if(s.status===b.BLUE_REPOSITORY_STATUS_DEV){if(s.versions&&s.versions.length>1)throw new Error(`Dev type ${r}/${s.name} (${t}) must not declare multiple versions`);if(s.versions&&s.versions.length===1){const n=s.versions[0];if(n.repositoryVersionIndex<0||n.repositoryVersionIndex>=e.repositoryVersions.length)throw new Error(`Invalid repositoryVersionIndex ${n.repositoryVersionIndex} for dev type ${r}/${s.name}`)}}}function sn(s,e,t,r){try{b.validateAttributesAddedPointer(s)}catch(n){const i=n instanceof Error?n.message:"Unknown error";throw new Error(`Invalid attributesAdded pointer '${s}' for type ${t} in repository ${e} at index ${r}: ${i}`)}}function nn(s,e,t){for(const[r,n]of Object.entries(e)){const i=s[r];if(i&&i!==n)throw new Error(`Conflicting alias '${r}' across repositories: '${i}' vs '${n}' (from ${t})`);s[r]=n}}function on(s,e,t){for(const[r,n]of Object.entries(e)){if(r in s){const i=s[r];if(!ln(i,n))throw new Error(`Conflicting content for BlueId '${r}' across repositories (from ${t})`);continue}s[r]=n}}function ln(s,e){if(s===e)return!0;if(s===null||e===null||typeof s!="object"||typeof e!="object")return!1;const t=Be.canonicalize(s),r=Be.canonicalize(e);return t!==void 0&&t===r}class Se extends Error{code;details;constructor(e,t,r){super(t),this.code=e,this.details=r&&r.length>0?r:[],this.name="BlueError"}}const M={REPO_UNKNOWN_REPO_BLUE_ID:"REPO_UNKNOWN_REPO_BLUE_ID",REPO_UNREPRESENTABLE_IN_TARGET_VERSION:"REPO_UNREPRESENTABLE_IN_TARGET_VERSION",INVALID_BLUE_CONTEXT_REPOSITORIES:"INVALID_BLUE_CONTEXT_REPOSITORIES",INVALID_REPOSITORY_POINTER:"INVALID_REPOSITORY_POINTER"},an=new Set(["__proto__","constructor","prototype"]);function ft(s){const e=s.at(0),t=s.at(-1);return!e||!t?s:e==="'"&&t==="'"||e==='"'&&t==='"'?s.slice(1,-1):s}function un(s,e){const t=s.indexOf("=");if(t===-1)throw ee(e,`Missing '=' in segment '${s.trim()}'`);if(s.indexOf("=",t+1)!==-1)throw ee(e,`Unexpected '=' in segment '${s.trim()}'`);const r=ft(s.slice(0,t).trim()),n=ft(s.slice(t+1).trim());if(!r)throw ee(e,"Repository name is empty");if(!n)throw ee(e,`Repository BlueId is empty for '${r}'`);return{name:r,value:n}}function cn(s){if(s.trim().length===0)return Object.create(null);const e=Object.create(null);for(const t of s.split(",")){const r=t.trim();if(!r)throw ee(s,"Empty repository segment");const{name:n,value:i}=un(r,s);pn(n,s),e[n]=i}return e}function dn(s){return typeof s=="string"?cn(s):s}function ee(s,e){return new Se(M.INVALID_BLUE_CONTEXT_REPOSITORIES,`Invalid BlueContext repositories value: ${e}`,[{code:M.INVALID_BLUE_CONTEXT_REPOSITORIES,message:e,locationPath:[],context:{rawRepositories:s,reason:e}}])}function pn(s,e){if(an.has(s))throw ee(e,`Forbidden repository name '${s}'`)}function fn(s,e){const t=s.filter(n=>n.repositoryVersionIndex>e).sort((n,i)=>i.repositoryVersionIndex-n.repositoryVersionIndex),r=[];for(const n of t){const i=[...n.attributesAdded].sort((o,l)=>ht(l)-ht(o));r.push(...i)}return r}function ht(s){return b.parsePointer(s).length}const hn=new Set([...Ge]),N={core:"core",noRuntime:"no-runtime",noTargetContext:"no-target-context",representable:"representable",unrepresentable:"unrepresentable"};class yn{registry;targetRepoVersionIndexes;fallbackToCurrentInlineDefinitions;inliningStack=new Set;constructor(e){this.registry=e.registry,this.targetRepoVersionIndexes=e.targetRepoVersionIndexes,this.fallbackToCurrentInlineDefinitions=e.fallbackToCurrentInlineDefinitions}transform(e){return B.transform(e,t=>this.transformNode(t))}transformNode(e){return this.processTypeReference(e,{getter:()=>e.getType(),setter:t=>e.setType(t),schemaTraversalTargets:[e]}),this.processTypeReference(e,{getter:()=>e.getItemType(),setter:t=>e.setItemType(t),schemaTraversalTargets:e.getItems()??[]}),this.processTypeReference(e,{getter:()=>e.getKeyType(),setter:t=>e.setKeyType(t),schemaTraversalTargets:[]}),this.processTypeReference(e,{getter:()=>e.getValueType(),setter:t=>e.setValueType(t),schemaTraversalTargets:this.getDictionaryValueTargets(e)}),e}processTypeReference(e,t){const r=t.getter(),n=r?.getBlueId();if(!r||!n)return;const i=this.resolveType(n);switch(i.kind){case N.core:{r.setBlueId(i.blueId);return}case N.representable:{this.applyDropPointers([r],i.dropPointers,{rootIsSchema:!0}),this.applyDropPointers(t.schemaTraversalTargets,i.dropPointers),r.setBlueId(i.targetBlueId);return}case N.noRuntime:case N.noTargetContext:case N.unrepresentable:{if(this.fallbackToCurrentInlineDefinitions){this.inlineDefinition(e,t.setter,n);return}throw i.kind===N.unrepresentable?i.error:this.unrepresentableError(n,i.kind===N.noTargetContext?`Repository '${i.runtimeName}' not provided in BlueContext.`:"Type does not belong to any declared repository.",i.kind===N.noTargetContext?i.runtime:void 0,i.kind===N.noTargetContext?i.meta:void 0,void 0,i.kind===N.noTargetContext?i.typeAlias:void 0)}}}resolveType(e){if(q.includes(e))return{kind:N.core,blueId:e};const t=this.registry.toCurrentBlueId(e),r=this.registry.getTypeAlias(t),n=this.registry.findRuntimeByBlueId(t);if(!n||!n.typeMeta)return{kind:N.noRuntime};const i=this.targetRepoVersionIndexes[n.runtime.name];if(i===void 0)return{kind:N.noTargetContext,currentBlueId:t,runtimeName:n.runtime.name,runtime:n.runtime,meta:n.typeMeta,typeAlias:r};const o=n.typeMeta;if(o.status===b.BLUE_REPOSITORY_STATUS_DEV){const f=n.runtime.repositoryVersions.length-1;if(i!==f)return{kind:N.unrepresentable,currentBlueId:t,error:this.unrepresentableError(t,`Dev type cannot be represented at repository version index ${i}.`,n.runtime,o,i,r)};const h=o.versions?.[0];return{kind:N.representable,currentBlueId:t,targetBlueId:h?.typeBlueId??t,dropPointers:[]}}const l=o.versions||[];if(l.length===0)return{kind:N.unrepresentable,currentBlueId:t,error:this.unrepresentableError(t,`Stable type metadata missing versions for ${t}.`,n.runtime,o,i,r)};const a=l[0].repositoryVersionIndex;if(i<a)return{kind:N.unrepresentable,currentBlueId:t,error:this.unrepresentableError(t,`Type introduced after target repository version index ${i}.`,n.runtime,o,i,r)};let p=l[0].typeBlueId;for(const f of l)f.repositoryVersionIndex<=i&&(p=f.typeBlueId);const y=o.status===b.BLUE_REPOSITORY_STATUS_STABLE?this.getDropPointers(o,i):[];return{kind:N.representable,currentBlueId:t,targetBlueId:p,dropPointers:y}}getDropPointers(e,t){return e.status!==b.BLUE_REPOSITORY_STATUS_STABLE?[]:fn(e.versions,t)}applyDropPointers(e,t,r={}){if(e.length===0||t.length===0)return;const n=r.rootIsSchema??!1;for(const i of t)for(const o of e)this.deletePropertyAtPointer(o,i,n)}getDictionaryValueTargets(e){const t=e.getProperties();return t?Object.entries(t).filter(([r,n])=>n instanceof d&&!hn.has(r)).map(([,r])=>r):[]}deletePropertyAtPointer(e,t,r){let n;try{n=b.parsePointer(t)}catch{throw this.invalidPointerError(t)}this.applyPointerSegments(e,n,r)}applyPointerSegments(e,t,r){if(t.length===0)return;const[n,...i]=t;if(n===H){const a=e.getType();a&&this.applyPointerSegments(a,i,!0);return}if(n===fe){const a=e.getItemType();a&&this.applyPointerSegments(a,i,!0);return}if(n===he){const a=e.getKeyType();a&&this.applyPointerSegments(a,i,!0);return}if(n===ye){const a=e.getValueType();a&&this.applyPointerSegments(a,i,!0);return}const o=e.getProperties();if(!o)return;if(i.length===0){if(!r||!(n in o))return;const a={...o};delete a[n],e.setProperties(a);return}const l=o[n];l instanceof d&&this.applyPointerSegments(l,i,r)}inlineDefinition(e,t,r){const n=this.registry.toCurrentBlueId(r);if(this.inliningStack.has(n))throw this.unrepresentableError(n,"Cycle detected while inlining type.",void 0,void 0,void 0,void 0,{cycle:Array.from(this.inliningStack).concat(n)});const i=this.registry.getContents()[n];if(!i)throw this.unrepresentableError(n,`Missing definition to inline for BlueId ${n}.`);this.inliningStack.add(n);try{const o=g.deserialize(i);o.setBlueId(void 0);const l=B.transform(o,a=>this.transformNode(a));return t(l),e}finally{this.inliningStack.delete(n)}}invalidPointerError(e){const t=`Invalid attributesAdded pointer '${e}'.`;return new Se(M.INVALID_REPOSITORY_POINTER,t,[{code:M.INVALID_REPOSITORY_POINTER,message:t,locationPath:[],context:{pointer:e}}])}unrepresentableError(e,t,r,n,i,o,l){const a={currentTypeBlueId:e,targetRepoVersionIndex:i,typeAlias:o,...l};if(r&&(i!==void 0&&(a.requestedRepoBlueId=r.repositoryVersions[i]),a.serverRepoBlueId=r.currentRepoBlueId),n&&n.status===b.BLUE_REPOSITORY_STATUS_STABLE){const y=n.versions?.[0]?.repositoryVersionIndex;y!==void 0&&(a.typeIntroducedInRepoBlueId=r?.repositoryVersions[y])}const p={code:M.REPO_UNREPRESENTABLE_IN_TARGET_VERSION,message:t,locationPath:[H],context:a};return new Se(M.REPO_UNREPRESENTABLE_IN_TARGET_VERSION,t,[p])}}function Ze(s,e){return e?B.transform(s,t=>(be(()=>t.getType(),r=>t.setType(r),e),be(()=>t.getItemType(),r=>t.setItemType(r),e),be(()=>t.getKeyType(),r=>t.setKeyType(r),e),be(()=>t.getValueType(),r=>t.setValueType(r),e),t)):s}function be(s,e,t){const r=s();if(!r||r.isInlineValue())return;const n=r.getBlueId();if(!n)return;const i=t.toCurrentBlueId(n);i!==n&&e(r.clone().setBlueId(i))}class gn{registry;blueIdMapper;constructor(e){this.registry=e.registry,this.blueIdMapper=e.blueIdMapper}transform(e,t){const r=this.computeTargetRepoVersionIndexes(t);if(Object.keys(r).length===0)return e;const n=Ze(e,this.blueIdMapper);return new yn({registry:this.registry,targetRepoVersionIndexes:r,fallbackToCurrentInlineDefinitions:t.fallbackToCurrentInlineDefinitions!==!1}).transform(n)}computeTargetRepoVersionIndexes(e){const t={};if(!e?.repositories)return t;const r=typeof e.repositories=="string"?dn(e.repositories):e.repositories;for(const[n,i]of Object.entries(r)){const o=this.registry.findRuntimeByName(n);if(!o)continue;const l=o.repoVersionIndexById[i];if(l===void 0)throw this.unknownRepoBlueIdError(n,i,o.currentRepoBlueId);t[n]=l}return t}unknownRepoBlueIdError(e,t,r){const n=`Unknown RepoBlueId '${t}' for repository '${e}'.`,i={code:M.REPO_UNKNOWN_REPO_BLUE_ID,message:n,locationPath:[],context:{repoName:e,requestedRepoBlueId:t,serverRepoBlueId:r}};return new Se(M.REPO_UNKNOWN_REPO_BLUE_ID,n,[i])}}class mn{nodeProvider;typeSchemaResolver;blueDirectivePreprocessor;urlContentFetcher;blueIdsMappingGenerator;globalLimits=k;mergingProcessor;repositories;repositoryRegistry;blueContextResolver;constructor(e={}){const{nodeProvider:t,typeSchemaResolver:r=null,urlFetchStrategy:n,repositories:i,mergingProcessor:o}=e;this.repositories=i,this.repositoryRegistry=new Zs(i??[]),this.blueContextResolver=new gn({registry:this.repositoryRegistry,blueIdMapper:this.repositoryRegistry});const l=Ts(()=>[]);this.nodeProvider=pe.wrap(t||l,i),this.typeSchemaResolver=r??new Yt([],{nodeProvider:this.nodeProvider}),this.typeSchemaResolver?.setNodeProvider(this.nodeProvider),this.mergingProcessor=o??Ks(),this.urlContentFetcher=new zs(n),this.blueDirectivePreprocessor=new Ls(void 0,this.urlContentFetcher),this.blueIdsMappingGenerator=new lt,this.blueIdsMappingGenerator.registerBlueIds(this.repositoryRegistry.getAliases());const a=this.repositoryRegistry.getRuntimes().flatMap(p=>p.schemas);a.length>0&&this.typeSchemaResolver?.registerSchemas(a)}nodeToJson(e,t="official"){const r=this.normalizeNodeToJsonOptions(t),n=r.blueContext?this.blueContextResolver.transform(e,r.blueContext):e;return m.get(n,r.format)}nodeToYaml(e,t="official"){const r=this.normalizeNodeToJsonOptions(t),n=r.blueContext?this.blueContextResolver.transform(e,r.blueContext):e;return ws.get(n,{strategy:r.format})}nodeToSchemaOutput(e,t){return new Is(this.typeSchemaResolver).convert(e,t)}resolve(e,t=k){const r=this.combineWithGlobalLimits(t);return new er(this.mergingProcessor,this.nodeProvider).resolve(e,r)}createResolvedNode(e){return e instanceof se?e:new se(e)}reverse(e){return new Kt().reverse(e)}restoreInlineTypes(e){return new Js({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).restore(e)}extend(e,t){const r=this.combineWithGlobalLimits(t);new ot(this.nodeProvider).extend(e,r)}jsonValueToNode(e){const t=this.preprocess(g.deserialize(e));return Ze(t,this.repositoryRegistry)}async jsonValueToNodeAsync(e){const t=await this.preprocessAsync(g.deserialize(e));return Ze(t,this.repositoryRegistry)}yamlToNode(e){const t=D(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNode(t)}async yamlToNodeAsync(e){const t=D(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNodeAsync(t)}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);calculateBlueId=async e=>{const t=await this.prepareForBlueIdCalculation(e);return I.calculateBlueId(t)};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);calculateBlueIdSync(e){const t=this.prepareForBlueIdCalculationSync(e);return I.calculateBlueIdSync(t)}addPreprocessingAliases(e){this.blueDirectivePreprocessor.addPreprocessingAliases(e)}preprocess(e){const t=this.blueDirectivePreprocessor.process(e);return new ne({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}async preprocessAsync(e){const t=await this.blueDirectivePreprocessor.processAsync(e);return new ne({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}transform(e,t){return B.transform(e,t)}getNodeProvider(){return this.nodeProvider}setNodeProvider(e){return this.nodeProvider=pe.wrap(e,this.repositories),this.typeSchemaResolver?.setNodeProvider(this.nodeProvider),this}getTypeSchemaResolver(){return this.typeSchemaResolver}setTypeSchemaResolver(e){return this.typeSchemaResolver=e,this.typeSchemaResolver?.setNodeProvider(this.nodeProvider),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 A.isTypeOf(e,t,{checkSchemaExtensions:r?.checkSchemaExtensions,typeSchemaResolver:this.typeSchemaResolver})}isTypeOfNode(e,t){return new is(this).matchesType(e,t,this.globalLimits)}setGlobalLimits(e){return this.globalLimits=e??k,this}getGlobalLimits(){return this.globalLimits}normalizeNodeToJsonOptions(e){return typeof e=="string"?{format:e,blueContext:void 0}:{format:e?.format??"official",blueContext:e?.blueContext}}combineWithGlobalLimits(e){return this.globalLimits==k?e:e==k?this.globalLimits:Me.of(this.globalLimits,e)}}class In extends Ht{blueIdToContentMap=new Map;blueIdToMultipleDocumentsMap=new Map;preprocessor;constructor(e=[]){super();const t=new ne({nodeProvider:this});this.preprocessor=r=>t.preprocessWithDefaultBlue(r),e.forEach(r=>this.processNode(r))}processNode(e){Re.hasItemsOnly(e)?this.processNodeWithItems(e):this.processSingleNode(e)}processSingleNode(e){const t=J.parseAndCalculateBlueIdForNode(e,this.preprocessor);this.blueIdToContentMap.set(t.blueId,t.content),this.blueIdToMultipleDocumentsMap.set(t.blueId,t.isMultipleDocuments);const r=e.getName();r&&this.addToNameMap(r,t.blueId)}processNodeWithItems(e){const t=e.getItems();if(!t)return;this.processNodeList(t);const r=J.parseAndCalculateBlueIdForNodeList(t,this.preprocessor);this.blueIdToContentMap.set(r.blueId,r.content),this.blueIdToMultipleDocumentsMap.set(r.blueId,!0),t.forEach((n,i)=>{const o=n.getName();o&&this.addToNameMap(o,`${r.blueId}#${i}`)})}processNodeList(e){const t=I.calculateBlueIdSync(e),r=e.map(n=>m.get(n));this.blueIdToContentMap.set(t,r),this.blueIdToMultipleDocumentsMap.set(t,!0)}fetchContentByBlueId(e){const t=this.blueIdToContentMap.get(e),r=this.blueIdToMultipleDocumentsMap.get(e);return t!==void 0&&r!==void 0?J.resolveThisReferences(t,e,r):null}addSingleNodes(...e){e.forEach(t=>this.processNode(t))}addSingleDocs(...e){e.forEach(t=>{const r=D(t);if(r!==void 0){const n=g.deserialize(r);this.processNode(n)}})}getBlueIdByName(e){const t=this.nameToBlueIdsMap.get(e);if(!t||t.length===0)throw new Error(`No node with name "${e}"`);return t[0]}getNodeByName(e){const t=this.findNodeByName(e);if(!t)throw new Error(`No node with name "${e}"`);return t}addListAndItsItemsFromNodes(e){this.processNodeList(e),e.forEach(t=>this.processNode(t))}addListAndItsItemsFromDoc(e){const t=D(e);if(t!==void 0){const n=g.deserialize(t).getItems();n&&this.addListAndItsItems(n)}}addListAndItsItems(e){Array.isArray(e)?this.addListAndItsItemsFromNodes(e):this.addListAndItsItemsFromDoc(e)}addList(e){this.processNodeList(e)}}exports.Base58Sha256Provider=St;exports.BasicNodeProvider=In;exports.Blue=mn;exports.BlueIdCalculator=I;exports.BlueIdToCid=Or;exports.BlueNode=d;exports.BlueNodeTypeSchema=A;exports.JsonCanonicalizer=Be;exports.Limits=Oe;exports.Merger=er;exports.MergingProcessors=ks;exports.NodeResolver=Qt;exports.Nodes=Re;exports.Properties=hr;exports.ResolvedBlueNode=se;exports.TypeSchemaResolver=Yt;exports.applyBlueNodePatch=zr;exports.baseBlueObjectSchema=me;exports.blueDescriptionField=kr;exports.blueIdField=Jr;exports.blueIdSchema=gr;exports.blueNameField=Zr;exports.blueNodeField=Gr;exports.blueObjectBooleanValueSchema=Tr;exports.blueObjectNumberValueSchema=Ir;exports.blueObjectSchema=te;exports.blueObjectStringListItemsSchema=br;exports.blueObjectStringValueSchema=mr;exports.calculateBlueId=qt;exports.calculateBlueIdSync=Os;exports.enrichWithBlueId=Ke;exports.getBlueDescriptionAnnotation=Dt;exports.getBlueIdAnnotation=_t;exports.getBlueNameAnnotation=Ft;exports.getBlueNodeAnnotation=jt;exports.getBlueObjectItems=Ds;exports.getBlueObjectProperties=_s;exports.getBlueObjectTypeLabel=xs;exports.getBlueObjectValue=Ms;exports.getTypeBlueIdAnnotation=Lt;exports.hasBlueObjectBlueIdDefined=vt;exports.hasBlueObjectItemsDefined=Bt;exports.hasBlueObjectNameDefined=vr;exports.hasBlueObjectTypeDefined=wt;exports.hasBlueObjectValueDefined=Et;exports.isBigDecimalNumber=ve;exports.isBigIntegerNumber=F;exports.isBigNumber=C;exports.isBlueNodeSchema=nt;exports.isBlueObject=Nr;exports.isBlueObjectResolved=Xt;exports.isGivenBlueObjectTypeSchema=Br;exports.isJsonBlueArray=et;exports.isJsonBlueObject=Qe;exports.isJsonBlueValue=Sr;exports.isUrl=ae;exports.jsonBlueValueSchema=ce;exports.normalizeToBlueObject=Fs;exports.resolveBlueObjectItems=Je;exports.withBlueDescription=Ot;exports.withBlueId=Mt;exports.withBlueName=xt;exports.withBlueNode=$t;exports.withTypeBlueId=Wr;exports.yamlBlueDump=Zt;exports.yamlBlueParse=D;
27
+ ${n.message}`):n}else throw ae(t)?new Error(`UrlContentFetcher not provided for URL: ${t}`):new Error(`Invalid blue value: ${t}`)}return e}getBlueNodeValue(e){const r=e.getBlue()?.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 zs{cache=new Map;fetchStrategy;enabled=!1;allowedDomains=[];constructor(e){this.fetchStrategy=e||Us}validateUrl(e){if(!ae(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=D(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=>g.deserialize(l)):o=[g.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 Qt{resolveWithoutLimits(e){return this.resolve(e,k)}}class er extends Qt{mergingProcessor;nodeProvider;constructor(e,t){super(),this.mergingProcessor=e,this.nodeProvider=pe.wrap(t)}merge(e,t,r){if(u.isNonNullable(t.getBlue()))throw new Error('Document contains "blue" attribute. Preprocess document before merging.');let n=e;const i=t.getType();if(u.isNonNullable(i)){const o=i.clone();u.isNonNullable(o.getBlueId())&&new ot(this.nodeProvider).extend(o,De.withSinglePath("/"));const l=this.resolve(o,r),a=t.clone().setType(l);return n=this.merge(n,o,r),this.mergeObject(n,a,r)}return this.mergeObject(n,t,r)}mergeObject(e,t,r){let n=this.mergingProcessor.process(e,t,this.nodeProvider);const i=t.getItems();u.isNonNullable(i)&&(n=this.mergeChildren(n,i,r));const o=t.getProperties();return u.isNonNullable(o)&&Object.entries(o).forEach(([l,a])=>{r.shouldMergePathSegment(l,a)&&(r.enterPathSegment(l,a),n=this.mergeProperty(n,l,a,r),r.exitPathSegment())}),u.isNonNullable(t.getBlueId())&&(n=n.clone().setBlueId(t.getBlueId())),this.mergingProcessor.postProcess&&(n=this.mergingProcessor.postProcess(n,t,this.nodeProvider)),n}mergeChildren(e,t,r){const n=e.getItems();if(u.isNullable(n)){const o=t.filter((l,a)=>r.shouldMergePathSegment(String(a),l)).map(l=>{r.enterPathSegment(String(t.indexOf(l)),l);const a=this.resolve(l,r);return r.exitPathSegment(),a});return e.clone().setItems(o)}else if(t.length<n.length)throw new Error(`Subtype of element must not have more items (${n.length}) than the element itself (${t.length}).`);const i=[...n];for(let o=0;o<t.length;o++){if(!r.shouldMergePathSegment(String(o),t[o]))continue;if(r.enterPathSegment(String(o),t[o]),o>=i.length){i.push(t[o]),r.exitPathSegment();continue}const l=I.calculateBlueIdSync(t[o]),a=I.calculateBlueIdSync(i[o]);if(l!==a)throw new Error(`Mismatched items at index ${o}: source item has blueId '${l}', but target item has blueId '${a}'.`);r.exitPathSegment()}return e.clone().setItems(i)}mergeProperty(e,t,r,n){const i=this.resolve(r,n),o=e.clone();u.isNullable(o.getProperties())&&o.setProperties({});const l=o.getProperties()[t];return l===void 0?o.getProperties()[t]=i:o.getProperties()[t]=this.mergeObject(l,i,n),o}resolve(e,t){const r=new d,i=this.merge(r,e,t).clone().setName(e.getName()).setDescription(e.getDescription()).setBlueId(e.getBlueId());return new se(i)}}class tr{mergingProcessors;constructor(e){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 rr{process(e,t){const r=t.getValue();if(u.isNonNullable(r)){const n=e.getValue();if(u.isNullable(n))return e.clone().setValue(r);if(!Ys(r,n))throw new Error(`Node values conflict. Source node value: ${r}, target node value: ${n}`)}return e}}const Ys=(s,e)=>F(s)&&F(e)||ve(s)&&ve(e)?s.eq(e):s===e;class sr{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(!v(i,n,r)){const a=m.get(i),p=m.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 nr{process(e,t,r){const n=t.getItemType(),i=t.getType();if(n!==void 0&&i!==void 0&&!Ut(i,r))throw new Error("Source node with itemType must have a List type");const o=e.getItemType();let l=e;if(o===void 0)n!==void 0&&(l=e.clone().setItemType(n));else if(n!==void 0){if(!v(n,o,r)){const f=m.get(n),h=m.get(o);throw new Error(`The source item type '${JSON.stringify(f)}' is not a subtype of the target item type '${JSON.stringify(h)}'.`)}l=e.clone().setItemType(n)}const a=l.getItemType(),p=t.getItems();if(a!==void 0&&p!==void 0)for(const y of p){const f=y.getType();if(f!==void 0&&!v(f,a,r)){const h=m.get(f),T=m.get(a);throw new Error(`Item of type '${JSON.stringify(h)}' is not a subtype of the list's item type '${JSON.stringify(T)}'.`)}}return l}}class ir{process(e,t,r){const n=t.getKeyType(),i=t.getValueType(),o=t.getType();if((n!==void 0||i!==void 0)&&o!==void 0&&!zt(o,r))throw new Error("Source node with keyType or valueType must have a Dictionary type");let l=this.processKeyType(e,t,r);l=this.processValueType(l,t,r);const a=l.getKeyType(),p=l.getValueType(),y=t.getProperties();return(a!==void 0||p!==void 0)&&y!==void 0&&Object.entries(y).forEach(([f,h])=>{a!==void 0&&this.validateKeyType(f,a,r),p!==void 0&&this.validateValueType(h,p,r)}),l}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),!v(i,n,r)){const l=m.get(i),a=m.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(!v(i,n,r)){const l=m.get(i),a=m.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&&!v(n,t,r)){const i=m.get(n),o=m.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 or{process(e){return e}postProcess(e,t,r){const n=e.getType();if(n!==void 0&&rs(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=ss(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 lr{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 ks=Object.freeze(Object.defineProperty({__proto__:null,BasicTypesVerifier:or,DictionaryProcessor:ir,ListProcessor:nr,MetadataPropagator:lr,SequentialMergingProcessor:tr,TypeAssigner:sr,ValuePropagator:rr},Symbol.toStringTag,{value:"Module"}));function Ks(){return new tr([new rr,new sr,new nr,new ir,new lr,new or])}class Js{nodeProvider;blueIdToInlineValue=new Map;constructor(e){const{nodeProvider:t,blueIdsMappingGenerator:r}=e;this.nodeProvider=t,Object.entries(Ve).forEach(([i,o])=>{this.blueIdToInlineValue.set(i,o)});const n=r.getAllBlueIds();Object.entries(n).forEach(([i,o])=>{this.blueIdToInlineValue.has(o)||this.blueIdToInlineValue.set(o,i)})}restore(e){return B.transform(e,t=>this.restoreNode(t))}restoreNode(e){return this.restoreTypeField(e,()=>e.getType(),t=>e.setType(t)),this.restoreTypeField(e,()=>e.getItemType(),t=>e.setItemType(t)),this.restoreTypeField(e,()=>e.getKeyType(),t=>e.setKeyType(t)),this.restoreTypeField(e,()=>e.getValueType(),t=>e.setValueType(t)),e}restoreTypeField(e,t,r){const n=t();if(!n||n.isInlineValue()&&n.getValue()!==void 0)return;const i=n.getBlueId();if(!i)return;const o=this.resolveInlineValue(i,n);if(!o)return;const l=new d().setValue(o).setInlineValue(!0);r(l)}resolveInlineValue(e,t){const r=this.blueIdToInlineValue.get(e);if(r)return r;const n=t.getName();if(n)return this.blueIdToInlineValue.set(e,n),n;const o=this.nodeProvider.fetchFirstByBlueId(e)?.getName();if(o)return this.blueIdToInlineValue.set(e,o),o}}class Zs{runtimes;contents;aliases;constructor(e){const t=[];for(const r of e)t.push(Gs(r));this.runtimes=t,this.contents={},this.aliases={};for(const r of this.runtimes)on(this.contents,r.contents,r.name),nn(this.aliases,r.aliases,r.name)}getRuntimes(){return this.runtimes}getAliases(){return this.aliases}getContents(){return this.contents}findRuntimeByName(e){return this.runtimes.find(t=>t.name===e)}toCurrentBlueId(e){for(const t of this.runtimes){const r=t.toCurrentBlueIdIndex[e];if(r)return r}return e}getTypeAlias(e){const t=this.toCurrentBlueId(e),r=Ve[t];if(r)return r;for(const n of this.runtimes){const i=n.typeAliasByCurrentBlueId[t];if(i)return i}}findRuntimeByBlueId(e){const t=this.toCurrentBlueId(e);for(const r of this.runtimes){const n=r.types[t];if(n)return{runtime:r,currentBlueId:t,typeMeta:n,typeAlias:r.typeAliasByCurrentBlueId[t]}}}}function Gs(s){const e=Hs(s);return Object.values(s.packages).forEach(t=>{Ws(e,s,t)}),{name:s.name,repositoryVersions:s.repositoryVersions,repoVersionIndexById:e.repoVersionIndexById,aliases:e.aliases,types:e.types,toCurrentBlueIdIndex:e.toCurrentBlueIdIndex,contents:e.contents,schemas:e.schemas,currentRepoBlueId:e.currentRepoBlueId,typeAliasByCurrentBlueId:e.typeAliasByCurrentBlueId,typePackageByCurrentBlueId:e.typePackageByCurrentBlueId}}function Hs(s){const e=Object.fromEntries(s.repositoryVersions.map((r,n)=>[r,n])),t=s.repositoryVersions[s.repositoryVersions.length-1];return{aliases:{},types:{},toCurrentBlueIdIndex:{},contents:{},schemas:[],typeAliasByCurrentBlueId:{},typePackageByCurrentBlueId:{},packageNames:new Set,repoVersionIndexById:e,currentRepoBlueId:t}}function Ws(s,e,t){if(s.packageNames.has(t.name))throw new Error(`Duplicate package name detected: ${t.name}`);s.packageNames.add(t.name),qs(s,t),Xs(s,e,t),Qs(s,t),en(s,t)}function qs(s,e){Object.entries(e.aliases).forEach(([t,r])=>{if(s.aliases[t]&&s.aliases[t]!==r)throw new Error(`Conflicting alias mapping for ${t}`);s.aliases[t]=r})}function Xs(s,e,t){Object.entries(t.typesMeta).forEach(([r,n])=>{if(s.types[r])throw new Error(`Duplicate type mapping for BlueId ${r}`);const i=tn(n,e,r,t.name);if(s.types[r]=i,s.typePackageByCurrentBlueId[r]=t.name,s.typeAliasByCurrentBlueId[r]=`${t.name}/${n.name}`,i.status===b.BLUE_REPOSITORY_STATUS_STABLE&&!s.toCurrentBlueIdIndex[r]&&(s.toCurrentBlueIdIndex[r]=r),i.status===b.BLUE_REPOSITORY_STATUS_STABLE)for(const o of i.versions){const l=s.toCurrentBlueIdIndex[o.typeBlueId];if(l&&l!==r)throw new Error(`Conflicting toCurrentBlueIdIndex mapping for ${o.typeBlueId}`);s.toCurrentBlueIdIndex[o.typeBlueId]=r}})}function Qs(s,e){Object.entries(e.contents).forEach(([t,r])=>{s.contents[t]=r})}function en(s,e){s.schemas.push(...Object.values(e.schemas))}function tn(s,e,t,r){if(s.status===b.BLUE_REPOSITORY_STATUS_DEV)return rn(s,e,t,r),{...s,versions:s.versions?[...s.versions]:s.versions};const n=[...s.versions??[]].sort((o,l)=>o.repositoryVersionIndex-l.repositoryVersionIndex);if(n.length===0)throw new Error(`Stable type ${r}/${s.name} (${t}) must have at least one version entry`);const i=new Set;return n.forEach(o=>{if(o.repositoryVersionIndex<0||o.repositoryVersionIndex>=e.repositoryVersions.length)throw new Error(`Invalid repositoryVersionIndex ${o.repositoryVersionIndex} for ${r}/${s.name}`);if(i.has(o.repositoryVersionIndex))throw new Error(`Duplicate repositoryVersionIndex ${o.repositoryVersionIndex} for ${r}/${s.name}`);i.add(o.repositoryVersionIndex);for(const l of o.attributesAdded??[])sn(l,e.name,t,o.repositoryVersionIndex)}),{...s,versions:n}}function rn(s,e,t,r){if(s.status===b.BLUE_REPOSITORY_STATUS_DEV){if(s.versions&&s.versions.length>1)throw new Error(`Dev type ${r}/${s.name} (${t}) must not declare multiple versions`);if(s.versions&&s.versions.length===1){const n=s.versions[0];if(n.repositoryVersionIndex<0||n.repositoryVersionIndex>=e.repositoryVersions.length)throw new Error(`Invalid repositoryVersionIndex ${n.repositoryVersionIndex} for dev type ${r}/${s.name}`)}}}function sn(s,e,t,r){try{b.validateAttributesAddedPointer(s)}catch(n){const i=n instanceof Error?n.message:"Unknown error";throw new Error(`Invalid attributesAdded pointer '${s}' for type ${t} in repository ${e} at index ${r}: ${i}`)}}function nn(s,e,t){for(const[r,n]of Object.entries(e)){const i=s[r];if(i&&i!==n)throw new Error(`Conflicting alias '${r}' across repositories: '${i}' vs '${n}' (from ${t})`);s[r]=n}}function on(s,e,t){for(const[r,n]of Object.entries(e)){if(r in s){const i=s[r];if(!ln(i,n))throw new Error(`Conflicting content for BlueId '${r}' across repositories (from ${t})`);continue}s[r]=n}}function ln(s,e){if(s===e)return!0;if(s===null||e===null||typeof s!="object"||typeof e!="object")return!1;const t=Be.canonicalize(s),r=Be.canonicalize(e);return t!==void 0&&t===r}class Pe extends Error{code;details;constructor(e,t,r){super(t),this.code=e,this.details=r&&r.length>0?r:[],this.name="BlueError"}}const M={REPO_UNKNOWN_REPO_BLUE_ID:"REPO_UNKNOWN_REPO_BLUE_ID",REPO_UNREPRESENTABLE_IN_TARGET_VERSION:"REPO_UNREPRESENTABLE_IN_TARGET_VERSION",INVALID_BLUE_CONTEXT_REPOSITORIES:"INVALID_BLUE_CONTEXT_REPOSITORIES",INVALID_REPOSITORY_POINTER:"INVALID_REPOSITORY_POINTER"},an=new Set(["__proto__","constructor","prototype"]);function ft(s){const e=s.at(0),t=s.at(-1);return!e||!t?s:e==="'"&&t==="'"||e==='"'&&t==='"'?s.slice(1,-1):s}function un(s,e){const t=s.indexOf("=");if(t===-1)throw ee(e,`Missing '=' in segment '${s.trim()}'`);if(s.indexOf("=",t+1)!==-1)throw ee(e,`Unexpected '=' in segment '${s.trim()}'`);const r=ft(s.slice(0,t).trim()),n=ft(s.slice(t+1).trim());if(!r)throw ee(e,"Repository name is empty");if(!n)throw ee(e,`Repository BlueId is empty for '${r}'`);return{name:r,value:n}}function cn(s){if(s.trim().length===0)return Object.create(null);const e=Object.create(null);for(const t of s.split(",")){const r=t.trim();if(!r)throw ee(s,"Empty repository segment");const{name:n,value:i}=un(r,s);pn(n,s),e[n]=i}return e}function dn(s){return typeof s=="string"?cn(s):s}function ee(s,e){return new Pe(M.INVALID_BLUE_CONTEXT_REPOSITORIES,`Invalid BlueContext repositories value: ${e}`,[{code:M.INVALID_BLUE_CONTEXT_REPOSITORIES,message:e,locationPath:[],context:{rawRepositories:s,reason:e}}])}function pn(s,e){if(an.has(s))throw ee(e,`Forbidden repository name '${s}'`)}function fn(s,e){const t=s.filter(n=>n.repositoryVersionIndex>e).sort((n,i)=>i.repositoryVersionIndex-n.repositoryVersionIndex),r=[];for(const n of t){const i=[...n.attributesAdded].sort((o,l)=>ht(l)-ht(o));r.push(...i)}return r}function ht(s){return b.parsePointer(s).length}const hn=new Set([...Ge]),N={core:"core",noRuntime:"no-runtime",noTargetContext:"no-target-context",representable:"representable",unrepresentable:"unrepresentable"};class yn{registry;targetRepoVersionIndexes;fallbackToCurrentInlineDefinitions;inliningStack=new Set;constructor(e){this.registry=e.registry,this.targetRepoVersionIndexes=e.targetRepoVersionIndexes,this.fallbackToCurrentInlineDefinitions=e.fallbackToCurrentInlineDefinitions}transform(e){return B.transform(e,t=>this.transformNode(t))}transformNode(e){return this.processTypeReference(e,{getter:()=>e.getType(),setter:t=>e.setType(t),schemaTraversalTargets:[e]}),this.processTypeReference(e,{getter:()=>e.getItemType(),setter:t=>e.setItemType(t),schemaTraversalTargets:e.getItems()??[]}),this.processTypeReference(e,{getter:()=>e.getKeyType(),setter:t=>e.setKeyType(t),schemaTraversalTargets:[]}),this.processTypeReference(e,{getter:()=>e.getValueType(),setter:t=>e.setValueType(t),schemaTraversalTargets:this.getDictionaryValueTargets(e)}),e}processTypeReference(e,t){const r=t.getter(),n=r?.getBlueId();if(!r||!n)return;const i=this.resolveType(n);switch(i.kind){case N.core:{r.setBlueId(i.blueId);return}case N.representable:{this.applyDropPointers([r],i.dropPointers,{rootIsSchema:!0}),this.applyDropPointers(t.schemaTraversalTargets,i.dropPointers),r.setBlueId(i.targetBlueId);return}case N.noRuntime:case N.noTargetContext:case N.unrepresentable:{if(this.fallbackToCurrentInlineDefinitions){this.inlineDefinition(e,t.setter,n);return}throw i.kind===N.unrepresentable?i.error:this.unrepresentableError(n,i.kind===N.noTargetContext?`Repository '${i.runtimeName}' not provided in BlueContext.`:"Type does not belong to any declared repository.",i.kind===N.noTargetContext?i.runtime:void 0,i.kind===N.noTargetContext?i.meta:void 0,void 0,i.kind===N.noTargetContext?i.typeAlias:void 0)}}}resolveType(e){if(q.includes(e))return{kind:N.core,blueId:e};const t=this.registry.toCurrentBlueId(e),r=this.registry.getTypeAlias(t),n=this.registry.findRuntimeByBlueId(t);if(!n||!n.typeMeta)return{kind:N.noRuntime};const i=this.targetRepoVersionIndexes[n.runtime.name];if(i===void 0)return{kind:N.noTargetContext,currentBlueId:t,runtimeName:n.runtime.name,runtime:n.runtime,meta:n.typeMeta,typeAlias:r};const o=n.typeMeta;if(o.status===b.BLUE_REPOSITORY_STATUS_DEV){const f=n.runtime.repositoryVersions.length-1;if(i!==f)return{kind:N.unrepresentable,currentBlueId:t,error:this.unrepresentableError(t,`Dev type cannot be represented at repository version index ${i}.`,n.runtime,o,i,r)};const h=o.versions?.[0];return{kind:N.representable,currentBlueId:t,targetBlueId:h?.typeBlueId??t,dropPointers:[]}}const l=o.versions||[];if(l.length===0)return{kind:N.unrepresentable,currentBlueId:t,error:this.unrepresentableError(t,`Stable type metadata missing versions for ${t}.`,n.runtime,o,i,r)};const a=l[0].repositoryVersionIndex;if(i<a)return{kind:N.unrepresentable,currentBlueId:t,error:this.unrepresentableError(t,`Type introduced after target repository version index ${i}.`,n.runtime,o,i,r)};let p=l[0].typeBlueId;for(const f of l)f.repositoryVersionIndex<=i&&(p=f.typeBlueId);const y=o.status===b.BLUE_REPOSITORY_STATUS_STABLE?this.getDropPointers(o,i):[];return{kind:N.representable,currentBlueId:t,targetBlueId:p,dropPointers:y}}getDropPointers(e,t){return e.status!==b.BLUE_REPOSITORY_STATUS_STABLE?[]:fn(e.versions,t)}applyDropPointers(e,t,r={}){if(e.length===0||t.length===0)return;const n=r.rootIsSchema??!1;for(const i of t)for(const o of e)this.deletePropertyAtPointer(o,i,n)}getDictionaryValueTargets(e){const t=e.getProperties();return t?Object.entries(t).filter(([r,n])=>n instanceof d&&!hn.has(r)).map(([,r])=>r):[]}deletePropertyAtPointer(e,t,r){let n;try{n=b.parsePointer(t)}catch{throw this.invalidPointerError(t)}this.applyPointerSegments(e,n,r)}applyPointerSegments(e,t,r){if(t.length===0)return;const[n,...i]=t;if(n===H){const a=e.getType();a&&this.applyPointerSegments(a,i,!0);return}if(n===fe){const a=e.getItemType();a&&this.applyPointerSegments(a,i,!0);return}if(n===he){const a=e.getKeyType();a&&this.applyPointerSegments(a,i,!0);return}if(n===ye){const a=e.getValueType();a&&this.applyPointerSegments(a,i,!0);return}const o=e.getProperties();if(!o)return;if(i.length===0){if(!r||!(n in o))return;const a={...o};delete a[n],e.setProperties(a);return}const l=o[n];l instanceof d&&this.applyPointerSegments(l,i,r)}inlineDefinition(e,t,r){const n=this.registry.toCurrentBlueId(r);if(this.inliningStack.has(n))throw this.unrepresentableError(n,"Cycle detected while inlining type.",void 0,void 0,void 0,void 0,{cycle:Array.from(this.inliningStack).concat(n)});const i=this.registry.getContents()[n];if(!i)throw this.unrepresentableError(n,`Missing definition to inline for BlueId ${n}.`);this.inliningStack.add(n);try{const o=g.deserialize(i);o.setBlueId(void 0);const l=B.transform(o,a=>this.transformNode(a));return t(l),e}finally{this.inliningStack.delete(n)}}invalidPointerError(e){const t=`Invalid attributesAdded pointer '${e}'.`;return new Pe(M.INVALID_REPOSITORY_POINTER,t,[{code:M.INVALID_REPOSITORY_POINTER,message:t,locationPath:[],context:{pointer:e}}])}unrepresentableError(e,t,r,n,i,o,l){const a={currentTypeBlueId:e,targetRepoVersionIndex:i,typeAlias:o,...l};if(r&&(i!==void 0&&(a.requestedRepoBlueId=r.repositoryVersions[i]),a.serverRepoBlueId=r.currentRepoBlueId),n&&n.status===b.BLUE_REPOSITORY_STATUS_STABLE){const y=n.versions?.[0]?.repositoryVersionIndex;y!==void 0&&(a.typeIntroducedInRepoBlueId=r?.repositoryVersions[y])}const p={code:M.REPO_UNREPRESENTABLE_IN_TARGET_VERSION,message:t,locationPath:[H],context:a};return new Pe(M.REPO_UNREPRESENTABLE_IN_TARGET_VERSION,t,[p])}}function Ze(s,e){return e?B.transform(s,t=>(be(()=>t.getType(),r=>t.setType(r),e),be(()=>t.getItemType(),r=>t.setItemType(r),e),be(()=>t.getKeyType(),r=>t.setKeyType(r),e),be(()=>t.getValueType(),r=>t.setValueType(r),e),t)):s}function be(s,e,t){const r=s();if(!r||r.isInlineValue())return;const n=r.getBlueId();if(!n)return;const i=t.toCurrentBlueId(n);i!==n&&e(r.clone().setBlueId(i))}class gn{registry;blueIdMapper;constructor(e){this.registry=e.registry,this.blueIdMapper=e.blueIdMapper}transform(e,t){const r=this.computeTargetRepoVersionIndexes(t);if(Object.keys(r).length===0)return e;const n=Ze(e,this.blueIdMapper);return new yn({registry:this.registry,targetRepoVersionIndexes:r,fallbackToCurrentInlineDefinitions:t.fallbackToCurrentInlineDefinitions!==!1}).transform(n)}computeTargetRepoVersionIndexes(e){const t={};if(!e?.repositories)return t;const r=typeof e.repositories=="string"?dn(e.repositories):e.repositories;for(const[n,i]of Object.entries(r)){const o=this.registry.findRuntimeByName(n);if(!o)continue;const l=o.repoVersionIndexById[i];if(l===void 0)throw this.unknownRepoBlueIdError(n,i,o.currentRepoBlueId);t[n]=l}return t}unknownRepoBlueIdError(e,t,r){const n=`Unknown RepoBlueId '${t}' for repository '${e}'.`,i={code:M.REPO_UNKNOWN_REPO_BLUE_ID,message:n,locationPath:[],context:{repoName:e,requestedRepoBlueId:t,serverRepoBlueId:r}};return new Pe(M.REPO_UNKNOWN_REPO_BLUE_ID,n,[i])}}class mn{nodeProvider;typeSchemaResolver;blueDirectivePreprocessor;urlContentFetcher;blueIdsMappingGenerator;globalLimits=k;mergingProcessor;repositories;repositoryRegistry;blueContextResolver;constructor(e={}){const{nodeProvider:t,typeSchemaResolver:r=null,urlFetchStrategy:n,repositories:i,mergingProcessor:o}=e;this.repositories=i,this.repositoryRegistry=new Zs(i??[]),this.blueContextResolver=new gn({registry:this.repositoryRegistry,blueIdMapper:this.repositoryRegistry});const l=Ts(()=>[]);this.nodeProvider=pe.wrap(t||l,i),this.typeSchemaResolver=r??new Yt([],{nodeProvider:this.nodeProvider}),this.typeSchemaResolver?.setNodeProvider(this.nodeProvider),this.mergingProcessor=o??Ks(),this.urlContentFetcher=new zs(n),this.blueDirectivePreprocessor=new Ls(void 0,this.urlContentFetcher),this.blueIdsMappingGenerator=new lt,this.blueIdsMappingGenerator.registerBlueIds(this.repositoryRegistry.getAliases());const a=this.repositoryRegistry.getRuntimes().flatMap(p=>p.schemas);a.length>0&&this.typeSchemaResolver?.registerSchemas(a)}nodeToJson(e,t="official"){const r=this.normalizeNodeToJsonOptions(t),n=r.blueContext?this.blueContextResolver.transform(e,r.blueContext):e;return m.get(n,r.format)}nodeToYaml(e,t="official"){const r=this.normalizeNodeToJsonOptions(t),n=r.blueContext?this.blueContextResolver.transform(e,r.blueContext):e;return ws.get(n,{strategy:r.format})}nodeToSchemaOutput(e,t){return new Is(this.typeSchemaResolver).convert(e,t)}resolve(e,t=k){const r=this.combineWithGlobalLimits(t);return new er(this.mergingProcessor,this.nodeProvider).resolve(e,r)}createResolvedNode(e){return e instanceof se?e:new se(e)}reverse(e){return new Kt().reverse(e)}restoreInlineTypes(e){return new Js({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).restore(e)}extend(e,t){const r=this.combineWithGlobalLimits(t);new ot(this.nodeProvider).extend(e,r)}jsonValueToNode(e){const t=this.preprocess(g.deserialize(e));return Ze(t,this.repositoryRegistry)}async jsonValueToNodeAsync(e){const t=await this.preprocessAsync(g.deserialize(e));return Ze(t,this.repositoryRegistry)}yamlToNode(e){const t=D(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNode(t)}async yamlToNodeAsync(e){const t=D(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNodeAsync(t)}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);calculateBlueId=async e=>{const t=await this.prepareForBlueIdCalculation(e);return I.calculateBlueId(t)};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);calculateBlueIdSync(e){const t=this.prepareForBlueIdCalculationSync(e);return I.calculateBlueIdSync(t)}addPreprocessingAliases(e){this.blueDirectivePreprocessor.addPreprocessingAliases(e)}preprocess(e){const t=this.blueDirectivePreprocessor.process(e);return new ne({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}async preprocessAsync(e){const t=await this.blueDirectivePreprocessor.processAsync(e);return new ne({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}transform(e,t){return B.transform(e,t)}getNodeProvider(){return this.nodeProvider}setNodeProvider(e){return this.nodeProvider=pe.wrap(e,this.repositories),this.typeSchemaResolver?.setNodeProvider(this.nodeProvider),this}getTypeSchemaResolver(){return this.typeSchemaResolver}setTypeSchemaResolver(e){return this.typeSchemaResolver=e,this.typeSchemaResolver?.setNodeProvider(this.nodeProvider),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 A.isTypeOf(e,t,{checkSchemaExtensions:r?.checkSchemaExtensions,typeSchemaResolver:this.typeSchemaResolver})}isTypeOfBlueId(e,t){const r=t.trim();if(r.length===0)return!1;const n=e.getType();if(!n)return!1;const i=new d().setBlueId(r);return v(n,i,this.nodeProvider)}isTypeOfNode(e,t){return new is(this).matchesType(e,t,this.globalLimits)}setGlobalLimits(e){return this.globalLimits=e??k,this}getGlobalLimits(){return this.globalLimits}normalizeNodeToJsonOptions(e){return typeof e=="string"?{format:e,blueContext:void 0}:{format:e?.format??"official",blueContext:e?.blueContext}}combineWithGlobalLimits(e){return this.globalLimits==k?e:e==k?this.globalLimits:Me.of(this.globalLimits,e)}}class In extends Ht{blueIdToContentMap=new Map;blueIdToMultipleDocumentsMap=new Map;preprocessor;constructor(e=[]){super();const t=new ne({nodeProvider:this});this.preprocessor=r=>t.preprocessWithDefaultBlue(r),e.forEach(r=>this.processNode(r))}processNode(e){Oe.hasItemsOnly(e)?this.processNodeWithItems(e):this.processSingleNode(e)}processSingleNode(e){const t=J.parseAndCalculateBlueIdForNode(e,this.preprocessor);this.blueIdToContentMap.set(t.blueId,t.content),this.blueIdToMultipleDocumentsMap.set(t.blueId,t.isMultipleDocuments);const r=e.getName();r&&this.addToNameMap(r,t.blueId)}processNodeWithItems(e){const t=e.getItems();if(!t)return;this.processNodeList(t);const r=J.parseAndCalculateBlueIdForNodeList(t,this.preprocessor);this.blueIdToContentMap.set(r.blueId,r.content),this.blueIdToMultipleDocumentsMap.set(r.blueId,!0),t.forEach((n,i)=>{const o=n.getName();o&&this.addToNameMap(o,`${r.blueId}#${i}`)})}processNodeList(e){const t=I.calculateBlueIdSync(e),r=e.map(n=>m.get(n));this.blueIdToContentMap.set(t,r),this.blueIdToMultipleDocumentsMap.set(t,!0)}fetchContentByBlueId(e){const t=this.blueIdToContentMap.get(e),r=this.blueIdToMultipleDocumentsMap.get(e);return t!==void 0&&r!==void 0?J.resolveThisReferences(t,e,r):null}addSingleNodes(...e){e.forEach(t=>this.processNode(t))}addSingleDocs(...e){e.forEach(t=>{const r=D(t);if(r!==void 0){const n=g.deserialize(r);this.processNode(n)}})}getBlueIdByName(e){const t=this.nameToBlueIdsMap.get(e);if(!t||t.length===0)throw new Error(`No node with name "${e}"`);return t[0]}getNodeByName(e){const t=this.findNodeByName(e);if(!t)throw new Error(`No node with name "${e}"`);return t}addListAndItsItemsFromNodes(e){this.processNodeList(e),e.forEach(t=>this.processNode(t))}addListAndItsItemsFromDoc(e){const t=D(e);if(t!==void 0){const n=g.deserialize(t).getItems();n&&this.addListAndItsItems(n)}}addListAndItsItems(e){Array.isArray(e)?this.addListAndItsItemsFromNodes(e):this.addListAndItsItemsFromDoc(e)}addList(e){this.processNodeList(e)}}exports.Base58Sha256Provider=Pt;exports.BasicNodeProvider=In;exports.Blue=mn;exports.BlueIdCalculator=I;exports.BlueIdToCid=Rr;exports.BlueNode=d;exports.BlueNodeTypeSchema=A;exports.JsonCanonicalizer=Be;exports.Limits=Re;exports.Merger=er;exports.MergingProcessors=ks;exports.NodeResolver=Qt;exports.Nodes=Oe;exports.Properties=hr;exports.ResolvedBlueNode=se;exports.TypeSchemaResolver=Yt;exports.applyBlueNodePatch=zr;exports.baseBlueObjectSchema=me;exports.blueDescriptionField=kr;exports.blueIdField=Jr;exports.blueIdSchema=gr;exports.blueNameField=Zr;exports.blueNodeField=Gr;exports.blueObjectBooleanValueSchema=Tr;exports.blueObjectNumberValueSchema=Ir;exports.blueObjectSchema=te;exports.blueObjectStringListItemsSchema=br;exports.blueObjectStringValueSchema=mr;exports.calculateBlueId=qt;exports.calculateBlueIdSync=Rs;exports.enrichWithBlueId=Ke;exports.getBlueDescriptionAnnotation=Dt;exports.getBlueIdAnnotation=_t;exports.getBlueNameAnnotation=Ft;exports.getBlueNodeAnnotation=jt;exports.getBlueObjectItems=Ds;exports.getBlueObjectProperties=_s;exports.getBlueObjectTypeLabel=xs;exports.getBlueObjectValue=Ms;exports.getTypeBlueIdAnnotation=Lt;exports.hasBlueObjectBlueIdDefined=vt;exports.hasBlueObjectItemsDefined=Bt;exports.hasBlueObjectNameDefined=vr;exports.hasBlueObjectTypeDefined=wt;exports.hasBlueObjectValueDefined=Et;exports.isBigDecimalNumber=ve;exports.isBigIntegerNumber=F;exports.isBigNumber=C;exports.isBlueNodeSchema=nt;exports.isBlueObject=Nr;exports.isBlueObjectResolved=Xt;exports.isGivenBlueObjectTypeSchema=Br;exports.isJsonBlueArray=et;exports.isJsonBlueObject=Qe;exports.isJsonBlueValue=Pr;exports.isUrl=ae;exports.jsonBlueValueSchema=ce;exports.normalizeToBlueObject=Fs;exports.resolveBlueObjectItems=Je;exports.withBlueDescription=Rt;exports.withBlueId=Mt;exports.withBlueName=xt;exports.withBlueNode=$t;exports.withTypeBlueId=Wr;exports.yamlBlueDump=Zt;exports.yamlBlueParse=D;
package/dist/index.mjs CHANGED
@@ -5066,6 +5066,23 @@ class ri {
5066
5066
  typeSchemaResolver: this.typeSchemaResolver
5067
5067
  });
5068
5068
  }
5069
+ /**
5070
+ * Checks if a BlueNode's type matches or extends a type BlueId.
5071
+ *
5072
+ * @param node - The BlueNode to check.
5073
+ * @param blueId - The base type BlueId to compare against.
5074
+ * @returns true if the node matches or extends the BlueId type.
5075
+ */
5076
+ isTypeOfBlueId(e, t) {
5077
+ const r = t.trim();
5078
+ if (r.length === 0)
5079
+ return !1;
5080
+ const n = e.getType();
5081
+ if (!n)
5082
+ return !1;
5083
+ const i = new a().setBlueId(r);
5084
+ return b(n, i, this.nodeProvider);
5085
+ }
5069
5086
  /**
5070
5087
  * Checks if a BlueNode matches a BlueNode type.
5071
5088
  *
@@ -165,6 +165,14 @@ export declare class Blue {
165
165
  isTypeOf(node: BlueNode, schema: AnyZodObject, options?: {
166
166
  checkSchemaExtensions?: boolean;
167
167
  }): boolean;
168
+ /**
169
+ * Checks if a BlueNode's type matches or extends a type BlueId.
170
+ *
171
+ * @param node - The BlueNode to check.
172
+ * @param blueId - The base type BlueId to compare against.
173
+ * @returns true if the node matches or extends the BlueId type.
174
+ */
175
+ isTypeOfBlueId(node: BlueNode, blueId: string): boolean;
168
176
  /**
169
177
  * Checks if a BlueNode matches a BlueNode type.
170
178
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Blue.d.ts","sourceRoot":"","sources":["../../src/lib/Blue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAoB,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAEL,oBAAoB,EAGpB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAIxD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,aAAa,EACd,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,MAAM,EAAa,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAQ5D,OAAO,EAGL,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,qBAAa,IAAI;IACf,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,kBAAkB,CAA4B;IACtD,OAAO,CAAC,yBAAyB,CAA4B;IAC7D,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,uBAAuB,CAA0B;IACzD,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAC,CAAmB;IACxC,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,mBAAmB,CAAsB;gBAErC,OAAO,GAAE,WAAgB;IAmDrC;;;;;;OAMG;IACI,UAAU,CACf,IAAI,EAAE,QAAQ,EACd,iBAAiB,GACb,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAC9C,iBAA8B;IASpC;;;OAGG;IACI,UAAU,CACf,IAAI,EAAE,QAAQ,EACd,QAAQ,GACJ,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAC9C,iBAA8B;IAS7B,kBAAkB,CACvB,MAAM,GAAG,OAAO,EAChB,GAAG,SAAS,UAAU,GAAG,UAAU,EACnC,KAAK,GAAG,MAAM,EACd,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,MAAM;IAKvD,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAkB,GAAG,gBAAgB;IAM5E;;;;;;;OAOG;IACI,kBAAkB,CAAC,YAAY,EAAE,QAAQ,GAAG,gBAAgB;IAO5D,OAAO,CAAC,IAAI,EAAE,QAAQ;IAK7B;;;;;;OAMG;IACI,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ;IAQ5C,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM;IAKrC,eAAe,CAAC,IAAI,EAAE,OAAO;IAKvB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAO5D,UAAU,CAAC,IAAI,EAAE,MAAM;IAQjB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQ7D,OAAO,CAAC,2BAA2B,CAkBjC;IAEK,eAAe,GACpB,OAAO,aAAa,GAAG,QAAQ,GAAG,QAAQ,EAAE,qBAI5C;IAEF,OAAO,CAAC,+BAA+B,CAerC;IAEK,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,GAAG,QAAQ,EAAE;IAKhE,uBAAuB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAI3D,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ;IAS9B,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAUxD,SAAS,CACd,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,QAAQ,GACxC,QAAQ;IAIJ,eAAe,IAAI,YAAY;IAI/B,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IASjD,qBAAqB,IAAI,kBAAkB,GAAG,IAAI;IAIlD,qBAAqB,CAC1B,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,GAC5C,IAAI;IAMA,oBAAoB,IAAI,iBAAiB;IAIzC,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI;IAKpE;;;;;;OAMG;IACI,yCAAyC,IAAI,IAAI;IAKxD;;;;;;OAMG;IACI,4CAA4C,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAK5E;;;;;OAKG;IACI,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKtD;;;;;OAKG;IACI,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKzD;;;;;OAKG;IACI,4BAA4B,IAAI,MAAM,EAAE;IAI/C;;;;OAIG;IACI,0CAA0C,IAAI,IAAI;IAKzD;;;;OAIG;IACI,4CAA4C,IAAI,OAAO;IAIvD,uBAAuB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAI9C,uBAAuB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAKlE;;;;OAIG;IACI,eAAe,CAAC,GAAG,kBAAkB,EAAE,aAAa,EAAE,GAAG,IAAI;IAKpE;;;OAGG;IACI,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIxD;;;OAGG;IACI,iBAAiB,IAAI,MAAM,EAAE;IAIpC;;;OAGG;IACI,0BAA0B,IAAI,uBAAuB;IAI5D;;;;;;;OAOG;IACI,QAAQ,CACb,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE;QACR,qBAAqB,CAAC,EAAE,OAAO,CAAC;KACjC,GACA,OAAO;IAOV;;;;;;OAMG;IACI,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ;IAIlD;;;;;;OAMG;IACI,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAKzD;;;;OAIG;IACI,eAAe,IAAI,MAAM;IAIhC,OAAO,CAAC,0BAA0B;IAelC,OAAO,CAAC,uBAAuB;CAWhC"}
1
+ {"version":3,"file":"Blue.d.ts","sourceRoot":"","sources":["../../src/lib/Blue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAoB,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAEL,oBAAoB,EAIpB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAIxD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,aAAa,EACd,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,MAAM,EAAa,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAQ5D,OAAO,EAGL,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,qBAAa,IAAI;IACf,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,kBAAkB,CAA4B;IACtD,OAAO,CAAC,yBAAyB,CAA4B;IAC7D,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,uBAAuB,CAA0B;IACzD,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAC,CAAmB;IACxC,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,mBAAmB,CAAsB;gBAErC,OAAO,GAAE,WAAgB;IAmDrC;;;;;;OAMG;IACI,UAAU,CACf,IAAI,EAAE,QAAQ,EACd,iBAAiB,GACb,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAC9C,iBAA8B;IASpC;;;OAGG;IACI,UAAU,CACf,IAAI,EAAE,QAAQ,EACd,QAAQ,GACJ,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAC9C,iBAA8B;IAS7B,kBAAkB,CACvB,MAAM,GAAG,OAAO,EAChB,GAAG,SAAS,UAAU,GAAG,UAAU,EACnC,KAAK,GAAG,MAAM,EACd,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,MAAM;IAKvD,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAkB,GAAG,gBAAgB;IAM5E;;;;;;;OAOG;IACI,kBAAkB,CAAC,YAAY,EAAE,QAAQ,GAAG,gBAAgB;IAO5D,OAAO,CAAC,IAAI,EAAE,QAAQ;IAK7B;;;;;;OAMG;IACI,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ;IAQ5C,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM;IAKrC,eAAe,CAAC,IAAI,EAAE,OAAO;IAKvB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAO5D,UAAU,CAAC,IAAI,EAAE,MAAM;IAQjB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQ7D,OAAO,CAAC,2BAA2B,CAkBjC;IAEK,eAAe,GACpB,OAAO,aAAa,GAAG,QAAQ,GAAG,QAAQ,EAAE,qBAI5C;IAEF,OAAO,CAAC,+BAA+B,CAerC;IAEK,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,GAAG,QAAQ,EAAE;IAKhE,uBAAuB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAI3D,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ;IAS9B,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAUxD,SAAS,CACd,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,QAAQ,GACxC,QAAQ;IAIJ,eAAe,IAAI,YAAY;IAI/B,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IASjD,qBAAqB,IAAI,kBAAkB,GAAG,IAAI;IAIlD,qBAAqB,CAC1B,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,GAC5C,IAAI;IAMA,oBAAoB,IAAI,iBAAiB;IAIzC,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI;IAKpE;;;;;;OAMG;IACI,yCAAyC,IAAI,IAAI;IAKxD;;;;;;OAMG;IACI,4CAA4C,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAK5E;;;;;OAKG;IACI,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKtD;;;;;OAKG;IACI,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKzD;;;;;OAKG;IACI,4BAA4B,IAAI,MAAM,EAAE;IAI/C;;;;OAIG;IACI,0CAA0C,IAAI,IAAI;IAKzD;;;;OAIG;IACI,4CAA4C,IAAI,OAAO;IAIvD,uBAAuB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAI9C,uBAAuB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAKlE;;;;OAIG;IACI,eAAe,CAAC,GAAG,kBAAkB,EAAE,aAAa,EAAE,GAAG,IAAI;IAKpE;;;OAGG;IACI,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIxD;;;OAGG;IACI,iBAAiB,IAAI,MAAM,EAAE;IAIpC;;;OAGG;IACI,0BAA0B,IAAI,uBAAuB;IAI5D;;;;;;;OAOG;IACI,QAAQ,CACb,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE;QACR,qBAAqB,CAAC,EAAE,OAAO,CAAC;KACjC,GACA,OAAO;IAOV;;;;;;OAMG;IACI,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAa9D;;;;;;OAMG;IACI,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ;IAIlD;;;;;;OAMG;IACI,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAKzD;;;;OAIG;IACI,eAAe,IAAI,MAAM;IAIhC,OAAO,CAAC,0BAA0B;IAelC,OAAO,CAAC,uBAAuB;CAWhC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blue-labs/language",
3
- "version": "3.3.1",
3
+ "version": "3.4.1",
4
4
  "dependencies": {
5
5
  "@blue-labs/repository-contract": "*",
6
6
  "@blue-labs/shared-utils": "*",