trigger_system 1.1.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node/node.js CHANGED
@@ -1,14 +1,14 @@
1
- import{createRequire as aQ}from"node:module";var oQ=Object.create;var{getPrototypeOf:rQ,defineProperty:Z2,getOwnPropertyNames:LX,getOwnPropertyDescriptor:nQ}=Object,zX=Object.prototype.hasOwnProperty;var FX=(U,X,q)=>{q=U!=null?oQ(rQ(U)):{};let Z=X||!U||!U.__esModule?Z2(q,"default",{value:U,enumerable:!0}):q;for(let Q of LX(U))if(!zX.call(Z,Q))Z2(Z,Q,{get:()=>U[Q],enumerable:!0});return Z},$X=new WeakMap,AX=(U)=>{var X=$X.get(U),q;if(X)return X;if(X=Z2({},"__esModule",{value:!0}),U&&typeof U==="object"||typeof U==="function")LX(U).map((Z)=>!zX.call(X,Z)&&Z2(X,Z,{get:()=>U[Z],enumerable:!(q=nQ(U,Z))||q.enumerable}));return $X.set(U,X),X},R=(U,X)=>()=>(X||U((X={exports:{}}).exports,X),X.exports);var OX=(U,X)=>{for(var q in X)Z2(U,q,{get:X[q],enumerable:!0,configurable:!0,set:(Z)=>X[q]=()=>Z})};var BX=(U,X)=>()=>(U&&(X=U(U=0)),X);var w1=aQ(import.meta.url);var j4={};OX(j4,{ExpressionEngine:()=>e});class e{static evaluate(U,X){try{if(U.includes("${")){let q=this.interpolate(U,X);if(!isNaN(Number(q))&&q.trim()!=="")return Number(q);return q}return this.evaluateExpression(U,X)}catch(q){return console.error(`Error evaluating expression: ${U}`,q),null}}static interpolate(U,X){return U.replace(/\$\{([^}]+)\}/g,(q,Z)=>{try{let Q=this.evaluateExpression(Z,X);if(Q===void 0||Q===null)return"undefined";return String(Q)}catch(Q){return console.error(`Error en interpolación: ${q}`,Q),q}})}static evaluateMathExpression(U){try{return Function("Math",`return ${U}`)(Math)}catch(X){throw Error(`Error evaluando expresión matemática: ${U}`)}}static evaluateExpression(U,X){if(/^(data|vars|request|computed|env|state)(\.[a-zA-Z0-9_]+)+$/.test(U))return this.getNestedValue(U,X);if(/^(vars|env|state)(\.[a-zA-Z0-9_]+)$/.test(U))return this.getNestedValue(U,X);try{return Function("context","with(context) { return "+U+" }")(X)}catch(q){return console.error(`ERROR evaluating expression '${U}':`,q),U}}static getNestedValue(U,X){let q=U.split("."),Z=X;for(let Q of q){if(Z===null||Z===void 0||typeof Z!=="object"||!(Q in Z))return;Z=Z[Q]}return Z}static evaluateMath(U,X){let q=U;q=q.replace(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g,(Z)=>{if(["Math","random","floor","ceil","round","sqrt","abs","pow","min","max","sin","cos","tan"].includes(Z))return Z;let Q=this.getNestedValue(Z,X);if(Q!==void 0)return typeof Q==="string"?`"${Q}"`:String(Q);return Z});try{return this.evaluateMathExpression(q)}catch(Z){return console.error(`Error en evaluación matemática: ${U}`,Z),NaN}}}class b4{store=new Map;async loadState(){return new Map(this.store)}async saveState(U,X){this.store.set(U,X)}async deleteState(U){this.store.delete(U)}async clearState(){this.store.clear()}}class U0{static instance;state;persistence;constructor(){this.state={},this.persistence=new b4}static getInstance(){if(!U0.instance)U0.instance=new U0;return U0.instance}setPersistence(U){this.persistence=U}async initialize(){let U=await this.persistence.loadState();if(U instanceof Map)this.state=Object.fromEntries(U);else this.state=U||{};console.log(`[StateManager] Initialized with ${Object.keys(this.state).length} root keys.`)}get(U){return this.state[U]}async set(U,X){this.state[U]=X,await this.persistence.saveState(U,X)}async increment(U,X=1){let q=this.state[U]||0,Z=Number(q)+X;return this.state[U]=Z,await this.persistence.saveState(U,Z),Z}async decrement(U,X=1){return this.increment(U,-X)}async delete(U){if(U in this.state)return delete this.state[U],await this.persistence.deleteState(U),!0;return!1}async clear(){this.state={},await this.persistence.clearState()}async applyConfig(U){if(!U.state)return;for(let[X,q]of Object.entries(U.state))if(typeof q!=="object"||q===null||!("value"in q)){if(this.state[X]===void 0)await this.set(X,q)}else{let Z=q;if(this.state[X]===void 0)await this.set(X,Z.value);if(Z.lifecycle?.ttl)this.setupTTL(X,Z.lifecycle.ttl)}}setupTTL(U,X){let q=0;if(typeof X==="number")q=X;else{let Z=X.match(/^(\d+)([smhd])$/);if(Z&&Z[1]&&Z[2]){let Q=parseInt(Z[1]),G=Z[2];q=Q*({s:1000,m:60000,h:3600000,d:86400000}[G]||0)}}if(q>0)setTimeout(()=>{this.delete(U).catch(console.error)},q)}getAll(){return{...this.state}}getLiveProxy(){let U=this;function X(q,Z=[]){return new Proxy(q,{get(Q,G){let Y=Q[G];if(Y&&typeof Y==="object"&&!Array.isArray(Y))return X(Y,[...Z,G]);return Y},set(Q,G,Y){if(typeof G!=="string")return!1;Q[G]=Y;let J=Z.length>0?Z[0]:G;if(J)U.persistence.saveState(J,U.state[J]);return!0}})}return X(this.state)}}var P1=()=>{};var VX={};OX(VX,{ActionRegistry:()=>I1});class I1{static instance;handlers=new Map;constructor(){this.registerDefaults()}static getInstance(){if(!this.instance)this.instance=new I1;return this.instance}register(U,X){this.handlers.set(U.toUpperCase(),X)}get(U){return this.handlers.get(U.toUpperCase())}registerDefaults(){this.register("log",(U,X)=>{let q=U.params?.message||U.params?.content||"Log Trigger",Z=typeof q==="string"?e.interpolate(q,X):String(q);return console.log(`[TriggerLog] ${Z}`),{message:Z}}),this.register("math",(U,X)=>{let q=String(U.params?.expression||"0");return e.evaluate(q,X)}),this.register("response",(U,X)=>{let q=U.params?.content||U.params?.body||"",Z=typeof q==="string"?e.interpolate(q,X):String(q);return{statusCode:U.params?.statusCode||200,headers:U.params?.headers||{"Content-Type":"application/json"},body:Z}}),this.register("execute",async(U,X)=>{let q=U.params?.command||U.params?.content||"",Z=typeof q==="string"?e.interpolate(q,X):String(q);if(!U.params?.safe)console.warn(`[Trigger] Ejecutando comando no seguro: ${Z}`);try{let Q=Bun.spawn(Z.split(" "),{stdout:"pipe",stderr:"pipe"}),[G,Y]=await Promise.all([new Response(Q.stdout).text(),new Response(Q.stderr).text()]);return{command:Z,stdout:G,stderr:Y,exitCode:await Q.exited}}catch(Q){return{command:Z,error:String(Q)}}}),this.register("forward",async(U,X)=>{let q=U.params?.url||"",Z=typeof q==="string"?e.interpolate(q,X):String(q),Q=String(U.params?.method||"POST").toUpperCase(),Y=["POST","PUT","PATCH"].includes(Q);try{let J=await fetch(Z,{method:Q,headers:{"Content-Type":"application/json",...typeof U.params?.headers==="object"&&U.params.headers!==null&&!Array.isArray(U.params.headers)?U.params.headers:{}},...Y?{body:JSON.stringify(X.data)}:{}});return{url:Z,method:Q,status:J.status,headers:(()=>{let H={};return J.headers.forEach((W,$)=>H[$]=W),H})(),body:await J.text()}}catch(J){return{url:Z,method:Q,error:String(J)}}}),this.register("STATE_SET",async(U,X)=>{let q=String(U.params?.key||""),Z=U.params?.value;if(!q)return{error:"Missing key for STATE_SET"};let Q=Z;if(typeof Z==="string"&&Z.includes("${"))Q=e.interpolate(Z,X);return await U0.getInstance().set(q,Q),{key:q,value:Q}}),this.register("STATE_INCREMENT",async(U,X)=>{let q=String(U.params?.key||""),Z=Number(U.params?.amount)||1;if(!q)return{error:"Missing key for STATE_INCREMENT"};let Q=await U0.getInstance().increment(q,Z);return{key:q,newValue:Q}}),this.register("STATE_GET",async(U,X)=>{let q=String(U.params?.key||""),Z=String(U.params?.as||q);if(!q)return{error:"Missing key for STATE_GET"};let Q=await U0.getInstance().get(q);if(!X.env)X.env={};return X.env[Z]=Q,{key:q,value:Q,storedAs:Z}}),this.register("STATE_DELETE",async(U,X)=>{let q=String(U.params?.key||"");if(!q)return{error:"Missing key for STATE_DELETE"};let Z=await U0.getInstance().delete(q);return{key:q,deleted:Z}}),this.register("EMIT_EVENT",(U,X)=>{return{event:U.params?.event,payload:U.params?.data||{}}}),this.register("notify",(U,X)=>{let q=U.params?.message||U.params?.content||"Notification",Z=U.params?.target||"default";return console.log(`[Notification] To: ${Z}, Msg: ${q}`),{target:Z,message:q}}),this.register("STATE_OP",(U,X)=>{if(U.params?.run)return Function("context","state","data","vars","env","helpers",`with(context) { ${U.params.run} }`)(X,X.state,X.data,X.vars,X.env,X.helpers);return{warning:"Missing 'run' param for STATE_OP"}})}}var Q2=BX(()=>{P1()});var k=R((WJ)=>{var t9=Symbol.for("yaml.alias"),v8=Symbol.for("yaml.document"),l6=Symbol.for("yaml.map"),h8=Symbol.for("yaml.pair"),e9=Symbol.for("yaml.scalar"),d6=Symbol.for("yaml.seq"),u0=Symbol.for("yaml.node.type"),qJ=(U)=>!!U&&typeof U==="object"&&U[u0]===t9,ZJ=(U)=>!!U&&typeof U==="object"&&U[u0]===v8,QJ=(U)=>!!U&&typeof U==="object"&&U[u0]===l6,GJ=(U)=>!!U&&typeof U==="object"&&U[u0]===h8,x8=(U)=>!!U&&typeof U==="object"&&U[u0]===e9,YJ=(U)=>!!U&&typeof U==="object"&&U[u0]===d6;function u8(U){if(U&&typeof U==="object")switch(U[u0]){case l6:case d6:return!0}return!1}function JJ(U){if(U&&typeof U==="object")switch(U[u0]){case t9:case l6:case e9:case d6:return!0}return!1}var HJ=(U)=>(x8(U)||u8(U))&&!!U.anchor;WJ.ALIAS=t9;WJ.DOC=v8;WJ.MAP=l6;WJ.NODE_TYPE=u0;WJ.PAIR=h8;WJ.SCALAR=e9;WJ.SEQ=d6;WJ.hasAnchor=HJ;WJ.isAlias=qJ;WJ.isCollection=u8;WJ.isDocument=ZJ;WJ.isMap=QJ;WJ.isNode=JJ;WJ.isPair=GJ;WJ.isScalar=x8;WJ.isSeq=YJ});var k2=R((KJ)=>{var t=k(),L0=Symbol("break visit"),m8=Symbol("skip children"),b0=Symbol("remove node");function c6(U,X){let q=p8(X);if(t.isDocument(U)){if(c1(null,U.contents,q,Object.freeze([U]))===b0)U.contents=null}else c1(null,U,q,Object.freeze([]))}c6.BREAK=L0;c6.SKIP=m8;c6.REMOVE=b0;function c1(U,X,q,Z){let Q=l8(U,X,q,Z);if(t.isNode(Q)||t.isPair(Q))return d8(U,Z,Q),c1(U,Q,q,Z);if(typeof Q!=="symbol"){if(t.isCollection(X)){Z=Object.freeze(Z.concat(X));for(let G=0;G<X.items.length;++G){let Y=c1(G,X.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===L0)return L0;else if(Y===b0)X.items.splice(G,1),G-=1}}else if(t.isPair(X)){Z=Object.freeze(Z.concat(X));let G=c1("key",X.key,q,Z);if(G===L0)return L0;else if(G===b0)X.key=null;let Y=c1("value",X.value,q,Z);if(Y===L0)return L0;else if(Y===b0)X.value=null}}return Q}async function i6(U,X){let q=p8(X);if(t.isDocument(U)){if(await i1(null,U.contents,q,Object.freeze([U]))===b0)U.contents=null}else await i1(null,U,q,Object.freeze([]))}i6.BREAK=L0;i6.SKIP=m8;i6.REMOVE=b0;async function i1(U,X,q,Z){let Q=await l8(U,X,q,Z);if(t.isNode(Q)||t.isPair(Q))return d8(U,Z,Q),i1(U,Q,q,Z);if(typeof Q!=="symbol"){if(t.isCollection(X)){Z=Object.freeze(Z.concat(X));for(let G=0;G<X.items.length;++G){let Y=await i1(G,X.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===L0)return L0;else if(Y===b0)X.items.splice(G,1),G-=1}}else if(t.isPair(X)){Z=Object.freeze(Z.concat(X));let G=await i1("key",X.key,q,Z);if(G===L0)return L0;else if(G===b0)X.key=null;let Y=await i1("value",X.value,q,Z);if(Y===L0)return L0;else if(Y===b0)X.value=null}}return Q}function p8(U){if(typeof U==="object"&&(U.Collection||U.Node||U.Value))return Object.assign({Alias:U.Node,Map:U.Node,Scalar:U.Node,Seq:U.Node},U.Value&&{Map:U.Value,Scalar:U.Value,Seq:U.Value},U.Collection&&{Map:U.Collection,Seq:U.Collection},U);return U}function l8(U,X,q,Z){if(typeof q==="function")return q(U,X,Z);if(t.isMap(X))return q.Map?.(U,X,Z);if(t.isSeq(X))return q.Seq?.(U,X,Z);if(t.isPair(X))return q.Pair?.(U,X,Z);if(t.isScalar(X))return q.Scalar?.(U,X,Z);if(t.isAlias(X))return q.Alias?.(U,X,Z);return}function d8(U,X,q){let Z=X[X.length-1];if(t.isCollection(Z))Z.items[U]=q;else if(t.isPair(Z))if(U==="key")Z.key=q;else Z.value=q;else if(t.isDocument(Z))Z.contents=q;else{let Q=t.isAlias(Z)?"alias":"scalar";throw Error(`Cannot replace node with ${Q} parent`)}}KJ.visit=c6;KJ.visitAsync=i6});var UU=R((bJ)=>{var c8=k(),SJ=k2(),EJ={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},jJ=(U)=>U.replace(/[!,[\]{}]/g,(X)=>EJ[X]);class V0{constructor(U,X){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},V0.defaultYaml,U),this.tags=Object.assign({},V0.defaultTags,X)}clone(){let U=new V0(this.yaml,this.tags);return U.docStart=this.docStart,U}atDocument(){let U=new V0(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:V0.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},V0.defaultTags);break}return U}add(U,X){if(this.atNextDocument)this.yaml={explicit:V0.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},V0.defaultTags),this.atNextDocument=!1;let q=U.trim().split(/[ \t]+/),Z=q.shift();switch(Z){case"%TAG":{if(q.length!==2){if(X(0,"%TAG directive should contain exactly two parts"),q.length<2)return!1}let[Q,G]=q;return this.tags[Q]=G,!0}case"%YAML":{if(this.yaml.explicit=!0,q.length!==1)return X(0,"%YAML directive should contain exactly one part"),!1;let[Q]=q;if(Q==="1.1"||Q==="1.2")return this.yaml.version=Q,!0;else{let G=/^\d+\.\d+$/.test(Q);return X(6,`Unsupported YAML version ${Q}`,G),!1}}default:return X(0,`Unknown directive ${Z}`,!0),!1}}tagName(U,X){if(U==="!")return"!";if(U[0]!=="!")return X(`Not a valid tag: ${U}`),null;if(U[1]==="<"){let G=U.slice(2,-1);if(G==="!"||G==="!!")return X(`Verbatim tags aren't resolved, so ${U} is invalid.`),null;if(U[U.length-1]!==">")X("Verbatim tags must end with a >");return G}let[,q,Z]=U.match(/^(.*!)([^!]*)$/s);if(!Z)X(`The ${U} tag has no suffix`);let Q=this.tags[q];if(Q)try{return Q+decodeURIComponent(Z)}catch(G){return X(String(G)),null}if(q==="!")return U;return X(`Could not resolve tag: ${U}`),null}tagString(U){for(let[X,q]of Object.entries(this.tags))if(U.startsWith(q))return X+jJ(U.substring(q.length));return U[0]==="!"?U:`!<${U}>`}toString(U){let X=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],q=Object.entries(this.tags),Z;if(U&&q.length>0&&c8.isNode(U.contents)){let Q={};SJ.visit(U.contents,(G,Y)=>{if(c8.isNode(Y)&&Y.tag)Q[Y.tag]=!0}),Z=Object.keys(Q)}else Z=[];for(let[Q,G]of q){if(Q==="!!"&&G==="tag:yaml.org,2002:")continue;if(!U||Z.some((Y)=>Y.startsWith(G)))X.push(`%TAG ${Q} ${G}`)}return X.join(`
2
- `)}}V0.defaultYaml={explicit:!1,version:"1.2"};V0.defaultTags={"!!":"tag:yaml.org,2002:"};bJ.Directives=V0});var s6=R((vJ)=>{var i8=k(),gJ=k2();function yJ(U){if(/[\x00-\x19\s,[\]{}]/.test(U)){let q=`Anchor must not contain whitespace or control characters: ${JSON.stringify(U)}`;throw Error(q)}return!0}function s8(U){let X=new Set;return gJ.visit(U,{Value(q,Z){if(Z.anchor)X.add(Z.anchor)}}),X}function o8(U,X){for(let q=1;;++q){let Z=`${U}${q}`;if(!X.has(Z))return Z}}function kJ(U,X){let q=[],Z=new Map,Q=null;return{onAnchor:(G)=>{q.push(G),Q??(Q=s8(U));let Y=o8(X,Q);return Q.add(Y),Y},setAnchors:()=>{for(let G of q){let Y=Z.get(G);if(typeof Y==="object"&&Y.anchor&&(i8.isScalar(Y.node)||i8.isCollection(Y.node)))Y.node.anchor=Y.anchor;else{let J=Error("Failed to resolve repeated object (this should not happen)");throw J.source=G,J}}},sourceObjects:Z}}vJ.anchorIsValid=yJ;vJ.anchorNames=s8;vJ.createNodeAnchors=kJ;vJ.findNewAnchor=o8});var XU=R((pJ)=>{function v2(U,X,q,Z){if(Z&&typeof Z==="object")if(Array.isArray(Z))for(let Q=0,G=Z.length;Q<G;++Q){let Y=Z[Q],J=v2(U,Z,String(Q),Y);if(J===void 0)delete Z[Q];else if(J!==Y)Z[Q]=J}else if(Z instanceof Map)for(let Q of Array.from(Z.keys())){let G=Z.get(Q),Y=v2(U,Z,Q,G);if(Y===void 0)Z.delete(Q);else if(Y!==G)Z.set(Q,Y)}else if(Z instanceof Set)for(let Q of Array.from(Z)){let G=v2(U,Z,Q,Q);if(G===void 0)Z.delete(Q);else if(G!==Q)Z.delete(Q),Z.add(G)}else for(let[Q,G]of Object.entries(Z)){let Y=v2(U,Z,Q,G);if(Y===void 0)delete Z[Q];else if(Y!==G)Z[Q]=Y}return U.call(X,q,Z)}pJ.applyReviver=v2});var a0=R((cJ)=>{var dJ=k();function r8(U,X,q){if(Array.isArray(U))return U.map((Z,Q)=>r8(Z,String(Q),q));if(U&&typeof U.toJSON==="function"){if(!q||!dJ.hasAnchor(U))return U.toJSON(X,q);let Z={aliasCount:0,count:1,res:void 0};q.anchors.set(U,Z),q.onCreate=(G)=>{Z.res=G,delete q.onCreate};let Q=U.toJSON(X,q);if(q.onCreate)q.onCreate(Q);return Q}if(typeof U==="bigint"&&!q?.keep)return Number(U);return U}cJ.toJS=r8});var o6=R((rJ)=>{var sJ=XU(),n8=k(),oJ=a0();class a8{constructor(U){Object.defineProperty(this,n8.NODE_TYPE,{value:U})}clone(){let U=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)U.range=this.range.slice();return U}toJS(U,{mapAsMap:X,maxAliasCount:q,onAnchor:Z,reviver:Q}={}){if(!n8.isDocument(U))throw TypeError("A document argument is required");let G={anchors:new Map,doc:U,keep:!0,mapAsMap:X===!0,mapKeyWarned:!1,maxAliasCount:typeof q==="number"?q:100},Y=oJ.toJS(this,"",G);if(typeof Z==="function")for(let{count:J,res:H}of G.anchors.values())Z(H,J);return typeof Q==="function"?sJ.applyReviver(Q,{"":Y},"",Y):Y}}rJ.NodeBase=a8});var h2=R((XH)=>{var aJ=s6(),tJ=k2(),s1=k(),eJ=o6(),UH=a0();class t8 extends eJ.NodeBase{constructor(U){super(s1.ALIAS);this.source=U,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(U,X){let q;if(X?.aliasResolveCache)q=X.aliasResolveCache;else if(q=[],tJ.visit(U,{Node:(Q,G)=>{if(s1.isAlias(G)||s1.hasAnchor(G))q.push(G)}}),X)X.aliasResolveCache=q;let Z=void 0;for(let Q of q){if(Q===this)break;if(Q.anchor===this.source)Z=Q}return Z}toJSON(U,X){if(!X)return{source:this.source};let{anchors:q,doc:Z,maxAliasCount:Q}=X,G=this.resolve(Z,X);if(!G){let J=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(J)}let Y=q.get(G);if(!Y)UH.toJS(G,null,X),Y=q.get(G);if(Y?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(Q>=0){if(Y.count+=1,Y.aliasCount===0)Y.aliasCount=r6(Z,G,q);if(Y.count*Y.aliasCount>Q)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return Y.res}toString(U,X,q){let Z=`*${this.source}`;if(U){if(aJ.anchorIsValid(this.source),U.options.verifyAliasOrder&&!U.anchors.has(this.source)){let Q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(Q)}if(U.implicitKey)return`${Z} `}return Z}}function r6(U,X,q){if(s1.isAlias(X)){let Z=X.resolve(U),Q=q&&Z&&q.get(Z);return Q?Q.count*Q.aliasCount:0}else if(s1.isCollection(X)){let Z=0;for(let Q of X.items){let G=r6(U,Q,q);if(G>Z)Z=G}return Z}else if(s1.isPair(X)){let Z=r6(U,X.key,q),Q=r6(U,X.value,q);return Math.max(Z,Q)}return 1}XH.Alias=t8});var i=R((JH)=>{var ZH=k(),QH=o6(),GH=a0(),YH=(U)=>!U||typeof U!=="function"&&typeof U!=="object";class F1 extends QH.NodeBase{constructor(U){super(ZH.SCALAR);this.value=U}toJSON(U,X){return X?.keep?this.value:GH.toJS(this.value,U,X)}toString(){return String(this.value)}}F1.BLOCK_FOLDED="BLOCK_FOLDED";F1.BLOCK_LITERAL="BLOCK_LITERAL";F1.PLAIN="PLAIN";F1.QUOTE_DOUBLE="QUOTE_DOUBLE";F1.QUOTE_SINGLE="QUOTE_SINGLE";JH.Scalar=F1;JH.isScalarValue=YH});var x2=R((FH)=>{var _H=h2(),A1=k(),e8=i(),$H="tag:yaml.org,2002:";function LH(U,X,q){if(X){let Z=q.filter((G)=>G.tag===X),Q=Z.find((G)=>!G.format)??Z[0];if(!Q)throw Error(`Tag ${X} not found`);return Q}return q.find((Z)=>Z.identify?.(U)&&!Z.format)}function zH(U,X,q){if(A1.isDocument(U))U=U.contents;if(A1.isNode(U))return U;if(A1.isPair(U)){let _=q.schema[A1.MAP].createNode?.(q.schema,null,q);return _.items.push(U),_}if(U instanceof String||U instanceof Number||U instanceof Boolean||typeof BigInt<"u"&&U instanceof BigInt)U=U.valueOf();let{aliasDuplicateObjects:Z,onAnchor:Q,onTagObj:G,schema:Y,sourceObjects:J}=q,H=void 0;if(Z&&U&&typeof U==="object")if(H=J.get(U),H)return H.anchor??(H.anchor=Q(U)),new _H.Alias(H.anchor);else H={anchor:null,node:null},J.set(U,H);if(X?.startsWith("!!"))X=$H+X.slice(2);let W=LH(U,X,Y.tags);if(!W){if(U&&typeof U.toJSON==="function")U=U.toJSON();if(!U||typeof U!=="object"){let _=new e8.Scalar(U);if(H)H.node=_;return _}W=U instanceof Map?Y[A1.MAP]:(Symbol.iterator in Object(U))?Y[A1.SEQ]:Y[A1.MAP]}if(G)G(W),delete q.onTagObj;let $=W?.createNode?W.createNode(q.schema,U,q):typeof W?.nodeClass?.from==="function"?W.nodeClass.from(q.schema,U,q):new e8.Scalar(U);if(X)$.tag=X;else if(!W.default)$.tag=W.tag;if(H)H.node=$;return $}FH.createNode=zH});var n6=R((TH)=>{var OH=x2(),f0=k(),BH=o6();function qU(U,X,q){let Z=q;for(let Q=X.length-1;Q>=0;--Q){let G=X[Q];if(typeof G==="number"&&Number.isInteger(G)&&G>=0){let Y=[];Y[G]=Z,Z=Y}else Z=new Map([[G,Z]])}return OH.createNode(Z,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:U,sourceObjects:new Map})}var U3=(U)=>U==null||typeof U==="object"&&!!U[Symbol.iterator]().next().done;class X3 extends BH.NodeBase{constructor(U,X){super(U);Object.defineProperty(this,"schema",{value:X,configurable:!0,enumerable:!1,writable:!0})}clone(U){let X=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(U)X.schema=U;if(X.items=X.items.map((q)=>f0.isNode(q)||f0.isPair(q)?q.clone(U):q),this.range)X.range=this.range.slice();return X}addIn(U,X){if(U3(U))this.add(X);else{let[q,...Z]=U,Q=this.get(q,!0);if(f0.isCollection(Q))Q.addIn(Z,X);else if(Q===void 0&&this.schema)this.set(q,qU(this.schema,Z,X));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${Z}`)}}deleteIn(U){let[X,...q]=U;if(q.length===0)return this.delete(X);let Z=this.get(X,!0);if(f0.isCollection(Z))return Z.deleteIn(q);else throw Error(`Expected YAML collection at ${X}. Remaining path: ${q}`)}getIn(U,X){let[q,...Z]=U,Q=this.get(q,!0);if(Z.length===0)return!X&&f0.isScalar(Q)?Q.value:Q;else return f0.isCollection(Q)?Q.getIn(Z,X):void 0}hasAllNullValues(U){return this.items.every((X)=>{if(!f0.isPair(X))return!1;let q=X.value;return q==null||U&&f0.isScalar(q)&&q.value==null&&!q.commentBefore&&!q.comment&&!q.tag})}hasIn(U){let[X,...q]=U;if(q.length===0)return this.has(X);let Z=this.get(X,!0);return f0.isCollection(Z)?Z.hasIn(q):!1}setIn(U,X){let[q,...Z]=U;if(Z.length===0)this.set(q,X);else{let Q=this.get(q,!0);if(f0.isCollection(Q))Q.setIn(Z,X);else if(Q===void 0&&this.schema)this.set(q,qU(this.schema,Z,X));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${Z}`)}}}TH.Collection=X3;TH.collectionFromPath=qU;TH.isEmptyPath=U3});var u2=R((PH)=>{var MH=(U)=>U.replace(/^(?!$)(?: $)?/gm,"#");function ZU(U,X){if(/^\n+$/.test(U))return U.substring(1);return X?U.replace(/^(?! *$)/gm,X):U}var wH=(U,X,q)=>U.endsWith(`
1
+ import{createRequire as qG}from"node:module";var rQ=Object.create;var{getPrototypeOf:nQ,defineProperty:Z2,getOwnPropertyNames:LX,getOwnPropertyDescriptor:aQ}=Object,zX=Object.prototype.hasOwnProperty;function FX(U){return this[U]}var tQ,eQ,AX=(U,X,q)=>{var Z=U!=null&&typeof U==="object";if(Z){var Q=X?tQ??=new WeakMap:eQ??=new WeakMap,G=Q.get(U);if(G)return G}q=U!=null?rQ(nQ(U)):{};let Y=X||!U||!U.__esModule?Z2(q,"default",{value:U,enumerable:!0}):q;for(let J of LX(U))if(!zX.call(Y,J))Z2(Y,J,{get:FX.bind(U,J),enumerable:!0});if(Z)Q.set(U,Y);return Y},OX=(U)=>{var X=($X??=new WeakMap).get(U),q;if(X)return X;if(X=Z2({},"__esModule",{value:!0}),U&&typeof U==="object"||typeof U==="function"){for(var Z of LX(U))if(!zX.call(X,Z))Z2(X,Z,{get:FX.bind(U,Z),enumerable:!(q=aQ(U,Z))||q.enumerable})}return $X.set(U,X),X},$X,R=(U,X)=>()=>(X||U((X={exports:{}}).exports,X),X.exports);var UG=(U)=>U;function XG(U,X){this[U]=UG.bind(null,X)}var BX=(U,X)=>{for(var q in X)Z2(U,q,{get:X[q],enumerable:!0,configurable:!0,set:XG.bind(X,q)})};var TX=(U,X)=>()=>(U&&(X=U(U=0)),X);var w1=qG(import.meta.url);var j4={};BX(j4,{ExpressionEngine:()=>e});class e{static evaluate(U,X){try{if(U.includes("${")){let q=this.interpolate(U,X);if(!isNaN(Number(q))&&q.trim()!=="")return Number(q);return q}return this.evaluateExpression(U,X)}catch(q){return console.error(`Error evaluating expression: ${U}`,q),null}}static interpolate(U,X){return U.replace(/\$\{([^}]+)\}/g,(q,Z)=>{try{let Q=this.evaluateExpression(Z,X);if(Q===void 0||Q===null)return"undefined";return String(Q)}catch(Q){return console.error(`Error en interpolación: ${q}`,Q),q}})}static evaluateMathExpression(U){try{return Function("Math",`return ${U}`)(Math)}catch(X){throw Error(`Error evaluando expresión matemática: ${U}`)}}static evaluateExpression(U,X){if(/^(data|vars|request|computed|env|state)(\.[a-zA-Z0-9_]+)+$/.test(U))return this.getNestedValue(U,X);if(/^(vars|env|state)(\.[a-zA-Z0-9_]+)$/.test(U))return this.getNestedValue(U,X);try{return Function("context","with(context) { return "+U+" }")(X)}catch(q){return console.error(`ERROR evaluating expression '${U}':`,q),U}}static getNestedValue(U,X){let q=U.split("."),Z=X;for(let Q of q){if(Z===null||Z===void 0||typeof Z!=="object"||!(Q in Z))return;Z=Z[Q]}return Z}static evaluateMath(U,X){let q=U;q=q.replace(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g,(Z)=>{if(["Math","random","floor","ceil","round","sqrt","abs","pow","min","max","sin","cos","tan"].includes(Z))return Z;let Q=this.getNestedValue(Z,X);if(Q!==void 0)return typeof Q==="string"?`"${Q}"`:String(Q);return Z});try{return this.evaluateMathExpression(q)}catch(Z){return console.error(`Error en evaluación matemática: ${U}`,Z),NaN}}}class b4{store=new Map;async loadState(){return new Map(this.store)}async saveState(U,X){this.store.set(U,X)}async deleteState(U){this.store.delete(U)}async clearState(){this.store.clear()}}class U0{static instance;state;persistence;constructor(){this.state={},this.persistence=new b4}static getInstance(){if(!U0.instance)U0.instance=new U0;return U0.instance}setPersistence(U){this.persistence=U}async initialize(){let U=await this.persistence.loadState();if(U instanceof Map)this.state=Object.fromEntries(U);else this.state=U||{};console.log(`[StateManager] Initialized with ${Object.keys(this.state).length} root keys.`)}get(U){return this.state[U]}async set(U,X){this.state[U]=X,await this.persistence.saveState(U,X)}async increment(U,X=1){let q=this.state[U]||0,Z=Number(q)+X;return this.state[U]=Z,await this.persistence.saveState(U,Z),Z}async decrement(U,X=1){return this.increment(U,-X)}async delete(U){if(U in this.state)return delete this.state[U],await this.persistence.deleteState(U),!0;return!1}async clear(){this.state={},await this.persistence.clearState()}async applyConfig(U){if(!U.state)return;for(let[X,q]of Object.entries(U.state))if(typeof q!=="object"||q===null||!("value"in q)){if(this.state[X]===void 0)await this.set(X,q)}else{let Z=q;if(this.state[X]===void 0)await this.set(X,Z.value);if(Z.lifecycle?.ttl)this.setupTTL(X,Z.lifecycle.ttl)}}setupTTL(U,X){let q=0;if(typeof X==="number")q=X;else{let Z=X.match(/^(\d+)([smhd])$/);if(Z&&Z[1]&&Z[2]){let Q=parseInt(Z[1]),G=Z[2];q=Q*({s:1000,m:60000,h:3600000,d:86400000}[G]||0)}}if(q>0)setTimeout(()=>{this.delete(U).catch(console.error)},q)}getAll(){return{...this.state}}getLiveProxy(){let U=this;function X(q,Z=[]){return new Proxy(q,{get(Q,G){let Y=Q[G];if(Y&&typeof Y==="object"&&!Array.isArray(Y))return X(Y,[...Z,G]);return Y},set(Q,G,Y){if(typeof G!=="string")return!1;Q[G]=Y;let J=Z.length>0?Z[0]:G;if(J)U.persistence.saveState(J,U.state[J]);return!0}})}return X(this.state)}}var P1=()=>{};var RX={};BX(RX,{ActionRegistry:()=>I1});class I1{static instance;handlers=new Map;constructor(){this.registerDefaults()}static getInstance(){if(!this.instance)this.instance=new I1;return this.instance}register(U,X){this.handlers.set(U.toUpperCase(),X)}get(U){return this.handlers.get(U.toUpperCase())}get Handlers(){return this.handlers}registerDefaults(){this.register("log",(U,X)=>{let q=U.params?.message||U.params?.content||"Log Trigger",Z=typeof q==="string"?e.interpolate(q,X):String(q);return console.log(`[TriggerLog] ${Z}`),{message:Z}}),this.register("math",(U,X)=>{let q=String(U.params?.expression||"0");return e.evaluate(q,X)}),this.register("response",(U,X)=>{let q=U.params?.content||U.params?.body||"",Z=typeof q==="string"?e.interpolate(q,X):String(q);return{statusCode:U.params?.statusCode||200,headers:U.params?.headers||{"Content-Type":"application/json"},body:Z}}),this.register("execute",async(U,X)=>{let q=U.params?.command||U.params?.content||"",Z=typeof q==="string"?e.interpolate(q,X):String(q);if(!U.params?.safe)console.warn(`[Trigger] Ejecutando comando no seguro: ${Z}`);try{let Q=Bun.spawn(Z.split(" "),{stdout:"pipe",stderr:"pipe"}),[G,Y]=await Promise.all([new Response(Q.stdout).text(),new Response(Q.stderr).text()]);return{command:Z,stdout:G,stderr:Y,exitCode:await Q.exited}}catch(Q){return{command:Z,error:String(Q)}}}),this.register("forward",async(U,X)=>{let q=U.params?.url||"",Z=typeof q==="string"?e.interpolate(q,X):String(q),Q=String(U.params?.method||"POST").toUpperCase(),Y=["POST","PUT","PATCH"].includes(Q);try{let J=await fetch(Z,{method:Q,headers:{"Content-Type":"application/json",...typeof U.params?.headers==="object"&&U.params.headers!==null&&!Array.isArray(U.params.headers)?U.params.headers:{}},...Y?{body:JSON.stringify(X.data)}:{}});return{url:Z,method:Q,status:J.status,headers:(()=>{let H={};return J.headers.forEach((W,$)=>H[$]=W),H})(),body:await J.text()}}catch(J){return{url:Z,method:Q,error:String(J)}}}),this.register("STATE_SET",async(U,X)=>{let q=String(U.params?.key||""),Z=U.params?.value;if(!q)return{error:"Missing key for STATE_SET"};let Q=Z;if(typeof Z==="string"&&Z.includes("${"))Q=e.interpolate(Z,X);return await U0.getInstance().set(q,Q),{key:q,value:Q}}),this.register("STATE_INCREMENT",async(U,X)=>{let q=String(U.params?.key||""),Z=Number(U.params?.amount)||1;if(!q)return{error:"Missing key for STATE_INCREMENT"};let Q=await U0.getInstance().increment(q,Z);return{key:q,newValue:Q}}),this.register("STATE_GET",async(U,X)=>{let q=String(U.params?.key||""),Z=String(U.params?.as||q);if(!q)return{error:"Missing key for STATE_GET"};let Q=await U0.getInstance().get(q);if(!X.env)X.env={};return X.env[Z]=Q,{key:q,value:Q,storedAs:Z}}),this.register("STATE_DELETE",async(U,X)=>{let q=String(U.params?.key||"");if(!q)return{error:"Missing key for STATE_DELETE"};let Z=await U0.getInstance().delete(q);return{key:q,deleted:Z}}),this.register("EMIT_EVENT",(U,X)=>{return{event:U.params?.event,payload:U.params?.data||{}}}),this.register("notify",(U,X)=>{let q=U.params?.message||U.params?.content||"Notification",Z=U.params?.target||"default";return console.log(`[Notification] To: ${Z}, Msg: ${q}`),{target:Z,message:q}}),this.register("STATE_OP",(U,X)=>{if(U.params?.run)return Function("context","state","data","vars","env","helpers",`with(context) { ${U.params.run} }`)(X,X.state,X.data,X.vars,X.env,X.helpers);return{warning:"Missing 'run' param for STATE_OP"}})}}var Q2=TX(()=>{P1()});var k=R((FJ)=>{var t9=Symbol.for("yaml.alias"),h8=Symbol.for("yaml.document"),l6=Symbol.for("yaml.map"),x8=Symbol.for("yaml.pair"),e9=Symbol.for("yaml.scalar"),d6=Symbol.for("yaml.seq"),u0=Symbol.for("yaml.node.type"),JJ=(U)=>!!U&&typeof U==="object"&&U[u0]===t9,HJ=(U)=>!!U&&typeof U==="object"&&U[u0]===h8,WJ=(U)=>!!U&&typeof U==="object"&&U[u0]===l6,_J=(U)=>!!U&&typeof U==="object"&&U[u0]===x8,u8=(U)=>!!U&&typeof U==="object"&&U[u0]===e9,$J=(U)=>!!U&&typeof U==="object"&&U[u0]===d6;function m8(U){if(U&&typeof U==="object")switch(U[u0]){case l6:case d6:return!0}return!1}function LJ(U){if(U&&typeof U==="object")switch(U[u0]){case t9:case l6:case e9:case d6:return!0}return!1}var zJ=(U)=>(u8(U)||m8(U))&&!!U.anchor;FJ.ALIAS=t9;FJ.DOC=h8;FJ.MAP=l6;FJ.NODE_TYPE=u0;FJ.PAIR=x8;FJ.SCALAR=e9;FJ.SEQ=d6;FJ.hasAnchor=zJ;FJ.isAlias=JJ;FJ.isCollection=m8;FJ.isDocument=HJ;FJ.isMap=WJ;FJ.isNode=LJ;FJ.isPair=_J;FJ.isScalar=u8;FJ.isSeq=$J});var k2=R((jJ)=>{var t=k(),L0=Symbol("break visit"),p8=Symbol("skip children"),b0=Symbol("remove node");function c6(U,X){let q=l8(X);if(t.isDocument(U)){if(c1(null,U.contents,q,Object.freeze([U]))===b0)U.contents=null}else c1(null,U,q,Object.freeze([]))}c6.BREAK=L0;c6.SKIP=p8;c6.REMOVE=b0;function c1(U,X,q,Z){let Q=d8(U,X,q,Z);if(t.isNode(Q)||t.isPair(Q))return c8(U,Z,Q),c1(U,Q,q,Z);if(typeof Q!=="symbol"){if(t.isCollection(X)){Z=Object.freeze(Z.concat(X));for(let G=0;G<X.items.length;++G){let Y=c1(G,X.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===L0)return L0;else if(Y===b0)X.items.splice(G,1),G-=1}}else if(t.isPair(X)){Z=Object.freeze(Z.concat(X));let G=c1("key",X.key,q,Z);if(G===L0)return L0;else if(G===b0)X.key=null;let Y=c1("value",X.value,q,Z);if(Y===L0)return L0;else if(Y===b0)X.value=null}}return Q}async function i6(U,X){let q=l8(X);if(t.isDocument(U)){if(await i1(null,U.contents,q,Object.freeze([U]))===b0)U.contents=null}else await i1(null,U,q,Object.freeze([]))}i6.BREAK=L0;i6.SKIP=p8;i6.REMOVE=b0;async function i1(U,X,q,Z){let Q=await d8(U,X,q,Z);if(t.isNode(Q)||t.isPair(Q))return c8(U,Z,Q),i1(U,Q,q,Z);if(typeof Q!=="symbol"){if(t.isCollection(X)){Z=Object.freeze(Z.concat(X));for(let G=0;G<X.items.length;++G){let Y=await i1(G,X.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===L0)return L0;else if(Y===b0)X.items.splice(G,1),G-=1}}else if(t.isPair(X)){Z=Object.freeze(Z.concat(X));let G=await i1("key",X.key,q,Z);if(G===L0)return L0;else if(G===b0)X.key=null;let Y=await i1("value",X.value,q,Z);if(Y===L0)return L0;else if(Y===b0)X.value=null}}return Q}function l8(U){if(typeof U==="object"&&(U.Collection||U.Node||U.Value))return Object.assign({Alias:U.Node,Map:U.Node,Scalar:U.Node,Seq:U.Node},U.Value&&{Map:U.Value,Scalar:U.Value,Seq:U.Value},U.Collection&&{Map:U.Collection,Seq:U.Collection},U);return U}function d8(U,X,q,Z){if(typeof q==="function")return q(U,X,Z);if(t.isMap(X))return q.Map?.(U,X,Z);if(t.isSeq(X))return q.Seq?.(U,X,Z);if(t.isPair(X))return q.Pair?.(U,X,Z);if(t.isScalar(X))return q.Scalar?.(U,X,Z);if(t.isAlias(X))return q.Alias?.(U,X,Z);return}function c8(U,X,q){let Z=X[X.length-1];if(t.isCollection(Z))Z.items[U]=q;else if(t.isPair(Z))if(U==="key")Z.key=q;else Z.value=q;else if(t.isDocument(Z))Z.contents=q;else{let Q=t.isAlias(Z)?"alias":"scalar";throw Error(`Cannot replace node with ${Q} parent`)}}jJ.visit=c6;jJ.visitAsync=i6});var UU=R((vJ)=>{var i8=k(),gJ=k2(),yJ={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},kJ=(U)=>U.replace(/[!,[\]{}]/g,(X)=>yJ[X]);class V0{constructor(U,X){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},V0.defaultYaml,U),this.tags=Object.assign({},V0.defaultTags,X)}clone(){let U=new V0(this.yaml,this.tags);return U.docStart=this.docStart,U}atDocument(){let U=new V0(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:V0.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},V0.defaultTags);break}return U}add(U,X){if(this.atNextDocument)this.yaml={explicit:V0.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},V0.defaultTags),this.atNextDocument=!1;let q=U.trim().split(/[ \t]+/),Z=q.shift();switch(Z){case"%TAG":{if(q.length!==2){if(X(0,"%TAG directive should contain exactly two parts"),q.length<2)return!1}let[Q,G]=q;return this.tags[Q]=G,!0}case"%YAML":{if(this.yaml.explicit=!0,q.length!==1)return X(0,"%YAML directive should contain exactly one part"),!1;let[Q]=q;if(Q==="1.1"||Q==="1.2")return this.yaml.version=Q,!0;else{let G=/^\d+\.\d+$/.test(Q);return X(6,`Unsupported YAML version ${Q}`,G),!1}}default:return X(0,`Unknown directive ${Z}`,!0),!1}}tagName(U,X){if(U==="!")return"!";if(U[0]!=="!")return X(`Not a valid tag: ${U}`),null;if(U[1]==="<"){let G=U.slice(2,-1);if(G==="!"||G==="!!")return X(`Verbatim tags aren't resolved, so ${U} is invalid.`),null;if(U[U.length-1]!==">")X("Verbatim tags must end with a >");return G}let[,q,Z]=U.match(/^(.*!)([^!]*)$/s);if(!Z)X(`The ${U} tag has no suffix`);let Q=this.tags[q];if(Q)try{return Q+decodeURIComponent(Z)}catch(G){return X(String(G)),null}if(q==="!")return U;return X(`Could not resolve tag: ${U}`),null}tagString(U){for(let[X,q]of Object.entries(this.tags))if(U.startsWith(q))return X+kJ(U.substring(q.length));return U[0]==="!"?U:`!<${U}>`}toString(U){let X=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],q=Object.entries(this.tags),Z;if(U&&q.length>0&&i8.isNode(U.contents)){let Q={};gJ.visit(U.contents,(G,Y)=>{if(i8.isNode(Y)&&Y.tag)Q[Y.tag]=!0}),Z=Object.keys(Q)}else Z=[];for(let[Q,G]of q){if(Q==="!!"&&G==="tag:yaml.org,2002:")continue;if(!U||Z.some((Y)=>Y.startsWith(G)))X.push(`%TAG ${Q} ${G}`)}return X.join(`
2
+ `)}}V0.defaultYaml={explicit:!1,version:"1.2"};V0.defaultTags={"!!":"tag:yaml.org,2002:"};vJ.Directives=V0});var s6=R((pJ)=>{var s8=k(),xJ=k2();function uJ(U){if(/[\x00-\x19\s,[\]{}]/.test(U)){let q=`Anchor must not contain whitespace or control characters: ${JSON.stringify(U)}`;throw Error(q)}return!0}function o8(U){let X=new Set;return xJ.visit(U,{Value(q,Z){if(Z.anchor)X.add(Z.anchor)}}),X}function r8(U,X){for(let q=1;;++q){let Z=`${U}${q}`;if(!X.has(Z))return Z}}function mJ(U,X){let q=[],Z=new Map,Q=null;return{onAnchor:(G)=>{q.push(G),Q??(Q=o8(U));let Y=r8(X,Q);return Q.add(Y),Y},setAnchors:()=>{for(let G of q){let Y=Z.get(G);if(typeof Y==="object"&&Y.anchor&&(s8.isScalar(Y.node)||s8.isCollection(Y.node)))Y.node.anchor=Y.anchor;else{let J=Error("Failed to resolve repeated object (this should not happen)");throw J.source=G,J}}},sourceObjects:Z}}pJ.anchorIsValid=uJ;pJ.anchorNames=o8;pJ.createNodeAnchors=mJ;pJ.findNewAnchor=r8});var XU=R((sJ)=>{function v2(U,X,q,Z){if(Z&&typeof Z==="object")if(Array.isArray(Z))for(let Q=0,G=Z.length;Q<G;++Q){let Y=Z[Q],J=v2(U,Z,String(Q),Y);if(J===void 0)delete Z[Q];else if(J!==Y)Z[Q]=J}else if(Z instanceof Map)for(let Q of Array.from(Z.keys())){let G=Z.get(Q),Y=v2(U,Z,Q,G);if(Y===void 0)Z.delete(Q);else if(Y!==G)Z.set(Q,Y)}else if(Z instanceof Set)for(let Q of Array.from(Z)){let G=v2(U,Z,Q,Q);if(G===void 0)Z.delete(Q);else if(G!==Q)Z.delete(Q),Z.add(G)}else for(let[Q,G]of Object.entries(Z)){let Y=v2(U,Z,Q,G);if(Y===void 0)delete Z[Q];else if(Y!==G)Z[Q]=Y}return U.call(X,q,Z)}sJ.applyReviver=v2});var a0=R((nJ)=>{var rJ=k();function n8(U,X,q){if(Array.isArray(U))return U.map((Z,Q)=>n8(Z,String(Q),q));if(U&&typeof U.toJSON==="function"){if(!q||!rJ.hasAnchor(U))return U.toJSON(X,q);let Z={aliasCount:0,count:1,res:void 0};q.anchors.set(U,Z),q.onCreate=(G)=>{Z.res=G,delete q.onCreate};let Q=U.toJSON(X,q);if(q.onCreate)q.onCreate(Q);return Q}if(typeof U==="bigint"&&!q?.keep)return Number(U);return U}nJ.toJS=n8});var o6=R((UH)=>{var tJ=XU(),a8=k(),eJ=a0();class t8{constructor(U){Object.defineProperty(this,a8.NODE_TYPE,{value:U})}clone(){let U=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)U.range=this.range.slice();return U}toJS(U,{mapAsMap:X,maxAliasCount:q,onAnchor:Z,reviver:Q}={}){if(!a8.isDocument(U))throw TypeError("A document argument is required");let G={anchors:new Map,doc:U,keep:!0,mapAsMap:X===!0,mapKeyWarned:!1,maxAliasCount:typeof q==="number"?q:100},Y=eJ.toJS(this,"",G);if(typeof Z==="function")for(let{count:J,res:H}of G.anchors.values())Z(H,J);return typeof Q==="function"?tJ.applyReviver(Q,{"":Y},"",Y):Y}}UH.NodeBase=t8});var h2=R((YH)=>{var qH=s6(),ZH=k2(),s1=k(),QH=o6(),GH=a0();class e8 extends QH.NodeBase{constructor(U){super(s1.ALIAS);this.source=U,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(U,X){let q;if(X?.aliasResolveCache)q=X.aliasResolveCache;else if(q=[],ZH.visit(U,{Node:(Q,G)=>{if(s1.isAlias(G)||s1.hasAnchor(G))q.push(G)}}),X)X.aliasResolveCache=q;let Z=void 0;for(let Q of q){if(Q===this)break;if(Q.anchor===this.source)Z=Q}return Z}toJSON(U,X){if(!X)return{source:this.source};let{anchors:q,doc:Z,maxAliasCount:Q}=X,G=this.resolve(Z,X);if(!G){let J=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(J)}let Y=q.get(G);if(!Y)GH.toJS(G,null,X),Y=q.get(G);if(Y?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(Q>=0){if(Y.count+=1,Y.aliasCount===0)Y.aliasCount=r6(Z,G,q);if(Y.count*Y.aliasCount>Q)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return Y.res}toString(U,X,q){let Z=`*${this.source}`;if(U){if(qH.anchorIsValid(this.source),U.options.verifyAliasOrder&&!U.anchors.has(this.source)){let Q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(Q)}if(U.implicitKey)return`${Z} `}return Z}}function r6(U,X,q){if(s1.isAlias(X)){let Z=X.resolve(U),Q=q&&Z&&q.get(Z);return Q?Q.count*Q.aliasCount:0}else if(s1.isCollection(X)){let Z=0;for(let Q of X.items){let G=r6(U,Q,q);if(G>Z)Z=G}return Z}else if(s1.isPair(X)){let Z=r6(U,X.key,q),Q=r6(U,X.value,q);return Math.max(Z,Q)}return 1}YH.Alias=e8});var i=R((LH)=>{var HH=k(),WH=o6(),_H=a0(),$H=(U)=>!U||typeof U!=="function"&&typeof U!=="object";class F1 extends WH.NodeBase{constructor(U){super(HH.SCALAR);this.value=U}toJSON(U,X){return X?.keep?this.value:_H.toJS(this.value,U,X)}toString(){return String(this.value)}}F1.BLOCK_FOLDED="BLOCK_FOLDED";F1.BLOCK_LITERAL="BLOCK_LITERAL";F1.PLAIN="PLAIN";F1.QUOTE_DOUBLE="QUOTE_DOUBLE";F1.QUOTE_SINGLE="QUOTE_SINGLE";LH.Scalar=F1;LH.isScalarValue=$H});var x2=R((VH)=>{var AH=h2(),A1=k(),U3=i(),OH="tag:yaml.org,2002:";function BH(U,X,q){if(X){let Z=q.filter((G)=>G.tag===X),Q=Z.find((G)=>!G.format)??Z[0];if(!Q)throw Error(`Tag ${X} not found`);return Q}return q.find((Z)=>Z.identify?.(U)&&!Z.format)}function TH(U,X,q){if(A1.isDocument(U))U=U.contents;if(A1.isNode(U))return U;if(A1.isPair(U)){let _=q.schema[A1.MAP].createNode?.(q.schema,null,q);return _.items.push(U),_}if(U instanceof String||U instanceof Number||U instanceof Boolean||typeof BigInt<"u"&&U instanceof BigInt)U=U.valueOf();let{aliasDuplicateObjects:Z,onAnchor:Q,onTagObj:G,schema:Y,sourceObjects:J}=q,H=void 0;if(Z&&U&&typeof U==="object")if(H=J.get(U),H)return H.anchor??(H.anchor=Q(U)),new AH.Alias(H.anchor);else H={anchor:null,node:null},J.set(U,H);if(X?.startsWith("!!"))X=OH+X.slice(2);let W=BH(U,X,Y.tags);if(!W){if(U&&typeof U.toJSON==="function")U=U.toJSON();if(!U||typeof U!=="object"){let _=new U3.Scalar(U);if(H)H.node=_;return _}W=U instanceof Map?Y[A1.MAP]:(Symbol.iterator in Object(U))?Y[A1.SEQ]:Y[A1.MAP]}if(G)G(W),delete q.onTagObj;let $=W?.createNode?W.createNode(q.schema,U,q):typeof W?.nodeClass?.from==="function"?W.nodeClass.from(q.schema,U,q):new U3.Scalar(U);if(X)$.tag=X;else if(!W.default)$.tag=W.tag;if(H)H.node=$;return $}VH.createNode=TH});var n6=R((wH)=>{var DH=x2(),f0=k(),MH=o6();function qU(U,X,q){let Z=q;for(let Q=X.length-1;Q>=0;--Q){let G=X[Q];if(typeof G==="number"&&Number.isInteger(G)&&G>=0){let Y=[];Y[G]=Z,Z=Y}else Z=new Map([[G,Z]])}return DH.createNode(Z,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:U,sourceObjects:new Map})}var X3=(U)=>U==null||typeof U==="object"&&!!U[Symbol.iterator]().next().done;class q3 extends MH.NodeBase{constructor(U,X){super(U);Object.defineProperty(this,"schema",{value:X,configurable:!0,enumerable:!1,writable:!0})}clone(U){let X=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(U)X.schema=U;if(X.items=X.items.map((q)=>f0.isNode(q)||f0.isPair(q)?q.clone(U):q),this.range)X.range=this.range.slice();return X}addIn(U,X){if(X3(U))this.add(X);else{let[q,...Z]=U,Q=this.get(q,!0);if(f0.isCollection(Q))Q.addIn(Z,X);else if(Q===void 0&&this.schema)this.set(q,qU(this.schema,Z,X));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${Z}`)}}deleteIn(U){let[X,...q]=U;if(q.length===0)return this.delete(X);let Z=this.get(X,!0);if(f0.isCollection(Z))return Z.deleteIn(q);else throw Error(`Expected YAML collection at ${X}. Remaining path: ${q}`)}getIn(U,X){let[q,...Z]=U,Q=this.get(q,!0);if(Z.length===0)return!X&&f0.isScalar(Q)?Q.value:Q;else return f0.isCollection(Q)?Q.getIn(Z,X):void 0}hasAllNullValues(U){return this.items.every((X)=>{if(!f0.isPair(X))return!1;let q=X.value;return q==null||U&&f0.isScalar(q)&&q.value==null&&!q.commentBefore&&!q.comment&&!q.tag})}hasIn(U){let[X,...q]=U;if(q.length===0)return this.has(X);let Z=this.get(X,!0);return f0.isCollection(Z)?Z.hasIn(q):!1}setIn(U,X){let[q,...Z]=U;if(Z.length===0)this.set(q,X);else{let Q=this.get(q,!0);if(f0.isCollection(Q))Q.setIn(Z,X);else if(Q===void 0&&this.schema)this.set(q,qU(this.schema,Z,X));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${Z}`)}}}wH.Collection=q3;wH.collectionFromPath=qU;wH.isEmptyPath=X3});var u2=R((SH)=>{var NH=(U)=>U.replace(/^(?!$)(?: $)?/gm,"#");function ZU(U,X){if(/^\n+$/.test(U))return U.substring(1);return X?U.replace(/^(?! *$)/gm,X):U}var CH=(U,X,q)=>U.endsWith(`
3
3
  `)?ZU(q,X):q.includes(`
4
4
  `)?`
5
- `+ZU(q,X):(U.endsWith(" ")?"":" ")+q;PH.indentComment=ZU;PH.lineComment=wH;PH.stringifyComment=MH});var Z3=R((SH)=>{function CH(U,X,q="flow",{indentAtStart:Z,lineWidth:Q=80,minContentWidth:G=20,onFold:Y,onOverflow:J}={}){if(!Q||Q<0)return U;if(Q<G)G=0;let H=Math.max(1+G,1+Q-X.length);if(U.length<=H)return U;let W=[],$={},_=Q-X.length;if(typeof Z==="number")if(Z>Q-Math.max(2,G))W.push(0);else _=Q-Z;let L=void 0,A=void 0,V=!1,z=-1,B=-1,D=-1;if(q==="block"){if(z=q3(U,z,X.length),z!==-1)_=z+H}for(let K;K=U[z+=1];){if(q==="quoted"&&K==="\\"){switch(B=z,U[z+1]){case"x":z+=3;break;case"u":z+=5;break;case"U":z+=9;break;default:z+=1}D=z}if(K===`
6
- `){if(q==="block")z=q3(U,z,X.length);_=z+X.length+H,L=void 0}else{if(K===" "&&A&&A!==" "&&A!==`
5
+ `+ZU(q,X):(U.endsWith(" ")?"":" ")+q;SH.indentComment=ZU;SH.lineComment=CH;SH.stringifyComment=NH});var Q3=R((gH)=>{function fH(U,X,q="flow",{indentAtStart:Z,lineWidth:Q=80,minContentWidth:G=20,onFold:Y,onOverflow:J}={}){if(!Q||Q<0)return U;if(Q<G)G=0;let H=Math.max(1+G,1+Q-X.length);if(U.length<=H)return U;let W=[],$={},_=Q-X.length;if(typeof Z==="number")if(Z>Q-Math.max(2,G))W.push(0);else _=Q-Z;let L=void 0,A=void 0,V=!1,z=-1,B=-1,D=-1;if(q==="block"){if(z=Z3(U,z,X.length),z!==-1)_=z+H}for(let K;K=U[z+=1];){if(q==="quoted"&&K==="\\"){switch(B=z,U[z+1]){case"x":z+=3;break;case"u":z+=5;break;case"U":z+=9;break;default:z+=1}D=z}if(K===`
6
+ `){if(q==="block")z=Z3(U,z,X.length);_=z+X.length+H,L=void 0}else{if(K===" "&&A&&A!==" "&&A!==`
7
7
  `&&A!=="\t"){let C=U[z+1];if(C&&C!==" "&&C!==`
8
8
  `&&C!=="\t")L=z}if(z>=_)if(L)W.push(L),_=L+H,L=void 0;else if(q==="quoted"){while(A===" "||A==="\t")A=K,K=U[z+=1],V=!0;let C=z>D+1?z-2:B-1;if($[C])return U;W.push(C),$[C]=!0,_=C+H,L=void 0}else V=!0}A=K}if(V&&J)J();if(W.length===0)return U;if(Y)Y();let P=U.slice(0,W[0]);for(let K=0;K<W.length;++K){let C=W[K],N=W[K+1]||U.length;if(C===0)P=`
9
9
  ${X}${U.slice(0,N)}`;else{if(q==="quoted"&&$[C])P+=`${U[C]}\\`;P+=`
10
- ${X}${U.slice(C+1,N)}`}}return P}function q3(U,X,q){let Z=X,Q=X+1,G=U[Q];while(G===" "||G==="\t")if(X<Q+q)G=U[++X];else{do G=U[++X];while(G&&G!==`
11
- `);Z=X,Q=X+1,G=U[Q]}return Z}SH.FOLD_BLOCK="block";SH.FOLD_FLOW="flow";SH.FOLD_QUOTED="quoted";SH.foldFlowLines=CH});var p2=R((vH)=>{var I0=i(),t0=Z3(),t6=(U,X)=>({indentAtStart:X?U.indent.length:U.indentAtStart,lineWidth:U.options.lineWidth,minContentWidth:U.options.minContentWidth}),e6=(U)=>/^(%|---|\.\.\.)/m.test(U);function gH(U,X,q){if(!X||X<0)return!1;let Z=X-q,Q=U.length;if(Q<=Z)return!1;for(let G=0,Y=0;G<Q;++G)if(U[G]===`
10
+ ${X}${U.slice(C+1,N)}`}}return P}function Z3(U,X,q){let Z=X,Q=X+1,G=U[Q];while(G===" "||G==="\t")if(X<Q+q)G=U[++X];else{do G=U[++X];while(G&&G!==`
11
+ `);Z=X,Q=X+1,G=U[Q]}return Z}gH.FOLD_BLOCK="block";gH.FOLD_FLOW="flow";gH.FOLD_QUOTED="quoted";gH.foldFlowLines=fH});var p2=R((pH)=>{var I0=i(),t0=Q3(),t6=(U,X)=>({indentAtStart:X?U.indent.length:U.indentAtStart,lineWidth:U.options.lineWidth,minContentWidth:U.options.minContentWidth}),e6=(U)=>/^(%|---|\.\.\.)/m.test(U);function xH(U,X,q){if(!X||X<0)return!1;let Z=X-q,Q=U.length;if(Q<=Z)return!1;for(let G=0,Y=0;G<Q;++G)if(U[G]===`
12
12
  `){if(G-Y>Z)return!0;if(Y=G+1,Q-Y<=Z)return!1}return!0}function m2(U,X){let q=JSON.stringify(U);if(X.options.doubleQuotedAsJSON)return q;let{implicitKey:Z}=X,Q=X.options.doubleQuotedMinMultiLineLength,G=X.indent||(e6(U)?" ":""),Y="",J=0;for(let H=0,W=q[H];W;W=q[++H]){if(W===" "&&q[H+1]==="\\"&&q[H+2]==="n")Y+=q.slice(J,H)+"\\ ",H+=1,J=H,W="\\";if(W==="\\")switch(q[H+1]){case"u":{Y+=q.slice(J,H);let $=q.substr(H+2,4);switch($){case"0000":Y+="\\0";break;case"0007":Y+="\\a";break;case"000b":Y+="\\v";break;case"001b":Y+="\\e";break;case"0085":Y+="\\N";break;case"00a0":Y+="\\_";break;case"2028":Y+="\\L";break;case"2029":Y+="\\P";break;default:if($.substr(0,2)==="00")Y+="\\x"+$.substr(2);else Y+=q.substr(H,6)}H+=5,J=H+1}break;case"n":if(Z||q[H+2]==='"'||q.length<Q)H+=1;else{Y+=q.slice(J,H)+`
13
13
 
14
14
  `;while(q[H+2]==="\\"&&q[H+3]==="n"&&q[H+4]!=='"')Y+=`
@@ -17,7 +17,7 @@ ${X}${U.slice(C+1,N)}`}}return P}function q3(U,X,q){let Z=X,Q=X+1,G=U[Q];while(G
17
17
  ${q}`)+"'";return X.implicitKey?Z:t0.foldFlowLines(Z,q,t0.FOLD_FLOW,t6(X,!1))}function o1(U,X){let{singleQuote:q}=X.options,Z;if(q===!1)Z=m2;else{let Q=U.includes('"'),G=U.includes("'");if(Q&&!G)Z=QU;else if(G&&!Q)Z=m2;else Z=q?QU:m2}return Z(U,X)}var GU;try{GU=new RegExp(`(^|(?<!
18
18
  ))
19
19
  +(?!
20
- |$)`,"g")}catch{GU=/\n+(?!\n|$)/g}function a6({comment:U,type:X,value:q},Z,Q,G){let{blockQuote:Y,commentString:J,lineWidth:H}=Z.options;if(!Y||/\n[\t ]+$/.test(q))return o1(q,Z);let W=Z.indent||(Z.forceBlockIndent||e6(q)?" ":""),$=Y==="literal"?!0:Y==="folded"||X===I0.Scalar.BLOCK_FOLDED?!1:X===I0.Scalar.BLOCK_LITERAL?!0:!gH(q,H,W.length);if(!q)return $?`|
20
+ |$)`,"g")}catch{GU=/\n+(?!\n|$)/g}function a6({comment:U,type:X,value:q},Z,Q,G){let{blockQuote:Y,commentString:J,lineWidth:H}=Z.options;if(!Y||/\n[\t ]+$/.test(q))return o1(q,Z);let W=Z.indent||(Z.forceBlockIndent||e6(q)?" ":""),$=Y==="literal"?!0:Y==="folded"||X===I0.Scalar.BLOCK_FOLDED?!1:X===I0.Scalar.BLOCK_LITERAL?!0:!xH(q,H,W.length);if(!q)return $?`|
21
21
  `:`>
22
22
  `;let _,L;for(L=q.length;L>0;--L){let N=q[L-1];if(N!==`
23
23
  `&&N!=="\t"&&N!==" ")break}let A=q.substring(L),V=A.indexOf(`
@@ -26,13 +26,13 @@ ${q}`)+"'";return X.implicitKey?Z:t0.foldFlowLines(Z,q,t0.FOLD_FLOW,t6(X,!1))}fu
26
26
  `)D=B;else break}let P=q.substring(0,D<B?D+1:B);if(P)q=q.substring(P.length),P=P.replace(/\n+/g,`$&${W}`);let C=(z?W?"2":"1":"")+_;if(U){if(C+=" "+J(U.replace(/ ?[\r\n]+/g," ")),Q)Q()}if(!$){let N=q.replace(/\n+/g,`
27
27
  $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${W}`),b=!1,m=t6(Z,!0);if(Y!=="folded"&&X!==I0.Scalar.BLOCK_FOLDED)m.onOverflow=()=>{b=!0};let w=t0.foldFlowLines(`${P}${N}${A}`,W,t0.FOLD_BLOCK,m);if(!b)return`>${C}
28
28
  ${W}${w}`}return q=q.replace(/\n+/g,`$&${W}`),`|${C}
29
- ${W}${P}${q}${A}`}function yH(U,X,q,Z){let{type:Q,value:G}=U,{actualString:Y,implicitKey:J,indent:H,indentStep:W,inFlow:$}=X;if(J&&G.includes(`
29
+ ${W}${P}${q}${A}`}function uH(U,X,q,Z){let{type:Q,value:G}=U,{actualString:Y,implicitKey:J,indent:H,indentStep:W,inFlow:$}=X;if(J&&G.includes(`
30
30
  `)||$&&/[[\]{},]/.test(G))return o1(G,X);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(G))return J||$||!G.includes(`
31
31
  `)?o1(G,X):a6(U,X,q,Z);if(!J&&!$&&Q!==I0.Scalar.PLAIN&&G.includes(`
32
32
  `))return a6(U,X,q,Z);if(e6(G)){if(H==="")return X.forceBlockIndent=!0,a6(U,X,q,Z);else if(J&&H===W)return o1(G,X)}let _=G.replace(/\n+/g,`$&
33
- ${H}`);if(Y){let L=(z)=>z.default&&z.tag!=="tag:yaml.org,2002:str"&&z.test?.test(_),{compat:A,tags:V}=X.doc.schema;if(V.some(L)||A?.some(L))return o1(G,X)}return J?_:t0.foldFlowLines(_,H,t0.FOLD_FLOW,t6(X,!1))}function kH(U,X,q,Z){let{implicitKey:Q,inFlow:G}=X,Y=typeof U.value==="string"?U:Object.assign({},U,{value:String(U.value)}),{type:J}=U;if(J!==I0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(Y.value))J=I0.Scalar.QUOTE_DOUBLE}let H=($)=>{switch($){case I0.Scalar.BLOCK_FOLDED:case I0.Scalar.BLOCK_LITERAL:return Q||G?o1(Y.value,X):a6(Y,X,q,Z);case I0.Scalar.QUOTE_DOUBLE:return m2(Y.value,X);case I0.Scalar.QUOTE_SINGLE:return QU(Y.value,X);case I0.Scalar.PLAIN:return yH(Y,X,q,Z);default:return null}},W=H(J);if(W===null){let{defaultKeyType:$,defaultStringType:_}=X.options,L=Q&&$||_;if(W=H(L),W===null)throw Error(`Unsupported default string type ${L}`)}return W}vH.stringifyString=kH});var l2=R((iH)=>{var xH=s6(),e0=k(),uH=u2(),mH=p2();function pH(U,X){let q=Object.assign({blockQuote:!0,commentString:uH.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},U.schema.toStringOptions,X),Z;switch(q.collectionStyle){case"block":Z=!1;break;case"flow":Z=!0;break;default:Z=null}return{anchors:new Set,doc:U,flowCollectionPadding:q.flowCollectionPadding?" ":"",indent:"",indentStep:typeof q.indent==="number"?" ".repeat(q.indent):" ",inFlow:Z,options:q}}function lH(U,X){if(X.tag){let Q=U.filter((G)=>G.tag===X.tag);if(Q.length>0)return Q.find((G)=>G.format===X.format)??Q[0]}let q=void 0,Z;if(e0.isScalar(X)){Z=X.value;let Q=U.filter((G)=>G.identify?.(Z));if(Q.length>1){let G=Q.filter((Y)=>Y.test);if(G.length>0)Q=G}q=Q.find((G)=>G.format===X.format)??Q.find((G)=>!G.format)}else Z=X,q=U.find((Q)=>Q.nodeClass&&Z instanceof Q.nodeClass);if(!q){let Q=Z?.constructor?.name??(Z===null?"null":typeof Z);throw Error(`Tag not resolved for ${Q} value`)}return q}function dH(U,X,{anchors:q,doc:Z}){if(!Z.directives)return"";let Q=[],G=(e0.isScalar(U)||e0.isCollection(U))&&U.anchor;if(G&&xH.anchorIsValid(G))q.add(G),Q.push(`&${G}`);let Y=U.tag??(X.default?null:X.tag);if(Y)Q.push(Z.directives.tagString(Y));return Q.join(" ")}function cH(U,X,q,Z){if(e0.isPair(U))return U.toString(X,q,Z);if(e0.isAlias(U)){if(X.doc.directives)return U.toString(X);if(X.resolvedAliases?.has(U))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(X.resolvedAliases)X.resolvedAliases.add(U);else X.resolvedAliases=new Set([U]);U=U.resolve(X.doc)}}let Q=void 0,G=e0.isNode(U)?U:X.doc.createNode(U,{onTagObj:(H)=>Q=H});Q??(Q=lH(X.doc.schema.tags,G));let Y=dH(G,Q,X);if(Y.length>0)X.indentAtStart=(X.indentAtStart??0)+Y.length+1;let J=typeof Q.stringify==="function"?Q.stringify(G,X,q,Z):e0.isScalar(G)?mH.stringifyString(G,X,q,Z):G.toString(X,q,Z);if(!Y)return J;return e0.isScalar(G)||J[0]==="{"||J[0]==="["?`${Y} ${J}`:`${Y}
34
- ${X.indent}${J}`}iH.createStringifyContext=pH;iH.stringify=cH});var Y3=R((nH)=>{var m0=k(),Q3=i(),G3=l2(),d2=u2();function rH({key:U,value:X},q,Z,Q){let{allNullValues:G,doc:Y,indent:J,indentStep:H,options:{commentString:W,indentSeq:$,simpleKeys:_}}=q,L=m0.isNode(U)&&U.comment||null;if(_){if(L)throw Error("With simple keys, key nodes cannot have comments");if(m0.isCollection(U)||!m0.isNode(U)&&typeof U==="object")throw Error("With simple keys, collection cannot be used as a key value")}let A=!_&&(!U||L&&X==null&&!q.inFlow||m0.isCollection(U)||(m0.isScalar(U)?U.type===Q3.Scalar.BLOCK_FOLDED||U.type===Q3.Scalar.BLOCK_LITERAL:typeof U==="object"));q=Object.assign({},q,{allNullValues:!1,implicitKey:!A&&(_||!G),indent:J+H});let V=!1,z=!1,B=G3.stringify(U,q,()=>V=!0,()=>z=!0);if(!A&&!q.inFlow&&B.length>1024){if(_)throw Error("With simple keys, single line scalar must not span more than 1024 characters");A=!0}if(q.inFlow){if(G||X==null){if(V&&Z)Z();return B===""?"?":A?`? ${B}`:B}}else if(G&&!_||X==null&&A){if(B=`? ${B}`,L&&!V)B+=d2.lineComment(B,q.indent,W(L));else if(z&&Q)Q();return B}if(V)L=null;if(A){if(L)B+=d2.lineComment(B,q.indent,W(L));B=`? ${B}
35
- ${J}:`}else if(B=`${B}:`,L)B+=d2.lineComment(B,q.indent,W(L));let D,P,K;if(m0.isNode(X))D=!!X.spaceBefore,P=X.commentBefore,K=X.comment;else if(D=!1,P=null,K=null,X&&typeof X==="object")X=Y.createNode(X);if(q.implicitKey=!1,!A&&!L&&m0.isScalar(X))q.indentAtStart=B.length+1;if(z=!1,!$&&H.length>=2&&!q.inFlow&&!A&&m0.isSeq(X)&&!X.flow&&!X.tag&&!X.anchor)q.indent=q.indent.substring(2);let C=!1,N=G3.stringify(X,q,()=>C=!0,()=>z=!0),b=" ";if(L||D||P){if(b=D?`
33
+ ${H}`);if(Y){let L=(z)=>z.default&&z.tag!=="tag:yaml.org,2002:str"&&z.test?.test(_),{compat:A,tags:V}=X.doc.schema;if(V.some(L)||A?.some(L))return o1(G,X)}return J?_:t0.foldFlowLines(_,H,t0.FOLD_FLOW,t6(X,!1))}function mH(U,X,q,Z){let{implicitKey:Q,inFlow:G}=X,Y=typeof U.value==="string"?U:Object.assign({},U,{value:String(U.value)}),{type:J}=U;if(J!==I0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(Y.value))J=I0.Scalar.QUOTE_DOUBLE}let H=($)=>{switch($){case I0.Scalar.BLOCK_FOLDED:case I0.Scalar.BLOCK_LITERAL:return Q||G?o1(Y.value,X):a6(Y,X,q,Z);case I0.Scalar.QUOTE_DOUBLE:return m2(Y.value,X);case I0.Scalar.QUOTE_SINGLE:return QU(Y.value,X);case I0.Scalar.PLAIN:return uH(Y,X,q,Z);default:return null}},W=H(J);if(W===null){let{defaultKeyType:$,defaultStringType:_}=X.options,L=Q&&$||_;if(W=H(L),W===null)throw Error(`Unsupported default string type ${L}`)}return W}pH.stringifyString=mH});var l2=R((aH)=>{var dH=s6(),e0=k(),cH=u2(),iH=p2();function sH(U,X){let q=Object.assign({blockQuote:!0,commentString:cH.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},U.schema.toStringOptions,X),Z;switch(q.collectionStyle){case"block":Z=!1;break;case"flow":Z=!0;break;default:Z=null}return{anchors:new Set,doc:U,flowCollectionPadding:q.flowCollectionPadding?" ":"",indent:"",indentStep:typeof q.indent==="number"?" ".repeat(q.indent):" ",inFlow:Z,options:q}}function oH(U,X){if(X.tag){let Q=U.filter((G)=>G.tag===X.tag);if(Q.length>0)return Q.find((G)=>G.format===X.format)??Q[0]}let q=void 0,Z;if(e0.isScalar(X)){Z=X.value;let Q=U.filter((G)=>G.identify?.(Z));if(Q.length>1){let G=Q.filter((Y)=>Y.test);if(G.length>0)Q=G}q=Q.find((G)=>G.format===X.format)??Q.find((G)=>!G.format)}else Z=X,q=U.find((Q)=>Q.nodeClass&&Z instanceof Q.nodeClass);if(!q){let Q=Z?.constructor?.name??(Z===null?"null":typeof Z);throw Error(`Tag not resolved for ${Q} value`)}return q}function rH(U,X,{anchors:q,doc:Z}){if(!Z.directives)return"";let Q=[],G=(e0.isScalar(U)||e0.isCollection(U))&&U.anchor;if(G&&dH.anchorIsValid(G))q.add(G),Q.push(`&${G}`);let Y=U.tag??(X.default?null:X.tag);if(Y)Q.push(Z.directives.tagString(Y));return Q.join(" ")}function nH(U,X,q,Z){if(e0.isPair(U))return U.toString(X,q,Z);if(e0.isAlias(U)){if(X.doc.directives)return U.toString(X);if(X.resolvedAliases?.has(U))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(X.resolvedAliases)X.resolvedAliases.add(U);else X.resolvedAliases=new Set([U]);U=U.resolve(X.doc)}}let Q=void 0,G=e0.isNode(U)?U:X.doc.createNode(U,{onTagObj:(H)=>Q=H});Q??(Q=oH(X.doc.schema.tags,G));let Y=rH(G,Q,X);if(Y.length>0)X.indentAtStart=(X.indentAtStart??0)+Y.length+1;let J=typeof Q.stringify==="function"?Q.stringify(G,X,q,Z):e0.isScalar(G)?iH.stringifyString(G,X,q,Z):G.toString(X,q,Z);if(!Y)return J;return e0.isScalar(G)||J[0]==="{"||J[0]==="["?`${Y} ${J}`:`${Y}
34
+ ${X.indent}${J}`}aH.createStringifyContext=sH;aH.stringify=nH});var J3=R((XW)=>{var m0=k(),G3=i(),Y3=l2(),d2=u2();function UW({key:U,value:X},q,Z,Q){let{allNullValues:G,doc:Y,indent:J,indentStep:H,options:{commentString:W,indentSeq:$,simpleKeys:_}}=q,L=m0.isNode(U)&&U.comment||null;if(_){if(L)throw Error("With simple keys, key nodes cannot have comments");if(m0.isCollection(U)||!m0.isNode(U)&&typeof U==="object")throw Error("With simple keys, collection cannot be used as a key value")}let A=!_&&(!U||L&&X==null&&!q.inFlow||m0.isCollection(U)||(m0.isScalar(U)?U.type===G3.Scalar.BLOCK_FOLDED||U.type===G3.Scalar.BLOCK_LITERAL:typeof U==="object"));q=Object.assign({},q,{allNullValues:!1,implicitKey:!A&&(_||!G),indent:J+H});let V=!1,z=!1,B=Y3.stringify(U,q,()=>V=!0,()=>z=!0);if(!A&&!q.inFlow&&B.length>1024){if(_)throw Error("With simple keys, single line scalar must not span more than 1024 characters");A=!0}if(q.inFlow){if(G||X==null){if(V&&Z)Z();return B===""?"?":A?`? ${B}`:B}}else if(G&&!_||X==null&&A){if(B=`? ${B}`,L&&!V)B+=d2.lineComment(B,q.indent,W(L));else if(z&&Q)Q();return B}if(V)L=null;if(A){if(L)B+=d2.lineComment(B,q.indent,W(L));B=`? ${B}
35
+ ${J}:`}else if(B=`${B}:`,L)B+=d2.lineComment(B,q.indent,W(L));let D,P,K;if(m0.isNode(X))D=!!X.spaceBefore,P=X.commentBefore,K=X.comment;else if(D=!1,P=null,K=null,X&&typeof X==="object")X=Y.createNode(X);if(q.implicitKey=!1,!A&&!L&&m0.isScalar(X))q.indentAtStart=B.length+1;if(z=!1,!$&&H.length>=2&&!q.inFlow&&!A&&m0.isSeq(X)&&!X.flow&&!X.tag&&!X.anchor)q.indent=q.indent.substring(2);let C=!1,N=Y3.stringify(X,q,()=>C=!0,()=>z=!0),b=" ";if(L||D||P){if(b=D?`
36
36
  `:"",P){let m=W(P);b+=`
37
37
  ${d2.indentComment(m,q.indent)}`}if(N===""&&!q.inFlow){if(b===`
38
38
  `&&K)b=`
@@ -41,32 +41,32 @@ ${d2.indentComment(m,q.indent)}`}if(N===""&&!q.inFlow){if(b===`
41
41
  ${q.indent}`}else if(!A&&m0.isCollection(X)){let m=N[0],w=N.indexOf(`
42
42
  `),s=w!==-1,p0=q.inFlow??X.flow??X.items.length===0;if(s||!p0){let M1=!1;if(s&&(m==="&"||m==="!")){let o=N.indexOf(" ");if(m==="&"&&o!==-1&&o<w&&N[o+1]==="!")o=N.indexOf(" ",o+1);if(o===-1||w<o)M1=!0}if(!M1)b=`
43
43
  ${q.indent}`}}else if(N===""||N[0]===`
44
- `)b="";if(B+=b+N,q.inFlow){if(C&&Z)Z()}else if(K&&!C)B+=d2.lineComment(B,q.indent,W(K));else if(z&&Q)Q();return B}nH.stringifyPair=rH});var YU=R((UW)=>{var J3=w1("process");function tH(U,...X){if(U==="debug")console.log(...X)}function eH(U,X){if(U==="debug"||U==="warn")if(typeof J3.emitWarning==="function")J3.emitWarning(X);else console.warn(X)}UW.debug=tH;UW.warn=eH});var q4=R((QW)=>{var c2=k(),H3=i(),U4="<<",X4={identify:(U)=>U===U4||typeof U==="symbol"&&U.description===U4,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new H3.Scalar(Symbol(U4)),{addToJSMap:W3}),stringify:()=>U4},ZW=(U,X)=>(X4.identify(X)||c2.isScalar(X)&&(!X.type||X.type===H3.Scalar.PLAIN)&&X4.identify(X.value))&&U?.doc.schema.tags.some((q)=>q.tag===X4.tag&&q.default);function W3(U,X,q){if(q=U&&c2.isAlias(q)?q.resolve(U.doc):q,c2.isSeq(q))for(let Z of q.items)JU(U,X,Z);else if(Array.isArray(q))for(let Z of q)JU(U,X,Z);else JU(U,X,q)}function JU(U,X,q){let Z=U&&c2.isAlias(q)?q.resolve(U.doc):q;if(!c2.isMap(Z))throw Error("Merge sources must be maps or map aliases");let Q=Z.toJSON(null,U,Map);for(let[G,Y]of Q)if(X instanceof Map){if(!X.has(G))X.set(G,Y)}else if(X instanceof Set)X.add(G);else if(!Object.prototype.hasOwnProperty.call(X,G))Object.defineProperty(X,G,{value:Y,writable:!0,enumerable:!0,configurable:!0});return X}QW.addMergeToJSMap=W3;QW.isMergeKey=ZW;QW.merge=X4});var WU=R((LW)=>{var HW=YU(),_3=q4(),WW=l2(),$3=k(),HU=a0();function _W(U,X,{key:q,value:Z}){if($3.isNode(q)&&q.addToJSMap)q.addToJSMap(U,X,Z);else if(_3.isMergeKey(U,q))_3.addMergeToJSMap(U,X,Z);else{let Q=HU.toJS(q,"",U);if(X instanceof Map)X.set(Q,HU.toJS(Z,Q,U));else if(X instanceof Set)X.add(Q);else{let G=$W(q,Q,U),Y=HU.toJS(Z,G,U);if(G in X)Object.defineProperty(X,G,{value:Y,writable:!0,enumerable:!0,configurable:!0});else X[G]=Y}}return X}function $W(U,X,q){if(X===null)return"";if(typeof X!=="object")return String(X);if($3.isNode(U)&&q?.doc){let Z=WW.createStringifyContext(q.doc,{});Z.anchors=new Set;for(let G of q.anchors.keys())Z.anchors.add(G.anchor);Z.inFlow=!0,Z.inStringifyKey=!0;let Q=U.toString(Z);if(!q.mapKeyWarned){let G=JSON.stringify(Q);if(G.length>40)G=G.substring(0,36)+'..."';HW.warn(q.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${G}. Set mapAsMap: true to use object keys.`),q.mapKeyWarned=!0}return Q}return JSON.stringify(X)}LW.addPairToJSMap=_W});var U1=R((BW)=>{var L3=x2(),FW=Y3(),AW=WU(),Z4=k();function OW(U,X,q){let Z=L3.createNode(U,void 0,q),Q=L3.createNode(X,void 0,q);return new Q4(Z,Q)}class Q4{constructor(U,X=null){Object.defineProperty(this,Z4.NODE_TYPE,{value:Z4.PAIR}),this.key=U,this.value=X}clone(U){let{key:X,value:q}=this;if(Z4.isNode(X))X=X.clone(U);if(Z4.isNode(q))q=q.clone(U);return new Q4(X,q)}toJSON(U,X){let q=X?.mapAsMap?new Map:{};return AW.addPairToJSMap(X,q,this)}toString(U,X,q){return U?.doc?FW.stringifyPair(this,U,X,q):JSON.stringify(this)}}BW.Pair=Q4;BW.createPair=OW});var _U=R((wW)=>{var O1=k(),z3=l2(),G4=u2();function RW(U,X,q){return(X.inFlow??U.flow?MW:DW)(U,X,q)}function DW({comment:U,items:X},q,{blockItemPrefix:Z,flowChars:Q,itemIndent:G,onChompKeep:Y,onComment:J}){let{indent:H,options:{commentString:W}}=q,$=Object.assign({},q,{indent:G,type:null}),_=!1,L=[];for(let V=0;V<X.length;++V){let z=X[V],B=null;if(O1.isNode(z)){if(!_&&z.spaceBefore)L.push("");if(Y4(q,L,z.commentBefore,_),z.comment)B=z.comment}else if(O1.isPair(z)){let P=O1.isNode(z.key)?z.key:null;if(P){if(!_&&P.spaceBefore)L.push("");Y4(q,L,P.commentBefore,_)}}_=!1;let D=z3.stringify(z,$,()=>B=null,()=>_=!0);if(B)D+=G4.lineComment(D,G,W(B));if(_&&B)_=!1;L.push(Z+D)}let A;if(L.length===0)A=Q.start+Q.end;else{A=L[0];for(let V=1;V<L.length;++V){let z=L[V];A+=z?`
44
+ `)b="";if(B+=b+N,q.inFlow){if(C&&Z)Z()}else if(K&&!C)B+=d2.lineComment(B,q.indent,W(K));else if(z&&Q)Q();return B}XW.stringifyPair=UW});var YU=R((GW)=>{var H3=w1("process");function ZW(U,...X){if(U==="debug")console.log(...X)}function QW(U,X){if(U==="debug"||U==="warn")if(typeof H3.emitWarning==="function")H3.emitWarning(X);else console.warn(X)}GW.debug=ZW;GW.warn=QW});var q4=R((WW)=>{var c2=k(),W3=i(),U4="<<",X4={identify:(U)=>U===U4||typeof U==="symbol"&&U.description===U4,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new W3.Scalar(Symbol(U4)),{addToJSMap:_3}),stringify:()=>U4},HW=(U,X)=>(X4.identify(X)||c2.isScalar(X)&&(!X.type||X.type===W3.Scalar.PLAIN)&&X4.identify(X.value))&&U?.doc.schema.tags.some((q)=>q.tag===X4.tag&&q.default);function _3(U,X,q){if(q=U&&c2.isAlias(q)?q.resolve(U.doc):q,c2.isSeq(q))for(let Z of q.items)JU(U,X,Z);else if(Array.isArray(q))for(let Z of q)JU(U,X,Z);else JU(U,X,q)}function JU(U,X,q){let Z=U&&c2.isAlias(q)?q.resolve(U.doc):q;if(!c2.isMap(Z))throw Error("Merge sources must be maps or map aliases");let Q=Z.toJSON(null,U,Map);for(let[G,Y]of Q)if(X instanceof Map){if(!X.has(G))X.set(G,Y)}else if(X instanceof Set)X.add(G);else if(!Object.prototype.hasOwnProperty.call(X,G))Object.defineProperty(X,G,{value:Y,writable:!0,enumerable:!0,configurable:!0});return X}WW.addMergeToJSMap=_3;WW.isMergeKey=HW;WW.merge=X4});var WU=R((BW)=>{var zW=YU(),$3=q4(),FW=l2(),L3=k(),HU=a0();function AW(U,X,{key:q,value:Z}){if(L3.isNode(q)&&q.addToJSMap)q.addToJSMap(U,X,Z);else if($3.isMergeKey(U,q))$3.addMergeToJSMap(U,X,Z);else{let Q=HU.toJS(q,"",U);if(X instanceof Map)X.set(Q,HU.toJS(Z,Q,U));else if(X instanceof Set)X.add(Q);else{let G=OW(q,Q,U),Y=HU.toJS(Z,G,U);if(G in X)Object.defineProperty(X,G,{value:Y,writable:!0,enumerable:!0,configurable:!0});else X[G]=Y}}return X}function OW(U,X,q){if(X===null)return"";if(typeof X!=="object")return String(X);if(L3.isNode(U)&&q?.doc){let Z=FW.createStringifyContext(q.doc,{});Z.anchors=new Set;for(let G of q.anchors.keys())Z.anchors.add(G.anchor);Z.inFlow=!0,Z.inStringifyKey=!0;let Q=U.toString(Z);if(!q.mapKeyWarned){let G=JSON.stringify(Q);if(G.length>40)G=G.substring(0,36)+'..."';zW.warn(q.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${G}. Set mapAsMap: true to use object keys.`),q.mapKeyWarned=!0}return Q}return JSON.stringify(X)}BW.addPairToJSMap=AW});var U1=R((MW)=>{var z3=x2(),VW=J3(),RW=WU(),Z4=k();function DW(U,X,q){let Z=z3.createNode(U,void 0,q),Q=z3.createNode(X,void 0,q);return new Q4(Z,Q)}class Q4{constructor(U,X=null){Object.defineProperty(this,Z4.NODE_TYPE,{value:Z4.PAIR}),this.key=U,this.value=X}clone(U){let{key:X,value:q}=this;if(Z4.isNode(X))X=X.clone(U);if(Z4.isNode(q))q=q.clone(U);return new Q4(X,q)}toJSON(U,X){let q=X?.mapAsMap?new Map:{};return RW.addPairToJSMap(X,q,this)}toString(U,X,q){return U?.doc?VW.stringifyPair(this,U,X,q):JSON.stringify(this)}}MW.Pair=Q4;MW.createPair=DW});var _U=R((CW)=>{var O1=k(),F3=l2(),G4=u2();function IW(U,X,q){return(X.inFlow??U.flow?NW:KW)(U,X,q)}function KW({comment:U,items:X},q,{blockItemPrefix:Z,flowChars:Q,itemIndent:G,onChompKeep:Y,onComment:J}){let{indent:H,options:{commentString:W}}=q,$=Object.assign({},q,{indent:G,type:null}),_=!1,L=[];for(let V=0;V<X.length;++V){let z=X[V],B=null;if(O1.isNode(z)){if(!_&&z.spaceBefore)L.push("");if(Y4(q,L,z.commentBefore,_),z.comment)B=z.comment}else if(O1.isPair(z)){let P=O1.isNode(z.key)?z.key:null;if(P){if(!_&&P.spaceBefore)L.push("");Y4(q,L,P.commentBefore,_)}}_=!1;let D=F3.stringify(z,$,()=>B=null,()=>_=!0);if(B)D+=G4.lineComment(D,G,W(B));if(_&&B)_=!1;L.push(Z+D)}let A;if(L.length===0)A=Q.start+Q.end;else{A=L[0];for(let V=1;V<L.length;++V){let z=L[V];A+=z?`
45
45
  ${H}${z}`:`
46
46
  `}}if(U){if(A+=`
47
- `+G4.indentComment(W(U),H),J)J()}else if(_&&Y)Y();return A}function MW({items:U},X,{flowChars:q,itemIndent:Z}){let{indent:Q,indentStep:G,flowCollectionPadding:Y,options:{commentString:J}}=X;Z+=G;let H=Object.assign({},X,{indent:Z,inFlow:!0,type:null}),W=!1,$=0,_=[];for(let V=0;V<U.length;++V){let z=U[V],B=null;if(O1.isNode(z)){if(z.spaceBefore)_.push("");if(Y4(X,_,z.commentBefore,!1),z.comment)B=z.comment}else if(O1.isPair(z)){let P=O1.isNode(z.key)?z.key:null;if(P){if(P.spaceBefore)_.push("");if(Y4(X,_,P.commentBefore,!1),P.comment)W=!0}let K=O1.isNode(z.value)?z.value:null;if(K){if(K.comment)B=K.comment;if(K.commentBefore)W=!0}else if(z.value==null&&P?.comment)B=P.comment}if(B)W=!0;let D=z3.stringify(z,H,()=>B=null);if(V<U.length-1)D+=",";if(B)D+=G4.lineComment(D,Z,J(B));if(!W&&(_.length>$||D.includes(`
47
+ `+G4.indentComment(W(U),H),J)J()}else if(_&&Y)Y();return A}function NW({items:U},X,{flowChars:q,itemIndent:Z}){let{indent:Q,indentStep:G,flowCollectionPadding:Y,options:{commentString:J}}=X;Z+=G;let H=Object.assign({},X,{indent:Z,inFlow:!0,type:null}),W=!1,$=0,_=[];for(let V=0;V<U.length;++V){let z=U[V],B=null;if(O1.isNode(z)){if(z.spaceBefore)_.push("");if(Y4(X,_,z.commentBefore,!1),z.comment)B=z.comment}else if(O1.isPair(z)){let P=O1.isNode(z.key)?z.key:null;if(P){if(P.spaceBefore)_.push("");if(Y4(X,_,P.commentBefore,!1),P.comment)W=!0}let K=O1.isNode(z.value)?z.value:null;if(K){if(K.comment)B=K.comment;if(K.commentBefore)W=!0}else if(z.value==null&&P?.comment)B=P.comment}if(B)W=!0;let D=F3.stringify(z,H,()=>B=null);if(V<U.length-1)D+=",";if(B)D+=G4.lineComment(D,Z,J(B));if(!W&&(_.length>$||D.includes(`
48
48
  `)))W=!0;_.push(D),$=_.length}let{start:L,end:A}=q;if(_.length===0)return L+A;else{if(!W){let V=_.reduce((z,B)=>z+B.length+2,2);W=X.options.lineWidth>0&&V>X.options.lineWidth}if(W){let V=L;for(let z of _)V+=z?`
49
49
  ${G}${Q}${z}`:`
50
50
  `;return`${V}
51
- ${Q}${A}`}else return`${L}${Y}${_.join(" ")}${Y}${A}`}}function Y4({indent:U,options:{commentString:X}},q,Z,Q){if(Z&&Q)Z=Z.replace(/^\n+/,"");if(Z){let G=G4.indentComment(X(Z),U);q.push(G.trimStart())}}wW.stringifyCollection=RW});var q1=R((SW)=>{var IW=_U(),KW=WU(),NW=n6(),X1=k(),J4=U1(),CW=i();function i2(U,X){let q=X1.isScalar(X)?X.value:X;for(let Z of U)if(X1.isPair(Z)){if(Z.key===X||Z.key===q)return Z;if(X1.isScalar(Z.key)&&Z.key.value===q)return Z}return}class F3 extends NW.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(U){super(X1.MAP,U);this.items=[]}static from(U,X,q){let{keepUndefined:Z,replacer:Q}=q,G=new this(U),Y=(J,H)=>{if(typeof Q==="function")H=Q.call(X,J,H);else if(Array.isArray(Q)&&!Q.includes(J))return;if(H!==void 0||Z)G.items.push(J4.createPair(J,H,q))};if(X instanceof Map)for(let[J,H]of X)Y(J,H);else if(X&&typeof X==="object")for(let J of Object.keys(X))Y(J,X[J]);if(typeof U.sortMapEntries==="function")G.items.sort(U.sortMapEntries);return G}add(U,X){let q;if(X1.isPair(U))q=U;else if(!U||typeof U!=="object"||!("key"in U))q=new J4.Pair(U,U?.value);else q=new J4.Pair(U.key,U.value);let Z=i2(this.items,q.key),Q=this.schema?.sortMapEntries;if(Z){if(!X)throw Error(`Key ${q.key} already set`);if(X1.isScalar(Z.value)&&CW.isScalarValue(q.value))Z.value.value=q.value;else Z.value=q.value}else if(Q){let G=this.items.findIndex((Y)=>Q(q,Y)<0);if(G===-1)this.items.push(q);else this.items.splice(G,0,q)}else this.items.push(q)}delete(U){let X=i2(this.items,U);if(!X)return!1;return this.items.splice(this.items.indexOf(X),1).length>0}get(U,X){let Z=i2(this.items,U)?.value;return(!X&&X1.isScalar(Z)?Z.value:Z)??void 0}has(U){return!!i2(this.items,U)}set(U,X){this.add(new J4.Pair(U,X),!0)}toJSON(U,X,q){let Z=q?new q:X?.mapAsMap?new Map:{};if(X?.onCreate)X.onCreate(Z);for(let Q of this.items)KW.addPairToJSMap(X,Z,Q);return Z}toString(U,X,q){if(!U)return JSON.stringify(this);for(let Z of this.items)if(!X1.isPair(Z))throw Error(`Map items must all be pairs; found ${JSON.stringify(Z)} instead`);if(!U.allNullValues&&this.hasAllNullValues(!1))U=Object.assign({},U,{allNullValues:!0});return IW.stringifyCollection(this,U,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:U.indent||"",onChompKeep:q,onComment:X})}}SW.YAMLMap=F3;SW.findPair=i2});var r1=R((gW)=>{var bW=k(),A3=q1(),fW={collection:"map",default:!0,nodeClass:A3.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(U,X){if(!bW.isMap(U))X("Expected a mapping for this tag");return U},createNode:(U,X,q)=>A3.YAMLMap.from(U,X,q)};gW.map=fW});var Z1=R((mW)=>{var kW=x2(),vW=_U(),hW=n6(),W4=k(),xW=i(),uW=a0();class O3 extends hW.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(U){super(W4.SEQ,U);this.items=[]}add(U){this.items.push(U)}delete(U){let X=H4(U);if(typeof X!=="number")return!1;return this.items.splice(X,1).length>0}get(U,X){let q=H4(U);if(typeof q!=="number")return;let Z=this.items[q];return!X&&W4.isScalar(Z)?Z.value:Z}has(U){let X=H4(U);return typeof X==="number"&&X<this.items.length}set(U,X){let q=H4(U);if(typeof q!=="number")throw Error(`Expected a valid index, not ${U}.`);let Z=this.items[q];if(W4.isScalar(Z)&&xW.isScalarValue(X))Z.value=X;else this.items[q]=X}toJSON(U,X){let q=[];if(X?.onCreate)X.onCreate(q);let Z=0;for(let Q of this.items)q.push(uW.toJS(Q,String(Z++),X));return q}toString(U,X,q){if(!U)return JSON.stringify(this);return vW.stringifyCollection(this,U,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(U.indent||"")+" ",onChompKeep:q,onComment:X})}static from(U,X,q){let{replacer:Z}=q,Q=new this(U);if(X&&Symbol.iterator in Object(X)){let G=0;for(let Y of X){if(typeof Z==="function"){let J=X instanceof Set?Y:String(G++);Y=Z.call(X,J,Y)}Q.items.push(kW.createNode(Y,void 0,q))}}return Q}}function H4(U){let X=W4.isScalar(U)?U.value:U;if(X&&typeof X==="string")X=Number(X);return typeof X==="number"&&Number.isInteger(X)&&X>=0?X:null}mW.YAMLSeq=O3});var n1=R((cW)=>{var lW=k(),B3=Z1(),dW={collection:"seq",default:!0,nodeClass:B3.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(U,X){if(!lW.isSeq(U))X("Expected a sequence for this tag");return U},createNode:(U,X,q)=>B3.YAMLSeq.from(U,X,q)};cW.seq=dW});var s2=R((rW)=>{var sW=p2(),oW={identify:(U)=>typeof U==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(U)=>U,stringify(U,X,q,Z){return X=Object.assign({actualString:!0},X),sW.stringifyString(U,X,q,Z)}};rW.string=oW});var _4=R((aW)=>{var T3=i(),V3={identify:(U)=>U==null,createNode:()=>new T3.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new T3.Scalar(null),stringify:({source:U},X)=>typeof U==="string"&&V3.test.test(U)?U:X.options.nullStr};aW.nullTag=V3});var $U=R((U_)=>{var eW=i(),R3={identify:(U)=>typeof U==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(U)=>new eW.Scalar(U[0]==="t"||U[0]==="T"),stringify({source:U,value:X},q){if(U&&R3.test.test(U)){let Z=U[0]==="t"||U[0]==="T";if(X===Z)return U}return X?q.options.trueStr:q.options.falseStr}};U_.boolTag=R3});var a1=R((Z_)=>{function q_({format:U,minFractionDigits:X,tag:q,value:Z}){if(typeof Z==="bigint")return String(Z);let Q=typeof Z==="number"?Z:Number(Z);if(!isFinite(Q))return isNaN(Q)?".nan":Q<0?"-.inf":".inf";let G=Object.is(Z,-0)?"-0":JSON.stringify(Z);if(!U&&X&&(!q||q==="tag:yaml.org,2002:float")&&/^\d/.test(G)){let Y=G.indexOf(".");if(Y<0)Y=G.length,G+=".";let J=X-(G.length-Y-1);while(J-- >0)G+="0"}return G}Z_.stringifyNumber=q_});var zU=R((W_)=>{var G_=i(),LU=a1(),Y_={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(U)=>U.slice(-3).toLowerCase()==="nan"?NaN:U[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:LU.stringifyNumber},J_={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(U)=>parseFloat(U),stringify(U){let X=Number(U.value);return isFinite(X)?X.toExponential():LU.stringifyNumber(U)}},H_={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(U){let X=new G_.Scalar(parseFloat(U)),q=U.indexOf(".");if(q!==-1&&U[U.length-1]==="0")X.minFractionDigits=U.length-q-1;return X},stringify:LU.stringifyNumber};W_.float=H_;W_.floatExp=J_;W_.floatNaN=Y_});var AU=R((O_)=>{var D3=a1(),$4=(U)=>typeof U==="bigint"||Number.isInteger(U),FU=(U,X,q,{intAsBigInt:Z})=>Z?BigInt(U):parseInt(U.substring(X),q);function M3(U,X,q){let{value:Z}=U;if($4(Z)&&Z>=0)return q+Z.toString(X);return D3.stringifyNumber(U)}var z_={identify:(U)=>$4(U)&&U>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(U,X,q)=>FU(U,2,8,q),stringify:(U)=>M3(U,8,"0o")},F_={identify:$4,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(U,X,q)=>FU(U,0,10,q),stringify:D3.stringifyNumber},A_={identify:(U)=>$4(U)&&U>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(U,X,q)=>FU(U,2,16,q),stringify:(U)=>M3(U,16,"0x")};O_.int=F_;O_.intHex=A_;O_.intOct=z_});var w3=R((K_)=>{var R_=r1(),D_=_4(),M_=n1(),w_=s2(),P_=$U(),OU=zU(),BU=AU(),I_=[R_.map,M_.seq,w_.string,D_.nullTag,P_.boolTag,BU.intOct,BU.int,BU.intHex,OU.floatNaN,OU.floatExp,OU.float];K_.schema=I_});var I3=R((g_)=>{var C_=i(),S_=r1(),E_=n1();function P3(U){return typeof U==="bigint"||Number.isInteger(U)}var L4=({value:U})=>JSON.stringify(U),j_=[{identify:(U)=>typeof U==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(U)=>U,stringify:L4},{identify:(U)=>U==null,createNode:()=>new C_.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:L4},{identify:(U)=>typeof U==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(U)=>U==="true",stringify:L4},{identify:P3,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(U,X,{intAsBigInt:q})=>q?BigInt(U):parseInt(U,10),stringify:({value:U})=>P3(U)?U.toString():JSON.stringify(U)},{identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(U)=>parseFloat(U),stringify:L4}],b_={default:!0,tag:"",test:/^/,resolve(U,X){return X(`Unresolved plain scalar ${JSON.stringify(U)}`),U}},f_=[S_.map,E_.seq].concat(j_,b_);g_.schema=f_});var VU=R((h_)=>{var o2=w1("buffer"),TU=i(),k_=p2(),v_={identify:(U)=>U instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(U,X){if(typeof o2.Buffer==="function")return o2.Buffer.from(U,"base64");else if(typeof atob==="function"){let q=atob(U.replace(/[\n\r]/g,"")),Z=new Uint8Array(q.length);for(let Q=0;Q<q.length;++Q)Z[Q]=q.charCodeAt(Q);return Z}else return X("This environment does not support reading binary tags; either Buffer or atob is required"),U},stringify({comment:U,type:X,value:q},Z,Q,G){if(!q)return"";let Y=q,J;if(typeof o2.Buffer==="function")J=Y instanceof o2.Buffer?Y.toString("base64"):o2.Buffer.from(Y.buffer).toString("base64");else if(typeof btoa==="function"){let H="";for(let W=0;W<Y.length;++W)H+=String.fromCharCode(Y[W]);J=btoa(H)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(X??(X=TU.Scalar.BLOCK_LITERAL),X!==TU.Scalar.QUOTE_DOUBLE){let H=Math.max(Z.options.lineWidth-Z.indent.length,Z.options.minContentWidth),W=Math.ceil(J.length/H),$=Array(W);for(let _=0,L=0;_<W;++_,L+=H)$[_]=J.substr(L,H);J=$.join(X===TU.Scalar.BLOCK_LITERAL?`
52
- `:" ")}return k_.stringifyString({comment:U,type:X,value:J},Z,Q,G)}};h_.binary=v_});var F4=R((l_)=>{var z4=k(),RU=U1(),u_=i(),m_=Z1();function K3(U,X){if(z4.isSeq(U))for(let q=0;q<U.items.length;++q){let Z=U.items[q];if(z4.isPair(Z))continue;else if(z4.isMap(Z)){if(Z.items.length>1)X("Each pair must have its own sequence indicator");let Q=Z.items[0]||new RU.Pair(new u_.Scalar(null));if(Z.commentBefore)Q.key.commentBefore=Q.key.commentBefore?`${Z.commentBefore}
51
+ ${Q}${A}`}else return`${L}${Y}${_.join(" ")}${Y}${A}`}}function Y4({indent:U,options:{commentString:X}},q,Z,Q){if(Z&&Q)Z=Z.replace(/^\n+/,"");if(Z){let G=G4.indentComment(X(Z),U);q.push(G.trimStart())}}CW.stringifyCollection=IW});var q1=R((gW)=>{var EW=_U(),jW=WU(),bW=n6(),X1=k(),J4=U1(),fW=i();function i2(U,X){let q=X1.isScalar(X)?X.value:X;for(let Z of U)if(X1.isPair(Z)){if(Z.key===X||Z.key===q)return Z;if(X1.isScalar(Z.key)&&Z.key.value===q)return Z}return}class A3 extends bW.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(U){super(X1.MAP,U);this.items=[]}static from(U,X,q){let{keepUndefined:Z,replacer:Q}=q,G=new this(U),Y=(J,H)=>{if(typeof Q==="function")H=Q.call(X,J,H);else if(Array.isArray(Q)&&!Q.includes(J))return;if(H!==void 0||Z)G.items.push(J4.createPair(J,H,q))};if(X instanceof Map)for(let[J,H]of X)Y(J,H);else if(X&&typeof X==="object")for(let J of Object.keys(X))Y(J,X[J]);if(typeof U.sortMapEntries==="function")G.items.sort(U.sortMapEntries);return G}add(U,X){let q;if(X1.isPair(U))q=U;else if(!U||typeof U!=="object"||!("key"in U))q=new J4.Pair(U,U?.value);else q=new J4.Pair(U.key,U.value);let Z=i2(this.items,q.key),Q=this.schema?.sortMapEntries;if(Z){if(!X)throw Error(`Key ${q.key} already set`);if(X1.isScalar(Z.value)&&fW.isScalarValue(q.value))Z.value.value=q.value;else Z.value=q.value}else if(Q){let G=this.items.findIndex((Y)=>Q(q,Y)<0);if(G===-1)this.items.push(q);else this.items.splice(G,0,q)}else this.items.push(q)}delete(U){let X=i2(this.items,U);if(!X)return!1;return this.items.splice(this.items.indexOf(X),1).length>0}get(U,X){let Z=i2(this.items,U)?.value;return(!X&&X1.isScalar(Z)?Z.value:Z)??void 0}has(U){return!!i2(this.items,U)}set(U,X){this.add(new J4.Pair(U,X),!0)}toJSON(U,X,q){let Z=q?new q:X?.mapAsMap?new Map:{};if(X?.onCreate)X.onCreate(Z);for(let Q of this.items)jW.addPairToJSMap(X,Z,Q);return Z}toString(U,X,q){if(!U)return JSON.stringify(this);for(let Z of this.items)if(!X1.isPair(Z))throw Error(`Map items must all be pairs; found ${JSON.stringify(Z)} instead`);if(!U.allNullValues&&this.hasAllNullValues(!1))U=Object.assign({},U,{allNullValues:!0});return EW.stringifyCollection(this,U,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:U.indent||"",onChompKeep:q,onComment:X})}}gW.YAMLMap=A3;gW.findPair=i2});var r1=R((xW)=>{var vW=k(),O3=q1(),hW={collection:"map",default:!0,nodeClass:O3.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(U,X){if(!vW.isMap(U))X("Expected a mapping for this tag");return U},createNode:(U,X,q)=>O3.YAMLMap.from(U,X,q)};xW.map=hW});var Z1=R((iW)=>{var mW=x2(),pW=_U(),lW=n6(),W4=k(),dW=i(),cW=a0();class B3 extends lW.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(U){super(W4.SEQ,U);this.items=[]}add(U){this.items.push(U)}delete(U){let X=H4(U);if(typeof X!=="number")return!1;return this.items.splice(X,1).length>0}get(U,X){let q=H4(U);if(typeof q!=="number")return;let Z=this.items[q];return!X&&W4.isScalar(Z)?Z.value:Z}has(U){let X=H4(U);return typeof X==="number"&&X<this.items.length}set(U,X){let q=H4(U);if(typeof q!=="number")throw Error(`Expected a valid index, not ${U}.`);let Z=this.items[q];if(W4.isScalar(Z)&&dW.isScalarValue(X))Z.value=X;else this.items[q]=X}toJSON(U,X){let q=[];if(X?.onCreate)X.onCreate(q);let Z=0;for(let Q of this.items)q.push(cW.toJS(Q,String(Z++),X));return q}toString(U,X,q){if(!U)return JSON.stringify(this);return pW.stringifyCollection(this,U,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(U.indent||"")+" ",onChompKeep:q,onComment:X})}static from(U,X,q){let{replacer:Z}=q,Q=new this(U);if(X&&Symbol.iterator in Object(X)){let G=0;for(let Y of X){if(typeof Z==="function"){let J=X instanceof Set?Y:String(G++);Y=Z.call(X,J,Y)}Q.items.push(mW.createNode(Y,void 0,q))}}return Q}}function H4(U){let X=W4.isScalar(U)?U.value:U;if(X&&typeof X==="string")X=Number(X);return typeof X==="number"&&Number.isInteger(X)&&X>=0?X:null}iW.YAMLSeq=B3});var n1=R((nW)=>{var oW=k(),T3=Z1(),rW={collection:"seq",default:!0,nodeClass:T3.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(U,X){if(!oW.isSeq(U))X("Expected a sequence for this tag");return U},createNode:(U,X,q)=>T3.YAMLSeq.from(U,X,q)};nW.seq=rW});var s2=R((U_)=>{var tW=p2(),eW={identify:(U)=>typeof U==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(U)=>U,stringify(U,X,q,Z){return X=Object.assign({actualString:!0},X),tW.stringifyString(U,X,q,Z)}};U_.string=eW});var _4=R((q_)=>{var V3=i(),R3={identify:(U)=>U==null,createNode:()=>new V3.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new V3.Scalar(null),stringify:({source:U},X)=>typeof U==="string"&&R3.test.test(U)?U:X.options.nullStr};q_.nullTag=R3});var $U=R((G_)=>{var Q_=i(),D3={identify:(U)=>typeof U==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(U)=>new Q_.Scalar(U[0]==="t"||U[0]==="T"),stringify({source:U,value:X},q){if(U&&D3.test.test(U)){let Z=U[0]==="t"||U[0]==="T";if(X===Z)return U}return X?q.options.trueStr:q.options.falseStr}};G_.boolTag=D3});var a1=R((H_)=>{function J_({format:U,minFractionDigits:X,tag:q,value:Z}){if(typeof Z==="bigint")return String(Z);let Q=typeof Z==="number"?Z:Number(Z);if(!isFinite(Q))return isNaN(Q)?".nan":Q<0?"-.inf":".inf";let G=Object.is(Z,-0)?"-0":JSON.stringify(Z);if(!U&&X&&(!q||q==="tag:yaml.org,2002:float")&&/^\d/.test(G)){let Y=G.indexOf(".");if(Y<0)Y=G.length,G+=".";let J=X-(G.length-Y-1);while(J-- >0)G+="0"}return G}H_.stringifyNumber=J_});var zU=R((F_)=>{var __=i(),LU=a1(),$_={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(U)=>U.slice(-3).toLowerCase()==="nan"?NaN:U[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:LU.stringifyNumber},L_={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(U)=>parseFloat(U),stringify(U){let X=Number(U.value);return isFinite(X)?X.toExponential():LU.stringifyNumber(U)}},z_={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(U){let X=new __.Scalar(parseFloat(U)),q=U.indexOf(".");if(q!==-1&&U[U.length-1]==="0")X.minFractionDigits=U.length-q-1;return X},stringify:LU.stringifyNumber};F_.float=z_;F_.floatExp=L_;F_.floatNaN=$_});var AU=R((D_)=>{var M3=a1(),$4=(U)=>typeof U==="bigint"||Number.isInteger(U),FU=(U,X,q,{intAsBigInt:Z})=>Z?BigInt(U):parseInt(U.substring(X),q);function w3(U,X,q){let{value:Z}=U;if($4(Z)&&Z>=0)return q+Z.toString(X);return M3.stringifyNumber(U)}var T_={identify:(U)=>$4(U)&&U>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(U,X,q)=>FU(U,2,8,q),stringify:(U)=>w3(U,8,"0o")},V_={identify:$4,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(U,X,q)=>FU(U,0,10,q),stringify:M3.stringifyNumber},R_={identify:(U)=>$4(U)&&U>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(U,X,q)=>FU(U,2,16,q),stringify:(U)=>w3(U,16,"0x")};D_.int=V_;D_.intHex=R_;D_.intOct=T_});var P3=R((j_)=>{var I_=r1(),K_=_4(),N_=n1(),C_=s2(),S_=$U(),OU=zU(),BU=AU(),E_=[I_.map,N_.seq,C_.string,K_.nullTag,S_.boolTag,BU.intOct,BU.int,BU.intHex,OU.floatNaN,OU.floatExp,OU.float];j_.schema=E_});var K3=R((x_)=>{var f_=i(),g_=r1(),y_=n1();function I3(U){return typeof U==="bigint"||Number.isInteger(U)}var L4=({value:U})=>JSON.stringify(U),k_=[{identify:(U)=>typeof U==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(U)=>U,stringify:L4},{identify:(U)=>U==null,createNode:()=>new f_.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:L4},{identify:(U)=>typeof U==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(U)=>U==="true",stringify:L4},{identify:I3,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(U,X,{intAsBigInt:q})=>q?BigInt(U):parseInt(U,10),stringify:({value:U})=>I3(U)?U.toString():JSON.stringify(U)},{identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(U)=>parseFloat(U),stringify:L4}],v_={default:!0,tag:"",test:/^/,resolve(U,X){return X(`Unresolved plain scalar ${JSON.stringify(U)}`),U}},h_=[g_.map,y_.seq].concat(k_,v_);x_.schema=h_});var VU=R((l_)=>{var o2=w1("buffer"),TU=i(),m_=p2(),p_={identify:(U)=>U instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(U,X){if(typeof o2.Buffer==="function")return o2.Buffer.from(U,"base64");else if(typeof atob==="function"){let q=atob(U.replace(/[\n\r]/g,"")),Z=new Uint8Array(q.length);for(let Q=0;Q<q.length;++Q)Z[Q]=q.charCodeAt(Q);return Z}else return X("This environment does not support reading binary tags; either Buffer or atob is required"),U},stringify({comment:U,type:X,value:q},Z,Q,G){if(!q)return"";let Y=q,J;if(typeof o2.Buffer==="function")J=Y instanceof o2.Buffer?Y.toString("base64"):o2.Buffer.from(Y.buffer).toString("base64");else if(typeof btoa==="function"){let H="";for(let W=0;W<Y.length;++W)H+=String.fromCharCode(Y[W]);J=btoa(H)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(X??(X=TU.Scalar.BLOCK_LITERAL),X!==TU.Scalar.QUOTE_DOUBLE){let H=Math.max(Z.options.lineWidth-Z.indent.length,Z.options.minContentWidth),W=Math.ceil(J.length/H),$=Array(W);for(let _=0,L=0;_<W;++_,L+=H)$[_]=J.substr(L,H);J=$.join(X===TU.Scalar.BLOCK_LITERAL?`
52
+ `:" ")}return m_.stringifyString({comment:U,type:X,value:J},Z,Q,G)}};l_.binary=p_});var F4=R((o_)=>{var z4=k(),RU=U1(),c_=i(),i_=Z1();function N3(U,X){if(z4.isSeq(U))for(let q=0;q<U.items.length;++q){let Z=U.items[q];if(z4.isPair(Z))continue;else if(z4.isMap(Z)){if(Z.items.length>1)X("Each pair must have its own sequence indicator");let Q=Z.items[0]||new RU.Pair(new c_.Scalar(null));if(Z.commentBefore)Q.key.commentBefore=Q.key.commentBefore?`${Z.commentBefore}
53
53
  ${Q.key.commentBefore}`:Z.commentBefore;if(Z.comment){let G=Q.value??Q.key;G.comment=G.comment?`${Z.comment}
54
- ${G.comment}`:Z.comment}Z=Q}U.items[q]=z4.isPair(Z)?Z:new RU.Pair(Z)}else X("Expected a sequence for this tag");return U}function N3(U,X,q){let{replacer:Z}=q,Q=new m_.YAMLSeq(U);Q.tag="tag:yaml.org,2002:pairs";let G=0;if(X&&Symbol.iterator in Object(X))for(let Y of X){if(typeof Z==="function")Y=Z.call(X,String(G++),Y);let J,H;if(Array.isArray(Y))if(Y.length===2)J=Y[0],H=Y[1];else throw TypeError(`Expected [key, value] tuple: ${Y}`);else if(Y&&Y instanceof Object){let W=Object.keys(Y);if(W.length===1)J=W[0],H=Y[J];else throw TypeError(`Expected tuple with one key, not ${W.length} keys`)}else J=Y;Q.items.push(RU.createPair(J,H,q))}return Q}var p_={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:K3,createNode:N3};l_.createPairs=N3;l_.pairs=p_;l_.resolvePairs=K3});var MU=R((r_)=>{var C3=k(),DU=a0(),r2=q1(),s_=Z1(),S3=F4();class B1 extends s_.YAMLSeq{constructor(){super();this.add=r2.YAMLMap.prototype.add.bind(this),this.delete=r2.YAMLMap.prototype.delete.bind(this),this.get=r2.YAMLMap.prototype.get.bind(this),this.has=r2.YAMLMap.prototype.has.bind(this),this.set=r2.YAMLMap.prototype.set.bind(this),this.tag=B1.tag}toJSON(U,X){if(!X)return super.toJSON(U);let q=new Map;if(X?.onCreate)X.onCreate(q);for(let Z of this.items){let Q,G;if(C3.isPair(Z))Q=DU.toJS(Z.key,"",X),G=DU.toJS(Z.value,Q,X);else Q=DU.toJS(Z,"",X);if(q.has(Q))throw Error("Ordered maps must not include duplicate keys");q.set(Q,G)}return q}static from(U,X,q){let Z=S3.createPairs(U,X,q),Q=new this;return Q.items=Z.items,Q}}B1.tag="tag:yaml.org,2002:omap";var o_={collection:"seq",identify:(U)=>U instanceof Map,nodeClass:B1,default:!1,tag:"tag:yaml.org,2002:omap",resolve(U,X){let q=S3.resolvePairs(U,X),Z=[];for(let{key:Q}of q.items)if(C3.isScalar(Q))if(Z.includes(Q.value))X(`Ordered maps must not include duplicate keys: ${Q.value}`);else Z.push(Q.value);return Object.assign(new B1,q)},createNode:(U,X,q)=>B1.from(U,X,q)};r_.YAMLOMap=B1;r_.omap=o_});var g3=R((t_)=>{var E3=i();function j3({value:U,source:X},q){if(X&&(U?b3:f3).test.test(X))return X;return U?q.options.trueStr:q.options.falseStr}var b3={identify:(U)=>U===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new E3.Scalar(!0),stringify:j3},f3={identify:(U)=>U===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new E3.Scalar(!1),stringify:j3};t_.falseTag=f3;t_.trueTag=b3});var y3=R((G$)=>{var X$=i(),wU=a1(),q$={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(U)=>U.slice(-3).toLowerCase()==="nan"?NaN:U[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:wU.stringifyNumber},Z$={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(U)=>parseFloat(U.replace(/_/g,"")),stringify(U){let X=Number(U.value);return isFinite(X)?X.toExponential():wU.stringifyNumber(U)}},Q$={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(U){let X=new X$.Scalar(parseFloat(U.replace(/_/g,""))),q=U.indexOf(".");if(q!==-1){let Z=U.substring(q+1).replace(/_/g,"");if(Z[Z.length-1]==="0")X.minFractionDigits=Z.length}return X},stringify:wU.stringifyNumber};G$.float=Q$;G$.floatExp=Z$;G$.floatNaN=q$});var v3=R((z$)=>{var k3=a1(),n2=(U)=>typeof U==="bigint"||Number.isInteger(U);function A4(U,X,q,{intAsBigInt:Z}){let Q=U[0];if(Q==="-"||Q==="+")X+=1;if(U=U.substring(X).replace(/_/g,""),Z){switch(q){case 2:U=`0b${U}`;break;case 8:U=`0o${U}`;break;case 16:U=`0x${U}`;break}let Y=BigInt(U);return Q==="-"?BigInt(-1)*Y:Y}let G=parseInt(U,q);return Q==="-"?-1*G:G}function PU(U,X,q){let{value:Z}=U;if(n2(Z)){let Q=Z.toString(X);return Z<0?"-"+q+Q.substr(1):q+Q}return k3.stringifyNumber(U)}var W$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(U,X,q)=>A4(U,2,2,q),stringify:(U)=>PU(U,2,"0b")},_$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(U,X,q)=>A4(U,1,8,q),stringify:(U)=>PU(U,8,"0")},$$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(U,X,q)=>A4(U,0,10,q),stringify:k3.stringifyNumber},L$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(U,X,q)=>A4(U,2,16,q),stringify:(U)=>PU(U,16,"0x")};z$.int=$$;z$.intBin=W$;z$.intHex=L$;z$.intOct=_$});var IU=R((V$)=>{var T4=k(),O4=U1(),B4=q1();class T1 extends B4.YAMLMap{constructor(U){super(U);this.tag=T1.tag}add(U){let X;if(T4.isPair(U))X=U;else if(U&&typeof U==="object"&&"key"in U&&"value"in U&&U.value===null)X=new O4.Pair(U.key,null);else X=new O4.Pair(U,null);if(!B4.findPair(this.items,X.key))this.items.push(X)}get(U,X){let q=B4.findPair(this.items,U);return!X&&T4.isPair(q)?T4.isScalar(q.key)?q.key.value:q.key:q}set(U,X){if(typeof X!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof X}`);let q=B4.findPair(this.items,U);if(q&&!X)this.items.splice(this.items.indexOf(q),1);else if(!q&&X)this.items.push(new O4.Pair(U))}toJSON(U,X){return super.toJSON(U,X,Set)}toString(U,X,q){if(!U)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},U,{allNullValues:!0}),X,q);else throw Error("Set items must all have null values")}static from(U,X,q){let{replacer:Z}=q,Q=new this(U);if(X&&Symbol.iterator in Object(X))for(let G of X){if(typeof Z==="function")G=Z.call(X,G,G);Q.items.push(O4.createPair(G,null,q))}return Q}}T1.tag="tag:yaml.org,2002:set";var T$={collection:"map",identify:(U)=>U instanceof Set,nodeClass:T1,default:!1,tag:"tag:yaml.org,2002:set",createNode:(U,X,q)=>T1.from(U,X,q),resolve(U,X){if(T4.isMap(U))if(U.hasAllNullValues(!0))return Object.assign(new T1,U);else X("Set items must all have null values");else X("Expected a mapping for this tag");return U}};V$.YAMLSet=T1;V$.set=T$});var NU=R((I$)=>{var M$=a1();function KU(U,X){let q=U[0],Z=q==="-"||q==="+"?U.substring(1):U,Q=(Y)=>X?BigInt(Y):Number(Y),G=Z.replace(/_/g,"").split(":").reduce((Y,J)=>Y*Q(60)+Q(J),Q(0));return q==="-"?Q(-1)*G:G}function h3(U){let{value:X}=U,q=(Y)=>Y;if(typeof X==="bigint")q=(Y)=>BigInt(Y);else if(isNaN(X)||!isFinite(X))return M$.stringifyNumber(U);let Z="";if(X<0)Z="-",X*=q(-1);let Q=q(60),G=[X%Q];if(X<60)G.unshift(0);else if(X=(X-G[0])/Q,G.unshift(X%Q),X>=60)X=(X-G[0])/Q,G.unshift(X);return Z+G.map((Y)=>String(Y).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var w$={identify:(U)=>typeof U==="bigint"||Number.isInteger(U),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(U,X,{intAsBigInt:q})=>KU(U,q),stringify:h3},P$={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(U)=>KU(U,!1),stringify:h3},x3={identify:(U)=>U instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(U){let X=U.match(x3.test);if(!X)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,q,Z,Q,G,Y,J]=X.map(Number),H=X[7]?Number((X[7]+"00").substr(1,3)):0,W=Date.UTC(q,Z-1,Q,G||0,Y||0,J||0,H),$=X[8];if($&&$!=="Z"){let _=KU($,!1);if(Math.abs(_)<30)_*=60;W-=60000*_}return new Date(W)},stringify:({value:U})=>U?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};I$.floatTime=P$;I$.intTime=w$;I$.timestamp=x3});var m3=R((x$)=>{var S$=r1(),E$=_4(),j$=n1(),b$=s2(),f$=VU(),u3=g3(),CU=y3(),V4=v3(),g$=q4(),y$=MU(),k$=F4(),v$=IU(),SU=NU(),h$=[S$.map,j$.seq,b$.string,E$.nullTag,u3.trueTag,u3.falseTag,V4.intBin,V4.intOct,V4.int,V4.intHex,CU.floatNaN,CU.floatExp,CU.float,f$.binary,g$.merge,y$.omap,k$.pairs,v$.set,SU.intTime,SU.floatTime,SU.timestamp];x$.schema=h$});var a3=R((o$)=>{var c3=r1(),m$=_4(),i3=n1(),p$=s2(),l$=$U(),EU=zU(),jU=AU(),d$=w3(),c$=I3(),s3=VU(),a2=q4(),o3=MU(),r3=F4(),p3=m3(),n3=IU(),R4=NU(),l3=new Map([["core",d$.schema],["failsafe",[c3.map,i3.seq,p$.string]],["json",c$.schema],["yaml11",p3.schema],["yaml-1.1",p3.schema]]),d3={binary:s3.binary,bool:l$.boolTag,float:EU.float,floatExp:EU.floatExp,floatNaN:EU.floatNaN,floatTime:R4.floatTime,int:jU.int,intHex:jU.intHex,intOct:jU.intOct,intTime:R4.intTime,map:c3.map,merge:a2.merge,null:m$.nullTag,omap:o3.omap,pairs:r3.pairs,seq:i3.seq,set:n3.set,timestamp:R4.timestamp},i$={"tag:yaml.org,2002:binary":s3.binary,"tag:yaml.org,2002:merge":a2.merge,"tag:yaml.org,2002:omap":o3.omap,"tag:yaml.org,2002:pairs":r3.pairs,"tag:yaml.org,2002:set":n3.set,"tag:yaml.org,2002:timestamp":R4.timestamp};function s$(U,X,q){let Z=l3.get(X);if(Z&&!U)return q&&!Z.includes(a2.merge)?Z.concat(a2.merge):Z.slice();let Q=Z;if(!Q)if(Array.isArray(U))Q=[];else{let G=Array.from(l3.keys()).filter((Y)=>Y!=="yaml11").map((Y)=>JSON.stringify(Y)).join(", ");throw Error(`Unknown schema "${X}"; use one of ${G} or define customTags array`)}if(Array.isArray(U))for(let G of U)Q=Q.concat(G);else if(typeof U==="function")Q=U(Q.slice());if(q)Q=Q.concat(a2.merge);return Q.reduce((G,Y)=>{let J=typeof Y==="string"?d3[Y]:Y;if(!J){let H=JSON.stringify(Y),W=Object.keys(d3).map(($)=>JSON.stringify($)).join(", ");throw Error(`Unknown custom tag ${H}; use one of ${W}`)}if(!G.includes(J))G.push(J);return G},[])}o$.coreKnownTags=i$;o$.getTags=s$});var gU=R((XL)=>{var bU=k(),a$=r1(),t$=n1(),e$=s2(),D4=a3(),UL=(U,X)=>U.key<X.key?-1:U.key>X.key?1:0;class fU{constructor({compat:U,customTags:X,merge:q,resolveKnownTags:Z,schema:Q,sortMapEntries:G,toStringDefaults:Y}){this.compat=Array.isArray(U)?D4.getTags(U,"compat"):U?D4.getTags(null,U):null,this.name=typeof Q==="string"&&Q||"core",this.knownTags=Z?D4.coreKnownTags:{},this.tags=D4.getTags(X,this.name,q),this.toStringOptions=Y??null,Object.defineProperty(this,bU.MAP,{value:a$.map}),Object.defineProperty(this,bU.SCALAR,{value:e$.string}),Object.defineProperty(this,bU.SEQ,{value:t$.seq}),this.sortMapEntries=typeof G==="function"?G:G===!0?UL:null}clone(){let U=Object.create(fU.prototype,Object.getOwnPropertyDescriptors(this));return U.tags=this.tags.slice(),U}}XL.Schema=fU});var t3=R((GL)=>{var ZL=k(),yU=l2(),t2=u2();function QL(U,X){let q=[],Z=X.directives===!0;if(X.directives!==!1&&U.directives){let H=U.directives.toString(U);if(H)q.push(H),Z=!0;else if(U.directives.docStart)Z=!0}if(Z)q.push("---");let Q=yU.createStringifyContext(U,X),{commentString:G}=Q.options;if(U.commentBefore){if(q.length!==1)q.unshift("");let H=G(U.commentBefore);q.unshift(t2.indentComment(H,""))}let Y=!1,J=null;if(U.contents){if(ZL.isNode(U.contents)){if(U.contents.spaceBefore&&Z)q.push("");if(U.contents.commentBefore){let $=G(U.contents.commentBefore);q.push(t2.indentComment($,""))}Q.forceBlockIndent=!!U.comment,J=U.contents.comment}let H=J?void 0:()=>Y=!0,W=yU.stringify(U.contents,Q,()=>J=null,H);if(J)W+=t2.lineComment(W,"",G(J));if((W[0]==="|"||W[0]===">")&&q[q.length-1]==="---")q[q.length-1]=`--- ${W}`;else q.push(W)}else q.push(yU.stringify(U.contents,Q));if(U.directives?.docEnd)if(U.comment){let H=G(U.comment);if(H.includes(`
54
+ ${G.comment}`:Z.comment}Z=Q}U.items[q]=z4.isPair(Z)?Z:new RU.Pair(Z)}else X("Expected a sequence for this tag");return U}function C3(U,X,q){let{replacer:Z}=q,Q=new i_.YAMLSeq(U);Q.tag="tag:yaml.org,2002:pairs";let G=0;if(X&&Symbol.iterator in Object(X))for(let Y of X){if(typeof Z==="function")Y=Z.call(X,String(G++),Y);let J,H;if(Array.isArray(Y))if(Y.length===2)J=Y[0],H=Y[1];else throw TypeError(`Expected [key, value] tuple: ${Y}`);else if(Y&&Y instanceof Object){let W=Object.keys(Y);if(W.length===1)J=W[0],H=Y[J];else throw TypeError(`Expected tuple with one key, not ${W.length} keys`)}else J=Y;Q.items.push(RU.createPair(J,H,q))}return Q}var s_={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:N3,createNode:C3};o_.createPairs=C3;o_.pairs=s_;o_.resolvePairs=N3});var MU=R((U$)=>{var S3=k(),DU=a0(),r2=q1(),t_=Z1(),E3=F4();class B1 extends t_.YAMLSeq{constructor(){super();this.add=r2.YAMLMap.prototype.add.bind(this),this.delete=r2.YAMLMap.prototype.delete.bind(this),this.get=r2.YAMLMap.prototype.get.bind(this),this.has=r2.YAMLMap.prototype.has.bind(this),this.set=r2.YAMLMap.prototype.set.bind(this),this.tag=B1.tag}toJSON(U,X){if(!X)return super.toJSON(U);let q=new Map;if(X?.onCreate)X.onCreate(q);for(let Z of this.items){let Q,G;if(S3.isPair(Z))Q=DU.toJS(Z.key,"",X),G=DU.toJS(Z.value,Q,X);else Q=DU.toJS(Z,"",X);if(q.has(Q))throw Error("Ordered maps must not include duplicate keys");q.set(Q,G)}return q}static from(U,X,q){let Z=E3.createPairs(U,X,q),Q=new this;return Q.items=Z.items,Q}}B1.tag="tag:yaml.org,2002:omap";var e_={collection:"seq",identify:(U)=>U instanceof Map,nodeClass:B1,default:!1,tag:"tag:yaml.org,2002:omap",resolve(U,X){let q=E3.resolvePairs(U,X),Z=[];for(let{key:Q}of q.items)if(S3.isScalar(Q))if(Z.includes(Q.value))X(`Ordered maps must not include duplicate keys: ${Q.value}`);else Z.push(Q.value);return Object.assign(new B1,q)},createNode:(U,X,q)=>B1.from(U,X,q)};U$.YAMLOMap=B1;U$.omap=e_});var y3=R((Z$)=>{var j3=i();function b3({value:U,source:X},q){if(X&&(U?f3:g3).test.test(X))return X;return U?q.options.trueStr:q.options.falseStr}var f3={identify:(U)=>U===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new j3.Scalar(!0),stringify:b3},g3={identify:(U)=>U===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new j3.Scalar(!1),stringify:b3};Z$.falseTag=g3;Z$.trueTag=f3});var k3=R((_$)=>{var Y$=i(),wU=a1(),J$={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(U)=>U.slice(-3).toLowerCase()==="nan"?NaN:U[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:wU.stringifyNumber},H$={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(U)=>parseFloat(U.replace(/_/g,"")),stringify(U){let X=Number(U.value);return isFinite(X)?X.toExponential():wU.stringifyNumber(U)}},W$={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(U){let X=new Y$.Scalar(parseFloat(U.replace(/_/g,""))),q=U.indexOf(".");if(q!==-1){let Z=U.substring(q+1).replace(/_/g,"");if(Z[Z.length-1]==="0")X.minFractionDigits=Z.length}return X},stringify:wU.stringifyNumber};_$.float=W$;_$.floatExp=H$;_$.floatNaN=J$});var h3=R((T$)=>{var v3=a1(),n2=(U)=>typeof U==="bigint"||Number.isInteger(U);function A4(U,X,q,{intAsBigInt:Z}){let Q=U[0];if(Q==="-"||Q==="+")X+=1;if(U=U.substring(X).replace(/_/g,""),Z){switch(q){case 2:U=`0b${U}`;break;case 8:U=`0o${U}`;break;case 16:U=`0x${U}`;break}let Y=BigInt(U);return Q==="-"?BigInt(-1)*Y:Y}let G=parseInt(U,q);return Q==="-"?-1*G:G}function PU(U,X,q){let{value:Z}=U;if(n2(Z)){let Q=Z.toString(X);return Z<0?"-"+q+Q.substr(1):q+Q}return v3.stringifyNumber(U)}var F$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(U,X,q)=>A4(U,2,2,q),stringify:(U)=>PU(U,2,"0b")},A$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(U,X,q)=>A4(U,1,8,q),stringify:(U)=>PU(U,8,"0")},O$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(U,X,q)=>A4(U,0,10,q),stringify:v3.stringifyNumber},B$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(U,X,q)=>A4(U,2,16,q),stringify:(U)=>PU(U,16,"0x")};T$.int=O$;T$.intBin=F$;T$.intHex=B$;T$.intOct=A$});var IU=R((P$)=>{var T4=k(),O4=U1(),B4=q1();class T1 extends B4.YAMLMap{constructor(U){super(U);this.tag=T1.tag}add(U){let X;if(T4.isPair(U))X=U;else if(U&&typeof U==="object"&&"key"in U&&"value"in U&&U.value===null)X=new O4.Pair(U.key,null);else X=new O4.Pair(U,null);if(!B4.findPair(this.items,X.key))this.items.push(X)}get(U,X){let q=B4.findPair(this.items,U);return!X&&T4.isPair(q)?T4.isScalar(q.key)?q.key.value:q.key:q}set(U,X){if(typeof X!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof X}`);let q=B4.findPair(this.items,U);if(q&&!X)this.items.splice(this.items.indexOf(q),1);else if(!q&&X)this.items.push(new O4.Pair(U))}toJSON(U,X){return super.toJSON(U,X,Set)}toString(U,X,q){if(!U)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},U,{allNullValues:!0}),X,q);else throw Error("Set items must all have null values")}static from(U,X,q){let{replacer:Z}=q,Q=new this(U);if(X&&Symbol.iterator in Object(X))for(let G of X){if(typeof Z==="function")G=Z.call(X,G,G);Q.items.push(O4.createPair(G,null,q))}return Q}}T1.tag="tag:yaml.org,2002:set";var w$={collection:"map",identify:(U)=>U instanceof Set,nodeClass:T1,default:!1,tag:"tag:yaml.org,2002:set",createNode:(U,X,q)=>T1.from(U,X,q),resolve(U,X){if(T4.isMap(U))if(U.hasAllNullValues(!0))return Object.assign(new T1,U);else X("Set items must all have null values");else X("Expected a mapping for this tag");return U}};P$.YAMLSet=T1;P$.set=w$});var NU=R((E$)=>{var N$=a1();function KU(U,X){let q=U[0],Z=q==="-"||q==="+"?U.substring(1):U,Q=(Y)=>X?BigInt(Y):Number(Y),G=Z.replace(/_/g,"").split(":").reduce((Y,J)=>Y*Q(60)+Q(J),Q(0));return q==="-"?Q(-1)*G:G}function x3(U){let{value:X}=U,q=(Y)=>Y;if(typeof X==="bigint")q=(Y)=>BigInt(Y);else if(isNaN(X)||!isFinite(X))return N$.stringifyNumber(U);let Z="";if(X<0)Z="-",X*=q(-1);let Q=q(60),G=[X%Q];if(X<60)G.unshift(0);else if(X=(X-G[0])/Q,G.unshift(X%Q),X>=60)X=(X-G[0])/Q,G.unshift(X);return Z+G.map((Y)=>String(Y).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var C$={identify:(U)=>typeof U==="bigint"||Number.isInteger(U),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(U,X,{intAsBigInt:q})=>KU(U,q),stringify:x3},S$={identify:(U)=>typeof U==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(U)=>KU(U,!1),stringify:x3},u3={identify:(U)=>U instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(U){let X=U.match(u3.test);if(!X)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,q,Z,Q,G,Y,J]=X.map(Number),H=X[7]?Number((X[7]+"00").substr(1,3)):0,W=Date.UTC(q,Z-1,Q,G||0,Y||0,J||0,H),$=X[8];if($&&$!=="Z"){let _=KU($,!1);if(Math.abs(_)<30)_*=60;W-=60000*_}return new Date(W)},stringify:({value:U})=>U?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};E$.floatTime=S$;E$.intTime=C$;E$.timestamp=u3});var p3=R((d$)=>{var g$=r1(),y$=_4(),k$=n1(),v$=s2(),h$=VU(),m3=y3(),CU=k3(),V4=h3(),x$=q4(),u$=MU(),m$=F4(),p$=IU(),SU=NU(),l$=[g$.map,k$.seq,v$.string,y$.nullTag,m3.trueTag,m3.falseTag,V4.intBin,V4.intOct,V4.int,V4.intHex,CU.floatNaN,CU.floatExp,CU.float,h$.binary,x$.merge,u$.omap,m$.pairs,p$.set,SU.intTime,SU.floatTime,SU.timestamp];d$.schema=l$});var t3=R((e$)=>{var i3=r1(),i$=_4(),s3=n1(),s$=s2(),o$=$U(),EU=zU(),jU=AU(),r$=P3(),n$=K3(),o3=VU(),a2=q4(),r3=MU(),n3=F4(),l3=p3(),a3=IU(),R4=NU(),d3=new Map([["core",r$.schema],["failsafe",[i3.map,s3.seq,s$.string]],["json",n$.schema],["yaml11",l3.schema],["yaml-1.1",l3.schema]]),c3={binary:o3.binary,bool:o$.boolTag,float:EU.float,floatExp:EU.floatExp,floatNaN:EU.floatNaN,floatTime:R4.floatTime,int:jU.int,intHex:jU.intHex,intOct:jU.intOct,intTime:R4.intTime,map:i3.map,merge:a2.merge,null:i$.nullTag,omap:r3.omap,pairs:n3.pairs,seq:s3.seq,set:a3.set,timestamp:R4.timestamp},a$={"tag:yaml.org,2002:binary":o3.binary,"tag:yaml.org,2002:merge":a2.merge,"tag:yaml.org,2002:omap":r3.omap,"tag:yaml.org,2002:pairs":n3.pairs,"tag:yaml.org,2002:set":a3.set,"tag:yaml.org,2002:timestamp":R4.timestamp};function t$(U,X,q){let Z=d3.get(X);if(Z&&!U)return q&&!Z.includes(a2.merge)?Z.concat(a2.merge):Z.slice();let Q=Z;if(!Q)if(Array.isArray(U))Q=[];else{let G=Array.from(d3.keys()).filter((Y)=>Y!=="yaml11").map((Y)=>JSON.stringify(Y)).join(", ");throw Error(`Unknown schema "${X}"; use one of ${G} or define customTags array`)}if(Array.isArray(U))for(let G of U)Q=Q.concat(G);else if(typeof U==="function")Q=U(Q.slice());if(q)Q=Q.concat(a2.merge);return Q.reduce((G,Y)=>{let J=typeof Y==="string"?c3[Y]:Y;if(!J){let H=JSON.stringify(Y),W=Object.keys(c3).map(($)=>JSON.stringify($)).join(", ");throw Error(`Unknown custom tag ${H}; use one of ${W}`)}if(!G.includes(J))G.push(J);return G},[])}e$.coreKnownTags=a$;e$.getTags=t$});var gU=R((YL)=>{var bU=k(),qL=r1(),ZL=n1(),QL=s2(),D4=t3(),GL=(U,X)=>U.key<X.key?-1:U.key>X.key?1:0;class fU{constructor({compat:U,customTags:X,merge:q,resolveKnownTags:Z,schema:Q,sortMapEntries:G,toStringDefaults:Y}){this.compat=Array.isArray(U)?D4.getTags(U,"compat"):U?D4.getTags(null,U):null,this.name=typeof Q==="string"&&Q||"core",this.knownTags=Z?D4.coreKnownTags:{},this.tags=D4.getTags(X,this.name,q),this.toStringOptions=Y??null,Object.defineProperty(this,bU.MAP,{value:qL.map}),Object.defineProperty(this,bU.SCALAR,{value:QL.string}),Object.defineProperty(this,bU.SEQ,{value:ZL.seq}),this.sortMapEntries=typeof G==="function"?G:G===!0?GL:null}clone(){let U=Object.create(fU.prototype,Object.getOwnPropertyDescriptors(this));return U.tags=this.tags.slice(),U}}YL.Schema=fU});var e3=R((_L)=>{var HL=k(),yU=l2(),t2=u2();function WL(U,X){let q=[],Z=X.directives===!0;if(X.directives!==!1&&U.directives){let H=U.directives.toString(U);if(H)q.push(H),Z=!0;else if(U.directives.docStart)Z=!0}if(Z)q.push("---");let Q=yU.createStringifyContext(U,X),{commentString:G}=Q.options;if(U.commentBefore){if(q.length!==1)q.unshift("");let H=G(U.commentBefore);q.unshift(t2.indentComment(H,""))}let Y=!1,J=null;if(U.contents){if(HL.isNode(U.contents)){if(U.contents.spaceBefore&&Z)q.push("");if(U.contents.commentBefore){let $=G(U.contents.commentBefore);q.push(t2.indentComment($,""))}Q.forceBlockIndent=!!U.comment,J=U.contents.comment}let H=J?void 0:()=>Y=!0,W=yU.stringify(U.contents,Q,()=>J=null,H);if(J)W+=t2.lineComment(W,"",G(J));if((W[0]==="|"||W[0]===">")&&q[q.length-1]==="---")q[q.length-1]=`--- ${W}`;else q.push(W)}else q.push(yU.stringify(U.contents,Q));if(U.directives?.docEnd)if(U.comment){let H=G(U.comment);if(H.includes(`
55
55
  `))q.push("..."),q.push(t2.indentComment(H,""));else q.push(`... ${H}`)}else q.push("...");else{let H=U.comment;if(H&&Y)H=H.replace(/^\n+/,"");if(H){if((!Y||J)&&q[q.length-1]!=="")q.push("");q.push(t2.indentComment(G(H),""))}}return q.join(`
56
56
  `)+`
57
- `}GL.stringifyDocument=QL});var e2=R((FL)=>{var JL=h2(),t1=n6(),R0=k(),HL=U1(),WL=a0(),_L=gU(),$L=t3(),kU=s6(),LL=XU(),zL=x2(),vU=UU();class hU{constructor(U,X,q){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,R0.NODE_TYPE,{value:R0.DOC});let Z=null;if(typeof X==="function"||Array.isArray(X))Z=X;else if(q===void 0&&X)q=X,X=void 0;let Q=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},q);this.options=Q;let{version:G}=Q;if(q?._directives){if(this.directives=q._directives.atDocument(),this.directives.yaml.explicit)G=this.directives.yaml.version}else this.directives=new vU.Directives({version:G});this.setSchema(G,q),this.contents=U===void 0?null:this.createNode(U,Z,q)}clone(){let U=Object.create(hU.prototype,{[R0.NODE_TYPE]:{value:R0.DOC}});if(U.commentBefore=this.commentBefore,U.comment=this.comment,U.errors=this.errors.slice(),U.warnings=this.warnings.slice(),U.options=Object.assign({},this.options),this.directives)U.directives=this.directives.clone();if(U.schema=this.schema.clone(),U.contents=R0.isNode(this.contents)?this.contents.clone(U.schema):this.contents,this.range)U.range=this.range.slice();return U}add(U){if(e1(this.contents))this.contents.add(U)}addIn(U,X){if(e1(this.contents))this.contents.addIn(U,X)}createAlias(U,X){if(!U.anchor){let q=kU.anchorNames(this);U.anchor=!X||q.has(X)?kU.findNewAnchor(X||"a",q):X}return new JL.Alias(U.anchor)}createNode(U,X,q){let Z=void 0;if(typeof X==="function")U=X.call({"":U},"",U),Z=X;else if(Array.isArray(X)){let z=(D)=>typeof D==="number"||D instanceof String||D instanceof Number,B=X.filter(z).map(String);if(B.length>0)X=X.concat(B);Z=X}else if(q===void 0&&X)q=X,X=void 0;let{aliasDuplicateObjects:Q,anchorPrefix:G,flow:Y,keepUndefined:J,onTagObj:H,tag:W}=q??{},{onAnchor:$,setAnchors:_,sourceObjects:L}=kU.createNodeAnchors(this,G||"a"),A={aliasDuplicateObjects:Q??!0,keepUndefined:J??!1,onAnchor:$,onTagObj:H,replacer:Z,schema:this.schema,sourceObjects:L},V=zL.createNode(U,W,A);if(Y&&R0.isCollection(V))V.flow=!0;return _(),V}createPair(U,X,q={}){let Z=this.createNode(U,null,q),Q=this.createNode(X,null,q);return new HL.Pair(Z,Q)}delete(U){return e1(this.contents)?this.contents.delete(U):!1}deleteIn(U){if(t1.isEmptyPath(U)){if(this.contents==null)return!1;return this.contents=null,!0}return e1(this.contents)?this.contents.deleteIn(U):!1}get(U,X){return R0.isCollection(this.contents)?this.contents.get(U,X):void 0}getIn(U,X){if(t1.isEmptyPath(U))return!X&&R0.isScalar(this.contents)?this.contents.value:this.contents;return R0.isCollection(this.contents)?this.contents.getIn(U,X):void 0}has(U){return R0.isCollection(this.contents)?this.contents.has(U):!1}hasIn(U){if(t1.isEmptyPath(U))return this.contents!==void 0;return R0.isCollection(this.contents)?this.contents.hasIn(U):!1}set(U,X){if(this.contents==null)this.contents=t1.collectionFromPath(this.schema,[U],X);else if(e1(this.contents))this.contents.set(U,X)}setIn(U,X){if(t1.isEmptyPath(U))this.contents=X;else if(this.contents==null)this.contents=t1.collectionFromPath(this.schema,Array.from(U),X);else if(e1(this.contents))this.contents.setIn(U,X)}setSchema(U,X={}){if(typeof U==="number")U=String(U);let q;switch(U){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new vU.Directives({version:"1.1"});q={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=U;else this.directives=new vU.Directives({version:U});q={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;q=null;break;default:{let Z=JSON.stringify(U);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${Z}`)}}if(X.schema instanceof Object)this.schema=X.schema;else if(q)this.schema=new _L.Schema(Object.assign(q,X));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:U,jsonArg:X,mapAsMap:q,maxAliasCount:Z,onAnchor:Q,reviver:G}={}){let Y={anchors:new Map,doc:this,keep:!U,mapAsMap:q===!0,mapKeyWarned:!1,maxAliasCount:typeof Z==="number"?Z:100},J=WL.toJS(this.contents,X??"",Y);if(typeof Q==="function")for(let{count:H,res:W}of Y.anchors.values())Q(W,H);return typeof G==="function"?LL.applyReviver(G,{"":J},"",J):J}toJSON(U,X){return this.toJS({json:!0,jsonArg:U,mapAsMap:!1,onAnchor:X})}toString(U={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in U&&(!Number.isInteger(U.indent)||Number(U.indent)<=0)){let X=JSON.stringify(U.indent);throw Error(`"indent" option must be a positive integer, not ${X}`)}return $L.stringifyDocument(this,U)}}function e1(U){if(R0.isCollection(U))return!0;throw Error("Expected a YAML collection as document contents")}FL.Document=hU});var U6=R((BL)=>{class M4 extends Error{constructor(U,X,q,Z){super();this.name=U,this.code=q,this.message=Z,this.pos=X}}class e3 extends M4{constructor(U,X,q){super("YAMLParseError",U,X,q)}}class UQ extends M4{constructor(U,X,q){super("YAMLWarning",U,X,q)}}var OL=(U,X)=>(q)=>{if(q.pos[0]===-1)return;q.linePos=q.pos.map((J)=>X.linePos(J));let{line:Z,col:Q}=q.linePos[0];q.message+=` at line ${Z}, column ${Q}`;let G=Q-1,Y=U.substring(X.lineStarts[Z-1],X.lineStarts[Z]).replace(/[\n\r]+$/,"");if(G>=60&&Y.length>80){let J=Math.min(G-39,Y.length-79);Y="…"+Y.substring(J),G-=J-1}if(Y.length>80)Y=Y.substring(0,79)+"…";if(Z>1&&/^ *$/.test(Y.substring(0,G))){let J=U.substring(X.lineStarts[Z-2],X.lineStarts[Z-1]);if(J.length>80)J=J.substring(0,79)+`…
57
+ `}_L.stringifyDocument=WL});var e2=R((VL)=>{var LL=h2(),t1=n6(),R0=k(),zL=U1(),FL=a0(),AL=gU(),OL=e3(),kU=s6(),BL=XU(),TL=x2(),vU=UU();class hU{constructor(U,X,q){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,R0.NODE_TYPE,{value:R0.DOC});let Z=null;if(typeof X==="function"||Array.isArray(X))Z=X;else if(q===void 0&&X)q=X,X=void 0;let Q=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},q);this.options=Q;let{version:G}=Q;if(q?._directives){if(this.directives=q._directives.atDocument(),this.directives.yaml.explicit)G=this.directives.yaml.version}else this.directives=new vU.Directives({version:G});this.setSchema(G,q),this.contents=U===void 0?null:this.createNode(U,Z,q)}clone(){let U=Object.create(hU.prototype,{[R0.NODE_TYPE]:{value:R0.DOC}});if(U.commentBefore=this.commentBefore,U.comment=this.comment,U.errors=this.errors.slice(),U.warnings=this.warnings.slice(),U.options=Object.assign({},this.options),this.directives)U.directives=this.directives.clone();if(U.schema=this.schema.clone(),U.contents=R0.isNode(this.contents)?this.contents.clone(U.schema):this.contents,this.range)U.range=this.range.slice();return U}add(U){if(e1(this.contents))this.contents.add(U)}addIn(U,X){if(e1(this.contents))this.contents.addIn(U,X)}createAlias(U,X){if(!U.anchor){let q=kU.anchorNames(this);U.anchor=!X||q.has(X)?kU.findNewAnchor(X||"a",q):X}return new LL.Alias(U.anchor)}createNode(U,X,q){let Z=void 0;if(typeof X==="function")U=X.call({"":U},"",U),Z=X;else if(Array.isArray(X)){let z=(D)=>typeof D==="number"||D instanceof String||D instanceof Number,B=X.filter(z).map(String);if(B.length>0)X=X.concat(B);Z=X}else if(q===void 0&&X)q=X,X=void 0;let{aliasDuplicateObjects:Q,anchorPrefix:G,flow:Y,keepUndefined:J,onTagObj:H,tag:W}=q??{},{onAnchor:$,setAnchors:_,sourceObjects:L}=kU.createNodeAnchors(this,G||"a"),A={aliasDuplicateObjects:Q??!0,keepUndefined:J??!1,onAnchor:$,onTagObj:H,replacer:Z,schema:this.schema,sourceObjects:L},V=TL.createNode(U,W,A);if(Y&&R0.isCollection(V))V.flow=!0;return _(),V}createPair(U,X,q={}){let Z=this.createNode(U,null,q),Q=this.createNode(X,null,q);return new zL.Pair(Z,Q)}delete(U){return e1(this.contents)?this.contents.delete(U):!1}deleteIn(U){if(t1.isEmptyPath(U)){if(this.contents==null)return!1;return this.contents=null,!0}return e1(this.contents)?this.contents.deleteIn(U):!1}get(U,X){return R0.isCollection(this.contents)?this.contents.get(U,X):void 0}getIn(U,X){if(t1.isEmptyPath(U))return!X&&R0.isScalar(this.contents)?this.contents.value:this.contents;return R0.isCollection(this.contents)?this.contents.getIn(U,X):void 0}has(U){return R0.isCollection(this.contents)?this.contents.has(U):!1}hasIn(U){if(t1.isEmptyPath(U))return this.contents!==void 0;return R0.isCollection(this.contents)?this.contents.hasIn(U):!1}set(U,X){if(this.contents==null)this.contents=t1.collectionFromPath(this.schema,[U],X);else if(e1(this.contents))this.contents.set(U,X)}setIn(U,X){if(t1.isEmptyPath(U))this.contents=X;else if(this.contents==null)this.contents=t1.collectionFromPath(this.schema,Array.from(U),X);else if(e1(this.contents))this.contents.setIn(U,X)}setSchema(U,X={}){if(typeof U==="number")U=String(U);let q;switch(U){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new vU.Directives({version:"1.1"});q={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=U;else this.directives=new vU.Directives({version:U});q={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;q=null;break;default:{let Z=JSON.stringify(U);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${Z}`)}}if(X.schema instanceof Object)this.schema=X.schema;else if(q)this.schema=new AL.Schema(Object.assign(q,X));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:U,jsonArg:X,mapAsMap:q,maxAliasCount:Z,onAnchor:Q,reviver:G}={}){let Y={anchors:new Map,doc:this,keep:!U,mapAsMap:q===!0,mapKeyWarned:!1,maxAliasCount:typeof Z==="number"?Z:100},J=FL.toJS(this.contents,X??"",Y);if(typeof Q==="function")for(let{count:H,res:W}of Y.anchors.values())Q(W,H);return typeof G==="function"?BL.applyReviver(G,{"":J},"",J):J}toJSON(U,X){return this.toJS({json:!0,jsonArg:U,mapAsMap:!1,onAnchor:X})}toString(U={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in U&&(!Number.isInteger(U.indent)||Number(U.indent)<=0)){let X=JSON.stringify(U.indent);throw Error(`"indent" option must be a positive integer, not ${X}`)}return OL.stringifyDocument(this,U)}}function e1(U){if(R0.isCollection(U))return!0;throw Error("Expected a YAML collection as document contents")}VL.Document=hU});var U6=R((ML)=>{class M4 extends Error{constructor(U,X,q,Z){super();this.name=U,this.code=q,this.message=Z,this.pos=X}}class UQ extends M4{constructor(U,X,q){super("YAMLParseError",U,X,q)}}class XQ extends M4{constructor(U,X,q){super("YAMLWarning",U,X,q)}}var DL=(U,X)=>(q)=>{if(q.pos[0]===-1)return;q.linePos=q.pos.map((J)=>X.linePos(J));let{line:Z,col:Q}=q.linePos[0];q.message+=` at line ${Z}, column ${Q}`;let G=Q-1,Y=U.substring(X.lineStarts[Z-1],X.lineStarts[Z]).replace(/[\n\r]+$/,"");if(G>=60&&Y.length>80){let J=Math.min(G-39,Y.length-79);Y="…"+Y.substring(J),G-=J-1}if(Y.length>80)Y=Y.substring(0,79)+"…";if(Z>1&&/^ *$/.test(Y.substring(0,G))){let J=U.substring(X.lineStarts[Z-2],X.lineStarts[Z-1]);if(J.length>80)J=J.substring(0,79)+`…
58
58
  `;Y=J+Y}if(/[^ ]/.test(Y)){let J=1,H=q.linePos[1];if(H?.line===Z&&H.col>Q)J=Math.max(1,Math.min(H.col-Q,80-G));let W=" ".repeat(G)+"^".repeat(J);q.message+=`:
59
59
 
60
60
  ${Y}
61
61
  ${W}
62
- `}};BL.YAMLError=M4;BL.YAMLParseError=e3;BL.YAMLWarning=UQ;BL.prettifyError=OL});var X6=R((wL)=>{function ML(U,{flow:X,indicator:q,next:Z,offset:Q,onError:G,parentIndent:Y,startOnNewline:J}){let H=!1,W=J,$=J,_="",L="",A=!1,V=!1,z=null,B=null,D=null,P=null,K=null,C=null,N=null;for(let w of U){if(V){if(w.type!=="space"&&w.type!=="newline"&&w.type!=="comma")G(w.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");V=!1}if(z){if(W&&w.type!=="comment"&&w.type!=="newline")G(z,"TAB_AS_INDENT","Tabs are not allowed as indentation");z=null}switch(w.type){case"space":if(!X&&(q!=="doc-start"||Z?.type!=="flow-collection")&&w.source.includes("\t"))z=w;$=!0;break;case"comment":{if(!$)G(w,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let s=w.source.substring(1)||" ";if(!_)_=s;else _+=L+s;L="",W=!1;break}case"newline":if(W){if(_)_+=w.source;else if(!C||q!=="seq-item-ind")H=!0}else L+=w.source;if(W=!0,A=!0,B||D)P=w;$=!0;break;case"anchor":if(B)G(w,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(w.source.endsWith(":"))G(w.offset+w.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);B=w,N??(N=w.offset),W=!1,$=!1,V=!0;break;case"tag":{if(D)G(w,"MULTIPLE_TAGS","A node can have at most one tag");D=w,N??(N=w.offset),W=!1,$=!1,V=!0;break}case q:if(B||D)G(w,"BAD_PROP_ORDER",`Anchors and tags must be after the ${w.source} indicator`);if(C)G(w,"UNEXPECTED_TOKEN",`Unexpected ${w.source} in ${X??"collection"}`);C=w,W=q==="seq-item-ind"||q==="explicit-key-ind",$=!1;break;case"comma":if(X){if(K)G(w,"UNEXPECTED_TOKEN",`Unexpected , in ${X}`);K=w,W=!1,$=!1;break}default:G(w,"UNEXPECTED_TOKEN",`Unexpected ${w.type} token`),W=!1,$=!1}}let b=U[U.length-1],m=b?b.offset+b.source.length:Q;if(V&&Z&&Z.type!=="space"&&Z.type!=="newline"&&Z.type!=="comma"&&(Z.type!=="scalar"||Z.source!==""))G(Z.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(z&&(W&&z.indent<=Y||Z?.type==="block-map"||Z?.type==="block-seq"))G(z,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:K,found:C,spaceBefore:H,comment:_,hasNewline:A,anchor:B,tag:D,newlineAfterProp:P,end:m,start:N??m}}wL.resolveProps=ML});var w4=R((IL)=>{function xU(U){if(!U)return null;switch(U.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(U.source.includes(`
63
- `))return!0;if(U.end){for(let X of U.end)if(X.type==="newline")return!0}return!1;case"flow-collection":for(let X of U.items){for(let q of X.start)if(q.type==="newline")return!0;if(X.sep){for(let q of X.sep)if(q.type==="newline")return!0}if(xU(X.key)||xU(X.value))return!0}return!1;default:return!0}}IL.containsNewline=xU});var uU=R((SL)=>{var NL=w4();function CL(U,X,q){if(X?.type==="flow-collection"){let Z=X.end[0];if(Z.indent===U&&(Z.source==="]"||Z.source==="}")&&NL.containsNewline(X))q(Z,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}SL.flowIndentCheck=CL});var mU=R((bL)=>{var XQ=k();function jL(U,X,q){let{uniqueKeys:Z}=U.options;if(Z===!1)return!1;let Q=typeof Z==="function"?Z:(G,Y)=>G===Y||XQ.isScalar(G)&&XQ.isScalar(Y)&&G.value===Y.value;return X.some((G)=>Q(G.key,q))}bL.mapIncludes=jL});var YQ=R((hL)=>{var qQ=U1(),gL=q1(),ZQ=X6(),yL=w4(),QQ=uU(),kL=mU(),GQ="All mapping items must start at the same column";function vL({composeNode:U,composeEmptyNode:X},q,Z,Q,G){let J=new(G?.nodeClass??gL.YAMLMap)(q.schema);if(q.atRoot)q.atRoot=!1;let H=Z.offset,W=null;for(let $ of Z.items){let{start:_,key:L,sep:A,value:V}=$,z=ZQ.resolveProps(_,{indicator:"explicit-key-ind",next:L??A?.[0],offset:H,onError:Q,parentIndent:Z.indent,startOnNewline:!0}),B=!z.found;if(B){if(L){if(L.type==="block-seq")Q(H,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in L&&L.indent!==Z.indent)Q(H,"BAD_INDENT",GQ)}if(!z.anchor&&!z.tag&&!A){if(W=z.end,z.comment)if(J.comment)J.comment+=`
64
- `+z.comment;else J.comment=z.comment;continue}if(z.newlineAfterProp||yL.containsNewline(L))Q(L??_[_.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(z.found?.indent!==Z.indent)Q(H,"BAD_INDENT",GQ);q.atKey=!0;let D=z.end,P=L?U(q,L,z,Q):X(q,D,_,null,z,Q);if(q.schema.compat)QQ.flowIndentCheck(Z.indent,L,Q);if(q.atKey=!1,kL.mapIncludes(q,J.items,P))Q(D,"DUPLICATE_KEY","Map keys must be unique");let K=ZQ.resolveProps(A??[],{indicator:"map-value-ind",next:V,offset:P.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!L||L.type==="block-scalar"});if(H=K.end,K.found){if(B){if(V?.type==="block-map"&&!K.hasNewline)Q(H,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(q.options.strict&&z.start<K.found.offset-1024)Q(P.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let C=V?U(q,V,K,Q):X(q,H,A,null,K,Q);if(q.schema.compat)QQ.flowIndentCheck(Z.indent,V,Q);H=C.range[2];let N=new qQ.Pair(P,C);if(q.options.keepSourceTokens)N.srcToken=$;J.items.push(N)}else{if(B)Q(P.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(K.comment)if(P.comment)P.comment+=`
65
- `+K.comment;else P.comment=K.comment;let C=new qQ.Pair(P);if(q.options.keepSourceTokens)C.srcToken=$;J.items.push(C)}}if(W&&W<H)Q(W,"IMPOSSIBLE","Map comment with trailing content");return J.range=[Z.offset,H,W??H],J}hL.resolveBlockMap=vL});var JQ=R((dL)=>{var uL=Z1(),mL=X6(),pL=uU();function lL({composeNode:U,composeEmptyNode:X},q,Z,Q,G){let J=new(G?.nodeClass??uL.YAMLSeq)(q.schema);if(q.atRoot)q.atRoot=!1;if(q.atKey)q.atKey=!1;let H=Z.offset,W=null;for(let{start:$,value:_}of Z.items){let L=mL.resolveProps($,{indicator:"seq-item-ind",next:_,offset:H,onError:Q,parentIndent:Z.indent,startOnNewline:!0});if(!L.found)if(L.anchor||L.tag||_)if(_?.type==="block-seq")Q(L.end,"BAD_INDENT","All sequence items must start at the same column");else Q(H,"MISSING_CHAR","Sequence item without - indicator");else{if(W=L.end,L.comment)J.comment=L.comment;continue}let A=_?U(q,_,L,Q):X(q,L.end,$,null,L,Q);if(q.schema.compat)pL.flowIndentCheck(Z.indent,_,Q);H=A.range[2],J.items.push(A)}return J.range=[Z.offset,H,W??H],J}dL.resolveBlockSeq=lL});var U2=R((sL)=>{function iL(U,X,q,Z){let Q="";if(U){let G=!1,Y="";for(let J of U){let{source:H,type:W}=J;switch(W){case"space":G=!0;break;case"comment":{if(q&&!G)Z(J,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let $=H.substring(1)||" ";if(!Q)Q=$;else Q+=Y+$;Y="";break}case"newline":if(Q)Y+=H;G=!0;break;default:Z(J,"UNEXPECTED_TOKEN",`Unexpected ${W} at node end`)}X+=H.length}}return{comment:Q,offset:X}}sL.resolveEnd=iL});var _Q=R((qz)=>{var rL=k(),nL=U1(),HQ=q1(),aL=Z1(),tL=U2(),WQ=X6(),eL=w4(),Uz=mU(),pU="Block collections are not allowed within flow collections",lU=(U)=>U&&(U.type==="block-map"||U.type==="block-seq");function Xz({composeNode:U,composeEmptyNode:X},q,Z,Q,G){let Y=Z.start.source==="{",J=Y?"flow map":"flow sequence",W=new(G?.nodeClass??(Y?HQ.YAMLMap:aL.YAMLSeq))(q.schema);W.flow=!0;let $=q.atRoot;if($)q.atRoot=!1;if(q.atKey)q.atKey=!1;let _=Z.offset+Z.start.source.length;for(let B=0;B<Z.items.length;++B){let D=Z.items[B],{start:P,key:K,sep:C,value:N}=D,b=WQ.resolveProps(P,{flow:J,indicator:"explicit-key-ind",next:K??C?.[0],offset:_,onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(!b.found){if(!b.anchor&&!b.tag&&!C&&!N){if(B===0&&b.comma)Q(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${J}`);else if(B<Z.items.length-1)Q(b.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${J}`);if(b.comment)if(W.comment)W.comment+=`
66
- `+b.comment;else W.comment=b.comment;_=b.end;continue}if(!Y&&q.options.strict&&eL.containsNewline(K))Q(K,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(B===0){if(b.comma)Q(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${J}`)}else{if(!b.comma)Q(b.start,"MISSING_CHAR",`Missing , between ${J} items`);if(b.comment){let m="";U:for(let w of P)switch(w.type){case"comma":case"space":break;case"comment":m=w.source.substring(1);break U;default:break U}if(m){let w=W.items[W.items.length-1];if(rL.isPair(w))w=w.value??w.key;if(w.comment)w.comment+=`
67
- `+m;else w.comment=m;b.comment=b.comment.substring(m.length+1)}}}if(!Y&&!C&&!b.found){let m=N?U(q,N,b,Q):X(q,b.end,C,null,b,Q);if(W.items.push(m),_=m.range[2],lU(N))Q(m.range,"BLOCK_IN_FLOW",pU)}else{q.atKey=!0;let m=b.end,w=K?U(q,K,b,Q):X(q,m,P,null,b,Q);if(lU(K))Q(w.range,"BLOCK_IN_FLOW",pU);q.atKey=!1;let s=WQ.resolveProps(C??[],{flow:J,indicator:"map-value-ind",next:N,offset:w.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(s.found){if(!Y&&!b.found&&q.options.strict){if(C)for(let o of C){if(o===s.found)break;if(o.type==="newline"){Q(o,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(b.start<s.found.offset-1024)Q(s.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(N)if("source"in N&&N.source?.[0]===":")Q(N,"MISSING_CHAR",`Missing space after : in ${J}`);else Q(s.start,"MISSING_CHAR",`Missing , or : between ${J} items`);let p0=N?U(q,N,s,Q):s.found?X(q,s.end,C,null,s,Q):null;if(p0){if(lU(N))Q(p0.range,"BLOCK_IN_FLOW",pU)}else if(s.comment)if(w.comment)w.comment+=`
68
- `+s.comment;else w.comment=s.comment;let M1=new nL.Pair(w,p0);if(q.options.keepSourceTokens)M1.srcToken=D;if(Y){let o=W;if(Uz.mapIncludes(q,o.items,w))Q(m,"DUPLICATE_KEY","Map keys must be unique");o.items.push(M1)}else{let o=new HQ.YAMLMap(q.schema);o.flow=!0,o.items.push(M1);let _X=(p0??w).range;o.range=[w.range[0],_X[1],_X[2]],W.items.push(o)}_=p0?p0.range[2]:s.end}}let L=Y?"}":"]",[A,...V]=Z.end,z=_;if(A?.source===L)z=A.offset+A.source.length;else{let B=J[0].toUpperCase()+J.substring(1),D=$?`${B} must end with a ${L}`:`${B} in block collection must be sufficiently indented and end with a ${L}`;if(Q(_,$?"MISSING_CHAR":"BAD_INDENT",D),A&&A.source.length!==1)V.unshift(A)}if(V.length>0){let B=tL.resolveEnd(V,z,q.options.strict,Q);if(B.comment)if(W.comment)W.comment+=`
69
- `+B.comment;else W.comment=B.comment;W.range=[Z.offset,z,B.offset]}else W.range=[Z.offset,z,z];return W}qz.resolveFlowCollection=Xz});var $Q=R((Lz)=>{var Qz=k(),Gz=i(),Yz=q1(),Jz=Z1(),Hz=YQ(),Wz=JQ(),_z=_Q();function dU(U,X,q,Z,Q,G){let Y=q.type==="block-map"?Hz.resolveBlockMap(U,X,q,Z,G):q.type==="block-seq"?Wz.resolveBlockSeq(U,X,q,Z,G):_z.resolveFlowCollection(U,X,q,Z,G),J=Y.constructor;if(Q==="!"||Q===J.tagName)return Y.tag=J.tagName,Y;if(Q)Y.tag=Q;return Y}function $z(U,X,q,Z,Q){let G=Z.tag,Y=!G?null:X.directives.tagName(G.source,(L)=>Q(G,"TAG_RESOLVE_FAILED",L));if(q.type==="block-seq"){let{anchor:L,newlineAfterProp:A}=Z,V=L&&G?L.offset>G.offset?L:G:L??G;if(V&&(!A||A.offset<V.offset))Q(V,"MISSING_CHAR","Missing newline after block sequence props")}let J=q.type==="block-map"?"map":q.type==="block-seq"?"seq":q.start.source==="{"?"map":"seq";if(!G||!Y||Y==="!"||Y===Yz.YAMLMap.tagName&&J==="map"||Y===Jz.YAMLSeq.tagName&&J==="seq")return dU(U,X,q,Q,Y);let H=X.schema.tags.find((L)=>L.tag===Y&&L.collection===J);if(!H){let L=X.schema.knownTags[Y];if(L?.collection===J)X.schema.tags.push(Object.assign({},L,{default:!1})),H=L;else{if(L)Q(G,"BAD_COLLECTION_TYPE",`${L.tag} used for ${J} collection, but expects ${L.collection??"scalar"}`,!0);else Q(G,"TAG_RESOLVE_FAILED",`Unresolved tag: ${Y}`,!0);return dU(U,X,q,Q,Y)}}let W=dU(U,X,q,Q,Y,H),$=H.resolve?.(W,(L)=>Q(G,"TAG_RESOLVE_FAILED",L),X.options)??W,_=Qz.isNode($)?$:new Gz.Scalar($);if(_.range=W.range,_.tag=Y,H?.format)_.format=H.format;return _}Lz.composeCollection=$z});var iU=R((Bz)=>{var cU=i();function Fz(U,X,q){let Z=X.offset,Q=Az(X,U.options.strict,q);if(!Q)return{value:"",type:null,comment:"",range:[Z,Z,Z]};let G=Q.mode===">"?cU.Scalar.BLOCK_FOLDED:cU.Scalar.BLOCK_LITERAL,Y=X.source?Oz(X.source):[],J=Y.length;for(let z=Y.length-1;z>=0;--z){let B=Y[z][1];if(B===""||B==="\r")J=z;else break}if(J===0){let z=Q.chomp==="+"&&Y.length>0?`
62
+ `}};ML.YAMLError=M4;ML.YAMLParseError=UQ;ML.YAMLWarning=XQ;ML.prettifyError=DL});var X6=R((CL)=>{function NL(U,{flow:X,indicator:q,next:Z,offset:Q,onError:G,parentIndent:Y,startOnNewline:J}){let H=!1,W=J,$=J,_="",L="",A=!1,V=!1,z=null,B=null,D=null,P=null,K=null,C=null,N=null;for(let w of U){if(V){if(w.type!=="space"&&w.type!=="newline"&&w.type!=="comma")G(w.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");V=!1}if(z){if(W&&w.type!=="comment"&&w.type!=="newline")G(z,"TAB_AS_INDENT","Tabs are not allowed as indentation");z=null}switch(w.type){case"space":if(!X&&(q!=="doc-start"||Z?.type!=="flow-collection")&&w.source.includes("\t"))z=w;$=!0;break;case"comment":{if(!$)G(w,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let s=w.source.substring(1)||" ";if(!_)_=s;else _+=L+s;L="",W=!1;break}case"newline":if(W){if(_)_+=w.source;else if(!C||q!=="seq-item-ind")H=!0}else L+=w.source;if(W=!0,A=!0,B||D)P=w;$=!0;break;case"anchor":if(B)G(w,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(w.source.endsWith(":"))G(w.offset+w.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);B=w,N??(N=w.offset),W=!1,$=!1,V=!0;break;case"tag":{if(D)G(w,"MULTIPLE_TAGS","A node can have at most one tag");D=w,N??(N=w.offset),W=!1,$=!1,V=!0;break}case q:if(B||D)G(w,"BAD_PROP_ORDER",`Anchors and tags must be after the ${w.source} indicator`);if(C)G(w,"UNEXPECTED_TOKEN",`Unexpected ${w.source} in ${X??"collection"}`);C=w,W=q==="seq-item-ind"||q==="explicit-key-ind",$=!1;break;case"comma":if(X){if(K)G(w,"UNEXPECTED_TOKEN",`Unexpected , in ${X}`);K=w,W=!1,$=!1;break}default:G(w,"UNEXPECTED_TOKEN",`Unexpected ${w.type} token`),W=!1,$=!1}}let b=U[U.length-1],m=b?b.offset+b.source.length:Q;if(V&&Z&&Z.type!=="space"&&Z.type!=="newline"&&Z.type!=="comma"&&(Z.type!=="scalar"||Z.source!==""))G(Z.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(z&&(W&&z.indent<=Y||Z?.type==="block-map"||Z?.type==="block-seq"))G(z,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:K,found:C,spaceBefore:H,comment:_,hasNewline:A,anchor:B,tag:D,newlineAfterProp:P,end:m,start:N??m}}CL.resolveProps=NL});var w4=R((EL)=>{function xU(U){if(!U)return null;switch(U.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(U.source.includes(`
63
+ `))return!0;if(U.end){for(let X of U.end)if(X.type==="newline")return!0}return!1;case"flow-collection":for(let X of U.items){for(let q of X.start)if(q.type==="newline")return!0;if(X.sep){for(let q of X.sep)if(q.type==="newline")return!0}if(xU(X.key)||xU(X.value))return!0}return!1;default:return!0}}EL.containsNewline=xU});var uU=R((gL)=>{var bL=w4();function fL(U,X,q){if(X?.type==="flow-collection"){let Z=X.end[0];if(Z.indent===U&&(Z.source==="]"||Z.source==="}")&&bL.containsNewline(X))q(Z,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}gL.flowIndentCheck=fL});var mU=R((vL)=>{var qQ=k();function kL(U,X,q){let{uniqueKeys:Z}=U.options;if(Z===!1)return!1;let Q=typeof Z==="function"?Z:(G,Y)=>G===Y||qQ.isScalar(G)&&qQ.isScalar(Y)&&G.value===Y.value;return X.some((G)=>Q(G.key,q))}vL.mapIncludes=kL});var JQ=R((lL)=>{var ZQ=U1(),xL=q1(),QQ=X6(),uL=w4(),GQ=uU(),mL=mU(),YQ="All mapping items must start at the same column";function pL({composeNode:U,composeEmptyNode:X},q,Z,Q,G){let J=new(G?.nodeClass??xL.YAMLMap)(q.schema);if(q.atRoot)q.atRoot=!1;let H=Z.offset,W=null;for(let $ of Z.items){let{start:_,key:L,sep:A,value:V}=$,z=QQ.resolveProps(_,{indicator:"explicit-key-ind",next:L??A?.[0],offset:H,onError:Q,parentIndent:Z.indent,startOnNewline:!0}),B=!z.found;if(B){if(L){if(L.type==="block-seq")Q(H,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in L&&L.indent!==Z.indent)Q(H,"BAD_INDENT",YQ)}if(!z.anchor&&!z.tag&&!A){if(W=z.end,z.comment)if(J.comment)J.comment+=`
64
+ `+z.comment;else J.comment=z.comment;continue}if(z.newlineAfterProp||uL.containsNewline(L))Q(L??_[_.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(z.found?.indent!==Z.indent)Q(H,"BAD_INDENT",YQ);q.atKey=!0;let D=z.end,P=L?U(q,L,z,Q):X(q,D,_,null,z,Q);if(q.schema.compat)GQ.flowIndentCheck(Z.indent,L,Q);if(q.atKey=!1,mL.mapIncludes(q,J.items,P))Q(D,"DUPLICATE_KEY","Map keys must be unique");let K=QQ.resolveProps(A??[],{indicator:"map-value-ind",next:V,offset:P.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!L||L.type==="block-scalar"});if(H=K.end,K.found){if(B){if(V?.type==="block-map"&&!K.hasNewline)Q(H,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(q.options.strict&&z.start<K.found.offset-1024)Q(P.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let C=V?U(q,V,K,Q):X(q,H,A,null,K,Q);if(q.schema.compat)GQ.flowIndentCheck(Z.indent,V,Q);H=C.range[2];let N=new ZQ.Pair(P,C);if(q.options.keepSourceTokens)N.srcToken=$;J.items.push(N)}else{if(B)Q(P.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(K.comment)if(P.comment)P.comment+=`
65
+ `+K.comment;else P.comment=K.comment;let C=new ZQ.Pair(P);if(q.options.keepSourceTokens)C.srcToken=$;J.items.push(C)}}if(W&&W<H)Q(W,"IMPOSSIBLE","Map comment with trailing content");return J.range=[Z.offset,H,W??H],J}lL.resolveBlockMap=pL});var HQ=R((rL)=>{var cL=Z1(),iL=X6(),sL=uU();function oL({composeNode:U,composeEmptyNode:X},q,Z,Q,G){let J=new(G?.nodeClass??cL.YAMLSeq)(q.schema);if(q.atRoot)q.atRoot=!1;if(q.atKey)q.atKey=!1;let H=Z.offset,W=null;for(let{start:$,value:_}of Z.items){let L=iL.resolveProps($,{indicator:"seq-item-ind",next:_,offset:H,onError:Q,parentIndent:Z.indent,startOnNewline:!0});if(!L.found)if(L.anchor||L.tag||_)if(_?.type==="block-seq")Q(L.end,"BAD_INDENT","All sequence items must start at the same column");else Q(H,"MISSING_CHAR","Sequence item without - indicator");else{if(W=L.end,L.comment)J.comment=L.comment;continue}let A=_?U(q,_,L,Q):X(q,L.end,$,null,L,Q);if(q.schema.compat)sL.flowIndentCheck(Z.indent,_,Q);H=A.range[2],J.items.push(A)}return J.range=[Z.offset,H,W??H],J}rL.resolveBlockSeq=oL});var U2=R((tL)=>{function aL(U,X,q,Z){let Q="";if(U){let G=!1,Y="";for(let J of U){let{source:H,type:W}=J;switch(W){case"space":G=!0;break;case"comment":{if(q&&!G)Z(J,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let $=H.substring(1)||" ";if(!Q)Q=$;else Q+=Y+$;Y="";break}case"newline":if(Q)Y+=H;G=!0;break;default:Z(J,"UNEXPECTED_TOKEN",`Unexpected ${W} at node end`)}X+=H.length}}return{comment:Q,offset:X}}tL.resolveEnd=aL});var $Q=R((Jz)=>{var Uz=k(),Xz=U1(),WQ=q1(),qz=Z1(),Zz=U2(),_Q=X6(),Qz=w4(),Gz=mU(),pU="Block collections are not allowed within flow collections",lU=(U)=>U&&(U.type==="block-map"||U.type==="block-seq");function Yz({composeNode:U,composeEmptyNode:X},q,Z,Q,G){let Y=Z.start.source==="{",J=Y?"flow map":"flow sequence",W=new(G?.nodeClass??(Y?WQ.YAMLMap:qz.YAMLSeq))(q.schema);W.flow=!0;let $=q.atRoot;if($)q.atRoot=!1;if(q.atKey)q.atKey=!1;let _=Z.offset+Z.start.source.length;for(let B=0;B<Z.items.length;++B){let D=Z.items[B],{start:P,key:K,sep:C,value:N}=D,b=_Q.resolveProps(P,{flow:J,indicator:"explicit-key-ind",next:K??C?.[0],offset:_,onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(!b.found){if(!b.anchor&&!b.tag&&!C&&!N){if(B===0&&b.comma)Q(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${J}`);else if(B<Z.items.length-1)Q(b.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${J}`);if(b.comment)if(W.comment)W.comment+=`
66
+ `+b.comment;else W.comment=b.comment;_=b.end;continue}if(!Y&&q.options.strict&&Qz.containsNewline(K))Q(K,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(B===0){if(b.comma)Q(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${J}`)}else{if(!b.comma)Q(b.start,"MISSING_CHAR",`Missing , between ${J} items`);if(b.comment){let m="";U:for(let w of P)switch(w.type){case"comma":case"space":break;case"comment":m=w.source.substring(1);break U;default:break U}if(m){let w=W.items[W.items.length-1];if(Uz.isPair(w))w=w.value??w.key;if(w.comment)w.comment+=`
67
+ `+m;else w.comment=m;b.comment=b.comment.substring(m.length+1)}}}if(!Y&&!C&&!b.found){let m=N?U(q,N,b,Q):X(q,b.end,C,null,b,Q);if(W.items.push(m),_=m.range[2],lU(N))Q(m.range,"BLOCK_IN_FLOW",pU)}else{q.atKey=!0;let m=b.end,w=K?U(q,K,b,Q):X(q,m,P,null,b,Q);if(lU(K))Q(w.range,"BLOCK_IN_FLOW",pU);q.atKey=!1;let s=_Q.resolveProps(C??[],{flow:J,indicator:"map-value-ind",next:N,offset:w.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(s.found){if(!Y&&!b.found&&q.options.strict){if(C)for(let o of C){if(o===s.found)break;if(o.type==="newline"){Q(o,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(b.start<s.found.offset-1024)Q(s.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(N)if("source"in N&&N.source?.[0]===":")Q(N,"MISSING_CHAR",`Missing space after : in ${J}`);else Q(s.start,"MISSING_CHAR",`Missing , or : between ${J} items`);let p0=N?U(q,N,s,Q):s.found?X(q,s.end,C,null,s,Q):null;if(p0){if(lU(N))Q(p0.range,"BLOCK_IN_FLOW",pU)}else if(s.comment)if(w.comment)w.comment+=`
68
+ `+s.comment;else w.comment=s.comment;let M1=new Xz.Pair(w,p0);if(q.options.keepSourceTokens)M1.srcToken=D;if(Y){let o=W;if(Gz.mapIncludes(q,o.items,w))Q(m,"DUPLICATE_KEY","Map keys must be unique");o.items.push(M1)}else{let o=new WQ.YAMLMap(q.schema);o.flow=!0,o.items.push(M1);let _X=(p0??w).range;o.range=[w.range[0],_X[1],_X[2]],W.items.push(o)}_=p0?p0.range[2]:s.end}}let L=Y?"}":"]",[A,...V]=Z.end,z=_;if(A?.source===L)z=A.offset+A.source.length;else{let B=J[0].toUpperCase()+J.substring(1),D=$?`${B} must end with a ${L}`:`${B} in block collection must be sufficiently indented and end with a ${L}`;if(Q(_,$?"MISSING_CHAR":"BAD_INDENT",D),A&&A.source.length!==1)V.unshift(A)}if(V.length>0){let B=Zz.resolveEnd(V,z,q.options.strict,Q);if(B.comment)if(W.comment)W.comment+=`
69
+ `+B.comment;else W.comment=B.comment;W.range=[Z.offset,z,B.offset]}else W.range=[Z.offset,z,z];return W}Jz.resolveFlowCollection=Yz});var LQ=R((Bz)=>{var Wz=k(),_z=i(),$z=q1(),Lz=Z1(),zz=JQ(),Fz=HQ(),Az=$Q();function dU(U,X,q,Z,Q,G){let Y=q.type==="block-map"?zz.resolveBlockMap(U,X,q,Z,G):q.type==="block-seq"?Fz.resolveBlockSeq(U,X,q,Z,G):Az.resolveFlowCollection(U,X,q,Z,G),J=Y.constructor;if(Q==="!"||Q===J.tagName)return Y.tag=J.tagName,Y;if(Q)Y.tag=Q;return Y}function Oz(U,X,q,Z,Q){let G=Z.tag,Y=!G?null:X.directives.tagName(G.source,(L)=>Q(G,"TAG_RESOLVE_FAILED",L));if(q.type==="block-seq"){let{anchor:L,newlineAfterProp:A}=Z,V=L&&G?L.offset>G.offset?L:G:L??G;if(V&&(!A||A.offset<V.offset))Q(V,"MISSING_CHAR","Missing newline after block sequence props")}let J=q.type==="block-map"?"map":q.type==="block-seq"?"seq":q.start.source==="{"?"map":"seq";if(!G||!Y||Y==="!"||Y===$z.YAMLMap.tagName&&J==="map"||Y===Lz.YAMLSeq.tagName&&J==="seq")return dU(U,X,q,Q,Y);let H=X.schema.tags.find((L)=>L.tag===Y&&L.collection===J);if(!H){let L=X.schema.knownTags[Y];if(L?.collection===J)X.schema.tags.push(Object.assign({},L,{default:!1})),H=L;else{if(L)Q(G,"BAD_COLLECTION_TYPE",`${L.tag} used for ${J} collection, but expects ${L.collection??"scalar"}`,!0);else Q(G,"TAG_RESOLVE_FAILED",`Unresolved tag: ${Y}`,!0);return dU(U,X,q,Q,Y)}}let W=dU(U,X,q,Q,Y,H),$=H.resolve?.(W,(L)=>Q(G,"TAG_RESOLVE_FAILED",L),X.options)??W,_=Wz.isNode($)?$:new _z.Scalar($);if(_.range=W.range,_.tag=Y,H?.format)_.format=H.format;return _}Bz.composeCollection=Oz});var iU=R((Mz)=>{var cU=i();function Vz(U,X,q){let Z=X.offset,Q=Rz(X,U.options.strict,q);if(!Q)return{value:"",type:null,comment:"",range:[Z,Z,Z]};let G=Q.mode===">"?cU.Scalar.BLOCK_FOLDED:cU.Scalar.BLOCK_LITERAL,Y=X.source?Dz(X.source):[],J=Y.length;for(let z=Y.length-1;z>=0;--z){let B=Y[z][1];if(B===""||B==="\r")J=z;else break}if(J===0){let z=Q.chomp==="+"&&Y.length>0?`
70
70
  `.repeat(Math.max(1,Y.length-1)):"",B=Z+Q.length;if(X.source)B+=X.source.length;return{value:z,type:G,comment:Q.comment,range:[Z,B,B]}}let H=X.indent+Q.indent,W=X.offset+Q.length,$=0;for(let z=0;z<J;++z){let[B,D]=Y[z];if(D===""||D==="\r"){if(Q.indent===0&&B.length>H)H=B.length}else{if(B.length<H)q(W+B.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(Q.indent===0)H=B.length;if($=z,H===0&&!U.atRoot)q(W,"BAD_INDENT","Block scalar values in collections must be indented");break}W+=B.length+D.length+1}for(let z=Y.length-1;z>=J;--z)if(Y[z][0].length>H)J=z+1;let _="",L="",A=!1;for(let z=0;z<$;++z)_+=Y[z][0].slice(H)+`
71
71
  `;for(let z=$;z<J;++z){let[B,D]=Y[z];W+=B.length+D.length+1;let P=D[D.length-1]==="\r";if(P)D=D.slice(0,-1);if(D&&B.length<H){let C=`Block scalar lines must not be less indented than their ${Q.indent?"explicit indentation indicator":"first line"}`;q(W-D.length-(P?2:1),"BAD_INDENT",C),B=""}if(G===cU.Scalar.BLOCK_LITERAL)_+=L+B.slice(H)+D,L=`
72
72
  `;else if(B.length>H||D[0]==="\t"){if(L===" ")L=`
@@ -81,41 +81,41 @@ ${W}
81
81
  `+Y[z][0].slice(H);if(_[_.length-1]!==`
82
82
  `)_+=`
83
83
  `;break;default:_+=`
84
- `}let V=Z+Q.length+X.source.length;return{value:_,type:G,comment:Q.comment,range:[Z,V,V]}}function Az({offset:U,props:X},q,Z){if(X[0].type!=="block-scalar-header")return Z(X[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:Q}=X[0],G=Q[0],Y=0,J="",H=-1;for(let L=1;L<Q.length;++L){let A=Q[L];if(!J&&(A==="-"||A==="+"))J=A;else{let V=Number(A);if(!Y&&V)Y=V;else if(H===-1)H=U+L}}if(H!==-1)Z(H,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${Q}`);let W=!1,$="",_=Q.length;for(let L=1;L<X.length;++L){let A=X[L];switch(A.type){case"space":W=!0;case"newline":_+=A.source.length;break;case"comment":if(q&&!W)Z(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");_+=A.source.length,$=A.source.substring(1);break;case"error":Z(A,"UNEXPECTED_TOKEN",A.message),_+=A.source.length;break;default:{let V=`Unexpected token in block scalar header: ${A.type}`;Z(A,"UNEXPECTED_TOKEN",V);let z=A.source;if(z&&typeof z==="string")_+=z.length}}}return{mode:G,indent:Y,chomp:J,comment:$,length:_}}function Oz(U){let X=U.split(/\n( *)/),q=X[0],Z=q.match(/^( *)/),G=[Z?.[1]?[Z[1],q.slice(Z[1].length)]:["",q]];for(let Y=1;Y<X.length;Y+=2)G.push([X[Y],X[Y+1]]);return G}Bz.resolveBlockScalar=Fz});var oU=R((Nz)=>{var sU=i(),Vz=U2();function Rz(U,X,q){let{offset:Z,type:Q,source:G,end:Y}=U,J,H,W=(L,A,V)=>q(Z+L,A,V);switch(Q){case"scalar":J=sU.Scalar.PLAIN,H=Dz(G,W);break;case"single-quoted-scalar":J=sU.Scalar.QUOTE_SINGLE,H=Mz(G,W);break;case"double-quoted-scalar":J=sU.Scalar.QUOTE_DOUBLE,H=wz(G,W);break;default:return q(U,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${Q}`),{value:"",type:null,comment:"",range:[Z,Z+G.length,Z+G.length]}}let $=Z+G.length,_=Vz.resolveEnd(Y,$,X,q);return{value:H,type:J,comment:_.comment,range:[Z,$,_.offset]}}function Dz(U,X){let q="";switch(U[0]){case"\t":q="a tab character";break;case",":q="flow indicator character ,";break;case"%":q="directive indicator character %";break;case"|":case">":{q=`block scalar indicator ${U[0]}`;break}case"@":case"`":{q=`reserved character ${U[0]}`;break}}if(q)X(0,"BAD_SCALAR_START",`Plain value cannot start with ${q}`);return LQ(U)}function Mz(U,X){if(U[U.length-1]!=="'"||U.length===1)X(U.length,"MISSING_CHAR","Missing closing 'quote");return LQ(U.slice(1,-1)).replace(/''/g,"'")}function LQ(U){let X,q;try{X=new RegExp(`(.*?)(?<![ ])[ ]*\r?
84
+ `}let V=Z+Q.length+X.source.length;return{value:_,type:G,comment:Q.comment,range:[Z,V,V]}}function Rz({offset:U,props:X},q,Z){if(X[0].type!=="block-scalar-header")return Z(X[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:Q}=X[0],G=Q[0],Y=0,J="",H=-1;for(let L=1;L<Q.length;++L){let A=Q[L];if(!J&&(A==="-"||A==="+"))J=A;else{let V=Number(A);if(!Y&&V)Y=V;else if(H===-1)H=U+L}}if(H!==-1)Z(H,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${Q}`);let W=!1,$="",_=Q.length;for(let L=1;L<X.length;++L){let A=X[L];switch(A.type){case"space":W=!0;case"newline":_+=A.source.length;break;case"comment":if(q&&!W)Z(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");_+=A.source.length,$=A.source.substring(1);break;case"error":Z(A,"UNEXPECTED_TOKEN",A.message),_+=A.source.length;break;default:{let V=`Unexpected token in block scalar header: ${A.type}`;Z(A,"UNEXPECTED_TOKEN",V);let z=A.source;if(z&&typeof z==="string")_+=z.length}}}return{mode:G,indent:Y,chomp:J,comment:$,length:_}}function Dz(U){let X=U.split(/\n( *)/),q=X[0],Z=q.match(/^( *)/),G=[Z?.[1]?[Z[1],q.slice(Z[1].length)]:["",q]];for(let Y=1;Y<X.length;Y+=2)G.push([X[Y],X[Y+1]]);return G}Mz.resolveBlockScalar=Vz});var oU=R((bz)=>{var sU=i(),Pz=U2();function Iz(U,X,q){let{offset:Z,type:Q,source:G,end:Y}=U,J,H,W=(L,A,V)=>q(Z+L,A,V);switch(Q){case"scalar":J=sU.Scalar.PLAIN,H=Kz(G,W);break;case"single-quoted-scalar":J=sU.Scalar.QUOTE_SINGLE,H=Nz(G,W);break;case"double-quoted-scalar":J=sU.Scalar.QUOTE_DOUBLE,H=Cz(G,W);break;default:return q(U,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${Q}`),{value:"",type:null,comment:"",range:[Z,Z+G.length,Z+G.length]}}let $=Z+G.length,_=Pz.resolveEnd(Y,$,X,q);return{value:H,type:J,comment:_.comment,range:[Z,$,_.offset]}}function Kz(U,X){let q="";switch(U[0]){case"\t":q="a tab character";break;case",":q="flow indicator character ,";break;case"%":q="directive indicator character %";break;case"|":case">":{q=`block scalar indicator ${U[0]}`;break}case"@":case"`":{q=`reserved character ${U[0]}`;break}}if(q)X(0,"BAD_SCALAR_START",`Plain value cannot start with ${q}`);return zQ(U)}function Nz(U,X){if(U[U.length-1]!=="'"||U.length===1)X(U.length,"MISSING_CHAR","Missing closing 'quote");return zQ(U.slice(1,-1)).replace(/''/g,"'")}function zQ(U){let X,q;try{X=new RegExp(`(.*?)(?<![ ])[ ]*\r?
85
85
  `,"sy"),q=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
86
86
  `,"sy")}catch{X=/(.*?)[ \t]*\r?\n/sy,q=/[ \t]*(.*?)[ \t]*\r?\n/sy}let Z=X.exec(U);if(!Z)return U;let Q=Z[1],G=" ",Y=X.lastIndex;q.lastIndex=Y;while(Z=q.exec(U)){if(Z[1]==="")if(G===`
87
87
  `)Q+=G;else G=`
88
- `;else Q+=G+Z[1],G=" ";Y=q.lastIndex}let J=/[ \t]*(.*)/sy;return J.lastIndex=Y,Z=J.exec(U),Q+G+(Z?.[1]??"")}function wz(U,X){let q="";for(let Z=1;Z<U.length-1;++Z){let Q=U[Z];if(Q==="\r"&&U[Z+1]===`
88
+ `;else Q+=G+Z[1],G=" ";Y=q.lastIndex}let J=/[ \t]*(.*)/sy;return J.lastIndex=Y,Z=J.exec(U),Q+G+(Z?.[1]??"")}function Cz(U,X){let q="";for(let Z=1;Z<U.length-1;++Z){let Q=U[Z];if(Q==="\r"&&U[Z+1]===`
89
89
  `)continue;if(Q===`
90
- `){let{fold:G,offset:Y}=Pz(U,Z);q+=G,Z=Y}else if(Q==="\\"){let G=U[++Z],Y=Iz[G];if(Y)q+=Y;else if(G===`
90
+ `){let{fold:G,offset:Y}=Sz(U,Z);q+=G,Z=Y}else if(Q==="\\"){let G=U[++Z],Y=Ez[G];if(Y)q+=Y;else if(G===`
91
91
  `){G=U[Z+1];while(G===" "||G==="\t")G=U[++Z+1]}else if(G==="\r"&&U[Z+1]===`
92
- `){G=U[++Z+1];while(G===" "||G==="\t")G=U[++Z+1]}else if(G==="x"||G==="u"||G==="U"){let J={x:2,u:4,U:8}[G];q+=Kz(U,Z+1,J,X),Z+=J}else{let J=U.substr(Z-1,2);X(Z-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${J}`),q+=J}}else if(Q===" "||Q==="\t"){let G=Z,Y=U[Z+1];while(Y===" "||Y==="\t")Y=U[++Z+1];if(Y!==`
92
+ `){G=U[++Z+1];while(G===" "||G==="\t")G=U[++Z+1]}else if(G==="x"||G==="u"||G==="U"){let J={x:2,u:4,U:8}[G];q+=jz(U,Z+1,J,X),Z+=J}else{let J=U.substr(Z-1,2);X(Z-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${J}`),q+=J}}else if(Q===" "||Q==="\t"){let G=Z,Y=U[Z+1];while(Y===" "||Y==="\t")Y=U[++Z+1];if(Y!==`
93
93
  `&&!(Y==="\r"&&U[Z+2]===`
94
- `))q+=Z>G?U.slice(G,Z+1):Q}else q+=Q}if(U[U.length-1]!=='"'||U.length===1)X(U.length,"MISSING_CHAR",'Missing closing "quote');return q}function Pz(U,X){let q="",Z=U[X+1];while(Z===" "||Z==="\t"||Z===`
94
+ `))q+=Z>G?U.slice(G,Z+1):Q}else q+=Q}if(U[U.length-1]!=='"'||U.length===1)X(U.length,"MISSING_CHAR",'Missing closing "quote');return q}function Sz(U,X){let q="",Z=U[X+1];while(Z===" "||Z==="\t"||Z===`
95
95
  `||Z==="\r"){if(Z==="\r"&&U[X+2]!==`
96
96
  `)break;if(Z===`
97
97
  `)q+=`
98
- `;X+=1,Z=U[X+1]}if(!q)q=" ";return{fold:q,offset:X}}var Iz={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
- `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Kz(U,X,q,Z){let Q=U.substr(X,q),Y=Q.length===q&&/^[0-9a-fA-F]+$/.test(Q)?parseInt(Q,16):NaN;if(isNaN(Y)){let J=U.substr(X-2,q+2);return Z(X-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${J}`),J}return String.fromCodePoint(Y)}Nz.resolveFlowScalar=Rz});var FQ=R((gz)=>{var V1=k(),zQ=i(),Sz=iU(),Ez=oU();function jz(U,X,q,Z){let{value:Q,type:G,comment:Y,range:J}=X.type==="block-scalar"?Sz.resolveBlockScalar(U,X,Z):Ez.resolveFlowScalar(X,U.options.strict,Z),H=q?U.directives.tagName(q.source,(_)=>Z(q,"TAG_RESOLVE_FAILED",_)):null,W;if(U.options.stringKeys&&U.atKey)W=U.schema[V1.SCALAR];else if(H)W=bz(U.schema,Q,H,q,Z);else if(X.type==="scalar")W=fz(U,Q,X,Z);else W=U.schema[V1.SCALAR];let $;try{let _=W.resolve(Q,(L)=>Z(q??X,"TAG_RESOLVE_FAILED",L),U.options);$=V1.isScalar(_)?_:new zQ.Scalar(_)}catch(_){let L=_ instanceof Error?_.message:String(_);Z(q??X,"TAG_RESOLVE_FAILED",L),$=new zQ.Scalar(Q)}if($.range=J,$.source=Q,G)$.type=G;if(H)$.tag=H;if(W.format)$.format=W.format;if(Y)$.comment=Y;return $}function bz(U,X,q,Z,Q){if(q==="!")return U[V1.SCALAR];let G=[];for(let J of U.tags)if(!J.collection&&J.tag===q)if(J.default&&J.test)G.push(J);else return J;for(let J of G)if(J.test?.test(X))return J;let Y=U.knownTags[q];if(Y&&!Y.collection)return U.tags.push(Object.assign({},Y,{default:!1,test:void 0})),Y;return Q(Z,"TAG_RESOLVE_FAILED",`Unresolved tag: ${q}`,q!=="tag:yaml.org,2002:str"),U[V1.SCALAR]}function fz({atKey:U,directives:X,schema:q},Z,Q,G){let Y=q.tags.find((J)=>(J.default===!0||U&&J.default==="key")&&J.test?.test(Z))||q[V1.SCALAR];if(q.compat){let J=q.compat.find((H)=>H.default&&H.test?.test(Z))??q[V1.SCALAR];if(Y.tag!==J.tag){let H=X.tagString(Y.tag),W=X.tagString(J.tag),$=`Value may be parsed as either ${H} or ${W}`;G(Q,"TAG_RESOLVE_FAILED",$,!0)}}return Y}gz.composeScalar=jz});var AQ=R((vz)=>{function kz(U,X,q){if(X){q??(q=X.length);for(let Z=q-1;Z>=0;--Z){let Q=X[Z];switch(Q.type){case"space":case"comment":case"newline":U-=Q.source.length;continue}Q=X[++Z];while(Q?.type==="space")U+=Q.source.length,Q=X[++Z];break}}return U}vz.emptyScalarPosition=kz});var TQ=R((iz)=>{var xz=h2(),uz=k(),mz=$Q(),OQ=FQ(),pz=U2(),lz=AQ(),dz={composeNode:BQ,composeEmptyNode:rU};function BQ(U,X,q,Z){let Q=U.atKey,{spaceBefore:G,comment:Y,anchor:J,tag:H}=q,W,$=!0;switch(X.type){case"alias":if(W=cz(U,X,Z),J||H)Z(X,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(W=OQ.composeScalar(U,X,H,Z),J)W.anchor=J.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(W=mz.composeCollection(dz,U,X,q,Z),J)W.anchor=J.source.substring(1);break;default:{let _=X.type==="error"?X.message:`Unsupported token (type: ${X.type})`;Z(X,"UNEXPECTED_TOKEN",_),W=rU(U,X.offset,void 0,null,q,Z),$=!1}}if(J&&W.anchor==="")Z(J,"BAD_ALIAS","Anchor cannot be an empty string");if(Q&&U.options.stringKeys&&(!uz.isScalar(W)||typeof W.value!=="string"||W.tag&&W.tag!=="tag:yaml.org,2002:str"))Z(H??X,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(G)W.spaceBefore=!0;if(Y)if(X.type==="scalar"&&X.source==="")W.comment=Y;else W.commentBefore=Y;if(U.options.keepSourceTokens&&$)W.srcToken=X;return W}function rU(U,X,q,Z,{spaceBefore:Q,comment:G,anchor:Y,tag:J,end:H},W){let $={type:"scalar",offset:lz.emptyScalarPosition(X,q,Z),indent:-1,source:""},_=OQ.composeScalar(U,$,J,W);if(Y){if(_.anchor=Y.source.substring(1),_.anchor==="")W(Y,"BAD_ALIAS","Anchor cannot be an empty string")}if(Q)_.spaceBefore=!0;if(G)_.comment=G,_.range[2]=H;return _}function cz({options:U},{offset:X,source:q,end:Z},Q){let G=new xz.Alias(q.substring(1));if(G.source==="")Q(X,"BAD_ALIAS","Alias cannot be an empty string");if(G.source.endsWith(":"))Q(X+q.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let Y=X+q.length,J=pz.resolveEnd(Z,Y,U.strict,Q);if(G.range=[X,Y,J.offset],J.comment)G.comment=J.comment;return G}iz.composeEmptyNode=rU;iz.composeNode=BQ});var RQ=R((ez)=>{var rz=e2(),VQ=TQ(),nz=U2(),az=X6();function tz(U,X,{offset:q,start:Z,value:Q,end:G},Y){let J=Object.assign({_directives:X},U),H=new rz.Document(void 0,J),W={atKey:!1,atRoot:!0,directives:H.directives,options:H.options,schema:H.schema},$=az.resolveProps(Z,{indicator:"doc-start",next:Q??G?.[0],offset:q,onError:Y,parentIndent:0,startOnNewline:!0});if($.found){if(H.directives.docStart=!0,Q&&(Q.type==="block-map"||Q.type==="block-seq")&&!$.hasNewline)Y($.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}H.contents=Q?VQ.composeNode(W,Q,$,Y):VQ.composeEmptyNode(W,$.end,Z,null,$,Y);let _=H.contents.range[2],L=nz.resolveEnd(G,_,!1,Y);if(L.comment)H.comment=L.comment;return H.range=[q,_,L.offset],H}ez.composeDoc=tz});var nU=R((YF)=>{var XF=w1("process"),qF=UU(),ZF=e2(),q6=U6(),DQ=k(),QF=RQ(),GF=U2();function Z6(U){if(typeof U==="number")return[U,U+1];if(Array.isArray(U))return U.length===2?U:[U[0],U[1]];let{offset:X,source:q}=U;return[X,X+(typeof q==="string"?q.length:1)]}function MQ(U){let X="",q=!1,Z=!1;for(let Q=0;Q<U.length;++Q){let G=U[Q];switch(G[0]){case"#":X+=(X===""?"":Z?`
98
+ `;X+=1,Z=U[X+1]}if(!q)q=" ";return{fold:q,offset:X}}var Ez={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
+ `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function jz(U,X,q,Z){let Q=U.substr(X,q),Y=Q.length===q&&/^[0-9a-fA-F]+$/.test(Q)?parseInt(Q,16):NaN;if(isNaN(Y)){let J=U.substr(X-2,q+2);return Z(X-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${J}`),J}return String.fromCodePoint(Y)}bz.resolveFlowScalar=Iz});var AQ=R((xz)=>{var V1=k(),FQ=i(),gz=iU(),yz=oU();function kz(U,X,q,Z){let{value:Q,type:G,comment:Y,range:J}=X.type==="block-scalar"?gz.resolveBlockScalar(U,X,Z):yz.resolveFlowScalar(X,U.options.strict,Z),H=q?U.directives.tagName(q.source,(_)=>Z(q,"TAG_RESOLVE_FAILED",_)):null,W;if(U.options.stringKeys&&U.atKey)W=U.schema[V1.SCALAR];else if(H)W=vz(U.schema,Q,H,q,Z);else if(X.type==="scalar")W=hz(U,Q,X,Z);else W=U.schema[V1.SCALAR];let $;try{let _=W.resolve(Q,(L)=>Z(q??X,"TAG_RESOLVE_FAILED",L),U.options);$=V1.isScalar(_)?_:new FQ.Scalar(_)}catch(_){let L=_ instanceof Error?_.message:String(_);Z(q??X,"TAG_RESOLVE_FAILED",L),$=new FQ.Scalar(Q)}if($.range=J,$.source=Q,G)$.type=G;if(H)$.tag=H;if(W.format)$.format=W.format;if(Y)$.comment=Y;return $}function vz(U,X,q,Z,Q){if(q==="!")return U[V1.SCALAR];let G=[];for(let J of U.tags)if(!J.collection&&J.tag===q)if(J.default&&J.test)G.push(J);else return J;for(let J of G)if(J.test?.test(X))return J;let Y=U.knownTags[q];if(Y&&!Y.collection)return U.tags.push(Object.assign({},Y,{default:!1,test:void 0})),Y;return Q(Z,"TAG_RESOLVE_FAILED",`Unresolved tag: ${q}`,q!=="tag:yaml.org,2002:str"),U[V1.SCALAR]}function hz({atKey:U,directives:X,schema:q},Z,Q,G){let Y=q.tags.find((J)=>(J.default===!0||U&&J.default==="key")&&J.test?.test(Z))||q[V1.SCALAR];if(q.compat){let J=q.compat.find((H)=>H.default&&H.test?.test(Z))??q[V1.SCALAR];if(Y.tag!==J.tag){let H=X.tagString(Y.tag),W=X.tagString(J.tag),$=`Value may be parsed as either ${H} or ${W}`;G(Q,"TAG_RESOLVE_FAILED",$,!0)}}return Y}xz.composeScalar=kz});var OQ=R((pz)=>{function mz(U,X,q){if(X){q??(q=X.length);for(let Z=q-1;Z>=0;--Z){let Q=X[Z];switch(Q.type){case"space":case"comment":case"newline":U-=Q.source.length;continue}Q=X[++Z];while(Q?.type==="space")U+=Q.source.length,Q=X[++Z];break}}return U}pz.emptyScalarPosition=mz});var VQ=R((az)=>{var dz=h2(),cz=k(),iz=LQ(),BQ=AQ(),sz=U2(),oz=OQ(),rz={composeNode:TQ,composeEmptyNode:rU};function TQ(U,X,q,Z){let Q=U.atKey,{spaceBefore:G,comment:Y,anchor:J,tag:H}=q,W,$=!0;switch(X.type){case"alias":if(W=nz(U,X,Z),J||H)Z(X,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(W=BQ.composeScalar(U,X,H,Z),J)W.anchor=J.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(W=iz.composeCollection(rz,U,X,q,Z),J)W.anchor=J.source.substring(1);break;default:{let _=X.type==="error"?X.message:`Unsupported token (type: ${X.type})`;Z(X,"UNEXPECTED_TOKEN",_),W=rU(U,X.offset,void 0,null,q,Z),$=!1}}if(J&&W.anchor==="")Z(J,"BAD_ALIAS","Anchor cannot be an empty string");if(Q&&U.options.stringKeys&&(!cz.isScalar(W)||typeof W.value!=="string"||W.tag&&W.tag!=="tag:yaml.org,2002:str"))Z(H??X,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(G)W.spaceBefore=!0;if(Y)if(X.type==="scalar"&&X.source==="")W.comment=Y;else W.commentBefore=Y;if(U.options.keepSourceTokens&&$)W.srcToken=X;return W}function rU(U,X,q,Z,{spaceBefore:Q,comment:G,anchor:Y,tag:J,end:H},W){let $={type:"scalar",offset:oz.emptyScalarPosition(X,q,Z),indent:-1,source:""},_=BQ.composeScalar(U,$,J,W);if(Y){if(_.anchor=Y.source.substring(1),_.anchor==="")W(Y,"BAD_ALIAS","Anchor cannot be an empty string")}if(Q)_.spaceBefore=!0;if(G)_.comment=G,_.range[2]=H;return _}function nz({options:U},{offset:X,source:q,end:Z},Q){let G=new dz.Alias(q.substring(1));if(G.source==="")Q(X,"BAD_ALIAS","Alias cannot be an empty string");if(G.source.endsWith(":"))Q(X+q.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let Y=X+q.length,J=sz.resolveEnd(Z,Y,U.strict,Q);if(G.range=[X,Y,J.offset],J.comment)G.comment=J.comment;return G}az.composeEmptyNode=rU;az.composeNode=TQ});var DQ=R((QF)=>{var UF=e2(),RQ=VQ(),XF=U2(),qF=X6();function ZF(U,X,{offset:q,start:Z,value:Q,end:G},Y){let J=Object.assign({_directives:X},U),H=new UF.Document(void 0,J),W={atKey:!1,atRoot:!0,directives:H.directives,options:H.options,schema:H.schema},$=qF.resolveProps(Z,{indicator:"doc-start",next:Q??G?.[0],offset:q,onError:Y,parentIndent:0,startOnNewline:!0});if($.found){if(H.directives.docStart=!0,Q&&(Q.type==="block-map"||Q.type==="block-seq")&&!$.hasNewline)Y($.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}H.contents=Q?RQ.composeNode(W,Q,$,Y):RQ.composeEmptyNode(W,$.end,Z,null,$,Y);let _=H.contents.range[2],L=XF.resolveEnd(G,_,!1,Y);if(L.comment)H.comment=L.comment;return H.range=[q,_,L.offset],H}QF.composeDoc=ZF});var nU=R(($F)=>{var YF=w1("process"),JF=UU(),HF=e2(),q6=U6(),MQ=k(),WF=DQ(),_F=U2();function Z6(U){if(typeof U==="number")return[U,U+1];if(Array.isArray(U))return U.length===2?U:[U[0],U[1]];let{offset:X,source:q}=U;return[X,X+(typeof q==="string"?q.length:1)]}function wQ(U){let X="",q=!1,Z=!1;for(let Q=0;Q<U.length;++Q){let G=U[Q];switch(G[0]){case"#":X+=(X===""?"":Z?`
100
100
 
101
101
  `:`
102
- `)+(G.substring(1)||" "),q=!0,Z=!1;break;case"%":if(U[Q+1]?.[0]!=="#")Q+=1;q=!1;break;default:if(!q)Z=!0;q=!1}}return{comment:X,afterEmptyLine:Z}}class wQ{constructor(U={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(X,q,Z,Q)=>{let G=Z6(X);if(Q)this.warnings.push(new q6.YAMLWarning(G,q,Z));else this.errors.push(new q6.YAMLParseError(G,q,Z))},this.directives=new qF.Directives({version:U.version||"1.2"}),this.options=U}decorate(U,X){let{comment:q,afterEmptyLine:Z}=MQ(this.prelude);if(q){let Q=U.contents;if(X)U.comment=U.comment?`${U.comment}
103
- ${q}`:q;else if(Z||U.directives.docStart||!Q)U.commentBefore=q;else if(DQ.isCollection(Q)&&!Q.flow&&Q.items.length>0){let G=Q.items[0];if(DQ.isPair(G))G=G.key;let Y=G.commentBefore;G.commentBefore=Y?`${q}
102
+ `)+(G.substring(1)||" "),q=!0,Z=!1;break;case"%":if(U[Q+1]?.[0]!=="#")Q+=1;q=!1;break;default:if(!q)Z=!0;q=!1}}return{comment:X,afterEmptyLine:Z}}class PQ{constructor(U={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(X,q,Z,Q)=>{let G=Z6(X);if(Q)this.warnings.push(new q6.YAMLWarning(G,q,Z));else this.errors.push(new q6.YAMLParseError(G,q,Z))},this.directives=new JF.Directives({version:U.version||"1.2"}),this.options=U}decorate(U,X){let{comment:q,afterEmptyLine:Z}=wQ(this.prelude);if(q){let Q=U.contents;if(X)U.comment=U.comment?`${U.comment}
103
+ ${q}`:q;else if(Z||U.directives.docStart||!Q)U.commentBefore=q;else if(MQ.isCollection(Q)&&!Q.flow&&Q.items.length>0){let G=Q.items[0];if(MQ.isPair(G))G=G.key;let Y=G.commentBefore;G.commentBefore=Y?`${q}
104
104
  ${Y}`:q}else{let G=Q.commentBefore;Q.commentBefore=G?`${q}
105
- ${G}`:q}}if(X)Array.prototype.push.apply(U.errors,this.errors),Array.prototype.push.apply(U.warnings,this.warnings);else U.errors=this.errors,U.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:MQ(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(U,X=!1,q=-1){for(let Z of U)yield*this.next(Z);yield*this.end(X,q)}*next(U){if(XF.env.LOG_STREAM)console.dir(U,{depth:null});switch(U.type){case"directive":this.directives.add(U.source,(X,q,Z)=>{let Q=Z6(U);Q[0]+=X,this.onError(Q,"BAD_DIRECTIVE",q,Z)}),this.prelude.push(U.source),this.atDirectives=!0;break;case"document":{let X=QF.composeDoc(this.options,this.directives,U,this.onError);if(this.atDirectives&&!X.directives.docStart)this.onError(U,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(X,!1),this.doc)yield this.doc;this.doc=X,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(U.source);break;case"error":{let X=U.source?`${U.message}: ${JSON.stringify(U.source)}`:U.message,q=new q6.YAMLParseError(Z6(U),"UNEXPECTED_TOKEN",X);if(this.atDirectives||!this.doc)this.errors.push(q);else this.doc.errors.push(q);break}case"doc-end":{if(!this.doc){this.errors.push(new q6.YAMLParseError(Z6(U),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let X=GF.resolveEnd(U.end,U.offset+U.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),X.comment){let q=this.doc.comment;this.doc.comment=q?`${q}
106
- ${X.comment}`:X.comment}this.doc.range[2]=X.offset;break}default:this.errors.push(new q6.YAMLParseError(Z6(U),"UNEXPECTED_TOKEN",`Unsupported token ${U.type}`))}}*end(U=!1,X=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(U){let q=Object.assign({_directives:this.directives},this.options),Z=new ZF.Document(void 0,q);if(this.atDirectives)this.onError(X,"MISSING_CHAR","Missing directives-end indicator line");Z.range=[0,X,X],this.decorate(Z,!1),yield Z}}}YF.Composer=wQ});var KQ=R((AF)=>{var HF=iU(),WF=oU(),_F=U6(),PQ=p2();function $F(U,X=!0,q){if(U){let Z=(Q,G,Y)=>{let J=typeof Q==="number"?Q:Array.isArray(Q)?Q[0]:Q.offset;if(q)q(J,G,Y);else throw new _F.YAMLParseError([J,J+1],G,Y)};switch(U.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return WF.resolveFlowScalar(U,X,Z);case"block-scalar":return HF.resolveBlockScalar({options:{strict:X}},U,Z)}}return null}function LF(U,X){let{implicitKey:q=!1,indent:Z,inFlow:Q=!1,offset:G=-1,type:Y="PLAIN"}=X,J=PQ.stringifyString({type:Y,value:U},{implicitKey:q,indent:Z>0?" ".repeat(Z):"",inFlow:Q,options:{blockQuote:!0,lineWidth:-1}}),H=X.end??[{type:"newline",offset:-1,indent:Z,source:`
105
+ ${G}`:q}}if(X)Array.prototype.push.apply(U.errors,this.errors),Array.prototype.push.apply(U.warnings,this.warnings);else U.errors=this.errors,U.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:wQ(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(U,X=!1,q=-1){for(let Z of U)yield*this.next(Z);yield*this.end(X,q)}*next(U){if(YF.env.LOG_STREAM)console.dir(U,{depth:null});switch(U.type){case"directive":this.directives.add(U.source,(X,q,Z)=>{let Q=Z6(U);Q[0]+=X,this.onError(Q,"BAD_DIRECTIVE",q,Z)}),this.prelude.push(U.source),this.atDirectives=!0;break;case"document":{let X=WF.composeDoc(this.options,this.directives,U,this.onError);if(this.atDirectives&&!X.directives.docStart)this.onError(U,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(X,!1),this.doc)yield this.doc;this.doc=X,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(U.source);break;case"error":{let X=U.source?`${U.message}: ${JSON.stringify(U.source)}`:U.message,q=new q6.YAMLParseError(Z6(U),"UNEXPECTED_TOKEN",X);if(this.atDirectives||!this.doc)this.errors.push(q);else this.doc.errors.push(q);break}case"doc-end":{if(!this.doc){this.errors.push(new q6.YAMLParseError(Z6(U),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let X=_F.resolveEnd(U.end,U.offset+U.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),X.comment){let q=this.doc.comment;this.doc.comment=q?`${q}
106
+ ${X.comment}`:X.comment}this.doc.range[2]=X.offset;break}default:this.errors.push(new q6.YAMLParseError(Z6(U),"UNEXPECTED_TOKEN",`Unsupported token ${U.type}`))}}*end(U=!1,X=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(U){let q=Object.assign({_directives:this.directives},this.options),Z=new HF.Document(void 0,q);if(this.atDirectives)this.onError(X,"MISSING_CHAR","Missing directives-end indicator line");Z.range=[0,X,X],this.decorate(Z,!1),yield Z}}}$F.Composer=PQ});var NQ=R((RF)=>{var zF=iU(),FF=oU(),AF=U6(),IQ=p2();function OF(U,X=!0,q){if(U){let Z=(Q,G,Y)=>{let J=typeof Q==="number"?Q:Array.isArray(Q)?Q[0]:Q.offset;if(q)q(J,G,Y);else throw new AF.YAMLParseError([J,J+1],G,Y)};switch(U.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return FF.resolveFlowScalar(U,X,Z);case"block-scalar":return zF.resolveBlockScalar({options:{strict:X}},U,Z)}}return null}function BF(U,X){let{implicitKey:q=!1,indent:Z,inFlow:Q=!1,offset:G=-1,type:Y="PLAIN"}=X,J=IQ.stringifyString({type:Y,value:U},{implicitKey:q,indent:Z>0?" ".repeat(Z):"",inFlow:Q,options:{blockQuote:!0,lineWidth:-1}}),H=X.end??[{type:"newline",offset:-1,indent:Z,source:`
107
107
  `}];switch(J[0]){case"|":case">":{let W=J.indexOf(`
108
108
  `),$=J.substring(0,W),_=J.substring(W+1)+`
109
- `,L=[{type:"block-scalar-header",offset:G,indent:Z,source:$}];if(!IQ(L,H))L.push({type:"newline",offset:-1,indent:Z,source:`
110
- `});return{type:"block-scalar",offset:G,indent:Z,props:L,source:_}}case'"':return{type:"double-quoted-scalar",offset:G,indent:Z,source:J,end:H};case"'":return{type:"single-quoted-scalar",offset:G,indent:Z,source:J,end:H};default:return{type:"scalar",offset:G,indent:Z,source:J,end:H}}}function zF(U,X,q={}){let{afterKey:Z=!1,implicitKey:Q=!1,inFlow:G=!1,type:Y}=q,J="indent"in U?U.indent:null;if(Z&&typeof J==="number")J+=2;if(!Y)switch(U.type){case"single-quoted-scalar":Y="QUOTE_SINGLE";break;case"double-quoted-scalar":Y="QUOTE_DOUBLE";break;case"block-scalar":{let W=U.props[0];if(W.type!=="block-scalar-header")throw Error("Invalid block scalar header");Y=W.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:Y="PLAIN"}let H=PQ.stringifyString({type:Y,value:X},{implicitKey:Q||J===null,indent:J!==null&&J>0?" ".repeat(J):"",inFlow:G,options:{blockQuote:!0,lineWidth:-1}});switch(H[0]){case"|":case">":FF(U,H);break;case'"':aU(U,H,"double-quoted-scalar");break;case"'":aU(U,H,"single-quoted-scalar");break;default:aU(U,H,"scalar")}}function FF(U,X){let q=X.indexOf(`
109
+ `,L=[{type:"block-scalar-header",offset:G,indent:Z,source:$}];if(!KQ(L,H))L.push({type:"newline",offset:-1,indent:Z,source:`
110
+ `});return{type:"block-scalar",offset:G,indent:Z,props:L,source:_}}case'"':return{type:"double-quoted-scalar",offset:G,indent:Z,source:J,end:H};case"'":return{type:"single-quoted-scalar",offset:G,indent:Z,source:J,end:H};default:return{type:"scalar",offset:G,indent:Z,source:J,end:H}}}function TF(U,X,q={}){let{afterKey:Z=!1,implicitKey:Q=!1,inFlow:G=!1,type:Y}=q,J="indent"in U?U.indent:null;if(Z&&typeof J==="number")J+=2;if(!Y)switch(U.type){case"single-quoted-scalar":Y="QUOTE_SINGLE";break;case"double-quoted-scalar":Y="QUOTE_DOUBLE";break;case"block-scalar":{let W=U.props[0];if(W.type!=="block-scalar-header")throw Error("Invalid block scalar header");Y=W.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:Y="PLAIN"}let H=IQ.stringifyString({type:Y,value:X},{implicitKey:Q||J===null,indent:J!==null&&J>0?" ".repeat(J):"",inFlow:G,options:{blockQuote:!0,lineWidth:-1}});switch(H[0]){case"|":case">":VF(U,H);break;case'"':aU(U,H,"double-quoted-scalar");break;case"'":aU(U,H,"single-quoted-scalar");break;default:aU(U,H,"scalar")}}function VF(U,X){let q=X.indexOf(`
111
111
  `),Z=X.substring(0,q),Q=X.substring(q+1)+`
112
- `;if(U.type==="block-scalar"){let G=U.props[0];if(G.type!=="block-scalar-header")throw Error("Invalid block scalar header");G.source=Z,U.source=Q}else{let{offset:G}=U,Y="indent"in U?U.indent:-1,J=[{type:"block-scalar-header",offset:G,indent:Y,source:Z}];if(!IQ(J,"end"in U?U.end:void 0))J.push({type:"newline",offset:-1,indent:Y,source:`
113
- `});for(let H of Object.keys(U))if(H!=="type"&&H!=="offset")delete U[H];Object.assign(U,{type:"block-scalar",indent:Y,props:J,source:Q})}}function IQ(U,X){if(X)for(let q of X)switch(q.type){case"space":case"comment":U.push(q);break;case"newline":return U.push(q),!0}return!1}function aU(U,X,q){switch(U.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":U.type=q,U.source=X;break;case"block-scalar":{let Z=U.props.slice(1),Q=X.length;if(U.props[0].type==="block-scalar-header")Q-=U.props[0].source.length;for(let G of Z)G.offset+=Q;delete U.props,Object.assign(U,{type:q,source:X,end:Z});break}case"block-map":case"block-seq":{let Q={type:"newline",offset:U.offset+X.length,indent:U.indent,source:`
114
- `};delete U.items,Object.assign(U,{type:q,source:X,end:[Q]});break}default:{let Z="indent"in U?U.indent:-1,Q="end"in U&&Array.isArray(U.end)?U.end.filter((G)=>G.type==="space"||G.type==="comment"||G.type==="newline"):[];for(let G of Object.keys(U))if(G!=="type"&&G!=="offset")delete U[G];Object.assign(U,{type:q,indent:Z,source:X,end:Q})}}}AF.createScalarToken=LF;AF.resolveAsScalar=$F;AF.setScalarValue=zF});var NQ=R((RF)=>{var VF=(U)=>("type"in U)?I4(U):P4(U);function I4(U){switch(U.type){case"block-scalar":{let X="";for(let q of U.props)X+=I4(q);return X+U.source}case"block-map":case"block-seq":{let X="";for(let q of U.items)X+=P4(q);return X}case"flow-collection":{let X=U.start.source;for(let q of U.items)X+=P4(q);for(let q of U.end)X+=q.source;return X}case"document":{let X=P4(U);if(U.end)for(let q of U.end)X+=q.source;return X}default:{let X=U.source;if("end"in U&&U.end)for(let q of U.end)X+=q.source;return X}}}function P4({start:U,key:X,sep:q,value:Z}){let Q="";for(let G of U)Q+=G.source;if(X)Q+=I4(X);if(q)for(let G of q)Q+=G.source;if(Z)Q+=I4(Z);return Q}RF.stringify=VF});var EQ=R((wF)=>{var tU=Symbol("break visit"),MF=Symbol("skip children"),CQ=Symbol("remove item");function R1(U,X){if("type"in U&&U.type==="document")U={start:U.start,value:U.value};SQ(Object.freeze([]),U,X)}R1.BREAK=tU;R1.SKIP=MF;R1.REMOVE=CQ;R1.itemAtPath=(U,X)=>{let q=U;for(let[Z,Q]of X){let G=q?.[Z];if(G&&"items"in G)q=G.items[Q];else return}return q};R1.parentCollection=(U,X)=>{let q=R1.itemAtPath(U,X.slice(0,-1)),Z=X[X.length-1][0],Q=q?.[Z];if(Q&&"items"in Q)return Q;throw Error("Parent collection not found")};function SQ(U,X,q){let Z=q(X,U);if(typeof Z==="symbol")return Z;for(let Q of["key","value"]){let G=X[Q];if(G&&"items"in G){for(let Y=0;Y<G.items.length;++Y){let J=SQ(Object.freeze(U.concat([[Q,Y]])),G.items[Y],q);if(typeof J==="number")Y=J-1;else if(J===tU)return tU;else if(J===CQ)G.items.splice(Y,1),Y-=1}if(typeof Z==="function"&&Q==="key")Z=Z(X,U)}}return typeof Z==="function"?Z(X,U):Z}wF.visit=R1});var K4=R((jF)=>{var eU=KQ(),IF=NQ(),KF=EQ(),UX="\uFEFF",XX="\x02",qX="\x18",ZX="\x1F",NF=(U)=>!!U&&("items"in U),CF=(U)=>!!U&&(U.type==="scalar"||U.type==="single-quoted-scalar"||U.type==="double-quoted-scalar"||U.type==="block-scalar");function SF(U){switch(U){case UX:return"<BOM>";case XX:return"<DOC>";case qX:return"<FLOW_END>";case ZX:return"<SCALAR>";default:return JSON.stringify(U)}}function EF(U){switch(U){case UX:return"byte-order-mark";case XX:return"doc-mode";case qX:return"flow-error-end";case ZX:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
112
+ `;if(U.type==="block-scalar"){let G=U.props[0];if(G.type!=="block-scalar-header")throw Error("Invalid block scalar header");G.source=Z,U.source=Q}else{let{offset:G}=U,Y="indent"in U?U.indent:-1,J=[{type:"block-scalar-header",offset:G,indent:Y,source:Z}];if(!KQ(J,"end"in U?U.end:void 0))J.push({type:"newline",offset:-1,indent:Y,source:`
113
+ `});for(let H of Object.keys(U))if(H!=="type"&&H!=="offset")delete U[H];Object.assign(U,{type:"block-scalar",indent:Y,props:J,source:Q})}}function KQ(U,X){if(X)for(let q of X)switch(q.type){case"space":case"comment":U.push(q);break;case"newline":return U.push(q),!0}return!1}function aU(U,X,q){switch(U.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":U.type=q,U.source=X;break;case"block-scalar":{let Z=U.props.slice(1),Q=X.length;if(U.props[0].type==="block-scalar-header")Q-=U.props[0].source.length;for(let G of Z)G.offset+=Q;delete U.props,Object.assign(U,{type:q,source:X,end:Z});break}case"block-map":case"block-seq":{let Q={type:"newline",offset:U.offset+X.length,indent:U.indent,source:`
114
+ `};delete U.items,Object.assign(U,{type:q,source:X,end:[Q]});break}default:{let Z="indent"in U?U.indent:-1,Q="end"in U&&Array.isArray(U.end)?U.end.filter((G)=>G.type==="space"||G.type==="comment"||G.type==="newline"):[];for(let G of Object.keys(U))if(G!=="type"&&G!=="offset")delete U[G];Object.assign(U,{type:q,indent:Z,source:X,end:Q})}}}RF.createScalarToken=BF;RF.resolveAsScalar=OF;RF.setScalarValue=TF});var CQ=R((IF)=>{var PF=(U)=>("type"in U)?I4(U):P4(U);function I4(U){switch(U.type){case"block-scalar":{let X="";for(let q of U.props)X+=I4(q);return X+U.source}case"block-map":case"block-seq":{let X="";for(let q of U.items)X+=P4(q);return X}case"flow-collection":{let X=U.start.source;for(let q of U.items)X+=P4(q);for(let q of U.end)X+=q.source;return X}case"document":{let X=P4(U);if(U.end)for(let q of U.end)X+=q.source;return X}default:{let X=U.source;if("end"in U&&U.end)for(let q of U.end)X+=q.source;return X}}}function P4({start:U,key:X,sep:q,value:Z}){let Q="";for(let G of U)Q+=G.source;if(X)Q+=I4(X);if(q)for(let G of q)Q+=G.source;if(Z)Q+=I4(Z);return Q}IF.stringify=PF});var jQ=R((CF)=>{var tU=Symbol("break visit"),NF=Symbol("skip children"),SQ=Symbol("remove item");function R1(U,X){if("type"in U&&U.type==="document")U={start:U.start,value:U.value};EQ(Object.freeze([]),U,X)}R1.BREAK=tU;R1.SKIP=NF;R1.REMOVE=SQ;R1.itemAtPath=(U,X)=>{let q=U;for(let[Z,Q]of X){let G=q?.[Z];if(G&&"items"in G)q=G.items[Q];else return}return q};R1.parentCollection=(U,X)=>{let q=R1.itemAtPath(U,X.slice(0,-1)),Z=X[X.length-1][0],Q=q?.[Z];if(Q&&"items"in Q)return Q;throw Error("Parent collection not found")};function EQ(U,X,q){let Z=q(X,U);if(typeof Z==="symbol")return Z;for(let Q of["key","value"]){let G=X[Q];if(G&&"items"in G){for(let Y=0;Y<G.items.length;++Y){let J=EQ(Object.freeze(U.concat([[Q,Y]])),G.items[Y],q);if(typeof J==="number")Y=J-1;else if(J===tU)return tU;else if(J===SQ)G.items.splice(Y,1),Y-=1}if(typeof Z==="function"&&Q==="key")Z=Z(X,U)}}return typeof Z==="function"?Z(X,U):Z}CF.visit=R1});var K4=R((kF)=>{var eU=NQ(),EF=CQ(),jF=jQ(),UX="\uFEFF",XX="\x02",qX="\x18",ZX="\x1F",bF=(U)=>!!U&&("items"in U),fF=(U)=>!!U&&(U.type==="scalar"||U.type==="single-quoted-scalar"||U.type==="double-quoted-scalar"||U.type==="block-scalar");function gF(U){switch(U){case UX:return"<BOM>";case XX:return"<DOC>";case qX:return"<FLOW_END>";case ZX:return"<SCALAR>";default:return JSON.stringify(U)}}function yF(U){switch(U){case UX:return"byte-order-mark";case XX:return"doc-mode";case qX:return"flow-error-end";case ZX:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
115
  `:case`\r
116
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(U[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}jF.createScalarToken=eU.createScalarToken;jF.resolveAsScalar=eU.resolveAsScalar;jF.setScalarValue=eU.setScalarValue;jF.stringify=IF.stringify;jF.visit=KF.visit;jF.BOM=UX;jF.DOCUMENT=XX;jF.FLOW_END=qX;jF.SCALAR=ZX;jF.isCollection=NF;jF.isScalar=CF;jF.prettyToken=SF;jF.tokenType=EF});var GX=R((sF)=>{var Q6=K4();function K0(U){switch(U){case void 0:case" ":case`
117
- `:case"\r":case"\t":return!0;default:return!1}}var jQ=new Set("0123456789ABCDEFabcdef"),cF=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),N4=new Set(",[]{}"),iF=new Set(` ,[]{}
118
- \r `),QX=(U)=>!U||iF.has(U);class bQ{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(U,X=!1){if(U){if(typeof U!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+U:U,this.lineEndPos=null}this.atEnd=!X;let q=this.next??"stream";while(q&&(X||this.hasChars(1)))q=yield*this.parseNext(q)}atLineEnd(){let U=this.pos,X=this.buffer[U];while(X===" "||X==="\t")X=this.buffer[++U];if(!X||X==="#"||X===`
116
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(U[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}kF.createScalarToken=eU.createScalarToken;kF.resolveAsScalar=eU.resolveAsScalar;kF.setScalarValue=eU.setScalarValue;kF.stringify=EF.stringify;kF.visit=jF.visit;kF.BOM=UX;kF.DOCUMENT=XX;kF.FLOW_END=qX;kF.SCALAR=ZX;kF.isCollection=bF;kF.isScalar=fF;kF.prettyToken=gF;kF.tokenType=yF});var GX=R((tF)=>{var Q6=K4();function K0(U){switch(U){case void 0:case" ":case`
117
+ `:case"\r":case"\t":return!0;default:return!1}}var bQ=new Set("0123456789ABCDEFabcdef"),nF=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),N4=new Set(",[]{}"),aF=new Set(` ,[]{}
118
+ \r `),QX=(U)=>!U||aF.has(U);class fQ{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(U,X=!1){if(U){if(typeof U!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+U:U,this.lineEndPos=null}this.atEnd=!X;let q=this.next??"stream";while(q&&(X||this.hasChars(1)))q=yield*this.parseNext(q)}atLineEnd(){let U=this.pos,X=this.buffer[U];while(X===" "||X==="\t")X=this.buffer[++U];if(!X||X==="#"||X===`
119
119
  `)return!0;if(X==="\r")return this.buffer[U+1]===`
120
120
  `;return!1}charAt(U){return this.buffer[this.pos+U]}continueScalar(U){let X=this.buffer[U];if(this.indentNext>0){let q=0;while(X===" ")X=this.buffer[++q+U];if(X==="\r"){let Z=this.buffer[q+U+1];if(Z===`
121
121
  `||!Z&&!this.atEnd)return U+q+1}return X===`
@@ -130,58 +130,58 @@ ${X.comment}`:X.comment}this.doc.range[2]=X.offset;break}default:this.errors.pus
130
130
  `&&Q>=this.pos&&Q+1+X>Y)U=Q;else break}while(!0);return yield Q6.SCALAR,yield*this.pushToIndex(U+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let U=this.flowLevel>0,X=this.pos-1,q=this.pos-1,Z;while(Z=this.buffer[++q])if(Z===":"){let Q=this.buffer[q+1];if(K0(Q)||U&&N4.has(Q))break;X=q}else if(K0(Z)){let Q=this.buffer[q+1];if(Z==="\r")if(Q===`
131
131
  `)q+=1,Z=`
132
132
  `,Q=this.buffer[q+1];else X=q;if(Q==="#"||U&&N4.has(Q))break;if(Z===`
133
- `){let G=this.continueScalar(q+1);if(G===-1)break;q=Math.max(q,G-2)}}else{if(U&&N4.has(Z))break;X=q}if(!Z&&!this.atEnd)return this.setNext("plain-scalar");return yield Q6.SCALAR,yield*this.pushToIndex(X+1,!0),U?"flow":"doc"}*pushCount(U){if(U>0)return yield this.buffer.substr(this.pos,U),this.pos+=U,U;return 0}*pushToIndex(U,X){let q=this.buffer.slice(this.pos,U);if(q)return yield q,this.pos+=q.length,q.length;else if(X)yield"";return 0}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(QX))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let U=this.flowLevel>0,X=this.charAt(1);if(K0(X)||U&&N4.has(X)){if(!U)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;return(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}}return 0}*pushTag(){if(this.charAt(1)==="<"){let U=this.pos+2,X=this.buffer[U];while(!K0(X)&&X!==">")X=this.buffer[++U];return yield*this.pushToIndex(X===">"?U+1:U,!1)}else{let U=this.pos+1,X=this.buffer[U];while(X)if(cF.has(X))X=this.buffer[++U];else if(X==="%"&&jQ.has(this.buffer[U+1])&&jQ.has(this.buffer[U+2]))X=this.buffer[U+=3];else break;return yield*this.pushToIndex(U,!1)}}*pushNewline(){let U=this.buffer[this.pos];if(U===`
133
+ `){let G=this.continueScalar(q+1);if(G===-1)break;q=Math.max(q,G-2)}}else{if(U&&N4.has(Z))break;X=q}if(!Z&&!this.atEnd)return this.setNext("plain-scalar");return yield Q6.SCALAR,yield*this.pushToIndex(X+1,!0),U?"flow":"doc"}*pushCount(U){if(U>0)return yield this.buffer.substr(this.pos,U),this.pos+=U,U;return 0}*pushToIndex(U,X){let q=this.buffer.slice(this.pos,U);if(q)return yield q,this.pos+=q.length,q.length;else if(X)yield"";return 0}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(QX))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let U=this.flowLevel>0,X=this.charAt(1);if(K0(X)||U&&N4.has(X)){if(!U)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;return(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}}return 0}*pushTag(){if(this.charAt(1)==="<"){let U=this.pos+2,X=this.buffer[U];while(!K0(X)&&X!==">")X=this.buffer[++U];return yield*this.pushToIndex(X===">"?U+1:U,!1)}else{let U=this.pos+1,X=this.buffer[U];while(X)if(nF.has(X))X=this.buffer[++U];else if(X==="%"&&bQ.has(this.buffer[U+1])&&bQ.has(this.buffer[U+2]))X=this.buffer[U+=3];else break;return yield*this.pushToIndex(U,!1)}}*pushNewline(){let U=this.buffer[this.pos];if(U===`
134
134
  `)return yield*this.pushCount(1);else if(U==="\r"&&this.charAt(1)===`
135
- `)return yield*this.pushCount(2);else return 0}*pushSpaces(U){let X=this.pos-1,q;do q=this.buffer[++X];while(q===" "||U&&q==="\t");let Z=X-this.pos;if(Z>0)yield this.buffer.substr(this.pos,Z),this.pos=X;return Z}*pushUntil(U){let X=this.pos,q=this.buffer[X];while(!U(q))q=this.buffer[++X];return yield*this.pushToIndex(X,!1)}}sF.Lexer=bQ});var YX=R((rF)=>{class fQ{constructor(){this.lineStarts=[],this.addNewLine=(U)=>this.lineStarts.push(U),this.linePos=(U)=>{let X=0,q=this.lineStarts.length;while(X<q){let Q=X+q>>1;if(this.lineStarts[Q]<U)X=Q+1;else q=Q}if(this.lineStarts[X]===U)return{line:X+1,col:1};if(X===0)return{line:0,col:U};let Z=this.lineStarts[X-1];return{line:X,col:U-Z+1}}}}rF.LineCounter=fQ});var JX=R((eF)=>{var aF=w1("process"),gQ=K4(),tF=GX();function Q1(U,X){for(let q=0;q<U.length;++q)if(U[q].type===X)return!0;return!1}function yQ(U){for(let X=0;X<U.length;++X)switch(U[X].type){case"space":case"comment":case"newline":break;default:return X}return-1}function vQ(U){switch(U?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function C4(U){switch(U.type){case"document":return U.start;case"block-map":{let X=U.items[U.items.length-1];return X.sep??X.start}case"block-seq":return U.items[U.items.length-1].start;default:return[]}}function X2(U){if(U.length===0)return[];let X=U.length;U:while(--X>=0)switch(U[X].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break U}while(U[++X]?.type==="space");return U.splice(X,U.length)}function kQ(U){if(U.start.type==="flow-seq-start"){for(let X of U.items)if(X.sep&&!X.value&&!Q1(X.start,"explicit-key-ind")&&!Q1(X.sep,"map-value-ind")){if(X.key)X.value=X.key;if(delete X.key,vQ(X.value))if(X.value.end)Array.prototype.push.apply(X.value.end,X.sep);else X.value.end=X.sep;else Array.prototype.push.apply(X.start,X.sep);delete X.sep}}}class hQ{constructor(U){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new tF.Lexer,this.onNewLine=U}*parse(U,X=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let q of this.lexer.lex(U,X))yield*this.next(q);if(!X)yield*this.end()}*next(U){if(this.source=U,aF.env.LOG_TOKENS)console.log("|",gQ.prettyToken(U));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=U.length;return}let X=gQ.tokenType(U);if(!X){let q=`Not a YAML token: ${U}`;yield*this.pop({type:"error",offset:this.offset,message:q,source:U}),this.offset+=U.length}else if(X==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=X,yield*this.step(),X){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+U.length);break;case"space":if(this.atNewLine&&U[0]===" ")this.indent+=U.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=U.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=U.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let U=this.peek(1);if(this.type==="doc-end"&&U?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!U)return yield*this.stream();switch(U.type){case"document":return yield*this.document(U);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(U);case"block-scalar":return yield*this.blockScalar(U);case"block-map":return yield*this.blockMap(U);case"block-seq":return yield*this.blockSequence(U);case"flow-collection":return yield*this.flowCollection(U);case"doc-end":return yield*this.documentEnd(U)}yield*this.pop()}peek(U){return this.stack[this.stack.length-U]}*pop(U){let X=U??this.stack.pop();if(!X)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield X;else{let q=this.peek(1);if(X.type==="block-scalar")X.indent="indent"in q?q.indent:0;else if(X.type==="flow-collection"&&q.type==="document")X.indent=0;if(X.type==="flow-collection")kQ(X);switch(q.type){case"document":q.value=X;break;case"block-scalar":q.props.push(X);break;case"block-map":{let Z=q.items[q.items.length-1];if(Z.value){q.items.push({start:[],key:X,sep:[]}),this.onKeyLine=!0;return}else if(Z.sep)Z.value=X;else{Object.assign(Z,{key:X,sep:[]}),this.onKeyLine=!Z.explicitKey;return}break}case"block-seq":{let Z=q.items[q.items.length-1];if(Z.value)q.items.push({start:[],value:X});else Z.value=X;break}case"flow-collection":{let Z=q.items[q.items.length-1];if(!Z||Z.value)q.items.push({start:[],key:X,sep:[]});else if(Z.sep)Z.value=X;else Object.assign(Z,{key:X,sep:[]});return}default:yield*this.pop(),yield*this.pop(X)}if((q.type==="document"||q.type==="block-map"||q.type==="block-seq")&&(X.type==="block-map"||X.type==="block-seq")){let Z=X.items[X.items.length-1];if(Z&&!Z.sep&&!Z.value&&Z.start.length>0&&yQ(Z.start)===-1&&(X.indent===0||Z.start.every((Q)=>Q.type!=="comment"||Q.indent<X.indent))){if(q.type==="document")q.end=Z.start;else q.items.push({start:Z.start});X.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let U={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")U.start.push(this.sourceToken);this.stack.push(U);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(U){if(U.value)return yield*this.lineEnd(U);switch(this.type){case"doc-start":{if(yQ(U.start)!==-1)yield*this.pop(),yield*this.step();else U.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":U.start.push(this.sourceToken);return}let X=this.startBlockValue(U);if(X)this.stack.push(X);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(U){if(this.type==="map-value-ind"){let X=C4(this.peek(2)),q=X2(X),Z;if(U.end)Z=U.end,Z.push(this.sourceToken),delete U.end;else Z=[this.sourceToken];let Q={type:"block-map",offset:U.offset,indent:U.indent,items:[{start:q,key:U,sep:Z}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=Q}else yield*this.lineEnd(U)}*blockScalar(U){switch(this.type){case"space":case"comment":case"newline":U.props.push(this.sourceToken);return;case"scalar":if(U.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let X=this.source.indexOf(`
135
+ `)return yield*this.pushCount(2);else return 0}*pushSpaces(U){let X=this.pos-1,q;do q=this.buffer[++X];while(q===" "||U&&q==="\t");let Z=X-this.pos;if(Z>0)yield this.buffer.substr(this.pos,Z),this.pos=X;return Z}*pushUntil(U){let X=this.pos,q=this.buffer[X];while(!U(q))q=this.buffer[++X];return yield*this.pushToIndex(X,!1)}}tF.Lexer=fQ});var YX=R((UA)=>{class gQ{constructor(){this.lineStarts=[],this.addNewLine=(U)=>this.lineStarts.push(U),this.linePos=(U)=>{let X=0,q=this.lineStarts.length;while(X<q){let Q=X+q>>1;if(this.lineStarts[Q]<U)X=Q+1;else q=Q}if(this.lineStarts[X]===U)return{line:X+1,col:1};if(X===0)return{line:0,col:U};let Z=this.lineStarts[X-1];return{line:X,col:U-Z+1}}}}UA.LineCounter=gQ});var JX=R((QA)=>{var qA=w1("process"),yQ=K4(),ZA=GX();function Q1(U,X){for(let q=0;q<U.length;++q)if(U[q].type===X)return!0;return!1}function kQ(U){for(let X=0;X<U.length;++X)switch(U[X].type){case"space":case"comment":case"newline":break;default:return X}return-1}function hQ(U){switch(U?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function C4(U){switch(U.type){case"document":return U.start;case"block-map":{let X=U.items[U.items.length-1];return X.sep??X.start}case"block-seq":return U.items[U.items.length-1].start;default:return[]}}function X2(U){if(U.length===0)return[];let X=U.length;U:while(--X>=0)switch(U[X].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break U}while(U[++X]?.type==="space");return U.splice(X,U.length)}function vQ(U){if(U.start.type==="flow-seq-start"){for(let X of U.items)if(X.sep&&!X.value&&!Q1(X.start,"explicit-key-ind")&&!Q1(X.sep,"map-value-ind")){if(X.key)X.value=X.key;if(delete X.key,hQ(X.value))if(X.value.end)Array.prototype.push.apply(X.value.end,X.sep);else X.value.end=X.sep;else Array.prototype.push.apply(X.start,X.sep);delete X.sep}}}class xQ{constructor(U){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new ZA.Lexer,this.onNewLine=U}*parse(U,X=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let q of this.lexer.lex(U,X))yield*this.next(q);if(!X)yield*this.end()}*next(U){if(this.source=U,qA.env.LOG_TOKENS)console.log("|",yQ.prettyToken(U));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=U.length;return}let X=yQ.tokenType(U);if(!X){let q=`Not a YAML token: ${U}`;yield*this.pop({type:"error",offset:this.offset,message:q,source:U}),this.offset+=U.length}else if(X==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=X,yield*this.step(),X){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+U.length);break;case"space":if(this.atNewLine&&U[0]===" ")this.indent+=U.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=U.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=U.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let U=this.peek(1);if(this.type==="doc-end"&&U?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!U)return yield*this.stream();switch(U.type){case"document":return yield*this.document(U);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(U);case"block-scalar":return yield*this.blockScalar(U);case"block-map":return yield*this.blockMap(U);case"block-seq":return yield*this.blockSequence(U);case"flow-collection":return yield*this.flowCollection(U);case"doc-end":return yield*this.documentEnd(U)}yield*this.pop()}peek(U){return this.stack[this.stack.length-U]}*pop(U){let X=U??this.stack.pop();if(!X)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield X;else{let q=this.peek(1);if(X.type==="block-scalar")X.indent="indent"in q?q.indent:0;else if(X.type==="flow-collection"&&q.type==="document")X.indent=0;if(X.type==="flow-collection")vQ(X);switch(q.type){case"document":q.value=X;break;case"block-scalar":q.props.push(X);break;case"block-map":{let Z=q.items[q.items.length-1];if(Z.value){q.items.push({start:[],key:X,sep:[]}),this.onKeyLine=!0;return}else if(Z.sep)Z.value=X;else{Object.assign(Z,{key:X,sep:[]}),this.onKeyLine=!Z.explicitKey;return}break}case"block-seq":{let Z=q.items[q.items.length-1];if(Z.value)q.items.push({start:[],value:X});else Z.value=X;break}case"flow-collection":{let Z=q.items[q.items.length-1];if(!Z||Z.value)q.items.push({start:[],key:X,sep:[]});else if(Z.sep)Z.value=X;else Object.assign(Z,{key:X,sep:[]});return}default:yield*this.pop(),yield*this.pop(X)}if((q.type==="document"||q.type==="block-map"||q.type==="block-seq")&&(X.type==="block-map"||X.type==="block-seq")){let Z=X.items[X.items.length-1];if(Z&&!Z.sep&&!Z.value&&Z.start.length>0&&kQ(Z.start)===-1&&(X.indent===0||Z.start.every((Q)=>Q.type!=="comment"||Q.indent<X.indent))){if(q.type==="document")q.end=Z.start;else q.items.push({start:Z.start});X.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let U={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")U.start.push(this.sourceToken);this.stack.push(U);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(U){if(U.value)return yield*this.lineEnd(U);switch(this.type){case"doc-start":{if(kQ(U.start)!==-1)yield*this.pop(),yield*this.step();else U.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":U.start.push(this.sourceToken);return}let X=this.startBlockValue(U);if(X)this.stack.push(X);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(U){if(this.type==="map-value-ind"){let X=C4(this.peek(2)),q=X2(X),Z;if(U.end)Z=U.end,Z.push(this.sourceToken),delete U.end;else Z=[this.sourceToken];let Q={type:"block-map",offset:U.offset,indent:U.indent,items:[{start:q,key:U,sep:Z}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=Q}else yield*this.lineEnd(U)}*blockScalar(U){switch(this.type){case"space":case"comment":case"newline":U.props.push(this.sourceToken);return;case"scalar":if(U.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let X=this.source.indexOf(`
136
136
  `)+1;while(X!==0)this.onNewLine(this.offset+X),X=this.source.indexOf(`
137
- `,X)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(U){let X=U.items[U.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,X.value){let q="end"in X.value?X.value.end:void 0;if((Array.isArray(q)?q[q.length-1]:void 0)?.type==="comment")q?.push(this.sourceToken);else U.items.push({start:[this.sourceToken]})}else if(X.sep)X.sep.push(this.sourceToken);else X.start.push(this.sourceToken);return;case"space":case"comment":if(X.value)U.items.push({start:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else{if(this.atIndentedComment(X.start,U.indent)){let Z=U.items[U.items.length-2]?.value?.end;if(Array.isArray(Z)){Array.prototype.push.apply(Z,X.start),Z.push(this.sourceToken),U.items.pop();return}}X.start.push(this.sourceToken)}return}if(this.indent>=U.indent){let q=!this.onKeyLine&&this.indent===U.indent,Z=q&&(X.sep||X.explicitKey)&&this.type!=="seq-item-ind",Q=[];if(Z&&X.sep&&!X.value){let G=[];for(let Y=0;Y<X.sep.length;++Y){let J=X.sep[Y];switch(J.type){case"newline":G.push(Y);break;case"space":break;case"comment":if(J.indent>U.indent)G.length=0;break;default:G.length=0}}if(G.length>=2)Q=X.sep.splice(G[1])}switch(this.type){case"anchor":case"tag":if(Z||X.value)Q.push(this.sourceToken),U.items.push({start:Q}),this.onKeyLine=!0;else if(X.sep)X.sep.push(this.sourceToken);else X.start.push(this.sourceToken);return;case"explicit-key-ind":if(!X.sep&&!X.explicitKey)X.start.push(this.sourceToken),X.explicitKey=!0;else if(Z||X.value)Q.push(this.sourceToken),U.items.push({start:Q,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(X.explicitKey)if(!X.sep)if(Q1(X.start,"newline"))Object.assign(X,{key:null,sep:[this.sourceToken]});else{let G=X2(X.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:null,sep:[this.sourceToken]}]})}else if(X.value)U.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Q1(X.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Q,key:null,sep:[this.sourceToken]}]});else if(vQ(X.key)&&!Q1(X.sep,"newline")){let G=X2(X.start),Y=X.key,J=X.sep;J.push(this.sourceToken),delete X.key,delete X.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:Y,sep:J}]})}else if(Q.length>0)X.sep=X.sep.concat(Q,this.sourceToken);else X.sep.push(this.sourceToken);else if(!X.sep)Object.assign(X,{key:null,sep:[this.sourceToken]});else if(X.value||Z)U.items.push({start:Q,key:null,sep:[this.sourceToken]});else if(Q1(X.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else X.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let G=this.flowScalar(this.type);if(Z||X.value)U.items.push({start:Q,key:G,sep:[]}),this.onKeyLine=!0;else if(X.sep)this.stack.push(G);else Object.assign(X,{key:G,sep:[]}),this.onKeyLine=!0;return}default:{let G=this.startBlockValue(U);if(G){if(G.type==="block-seq"){if(!X.explicitKey&&X.sep&&!Q1(X.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(q)U.items.push({start:Q});this.stack.push(G);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(U){let X=U.items[U.items.length-1];switch(this.type){case"newline":if(X.value){let q="end"in X.value?X.value.end:void 0;if((Array.isArray(q)?q[q.length-1]:void 0)?.type==="comment")q?.push(this.sourceToken);else U.items.push({start:[this.sourceToken]})}else X.start.push(this.sourceToken);return;case"space":case"comment":if(X.value)U.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(X.start,U.indent)){let Z=U.items[U.items.length-2]?.value?.end;if(Array.isArray(Z)){Array.prototype.push.apply(Z,X.start),Z.push(this.sourceToken),U.items.pop();return}}X.start.push(this.sourceToken)}return;case"anchor":case"tag":if(X.value||this.indent<=U.indent)break;X.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==U.indent)break;if(X.value||Q1(X.start,"seq-item-ind"))U.items.push({start:[this.sourceToken]});else X.start.push(this.sourceToken);return}if(this.indent>U.indent){let q=this.startBlockValue(U);if(q){this.stack.push(q);return}}yield*this.pop(),yield*this.step()}*flowCollection(U){let X=U.items[U.items.length-1];if(this.type==="flow-error-end"){let q;do yield*this.pop(),q=this.peek(1);while(q?.type==="flow-collection")}else if(U.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!X||X.sep)U.items.push({start:[this.sourceToken]});else X.start.push(this.sourceToken);return;case"map-value-ind":if(!X||X.value)U.items.push({start:[],key:null,sep:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else Object.assign(X,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!X||X.value)U.items.push({start:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else X.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let Z=this.flowScalar(this.type);if(!X||X.value)U.items.push({start:[],key:Z,sep:[]});else if(X.sep)this.stack.push(Z);else Object.assign(X,{key:Z,sep:[]});return}case"flow-map-end":case"flow-seq-end":U.end.push(this.sourceToken);return}let q=this.startBlockValue(U);if(q)this.stack.push(q);else yield*this.pop(),yield*this.step()}else{let q=this.peek(2);if(q.type==="block-map"&&(this.type==="map-value-ind"&&q.indent===U.indent||this.type==="newline"&&!q.items[q.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&q.type!=="flow-collection"){let Z=C4(q),Q=X2(Z);kQ(U);let G=U.end.splice(1,U.end.length);G.push(this.sourceToken);let Y={type:"block-map",offset:U.offset,indent:U.indent,items:[{start:Q,key:U,sep:G}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=Y}else yield*this.lineEnd(U)}}flowScalar(U){if(this.onNewLine){let X=this.source.indexOf(`
137
+ `,X)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(U){let X=U.items[U.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,X.value){let q="end"in X.value?X.value.end:void 0;if((Array.isArray(q)?q[q.length-1]:void 0)?.type==="comment")q?.push(this.sourceToken);else U.items.push({start:[this.sourceToken]})}else if(X.sep)X.sep.push(this.sourceToken);else X.start.push(this.sourceToken);return;case"space":case"comment":if(X.value)U.items.push({start:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else{if(this.atIndentedComment(X.start,U.indent)){let Z=U.items[U.items.length-2]?.value?.end;if(Array.isArray(Z)){Array.prototype.push.apply(Z,X.start),Z.push(this.sourceToken),U.items.pop();return}}X.start.push(this.sourceToken)}return}if(this.indent>=U.indent){let q=!this.onKeyLine&&this.indent===U.indent,Z=q&&(X.sep||X.explicitKey)&&this.type!=="seq-item-ind",Q=[];if(Z&&X.sep&&!X.value){let G=[];for(let Y=0;Y<X.sep.length;++Y){let J=X.sep[Y];switch(J.type){case"newline":G.push(Y);break;case"space":break;case"comment":if(J.indent>U.indent)G.length=0;break;default:G.length=0}}if(G.length>=2)Q=X.sep.splice(G[1])}switch(this.type){case"anchor":case"tag":if(Z||X.value)Q.push(this.sourceToken),U.items.push({start:Q}),this.onKeyLine=!0;else if(X.sep)X.sep.push(this.sourceToken);else X.start.push(this.sourceToken);return;case"explicit-key-ind":if(!X.sep&&!X.explicitKey)X.start.push(this.sourceToken),X.explicitKey=!0;else if(Z||X.value)Q.push(this.sourceToken),U.items.push({start:Q,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(X.explicitKey)if(!X.sep)if(Q1(X.start,"newline"))Object.assign(X,{key:null,sep:[this.sourceToken]});else{let G=X2(X.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:null,sep:[this.sourceToken]}]})}else if(X.value)U.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Q1(X.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Q,key:null,sep:[this.sourceToken]}]});else if(hQ(X.key)&&!Q1(X.sep,"newline")){let G=X2(X.start),Y=X.key,J=X.sep;J.push(this.sourceToken),delete X.key,delete X.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:Y,sep:J}]})}else if(Q.length>0)X.sep=X.sep.concat(Q,this.sourceToken);else X.sep.push(this.sourceToken);else if(!X.sep)Object.assign(X,{key:null,sep:[this.sourceToken]});else if(X.value||Z)U.items.push({start:Q,key:null,sep:[this.sourceToken]});else if(Q1(X.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else X.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let G=this.flowScalar(this.type);if(Z||X.value)U.items.push({start:Q,key:G,sep:[]}),this.onKeyLine=!0;else if(X.sep)this.stack.push(G);else Object.assign(X,{key:G,sep:[]}),this.onKeyLine=!0;return}default:{let G=this.startBlockValue(U);if(G){if(G.type==="block-seq"){if(!X.explicitKey&&X.sep&&!Q1(X.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(q)U.items.push({start:Q});this.stack.push(G);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(U){let X=U.items[U.items.length-1];switch(this.type){case"newline":if(X.value){let q="end"in X.value?X.value.end:void 0;if((Array.isArray(q)?q[q.length-1]:void 0)?.type==="comment")q?.push(this.sourceToken);else U.items.push({start:[this.sourceToken]})}else X.start.push(this.sourceToken);return;case"space":case"comment":if(X.value)U.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(X.start,U.indent)){let Z=U.items[U.items.length-2]?.value?.end;if(Array.isArray(Z)){Array.prototype.push.apply(Z,X.start),Z.push(this.sourceToken),U.items.pop();return}}X.start.push(this.sourceToken)}return;case"anchor":case"tag":if(X.value||this.indent<=U.indent)break;X.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==U.indent)break;if(X.value||Q1(X.start,"seq-item-ind"))U.items.push({start:[this.sourceToken]});else X.start.push(this.sourceToken);return}if(this.indent>U.indent){let q=this.startBlockValue(U);if(q){this.stack.push(q);return}}yield*this.pop(),yield*this.step()}*flowCollection(U){let X=U.items[U.items.length-1];if(this.type==="flow-error-end"){let q;do yield*this.pop(),q=this.peek(1);while(q?.type==="flow-collection")}else if(U.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!X||X.sep)U.items.push({start:[this.sourceToken]});else X.start.push(this.sourceToken);return;case"map-value-ind":if(!X||X.value)U.items.push({start:[],key:null,sep:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else Object.assign(X,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!X||X.value)U.items.push({start:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else X.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let Z=this.flowScalar(this.type);if(!X||X.value)U.items.push({start:[],key:Z,sep:[]});else if(X.sep)this.stack.push(Z);else Object.assign(X,{key:Z,sep:[]});return}case"flow-map-end":case"flow-seq-end":U.end.push(this.sourceToken);return}let q=this.startBlockValue(U);if(q)this.stack.push(q);else yield*this.pop(),yield*this.step()}else{let q=this.peek(2);if(q.type==="block-map"&&(this.type==="map-value-ind"&&q.indent===U.indent||this.type==="newline"&&!q.items[q.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&q.type!=="flow-collection"){let Z=C4(q),Q=X2(Z);vQ(U);let G=U.end.splice(1,U.end.length);G.push(this.sourceToken);let Y={type:"block-map",offset:U.offset,indent:U.indent,items:[{start:Q,key:U,sep:G}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=Y}else yield*this.lineEnd(U)}}flowScalar(U){if(this.onNewLine){let X=this.source.indexOf(`
138
138
  `)+1;while(X!==0)this.onNewLine(this.offset+X),X=this.source.indexOf(`
139
- `,X)+1}return{type:U,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(U){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let X=C4(U),q=X2(X);return q.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let X=C4(U),q=X2(X);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(U,X){if(this.type!=="comment")return!1;if(this.indent<=X)return!1;return U.every((q)=>q.type==="newline"||q.type==="space")}*documentEnd(U){if(this.type!=="doc-mode"){if(U.end)U.end.push(this.sourceToken);else U.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(U){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(U.end)U.end.push(this.sourceToken);else U.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}eF.Parser=hQ});var lQ=R((HA)=>{var xQ=nU(),XA=e2(),G6=U6(),qA=YU(),ZA=k(),QA=YX(),uQ=JX();function mQ(U){let X=U.prettyErrors!==!1;return{lineCounter:U.lineCounter||X&&new QA.LineCounter||null,prettyErrors:X}}function GA(U,X={}){let{lineCounter:q,prettyErrors:Z}=mQ(X),Q=new uQ.Parser(q?.addNewLine),G=new xQ.Composer(X),Y=Array.from(G.compose(Q.parse(U)));if(Z&&q)for(let J of Y)J.errors.forEach(G6.prettifyError(U,q)),J.warnings.forEach(G6.prettifyError(U,q));if(Y.length>0)return Y;return Object.assign([],{empty:!0},G.streamInfo())}function pQ(U,X={}){let{lineCounter:q,prettyErrors:Z}=mQ(X),Q=new uQ.Parser(q?.addNewLine),G=new xQ.Composer(X),Y=null;for(let J of G.compose(Q.parse(U),!0,U.length))if(!Y)Y=J;else if(Y.options.logLevel!=="silent"){Y.errors.push(new G6.YAMLParseError(J.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(Z&&q)Y.errors.forEach(G6.prettifyError(U,q)),Y.warnings.forEach(G6.prettifyError(U,q));return Y}function YA(U,X,q){let Z=void 0;if(typeof X==="function")Z=X;else if(q===void 0&&X&&typeof X==="object")q=X;let Q=pQ(U,q);if(!Q)return null;if(Q.warnings.forEach((G)=>qA.warn(Q.options.logLevel,G)),Q.errors.length>0)if(Q.options.logLevel!=="silent")throw Q.errors[0];else Q.errors=[];return Q.toJS(Object.assign({reviver:Z},q))}function JA(U,X,q){let Z=null;if(typeof X==="function"||Array.isArray(X))Z=X;else if(q===void 0&&X)q=X;if(typeof q==="string")q=q.length;if(typeof q==="number"){let Q=Math.round(q);q=Q<1?void 0:Q>8?{indent:8}:{indent:Q}}if(U===void 0){let{keepUndefined:Q}=q??X??{};if(!Q)return}if(ZA.isDocument(U)&&!Z)return U.toString(q);return new XA.Document(U,Z,q).toString(q)}HA.parse=YA;HA.parseAllDocuments=GA;HA.parseDocument=pQ;HA.stringify=JA});var WX=R((IA)=>{var zA=nU(),FA=e2(),AA=gU(),HX=U6(),OA=h2(),G1=k(),BA=U1(),TA=i(),VA=q1(),RA=Z1(),DA=K4(),MA=GX(),wA=YX(),PA=JX(),S4=lQ(),dQ=k2();IA.Composer=zA.Composer;IA.Document=FA.Document;IA.Schema=AA.Schema;IA.YAMLError=HX.YAMLError;IA.YAMLParseError=HX.YAMLParseError;IA.YAMLWarning=HX.YAMLWarning;IA.Alias=OA.Alias;IA.isAlias=G1.isAlias;IA.isCollection=G1.isCollection;IA.isDocument=G1.isDocument;IA.isMap=G1.isMap;IA.isNode=G1.isNode;IA.isPair=G1.isPair;IA.isScalar=G1.isScalar;IA.isSeq=G1.isSeq;IA.Pair=BA.Pair;IA.Scalar=TA.Scalar;IA.YAMLMap=VA.YAMLMap;IA.YAMLSeq=RA.YAMLSeq;IA.CST=DA;IA.Lexer=MA.Lexer;IA.LineCounter=wA.LineCounter;IA.Parser=PA.Parser;IA.parse=S4.parse;IA.parseAllDocuments=S4.parseAllDocuments;IA.parseDocument=S4.parseDocument;IA.stringify=S4.stringify;IA.visit=dQ.visit;IA.visitAsync=dQ.visitAsync});class tQ{queue=[];engine;config;timer=null;isProcessing=!1;constructor(U,X={maxBatchSize:10,flushIntervalMs:100}){this.engine=U,this.config=X}push(U){if(this.queue.push(U),this.queue.length>=this.config.maxBatchSize)this.processQueue();else if(!this.timer)this.timer=setTimeout(()=>this.processQueue(),this.config.flushIntervalMs)}async processQueue(){if(this.isProcessing)return;if(this.isProcessing=!0,this.timer)clearTimeout(this.timer),this.timer=null;let U=this.queue.splice(0,this.config.maxBatchSize);if(U.length===0){this.isProcessing=!1;return}console.debug(`[EventQueue] Processing batch of ${U.length} events.`);for(let X of U)try{await this.engine.evaluateContext(X)}catch(q){console.error(`[EventQueue] Error processing event ${X.event}:`,q)}if(this.queue.length>0)setTimeout(()=>this.processQueue(),0);this.isProcessing=!1}getQueueLength(){return this.queue.length}}class eQ{keyPrefix;cache=new Map;isLoaded=!1;constructor(U="trigger_system:"){this.keyPrefix=U}isAvailable(){return typeof window<"u"&&typeof window.localStorage<"u"}ensureLoaded(){if(this.isLoaded)return;if(this.isAvailable())try{let U=window.localStorage.getItem(this.keyPrefix+"state");if(U){let X=JSON.parse(U);this.cache=new Map(Object.entries(X))}}catch(U){console.error("[BrowserPersistence] Failed to load from localStorage:",U)}this.isLoaded=!0}persist(){if(this.isAvailable())try{let U=Object.fromEntries(this.cache);window.localStorage.setItem(this.keyPrefix+"state",JSON.stringify(U))}catch(U){console.error("[BrowserPersistence] Failed to save to localStorage:",U)}}async loadState(){return this.ensureLoaded(),new Map(this.cache)}async saveState(U,X){this.ensureLoaded(),this.cache.set(U,X),this.persist()}async deleteState(U){this.ensureLoaded(),this.cache.delete(U),this.persist()}async clearState(){this.cache.clear(),this.persist()}}class Y6{static getNestedValue(U,X){let q=U.split("."),Z=X;for(let Q of q){if(Z===null||Z===void 0)return;if(typeof Z==="object"&&Z!==null&&Q in Z)Z=Z[Q];else return}return Z}static interpolate(U,X){if(typeof U!=="string")return U;return U.replace(/\$\{([^}]+)\}/g,(q,Z)=>{let Q=this.getNestedValue(Z,X);if(Q!==void 0)return String(Q);return q})}static compare(U,X,q){switch(X){case"EQ":case"==":return U==q;case"NEQ":case"!=":return U!=q;case"GT":case">":return Number(U)>Number(q);case"GTE":case">=":return Number(U)>=Number(q);case"LT":case"<":return Number(U)<Number(q);case"LTE":case"<=":return Number(U)<=Number(q);case"IN":return Array.isArray(q)&&q.some((Z)=>Z===U);case"NOT_IN":return Array.isArray(q)&&!q.some((Z)=>Z===U);case"CONTAINS":if(Array.isArray(U)||typeof U==="string")return U.includes(q);return!1;case"NOT_CONTAINS":if(Array.isArray(U)||typeof U==="string")return!U.includes(q);return!1;case"STARTS_WITH":if(typeof U==="string"&&typeof q==="string")return U.startsWith(q);return!1;case"ENDS_WITH":if(typeof U==="string"&&typeof q==="string")return U.endsWith(q);return!1;case"IS_EMPTY":if(typeof U==="string")return U==="";if(Array.isArray(U))return U.length===0;if(U===null||U===void 0)return!0;if(typeof U==="object")return Object.keys(U).length===0;return!1;case"IS_NULL":case"IS_NONE":return U===null||U===void 0;case"HAS_KEY":if(typeof U==="object"&&U!==null&&typeof q==="string")return q in U;return!1;case"MATCHES":if(typeof q==="string")return new RegExp(q).test(String(U));return!1;case"RANGE":if(Array.isArray(q)&&q.length===2){let Z=Number(U),Q=Number(q[0]),G=Number(q[1]);return!isNaN(Z)&&!isNaN(Q)&&!isNaN(G)&&Z>=Q&&Z<=G}return!1;default:return console.warn(`Unknown operator: ${X}`),!1}}}var J6;((G)=>{G.ENGINE_START="engine:start";G.ENGINE_DONE="engine:done";G.RULE_MATCH="rule:match";G.ACTION_SUCCESS="action:success";G.ACTION_ERROR="action:error"})(J6||={});var TX;((Z)=>{Z.RULE_ADDED="rule:added";Z.RULE_REMOVED="rule:removed";Z.RULE_UPDATED="rule:updated"})(TX||={});var FO=J6,H6=TX;class f4{static instance;handlers=new Map;constructor(){}static getInstance(){if(!this.instance)this.instance=new f4;return this.instance}on(U,X){let q=U;if(!this.handlers.has(q))this.handlers.set(q,new Set);return this.handlers.get(q).add(X),()=>this.off(q,X)}off(U,X){let q=U,Z=this.handlers.get(q);if(Z)Z.delete(X)}emit(U,X){let q=U,Z=this.handlers.get(q);if(Z)Z.forEach((Q)=>{try{Q(X)}catch(G){console.error(`Error in event handler for ${q}:`,G)}})}}var N0=f4.getInstance();class G2{_rules=[];actionHandlers=new Map;lastExecution=new Map;_config;constructor(U=[]){if(Array.isArray(U))this._rules=U;else this._config=U,this._rules=[...U.rules];this.sortRules()}sortRules(){this._rules.sort((U,X)=>(X.priority||0)-(U.priority||0))}registerAction(U,X){this.actionHandlers.set(U,X)}async processEvent(U){let X=[];if(!U.state)U.state={};let q=this._rules.filter((Z)=>Z.enabled!==!1&&Z.on===U.event);for(let Z of q){if(Z.cooldown&&this.checkCooldown(Z.id,Z.cooldown))continue;if(this.evaluateConditions(Z.if,U)){let Q=await this.executeRuleActions(Z.do,U);if(this.lastExecution.set(Z.id,Date.now()),X.push({ruleId:Z.id,success:!0,executedActions:Q}),!this.shouldEvaluateAll())break}}return X}async processEventSimple(U,X={},q={}){let Z={event:U,data:X,vars:q,timestamp:Date.now(),state:this.getStateContext?this.getStateContext():{}};return this.processEvent(Z)}updateRules(U){let X=this.getRules(),q=new Set(X.map((Y)=>Y.id)),Z=new Set(U.map((Y)=>Y.id)),Q=U.filter((Y)=>!q.has(Y.id)),G=X.filter((Y)=>!Z.has(Y.id));this.rules=[...U],this.sortRules(),Q.forEach((Y)=>{this.emitRuleEvent(H6.RULE_ADDED,{ruleId:Y.id,timestamp:Date.now()})}),G.forEach((Y)=>{this.emitRuleEvent(H6.RULE_REMOVED,{ruleId:Y.id,timestamp:Date.now()})}),this.emitRuleEvent(H6.RULE_UPDATED,{count:U.length,added:Q.length,removed:G.length,unchanged:U.length-Q.length,timestamp:Date.now()})}emitRuleEvent(U,X){try{if(N0)N0.emit(U,{...X,timestamp:Date.now()})}catch(q){console.warn(`Could not emit event ${U}:`,q)}}getRules(){return[...this.rules]}checkCooldown(U,X){let q=this.lastExecution.get(U);if(!q)return!1;return Date.now()-q<X}shouldEvaluateAll(){return this.config?.globalSettings?.evaluateAll??!0}getStateContext(){return{}}evaluateConditions(U,X){if(!U)return!0;if(Array.isArray(U))return U.every((q)=>this.evaluateSingleCondition(q,X));return this.evaluateSingleCondition(U,X)}evaluateSingleCondition(U,X){if("operator"in U&&"conditions"in U){let G=U;if(G.operator==="OR")return G.conditions.some((Y)=>this.evaluateSingleCondition(Y,X));else return G.conditions.every((Y)=>this.evaluateSingleCondition(Y,X))}let q=U,Z=e.evaluate(q.field,X),Q=q.value;if(typeof Q==="string"&&Q.includes("${"))Q=e.interpolate(Q,X);return Y6.compare(Z,q.operator,Q)}async executeRuleActions(U,X){let q=[],Z=[],Q="ALL";if(Array.isArray(U))Z=U;else if(U&&typeof U==="object"&&"mode"in U&&"actions"in U){let G=U;Q=G.mode,Z=G.actions}else Z=[U];if(Q==="EITHER"&&Z.length>0){let G=Z.reduce((H,W)=>H+(W.probability||1),0),Y=Math.random()*G,J;for(let H of Z){let W=H.probability||1;if(Y-=W,Y<=0){J=H;break}}if(!J&&Z.length>0)J=Z[Z.length-1];if(J)Z=[J];else Z=[]}for(let G of Z){let Y=await this.executeSingleAction(G,X);q.push(Y)}return q}async executeSingleAction(U,X){if(!U.type&&!U.run&&!U.break&&!U.continue){let G=["params","run","delay","probability","if","then","else","break","continue","mode","actions"],Y=Object.keys(U).filter((J)=>!G.includes(J));for(let J of Y){if(U.type=J,typeof U[J]==="string")U.params={...U.params,message:U[J],content:U[J]};else if(typeof U[J]==="object"&&U[J]!==null)U.params={...U.params,...U[J]};break}}if(U.run)try{return{type:"RUN",result:Function("context","state","data","vars","env","helpers",`with(context) { ${U.run} }`)(X,X.state,X.data,X.vars,X.env,X.helpers),timestamp:Date.now()}}catch(G){return{type:"RUN",error:String(G),timestamp:Date.now()}}let q=U.probability;if(typeof q==="string"){let G=e.evaluate(q,X);q=typeof G==="number"?G:Number(G)}if(q!==void 0&&Math.random()>q)return{type:U.type||"skipped",timestamp:Date.now(),result:{skipped:"probability check failed"}};let Z=U.delay;if(typeof Z==="string"){let G=e.evaluate(Z,X);Z=typeof G==="number"?G:Number(G)}if(Z&&Z>0)await new Promise((G)=>setTimeout(G,Z));let Q=this.interpolateParams(U.params||{},X);try{let G;try{let{ActionRegistry:J}=await Promise.resolve().then(() => (Q2(),VX)),H=J.getInstance().get(U.type);if(H)G=(W)=>H({...U,params:W},X)}catch{G=this.actionHandlers.get(U.type)}let Y;if(G)Y=await G(Q,X);else{let J=`No handler registered for action type: ${U.type}`;console.warn(J),Y={warning:J}}return{type:U.type,result:Y,timestamp:Date.now()}}catch(G){return console.error(`Error executing action ${U.type}:`,G),{type:U.type,error:String(G),timestamp:Date.now()}}}interpolateParams(U,X){let q={};for(let[Z,Q]of Object.entries(U))if(typeof Q==="string")q[Z]=e.interpolate(Q,X);else if(typeof Q==="object"&&Q!==null&&!Array.isArray(Q))q[Z]=this.interpolateDeep(Q,X);else q[Z]=Q;return q}interpolateDeep(U,X){if(typeof U==="string")return e.interpolate(U,X);if(Array.isArray(U))return U.map((q)=>this.interpolateDeep(q,X));if(typeof U==="object"&&U!==null){let q={};for(let Z in U)q[Z]=this.interpolateDeep(U[Z],X);return q}return U}get rules(){return[...this._rules]}get config(){return this._config}set rules(U){this._rules=[...U],this.sortRules()}}Q2();P1();class g4 extends G2{actionRegistry;stateManager;constructor(U){super(U);this.actionRegistry=I1.getInstance(),this.stateManager=U0.getInstance()}async processEvent(U){let X=[];if(U.state=this.stateManager.getLiveProxy(),this.config?.stateConfig)await this.stateManager.applyConfig(this.config.stateConfig);if(N0.emit("engine:start",{context:U,rulesCount:this.rules.length}),this.config?.globalSettings?.debugMode)console.log(`[RuleEngine] Evaluating context with ${this.rules.length} rules for event: ${U.event}`);let q=this.rules.filter((Z)=>Z.enabled!==!1&&Z.on===U.event);for(let Z of q){if(Z.cooldown&&this.checkCooldown(Z.id,Z.cooldown)){if(this.config?.globalSettings?.debugMode)console.log(`[RuleEngine] Rule ${Z.id} in cooldown`);continue}if(this.evaluateConditions(Z.if,U)){if(this.config?.globalSettings?.debugMode)console.log(`[RuleEngine] Executing rule: ${Z.name||Z.id}`);N0.emit("rule:match",{rule:Z,context:U});let G=await this.executeRuleActionsWithRegistry(Z.do,U);if(X.push({ruleId:Z.id,executedActions:G,success:!0}),this.updateLastExecution(Z.id),!this.shouldEvaluateAll())break}}return N0.emit("engine:done",{results:X,context:U}),X}async processEventSimple(U,X={},q={}){let Z={event:U,data:X,vars:q,timestamp:Date.now(),state:this.stateManager.getLiveProxy()};return this.processEvent(Z)}async executeRuleActionsWithRegistry(U,X){let q=[],Z=[],Q="ALL";if(Array.isArray(U))Z=U;else if(this.isActionGroup(U)){let G=U;Q=G.mode,Z=G.actions}else Z=[U];if(Q==="EITHER"&&Z.length>0){let G=Z.reduce((H,W)=>H+(W.probability||1),0),Y=Math.random()*G,J;for(let H of Z){let W=H.probability||1;if(Y-=W,Y<=0){J=H;break}}if(J)Z=[J]}for(let G of Z){let Y=await this.executeSingleActionWithRegistry(G,X);q.push(Y)}return q}isActionGroup(U){return typeof U==="object"&&U!==null&&"mode"in U&&"actions"in U}async executeSingleActionWithRegistry(U,X){if(!U.type&&!U.run&&!U.break&&!U.continue){let G=Object.keys(U);for(let Y of G)if(this.actionRegistry.get(Y)){if(U.type=Y,typeof U[Y]==="string")U.params={...U.params,message:U[Y],content:U[Y]};else if(typeof U[Y]==="object"&&U[Y]!==null)U.params={...U.params,...U[Y]};break}}if(U.run)try{return{type:"RUN",result:Function("context","state","data","vars","env","helpers",`with(context) { ${U.run} }`)(X,X.state,X.data,X.vars,X.env,X.helpers),timestamp:Date.now()}}catch(G){return{type:"RUN",error:String(G),timestamp:Date.now()}}let q=U.probability;if(typeof q==="string"){let{ExpressionEngine:G}=AX(j4),Y=G.evaluate(q,X);q=typeof Y==="number"?Y:Number(Y)}if(q!==void 0&&Math.random()>q)return{type:U.type||"unknown",timestamp:Date.now(),result:{skipped:"probability check failed"}};if(U.break)return{type:"BREAK",result:"Break action",timestamp:Date.now()};if(U.continue)return{type:"CONTINUE",result:"Continue action",timestamp:Date.now()};let Z=U.delay;if(typeof Z==="string"){let{ExpressionEngine:G}=AX(j4),Y=G.evaluate(Z,X);Z=typeof Y==="number"?Y:Number(Y)}if(Z&&Z>0)await new Promise((G)=>setTimeout(G,Z));let Q=this.interpolateParams(U.params||{},X);try{let G=this.actionRegistry.get(U.type),Y;if(G)Y=await G({...U,params:Q},X);else{let J=`Generic or unknown action type: ${U.type}`;if(this.config?.globalSettings?.strictActions)throw Error(J);console.warn(J),Y={warning:`Generic action executed: ${U.type}`}}return N0.emit("action:success",{action:{...U,params:Q},context:X,result:Y}),{type:U.type,result:Y,timestamp:Date.now()}}catch(G){return console.error("Error executing action:",U,G),N0.emit("action:error",{action:U,context:X,error:String(G)}),{type:U.type,error:String(G),timestamp:Date.now()}}}updateLastExecution(U){this.lastExecution.set(U,Date.now())}getStateContext(){return this.stateManager.getAll()}shouldEvaluateAll(){return this.config?.globalSettings?.evaluateAll??!0}async executeRuleActions(U,X){return this.executeRuleActionsWithRegistry(U,X)}async executeSingleAction(U,X){return this.executeSingleActionWithRegistry(U,X)}}Q2();P1();class UG{static create(U,X,q={}){return{event:U,timestamp:Date.now(),data:typeof X==="object"&&X!==null?X:{value:X},vars:q,state:U0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static fromRequest(U,X,q={}){let Z=new URL(U.url);return{event:"HTTP_REQUEST",timestamp:Date.now(),data:{method:U.method,path:Z.pathname,query:Object.fromEntries(Z.searchParams),headers:(()=>{let Q={};return U.headers.forEach((G,Y)=>Q[Y]=G),Q})(),body:X||{}},vars:{...q,ip:U.headers.get("x-forwarded-for")||"unknown"},state:U0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static fromWebhook(U,X,q,Z={}){return{event:`WEBHOOK_${U.toUpperCase()}_${X.toUpperCase()}`,timestamp:Date.now(),data:q,vars:{...Z,provider:U},state:U0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static getDefaultHelpers(){return{now:()=>Date.now(),uuid:()=>crypto.randomUUID(),jsonParse:(U)=>typeof U==="string"?JSON.parse(U):null,jsonStringify:(U)=>JSON.stringify(U)}}}P1();Q2();P1();var l0=(U)=>Array.isArray(U)?U:[U],RX=(U,X)=>{let q=[[],[]];for(let Z of U)if(X(Z))q[0].push(Z);else q[1].push(Z);return q},W6=Array,F0=(U,X)=>U.includes(X),DX=(U,X=0)=>[...Array(U)].map((q,Z)=>Z+X),g=(U,X,q)=>{if(U===void 0)return X===void 0?[]:Array.isArray(X)?X:[X];if(q?.prepend)if(Array.isArray(X))U.unshift(...X);else U.unshift(X);else if(Array.isArray(X))U.push(...X);else U.push(X);return U},g0=(U,X)=>{if(X===void 0||X===null)return U??[];if(U===void 0||U===null)return l0(X);return U.concat(X)},MX=(...U)=>U.reduce(g0,[]),C0=(U,X,q)=>{if(U===void 0)return Array.isArray(X)?X:[X];let Z=q?.isEqual??((Q,G)=>Q===G);for(let Q of l0(X))if(!U.some((G)=>Z(G,Q)))U.push(Q);return U},wX=(U,X)=>U.reduce((q,Z)=>{let Q=Z[X];return q[Q]=g(q[Q],Z),q},{}),y0=(U,X,q)=>U.length===X.length&&U.every(q?.isEqual?(Z,Q)=>q.isEqual(Z,X[Q]):(Z,Q)=>Z===X[Q]);var G0=(U,X)=>r(U)===X,r=(U)=>{let X=typeof U;return X==="object"?U===null?"null":"object":X==="function"?"object":X},Y0={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},PX={...Y0,function:"a function"};class IX extends Error{}var y=(U)=>Y1(U,IX),Y1=(U,X=Error)=>{throw new X(U)};class Y2 extends Error{name="ParseError"}var F=(U)=>Y1(U,Y2),D0=(U)=>` ${U}`,KX="​";var S=(U,X)=>{let q={},Z=Array.isArray(U),Q=!1;for(let[G,Y]of Object.entries(U).entries()){let J=Z?X(G,Y[1]):X(...Y,G);Q||=typeof J[0]==="number";let H=Array.isArray(J[0])||J.length===0?J:[J];for(let[W,$]of H)if(typeof W==="object")q[W.group]=g(q[W.group],$);else q[W]=$}return Q?Object.values(q):q};var y4=Object.entries;var n=(U,X)=>(U in X),K1=(U,X)=>(X in U);class k4{constructor(U){Object.assign(this,U)}}var NX=class{};class J2 extends NX{}var XG=(U,X)=>{let q={},Z={},Q;for(Q in U)if(Q in X)q[Q]=U[Q];else Z[Q]=U[Q];return[q,Z]};var _6=(U,X)=>XG(U,X)[1],S0=(U)=>Object.keys(U).length===0,J1=(U)=>[...Object.entries(U),...Object.getOwnPropertySymbols(U).map((X)=>[X,U[X]])],CX=(U,X)=>Object.defineProperties(U,Object.getOwnPropertyDescriptors(X)),SX=(U)=>{let X=Object.keys(U).sort(),q={};for(let Z=0;Z<X.length;Z++)q[X[Z]]=U[X[Z]];return q};var J0=D0(`unset${KX}`),EX=(U)=>Object.values(U).filter((X)=>{if(typeof X==="number")return!0;return typeof U[X]!=="number"});var v4={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},h4=globalThis.File??Blob,x4={ArrayBuffer,Blob,File:h4,FormData,Headers,Request,Response,URL},qG={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},H1={...v4,...x4,...qG,String,Number,Boolean},H2=(U)=>{let X=Object.getPrototypeOf(U);while(X?.constructor&&(!n(X.constructor.name,H1)||!(U instanceof H1[X.constructor.name])))X=Object.getPrototypeOf(X);let q=X?.constructor?.name;if(q===void 0||q==="Object")return;return q},W2=(U)=>typeof U==="object"&&U!==null?H2(U)??"object":r(U);var h=Array.isArray,ZG={Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},QG={ArrayBuffer:"an ArrayBuffer instance",Blob:"a Blob instance",File:"a File instance",FormData:"a FormData instance",Headers:"a Headers instance",Request:"a Request instance",Response:"a Response instance",URL:"a URL instance"},GG={Int8Array:"an Int8Array",Uint8Array:"a Uint8Array",Uint8ClampedArray:"a Uint8ClampedArray",Int16Array:"an Int16Array",Uint16Array:"a Uint16Array",Int32Array:"an Int32Array",Uint32Array:"a Uint32Array",Float32Array:"a Float32Array",Float64Array:"a Float64Array",BigInt64Array:"a BigInt64Array",BigUint64Array:"a BigUint64Array"},jX={...ZG,...QG,...GG},_2=(U)=>{let X=Object(U).name??null;return X&&n(X,H1)&&H1[X]===U?X:null};var u4=(U,X)=>{let q=U.prototype;while(q!==null){if(q===X.prototype)return!0;q=Object.getPrototypeOf(q)}return!1};var bX=(U)=>fX(U,new Map),fX=(U,X)=>{if(typeof U!=="object"||U===null)return U;if(X?.has(U))return X.get(U);let q=_2(U.constructor);if(q==="Date")return new Date(U.getTime());if(q&&q!=="Array")return U;let Z=Array.isArray(U)?U.slice():Object.create(Object.getPrototypeOf(U)),Q=Object.getOwnPropertyDescriptors(U);if(X){X.set(U,Z);for(let G in Q){let Y=Q[G];if("get"in Y||"set"in Y)continue;Y.value=fX(Y.value,X)}}return Object.defineProperties(Z,Q),Z};var YG=(U)=>{let X=J0;return()=>X===J0?X=U():X},d0=(U)=>typeof U==="function"&&U.length===0;var gX=class extends Function{constructor(...U){let X=U.slice(0,-1),q=U[U.length-1];try{super(...X,q)}catch(Z){return y(`Encountered an unexpected error while compiling your definition:
139
+ `,X)+1}return{type:U,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(U){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let X=C4(U),q=X2(X);return q.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let X=C4(U),q=X2(X);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(U,X){if(this.type!=="comment")return!1;if(this.indent<=X)return!1;return U.every((q)=>q.type==="newline"||q.type==="space")}*documentEnd(U){if(this.type!=="doc-mode"){if(U.end)U.end.push(this.sourceToken);else U.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(U){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(U.end)U.end.push(this.sourceToken);else U.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}QA.Parser=xQ});var dQ=R((zA)=>{var uQ=nU(),YA=e2(),G6=U6(),JA=YU(),HA=k(),WA=YX(),mQ=JX();function pQ(U){let X=U.prettyErrors!==!1;return{lineCounter:U.lineCounter||X&&new WA.LineCounter||null,prettyErrors:X}}function _A(U,X={}){let{lineCounter:q,prettyErrors:Z}=pQ(X),Q=new mQ.Parser(q?.addNewLine),G=new uQ.Composer(X),Y=Array.from(G.compose(Q.parse(U)));if(Z&&q)for(let J of Y)J.errors.forEach(G6.prettifyError(U,q)),J.warnings.forEach(G6.prettifyError(U,q));if(Y.length>0)return Y;return Object.assign([],{empty:!0},G.streamInfo())}function lQ(U,X={}){let{lineCounter:q,prettyErrors:Z}=pQ(X),Q=new mQ.Parser(q?.addNewLine),G=new uQ.Composer(X),Y=null;for(let J of G.compose(Q.parse(U),!0,U.length))if(!Y)Y=J;else if(Y.options.logLevel!=="silent"){Y.errors.push(new G6.YAMLParseError(J.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(Z&&q)Y.errors.forEach(G6.prettifyError(U,q)),Y.warnings.forEach(G6.prettifyError(U,q));return Y}function $A(U,X,q){let Z=void 0;if(typeof X==="function")Z=X;else if(q===void 0&&X&&typeof X==="object")q=X;let Q=lQ(U,q);if(!Q)return null;if(Q.warnings.forEach((G)=>JA.warn(Q.options.logLevel,G)),Q.errors.length>0)if(Q.options.logLevel!=="silent")throw Q.errors[0];else Q.errors=[];return Q.toJS(Object.assign({reviver:Z},q))}function LA(U,X,q){let Z=null;if(typeof X==="function"||Array.isArray(X))Z=X;else if(q===void 0&&X)q=X;if(typeof q==="string")q=q.length;if(typeof q==="number"){let Q=Math.round(q);q=Q<1?void 0:Q>8?{indent:8}:{indent:Q}}if(U===void 0){let{keepUndefined:Q}=q??X??{};if(!Q)return}if(HA.isDocument(U)&&!Z)return U.toString(q);return new YA.Document(U,Z,q).toString(q)}zA.parse=$A;zA.parseAllDocuments=_A;zA.parseDocument=lQ;zA.stringify=LA});var WX=R((EA)=>{var TA=nU(),VA=e2(),RA=gU(),HX=U6(),DA=h2(),G1=k(),MA=U1(),wA=i(),PA=q1(),IA=Z1(),KA=K4(),NA=GX(),CA=YX(),SA=JX(),S4=dQ(),cQ=k2();EA.Composer=TA.Composer;EA.Document=VA.Document;EA.Schema=RA.Schema;EA.YAMLError=HX.YAMLError;EA.YAMLParseError=HX.YAMLParseError;EA.YAMLWarning=HX.YAMLWarning;EA.Alias=DA.Alias;EA.isAlias=G1.isAlias;EA.isCollection=G1.isCollection;EA.isDocument=G1.isDocument;EA.isMap=G1.isMap;EA.isNode=G1.isNode;EA.isPair=G1.isPair;EA.isScalar=G1.isScalar;EA.isSeq=G1.isSeq;EA.Pair=MA.Pair;EA.Scalar=wA.Scalar;EA.YAMLMap=PA.YAMLMap;EA.YAMLSeq=IA.YAMLSeq;EA.CST=KA;EA.Lexer=NA.Lexer;EA.LineCounter=CA.LineCounter;EA.Parser=SA.Parser;EA.parse=S4.parse;EA.parseAllDocuments=S4.parseAllDocuments;EA.parseDocument=S4.parseDocument;EA.stringify=S4.stringify;EA.visit=cQ.visit;EA.visitAsync=cQ.visitAsync});class ZG{queue=[];engine;config;timer=null;isProcessing=!1;constructor(U,X={maxBatchSize:10,flushIntervalMs:100}){this.engine=U,this.config=X}push(U){if(this.queue.push(U),this.queue.length>=this.config.maxBatchSize)this.processQueue();else if(!this.timer)this.timer=setTimeout(()=>this.processQueue(),this.config.flushIntervalMs)}async processQueue(){if(this.isProcessing)return;if(this.isProcessing=!0,this.timer)clearTimeout(this.timer),this.timer=null;let U=this.queue.splice(0,this.config.maxBatchSize);if(U.length===0){this.isProcessing=!1;return}console.debug(`[EventQueue] Processing batch of ${U.length} events.`);for(let X of U)try{await this.engine.evaluateContext(X)}catch(q){console.error(`[EventQueue] Error processing event ${X.event}:`,q)}if(this.queue.length>0)setTimeout(()=>this.processQueue(),0);this.isProcessing=!1}getQueueLength(){return this.queue.length}}class QG{keyPrefix;cache=new Map;isLoaded=!1;constructor(U="trigger_system:"){this.keyPrefix=U}isAvailable(){return typeof window<"u"&&typeof window.localStorage<"u"}ensureLoaded(){if(this.isLoaded)return;if(this.isAvailable())try{let U=window.localStorage.getItem(this.keyPrefix+"state");if(U){let X=JSON.parse(U);this.cache=new Map(Object.entries(X))}}catch(U){console.error("[BrowserPersistence] Failed to load from localStorage:",U)}this.isLoaded=!0}persist(){if(this.isAvailable())try{let U=Object.fromEntries(this.cache);window.localStorage.setItem(this.keyPrefix+"state",JSON.stringify(U))}catch(U){console.error("[BrowserPersistence] Failed to save to localStorage:",U)}}async loadState(){return this.ensureLoaded(),new Map(this.cache)}async saveState(U,X){this.ensureLoaded(),this.cache.set(U,X),this.persist()}async deleteState(U){this.ensureLoaded(),this.cache.delete(U),this.persist()}async clearState(){this.cache.clear(),this.persist()}}class Y6{static getNestedValue(U,X){let q=U.split("."),Z=X;for(let Q of q){if(Z===null||Z===void 0)return;if(typeof Z==="object"&&Z!==null&&Q in Z)Z=Z[Q];else return}return Z}static interpolate(U,X){if(typeof U!=="string")return U;return U.replace(/\$\{([^}]+)\}/g,(q,Z)=>{let Q=this.getNestedValue(Z,X);if(Q!==void 0)return String(Q);return q})}static compare(U,X,q){switch(X){case"EQ":case"==":return U==q;case"NEQ":case"!=":return U!=q;case"GT":case">":return Number(U)>Number(q);case"GTE":case">=":return Number(U)>=Number(q);case"LT":case"<":return Number(U)<Number(q);case"LTE":case"<=":return Number(U)<=Number(q);case"IN":return Array.isArray(q)&&q.some((Z)=>Z===U);case"NOT_IN":return Array.isArray(q)&&!q.some((Z)=>Z===U);case"CONTAINS":if(Array.isArray(U)||typeof U==="string")return U.includes(q);return!1;case"NOT_CONTAINS":if(Array.isArray(U)||typeof U==="string")return!U.includes(q);return!1;case"STARTS_WITH":if(typeof U==="string"&&typeof q==="string")return U.startsWith(q);return!1;case"ENDS_WITH":if(typeof U==="string"&&typeof q==="string")return U.endsWith(q);return!1;case"IS_EMPTY":if(typeof U==="string")return U==="";if(Array.isArray(U))return U.length===0;if(U===null||U===void 0)return!0;if(typeof U==="object")return Object.keys(U).length===0;return!1;case"IS_NULL":case"IS_NONE":return U===null||U===void 0;case"HAS_KEY":if(typeof U==="object"&&U!==null&&typeof q==="string")return q in U;return!1;case"MATCHES":if(typeof q==="string")return new RegExp(q).test(String(U));return!1;case"RANGE":if(Array.isArray(q)&&q.length===2){let Z=Number(U),Q=Number(q[0]),G=Number(q[1]);return!isNaN(Z)&&!isNaN(Q)&&!isNaN(G)&&Z>=Q&&Z<=G}return!1;default:return console.warn(`Unknown operator: ${X}`),!1}}}var J6;((G)=>{G.ENGINE_START="engine:start";G.ENGINE_DONE="engine:done";G.RULE_MATCH="rule:match";G.ACTION_SUCCESS="action:success";G.ACTION_ERROR="action:error"})(J6||={});var VX;((Z)=>{Z.RULE_ADDED="rule:added";Z.RULE_REMOVED="rule:removed";Z.RULE_UPDATED="rule:updated"})(VX||={});var VO=J6,H6=VX;class f4{static instance;handlers=new Map;constructor(){}static getInstance(){if(!this.instance)this.instance=new f4;return this.instance}on(U,X){let q=U;if(!this.handlers.has(q))this.handlers.set(q,new Set);return this.handlers.get(q).add(X),()=>this.off(q,X)}off(U,X){let q=U,Z=this.handlers.get(q);if(Z)Z.delete(X)}emit(U,X){let q=U,Z=this.handlers.get(q);if(Z)Z.forEach((Q)=>{try{Q(X)}catch(G){console.error(`Error in event handler for ${q}:`,G)}})}}var N0=f4.getInstance();class G2{_rules=[];actionHandlers=new Map;lastExecution=new Map;_config;constructor(U=[]){if(Array.isArray(U))this._rules=U;else this._config=U,this._rules=[...U.rules];this.sortRules()}sortRules(){this._rules.sort((U,X)=>(X.priority||0)-(U.priority||0))}registerAction(U,X){this.actionHandlers.set(U,X)}async processEvent(U){let X=[];if(!U.state)U.state={};let q=this._rules.filter((Z)=>Z.enabled!==!1&&Z.on===U.event);for(let Z of q){if(Z.cooldown&&this.checkCooldown(Z.id,Z.cooldown))continue;if(this.evaluateConditions(Z.if,U)){let Q=await this.executeRuleActions(Z.do,U);if(this.lastExecution.set(Z.id,Date.now()),X.push({ruleId:Z.id,success:!0,executedActions:Q}),!this.shouldEvaluateAll())break}}return X}async processEventSimple(U,X={},q={}){let Z={event:U,data:X,vars:q,timestamp:Date.now(),state:this.getStateContext?this.getStateContext():{}};return this.processEvent(Z)}updateRules(U){let X=this.getRules(),q=new Set(X.map((Y)=>Y.id)),Z=new Set(U.map((Y)=>Y.id)),Q=U.filter((Y)=>!q.has(Y.id)),G=X.filter((Y)=>!Z.has(Y.id));this.rules=[...U],this.sortRules(),Q.forEach((Y)=>{this.emitRuleEvent(H6.RULE_ADDED,{ruleId:Y.id,timestamp:Date.now()})}),G.forEach((Y)=>{this.emitRuleEvent(H6.RULE_REMOVED,{ruleId:Y.id,timestamp:Date.now()})}),this.emitRuleEvent(H6.RULE_UPDATED,{count:U.length,added:Q.length,removed:G.length,unchanged:U.length-Q.length,timestamp:Date.now()})}emitRuleEvent(U,X){try{if(N0)N0.emit(U,{...X,timestamp:Date.now()})}catch(q){console.warn(`Could not emit event ${U}:`,q)}}getRules(){return[...this.rules]}checkCooldown(U,X){let q=this.lastExecution.get(U);if(!q)return!1;return Date.now()-q<X}shouldEvaluateAll(){return this.config?.globalSettings?.evaluateAll??!0}getStateContext(){return{}}evaluateConditions(U,X){if(!U)return!0;if(Array.isArray(U))return U.every((q)=>this.evaluateSingleCondition(q,X));return this.evaluateSingleCondition(U,X)}evaluateSingleCondition(U,X){if("operator"in U&&"conditions"in U){let G=U;if(G.operator==="OR")return G.conditions.some((Y)=>this.evaluateSingleCondition(Y,X));else return G.conditions.every((Y)=>this.evaluateSingleCondition(Y,X))}let q=U,Z=e.evaluate(q.field,X),Q=q.value;if(typeof Q==="string"&&Q.includes("${"))Q=e.interpolate(Q,X);return Y6.compare(Z,q.operator,Q)}async executeRuleActions(U,X){let q=[],Z=[],Q="ALL";if(Array.isArray(U))Z=U;else if(U&&typeof U==="object"&&"mode"in U&&"actions"in U){let Y=U;Q=Y.mode,Z=Y.actions}else Z=[U];if(Q==="EITHER"&&Z.length>0){let Y=Z.reduce((W,$)=>W+($.probability||1),0),J=Math.random()*Y,H;for(let W of Z){let $=W.probability||1;if(J-=$,J<=0){H=W;break}}if(!H&&Z.length>0)H=Z[Z.length-1];if(H)Z=[H];else Z=[]}let G=!1;for(let Y of Z){if(G)break;if("if"in Y&&Y.if&&(Y.then||Y.else)){let H=this.evaluateConditions(Y.if,X);if(H&&Y.then){let W=await this.executeRuleActions(Y.then,X);q.push(...W)}else if(!H&&Y.else){let W=await this.executeRuleActions(Y.else,X);q.push(...W)}continue}if("if"in Y&&Y.if){if(!this.evaluateConditions(Y.if,X))continue}if(Y.break){G=!0,q.push({type:"BREAK",result:"Breaking action execution",timestamp:Date.now()});break}if(Y.continue){q.push({type:"CONTINUE",result:"Skipping remaining actions",timestamp:Date.now()});continue}let J=await this.executeSingleAction(Y,X);q.push(J)}return q}async executeSingleAction(U,X){if(!U.type&&!U.run&&!U.break&&!U.continue){let G=["params","run","delay","probability","if","then","else","break","continue","mode","actions"],Y=Object.keys(U).filter((J)=>!G.includes(J));for(let J of Y){if(U.type=J,typeof U[J]==="string")U.params={...U.params,message:U[J],content:U[J]};else if(typeof U[J]==="object"&&U[J]!==null)U.params={...U.params,...U[J]};break}}if(U.run)try{return{type:"RUN",result:Function("context","state","data","vars","env","helpers",`with(context) { ${U.run} }`)(X,X.state,X.data,X.vars,X.env,X.helpers),timestamp:Date.now()}}catch(G){return{type:"RUN",error:String(G),timestamp:Date.now()}}let q=U.probability;if(typeof q==="string"){let G=e.evaluate(q,X);q=typeof G==="number"?G:Number(G)}if(q!==void 0&&Math.random()>q)return{type:U.type||"skipped",timestamp:Date.now(),result:{skipped:"probability check failed"}};let Z=U.delay;if(typeof Z==="string"){let G=e.evaluate(Z,X);Z=typeof G==="number"?G:Number(G)}if(Z&&Z>0)await new Promise((G)=>setTimeout(G,Z));let Q=this.interpolateParams(U.params||{},X);try{let G;try{let{ActionRegistry:J}=await Promise.resolve().then(() => (Q2(),RX)),H=J.getInstance().get(U.type);if(H)G=(W)=>H({...U,params:W},X)}catch{G=this.actionHandlers.get(U.type)}let Y;if(G)Y=await G(Q,X);else{let J=`No handler registered for action type: ${U.type}`;console.warn(J),Y={warning:J}}return{type:U.type,result:Y,timestamp:Date.now()}}catch(G){return console.error(`Error executing action ${U.type}:`,G),{type:U.type,error:String(G),timestamp:Date.now()}}}interpolateParams(U,X){let q={};for(let[Z,Q]of Object.entries(U))if(typeof Q==="string")q[Z]=e.interpolate(Q,X);else if(typeof Q==="object"&&Q!==null&&!Array.isArray(Q))q[Z]=this.interpolateDeep(Q,X);else q[Z]=Q;return q}interpolateDeep(U,X){if(typeof U==="string")return e.interpolate(U,X);if(Array.isArray(U))return U.map((q)=>this.interpolateDeep(q,X));if(typeof U==="object"&&U!==null){let q={};for(let Z in U)q[Z]=this.interpolateDeep(U[Z],X);return q}return U}get rules(){return[...this._rules]}get config(){return this._config}set rules(U){this._rules=[...U],this.sortRules()}}Q2();P1();class g4 extends G2{actionRegistry;stateManager;constructor(U){super(U);this.actionRegistry=I1.getInstance(),this.stateManager=U0.getInstance()}async processEvent(U){let X=[];if(U.state=this.stateManager.getLiveProxy(),this.config?.stateConfig)await this.stateManager.applyConfig(this.config.stateConfig);if(N0.emit("engine:start",{context:U,rulesCount:this.rules.length}),this.config?.globalSettings?.debugMode)console.log(`[RuleEngine] Evaluating context with ${this.rules.length} rules for event: ${U.event}`);let q=this.rules.filter((Z)=>Z.enabled!==!1&&Z.on===U.event);for(let Z of q){if(Z.cooldown&&this.checkCooldown(Z.id,Z.cooldown)){if(this.config?.globalSettings?.debugMode)console.log(`[RuleEngine] Rule ${Z.id} in cooldown`);continue}if(this.evaluateConditions(Z.if,U)){if(this.config?.globalSettings?.debugMode)console.log(`[RuleEngine] Executing rule: ${Z.name||Z.id}`);N0.emit("rule:match",{rule:Z,context:U});let G=await this.executeRuleActionsWithRegistry(Z.do,U);if(X.push({ruleId:Z.id,executedActions:G,success:!0}),this.updateLastExecution(Z.id),!this.shouldEvaluateAll())break}}return N0.emit("engine:done",{results:X,context:U}),X}async processEventSimple(U,X={},q={}){let Z={event:U,data:X,vars:q,timestamp:Date.now(),state:this.stateManager.getLiveProxy()};return this.processEvent(Z)}async executeRuleActionsWithRegistry(U,X){let q=[],Z=[],Q="ALL";if(Array.isArray(U))Z=U;else if(this.isActionGroup(U)){let Y=U;Q=Y.mode,Z=Y.actions}else Z=[U];if(Q==="EITHER"&&Z.length>0){let Y=Z.reduce((W,$)=>W+($.probability||1),0),J=Math.random()*Y,H;for(let W of Z){let $=W.probability||1;if(J-=$,J<=0){H=W;break}}if(H)Z=[H]}let G=!1;for(let Y of Z){if(G)break;if("if"in Y&&Y.if&&(Y.then||Y.else)){let H=this.evaluateConditions(Y.if,X);if(H&&Y.then){let W=await this.executeRuleActionsWithRegistry(Y.then,X);q.push(...W)}else if(!H&&Y.else){let W=await this.executeRuleActionsWithRegistry(Y.else,X);q.push(...W)}continue}if("if"in Y&&Y.if){if(!this.evaluateConditions(Y.if,X))continue}if(Y.break){G=!0,q.push({type:"BREAK",result:"Breaking action execution",timestamp:Date.now()});break}if(Y.continue){q.push({type:"CONTINUE",result:"Skipping remaining actions",timestamp:Date.now()});continue}let J=await this.executeSingleActionWithRegistry(Y,X);q.push(J)}return q}isActionGroup(U){return typeof U==="object"&&U!==null&&"mode"in U&&"actions"in U}async executeSingleActionWithRegistry(U,X){if(!U.type&&!U.run&&!U.break&&!U.continue){let G=Object.keys(U);for(let Y of G)if(this.actionRegistry.get(Y)){if(U.type=Y,typeof U[Y]==="string")U.params={...U.params,message:U[Y],content:U[Y]};else if(typeof U[Y]==="object"&&U[Y]!==null)U.params={...U.params,...U[Y]};break}}if(U.run)try{return{type:"RUN",result:Function("context","state","data","vars","env","helpers",`with(context) { ${U.run} }`)(X,X.state,X.data,X.vars,X.env,X.helpers),timestamp:Date.now()}}catch(G){return{type:"RUN",error:String(G),timestamp:Date.now()}}let q=U.probability;if(typeof q==="string"){let{ExpressionEngine:G}=OX(j4),Y=G.evaluate(q,X);q=typeof Y==="number"?Y:Number(Y)}if(q!==void 0&&Math.random()>q)return{type:U.type||"unknown",timestamp:Date.now(),result:{skipped:"probability check failed"}};if(U.break)return{type:"BREAK",result:"Break action",timestamp:Date.now()};if(U.continue)return{type:"CONTINUE",result:"Continue action",timestamp:Date.now()};let Z=U.delay;if(typeof Z==="string"){let{ExpressionEngine:G}=OX(j4),Y=G.evaluate(Z,X);Z=typeof Y==="number"?Y:Number(Y)}if(Z&&Z>0)await new Promise((G)=>setTimeout(G,Z));let Q=this.interpolateParams(U.params||{},X);try{let G=this.actionRegistry.get(U.type),Y;if(G)Y=await G({...U,params:Q},X);else{let J=`Generic or unknown action type: ${U.type}`;if(this.config?.globalSettings?.strictActions)throw Error(J);console.warn(J),Y={warning:`Generic action executed: ${U.type}`}}return N0.emit("action:success",{action:{...U,params:Q},context:X,result:Y}),{type:U.type,result:Y,timestamp:Date.now()}}catch(G){return console.error("Error executing action:",U,G),N0.emit("action:error",{action:U,context:X,error:String(G)}),{type:U.type,error:String(G),timestamp:Date.now()}}}updateLastExecution(U){this.lastExecution.set(U,Date.now())}getStateContext(){return this.stateManager.getAll()}shouldEvaluateAll(){return this.config?.globalSettings?.evaluateAll??!0}async executeRuleActions(U,X){return this.executeRuleActionsWithRegistry(U,X)}async executeSingleAction(U,X){return this.executeSingleActionWithRegistry(U,X)}}Q2();P1();class GG{static create(U,X,q={}){return{event:U,timestamp:Date.now(),data:typeof X==="object"&&X!==null?X:{value:X},vars:q,state:U0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static fromRequest(U,X,q={}){let Z=new URL(U.url);return{event:"HTTP_REQUEST",timestamp:Date.now(),data:{method:U.method,path:Z.pathname,query:Object.fromEntries(Z.searchParams),headers:(()=>{let Q={};return U.headers.forEach((G,Y)=>Q[Y]=G),Q})(),body:X||{}},vars:{...q,ip:U.headers.get("x-forwarded-for")||"unknown"},state:U0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static fromWebhook(U,X,q,Z={}){return{event:`WEBHOOK_${U.toUpperCase()}_${X.toUpperCase()}`,timestamp:Date.now(),data:q,vars:{...Z,provider:U},state:U0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static getDefaultHelpers(){return{now:()=>Date.now(),uuid:()=>crypto.randomUUID(),jsonParse:(U)=>{try{return typeof U==="string"?JSON.parse(U):null}catch{return null}},jsonStringify:(U)=>{try{return JSON.stringify(U)}catch{return null}}}}}P1();Q2();P1();var l0=(U)=>Array.isArray(U)?U:[U],DX=(U,X)=>{let q=[[],[]];for(let Z of U)if(X(Z))q[0].push(Z);else q[1].push(Z);return q},W6=Array,F0=(U,X)=>U.includes(X),MX=(U,X=0)=>[...Array(U)].map((q,Z)=>Z+X),g=(U,X,q)=>{if(U===void 0)return X===void 0?[]:Array.isArray(X)?X:[X];if(q?.prepend)if(Array.isArray(X))U.unshift(...X);else U.unshift(X);else if(Array.isArray(X))U.push(...X);else U.push(X);return U},g0=(U,X)=>{if(X===void 0||X===null)return U??[];if(U===void 0||U===null)return l0(X);return U.concat(X)},wX=(...U)=>U.reduce(g0,[]),C0=(U,X,q)=>{if(U===void 0)return Array.isArray(X)?X:[X];let Z=q?.isEqual??((Q,G)=>Q===G);for(let Q of l0(X))if(!U.some((G)=>Z(G,Q)))U.push(Q);return U},PX=(U,X)=>U.reduce((q,Z)=>{let Q=Z[X];return q[Q]=g(q[Q],Z),q},{}),y0=(U,X,q)=>U.length===X.length&&U.every(q?.isEqual?(Z,Q)=>q.isEqual(Z,X[Q]):(Z,Q)=>Z===X[Q]);var G0=(U,X)=>r(U)===X,r=(U)=>{let X=typeof U;return X==="object"?U===null?"null":"object":X==="function"?"object":X},Y0={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},IX={...Y0,function:"a function"};class KX extends Error{}var y=(U)=>Y1(U,KX),Y1=(U,X=Error)=>{throw new X(U)};class Y2 extends Error{name="ParseError"}var F=(U)=>Y1(U,Y2),D0=(U)=>` ${U}`,NX="​";var S=(U,X)=>{let q={},Z=Array.isArray(U),Q=!1;for(let[G,Y]of Object.entries(U).entries()){let J=Z?X(G,Y[1]):X(...Y,G);Q||=typeof J[0]==="number";let H=Array.isArray(J[0])||J.length===0?J:[J];for(let[W,$]of H)if(typeof W==="object")q[W.group]=g(q[W.group],$);else q[W]=$}return Q?Object.values(q):q};var y4=Object.entries;var n=(U,X)=>(U in X),K1=(U,X)=>(X in U);class k4{constructor(U){Object.assign(this,U)}}var CX=class{};class J2 extends CX{}var YG=(U,X)=>{let q={},Z={},Q;for(Q in U)if(Q in X)q[Q]=U[Q];else Z[Q]=U[Q];return[q,Z]};var _6=(U,X)=>YG(U,X)[1],S0=(U)=>Object.keys(U).length===0,J1=(U)=>[...Object.entries(U),...Object.getOwnPropertySymbols(U).map((X)=>[X,U[X]])],SX=(U,X)=>Object.defineProperties(U,Object.getOwnPropertyDescriptors(X)),EX=(U)=>{let X=Object.keys(U).sort(),q={};for(let Z=0;Z<X.length;Z++)q[X[Z]]=U[X[Z]];return q};var J0=D0(`unset${NX}`),jX=(U)=>Object.values(U).filter((X)=>{if(typeof X==="number")return!0;return typeof U[X]!=="number"});var v4={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},h4=globalThis.File??Blob,x4={ArrayBuffer,Blob,File:h4,FormData,Headers,Request,Response,URL},JG={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},H1={...v4,...x4,...JG,String,Number,Boolean},H2=(U)=>{let X=Object.getPrototypeOf(U);while(X?.constructor&&(!n(X.constructor.name,H1)||!(U instanceof H1[X.constructor.name])))X=Object.getPrototypeOf(X);let q=X?.constructor?.name;if(q===void 0||q==="Object")return;return q},W2=(U)=>typeof U==="object"&&U!==null?H2(U)??"object":r(U);var h=Array.isArray,HG={Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},WG={ArrayBuffer:"an ArrayBuffer instance",Blob:"a Blob instance",File:"a File instance",FormData:"a FormData instance",Headers:"a Headers instance",Request:"a Request instance",Response:"a Response instance",URL:"a URL instance"},_G={Int8Array:"an Int8Array",Uint8Array:"a Uint8Array",Uint8ClampedArray:"a Uint8ClampedArray",Int16Array:"an Int16Array",Uint16Array:"a Uint16Array",Int32Array:"an Int32Array",Uint32Array:"a Uint32Array",Float32Array:"a Float32Array",Float64Array:"a Float64Array",BigInt64Array:"a BigInt64Array",BigUint64Array:"a BigUint64Array"},bX={...HG,...WG,..._G},_2=(U)=>{let X=Object(U).name??null;return X&&n(X,H1)&&H1[X]===U?X:null};var u4=(U,X)=>{let q=U.prototype;while(q!==null){if(q===X.prototype)return!0;q=Object.getPrototypeOf(q)}return!1};var fX=(U)=>gX(U,new Map),gX=(U,X)=>{if(typeof U!=="object"||U===null)return U;if(X?.has(U))return X.get(U);let q=_2(U.constructor);if(q==="Date")return new Date(U.getTime());if(q&&q!=="Array")return U;let Z=Array.isArray(U)?U.slice():Object.create(Object.getPrototypeOf(U)),Q=Object.getOwnPropertyDescriptors(U);if(X){X.set(U,Z);for(let G in Q){let Y=Q[G];if("get"in Y||"set"in Y)continue;Y.value=gX(Y.value,X)}}return Object.defineProperties(Z,Q),Z};var $G=(U)=>{let X=J0;return()=>X===J0?X=U():X},d0=(U)=>typeof U==="function"&&U.length===0;var yX=class extends Function{constructor(...U){let X=U.slice(0,-1),q=U[U.length-1];try{super(...X,q)}catch(Z){return y(`Encountered an unexpected error while compiling your definition:
140
140
  Message: ${Z}
141
141
  Source: (${U.slice(0,-1)}) => {
142
142
  ${U[U.length-1]}
143
- }`)}}};class H0{constructor(U,...[X]){return Object.assign(Object.setPrototypeOf(U.bind(X?.bind??this),this.constructor.prototype),X?.attach)}}var yX=YG(()=>{try{return Function("return false")()}catch{return!0}});var VB=D0("brand");var kX=D0("arkInferred");var MB=D0("args");class X0{constructor(){}}var JG=()=>{try{return((Error().stack?.split(`
144
- `)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},HG=globalThis.process?.env??{},vX={fileName:JG,env:HG};var hX=(U)=>U[0].toUpperCase()+U.slice(1),xX=(U)=>U[0].toLowerCase()+U.slice(1),m4=(U)=>new RegExp(WG(U),typeof U==="string"?"":U.flags);var WG=(U)=>{return`^(?:${typeof U==="string"?U:U.source})$`};var k0={negativeLookahead:(U)=>`(?!${U})`,nonCapturingGroup:(U)=>`(?:${U})`},W1="\\",c0={" ":1,"\n":1,"\t":1};var _G=/^-0\.?0*$/.source,mX=/[1-9]\d*/.source,$G=/\.\d+/.source,LG=/\.\d*[1-9]/.source,pX=(U)=>m4(k0.negativeLookahead(_G)+k0.nonCapturingGroup("-?"+k0.nonCapturingGroup(k0.nonCapturingGroup("0|"+mX)+k0.nonCapturingGroup(U.decimalPattern)+"?")+(U.allowDecimalOnly?"|"+U.decimalPattern:"")+"?")),uX=pX({decimalPattern:LG,allowDecimalOnly:!1}),zG=uX.test.bind(uX),$6=pX({decimalPattern:$G,allowDecimalOnly:!0}),SB=$6.test.bind($6),FG=/^-?\d*\.?\d*$/,AG=(U)=>U.length!==0&&FG.test(U),$2=m4(k0.negativeLookahead("^-0$")+"-?"+k0.nonCapturingGroup(k0.nonCapturingGroup("0|"+mX))),OG=$2.test.bind($2),p4=/^-?\d+$/,BG=p4.test.bind(p4),lX={number:"a number",bigint:"a bigint",integer:"an integer"},dX=(U,X)=>`'${U}' was parsed as ${lX[X]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,TG=(U,X)=>X==="number"?zG(U):OG(U),VG=(U,X)=>X==="number"?Number(U):Number.parseInt(U),RG=(U,X)=>X==="number"?AG(U):BG(U),cX=(U,X)=>l4(U,"number",X),iX=(U,X)=>l4(U,"number",{...X,strict:!0}),sX=(U,X)=>l4(U,"integer",X),l4=(U,X,q)=>{let Z=VG(U,X);if(!Number.isNaN(Z)){if(RG(U,X)){if(q?.strict)return TG(U,X)?Z:F(dX(U,X));return Z}}return q?.errorOnFail?F(q?.errorOnFail===!0?`Failed to parse ${lX[X]} from '${U}'`:q?.errorOnFail):void 0},oX=(U)=>{if(U[U.length-1]!=="n")return;let X=U.slice(0,-1),q;try{q=BigInt(X)}catch{return}if($2.test(X))return q;if(p4.test(X))return F(dX(U,"bigint"))};var DG="0.56.0",MG={version:DG,filename:vX.fileName(),FileConstructor:h4},_1=MG,rX=new Map,d4=Object.create(null),L2=(U)=>{let X=rX.get(U);if(X)return X;let q=wG(U);if(d4[q])q=`${q}${d4[q]++}`;else d4[q]=1;return _1[q]=U,rX.set(U,q),q},i0=(U)=>/^[$A-Z_a-z][\w$]*$/.test(U),wG=(U)=>{switch(typeof U){case"object":{if(U===null)break;let X=H2(U)??"object";return X[0].toLowerCase()+X.slice(1)}case"function":return i0(U.name)?U.name:"fn";case"symbol":return U.description&&i0(U.description)?U.description:"symbol"}return y(`Unexpected attempt to register serializable value of type ${r(U)}`)};var z2=(U)=>typeof U==="string"?JSON.stringify(U):typeof U==="bigint"?`${U}n`:`${U}`;var nX=(U,X={})=>F2(U,{onUndefined:"$ark.undefined",onBigInt:(q)=>`$ark.bigint-${q}`,...X},[]);var E=(U,X)=>{switch(r(U)){case"object":let q=U,Z=q.constructor?.name??"Object";return Z==="Object"||Z==="Array"?X?.quoteKeys===!1?L6(q,X?.indent??0,""):JSON.stringify(F2(q,N1,[]),null,X?.indent):L6(q,X?.indent??0,"");case"symbol":return N1.onSymbol(U);default:return z2(U)}},L6=(U,X,q)=>{if(typeof U==="function")return N1.onFunction(U);if(typeof U!=="object"||U===null)return z2(U);let Z=q+" ".repeat(X);if(Array.isArray(U)){if(U.length===0)return"[]";let G=U.map((Y)=>L6(Y,X,Z)).join(`,
143
+ }`)}}};class H0{constructor(U,...[X]){return Object.assign(Object.setPrototypeOf(U.bind(X?.bind??this),this.constructor.prototype),X?.attach)}}var kX=$G(()=>{try{return Function("return false")()}catch{return!0}});var PB=D0("brand");var vX=D0("arkInferred");var NB=D0("args");class X0{constructor(){}}var LG=()=>{try{return((Error().stack?.split(`
144
+ `)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},zG=globalThis.process?.env??{},hX={fileName:LG,env:zG};var xX=(U)=>U[0].toUpperCase()+U.slice(1),uX=(U)=>U[0].toLowerCase()+U.slice(1),m4=(U)=>new RegExp(FG(U),typeof U==="string"?"":U.flags);var FG=(U)=>{return`^(?:${typeof U==="string"?U:U.source})$`};var k0={negativeLookahead:(U)=>`(?!${U})`,nonCapturingGroup:(U)=>`(?:${U})`},W1="\\",c0={" ":1,"\n":1,"\t":1};var AG=/^-0\.?0*$/.source,pX=/[1-9]\d*/.source,OG=/\.\d+/.source,BG=/\.\d*[1-9]/.source,lX=(U)=>m4(k0.negativeLookahead(AG)+k0.nonCapturingGroup("-?"+k0.nonCapturingGroup(k0.nonCapturingGroup("0|"+pX)+k0.nonCapturingGroup(U.decimalPattern)+"?")+(U.allowDecimalOnly?"|"+U.decimalPattern:"")+"?")),mX=lX({decimalPattern:BG,allowDecimalOnly:!1}),TG=mX.test.bind(mX),$6=lX({decimalPattern:OG,allowDecimalOnly:!0}),gB=$6.test.bind($6),VG=/^-?\d*\.?\d*$/,RG=(U)=>U.length!==0&&VG.test(U),$2=m4(k0.negativeLookahead("^-0$")+"-?"+k0.nonCapturingGroup(k0.nonCapturingGroup("0|"+pX))),DG=$2.test.bind($2),p4=/^-?\d+$/,MG=p4.test.bind(p4),dX={number:"a number",bigint:"a bigint",integer:"an integer"},cX=(U,X)=>`'${U}' was parsed as ${dX[X]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,wG=(U,X)=>X==="number"?TG(U):DG(U),PG=(U,X)=>X==="number"?Number(U):Number.parseInt(U),IG=(U,X)=>X==="number"?RG(U):MG(U),iX=(U,X)=>l4(U,"number",X),sX=(U,X)=>l4(U,"number",{...X,strict:!0}),oX=(U,X)=>l4(U,"integer",X),l4=(U,X,q)=>{let Z=PG(U,X);if(!Number.isNaN(Z)){if(IG(U,X)){if(q?.strict)return wG(U,X)?Z:F(cX(U,X));return Z}}return q?.errorOnFail?F(q?.errorOnFail===!0?`Failed to parse ${dX[X]} from '${U}'`:q?.errorOnFail):void 0},rX=(U)=>{if(U[U.length-1]!=="n")return;let X=U.slice(0,-1),q;try{q=BigInt(X)}catch{return}if($2.test(X))return q;if(p4.test(X))return F(cX(U,"bigint"))};var KG="0.56.0",NG={version:KG,filename:hX.fileName(),FileConstructor:h4},_1=NG,nX=new Map,d4=Object.create(null),L2=(U)=>{let X=nX.get(U);if(X)return X;let q=CG(U);if(d4[q])q=`${q}${d4[q]++}`;else d4[q]=1;return _1[q]=U,nX.set(U,q),q},i0=(U)=>/^[$A-Z_a-z][\w$]*$/.test(U),CG=(U)=>{switch(typeof U){case"object":{if(U===null)break;let X=H2(U)??"object";return X[0].toLowerCase()+X.slice(1)}case"function":return i0(U.name)?U.name:"fn";case"symbol":return U.description&&i0(U.description)?U.description:"symbol"}return y(`Unexpected attempt to register serializable value of type ${r(U)}`)};var z2=(U)=>typeof U==="string"?JSON.stringify(U):typeof U==="bigint"?`${U}n`:`${U}`;var aX=(U,X={})=>F2(U,{onUndefined:"$ark.undefined",onBigInt:(q)=>`$ark.bigint-${q}`,...X},[]);var E=(U,X)=>{switch(r(U)){case"object":let q=U,Z=q.constructor?.name??"Object";return Z==="Object"||Z==="Array"?X?.quoteKeys===!1?L6(q,X?.indent??0,""):JSON.stringify(F2(q,N1,[]),null,X?.indent):L6(q,X?.indent??0,"");case"symbol":return N1.onSymbol(U);default:return z2(U)}},L6=(U,X,q)=>{if(typeof U==="function")return N1.onFunction(U);if(typeof U!=="object"||U===null)return z2(U);let Z=q+" ".repeat(X);if(Array.isArray(U)){if(U.length===0)return"[]";let G=U.map((Y)=>L6(Y,X,Z)).join(`,
145
145
  `+Z);return X?`[
146
146
  ${Z}${G}
147
147
  ${q}]`:`[${G}]`}let Q=U.constructor?.name??"Object";if(Q==="Object"){let G=J1(U).map(([Y,J])=>{let H=typeof Y==="symbol"?N1.onSymbol(Y):i0(Y)?Y:JSON.stringify(Y),W=L6(J,X,Z);return`${Z}${H}: ${W}`});if(G.length===0)return"{}";return X?`{
148
148
  ${G.join(`,
149
149
  `)}
150
- ${q}}`:`{${G.join(", ")}}`}if(U instanceof Date)return $1(U);if("expression"in U&&typeof U.expression==="string")return U.expression;return Q},N1={onCycle:()=>"(cycle)",onSymbol:(U)=>`Symbol(${L2(U)})`,onFunction:(U)=>`Function(${L2(U)})`},F2=(U,X,q)=>{switch(r(U)){case"object":{let Z=U;if("toJSON"in Z&&typeof Z.toJSON==="function")return Z.toJSON();if(typeof Z==="function")return N1.onFunction(Z);if(q.includes(Z))return"(cycle)";let Q=[...q,Z];if(Array.isArray(Z))return Z.map((Y)=>F2(Y,X,Q));if(Z instanceof Date)return Z.toDateString();let G={};for(let Y in Z)G[Y]=F2(Z[Y],X,Q);for(let Y of Object.getOwnPropertySymbols(Z))G[X.onSymbol?.(Y)??Y.toString()]=F2(Z[Y],X,Q);return G}case"symbol":return N1.onSymbol(U);case"bigint":return X.onBigInt?.(U)??`${U}n`;case"undefined":return X.onUndefined??"undefined";case"string":return U.replace(/\\/g,"\\\\");default:return U}},$1=(U)=>{let X=U.getFullYear(),q=U.getMonth(),Z=U.getDate(),Q=U.getHours(),G=U.getMinutes(),Y=U.getSeconds(),J=U.getMilliseconds();if(q===0&&Z===1&&Q===0&&G===0&&Y===0&&J===0)return`${X}`;let H=`${PG[q]} ${Z}, ${X}`;if(Q===0&&G===0&&Y===0&&J===0)return H;let W=U.toLocaleTimeString(),$=W.endsWith(" AM")||W.endsWith(" PM")?W.slice(-3):"";if($)W=W.slice(0,-$.length);if(J)W+=`.${KG(J,3)}`;else if(IG.test(W))W=W.slice(0,-3);return`${W+$}, ${H}`},PG=["January","February","March","April","May","June","July","August","September","October","November","December"],IG=/:\d\d:00$/,KG=(U,X)=>String(U).padStart(X,"0");var aX=(U,X,...[q])=>{let Z=q?.stringifySymbol??E,Q=U;switch(typeof X){case"string":Q=i0(X)?U===""?X:`${U}.${X}`:`${U}[${JSON.stringify(X)}]`;break;case"number":Q=`${U}[${X}]`;break;case"symbol":Q=`${U}[${Z(X)}]`;break;default:if(q?.stringifyNonKey)Q=`${U}[${q.stringifyNonKey(X)}]`;else F(`${E(X)} must be a PropertyKey or stringifyNonKey must be passed to options`)}return Q},v0=(U,...X)=>U.reduce((q,Z)=>aX(q,Z,...X),"");class A2 extends W6{cache={};constructor(...U){super();this.push(...U)}toJSON(){if(this.cache.json)return this.cache.json;this.cache.json=[];for(let U=0;U<this.length;U++)this.cache.json.push(typeof this[U]==="symbol"?E(this[U]):this[U]);return this.cache.json}stringify(){if(this.cache.stringify)return this.cache.stringify;return this.cache.stringify=v0(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let U="",X=[U];for(let q of this)U=aX(U,q),X.push(U);return this.cache.stringifyAncestors=X}}class O2{chars;i;def;constructor(U){this.def=U,this.chars=[...U],this.i=0}shift(){return this.chars[this.i++]??""}get lookahead(){return this.chars[this.i]??""}get nextLookahead(){return this.chars[this.i+1]??""}get length(){return this.chars.length}shiftUntil(U){let X="";while(this.lookahead)if(U(this,X))break;else X+=this.shift();return X}shiftUntilEscapable(U){let X="";while(this.lookahead)if(this.lookahead===W1)if(this.shift(),U(this,X))X+=this.shift();else if(this.lookahead===W1)X+=this.shift();else X+=`${W1}${this.shift()}`;else if(U(this,X))break;else X+=this.shift();return X}shiftUntilLookahead(U){return typeof U==="string"?this.shiftUntil((X)=>X.lookahead===U):this.shiftUntil((X)=>(X.lookahead in U))}shiftUntilNonWhitespace(){return this.shiftUntil(()=>!(this.lookahead in c0))}jumpToIndex(U){this.i=U<0?this.length+U:U}jumpForward(U){this.i+=U}get location(){return this.i}get unscanned(){return this.chars.slice(this.i,this.length).join("")}get scanned(){return this.chars.slice(0,this.i).join("")}sliceChars(U,X){return this.chars.slice(U,X).join("")}lookaheadIs(U){return this.lookahead===U}lookaheadIsIn(U){return this.lookahead in U}}var tX=(U,X)=>`Unmatched ${U}${X===""?"":` before ${X}`}`,z6=(U)=>`Missing ${U}`;var UT=D0("implementedTraits");var c4="$ark",NG=2;while(c4 in globalThis)c4=`$ark${NG++}`;var eX=c4;globalThis[eX]=_1;var O=_1,CG=(U)=>`${eX}.${U}`,d=(U)=>CG(L2(U));class F6 extends J2{argNames;body="";constructor(...U){super();this.argNames=U;for(let X of U){if(X in this)throw Error(`Arg name '${X}' would overwrite an existing property on FunctionBody`);this[X]=X}}indentation=0;indent(){return this.indentation+=4,this}dedent(){return this.indentation-=4,this}prop(U,X=!1){return i4(U,X)}index(U,X=!1){return Uq(`${U}`,X)}line(U){return this.body+=`${" ".repeat(this.indentation)}${U}
150
+ ${q}}`:`{${G.join(", ")}}`}if(U instanceof Date)return $1(U);if("expression"in U&&typeof U.expression==="string")return U.expression;return Q},N1={onCycle:()=>"(cycle)",onSymbol:(U)=>`Symbol(${L2(U)})`,onFunction:(U)=>`Function(${L2(U)})`},F2=(U,X,q)=>{switch(r(U)){case"object":{let Z=U;if("toJSON"in Z&&typeof Z.toJSON==="function")return Z.toJSON();if(typeof Z==="function")return N1.onFunction(Z);if(q.includes(Z))return"(cycle)";let Q=[...q,Z];if(Array.isArray(Z))return Z.map((Y)=>F2(Y,X,Q));if(Z instanceof Date)return Z.toDateString();let G={};for(let Y in Z)G[Y]=F2(Z[Y],X,Q);for(let Y of Object.getOwnPropertySymbols(Z))G[X.onSymbol?.(Y)??Y.toString()]=F2(Z[Y],X,Q);return G}case"symbol":return N1.onSymbol(U);case"bigint":return X.onBigInt?.(U)??`${U}n`;case"undefined":return X.onUndefined??"undefined";case"string":return U.replace(/\\/g,"\\\\");default:return U}},$1=(U)=>{let X=U.getFullYear(),q=U.getMonth(),Z=U.getDate(),Q=U.getHours(),G=U.getMinutes(),Y=U.getSeconds(),J=U.getMilliseconds();if(q===0&&Z===1&&Q===0&&G===0&&Y===0&&J===0)return`${X}`;let H=`${SG[q]} ${Z}, ${X}`;if(Q===0&&G===0&&Y===0&&J===0)return H;let W=U.toLocaleTimeString(),$=W.endsWith(" AM")||W.endsWith(" PM")?W.slice(-3):"";if($)W=W.slice(0,-$.length);if(J)W+=`.${jG(J,3)}`;else if(EG.test(W))W=W.slice(0,-3);return`${W+$}, ${H}`},SG=["January","February","March","April","May","June","July","August","September","October","November","December"],EG=/:\d\d:00$/,jG=(U,X)=>String(U).padStart(X,"0");var tX=(U,X,...[q])=>{let Z=q?.stringifySymbol??E,Q=U;switch(typeof X){case"string":Q=i0(X)?U===""?X:`${U}.${X}`:`${U}[${JSON.stringify(X)}]`;break;case"number":Q=`${U}[${X}]`;break;case"symbol":Q=`${U}[${Z(X)}]`;break;default:if(q?.stringifyNonKey)Q=`${U}[${q.stringifyNonKey(X)}]`;else F(`${E(X)} must be a PropertyKey or stringifyNonKey must be passed to options`)}return Q},v0=(U,...X)=>U.reduce((q,Z)=>tX(q,Z,...X),"");class A2 extends W6{cache={};constructor(...U){super();this.push(...U)}toJSON(){if(this.cache.json)return this.cache.json;this.cache.json=[];for(let U=0;U<this.length;U++)this.cache.json.push(typeof this[U]==="symbol"?E(this[U]):this[U]);return this.cache.json}stringify(){if(this.cache.stringify)return this.cache.stringify;return this.cache.stringify=v0(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let U="",X=[U];for(let q of this)U=tX(U,q),X.push(U);return this.cache.stringifyAncestors=X}}class O2{chars;i;def;constructor(U){this.def=U,this.chars=[...U],this.i=0}shift(){return this.chars[this.i++]??""}get lookahead(){return this.chars[this.i]??""}get nextLookahead(){return this.chars[this.i+1]??""}get length(){return this.chars.length}shiftUntil(U){let X="";while(this.lookahead)if(U(this,X))break;else X+=this.shift();return X}shiftUntilEscapable(U){let X="";while(this.lookahead)if(this.lookahead===W1)if(this.shift(),U(this,X))X+=this.shift();else if(this.lookahead===W1)X+=this.shift();else X+=`${W1}${this.shift()}`;else if(U(this,X))break;else X+=this.shift();return X}shiftUntilLookahead(U){return typeof U==="string"?this.shiftUntil((X)=>X.lookahead===U):this.shiftUntil((X)=>(X.lookahead in U))}shiftUntilNonWhitespace(){return this.shiftUntil(()=>!(this.lookahead in c0))}jumpToIndex(U){this.i=U<0?this.length+U:U}jumpForward(U){this.i+=U}get location(){return this.i}get unscanned(){return this.chars.slice(this.i,this.length).join("")}get scanned(){return this.chars.slice(0,this.i).join("")}sliceChars(U,X){return this.chars.slice(U,X).join("")}lookaheadIs(U){return this.lookahead===U}lookaheadIsIn(U){return this.lookahead in U}}var eX=(U,X)=>`Unmatched ${U}${X===""?"":` before ${X}`}`,z6=(U)=>`Missing ${U}`;var GT=D0("implementedTraits");var c4="$ark",bG=2;while(c4 in globalThis)c4=`$ark${bG++}`;var Uq=c4;globalThis[Uq]=_1;var O=_1,fG=(U)=>`${Uq}.${U}`,d=(U)=>fG(L2(U));class F6 extends J2{argNames;body="";constructor(...U){super();this.argNames=U;for(let X of U){if(X in this)throw Error(`Arg name '${X}' would overwrite an existing property on FunctionBody`);this[X]=X}}indentation=0;indent(){return this.indentation+=4,this}dedent(){return this.indentation-=4,this}prop(U,X=!1){return i4(U,X)}index(U,X=!1){return Xq(`${U}`,X)}line(U){return this.body+=`${" ".repeat(this.indentation)}${U}
151
151
  `,this}const(U,X){return this.line(`const ${U} = ${X}`),this}let(U,X){return this.line(`let ${U} = ${X}`)}set(U,X){return this.line(`${U} = ${X}`)}if(U,X){return this.block(`if (${U})`,X)}elseIf(U,X){return this.block(`else if (${U})`,X)}else(U){return this.block("else",U)}for(U,X,q=0){return this.block(`for (let i = ${q}; ${U}; i++)`,X)}forIn(U,X){return this.block(`for (const k in ${U})`,X)}block(U,X,q=""){return this.line(`${U} {`),this.indent(),X(this),this.dedent(),this.line(`}${q}`)}return(U=""){return this.line(`return ${U}`)}write(U="anonymous",X=0){return`${U}(${this.argNames.join(", ")}) { ${X?this.body.split(`
152
152
  `).map((q)=>" ".repeat(X)+`${q}`).join(`
153
- `):this.body} }`}compile(){return new gX(...this.argNames,this.body)}}var M0=(U)=>G0(U,"object")||typeof U==="symbol"?d(U):z2(U),i4=(U,X=!1)=>{if(typeof U==="string"&&i0(U))return`${X?"?":""}.${U}`;return Uq(SG(U),X)},SG=(U)=>typeof U==="symbol"?d(U):JSON.stringify(U),Uq=(U,X=!1)=>`${X?"?.":""}[${U}]`;class B2 extends F6{traversalKind;optimistic;constructor(U){super("data","ctx");this.traversalKind=U.kind,this.optimistic=U.optimistic===!0}invoke(U,X){let q=X?.arg??this.data,Z=typeof U==="string"?!0:this.requiresContextFor(U),Q=typeof U==="string"?U:U.id;if(Z)return`${this.referenceToId(Q,X)}(${q}, ${this.ctx})`;return`${this.referenceToId(Q,X)}(${q})`}referenceToId(U,X){let q=X?.kind??this.traversalKind,Z=`this.${U}${q}`;return X?.bind?`${Z}.bind(${X?.bind})`:Z}requiresContextFor(U){return this.traversalKind==="Apply"||U.allowsRequiresContext}initializeErrorCount(){return this.const("errorCount","ctx.currentErrorCount")}returnIfFail(){return this.if("ctx.currentErrorCount > errorCount",()=>this.return())}returnIfFailFast(){return this.if("ctx.failFast && ctx.currentErrorCount > errorCount",()=>this.return())}traverseKey(U,X,q){let Z=this.requiresContextFor(q);if(Z)this.line(`${this.ctx}.path.push(${U})`);if(this.check(q,{arg:X}),Z)this.line(`${this.ctx}.path.pop()`);return this}check(U,X){return this.traversalKind==="Allows"?this.if(`!${this.invoke(U,X)}`,()=>this.return(!1)):this.line(this.invoke(U,X))}}var A6=(U)=>S(U,(X,q)=>[X,h(q)?[...q]:q]),Z0=D0("arkKind"),M=(U,X)=>U?.[Z0]===X,x=(U)=>M(U,"root")||M(U,"constraint");var Xq=["unit","proto","domain"],C1=["required","optional","index","sequence"],s4=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],o4=[...s4,"structure","predicate"],O6=[...o4,...C1],S1=["alias","union","morph","unit","intersection","proto","domain"],EG=[...S1,...O6],B6=S(O6,(U,X)=>[X,1]),qq=S([...C1,"undeclared"],(U,X)=>[X,1]),Zq=S(EG,(U,X)=>[X,U]),E1=(U)=>typeof U==="string"&&(U in Zq);var j1=(U)=>Zq[U],T6=(U)=>S1.slice(j1(U)+1),vT=[...T6("union"),"alias"],hT=[...T6("morph"),"alias"],A0=(U)=>{if(typeof U==="string"||typeof U==="boolean"||U===null)return U;if(typeof U==="number"){if(Number.isNaN(U))return"NaN";if(U===Number.POSITIVE_INFINITY)return"Infinity";if(U===Number.NEGATIVE_INFINITY)return"-Infinity";return U}return M0(U)},s0=(U)=>{let X="{ ";for(let[q,Z]of Object.entries(U))X+=`${q}: ${M0(Z)}, `;return X+" }"},j=(U)=>{let X=U;if(X.hasAssociatedError)X.defaults.expected??=(q)=>("description"in q)?q.description:X.defaults.description(q),X.defaults.actual??=(q)=>E(q),X.defaults.problem??=(q)=>`must be ${q.expected}${q.actual?` (was ${q.actual})`:""}`,X.defaults.message??=(q)=>{if(q.path.length===0)return q.problem;let Z=`${q.propString} ${q.problem}`;if(Z[0]==="[")return`value at ${Z}`;return Z};return X};class Qq extends Error{name="ToJsonSchemaError";code;context;constructor(U,X){super(E(X,{quoteKeys:!1,indent:4}));this.code=U,this.context=X}hasCode(U){return this.code===U}}var jG={target:"draft-2020-12",dialect:"https://json-schema.org/draft/2020-12/schema",useRefs:!1,fallback:{arrayObject:(U)=>p.throw("arrayObject",U),arrayPostfix:(U)=>p.throw("arrayPostfix",U),defaultValue:(U)=>p.throw("defaultValue",U),domain:(U)=>p.throw("domain",U),morph:(U)=>p.throw("morph",U),patternIntersection:(U)=>p.throw("patternIntersection",U),predicate:(U)=>p.throw("predicate",U),proto:(U)=>p.throw("proto",U),symbolKey:(U)=>p.throw("symbolKey",U),unit:(U)=>p.throw("unit",U),date:(U)=>p.throw("date",U)}},p={Error:Qq,throw:(...U)=>{throw new p.Error(...U)},throwInternalOperandError:(U,X)=>y(`Unexpected JSON Schema input for ${U}: ${E(X)}`),defaultConfig:jG};O.config??={};var T2=(U,X)=>{if(!X)return U;let q={...U},Z;for(Z in X){let Q={...U.keywords};if(Z==="keywords"){for(let G in X[Z]){let Y=X.keywords[G];if(Y===void 0)continue;Q[G]=typeof Y==="string"?{description:Y}:Y}q.keywords=Q}else if(Z==="toJsonSchema")q[Z]=r4(U.toJsonSchema,X.toJsonSchema);else if(E1(Z))q[Z]={...U[Z],...X[Z]};else q[Z]=X[Z]}return q},bG={"draft-2020-12":"https://json-schema.org/draft/2020-12/schema","draft-07":"http://json-schema.org/draft-07/schema#"},r4=(U,X)=>{if(!U)return Gq(X??{},void 0);if(!X)return U;let q={...U},Z;for(Z in X)if(Z==="fallback")q.fallback=fG(U.fallback,X.fallback);else q[Z]=X[Z];return Gq(q,X)},Gq=(U,X)=>{if(X?.dialect!==void 0)return U;if(X?.target!==void 0)return{...U,dialect:bG[X.target]};return U},fG=(U,X)=>{U=Yq(U),X=Yq(X);let q={},Z;for(Z in p.defaultConfig.fallback)q[Z]=X[Z]??X.default??U[Z]??U.default??p.defaultConfig.fallback[Z];return q},Yq=(U)=>typeof U==="function"?{default:U}:U??{};class o0 extends J2{[Z0]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:U,relativePath:X,...q},Z){super();this.input=q,this.ctx=Z,CX(this,q);let Q=Z.data;if(q.code==="union")q.errors=q.errors.flatMap((Y)=>{let J=Y.hasCode("union")?Y.errors:[Y];if(!U&&!X)return J;return J.map((H)=>H.transform((W)=>({...W,path:MX(U,W.path,X)})))});this.nodeConfig=Z.config[this.code];let G=[...q.path??Z.path];if(X)G.push(...X);if(U)G.unshift(...U);this.path=new A2(...G),this.data="data"in q?q.data:Q}transform(U){return new o0(U({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode(U){return this.code===U}get propString(){return v0(this.path)}get expected(){if(this.input.expected)return this.input.expected;let U=this.meta?.expected??this.nodeConfig.expected;return typeof U==="function"?U(this.input):U}get actual(){if(this.input.actual)return this.input.actual;let U=this.meta?.actual??this.nodeConfig.actual;return typeof U==="function"?U(this.data):U}get problem(){if(this.input.problem)return this.input.problem;let U=this.meta?.problem??this.nodeConfig.problem;return typeof U==="function"?U(this):U}get message(){if(this.input.message)return this.input.message;let U=this.meta?.message??this.nodeConfig.message;return typeof U==="function"?U(this):U}get flat(){return this.hasCode("intersection")?[...this.errors]:[this]}toJSON(){return{data:this.data,path:this.path,...this.input,expected:this.expected,actual:this.actual,problem:this.problem,message:this.message}}toString(){return this.message}throw(){throw this}}class W0 extends W6{[Z0]="errors";ctx;constructor(U){super();this.ctx=U}byPath=Object.create(null);get flatByPath(){return S(this.byPath,(U,X)=>[U,X.flat])}get flatProblemsByPath(){return S(this.byPath,(U,X)=>[U,X.flat.map((q)=>q.problem)])}byAncestorPath=Object.create(null);count=0;mutable=this;throw(){throw this.toTraversalError()}toTraversalError(){return new n4(this)}add(U){let X=this.byPath[U.propString];if(X){if(U===X)return;if(X.hasCode("union")&&X.errors.length===0)return;let q=U.hasCode("union")&&U.errors.length===0?U:new o0({code:"intersection",errors:X.hasCode("intersection")?[...X.errors,U]:[X,U]},this.ctx),Z=this.indexOf(X);this.mutable[Z===-1?this.length:Z]=q,this.byPath[U.propString]=q,this.addAncestorPaths(U)}else this.byPath[U.propString]=U,this.addAncestorPaths(U),this.mutable.push(U);this.count++}transform(U){let X=new W0(this.ctx);for(let q of this)X.add(U(q));return X}merge(U){for(let X of U)this.add(new o0({...X,path:[...this.ctx.path,...X.path]},this.ctx))}affectsPath(U){if(this.length===0)return!1;return U.stringifyAncestors().some((X)=>(X in this.byPath))||U.stringify()in this.byAncestorPath}get summary(){return this.toString()}get issues(){return this}toJSON(){return[...this.map((U)=>U.toJSON())]}toString(){return this.join(`
153
+ `):this.body} }`}compile(){return new yX(...this.argNames,this.body)}}var M0=(U)=>G0(U,"object")||typeof U==="symbol"?d(U):z2(U),i4=(U,X=!1)=>{if(typeof U==="string"&&i0(U))return`${X?"?":""}.${U}`;return Xq(gG(U),X)},gG=(U)=>typeof U==="symbol"?d(U):JSON.stringify(U),Xq=(U,X=!1)=>`${X?"?.":""}[${U}]`;class B2 extends F6{traversalKind;optimistic;constructor(U){super("data","ctx");this.traversalKind=U.kind,this.optimistic=U.optimistic===!0}invoke(U,X){let q=X?.arg??this.data,Z=typeof U==="string"?!0:this.requiresContextFor(U),Q=typeof U==="string"?U:U.id;if(Z)return`${this.referenceToId(Q,X)}(${q}, ${this.ctx})`;return`${this.referenceToId(Q,X)}(${q})`}referenceToId(U,X){let q=X?.kind??this.traversalKind,Z=`this.${U}${q}`;return X?.bind?`${Z}.bind(${X?.bind})`:Z}requiresContextFor(U){return this.traversalKind==="Apply"||U.allowsRequiresContext}initializeErrorCount(){return this.const("errorCount","ctx.currentErrorCount")}returnIfFail(){return this.if("ctx.currentErrorCount > errorCount",()=>this.return())}returnIfFailFast(){return this.if("ctx.failFast && ctx.currentErrorCount > errorCount",()=>this.return())}traverseKey(U,X,q){let Z=this.requiresContextFor(q);if(Z)this.line(`${this.ctx}.path.push(${U})`);if(this.check(q,{arg:X}),Z)this.line(`${this.ctx}.path.pop()`);return this}check(U,X){return this.traversalKind==="Allows"?this.if(`!${this.invoke(U,X)}`,()=>this.return(!1)):this.line(this.invoke(U,X))}}var A6=(U)=>S(U,(X,q)=>[X,h(q)?[...q]:q]),Z0=D0("arkKind"),M=(U,X)=>U?.[Z0]===X,x=(U)=>M(U,"root")||M(U,"constraint");var qq=["unit","proto","domain"],C1=["required","optional","index","sequence"],s4=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],o4=[...s4,"structure","predicate"],O6=[...o4,...C1],S1=["alias","union","morph","unit","intersection","proto","domain"],yG=[...S1,...O6],B6=S(O6,(U,X)=>[X,1]),Zq=S([...C1,"undeclared"],(U,X)=>[X,1]),Qq=S(yG,(U,X)=>[X,U]),E1=(U)=>typeof U==="string"&&(U in Qq);var j1=(U)=>Qq[U],T6=(U)=>S1.slice(j1(U)+1),pT=[...T6("union"),"alias"],lT=[...T6("morph"),"alias"],A0=(U)=>{if(typeof U==="string"||typeof U==="boolean"||U===null)return U;if(typeof U==="number"){if(Number.isNaN(U))return"NaN";if(U===Number.POSITIVE_INFINITY)return"Infinity";if(U===Number.NEGATIVE_INFINITY)return"-Infinity";return U}return M0(U)},s0=(U)=>{let X="{ ";for(let[q,Z]of Object.entries(U))X+=`${q}: ${M0(Z)}, `;return X+" }"},j=(U)=>{let X=U;if(X.hasAssociatedError)X.defaults.expected??=(q)=>("description"in q)?q.description:X.defaults.description(q),X.defaults.actual??=(q)=>E(q),X.defaults.problem??=(q)=>`must be ${q.expected}${q.actual?` (was ${q.actual})`:""}`,X.defaults.message??=(q)=>{if(q.path.length===0)return q.problem;let Z=`${q.propString} ${q.problem}`;if(Z[0]==="[")return`value at ${Z}`;return Z};return X};class Gq extends Error{name="ToJsonSchemaError";code;context;constructor(U,X){super(E(X,{quoteKeys:!1,indent:4}));this.code=U,this.context=X}hasCode(U){return this.code===U}}var kG={target:"draft-2020-12",dialect:"https://json-schema.org/draft/2020-12/schema",useRefs:!1,fallback:{arrayObject:(U)=>p.throw("arrayObject",U),arrayPostfix:(U)=>p.throw("arrayPostfix",U),defaultValue:(U)=>p.throw("defaultValue",U),domain:(U)=>p.throw("domain",U),morph:(U)=>p.throw("morph",U),patternIntersection:(U)=>p.throw("patternIntersection",U),predicate:(U)=>p.throw("predicate",U),proto:(U)=>p.throw("proto",U),symbolKey:(U)=>p.throw("symbolKey",U),unit:(U)=>p.throw("unit",U),date:(U)=>p.throw("date",U)}},p={Error:Gq,throw:(...U)=>{throw new p.Error(...U)},throwInternalOperandError:(U,X)=>y(`Unexpected JSON Schema input for ${U}: ${E(X)}`),defaultConfig:kG};O.config??={};var T2=(U,X)=>{if(!X)return U;let q={...U},Z;for(Z in X){let Q={...U.keywords};if(Z==="keywords"){for(let G in X[Z]){let Y=X.keywords[G];if(Y===void 0)continue;Q[G]=typeof Y==="string"?{description:Y}:Y}q.keywords=Q}else if(Z==="toJsonSchema")q[Z]=r4(U.toJsonSchema,X.toJsonSchema);else if(E1(Z))q[Z]={...U[Z],...X[Z]};else q[Z]=X[Z]}return q},vG={"draft-2020-12":"https://json-schema.org/draft/2020-12/schema","draft-07":"http://json-schema.org/draft-07/schema#"},r4=(U,X)=>{if(!U)return Yq(X??{},void 0);if(!X)return U;let q={...U},Z;for(Z in X)if(Z==="fallback")q.fallback=hG(U.fallback,X.fallback);else q[Z]=X[Z];return Yq(q,X)},Yq=(U,X)=>{if(X?.dialect!==void 0)return U;if(X?.target!==void 0)return{...U,dialect:vG[X.target]};return U},hG=(U,X)=>{U=Jq(U),X=Jq(X);let q={},Z;for(Z in p.defaultConfig.fallback)q[Z]=X[Z]??X.default??U[Z]??U.default??p.defaultConfig.fallback[Z];return q},Jq=(U)=>typeof U==="function"?{default:U}:U??{};class o0 extends J2{[Z0]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:U,relativePath:X,...q},Z){super();this.input=q,this.ctx=Z,SX(this,q);let Q=Z.data;if(q.code==="union")q.errors=q.errors.flatMap((Y)=>{let J=Y.hasCode("union")?Y.errors:[Y];if(!U&&!X)return J;return J.map((H)=>H.transform((W)=>({...W,path:wX(U,W.path,X)})))});this.nodeConfig=Z.config[this.code];let G=[...q.path??Z.path];if(X)G.push(...X);if(U)G.unshift(...U);this.path=new A2(...G),this.data="data"in q?q.data:Q}transform(U){return new o0(U({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode(U){return this.code===U}get propString(){return v0(this.path)}get expected(){if(this.input.expected)return this.input.expected;let U=this.meta?.expected??this.nodeConfig.expected;return typeof U==="function"?U(this.input):U}get actual(){if(this.input.actual)return this.input.actual;let U=this.meta?.actual??this.nodeConfig.actual;return typeof U==="function"?U(this.data):U}get problem(){if(this.input.problem)return this.input.problem;let U=this.meta?.problem??this.nodeConfig.problem;return typeof U==="function"?U(this):U}get message(){if(this.input.message)return this.input.message;let U=this.meta?.message??this.nodeConfig.message;return typeof U==="function"?U(this):U}get flat(){return this.hasCode("intersection")?[...this.errors]:[this]}toJSON(){return{data:this.data,path:this.path,...this.input,expected:this.expected,actual:this.actual,problem:this.problem,message:this.message}}toString(){return this.message}throw(){throw this}}class W0 extends W6{[Z0]="errors";ctx;constructor(U){super();this.ctx=U}byPath=Object.create(null);get flatByPath(){return S(this.byPath,(U,X)=>[U,X.flat])}get flatProblemsByPath(){return S(this.byPath,(U,X)=>[U,X.flat.map((q)=>q.problem)])}byAncestorPath=Object.create(null);count=0;mutable=this;throw(){throw this.toTraversalError()}toTraversalError(){return new n4(this)}add(U){let X=this.byPath[U.propString];if(X){if(U===X)return;if(X.hasCode("union")&&X.errors.length===0)return;let q=U.hasCode("union")&&U.errors.length===0?U:new o0({code:"intersection",errors:X.hasCode("intersection")?[...X.errors,U]:[X,U]},this.ctx),Z=this.indexOf(X);this.mutable[Z===-1?this.length:Z]=q,this.byPath[U.propString]=q,this.addAncestorPaths(U)}else this.byPath[U.propString]=U,this.addAncestorPaths(U),this.mutable.push(U);this.count++}transform(U){let X=new W0(this.ctx);for(let q of this)X.add(U(q));return X}merge(U){for(let X of U)this.add(new o0({...X,path:[...this.ctx.path,...X.path]},this.ctx))}affectsPath(U){if(this.length===0)return!1;return U.stringifyAncestors().some((X)=>(X in this.byPath))||U.stringify()in this.byAncestorPath}get summary(){return this.toString()}get issues(){return this}toJSON(){return[...this.map((U)=>U.toJSON())]}toString(){return this.join(`
154
154
  `)}addAncestorPaths(U){for(let X of U.path.stringifyAncestors())this.byAncestorPath[X]=g(this.byAncestorPath[X],U)}}class n4 extends Error{name="TraversalError";constructor(U){if(U.length===1)super(U.summary);else super(`
155
- `+U.map((X)=>` • ${gG(X)}`).join(`
156
- `));Object.defineProperty(this,"arkErrors",{value:U,enumerable:!1})}}var gG=(U)=>U.toString().split(`
155
+ `+U.map((X)=>` • ${xG(X)}`).join(`
156
+ `));Object.defineProperty(this,"arkErrors",{value:U,enumerable:!1})}}var xG=(U)=>U.toString().split(`
157
157
  `).join(`
158
- `);class w0{path=[];errors=new W0(this);root;config;queuedMorphs=[];branches=[];seen={};constructor(U,X){this.root=U,this.config=X}get data(){let U=this.root;for(let X of this.path)U=U?.[X];return U}get propString(){return v0(this.path)}reject(U){return this.error(U),!1}mustBe(U){return this.error(U),!1}error(U){let X=typeof U==="object"?U.code?U:{...U,code:"predicate"}:{code:"predicate",expected:U};return this.errorFromContext(X)}hasError(){return this.currentErrorCount!==0}get currentBranch(){return this.branches[this.branches.length-1]}queueMorphs(U){let X={path:new A2(...this.path),morphs:U};if(this.currentBranch)this.currentBranch.queuedMorphs.push(X);else this.queuedMorphs.push(X)}finalize(U){if(this.queuedMorphs.length){if(typeof this.root==="object"&&this.root!==null&&this.config.clone)this.root=this.config.clone(this.root);this.applyQueuedMorphs()}if(this.hasError())return U?U(this.errors):this.errors;return this.root}get currentErrorCount(){return this.currentBranch?this.currentBranch.error?1:0:this.errors.count}get failFast(){return this.branches.length!==0}pushBranch(){this.branches.push({error:void 0,queuedMorphs:[]})}popBranch(){return this.branches.pop()}get external(){return this}errorFromNodeContext(U){return this.errorFromContext(U)}errorFromContext(U){let X=new o0(U,this);if(this.currentBranch)this.currentBranch.error=X;else this.errors.add(X);return X}applyQueuedMorphs(){while(this.queuedMorphs.length){let U=this.queuedMorphs;this.queuedMorphs=[];for(let{path:X,morphs:q}of U){if(this.errors.affectsPath(X))continue;this.applyMorphsAtPath(X,q)}}}applyMorphsAtPath(U,X){let q=U[U.length-1],Z;if(q!==void 0){Z=this.root;for(let Q=0;Q<U.length-1;Q++)Z=Z[U[Q]]}for(let Q of X){this.path=[...U];let G=x(Q),Y=Q(Z===void 0?this.root:Z[q],this);if(Y instanceof o0){if(!this.errors.includes(Y))this.errors.add(Y);break}if(Y instanceof W0){if(!G)this.errors.merge(Y);this.queuedMorphs=[];break}if(Z===void 0)this.root=Y;else Z[q]=Y;this.applyQueuedMorphs()}}}var _0=(U,X,q)=>{if(!q)return X();q.path.push(U);let Z=X();return q.path.pop(),Z};class R2 extends H0{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor(U,X){super((Z,Q,G=this.onFail)=>{if(Q)return this.traverseApply(Z,Q),Q.hasError()?Q.errors:Q.data;return this.rootApply(Z,G)},{attach:U});this.attachments=U,this.$=X,this.onFail=this.meta.onFail??this.$.resolvedConfig.onFail,this.includesTransform=this.hasKind("morph")||this.hasKind("structure")&&this.structuralMorph!==void 0||this.hasKind("sequence")&&this.inner.defaultables!==void 0,this.includesContextualPredicate=this.hasKind("predicate")&&this.inner.predicate.length!==1,this.isCyclic=this.kind==="alias",this.referencesById={[this.id]:this},this.shallowReferences=this.hasKind("structure")?[this,...this.children]:this.children.reduce((Z,Q)=>hG(Z,Q.shallowReferences),[this]);let q=this.isStructural();this.flatRefs=[],this.flatMorphs=[];for(let Z=0;Z<this.children.length;Z++){if(this.includesTransform||=this.children[Z].includesTransform,this.includesContextualPredicate||=this.children[Z].includesContextualPredicate,this.isCyclic||=this.children[Z].isCyclic,!q){let Q=this.children[Z].flatRefs;for(let G=0;G<Q.length;G++){let Y=Q[G];if(!this.flatRefs.some((J)=>Hq(J,Y))){this.flatRefs.push(Y);for(let J of Y.node.branches)if(J.hasKind("morph")||J.hasKind("intersection")&&J.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:Y.path,propString:Y.propString,node:J})}}}Object.assign(this.referencesById,this.children[Z].referencesById)}this.flatRefs.sort((Z,Q)=>Z.path.length>Q.path.length?1:Z.path.length<Q.path.length?-1:Z.propString>Q.propString?1:Z.propString<Q.propString?-1:Z.node.expression<Q.node.expression?-1:1),this.allowsRequiresContext=this.includesContextualPredicate||this.isCyclic,this.rootApplyStrategy=!this.allowsRequiresContext&&this.flatMorphs.length===0?this.shallowMorphs.length===0?"allows":this.shallowMorphs.every((Z)=>Z.length===1||Z.name==="$arkStructuralMorph")?this.hasKind("union")?this.branches.some((Z)=>Z.shallowMorphs.length>1)?"contextual":"branchedOptimistic":this.shallowMorphs.length>1?"contextual":"optimistic":"contextual":"contextual",this.rootApply=this.createRootApply(),this.allows=this.allowsRequiresContext?(Z)=>this.traverseAllows(Z,new w0(Z,this.$.resolvedConfig)):(Z)=>this.traverseAllows(Z)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(X,q)=>{if(this.allows(X))return X;let Z=new w0(X,this.$.resolvedConfig);return this.traverseApply(X,Z),Z.finalize(q)};case"contextual":return(X,q)=>{let Z=new w0(X,this.$.resolvedConfig);return this.traverseApply(X,Z),Z.finalize(q)};case"optimistic":this.contextFreeMorph=this.shallowMorphs[0];let U=this.$.resolvedConfig.clone;return(X,q)=>{if(this.allows(X))return this.contextFreeMorph(U&&(typeof X==="object"&&X!==null||typeof X==="function")?U(X):X);let Z=new w0(X,this.$.resolvedConfig);return this.traverseApply(X,Z),Z.finalize(q)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,y(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=vG(this.metaJson);cacheGetter(U,X){return Object.defineProperty(this,U,{value:X}),X}get description(){return this.cacheGetter("description",this.meta?.description??this.$.resolvedConfig[this.kind].description(this))}get references(){return Object.values(this.referencesById)}precedence=j1(this.kind);precompilation;assert=(U,X)=>this(U,X,(q)=>q.throw());traverse(U,X){return this(U,X,null)}get in(){return this.cacheGetter("in",this.rawIn.isRoot()?this.$.finalize(this.rawIn):this.rawIn)}get rawIn(){return this.cacheGetter("rawIn",this.getIo("in"))}get out(){return this.cacheGetter("out",this.rawOut.isRoot()?this.$.finalize(this.rawOut):this.rawOut)}get rawOut(){return this.cacheGetter("rawOut",this.getIo("out"))}getIo(U){if(!this.includesTransform)return this;let X={};for(let[q,Z]of this.innerEntries){let Q=this.impl.keys[q];if(Q.reduceIo)Q.reduceIo(U,X,Z);else if(Q.child){let G=Z;X[q]=h(G)?G.map((Y)=>U==="in"?Y.rawIn:Y.rawOut):U==="in"?G.rawIn:G.rawOut}else X[q]=Z}return this.$.node(this.kind,X)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals(U){let X=x(U)?U:this.$.parseDefinition(U);return this.innerHash===X.innerHash}ifEquals(U){return this.equals(U)?this:void 0}hasKind(U){return this.kind===U}assertHasKind(U){if(this.kind!==U)Y1(`${this.kind} node was not of asserted kind ${U}`);return this}hasKindIn(...U){return U.includes(this.kind)}assertHasKindIn(...U){if(!F0(U,this.kind))Y1(`${this.kind} node was not one of asserted kinds ${U}`);return this}isBasis(){return F0(Xq,this.kind)}isConstraint(){return F0(O6,this.kind)}isStructural(){return F0(C1,this.kind)}isRefinement(){return F0(o4,this.kind)}isRoot(){return F0(S1,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit(U){return this.hasKind("unit")&&this.allows(U)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select(U){let X=V2.normalize(U);return this._select(X)}_select(U){let X=V2.applyBoundary[U.boundary??"references"](this);if(U.kind)X=X.filter((q)=>q.kind===U.kind);if(U.where)X=X.filter(U.where);return V2.applyMethod[U.method??"filter"](X,this,U)}transform(U,X){return this._transform(U,this._createTransformContext(X))}_createTransformContext(U){return{root:this,selected:void 0,seen:{},path:[],parseOptions:{prereduced:U?.prereduced??!1},undeclaredKeyHandling:void 0,...U}}_transform(U,X){let q=X.bindScope??this.$;if(X.seen[this.id])return this.$.lazilyResolve(X.seen[this.id]);if(X.shouldTransform?.(this,X)===!1)return this;let Z;if(X.seen[this.id]=()=>Z,this.hasKind("structure")&&this.undeclared!==X.undeclaredKeyHandling)X={...X,undeclaredKeyHandling:this.undeclared};let Q=S(this.inner,(W,$)=>{if(!this.impl.keys[W].child)return[W,$];let _=$;if(!h(_)){let A=_._transform(U,X);return A?[W,A]:[]}if(_.length===0)return[W,$];let L=_.flatMap((A)=>{return A._transform(U,X)??[]});return L.length?[W,L]:[]});delete X.seen[this.id];let G=Object.assign(Q,{meta:this.meta}),Y=X.selected&&!X.selected.includes(this)?G:U(this.kind,G,X);if(Y===null)return null;if(x(Y))return Z=Y;let J=Object.keys(Y);if((J.length===0||J.length===1&&J[0]==="meta")&&!S0(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in Y))return X.undeclaredKeyHandling?{...Y,value:O.intrinsic.unknown}:null;if(this.kind==="morph")Y.in??=O.intrinsic.unknown;return Z=q.node(this.kind,Y,X.parseOptions)}configureReferences(U,X="references"){let q=V2.normalize(X),Z=typeof U==="string"?(J,H)=>({...H,meta:{...H.meta,description:U}}):typeof U==="function"?(J,H)=>({...H,meta:U(H.meta)}):(J,H)=>({...H,meta:{...H.meta,...U}});if(q.boundary==="self")return this.$.node(this.kind,Z(this.kind,{...this.inner,meta:this.meta}));let Q=this._select(q),G=Q&&l0(Q),Y=q.boundary==="child"?(J,H)=>H.root.children.includes(J):q.boundary==="shallow"?(J)=>J.kind!=="structure":()=>!0;return this.$.finalize(this.transform(Z,{shouldTransform:Y,selected:G}))}}var V2={applyBoundary:{self:(U)=>[U],child:(U)=>[...U.children],shallow:(U)=>[...U.shallowReferences],references:(U)=>[...U.references]},applyMethod:{filter:(U)=>U,assertFilter:(U,X,q)=>{if(U.length===0)Y1(Jq(X,q));return U},find:(U)=>U[0],assertFind:(U,X,q)=>{if(U.length===0)Y1(Jq(X,q));return U[0]}},normalize:(U)=>typeof U==="function"?{boundary:"references",method:"filter",where:U}:typeof U==="string"?n(U,V2.applyBoundary)?{method:"filter",boundary:U}:{boundary:"references",method:"filter",kind:U}:{boundary:"references",method:"filter",...U}},Jq=(U,X)=>`${U} had no references matching ${E(X)}.`,yG=(U)=>v0(U,{stringifyNonKey:(X)=>X.expression}),kG=/"(\$ark\.[^"]+)"/g,vG=(U)=>JSON.stringify(U).replace(kG,"$1"),P0=(U,X)=>({path:U,node:X,propString:yG(U)}),Hq=(U,X)=>U.propString===X.propString&&U.node.equals(X.node),a4=(U,X)=>C0(U,X,{isEqual:Hq}),hG=(U,X)=>C0(U,X,{isEqual:(q,Z)=>q.equals(Z)});class T extends Array{static init(U,X,q,Z){return new T({kind:U,l:X,r:q,path:Z?.path??[],optional:Z?.optional??!1})}add(U,X,q,Z){return this.push({kind:U,l:X,r:q,path:Z?.path??[],optional:Z?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:U,l:X,r:q}=this[0],Z=v0(U);return e4(`Intersection${Z&&` at ${Z}`} of ${Wq(X,q)}`)}return`The following intersections result in unsatisfiable types:
159
- • ${this.map(({path:U,l:X,r:q})=>`${U}: ${Wq(X,q)}`).join(`
160
- • `)}`}throw(){return F(this.describeReasons())}invert(){let U=this.map((X)=>({...X,l:X.r,r:X.l}));if(!(U instanceof T))return new T(...U);return U}withPrefixKey(U,X){return this.map((q)=>({...q,path:[U,...q.path],optional:q.optional||X==="optional"}))}toNeverIfDisjoint(){return O.intrinsic.never}}var Wq=(U,X)=>`${t4(U)} and ${t4(X)}`,t4=(U)=>x(U)?U.expression:h(U)?U.map(t4).join(" | ")||"never":String(U),e4=(U)=>`${U} results in an unsatisfiable type`;var b1={},$0=(U,X,q)=>u(U,X,{$:q,invert:!1,pipe:!1}),D2=(U,X,q)=>u(U,X,{$:q,invert:!1,pipe:!0}),u=(U,X,q)=>{let Z=q.pipe?"|>":"&",Q=`${U.hash}${Z}${X.hash}`;if(b1[Q]!==void 0)return b1[Q];if(!q.pipe){let J=`${X.hash}${Z}${U.hash}`;if(b1[J]!==void 0){let H=b1[J],W=H instanceof T?H.invert():H;return b1[Q]=W,W}}let G=!q.pipe||!U.includesTransform&&!X.includesTransform;if(G&&U.equals(X))return U;let Y=G?U9(U,X,q):U.hasKindIn(...S1)?xG(U,X,q):U9(U,X,q);if(x(Y)){if(U.equals(Y))Y=U;else if(X.equals(Y))Y=X}return b1[Q]=Y,Y},U9=(U,X,q)=>{let Z=U.precedence<X.precedence?U.kind:X.kind,Q=U.impl.intersections[X.kind]??X.impl.intersections[U.kind];if(Q===void 0)return null;else if(Z===U.kind)return Q(U,X,q);else{let G=Q(X,U,{...q,invert:!q.invert});if(G instanceof T)G=G.invert();return G}},xG=(U,X,q)=>U.includesTransform||X.includesTransform?q.invert?_q(X,U,q):_q(U,X,q):U9(U,X,q),_q=(U,X,q)=>U.distribute((Z)=>uG(Z,X,q),(Z)=>{let Q=Z.filter(x);if(Q.length===0)return T.init("union",U.branches,X.branches);if(Q.length<U.branches.length||!U.branches.every((J,H)=>J.rawIn.equals(Q[H].rawIn)))return q.$.parseSchema(Q);let G;if(Q.length===1){let J=Q[0];if(!G)return J;return q.$.node("morph",{...J.inner,in:J.rawIn.configure(G,"self")})}let Y={branches:Q};if(G)Y.meta=G;return q.$.parseSchema(Y)}),uG=(U,X,q)=>{if(U.hasKind("morph")){let Q=[...U.morphs];if(U.lastMorphIfNode){let G=u(U.lastMorphIfNode,X,q);if(G instanceof T)return G;Q[Q.length-1]=G}else Q.push(X);return q.$.node("morph",{morphs:Q,in:U.inner.in})}if(X.hasKind("morph")){let Q=u(U,X.rawIn,q);if(Q instanceof T)return Q;return q.$.node("morph",{morphs:[X],in:Q})}return q.$.node("morph",{morphs:[X],in:U})};class O0 extends R2{constructor(U,X){super(U,X);Object.defineProperty(this,Z0,{value:"constraint",enumerable:!1})}impliedSiblings;intersect(U){return $0(this,U,this.$)}}class h0 extends O0{traverseApply=(U,X)=>{if(!this.traverseAllows(U,X))X.errorFromNodeContext(this.errorContext)};compile(U){if(U.traversalKind==="Allows")U.return(this.compiledCondition);else U.if(this.compiledNegation,()=>U.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return s0(this.errorContext)}}var q0=(U)=>(X,q)=>{if(h(X)){if(X.length===0)return;let Q=X.map((G)=>q.$.node(U,G));if(U==="predicate")return Q;return Q.sort((G,Y)=>G.hash<Y.hash?-1:1)}let Z=q.$.node(U,X);return Z.hasOpenIntersection()?[Z]:Z},f1=(U)=>{let X=U.r.shift();if(!X){let Z=U.l.length===0&&U.kind==="structure"?O.intrinsic.unknown.internal:U.ctx.$.node(U.kind,Object.assign(U.baseInner,mG(U.l)),{prereduced:!0});for(let Q of U.roots){if(Z instanceof T)return Z;Z=u(Q,Z,U.ctx)}return Z}let q=!1;for(let Z=0;Z<U.l.length;Z++){let Q=u(U.l[Z],X,U.ctx);if(Q===null)continue;if(Q instanceof T)return Q;if(Q.isRoot())return U.roots.push(Q),U.l.splice(Z),f1(U);if(!q)U.l[Z]=Q,q=!0;else if(!U.l.includes(Q))return y(`Unexpectedly encountered multiple distinct intersection results for refinement ${X}`)}if(!q)U.l.push(X);if(U.kind==="intersection"){if(X.impliedSiblings)for(let Z of X.impliedSiblings)C0(U.r,Z)}return f1(U)},g1=(U)=>{return Object.entries(U).flatMap(([q,Z])=>(q in B6)?Z:[]).sort((q,Z)=>q.precedence<Z.precedence?-1:q.precedence>Z.precedence?1:q.kind==="predicate"&&Z.kind==="predicate"?0:q.hash<Z.hash?-1:1)},mG=(U)=>{let X={};for(let q of U)if(q.hasOpenIntersection())X[q.kind]=g(X[q.kind],q);else{if(X[q.kind])return y(`Unexpected intersection of closed refinements of kind ${q.kind}`);X[q.kind]=q}return X},$q=(...U)=>F(Lq(...U)),Lq=(U,X,q)=>{let Z=q.hasKind("morph")?"a morph":q.isUnknown()?"unknown":q.exclude(X).defaultShortDescription;return`${hX(U)} operand must be ${X.description} (was ${Z})`};var zq=(U,X,q)=>new r0(U,X,q,q,null);class V6 extends H0{}class r0 extends H0{[Z0]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor(U,X,q,Z,Q){super((...G)=>{let Y=S(this.names,(J,H)=>{let W=this.arg$.parse(G[J]);if(!W.extends(this.constraints[J]))F(pG(H,this.constraints[J].expression,W.expression));return[H,W]});if(this.defIsLazy()){let J=this.bodyDef(Y);return this.$.parse(J)}return this.$.parse(X,{args:Y})});this.paramDefs=U,this.bodyDef=X,this.$=q,this.arg$=Z,this.hkt=Q,this.description=Q?new Q().description??`a generic type for ${Q.constructor.name}`:"a generic type",this.baseInstantiation=this(...this.constraints)}defIsLazy(){return this.bodyDef instanceof V6}cacheGetter(U,X){return Object.defineProperty(this,U,{value:X}),X}get json(){return this.cacheGetter("json",{params:this.params.map((U)=>U[1].isUnknown()?U[0]:[U[0],U[1].json]),body:nX(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map((U)=>typeof U==="string"?[U,O.intrinsic.unknown]:[U[0],this.$.parse(U[1])]))}get names(){return this.cacheGetter("names",this.params.map((U)=>U[0]))}get constraints(){return this.cacheGetter("constraints",this.params.map((U)=>U[1]))}get internal(){return this}get referencesById(){return this.baseInstantiation.internal.referencesById}get references(){return this.baseInstantiation.internal.references}}var pG=(U,X,q)=>`${U} must be assignable to ${X} (was ${q})`;var lG=j({kind:"predicate",hasAssociatedError:!0,collapsibleKey:"predicate",keys:{predicate:{}},normalize:(U)=>typeof U==="function"?{predicate:U}:U,defaults:{description:(U)=>`valid according to ${U.predicate.name||"an anonymous predicate"}`},intersectionIsOpen:!0,intersections:{predicate:()=>null}});class Fq extends O0{serializedPredicate=d(this.predicate);compiledCondition=`${this.serializedPredicate}(data, ctx)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=null;expression=this.serializedPredicate;traverseAllows=this.predicate;errorContext={code:"predicate",description:this.description,meta:this.meta};compiledErrorContext=s0(this.errorContext);traverseApply=(U,X)=>{let q=X.currentErrorCount;if(!this.predicate(U,X.external)&&X.currentErrorCount===q)X.errorFromNodeContext(this.errorContext)};compile(U){if(U.traversalKind==="Allows"){U.return(this.compiledCondition);return}U.initializeErrorCount(),U.if(`${this.compiledNegation} && ctx.currentErrorCount === errorCount`,()=>U.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}reduceJsonSchema(U,X){return X.fallback.predicate({code:"predicate",base:U,predicate:this.predicate})}}var X9={implementation:lG,Node:Fq};var dG=j({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:(U)=>Number.isInteger(U)?U:F(cG(U))}},normalize:(U)=>typeof U==="number"?{rule:U}:U,hasAssociatedError:!0,defaults:{description:(U)=>U.rule===1?"an integer":U.rule===2?"even":`a multiple of ${U.rule}`},intersections:{divisor:(U,X,q)=>q.$.node("divisor",{rule:Math.abs(U.rule*X.rule/iG(U.rule,X.rule))})},obviatesBasisDescription:!0});class Aq extends h0{traverseAllows=(U)=>U%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=O.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema(U){if(U.type="integer",this.rule===1)return U;return U.multipleOf=this.rule,U}}var q9={implementation:dG,Node:Aq};var cG=(U)=>`divisor must be an integer (was ${U})`,iG=(U,X)=>{let q,Z=U,Q=X;while(Q!==0)q=Q,Q=Z%Q,Z=q;return Z};class z0 extends h0{boundOperandKind=nG[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=aG(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${sG[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?tG(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan(U){return(this.limitKind==="upper"?this.numericLimit<U.numericLimit:this.numericLimit>U.numericLimit)||this.numericLimit===U.numericLimit&&this.exclusive===!0&&!U.exclusive}overlapsRange(U){if(this.isStricterThan(U))return!1;if(this.numericLimit===U.numericLimit&&(this.exclusive||U.exclusive))return!1;return!0}overlapIsUnit(U){return this.numericLimit===U.numericLimit&&!this.exclusive&&!U.exclusive}}var sG={"<":">=","<=":">",">":"<=",">=":"<"},oG={min:"max",minLength:"maxLength",after:"before"},R6={parse:(U)=>U||void 0},D6=(U)=>(X)=>{if(typeof X==="number")return{rule:X};let{exclusive:q,...Z}=X;return q?{...Z,rule:U==="minLength"?Z.rule+1:Z.rule-1}:Z},M6=(U)=>(X)=>{if(typeof X==="number"||typeof X==="string"||X instanceof Date)return{rule:X};let{exclusive:q,...Z}=X;if(!q)return Z;let Q=typeof Z.rule==="number"?Z.rule:typeof Z.rule==="string"?new Date(Z.rule).valueOf():Z.rule.valueOf();return q?{...Z,rule:U==="after"?Q+1:Q-1}:Z},w6=(U)=>typeof U==="string"||typeof U==="number"?new Date(U):U,rG=(U,X)=>`${U} bound must be a positive integer (was ${X})`,y1=(U)=>(X)=>{if(!Number.isInteger(X)||X<0)F(rG(U,X));return X},nG={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},aG=(U,X)=>`${n(U,oG)?">":"<"}${X?"":"="}`,tG=(U)=>typeof U==="string"?U:new Date(U).toLocaleString(),Oq=(U)=>`Bounded expression ${U} must be exactly one of number, string, Array, or Date`;var eG=j({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:w6,serialize:(U)=>U.toISOString()}},normalize:M6("after"),defaults:{description:(U)=>`${U.collapsibleLimitString} or later`,actual:$1},intersections:{after:(U,X)=>U.isStricterThan(X)?U:X}});class Bq extends z0{impliedBasis=O.intrinsic.Date.internal;collapsibleLimitString=$1(this.rule);traverseAllows=(U)=>U>=this.rule;reduceJsonSchema(U,X){return X.fallback.date({code:"date",base:U,after:this.rule})}}var Z9={implementation:eG,Node:Bq};var U5=j({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:w6,serialize:(U)=>U.toISOString()}},normalize:M6("before"),defaults:{description:(U)=>`${U.collapsibleLimitString} or earlier`,actual:$1},intersections:{before:(U,X)=>U.isStricterThan(X)?U:X,after:(U,X,q)=>U.overlapsRange(X)?U.overlapIsUnit(X)?q.$.node("unit",{unit:U.rule}):null:T.init("range",U,X)}});class Tq extends z0{collapsibleLimitString=$1(this.rule);traverseAllows=(U)=>U<=this.rule;impliedBasis=O.intrinsic.Date.internal;reduceJsonSchema(U,X){return X.fallback.date({code:"date",base:U,before:this.rule})}}var Q9={implementation:U5,Node:Tq};var X5=j({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:y1("exactLength")}},normalize:(U)=>typeof U==="number"?{rule:U}:U,hasAssociatedError:!0,defaults:{description:(U)=>`exactly length ${U.rule}`,actual:(U)=>`${U.length}`},intersections:{exactLength:(U,X,q)=>T.init("unit",q.$.node("unit",{unit:U.rule}),q.$.node("unit",{unit:X.rule}),{path:["length"]}),minLength:(U,X)=>U.rule>=X.rule?U:T.init("range",U,X),maxLength:(U,X)=>U.rule<=X.rule?U:T.init("range",U,X)}});class Vq extends h0{traverseAllows=(U)=>U.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=O.intrinsic.lengthBoundable.internal;expression=`== ${this.rule}`;reduceJsonSchema(U){switch(U.type){case"string":return U.minLength=this.rule,U.maxLength=this.rule,U;case"array":return U.minItems=this.rule,U.maxItems=this.rule,U;default:return p.throwInternalOperandError("exactLength",U)}}}var G9={implementation:X5,Node:Vq};var q5=j({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:R6},normalize:(U)=>typeof U==="number"?{rule:U}:U,defaults:{description:(U)=>{if(U.rule===0)return U.exclusive?"negative":"non-positive";return`${U.exclusive?"less than":"at most"} ${U.rule}`}},intersections:{max:(U,X)=>U.isStricterThan(X)?U:X,min:(U,X,q)=>U.overlapsRange(X)?U.overlapIsUnit(X)?q.$.node("unit",{unit:U.rule}):null:T.init("range",U,X)},obviatesBasisDescription:!0});class Rq extends z0{impliedBasis=O.intrinsic.number.internal;traverseAllows=this.exclusive?(U)=>U<this.rule:(U)=>U<=this.rule;reduceJsonSchema(U){if(this.exclusive)U.exclusiveMaximum=this.rule;else U.maximum=this.rule;return U}}var Y9={implementation:q5,Node:Rq};var Z5=j({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:y1("maxLength")}},reduce:(U,X)=>U.rule===0?X.node("exactLength",U):void 0,normalize:D6("maxLength"),defaults:{description:(U)=>`at most length ${U.rule}`,actual:(U)=>`${U.length}`},intersections:{maxLength:(U,X)=>U.isStricterThan(X)?U:X,minLength:(U,X,q)=>U.overlapsRange(X)?U.overlapIsUnit(X)?q.$.node("exactLength",{rule:U.rule}):null:T.init("range",U,X)}});class Dq extends z0{impliedBasis=O.intrinsic.lengthBoundable.internal;traverseAllows=(U)=>U.length<=this.rule;reduceJsonSchema(U){switch(U.type){case"string":return U.maxLength=this.rule,U;case"array":return U.maxItems=this.rule,U;default:return p.throwInternalOperandError("maxLength",U)}}}var J9={implementation:Z5,Node:Dq};var Q5=j({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:R6},normalize:(U)=>typeof U==="number"?{rule:U}:U,defaults:{description:(U)=>{if(U.rule===0)return U.exclusive?"positive":"non-negative";return`${U.exclusive?"more than":"at least"} ${U.rule}`}},intersections:{min:(U,X)=>U.isStricterThan(X)?U:X},obviatesBasisDescription:!0});class Mq extends z0{impliedBasis=O.intrinsic.number.internal;traverseAllows=this.exclusive?(U)=>U>this.rule:(U)=>U>=this.rule;reduceJsonSchema(U){if(this.exclusive)U.exclusiveMinimum=this.rule;else U.minimum=this.rule;return U}}var H9={implementation:Q5,Node:Mq};var G5=j({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:y1("minLength")}},reduce:(U)=>U.rule===0?O.intrinsic.unknown:void 0,normalize:D6("minLength"),defaults:{description:(U)=>U.rule===1?"non-empty":`at least length ${U.rule}`,actual:(U)=>U.length===0?"":`${U.length}`},intersections:{minLength:(U,X)=>U.isStricterThan(X)?U:X}});class wq extends z0{impliedBasis=O.intrinsic.lengthBoundable.internal;traverseAllows=(U)=>U.length>=this.rule;reduceJsonSchema(U){switch(U.type){case"string":return U.minLength=this.rule,U;case"array":return U.minItems=this.rule,U;default:return p.throwInternalOperandError("minLength",U)}}}var W9={implementation:G5,Node:wq};var Pq={min:H9.implementation,max:Y9.implementation,minLength:W9.implementation,maxLength:J9.implementation,exactLength:G9.implementation,after:Z9.implementation,before:Q9.implementation},Iq={min:H9.Node,max:Y9.Node,minLength:W9.Node,maxLength:J9.Node,exactLength:G9.Node,after:Z9.Node,before:Q9.Node};var Y5=j({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:(U)=>typeof U==="string"?{rule:U}:U instanceof RegExp?U.flags?{rule:U.source,flags:U.flags}:{rule:U.source}:U,obviatesBasisDescription:!0,obviatesBasisExpression:!0,hasAssociatedError:!0,intersectionIsOpen:!0,defaults:{description:(U)=>`matched by ${U.rule}`},intersections:{pattern:()=>null}});class Kq extends h0{instance=new RegExp(this.rule,this.flags);expression=`${this.instance}`;traverseAllows=this.instance.test.bind(this.instance);compiledCondition=`${this.expression}.test(data)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=O.intrinsic.string.internal;reduceJsonSchema(U,X){if(U.pattern)return X.fallback.patternIntersection({code:"patternIntersection",base:U,pattern:this.rule});return U.pattern=this.rule,U}}var _9={implementation:Y5,Node:Kq};var M2=(U,X)=>{let q=J5(U);if(X&&!X.includes(q))return F(`Root of kind ${q} should be one of ${X}`);return q},J5=(U)=>{if(M(U,"root"))return U.kind;if(typeof U==="string")return U[0]==="$"?"alias":(U in Y0)?"domain":"proto";if(typeof U==="function")return"proto";if(typeof U!=="object"||U===null)return F(Nq(U));if("morphs"in U)return"morph";if("branches"in U||h(U))return"union";if("unit"in U)return"unit";if("reference"in U)return"alias";let X=Object.keys(U);if(X.length===0||X.some((q)=>(q in B6)))return"intersection";if("proto"in U)return"proto";if("domain"in U)return"domain";return F(Nq(U))},Nq=(U)=>`${E(U)} is not a valid type schema`,Cq={},H5=(U)=>h(U)?U.map((X)=>X.collapsibleJson):U.collapsibleJson,Q0={};O.nodesByRegisteredId=Q0;var $9=(U)=>{return Cq[U]??=0,`${U}${++Cq[U]}`},L9=(U)=>{let X=k1[U.kind],q=X.applyConfig?.(U.def,U.$.resolvedConfig)??U.def,Z={},{meta:Q,...G}=q,Y=Q===void 0?{}:typeof Q==="string"?{description:Q}:Q,J=y4(G).sort(([W],[$])=>E1(W)?E1($)?j1(W)-j1($):1:E1($)?-1:W<$?-1:1).filter(([W,$])=>{if(W.startsWith("meta.")){let _=W.slice(5);return Y[_]=$,!1}return!0});for(let W of J){let $=W[0],_=X.keys[$];if(!_)return F(`Key ${$} is not valid on ${U.kind} schema`);let L=_.parse?_.parse(W[1],U):W[1];if(L!==J0&&(L!==void 0||_.preserveUndefined))Z[$]=L}if(X.reduce&&!U.prereduced){let W=X.reduce(Z,U.$);if(W){if(W instanceof T)return W.throw();return W5(W,Y)}}return z9({id:U.id,kind:U.kind,inner:Z,meta:Y,$:U.$})},z9=({id:U,kind:X,inner:q,meta:Z,$:Q,ignoreCache:G})=>{let Y=k1[X],J=y4(q),H=[],W={};for(let[D,P]of J){let K=Y.keys[D],C=K.serialize??(K.child?H5:A0);if(W[D]=C(P),K.child===!0){let N=P;if(h(N))H.push(...N);else H.push(N)}else if(typeof K.child==="function")H.push(...K.child(P))}if(Y.finalizeInnerJson)W=Y.finalizeInnerJson(W);let $={...W},_={};if(!S0(Z))_=S(Z,(D,P)=>[D,D==="examples"?P:A0(P)]),$.meta=P6(_,"description",!0);W=P6(W,Y.collapsibleKey,!1);let L=JSON.stringify({kind:X,...W});$=P6($,Y.collapsibleKey,!1);let A=P6($,Y.collapsibleKey,!0),V=JSON.stringify({kind:X,...$});if(Q.nodesByHash[V]&&!G)return Q.nodesByHash[V];let z={id:U,kind:X,impl:Y,inner:q,innerEntries:J,innerJson:W,innerHash:L,meta:Z,metaJson:_,json:$,hash:V,collapsibleJson:A,children:H};if(X!=="intersection"){for(let D in q)if(D!=="in"&&D!=="out")z[D]=q[D]}let B=new Eq[X](z,Q);return Q.nodesByHash[V]=B},Sq=(U,X)=>{if(U.id===X)return U;if(x(Q0[X]))y(`Unexpected attempt to overwrite node id ${X}`);return z9({id:X,kind:U.kind,inner:U.inner,meta:U.meta,$:U.$,ignoreCache:!0})},W5=(U,X,q)=>{if(q&&x(Q0[q]))y(`Unexpected attempt to overwrite node id ${q}`);return z9({id:q??$9(X.alias??U.kind),kind:U.kind,inner:U.inner,meta:X,$:U.$})},P6=(U,X,q)=>{let Z=Object.keys(U);if(Z.length===1&&Z[0]===X){let Q=U[X];if(q)return Q;if(G0(Q,"object")&&(Object.keys(Q).length===1||Array.isArray(Q)))return Q}return U};var w2=(U,X,q)=>{if(U.key!==X.key)return null;let Z=U.key,Q=u(U.value,X.value,q),G=U.required||X.required?"required":"optional";if(Q instanceof T)if(G==="optional")Q=O.intrinsic.never.internal;else return Q.withPrefixKey(U.key,U.required&&X.required?"required":"optional");if(G==="required")return q.$.node("required",{key:Z,value:Q});let Y=U.hasDefault()?X.hasDefault()?U.default===X.default?U.default:F(F9(U.default,X.default)):U.default:X.hasDefault()?X.default:J0;return q.$.node("optional",{key:Z,value:Q,default:Y})};class P2 extends O0{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=O.intrinsic.object.internal;serializedKey=M0(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=g(this.value.flatRefs.map((U)=>P0([this.key,...U.path],U.node)),P0([this.key],this.value));_transform(U,X){X.path.push(this.key);let q=super._transform(U,X);return X.path.pop(),q}hasDefault(){return"default"in this.inner}traverseAllows=(U,X)=>{if(this.key in U)return _0(this.key,()=>this.value.traverseAllows(U[this.key],X),X);return this.optional};traverseApply=(U,X)=>{if(this.key in U)_0(this.key,()=>this.value.traverseApply(U[this.key],X),X);else if(this.hasKind("required"))X.errorFromNodeContext(this.errorContext)};compile(U){if(U.if(`${this.serializedKey} in data`,()=>U.traverseKey(this.serializedKey,`data${U.prop(this.key)}`,this.value)),this.hasKind("required"))U.else(()=>U.traversalKind==="Apply"?U.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`):U.return(!1));if(U.traversalKind==="Allows")U.return(!0)}}var F9=(U,X)=>`Invalid intersection of default values ${E(U)} & ${E(X)}`;var _5=j({kind:"optional",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(U,X)=>X.$.parseSchema(U)},default:{preserveUndefined:!0}},normalize:(U)=>U,reduce:(U,X)=>{if(X.resolvedConfig.exactOptionalPropertyTypes===!1){if(!U.value.allows(void 0))return X.node("optional",{...U,value:U.value.or(I.undefined)},{prereduced:!0})}},defaults:{description:(U)=>`${U.compiledKey}?: ${U.value.description}`},intersections:{optional:w2}});class jq extends P2{constructor(...U){super(...U);if("default"in this.inner)K2(this.value,this.inner.default,this.key)}get rawIn(){let U=super.rawIn;if(!this.hasDefault())return U;return this.$.node("optional",_6(U.inner,{default:!0}),{prereduced:!0})}get outProp(){if(!this.hasDefault())return this;let{default:U,...X}=this.inner;return this.cacheGetter("outProp",this.$.node("required",X,{prereduced:!0}))}expression=this.hasDefault()?`${this.compiledKey}: ${this.value.expression} = ${E(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=L5(this);defaultValueMorphRef=this.defaultValueMorph&&d(this.defaultValueMorph)}var I2={implementation:_5,Node:jq},$5={},L5=(U)=>{if(!U.hasDefault())return;let X=`{${U.compiledKey}: ${U.value.id} = ${A0(U.default)}}`;return $5[X]??=A9(U.key,U.value,U.default)},A9=(U,X,q)=>{if(typeof q==="function")return X.includesTransform?(Q,G)=>{return _0(U,()=>X(Q[U]=q(),G),G),Q}:(Q)=>{return Q[U]=q(),Q};let Z=X.includesTransform?X.assert(q):q;return G0(Z,"object")?(Q,G)=>{return _0(U,()=>X(Q[U]=q,G),G),Q}:(Q)=>{return Q[U]=Z,Q}},K2=(U,X,q)=>{let Z=d0(X);if(G0(X,"object")&&!Z)F(z5(q));let Q=U.in(Z?X():X);if(Q instanceof W0){if(q===null)F(`Default ${Q.summary}`);let G=Q.transform((Y)=>Y.transform((J)=>({...J,prefixPath:[q]})));F(`Default for ${G.summary}`)}return X},z5=(U)=>{return`Non-primitive default ${U===null?"":typeof U==="number"?`for value at [${U}] `:`for ${M0(U)} `}must be specified as a function like () => ({my: 'object'})`};class B0 extends R2{constructor(U,X){super(U,X);Object.defineProperty(this,Z0,{value:"root",enumerable:!1})}get rawIn(){return super.rawIn}get rawOut(){return super.rawOut}get internal(){return this}get "~standard"(){return{vendor:"arktype",version:1,validate:(U)=>{let X=this(U);if(X instanceof W0)return X;return{value:X}},jsonSchema:{input:(U)=>this.rawIn.toJsonSchema({target:bq(U.target),...U.libraryOptions}),output:(U)=>this.rawOut.toJsonSchema({target:bq(U.target),...U.libraryOptions})}}}as(){return this}brand(U){if(U==="")return F(F5);return this}readonly(){return this}branches=this.hasKind("union")?this.inner.branches:[this];distribute(U,X){let q=this.branches.map(U);return X?.(q)??q}get shortDescription(){return this.meta.description??this.defaultShortDescription}toJsonSchema(U={}){let X=r4(this.$.resolvedConfig.toJsonSchema,U);X.useRefs||=this.isCyclic;let q=typeof X.dialect==="string"?{$schema:X.dialect}:{};if(Object.assign(q,this.toJsonSchemaRecurse(X)),X.useRefs){let Z=S(this.references,(Q,G)=>G.isRoot()&&!G.alwaysExpandJsonSchema?[G.id,G.toResolvedJsonSchema(X)]:[]);if(X.target==="draft-07")Object.assign(q,{definitions:Z});else q.$defs=Z}return q}toJsonSchemaRecurse(U){if(U.useRefs&&!this.alwaysExpandJsonSchema)return{$ref:`#/${U.target==="draft-07"?"definitions":"$defs"}/${this.id}`};return this.toResolvedJsonSchema(U)}get alwaysExpandJsonSchema(){return this.isBasis()||this.kind==="alias"||this.hasKind("union")&&this.isBoolean}toResolvedJsonSchema(U){let X=this.innerToJsonSchema(U);return Object.assign(X,this.metaJson)}intersect(U){let X=this.$.parseDefinition(U),q=this.rawIntersect(X);if(q instanceof T)return q;return this.$.finalize(q)}rawIntersect(U){return $0(this,U,this.$)}toNeverIfDisjoint(){return this}and(U){let X=this.intersect(U);return X instanceof T?X.throw():X}rawAnd(U){let X=this.rawIntersect(U);return X instanceof T?X.throw():X}or(U){let X=this.$.parseDefinition(U);return this.$.finalize(this.rawOr(X))}rawOr(U){let X=[...this.branches,...U.branches];return this.$.node("union",X)}map(U){return this.$.schema(this.applyStructuralOperation("map",[U]))}pick(...U){return this.$.schema(this.applyStructuralOperation("pick",U))}omit(...U){return this.$.schema(this.applyStructuralOperation("omit",U))}required(){return this.$.schema(this.applyStructuralOperation("required",[]))}partial(){return this.$.schema(this.applyStructuralOperation("partial",[]))}_keyof;keyof(){if(this._keyof)return this._keyof;let U=this.applyStructuralOperation("keyof",[]).reduce((X,q)=>X.intersect(q).toNeverIfDisjoint(),O.intrinsic.unknown.internal);if(U.branches.length===0)F(e4(`keyof ${this.expression}`));return this._keyof=this.$.finalize(U)}get props(){if(this.branches.length!==1)return F(O5(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge(U){let X=this.$.parseDefinition(U);return this.$.schema(X.distribute((q)=>this.applyStructuralOperation("merge",[fq(q)??F(gq("merge",q.expression))])))}applyStructuralOperation(U,X){return this.distribute((q)=>{if(q.equals(O.intrinsic.object)&&U!=="merge")return q;let Z=fq(q);if(!Z)F(gq(U,q.expression));if(U==="keyof")return Z.keyof();if(U==="get")return Z.get(...X);if(U==="props")return Z.props;let Q=U==="required"?"require":U==="partial"?"optionalize":U;return this.$.node("intersection",{domain:"object",structure:Z[Q](...X)})})}get(...U){if(U[0]===void 0)return this;return this.$.schema(this.applyStructuralOperation("get",U))}extract(U){let X=this.$.parseDefinition(U);return this.$.schema(this.branches.filter((q)=>q.extends(X)))}exclude(U){let X=this.$.parseDefinition(U);return this.$.schema(this.branches.filter((q)=>!q.extends(X)))}array(){return this.$.schema(this.isUnknown()?{proto:Array}:{proto:Array,sequence:this},{prereduced:!0})}overlaps(U){return!(this.intersect(U)instanceof T)}extends(U){if(this.isNever())return!0;let X=this.intersect(U);return!(X instanceof T)&&this.equals(X)}ifExtends(U){return this.extends(U)?this:void 0}subsumes(U){return this.$.parseDefinition(U).extends(this)}configure(U,X="shallow"){return this.configureReferences(U,X)}describe(U,X="shallow"){return this.configure({description:U},X)}optional(){return[this,"?"]}default(U){return K2(this,U,null),[this,"=",U]}from(U){return this.assert(U)}_pipe(...U){let X=U.reduce((q,Z)=>q.rawPipeOnce(Z),this);return this.$.finalize(X)}tryPipe(...U){let X=U.reduce((q,Z)=>q.rawPipeOnce(M(Z,"root")?Z:(Q,G)=>{try{return Z(Q,G)}catch(Y){return G.error({code:"predicate",predicate:Z,actual:`aborted due to error:
158
+ `);class w0{path=[];errors=new W0(this);root;config;queuedMorphs=[];branches=[];seen={};constructor(U,X){this.root=U,this.config=X}get data(){let U=this.root;for(let X of this.path)U=U?.[X];return U}get propString(){return v0(this.path)}reject(U){return this.error(U),!1}mustBe(U){return this.error(U),!1}error(U){let X=typeof U==="object"?U.code?U:{...U,code:"predicate"}:{code:"predicate",expected:U};return this.errorFromContext(X)}hasError(){return this.currentErrorCount!==0}get currentBranch(){return this.branches[this.branches.length-1]}queueMorphs(U){let X={path:new A2(...this.path),morphs:U};if(this.currentBranch)this.currentBranch.queuedMorphs.push(X);else this.queuedMorphs.push(X)}finalize(U){if(this.queuedMorphs.length){if(typeof this.root==="object"&&this.root!==null&&this.config.clone)this.root=this.config.clone(this.root);this.applyQueuedMorphs()}if(this.hasError())return U?U(this.errors):this.errors;return this.root}get currentErrorCount(){return this.currentBranch?this.currentBranch.error?1:0:this.errors.count}get failFast(){return this.branches.length!==0}pushBranch(){this.branches.push({error:void 0,queuedMorphs:[]})}popBranch(){return this.branches.pop()}get external(){return this}errorFromNodeContext(U){return this.errorFromContext(U)}errorFromContext(U){let X=new o0(U,this);if(this.currentBranch)this.currentBranch.error=X;else this.errors.add(X);return X}applyQueuedMorphs(){while(this.queuedMorphs.length){let U=this.queuedMorphs;this.queuedMorphs=[];for(let{path:X,morphs:q}of U){if(this.errors.affectsPath(X))continue;this.applyMorphsAtPath(X,q)}}}applyMorphsAtPath(U,X){let q=U[U.length-1],Z;if(q!==void 0){Z=this.root;for(let Q=0;Q<U.length-1;Q++)Z=Z[U[Q]]}for(let Q of X){this.path=[...U];let G=x(Q),Y=Q(Z===void 0?this.root:Z[q],this);if(Y instanceof o0){if(!this.errors.includes(Y))this.errors.add(Y);break}if(Y instanceof W0){if(!G)this.errors.merge(Y);this.queuedMorphs=[];break}if(Z===void 0)this.root=Y;else Z[q]=Y;this.applyQueuedMorphs()}}}var _0=(U,X,q)=>{if(!q)return X();q.path.push(U);let Z=X();return q.path.pop(),Z};class R2 extends H0{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor(U,X){super((Z,Q,G=this.onFail)=>{if(Q)return this.traverseApply(Z,Q),Q.hasError()?Q.errors:Q.data;return this.rootApply(Z,G)},{attach:U});this.attachments=U,this.$=X,this.onFail=this.meta.onFail??this.$.resolvedConfig.onFail,this.includesTransform=this.hasKind("morph")||this.hasKind("structure")&&this.structuralMorph!==void 0||this.hasKind("sequence")&&this.inner.defaultables!==void 0,this.includesContextualPredicate=this.hasKind("predicate")&&this.inner.predicate.length!==1,this.isCyclic=this.kind==="alias",this.referencesById={[this.id]:this},this.shallowReferences=this.hasKind("structure")?[this,...this.children]:this.children.reduce((Z,Q)=>lG(Z,Q.shallowReferences),[this]);let q=this.isStructural();this.flatRefs=[],this.flatMorphs=[];for(let Z=0;Z<this.children.length;Z++){if(this.includesTransform||=this.children[Z].includesTransform,this.includesContextualPredicate||=this.children[Z].includesContextualPredicate,this.isCyclic||=this.children[Z].isCyclic,!q){let Q=this.children[Z].flatRefs;for(let G=0;G<Q.length;G++){let Y=Q[G];if(!this.flatRefs.some((J)=>Wq(J,Y))){this.flatRefs.push(Y);for(let J of Y.node.branches)if(J.hasKind("morph")||J.hasKind("intersection")&&J.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:Y.path,propString:Y.propString,node:J})}}}Object.assign(this.referencesById,this.children[Z].referencesById)}this.flatRefs.sort((Z,Q)=>Z.path.length>Q.path.length?1:Z.path.length<Q.path.length?-1:Z.propString>Q.propString?1:Z.propString<Q.propString?-1:Z.node.expression<Q.node.expression?-1:1),this.allowsRequiresContext=this.includesContextualPredicate||this.isCyclic,this.rootApplyStrategy=!this.allowsRequiresContext&&this.flatMorphs.length===0?this.shallowMorphs.length===0?"allows":this.shallowMorphs.every((Z)=>Z.length===1||Z.name==="$arkStructuralMorph")?this.hasKind("union")?this.branches.some((Z)=>Z.shallowMorphs.length>1)?"contextual":"branchedOptimistic":this.shallowMorphs.length>1?"contextual":"optimistic":"contextual":"contextual",this.rootApply=this.createRootApply(),this.allows=this.allowsRequiresContext?(Z)=>this.traverseAllows(Z,new w0(Z,this.$.resolvedConfig)):(Z)=>this.traverseAllows(Z)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(X,q)=>{if(this.allows(X))return X;let Z=new w0(X,this.$.resolvedConfig);return this.traverseApply(X,Z),Z.finalize(q)};case"contextual":return(X,q)=>{let Z=new w0(X,this.$.resolvedConfig);return this.traverseApply(X,Z),Z.finalize(q)};case"optimistic":this.contextFreeMorph=this.shallowMorphs[0];let U=this.$.resolvedConfig.clone;return(X,q)=>{if(this.allows(X))return this.contextFreeMorph(U&&(typeof X==="object"&&X!==null||typeof X==="function")?U(X):X);let Z=new w0(X,this.$.resolvedConfig);return this.traverseApply(X,Z),Z.finalize(q)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,y(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=pG(this.metaJson);cacheGetter(U,X){return Object.defineProperty(this,U,{value:X}),X}get description(){return this.cacheGetter("description",this.meta?.description??this.$.resolvedConfig[this.kind].description(this))}get references(){return Object.values(this.referencesById)}precedence=j1(this.kind);precompilation;assert=(U,X)=>this(U,X,(q)=>q.throw());traverse(U,X){return this(U,X,null)}get in(){return this.cacheGetter("in",this.rawIn.isRoot()?this.$.finalize(this.rawIn):this.rawIn)}get rawIn(){return this.cacheGetter("rawIn",this.getIo("in"))}get out(){return this.cacheGetter("out",this.rawOut.isRoot()?this.$.finalize(this.rawOut):this.rawOut)}get rawOut(){return this.cacheGetter("rawOut",this.getIo("out"))}getIo(U){if(!this.includesTransform)return this;let X={};for(let[q,Z]of this.innerEntries){let Q=this.impl.keys[q];if(Q.reduceIo)Q.reduceIo(U,X,Z);else if(Q.child){let G=Z;X[q]=h(G)?G.map((Y)=>U==="in"?Y.rawIn:Y.rawOut):U==="in"?G.rawIn:G.rawOut}else X[q]=Z}return this.$.node(this.kind,X)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals(U){let X=x(U)?U:this.$.parseDefinition(U);return this.innerHash===X.innerHash}ifEquals(U){return this.equals(U)?this:void 0}hasKind(U){return this.kind===U}assertHasKind(U){if(this.kind!==U)Y1(`${this.kind} node was not of asserted kind ${U}`);return this}hasKindIn(...U){return U.includes(this.kind)}assertHasKindIn(...U){if(!F0(U,this.kind))Y1(`${this.kind} node was not one of asserted kinds ${U}`);return this}isBasis(){return F0(qq,this.kind)}isConstraint(){return F0(O6,this.kind)}isStructural(){return F0(C1,this.kind)}isRefinement(){return F0(o4,this.kind)}isRoot(){return F0(S1,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit(U){return this.hasKind("unit")&&this.allows(U)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select(U){let X=V2.normalize(U);return this._select(X)}_select(U){let X=V2.applyBoundary[U.boundary??"references"](this);if(U.kind)X=X.filter((q)=>q.kind===U.kind);if(U.where)X=X.filter(U.where);return V2.applyMethod[U.method??"filter"](X,this,U)}transform(U,X){return this._transform(U,this._createTransformContext(X))}_createTransformContext(U){return{root:this,selected:void 0,seen:{},path:[],parseOptions:{prereduced:U?.prereduced??!1},undeclaredKeyHandling:void 0,...U}}_transform(U,X){let q=X.bindScope??this.$;if(X.seen[this.id])return this.$.lazilyResolve(X.seen[this.id]);if(X.shouldTransform?.(this,X)===!1)return this;let Z;if(X.seen[this.id]=()=>Z,this.hasKind("structure")&&this.undeclared!==X.undeclaredKeyHandling)X={...X,undeclaredKeyHandling:this.undeclared};let Q=S(this.inner,(W,$)=>{if(!this.impl.keys[W].child)return[W,$];let _=$;if(!h(_)){let A=_._transform(U,X);return A?[W,A]:[]}if(_.length===0)return[W,$];let L=_.flatMap((A)=>{return A._transform(U,X)??[]});return L.length?[W,L]:[]});delete X.seen[this.id];let G=Object.assign(Q,{meta:this.meta}),Y=X.selected&&!X.selected.includes(this)?G:U(this.kind,G,X);if(Y===null)return null;if(x(Y))return Z=Y;let J=Object.keys(Y);if((J.length===0||J.length===1&&J[0]==="meta")&&!S0(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in Y))return X.undeclaredKeyHandling?{...Y,value:O.intrinsic.unknown}:null;if(this.kind==="morph")Y.in??=O.intrinsic.unknown;return Z=q.node(this.kind,Y,X.parseOptions)}configureReferences(U,X="references"){let q=V2.normalize(X),Z=typeof U==="string"?(J,H)=>({...H,meta:{...H.meta,description:U}}):typeof U==="function"?(J,H)=>({...H,meta:U(H.meta)}):(J,H)=>({...H,meta:{...H.meta,...U}});if(q.boundary==="self")return this.$.node(this.kind,Z(this.kind,{...this.inner,meta:this.meta}));let Q=this._select(q),G=Q&&l0(Q),Y=q.boundary==="child"?(J,H)=>H.root.children.includes(J):q.boundary==="shallow"?(J)=>J.kind!=="structure":()=>!0;return this.$.finalize(this.transform(Z,{shouldTransform:Y,selected:G}))}}var V2={applyBoundary:{self:(U)=>[U],child:(U)=>[...U.children],shallow:(U)=>[...U.shallowReferences],references:(U)=>[...U.references]},applyMethod:{filter:(U)=>U,assertFilter:(U,X,q)=>{if(U.length===0)Y1(Hq(X,q));return U},find:(U)=>U[0],assertFind:(U,X,q)=>{if(U.length===0)Y1(Hq(X,q));return U[0]}},normalize:(U)=>typeof U==="function"?{boundary:"references",method:"filter",where:U}:typeof U==="string"?n(U,V2.applyBoundary)?{method:"filter",boundary:U}:{boundary:"references",method:"filter",kind:U}:{boundary:"references",method:"filter",...U}},Hq=(U,X)=>`${U} had no references matching ${E(X)}.`,uG=(U)=>v0(U,{stringifyNonKey:(X)=>X.expression}),mG=/"(\$ark\.[^"]+)"/g,pG=(U)=>JSON.stringify(U).replace(mG,"$1"),P0=(U,X)=>({path:U,node:X,propString:uG(U)}),Wq=(U,X)=>U.propString===X.propString&&U.node.equals(X.node),a4=(U,X)=>C0(U,X,{isEqual:Wq}),lG=(U,X)=>C0(U,X,{isEqual:(q,Z)=>q.equals(Z)});class T extends Array{static init(U,X,q,Z){return new T({kind:U,l:X,r:q,path:Z?.path??[],optional:Z?.optional??!1})}add(U,X,q,Z){return this.push({kind:U,l:X,r:q,path:Z?.path??[],optional:Z?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:U,l:X,r:q}=this[0],Z=v0(U);return e4(`Intersection${Z&&` at ${Z}`} of ${_q(X,q)}`)}return`The following intersections result in unsatisfiable types:
159
+ • ${this.map(({path:U,l:X,r:q})=>`${U}: ${_q(X,q)}`).join(`
160
+ • `)}`}throw(){return F(this.describeReasons())}invert(){let U=this.map((X)=>({...X,l:X.r,r:X.l}));if(!(U instanceof T))return new T(...U);return U}withPrefixKey(U,X){return this.map((q)=>({...q,path:[U,...q.path],optional:q.optional||X==="optional"}))}toNeverIfDisjoint(){return O.intrinsic.never}}var _q=(U,X)=>`${t4(U)} and ${t4(X)}`,t4=(U)=>x(U)?U.expression:h(U)?U.map(t4).join(" | ")||"never":String(U),e4=(U)=>`${U} results in an unsatisfiable type`;var b1={},$0=(U,X,q)=>u(U,X,{$:q,invert:!1,pipe:!1}),D2=(U,X,q)=>u(U,X,{$:q,invert:!1,pipe:!0}),u=(U,X,q)=>{let Z=q.pipe?"|>":"&",Q=`${U.hash}${Z}${X.hash}`;if(b1[Q]!==void 0)return b1[Q];if(!q.pipe){let J=`${X.hash}${Z}${U.hash}`;if(b1[J]!==void 0){let H=b1[J],W=H instanceof T?H.invert():H;return b1[Q]=W,W}}let G=!q.pipe||!U.includesTransform&&!X.includesTransform;if(G&&U.equals(X))return U;let Y=G?U9(U,X,q):U.hasKindIn(...S1)?dG(U,X,q):U9(U,X,q);if(x(Y)){if(U.equals(Y))Y=U;else if(X.equals(Y))Y=X}return b1[Q]=Y,Y},U9=(U,X,q)=>{let Z=U.precedence<X.precedence?U.kind:X.kind,Q=U.impl.intersections[X.kind]??X.impl.intersections[U.kind];if(Q===void 0)return null;else if(Z===U.kind)return Q(U,X,q);else{let G=Q(X,U,{...q,invert:!q.invert});if(G instanceof T)G=G.invert();return G}},dG=(U,X,q)=>U.includesTransform||X.includesTransform?q.invert?$q(X,U,q):$q(U,X,q):U9(U,X,q),$q=(U,X,q)=>U.distribute((Z)=>cG(Z,X,q),(Z)=>{let Q=Z.filter(x);if(Q.length===0)return T.init("union",U.branches,X.branches);if(Q.length<U.branches.length||!U.branches.every((J,H)=>J.rawIn.equals(Q[H].rawIn)))return q.$.parseSchema(Q);let G;if(Q.length===1){let J=Q[0];if(!G)return J;return q.$.node("morph",{...J.inner,in:J.rawIn.configure(G,"self")})}let Y={branches:Q};if(G)Y.meta=G;return q.$.parseSchema(Y)}),cG=(U,X,q)=>{if(U.hasKind("morph")){let Q=[...U.morphs];if(U.lastMorphIfNode){let G=u(U.lastMorphIfNode,X,q);if(G instanceof T)return G;Q[Q.length-1]=G}else Q.push(X);return q.$.node("morph",{morphs:Q,in:U.inner.in})}if(X.hasKind("morph")){let Q=u(U,X.rawIn,q);if(Q instanceof T)return Q;return q.$.node("morph",{morphs:[X],in:Q})}return q.$.node("morph",{morphs:[X],in:U})};class O0 extends R2{constructor(U,X){super(U,X);Object.defineProperty(this,Z0,{value:"constraint",enumerable:!1})}impliedSiblings;intersect(U){return $0(this,U,this.$)}}class h0 extends O0{traverseApply=(U,X)=>{if(!this.traverseAllows(U,X))X.errorFromNodeContext(this.errorContext)};compile(U){if(U.traversalKind==="Allows")U.return(this.compiledCondition);else U.if(this.compiledNegation,()=>U.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return s0(this.errorContext)}}var q0=(U)=>(X,q)=>{if(h(X)){if(X.length===0)return;let Q=X.map((G)=>q.$.node(U,G));if(U==="predicate")return Q;return Q.sort((G,Y)=>G.hash<Y.hash?-1:1)}let Z=q.$.node(U,X);return Z.hasOpenIntersection()?[Z]:Z},f1=(U)=>{let X=U.r.shift();if(!X){let Z=U.l.length===0&&U.kind==="structure"?O.intrinsic.unknown.internal:U.ctx.$.node(U.kind,Object.assign(U.baseInner,iG(U.l)),{prereduced:!0});for(let Q of U.roots){if(Z instanceof T)return Z;Z=u(Q,Z,U.ctx)}return Z}let q=!1;for(let Z=0;Z<U.l.length;Z++){let Q=u(U.l[Z],X,U.ctx);if(Q===null)continue;if(Q instanceof T)return Q;if(Q.isRoot())return U.roots.push(Q),U.l.splice(Z),f1(U);if(!q)U.l[Z]=Q,q=!0;else if(!U.l.includes(Q))return y(`Unexpectedly encountered multiple distinct intersection results for refinement ${X}`)}if(!q)U.l.push(X);if(U.kind==="intersection"){if(X.impliedSiblings)for(let Z of X.impliedSiblings)C0(U.r,Z)}return f1(U)},g1=(U)=>{return Object.entries(U).flatMap(([q,Z])=>(q in B6)?Z:[]).sort((q,Z)=>q.precedence<Z.precedence?-1:q.precedence>Z.precedence?1:q.kind==="predicate"&&Z.kind==="predicate"?0:q.hash<Z.hash?-1:1)},iG=(U)=>{let X={};for(let q of U)if(q.hasOpenIntersection())X[q.kind]=g(X[q.kind],q);else{if(X[q.kind])return y(`Unexpected intersection of closed refinements of kind ${q.kind}`);X[q.kind]=q}return X},Lq=(...U)=>F(zq(...U)),zq=(U,X,q)=>{let Z=q.hasKind("morph")?"a morph":q.isUnknown()?"unknown":q.exclude(X).defaultShortDescription;return`${xX(U)} operand must be ${X.description} (was ${Z})`};var Fq=(U,X,q)=>new r0(U,X,q,q,null);class V6 extends H0{}class r0 extends H0{[Z0]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor(U,X,q,Z,Q){super((...G)=>{let Y=S(this.names,(J,H)=>{let W=this.arg$.parse(G[J]);if(!W.extends(this.constraints[J]))F(sG(H,this.constraints[J].expression,W.expression));return[H,W]});if(this.defIsLazy()){let J=this.bodyDef(Y);return this.$.parse(J)}return this.$.parse(X,{args:Y})});this.paramDefs=U,this.bodyDef=X,this.$=q,this.arg$=Z,this.hkt=Q,this.description=Q?new Q().description??`a generic type for ${Q.constructor.name}`:"a generic type",this.baseInstantiation=this(...this.constraints)}defIsLazy(){return this.bodyDef instanceof V6}cacheGetter(U,X){return Object.defineProperty(this,U,{value:X}),X}get json(){return this.cacheGetter("json",{params:this.params.map((U)=>U[1].isUnknown()?U[0]:[U[0],U[1].json]),body:aX(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map((U)=>typeof U==="string"?[U,O.intrinsic.unknown]:[U[0],this.$.parse(U[1])]))}get names(){return this.cacheGetter("names",this.params.map((U)=>U[0]))}get constraints(){return this.cacheGetter("constraints",this.params.map((U)=>U[1]))}get internal(){return this}get referencesById(){return this.baseInstantiation.internal.referencesById}get references(){return this.baseInstantiation.internal.references}}var sG=(U,X,q)=>`${U} must be assignable to ${X} (was ${q})`;var oG=j({kind:"predicate",hasAssociatedError:!0,collapsibleKey:"predicate",keys:{predicate:{}},normalize:(U)=>typeof U==="function"?{predicate:U}:U,defaults:{description:(U)=>`valid according to ${U.predicate.name||"an anonymous predicate"}`},intersectionIsOpen:!0,intersections:{predicate:()=>null}});class Aq extends O0{serializedPredicate=d(this.predicate);compiledCondition=`${this.serializedPredicate}(data, ctx)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=null;expression=this.serializedPredicate;traverseAllows=this.predicate;errorContext={code:"predicate",description:this.description,meta:this.meta};compiledErrorContext=s0(this.errorContext);traverseApply=(U,X)=>{let q=X.currentErrorCount;if(!this.predicate(U,X.external)&&X.currentErrorCount===q)X.errorFromNodeContext(this.errorContext)};compile(U){if(U.traversalKind==="Allows"){U.return(this.compiledCondition);return}U.initializeErrorCount(),U.if(`${this.compiledNegation} && ctx.currentErrorCount === errorCount`,()=>U.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}reduceJsonSchema(U,X){return X.fallback.predicate({code:"predicate",base:U,predicate:this.predicate})}}var X9={implementation:oG,Node:Aq};var rG=j({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:(U)=>Number.isInteger(U)?U:F(nG(U))}},normalize:(U)=>typeof U==="number"?{rule:U}:U,hasAssociatedError:!0,defaults:{description:(U)=>U.rule===1?"an integer":U.rule===2?"even":`a multiple of ${U.rule}`},intersections:{divisor:(U,X,q)=>q.$.node("divisor",{rule:Math.abs(U.rule*X.rule/aG(U.rule,X.rule))})},obviatesBasisDescription:!0});class Oq extends h0{traverseAllows=(U)=>U%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=O.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema(U){if(U.type="integer",this.rule===1)return U;return U.multipleOf=this.rule,U}}var q9={implementation:rG,Node:Oq};var nG=(U)=>`divisor must be an integer (was ${U})`,aG=(U,X)=>{let q,Z=U,Q=X;while(Q!==0)q=Q,Q=Z%Q,Z=q;return Z};class z0 extends h0{boundOperandKind=X5[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=q5(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${tG[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?Z5(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan(U){return(this.limitKind==="upper"?this.numericLimit<U.numericLimit:this.numericLimit>U.numericLimit)||this.numericLimit===U.numericLimit&&this.exclusive===!0&&!U.exclusive}overlapsRange(U){if(this.isStricterThan(U))return!1;if(this.numericLimit===U.numericLimit&&(this.exclusive||U.exclusive))return!1;return!0}overlapIsUnit(U){return this.numericLimit===U.numericLimit&&!this.exclusive&&!U.exclusive}}var tG={"<":">=","<=":">",">":"<=",">=":"<"},eG={min:"max",minLength:"maxLength",after:"before"},R6={parse:(U)=>U||void 0},D6=(U)=>(X)=>{if(typeof X==="number")return{rule:X};let{exclusive:q,...Z}=X;return q?{...Z,rule:U==="minLength"?Z.rule+1:Z.rule-1}:Z},M6=(U)=>(X)=>{if(typeof X==="number"||typeof X==="string"||X instanceof Date)return{rule:X};let{exclusive:q,...Z}=X;if(!q)return Z;let Q=typeof Z.rule==="number"?Z.rule:typeof Z.rule==="string"?new Date(Z.rule).valueOf():Z.rule.valueOf();return q?{...Z,rule:U==="after"?Q+1:Q-1}:Z},w6=(U)=>typeof U==="string"||typeof U==="number"?new Date(U):U,U5=(U,X)=>`${U} bound must be a positive integer (was ${X})`,y1=(U)=>(X)=>{if(!Number.isInteger(X)||X<0)F(U5(U,X));return X},X5={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},q5=(U,X)=>`${n(U,eG)?">":"<"}${X?"":"="}`,Z5=(U)=>typeof U==="string"?U:new Date(U).toLocaleString(),Bq=(U)=>`Bounded expression ${U} must be exactly one of number, string, Array, or Date`;var Q5=j({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:w6,serialize:(U)=>U.toISOString()}},normalize:M6("after"),defaults:{description:(U)=>`${U.collapsibleLimitString} or later`,actual:$1},intersections:{after:(U,X)=>U.isStricterThan(X)?U:X}});class Tq extends z0{impliedBasis=O.intrinsic.Date.internal;collapsibleLimitString=$1(this.rule);traverseAllows=(U)=>U>=this.rule;reduceJsonSchema(U,X){return X.fallback.date({code:"date",base:U,after:this.rule})}}var Z9={implementation:Q5,Node:Tq};var G5=j({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:w6,serialize:(U)=>U.toISOString()}},normalize:M6("before"),defaults:{description:(U)=>`${U.collapsibleLimitString} or earlier`,actual:$1},intersections:{before:(U,X)=>U.isStricterThan(X)?U:X,after:(U,X,q)=>U.overlapsRange(X)?U.overlapIsUnit(X)?q.$.node("unit",{unit:U.rule}):null:T.init("range",U,X)}});class Vq extends z0{collapsibleLimitString=$1(this.rule);traverseAllows=(U)=>U<=this.rule;impliedBasis=O.intrinsic.Date.internal;reduceJsonSchema(U,X){return X.fallback.date({code:"date",base:U,before:this.rule})}}var Q9={implementation:G5,Node:Vq};var Y5=j({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:y1("exactLength")}},normalize:(U)=>typeof U==="number"?{rule:U}:U,hasAssociatedError:!0,defaults:{description:(U)=>`exactly length ${U.rule}`,actual:(U)=>`${U.length}`},intersections:{exactLength:(U,X,q)=>T.init("unit",q.$.node("unit",{unit:U.rule}),q.$.node("unit",{unit:X.rule}),{path:["length"]}),minLength:(U,X)=>U.rule>=X.rule?U:T.init("range",U,X),maxLength:(U,X)=>U.rule<=X.rule?U:T.init("range",U,X)}});class Rq extends h0{traverseAllows=(U)=>U.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=O.intrinsic.lengthBoundable.internal;expression=`== ${this.rule}`;reduceJsonSchema(U){switch(U.type){case"string":return U.minLength=this.rule,U.maxLength=this.rule,U;case"array":return U.minItems=this.rule,U.maxItems=this.rule,U;default:return p.throwInternalOperandError("exactLength",U)}}}var G9={implementation:Y5,Node:Rq};var J5=j({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:R6},normalize:(U)=>typeof U==="number"?{rule:U}:U,defaults:{description:(U)=>{if(U.rule===0)return U.exclusive?"negative":"non-positive";return`${U.exclusive?"less than":"at most"} ${U.rule}`}},intersections:{max:(U,X)=>U.isStricterThan(X)?U:X,min:(U,X,q)=>U.overlapsRange(X)?U.overlapIsUnit(X)?q.$.node("unit",{unit:U.rule}):null:T.init("range",U,X)},obviatesBasisDescription:!0});class Dq extends z0{impliedBasis=O.intrinsic.number.internal;traverseAllows=this.exclusive?(U)=>U<this.rule:(U)=>U<=this.rule;reduceJsonSchema(U){if(this.exclusive)U.exclusiveMaximum=this.rule;else U.maximum=this.rule;return U}}var Y9={implementation:J5,Node:Dq};var H5=j({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:y1("maxLength")}},reduce:(U,X)=>U.rule===0?X.node("exactLength",U):void 0,normalize:D6("maxLength"),defaults:{description:(U)=>`at most length ${U.rule}`,actual:(U)=>`${U.length}`},intersections:{maxLength:(U,X)=>U.isStricterThan(X)?U:X,minLength:(U,X,q)=>U.overlapsRange(X)?U.overlapIsUnit(X)?q.$.node("exactLength",{rule:U.rule}):null:T.init("range",U,X)}});class Mq extends z0{impliedBasis=O.intrinsic.lengthBoundable.internal;traverseAllows=(U)=>U.length<=this.rule;reduceJsonSchema(U){switch(U.type){case"string":return U.maxLength=this.rule,U;case"array":return U.maxItems=this.rule,U;default:return p.throwInternalOperandError("maxLength",U)}}}var J9={implementation:H5,Node:Mq};var W5=j({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:R6},normalize:(U)=>typeof U==="number"?{rule:U}:U,defaults:{description:(U)=>{if(U.rule===0)return U.exclusive?"positive":"non-negative";return`${U.exclusive?"more than":"at least"} ${U.rule}`}},intersections:{min:(U,X)=>U.isStricterThan(X)?U:X},obviatesBasisDescription:!0});class wq extends z0{impliedBasis=O.intrinsic.number.internal;traverseAllows=this.exclusive?(U)=>U>this.rule:(U)=>U>=this.rule;reduceJsonSchema(U){if(this.exclusive)U.exclusiveMinimum=this.rule;else U.minimum=this.rule;return U}}var H9={implementation:W5,Node:wq};var _5=j({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:y1("minLength")}},reduce:(U)=>U.rule===0?O.intrinsic.unknown:void 0,normalize:D6("minLength"),defaults:{description:(U)=>U.rule===1?"non-empty":`at least length ${U.rule}`,actual:(U)=>U.length===0?"":`${U.length}`},intersections:{minLength:(U,X)=>U.isStricterThan(X)?U:X}});class Pq extends z0{impliedBasis=O.intrinsic.lengthBoundable.internal;traverseAllows=(U)=>U.length>=this.rule;reduceJsonSchema(U){switch(U.type){case"string":return U.minLength=this.rule,U;case"array":return U.minItems=this.rule,U;default:return p.throwInternalOperandError("minLength",U)}}}var W9={implementation:_5,Node:Pq};var Iq={min:H9.implementation,max:Y9.implementation,minLength:W9.implementation,maxLength:J9.implementation,exactLength:G9.implementation,after:Z9.implementation,before:Q9.implementation},Kq={min:H9.Node,max:Y9.Node,minLength:W9.Node,maxLength:J9.Node,exactLength:G9.Node,after:Z9.Node,before:Q9.Node};var $5=j({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:(U)=>typeof U==="string"?{rule:U}:U instanceof RegExp?U.flags?{rule:U.source,flags:U.flags}:{rule:U.source}:U,obviatesBasisDescription:!0,obviatesBasisExpression:!0,hasAssociatedError:!0,intersectionIsOpen:!0,defaults:{description:(U)=>`matched by ${U.rule}`},intersections:{pattern:()=>null}});class Nq extends h0{instance=new RegExp(this.rule,this.flags);expression=`${this.instance}`;traverseAllows=this.instance.test.bind(this.instance);compiledCondition=`${this.expression}.test(data)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=O.intrinsic.string.internal;reduceJsonSchema(U,X){if(U.pattern)return X.fallback.patternIntersection({code:"patternIntersection",base:U,pattern:this.rule});return U.pattern=this.rule,U}}var _9={implementation:$5,Node:Nq};var M2=(U,X)=>{let q=L5(U);if(X&&!X.includes(q))return F(`Root of kind ${q} should be one of ${X}`);return q},L5=(U)=>{if(M(U,"root"))return U.kind;if(typeof U==="string")return U[0]==="$"?"alias":(U in Y0)?"domain":"proto";if(typeof U==="function")return"proto";if(typeof U!=="object"||U===null)return F(Cq(U));if("morphs"in U)return"morph";if("branches"in U||h(U))return"union";if("unit"in U)return"unit";if("reference"in U)return"alias";let X=Object.keys(U);if(X.length===0||X.some((q)=>(q in B6)))return"intersection";if("proto"in U)return"proto";if("domain"in U)return"domain";return F(Cq(U))},Cq=(U)=>`${E(U)} is not a valid type schema`,Sq={},z5=(U)=>h(U)?U.map((X)=>X.collapsibleJson):U.collapsibleJson,Q0={};O.nodesByRegisteredId=Q0;var $9=(U)=>{return Sq[U]??=0,`${U}${++Sq[U]}`},L9=(U)=>{let X=k1[U.kind],q=X.applyConfig?.(U.def,U.$.resolvedConfig)??U.def,Z={},{meta:Q,...G}=q,Y=Q===void 0?{}:typeof Q==="string"?{description:Q}:Q,J=y4(G).sort(([W],[$])=>E1(W)?E1($)?j1(W)-j1($):1:E1($)?-1:W<$?-1:1).filter(([W,$])=>{if(W.startsWith("meta.")){let _=W.slice(5);return Y[_]=$,!1}return!0});for(let W of J){let $=W[0],_=X.keys[$];if(!_)return F(`Key ${$} is not valid on ${U.kind} schema`);let L=_.parse?_.parse(W[1],U):W[1];if(L!==J0&&(L!==void 0||_.preserveUndefined))Z[$]=L}if(X.reduce&&!U.prereduced){let W=X.reduce(Z,U.$);if(W){if(W instanceof T)return W.throw();return F5(W,Y)}}return z9({id:U.id,kind:U.kind,inner:Z,meta:Y,$:U.$})},z9=({id:U,kind:X,inner:q,meta:Z,$:Q,ignoreCache:G})=>{let Y=k1[X],J=y4(q),H=[],W={};for(let[D,P]of J){let K=Y.keys[D],C=K.serialize??(K.child?z5:A0);if(W[D]=C(P),K.child===!0){let N=P;if(h(N))H.push(...N);else H.push(N)}else if(typeof K.child==="function")H.push(...K.child(P))}if(Y.finalizeInnerJson)W=Y.finalizeInnerJson(W);let $={...W},_={};if(!S0(Z))_=S(Z,(D,P)=>[D,D==="examples"?P:A0(P)]),$.meta=P6(_,"description",!0);W=P6(W,Y.collapsibleKey,!1);let L=JSON.stringify({kind:X,...W});$=P6($,Y.collapsibleKey,!1);let A=P6($,Y.collapsibleKey,!0),V=JSON.stringify({kind:X,...$});if(Q.nodesByHash[V]&&!G)return Q.nodesByHash[V];let z={id:U,kind:X,impl:Y,inner:q,innerEntries:J,innerJson:W,innerHash:L,meta:Z,metaJson:_,json:$,hash:V,collapsibleJson:A,children:H};if(X!=="intersection"){for(let D in q)if(D!=="in"&&D!=="out")z[D]=q[D]}let B=new jq[X](z,Q);return Q.nodesByHash[V]=B},Eq=(U,X)=>{if(U.id===X)return U;if(x(Q0[X]))y(`Unexpected attempt to overwrite node id ${X}`);return z9({id:X,kind:U.kind,inner:U.inner,meta:U.meta,$:U.$,ignoreCache:!0})},F5=(U,X,q)=>{if(q&&x(Q0[q]))y(`Unexpected attempt to overwrite node id ${q}`);return z9({id:q??$9(X.alias??U.kind),kind:U.kind,inner:U.inner,meta:X,$:U.$})},P6=(U,X,q)=>{let Z=Object.keys(U);if(Z.length===1&&Z[0]===X){let Q=U[X];if(q)return Q;if(G0(Q,"object")&&(Object.keys(Q).length===1||Array.isArray(Q)))return Q}return U};var w2=(U,X,q)=>{if(U.key!==X.key)return null;let Z=U.key,Q=u(U.value,X.value,q),G=U.required||X.required?"required":"optional";if(Q instanceof T)if(G==="optional")Q=O.intrinsic.never.internal;else return Q.withPrefixKey(U.key,U.required&&X.required?"required":"optional");if(G==="required")return q.$.node("required",{key:Z,value:Q});let Y=U.hasDefault()?X.hasDefault()?U.default===X.default?U.default:F(F9(U.default,X.default)):U.default:X.hasDefault()?X.default:J0;return q.$.node("optional",{key:Z,value:Q,default:Y})};class P2 extends O0{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=O.intrinsic.object.internal;serializedKey=M0(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=g(this.value.flatRefs.map((U)=>P0([this.key,...U.path],U.node)),P0([this.key],this.value));_transform(U,X){X.path.push(this.key);let q=super._transform(U,X);return X.path.pop(),q}hasDefault(){return"default"in this.inner}traverseAllows=(U,X)=>{if(this.key in U)return _0(this.key,()=>this.value.traverseAllows(U[this.key],X),X);return this.optional};traverseApply=(U,X)=>{if(this.key in U)_0(this.key,()=>this.value.traverseApply(U[this.key],X),X);else if(this.hasKind("required"))X.errorFromNodeContext(this.errorContext)};compile(U){if(U.if(`${this.serializedKey} in data`,()=>U.traverseKey(this.serializedKey,`data${U.prop(this.key)}`,this.value)),this.hasKind("required"))U.else(()=>U.traversalKind==="Apply"?U.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`):U.return(!1));if(U.traversalKind==="Allows")U.return(!0)}}var F9=(U,X)=>`Invalid intersection of default values ${E(U)} & ${E(X)}`;var A5=j({kind:"optional",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(U,X)=>X.$.parseSchema(U)},default:{preserveUndefined:!0}},normalize:(U)=>U,reduce:(U,X)=>{if(X.resolvedConfig.exactOptionalPropertyTypes===!1){if(!U.value.allows(void 0))return X.node("optional",{...U,value:U.value.or(I.undefined)},{prereduced:!0})}},defaults:{description:(U)=>`${U.compiledKey}?: ${U.value.description}`},intersections:{optional:w2}});class bq extends P2{constructor(...U){super(...U);if("default"in this.inner)K2(this.value,this.inner.default,this.key)}get rawIn(){let U=super.rawIn;if(!this.hasDefault())return U;return this.$.node("optional",_6(U.inner,{default:!0}),{prereduced:!0})}get outProp(){if(!this.hasDefault())return this;let{default:U,...X}=this.inner;return this.cacheGetter("outProp",this.$.node("required",X,{prereduced:!0}))}expression=this.hasDefault()?`${this.compiledKey}: ${this.value.expression} = ${E(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=B5(this);defaultValueMorphRef=this.defaultValueMorph&&d(this.defaultValueMorph)}var I2={implementation:A5,Node:bq},O5={},B5=(U)=>{if(!U.hasDefault())return;let X=`{${U.compiledKey}: ${U.value.id} = ${A0(U.default)}}`;return O5[X]??=A9(U.key,U.value,U.default)},A9=(U,X,q)=>{if(typeof q==="function")return X.includesTransform?(Q,G)=>{return _0(U,()=>X(Q[U]=q(),G),G),Q}:(Q)=>{return Q[U]=q(),Q};let Z=X.includesTransform?X.assert(q):q;return G0(Z,"object")?(Q,G)=>{return _0(U,()=>X(Q[U]=q,G),G),Q}:(Q)=>{return Q[U]=Z,Q}},K2=(U,X,q)=>{let Z=d0(X);if(G0(X,"object")&&!Z)F(T5(q));let Q=U.in(Z?X():X);if(Q instanceof W0){if(q===null)F(`Default ${Q.summary}`);let G=Q.transform((Y)=>Y.transform((J)=>({...J,prefixPath:[q]})));F(`Default for ${G.summary}`)}return X},T5=(U)=>{return`Non-primitive default ${U===null?"":typeof U==="number"?`for value at [${U}] `:`for ${M0(U)} `}must be specified as a function like () => ({my: 'object'})`};class B0 extends R2{constructor(U,X){super(U,X);Object.defineProperty(this,Z0,{value:"root",enumerable:!1})}get rawIn(){return super.rawIn}get rawOut(){return super.rawOut}get internal(){return this}get "~standard"(){return{vendor:"arktype",version:1,validate:(U)=>{let X=this(U);if(X instanceof W0)return X;return{value:X}},jsonSchema:{input:(U)=>this.rawIn.toJsonSchema({target:fq(U.target),...U.libraryOptions}),output:(U)=>this.rawOut.toJsonSchema({target:fq(U.target),...U.libraryOptions})}}}as(){return this}brand(U){if(U==="")return F(V5);return this}readonly(){return this}branches=this.hasKind("union")?this.inner.branches:[this];distribute(U,X){let q=this.branches.map(U);return X?.(q)??q}get shortDescription(){return this.meta.description??this.defaultShortDescription}toJsonSchema(U={}){let X=r4(this.$.resolvedConfig.toJsonSchema,U);X.useRefs||=this.isCyclic;let q=typeof X.dialect==="string"?{$schema:X.dialect}:{};if(Object.assign(q,this.toJsonSchemaRecurse(X)),X.useRefs){let Z=S(this.references,(Q,G)=>G.isRoot()&&!G.alwaysExpandJsonSchema?[G.id,G.toResolvedJsonSchema(X)]:[]);if(X.target==="draft-07")Object.assign(q,{definitions:Z});else q.$defs=Z}return q}toJsonSchemaRecurse(U){if(U.useRefs&&!this.alwaysExpandJsonSchema)return{$ref:`#/${U.target==="draft-07"?"definitions":"$defs"}/${this.id}`};return this.toResolvedJsonSchema(U)}get alwaysExpandJsonSchema(){return this.isBasis()||this.kind==="alias"||this.hasKind("union")&&this.isBoolean}toResolvedJsonSchema(U){let X=this.innerToJsonSchema(U);return Object.assign(X,this.metaJson)}intersect(U){let X=this.$.parseDefinition(U),q=this.rawIntersect(X);if(q instanceof T)return q;return this.$.finalize(q)}rawIntersect(U){return $0(this,U,this.$)}toNeverIfDisjoint(){return this}and(U){let X=this.intersect(U);return X instanceof T?X.throw():X}rawAnd(U){let X=this.rawIntersect(U);return X instanceof T?X.throw():X}or(U){let X=this.$.parseDefinition(U);return this.$.finalize(this.rawOr(X))}rawOr(U){let X=[...this.branches,...U.branches];return this.$.node("union",X)}map(U){return this.$.schema(this.applyStructuralOperation("map",[U]))}pick(...U){return this.$.schema(this.applyStructuralOperation("pick",U))}omit(...U){return this.$.schema(this.applyStructuralOperation("omit",U))}required(){return this.$.schema(this.applyStructuralOperation("required",[]))}partial(){return this.$.schema(this.applyStructuralOperation("partial",[]))}_keyof;keyof(){if(this._keyof)return this._keyof;let U=this.applyStructuralOperation("keyof",[]).reduce((X,q)=>X.intersect(q).toNeverIfDisjoint(),O.intrinsic.unknown.internal);if(U.branches.length===0)F(e4(`keyof ${this.expression}`));return this._keyof=this.$.finalize(U)}get props(){if(this.branches.length!==1)return F(D5(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge(U){let X=this.$.parseDefinition(U);return this.$.schema(X.distribute((q)=>this.applyStructuralOperation("merge",[gq(q)??F(yq("merge",q.expression))])))}applyStructuralOperation(U,X){return this.distribute((q)=>{if(q.equals(O.intrinsic.object)&&U!=="merge")return q;let Z=gq(q);if(!Z)F(yq(U,q.expression));if(U==="keyof")return Z.keyof();if(U==="get")return Z.get(...X);if(U==="props")return Z.props;let Q=U==="required"?"require":U==="partial"?"optionalize":U;return this.$.node("intersection",{domain:"object",structure:Z[Q](...X)})})}get(...U){if(U[0]===void 0)return this;return this.$.schema(this.applyStructuralOperation("get",U))}extract(U){let X=this.$.parseDefinition(U);return this.$.schema(this.branches.filter((q)=>q.extends(X)))}exclude(U){let X=this.$.parseDefinition(U);return this.$.schema(this.branches.filter((q)=>!q.extends(X)))}array(){return this.$.schema(this.isUnknown()?{proto:Array}:{proto:Array,sequence:this},{prereduced:!0})}overlaps(U){return!(this.intersect(U)instanceof T)}extends(U){if(this.isNever())return!0;let X=this.intersect(U);return!(X instanceof T)&&this.equals(X)}ifExtends(U){return this.extends(U)?this:void 0}subsumes(U){return this.$.parseDefinition(U).extends(this)}configure(U,X="shallow"){return this.configureReferences(U,X)}describe(U,X="shallow"){return this.configure({description:U},X)}optional(){return[this,"?"]}default(U){return K2(this,U,null),[this,"=",U]}from(U){return this.assert(U)}_pipe(...U){let X=U.reduce((q,Z)=>q.rawPipeOnce(Z),this);return this.$.finalize(X)}tryPipe(...U){let X=U.reduce((q,Z)=>q.rawPipeOnce(M(Z,"root")?Z:(Q,G)=>{try{return Z(Q,G)}catch(Y){return G.error({code:"predicate",predicate:Z,actual:`aborted due to error:
161
161
  ${Y}
162
- `})}}),this);return this.$.finalize(X)}pipe=Object.assign(this._pipe.bind(this),{try:this.tryPipe.bind(this)});to(U){return this.$.finalize(this.toNode(this.$.parseDefinition(U)))}toNode(U){let X=D2(this,U,this.$);if(X instanceof T)return X.throw();return X}rawPipeOnce(U){if(M(U,"root"))return this.toNode(U);return this.distribute((X)=>X.hasKind("morph")?this.$.node("morph",{in:X.inner.in,morphs:[...X.morphs,U]}):this.$.node("morph",{in:X,morphs:[U]}),this.$.parseSchema)}narrow(U){return this.constrainOut("predicate",U)}constrain(U,X){return this._constrain("root",U,X)}constrainIn(U,X){return this._constrain("in",U,X)}constrainOut(U,X){return this._constrain("out",U,X)}_constrain(U,X,q){let Z=this.$.node(X,q);if(Z.isRoot())return Z.isUnknown()?this:y(`Unexpected constraint node ${Z}`);let Q=U==="root"?this:U==="in"?this.rawIn:this.rawOut;if(Q.hasKind("morph")||Z.impliedBasis&&!Q.extends(Z.impliedBasis))return $q(X,Z.impliedBasis,this);let G=this.$.node("intersection",{[Z.kind]:Z}),Y=U==="out"?D2(this,G,this.$):$0(this,G,this.$);if(Y instanceof T)Y.throw();return this.$.finalize(Y)}onUndeclaredKey(U){let X=typeof U==="string"?U:U.rule,q=typeof U==="string"?!1:U.deep;return this.$.finalize(this.transform((Z,Q)=>Z==="structure"?X==="ignore"?_6(Q,{undeclared:1}):{...Q,undeclared:X}:Q,q?void 0:{shouldTransform:(Z)=>!F0(C1,Z.kind)}))}hasEqualMorphs(U){if(!this.includesTransform&&!U.includesTransform)return!0;if(!y0(this.shallowMorphs,U.shallowMorphs))return!1;if(!y0(this.flatMorphs,U.flatMorphs,{isEqual:(X,q)=>X.propString===q.propString&&(X.node.hasKind("morph")&&q.node.hasKind("morph")?X.node.hasEqualMorphs(q.node):X.node.hasKind("intersection")&&q.node.hasKind("intersection")?X.node.structure?.structuralMorphRef===q.node.structure?.structuralMorphRef:!1)}))return!1;return!0}onDeepUndeclaredKey(U){return this.onUndeclaredKey({rule:U,deep:!0})}filter(U){return this.constrainIn("predicate",U)}divisibleBy(U){return this.constrain("divisor",U)}matching(U){return this.constrain("pattern",U)}atLeast(U){return this.constrain("min",U)}atMost(U){return this.constrain("max",U)}moreThan(U){return this.constrain("min",v1(U))}lessThan(U){return this.constrain("max",v1(U))}atLeastLength(U){return this.constrain("minLength",U)}atMostLength(U){return this.constrain("maxLength",U)}moreThanLength(U){return this.constrain("minLength",v1(U))}lessThanLength(U){return this.constrain("maxLength",v1(U))}exactlyLength(U){return this.constrain("exactLength",U)}atOrAfter(U){return this.constrain("after",U)}atOrBefore(U){return this.constrain("before",U)}laterThan(U){return this.constrain("after",v1(U))}earlierThan(U){return this.constrain("before",v1(U))}}var F5="Expected a non-empty brand name after #",yq=["draft-2020-12","draft-07"],A5=(U)=>`JSONSchema target '${U}' is not supported (must be ${yq.map((X)=>`"${X}"`).join(" or ")})`,bq=(U)=>{if(!F0(yq,U))F(A5(U));return U},v1=(U)=>typeof U==="object"&&!(U instanceof Date)?{...U,exclusive:!0}:{rule:U,exclusive:!0},N2=(U,X)=>M(X,"root")?M(U,"root")?U.extends(X):X.allows(U):M(U,"root")?U.hasUnit(X):X===U,fq=(U)=>{if(U.hasKind("morph"))return null;if(U.hasKind("intersection"))return U.inner.structure??(U.basis?.domain==="object"?U.$.bindReference(O.intrinsic.emptyStructure):null);if(U.isBasis()&&U.domain==="object")return U.$.bindReference(O.intrinsic.emptyStructure);return null},O5=(U)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
163
- ${U}`,gq=(U,X)=>`${U} operand must be an object (was ${X})`;var E0=(U,X)=>S(T6(U),(q,Z)=>[Z,X]);var B5=(U)=>typeof U==="string"?{reference:U}:U,kq=(U)=>U instanceof T?O.intrinsic.never.internal:U,T5=j({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:(U)=>U.startsWith("$")?U:`$ark.${U}`},resolve:{}},normalize:B5,defaults:{description:(U)=>U.reference},intersections:{alias:(U,X,q)=>q.$.lazilyResolve(()=>kq(u(U.resolution,X.resolution,q)),`${U.reference}${q.pipe?"=>":"&"}${X.reference}`),...E0("alias",(U,X,q)=>{if(X.isUnknown())return U;if(X.isNever())return X;if(X.isBasis()&&!X.overlaps(O.intrinsic.object))return T.init("assignability",O.intrinsic.object,X);return q.$.lazilyResolve(()=>kq(u(U.resolution,X,q)),`${U.reference}${q.pipe?"=>":"&"}${X.id}`)})}});class vq extends B0{expression=this.reference;structure=void 0;get resolution(){let U=this._resolve();return Q0[this.id]=U}_resolve(){if(this.resolve)return this.resolve();if(this.reference[0]==="$")return this.$.resolveRoot(this.reference.slice(1));let U=this.reference,X=Q0[U],q=[];while(M(X,"context")){if(q.includes(X.id))return F(V5(X.id,q));q.push(X.id),X=Q0[X.id]}if(!M(X,"root"))return y(`Unexpected resolution for reference ${this.reference}
162
+ `})}}),this);return this.$.finalize(X)}pipe=Object.assign(this._pipe.bind(this),{try:this.tryPipe.bind(this)});to(U){return this.$.finalize(this.toNode(this.$.parseDefinition(U)))}toNode(U){let X=D2(this,U,this.$);if(X instanceof T)return X.throw();return X}rawPipeOnce(U){if(M(U,"root"))return this.toNode(U);return this.distribute((X)=>X.hasKind("morph")?this.$.node("morph",{in:X.inner.in,morphs:[...X.morphs,U]}):this.$.node("morph",{in:X,morphs:[U]}),this.$.parseSchema)}narrow(U){return this.constrainOut("predicate",U)}constrain(U,X){return this._constrain("root",U,X)}constrainIn(U,X){return this._constrain("in",U,X)}constrainOut(U,X){return this._constrain("out",U,X)}_constrain(U,X,q){let Z=this.$.node(X,q);if(Z.isRoot())return Z.isUnknown()?this:y(`Unexpected constraint node ${Z}`);let Q=U==="root"?this:U==="in"?this.rawIn:this.rawOut;if(Q.hasKind("morph")||Z.impliedBasis&&!Q.extends(Z.impliedBasis))return Lq(X,Z.impliedBasis,this);let G=this.$.node("intersection",{[Z.kind]:Z}),Y=U==="out"?D2(this,G,this.$):$0(this,G,this.$);if(Y instanceof T)Y.throw();return this.$.finalize(Y)}onUndeclaredKey(U){let X=typeof U==="string"?U:U.rule,q=typeof U==="string"?!1:U.deep;return this.$.finalize(this.transform((Z,Q)=>Z==="structure"?X==="ignore"?_6(Q,{undeclared:1}):{...Q,undeclared:X}:Q,q?void 0:{shouldTransform:(Z)=>!F0(C1,Z.kind)}))}hasEqualMorphs(U){if(!this.includesTransform&&!U.includesTransform)return!0;if(!y0(this.shallowMorphs,U.shallowMorphs))return!1;if(!y0(this.flatMorphs,U.flatMorphs,{isEqual:(X,q)=>X.propString===q.propString&&(X.node.hasKind("morph")&&q.node.hasKind("morph")?X.node.hasEqualMorphs(q.node):X.node.hasKind("intersection")&&q.node.hasKind("intersection")?X.node.structure?.structuralMorphRef===q.node.structure?.structuralMorphRef:!1)}))return!1;return!0}onDeepUndeclaredKey(U){return this.onUndeclaredKey({rule:U,deep:!0})}filter(U){return this.constrainIn("predicate",U)}divisibleBy(U){return this.constrain("divisor",U)}matching(U){return this.constrain("pattern",U)}atLeast(U){return this.constrain("min",U)}atMost(U){return this.constrain("max",U)}moreThan(U){return this.constrain("min",v1(U))}lessThan(U){return this.constrain("max",v1(U))}atLeastLength(U){return this.constrain("minLength",U)}atMostLength(U){return this.constrain("maxLength",U)}moreThanLength(U){return this.constrain("minLength",v1(U))}lessThanLength(U){return this.constrain("maxLength",v1(U))}exactlyLength(U){return this.constrain("exactLength",U)}atOrAfter(U){return this.constrain("after",U)}atOrBefore(U){return this.constrain("before",U)}laterThan(U){return this.constrain("after",v1(U))}earlierThan(U){return this.constrain("before",v1(U))}}var V5="Expected a non-empty brand name after #",kq=["draft-2020-12","draft-07"],R5=(U)=>`JSONSchema target '${U}' is not supported (must be ${kq.map((X)=>`"${X}"`).join(" or ")})`,fq=(U)=>{if(!F0(kq,U))F(R5(U));return U},v1=(U)=>typeof U==="object"&&!(U instanceof Date)?{...U,exclusive:!0}:{rule:U,exclusive:!0},N2=(U,X)=>M(X,"root")?M(U,"root")?U.extends(X):X.allows(U):M(U,"root")?U.hasUnit(X):X===U,gq=(U)=>{if(U.hasKind("morph"))return null;if(U.hasKind("intersection"))return U.inner.structure??(U.basis?.domain==="object"?U.$.bindReference(O.intrinsic.emptyStructure):null);if(U.isBasis()&&U.domain==="object")return U.$.bindReference(O.intrinsic.emptyStructure);return null},D5=(U)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
163
+ ${U}`,yq=(U,X)=>`${U} operand must be an object (was ${X})`;var E0=(U,X)=>S(T6(U),(q,Z)=>[Z,X]);var M5=(U)=>typeof U==="string"?{reference:U}:U,vq=(U)=>U instanceof T?O.intrinsic.never.internal:U,w5=j({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:(U)=>U.startsWith("$")?U:`$ark.${U}`},resolve:{}},normalize:M5,defaults:{description:(U)=>U.reference},intersections:{alias:(U,X,q)=>q.$.lazilyResolve(()=>vq(u(U.resolution,X.resolution,q)),`${U.reference}${q.pipe?"=>":"&"}${X.reference}`),...E0("alias",(U,X,q)=>{if(X.isUnknown())return U;if(X.isNever())return X;if(X.isBasis()&&!X.overlaps(O.intrinsic.object))return T.init("assignability",O.intrinsic.object,X);return q.$.lazilyResolve(()=>vq(u(U.resolution,X,q)),`${U.reference}${q.pipe?"=>":"&"}${X.id}`)})}});class hq extends B0{expression=this.reference;structure=void 0;get resolution(){let U=this._resolve();return Q0[this.id]=U}_resolve(){if(this.resolve)return this.resolve();if(this.reference[0]==="$")return this.$.resolveRoot(this.reference.slice(1));let U=this.reference,X=Q0[U],q=[];while(M(X,"context")){if(q.includes(X.id))return F(P5(X.id,q));q.push(X.id),X=Q0[X.id]}if(!M(X,"root"))return y(`Unexpected resolution for reference ${this.reference}
164
164
  Seen: [${q.join("->")}]
165
- Resolution: ${E(X)}`);return X}get resolutionId(){if(this.reference.includes("&")||this.reference.includes("=>"))return this.resolution.id;if(this.reference[0]!=="$")return this.reference;let U=this.reference.slice(1),X=this.$.resolutions[U];if(typeof X==="string")return X;if(M(X,"root"))return X.id;return y(`Unexpected resolution for reference ${this.reference}: ${E(X)}`)}get defaultShortDescription(){return Y0.object}innerToJsonSchema(U){return this.resolution.toJsonSchemaRecurse(U)}traverseAllows=(U,X)=>{let q=X.seen[this.reference];if(q?.includes(U))return!0;return X.seen[this.reference]=g(q,U),this.resolution.traverseAllows(U,X)};traverseApply=(U,X)=>{let q=X.seen[this.reference];if(q?.includes(U))return;X.seen[this.reference]=g(q,U),this.resolution.traverseApply(U,X)};compile(U){let X=this.resolutionId;U.if(`ctx.seen.${X} && ctx.seen.${X}.includes(data)`,()=>U.return(!0)),U.if(`!ctx.seen.${X}`,()=>U.line(`ctx.seen.${X} = []`)),U.line(`ctx.seen.${X}.push(data)`),U.return(U.invoke(X))}}var V5=(U,X)=>`Alias '${U}' has a shallow resolution cycle: ${[...X,U].join("->")}`,C2={implementation:T5,Node:vq};class L1 extends B0{traverseApply=(U,X)=>{if(!this.traverseAllows(U,X))X.errorFromNodeContext(this.errorContext)};get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return s0(this.errorContext)}compile(U){if(U.traversalKind==="Allows")U.return(this.compiledCondition);else U.if(this.compiledNegation,()=>U.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}}var R5=j({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:(U)=>typeof U==="string"?{domain:U}:K1(U,"numberAllowsNaN")&&U.domain!=="number"?F(I6.writeBadAllowNanMessage(U.domain)):U,applyConfig:(U,X)=>U.numberAllowsNaN===void 0&&U.domain==="number"&&X.numberAllowsNaN?{...U,numberAllowsNaN:!0}:U,defaults:{description:(U)=>Y0[U.domain],actual:(U)=>Number.isNaN(U)?"NaN":Y0[r(U)]},intersections:{domain:(U,X)=>U.domain==="number"&&X.domain==="number"?U.numberAllowsNaN?X:U:T.init("domain",U,X)}});class hq extends L1{requiresNaNCheck=this.domain==="number"&&!this.numberAllowsNaN;traverseAllows=this.requiresNaNCheck?(U)=>typeof U==="number"&&!Number.isNaN(U):(U)=>r(U)===this.domain;compiledCondition=this.domain==="object"?'((typeof data === "object" && data !== null) || typeof data === "function")':`typeof data === "${this.domain}"${this.requiresNaNCheck?" && !Number.isNaN(data)":""}`;compiledNegation=this.domain==="object"?'((typeof data !== "object" || data === null) && typeof data !== "function")':`typeof data !== "${this.domain}"${this.requiresNaNCheck?" || Number.isNaN(data)":""}`;expression=this.numberAllowsNaN?"number | NaN":this.domain;get nestableExpression(){return this.numberAllowsNaN?`(${this.expression})`:this.expression}get defaultShortDescription(){return Y0[this.domain]}innerToJsonSchema(U){if(this.domain==="bigint"||this.domain==="symbol")return U.fallback.domain({code:"domain",base:{},domain:this.domain});return{type:this.domain}}}var I6={implementation:R5,Node:hq,writeBadAllowNanMessage:(U)=>`numberAllowsNaN may only be specified with domain "number" (was ${U})`};var D5=j({kind:"intersection",hasAssociatedError:!0,normalize:(U)=>{if(x(U))return U;let{structure:X,...q}=U,Z=!!X,Q=X??{},G=S(q,(Y,J)=>{if(n(Y,qq)){if(Z)F(`Flattened structure key ${Y} cannot be specified alongside a root 'structure' key.`);return Q[Y]=J,[]}return[Y,J]});if(M(Q,"constraint")||!S0(Q))G.structure=Q;return G},finalizeInnerJson:({structure:U,...X})=>G0(U,"object")?{...U,...X}:X,keys:{domain:{child:!0,parse:(U,X)=>X.$.node("domain",U)},proto:{child:!0,parse:(U,X)=>X.$.node("proto",U)},structure:{child:!0,parse:(U,X)=>X.$.node("structure",U),serialize:(U)=>{if(!U.sequence?.minLength)return U.collapsibleJson;let{sequence:X,...q}=U.collapsibleJson,{minVariadicLength:Z,...Q}=X,G=Q.variadic&&Object.keys(Q).length===1?Q.variadic:Q;return{...q,sequence:G}}},divisor:{child:!0,parse:q0("divisor")},max:{child:!0,parse:q0("max")},min:{child:!0,parse:q0("min")},maxLength:{child:!0,parse:q0("maxLength")},minLength:{child:!0,parse:q0("minLength")},exactLength:{child:!0,parse:q0("exactLength")},before:{child:!0,parse:q0("before")},after:{child:!0,parse:q0("after")},pattern:{child:!0,parse:q0("pattern")},predicate:{child:!0,parse:q0("predicate")}},reduce:(U,X)=>xq({},U,{$:X,invert:!1,pipe:!1}),defaults:{description:(U)=>{if(U.children.length===0)return"unknown";if(U.structure)return U.structure.description;let X=[];if(U.basis&&!U.prestructurals.some((q)=>q.impl.obviatesBasisDescription))X.push(U.basis.description);if(U.prestructurals.length){let q=U.prestructurals.slice().sort((Z,Q)=>Z.kind==="min"&&Q.kind==="max"?-1:0).map((Z)=>Z.description);X.push(...q)}if(U.inner.predicate)X.push(...U.inner.predicate.map((q)=>q.description));return X.join(" and ")},expected:(U)=>` ◦ ${U.errors.map((X)=>X.expected).join(`
165
+ Resolution: ${E(X)}`);return X}get resolutionId(){if(this.reference.includes("&")||this.reference.includes("=>"))return this.resolution.id;if(this.reference[0]!=="$")return this.reference;let U=this.reference.slice(1),X=this.$.resolutions[U];if(typeof X==="string")return X;if(M(X,"root"))return X.id;return y(`Unexpected resolution for reference ${this.reference}: ${E(X)}`)}get defaultShortDescription(){return Y0.object}innerToJsonSchema(U){return this.resolution.toJsonSchemaRecurse(U)}traverseAllows=(U,X)=>{let q=X.seen[this.reference];if(q?.includes(U))return!0;return X.seen[this.reference]=g(q,U),this.resolution.traverseAllows(U,X)};traverseApply=(U,X)=>{let q=X.seen[this.reference];if(q?.includes(U))return;X.seen[this.reference]=g(q,U),this.resolution.traverseApply(U,X)};compile(U){let X=this.resolutionId;U.if(`ctx.seen.${X} && ctx.seen.${X}.includes(data)`,()=>U.return(!0)),U.if(`!ctx.seen.${X}`,()=>U.line(`ctx.seen.${X} = []`)),U.line(`ctx.seen.${X}.push(data)`),U.return(U.invoke(X))}}var P5=(U,X)=>`Alias '${U}' has a shallow resolution cycle: ${[...X,U].join("->")}`,C2={implementation:w5,Node:hq};class L1 extends B0{traverseApply=(U,X)=>{if(!this.traverseAllows(U,X))X.errorFromNodeContext(this.errorContext)};get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return s0(this.errorContext)}compile(U){if(U.traversalKind==="Allows")U.return(this.compiledCondition);else U.if(this.compiledNegation,()=>U.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}}var I5=j({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:(U)=>typeof U==="string"?{domain:U}:K1(U,"numberAllowsNaN")&&U.domain!=="number"?F(I6.writeBadAllowNanMessage(U.domain)):U,applyConfig:(U,X)=>U.numberAllowsNaN===void 0&&U.domain==="number"&&X.numberAllowsNaN?{...U,numberAllowsNaN:!0}:U,defaults:{description:(U)=>Y0[U.domain],actual:(U)=>Number.isNaN(U)?"NaN":Y0[r(U)]},intersections:{domain:(U,X)=>U.domain==="number"&&X.domain==="number"?U.numberAllowsNaN?X:U:T.init("domain",U,X)}});class xq extends L1{requiresNaNCheck=this.domain==="number"&&!this.numberAllowsNaN;traverseAllows=this.requiresNaNCheck?(U)=>typeof U==="number"&&!Number.isNaN(U):(U)=>r(U)===this.domain;compiledCondition=this.domain==="object"?'((typeof data === "object" && data !== null) || typeof data === "function")':`typeof data === "${this.domain}"${this.requiresNaNCheck?" && !Number.isNaN(data)":""}`;compiledNegation=this.domain==="object"?'((typeof data !== "object" || data === null) && typeof data !== "function")':`typeof data !== "${this.domain}"${this.requiresNaNCheck?" || Number.isNaN(data)":""}`;expression=this.numberAllowsNaN?"number | NaN":this.domain;get nestableExpression(){return this.numberAllowsNaN?`(${this.expression})`:this.expression}get defaultShortDescription(){return Y0[this.domain]}innerToJsonSchema(U){if(this.domain==="bigint"||this.domain==="symbol")return U.fallback.domain({code:"domain",base:{},domain:this.domain});return{type:this.domain}}}var I6={implementation:I5,Node:xq,writeBadAllowNanMessage:(U)=>`numberAllowsNaN may only be specified with domain "number" (was ${U})`};var K5=j({kind:"intersection",hasAssociatedError:!0,normalize:(U)=>{if(x(U))return U;let{structure:X,...q}=U,Z=!!X,Q=X??{},G=S(q,(Y,J)=>{if(n(Y,Zq)){if(Z)F(`Flattened structure key ${Y} cannot be specified alongside a root 'structure' key.`);return Q[Y]=J,[]}return[Y,J]});if(M(Q,"constraint")||!S0(Q))G.structure=Q;return G},finalizeInnerJson:({structure:U,...X})=>G0(U,"object")?{...U,...X}:X,keys:{domain:{child:!0,parse:(U,X)=>X.$.node("domain",U)},proto:{child:!0,parse:(U,X)=>X.$.node("proto",U)},structure:{child:!0,parse:(U,X)=>X.$.node("structure",U),serialize:(U)=>{if(!U.sequence?.minLength)return U.collapsibleJson;let{sequence:X,...q}=U.collapsibleJson,{minVariadicLength:Z,...Q}=X,G=Q.variadic&&Object.keys(Q).length===1?Q.variadic:Q;return{...q,sequence:G}}},divisor:{child:!0,parse:q0("divisor")},max:{child:!0,parse:q0("max")},min:{child:!0,parse:q0("min")},maxLength:{child:!0,parse:q0("maxLength")},minLength:{child:!0,parse:q0("minLength")},exactLength:{child:!0,parse:q0("exactLength")},before:{child:!0,parse:q0("before")},after:{child:!0,parse:q0("after")},pattern:{child:!0,parse:q0("pattern")},predicate:{child:!0,parse:q0("predicate")}},reduce:(U,X)=>uq({},U,{$:X,invert:!1,pipe:!1}),defaults:{description:(U)=>{if(U.children.length===0)return"unknown";if(U.structure)return U.structure.description;let X=[];if(U.basis&&!U.prestructurals.some((q)=>q.impl.obviatesBasisDescription))X.push(U.basis.description);if(U.prestructurals.length){let q=U.prestructurals.slice().sort((Z,Q)=>Z.kind==="min"&&Q.kind==="max"?-1:0).map((Z)=>Z.description);X.push(...q)}if(U.inner.predicate)X.push(...U.inner.predicate.map((q)=>q.description));return X.join(" and ")},expected:(U)=>` ◦ ${U.errors.map((X)=>X.expected).join(`
166
166
  ◦ `)}`,problem:(U)=>`(${U.actual}) must be...
167
- ${U.expected}`},intersections:{intersection:(U,X,q)=>xq(U.inner,X.inner,q),...E0("intersection",(U,X,q)=>{if(U.children.length===0)return X;let{domain:Z,proto:Q,...G}=U.inner,Y=Q??Z,J=Y?u(Y,X,q):X;return J instanceof T?J:U?.basis?.equals(J)?U:U.$.node("intersection",{...G,[J.kind]:J},{prereduced:!0})})}});class uq extends B0{basis=this.inner.domain??this.inner.proto??null;prestructurals=[];refinements=this.children.filter((U)=>{if(!U.isRefinement())return!1;if(F0(s4,U.kind))this.prestructurals.push(U);return!0});structure=this.inner.structure;expression=M5(this);get shallowMorphs(){return this.inner.structure?.structuralMorph?[this.inner.structure.structuralMorph]:[]}get defaultShortDescription(){return this.basis?.defaultShortDescription??"present"}innerToJsonSchema(U){return this.children.reduce((X,q)=>q.isBasis()?q.toJsonSchemaRecurse(U):q.reduceJsonSchema(X,U),{})}traverseAllows=(U,X)=>this.children.every((q)=>q.traverseAllows(U,X));traverseApply=(U,X)=>{let q=X.currentErrorCount;if(this.basis){if(this.basis.traverseApply(U,X),X.currentErrorCount>q)return}if(this.prestructurals.length){for(let Z=0;Z<this.prestructurals.length-1;Z++)if(this.prestructurals[Z].traverseApply(U,X),X.failFast&&X.currentErrorCount>q)return;if(this.prestructurals[this.prestructurals.length-1].traverseApply(U,X),X.currentErrorCount>q)return}if(this.structure){if(this.structure.traverseApply(U,X),X.currentErrorCount>q)return}if(this.inner.predicate){for(let Z=0;Z<this.inner.predicate.length-1;Z++)if(this.inner.predicate[Z].traverseApply(U,X),X.failFast&&X.currentErrorCount>q)return;this.inner.predicate[this.inner.predicate.length-1].traverseApply(U,X)}};compile(U){if(U.traversalKind==="Allows"){for(let X of this.children)U.check(X);U.return(!0);return}if(U.initializeErrorCount(),this.basis){if(U.check(this.basis),this.children.length>1)U.returnIfFail()}if(this.prestructurals.length){for(let X=0;X<this.prestructurals.length-1;X++)U.check(this.prestructurals[X]),U.returnIfFailFast();if(U.check(this.prestructurals[this.prestructurals.length-1]),this.structure||this.inner.predicate)U.returnIfFail()}if(this.structure){if(U.check(this.structure),this.inner.predicate)U.returnIfFail()}if(this.inner.predicate){for(let X=0;X<this.inner.predicate.length-1;X++)U.check(this.inner.predicate[X]),U.returnIfFail();U.check(this.inner.predicate[this.inner.predicate.length-1])}}}var O9={implementation:D5,Node:uq},M5=(U)=>{if(U.structure?.expression)return U.structure.expression;let X=U.basis&&!U.prestructurals.some((Q)=>Q.impl.obviatesBasisExpression)?U.basis.nestableExpression:"",q=U.prestructurals.map((Q)=>Q.expression).join(" & "),Z=`${X}${X?" ":""}${q}`;if(Z==="Array == 0")return"[]";return Z||"unknown"},xq=(U,X,q)=>{let Z={},Q=U.proto??U.domain,G=X.proto??X.domain,Y=Q?G?u(Q,G,q):Q:G;if(Y instanceof T)return Y;if(Y)Z[Y.kind]=Y;return f1({kind:"intersection",baseInner:Z,l:g1(U),r:g1(X),roots:[],ctx:q})};var w5=j({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:(U,X)=>X.$.parseSchema(U)},morphs:{parse:l0,serialize:(U)=>U.map((X)=>M(X,"root")?X.json:d(X))},declaredIn:{child:!1,serialize:(U)=>U.json},declaredOut:{child:!1,serialize:(U)=>U.json}},normalize:(U)=>U,defaults:{description:(U)=>`a morph from ${U.rawIn.description} to ${U.rawOut?.description??"unknown"}`},intersections:{morph:(U,X,q)=>{if(!U.hasEqualMorphs(X))return F(P5(U.expression,X.expression));let Z=u(U.rawIn,X.rawIn,q);if(Z instanceof T)return Z;let Q={morphs:U.morphs};if(U.declaredIn||X.declaredIn){let G=u(U.rawIn,X.rawIn,q);if(G instanceof T)return G.throw();else Q.declaredIn=G}if(U.declaredOut||X.declaredOut){let G=u(U.rawOut,X.rawOut,q);if(G instanceof T)return G.throw();else Q.declaredOut=G}return Z.distribute((G)=>q.$.node("morph",{...Q,in:G}),q.$.parseSchema)},...E0("morph",(U,X,q)=>{let Z=U.inner.in?u(U.inner.in,X,q):X;return Z instanceof T?Z:Z.equals(U.inner.in)?U:q.$.node("morph",{...U.inner,in:Z})})}});class mq extends B0{serializedMorphs=this.morphs.map(d);compiledMorphs=`[${this.serializedMorphs}]`;lastMorph=this.inner.morphs[this.inner.morphs.length-1];lastMorphIfNode=M(this.lastMorph,"root")?this.lastMorph:void 0;introspectableIn=this.inner.in;introspectableOut=this.lastMorphIfNode?Object.assign(this.referencesById,this.lastMorphIfNode.referencesById)&&this.lastMorphIfNode.rawOut:void 0;get shallowMorphs(){return Array.isArray(this.inner.in?.shallowMorphs)?[...this.inner.in.shallowMorphs,...this.morphs]:this.morphs}get rawIn(){return this.declaredIn??this.inner.in?.rawIn??O.intrinsic.unknown.internal}get rawOut(){return this.declaredOut??this.introspectableOut??O.intrinsic.unknown.internal}declareIn(U){return this.$.node("morph",{...this.inner,declaredIn:U})}declareOut(U){return this.$.node("morph",{...this.inner,declaredOut:U})}expression=`(In: ${this.rawIn.expression}) => ${this.lastMorphIfNode?"To":"Out"}<${this.rawOut.expression}>`;get defaultShortDescription(){return this.rawIn.meta.description??this.rawIn.defaultShortDescription}innerToJsonSchema(U){return U.fallback.morph({code:"morph",base:this.rawIn.toJsonSchemaRecurse(U),out:this.introspectableOut?.toJsonSchemaRecurse(U)??null})}compile(U){if(U.traversalKind==="Allows"){if(!this.introspectableIn)return;U.return(U.invoke(this.introspectableIn));return}if(this.introspectableIn)U.line(U.invoke(this.introspectableIn));U.line(`ctx.queueMorphs(${this.compiledMorphs})`)}traverseAllows=(U,X)=>!this.introspectableIn||this.introspectableIn.traverseAllows(U,X);traverseApply=(U,X)=>{if(this.introspectableIn)this.introspectableIn.traverseApply(U,X);X.queueMorphs(this.morphs)};hasEqualMorphs(U){return y0(this.morphs,U.morphs,{isEqual:(X,q)=>X===q||M(X,"root")&&M(q,"root")&&X.equals(q)})}}var B9={implementation:w5,Node:mq},P5=(U,X)=>`The intersection of distinct morphs at a single path is indeterminate:
167
+ ${U.expected}`},intersections:{intersection:(U,X,q)=>uq(U.inner,X.inner,q),...E0("intersection",(U,X,q)=>{if(U.children.length===0)return X;let{domain:Z,proto:Q,...G}=U.inner,Y=Q??Z,J=Y?u(Y,X,q):X;return J instanceof T?J:U?.basis?.equals(J)?U:U.$.node("intersection",{...G,[J.kind]:J},{prereduced:!0})})}});class mq extends B0{basis=this.inner.domain??this.inner.proto??null;prestructurals=[];refinements=this.children.filter((U)=>{if(!U.isRefinement())return!1;if(F0(s4,U.kind))this.prestructurals.push(U);return!0});structure=this.inner.structure;expression=N5(this);get shallowMorphs(){return this.inner.structure?.structuralMorph?[this.inner.structure.structuralMorph]:[]}get defaultShortDescription(){return this.basis?.defaultShortDescription??"present"}innerToJsonSchema(U){return this.children.reduce((X,q)=>q.isBasis()?q.toJsonSchemaRecurse(U):q.reduceJsonSchema(X,U),{})}traverseAllows=(U,X)=>this.children.every((q)=>q.traverseAllows(U,X));traverseApply=(U,X)=>{let q=X.currentErrorCount;if(this.basis){if(this.basis.traverseApply(U,X),X.currentErrorCount>q)return}if(this.prestructurals.length){for(let Z=0;Z<this.prestructurals.length-1;Z++)if(this.prestructurals[Z].traverseApply(U,X),X.failFast&&X.currentErrorCount>q)return;if(this.prestructurals[this.prestructurals.length-1].traverseApply(U,X),X.currentErrorCount>q)return}if(this.structure){if(this.structure.traverseApply(U,X),X.currentErrorCount>q)return}if(this.inner.predicate){for(let Z=0;Z<this.inner.predicate.length-1;Z++)if(this.inner.predicate[Z].traverseApply(U,X),X.failFast&&X.currentErrorCount>q)return;this.inner.predicate[this.inner.predicate.length-1].traverseApply(U,X)}};compile(U){if(U.traversalKind==="Allows"){for(let X of this.children)U.check(X);U.return(!0);return}if(U.initializeErrorCount(),this.basis){if(U.check(this.basis),this.children.length>1)U.returnIfFail()}if(this.prestructurals.length){for(let X=0;X<this.prestructurals.length-1;X++)U.check(this.prestructurals[X]),U.returnIfFailFast();if(U.check(this.prestructurals[this.prestructurals.length-1]),this.structure||this.inner.predicate)U.returnIfFail()}if(this.structure){if(U.check(this.structure),this.inner.predicate)U.returnIfFail()}if(this.inner.predicate){for(let X=0;X<this.inner.predicate.length-1;X++)U.check(this.inner.predicate[X]),U.returnIfFail();U.check(this.inner.predicate[this.inner.predicate.length-1])}}}var O9={implementation:K5,Node:mq},N5=(U)=>{if(U.structure?.expression)return U.structure.expression;let X=U.basis&&!U.prestructurals.some((Q)=>Q.impl.obviatesBasisExpression)?U.basis.nestableExpression:"",q=U.prestructurals.map((Q)=>Q.expression).join(" & "),Z=`${X}${X?" ":""}${q}`;if(Z==="Array == 0")return"[]";return Z||"unknown"},uq=(U,X,q)=>{let Z={},Q=U.proto??U.domain,G=X.proto??X.domain,Y=Q?G?u(Q,G,q):Q:G;if(Y instanceof T)return Y;if(Y)Z[Y.kind]=Y;return f1({kind:"intersection",baseInner:Z,l:g1(U),r:g1(X),roots:[],ctx:q})};var C5=j({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:(U,X)=>X.$.parseSchema(U)},morphs:{parse:l0,serialize:(U)=>U.map((X)=>M(X,"root")?X.json:d(X))},declaredIn:{child:!1,serialize:(U)=>U.json},declaredOut:{child:!1,serialize:(U)=>U.json}},normalize:(U)=>U,defaults:{description:(U)=>`a morph from ${U.rawIn.description} to ${U.rawOut?.description??"unknown"}`},intersections:{morph:(U,X,q)=>{if(!U.hasEqualMorphs(X))return F(S5(U.expression,X.expression));let Z=u(U.rawIn,X.rawIn,q);if(Z instanceof T)return Z;let Q={morphs:U.morphs};if(U.declaredIn||X.declaredIn){let G=u(U.rawIn,X.rawIn,q);if(G instanceof T)return G.throw();else Q.declaredIn=G}if(U.declaredOut||X.declaredOut){let G=u(U.rawOut,X.rawOut,q);if(G instanceof T)return G.throw();else Q.declaredOut=G}return Z.distribute((G)=>q.$.node("morph",{...Q,in:G}),q.$.parseSchema)},...E0("morph",(U,X,q)=>{let Z=U.inner.in?u(U.inner.in,X,q):X;return Z instanceof T?Z:Z.equals(U.inner.in)?U:q.$.node("morph",{...U.inner,in:Z})})}});class pq extends B0{serializedMorphs=this.morphs.map(d);compiledMorphs=`[${this.serializedMorphs}]`;lastMorph=this.inner.morphs[this.inner.morphs.length-1];lastMorphIfNode=M(this.lastMorph,"root")?this.lastMorph:void 0;introspectableIn=this.inner.in;introspectableOut=this.lastMorphIfNode?Object.assign(this.referencesById,this.lastMorphIfNode.referencesById)&&this.lastMorphIfNode.rawOut:void 0;get shallowMorphs(){return Array.isArray(this.inner.in?.shallowMorphs)?[...this.inner.in.shallowMorphs,...this.morphs]:this.morphs}get rawIn(){return this.declaredIn??this.inner.in?.rawIn??O.intrinsic.unknown.internal}get rawOut(){return this.declaredOut??this.introspectableOut??O.intrinsic.unknown.internal}declareIn(U){return this.$.node("morph",{...this.inner,declaredIn:U})}declareOut(U){return this.$.node("morph",{...this.inner,declaredOut:U})}expression=`(In: ${this.rawIn.expression}) => ${this.lastMorphIfNode?"To":"Out"}<${this.rawOut.expression}>`;get defaultShortDescription(){return this.rawIn.meta.description??this.rawIn.defaultShortDescription}innerToJsonSchema(U){return U.fallback.morph({code:"morph",base:this.rawIn.toJsonSchemaRecurse(U),out:this.introspectableOut?.toJsonSchemaRecurse(U)??null})}compile(U){if(U.traversalKind==="Allows"){if(!this.introspectableIn)return;U.return(U.invoke(this.introspectableIn));return}if(this.introspectableIn)U.line(U.invoke(this.introspectableIn));U.line(`ctx.queueMorphs(${this.compiledMorphs})`)}traverseAllows=(U,X)=>!this.introspectableIn||this.introspectableIn.traverseAllows(U,X);traverseApply=(U,X)=>{if(this.introspectableIn)this.introspectableIn.traverseApply(U,X);X.queueMorphs(this.morphs)};hasEqualMorphs(U){return y0(this.morphs,U.morphs,{isEqual:(X,q)=>X===q||M(X,"root")&&M(q,"root")&&X.equals(q)})}}var B9={implementation:C5,Node:pq},S5=(U,X)=>`The intersection of distinct morphs at a single path is indeterminate:
168
168
  Left: ${U}
169
- Right: ${X}`;var I5=j({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:(U)=>_2(U)??A0(U)},dateAllowsInvalid:{}},normalize:(U)=>{let X=typeof U==="string"?{proto:H1[U]}:typeof U==="function"?x(U)?U:{proto:U}:typeof U.proto==="string"?{...U,proto:H1[U.proto]}:U;if(typeof X.proto!=="function")F(S2.writeInvalidSchemaMessage(X.proto));if(K1(X,"dateAllowsInvalid")&&X.proto!==Date)F(S2.writeBadInvalidDateMessage(X.proto));return X},applyConfig:(U,X)=>{if(U.dateAllowsInvalid===void 0&&U.proto===Date&&X.dateAllowsInvalid)return{...U,dateAllowsInvalid:!0};return U},defaults:{description:(U)=>U.builtinName?jX[U.builtinName]:`an instance of ${U.proto.name}`,actual:(U)=>U instanceof Date&&U.toString()==="Invalid Date"?"an invalid Date":W2(U)},intersections:{proto:(U,X)=>U.proto===Date&&X.proto===Date?U.dateAllowsInvalid?X:U:u4(U.proto,X.proto)?U:u4(X.proto,U.proto)?X:T.init("proto",U,X),domain:(U,X)=>X.domain==="object"?U:T.init("domain",O.intrinsic.object.internal,X)}});class pq extends L1{builtinName=_2(this.proto);serializedConstructor=this.json.proto;requiresInvalidDateCheck=this.proto===Date&&!this.dateAllowsInvalid;traverseAllows=this.requiresInvalidDateCheck?(U)=>U instanceof Date&&U.toString()!=="Invalid Date":(U)=>U instanceof this.proto;compiledCondition=`data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck?' && data.toString() !== "Invalid Date"':""}`;compiledNegation=`!(${this.compiledCondition})`;innerToJsonSchema(U){switch(this.builtinName){case"Array":return{type:"array"};case"Date":return U.fallback.date?.({code:"date",base:{}})??U.fallback.proto({code:"proto",base:{},proto:this.proto});default:return U.fallback.proto({code:"proto",base:{},proto:this.proto})}}expression=this.dateAllowsInvalid?"Date | InvalidDate":this.proto.name;get nestableExpression(){return this.dateAllowsInvalid?`(${this.expression})`:this.expression}domain="object";get defaultShortDescription(){return this.description}}var S2={implementation:I5,Node:pq,writeBadInvalidDateMessage:(U)=>`dateAllowsInvalid may only be specified with constructor Date (was ${U.name})`,writeInvalidSchemaMessage:(U)=>`instanceOf operand must be a function (was ${r(U)})`};var K5=j({kind:"union",hasAssociatedError:!0,collapsibleKey:"branches",keys:{ordered:{},branches:{child:!0,parse:(U,X)=>{let q=[];for(let Z of U){let Q=M(Z,"root")?Z.branches:X.$.parseSchema(Z).branches;for(let G of Q)if(G.hasKind("morph")){let Y=q.findIndex((J)=>J.hasKind("morph")&&J.hasEqualMorphs(G));if(Y===-1)q.push(G);else{let J=q[Y];q[Y]=X.$.node("morph",{...J.inner,in:J.rawIn.rawOr(G.rawIn)})}}else q.push(G)}if(!X.def.ordered)q.sort((Z,Q)=>Z.hash<Q.hash?-1:1);return q}}},normalize:(U)=>h(U)?{branches:U}:U,reduce:(U,X)=>{let q=k5(U);if(q.length===1)return q[0];if(q.length===U.branches.length)return;return X.node("union",{...U,branches:q},{prereduced:!0})},defaults:{description:(U)=>U.distribute((X)=>X.description,h1),expected:(U)=>{let X=wX(U.errors,"propString"),q=Object.entries(X).map(([Z,Q])=>{let G=[];for(let H of Q)C0(G,H.expected);let Y=h1(G),J=Q.every((H)=>H.actual===Q[0].actual)?Q[0].actual:E(Q[0].data);return`${Z&&`${Z} `}must be ${Y}${J&&` (was ${J})`}`});return h1(q)},problem:(U)=>U.expected,message:(U)=>{if(U.problem[0]==="[")return`value at ${U.problem}`;return U.problem}},intersections:{union:(U,X,q)=>{if(U.isNever!==X.isNever)return T.init("presence",U,X);let Z;if(U.ordered){if(X.ordered)F(h5(U.expression,X.expression));if(Z=T9(X.branches,U.branches,q),Z instanceof T)Z.invert()}else Z=T9(U.branches,X.branches,q);if(Z instanceof T)return Z;return q.$.parseSchema(U.ordered||X.ordered?{branches:Z,ordered:!0}:{branches:Z})},...E0("union",(U,X,q)=>{let Z=T9(U.branches,[X],q);if(Z instanceof T)return Z;if(Z.length===1)return Z[0];return q.$.parseSchema(U.ordered?{branches:Z,ordered:!0}:{branches:Z})})}});class cq extends B0{isBoolean=this.branches.length===2&&this.branches[0].hasUnit(!1)&&this.branches[1].hasUnit(!0);get branchGroups(){let U=[],X=-1;for(let q of this.branches){if(q.hasKind("unit")&&q.domain==="boolean"){if(X===-1)X=U.length,U.push(q);else U[X]=O.intrinsic.boolean;continue}U.push(q)}return U}unitBranches=this.branches.filter((U)=>U.rawIn.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?f5(this.discriminant):null;expression=this.distribute((U)=>U.nestableExpression,y5);createBranchedOptimisticRootApply(){return(U,X)=>{let q=this.traverseOptimistic(U);if(q!==J0)return q;let Z=new w0(U,this.$.resolvedConfig);return this.traverseApply(U,Z),Z.finalize(X)}}get shallowMorphs(){return this.branches.reduce((U,X)=>C0(U,X.shallowMorphs),[])}get defaultShortDescription(){return this.distribute((U)=>U.defaultShortDescription,h1)}innerToJsonSchema(U){if(this.branchGroups.length===1&&this.branchGroups[0].equals(O.intrinsic.boolean))return{type:"boolean"};let X=this.branchGroups.map((q)=>q.toJsonSchemaRecurse(U));if(X.every((q)=>Object.keys(q).length===1&&K1(q,"const")))return{enum:X.map((q)=>q.const)};return{anyOf:X}}traverseAllows=(U,X)=>this.branches.some((q)=>q.traverseAllows(U,X));traverseApply=(U,X)=>{let q=[];for(let Z=0;Z<this.branches.length;Z++){if(X.pushBranch(),this.branches[Z].traverseApply(U,X),!X.hasError()){if(this.branches[Z].includesTransform)return X.queuedMorphs.push(...X.popBranch().queuedMorphs);return X.popBranch()}q.push(X.popBranch().error)}X.errorFromNodeContext({code:"union",errors:q,meta:this.meta})};traverseOptimistic=(U)=>{for(let X=0;X<this.branches.length;X++){let q=this.branches[X];if(q.traverseAllows(U)){if(q.contextFreeMorph)return q.contextFreeMorph(U);return U}}return J0};compile(U){if(!this.discriminant||this.unitBranches.length===this.branches.length&&this.branches.length===2)return this.compileIndiscriminable(U);let X=this.discriminant.optionallyChainedPropString;if(this.discriminant.kind==="domain")X=`typeof ${X} === "object" ? ${X} === null ? "null" : "object" : typeof ${X} === "function" ? "object" : typeof ${X}`;let q=this.discriminant.cases,Z=Object.keys(q),{optimistic:Q}=U;if(U.optimistic=!1,U.block(`switch(${X})`,()=>{for(let W in q){let $=q[W],_=W==="default"?W:`case ${W}`,L;if($===!0)L=Q?"data":"true";else if(Q)if($.rootApplyStrategy==="branchedOptimistic")L=U.invoke($,{kind:"Optimistic"});else if($.contextFreeMorph)L=`${U.invoke($)} ? ${d($.contextFreeMorph)}(data) : "${J0}"`;else L=`${U.invoke($)} ? data : "${J0}"`;else L=U.invoke($);U.line(`${_}: return ${L}`)}return U}),U.traversalKind==="Allows"){U.return(Q?`"${J0}"`:!1);return}let G=h1(this.discriminant.kind==="domain"?Z.map((W)=>{let $=W.slice(1,-1);return $==="function"?Y0.object:Y0[$]}):Z),Y=this.discriminant.path.map((W)=>typeof W==="symbol"?d(W):JSON.stringify(W)),J=JSON.stringify(G),H=this.discriminant.kind==="domain"?`${j5}[${X}]`:`${b5}(${X})`;U.line(`ctx.errorFromNodeContext({
169
+ Right: ${X}`;var E5=j({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:(U)=>_2(U)??A0(U)},dateAllowsInvalid:{}},normalize:(U)=>{let X=typeof U==="string"?{proto:H1[U]}:typeof U==="function"?x(U)?U:{proto:U}:typeof U.proto==="string"?{...U,proto:H1[U.proto]}:U;if(typeof X.proto!=="function")F(S2.writeInvalidSchemaMessage(X.proto));if(K1(X,"dateAllowsInvalid")&&X.proto!==Date)F(S2.writeBadInvalidDateMessage(X.proto));return X},applyConfig:(U,X)=>{if(U.dateAllowsInvalid===void 0&&U.proto===Date&&X.dateAllowsInvalid)return{...U,dateAllowsInvalid:!0};return U},defaults:{description:(U)=>U.builtinName?bX[U.builtinName]:`an instance of ${U.proto.name}`,actual:(U)=>U instanceof Date&&U.toString()==="Invalid Date"?"an invalid Date":W2(U)},intersections:{proto:(U,X)=>U.proto===Date&&X.proto===Date?U.dateAllowsInvalid?X:U:u4(U.proto,X.proto)?U:u4(X.proto,U.proto)?X:T.init("proto",U,X),domain:(U,X)=>X.domain==="object"?U:T.init("domain",O.intrinsic.object.internal,X)}});class lq extends L1{builtinName=_2(this.proto);serializedConstructor=this.json.proto;requiresInvalidDateCheck=this.proto===Date&&!this.dateAllowsInvalid;traverseAllows=this.requiresInvalidDateCheck?(U)=>U instanceof Date&&U.toString()!=="Invalid Date":(U)=>U instanceof this.proto;compiledCondition=`data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck?' && data.toString() !== "Invalid Date"':""}`;compiledNegation=`!(${this.compiledCondition})`;innerToJsonSchema(U){switch(this.builtinName){case"Array":return{type:"array"};case"Date":return U.fallback.date?.({code:"date",base:{}})??U.fallback.proto({code:"proto",base:{},proto:this.proto});default:return U.fallback.proto({code:"proto",base:{},proto:this.proto})}}expression=this.dateAllowsInvalid?"Date | InvalidDate":this.proto.name;get nestableExpression(){return this.dateAllowsInvalid?`(${this.expression})`:this.expression}domain="object";get defaultShortDescription(){return this.description}}var S2={implementation:E5,Node:lq,writeBadInvalidDateMessage:(U)=>`dateAllowsInvalid may only be specified with constructor Date (was ${U.name})`,writeInvalidSchemaMessage:(U)=>`instanceOf operand must be a function (was ${r(U)})`};var j5=j({kind:"union",hasAssociatedError:!0,collapsibleKey:"branches",keys:{ordered:{},branches:{child:!0,parse:(U,X)=>{let q=[];for(let Z of U){let Q=M(Z,"root")?Z.branches:X.$.parseSchema(Z).branches;for(let G of Q)if(G.hasKind("morph")){let Y=q.findIndex((J)=>J.hasKind("morph")&&J.hasEqualMorphs(G));if(Y===-1)q.push(G);else{let J=q[Y];q[Y]=X.$.node("morph",{...J.inner,in:J.rawIn.rawOr(G.rawIn)})}}else q.push(G)}if(!X.def.ordered)q.sort((Z,Q)=>Z.hash<Q.hash?-1:1);return q}}},normalize:(U)=>h(U)?{branches:U}:U,reduce:(U,X)=>{let q=m5(U);if(q.length===1)return q[0];if(q.length===U.branches.length)return;return X.node("union",{...U,branches:q},{prereduced:!0})},defaults:{description:(U)=>U.distribute((X)=>X.description,h1),expected:(U)=>{let X=PX(U.errors,"propString"),q=Object.entries(X).map(([Z,Q])=>{let G=[];for(let H of Q)C0(G,H.expected);let Y=h1(G),J=Q.every((H)=>H.actual===Q[0].actual)?Q[0].actual:E(Q[0].data);return`${Z&&`${Z} `}must be ${Y}${J&&` (was ${J})`}`});return h1(q)},problem:(U)=>U.expected,message:(U)=>{if(U.problem[0]==="[")return`value at ${U.problem}`;return U.problem}},intersections:{union:(U,X,q)=>{if(U.isNever!==X.isNever)return T.init("presence",U,X);let Z;if(U.ordered){if(X.ordered)F(l5(U.expression,X.expression));if(Z=T9(X.branches,U.branches,q),Z instanceof T)Z.invert()}else Z=T9(U.branches,X.branches,q);if(Z instanceof T)return Z;return q.$.parseSchema(U.ordered||X.ordered?{branches:Z,ordered:!0}:{branches:Z})},...E0("union",(U,X,q)=>{let Z=T9(U.branches,[X],q);if(Z instanceof T)return Z;if(Z.length===1)return Z[0];return q.$.parseSchema(U.ordered?{branches:Z,ordered:!0}:{branches:Z})})}});class iq extends B0{isBoolean=this.branches.length===2&&this.branches[0].hasUnit(!1)&&this.branches[1].hasUnit(!0);get branchGroups(){let U=[],X=-1;for(let q of this.branches){if(q.hasKind("unit")&&q.domain==="boolean"){if(X===-1)X=U.length,U.push(q);else U[X]=O.intrinsic.boolean;continue}U.push(q)}return U}unitBranches=this.branches.filter((U)=>U.rawIn.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?h5(this.discriminant):null;expression=this.distribute((U)=>U.nestableExpression,u5);createBranchedOptimisticRootApply(){return(U,X)=>{let q=this.traverseOptimistic(U);if(q!==J0)return q;let Z=new w0(U,this.$.resolvedConfig);return this.traverseApply(U,Z),Z.finalize(X)}}get shallowMorphs(){return this.branches.reduce((U,X)=>C0(U,X.shallowMorphs),[])}get defaultShortDescription(){return this.distribute((U)=>U.defaultShortDescription,h1)}innerToJsonSchema(U){if(this.branchGroups.length===1&&this.branchGroups[0].equals(O.intrinsic.boolean))return{type:"boolean"};let X=this.branchGroups.map((q)=>q.toJsonSchemaRecurse(U));if(X.every((q)=>Object.keys(q).length===1&&K1(q,"const")))return{enum:X.map((q)=>q.const)};return{anyOf:X}}traverseAllows=(U,X)=>this.branches.some((q)=>q.traverseAllows(U,X));traverseApply=(U,X)=>{let q=[];for(let Z=0;Z<this.branches.length;Z++){if(X.pushBranch(),this.branches[Z].traverseApply(U,X),!X.hasError()){if(this.branches[Z].includesTransform)return X.queuedMorphs.push(...X.popBranch().queuedMorphs);return X.popBranch()}q.push(X.popBranch().error)}X.errorFromNodeContext({code:"union",errors:q,meta:this.meta})};traverseOptimistic=(U)=>{for(let X=0;X<this.branches.length;X++){let q=this.branches[X];if(q.traverseAllows(U)){if(q.contextFreeMorph)return q.contextFreeMorph(U);return U}}return J0};compile(U){if(!this.discriminant||this.unitBranches.length===this.branches.length&&this.branches.length===2)return this.compileIndiscriminable(U);let X=this.discriminant.optionallyChainedPropString;if(this.discriminant.kind==="domain")X=`typeof ${X} === "object" ? ${X} === null ? "null" : "object" : typeof ${X} === "function" ? "object" : typeof ${X}`;let q=this.discriminant.cases,Z=Object.keys(q),{optimistic:Q}=U;if(U.optimistic=!1,U.block(`switch(${X})`,()=>{for(let W in q){let $=q[W],_=W==="default"?W:`case ${W}`,L;if($===!0)L=Q?"data":"true";else if(Q)if($.rootApplyStrategy==="branchedOptimistic")L=U.invoke($,{kind:"Optimistic"});else if($.contextFreeMorph)L=`${U.invoke($)} ? ${d($.contextFreeMorph)}(data) : "${J0}"`;else L=`${U.invoke($)} ? data : "${J0}"`;else L=U.invoke($);U.line(`${_}: return ${L}`)}return U}),U.traversalKind==="Allows"){U.return(Q?`"${J0}"`:!1);return}let G=h1(this.discriminant.kind==="domain"?Z.map((W)=>{let $=W.slice(1,-1);return $==="function"?Y0.object:Y0[$]}):Z),Y=this.discriminant.path.map((W)=>typeof W==="symbol"?d(W):JSON.stringify(W)),J=JSON.stringify(G),H=this.discriminant.kind==="domain"?`${k5}[${X}]`:`${v5}(${X})`;U.line(`ctx.errorFromNodeContext({
170
170
  code: "predicate",
171
171
  expected: ${J},
172
172
  actual: ${H},
173
173
  relativePath: [${Y}],
174
174
  meta: ${this.compiledMeta}
175
- })`)}compileIndiscriminable(U){if(U.traversalKind==="Apply"){U.const("errors","[]");for(let X of this.branches)U.line("ctx.pushBranch()").line(U.invoke(X)).if("!ctx.hasError()",()=>U.return(X.includesTransform?"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)":"ctx.popBranch()")).line("errors.push(ctx.popBranch().error)");U.line(`ctx.errorFromNodeContext({ code: "union", errors, meta: ${this.compiledMeta} })`)}else{let{optimistic:X}=U;U.optimistic=!1;for(let q of this.branches)U.if(`${U.invoke(q)}`,()=>U.return(X?q.contextFreeMorph?`${d(q.contextFreeMorph)}(data)`:"data":!0));U.return(X?`"${J0}"`:!1)}}get nestableExpression(){return this.isBoolean?"boolean":`(${this.expression})`}discriminate(){if(this.branches.length<2||this.isCyclic)return null;if(this.unitBranches.length===this.branches.length){let Q=S(this.unitBranches,(G,Y)=>[`${Y.rawIn.serializedValue}`,Y.hasKind("morph")?Y:!0]);return{kind:"unit",path:[],optionallyChainedPropString:"data",cases:Q}}let U=[];for(let Q=0;Q<this.branches.length-1;Q++){let G=this.branches[Q];for(let Y=Q+1;Y<this.branches.length;Y++){let J=this.branches[Y],H=$0(G.rawIn,J.rawIn,G.$);if(!(H instanceof T))continue;for(let W of H){if(!W.kind||W.optional)continue;let $,_;if(W.kind==="domain"){let{l:A,r:V}=W;$=`"${typeof A==="string"?A:A.domain}"`,_=`"${typeof V==="string"?V:V.domain}"`}else if(W.kind==="unit")$=W.l.serializedValue,_=W.r.serializedValue;else continue;let L=U.find((A)=>y0(A.path,W.path)&&A.kind===W.kind);if(!L)U.push({kind:W.kind,cases:{[$]:{branchIndices:[Q],condition:W.l},[_]:{branchIndices:[Y],condition:W.r}},path:W.path});else{if(L.cases[$])L.cases[$].branchIndices=C0(L.cases[$].branchIndices,Q);else L.cases[$]??={branchIndices:[Q],condition:W.l};if(L.cases[_])L.cases[_].branchIndices=C0(L.cases[_].branchIndices,Y);else L.cases[_]??={branchIndices:[Y],condition:W.r}}}}}let X=this.ordered?S5(U,this.branches):U;if(!X.length)return null;let q=N5(X,this),Z={};for(let Q in q.best.cases){let G=C5(q,Q);if(G===null){Z[Q]=!0;continue}if(G.length===this.branches.length)return null;if(this.ordered)G.sort((H,W)=>H.originalIndex-W.originalIndex);let Y=G.map((H)=>H.branch),J=Y.length===1?Y[0]:this.$.node("union",this.ordered?{branches:Y,ordered:!0}:Y);Object.assign(this.referencesById,J.referencesById),Z[Q]=J}if(q.defaultEntries.length){let Q=q.defaultEntries.map((G)=>G.branch);Z.default=this.$.node("union",this.ordered?{branches:Q,ordered:!0}:Q,{prereduced:!0}),Object.assign(this.referencesById,Z.default.referencesById)}return Object.assign(q.location,{cases:Z})}}var N5=(U,X)=>{let Z=U.sort((Y,J)=>Y.path.length===J.path.length?Object.keys(J.cases).length-Object.keys(Y.cases).length:Y.path.length-J.path.length)[0],Q={kind:Z.kind,path:Z.path,optionallyChainedPropString:iq(Z.path)},G=X.branches.map((Y,J)=>({originalIndex:J,branch:Y}));return{best:Z,location:Q,defaultEntries:G,node:X}},C5=(U,X)=>{let q=U.best.cases[X],Z=E5(q.condition,U.location.path,U.node.$),Q=[],G=[];for(let Y=0;Y<U.defaultEntries.length;Y++){let J=U.defaultEntries[Y];if(q.branchIndices.includes(J.originalIndex)){let H=lq(U.node.branches[J.originalIndex],U.location);if(H===null)Q=null;else Q?.push({originalIndex:J.originalIndex,branch:H})}else if(J.branch.hasKind("alias")&&Z.hasKind("domain")&&Z.domain==="object")Q?.push(J);else{if(J.branch.rawIn.overlaps(Z)){let H=lq(J.branch,U.location);Q?.push({originalIndex:J.originalIndex,branch:H})}G.push(J)}}return U.defaultEntries=G,Q},S5=(U,X)=>{return U.filter((Z)=>{let Q=Object.values(Z.cases).map((G)=>G.branchIndices);for(let G=0;G<Q.length-1;G++){let Y=Q[G];for(let J=G+1;J<Q.length;J++){let H=Q[J];for(let W of Y)for(let $ of H)if(W>$){if(X[W].overlaps(X[$]))return!1}}}return!0})},E5=(U,X,q)=>{let Z=U==="undefined"?q.node("unit",{unit:void 0}):U==="null"?q.node("unit",{unit:null}):U==="boolean"?q.units([!0,!1]):U;for(let Q=X.length-1;Q>=0;Q--){let G=X[Q];Z=q.node("intersection",typeof G==="number"?{proto:"Array",sequence:[...DX(G).map((Y)=>({})),Z]}:{domain:"object",required:[{key:G,value:Z}]})}return Z},iq=(U)=>U.reduce((X,q)=>X+i4(q,!0),"data"),j5=d(PX),b5=d(E),V9={implementation:K5,Node:cq},f5=(U)=>({kind:U.kind,path:U.path.map((X)=>typeof X==="string"?X:M0(X)),cases:S(U.cases,(X,q)=>[X,q===!0?q:q.hasKind("union")&&q.discriminantJson?q.discriminantJson:q.json])}),g5={delimiter:" | ",finalDelimiter:" | "},y5=(U)=>h1(U,g5),h1=(U,X)=>{let q=X?.delimiter??", ",Z=X?.finalDelimiter??" or ";if(U.length===0)return"never";if(U.length===1)return U[0];if(U.length===2&&U[0]==="false"&&U[1]==="true"||U[0]==="true"&&U[1]==="false")return"boolean";let Q={},G=U.filter((J)=>Q[J]?!1:Q[J]=!0),Y=G.pop();return`${G.join(q)}${G.length?Z:""}${Y}`},T9=(U,X,q)=>{let Z=X.map(()=>[]);for(let G=0;G<U.length;G++){let Y={};for(let J=0;J<X.length;J++){if(Z[J]===null)continue;if(U[G].equals(X[J])){Z[J]=null,Y={};break}let H=u(U[G],X[J],q);if(H instanceof T)continue;if(H.equals(U[G])){Z[J].push(U[G]),Y={};break}if(H.equals(X[J]))Z[J]=null;else Y[J]=H}for(let J in Y)Z[J][G]=Y[J]}let Q=Z.flatMap((G,Y)=>G?.flatMap((J)=>J.branches)??X[Y]);return Q.length===0?T.init("union",U,X):Q},k5=({branches:U,ordered:X})=>{if(U.length<2)return U;let q=U.map(()=>!0);for(let Z=0;Z<U.length;Z++)for(let Q=Z+1;Q<U.length&&q[Z]&&q[Q];Q++){if(U[Z].equals(U[Q])){q[Q]=!1;continue}let G=$0(U[Z].rawIn,U[Q].rawIn,U[0].$);if(G instanceof T)continue;if(!X)v5(U[Z],U[Q]);if(G.equals(U[Z].rawIn))q[Z]=!!X;else if(G.equals(U[Q].rawIn))q[Q]=!1}return U.filter((Z,Q)=>q[Q])},v5=(U,X)=>{if(!U.includesTransform&&!X.includesTransform)return;if(!y0(U.shallowMorphs,X.shallowMorphs))F(dq(U.expression,X.expression));if(!y0(U.flatMorphs,X.flatMorphs,{isEqual:(q,Z)=>q.propString===Z.propString&&(q.node.hasKind("morph")&&Z.node.hasKind("morph")?q.node.hasEqualMorphs(Z.node):q.node.hasKind("intersection")&&Z.node.hasKind("intersection")?q.node.structure?.structuralMorphRef===Z.node.structure?.structuralMorphRef:!1)}))F(dq(U.expression,X.expression))},lq=(U,X)=>U.transform((q,Z)=>{if(q==="domain"||q==="unit")return null;return Z},{shouldTransform:(q,Z)=>{let Q=iq(Z.path);if(!X.optionallyChainedPropString.startsWith(Q))return!1;if(q.hasKind("domain")&&q.domain==="object")return!0;if((q.hasKind("domain")||X.kind==="unit")&&Q===X.optionallyChainedPropString)return!0;return q.children.length!==0&&q.kind!=="index"}}),dq=(U,X)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
175
+ })`)}compileIndiscriminable(U){if(U.traversalKind==="Apply"){U.const("errors","[]");for(let X of this.branches)U.line("ctx.pushBranch()").line(U.invoke(X)).if("!ctx.hasError()",()=>U.return(X.includesTransform?"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)":"ctx.popBranch()")).line("errors.push(ctx.popBranch().error)");U.line(`ctx.errorFromNodeContext({ code: "union", errors, meta: ${this.compiledMeta} })`)}else{let{optimistic:X}=U;U.optimistic=!1;for(let q of this.branches)U.if(`${U.invoke(q)}`,()=>U.return(X?q.contextFreeMorph?`${d(q.contextFreeMorph)}(data)`:"data":!0));U.return(X?`"${J0}"`:!1)}}get nestableExpression(){return this.isBoolean?"boolean":`(${this.expression})`}discriminate(){if(this.branches.length<2||this.isCyclic)return null;if(this.unitBranches.length===this.branches.length){let Q=S(this.unitBranches,(G,Y)=>[`${Y.rawIn.serializedValue}`,Y.hasKind("morph")?Y:!0]);return{kind:"unit",path:[],optionallyChainedPropString:"data",cases:Q}}let U=[];for(let Q=0;Q<this.branches.length-1;Q++){let G=this.branches[Q];for(let Y=Q+1;Y<this.branches.length;Y++){let J=this.branches[Y],H=$0(G.rawIn,J.rawIn,G.$);if(!(H instanceof T))continue;for(let W of H){if(!W.kind||W.optional)continue;let $,_;if(W.kind==="domain"){let{l:A,r:V}=W;$=`"${typeof A==="string"?A:A.domain}"`,_=`"${typeof V==="string"?V:V.domain}"`}else if(W.kind==="unit")$=W.l.serializedValue,_=W.r.serializedValue;else continue;let L=U.find((A)=>y0(A.path,W.path)&&A.kind===W.kind);if(!L)U.push({kind:W.kind,cases:{[$]:{branchIndices:[Q],condition:W.l},[_]:{branchIndices:[Y],condition:W.r}},path:W.path});else{if(L.cases[$])L.cases[$].branchIndices=C0(L.cases[$].branchIndices,Q);else L.cases[$]??={branchIndices:[Q],condition:W.l};if(L.cases[_])L.cases[_].branchIndices=C0(L.cases[_].branchIndices,Y);else L.cases[_]??={branchIndices:[Y],condition:W.r}}}}}let X=this.ordered?g5(U,this.branches):U;if(!X.length)return null;let q=b5(X,this),Z={};for(let Q in q.best.cases){let G=f5(q,Q);if(G===null){Z[Q]=!0;continue}if(G.length===this.branches.length)return null;if(this.ordered)G.sort((H,W)=>H.originalIndex-W.originalIndex);let Y=G.map((H)=>H.branch),J=Y.length===1?Y[0]:this.$.node("union",this.ordered?{branches:Y,ordered:!0}:Y);Object.assign(this.referencesById,J.referencesById),Z[Q]=J}if(q.defaultEntries.length){let Q=q.defaultEntries.map((G)=>G.branch);Z.default=this.$.node("union",this.ordered?{branches:Q,ordered:!0}:Q,{prereduced:!0}),Object.assign(this.referencesById,Z.default.referencesById)}return Object.assign(q.location,{cases:Z})}}var b5=(U,X)=>{let Z=U.sort((Y,J)=>Y.path.length===J.path.length?Object.keys(J.cases).length-Object.keys(Y.cases).length:Y.path.length-J.path.length)[0],Q={kind:Z.kind,path:Z.path,optionallyChainedPropString:sq(Z.path)},G=X.branches.map((Y,J)=>({originalIndex:J,branch:Y}));return{best:Z,location:Q,defaultEntries:G,node:X}},f5=(U,X)=>{let q=U.best.cases[X],Z=y5(q.condition,U.location.path,U.node.$),Q=[],G=[];for(let Y=0;Y<U.defaultEntries.length;Y++){let J=U.defaultEntries[Y];if(q.branchIndices.includes(J.originalIndex)){let H=dq(U.node.branches[J.originalIndex],U.location);if(H===null)Q=null;else Q?.push({originalIndex:J.originalIndex,branch:H})}else if(J.branch.hasKind("alias")&&Z.hasKind("domain")&&Z.domain==="object")Q?.push(J);else{if(J.branch.rawIn.overlaps(Z)){let H=dq(J.branch,U.location);Q?.push({originalIndex:J.originalIndex,branch:H})}G.push(J)}}return U.defaultEntries=G,Q},g5=(U,X)=>{return U.filter((Z)=>{let Q=Object.values(Z.cases).map((G)=>G.branchIndices);for(let G=0;G<Q.length-1;G++){let Y=Q[G];for(let J=G+1;J<Q.length;J++){let H=Q[J];for(let W of Y)for(let $ of H)if(W>$){if(X[W].overlaps(X[$]))return!1}}}return!0})},y5=(U,X,q)=>{let Z=U==="undefined"?q.node("unit",{unit:void 0}):U==="null"?q.node("unit",{unit:null}):U==="boolean"?q.units([!0,!1]):U;for(let Q=X.length-1;Q>=0;Q--){let G=X[Q];Z=q.node("intersection",typeof G==="number"?{proto:"Array",sequence:[...MX(G).map((Y)=>({})),Z]}:{domain:"object",required:[{key:G,value:Z}]})}return Z},sq=(U)=>U.reduce((X,q)=>X+i4(q,!0),"data"),k5=d(IX),v5=d(E),V9={implementation:j5,Node:iq},h5=(U)=>({kind:U.kind,path:U.path.map((X)=>typeof X==="string"?X:M0(X)),cases:S(U.cases,(X,q)=>[X,q===!0?q:q.hasKind("union")&&q.discriminantJson?q.discriminantJson:q.json])}),x5={delimiter:" | ",finalDelimiter:" | "},u5=(U)=>h1(U,x5),h1=(U,X)=>{let q=X?.delimiter??", ",Z=X?.finalDelimiter??" or ";if(U.length===0)return"never";if(U.length===1)return U[0];if(U.length===2&&U[0]==="false"&&U[1]==="true"||U[0]==="true"&&U[1]==="false")return"boolean";let Q={},G=U.filter((J)=>Q[J]?!1:Q[J]=!0),Y=G.pop();return`${G.join(q)}${G.length?Z:""}${Y}`},T9=(U,X,q)=>{let Z=X.map(()=>[]);for(let G=0;G<U.length;G++){let Y={};for(let J=0;J<X.length;J++){if(Z[J]===null)continue;if(U[G].equals(X[J])){Z[J]=null,Y={};break}let H=u(U[G],X[J],q);if(H instanceof T)continue;if(H.equals(U[G])){Z[J].push(U[G]),Y={};break}if(H.equals(X[J]))Z[J]=null;else Y[J]=H}for(let J in Y)Z[J][G]=Y[J]}let Q=Z.flatMap((G,Y)=>G?.flatMap((J)=>J.branches)??X[Y]);return Q.length===0?T.init("union",U,X):Q},m5=({branches:U,ordered:X})=>{if(U.length<2)return U;let q=U.map(()=>!0);for(let Z=0;Z<U.length;Z++)for(let Q=Z+1;Q<U.length&&q[Z]&&q[Q];Q++){if(U[Z].equals(U[Q])){q[Q]=!1;continue}let G=$0(U[Z].rawIn,U[Q].rawIn,U[0].$);if(G instanceof T)continue;if(!X)p5(U[Z],U[Q]);if(G.equals(U[Z].rawIn))q[Z]=!!X;else if(G.equals(U[Q].rawIn))q[Q]=!1}return U.filter((Z,Q)=>q[Q])},p5=(U,X)=>{if(!U.includesTransform&&!X.includesTransform)return;if(!y0(U.shallowMorphs,X.shallowMorphs))F(cq(U.expression,X.expression));if(!y0(U.flatMorphs,X.flatMorphs,{isEqual:(q,Z)=>q.propString===Z.propString&&(q.node.hasKind("morph")&&Z.node.hasKind("morph")?q.node.hasEqualMorphs(Z.node):q.node.hasKind("intersection")&&Z.node.hasKind("intersection")?q.node.structure?.structuralMorphRef===Z.node.structure?.structuralMorphRef:!1)}))F(cq(U.expression,X.expression))},dq=(U,X)=>U.transform((q,Z)=>{if(q==="domain"||q==="unit")return null;return Z},{shouldTransform:(q,Z)=>{let Q=sq(Z.path);if(!X.optionallyChainedPropString.startsWith(Q))return!1;if(q.hasKind("domain")&&q.domain==="object")return!0;if((q.hasKind("domain")||X.kind==="unit")&&Q===X.optionallyChainedPropString)return!0;return q.children.length!==0&&q.kind!=="index"}}),cq=(U,X)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
176
176
  Left: ${U}
177
- Right: ${X}`,h5=(U,X)=>`The intersection of two ordered unions is indeterminate:
177
+ Right: ${X}`,l5=(U,X)=>`The intersection of two ordered unions is indeterminate:
178
178
  Left: ${U}
179
- Right: ${X}`;var x5=j({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:(U)=>U instanceof Date?U.toISOString():A0(U)}},normalize:(U)=>U,defaults:{description:(U)=>E(U.unit),problem:({expected:U,actual:X})=>`${U===X?`must be reference equal to ${U} (serialized to the same value)`:`must be ${U} (was ${X})`}`},intersections:{unit:(U,X)=>T.init("unit",U,X),...E0("unit",(U,X)=>{if(X.allows(U.unit))return U;let q=X.hasKind("intersection")?X.basis:X;if(q){let Z=q.hasKind("domain")?q:O.intrinsic.object;if(U.domain!==Z.domain){let Q=U.domain==="undefined"||U.domain==="null"||U.domain==="boolean"?U.domain:O.intrinsic[U.domain];return T.init("domain",Q,Z)}}return T.init("assignability",U,X.hasKind("intersection")?X.children.find((Z)=>!Z.allows(U.unit)):X)})}});class oq extends L1{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=sq(this.unit,this.serializedValue);compiledNegation=sq(this.unit,this.serializedValue,"negated");expression=E(this.unit);domain=r(this.unit);get defaultShortDescription(){return this.domain==="object"?Y0.object:this.description}innerToJsonSchema(U){return this.unit===null?{type:"null"}:O.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:U.fallback.unit({code:"unit",base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?(U)=>U instanceof Date&&U.toISOString()===this.compiledValue:Number.isNaN(this.unit)?(U)=>Number.isNaN(U):(U)=>U===this.unit}var R9={implementation:x5,Node:oq},sq=(U,X,q)=>{if(U instanceof Date){let Z=`data instanceof Date && data.toISOString() === ${X}`;return q?`!(${Z})`:Z}if(Number.isNaN(U))return`${q?"!":""}Number.isNaN(data)`;return`data ${q?"!":"="}== ${X}`};var u5=j({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:(U,X)=>{let q=X.$.parseSchema(U);if(!q.extends(O.intrinsic.key))return F(p5(q.expression));let Z=q.branches.filter((Q)=>Q.hasKind("unit"));if(Z.length)return F(m5(Z.map((Q)=>E(Q.unit))));return q}},value:{child:!0,parse:(U,X)=>X.$.parseSchema(U)}},normalize:(U)=>U,defaults:{description:(U)=>`[${U.signature.expression}]: ${U.value.description}`},intersections:{index:(U,X,q)=>{if(U.signature.equals(X.signature)){let Z=u(U.value,X.value,q),Q=Z instanceof T?O.intrinsic.never.internal:Z;return q.$.node("index",{signature:U.signature,value:Q})}if(U.signature.extends(X.signature)&&U.value.subsumes(X.value))return X;if(X.signature.extends(U.signature)&&X.value.subsumes(U.value))return U;return null}}});class rq extends O0{impliedBasis=O.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=g(this.value.flatRefs.map((U)=>P0([this.signature,...U.path],U.node)),P0([this.signature],this.value));traverseAllows=(U,X)=>J1(U).every((q)=>{if(this.signature.traverseAllows(q[0],X))return _0(q[0],()=>this.value.traverseAllows(q[1],X),X);return!0});traverseApply=(U,X)=>{for(let q of J1(U))if(this.signature.traverseAllows(q[0],X))_0(q[0],()=>this.value.traverseApply(q[1],X),X)};_transform(U,X){X.path.push(this.signature);let q=super._transform(U,X);return X.path.pop(),q}compile(){}}var D9={implementation:u5,Node:rq},m5=(U)=>`Index keys ${U.join(", ")} should be specified as named props.`,p5=(U)=>`Indexed key definition '${U}' must be a string or symbol`;var l5=j({kind:"required",hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(U,X)=>X.$.parseSchema(U)}},normalize:(U)=>U,defaults:{description:(U)=>`${U.compiledKey}: ${U.value.description}`,expected:(U)=>U.missingValueDescription,actual:()=>"missing"},intersections:{required:w2,optional:w2}});class nq extends P2{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=s0(this.errorContext)}var M9={implementation:l5,Node:nq};var d5=j({kind:"sequence",hasAssociatedError:!1,collapsibleKey:"variadic",keys:{prefix:{child:!0,parse:(U,X)=>{if(U.length===0)return;return U.map((q)=>X.$.parseSchema(q))}},optionals:{child:!0,parse:(U,X)=>{if(U.length===0)return;return U.map((q)=>X.$.parseSchema(q))}},defaultables:{child:(U)=>U.map((X)=>X[0]),parse:(U,X)=>{if(U.length===0)return;return U.map((q)=>{let Z=X.$.parseSchema(q[0]);return K2(Z,q[1],null),[Z,q[1]]})},serialize:(U)=>U.map((X)=>[X[0].collapsibleJson,A0(X[1])]),reduceIo:(U,X,q)=>{if(U==="in"){X.optionals=q.map((Z)=>Z[0].rawIn);return}X.prefix=q.map((Z)=>Z[0].rawOut);return}},variadic:{child:!0,parse:(U,X)=>X.$.parseSchema(U,X)},minVariadicLength:{parse:(U)=>U===0?void 0:U},postfix:{child:!0,parse:(U,X)=>{if(U.length===0)return;return U.map((q)=>X.$.parseSchema(q))}}},normalize:(U)=>{if(typeof U==="string")return{variadic:U};if("variadic"in U||"prefix"in U||"defaultables"in U||"optionals"in U||"postfix"in U||"minVariadicLength"in U){if(U.postfix?.length){if(!U.variadic)return F(o5);if(U.optionals?.length||U.defaultables?.length)return F(P9)}if(U.minVariadicLength&&!U.variadic)return F("minVariadicLength may not be specified without a variadic element");return U}return{variadic:U}},reduce:(U,X)=>{let q=U.minVariadicLength??0,Z=U.prefix?.slice()??[],Q=U.defaultables?.slice()??[],G=U.optionals?.slice()??[],Y=U.postfix?.slice()??[];if(U.variadic){while(G[G.length-1]?.equals(U.variadic))G.pop();if(G.length===0&&Q.length===0)while(Z[Z.length-1]?.equals(U.variadic))Z.pop(),q++;while(Y[0]?.equals(U.variadic))Y.shift(),q++}else if(G.length===0&&Q.length===0)Z.push(...Y.splice(0));if(q!==U.minVariadicLength||U.prefix&&U.prefix.length!==Z.length)return X.node("sequence",{...U,prefix:Z,defaultables:Q,optionals:G,postfix:Y,minVariadicLength:q},{prereduced:!0})},defaults:{description:(U)=>{if(U.isVariadicOnly)return`${U.variadic.nestableExpression}[]`;return`[${U.tuple.map((q)=>q.kind==="defaultables"?`${q.node.nestableExpression} = ${E(q.default)}`:q.kind==="optionals"?`${q.node.nestableExpression}?`:q.kind==="variadic"?`...${q.node.nestableExpression}[]`:q.node.expression).join(", ")}]`}},intersections:{sequence:(U,X,q)=>{let Z=E2({l:U.tuple,r:X.tuple,disjoint:new T,result:[],fixedVariants:[],ctx:q}),Q=Z.disjoint.length===0?[Z,...Z.fixedVariants]:Z.fixedVariants;return Q.length===0?Z.disjoint:Q.length===1?q.$.node("sequence",aq(Q[0].result)):q.$.node("union",Q.map((G)=>({proto:Array,sequence:aq(G.result)})))}}});class eq extends O0{impliedBasis=O.intrinsic.Array.internal;tuple=s5(this.inner);prefixLength=this.prefix?.length??0;defaultablesLength=this.defaultables?.length??0;optionalsLength=this.optionals?.length??0;postfixLength=this.postfix?.length??0;defaultablesAndOptionals=[];prevariadic=this.tuple.filter((U)=>{if(U.kind==="defaultables"||U.kind==="optionals")return this.defaultablesAndOptionals.push(U.node),!0;return U.kind==="prefix"});variadicOrPostfix=g0(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return a4(this.flatRefs,this.prevariadic.flatMap((U,X)=>g(U.node.flatRefs.map((q)=>P0([`${X}`,...q.path],q.node)),P0([`${X}`],U.node)))),a4(this.flatRefs,this.variadicOrPostfix.flatMap((U)=>g(U.flatRefs.map((X)=>P0([O.intrinsic.nonNegativeIntegerString.internal,...X.path],X.node)),P0([O.intrinsic.nonNegativeIntegerString.internal],U)))),this.flatRefs}isVariadicOnly=this.prevariadic.length+this.postfixLength===0;minVariadicLength=this.inner.minVariadicLength??0;minLength=this.prefixLength+this.minVariadicLength+this.postfixLength;minLengthNode=this.minLength===0?null:this.$.node("minLength",this.minLength);maxLength=this.variadic?null:this.tuple.length;maxLengthNode=this.maxLength===null?null:this.$.node("maxLength",this.maxLength);impliedSiblings=this.minLengthNode?this.maxLengthNode?[this.minLengthNode,this.maxLengthNode]:[this.minLengthNode]:this.maxLengthNode?[this.maxLengthNode]:[];defaultValueMorphs=i5(this);defaultValueMorphsReference=this.defaultValueMorphs.length?d(this.defaultValueMorphs):void 0;elementAtIndex(U,X){if(X<this.prevariadic.length)return this.tuple[X];let q=U.length-this.postfixLength;if(X>=q)return{kind:"postfix",node:this.postfix[X-q]};return{kind:"variadic",node:this.variadic??y(`Unexpected attempt to access index ${X} on ${this}`)}}traverseAllows=(U,X)=>{for(let q=0;q<U.length;q++)if(!this.elementAtIndex(U,q).node.traverseAllows(U[q],X))return!1;return!0};traverseApply=(U,X)=>{let q=0;for(;q<U.length;q++)_0(q,()=>this.elementAtIndex(U,q).node.traverseApply(U[q],X),X)};get element(){return this.cacheGetter("element",this.$.node("union",this.children))}compile(U){if(this.prefix)for(let[X,q]of this.prefix.entries())U.traverseKey(`${X}`,`data[${X}]`,q);for(let[X,q]of this.defaultablesAndOptionals.entries()){let Z=`${X+this.prefixLength}`;U.if(`${Z} >= data.length`,()=>U.traversalKind==="Allows"?U.return(!0):U.return()),U.traverseKey(Z,`data[${Z}]`,q)}if(this.variadic){if(this.postfix)U.const("firstPostfixIndex",`data.length${this.postfix?`- ${this.postfix.length}`:""}`);if(U.for(`i < ${this.postfix?"firstPostfixIndex":"data.length"}`,()=>U.traverseKey("i","data[i]",this.variadic),this.prevariadic.length),this.postfix)for(let[X,q]of this.postfix.entries()){let Z=`firstPostfixIndex + ${X}`;U.traverseKey(Z,`data[${Z}]`,q)}}if(U.traversalKind==="Allows")U.return(!0)}_transform(U,X){X.path.push(O.intrinsic.nonNegativeIntegerString.internal);let q=super._transform(U,X);return X.path.pop(),q}expression=this.description;reduceJsonSchema(U,X){let q=X.target==="draft-07";if(this.prevariadic.length){let Z=this.prevariadic.map((Q)=>{let G=Q.node.toJsonSchemaRecurse(X);if(Q.kind==="defaultables"){let Y=typeof Q.default==="function"?Q.default():Q.default;G.default=O.intrinsic.jsonData.allows(Y)?Y:X.fallback.defaultValue({code:"defaultValue",base:G,value:Y})}return G});if(q)U.items=Z;else U.prefixItems=Z}if(this.minLength)U.minItems=this.minLength;if(this.variadic){let Z=this.variadic.toJsonSchemaRecurse(X);if(q&&this.prevariadic.length)U.additionalItems=Z;else U.items=Z;if(this.maxLength)U.maxItems=this.maxLength;if(this.postfix){let Q=this.postfix.map((G)=>G.toJsonSchemaRecurse(X));U=X.fallback.arrayPostfix({code:"arrayPostfix",base:U,elements:Q})}}else{if(q)U.additionalItems=!1;else U.items=!1;delete U.maxItems}return U}}var c5={},i5=(U)=>{if(!U.defaultables)return[];let X=[],q="[",Z=U.prefixLength+U.defaultablesLength-1;for(let Q=U.prefixLength;Q<=Z;Q++){let[G,Y]=U.defaultables[Q-U.prefixLength];X.push(A9(Q,G,Y)),q+=`${Q}: ${G.id} = ${A0(Y)}, `}return q+="]",c5[q]??=X},w9={implementation:d5,Node:eq},s5=(U)=>{let X=[];if(U.prefix)for(let q of U.prefix)X.push({kind:"prefix",node:q});if(U.defaultables)for(let[q,Z]of U.defaultables)X.push({kind:"defaultables",node:q,default:Z});if(U.optionals)for(let q of U.optionals)X.push({kind:"optionals",node:q});if(U.variadic)X.push({kind:"variadic",node:U.variadic});if(U.postfix)for(let q of U.postfix)X.push({kind:"postfix",node:q});return X},aq=(U)=>U.reduce((X,q)=>{if(q.kind==="variadic")X.variadic=q.node;else if(q.kind==="defaultables")X.defaultables=g(X.defaultables,[[q.node,q.default]]);else X[q.kind]=g(X[q.kind],q.node);return X},{}),P9="A postfix required element cannot follow an optional or defaultable element",o5="A postfix element requires a variadic element",E2=(U)=>{let[X,...q]=U.l,[Z,...Q]=U.r;if(!X||!Z)return U;let G=q[q.length-1]?.kind==="postfix",Y=Q[Q.length-1]?.kind==="postfix",J=X.kind==="prefix"||Z.kind==="prefix"?"prefix":X.kind==="postfix"||Z.kind==="postfix"?"postfix":X.kind==="variadic"&&Z.kind==="variadic"?"variadic":G||Y?"prefix":X.kind==="defaultables"||Z.kind==="defaultables"?"defaultables":"optionals";if(X.kind==="prefix"&&Z.kind==="variadic"&&Y){let _=E2({...U,fixedVariants:[],r:Q.map((L)=>({...L,kind:"prefix"}))});if(_.disjoint.length===0)U.fixedVariants.push(_)}else if(Z.kind==="prefix"&&X.kind==="variadic"&&G){let _=E2({...U,fixedVariants:[],l:q.map((L)=>({...L,kind:"prefix"}))});if(_.disjoint.length===0)U.fixedVariants.push(_)}let H=u(X.node,Z.node,U.ctx);if(H instanceof T)if(J==="prefix"||J==="postfix")U.disjoint.push(...H.withPrefixKey(J==="prefix"?U.result.length:`-${q.length+1}`,tq(X)&&tq(Z)?"required":"optional")),U.result=[...U.result,{kind:J,node:O.intrinsic.never.internal}];else if(J==="optionals"||J==="defaultables")return U;else return E2({...U,fixedVariants:[],l:q.map((_)=>({..._,kind:"prefix"})),r:q.map((_)=>({..._,kind:"prefix"}))});else if(J==="defaultables"){if(X.kind==="defaultables"&&Z.kind==="defaultables"&&X.default!==Z.default)F(F9(X.default,Z.default));U.result=[...U.result,{kind:J,node:H,default:X.kind==="defaultables"?X.default:Z.kind==="defaultables"?Z.default:y(`Unexpected defaultable intersection from ${X.kind} and ${Z.kind} elements.`)}]}else U.result=[...U.result,{kind:J,node:H}];let W=U.l.length,$=U.r.length;if(X.kind!=="variadic"||W>=$&&(Z.kind==="variadic"||$===1))U.l=q;if(Z.kind!=="variadic"||$>=W&&(X.kind==="variadic"||W===1))U.r=Q;return E2(U)},tq=(U)=>U.kind==="prefix"||U.kind==="postfix";var ZZ=(U)=>(X)=>{if(X.props.length||X.index){let q=X.index?.map((Q)=>Q[U])??[];for(let Q of X.props)q.push(Q[U]);if(X.undeclared)q.push(`+ (undeclared): ${X.undeclared}`);let Z=`{ ${q.join(", ")} }`;return X.sequence?`${Z} & ${X.sequence.description}`:Z}return X.sequence?.description??"{}"},r5=ZZ("description"),n5=ZZ("expression"),UZ=(U,X,q)=>{let Z=U.required?"required":"optional";if(!X.signature.allows(U.key))return null;let Q=$0(U.value,X.value,q);if(Q instanceof T)return Z==="optional"?q.node("optional",{key:U.key,value:O.intrinsic.never.internal}):Q.withPrefixKey(U.key,U.kind);return null},a5=j({kind:"structure",hasAssociatedError:!1,normalize:(U)=>U,applyConfig:(U,X)=>{if(!U.undeclared&&X.onUndeclaredKey!=="ignore")return{...U,undeclared:X.onUndeclaredKey};return U},keys:{required:{child:!0,parse:q0("required"),reduceIo:(U,X,q)=>{X.required=g(X.required,q.map((Z)=>U==="in"?Z.rawIn:Z.rawOut));return}},optional:{child:!0,parse:q0("optional"),reduceIo:(U,X,q)=>{if(U==="in"){X.optional=q.map((Z)=>Z.rawIn);return}for(let Z of q)X[Z.outProp.kind]=g(X[Z.outProp.kind],Z.outProp.rawOut)}},index:{child:!0,parse:q0("index")},sequence:{child:!0,parse:q0("sequence")},undeclared:{parse:(U)=>U==="ignore"?void 0:U,reduceIo:(U,X,q)=>{if(q==="reject"){X.undeclared="reject";return}if(U==="in")delete X.undeclared;else X.undeclared="reject"}}},defaults:{description:r5},intersections:{structure:(U,X,q)=>{let Z={...U.inner},Q={...X.inner},G=new T;if(U.undeclared){let H=U.keyof();for(let W of X.requiredKeys)if(!H.allows(W))G.add("presence",O.intrinsic.never.internal,X.propsByKey[W].value,{path:[W]});if(Q.optional)Q.optional=Q.optional.filter((W)=>H.allows(W.key));if(Q.index)Q.index=Q.index.flatMap((W)=>{if(W.signature.extends(H))return W;let $=$0(H,W.signature,q.$);if($ instanceof T)return[];let _=K6($,W.value,q.$);if(_.required)Q.required=g0(Q.required,_.required);if(_.optional)Q.optional=g0(Q.optional,_.optional);return _.index??[]})}if(X.undeclared){let H=X.keyof();for(let W of U.requiredKeys)if(!H.allows(W))G.add("presence",U.propsByKey[W].value,O.intrinsic.never.internal,{path:[W]});if(Z.optional)Z.optional=Z.optional.filter((W)=>H.allows(W.key));if(Z.index)Z.index=Z.index.flatMap((W)=>{if(W.signature.extends(H))return W;let $=$0(H,W.signature,q.$);if($ instanceof T)return[];let _=K6($,W.value,q.$);if(_.required)Z.required=g0(Z.required,_.required);if(_.optional)Z.optional=g0(Z.optional,_.optional);return _.index??[]})}let Y={};if(U.undeclared||X.undeclared)Y.undeclared=U.undeclared==="reject"||X.undeclared==="reject"?"reject":"delete";let J=f1({kind:"structure",baseInner:Y,l:g1(Z),r:g1(Q),roots:[],ctx:q});if(J instanceof T)G.push(...J);if(G.length)return G;return J}},reduce:(U,X)=>{if(!U.required&&!U.optional)return;let q={},Z=!1,Q=U.optional?[...U.optional]:[];if(U.required)for(let G=0;G<U.required.length;G++){let Y=U.required[G];if(Y.key in q)F(qZ(Y.key));if(q[Y.key]=!0,U.index)for(let J of U.index){let H=UZ(Y,J,X);if(H instanceof T)return H}}if(U.optional)for(let G=0;G<U.optional.length;G++){let Y=U.optional[G];if(Y.key in q)F(qZ(Y.key));if(q[Y.key]=!0,U.index)for(let J of U.index){let H=UZ(Y,J,X);if(H instanceof T)return H;if(H!==null)Q[G]=H,Z=!0}}if(Z)return X.node("structure",{...U,optional:Q},{prereduced:!0})}});class QZ extends O0{impliedBasis=O.intrinsic.object.internal;impliedSiblings=this.children.flatMap((U)=>U.impliedSiblings??[]);props=g0(this.required,this.optional);propsByKey=S(this.props,(U,X)=>[X.key,X]);propsByKeyReference=d(this.propsByKey);expression=n5(this);requiredKeys=this.required?.map((U)=>U.key)??[];optionalKeys=this.optional?.map((U)=>U.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let U=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:X}of this.index)U=U.concat(X.branches);return this._keyof=this.$.node("union",U)}map(U){return this.$.node("structure",this.props.flatMap(U).reduce((X,q)=>{let Z=this.propsByKey[q.key];if(x(q)){if(q.kind!=="required"&&q.kind!=="optional")return F(`Map result must have kind "required" or "optional" (was ${q.kind})`);return X[q.kind]=g(X[q.kind],q),X}let Q=q.kind??Z?.kind??"required",G=S(q,(Y,J)=>(Y in I2.implementation.keys)?[Y,J]:[]);return X[Q]=g(X[Q],this.$.node(Q,G)),X},{}))}assertHasKeys(U){let X=U.filter((q)=>!N2(q,this.keyof()));if(X.length)return F(XZ(this.expression,X))}get(U,...X){let q,Z=!1,Q=X7(U);if((typeof Q==="string"||typeof Q==="symbol")&&this.propsByKey[Q])q=this.propsByKey[Q].value,Z=this.propsByKey[Q].required;if(this.index){for(let Y of this.index)if(N2(Q,Y.signature))q=q?.and(Y.value)??Y.value}if(this.sequence&&N2(Q,O.intrinsic.nonNegativeIntegerString))if(M(Q,"root")){if(this.sequence.variadic)q=q?.and(this.sequence.element)??this.sequence.element}else{let Y=Number.parseInt(Q);if(Y<this.sequence.prevariadic.length){let J=this.sequence.prevariadic[Y].node;q=q?.and(J)??J,Z||=Y<this.sequence.prefixLength}else if(this.sequence.variadic){let J=this.$.node("union",this.sequence.variadicOrPostfix);q=q?.and(J)??J}}if(!q){if(this.sequence?.variadic&&M(Q,"root")&&Q.extends(O.intrinsic.number))return F(q7(Q.expression,this.sequence.expression));return F(XZ(this.expression,[Q]))}let G=q.get(...X);return Z?G:G.or(O.intrinsic.undefined)}pick(...U){return this.assertHasKeys(U),this.$.node("structure",this.filterKeys("pick",U))}omit(...U){return this.assertHasKeys(U),this.$.node("structure",this.filterKeys("omit",U))}optionalize(){let{required:U,...X}=this.inner;return this.$.node("structure",{...X,optional:this.props.map((q)=>q.hasKind("required")?this.$.node("optional",q.inner):q)})}require(){let{optional:U,...X}=this.inner;return this.$.node("structure",{...X,required:this.props.map((q)=>q.hasKind("optional")?{key:q.key,value:q.value}:q)})}merge(U){let X=this.filterKeys("omit",[U.keyof()]);if(U.required)X.required=g(X.required,U.required);if(U.optional)X.optional=g(X.optional,U.optional);if(U.index)X.index=g(X.index,U.index);if(U.sequence)X.sequence=U.sequence;if(U.undeclared)X.undeclared=U.undeclared;else delete X.undeclared;return this.$.node("structure",X)}filterKeys(U,X){let q=A6(this.inner),Z=(Q)=>{let G=X.some((Y)=>N2(Q,Y));return U==="pick"?G:!G};if(q.required)q.required=q.required.filter((Q)=>Z(Q.key));if(q.optional)q.optional=q.optional.filter((Q)=>Z(Q.key));if(q.index)q.index=q.index.filter((Q)=>Z(Q.signature));return q}traverseAllows=(U,X)=>this._traverse("Allows",U,X);traverseApply=(U,X)=>this._traverse("Apply",U,X);_traverse=(U,X,q)=>{let Z=q?.currentErrorCount??0;for(let Q=0;Q<this.props.length;Q++)if(U==="Allows"){if(!this.props[Q].traverseAllows(X,q))return!1}else if(this.props[Q].traverseApply(X,q),q.failFast&&q.currentErrorCount>Z)return!1;if(this.sequence){if(U==="Allows"){if(!this.sequence.traverseAllows(X,q))return!1}else if(this.sequence.traverseApply(X,q),q.failFast&&q.currentErrorCount>Z)return!1}if(this.index||this.undeclared==="reject"){let Q=Object.keys(X);Q.push(...Object.getOwnPropertySymbols(X));for(let G=0;G<Q.length;G++){let Y=Q[G];if(this.index){for(let J of this.index)if(J.signature.traverseAllows(Y,q)){if(U==="Allows"){if(!_0(Y,()=>J.value.traverseAllows(X[Y],q),q))return!1}else if(_0(Y,()=>J.value.traverseApply(X[Y],q),q),q.failFast&&q.currentErrorCount>Z)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(Y)){if(U==="Allows")return!1;if(q.errorFromNodeContext({code:"predicate",expected:"removed",actual:"",relativePath:[Y],meta:this.meta}),q.failFast)return!1}}}if(this.structuralMorph&&q&&!q.hasError())q.queueMorphs([this.structuralMorph]);return!0};get defaultable(){return this.cacheGetter("defaultable",this.optional?.filter((U)=>U.hasDefault())??[])}declaresKey=(U)=>(U in this.propsByKey)||this.index?.some((X)=>X.signature.allows(U))||this.sequence!==void 0&&O.intrinsic.nonNegativeIntegerString.allows(U);_compileDeclaresKey(U){let X=[];if(this.props.length)X.push(`k in ${this.propsByKeyReference}`);if(this.index)for(let q of this.index)X.push(U.invoke(q.signature,{kind:"Allows",arg:"k"}));if(this.sequence)X.push("$ark.intrinsic.nonNegativeIntegerString.allows(k)");return X.join(" || ")||"false"}get structuralMorph(){return this.cacheGetter("structuralMorph",e5(this))}structuralMorphRef=this.structuralMorph&&d(this.structuralMorph);compile(U){if(U.traversalKind==="Apply")U.initializeErrorCount();for(let X of this.props)if(U.check(X),U.traversalKind==="Apply")U.returnIfFailFast();if(this.sequence){if(U.check(this.sequence),U.traversalKind==="Apply")U.returnIfFailFast()}if(this.index||this.undeclared==="reject")U.const("keys","Object.keys(data)"),U.line("keys.push(...Object.getOwnPropertySymbols(data))"),U.for("i < keys.length",()=>this.compileExhaustiveEntry(U));if(U.traversalKind==="Allows")return U.return(!0);if(this.structuralMorphRef)U.if("ctx && !ctx.hasError()",()=>{return U.line("ctx.queueMorphs(["),U7(U,this),U.line("])")})}compileExhaustiveEntry(U){if(U.const("k","keys[i]"),this.index)for(let X of this.index)U.if(`${U.invoke(X.signature,{arg:"k",kind:"Allows"})}`,()=>U.traverseKey("k","data[k]",X.value));if(this.undeclared==="reject")U.if(`!(${this._compileDeclaresKey(U)})`,()=>{if(U.traversalKind==="Allows")return U.return(!1);return U.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast",()=>U.return())});return U}reduceJsonSchema(U,X){switch(U.type){case"object":return this.reduceObjectJsonSchema(U,X);case"array":let q=this.sequence?.reduceJsonSchema(U,X)??U;if(this.props.length||this.index)return X.fallback.arrayObject({code:"arrayObject",base:q,object:this.reduceObjectJsonSchema({type:"object"},X)});return q;default:return p.throwInternalOperandError("structure",U)}}reduceObjectJsonSchema(U,X){if(this.props.length){U.properties={};for(let q of this.props){let Z=q.value.toJsonSchemaRecurse(X);if(typeof q.key==="symbol"){X.fallback.symbolKey({code:"symbolKey",base:U,key:q.key,value:Z,optional:q.optional});continue}if(q.hasDefault()){let Q=typeof q.default==="function"?q.default():q.default;Z.default=O.intrinsic.jsonData.allows(Q)?Q:X.fallback.defaultValue({code:"defaultValue",base:Z,value:Q})}U.properties[q.key]=Z}if(this.requiredKeys.length&&U.properties)U.required=this.requiredKeys.filter((q)=>typeof q==="string"&&(q in U.properties))}if(this.index)for(let q of this.index){let Z=q.value.toJsonSchemaRecurse(X);if(q.signature.equals(O.intrinsic.string)){U.additionalProperties=Z;continue}for(let Q of q.signature.branches){if(!Q.extends(O.intrinsic.string)){U=X.fallback.symbolKey({code:"symbolKey",base:U,key:null,value:Z,optional:!1});continue}let G={type:"string"};if(Q.hasKind("morph"))G=X.fallback.morph({code:"morph",base:Q.rawIn.toJsonSchemaRecurse(X),out:Q.rawOut.toJsonSchemaRecurse(X)});if(!Q.hasKind("intersection"))return y(`Unexpected index branch kind ${Q.kind}.`);let{pattern:Y}=Q.inner;if(Y){let J=Object.assign(G,{pattern:Y[0].rule});for(let H=1;H<Y.length;H++)G=X.fallback.patternIntersection({code:"patternIntersection",base:J,pattern:Y[H].rule});U.patternProperties??={},U.patternProperties[J.pattern]=Z}}}if(this.undeclared&&!U.additionalProperties)U.additionalProperties=!1;return U}}var I9={},t5=(U)=>{let X="";for(let q=0;q<U.defaultable.length;q++)X+=U.defaultable[q].defaultValueMorphRef;if(U.sequence?.defaultValueMorphsReference)X+=U.sequence?.defaultValueMorphsReference;if(U.undeclared==="delete"){if(X+="delete !(",U.required)for(let q of U.required)X+=q.compiledKey+" | ";if(U.optional)for(let q of U.optional)X+=q.compiledKey+" | ";if(U.index)for(let q of U.index)X+=q.signature.id+" | ";if(U.sequence)if(U.sequence.maxLength===null)X+=I.nonNegativeIntegerString.id;else for(let q=0;q<U.sequence.tuple.length;q++)X+=q+" | ";X+=")"}return X},e5=(U)=>{let X=t5(U);if(!X)return;if(I9[X])return I9[X];let q=(Z,Q)=>{for(let G=0;G<U.defaultable.length;G++)if(!(U.defaultable[G].key in Z))U.defaultable[G].defaultValueMorph(Z,Q);if(U.sequence?.defaultables)for(let G=Z.length-U.sequence.prefixLength;G<U.sequence.defaultables.length;G++)U.sequence.defaultValueMorphs[G](Z,Q);if(U.undeclared==="delete"){for(let G in Z)if(!U.declaresKey(G))delete Z[G]}return Z};return I9[X]=q},U7=(U,X)=>{let Z=`(data${X.defaultable.some((Q)=>Q.defaultValueMorph.length===2)||X.sequence?.defaultValueMorphs.some((Q)=>Q.length===2)?", ctx":""})`;return U.block(`${Z} => `,(Q)=>{for(let G=0;G<X.defaultable.length;G++){let{serializedKey:Y,defaultValueMorphRef:J}=X.defaultable[G];Q.if(`!(${Y} in data)`,(H)=>H.line(`${J}${Z}`))}if(X.sequence?.defaultables)Q.for(`i < ${X.sequence.defaultables.length}`,(G)=>G.set("data[i]",5),`data.length - ${X.sequence.prefixLength}`);if(X.undeclared==="delete")Q.forIn("data",(G)=>G.if(`!(${X._compileDeclaresKey(G)})`,(Y)=>Y.line("delete data[k]")));return Q.return("data")})},K9={implementation:a5,Node:QZ},X7=(U)=>{if(M(U,"root")&&U.hasKind("unit"))U=U.unit;if(typeof U==="number")U=`${U}`;return U},q7=(U,X)=>`${U} is not allowed as an array index on ${X}. Use the 'nonNegativeIntegerString' keyword instead.`,K6=(U,X,q)=>{let[Z,Q]=RX(U.branches,(Y)=>Y.hasKind("unit"));if(!Z.length)return{index:q.node("index",{signature:U,value:X})};let G={};for(let Y of Z){let J=q.node("required",{key:Y.unit,value:X});G[J.kind]=g(G[J.kind],J)}if(Q.length)G.index=q.node("index",{signature:Q,value:X});return G},Z7=(U)=>M(U,"root")?U.expression:E(U),XZ=(U,X)=>`Key${X.length===1?"":"s"} ${X.map(Z7).join(", ")} ${X.length===1?"does":"do"} not exist on ${U}`,qZ=(U)=>`Duplicate key ${M0(U)}`;var k1={...Pq,alias:C2.implementation,domain:I6.implementation,unit:R9.implementation,proto:S2.implementation,union:V9.implementation,morph:B9.implementation,intersection:O9.implementation,divisor:q9.implementation,pattern:_9.implementation,predicate:X9.implementation,required:M9.implementation,optional:I2.implementation,index:D9.implementation,sequence:w9.implementation,structure:K9.implementation};O.defaultConfig=SX(Object.assign(S(k1,(U,X)=>[U,X.defaults]),{jitless:yX(),clone:bX,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:p.defaultConfig}));O.resolvedConfig=T2(O.defaultConfig,O.config);var Eq={...Iq,alias:C2.Node,domain:I6.Node,unit:R9.Node,proto:S2.Node,union:V9.Node,morph:B9.Node,intersection:O9.Node,divisor:q9.Node,pattern:_9.Node,predicate:X9.Node,required:M9.Node,optional:I2.Node,index:D9.Node,sequence:w9.Node,structure:K9.Node};class x1 extends k4{get[Z0](){return"module"}}var N9=(U,X)=>new x1(S(U,(q,Z)=>[q,M(Z,"module")?N9(Z,X):X.bindReference(Z)]));var Q7=(U)=>h(U)?U:("branches"in U)&&h(U.branches)?U.branches:void 0,G7=(U,X)=>F(`Node of kind ${X} is not valid as a ${U} definition`),GZ=(U)=>`#${U} duplicates public alias ${U}`,C9={};O.ambient??={};var YZ,HZ="function $",Y7=(U)=>WZ(U,_Z(U)),WZ=(U,X)=>{let q=X.write(HZ,4),Z=X.compile()();for(let Q of U){if(Q.precompilation)continue;if(Q.traverseAllows=Z[`${Q.id}Allows`].bind(Z),Q.isRoot()&&!Q.allowsRequiresContext)Q.allows=Q.traverseAllows;if(Q.traverseApply=Z[`${Q.id}Apply`].bind(Z),Z[`${Q.id}Optimistic`])Q.traverseOptimistic=Z[`${Q.id}Optimistic`].bind(Z);Q.precompilation=q}},_Z=(U)=>new F6().return(U.reduce((X,q)=>{let Z=new B2({kind:"Allows"}).indent();q.compile(Z);let Q=Z.write(`${q.id}Allows`),G=new B2({kind:"Apply"}).indent();q.compile(G);let Y=G.write(`${q.id}Apply`),J=`${X}${Q},
179
+ Right: ${X}`;var d5=j({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:(U)=>U instanceof Date?U.toISOString():A0(U)}},normalize:(U)=>U,defaults:{description:(U)=>E(U.unit),problem:({expected:U,actual:X})=>`${U===X?`must be reference equal to ${U} (serialized to the same value)`:`must be ${U} (was ${X})`}`},intersections:{unit:(U,X)=>T.init("unit",U,X),...E0("unit",(U,X)=>{if(X.allows(U.unit))return U;let q=X.hasKind("intersection")?X.basis:X;if(q){let Z=q.hasKind("domain")?q:O.intrinsic.object;if(U.domain!==Z.domain){let Q=U.domain==="undefined"||U.domain==="null"||U.domain==="boolean"?U.domain:O.intrinsic[U.domain];return T.init("domain",Q,Z)}}return T.init("assignability",U,X.hasKind("intersection")?X.children.find((Z)=>!Z.allows(U.unit)):X)})}});class rq extends L1{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=oq(this.unit,this.serializedValue);compiledNegation=oq(this.unit,this.serializedValue,"negated");expression=E(this.unit);domain=r(this.unit);get defaultShortDescription(){return this.domain==="object"?Y0.object:this.description}innerToJsonSchema(U){return this.unit===null?{type:"null"}:O.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:U.fallback.unit({code:"unit",base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?(U)=>U instanceof Date&&U.toISOString()===this.compiledValue:Number.isNaN(this.unit)?(U)=>Number.isNaN(U):(U)=>U===this.unit}var R9={implementation:d5,Node:rq},oq=(U,X,q)=>{if(U instanceof Date){let Z=`data instanceof Date && data.toISOString() === ${X}`;return q?`!(${Z})`:Z}if(Number.isNaN(U))return`${q?"!":""}Number.isNaN(data)`;return`data ${q?"!":"="}== ${X}`};var c5=j({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:(U,X)=>{let q=X.$.parseSchema(U);if(!q.extends(O.intrinsic.key))return F(s5(q.expression));let Z=q.branches.filter((Q)=>Q.hasKind("unit"));if(Z.length)return F(i5(Z.map((Q)=>E(Q.unit))));return q}},value:{child:!0,parse:(U,X)=>X.$.parseSchema(U)}},normalize:(U)=>U,defaults:{description:(U)=>`[${U.signature.expression}]: ${U.value.description}`},intersections:{index:(U,X,q)=>{if(U.signature.equals(X.signature)){let Z=u(U.value,X.value,q),Q=Z instanceof T?O.intrinsic.never.internal:Z;return q.$.node("index",{signature:U.signature,value:Q})}if(U.signature.extends(X.signature)&&U.value.subsumes(X.value))return X;if(X.signature.extends(U.signature)&&X.value.subsumes(U.value))return U;return null}}});class nq extends O0{impliedBasis=O.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=g(this.value.flatRefs.map((U)=>P0([this.signature,...U.path],U.node)),P0([this.signature],this.value));traverseAllows=(U,X)=>J1(U).every((q)=>{if(this.signature.traverseAllows(q[0],X))return _0(q[0],()=>this.value.traverseAllows(q[1],X),X);return!0});traverseApply=(U,X)=>{for(let q of J1(U))if(this.signature.traverseAllows(q[0],X))_0(q[0],()=>this.value.traverseApply(q[1],X),X)};_transform(U,X){X.path.push(this.signature);let q=super._transform(U,X);return X.path.pop(),q}compile(){}}var D9={implementation:c5,Node:nq},i5=(U)=>`Index keys ${U.join(", ")} should be specified as named props.`,s5=(U)=>`Indexed key definition '${U}' must be a string or symbol`;var o5=j({kind:"required",hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(U,X)=>X.$.parseSchema(U)}},normalize:(U)=>U,defaults:{description:(U)=>`${U.compiledKey}: ${U.value.description}`,expected:(U)=>U.missingValueDescription,actual:()=>"missing"},intersections:{required:w2,optional:w2}});class aq extends P2{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=s0(this.errorContext)}var M9={implementation:o5,Node:aq};var r5=j({kind:"sequence",hasAssociatedError:!1,collapsibleKey:"variadic",keys:{prefix:{child:!0,parse:(U,X)=>{if(U.length===0)return;return U.map((q)=>X.$.parseSchema(q))}},optionals:{child:!0,parse:(U,X)=>{if(U.length===0)return;return U.map((q)=>X.$.parseSchema(q))}},defaultables:{child:(U)=>U.map((X)=>X[0]),parse:(U,X)=>{if(U.length===0)return;return U.map((q)=>{let Z=X.$.parseSchema(q[0]);return K2(Z,q[1],null),[Z,q[1]]})},serialize:(U)=>U.map((X)=>[X[0].collapsibleJson,A0(X[1])]),reduceIo:(U,X,q)=>{if(U==="in"){X.optionals=q.map((Z)=>Z[0].rawIn);return}X.prefix=q.map((Z)=>Z[0].rawOut);return}},variadic:{child:!0,parse:(U,X)=>X.$.parseSchema(U,X)},minVariadicLength:{parse:(U)=>U===0?void 0:U},postfix:{child:!0,parse:(U,X)=>{if(U.length===0)return;return U.map((q)=>X.$.parseSchema(q))}}},normalize:(U)=>{if(typeof U==="string")return{variadic:U};if("variadic"in U||"prefix"in U||"defaultables"in U||"optionals"in U||"postfix"in U||"minVariadicLength"in U){if(U.postfix?.length){if(!U.variadic)return F(e5);if(U.optionals?.length||U.defaultables?.length)return F(P9)}if(U.minVariadicLength&&!U.variadic)return F("minVariadicLength may not be specified without a variadic element");return U}return{variadic:U}},reduce:(U,X)=>{let q=U.minVariadicLength??0,Z=U.prefix?.slice()??[],Q=U.defaultables?.slice()??[],G=U.optionals?.slice()??[],Y=U.postfix?.slice()??[];if(U.variadic){while(G[G.length-1]?.equals(U.variadic))G.pop();if(G.length===0&&Q.length===0)while(Z[Z.length-1]?.equals(U.variadic))Z.pop(),q++;while(Y[0]?.equals(U.variadic))Y.shift(),q++}else if(G.length===0&&Q.length===0)Z.push(...Y.splice(0));if(q!==U.minVariadicLength||U.prefix&&U.prefix.length!==Z.length)return X.node("sequence",{...U,prefix:Z,defaultables:Q,optionals:G,postfix:Y,minVariadicLength:q},{prereduced:!0})},defaults:{description:(U)=>{if(U.isVariadicOnly)return`${U.variadic.nestableExpression}[]`;return`[${U.tuple.map((q)=>q.kind==="defaultables"?`${q.node.nestableExpression} = ${E(q.default)}`:q.kind==="optionals"?`${q.node.nestableExpression}?`:q.kind==="variadic"?`...${q.node.nestableExpression}[]`:q.node.expression).join(", ")}]`}},intersections:{sequence:(U,X,q)=>{let Z=E2({l:U.tuple,r:X.tuple,disjoint:new T,result:[],fixedVariants:[],ctx:q}),Q=Z.disjoint.length===0?[Z,...Z.fixedVariants]:Z.fixedVariants;return Q.length===0?Z.disjoint:Q.length===1?q.$.node("sequence",tq(Q[0].result)):q.$.node("union",Q.map((G)=>({proto:Array,sequence:tq(G.result)})))}}});class UZ extends O0{impliedBasis=O.intrinsic.Array.internal;tuple=t5(this.inner);prefixLength=this.prefix?.length??0;defaultablesLength=this.defaultables?.length??0;optionalsLength=this.optionals?.length??0;postfixLength=this.postfix?.length??0;defaultablesAndOptionals=[];prevariadic=this.tuple.filter((U)=>{if(U.kind==="defaultables"||U.kind==="optionals")return this.defaultablesAndOptionals.push(U.node),!0;return U.kind==="prefix"});variadicOrPostfix=g0(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return a4(this.flatRefs,this.prevariadic.flatMap((U,X)=>g(U.node.flatRefs.map((q)=>P0([`${X}`,...q.path],q.node)),P0([`${X}`],U.node)))),a4(this.flatRefs,this.variadicOrPostfix.flatMap((U)=>g(U.flatRefs.map((X)=>P0([O.intrinsic.nonNegativeIntegerString.internal,...X.path],X.node)),P0([O.intrinsic.nonNegativeIntegerString.internal],U)))),this.flatRefs}isVariadicOnly=this.prevariadic.length+this.postfixLength===0;minVariadicLength=this.inner.minVariadicLength??0;minLength=this.prefixLength+this.minVariadicLength+this.postfixLength;minLengthNode=this.minLength===0?null:this.$.node("minLength",this.minLength);maxLength=this.variadic?null:this.tuple.length;maxLengthNode=this.maxLength===null?null:this.$.node("maxLength",this.maxLength);impliedSiblings=this.minLengthNode?this.maxLengthNode?[this.minLengthNode,this.maxLengthNode]:[this.minLengthNode]:this.maxLengthNode?[this.maxLengthNode]:[];defaultValueMorphs=a5(this);defaultValueMorphsReference=this.defaultValueMorphs.length?d(this.defaultValueMorphs):void 0;elementAtIndex(U,X){if(X<this.prevariadic.length)return this.tuple[X];let q=U.length-this.postfixLength;if(X>=q)return{kind:"postfix",node:this.postfix[X-q]};return{kind:"variadic",node:this.variadic??y(`Unexpected attempt to access index ${X} on ${this}`)}}traverseAllows=(U,X)=>{for(let q=0;q<U.length;q++)if(!this.elementAtIndex(U,q).node.traverseAllows(U[q],X))return!1;return!0};traverseApply=(U,X)=>{let q=0;for(;q<U.length;q++)_0(q,()=>this.elementAtIndex(U,q).node.traverseApply(U[q],X),X)};get element(){return this.cacheGetter("element",this.$.node("union",this.children))}compile(U){if(this.prefix)for(let[X,q]of this.prefix.entries())U.traverseKey(`${X}`,`data[${X}]`,q);for(let[X,q]of this.defaultablesAndOptionals.entries()){let Z=`${X+this.prefixLength}`;U.if(`${Z} >= data.length`,()=>U.traversalKind==="Allows"?U.return(!0):U.return()),U.traverseKey(Z,`data[${Z}]`,q)}if(this.variadic){if(this.postfix)U.const("firstPostfixIndex",`data.length${this.postfix?`- ${this.postfix.length}`:""}`);if(U.for(`i < ${this.postfix?"firstPostfixIndex":"data.length"}`,()=>U.traverseKey("i","data[i]",this.variadic),this.prevariadic.length),this.postfix)for(let[X,q]of this.postfix.entries()){let Z=`firstPostfixIndex + ${X}`;U.traverseKey(Z,`data[${Z}]`,q)}}if(U.traversalKind==="Allows")U.return(!0)}_transform(U,X){X.path.push(O.intrinsic.nonNegativeIntegerString.internal);let q=super._transform(U,X);return X.path.pop(),q}expression=this.description;reduceJsonSchema(U,X){let q=X.target==="draft-07";if(this.prevariadic.length){let Z=this.prevariadic.map((Q)=>{let G=Q.node.toJsonSchemaRecurse(X);if(Q.kind==="defaultables"){let Y=typeof Q.default==="function"?Q.default():Q.default;G.default=O.intrinsic.jsonData.allows(Y)?Y:X.fallback.defaultValue({code:"defaultValue",base:G,value:Y})}return G});if(q)U.items=Z;else U.prefixItems=Z}if(this.minLength)U.minItems=this.minLength;if(this.variadic){let Z=this.variadic.toJsonSchemaRecurse(X);if(q&&this.prevariadic.length)U.additionalItems=Z;else U.items=Z;if(this.maxLength)U.maxItems=this.maxLength;if(this.postfix){let Q=this.postfix.map((G)=>G.toJsonSchemaRecurse(X));U=X.fallback.arrayPostfix({code:"arrayPostfix",base:U,elements:Q})}}else{if(q)U.additionalItems=!1;else U.items=!1;delete U.maxItems}return U}}var n5={},a5=(U)=>{if(!U.defaultables)return[];let X=[],q="[",Z=U.prefixLength+U.defaultablesLength-1;for(let Q=U.prefixLength;Q<=Z;Q++){let[G,Y]=U.defaultables[Q-U.prefixLength];X.push(A9(Q,G,Y)),q+=`${Q}: ${G.id} = ${A0(Y)}, `}return q+="]",n5[q]??=X},w9={implementation:r5,Node:UZ},t5=(U)=>{let X=[];if(U.prefix)for(let q of U.prefix)X.push({kind:"prefix",node:q});if(U.defaultables)for(let[q,Z]of U.defaultables)X.push({kind:"defaultables",node:q,default:Z});if(U.optionals)for(let q of U.optionals)X.push({kind:"optionals",node:q});if(U.variadic)X.push({kind:"variadic",node:U.variadic});if(U.postfix)for(let q of U.postfix)X.push({kind:"postfix",node:q});return X},tq=(U)=>U.reduce((X,q)=>{if(q.kind==="variadic")X.variadic=q.node;else if(q.kind==="defaultables")X.defaultables=g(X.defaultables,[[q.node,q.default]]);else X[q.kind]=g(X[q.kind],q.node);return X},{}),P9="A postfix required element cannot follow an optional or defaultable element",e5="A postfix element requires a variadic element",E2=(U)=>{let[X,...q]=U.l,[Z,...Q]=U.r;if(!X||!Z)return U;let G=q[q.length-1]?.kind==="postfix",Y=Q[Q.length-1]?.kind==="postfix",J=X.kind==="prefix"||Z.kind==="prefix"?"prefix":X.kind==="postfix"||Z.kind==="postfix"?"postfix":X.kind==="variadic"&&Z.kind==="variadic"?"variadic":G||Y?"prefix":X.kind==="defaultables"||Z.kind==="defaultables"?"defaultables":"optionals";if(X.kind==="prefix"&&Z.kind==="variadic"&&Y){let _=E2({...U,fixedVariants:[],r:Q.map((L)=>({...L,kind:"prefix"}))});if(_.disjoint.length===0)U.fixedVariants.push(_)}else if(Z.kind==="prefix"&&X.kind==="variadic"&&G){let _=E2({...U,fixedVariants:[],l:q.map((L)=>({...L,kind:"prefix"}))});if(_.disjoint.length===0)U.fixedVariants.push(_)}let H=u(X.node,Z.node,U.ctx);if(H instanceof T)if(J==="prefix"||J==="postfix")U.disjoint.push(...H.withPrefixKey(J==="prefix"?U.result.length:`-${q.length+1}`,eq(X)&&eq(Z)?"required":"optional")),U.result=[...U.result,{kind:J,node:O.intrinsic.never.internal}];else if(J==="optionals"||J==="defaultables")return U;else return E2({...U,fixedVariants:[],l:q.map((_)=>({..._,kind:"prefix"})),r:q.map((_)=>({..._,kind:"prefix"}))});else if(J==="defaultables"){if(X.kind==="defaultables"&&Z.kind==="defaultables"&&X.default!==Z.default)F(F9(X.default,Z.default));U.result=[...U.result,{kind:J,node:H,default:X.kind==="defaultables"?X.default:Z.kind==="defaultables"?Z.default:y(`Unexpected defaultable intersection from ${X.kind} and ${Z.kind} elements.`)}]}else U.result=[...U.result,{kind:J,node:H}];let W=U.l.length,$=U.r.length;if(X.kind!=="variadic"||W>=$&&(Z.kind==="variadic"||$===1))U.l=q;if(Z.kind!=="variadic"||$>=W&&(X.kind==="variadic"||W===1))U.r=Q;return E2(U)},eq=(U)=>U.kind==="prefix"||U.kind==="postfix";var QZ=(U)=>(X)=>{if(X.props.length||X.index){let q=X.index?.map((Q)=>Q[U])??[];for(let Q of X.props)q.push(Q[U]);if(X.undeclared)q.push(`+ (undeclared): ${X.undeclared}`);let Z=`{ ${q.join(", ")} }`;return X.sequence?`${Z} & ${X.sequence.description}`:Z}return X.sequence?.description??"{}"},U7=QZ("description"),X7=QZ("expression"),XZ=(U,X,q)=>{let Z=U.required?"required":"optional";if(!X.signature.allows(U.key))return null;let Q=$0(U.value,X.value,q);if(Q instanceof T)return Z==="optional"?q.node("optional",{key:U.key,value:O.intrinsic.never.internal}):Q.withPrefixKey(U.key,U.kind);return null},q7=j({kind:"structure",hasAssociatedError:!1,normalize:(U)=>U,applyConfig:(U,X)=>{if(!U.undeclared&&X.onUndeclaredKey!=="ignore")return{...U,undeclared:X.onUndeclaredKey};return U},keys:{required:{child:!0,parse:q0("required"),reduceIo:(U,X,q)=>{X.required=g(X.required,q.map((Z)=>U==="in"?Z.rawIn:Z.rawOut));return}},optional:{child:!0,parse:q0("optional"),reduceIo:(U,X,q)=>{if(U==="in"){X.optional=q.map((Z)=>Z.rawIn);return}for(let Z of q)X[Z.outProp.kind]=g(X[Z.outProp.kind],Z.outProp.rawOut)}},index:{child:!0,parse:q0("index")},sequence:{child:!0,parse:q0("sequence")},undeclared:{parse:(U)=>U==="ignore"?void 0:U,reduceIo:(U,X,q)=>{if(q==="reject"){X.undeclared="reject";return}if(U==="in")delete X.undeclared;else X.undeclared="reject"}}},defaults:{description:U7},intersections:{structure:(U,X,q)=>{let Z={...U.inner},Q={...X.inner},G=new T;if(U.undeclared){let H=U.keyof();for(let W of X.requiredKeys)if(!H.allows(W))G.add("presence",O.intrinsic.never.internal,X.propsByKey[W].value,{path:[W]});if(Q.optional)Q.optional=Q.optional.filter((W)=>H.allows(W.key));if(Q.index)Q.index=Q.index.flatMap((W)=>{if(W.signature.extends(H))return W;let $=$0(H,W.signature,q.$);if($ instanceof T)return[];let _=K6($,W.value,q.$);if(_.required)Q.required=g0(Q.required,_.required);if(_.optional)Q.optional=g0(Q.optional,_.optional);return _.index??[]})}if(X.undeclared){let H=X.keyof();for(let W of U.requiredKeys)if(!H.allows(W))G.add("presence",U.propsByKey[W].value,O.intrinsic.never.internal,{path:[W]});if(Z.optional)Z.optional=Z.optional.filter((W)=>H.allows(W.key));if(Z.index)Z.index=Z.index.flatMap((W)=>{if(W.signature.extends(H))return W;let $=$0(H,W.signature,q.$);if($ instanceof T)return[];let _=K6($,W.value,q.$);if(_.required)Z.required=g0(Z.required,_.required);if(_.optional)Z.optional=g0(Z.optional,_.optional);return _.index??[]})}let Y={};if(U.undeclared||X.undeclared)Y.undeclared=U.undeclared==="reject"||X.undeclared==="reject"?"reject":"delete";let J=f1({kind:"structure",baseInner:Y,l:g1(Z),r:g1(Q),roots:[],ctx:q});if(J instanceof T)G.push(...J);if(G.length)return G;return J}},reduce:(U,X)=>{if(!U.required&&!U.optional)return;let q={},Z=!1,Q=U.optional?[...U.optional]:[];if(U.required)for(let G=0;G<U.required.length;G++){let Y=U.required[G];if(Y.key in q)F(ZZ(Y.key));if(q[Y.key]=!0,U.index)for(let J of U.index){let H=XZ(Y,J,X);if(H instanceof T)return H}}if(U.optional)for(let G=0;G<U.optional.length;G++){let Y=U.optional[G];if(Y.key in q)F(ZZ(Y.key));if(q[Y.key]=!0,U.index)for(let J of U.index){let H=XZ(Y,J,X);if(H instanceof T)return H;if(H!==null)Q[G]=H,Z=!0}}if(Z)return X.node("structure",{...U,optional:Q},{prereduced:!0})}});class GZ extends O0{impliedBasis=O.intrinsic.object.internal;impliedSiblings=this.children.flatMap((U)=>U.impliedSiblings??[]);props=g0(this.required,this.optional);propsByKey=S(this.props,(U,X)=>[X.key,X]);propsByKeyReference=d(this.propsByKey);expression=X7(this);requiredKeys=this.required?.map((U)=>U.key)??[];optionalKeys=this.optional?.map((U)=>U.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let U=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:X}of this.index)U=U.concat(X.branches);return this._keyof=this.$.node("union",U)}map(U){return this.$.node("structure",this.props.flatMap(U).reduce((X,q)=>{let Z=this.propsByKey[q.key];if(x(q)){if(q.kind!=="required"&&q.kind!=="optional")return F(`Map result must have kind "required" or "optional" (was ${q.kind})`);return X[q.kind]=g(X[q.kind],q),X}let Q=q.kind??Z?.kind??"required",G=S(q,(Y,J)=>(Y in I2.implementation.keys)?[Y,J]:[]);return X[Q]=g(X[Q],this.$.node(Q,G)),X},{}))}assertHasKeys(U){let X=U.filter((q)=>!N2(q,this.keyof()));if(X.length)return F(qZ(this.expression,X))}get(U,...X){let q,Z=!1,Q=Y7(U);if((typeof Q==="string"||typeof Q==="symbol")&&this.propsByKey[Q])q=this.propsByKey[Q].value,Z=this.propsByKey[Q].required;if(this.index){for(let Y of this.index)if(N2(Q,Y.signature))q=q?.and(Y.value)??Y.value}if(this.sequence&&N2(Q,O.intrinsic.nonNegativeIntegerString))if(M(Q,"root")){if(this.sequence.variadic)q=q?.and(this.sequence.element)??this.sequence.element}else{let Y=Number.parseInt(Q);if(Y<this.sequence.prevariadic.length){let J=this.sequence.prevariadic[Y].node;q=q?.and(J)??J,Z||=Y<this.sequence.prefixLength}else if(this.sequence.variadic){let J=this.$.node("union",this.sequence.variadicOrPostfix);q=q?.and(J)??J}}if(!q){if(this.sequence?.variadic&&M(Q,"root")&&Q.extends(O.intrinsic.number))return F(J7(Q.expression,this.sequence.expression));return F(qZ(this.expression,[Q]))}let G=q.get(...X);return Z?G:G.or(O.intrinsic.undefined)}pick(...U){return this.assertHasKeys(U),this.$.node("structure",this.filterKeys("pick",U))}omit(...U){return this.assertHasKeys(U),this.$.node("structure",this.filterKeys("omit",U))}optionalize(){let{required:U,...X}=this.inner;return this.$.node("structure",{...X,optional:this.props.map((q)=>q.hasKind("required")?this.$.node("optional",q.inner):q)})}require(){let{optional:U,...X}=this.inner;return this.$.node("structure",{...X,required:this.props.map((q)=>q.hasKind("optional")?{key:q.key,value:q.value}:q)})}merge(U){let X=this.filterKeys("omit",[U.keyof()]);if(U.required)X.required=g(X.required,U.required);if(U.optional)X.optional=g(X.optional,U.optional);if(U.index)X.index=g(X.index,U.index);if(U.sequence)X.sequence=U.sequence;if(U.undeclared)X.undeclared=U.undeclared;else delete X.undeclared;return this.$.node("structure",X)}filterKeys(U,X){let q=A6(this.inner),Z=(Q)=>{let G=X.some((Y)=>N2(Q,Y));return U==="pick"?G:!G};if(q.required)q.required=q.required.filter((Q)=>Z(Q.key));if(q.optional)q.optional=q.optional.filter((Q)=>Z(Q.key));if(q.index)q.index=q.index.filter((Q)=>Z(Q.signature));return q}traverseAllows=(U,X)=>this._traverse("Allows",U,X);traverseApply=(U,X)=>this._traverse("Apply",U,X);_traverse=(U,X,q)=>{let Z=q?.currentErrorCount??0;for(let Q=0;Q<this.props.length;Q++)if(U==="Allows"){if(!this.props[Q].traverseAllows(X,q))return!1}else if(this.props[Q].traverseApply(X,q),q.failFast&&q.currentErrorCount>Z)return!1;if(this.sequence){if(U==="Allows"){if(!this.sequence.traverseAllows(X,q))return!1}else if(this.sequence.traverseApply(X,q),q.failFast&&q.currentErrorCount>Z)return!1}if(this.index||this.undeclared==="reject"){let Q=Object.keys(X);Q.push(...Object.getOwnPropertySymbols(X));for(let G=0;G<Q.length;G++){let Y=Q[G];if(this.index){for(let J of this.index)if(J.signature.traverseAllows(Y,q)){if(U==="Allows"){if(!_0(Y,()=>J.value.traverseAllows(X[Y],q),q))return!1}else if(_0(Y,()=>J.value.traverseApply(X[Y],q),q),q.failFast&&q.currentErrorCount>Z)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(Y)){if(U==="Allows")return!1;if(q.errorFromNodeContext({code:"predicate",expected:"removed",actual:"",relativePath:[Y],meta:this.meta}),q.failFast)return!1}}}if(this.structuralMorph&&q&&!q.hasError())q.queueMorphs([this.structuralMorph]);return!0};get defaultable(){return this.cacheGetter("defaultable",this.optional?.filter((U)=>U.hasDefault())??[])}declaresKey=(U)=>(U in this.propsByKey)||this.index?.some((X)=>X.signature.allows(U))||this.sequence!==void 0&&O.intrinsic.nonNegativeIntegerString.allows(U);_compileDeclaresKey(U){let X=[];if(this.props.length)X.push(`k in ${this.propsByKeyReference}`);if(this.index)for(let q of this.index)X.push(U.invoke(q.signature,{kind:"Allows",arg:"k"}));if(this.sequence)X.push("$ark.intrinsic.nonNegativeIntegerString.allows(k)");return X.join(" || ")||"false"}get structuralMorph(){return this.cacheGetter("structuralMorph",Q7(this))}structuralMorphRef=this.structuralMorph&&d(this.structuralMorph);compile(U){if(U.traversalKind==="Apply")U.initializeErrorCount();for(let X of this.props)if(U.check(X),U.traversalKind==="Apply")U.returnIfFailFast();if(this.sequence){if(U.check(this.sequence),U.traversalKind==="Apply")U.returnIfFailFast()}if(this.index||this.undeclared==="reject")U.const("keys","Object.keys(data)"),U.line("keys.push(...Object.getOwnPropertySymbols(data))"),U.for("i < keys.length",()=>this.compileExhaustiveEntry(U));if(U.traversalKind==="Allows")return U.return(!0);if(this.structuralMorphRef)U.if("ctx && !ctx.hasError()",()=>{return U.line("ctx.queueMorphs(["),G7(U,this),U.line("])")})}compileExhaustiveEntry(U){if(U.const("k","keys[i]"),this.index)for(let X of this.index)U.if(`${U.invoke(X.signature,{arg:"k",kind:"Allows"})}`,()=>U.traverseKey("k","data[k]",X.value));if(this.undeclared==="reject")U.if(`!(${this._compileDeclaresKey(U)})`,()=>{if(U.traversalKind==="Allows")return U.return(!1);return U.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast",()=>U.return())});return U}reduceJsonSchema(U,X){switch(U.type){case"object":return this.reduceObjectJsonSchema(U,X);case"array":let q=this.sequence?.reduceJsonSchema(U,X)??U;if(this.props.length||this.index)return X.fallback.arrayObject({code:"arrayObject",base:q,object:this.reduceObjectJsonSchema({type:"object"},X)});return q;default:return p.throwInternalOperandError("structure",U)}}reduceObjectJsonSchema(U,X){if(this.props.length){U.properties={};for(let q of this.props){let Z=q.value.toJsonSchemaRecurse(X);if(typeof q.key==="symbol"){X.fallback.symbolKey({code:"symbolKey",base:U,key:q.key,value:Z,optional:q.optional});continue}if(q.hasDefault()){let Q=typeof q.default==="function"?q.default():q.default;Z.default=O.intrinsic.jsonData.allows(Q)?Q:X.fallback.defaultValue({code:"defaultValue",base:Z,value:Q})}U.properties[q.key]=Z}if(this.requiredKeys.length&&U.properties)U.required=this.requiredKeys.filter((q)=>typeof q==="string"&&(q in U.properties))}if(this.index)for(let q of this.index){let Z=q.value.toJsonSchemaRecurse(X);if(q.signature.equals(O.intrinsic.string)){U.additionalProperties=Z;continue}for(let Q of q.signature.branches){if(!Q.extends(O.intrinsic.string)){U=X.fallback.symbolKey({code:"symbolKey",base:U,key:null,value:Z,optional:!1});continue}let G={type:"string"};if(Q.hasKind("morph"))G=X.fallback.morph({code:"morph",base:Q.rawIn.toJsonSchemaRecurse(X),out:Q.rawOut.toJsonSchemaRecurse(X)});if(!Q.hasKind("intersection"))return y(`Unexpected index branch kind ${Q.kind}.`);let{pattern:Y}=Q.inner;if(Y){let J=Object.assign(G,{pattern:Y[0].rule});for(let H=1;H<Y.length;H++)G=X.fallback.patternIntersection({code:"patternIntersection",base:J,pattern:Y[H].rule});U.patternProperties??={},U.patternProperties[J.pattern]=Z}}}if(this.undeclared&&!U.additionalProperties)U.additionalProperties=!1;return U}}var I9={},Z7=(U)=>{let X="";for(let q=0;q<U.defaultable.length;q++)X+=U.defaultable[q].defaultValueMorphRef;if(U.sequence?.defaultValueMorphsReference)X+=U.sequence?.defaultValueMorphsReference;if(U.undeclared==="delete"){if(X+="delete !(",U.required)for(let q of U.required)X+=q.compiledKey+" | ";if(U.optional)for(let q of U.optional)X+=q.compiledKey+" | ";if(U.index)for(let q of U.index)X+=q.signature.id+" | ";if(U.sequence)if(U.sequence.maxLength===null)X+=I.nonNegativeIntegerString.id;else for(let q=0;q<U.sequence.tuple.length;q++)X+=q+" | ";X+=")"}return X},Q7=(U)=>{let X=Z7(U);if(!X)return;if(I9[X])return I9[X];let q=(Z,Q)=>{for(let G=0;G<U.defaultable.length;G++)if(!(U.defaultable[G].key in Z))U.defaultable[G].defaultValueMorph(Z,Q);if(U.sequence?.defaultables)for(let G=Z.length-U.sequence.prefixLength;G<U.sequence.defaultables.length;G++)U.sequence.defaultValueMorphs[G](Z,Q);if(U.undeclared==="delete"){for(let G in Z)if(!U.declaresKey(G))delete Z[G]}return Z};return I9[X]=q},G7=(U,X)=>{let Z=`(data${X.defaultable.some((Q)=>Q.defaultValueMorph.length===2)||X.sequence?.defaultValueMorphs.some((Q)=>Q.length===2)?", ctx":""})`;return U.block(`${Z} => `,(Q)=>{for(let G=0;G<X.defaultable.length;G++){let{serializedKey:Y,defaultValueMorphRef:J}=X.defaultable[G];Q.if(`!(${Y} in data)`,(H)=>H.line(`${J}${Z}`))}if(X.sequence?.defaultables)Q.for(`i < ${X.sequence.defaultables.length}`,(G)=>G.set("data[i]",5),`data.length - ${X.sequence.prefixLength}`);if(X.undeclared==="delete")Q.forIn("data",(G)=>G.if(`!(${X._compileDeclaresKey(G)})`,(Y)=>Y.line("delete data[k]")));return Q.return("data")})},K9={implementation:q7,Node:GZ},Y7=(U)=>{if(M(U,"root")&&U.hasKind("unit"))U=U.unit;if(typeof U==="number")U=`${U}`;return U},J7=(U,X)=>`${U} is not allowed as an array index on ${X}. Use the 'nonNegativeIntegerString' keyword instead.`,K6=(U,X,q)=>{let[Z,Q]=DX(U.branches,(Y)=>Y.hasKind("unit"));if(!Z.length)return{index:q.node("index",{signature:U,value:X})};let G={};for(let Y of Z){let J=q.node("required",{key:Y.unit,value:X});G[J.kind]=g(G[J.kind],J)}if(Q.length)G.index=q.node("index",{signature:Q,value:X});return G},H7=(U)=>M(U,"root")?U.expression:E(U),qZ=(U,X)=>`Key${X.length===1?"":"s"} ${X.map(H7).join(", ")} ${X.length===1?"does":"do"} not exist on ${U}`,ZZ=(U)=>`Duplicate key ${M0(U)}`;var k1={...Iq,alias:C2.implementation,domain:I6.implementation,unit:R9.implementation,proto:S2.implementation,union:V9.implementation,morph:B9.implementation,intersection:O9.implementation,divisor:q9.implementation,pattern:_9.implementation,predicate:X9.implementation,required:M9.implementation,optional:I2.implementation,index:D9.implementation,sequence:w9.implementation,structure:K9.implementation};O.defaultConfig=EX(Object.assign(S(k1,(U,X)=>[U,X.defaults]),{jitless:kX(),clone:fX,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:p.defaultConfig}));O.resolvedConfig=T2(O.defaultConfig,O.config);var jq={...Kq,alias:C2.Node,domain:I6.Node,unit:R9.Node,proto:S2.Node,union:V9.Node,morph:B9.Node,intersection:O9.Node,divisor:q9.Node,pattern:_9.Node,predicate:X9.Node,required:M9.Node,optional:I2.Node,index:D9.Node,sequence:w9.Node,structure:K9.Node};class x1 extends k4{get[Z0](){return"module"}}var N9=(U,X)=>new x1(S(U,(q,Z)=>[q,M(Z,"module")?N9(Z,X):X.bindReference(Z)]));var W7=(U)=>h(U)?U:("branches"in U)&&h(U.branches)?U.branches:void 0,_7=(U,X)=>F(`Node of kind ${X} is not valid as a ${U} definition`),YZ=(U)=>`#${U} duplicates public alias ${U}`,C9={};O.ambient??={};var JZ,WZ="function $",$7=(U)=>_Z(U,$Z(U)),_Z=(U,X)=>{let q=X.write(WZ,4),Z=X.compile()();for(let Q of U){if(Q.precompilation)continue;if(Q.traverseAllows=Z[`${Q.id}Allows`].bind(Z),Q.isRoot()&&!Q.allowsRequiresContext)Q.allows=Q.traverseAllows;if(Q.traverseApply=Z[`${Q.id}Apply`].bind(Z),Z[`${Q.id}Optimistic`])Q.traverseOptimistic=Z[`${Q.id}Optimistic`].bind(Z);Q.precompilation=q}},$Z=(U)=>new F6().return(U.reduce((X,q)=>{let Z=new B2({kind:"Allows"}).indent();q.compile(Z);let Q=Z.write(`${q.id}Allows`),G=new B2({kind:"Apply"}).indent();q.compile(G);let Y=G.write(`${q.id}Apply`),J=`${X}${Q},
180
180
  ${Y},
181
181
  `;if(!q.hasKind("union"))return J;let H=new B2({kind:"Allows",optimistic:!0}).indent();q.compile(H);let W=H.write(`${q.id}Optimistic`);return`${J}${W},
182
182
  `},`{
183
- `)+"}");class N6{config;resolvedConfig;name;get[Z0](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(U,X){if(this.config=T2(O.config,X),this.resolvedConfig=T2(O.resolvedConfig,X),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(C9).length}`,this.name in C9)F(`A Scope already named ${this.name} already exists`);C9[this.name]=this;let q=Object.entries(U).map((Z)=>this.preparseOwnAliasEntry(...Z));for(let[Z,Q]of q){let G=Z;if(Z[0]==="#"){if(G=Z.slice(1),G in this.aliases)F(GZ(G));this.aliases[G]=Q}else{if(G in this.aliases)F(GZ(Z));this.aliases[G]=Q,this.exportedNames.push(G)}if(!M(Q,"module")&&!M(Q,"generic")&&!d0(Q)){let Y=this.preparseOwnDefinitionFormat(Q,{alias:G});this.resolutions[G]=M(Y,"root")?this.bindReference(Y):this.createParseContext(Y).id}}YZ??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[YZ.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=O.intrinsic?S(O.intrinsic,(Z,Q)=>Z.startsWith("json")?[]:[Z,this.bindReference(Q)]):{}}cacheGetter(U,X){return Object.defineProperty(this,U,{value:X}),X}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema(U){return U}generic=(...U)=>{let X=this;return(q,Z)=>new r0(U,Z?new V6(q):q,X,X,Z??null)};units=(U,X)=>{let q=[];for(let Q of U)if(!q.includes(Q))q.push(Q);let Z=q.map((Q)=>this.node("unit",{unit:Q},X));return this.node("union",Z,{...X,prereduced:!0})};lazyResolutions=[];lazilyResolve(U,X){let q=this.node("alias",{reference:X??"synthetic",resolve:U},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(q);return q}schema=(U,X)=>this.finalize(this.parseSchema(U,X));parseSchema=(U,X)=>this.node(M2(U),U,X);preparseNode(U,X,q){let Z=typeof U==="string"?U:M2(X,U);if(x(X)&&X.kind===Z)return X;if(Z==="alias"&&!q?.prereduced){let{reference:Y}=C2.implementation.normalize(X,this);if(Y.startsWith("$")){let J=this.resolveRoot(Y.slice(1));X=J,Z=J.kind}}else if(Z==="union"&&G0(X,"object")){let Y=Q7(X);if(Y?.length===1)X=Y[0],Z=M2(X)}if(x(X)&&X.kind===Z)return X;let G=k1[Z].normalize?.(X,this)??X;if(x(G))return G.kind===Z?G:G7(Z,G.kind);return{...q,$:this,kind:Z,def:G,prefix:q.alias??Z}}bindReference(U){let X;if(x(U))X=U.$===this?U:new U.constructor(U.attachments,this);else X=U.$===this?U:new r0(U.params,U.bodyDef,U.$,this,U.hkt);if(!this.resolved)Object.assign(this.referencesById,X.referencesById);return X}resolveRoot(U){return this.maybeResolveRoot(U)??F(j9(U))}maybeResolveRoot(U){let X=this.maybeResolve(U);if(M(X,"generic"))return;return X}maybeResolveSubalias(U){return S9(this.aliases,U)??S9(this.ambient,U)}get ambient(){return O.ambient}maybeResolve(U){let X=this.resolutions[U];if(X){if(typeof X!=="string")return this.bindReference(X);let Z=Q0[X];if(M(Z,"root"))return this.resolutions[U]=Z;if(M(Z,"context")){if(Z.phase==="resolving")return this.node("alias",{reference:`$${U}`},{prereduced:!0});if(Z.phase==="resolved")return y(`Unexpected resolved context for was uncached by its scope: ${E(Z)}`);Z.phase="resolving";let Q=this.bindReference(this.parseOwnDefinitionFormat(Z.def,Z));return Z.phase="resolved",Q0[Q.id]=Q,Q0[Z.id]=Q,this.resolutions[U]=Q}return y(`Unexpected nodesById entry for ${X}: ${E(Z)}`)}let q=this.aliases[U]??this.ambient?.[U];if(!q)return this.maybeResolveSubalias(U);if(q=this.normalizeRootScopeValue(q),M(q,"generic"))return this.resolutions[U]=this.bindReference(q);if(M(q,"module")){if(!q.root)F(zZ(U));return this.resolutions[U]=this.bindReference(q.root)}return this.resolutions[U]=this.parse(q,{alias:U})}createParseContext(U){let X=U.id??$9(U.prefix);return Q0[X]=Object.assign(U,{[Z0]:"context",$:this,id:X,phase:"unresolved"})}traversal(U){return new w0(U,this.resolvedConfig)}import(...U){return new x1(S(this.export(...U),(X,q)=>[`#${X}`,q]))}precompilation;_exportedResolutions;_exports;export(...U){if(!this._exports){this._exports={};for(let q of this.exportedNames){let Z=this.aliases[q];this._exports[q]=M(Z,"module")?N9(Z,this):JZ(this.maybeResolve(q))}for(let q of this.lazyResolutions)q.resolution;if(this._exportedResolutions=LZ(this,this._exports),this._json=$Z(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let q=_Z(this.references);this.precompilation=q.write(HZ,4),WZ(this.references,q)}this.resolved=!0}let X=U.length?U:this.exportedNames;return new x1(S(X,(q,Z)=>[Z,this._exports[Z]]))}resolve(U){return this.export()[U]}node=(U,X,q={})=>{let Z=this.preparseNode(U,X,q);if(x(Z))return this.bindReference(Z);let Q=this.createParseContext(Z),G=L9(Q),Y=this.bindReference(G);return Q0[Q.id]=Y};parse=(U,X={})=>this.finalize(this.parseDefinition(U,X));parseDefinition(U,X={}){if(M(U,"root"))return this.bindReference(U);let q=this.preparseOwnDefinitionFormat(U,X);if(M(q,"root"))return this.bindReference(q);let Z=this.createParseContext(q);Q0[Z.id]=Z;let Q=this.bindReference(this.parseOwnDefinitionFormat(U,Z));if(Q.isCyclic)Q=Sq(Q,Z.id);return Q0[Z.id]=Q,Q}finalize(U){if(JZ(U),!U.precompilation&&!this.resolvedConfig.jitless)Y7(U.references);return U}}class E9 extends N6{parseOwnDefinitionFormat(U,X){return L9(X)}preparseOwnDefinitionFormat(U,X){return this.preparseNode(M2(U),U,X)}preparseOwnAliasEntry(U,X){return[U,X]}normalizeRootScopeValue(U){return U}}var JZ=(U)=>{let X=U.references.filter((q)=>q.hasKind("alias"));for(let q of X){Object.assign(q.referencesById,q.resolution.referencesById);for(let Z of U.references)if(q.id in Z.referencesById)Object.assign(Z.referencesById,q.referencesById)}return U},$Z=(U)=>S(U,(X,q)=>[X,M(q,"root")||M(q,"generic")?q.json:M(q,"module")?$Z(q):y(`Unexpected resolution ${E(q)}`)]),S9=(U,X)=>{let q=X.indexOf(".");if(q===-1)return;let Z=X.slice(0,q),Q=U[Z];if(Q===void 0)return;if(!M(Q,"module"))return F(J7(Z));let G=X.slice(q+1),Y=Q[G];if(Y===void 0)return S9(Q,G);if(M(Y,"root")||M(Y,"generic"))return Y;if(M(Y,"module"))return Y.root??F(zZ(X));y(`Unexpected resolution for alias '${X}': ${E(Y)}`)},C6=(U,X)=>new E9(U,X),j2=new E9({});var LZ=(U,X)=>{let q={};for(let Z in X){let Q=X[Z];if(M(Q,"module")){let G=LZ(U,Q),Y=S(G,(J,H)=>[`${Z}.${J}`,H]);Object.assign(q,Y)}else if(M(Q,"root")||M(Q,"generic"))q[Z]=Q;else y(`Unexpected scope resolution ${E(Q)}`)}return q},j9=(U)=>`'${U}' is unresolvable`,J7=(U)=>`'${U}' must reference a module to be accessed using dot syntax`,zZ=(U)=>`Reference to submodule '${U}' must specify an alias`;j2.export();var{schema:v,node:u1,defineSchema:dw,generic:T0}=j2;var b9="^(?:0|[1-9]\\d*)$",H7=new RegExp(b9),sw=d(H7);var FZ=C6({bigint:"bigint",boolean:[{unit:!1},{unit:!0}],false:{unit:!1},never:[],null:{unit:null},number:"number",object:"object",string:"string",symbol:"symbol",true:{unit:!0},unknown:{},undefined:{unit:void 0},Array,Date},{prereducedAliases:!0}).export();O.intrinsic={...FZ};var AZ=C6({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:b9}},{prereducedAliases:!0}).export();Object.assign(O.intrinsic,AZ);var W7=C6({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),I={...FZ,...AZ,...W7,emptyStructure:u1("structure",{},{prereduced:!0})};O.intrinsic={...I};var S6=(U,X)=>new RegExp(U,X);Object.assign(S6,{as:S6});var BZ=(U)=>typeof U==="string"&&U[0]==="d"&&(U[1]==="'"||U[1]==='"')&&U[U.length-1]===U[1],OZ=(U)=>U.toString()!=="Invalid Date",TZ=(U)=>U.slice(2,-1),f9=(U)=>`'${U}' could not be parsed by the Date constructor`,VZ=(U,X)=>_7(U,X),_7=(U,X)=>{let q=new Date(U);if(OZ(q))return q;let Z=cX(U);if(Z!==void 0){let Q=new Date(Z);if(OZ(Q))return Q}return X?F(X===!0?f9(U):X):void 0};var $7=v({proto:"Array",sequence:"string",required:{key:"groups",value:["object",{unit:void 0}]}}),E6=(U,X)=>{let q=U.scanner.shiftUntilEscapable(z7[MZ[X]]);if(U.scanner.lookahead==="")return U.error(A7(q,X));if(U.scanner.shift(),X in DZ){let Z;try{Z=new RegExp(q)}catch(Q){F(String(Q))}if(U.root=U.ctx.$.node("intersection",{domain:"string",pattern:q},{prereduced:!0}),X==="x/")U.root=U.ctx.$.node("morph",{in:U.root,morphs:(Q)=>Z.exec(Q),declaredOut:$7})}else if(n(X,g9))U.root=U.ctx.$.node("unit",{unit:q});else{let Z=VZ(q,f9(q));U.root=U.ctx.$.node("unit",{meta:q,unit:Z})}},g9={"'":1,'"':1},RZ={"/":1,"'":1,'"':1},L7={"d'":"'",'d"':'"',"'":"'",'"':'"'},DZ={"/":"/","x/":"/"},MZ={...L7,...DZ},z7={"'":(U)=>U.lookahead==="'",'"':(U)=>U.lookahead==='"',"/":(U)=>U.lookahead==="/"},F7={'"':"double-quote","'":"single-quote","/":"forward slash"},A7=(U,X)=>`${X}${U} requires a closing ${F7[MZ[X]]}`;var wZ=(U)=>`Private type references should not include '#'. Use '${U}' instead.`,j6="Optional definitions like 'string?' are only valid as properties in an object or tuple",b6="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var j0={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...c0};var PZ=(U,X)=>U===">"?X[0]==="="?X[1]==="=":X.trimStart()===""||n(X.trimStart()[0],j0):U==="="?X[0]!=="=":U===","||U==="?";var IZ=(U,X,q)=>KZ(U,X,q,[]),KZ=(U,X,q,Z)=>{let Q=q.parseUntilFinalizer();if(Z.push(Q.root),Q.finalizer===">"){if(Z.length!==X.params.length)return q.error(y9(U,X.names,Z.map((G)=>G.expression)));return Z}if(Q.finalizer===",")return KZ(U,X,q,Z);return Q.error(z6(">"))},y9=(U,X,q)=>`${U}<${X.join(", ")}> requires exactly ${X.length} args (got ${q.length}${q.length===0?"":`: ${q.join(", ")}`})`;var f6=(U)=>{let X=U.scanner.shiftUntilLookahead(j0);if(X==="keyof")U.addPrefix("keyof");else U.root=B7(U,X)},O7=(U,X,q)=>{if(q.scanner.shiftUntilNonWhitespace(),q.scanner.shift()!=="<")return q.error(y9(U,X.names,[]));let Q=IZ(U,X,q);return X(...Q)},B7=(U,X)=>T7(U,X)??V7(U,X)??U.error(X===""?U.scanner.lookahead==="#"?wZ(U.shiftedBy(1).scanner.shiftUntilLookahead(j0)):k9(U):j9(X)),T7=(U,X)=>{if(U.ctx.args?.[X]){let Z=U.ctx.args[X];if(typeof Z!=="string")return Z;return U.ctx.$.node("alias",{reference:Z},{prereduced:!0})}let q=U.ctx.$.maybeResolve(X);if(M(q,"root"))return q;if(q===void 0)return;if(M(q,"generic"))return O7(X,q,U);return F(`Unexpected resolution ${E(q)}`)},V7=(U,X)=>{let q=iX(X);if(q!==void 0)return U.ctx.$.node("unit",{unit:q});let Z=oX(X);if(Z!==void 0)return U.ctx.$.node("unit",{unit:Z})},k9=(U)=>{let X=U.previousOperator();return X?v9(X,U.scanner.unscanned):R7(U.scanner.unscanned)},v9=(U,X="")=>`Token '${U}' requires a right operand${X?` before '${X}'`:""}`,R7=(U)=>`Expected an expression${U?` before '${U}'`:""}`;var h9=(U)=>U.scanner.lookahead===""?U.error(k9(U)):U.scanner.lookahead==="("?U.shiftedBy(1).reduceGroupOpen():U.scanner.lookaheadIsIn(RZ)?E6(U,U.scanner.shift()):U.scanner.lookaheadIsIn(c0)?h9(U.shiftedBy(1)):U.scanner.lookahead==="d"?U.scanner.nextLookahead in g9?E6(U,`${U.scanner.shift()}${U.scanner.shift()}`):f6(U):U.scanner.lookahead==="x"?U.scanner.nextLookahead==="/"?U.shiftedBy(2)&&E6(U,"x/"):f6(U):f6(U);var NZ={">":!0,">=":!0},CZ={"<":!0,"<=":!0};var m1={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},SZ=(U,X)=>`Left bounds are only valid when paired with right bounds (try ...${X}${U})`,g6=(U)=>`Left-bounded expressions must specify their limits using < or <= (was ${U})`,EZ=(U,X,q,Z)=>`An expression may have at most one left bound (parsed ${U}${m1[X]}, ${q}${m1[Z]})`;var bZ=(U,X)=>{let q=D7(U,X);if(U.root.hasKind("unit")){if(typeof U.root.unit==="number"){U.reduceLeftBound(U.root.unit,q),U.unsetRoot();return}if(U.root.unit instanceof Date){let Z=`d'${U.root.description??U.root.unit.toISOString()}'`;U.unsetRoot(),U.reduceLeftBound(Z,q);return}}return w7(U,q)},fZ={"<":1,">":1,"=":1},D7=(U,X)=>U.scanner.lookaheadIs("=")?`${X}${U.scanner.shift()}`:X;var jZ=(U,X,q,Z)=>{if(q.extends(O.intrinsic.number)){if(typeof X!=="number")return F(x9(U,X,Z));return U==="=="?["min","max"]:U[0]===">"?["min"]:["max"]}if(q.extends(O.intrinsic.lengthBoundable)){if(typeof X!=="number")return F(x9(U,X,Z));return U==="=="?["exactLength"]:U[0]===">"?["minLength"]:["maxLength"]}if(q.extends(O.intrinsic.Date))return U==="=="?["after","before"]:U[0]===">"?["after"]:["before"];return F(Oq(q.expression))},M7=(U)=>({rule:BZ(U.limit)?TZ(U.limit):U.limit,exclusive:U.comparator.length===1}),w7=(U,X)=>{let q=U.unsetRoot(),Z=U.scanner.location;U.parseOperand();let Q=U.unsetRoot(),G=U.scanner.sliceChars(Z,U.scanner.location);if(U.root=q,!Q.hasKind("unit")||typeof Q.unit!=="number"&&!(Q.unit instanceof Date))return U.error(x9(X,G,"right"));let Y=Q.unit,J=X.length===1,H=jZ(X,typeof Y==="number"?Y:G,q,"right");for(let $ of H)U.constrainRoot($,X==="=="?{rule:Y}:{rule:Y,exclusive:J});if(!U.branches.leftBound)return;if(!n(X,CZ))return U.error(g6(X));let W=jZ(U.branches.leftBound.comparator,U.branches.leftBound.limit,q,"left");U.constrainRoot(W[0],M7(U.branches.leftBound)),U.branches.leftBound=null},x9=(U,X,q)=>`Comparator ${q==="left"?m1[U]:U} must be ${q==="left"?"preceded":"followed"} by a corresponding literal (was ${X})`;var gZ=(U)=>{U.scanner.shiftUntilNonWhitespace();let X=U.scanner.shiftUntilLookahead(j0);U.root=U.root.brand(X)};var kZ=(U)=>{U.scanner.shiftUntilNonWhitespace();let X=U.scanner.shiftUntilLookahead(j0),q=sX(X,{errorOnFail:yZ(X)});if(q===0)U.error(yZ(0));U.root=U.root.constrain("divisor",q)},yZ=(U)=>`% operator must be followed by a non-zero integer literal (was ${U})`;var u9=(U)=>{let X=U.scanner.shift();return X===""?U.finalize(""):X==="["?U.scanner.shift()==="]"?U.setRoot(U.root.array()):U.error(P7):X==="|"?U.scanner.lookahead===">"?U.shiftedBy(1).pushRootToBranch("|>"):U.pushRootToBranch(X):X==="&"?U.pushRootToBranch(X):X===")"?U.finalizeGroup():PZ(X,U.scanner.unscanned)?U.finalize(X):n(X,fZ)?bZ(U,X):X==="%"?kZ(U):X==="#"?gZ(U):(X in c0)?u9(U):U.error(y6(X))},y6=(U,X="")=>`'${U}' is not allowed here${X&&` (should be ${X})`}`,P7="Missing expected ']'";var vZ=(U)=>{let X=U.unsetRoot();U.parseOperand();let q=U.unsetRoot();if(!q.hasKind("unit"))return U.error(I7(q.expression));let Z=q.unit instanceof Date?()=>new Date(q.unit):q.unit;return[X,"=",Z]},I7=(U)=>`Default value '${U}' must be a literal value`;var m9=(U,X)=>{let q=X.$.maybeResolveRoot(U);if(q)return q;if(U.endsWith("[]")){let G=X.$.maybeResolveRoot(U.slice(0,-2));if(G)return G.array()}let Z=new p1(new O2(U),X),Q=K7(Z);if(Z.finalizer===">")F(y6(">"));return Q},K7=(U)=>{U.parseOperand();let X=b2(U).root;if(!X)return y(`Root was unexpectedly unset after parsing string '${U.scanner.scanned}'`);if(U.finalizer==="=")X=vZ(U);else if(U.finalizer==="?")X=[X,"?"];if(U.scanner.shiftUntilNonWhitespace(),U.scanner.lookahead)F(y6(U.scanner.lookahead));return X},b2=(U)=>{while(U.finalizer===void 0)N7(U);return U},N7=(U)=>U.hasRoot()?U.parseOperator():U.parseOperand();class p1{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor(U,X){this.scanner=U,this.ctx=X}error(U){return F(U)}hasRoot(){return this.root!==void 0}setRoot(U){this.root=U}unsetRoot(){let U=this.root;return this.root=void 0,U}constrainRoot(...U){this.root=this.root.constrain(U[0],U[1])}finalize(U){if(this.groups.length)return this.error(z6(")"));this.finalizeBranches(),this.finalizer=U}reduceLeftBound(U,X){let q=m1[X];if(!n(q,NZ))return this.error(g6(X));if(this.branches.leftBound)return this.error(EZ(this.branches.leftBound.limit,this.branches.leftBound.comparator,U,q));this.branches.leftBound={comparator:q,limit:U}}finalizeBranches(){if(this.assertRangeUnset(),this.branches.pipe){this.pushRootToBranch("|>"),this.root=this.branches.pipe;return}if(this.branches.union){this.pushRootToBranch("|"),this.root=this.branches.union;return}if(this.branches.intersection){this.pushRootToBranch("&"),this.root=this.branches.intersection;return}this.applyPrefixes()}finalizeGroup(){this.finalizeBranches();let U=this.groups.pop();if(!U)return this.error(tX(")",this.scanner.unscanned));this.branches=U}addPrefix(U){this.branches.prefixes.push(U)}applyPrefixes(){while(this.branches.prefixes.length){let U=this.branches.prefixes.pop();this.root=U==="keyof"?this.root.keyof():y(`Unexpected prefix '${U}'`)}}pushRootToBranch(U){this.assertRangeUnset(),this.applyPrefixes();let X=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(X)??X,U==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,U==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return b2(new p1(this.scanner,this.ctx))}parseOperator(){return u9(this)}parseOperand(){return h9(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(SZ(this.branches.leftBound.limit,this.branches.leftBound.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={prefixes:[],leftBound:null,union:null,intersection:null,pipe:null}}previousOperator(){return this.branches.leftBound?.comparator??this.branches.prefixes[this.branches.prefixes.length-1]??(this.branches.intersection?"&":this.branches.union?"|":this.branches.pipe?"|>":void 0)}shiftedBy(U){return this.scanner.jumpForward(U),this}}var C7="An empty string is not a valid generic parameter name",k6=(U,X,q)=>{U.shiftUntilNonWhitespace();let Z=U.shiftUntilLookahead(j0);if(Z===""){if(U.lookahead===""&&X.length)return X;return F(C7)}return U.shiftUntilNonWhitespace(),S7(U,Z,X,q)},hZ="extends ",S7=(U,X,q,Z)=>{if(U.shiftUntilNonWhitespace(),U.unscanned.startsWith(hZ))U.jumpForward(hZ.length);else{if(U.lookahead===",")U.shift();return q.push(X),k6(U,q,Z)}let Q=b2(new p1(U,Z));return q.push([X,Q.root]),k6(U,q,Z)};class p9 extends H0{constructor(U){let X={$:U,raw:U.fn};super((...q)=>{let Z=q.indexOf(":"),Q=Z===-1?q.length-1:Z-1,G=q.slice(0,Q+1),Y=U.parse(G).assertHasKind("intersection"),J=U.intrinsic.unknown;if(Z!==-1){if(Z!==q.length-2)return F(E7);J=U.parse(q[Z+1])}return(H)=>new xZ(H,Y,J)},{attach:X})}}class xZ extends H0{raw;params;returns;expression;constructor(U,X,q){let Z=`typed ${U.name}`,Q={[Z]:(...Y)=>{let J=X.assert(Y),H=U(...J);return q.assert(H)}}[Z];super(Q);this.raw=U,this.params=X,this.returns=q;let G=X.expression;if(G[0]==="["&&G[G.length-1]==="]")G=G.slice(1,-1);else if(G.endsWith("[]"))G=`...${G}`;this.expression=`(${G}) => ${q?.expression??"unknown"}`}}var E7=`":" must be followed by exactly one return type e.g:
184
- fn("string", ":", "number")(s => s.length)`;class l9 extends H0{$;constructor(U){super((...X)=>new f2(U)(...X),{bind:U});this.$=U}in(U){return new f2(this.$,U===void 0?void 0:this.$.parse(U))}at(U,X){return new f2(this.$).at(U,X)}case(U,X){return new f2(this.$).case(U,X)}}class f2 extends H0{$;in;key;branches=[];constructor(U,X){super((q)=>this.caseEntries(Object.entries(q).map(([Z,Q])=>Z==="default"?[Z,Q]:[this.$.parse(Z),Q])));this.$=U,this.in=X}at(U,X){if(this.key)F(b7);if(this.branches.length)F(j7);return this.key=U,X?this.match(X):this}case(U,X){return this.caseEntry(this.$.parse(U),X)}caseEntry(U,X){let Z=(this.key?this.$.parse({[this.key]:U}):U).pipe(X);return this.branches.push(Z),this}match(U){return this(U)}strings(U){return this.caseEntries(Object.entries(U).map(([X,q])=>X==="default"?[X,q]:[this.$.node("unit",{unit:X}),q]))}caseEntries(U){for(let X=0;X<U.length;X++){let[q,Z]=U[X];if(q==="default"){if(X!==U.length-1)F("default may only be specified as the last key of a switch definition");return this.default(Z)}if(typeof Z!=="function")return F(`Value for case "${q}" must be a function (was ${r(Z)})`);this.caseEntry(q,Z)}return this}default(U){if(typeof U==="function")this.case(I.unknown,U);let X={branches:this.branches,ordered:!0};if(U==="never"||U==="assert")X.meta={onFail:uZ};let q=this.$.node("union",X);if(!this.in)return this.$.finalize(q);let Z=this.in.pipe(q);if(U==="never"||U==="assert")Z=Z.configureReferences({onFail:uZ},"self");return this.$.finalize(Z)}}var uZ=(U)=>U.throw(),j7="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",b7="At most one key matcher may be specified per expression";var v6=(U,X)=>{if(h(U)){if(U[1]==="=")return[X.$.parseOwnDefinitionFormat(U[0],X),"=",U[2]];if(U[1]==="?")return[X.$.parseOwnDefinitionFormat(U[0],X),"?"]}return h6(U,X)},mZ="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",pZ="Only required keys may specify default values, e.g. { value: 'number = 0' }";var lZ=(U,X)=>{let q,Z={},Q=J1(U);for(let[Y,J]of Q){let H=y7(Y);if(H.kind==="spread"){if(!S0(Z))return F(g7);let A=X.$.parseOwnDefinitionFormat(J,X);if(A.equals(I.object))continue;if(!A.hasKind("intersection")||!A.basis?.equals(I.object))return F(k7(A.expression));q=A.structure;continue}if(H.kind==="undeclared"){if(J!=="reject"&&J!=="delete"&&J!=="ignore")F(f7(J));Z.undeclared=J;continue}let W=v6(J,X),$=H;if(H.kind==="required"){if(!h(W))d9(Z,"required",{key:H.normalized,value:W},X);else d9(Z,"optional",W[1]==="="?{key:H.normalized,value:W[0],default:W[2]}:{key:H.normalized,value:W[0]},X);continue}if(h(W)){if(W[1]==="?")F(mZ);if(W[1]==="=")F(pZ)}if(H.kind==="optional"){d9(Z,"optional",{key:H.normalized,value:W},X);continue}let _=X.$.parseOwnDefinitionFormat($.normalized,X),L=K6(_,W,X.$);if(L.index)Z.index=g(Z.index,L.index);if(L.required)Z.required=g(Z.required,L.required)}let G=X.$.node("structure",Z);return X.$.parseSchema({domain:"object",structure:q?.merge(G)??G})},d9=(U,X,q,Z)=>{U[X]=g(U[X],Z.$.node(X,q))},f7=(U)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${E(U)})`,g7="Spread operator may only be used as the first key in an object",y7=(U)=>typeof U==="symbol"?{kind:"required",normalized:U}:U[U.length-1]==="?"?U[U.length-2]===W1?{kind:"required",normalized:`${U.slice(0,-2)}?`}:{kind:"optional",normalized:U.slice(0,-1)}:U[0]==="["&&U[U.length-1]==="]"?{kind:"index",normalized:U.slice(1,-1)}:U[0]===W1&&U[1]==="["&&U[U.length-1]==="]"?{kind:"required",normalized:U.slice(1)}:U==="..."?{kind:"spread"}:U==="+"?{kind:"undeclared"}:{kind:"required",normalized:U==="\\..."?"...":U==="\\+"?"+":U},k7=(U)=>`Spread operand must resolve to an object literal type (was ${U})`;var cZ=(U,X)=>i7(U)?rZ[U[0]](U,X):d7(U)?oZ[U[1]](U,X):null,v7=(U,X)=>X.$.parseOwnDefinitionFormat(U[1],X).keyof(),c9=(U,X)=>{if(U[2]===void 0)return F(v9(U[1],""));let q=X.$.parseOwnDefinitionFormat(U[0],X),Z=X.$.parseOwnDefinitionFormat(U[2],X);if(U[1]==="|")return X.$.node("union",{branches:[q,Z]});let Q=U[1]==="&"?$0(q,Z,X.$):D2(q,Z,X.$);if(Q instanceof T)return Q.throw();return Q},h7=(U,X)=>X.$.parseOwnDefinitionFormat(U[0],X).array(),x7=(U,X)=>{if(typeof U[2]!=="function")return F(iZ("=>",U[2]));return X.$.parseOwnDefinitionFormat(U[0],X).pipe(U[2])},iZ=(U,X)=>`${U===":"?"Narrow":"Morph"} expression requires a function following '${U}' (was ${typeof X})`,u7=(U,X)=>{if(typeof U[2]!=="function")return F(iZ(":",U[2]));return X.$.parseOwnDefinitionFormat(U[0],X).constrain("predicate",U[2])},m7=(U,X)=>X.$.parseOwnDefinitionFormat(U[0],X).configure(U[2],U[3]),sZ=(U)=>U,p7=sZ({"[]":h7,"?":()=>F(j6)}),l7=sZ({"|":c9,"&":c9,":":u7,"=>":x7,"|>":c9,"@":m7,"=":()=>F(b6)}),oZ={...p7,...l7},d7=(U)=>oZ[U[1]]!==void 0,c7=(U)=>U,rZ=c7({keyof:v7,instanceof:(U,X)=>{if(typeof U[1]!=="function")return F(dZ(W2(U[1])));let q=U.slice(1).map((Z)=>typeof Z==="function"?X.$.node("proto",{proto:Z}):F(dZ(W2(Z))));return q.length===1?q[0]:X.$.node("union",{branches:q})},"===":(U,X)=>X.$.units(U.slice(1))}),i7=(U)=>rZ[U[0]]!==void 0,dZ=(U)=>`Expected a constructor following 'instanceof' operator (was ${U})`;var tZ=(U,X)=>{let q=[{}],Z=0;while(Z<U.length){let Q=!1;if(U[Z]==="..."&&Z<U.length-1)Q=!0,Z++;let G=v6(U[Z],X),[Y,J,H]=!h(G)?[G]:G;if(Z++,Q){if(!Y.extends(O.intrinsic.Array))return F(r7(Y.expression));q=q.flatMap((W)=>Y.distribute(($)=>o7(A6(W),$)))}else q=q.map((W)=>{if(J==="?")return eZ(W,Y);if(J==="=")return s7(W,Y,H);return i9(W,Y)})}return X.$.parseSchema(q.map((Q)=>S0(Q)?{proto:Array,exactLength:0}:{proto:Array,sequence:Q}))},i9=(U,X)=>{if(U.defaultables||U.optionals)return F(U.variadic?P9:n7);if(U.variadic)U.postfix=g(U.postfix,X);else U.prefix=g(U.prefix,X);return U},eZ=(U,X)=>{if(U.variadic)return F(U8);return U.optionals=g(U.optionals,X),U},s7=(U,X,q)=>{if(U.variadic)return F(U8);if(U.optionals)return F(a7);return U.defaultables=g(U.defaultables,[[X,q]]),U},nZ=(U,X)=>{if(U.postfix)F(aZ);if(U.variadic){if(!U.variadic.equals(X))F(aZ)}else U.variadic=X.internal;return U},o7=(U,X)=>{let q=X.select({method:"find",kind:"sequence"});if(!q)return nZ(U,O.intrinsic.unknown);if(q.prefix)for(let Z of q.prefix)i9(U,Z);if(q.optionals)for(let Z of q.optionals)eZ(U,Z);if(q.variadic)nZ(U,q.variadic);if(q.postfix)for(let Z of q.postfix)i9(U,Z);return U},r7=(U)=>`Spread element must be an array (was ${U})`,aZ="A tuple may have at most one variadic element",n7="A required element may not follow an optional element",U8="An optional element may not follow a variadic element";var a7="A defaultable element may not follow an optional element without a default";var t7={},h6=(U,X)=>{if(typeof U==="string"){if(X.args&&Object.keys(X.args).some((Z)=>U.includes(Z)))return m9(U,X);let q=t7[X.$.name]??={};return q[U]??=m9(U,X)}return G0(U,"object")?e7(U,X):F(s9(r(U)))},e7=(U,X)=>{let q=H2(U);switch(q){case void 0:if(M(U,"root"))return U;if("~standard"in U)return UY(U,X);return lZ(U,X);case"Array":return XY(U,X);case"RegExp":return X.$.node("intersection",{domain:"string",pattern:U},{prereduced:!0});case"Function":{let Z=d0(U)?U():U;if(M(Z,"root"))return Z;return F(s9("Function"))}default:return F(s9(q??E(U)))}},UY=(U,X)=>X.$.intrinsic.unknown.pipe((q,Z)=>{let Q=U["~standard"].validate(q);if(!Q.issues)return Q.value;for(let{message:G,path:Y}of Q.issues)if(Y)if(Y.length)Z.error({problem:xX(G),relativePath:Y.map((J)=>typeof J==="object"?J.key:J)});else Z.error({message:G});else Z.error({message:G})}),XY=(U,X)=>cZ(U,X)??tZ(U,X),s9=(U)=>`Type definitions must be strings or objects (was ${U})`;class o9 extends H0{constructor(U){let X=Object.assign({errors:W0,hkt:X0,$:U,raw:U.parse,module:U.constructor.module,scope:U.constructor.scope,declare:U.declare,define:U.define,match:U.match,generic:U.generic,schema:U.schema,keywords:U.ambient,unit:U.unit,enumerated:U.enumerated,instanceOf:U.instanceOf,valueOf:U.valueOf,or:U.or,and:U.and,merge:U.merge,pipe:U.pipe,fn:U.fn},U.ambientAttachments);super((...q)=>{if(q.length===1)return U.parse(q[0]);if(q.length===2&&typeof q[0]==="string"&&q[0][0]==="<"&&q[0][q[0].length-1]===">"){let Z=q[0].slice(1,-1),Q=U.parseGenericParams(Z,{});return new r0(Q,q[1],U,U,null)}return U.parse(q)},{attach:X})}}var l1=O;class x6 extends N6{get ambientAttachments(){if(!l1.typeAttachments)return;return this.cacheGetter("ambientAttachments",S(l1.typeAttachments,(U,X)=>[U,this.bindReference(X)]))}preparseOwnAliasEntry(U,X){let q=U.indexOf("<");if(q===-1){if(M(X,"module")||M(X,"generic"))return[U,X];let G=this.name==="ark"?U:U==="root"?this.name:`${this.name}.${U}`,Y=this.resolvedConfig.keywords?.[G];if(Y)X=[X,"@",Y];return[U,X]}if(U[U.length-1]!==">")F("'>' must be the last character of a generic declaration in a scope");let Z=U.slice(0,q),Q=U.slice(q+1,-1);return[Z,()=>{let G=this.parseGenericParams(Q,{alias:Z});return zq(G,X,this)}]}parseGenericParams(U,X){return k6(new O2(U),[],this.createParseContext({...X,def:U,prefix:"generic"}))}normalizeRootScopeValue(U){if(d0(U)&&!M(U,"generic"))return U();return U}preparseOwnDefinitionFormat(U,X){return{...X,def:U,prefix:X.alias??"type"}}parseOwnDefinitionFormat(U,X){if(!(X.alias&&(X.alias in this.aliases))&&!X.args)X.args={this:X.id};let Z=h6(U,X);if(h(Z)){if(Z[1]==="=")return F(b6);if(Z[1]==="?")return F(j6)}return Z}unit=(U)=>this.units([U]);valueOf=(U)=>this.units(EX(U));enumerated=(...U)=>this.units(U);instanceOf=(U)=>this.node("proto",{proto:U},{prereduced:!0});or=(...U)=>this.schema(U.map((X)=>this.parse(X)));and=(...U)=>U.reduce((X,q)=>X.and(this.parse(q)),this.intrinsic.unknown);merge=(...U)=>U.reduce((X,q)=>X.merge(this.parse(q)),this.intrinsic.object);pipe=(...U)=>this.intrinsic.unknown.pipe(...U);fn=new p9(this);match=new l9(this);declare=()=>({type:this.type});define(U){return U}type=new o9(this);static scope=(U,X={})=>new x6(U,X);static module=(U,X={})=>this.scope(U,X).export()}var g2=Object.assign(x6.scope,{define:(U)=>U}),f=x6;class X8 extends X0{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var qY=T0(["base",I.object],["props",I.object])((U)=>U.base.merge(U.props),X8),q8=f.module({Key:I.key,Merge:qY});class Z8 extends X0{}var ZY=T0("element")((U)=>{let X=U.element.exclude(I.Array),q=X.array();return X.rawOr(q).pipe(l0).distribute((Z)=>Z.assertHasKind("morph").declareOut(q),v)},Z8),Q8=f.module({root:I.Array,readonly:"root",index:I.nonNegativeIntegerString,liftFrom:ZY},{name:"Array"});var r9=v(["string",_1.FileConstructor]),QY=r9.rawOr(r9.array()),G8=v({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:QY}}),Y8=f.module({root:["instanceof",FormData],value:r9,parsed:G8,parse:v({in:FormData,morphs:(U)=>{let X={};for(let[q,Z]of U)if(q in X){let Q=X[q];if(typeof Q==="string"||Q instanceof _1.FileConstructor)X[q]=[Q,Z];else Q.push(Z)}else X[q]=Z;return X},declaredOut:G8})},{name:"FormData"});var J8=f.module({Int8:["instanceof",Int8Array],Uint8:["instanceof",Uint8Array],Uint8Clamped:["instanceof",Uint8ClampedArray],Int16:["instanceof",Int16Array],Uint16:["instanceof",Uint16Array],Int32:["instanceof",Int32Array],Uint32:["instanceof",Uint32Array],Float32:["instanceof",Float32Array],Float64:["instanceof",Float64Array],BigInt64:["instanceof",BigInt64Array],BigUint64:["instanceof",BigUint64Array]},{name:"TypedArray"});var GY={Boolean:1,Number:1,String:1},H8=f.module({...S({...v4,...x4},(U,X)=>(U in GY)?[]:[U,["instanceof",X]]),Array:Q8,TypedArray:J8,FormData:Y8});var YY=v({domain:{domain:"number",meta:"a number representing a Unix timestamp"},divisor:{rule:1,meta:"an integer representing a Unix timestamp"},min:{rule:-8640000000000000,meta:"a Unix timestamp after -8640000000000000"},max:{rule:8640000000000000,meta:"a Unix timestamp before 8640000000000000"},meta:"an integer representing a safe Unix timestamp"}),JY=v({domain:"number",divisor:1}),u6=f.module({root:I.number,integer:JY,epoch:YY,safe:v({domain:{domain:"number",numberAllowsNaN:!1},min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}),NaN:["===",Number.NaN],Infinity:["===",Number.POSITIVE_INFINITY],NegativeInfinity:["===",Number.NEGATIVE_INFINITY]},{name:"number"});var l=(U,X,q)=>{let Z={domain:"string",pattern:{rule:U.source,flags:U.flags,meta:X}};if(q)Z.meta={format:q};return u1("intersection",Z)},W8=l($2,"a well-formed integer string"),D8=f.module({root:W8,parse:v({in:W8,morphs:(U,X)=>{let q=Number.parseInt(U);return Number.isSafeInteger(q)?q:X.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:I.integer})},{name:"string.integer"}),HY=l(/^[\dA-Fa-f]+$/,"hex characters only"),WY=f.module({root:l(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:l(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),_8=l(/^[A-Z].*$/,"capitalized"),_Y=f.module({root:v({in:"string",morphs:(U)=>U.charAt(0).toUpperCase()+U.slice(1),declaredOut:_8}),preformatted:_8},{name:"string.capitalize"}),$Y=(U)=>{let X=U.replace(/[ -]+/g,""),q=0,Z,Q,G=!1;for(let Y=X.length-1;Y>=0;Y--){if(Z=X.substring(Y,Y+1),Q=Number.parseInt(Z,10),G)Q*=2,q+=Q>=10?Q%10+1:Q;else q+=Q;G=!G}return!!(q%10===0?X:!1)},LY=/^(?:4\d{12}(?:\d{3,6})?|5[1-5]\d{14}|(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}|6(?:011|5\d\d)\d{12,15}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|(?:2131|1800|35\d{3})\d{11}|6[27]\d{14}|^(81\d{14,17}))$/,zY=v({domain:"string",pattern:{meta:"a credit card number",rule:LY.source},predicate:{meta:"a credit card number",predicate:$Y}});var FY=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([,.]\d+(?!:))?)?(\17[0-5]\d([,.]\d+)?)?([Zz]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;var AY=(U)=>!Number.isNaN(new Date(U).valueOf()),$8=v({domain:"string",predicate:{meta:"a parsable date",predicate:AY}}).assertHasKind("intersection"),L8=D8.root.internal.narrow((U,X)=>{let q=Number.parseInt(U),Z=u6.epoch(q);if(Z instanceof W0)return X.errors.merge(Z),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),OY=f.module({root:L8,parse:v({in:L8,morphs:(U)=>new Date(U),declaredOut:I.Date})},{name:"string.date.epoch"}),z8=l(FY,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),BY=f.module({root:z8,parse:v({in:z8,morphs:(U)=>new Date(U),declaredOut:I.Date})},{name:"string.date.iso"}),TY=f.module({root:$8,parse:v({declaredIn:$8,in:"string",morphs:(U,X)=>{let q=new Date(U);if(Number.isNaN(q.valueOf()))return X.error("a parsable date");return q},declaredOut:I.Date}),iso:BY,epoch:OY},{name:"string.date"}),VY=l(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),F8="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",n0=`(${F8}[.]){3}${F8}`,RY=new RegExp(`^${n0}$`),c="(?:[0-9a-fA-F]{1,4})",DY=new RegExp(`^((?:${c}:){7}(?:${c}|:)|(?:${c}:){6}(?:${n0}|:${c}|:)|(?:${c}:){5}(?::${n0}|(:${c}){1,2}|:)|(?:${c}:){4}(?:(:${c}){0,1}:${n0}|(:${c}){1,3}|:)|(?:${c}:){3}(?:(:${c}){0,2}:${n0}|(:${c}){1,4}|:)|(?:${c}:){2}(?:(:${c}){0,3}:${n0}|(:${c}){1,5}|:)|(?:${c}:){1}(?:(:${c}){0,4}:${n0}|(:${c}){1,6}|:)|(?::((?::${c}){0,5}:${n0}|(?::${c}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),MY=f.module({root:["v4 | v6","@","an IP address"],v4:l(RY,"an IPv4 address","ipv4"),v6:l(DY,"an IPv6 address","ipv6")},{name:"string.ip"}),d1="a JSON string",M8=(U)=>{if(!(U instanceof SyntaxError))throw U;return`must be ${d1} (${U})`},wY=v({meta:d1,domain:"string",predicate:{meta:d1,predicate:(U,X)=>{try{return JSON.parse(U),!0}catch(q){return X.reject({code:"predicate",expected:d1,problem:M8(q)})}}}}),PY=(U,X)=>{if(U.length===0)return X.error({code:"predicate",expected:d1,actual:"empty"});try{return JSON.parse(U)}catch(q){return X.error({code:"predicate",expected:d1,problem:M8(q)})}},IY=f.module({root:wY,parse:v({meta:"safe JSON string parser",in:"string",morphs:PY,declaredOut:I.jsonObject})},{name:"string.json"}),A8=l(/^[a-z]*$/,"only lowercase letters"),KY=f.module({root:v({in:"string",morphs:(U)=>U.toLowerCase(),declaredOut:A8}),preformatted:A8},{name:"string.lower"}),w8=["NFC","NFD","NFKC","NFKD"],y2=S(w8,(U,X)=>[X,v({domain:"string",predicate:(q)=>q.normalize(X)===q,meta:`${X}-normalized unicode`})]),m6=S(w8,(U,X)=>[X,v({in:"string",morphs:(q)=>q.normalize(X),declaredOut:y2[X]})]),NY=f.module({root:m6.NFC,preformatted:y2.NFC},{name:"string.normalize.NFC"}),CY=f.module({root:m6.NFD,preformatted:y2.NFD},{name:"string.normalize.NFD"}),SY=f.module({root:m6.NFKC,preformatted:y2.NFKC},{name:"string.normalize.NFKC"}),EY=f.module({root:m6.NFKD,preformatted:y2.NFKD},{name:"string.normalize.NFKD"}),jY=f.module({root:"NFC",NFC:NY,NFD:CY,NFKC:SY,NFKD:EY},{name:"string.normalize"}),O8=l($6,"a well-formed numeric string"),bY=f.module({root:O8,parse:v({in:O8,morphs:(U)=>Number.parseFloat(U),declaredOut:I.number})},{name:"string.numeric"}),B8="a regex pattern",fY=v({domain:"string",predicate:{meta:B8,predicate:(U,X)=>{try{return new RegExp(U),!0}catch(q){return X.reject({code:"predicate",expected:B8,problem:String(q)})}}},meta:{format:"regex"}}),gY=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/,yY=l(gY,"a semantic version (see https://semver.org/)"),T8=l(/^\S.*\S$|^\S?$/,"trimmed"),kY=f.module({root:v({in:"string",morphs:(U)=>U.trim(),declaredOut:T8}),preformatted:T8},{name:"string.trim"}),V8=l(/^[A-Z]*$/,"only uppercase letters"),vY=f.module({root:v({in:"string",morphs:(U)=>U.toUpperCase(),declaredOut:V8}),preformatted:V8},{name:"string.upper"}),hY=(U)=>URL.canParse(U),R8=v({domain:"string",predicate:{meta:"a URL string",predicate:hY},meta:{format:"uri"}}),xY=f.module({root:R8,parse:v({declaredIn:R8,in:"string",morphs:(U,X)=>{try{return new URL(U)}catch{return X.error("a URL string")}},declaredOut:v(URL)})},{name:"string.url"}),uY=f.module({root:["versioned | nil | max","@",{description:"a UUID",format:"uuid"}],"#nil":"'00000000-0000-0000-0000-000000000000'","#max":"'ffffffff-ffff-ffff-ffff-ffffffffffff'","#versioned":/[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}/i,v1:l(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:l(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:l(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:l(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:l(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:l(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:l(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:l(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),P8=f.module({root:I.string,alpha:l(/^[A-Za-z]*$/,"only letters"),alphanumeric:l(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:HY,base64:WY,capitalize:_Y,creditCard:zY,date:TY,digits:l(/^\d*$/,"only digits 0-9"),email:VY,integer:D8,ip:MY,json:IY,lower:KY,normalize:jY,numeric:bY,regex:fY,semver:yY,trim:kY,upper:vY,url:xY,uuid:uY},{name:"string"});var I8=f.module({bigint:I.bigint,boolean:I.boolean,false:I.false,never:I.never,null:I.null,number:I.number,object:I.object,string:I.string,symbol:I.symbol,true:I.true,unknown:I.unknown,undefined:I.undefined}),K8=f.module({root:I.unknown,any:I.unknown},{name:"unknown"}),mY=f.module({root:I.jsonObject,stringify:u1("morph",{in:I.jsonObject,morphs:(U)=>JSON.stringify(U),declaredOut:I.string})},{name:"object.json"}),N8=f.module({root:I.object,json:mY},{name:"object"});class C8 extends X0{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var pY=T0(["K",I.key],"V")((U)=>({domain:"object",index:{signature:U.K,value:U.V}}),C8);class S8 extends X0{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var lY=T0(["T",I.object],["K",I.key])((U)=>U.T.pick(U.K),S8);class E8 extends X0{description='omit a set of properties from an object like `Omit(User, "age")`'}var dY=T0(["T",I.object],["K",I.key])((U)=>U.T.omit(U.K),E8);class j8 extends X0{description="make all named properties of an object optional like `Partial(User)`"}var cY=T0(["T",I.object])((U)=>U.T.partial(),j8);class b8 extends X0{description="make all named properties of an object required like `Required(User)`"}var iY=T0(["T",I.object])((U)=>U.T.required(),b8);class f8 extends X0{description='exclude branches of a union like `Exclude("boolean", "true")`'}var sY=T0("T","U")((U)=>U.T.exclude(U.U),f8);class g8 extends X0{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var oY=T0("T","U")((U)=>U.T.extract(U.U),g8),y8=f.module({Exclude:sY,Extract:oY,Omit:dY,Partial:cY,Pick:lY,Record:pY,Required:iY});var x0=g2({...I8,...y8,...H8,...q8,string:P8,number:u6,object:N8,unknown:K8},{prereducedAliases:!0,name:"ark"}),a=x0.export();Object.assign(l1.ambient,a);l1.typeAttachments={string:a.string.root,number:a.number.root,bigint:a.bigint,boolean:a.boolean,symbol:a.symbol,undefined:a.undefined,null:a.null,object:a.object.root,unknown:a.unknown.root,false:a.false,true:a.true,never:a.never,arrayIndex:a.Array.index,Key:a.Key,Record:a.Record,Array:a.Array.root,Date:a.Date};var n9=Object.assign(x0.type,l1.typeAttachments),rY=x0.match,nY=x0.fn,aY=x0.generic,IN=x0.schema,tY=x0.define,eY=x0.declare;var z1=g2({Operator:"'EQ' | '==' | 'NEQ' | '!=' | 'GT' | '>' | 'GTE' | '>=' | 'LT' | '<' | 'LTE' | '<=' | 'IN' | 'NOT_IN' | 'CONTAINS' | 'MATCHES' | 'RANGE' | 'SINCE' | 'AFTER' | 'BEFORE' | 'UNTIL'",Condition:"RangeCondition | ListCondition | ContainsCondition | NumericCondition | RegexCondition | BasicCondition",RangeCondition:{field:"string > 0",operator:"'RANGE'",value:"unknown[] == 2"},ListCondition:{field:"string > 0",operator:"'IN' | 'NOT_IN'",value:"unknown[]"},ContainsCondition:{field:"string > 0",operator:"'CONTAINS' | 'NOT_CONTAINS'",value:"string | unknown[]"},StringOperatorCondition:{field:"string > 0",operator:"'STARTS_WITH' | 'ENDS_WITH'",value:"string"},HasKeyCondition:{field:"string > 0",operator:"'HAS_KEY'",value:"string"},NullCondition:{field:"string > 0",operator:"'IS_NULL' | 'IS_NONE'",value:"null"},EmptyCondition:{field:"string > 0",operator:"'IS_EMPTY'",value:"null"},NumericCondition:{field:"string > 0",operator:"'>' | '>=' | '<' | '<=' | 'GT' | 'GTE' | 'LT' | 'LTE'",value:"number | string"},RegexCondition:{field:"string > 0",operator:"'MATCHES'",value:"string"},BasicCondition:{field:"string > 0",operator:"Operator",value:"unknown"},ConditionGroup:{operator:"'AND' | 'OR'",conditions:"(Condition | ConditionGroup)[] >= 1"},RuleCondition:"Condition | ConditionGroup",Action:{"type?":"string > 0","params?":"object","delay?":"number.integer >= 0 | string","probability?":"0 <= number <= 1 | string","if?":"RuleCondition | RuleCondition[]","then?":"Action | ActionGroup","else?":"Action | ActionGroup","break?":"boolean","continue?":"boolean"},ActionGroup:{"mode?":"'ALL' | 'EITHER' | 'SEQUENCE'",actions:"(Action | ActionGroup)[] >= 1"},RuleAction:"Action | ActionGroup",TriggerRule:{id:"string > 0","name?":"string","description?":"string","priority?":"number.integer","enabled?":"boolean","cooldown?":"number.integer >= 0","tags?":"string[]",on:"string > 0","if?":"RuleCondition | RuleCondition[]",do:"RuleAction | RuleAction[]","comment?":"string"}}).export(),lN=z1.Operator,dN=z1.Condition,cN=z1.ConditionGroup,iN=z1.RuleCondition,sN=z1.Action,oN=z1.ActionGroup,UJ=z1.TriggerRule;class a9{static validate(U){let X=UJ(U);if(X instanceof n9.errors){let Q=[];for(let G of X){let Y=G.path.join("."),J=G.message,H=void 0;if(Y.endsWith("on")&&(J.includes("string")||J.includes("must be")))if(typeof U==="object"&&U!==null&&"on"in U&&U.on===!0)J="The 'on' field is incorrect (boolean true found).",H=`In YAML, 'on' is a boolean keyword (true). Quote it: "on": "EventName"`;else H="Ensure 'on' is a string event name.";Q.push({path:Y,message:J,suggestion:H,severity:"error"})}return{valid:!1,issues:Q}}let q=X,Z=[];if(this.validateConditionsRecursive(q.if,Z,"if"),Z.length>0)return{valid:!1,issues:Z};return{valid:!0,rule:q}}static validateConditionsRecursive(U,X,q){if(!U)return;if(Array.isArray(U)){U.forEach((Z,Q)=>{this.validateConditionsRecursive(Z,X,`${q}.${Q}`)});return}if(typeof U==="object"&&U!==null&&"conditions"in U&&Array.isArray(U.conditions)){U.conditions.forEach((Z,Q)=>{this.validateConditionsRecursive(Z,X,`${q}.conditions.${Q}`)});return}if(typeof U==="object"&&U!==null&&"operator"in U&&"value"in U)this.validateConditionValue(U,X,q)}static validateConditionValue(U,X,q){let{operator:Z,value:Q}=U;if(typeof Z==="string"&&["IN","NOT_IN","RANGE","CONTAINS","NOT_CONTAINS"].includes(Z)){if(Z==="CONTAINS"){if(typeof Q!=="string"&&!Array.isArray(Q))X.push({path:`${q}.value`,message:`Incorrect value type: Operator 'CONTAINS' expects a String or List (Array), but received ${typeof Q}.`,suggestion:"Use a substring or a list of items.",severity:"error"});return}if(!Array.isArray(Q)){X.push({path:`${q}.value`,message:`Incorrect value type: Operator '${Z}' expects a List (Array), but received ${typeof Q}.`,suggestion:Z==="RANGE"?"Use format [min, max]":"Use format [item1, item2]",severity:"error"});return}if(Z==="RANGE"){if(Q.length!==2)X.push({path:`${q}.value`,message:"Invalid Range: Operator 'RANGE' requires exactly 2 values (min and max).",suggestion:"Use format [min, max], e.g. [1, 10]",severity:"error"});else if(typeof Q[0]!=="number"&&typeof Q[0]!=="string")X.push({path:`${q}.value`,message:"Incorrect range type: Range values must be numbers or expression strings.",severity:"error"})}}else if(Z==="MATCHES")if(typeof Q!=="string")X.push({path:`${q}.value`,message:`Incorrect value type: Operator 'MATCHES' expects a string (regex pattern), but received ${typeof Q}.`,severity:"error"});else try{new RegExp(Q)}catch(G){X.push({path:`${q}.value`,message:`Invalid Regex pattern: ${G.message}`,severity:"error"})}else if(typeof Z==="string"&&["GT","GTE","LT","LTE",">",">=","<","<="].includes(Z)){if(typeof Q!=="number"&&typeof Q!=="string")X.push({path:`${q}.value`,message:`Incorrect value type: Operator '${Z}' expects a number or expression string, but received ${typeof Q}.`,severity:"error"})}else if(typeof Z==="string"&&["STARTS_WITH","ENDS_WITH"].includes(Z)){if(typeof Q!=="string")X.push({path:`${q}.value`,message:`Incorrect value type: Operator '${Z}' expects a string, but received ${typeof Q}.`,severity:"error"})}else if(Z==="HAS_KEY"){if(typeof Q!=="string")X.push({path:`${q}.value`,message:`Incorrect value type: Operator 'HAS_KEY' expects a string (key name), but received ${typeof Q}.`,severity:"error"})}}}class p6{conditions=[];op="AND";constructor(U="AND"){this.op=U}where(U,X,q){return this.conditions.push({field:U,operator:X,value:q}),this}and(U){let X=new p6("AND");return this.conditions.push(U(X).build()),this}or(U){let X=new p6("OR");return this.conditions.push(U(X).build()),this}build(){if(this.conditions.length===0)throw Error("Condition group must have at least one condition");if(this.conditions.length===1&&this.op==="AND")return this.conditions[0];return{operator:this.op,conditions:this.conditions}}}class k8{actions=[];mode="ALL";setMode(U){return this.mode=U,this}add(U,X,q){return this.actions.push({type:U,params:X,...q}),this}build(){if(this.actions.length===0)throw Error("Action group must have at least one action");if(this.actions.length===1&&this.mode==="ALL")return this.actions[0];if(this.mode==="ALL")return this.actions;return{mode:this.mode,actions:this.actions}}}class XJ{rule={enabled:!0,priority:0};withId(U){return this.rule.id=U,this}withName(U){return this.rule.name=U,this}withDescription(U){return this.rule.description=U,this}withPriority(U){return this.rule.priority=U,this}withCooldown(U){return this.rule.cooldown=U,this}withTags(U){return this.rule.tags=U,this}on(U){return this.rule.on=U,this}if(U,X,q){if(!this.rule.if)this.rule.if={field:U,operator:X,value:q};else if(Array.isArray(this.rule.if))this.rule.if.push({field:U,operator:X,value:q});else this.rule.if=[this.rule.if,{field:U,operator:X,value:q}];return this}ifComplex(U){let X=new p6,q=U(X).build();return this.rule.if=q,this}do(U,X,q){let Z={type:U,params:X,...q};if(!this.rule.do)this.rule.do=Z;else if(Array.isArray(this.rule.do))this.rule.do.push(Z);else if(this.rule.do&&typeof this.rule.do==="object"&&"actions"in this.rule.do)this.rule.do.actions.push(Z);else this.rule.do=[this.rule.do,Z];return this}doComplex(U){let X=new k8,q=U(X).build();return this.rule.do=q,this}build(){if(!this.rule.id)throw Error("Rule ID is required");if(!this.rule.on)throw Error("Rule 'on' event is required");if(!this.rule.do)throw Error("Rule 'do' action is required");return this.rule}}var cQ=FX(WX(),1);class XO{static toYaml(U){let X=Array.isArray(U)?U:[U];return cQ.default.stringify(X)}static async saveToFile(U,X){let q=this.toYaml(U);if(typeof process<"u"&&process.versions&&process.versions.node){let Z=await import("fs/promises"),G=(await import("path")).dirname(X);await Z.mkdir(G,{recursive:!0}),await Z.writeFile(X,q,"utf8")}else throw Error("saveToFile is only supported in Node.js/Bun environments")}}import{existsSync as iQ,mkdirSync as qO,readFileSync as ZO,writeFileSync as QO}from"fs";import{dirname as GO}from"path";class YO{filePath;cache=new Map;isLoaded=!1;constructor(U){this.filePath=U}ensureLoaded(){if(this.isLoaded)return;try{if(iQ(this.filePath)){let U=ZO(this.filePath,"utf-8"),X=JSON.parse(U);this.cache=new Map(Object.entries(X))}}catch(U){console.error(`[FilePersistence] Failed to load state from ${this.filePath}:`,U),this.cache=new Map}this.isLoaded=!0}persist(){try{let U=GO(this.filePath);if(!iQ(U))qO(U,{recursive:!0});let X=Object.fromEntries(this.cache);QO(this.filePath,JSON.stringify(X,null,2),"utf-8")}catch(U){console.error(`[FilePersistence] Failed to save state to ${this.filePath}:`,U)}}async loadState(){return this.ensureLoaded(),new Map(this.cache)}async saveState(U,X){this.ensureLoaded(),this.cache.set(U,X),this.persist()}async deleteState(U){this.ensureLoaded(),this.cache.delete(U),this.persist()}async clearState(){this.cache.clear(),this.persist()}}import*as q2 from"path";import*as D1 from"fs";var sQ=FX(WX(),1);class JO{static async loadRulesFromDir(U){let X=[],q=async(Z)=>{let Q;try{Q=await D1.promises.readdir(Z,{withFileTypes:!0})}catch(G){console.error(`[TriggerLoader] Failed to readdir ${Z}:`,G);return}for(let G of Q){let Y=q2.resolve(Z,G.name);if(G.isDirectory())await q(Y);else if(Y.toLowerCase().endsWith(".yaml")||Y.toLowerCase().endsWith(".yml"))try{let J=await this.loadRule(Y);X.push(...J)}catch(J){console.error(`Failed to load rule from ${Y}:`,J)}}};if(D1.existsSync(U))await q(U);else console.warn(`[TriggerLoader] Directory not found: ${U}`);return X}static async loadRule(U){try{let X=await D1.promises.readFile(U,"utf-8"),q=sQ.parseAllDocuments(X);for(let Y of q)if(Y.errors&&Y.errors.length>0)throw Error(`YAML syntax error in ${U}: ${Y.errors.map((J)=>J.message).join(", ")}`);let Z=q.map((Y)=>Y.toJS()),Q=[],G=[];return Z.forEach((Y)=>{if(Array.isArray(Y))G.push(...Y);else G.push(Y)}),G.forEach((Y,J)=>{if(Y&&typeof Y==="object"&&Y!==null&&"actions"in Y&&!Y.do)Y.do=Y.actions;let H=a9.validate(Y);if(H.valid){let W=H.rule;if(!W.id&&typeof Y==="object"&&Y!==null){let $=q2.basename(U,q2.extname(U));W.id=G.length>1?`${$}-${J}`:$}Q.push(W)}else console.error(`
185
- [TriggerLoader] ⚠️ Validation Problem in ${U} (item #${J+1})`),H.issues.forEach((W)=>{if(console.error(` - [${W.path}] ${W.message}`),W.suggestion)console.error(` \uD83D\uDCA1 Suggestion: ${W.suggestion}`)})}),Q}catch(X){throw console.error(`Error parsing YAML file ${U}:`,X),X}}static watchRules(U,X){return this.loadRulesFromDir(U).then(X),console.log(`[TriggerLoader] Watching for changes in ${U}...`),D1.watch(U,{recursive:!0},async(Z,Q)=>{if(Q&&(String(Q).endsWith(".yaml")||String(Q).endsWith(".yml"))){console.log(`[TriggerLoader] Detected change in ${Q} (${Z}). Reloading rules...`);try{let G=await this.loadRulesFromDir(U);X(G),console.log(`[TriggerLoader] Reloaded ${G.length} rules.`)}catch(G){console.error("[TriggerLoader] Failed to reload rules:",G)}}})}}export{N0 as triggerEmitter,H6 as ruleEvents,FO as engineEvents,a9 as TriggerValidator,Y6 as TriggerUtils,UJ as TriggerRuleSchema,JO as TriggerLoader,G2 as TriggerEngine,f4 as TriggerEmitter,U0 as StateManager,XO as RuleExporter,TX as RuleEvent,g4 as RuleEngine,iN as RuleConditionSchema,XJ as RuleBuilder,b4 as InMemoryPersistence,YO as FilePersistence,e as ExpressionEngine,tQ as EventQueue,J6 as EngineEvent,G2 as Engine,UG as ContextAdapter,dN as ConditionSchema,cN as ConditionGroupSchema,p6 as ConditionBuilder,lN as ComparisonOperatorSchema,eQ as BrowserPersistence,g4 as AdvancedRuleEngine,sN as ActionSchema,I1 as ActionRegistry,oN as ActionGroupSchema,k8 as ActionBuilder};
183
+ `)+"}");class N6{config;resolvedConfig;name;get[Z0](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(U,X){if(this.config=T2(O.config,X),this.resolvedConfig=T2(O.resolvedConfig,X),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(C9).length}`,this.name in C9)F(`A Scope already named ${this.name} already exists`);C9[this.name]=this;let q=Object.entries(U).map((Z)=>this.preparseOwnAliasEntry(...Z));for(let[Z,Q]of q){let G=Z;if(Z[0]==="#"){if(G=Z.slice(1),G in this.aliases)F(YZ(G));this.aliases[G]=Q}else{if(G in this.aliases)F(YZ(Z));this.aliases[G]=Q,this.exportedNames.push(G)}if(!M(Q,"module")&&!M(Q,"generic")&&!d0(Q)){let Y=this.preparseOwnDefinitionFormat(Q,{alias:G});this.resolutions[G]=M(Y,"root")?this.bindReference(Y):this.createParseContext(Y).id}}JZ??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[JZ.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=O.intrinsic?S(O.intrinsic,(Z,Q)=>Z.startsWith("json")?[]:[Z,this.bindReference(Q)]):{}}cacheGetter(U,X){return Object.defineProperty(this,U,{value:X}),X}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema(U){return U}generic=(...U)=>{let X=this;return(q,Z)=>new r0(U,Z?new V6(q):q,X,X,Z??null)};units=(U,X)=>{let q=[];for(let Q of U)if(!q.includes(Q))q.push(Q);let Z=q.map((Q)=>this.node("unit",{unit:Q},X));return this.node("union",Z,{...X,prereduced:!0})};lazyResolutions=[];lazilyResolve(U,X){let q=this.node("alias",{reference:X??"synthetic",resolve:U},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(q);return q}schema=(U,X)=>this.finalize(this.parseSchema(U,X));parseSchema=(U,X)=>this.node(M2(U),U,X);preparseNode(U,X,q){let Z=typeof U==="string"?U:M2(X,U);if(x(X)&&X.kind===Z)return X;if(Z==="alias"&&!q?.prereduced){let{reference:Y}=C2.implementation.normalize(X,this);if(Y.startsWith("$")){let J=this.resolveRoot(Y.slice(1));X=J,Z=J.kind}}else if(Z==="union"&&G0(X,"object")){let Y=W7(X);if(Y?.length===1)X=Y[0],Z=M2(X)}if(x(X)&&X.kind===Z)return X;let G=k1[Z].normalize?.(X,this)??X;if(x(G))return G.kind===Z?G:_7(Z,G.kind);return{...q,$:this,kind:Z,def:G,prefix:q.alias??Z}}bindReference(U){let X;if(x(U))X=U.$===this?U:new U.constructor(U.attachments,this);else X=U.$===this?U:new r0(U.params,U.bodyDef,U.$,this,U.hkt);if(!this.resolved)Object.assign(this.referencesById,X.referencesById);return X}resolveRoot(U){return this.maybeResolveRoot(U)??F(j9(U))}maybeResolveRoot(U){let X=this.maybeResolve(U);if(M(X,"generic"))return;return X}maybeResolveSubalias(U){return S9(this.aliases,U)??S9(this.ambient,U)}get ambient(){return O.ambient}maybeResolve(U){let X=this.resolutions[U];if(X){if(typeof X!=="string")return this.bindReference(X);let Z=Q0[X];if(M(Z,"root"))return this.resolutions[U]=Z;if(M(Z,"context")){if(Z.phase==="resolving")return this.node("alias",{reference:`$${U}`},{prereduced:!0});if(Z.phase==="resolved")return y(`Unexpected resolved context for was uncached by its scope: ${E(Z)}`);Z.phase="resolving";let Q=this.bindReference(this.parseOwnDefinitionFormat(Z.def,Z));return Z.phase="resolved",Q0[Q.id]=Q,Q0[Z.id]=Q,this.resolutions[U]=Q}return y(`Unexpected nodesById entry for ${X}: ${E(Z)}`)}let q=this.aliases[U]??this.ambient?.[U];if(!q)return this.maybeResolveSubalias(U);if(q=this.normalizeRootScopeValue(q),M(q,"generic"))return this.resolutions[U]=this.bindReference(q);if(M(q,"module")){if(!q.root)F(FZ(U));return this.resolutions[U]=this.bindReference(q.root)}return this.resolutions[U]=this.parse(q,{alias:U})}createParseContext(U){let X=U.id??$9(U.prefix);return Q0[X]=Object.assign(U,{[Z0]:"context",$:this,id:X,phase:"unresolved"})}traversal(U){return new w0(U,this.resolvedConfig)}import(...U){return new x1(S(this.export(...U),(X,q)=>[`#${X}`,q]))}precompilation;_exportedResolutions;_exports;export(...U){if(!this._exports){this._exports={};for(let q of this.exportedNames){let Z=this.aliases[q];this._exports[q]=M(Z,"module")?N9(Z,this):HZ(this.maybeResolve(q))}for(let q of this.lazyResolutions)q.resolution;if(this._exportedResolutions=zZ(this,this._exports),this._json=LZ(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let q=$Z(this.references);this.precompilation=q.write(WZ,4),_Z(this.references,q)}this.resolved=!0}let X=U.length?U:this.exportedNames;return new x1(S(X,(q,Z)=>[Z,this._exports[Z]]))}resolve(U){return this.export()[U]}node=(U,X,q={})=>{let Z=this.preparseNode(U,X,q);if(x(Z))return this.bindReference(Z);let Q=this.createParseContext(Z),G=L9(Q),Y=this.bindReference(G);return Q0[Q.id]=Y};parse=(U,X={})=>this.finalize(this.parseDefinition(U,X));parseDefinition(U,X={}){if(M(U,"root"))return this.bindReference(U);let q=this.preparseOwnDefinitionFormat(U,X);if(M(q,"root"))return this.bindReference(q);let Z=this.createParseContext(q);Q0[Z.id]=Z;let Q=this.bindReference(this.parseOwnDefinitionFormat(U,Z));if(Q.isCyclic)Q=Eq(Q,Z.id);return Q0[Z.id]=Q,Q}finalize(U){if(HZ(U),!U.precompilation&&!this.resolvedConfig.jitless)$7(U.references);return U}}class E9 extends N6{parseOwnDefinitionFormat(U,X){return L9(X)}preparseOwnDefinitionFormat(U,X){return this.preparseNode(M2(U),U,X)}preparseOwnAliasEntry(U,X){return[U,X]}normalizeRootScopeValue(U){return U}}var HZ=(U)=>{let X=U.references.filter((q)=>q.hasKind("alias"));for(let q of X){Object.assign(q.referencesById,q.resolution.referencesById);for(let Z of U.references)if(q.id in Z.referencesById)Object.assign(Z.referencesById,q.referencesById)}return U},LZ=(U)=>S(U,(X,q)=>[X,M(q,"root")||M(q,"generic")?q.json:M(q,"module")?LZ(q):y(`Unexpected resolution ${E(q)}`)]),S9=(U,X)=>{let q=X.indexOf(".");if(q===-1)return;let Z=X.slice(0,q),Q=U[Z];if(Q===void 0)return;if(!M(Q,"module"))return F(L7(Z));let G=X.slice(q+1),Y=Q[G];if(Y===void 0)return S9(Q,G);if(M(Y,"root")||M(Y,"generic"))return Y;if(M(Y,"module"))return Y.root??F(FZ(X));y(`Unexpected resolution for alias '${X}': ${E(Y)}`)},C6=(U,X)=>new E9(U,X),j2=new E9({});var zZ=(U,X)=>{let q={};for(let Z in X){let Q=X[Z];if(M(Q,"module")){let G=zZ(U,Q),Y=S(G,(J,H)=>[`${Z}.${J}`,H]);Object.assign(q,Y)}else if(M(Q,"root")||M(Q,"generic"))q[Z]=Q;else y(`Unexpected scope resolution ${E(Q)}`)}return q},j9=(U)=>`'${U}' is unresolvable`,L7=(U)=>`'${U}' must reference a module to be accessed using dot syntax`,FZ=(U)=>`Reference to submodule '${U}' must specify an alias`;j2.export();var{schema:v,node:u1,defineSchema:rw,generic:T0}=j2;var b9="^(?:0|[1-9]\\d*)$",z7=new RegExp(b9),tw=d(z7);var AZ=C6({bigint:"bigint",boolean:[{unit:!1},{unit:!0}],false:{unit:!1},never:[],null:{unit:null},number:"number",object:"object",string:"string",symbol:"symbol",true:{unit:!0},unknown:{},undefined:{unit:void 0},Array,Date},{prereducedAliases:!0}).export();O.intrinsic={...AZ};var OZ=C6({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:b9}},{prereducedAliases:!0}).export();Object.assign(O.intrinsic,OZ);var F7=C6({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),I={...AZ,...OZ,...F7,emptyStructure:u1("structure",{},{prereduced:!0})};O.intrinsic={...I};var S6=(U,X)=>new RegExp(U,X);Object.assign(S6,{as:S6});var TZ=(U)=>typeof U==="string"&&U[0]==="d"&&(U[1]==="'"||U[1]==='"')&&U[U.length-1]===U[1],BZ=(U)=>U.toString()!=="Invalid Date",VZ=(U)=>U.slice(2,-1),f9=(U)=>`'${U}' could not be parsed by the Date constructor`,RZ=(U,X)=>A7(U,X),A7=(U,X)=>{let q=new Date(U);if(BZ(q))return q;let Z=iX(U);if(Z!==void 0){let Q=new Date(Z);if(BZ(Q))return Q}return X?F(X===!0?f9(U):X):void 0};var O7=v({proto:"Array",sequence:"string",required:{key:"groups",value:["object",{unit:void 0}]}}),E6=(U,X)=>{let q=U.scanner.shiftUntilEscapable(T7[wZ[X]]);if(U.scanner.lookahead==="")return U.error(R7(q,X));if(U.scanner.shift(),X in MZ){let Z;try{Z=new RegExp(q)}catch(Q){F(String(Q))}if(U.root=U.ctx.$.node("intersection",{domain:"string",pattern:q},{prereduced:!0}),X==="x/")U.root=U.ctx.$.node("morph",{in:U.root,morphs:(Q)=>Z.exec(Q),declaredOut:O7})}else if(n(X,g9))U.root=U.ctx.$.node("unit",{unit:q});else{let Z=RZ(q,f9(q));U.root=U.ctx.$.node("unit",{meta:q,unit:Z})}},g9={"'":1,'"':1},DZ={"/":1,"'":1,'"':1},B7={"d'":"'",'d"':'"',"'":"'",'"':'"'},MZ={"/":"/","x/":"/"},wZ={...B7,...MZ},T7={"'":(U)=>U.lookahead==="'",'"':(U)=>U.lookahead==='"',"/":(U)=>U.lookahead==="/"},V7={'"':"double-quote","'":"single-quote","/":"forward slash"},R7=(U,X)=>`${X}${U} requires a closing ${V7[wZ[X]]}`;var PZ=(U)=>`Private type references should not include '#'. Use '${U}' instead.`,j6="Optional definitions like 'string?' are only valid as properties in an object or tuple",b6="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var j0={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...c0};var IZ=(U,X)=>U===">"?X[0]==="="?X[1]==="=":X.trimStart()===""||n(X.trimStart()[0],j0):U==="="?X[0]!=="=":U===","||U==="?";var KZ=(U,X,q)=>NZ(U,X,q,[]),NZ=(U,X,q,Z)=>{let Q=q.parseUntilFinalizer();if(Z.push(Q.root),Q.finalizer===">"){if(Z.length!==X.params.length)return q.error(y9(U,X.names,Z.map((G)=>G.expression)));return Z}if(Q.finalizer===",")return NZ(U,X,q,Z);return Q.error(z6(">"))},y9=(U,X,q)=>`${U}<${X.join(", ")}> requires exactly ${X.length} args (got ${q.length}${q.length===0?"":`: ${q.join(", ")}`})`;var f6=(U)=>{let X=U.scanner.shiftUntilLookahead(j0);if(X==="keyof")U.addPrefix("keyof");else U.root=M7(U,X)},D7=(U,X,q)=>{if(q.scanner.shiftUntilNonWhitespace(),q.scanner.shift()!=="<")return q.error(y9(U,X.names,[]));let Q=KZ(U,X,q);return X(...Q)},M7=(U,X)=>w7(U,X)??P7(U,X)??U.error(X===""?U.scanner.lookahead==="#"?PZ(U.shiftedBy(1).scanner.shiftUntilLookahead(j0)):k9(U):j9(X)),w7=(U,X)=>{if(U.ctx.args?.[X]){let Z=U.ctx.args[X];if(typeof Z!=="string")return Z;return U.ctx.$.node("alias",{reference:Z},{prereduced:!0})}let q=U.ctx.$.maybeResolve(X);if(M(q,"root"))return q;if(q===void 0)return;if(M(q,"generic"))return D7(X,q,U);return F(`Unexpected resolution ${E(q)}`)},P7=(U,X)=>{let q=sX(X);if(q!==void 0)return U.ctx.$.node("unit",{unit:q});let Z=rX(X);if(Z!==void 0)return U.ctx.$.node("unit",{unit:Z})},k9=(U)=>{let X=U.previousOperator();return X?v9(X,U.scanner.unscanned):I7(U.scanner.unscanned)},v9=(U,X="")=>`Token '${U}' requires a right operand${X?` before '${X}'`:""}`,I7=(U)=>`Expected an expression${U?` before '${U}'`:""}`;var h9=(U)=>U.scanner.lookahead===""?U.error(k9(U)):U.scanner.lookahead==="("?U.shiftedBy(1).reduceGroupOpen():U.scanner.lookaheadIsIn(DZ)?E6(U,U.scanner.shift()):U.scanner.lookaheadIsIn(c0)?h9(U.shiftedBy(1)):U.scanner.lookahead==="d"?U.scanner.nextLookahead in g9?E6(U,`${U.scanner.shift()}${U.scanner.shift()}`):f6(U):U.scanner.lookahead==="x"?U.scanner.nextLookahead==="/"?U.shiftedBy(2)&&E6(U,"x/"):f6(U):f6(U);var CZ={">":!0,">=":!0},SZ={"<":!0,"<=":!0};var m1={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},EZ=(U,X)=>`Left bounds are only valid when paired with right bounds (try ...${X}${U})`,g6=(U)=>`Left-bounded expressions must specify their limits using < or <= (was ${U})`,jZ=(U,X,q,Z)=>`An expression may have at most one left bound (parsed ${U}${m1[X]}, ${q}${m1[Z]})`;var fZ=(U,X)=>{let q=K7(U,X);if(U.root.hasKind("unit")){if(typeof U.root.unit==="number"){U.reduceLeftBound(U.root.unit,q),U.unsetRoot();return}if(U.root.unit instanceof Date){let Z=`d'${U.root.description??U.root.unit.toISOString()}'`;U.unsetRoot(),U.reduceLeftBound(Z,q);return}}return C7(U,q)},gZ={"<":1,">":1,"=":1},K7=(U,X)=>U.scanner.lookaheadIs("=")?`${X}${U.scanner.shift()}`:X;var bZ=(U,X,q,Z)=>{if(q.extends(O.intrinsic.number)){if(typeof X!=="number")return F(x9(U,X,Z));return U==="=="?["min","max"]:U[0]===">"?["min"]:["max"]}if(q.extends(O.intrinsic.lengthBoundable)){if(typeof X!=="number")return F(x9(U,X,Z));return U==="=="?["exactLength"]:U[0]===">"?["minLength"]:["maxLength"]}if(q.extends(O.intrinsic.Date))return U==="=="?["after","before"]:U[0]===">"?["after"]:["before"];return F(Bq(q.expression))},N7=(U)=>({rule:TZ(U.limit)?VZ(U.limit):U.limit,exclusive:U.comparator.length===1}),C7=(U,X)=>{let q=U.unsetRoot(),Z=U.scanner.location;U.parseOperand();let Q=U.unsetRoot(),G=U.scanner.sliceChars(Z,U.scanner.location);if(U.root=q,!Q.hasKind("unit")||typeof Q.unit!=="number"&&!(Q.unit instanceof Date))return U.error(x9(X,G,"right"));let Y=Q.unit,J=X.length===1,H=bZ(X,typeof Y==="number"?Y:G,q,"right");for(let $ of H)U.constrainRoot($,X==="=="?{rule:Y}:{rule:Y,exclusive:J});if(!U.branches.leftBound)return;if(!n(X,SZ))return U.error(g6(X));let W=bZ(U.branches.leftBound.comparator,U.branches.leftBound.limit,q,"left");U.constrainRoot(W[0],N7(U.branches.leftBound)),U.branches.leftBound=null},x9=(U,X,q)=>`Comparator ${q==="left"?m1[U]:U} must be ${q==="left"?"preceded":"followed"} by a corresponding literal (was ${X})`;var yZ=(U)=>{U.scanner.shiftUntilNonWhitespace();let X=U.scanner.shiftUntilLookahead(j0);U.root=U.root.brand(X)};var vZ=(U)=>{U.scanner.shiftUntilNonWhitespace();let X=U.scanner.shiftUntilLookahead(j0),q=oX(X,{errorOnFail:kZ(X)});if(q===0)U.error(kZ(0));U.root=U.root.constrain("divisor",q)},kZ=(U)=>`% operator must be followed by a non-zero integer literal (was ${U})`;var u9=(U)=>{let X=U.scanner.shift();return X===""?U.finalize(""):X==="["?U.scanner.shift()==="]"?U.setRoot(U.root.array()):U.error(S7):X==="|"?U.scanner.lookahead===">"?U.shiftedBy(1).pushRootToBranch("|>"):U.pushRootToBranch(X):X==="&"?U.pushRootToBranch(X):X===")"?U.finalizeGroup():IZ(X,U.scanner.unscanned)?U.finalize(X):n(X,gZ)?fZ(U,X):X==="%"?vZ(U):X==="#"?yZ(U):(X in c0)?u9(U):U.error(y6(X))},y6=(U,X="")=>`'${U}' is not allowed here${X&&` (should be ${X})`}`,S7="Missing expected ']'";var hZ=(U)=>{let X=U.unsetRoot();U.parseOperand();let q=U.unsetRoot();if(!q.hasKind("unit"))return U.error(E7(q.expression));let Z=q.unit instanceof Date?()=>new Date(q.unit):q.unit;return[X,"=",Z]},E7=(U)=>`Default value '${U}' must be a literal value`;var m9=(U,X)=>{let q=X.$.maybeResolveRoot(U);if(q)return q;if(U.endsWith("[]")){let G=X.$.maybeResolveRoot(U.slice(0,-2));if(G)return G.array()}let Z=new p1(new O2(U),X),Q=j7(Z);if(Z.finalizer===">")F(y6(">"));return Q},j7=(U)=>{U.parseOperand();let X=b2(U).root;if(!X)return y(`Root was unexpectedly unset after parsing string '${U.scanner.scanned}'`);if(U.finalizer==="=")X=hZ(U);else if(U.finalizer==="?")X=[X,"?"];if(U.scanner.shiftUntilNonWhitespace(),U.scanner.lookahead)F(y6(U.scanner.lookahead));return X},b2=(U)=>{while(U.finalizer===void 0)b7(U);return U},b7=(U)=>U.hasRoot()?U.parseOperator():U.parseOperand();class p1{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor(U,X){this.scanner=U,this.ctx=X}error(U){return F(U)}hasRoot(){return this.root!==void 0}setRoot(U){this.root=U}unsetRoot(){let U=this.root;return this.root=void 0,U}constrainRoot(...U){this.root=this.root.constrain(U[0],U[1])}finalize(U){if(this.groups.length)return this.error(z6(")"));this.finalizeBranches(),this.finalizer=U}reduceLeftBound(U,X){let q=m1[X];if(!n(q,CZ))return this.error(g6(X));if(this.branches.leftBound)return this.error(jZ(this.branches.leftBound.limit,this.branches.leftBound.comparator,U,q));this.branches.leftBound={comparator:q,limit:U}}finalizeBranches(){if(this.assertRangeUnset(),this.branches.pipe){this.pushRootToBranch("|>"),this.root=this.branches.pipe;return}if(this.branches.union){this.pushRootToBranch("|"),this.root=this.branches.union;return}if(this.branches.intersection){this.pushRootToBranch("&"),this.root=this.branches.intersection;return}this.applyPrefixes()}finalizeGroup(){this.finalizeBranches();let U=this.groups.pop();if(!U)return this.error(eX(")",this.scanner.unscanned));this.branches=U}addPrefix(U){this.branches.prefixes.push(U)}applyPrefixes(){while(this.branches.prefixes.length){let U=this.branches.prefixes.pop();this.root=U==="keyof"?this.root.keyof():y(`Unexpected prefix '${U}'`)}}pushRootToBranch(U){this.assertRangeUnset(),this.applyPrefixes();let X=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(X)??X,U==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,U==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return b2(new p1(this.scanner,this.ctx))}parseOperator(){return u9(this)}parseOperand(){return h9(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(EZ(this.branches.leftBound.limit,this.branches.leftBound.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={prefixes:[],leftBound:null,union:null,intersection:null,pipe:null}}previousOperator(){return this.branches.leftBound?.comparator??this.branches.prefixes[this.branches.prefixes.length-1]??(this.branches.intersection?"&":this.branches.union?"|":this.branches.pipe?"|>":void 0)}shiftedBy(U){return this.scanner.jumpForward(U),this}}var f7="An empty string is not a valid generic parameter name",k6=(U,X,q)=>{U.shiftUntilNonWhitespace();let Z=U.shiftUntilLookahead(j0);if(Z===""){if(U.lookahead===""&&X.length)return X;return F(f7)}return U.shiftUntilNonWhitespace(),g7(U,Z,X,q)},xZ="extends ",g7=(U,X,q,Z)=>{if(U.shiftUntilNonWhitespace(),U.unscanned.startsWith(xZ))U.jumpForward(xZ.length);else{if(U.lookahead===",")U.shift();return q.push(X),k6(U,q,Z)}let Q=b2(new p1(U,Z));return q.push([X,Q.root]),k6(U,q,Z)};class p9 extends H0{constructor(U){let X={$:U,raw:U.fn};super((...q)=>{let Z=q.indexOf(":"),Q=Z===-1?q.length-1:Z-1,G=q.slice(0,Q+1),Y=U.parse(G).assertHasKind("intersection"),J=U.intrinsic.unknown;if(Z!==-1){if(Z!==q.length-2)return F(y7);J=U.parse(q[Z+1])}return(H)=>new uZ(H,Y,J)},{attach:X})}}class uZ extends H0{raw;params;returns;expression;constructor(U,X,q){let Z=`typed ${U.name}`,Q={[Z]:(...Y)=>{let J=X.assert(Y),H=U(...J);return q.assert(H)}}[Z];super(Q);this.raw=U,this.params=X,this.returns=q;let G=X.expression;if(G[0]==="["&&G[G.length-1]==="]")G=G.slice(1,-1);else if(G.endsWith("[]"))G=`...${G}`;this.expression=`(${G}) => ${q?.expression??"unknown"}`}}var y7=`":" must be followed by exactly one return type e.g:
184
+ fn("string", ":", "number")(s => s.length)`;class l9 extends H0{$;constructor(U){super((...X)=>new f2(U)(...X),{bind:U});this.$=U}in(U){return new f2(this.$,U===void 0?void 0:this.$.parse(U))}at(U,X){return new f2(this.$).at(U,X)}case(U,X){return new f2(this.$).case(U,X)}}class f2 extends H0{$;in;key;branches=[];constructor(U,X){super((q)=>this.caseEntries(Object.entries(q).map(([Z,Q])=>Z==="default"?[Z,Q]:[this.$.parse(Z),Q])));this.$=U,this.in=X}at(U,X){if(this.key)F(v7);if(this.branches.length)F(k7);return this.key=U,X?this.match(X):this}case(U,X){return this.caseEntry(this.$.parse(U),X)}caseEntry(U,X){let Z=(this.key?this.$.parse({[this.key]:U}):U).pipe(X);return this.branches.push(Z),this}match(U){return this(U)}strings(U){return this.caseEntries(Object.entries(U).map(([X,q])=>X==="default"?[X,q]:[this.$.node("unit",{unit:X}),q]))}caseEntries(U){for(let X=0;X<U.length;X++){let[q,Z]=U[X];if(q==="default"){if(X!==U.length-1)F("default may only be specified as the last key of a switch definition");return this.default(Z)}if(typeof Z!=="function")return F(`Value for case "${q}" must be a function (was ${r(Z)})`);this.caseEntry(q,Z)}return this}default(U){if(typeof U==="function")this.case(I.unknown,U);let X={branches:this.branches,ordered:!0};if(U==="never"||U==="assert")X.meta={onFail:mZ};let q=this.$.node("union",X);if(!this.in)return this.$.finalize(q);let Z=this.in.pipe(q);if(U==="never"||U==="assert")Z=Z.configureReferences({onFail:mZ},"self");return this.$.finalize(Z)}}var mZ=(U)=>U.throw(),k7="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",v7="At most one key matcher may be specified per expression";var v6=(U,X)=>{if(h(U)){if(U[1]==="=")return[X.$.parseOwnDefinitionFormat(U[0],X),"=",U[2]];if(U[1]==="?")return[X.$.parseOwnDefinitionFormat(U[0],X),"?"]}return h6(U,X)},pZ="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",lZ="Only required keys may specify default values, e.g. { value: 'number = 0' }";var dZ=(U,X)=>{let q,Z={},Q=J1(U);for(let[Y,J]of Q){let H=u7(Y);if(H.kind==="spread"){if(!S0(Z))return F(x7);let A=X.$.parseOwnDefinitionFormat(J,X);if(A.equals(I.object))continue;if(!A.hasKind("intersection")||!A.basis?.equals(I.object))return F(m7(A.expression));q=A.structure;continue}if(H.kind==="undeclared"){if(J!=="reject"&&J!=="delete"&&J!=="ignore")F(h7(J));Z.undeclared=J;continue}let W=v6(J,X),$=H;if(H.kind==="required"){if(!h(W))d9(Z,"required",{key:H.normalized,value:W},X);else d9(Z,"optional",W[1]==="="?{key:H.normalized,value:W[0],default:W[2]}:{key:H.normalized,value:W[0]},X);continue}if(h(W)){if(W[1]==="?")F(pZ);if(W[1]==="=")F(lZ)}if(H.kind==="optional"){d9(Z,"optional",{key:H.normalized,value:W},X);continue}let _=X.$.parseOwnDefinitionFormat($.normalized,X),L=K6(_,W,X.$);if(L.index)Z.index=g(Z.index,L.index);if(L.required)Z.required=g(Z.required,L.required)}let G=X.$.node("structure",Z);return X.$.parseSchema({domain:"object",structure:q?.merge(G)??G})},d9=(U,X,q,Z)=>{U[X]=g(U[X],Z.$.node(X,q))},h7=(U)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${E(U)})`,x7="Spread operator may only be used as the first key in an object",u7=(U)=>typeof U==="symbol"?{kind:"required",normalized:U}:U[U.length-1]==="?"?U[U.length-2]===W1?{kind:"required",normalized:`${U.slice(0,-2)}?`}:{kind:"optional",normalized:U.slice(0,-1)}:U[0]==="["&&U[U.length-1]==="]"?{kind:"index",normalized:U.slice(1,-1)}:U[0]===W1&&U[1]==="["&&U[U.length-1]==="]"?{kind:"required",normalized:U.slice(1)}:U==="..."?{kind:"spread"}:U==="+"?{kind:"undeclared"}:{kind:"required",normalized:U==="\\..."?"...":U==="\\+"?"+":U},m7=(U)=>`Spread operand must resolve to an object literal type (was ${U})`;var iZ=(U,X)=>a7(U)?nZ[U[0]](U,X):r7(U)?rZ[U[1]](U,X):null,p7=(U,X)=>X.$.parseOwnDefinitionFormat(U[1],X).keyof(),c9=(U,X)=>{if(U[2]===void 0)return F(v9(U[1],""));let q=X.$.parseOwnDefinitionFormat(U[0],X),Z=X.$.parseOwnDefinitionFormat(U[2],X);if(U[1]==="|")return X.$.node("union",{branches:[q,Z]});let Q=U[1]==="&"?$0(q,Z,X.$):D2(q,Z,X.$);if(Q instanceof T)return Q.throw();return Q},l7=(U,X)=>X.$.parseOwnDefinitionFormat(U[0],X).array(),d7=(U,X)=>{if(typeof U[2]!=="function")return F(sZ("=>",U[2]));return X.$.parseOwnDefinitionFormat(U[0],X).pipe(U[2])},sZ=(U,X)=>`${U===":"?"Narrow":"Morph"} expression requires a function following '${U}' (was ${typeof X})`,c7=(U,X)=>{if(typeof U[2]!=="function")return F(sZ(":",U[2]));return X.$.parseOwnDefinitionFormat(U[0],X).constrain("predicate",U[2])},i7=(U,X)=>X.$.parseOwnDefinitionFormat(U[0],X).configure(U[2],U[3]),oZ=(U)=>U,s7=oZ({"[]":l7,"?":()=>F(j6)}),o7=oZ({"|":c9,"&":c9,":":c7,"=>":d7,"|>":c9,"@":i7,"=":()=>F(b6)}),rZ={...s7,...o7},r7=(U)=>rZ[U[1]]!==void 0,n7=(U)=>U,nZ=n7({keyof:p7,instanceof:(U,X)=>{if(typeof U[1]!=="function")return F(cZ(W2(U[1])));let q=U.slice(1).map((Z)=>typeof Z==="function"?X.$.node("proto",{proto:Z}):F(cZ(W2(Z))));return q.length===1?q[0]:X.$.node("union",{branches:q})},"===":(U,X)=>X.$.units(U.slice(1))}),a7=(U)=>nZ[U[0]]!==void 0,cZ=(U)=>`Expected a constructor following 'instanceof' operator (was ${U})`;var eZ=(U,X)=>{let q=[{}],Z=0;while(Z<U.length){let Q=!1;if(U[Z]==="..."&&Z<U.length-1)Q=!0,Z++;let G=v6(U[Z],X),[Y,J,H]=!h(G)?[G]:G;if(Z++,Q){if(!Y.extends(O.intrinsic.Array))return F(UY(Y.expression));q=q.flatMap((W)=>Y.distribute(($)=>e7(A6(W),$)))}else q=q.map((W)=>{if(J==="?")return U8(W,Y);if(J==="=")return t7(W,Y,H);return i9(W,Y)})}return X.$.parseSchema(q.map((Q)=>S0(Q)?{proto:Array,exactLength:0}:{proto:Array,sequence:Q}))},i9=(U,X)=>{if(U.defaultables||U.optionals)return F(U.variadic?P9:XY);if(U.variadic)U.postfix=g(U.postfix,X);else U.prefix=g(U.prefix,X);return U},U8=(U,X)=>{if(U.variadic)return F(X8);return U.optionals=g(U.optionals,X),U},t7=(U,X,q)=>{if(U.variadic)return F(X8);if(U.optionals)return F(qY);return U.defaultables=g(U.defaultables,[[X,q]]),U},aZ=(U,X)=>{if(U.postfix)F(tZ);if(U.variadic){if(!U.variadic.equals(X))F(tZ)}else U.variadic=X.internal;return U},e7=(U,X)=>{let q=X.select({method:"find",kind:"sequence"});if(!q)return aZ(U,O.intrinsic.unknown);if(q.prefix)for(let Z of q.prefix)i9(U,Z);if(q.optionals)for(let Z of q.optionals)U8(U,Z);if(q.variadic)aZ(U,q.variadic);if(q.postfix)for(let Z of q.postfix)i9(U,Z);return U},UY=(U)=>`Spread element must be an array (was ${U})`,tZ="A tuple may have at most one variadic element",XY="A required element may not follow an optional element",X8="An optional element may not follow a variadic element";var qY="A defaultable element may not follow an optional element without a default";var ZY={},h6=(U,X)=>{if(typeof U==="string"){if(X.args&&Object.keys(X.args).some((Z)=>U.includes(Z)))return m9(U,X);let q=ZY[X.$.name]??={};return q[U]??=m9(U,X)}return G0(U,"object")?QY(U,X):F(s9(r(U)))},QY=(U,X)=>{let q=H2(U);switch(q){case void 0:if(M(U,"root"))return U;if("~standard"in U)return GY(U,X);return dZ(U,X);case"Array":return YY(U,X);case"RegExp":return X.$.node("intersection",{domain:"string",pattern:U},{prereduced:!0});case"Function":{let Z=d0(U)?U():U;if(M(Z,"root"))return Z;return F(s9("Function"))}default:return F(s9(q??E(U)))}},GY=(U,X)=>X.$.intrinsic.unknown.pipe((q,Z)=>{let Q=U["~standard"].validate(q);if(!Q.issues)return Q.value;for(let{message:G,path:Y}of Q.issues)if(Y)if(Y.length)Z.error({problem:uX(G),relativePath:Y.map((J)=>typeof J==="object"?J.key:J)});else Z.error({message:G});else Z.error({message:G})}),YY=(U,X)=>iZ(U,X)??eZ(U,X),s9=(U)=>`Type definitions must be strings or objects (was ${U})`;class o9 extends H0{constructor(U){let X=Object.assign({errors:W0,hkt:X0,$:U,raw:U.parse,module:U.constructor.module,scope:U.constructor.scope,declare:U.declare,define:U.define,match:U.match,generic:U.generic,schema:U.schema,keywords:U.ambient,unit:U.unit,enumerated:U.enumerated,instanceOf:U.instanceOf,valueOf:U.valueOf,or:U.or,and:U.and,merge:U.merge,pipe:U.pipe,fn:U.fn},U.ambientAttachments);super((...q)=>{if(q.length===1)return U.parse(q[0]);if(q.length===2&&typeof q[0]==="string"&&q[0][0]==="<"&&q[0][q[0].length-1]===">"){let Z=q[0].slice(1,-1),Q=U.parseGenericParams(Z,{});return new r0(Q,q[1],U,U,null)}return U.parse(q)},{attach:X})}}var l1=O;class x6 extends N6{get ambientAttachments(){if(!l1.typeAttachments)return;return this.cacheGetter("ambientAttachments",S(l1.typeAttachments,(U,X)=>[U,this.bindReference(X)]))}preparseOwnAliasEntry(U,X){let q=U.indexOf("<");if(q===-1){if(M(X,"module")||M(X,"generic"))return[U,X];let G=this.name==="ark"?U:U==="root"?this.name:`${this.name}.${U}`,Y=this.resolvedConfig.keywords?.[G];if(Y)X=[X,"@",Y];return[U,X]}if(U[U.length-1]!==">")F("'>' must be the last character of a generic declaration in a scope");let Z=U.slice(0,q),Q=U.slice(q+1,-1);return[Z,()=>{let G=this.parseGenericParams(Q,{alias:Z});return Fq(G,X,this)}]}parseGenericParams(U,X){return k6(new O2(U),[],this.createParseContext({...X,def:U,prefix:"generic"}))}normalizeRootScopeValue(U){if(d0(U)&&!M(U,"generic"))return U();return U}preparseOwnDefinitionFormat(U,X){return{...X,def:U,prefix:X.alias??"type"}}parseOwnDefinitionFormat(U,X){if(!(X.alias&&(X.alias in this.aliases))&&!X.args)X.args={this:X.id};let Z=h6(U,X);if(h(Z)){if(Z[1]==="=")return F(b6);if(Z[1]==="?")return F(j6)}return Z}unit=(U)=>this.units([U]);valueOf=(U)=>this.units(jX(U));enumerated=(...U)=>this.units(U);instanceOf=(U)=>this.node("proto",{proto:U},{prereduced:!0});or=(...U)=>this.schema(U.map((X)=>this.parse(X)));and=(...U)=>U.reduce((X,q)=>X.and(this.parse(q)),this.intrinsic.unknown);merge=(...U)=>U.reduce((X,q)=>X.merge(this.parse(q)),this.intrinsic.object);pipe=(...U)=>this.intrinsic.unknown.pipe(...U);fn=new p9(this);match=new l9(this);declare=()=>({type:this.type});define(U){return U}type=new o9(this);static scope=(U,X={})=>new x6(U,X);static module=(U,X={})=>this.scope(U,X).export()}var g2=Object.assign(x6.scope,{define:(U)=>U}),f=x6;class q8 extends X0{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var JY=T0(["base",I.object],["props",I.object])((U)=>U.base.merge(U.props),q8),Z8=f.module({Key:I.key,Merge:JY});class Q8 extends X0{}var HY=T0("element")((U)=>{let X=U.element.exclude(I.Array),q=X.array();return X.rawOr(q).pipe(l0).distribute((Z)=>Z.assertHasKind("morph").declareOut(q),v)},Q8),G8=f.module({root:I.Array,readonly:"root",index:I.nonNegativeIntegerString,liftFrom:HY},{name:"Array"});var r9=v(["string",_1.FileConstructor]),WY=r9.rawOr(r9.array()),Y8=v({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:WY}}),J8=f.module({root:["instanceof",FormData],value:r9,parsed:Y8,parse:v({in:FormData,morphs:(U)=>{let X={};for(let[q,Z]of U)if(q in X){let Q=X[q];if(typeof Q==="string"||Q instanceof _1.FileConstructor)X[q]=[Q,Z];else Q.push(Z)}else X[q]=Z;return X},declaredOut:Y8})},{name:"FormData"});var H8=f.module({Int8:["instanceof",Int8Array],Uint8:["instanceof",Uint8Array],Uint8Clamped:["instanceof",Uint8ClampedArray],Int16:["instanceof",Int16Array],Uint16:["instanceof",Uint16Array],Int32:["instanceof",Int32Array],Uint32:["instanceof",Uint32Array],Float32:["instanceof",Float32Array],Float64:["instanceof",Float64Array],BigInt64:["instanceof",BigInt64Array],BigUint64:["instanceof",BigUint64Array]},{name:"TypedArray"});var _Y={Boolean:1,Number:1,String:1},W8=f.module({...S({...v4,...x4},(U,X)=>(U in _Y)?[]:[U,["instanceof",X]]),Array:G8,TypedArray:H8,FormData:J8});var $Y=v({domain:{domain:"number",meta:"a number representing a Unix timestamp"},divisor:{rule:1,meta:"an integer representing a Unix timestamp"},min:{rule:-8640000000000000,meta:"a Unix timestamp after -8640000000000000"},max:{rule:8640000000000000,meta:"a Unix timestamp before 8640000000000000"},meta:"an integer representing a safe Unix timestamp"}),LY=v({domain:"number",divisor:1}),u6=f.module({root:I.number,integer:LY,epoch:$Y,safe:v({domain:{domain:"number",numberAllowsNaN:!1},min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}),NaN:["===",Number.NaN],Infinity:["===",Number.POSITIVE_INFINITY],NegativeInfinity:["===",Number.NEGATIVE_INFINITY]},{name:"number"});var l=(U,X,q)=>{let Z={domain:"string",pattern:{rule:U.source,flags:U.flags,meta:X}};if(q)Z.meta={format:q};return u1("intersection",Z)},_8=l($2,"a well-formed integer string"),M8=f.module({root:_8,parse:v({in:_8,morphs:(U,X)=>{let q=Number.parseInt(U);return Number.isSafeInteger(q)?q:X.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:I.integer})},{name:"string.integer"}),zY=l(/^[\dA-Fa-f]+$/,"hex characters only"),FY=f.module({root:l(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:l(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),$8=l(/^[A-Z].*$/,"capitalized"),AY=f.module({root:v({in:"string",morphs:(U)=>U.charAt(0).toUpperCase()+U.slice(1),declaredOut:$8}),preformatted:$8},{name:"string.capitalize"}),OY=(U)=>{let X=U.replace(/[ -]+/g,""),q=0,Z,Q,G=!1;for(let Y=X.length-1;Y>=0;Y--){if(Z=X.substring(Y,Y+1),Q=Number.parseInt(Z,10),G)Q*=2,q+=Q>=10?Q%10+1:Q;else q+=Q;G=!G}return!!(q%10===0?X:!1)},BY=/^(?:4\d{12}(?:\d{3,6})?|5[1-5]\d{14}|(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}|6(?:011|5\d\d)\d{12,15}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|(?:2131|1800|35\d{3})\d{11}|6[27]\d{14}|^(81\d{14,17}))$/,TY=v({domain:"string",pattern:{meta:"a credit card number",rule:BY.source},predicate:{meta:"a credit card number",predicate:OY}});var VY=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([,.]\d+(?!:))?)?(\17[0-5]\d([,.]\d+)?)?([Zz]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;var RY=(U)=>!Number.isNaN(new Date(U).valueOf()),L8=v({domain:"string",predicate:{meta:"a parsable date",predicate:RY}}).assertHasKind("intersection"),z8=M8.root.internal.narrow((U,X)=>{let q=Number.parseInt(U),Z=u6.epoch(q);if(Z instanceof W0)return X.errors.merge(Z),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),DY=f.module({root:z8,parse:v({in:z8,morphs:(U)=>new Date(U),declaredOut:I.Date})},{name:"string.date.epoch"}),F8=l(VY,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),MY=f.module({root:F8,parse:v({in:F8,morphs:(U)=>new Date(U),declaredOut:I.Date})},{name:"string.date.iso"}),wY=f.module({root:L8,parse:v({declaredIn:L8,in:"string",morphs:(U,X)=>{let q=new Date(U);if(Number.isNaN(q.valueOf()))return X.error("a parsable date");return q},declaredOut:I.Date}),iso:MY,epoch:DY},{name:"string.date"}),PY=l(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),A8="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",n0=`(${A8}[.]){3}${A8}`,IY=new RegExp(`^${n0}$`),c="(?:[0-9a-fA-F]{1,4})",KY=new RegExp(`^((?:${c}:){7}(?:${c}|:)|(?:${c}:){6}(?:${n0}|:${c}|:)|(?:${c}:){5}(?::${n0}|(:${c}){1,2}|:)|(?:${c}:){4}(?:(:${c}){0,1}:${n0}|(:${c}){1,3}|:)|(?:${c}:){3}(?:(:${c}){0,2}:${n0}|(:${c}){1,4}|:)|(?:${c}:){2}(?:(:${c}){0,3}:${n0}|(:${c}){1,5}|:)|(?:${c}:){1}(?:(:${c}){0,4}:${n0}|(:${c}){1,6}|:)|(?::((?::${c}){0,5}:${n0}|(?::${c}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),NY=f.module({root:["v4 | v6","@","an IP address"],v4:l(IY,"an IPv4 address","ipv4"),v6:l(KY,"an IPv6 address","ipv6")},{name:"string.ip"}),d1="a JSON string",w8=(U)=>{if(!(U instanceof SyntaxError))throw U;return`must be ${d1} (${U})`},CY=v({meta:d1,domain:"string",predicate:{meta:d1,predicate:(U,X)=>{try{return JSON.parse(U),!0}catch(q){return X.reject({code:"predicate",expected:d1,problem:w8(q)})}}}}),SY=(U,X)=>{if(U.length===0)return X.error({code:"predicate",expected:d1,actual:"empty"});try{return JSON.parse(U)}catch(q){return X.error({code:"predicate",expected:d1,problem:w8(q)})}},EY=f.module({root:CY,parse:v({meta:"safe JSON string parser",in:"string",morphs:SY,declaredOut:I.jsonObject})},{name:"string.json"}),O8=l(/^[a-z]*$/,"only lowercase letters"),jY=f.module({root:v({in:"string",morphs:(U)=>U.toLowerCase(),declaredOut:O8}),preformatted:O8},{name:"string.lower"}),P8=["NFC","NFD","NFKC","NFKD"],y2=S(P8,(U,X)=>[X,v({domain:"string",predicate:(q)=>q.normalize(X)===q,meta:`${X}-normalized unicode`})]),m6=S(P8,(U,X)=>[X,v({in:"string",morphs:(q)=>q.normalize(X),declaredOut:y2[X]})]),bY=f.module({root:m6.NFC,preformatted:y2.NFC},{name:"string.normalize.NFC"}),fY=f.module({root:m6.NFD,preformatted:y2.NFD},{name:"string.normalize.NFD"}),gY=f.module({root:m6.NFKC,preformatted:y2.NFKC},{name:"string.normalize.NFKC"}),yY=f.module({root:m6.NFKD,preformatted:y2.NFKD},{name:"string.normalize.NFKD"}),kY=f.module({root:"NFC",NFC:bY,NFD:fY,NFKC:gY,NFKD:yY},{name:"string.normalize"}),B8=l($6,"a well-formed numeric string"),vY=f.module({root:B8,parse:v({in:B8,morphs:(U)=>Number.parseFloat(U),declaredOut:I.number})},{name:"string.numeric"}),T8="a regex pattern",hY=v({domain:"string",predicate:{meta:T8,predicate:(U,X)=>{try{return new RegExp(U),!0}catch(q){return X.reject({code:"predicate",expected:T8,problem:String(q)})}}},meta:{format:"regex"}}),xY=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/,uY=l(xY,"a semantic version (see https://semver.org/)"),V8=l(/^\S.*\S$|^\S?$/,"trimmed"),mY=f.module({root:v({in:"string",morphs:(U)=>U.trim(),declaredOut:V8}),preformatted:V8},{name:"string.trim"}),R8=l(/^[A-Z]*$/,"only uppercase letters"),pY=f.module({root:v({in:"string",morphs:(U)=>U.toUpperCase(),declaredOut:R8}),preformatted:R8},{name:"string.upper"}),lY=(U)=>URL.canParse(U),D8=v({domain:"string",predicate:{meta:"a URL string",predicate:lY},meta:{format:"uri"}}),dY=f.module({root:D8,parse:v({declaredIn:D8,in:"string",morphs:(U,X)=>{try{return new URL(U)}catch{return X.error("a URL string")}},declaredOut:v(URL)})},{name:"string.url"}),cY=f.module({root:["versioned | nil | max","@",{description:"a UUID",format:"uuid"}],"#nil":"'00000000-0000-0000-0000-000000000000'","#max":"'ffffffff-ffff-ffff-ffff-ffffffffffff'","#versioned":/[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}/i,v1:l(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:l(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:l(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:l(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:l(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:l(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:l(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:l(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),I8=f.module({root:I.string,alpha:l(/^[A-Za-z]*$/,"only letters"),alphanumeric:l(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:zY,base64:FY,capitalize:AY,creditCard:TY,date:wY,digits:l(/^\d*$/,"only digits 0-9"),email:PY,integer:M8,ip:NY,json:EY,lower:jY,normalize:kY,numeric:vY,regex:hY,semver:uY,trim:mY,upper:pY,url:dY,uuid:cY},{name:"string"});var K8=f.module({bigint:I.bigint,boolean:I.boolean,false:I.false,never:I.never,null:I.null,number:I.number,object:I.object,string:I.string,symbol:I.symbol,true:I.true,unknown:I.unknown,undefined:I.undefined}),N8=f.module({root:I.unknown,any:I.unknown},{name:"unknown"}),iY=f.module({root:I.jsonObject,stringify:u1("morph",{in:I.jsonObject,morphs:(U)=>JSON.stringify(U),declaredOut:I.string})},{name:"object.json"}),C8=f.module({root:I.object,json:iY},{name:"object"});class S8 extends X0{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var sY=T0(["K",I.key],"V")((U)=>({domain:"object",index:{signature:U.K,value:U.V}}),S8);class E8 extends X0{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var oY=T0(["T",I.object],["K",I.key])((U)=>U.T.pick(U.K),E8);class j8 extends X0{description='omit a set of properties from an object like `Omit(User, "age")`'}var rY=T0(["T",I.object],["K",I.key])((U)=>U.T.omit(U.K),j8);class b8 extends X0{description="make all named properties of an object optional like `Partial(User)`"}var nY=T0(["T",I.object])((U)=>U.T.partial(),b8);class f8 extends X0{description="make all named properties of an object required like `Required(User)`"}var aY=T0(["T",I.object])((U)=>U.T.required(),f8);class g8 extends X0{description='exclude branches of a union like `Exclude("boolean", "true")`'}var tY=T0("T","U")((U)=>U.T.exclude(U.U),g8);class y8 extends X0{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var eY=T0("T","U")((U)=>U.T.extract(U.U),y8),k8=f.module({Exclude:tY,Extract:eY,Omit:rY,Partial:nY,Pick:oY,Record:sY,Required:aY});var x0=g2({...K8,...k8,...W8,...Z8,string:I8,number:u6,object:C8,unknown:N8},{prereducedAliases:!0,name:"ark"}),a=x0.export();Object.assign(l1.ambient,a);l1.typeAttachments={string:a.string.root,number:a.number.root,bigint:a.bigint,boolean:a.boolean,symbol:a.symbol,undefined:a.undefined,null:a.null,object:a.object.root,unknown:a.unknown.root,false:a.false,true:a.true,never:a.never,arrayIndex:a.Array.index,Key:a.Key,Record:a.Record,Array:a.Array.root,Date:a.Date};var n9=Object.assign(x0.type,l1.typeAttachments),UJ=x0.match,XJ=x0.fn,qJ=x0.generic,EN=x0.schema,ZJ=x0.define,QJ=x0.declare;var z1=g2({Operator:"'EQ' | '==' | 'NEQ' | '!=' | 'GT' | '>' | 'GTE' | '>=' | 'LT' | '<' | 'LTE' | '<=' | 'IN' | 'NOT_IN' | 'CONTAINS' | 'MATCHES' | 'RANGE' | 'SINCE' | 'AFTER' | 'BEFORE' | 'UNTIL'",Condition:"RangeCondition | ListCondition | ContainsCondition | NumericCondition | RegexCondition | StringOperatorCondition | HasKeyCondition | NullCondition | EmptyCondition | BasicCondition",RangeCondition:{field:"string > 0",operator:"'RANGE'",value:"unknown[] == 2"},ListCondition:{field:"string > 0",operator:"'IN' | 'NOT_IN'",value:"unknown[]"},ContainsCondition:{field:"string > 0",operator:"'CONTAINS' | 'NOT_CONTAINS'",value:"string | unknown[]"},StringOperatorCondition:{field:"string > 0",operator:"'STARTS_WITH' | 'ENDS_WITH'",value:"string"},HasKeyCondition:{field:"string > 0",operator:"'HAS_KEY'",value:"string"},NullCondition:{field:"string > 0",operator:"'IS_NULL' | 'IS_NONE'","value?":"boolean | null"},EmptyCondition:{field:"string > 0",operator:"'IS_EMPTY'","value?":"boolean | null"},NumericCondition:{field:"string > 0",operator:"'>' | '>=' | '<' | '<=' | 'GT' | 'GTE' | 'LT' | 'LTE'",value:"number | string"},RegexCondition:{field:"string > 0",operator:"'MATCHES'",value:"string"},BasicCondition:{field:"string > 0",operator:"Operator",value:"unknown"},ConditionGroup:{operator:"'AND' | 'OR'",conditions:"(Condition | ConditionGroup)[] >= 1"},RuleCondition:"Condition | ConditionGroup",Action:{"type?":"string > 0","params?":"object","delay?":"number.integer >= 0 | string","probability?":"0 <= number <= 1 | string","if?":"RuleCondition | RuleCondition[]","then?":"Action | ActionGroup","else?":"Action | ActionGroup","break?":"boolean","continue?":"boolean"},ActionGroup:{"mode?":"'ALL' | 'EITHER' | 'SEQUENCE'",actions:"(Action | ActionGroup)[] >= 1"},RuleAction:"Action | ActionGroup",TriggerRule:{id:"string > 0","name?":"string","description?":"string","priority?":"number.integer","enabled?":"boolean","cooldown?":"number.integer >= 0","tags?":"string[]",on:"string > 0","if?":"RuleCondition | RuleCondition[]",do:"RuleAction | RuleAction[]","comment?":"string"}}).export(),oN=z1.Operator,rN=z1.Condition,nN=z1.ConditionGroup,aN=z1.RuleCondition,tN=z1.Action,eN=z1.ActionGroup,GJ=z1.TriggerRule;class a9{static validate(U){let X=GJ(U);if(X instanceof n9.errors){let Q=[];for(let G of X){let Y=G.path.join("."),J=G.message,H=void 0;if(Y.endsWith("on")&&(J.includes("string")||J.includes("must be")))if(typeof U==="object"&&U!==null&&"on"in U&&U.on===!0)J="The 'on' field is incorrect (boolean true found).",H=`In YAML, 'on' is a boolean keyword (true). Quote it: "on": "EventName"`;else H="Ensure 'on' is a string event name.";Q.push({path:Y,message:J,suggestion:H,severity:"error"})}return{valid:!1,issues:Q}}let q=X,Z=[];if(this.validateConditionsRecursive(q.if,Z,"if"),Z.length>0)return{valid:!1,issues:Z};return{valid:!0,rule:q}}static validateConditionsRecursive(U,X,q){if(!U)return;if(Array.isArray(U)){U.forEach((Z,Q)=>{this.validateConditionsRecursive(Z,X,`${q}.${Q}`)});return}if(typeof U==="object"&&U!==null&&"conditions"in U&&Array.isArray(U.conditions)){U.conditions.forEach((Z,Q)=>{this.validateConditionsRecursive(Z,X,`${q}.conditions.${Q}`)});return}if(typeof U==="object"&&U!==null&&"operator"in U&&"value"in U)this.validateConditionValue(U,X,q)}static validateConditionValue(U,X,q){let{operator:Z,value:Q}=U;if(typeof Z==="string"&&["IN","NOT_IN","RANGE","CONTAINS","NOT_CONTAINS"].includes(Z)){if(Z==="CONTAINS"){if(typeof Q!=="string"&&!Array.isArray(Q))X.push({path:`${q}.value`,message:`Incorrect value type: Operator 'CONTAINS' expects a String or List (Array), but received ${typeof Q}.`,suggestion:"Use a substring or a list of items.",severity:"error"});return}if(!Array.isArray(Q)){X.push({path:`${q}.value`,message:`Incorrect value type: Operator '${Z}' expects a List (Array), but received ${typeof Q}.`,suggestion:Z==="RANGE"?"Use format [min, max]":"Use format [item1, item2]",severity:"error"});return}if(Z==="RANGE"){if(Q.length!==2)X.push({path:`${q}.value`,message:"Invalid Range: Operator 'RANGE' requires exactly 2 values (min and max).",suggestion:"Use format [min, max], e.g. [1, 10]",severity:"error"});else if(typeof Q[0]!=="number"&&typeof Q[0]!=="string")X.push({path:`${q}.value`,message:"Incorrect range type: Range values must be numbers or expression strings.",severity:"error"})}}else if(Z==="MATCHES")if(typeof Q!=="string")X.push({path:`${q}.value`,message:`Incorrect value type: Operator 'MATCHES' expects a string (regex pattern), but received ${typeof Q}.`,severity:"error"});else try{new RegExp(Q)}catch(G){X.push({path:`${q}.value`,message:`Invalid Regex pattern: ${G.message}`,severity:"error"})}else if(typeof Z==="string"&&["GT","GTE","LT","LTE",">",">=","<","<="].includes(Z)){if(typeof Q!=="number"&&typeof Q!=="string")X.push({path:`${q}.value`,message:`Incorrect value type: Operator '${Z}' expects a number or expression string, but received ${typeof Q}.`,severity:"error"})}else if(typeof Z==="string"&&["STARTS_WITH","ENDS_WITH"].includes(Z)){if(typeof Q!=="string")X.push({path:`${q}.value`,message:`Incorrect value type: Operator '${Z}' expects a string, but received ${typeof Q}.`,severity:"error"})}else if(Z==="HAS_KEY"){if(typeof Q!=="string")X.push({path:`${q}.value`,message:`Incorrect value type: Operator 'HAS_KEY' expects a string (key name), but received ${typeof Q}.`,severity:"error"})}}}class p6{conditions=[];op="AND";constructor(U="AND"){this.op=U}where(U,X,q){return this.conditions.push({field:U,operator:X,value:q}),this}and(U){let X=new p6("AND");return this.conditions.push(U(X).build()),this}or(U){let X=new p6("OR");return this.conditions.push(U(X).build()),this}build(){if(this.conditions.length===0)throw Error("Condition group must have at least one condition");if(this.conditions.length===1&&this.op==="AND")return this.conditions[0];return{operator:this.op,conditions:this.conditions}}}class v8{actions=[];mode="ALL";setMode(U){return this.mode=U,this}add(U,X,q){return this.actions.push({type:U,params:X,...q}),this}build(){if(this.actions.length===0)throw Error("Action group must have at least one action");if(this.actions.length===1&&this.mode==="ALL")return this.actions[0];if(this.mode==="ALL")return this.actions;return{mode:this.mode,actions:this.actions}}}class YJ{rule={enabled:!0,priority:0};withId(U){return this.rule.id=U,this}withName(U){return this.rule.name=U,this}withDescription(U){return this.rule.description=U,this}withPriority(U){return this.rule.priority=U,this}withCooldown(U){return this.rule.cooldown=U,this}withTags(U){return this.rule.tags=U,this}on(U){return this.rule.on=U,this}if(U,X,q){if(!this.rule.if)this.rule.if={field:U,operator:X,value:q};else if(Array.isArray(this.rule.if))this.rule.if.push({field:U,operator:X,value:q});else this.rule.if=[this.rule.if,{field:U,operator:X,value:q}];return this}ifComplex(U){let X=new p6,q=U(X).build();return this.rule.if=q,this}do(U,X,q){let Z={type:U,params:X,...q};if(!this.rule.do)this.rule.do=Z;else if(Array.isArray(this.rule.do))this.rule.do.push(Z);else if(this.rule.do&&typeof this.rule.do==="object"&&"actions"in this.rule.do)this.rule.do.actions.push(Z);else this.rule.do=[this.rule.do,Z];return this}doComplex(U){let X=new v8,q=U(X).build();return this.rule.do=q,this}build(){if(!this.rule.id)throw Error("Rule ID is required");if(!this.rule.on)throw Error("Rule 'on' event is required");if(!this.rule.do)throw Error("Rule 'do' action is required");return this.rule}}var iQ=AX(WX(),1);class YO{static toYaml(U){let X=Array.isArray(U)?U:[U];return iQ.default.stringify(X)}static async saveToFile(U,X){let q=this.toYaml(U);if(typeof process<"u"&&process.versions&&process.versions.node){let Z=await import("fs/promises"),G=(await import("path")).dirname(X);await Z.mkdir(G,{recursive:!0}),await Z.writeFile(X,q,"utf8")}else throw Error("saveToFile is only supported in Node.js/Bun environments")}}import{existsSync as sQ,mkdirSync as JO,readFileSync as HO,writeFileSync as WO}from"fs";import{dirname as _O}from"path";class $O{filePath;cache=new Map;isLoaded=!1;constructor(U){this.filePath=U}ensureLoaded(){if(this.isLoaded)return;try{if(sQ(this.filePath)){let U=HO(this.filePath,"utf-8"),X=JSON.parse(U);this.cache=new Map(Object.entries(X))}}catch(U){console.error(`[FilePersistence] Failed to load state from ${this.filePath}:`,U),this.cache=new Map}this.isLoaded=!0}persist(){try{let U=_O(this.filePath);if(!sQ(U))JO(U,{recursive:!0});let X=Object.fromEntries(this.cache);WO(this.filePath,JSON.stringify(X,null,2),"utf-8")}catch(U){console.error(`[FilePersistence] Failed to save state to ${this.filePath}:`,U)}}async loadState(){return this.ensureLoaded(),new Map(this.cache)}async saveState(U,X){this.ensureLoaded(),this.cache.set(U,X),this.persist()}async deleteState(U){this.ensureLoaded(),this.cache.delete(U),this.persist()}async clearState(){this.cache.clear(),this.persist()}}import*as q2 from"path";import*as D1 from"fs";var oQ=AX(WX(),1);class LO{static async loadRulesFromDir(U){let X=[],q=async(Z)=>{let Q;try{Q=await D1.promises.readdir(Z,{withFileTypes:!0})}catch(G){console.error(`[TriggerLoader] Failed to readdir ${Z}:`,G);return}for(let G of Q){let Y=q2.resolve(Z,G.name);if(G.isDirectory())await q(Y);else if(Y.toLowerCase().endsWith(".yaml")||Y.toLowerCase().endsWith(".yml"))try{let J=await this.loadRule(Y);X.push(...J)}catch(J){console.error(`Failed to load rule from ${Y}:`,J)}}};if(D1.existsSync(U))await q(U);else console.warn(`[TriggerLoader] Directory not found: ${U}`);return X}static async loadRule(U){try{let X=await D1.promises.readFile(U,"utf-8"),q=oQ.parseAllDocuments(X);for(let Y of q)if(Y.errors&&Y.errors.length>0)throw Error(`YAML syntax error in ${U}: ${Y.errors.map((J)=>J.message).join(", ")}`);let Z=q.map((Y)=>Y.toJS()),Q=[],G=[];return Z.forEach((Y)=>{if(Array.isArray(Y))G.push(...Y);else G.push(Y)}),G.forEach((Y,J)=>{if(Y&&typeof Y==="object"&&Y!==null&&"actions"in Y&&!Y.do)Y.do=Y.actions;let H=a9.validate(Y);if(H.valid){let W=H.rule;if(!W.id&&typeof Y==="object"&&Y!==null){let $=q2.basename(U,q2.extname(U));W.id=G.length>1?`${$}-${J}`:$}Q.push(W)}else console.error(`
185
+ [TriggerLoader] ⚠️ Validation Problem in ${U} (item #${J+1})`),H.issues.forEach((W)=>{if(console.error(` - [${W.path}] ${W.message}`),W.suggestion)console.error(` \uD83D\uDCA1 Suggestion: ${W.suggestion}`)})}),Q}catch(X){throw console.error(`Error parsing YAML file ${U}:`,X),X}}static watchRules(U,X){return this.loadRulesFromDir(U).then(X),console.log(`[TriggerLoader] Watching for changes in ${U}...`),D1.watch(U,{recursive:!0},async(Z,Q)=>{if(Q&&(String(Q).endsWith(".yaml")||String(Q).endsWith(".yml"))){console.log(`[TriggerLoader] Detected change in ${Q} (${Z}). Reloading rules...`);try{let G=await this.loadRulesFromDir(U);X(G),console.log(`[TriggerLoader] Reloaded ${G.length} rules.`)}catch(G){console.error("[TriggerLoader] Failed to reload rules:",G)}}})}}export{N0 as triggerEmitter,H6 as ruleEvents,VO as engineEvents,a9 as TriggerValidator,Y6 as TriggerUtils,GJ as TriggerRuleSchema,LO as TriggerLoader,G2 as TriggerEngine,f4 as TriggerEmitter,U0 as StateManager,YO as RuleExporter,VX as RuleEvent,g4 as RuleEngine,aN as RuleConditionSchema,YJ as RuleBuilder,b4 as InMemoryPersistence,$O as FilePersistence,e as ExpressionEngine,ZG as EventQueue,J6 as EngineEvent,G2 as Engine,GG as ContextAdapter,rN as ConditionSchema,nN as ConditionGroupSchema,p6 as ConditionBuilder,oN as ComparisonOperatorSchema,QG as BrowserPersistence,g4 as AdvancedRuleEngine,tN as ActionSchema,I1 as ActionRegistry,eN as ActionGroupSchema,v8 as ActionBuilder};
186
186
 
187
- //# debugId=E8AF06CA685D5D5B64756E2164756E21
187
+ //# debugId=AF0F8D138A9A4E5564756E2164756E21