trigger_system 1.0.0 → 1.0.2

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,187 +1,187 @@
1
- import{createRequire as vQ}from"node:module";var fQ=Object.create;var{getPrototypeOf:gQ,defineProperty:QX,getOwnPropertyNames:yQ}=Object;var kQ=Object.prototype.hasOwnProperty;var X6=(U,X,q)=>{q=U!=null?fQ(gQ(U)):{};let Z=X||!U||!U.__esModule?QX(q,"default",{value:U,enumerable:!0}):q;for(let Q of yQ(U))if(!kQ.call(Z,Q))QX(Z,Q,{get:()=>U[Q],enumerable:!0});return Z};var R=(U,X)=>()=>(X||U((X={exports:{}}).exports,X),X.exports);var M1=vQ(import.meta.url);var k=R((a7)=>{var c9=Symbol.for("yaml.alias"),M8=Symbol.for("yaml.document"),x6=Symbol.for("yaml.map"),w8=Symbol.for("yaml.pair"),i9=Symbol.for("yaml.scalar"),h6=Symbol.for("yaml.seq"),h0=Symbol.for("yaml.node.type"),d7=(U)=>!!U&&typeof U==="object"&&U[h0]===c9,c7=(U)=>!!U&&typeof U==="object"&&U[h0]===M8,i7=(U)=>!!U&&typeof U==="object"&&U[h0]===x6,o7=(U)=>!!U&&typeof U==="object"&&U[h0]===w8,P8=(U)=>!!U&&typeof U==="object"&&U[h0]===i9,s7=(U)=>!!U&&typeof U==="object"&&U[h0]===h6;function I8(U){if(U&&typeof U==="object")switch(U[h0]){case x6:case h6:return!0}return!1}function r7(U){if(U&&typeof U==="object")switch(U[h0]){case c9:case x6:case i9:case h6:return!0}return!1}var n7=(U)=>(P8(U)||I8(U))&&!!U.anchor;a7.ALIAS=c9;a7.DOC=M8;a7.MAP=x6;a7.NODE_TYPE=h0;a7.PAIR=w8;a7.SCALAR=i9;a7.SEQ=h6;a7.hasAnchor=n7;a7.isAlias=d7;a7.isCollection=I8;a7.isDocument=c7;a7.isMap=i7;a7.isNode=r7;a7.isPair=o7;a7.isScalar=P8;a7.isSeq=s7});var b2=R((FH)=>{var t=k(),_0=Symbol("break visit"),K8=Symbol("skip children"),b0=Symbol("remove node");function u6(U,X){let q=N8(X);if(t.isDocument(U)){if(l1(null,U.contents,q,Object.freeze([U]))===b0)U.contents=null}else l1(null,U,q,Object.freeze([]))}u6.BREAK=_0;u6.SKIP=K8;u6.REMOVE=b0;function l1(U,X,q,Z){let Q=C8(U,X,q,Z);if(t.isNode(Q)||t.isPair(Q))return S8(U,Z,Q),l1(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=l1(G,X.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===_0)return _0;else if(Y===b0)X.items.splice(G,1),G-=1}}else if(t.isPair(X)){Z=Object.freeze(Z.concat(X));let G=l1("key",X.key,q,Z);if(G===_0)return _0;else if(G===b0)X.key=null;let Y=l1("value",X.value,q,Z);if(Y===_0)return _0;else if(Y===b0)X.value=null}}return Q}async function m6(U,X){let q=N8(X);if(t.isDocument(U)){if(await d1(null,U.contents,q,Object.freeze([U]))===b0)U.contents=null}else await d1(null,U,q,Object.freeze([]))}m6.BREAK=_0;m6.SKIP=K8;m6.REMOVE=b0;async function d1(U,X,q,Z){let Q=await C8(U,X,q,Z);if(t.isNode(Q)||t.isPair(Q))return S8(U,Z,Q),d1(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 d1(G,X.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===_0)return _0;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 d1("key",X.key,q,Z);if(G===_0)return _0;else if(G===b0)X.key=null;let Y=await d1("value",X.value,q,Z);if(Y===_0)return _0;else if(Y===b0)X.value=null}}return Q}function N8(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 C8(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 S8(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`)}}FH.visit=u6;FH.visitAsync=m6});var o9=R((RH)=>{var E8=k(),OH=b2(),VH={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},BH=(U)=>U.replace(/[!,[\]{}]/g,(X)=>VH[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+BH(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&&E8.isNode(U.contents)){let Q={};OH.visit(U.contents,(G,Y)=>{if(E8.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:"};RH.Directives=V0});var p6=R((IH)=>{var b8=k(),MH=b2();function wH(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 j8(U){let X=new Set;return MH.visit(U,{Value(q,Z){if(Z.anchor)X.add(Z.anchor)}}),X}function f8(U,X){for(let q=1;;++q){let Z=`${U}${q}`;if(!X.has(Z))return Z}}function PH(U,X){let q=[],Z=new Map,Q=null;return{onAnchor:(G)=>{q.push(G),Q??(Q=j8(U));let Y=f8(X,Q);return Q.add(Y),Y},setAnchors:()=>{for(let G of q){let Y=Z.get(G);if(typeof Y==="object"&&Y.anchor&&(b8.isScalar(Y.node)||b8.isCollection(Y.node)))Y.node.anchor=Y.anchor;else{let H=Error("Failed to resolve repeated object (this should not happen)");throw H.source=G,H}}},sourceObjects:Z}}IH.anchorIsValid=wH;IH.anchorNames=j8;IH.createNodeAnchors=PH;IH.findNewAnchor=f8});var s9=R((EH)=>{function j2(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],H=j2(U,Z,String(Q),Y);if(H===void 0)delete Z[Q];else if(H!==Y)Z[Q]=H}else if(Z instanceof Map)for(let Q of Array.from(Z.keys())){let G=Z.get(Q),Y=j2(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=j2(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=j2(U,Z,Q,G);if(Y===void 0)delete Z[Q];else if(Y!==G)Z[Q]=Y}return U.call(X,q,Z)}EH.applyReviver=j2});var n0=R((fH)=>{var jH=k();function g8(U,X,q){if(Array.isArray(U))return U.map((Z,Q)=>g8(Z,String(Q),q));if(U&&typeof U.toJSON==="function"){if(!q||!jH.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}fH.toJS=g8});var l6=R((vH)=>{var yH=s9(),y8=k(),kH=n0();class k8{constructor(U){Object.defineProperty(this,y8.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(!y8.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=kH.toJS(this,"",G);if(typeof Z==="function")for(let{count:H,res:J}of G.anchors.values())Z(J,H);return typeof Q==="function"?yH.applyReviver(Q,{"":Y},"",Y):Y}}vH.NodeBase=k8});var f2=R((lH)=>{var hH=p6(),uH=b2(),c1=k(),mH=l6(),pH=n0();class v8 extends mH.NodeBase{constructor(U){super(c1.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=[],uH.visit(U,{Node:(Q,G)=>{if(c1.isAlias(G)||c1.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 H=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(H)}let Y=q.get(G);if(!Y)pH.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=d6(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(hH.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 d6(U,X,q){if(c1.isAlias(X)){let Z=X.resolve(U),Q=q&&Z&&q.get(Z);return Q?Q.count*Q.aliasCount:0}else if(c1.isCollection(X)){let Z=0;for(let Q of X.items){let G=d6(U,Q,q);if(G>Z)Z=G}return Z}else if(c1.isPair(X)){let Z=d6(U,X.key,q),Q=d6(U,X.value,q);return Math.max(Z,Q)}return 1}lH.Alias=v8});var i=R((rH)=>{var cH=k(),iH=l6(),oH=n0(),sH=(U)=>!U||typeof U!=="function"&&typeof U!=="object";class z1 extends iH.NodeBase{constructor(U){super(cH.SCALAR);this.value=U}toJSON(U,X){return X?.keep?this.value:oH.toJS(this.value,U,X)}toString(){return String(this.value)}}z1.BLOCK_FOLDED="BLOCK_FOLDED";z1.BLOCK_LITERAL="BLOCK_LITERAL";z1.PLAIN="PLAIN";z1.QUOTE_DOUBLE="QUOTE_DOUBLE";z1.QUOTE_SINGLE="QUOTE_SINGLE";rH.Scalar=z1;rH.isScalarValue=sH});var g2=R((qJ)=>{var tH=f2(),F1=k(),x8=i(),eH="tag:yaml.org,2002:";function UJ(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 XJ(U,X,q){if(F1.isDocument(U))U=U.contents;if(F1.isNode(U))return U;if(F1.isPair(U)){let L=q.schema[F1.MAP].createNode?.(q.schema,null,q);return L.items.push(U),L}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:H}=q,J=void 0;if(Z&&U&&typeof U==="object")if(J=H.get(U),J)return J.anchor??(J.anchor=Q(U)),new tH.Alias(J.anchor);else J={anchor:null,node:null},H.set(U,J);if(X?.startsWith("!!"))X=eH+X.slice(2);let W=UJ(U,X,Y.tags);if(!W){if(U&&typeof U.toJSON==="function")U=U.toJSON();if(!U||typeof U!=="object"){let L=new x8.Scalar(U);if(J)J.node=L;return L}W=U instanceof Map?Y[F1.MAP]:(Symbol.iterator in Object(U))?Y[F1.SEQ]:Y[F1.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 x8.Scalar(U);if(X)_.tag=X;else if(!W.default)_.tag=W.tag;if(J)J.node=_;return _}qJ.createNode=XJ});var c6=R((YJ)=>{var QJ=g2(),j0=k(),GJ=l6();function r9(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 QJ.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 h8=(U)=>U==null||typeof U==="object"&&!!U[Symbol.iterator]().next().done;class u8 extends GJ.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)=>j0.isNode(q)||j0.isPair(q)?q.clone(U):q),this.range)X.range=this.range.slice();return X}addIn(U,X){if(h8(U))this.add(X);else{let[q,...Z]=U,Q=this.get(q,!0);if(j0.isCollection(Q))Q.addIn(Z,X);else if(Q===void 0&&this.schema)this.set(q,r9(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(j0.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&&j0.isScalar(Q)?Q.value:Q;else return j0.isCollection(Q)?Q.getIn(Z,X):void 0}hasAllNullValues(U){return this.items.every((X)=>{if(!j0.isPair(X))return!1;let q=X.value;return q==null||U&&j0.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 j0.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(j0.isCollection(Q))Q.setIn(Z,X);else if(Q===void 0&&this.schema)this.set(q,r9(this.schema,Z,X));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${Z}`)}}}YJ.Collection=u8;YJ.collectionFromPath=r9;YJ.isEmptyPath=h8});var y2=R(($J)=>{var LJ=(U)=>U.replace(/^(?!$)(?: $)?/gm,"#");function n9(U,X){if(/^\n+$/.test(U))return U.substring(1);return X?U.replace(/^(?! *$)/gm,X):U}var _J=(U,X,q)=>U.endsWith(`
3
- `)?n9(q,X):q.includes(`
1
+ import{createRequire as cQ}from"node:module";var uQ=Object.create;var{getPrototypeOf:mQ,defineProperty:S4,getOwnPropertyNames:pQ}=Object;var lQ=Object.prototype.hasOwnProperty;var Y6=(X,U,q)=>{q=X!=null?uQ(mQ(X)):{};let Z=U||!X||!X.__esModule?S4(q,"default",{value:X,enumerable:!0}):q;for(let Q of pQ(X))if(!lQ.call(Z,Q))S4(Z,Q,{get:()=>X[Q],enumerable:!0});return Z};var R=(X,U)=>()=>(U||X((U={exports:{}}).exports,U),U.exports);var dQ=(X,U)=>{for(var q in U)S4(X,q,{get:U[q],enumerable:!0,configurable:!0,set:(Z)=>U[q]=()=>Z})};var _U=(X,U)=>()=>(X&&(U=X(X=0)),U);var w1=cQ(import.meta.url);class $0{static evaluate(X,U){try{if(X.includes("${")){let q=this.interpolate(X,U);if(!isNaN(Number(q))&&q.trim()!=="")return Number(q);return q}return this.evaluateExpression(X,U)}catch(q){return console.error(`Error evaluating expression: ${X}`,q),null}}static interpolate(X,U){return X.replace(/\$\{([^}]+)\}/g,(q,Z)=>{try{let Q=this.evaluateExpression(Z,U);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(X){try{return Function("Math",`return ${X}`)(Math)}catch(U){throw Error(`Error evaluando expresión matemática: ${X}`)}}static evaluateExpression(X,U){if(/^(data|globals|request|computed)(\.[a-zA-Z0-9_]+)+$/.test(X))return this.getNestedValue(X,U);try{return Function("context","with(context) { return "+X+" }")(U)}catch(q){return console.error(`ERROR evaluating expression '${X}':`,q),X}}static getNestedValue(X,U){let q=X.split("."),Z=U;for(let Q of q){if(Z===null||Z===void 0||!(Q in Z))return;Z=Z[Q]}return Z}static evaluateMath(X,U){let q=X;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,U);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: ${X}`,Z),NaN}}}class b4{store=new Map;async loadState(){return new Map(this.store)}async saveState(X,U){this.store.set(X,U)}async deleteState(X){this.store.delete(X)}async clearState(){this.store.clear()}}class R0{static instance;state;persistence;constructor(){this.state=new Map,this.persistence=new b4}static getInstance(){if(!R0.instance)R0.instance=new R0;return R0.instance}setPersistence(X){this.persistence=X}async initialize(){let X=await this.persistence.loadState();this.state=X,console.log(`[StateManager] Initialized with ${this.state.size} keys.`)}get(X){return this.state.get(X)}async set(X,U){this.state.set(X,U),await this.persistence.saveState(X,U)}async increment(X,U=1){let q=this.get(X)||0,Z=Number(q)+U;return await this.set(X,Z),Z}async decrement(X,U=1){return this.increment(X,-U)}async delete(X){let U=this.state.delete(X);if(U)await this.persistence.deleteState(X);return U}async clear(){this.state.clear(),await this.persistence.clearState()}getAll(){return Object.fromEntries(this.state)}}var Z2=()=>{};var $U={};dQ($U,{ActionRegistry:()=>P1});class P1{static instance;handlers=new Map;constructor(){this.registerDefaults()}static getInstance(){if(!this.instance)this.instance=new P1;return this.instance}register(X,U){this.handlers.set(X.toUpperCase(),U)}get(X){return this.handlers.get(X.toUpperCase())}registerDefaults(){this.register("log",(X,U)=>{let q=X.params?.message||X.params?.content||"Log Trigger",Z=$0.interpolate(q,U);return console.log(`[TriggerLog] ${Z}`),{message:Z}}),this.register("response",(X,U)=>{let q=X.params?.content||X.params?.body||"",Z=$0.interpolate(q,U);return{statusCode:X.params?.statusCode||200,headers:X.params?.headers||{"Content-Type":"application/json"},body:Z}}),this.register("execute",async(X,U)=>{let q=X.params?.command||X.params?.content||"",Z=$0.interpolate(q,U);if(!X.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(X,U)=>{let q=X.params?.url||"",Z=$0.interpolate(q,U),Q=X.params?.method||"POST";try{let G=await fetch(Z,{method:Q,headers:{"Content-Type":"application/json",...X.params?.headers},body:JSON.stringify(U.data)});return{url:Z,method:Q,status:G.status,headers:(()=>{let Y={};return G.headers.forEach((H,J)=>Y[J]=H),Y})(),body:await G.text()}}catch(G){return{url:Z,method:Q,error:String(G)}}}),this.register("STATE_SET",async(X,U)=>{let q=X.params?.key,Z=X.params?.value;if(!q)return{error:"Missing key for STATE_SET"};let Q=Z;if(typeof Z==="string"&&Z.includes("${"))Q=$0.interpolate(Z,U);return await R0.getInstance().set(q,Q),{key:q,value:Q}}),this.register("STATE_INCREMENT",async(X,U)=>{let q=X.params?.key,Z=Number(X.params?.amount)||1;if(!q)return{error:"Missing key for STATE_INCREMENT"};let Q=await R0.getInstance().increment(q,Z);return{key:q,newValue:Q}}),this.register("EMIT_EVENT",(X,U)=>{return{event:X.params?.event,payload:X.params?.data||{}}})}}var Q2=_U(()=>{Z2()});var k=R((ZH)=>{var n9=Symbol.for("yaml.alias"),S8=Symbol.for("yaml.document"),p6=Symbol.for("yaml.map"),E8=Symbol.for("yaml.pair"),t9=Symbol.for("yaml.scalar"),l6=Symbol.for("yaml.seq"),h0=Symbol.for("yaml.node.type"),a7=(X)=>!!X&&typeof X==="object"&&X[h0]===n9,n7=(X)=>!!X&&typeof X==="object"&&X[h0]===S8,t7=(X)=>!!X&&typeof X==="object"&&X[h0]===p6,e7=(X)=>!!X&&typeof X==="object"&&X[h0]===E8,b8=(X)=>!!X&&typeof X==="object"&&X[h0]===t9,XH=(X)=>!!X&&typeof X==="object"&&X[h0]===l6;function j8(X){if(X&&typeof X==="object")switch(X[h0]){case p6:case l6:return!0}return!1}function UH(X){if(X&&typeof X==="object")switch(X[h0]){case n9:case p6:case t9:case l6:return!0}return!1}var qH=(X)=>(b8(X)||j8(X))&&!!X.anchor;ZH.ALIAS=n9;ZH.DOC=S8;ZH.MAP=p6;ZH.NODE_TYPE=h0;ZH.PAIR=E8;ZH.SCALAR=t9;ZH.SEQ=l6;ZH.hasAnchor=qH;ZH.isAlias=a7;ZH.isCollection=j8;ZH.isDocument=n7;ZH.isMap=t7;ZH.isNode=UH;ZH.isPair=e7;ZH.isScalar=b8;ZH.isSeq=XH});var k2=R((RH)=>{var t=k(),_0=Symbol("break visit"),f8=Symbol("skip children"),b0=Symbol("remove node");function d6(X,U){let q=y8(U);if(t.isDocument(X)){if(d1(null,X.contents,q,Object.freeze([X]))===b0)X.contents=null}else d1(null,X,q,Object.freeze([]))}d6.BREAK=_0;d6.SKIP=f8;d6.REMOVE=b0;function d1(X,U,q,Z){let Q=g8(X,U,q,Z);if(t.isNode(Q)||t.isPair(Q))return k8(X,Z,Q),d1(X,Q,q,Z);if(typeof Q!=="symbol"){if(t.isCollection(U)){Z=Object.freeze(Z.concat(U));for(let G=0;G<U.items.length;++G){let Y=d1(G,U.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===_0)return _0;else if(Y===b0)U.items.splice(G,1),G-=1}}else if(t.isPair(U)){Z=Object.freeze(Z.concat(U));let G=d1("key",U.key,q,Z);if(G===_0)return _0;else if(G===b0)U.key=null;let Y=d1("value",U.value,q,Z);if(Y===_0)return _0;else if(Y===b0)U.value=null}}return Q}async function c6(X,U){let q=y8(U);if(t.isDocument(X)){if(await c1(null,X.contents,q,Object.freeze([X]))===b0)X.contents=null}else await c1(null,X,q,Object.freeze([]))}c6.BREAK=_0;c6.SKIP=f8;c6.REMOVE=b0;async function c1(X,U,q,Z){let Q=await g8(X,U,q,Z);if(t.isNode(Q)||t.isPair(Q))return k8(X,Z,Q),c1(X,Q,q,Z);if(typeof Q!=="symbol"){if(t.isCollection(U)){Z=Object.freeze(Z.concat(U));for(let G=0;G<U.items.length;++G){let Y=await c1(G,U.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===_0)return _0;else if(Y===b0)U.items.splice(G,1),G-=1}}else if(t.isPair(U)){Z=Object.freeze(Z.concat(U));let G=await c1("key",U.key,q,Z);if(G===_0)return _0;else if(G===b0)U.key=null;let Y=await c1("value",U.value,q,Z);if(Y===_0)return _0;else if(Y===b0)U.value=null}}return Q}function y8(X){if(typeof X==="object"&&(X.Collection||X.Node||X.Value))return Object.assign({Alias:X.Node,Map:X.Node,Scalar:X.Node,Seq:X.Node},X.Value&&{Map:X.Value,Scalar:X.Value,Seq:X.Value},X.Collection&&{Map:X.Collection,Seq:X.Collection},X);return X}function g8(X,U,q,Z){if(typeof q==="function")return q(X,U,Z);if(t.isMap(U))return q.Map?.(X,U,Z);if(t.isSeq(U))return q.Seq?.(X,U,Z);if(t.isPair(U))return q.Pair?.(X,U,Z);if(t.isScalar(U))return q.Scalar?.(X,U,Z);if(t.isAlias(U))return q.Alias?.(X,U,Z);return}function k8(X,U,q){let Z=U[U.length-1];if(t.isCollection(Z))Z.items[X]=q;else if(t.isPair(Z))if(X==="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`)}}RH.visit=d6;RH.visitAsync=c6});var e9=R((KH)=>{var v8=k(),wH=k2(),PH={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},IH=(X)=>X.replace(/[!,[\]{}]/g,(U)=>PH[U]);class B0{constructor(X,U){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},B0.defaultYaml,X),this.tags=Object.assign({},B0.defaultTags,U)}clone(){let X=new B0(this.yaml,this.tags);return X.docStart=this.docStart,X}atDocument(){let X=new B0(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:B0.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},B0.defaultTags);break}return X}add(X,U){if(this.atNextDocument)this.yaml={explicit:B0.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},B0.defaultTags),this.atNextDocument=!1;let q=X.trim().split(/[ \t]+/),Z=q.shift();switch(Z){case"%TAG":{if(q.length!==2){if(U(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 U(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 U(6,`Unsupported YAML version ${Q}`,G),!1}}default:return U(0,`Unknown directive ${Z}`,!0),!1}}tagName(X,U){if(X==="!")return"!";if(X[0]!=="!")return U(`Not a valid tag: ${X}`),null;if(X[1]==="<"){let G=X.slice(2,-1);if(G==="!"||G==="!!")return U(`Verbatim tags aren't resolved, so ${X} is invalid.`),null;if(X[X.length-1]!==">")U("Verbatim tags must end with a >");return G}let[,q,Z]=X.match(/^(.*!)([^!]*)$/s);if(!Z)U(`The ${X} tag has no suffix`);let Q=this.tags[q];if(Q)try{return Q+decodeURIComponent(Z)}catch(G){return U(String(G)),null}if(q==="!")return X;return U(`Could not resolve tag: ${X}`),null}tagString(X){for(let[U,q]of Object.entries(this.tags))if(X.startsWith(q))return U+IH(X.substring(q.length));return X[0]==="!"?X:`!<${X}>`}toString(X){let U=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],q=Object.entries(this.tags),Z;if(X&&q.length>0&&v8.isNode(X.contents)){let Q={};wH.visit(X.contents,(G,Y)=>{if(v8.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(!X||Z.some((Y)=>Y.startsWith(G)))U.push(`%TAG ${Q} ${G}`)}return U.join(`
2
+ `)}}B0.defaultYaml={explicit:!1,version:"1.2"};B0.defaultTags={"!!":"tag:yaml.org,2002:"};KH.Directives=B0});var i6=R((bH)=>{var x8=k(),CH=k2();function SH(X){if(/[\x00-\x19\s,[\]{}]/.test(X)){let q=`Anchor must not contain whitespace or control characters: ${JSON.stringify(X)}`;throw Error(q)}return!0}function h8(X){let U=new Set;return CH.visit(X,{Value(q,Z){if(Z.anchor)U.add(Z.anchor)}}),U}function u8(X,U){for(let q=1;;++q){let Z=`${X}${q}`;if(!U.has(Z))return Z}}function EH(X,U){let q=[],Z=new Map,Q=null;return{onAnchor:(G)=>{q.push(G),Q??(Q=h8(X));let Y=u8(U,Q);return Q.add(Y),Y},setAnchors:()=>{for(let G of q){let Y=Z.get(G);if(typeof Y==="object"&&Y.anchor&&(x8.isScalar(Y.node)||x8.isCollection(Y.node)))Y.node.anchor=Y.anchor;else{let H=Error("Failed to resolve repeated object (this should not happen)");throw H.source=G,H}}},sourceObjects:Z}}bH.anchorIsValid=SH;bH.anchorNames=h8;bH.createNodeAnchors=EH;bH.findNewAnchor=u8});var XX=R((kH)=>{function v2(X,U,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],H=v2(X,Z,String(Q),Y);if(H===void 0)delete Z[Q];else if(H!==Y)Z[Q]=H}else if(Z instanceof Map)for(let Q of Array.from(Z.keys())){let G=Z.get(Q),Y=v2(X,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(X,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(X,Z,Q,G);if(Y===void 0)delete Z[Q];else if(Y!==G)Z[Q]=Y}return X.call(U,q,Z)}kH.applyReviver=v2});var a0=R((hH)=>{var xH=k();function m8(X,U,q){if(Array.isArray(X))return X.map((Z,Q)=>m8(Z,String(Q),q));if(X&&typeof X.toJSON==="function"){if(!q||!xH.hasAnchor(X))return X.toJSON(U,q);let Z={aliasCount:0,count:1,res:void 0};q.anchors.set(X,Z),q.onCreate=(G)=>{Z.res=G,delete q.onCreate};let Q=X.toJSON(U,q);if(q.onCreate)q.onCreate(Q);return Q}if(typeof X==="bigint"&&!q?.keep)return Number(X);return X}hH.toJS=m8});var s6=R((lH)=>{var mH=XX(),p8=k(),pH=a0();class l8{constructor(X){Object.defineProperty(this,p8.NODE_TYPE,{value:X})}clone(){let X=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)X.range=this.range.slice();return X}toJS(X,{mapAsMap:U,maxAliasCount:q,onAnchor:Z,reviver:Q}={}){if(!p8.isDocument(X))throw TypeError("A document argument is required");let G={anchors:new Map,doc:X,keep:!0,mapAsMap:U===!0,mapKeyWarned:!1,maxAliasCount:typeof q==="number"?q:100},Y=pH.toJS(this,"",G);if(typeof Z==="function")for(let{count:H,res:J}of G.anchors.values())Z(J,H);return typeof Q==="function"?mH.applyReviver(Q,{"":Y},"",Y):Y}}lH.NodeBase=l8});var x2=R((rH)=>{var cH=i6(),iH=k2(),i1=k(),sH=s6(),oH=a0();class d8 extends sH.NodeBase{constructor(X){super(i1.ALIAS);this.source=X,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(X,U){let q;if(U?.aliasResolveCache)q=U.aliasResolveCache;else if(q=[],iH.visit(X,{Node:(Q,G)=>{if(i1.isAlias(G)||i1.hasAnchor(G))q.push(G)}}),U)U.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(X,U){if(!U)return{source:this.source};let{anchors:q,doc:Z,maxAliasCount:Q}=U,G=this.resolve(Z,U);if(!G){let H=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(H)}let Y=q.get(G);if(!Y)oH.toJS(G,null,U),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=o6(Z,G,q);if(Y.count*Y.aliasCount>Q)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return Y.res}toString(X,U,q){let Z=`*${this.source}`;if(X){if(cH.anchorIsValid(this.source),X.options.verifyAliasOrder&&!X.anchors.has(this.source)){let Q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(Q)}if(X.implicitKey)return`${Z} `}return Z}}function o6(X,U,q){if(i1.isAlias(U)){let Z=U.resolve(X),Q=q&&Z&&q.get(Z);return Q?Q.count*Q.aliasCount:0}else if(i1.isCollection(U)){let Z=0;for(let Q of U.items){let G=o6(X,Q,q);if(G>Z)Z=G}return Z}else if(i1.isPair(U)){let Z=o6(X,U.key,q),Q=o6(X,U.value,q);return Math.max(Z,Q)}return 1}rH.Alias=d8});var i=R((UJ)=>{var nH=k(),tH=s6(),eH=a0(),XJ=(X)=>!X||typeof X!=="function"&&typeof X!=="object";class F1 extends tH.NodeBase{constructor(X){super(nH.SCALAR);this.value=X}toJSON(X,U){return U?.keep?this.value:eH.toJS(this.value,X,U)}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";UJ.Scalar=F1;UJ.isScalarValue=XJ});var h2=R((JJ)=>{var QJ=x2(),A1=k(),c8=i(),GJ="tag:yaml.org,2002:";function YJ(X,U,q){if(U){let Z=q.filter((G)=>G.tag===U),Q=Z.find((G)=>!G.format)??Z[0];if(!Q)throw Error(`Tag ${U} not found`);return Q}return q.find((Z)=>Z.identify?.(X)&&!Z.format)}function HJ(X,U,q){if(A1.isDocument(X))X=X.contents;if(A1.isNode(X))return X;if(A1.isPair(X)){let _=q.schema[A1.MAP].createNode?.(q.schema,null,q);return _.items.push(X),_}if(X instanceof String||X instanceof Number||X instanceof Boolean||typeof BigInt<"u"&&X instanceof BigInt)X=X.valueOf();let{aliasDuplicateObjects:Z,onAnchor:Q,onTagObj:G,schema:Y,sourceObjects:H}=q,J=void 0;if(Z&&X&&typeof X==="object")if(J=H.get(X),J)return J.anchor??(J.anchor=Q(X)),new QJ.Alias(J.anchor);else J={anchor:null,node:null},H.set(X,J);if(U?.startsWith("!!"))U=GJ+U.slice(2);let W=YJ(X,U,Y.tags);if(!W){if(X&&typeof X.toJSON==="function")X=X.toJSON();if(!X||typeof X!=="object"){let _=new c8.Scalar(X);if(J)J.node=_;return _}W=X instanceof Map?Y[A1.MAP]:(Symbol.iterator in Object(X))?Y[A1.SEQ]:Y[A1.MAP]}if(G)G(W),delete q.onTagObj;let $=W?.createNode?W.createNode(q.schema,X,q):typeof W?.nodeClass?.from==="function"?W.nodeClass.from(q.schema,X,q):new c8.Scalar(X);if(U)$.tag=U;else if(!W.default)$.tag=W.tag;if(J)J.node=$;return $}JJ.createNode=HJ});var r6=R((LJ)=>{var _J=h2(),j0=k(),$J=s6();function UX(X,U,q){let Z=q;for(let Q=U.length-1;Q>=0;--Q){let G=U[Q];if(typeof G==="number"&&Number.isInteger(G)&&G>=0){let Y=[];Y[G]=Z,Z=Y}else Z=new Map([[G,Z]])}return _J.createNode(Z,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:X,sourceObjects:new Map})}var i8=(X)=>X==null||typeof X==="object"&&!!X[Symbol.iterator]().next().done;class s8 extends $J.NodeBase{constructor(X,U){super(X);Object.defineProperty(this,"schema",{value:U,configurable:!0,enumerable:!1,writable:!0})}clone(X){let U=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(X)U.schema=X;if(U.items=U.items.map((q)=>j0.isNode(q)||j0.isPair(q)?q.clone(X):q),this.range)U.range=this.range.slice();return U}addIn(X,U){if(i8(X))this.add(U);else{let[q,...Z]=X,Q=this.get(q,!0);if(j0.isCollection(Q))Q.addIn(Z,U);else if(Q===void 0&&this.schema)this.set(q,UX(this.schema,Z,U));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${Z}`)}}deleteIn(X){let[U,...q]=X;if(q.length===0)return this.delete(U);let Z=this.get(U,!0);if(j0.isCollection(Z))return Z.deleteIn(q);else throw Error(`Expected YAML collection at ${U}. Remaining path: ${q}`)}getIn(X,U){let[q,...Z]=X,Q=this.get(q,!0);if(Z.length===0)return!U&&j0.isScalar(Q)?Q.value:Q;else return j0.isCollection(Q)?Q.getIn(Z,U):void 0}hasAllNullValues(X){return this.items.every((U)=>{if(!j0.isPair(U))return!1;let q=U.value;return q==null||X&&j0.isScalar(q)&&q.value==null&&!q.commentBefore&&!q.comment&&!q.tag})}hasIn(X){let[U,...q]=X;if(q.length===0)return this.has(U);let Z=this.get(U,!0);return j0.isCollection(Z)?Z.hasIn(q):!1}setIn(X,U){let[q,...Z]=X;if(Z.length===0)this.set(q,U);else{let Q=this.get(q,!0);if(j0.isCollection(Q))Q.setIn(Z,U);else if(Q===void 0&&this.schema)this.set(q,UX(this.schema,Z,U));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${Z}`)}}}LJ.Collection=s8;LJ.collectionFromPath=UX;LJ.isEmptyPath=i8});var u2=R((BJ)=>{var VJ=(X)=>X.replace(/^(?!$)(?: $)?/gm,"#");function qX(X,U){if(/^\n+$/.test(X))return X.substring(1);return U?X.replace(/^(?! *$)/gm,U):X}var OJ=(X,U,q)=>X.endsWith(`
3
+ `)?qX(q,U):q.includes(`
4
4
  `)?`
5
- `+n9(q,X):(U.endsWith(" ")?"":" ")+q;$J.indentComment=n9;$J.lineComment=_J;$J.stringifyComment=LJ});var p8=R((OJ)=>{function TJ(U,X,q="flow",{indentAtStart:Z,lineWidth:Q=80,minContentWidth:G=20,onFold:Y,onOverflow:H}={}){if(!Q||Q<0)return U;if(Q<G)G=0;let J=Math.max(1+G,1+Q-X.length);if(U.length<=J)return U;let W=[],_={},L=Q-X.length;if(typeof Z==="number")if(Z>Q-Math.max(2,G))W.push(0);else L=Q-Z;let $=void 0,A=void 0,B=!1,z=-1,O=-1,D=-1;if(q==="block"){if(z=m8(U,z,X.length),z!==-1)L=z+J}for(let K;K=U[z+=1];){if(q==="quoted"&&K==="\\"){switch(O=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=m8(U,z,X.length);L=z+X.length+J,$=void 0}else{if(K===" "&&A&&A!==" "&&A!==`
7
- `&&A!=="\t"){let C=U[z+1];if(C&&C!==" "&&C!==`
8
- `&&C!=="\t")$=z}if(z>=L)if($)W.push($),L=$+J,$=void 0;else if(q==="quoted"){while(A===" "||A==="\t")A=K,K=U[z+=1],B=!0;let C=z>D+1?z-2:O-1;if(_[C])return U;W.push(C),_[C]=!0,L=C+J,$=void 0}else B=!0}A=K}if(B&&H)H();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
- ${X}${U.slice(0,N)}`;else{if(q==="quoted"&&_[C])P+=`${U[C]}\\`;P+=`
10
- ${X}${U.slice(C+1,N)}`}}return P}function m8(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}OJ.FOLD_BLOCK="block";OJ.FOLD_FLOW="flow";OJ.FOLD_QUOTED="quoted";OJ.foldFlowLines=TJ});var v2=R((IJ)=>{var P0=i(),a0=p8(),o6=(U,X)=>({indentAtStart:X?U.indent.length:U.indentAtStart,lineWidth:U.options.lineWidth,minContentWidth:U.options.minContentWidth}),s6=(U)=>/^(%|---|\.\.\.)/m.test(U);function MJ(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
- `){if(G-Y>Z)return!0;if(Y=G+1,Q-Y<=Z)return!1}return!0}function k2(U,X){let q=JSON.stringify(U);if(X.options.doubleQuotedAsJSON)return q;let{implicitKey:Z}=X,Q=X.options.doubleQuotedMinMultiLineLength,G=X.indent||(s6(U)?" ":""),Y="",H=0;for(let J=0,W=q[J];W;W=q[++J]){if(W===" "&&q[J+1]==="\\"&&q[J+2]==="n")Y+=q.slice(H,J)+"\\ ",J+=1,H=J,W="\\";if(W==="\\")switch(q[J+1]){case"u":{Y+=q.slice(H,J);let _=q.substr(J+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(J,6)}J+=5,H=J+1}break;case"n":if(Z||q[J+2]==='"'||q.length<Q)J+=1;else{Y+=q.slice(H,J)+`
5
+ `+qX(q,U):(X.endsWith(" ")?"":" ")+q;BJ.indentComment=qX;BJ.lineComment=OJ;BJ.stringifyComment=VJ});var r8=R((wJ)=>{function MJ(X,U,q="flow",{indentAtStart:Z,lineWidth:Q=80,minContentWidth:G=20,onFold:Y,onOverflow:H}={}){if(!Q||Q<0)return X;if(Q<G)G=0;let J=Math.max(1+G,1+Q-U.length);if(X.length<=J)return X;let W=[],$={},_=Q-U.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,T=!1,z=-1,O=-1,D=-1;if(q==="block"){if(z=o8(X,z,U.length),z!==-1)_=z+J}for(let K;K=X[z+=1];){if(q==="quoted"&&K==="\\"){switch(O=z,X[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=o8(X,z,U.length);_=z+U.length+J,L=void 0}else{if(K===" "&&A&&A!==" "&&A!==`
7
+ `&&A!=="\t"){let C=X[z+1];if(C&&C!==" "&&C!==`
8
+ `&&C!=="\t")L=z}if(z>=_)if(L)W.push(L),_=L+J,L=void 0;else if(q==="quoted"){while(A===" "||A==="\t")A=K,K=X[z+=1],T=!0;let C=z>D+1?z-2:O-1;if($[C])return X;W.push(C),$[C]=!0,_=C+J,L=void 0}else T=!0}A=K}if(T&&H)H();if(W.length===0)return X;if(Y)Y();let P=X.slice(0,W[0]);for(let K=0;K<W.length;++K){let C=W[K],N=W[K+1]||X.length;if(C===0)P=`
9
+ ${U}${X.slice(0,N)}`;else{if(q==="quoted"&&$[C])P+=`${X[C]}\\`;P+=`
10
+ ${U}${X.slice(C+1,N)}`}}return P}function o8(X,U,q){let Z=U,Q=U+1,G=X[Q];while(G===" "||G==="\t")if(U<Q+q)G=X[++U];else{do G=X[++U];while(G&&G!==`
11
+ `);Z=U,Q=U+1,G=X[Q]}return Z}wJ.FOLD_BLOCK="block";wJ.FOLD_FLOW="flow";wJ.FOLD_QUOTED="quoted";wJ.foldFlowLines=MJ});var p2=R((bJ)=>{var I0=i(),n0=r8(),n6=(X,U)=>({indentAtStart:U?X.indent.length:X.indentAtStart,lineWidth:X.options.lineWidth,minContentWidth:X.options.minContentWidth}),t6=(X)=>/^(%|---|\.\.\.)/m.test(X);function CJ(X,U,q){if(!U||U<0)return!1;let Z=U-q,Q=X.length;if(Q<=Z)return!1;for(let G=0,Y=0;G<Q;++G)if(X[G]===`
12
+ `){if(G-Y>Z)return!0;if(Y=G+1,Q-Y<=Z)return!1}return!0}function m2(X,U){let q=JSON.stringify(X);if(U.options.doubleQuotedAsJSON)return q;let{implicitKey:Z}=U,Q=U.options.doubleQuotedMinMultiLineLength,G=U.indent||(t6(X)?" ":""),Y="",H=0;for(let J=0,W=q[J];W;W=q[++J]){if(W===" "&&q[J+1]==="\\"&&q[J+2]==="n")Y+=q.slice(H,J)+"\\ ",J+=1,H=J,W="\\";if(W==="\\")switch(q[J+1]){case"u":{Y+=q.slice(H,J);let $=q.substr(J+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(J,6)}J+=5,H=J+1}break;case"n":if(Z||q[J+2]==='"'||q.length<Q)J+=1;else{Y+=q.slice(H,J)+`
13
13
 
14
14
  `;while(q[J+2]==="\\"&&q[J+3]==="n"&&q[J+4]!=='"')Y+=`
15
- `,J+=2;if(Y+=G,q[J+2]===" ")Y+="\\";J+=1,H=J+1}break;default:J+=1}}return Y=H?Y+q.slice(H):q,Z?Y:a0.foldFlowLines(Y,G,a0.FOLD_QUOTED,o6(X,!1))}function a9(U,X){if(X.options.singleQuote===!1||X.implicitKey&&U.includes(`
16
- `)||/[ \t]\n|\n[ \t]/.test(U))return k2(U,X);let q=X.indent||(s6(U)?" ":""),Z="'"+U.replace(/'/g,"''").replace(/\n+/g,`$&
17
- ${q}`)+"'";return X.implicitKey?Z:a0.foldFlowLines(Z,q,a0.FOLD_FLOW,o6(X,!1))}function i1(U,X){let{singleQuote:q}=X.options,Z;if(q===!1)Z=k2;else{let Q=U.includes('"'),G=U.includes("'");if(Q&&!G)Z=a9;else if(G&&!Q)Z=k2;else Z=q?a9:k2}return Z(U,X)}var t9;try{t9=new RegExp(`(^|(?<!
15
+ `,J+=2;if(Y+=G,q[J+2]===" ")Y+="\\";J+=1,H=J+1}break;default:J+=1}}return Y=H?Y+q.slice(H):q,Z?Y:n0.foldFlowLines(Y,G,n0.FOLD_QUOTED,n6(U,!1))}function ZX(X,U){if(U.options.singleQuote===!1||U.implicitKey&&X.includes(`
16
+ `)||/[ \t]\n|\n[ \t]/.test(X))return m2(X,U);let q=U.indent||(t6(X)?" ":""),Z="'"+X.replace(/'/g,"''").replace(/\n+/g,`$&
17
+ ${q}`)+"'";return U.implicitKey?Z:n0.foldFlowLines(Z,q,n0.FOLD_FLOW,n6(U,!1))}function s1(X,U){let{singleQuote:q}=U.options,Z;if(q===!1)Z=m2;else{let Q=X.includes('"'),G=X.includes("'");if(Q&&!G)Z=ZX;else if(G&&!Q)Z=m2;else Z=q?ZX:m2}return Z(X,U)}var QX;try{QX=new RegExp(`(^|(?<!
18
18
  ))
19
19
  +(?!
20
- |$)`,"g")}catch{t9=/\n+(?!\n|$)/g}function i6({comment:U,type:X,value:q},Z,Q,G){let{blockQuote:Y,commentString:H,lineWidth:J}=Z.options;if(!Y||/\n[\t ]+$/.test(q))return i1(q,Z);let W=Z.indent||(Z.forceBlockIndent||s6(q)?" ":""),_=Y==="literal"?!0:Y==="folded"||X===P0.Scalar.BLOCK_FOLDED?!1:X===P0.Scalar.BLOCK_LITERAL?!0:!MJ(q,J,W.length);if(!q)return _?`|
20
+ |$)`,"g")}catch{QX=/\n+(?!\n|$)/g}function a6({comment:X,type:U,value:q},Z,Q,G){let{blockQuote:Y,commentString:H,lineWidth:J}=Z.options;if(!Y||/\n[\t ]+$/.test(q))return s1(q,Z);let W=Z.indent||(Z.forceBlockIndent||t6(q)?" ":""),$=Y==="literal"?!0:Y==="folded"||U===I0.Scalar.BLOCK_FOLDED?!1:U===I0.Scalar.BLOCK_LITERAL?!0:!CJ(q,J,W.length);if(!q)return $?`|
21
21
  `:`>
22
- `;let L,$;for($=q.length;$>0;--$){let N=q[$-1];if(N!==`
23
- `&&N!=="\t"&&N!==" ")break}let A=q.substring($),B=A.indexOf(`
24
- `);if(B===-1)L="-";else if(q===A||B!==A.length-1){if(L="+",G)G()}else L="";if(A){if(q=q.slice(0,-A.length),A[A.length-1]===`
25
- `)A=A.slice(0,-1);A=A.replace(t9,`$&${W}`)}let z=!1,O,D=-1;for(O=0;O<q.length;++O){let N=q[O];if(N===" ")z=!0;else if(N===`
26
- `)D=O;else break}let P=q.substring(0,D<O?D+1:O);if(P)q=q.substring(P.length),P=P.replace(/\n+/g,`$&${W}`);let C=(z?W?"2":"1":"")+L;if(U){if(C+=" "+H(U.replace(/ ?[\r\n]+/g," ")),Q)Q()}if(!_){let N=q.replace(/\n+/g,`
27
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${W}`),j=!1,m=o6(Z,!0);if(Y!=="folded"&&X!==P0.Scalar.BLOCK_FOLDED)m.onOverflow=()=>{j=!0};let w=a0.foldFlowLines(`${P}${N}${A}`,W,a0.FOLD_BLOCK,m);if(!j)return`>${C}
22
+ `;let _,L;for(L=q.length;L>0;--L){let N=q[L-1];if(N!==`
23
+ `&&N!=="\t"&&N!==" ")break}let A=q.substring(L),T=A.indexOf(`
24
+ `);if(T===-1)_="-";else if(q===A||T!==A.length-1){if(_="+",G)G()}else _="";if(A){if(q=q.slice(0,-A.length),A[A.length-1]===`
25
+ `)A=A.slice(0,-1);A=A.replace(QX,`$&${W}`)}let z=!1,O,D=-1;for(O=0;O<q.length;++O){let N=q[O];if(N===" ")z=!0;else if(N===`
26
+ `)D=O;else break}let P=q.substring(0,D<O?D+1:O);if(P)q=q.substring(P.length),P=P.replace(/\n+/g,`$&${W}`);let C=(z?W?"2":"1":"")+_;if(X){if(C+=" "+H(X.replace(/ ?[\r\n]+/g," ")),Q)Q()}if(!$){let N=q.replace(/\n+/g,`
27
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${W}`),j=!1,m=n6(Z,!0);if(Y!=="folded"&&U!==I0.Scalar.BLOCK_FOLDED)m.onOverflow=()=>{j=!0};let w=n0.foldFlowLines(`${P}${N}${A}`,W,n0.FOLD_BLOCK,m);if(!j)return`>${C}
28
28
  ${W}${w}`}return q=q.replace(/\n+/g,`$&${W}`),`|${C}
29
- ${W}${P}${q}${A}`}function wJ(U,X,q,Z){let{type:Q,value:G}=U,{actualString:Y,implicitKey:H,indent:J,indentStep:W,inFlow:_}=X;if(H&&G.includes(`
30
- `)||_&&/[[\]{},]/.test(G))return i1(G,X);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(G))return H||_||!G.includes(`
31
- `)?i1(G,X):i6(U,X,q,Z);if(!H&&!_&&Q!==P0.Scalar.PLAIN&&G.includes(`
32
- `))return i6(U,X,q,Z);if(s6(G)){if(J==="")return X.forceBlockIndent=!0,i6(U,X,q,Z);else if(H&&J===W)return i1(G,X)}let L=G.replace(/\n+/g,`$&
33
- ${J}`);if(Y){let $=(z)=>z.default&&z.tag!=="tag:yaml.org,2002:str"&&z.test?.test(L),{compat:A,tags:B}=X.doc.schema;if(B.some($)||A?.some($))return i1(G,X)}return H?L:a0.foldFlowLines(L,J,a0.FOLD_FLOW,o6(X,!1))}function PJ(U,X,q,Z){let{implicitKey:Q,inFlow:G}=X,Y=typeof U.value==="string"?U:Object.assign({},U,{value:String(U.value)}),{type:H}=U;if(H!==P0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(Y.value))H=P0.Scalar.QUOTE_DOUBLE}let J=(_)=>{switch(_){case P0.Scalar.BLOCK_FOLDED:case P0.Scalar.BLOCK_LITERAL:return Q||G?i1(Y.value,X):i6(Y,X,q,Z);case P0.Scalar.QUOTE_DOUBLE:return k2(Y.value,X);case P0.Scalar.QUOTE_SINGLE:return a9(Y.value,X);case P0.Scalar.PLAIN:return wJ(Y,X,q,Z);default:return null}},W=J(H);if(W===null){let{defaultKeyType:_,defaultStringType:L}=X.options,$=Q&&_||L;if(W=J($),W===null)throw Error(`Unsupported default string type ${$}`)}return W}IJ.stringifyString=PJ});var x2=R((gJ)=>{var NJ=p6(),t0=k(),CJ=y2(),SJ=v2();function EJ(U,X){let q=Object.assign({blockQuote:!0,commentString:CJ.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 bJ(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(t0.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 jJ(U,X,{anchors:q,doc:Z}){if(!Z.directives)return"";let Q=[],G=(t0.isScalar(U)||t0.isCollection(U))&&U.anchor;if(G&&NJ.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 fJ(U,X,q,Z){if(t0.isPair(U))return U.toString(X,q,Z);if(t0.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=t0.isNode(U)?U:X.doc.createNode(U,{onTagObj:(J)=>Q=J});Q??(Q=bJ(X.doc.schema.tags,G));let Y=jJ(G,Q,X);if(Y.length>0)X.indentAtStart=(X.indentAtStart??0)+Y.length+1;let H=typeof Q.stringify==="function"?Q.stringify(G,X,q,Z):t0.isScalar(G)?SJ.stringifyString(G,X,q,Z):G.toString(X,q,Z);if(!Y)return H;return t0.isScalar(G)||H[0]==="{"||H[0]==="["?`${Y} ${H}`:`${Y}
34
- ${X.indent}${H}`}gJ.createStringifyContext=EJ;gJ.stringify=fJ});var c8=R((xJ)=>{var u0=k(),l8=i(),d8=x2(),h2=y2();function vJ({key:U,value:X},q,Z,Q){let{allNullValues:G,doc:Y,indent:H,indentStep:J,options:{commentString:W,indentSeq:_,simpleKeys:L}}=q,$=u0.isNode(U)&&U.comment||null;if(L){if($)throw Error("With simple keys, key nodes cannot have comments");if(u0.isCollection(U)||!u0.isNode(U)&&typeof U==="object")throw Error("With simple keys, collection cannot be used as a key value")}let A=!L&&(!U||$&&X==null&&!q.inFlow||u0.isCollection(U)||(u0.isScalar(U)?U.type===l8.Scalar.BLOCK_FOLDED||U.type===l8.Scalar.BLOCK_LITERAL:typeof U==="object"));q=Object.assign({},q,{allNullValues:!1,implicitKey:!A&&(L||!G),indent:H+J});let B=!1,z=!1,O=d8.stringify(U,q,()=>B=!0,()=>z=!0);if(!A&&!q.inFlow&&O.length>1024){if(L)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(B&&Z)Z();return O===""?"?":A?`? ${O}`:O}}else if(G&&!L||X==null&&A){if(O=`? ${O}`,$&&!B)O+=h2.lineComment(O,q.indent,W($));else if(z&&Q)Q();return O}if(B)$=null;if(A){if($)O+=h2.lineComment(O,q.indent,W($));O=`? ${O}
35
- ${H}:`}else if(O=`${O}:`,$)O+=h2.lineComment(O,q.indent,W($));let D,P,K;if(u0.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&&!$&&u0.isScalar(X))q.indentAtStart=O.length+1;if(z=!1,!_&&J.length>=2&&!q.inFlow&&!A&&u0.isSeq(X)&&!X.flow&&!X.tag&&!X.anchor)q.indent=q.indent.substring(2);let C=!1,N=d8.stringify(X,q,()=>C=!0,()=>z=!0),j=" ";if($||D||P){if(j=D?`
29
+ ${W}${P}${q}${A}`}function SJ(X,U,q,Z){let{type:Q,value:G}=X,{actualString:Y,implicitKey:H,indent:J,indentStep:W,inFlow:$}=U;if(H&&G.includes(`
30
+ `)||$&&/[[\]{},]/.test(G))return s1(G,U);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(G))return H||$||!G.includes(`
31
+ `)?s1(G,U):a6(X,U,q,Z);if(!H&&!$&&Q!==I0.Scalar.PLAIN&&G.includes(`
32
+ `))return a6(X,U,q,Z);if(t6(G)){if(J==="")return U.forceBlockIndent=!0,a6(X,U,q,Z);else if(H&&J===W)return s1(G,U)}let _=G.replace(/\n+/g,`$&
33
+ ${J}`);if(Y){let L=(z)=>z.default&&z.tag!=="tag:yaml.org,2002:str"&&z.test?.test(_),{compat:A,tags:T}=U.doc.schema;if(T.some(L)||A?.some(L))return s1(G,U)}return H?_:n0.foldFlowLines(_,J,n0.FOLD_FLOW,n6(U,!1))}function EJ(X,U,q,Z){let{implicitKey:Q,inFlow:G}=U,Y=typeof X.value==="string"?X:Object.assign({},X,{value:String(X.value)}),{type:H}=X;if(H!==I0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(Y.value))H=I0.Scalar.QUOTE_DOUBLE}let J=($)=>{switch($){case I0.Scalar.BLOCK_FOLDED:case I0.Scalar.BLOCK_LITERAL:return Q||G?s1(Y.value,U):a6(Y,U,q,Z);case I0.Scalar.QUOTE_DOUBLE:return m2(Y.value,U);case I0.Scalar.QUOTE_SINGLE:return ZX(Y.value,U);case I0.Scalar.PLAIN:return SJ(Y,U,q,Z);default:return null}},W=J(H);if(W===null){let{defaultKeyType:$,defaultStringType:_}=U.options,L=Q&&$||_;if(W=J(L),W===null)throw Error(`Unsupported default string type ${L}`)}return W}bJ.stringifyString=EJ});var l2=R((uJ)=>{var fJ=i6(),t0=k(),yJ=u2(),gJ=p2();function kJ(X,U){let q=Object.assign({blockQuote:!0,commentString:yJ.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},X.schema.toStringOptions,U),Z;switch(q.collectionStyle){case"block":Z=!1;break;case"flow":Z=!0;break;default:Z=null}return{anchors:new Set,doc:X,flowCollectionPadding:q.flowCollectionPadding?" ":"",indent:"",indentStep:typeof q.indent==="number"?" ".repeat(q.indent):" ",inFlow:Z,options:q}}function vJ(X,U){if(U.tag){let Q=X.filter((G)=>G.tag===U.tag);if(Q.length>0)return Q.find((G)=>G.format===U.format)??Q[0]}let q=void 0,Z;if(t0.isScalar(U)){Z=U.value;let Q=X.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===U.format)??Q.find((G)=>!G.format)}else Z=U,q=X.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 xJ(X,U,{anchors:q,doc:Z}){if(!Z.directives)return"";let Q=[],G=(t0.isScalar(X)||t0.isCollection(X))&&X.anchor;if(G&&fJ.anchorIsValid(G))q.add(G),Q.push(`&${G}`);let Y=X.tag??(U.default?null:U.tag);if(Y)Q.push(Z.directives.tagString(Y));return Q.join(" ")}function hJ(X,U,q,Z){if(t0.isPair(X))return X.toString(U,q,Z);if(t0.isAlias(X)){if(U.doc.directives)return X.toString(U);if(U.resolvedAliases?.has(X))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(U.resolvedAliases)U.resolvedAliases.add(X);else U.resolvedAliases=new Set([X]);X=X.resolve(U.doc)}}let Q=void 0,G=t0.isNode(X)?X:U.doc.createNode(X,{onTagObj:(J)=>Q=J});Q??(Q=vJ(U.doc.schema.tags,G));let Y=xJ(G,Q,U);if(Y.length>0)U.indentAtStart=(U.indentAtStart??0)+Y.length+1;let H=typeof Q.stringify==="function"?Q.stringify(G,U,q,Z):t0.isScalar(G)?gJ.stringifyString(G,U,q,Z):G.toString(U,q,Z);if(!Y)return H;return t0.isScalar(G)||H[0]==="{"||H[0]==="["?`${Y} ${H}`:`${Y}
34
+ ${U.indent}${H}`}uJ.createStringifyContext=kJ;uJ.stringify=hJ});var t8=R((dJ)=>{var u0=k(),a8=i(),n8=l2(),d2=u2();function lJ({key:X,value:U},q,Z,Q){let{allNullValues:G,doc:Y,indent:H,indentStep:J,options:{commentString:W,indentSeq:$,simpleKeys:_}}=q,L=u0.isNode(X)&&X.comment||null;if(_){if(L)throw Error("With simple keys, key nodes cannot have comments");if(u0.isCollection(X)||!u0.isNode(X)&&typeof X==="object")throw Error("With simple keys, collection cannot be used as a key value")}let A=!_&&(!X||L&&U==null&&!q.inFlow||u0.isCollection(X)||(u0.isScalar(X)?X.type===a8.Scalar.BLOCK_FOLDED||X.type===a8.Scalar.BLOCK_LITERAL:typeof X==="object"));q=Object.assign({},q,{allNullValues:!1,implicitKey:!A&&(_||!G),indent:H+J});let T=!1,z=!1,O=n8.stringify(X,q,()=>T=!0,()=>z=!0);if(!A&&!q.inFlow&&O.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||U==null){if(T&&Z)Z();return O===""?"?":A?`? ${O}`:O}}else if(G&&!_||U==null&&A){if(O=`? ${O}`,L&&!T)O+=d2.lineComment(O,q.indent,W(L));else if(z&&Q)Q();return O}if(T)L=null;if(A){if(L)O+=d2.lineComment(O,q.indent,W(L));O=`? ${O}
35
+ ${H}:`}else if(O=`${O}:`,L)O+=d2.lineComment(O,q.indent,W(L));let D,P,K;if(u0.isNode(U))D=!!U.spaceBefore,P=U.commentBefore,K=U.comment;else if(D=!1,P=null,K=null,U&&typeof U==="object")U=Y.createNode(U);if(q.implicitKey=!1,!A&&!L&&u0.isScalar(U))q.indentAtStart=O.length+1;if(z=!1,!$&&J.length>=2&&!q.inFlow&&!A&&u0.isSeq(U)&&!U.flow&&!U.tag&&!U.anchor)q.indent=q.indent.substring(2);let C=!1,N=n8.stringify(U,q,()=>C=!0,()=>z=!0),j=" ";if(L||D||P){if(j=D?`
36
36
  `:"",P){let m=W(P);j+=`
37
- ${h2.indentComment(m,q.indent)}`}if(N===""&&!q.inFlow){if(j===`
37
+ ${d2.indentComment(m,q.indent)}`}if(N===""&&!q.inFlow){if(j===`
38
38
  `&&K)j=`
39
39
 
40
40
  `}else j+=`
41
- ${q.indent}`}else if(!A&&u0.isCollection(X)){let m=N[0],w=N.indexOf(`
42
- `),o=w!==-1,m0=q.inFlow??X.flow??X.items.length===0;if(o||!m0){let D1=!1;if(o&&(m==="&"||m==="!")){let s=N.indexOf(" ");if(m==="&"&&s!==-1&&s<w&&N[s+1]==="!")s=N.indexOf(" ",s+1);if(s===-1||w<s)D1=!0}if(!D1)j=`
41
+ ${q.indent}`}else if(!A&&u0.isCollection(U)){let m=N[0],w=N.indexOf(`
42
+ `),s=w!==-1,m0=q.inFlow??U.flow??U.items.length===0;if(s||!m0){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)j=`
43
43
  ${q.indent}`}}else if(N===""||N[0]===`
44
- `)j="";if(O+=j+N,q.inFlow){if(C&&Z)Z()}else if(K&&!C)O+=h2.lineComment(O,q.indent,W(K));else if(z&&Q)Q();return O}xJ.stringifyPair=vJ});var e9=R((pJ)=>{var i8=M1("process");function uJ(U,...X){if(U==="debug")console.log(...X)}function mJ(U,X){if(U==="debug"||U==="warn")if(typeof i8.emitWarning==="function")i8.emitWarning(X);else console.warn(X)}pJ.debug=uJ;pJ.warn=mJ});var a6=R((iJ)=>{var u2=k(),o8=i(),r6="<<",n6={identify:(U)=>U===r6||typeof U==="symbol"&&U.description===r6,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new o8.Scalar(Symbol(r6)),{addToJSMap:s8}),stringify:()=>r6},cJ=(U,X)=>(n6.identify(X)||u2.isScalar(X)&&(!X.type||X.type===o8.Scalar.PLAIN)&&n6.identify(X.value))&&U?.doc.schema.tags.some((q)=>q.tag===n6.tag&&q.default);function s8(U,X,q){if(q=U&&u2.isAlias(q)?q.resolve(U.doc):q,u2.isSeq(q))for(let Z of q.items)UU(U,X,Z);else if(Array.isArray(q))for(let Z of q)UU(U,X,Z);else UU(U,X,q)}function UU(U,X,q){let Z=U&&u2.isAlias(q)?q.resolve(U.doc):q;if(!u2.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}iJ.addMergeToJSMap=s8;iJ.isMergeKey=cJ;iJ.merge=n6});var qU=R((UW)=>{var nJ=e9(),r8=a6(),aJ=x2(),n8=k(),XU=n0();function tJ(U,X,{key:q,value:Z}){if(n8.isNode(q)&&q.addToJSMap)q.addToJSMap(U,X,Z);else if(r8.isMergeKey(U,q))r8.addMergeToJSMap(U,X,Z);else{let Q=XU.toJS(q,"",U);if(X instanceof Map)X.set(Q,XU.toJS(Z,Q,U));else if(X instanceof Set)X.add(Q);else{let G=eJ(q,Q,U),Y=XU.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 eJ(U,X,q){if(X===null)return"";if(typeof X!=="object")return String(X);if(n8.isNode(U)&&q?.doc){let Z=aJ.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)+'..."';nJ.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)}UW.addPairToJSMap=tJ});var e0=R((GW)=>{var a8=g2(),qW=c8(),ZW=qU(),t6=k();function QW(U,X,q){let Z=a8.createNode(U,void 0,q),Q=a8.createNode(X,void 0,q);return new e6(Z,Q)}class e6{constructor(U,X=null){Object.defineProperty(this,t6.NODE_TYPE,{value:t6.PAIR}),this.key=U,this.value=X}clone(U){let{key:X,value:q}=this;if(t6.isNode(X))X=X.clone(U);if(t6.isNode(q))q=q.clone(U);return new e6(X,q)}toJSON(U,X){let q=X?.mapAsMap?new Map:{};return ZW.addPairToJSMap(X,q,this)}toString(U,X,q){return U?.doc?qW.stringifyPair(this,U,X,q):JSON.stringify(this)}}GW.Pair=e6;GW.createPair=QW});var ZU=R((_W)=>{var A1=k(),t8=x2(),U4=y2();function JW(U,X,q){return(X.inFlow??U.flow?LW:WW)(U,X,q)}function WW({comment:U,items:X},q,{blockItemPrefix:Z,flowChars:Q,itemIndent:G,onChompKeep:Y,onComment:H}){let{indent:J,options:{commentString:W}}=q,_=Object.assign({},q,{indent:G,type:null}),L=!1,$=[];for(let B=0;B<X.length;++B){let z=X[B],O=null;if(A1.isNode(z)){if(!L&&z.spaceBefore)$.push("");if(X4(q,$,z.commentBefore,L),z.comment)O=z.comment}else if(A1.isPair(z)){let P=A1.isNode(z.key)?z.key:null;if(P){if(!L&&P.spaceBefore)$.push("");X4(q,$,P.commentBefore,L)}}L=!1;let D=t8.stringify(z,_,()=>O=null,()=>L=!0);if(O)D+=U4.lineComment(D,G,W(O));if(L&&O)L=!1;$.push(Z+D)}let A;if($.length===0)A=Q.start+Q.end;else{A=$[0];for(let B=1;B<$.length;++B){let z=$[B];A+=z?`
44
+ `)j="";if(O+=j+N,q.inFlow){if(C&&Z)Z()}else if(K&&!C)O+=d2.lineComment(O,q.indent,W(K));else if(z&&Q)Q();return O}dJ.stringifyPair=lJ});var GX=R((oJ)=>{var e8=w1("process");function iJ(X,...U){if(X==="debug")console.log(...U)}function sJ(X,U){if(X==="debug"||X==="warn")if(typeof e8.emitWarning==="function")e8.emitWarning(U);else console.warn(U)}oJ.debug=iJ;oJ.warn=sJ});var U4=R((tJ)=>{var c2=k(),X3=i(),e6="<<",X4={identify:(X)=>X===e6||typeof X==="symbol"&&X.description===e6,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new X3.Scalar(Symbol(e6)),{addToJSMap:U3}),stringify:()=>e6},nJ=(X,U)=>(X4.identify(U)||c2.isScalar(U)&&(!U.type||U.type===X3.Scalar.PLAIN)&&X4.identify(U.value))&&X?.doc.schema.tags.some((q)=>q.tag===X4.tag&&q.default);function U3(X,U,q){if(q=X&&c2.isAlias(q)?q.resolve(X.doc):q,c2.isSeq(q))for(let Z of q.items)YX(X,U,Z);else if(Array.isArray(q))for(let Z of q)YX(X,U,Z);else YX(X,U,q)}function YX(X,U,q){let Z=X&&c2.isAlias(q)?q.resolve(X.doc):q;if(!c2.isMap(Z))throw Error("Merge sources must be maps or map aliases");let Q=Z.toJSON(null,X,Map);for(let[G,Y]of Q)if(U instanceof Map){if(!U.has(G))U.set(G,Y)}else if(U instanceof Set)U.add(G);else if(!Object.prototype.hasOwnProperty.call(U,G))Object.defineProperty(U,G,{value:Y,writable:!0,enumerable:!0,configurable:!0});return U}tJ.addMergeToJSMap=U3;tJ.isMergeKey=nJ;tJ.merge=X4});var JX=R((YW)=>{var qW=GX(),q3=U4(),ZW=l2(),Z3=k(),HX=a0();function QW(X,U,{key:q,value:Z}){if(Z3.isNode(q)&&q.addToJSMap)q.addToJSMap(X,U,Z);else if(q3.isMergeKey(X,q))q3.addMergeToJSMap(X,U,Z);else{let Q=HX.toJS(q,"",X);if(U instanceof Map)U.set(Q,HX.toJS(Z,Q,X));else if(U instanceof Set)U.add(Q);else{let G=GW(q,Q,X),Y=HX.toJS(Z,G,X);if(G in U)Object.defineProperty(U,G,{value:Y,writable:!0,enumerable:!0,configurable:!0});else U[G]=Y}}return U}function GW(X,U,q){if(U===null)return"";if(typeof U!=="object")return String(U);if(Z3.isNode(X)&&q?.doc){let Z=ZW.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=X.toString(Z);if(!q.mapKeyWarned){let G=JSON.stringify(Q);if(G.length>40)G=G.substring(0,36)+'..."';qW.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(U)}YW.addPairToJSMap=QW});var e0=R(($W)=>{var Q3=h2(),JW=t8(),WW=JX(),q4=k();function _W(X,U,q){let Z=Q3.createNode(X,void 0,q),Q=Q3.createNode(U,void 0,q);return new Z4(Z,Q)}class Z4{constructor(X,U=null){Object.defineProperty(this,q4.NODE_TYPE,{value:q4.PAIR}),this.key=X,this.value=U}clone(X){let{key:U,value:q}=this;if(q4.isNode(U))U=U.clone(X);if(q4.isNode(q))q=q.clone(X);return new Z4(U,q)}toJSON(X,U){let q=U?.mapAsMap?new Map:{};return WW.addPairToJSMap(U,q,this)}toString(X,U,q){return X?.doc?JW.stringifyPair(this,X,U,q):JSON.stringify(this)}}$W.Pair=Z4;$W.createPair=_W});var WX=R((OW)=>{var V1=k(),G3=l2(),Q4=u2();function FW(X,U,q){return(U.inFlow??X.flow?VW:AW)(X,U,q)}function AW({comment:X,items:U},q,{blockItemPrefix:Z,flowChars:Q,itemIndent:G,onChompKeep:Y,onComment:H}){let{indent:J,options:{commentString:W}}=q,$=Object.assign({},q,{indent:G,type:null}),_=!1,L=[];for(let T=0;T<U.length;++T){let z=U[T],O=null;if(V1.isNode(z)){if(!_&&z.spaceBefore)L.push("");if(G4(q,L,z.commentBefore,_),z.comment)O=z.comment}else if(V1.isPair(z)){let P=V1.isNode(z.key)?z.key:null;if(P){if(!_&&P.spaceBefore)L.push("");G4(q,L,P.commentBefore,_)}}_=!1;let D=G3.stringify(z,$,()=>O=null,()=>_=!0);if(O)D+=Q4.lineComment(D,G,W(O));if(_&&O)_=!1;L.push(Z+D)}let A;if(L.length===0)A=Q.start+Q.end;else{A=L[0];for(let T=1;T<L.length;++T){let z=L[T];A+=z?`
45
45
  ${J}${z}`:`
46
- `}}if(U){if(A+=`
47
- `+U4.indentComment(W(U),J),H)H()}else if(L&&Y)Y();return A}function LW({items:U},X,{flowChars:q,itemIndent:Z}){let{indent:Q,indentStep:G,flowCollectionPadding:Y,options:{commentString:H}}=X;Z+=G;let J=Object.assign({},X,{indent:Z,inFlow:!0,type:null}),W=!1,_=0,L=[];for(let B=0;B<U.length;++B){let z=U[B],O=null;if(A1.isNode(z)){if(z.spaceBefore)L.push("");if(X4(X,L,z.commentBefore,!1),z.comment)O=z.comment}else if(A1.isPair(z)){let P=A1.isNode(z.key)?z.key:null;if(P){if(P.spaceBefore)L.push("");if(X4(X,L,P.commentBefore,!1),P.comment)W=!0}let K=A1.isNode(z.value)?z.value:null;if(K){if(K.comment)O=K.comment;if(K.commentBefore)W=!0}else if(z.value==null&&P?.comment)O=P.comment}if(O)W=!0;let D=t8.stringify(z,J,()=>O=null);if(B<U.length-1)D+=",";if(O)D+=U4.lineComment(D,Z,H(O));if(!W&&(L.length>_||D.includes(`
48
- `)))W=!0;L.push(D),_=L.length}let{start:$,end:A}=q;if(L.length===0)return $+A;else{if(!W){let B=L.reduce((z,O)=>z+O.length+2,2);W=X.options.lineWidth>0&&B>X.options.lineWidth}if(W){let B=$;for(let z of L)B+=z?`
46
+ `}}if(X){if(A+=`
47
+ `+Q4.indentComment(W(X),J),H)H()}else if(_&&Y)Y();return A}function VW({items:X},U,{flowChars:q,itemIndent:Z}){let{indent:Q,indentStep:G,flowCollectionPadding:Y,options:{commentString:H}}=U;Z+=G;let J=Object.assign({},U,{indent:Z,inFlow:!0,type:null}),W=!1,$=0,_=[];for(let T=0;T<X.length;++T){let z=X[T],O=null;if(V1.isNode(z)){if(z.spaceBefore)_.push("");if(G4(U,_,z.commentBefore,!1),z.comment)O=z.comment}else if(V1.isPair(z)){let P=V1.isNode(z.key)?z.key:null;if(P){if(P.spaceBefore)_.push("");if(G4(U,_,P.commentBefore,!1),P.comment)W=!0}let K=V1.isNode(z.value)?z.value:null;if(K){if(K.comment)O=K.comment;if(K.commentBefore)W=!0}else if(z.value==null&&P?.comment)O=P.comment}if(O)W=!0;let D=G3.stringify(z,J,()=>O=null);if(T<X.length-1)D+=",";if(O)D+=Q4.lineComment(D,Z,H(O));if(!W&&(_.length>$||D.includes(`
48
+ `)))W=!0;_.push(D),$=_.length}let{start:L,end:A}=q;if(_.length===0)return L+A;else{if(!W){let T=_.reduce((z,O)=>z+O.length+2,2);W=U.options.lineWidth>0&&T>U.options.lineWidth}if(W){let T=L;for(let z of _)T+=z?`
49
49
  ${G}${Q}${z}`:`
50
- `;return`${B}
51
- ${Q}${A}`}else return`${$}${Y}${L.join(" ")}${Y}${A}`}}function X4({indent:U,options:{commentString:X}},q,Z,Q){if(Z&&Q)Z=Z.replace(/^\n+/,"");if(Z){let G=U4.indentComment(X(Z),U);q.push(G.trimStart())}}_W.stringifyCollection=JW});var X1=R((OW)=>{var zW=ZU(),FW=qU(),AW=c6(),U1=k(),q4=e0(),TW=i();function m2(U,X){let q=U1.isScalar(X)?X.value:X;for(let Z of U)if(U1.isPair(Z)){if(Z.key===X||Z.key===q)return Z;if(U1.isScalar(Z.key)&&Z.key.value===q)return Z}return}class e8 extends AW.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(U){super(U1.MAP,U);this.items=[]}static from(U,X,q){let{keepUndefined:Z,replacer:Q}=q,G=new this(U),Y=(H,J)=>{if(typeof Q==="function")J=Q.call(X,H,J);else if(Array.isArray(Q)&&!Q.includes(H))return;if(J!==void 0||Z)G.items.push(q4.createPair(H,J,q))};if(X instanceof Map)for(let[H,J]of X)Y(H,J);else if(X&&typeof X==="object")for(let H of Object.keys(X))Y(H,X[H]);if(typeof U.sortMapEntries==="function")G.items.sort(U.sortMapEntries);return G}add(U,X){let q;if(U1.isPair(U))q=U;else if(!U||typeof U!=="object"||!("key"in U))q=new q4.Pair(U,U?.value);else q=new q4.Pair(U.key,U.value);let Z=m2(this.items,q.key),Q=this.schema?.sortMapEntries;if(Z){if(!X)throw Error(`Key ${q.key} already set`);if(U1.isScalar(Z.value)&&TW.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=m2(this.items,U);if(!X)return!1;return this.items.splice(this.items.indexOf(X),1).length>0}get(U,X){let Z=m2(this.items,U)?.value;return(!X&&U1.isScalar(Z)?Z.value:Z)??void 0}has(U){return!!m2(this.items,U)}set(U,X){this.add(new q4.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)FW.addPairToJSMap(X,Z,Q);return Z}toString(U,X,q){if(!U)return JSON.stringify(this);for(let Z of this.items)if(!U1.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 zW.stringifyCollection(this,U,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:U.indent||"",onChompKeep:q,onComment:X})}}OW.YAMLMap=e8;OW.findPair=m2});var o1=R((MW)=>{var RW=k(),U3=X1(),DW={collection:"map",default:!0,nodeClass:U3.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(U,X){if(!RW.isMap(U))X("Expected a mapping for this tag");return U},createNode:(U,X,q)=>U3.YAMLMap.from(U,X,q)};MW.map=DW});var q1=R((SW)=>{var PW=g2(),IW=ZU(),KW=c6(),Q4=k(),NW=i(),CW=n0();class X3 extends KW.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(U){super(Q4.SEQ,U);this.items=[]}add(U){this.items.push(U)}delete(U){let X=Z4(U);if(typeof X!=="number")return!1;return this.items.splice(X,1).length>0}get(U,X){let q=Z4(U);if(typeof q!=="number")return;let Z=this.items[q];return!X&&Q4.isScalar(Z)?Z.value:Z}has(U){let X=Z4(U);return typeof X==="number"&&X<this.items.length}set(U,X){let q=Z4(U);if(typeof q!=="number")throw Error(`Expected a valid index, not ${U}.`);let Z=this.items[q];if(Q4.isScalar(Z)&&NW.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 IW.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 H=X instanceof Set?Y:String(G++);Y=Z.call(X,H,Y)}Q.items.push(PW.createNode(Y,void 0,q))}}return Q}}function Z4(U){let X=Q4.isScalar(U)?U.value:U;if(X&&typeof X==="string")X=Number(X);return typeof X==="number"&&Number.isInteger(X)&&X>=0?X:null}SW.YAMLSeq=X3});var s1=R((fW)=>{var bW=k(),q3=q1(),jW={collection:"seq",default:!0,nodeClass:q3.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(U,X){if(!bW.isSeq(U))X("Expected a sequence for this tag");return U},createNode:(U,X,q)=>q3.YAMLSeq.from(U,X,q)};fW.seq=jW});var p2=R((vW)=>{var yW=v2(),kW={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),yW.stringifyString(U,X,q,Z)}};vW.string=kW});var G4=R((hW)=>{var Z3=i(),Q3={identify:(U)=>U==null,createNode:()=>new Z3.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Z3.Scalar(null),stringify:({source:U},X)=>typeof U==="string"&&Q3.test.test(U)?U:X.options.nullStr};hW.nullTag=Q3});var QU=R((pW)=>{var mW=i(),G3={identify:(U)=>typeof U==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(U)=>new mW.Scalar(U[0]==="t"||U[0]==="T"),stringify({source:U,value:X},q){if(U&&G3.test.test(U)){let Z=U[0]==="t"||U[0]==="T";if(X===Z)return U}return X?q.options.trueStr:q.options.falseStr}};pW.boolTag=G3});var r1=R((cW)=>{function dW({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 H=X-(G.length-Y-1);while(H-- >0)G+="0"}return G}cW.stringifyNumber=dW});var YU=R((aW)=>{var oW=i(),GU=r1(),sW={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:GU.stringifyNumber},rW={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():GU.stringifyNumber(U)}},nW={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 oW.Scalar(parseFloat(U)),q=U.indexOf(".");if(q!==-1&&U[U.length-1]==="0")X.minFractionDigits=U.length-q-1;return X},stringify:GU.stringifyNumber};aW.float=nW;aW.floatExp=rW;aW.floatNaN=sW});var JU=R((QL)=>{var Y3=r1(),Y4=(U)=>typeof U==="bigint"||Number.isInteger(U),HU=(U,X,q,{intAsBigInt:Z})=>Z?BigInt(U):parseInt(U.substring(X),q);function H3(U,X,q){let{value:Z}=U;if(Y4(Z)&&Z>=0)return q+Z.toString(X);return Y3.stringifyNumber(U)}var XL={identify:(U)=>Y4(U)&&U>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(U,X,q)=>HU(U,2,8,q),stringify:(U)=>H3(U,8,"0o")},qL={identify:Y4,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(U,X,q)=>HU(U,0,10,q),stringify:Y3.stringifyNumber},ZL={identify:(U)=>Y4(U)&&U>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(U,X,q)=>HU(U,2,16,q),stringify:(U)=>H3(U,16,"0x")};QL.int=qL;QL.intHex=ZL;QL.intOct=XL});var J3=R((FL)=>{var JL=o1(),WL=G4(),LL=s1(),_L=p2(),$L=QU(),WU=YU(),LU=JU(),zL=[JL.map,LL.seq,_L.string,WL.nullTag,$L.boolTag,LU.intOct,LU.int,LU.intHex,WU.floatNaN,WU.floatExp,WU.float];FL.schema=zL});var L3=R((ML)=>{var TL=i(),OL=o1(),VL=s1();function W3(U){return typeof U==="bigint"||Number.isInteger(U)}var H4=({value:U})=>JSON.stringify(U),BL=[{identify:(U)=>typeof U==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(U)=>U,stringify:H4},{identify:(U)=>U==null,createNode:()=>new TL.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:H4},{identify:(U)=>typeof U==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(U)=>U==="true",stringify:H4},{identify:W3,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})=>W3(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:H4}],RL={default:!0,tag:"",test:/^/,resolve(U,X){return X(`Unresolved plain scalar ${JSON.stringify(U)}`),U}},DL=[OL.map,VL.seq].concat(BL,RL);ML.schema=DL});var $U=R((KL)=>{var l2=M1("buffer"),_U=i(),PL=v2(),IL={identify:(U)=>U instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(U,X){if(typeof l2.Buffer==="function")return l2.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,H;if(typeof l2.Buffer==="function")H=Y instanceof l2.Buffer?Y.toString("base64"):l2.Buffer.from(Y.buffer).toString("base64");else if(typeof btoa==="function"){let J="";for(let W=0;W<Y.length;++W)J+=String.fromCharCode(Y[W]);H=btoa(J)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(X??(X=_U.Scalar.BLOCK_LITERAL),X!==_U.Scalar.QUOTE_DOUBLE){let J=Math.max(Z.options.lineWidth-Z.indent.length,Z.options.minContentWidth),W=Math.ceil(H.length/J),_=Array(W);for(let L=0,$=0;L<W;++L,$+=J)_[L]=H.substr($,J);H=_.join(X===_U.Scalar.BLOCK_LITERAL?`
52
- `:" ")}return PL.stringifyString({comment:U,type:X,value:H},Z,Q,G)}};KL.binary=IL});var W4=R((bL)=>{var J4=k(),zU=e0(),CL=i(),SL=q1();function _3(U,X){if(J4.isSeq(U))for(let q=0;q<U.items.length;++q){let Z=U.items[q];if(J4.isPair(Z))continue;else if(J4.isMap(Z)){if(Z.items.length>1)X("Each pair must have its own sequence indicator");let Q=Z.items[0]||new zU.Pair(new CL.Scalar(null));if(Z.commentBefore)Q.key.commentBefore=Q.key.commentBefore?`${Z.commentBefore}
50
+ `;return`${T}
51
+ ${Q}${A}`}else return`${L}${Y}${_.join(" ")}${Y}${A}`}}function G4({indent:X,options:{commentString:U}},q,Z,Q){if(Z&&Q)Z=Z.replace(/^\n+/,"");if(Z){let G=Q4.indentComment(U(Z),X);q.push(G.trimStart())}}OW.stringifyCollection=FW});var U1=R((wW)=>{var TW=WX(),RW=JX(),DW=r6(),X1=k(),Y4=e0(),MW=i();function i2(X,U){let q=X1.isScalar(U)?U.value:U;for(let Z of X)if(X1.isPair(Z)){if(Z.key===U||Z.key===q)return Z;if(X1.isScalar(Z.key)&&Z.key.value===q)return Z}return}class Y3 extends DW.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(X){super(X1.MAP,X);this.items=[]}static from(X,U,q){let{keepUndefined:Z,replacer:Q}=q,G=new this(X),Y=(H,J)=>{if(typeof Q==="function")J=Q.call(U,H,J);else if(Array.isArray(Q)&&!Q.includes(H))return;if(J!==void 0||Z)G.items.push(Y4.createPair(H,J,q))};if(U instanceof Map)for(let[H,J]of U)Y(H,J);else if(U&&typeof U==="object")for(let H of Object.keys(U))Y(H,U[H]);if(typeof X.sortMapEntries==="function")G.items.sort(X.sortMapEntries);return G}add(X,U){let q;if(X1.isPair(X))q=X;else if(!X||typeof X!=="object"||!("key"in X))q=new Y4.Pair(X,X?.value);else q=new Y4.Pair(X.key,X.value);let Z=i2(this.items,q.key),Q=this.schema?.sortMapEntries;if(Z){if(!U)throw Error(`Key ${q.key} already set`);if(X1.isScalar(Z.value)&&MW.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(X){let U=i2(this.items,X);if(!U)return!1;return this.items.splice(this.items.indexOf(U),1).length>0}get(X,U){let Z=i2(this.items,X)?.value;return(!U&&X1.isScalar(Z)?Z.value:Z)??void 0}has(X){return!!i2(this.items,X)}set(X,U){this.add(new Y4.Pair(X,U),!0)}toJSON(X,U,q){let Z=q?new q:U?.mapAsMap?new Map:{};if(U?.onCreate)U.onCreate(Z);for(let Q of this.items)RW.addPairToJSMap(U,Z,Q);return Z}toString(X,U,q){if(!X)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(!X.allNullValues&&this.hasAllNullValues(!1))X=Object.assign({},X,{allNullValues:!0});return TW.stringifyCollection(this,X,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:X.indent||"",onChompKeep:q,onComment:U})}}wW.YAMLMap=Y3;wW.findPair=i2});var o1=R((CW)=>{var KW=k(),H3=U1(),NW={collection:"map",default:!0,nodeClass:H3.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(X,U){if(!KW.isMap(X))U("Expected a mapping for this tag");return X},createNode:(X,U,q)=>H3.YAMLMap.from(X,U,q)};CW.map=NW});var q1=R((gW)=>{var EW=h2(),bW=WX(),jW=r6(),J4=k(),fW=i(),yW=a0();class J3 extends jW.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(X){super(J4.SEQ,X);this.items=[]}add(X){this.items.push(X)}delete(X){let U=H4(X);if(typeof U!=="number")return!1;return this.items.splice(U,1).length>0}get(X,U){let q=H4(X);if(typeof q!=="number")return;let Z=this.items[q];return!U&&J4.isScalar(Z)?Z.value:Z}has(X){let U=H4(X);return typeof U==="number"&&U<this.items.length}set(X,U){let q=H4(X);if(typeof q!=="number")throw Error(`Expected a valid index, not ${X}.`);let Z=this.items[q];if(J4.isScalar(Z)&&fW.isScalarValue(U))Z.value=U;else this.items[q]=U}toJSON(X,U){let q=[];if(U?.onCreate)U.onCreate(q);let Z=0;for(let Q of this.items)q.push(yW.toJS(Q,String(Z++),U));return q}toString(X,U,q){if(!X)return JSON.stringify(this);return bW.stringifyCollection(this,X,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(X.indent||"")+" ",onChompKeep:q,onComment:U})}static from(X,U,q){let{replacer:Z}=q,Q=new this(X);if(U&&Symbol.iterator in Object(U)){let G=0;for(let Y of U){if(typeof Z==="function"){let H=U instanceof Set?Y:String(G++);Y=Z.call(U,H,Y)}Q.items.push(EW.createNode(Y,void 0,q))}}return Q}}function H4(X){let U=J4.isScalar(X)?X.value:X;if(U&&typeof U==="string")U=Number(U);return typeof U==="number"&&Number.isInteger(U)&&U>=0?U:null}gW.YAMLSeq=J3});var r1=R((hW)=>{var vW=k(),W3=q1(),xW={collection:"seq",default:!0,nodeClass:W3.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(X,U){if(!vW.isSeq(X))U("Expected a sequence for this tag");return X},createNode:(X,U,q)=>W3.YAMLSeq.from(X,U,q)};hW.seq=xW});var s2=R((lW)=>{var mW=p2(),pW={identify:(X)=>typeof X==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(X)=>X,stringify(X,U,q,Z){return U=Object.assign({actualString:!0},U),mW.stringifyString(X,U,q,Z)}};lW.string=pW});var W4=R((cW)=>{var _3=i(),$3={identify:(X)=>X==null,createNode:()=>new _3.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new _3.Scalar(null),stringify:({source:X},U)=>typeof X==="string"&&$3.test.test(X)?X:U.options.nullStr};cW.nullTag=$3});var _X=R((oW)=>{var sW=i(),L3={identify:(X)=>typeof X==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(X)=>new sW.Scalar(X[0]==="t"||X[0]==="T"),stringify({source:X,value:U},q){if(X&&L3.test.test(X)){let Z=X[0]==="t"||X[0]==="T";if(U===Z)return X}return U?q.options.trueStr:q.options.falseStr}};oW.boolTag=L3});var a1=R((nW)=>{function aW({format:X,minFractionDigits:U,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(!X&&U&&(!q||q==="tag:yaml.org,2002:float")&&/^\d/.test(G)){let Y=G.indexOf(".");if(Y<0)Y=G.length,G+=".";let H=U-(G.length-Y-1);while(H-- >0)G+="0"}return G}nW.stringifyNumber=aW});var LX=R((Z_)=>{var eW=i(),$X=a1(),X_={identify:(X)=>typeof X==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(X)=>X.slice(-3).toLowerCase()==="nan"?NaN:X[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:$X.stringifyNumber},U_={identify:(X)=>typeof X==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(X)=>parseFloat(X),stringify(X){let U=Number(X.value);return isFinite(U)?U.toExponential():$X.stringifyNumber(X)}},q_={identify:(X)=>typeof X==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(X){let U=new eW.Scalar(parseFloat(X)),q=X.indexOf(".");if(q!==-1&&X[X.length-1]==="0")U.minFractionDigits=X.length-q-1;return U},stringify:$X.stringifyNumber};Z_.float=q_;Z_.floatExp=U_;Z_.floatNaN=X_});var FX=R((__)=>{var z3=a1(),_4=(X)=>typeof X==="bigint"||Number.isInteger(X),zX=(X,U,q,{intAsBigInt:Z})=>Z?BigInt(X):parseInt(X.substring(U),q);function F3(X,U,q){let{value:Z}=X;if(_4(Z)&&Z>=0)return q+Z.toString(U);return z3.stringifyNumber(X)}var H_={identify:(X)=>_4(X)&&X>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(X,U,q)=>zX(X,2,8,q),stringify:(X)=>F3(X,8,"0o")},J_={identify:_4,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(X,U,q)=>zX(X,0,10,q),stringify:z3.stringifyNumber},W_={identify:(X)=>_4(X)&&X>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(X,U,q)=>zX(X,2,16,q),stringify:(X)=>F3(X,16,"0x")};__.int=J_;__.intHex=W_;__.intOct=H_});var A3=R((R_)=>{var F_=o1(),A_=W4(),V_=r1(),O_=s2(),B_=_X(),AX=LX(),VX=FX(),T_=[F_.map,V_.seq,O_.string,A_.nullTag,B_.boolTag,VX.intOct,VX.int,VX.intHex,AX.floatNaN,AX.floatExp,AX.float];R_.schema=T_});var O3=R((C_)=>{var M_=i(),w_=o1(),P_=r1();function V3(X){return typeof X==="bigint"||Number.isInteger(X)}var $4=({value:X})=>JSON.stringify(X),I_=[{identify:(X)=>typeof X==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(X)=>X,stringify:$4},{identify:(X)=>X==null,createNode:()=>new M_.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:$4},{identify:(X)=>typeof X==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(X)=>X==="true",stringify:$4},{identify:V3,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(X,U,{intAsBigInt:q})=>q?BigInt(X):parseInt(X,10),stringify:({value:X})=>V3(X)?X.toString():JSON.stringify(X)},{identify:(X)=>typeof X==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(X)=>parseFloat(X),stringify:$4}],K_={default:!0,tag:"",test:/^/,resolve(X,U){return U(`Unresolved plain scalar ${JSON.stringify(X)}`),X}},N_=[w_.map,P_.seq].concat(I_,K_);C_.schema=N_});var BX=R((j_)=>{var o2=w1("buffer"),OX=i(),E_=p2(),b_={identify:(X)=>X instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(X,U){if(typeof o2.Buffer==="function")return o2.Buffer.from(X,"base64");else if(typeof atob==="function"){let q=atob(X.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 U("This environment does not support reading binary tags; either Buffer or atob is required"),X},stringify({comment:X,type:U,value:q},Z,Q,G){if(!q)return"";let Y=q,H;if(typeof o2.Buffer==="function")H=Y instanceof o2.Buffer?Y.toString("base64"):o2.Buffer.from(Y.buffer).toString("base64");else if(typeof btoa==="function"){let J="";for(let W=0;W<Y.length;++W)J+=String.fromCharCode(Y[W]);H=btoa(J)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(U??(U=OX.Scalar.BLOCK_LITERAL),U!==OX.Scalar.QUOTE_DOUBLE){let J=Math.max(Z.options.lineWidth-Z.indent.length,Z.options.minContentWidth),W=Math.ceil(H.length/J),$=Array(W);for(let _=0,L=0;_<W;++_,L+=J)$[_]=H.substr(L,J);H=$.join(U===OX.Scalar.BLOCK_LITERAL?`
52
+ `:" ")}return E_.stringifyString({comment:X,type:U,value:H},Z,Q,G)}};j_.binary=b_});var z4=R((v_)=>{var L4=k(),TX=e0(),y_=i(),g_=q1();function B3(X,U){if(L4.isSeq(X))for(let q=0;q<X.items.length;++q){let Z=X.items[q];if(L4.isPair(Z))continue;else if(L4.isMap(Z)){if(Z.items.length>1)U("Each pair must have its own sequence indicator");let Q=Z.items[0]||new TX.Pair(new y_.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]=J4.isPair(Z)?Z:new zU.Pair(Z)}else X("Expected a sequence for this tag");return U}function $3(U,X,q){let{replacer:Z}=q,Q=new SL.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 H,J;if(Array.isArray(Y))if(Y.length===2)H=Y[0],J=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)H=W[0],J=Y[H];else throw TypeError(`Expected tuple with one key, not ${W.length} keys`)}else H=Y;Q.items.push(zU.createPair(H,J,q))}return Q}var EL={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:_3,createNode:$3};bL.createPairs=$3;bL.pairs=EL;bL.resolvePairs=_3});var AU=R((vL)=>{var z3=k(),FU=n0(),d2=X1(),yL=q1(),F3=W4();class T1 extends yL.YAMLSeq{constructor(){super();this.add=d2.YAMLMap.prototype.add.bind(this),this.delete=d2.YAMLMap.prototype.delete.bind(this),this.get=d2.YAMLMap.prototype.get.bind(this),this.has=d2.YAMLMap.prototype.has.bind(this),this.set=d2.YAMLMap.prototype.set.bind(this),this.tag=T1.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(z3.isPair(Z))Q=FU.toJS(Z.key,"",X),G=FU.toJS(Z.value,Q,X);else Q=FU.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=F3.createPairs(U,X,q),Q=new this;return Q.items=Z.items,Q}}T1.tag="tag:yaml.org,2002:omap";var kL={collection:"seq",identify:(U)=>U instanceof Map,nodeClass:T1,default:!1,tag:"tag:yaml.org,2002:omap",resolve(U,X){let q=F3.resolvePairs(U,X),Z=[];for(let{key:Q}of q.items)if(z3.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 T1,q)},createNode:(U,X,q)=>T1.from(U,X,q)};vL.YAMLOMap=T1;vL.omap=kL});var B3=R((uL)=>{var A3=i();function T3({value:U,source:X},q){if(X&&(U?O3:V3).test.test(X))return X;return U?q.options.trueStr:q.options.falseStr}var O3={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 A3.Scalar(!0),stringify:T3},V3={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 A3.Scalar(!1),stringify:T3};uL.falseTag=V3;uL.trueTag=O3});var R3=R((oL)=>{var lL=i(),TU=r1(),dL={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:TU.stringifyNumber},cL={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():TU.stringifyNumber(U)}},iL={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 lL.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:TU.stringifyNumber};oL.float=iL;oL.floatExp=cL;oL.floatNaN=dL});var M3=R((X_)=>{var D3=r1(),c2=(U)=>typeof U==="bigint"||Number.isInteger(U);function L4(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 OU(U,X,q){let{value:Z}=U;if(c2(Z)){let Q=Z.toString(X);return Z<0?"-"+q+Q.substr(1):q+Q}return D3.stringifyNumber(U)}var aL={identify:c2,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(U,X,q)=>L4(U,2,2,q),stringify:(U)=>OU(U,2,"0b")},tL={identify:c2,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(U,X,q)=>L4(U,1,8,q),stringify:(U)=>OU(U,8,"0")},eL={identify:c2,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(U,X,q)=>L4(U,0,10,q),stringify:D3.stringifyNumber},U_={identify:c2,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(U,X,q)=>L4(U,2,16,q),stringify:(U)=>OU(U,16,"0x")};X_.int=eL;X_.intBin=aL;X_.intHex=U_;X_.intOct=tL});var VU=R((H_)=>{var z4=k(),_4=e0(),$4=X1();class O1 extends $4.YAMLMap{constructor(U){super(U);this.tag=O1.tag}add(U){let X;if(z4.isPair(U))X=U;else if(U&&typeof U==="object"&&"key"in U&&"value"in U&&U.value===null)X=new _4.Pair(U.key,null);else X=new _4.Pair(U,null);if(!$4.findPair(this.items,X.key))this.items.push(X)}get(U,X){let q=$4.findPair(this.items,U);return!X&&z4.isPair(q)?z4.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=$4.findPair(this.items,U);if(q&&!X)this.items.splice(this.items.indexOf(q),1);else if(!q&&X)this.items.push(new _4.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(_4.createPair(G,null,q))}return Q}}O1.tag="tag:yaml.org,2002:set";var Y_={collection:"map",identify:(U)=>U instanceof Set,nodeClass:O1,default:!1,tag:"tag:yaml.org,2002:set",createNode:(U,X,q)=>O1.from(U,X,q),resolve(U,X){if(z4.isMap(U))if(U.hasAllNullValues(!0))return Object.assign(new O1,U);else X("Set items must all have null values");else X("Expected a mapping for this tag");return U}};H_.YAMLSet=O1;H_.set=Y_});var RU=R((z_)=>{var L_=r1();function BU(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,H)=>Y*Q(60)+Q(H),Q(0));return q==="-"?Q(-1)*G:G}function w3(U){let{value:X}=U,q=(Y)=>Y;if(typeof X==="bigint")q=(Y)=>BigInt(Y);else if(isNaN(X)||!isFinite(X))return L_.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 __={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})=>BU(U,q),stringify:w3},$_={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)=>BU(U,!1),stringify:w3},P3={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(P3.test);if(!X)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,q,Z,Q,G,Y,H]=X.map(Number),J=X[7]?Number((X[7]+"00").substr(1,3)):0,W=Date.UTC(q,Z-1,Q,G||0,Y||0,H||0,J),_=X[8];if(_&&_!=="Z"){let L=BU(_,!1);if(Math.abs(L)<30)L*=60;W-=60000*L}return new Date(W)},stringify:({value:U})=>U?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};z_.floatTime=$_;z_.intTime=__;z_.timestamp=P3});var K3=R((N_)=>{var O_=o1(),V_=G4(),B_=s1(),R_=p2(),D_=$U(),I3=B3(),DU=R3(),F4=M3(),M_=a6(),w_=AU(),P_=W4(),I_=VU(),MU=RU(),K_=[O_.map,B_.seq,R_.string,V_.nullTag,I3.trueTag,I3.falseTag,F4.intBin,F4.intOct,F4.int,F4.intHex,DU.floatNaN,DU.floatExp,DU.float,D_.binary,M_.merge,w_.omap,P_.pairs,I_.set,MU.intTime,MU.floatTime,MU.timestamp];N_.schema=K_});var k3=R((k_)=>{var E3=o1(),S_=G4(),b3=s1(),E_=p2(),b_=QU(),wU=YU(),PU=JU(),j_=J3(),f_=L3(),j3=$U(),i2=a6(),f3=AU(),g3=W4(),N3=K3(),y3=VU(),A4=RU(),C3=new Map([["core",j_.schema],["failsafe",[E3.map,b3.seq,E_.string]],["json",f_.schema],["yaml11",N3.schema],["yaml-1.1",N3.schema]]),S3={binary:j3.binary,bool:b_.boolTag,float:wU.float,floatExp:wU.floatExp,floatNaN:wU.floatNaN,floatTime:A4.floatTime,int:PU.int,intHex:PU.intHex,intOct:PU.intOct,intTime:A4.intTime,map:E3.map,merge:i2.merge,null:S_.nullTag,omap:f3.omap,pairs:g3.pairs,seq:b3.seq,set:y3.set,timestamp:A4.timestamp},g_={"tag:yaml.org,2002:binary":j3.binary,"tag:yaml.org,2002:merge":i2.merge,"tag:yaml.org,2002:omap":f3.omap,"tag:yaml.org,2002:pairs":g3.pairs,"tag:yaml.org,2002:set":y3.set,"tag:yaml.org,2002:timestamp":A4.timestamp};function y_(U,X,q){let Z=C3.get(X);if(Z&&!U)return q&&!Z.includes(i2.merge)?Z.concat(i2.merge):Z.slice();let Q=Z;if(!Q)if(Array.isArray(U))Q=[];else{let G=Array.from(C3.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(i2.merge);return Q.reduce((G,Y)=>{let H=typeof Y==="string"?S3[Y]:Y;if(!H){let J=JSON.stringify(Y),W=Object.keys(S3).map((_)=>JSON.stringify(_)).join(", ");throw Error(`Unknown custom tag ${J}; use one of ${W}`)}if(!G.includes(H))G.push(H);return G},[])}k_.coreKnownTags=g_;k_.getTags=y_});var NU=R((l_)=>{var IU=k(),h_=o1(),u_=s1(),m_=p2(),T4=k3(),p_=(U,X)=>U.key<X.key?-1:U.key>X.key?1:0;class KU{constructor({compat:U,customTags:X,merge:q,resolveKnownTags:Z,schema:Q,sortMapEntries:G,toStringDefaults:Y}){this.compat=Array.isArray(U)?T4.getTags(U,"compat"):U?T4.getTags(null,U):null,this.name=typeof Q==="string"&&Q||"core",this.knownTags=Z?T4.coreKnownTags:{},this.tags=T4.getTags(X,this.name,q),this.toStringOptions=Y??null,Object.defineProperty(this,IU.MAP,{value:h_.map}),Object.defineProperty(this,IU.SCALAR,{value:m_.string}),Object.defineProperty(this,IU.SEQ,{value:u_.seq}),this.sortMapEntries=typeof G==="function"?G:G===!0?p_:null}clone(){let U=Object.create(KU.prototype,Object.getOwnPropertyDescriptors(this));return U.tags=this.tags.slice(),U}}l_.Schema=KU});var v3=R((o_)=>{var c_=k(),CU=x2(),o2=y2();function i_(U,X){let q=[],Z=X.directives===!0;if(X.directives!==!1&&U.directives){let J=U.directives.toString(U);if(J)q.push(J),Z=!0;else if(U.directives.docStart)Z=!0}if(Z)q.push("---");let Q=CU.createStringifyContext(U,X),{commentString:G}=Q.options;if(U.commentBefore){if(q.length!==1)q.unshift("");let J=G(U.commentBefore);q.unshift(o2.indentComment(J,""))}let Y=!1,H=null;if(U.contents){if(c_.isNode(U.contents)){if(U.contents.spaceBefore&&Z)q.push("");if(U.contents.commentBefore){let _=G(U.contents.commentBefore);q.push(o2.indentComment(_,""))}Q.forceBlockIndent=!!U.comment,H=U.contents.comment}let J=H?void 0:()=>Y=!0,W=CU.stringify(U.contents,Q,()=>H=null,J);if(H)W+=o2.lineComment(W,"",G(H));if((W[0]==="|"||W[0]===">")&&q[q.length-1]==="---")q[q.length-1]=`--- ${W}`;else q.push(W)}else q.push(CU.stringify(U.contents,Q));if(U.directives?.docEnd)if(U.comment){let J=G(U.comment);if(J.includes(`
55
- `))q.push("..."),q.push(o2.indentComment(J,""));else q.push(`... ${J}`)}else q.push("...");else{let J=U.comment;if(J&&Y)J=J.replace(/^\n+/,"");if(J){if((!Y||H)&&q[q.length-1]!=="")q.push("");q.push(o2.indentComment(G(J),""))}}return q.join(`
54
+ ${G.comment}`:Z.comment}Z=Q}X.items[q]=L4.isPair(Z)?Z:new TX.Pair(Z)}else U("Expected a sequence for this tag");return X}function T3(X,U,q){let{replacer:Z}=q,Q=new g_.YAMLSeq(X);Q.tag="tag:yaml.org,2002:pairs";let G=0;if(U&&Symbol.iterator in Object(U))for(let Y of U){if(typeof Z==="function")Y=Z.call(U,String(G++),Y);let H,J;if(Array.isArray(Y))if(Y.length===2)H=Y[0],J=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)H=W[0],J=Y[H];else throw TypeError(`Expected tuple with one key, not ${W.length} keys`)}else H=Y;Q.items.push(TX.createPair(H,J,q))}return Q}var k_={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:B3,createNode:T3};v_.createPairs=T3;v_.pairs=k_;v_.resolvePairs=B3});var DX=R((l_)=>{var R3=k(),RX=a0(),r2=U1(),m_=q1(),D3=z4();class O1 extends m_.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=O1.tag}toJSON(X,U){if(!U)return super.toJSON(X);let q=new Map;if(U?.onCreate)U.onCreate(q);for(let Z of this.items){let Q,G;if(R3.isPair(Z))Q=RX.toJS(Z.key,"",U),G=RX.toJS(Z.value,Q,U);else Q=RX.toJS(Z,"",U);if(q.has(Q))throw Error("Ordered maps must not include duplicate keys");q.set(Q,G)}return q}static from(X,U,q){let Z=D3.createPairs(X,U,q),Q=new this;return Q.items=Z.items,Q}}O1.tag="tag:yaml.org,2002:omap";var p_={collection:"seq",identify:(X)=>X instanceof Map,nodeClass:O1,default:!1,tag:"tag:yaml.org,2002:omap",resolve(X,U){let q=D3.resolvePairs(X,U),Z=[];for(let{key:Q}of q.items)if(R3.isScalar(Q))if(Z.includes(Q.value))U(`Ordered maps must not include duplicate keys: ${Q.value}`);else Z.push(Q.value);return Object.assign(new O1,q)},createNode:(X,U,q)=>O1.from(X,U,q)};l_.YAMLOMap=O1;l_.omap=p_});var K3=R((i_)=>{var M3=i();function w3({value:X,source:U},q){if(U&&(X?P3:I3).test.test(U))return U;return X?q.options.trueStr:q.options.falseStr}var P3={identify:(X)=>X===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new M3.Scalar(!0),stringify:w3},I3={identify:(X)=>X===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new M3.Scalar(!1),stringify:w3};i_.falseTag=I3;i_.trueTag=P3});var N3=R((e_)=>{var r_=i(),MX=a1(),a_={identify:(X)=>typeof X==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(X)=>X.slice(-3).toLowerCase()==="nan"?NaN:X[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:MX.stringifyNumber},n_={identify:(X)=>typeof X==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(X)=>parseFloat(X.replace(/_/g,"")),stringify(X){let U=Number(X.value);return isFinite(U)?U.toExponential():MX.stringifyNumber(X)}},t_={identify:(X)=>typeof X==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(X){let U=new r_.Scalar(parseFloat(X.replace(/_/g,""))),q=X.indexOf(".");if(q!==-1){let Z=X.substring(q+1).replace(/_/g,"");if(Z[Z.length-1]==="0")U.minFractionDigits=Z.length}return U},stringify:MX.stringifyNumber};e_.float=t_;e_.floatExp=n_;e_.floatNaN=a_});var S3=R((H$)=>{var C3=a1(),a2=(X)=>typeof X==="bigint"||Number.isInteger(X);function F4(X,U,q,{intAsBigInt:Z}){let Q=X[0];if(Q==="-"||Q==="+")U+=1;if(X=X.substring(U).replace(/_/g,""),Z){switch(q){case 2:X=`0b${X}`;break;case 8:X=`0o${X}`;break;case 16:X=`0x${X}`;break}let Y=BigInt(X);return Q==="-"?BigInt(-1)*Y:Y}let G=parseInt(X,q);return Q==="-"?-1*G:G}function wX(X,U,q){let{value:Z}=X;if(a2(Z)){let Q=Z.toString(U);return Z<0?"-"+q+Q.substr(1):q+Q}return C3.stringifyNumber(X)}var Z$={identify:a2,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(X,U,q)=>F4(X,2,2,q),stringify:(X)=>wX(X,2,"0b")},Q$={identify:a2,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(X,U,q)=>F4(X,1,8,q),stringify:(X)=>wX(X,8,"0")},G$={identify:a2,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(X,U,q)=>F4(X,0,10,q),stringify:C3.stringifyNumber},Y$={identify:a2,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(X,U,q)=>F4(X,2,16,q),stringify:(X)=>wX(X,16,"0x")};H$.int=G$;H$.intBin=Z$;H$.intHex=Y$;H$.intOct=Q$});var PX=R((z$)=>{var O4=k(),A4=e0(),V4=U1();class B1 extends V4.YAMLMap{constructor(X){super(X);this.tag=B1.tag}add(X){let U;if(O4.isPair(X))U=X;else if(X&&typeof X==="object"&&"key"in X&&"value"in X&&X.value===null)U=new A4.Pair(X.key,null);else U=new A4.Pair(X,null);if(!V4.findPair(this.items,U.key))this.items.push(U)}get(X,U){let q=V4.findPair(this.items,X);return!U&&O4.isPair(q)?O4.isScalar(q.key)?q.key.value:q.key:q}set(X,U){if(typeof U!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof U}`);let q=V4.findPair(this.items,X);if(q&&!U)this.items.splice(this.items.indexOf(q),1);else if(!q&&U)this.items.push(new A4.Pair(X))}toJSON(X,U){return super.toJSON(X,U,Set)}toString(X,U,q){if(!X)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},X,{allNullValues:!0}),U,q);else throw Error("Set items must all have null values")}static from(X,U,q){let{replacer:Z}=q,Q=new this(X);if(U&&Symbol.iterator in Object(U))for(let G of U){if(typeof Z==="function")G=Z.call(U,G,G);Q.items.push(A4.createPair(G,null,q))}return Q}}B1.tag="tag:yaml.org,2002:set";var L$={collection:"map",identify:(X)=>X instanceof Set,nodeClass:B1,default:!1,tag:"tag:yaml.org,2002:set",createNode:(X,U,q)=>B1.from(X,U,q),resolve(X,U){if(O4.isMap(X))if(X.hasAllNullValues(!0))return Object.assign(new B1,X);else U("Set items must all have null values");else U("Expected a mapping for this tag");return X}};z$.YAMLSet=B1;z$.set=L$});var KX=R((T$)=>{var V$=a1();function IX(X,U){let q=X[0],Z=q==="-"||q==="+"?X.substring(1):X,Q=(Y)=>U?BigInt(Y):Number(Y),G=Z.replace(/_/g,"").split(":").reduce((Y,H)=>Y*Q(60)+Q(H),Q(0));return q==="-"?Q(-1)*G:G}function E3(X){let{value:U}=X,q=(Y)=>Y;if(typeof U==="bigint")q=(Y)=>BigInt(Y);else if(isNaN(U)||!isFinite(U))return V$.stringifyNumber(X);let Z="";if(U<0)Z="-",U*=q(-1);let Q=q(60),G=[U%Q];if(U<60)G.unshift(0);else if(U=(U-G[0])/Q,G.unshift(U%Q),U>=60)U=(U-G[0])/Q,G.unshift(U);return Z+G.map((Y)=>String(Y).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var O$={identify:(X)=>typeof X==="bigint"||Number.isInteger(X),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(X,U,{intAsBigInt:q})=>IX(X,q),stringify:E3},B$={identify:(X)=>typeof X==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(X)=>IX(X,!1),stringify:E3},b3={identify:(X)=>X 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(X){let U=X.match(b3.test);if(!U)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,q,Z,Q,G,Y,H]=U.map(Number),J=U[7]?Number((U[7]+"00").substr(1,3)):0,W=Date.UTC(q,Z-1,Q,G||0,Y||0,H||0,J),$=U[8];if($&&$!=="Z"){let _=IX($,!1);if(Math.abs(_)<30)_*=60;W-=60000*_}return new Date(W)},stringify:({value:X})=>X?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};T$.floatTime=B$;T$.intTime=O$;T$.timestamp=b3});var f3=R((f$)=>{var w$=o1(),P$=W4(),I$=r1(),K$=s2(),N$=BX(),j3=K3(),NX=N3(),B4=S3(),C$=U4(),S$=DX(),E$=z4(),b$=PX(),CX=KX(),j$=[w$.map,I$.seq,K$.string,P$.nullTag,j3.trueTag,j3.falseTag,B4.intBin,B4.intOct,B4.int,B4.intHex,NX.floatNaN,NX.floatExp,NX.float,N$.binary,C$.merge,S$.omap,E$.pairs,b$.set,CX.intTime,CX.floatTime,CX.timestamp];f$.schema=j$});var l3=R((p$)=>{var v3=o1(),g$=W4(),x3=r1(),k$=s2(),v$=_X(),SX=LX(),EX=FX(),x$=A3(),h$=O3(),h3=BX(),n2=U4(),u3=DX(),m3=z4(),y3=f3(),p3=PX(),T4=KX(),g3=new Map([["core",x$.schema],["failsafe",[v3.map,x3.seq,k$.string]],["json",h$.schema],["yaml11",y3.schema],["yaml-1.1",y3.schema]]),k3={binary:h3.binary,bool:v$.boolTag,float:SX.float,floatExp:SX.floatExp,floatNaN:SX.floatNaN,floatTime:T4.floatTime,int:EX.int,intHex:EX.intHex,intOct:EX.intOct,intTime:T4.intTime,map:v3.map,merge:n2.merge,null:g$.nullTag,omap:u3.omap,pairs:m3.pairs,seq:x3.seq,set:p3.set,timestamp:T4.timestamp},u$={"tag:yaml.org,2002:binary":h3.binary,"tag:yaml.org,2002:merge":n2.merge,"tag:yaml.org,2002:omap":u3.omap,"tag:yaml.org,2002:pairs":m3.pairs,"tag:yaml.org,2002:set":p3.set,"tag:yaml.org,2002:timestamp":T4.timestamp};function m$(X,U,q){let Z=g3.get(U);if(Z&&!X)return q&&!Z.includes(n2.merge)?Z.concat(n2.merge):Z.slice();let Q=Z;if(!Q)if(Array.isArray(X))Q=[];else{let G=Array.from(g3.keys()).filter((Y)=>Y!=="yaml11").map((Y)=>JSON.stringify(Y)).join(", ");throw Error(`Unknown schema "${U}"; use one of ${G} or define customTags array`)}if(Array.isArray(X))for(let G of X)Q=Q.concat(G);else if(typeof X==="function")Q=X(Q.slice());if(q)Q=Q.concat(n2.merge);return Q.reduce((G,Y)=>{let H=typeof Y==="string"?k3[Y]:Y;if(!H){let J=JSON.stringify(Y),W=Object.keys(k3).map(($)=>JSON.stringify($)).join(", ");throw Error(`Unknown custom tag ${J}; use one of ${W}`)}if(!G.includes(H))G.push(H);return G},[])}p$.coreKnownTags=u$;p$.getTags=m$});var fX=R((r$)=>{var bX=k(),c$=o1(),i$=r1(),s$=s2(),R4=l3(),o$=(X,U)=>X.key<U.key?-1:X.key>U.key?1:0;class jX{constructor({compat:X,customTags:U,merge:q,resolveKnownTags:Z,schema:Q,sortMapEntries:G,toStringDefaults:Y}){this.compat=Array.isArray(X)?R4.getTags(X,"compat"):X?R4.getTags(null,X):null,this.name=typeof Q==="string"&&Q||"core",this.knownTags=Z?R4.coreKnownTags:{},this.tags=R4.getTags(U,this.name,q),this.toStringOptions=Y??null,Object.defineProperty(this,bX.MAP,{value:c$.map}),Object.defineProperty(this,bX.SCALAR,{value:s$.string}),Object.defineProperty(this,bX.SEQ,{value:i$.seq}),this.sortMapEntries=typeof G==="function"?G:G===!0?o$:null}clone(){let X=Object.create(jX.prototype,Object.getOwnPropertyDescriptors(this));return X.tags=this.tags.slice(),X}}r$.Schema=jX});var d3=R((e$)=>{var n$=k(),yX=l2(),t2=u2();function t$(X,U){let q=[],Z=U.directives===!0;if(U.directives!==!1&&X.directives){let J=X.directives.toString(X);if(J)q.push(J),Z=!0;else if(X.directives.docStart)Z=!0}if(Z)q.push("---");let Q=yX.createStringifyContext(X,U),{commentString:G}=Q.options;if(X.commentBefore){if(q.length!==1)q.unshift("");let J=G(X.commentBefore);q.unshift(t2.indentComment(J,""))}let Y=!1,H=null;if(X.contents){if(n$.isNode(X.contents)){if(X.contents.spaceBefore&&Z)q.push("");if(X.contents.commentBefore){let $=G(X.contents.commentBefore);q.push(t2.indentComment($,""))}Q.forceBlockIndent=!!X.comment,H=X.contents.comment}let J=H?void 0:()=>Y=!0,W=yX.stringify(X.contents,Q,()=>H=null,J);if(H)W+=t2.lineComment(W,"",G(H));if((W[0]==="|"||W[0]===">")&&q[q.length-1]==="---")q[q.length-1]=`--- ${W}`;else q.push(W)}else q.push(yX.stringify(X.contents,Q));if(X.directives?.docEnd)if(X.comment){let J=G(X.comment);if(J.includes(`
55
+ `))q.push("..."),q.push(t2.indentComment(J,""));else q.push(`... ${J}`)}else q.push("...");else{let J=X.comment;if(J&&Y)J=J.replace(/^\n+/,"");if(J){if((!Y||H)&&q[q.length-1]!=="")q.push("");q.push(t2.indentComment(G(J),""))}}return q.join(`
56
56
  `)+`
57
- `}o_.stringifyDocument=i_});var s2=R((q$)=>{var r_=f2(),n1=c6(),B0=k(),n_=e0(),a_=n0(),t_=NU(),e_=v3(),SU=p6(),U$=s9(),X$=g2(),EU=o9();class bU{constructor(U,X,q){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,B0.NODE_TYPE,{value:B0.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 EU.Directives({version:G});this.setSchema(G,q),this.contents=U===void 0?null:this.createNode(U,Z,q)}clone(){let U=Object.create(bU.prototype,{[B0.NODE_TYPE]:{value:B0.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=B0.isNode(this.contents)?this.contents.clone(U.schema):this.contents,this.range)U.range=this.range.slice();return U}add(U){if(a1(this.contents))this.contents.add(U)}addIn(U,X){if(a1(this.contents))this.contents.addIn(U,X)}createAlias(U,X){if(!U.anchor){let q=SU.anchorNames(this);U.anchor=!X||q.has(X)?SU.findNewAnchor(X||"a",q):X}return new r_.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,O=X.filter(z).map(String);if(O.length>0)X=X.concat(O);Z=X}else if(q===void 0&&X)q=X,X=void 0;let{aliasDuplicateObjects:Q,anchorPrefix:G,flow:Y,keepUndefined:H,onTagObj:J,tag:W}=q??{},{onAnchor:_,setAnchors:L,sourceObjects:$}=SU.createNodeAnchors(this,G||"a"),A={aliasDuplicateObjects:Q??!0,keepUndefined:H??!1,onAnchor:_,onTagObj:J,replacer:Z,schema:this.schema,sourceObjects:$},B=X$.createNode(U,W,A);if(Y&&B0.isCollection(B))B.flow=!0;return L(),B}createPair(U,X,q={}){let Z=this.createNode(U,null,q),Q=this.createNode(X,null,q);return new n_.Pair(Z,Q)}delete(U){return a1(this.contents)?this.contents.delete(U):!1}deleteIn(U){if(n1.isEmptyPath(U)){if(this.contents==null)return!1;return this.contents=null,!0}return a1(this.contents)?this.contents.deleteIn(U):!1}get(U,X){return B0.isCollection(this.contents)?this.contents.get(U,X):void 0}getIn(U,X){if(n1.isEmptyPath(U))return!X&&B0.isScalar(this.contents)?this.contents.value:this.contents;return B0.isCollection(this.contents)?this.contents.getIn(U,X):void 0}has(U){return B0.isCollection(this.contents)?this.contents.has(U):!1}hasIn(U){if(n1.isEmptyPath(U))return this.contents!==void 0;return B0.isCollection(this.contents)?this.contents.hasIn(U):!1}set(U,X){if(this.contents==null)this.contents=n1.collectionFromPath(this.schema,[U],X);else if(a1(this.contents))this.contents.set(U,X)}setIn(U,X){if(n1.isEmptyPath(U))this.contents=X;else if(this.contents==null)this.contents=n1.collectionFromPath(this.schema,Array.from(U),X);else if(a1(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 EU.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 EU.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 t_.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},H=a_.toJS(this.contents,X??"",Y);if(typeof Q==="function")for(let{count:J,res:W}of Y.anchors.values())Q(W,J);return typeof G==="function"?U$.applyReviver(G,{"":H},"",H):H}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 e_.stringifyDocument(this,U)}}function a1(U){if(B0.isCollection(U))return!0;throw Error("Expected a YAML collection as document contents")}q$.Document=bU});var r2=R((G$)=>{class O4 extends Error{constructor(U,X,q,Z){super();this.name=U,this.code=q,this.message=Z,this.pos=X}}class x3 extends O4{constructor(U,X,q){super("YAMLParseError",U,X,q)}}class h3 extends O4{constructor(U,X,q){super("YAMLWarning",U,X,q)}}var Q$=(U,X)=>(q)=>{if(q.pos[0]===-1)return;q.linePos=q.pos.map((H)=>X.linePos(H));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 H=Math.min(G-39,Y.length-79);Y="…"+Y.substring(H),G-=H-1}if(Y.length>80)Y=Y.substring(0,79)+"…";if(Z>1&&/^ *$/.test(Y.substring(0,G))){let H=U.substring(X.lineStarts[Z-2],X.lineStarts[Z-1]);if(H.length>80)H=H.substring(0,79)+`…
57
+ `}e$.stringifyDocument=t$});var e2=R((JL)=>{var UL=x2(),n1=r6(),T0=k(),qL=e0(),ZL=a0(),QL=fX(),GL=d3(),gX=i6(),YL=XX(),HL=h2(),kX=e9();class vX{constructor(X,U,q){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,T0.NODE_TYPE,{value:T0.DOC});let Z=null;if(typeof U==="function"||Array.isArray(U))Z=U;else if(q===void 0&&U)q=U,U=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 kX.Directives({version:G});this.setSchema(G,q),this.contents=X===void 0?null:this.createNode(X,Z,q)}clone(){let X=Object.create(vX.prototype,{[T0.NODE_TYPE]:{value:T0.DOC}});if(X.commentBefore=this.commentBefore,X.comment=this.comment,X.errors=this.errors.slice(),X.warnings=this.warnings.slice(),X.options=Object.assign({},this.options),this.directives)X.directives=this.directives.clone();if(X.schema=this.schema.clone(),X.contents=T0.isNode(this.contents)?this.contents.clone(X.schema):this.contents,this.range)X.range=this.range.slice();return X}add(X){if(t1(this.contents))this.contents.add(X)}addIn(X,U){if(t1(this.contents))this.contents.addIn(X,U)}createAlias(X,U){if(!X.anchor){let q=gX.anchorNames(this);X.anchor=!U||q.has(U)?gX.findNewAnchor(U||"a",q):U}return new UL.Alias(X.anchor)}createNode(X,U,q){let Z=void 0;if(typeof U==="function")X=U.call({"":X},"",X),Z=U;else if(Array.isArray(U)){let z=(D)=>typeof D==="number"||D instanceof String||D instanceof Number,O=U.filter(z).map(String);if(O.length>0)U=U.concat(O);Z=U}else if(q===void 0&&U)q=U,U=void 0;let{aliasDuplicateObjects:Q,anchorPrefix:G,flow:Y,keepUndefined:H,onTagObj:J,tag:W}=q??{},{onAnchor:$,setAnchors:_,sourceObjects:L}=gX.createNodeAnchors(this,G||"a"),A={aliasDuplicateObjects:Q??!0,keepUndefined:H??!1,onAnchor:$,onTagObj:J,replacer:Z,schema:this.schema,sourceObjects:L},T=HL.createNode(X,W,A);if(Y&&T0.isCollection(T))T.flow=!0;return _(),T}createPair(X,U,q={}){let Z=this.createNode(X,null,q),Q=this.createNode(U,null,q);return new qL.Pair(Z,Q)}delete(X){return t1(this.contents)?this.contents.delete(X):!1}deleteIn(X){if(n1.isEmptyPath(X)){if(this.contents==null)return!1;return this.contents=null,!0}return t1(this.contents)?this.contents.deleteIn(X):!1}get(X,U){return T0.isCollection(this.contents)?this.contents.get(X,U):void 0}getIn(X,U){if(n1.isEmptyPath(X))return!U&&T0.isScalar(this.contents)?this.contents.value:this.contents;return T0.isCollection(this.contents)?this.contents.getIn(X,U):void 0}has(X){return T0.isCollection(this.contents)?this.contents.has(X):!1}hasIn(X){if(n1.isEmptyPath(X))return this.contents!==void 0;return T0.isCollection(this.contents)?this.contents.hasIn(X):!1}set(X,U){if(this.contents==null)this.contents=n1.collectionFromPath(this.schema,[X],U);else if(t1(this.contents))this.contents.set(X,U)}setIn(X,U){if(n1.isEmptyPath(X))this.contents=U;else if(this.contents==null)this.contents=n1.collectionFromPath(this.schema,Array.from(X),U);else if(t1(this.contents))this.contents.setIn(X,U)}setSchema(X,U={}){if(typeof X==="number")X=String(X);let q;switch(X){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new kX.Directives({version:"1.1"});q={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=X;else this.directives=new kX.Directives({version:X});q={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;q=null;break;default:{let Z=JSON.stringify(X);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${Z}`)}}if(U.schema instanceof Object)this.schema=U.schema;else if(q)this.schema=new QL.Schema(Object.assign(q,U));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:X,jsonArg:U,mapAsMap:q,maxAliasCount:Z,onAnchor:Q,reviver:G}={}){let Y={anchors:new Map,doc:this,keep:!X,mapAsMap:q===!0,mapKeyWarned:!1,maxAliasCount:typeof Z==="number"?Z:100},H=ZL.toJS(this.contents,U??"",Y);if(typeof Q==="function")for(let{count:J,res:W}of Y.anchors.values())Q(W,J);return typeof G==="function"?YL.applyReviver(G,{"":H},"",H):H}toJSON(X,U){return this.toJS({json:!0,jsonArg:X,mapAsMap:!1,onAnchor:U})}toString(X={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in X&&(!Number.isInteger(X.indent)||Number(X.indent)<=0)){let U=JSON.stringify(X.indent);throw Error(`"indent" option must be a positive integer, not ${U}`)}return GL.stringifyDocument(this,X)}}function t1(X){if(T0.isCollection(X))return!0;throw Error("Expected a YAML collection as document contents")}JL.Document=vX});var X6=R(($L)=>{class D4 extends Error{constructor(X,U,q,Z){super();this.name=X,this.code=q,this.message=Z,this.pos=U}}class c3 extends D4{constructor(X,U,q){super("YAMLParseError",X,U,q)}}class i3 extends D4{constructor(X,U,q){super("YAMLWarning",X,U,q)}}var _L=(X,U)=>(q)=>{if(q.pos[0]===-1)return;q.linePos=q.pos.map((H)=>U.linePos(H));let{line:Z,col:Q}=q.linePos[0];q.message+=` at line ${Z}, column ${Q}`;let G=Q-1,Y=X.substring(U.lineStarts[Z-1],U.lineStarts[Z]).replace(/[\n\r]+$/,"");if(G>=60&&Y.length>80){let H=Math.min(G-39,Y.length-79);Y="…"+Y.substring(H),G-=H-1}if(Y.length>80)Y=Y.substring(0,79)+"…";if(Z>1&&/^ *$/.test(Y.substring(0,G))){let H=X.substring(U.lineStarts[Z-2],U.lineStarts[Z-1]);if(H.length>80)H=H.substring(0,79)+`…
58
58
  `;Y=H+Y}if(/[^ ]/.test(Y)){let H=1,J=q.linePos[1];if(J?.line===Z&&J.col>Q)H=Math.max(1,Math.min(J.col-Q,80-G));let W=" ".repeat(G)+"^".repeat(H);q.message+=`:
59
59
 
60
60
  ${Y}
61
61
  ${W}
62
- `}};G$.YAMLError=O4;G$.YAMLParseError=x3;G$.YAMLWarning=h3;G$.prettifyError=Q$});var n2=R((_$)=>{function L$(U,{flow:X,indicator:q,next:Z,offset:Q,onError:G,parentIndent:Y,startOnNewline:H}){let J=!1,W=H,_=H,L="",$="",A=!1,B=!1,z=null,O=null,D=null,P=null,K=null,C=null,N=null;for(let w of U){if(B){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");B=!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 o=w.source.substring(1)||" ";if(!L)L=o;else L+=$+o;$="",W=!1;break}case"newline":if(W){if(L)L+=w.source;else if(!C||q!=="seq-item-ind")J=!0}else $+=w.source;if(W=!0,A=!0,O||D)P=w;_=!0;break;case"anchor":if(O)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);O=w,N??(N=w.offset),W=!1,_=!1,B=!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,B=!0;break}case q:if(O||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 j=U[U.length-1],m=j?j.offset+j.source.length:Q;if(B&&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:J,comment:L,hasNewline:A,anchor:O,tag:D,newlineAfterProp:P,end:m,start:N??m}}_$.resolveProps=L$});var V4=R((z$)=>{function jU(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(jU(X.key)||jU(X.value))return!0}return!1;default:return!0}}z$.containsNewline=jU});var fU=R((O$)=>{var A$=V4();function T$(U,X,q){if(X?.type==="flow-collection"){let Z=X.end[0];if(Z.indent===U&&(Z.source==="]"||Z.source==="}")&&A$.containsNewline(X))q(Z,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}O$.flowIndentCheck=T$});var gU=R((R$)=>{var u3=k();function B$(U,X,q){let{uniqueKeys:Z}=U.options;if(Z===!1)return!1;let Q=typeof Z==="function"?Z:(G,Y)=>G===Y||u3.isScalar(G)&&u3.isScalar(Y)&&G.value===Y.value;return X.some((G)=>Q(G.key,q))}R$.mapIncludes=B$});var c3=R((K$)=>{var m3=e0(),M$=X1(),p3=n2(),w$=V4(),l3=fU(),P$=gU(),d3="All mapping items must start at the same column";function I$({composeNode:U,composeEmptyNode:X},q,Z,Q,G){let H=new(G?.nodeClass??M$.YAMLMap)(q.schema);if(q.atRoot)q.atRoot=!1;let J=Z.offset,W=null;for(let _ of Z.items){let{start:L,key:$,sep:A,value:B}=_,z=p3.resolveProps(L,{indicator:"explicit-key-ind",next:$??A?.[0],offset:J,onError:Q,parentIndent:Z.indent,startOnNewline:!0}),O=!z.found;if(O){if($){if($.type==="block-seq")Q(J,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in $&&$.indent!==Z.indent)Q(J,"BAD_INDENT",d3)}if(!z.anchor&&!z.tag&&!A){if(W=z.end,z.comment)if(H.comment)H.comment+=`
64
- `+z.comment;else H.comment=z.comment;continue}if(z.newlineAfterProp||w$.containsNewline($))Q($??L[L.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(z.found?.indent!==Z.indent)Q(J,"BAD_INDENT",d3);q.atKey=!0;let D=z.end,P=$?U(q,$,z,Q):X(q,D,L,null,z,Q);if(q.schema.compat)l3.flowIndentCheck(Z.indent,$,Q);if(q.atKey=!1,P$.mapIncludes(q,H.items,P))Q(D,"DUPLICATE_KEY","Map keys must be unique");let K=p3.resolveProps(A??[],{indicator:"map-value-ind",next:B,offset:P.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!$||$.type==="block-scalar"});if(J=K.end,K.found){if(O){if(B?.type==="block-map"&&!K.hasNewline)Q(J,"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=B?U(q,B,K,Q):X(q,J,A,null,K,Q);if(q.schema.compat)l3.flowIndentCheck(Z.indent,B,Q);J=C.range[2];let N=new m3.Pair(P,C);if(q.options.keepSourceTokens)N.srcToken=_;H.items.push(N)}else{if(O)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 m3.Pair(P);if(q.options.keepSourceTokens)C.srcToken=_;H.items.push(C)}}if(W&&W<J)Q(W,"IMPOSSIBLE","Map comment with trailing content");return H.range=[Z.offset,J,W??J],H}K$.resolveBlockMap=I$});var i3=R((j$)=>{var C$=q1(),S$=n2(),E$=fU();function b$({composeNode:U,composeEmptyNode:X},q,Z,Q,G){let H=new(G?.nodeClass??C$.YAMLSeq)(q.schema);if(q.atRoot)q.atRoot=!1;if(q.atKey)q.atKey=!1;let J=Z.offset,W=null;for(let{start:_,value:L}of Z.items){let $=S$.resolveProps(_,{indicator:"seq-item-ind",next:L,offset:J,onError:Q,parentIndent:Z.indent,startOnNewline:!0});if(!$.found)if($.anchor||$.tag||L)if(L?.type==="block-seq")Q($.end,"BAD_INDENT","All sequence items must start at the same column");else Q(J,"MISSING_CHAR","Sequence item without - indicator");else{if(W=$.end,$.comment)H.comment=$.comment;continue}let A=L?U(q,L,$,Q):X(q,$.end,_,null,$,Q);if(q.schema.compat)E$.flowIndentCheck(Z.indent,L,Q);J=A.range[2],H.items.push(A)}return H.range=[Z.offset,J,W??J],H}j$.resolveBlockSeq=b$});var t1=R((y$)=>{function g$(U,X,q,Z){let Q="";if(U){let G=!1,Y="";for(let H of U){let{source:J,type:W}=H;switch(W){case"space":G=!0;break;case"comment":{if(q&&!G)Z(H,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=J.substring(1)||" ";if(!Q)Q=_;else Q+=Y+_;Y="";break}case"newline":if(Q)Y+=J;G=!0;break;default:Z(H,"UNEXPECTED_TOKEN",`Unexpected ${W} at node end`)}X+=J.length}}return{comment:Q,offset:X}}y$.resolveEnd=g$});var r3=R((d$)=>{var v$=k(),x$=e0(),o3=X1(),h$=q1(),u$=t1(),s3=n2(),m$=V4(),p$=gU(),yU="Block collections are not allowed within flow collections",kU=(U)=>U&&(U.type==="block-map"||U.type==="block-seq");function l$({composeNode:U,composeEmptyNode:X},q,Z,Q,G){let Y=Z.start.source==="{",H=Y?"flow map":"flow sequence",W=new(G?.nodeClass??(Y?o3.YAMLMap:h$.YAMLSeq))(q.schema);W.flow=!0;let _=q.atRoot;if(_)q.atRoot=!1;if(q.atKey)q.atKey=!1;let L=Z.offset+Z.start.source.length;for(let O=0;O<Z.items.length;++O){let D=Z.items[O],{start:P,key:K,sep:C,value:N}=D,j=s3.resolveProps(P,{flow:H,indicator:"explicit-key-ind",next:K??C?.[0],offset:L,onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(!j.found){if(!j.anchor&&!j.tag&&!C&&!N){if(O===0&&j.comma)Q(j.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${H}`);else if(O<Z.items.length-1)Q(j.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${H}`);if(j.comment)if(W.comment)W.comment+=`
66
- `+j.comment;else W.comment=j.comment;L=j.end;continue}if(!Y&&q.options.strict&&m$.containsNewline(K))Q(K,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(O===0){if(j.comma)Q(j.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${H}`)}else{if(!j.comma)Q(j.start,"MISSING_CHAR",`Missing , between ${H} items`);if(j.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(v$.isPair(w))w=w.value??w.key;if(w.comment)w.comment+=`
67
- `+m;else w.comment=m;j.comment=j.comment.substring(m.length+1)}}}if(!Y&&!C&&!j.found){let m=N?U(q,N,j,Q):X(q,j.end,C,null,j,Q);if(W.items.push(m),L=m.range[2],kU(N))Q(m.range,"BLOCK_IN_FLOW",yU)}else{q.atKey=!0;let m=j.end,w=K?U(q,K,j,Q):X(q,m,P,null,j,Q);if(kU(K))Q(w.range,"BLOCK_IN_FLOW",yU);q.atKey=!1;let o=s3.resolveProps(C??[],{flow:H,indicator:"map-value-ind",next:N,offset:w.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(o.found){if(!Y&&!j.found&&q.options.strict){if(C)for(let s of C){if(s===o.found)break;if(s.type==="newline"){Q(s,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(j.start<o.found.offset-1024)Q(o.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 ${H}`);else Q(o.start,"MISSING_CHAR",`Missing , or : between ${H} items`);let m0=N?U(q,N,o,Q):o.found?X(q,o.end,C,null,o,Q):null;if(m0){if(kU(N))Q(m0.range,"BLOCK_IN_FLOW",yU)}else if(o.comment)if(w.comment)w.comment+=`
68
- `+o.comment;else w.comment=o.comment;let D1=new x$.Pair(w,m0);if(q.options.keepSourceTokens)D1.srcToken=D;if(Y){let s=W;if(p$.mapIncludes(q,s.items,w))Q(m,"DUPLICATE_KEY","Map keys must be unique");s.items.push(D1)}else{let s=new o3.YAMLMap(q.schema);s.flow=!0,s.items.push(D1);let ZX=(m0??w).range;s.range=[w.range[0],ZX[1],ZX[2]],W.items.push(s)}L=m0?m0.range[2]:o.end}}let $=Y?"}":"]",[A,...B]=Z.end,z=L;if(A?.source===$)z=A.offset+A.source.length;else{let O=H[0].toUpperCase()+H.substring(1),D=_?`${O} must end with a ${$}`:`${O} in block collection must be sufficiently indented and end with a ${$}`;if(Q(L,_?"MISSING_CHAR":"BAD_INDENT",D),A&&A.source.length!==1)B.unshift(A)}if(B.length>0){let O=u$.resolveEnd(B,z,q.options.strict,Q);if(O.comment)if(W.comment)W.comment+=`
69
- `+O.comment;else W.comment=O.comment;W.range=[Z.offset,z,O.offset]}else W.range=[Z.offset,z,z];return W}d$.resolveFlowCollection=l$});var n3=R((Uz)=>{var i$=k(),o$=i(),s$=X1(),r$=q1(),n$=c3(),a$=i3(),t$=r3();function vU(U,X,q,Z,Q,G){let Y=q.type==="block-map"?n$.resolveBlockMap(U,X,q,Z,G):q.type==="block-seq"?a$.resolveBlockSeq(U,X,q,Z,G):t$.resolveFlowCollection(U,X,q,Z,G),H=Y.constructor;if(Q==="!"||Q===H.tagName)return Y.tag=H.tagName,Y;if(Q)Y.tag=Q;return Y}function e$(U,X,q,Z,Q){let G=Z.tag,Y=!G?null:X.directives.tagName(G.source,($)=>Q(G,"TAG_RESOLVE_FAILED",$));if(q.type==="block-seq"){let{anchor:$,newlineAfterProp:A}=Z,B=$&&G?$.offset>G.offset?$:G:$??G;if(B&&(!A||A.offset<B.offset))Q(B,"MISSING_CHAR","Missing newline after block sequence props")}let H=q.type==="block-map"?"map":q.type==="block-seq"?"seq":q.start.source==="{"?"map":"seq";if(!G||!Y||Y==="!"||Y===s$.YAMLMap.tagName&&H==="map"||Y===r$.YAMLSeq.tagName&&H==="seq")return vU(U,X,q,Q,Y);let J=X.schema.tags.find(($)=>$.tag===Y&&$.collection===H);if(!J){let $=X.schema.knownTags[Y];if($?.collection===H)X.schema.tags.push(Object.assign({},$,{default:!1})),J=$;else{if($)Q(G,"BAD_COLLECTION_TYPE",`${$.tag} used for ${H} collection, but expects ${$.collection??"scalar"}`,!0);else Q(G,"TAG_RESOLVE_FAILED",`Unresolved tag: ${Y}`,!0);return vU(U,X,q,Q,Y)}}let W=vU(U,X,q,Q,Y,J),_=J.resolve?.(W,($)=>Q(G,"TAG_RESOLVE_FAILED",$),X.options)??W,L=i$.isNode(_)?_:new o$.Scalar(_);if(L.range=W.range,L.tag=Y,J?.format)L.format=J.format;return L}Uz.composeCollection=e$});var hU=R((Gz)=>{var xU=i();function qz(U,X,q){let Z=X.offset,Q=Zz(X,U.options.strict,q);if(!Q)return{value:"",type:null,comment:"",range:[Z,Z,Z]};let G=Q.mode===">"?xU.Scalar.BLOCK_FOLDED:xU.Scalar.BLOCK_LITERAL,Y=X.source?Qz(X.source):[],H=Y.length;for(let z=Y.length-1;z>=0;--z){let O=Y[z][1];if(O===""||O==="\r")H=z;else break}if(H===0){let z=Q.chomp==="+"&&Y.length>0?`
70
- `.repeat(Math.max(1,Y.length-1)):"",O=Z+Q.length;if(X.source)O+=X.source.length;return{value:z,type:G,comment:Q.comment,range:[Z,O,O]}}let J=X.indent+Q.indent,W=X.offset+Q.length,_=0;for(let z=0;z<H;++z){let[O,D]=Y[z];if(D===""||D==="\r"){if(Q.indent===0&&O.length>J)J=O.length}else{if(O.length<J)q(W+O.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(Q.indent===0)J=O.length;if(_=z,J===0&&!U.atRoot)q(W,"BAD_INDENT","Block scalar values in collections must be indented");break}W+=O.length+D.length+1}for(let z=Y.length-1;z>=H;--z)if(Y[z][0].length>J)H=z+1;let L="",$="",A=!1;for(let z=0;z<_;++z)L+=Y[z][0].slice(J)+`
71
- `;for(let z=_;z<H;++z){let[O,D]=Y[z];W+=O.length+D.length+1;let P=D[D.length-1]==="\r";if(P)D=D.slice(0,-1);if(D&&O.length<J){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),O=""}if(G===xU.Scalar.BLOCK_LITERAL)L+=$+O.slice(J)+D,$=`
72
- `;else if(O.length>J||D[0]==="\t"){if($===" ")$=`
73
- `;else if(!A&&$===`
74
- `)$=`
62
+ `}};$L.YAMLError=D4;$L.YAMLParseError=c3;$L.YAMLWarning=i3;$L.prettifyError=_L});var U6=R((OL)=>{function VL(X,{flow:U,indicator:q,next:Z,offset:Q,onError:G,parentIndent:Y,startOnNewline:H}){let J=!1,W=H,$=H,_="",L="",A=!1,T=!1,z=null,O=null,D=null,P=null,K=null,C=null,N=null;for(let w of X){if(T){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");T=!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(!U&&(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")J=!0}else L+=w.source;if(W=!0,A=!0,O||D)P=w;$=!0;break;case"anchor":if(O)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);O=w,N??(N=w.offset),W=!1,$=!1,T=!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,T=!0;break}case q:if(O||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 ${U??"collection"}`);C=w,W=q==="seq-item-ind"||q==="explicit-key-ind",$=!1;break;case"comma":if(U){if(K)G(w,"UNEXPECTED_TOKEN",`Unexpected , in ${U}`);K=w,W=!1,$=!1;break}default:G(w,"UNEXPECTED_TOKEN",`Unexpected ${w.type} token`),W=!1,$=!1}}let j=X[X.length-1],m=j?j.offset+j.source.length:Q;if(T&&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:J,comment:_,hasNewline:A,anchor:O,tag:D,newlineAfterProp:P,end:m,start:N??m}}OL.resolveProps=VL});var M4=R((TL)=>{function xX(X){if(!X)return null;switch(X.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(X.source.includes(`
63
+ `))return!0;if(X.end){for(let U of X.end)if(U.type==="newline")return!0}return!1;case"flow-collection":for(let U of X.items){for(let q of U.start)if(q.type==="newline")return!0;if(U.sep){for(let q of U.sep)if(q.type==="newline")return!0}if(xX(U.key)||xX(U.value))return!0}return!1;default:return!0}}TL.containsNewline=xX});var hX=R((wL)=>{var DL=M4();function ML(X,U,q){if(U?.type==="flow-collection"){let Z=U.end[0];if(Z.indent===X&&(Z.source==="]"||Z.source==="}")&&DL.containsNewline(U))q(Z,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}wL.flowIndentCheck=ML});var uX=R((KL)=>{var s3=k();function IL(X,U,q){let{uniqueKeys:Z}=X.options;if(Z===!1)return!1;let Q=typeof Z==="function"?Z:(G,Y)=>G===Y||s3.isScalar(G)&&s3.isScalar(Y)&&G.value===Y.value;return U.some((G)=>Q(G.key,q))}KL.mapIncludes=IL});var t3=R((jL)=>{var o3=e0(),CL=U1(),r3=U6(),SL=M4(),a3=hX(),EL=uX(),n3="All mapping items must start at the same column";function bL({composeNode:X,composeEmptyNode:U},q,Z,Q,G){let H=new(G?.nodeClass??CL.YAMLMap)(q.schema);if(q.atRoot)q.atRoot=!1;let J=Z.offset,W=null;for(let $ of Z.items){let{start:_,key:L,sep:A,value:T}=$,z=r3.resolveProps(_,{indicator:"explicit-key-ind",next:L??A?.[0],offset:J,onError:Q,parentIndent:Z.indent,startOnNewline:!0}),O=!z.found;if(O){if(L){if(L.type==="block-seq")Q(J,"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(J,"BAD_INDENT",n3)}if(!z.anchor&&!z.tag&&!A){if(W=z.end,z.comment)if(H.comment)H.comment+=`
64
+ `+z.comment;else H.comment=z.comment;continue}if(z.newlineAfterProp||SL.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(J,"BAD_INDENT",n3);q.atKey=!0;let D=z.end,P=L?X(q,L,z,Q):U(q,D,_,null,z,Q);if(q.schema.compat)a3.flowIndentCheck(Z.indent,L,Q);if(q.atKey=!1,EL.mapIncludes(q,H.items,P))Q(D,"DUPLICATE_KEY","Map keys must be unique");let K=r3.resolveProps(A??[],{indicator:"map-value-ind",next:T,offset:P.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!L||L.type==="block-scalar"});if(J=K.end,K.found){if(O){if(T?.type==="block-map"&&!K.hasNewline)Q(J,"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=T?X(q,T,K,Q):U(q,J,A,null,K,Q);if(q.schema.compat)a3.flowIndentCheck(Z.indent,T,Q);J=C.range[2];let N=new o3.Pair(P,C);if(q.options.keepSourceTokens)N.srcToken=$;H.items.push(N)}else{if(O)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 o3.Pair(P);if(q.options.keepSourceTokens)C.srcToken=$;H.items.push(C)}}if(W&&W<J)Q(W,"IMPOSSIBLE","Map comment with trailing content");return H.range=[Z.offset,J,W??J],H}jL.resolveBlockMap=bL});var e3=R((xL)=>{var yL=q1(),gL=U6(),kL=hX();function vL({composeNode:X,composeEmptyNode:U},q,Z,Q,G){let H=new(G?.nodeClass??yL.YAMLSeq)(q.schema);if(q.atRoot)q.atRoot=!1;if(q.atKey)q.atKey=!1;let J=Z.offset,W=null;for(let{start:$,value:_}of Z.items){let L=gL.resolveProps($,{indicator:"seq-item-ind",next:_,offset:J,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(J,"MISSING_CHAR","Sequence item without - indicator");else{if(W=L.end,L.comment)H.comment=L.comment;continue}let A=_?X(q,_,L,Q):U(q,L.end,$,null,L,Q);if(q.schema.compat)kL.flowIndentCheck(Z.indent,_,Q);J=A.range[2],H.items.push(A)}return H.range=[Z.offset,J,W??J],H}xL.resolveBlockSeq=vL});var e1=R((mL)=>{function uL(X,U,q,Z){let Q="";if(X){let G=!1,Y="";for(let H of X){let{source:J,type:W}=H;switch(W){case"space":G=!0;break;case"comment":{if(q&&!G)Z(H,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let $=J.substring(1)||" ";if(!Q)Q=$;else Q+=Y+$;Y="";break}case"newline":if(Q)Y+=J;G=!0;break;default:Z(H,"UNEXPECTED_TOKEN",`Unexpected ${W} at node end`)}U+=J.length}}return{comment:Q,offset:U}}mL.resolveEnd=uL});var qQ=R((aL)=>{var lL=k(),dL=e0(),XQ=U1(),cL=q1(),iL=e1(),UQ=U6(),sL=M4(),oL=uX(),mX="Block collections are not allowed within flow collections",pX=(X)=>X&&(X.type==="block-map"||X.type==="block-seq");function rL({composeNode:X,composeEmptyNode:U},q,Z,Q,G){let Y=Z.start.source==="{",H=Y?"flow map":"flow sequence",W=new(G?.nodeClass??(Y?XQ.YAMLMap:cL.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 O=0;O<Z.items.length;++O){let D=Z.items[O],{start:P,key:K,sep:C,value:N}=D,j=UQ.resolveProps(P,{flow:H,indicator:"explicit-key-ind",next:K??C?.[0],offset:_,onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(!j.found){if(!j.anchor&&!j.tag&&!C&&!N){if(O===0&&j.comma)Q(j.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${H}`);else if(O<Z.items.length-1)Q(j.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${H}`);if(j.comment)if(W.comment)W.comment+=`
66
+ `+j.comment;else W.comment=j.comment;_=j.end;continue}if(!Y&&q.options.strict&&sL.containsNewline(K))Q(K,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(O===0){if(j.comma)Q(j.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${H}`)}else{if(!j.comma)Q(j.start,"MISSING_CHAR",`Missing , between ${H} items`);if(j.comment){let m="";X:for(let w of P)switch(w.type){case"comma":case"space":break;case"comment":m=w.source.substring(1);break X;default:break X}if(m){let w=W.items[W.items.length-1];if(lL.isPair(w))w=w.value??w.key;if(w.comment)w.comment+=`
67
+ `+m;else w.comment=m;j.comment=j.comment.substring(m.length+1)}}}if(!Y&&!C&&!j.found){let m=N?X(q,N,j,Q):U(q,j.end,C,null,j,Q);if(W.items.push(m),_=m.range[2],pX(N))Q(m.range,"BLOCK_IN_FLOW",mX)}else{q.atKey=!0;let m=j.end,w=K?X(q,K,j,Q):U(q,m,P,null,j,Q);if(pX(K))Q(w.range,"BLOCK_IN_FLOW",mX);q.atKey=!1;let s=UQ.resolveProps(C??[],{flow:H,indicator:"map-value-ind",next:N,offset:w.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(s.found){if(!Y&&!j.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(j.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 ${H}`);else Q(s.start,"MISSING_CHAR",`Missing , or : between ${H} items`);let m0=N?X(q,N,s,Q):s.found?U(q,s.end,C,null,s,Q):null;if(m0){if(pX(N))Q(m0.range,"BLOCK_IN_FLOW",mX)}else if(s.comment)if(w.comment)w.comment+=`
68
+ `+s.comment;else w.comment=s.comment;let M1=new dL.Pair(w,m0);if(q.options.keepSourceTokens)M1.srcToken=D;if(Y){let o=W;if(oL.mapIncludes(q,o.items,w))Q(m,"DUPLICATE_KEY","Map keys must be unique");o.items.push(M1)}else{let o=new XQ.YAMLMap(q.schema);o.flow=!0,o.items.push(M1);let WU=(m0??w).range;o.range=[w.range[0],WU[1],WU[2]],W.items.push(o)}_=m0?m0.range[2]:s.end}}let L=Y?"}":"]",[A,...T]=Z.end,z=_;if(A?.source===L)z=A.offset+A.source.length;else{let O=H[0].toUpperCase()+H.substring(1),D=$?`${O} must end with a ${L}`:`${O} in block collection must be sufficiently indented and end with a ${L}`;if(Q(_,$?"MISSING_CHAR":"BAD_INDENT",D),A&&A.source.length!==1)T.unshift(A)}if(T.length>0){let O=iL.resolveEnd(T,z,q.options.strict,Q);if(O.comment)if(W.comment)W.comment+=`
69
+ `+O.comment;else W.comment=O.comment;W.range=[Z.offset,z,O.offset]}else W.range=[Z.offset,z,z];return W}aL.resolveFlowCollection=rL});var ZQ=R((Yz)=>{var tL=k(),eL=i(),Xz=U1(),Uz=q1(),qz=t3(),Zz=e3(),Qz=qQ();function lX(X,U,q,Z,Q,G){let Y=q.type==="block-map"?qz.resolveBlockMap(X,U,q,Z,G):q.type==="block-seq"?Zz.resolveBlockSeq(X,U,q,Z,G):Qz.resolveFlowCollection(X,U,q,Z,G),H=Y.constructor;if(Q==="!"||Q===H.tagName)return Y.tag=H.tagName,Y;if(Q)Y.tag=Q;return Y}function Gz(X,U,q,Z,Q){let G=Z.tag,Y=!G?null:U.directives.tagName(G.source,(L)=>Q(G,"TAG_RESOLVE_FAILED",L));if(q.type==="block-seq"){let{anchor:L,newlineAfterProp:A}=Z,T=L&&G?L.offset>G.offset?L:G:L??G;if(T&&(!A||A.offset<T.offset))Q(T,"MISSING_CHAR","Missing newline after block sequence props")}let H=q.type==="block-map"?"map":q.type==="block-seq"?"seq":q.start.source==="{"?"map":"seq";if(!G||!Y||Y==="!"||Y===Xz.YAMLMap.tagName&&H==="map"||Y===Uz.YAMLSeq.tagName&&H==="seq")return lX(X,U,q,Q,Y);let J=U.schema.tags.find((L)=>L.tag===Y&&L.collection===H);if(!J){let L=U.schema.knownTags[Y];if(L?.collection===H)U.schema.tags.push(Object.assign({},L,{default:!1})),J=L;else{if(L)Q(G,"BAD_COLLECTION_TYPE",`${L.tag} used for ${H} collection, but expects ${L.collection??"scalar"}`,!0);else Q(G,"TAG_RESOLVE_FAILED",`Unresolved tag: ${Y}`,!0);return lX(X,U,q,Q,Y)}}let W=lX(X,U,q,Q,Y,J),$=J.resolve?.(W,(L)=>Q(G,"TAG_RESOLVE_FAILED",L),U.options)??W,_=tL.isNode($)?$:new eL.Scalar($);if(_.range=W.range,_.tag=Y,J?.format)_.format=J.format;return _}Yz.composeCollection=Gz});var cX=R(($z)=>{var dX=i();function Jz(X,U,q){let Z=U.offset,Q=Wz(U,X.options.strict,q);if(!Q)return{value:"",type:null,comment:"",range:[Z,Z,Z]};let G=Q.mode===">"?dX.Scalar.BLOCK_FOLDED:dX.Scalar.BLOCK_LITERAL,Y=U.source?_z(U.source):[],H=Y.length;for(let z=Y.length-1;z>=0;--z){let O=Y[z][1];if(O===""||O==="\r")H=z;else break}if(H===0){let z=Q.chomp==="+"&&Y.length>0?`
70
+ `.repeat(Math.max(1,Y.length-1)):"",O=Z+Q.length;if(U.source)O+=U.source.length;return{value:z,type:G,comment:Q.comment,range:[Z,O,O]}}let J=U.indent+Q.indent,W=U.offset+Q.length,$=0;for(let z=0;z<H;++z){let[O,D]=Y[z];if(D===""||D==="\r"){if(Q.indent===0&&O.length>J)J=O.length}else{if(O.length<J)q(W+O.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(Q.indent===0)J=O.length;if($=z,J===0&&!X.atRoot)q(W,"BAD_INDENT","Block scalar values in collections must be indented");break}W+=O.length+D.length+1}for(let z=Y.length-1;z>=H;--z)if(Y[z][0].length>J)H=z+1;let _="",L="",A=!1;for(let z=0;z<$;++z)_+=Y[z][0].slice(J)+`
71
+ `;for(let z=$;z<H;++z){let[O,D]=Y[z];W+=O.length+D.length+1;let P=D[D.length-1]==="\r";if(P)D=D.slice(0,-1);if(D&&O.length<J){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),O=""}if(G===dX.Scalar.BLOCK_LITERAL)_+=L+O.slice(J)+D,L=`
72
+ `;else if(O.length>J||D[0]==="\t"){if(L===" ")L=`
73
+ `;else if(!A&&L===`
74
+ `)L=`
75
75
 
76
- `;L+=$+O.slice(J)+D,$=`
77
- `,A=!0}else if(D==="")if($===`
78
- `)L+=`
79
- `;else $=`
80
- `;else L+=$+D,$=" ",A=!1}switch(Q.chomp){case"-":break;case"+":for(let z=H;z<Y.length;++z)L+=`
81
- `+Y[z][0].slice(J);if(L[L.length-1]!==`
82
- `)L+=`
83
- `;break;default:L+=`
84
- `}let B=Z+Q.length+X.source.length;return{value:L,type:G,comment:Q.comment,range:[Z,B,B]}}function Zz({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,H="",J=-1;for(let $=1;$<Q.length;++$){let A=Q[$];if(!H&&(A==="-"||A==="+"))H=A;else{let B=Number(A);if(!Y&&B)Y=B;else if(J===-1)J=U+$}}if(J!==-1)Z(J,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${Q}`);let W=!1,_="",L=Q.length;for(let $=1;$<X.length;++$){let A=X[$];switch(A.type){case"space":W=!0;case"newline":L+=A.source.length;break;case"comment":if(q&&!W)Z(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");L+=A.source.length,_=A.source.substring(1);break;case"error":Z(A,"UNEXPECTED_TOKEN",A.message),L+=A.source.length;break;default:{let B=`Unexpected token in block scalar header: ${A.type}`;Z(A,"UNEXPECTED_TOKEN",B);let z=A.source;if(z&&typeof z==="string")L+=z.length}}}return{mode:G,indent:Y,chomp:H,comment:_,length:L}}function Qz(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}Gz.resolveBlockScalar=qz});var mU=R((Az)=>{var uU=i(),Hz=t1();function Jz(U,X,q){let{offset:Z,type:Q,source:G,end:Y}=U,H,J,W=($,A,B)=>q(Z+$,A,B);switch(Q){case"scalar":H=uU.Scalar.PLAIN,J=Wz(G,W);break;case"single-quoted-scalar":H=uU.Scalar.QUOTE_SINGLE,J=Lz(G,W);break;case"double-quoted-scalar":H=uU.Scalar.QUOTE_DOUBLE,J=_z(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,L=Hz.resolveEnd(Y,_,X,q);return{value:J,type:H,comment:L.comment,range:[Z,_,L.offset]}}function Wz(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 a3(U)}function Lz(U,X){if(U[U.length-1]!=="'"||U.length===1)X(U.length,"MISSING_CHAR","Missing closing 'quote");return a3(U.slice(1,-1)).replace(/''/g,"'")}function a3(U){let X,q;try{X=new RegExp(`(.*?)(?<![ ])[ ]*\r?
76
+ `;_+=L+O.slice(J)+D,L=`
77
+ `,A=!0}else if(D==="")if(L===`
78
+ `)_+=`
79
+ `;else L=`
80
+ `;else _+=L+D,L=" ",A=!1}switch(Q.chomp){case"-":break;case"+":for(let z=H;z<Y.length;++z)_+=`
81
+ `+Y[z][0].slice(J);if(_[_.length-1]!==`
82
+ `)_+=`
83
+ `;break;default:_+=`
84
+ `}let T=Z+Q.length+U.source.length;return{value:_,type:G,comment:Q.comment,range:[Z,T,T]}}function Wz({offset:X,props:U},q,Z){if(U[0].type!=="block-scalar-header")return Z(U[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:Q}=U[0],G=Q[0],Y=0,H="",J=-1;for(let L=1;L<Q.length;++L){let A=Q[L];if(!H&&(A==="-"||A==="+"))H=A;else{let T=Number(A);if(!Y&&T)Y=T;else if(J===-1)J=X+L}}if(J!==-1)Z(J,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${Q}`);let W=!1,$="",_=Q.length;for(let L=1;L<U.length;++L){let A=U[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 T=`Unexpected token in block scalar header: ${A.type}`;Z(A,"UNEXPECTED_TOKEN",T);let z=A.source;if(z&&typeof z==="string")_+=z.length}}}return{mode:G,indent:Y,chomp:H,comment:$,length:_}}function _z(X){let U=X.split(/\n( *)/),q=U[0],Z=q.match(/^( *)/),G=[Z?.[1]?[Z[1],q.slice(Z[1].length)]:["",q]];for(let Y=1;Y<U.length;Y+=2)G.push([U[Y],U[Y+1]]);return G}$z.resolveBlockScalar=Jz});var sX=R((Dz)=>{var iX=i(),zz=e1();function Fz(X,U,q){let{offset:Z,type:Q,source:G,end:Y}=X,H,J,W=(L,A,T)=>q(Z+L,A,T);switch(Q){case"scalar":H=iX.Scalar.PLAIN,J=Az(G,W);break;case"single-quoted-scalar":H=iX.Scalar.QUOTE_SINGLE,J=Vz(G,W);break;case"double-quoted-scalar":H=iX.Scalar.QUOTE_DOUBLE,J=Oz(G,W);break;default:return q(X,"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,_=zz.resolveEnd(Y,$,U,q);return{value:J,type:H,comment:_.comment,range:[Z,$,_.offset]}}function Az(X,U){let q="";switch(X[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 ${X[0]}`;break}case"@":case"`":{q=`reserved character ${X[0]}`;break}}if(q)U(0,"BAD_SCALAR_START",`Plain value cannot start with ${q}`);return QQ(X)}function Vz(X,U){if(X[X.length-1]!=="'"||X.length===1)U(X.length,"MISSING_CHAR","Missing closing 'quote");return QQ(X.slice(1,-1)).replace(/''/g,"'")}function QQ(X){let U,q;try{U=new RegExp(`(.*?)(?<![ ])[ ]*\r?
85
85
  `,"sy"),q=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
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===`
86
+ `,"sy")}catch{U=/(.*?)[ \t]*\r?\n/sy,q=/[ \t]*(.*?)[ \t]*\r?\n/sy}let Z=U.exec(X);if(!Z)return X;let Q=Z[1],G=" ",Y=U.lastIndex;q.lastIndex=Y;while(Z=q.exec(X)){if(Z[1]==="")if(G===`
87
87
  `)Q+=G;else G=`
88
- `;else Q+=G+Z[1],G=" ";Y=q.lastIndex}let H=/[ \t]*(.*)/sy;return H.lastIndex=Y,Z=H.exec(U),Q+G+(Z?.[1]??"")}function _z(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 H=/[ \t]*(.*)/sy;return H.lastIndex=Y,Z=H.exec(X),Q+G+(Z?.[1]??"")}function Oz(X,U){let q="";for(let Z=1;Z<X.length-1;++Z){let Q=X[Z];if(Q==="\r"&&X[Z+1]===`
89
89
  `)continue;if(Q===`
90
- `){let{fold:G,offset:Y}=$z(U,Z);q+=G,Z=Y}else if(Q==="\\"){let G=U[++Z],Y=zz[G];if(Y)q+=Y;else if(G===`
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 H={x:2,u:4,U:8}[G];q+=Fz(U,Z+1,H,X),Z+=H}else{let H=U.substr(Z-1,2);X(Z-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${H}`),q+=H}}else if(Q===" "||Q==="\t"){let G=Z,Y=U[Z+1];while(Y===" "||Y==="\t")Y=U[++Z+1];if(Y!==`
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 $z(U,X){let q="",Z=U[X+1];while(Z===" "||Z==="\t"||Z===`
95
- `||Z==="\r"){if(Z==="\r"&&U[X+2]!==`
90
+ `){let{fold:G,offset:Y}=Bz(X,Z);q+=G,Z=Y}else if(Q==="\\"){let G=X[++Z],Y=Tz[G];if(Y)q+=Y;else if(G===`
91
+ `){G=X[Z+1];while(G===" "||G==="\t")G=X[++Z+1]}else if(G==="\r"&&X[Z+1]===`
92
+ `){G=X[++Z+1];while(G===" "||G==="\t")G=X[++Z+1]}else if(G==="x"||G==="u"||G==="U"){let H={x:2,u:4,U:8}[G];q+=Rz(X,Z+1,H,U),Z+=H}else{let H=X.substr(Z-1,2);U(Z-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${H}`),q+=H}}else if(Q===" "||Q==="\t"){let G=Z,Y=X[Z+1];while(Y===" "||Y==="\t")Y=X[++Z+1];if(Y!==`
93
+ `&&!(Y==="\r"&&X[Z+2]===`
94
+ `))q+=Z>G?X.slice(G,Z+1):Q}else q+=Q}if(X[X.length-1]!=='"'||X.length===1)U(X.length,"MISSING_CHAR",'Missing closing "quote');return q}function Bz(X,U){let q="",Z=X[U+1];while(Z===" "||Z==="\t"||Z===`
95
+ `||Z==="\r"){if(Z==="\r"&&X[U+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 zz={"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 Fz(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 H=U.substr(X-2,q+2);return Z(X-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${H}`),H}return String.fromCodePoint(Y)}Az.resolveFlowScalar=Jz});var e3=R((Mz)=>{var V1=k(),t3=i(),Oz=hU(),Vz=mU();function Bz(U,X,q,Z){let{value:Q,type:G,comment:Y,range:H}=X.type==="block-scalar"?Oz.resolveBlockScalar(U,X,Z):Vz.resolveFlowScalar(X,U.options.strict,Z),J=q?U.directives.tagName(q.source,(L)=>Z(q,"TAG_RESOLVE_FAILED",L)):null,W;if(U.options.stringKeys&&U.atKey)W=U.schema[V1.SCALAR];else if(J)W=Rz(U.schema,Q,J,q,Z);else if(X.type==="scalar")W=Dz(U,Q,X,Z);else W=U.schema[V1.SCALAR];let _;try{let L=W.resolve(Q,($)=>Z(q??X,"TAG_RESOLVE_FAILED",$),U.options);_=V1.isScalar(L)?L:new t3.Scalar(L)}catch(L){let $=L instanceof Error?L.message:String(L);Z(q??X,"TAG_RESOLVE_FAILED",$),_=new t3.Scalar(Q)}if(_.range=H,_.source=Q,G)_.type=G;if(J)_.tag=J;if(W.format)_.format=W.format;if(Y)_.comment=Y;return _}function Rz(U,X,q,Z,Q){if(q==="!")return U[V1.SCALAR];let G=[];for(let H of U.tags)if(!H.collection&&H.tag===q)if(H.default&&H.test)G.push(H);else return H;for(let H of G)if(H.test?.test(X))return H;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 Dz({atKey:U,directives:X,schema:q},Z,Q,G){let Y=q.tags.find((H)=>(H.default===!0||U&&H.default==="key")&&H.test?.test(Z))||q[V1.SCALAR];if(q.compat){let H=q.compat.find((J)=>J.default&&J.test?.test(Z))??q[V1.SCALAR];if(Y.tag!==H.tag){let J=X.tagString(Y.tag),W=X.tagString(H.tag),_=`Value may be parsed as either ${J} or ${W}`;G(Q,"TAG_RESOLVE_FAILED",_,!0)}}return Y}Mz.composeScalar=Bz});var UQ=R((Iz)=>{function Pz(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}Iz.emptyScalarPosition=Pz});var ZQ=R((gz)=>{var Nz=f2(),Cz=k(),Sz=n3(),XQ=e3(),Ez=t1(),bz=UQ(),jz={composeNode:qQ,composeEmptyNode:pU};function qQ(U,X,q,Z){let Q=U.atKey,{spaceBefore:G,comment:Y,anchor:H,tag:J}=q,W,_=!0;switch(X.type){case"alias":if(W=fz(U,X,Z),H||J)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=XQ.composeScalar(U,X,J,Z),H)W.anchor=H.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(W=Sz.composeCollection(jz,U,X,q,Z),H)W.anchor=H.source.substring(1);break;default:{let L=X.type==="error"?X.message:`Unsupported token (type: ${X.type})`;Z(X,"UNEXPECTED_TOKEN",L),W=pU(U,X.offset,void 0,null,q,Z),_=!1}}if(H&&W.anchor==="")Z(H,"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(J??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 pU(U,X,q,Z,{spaceBefore:Q,comment:G,anchor:Y,tag:H,end:J},W){let _={type:"scalar",offset:bz.emptyScalarPosition(X,q,Z),indent:-1,source:""},L=XQ.composeScalar(U,_,H,W);if(Y){if(L.anchor=Y.source.substring(1),L.anchor==="")W(Y,"BAD_ALIAS","Anchor cannot be an empty string")}if(Q)L.spaceBefore=!0;if(G)L.comment=G,L.range[2]=J;return L}function fz({options:U},{offset:X,source:q,end:Z},Q){let G=new Nz.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,H=Ez.resolveEnd(Z,Y,U.strict,Q);if(G.range=[X,Y,H.offset],H.comment)G.comment=H.comment;return G}gz.composeEmptyNode=pU;gz.composeNode=qQ});var GQ=R((mz)=>{var vz=s2(),QQ=ZQ(),xz=t1(),hz=n2();function uz(U,X,{offset:q,start:Z,value:Q,end:G},Y){let H=Object.assign({_directives:X},U),J=new vz.Document(void 0,H),W={atKey:!1,atRoot:!0,directives:J.directives,options:J.options,schema:J.schema},_=hz.resolveProps(Z,{indicator:"doc-start",next:Q??G?.[0],offset:q,onError:Y,parentIndent:0,startOnNewline:!0});if(_.found){if(J.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")}J.contents=Q?QQ.composeNode(W,Q,_,Y):QQ.composeEmptyNode(W,_.end,Z,null,_,Y);let L=J.contents.range[2],$=xz.resolveEnd(G,L,!1,Y);if($.comment)J.comment=$.comment;return J.range=[q,L,$.offset],J}mz.composeDoc=uz});var lU=R((sz)=>{var lz=M1("process"),dz=o9(),cz=s2(),a2=r2(),YQ=k(),iz=GQ(),oz=t1();function t2(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 HQ(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
+ `;U+=1,Z=X[U+1]}if(!q)q=" ";return{fold:q,offset:U}}var Tz={"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 Rz(X,U,q,Z){let Q=X.substr(U,q),Y=Q.length===q&&/^[0-9a-fA-F]+$/.test(Q)?parseInt(Q,16):NaN;if(isNaN(Y)){let H=X.substr(U-2,q+2);return Z(U-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${H}`),H}return String.fromCodePoint(Y)}Dz.resolveFlowScalar=Fz});var YQ=R((Cz)=>{var T1=k(),GQ=i(),wz=cX(),Pz=sX();function Iz(X,U,q,Z){let{value:Q,type:G,comment:Y,range:H}=U.type==="block-scalar"?wz.resolveBlockScalar(X,U,Z):Pz.resolveFlowScalar(U,X.options.strict,Z),J=q?X.directives.tagName(q.source,(_)=>Z(q,"TAG_RESOLVE_FAILED",_)):null,W;if(X.options.stringKeys&&X.atKey)W=X.schema[T1.SCALAR];else if(J)W=Kz(X.schema,Q,J,q,Z);else if(U.type==="scalar")W=Nz(X,Q,U,Z);else W=X.schema[T1.SCALAR];let $;try{let _=W.resolve(Q,(L)=>Z(q??U,"TAG_RESOLVE_FAILED",L),X.options);$=T1.isScalar(_)?_:new GQ.Scalar(_)}catch(_){let L=_ instanceof Error?_.message:String(_);Z(q??U,"TAG_RESOLVE_FAILED",L),$=new GQ.Scalar(Q)}if($.range=H,$.source=Q,G)$.type=G;if(J)$.tag=J;if(W.format)$.format=W.format;if(Y)$.comment=Y;return $}function Kz(X,U,q,Z,Q){if(q==="!")return X[T1.SCALAR];let G=[];for(let H of X.tags)if(!H.collection&&H.tag===q)if(H.default&&H.test)G.push(H);else return H;for(let H of G)if(H.test?.test(U))return H;let Y=X.knownTags[q];if(Y&&!Y.collection)return X.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"),X[T1.SCALAR]}function Nz({atKey:X,directives:U,schema:q},Z,Q,G){let Y=q.tags.find((H)=>(H.default===!0||X&&H.default==="key")&&H.test?.test(Z))||q[T1.SCALAR];if(q.compat){let H=q.compat.find((J)=>J.default&&J.test?.test(Z))??q[T1.SCALAR];if(Y.tag!==H.tag){let J=U.tagString(Y.tag),W=U.tagString(H.tag),$=`Value may be parsed as either ${J} or ${W}`;G(Q,"TAG_RESOLVE_FAILED",$,!0)}}return Y}Cz.composeScalar=Iz});var HQ=R((bz)=>{function Ez(X,U,q){if(U){q??(q=U.length);for(let Z=q-1;Z>=0;--Z){let Q=U[Z];switch(Q.type){case"space":case"comment":case"newline":X-=Q.source.length;continue}Q=U[++Z];while(Q?.type==="space")X+=Q.source.length,Q=U[++Z];break}}return X}bz.emptyScalarPosition=Ez});var _Q=R((uz)=>{var fz=x2(),yz=k(),gz=ZQ(),JQ=YQ(),kz=e1(),vz=HQ(),xz={composeNode:WQ,composeEmptyNode:oX};function WQ(X,U,q,Z){let Q=X.atKey,{spaceBefore:G,comment:Y,anchor:H,tag:J}=q,W,$=!0;switch(U.type){case"alias":if(W=hz(X,U,Z),H||J)Z(U,"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=JQ.composeScalar(X,U,J,Z),H)W.anchor=H.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(W=gz.composeCollection(xz,X,U,q,Z),H)W.anchor=H.source.substring(1);break;default:{let _=U.type==="error"?U.message:`Unsupported token (type: ${U.type})`;Z(U,"UNEXPECTED_TOKEN",_),W=oX(X,U.offset,void 0,null,q,Z),$=!1}}if(H&&W.anchor==="")Z(H,"BAD_ALIAS","Anchor cannot be an empty string");if(Q&&X.options.stringKeys&&(!yz.isScalar(W)||typeof W.value!=="string"||W.tag&&W.tag!=="tag:yaml.org,2002:str"))Z(J??U,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(G)W.spaceBefore=!0;if(Y)if(U.type==="scalar"&&U.source==="")W.comment=Y;else W.commentBefore=Y;if(X.options.keepSourceTokens&&$)W.srcToken=U;return W}function oX(X,U,q,Z,{spaceBefore:Q,comment:G,anchor:Y,tag:H,end:J},W){let $={type:"scalar",offset:vz.emptyScalarPosition(U,q,Z),indent:-1,source:""},_=JQ.composeScalar(X,$,H,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]=J;return _}function hz({options:X},{offset:U,source:q,end:Z},Q){let G=new fz.Alias(q.substring(1));if(G.source==="")Q(U,"BAD_ALIAS","Alias cannot be an empty string");if(G.source.endsWith(":"))Q(U+q.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let Y=U+q.length,H=kz.resolveEnd(Z,Y,X.strict,Q);if(G.range=[U,Y,H.offset],H.comment)G.comment=H.comment;return G}uz.composeEmptyNode=oX;uz.composeNode=WQ});var LQ=R((sz)=>{var lz=e2(),$Q=_Q(),dz=e1(),cz=U6();function iz(X,U,{offset:q,start:Z,value:Q,end:G},Y){let H=Object.assign({_directives:U},X),J=new lz.Document(void 0,H),W={atKey:!1,atRoot:!0,directives:J.directives,options:J.options,schema:J.schema},$=cz.resolveProps(Z,{indicator:"doc-start",next:Q??G?.[0],offset:q,onError:Y,parentIndent:0,startOnNewline:!0});if($.found){if(J.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")}J.contents=Q?$Q.composeNode(W,Q,$,Y):$Q.composeEmptyNode(W,$.end,Z,null,$,Y);let _=J.contents.range[2],L=dz.resolveEnd(G,_,!1,Y);if(L.comment)J.comment=L.comment;return J.range=[q,_,L.offset],J}sz.composeDoc=iz});var rX=R((XF)=>{var rz=w1("process"),az=e9(),nz=e2(),q6=X6(),zQ=k(),tz=LQ(),ez=e1();function Z6(X){if(typeof X==="number")return[X,X+1];if(Array.isArray(X))return X.length===2?X:[X[0],X[1]];let{offset:U,source:q}=X;return[U,U+(typeof q==="string"?q.length:1)]}function FQ(X){let U="",q=!1,Z=!1;for(let Q=0;Q<X.length;++Q){let G=X[Q];switch(G[0]){case"#":U+=(U===""?"":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 JQ{constructor(U={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(X,q,Z,Q)=>{let G=t2(X);if(Q)this.warnings.push(new a2.YAMLWarning(G,q,Z));else this.errors.push(new a2.YAMLParseError(G,q,Z))},this.directives=new dz.Directives({version:U.version||"1.2"}),this.options=U}decorate(U,X){let{comment:q,afterEmptyLine:Z}=HQ(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(YQ.isCollection(Q)&&!Q.flow&&Q.items.length>0){let G=Q.items[0];if(YQ.isPair(G))G=G.key;let Y=G.commentBefore;G.commentBefore=Y?`${q}
102
+ `)+(G.substring(1)||" "),q=!0,Z=!1;break;case"%":if(X[Q+1]?.[0]!=="#")Q+=1;q=!1;break;default:if(!q)Z=!0;q=!1}}return{comment:U,afterEmptyLine:Z}}class AQ{constructor(X={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(U,q,Z,Q)=>{let G=Z6(U);if(Q)this.warnings.push(new q6.YAMLWarning(G,q,Z));else this.errors.push(new q6.YAMLParseError(G,q,Z))},this.directives=new az.Directives({version:X.version||"1.2"}),this.options=X}decorate(X,U){let{comment:q,afterEmptyLine:Z}=FQ(this.prelude);if(q){let Q=X.contents;if(U)X.comment=X.comment?`${X.comment}
103
+ ${q}`:q;else if(Z||X.directives.docStart||!Q)X.commentBefore=q;else if(zQ.isCollection(Q)&&!Q.flow&&Q.items.length>0){let G=Q.items[0];if(zQ.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:HQ(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(lz.env.LOG_STREAM)console.dir(U,{depth:null});switch(U.type){case"directive":this.directives.add(U.source,(X,q,Z)=>{let Q=t2(U);Q[0]+=X,this.onError(Q,"BAD_DIRECTIVE",q,Z)}),this.prelude.push(U.source),this.atDirectives=!0;break;case"document":{let X=iz.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 a2.YAMLParseError(t2(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 a2.YAMLParseError(t2(U),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let X=oz.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 a2.YAMLParseError(t2(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 cz.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}}}sz.Composer=JQ});var _Q=R((ZF)=>{var nz=hU(),az=mU(),tz=r2(),WQ=v2();function ez(U,X=!0,q){if(U){let Z=(Q,G,Y)=>{let H=typeof Q==="number"?Q:Array.isArray(Q)?Q[0]:Q.offset;if(q)q(H,G,Y);else throw new tz.YAMLParseError([H,H+1],G,Y)};switch(U.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return az.resolveFlowScalar(U,X,Z);case"block-scalar":return nz.resolveBlockScalar({options:{strict:X}},U,Z)}}return null}function UF(U,X){let{implicitKey:q=!1,indent:Z,inFlow:Q=!1,offset:G=-1,type:Y="PLAIN"}=X,H=WQ.stringifyString({type:Y,value:U},{implicitKey:q,indent:Z>0?" ".repeat(Z):"",inFlow:Q,options:{blockQuote:!0,lineWidth:-1}}),J=X.end??[{type:"newline",offset:-1,indent:Z,source:`
105
+ ${G}`:q}}if(U)Array.prototype.push.apply(X.errors,this.errors),Array.prototype.push.apply(X.warnings,this.warnings);else X.errors=this.errors,X.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:FQ(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(X,U=!1,q=-1){for(let Z of X)yield*this.next(Z);yield*this.end(U,q)}*next(X){if(rz.env.LOG_STREAM)console.dir(X,{depth:null});switch(X.type){case"directive":this.directives.add(X.source,(U,q,Z)=>{let Q=Z6(X);Q[0]+=U,this.onError(Q,"BAD_DIRECTIVE",q,Z)}),this.prelude.push(X.source),this.atDirectives=!0;break;case"document":{let U=tz.composeDoc(this.options,this.directives,X,this.onError);if(this.atDirectives&&!U.directives.docStart)this.onError(X,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(U,!1),this.doc)yield this.doc;this.doc=U,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(X.source);break;case"error":{let U=X.source?`${X.message}: ${JSON.stringify(X.source)}`:X.message,q=new q6.YAMLParseError(Z6(X),"UNEXPECTED_TOKEN",U);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(X),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let U=ez.resolveEnd(X.end,X.offset+X.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),U.comment){let q=this.doc.comment;this.doc.comment=q?`${q}
106
+ ${U.comment}`:U.comment}this.doc.range[2]=U.offset;break}default:this.errors.push(new q6.YAMLParseError(Z6(X),"UNEXPECTED_TOKEN",`Unsupported token ${X.type}`))}}*end(X=!1,U=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(X){let q=Object.assign({_directives:this.directives},this.options),Z=new nz.Document(void 0,q);if(this.atDirectives)this.onError(U,"MISSING_CHAR","Missing directives-end indicator line");Z.range=[0,U,U],this.decorate(Z,!1),yield Z}}}XF.Composer=AQ});var BQ=R((WF)=>{var qF=cX(),ZF=sX(),QF=X6(),VQ=p2();function GF(X,U=!0,q){if(X){let Z=(Q,G,Y)=>{let H=typeof Q==="number"?Q:Array.isArray(Q)?Q[0]:Q.offset;if(q)q(H,G,Y);else throw new QF.YAMLParseError([H,H+1],G,Y)};switch(X.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return ZF.resolveFlowScalar(X,U,Z);case"block-scalar":return qF.resolveBlockScalar({options:{strict:U}},X,Z)}}return null}function YF(X,U){let{implicitKey:q=!1,indent:Z,inFlow:Q=!1,offset:G=-1,type:Y="PLAIN"}=U,H=VQ.stringifyString({type:Y,value:X},{implicitKey:q,indent:Z>0?" ".repeat(Z):"",inFlow:Q,options:{blockQuote:!0,lineWidth:-1}}),J=U.end??[{type:"newline",offset:-1,indent:Z,source:`
107
107
  `}];switch(H[0]){case"|":case">":{let W=H.indexOf(`
108
- `),_=H.substring(0,W),L=H.substring(W+1)+`
109
- `,$=[{type:"block-scalar-header",offset:G,indent:Z,source:_}];if(!LQ($,J))$.push({type:"newline",offset:-1,indent:Z,source:`
110
- `});return{type:"block-scalar",offset:G,indent:Z,props:$,source:L}}case'"':return{type:"double-quoted-scalar",offset:G,indent:Z,source:H,end:J};case"'":return{type:"single-quoted-scalar",offset:G,indent:Z,source:H,end:J};default:return{type:"scalar",offset:G,indent:Z,source:H,end:J}}}function XF(U,X,q={}){let{afterKey:Z=!1,implicitKey:Q=!1,inFlow:G=!1,type:Y}=q,H="indent"in U?U.indent:null;if(Z&&typeof H==="number")H+=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 J=WQ.stringifyString({type:Y,value:X},{implicitKey:Q||H===null,indent:H!==null&&H>0?" ".repeat(H):"",inFlow:G,options:{blockQuote:!0,lineWidth:-1}});switch(J[0]){case"|":case">":qF(U,J);break;case'"':dU(U,J,"double-quoted-scalar");break;case"'":dU(U,J,"single-quoted-scalar");break;default:dU(U,J,"scalar")}}function qF(U,X){let q=X.indexOf(`
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,H=[{type:"block-scalar-header",offset:G,indent:Y,source:Z}];if(!LQ(H,"end"in U?U.end:void 0))H.push({type:"newline",offset:-1,indent:Y,source:`
113
- `});for(let J of Object.keys(U))if(J!=="type"&&J!=="offset")delete U[J];Object.assign(U,{type:"block-scalar",indent:Y,props:H,source:Q})}}function LQ(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 dU(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})}}}ZF.createScalarToken=UF;ZF.resolveAsScalar=ez;ZF.setScalarValue=XF});var $Q=R((JF)=>{var HF=(U)=>("type"in U)?R4(U):B4(U);function R4(U){switch(U.type){case"block-scalar":{let X="";for(let q of U.props)X+=R4(q);return X+U.source}case"block-map":case"block-seq":{let X="";for(let q of U.items)X+=B4(q);return X}case"flow-collection":{let X=U.start.source;for(let q of U.items)X+=B4(q);for(let q of U.end)X+=q.source;return X}case"document":{let X=B4(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 B4({start:U,key:X,sep:q,value:Z}){let Q="";for(let G of U)Q+=G.source;if(X)Q+=R4(X);if(q)for(let G of q)Q+=G.source;if(Z)Q+=R4(Z);return Q}JF.stringify=HF});var AQ=R((_F)=>{var cU=Symbol("break visit"),LF=Symbol("skip children"),zQ=Symbol("remove item");function B1(U,X){if("type"in U&&U.type==="document")U={start:U.start,value:U.value};FQ(Object.freeze([]),U,X)}B1.BREAK=cU;B1.SKIP=LF;B1.REMOVE=zQ;B1.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};B1.parentCollection=(U,X)=>{let q=B1.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 FQ(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 H=FQ(Object.freeze(U.concat([[Q,Y]])),G.items[Y],q);if(typeof H==="number")Y=H-1;else if(H===cU)return cU;else if(H===zQ)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}_F.visit=B1});var D4=R((BF)=>{var iU=_Q(),zF=$Q(),FF=AQ(),oU="\uFEFF",sU="\x02",rU="\x18",nU="\x1F",AF=(U)=>!!U&&("items"in U),TF=(U)=>!!U&&(U.type==="scalar"||U.type==="single-quoted-scalar"||U.type==="double-quoted-scalar"||U.type==="block-scalar");function OF(U){switch(U){case oU:return"<BOM>";case sU:return"<DOC>";case rU:return"<FLOW_END>";case nU:return"<SCALAR>";default:return JSON.stringify(U)}}function VF(U){switch(U){case oU:return"byte-order-mark";case sU:return"doc-mode";case rU:return"flow-error-end";case nU:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
108
+ `),$=H.substring(0,W),_=H.substring(W+1)+`
109
+ `,L=[{type:"block-scalar-header",offset:G,indent:Z,source:$}];if(!OQ(L,J))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:H,end:J};case"'":return{type:"single-quoted-scalar",offset:G,indent:Z,source:H,end:J};default:return{type:"scalar",offset:G,indent:Z,source:H,end:J}}}function HF(X,U,q={}){let{afterKey:Z=!1,implicitKey:Q=!1,inFlow:G=!1,type:Y}=q,H="indent"in X?X.indent:null;if(Z&&typeof H==="number")H+=2;if(!Y)switch(X.type){case"single-quoted-scalar":Y="QUOTE_SINGLE";break;case"double-quoted-scalar":Y="QUOTE_DOUBLE";break;case"block-scalar":{let W=X.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 J=VQ.stringifyString({type:Y,value:U},{implicitKey:Q||H===null,indent:H!==null&&H>0?" ".repeat(H):"",inFlow:G,options:{blockQuote:!0,lineWidth:-1}});switch(J[0]){case"|":case">":JF(X,J);break;case'"':aX(X,J,"double-quoted-scalar");break;case"'":aX(X,J,"single-quoted-scalar");break;default:aX(X,J,"scalar")}}function JF(X,U){let q=U.indexOf(`
111
+ `),Z=U.substring(0,q),Q=U.substring(q+1)+`
112
+ `;if(X.type==="block-scalar"){let G=X.props[0];if(G.type!=="block-scalar-header")throw Error("Invalid block scalar header");G.source=Z,X.source=Q}else{let{offset:G}=X,Y="indent"in X?X.indent:-1,H=[{type:"block-scalar-header",offset:G,indent:Y,source:Z}];if(!OQ(H,"end"in X?X.end:void 0))H.push({type:"newline",offset:-1,indent:Y,source:`
113
+ `});for(let J of Object.keys(X))if(J!=="type"&&J!=="offset")delete X[J];Object.assign(X,{type:"block-scalar",indent:Y,props:H,source:Q})}}function OQ(X,U){if(U)for(let q of U)switch(q.type){case"space":case"comment":X.push(q);break;case"newline":return X.push(q),!0}return!1}function aX(X,U,q){switch(X.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":X.type=q,X.source=U;break;case"block-scalar":{let Z=X.props.slice(1),Q=U.length;if(X.props[0].type==="block-scalar-header")Q-=X.props[0].source.length;for(let G of Z)G.offset+=Q;delete X.props,Object.assign(X,{type:q,source:U,end:Z});break}case"block-map":case"block-seq":{let Q={type:"newline",offset:X.offset+U.length,indent:X.indent,source:`
114
+ `};delete X.items,Object.assign(X,{type:q,source:U,end:[Q]});break}default:{let Z="indent"in X?X.indent:-1,Q="end"in X&&Array.isArray(X.end)?X.end.filter((G)=>G.type==="space"||G.type==="comment"||G.type==="newline"):[];for(let G of Object.keys(X))if(G!=="type"&&G!=="offset")delete X[G];Object.assign(X,{type:q,indent:Z,source:U,end:Q})}}}WF.createScalarToken=YF;WF.resolveAsScalar=GF;WF.setScalarValue=HF});var TQ=R((FF)=>{var zF=(X)=>("type"in X)?P4(X):w4(X);function P4(X){switch(X.type){case"block-scalar":{let U="";for(let q of X.props)U+=P4(q);return U+X.source}case"block-map":case"block-seq":{let U="";for(let q of X.items)U+=w4(q);return U}case"flow-collection":{let U=X.start.source;for(let q of X.items)U+=w4(q);for(let q of X.end)U+=q.source;return U}case"document":{let U=w4(X);if(X.end)for(let q of X.end)U+=q.source;return U}default:{let U=X.source;if("end"in X&&X.end)for(let q of X.end)U+=q.source;return U}}}function w4({start:X,key:U,sep:q,value:Z}){let Q="";for(let G of X)Q+=G.source;if(U)Q+=P4(U);if(q)for(let G of q)Q+=G.source;if(Z)Q+=P4(Z);return Q}FF.stringify=zF});var MQ=R((OF)=>{var nX=Symbol("break visit"),VF=Symbol("skip children"),RQ=Symbol("remove item");function R1(X,U){if("type"in X&&X.type==="document")X={start:X.start,value:X.value};DQ(Object.freeze([]),X,U)}R1.BREAK=nX;R1.SKIP=VF;R1.REMOVE=RQ;R1.itemAtPath=(X,U)=>{let q=X;for(let[Z,Q]of U){let G=q?.[Z];if(G&&"items"in G)q=G.items[Q];else return}return q};R1.parentCollection=(X,U)=>{let q=R1.itemAtPath(X,U.slice(0,-1)),Z=U[U.length-1][0],Q=q?.[Z];if(Q&&"items"in Q)return Q;throw Error("Parent collection not found")};function DQ(X,U,q){let Z=q(U,X);if(typeof Z==="symbol")return Z;for(let Q of["key","value"]){let G=U[Q];if(G&&"items"in G){for(let Y=0;Y<G.items.length;++Y){let H=DQ(Object.freeze(X.concat([[Q,Y]])),G.items[Y],q);if(typeof H==="number")Y=H-1;else if(H===nX)return nX;else if(H===RQ)G.items.splice(Y,1),Y-=1}if(typeof Z==="function"&&Q==="key")Z=Z(U,X)}}return typeof Z==="function"?Z(U,X):Z}OF.visit=R1});var I4=R((IF)=>{var tX=BQ(),TF=TQ(),RF=MQ(),eX="\uFEFF",XU="\x02",UU="\x18",qU="\x1F",DF=(X)=>!!X&&("items"in X),MF=(X)=>!!X&&(X.type==="scalar"||X.type==="single-quoted-scalar"||X.type==="double-quoted-scalar"||X.type==="block-scalar");function wF(X){switch(X){case eX:return"<BOM>";case XU:return"<DOC>";case UU:return"<FLOW_END>";case qU:return"<SCALAR>";default:return JSON.stringify(X)}}function PF(X){switch(X){case eX:return"byte-order-mark";case XU:return"doc-mode";case UU:return"flow-error-end";case qU: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}BF.createScalarToken=iU.createScalarToken;BF.resolveAsScalar=iU.resolveAsScalar;BF.setScalarValue=iU.setScalarValue;BF.stringify=zF.stringify;BF.visit=FF.visit;BF.BOM=oU;BF.DOCUMENT=sU;BF.FLOW_END=rU;BF.SCALAR=nU;BF.isCollection=AF;BF.isScalar=TF;BF.prettyToken=OF;BF.tokenType=VF});var tU=R((yF)=>{var e2=D4();function I0(U){switch(U){case void 0:case" ":case`
117
- `:case"\r":case"\t":return!0;default:return!1}}var TQ=new Set("0123456789ABCDEFabcdef"),fF=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),M4=new Set(",[]{}"),gF=new Set(` ,[]{}
118
- \r `),aU=(U)=>!U||gF.has(U);class OQ{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
- `)return!0;if(X==="\r")return this.buffer[U+1]===`
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
- `||!Z&&!this.atEnd)return U+q+1}return X===`
122
- `||q>=this.indentNext||!X&&!this.atEnd?U+q:-1}if(X==="-"||X==="."){let q=this.buffer.substr(U,3);if((q==="---"||q==="...")&&I0(this.buffer[U+3]))return-1}return U}getLine(){let U=this.lineEndPos;if(typeof U!=="number"||U!==-1&&U<this.pos)U=this.buffer.indexOf(`
123
- `,this.pos),this.lineEndPos=U;if(U===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[U-1]==="\r")U-=1;return this.buffer.substring(this.pos,U)}hasChars(U){return this.pos+U<=this.buffer.length}setNext(U){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=U,null}peek(U){return this.buffer.substr(this.pos,U)}*parseNext(U){switch(U){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let U=this.getLine();if(U===null)return this.setNext("stream");if(U[0]===e2.BOM)yield*this.pushCount(1),U=U.substring(1);if(U[0]==="%"){let X=U.length,q=U.indexOf("#");while(q!==-1){let Q=U[q-1];if(Q===" "||Q==="\t"){X=q-1;break}else q=U.indexOf("#",q+1)}while(!0){let Q=U[X-1];if(Q===" "||Q==="\t")X-=1;else break}let Z=(yield*this.pushCount(X))+(yield*this.pushSpaces(!0));return yield*this.pushCount(U.length-Z),this.pushNewline(),"stream"}if(this.atLineEnd()){let X=yield*this.pushSpaces(!0);return yield*this.pushCount(U.length-X),yield*this.pushNewline(),"stream"}return yield e2.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let U=this.charAt(0);if(!U&&!this.atEnd)return this.setNext("line-start");if(U==="-"||U==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let X=this.peek(3);if((X==="---"||X==="...")&&I0(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,X==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!I0(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[U,X]=this.peek(2);if(!X&&!this.atEnd)return this.setNext("block-start");if((U==="-"||U==="?"||U===":")&&I0(X)){let q=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=q,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let U=this.getLine();if(U===null)return this.setNext("doc");let X=yield*this.pushIndicators();switch(U[X]){case"#":yield*this.pushCount(U.length-X);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(aU),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return X+=yield*this.parseBlockScalarHeader(),X+=yield*this.pushSpaces(!0),yield*this.pushCount(U.length-X),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let U,X,q=-1;do{if(U=yield*this.pushNewline(),U>0)X=yield*this.pushSpaces(!1),this.indentValue=q=X;else X=0;X+=yield*this.pushSpaces(!0)}while(U+X>0);let Z=this.getLine();if(Z===null)return this.setNext("flow");if(q!==-1&&q<this.indentNext&&Z[0]!=="#"||q===0&&(Z.startsWith("---")||Z.startsWith("..."))&&I0(Z[3])){if(!(q===this.indentNext-1&&this.flowLevel===1&&(Z[0]==="]"||Z[0]==="}")))return this.flowLevel=0,yield e2.FLOW_END,yield*this.parseLineStart()}let Q=0;while(Z[Q]===",")Q+=yield*this.pushCount(1),Q+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(Q+=yield*this.pushIndicators(),Z[Q]){case void 0:return"flow";case"#":return yield*this.pushCount(Z.length-Q),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(aU),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let G=this.charAt(1);if(this.flowKey||I0(G)||G===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let U=this.charAt(0),X=this.buffer.indexOf(U,this.pos+1);if(U==="'")while(X!==-1&&this.buffer[X+1]==="'")X=this.buffer.indexOf("'",X+2);else while(X!==-1){let Q=0;while(this.buffer[X-1-Q]==="\\")Q+=1;if(Q%2===0)break;X=this.buffer.indexOf('"',X+1)}let q=this.buffer.substring(0,X),Z=q.indexOf(`
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(X[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}IF.createScalarToken=tX.createScalarToken;IF.resolveAsScalar=tX.resolveAsScalar;IF.setScalarValue=tX.setScalarValue;IF.stringify=TF.stringify;IF.visit=RF.visit;IF.BOM=eX;IF.DOCUMENT=XU;IF.FLOW_END=UU;IF.SCALAR=qU;IF.isCollection=DF;IF.isScalar=MF;IF.prettyToken=wF;IF.tokenType=PF});var QU=R((mF)=>{var Q6=I4();function K0(X){switch(X){case void 0:case" ":case`
117
+ `:case"\r":case"\t":return!0;default:return!1}}var wQ=new Set("0123456789ABCDEFabcdef"),hF=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),K4=new Set(",[]{}"),uF=new Set(` ,[]{}
118
+ \r `),ZU=(X)=>!X||uF.has(X);class PQ{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(X,U=!1){if(X){if(typeof X!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+X:X,this.lineEndPos=null}this.atEnd=!U;let q=this.next??"stream";while(q&&(U||this.hasChars(1)))q=yield*this.parseNext(q)}atLineEnd(){let X=this.pos,U=this.buffer[X];while(U===" "||U==="\t")U=this.buffer[++X];if(!U||U==="#"||U===`
119
+ `)return!0;if(U==="\r")return this.buffer[X+1]===`
120
+ `;return!1}charAt(X){return this.buffer[this.pos+X]}continueScalar(X){let U=this.buffer[X];if(this.indentNext>0){let q=0;while(U===" ")U=this.buffer[++q+X];if(U==="\r"){let Z=this.buffer[q+X+1];if(Z===`
121
+ `||!Z&&!this.atEnd)return X+q+1}return U===`
122
+ `||q>=this.indentNext||!U&&!this.atEnd?X+q:-1}if(U==="-"||U==="."){let q=this.buffer.substr(X,3);if((q==="---"||q==="...")&&K0(this.buffer[X+3]))return-1}return X}getLine(){let X=this.lineEndPos;if(typeof X!=="number"||X!==-1&&X<this.pos)X=this.buffer.indexOf(`
123
+ `,this.pos),this.lineEndPos=X;if(X===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[X-1]==="\r")X-=1;return this.buffer.substring(this.pos,X)}hasChars(X){return this.pos+X<=this.buffer.length}setNext(X){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=X,null}peek(X){return this.buffer.substr(this.pos,X)}*parseNext(X){switch(X){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let X=this.getLine();if(X===null)return this.setNext("stream");if(X[0]===Q6.BOM)yield*this.pushCount(1),X=X.substring(1);if(X[0]==="%"){let U=X.length,q=X.indexOf("#");while(q!==-1){let Q=X[q-1];if(Q===" "||Q==="\t"){U=q-1;break}else q=X.indexOf("#",q+1)}while(!0){let Q=X[U-1];if(Q===" "||Q==="\t")U-=1;else break}let Z=(yield*this.pushCount(U))+(yield*this.pushSpaces(!0));return yield*this.pushCount(X.length-Z),this.pushNewline(),"stream"}if(this.atLineEnd()){let U=yield*this.pushSpaces(!0);return yield*this.pushCount(X.length-U),yield*this.pushNewline(),"stream"}return yield Q6.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let X=this.charAt(0);if(!X&&!this.atEnd)return this.setNext("line-start");if(X==="-"||X==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let U=this.peek(3);if((U==="---"||U==="...")&&K0(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,U==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!K0(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[X,U]=this.peek(2);if(!U&&!this.atEnd)return this.setNext("block-start");if((X==="-"||X==="?"||X===":")&&K0(U)){let q=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=q,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let X=this.getLine();if(X===null)return this.setNext("doc");let U=yield*this.pushIndicators();switch(X[U]){case"#":yield*this.pushCount(X.length-U);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(ZU),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return U+=yield*this.parseBlockScalarHeader(),U+=yield*this.pushSpaces(!0),yield*this.pushCount(X.length-U),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let X,U,q=-1;do{if(X=yield*this.pushNewline(),X>0)U=yield*this.pushSpaces(!1),this.indentValue=q=U;else U=0;U+=yield*this.pushSpaces(!0)}while(X+U>0);let Z=this.getLine();if(Z===null)return this.setNext("flow");if(q!==-1&&q<this.indentNext&&Z[0]!=="#"||q===0&&(Z.startsWith("---")||Z.startsWith("..."))&&K0(Z[3])){if(!(q===this.indentNext-1&&this.flowLevel===1&&(Z[0]==="]"||Z[0]==="}")))return this.flowLevel=0,yield Q6.FLOW_END,yield*this.parseLineStart()}let Q=0;while(Z[Q]===",")Q+=yield*this.pushCount(1),Q+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(Q+=yield*this.pushIndicators(),Z[Q]){case void 0:return"flow";case"#":return yield*this.pushCount(Z.length-Q),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(ZU),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let G=this.charAt(1);if(this.flowKey||K0(G)||G===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let X=this.charAt(0),U=this.buffer.indexOf(X,this.pos+1);if(X==="'")while(U!==-1&&this.buffer[U+1]==="'")U=this.buffer.indexOf("'",U+2);else while(U!==-1){let Q=0;while(this.buffer[U-1-Q]==="\\")Q+=1;if(Q%2===0)break;U=this.buffer.indexOf('"',U+1)}let q=this.buffer.substring(0,U),Z=q.indexOf(`
124
124
  `,this.pos);if(Z!==-1){while(Z!==-1){let Q=this.continueScalar(Z+1);if(Q===-1)break;Z=q.indexOf(`
125
- `,Q)}if(Z!==-1)X=Z-(q[Z-1]==="\r"?2:1)}if(X===-1){if(!this.atEnd)return this.setNext("quoted-scalar");X=this.buffer.length}return yield*this.pushToIndex(X+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let U=this.pos;while(!0){let X=this.buffer[++U];if(X==="+")this.blockScalarKeep=!0;else if(X>"0"&&X<="9")this.blockScalarIndent=Number(X)-1;else if(X!=="-")break}return yield*this.pushUntil((X)=>I0(X)||X==="#")}*parseBlockScalar(){let U=this.pos-1,X=0,q;U:for(let Q=this.pos;q=this.buffer[Q];++Q)switch(q){case" ":X+=1;break;case`
126
- `:U=Q,X=0;break;case"\r":{let G=this.buffer[Q+1];if(!G&&!this.atEnd)return this.setNext("block-scalar");if(G===`
127
- `)break}default:break U}if(!q&&!this.atEnd)return this.setNext("block-scalar");if(X>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=X;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let Q=this.continueScalar(U+1);if(Q===-1)break;U=this.buffer.indexOf(`
128
- `,Q)}while(U!==-1);if(U===-1){if(!this.atEnd)return this.setNext("block-scalar");U=this.buffer.length}}let Z=U+1;q=this.buffer[Z];while(q===" ")q=this.buffer[++Z];if(q==="\t"){while(q==="\t"||q===" "||q==="\r"||q===`
129
- `)q=this.buffer[++Z];U=Z-1}else if(!this.blockScalarKeep)do{let Q=U-1,G=this.buffer[Q];if(G==="\r")G=this.buffer[--Q];let Y=Q;while(G===" ")G=this.buffer[--Q];if(G===`
130
- `&&Q>=this.pos&&Q+1+X>Y)U=Q;else break}while(!0);return yield e2.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(I0(Q)||U&&M4.has(Q))break;X=q}else if(I0(Z)){let Q=this.buffer[q+1];if(Z==="\r")if(Q===`
125
+ `,Q)}if(Z!==-1)U=Z-(q[Z-1]==="\r"?2:1)}if(U===-1){if(!this.atEnd)return this.setNext("quoted-scalar");U=this.buffer.length}return yield*this.pushToIndex(U+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let X=this.pos;while(!0){let U=this.buffer[++X];if(U==="+")this.blockScalarKeep=!0;else if(U>"0"&&U<="9")this.blockScalarIndent=Number(U)-1;else if(U!=="-")break}return yield*this.pushUntil((U)=>K0(U)||U==="#")}*parseBlockScalar(){let X=this.pos-1,U=0,q;X:for(let Q=this.pos;q=this.buffer[Q];++Q)switch(q){case" ":U+=1;break;case`
126
+ `:X=Q,U=0;break;case"\r":{let G=this.buffer[Q+1];if(!G&&!this.atEnd)return this.setNext("block-scalar");if(G===`
127
+ `)break}default:break X}if(!q&&!this.atEnd)return this.setNext("block-scalar");if(U>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=U;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let Q=this.continueScalar(X+1);if(Q===-1)break;X=this.buffer.indexOf(`
128
+ `,Q)}while(X!==-1);if(X===-1){if(!this.atEnd)return this.setNext("block-scalar");X=this.buffer.length}}let Z=X+1;q=this.buffer[Z];while(q===" ")q=this.buffer[++Z];if(q==="\t"){while(q==="\t"||q===" "||q==="\r"||q===`
129
+ `)q=this.buffer[++Z];X=Z-1}else if(!this.blockScalarKeep)do{let Q=X-1,G=this.buffer[Q];if(G==="\r")G=this.buffer[--Q];let Y=Q;while(G===" ")G=this.buffer[--Q];if(G===`
130
+ `&&Q>=this.pos&&Q+1+U>Y)X=Q;else break}while(!0);return yield Q6.SCALAR,yield*this.pushToIndex(X+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let X=this.flowLevel>0,U=this.pos-1,q=this.pos-1,Z;while(Z=this.buffer[++q])if(Z===":"){let Q=this.buffer[q+1];if(K0(Q)||X&&K4.has(Q))break;U=q}else if(K0(Z)){let Q=this.buffer[q+1];if(Z==="\r")if(Q===`
131
131
  `)q+=1,Z=`
132
- `,Q=this.buffer[q+1];else X=q;if(Q==="#"||U&&M4.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&&M4.has(Z))break;X=q}if(!Z&&!this.atEnd)return this.setNext("plain-scalar");return yield e2.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(aU))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let U=this.flowLevel>0,X=this.charAt(1);if(I0(X)||U&&M4.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(!I0(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(fF.has(X))X=this.buffer[++U];else if(X==="%"&&TQ.has(this.buffer[U+1])&&TQ.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
- `)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)}}yF.Lexer=OQ});var eU=R((vF)=>{class VQ{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}}}}vF.LineCounter=VQ});var UX=R((mF)=>{var hF=M1("process"),BQ=D4(),uF=tU();function Z1(U,X){for(let q=0;q<U.length;++q)if(U[q].type===X)return!0;return!1}function RQ(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 MQ(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 w4(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 e1(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 DQ(U){if(U.start.type==="flow-seq-start"){for(let X of U.items)if(X.sep&&!X.value&&!Z1(X.start,"explicit-key-ind")&&!Z1(X.sep,"map-value-ind")){if(X.key)X.value=X.key;if(delete X.key,MQ(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 wQ{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 uF.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,hF.env.LOG_TOKENS)console.log("|",BQ.prettyToken(U));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=U.length;return}let X=BQ.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")DQ(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&&RQ(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(RQ(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=w4(this.peek(2)),q=e1(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
- `)+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 H=X.sep[Y];switch(H.type){case"newline":G.push(Y);break;case"space":break;case"comment":if(H.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(Z1(X.start,"newline"))Object.assign(X,{key:null,sep:[this.sourceToken]});else{let G=e1(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(Z1(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(MQ(X.key)&&!Z1(X.sep,"newline")){let G=e1(X.start),Y=X.key,H=X.sep;H.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:H}]})}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(Z1(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&&!Z1(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||Z1(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=w4(q),Q=e1(Z);DQ(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
- `)+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=w4(U),q=e1(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=w4(U),q=e1(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()}}}mF.Parser=wQ});var CQ=R((nF)=>{var PQ=lU(),lF=s2(),U6=r2(),dF=e9(),cF=k(),iF=eU(),IQ=UX();function KQ(U){let X=U.prettyErrors!==!1;return{lineCounter:U.lineCounter||X&&new iF.LineCounter||null,prettyErrors:X}}function oF(U,X={}){let{lineCounter:q,prettyErrors:Z}=KQ(X),Q=new IQ.Parser(q?.addNewLine),G=new PQ.Composer(X),Y=Array.from(G.compose(Q.parse(U)));if(Z&&q)for(let H of Y)H.errors.forEach(U6.prettifyError(U,q)),H.warnings.forEach(U6.prettifyError(U,q));if(Y.length>0)return Y;return Object.assign([],{empty:!0},G.streamInfo())}function NQ(U,X={}){let{lineCounter:q,prettyErrors:Z}=KQ(X),Q=new IQ.Parser(q?.addNewLine),G=new PQ.Composer(X),Y=null;for(let H of G.compose(Q.parse(U),!0,U.length))if(!Y)Y=H;else if(Y.options.logLevel!=="silent"){Y.errors.push(new U6.YAMLParseError(H.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(Z&&q)Y.errors.forEach(U6.prettifyError(U,q)),Y.warnings.forEach(U6.prettifyError(U,q));return Y}function sF(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=NQ(U,q);if(!Q)return null;if(Q.warnings.forEach((G)=>dF.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 rF(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(cF.isDocument(U)&&!Z)return U.toString(q);return new lF.Document(U,Z,q).toString(q)}nF.parse=sF;nF.parseAllDocuments=oF;nF.parseDocument=NQ;nF.stringify=rF});var qX=R((zA)=>{var XA=lU(),qA=s2(),ZA=NU(),XX=r2(),QA=f2(),Q1=k(),GA=e0(),YA=i(),HA=X1(),JA=q1(),WA=D4(),LA=tU(),_A=eU(),$A=UX(),P4=CQ(),SQ=b2();zA.Composer=XA.Composer;zA.Document=qA.Document;zA.Schema=ZA.Schema;zA.YAMLError=XX.YAMLError;zA.YAMLParseError=XX.YAMLParseError;zA.YAMLWarning=XX.YAMLWarning;zA.Alias=QA.Alias;zA.isAlias=Q1.isAlias;zA.isCollection=Q1.isCollection;zA.isDocument=Q1.isDocument;zA.isMap=Q1.isMap;zA.isNode=Q1.isNode;zA.isPair=Q1.isPair;zA.isScalar=Q1.isScalar;zA.isSeq=Q1.isSeq;zA.Pair=GA.Pair;zA.Scalar=YA.Scalar;zA.YAMLMap=HA.YAMLMap;zA.YAMLSeq=JA.YAMLSeq;zA.CST=WA;zA.Lexer=LA.Lexer;zA.LineCounter=_A.LineCounter;zA.Parser=$A.Parser;zA.parse=P4.parse;zA.parseAllDocuments=P4.parseAllDocuments;zA.parseDocument=P4.parseDocument;zA.stringify=P4.stringify;zA.visit=SQ.visit;zA.visitAsync=SQ.visitAsync});class Z0{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|globals|request|computed)(\.[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||!(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 xQ{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 I4{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 hQ{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 K0{static instance;state;persistence;constructor(){this.state=new Map,this.persistence=new I4}static getInstance(){if(!K0.instance)K0.instance=new K0;return K0.instance}setPersistence(U){this.persistence=U}async initialize(){let U=await this.persistence.loadState();this.state=U,console.log(`[StateManager] Initialized with ${this.state.size} keys.`)}get(U){return this.state.get(U)}async set(U,X){this.state.set(U,X),await this.persistence.saveState(U,X)}async increment(U,X=1){let q=this.get(U)||0,Z=Number(q)+X;return await this.set(U,Z),Z}async decrement(U,X=1){return this.increment(U,-X)}async delete(U){let X=this.state.delete(U);if(X)await this.persistence.deleteState(U);return X}async clear(){this.state.clear(),await this.persistence.clearState()}getAll(){return Object.fromEntries(this.state)}}class q6{static instance;handlers=new Map;constructor(){this.registerDefaults()}static getInstance(){if(!this.instance)this.instance=new q6;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=Z0.interpolate(q,X);return console.log(`[TriggerLog] ${Z}`),{message:Z}}),this.register("response",(U,X)=>{let q=U.params?.content||U.params?.body||"",Z=Z0.interpolate(q,X);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=Z0.interpolate(q,X);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=Z0.interpolate(q,X),Q=U.params?.method||"POST";try{let G=await fetch(Z,{method:Q,headers:{"Content-Type":"application/json",...U.params?.headers},body:JSON.stringify(X.data)});return{url:Z,method:Q,status:G.status,headers:(()=>{let Y={};return G.headers.forEach((H,J)=>Y[J]=H),Y})(),body:await G.text()}}catch(G){return{url:Z,method:Q,error:String(G)}}}),this.register("STATE_SET",async(U,X)=>{let q=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=Z0.interpolate(Z,X);return await K0.getInstance().set(q,Q),{key:q,value:Q}}),this.register("STATE_INCREMENT",async(U,X)=>{let q=U.params?.key,Z=Number(U.params?.amount)||1;if(!q)return{error:"Missing key for STATE_INCREMENT"};let Q=await K0.getInstance().increment(q,Z);return{key:q,newValue:Q}}),this.register("EMIT_EVENT",(U,X)=>{return{event:U.params?.event,payload:U.params?.data||{}}})}}class uQ{static create(U,X,q={}){return{event:U,timestamp:Date.now(),data:typeof X==="object"?X:{value:X},globals:q,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||{}},globals:{...q,ip:U.headers.get("x-forwarded-for")||"unknown"},helpers:this.getDefaultHelpers()}}static fromWebhook(U,X,q,Z={}){return{event:`WEBHOOK_${U.toUpperCase()}_${X.toUpperCase()}`,timestamp:Date.now(),data:q,globals:{...Z,provider:U},helpers:this.getDefaultHelpers()}}static getDefaultHelpers(){return{now:()=>Date.now(),uuid:()=>crypto.randomUUID(),jsonParse:(U)=>JSON.parse(U),jsonStringify:(U)=>JSON.stringify(U)}}}var K4;((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"})(K4||={});var JT=K4;class N4{static instance;handlers=new Map;constructor(){}static getInstance(){if(!this.instance)this.instance=new N4;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 w1=N4.getInstance();class mQ{rules=[];config;lastExecutionTimes=new Map;actionRegistry;constructor(U){this.config=U,this.rules=[...U.rules],this.rules.sort((X,q)=>(q.priority||0)-(X.priority||0)),this.actionRegistry=q6.getInstance()}async processEvent(U,X={},q={}){let Z={event:U,data:X,globals:q,timestamp:Date.now(),state:{}};return this.evaluateContext(Z)}async evaluateContext(U){let X=[];if(U.state=K0.getInstance().getAll(),this.config.globalSettings.debugMode)console.log(`[RuleEngine] Evaluando contexto con ${this.rules.length} reglas para evento: ${U.event}`);w1.emit("engine:start",{context:U,rulesCount:this.rules.length});for(let q of this.rules){if(q.enabled===!1)continue;if(q.on!==U.event)continue;if(q.cooldown&&!this.checkCooldown(q.id,q.cooldown)){if(this.config.globalSettings.debugMode)console.log(`[RuleEngine] Regla ${q.id} en cooldown`);continue}if(this.evaluateRuleConditions(q.if,U)){if(this.config.globalSettings.debugMode)console.log(`[RuleEngine] Ejecutando regla: ${q.name||q.id}`);w1.emit("rule:match",{rule:q,context:U});let Q=await this.executeRuleActions(q.do,U);if(X.push({ruleId:q.id,executedActions:Q,success:!0}),this.lastExecutionTimes.set(q.id,Date.now()),!this.config.globalSettings.evaluateAll)break}}return w1.emit("engine:done",{results:X,context:U}),X}evaluateRuleConditions(U,X){if(!U)return!0;if(Array.isArray(U))return U.every((q)=>this.evaluateRecursiveCondition(q,X));else return this.evaluateRecursiveCondition(U,X)}evaluateRecursiveCondition(U,X){if("conditions"in U&&"operator"in U)return this.evaluateConditionGroup(U,X);else return this.evaluateSingleCondition(U,X)}evaluateConditionGroup(U,X){if(U.operator==="OR")return U.conditions.some((q)=>this.evaluateRecursiveCondition(q,X));else return U.conditions.every((q)=>this.evaluateRecursiveCondition(q,X))}evaluateSingleCondition(U,X){try{let q=Z0.getNestedValue(U.field,X),Z=U.value;if(typeof Z==="string"&&(Z.includes("${")||Z.startsWith("data.")||Z.startsWith("globals.")))Z=Z0.evaluate(Z,X);let Q=(Y)=>{if(Y instanceof Date)return Y.getTime();if(typeof Y==="number")return Y;let H=new Date(Y);return isNaN(H.getTime())?0:H.getTime()},G=(Y)=>{if(typeof Y==="number")return Y;if(Y===null||Y===void 0||Y==="")return null;let H=Number(Y);return isNaN(H)?null:H};switch(U.operator){case"EQ":case"==":return q==Z;case"NEQ":case"!=":return q!=Z;case"GT":case">":{let Y=G(q),H=G(Z);return Y!==null&&H!==null&&Y>H}case"GTE":case">=":{let Y=G(q),H=G(Z);return Y!==null&&H!==null&&Y>=H}case"LT":case"<":{let Y=G(q),H=G(Z);return Y!==null&&H!==null&&Y<H}case"LTE":case"<=":{let Y=G(q),H=G(Z);return Y!==null&&H!==null&&Y<=H}case"CONTAINS":return String(q).includes(String(Z));case"MATCHES":return new RegExp(String(Z)).test(String(q));case"IN":return Array.isArray(Z)&&Z.includes(q);case"NOT_IN":return Array.isArray(Z)&&!Z.includes(q);case"SINCE":case"AFTER":return Q(q)>=Q(Z);case"BEFORE":case"UNTIL":return Q(q)<Q(Z);case"RANGE":if(Array.isArray(Z)&&Z.length===2){let Y=G(q);return Y!==null&&Y>=Number(Z[0])&&Y<=Number(Z[1])}return!1;default:return console.error(`Operador desconocido: ${U.operator}`),!1}}catch(q){return console.error("Error evaluando condición:",U,q),!1}}async executeRuleActions(U,X){let q=[],Z=[],Q="ALL";if(this.isActionGroup(U))Z=U.actions,Q=U.mode;else if(Array.isArray(U))Z=U;else Z=[U];if(Q==="EITHER"&&Z.length>0){let G=Math.floor(Math.random()*Z.length),Y=Z[G];if(Y)Z=[Y]}if(Q==="SEQUENCE")for(let G of Z){let Y=await this.executeSingleAction(G,X);q.push(Y)}else for(let G of Z){let Y=await this.executeSingleAction(G,X);q.push(Y)}return q}isActionGroup(U){return"mode"in U&&"actions"in U}async executeSingleAction(U,X){if(U.probability!==void 0&&Math.random()>U.probability)return{type:U.type,timestamp:Date.now(),result:{skipped:"probability check failed"}};if(U.delay&&U.delay>0)await new Promise((q)=>setTimeout(q,U.delay));try{let q=this.actionRegistry.get(U.type),Z;if(q)Z=await q(U,X);else{let Q=`Tipo de acción genérica o desconocida: ${U.type}`;if(this.config.globalSettings.strictActions)throw Error(Q);console.warn(Q),Z={warning:`Generic action executed: ${U.type}`}}return w1.emit("action:success",{action:U,context:X,result:Z}),{type:U.type,result:Z,timestamp:Date.now()}}catch(q){return console.error("Error ejecutando acción:",U,q),w1.emit("action:error",{action:U,context:X,error:String(q)}),{type:U.type,error:String(q),timestamp:Date.now()}}}checkCooldown(U,X){let q=this.lastExecutionTimes.get(U);if(!q)return!0;return Date.now()-q>X}updateRules(U){this.rules=[...U],this.rules.sort((X,q)=>(q.priority||0)-(X.priority||0))}getRules(){return[...this.rules]}}class Z6{static getNestedValue(U,X){let q=U.split("."),Z=X;for(let Q of q){if(Z===null||Z===void 0)return;Z=Z[Q]}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.includes(U);case"NOT_IN":return Array.isArray(q)&&!q.includes(U);case"CONTAINS":if(Array.isArray(U)||typeof U==="string")return U.includes(q);return!1;case"MATCHES":return new RegExp(q).test(String(U));case"RANGE":if(Array.isArray(q)&&q.length===2){let Z=Number(U);return Z>=q[0]&&Z<=q[1]}return!1;default:return console.warn(`Unknown operator: ${X}`),!1}}}class pQ{rules=[];actionHandlers=new Map;lastExecution=new Map;constructor(U=[]){this.rules=U,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=[],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);this.lastExecution.set(Z.id,Date.now()),X.push({ruleId:Z.id,success:!0,executedActions:Q})}}return X}checkCooldown(U,X){let q=this.lastExecution.get(U);if(!q)return!1;return Date.now()-q<X}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=Z6.getNestedValue(q.field,X),Q=q.value;if(typeof Q==="string"&&Q.includes("${"))Q=Z0.interpolate(Q,X);return Z6.compare(Z,q.operator,Q)}async executeRuleActions(U,X){let q=[],Z=[],Q="ALL";if(Array.isArray(U))Z=U;else if("mode"in U&&"actions"in U){let G=U;Q=G.mode,Z=G.actions}else Z=[U];if(Q==="EITHER"){let G=Z.reduce((J,W)=>J+(W.probability||1),0),Y=Math.random()*G,H;for(let J of Z){let W=J.probability||1;if(Y-=W,Y<=0){H=J;break}}if(!H&&Z.length>0)H=Z[Z.length-1];if(H)Z=[H];else Z=[]}for(let G of Z){let Y=this.interpolateParams(G.params||{},X),H=this.actionHandlers.get(G.type);if(H)try{if(G.delay&&G.delay>0)await new Promise((W)=>setTimeout(W,G.delay));let J=await H(Y,X);q.push({type:G.type,result:J,timestamp:Date.now()})}catch(J){console.error(`Action ${G.type} failed:`,J),q.push({type:G.type,error:J,timestamp:Date.now()})}else console.warn(`No handler registered for action type: ${G.type}`),q.push({type:G.type,error:"No handler registered",timestamp:Date.now()})}return q}interpolateParams(U,X){let q={};for(let[Z,Q]of Object.entries(U))if(typeof Q==="string")q[Z]=Z0.interpolate(Q,X);else if(typeof Q==="object"&&Q!==null)q[Z]=this.interpolateDeep(Q,X);else q[Z]=Q;return q}interpolateDeep(U,X){if(typeof U==="string")return Z0.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}}var p0=(U)=>Array.isArray(U)?U:[U],GX=(U,X)=>{let q=[[],[]];for(let Z of U)if(X(Z))q[0].push(Z);else q[1].push(Z);return q},Q6=Array,z0=(U,X)=>U.includes(X),YX=(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},f0=(U,X)=>{if(X===void 0||X===null)return U??[];if(U===void 0||U===null)return p0(X);return U.concat(X)},HX=(...U)=>U.reduce(f0,[]),N0=(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 p0(X))if(!U.some((G)=>Z(G,Q)))U.push(Q);return U},JX=(U,X)=>U.reduce((q,Z)=>{let Q=Z[X];return q[Q]=g(q[Q],Z),q},{}),g0=(U,X,q)=>U.length===X.length&&U.every(q?.isEqual?(Z,Q)=>q.isEqual(Z,X[Q]):(Z,Q)=>Z===X[Q]);var Q0=(U,X)=>r(U)===X,r=(U)=>{let X=typeof U;return X==="object"?U===null?"null":"object":X==="function"?"object":X},G0={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},WX={...G0,function:"a function"};class LX extends Error{}var y=(U)=>G1(U,LX),G1=(U,X=Error)=>{throw new X(U)};class X2 extends Error{name="ParseError"}var F=(U)=>G1(U,X2),R0=(U)=>` ${U}`,_X="​";var S=(U,X)=>{let q={},Z=Array.isArray(U),Q=!1;for(let[G,Y]of Object.entries(U).entries()){let H=Z?X(G,Y[1]):X(...Y,G);Q||=typeof H[0]==="number";let J=Array.isArray(H[0])||H.length===0?H:[H];for(let[W,_]of J)if(typeof W==="object")q[W.group]=g(q[W.group],_);else q[W]=_}return Q?Object.values(q):q};var C4=Object.entries;var n=(U,X)=>(U in X),P1=(U,X)=>(X in U);class S4{constructor(U){Object.assign(this,U)}}var $X=class{};class q2 extends $X{}var lQ=(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 G6=(U,X)=>lQ(U,X)[1],C0=(U)=>Object.keys(U).length===0,Y1=(U)=>[...Object.entries(U),...Object.getOwnPropertySymbols(U).map((X)=>[X,U[X]])],zX=(U,X)=>Object.defineProperties(U,Object.getOwnPropertyDescriptors(X)),FX=(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 Y0=R0(`unset${_X}`),AX=(U)=>Object.values(U).filter((X)=>{if(typeof X==="number")return!0;return typeof U[X]!=="number"});var E4={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},b4=globalThis.File??Blob,j4={ArrayBuffer,Blob,File:b4,FormData,Headers,Request,Response,URL},dQ={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},H1={...E4,...j4,...dQ,String,Number,Boolean},Z2=(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},Q2=(U)=>typeof U==="object"&&U!==null?Z2(U)??"object":r(U);var x=Array.isArray,cQ={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"},iQ={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"},oQ={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"},TX={...cQ,...iQ,...oQ},G2=(U)=>{let X=Object(U).name??null;return X&&n(X,H1)&&H1[X]===U?X:null};var f4=(U,X)=>{let q=U.prototype;while(q!==null){if(q===X.prototype)return!0;q=Object.getPrototypeOf(q)}return!1};var OX=(U)=>VX(U,new Map),VX=(U,X)=>{if(typeof U!=="object"||U===null)return U;if(X?.has(U))return X.get(U);let q=G2(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=VX(Y.value,X)}}return Object.defineProperties(Z,Q),Z};var sQ=(U)=>{let X=Y0;return()=>X===Y0?X=U():X},l0=(U)=>typeof U==="function"&&U.length===0;var BX=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:
132
+ `,Q=this.buffer[q+1];else U=q;if(Q==="#"||X&&K4.has(Q))break;if(Z===`
133
+ `){let G=this.continueScalar(q+1);if(G===-1)break;q=Math.max(q,G-2)}}else{if(X&&K4.has(Z))break;U=q}if(!Z&&!this.atEnd)return this.setNext("plain-scalar");return yield Q6.SCALAR,yield*this.pushToIndex(U+1,!0),X?"flow":"doc"}*pushCount(X){if(X>0)return yield this.buffer.substr(this.pos,X),this.pos+=X,X;return 0}*pushToIndex(X,U){let q=this.buffer.slice(this.pos,X);if(q)return yield q,this.pos+=q.length,q.length;else if(U)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(ZU))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let X=this.flowLevel>0,U=this.charAt(1);if(K0(U)||X&&K4.has(U)){if(!X)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 X=this.pos+2,U=this.buffer[X];while(!K0(U)&&U!==">")U=this.buffer[++X];return yield*this.pushToIndex(U===">"?X+1:X,!1)}else{let X=this.pos+1,U=this.buffer[X];while(U)if(hF.has(U))U=this.buffer[++X];else if(U==="%"&&wQ.has(this.buffer[X+1])&&wQ.has(this.buffer[X+2]))U=this.buffer[X+=3];else break;return yield*this.pushToIndex(X,!1)}}*pushNewline(){let X=this.buffer[this.pos];if(X===`
134
+ `)return yield*this.pushCount(1);else if(X==="\r"&&this.charAt(1)===`
135
+ `)return yield*this.pushCount(2);else return 0}*pushSpaces(X){let U=this.pos-1,q;do q=this.buffer[++U];while(q===" "||X&&q==="\t");let Z=U-this.pos;if(Z>0)yield this.buffer.substr(this.pos,Z),this.pos=U;return Z}*pushUntil(X){let U=this.pos,q=this.buffer[U];while(!X(q))q=this.buffer[++U];return yield*this.pushToIndex(U,!1)}}mF.Lexer=PQ});var GU=R((lF)=>{class IQ{constructor(){this.lineStarts=[],this.addNewLine=(X)=>this.lineStarts.push(X),this.linePos=(X)=>{let U=0,q=this.lineStarts.length;while(U<q){let Q=U+q>>1;if(this.lineStarts[Q]<X)U=Q+1;else q=Q}if(this.lineStarts[U]===X)return{line:U+1,col:1};if(U===0)return{line:0,col:X};let Z=this.lineStarts[U-1];return{line:U,col:X-Z+1}}}}lF.LineCounter=IQ});var YU=R((sF)=>{var cF=w1("process"),KQ=I4(),iF=QU();function Z1(X,U){for(let q=0;q<X.length;++q)if(X[q].type===U)return!0;return!1}function NQ(X){for(let U=0;U<X.length;++U)switch(X[U].type){case"space":case"comment":case"newline":break;default:return U}return-1}function SQ(X){switch(X?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function N4(X){switch(X.type){case"document":return X.start;case"block-map":{let U=X.items[X.items.length-1];return U.sep??U.start}case"block-seq":return X.items[X.items.length-1].start;default:return[]}}function X2(X){if(X.length===0)return[];let U=X.length;X:while(--U>=0)switch(X[U].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break X}while(X[++U]?.type==="space");return X.splice(U,X.length)}function CQ(X){if(X.start.type==="flow-seq-start"){for(let U of X.items)if(U.sep&&!U.value&&!Z1(U.start,"explicit-key-ind")&&!Z1(U.sep,"map-value-ind")){if(U.key)U.value=U.key;if(delete U.key,SQ(U.value))if(U.value.end)Array.prototype.push.apply(U.value.end,U.sep);else U.value.end=U.sep;else Array.prototype.push.apply(U.start,U.sep);delete U.sep}}}class EQ{constructor(X){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new iF.Lexer,this.onNewLine=X}*parse(X,U=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let q of this.lexer.lex(X,U))yield*this.next(q);if(!U)yield*this.end()}*next(X){if(this.source=X,cF.env.LOG_TOKENS)console.log("|",KQ.prettyToken(X));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=X.length;return}let U=KQ.tokenType(X);if(!U){let q=`Not a YAML token: ${X}`;yield*this.pop({type:"error",offset:this.offset,message:q,source:X}),this.offset+=X.length}else if(U==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=U,yield*this.step(),U){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+X.length);break;case"space":if(this.atNewLine&&X[0]===" ")this.indent+=X.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=X.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=X.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 X=this.peek(1);if(this.type==="doc-end"&&X?.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(!X)return yield*this.stream();switch(X.type){case"document":return yield*this.document(X);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(X);case"block-scalar":return yield*this.blockScalar(X);case"block-map":return yield*this.blockMap(X);case"block-seq":return yield*this.blockSequence(X);case"flow-collection":return yield*this.flowCollection(X);case"doc-end":return yield*this.documentEnd(X)}yield*this.pop()}peek(X){return this.stack[this.stack.length-X]}*pop(X){let U=X??this.stack.pop();if(!U)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield U;else{let q=this.peek(1);if(U.type==="block-scalar")U.indent="indent"in q?q.indent:0;else if(U.type==="flow-collection"&&q.type==="document")U.indent=0;if(U.type==="flow-collection")CQ(U);switch(q.type){case"document":q.value=U;break;case"block-scalar":q.props.push(U);break;case"block-map":{let Z=q.items[q.items.length-1];if(Z.value){q.items.push({start:[],key:U,sep:[]}),this.onKeyLine=!0;return}else if(Z.sep)Z.value=U;else{Object.assign(Z,{key:U,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:U});else Z.value=U;break}case"flow-collection":{let Z=q.items[q.items.length-1];if(!Z||Z.value)q.items.push({start:[],key:U,sep:[]});else if(Z.sep)Z.value=U;else Object.assign(Z,{key:U,sep:[]});return}default:yield*this.pop(),yield*this.pop(U)}if((q.type==="document"||q.type==="block-map"||q.type==="block-seq")&&(U.type==="block-map"||U.type==="block-seq")){let Z=U.items[U.items.length-1];if(Z&&!Z.sep&&!Z.value&&Z.start.length>0&&NQ(Z.start)===-1&&(U.indent===0||Z.start.every((Q)=>Q.type!=="comment"||Q.indent<U.indent))){if(q.type==="document")q.end=Z.start;else q.items.push({start:Z.start});U.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 X={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")X.start.push(this.sourceToken);this.stack.push(X);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(X){if(X.value)return yield*this.lineEnd(X);switch(this.type){case"doc-start":{if(NQ(X.start)!==-1)yield*this.pop(),yield*this.step();else X.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":X.start.push(this.sourceToken);return}let U=this.startBlockValue(X);if(U)this.stack.push(U);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(X){if(this.type==="map-value-ind"){let U=N4(this.peek(2)),q=X2(U),Z;if(X.end)Z=X.end,Z.push(this.sourceToken),delete X.end;else Z=[this.sourceToken];let Q={type:"block-map",offset:X.offset,indent:X.indent,items:[{start:q,key:X,sep:Z}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=Q}else yield*this.lineEnd(X)}*blockScalar(X){switch(this.type){case"space":case"comment":case"newline":X.props.push(this.sourceToken);return;case"scalar":if(X.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let U=this.source.indexOf(`
136
+ `)+1;while(U!==0)this.onNewLine(this.offset+U),U=this.source.indexOf(`
137
+ `,U)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(X){let U=X.items[X.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,U.value){let q="end"in U.value?U.value.end:void 0;if((Array.isArray(q)?q[q.length-1]:void 0)?.type==="comment")q?.push(this.sourceToken);else X.items.push({start:[this.sourceToken]})}else if(U.sep)U.sep.push(this.sourceToken);else U.start.push(this.sourceToken);return;case"space":case"comment":if(U.value)X.items.push({start:[this.sourceToken]});else if(U.sep)U.sep.push(this.sourceToken);else{if(this.atIndentedComment(U.start,X.indent)){let Z=X.items[X.items.length-2]?.value?.end;if(Array.isArray(Z)){Array.prototype.push.apply(Z,U.start),Z.push(this.sourceToken),X.items.pop();return}}U.start.push(this.sourceToken)}return}if(this.indent>=X.indent){let q=!this.onKeyLine&&this.indent===X.indent,Z=q&&(U.sep||U.explicitKey)&&this.type!=="seq-item-ind",Q=[];if(Z&&U.sep&&!U.value){let G=[];for(let Y=0;Y<U.sep.length;++Y){let H=U.sep[Y];switch(H.type){case"newline":G.push(Y);break;case"space":break;case"comment":if(H.indent>X.indent)G.length=0;break;default:G.length=0}}if(G.length>=2)Q=U.sep.splice(G[1])}switch(this.type){case"anchor":case"tag":if(Z||U.value)Q.push(this.sourceToken),X.items.push({start:Q}),this.onKeyLine=!0;else if(U.sep)U.sep.push(this.sourceToken);else U.start.push(this.sourceToken);return;case"explicit-key-ind":if(!U.sep&&!U.explicitKey)U.start.push(this.sourceToken),U.explicitKey=!0;else if(Z||U.value)Q.push(this.sourceToken),X.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(U.explicitKey)if(!U.sep)if(Z1(U.start,"newline"))Object.assign(U,{key:null,sep:[this.sourceToken]});else{let G=X2(U.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:null,sep:[this.sourceToken]}]})}else if(U.value)X.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Z1(U.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(SQ(U.key)&&!Z1(U.sep,"newline")){let G=X2(U.start),Y=U.key,H=U.sep;H.push(this.sourceToken),delete U.key,delete U.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:Y,sep:H}]})}else if(Q.length>0)U.sep=U.sep.concat(Q,this.sourceToken);else U.sep.push(this.sourceToken);else if(!U.sep)Object.assign(U,{key:null,sep:[this.sourceToken]});else if(U.value||Z)X.items.push({start:Q,key:null,sep:[this.sourceToken]});else if(Z1(U.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else U.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||U.value)X.items.push({start:Q,key:G,sep:[]}),this.onKeyLine=!0;else if(U.sep)this.stack.push(G);else Object.assign(U,{key:G,sep:[]}),this.onKeyLine=!0;return}default:{let G=this.startBlockValue(X);if(G){if(G.type==="block-seq"){if(!U.explicitKey&&U.sep&&!Z1(U.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)X.items.push({start:Q});this.stack.push(G);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(X){let U=X.items[X.items.length-1];switch(this.type){case"newline":if(U.value){let q="end"in U.value?U.value.end:void 0;if((Array.isArray(q)?q[q.length-1]:void 0)?.type==="comment")q?.push(this.sourceToken);else X.items.push({start:[this.sourceToken]})}else U.start.push(this.sourceToken);return;case"space":case"comment":if(U.value)X.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(U.start,X.indent)){let Z=X.items[X.items.length-2]?.value?.end;if(Array.isArray(Z)){Array.prototype.push.apply(Z,U.start),Z.push(this.sourceToken),X.items.pop();return}}U.start.push(this.sourceToken)}return;case"anchor":case"tag":if(U.value||this.indent<=X.indent)break;U.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==X.indent)break;if(U.value||Z1(U.start,"seq-item-ind"))X.items.push({start:[this.sourceToken]});else U.start.push(this.sourceToken);return}if(this.indent>X.indent){let q=this.startBlockValue(X);if(q){this.stack.push(q);return}}yield*this.pop(),yield*this.step()}*flowCollection(X){let U=X.items[X.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(X.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!U||U.sep)X.items.push({start:[this.sourceToken]});else U.start.push(this.sourceToken);return;case"map-value-ind":if(!U||U.value)X.items.push({start:[],key:null,sep:[this.sourceToken]});else if(U.sep)U.sep.push(this.sourceToken);else Object.assign(U,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!U||U.value)X.items.push({start:[this.sourceToken]});else if(U.sep)U.sep.push(this.sourceToken);else U.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let Z=this.flowScalar(this.type);if(!U||U.value)X.items.push({start:[],key:Z,sep:[]});else if(U.sep)this.stack.push(Z);else Object.assign(U,{key:Z,sep:[]});return}case"flow-map-end":case"flow-seq-end":X.end.push(this.sourceToken);return}let q=this.startBlockValue(X);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===X.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=N4(q),Q=X2(Z);CQ(X);let G=X.end.splice(1,X.end.length);G.push(this.sourceToken);let Y={type:"block-map",offset:X.offset,indent:X.indent,items:[{start:Q,key:X,sep:G}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=Y}else yield*this.lineEnd(X)}}flowScalar(X){if(this.onNewLine){let U=this.source.indexOf(`
138
+ `)+1;while(U!==0)this.onNewLine(this.offset+U),U=this.source.indexOf(`
139
+ `,U)+1}return{type:X,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(X){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 U=N4(X),q=X2(U);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 U=N4(X),q=X2(U);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(X,U){if(this.type!=="comment")return!1;if(this.indent<=U)return!1;return X.every((q)=>q.type==="newline"||q.type==="space")}*documentEnd(X){if(this.type!=="doc-mode"){if(X.end)X.end.push(this.sourceToken);else X.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(X){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(X.end)X.end.push(this.sourceToken);else X.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}sF.Parser=EQ});var gQ=R((qA)=>{var bQ=rX(),rF=e2(),G6=X6(),aF=GX(),nF=k(),tF=GU(),jQ=YU();function fQ(X){let U=X.prettyErrors!==!1;return{lineCounter:X.lineCounter||U&&new tF.LineCounter||null,prettyErrors:U}}function eF(X,U={}){let{lineCounter:q,prettyErrors:Z}=fQ(U),Q=new jQ.Parser(q?.addNewLine),G=new bQ.Composer(U),Y=Array.from(G.compose(Q.parse(X)));if(Z&&q)for(let H of Y)H.errors.forEach(G6.prettifyError(X,q)),H.warnings.forEach(G6.prettifyError(X,q));if(Y.length>0)return Y;return Object.assign([],{empty:!0},G.streamInfo())}function yQ(X,U={}){let{lineCounter:q,prettyErrors:Z}=fQ(U),Q=new jQ.Parser(q?.addNewLine),G=new bQ.Composer(U),Y=null;for(let H of G.compose(Q.parse(X),!0,X.length))if(!Y)Y=H;else if(Y.options.logLevel!=="silent"){Y.errors.push(new G6.YAMLParseError(H.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(Z&&q)Y.errors.forEach(G6.prettifyError(X,q)),Y.warnings.forEach(G6.prettifyError(X,q));return Y}function XA(X,U,q){let Z=void 0;if(typeof U==="function")Z=U;else if(q===void 0&&U&&typeof U==="object")q=U;let Q=yQ(X,q);if(!Q)return null;if(Q.warnings.forEach((G)=>aF.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 UA(X,U,q){let Z=null;if(typeof U==="function"||Array.isArray(U))Z=U;else if(q===void 0&&U)q=U;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(X===void 0){let{keepUndefined:Q}=q??U??{};if(!Q)return}if(nF.isDocument(X)&&!Z)return X.toString(q);return new rF.Document(X,Z,q).toString(q)}qA.parse=XA;qA.parseAllDocuments=eF;qA.parseDocument=yQ;qA.stringify=UA});var JU=R((TA)=>{var HA=rX(),JA=e2(),WA=fX(),HU=X6(),_A=x2(),Q1=k(),$A=e0(),LA=i(),zA=U1(),FA=q1(),AA=I4(),VA=QU(),OA=GU(),BA=YU(),C4=gQ(),kQ=k2();TA.Composer=HA.Composer;TA.Document=JA.Document;TA.Schema=WA.Schema;TA.YAMLError=HU.YAMLError;TA.YAMLParseError=HU.YAMLParseError;TA.YAMLWarning=HU.YAMLWarning;TA.Alias=_A.Alias;TA.isAlias=Q1.isAlias;TA.isCollection=Q1.isCollection;TA.isDocument=Q1.isDocument;TA.isMap=Q1.isMap;TA.isNode=Q1.isNode;TA.isPair=Q1.isPair;TA.isScalar=Q1.isScalar;TA.isSeq=Q1.isSeq;TA.Pair=$A.Pair;TA.Scalar=LA.Scalar;TA.YAMLMap=zA.YAMLMap;TA.YAMLSeq=FA.YAMLSeq;TA.CST=AA;TA.Lexer=VA.Lexer;TA.LineCounter=OA.LineCounter;TA.Parser=BA.Parser;TA.parse=C4.parse;TA.parseAllDocuments=C4.parseAllDocuments;TA.parseDocument=C4.parseDocument;TA.stringify=C4.stringify;TA.visit=kQ.visit;TA.visitAsync=kQ.visitAsync});class iQ{queue=[];engine;config;timer=null;isProcessing=!1;constructor(X,U={maxBatchSize:10,flushIntervalMs:100}){this.engine=X,this.config=U}push(X){if(this.queue.push(X),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 X=this.queue.splice(0,this.config.maxBatchSize);if(X.length===0){this.isProcessing=!1;return}console.debug(`[EventQueue] Processing batch of ${X.length} events.`);for(let U of X)try{await this.engine.evaluateContext(U)}catch(q){console.error(`[EventQueue] Error processing event ${U.event}:`,q)}if(this.queue.length>0)setTimeout(()=>this.processQueue(),0);this.isProcessing=!1}getQueueLength(){return this.queue.length}}class sQ{keyPrefix;cache=new Map;isLoaded=!1;constructor(X="trigger_system:"){this.keyPrefix=X}isAvailable(){return typeof window<"u"&&typeof window.localStorage<"u"}ensureLoaded(){if(this.isLoaded)return;if(this.isAvailable())try{let X=window.localStorage.getItem(this.keyPrefix+"state");if(X){let U=JSON.parse(X);this.cache=new Map(Object.entries(U))}}catch(X){console.error("[BrowserPersistence] Failed to load from localStorage:",X)}this.isLoaded=!0}persist(){if(this.isAvailable())try{let X=Object.fromEntries(this.cache);window.localStorage.setItem(this.keyPrefix+"state",JSON.stringify(X))}catch(X){console.error("[BrowserPersistence] Failed to save to localStorage:",X)}}async loadState(){return this.ensureLoaded(),new Map(this.cache)}async saveState(X,U){this.ensureLoaded(),this.cache.set(X,U),this.persist()}async deleteState(X){this.ensureLoaded(),this.cache.delete(X),this.persist()}async clearState(){this.cache.clear(),this.persist()}}class q2{static getNestedValue(X,U){let q=X.split("."),Z=U;for(let Q of q){if(Z===null||Z===void 0)return;Z=Z[Q]}return Z}static interpolate(X,U){if(typeof X!=="string")return X;return X.replace(/\$\{([^}]+)\}/g,(q,Z)=>{let Q=this.getNestedValue(Z,U);if(Q!==void 0)return String(Q);return q})}static compare(X,U,q){switch(U){case"EQ":case"==":return X==q;case"NEQ":case"!=":return X!=q;case"GT":case">":return Number(X)>Number(q);case"GTE":case">=":return Number(X)>=Number(q);case"LT":case"<":return Number(X)<Number(q);case"LTE":case"<=":return Number(X)<=Number(q);case"IN":return Array.isArray(q)&&q.includes(X);case"NOT_IN":return Array.isArray(q)&&!q.includes(X);case"CONTAINS":if(Array.isArray(X)||typeof X==="string")return X.includes(q);return!1;case"MATCHES":return new RegExp(q).test(String(X));case"RANGE":if(Array.isArray(q)&&q.length===2){let Z=Number(X);return Z>=q[0]&&Z<=q[1]}return!1;default:return console.warn(`Unknown operator: ${U}`),!1}}}class G2{_rules=[];actionHandlers=new Map;lastExecution=new Map;_config;constructor(X=[]){if(Array.isArray(X))this._rules=X;else this._config=X,this._rules=[...X.rules];this.sortRules()}sortRules(){this._rules.sort((X,U)=>(U.priority||0)-(X.priority||0))}registerAction(X,U){this.actionHandlers.set(X,U)}async processEvent(X){let U=[],q=this._rules.filter((Z)=>Z.enabled!==!1&&Z.on===X.event);for(let Z of q){if(Z.cooldown&&this.checkCooldown(Z.id,Z.cooldown))continue;if(this.evaluateConditions(Z.if,X)){let Q=await this.executeRuleActions(Z.do,X);if(this.lastExecution.set(Z.id,Date.now()),U.push({ruleId:Z.id,success:!0,executedActions:Q}),!this.shouldEvaluateAll())break}}return U}async processEventSimple(X,U={},q={}){let Z={event:X,data:U,globals:q,timestamp:Date.now(),state:this.getStateContext?this.getStateContext():{}};return this.processEvent(Z)}updateRules(X){this.rules=[...X],this.sortRules()}getRules(){return[...this.rules]}checkCooldown(X,U){let q=this.lastExecution.get(X);if(!q)return!1;return Date.now()-q<U}shouldEvaluateAll(){return this.config?.globalSettings?.evaluateAll??!0}getStateContext(){return{}}evaluateConditions(X,U){if(!X)return!0;if(Array.isArray(X))return X.every((q)=>this.evaluateSingleCondition(q,U));return this.evaluateSingleCondition(X,U)}evaluateSingleCondition(X,U){if("operator"in X&&"conditions"in X){let G=X;if(G.operator==="OR")return G.conditions.some((Y)=>this.evaluateSingleCondition(Y,U));else return G.conditions.every((Y)=>this.evaluateSingleCondition(Y,U))}let q=X,Z=q2.getNestedValue(q.field,U),Q=q.value;if(typeof Q==="string"&&Q.includes("${"))Q=$0.interpolate(Q,U);return q2.compare(Z,q.operator,Q)}async executeRuleActions(X,U){let q=[],Z=[],Q="ALL";if(Array.isArray(X))Z=X;else if("mode"in X&&"actions"in X){let G=X;Q=G.mode,Z=G.actions}else Z=[X];if(Q==="EITHER"&&Z.length>0){let G=Z.reduce((J,W)=>J+(W.probability||1),0),Y=Math.random()*G,H;for(let J of Z){let W=J.probability||1;if(Y-=W,Y<=0){H=J;break}}if(!H&&Z.length>0)H=Z[Z.length-1];if(H)Z=[H];else Z=[]}for(let G of Z){let Y=await this.executeSingleAction(G,U);q.push(Y)}return q}async executeSingleAction(X,U){if(X.probability!==void 0&&Math.random()>X.probability)return{type:X.type,timestamp:Date.now(),result:{skipped:"probability check failed"}};if(X.delay&&X.delay>0)await new Promise((q)=>setTimeout(q,X.delay));try{let q;try{let{ActionRegistry:Q}=await Promise.resolve().then(() => (Q2(),$U));q=Q.getInstance().get(X.type)}catch{q=this.actionHandlers.get(X.type)}let Z;if(q)Z=await q(X.params||{},U);else{let Q=`No handler registered for action type: ${X.type}`;console.warn(Q),Z={warning:Q}}return{type:X.type,result:Z,timestamp:Date.now()}}catch(q){return console.error(`Error executing action ${X.type}:`,q),{type:X.type,error:String(q),timestamp:Date.now()}}}interpolateParams(X,U){let q={};for(let[Z,Q]of Object.entries(X))if(typeof Q==="string")q[Z]=$0.interpolate(Q,U);else if(typeof Q==="object"&&Q!==null)q[Z]=this.interpolateDeep(Q,U);else q[Z]=Q;return q}interpolateDeep(X,U){if(typeof X==="string")return $0.interpolate(X,U);if(Array.isArray(X))return X.map((q)=>this.interpolateDeep(q,U));if(typeof X==="object"&&X!==null){let q={};for(let Z in X)q[Z]=this.interpolateDeep(X[Z],U);return q}return X}get rules(){return[...this._rules]}get config(){return this._config}set rules(X){this._rules=[...X],this.sortRules()}}Q2();Z2();var H6;((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"})(H6||={});var VV=H6;class j4{static instance;handlers=new Map;constructor(){}static getInstance(){if(!this.instance)this.instance=new j4;return this.instance}on(X,U){let q=X;if(!this.handlers.has(q))this.handlers.set(q,new Set);return this.handlers.get(q).add(U),()=>this.off(q,U)}off(X,U){let q=X,Z=this.handlers.get(q);if(Z)Z.delete(U)}emit(X,U){let q=X,Z=this.handlers.get(q);if(Z)Z.forEach((Q)=>{try{Q(U)}catch(G){console.error(`Error in event handler for ${q}:`,G)}})}}var G1=j4.getInstance();class f4 extends G2{actionRegistry;stateManager;constructor(X){super(X);this.actionRegistry=P1.getInstance(),this.stateManager=R0.getInstance()}async processEvent(X){let U=[];if(X.state=this.stateManager.getAll(),G1.emit("engine:start",{context:X,rulesCount:this.rules.length}),this.config?.globalSettings?.debugMode)console.log(`[RuleEngine] Evaluating context with ${this.rules.length} rules for event: ${X.event}`);let q=this.rules.filter((Z)=>Z.enabled!==!1&&Z.on===X.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,X)){if(this.config?.globalSettings?.debugMode)console.log(`[RuleEngine] Executing rule: ${Z.name||Z.id}`);G1.emit("rule:match",{rule:Z,context:X});let G=await this.executeRuleActionsWithRegistry(Z.do,X);if(U.push({ruleId:Z.id,executedActions:G,success:!0}),this.updateLastExecution(Z.id),!this.shouldEvaluateAll())break}}return G1.emit("engine:done",{results:U,context:X}),U}async processEventSimple(X,U={},q={}){let Z={event:X,data:U,globals:q,timestamp:Date.now(),state:this.stateManager.getAll()};return this.processEvent(Z)}async executeRuleActionsWithRegistry(X,U){let q=[],Z=[],Q="ALL";if(Array.isArray(X))Z=X;else if(X.mode&&X.actions){let G=X;Q=G.mode,Z=G.actions}else Z=[X];if(Q==="EITHER"&&Z.length>0){let G=Math.floor(Math.random()*Z.length),Y=Z[G];if(Y)Z=[Y]}if(Q==="SEQUENCE")for(let G of Z){let Y=await this.executeSingleActionWithRegistry(G,U);q.push(Y)}else for(let G of Z){let Y=await this.executeSingleActionWithRegistry(G,U);q.push(Y)}return q}async executeSingleActionWithRegistry(X,U){if(X.probability!==void 0&&Math.random()>X.probability)return{type:X.type,timestamp:Date.now(),result:{skipped:"probability check failed"}};if(X.delay&&X.delay>0)await new Promise((q)=>setTimeout(q,X.delay));try{let q=this.actionRegistry.get(X.type),Z;if(q)Z=await q(X,U);else{let Q=`Generic or unknown action type: ${X.type}`;if(this.config?.globalSettings?.strictActions)throw Error(Q);console.warn(Q),Z={warning:`Generic action executed: ${X.type}`}}return G1.emit("action:success",{action:X,context:U,result:Z}),{type:X.type,result:Z,timestamp:Date.now()}}catch(q){return console.error("Error executing action:",X,q),G1.emit("action:error",{action:X,context:U,error:String(q)}),{type:X.type,error:String(q),timestamp:Date.now()}}}updateLastExecution(X){this.lastExecution.set(X,Date.now())}getStateContext(){return this.stateManager.getAll()}shouldEvaluateAll(){return this.config?.globalSettings?.evaluateAll??!0}async executeRuleActions(X,U){return this.executeRuleActionsWithRegistry(X,U)}async executeSingleAction(X,U){return this.executeSingleActionWithRegistry(X,U)}}Q2();class oQ{static create(X,U,q={}){return{event:X,timestamp:Date.now(),data:typeof U==="object"?U:{value:U},globals:q,helpers:this.getDefaultHelpers()}}static fromRequest(X,U,q={}){let Z=new URL(X.url);return{event:"HTTP_REQUEST",timestamp:Date.now(),data:{method:X.method,path:Z.pathname,query:Object.fromEntries(Z.searchParams),headers:(()=>{let Q={};return X.headers.forEach((G,Y)=>Q[Y]=G),Q})(),body:U||{}},globals:{...q,ip:X.headers.get("x-forwarded-for")||"unknown"},helpers:this.getDefaultHelpers()}}static fromWebhook(X,U,q,Z={}){return{event:`WEBHOOK_${X.toUpperCase()}_${U.toUpperCase()}`,timestamp:Date.now(),data:q,globals:{...Z,provider:X},helpers:this.getDefaultHelpers()}}static getDefaultHelpers(){return{now:()=>Date.now(),uuid:()=>crypto.randomUUID(),jsonParse:(X)=>JSON.parse(X),jsonStringify:(X)=>JSON.stringify(X)}}}Z2();Q2();Z2();var p0=(X)=>Array.isArray(X)?X:[X],LU=(X,U)=>{let q=[[],[]];for(let Z of X)if(U(Z))q[0].push(Z);else q[1].push(Z);return q},J6=Array,z0=(X,U)=>X.includes(U),zU=(X,U=0)=>[...Array(X)].map((q,Z)=>Z+U),y=(X,U,q)=>{if(X===void 0)return U===void 0?[]:Array.isArray(U)?U:[U];if(q?.prepend)if(Array.isArray(U))X.unshift(...U);else X.unshift(U);else if(Array.isArray(U))X.push(...U);else X.push(U);return X},f0=(X,U)=>{if(U===void 0||U===null)return X??[];if(X===void 0||X===null)return p0(U);return X.concat(U)},FU=(...X)=>X.reduce(f0,[]),N0=(X,U,q)=>{if(X===void 0)return Array.isArray(U)?U:[U];let Z=q?.isEqual??((Q,G)=>Q===G);for(let Q of p0(U))if(!X.some((G)=>Z(G,Q)))X.push(Q);return X},AU=(X,U)=>X.reduce((q,Z)=>{let Q=Z[U];return q[Q]=y(q[Q],Z),q},{}),y0=(X,U,q)=>X.length===U.length&&X.every(q?.isEqual?(Z,Q)=>q.isEqual(Z,U[Q]):(Z,Q)=>Z===U[Q]);var Z0=(X,U)=>r(X)===U,r=(X)=>{let U=typeof X;return U==="object"?X===null?"null":"object":U==="function"?"object":U},Q0={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},VU={...Q0,function:"a function"};class OU extends Error{}var g=(X)=>Y1(X,OU),Y1=(X,U=Error)=>{throw new U(X)};class Y2 extends Error{name="ParseError"}var F=(X)=>Y1(X,Y2),D0=(X)=>` ${X}`,BU="​";var S=(X,U)=>{let q={},Z=Array.isArray(X),Q=!1;for(let[G,Y]of Object.entries(X).entries()){let H=Z?U(G,Y[1]):U(...Y,G);Q||=typeof H[0]==="number";let J=Array.isArray(H[0])||H.length===0?H:[H];for(let[W,$]of J)if(typeof W==="object")q[W.group]=y(q[W.group],$);else q[W]=$}return Q?Object.values(q):q};var y4=Object.entries;var a=(X,U)=>(X in U),I1=(X,U)=>(U in X);class g4{constructor(X){Object.assign(this,X)}}var TU=class{};class H2 extends TU{}var rQ=(X,U)=>{let q={},Z={},Q;for(Q in X)if(Q in U)q[Q]=X[Q];else Z[Q]=X[Q];return[q,Z]};var W6=(X,U)=>rQ(X,U)[1],C0=(X)=>Object.keys(X).length===0,H1=(X)=>[...Object.entries(X),...Object.getOwnPropertySymbols(X).map((U)=>[U,X[U]])],RU=(X,U)=>Object.defineProperties(X,Object.getOwnPropertyDescriptors(U)),DU=(X)=>{let U=Object.keys(X).sort(),q={};for(let Z=0;Z<U.length;Z++)q[U[Z]]=X[U[Z]];return q};var G0=D0(`unset${BU}`),MU=(X)=>Object.values(X).filter((U)=>{if(typeof U==="number")return!0;return typeof X[U]!=="number"});var k4={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},v4=globalThis.File??Blob,x4={ArrayBuffer,Blob,File:v4,FormData,Headers,Request,Response,URL},aQ={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},J1={...k4,...x4,...aQ,String,Number,Boolean},J2=(X)=>{let U=Object.getPrototypeOf(X);while(U?.constructor&&(!a(U.constructor.name,J1)||!(X instanceof J1[U.constructor.name])))U=Object.getPrototypeOf(U);let q=U?.constructor?.name;if(q===void 0||q==="Object")return;return q},W2=(X)=>typeof X==="object"&&X!==null?J2(X)??"object":r(X);var x=Array.isArray,nQ={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"},tQ={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"},eQ={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"},wU={...nQ,...tQ,...eQ},_2=(X)=>{let U=Object(X).name??null;return U&&a(U,J1)&&J1[U]===X?U:null};var h4=(X,U)=>{let q=X.prototype;while(q!==null){if(q===U.prototype)return!0;q=Object.getPrototypeOf(q)}return!1};var PU=(X)=>IU(X,new Map),IU=(X,U)=>{if(typeof X!=="object"||X===null)return X;if(U?.has(X))return U.get(X);let q=_2(X.constructor);if(q==="Date")return new Date(X.getTime());if(q&&q!=="Array")return X;let Z=Array.isArray(X)?X.slice():Object.create(Object.getPrototypeOf(X)),Q=Object.getOwnPropertyDescriptors(X);if(U){U.set(X,Z);for(let G in Q){let Y=Q[G];if("get"in Y||"set"in Y)continue;Y.value=IU(Y.value,U)}}return Object.defineProperties(Z,Q),Z};var XG=(X)=>{let U=G0;return()=>U===G0?U=X():U},l0=(X)=>typeof X==="function"&&X.length===0;var KU=class extends Function{constructor(...X){let U=X.slice(0,-1),q=X[X.length-1];try{super(...U,q)}catch(Z){return g(`Encountered an unexpected error while compiling your definition:
140
140
  Message: ${Z}
141
- Source: (${U.slice(0,-1)}) => {
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 RX=sQ(()=>{try{return Function("return false")()}catch{return!0}});var sT=R0("brand");var DX=R0("arkInferred");var aT=R0("args");class e{constructor(){}}var rQ=()=>{try{return((Error().stack?.split(`
144
- `)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},nQ=globalThis.process?.env??{},MX={fileName:rQ,env:nQ};var wX=(U)=>U[0].toUpperCase()+U.slice(1),PX=(U)=>U[0].toLowerCase()+U.slice(1),g4=(U)=>new RegExp(aQ(U),typeof U==="string"?"":U.flags);var aQ=(U)=>{return`^(?:${typeof U==="string"?U:U.source})$`};var y0={negativeLookahead:(U)=>`(?!${U})`,nonCapturingGroup:(U)=>`(?:${U})`},J1="\\",d0={" ":1,"\n":1,"\t":1};var tQ=/^-0\.?0*$/.source,KX=/[1-9]\d*/.source,eQ=/\.\d+/.source,UG=/\.\d*[1-9]/.source,NX=(U)=>g4(y0.negativeLookahead(tQ)+y0.nonCapturingGroup("-?"+y0.nonCapturingGroup(y0.nonCapturingGroup("0|"+KX)+y0.nonCapturingGroup(U.decimalPattern)+"?")+(U.allowDecimalOnly?"|"+U.decimalPattern:"")+"?")),IX=NX({decimalPattern:UG,allowDecimalOnly:!1}),XG=IX.test.bind(IX),Y6=NX({decimalPattern:eQ,allowDecimalOnly:!0}),QO=Y6.test.bind(Y6),qG=/^-?\d*\.?\d*$/,ZG=(U)=>U.length!==0&&qG.test(U),Y2=g4(y0.negativeLookahead("^-0$")+"-?"+y0.nonCapturingGroup(y0.nonCapturingGroup("0|"+KX))),QG=Y2.test.bind(Y2),y4=/^-?\d+$/,GG=y4.test.bind(y4),CX={number:"a number",bigint:"a bigint",integer:"an integer"},SX=(U,X)=>`'${U}' was parsed as ${CX[X]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,YG=(U,X)=>X==="number"?XG(U):QG(U),HG=(U,X)=>X==="number"?Number(U):Number.parseInt(U),JG=(U,X)=>X==="number"?ZG(U):GG(U),EX=(U,X)=>k4(U,"number",X),bX=(U,X)=>k4(U,"number",{...X,strict:!0}),jX=(U,X)=>k4(U,"integer",X),k4=(U,X,q)=>{let Z=HG(U,X);if(!Number.isNaN(Z)){if(JG(U,X)){if(q?.strict)return YG(U,X)?Z:F(SX(U,X));return Z}}return q?.errorOnFail?F(q?.errorOnFail===!0?`Failed to parse ${CX[X]} from '${U}'`:q?.errorOnFail):void 0},fX=(U)=>{if(U[U.length-1]!=="n")return;let X=U.slice(0,-1),q;try{q=BigInt(X)}catch{return}if(Y2.test(X))return q;if(y4.test(X))return F(SX(U,"bigint"))};var WG="0.56.0",LG={version:WG,filename:MX.fileName(),FileConstructor:b4},W1=LG,gX=new Map,v4=Object.create(null),H2=(U)=>{let X=gX.get(U);if(X)return X;let q=_G(U);if(v4[q])q=`${q}${v4[q]++}`;else v4[q]=1;return W1[q]=U,gX.set(U,q),q},c0=(U)=>/^[$A-Z_a-z][\w$]*$/.test(U),_G=(U)=>{switch(typeof U){case"object":{if(U===null)break;let X=Z2(U)??"object";return X[0].toLowerCase()+X.slice(1)}case"function":return c0(U.name)?U.name:"fn";case"symbol":return U.description&&c0(U.description)?U.description:"symbol"}return y(`Unexpected attempt to register serializable value of type ${r(U)}`)};var J2=(U)=>typeof U==="string"?JSON.stringify(U):typeof U==="bigint"?`${U}n`:`${U}`;var yX=(U,X={})=>W2(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?H6(q,X?.indent??0,""):JSON.stringify(W2(q,I1,[]),null,X?.indent):H6(q,X?.indent??0,"");case"symbol":return I1.onSymbol(U);default:return J2(U)}},H6=(U,X,q)=>{if(typeof U==="function")return I1.onFunction(U);if(typeof U!=="object"||U===null)return J2(U);let Z=q+" ".repeat(X);if(Array.isArray(U)){if(U.length===0)return"[]";let G=U.map((Y)=>H6(Y,X,Z)).join(`,
145
- `+Z);return X?`[
141
+ Source: (${X.slice(0,-1)}) => {
142
+ ${X[X.length-1]}
143
+ }`)}}};class Y0{constructor(X,...[U]){return Object.assign(Object.setPrototypeOf(X.bind(U?.bind??this),this.constructor.prototype),U?.attach)}}var NU=XG(()=>{try{return Function("return false")()}catch{return!0}});var $O=D0("brand");var CU=D0("arkInferred");var FO=D0("args");class e{constructor(){}}var UG=()=>{try{return((Error().stack?.split(`
144
+ `)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},qG=globalThis.process?.env??{},SU={fileName:UG,env:qG};var EU=(X)=>X[0].toUpperCase()+X.slice(1),bU=(X)=>X[0].toLowerCase()+X.slice(1),u4=(X)=>new RegExp(ZG(X),typeof X==="string"?"":X.flags);var ZG=(X)=>{return`^(?:${typeof X==="string"?X:X.source})$`};var g0={negativeLookahead:(X)=>`(?!${X})`,nonCapturingGroup:(X)=>`(?:${X})`},W1="\\",d0={" ":1,"\n":1,"\t":1};var QG=/^-0\.?0*$/.source,fU=/[1-9]\d*/.source,GG=/\.\d+/.source,YG=/\.\d*[1-9]/.source,yU=(X)=>u4(g0.negativeLookahead(QG)+g0.nonCapturingGroup("-?"+g0.nonCapturingGroup(g0.nonCapturingGroup("0|"+fU)+g0.nonCapturingGroup(X.decimalPattern)+"?")+(X.allowDecimalOnly?"|"+X.decimalPattern:"")+"?")),jU=yU({decimalPattern:YG,allowDecimalOnly:!1}),HG=jU.test.bind(jU),_6=yU({decimalPattern:GG,allowDecimalOnly:!0}),DO=_6.test.bind(_6),JG=/^-?\d*\.?\d*$/,WG=(X)=>X.length!==0&&JG.test(X),$2=u4(g0.negativeLookahead("^-0$")+"-?"+g0.nonCapturingGroup(g0.nonCapturingGroup("0|"+fU))),_G=$2.test.bind($2),m4=/^-?\d+$/,$G=m4.test.bind(m4),gU={number:"a number",bigint:"a bigint",integer:"an integer"},kU=(X,U)=>`'${X}' was parsed as ${gU[U]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,LG=(X,U)=>U==="number"?HG(X):_G(X),zG=(X,U)=>U==="number"?Number(X):Number.parseInt(X),FG=(X,U)=>U==="number"?WG(X):$G(X),vU=(X,U)=>p4(X,"number",U),xU=(X,U)=>p4(X,"number",{...U,strict:!0}),hU=(X,U)=>p4(X,"integer",U),p4=(X,U,q)=>{let Z=zG(X,U);if(!Number.isNaN(Z)){if(FG(X,U)){if(q?.strict)return LG(X,U)?Z:F(kU(X,U));return Z}}return q?.errorOnFail?F(q?.errorOnFail===!0?`Failed to parse ${gU[U]} from '${X}'`:q?.errorOnFail):void 0},uU=(X)=>{if(X[X.length-1]!=="n")return;let U=X.slice(0,-1),q;try{q=BigInt(U)}catch{return}if($2.test(U))return q;if(m4.test(U))return F(kU(X,"bigint"))};var AG="0.56.0",VG={version:AG,filename:SU.fileName(),FileConstructor:v4},_1=VG,mU=new Map,l4=Object.create(null),L2=(X)=>{let U=mU.get(X);if(U)return U;let q=OG(X);if(l4[q])q=`${q}${l4[q]++}`;else l4[q]=1;return _1[q]=X,mU.set(X,q),q},c0=(X)=>/^[$A-Z_a-z][\w$]*$/.test(X),OG=(X)=>{switch(typeof X){case"object":{if(X===null)break;let U=J2(X)??"object";return U[0].toLowerCase()+U.slice(1)}case"function":return c0(X.name)?X.name:"fn";case"symbol":return X.description&&c0(X.description)?X.description:"symbol"}return g(`Unexpected attempt to register serializable value of type ${r(X)}`)};var z2=(X)=>typeof X==="string"?JSON.stringify(X):typeof X==="bigint"?`${X}n`:`${X}`;var pU=(X,U={})=>F2(X,{onUndefined:"$ark.undefined",onBigInt:(q)=>`$ark.bigint-${q}`,...U},[]);var E=(X,U)=>{switch(r(X)){case"object":let q=X,Z=q.constructor?.name??"Object";return Z==="Object"||Z==="Array"?U?.quoteKeys===!1?$6(q,U?.indent??0,""):JSON.stringify(F2(q,K1,[]),null,U?.indent):$6(q,U?.indent??0,"");case"symbol":return K1.onSymbol(X);default:return z2(X)}},$6=(X,U,q)=>{if(typeof X==="function")return K1.onFunction(X);if(typeof X!=="object"||X===null)return z2(X);let Z=q+" ".repeat(U);if(Array.isArray(X)){if(X.length===0)return"[]";let G=X.map((Y)=>$6(Y,U,Z)).join(`,
145
+ `+Z);return U?`[
146
146
  ${Z}${G}
147
- ${q}]`:`[${G}]`}let Q=U.constructor?.name??"Object";if(Q==="Object"){let G=Y1(U).map(([Y,H])=>{let J=typeof Y==="symbol"?I1.onSymbol(Y):c0(Y)?Y:JSON.stringify(Y),W=H6(H,X,Z);return`${Z}${J}: ${W}`});if(G.length===0)return"{}";return X?`{
147
+ ${q}]`:`[${G}]`}let Q=X.constructor?.name??"Object";if(Q==="Object"){let G=H1(X).map(([Y,H])=>{let J=typeof Y==="symbol"?K1.onSymbol(Y):c0(Y)?Y:JSON.stringify(Y),W=$6(H,U,Z);return`${Z}${J}: ${W}`});if(G.length===0)return"{}";return U?`{
148
148
  ${G.join(`,
149
149
  `)}
150
- ${q}}`:`{${G.join(", ")}}`}if(U instanceof Date)return L1(U);if("expression"in U&&typeof U.expression==="string")return U.expression;return Q},I1={onCycle:()=>"(cycle)",onSymbol:(U)=>`Symbol(${H2(U)})`,onFunction:(U)=>`Function(${H2(U)})`},W2=(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 I1.onFunction(Z);if(q.includes(Z))return"(cycle)";let Q=[...q,Z];if(Array.isArray(Z))return Z.map((Y)=>W2(Y,X,Q));if(Z instanceof Date)return Z.toDateString();let G={};for(let Y in Z)G[Y]=W2(Z[Y],X,Q);for(let Y of Object.getOwnPropertySymbols(Z))G[X.onSymbol?.(Y)??Y.toString()]=W2(Z[Y],X,Q);return G}case"symbol":return I1.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}},L1=(U)=>{let X=U.getFullYear(),q=U.getMonth(),Z=U.getDate(),Q=U.getHours(),G=U.getMinutes(),Y=U.getSeconds(),H=U.getMilliseconds();if(q===0&&Z===1&&Q===0&&G===0&&Y===0&&H===0)return`${X}`;let J=`${$G[q]} ${Z}, ${X}`;if(Q===0&&G===0&&Y===0&&H===0)return J;let W=U.toLocaleTimeString(),_=W.endsWith(" AM")||W.endsWith(" PM")?W.slice(-3):"";if(_)W=W.slice(0,-_.length);if(H)W+=`.${FG(H,3)}`;else if(zG.test(W))W=W.slice(0,-3);return`${W+_}, ${J}`},$G=["January","February","March","April","May","June","July","August","September","October","November","December"],zG=/:\d\d:00$/,FG=(U,X)=>String(U).padStart(X,"0");var kX=(U,X,...[q])=>{let Z=q?.stringifySymbol??E,Q=U;switch(typeof X){case"string":Q=c0(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},k0=(U,...X)=>U.reduce((q,Z)=>kX(q,Z,...X),"");class L2 extends Q6{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=k0(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let U="",X=[U];for(let q of this)U=kX(U,q),X.push(U);return this.cache.stringifyAncestors=X}}class _2{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===J1)if(this.shift(),U(this,X))X+=this.shift();else if(this.lookahead===J1)X+=this.shift();else X+=`${J1}${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 d0))}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 vX=(U,X)=>`Unmatched ${U}${X===""?"":` before ${X}`}`,J6=(U)=>`Missing ${U}`;var SO=R0("implementedTraits");var x4="$ark",AG=2;while(x4 in globalThis)x4=`$ark${AG++}`;var xX=x4;globalThis[xX]=W1;var T=W1,TG=(U)=>`${xX}.${U}`,d=(U)=>TG(H2(U));class W6 extends q2{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 h4(U,X)}index(U,X=!1){return hX(`${U}`,X)}line(U){return this.body+=`${" ".repeat(this.indentation)}${U}
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
- `).map((q)=>" ".repeat(X)+`${q}`).join(`
153
- `):this.body} }`}compile(){return new BX(...this.argNames,this.body)}}var D0=(U)=>Q0(U,"object")||typeof U==="symbol"?d(U):J2(U),h4=(U,X=!1)=>{if(typeof U==="string"&&c0(U))return`${X?"?":""}.${U}`;return hX(OG(U),X)},OG=(U)=>typeof U==="symbol"?d(U):JSON.stringify(U),hX=(U,X=!1)=>`${X?"?.":""}[${U}]`;class $2 extends W6{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 L6=(U)=>S(U,(X,q)=>[X,x(q)?[...q]:q]),X0=R0("arkKind"),M=(U,X)=>U?.[X0]===X,h=(U)=>M(U,"root")||M(U,"constraint");var uX=["unit","proto","domain"],K1=["required","optional","index","sequence"],u4=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],m4=[...u4,"structure","predicate"],_6=[...m4,...K1],N1=["alias","union","morph","unit","intersection","proto","domain"],VG=[...N1,..._6],$6=S(_6,(U,X)=>[X,1]),mX=S([...K1,"undeclared"],(U,X)=>[X,1]),pX=S(VG,(U,X)=>[X,U]),C1=(U)=>typeof U==="string"&&(U in pX);var S1=(U)=>pX[U],z6=(U)=>N1.slice(S1(U)+1),$V=[...z6("union"),"alias"],zV=[...z6("morph"),"alias"],F0=(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 D0(U)},i0=(U)=>{let X="{ ";for(let[q,Z]of Object.entries(U))X+=`${q}: ${D0(Z)}, `;return X+" }"},b=(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 lX 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 BG={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:lX,throw:(...U)=>{throw new p.Error(...U)},throwInternalOperandError:(U,X)=>y(`Unexpected JSON Schema input for ${U}: ${E(X)}`),defaultConfig:BG};T.config??={};var z2=(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]=p4(U.toJsonSchema,X.toJsonSchema);else if(C1(Z))q[Z]={...U[Z],...X[Z]};else q[Z]=X[Z]}return q},RG={"draft-2020-12":"https://json-schema.org/draft/2020-12/schema","draft-07":"http://json-schema.org/draft-07/schema#"},p4=(U,X)=>{if(!U)return dX(X??{},void 0);if(!X)return U;let q={...U},Z;for(Z in X)if(Z==="fallback")q.fallback=DG(U.fallback,X.fallback);else q[Z]=X[Z];return dX(q,X)},dX=(U,X)=>{if(X?.dialect!==void 0)return U;if(X?.target!==void 0)return{...U,dialect:RG[X.target]};return U},DG=(U,X)=>{U=cX(U),X=cX(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},cX=(U)=>typeof U==="function"?{default:U}:U??{};class o0 extends q2{[X0]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:U,relativePath:X,...q},Z){super();this.input=q,this.ctx=Z,zX(this,q);let Q=Z.data;if(q.code==="union")q.errors=q.errors.flatMap((Y)=>{let H=Y.hasCode("union")?Y.errors:[Y];if(!U&&!X)return H;return H.map((J)=>J.transform((W)=>({...W,path:HX(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 L2(...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 k0(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 J0 extends Q6{[X0]="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 l4(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 J0(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
- `)}addAncestorPaths(U){for(let X of U.path.stringifyAncestors())this.byAncestorPath[X]=g(this.byAncestorPath[X],U)}}class l4 extends Error{name="TraversalError";constructor(U){if(U.length===1)super(U.summary);else super(`
155
- `+U.map((X)=>` • ${MG(X)}`).join(`
156
- `));Object.defineProperty(this,"arkErrors",{value:U,enumerable:!1})}}var MG=(U)=>U.toString().split(`
150
+ ${q}}`:`{${G.join(", ")}}`}if(X instanceof Date)return $1(X);if("expression"in X&&typeof X.expression==="string")return X.expression;return Q},K1={onCycle:()=>"(cycle)",onSymbol:(X)=>`Symbol(${L2(X)})`,onFunction:(X)=>`Function(${L2(X)})`},F2=(X,U,q)=>{switch(r(X)){case"object":{let Z=X;if("toJSON"in Z&&typeof Z.toJSON==="function")return Z.toJSON();if(typeof Z==="function")return K1.onFunction(Z);if(q.includes(Z))return"(cycle)";let Q=[...q,Z];if(Array.isArray(Z))return Z.map((Y)=>F2(Y,U,Q));if(Z instanceof Date)return Z.toDateString();let G={};for(let Y in Z)G[Y]=F2(Z[Y],U,Q);for(let Y of Object.getOwnPropertySymbols(Z))G[U.onSymbol?.(Y)??Y.toString()]=F2(Z[Y],U,Q);return G}case"symbol":return K1.onSymbol(X);case"bigint":return U.onBigInt?.(X)??`${X}n`;case"undefined":return U.onUndefined??"undefined";case"string":return X.replace(/\\/g,"\\\\");default:return X}},$1=(X)=>{let U=X.getFullYear(),q=X.getMonth(),Z=X.getDate(),Q=X.getHours(),G=X.getMinutes(),Y=X.getSeconds(),H=X.getMilliseconds();if(q===0&&Z===1&&Q===0&&G===0&&Y===0&&H===0)return`${U}`;let J=`${BG[q]} ${Z}, ${U}`;if(Q===0&&G===0&&Y===0&&H===0)return J;let W=X.toLocaleTimeString(),$=W.endsWith(" AM")||W.endsWith(" PM")?W.slice(-3):"";if($)W=W.slice(0,-$.length);if(H)W+=`.${RG(H,3)}`;else if(TG.test(W))W=W.slice(0,-3);return`${W+$}, ${J}`},BG=["January","February","March","April","May","June","July","August","September","October","November","December"],TG=/:\d\d:00$/,RG=(X,U)=>String(X).padStart(U,"0");var lU=(X,U,...[q])=>{let Z=q?.stringifySymbol??E,Q=X;switch(typeof U){case"string":Q=c0(U)?X===""?U:`${X}.${U}`:`${X}[${JSON.stringify(U)}]`;break;case"number":Q=`${X}[${U}]`;break;case"symbol":Q=`${X}[${Z(U)}]`;break;default:if(q?.stringifyNonKey)Q=`${X}[${q.stringifyNonKey(U)}]`;else F(`${E(U)} must be a PropertyKey or stringifyNonKey must be passed to options`)}return Q},k0=(X,...U)=>X.reduce((q,Z)=>lU(q,Z,...U),"");class A2 extends J6{cache={};constructor(...X){super();this.push(...X)}toJSON(){if(this.cache.json)return this.cache.json;this.cache.json=[];for(let X=0;X<this.length;X++)this.cache.json.push(typeof this[X]==="symbol"?E(this[X]):this[X]);return this.cache.json}stringify(){if(this.cache.stringify)return this.cache.stringify;return this.cache.stringify=k0(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let X="",U=[X];for(let q of this)X=lU(X,q),U.push(X);return this.cache.stringifyAncestors=U}}class V2{chars;i;def;constructor(X){this.def=X,this.chars=[...X],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(X){let U="";while(this.lookahead)if(X(this,U))break;else U+=this.shift();return U}shiftUntilEscapable(X){let U="";while(this.lookahead)if(this.lookahead===W1)if(this.shift(),X(this,U))U+=this.shift();else if(this.lookahead===W1)U+=this.shift();else U+=`${W1}${this.shift()}`;else if(X(this,U))break;else U+=this.shift();return U}shiftUntilLookahead(X){return typeof X==="string"?this.shiftUntil((U)=>U.lookahead===X):this.shiftUntil((U)=>(U.lookahead in X))}shiftUntilNonWhitespace(){return this.shiftUntil(()=>!(this.lookahead in d0))}jumpToIndex(X){this.i=X<0?this.length+X:X}jumpForward(X){this.i+=X}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(X,U){return this.chars.slice(X,U).join("")}lookaheadIs(X){return this.lookahead===X}lookaheadIsIn(X){return this.lookahead in X}}var dU=(X,U)=>`Unmatched ${X}${U===""?"":` before ${U}`}`,L6=(X)=>`Missing ${X}`;var iO=D0("implementedTraits");var d4="$ark",DG=2;while(d4 in globalThis)d4=`$ark${DG++}`;var cU=d4;globalThis[cU]=_1;var V=_1,MG=(X)=>`${cU}.${X}`,d=(X)=>MG(L2(X));class z6 extends H2{argNames;body="";constructor(...X){super();this.argNames=X;for(let U of X){if(U in this)throw Error(`Arg name '${U}' would overwrite an existing property on FunctionBody`);this[U]=U}}indentation=0;indent(){return this.indentation+=4,this}dedent(){return this.indentation-=4,this}prop(X,U=!1){return c4(X,U)}index(X,U=!1){return iU(`${X}`,U)}line(X){return this.body+=`${" ".repeat(this.indentation)}${X}
151
+ `,this}const(X,U){return this.line(`const ${X} = ${U}`),this}let(X,U){return this.line(`let ${X} = ${U}`)}set(X,U){return this.line(`${X} = ${U}`)}if(X,U){return this.block(`if (${X})`,U)}elseIf(X,U){return this.block(`else if (${X})`,U)}else(X){return this.block("else",X)}for(X,U,q=0){return this.block(`for (let i = ${q}; ${X}; i++)`,U)}forIn(X,U){return this.block(`for (const k in ${X})`,U)}block(X,U,q=""){return this.line(`${X} {`),this.indent(),U(this),this.dedent(),this.line(`}${q}`)}return(X=""){return this.line(`return ${X}`)}write(X="anonymous",U=0){return`${X}(${this.argNames.join(", ")}) { ${U?this.body.split(`
152
+ `).map((q)=>" ".repeat(U)+`${q}`).join(`
153
+ `):this.body} }`}compile(){return new KU(...this.argNames,this.body)}}var M0=(X)=>Z0(X,"object")||typeof X==="symbol"?d(X):z2(X),c4=(X,U=!1)=>{if(typeof X==="string"&&c0(X))return`${U?"?":""}.${X}`;return iU(wG(X),U)},wG=(X)=>typeof X==="symbol"?d(X):JSON.stringify(X),iU=(X,U=!1)=>`${U?"?.":""}[${X}]`;class O2 extends z6{traversalKind;optimistic;constructor(X){super("data","ctx");this.traversalKind=X.kind,this.optimistic=X.optimistic===!0}invoke(X,U){let q=U?.arg??this.data,Z=typeof X==="string"?!0:this.requiresContextFor(X),Q=typeof X==="string"?X:X.id;if(Z)return`${this.referenceToId(Q,U)}(${q}, ${this.ctx})`;return`${this.referenceToId(Q,U)}(${q})`}referenceToId(X,U){let q=U?.kind??this.traversalKind,Z=`this.${X}${q}`;return U?.bind?`${Z}.bind(${U?.bind})`:Z}requiresContextFor(X){return this.traversalKind==="Apply"||X.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(X,U,q){let Z=this.requiresContextFor(q);if(Z)this.line(`${this.ctx}.path.push(${X})`);if(this.check(q,{arg:U}),Z)this.line(`${this.ctx}.path.pop()`);return this}check(X,U){return this.traversalKind==="Allows"?this.if(`!${this.invoke(X,U)}`,()=>this.return(!1)):this.line(this.invoke(X,U))}}var F6=(X)=>S(X,(U,q)=>[U,x(q)?[...q]:q]),U0=D0("arkKind"),M=(X,U)=>X?.[U0]===U,h=(X)=>M(X,"root")||M(X,"constraint");var sU=["unit","proto","domain"],N1=["required","optional","index","sequence"],i4=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],s4=[...i4,"structure","predicate"],A6=[...s4,...N1],C1=["alias","union","morph","unit","intersection","proto","domain"],PG=[...C1,...A6],V6=S(A6,(X,U)=>[U,1]),oU=S([...N1,"undeclared"],(X,U)=>[U,1]),rU=S(PG,(X,U)=>[U,X]),S1=(X)=>typeof X==="string"&&(X in rU);var E1=(X)=>rU[X],O6=(X)=>C1.slice(E1(X)+1),SB=[...O6("union"),"alias"],EB=[...O6("morph"),"alias"],F0=(X)=>{if(typeof X==="string"||typeof X==="boolean"||X===null)return X;if(typeof X==="number"){if(Number.isNaN(X))return"NaN";if(X===Number.POSITIVE_INFINITY)return"Infinity";if(X===Number.NEGATIVE_INFINITY)return"-Infinity";return X}return M0(X)},i0=(X)=>{let U="{ ";for(let[q,Z]of Object.entries(X))U+=`${q}: ${M0(Z)}, `;return U+" }"},b=(X)=>{let U=X;if(U.hasAssociatedError)U.defaults.expected??=(q)=>("description"in q)?q.description:U.defaults.description(q),U.defaults.actual??=(q)=>E(q),U.defaults.problem??=(q)=>`must be ${q.expected}${q.actual?` (was ${q.actual})`:""}`,U.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 U};class aU extends Error{name="ToJsonSchemaError";code;context;constructor(X,U){super(E(U,{quoteKeys:!1,indent:4}));this.code=X,this.context=U}hasCode(X){return this.code===X}}var IG={target:"draft-2020-12",dialect:"https://json-schema.org/draft/2020-12/schema",useRefs:!1,fallback:{arrayObject:(X)=>p.throw("arrayObject",X),arrayPostfix:(X)=>p.throw("arrayPostfix",X),defaultValue:(X)=>p.throw("defaultValue",X),domain:(X)=>p.throw("domain",X),morph:(X)=>p.throw("morph",X),patternIntersection:(X)=>p.throw("patternIntersection",X),predicate:(X)=>p.throw("predicate",X),proto:(X)=>p.throw("proto",X),symbolKey:(X)=>p.throw("symbolKey",X),unit:(X)=>p.throw("unit",X),date:(X)=>p.throw("date",X)}},p={Error:aU,throw:(...X)=>{throw new p.Error(...X)},throwInternalOperandError:(X,U)=>g(`Unexpected JSON Schema input for ${X}: ${E(U)}`),defaultConfig:IG};V.config??={};var B2=(X,U)=>{if(!U)return X;let q={...X},Z;for(Z in U){let Q={...X.keywords};if(Z==="keywords"){for(let G in U[Z]){let Y=U.keywords[G];if(Y===void 0)continue;Q[G]=typeof Y==="string"?{description:Y}:Y}q.keywords=Q}else if(Z==="toJsonSchema")q[Z]=o4(X.toJsonSchema,U.toJsonSchema);else if(S1(Z))q[Z]={...X[Z],...U[Z]};else q[Z]=U[Z]}return q},KG={"draft-2020-12":"https://json-schema.org/draft/2020-12/schema","draft-07":"http://json-schema.org/draft-07/schema#"},o4=(X,U)=>{if(!X)return nU(U??{},void 0);if(!U)return X;let q={...X},Z;for(Z in U)if(Z==="fallback")q.fallback=NG(X.fallback,U.fallback);else q[Z]=U[Z];return nU(q,U)},nU=(X,U)=>{if(U?.dialect!==void 0)return X;if(U?.target!==void 0)return{...X,dialect:KG[U.target]};return X},NG=(X,U)=>{X=tU(X),U=tU(U);let q={},Z;for(Z in p.defaultConfig.fallback)q[Z]=U[Z]??U.default??X[Z]??X.default??p.defaultConfig.fallback[Z];return q},tU=(X)=>typeof X==="function"?{default:X}:X??{};class s0 extends H2{[U0]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:X,relativePath:U,...q},Z){super();this.input=q,this.ctx=Z,RU(this,q);let Q=Z.data;if(q.code==="union")q.errors=q.errors.flatMap((Y)=>{let H=Y.hasCode("union")?Y.errors:[Y];if(!X&&!U)return H;return H.map((J)=>J.transform((W)=>({...W,path:FU(X,W.path,U)})))});this.nodeConfig=Z.config[this.code];let G=[...q.path??Z.path];if(U)G.push(...U);if(X)G.unshift(...X);this.path=new A2(...G),this.data="data"in q?q.data:Q}transform(X){return new s0(X({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode(X){return this.code===X}get propString(){return k0(this.path)}get expected(){if(this.input.expected)return this.input.expected;let X=this.meta?.expected??this.nodeConfig.expected;return typeof X==="function"?X(this.input):X}get actual(){if(this.input.actual)return this.input.actual;let X=this.meta?.actual??this.nodeConfig.actual;return typeof X==="function"?X(this.data):X}get problem(){if(this.input.problem)return this.input.problem;let X=this.meta?.problem??this.nodeConfig.problem;return typeof X==="function"?X(this):X}get message(){if(this.input.message)return this.input.message;let X=this.meta?.message??this.nodeConfig.message;return typeof X==="function"?X(this):X}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 H0 extends J6{[U0]="errors";ctx;constructor(X){super();this.ctx=X}byPath=Object.create(null);get flatByPath(){return S(this.byPath,(X,U)=>[X,U.flat])}get flatProblemsByPath(){return S(this.byPath,(X,U)=>[X,U.flat.map((q)=>q.problem)])}byAncestorPath=Object.create(null);count=0;mutable=this;throw(){throw this.toTraversalError()}toTraversalError(){return new r4(this)}add(X){let U=this.byPath[X.propString];if(U){if(X===U)return;if(U.hasCode("union")&&U.errors.length===0)return;let q=X.hasCode("union")&&X.errors.length===0?X:new s0({code:"intersection",errors:U.hasCode("intersection")?[...U.errors,X]:[U,X]},this.ctx),Z=this.indexOf(U);this.mutable[Z===-1?this.length:Z]=q,this.byPath[X.propString]=q,this.addAncestorPaths(X)}else this.byPath[X.propString]=X,this.addAncestorPaths(X),this.mutable.push(X);this.count++}transform(X){let U=new H0(this.ctx);for(let q of this)U.add(X(q));return U}merge(X){for(let U of X)this.add(new s0({...U,path:[...this.ctx.path,...U.path]},this.ctx))}affectsPath(X){if(this.length===0)return!1;return X.stringifyAncestors().some((U)=>(U in this.byPath))||X.stringify()in this.byAncestorPath}get summary(){return this.toString()}get issues(){return this}toJSON(){return[...this.map((X)=>X.toJSON())]}toString(){return this.join(`
154
+ `)}addAncestorPaths(X){for(let U of X.path.stringifyAncestors())this.byAncestorPath[U]=y(this.byAncestorPath[U],X)}}class r4 extends Error{name="TraversalError";constructor(X){if(X.length===1)super(X.summary);else super(`
155
+ `+X.map((U)=>` • ${CG(U)}`).join(`
156
+ `));Object.defineProperty(this,"arkErrors",{value:X,enumerable:!1})}}var CG=(X)=>X.toString().split(`
157
157
  `).join(`
158
- `);class M0{path=[];errors=new J0(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 k0(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 L2(...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=h(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 J0){if(!G)this.errors.merge(Y);this.queuedMorphs=[];break}if(Z===void 0)this.root=Y;else Z[q]=Y;this.applyQueuedMorphs()}}}var W0=(U,X,q)=>{if(!q)return X();q.path.push(U);let Z=X();return q.path.pop(),Z};class A2 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)=>KG(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((H)=>oX(H,Y))){this.flatRefs.push(Y);for(let H of Y.node.branches)if(H.hasKind("morph")||H.hasKind("intersection")&&H.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:Y.path,propString:Y.propString,node:H})}}}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 M0(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 M0(X,this.$.resolvedConfig);return this.traverseApply(X,Z),Z.finalize(q)};case"contextual":return(X,q)=>{let Z=new M0(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 M0(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=IG(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=S1(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]=x(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=h(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)G1(`${this.kind} node was not of asserted kind ${U}`);return this}hasKindIn(...U){return U.includes(this.kind)}assertHasKindIn(...U){if(!z0(U,this.kind))G1(`${this.kind} node was not one of asserted kinds ${U}`);return this}isBasis(){return z0(uX,this.kind)}isConstraint(){return z0(_6,this.kind)}isStructural(){return z0(K1,this.kind)}isRefinement(){return z0(m4,this.kind)}isRoot(){return z0(N1,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=F2.normalize(U);return this._select(X)}_select(U){let X=F2.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 F2.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 L=_;if(!x(L)){let A=L._transform(U,X);return A?[W,A]:[]}if(L.length===0)return[W,_];let $=L.flatMap((A)=>{return A._transform(U,X)??[]});return $.length?[W,$]:[]});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(h(Y))return Z=Y;let H=Object.keys(Y);if((H.length===0||H.length===1&&H[0]==="meta")&&!C0(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in Y))return X.undeclaredKeyHandling?{...Y,value:T.intrinsic.unknown}:null;if(this.kind==="morph")Y.in??=T.intrinsic.unknown;return Z=q.node(this.kind,Y,X.parseOptions)}configureReferences(U,X="references"){let q=F2.normalize(X),Z=typeof U==="string"?(H,J)=>({...J,meta:{...J.meta,description:U}}):typeof U==="function"?(H,J)=>({...J,meta:U(J.meta)}):(H,J)=>({...J,meta:{...J.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&&p0(Q),Y=q.boundary==="child"?(H,J)=>J.root.children.includes(H):q.boundary==="shallow"?(H)=>H.kind!=="structure":()=>!0;return this.$.finalize(this.transform(Z,{shouldTransform:Y,selected:G}))}}var F2={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)G1(iX(X,q));return U},find:(U)=>U[0],assertFind:(U,X,q)=>{if(U.length===0)G1(iX(X,q));return U[0]}},normalize:(U)=>typeof U==="function"?{boundary:"references",method:"filter",where:U}:typeof U==="string"?n(U,F2.applyBoundary)?{method:"filter",boundary:U}:{boundary:"references",method:"filter",kind:U}:{boundary:"references",method:"filter",...U}},iX=(U,X)=>`${U} had no references matching ${E(X)}.`,wG=(U)=>k0(U,{stringifyNonKey:(X)=>X.expression}),PG=/"(\$ark\.[^"]+)"/g,IG=(U)=>JSON.stringify(U).replace(PG,"$1"),w0=(U,X)=>({path:U,node:X,propString:wG(U)}),oX=(U,X)=>U.propString===X.propString&&U.node.equals(X.node),d4=(U,X)=>N0(U,X,{isEqual:oX}),KG=(U,X)=>N0(U,X,{isEqual:(q,Z)=>q.equals(Z)});class V extends Array{static init(U,X,q,Z){return new V({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=k0(U);return i4(`Intersection${Z&&` at ${Z}`} of ${sX(X,q)}`)}return`The following intersections result in unsatisfiable types:
159
- • ${this.map(({path:U,l:X,r:q})=>`${U}: ${sX(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 V))return new V(...U);return U}withPrefixKey(U,X){return this.map((q)=>({...q,path:[U,...q.path],optional:q.optional||X==="optional"}))}toNeverIfDisjoint(){return T.intrinsic.never}}var sX=(U,X)=>`${c4(U)} and ${c4(X)}`,c4=(U)=>h(U)?U.expression:x(U)?U.map(c4).join(" | ")||"never":String(U),i4=(U)=>`${U} results in an unsatisfiable type`;var E1={},L0=(U,X,q)=>u(U,X,{$:q,invert:!1,pipe:!1}),T2=(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(E1[Q]!==void 0)return E1[Q];if(!q.pipe){let H=`${X.hash}${Z}${U.hash}`;if(E1[H]!==void 0){let J=E1[H],W=J instanceof V?J.invert():J;return E1[Q]=W,W}}let G=!q.pipe||!U.includesTransform&&!X.includesTransform;if(G&&U.equals(X))return U;let Y=G?o4(U,X,q):U.hasKindIn(...N1)?NG(U,X,q):o4(U,X,q);if(h(Y)){if(U.equals(Y))Y=U;else if(X.equals(Y))Y=X}return E1[Q]=Y,Y},o4=(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 V)G=G.invert();return G}},NG=(U,X,q)=>U.includesTransform||X.includesTransform?q.invert?rX(X,U,q):rX(U,X,q):o4(U,X,q),rX=(U,X,q)=>U.distribute((Z)=>CG(Z,X,q),(Z)=>{let Q=Z.filter(h);if(Q.length===0)return V.init("union",U.branches,X.branches);if(Q.length<U.branches.length||!U.branches.every((H,J)=>H.rawIn.equals(Q[J].rawIn)))return q.$.parseSchema(Q);let G;if(Q.length===1){let H=Q[0];if(!G)return H;return q.$.node("morph",{...H.inner,in:H.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 V)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 V)return Q;return q.$.node("morph",{morphs:[X],in:Q})}return q.$.node("morph",{morphs:[X],in:U})};class A0 extends A2{constructor(U,X){super(U,X);Object.defineProperty(this,X0,{value:"constraint",enumerable:!1})}impliedSiblings;intersect(U){return L0(this,U,this.$)}}class v0 extends A0{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 i0(this.errorContext)}}var U0=(U)=>(X,q)=>{if(x(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},b1=(U)=>{let X=U.r.shift();if(!X){let Z=U.l.length===0&&U.kind==="structure"?T.intrinsic.unknown.internal:U.ctx.$.node(U.kind,Object.assign(U.baseInner,SG(U.l)),{prereduced:!0});for(let Q of U.roots){if(Z instanceof V)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 V)return Q;if(Q.isRoot())return U.roots.push(Q),U.l.splice(Z),b1(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)N0(U.r,Z)}return b1(U)},j1=(U)=>{return Object.entries(U).flatMap(([q,Z])=>(q in $6)?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)},SG=(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},nX=(...U)=>F(aX(...U)),aX=(U,X,q)=>{let Z=q.hasKind("morph")?"a morph":q.isUnknown()?"unknown":q.exclude(X).defaultShortDescription;return`${wX(U)} operand must be ${X.description} (was ${Z})`};var tX=(U,X,q)=>new s0(U,X,q,q,null);class F6 extends H0{}class s0 extends H0{[X0]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor(U,X,q,Z,Q){super((...G)=>{let Y=S(this.names,(H,J)=>{let W=this.arg$.parse(G[H]);if(!W.extends(this.constraints[H]))F(EG(J,this.constraints[H].expression,W.expression));return[J,W]});if(this.defIsLazy()){let H=this.bodyDef(Y);return this.$.parse(H)}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 F6}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:yX(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map((U)=>typeof U==="string"?[U,T.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 EG=(U,X,q)=>`${U} must be assignable to ${X} (was ${q})`;var bG=b({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 eX extends A0{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=i0(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 s4={implementation:bG,Node:eX};var jG=b({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:(U)=>Number.isInteger(U)?U:F(fG(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/gG(U.rule,X.rule))})},obviatesBasisDescription:!0});class Uq extends v0{traverseAllows=(U)=>U%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=T.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema(U){if(U.type="integer",this.rule===1)return U;return U.multipleOf=this.rule,U}}var r4={implementation:jG,Node:Uq};var fG=(U)=>`divisor must be an integer (was ${U})`,gG=(U,X)=>{let q,Z=U,Q=X;while(Q!==0)q=Q,Q=Z%Q,Z=q;return Z};class $0 extends v0{boundOperandKind=xG[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=hG(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${yG[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?uG(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 yG={"<":">=","<=":">",">":"<=",">=":"<"},kG={min:"max",minLength:"maxLength",after:"before"},A6={parse:(U)=>U||void 0},T6=(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},O6=(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},V6=(U)=>typeof U==="string"||typeof U==="number"?new Date(U):U,vG=(U,X)=>`${U} bound must be a positive integer (was ${X})`,f1=(U)=>(X)=>{if(!Number.isInteger(X)||X<0)F(vG(U,X));return X},xG={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},hG=(U,X)=>`${n(U,kG)?">":"<"}${X?"":"="}`,uG=(U)=>typeof U==="string"?U:new Date(U).toLocaleString(),Xq=(U)=>`Bounded expression ${U} must be exactly one of number, string, Array, or Date`;var mG=b({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:V6,serialize:(U)=>U.toISOString()}},normalize:O6("after"),defaults:{description:(U)=>`${U.collapsibleLimitString} or later`,actual:L1},intersections:{after:(U,X)=>U.isStricterThan(X)?U:X}});class qq extends $0{impliedBasis=T.intrinsic.Date.internal;collapsibleLimitString=L1(this.rule);traverseAllows=(U)=>U>=this.rule;reduceJsonSchema(U,X){return X.fallback.date({code:"date",base:U,after:this.rule})}}var n4={implementation:mG,Node:qq};var pG=b({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:V6,serialize:(U)=>U.toISOString()}},normalize:O6("before"),defaults:{description:(U)=>`${U.collapsibleLimitString} or earlier`,actual:L1},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:V.init("range",U,X)}});class Zq extends $0{collapsibleLimitString=L1(this.rule);traverseAllows=(U)=>U<=this.rule;impliedBasis=T.intrinsic.Date.internal;reduceJsonSchema(U,X){return X.fallback.date({code:"date",base:U,before:this.rule})}}var a4={implementation:pG,Node:Zq};var lG=b({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:f1("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)=>V.init("unit",q.$.node("unit",{unit:U.rule}),q.$.node("unit",{unit:X.rule}),{path:["length"]}),minLength:(U,X)=>U.rule>=X.rule?U:V.init("range",U,X),maxLength:(U,X)=>U.rule<=X.rule?U:V.init("range",U,X)}});class Qq extends v0{traverseAllows=(U)=>U.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=T.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 t4={implementation:lG,Node:Qq};var dG=b({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:A6},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:V.init("range",U,X)},obviatesBasisDescription:!0});class Gq extends $0{impliedBasis=T.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 e4={implementation:dG,Node:Gq};var cG=b({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:f1("maxLength")}},reduce:(U,X)=>U.rule===0?X.node("exactLength",U):void 0,normalize:T6("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:V.init("range",U,X)}});class Yq extends $0{impliedBasis=T.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 U9={implementation:cG,Node:Yq};var iG=b({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:A6},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 Hq extends $0{impliedBasis=T.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 X9={implementation:iG,Node:Hq};var oG=b({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:f1("minLength")}},reduce:(U)=>U.rule===0?T.intrinsic.unknown:void 0,normalize:T6("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 Jq extends $0{impliedBasis=T.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 q9={implementation:oG,Node:Jq};var Wq={min:X9.implementation,max:e4.implementation,minLength:q9.implementation,maxLength:U9.implementation,exactLength:t4.implementation,after:n4.implementation,before:a4.implementation},Lq={min:X9.Node,max:e4.Node,minLength:q9.Node,maxLength:U9.Node,exactLength:t4.Node,after:n4.Node,before:a4.Node};var sG=b({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 _q extends v0{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=T.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 Z9={implementation:sG,Node:_q};var O2=(U,X)=>{let q=rG(U);if(X&&!X.includes(q))return F(`Root of kind ${q} should be one of ${X}`);return q},rG=(U)=>{if(M(U,"root"))return U.kind;if(typeof U==="string")return U[0]==="$"?"alias":(U in G0)?"domain":"proto";if(typeof U==="function")return"proto";if(typeof U!=="object"||U===null)return F($q(U));if("morphs"in U)return"morph";if("branches"in U||x(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 $6)))return"intersection";if("proto"in U)return"proto";if("domain"in U)return"domain";return F($q(U))},$q=(U)=>`${E(U)} is not a valid type schema`,zq={},nG=(U)=>x(U)?U.map((X)=>X.collapsibleJson):U.collapsibleJson,q0={};T.nodesByRegisteredId=q0;var Q9=(U)=>{return zq[U]??=0,`${U}${++zq[U]}`},G9=(U)=>{let X=g1[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,H=C4(G).sort(([W],[_])=>C1(W)?C1(_)?S1(W)-S1(_):1:C1(_)?-1:W<_?-1:1).filter(([W,_])=>{if(W.startsWith("meta.")){let L=W.slice(5);return Y[L]=_,!1}return!0});for(let W of H){let _=W[0],L=X.keys[_];if(!L)return F(`Key ${_} is not valid on ${U.kind} schema`);let $=L.parse?L.parse(W[1],U):W[1];if($!==Y0&&($!==void 0||L.preserveUndefined))Z[_]=$}if(X.reduce&&!U.prereduced){let W=X.reduce(Z,U.$);if(W){if(W instanceof V)return W.throw();return aG(W,Y)}}return Y9({id:U.id,kind:U.kind,inner:Z,meta:Y,$:U.$})},Y9=({id:U,kind:X,inner:q,meta:Z,$:Q,ignoreCache:G})=>{let Y=g1[X],H=C4(q),J=[],W={};for(let[D,P]of H){let K=Y.keys[D],C=K.serialize??(K.child?nG:F0);if(W[D]=C(P),K.child===!0){let N=P;if(x(N))J.push(...N);else J.push(N)}else if(typeof K.child==="function")J.push(...K.child(P))}if(Y.finalizeInnerJson)W=Y.finalizeInnerJson(W);let _={...W},L={};if(!C0(Z))L=S(Z,(D,P)=>[D,D==="examples"?P:F0(P)]),_.meta=B6(L,"description",!0);W=B6(W,Y.collapsibleKey,!1);let $=JSON.stringify({kind:X,...W});_=B6(_,Y.collapsibleKey,!1);let A=B6(_,Y.collapsibleKey,!0),B=JSON.stringify({kind:X,..._});if(Q.nodesByHash[B]&&!G)return Q.nodesByHash[B];let z={id:U,kind:X,impl:Y,inner:q,innerEntries:H,innerJson:W,innerHash:$,meta:Z,metaJson:L,json:_,hash:B,collapsibleJson:A,children:J};if(X!=="intersection"){for(let D in q)if(D!=="in"&&D!=="out")z[D]=q[D]}let O=new Aq[X](z,Q);return Q.nodesByHash[B]=O},Fq=(U,X)=>{if(U.id===X)return U;if(h(q0[X]))y(`Unexpected attempt to overwrite node id ${X}`);return Y9({id:X,kind:U.kind,inner:U.inner,meta:U.meta,$:U.$,ignoreCache:!0})},aG=(U,X,q)=>{if(q&&h(q0[q]))y(`Unexpected attempt to overwrite node id ${q}`);return Y9({id:q??Q9(X.alias??U.kind),kind:U.kind,inner:U.inner,meta:X,$:U.$})},B6=(U,X,q)=>{let Z=Object.keys(U);if(Z.length===1&&Z[0]===X){let Q=U[X];if(q)return Q;if(Q0(Q,"object")&&(Object.keys(Q).length===1||Array.isArray(Q)))return Q}return U};var V2=(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 V)if(G==="optional")Q=T.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(H9(U.default,X.default)):U.default:X.hasDefault()?X.default:Y0;return q.$.node("optional",{key:Z,value:Q,default:Y})};class B2 extends A0{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=T.intrinsic.object.internal;serializedKey=D0(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=g(this.value.flatRefs.map((U)=>w0([this.key,...U.path],U.node)),w0([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 W0(this.key,()=>this.value.traverseAllows(U[this.key],X),X);return this.optional};traverseApply=(U,X)=>{if(this.key in U)W0(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 H9=(U,X)=>`Invalid intersection of default values ${E(U)} & ${E(X)}`;var tG=b({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:V2}});class Tq extends B2{constructor(...U){super(...U);if("default"in this.inner)D2(this.value,this.inner.default,this.key)}get rawIn(){let U=super.rawIn;if(!this.hasDefault())return U;return this.$.node("optional",G6(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=U5(this);defaultValueMorphRef=this.defaultValueMorph&&d(this.defaultValueMorph)}var R2={implementation:tG,Node:Tq},eG={},U5=(U)=>{if(!U.hasDefault())return;let X=`{${U.compiledKey}: ${U.value.id} = ${F0(U.default)}}`;return eG[X]??=J9(U.key,U.value,U.default)},J9=(U,X,q)=>{if(typeof q==="function")return X.includesTransform?(Q,G)=>{return W0(U,()=>X(Q[U]=q(),G),G),Q}:(Q)=>{return Q[U]=q(),Q};let Z=X.includesTransform?X.assert(q):q;return Q0(Z,"object")?(Q,G)=>{return W0(U,()=>X(Q[U]=q,G),G),Q}:(Q)=>{return Q[U]=Z,Q}},D2=(U,X,q)=>{let Z=l0(X);if(Q0(X,"object")&&!Z)F(X5(q));let Q=U.in(Z?X():X);if(Q instanceof J0){if(q===null)F(`Default ${Q.summary}`);let G=Q.transform((Y)=>Y.transform((H)=>({...H,prefixPath:[q]})));F(`Default for ${G.summary}`)}return X},X5=(U)=>{return`Non-primitive default ${U===null?"":typeof U==="number"?`for value at [${U}] `:`for ${D0(U)} `}must be specified as a function like () => ({my: 'object'})`};class T0 extends A2{constructor(U,X){super(U,X);Object.defineProperty(this,X0,{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 J0)return X;return{value:X}},jsonSchema:{input:(U)=>this.rawIn.toJsonSchema({target:Oq(U.target),...U.libraryOptions}),output:(U)=>this.rawOut.toJsonSchema({target:Oq(U.target),...U.libraryOptions})}}}as(){return this}brand(U){if(U==="")return F(q5);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=p4(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 V)return q;return this.$.finalize(q)}rawIntersect(U){return L0(this,U,this.$)}toNeverIfDisjoint(){return this}and(U){let X=this.intersect(U);return X instanceof V?X.throw():X}rawAnd(U){let X=this.rawIntersect(U);return X instanceof V?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(),T.intrinsic.unknown.internal);if(U.branches.length===0)F(i4(`keyof ${this.expression}`));return this._keyof=this.$.finalize(U)}get props(){if(this.branches.length!==1)return F(Q5(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge(U){let X=this.$.parseDefinition(U);return this.$.schema(X.distribute((q)=>this.applyStructuralOperation("merge",[Vq(q)??F(Bq("merge",q.expression))])))}applyStructuralOperation(U,X){return this.distribute((q)=>{if(q.equals(T.intrinsic.object)&&U!=="merge")return q;let Z=Vq(q);if(!Z)F(Bq(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 V)}extends(U){if(this.isNever())return!0;let X=this.intersect(U);return!(X instanceof V)&&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 D2(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 H0(this);root;config;queuedMorphs=[];branches=[];seen={};constructor(X,U){this.root=X,this.config=U}get data(){let X=this.root;for(let U of this.path)X=X?.[U];return X}get propString(){return k0(this.path)}reject(X){return this.error(X),!1}mustBe(X){return this.error(X),!1}error(X){let U=typeof X==="object"?X.code?X:{...X,code:"predicate"}:{code:"predicate",expected:X};return this.errorFromContext(U)}hasError(){return this.currentErrorCount!==0}get currentBranch(){return this.branches[this.branches.length-1]}queueMorphs(X){let U={path:new A2(...this.path),morphs:X};if(this.currentBranch)this.currentBranch.queuedMorphs.push(U);else this.queuedMorphs.push(U)}finalize(X){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 X?X(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(X){return this.errorFromContext(X)}errorFromContext(X){let U=new s0(X,this);if(this.currentBranch)this.currentBranch.error=U;else this.errors.add(U);return U}applyQueuedMorphs(){while(this.queuedMorphs.length){let X=this.queuedMorphs;this.queuedMorphs=[];for(let{path:U,morphs:q}of X){if(this.errors.affectsPath(U))continue;this.applyMorphsAtPath(U,q)}}}applyMorphsAtPath(X,U){let q=X[X.length-1],Z;if(q!==void 0){Z=this.root;for(let Q=0;Q<X.length-1;Q++)Z=Z[X[Q]]}for(let Q of U){this.path=[...X];let G=h(Q),Y=Q(Z===void 0?this.root:Z[q],this);if(Y instanceof s0){if(!this.errors.includes(Y))this.errors.add(Y);break}if(Y instanceof H0){if(!G)this.errors.merge(Y);this.queuedMorphs=[];break}if(Z===void 0)this.root=Y;else Z[q]=Y;this.applyQueuedMorphs()}}}var J0=(X,U,q)=>{if(!q)return U();q.path.push(X);let Z=U();return q.path.pop(),Z};class R2 extends Y0{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor(X,U){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:X});this.attachments=X,this.$=U,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)=>jG(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((H)=>Xq(H,Y))){this.flatRefs.push(Y);for(let H of Y.node.branches)if(H.hasKind("morph")||H.hasKind("intersection")&&H.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:Y.path,propString:Y.propString,node:H})}}}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(U,q)=>{if(this.allows(U))return U;let Z=new w0(U,this.$.resolvedConfig);return this.traverseApply(U,Z),Z.finalize(q)};case"contextual":return(U,q)=>{let Z=new w0(U,this.$.resolvedConfig);return this.traverseApply(U,Z),Z.finalize(q)};case"optimistic":this.contextFreeMorph=this.shallowMorphs[0];let X=this.$.resolvedConfig.clone;return(U,q)=>{if(this.allows(U))return this.contextFreeMorph(X&&(typeof U==="object"&&U!==null||typeof U==="function")?X(U):U);let Z=new w0(U,this.$.resolvedConfig);return this.traverseApply(U,Z),Z.finalize(q)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,g(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=bG(this.metaJson);cacheGetter(X,U){return Object.defineProperty(this,X,{value:U}),U}get description(){return this.cacheGetter("description",this.meta?.description??this.$.resolvedConfig[this.kind].description(this))}get references(){return Object.values(this.referencesById)}precedence=E1(this.kind);precompilation;assert=(X,U)=>this(X,U,(q)=>q.throw());traverse(X,U){return this(X,U,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(X){if(!this.includesTransform)return this;let U={};for(let[q,Z]of this.innerEntries){let Q=this.impl.keys[q];if(Q.reduceIo)Q.reduceIo(X,U,Z);else if(Q.child){let G=Z;U[q]=x(G)?G.map((Y)=>X==="in"?Y.rawIn:Y.rawOut):X==="in"?G.rawIn:G.rawOut}else U[q]=Z}return this.$.node(this.kind,U)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals(X){let U=h(X)?X:this.$.parseDefinition(X);return this.innerHash===U.innerHash}ifEquals(X){return this.equals(X)?this:void 0}hasKind(X){return this.kind===X}assertHasKind(X){if(this.kind!==X)Y1(`${this.kind} node was not of asserted kind ${X}`);return this}hasKindIn(...X){return X.includes(this.kind)}assertHasKindIn(...X){if(!z0(X,this.kind))Y1(`${this.kind} node was not one of asserted kinds ${X}`);return this}isBasis(){return z0(sU,this.kind)}isConstraint(){return z0(A6,this.kind)}isStructural(){return z0(N1,this.kind)}isRefinement(){return z0(s4,this.kind)}isRoot(){return z0(C1,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit(X){return this.hasKind("unit")&&this.allows(X)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select(X){let U=T2.normalize(X);return this._select(U)}_select(X){let U=T2.applyBoundary[X.boundary??"references"](this);if(X.kind)U=U.filter((q)=>q.kind===X.kind);if(X.where)U=U.filter(X.where);return T2.applyMethod[X.method??"filter"](U,this,X)}transform(X,U){return this._transform(X,this._createTransformContext(U))}_createTransformContext(X){return{root:this,selected:void 0,seen:{},path:[],parseOptions:{prereduced:X?.prereduced??!1},undeclaredKeyHandling:void 0,...X}}_transform(X,U){let q=U.bindScope??this.$;if(U.seen[this.id])return this.$.lazilyResolve(U.seen[this.id]);if(U.shouldTransform?.(this,U)===!1)return this;let Z;if(U.seen[this.id]=()=>Z,this.hasKind("structure")&&this.undeclared!==U.undeclaredKeyHandling)U={...U,undeclaredKeyHandling:this.undeclared};let Q=S(this.inner,(W,$)=>{if(!this.impl.keys[W].child)return[W,$];let _=$;if(!x(_)){let A=_._transform(X,U);return A?[W,A]:[]}if(_.length===0)return[W,$];let L=_.flatMap((A)=>{return A._transform(X,U)??[]});return L.length?[W,L]:[]});delete U.seen[this.id];let G=Object.assign(Q,{meta:this.meta}),Y=U.selected&&!U.selected.includes(this)?G:X(this.kind,G,U);if(Y===null)return null;if(h(Y))return Z=Y;let H=Object.keys(Y);if((H.length===0||H.length===1&&H[0]==="meta")&&!C0(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in Y))return U.undeclaredKeyHandling?{...Y,value:V.intrinsic.unknown}:null;if(this.kind==="morph")Y.in??=V.intrinsic.unknown;return Z=q.node(this.kind,Y,U.parseOptions)}configureReferences(X,U="references"){let q=T2.normalize(U),Z=typeof X==="string"?(H,J)=>({...J,meta:{...J.meta,description:X}}):typeof X==="function"?(H,J)=>({...J,meta:X(J.meta)}):(H,J)=>({...J,meta:{...J.meta,...X}});if(q.boundary==="self")return this.$.node(this.kind,Z(this.kind,{...this.inner,meta:this.meta}));let Q=this._select(q),G=Q&&p0(Q),Y=q.boundary==="child"?(H,J)=>J.root.children.includes(H):q.boundary==="shallow"?(H)=>H.kind!=="structure":()=>!0;return this.$.finalize(this.transform(Z,{shouldTransform:Y,selected:G}))}}var T2={applyBoundary:{self:(X)=>[X],child:(X)=>[...X.children],shallow:(X)=>[...X.shallowReferences],references:(X)=>[...X.references]},applyMethod:{filter:(X)=>X,assertFilter:(X,U,q)=>{if(X.length===0)Y1(eU(U,q));return X},find:(X)=>X[0],assertFind:(X,U,q)=>{if(X.length===0)Y1(eU(U,q));return X[0]}},normalize:(X)=>typeof X==="function"?{boundary:"references",method:"filter",where:X}:typeof X==="string"?a(X,T2.applyBoundary)?{method:"filter",boundary:X}:{boundary:"references",method:"filter",kind:X}:{boundary:"references",method:"filter",...X}},eU=(X,U)=>`${X} had no references matching ${E(U)}.`,SG=(X)=>k0(X,{stringifyNonKey:(U)=>U.expression}),EG=/"(\$ark\.[^"]+)"/g,bG=(X)=>JSON.stringify(X).replace(EG,"$1"),P0=(X,U)=>({path:X,node:U,propString:SG(X)}),Xq=(X,U)=>X.propString===U.propString&&X.node.equals(U.node),a4=(X,U)=>N0(X,U,{isEqual:Xq}),jG=(X,U)=>N0(X,U,{isEqual:(q,Z)=>q.equals(Z)});class B extends Array{static init(X,U,q,Z){return new B({kind:X,l:U,r:q,path:Z?.path??[],optional:Z?.optional??!1})}add(X,U,q,Z){return this.push({kind:X,l:U,r:q,path:Z?.path??[],optional:Z?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:X,l:U,r:q}=this[0],Z=k0(X);return t4(`Intersection${Z&&` at ${Z}`} of ${Uq(U,q)}`)}return`The following intersections result in unsatisfiable types:
159
+ • ${this.map(({path:X,l:U,r:q})=>`${X}: ${Uq(U,q)}`).join(`
160
+ • `)}`}throw(){return F(this.describeReasons())}invert(){let X=this.map((U)=>({...U,l:U.r,r:U.l}));if(!(X instanceof B))return new B(...X);return X}withPrefixKey(X,U){return this.map((q)=>({...q,path:[X,...q.path],optional:q.optional||U==="optional"}))}toNeverIfDisjoint(){return V.intrinsic.never}}var Uq=(X,U)=>`${n4(X)} and ${n4(U)}`,n4=(X)=>h(X)?X.expression:x(X)?X.map(n4).join(" | ")||"never":String(X),t4=(X)=>`${X} results in an unsatisfiable type`;var b1={},W0=(X,U,q)=>u(X,U,{$:q,invert:!1,pipe:!1}),D2=(X,U,q)=>u(X,U,{$:q,invert:!1,pipe:!0}),u=(X,U,q)=>{let Z=q.pipe?"|>":"&",Q=`${X.hash}${Z}${U.hash}`;if(b1[Q]!==void 0)return b1[Q];if(!q.pipe){let H=`${U.hash}${Z}${X.hash}`;if(b1[H]!==void 0){let J=b1[H],W=J instanceof B?J.invert():J;return b1[Q]=W,W}}let G=!q.pipe||!X.includesTransform&&!U.includesTransform;if(G&&X.equals(U))return X;let Y=G?e4(X,U,q):X.hasKindIn(...C1)?fG(X,U,q):e4(X,U,q);if(h(Y)){if(X.equals(Y))Y=X;else if(U.equals(Y))Y=U}return b1[Q]=Y,Y},e4=(X,U,q)=>{let Z=X.precedence<U.precedence?X.kind:U.kind,Q=X.impl.intersections[U.kind]??U.impl.intersections[X.kind];if(Q===void 0)return null;else if(Z===X.kind)return Q(X,U,q);else{let G=Q(U,X,{...q,invert:!q.invert});if(G instanceof B)G=G.invert();return G}},fG=(X,U,q)=>X.includesTransform||U.includesTransform?q.invert?qq(U,X,q):qq(X,U,q):e4(X,U,q),qq=(X,U,q)=>X.distribute((Z)=>yG(Z,U,q),(Z)=>{let Q=Z.filter(h);if(Q.length===0)return B.init("union",X.branches,U.branches);if(Q.length<X.branches.length||!X.branches.every((H,J)=>H.rawIn.equals(Q[J].rawIn)))return q.$.parseSchema(Q);let G;if(Q.length===1){let H=Q[0];if(!G)return H;return q.$.node("morph",{...H.inner,in:H.rawIn.configure(G,"self")})}let Y={branches:Q};if(G)Y.meta=G;return q.$.parseSchema(Y)}),yG=(X,U,q)=>{if(X.hasKind("morph")){let Q=[...X.morphs];if(X.lastMorphIfNode){let G=u(X.lastMorphIfNode,U,q);if(G instanceof B)return G;Q[Q.length-1]=G}else Q.push(U);return q.$.node("morph",{morphs:Q,in:X.inner.in})}if(U.hasKind("morph")){let Q=u(X,U.rawIn,q);if(Q instanceof B)return Q;return q.$.node("morph",{morphs:[U],in:Q})}return q.$.node("morph",{morphs:[U],in:X})};class A0 extends R2{constructor(X,U){super(X,U);Object.defineProperty(this,U0,{value:"constraint",enumerable:!1})}impliedSiblings;intersect(X){return W0(this,X,this.$)}}class v0 extends A0{traverseApply=(X,U)=>{if(!this.traverseAllows(X,U))U.errorFromNodeContext(this.errorContext)};compile(X){if(X.traversalKind==="Allows")X.return(this.compiledCondition);else X.if(this.compiledNegation,()=>X.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return i0(this.errorContext)}}var X0=(X)=>(U,q)=>{if(x(U)){if(U.length===0)return;let Q=U.map((G)=>q.$.node(X,G));if(X==="predicate")return Q;return Q.sort((G,Y)=>G.hash<Y.hash?-1:1)}let Z=q.$.node(X,U);return Z.hasOpenIntersection()?[Z]:Z},j1=(X)=>{let U=X.r.shift();if(!U){let Z=X.l.length===0&&X.kind==="structure"?V.intrinsic.unknown.internal:X.ctx.$.node(X.kind,Object.assign(X.baseInner,gG(X.l)),{prereduced:!0});for(let Q of X.roots){if(Z instanceof B)return Z;Z=u(Q,Z,X.ctx)}return Z}let q=!1;for(let Z=0;Z<X.l.length;Z++){let Q=u(X.l[Z],U,X.ctx);if(Q===null)continue;if(Q instanceof B)return Q;if(Q.isRoot())return X.roots.push(Q),X.l.splice(Z),j1(X);if(!q)X.l[Z]=Q,q=!0;else if(!X.l.includes(Q))return g(`Unexpectedly encountered multiple distinct intersection results for refinement ${U}`)}if(!q)X.l.push(U);if(X.kind==="intersection"){if(U.impliedSiblings)for(let Z of U.impliedSiblings)N0(X.r,Z)}return j1(X)},f1=(X)=>{return Object.entries(X).flatMap(([q,Z])=>(q in V6)?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)},gG=(X)=>{let U={};for(let q of X)if(q.hasOpenIntersection())U[q.kind]=y(U[q.kind],q);else{if(U[q.kind])return g(`Unexpected intersection of closed refinements of kind ${q.kind}`);U[q.kind]=q}return U},Zq=(...X)=>F(Qq(...X)),Qq=(X,U,q)=>{let Z=q.hasKind("morph")?"a morph":q.isUnknown()?"unknown":q.exclude(U).defaultShortDescription;return`${EU(X)} operand must be ${U.description} (was ${Z})`};var Gq=(X,U,q)=>new o0(X,U,q,q,null);class B6 extends Y0{}class o0 extends Y0{[U0]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor(X,U,q,Z,Q){super((...G)=>{let Y=S(this.names,(H,J)=>{let W=this.arg$.parse(G[H]);if(!W.extends(this.constraints[H]))F(kG(J,this.constraints[H].expression,W.expression));return[J,W]});if(this.defIsLazy()){let H=this.bodyDef(Y);return this.$.parse(H)}return this.$.parse(U,{args:Y})});this.paramDefs=X,this.bodyDef=U,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 B6}cacheGetter(X,U){return Object.defineProperty(this,X,{value:U}),U}get json(){return this.cacheGetter("json",{params:this.params.map((X)=>X[1].isUnknown()?X[0]:[X[0],X[1].json]),body:pU(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map((X)=>typeof X==="string"?[X,V.intrinsic.unknown]:[X[0],this.$.parse(X[1])]))}get names(){return this.cacheGetter("names",this.params.map((X)=>X[0]))}get constraints(){return this.cacheGetter("constraints",this.params.map((X)=>X[1]))}get internal(){return this}get referencesById(){return this.baseInstantiation.internal.referencesById}get references(){return this.baseInstantiation.internal.references}}var kG=(X,U,q)=>`${X} must be assignable to ${U} (was ${q})`;var vG=b({kind:"predicate",hasAssociatedError:!0,collapsibleKey:"predicate",keys:{predicate:{}},normalize:(X)=>typeof X==="function"?{predicate:X}:X,defaults:{description:(X)=>`valid according to ${X.predicate.name||"an anonymous predicate"}`},intersectionIsOpen:!0,intersections:{predicate:()=>null}});class Yq extends A0{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=i0(this.errorContext);traverseApply=(X,U)=>{let q=U.currentErrorCount;if(!this.predicate(X,U.external)&&U.currentErrorCount===q)U.errorFromNodeContext(this.errorContext)};compile(X){if(X.traversalKind==="Allows"){X.return(this.compiledCondition);return}X.initializeErrorCount(),X.if(`${this.compiledNegation} && ctx.currentErrorCount === errorCount`,()=>X.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}reduceJsonSchema(X,U){return U.fallback.predicate({code:"predicate",base:X,predicate:this.predicate})}}var X9={implementation:vG,Node:Yq};var xG=b({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:(X)=>Number.isInteger(X)?X:F(hG(X))}},normalize:(X)=>typeof X==="number"?{rule:X}:X,hasAssociatedError:!0,defaults:{description:(X)=>X.rule===1?"an integer":X.rule===2?"even":`a multiple of ${X.rule}`},intersections:{divisor:(X,U,q)=>q.$.node("divisor",{rule:Math.abs(X.rule*U.rule/uG(X.rule,U.rule))})},obviatesBasisDescription:!0});class Hq extends v0{traverseAllows=(X)=>X%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=V.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema(X){if(X.type="integer",this.rule===1)return X;return X.multipleOf=this.rule,X}}var U9={implementation:xG,Node:Hq};var hG=(X)=>`divisor must be an integer (was ${X})`,uG=(X,U)=>{let q,Z=X,Q=U;while(Q!==0)q=Q,Q=Z%Q,Z=q;return Z};class L0 extends v0{boundOperandKind=dG[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=cG(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${mG[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?iG(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan(X){return(this.limitKind==="upper"?this.numericLimit<X.numericLimit:this.numericLimit>X.numericLimit)||this.numericLimit===X.numericLimit&&this.exclusive===!0&&!X.exclusive}overlapsRange(X){if(this.isStricterThan(X))return!1;if(this.numericLimit===X.numericLimit&&(this.exclusive||X.exclusive))return!1;return!0}overlapIsUnit(X){return this.numericLimit===X.numericLimit&&!this.exclusive&&!X.exclusive}}var mG={"<":">=","<=":">",">":"<=",">=":"<"},pG={min:"max",minLength:"maxLength",after:"before"},T6={parse:(X)=>X||void 0},R6=(X)=>(U)=>{if(typeof U==="number")return{rule:U};let{exclusive:q,...Z}=U;return q?{...Z,rule:X==="minLength"?Z.rule+1:Z.rule-1}:Z},D6=(X)=>(U)=>{if(typeof U==="number"||typeof U==="string"||U instanceof Date)return{rule:U};let{exclusive:q,...Z}=U;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:X==="after"?Q+1:Q-1}:Z},M6=(X)=>typeof X==="string"||typeof X==="number"?new Date(X):X,lG=(X,U)=>`${X} bound must be a positive integer (was ${U})`,y1=(X)=>(U)=>{if(!Number.isInteger(U)||U<0)F(lG(X,U));return U},dG={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},cG=(X,U)=>`${a(X,pG)?">":"<"}${U?"":"="}`,iG=(X)=>typeof X==="string"?X:new Date(X).toLocaleString(),Jq=(X)=>`Bounded expression ${X} must be exactly one of number, string, Array, or Date`;var sG=b({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:M6,serialize:(X)=>X.toISOString()}},normalize:D6("after"),defaults:{description:(X)=>`${X.collapsibleLimitString} or later`,actual:$1},intersections:{after:(X,U)=>X.isStricterThan(U)?X:U}});class Wq extends L0{impliedBasis=V.intrinsic.Date.internal;collapsibleLimitString=$1(this.rule);traverseAllows=(X)=>X>=this.rule;reduceJsonSchema(X,U){return U.fallback.date({code:"date",base:X,after:this.rule})}}var q9={implementation:sG,Node:Wq};var oG=b({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:M6,serialize:(X)=>X.toISOString()}},normalize:D6("before"),defaults:{description:(X)=>`${X.collapsibleLimitString} or earlier`,actual:$1},intersections:{before:(X,U)=>X.isStricterThan(U)?X:U,after:(X,U,q)=>X.overlapsRange(U)?X.overlapIsUnit(U)?q.$.node("unit",{unit:X.rule}):null:B.init("range",X,U)}});class _q extends L0{collapsibleLimitString=$1(this.rule);traverseAllows=(X)=>X<=this.rule;impliedBasis=V.intrinsic.Date.internal;reduceJsonSchema(X,U){return U.fallback.date({code:"date",base:X,before:this.rule})}}var Z9={implementation:oG,Node:_q};var rG=b({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:y1("exactLength")}},normalize:(X)=>typeof X==="number"?{rule:X}:X,hasAssociatedError:!0,defaults:{description:(X)=>`exactly length ${X.rule}`,actual:(X)=>`${X.length}`},intersections:{exactLength:(X,U,q)=>B.init("unit",q.$.node("unit",{unit:X.rule}),q.$.node("unit",{unit:U.rule}),{path:["length"]}),minLength:(X,U)=>X.rule>=U.rule?X:B.init("range",X,U),maxLength:(X,U)=>X.rule<=U.rule?X:B.init("range",X,U)}});class $q extends v0{traverseAllows=(X)=>X.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=V.intrinsic.lengthBoundable.internal;expression=`== ${this.rule}`;reduceJsonSchema(X){switch(X.type){case"string":return X.minLength=this.rule,X.maxLength=this.rule,X;case"array":return X.minItems=this.rule,X.maxItems=this.rule,X;default:return p.throwInternalOperandError("exactLength",X)}}}var Q9={implementation:rG,Node:$q};var aG=b({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:T6},normalize:(X)=>typeof X==="number"?{rule:X}:X,defaults:{description:(X)=>{if(X.rule===0)return X.exclusive?"negative":"non-positive";return`${X.exclusive?"less than":"at most"} ${X.rule}`}},intersections:{max:(X,U)=>X.isStricterThan(U)?X:U,min:(X,U,q)=>X.overlapsRange(U)?X.overlapIsUnit(U)?q.$.node("unit",{unit:X.rule}):null:B.init("range",X,U)},obviatesBasisDescription:!0});class Lq extends L0{impliedBasis=V.intrinsic.number.internal;traverseAllows=this.exclusive?(X)=>X<this.rule:(X)=>X<=this.rule;reduceJsonSchema(X){if(this.exclusive)X.exclusiveMaximum=this.rule;else X.maximum=this.rule;return X}}var G9={implementation:aG,Node:Lq};var nG=b({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:y1("maxLength")}},reduce:(X,U)=>X.rule===0?U.node("exactLength",X):void 0,normalize:R6("maxLength"),defaults:{description:(X)=>`at most length ${X.rule}`,actual:(X)=>`${X.length}`},intersections:{maxLength:(X,U)=>X.isStricterThan(U)?X:U,minLength:(X,U,q)=>X.overlapsRange(U)?X.overlapIsUnit(U)?q.$.node("exactLength",{rule:X.rule}):null:B.init("range",X,U)}});class zq extends L0{impliedBasis=V.intrinsic.lengthBoundable.internal;traverseAllows=(X)=>X.length<=this.rule;reduceJsonSchema(X){switch(X.type){case"string":return X.maxLength=this.rule,X;case"array":return X.maxItems=this.rule,X;default:return p.throwInternalOperandError("maxLength",X)}}}var Y9={implementation:nG,Node:zq};var tG=b({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:T6},normalize:(X)=>typeof X==="number"?{rule:X}:X,defaults:{description:(X)=>{if(X.rule===0)return X.exclusive?"positive":"non-negative";return`${X.exclusive?"more than":"at least"} ${X.rule}`}},intersections:{min:(X,U)=>X.isStricterThan(U)?X:U},obviatesBasisDescription:!0});class Fq extends L0{impliedBasis=V.intrinsic.number.internal;traverseAllows=this.exclusive?(X)=>X>this.rule:(X)=>X>=this.rule;reduceJsonSchema(X){if(this.exclusive)X.exclusiveMinimum=this.rule;else X.minimum=this.rule;return X}}var H9={implementation:tG,Node:Fq};var eG=b({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:y1("minLength")}},reduce:(X)=>X.rule===0?V.intrinsic.unknown:void 0,normalize:R6("minLength"),defaults:{description:(X)=>X.rule===1?"non-empty":`at least length ${X.rule}`,actual:(X)=>X.length===0?"":`${X.length}`},intersections:{minLength:(X,U)=>X.isStricterThan(U)?X:U}});class Aq extends L0{impliedBasis=V.intrinsic.lengthBoundable.internal;traverseAllows=(X)=>X.length>=this.rule;reduceJsonSchema(X){switch(X.type){case"string":return X.minLength=this.rule,X;case"array":return X.minItems=this.rule,X;default:return p.throwInternalOperandError("minLength",X)}}}var J9={implementation:eG,Node:Aq};var Vq={min:H9.implementation,max:G9.implementation,minLength:J9.implementation,maxLength:Y9.implementation,exactLength:Q9.implementation,after:q9.implementation,before:Z9.implementation},Oq={min:H9.Node,max:G9.Node,minLength:J9.Node,maxLength:Y9.Node,exactLength:Q9.Node,after:q9.Node,before:Z9.Node};var X5=b({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:(X)=>typeof X==="string"?{rule:X}:X instanceof RegExp?X.flags?{rule:X.source,flags:X.flags}:{rule:X.source}:X,obviatesBasisDescription:!0,obviatesBasisExpression:!0,hasAssociatedError:!0,intersectionIsOpen:!0,defaults:{description:(X)=>`matched by ${X.rule}`},intersections:{pattern:()=>null}});class Bq extends v0{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=V.intrinsic.string.internal;reduceJsonSchema(X,U){if(X.pattern)return U.fallback.patternIntersection({code:"patternIntersection",base:X,pattern:this.rule});return X.pattern=this.rule,X}}var W9={implementation:X5,Node:Bq};var M2=(X,U)=>{let q=U5(X);if(U&&!U.includes(q))return F(`Root of kind ${q} should be one of ${U}`);return q},U5=(X)=>{if(M(X,"root"))return X.kind;if(typeof X==="string")return X[0]==="$"?"alias":(X in Q0)?"domain":"proto";if(typeof X==="function")return"proto";if(typeof X!=="object"||X===null)return F(Tq(X));if("morphs"in X)return"morph";if("branches"in X||x(X))return"union";if("unit"in X)return"unit";if("reference"in X)return"alias";let U=Object.keys(X);if(U.length===0||U.some((q)=>(q in V6)))return"intersection";if("proto"in X)return"proto";if("domain"in X)return"domain";return F(Tq(X))},Tq=(X)=>`${E(X)} is not a valid type schema`,Rq={},q5=(X)=>x(X)?X.map((U)=>U.collapsibleJson):X.collapsibleJson,q0={};V.nodesByRegisteredId=q0;var _9=(X)=>{return Rq[X]??=0,`${X}${++Rq[X]}`},$9=(X)=>{let U=g1[X.kind],q=U.applyConfig?.(X.def,X.$.resolvedConfig)??X.def,Z={},{meta:Q,...G}=q,Y=Q===void 0?{}:typeof Q==="string"?{description:Q}:Q,H=y4(G).sort(([W],[$])=>S1(W)?S1($)?E1(W)-E1($):1:S1($)?-1:W<$?-1:1).filter(([W,$])=>{if(W.startsWith("meta.")){let _=W.slice(5);return Y[_]=$,!1}return!0});for(let W of H){let $=W[0],_=U.keys[$];if(!_)return F(`Key ${$} is not valid on ${X.kind} schema`);let L=_.parse?_.parse(W[1],X):W[1];if(L!==G0&&(L!==void 0||_.preserveUndefined))Z[$]=L}if(U.reduce&&!X.prereduced){let W=U.reduce(Z,X.$);if(W){if(W instanceof B)return W.throw();return Z5(W,Y)}}return L9({id:X.id,kind:X.kind,inner:Z,meta:Y,$:X.$})},L9=({id:X,kind:U,inner:q,meta:Z,$:Q,ignoreCache:G})=>{let Y=g1[U],H=y4(q),J=[],W={};for(let[D,P]of H){let K=Y.keys[D],C=K.serialize??(K.child?q5:F0);if(W[D]=C(P),K.child===!0){let N=P;if(x(N))J.push(...N);else J.push(N)}else if(typeof K.child==="function")J.push(...K.child(P))}if(Y.finalizeInnerJson)W=Y.finalizeInnerJson(W);let $={...W},_={};if(!C0(Z))_=S(Z,(D,P)=>[D,D==="examples"?P:F0(P)]),$.meta=w6(_,"description",!0);W=w6(W,Y.collapsibleKey,!1);let L=JSON.stringify({kind:U,...W});$=w6($,Y.collapsibleKey,!1);let A=w6($,Y.collapsibleKey,!0),T=JSON.stringify({kind:U,...$});if(Q.nodesByHash[T]&&!G)return Q.nodesByHash[T];let z={id:X,kind:U,impl:Y,inner:q,innerEntries:H,innerJson:W,innerHash:L,meta:Z,metaJson:_,json:$,hash:T,collapsibleJson:A,children:J};if(U!=="intersection"){for(let D in q)if(D!=="in"&&D!=="out")z[D]=q[D]}let O=new Mq[U](z,Q);return Q.nodesByHash[T]=O},Dq=(X,U)=>{if(X.id===U)return X;if(h(q0[U]))g(`Unexpected attempt to overwrite node id ${U}`);return L9({id:U,kind:X.kind,inner:X.inner,meta:X.meta,$:X.$,ignoreCache:!0})},Z5=(X,U,q)=>{if(q&&h(q0[q]))g(`Unexpected attempt to overwrite node id ${q}`);return L9({id:q??_9(U.alias??X.kind),kind:X.kind,inner:X.inner,meta:U,$:X.$})},w6=(X,U,q)=>{let Z=Object.keys(X);if(Z.length===1&&Z[0]===U){let Q=X[U];if(q)return Q;if(Z0(Q,"object")&&(Object.keys(Q).length===1||Array.isArray(Q)))return Q}return X};var w2=(X,U,q)=>{if(X.key!==U.key)return null;let Z=X.key,Q=u(X.value,U.value,q),G=X.required||U.required?"required":"optional";if(Q instanceof B)if(G==="optional")Q=V.intrinsic.never.internal;else return Q.withPrefixKey(X.key,X.required&&U.required?"required":"optional");if(G==="required")return q.$.node("required",{key:Z,value:Q});let Y=X.hasDefault()?U.hasDefault()?X.default===U.default?X.default:F(z9(X.default,U.default)):X.default:U.hasDefault()?U.default:G0;return q.$.node("optional",{key:Z,value:Q,default:Y})};class P2 extends A0{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=V.intrinsic.object.internal;serializedKey=M0(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=y(this.value.flatRefs.map((X)=>P0([this.key,...X.path],X.node)),P0([this.key],this.value));_transform(X,U){U.path.push(this.key);let q=super._transform(X,U);return U.path.pop(),q}hasDefault(){return"default"in this.inner}traverseAllows=(X,U)=>{if(this.key in X)return J0(this.key,()=>this.value.traverseAllows(X[this.key],U),U);return this.optional};traverseApply=(X,U)=>{if(this.key in X)J0(this.key,()=>this.value.traverseApply(X[this.key],U),U);else if(this.hasKind("required"))U.errorFromNodeContext(this.errorContext)};compile(X){if(X.if(`${this.serializedKey} in data`,()=>X.traverseKey(this.serializedKey,`data${X.prop(this.key)}`,this.value)),this.hasKind("required"))X.else(()=>X.traversalKind==="Apply"?X.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`):X.return(!1));if(X.traversalKind==="Allows")X.return(!0)}}var z9=(X,U)=>`Invalid intersection of default values ${E(X)} & ${E(U)}`;var Q5=b({kind:"optional",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(X,U)=>U.$.parseSchema(X)},default:{preserveUndefined:!0}},normalize:(X)=>X,reduce:(X,U)=>{if(U.resolvedConfig.exactOptionalPropertyTypes===!1){if(!X.value.allows(void 0))return U.node("optional",{...X,value:X.value.or(I.undefined)},{prereduced:!0})}},defaults:{description:(X)=>`${X.compiledKey}?: ${X.value.description}`},intersections:{optional:w2}});class wq extends P2{constructor(...X){super(...X);if("default"in this.inner)K2(this.value,this.inner.default,this.key)}get rawIn(){let X=super.rawIn;if(!this.hasDefault())return X;return this.$.node("optional",W6(X.inner,{default:!0}),{prereduced:!0})}get outProp(){if(!this.hasDefault())return this;let{default:X,...U}=this.inner;return this.cacheGetter("outProp",this.$.node("required",U,{prereduced:!0}))}expression=this.hasDefault()?`${this.compiledKey}: ${this.value.expression} = ${E(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=Y5(this);defaultValueMorphRef=this.defaultValueMorph&&d(this.defaultValueMorph)}var I2={implementation:Q5,Node:wq},G5={},Y5=(X)=>{if(!X.hasDefault())return;let U=`{${X.compiledKey}: ${X.value.id} = ${F0(X.default)}}`;return G5[U]??=F9(X.key,X.value,X.default)},F9=(X,U,q)=>{if(typeof q==="function")return U.includesTransform?(Q,G)=>{return J0(X,()=>U(Q[X]=q(),G),G),Q}:(Q)=>{return Q[X]=q(),Q};let Z=U.includesTransform?U.assert(q):q;return Z0(Z,"object")?(Q,G)=>{return J0(X,()=>U(Q[X]=q,G),G),Q}:(Q)=>{return Q[X]=Z,Q}},K2=(X,U,q)=>{let Z=l0(U);if(Z0(U,"object")&&!Z)F(H5(q));let Q=X.in(Z?U():U);if(Q instanceof H0){if(q===null)F(`Default ${Q.summary}`);let G=Q.transform((Y)=>Y.transform((H)=>({...H,prefixPath:[q]})));F(`Default for ${G.summary}`)}return U},H5=(X)=>{return`Non-primitive default ${X===null?"":typeof X==="number"?`for value at [${X}] `:`for ${M0(X)} `}must be specified as a function like () => ({my: 'object'})`};class V0 extends R2{constructor(X,U){super(X,U);Object.defineProperty(this,U0,{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:(X)=>{let U=this(X);if(U instanceof H0)return U;return{value:U}},jsonSchema:{input:(X)=>this.rawIn.toJsonSchema({target:Pq(X.target),...X.libraryOptions}),output:(X)=>this.rawOut.toJsonSchema({target:Pq(X.target),...X.libraryOptions})}}}as(){return this}brand(X){if(X==="")return F(J5);return this}readonly(){return this}branches=this.hasKind("union")?this.inner.branches:[this];distribute(X,U){let q=this.branches.map(X);return U?.(q)??q}get shortDescription(){return this.meta.description??this.defaultShortDescription}toJsonSchema(X={}){let U=o4(this.$.resolvedConfig.toJsonSchema,X);U.useRefs||=this.isCyclic;let q=typeof U.dialect==="string"?{$schema:U.dialect}:{};if(Object.assign(q,this.toJsonSchemaRecurse(U)),U.useRefs){let Z=S(this.references,(Q,G)=>G.isRoot()&&!G.alwaysExpandJsonSchema?[G.id,G.toResolvedJsonSchema(U)]:[]);if(U.target==="draft-07")Object.assign(q,{definitions:Z});else q.$defs=Z}return q}toJsonSchemaRecurse(X){if(X.useRefs&&!this.alwaysExpandJsonSchema)return{$ref:`#/${X.target==="draft-07"?"definitions":"$defs"}/${this.id}`};return this.toResolvedJsonSchema(X)}get alwaysExpandJsonSchema(){return this.isBasis()||this.kind==="alias"||this.hasKind("union")&&this.isBoolean}toResolvedJsonSchema(X){let U=this.innerToJsonSchema(X);return Object.assign(U,this.metaJson)}intersect(X){let U=this.$.parseDefinition(X),q=this.rawIntersect(U);if(q instanceof B)return q;return this.$.finalize(q)}rawIntersect(X){return W0(this,X,this.$)}toNeverIfDisjoint(){return this}and(X){let U=this.intersect(X);return U instanceof B?U.throw():U}rawAnd(X){let U=this.rawIntersect(X);return U instanceof B?U.throw():U}or(X){let U=this.$.parseDefinition(X);return this.$.finalize(this.rawOr(U))}rawOr(X){let U=[...this.branches,...X.branches];return this.$.node("union",U)}map(X){return this.$.schema(this.applyStructuralOperation("map",[X]))}pick(...X){return this.$.schema(this.applyStructuralOperation("pick",X))}omit(...X){return this.$.schema(this.applyStructuralOperation("omit",X))}required(){return this.$.schema(this.applyStructuralOperation("required",[]))}partial(){return this.$.schema(this.applyStructuralOperation("partial",[]))}_keyof;keyof(){if(this._keyof)return this._keyof;let X=this.applyStructuralOperation("keyof",[]).reduce((U,q)=>U.intersect(q).toNeverIfDisjoint(),V.intrinsic.unknown.internal);if(X.branches.length===0)F(t4(`keyof ${this.expression}`));return this._keyof=this.$.finalize(X)}get props(){if(this.branches.length!==1)return F(_5(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge(X){let U=this.$.parseDefinition(X);return this.$.schema(U.distribute((q)=>this.applyStructuralOperation("merge",[Iq(q)??F(Kq("merge",q.expression))])))}applyStructuralOperation(X,U){return this.distribute((q)=>{if(q.equals(V.intrinsic.object)&&X!=="merge")return q;let Z=Iq(q);if(!Z)F(Kq(X,q.expression));if(X==="keyof")return Z.keyof();if(X==="get")return Z.get(...U);if(X==="props")return Z.props;let Q=X==="required"?"require":X==="partial"?"optionalize":X;return this.$.node("intersection",{domain:"object",structure:Z[Q](...U)})})}get(...X){if(X[0]===void 0)return this;return this.$.schema(this.applyStructuralOperation("get",X))}extract(X){let U=this.$.parseDefinition(X);return this.$.schema(this.branches.filter((q)=>q.extends(U)))}exclude(X){let U=this.$.parseDefinition(X);return this.$.schema(this.branches.filter((q)=>!q.extends(U)))}array(){return this.$.schema(this.isUnknown()?{proto:Array}:{proto:Array,sequence:this},{prereduced:!0})}overlaps(X){return!(this.intersect(X)instanceof B)}extends(X){if(this.isNever())return!0;let U=this.intersect(X);return!(U instanceof B)&&this.equals(U)}ifExtends(X){return this.extends(X)?this:void 0}subsumes(X){return this.$.parseDefinition(X).extends(this)}configure(X,U="shallow"){return this.configureReferences(X,U)}describe(X,U="shallow"){return this.configure({description:X},U)}optional(){return[this,"?"]}default(X){return K2(this,X,null),[this,"=",X]}from(X){return this.assert(X)}_pipe(...X){let U=X.reduce((q,Z)=>q.rawPipeOnce(Z),this);return this.$.finalize(U)}tryPipe(...X){let U=X.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=T2(this,U,this.$);if(X instanceof V)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 nX(X,Z.impliedBasis,this);let G=this.$.node("intersection",{[Z.kind]:Z}),Y=U==="out"?T2(this,G,this.$):L0(this,G,this.$);if(Y instanceof V)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"?G6(Q,{undeclared:1}):{...Q,undeclared:X}:Q,q?void 0:{shouldTransform:(Z)=>!z0(K1,Z.kind)}))}hasEqualMorphs(U){if(!this.includesTransform&&!U.includesTransform)return!0;if(!g0(this.shallowMorphs,U.shallowMorphs))return!1;if(!g0(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",y1(U))}lessThan(U){return this.constrain("max",y1(U))}atLeastLength(U){return this.constrain("minLength",U)}atMostLength(U){return this.constrain("maxLength",U)}moreThanLength(U){return this.constrain("minLength",y1(U))}lessThanLength(U){return this.constrain("maxLength",y1(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",y1(U))}earlierThan(U){return this.constrain("before",y1(U))}}var q5="Expected a non-empty brand name after #",Rq=["draft-2020-12","draft-07"],Z5=(U)=>`JSONSchema target '${U}' is not supported (must be ${Rq.map((X)=>`"${X}"`).join(" or ")})`,Oq=(U)=>{if(!z0(Rq,U))F(Z5(U));return U},y1=(U)=>typeof U==="object"&&!(U instanceof Date)?{...U,exclusive:!0}:{rule:U,exclusive:!0},M2=(U,X)=>M(X,"root")?M(U,"root")?U.extends(X):X.allows(U):M(U,"root")?U.hasUnit(X):X===U,Vq=(U)=>{if(U.hasKind("morph"))return null;if(U.hasKind("intersection"))return U.inner.structure??(U.basis?.domain==="object"?U.$.bindReference(T.intrinsic.emptyStructure):null);if(U.isBasis()&&U.domain==="object")return U.$.bindReference(T.intrinsic.emptyStructure);return null},Q5=(U)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
163
- ${U}`,Bq=(U,X)=>`${U} operand must be an object (was ${X})`;var S0=(U,X)=>S(z6(U),(q,Z)=>[Z,X]);var G5=(U)=>typeof U==="string"?{reference:U}:U,Dq=(U)=>U instanceof V?T.intrinsic.never.internal:U,Y5=b({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:(U)=>U.startsWith("$")?U:`$ark.${U}`},resolve:{}},normalize:G5,defaults:{description:(U)=>U.reference},intersections:{alias:(U,X,q)=>q.$.lazilyResolve(()=>Dq(u(U.resolution,X.resolution,q)),`${U.reference}${q.pipe?"=>":"&"}${X.reference}`),...S0("alias",(U,X,q)=>{if(X.isUnknown())return U;if(X.isNever())return X;if(X.isBasis()&&!X.overlaps(T.intrinsic.object))return V.init("assignability",T.intrinsic.object,X);return q.$.lazilyResolve(()=>Dq(u(U.resolution,X,q)),`${U.reference}${q.pipe?"=>":"&"}${X.id}`)})}});class Mq extends T0{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(H5(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(U)}pipe=Object.assign(this._pipe.bind(this),{try:this.tryPipe.bind(this)});to(X){return this.$.finalize(this.toNode(this.$.parseDefinition(X)))}toNode(X){let U=D2(this,X,this.$);if(U instanceof B)return U.throw();return U}rawPipeOnce(X){if(M(X,"root"))return this.toNode(X);return this.distribute((U)=>U.hasKind("morph")?this.$.node("morph",{in:U.inner.in,morphs:[...U.morphs,X]}):this.$.node("morph",{in:U,morphs:[X]}),this.$.parseSchema)}narrow(X){return this.constrainOut("predicate",X)}constrain(X,U){return this._constrain("root",X,U)}constrainIn(X,U){return this._constrain("in",X,U)}constrainOut(X,U){return this._constrain("out",X,U)}_constrain(X,U,q){let Z=this.$.node(U,q);if(Z.isRoot())return Z.isUnknown()?this:g(`Unexpected constraint node ${Z}`);let Q=X==="root"?this:X==="in"?this.rawIn:this.rawOut;if(Q.hasKind("morph")||Z.impliedBasis&&!Q.extends(Z.impliedBasis))return Zq(U,Z.impliedBasis,this);let G=this.$.node("intersection",{[Z.kind]:Z}),Y=X==="out"?D2(this,G,this.$):W0(this,G,this.$);if(Y instanceof B)Y.throw();return this.$.finalize(Y)}onUndeclaredKey(X){let U=typeof X==="string"?X:X.rule,q=typeof X==="string"?!1:X.deep;return this.$.finalize(this.transform((Z,Q)=>Z==="structure"?U==="ignore"?W6(Q,{undeclared:1}):{...Q,undeclared:U}:Q,q?void 0:{shouldTransform:(Z)=>!z0(N1,Z.kind)}))}hasEqualMorphs(X){if(!this.includesTransform&&!X.includesTransform)return!0;if(!y0(this.shallowMorphs,X.shallowMorphs))return!1;if(!y0(this.flatMorphs,X.flatMorphs,{isEqual:(U,q)=>U.propString===q.propString&&(U.node.hasKind("morph")&&q.node.hasKind("morph")?U.node.hasEqualMorphs(q.node):U.node.hasKind("intersection")&&q.node.hasKind("intersection")?U.node.structure?.structuralMorphRef===q.node.structure?.structuralMorphRef:!1)}))return!1;return!0}onDeepUndeclaredKey(X){return this.onUndeclaredKey({rule:X,deep:!0})}filter(X){return this.constrainIn("predicate",X)}divisibleBy(X){return this.constrain("divisor",X)}matching(X){return this.constrain("pattern",X)}atLeast(X){return this.constrain("min",X)}atMost(X){return this.constrain("max",X)}moreThan(X){return this.constrain("min",k1(X))}lessThan(X){return this.constrain("max",k1(X))}atLeastLength(X){return this.constrain("minLength",X)}atMostLength(X){return this.constrain("maxLength",X)}moreThanLength(X){return this.constrain("minLength",k1(X))}lessThanLength(X){return this.constrain("maxLength",k1(X))}exactlyLength(X){return this.constrain("exactLength",X)}atOrAfter(X){return this.constrain("after",X)}atOrBefore(X){return this.constrain("before",X)}laterThan(X){return this.constrain("after",k1(X))}earlierThan(X){return this.constrain("before",k1(X))}}var J5="Expected a non-empty brand name after #",Nq=["draft-2020-12","draft-07"],W5=(X)=>`JSONSchema target '${X}' is not supported (must be ${Nq.map((U)=>`"${U}"`).join(" or ")})`,Pq=(X)=>{if(!z0(Nq,X))F(W5(X));return X},k1=(X)=>typeof X==="object"&&!(X instanceof Date)?{...X,exclusive:!0}:{rule:X,exclusive:!0},N2=(X,U)=>M(U,"root")?M(X,"root")?X.extends(U):U.allows(X):M(X,"root")?X.hasUnit(U):U===X,Iq=(X)=>{if(X.hasKind("morph"))return null;if(X.hasKind("intersection"))return X.inner.structure??(X.basis?.domain==="object"?X.$.bindReference(V.intrinsic.emptyStructure):null);if(X.isBasis()&&X.domain==="object")return X.$.bindReference(V.intrinsic.emptyStructure);return null},_5=(X)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
163
+ ${X}`,Kq=(X,U)=>`${X} operand must be an object (was ${U})`;var S0=(X,U)=>S(O6(X),(q,Z)=>[Z,U]);var $5=(X)=>typeof X==="string"?{reference:X}:X,Cq=(X)=>X instanceof B?V.intrinsic.never.internal:X,L5=b({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:(X)=>X.startsWith("$")?X:`$ark.${X}`},resolve:{}},normalize:$5,defaults:{description:(X)=>X.reference},intersections:{alias:(X,U,q)=>q.$.lazilyResolve(()=>Cq(u(X.resolution,U.resolution,q)),`${X.reference}${q.pipe?"=>":"&"}${U.reference}`),...S0("alias",(X,U,q)=>{if(U.isUnknown())return X;if(U.isNever())return U;if(U.isBasis()&&!U.overlaps(V.intrinsic.object))return B.init("assignability",V.intrinsic.object,U);return q.$.lazilyResolve(()=>Cq(u(X.resolution,U,q)),`${X.reference}${q.pipe?"=>":"&"}${U.id}`)})}});class Sq extends V0{expression=this.reference;structure=void 0;get resolution(){let X=this._resolve();return q0[this.id]=X}_resolve(){if(this.resolve)return this.resolve();if(this.reference[0]==="$")return this.$.resolveRoot(this.reference.slice(1));let X=this.reference,U=q0[X],q=[];while(M(U,"context")){if(q.includes(U.id))return F(z5(U.id,q));q.push(U.id),U=q0[U.id]}if(!M(U,"root"))return g(`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 G0.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 H5=(U,X)=>`Alias '${U}' has a shallow resolution cycle: ${[...X,U].join("->")}`,w2={implementation:Y5,Node:Mq};class _1 extends T0{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 i0(this.errorContext)}compile(U){if(U.traversalKind==="Allows")U.return(this.compiledCondition);else U.if(this.compiledNegation,()=>U.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}}var J5=b({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:(U)=>typeof U==="string"?{domain:U}:P1(U,"numberAllowsNaN")&&U.domain!=="number"?F(R6.writeBadAllowNanMessage(U.domain)):U,applyConfig:(U,X)=>U.numberAllowsNaN===void 0&&U.domain==="number"&&X.numberAllowsNaN?{...U,numberAllowsNaN:!0}:U,defaults:{description:(U)=>G0[U.domain],actual:(U)=>Number.isNaN(U)?"NaN":G0[r(U)]},intersections:{domain:(U,X)=>U.domain==="number"&&X.domain==="number"?U.numberAllowsNaN?X:U:V.init("domain",U,X)}});class wq extends _1{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 G0[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 R6={implementation:J5,Node:wq,writeBadAllowNanMessage:(U)=>`numberAllowsNaN may only be specified with domain "number" (was ${U})`};var W5=b({kind:"intersection",hasAssociatedError:!0,normalize:(U)=>{if(h(U))return U;let{structure:X,...q}=U,Z=!!X,Q=X??{},G=S(q,(Y,H)=>{if(n(Y,mX)){if(Z)F(`Flattened structure key ${Y} cannot be specified alongside a root 'structure' key.`);return Q[Y]=H,[]}return[Y,H]});if(M(Q,"constraint")||!C0(Q))G.structure=Q;return G},finalizeInnerJson:({structure:U,...X})=>Q0(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:U0("divisor")},max:{child:!0,parse:U0("max")},min:{child:!0,parse:U0("min")},maxLength:{child:!0,parse:U0("maxLength")},minLength:{child:!0,parse:U0("minLength")},exactLength:{child:!0,parse:U0("exactLength")},before:{child:!0,parse:U0("before")},after:{child:!0,parse:U0("after")},pattern:{child:!0,parse:U0("pattern")},predicate:{child:!0,parse:U0("predicate")}},reduce:(U,X)=>Pq({},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
- ◦ `)}`,problem:(U)=>`(${U.actual}) must be...
167
- ${U.expected}`},intersections:{intersection:(U,X,q)=>Pq(U.inner,X.inner,q),...S0("intersection",(U,X,q)=>{if(U.children.length===0)return X;let{domain:Z,proto:Q,...G}=U.inner,Y=Q??Z,H=Y?u(Y,X,q):X;return H instanceof V?H:U?.basis?.equals(H)?U:U.$.node("intersection",{...G,[H.kind]:H},{prereduced:!0})})}});class Iq extends T0{basis=this.inner.domain??this.inner.proto??null;prestructurals=[];refinements=this.children.filter((U)=>{if(!U.isRefinement())return!1;if(z0(u4,U.kind))this.prestructurals.push(U);return!0});structure=this.inner.structure;expression=L5(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 W9={implementation:W5,Node:Iq},L5=(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"},Pq=(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 V)return Y;if(Y)Z[Y.kind]=Y;return b1({kind:"intersection",baseInner:Z,l:j1(U),r:j1(X),roots:[],ctx:q})};var _5=b({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:(U,X)=>X.$.parseSchema(U)},morphs:{parse:p0,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($5(U.expression,X.expression));let Z=u(U.rawIn,X.rawIn,q);if(Z instanceof V)return Z;let Q={morphs:U.morphs};if(U.declaredIn||X.declaredIn){let G=u(U.rawIn,X.rawIn,q);if(G instanceof V)return G.throw();else Q.declaredIn=G}if(U.declaredOut||X.declaredOut){let G=u(U.rawOut,X.rawOut,q);if(G instanceof V)return G.throw();else Q.declaredOut=G}return Z.distribute((G)=>q.$.node("morph",{...Q,in:G}),q.$.parseSchema)},...S0("morph",(U,X,q)=>{let Z=U.inner.in?u(U.inner.in,X,q):X;return Z instanceof V?Z:Z.equals(U.inner.in)?U:q.$.node("morph",{...U.inner,in:Z})})}});class Kq extends T0{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??T.intrinsic.unknown.internal}get rawOut(){return this.declaredOut??this.introspectableOut??T.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 g0(this.morphs,U.morphs,{isEqual:(X,q)=>X===q||M(X,"root")&&M(q,"root")&&X.equals(q)})}}var L9={implementation:_5,Node:Kq},$5=(U,X)=>`The intersection of distinct morphs at a single path is indeterminate:
168
- Left: ${U}
169
- Right: ${X}`;var z5=b({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:(U)=>G2(U)??F0(U)},dateAllowsInvalid:{}},normalize:(U)=>{let X=typeof U==="string"?{proto:H1[U]}:typeof U==="function"?h(U)?U:{proto:U}:typeof U.proto==="string"?{...U,proto:H1[U.proto]}:U;if(typeof X.proto!=="function")F(P2.writeInvalidSchemaMessage(X.proto));if(P1(X,"dateAllowsInvalid")&&X.proto!==Date)F(P2.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?TX[U.builtinName]:`an instance of ${U.proto.name}`,actual:(U)=>U instanceof Date&&U.toString()==="Invalid Date"?"an invalid Date":Q2(U)},intersections:{proto:(U,X)=>U.proto===Date&&X.proto===Date?U.dateAllowsInvalid?X:U:f4(U.proto,X.proto)?U:f4(X.proto,U.proto)?X:V.init("proto",U,X),domain:(U,X)=>X.domain==="object"?U:V.init("domain",T.intrinsic.object.internal,X)}});class Nq extends _1{builtinName=G2(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 P2={implementation:z5,Node:Nq,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 F5=b({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((H)=>H.hasKind("morph")&&H.hasEqualMorphs(G));if(Y===-1)q.push(G);else{let H=q[Y];q[Y]=X.$.node("morph",{...H.inner,in:H.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)=>x(U)?{branches:U}:U,reduce:(U,X)=>{let q=P5(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,k1),expected:(U)=>{let X=JX(U.errors,"propString"),q=Object.entries(X).map(([Z,Q])=>{let G=[];for(let J of Q)N0(G,J.expected);let Y=k1(G),H=Q.every((J)=>J.actual===Q[0].actual)?Q[0].actual:E(Q[0].data);return`${Z&&`${Z} `}must be ${Y}${H&&` (was ${H})`}`});return k1(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 V.init("presence",U,X);let Z;if(U.ordered){if(X.ordered)F(K5(U.expression,X.expression));if(Z=_9(X.branches,U.branches,q),Z instanceof V)Z.invert()}else Z=_9(U.branches,X.branches,q);if(Z instanceof V)return Z;return q.$.parseSchema(U.ordered||X.ordered?{branches:Z,ordered:!0}:{branches:Z})},...S0("union",(U,X,q)=>{let Z=_9(U.branches,[X],q);if(Z instanceof V)return Z;if(Z.length===1)return Z[0];return q.$.parseSchema(U.ordered?{branches:Z,ordered:!0}:{branches:Z})})}});class Eq extends T0{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]=T.intrinsic.boolean;continue}U.push(q)}return U}unitBranches=this.branches.filter((U)=>U.rawIn.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?D5(this.discriminant):null;expression=this.distribute((U)=>U.nestableExpression,w5);createBranchedOptimisticRootApply(){return(U,X)=>{let q=this.traverseOptimistic(U);if(q!==Y0)return q;let Z=new M0(U,this.$.resolvedConfig);return this.traverseApply(U,Z),Z.finalize(X)}}get shallowMorphs(){return this.branches.reduce((U,X)=>N0(U,X.shallowMorphs),[])}get defaultShortDescription(){return this.distribute((U)=>U.defaultShortDescription,k1)}innerToJsonSchema(U){if(this.branchGroups.length===1&&this.branchGroups[0].equals(T.intrinsic.boolean))return{type:"boolean"};let X=this.branchGroups.map((q)=>q.toJsonSchemaRecurse(U));if(X.every((q)=>Object.keys(q).length===1&&P1(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 Y0};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],L=W==="default"?W:`case ${W}`,$;if(_===!0)$=Q?"data":"true";else if(Q)if(_.rootApplyStrategy==="branchedOptimistic")$=U.invoke(_,{kind:"Optimistic"});else if(_.contextFreeMorph)$=`${U.invoke(_)} ? ${d(_.contextFreeMorph)}(data) : "${Y0}"`;else $=`${U.invoke(_)} ? data : "${Y0}"`;else $=U.invoke(_);U.line(`${L}: return ${$}`)}return U}),U.traversalKind==="Allows"){U.return(Q?`"${Y0}"`:!1);return}let G=k1(this.discriminant.kind==="domain"?Z.map((W)=>{let _=W.slice(1,-1);return _==="function"?G0.object:G0[_]}):Z),Y=this.discriminant.path.map((W)=>typeof W==="symbol"?d(W):JSON.stringify(W)),H=JSON.stringify(G),J=this.discriminant.kind==="domain"?`${B5}[${X}]`:`${R5}(${X})`;U.line(`ctx.errorFromNodeContext({
165
+ Resolution: ${E(U)}`);return U}get resolutionId(){if(this.reference.includes("&")||this.reference.includes("=>"))return this.resolution.id;if(this.reference[0]!=="$")return this.reference;let X=this.reference.slice(1),U=this.$.resolutions[X];if(typeof U==="string")return U;if(M(U,"root"))return U.id;return g(`Unexpected resolution for reference ${this.reference}: ${E(U)}`)}get defaultShortDescription(){return Q0.object}innerToJsonSchema(X){return this.resolution.toJsonSchemaRecurse(X)}traverseAllows=(X,U)=>{let q=U.seen[this.reference];if(q?.includes(X))return!0;return U.seen[this.reference]=y(q,X),this.resolution.traverseAllows(X,U)};traverseApply=(X,U)=>{let q=U.seen[this.reference];if(q?.includes(X))return;U.seen[this.reference]=y(q,X),this.resolution.traverseApply(X,U)};compile(X){let U=this.resolutionId;X.if(`ctx.seen.${U} && ctx.seen.${U}.includes(data)`,()=>X.return(!0)),X.if(`!ctx.seen.${U}`,()=>X.line(`ctx.seen.${U} = []`)),X.line(`ctx.seen.${U}.push(data)`),X.return(X.invoke(U))}}var z5=(X,U)=>`Alias '${X}' has a shallow resolution cycle: ${[...U,X].join("->")}`,C2={implementation:L5,Node:Sq};class L1 extends V0{traverseApply=(X,U)=>{if(!this.traverseAllows(X,U))U.errorFromNodeContext(this.errorContext)};get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return i0(this.errorContext)}compile(X){if(X.traversalKind==="Allows")X.return(this.compiledCondition);else X.if(this.compiledNegation,()=>X.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}}var F5=b({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:(X)=>typeof X==="string"?{domain:X}:I1(X,"numberAllowsNaN")&&X.domain!=="number"?F(P6.writeBadAllowNanMessage(X.domain)):X,applyConfig:(X,U)=>X.numberAllowsNaN===void 0&&X.domain==="number"&&U.numberAllowsNaN?{...X,numberAllowsNaN:!0}:X,defaults:{description:(X)=>Q0[X.domain],actual:(X)=>Number.isNaN(X)?"NaN":Q0[r(X)]},intersections:{domain:(X,U)=>X.domain==="number"&&U.domain==="number"?X.numberAllowsNaN?U:X:B.init("domain",X,U)}});class Eq extends L1{requiresNaNCheck=this.domain==="number"&&!this.numberAllowsNaN;traverseAllows=this.requiresNaNCheck?(X)=>typeof X==="number"&&!Number.isNaN(X):(X)=>r(X)===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 Q0[this.domain]}innerToJsonSchema(X){if(this.domain==="bigint"||this.domain==="symbol")return X.fallback.domain({code:"domain",base:{},domain:this.domain});return{type:this.domain}}}var P6={implementation:F5,Node:Eq,writeBadAllowNanMessage:(X)=>`numberAllowsNaN may only be specified with domain "number" (was ${X})`};var A5=b({kind:"intersection",hasAssociatedError:!0,normalize:(X)=>{if(h(X))return X;let{structure:U,...q}=X,Z=!!U,Q=U??{},G=S(q,(Y,H)=>{if(a(Y,oU)){if(Z)F(`Flattened structure key ${Y} cannot be specified alongside a root 'structure' key.`);return Q[Y]=H,[]}return[Y,H]});if(M(Q,"constraint")||!C0(Q))G.structure=Q;return G},finalizeInnerJson:({structure:X,...U})=>Z0(X,"object")?{...X,...U}:U,keys:{domain:{child:!0,parse:(X,U)=>U.$.node("domain",X)},proto:{child:!0,parse:(X,U)=>U.$.node("proto",X)},structure:{child:!0,parse:(X,U)=>U.$.node("structure",X),serialize:(X)=>{if(!X.sequence?.minLength)return X.collapsibleJson;let{sequence:U,...q}=X.collapsibleJson,{minVariadicLength:Z,...Q}=U,G=Q.variadic&&Object.keys(Q).length===1?Q.variadic:Q;return{...q,sequence:G}}},divisor:{child:!0,parse:X0("divisor")},max:{child:!0,parse:X0("max")},min:{child:!0,parse:X0("min")},maxLength:{child:!0,parse:X0("maxLength")},minLength:{child:!0,parse:X0("minLength")},exactLength:{child:!0,parse:X0("exactLength")},before:{child:!0,parse:X0("before")},after:{child:!0,parse:X0("after")},pattern:{child:!0,parse:X0("pattern")},predicate:{child:!0,parse:X0("predicate")}},reduce:(X,U)=>bq({},X,{$:U,invert:!1,pipe:!1}),defaults:{description:(X)=>{if(X.children.length===0)return"unknown";if(X.structure)return X.structure.description;let U=[];if(X.basis&&!X.prestructurals.some((q)=>q.impl.obviatesBasisDescription))U.push(X.basis.description);if(X.prestructurals.length){let q=X.prestructurals.slice().sort((Z,Q)=>Z.kind==="min"&&Q.kind==="max"?-1:0).map((Z)=>Z.description);U.push(...q)}if(X.inner.predicate)U.push(...X.inner.predicate.map((q)=>q.description));return U.join(" and ")},expected:(X)=>` ◦ ${X.errors.map((U)=>U.expected).join(`
166
+ ◦ `)}`,problem:(X)=>`(${X.actual}) must be...
167
+ ${X.expected}`},intersections:{intersection:(X,U,q)=>bq(X.inner,U.inner,q),...S0("intersection",(X,U,q)=>{if(X.children.length===0)return U;let{domain:Z,proto:Q,...G}=X.inner,Y=Q??Z,H=Y?u(Y,U,q):U;return H instanceof B?H:X?.basis?.equals(H)?X:X.$.node("intersection",{...G,[H.kind]:H},{prereduced:!0})})}});class jq extends V0{basis=this.inner.domain??this.inner.proto??null;prestructurals=[];refinements=this.children.filter((X)=>{if(!X.isRefinement())return!1;if(z0(i4,X.kind))this.prestructurals.push(X);return!0});structure=this.inner.structure;expression=V5(this);get shallowMorphs(){return this.inner.structure?.structuralMorph?[this.inner.structure.structuralMorph]:[]}get defaultShortDescription(){return this.basis?.defaultShortDescription??"present"}innerToJsonSchema(X){return this.children.reduce((U,q)=>q.isBasis()?q.toJsonSchemaRecurse(X):q.reduceJsonSchema(U,X),{})}traverseAllows=(X,U)=>this.children.every((q)=>q.traverseAllows(X,U));traverseApply=(X,U)=>{let q=U.currentErrorCount;if(this.basis){if(this.basis.traverseApply(X,U),U.currentErrorCount>q)return}if(this.prestructurals.length){for(let Z=0;Z<this.prestructurals.length-1;Z++)if(this.prestructurals[Z].traverseApply(X,U),U.failFast&&U.currentErrorCount>q)return;if(this.prestructurals[this.prestructurals.length-1].traverseApply(X,U),U.currentErrorCount>q)return}if(this.structure){if(this.structure.traverseApply(X,U),U.currentErrorCount>q)return}if(this.inner.predicate){for(let Z=0;Z<this.inner.predicate.length-1;Z++)if(this.inner.predicate[Z].traverseApply(X,U),U.failFast&&U.currentErrorCount>q)return;this.inner.predicate[this.inner.predicate.length-1].traverseApply(X,U)}};compile(X){if(X.traversalKind==="Allows"){for(let U of this.children)X.check(U);X.return(!0);return}if(X.initializeErrorCount(),this.basis){if(X.check(this.basis),this.children.length>1)X.returnIfFail()}if(this.prestructurals.length){for(let U=0;U<this.prestructurals.length-1;U++)X.check(this.prestructurals[U]),X.returnIfFailFast();if(X.check(this.prestructurals[this.prestructurals.length-1]),this.structure||this.inner.predicate)X.returnIfFail()}if(this.structure){if(X.check(this.structure),this.inner.predicate)X.returnIfFail()}if(this.inner.predicate){for(let U=0;U<this.inner.predicate.length-1;U++)X.check(this.inner.predicate[U]),X.returnIfFail();X.check(this.inner.predicate[this.inner.predicate.length-1])}}}var A9={implementation:A5,Node:jq},V5=(X)=>{if(X.structure?.expression)return X.structure.expression;let U=X.basis&&!X.prestructurals.some((Q)=>Q.impl.obviatesBasisExpression)?X.basis.nestableExpression:"",q=X.prestructurals.map((Q)=>Q.expression).join(" & "),Z=`${U}${U?" ":""}${q}`;if(Z==="Array == 0")return"[]";return Z||"unknown"},bq=(X,U,q)=>{let Z={},Q=X.proto??X.domain,G=U.proto??U.domain,Y=Q?G?u(Q,G,q):Q:G;if(Y instanceof B)return Y;if(Y)Z[Y.kind]=Y;return j1({kind:"intersection",baseInner:Z,l:f1(X),r:f1(U),roots:[],ctx:q})};var O5=b({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:(X,U)=>U.$.parseSchema(X)},morphs:{parse:p0,serialize:(X)=>X.map((U)=>M(U,"root")?U.json:d(U))},declaredIn:{child:!1,serialize:(X)=>X.json},declaredOut:{child:!1,serialize:(X)=>X.json}},normalize:(X)=>X,defaults:{description:(X)=>`a morph from ${X.rawIn.description} to ${X.rawOut?.description??"unknown"}`},intersections:{morph:(X,U,q)=>{if(!X.hasEqualMorphs(U))return F(B5(X.expression,U.expression));let Z=u(X.rawIn,U.rawIn,q);if(Z instanceof B)return Z;let Q={morphs:X.morphs};if(X.declaredIn||U.declaredIn){let G=u(X.rawIn,U.rawIn,q);if(G instanceof B)return G.throw();else Q.declaredIn=G}if(X.declaredOut||U.declaredOut){let G=u(X.rawOut,U.rawOut,q);if(G instanceof B)return G.throw();else Q.declaredOut=G}return Z.distribute((G)=>q.$.node("morph",{...Q,in:G}),q.$.parseSchema)},...S0("morph",(X,U,q)=>{let Z=X.inner.in?u(X.inner.in,U,q):U;return Z instanceof B?Z:Z.equals(X.inner.in)?X:q.$.node("morph",{...X.inner,in:Z})})}});class fq extends V0{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??V.intrinsic.unknown.internal}get rawOut(){return this.declaredOut??this.introspectableOut??V.intrinsic.unknown.internal}declareIn(X){return this.$.node("morph",{...this.inner,declaredIn:X})}declareOut(X){return this.$.node("morph",{...this.inner,declaredOut:X})}expression=`(In: ${this.rawIn.expression}) => ${this.lastMorphIfNode?"To":"Out"}<${this.rawOut.expression}>`;get defaultShortDescription(){return this.rawIn.meta.description??this.rawIn.defaultShortDescription}innerToJsonSchema(X){return X.fallback.morph({code:"morph",base:this.rawIn.toJsonSchemaRecurse(X),out:this.introspectableOut?.toJsonSchemaRecurse(X)??null})}compile(X){if(X.traversalKind==="Allows"){if(!this.introspectableIn)return;X.return(X.invoke(this.introspectableIn));return}if(this.introspectableIn)X.line(X.invoke(this.introspectableIn));X.line(`ctx.queueMorphs(${this.compiledMorphs})`)}traverseAllows=(X,U)=>!this.introspectableIn||this.introspectableIn.traverseAllows(X,U);traverseApply=(X,U)=>{if(this.introspectableIn)this.introspectableIn.traverseApply(X,U);U.queueMorphs(this.morphs)};hasEqualMorphs(X){return y0(this.morphs,X.morphs,{isEqual:(U,q)=>U===q||M(U,"root")&&M(q,"root")&&U.equals(q)})}}var V9={implementation:O5,Node:fq},B5=(X,U)=>`The intersection of distinct morphs at a single path is indeterminate:
168
+ Left: ${X}
169
+ Right: ${U}`;var T5=b({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:(X)=>_2(X)??F0(X)},dateAllowsInvalid:{}},normalize:(X)=>{let U=typeof X==="string"?{proto:J1[X]}:typeof X==="function"?h(X)?X:{proto:X}:typeof X.proto==="string"?{...X,proto:J1[X.proto]}:X;if(typeof U.proto!=="function")F(S2.writeInvalidSchemaMessage(U.proto));if(I1(U,"dateAllowsInvalid")&&U.proto!==Date)F(S2.writeBadInvalidDateMessage(U.proto));return U},applyConfig:(X,U)=>{if(X.dateAllowsInvalid===void 0&&X.proto===Date&&U.dateAllowsInvalid)return{...X,dateAllowsInvalid:!0};return X},defaults:{description:(X)=>X.builtinName?wU[X.builtinName]:`an instance of ${X.proto.name}`,actual:(X)=>X instanceof Date&&X.toString()==="Invalid Date"?"an invalid Date":W2(X)},intersections:{proto:(X,U)=>X.proto===Date&&U.proto===Date?X.dateAllowsInvalid?U:X:h4(X.proto,U.proto)?X:h4(U.proto,X.proto)?U:B.init("proto",X,U),domain:(X,U)=>U.domain==="object"?X:B.init("domain",V.intrinsic.object.internal,U)}});class yq extends L1{builtinName=_2(this.proto);serializedConstructor=this.json.proto;requiresInvalidDateCheck=this.proto===Date&&!this.dateAllowsInvalid;traverseAllows=this.requiresInvalidDateCheck?(X)=>X instanceof Date&&X.toString()!=="Invalid Date":(X)=>X instanceof this.proto;compiledCondition=`data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck?' && data.toString() !== "Invalid Date"':""}`;compiledNegation=`!(${this.compiledCondition})`;innerToJsonSchema(X){switch(this.builtinName){case"Array":return{type:"array"};case"Date":return X.fallback.date?.({code:"date",base:{}})??X.fallback.proto({code:"proto",base:{},proto:this.proto});default:return X.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:T5,Node:yq,writeBadInvalidDateMessage:(X)=>`dateAllowsInvalid may only be specified with constructor Date (was ${X.name})`,writeInvalidSchemaMessage:(X)=>`instanceOf operand must be a function (was ${r(X)})`};var R5=b({kind:"union",hasAssociatedError:!0,collapsibleKey:"branches",keys:{ordered:{},branches:{child:!0,parse:(X,U)=>{let q=[];for(let Z of X){let Q=M(Z,"root")?Z.branches:U.$.parseSchema(Z).branches;for(let G of Q)if(G.hasKind("morph")){let Y=q.findIndex((H)=>H.hasKind("morph")&&H.hasEqualMorphs(G));if(Y===-1)q.push(G);else{let H=q[Y];q[Y]=U.$.node("morph",{...H.inner,in:H.rawIn.rawOr(G.rawIn)})}}else q.push(G)}if(!U.def.ordered)q.sort((Z,Q)=>Z.hash<Q.hash?-1:1);return q}}},normalize:(X)=>x(X)?{branches:X}:X,reduce:(X,U)=>{let q=E5(X);if(q.length===1)return q[0];if(q.length===X.branches.length)return;return U.node("union",{...X,branches:q},{prereduced:!0})},defaults:{description:(X)=>X.distribute((U)=>U.description,v1),expected:(X)=>{let U=AU(X.errors,"propString"),q=Object.entries(U).map(([Z,Q])=>{let G=[];for(let J of Q)N0(G,J.expected);let Y=v1(G),H=Q.every((J)=>J.actual===Q[0].actual)?Q[0].actual:E(Q[0].data);return`${Z&&`${Z} `}must be ${Y}${H&&` (was ${H})`}`});return v1(q)},problem:(X)=>X.expected,message:(X)=>{if(X.problem[0]==="[")return`value at ${X.problem}`;return X.problem}},intersections:{union:(X,U,q)=>{if(X.isNever!==U.isNever)return B.init("presence",X,U);let Z;if(X.ordered){if(U.ordered)F(j5(X.expression,U.expression));if(Z=O9(U.branches,X.branches,q),Z instanceof B)Z.invert()}else Z=O9(X.branches,U.branches,q);if(Z instanceof B)return Z;return q.$.parseSchema(X.ordered||U.ordered?{branches:Z,ordered:!0}:{branches:Z})},...S0("union",(X,U,q)=>{let Z=O9(X.branches,[U],q);if(Z instanceof B)return Z;if(Z.length===1)return Z[0];return q.$.parseSchema(X.ordered?{branches:Z,ordered:!0}:{branches:Z})})}});class vq extends V0{isBoolean=this.branches.length===2&&this.branches[0].hasUnit(!1)&&this.branches[1].hasUnit(!0);get branchGroups(){let X=[],U=-1;for(let q of this.branches){if(q.hasKind("unit")&&q.domain==="boolean"){if(U===-1)U=X.length,X.push(q);else X[U]=V.intrinsic.boolean;continue}X.push(q)}return X}unitBranches=this.branches.filter((X)=>X.rawIn.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?N5(this.discriminant):null;expression=this.distribute((X)=>X.nestableExpression,S5);createBranchedOptimisticRootApply(){return(X,U)=>{let q=this.traverseOptimistic(X);if(q!==G0)return q;let Z=new w0(X,this.$.resolvedConfig);return this.traverseApply(X,Z),Z.finalize(U)}}get shallowMorphs(){return this.branches.reduce((X,U)=>N0(X,U.shallowMorphs),[])}get defaultShortDescription(){return this.distribute((X)=>X.defaultShortDescription,v1)}innerToJsonSchema(X){if(this.branchGroups.length===1&&this.branchGroups[0].equals(V.intrinsic.boolean))return{type:"boolean"};let U=this.branchGroups.map((q)=>q.toJsonSchemaRecurse(X));if(U.every((q)=>Object.keys(q).length===1&&I1(q,"const")))return{enum:U.map((q)=>q.const)};return{anyOf:U}}traverseAllows=(X,U)=>this.branches.some((q)=>q.traverseAllows(X,U));traverseApply=(X,U)=>{let q=[];for(let Z=0;Z<this.branches.length;Z++){if(U.pushBranch(),this.branches[Z].traverseApply(X,U),!U.hasError()){if(this.branches[Z].includesTransform)return U.queuedMorphs.push(...U.popBranch().queuedMorphs);return U.popBranch()}q.push(U.popBranch().error)}U.errorFromNodeContext({code:"union",errors:q,meta:this.meta})};traverseOptimistic=(X)=>{for(let U=0;U<this.branches.length;U++){let q=this.branches[U];if(q.traverseAllows(X)){if(q.contextFreeMorph)return q.contextFreeMorph(X);return X}}return G0};compile(X){if(!this.discriminant||this.unitBranches.length===this.branches.length&&this.branches.length===2)return this.compileIndiscriminable(X);let U=this.discriminant.optionallyChainedPropString;if(this.discriminant.kind==="domain")U=`typeof ${U} === "object" ? ${U} === null ? "null" : "object" : typeof ${U} === "function" ? "object" : typeof ${U}`;let q=this.discriminant.cases,Z=Object.keys(q),{optimistic:Q}=X;if(X.optimistic=!1,X.block(`switch(${U})`,()=>{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=X.invoke($,{kind:"Optimistic"});else if($.contextFreeMorph)L=`${X.invoke($)} ? ${d($.contextFreeMorph)}(data) : "${G0}"`;else L=`${X.invoke($)} ? data : "${G0}"`;else L=X.invoke($);X.line(`${_}: return ${L}`)}return X}),X.traversalKind==="Allows"){X.return(Q?`"${G0}"`:!1);return}let G=v1(this.discriminant.kind==="domain"?Z.map((W)=>{let $=W.slice(1,-1);return $==="function"?Q0.object:Q0[$]}):Z),Y=this.discriminant.path.map((W)=>typeof W==="symbol"?d(W):JSON.stringify(W)),H=JSON.stringify(G),J=this.discriminant.kind==="domain"?`${I5}[${U}]`:`${K5}(${U})`;X.line(`ctx.errorFromNodeContext({
170
170
  code: "predicate",
171
171
  expected: ${H},
172
172
  actual: ${J},
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?`"${Y0}"`:!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 H=this.branches[Y],J=L0(G.rawIn,H.rawIn,G.$);if(!(J instanceof V))continue;for(let W of J){if(!W.kind||W.optional)continue;let _,L;if(W.kind==="domain"){let{l:A,r:B}=W;_=`"${typeof A==="string"?A:A.domain}"`,L=`"${typeof B==="string"?B:B.domain}"`}else if(W.kind==="unit")_=W.l.serializedValue,L=W.r.serializedValue;else continue;let $=U.find((A)=>g0(A.path,W.path)&&A.kind===W.kind);if(!$)U.push({kind:W.kind,cases:{[_]:{branchIndices:[Q],condition:W.l},[L]:{branchIndices:[Y],condition:W.r}},path:W.path});else{if($.cases[_])$.cases[_].branchIndices=N0($.cases[_].branchIndices,Q);else $.cases[_]??={branchIndices:[Q],condition:W.l};if($.cases[L])$.cases[L].branchIndices=N0($.cases[L].branchIndices,Y);else $.cases[L]??={branchIndices:[Y],condition:W.r}}}}}let X=this.ordered?O5(U,this.branches):U;if(!X.length)return null;let q=A5(X,this),Z={};for(let Q in q.best.cases){let G=T5(q,Q);if(G===null){Z[Q]=!0;continue}if(G.length===this.branches.length)return null;if(this.ordered)G.sort((J,W)=>J.originalIndex-W.originalIndex);let Y=G.map((J)=>J.branch),H=Y.length===1?Y[0]:this.$.node("union",this.ordered?{branches:Y,ordered:!0}:Y);Object.assign(this.referencesById,H.referencesById),Z[Q]=H}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 A5=(U,X)=>{let Z=U.sort((Y,H)=>Y.path.length===H.path.length?Object.keys(H.cases).length-Object.keys(Y.cases).length:Y.path.length-H.path.length)[0],Q={kind:Z.kind,path:Z.path,optionallyChainedPropString:bq(Z.path)},G=X.branches.map((Y,H)=>({originalIndex:H,branch:Y}));return{best:Z,location:Q,defaultEntries:G,node:X}},T5=(U,X)=>{let q=U.best.cases[X],Z=V5(q.condition,U.location.path,U.node.$),Q=[],G=[];for(let Y=0;Y<U.defaultEntries.length;Y++){let H=U.defaultEntries[Y];if(q.branchIndices.includes(H.originalIndex)){let J=Cq(U.node.branches[H.originalIndex],U.location);if(J===null)Q=null;else Q?.push({originalIndex:H.originalIndex,branch:J})}else if(H.branch.hasKind("alias")&&Z.hasKind("domain")&&Z.domain==="object")Q?.push(H);else{if(H.branch.rawIn.overlaps(Z)){let J=Cq(H.branch,U.location);Q?.push({originalIndex:H.originalIndex,branch:J})}G.push(H)}}return U.defaultEntries=G,Q},O5=(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 H=G+1;H<Q.length;H++){let J=Q[H];for(let W of Y)for(let _ of J)if(W>_){if(X[W].overlaps(X[_]))return!1}}}return!0})},V5=(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:[...YX(G).map((Y)=>({})),Z]}:{domain:"object",required:[{key:G,value:Z}]})}return Z},bq=(U)=>U.reduce((X,q)=>X+h4(q,!0),"data"),B5=d(WX),R5=d(E),$9={implementation:F5,Node:Eq},D5=(U)=>({kind:U.kind,path:U.path.map((X)=>typeof X==="string"?X:D0(X)),cases:S(U.cases,(X,q)=>[X,q===!0?q:q.hasKind("union")&&q.discriminantJson?q.discriminantJson:q.json])}),M5={delimiter:" | ",finalDelimiter:" | "},w5=(U)=>k1(U,M5),k1=(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((H)=>Q[H]?!1:Q[H]=!0),Y=G.pop();return`${G.join(q)}${G.length?Z:""}${Y}`},_9=(U,X,q)=>{let Z=X.map(()=>[]);for(let G=0;G<U.length;G++){let Y={};for(let H=0;H<X.length;H++){if(Z[H]===null)continue;if(U[G].equals(X[H])){Z[H]=null,Y={};break}let J=u(U[G],X[H],q);if(J instanceof V)continue;if(J.equals(U[G])){Z[H].push(U[G]),Y={};break}if(J.equals(X[H]))Z[H]=null;else Y[H]=J}for(let H in Y)Z[H][G]=Y[H]}let Q=Z.flatMap((G,Y)=>G?.flatMap((H)=>H.branches)??X[Y]);return Q.length===0?V.init("union",U,X):Q},P5=({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=L0(U[Z].rawIn,U[Q].rawIn,U[0].$);if(G instanceof V)continue;if(!X)I5(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])},I5=(U,X)=>{if(!U.includesTransform&&!X.includesTransform)return;if(!g0(U.shallowMorphs,X.shallowMorphs))F(Sq(U.expression,X.expression));if(!g0(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(Sq(U.expression,X.expression))},Cq=(U,X)=>U.transform((q,Z)=>{if(q==="domain"||q==="unit")return null;return Z},{shouldTransform:(q,Z)=>{let Q=bq(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"}}),Sq=(U,X)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
176
- Left: ${U}
177
- Right: ${X}`,K5=(U,X)=>`The intersection of two ordered unions is indeterminate:
178
- Left: ${U}
179
- Right: ${X}`;var N5=b({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:(U)=>U instanceof Date?U.toISOString():F0(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)=>V.init("unit",U,X),...S0("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:T.intrinsic.object;if(U.domain!==Z.domain){let Q=U.domain==="undefined"||U.domain==="null"||U.domain==="boolean"?U.domain:T.intrinsic[U.domain];return V.init("domain",Q,Z)}}return V.init("assignability",U,X.hasKind("intersection")?X.children.find((Z)=>!Z.allows(U.unit)):X)})}});class fq extends _1{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=jq(this.unit,this.serializedValue);compiledNegation=jq(this.unit,this.serializedValue,"negated");expression=E(this.unit);domain=r(this.unit);get defaultShortDescription(){return this.domain==="object"?G0.object:this.description}innerToJsonSchema(U){return this.unit===null?{type:"null"}:T.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 z9={implementation:N5,Node:fq},jq=(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=b({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:(U,X)=>{let q=X.$.parseSchema(U);if(!q.extends(T.intrinsic.key))return F(E5(q.expression));let Z=q.branches.filter((Q)=>Q.hasKind("unit"));if(Z.length)return F(S5(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 V?T.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 gq extends A0{impliedBasis=T.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=g(this.value.flatRefs.map((U)=>w0([this.signature,...U.path],U.node)),w0([this.signature],this.value));traverseAllows=(U,X)=>Y1(U).every((q)=>{if(this.signature.traverseAllows(q[0],X))return W0(q[0],()=>this.value.traverseAllows(q[1],X),X);return!0});traverseApply=(U,X)=>{for(let q of Y1(U))if(this.signature.traverseAllows(q[0],X))W0(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 F9={implementation:C5,Node:gq},S5=(U)=>`Index keys ${U.join(", ")} should be specified as named props.`,E5=(U)=>`Indexed key definition '${U}' must be a string or symbol`;var b5=b({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:V2,optional:V2}});class yq extends B2{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=i0(this.errorContext)}var A9={implementation:b5,Node:yq};var j5=b({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 D2(Z,q[1],null),[Z,q[1]]})},serialize:(U)=>U.map((X)=>[X[0].collapsibleJson,F0(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(k5);if(U.optionals?.length||U.defaultables?.length)return F(O9)}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=I2({l:U.tuple,r:X.tuple,disjoint:new V,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",kq(Q[0].result)):q.$.node("union",Q.map((G)=>({proto:Array,sequence:kq(G.result)})))}}});class xq extends A0{impliedBasis=T.intrinsic.Array.internal;tuple=y5(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=f0(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return d4(this.flatRefs,this.prevariadic.flatMap((U,X)=>g(U.node.flatRefs.map((q)=>w0([`${X}`,...q.path],q.node)),w0([`${X}`],U.node)))),d4(this.flatRefs,this.variadicOrPostfix.flatMap((U)=>g(U.flatRefs.map((X)=>w0([T.intrinsic.nonNegativeIntegerString.internal,...X.path],X.node)),w0([T.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=g5(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++)W0(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(T.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=T.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 f5={},g5=(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(J9(Q,G,Y)),q+=`${Q}: ${G.id} = ${F0(Y)}, `}return q+="]",f5[q]??=X},T9={implementation:j5,Node:xq},y5=(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},kq=(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},{}),O9="A postfix required element cannot follow an optional or defaultable element",k5="A postfix element requires a variadic element",I2=(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",H=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 L=I2({...U,fixedVariants:[],r:Q.map(($)=>({...$,kind:"prefix"}))});if(L.disjoint.length===0)U.fixedVariants.push(L)}else if(Z.kind==="prefix"&&X.kind==="variadic"&&G){let L=I2({...U,fixedVariants:[],l:q.map(($)=>({...$,kind:"prefix"}))});if(L.disjoint.length===0)U.fixedVariants.push(L)}let J=u(X.node,Z.node,U.ctx);if(J instanceof V)if(H==="prefix"||H==="postfix")U.disjoint.push(...J.withPrefixKey(H==="prefix"?U.result.length:`-${q.length+1}`,vq(X)&&vq(Z)?"required":"optional")),U.result=[...U.result,{kind:H,node:T.intrinsic.never.internal}];else if(H==="optionals"||H==="defaultables")return U;else return I2({...U,fixedVariants:[],l:q.map((L)=>({...L,kind:"prefix"})),r:q.map((L)=>({...L,kind:"prefix"}))});else if(H==="defaultables"){if(X.kind==="defaultables"&&Z.kind==="defaultables"&&X.default!==Z.default)F(H9(X.default,Z.default));U.result=[...U.result,{kind:H,node:J,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:H,node:J}];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 I2(U)},vq=(U)=>U.kind==="prefix"||U.kind==="postfix";var pq=(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??"{}"},v5=pq("description"),x5=pq("expression"),hq=(U,X,q)=>{let Z=U.required?"required":"optional";if(!X.signature.allows(U.key))return null;let Q=L0(U.value,X.value,q);if(Q instanceof V)return Z==="optional"?q.node("optional",{key:U.key,value:T.intrinsic.never.internal}):Q.withPrefixKey(U.key,U.kind);return null},h5=b({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:U0("required"),reduceIo:(U,X,q)=>{X.required=g(X.required,q.map((Z)=>U==="in"?Z.rawIn:Z.rawOut));return}},optional:{child:!0,parse:U0("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:U0("index")},sequence:{child:!0,parse:U0("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:v5},intersections:{structure:(U,X,q)=>{let Z={...U.inner},Q={...X.inner},G=new V;if(U.undeclared){let J=U.keyof();for(let W of X.requiredKeys)if(!J.allows(W))G.add("presence",T.intrinsic.never.internal,X.propsByKey[W].value,{path:[W]});if(Q.optional)Q.optional=Q.optional.filter((W)=>J.allows(W.key));if(Q.index)Q.index=Q.index.flatMap((W)=>{if(W.signature.extends(J))return W;let _=L0(J,W.signature,q.$);if(_ instanceof V)return[];let L=D6(_,W.value,q.$);if(L.required)Q.required=f0(Q.required,L.required);if(L.optional)Q.optional=f0(Q.optional,L.optional);return L.index??[]})}if(X.undeclared){let J=X.keyof();for(let W of U.requiredKeys)if(!J.allows(W))G.add("presence",U.propsByKey[W].value,T.intrinsic.never.internal,{path:[W]});if(Z.optional)Z.optional=Z.optional.filter((W)=>J.allows(W.key));if(Z.index)Z.index=Z.index.flatMap((W)=>{if(W.signature.extends(J))return W;let _=L0(J,W.signature,q.$);if(_ instanceof V)return[];let L=D6(_,W.value,q.$);if(L.required)Z.required=f0(Z.required,L.required);if(L.optional)Z.optional=f0(Z.optional,L.optional);return L.index??[]})}let Y={};if(U.undeclared||X.undeclared)Y.undeclared=U.undeclared==="reject"||X.undeclared==="reject"?"reject":"delete";let H=b1({kind:"structure",baseInner:Y,l:j1(Z),r:j1(Q),roots:[],ctx:q});if(H instanceof V)G.push(...H);if(G.length)return G;return H}},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(mq(Y.key));if(q[Y.key]=!0,U.index)for(let H of U.index){let J=hq(Y,H,X);if(J instanceof V)return J}}if(U.optional)for(let G=0;G<U.optional.length;G++){let Y=U.optional[G];if(Y.key in q)F(mq(Y.key));if(q[Y.key]=!0,U.index)for(let H of U.index){let J=hq(Y,H,X);if(J instanceof V)return J;if(J!==null)Q[G]=J,Z=!0}}if(Z)return X.node("structure",{...U,optional:Q},{prereduced:!0})}});class lq extends A0{impliedBasis=T.intrinsic.object.internal;impliedSiblings=this.children.flatMap((U)=>U.impliedSiblings??[]);props=f0(this.required,this.optional);propsByKey=S(this.props,(U,X)=>[X.key,X]);propsByKeyReference=d(this.propsByKey);expression=x5(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(h(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,H)=>(Y in R2.implementation.keys)?[Y,H]:[]);return X[Q]=g(X[Q],this.$.node(Q,G)),X},{}))}assertHasKeys(U){let X=U.filter((q)=>!M2(q,this.keyof()));if(X.length)return F(uq(this.expression,X))}get(U,...X){let q,Z=!1,Q=l5(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(M2(Q,Y.signature))q=q?.and(Y.value)??Y.value}if(this.sequence&&M2(Q,T.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 H=this.sequence.prevariadic[Y].node;q=q?.and(H)??H,Z||=Y<this.sequence.prefixLength}else if(this.sequence.variadic){let H=this.$.node("union",this.sequence.variadicOrPostfix);q=q?.and(H)??H}}if(!q){if(this.sequence?.variadic&&M(Q,"root")&&Q.extends(T.intrinsic.number))return F(d5(Q.expression,this.sequence.expression));return F(uq(this.expression,[Q]))}let G=q.get(...X);return Z?G:G.or(T.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=L6(this.inner),Z=(Q)=>{let G=X.some((Y)=>M2(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 H of this.index)if(H.signature.traverseAllows(Y,q)){if(U==="Allows"){if(!W0(Y,()=>H.value.traverseAllows(X[Y],q),q))return!1}else if(W0(Y,()=>H.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&&T.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",m5(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(["),p5(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=T.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(T.intrinsic.string)){U.additionalProperties=Z;continue}for(let Q of q.signature.branches){if(!Q.extends(T.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 H=Object.assign(G,{pattern:Y[0].rule});for(let J=1;J<Y.length;J++)G=X.fallback.patternIntersection({code:"patternIntersection",base:H,pattern:Y[J].rule});U.patternProperties??={},U.patternProperties[H.pattern]=Z}}}if(this.undeclared&&!U.additionalProperties)U.additionalProperties=!1;return U}}var V9={},u5=(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},m5=(U)=>{let X=u5(U);if(!X)return;if(V9[X])return V9[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 V9[X]=q},p5=(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:H}=X.defaultable[G];Q.if(`!(${Y} in data)`,(J)=>J.line(`${H}${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")})},B9={implementation:h5,Node:lq},l5=(U)=>{if(M(U,"root")&&U.hasKind("unit"))U=U.unit;if(typeof U==="number")U=`${U}`;return U},d5=(U,X)=>`${U} is not allowed as an array index on ${X}. Use the 'nonNegativeIntegerString' keyword instead.`,D6=(U,X,q)=>{let[Z,Q]=GX(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 H=q.node("required",{key:Y.unit,value:X});G[H.kind]=g(G[H.kind],H)}if(Q.length)G.index=q.node("index",{signature:Q,value:X});return G},c5=(U)=>M(U,"root")?U.expression:E(U),uq=(U,X)=>`Key${X.length===1?"":"s"} ${X.map(c5).join(", ")} ${X.length===1?"does":"do"} not exist on ${U}`,mq=(U)=>`Duplicate key ${D0(U)}`;var g1={...Wq,alias:w2.implementation,domain:R6.implementation,unit:z9.implementation,proto:P2.implementation,union:$9.implementation,morph:L9.implementation,intersection:W9.implementation,divisor:r4.implementation,pattern:Z9.implementation,predicate:s4.implementation,required:A9.implementation,optional:R2.implementation,index:F9.implementation,sequence:T9.implementation,structure:B9.implementation};T.defaultConfig=FX(Object.assign(S(g1,(U,X)=>[U,X.defaults]),{jitless:RX(),clone:OX,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:p.defaultConfig}));T.resolvedConfig=z2(T.defaultConfig,T.config);var Aq={...Lq,alias:w2.Node,domain:R6.Node,unit:z9.Node,proto:P2.Node,union:$9.Node,morph:L9.Node,intersection:W9.Node,divisor:r4.Node,pattern:Z9.Node,predicate:s4.Node,required:A9.Node,optional:R2.Node,index:F9.Node,sequence:T9.Node,structure:B9.Node};class v1 extends S4{get[X0](){return"module"}}var R9=(U,X)=>new v1(S(U,(q,Z)=>[q,M(Z,"module")?R9(Z,X):X.bindReference(Z)]));var i5=(U)=>x(U)?U:("branches"in U)&&x(U.branches)?U.branches:void 0,o5=(U,X)=>F(`Node of kind ${X} is not valid as a ${U} definition`),dq=(U)=>`#${U} duplicates public alias ${U}`,D9={};T.ambient??={};var cq,oq="function $",s5=(U)=>sq(U,rq(U)),sq=(U,X)=>{let q=X.write(oq,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}},rq=(U)=>new W6().return(U.reduce((X,q)=>{let Z=new $2({kind:"Allows"}).indent();q.compile(Z);let Q=Z.write(`${q.id}Allows`),G=new $2({kind:"Apply"}).indent();q.compile(G);let Y=G.write(`${q.id}Apply`),H=`${X}${Q},
175
+ })`)}compileIndiscriminable(X){if(X.traversalKind==="Apply"){X.const("errors","[]");for(let U of this.branches)X.line("ctx.pushBranch()").line(X.invoke(U)).if("!ctx.hasError()",()=>X.return(U.includesTransform?"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)":"ctx.popBranch()")).line("errors.push(ctx.popBranch().error)");X.line(`ctx.errorFromNodeContext({ code: "union", errors, meta: ${this.compiledMeta} })`)}else{let{optimistic:U}=X;X.optimistic=!1;for(let q of this.branches)X.if(`${X.invoke(q)}`,()=>X.return(U?q.contextFreeMorph?`${d(q.contextFreeMorph)}(data)`:"data":!0));X.return(U?`"${G0}"`:!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 X=[];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 H=this.branches[Y],J=W0(G.rawIn,H.rawIn,G.$);if(!(J instanceof B))continue;for(let W of J){if(!W.kind||W.optional)continue;let $,_;if(W.kind==="domain"){let{l:A,r:T}=W;$=`"${typeof A==="string"?A:A.domain}"`,_=`"${typeof T==="string"?T:T.domain}"`}else if(W.kind==="unit")$=W.l.serializedValue,_=W.r.serializedValue;else continue;let L=X.find((A)=>y0(A.path,W.path)&&A.kind===W.kind);if(!L)X.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=N0(L.cases[$].branchIndices,Q);else L.cases[$]??={branchIndices:[Q],condition:W.l};if(L.cases[_])L.cases[_].branchIndices=N0(L.cases[_].branchIndices,Y);else L.cases[_]??={branchIndices:[Y],condition:W.r}}}}}let U=this.ordered?w5(X,this.branches):X;if(!U.length)return null;let q=D5(U,this),Z={};for(let Q in q.best.cases){let G=M5(q,Q);if(G===null){Z[Q]=!0;continue}if(G.length===this.branches.length)return null;if(this.ordered)G.sort((J,W)=>J.originalIndex-W.originalIndex);let Y=G.map((J)=>J.branch),H=Y.length===1?Y[0]:this.$.node("union",this.ordered?{branches:Y,ordered:!0}:Y);Object.assign(this.referencesById,H.referencesById),Z[Q]=H}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 D5=(X,U)=>{let Z=X.sort((Y,H)=>Y.path.length===H.path.length?Object.keys(H.cases).length-Object.keys(Y.cases).length:Y.path.length-H.path.length)[0],Q={kind:Z.kind,path:Z.path,optionallyChainedPropString:xq(Z.path)},G=U.branches.map((Y,H)=>({originalIndex:H,branch:Y}));return{best:Z,location:Q,defaultEntries:G,node:U}},M5=(X,U)=>{let q=X.best.cases[U],Z=P5(q.condition,X.location.path,X.node.$),Q=[],G=[];for(let Y=0;Y<X.defaultEntries.length;Y++){let H=X.defaultEntries[Y];if(q.branchIndices.includes(H.originalIndex)){let J=gq(X.node.branches[H.originalIndex],X.location);if(J===null)Q=null;else Q?.push({originalIndex:H.originalIndex,branch:J})}else if(H.branch.hasKind("alias")&&Z.hasKind("domain")&&Z.domain==="object")Q?.push(H);else{if(H.branch.rawIn.overlaps(Z)){let J=gq(H.branch,X.location);Q?.push({originalIndex:H.originalIndex,branch:J})}G.push(H)}}return X.defaultEntries=G,Q},w5=(X,U)=>{return X.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 H=G+1;H<Q.length;H++){let J=Q[H];for(let W of Y)for(let $ of J)if(W>$){if(U[W].overlaps(U[$]))return!1}}}return!0})},P5=(X,U,q)=>{let Z=X==="undefined"?q.node("unit",{unit:void 0}):X==="null"?q.node("unit",{unit:null}):X==="boolean"?q.units([!0,!1]):X;for(let Q=U.length-1;Q>=0;Q--){let G=U[Q];Z=q.node("intersection",typeof G==="number"?{proto:"Array",sequence:[...zU(G).map((Y)=>({})),Z]}:{domain:"object",required:[{key:G,value:Z}]})}return Z},xq=(X)=>X.reduce((U,q)=>U+c4(q,!0),"data"),I5=d(VU),K5=d(E),B9={implementation:R5,Node:vq},N5=(X)=>({kind:X.kind,path:X.path.map((U)=>typeof U==="string"?U:M0(U)),cases:S(X.cases,(U,q)=>[U,q===!0?q:q.hasKind("union")&&q.discriminantJson?q.discriminantJson:q.json])}),C5={delimiter:" | ",finalDelimiter:" | "},S5=(X)=>v1(X,C5),v1=(X,U)=>{let q=U?.delimiter??", ",Z=U?.finalDelimiter??" or ";if(X.length===0)return"never";if(X.length===1)return X[0];if(X.length===2&&X[0]==="false"&&X[1]==="true"||X[0]==="true"&&X[1]==="false")return"boolean";let Q={},G=X.filter((H)=>Q[H]?!1:Q[H]=!0),Y=G.pop();return`${G.join(q)}${G.length?Z:""}${Y}`},O9=(X,U,q)=>{let Z=U.map(()=>[]);for(let G=0;G<X.length;G++){let Y={};for(let H=0;H<U.length;H++){if(Z[H]===null)continue;if(X[G].equals(U[H])){Z[H]=null,Y={};break}let J=u(X[G],U[H],q);if(J instanceof B)continue;if(J.equals(X[G])){Z[H].push(X[G]),Y={};break}if(J.equals(U[H]))Z[H]=null;else Y[H]=J}for(let H in Y)Z[H][G]=Y[H]}let Q=Z.flatMap((G,Y)=>G?.flatMap((H)=>H.branches)??U[Y]);return Q.length===0?B.init("union",X,U):Q},E5=({branches:X,ordered:U})=>{if(X.length<2)return X;let q=X.map(()=>!0);for(let Z=0;Z<X.length;Z++)for(let Q=Z+1;Q<X.length&&q[Z]&&q[Q];Q++){if(X[Z].equals(X[Q])){q[Q]=!1;continue}let G=W0(X[Z].rawIn,X[Q].rawIn,X[0].$);if(G instanceof B)continue;if(!U)b5(X[Z],X[Q]);if(G.equals(X[Z].rawIn))q[Z]=!!U;else if(G.equals(X[Q].rawIn))q[Q]=!1}return X.filter((Z,Q)=>q[Q])},b5=(X,U)=>{if(!X.includesTransform&&!U.includesTransform)return;if(!y0(X.shallowMorphs,U.shallowMorphs))F(kq(X.expression,U.expression));if(!y0(X.flatMorphs,U.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(kq(X.expression,U.expression))},gq=(X,U)=>X.transform((q,Z)=>{if(q==="domain"||q==="unit")return null;return Z},{shouldTransform:(q,Z)=>{let Q=xq(Z.path);if(!U.optionallyChainedPropString.startsWith(Q))return!1;if(q.hasKind("domain")&&q.domain==="object")return!0;if((q.hasKind("domain")||U.kind==="unit")&&Q===U.optionallyChainedPropString)return!0;return q.children.length!==0&&q.kind!=="index"}}),kq=(X,U)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
176
+ Left: ${X}
177
+ Right: ${U}`,j5=(X,U)=>`The intersection of two ordered unions is indeterminate:
178
+ Left: ${X}
179
+ Right: ${U}`;var f5=b({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:(X)=>X instanceof Date?X.toISOString():F0(X)}},normalize:(X)=>X,defaults:{description:(X)=>E(X.unit),problem:({expected:X,actual:U})=>`${X===U?`must be reference equal to ${X} (serialized to the same value)`:`must be ${X} (was ${U})`}`},intersections:{unit:(X,U)=>B.init("unit",X,U),...S0("unit",(X,U)=>{if(U.allows(X.unit))return X;let q=U.hasKind("intersection")?U.basis:U;if(q){let Z=q.hasKind("domain")?q:V.intrinsic.object;if(X.domain!==Z.domain){let Q=X.domain==="undefined"||X.domain==="null"||X.domain==="boolean"?X.domain:V.intrinsic[X.domain];return B.init("domain",Q,Z)}}return B.init("assignability",X,U.hasKind("intersection")?U.children.find((Z)=>!Z.allows(X.unit)):U)})}});class uq extends L1{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=hq(this.unit,this.serializedValue);compiledNegation=hq(this.unit,this.serializedValue,"negated");expression=E(this.unit);domain=r(this.unit);get defaultShortDescription(){return this.domain==="object"?Q0.object:this.description}innerToJsonSchema(X){return this.unit===null?{type:"null"}:V.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:X.fallback.unit({code:"unit",base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?(X)=>X instanceof Date&&X.toISOString()===this.compiledValue:Number.isNaN(this.unit)?(X)=>Number.isNaN(X):(X)=>X===this.unit}var T9={implementation:f5,Node:uq},hq=(X,U,q)=>{if(X instanceof Date){let Z=`data instanceof Date && data.toISOString() === ${U}`;return q?`!(${Z})`:Z}if(Number.isNaN(X))return`${q?"!":""}Number.isNaN(data)`;return`data ${q?"!":"="}== ${U}`};var y5=b({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:(X,U)=>{let q=U.$.parseSchema(X);if(!q.extends(V.intrinsic.key))return F(k5(q.expression));let Z=q.branches.filter((Q)=>Q.hasKind("unit"));if(Z.length)return F(g5(Z.map((Q)=>E(Q.unit))));return q}},value:{child:!0,parse:(X,U)=>U.$.parseSchema(X)}},normalize:(X)=>X,defaults:{description:(X)=>`[${X.signature.expression}]: ${X.value.description}`},intersections:{index:(X,U,q)=>{if(X.signature.equals(U.signature)){let Z=u(X.value,U.value,q),Q=Z instanceof B?V.intrinsic.never.internal:Z;return q.$.node("index",{signature:X.signature,value:Q})}if(X.signature.extends(U.signature)&&X.value.subsumes(U.value))return U;if(U.signature.extends(X.signature)&&U.value.subsumes(X.value))return X;return null}}});class mq extends A0{impliedBasis=V.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=y(this.value.flatRefs.map((X)=>P0([this.signature,...X.path],X.node)),P0([this.signature],this.value));traverseAllows=(X,U)=>H1(X).every((q)=>{if(this.signature.traverseAllows(q[0],U))return J0(q[0],()=>this.value.traverseAllows(q[1],U),U);return!0});traverseApply=(X,U)=>{for(let q of H1(X))if(this.signature.traverseAllows(q[0],U))J0(q[0],()=>this.value.traverseApply(q[1],U),U)};_transform(X,U){U.path.push(this.signature);let q=super._transform(X,U);return U.path.pop(),q}compile(){}}var R9={implementation:y5,Node:mq},g5=(X)=>`Index keys ${X.join(", ")} should be specified as named props.`,k5=(X)=>`Indexed key definition '${X}' must be a string or symbol`;var v5=b({kind:"required",hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(X,U)=>U.$.parseSchema(X)}},normalize:(X)=>X,defaults:{description:(X)=>`${X.compiledKey}: ${X.value.description}`,expected:(X)=>X.missingValueDescription,actual:()=>"missing"},intersections:{required:w2,optional:w2}});class pq extends P2{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=i0(this.errorContext)}var D9={implementation:v5,Node:pq};var x5=b({kind:"sequence",hasAssociatedError:!1,collapsibleKey:"variadic",keys:{prefix:{child:!0,parse:(X,U)=>{if(X.length===0)return;return X.map((q)=>U.$.parseSchema(q))}},optionals:{child:!0,parse:(X,U)=>{if(X.length===0)return;return X.map((q)=>U.$.parseSchema(q))}},defaultables:{child:(X)=>X.map((U)=>U[0]),parse:(X,U)=>{if(X.length===0)return;return X.map((q)=>{let Z=U.$.parseSchema(q[0]);return K2(Z,q[1],null),[Z,q[1]]})},serialize:(X)=>X.map((U)=>[U[0].collapsibleJson,F0(U[1])]),reduceIo:(X,U,q)=>{if(X==="in"){U.optionals=q.map((Z)=>Z[0].rawIn);return}U.prefix=q.map((Z)=>Z[0].rawOut);return}},variadic:{child:!0,parse:(X,U)=>U.$.parseSchema(X,U)},minVariadicLength:{parse:(X)=>X===0?void 0:X},postfix:{child:!0,parse:(X,U)=>{if(X.length===0)return;return X.map((q)=>U.$.parseSchema(q))}}},normalize:(X)=>{if(typeof X==="string")return{variadic:X};if("variadic"in X||"prefix"in X||"defaultables"in X||"optionals"in X||"postfix"in X||"minVariadicLength"in X){if(X.postfix?.length){if(!X.variadic)return F(p5);if(X.optionals?.length||X.defaultables?.length)return F(w9)}if(X.minVariadicLength&&!X.variadic)return F("minVariadicLength may not be specified without a variadic element");return X}return{variadic:X}},reduce:(X,U)=>{let q=X.minVariadicLength??0,Z=X.prefix?.slice()??[],Q=X.defaultables?.slice()??[],G=X.optionals?.slice()??[],Y=X.postfix?.slice()??[];if(X.variadic){while(G[G.length-1]?.equals(X.variadic))G.pop();if(G.length===0&&Q.length===0)while(Z[Z.length-1]?.equals(X.variadic))Z.pop(),q++;while(Y[0]?.equals(X.variadic))Y.shift(),q++}else if(G.length===0&&Q.length===0)Z.push(...Y.splice(0));if(q!==X.minVariadicLength||X.prefix&&X.prefix.length!==Z.length)return U.node("sequence",{...X,prefix:Z,defaultables:Q,optionals:G,postfix:Y,minVariadicLength:q},{prereduced:!0})},defaults:{description:(X)=>{if(X.isVariadicOnly)return`${X.variadic.nestableExpression}[]`;return`[${X.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:(X,U,q)=>{let Z=E2({l:X.tuple,r:U.tuple,disjoint:new B,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",lq(Q[0].result)):q.$.node("union",Q.map((G)=>({proto:Array,sequence:lq(G.result)})))}}});class cq extends A0{impliedBasis=V.intrinsic.Array.internal;tuple=m5(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((X)=>{if(X.kind==="defaultables"||X.kind==="optionals")return this.defaultablesAndOptionals.push(X.node),!0;return X.kind==="prefix"});variadicOrPostfix=f0(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return a4(this.flatRefs,this.prevariadic.flatMap((X,U)=>y(X.node.flatRefs.map((q)=>P0([`${U}`,...q.path],q.node)),P0([`${U}`],X.node)))),a4(this.flatRefs,this.variadicOrPostfix.flatMap((X)=>y(X.flatRefs.map((U)=>P0([V.intrinsic.nonNegativeIntegerString.internal,...U.path],U.node)),P0([V.intrinsic.nonNegativeIntegerString.internal],X)))),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=u5(this);defaultValueMorphsReference=this.defaultValueMorphs.length?d(this.defaultValueMorphs):void 0;elementAtIndex(X,U){if(U<this.prevariadic.length)return this.tuple[U];let q=X.length-this.postfixLength;if(U>=q)return{kind:"postfix",node:this.postfix[U-q]};return{kind:"variadic",node:this.variadic??g(`Unexpected attempt to access index ${U} on ${this}`)}}traverseAllows=(X,U)=>{for(let q=0;q<X.length;q++)if(!this.elementAtIndex(X,q).node.traverseAllows(X[q],U))return!1;return!0};traverseApply=(X,U)=>{let q=0;for(;q<X.length;q++)J0(q,()=>this.elementAtIndex(X,q).node.traverseApply(X[q],U),U)};get element(){return this.cacheGetter("element",this.$.node("union",this.children))}compile(X){if(this.prefix)for(let[U,q]of this.prefix.entries())X.traverseKey(`${U}`,`data[${U}]`,q);for(let[U,q]of this.defaultablesAndOptionals.entries()){let Z=`${U+this.prefixLength}`;X.if(`${Z} >= data.length`,()=>X.traversalKind==="Allows"?X.return(!0):X.return()),X.traverseKey(Z,`data[${Z}]`,q)}if(this.variadic){if(this.postfix)X.const("firstPostfixIndex",`data.length${this.postfix?`- ${this.postfix.length}`:""}`);if(X.for(`i < ${this.postfix?"firstPostfixIndex":"data.length"}`,()=>X.traverseKey("i","data[i]",this.variadic),this.prevariadic.length),this.postfix)for(let[U,q]of this.postfix.entries()){let Z=`firstPostfixIndex + ${U}`;X.traverseKey(Z,`data[${Z}]`,q)}}if(X.traversalKind==="Allows")X.return(!0)}_transform(X,U){U.path.push(V.intrinsic.nonNegativeIntegerString.internal);let q=super._transform(X,U);return U.path.pop(),q}expression=this.description;reduceJsonSchema(X,U){let q=U.target==="draft-07";if(this.prevariadic.length){let Z=this.prevariadic.map((Q)=>{let G=Q.node.toJsonSchemaRecurse(U);if(Q.kind==="defaultables"){let Y=typeof Q.default==="function"?Q.default():Q.default;G.default=V.intrinsic.jsonData.allows(Y)?Y:U.fallback.defaultValue({code:"defaultValue",base:G,value:Y})}return G});if(q)X.items=Z;else X.prefixItems=Z}if(this.minLength)X.minItems=this.minLength;if(this.variadic){let Z=this.variadic.toJsonSchemaRecurse(U);if(q&&this.prevariadic.length)X.additionalItems=Z;else X.items=Z;if(this.maxLength)X.maxItems=this.maxLength;if(this.postfix){let Q=this.postfix.map((G)=>G.toJsonSchemaRecurse(U));X=U.fallback.arrayPostfix({code:"arrayPostfix",base:X,elements:Q})}}else{if(q)X.additionalItems=!1;else X.items=!1;delete X.maxItems}return X}}var h5={},u5=(X)=>{if(!X.defaultables)return[];let U=[],q="[",Z=X.prefixLength+X.defaultablesLength-1;for(let Q=X.prefixLength;Q<=Z;Q++){let[G,Y]=X.defaultables[Q-X.prefixLength];U.push(F9(Q,G,Y)),q+=`${Q}: ${G.id} = ${F0(Y)}, `}return q+="]",h5[q]??=U},M9={implementation:x5,Node:cq},m5=(X)=>{let U=[];if(X.prefix)for(let q of X.prefix)U.push({kind:"prefix",node:q});if(X.defaultables)for(let[q,Z]of X.defaultables)U.push({kind:"defaultables",node:q,default:Z});if(X.optionals)for(let q of X.optionals)U.push({kind:"optionals",node:q});if(X.variadic)U.push({kind:"variadic",node:X.variadic});if(X.postfix)for(let q of X.postfix)U.push({kind:"postfix",node:q});return U},lq=(X)=>X.reduce((U,q)=>{if(q.kind==="variadic")U.variadic=q.node;else if(q.kind==="defaultables")U.defaultables=y(U.defaultables,[[q.node,q.default]]);else U[q.kind]=y(U[q.kind],q.node);return U},{}),w9="A postfix required element cannot follow an optional or defaultable element",p5="A postfix element requires a variadic element",E2=(X)=>{let[U,...q]=X.l,[Z,...Q]=X.r;if(!U||!Z)return X;let G=q[q.length-1]?.kind==="postfix",Y=Q[Q.length-1]?.kind==="postfix",H=U.kind==="prefix"||Z.kind==="prefix"?"prefix":U.kind==="postfix"||Z.kind==="postfix"?"postfix":U.kind==="variadic"&&Z.kind==="variadic"?"variadic":G||Y?"prefix":U.kind==="defaultables"||Z.kind==="defaultables"?"defaultables":"optionals";if(U.kind==="prefix"&&Z.kind==="variadic"&&Y){let _=E2({...X,fixedVariants:[],r:Q.map((L)=>({...L,kind:"prefix"}))});if(_.disjoint.length===0)X.fixedVariants.push(_)}else if(Z.kind==="prefix"&&U.kind==="variadic"&&G){let _=E2({...X,fixedVariants:[],l:q.map((L)=>({...L,kind:"prefix"}))});if(_.disjoint.length===0)X.fixedVariants.push(_)}let J=u(U.node,Z.node,X.ctx);if(J instanceof B)if(H==="prefix"||H==="postfix")X.disjoint.push(...J.withPrefixKey(H==="prefix"?X.result.length:`-${q.length+1}`,dq(U)&&dq(Z)?"required":"optional")),X.result=[...X.result,{kind:H,node:V.intrinsic.never.internal}];else if(H==="optionals"||H==="defaultables")return X;else return E2({...X,fixedVariants:[],l:q.map((_)=>({..._,kind:"prefix"})),r:q.map((_)=>({..._,kind:"prefix"}))});else if(H==="defaultables"){if(U.kind==="defaultables"&&Z.kind==="defaultables"&&U.default!==Z.default)F(z9(U.default,Z.default));X.result=[...X.result,{kind:H,node:J,default:U.kind==="defaultables"?U.default:Z.kind==="defaultables"?Z.default:g(`Unexpected defaultable intersection from ${U.kind} and ${Z.kind} elements.`)}]}else X.result=[...X.result,{kind:H,node:J}];let W=X.l.length,$=X.r.length;if(U.kind!=="variadic"||W>=$&&(Z.kind==="variadic"||$===1))X.l=q;if(Z.kind!=="variadic"||$>=W&&(U.kind==="variadic"||W===1))X.r=Q;return E2(X)},dq=(X)=>X.kind==="prefix"||X.kind==="postfix";var rq=(X)=>(U)=>{if(U.props.length||U.index){let q=U.index?.map((Q)=>Q[X])??[];for(let Q of U.props)q.push(Q[X]);if(U.undeclared)q.push(`+ (undeclared): ${U.undeclared}`);let Z=`{ ${q.join(", ")} }`;return U.sequence?`${Z} & ${U.sequence.description}`:Z}return U.sequence?.description??"{}"},l5=rq("description"),d5=rq("expression"),iq=(X,U,q)=>{let Z=X.required?"required":"optional";if(!U.signature.allows(X.key))return null;let Q=W0(X.value,U.value,q);if(Q instanceof B)return Z==="optional"?q.node("optional",{key:X.key,value:V.intrinsic.never.internal}):Q.withPrefixKey(X.key,X.kind);return null},c5=b({kind:"structure",hasAssociatedError:!1,normalize:(X)=>X,applyConfig:(X,U)=>{if(!X.undeclared&&U.onUndeclaredKey!=="ignore")return{...X,undeclared:U.onUndeclaredKey};return X},keys:{required:{child:!0,parse:X0("required"),reduceIo:(X,U,q)=>{U.required=y(U.required,q.map((Z)=>X==="in"?Z.rawIn:Z.rawOut));return}},optional:{child:!0,parse:X0("optional"),reduceIo:(X,U,q)=>{if(X==="in"){U.optional=q.map((Z)=>Z.rawIn);return}for(let Z of q)U[Z.outProp.kind]=y(U[Z.outProp.kind],Z.outProp.rawOut)}},index:{child:!0,parse:X0("index")},sequence:{child:!0,parse:X0("sequence")},undeclared:{parse:(X)=>X==="ignore"?void 0:X,reduceIo:(X,U,q)=>{if(q==="reject"){U.undeclared="reject";return}if(X==="in")delete U.undeclared;else U.undeclared="reject"}}},defaults:{description:l5},intersections:{structure:(X,U,q)=>{let Z={...X.inner},Q={...U.inner},G=new B;if(X.undeclared){let J=X.keyof();for(let W of U.requiredKeys)if(!J.allows(W))G.add("presence",V.intrinsic.never.internal,U.propsByKey[W].value,{path:[W]});if(Q.optional)Q.optional=Q.optional.filter((W)=>J.allows(W.key));if(Q.index)Q.index=Q.index.flatMap((W)=>{if(W.signature.extends(J))return W;let $=W0(J,W.signature,q.$);if($ instanceof B)return[];let _=I6($,W.value,q.$);if(_.required)Q.required=f0(Q.required,_.required);if(_.optional)Q.optional=f0(Q.optional,_.optional);return _.index??[]})}if(U.undeclared){let J=U.keyof();for(let W of X.requiredKeys)if(!J.allows(W))G.add("presence",X.propsByKey[W].value,V.intrinsic.never.internal,{path:[W]});if(Z.optional)Z.optional=Z.optional.filter((W)=>J.allows(W.key));if(Z.index)Z.index=Z.index.flatMap((W)=>{if(W.signature.extends(J))return W;let $=W0(J,W.signature,q.$);if($ instanceof B)return[];let _=I6($,W.value,q.$);if(_.required)Z.required=f0(Z.required,_.required);if(_.optional)Z.optional=f0(Z.optional,_.optional);return _.index??[]})}let Y={};if(X.undeclared||U.undeclared)Y.undeclared=X.undeclared==="reject"||U.undeclared==="reject"?"reject":"delete";let H=j1({kind:"structure",baseInner:Y,l:f1(Z),r:f1(Q),roots:[],ctx:q});if(H instanceof B)G.push(...H);if(G.length)return G;return H}},reduce:(X,U)=>{if(!X.required&&!X.optional)return;let q={},Z=!1,Q=X.optional?[...X.optional]:[];if(X.required)for(let G=0;G<X.required.length;G++){let Y=X.required[G];if(Y.key in q)F(oq(Y.key));if(q[Y.key]=!0,X.index)for(let H of X.index){let J=iq(Y,H,U);if(J instanceof B)return J}}if(X.optional)for(let G=0;G<X.optional.length;G++){let Y=X.optional[G];if(Y.key in q)F(oq(Y.key));if(q[Y.key]=!0,X.index)for(let H of X.index){let J=iq(Y,H,U);if(J instanceof B)return J;if(J!==null)Q[G]=J,Z=!0}}if(Z)return U.node("structure",{...X,optional:Q},{prereduced:!0})}});class aq extends A0{impliedBasis=V.intrinsic.object.internal;impliedSiblings=this.children.flatMap((X)=>X.impliedSiblings??[]);props=f0(this.required,this.optional);propsByKey=S(this.props,(X,U)=>[U.key,U]);propsByKeyReference=d(this.propsByKey);expression=d5(this);requiredKeys=this.required?.map((X)=>X.key)??[];optionalKeys=this.optional?.map((X)=>X.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let X=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:U}of this.index)X=X.concat(U.branches);return this._keyof=this.$.node("union",X)}map(X){return this.$.node("structure",this.props.flatMap(X).reduce((U,q)=>{let Z=this.propsByKey[q.key];if(h(q)){if(q.kind!=="required"&&q.kind!=="optional")return F(`Map result must have kind "required" or "optional" (was ${q.kind})`);return U[q.kind]=y(U[q.kind],q),U}let Q=q.kind??Z?.kind??"required",G=S(q,(Y,H)=>(Y in I2.implementation.keys)?[Y,H]:[]);return U[Q]=y(U[Q],this.$.node(Q,G)),U},{}))}assertHasKeys(X){let U=X.filter((q)=>!N2(q,this.keyof()));if(U.length)return F(sq(this.expression,U))}get(X,...U){let q,Z=!1,Q=r5(X);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,V.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 H=this.sequence.prevariadic[Y].node;q=q?.and(H)??H,Z||=Y<this.sequence.prefixLength}else if(this.sequence.variadic){let H=this.$.node("union",this.sequence.variadicOrPostfix);q=q?.and(H)??H}}if(!q){if(this.sequence?.variadic&&M(Q,"root")&&Q.extends(V.intrinsic.number))return F(a5(Q.expression,this.sequence.expression));return F(sq(this.expression,[Q]))}let G=q.get(...U);return Z?G:G.or(V.intrinsic.undefined)}pick(...X){return this.assertHasKeys(X),this.$.node("structure",this.filterKeys("pick",X))}omit(...X){return this.assertHasKeys(X),this.$.node("structure",this.filterKeys("omit",X))}optionalize(){let{required:X,...U}=this.inner;return this.$.node("structure",{...U,optional:this.props.map((q)=>q.hasKind("required")?this.$.node("optional",q.inner):q)})}require(){let{optional:X,...U}=this.inner;return this.$.node("structure",{...U,required:this.props.map((q)=>q.hasKind("optional")?{key:q.key,value:q.value}:q)})}merge(X){let U=this.filterKeys("omit",[X.keyof()]);if(X.required)U.required=y(U.required,X.required);if(X.optional)U.optional=y(U.optional,X.optional);if(X.index)U.index=y(U.index,X.index);if(X.sequence)U.sequence=X.sequence;if(X.undeclared)U.undeclared=X.undeclared;else delete U.undeclared;return this.$.node("structure",U)}filterKeys(X,U){let q=F6(this.inner),Z=(Q)=>{let G=U.some((Y)=>N2(Q,Y));return X==="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=(X,U)=>this._traverse("Allows",X,U);traverseApply=(X,U)=>this._traverse("Apply",X,U);_traverse=(X,U,q)=>{let Z=q?.currentErrorCount??0;for(let Q=0;Q<this.props.length;Q++)if(X==="Allows"){if(!this.props[Q].traverseAllows(U,q))return!1}else if(this.props[Q].traverseApply(U,q),q.failFast&&q.currentErrorCount>Z)return!1;if(this.sequence){if(X==="Allows"){if(!this.sequence.traverseAllows(U,q))return!1}else if(this.sequence.traverseApply(U,q),q.failFast&&q.currentErrorCount>Z)return!1}if(this.index||this.undeclared==="reject"){let Q=Object.keys(U);Q.push(...Object.getOwnPropertySymbols(U));for(let G=0;G<Q.length;G++){let Y=Q[G];if(this.index){for(let H of this.index)if(H.signature.traverseAllows(Y,q)){if(X==="Allows"){if(!J0(Y,()=>H.value.traverseAllows(U[Y],q),q))return!1}else if(J0(Y,()=>H.value.traverseApply(U[Y],q),q),q.failFast&&q.currentErrorCount>Z)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(Y)){if(X==="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((X)=>X.hasDefault())??[])}declaresKey=(X)=>(X in this.propsByKey)||this.index?.some((U)=>U.signature.allows(X))||this.sequence!==void 0&&V.intrinsic.nonNegativeIntegerString.allows(X);_compileDeclaresKey(X){let U=[];if(this.props.length)U.push(`k in ${this.propsByKeyReference}`);if(this.index)for(let q of this.index)U.push(X.invoke(q.signature,{kind:"Allows",arg:"k"}));if(this.sequence)U.push("$ark.intrinsic.nonNegativeIntegerString.allows(k)");return U.join(" || ")||"false"}get structuralMorph(){return this.cacheGetter("structuralMorph",s5(this))}structuralMorphRef=this.structuralMorph&&d(this.structuralMorph);compile(X){if(X.traversalKind==="Apply")X.initializeErrorCount();for(let U of this.props)if(X.check(U),X.traversalKind==="Apply")X.returnIfFailFast();if(this.sequence){if(X.check(this.sequence),X.traversalKind==="Apply")X.returnIfFailFast()}if(this.index||this.undeclared==="reject")X.const("keys","Object.keys(data)"),X.line("keys.push(...Object.getOwnPropertySymbols(data))"),X.for("i < keys.length",()=>this.compileExhaustiveEntry(X));if(X.traversalKind==="Allows")return X.return(!0);if(this.structuralMorphRef)X.if("ctx && !ctx.hasError()",()=>{return X.line("ctx.queueMorphs(["),o5(X,this),X.line("])")})}compileExhaustiveEntry(X){if(X.const("k","keys[i]"),this.index)for(let U of this.index)X.if(`${X.invoke(U.signature,{arg:"k",kind:"Allows"})}`,()=>X.traverseKey("k","data[k]",U.value));if(this.undeclared==="reject")X.if(`!(${this._compileDeclaresKey(X)})`,()=>{if(X.traversalKind==="Allows")return X.return(!1);return X.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast",()=>X.return())});return X}reduceJsonSchema(X,U){switch(X.type){case"object":return this.reduceObjectJsonSchema(X,U);case"array":let q=this.sequence?.reduceJsonSchema(X,U)??X;if(this.props.length||this.index)return U.fallback.arrayObject({code:"arrayObject",base:q,object:this.reduceObjectJsonSchema({type:"object"},U)});return q;default:return p.throwInternalOperandError("structure",X)}}reduceObjectJsonSchema(X,U){if(this.props.length){X.properties={};for(let q of this.props){let Z=q.value.toJsonSchemaRecurse(U);if(typeof q.key==="symbol"){U.fallback.symbolKey({code:"symbolKey",base:X,key:q.key,value:Z,optional:q.optional});continue}if(q.hasDefault()){let Q=typeof q.default==="function"?q.default():q.default;Z.default=V.intrinsic.jsonData.allows(Q)?Q:U.fallback.defaultValue({code:"defaultValue",base:Z,value:Q})}X.properties[q.key]=Z}if(this.requiredKeys.length&&X.properties)X.required=this.requiredKeys.filter((q)=>typeof q==="string"&&(q in X.properties))}if(this.index)for(let q of this.index){let Z=q.value.toJsonSchemaRecurse(U);if(q.signature.equals(V.intrinsic.string)){X.additionalProperties=Z;continue}for(let Q of q.signature.branches){if(!Q.extends(V.intrinsic.string)){X=U.fallback.symbolKey({code:"symbolKey",base:X,key:null,value:Z,optional:!1});continue}let G={type:"string"};if(Q.hasKind("morph"))G=U.fallback.morph({code:"morph",base:Q.rawIn.toJsonSchemaRecurse(U),out:Q.rawOut.toJsonSchemaRecurse(U)});if(!Q.hasKind("intersection"))return g(`Unexpected index branch kind ${Q.kind}.`);let{pattern:Y}=Q.inner;if(Y){let H=Object.assign(G,{pattern:Y[0].rule});for(let J=1;J<Y.length;J++)G=U.fallback.patternIntersection({code:"patternIntersection",base:H,pattern:Y[J].rule});X.patternProperties??={},X.patternProperties[H.pattern]=Z}}}if(this.undeclared&&!X.additionalProperties)X.additionalProperties=!1;return X}}var P9={},i5=(X)=>{let U="";for(let q=0;q<X.defaultable.length;q++)U+=X.defaultable[q].defaultValueMorphRef;if(X.sequence?.defaultValueMorphsReference)U+=X.sequence?.defaultValueMorphsReference;if(X.undeclared==="delete"){if(U+="delete !(",X.required)for(let q of X.required)U+=q.compiledKey+" | ";if(X.optional)for(let q of X.optional)U+=q.compiledKey+" | ";if(X.index)for(let q of X.index)U+=q.signature.id+" | ";if(X.sequence)if(X.sequence.maxLength===null)U+=I.nonNegativeIntegerString.id;else for(let q=0;q<X.sequence.tuple.length;q++)U+=q+" | ";U+=")"}return U},s5=(X)=>{let U=i5(X);if(!U)return;if(P9[U])return P9[U];let q=(Z,Q)=>{for(let G=0;G<X.defaultable.length;G++)if(!(X.defaultable[G].key in Z))X.defaultable[G].defaultValueMorph(Z,Q);if(X.sequence?.defaultables)for(let G=Z.length-X.sequence.prefixLength;G<X.sequence.defaultables.length;G++)X.sequence.defaultValueMorphs[G](Z,Q);if(X.undeclared==="delete"){for(let G in Z)if(!X.declaresKey(G))delete Z[G]}return Z};return P9[U]=q},o5=(X,U)=>{let Z=`(data${U.defaultable.some((Q)=>Q.defaultValueMorph.length===2)||U.sequence?.defaultValueMorphs.some((Q)=>Q.length===2)?", ctx":""})`;return X.block(`${Z} => `,(Q)=>{for(let G=0;G<U.defaultable.length;G++){let{serializedKey:Y,defaultValueMorphRef:H}=U.defaultable[G];Q.if(`!(${Y} in data)`,(J)=>J.line(`${H}${Z}`))}if(U.sequence?.defaultables)Q.for(`i < ${U.sequence.defaultables.length}`,(G)=>G.set("data[i]",5),`data.length - ${U.sequence.prefixLength}`);if(U.undeclared==="delete")Q.forIn("data",(G)=>G.if(`!(${U._compileDeclaresKey(G)})`,(Y)=>Y.line("delete data[k]")));return Q.return("data")})},I9={implementation:c5,Node:aq},r5=(X)=>{if(M(X,"root")&&X.hasKind("unit"))X=X.unit;if(typeof X==="number")X=`${X}`;return X},a5=(X,U)=>`${X} is not allowed as an array index on ${U}. Use the 'nonNegativeIntegerString' keyword instead.`,I6=(X,U,q)=>{let[Z,Q]=LU(X.branches,(Y)=>Y.hasKind("unit"));if(!Z.length)return{index:q.node("index",{signature:X,value:U})};let G={};for(let Y of Z){let H=q.node("required",{key:Y.unit,value:U});G[H.kind]=y(G[H.kind],H)}if(Q.length)G.index=q.node("index",{signature:Q,value:U});return G},n5=(X)=>M(X,"root")?X.expression:E(X),sq=(X,U)=>`Key${U.length===1?"":"s"} ${U.map(n5).join(", ")} ${U.length===1?"does":"do"} not exist on ${X}`,oq=(X)=>`Duplicate key ${M0(X)}`;var g1={...Vq,alias:C2.implementation,domain:P6.implementation,unit:T9.implementation,proto:S2.implementation,union:B9.implementation,morph:V9.implementation,intersection:A9.implementation,divisor:U9.implementation,pattern:W9.implementation,predicate:X9.implementation,required:D9.implementation,optional:I2.implementation,index:R9.implementation,sequence:M9.implementation,structure:I9.implementation};V.defaultConfig=DU(Object.assign(S(g1,(X,U)=>[X,U.defaults]),{jitless:NU(),clone:PU,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:p.defaultConfig}));V.resolvedConfig=B2(V.defaultConfig,V.config);var Mq={...Oq,alias:C2.Node,domain:P6.Node,unit:T9.Node,proto:S2.Node,union:B9.Node,morph:V9.Node,intersection:A9.Node,divisor:U9.Node,pattern:W9.Node,predicate:X9.Node,required:D9.Node,optional:I2.Node,index:R9.Node,sequence:M9.Node,structure:I9.Node};class x1 extends g4{get[U0](){return"module"}}var K9=(X,U)=>new x1(S(X,(q,Z)=>[q,M(Z,"module")?K9(Z,U):U.bindReference(Z)]));var t5=(X)=>x(X)?X:("branches"in X)&&x(X.branches)?X.branches:void 0,e5=(X,U)=>F(`Node of kind ${U} is not valid as a ${X} definition`),nq=(X)=>`#${X} duplicates public alias ${X}`,N9={};V.ambient??={};var tq,XZ="function $",XY=(X)=>UZ(X,qZ(X)),UZ=(X,U)=>{let q=U.write(XZ,4),Z=U.compile()();for(let Q of X){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}},qZ=(X)=>new z6().return(X.reduce((U,q)=>{let Z=new O2({kind:"Allows"}).indent();q.compile(Z);let Q=Z.write(`${q.id}Allows`),G=new O2({kind:"Apply"}).indent();q.compile(G);let Y=G.write(`${q.id}Apply`),H=`${U}${Q},
180
180
  ${Y},
181
- `;if(!q.hasKind("union"))return H;let J=new $2({kind:"Allows",optimistic:!0}).indent();q.compile(J);let W=J.write(`${q.id}Optimistic`);return`${H}${W},
181
+ `;if(!q.hasKind("union"))return H;let J=new O2({kind:"Allows",optimistic:!0}).indent();q.compile(J);let W=J.write(`${q.id}Optimistic`);return`${H}${W},
182
182
  `},`{
183
- `)+"}");class M6{config;resolvedConfig;name;get[X0](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(U,X){if(this.config=z2(T.config,X),this.resolvedConfig=z2(T.resolvedConfig,X),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(D9).length}`,this.name in D9)F(`A Scope already named ${this.name} already exists`);D9[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(dq(G));this.aliases[G]=Q}else{if(G in this.aliases)F(dq(Z));this.aliases[G]=Q,this.exportedNames.push(G)}if(!M(Q,"module")&&!M(Q,"generic")&&!l0(Q)){let Y=this.preparseOwnDefinitionFormat(Q,{alias:G});this.resolutions[G]=M(Y,"root")?this.bindReference(Y):this.createParseContext(Y).id}}cq??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[cq.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=T.intrinsic?S(T.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 s0(U,Z?new F6(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(O2(U),U,X);preparseNode(U,X,q){let Z=typeof U==="string"?U:O2(X,U);if(h(X)&&X.kind===Z)return X;if(Z==="alias"&&!q?.prereduced){let{reference:Y}=w2.implementation.normalize(X,this);if(Y.startsWith("$")){let H=this.resolveRoot(Y.slice(1));X=H,Z=H.kind}}else if(Z==="union"&&Q0(X,"object")){let Y=i5(X);if(Y?.length===1)X=Y[0],Z=O2(X)}if(h(X)&&X.kind===Z)return X;let G=g1[Z].normalize?.(X,this)??X;if(h(G))return G.kind===Z?G:o5(Z,G.kind);return{...q,$:this,kind:Z,def:G,prefix:q.alias??Z}}bindReference(U){let X;if(h(U))X=U.$===this?U:new U.constructor(U.attachments,this);else X=U.$===this?U:new s0(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(P9(U))}maybeResolveRoot(U){let X=this.maybeResolve(U);if(M(X,"generic"))return;return X}maybeResolveSubalias(U){return M9(this.aliases,U)??M9(this.ambient,U)}get ambient(){return T.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(tq(U));return this.resolutions[U]=this.bindReference(q.root)}return this.resolutions[U]=this.parse(q,{alias:U})}createParseContext(U){let X=U.id??Q9(U.prefix);return q0[X]=Object.assign(U,{[X0]:"context",$:this,id:X,phase:"unresolved"})}traversal(U){return new M0(U,this.resolvedConfig)}import(...U){return new v1(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")?R9(Z,this):iq(this.maybeResolve(q))}for(let q of this.lazyResolutions)q.resolution;if(this._exportedResolutions=aq(this,this._exports),this._json=nq(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let q=rq(this.references);this.precompilation=q.write(oq,4),sq(this.references,q)}this.resolved=!0}let X=U.length?U:this.exportedNames;return new v1(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(h(Z))return this.bindReference(Z);let Q=this.createParseContext(Z),G=G9(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=Fq(Q,Z.id);return q0[Z.id]=Q,Q}finalize(U){if(iq(U),!U.precompilation&&!this.resolvedConfig.jitless)s5(U.references);return U}}class w9 extends M6{parseOwnDefinitionFormat(U,X){return G9(X)}preparseOwnDefinitionFormat(U,X){return this.preparseNode(O2(U),U,X)}preparseOwnAliasEntry(U,X){return[U,X]}normalizeRootScopeValue(U){return U}}var iq=(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},nq=(U)=>S(U,(X,q)=>[X,M(q,"root")||M(q,"generic")?q.json:M(q,"module")?nq(q):y(`Unexpected resolution ${E(q)}`)]),M9=(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(r5(Z));let G=X.slice(q+1),Y=Q[G];if(Y===void 0)return M9(Q,G);if(M(Y,"root")||M(Y,"generic"))return Y;if(M(Y,"module"))return Y.root??F(tq(X));y(`Unexpected resolution for alias '${X}': ${E(Y)}`)},w6=(U,X)=>new w9(U,X),K2=new w9({});var aq=(U,X)=>{let q={};for(let Z in X){let Q=X[Z];if(M(Q,"module")){let G=aq(U,Q),Y=S(G,(H,J)=>[`${Z}.${H}`,J]);Object.assign(q,Y)}else if(M(Q,"root")||M(Q,"generic"))q[Z]=Q;else y(`Unexpected scope resolution ${E(Q)}`)}return q},P9=(U)=>`'${U}' is unresolvable`,r5=(U)=>`'${U}' must reference a module to be accessed using dot syntax`,tq=(U)=>`Reference to submodule '${U}' must specify an alias`;K2.export();var{schema:v,node:x1,defineSchema:Bw,generic:O0}=K2;var I9="^(?:0|[1-9]\\d*)$",n5=new RegExp(I9),Mw=d(n5);var eq=w6({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();T.intrinsic={...eq};var UZ=w6({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:I9}},{prereducedAliases:!0}).export();Object.assign(T.intrinsic,UZ);var a5=w6({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),I={...eq,...UZ,...a5,emptyStructure:x1("structure",{},{prereduced:!0})};T.intrinsic={...I};var P6=(U,X)=>new RegExp(U,X);Object.assign(P6,{as:P6});var qZ=(U)=>typeof U==="string"&&U[0]==="d"&&(U[1]==="'"||U[1]==='"')&&U[U.length-1]===U[1],XZ=(U)=>U.toString()!=="Invalid Date",ZZ=(U)=>U.slice(2,-1),K9=(U)=>`'${U}' could not be parsed by the Date constructor`,QZ=(U,X)=>t5(U,X),t5=(U,X)=>{let q=new Date(U);if(XZ(q))return q;let Z=EX(U);if(Z!==void 0){let Q=new Date(Z);if(XZ(Q))return Q}return X?F(X===!0?K9(U):X):void 0};var e5=v({proto:"Array",sequence:"string",required:{key:"groups",value:["object",{unit:void 0}]}}),I6=(U,X)=>{let q=U.scanner.shiftUntilEscapable(XY[HZ[X]]);if(U.scanner.lookahead==="")return U.error(ZY(q,X));if(U.scanner.shift(),X in YZ){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:e5})}else if(n(X,N9))U.root=U.ctx.$.node("unit",{unit:q});else{let Z=QZ(q,K9(q));U.root=U.ctx.$.node("unit",{meta:q,unit:Z})}},N9={"'":1,'"':1},GZ={"/":1,"'":1,'"':1},UY={"d'":"'",'d"':'"',"'":"'",'"':'"'},YZ={"/":"/","x/":"/"},HZ={...UY,...YZ},XY={"'":(U)=>U.lookahead==="'",'"':(U)=>U.lookahead==='"',"/":(U)=>U.lookahead==="/"},qY={'"':"double-quote","'":"single-quote","/":"forward slash"},ZY=(U,X)=>`${X}${U} requires a closing ${qY[HZ[X]]}`;var JZ=(U)=>`Private type references should not include '#'. Use '${U}' instead.`,K6="Optional definitions like 'string?' are only valid as properties in an object or tuple",N6="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var E0={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...d0};var WZ=(U,X)=>U===">"?X[0]==="="?X[1]==="=":X.trimStart()===""||n(X.trimStart()[0],E0):U==="="?X[0]!=="=":U===","||U==="?";var LZ=(U,X,q)=>_Z(U,X,q,[]),_Z=(U,X,q,Z)=>{let Q=q.parseUntilFinalizer();if(Z.push(Q.root),Q.finalizer===">"){if(Z.length!==X.params.length)return q.error(C9(U,X.names,Z.map((G)=>G.expression)));return Z}if(Q.finalizer===",")return _Z(U,X,q,Z);return Q.error(J6(">"))},C9=(U,X,q)=>`${U}<${X.join(", ")}> requires exactly ${X.length} args (got ${q.length}${q.length===0?"":`: ${q.join(", ")}`})`;var C6=(U)=>{let X=U.scanner.shiftUntilLookahead(E0);if(X==="keyof")U.addPrefix("keyof");else U.root=GY(U,X)},QY=(U,X,q)=>{if(q.scanner.shiftUntilNonWhitespace(),q.scanner.shift()!=="<")return q.error(C9(U,X.names,[]));let Q=LZ(U,X,q);return X(...Q)},GY=(U,X)=>YY(U,X)??HY(U,X)??U.error(X===""?U.scanner.lookahead==="#"?JZ(U.shiftedBy(1).scanner.shiftUntilLookahead(E0)):S9(U):P9(X)),YY=(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 QY(X,q,U);return F(`Unexpected resolution ${E(q)}`)},HY=(U,X)=>{let q=bX(X);if(q!==void 0)return U.ctx.$.node("unit",{unit:q});let Z=fX(X);if(Z!==void 0)return U.ctx.$.node("unit",{unit:Z})},S9=(U)=>{let X=U.previousOperator();return X?E9(X,U.scanner.unscanned):JY(U.scanner.unscanned)},E9=(U,X="")=>`Token '${U}' requires a right operand${X?` before '${X}'`:""}`,JY=(U)=>`Expected an expression${U?` before '${U}'`:""}`;var b9=(U)=>U.scanner.lookahead===""?U.error(S9(U)):U.scanner.lookahead==="("?U.shiftedBy(1).reduceGroupOpen():U.scanner.lookaheadIsIn(GZ)?I6(U,U.scanner.shift()):U.scanner.lookaheadIsIn(d0)?b9(U.shiftedBy(1)):U.scanner.lookahead==="d"?U.scanner.nextLookahead in N9?I6(U,`${U.scanner.shift()}${U.scanner.shift()}`):C6(U):U.scanner.lookahead==="x"?U.scanner.nextLookahead==="/"?U.shiftedBy(2)&&I6(U,"x/"):C6(U):C6(U);var $Z={">":!0,">=":!0},zZ={"<":!0,"<=":!0};var h1={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},FZ=(U,X)=>`Left bounds are only valid when paired with right bounds (try ...${X}${U})`,S6=(U)=>`Left-bounded expressions must specify their limits using < or <= (was ${U})`,AZ=(U,X,q,Z)=>`An expression may have at most one left bound (parsed ${U}${h1[X]}, ${q}${h1[Z]})`;var OZ=(U,X)=>{let q=WY(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 _Y(U,q)},VZ={"<":1,">":1,"=":1},WY=(U,X)=>U.scanner.lookaheadIs("=")?`${X}${U.scanner.shift()}`:X;var TZ=(U,X,q,Z)=>{if(q.extends(T.intrinsic.number)){if(typeof X!=="number")return F(j9(U,X,Z));return U==="=="?["min","max"]:U[0]===">"?["min"]:["max"]}if(q.extends(T.intrinsic.lengthBoundable)){if(typeof X!=="number")return F(j9(U,X,Z));return U==="=="?["exactLength"]:U[0]===">"?["minLength"]:["maxLength"]}if(q.extends(T.intrinsic.Date))return U==="=="?["after","before"]:U[0]===">"?["after"]:["before"];return F(Xq(q.expression))},LY=(U)=>({rule:qZ(U.limit)?ZZ(U.limit):U.limit,exclusive:U.comparator.length===1}),_Y=(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(j9(X,G,"right"));let Y=Q.unit,H=X.length===1,J=TZ(X,typeof Y==="number"?Y:G,q,"right");for(let _ of J)U.constrainRoot(_,X==="=="?{rule:Y}:{rule:Y,exclusive:H});if(!U.branches.leftBound)return;if(!n(X,zZ))return U.error(S6(X));let W=TZ(U.branches.leftBound.comparator,U.branches.leftBound.limit,q,"left");U.constrainRoot(W[0],LY(U.branches.leftBound)),U.branches.leftBound=null},j9=(U,X,q)=>`Comparator ${q==="left"?h1[U]:U} must be ${q==="left"?"preceded":"followed"} by a corresponding literal (was ${X})`;var BZ=(U)=>{U.scanner.shiftUntilNonWhitespace();let X=U.scanner.shiftUntilLookahead(E0);U.root=U.root.brand(X)};var DZ=(U)=>{U.scanner.shiftUntilNonWhitespace();let X=U.scanner.shiftUntilLookahead(E0),q=jX(X,{errorOnFail:RZ(X)});if(q===0)U.error(RZ(0));U.root=U.root.constrain("divisor",q)},RZ=(U)=>`% operator must be followed by a non-zero integer literal (was ${U})`;var f9=(U)=>{let X=U.scanner.shift();return X===""?U.finalize(""):X==="["?U.scanner.shift()==="]"?U.setRoot(U.root.array()):U.error($Y):X==="|"?U.scanner.lookahead===">"?U.shiftedBy(1).pushRootToBranch("|>"):U.pushRootToBranch(X):X==="&"?U.pushRootToBranch(X):X===")"?U.finalizeGroup():WZ(X,U.scanner.unscanned)?U.finalize(X):n(X,VZ)?OZ(U,X):X==="%"?DZ(U):X==="#"?BZ(U):(X in d0)?f9(U):U.error(E6(X))},E6=(U,X="")=>`'${U}' is not allowed here${X&&` (should be ${X})`}`,$Y="Missing expected ']'";var MZ=(U)=>{let X=U.unsetRoot();U.parseOperand();let q=U.unsetRoot();if(!q.hasKind("unit"))return U.error(zY(q.expression));let Z=q.unit instanceof Date?()=>new Date(q.unit):q.unit;return[X,"=",Z]},zY=(U)=>`Default value '${U}' must be a literal value`;var g9=(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 u1(new _2(U),X),Q=FY(Z);if(Z.finalizer===">")F(E6(">"));return Q},FY=(U)=>{U.parseOperand();let X=N2(U).root;if(!X)return y(`Root was unexpectedly unset after parsing string '${U.scanner.scanned}'`);if(U.finalizer==="=")X=MZ(U);else if(U.finalizer==="?")X=[X,"?"];if(U.scanner.shiftUntilNonWhitespace(),U.scanner.lookahead)F(E6(U.scanner.lookahead));return X},N2=(U)=>{while(U.finalizer===void 0)AY(U);return U},AY=(U)=>U.hasRoot()?U.parseOperator():U.parseOperand();class u1{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(J6(")"));this.finalizeBranches(),this.finalizer=U}reduceLeftBound(U,X){let q=h1[X];if(!n(q,$Z))return this.error(S6(X));if(this.branches.leftBound)return this.error(AZ(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(vX(")",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 N2(new u1(this.scanner,this.ctx))}parseOperator(){return f9(this)}parseOperand(){return b9(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(FZ(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 TY="An empty string is not a valid generic parameter name",b6=(U,X,q)=>{U.shiftUntilNonWhitespace();let Z=U.shiftUntilLookahead(E0);if(Z===""){if(U.lookahead===""&&X.length)return X;return F(TY)}return U.shiftUntilNonWhitespace(),OY(U,Z,X,q)},wZ="extends ",OY=(U,X,q,Z)=>{if(U.shiftUntilNonWhitespace(),U.unscanned.startsWith(wZ))U.jumpForward(wZ.length);else{if(U.lookahead===",")U.shift();return q.push(X),b6(U,q,Z)}let Q=N2(new u1(U,Z));return q.push([X,Q.root]),b6(U,q,Z)};class y9 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"),H=U.intrinsic.unknown;if(Z!==-1){if(Z!==q.length-2)return F(VY);H=U.parse(q[Z+1])}return(J)=>new PZ(J,Y,H)},{attach:X})}}class PZ extends H0{raw;params;returns;expression;constructor(U,X,q){let Z=`typed ${U.name}`,Q={[Z]:(...Y)=>{let H=X.assert(Y),J=U(...H);return q.assert(J)}}[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 VY=`":" must be followed by exactly one return type e.g:
184
- fn("string", ":", "number")(s => s.length)`;class k9 extends H0{$;constructor(U){super((...X)=>new C2(U)(...X),{bind:U});this.$=U}in(U){return new C2(this.$,U===void 0?void 0:this.$.parse(U))}at(U,X){return new C2(this.$).at(U,X)}case(U,X){return new C2(this.$).case(U,X)}}class C2 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(RY);if(this.branches.length)F(BY);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:IZ};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:IZ},"self");return this.$.finalize(Z)}}var IZ=(U)=>U.throw(),BY="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",RY="At most one key matcher may be specified per expression";var j6=(U,X)=>{if(x(U)){if(U[1]==="=")return[X.$.parseOwnDefinitionFormat(U[0],X),"=",U[2]];if(U[1]==="?")return[X.$.parseOwnDefinitionFormat(U[0],X),"?"]}return f6(U,X)},KZ="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",NZ="Only required keys may specify default values, e.g. { value: 'number = 0' }";var CZ=(U,X)=>{let q,Z={},Q=Y1(U);for(let[Y,H]of Q){let J=wY(Y);if(J.kind==="spread"){if(!C0(Z))return F(MY);let A=X.$.parseOwnDefinitionFormat(H,X);if(A.equals(I.object))continue;if(!A.hasKind("intersection")||!A.basis?.equals(I.object))return F(PY(A.expression));q=A.structure;continue}if(J.kind==="undeclared"){if(H!=="reject"&&H!=="delete"&&H!=="ignore")F(DY(H));Z.undeclared=H;continue}let W=j6(H,X),_=J;if(J.kind==="required"){if(!x(W))v9(Z,"required",{key:J.normalized,value:W},X);else v9(Z,"optional",W[1]==="="?{key:J.normalized,value:W[0],default:W[2]}:{key:J.normalized,value:W[0]},X);continue}if(x(W)){if(W[1]==="?")F(KZ);if(W[1]==="=")F(NZ)}if(J.kind==="optional"){v9(Z,"optional",{key:J.normalized,value:W},X);continue}let L=X.$.parseOwnDefinitionFormat(_.normalized,X),$=D6(L,W,X.$);if($.index)Z.index=g(Z.index,$.index);if($.required)Z.required=g(Z.required,$.required)}let G=X.$.node("structure",Z);return X.$.parseSchema({domain:"object",structure:q?.merge(G)??G})},v9=(U,X,q,Z)=>{U[X]=g(U[X],Z.$.node(X,q))},DY=(U)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${E(U)})`,MY="Spread operator may only be used as the first key in an object",wY=(U)=>typeof U==="symbol"?{kind:"required",normalized:U}:U[U.length-1]==="?"?U[U.length-2]===J1?{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]===J1&&U[1]==="["&&U[U.length-1]==="]"?{kind:"required",normalized:U.slice(1)}:U==="..."?{kind:"spread"}:U==="+"?{kind:"undeclared"}:{kind:"required",normalized:U==="\\..."?"...":U==="\\+"?"+":U},PY=(U)=>`Spread operand must resolve to an object literal type (was ${U})`;var EZ=(U,X)=>gY(U)?gZ[U[0]](U,X):jY(U)?fZ[U[1]](U,X):null,IY=(U,X)=>X.$.parseOwnDefinitionFormat(U[1],X).keyof(),x9=(U,X)=>{if(U[2]===void 0)return F(E9(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]==="&"?L0(q,Z,X.$):T2(q,Z,X.$);if(Q instanceof V)return Q.throw();return Q},KY=(U,X)=>X.$.parseOwnDefinitionFormat(U[0],X).array(),NY=(U,X)=>{if(typeof U[2]!=="function")return F(bZ("=>",U[2]));return X.$.parseOwnDefinitionFormat(U[0],X).pipe(U[2])},bZ=(U,X)=>`${U===":"?"Narrow":"Morph"} expression requires a function following '${U}' (was ${typeof X})`,CY=(U,X)=>{if(typeof U[2]!=="function")return F(bZ(":",U[2]));return X.$.parseOwnDefinitionFormat(U[0],X).constrain("predicate",U[2])},SY=(U,X)=>X.$.parseOwnDefinitionFormat(U[0],X).configure(U[2],U[3]),jZ=(U)=>U,EY=jZ({"[]":KY,"?":()=>F(K6)}),bY=jZ({"|":x9,"&":x9,":":CY,"=>":NY,"|>":x9,"@":SY,"=":()=>F(N6)}),fZ={...EY,...bY},jY=(U)=>fZ[U[1]]!==void 0,fY=(U)=>U,gZ=fY({keyof:IY,instanceof:(U,X)=>{if(typeof U[1]!=="function")return F(SZ(Q2(U[1])));let q=U.slice(1).map((Z)=>typeof Z==="function"?X.$.node("proto",{proto:Z}):F(SZ(Q2(Z))));return q.length===1?q[0]:X.$.node("union",{branches:q})},"===":(U,X)=>X.$.units(U.slice(1))}),gY=(U)=>gZ[U[0]]!==void 0,SZ=(U)=>`Expected a constructor following 'instanceof' operator (was ${U})`;var vZ=(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=j6(U[Z],X),[Y,H,J]=!x(G)?[G]:G;if(Z++,Q){if(!Y.extends(T.intrinsic.Array))return F(vY(Y.expression));q=q.flatMap((W)=>Y.distribute((_)=>kY(L6(W),_)))}else q=q.map((W)=>{if(H==="?")return xZ(W,Y);if(H==="=")return yY(W,Y,J);return h9(W,Y)})}return X.$.parseSchema(q.map((Q)=>C0(Q)?{proto:Array,exactLength:0}:{proto:Array,sequence:Q}))},h9=(U,X)=>{if(U.defaultables||U.optionals)return F(U.variadic?O9:xY);if(U.variadic)U.postfix=g(U.postfix,X);else U.prefix=g(U.prefix,X);return U},xZ=(U,X)=>{if(U.variadic)return F(hZ);return U.optionals=g(U.optionals,X),U},yY=(U,X,q)=>{if(U.variadic)return F(hZ);if(U.optionals)return F(hY);return U.defaultables=g(U.defaultables,[[X,q]]),U},yZ=(U,X)=>{if(U.postfix)F(kZ);if(U.variadic){if(!U.variadic.equals(X))F(kZ)}else U.variadic=X.internal;return U},kY=(U,X)=>{let q=X.select({method:"find",kind:"sequence"});if(!q)return yZ(U,T.intrinsic.unknown);if(q.prefix)for(let Z of q.prefix)h9(U,Z);if(q.optionals)for(let Z of q.optionals)xZ(U,Z);if(q.variadic)yZ(U,q.variadic);if(q.postfix)for(let Z of q.postfix)h9(U,Z);return U},vY=(U)=>`Spread element must be an array (was ${U})`,kZ="A tuple may have at most one variadic element",xY="A required element may not follow an optional element",hZ="An optional element may not follow a variadic element";var hY="A defaultable element may not follow an optional element without a default";var uY={},f6=(U,X)=>{if(typeof U==="string"){if(X.args&&Object.keys(X.args).some((Z)=>U.includes(Z)))return g9(U,X);let q=uY[X.$.name]??={};return q[U]??=g9(U,X)}return Q0(U,"object")?mY(U,X):F(u9(r(U)))},mY=(U,X)=>{let q=Z2(U);switch(q){case void 0:if(M(U,"root"))return U;if("~standard"in U)return pY(U,X);return CZ(U,X);case"Array":return lY(U,X);case"RegExp":return X.$.node("intersection",{domain:"string",pattern:U},{prereduced:!0});case"Function":{let Z=l0(U)?U():U;if(M(Z,"root"))return Z;return F(u9("Function"))}default:return F(u9(q??E(U)))}},pY=(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:PX(G),relativePath:Y.map((H)=>typeof H==="object"?H.key:H)});else Z.error({message:G});else Z.error({message:G})}),lY=(U,X)=>EZ(U,X)??vZ(U,X),u9=(U)=>`Type definitions must be strings or objects (was ${U})`;class m9 extends H0{constructor(U){let X=Object.assign({errors:J0,hkt:e,$: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 s0(Q,q[1],U,U,null)}return U.parse(q)},{attach:X})}}var m1=T;class g6 extends M6{get ambientAttachments(){if(!m1.typeAttachments)return;return this.cacheGetter("ambientAttachments",S(m1.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 tX(G,X,this)}]}parseGenericParams(U,X){return b6(new _2(U),[],this.createParseContext({...X,def:U,prefix:"generic"}))}normalizeRootScopeValue(U){if(l0(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=f6(U,X);if(x(Z)){if(Z[1]==="=")return F(N6);if(Z[1]==="?")return F(K6)}return Z}unit=(U)=>this.units([U]);valueOf=(U)=>this.units(AX(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 y9(this);match=new k9(this);declare=()=>({type:this.type});define(U){return U}type=new m9(this);static scope=(U,X={})=>new g6(U,X);static module=(U,X={})=>this.scope(U,X).export()}var S2=Object.assign(g6.scope,{define:(U)=>U}),f=g6;class uZ extends e{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var dY=O0(["base",I.object],["props",I.object])((U)=>U.base.merge(U.props),uZ),mZ=f.module({Key:I.key,Merge:dY});class pZ extends e{}var cY=O0("element")((U)=>{let X=U.element.exclude(I.Array),q=X.array();return X.rawOr(q).pipe(p0).distribute((Z)=>Z.assertHasKind("morph").declareOut(q),v)},pZ),lZ=f.module({root:I.Array,readonly:"root",index:I.nonNegativeIntegerString,liftFrom:cY},{name:"Array"});var p9=v(["string",W1.FileConstructor]),iY=p9.rawOr(p9.array()),dZ=v({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:iY}}),cZ=f.module({root:["instanceof",FormData],value:p9,parsed:dZ,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 W1.FileConstructor)X[q]=[Q,Z];else Q.push(Z)}else X[q]=Z;return X},declaredOut:dZ})},{name:"FormData"});var iZ=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 oY={Boolean:1,Number:1,String:1},oZ=f.module({...S({...E4,...j4},(U,X)=>(U in oY)?[]:[U,["instanceof",X]]),Array:lZ,TypedArray:iZ,FormData:cZ});var sY=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"}),rY=v({domain:"number",divisor:1}),y6=f.module({root:I.number,integer:rY,epoch:sY,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 x1("intersection",Z)},sZ=l(Y2,"a well-formed integer string"),Y8=f.module({root:sZ,parse:v({in:sZ,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"}),nY=l(/^[\dA-Fa-f]+$/,"hex characters only"),aY=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"}),rZ=l(/^[A-Z].*$/,"capitalized"),tY=f.module({root:v({in:"string",morphs:(U)=>U.charAt(0).toUpperCase()+U.slice(1),declaredOut:rZ}),preformatted:rZ},{name:"string.capitalize"}),eY=(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)},U7=/^(?: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}))$/,X7=v({domain:"string",pattern:{meta:"a credit card number",rule:U7.source},predicate:{meta:"a credit card number",predicate:eY}});var q7=/^([+-]?\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 Z7=(U)=>!Number.isNaN(new Date(U).valueOf()),nZ=v({domain:"string",predicate:{meta:"a parsable date",predicate:Z7}}).assertHasKind("intersection"),aZ=Y8.root.internal.narrow((U,X)=>{let q=Number.parseInt(U),Z=y6.epoch(q);if(Z instanceof J0)return X.errors.merge(Z),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),Q7=f.module({root:aZ,parse:v({in:aZ,morphs:(U)=>new Date(U),declaredOut:I.Date})},{name:"string.date.epoch"}),tZ=l(q7,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),G7=f.module({root:tZ,parse:v({in:tZ,morphs:(U)=>new Date(U),declaredOut:I.Date})},{name:"string.date.iso"}),Y7=f.module({root:nZ,parse:v({declaredIn:nZ,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:G7,epoch:Q7},{name:"string.date"}),H7=l(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),eZ="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",r0=`(${eZ}[.]){3}${eZ}`,J7=new RegExp(`^${r0}$`),c="(?:[0-9a-fA-F]{1,4})",W7=new RegExp(`^((?:${c}:){7}(?:${c}|:)|(?:${c}:){6}(?:${r0}|:${c}|:)|(?:${c}:){5}(?::${r0}|(:${c}){1,2}|:)|(?:${c}:){4}(?:(:${c}){0,1}:${r0}|(:${c}){1,3}|:)|(?:${c}:){3}(?:(:${c}){0,2}:${r0}|(:${c}){1,4}|:)|(?:${c}:){2}(?:(:${c}){0,3}:${r0}|(:${c}){1,5}|:)|(?:${c}:){1}(?:(:${c}){0,4}:${r0}|(:${c}){1,6}|:)|(?::((?::${c}){0,5}:${r0}|(?::${c}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),L7=f.module({root:["v4 | v6","@","an IP address"],v4:l(J7,"an IPv4 address","ipv4"),v6:l(W7,"an IPv6 address","ipv6")},{name:"string.ip"}),p1="a JSON string",H8=(U)=>{if(!(U instanceof SyntaxError))throw U;return`must be ${p1} (${U})`},_7=v({meta:p1,domain:"string",predicate:{meta:p1,predicate:(U,X)=>{try{return JSON.parse(U),!0}catch(q){return X.reject({code:"predicate",expected:p1,problem:H8(q)})}}}}),$7=(U,X)=>{if(U.length===0)return X.error({code:"predicate",expected:p1,actual:"empty"});try{return JSON.parse(U)}catch(q){return X.error({code:"predicate",expected:p1,problem:H8(q)})}},z7=f.module({root:_7,parse:v({meta:"safe JSON string parser",in:"string",morphs:$7,declaredOut:I.jsonObject})},{name:"string.json"}),U8=l(/^[a-z]*$/,"only lowercase letters"),F7=f.module({root:v({in:"string",morphs:(U)=>U.toLowerCase(),declaredOut:U8}),preformatted:U8},{name:"string.lower"}),J8=["NFC","NFD","NFKC","NFKD"],E2=S(J8,(U,X)=>[X,v({domain:"string",predicate:(q)=>q.normalize(X)===q,meta:`${X}-normalized unicode`})]),k6=S(J8,(U,X)=>[X,v({in:"string",morphs:(q)=>q.normalize(X),declaredOut:E2[X]})]),A7=f.module({root:k6.NFC,preformatted:E2.NFC},{name:"string.normalize.NFC"}),T7=f.module({root:k6.NFD,preformatted:E2.NFD},{name:"string.normalize.NFD"}),O7=f.module({root:k6.NFKC,preformatted:E2.NFKC},{name:"string.normalize.NFKC"}),V7=f.module({root:k6.NFKD,preformatted:E2.NFKD},{name:"string.normalize.NFKD"}),B7=f.module({root:"NFC",NFC:A7,NFD:T7,NFKC:O7,NFKD:V7},{name:"string.normalize"}),X8=l(Y6,"a well-formed numeric string"),R7=f.module({root:X8,parse:v({in:X8,morphs:(U)=>Number.parseFloat(U),declaredOut:I.number})},{name:"string.numeric"}),q8="a regex pattern",D7=v({domain:"string",predicate:{meta:q8,predicate:(U,X)=>{try{return new RegExp(U),!0}catch(q){return X.reject({code:"predicate",expected:q8,problem:String(q)})}}},meta:{format:"regex"}}),M7=/^(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-]+)*))?$/,w7=l(M7,"a semantic version (see https://semver.org/)"),Z8=l(/^\S.*\S$|^\S?$/,"trimmed"),P7=f.module({root:v({in:"string",morphs:(U)=>U.trim(),declaredOut:Z8}),preformatted:Z8},{name:"string.trim"}),Q8=l(/^[A-Z]*$/,"only uppercase letters"),I7=f.module({root:v({in:"string",morphs:(U)=>U.toUpperCase(),declaredOut:Q8}),preformatted:Q8},{name:"string.upper"}),K7=(U)=>URL.canParse(U),G8=v({domain:"string",predicate:{meta:"a URL string",predicate:K7},meta:{format:"uri"}}),N7=f.module({root:G8,parse:v({declaredIn:G8,in:"string",morphs:(U,X)=>{try{return new URL(U)}catch{return X.error("a URL string")}},declaredOut:v(URL)})},{name:"string.url"}),C7=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"}),W8=f.module({root:I.string,alpha:l(/^[A-Za-z]*$/,"only letters"),alphanumeric:l(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:nY,base64:aY,capitalize:tY,creditCard:X7,date:Y7,digits:l(/^\d*$/,"only digits 0-9"),email:H7,integer:Y8,ip:L7,json:z7,lower:F7,normalize:B7,numeric:R7,regex:D7,semver:w7,trim:P7,upper:I7,url:N7,uuid:C7},{name:"string"});var L8=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}),_8=f.module({root:I.unknown,any:I.unknown},{name:"unknown"}),S7=f.module({root:I.jsonObject,stringify:x1("morph",{in:I.jsonObject,morphs:(U)=>JSON.stringify(U),declaredOut:I.string})},{name:"object.json"}),$8=f.module({root:I.object,json:S7},{name:"object"});class z8 extends e{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var E7=O0(["K",I.key],"V")((U)=>({domain:"object",index:{signature:U.K,value:U.V}}),z8);class F8 extends e{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var b7=O0(["T",I.object],["K",I.key])((U)=>U.T.pick(U.K),F8);class A8 extends e{description='omit a set of properties from an object like `Omit(User, "age")`'}var j7=O0(["T",I.object],["K",I.key])((U)=>U.T.omit(U.K),A8);class T8 extends e{description="make all named properties of an object optional like `Partial(User)`"}var f7=O0(["T",I.object])((U)=>U.T.partial(),T8);class O8 extends e{description="make all named properties of an object required like `Required(User)`"}var g7=O0(["T",I.object])((U)=>U.T.required(),O8);class V8 extends e{description='exclude branches of a union like `Exclude("boolean", "true")`'}var y7=O0("T","U")((U)=>U.T.exclude(U.U),V8);class B8 extends e{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var k7=O0("T","U")((U)=>U.T.extract(U.U),B8),R8=f.module({Exclude:y7,Extract:k7,Omit:j7,Partial:f7,Pick:b7,Record:E7,Required:g7});var x0=S2({...L8,...R8,...oZ,...mZ,string:W8,number:y6,object:$8,unknown:_8},{prereducedAliases:!0,name:"ark"}),a=x0.export();Object.assign(m1.ambient,a);m1.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 l9=Object.assign(x0.type,m1.typeAttachments),v7=x0.match,x7=x0.fn,h7=x0.generic,UN=x0.schema,u7=x0.define,m7=x0.declare;var $1=S2({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'",value:"string | unknown[]"},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","probability?":"0 <= number <= 1"},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(),VN=$1.Operator,BN=$1.Condition,RN=$1.ConditionGroup,DN=$1.RuleCondition,MN=$1.Action,wN=$1.ActionGroup,p7=$1.TriggerRule;class d9{static validate(U){let X=p7(U);if(X instanceof l9.errors){let Q=[];for(let G of X){let Y=G.path.join("."),H=G.message,J=void 0;if(Y.endsWith("on")&&(H.includes("string")||H.includes("must be")))if(typeof U==="object"&&U&&U.on===!0)H="The 'on' field is incorrect (boolean true found).",J=`In YAML, 'on' is a boolean keyword (true). Quote it: "on": "EventName"`;else J="Ensure 'on' is a string event name.";Q.push({path:Y,message:H,suggestion:J,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("conditions"in U&&Array.isArray(U.conditions)){U.conditions.forEach((Z,Q)=>{this.validateConditionsRecursive(Z,X,`${q}.conditions.${Q}`)});return}if("operator"in U&&"value"in U)this.validateConditionValue(U,X,q)}static validateConditionValue(U,X,q){let{operator:Z,value:Q}=U;if(["IN","NOT_IN","RANGE","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(["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"})}}}class v6{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 v6("AND");return this.conditions.push(U(X).build()),this}or(U){let X=new v6("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 D8{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 l7{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 v6,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 D8,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 EQ=X6(qX(),1);class lA{static toYaml(U){let X=Array.isArray(U)?U:[U];return EQ.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 bQ,mkdirSync as dA,readFileSync as cA,writeFileSync as iA}from"fs";import{dirname as oA}from"path";class sA{filePath;cache=new Map;isLoaded=!1;constructor(U){this.filePath=U}ensureLoaded(){if(this.isLoaded)return;try{if(bQ(this.filePath)){let U=cA(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=oA(this.filePath);if(!bQ(U))dA(U,{recursive:!0});let X=Object.fromEntries(this.cache);iA(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 U2 from"path";import*as R1 from"fs";var jQ=X6(qX(),1);class rA{static async loadRulesFromDir(U){let X=[],q=async(Z)=>{let Q;try{Q=await R1.promises.readdir(Z,{withFileTypes:!0})}catch(G){console.error(`[TriggerLoader] Failed to readdir ${Z}:`,G);return}for(let G of Q){let Y=U2.resolve(Z,G.name);if(G.isDirectory())await q(Y);else if(Y.toLowerCase().endsWith(".yaml")||Y.toLowerCase().endsWith(".yml"))try{let H=await this.loadRule(Y);X.push(...H)}catch(H){console.error(`Failed to load rule from ${Y}:`,H)}}};if(R1.existsSync(U))await q(U);else console.warn(`[TriggerLoader] Directory not found: ${U}`);return X}static async loadRule(U){try{let X=await R1.promises.readFile(U,"utf-8"),q=jQ.parseAllDocuments(X);for(let Y of q)if(Y.errors&&Y.errors.length>0)throw Error(`YAML syntax error in ${U}: ${Y.errors.map((H)=>H.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,H)=>{if(Y&&typeof Y==="object"&&Y.actions&&!Y.do)Y.do=Y.actions;let J=d9.validate(Y);if(J.valid){let W=J.rule;if(!W.id){let _=U2.basename(U,U2.extname(U));W.id=G.length>1?`${_}-${H}`:_}Q.push(W)}else console.error(`
185
- [TriggerLoader] ⚠️ Validation Problem in ${U} (item #${H+1})`),J.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}...`),R1.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{w1 as triggerEmitter,JT as engineEvents,d9 as TriggerValidator,Z6 as TriggerUtils,p7 as TriggerRuleSchema,rA as TriggerLoader,pQ as TriggerEngine,N4 as TriggerEmitter,K0 as StateManager,lA as RuleExporter,mQ as RuleEngine,DN as RuleConditionSchema,l7 as RuleBuilder,I4 as InMemoryPersistence,sA as FilePersistence,Z0 as ExpressionEngine,xQ as EventQueue,K4 as EngineEvent,uQ as ContextAdapter,BN as ConditionSchema,RN as ConditionGroupSchema,v6 as ConditionBuilder,VN as ComparisonOperatorSchema,hQ as BrowserPersistence,MN as ActionSchema,q6 as ActionRegistry,wN as ActionGroupSchema,D8 as ActionBuilder};
183
+ `)+"}");class K6{config;resolvedConfig;name;get[U0](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(X,U){if(this.config=B2(V.config,U),this.resolvedConfig=B2(V.resolvedConfig,U),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(N9).length}`,this.name in N9)F(`A Scope already named ${this.name} already exists`);N9[this.name]=this;let q=Object.entries(X).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(nq(G));this.aliases[G]=Q}else{if(G in this.aliases)F(nq(Z));this.aliases[G]=Q,this.exportedNames.push(G)}if(!M(Q,"module")&&!M(Q,"generic")&&!l0(Q)){let Y=this.preparseOwnDefinitionFormat(Q,{alias:G});this.resolutions[G]=M(Y,"root")?this.bindReference(Y):this.createParseContext(Y).id}}tq??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[tq.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=V.intrinsic?S(V.intrinsic,(Z,Q)=>Z.startsWith("json")?[]:[Z,this.bindReference(Q)]):{}}cacheGetter(X,U){return Object.defineProperty(this,X,{value:U}),U}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema(X){return X}generic=(...X)=>{let U=this;return(q,Z)=>new o0(X,Z?new B6(q):q,U,U,Z??null)};units=(X,U)=>{let q=[];for(let Q of X)if(!q.includes(Q))q.push(Q);let Z=q.map((Q)=>this.node("unit",{unit:Q},U));return this.node("union",Z,{...U,prereduced:!0})};lazyResolutions=[];lazilyResolve(X,U){let q=this.node("alias",{reference:U??"synthetic",resolve:X},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(q);return q}schema=(X,U)=>this.finalize(this.parseSchema(X,U));parseSchema=(X,U)=>this.node(M2(X),X,U);preparseNode(X,U,q){let Z=typeof X==="string"?X:M2(U,X);if(h(U)&&U.kind===Z)return U;if(Z==="alias"&&!q?.prereduced){let{reference:Y}=C2.implementation.normalize(U,this);if(Y.startsWith("$")){let H=this.resolveRoot(Y.slice(1));U=H,Z=H.kind}}else if(Z==="union"&&Z0(U,"object")){let Y=t5(U);if(Y?.length===1)U=Y[0],Z=M2(U)}if(h(U)&&U.kind===Z)return U;let G=g1[Z].normalize?.(U,this)??U;if(h(G))return G.kind===Z?G:e5(Z,G.kind);return{...q,$:this,kind:Z,def:G,prefix:q.alias??Z}}bindReference(X){let U;if(h(X))U=X.$===this?X:new X.constructor(X.attachments,this);else U=X.$===this?X:new o0(X.params,X.bodyDef,X.$,this,X.hkt);if(!this.resolved)Object.assign(this.referencesById,U.referencesById);return U}resolveRoot(X){return this.maybeResolveRoot(X)??F(E9(X))}maybeResolveRoot(X){let U=this.maybeResolve(X);if(M(U,"generic"))return;return U}maybeResolveSubalias(X){return C9(this.aliases,X)??C9(this.ambient,X)}get ambient(){return V.ambient}maybeResolve(X){let U=this.resolutions[X];if(U){if(typeof U!=="string")return this.bindReference(U);let Z=q0[U];if(M(Z,"root"))return this.resolutions[X]=Z;if(M(Z,"context")){if(Z.phase==="resolving")return this.node("alias",{reference:`$${X}`},{prereduced:!0});if(Z.phase==="resolved")return g(`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[X]=Q}return g(`Unexpected nodesById entry for ${U}: ${E(Z)}`)}let q=this.aliases[X]??this.ambient?.[X];if(!q)return this.maybeResolveSubalias(X);if(q=this.normalizeRootScopeValue(q),M(q,"generic"))return this.resolutions[X]=this.bindReference(q);if(M(q,"module")){if(!q.root)F(GZ(X));return this.resolutions[X]=this.bindReference(q.root)}return this.resolutions[X]=this.parse(q,{alias:X})}createParseContext(X){let U=X.id??_9(X.prefix);return q0[U]=Object.assign(X,{[U0]:"context",$:this,id:U,phase:"unresolved"})}traversal(X){return new w0(X,this.resolvedConfig)}import(...X){return new x1(S(this.export(...X),(U,q)=>[`#${U}`,q]))}precompilation;_exportedResolutions;_exports;export(...X){if(!this._exports){this._exports={};for(let q of this.exportedNames){let Z=this.aliases[q];this._exports[q]=M(Z,"module")?K9(Z,this):eq(this.maybeResolve(q))}for(let q of this.lazyResolutions)q.resolution;if(this._exportedResolutions=QZ(this,this._exports),this._json=ZZ(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let q=qZ(this.references);this.precompilation=q.write(XZ,4),UZ(this.references,q)}this.resolved=!0}let U=X.length?X:this.exportedNames;return new x1(S(U,(q,Z)=>[Z,this._exports[Z]]))}resolve(X){return this.export()[X]}node=(X,U,q={})=>{let Z=this.preparseNode(X,U,q);if(h(Z))return this.bindReference(Z);let Q=this.createParseContext(Z),G=$9(Q),Y=this.bindReference(G);return q0[Q.id]=Y};parse=(X,U={})=>this.finalize(this.parseDefinition(X,U));parseDefinition(X,U={}){if(M(X,"root"))return this.bindReference(X);let q=this.preparseOwnDefinitionFormat(X,U);if(M(q,"root"))return this.bindReference(q);let Z=this.createParseContext(q);q0[Z.id]=Z;let Q=this.bindReference(this.parseOwnDefinitionFormat(X,Z));if(Q.isCyclic)Q=Dq(Q,Z.id);return q0[Z.id]=Q,Q}finalize(X){if(eq(X),!X.precompilation&&!this.resolvedConfig.jitless)XY(X.references);return X}}class S9 extends K6{parseOwnDefinitionFormat(X,U){return $9(U)}preparseOwnDefinitionFormat(X,U){return this.preparseNode(M2(X),X,U)}preparseOwnAliasEntry(X,U){return[X,U]}normalizeRootScopeValue(X){return X}}var eq=(X)=>{let U=X.references.filter((q)=>q.hasKind("alias"));for(let q of U){Object.assign(q.referencesById,q.resolution.referencesById);for(let Z of X.references)if(q.id in Z.referencesById)Object.assign(Z.referencesById,q.referencesById)}return X},ZZ=(X)=>S(X,(U,q)=>[U,M(q,"root")||M(q,"generic")?q.json:M(q,"module")?ZZ(q):g(`Unexpected resolution ${E(q)}`)]),C9=(X,U)=>{let q=U.indexOf(".");if(q===-1)return;let Z=U.slice(0,q),Q=X[Z];if(Q===void 0)return;if(!M(Q,"module"))return F(UY(Z));let G=U.slice(q+1),Y=Q[G];if(Y===void 0)return C9(Q,G);if(M(Y,"root")||M(Y,"generic"))return Y;if(M(Y,"module"))return Y.root??F(GZ(U));g(`Unexpected resolution for alias '${U}': ${E(Y)}`)},N6=(X,U)=>new S9(X,U),b2=new S9({});var QZ=(X,U)=>{let q={};for(let Z in U){let Q=U[Z];if(M(Q,"module")){let G=QZ(X,Q),Y=S(G,(H,J)=>[`${Z}.${H}`,J]);Object.assign(q,Y)}else if(M(Q,"root")||M(Q,"generic"))q[Z]=Q;else g(`Unexpected scope resolution ${E(Q)}`)}return q},E9=(X)=>`'${X}' is unresolvable`,UY=(X)=>`'${X}' must reference a module to be accessed using dot syntax`,GZ=(X)=>`Reference to submodule '${X}' must specify an alias`;b2.export();var{schema:v,node:h1,defineSchema:kw,generic:O0}=b2;var b9="^(?:0|[1-9]\\d*)$",qY=new RegExp(b9),hw=d(qY);var YZ=N6({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();V.intrinsic={...YZ};var HZ=N6({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:b9}},{prereducedAliases:!0}).export();Object.assign(V.intrinsic,HZ);var ZY=N6({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),I={...YZ,...HZ,...ZY,emptyStructure:h1("structure",{},{prereduced:!0})};V.intrinsic={...I};var C6=(X,U)=>new RegExp(X,U);Object.assign(C6,{as:C6});var WZ=(X)=>typeof X==="string"&&X[0]==="d"&&(X[1]==="'"||X[1]==='"')&&X[X.length-1]===X[1],JZ=(X)=>X.toString()!=="Invalid Date",_Z=(X)=>X.slice(2,-1),j9=(X)=>`'${X}' could not be parsed by the Date constructor`,$Z=(X,U)=>QY(X,U),QY=(X,U)=>{let q=new Date(X);if(JZ(q))return q;let Z=vU(X);if(Z!==void 0){let Q=new Date(Z);if(JZ(Q))return Q}return U?F(U===!0?j9(X):U):void 0};var GY=v({proto:"Array",sequence:"string",required:{key:"groups",value:["object",{unit:void 0}]}}),S6=(X,U)=>{let q=X.scanner.shiftUntilEscapable(HY[FZ[U]]);if(X.scanner.lookahead==="")return X.error(WY(q,U));if(X.scanner.shift(),U in zZ){let Z;try{Z=new RegExp(q)}catch(Q){F(String(Q))}if(X.root=X.ctx.$.node("intersection",{domain:"string",pattern:q},{prereduced:!0}),U==="x/")X.root=X.ctx.$.node("morph",{in:X.root,morphs:(Q)=>Z.exec(Q),declaredOut:GY})}else if(a(U,f9))X.root=X.ctx.$.node("unit",{unit:q});else{let Z=$Z(q,j9(q));X.root=X.ctx.$.node("unit",{meta:q,unit:Z})}},f9={"'":1,'"':1},LZ={"/":1,"'":1,'"':1},YY={"d'":"'",'d"':'"',"'":"'",'"':'"'},zZ={"/":"/","x/":"/"},FZ={...YY,...zZ},HY={"'":(X)=>X.lookahead==="'",'"':(X)=>X.lookahead==='"',"/":(X)=>X.lookahead==="/"},JY={'"':"double-quote","'":"single-quote","/":"forward slash"},WY=(X,U)=>`${U}${X} requires a closing ${JY[FZ[U]]}`;var AZ=(X)=>`Private type references should not include '#'. Use '${X}' instead.`,E6="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 E0={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...d0};var VZ=(X,U)=>X===">"?U[0]==="="?U[1]==="=":U.trimStart()===""||a(U.trimStart()[0],E0):X==="="?U[0]!=="=":X===","||X==="?";var OZ=(X,U,q)=>BZ(X,U,q,[]),BZ=(X,U,q,Z)=>{let Q=q.parseUntilFinalizer();if(Z.push(Q.root),Q.finalizer===">"){if(Z.length!==U.params.length)return q.error(y9(X,U.names,Z.map((G)=>G.expression)));return Z}if(Q.finalizer===",")return BZ(X,U,q,Z);return Q.error(L6(">"))},y9=(X,U,q)=>`${X}<${U.join(", ")}> requires exactly ${U.length} args (got ${q.length}${q.length===0?"":`: ${q.join(", ")}`})`;var j6=(X)=>{let U=X.scanner.shiftUntilLookahead(E0);if(U==="keyof")X.addPrefix("keyof");else X.root=$Y(X,U)},_Y=(X,U,q)=>{if(q.scanner.shiftUntilNonWhitespace(),q.scanner.shift()!=="<")return q.error(y9(X,U.names,[]));let Q=OZ(X,U,q);return U(...Q)},$Y=(X,U)=>LY(X,U)??zY(X,U)??X.error(U===""?X.scanner.lookahead==="#"?AZ(X.shiftedBy(1).scanner.shiftUntilLookahead(E0)):g9(X):E9(U)),LY=(X,U)=>{if(X.ctx.args?.[U]){let Z=X.ctx.args[U];if(typeof Z!=="string")return Z;return X.ctx.$.node("alias",{reference:Z},{prereduced:!0})}let q=X.ctx.$.maybeResolve(U);if(M(q,"root"))return q;if(q===void 0)return;if(M(q,"generic"))return _Y(U,q,X);return F(`Unexpected resolution ${E(q)}`)},zY=(X,U)=>{let q=xU(U);if(q!==void 0)return X.ctx.$.node("unit",{unit:q});let Z=uU(U);if(Z!==void 0)return X.ctx.$.node("unit",{unit:Z})},g9=(X)=>{let U=X.previousOperator();return U?k9(U,X.scanner.unscanned):FY(X.scanner.unscanned)},k9=(X,U="")=>`Token '${X}' requires a right operand${U?` before '${U}'`:""}`,FY=(X)=>`Expected an expression${X?` before '${X}'`:""}`;var v9=(X)=>X.scanner.lookahead===""?X.error(g9(X)):X.scanner.lookahead==="("?X.shiftedBy(1).reduceGroupOpen():X.scanner.lookaheadIsIn(LZ)?S6(X,X.scanner.shift()):X.scanner.lookaheadIsIn(d0)?v9(X.shiftedBy(1)):X.scanner.lookahead==="d"?X.scanner.nextLookahead in f9?S6(X,`${X.scanner.shift()}${X.scanner.shift()}`):j6(X):X.scanner.lookahead==="x"?X.scanner.nextLookahead==="/"?X.shiftedBy(2)&&S6(X,"x/"):j6(X):j6(X);var TZ={">":!0,">=":!0},RZ={"<":!0,"<=":!0};var u1={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},DZ=(X,U)=>`Left bounds are only valid when paired with right bounds (try ...${U}${X})`,f6=(X)=>`Left-bounded expressions must specify their limits using < or <= (was ${X})`,MZ=(X,U,q,Z)=>`An expression may have at most one left bound (parsed ${X}${u1[U]}, ${q}${u1[Z]})`;var PZ=(X,U)=>{let q=AY(X,U);if(X.root.hasKind("unit")){if(typeof X.root.unit==="number"){X.reduceLeftBound(X.root.unit,q),X.unsetRoot();return}if(X.root.unit instanceof Date){let Z=`d'${X.root.description??X.root.unit.toISOString()}'`;X.unsetRoot(),X.reduceLeftBound(Z,q);return}}return OY(X,q)},IZ={"<":1,">":1,"=":1},AY=(X,U)=>X.scanner.lookaheadIs("=")?`${U}${X.scanner.shift()}`:U;var wZ=(X,U,q,Z)=>{if(q.extends(V.intrinsic.number)){if(typeof U!=="number")return F(x9(X,U,Z));return X==="=="?["min","max"]:X[0]===">"?["min"]:["max"]}if(q.extends(V.intrinsic.lengthBoundable)){if(typeof U!=="number")return F(x9(X,U,Z));return X==="=="?["exactLength"]:X[0]===">"?["minLength"]:["maxLength"]}if(q.extends(V.intrinsic.Date))return X==="=="?["after","before"]:X[0]===">"?["after"]:["before"];return F(Jq(q.expression))},VY=(X)=>({rule:WZ(X.limit)?_Z(X.limit):X.limit,exclusive:X.comparator.length===1}),OY=(X,U)=>{let q=X.unsetRoot(),Z=X.scanner.location;X.parseOperand();let Q=X.unsetRoot(),G=X.scanner.sliceChars(Z,X.scanner.location);if(X.root=q,!Q.hasKind("unit")||typeof Q.unit!=="number"&&!(Q.unit instanceof Date))return X.error(x9(U,G,"right"));let Y=Q.unit,H=U.length===1,J=wZ(U,typeof Y==="number"?Y:G,q,"right");for(let $ of J)X.constrainRoot($,U==="=="?{rule:Y}:{rule:Y,exclusive:H});if(!X.branches.leftBound)return;if(!a(U,RZ))return X.error(f6(U));let W=wZ(X.branches.leftBound.comparator,X.branches.leftBound.limit,q,"left");X.constrainRoot(W[0],VY(X.branches.leftBound)),X.branches.leftBound=null},x9=(X,U,q)=>`Comparator ${q==="left"?u1[X]:X} must be ${q==="left"?"preceded":"followed"} by a corresponding literal (was ${U})`;var KZ=(X)=>{X.scanner.shiftUntilNonWhitespace();let U=X.scanner.shiftUntilLookahead(E0);X.root=X.root.brand(U)};var CZ=(X)=>{X.scanner.shiftUntilNonWhitespace();let U=X.scanner.shiftUntilLookahead(E0),q=hU(U,{errorOnFail:NZ(U)});if(q===0)X.error(NZ(0));X.root=X.root.constrain("divisor",q)},NZ=(X)=>`% operator must be followed by a non-zero integer literal (was ${X})`;var h9=(X)=>{let U=X.scanner.shift();return U===""?X.finalize(""):U==="["?X.scanner.shift()==="]"?X.setRoot(X.root.array()):X.error(BY):U==="|"?X.scanner.lookahead===">"?X.shiftedBy(1).pushRootToBranch("|>"):X.pushRootToBranch(U):U==="&"?X.pushRootToBranch(U):U===")"?X.finalizeGroup():VZ(U,X.scanner.unscanned)?X.finalize(U):a(U,IZ)?PZ(X,U):U==="%"?CZ(X):U==="#"?KZ(X):(U in d0)?h9(X):X.error(y6(U))},y6=(X,U="")=>`'${X}' is not allowed here${U&&` (should be ${U})`}`,BY="Missing expected ']'";var SZ=(X)=>{let U=X.unsetRoot();X.parseOperand();let q=X.unsetRoot();if(!q.hasKind("unit"))return X.error(TY(q.expression));let Z=q.unit instanceof Date?()=>new Date(q.unit):q.unit;return[U,"=",Z]},TY=(X)=>`Default value '${X}' must be a literal value`;var u9=(X,U)=>{let q=U.$.maybeResolveRoot(X);if(q)return q;if(X.endsWith("[]")){let G=U.$.maybeResolveRoot(X.slice(0,-2));if(G)return G.array()}let Z=new m1(new V2(X),U),Q=RY(Z);if(Z.finalizer===">")F(y6(">"));return Q},RY=(X)=>{X.parseOperand();let U=j2(X).root;if(!U)return g(`Root was unexpectedly unset after parsing string '${X.scanner.scanned}'`);if(X.finalizer==="=")U=SZ(X);else if(X.finalizer==="?")U=[U,"?"];if(X.scanner.shiftUntilNonWhitespace(),X.scanner.lookahead)F(y6(X.scanner.lookahead));return U},j2=(X)=>{while(X.finalizer===void 0)DY(X);return X},DY=(X)=>X.hasRoot()?X.parseOperator():X.parseOperand();class m1{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor(X,U){this.scanner=X,this.ctx=U}error(X){return F(X)}hasRoot(){return this.root!==void 0}setRoot(X){this.root=X}unsetRoot(){let X=this.root;return this.root=void 0,X}constrainRoot(...X){this.root=this.root.constrain(X[0],X[1])}finalize(X){if(this.groups.length)return this.error(L6(")"));this.finalizeBranches(),this.finalizer=X}reduceLeftBound(X,U){let q=u1[U];if(!a(q,TZ))return this.error(f6(U));if(this.branches.leftBound)return this.error(MZ(this.branches.leftBound.limit,this.branches.leftBound.comparator,X,q));this.branches.leftBound={comparator:q,limit:X}}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 X=this.groups.pop();if(!X)return this.error(dU(")",this.scanner.unscanned));this.branches=X}addPrefix(X){this.branches.prefixes.push(X)}applyPrefixes(){while(this.branches.prefixes.length){let X=this.branches.prefixes.pop();this.root=X==="keyof"?this.root.keyof():g(`Unexpected prefix '${X}'`)}}pushRootToBranch(X){this.assertRangeUnset(),this.applyPrefixes();let U=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(U)??U,X==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,X==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return j2(new m1(this.scanner,this.ctx))}parseOperator(){return h9(this)}parseOperand(){return v9(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(DZ(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(X){return this.scanner.jumpForward(X),this}}var MY="An empty string is not a valid generic parameter name",g6=(X,U,q)=>{X.shiftUntilNonWhitespace();let Z=X.shiftUntilLookahead(E0);if(Z===""){if(X.lookahead===""&&U.length)return U;return F(MY)}return X.shiftUntilNonWhitespace(),wY(X,Z,U,q)},EZ="extends ",wY=(X,U,q,Z)=>{if(X.shiftUntilNonWhitespace(),X.unscanned.startsWith(EZ))X.jumpForward(EZ.length);else{if(X.lookahead===",")X.shift();return q.push(U),g6(X,q,Z)}let Q=j2(new m1(X,Z));return q.push([U,Q.root]),g6(X,q,Z)};class m9 extends Y0{constructor(X){let U={$:X,raw:X.fn};super((...q)=>{let Z=q.indexOf(":"),Q=Z===-1?q.length-1:Z-1,G=q.slice(0,Q+1),Y=X.parse(G).assertHasKind("intersection"),H=X.intrinsic.unknown;if(Z!==-1){if(Z!==q.length-2)return F(PY);H=X.parse(q[Z+1])}return(J)=>new bZ(J,Y,H)},{attach:U})}}class bZ extends Y0{raw;params;returns;expression;constructor(X,U,q){let Z=`typed ${X.name}`,Q={[Z]:(...Y)=>{let H=U.assert(Y),J=X(...H);return q.assert(J)}}[Z];super(Q);this.raw=X,this.params=U,this.returns=q;let G=U.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 PY=`":" must be followed by exactly one return type e.g:
184
+ fn("string", ":", "number")(s => s.length)`;class p9 extends Y0{$;constructor(X){super((...U)=>new f2(X)(...U),{bind:X});this.$=X}in(X){return new f2(this.$,X===void 0?void 0:this.$.parse(X))}at(X,U){return new f2(this.$).at(X,U)}case(X,U){return new f2(this.$).case(X,U)}}class f2 extends Y0{$;in;key;branches=[];constructor(X,U){super((q)=>this.caseEntries(Object.entries(q).map(([Z,Q])=>Z==="default"?[Z,Q]:[this.$.parse(Z),Q])));this.$=X,this.in=U}at(X,U){if(this.key)F(KY);if(this.branches.length)F(IY);return this.key=X,U?this.match(U):this}case(X,U){return this.caseEntry(this.$.parse(X),U)}caseEntry(X,U){let Z=(this.key?this.$.parse({[this.key]:X}):X).pipe(U);return this.branches.push(Z),this}match(X){return this(X)}strings(X){return this.caseEntries(Object.entries(X).map(([U,q])=>U==="default"?[U,q]:[this.$.node("unit",{unit:U}),q]))}caseEntries(X){for(let U=0;U<X.length;U++){let[q,Z]=X[U];if(q==="default"){if(U!==X.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(X){if(typeof X==="function")this.case(I.unknown,X);let U={branches:this.branches,ordered:!0};if(X==="never"||X==="assert")U.meta={onFail:jZ};let q=this.$.node("union",U);if(!this.in)return this.$.finalize(q);let Z=this.in.pipe(q);if(X==="never"||X==="assert")Z=Z.configureReferences({onFail:jZ},"self");return this.$.finalize(Z)}}var jZ=(X)=>X.throw(),IY="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",KY="At most one key matcher may be specified per expression";var k6=(X,U)=>{if(x(X)){if(X[1]==="=")return[U.$.parseOwnDefinitionFormat(X[0],U),"=",X[2]];if(X[1]==="?")return[U.$.parseOwnDefinitionFormat(X[0],U),"?"]}return v6(X,U)},fZ="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",yZ="Only required keys may specify default values, e.g. { value: 'number = 0' }";var gZ=(X,U)=>{let q,Z={},Q=H1(X);for(let[Y,H]of Q){let J=SY(Y);if(J.kind==="spread"){if(!C0(Z))return F(CY);let A=U.$.parseOwnDefinitionFormat(H,U);if(A.equals(I.object))continue;if(!A.hasKind("intersection")||!A.basis?.equals(I.object))return F(EY(A.expression));q=A.structure;continue}if(J.kind==="undeclared"){if(H!=="reject"&&H!=="delete"&&H!=="ignore")F(NY(H));Z.undeclared=H;continue}let W=k6(H,U),$=J;if(J.kind==="required"){if(!x(W))l9(Z,"required",{key:J.normalized,value:W},U);else l9(Z,"optional",W[1]==="="?{key:J.normalized,value:W[0],default:W[2]}:{key:J.normalized,value:W[0]},U);continue}if(x(W)){if(W[1]==="?")F(fZ);if(W[1]==="=")F(yZ)}if(J.kind==="optional"){l9(Z,"optional",{key:J.normalized,value:W},U);continue}let _=U.$.parseOwnDefinitionFormat($.normalized,U),L=I6(_,W,U.$);if(L.index)Z.index=y(Z.index,L.index);if(L.required)Z.required=y(Z.required,L.required)}let G=U.$.node("structure",Z);return U.$.parseSchema({domain:"object",structure:q?.merge(G)??G})},l9=(X,U,q,Z)=>{X[U]=y(X[U],Z.$.node(U,q))},NY=(X)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${E(X)})`,CY="Spread operator may only be used as the first key in an object",SY=(X)=>typeof X==="symbol"?{kind:"required",normalized:X}:X[X.length-1]==="?"?X[X.length-2]===W1?{kind:"required",normalized:`${X.slice(0,-2)}?`}:{kind:"optional",normalized:X.slice(0,-1)}:X[0]==="["&&X[X.length-1]==="]"?{kind:"index",normalized:X.slice(1,-1)}:X[0]===W1&&X[1]==="["&&X[X.length-1]==="]"?{kind:"required",normalized:X.slice(1)}:X==="..."?{kind:"spread"}:X==="+"?{kind:"undeclared"}:{kind:"required",normalized:X==="\\..."?"...":X==="\\+"?"+":X},EY=(X)=>`Spread operand must resolve to an object literal type (was ${X})`;var vZ=(X,U)=>uY(X)?mZ[X[0]](X,U):xY(X)?uZ[X[1]](X,U):null,bY=(X,U)=>U.$.parseOwnDefinitionFormat(X[1],U).keyof(),d9=(X,U)=>{if(X[2]===void 0)return F(k9(X[1],""));let q=U.$.parseOwnDefinitionFormat(X[0],U),Z=U.$.parseOwnDefinitionFormat(X[2],U);if(X[1]==="|")return U.$.node("union",{branches:[q,Z]});let Q=X[1]==="&"?W0(q,Z,U.$):D2(q,Z,U.$);if(Q instanceof B)return Q.throw();return Q},jY=(X,U)=>U.$.parseOwnDefinitionFormat(X[0],U).array(),fY=(X,U)=>{if(typeof X[2]!=="function")return F(xZ("=>",X[2]));return U.$.parseOwnDefinitionFormat(X[0],U).pipe(X[2])},xZ=(X,U)=>`${X===":"?"Narrow":"Morph"} expression requires a function following '${X}' (was ${typeof U})`,yY=(X,U)=>{if(typeof X[2]!=="function")return F(xZ(":",X[2]));return U.$.parseOwnDefinitionFormat(X[0],U).constrain("predicate",X[2])},gY=(X,U)=>U.$.parseOwnDefinitionFormat(X[0],U).configure(X[2],X[3]),hZ=(X)=>X,kY=hZ({"[]":jY,"?":()=>F(E6)}),vY=hZ({"|":d9,"&":d9,":":yY,"=>":fY,"|>":d9,"@":gY,"=":()=>F(b6)}),uZ={...kY,...vY},xY=(X)=>uZ[X[1]]!==void 0,hY=(X)=>X,mZ=hY({keyof:bY,instanceof:(X,U)=>{if(typeof X[1]!=="function")return F(kZ(W2(X[1])));let q=X.slice(1).map((Z)=>typeof Z==="function"?U.$.node("proto",{proto:Z}):F(kZ(W2(Z))));return q.length===1?q[0]:U.$.node("union",{branches:q})},"===":(X,U)=>U.$.units(X.slice(1))}),uY=(X)=>mZ[X[0]]!==void 0,kZ=(X)=>`Expected a constructor following 'instanceof' operator (was ${X})`;var dZ=(X,U)=>{let q=[{}],Z=0;while(Z<X.length){let Q=!1;if(X[Z]==="..."&&Z<X.length-1)Q=!0,Z++;let G=k6(X[Z],U),[Y,H,J]=!x(G)?[G]:G;if(Z++,Q){if(!Y.extends(V.intrinsic.Array))return F(lY(Y.expression));q=q.flatMap((W)=>Y.distribute(($)=>pY(F6(W),$)))}else q=q.map((W)=>{if(H==="?")return cZ(W,Y);if(H==="=")return mY(W,Y,J);return c9(W,Y)})}return U.$.parseSchema(q.map((Q)=>C0(Q)?{proto:Array,exactLength:0}:{proto:Array,sequence:Q}))},c9=(X,U)=>{if(X.defaultables||X.optionals)return F(X.variadic?w9:dY);if(X.variadic)X.postfix=y(X.postfix,U);else X.prefix=y(X.prefix,U);return X},cZ=(X,U)=>{if(X.variadic)return F(iZ);return X.optionals=y(X.optionals,U),X},mY=(X,U,q)=>{if(X.variadic)return F(iZ);if(X.optionals)return F(cY);return X.defaultables=y(X.defaultables,[[U,q]]),X},pZ=(X,U)=>{if(X.postfix)F(lZ);if(X.variadic){if(!X.variadic.equals(U))F(lZ)}else X.variadic=U.internal;return X},pY=(X,U)=>{let q=U.select({method:"find",kind:"sequence"});if(!q)return pZ(X,V.intrinsic.unknown);if(q.prefix)for(let Z of q.prefix)c9(X,Z);if(q.optionals)for(let Z of q.optionals)cZ(X,Z);if(q.variadic)pZ(X,q.variadic);if(q.postfix)for(let Z of q.postfix)c9(X,Z);return X},lY=(X)=>`Spread element must be an array (was ${X})`,lZ="A tuple may have at most one variadic element",dY="A required element may not follow an optional element",iZ="An optional element may not follow a variadic element";var cY="A defaultable element may not follow an optional element without a default";var iY={},v6=(X,U)=>{if(typeof X==="string"){if(U.args&&Object.keys(U.args).some((Z)=>X.includes(Z)))return u9(X,U);let q=iY[U.$.name]??={};return q[X]??=u9(X,U)}return Z0(X,"object")?sY(X,U):F(i9(r(X)))},sY=(X,U)=>{let q=J2(X);switch(q){case void 0:if(M(X,"root"))return X;if("~standard"in X)return oY(X,U);return gZ(X,U);case"Array":return rY(X,U);case"RegExp":return U.$.node("intersection",{domain:"string",pattern:X},{prereduced:!0});case"Function":{let Z=l0(X)?X():X;if(M(Z,"root"))return Z;return F(i9("Function"))}default:return F(i9(q??E(X)))}},oY=(X,U)=>U.$.intrinsic.unknown.pipe((q,Z)=>{let Q=X["~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:bU(G),relativePath:Y.map((H)=>typeof H==="object"?H.key:H)});else Z.error({message:G});else Z.error({message:G})}),rY=(X,U)=>vZ(X,U)??dZ(X,U),i9=(X)=>`Type definitions must be strings or objects (was ${X})`;class s9 extends Y0{constructor(X){let U=Object.assign({errors:H0,hkt:e,$:X,raw:X.parse,module:X.constructor.module,scope:X.constructor.scope,declare:X.declare,define:X.define,match:X.match,generic:X.generic,schema:X.schema,keywords:X.ambient,unit:X.unit,enumerated:X.enumerated,instanceOf:X.instanceOf,valueOf:X.valueOf,or:X.or,and:X.and,merge:X.merge,pipe:X.pipe,fn:X.fn},X.ambientAttachments);super((...q)=>{if(q.length===1)return X.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=X.parseGenericParams(Z,{});return new o0(Q,q[1],X,X,null)}return X.parse(q)},{attach:U})}}var p1=V;class x6 extends K6{get ambientAttachments(){if(!p1.typeAttachments)return;return this.cacheGetter("ambientAttachments",S(p1.typeAttachments,(X,U)=>[X,this.bindReference(U)]))}preparseOwnAliasEntry(X,U){let q=X.indexOf("<");if(q===-1){if(M(U,"module")||M(U,"generic"))return[X,U];let G=this.name==="ark"?X:X==="root"?this.name:`${this.name}.${X}`,Y=this.resolvedConfig.keywords?.[G];if(Y)U=[U,"@",Y];return[X,U]}if(X[X.length-1]!==">")F("'>' must be the last character of a generic declaration in a scope");let Z=X.slice(0,q),Q=X.slice(q+1,-1);return[Z,()=>{let G=this.parseGenericParams(Q,{alias:Z});return Gq(G,U,this)}]}parseGenericParams(X,U){return g6(new V2(X),[],this.createParseContext({...U,def:X,prefix:"generic"}))}normalizeRootScopeValue(X){if(l0(X)&&!M(X,"generic"))return X();return X}preparseOwnDefinitionFormat(X,U){return{...U,def:X,prefix:U.alias??"type"}}parseOwnDefinitionFormat(X,U){if(!(U.alias&&(U.alias in this.aliases))&&!U.args)U.args={this:U.id};let Z=v6(X,U);if(x(Z)){if(Z[1]==="=")return F(b6);if(Z[1]==="?")return F(E6)}return Z}unit=(X)=>this.units([X]);valueOf=(X)=>this.units(MU(X));enumerated=(...X)=>this.units(X);instanceOf=(X)=>this.node("proto",{proto:X},{prereduced:!0});or=(...X)=>this.schema(X.map((U)=>this.parse(U)));and=(...X)=>X.reduce((U,q)=>U.and(this.parse(q)),this.intrinsic.unknown);merge=(...X)=>X.reduce((U,q)=>U.merge(this.parse(q)),this.intrinsic.object);pipe=(...X)=>this.intrinsic.unknown.pipe(...X);fn=new m9(this);match=new p9(this);declare=()=>({type:this.type});define(X){return X}type=new s9(this);static scope=(X,U={})=>new x6(X,U);static module=(X,U={})=>this.scope(X,U).export()}var y2=Object.assign(x6.scope,{define:(X)=>X}),f=x6;class sZ extends e{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var aY=O0(["base",I.object],["props",I.object])((X)=>X.base.merge(X.props),sZ),oZ=f.module({Key:I.key,Merge:aY});class rZ extends e{}var nY=O0("element")((X)=>{let U=X.element.exclude(I.Array),q=U.array();return U.rawOr(q).pipe(p0).distribute((Z)=>Z.assertHasKind("morph").declareOut(q),v)},rZ),aZ=f.module({root:I.Array,readonly:"root",index:I.nonNegativeIntegerString,liftFrom:nY},{name:"Array"});var o9=v(["string",_1.FileConstructor]),tY=o9.rawOr(o9.array()),nZ=v({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:tY}}),tZ=f.module({root:["instanceof",FormData],value:o9,parsed:nZ,parse:v({in:FormData,morphs:(X)=>{let U={};for(let[q,Z]of X)if(q in U){let Q=U[q];if(typeof Q==="string"||Q instanceof _1.FileConstructor)U[q]=[Q,Z];else Q.push(Z)}else U[q]=Z;return U},declaredOut:nZ})},{name:"FormData"});var eZ=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 eY={Boolean:1,Number:1,String:1},X8=f.module({...S({...k4,...x4},(X,U)=>(X in eY)?[]:[X,["instanceof",U]]),Array:aZ,TypedArray:eZ,FormData:tZ});var X7=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"}),U7=v({domain:"number",divisor:1}),h6=f.module({root:I.number,integer:U7,epoch:X7,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=(X,U,q)=>{let Z={domain:"string",pattern:{rule:X.source,flags:X.flags,meta:U}};if(q)Z.meta={format:q};return h1("intersection",Z)},U8=l($2,"a well-formed integer string"),z8=f.module({root:U8,parse:v({in:U8,morphs:(X,U)=>{let q=Number.parseInt(X);return Number.isSafeInteger(q)?q:U.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:I.integer})},{name:"string.integer"}),q7=l(/^[\dA-Fa-f]+$/,"hex characters only"),Z7=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"}),q8=l(/^[A-Z].*$/,"capitalized"),Q7=f.module({root:v({in:"string",morphs:(X)=>X.charAt(0).toUpperCase()+X.slice(1),declaredOut:q8}),preformatted:q8},{name:"string.capitalize"}),G7=(X)=>{let U=X.replace(/[ -]+/g,""),q=0,Z,Q,G=!1;for(let Y=U.length-1;Y>=0;Y--){if(Z=U.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?U:!1)},Y7=/^(?: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}))$/,H7=v({domain:"string",pattern:{meta:"a credit card number",rule:Y7.source},predicate:{meta:"a credit card number",predicate:G7}});var J7=/^([+-]?\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 W7=(X)=>!Number.isNaN(new Date(X).valueOf()),Z8=v({domain:"string",predicate:{meta:"a parsable date",predicate:W7}}).assertHasKind("intersection"),Q8=z8.root.internal.narrow((X,U)=>{let q=Number.parseInt(X),Z=h6.epoch(q);if(Z instanceof H0)return U.errors.merge(Z),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),_7=f.module({root:Q8,parse:v({in:Q8,morphs:(X)=>new Date(X),declaredOut:I.Date})},{name:"string.date.epoch"}),G8=l(J7,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),$7=f.module({root:G8,parse:v({in:G8,morphs:(X)=>new Date(X),declaredOut:I.Date})},{name:"string.date.iso"}),L7=f.module({root:Z8,parse:v({declaredIn:Z8,in:"string",morphs:(X,U)=>{let q=new Date(X);if(Number.isNaN(q.valueOf()))return U.error("a parsable date");return q},declaredOut:I.Date}),iso:$7,epoch:_7},{name:"string.date"}),z7=l(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),Y8="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",r0=`(${Y8}[.]){3}${Y8}`,F7=new RegExp(`^${r0}$`),c="(?:[0-9a-fA-F]{1,4})",A7=new RegExp(`^((?:${c}:){7}(?:${c}|:)|(?:${c}:){6}(?:${r0}|:${c}|:)|(?:${c}:){5}(?::${r0}|(:${c}){1,2}|:)|(?:${c}:){4}(?:(:${c}){0,1}:${r0}|(:${c}){1,3}|:)|(?:${c}:){3}(?:(:${c}){0,2}:${r0}|(:${c}){1,4}|:)|(?:${c}:){2}(?:(:${c}){0,3}:${r0}|(:${c}){1,5}|:)|(?:${c}:){1}(?:(:${c}){0,4}:${r0}|(:${c}){1,6}|:)|(?::((?::${c}){0,5}:${r0}|(?::${c}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),V7=f.module({root:["v4 | v6","@","an IP address"],v4:l(F7,"an IPv4 address","ipv4"),v6:l(A7,"an IPv6 address","ipv6")},{name:"string.ip"}),l1="a JSON string",F8=(X)=>{if(!(X instanceof SyntaxError))throw X;return`must be ${l1} (${X})`},O7=v({meta:l1,domain:"string",predicate:{meta:l1,predicate:(X,U)=>{try{return JSON.parse(X),!0}catch(q){return U.reject({code:"predicate",expected:l1,problem:F8(q)})}}}}),B7=(X,U)=>{if(X.length===0)return U.error({code:"predicate",expected:l1,actual:"empty"});try{return JSON.parse(X)}catch(q){return U.error({code:"predicate",expected:l1,problem:F8(q)})}},T7=f.module({root:O7,parse:v({meta:"safe JSON string parser",in:"string",morphs:B7,declaredOut:I.jsonObject})},{name:"string.json"}),H8=l(/^[a-z]*$/,"only lowercase letters"),R7=f.module({root:v({in:"string",morphs:(X)=>X.toLowerCase(),declaredOut:H8}),preformatted:H8},{name:"string.lower"}),A8=["NFC","NFD","NFKC","NFKD"],g2=S(A8,(X,U)=>[U,v({domain:"string",predicate:(q)=>q.normalize(U)===q,meta:`${U}-normalized unicode`})]),u6=S(A8,(X,U)=>[U,v({in:"string",morphs:(q)=>q.normalize(U),declaredOut:g2[U]})]),D7=f.module({root:u6.NFC,preformatted:g2.NFC},{name:"string.normalize.NFC"}),M7=f.module({root:u6.NFD,preformatted:g2.NFD},{name:"string.normalize.NFD"}),w7=f.module({root:u6.NFKC,preformatted:g2.NFKC},{name:"string.normalize.NFKC"}),P7=f.module({root:u6.NFKD,preformatted:g2.NFKD},{name:"string.normalize.NFKD"}),I7=f.module({root:"NFC",NFC:D7,NFD:M7,NFKC:w7,NFKD:P7},{name:"string.normalize"}),J8=l(_6,"a well-formed numeric string"),K7=f.module({root:J8,parse:v({in:J8,morphs:(X)=>Number.parseFloat(X),declaredOut:I.number})},{name:"string.numeric"}),W8="a regex pattern",N7=v({domain:"string",predicate:{meta:W8,predicate:(X,U)=>{try{return new RegExp(X),!0}catch(q){return U.reject({code:"predicate",expected:W8,problem:String(q)})}}},meta:{format:"regex"}}),C7=/^(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-]+)*))?$/,S7=l(C7,"a semantic version (see https://semver.org/)"),_8=l(/^\S.*\S$|^\S?$/,"trimmed"),E7=f.module({root:v({in:"string",morphs:(X)=>X.trim(),declaredOut:_8}),preformatted:_8},{name:"string.trim"}),$8=l(/^[A-Z]*$/,"only uppercase letters"),b7=f.module({root:v({in:"string",morphs:(X)=>X.toUpperCase(),declaredOut:$8}),preformatted:$8},{name:"string.upper"}),j7=(X)=>URL.canParse(X),L8=v({domain:"string",predicate:{meta:"a URL string",predicate:j7},meta:{format:"uri"}}),f7=f.module({root:L8,parse:v({declaredIn:L8,in:"string",morphs:(X,U)=>{try{return new URL(X)}catch{return U.error("a URL string")}},declaredOut:v(URL)})},{name:"string.url"}),y7=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"}),V8=f.module({root:I.string,alpha:l(/^[A-Za-z]*$/,"only letters"),alphanumeric:l(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:q7,base64:Z7,capitalize:Q7,creditCard:H7,date:L7,digits:l(/^\d*$/,"only digits 0-9"),email:z7,integer:z8,ip:V7,json:T7,lower:R7,normalize:I7,numeric:K7,regex:N7,semver:S7,trim:E7,upper:b7,url:f7,uuid:y7},{name:"string"});var O8=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}),B8=f.module({root:I.unknown,any:I.unknown},{name:"unknown"}),g7=f.module({root:I.jsonObject,stringify:h1("morph",{in:I.jsonObject,morphs:(X)=>JSON.stringify(X),declaredOut:I.string})},{name:"object.json"}),T8=f.module({root:I.object,json:g7},{name:"object"});class R8 extends e{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var k7=O0(["K",I.key],"V")((X)=>({domain:"object",index:{signature:X.K,value:X.V}}),R8);class D8 extends e{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var v7=O0(["T",I.object],["K",I.key])((X)=>X.T.pick(X.K),D8);class M8 extends e{description='omit a set of properties from an object like `Omit(User, "age")`'}var x7=O0(["T",I.object],["K",I.key])((X)=>X.T.omit(X.K),M8);class w8 extends e{description="make all named properties of an object optional like `Partial(User)`"}var h7=O0(["T",I.object])((X)=>X.T.partial(),w8);class P8 extends e{description="make all named properties of an object required like `Required(User)`"}var u7=O0(["T",I.object])((X)=>X.T.required(),P8);class I8 extends e{description='exclude branches of a union like `Exclude("boolean", "true")`'}var m7=O0("T","U")((X)=>X.T.exclude(X.U),I8);class K8 extends e{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var p7=O0("T","U")((X)=>X.T.extract(X.U),K8),N8=f.module({Exclude:m7,Extract:p7,Omit:x7,Partial:h7,Pick:v7,Record:k7,Required:u7});var x0=y2({...O8,...N8,...X8,...oZ,string:V8,number:h6,object:T8,unknown:B8},{prereducedAliases:!0,name:"ark"}),n=x0.export();Object.assign(p1.ambient,n);p1.typeAttachments={string:n.string.root,number:n.number.root,bigint:n.bigint,boolean:n.boolean,symbol:n.symbol,undefined:n.undefined,null:n.null,object:n.object.root,unknown:n.unknown.root,false:n.false,true:n.true,never:n.never,arrayIndex:n.Array.index,Key:n.Key,Record:n.Record,Array:n.Array.root,Date:n.Date};var r9=Object.assign(x0.type,p1.typeAttachments),l7=x0.match,d7=x0.fn,c7=x0.generic,ON=x0.schema,i7=x0.define,s7=x0.declare;var z1=y2({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'",value:"string | unknown[]"},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","probability?":"0 <= number <= 1"},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(),gN=z1.Operator,kN=z1.Condition,vN=z1.ConditionGroup,xN=z1.RuleCondition,hN=z1.Action,uN=z1.ActionGroup,o7=z1.TriggerRule;class a9{static validate(X){let U=o7(X);if(U instanceof r9.errors){let Q=[];for(let G of U){let Y=G.path.join("."),H=G.message,J=void 0;if(Y.endsWith("on")&&(H.includes("string")||H.includes("must be")))if(typeof X==="object"&&X&&X.on===!0)H="The 'on' field is incorrect (boolean true found).",J=`In YAML, 'on' is a boolean keyword (true). Quote it: "on": "EventName"`;else J="Ensure 'on' is a string event name.";Q.push({path:Y,message:H,suggestion:J,severity:"error"})}return{valid:!1,issues:Q}}let q=U,Z=[];if(this.validateConditionsRecursive(q.if,Z,"if"),Z.length>0)return{valid:!1,issues:Z};return{valid:!0,rule:q}}static validateConditionsRecursive(X,U,q){if(!X)return;if(Array.isArray(X)){X.forEach((Z,Q)=>{this.validateConditionsRecursive(Z,U,`${q}.${Q}`)});return}if("conditions"in X&&Array.isArray(X.conditions)){X.conditions.forEach((Z,Q)=>{this.validateConditionsRecursive(Z,U,`${q}.conditions.${Q}`)});return}if("operator"in X&&"value"in X)this.validateConditionValue(X,U,q)}static validateConditionValue(X,U,q){let{operator:Z,value:Q}=X;if(["IN","NOT_IN","RANGE","CONTAINS"].includes(Z)){if(Z==="CONTAINS"){if(typeof Q!=="string"&&!Array.isArray(Q))U.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)){U.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)U.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")U.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")U.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){U.push({path:`${q}.value`,message:`Invalid Regex pattern: ${G.message}`,severity:"error"})}else if(["GT","GTE","LT","LTE",">",">=","<","<="].includes(Z)){if(typeof Q!=="number"&&typeof Q!=="string")U.push({path:`${q}.value`,message:`Incorrect value type: Operator '${Z}' expects a number or expression string, but received ${typeof Q}.`,severity:"error"})}}}class m6{conditions=[];op="AND";constructor(X="AND"){this.op=X}where(X,U,q){return this.conditions.push({field:X,operator:U,value:q}),this}and(X){let U=new m6("AND");return this.conditions.push(X(U).build()),this}or(X){let U=new m6("OR");return this.conditions.push(X(U).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 C8{actions=[];mode="ALL";setMode(X){return this.mode=X,this}add(X,U,q){return this.actions.push({type:X,params:U,...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 r7{rule={enabled:!0,priority:0};withId(X){return this.rule.id=X,this}withName(X){return this.rule.name=X,this}withDescription(X){return this.rule.description=X,this}withPriority(X){return this.rule.priority=X,this}withCooldown(X){return this.rule.cooldown=X,this}withTags(X){return this.rule.tags=X,this}on(X){return this.rule.on=X,this}if(X,U,q){if(!this.rule.if)this.rule.if={field:X,operator:U,value:q};else if(Array.isArray(this.rule.if))this.rule.if.push({field:X,operator:U,value:q});else this.rule.if=[this.rule.if,{field:X,operator:U,value:q}];return this}ifComplex(X){let U=new m6,q=X(U).build();return this.rule.if=q,this}do(X,U,q){let Z={type:X,params:U,...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(X){let U=new C8,q=X(U).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 vQ=Y6(JU(),1);class rA{static toYaml(X){let U=Array.isArray(X)?X:[X];return vQ.default.stringify(U)}static async saveToFile(X,U){let q=this.toYaml(X);if(typeof process<"u"&&process.versions&&process.versions.node){let Z=await import("fs/promises"),G=(await import("path")).dirname(U);await Z.mkdir(G,{recursive:!0}),await Z.writeFile(U,q,"utf8")}else throw Error("saveToFile is only supported in Node.js/Bun environments")}}import{existsSync as xQ,mkdirSync as aA,readFileSync as nA,writeFileSync as tA}from"fs";import{dirname as eA}from"path";class XV{filePath;cache=new Map;isLoaded=!1;constructor(X){this.filePath=X}ensureLoaded(){if(this.isLoaded)return;try{if(xQ(this.filePath)){let X=nA(this.filePath,"utf-8"),U=JSON.parse(X);this.cache=new Map(Object.entries(U))}}catch(X){console.error(`[FilePersistence] Failed to load state from ${this.filePath}:`,X),this.cache=new Map}this.isLoaded=!0}persist(){try{let X=eA(this.filePath);if(!xQ(X))aA(X,{recursive:!0});let U=Object.fromEntries(this.cache);tA(this.filePath,JSON.stringify(U,null,2),"utf-8")}catch(X){console.error(`[FilePersistence] Failed to save state to ${this.filePath}:`,X)}}async loadState(){return this.ensureLoaded(),new Map(this.cache)}async saveState(X,U){this.ensureLoaded(),this.cache.set(X,U),this.persist()}async deleteState(X){this.ensureLoaded(),this.cache.delete(X),this.persist()}async clearState(){this.cache.clear(),this.persist()}}import*as U2 from"path";import*as D1 from"fs";var hQ=Y6(JU(),1);class UV{static async loadRulesFromDir(X){let U=[],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=U2.resolve(Z,G.name);if(G.isDirectory())await q(Y);else if(Y.toLowerCase().endsWith(".yaml")||Y.toLowerCase().endsWith(".yml"))try{let H=await this.loadRule(Y);U.push(...H)}catch(H){console.error(`Failed to load rule from ${Y}:`,H)}}};if(D1.existsSync(X))await q(X);else console.warn(`[TriggerLoader] Directory not found: ${X}`);return U}static async loadRule(X){try{let U=await D1.promises.readFile(X,"utf-8"),q=hQ.parseAllDocuments(U);for(let Y of q)if(Y.errors&&Y.errors.length>0)throw Error(`YAML syntax error in ${X}: ${Y.errors.map((H)=>H.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,H)=>{if(Y&&typeof Y==="object"&&Y.actions&&!Y.do)Y.do=Y.actions;let J=a9.validate(Y);if(J.valid){let W=J.rule;if(!W.id){let $=U2.basename(X,U2.extname(X));W.id=G.length>1?`${$}-${H}`:$}Q.push(W)}else console.error(`
185
+ [TriggerLoader] ⚠️ Validation Problem in ${X} (item #${H+1})`),J.issues.forEach((W)=>{if(console.error(` - [${W.path}] ${W.message}`),W.suggestion)console.error(` \uD83D\uDCA1 Suggestion: ${W.suggestion}`)})}),Q}catch(U){throw console.error(`Error parsing YAML file ${X}:`,U),U}}static watchRules(X,U){return this.loadRulesFromDir(X).then(U),console.log(`[TriggerLoader] Watching for changes in ${X}...`),D1.watch(X,{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(X);U(G),console.log(`[TriggerLoader] Reloaded ${G.length} rules.`)}catch(G){console.error("[TriggerLoader] Failed to reload rules:",G)}}})}}export{G1 as triggerEmitter,VV as engineEvents,a9 as TriggerValidator,q2 as TriggerUtils,o7 as TriggerRuleSchema,UV as TriggerLoader,G2 as TriggerEngine,j4 as TriggerEmitter,R0 as StateManager,rA as RuleExporter,f4 as RuleEngine,xN as RuleConditionSchema,r7 as RuleBuilder,b4 as InMemoryPersistence,XV as FilePersistence,$0 as ExpressionEngine,iQ as EventQueue,H6 as EngineEvent,G2 as Engine,oQ as ContextAdapter,kN as ConditionSchema,vN as ConditionGroupSchema,m6 as ConditionBuilder,gN as ComparisonOperatorSchema,sQ as BrowserPersistence,f4 as AdvancedRuleEngine,hN as ActionSchema,P1 as ActionRegistry,uN as ActionGroupSchema,C8 as ActionBuilder};
186
186
 
187
- //# debugId=A576519C4DE6A42564756E2164756E21
187
+ //# debugId=EB57C89A10C68B1A64756E2164756E21