trigger_system 1.2.1 → 1.2.5

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.
Files changed (124) hide show
  1. package/dist/browser/index.browser.js +183 -40
  2. package/dist/browser/index.browser.js.map +116 -17
  3. package/dist/core/action-registry.d.ts +29 -3
  4. package/dist/core/action-registry.d.ts.map +1 -1
  5. package/dist/core/base-engine.d.ts +3 -3
  6. package/dist/core/constants.d.ts +95 -0
  7. package/dist/core/constants.d.ts.map +1 -0
  8. package/dist/core/dependency-graph/analyzer.d.ts +60 -0
  9. package/dist/core/dependency-graph/analyzer.d.ts.map +1 -0
  10. package/dist/core/dependency-graph/builder.d.ts +28 -0
  11. package/dist/core/dependency-graph/builder.d.ts.map +1 -0
  12. package/dist/core/dependency-graph/cycles.d.ts +28 -0
  13. package/dist/core/dependency-graph/cycles.d.ts.map +1 -0
  14. package/dist/core/dependency-graph/index.d.ts +11 -0
  15. package/dist/core/dependency-graph/index.d.ts.map +1 -0
  16. package/dist/core/dependency-graph/types.d.ts +72 -0
  17. package/dist/core/dependency-graph/types.d.ts.map +1 -0
  18. package/dist/core/dependency-graph/utils.d.ts +39 -0
  19. package/dist/core/dependency-graph/utils.d.ts.map +1 -0
  20. package/dist/core/dependency-graph/validator.d.ts +28 -0
  21. package/dist/core/dependency-graph/validator.d.ts.map +1 -0
  22. package/dist/core/dependency-graph.d.ts +64 -13
  23. package/dist/core/dependency-graph.d.ts.map +1 -1
  24. package/dist/core/engine-utils.d.ts +45 -0
  25. package/dist/core/engine-utils.d.ts.map +1 -0
  26. package/dist/core/engine.d.ts +0 -8
  27. package/dist/core/engine.d.ts.map +1 -1
  28. package/dist/core/expression-engine.d.ts +52 -10
  29. package/dist/core/expression-engine.d.ts.map +1 -1
  30. package/dist/core/index.d.ts +2 -4
  31. package/dist/core/index.d.ts.map +1 -1
  32. package/dist/core/operators.d.ts +48 -0
  33. package/dist/core/operators.d.ts.map +1 -0
  34. package/dist/core/persistence-browser.d.ts +25 -2
  35. package/dist/core/persistence-browser.d.ts.map +1 -1
  36. package/dist/core/persistence.node.d.ts +25 -2
  37. package/dist/core/persistence.node.d.ts.map +1 -1
  38. package/dist/core/rule-engine-new.d.ts +2 -1
  39. package/dist/core/rule-engine-new.d.ts.map +1 -1
  40. package/dist/core/rule-engine.d.ts +22 -35
  41. package/dist/core/rule-engine.d.ts.map +1 -1
  42. package/dist/core/trigger-engine.d.ts +18 -25
  43. package/dist/core/trigger-engine.d.ts.map +1 -1
  44. package/dist/domain/validator.d.ts +36043 -5067
  45. package/dist/domain/validator.d.ts.map +1 -1
  46. package/dist/index.browser.d.ts +1 -0
  47. package/dist/index.browser.d.ts.map +1 -1
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/io/index.d.ts +6 -1
  51. package/dist/io/index.d.ts.map +1 -1
  52. package/dist/io/loader/index.d.ts +48 -0
  53. package/dist/io/loader/index.d.ts.map +1 -0
  54. package/dist/io/loader/persistence.d.ts +41 -0
  55. package/dist/io/loader/persistence.d.ts.map +1 -0
  56. package/dist/io/loader/query.d.ts +49 -0
  57. package/dist/io/loader/query.d.ts.map +1 -0
  58. package/dist/io/loader/registry.d.ts +91 -0
  59. package/dist/io/loader/registry.d.ts.map +1 -0
  60. package/dist/io/loader/types.d.ts +32 -0
  61. package/dist/io/loader/types.d.ts.map +1 -0
  62. package/dist/io/loader/watch.d.ts +36 -0
  63. package/dist/io/loader/watch.d.ts.map +1 -0
  64. package/dist/io/loader.node.d.ts +1 -13
  65. package/dist/io/loader.node.d.ts.map +1 -1
  66. package/dist/lsp/hover-constants.d.ts +42 -0
  67. package/dist/lsp/hover-constants.d.ts.map +1 -0
  68. package/dist/lsp/server.bundle.d.ts +2 -0
  69. package/dist/lsp/server.bundle.d.ts.map +1 -0
  70. package/dist/node/index.js +183 -170
  71. package/dist/node/index.js.map +116 -91
  72. package/dist/node/node.js +185 -173
  73. package/dist/node/node.js.map +122 -93
  74. package/dist/node.d.ts +1 -1
  75. package/dist/node.d.ts.map +1 -1
  76. package/dist/sdk/builder.d.ts +177 -21
  77. package/dist/sdk/builder.d.ts.map +1 -1
  78. package/dist/sdk/builders/action-builder.d.ts +24 -0
  79. package/dist/sdk/builders/action-builder.d.ts.map +1 -0
  80. package/dist/sdk/builders/condition-builder.d.ts +26 -0
  81. package/dist/sdk/builders/condition-builder.d.ts.map +1 -0
  82. package/dist/sdk/builders/index.d.ts +5 -0
  83. package/dist/sdk/builders/index.d.ts.map +1 -0
  84. package/dist/sdk/builders/params-builder.d.ts +59 -0
  85. package/dist/sdk/builders/params-builder.d.ts.map +1 -0
  86. package/dist/sdk/constants.d.ts +44 -0
  87. package/dist/sdk/constants.d.ts.map +1 -0
  88. package/dist/sdk/exporter.d.ts +16 -0
  89. package/dist/sdk/exporter.d.ts.map +1 -1
  90. package/dist/sdk/graph/action-resolver.d.ts +103 -0
  91. package/dist/sdk/graph/action-resolver.d.ts.map +1 -0
  92. package/dist/sdk/graph/condition-resolver.d.ts +87 -0
  93. package/dist/sdk/graph/condition-resolver.d.ts.map +1 -0
  94. package/dist/sdk/graph/converters.d.ts +152 -0
  95. package/dist/sdk/graph/converters.d.ts.map +1 -0
  96. package/dist/sdk/graph/index.d.ts +12 -0
  97. package/dist/sdk/graph/index.d.ts.map +1 -0
  98. package/dist/sdk/graph/node-filters.d.ts +96 -0
  99. package/dist/sdk/graph/node-filters.d.ts.map +1 -0
  100. package/dist/sdk/graph/traversal.d.ts +105 -0
  101. package/dist/sdk/graph/traversal.d.ts.map +1 -0
  102. package/dist/sdk/graph/types.d.ts +28 -0
  103. package/dist/sdk/graph/types.d.ts.map +1 -0
  104. package/dist/sdk/graph-parser.d.ts +40 -0
  105. package/dist/sdk/graph-parser.d.ts.map +1 -0
  106. package/dist/sdk/index.d.ts +3 -0
  107. package/dist/sdk/index.d.ts.map +1 -1
  108. package/dist/sdk/optimize.d.ts +27 -0
  109. package/dist/sdk/optimize.d.ts.map +1 -0
  110. package/dist/sdk/yaml/converter.d.ts +81 -0
  111. package/dist/sdk/yaml/converter.d.ts.map +1 -0
  112. package/dist/sdk/yaml/index.d.ts +39 -0
  113. package/dist/sdk/yaml/index.d.ts.map +1 -0
  114. package/dist/sdk/yaml/normalizer.d.ts +44 -0
  115. package/dist/sdk/yaml/normalizer.d.ts.map +1 -0
  116. package/dist/sdk/yaml/types.d.ts +198 -0
  117. package/dist/sdk/yaml/types.d.ts.map +1 -0
  118. package/dist/sdk/yaml/utils.d.ts +131 -0
  119. package/dist/sdk/yaml/utils.d.ts.map +1 -0
  120. package/dist/sdk/yaml-parser.d.ts +18 -0
  121. package/dist/sdk/yaml-parser.d.ts.map +1 -0
  122. package/dist/types.d.ts +40 -2
  123. package/dist/types.d.ts.map +1 -1
  124. package/package.json +6 -1
package/dist/node/node.js CHANGED
@@ -1,187 +1,199 @@
1
- import{createRequire as qG}from"node:module";var rQ=Object.create;var{getPrototypeOf:aQ,defineProperty:Z2,getOwnPropertyNames:LU,getOwnPropertyDescriptor:nQ}=Object,zU=Object.prototype.hasOwnProperty;function FU(X){return this[X]}var tQ,eQ,VU=(X,U,q)=>{var Z=X!=null&&typeof X==="object";if(Z){var Q=U?tQ??=new WeakMap:eQ??=new WeakMap,G=Q.get(X);if(G)return G}q=X!=null?rQ(aQ(X)):{};let Y=U||!X||!X.__esModule?Z2(q,"default",{value:X,enumerable:!0}):q;for(let J of LU(X))if(!zU.call(Y,J))Z2(Y,J,{get:FU.bind(X,J),enumerable:!0});if(Z)Q.set(X,Y);return Y},AU=(X)=>{var U=($U??=new WeakMap).get(X),q;if(U)return U;if(U=Z2({},"__esModule",{value:!0}),X&&typeof X==="object"||typeof X==="function"){for(var Z of LU(X))if(!zU.call(U,Z))Z2(U,Z,{get:FU.bind(X,Z),enumerable:!(q=nQ(X,Z))||q.enumerable})}return $U.set(X,U),U},$U,R=(X,U)=>()=>(U||X((U={exports:{}}).exports,U),U.exports);var XG=(X)=>X;function UG(X,U){this[X]=XG.bind(null,U)}var OU=(X,U)=>{for(var q in U)Z2(X,q,{get:U[q],enumerable:!0,configurable:!0,set:UG.bind(U,q)})};var TU=(X,U)=>()=>(X&&(U=X(X=0)),U);var w1=qG(import.meta.url);var j4={};OU(j4,{ExpressionEngine:()=>e});class e{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|vars|request|computed|env|state)(\.[a-zA-Z0-9_]+)+$/.test(X))return this.getNestedValue(X,U);if(/^(vars|env|state)(\.[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||typeof Z!=="object"||!(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 X0{static instance;state;persistence;constructor(){this.state={},this.persistence=new b4}static getInstance(){if(!X0.instance)X0.instance=new X0;return X0.instance}setPersistence(X){this.persistence=X}async initialize(){let X=await this.persistence.loadState();if(X instanceof Map)this.state=Object.fromEntries(X);else this.state=X||{};console.log(`[StateManager] Initialized with ${Object.keys(this.state).length} root keys.`)}get(X){return this.state[X]}async set(X,U){this.state[X]=U,await this.persistence.saveState(X,U)}async increment(X,U=1){let q=this.state[X]||0,Z=Number(q)+U;return this.state[X]=Z,await this.persistence.saveState(X,Z),Z}async decrement(X,U=1){return this.increment(X,-U)}async delete(X){if(X in this.state)return delete this.state[X],await this.persistence.deleteState(X),!0;return!1}async clear(){this.state={},await this.persistence.clearState()}async applyConfig(X){if(!X.state)return;for(let[U,q]of Object.entries(X.state))if(typeof q!=="object"||q===null||!("value"in q)){if(this.state[U]===void 0)await this.set(U,q)}else{let Z=q;if(this.state[U]===void 0)await this.set(U,Z.value);if(Z.lifecycle?.ttl)this.setupTTL(U,Z.lifecycle.ttl)}}setupTTL(X,U){let q=0;if(typeof U==="number")q=U;else{let Z=U.match(/^(\d+)([smhd])$/);if(Z&&Z[1]&&Z[2]){let Q=parseInt(Z[1]),G=Z[2];q=Q*({s:1000,m:60000,h:3600000,d:86400000}[G]||0)}}if(q>0)setTimeout(()=>{this.delete(X).catch(console.error)},q)}getAll(){return{...this.state}}getLiveProxy(){let X=this;function U(q,Z=[]){return new Proxy(q,{get(Q,G){let Y=Q[G];if(Y&&typeof Y==="object"&&!Array.isArray(Y))return U(Y,[...Z,G]);return Y},set(Q,G,Y){if(typeof G!=="string")return!1;Q[G]=Y;let J=Z.length>0?Z[0]:G;if(J)X.persistence.saveState(J,X.state[J]);return!0}})}return U(this.state)}}var P1=()=>{};var RU={};OU(RU,{ActionRegistry:()=>I1});class I1{static instance;handlers=new Map;constructor(){this.registerDefaults()}static getInstance(){if(!this.instance)this.instance=new I1;return this.instance}register(X,U){this.handlers.set(X.toUpperCase(),U)}get(X){return this.handlers.get(X.toUpperCase())}get Handlers(){return this.handlers}registerDefaults(){this.register("log",(X,U)=>{let q=X.params?.message||X.params?.content||"Log Trigger",Z=typeof q==="string"?e.interpolate(q,U):String(q);return console.log(`[TriggerLog] ${Z}`),{message:Z}}),this.register("math",(X,U)=>{let q=String(X.params?.expression||"0");return e.evaluate(q,U)}),this.register("response",(X,U)=>{let q=X.params?.content||X.params?.body||"",Z=typeof q==="string"?e.interpolate(q,U):String(q);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=typeof q==="string"?e.interpolate(q,U):String(q);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=typeof q==="string"?e.interpolate(q,U):String(q),Q=String(X.params?.method||"POST").toUpperCase(),Y=["POST","PUT","PATCH"].includes(Q);try{let J=await fetch(Z,{method:Q,headers:{"Content-Type":"application/json",...typeof X.params?.headers==="object"&&X.params.headers!==null&&!Array.isArray(X.params.headers)?X.params.headers:{}},...Y?{body:JSON.stringify(U.data)}:{}});return{url:Z,method:Q,status:J.status,headers:(()=>{let H={};return J.headers.forEach((W,$)=>H[$]=W),H})(),body:await J.text()}}catch(J){return{url:Z,method:Q,error:String(J)}}}),this.register("STATE_SET",async(X,U)=>{let q=String(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=e.interpolate(Z,U);return await X0.getInstance().set(q,Q),{key:q,value:Q}}),this.register("STATE_INCREMENT",async(X,U)=>{let q=String(X.params?.key||""),Z=Number(X.params?.amount)||1;if(!q)return{error:"Missing key for STATE_INCREMENT"};let Q=await X0.getInstance().increment(q,Z);return{key:q,newValue:Q}}),this.register("STATE_GET",async(X,U)=>{let q=String(X.params?.key||""),Z=String(X.params?.as||q);if(!q)return{error:"Missing key for STATE_GET"};let Q=await X0.getInstance().get(q);if(!U.env)U.env={};return U.env[Z]=Q,{key:q,value:Q,storedAs:Z}}),this.register("STATE_DELETE",async(X,U)=>{let q=String(X.params?.key||"");if(!q)return{error:"Missing key for STATE_DELETE"};let Z=await X0.getInstance().delete(q);return{key:q,deleted:Z}}),this.register("EMIT_EVENT",(X,U)=>{return{event:X.params?.event,payload:X.params?.data||{}}}),this.register("notify",(X,U)=>{let q=X.params?.message||X.params?.content||"Notification",Z=X.params?.target||"default";return console.log(`[Notification] To: ${Z}, Msg: ${q}`),{target:Z,message:q}}),this.register("STATE_OP",(X,U)=>{if(X.params?.run)return Function("context","state","data","vars","env","helpers",`with(context) { ${X.params.run} }`)(U,U.state,U.data,U.vars,U.env,U.helpers);return{warning:"Missing 'run' param for STATE_OP"}})}}var G2=TU(()=>{P1()});var k=R((FJ)=>{var t9=Symbol.for("yaml.alias"),h8=Symbol.for("yaml.document"),l6=Symbol.for("yaml.map"),x8=Symbol.for("yaml.pair"),e9=Symbol.for("yaml.scalar"),d6=Symbol.for("yaml.seq"),u0=Symbol.for("yaml.node.type"),JJ=(X)=>!!X&&typeof X==="object"&&X[u0]===t9,HJ=(X)=>!!X&&typeof X==="object"&&X[u0]===h8,WJ=(X)=>!!X&&typeof X==="object"&&X[u0]===l6,_J=(X)=>!!X&&typeof X==="object"&&X[u0]===x8,u8=(X)=>!!X&&typeof X==="object"&&X[u0]===e9,$J=(X)=>!!X&&typeof X==="object"&&X[u0]===d6;function m8(X){if(X&&typeof X==="object")switch(X[u0]){case l6:case d6:return!0}return!1}function LJ(X){if(X&&typeof X==="object")switch(X[u0]){case t9:case l6:case e9:case d6:return!0}return!1}var zJ=(X)=>(u8(X)||m8(X))&&!!X.anchor;FJ.ALIAS=t9;FJ.DOC=h8;FJ.MAP=l6;FJ.NODE_TYPE=u0;FJ.PAIR=x8;FJ.SCALAR=e9;FJ.SEQ=d6;FJ.hasAnchor=zJ;FJ.isAlias=JJ;FJ.isCollection=m8;FJ.isDocument=HJ;FJ.isMap=WJ;FJ.isNode=LJ;FJ.isPair=_J;FJ.isScalar=u8;FJ.isSeq=$J});var v2=R((jJ)=>{var t=k(),L0=Symbol("break visit"),p8=Symbol("skip children"),b0=Symbol("remove node");function c6(X,U){let q=l8(U);if(t.isDocument(X)){if(c1(null,X.contents,q,Object.freeze([X]))===b0)X.contents=null}else c1(null,X,q,Object.freeze([]))}c6.BREAK=L0;c6.SKIP=p8;c6.REMOVE=b0;function c1(X,U,q,Z){let Q=d8(X,U,q,Z);if(t.isNode(Q)||t.isPair(Q))return c8(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=c1(G,U.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===L0)return L0;else if(Y===b0)U.items.splice(G,1),G-=1}}else if(t.isPair(U)){Z=Object.freeze(Z.concat(U));let G=c1("key",U.key,q,Z);if(G===L0)return L0;else if(G===b0)U.key=null;let Y=c1("value",U.value,q,Z);if(Y===L0)return L0;else if(Y===b0)U.value=null}}return Q}async function i6(X,U){let q=l8(U);if(t.isDocument(X)){if(await i1(null,X.contents,q,Object.freeze([X]))===b0)X.contents=null}else await i1(null,X,q,Object.freeze([]))}i6.BREAK=L0;i6.SKIP=p8;i6.REMOVE=b0;async function i1(X,U,q,Z){let Q=await d8(X,U,q,Z);if(t.isNode(Q)||t.isPair(Q))return c8(X,Z,Q),i1(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 i1(G,U.items[G],q,Z);if(typeof Y==="number")G=Y-1;else if(Y===L0)return L0;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 i1("key",U.key,q,Z);if(G===L0)return L0;else if(G===b0)U.key=null;let Y=await i1("value",U.value,q,Z);if(Y===L0)return L0;else if(Y===b0)U.value=null}}return Q}function l8(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 d8(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 c8(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`)}}jJ.visit=c6;jJ.visitAsync=i6});var XX=R((vJ)=>{var i8=k(),gJ=v2(),yJ={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},kJ=(X)=>X.replace(/[!,[\]{}]/g,(U)=>yJ[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+kJ(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&&i8.isNode(X.contents)){let Q={};gJ.visit(X.contents,(G,Y)=>{if(i8.isNode(Y)&&Y.tag)Q[Y.tag]=!0}),Z=Object.keys(Q)}else Z=[];for(let[Q,G]of q){if(Q==="!!"&&G==="tag:yaml.org,2002:")continue;if(!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:"};vJ.Directives=B0});var s6=R((pJ)=>{var s8=k(),xJ=v2();function uJ(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 o8(X){let U=new Set;return xJ.visit(X,{Value(q,Z){if(Z.anchor)U.add(Z.anchor)}}),U}function r8(X,U){for(let q=1;;++q){let Z=`${X}${q}`;if(!U.has(Z))return Z}}function mJ(X,U){let q=[],Z=new Map,Q=null;return{onAnchor:(G)=>{q.push(G),Q??(Q=o8(X));let Y=r8(U,Q);return Q.add(Y),Y},setAnchors:()=>{for(let G of q){let Y=Z.get(G);if(typeof Y==="object"&&Y.anchor&&(s8.isScalar(Y.node)||s8.isCollection(Y.node)))Y.node.anchor=Y.anchor;else{let J=Error("Failed to resolve repeated object (this should not happen)");throw J.source=G,J}}},sourceObjects:Z}}pJ.anchorIsValid=uJ;pJ.anchorNames=o8;pJ.createNodeAnchors=mJ;pJ.findNewAnchor=r8});var UX=R((sJ)=>{function h2(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],J=h2(X,Z,String(Q),Y);if(J===void 0)delete Z[Q];else if(J!==Y)Z[Q]=J}else if(Z instanceof Map)for(let Q of Array.from(Z.keys())){let G=Z.get(Q),Y=h2(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=h2(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=h2(X,Z,Q,G);if(Y===void 0)delete Z[Q];else if(Y!==G)Z[Q]=Y}return X.call(U,q,Z)}sJ.applyReviver=h2});var n0=R((aJ)=>{var rJ=k();function a8(X,U,q){if(Array.isArray(X))return X.map((Z,Q)=>a8(Z,String(Q),q));if(X&&typeof X.toJSON==="function"){if(!q||!rJ.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}aJ.toJS=a8});var o6=R((XH)=>{var tJ=UX(),n8=k(),eJ=n0();class t8{constructor(X){Object.defineProperty(this,n8.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(!n8.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=eJ.toJS(this,"",G);if(typeof Z==="function")for(let{count:J,res:H}of G.anchors.values())Z(H,J);return typeof Q==="function"?tJ.applyReviver(Q,{"":Y},"",Y):Y}}XH.NodeBase=t8});var x2=R((YH)=>{var qH=s6(),ZH=v2(),s1=k(),QH=o6(),GH=n0();class e8 extends QH.NodeBase{constructor(X){super(s1.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=[],ZH.visit(X,{Node:(Q,G)=>{if(s1.isAlias(G)||s1.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 J=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(J)}let Y=q.get(G);if(!Y)GH.toJS(G,null,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=r6(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(qH.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 r6(X,U,q){if(s1.isAlias(U)){let Z=U.resolve(X),Q=q&&Z&&q.get(Z);return Q?Q.count*Q.aliasCount:0}else if(s1.isCollection(U)){let Z=0;for(let Q of U.items){let G=r6(X,Q,q);if(G>Z)Z=G}return Z}else if(s1.isPair(U)){let Z=r6(X,U.key,q),Q=r6(X,U.value,q);return Math.max(Z,Q)}return 1}YH.Alias=e8});var i=R((LH)=>{var HH=k(),WH=o6(),_H=n0(),$H=(X)=>!X||typeof X!=="function"&&typeof X!=="object";class F1 extends WH.NodeBase{constructor(X){super(HH.SCALAR);this.value=X}toJSON(X,U){return U?.keep?this.value:_H.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";LH.Scalar=F1;LH.isScalarValue=$H});var u2=R((BH)=>{var VH=x2(),V1=k(),X3=i(),AH="tag:yaml.org,2002:";function OH(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 TH(X,U,q){if(V1.isDocument(X))X=X.contents;if(V1.isNode(X))return X;if(V1.isPair(X)){let _=q.schema[V1.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:J}=q,H=void 0;if(Z&&X&&typeof X==="object")if(H=J.get(X),H)return H.anchor??(H.anchor=Q(X)),new VH.Alias(H.anchor);else H={anchor:null,node:null},J.set(X,H);if(U?.startsWith("!!"))U=AH+U.slice(2);let W=OH(X,U,Y.tags);if(!W){if(X&&typeof X.toJSON==="function")X=X.toJSON();if(!X||typeof X!=="object"){let _=new X3.Scalar(X);if(H)H.node=_;return _}W=X instanceof Map?Y[V1.MAP]:(Symbol.iterator in Object(X))?Y[V1.SEQ]:Y[V1.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 X3.Scalar(X);if(U)$.tag=U;else if(!W.default)$.tag=W.tag;if(H)H.node=$;return $}BH.createNode=TH});var a6=R((wH)=>{var DH=u2(),f0=k(),MH=o6();function qX(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 DH.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 U3=(X)=>X==null||typeof X==="object"&&!!X[Symbol.iterator]().next().done;class q3 extends MH.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)=>f0.isNode(q)||f0.isPair(q)?q.clone(X):q),this.range)U.range=this.range.slice();return U}addIn(X,U){if(U3(X))this.add(U);else{let[q,...Z]=X,Q=this.get(q,!0);if(f0.isCollection(Q))Q.addIn(Z,U);else if(Q===void 0&&this.schema)this.set(q,qX(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(f0.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&&f0.isScalar(Q)?Q.value:Q;else return f0.isCollection(Q)?Q.getIn(Z,U):void 0}hasAllNullValues(X){return this.items.every((U)=>{if(!f0.isPair(U))return!1;let q=U.value;return q==null||X&&f0.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 f0.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(f0.isCollection(Q))Q.setIn(Z,U);else if(Q===void 0&&this.schema)this.set(q,qX(this.schema,Z,U));else throw Error(`Expected YAML collection at ${q}. Remaining path: ${Z}`)}}}wH.Collection=q3;wH.collectionFromPath=qX;wH.isEmptyPath=U3});var m2=R((SH)=>{var NH=(X)=>X.replace(/^(?!$)(?: $)?/gm,"#");function ZX(X,U){if(/^\n+$/.test(X))return X.substring(1);return U?X.replace(/^(?! *$)/gm,U):X}var CH=(X,U,q)=>X.endsWith(`
3
- `)?ZX(q,U):q.includes(`
1
+ import{createRequire as nY}from"node:module";var lY=Object.create;var{getPrototypeOf:dY,defineProperty:L6,getOwnPropertyNames:ZQ,getOwnPropertyDescriptor:cY}=Object,XQ=Object.prototype.hasOwnProperty;function QQ(Z){return this[Z]}var iY,sY,UQ=(Z,X,Q)=>{var U=Z!=null&&typeof Z==="object";if(U){var J=X?iY??=new WeakMap:sY??=new WeakMap,q=J.get(Z);if(q)return q}Q=Z!=null?lY(dY(Z)):{};let Y=X||!Z||!Z.__esModule?L6(Q,"default",{value:Z,enumerable:!0}):Q;for(let W of ZQ(Z))if(!XQ.call(Y,W))L6(Y,W,{get:QQ.bind(Z,W),enumerable:!0});if(U)J.set(Z,Y);return Y},JQ=(Z)=>{var X=(e3??=new WeakMap).get(Z),Q;if(X)return X;if(X=L6({},"__esModule",{value:!0}),Z&&typeof Z==="object"||typeof Z==="function"){for(var U of ZQ(Z))if(!XQ.call(X,U))L6(X,U,{get:QQ.bind(Z,U),enumerable:!(Q=cY(Z,U))||Q.enumerable})}return e3.set(Z,X),X},e3,C=(Z,X)=>()=>(X||Z((X={exports:{}}).exports,X),X.exports);var aY=(Z)=>Z;function rY(Z,X){this[Z]=aY.bind(null,X)}var oY=(Z,X)=>{for(var Q in X)L6(Z,Q,{get:X[Q],enumerable:!0,configurable:!0,set:rY.bind(X,Q)})};var O=(Z,X)=>()=>(Z&&(X=Z(Z=0)),X);var z2=nY(import.meta.url);var P1=(Z)=>Array.isArray(Z)?Z:[Z],qQ=(Z,X)=>{let Q=[[],[]];for(let U of Z)if(X(U))Q[0].push(U);else Q[1].push(U);return Q},P4,g0=(Z,X)=>Z.includes(X),YQ=(Z,X=0)=>[...Array(Z)].map((Q,U)=>U+X),m=(Z,X,Q)=>{if(Z===void 0)return X===void 0?[]:Array.isArray(X)?X:[X];if(Q?.prepend)if(Array.isArray(X))Z.unshift(...X);else Z.unshift(X);else if(Array.isArray(X))Z.push(...X);else Z.push(X);return Z},H1=(Z,X)=>{if(X===void 0||X===null)return Z??[];if(Z===void 0||Z===null)return P1(X);return Z.concat(X)},WQ=(...Z)=>Z.reduce(H1,[]),X1=(Z,X,Q)=>{if(Z===void 0)return Array.isArray(X)?X:[X];let U=Q?.isEqual??((J,q)=>J===q);for(let J of P1(X))if(!Z.some((q)=>U(q,J)))Z.push(J);return Z},$Q=(Z,X)=>Z.reduce((Q,U)=>{let J=U[X];return Q[J]=m(Q[J],U),Q},{}),z1=(Z,X,Q)=>Z.length===X.length&&Z.every(Q?.isEqual?(U,J)=>Q.isEqual(U,X[J]):(U,J)=>U===X[J]);var A4=O(()=>{P4=Array});var w0=(Z,X)=>$0(Z)===X,$0=(Z)=>{let X=typeof Z;return X==="object"?Z===null?"null":"object":X==="function"?"object":X},P0,LQ;var F2=O(()=>{P0={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},LQ={...P0,function:"a function"}});var GQ,u=(Z)=>n1(Z,GQ),n1=(Z,X=Error)=>{throw new X(Z)},G6,M=(Z)=>n1(Z,G6),s0=(Z)=>` ${Z}`,_Q="​";var Q1=O(()=>{GQ=class GQ extends Error{};G6=class G6 extends Error{name="ParseError"}});var k=(Z,X)=>{let Q={},U=Array.isArray(Z),J=!1;for(let[q,Y]of Object.entries(Z).entries()){let W=U?X(q,Y[1]):X(...Y,q);J||=typeof W[0]==="number";let $=Array.isArray(W[0])||W.length===0?W:[W];for(let[L,_]of $)if(typeof L==="object")Q[L.group]=m(Q[L.group],_);else Q[L]=_}return J?Object.values(Q):Q};var zZ=O(()=>{A4()});class BZ{constructor(Z){Object.assign(this,Z)}}var FZ,L0=(Z,X)=>(Z in X),B2=(Z,X)=>(X in Z),VQ=class{},_6,tY=(Z,X)=>{let Q={},U={},J;for(J in Z)if(J in X)Q[J]=Z[J];else U[J]=Z[J];return[Q,U]},S4=(Z,X)=>tY(Z,X)[1],U1=(Z)=>Object.keys(Z).length===0,t1=(Z)=>[...Object.entries(Z),...Object.getOwnPropertySymbols(Z).map((X)=>[X,Z[X]])],HQ=(Z,X)=>Object.defineProperties(Z,Object.getOwnPropertyDescriptors(X)),zQ=(Z)=>{let X=Object.keys(Z).sort(),Q={};for(let U=0;U<X.length;U++)Q[X[U]]=Z[X[U]];return Q},A0,FQ=(Z)=>Object.values(Z).filter((X)=>{if(typeof X==="number")return!0;return typeof Z[X]!=="number"});var M2=O(()=>{Q1();zZ();FZ=Object.entries;_6=class _6 extends VQ{};A0=s0(`unset${_Q}`)});var MZ,OZ,RZ,eY,e1,V6=(Z)=>{let X=Object.getPrototypeOf(Z);while(X?.constructor&&(!L0(X.constructor.name,e1)||!(Z instanceof e1[X.constructor.name])))X=Object.getPrototypeOf(X);let Q=X?.constructor?.name;if(Q===void 0||Q==="Object")return;return Q},H6=(Z)=>typeof Z==="object"&&Z!==null?V6(Z)??"object":$0(Z),r,ZW,XW,QW,BQ,z6=(Z)=>{let X=Object(Z).name??null;return X&&L0(X,e1)&&e1[X]===Z?X:null},KZ=(Z,X)=>{let Q=Z.prototype;while(Q!==null){if(Q===X.prototype)return!0;Q=Object.getPrototypeOf(Q)}return!1};var F6=O(()=>{F2();M2();MZ={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},OZ=globalThis.File??Blob,RZ={ArrayBuffer,Blob,File:OZ,FormData,Headers,Request,Response,URL},eY={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},e1={...MZ,...RZ,...eY,String,Number,Boolean},r=Array.isArray,ZW={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"},XW={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"},QW={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"},BQ={...ZW,...XW,...QW}});var MQ=(Z)=>OQ(Z,new Map),OQ=(Z,X)=>{if(typeof Z!=="object"||Z===null)return Z;if(X?.has(Z))return X.get(Z);let Q=z6(Z.constructor);if(Q==="Date")return new Date(Z.getTime());if(Q&&Q!=="Array")return Z;let U=Array.isArray(Z)?Z.slice():Object.create(Object.getPrototypeOf(Z)),J=Object.getOwnPropertyDescriptors(Z);if(X){X.set(Z,U);for(let q in J){let Y=J[q];if("get"in Y||"set"in Y)continue;Y.value=OQ(Y.value,X)}}return Object.defineProperties(U,J),U};var RQ=O(()=>{F6()});var KQ=()=>{};class S0{constructor(Z,...[X]){return Object.assign(Object.setPrototypeOf(Z.bind(X?.bind??this),this.constructor.prototype),X?.attach)}}var UW=(Z)=>{let X=A0;return()=>X===A0?X=Z():X},A1=(Z)=>typeof Z==="function"&&Z.length===0,TQ,DQ;var wQ=O(()=>{Q1();M2();TQ=class extends Function{constructor(...Z){let X=Z.slice(0,-1),Q=Z[Z.length-1];try{super(...X,Q)}catch(U){return u(`Encountered an unexpected error while compiling your definition:
2
+ Message: ${U}
3
+ Source: (${Z.slice(0,-1)}) => {
4
+ ${Z[Z.length-1]}
5
+ }`)}}};DQ=UW(()=>{try{return Function("return false")()}catch{return!0}})});var qT,PQ;var AQ=O(()=>{Q1();qT=s0("brand"),PQ=s0("arkInferred")});class H0{constructor(){}}var $T;var SQ=O(()=>{Q1();$T=s0("args")});var CQ=()=>{};var JW=()=>{try{return((Error().stack?.split(`
6
+ `)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},qW,NQ;var TZ=O(()=>{qW=globalThis.process?.env??{},NQ={fileName:JW,env:qW}});var jQ=()=>{};var EQ=(Z)=>Z[0].toUpperCase()+Z.slice(1),bQ=(Z)=>Z[0].toLowerCase()+Z.slice(1),DZ=(Z)=>new RegExp(YW(Z),typeof Z==="string"?"":Z.flags),YW=(Z)=>{return`^(?:${typeof Z==="string"?Z:Z.source})$`},B1,Z2="\\",S1;var C4=O(()=>{B1={negativeLookahead:(Z)=>`(?!${Z})`,nonCapturingGroup:(Z)=>`(?:${Z})`},S1={" ":1,"\n":1,"\t":1}});var WW,fQ,$W,LW,kQ=(Z)=>DZ(B1.negativeLookahead(WW)+B1.nonCapturingGroup("-?"+B1.nonCapturingGroup(B1.nonCapturingGroup("0|"+fQ)+B1.nonCapturingGroup(Z.decimalPattern)+"?")+(Z.allowDecimalOnly?"|"+Z.decimalPattern:"")+"?")),IQ,GW,N4,FT,_W,VW=(Z)=>Z.length!==0&&_W.test(Z),B6,HW,wZ,zW,yQ,gQ=(Z,X)=>`'${Z}' was parsed as ${yQ[X]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,FW=(Z,X)=>X==="number"?GW(Z):HW(Z),BW=(Z,X)=>X==="number"?Number(Z):Number.parseInt(Z),MW=(Z,X)=>X==="number"?VW(Z):zW(Z),vQ=(Z,X)=>PZ(Z,"number",X),xQ=(Z,X)=>PZ(Z,"number",{...X,strict:!0}),hQ=(Z,X)=>PZ(Z,"integer",X),PZ=(Z,X,Q)=>{let U=BW(Z,X);if(!Number.isNaN(U)){if(MW(Z,X)){if(Q?.strict)return FW(Z,X)?U:M(gQ(Z,X));return U}}return Q?.errorOnFail?M(Q?.errorOnFail===!0?`Failed to parse ${yQ[X]} from '${Z}'`:Q?.errorOnFail):void 0},mQ=(Z)=>{if(Z[Z.length-1]!=="n")return;let X=Z.slice(0,-1),Q;try{Q=BigInt(X)}catch{return}if(B6.test(X))return Q;if(wZ.test(X))return M(gQ(Z,"bigint"))};var uQ=O(()=>{Q1();C4();WW=/^-0\.?0*$/.source,fQ=/[1-9]\d*/.source,$W=/\.\d+/.source,LW=/\.\d*[1-9]/.source,IQ=kQ({decimalPattern:LW,allowDecimalOnly:!1}),GW=IQ.test.bind(IQ),N4=kQ({decimalPattern:$W,allowDecimalOnly:!0}),FT=N4.test.bind(N4),_W=/^-?\d*\.?\d*$/,B6=DZ(B1.negativeLookahead("^-0$")+"-?"+B1.nonCapturingGroup(B1.nonCapturingGroup("0|"+fQ))),HW=B6.test.bind(B6),wZ=/^-?\d+$/,zW=wZ.test.bind(wZ),yQ={number:"a number",bigint:"a bigint",integer:"an integer"}});var OW="0.56.0",RW,X2,pQ,AZ,M6=(Z)=>{let X=pQ.get(Z);if(X)return X;let Q=KW(Z);if(AZ[Q])Q=`${Q}${AZ[Q]++}`;else AZ[Q]=1;return X2[Q]=Z,pQ.set(Z,Q),Q},C1=(Z)=>/^[$A-Z_a-z][\w$]*$/.test(Z),KW=(Z)=>{switch(typeof Z){case"object":{if(Z===null)break;let X=V6(Z)??"object";return X[0].toLowerCase()+X.slice(1)}case"function":return C1(Z.name)?Z.name:"fn";case"symbol":return Z.description&&C1(Z.description)?Z.description:"symbol"}return u(`Unexpected attempt to register serializable value of type ${$0(Z)}`)};var j4=O(()=>{F2();Q1();TZ();F6();RW={version:OW,filename:NQ.fileName(),FileConstructor:OZ},X2=RW,pQ=new Map,AZ=Object.create(null)});var O6=(Z)=>typeof Z==="string"?JSON.stringify(Z):typeof Z==="bigint"?`${Z}n`:`${Z}`;var lQ=(Z,X={})=>R6(Z,{onUndefined:"$ark.undefined",onBigInt:(Q)=>`$ark.bigint-${Q}`,...X},[]),y=(Z,X)=>{switch($0(Z)){case"object":let Q=Z,U=Q.constructor?.name??"Object";return U==="Object"||U==="Array"?X?.quoteKeys===!1?E4(Q,X?.indent??0,""):JSON.stringify(R6(Q,O2,[]),null,X?.indent):E4(Q,X?.indent??0,"");case"symbol":return O2.onSymbol(Z);default:return O6(Z)}},E4=(Z,X,Q)=>{if(typeof Z==="function")return O2.onFunction(Z);if(typeof Z!=="object"||Z===null)return O6(Z);let U=Q+" ".repeat(X);if(Array.isArray(Z)){if(Z.length===0)return"[]";let q=Z.map((Y)=>E4(Y,X,U)).join(`,
7
+ `+U);return X?`[
8
+ ${U}${q}
9
+ ${Q}]`:`[${q}]`}let J=Z.constructor?.name??"Object";if(J==="Object"){let q=t1(Z).map(([Y,W])=>{let $=typeof Y==="symbol"?O2.onSymbol(Y):C1(Y)?Y:JSON.stringify(Y),L=E4(W,X,U);return`${U}${$}: ${L}`});if(q.length===0)return"{}";return X?`{
10
+ ${q.join(`,
11
+ `)}
12
+ ${Q}}`:`{${q.join(", ")}}`}if(Z instanceof Date)return Q2(Z);if("expression"in Z&&typeof Z.expression==="string")return Z.expression;return J},O2,R6=(Z,X,Q)=>{switch($0(Z)){case"object":{let U=Z;if("toJSON"in U&&typeof U.toJSON==="function")return U.toJSON();if(typeof U==="function")return O2.onFunction(U);if(Q.includes(U))return"(cycle)";let J=[...Q,U];if(Array.isArray(U))return U.map((Y)=>R6(Y,X,J));if(U instanceof Date)return U.toDateString();let q={};for(let Y in U)q[Y]=R6(U[Y],X,J);for(let Y of Object.getOwnPropertySymbols(U))q[X.onSymbol?.(Y)??Y.toString()]=R6(U[Y],X,J);return q}case"symbol":return O2.onSymbol(Z);case"bigint":return X.onBigInt?.(Z)??`${Z}n`;case"undefined":return X.onUndefined??"undefined";case"string":return Z.replace(/\\/g,"\\\\");default:return Z}},Q2=(Z)=>{let X=Z.getFullYear(),Q=Z.getMonth(),U=Z.getDate(),J=Z.getHours(),q=Z.getMinutes(),Y=Z.getSeconds(),W=Z.getMilliseconds();if(Q===0&&U===1&&J===0&&q===0&&Y===0&&W===0)return`${X}`;let $=`${TW[Q]} ${U}, ${X}`;if(J===0&&q===0&&Y===0&&W===0)return $;let L=Z.toLocaleTimeString(),_=L.endsWith(" AM")||L.endsWith(" PM")?L.slice(-3):"";if(_)L=L.slice(0,-_.length);if(W)L+=`.${wW(W,3)}`;else if(DW.test(L))L=L.slice(0,-3);return`${L+_}, ${$}`},TW,DW,wW=(Z,X)=>String(Z).padStart(X,"0");var SZ=O(()=>{F2();M2();j4();O2={onCycle:()=>"(cycle)",onSymbol:(Z)=>`Symbol(${M6(Z)})`,onFunction:(Z)=>`Function(${M6(Z)})`},TW=["January","February","March","April","May","June","July","August","September","October","November","December"],DW=/:\d\d:00$/});var dQ=(Z,X,...[Q])=>{let U=Q?.stringifySymbol??y,J=Z;switch(typeof X){case"string":J=C1(X)?Z===""?X:`${Z}.${X}`:`${Z}[${JSON.stringify(X)}]`;break;case"number":J=`${Z}[${X}]`;break;case"symbol":J=`${Z}[${U(X)}]`;break;default:if(Q?.stringifyNonKey)J=`${Z}[${Q.stringifyNonKey(X)}]`;else M(`${y(X)} must be a PropertyKey or stringifyNonKey must be passed to options`)}return J},M1=(Z,...X)=>Z.reduce((Q,U)=>dQ(Q,U,...X),""),K6;var cQ=O(()=>{A4();Q1();j4();SZ();K6=class K6 extends P4{cache={};constructor(...Z){super();this.push(...Z)}toJSON(){if(this.cache.json)return this.cache.json;this.cache.json=[];for(let Z=0;Z<this.length;Z++)this.cache.json.push(typeof this[Z]==="symbol"?y(this[Z]):this[Z]);return this.cache.json}stringify(){if(this.cache.stringify)return this.cache.stringify;return this.cache.stringify=M1(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let Z="",X=[Z];for(let Q of this)Z=dQ(Z,Q),X.push(Z);return this.cache.stringifyAncestors=X}}});class T6{chars;i;def;constructor(Z){this.def=Z,this.chars=[...Z],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(Z){let X="";while(this.lookahead)if(Z(this,X))break;else X+=this.shift();return X}shiftUntilEscapable(Z){let X="";while(this.lookahead)if(this.lookahead===Z2)if(this.shift(),Z(this,X))X+=this.shift();else if(this.lookahead===Z2)X+=this.shift();else X+=`${Z2}${this.shift()}`;else if(Z(this,X))break;else X+=this.shift();return X}shiftUntilLookahead(Z){return typeof Z==="string"?this.shiftUntil((X)=>X.lookahead===Z):this.shiftUntil((X)=>(X.lookahead in Z))}shiftUntilNonWhitespace(){return this.shiftUntil(()=>!(this.lookahead in S1))}jumpToIndex(Z){this.i=Z<0?this.length+Z:Z}jumpForward(Z){this.i+=Z}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(Z,X){return this.chars.slice(Z,X).join("")}lookaheadIs(Z){return this.lookahead===Z}lookaheadIsIn(Z){return this.lookahead in Z}}var iQ=(Z,X)=>`Unmatched ${Z}${X===""?"":` before ${X}`}`,b4=(Z)=>`Missing ${Z}`;var sQ=O(()=>{C4()});var mT;var aQ=O(()=>{F2();Q1();F6();M2();mT=s0("implementedTraits")});var rQ=()=>{};var E=O(()=>{A4();RQ();KQ();F2();Q1();zZ();wQ();AQ();SQ();CQ();TZ();jQ();uQ();F6();cQ();M2();j4();sQ();SZ();C4();aQ();rQ()});var CZ="$ark",PW=2,oQ,R,AW=(Z)=>`${oQ}.${Z}`,Z0=(Z)=>AW(M6(Z));var p=O(()=>{E();while(CZ in globalThis)CZ=`$ark${PW++}`;oQ=CZ;globalThis[oQ]=X2;R=X2});var I4,a0=(Z)=>w0(Z,"object")||typeof Z==="symbol"?Z0(Z):O6(Z),NZ=(Z,X=!1)=>{if(typeof Z==="string"&&C1(Z))return`${X?"?":""}.${Z}`;return nQ(SW(Z),X)},SW=(Z)=>typeof Z==="symbol"?Z0(Z):JSON.stringify(Z),nQ=(Z,X=!1)=>`${X?"?.":""}[${Z}]`,D6;var N1=O(()=>{E();p();I4=class I4 extends _6{argNames;body="";constructor(...Z){super();this.argNames=Z;for(let X of Z){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(Z,X=!1){return NZ(Z,X)}index(Z,X=!1){return nQ(`${Z}`,X)}line(Z){return this.body+=`${" ".repeat(this.indentation)}${Z}
13
+ `,this}const(Z,X){return this.line(`const ${Z} = ${X}`),this}let(Z,X){return this.line(`let ${Z} = ${X}`)}set(Z,X){return this.line(`${Z} = ${X}`)}if(Z,X){return this.block(`if (${Z})`,X)}elseIf(Z,X){return this.block(`else if (${Z})`,X)}else(Z){return this.block("else",Z)}for(Z,X,Q=0){return this.block(`for (let i = ${Q}; ${Z}; i++)`,X)}forIn(Z,X){return this.block(`for (const k in ${Z})`,X)}block(Z,X,Q=""){return this.line(`${Z} {`),this.indent(),X(this),this.dedent(),this.line(`}${Q}`)}return(Z=""){return this.line(`return ${Z}`)}write(Z="anonymous",X=0){return`${Z}(${this.argNames.join(", ")}) { ${X?this.body.split(`
14
+ `).map((Q)=>" ".repeat(X)+`${Q}`).join(`
15
+ `):this.body} }`}compile(){return new TQ(...this.argNames,this.body)}};D6=class D6 extends I4{traversalKind;optimistic;constructor(Z){super("data","ctx");this.traversalKind=Z.kind,this.optimistic=Z.optimistic===!0}invoke(Z,X){let Q=X?.arg??this.data,U=typeof Z==="string"?!0:this.requiresContextFor(Z),J=typeof Z==="string"?Z:Z.id;if(U)return`${this.referenceToId(J,X)}(${Q}, ${this.ctx})`;return`${this.referenceToId(J,X)}(${Q})`}referenceToId(Z,X){let Q=X?.kind??this.traversalKind,U=`this.${Z}${Q}`;return X?.bind?`${U}.bind(${X?.bind})`:U}requiresContextFor(Z){return this.traversalKind==="Apply"||Z.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(Z,X,Q){let U=this.requiresContextFor(Q);if(U)this.line(`${this.ctx}.path.push(${Z})`);if(this.check(Q,{arg:X}),U)this.line(`${this.ctx}.path.pop()`);return this}check(Z,X){return this.traversalKind==="Allows"?this.if(`!${this.invoke(Z,X)}`,()=>this.return(!1)):this.line(this.invoke(Z,X))}}});var f4=(Z)=>k(Z,(X,Q)=>[X,r(Q)?[...Q]:Q]),O0,b=(Z,X)=>Z?.[O0]===X,o=(Z)=>b(Z,"root")||b(Z,"constraint");var J0=O(()=>{E();O0=s0("arkKind")});var tQ,R2,jZ,EZ,k4,K2,CW,y4,eQ,Z5,T2=(Z)=>typeof Z==="string"&&(Z in Z5),D2=(Z)=>Z5[Z],g4=(Z)=>K2.slice(D2(Z)+1),wD,PD,v0=(Z)=>{if(typeof Z==="string"||typeof Z==="boolean"||Z===null)return Z;if(typeof Z==="number"){if(Number.isNaN(Z))return"NaN";if(Z===Number.POSITIVE_INFINITY)return"Infinity";if(Z===Number.NEGATIVE_INFINITY)return"-Infinity";return Z}return a0(Z)},j1=(Z)=>{let X="{ ";for(let[Q,U]of Object.entries(Z))X+=`${Q}: ${a0(U)}, `;return X+" }"},g=(Z)=>{let X=Z;if(X.hasAssociatedError)X.defaults.expected??=(Q)=>("description"in Q)?Q.description:X.defaults.description(Q),X.defaults.actual??=(Q)=>y(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 U=`${Q.propString} ${Q.problem}`;if(U[0]==="[")return`value at ${U}`;return U};return X};var d=O(()=>{E();N1();J0();tQ=["unit","proto","domain"],R2=["required","optional","index","sequence"],jZ=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],EZ=[...jZ,"structure","predicate"],k4=[...EZ,...R2],K2=["alias","union","morph","unit","intersection","proto","domain"],CW=[...K2,...k4],y4=k(k4,(Z,X)=>[X,1]),eQ=k([...R2,"undeclared"],(Z,X)=>[X,1]),Z5=k(CW,(Z,X)=>[X,Z]),wD=[...g4("union"),"alias"],PD=[...g4("morph"),"alias"]});var X5,NW,t;var E1=O(()=>{E();X5=class X5 extends Error{name="ToJsonSchemaError";code;context;constructor(Z,X){super(y(X,{quoteKeys:!1,indent:4}));this.code=Z,this.context=X}hasCode(Z){return this.code===Z}};NW={target:"draft-2020-12",dialect:"https://json-schema.org/draft/2020-12/schema",useRefs:!1,fallback:{arrayObject:(Z)=>t.throw("arrayObject",Z),arrayPostfix:(Z)=>t.throw("arrayPostfix",Z),defaultValue:(Z)=>t.throw("defaultValue",Z),domain:(Z)=>t.throw("domain",Z),morph:(Z)=>t.throw("morph",Z),patternIntersection:(Z)=>t.throw("patternIntersection",Z),predicate:(Z)=>t.throw("predicate",Z),proto:(Z)=>t.throw("proto",Z),symbolKey:(Z)=>t.throw("symbolKey",Z),unit:(Z)=>t.throw("unit",Z),date:(Z)=>t.throw("date",Z)}},t={Error:X5,throw:(...Z)=>{throw new t.Error(...Z)},throwInternalOperandError:(Z,X)=>u(`Unexpected JSON Schema input for ${Z}: ${y(X)}`),defaultConfig:NW}});var w6=(Z,X)=>{if(!X)return Z;let Q={...Z},U;for(U in X){let J={...Z.keywords};if(U==="keywords"){for(let q in X[U]){let Y=X.keywords[q];if(Y===void 0)continue;J[q]=typeof Y==="string"?{description:Y}:Y}Q.keywords=J}else if(U==="toJsonSchema")Q[U]=bZ(Z.toJsonSchema,X.toJsonSchema);else if(T2(U))Q[U]={...Z[U],...X[U]};else Q[U]=X[U]}return Q},jW,bZ=(Z,X)=>{if(!Z)return Q5(X??{},void 0);if(!X)return Z;let Q={...Z},U;for(U in X)if(U==="fallback")Q.fallback=EW(Z.fallback,X.fallback);else Q[U]=X[U];return Q5(Q,X)},Q5=(Z,X)=>{if(X?.dialect!==void 0)return Z;if(X?.target!==void 0)return{...Z,dialect:jW[X.target]};return Z},EW=(Z,X)=>{Z=U5(Z),X=U5(X);let Q={},U;for(U in t.defaultConfig.fallback)Q[U]=X[U]??X.default??Z[U]??Z.default??t.defaultConfig.fallback[U];return Q},U5=(Z)=>typeof Z==="function"?{default:Z}:Z??{};var w2=O(()=>{d();p();E1();R.config??={};jW={"draft-2020-12":"https://json-schema.org/draft/2020-12/schema","draft-07":"http://json-schema.org/draft-07/schema#"}});var b1,C0,IZ,bW=(Z)=>Z.toString().split(`
16
+ `).join(`
17
+ `);var P6=O(()=>{E();J0();b1=class b1 extends _6{[O0]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:Z,relativePath:X,...Q},U){super();this.input=Q,this.ctx=U,HQ(this,Q);let J=U.data;if(Q.code==="union")Q.errors=Q.errors.flatMap((Y)=>{let W=Y.hasCode("union")?Y.errors:[Y];if(!Z&&!X)return W;return W.map(($)=>$.transform((L)=>({...L,path:WQ(Z,L.path,X)})))});this.nodeConfig=U.config[this.code];let q=[...Q.path??U.path];if(X)q.push(...X);if(Z)q.unshift(...Z);this.path=new K6(...q),this.data="data"in Q?Q.data:J}transform(Z){return new b1(Z({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode(Z){return this.code===Z}get propString(){return M1(this.path)}get expected(){if(this.input.expected)return this.input.expected;let Z=this.meta?.expected??this.nodeConfig.expected;return typeof Z==="function"?Z(this.input):Z}get actual(){if(this.input.actual)return this.input.actual;let Z=this.meta?.actual??this.nodeConfig.actual;return typeof Z==="function"?Z(this.data):Z}get problem(){if(this.input.problem)return this.input.problem;let Z=this.meta?.problem??this.nodeConfig.problem;return typeof Z==="function"?Z(this):Z}get message(){if(this.input.message)return this.input.message;let Z=this.meta?.message??this.nodeConfig.message;return typeof Z==="function"?Z(this):Z}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}};C0=class C0 extends P4{[O0]="errors";ctx;constructor(Z){super();this.ctx=Z}byPath=Object.create(null);get flatByPath(){return k(this.byPath,(Z,X)=>[Z,X.flat])}get flatProblemsByPath(){return k(this.byPath,(Z,X)=>[Z,X.flat.map((Q)=>Q.problem)])}byAncestorPath=Object.create(null);count=0;mutable=this;throw(){throw this.toTraversalError()}toTraversalError(){return new IZ(this)}add(Z){let X=this.byPath[Z.propString];if(X){if(Z===X)return;if(X.hasCode("union")&&X.errors.length===0)return;let Q=Z.hasCode("union")&&Z.errors.length===0?Z:new b1({code:"intersection",errors:X.hasCode("intersection")?[...X.errors,Z]:[X,Z]},this.ctx),U=this.indexOf(X);this.mutable[U===-1?this.length:U]=Q,this.byPath[Z.propString]=Q,this.addAncestorPaths(Z)}else this.byPath[Z.propString]=Z,this.addAncestorPaths(Z),this.mutable.push(Z);this.count++}transform(Z){let X=new C0(this.ctx);for(let Q of this)X.add(Z(Q));return X}merge(Z){for(let X of Z)this.add(new b1({...X,path:[...this.ctx.path,...X.path]},this.ctx))}affectsPath(Z){if(this.length===0)return!1;return Z.stringifyAncestors().some((X)=>(X in this.byPath))||Z.stringify()in this.byAncestorPath}get summary(){return this.toString()}get issues(){return this}toJSON(){return[...this.map((Z)=>Z.toJSON())]}toString(){return this.join(`
18
+ `)}addAncestorPaths(Z){for(let X of Z.path.stringifyAncestors())this.byAncestorPath[X]=m(this.byAncestorPath[X],Z)}};IZ=class IZ extends Error{name="TraversalError";constructor(Z){if(Z.length===1)super(Z.summary);else super(`
19
+ `+Z.map((X)=>` • ${bW(X)}`).join(`
20
+ `));Object.defineProperty(this,"arkErrors",{value:Z,enumerable:!1})}}});class r0{path=[];errors=new C0(this);root;config;queuedMorphs=[];branches=[];seen={};constructor(Z,X){this.root=Z,this.config=X}get data(){let Z=this.root;for(let X of this.path)Z=Z?.[X];return Z}get propString(){return M1(this.path)}reject(Z){return this.error(Z),!1}mustBe(Z){return this.error(Z),!1}error(Z){let X=typeof Z==="object"?Z.code?Z:{...Z,code:"predicate"}:{code:"predicate",expected:Z};return this.errorFromContext(X)}hasError(){return this.currentErrorCount!==0}get currentBranch(){return this.branches[this.branches.length-1]}queueMorphs(Z){let X={path:new K6(...this.path),morphs:Z};if(this.currentBranch)this.currentBranch.queuedMorphs.push(X);else this.queuedMorphs.push(X)}finalize(Z){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 Z?Z(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(Z){return this.errorFromContext(Z)}errorFromContext(Z){let X=new b1(Z,this);if(this.currentBranch)this.currentBranch.error=X;else this.errors.add(X);return X}applyQueuedMorphs(){while(this.queuedMorphs.length){let Z=this.queuedMorphs;this.queuedMorphs=[];for(let{path:X,morphs:Q}of Z){if(this.errors.affectsPath(X))continue;this.applyMorphsAtPath(X,Q)}}}applyMorphsAtPath(Z,X){let Q=Z[Z.length-1],U;if(Q!==void 0){U=this.root;for(let J=0;J<Z.length-1;J++)U=U[Z[J]]}for(let J of X){this.path=[...Z];let q=o(J),Y=J(U===void 0?this.root:U[Q],this);if(Y instanceof b1){if(!this.errors.includes(Y))this.errors.add(Y);break}if(Y instanceof C0){if(!q)this.errors.merge(Y);this.queuedMorphs=[];break}if(U===void 0)this.root=Y;else U[Q]=Y;this.applyQueuedMorphs()}}}var N0=(Z,X,Q)=>{if(!Q)return X();Q.path.push(Z);let U=X();return Q.path.pop(),U};var J1=O(()=>{E();P6();J0()});var S6,A6,J5=(Z,X)=>`${Z} had no references matching ${y(X)}.`,IW=(Z)=>M1(Z,{stringifyNonKey:(X)=>X.expression}),fW,kW=(Z)=>JSON.stringify(Z).replace(fW,"$1"),o0=(Z,X)=>({path:Z,node:X,propString:IW(Z)}),q5=(Z,X)=>Z.propString===X.propString&&Z.node.equals(X.node),fZ=(Z,X)=>X1(Z,X,{isEqual:q5}),yW=(Z,X)=>X1(Z,X,{isEqual:(Q,U)=>Q.equals(U)});var U2=O(()=>{E();d();p();J1();J0();S6=class S6 extends S0{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor(Z,X){super((U,J,q=this.onFail)=>{if(J)return this.traverseApply(U,J),J.hasError()?J.errors:J.data;return this.rootApply(U,q)},{attach:Z});this.attachments=Z,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((U,J)=>yW(U,J.shallowReferences),[this]);let Q=this.isStructural();this.flatRefs=[],this.flatMorphs=[];for(let U=0;U<this.children.length;U++){if(this.includesTransform||=this.children[U].includesTransform,this.includesContextualPredicate||=this.children[U].includesContextualPredicate,this.isCyclic||=this.children[U].isCyclic,!Q){let J=this.children[U].flatRefs;for(let q=0;q<J.length;q++){let Y=J[q];if(!this.flatRefs.some((W)=>q5(W,Y))){this.flatRefs.push(Y);for(let W of Y.node.branches)if(W.hasKind("morph")||W.hasKind("intersection")&&W.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:Y.path,propString:Y.propString,node:W})}}}Object.assign(this.referencesById,this.children[U].referencesById)}this.flatRefs.sort((U,J)=>U.path.length>J.path.length?1:U.path.length<J.path.length?-1:U.propString>J.propString?1:U.propString<J.propString?-1:U.node.expression<J.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((U)=>U.length===1||U.name==="$arkStructuralMorph")?this.hasKind("union")?this.branches.some((U)=>U.shallowMorphs.length>1)?"contextual":"branchedOptimistic":this.shallowMorphs.length>1?"contextual":"optimistic":"contextual":"contextual",this.rootApply=this.createRootApply(),this.allows=this.allowsRequiresContext?(U)=>this.traverseAllows(U,new r0(U,this.$.resolvedConfig)):(U)=>this.traverseAllows(U)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(X,Q)=>{if(this.allows(X))return X;let U=new r0(X,this.$.resolvedConfig);return this.traverseApply(X,U),U.finalize(Q)};case"contextual":return(X,Q)=>{let U=new r0(X,this.$.resolvedConfig);return this.traverseApply(X,U),U.finalize(Q)};case"optimistic":this.contextFreeMorph=this.shallowMorphs[0];let Z=this.$.resolvedConfig.clone;return(X,Q)=>{if(this.allows(X))return this.contextFreeMorph(Z&&(typeof X==="object"&&X!==null||typeof X==="function")?Z(X):X);let U=new r0(X,this.$.resolvedConfig);return this.traverseApply(X,U),U.finalize(Q)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,u(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=kW(this.metaJson);cacheGetter(Z,X){return Object.defineProperty(this,Z,{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=D2(this.kind);precompilation;assert=(Z,X)=>this(Z,X,(Q)=>Q.throw());traverse(Z,X){return this(Z,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(Z){if(!this.includesTransform)return this;let X={};for(let[Q,U]of this.innerEntries){let J=this.impl.keys[Q];if(J.reduceIo)J.reduceIo(Z,X,U);else if(J.child){let q=U;X[Q]=r(q)?q.map((Y)=>Z==="in"?Y.rawIn:Y.rawOut):Z==="in"?q.rawIn:q.rawOut}else X[Q]=U}return this.$.node(this.kind,X)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals(Z){let X=o(Z)?Z:this.$.parseDefinition(Z);return this.innerHash===X.innerHash}ifEquals(Z){return this.equals(Z)?this:void 0}hasKind(Z){return this.kind===Z}assertHasKind(Z){if(this.kind!==Z)n1(`${this.kind} node was not of asserted kind ${Z}`);return this}hasKindIn(...Z){return Z.includes(this.kind)}assertHasKindIn(...Z){if(!g0(Z,this.kind))n1(`${this.kind} node was not one of asserted kinds ${Z}`);return this}isBasis(){return g0(tQ,this.kind)}isConstraint(){return g0(k4,this.kind)}isStructural(){return g0(R2,this.kind)}isRefinement(){return g0(EZ,this.kind)}isRoot(){return g0(K2,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit(Z){return this.hasKind("unit")&&this.allows(Z)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select(Z){let X=A6.normalize(Z);return this._select(X)}_select(Z){let X=A6.applyBoundary[Z.boundary??"references"](this);if(Z.kind)X=X.filter((Q)=>Q.kind===Z.kind);if(Z.where)X=X.filter(Z.where);return A6.applyMethod[Z.method??"filter"](X,this,Z)}transform(Z,X){return this._transform(Z,this._createTransformContext(X))}_createTransformContext(Z){return{root:this,selected:void 0,seen:{},path:[],parseOptions:{prereduced:Z?.prereduced??!1},undeclaredKeyHandling:void 0,...Z}}_transform(Z,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 U;if(X.seen[this.id]=()=>U,this.hasKind("structure")&&this.undeclared!==X.undeclaredKeyHandling)X={...X,undeclaredKeyHandling:this.undeclared};let J=k(this.inner,(L,_)=>{if(!this.impl.keys[L].child)return[L,_];let G=_;if(!r(G)){let z=G._transform(Z,X);return z?[L,z]:[]}if(G.length===0)return[L,_];let V=G.flatMap((z)=>{return z._transform(Z,X)??[]});return V.length?[L,V]:[]});delete X.seen[this.id];let q=Object.assign(J,{meta:this.meta}),Y=X.selected&&!X.selected.includes(this)?q:Z(this.kind,q,X);if(Y===null)return null;if(o(Y))return U=Y;let W=Object.keys(Y);if((W.length===0||W.length===1&&W[0]==="meta")&&!U1(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in Y))return X.undeclaredKeyHandling?{...Y,value:R.intrinsic.unknown}:null;if(this.kind==="morph")Y.in??=R.intrinsic.unknown;return U=Q.node(this.kind,Y,X.parseOptions)}configureReferences(Z,X="references"){let Q=A6.normalize(X),U=typeof Z==="string"?(W,$)=>({...$,meta:{...$.meta,description:Z}}):typeof Z==="function"?(W,$)=>({...$,meta:Z($.meta)}):(W,$)=>({...$,meta:{...$.meta,...Z}});if(Q.boundary==="self")return this.$.node(this.kind,U(this.kind,{...this.inner,meta:this.meta}));let J=this._select(Q),q=J&&P1(J),Y=Q.boundary==="child"?(W,$)=>$.root.children.includes(W):Q.boundary==="shallow"?(W)=>W.kind!=="structure":()=>!0;return this.$.finalize(this.transform(U,{shouldTransform:Y,selected:q}))}};A6={applyBoundary:{self:(Z)=>[Z],child:(Z)=>[...Z.children],shallow:(Z)=>[...Z.shallowReferences],references:(Z)=>[...Z.references]},applyMethod:{filter:(Z)=>Z,assertFilter:(Z,X,Q)=>{if(Z.length===0)n1(J5(X,Q));return Z},find:(Z)=>Z[0],assertFind:(Z,X,Q)=>{if(Z.length===0)n1(J5(X,Q));return Z[0]}},normalize:(Z)=>typeof Z==="function"?{boundary:"references",method:"filter",where:Z}:typeof Z==="string"?L0(Z,A6.applyBoundary)?{method:"filter",boundary:Z}:{boundary:"references",method:"filter",kind:Z}:{boundary:"references",method:"filter",...Z}},fW=/"(\$ark\.[^"]+)"/g});var A,Y5=(Z,X)=>`${kZ(Z)} and ${kZ(X)}`,kZ=(Z)=>o(Z)?Z.expression:r(Z)?Z.map(kZ).join(" | ")||"never":String(Z),yZ=(Z)=>`${Z} results in an unsatisfiable type`;var U0=O(()=>{E();p();J0();A=class A extends Array{static init(Z,X,Q,U){return new A({kind:Z,l:X,r:Q,path:U?.path??[],optional:U?.optional??!1})}add(Z,X,Q,U){return this.push({kind:Z,l:X,r:Q,path:U?.path??[],optional:U?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:Z,l:X,r:Q}=this[0],U=M1(Z);return yZ(`Intersection${U&&` at ${U}`} of ${Y5(X,Q)}`)}return`The following intersections result in unsatisfiable types:
21
+ • ${this.map(({path:Z,l:X,r:Q})=>`${Z}: ${Y5(X,Q)}`).join(`
22
+ • `)}`}throw(){return M(this.describeReasons())}invert(){let Z=this.map((X)=>({...X,l:X.r,r:X.l}));if(!(Z instanceof A))return new A(...Z);return Z}withPrefixKey(Z,X){return this.map((Q)=>({...Q,path:[Z,...Q.path],optional:Q.optional||X==="optional"}))}toNeverIfDisjoint(){return R.intrinsic.never}}});var P2,j0=(Z,X,Q)=>n(Z,X,{$:Q,invert:!1,pipe:!1}),C6=(Z,X,Q)=>n(Z,X,{$:Q,invert:!1,pipe:!0}),n=(Z,X,Q)=>{let U=Q.pipe?"|>":"&",J=`${Z.hash}${U}${X.hash}`;if(P2[J]!==void 0)return P2[J];if(!Q.pipe){let W=`${X.hash}${U}${Z.hash}`;if(P2[W]!==void 0){let $=P2[W],L=$ instanceof A?$.invert():$;return P2[J]=L,L}}let q=!Q.pipe||!Z.includesTransform&&!X.includesTransform;if(q&&Z.equals(X))return Z;let Y=q?gZ(Z,X,Q):Z.hasKindIn(...K2)?gW(Z,X,Q):gZ(Z,X,Q);if(o(Y)){if(Z.equals(Y))Y=Z;else if(X.equals(Y))Y=X}return P2[J]=Y,Y},gZ=(Z,X,Q)=>{let U=Z.precedence<X.precedence?Z.kind:X.kind,J=Z.impl.intersections[X.kind]??X.impl.intersections[Z.kind];if(J===void 0)return null;else if(U===Z.kind)return J(Z,X,Q);else{let q=J(X,Z,{...Q,invert:!Q.invert});if(q instanceof A)q=q.invert();return q}},gW=(Z,X,Q)=>Z.includesTransform||X.includesTransform?Q.invert?W5(X,Z,Q):W5(Z,X,Q):gZ(Z,X,Q),W5=(Z,X,Q)=>Z.distribute((U)=>vW(U,X,Q),(U)=>{let J=U.filter(o);if(J.length===0)return A.init("union",Z.branches,X.branches);if(J.length<Z.branches.length||!Z.branches.every((W,$)=>W.rawIn.equals(J[$].rawIn)))return Q.$.parseSchema(J);let q;if(J.length===1){let W=J[0];if(!q)return W;return Q.$.node("morph",{...W.inner,in:W.rawIn.configure(q,"self")})}let Y={branches:J};if(q)Y.meta=q;return Q.$.parseSchema(Y)}),vW=(Z,X,Q)=>{if(Z.hasKind("morph")){let J=[...Z.morphs];if(Z.lastMorphIfNode){let q=n(Z.lastMorphIfNode,X,Q);if(q instanceof A)return q;J[J.length-1]=q}else J.push(X);return Q.$.node("morph",{morphs:J,in:Z.inner.in})}if(X.hasKind("morph")){let J=n(Z,X.rawIn,Q);if(J instanceof A)return J;return Q.$.node("morph",{morphs:[X],in:J})}return Q.$.node("morph",{morphs:[X],in:Z})};var x0=O(()=>{U0();d();J0();P2={}});var h0,O1,z0=(Z)=>(X,Q)=>{if(r(X)){if(X.length===0)return;let J=X.map((q)=>Q.$.node(Z,q));if(Z==="predicate")return J;return J.sort((q,Y)=>q.hash<Y.hash?-1:1)}let U=Q.$.node(Z,X);return U.hasOpenIntersection()?[U]:U},A2=(Z)=>{let X=Z.r.shift();if(!X){let U=Z.l.length===0&&Z.kind==="structure"?R.intrinsic.unknown.internal:Z.ctx.$.node(Z.kind,Object.assign(Z.baseInner,xW(Z.l)),{prereduced:!0});for(let J of Z.roots){if(U instanceof A)return U;U=n(J,U,Z.ctx)}return U}let Q=!1;for(let U=0;U<Z.l.length;U++){let J=n(Z.l[U],X,Z.ctx);if(J===null)continue;if(J instanceof A)return J;if(J.isRoot())return Z.roots.push(J),Z.l.splice(U),A2(Z);if(!Q)Z.l[U]=J,Q=!0;else if(!Z.l.includes(J))return u(`Unexpectedly encountered multiple distinct intersection results for refinement ${X}`)}if(!Q)Z.l.push(X);if(Z.kind==="intersection"){if(X.impliedSiblings)for(let U of X.impliedSiblings)X1(Z.r,U)}return A2(Z)},S2=(Z)=>{return Object.entries(Z).flatMap(([Q,U])=>(Q in y4)?U:[]).sort((Q,U)=>Q.precedence<U.precedence?-1:Q.precedence>U.precedence?1:Q.kind==="predicate"&&U.kind==="predicate"?0:Q.hash<U.hash?-1:1)},xW=(Z)=>{let X={};for(let Q of Z)if(Q.hasOpenIntersection())X[Q.kind]=m(X[Q.kind],Q);else{if(X[Q.kind])return u(`Unexpected intersection of closed refinements of kind ${Q.kind}`);X[Q.kind]=Q}return X},$5=(...Z)=>M(L5(...Z)),L5=(Z,X,Q)=>{let U=Q.hasKind("morph")?"a morph":Q.isUnknown()?"unknown":Q.exclude(X).defaultShortDescription;return`${EQ(Z)} operand must be ${X.description} (was ${U})`};var I0=O(()=>{E();U2();U0();d();x0();p();J0();h0=class h0 extends S6{constructor(Z,X){super(Z,X);Object.defineProperty(this,O0,{value:"constraint",enumerable:!1})}impliedSiblings;intersect(Z){return j0(this,Z,this.$)}};O1=class O1 extends h0{traverseApply=(Z,X)=>{if(!this.traverseAllows(Z,X))X.errorFromNodeContext(this.errorContext)};compile(Z){if(Z.traversalKind==="Allows")Z.return(this.compiledCondition);else Z.if(this.compiledNegation,()=>Z.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return j1(this.errorContext)}}});var G5=(Z,X,Q)=>new I1(Z,X,Q,Q,null),v4,I1,hW=(Z,X,Q)=>`${Z} must be assignable to ${X} (was ${Q})`;var vZ=O(()=>{E();p();J0();v4=class v4 extends S0{};I1=class I1 extends S0{[O0]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor(Z,X,Q,U,J){super((...q)=>{let Y=k(this.names,(W,$)=>{let L=this.arg$.parse(q[W]);if(!L.extends(this.constraints[W]))M(hW($,this.constraints[W].expression,L.expression));return[$,L]});if(this.defIsLazy()){let W=this.bodyDef(Y);return this.$.parse(W)}return this.$.parse(X,{args:Y})});this.paramDefs=Z,this.bodyDef=X,this.$=Q,this.arg$=U,this.hkt=J,this.description=J?new J().description??`a generic type for ${J.constructor.name}`:"a generic type",this.baseInstantiation=this(...this.constraints)}defIsLazy(){return this.bodyDef instanceof v4}cacheGetter(Z,X){return Object.defineProperty(this,Z,{value:X}),X}get json(){return this.cacheGetter("json",{params:this.params.map((Z)=>Z[1].isUnknown()?Z[0]:[Z[0],Z[1].json]),body:lQ(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map((Z)=>typeof Z==="string"?[Z,R.intrinsic.unknown]:[Z[0],this.$.parse(Z[1])]))}get names(){return this.cacheGetter("names",this.params.map((Z)=>Z[0]))}get constraints(){return this.cacheGetter("constraints",this.params.map((Z)=>Z[1]))}get internal(){return this}get referencesById(){return this.baseInstantiation.internal.referencesById}get references(){return this.baseInstantiation.internal.references}}});var mW,_5,xZ;var hZ=O(()=>{I0();d();p();mW=g({kind:"predicate",hasAssociatedError:!0,collapsibleKey:"predicate",keys:{predicate:{}},normalize:(Z)=>typeof Z==="function"?{predicate:Z}:Z,defaults:{description:(Z)=>`valid according to ${Z.predicate.name||"an anonymous predicate"}`},intersectionIsOpen:!0,intersections:{predicate:()=>null}});_5=class _5 extends h0{serializedPredicate=Z0(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=j1(this.errorContext);traverseApply=(Z,X)=>{let Q=X.currentErrorCount;if(!this.predicate(Z,X.external)&&X.currentErrorCount===Q)X.errorFromNodeContext(this.errorContext)};compile(Z){if(Z.traversalKind==="Allows"){Z.return(this.compiledCondition);return}Z.initializeErrorCount(),Z.if(`${this.compiledNegation} && ctx.currentErrorCount === errorCount`,()=>Z.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}reduceJsonSchema(Z,X){return X.fallback.predicate({code:"predicate",base:Z,predicate:this.predicate})}};xZ={implementation:mW,Node:_5}});var uW,V5,mZ,pW=(Z)=>`divisor must be an integer (was ${Z})`,lW=(Z,X)=>{let Q,U=Z,J=X;while(J!==0)Q=J,J=U%J,U=Q;return U};var uZ=O(()=>{E();I0();d();p();uW=g({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:(Z)=>Number.isInteger(Z)?Z:M(pW(Z))}},normalize:(Z)=>typeof Z==="number"?{rule:Z}:Z,hasAssociatedError:!0,defaults:{description:(Z)=>Z.rule===1?"an integer":Z.rule===2?"even":`a multiple of ${Z.rule}`},intersections:{divisor:(Z,X,Q)=>Q.$.node("divisor",{rule:Math.abs(Z.rule*X.rule/lW(Z.rule,X.rule))})},obviatesBasisDescription:!0});V5=class V5 extends O1{traverseAllows=(Z)=>Z%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=R.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema(Z){if(Z.type="integer",this.rule===1)return Z;return Z.multipleOf=this.rule,Z}};mZ={implementation:uW,Node:V5}});var f0,dW,cW,x4,h4=(Z)=>(X)=>{if(typeof X==="number")return{rule:X};let{exclusive:Q,...U}=X;return Q?{...U,rule:Z==="minLength"?U.rule+1:U.rule-1}:U},m4=(Z)=>(X)=>{if(typeof X==="number"||typeof X==="string"||X instanceof Date)return{rule:X};let{exclusive:Q,...U}=X;if(!Q)return U;let J=typeof U.rule==="number"?U.rule:typeof U.rule==="string"?new Date(U.rule).valueOf():U.rule.valueOf();return Q?{...U,rule:Z==="after"?J+1:J-1}:U},u4=(Z)=>typeof Z==="string"||typeof Z==="number"?new Date(Z):Z,iW=(Z,X)=>`${Z} bound must be a positive integer (was ${X})`,C2=(Z)=>(X)=>{if(!Number.isInteger(X)||X<0)M(iW(Z,X));return X},sW,aW=(Z,X)=>`${L0(Z,cW)?">":"<"}${X?"":"="}`,rW=(Z)=>typeof Z==="string"?Z:new Date(Z).toLocaleString(),H5=(Z)=>`Bounded expression ${Z} must be exactly one of number, string, Array, or Date`;var R1=O(()=>{E();I0();f0=class f0 extends O1{boundOperandKind=sW[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=aW(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${dW[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?rW(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan(Z){return(this.limitKind==="upper"?this.numericLimit<Z.numericLimit:this.numericLimit>Z.numericLimit)||this.numericLimit===Z.numericLimit&&this.exclusive===!0&&!Z.exclusive}overlapsRange(Z){if(this.isStricterThan(Z))return!1;if(this.numericLimit===Z.numericLimit&&(this.exclusive||Z.exclusive))return!1;return!0}overlapIsUnit(Z){return this.numericLimit===Z.numericLimit&&!this.exclusive&&!Z.exclusive}};dW={"<":">=","<=":">",">":"<=",">=":"<"},cW={min:"max",minLength:"maxLength",after:"before"},x4={parse:(Z)=>Z||void 0},sW={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"}});var oW,z5,pZ;var lZ=O(()=>{E();d();p();R1();oW=g({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:u4,serialize:(Z)=>Z.toISOString()}},normalize:m4("after"),defaults:{description:(Z)=>`${Z.collapsibleLimitString} or later`,actual:Q2},intersections:{after:(Z,X)=>Z.isStricterThan(X)?Z:X}});z5=class z5 extends f0{impliedBasis=R.intrinsic.Date.internal;collapsibleLimitString=Q2(this.rule);traverseAllows=(Z)=>Z>=this.rule;reduceJsonSchema(Z,X){return X.fallback.date({code:"date",base:Z,after:this.rule})}};pZ={implementation:oW,Node:z5}});var nW,F5,dZ;var cZ=O(()=>{E();U0();d();p();R1();nW=g({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:u4,serialize:(Z)=>Z.toISOString()}},normalize:m4("before"),defaults:{description:(Z)=>`${Z.collapsibleLimitString} or earlier`,actual:Q2},intersections:{before:(Z,X)=>Z.isStricterThan(X)?Z:X,after:(Z,X,Q)=>Z.overlapsRange(X)?Z.overlapIsUnit(X)?Q.$.node("unit",{unit:Z.rule}):null:A.init("range",Z,X)}});F5=class F5 extends f0{collapsibleLimitString=Q2(this.rule);traverseAllows=(Z)=>Z<=this.rule;impliedBasis=R.intrinsic.Date.internal;reduceJsonSchema(Z,X){return X.fallback.date({code:"date",base:Z,before:this.rule})}};dZ={implementation:nW,Node:F5}});var tW,B5,iZ;var sZ=O(()=>{I0();U0();d();p();E1();R1();tW=g({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:C2("exactLength")}},normalize:(Z)=>typeof Z==="number"?{rule:Z}:Z,hasAssociatedError:!0,defaults:{description:(Z)=>`exactly length ${Z.rule}`,actual:(Z)=>`${Z.length}`},intersections:{exactLength:(Z,X,Q)=>A.init("unit",Q.$.node("unit",{unit:Z.rule}),Q.$.node("unit",{unit:X.rule}),{path:["length"]}),minLength:(Z,X)=>Z.rule>=X.rule?Z:A.init("range",Z,X),maxLength:(Z,X)=>Z.rule<=X.rule?Z:A.init("range",Z,X)}});B5=class B5 extends O1{traverseAllows=(Z)=>Z.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=R.intrinsic.lengthBoundable.internal;expression=`== ${this.rule}`;reduceJsonSchema(Z){switch(Z.type){case"string":return Z.minLength=this.rule,Z.maxLength=this.rule,Z;case"array":return Z.minItems=this.rule,Z.maxItems=this.rule,Z;default:return t.throwInternalOperandError("exactLength",Z)}}};iZ={implementation:tW,Node:B5}});var eW,M5,aZ;var rZ=O(()=>{U0();d();p();R1();eW=g({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:x4},normalize:(Z)=>typeof Z==="number"?{rule:Z}:Z,defaults:{description:(Z)=>{if(Z.rule===0)return Z.exclusive?"negative":"non-positive";return`${Z.exclusive?"less than":"at most"} ${Z.rule}`}},intersections:{max:(Z,X)=>Z.isStricterThan(X)?Z:X,min:(Z,X,Q)=>Z.overlapsRange(X)?Z.overlapIsUnit(X)?Q.$.node("unit",{unit:Z.rule}):null:A.init("range",Z,X)},obviatesBasisDescription:!0});M5=class M5 extends f0{impliedBasis=R.intrinsic.number.internal;traverseAllows=this.exclusive?(Z)=>Z<this.rule:(Z)=>Z<=this.rule;reduceJsonSchema(Z){if(this.exclusive)Z.exclusiveMaximum=this.rule;else Z.maximum=this.rule;return Z}};aZ={implementation:eW,Node:M5}});var Z$,O5,oZ;var nZ=O(()=>{U0();d();p();E1();R1();Z$=g({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:C2("maxLength")}},reduce:(Z,X)=>Z.rule===0?X.node("exactLength",Z):void 0,normalize:h4("maxLength"),defaults:{description:(Z)=>`at most length ${Z.rule}`,actual:(Z)=>`${Z.length}`},intersections:{maxLength:(Z,X)=>Z.isStricterThan(X)?Z:X,minLength:(Z,X,Q)=>Z.overlapsRange(X)?Z.overlapIsUnit(X)?Q.$.node("exactLength",{rule:Z.rule}):null:A.init("range",Z,X)}});O5=class O5 extends f0{impliedBasis=R.intrinsic.lengthBoundable.internal;traverseAllows=(Z)=>Z.length<=this.rule;reduceJsonSchema(Z){switch(Z.type){case"string":return Z.maxLength=this.rule,Z;case"array":return Z.maxItems=this.rule,Z;default:return t.throwInternalOperandError("maxLength",Z)}}};oZ={implementation:Z$,Node:O5}});var X$,R5,tZ;var eZ=O(()=>{d();p();R1();X$=g({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:x4},normalize:(Z)=>typeof Z==="number"?{rule:Z}:Z,defaults:{description:(Z)=>{if(Z.rule===0)return Z.exclusive?"positive":"non-negative";return`${Z.exclusive?"more than":"at least"} ${Z.rule}`}},intersections:{min:(Z,X)=>Z.isStricterThan(X)?Z:X},obviatesBasisDescription:!0});R5=class R5 extends f0{impliedBasis=R.intrinsic.number.internal;traverseAllows=this.exclusive?(Z)=>Z>this.rule:(Z)=>Z>=this.rule;reduceJsonSchema(Z){if(this.exclusive)Z.exclusiveMinimum=this.rule;else Z.minimum=this.rule;return Z}};tZ={implementation:X$,Node:R5}});var Q$,K5,Z8;var X8=O(()=>{d();p();E1();R1();Q$=g({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:C2("minLength")}},reduce:(Z)=>Z.rule===0?R.intrinsic.unknown:void 0,normalize:h4("minLength"),defaults:{description:(Z)=>Z.rule===1?"non-empty":`at least length ${Z.rule}`,actual:(Z)=>Z.length===0?"":`${Z.length}`},intersections:{minLength:(Z,X)=>Z.isStricterThan(X)?Z:X}});K5=class K5 extends f0{impliedBasis=R.intrinsic.lengthBoundable.internal;traverseAllows=(Z)=>Z.length>=this.rule;reduceJsonSchema(Z){switch(Z.type){case"string":return Z.minLength=this.rule,Z;case"array":return Z.minItems=this.rule,Z;default:return t.throwInternalOperandError("minLength",Z)}}};Z8={implementation:Q$,Node:K5}});var T5,D5;var Q8=O(()=>{lZ();cZ();sZ();rZ();nZ();eZ();X8();T5={min:tZ.implementation,max:aZ.implementation,minLength:Z8.implementation,maxLength:oZ.implementation,exactLength:iZ.implementation,after:pZ.implementation,before:dZ.implementation},D5={min:tZ.Node,max:aZ.Node,minLength:Z8.Node,maxLength:oZ.Node,exactLength:iZ.Node,after:pZ.Node,before:dZ.Node}});var U$,w5,U8;var J8=O(()=>{I0();d();p();U$=g({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:(Z)=>typeof Z==="string"?{rule:Z}:Z instanceof RegExp?Z.flags?{rule:Z.source,flags:Z.flags}:{rule:Z.source}:Z,obviatesBasisDescription:!0,obviatesBasisExpression:!0,hasAssociatedError:!0,intersectionIsOpen:!0,defaults:{description:(Z)=>`matched by ${Z.rule}`},intersections:{pattern:()=>null}});w5=class w5 extends O1{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=R.intrinsic.string.internal;reduceJsonSchema(Z,X){if(Z.pattern)return X.fallback.patternIntersection({code:"patternIntersection",base:Z,pattern:this.rule});return Z.pattern=this.rule,Z}};U8={implementation:U$,Node:w5}});var N6=(Z,X)=>{let Q=J$(Z);if(X&&!X.includes(Q))return M(`Root of kind ${Q} should be one of ${X}`);return Q},J$=(Z)=>{if(b(Z,"root"))return Z.kind;if(typeof Z==="string")return Z[0]==="$"?"alias":(Z in P0)?"domain":"proto";if(typeof Z==="function")return"proto";if(typeof Z!=="object"||Z===null)return M(P5(Z));if("morphs"in Z)return"morph";if("branches"in Z||r(Z))return"union";if("unit"in Z)return"unit";if("reference"in Z)return"alias";let X=Object.keys(Z);if(X.length===0||X.some((Q)=>(Q in y4)))return"intersection";if("proto"in Z)return"proto";if("domain"in Z)return"domain";return M(P5(Z))},P5=(Z)=>`${y(Z)} is not a valid type schema`,A5,q$=(Z)=>r(Z)?Z.map((X)=>X.collapsibleJson):Z.collapsibleJson,R0,q8=(Z)=>{return A5[Z]??=0,`${Z}${++A5[Z]}`},Y8=(Z)=>{let X=N2[Z.kind],Q=X.applyConfig?.(Z.def,Z.$.resolvedConfig)??Z.def,U={},{meta:J,...q}=Q,Y=J===void 0?{}:typeof J==="string"?{description:J}:J,W=FZ(q).sort(([L],[_])=>T2(L)?T2(_)?D2(L)-D2(_):1:T2(_)?-1:L<_?-1:1).filter(([L,_])=>{if(L.startsWith("meta.")){let G=L.slice(5);return Y[G]=_,!1}return!0});for(let L of W){let _=L[0],G=X.keys[_];if(!G)return M(`Key ${_} is not valid on ${Z.kind} schema`);let V=G.parse?G.parse(L[1],Z):L[1];if(V!==A0&&(V!==void 0||G.preserveUndefined))U[_]=V}if(X.reduce&&!Z.prereduced){let L=X.reduce(U,Z.$);if(L){if(L instanceof A)return L.throw();return Y$(L,Y)}}return W8({id:Z.id,kind:Z.kind,inner:U,meta:Y,$:Z.$})},W8=({id:Z,kind:X,inner:Q,meta:U,$:J,ignoreCache:q})=>{let Y=N2[X],W=FZ(Q),$=[],L={};for(let[T,D]of W){let K=Y.keys[T],w=K.serialize??(K.child?q$:v0);if(L[T]=w(D),K.child===!0){let S=D;if(r(S))$.push(...S);else $.push(S)}else if(typeof K.child==="function")$.push(...K.child(D))}if(Y.finalizeInnerJson)L=Y.finalizeInnerJson(L);let _={...L},G={};if(!U1(U))G=k(U,(T,D)=>[T,T==="examples"?D:v0(D)]),_.meta=p4(G,"description",!0);L=p4(L,Y.collapsibleKey,!1);let V=JSON.stringify({kind:X,...L});_=p4(_,Y.collapsibleKey,!1);let z=p4(_,Y.collapsibleKey,!0),F=JSON.stringify({kind:X,..._});if(J.nodesByHash[F]&&!q)return J.nodesByHash[F];let H={id:Z,kind:X,impl:Y,inner:Q,innerEntries:W,innerJson:L,innerHash:V,meta:U,metaJson:G,json:_,hash:F,collapsibleJson:z,children:$};if(X!=="intersection"){for(let T in Q)if(T!=="in"&&T!=="out")H[T]=Q[T]}let B=new C5[X](H,J);return J.nodesByHash[F]=B},S5=(Z,X)=>{if(Z.id===X)return Z;if(o(R0[X]))u(`Unexpected attempt to overwrite node id ${X}`);return W8({id:X,kind:Z.kind,inner:Z.inner,meta:Z.meta,$:Z.$,ignoreCache:!0})},Y$=(Z,X,Q)=>{if(Q&&o(R0[Q]))u(`Unexpected attempt to overwrite node id ${Q}`);return W8({id:Q??q8(X.alias??Z.kind),kind:Z.kind,inner:Z.inner,meta:X,$:Z.$})},p4=(Z,X,Q)=>{let U=Object.keys(Z);if(U.length===1&&U[0]===X){let J=Z[X];if(Q)return J;if(w0(J,"object")&&(Object.keys(J).length===1||Array.isArray(J)))return J}return Z};var l4=O(()=>{E();d4();U0();d();p();J0();A5={},R0={};R.nodesByRegisteredId=R0});var j6=(Z,X,Q)=>{if(Z.key!==X.key)return null;let U=Z.key,J=n(Z.value,X.value,Q),q=Z.required||X.required?"required":"optional";if(J instanceof A)if(q==="optional")J=R.intrinsic.never.internal;else return J.withPrefixKey(Z.key,Z.required&&X.required?"required":"optional");if(q==="required")return Q.$.node("required",{key:U,value:J});let Y=Z.hasDefault()?X.hasDefault()?Z.default===X.default?Z.default:M($8(Z.default,X.default)):Z.default:X.hasDefault()?X.default:A0;return Q.$.node("optional",{key:U,value:J,default:Y})},E6,$8=(Z,X)=>`Invalid intersection of default values ${y(Z)} & ${y(X)}`;var b6=O(()=>{E();I0();U2();N1();U0();x0();p();J1();E6=class E6 extends h0{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=R.intrinsic.object.internal;serializedKey=a0(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=m(this.value.flatRefs.map((Z)=>o0([this.key,...Z.path],Z.node)),o0([this.key],this.value));_transform(Z,X){X.path.push(this.key);let Q=super._transform(Z,X);return X.path.pop(),Q}hasDefault(){return"default"in this.inner}traverseAllows=(Z,X)=>{if(this.key in Z)return N0(this.key,()=>this.value.traverseAllows(Z[this.key],X),X);return this.optional};traverseApply=(Z,X)=>{if(this.key in Z)N0(this.key,()=>this.value.traverseApply(Z[this.key],X),X);else if(this.hasKind("required"))X.errorFromNodeContext(this.errorContext)};compile(Z){if(Z.if(`${this.serializedKey} in data`,()=>Z.traverseKey(this.serializedKey,`data${Z.prop(this.key)}`,this.value)),this.hasKind("required"))Z.else(()=>Z.traversalKind==="Apply"?Z.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`):Z.return(!1));if(Z.traversalKind==="Allows")Z.return(!0)}}});var W$,N5,I6,$$,L$=(Z)=>{if(!Z.hasDefault())return;let X=`{${Z.compiledKey}: ${Z.value.id} = ${v0(Z.default)}}`;return $$[X]??=L8(Z.key,Z.value,Z.default)},L8=(Z,X,Q)=>{if(typeof Q==="function")return X.includesTransform?(J,q)=>{return N0(Z,()=>X(J[Z]=Q(),q),q),J}:(J)=>{return J[Z]=Q(),J};let U=X.includesTransform?X.assert(Q):Q;return w0(U,"object")?(J,q)=>{return N0(Z,()=>X(J[Z]=Q,q),q),J}:(J)=>{return J[Z]=U,J}},f6=(Z,X,Q)=>{let U=A1(X);if(w0(X,"object")&&!U)M(G$(Q));let J=Z.in(U?X():X);if(J instanceof C0){if(Q===null)M(`Default ${J.summary}`);let q=J.transform((Y)=>Y.transform((W)=>({...W,prefixPath:[Q]})));M(`Default for ${q.summary}`)}return X},G$=(Z)=>{return`Non-primitive default ${Z===null?"":typeof Z==="number"?`for value at [${Z}] `:`for ${a0(Z)} `}must be specified as a function like () => ({my: 'object'})`};var j2=O(()=>{E();c4();N1();P6();d();p();J1();b6();W$=g({kind:"optional",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(Z,X)=>X.$.parseSchema(Z)},default:{preserveUndefined:!0}},normalize:(Z)=>Z,reduce:(Z,X)=>{if(X.resolvedConfig.exactOptionalPropertyTypes===!1){if(!Z.value.allows(void 0))return X.node("optional",{...Z,value:Z.value.or(I.undefined)},{prereduced:!0})}},defaults:{description:(Z)=>`${Z.compiledKey}?: ${Z.value.description}`},intersections:{optional:j6}});N5=class N5 extends E6{constructor(...Z){super(...Z);if("default"in this.inner)f6(this.value,this.inner.default,this.key)}get rawIn(){let Z=super.rawIn;if(!this.hasDefault())return Z;return this.$.node("optional",S4(Z.inner,{default:!0}),{prereduced:!0})}get outProp(){if(!this.hasDefault())return this;let{default:Z,...X}=this.inner;return this.cacheGetter("outProp",this.$.node("required",X,{prereduced:!0}))}expression=this.hasDefault()?`${this.compiledKey}: ${this.value.expression} = ${y(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=L$(this);defaultValueMorphRef=this.defaultValueMorph&&Z0(this.defaultValueMorph)};I6={implementation:W$,Node:N5},$$={}});var m0,_$="Expected a non-empty brand name after #",I5,V$=(Z)=>`JSONSchema target '${Z}' is not supported (must be ${I5.map((X)=>`"${X}"`).join(" or ")})`,j5=(Z)=>{if(!g0(I5,Z))M(V$(Z));return Z},E2=(Z)=>typeof Z==="object"&&!(Z instanceof Date)?{...Z,exclusive:!0}:{rule:Z,exclusive:!0},k6=(Z,X)=>b(X,"root")?b(Z,"root")?Z.extends(X):X.allows(Z):b(Z,"root")?Z.hasUnit(X):X===Z,E5=(Z)=>{if(Z.hasKind("morph"))return null;if(Z.hasKind("intersection"))return Z.inner.structure??(Z.basis?.domain==="object"?Z.$.bindReference(R.intrinsic.emptyStructure):null);if(Z.isBasis()&&Z.domain==="object")return Z.$.bindReference(R.intrinsic.emptyStructure);return null},H$=(Z)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
23
+ ${Z}`,b5=(Z,X)=>`${Z} operand must be an object (was ${X})`;var f1=O(()=>{E();w2();I0();U2();U0();P6();d();x0();p();J0();j2();m0=class m0 extends S6{constructor(Z,X){super(Z,X);Object.defineProperty(this,O0,{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:(Z)=>{let X=this(Z);if(X instanceof C0)return X;return{value:X}},jsonSchema:{input:(Z)=>this.rawIn.toJsonSchema({target:j5(Z.target),...Z.libraryOptions}),output:(Z)=>this.rawOut.toJsonSchema({target:j5(Z.target),...Z.libraryOptions})}}}as(){return this}brand(Z){if(Z==="")return M(_$);return this}readonly(){return this}branches=this.hasKind("union")?this.inner.branches:[this];distribute(Z,X){let Q=this.branches.map(Z);return X?.(Q)??Q}get shortDescription(){return this.meta.description??this.defaultShortDescription}toJsonSchema(Z={}){let X=bZ(this.$.resolvedConfig.toJsonSchema,Z);X.useRefs||=this.isCyclic;let Q=typeof X.dialect==="string"?{$schema:X.dialect}:{};if(Object.assign(Q,this.toJsonSchemaRecurse(X)),X.useRefs){let U=k(this.references,(J,q)=>q.isRoot()&&!q.alwaysExpandJsonSchema?[q.id,q.toResolvedJsonSchema(X)]:[]);if(X.target==="draft-07")Object.assign(Q,{definitions:U});else Q.$defs=U}return Q}toJsonSchemaRecurse(Z){if(Z.useRefs&&!this.alwaysExpandJsonSchema)return{$ref:`#/${Z.target==="draft-07"?"definitions":"$defs"}/${this.id}`};return this.toResolvedJsonSchema(Z)}get alwaysExpandJsonSchema(){return this.isBasis()||this.kind==="alias"||this.hasKind("union")&&this.isBoolean}toResolvedJsonSchema(Z){let X=this.innerToJsonSchema(Z);return Object.assign(X,this.metaJson)}intersect(Z){let X=this.$.parseDefinition(Z),Q=this.rawIntersect(X);if(Q instanceof A)return Q;return this.$.finalize(Q)}rawIntersect(Z){return j0(this,Z,this.$)}toNeverIfDisjoint(){return this}and(Z){let X=this.intersect(Z);return X instanceof A?X.throw():X}rawAnd(Z){let X=this.rawIntersect(Z);return X instanceof A?X.throw():X}or(Z){let X=this.$.parseDefinition(Z);return this.$.finalize(this.rawOr(X))}rawOr(Z){let X=[...this.branches,...Z.branches];return this.$.node("union",X)}map(Z){return this.$.schema(this.applyStructuralOperation("map",[Z]))}pick(...Z){return this.$.schema(this.applyStructuralOperation("pick",Z))}omit(...Z){return this.$.schema(this.applyStructuralOperation("omit",Z))}required(){return this.$.schema(this.applyStructuralOperation("required",[]))}partial(){return this.$.schema(this.applyStructuralOperation("partial",[]))}_keyof;keyof(){if(this._keyof)return this._keyof;let Z=this.applyStructuralOperation("keyof",[]).reduce((X,Q)=>X.intersect(Q).toNeverIfDisjoint(),R.intrinsic.unknown.internal);if(Z.branches.length===0)M(yZ(`keyof ${this.expression}`));return this._keyof=this.$.finalize(Z)}get props(){if(this.branches.length!==1)return M(H$(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge(Z){let X=this.$.parseDefinition(Z);return this.$.schema(X.distribute((Q)=>this.applyStructuralOperation("merge",[E5(Q)??M(b5("merge",Q.expression))])))}applyStructuralOperation(Z,X){return this.distribute((Q)=>{if(Q.equals(R.intrinsic.object)&&Z!=="merge")return Q;let U=E5(Q);if(!U)M(b5(Z,Q.expression));if(Z==="keyof")return U.keyof();if(Z==="get")return U.get(...X);if(Z==="props")return U.props;let J=Z==="required"?"require":Z==="partial"?"optionalize":Z;return this.$.node("intersection",{domain:"object",structure:U[J](...X)})})}get(...Z){if(Z[0]===void 0)return this;return this.$.schema(this.applyStructuralOperation("get",Z))}extract(Z){let X=this.$.parseDefinition(Z);return this.$.schema(this.branches.filter((Q)=>Q.extends(X)))}exclude(Z){let X=this.$.parseDefinition(Z);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(Z){return!(this.intersect(Z)instanceof A)}extends(Z){if(this.isNever())return!0;let X=this.intersect(Z);return!(X instanceof A)&&this.equals(X)}ifExtends(Z){return this.extends(Z)?this:void 0}subsumes(Z){return this.$.parseDefinition(Z).extends(this)}configure(Z,X="shallow"){return this.configureReferences(Z,X)}describe(Z,X="shallow"){return this.configure({description:Z},X)}optional(){return[this,"?"]}default(Z){return f6(this,Z,null),[this,"=",Z]}from(Z){return this.assert(Z)}_pipe(...Z){let X=Z.reduce((Q,U)=>Q.rawPipeOnce(U),this);return this.$.finalize(X)}tryPipe(...Z){let X=Z.reduce((Q,U)=>Q.rawPipeOnce(b(U,"root")?U:(J,q)=>{try{return U(J,q)}catch(Y){return q.error({code:"predicate",predicate:U,actual:`aborted due to error:
24
+ ${Y}
25
+ `})}}),this);return this.$.finalize(X)}pipe=Object.assign(this._pipe.bind(this),{try:this.tryPipe.bind(this)});to(Z){return this.$.finalize(this.toNode(this.$.parseDefinition(Z)))}toNode(Z){let X=C6(this,Z,this.$);if(X instanceof A)return X.throw();return X}rawPipeOnce(Z){if(b(Z,"root"))return this.toNode(Z);return this.distribute((X)=>X.hasKind("morph")?this.$.node("morph",{in:X.inner.in,morphs:[...X.morphs,Z]}):this.$.node("morph",{in:X,morphs:[Z]}),this.$.parseSchema)}narrow(Z){return this.constrainOut("predicate",Z)}constrain(Z,X){return this._constrain("root",Z,X)}constrainIn(Z,X){return this._constrain("in",Z,X)}constrainOut(Z,X){return this._constrain("out",Z,X)}_constrain(Z,X,Q){let U=this.$.node(X,Q);if(U.isRoot())return U.isUnknown()?this:u(`Unexpected constraint node ${U}`);let J=Z==="root"?this:Z==="in"?this.rawIn:this.rawOut;if(J.hasKind("morph")||U.impliedBasis&&!J.extends(U.impliedBasis))return $5(X,U.impliedBasis,this);let q=this.$.node("intersection",{[U.kind]:U}),Y=Z==="out"?C6(this,q,this.$):j0(this,q,this.$);if(Y instanceof A)Y.throw();return this.$.finalize(Y)}onUndeclaredKey(Z){let X=typeof Z==="string"?Z:Z.rule,Q=typeof Z==="string"?!1:Z.deep;return this.$.finalize(this.transform((U,J)=>U==="structure"?X==="ignore"?S4(J,{undeclared:1}):{...J,undeclared:X}:J,Q?void 0:{shouldTransform:(U)=>!g0(R2,U.kind)}))}hasEqualMorphs(Z){if(!this.includesTransform&&!Z.includesTransform)return!0;if(!z1(this.shallowMorphs,Z.shallowMorphs))return!1;if(!z1(this.flatMorphs,Z.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(Z){return this.onUndeclaredKey({rule:Z,deep:!0})}filter(Z){return this.constrainIn("predicate",Z)}divisibleBy(Z){return this.constrain("divisor",Z)}matching(Z){return this.constrain("pattern",Z)}atLeast(Z){return this.constrain("min",Z)}atMost(Z){return this.constrain("max",Z)}moreThan(Z){return this.constrain("min",E2(Z))}lessThan(Z){return this.constrain("max",E2(Z))}atLeastLength(Z){return this.constrain("minLength",Z)}atMostLength(Z){return this.constrain("maxLength",Z)}moreThanLength(Z){return this.constrain("minLength",E2(Z))}lessThanLength(Z){return this.constrain("maxLength",E2(Z))}exactlyLength(Z){return this.constrain("exactLength",Z)}atOrAfter(Z){return this.constrain("after",Z)}atOrBefore(Z){return this.constrain("before",Z)}laterThan(Z){return this.constrain("after",E2(Z))}earlierThan(Z){return this.constrain("before",E2(Z))}};I5=["draft-2020-12","draft-07"]});var q1=(Z,X)=>k(g4(Z),(Q,U)=>[U,X]);var b2=O(()=>{E();d()});var z$=(Z)=>typeof Z==="string"?{reference:Z}:Z,f5=(Z)=>Z instanceof A?R.intrinsic.never.internal:Z,F$,k5,B$=(Z,X)=>`Alias '${Z}' has a shallow resolution cycle: ${[...X,Z].join("->")}`,y6;var G8=O(()=>{E();l4();U0();d();x0();p();J0();f1();b2();F$=g({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:(Z)=>Z.startsWith("$")?Z:`$ark.${Z}`},resolve:{}},normalize:z$,defaults:{description:(Z)=>Z.reference},intersections:{alias:(Z,X,Q)=>Q.$.lazilyResolve(()=>f5(n(Z.resolution,X.resolution,Q)),`${Z.reference}${Q.pipe?"=>":"&"}${X.reference}`),...q1("alias",(Z,X,Q)=>{if(X.isUnknown())return Z;if(X.isNever())return X;if(X.isBasis()&&!X.overlaps(R.intrinsic.object))return A.init("assignability",R.intrinsic.object,X);return Q.$.lazilyResolve(()=>f5(n(Z.resolution,X,Q)),`${Z.reference}${Q.pipe?"=>":"&"}${X.id}`)})}});k5=class k5 extends m0{expression=this.reference;structure=void 0;get resolution(){let Z=this._resolve();return R0[this.id]=Z}_resolve(){if(this.resolve)return this.resolve();if(this.reference[0]==="$")return this.$.resolveRoot(this.reference.slice(1));let Z=this.reference,X=R0[Z],Q=[];while(b(X,"context")){if(Q.includes(X.id))return M(B$(X.id,Q));Q.push(X.id),X=R0[X.id]}if(!b(X,"root"))return u(`Unexpected resolution for reference ${this.reference}
26
+ Seen: [${Q.join("->")}]
27
+ Resolution: ${y(X)}`);return X}get resolutionId(){if(this.reference.includes("&")||this.reference.includes("=>"))return this.resolution.id;if(this.reference[0]!=="$")return this.reference;let Z=this.reference.slice(1),X=this.$.resolutions[Z];if(typeof X==="string")return X;if(b(X,"root"))return X.id;return u(`Unexpected resolution for reference ${this.reference}: ${y(X)}`)}get defaultShortDescription(){return P0.object}innerToJsonSchema(Z){return this.resolution.toJsonSchemaRecurse(Z)}traverseAllows=(Z,X)=>{let Q=X.seen[this.reference];if(Q?.includes(Z))return!0;return X.seen[this.reference]=m(Q,Z),this.resolution.traverseAllows(Z,X)};traverseApply=(Z,X)=>{let Q=X.seen[this.reference];if(Q?.includes(Z))return;X.seen[this.reference]=m(Q,Z),this.resolution.traverseApply(Z,X)};compile(Z){let X=this.resolutionId;Z.if(`ctx.seen.${X} && ctx.seen.${X}.includes(data)`,()=>Z.return(!0)),Z.if(`!ctx.seen.${X}`,()=>Z.line(`ctx.seen.${X} = []`)),Z.line(`ctx.seen.${X}.push(data)`),Z.return(Z.invoke(X))}};y6={implementation:F$,Node:k5}});var J2;var i4=O(()=>{d();f1();J2=class J2 extends m0{traverseApply=(Z,X)=>{if(!this.traverseAllows(Z,X))X.errorFromNodeContext(this.errorContext)};get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return j1(this.errorContext)}compile(Z){if(Z.traversalKind==="Allows")Z.return(this.compiledCondition);else Z.if(this.compiledNegation,()=>Z.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}}});var M$,y5,s4;var _8=O(()=>{E();U0();d();i4();M$=g({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:(Z)=>typeof Z==="string"?{domain:Z}:B2(Z,"numberAllowsNaN")&&Z.domain!=="number"?M(s4.writeBadAllowNanMessage(Z.domain)):Z,applyConfig:(Z,X)=>Z.numberAllowsNaN===void 0&&Z.domain==="number"&&X.numberAllowsNaN?{...Z,numberAllowsNaN:!0}:Z,defaults:{description:(Z)=>P0[Z.domain],actual:(Z)=>Number.isNaN(Z)?"NaN":P0[$0(Z)]},intersections:{domain:(Z,X)=>Z.domain==="number"&&X.domain==="number"?Z.numberAllowsNaN?X:Z:A.init("domain",Z,X)}});y5=class y5 extends J2{requiresNaNCheck=this.domain==="number"&&!this.numberAllowsNaN;traverseAllows=this.requiresNaNCheck?(Z)=>typeof Z==="number"&&!Number.isNaN(Z):(Z)=>$0(Z)===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 P0[this.domain]}innerToJsonSchema(Z){if(this.domain==="bigint"||this.domain==="symbol")return Z.fallback.domain({code:"domain",base:{},domain:this.domain});return{type:this.domain}}};s4={implementation:M$,Node:y5,writeBadAllowNanMessage:(Z)=>`numberAllowsNaN may only be specified with domain "number" (was ${Z})`}});var O$,v5,V8,R$=(Z)=>{if(Z.structure?.expression)return Z.structure.expression;let X=Z.basis&&!Z.prestructurals.some((J)=>J.impl.obviatesBasisExpression)?Z.basis.nestableExpression:"",Q=Z.prestructurals.map((J)=>J.expression).join(" & "),U=`${X}${X?" ":""}${Q}`;if(U==="Array == 0")return"[]";return U||"unknown"},g5=(Z,X,Q)=>{let U={},J=Z.proto??Z.domain,q=X.proto??X.domain,Y=J?q?n(J,q,Q):J:q;if(Y instanceof A)return Y;if(Y)U[Y.kind]=Y;return A2({kind:"intersection",baseInner:U,l:S2(Z),r:S2(X),roots:[],ctx:Q})};var H8=O(()=>{E();I0();U0();d();x0();J0();f1();b2();O$=g({kind:"intersection",hasAssociatedError:!0,normalize:(Z)=>{if(o(Z))return Z;let{structure:X,...Q}=Z,U=!!X,J=X??{},q=k(Q,(Y,W)=>{if(L0(Y,eQ)){if(U)M(`Flattened structure key ${Y} cannot be specified alongside a root 'structure' key.`);return J[Y]=W,[]}return[Y,W]});if(b(J,"constraint")||!U1(J))q.structure=J;return q},finalizeInnerJson:({structure:Z,...X})=>w0(Z,"object")?{...Z,...X}:X,keys:{domain:{child:!0,parse:(Z,X)=>X.$.node("domain",Z)},proto:{child:!0,parse:(Z,X)=>X.$.node("proto",Z)},structure:{child:!0,parse:(Z,X)=>X.$.node("structure",Z),serialize:(Z)=>{if(!Z.sequence?.minLength)return Z.collapsibleJson;let{sequence:X,...Q}=Z.collapsibleJson,{minVariadicLength:U,...J}=X,q=J.variadic&&Object.keys(J).length===1?J.variadic:J;return{...Q,sequence:q}}},divisor:{child:!0,parse:z0("divisor")},max:{child:!0,parse:z0("max")},min:{child:!0,parse:z0("min")},maxLength:{child:!0,parse:z0("maxLength")},minLength:{child:!0,parse:z0("minLength")},exactLength:{child:!0,parse:z0("exactLength")},before:{child:!0,parse:z0("before")},after:{child:!0,parse:z0("after")},pattern:{child:!0,parse:z0("pattern")},predicate:{child:!0,parse:z0("predicate")}},reduce:(Z,X)=>g5({},Z,{$:X,invert:!1,pipe:!1}),defaults:{description:(Z)=>{if(Z.children.length===0)return"unknown";if(Z.structure)return Z.structure.description;let X=[];if(Z.basis&&!Z.prestructurals.some((Q)=>Q.impl.obviatesBasisDescription))X.push(Z.basis.description);if(Z.prestructurals.length){let Q=Z.prestructurals.slice().sort((U,J)=>U.kind==="min"&&J.kind==="max"?-1:0).map((U)=>U.description);X.push(...Q)}if(Z.inner.predicate)X.push(...Z.inner.predicate.map((Q)=>Q.description));return X.join(" and ")},expected:(Z)=>` ◦ ${Z.errors.map((X)=>X.expected).join(`
28
+ ◦ `)}`,problem:(Z)=>`(${Z.actual}) must be...
29
+ ${Z.expected}`},intersections:{intersection:(Z,X,Q)=>g5(Z.inner,X.inner,Q),...q1("intersection",(Z,X,Q)=>{if(Z.children.length===0)return X;let{domain:U,proto:J,...q}=Z.inner,Y=J??U,W=Y?n(Y,X,Q):X;return W instanceof A?W:Z?.basis?.equals(W)?Z:Z.$.node("intersection",{...q,[W.kind]:W},{prereduced:!0})})}});v5=class v5 extends m0{basis=this.inner.domain??this.inner.proto??null;prestructurals=[];refinements=this.children.filter((Z)=>{if(!Z.isRefinement())return!1;if(g0(jZ,Z.kind))this.prestructurals.push(Z);return!0});structure=this.inner.structure;expression=R$(this);get shallowMorphs(){return this.inner.structure?.structuralMorph?[this.inner.structure.structuralMorph]:[]}get defaultShortDescription(){return this.basis?.defaultShortDescription??"present"}innerToJsonSchema(Z){return this.children.reduce((X,Q)=>Q.isBasis()?Q.toJsonSchemaRecurse(Z):Q.reduceJsonSchema(X,Z),{})}traverseAllows=(Z,X)=>this.children.every((Q)=>Q.traverseAllows(Z,X));traverseApply=(Z,X)=>{let Q=X.currentErrorCount;if(this.basis){if(this.basis.traverseApply(Z,X),X.currentErrorCount>Q)return}if(this.prestructurals.length){for(let U=0;U<this.prestructurals.length-1;U++)if(this.prestructurals[U].traverseApply(Z,X),X.failFast&&X.currentErrorCount>Q)return;if(this.prestructurals[this.prestructurals.length-1].traverseApply(Z,X),X.currentErrorCount>Q)return}if(this.structure){if(this.structure.traverseApply(Z,X),X.currentErrorCount>Q)return}if(this.inner.predicate){for(let U=0;U<this.inner.predicate.length-1;U++)if(this.inner.predicate[U].traverseApply(Z,X),X.failFast&&X.currentErrorCount>Q)return;this.inner.predicate[this.inner.predicate.length-1].traverseApply(Z,X)}};compile(Z){if(Z.traversalKind==="Allows"){for(let X of this.children)Z.check(X);Z.return(!0);return}if(Z.initializeErrorCount(),this.basis){if(Z.check(this.basis),this.children.length>1)Z.returnIfFail()}if(this.prestructurals.length){for(let X=0;X<this.prestructurals.length-1;X++)Z.check(this.prestructurals[X]),Z.returnIfFailFast();if(Z.check(this.prestructurals[this.prestructurals.length-1]),this.structure||this.inner.predicate)Z.returnIfFail()}if(this.structure){if(Z.check(this.structure),this.inner.predicate)Z.returnIfFail()}if(this.inner.predicate){for(let X=0;X<this.inner.predicate.length-1;X++)Z.check(this.inner.predicate[X]),Z.returnIfFail();Z.check(this.inner.predicate[this.inner.predicate.length-1])}}};V8={implementation:O$,Node:v5}});var K$,x5,z8,T$=(Z,X)=>`The intersection of distinct morphs at a single path is indeterminate:
30
+ Left: ${Z}
31
+ Right: ${X}`;var F8=O(()=>{E();U0();d();x0();p();J0();f1();b2();K$=g({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:(Z,X)=>X.$.parseSchema(Z)},morphs:{parse:P1,serialize:(Z)=>Z.map((X)=>b(X,"root")?X.json:Z0(X))},declaredIn:{child:!1,serialize:(Z)=>Z.json},declaredOut:{child:!1,serialize:(Z)=>Z.json}},normalize:(Z)=>Z,defaults:{description:(Z)=>`a morph from ${Z.rawIn.description} to ${Z.rawOut?.description??"unknown"}`},intersections:{morph:(Z,X,Q)=>{if(!Z.hasEqualMorphs(X))return M(T$(Z.expression,X.expression));let U=n(Z.rawIn,X.rawIn,Q);if(U instanceof A)return U;let J={morphs:Z.morphs};if(Z.declaredIn||X.declaredIn){let q=n(Z.rawIn,X.rawIn,Q);if(q instanceof A)return q.throw();else J.declaredIn=q}if(Z.declaredOut||X.declaredOut){let q=n(Z.rawOut,X.rawOut,Q);if(q instanceof A)return q.throw();else J.declaredOut=q}return U.distribute((q)=>Q.$.node("morph",{...J,in:q}),Q.$.parseSchema)},...q1("morph",(Z,X,Q)=>{let U=Z.inner.in?n(Z.inner.in,X,Q):X;return U instanceof A?U:U.equals(Z.inner.in)?Z:Q.$.node("morph",{...Z.inner,in:U})})}});x5=class x5 extends m0{serializedMorphs=this.morphs.map(Z0);compiledMorphs=`[${this.serializedMorphs}]`;lastMorph=this.inner.morphs[this.inner.morphs.length-1];lastMorphIfNode=b(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??R.intrinsic.unknown.internal}get rawOut(){return this.declaredOut??this.introspectableOut??R.intrinsic.unknown.internal}declareIn(Z){return this.$.node("morph",{...this.inner,declaredIn:Z})}declareOut(Z){return this.$.node("morph",{...this.inner,declaredOut:Z})}expression=`(In: ${this.rawIn.expression}) => ${this.lastMorphIfNode?"To":"Out"}<${this.rawOut.expression}>`;get defaultShortDescription(){return this.rawIn.meta.description??this.rawIn.defaultShortDescription}innerToJsonSchema(Z){return Z.fallback.morph({code:"morph",base:this.rawIn.toJsonSchemaRecurse(Z),out:this.introspectableOut?.toJsonSchemaRecurse(Z)??null})}compile(Z){if(Z.traversalKind==="Allows"){if(!this.introspectableIn)return;Z.return(Z.invoke(this.introspectableIn));return}if(this.introspectableIn)Z.line(Z.invoke(this.introspectableIn));Z.line(`ctx.queueMorphs(${this.compiledMorphs})`)}traverseAllows=(Z,X)=>!this.introspectableIn||this.introspectableIn.traverseAllows(Z,X);traverseApply=(Z,X)=>{if(this.introspectableIn)this.introspectableIn.traverseApply(Z,X);X.queueMorphs(this.morphs)};hasEqualMorphs(Z){return z1(this.morphs,Z.morphs,{isEqual:(X,Q)=>X===Q||b(X,"root")&&b(Q,"root")&&X.equals(Q)})}};z8={implementation:K$,Node:x5}});var D$,h5,g6;var B8=O(()=>{E();U0();d();p();J0();i4();D$=g({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:(Z)=>z6(Z)??v0(Z)},dateAllowsInvalid:{}},normalize:(Z)=>{let X=typeof Z==="string"?{proto:e1[Z]}:typeof Z==="function"?o(Z)?Z:{proto:Z}:typeof Z.proto==="string"?{...Z,proto:e1[Z.proto]}:Z;if(typeof X.proto!=="function")M(g6.writeInvalidSchemaMessage(X.proto));if(B2(X,"dateAllowsInvalid")&&X.proto!==Date)M(g6.writeBadInvalidDateMessage(X.proto));return X},applyConfig:(Z,X)=>{if(Z.dateAllowsInvalid===void 0&&Z.proto===Date&&X.dateAllowsInvalid)return{...Z,dateAllowsInvalid:!0};return Z},defaults:{description:(Z)=>Z.builtinName?BQ[Z.builtinName]:`an instance of ${Z.proto.name}`,actual:(Z)=>Z instanceof Date&&Z.toString()==="Invalid Date"?"an invalid Date":H6(Z)},intersections:{proto:(Z,X)=>Z.proto===Date&&X.proto===Date?Z.dateAllowsInvalid?X:Z:KZ(Z.proto,X.proto)?Z:KZ(X.proto,Z.proto)?X:A.init("proto",Z,X),domain:(Z,X)=>X.domain==="object"?Z:A.init("domain",R.intrinsic.object.internal,X)}});h5=class h5 extends J2{builtinName=z6(this.proto);serializedConstructor=this.json.proto;requiresInvalidDateCheck=this.proto===Date&&!this.dateAllowsInvalid;traverseAllows=this.requiresInvalidDateCheck?(Z)=>Z instanceof Date&&Z.toString()!=="Invalid Date":(Z)=>Z instanceof this.proto;compiledCondition=`data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck?' && data.toString() !== "Invalid Date"':""}`;compiledNegation=`!(${this.compiledCondition})`;innerToJsonSchema(Z){switch(this.builtinName){case"Array":return{type:"array"};case"Date":return Z.fallback.date?.({code:"date",base:{}})??Z.fallback.proto({code:"proto",base:{},proto:this.proto});default:return Z.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}};g6={implementation:D$,Node:h5,writeBadInvalidDateMessage:(Z)=>`dateAllowsInvalid may only be specified with constructor Date (was ${Z.name})`,writeInvalidSchemaMessage:(Z)=>`instanceOf operand must be a function (was ${$0(Z)})`}});var w$,p5,P$=(Z,X)=>{let U=Z.sort((Y,W)=>Y.path.length===W.path.length?Object.keys(W.cases).length-Object.keys(Y.cases).length:Y.path.length-W.path.length)[0],J={kind:U.kind,path:U.path,optionallyChainedPropString:l5(U.path)},q=X.branches.map((Y,W)=>({originalIndex:W,branch:Y}));return{best:U,location:J,defaultEntries:q,node:X}},A$=(Z,X)=>{let Q=Z.best.cases[X],U=C$(Q.condition,Z.location.path,Z.node.$),J=[],q=[];for(let Y=0;Y<Z.defaultEntries.length;Y++){let W=Z.defaultEntries[Y];if(Q.branchIndices.includes(W.originalIndex)){let $=m5(Z.node.branches[W.originalIndex],Z.location);if($===null)J=null;else J?.push({originalIndex:W.originalIndex,branch:$})}else if(W.branch.hasKind("alias")&&U.hasKind("domain")&&U.domain==="object")J?.push(W);else{if(W.branch.rawIn.overlaps(U)){let $=m5(W.branch,Z.location);J?.push({originalIndex:W.originalIndex,branch:$})}q.push(W)}}return Z.defaultEntries=q,J},S$=(Z,X)=>{return Z.filter((U)=>{let J=Object.values(U.cases).map((q)=>q.branchIndices);for(let q=0;q<J.length-1;q++){let Y=J[q];for(let W=q+1;W<J.length;W++){let $=J[W];for(let L of Y)for(let _ of $)if(L>_){if(X[L].overlaps(X[_]))return!1}}}return!0})},C$=(Z,X,Q)=>{let U=Z==="undefined"?Q.node("unit",{unit:void 0}):Z==="null"?Q.node("unit",{unit:null}):Z==="boolean"?Q.units([!0,!1]):Z;for(let J=X.length-1;J>=0;J--){let q=X[J];U=Q.node("intersection",typeof q==="number"?{proto:"Array",sequence:[...YQ(q).map((Y)=>({})),U]}:{domain:"object",required:[{key:q,value:U}]})}return U},l5=(Z)=>Z.reduce((X,Q)=>X+NZ(Q,!0),"data"),N$,j$,O8,E$=(Z)=>({kind:Z.kind,path:Z.path.map((X)=>typeof X==="string"?X:a0(X)),cases:k(Z.cases,(X,Q)=>[X,Q===!0?Q:Q.hasKind("union")&&Q.discriminantJson?Q.discriminantJson:Q.json])}),b$,I$=(Z)=>I2(Z,b$),I2=(Z,X)=>{let Q=X?.delimiter??", ",U=X?.finalDelimiter??" or ";if(Z.length===0)return"never";if(Z.length===1)return Z[0];if(Z.length===2&&Z[0]==="false"&&Z[1]==="true"||Z[0]==="true"&&Z[1]==="false")return"boolean";let J={},q=Z.filter((W)=>J[W]?!1:J[W]=!0),Y=q.pop();return`${q.join(Q)}${q.length?U:""}${Y}`},M8=(Z,X,Q)=>{let U=X.map(()=>[]);for(let q=0;q<Z.length;q++){let Y={};for(let W=0;W<X.length;W++){if(U[W]===null)continue;if(Z[q].equals(X[W])){U[W]=null,Y={};break}let $=n(Z[q],X[W],Q);if($ instanceof A)continue;if($.equals(Z[q])){U[W].push(Z[q]),Y={};break}if($.equals(X[W]))U[W]=null;else Y[W]=$}for(let W in Y)U[W][q]=Y[W]}let J=U.flatMap((q,Y)=>q?.flatMap((W)=>W.branches)??X[Y]);return J.length===0?A.init("union",Z,X):J},f$=({branches:Z,ordered:X})=>{if(Z.length<2)return Z;let Q=Z.map(()=>!0);for(let U=0;U<Z.length;U++)for(let J=U+1;J<Z.length&&Q[U]&&Q[J];J++){if(Z[U].equals(Z[J])){Q[J]=!1;continue}let q=j0(Z[U].rawIn,Z[J].rawIn,Z[0].$);if(q instanceof A)continue;if(!X)k$(Z[U],Z[J]);if(q.equals(Z[U].rawIn))Q[U]=!!X;else if(q.equals(Z[J].rawIn))Q[J]=!1}return Z.filter((U,J)=>Q[J])},k$=(Z,X)=>{if(!Z.includesTransform&&!X.includesTransform)return;if(!z1(Z.shallowMorphs,X.shallowMorphs))M(u5(Z.expression,X.expression));if(!z1(Z.flatMorphs,X.flatMorphs,{isEqual:(Q,U)=>Q.propString===U.propString&&(Q.node.hasKind("morph")&&U.node.hasKind("morph")?Q.node.hasEqualMorphs(U.node):Q.node.hasKind("intersection")&&U.node.hasKind("intersection")?Q.node.structure?.structuralMorphRef===U.node.structure?.structuralMorphRef:!1)}))M(u5(Z.expression,X.expression))},m5=(Z,X)=>Z.transform((Q,U)=>{if(Q==="domain"||Q==="unit")return null;return U},{shouldTransform:(Q,U)=>{let J=l5(U.path);if(!X.optionallyChainedPropString.startsWith(J))return!1;if(Q.hasKind("domain")&&Q.domain==="object")return!0;if((Q.hasKind("domain")||X.kind==="unit")&&J===X.optionallyChainedPropString)return!0;return Q.children.length!==0&&Q.kind!=="index"}}),u5=(Z,X)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
32
+ Left: ${Z}
33
+ Right: ${X}`,y$=(Z,X)=>`The intersection of two ordered unions is indeterminate:
34
+ Left: ${Z}
35
+ Right: ${X}`;var R8=O(()=>{E();N1();U0();d();x0();p();J1();J0();f1();b2();w$=g({kind:"union",hasAssociatedError:!0,collapsibleKey:"branches",keys:{ordered:{},branches:{child:!0,parse:(Z,X)=>{let Q=[];for(let U of Z){let J=b(U,"root")?U.branches:X.$.parseSchema(U).branches;for(let q of J)if(q.hasKind("morph")){let Y=Q.findIndex((W)=>W.hasKind("morph")&&W.hasEqualMorphs(q));if(Y===-1)Q.push(q);else{let W=Q[Y];Q[Y]=X.$.node("morph",{...W.inner,in:W.rawIn.rawOr(q.rawIn)})}}else Q.push(q)}if(!X.def.ordered)Q.sort((U,J)=>U.hash<J.hash?-1:1);return Q}}},normalize:(Z)=>r(Z)?{branches:Z}:Z,reduce:(Z,X)=>{let Q=f$(Z);if(Q.length===1)return Q[0];if(Q.length===Z.branches.length)return;return X.node("union",{...Z,branches:Q},{prereduced:!0})},defaults:{description:(Z)=>Z.distribute((X)=>X.description,I2),expected:(Z)=>{let X=$Q(Z.errors,"propString"),Q=Object.entries(X).map(([U,J])=>{let q=[];for(let $ of J)X1(q,$.expected);let Y=I2(q),W=J.every(($)=>$.actual===J[0].actual)?J[0].actual:y(J[0].data);return`${U&&`${U} `}must be ${Y}${W&&` (was ${W})`}`});return I2(Q)},problem:(Z)=>Z.expected,message:(Z)=>{if(Z.problem[0]==="[")return`value at ${Z.problem}`;return Z.problem}},intersections:{union:(Z,X,Q)=>{if(Z.isNever!==X.isNever)return A.init("presence",Z,X);let U;if(Z.ordered){if(X.ordered)M(y$(Z.expression,X.expression));if(U=M8(X.branches,Z.branches,Q),U instanceof A)U.invert()}else U=M8(Z.branches,X.branches,Q);if(U instanceof A)return U;return Q.$.parseSchema(Z.ordered||X.ordered?{branches:U,ordered:!0}:{branches:U})},...q1("union",(Z,X,Q)=>{let U=M8(Z.branches,[X],Q);if(U instanceof A)return U;if(U.length===1)return U[0];return Q.$.parseSchema(Z.ordered?{branches:U,ordered:!0}:{branches:U})})}});p5=class p5 extends m0{isBoolean=this.branches.length===2&&this.branches[0].hasUnit(!1)&&this.branches[1].hasUnit(!0);get branchGroups(){let Z=[],X=-1;for(let Q of this.branches){if(Q.hasKind("unit")&&Q.domain==="boolean"){if(X===-1)X=Z.length,Z.push(Q);else Z[X]=R.intrinsic.boolean;continue}Z.push(Q)}return Z}unitBranches=this.branches.filter((Z)=>Z.rawIn.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?E$(this.discriminant):null;expression=this.distribute((Z)=>Z.nestableExpression,I$);createBranchedOptimisticRootApply(){return(Z,X)=>{let Q=this.traverseOptimistic(Z);if(Q!==A0)return Q;let U=new r0(Z,this.$.resolvedConfig);return this.traverseApply(Z,U),U.finalize(X)}}get shallowMorphs(){return this.branches.reduce((Z,X)=>X1(Z,X.shallowMorphs),[])}get defaultShortDescription(){return this.distribute((Z)=>Z.defaultShortDescription,I2)}innerToJsonSchema(Z){if(this.branchGroups.length===1&&this.branchGroups[0].equals(R.intrinsic.boolean))return{type:"boolean"};let X=this.branchGroups.map((Q)=>Q.toJsonSchemaRecurse(Z));if(X.every((Q)=>Object.keys(Q).length===1&&B2(Q,"const")))return{enum:X.map((Q)=>Q.const)};return{anyOf:X}}traverseAllows=(Z,X)=>this.branches.some((Q)=>Q.traverseAllows(Z,X));traverseApply=(Z,X)=>{let Q=[];for(let U=0;U<this.branches.length;U++){if(X.pushBranch(),this.branches[U].traverseApply(Z,X),!X.hasError()){if(this.branches[U].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=(Z)=>{for(let X=0;X<this.branches.length;X++){let Q=this.branches[X];if(Q.traverseAllows(Z)){if(Q.contextFreeMorph)return Q.contextFreeMorph(Z);return Z}}return A0};compile(Z){if(!this.discriminant||this.unitBranches.length===this.branches.length&&this.branches.length===2)return this.compileIndiscriminable(Z);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,U=Object.keys(Q),{optimistic:J}=Z;if(Z.optimistic=!1,Z.block(`switch(${X})`,()=>{for(let L in Q){let _=Q[L],G=L==="default"?L:`case ${L}`,V;if(_===!0)V=J?"data":"true";else if(J)if(_.rootApplyStrategy==="branchedOptimistic")V=Z.invoke(_,{kind:"Optimistic"});else if(_.contextFreeMorph)V=`${Z.invoke(_)} ? ${Z0(_.contextFreeMorph)}(data) : "${A0}"`;else V=`${Z.invoke(_)} ? data : "${A0}"`;else V=Z.invoke(_);Z.line(`${G}: return ${V}`)}return Z}),Z.traversalKind==="Allows"){Z.return(J?`"${A0}"`:!1);return}let q=I2(this.discriminant.kind==="domain"?U.map((L)=>{let _=L.slice(1,-1);return _==="function"?P0.object:P0[_]}):U),Y=this.discriminant.path.map((L)=>typeof L==="symbol"?Z0(L):JSON.stringify(L)),W=JSON.stringify(q),$=this.discriminant.kind==="domain"?`${N$}[${X}]`:`${j$}(${X})`;Z.line(`ctx.errorFromNodeContext({
36
+ code: "predicate",
37
+ expected: ${W},
38
+ actual: ${$},
39
+ relativePath: [${Y}],
40
+ meta: ${this.compiledMeta}
41
+ })`)}compileIndiscriminable(Z){if(Z.traversalKind==="Apply"){Z.const("errors","[]");for(let X of this.branches)Z.line("ctx.pushBranch()").line(Z.invoke(X)).if("!ctx.hasError()",()=>Z.return(X.includesTransform?"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)":"ctx.popBranch()")).line("errors.push(ctx.popBranch().error)");Z.line(`ctx.errorFromNodeContext({ code: "union", errors, meta: ${this.compiledMeta} })`)}else{let{optimistic:X}=Z;Z.optimistic=!1;for(let Q of this.branches)Z.if(`${Z.invoke(Q)}`,()=>Z.return(X?Q.contextFreeMorph?`${Z0(Q.contextFreeMorph)}(data)`:"data":!0));Z.return(X?`"${A0}"`:!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 J=k(this.unitBranches,(q,Y)=>[`${Y.rawIn.serializedValue}`,Y.hasKind("morph")?Y:!0]);return{kind:"unit",path:[],optionallyChainedPropString:"data",cases:J}}let Z=[];for(let J=0;J<this.branches.length-1;J++){let q=this.branches[J];for(let Y=J+1;Y<this.branches.length;Y++){let W=this.branches[Y],$=j0(q.rawIn,W.rawIn,q.$);if(!($ instanceof A))continue;for(let L of $){if(!L.kind||L.optional)continue;let _,G;if(L.kind==="domain"){let{l:z,r:F}=L;_=`"${typeof z==="string"?z:z.domain}"`,G=`"${typeof F==="string"?F:F.domain}"`}else if(L.kind==="unit")_=L.l.serializedValue,G=L.r.serializedValue;else continue;let V=Z.find((z)=>z1(z.path,L.path)&&z.kind===L.kind);if(!V)Z.push({kind:L.kind,cases:{[_]:{branchIndices:[J],condition:L.l},[G]:{branchIndices:[Y],condition:L.r}},path:L.path});else{if(V.cases[_])V.cases[_].branchIndices=X1(V.cases[_].branchIndices,J);else V.cases[_]??={branchIndices:[J],condition:L.l};if(V.cases[G])V.cases[G].branchIndices=X1(V.cases[G].branchIndices,Y);else V.cases[G]??={branchIndices:[Y],condition:L.r}}}}}let X=this.ordered?S$(Z,this.branches):Z;if(!X.length)return null;let Q=P$(X,this),U={};for(let J in Q.best.cases){let q=A$(Q,J);if(q===null){U[J]=!0;continue}if(q.length===this.branches.length)return null;if(this.ordered)q.sort(($,L)=>$.originalIndex-L.originalIndex);let Y=q.map(($)=>$.branch),W=Y.length===1?Y[0]:this.$.node("union",this.ordered?{branches:Y,ordered:!0}:Y);Object.assign(this.referencesById,W.referencesById),U[J]=W}if(Q.defaultEntries.length){let J=Q.defaultEntries.map((q)=>q.branch);U.default=this.$.node("union",this.ordered?{branches:J,ordered:!0}:J,{prereduced:!0}),Object.assign(this.referencesById,U.default.referencesById)}return Object.assign(Q.location,{cases:U})}};N$=Z0(LQ),j$=Z0(y),O8={implementation:w$,Node:p5},b$={delimiter:" | ",finalDelimiter:" | "}});var g$,c5,K8,d5=(Z,X,Q)=>{if(Z instanceof Date){let U=`data instanceof Date && data.toISOString() === ${X}`;return Q?`!(${U})`:U}if(Number.isNaN(Z))return`${Q?"!":""}Number.isNaN(data)`;return`data ${Q?"!":"="}== ${X}`};var T8=O(()=>{E();U0();d();p();i4();b2();g$=g({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:(Z)=>Z instanceof Date?Z.toISOString():v0(Z)}},normalize:(Z)=>Z,defaults:{description:(Z)=>y(Z.unit),problem:({expected:Z,actual:X})=>`${Z===X?`must be reference equal to ${Z} (serialized to the same value)`:`must be ${Z} (was ${X})`}`},intersections:{unit:(Z,X)=>A.init("unit",Z,X),...q1("unit",(Z,X)=>{if(X.allows(Z.unit))return Z;let Q=X.hasKind("intersection")?X.basis:X;if(Q){let U=Q.hasKind("domain")?Q:R.intrinsic.object;if(Z.domain!==U.domain){let J=Z.domain==="undefined"||Z.domain==="null"||Z.domain==="boolean"?Z.domain:R.intrinsic[Z.domain];return A.init("domain",J,U)}}return A.init("assignability",Z,X.hasKind("intersection")?X.children.find((U)=>!U.allows(Z.unit)):X)})}});c5=class c5 extends J2{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=d5(this.unit,this.serializedValue);compiledNegation=d5(this.unit,this.serializedValue,"negated");expression=y(this.unit);domain=$0(this.unit);get defaultShortDescription(){return this.domain==="object"?P0.object:this.description}innerToJsonSchema(Z){return this.unit===null?{type:"null"}:R.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:Z.fallback.unit({code:"unit",base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?(Z)=>Z instanceof Date&&Z.toISOString()===this.compiledValue:Number.isNaN(this.unit)?(Z)=>Number.isNaN(Z):(Z)=>Z===this.unit};K8={implementation:g$,Node:c5}});var v$,i5,D8,x$=(Z)=>`Index keys ${Z.join(", ")} should be specified as named props.`,h$=(Z)=>`Indexed key definition '${Z}' must be a string or symbol`;var w8=O(()=>{E();I0();U2();U0();d();x0();p();J1();v$=g({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:(Z,X)=>{let Q=X.$.parseSchema(Z);if(!Q.extends(R.intrinsic.key))return M(h$(Q.expression));let U=Q.branches.filter((J)=>J.hasKind("unit"));if(U.length)return M(x$(U.map((J)=>y(J.unit))));return Q}},value:{child:!0,parse:(Z,X)=>X.$.parseSchema(Z)}},normalize:(Z)=>Z,defaults:{description:(Z)=>`[${Z.signature.expression}]: ${Z.value.description}`},intersections:{index:(Z,X,Q)=>{if(Z.signature.equals(X.signature)){let U=n(Z.value,X.value,Q),J=U instanceof A?R.intrinsic.never.internal:U;return Q.$.node("index",{signature:Z.signature,value:J})}if(Z.signature.extends(X.signature)&&Z.value.subsumes(X.value))return X;if(X.signature.extends(Z.signature)&&X.value.subsumes(Z.value))return Z;return null}}});i5=class i5 extends h0{impliedBasis=R.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=m(this.value.flatRefs.map((Z)=>o0([this.signature,...Z.path],Z.node)),o0([this.signature],this.value));traverseAllows=(Z,X)=>t1(Z).every((Q)=>{if(this.signature.traverseAllows(Q[0],X))return N0(Q[0],()=>this.value.traverseAllows(Q[1],X),X);return!0});traverseApply=(Z,X)=>{for(let Q of t1(Z))if(this.signature.traverseAllows(Q[0],X))N0(Q[0],()=>this.value.traverseApply(Q[1],X),X)};_transform(Z,X){X.path.push(this.signature);let Q=super._transform(Z,X);return X.path.pop(),Q}compile(){}};D8={implementation:v$,Node:i5}});var m$,s5,P8;var A8=O(()=>{d();b6();m$=g({kind:"required",hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(Z,X)=>X.$.parseSchema(Z)}},normalize:(Z)=>Z,defaults:{description:(Z)=>`${Z.compiledKey}: ${Z.value.description}`,expected:(Z)=>Z.missingValueDescription,actual:()=>"missing"},intersections:{required:j6,optional:j6}});s5=class s5 extends E6{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=j1(this.errorContext)};P8={implementation:m$,Node:s5}});var u$,o5,p$,l$=(Z)=>{if(!Z.defaultables)return[];let X=[],Q="[",U=Z.prefixLength+Z.defaultablesLength-1;for(let J=Z.prefixLength;J<=U;J++){let[q,Y]=Z.defaultables[J-Z.prefixLength];X.push(L8(J,q,Y)),Q+=`${J}: ${q.id} = ${v0(Y)}, `}return Q+="]",p$[Q]??=X},S8,d$=(Z)=>{let X=[];if(Z.prefix)for(let Q of Z.prefix)X.push({kind:"prefix",node:Q});if(Z.defaultables)for(let[Q,U]of Z.defaultables)X.push({kind:"defaultables",node:Q,default:U});if(Z.optionals)for(let Q of Z.optionals)X.push({kind:"optionals",node:Q});if(Z.variadic)X.push({kind:"variadic",node:Z.variadic});if(Z.postfix)for(let Q of Z.postfix)X.push({kind:"postfix",node:Q});return X},a5=(Z)=>Z.reduce((X,Q)=>{if(Q.kind==="variadic")X.variadic=Q.node;else if(Q.kind==="defaultables")X.defaultables=m(X.defaultables,[[Q.node,Q.default]]);else X[Q.kind]=m(X[Q.kind],Q.node);return X},{}),C8="A postfix required element cannot follow an optional or defaultable element",c$="A postfix element requires a variadic element",v6=(Z)=>{let[X,...Q]=Z.l,[U,...J]=Z.r;if(!X||!U)return Z;let q=Q[Q.length-1]?.kind==="postfix",Y=J[J.length-1]?.kind==="postfix",W=X.kind==="prefix"||U.kind==="prefix"?"prefix":X.kind==="postfix"||U.kind==="postfix"?"postfix":X.kind==="variadic"&&U.kind==="variadic"?"variadic":q||Y?"prefix":X.kind==="defaultables"||U.kind==="defaultables"?"defaultables":"optionals";if(X.kind==="prefix"&&U.kind==="variadic"&&Y){let G=v6({...Z,fixedVariants:[],r:J.map((V)=>({...V,kind:"prefix"}))});if(G.disjoint.length===0)Z.fixedVariants.push(G)}else if(U.kind==="prefix"&&X.kind==="variadic"&&q){let G=v6({...Z,fixedVariants:[],l:Q.map((V)=>({...V,kind:"prefix"}))});if(G.disjoint.length===0)Z.fixedVariants.push(G)}let $=n(X.node,U.node,Z.ctx);if($ instanceof A)if(W==="prefix"||W==="postfix")Z.disjoint.push(...$.withPrefixKey(W==="prefix"?Z.result.length:`-${Q.length+1}`,r5(X)&&r5(U)?"required":"optional")),Z.result=[...Z.result,{kind:W,node:R.intrinsic.never.internal}];else if(W==="optionals"||W==="defaultables")return Z;else return v6({...Z,fixedVariants:[],l:Q.map((G)=>({...G,kind:"prefix"})),r:Q.map((G)=>({...G,kind:"prefix"}))});else if(W==="defaultables"){if(X.kind==="defaultables"&&U.kind==="defaultables"&&X.default!==U.default)M($8(X.default,U.default));Z.result=[...Z.result,{kind:W,node:$,default:X.kind==="defaultables"?X.default:U.kind==="defaultables"?U.default:u(`Unexpected defaultable intersection from ${X.kind} and ${U.kind} elements.`)}]}else Z.result=[...Z.result,{kind:W,node:$}];let L=Z.l.length,_=Z.r.length;if(X.kind!=="variadic"||L>=_&&(U.kind==="variadic"||_===1))Z.l=Q;if(U.kind!=="variadic"||_>=L&&(X.kind==="variadic"||L===1))Z.r=J;return v6(Z)},r5=(Z)=>Z.kind==="prefix"||Z.kind==="postfix";var N8=O(()=>{E();I0();U2();U0();d();x0();p();J1();j2();b6();u$=g({kind:"sequence",hasAssociatedError:!1,collapsibleKey:"variadic",keys:{prefix:{child:!0,parse:(Z,X)=>{if(Z.length===0)return;return Z.map((Q)=>X.$.parseSchema(Q))}},optionals:{child:!0,parse:(Z,X)=>{if(Z.length===0)return;return Z.map((Q)=>X.$.parseSchema(Q))}},defaultables:{child:(Z)=>Z.map((X)=>X[0]),parse:(Z,X)=>{if(Z.length===0)return;return Z.map((Q)=>{let U=X.$.parseSchema(Q[0]);return f6(U,Q[1],null),[U,Q[1]]})},serialize:(Z)=>Z.map((X)=>[X[0].collapsibleJson,v0(X[1])]),reduceIo:(Z,X,Q)=>{if(Z==="in"){X.optionals=Q.map((U)=>U[0].rawIn);return}X.prefix=Q.map((U)=>U[0].rawOut);return}},variadic:{child:!0,parse:(Z,X)=>X.$.parseSchema(Z,X)},minVariadicLength:{parse:(Z)=>Z===0?void 0:Z},postfix:{child:!0,parse:(Z,X)=>{if(Z.length===0)return;return Z.map((Q)=>X.$.parseSchema(Q))}}},normalize:(Z)=>{if(typeof Z==="string")return{variadic:Z};if("variadic"in Z||"prefix"in Z||"defaultables"in Z||"optionals"in Z||"postfix"in Z||"minVariadicLength"in Z){if(Z.postfix?.length){if(!Z.variadic)return M(c$);if(Z.optionals?.length||Z.defaultables?.length)return M(C8)}if(Z.minVariadicLength&&!Z.variadic)return M("minVariadicLength may not be specified without a variadic element");return Z}return{variadic:Z}},reduce:(Z,X)=>{let Q=Z.minVariadicLength??0,U=Z.prefix?.slice()??[],J=Z.defaultables?.slice()??[],q=Z.optionals?.slice()??[],Y=Z.postfix?.slice()??[];if(Z.variadic){while(q[q.length-1]?.equals(Z.variadic))q.pop();if(q.length===0&&J.length===0)while(U[U.length-1]?.equals(Z.variadic))U.pop(),Q++;while(Y[0]?.equals(Z.variadic))Y.shift(),Q++}else if(q.length===0&&J.length===0)U.push(...Y.splice(0));if(Q!==Z.minVariadicLength||Z.prefix&&Z.prefix.length!==U.length)return X.node("sequence",{...Z,prefix:U,defaultables:J,optionals:q,postfix:Y,minVariadicLength:Q},{prereduced:!0})},defaults:{description:(Z)=>{if(Z.isVariadicOnly)return`${Z.variadic.nestableExpression}[]`;return`[${Z.tuple.map((Q)=>Q.kind==="defaultables"?`${Q.node.nestableExpression} = ${y(Q.default)}`:Q.kind==="optionals"?`${Q.node.nestableExpression}?`:Q.kind==="variadic"?`...${Q.node.nestableExpression}[]`:Q.node.expression).join(", ")}]`}},intersections:{sequence:(Z,X,Q)=>{let U=v6({l:Z.tuple,r:X.tuple,disjoint:new A,result:[],fixedVariants:[],ctx:Q}),J=U.disjoint.length===0?[U,...U.fixedVariants]:U.fixedVariants;return J.length===0?U.disjoint:J.length===1?Q.$.node("sequence",a5(J[0].result)):Q.$.node("union",J.map((q)=>({proto:Array,sequence:a5(q.result)})))}}});o5=class o5 extends h0{impliedBasis=R.intrinsic.Array.internal;tuple=d$(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((Z)=>{if(Z.kind==="defaultables"||Z.kind==="optionals")return this.defaultablesAndOptionals.push(Z.node),!0;return Z.kind==="prefix"});variadicOrPostfix=H1(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return fZ(this.flatRefs,this.prevariadic.flatMap((Z,X)=>m(Z.node.flatRefs.map((Q)=>o0([`${X}`,...Q.path],Q.node)),o0([`${X}`],Z.node)))),fZ(this.flatRefs,this.variadicOrPostfix.flatMap((Z)=>m(Z.flatRefs.map((X)=>o0([R.intrinsic.nonNegativeIntegerString.internal,...X.path],X.node)),o0([R.intrinsic.nonNegativeIntegerString.internal],Z)))),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=l$(this);defaultValueMorphsReference=this.defaultValueMorphs.length?Z0(this.defaultValueMorphs):void 0;elementAtIndex(Z,X){if(X<this.prevariadic.length)return this.tuple[X];let Q=Z.length-this.postfixLength;if(X>=Q)return{kind:"postfix",node:this.postfix[X-Q]};return{kind:"variadic",node:this.variadic??u(`Unexpected attempt to access index ${X} on ${this}`)}}traverseAllows=(Z,X)=>{for(let Q=0;Q<Z.length;Q++)if(!this.elementAtIndex(Z,Q).node.traverseAllows(Z[Q],X))return!1;return!0};traverseApply=(Z,X)=>{let Q=0;for(;Q<Z.length;Q++)N0(Q,()=>this.elementAtIndex(Z,Q).node.traverseApply(Z[Q],X),X)};get element(){return this.cacheGetter("element",this.$.node("union",this.children))}compile(Z){if(this.prefix)for(let[X,Q]of this.prefix.entries())Z.traverseKey(`${X}`,`data[${X}]`,Q);for(let[X,Q]of this.defaultablesAndOptionals.entries()){let U=`${X+this.prefixLength}`;Z.if(`${U} >= data.length`,()=>Z.traversalKind==="Allows"?Z.return(!0):Z.return()),Z.traverseKey(U,`data[${U}]`,Q)}if(this.variadic){if(this.postfix)Z.const("firstPostfixIndex",`data.length${this.postfix?`- ${this.postfix.length}`:""}`);if(Z.for(`i < ${this.postfix?"firstPostfixIndex":"data.length"}`,()=>Z.traverseKey("i","data[i]",this.variadic),this.prevariadic.length),this.postfix)for(let[X,Q]of this.postfix.entries()){let U=`firstPostfixIndex + ${X}`;Z.traverseKey(U,`data[${U}]`,Q)}}if(Z.traversalKind==="Allows")Z.return(!0)}_transform(Z,X){X.path.push(R.intrinsic.nonNegativeIntegerString.internal);let Q=super._transform(Z,X);return X.path.pop(),Q}expression=this.description;reduceJsonSchema(Z,X){let Q=X.target==="draft-07";if(this.prevariadic.length){let U=this.prevariadic.map((J)=>{let q=J.node.toJsonSchemaRecurse(X);if(J.kind==="defaultables"){let Y=typeof J.default==="function"?J.default():J.default;q.default=R.intrinsic.jsonData.allows(Y)?Y:X.fallback.defaultValue({code:"defaultValue",base:q,value:Y})}return q});if(Q)Z.items=U;else Z.prefixItems=U}if(this.minLength)Z.minItems=this.minLength;if(this.variadic){let U=this.variadic.toJsonSchemaRecurse(X);if(Q&&this.prevariadic.length)Z.additionalItems=U;else Z.items=U;if(this.maxLength)Z.maxItems=this.maxLength;if(this.postfix){let J=this.postfix.map((q)=>q.toJsonSchemaRecurse(X));Z=X.fallback.arrayPostfix({code:"arrayPostfix",base:Z,elements:J})}}else{if(Q)Z.additionalItems=!1;else Z.items=!1;delete Z.maxItems}return Z}};p$={},S8={implementation:u$,Node:o5}});var ZU=(Z)=>(X)=>{if(X.props.length||X.index){let Q=X.index?.map((J)=>J[Z])??[];for(let J of X.props)Q.push(J[Z]);if(X.undeclared)Q.push(`+ (undeclared): ${X.undeclared}`);let U=`{ ${Q.join(", ")} }`;return X.sequence?`${U} & ${X.sequence.description}`:U}return X.sequence?.description??"{}"},i$,s$,n5=(Z,X,Q)=>{let U=Z.required?"required":"optional";if(!X.signature.allows(Z.key))return null;let J=j0(Z.value,X.value,Q);if(J instanceof A)return U==="optional"?Q.node("optional",{key:Z.key,value:R.intrinsic.never.internal}):J.withPrefixKey(Z.key,Z.kind);return null},a$,XU,j8,r$=(Z)=>{let X="";for(let Q=0;Q<Z.defaultable.length;Q++)X+=Z.defaultable[Q].defaultValueMorphRef;if(Z.sequence?.defaultValueMorphsReference)X+=Z.sequence?.defaultValueMorphsReference;if(Z.undeclared==="delete"){if(X+="delete !(",Z.required)for(let Q of Z.required)X+=Q.compiledKey+" | ";if(Z.optional)for(let Q of Z.optional)X+=Q.compiledKey+" | ";if(Z.index)for(let Q of Z.index)X+=Q.signature.id+" | ";if(Z.sequence)if(Z.sequence.maxLength===null)X+=I.nonNegativeIntegerString.id;else for(let Q=0;Q<Z.sequence.tuple.length;Q++)X+=Q+" | ";X+=")"}return X},o$=(Z)=>{let X=r$(Z);if(!X)return;if(j8[X])return j8[X];let Q=(U,J)=>{for(let q=0;q<Z.defaultable.length;q++)if(!(Z.defaultable[q].key in U))Z.defaultable[q].defaultValueMorph(U,J);if(Z.sequence?.defaultables)for(let q=U.length-Z.sequence.prefixLength;q<Z.sequence.defaultables.length;q++)Z.sequence.defaultValueMorphs[q](U,J);if(Z.undeclared==="delete"){for(let q in U)if(!Z.declaresKey(q))delete U[q]}return U};return j8[X]=Q},n$=(Z,X)=>{let U=`(data${X.defaultable.some((J)=>J.defaultValueMorph.length===2)||X.sequence?.defaultValueMorphs.some((J)=>J.length===2)?", ctx":""})`;return Z.block(`${U} => `,(J)=>{for(let q=0;q<X.defaultable.length;q++){let{serializedKey:Y,defaultValueMorphRef:W}=X.defaultable[q];J.if(`!(${Y} in data)`,($)=>$.line(`${W}${U}`))}if(X.sequence?.defaultables)J.for(`i < ${X.sequence.defaultables.length}`,(q)=>q.set("data[i]",5),`data.length - ${X.sequence.prefixLength}`);if(X.undeclared==="delete")J.forIn("data",(q)=>q.if(`!(${X._compileDeclaresKey(q)})`,(Y)=>Y.line("delete data[k]")));return J.return("data")})},E8,t$=(Z)=>{if(b(Z,"root")&&Z.hasKind("unit"))Z=Z.unit;if(typeof Z==="number")Z=`${Z}`;return Z},e$=(Z,X)=>`${Z} is not allowed as an array index on ${X}. Use the 'nonNegativeIntegerString' keyword instead.`,a4=(Z,X,Q)=>{let[U,J]=qQ(Z.branches,(Y)=>Y.hasKind("unit"));if(!U.length)return{index:Q.node("index",{signature:Z,value:X})};let q={};for(let Y of U){let W=Q.node("required",{key:Y.unit,value:X});q[W.kind]=m(q[W.kind],W)}if(J.length)q.index=Q.node("index",{signature:J,value:X});return q},ZL=(Z)=>b(Z,"root")?Z.expression:y(Z),t5=(Z,X)=>`Key${X.length===1?"":"s"} ${X.map(ZL).join(", ")} ${X.length===1?"does":"do"} not exist on ${Z}`,e5=(Z)=>`Duplicate key ${a0(Z)}`;var b8=O(()=>{E();I0();c4();f1();N1();U0();d();x0();p();E1();J1();J0();j2();i$=ZU("description"),s$=ZU("expression"),a$=g({kind:"structure",hasAssociatedError:!1,normalize:(Z)=>Z,applyConfig:(Z,X)=>{if(!Z.undeclared&&X.onUndeclaredKey!=="ignore")return{...Z,undeclared:X.onUndeclaredKey};return Z},keys:{required:{child:!0,parse:z0("required"),reduceIo:(Z,X,Q)=>{X.required=m(X.required,Q.map((U)=>Z==="in"?U.rawIn:U.rawOut));return}},optional:{child:!0,parse:z0("optional"),reduceIo:(Z,X,Q)=>{if(Z==="in"){X.optional=Q.map((U)=>U.rawIn);return}for(let U of Q)X[U.outProp.kind]=m(X[U.outProp.kind],U.outProp.rawOut)}},index:{child:!0,parse:z0("index")},sequence:{child:!0,parse:z0("sequence")},undeclared:{parse:(Z)=>Z==="ignore"?void 0:Z,reduceIo:(Z,X,Q)=>{if(Q==="reject"){X.undeclared="reject";return}if(Z==="in")delete X.undeclared;else X.undeclared="reject"}}},defaults:{description:i$},intersections:{structure:(Z,X,Q)=>{let U={...Z.inner},J={...X.inner},q=new A;if(Z.undeclared){let $=Z.keyof();for(let L of X.requiredKeys)if(!$.allows(L))q.add("presence",R.intrinsic.never.internal,X.propsByKey[L].value,{path:[L]});if(J.optional)J.optional=J.optional.filter((L)=>$.allows(L.key));if(J.index)J.index=J.index.flatMap((L)=>{if(L.signature.extends($))return L;let _=j0($,L.signature,Q.$);if(_ instanceof A)return[];let G=a4(_,L.value,Q.$);if(G.required)J.required=H1(J.required,G.required);if(G.optional)J.optional=H1(J.optional,G.optional);return G.index??[]})}if(X.undeclared){let $=X.keyof();for(let L of Z.requiredKeys)if(!$.allows(L))q.add("presence",Z.propsByKey[L].value,R.intrinsic.never.internal,{path:[L]});if(U.optional)U.optional=U.optional.filter((L)=>$.allows(L.key));if(U.index)U.index=U.index.flatMap((L)=>{if(L.signature.extends($))return L;let _=j0($,L.signature,Q.$);if(_ instanceof A)return[];let G=a4(_,L.value,Q.$);if(G.required)U.required=H1(U.required,G.required);if(G.optional)U.optional=H1(U.optional,G.optional);return G.index??[]})}let Y={};if(Z.undeclared||X.undeclared)Y.undeclared=Z.undeclared==="reject"||X.undeclared==="reject"?"reject":"delete";let W=A2({kind:"structure",baseInner:Y,l:S2(U),r:S2(J),roots:[],ctx:Q});if(W instanceof A)q.push(...W);if(q.length)return q;return W}},reduce:(Z,X)=>{if(!Z.required&&!Z.optional)return;let Q={},U=!1,J=Z.optional?[...Z.optional]:[];if(Z.required)for(let q=0;q<Z.required.length;q++){let Y=Z.required[q];if(Y.key in Q)M(e5(Y.key));if(Q[Y.key]=!0,Z.index)for(let W of Z.index){let $=n5(Y,W,X);if($ instanceof A)return $}}if(Z.optional)for(let q=0;q<Z.optional.length;q++){let Y=Z.optional[q];if(Y.key in Q)M(e5(Y.key));if(Q[Y.key]=!0,Z.index)for(let W of Z.index){let $=n5(Y,W,X);if($ instanceof A)return $;if($!==null)J[q]=$,U=!0}}if(U)return X.node("structure",{...Z,optional:J},{prereduced:!0})}});XU=class XU extends h0{impliedBasis=R.intrinsic.object.internal;impliedSiblings=this.children.flatMap((Z)=>Z.impliedSiblings??[]);props=H1(this.required,this.optional);propsByKey=k(this.props,(Z,X)=>[X.key,X]);propsByKeyReference=Z0(this.propsByKey);expression=s$(this);requiredKeys=this.required?.map((Z)=>Z.key)??[];optionalKeys=this.optional?.map((Z)=>Z.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let Z=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:X}of this.index)Z=Z.concat(X.branches);return this._keyof=this.$.node("union",Z)}map(Z){return this.$.node("structure",this.props.flatMap(Z).reduce((X,Q)=>{let U=this.propsByKey[Q.key];if(o(Q)){if(Q.kind!=="required"&&Q.kind!=="optional")return M(`Map result must have kind "required" or "optional" (was ${Q.kind})`);return X[Q.kind]=m(X[Q.kind],Q),X}let J=Q.kind??U?.kind??"required",q=k(Q,(Y,W)=>(Y in I6.implementation.keys)?[Y,W]:[]);return X[J]=m(X[J],this.$.node(J,q)),X},{}))}assertHasKeys(Z){let X=Z.filter((Q)=>!k6(Q,this.keyof()));if(X.length)return M(t5(this.expression,X))}get(Z,...X){let Q,U=!1,J=t$(Z);if((typeof J==="string"||typeof J==="symbol")&&this.propsByKey[J])Q=this.propsByKey[J].value,U=this.propsByKey[J].required;if(this.index){for(let Y of this.index)if(k6(J,Y.signature))Q=Q?.and(Y.value)??Y.value}if(this.sequence&&k6(J,R.intrinsic.nonNegativeIntegerString))if(b(J,"root")){if(this.sequence.variadic)Q=Q?.and(this.sequence.element)??this.sequence.element}else{let Y=Number.parseInt(J);if(Y<this.sequence.prevariadic.length){let W=this.sequence.prevariadic[Y].node;Q=Q?.and(W)??W,U||=Y<this.sequence.prefixLength}else if(this.sequence.variadic){let W=this.$.node("union",this.sequence.variadicOrPostfix);Q=Q?.and(W)??W}}if(!Q){if(this.sequence?.variadic&&b(J,"root")&&J.extends(R.intrinsic.number))return M(e$(J.expression,this.sequence.expression));return M(t5(this.expression,[J]))}let q=Q.get(...X);return U?q:q.or(R.intrinsic.undefined)}pick(...Z){return this.assertHasKeys(Z),this.$.node("structure",this.filterKeys("pick",Z))}omit(...Z){return this.assertHasKeys(Z),this.$.node("structure",this.filterKeys("omit",Z))}optionalize(){let{required:Z,...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:Z,...X}=this.inner;return this.$.node("structure",{...X,required:this.props.map((Q)=>Q.hasKind("optional")?{key:Q.key,value:Q.value}:Q)})}merge(Z){let X=this.filterKeys("omit",[Z.keyof()]);if(Z.required)X.required=m(X.required,Z.required);if(Z.optional)X.optional=m(X.optional,Z.optional);if(Z.index)X.index=m(X.index,Z.index);if(Z.sequence)X.sequence=Z.sequence;if(Z.undeclared)X.undeclared=Z.undeclared;else delete X.undeclared;return this.$.node("structure",X)}filterKeys(Z,X){let Q=f4(this.inner),U=(J)=>{let q=X.some((Y)=>k6(J,Y));return Z==="pick"?q:!q};if(Q.required)Q.required=Q.required.filter((J)=>U(J.key));if(Q.optional)Q.optional=Q.optional.filter((J)=>U(J.key));if(Q.index)Q.index=Q.index.filter((J)=>U(J.signature));return Q}traverseAllows=(Z,X)=>this._traverse("Allows",Z,X);traverseApply=(Z,X)=>this._traverse("Apply",Z,X);_traverse=(Z,X,Q)=>{let U=Q?.currentErrorCount??0;for(let J=0;J<this.props.length;J++)if(Z==="Allows"){if(!this.props[J].traverseAllows(X,Q))return!1}else if(this.props[J].traverseApply(X,Q),Q.failFast&&Q.currentErrorCount>U)return!1;if(this.sequence){if(Z==="Allows"){if(!this.sequence.traverseAllows(X,Q))return!1}else if(this.sequence.traverseApply(X,Q),Q.failFast&&Q.currentErrorCount>U)return!1}if(this.index||this.undeclared==="reject"){let J=Object.keys(X);J.push(...Object.getOwnPropertySymbols(X));for(let q=0;q<J.length;q++){let Y=J[q];if(this.index){for(let W of this.index)if(W.signature.traverseAllows(Y,Q)){if(Z==="Allows"){if(!N0(Y,()=>W.value.traverseAllows(X[Y],Q),Q))return!1}else if(N0(Y,()=>W.value.traverseApply(X[Y],Q),Q),Q.failFast&&Q.currentErrorCount>U)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(Y)){if(Z==="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((Z)=>Z.hasDefault())??[])}declaresKey=(Z)=>(Z in this.propsByKey)||this.index?.some((X)=>X.signature.allows(Z))||this.sequence!==void 0&&R.intrinsic.nonNegativeIntegerString.allows(Z);_compileDeclaresKey(Z){let X=[];if(this.props.length)X.push(`k in ${this.propsByKeyReference}`);if(this.index)for(let Q of this.index)X.push(Z.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",o$(this))}structuralMorphRef=this.structuralMorph&&Z0(this.structuralMorph);compile(Z){if(Z.traversalKind==="Apply")Z.initializeErrorCount();for(let X of this.props)if(Z.check(X),Z.traversalKind==="Apply")Z.returnIfFailFast();if(this.sequence){if(Z.check(this.sequence),Z.traversalKind==="Apply")Z.returnIfFailFast()}if(this.index||this.undeclared==="reject")Z.const("keys","Object.keys(data)"),Z.line("keys.push(...Object.getOwnPropertySymbols(data))"),Z.for("i < keys.length",()=>this.compileExhaustiveEntry(Z));if(Z.traversalKind==="Allows")return Z.return(!0);if(this.structuralMorphRef)Z.if("ctx && !ctx.hasError()",()=>{return Z.line("ctx.queueMorphs(["),n$(Z,this),Z.line("])")})}compileExhaustiveEntry(Z){if(Z.const("k","keys[i]"),this.index)for(let X of this.index)Z.if(`${Z.invoke(X.signature,{arg:"k",kind:"Allows"})}`,()=>Z.traverseKey("k","data[k]",X.value));if(this.undeclared==="reject")Z.if(`!(${this._compileDeclaresKey(Z)})`,()=>{if(Z.traversalKind==="Allows")return Z.return(!1);return Z.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast",()=>Z.return())});return Z}reduceJsonSchema(Z,X){switch(Z.type){case"object":return this.reduceObjectJsonSchema(Z,X);case"array":let Q=this.sequence?.reduceJsonSchema(Z,X)??Z;if(this.props.length||this.index)return X.fallback.arrayObject({code:"arrayObject",base:Q,object:this.reduceObjectJsonSchema({type:"object"},X)});return Q;default:return t.throwInternalOperandError("structure",Z)}}reduceObjectJsonSchema(Z,X){if(this.props.length){Z.properties={};for(let Q of this.props){let U=Q.value.toJsonSchemaRecurse(X);if(typeof Q.key==="symbol"){X.fallback.symbolKey({code:"symbolKey",base:Z,key:Q.key,value:U,optional:Q.optional});continue}if(Q.hasDefault()){let J=typeof Q.default==="function"?Q.default():Q.default;U.default=R.intrinsic.jsonData.allows(J)?J:X.fallback.defaultValue({code:"defaultValue",base:U,value:J})}Z.properties[Q.key]=U}if(this.requiredKeys.length&&Z.properties)Z.required=this.requiredKeys.filter((Q)=>typeof Q==="string"&&(Q in Z.properties))}if(this.index)for(let Q of this.index){let U=Q.value.toJsonSchemaRecurse(X);if(Q.signature.equals(R.intrinsic.string)){Z.additionalProperties=U;continue}for(let J of Q.signature.branches){if(!J.extends(R.intrinsic.string)){Z=X.fallback.symbolKey({code:"symbolKey",base:Z,key:null,value:U,optional:!1});continue}let q={type:"string"};if(J.hasKind("morph"))q=X.fallback.morph({code:"morph",base:J.rawIn.toJsonSchemaRecurse(X),out:J.rawOut.toJsonSchemaRecurse(X)});if(!J.hasKind("intersection"))return u(`Unexpected index branch kind ${J.kind}.`);let{pattern:Y}=J.inner;if(Y){let W=Object.assign(q,{pattern:Y[0].rule});for(let $=1;$<Y.length;$++)q=X.fallback.patternIntersection({code:"patternIntersection",base:W,pattern:Y[$].rule});Z.patternProperties??={},Z.patternProperties[W.pattern]=U}}}if(this.undeclared&&!Z.additionalProperties)Z.additionalProperties=!1;return Z}};j8={},E8={implementation:a$,Node:XU}});var N2,C5;var d4=O(()=>{E();w2();hZ();uZ();Q8();J8();G8();_8();H8();F8();B8();R8();T8();p();E1();w8();j2();A8();N8();b8();N2={...T5,alias:y6.implementation,domain:s4.implementation,unit:K8.implementation,proto:g6.implementation,union:O8.implementation,morph:z8.implementation,intersection:V8.implementation,divisor:mZ.implementation,pattern:U8.implementation,predicate:xZ.implementation,required:P8.implementation,optional:I6.implementation,index:D8.implementation,sequence:S8.implementation,structure:E8.implementation};R.defaultConfig=zQ(Object.assign(k(N2,(Z,X)=>[Z,X.defaults]),{jitless:DQ(),clone:MQ,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:t.defaultConfig}));R.resolvedConfig=w6(R.defaultConfig,R.config);C5={...D5,alias:y6.Node,domain:s4.Node,unit:K8.Node,proto:g6.Node,union:O8.Node,morph:z8.Node,intersection:V8.Node,divisor:mZ.Node,pattern:U8.Node,predicate:xZ.Node,required:P8.Node,optional:I6.Node,index:D8.Node,sequence:S8.Node,structure:E8.Node}});var f2,I8=(Z,X)=>new f2(k(Z,(Q,U)=>[Q,b(U,"module")?I8(U,X):X.bindReference(U)]));var f8=O(()=>{E();J0();f2=class f2 extends BZ{get[O0](){return"module"}}});var XL=(Z)=>r(Z)?Z:("branches"in Z)&&r(Z.branches)?Z.branches:void 0,QL=(Z,X)=>M(`Node of kind ${X} is not valid as a ${Z} definition`),QU=(Z)=>`#${Z} duplicates public alias ${Z}`,k8,UU,qU="function $",UL=(Z)=>YU(Z,WU(Z)),YU=(Z,X)=>{let Q=X.write(qU,4),U=X.compile()();for(let J of Z){if(J.precompilation)continue;if(J.traverseAllows=U[`${J.id}Allows`].bind(U),J.isRoot()&&!J.allowsRequiresContext)J.allows=J.traverseAllows;if(J.traverseApply=U[`${J.id}Apply`].bind(U),U[`${J.id}Optimistic`])J.traverseOptimistic=U[`${J.id}Optimistic`].bind(U);J.precompilation=Q}},WU=(Z)=>new I4().return(Z.reduce((X,Q)=>{let U=new D6({kind:"Allows"}).indent();Q.compile(U);let J=U.write(`${Q.id}Allows`),q=new D6({kind:"Apply"}).indent();Q.compile(q);let Y=q.write(`${Q.id}Apply`),W=`${X}${J},
42
+ ${Y},
43
+ `;if(!Q.hasKind("union"))return W;let $=new D6({kind:"Allows",optimistic:!0}).indent();Q.compile($);let L=$.write(`${Q.id}Optimistic`);return`${W}${L},
44
+ `},`{
45
+ `)+"}"),r4,g8,JU=(Z)=>{let X=Z.references.filter((Q)=>Q.hasKind("alias"));for(let Q of X){Object.assign(Q.referencesById,Q.resolution.referencesById);for(let U of Z.references)if(Q.id in U.referencesById)Object.assign(U.referencesById,Q.referencesById)}return Z},$U=(Z)=>k(Z,(X,Q)=>[X,b(Q,"root")||b(Q,"generic")?Q.json:b(Q,"module")?$U(Q):u(`Unexpected resolution ${y(Q)}`)]),y8=(Z,X)=>{let Q=X.indexOf(".");if(Q===-1)return;let U=X.slice(0,Q),J=Z[U];if(J===void 0)return;if(!b(J,"module"))return M(JL(U));let q=X.slice(Q+1),Y=J[q];if(Y===void 0)return y8(J,q);if(b(Y,"root")||b(Y,"generic"))return Y;if(b(Y,"module"))return Y.root??M(GU(X));u(`Unexpected resolution for alias '${X}': ${y(Y)}`)},o4=(Z,X)=>new g8(Z,X),x6,LU=(Z,X)=>{let Q={};for(let U in X){let J=X[U];if(b(J,"module")){let q=LU(Z,J),Y=k(q,(W,$)=>[`${U}.${W}`,$]);Object.assign(Q,Y)}else if(b(J,"root")||b(J,"generic"))Q[U]=J;else u(`Unexpected scope resolution ${y(J)}`)}return Q},v8=(Z)=>`'${Z}' is unresolvable`,JL=(Z)=>`'${Z}' must reference a module to be accessed using dot syntax`,GU=(Z)=>`Reference to submodule '${Z}' must specify an alias`,c,k2,EC,u0;var x8=O(()=>{E();w2();vZ();d4();f8();l4();G8();N1();p();J1();J0();k8={};R.ambient??={};r4=class r4{config;resolvedConfig;name;get[O0](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(Z,X){if(this.config=w6(R.config,X),this.resolvedConfig=w6(R.resolvedConfig,X),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(k8).length}`,this.name in k8)M(`A Scope already named ${this.name} already exists`);k8[this.name]=this;let Q=Object.entries(Z).map((U)=>this.preparseOwnAliasEntry(...U));for(let[U,J]of Q){let q=U;if(U[0]==="#"){if(q=U.slice(1),q in this.aliases)M(QU(q));this.aliases[q]=J}else{if(q in this.aliases)M(QU(U));this.aliases[q]=J,this.exportedNames.push(q)}if(!b(J,"module")&&!b(J,"generic")&&!A1(J)){let Y=this.preparseOwnDefinitionFormat(J,{alias:q});this.resolutions[q]=b(Y,"root")?this.bindReference(Y):this.createParseContext(Y).id}}UU??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[UU.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=R.intrinsic?k(R.intrinsic,(U,J)=>U.startsWith("json")?[]:[U,this.bindReference(J)]):{}}cacheGetter(Z,X){return Object.defineProperty(this,Z,{value:X}),X}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema(Z){return Z}generic=(...Z)=>{let X=this;return(Q,U)=>new I1(Z,U?new v4(Q):Q,X,X,U??null)};units=(Z,X)=>{let Q=[];for(let J of Z)if(!Q.includes(J))Q.push(J);let U=Q.map((J)=>this.node("unit",{unit:J},X));return this.node("union",U,{...X,prereduced:!0})};lazyResolutions=[];lazilyResolve(Z,X){let Q=this.node("alias",{reference:X??"synthetic",resolve:Z},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(Q);return Q}schema=(Z,X)=>this.finalize(this.parseSchema(Z,X));parseSchema=(Z,X)=>this.node(N6(Z),Z,X);preparseNode(Z,X,Q){let U=typeof Z==="string"?Z:N6(X,Z);if(o(X)&&X.kind===U)return X;if(U==="alias"&&!Q?.prereduced){let{reference:Y}=y6.implementation.normalize(X,this);if(Y.startsWith("$")){let W=this.resolveRoot(Y.slice(1));X=W,U=W.kind}}else if(U==="union"&&w0(X,"object")){let Y=XL(X);if(Y?.length===1)X=Y[0],U=N6(X)}if(o(X)&&X.kind===U)return X;let q=N2[U].normalize?.(X,this)??X;if(o(q))return q.kind===U?q:QL(U,q.kind);return{...Q,$:this,kind:U,def:q,prefix:Q.alias??U}}bindReference(Z){let X;if(o(Z))X=Z.$===this?Z:new Z.constructor(Z.attachments,this);else X=Z.$===this?Z:new I1(Z.params,Z.bodyDef,Z.$,this,Z.hkt);if(!this.resolved)Object.assign(this.referencesById,X.referencesById);return X}resolveRoot(Z){return this.maybeResolveRoot(Z)??M(v8(Z))}maybeResolveRoot(Z){let X=this.maybeResolve(Z);if(b(X,"generic"))return;return X}maybeResolveSubalias(Z){return y8(this.aliases,Z)??y8(this.ambient,Z)}get ambient(){return R.ambient}maybeResolve(Z){let X=this.resolutions[Z];if(X){if(typeof X!=="string")return this.bindReference(X);let U=R0[X];if(b(U,"root"))return this.resolutions[Z]=U;if(b(U,"context")){if(U.phase==="resolving")return this.node("alias",{reference:`$${Z}`},{prereduced:!0});if(U.phase==="resolved")return u(`Unexpected resolved context for was uncached by its scope: ${y(U)}`);U.phase="resolving";let J=this.bindReference(this.parseOwnDefinitionFormat(U.def,U));return U.phase="resolved",R0[J.id]=J,R0[U.id]=J,this.resolutions[Z]=J}return u(`Unexpected nodesById entry for ${X}: ${y(U)}`)}let Q=this.aliases[Z]??this.ambient?.[Z];if(!Q)return this.maybeResolveSubalias(Z);if(Q=this.normalizeRootScopeValue(Q),b(Q,"generic"))return this.resolutions[Z]=this.bindReference(Q);if(b(Q,"module")){if(!Q.root)M(GU(Z));return this.resolutions[Z]=this.bindReference(Q.root)}return this.resolutions[Z]=this.parse(Q,{alias:Z})}createParseContext(Z){let X=Z.id??q8(Z.prefix);return R0[X]=Object.assign(Z,{[O0]:"context",$:this,id:X,phase:"unresolved"})}traversal(Z){return new r0(Z,this.resolvedConfig)}import(...Z){return new f2(k(this.export(...Z),(X,Q)=>[`#${X}`,Q]))}precompilation;_exportedResolutions;_exports;export(...Z){if(!this._exports){this._exports={};for(let Q of this.exportedNames){let U=this.aliases[Q];this._exports[Q]=b(U,"module")?I8(U,this):JU(this.maybeResolve(Q))}for(let Q of this.lazyResolutions)Q.resolution;if(this._exportedResolutions=LU(this,this._exports),this._json=$U(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let Q=WU(this.references);this.precompilation=Q.write(qU,4),YU(this.references,Q)}this.resolved=!0}let X=Z.length?Z:this.exportedNames;return new f2(k(X,(Q,U)=>[U,this._exports[U]]))}resolve(Z){return this.export()[Z]}node=(Z,X,Q={})=>{let U=this.preparseNode(Z,X,Q);if(o(U))return this.bindReference(U);let J=this.createParseContext(U),q=Y8(J),Y=this.bindReference(q);return R0[J.id]=Y};parse=(Z,X={})=>this.finalize(this.parseDefinition(Z,X));parseDefinition(Z,X={}){if(b(Z,"root"))return this.bindReference(Z);let Q=this.preparseOwnDefinitionFormat(Z,X);if(b(Q,"root"))return this.bindReference(Q);let U=this.createParseContext(Q);R0[U.id]=U;let J=this.bindReference(this.parseOwnDefinitionFormat(Z,U));if(J.isCyclic)J=S5(J,U.id);return R0[U.id]=J,J}finalize(Z){if(JU(Z),!Z.precompilation&&!this.resolvedConfig.jitless)UL(Z.references);return Z}};g8=class g8 extends r4{parseOwnDefinitionFormat(Z,X){return Y8(X)}preparseOwnDefinitionFormat(Z,X){return this.preparseNode(N6(Z),Z,X)}preparseOwnAliasEntry(Z,X){return[Z,X]}normalizeRootScopeValue(Z){return Z}};x6=new g8({});x6.export();c=x6.schema,k2=x6.node,EC=x6.defineSchema,u0=x6.generic});var h8="^(?:0|[1-9]\\d*)$",qL,fC;var _U=O(()=>{p();qL=new RegExp(h8),fC=Z0(qL)});var VU,HU,YL,I;var c4=O(()=>{x8();p();_U();VU=o4({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();R.intrinsic={...VU};HU=o4({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:h8}},{prereducedAliases:!0}).export();Object.assign(R.intrinsic,HU);YL=o4({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),I={...VU,...HU,...YL,emptyStructure:k2("structure",{},{prereduced:!0})};R.intrinsic={...I}});var zU=()=>{};var FU=()=>{};var BU=()=>{};var q0=O(()=>{E();w2();I0();vZ();c4();d4();f8();U2();l4();hZ();lZ();cZ();uZ();sZ();Q8();rZ();nZ();eZ();X8();J8();R1();_8();H8();F8();B8();f1();R8();T8();x8();N1();zU();U0();P6();d();x0();FU();p();BU();E1();J1();J0();w8();j2();b6();A8();N8();b8()});var n4=(Z,X)=>new RegExp(Z,X);var MU=O(()=>{Object.assign(n4,{as:n4})});var OU=O(()=>{MU()});var RU=O(()=>{w2()});var TU=(Z)=>typeof Z==="string"&&Z[0]==="d"&&(Z[1]==="'"||Z[1]==='"')&&Z[Z.length-1]===Z[1],KU=(Z)=>Z.toString()!=="Invalid Date",DU=(Z)=>Z.slice(2,-1),m8=(Z)=>`'${Z}' could not be parsed by the Date constructor`,wU=(Z,X)=>WL(Z,X),WL=(Z,X)=>{let Q=new Date(Z);if(KU(Q))return Q;let U=vQ(Z);if(U!==void 0){let J=new Date(U);if(KU(J))return J}return X?M(X===!0?m8(Z):X):void 0};var u8=O(()=>{E()});var $L,t4=(Z,X)=>{let Q=Z.scanner.shiftUntilEscapable(GL[SU[X]]);if(Z.scanner.lookahead==="")return Z.error(VL(Q,X));if(Z.scanner.shift(),X in AU){let U;try{U=new RegExp(Q)}catch(J){M(String(J))}if(Z.root=Z.ctx.$.node("intersection",{domain:"string",pattern:Q},{prereduced:!0}),X==="x/")Z.root=Z.ctx.$.node("morph",{in:Z.root,morphs:(J)=>U.exec(J),declaredOut:$L})}else if(L0(X,p8))Z.root=Z.ctx.$.node("unit",{unit:Q});else{let U=wU(Q,m8(Q));Z.root=Z.ctx.$.node("unit",{meta:Q,unit:U})}},p8,PU,LL,AU,SU,GL,_L,VL=(Z,X)=>`${X}${Z} requires a closing ${_L[SU[X]]}`;var CU=O(()=>{q0();E();u8();$L=c({proto:"Array",sequence:"string",required:{key:"groups",value:["object",{unit:void 0}]}}),p8={"'":1,'"':1},PU={"/":1,"'":1,'"':1},LL={"d'":"'",'d"':'"',"'":"'",'"':'"'},AU={"/":"/","x/":"/"},SU={...LL,...AU},GL={"'":(Z)=>Z.lookahead==="'",'"':(Z)=>Z.lookahead==='"',"/":(Z)=>Z.lookahead==="/"},_L={'"':"double-quote","'":"single-quote","/":"forward slash"}});var NU=(Z)=>`Private type references should not include '#'. Use '${Z}' instead.`,e4="Optional definitions like 'string?' are only valid as properties in an object or tuple",Z9="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var Y1,jU=(Z,X)=>Z===">"?X[0]==="="?X[1]==="=":X.trimStart()===""||L0(X.trimStart()[0],Y1):Z==="="?X[0]!=="=":Z===","||Z==="?";var y2=O(()=>{E();Y1={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...S1}});var EU=(Z,X,Q)=>bU(Z,X,Q,[]),bU=(Z,X,Q,U)=>{let J=Q.parseUntilFinalizer();if(U.push(J.root),J.finalizer===">"){if(U.length!==X.params.length)return Q.error(l8(Z,X.names,U.map((q)=>q.expression)));return U}if(J.finalizer===",")return bU(Z,X,Q,U);return J.error(b4(">"))},l8=(Z,X,Q)=>`${Z}<${X.join(", ")}> requires exactly ${X.length} args (got ${Q.length}${Q.length===0?"":`: ${Q.join(", ")}`})`;var IU=O(()=>{E()});var X9=(Z)=>{let X=Z.scanner.shiftUntilLookahead(Y1);if(X==="keyof")Z.addPrefix("keyof");else Z.root=zL(Z,X)},HL=(Z,X,Q)=>{if(Q.scanner.shiftUntilNonWhitespace(),Q.scanner.shift()!=="<")return Q.error(l8(Z,X.names,[]));let J=EU(Z,X,Q);return X(...J)},zL=(Z,X)=>FL(Z,X)??BL(Z,X)??Z.error(X===""?Z.scanner.lookahead==="#"?NU(Z.shiftedBy(1).scanner.shiftUntilLookahead(Y1)):d8(Z):v8(X)),FL=(Z,X)=>{if(Z.ctx.args?.[X]){let U=Z.ctx.args[X];if(typeof U!=="string")return U;return Z.ctx.$.node("alias",{reference:U},{prereduced:!0})}let Q=Z.ctx.$.maybeResolve(X);if(b(Q,"root"))return Q;if(Q===void 0)return;if(b(Q,"generic"))return HL(X,Q,Z);return M(`Unexpected resolution ${y(Q)}`)},BL=(Z,X)=>{let Q=xQ(X);if(Q!==void 0)return Z.ctx.$.node("unit",{unit:Q});let U=mQ(X);if(U!==void 0)return Z.ctx.$.node("unit",{unit:U})},d8=(Z)=>{let X=Z.previousOperator();return X?c8(X,Z.scanner.unscanned):ML(Z.scanner.unscanned)},c8=(Z,X="")=>`Token '${Z}' requires a right operand${X?` before '${X}'`:""}`,ML=(Z)=>`Expected an expression${Z?` before '${Z}'`:""}`;var i8=O(()=>{q0();E();y2();IU()});var s8=(Z)=>Z.scanner.lookahead===""?Z.error(d8(Z)):Z.scanner.lookahead==="("?Z.shiftedBy(1).reduceGroupOpen():Z.scanner.lookaheadIsIn(PU)?t4(Z,Z.scanner.shift()):Z.scanner.lookaheadIsIn(S1)?s8(Z.shiftedBy(1)):Z.scanner.lookahead==="d"?Z.scanner.nextLookahead in p8?t4(Z,`${Z.scanner.shift()}${Z.scanner.shift()}`):X9(Z):Z.scanner.lookahead==="x"?Z.scanner.nextLookahead==="/"?Z.shiftedBy(2)&&t4(Z,"x/"):X9(Z):X9(Z);var fU=O(()=>{E();CU();i8()});var kU,yU,g2,gU=(Z,X)=>`Left bounds are only valid when paired with right bounds (try ...${X}${Z})`,Q9=(Z)=>`Left-bounded expressions must specify their limits using < or <= (was ${Z})`,vU=(Z,X,Q,U)=>`An expression may have at most one left bound (parsed ${Z}${g2[X]}, ${Q}${g2[U]})`;var a8=O(()=>{kU={">":!0,">=":!0},yU={"<":!0,"<=":!0},g2={"<":">",">":"<","<=":">=",">=":"<=","==":"=="}});var hU=(Z,X)=>{let Q=OL(Z,X);if(Z.root.hasKind("unit")){if(typeof Z.root.unit==="number"){Z.reduceLeftBound(Z.root.unit,Q),Z.unsetRoot();return}if(Z.root.unit instanceof Date){let U=`d'${Z.root.description??Z.root.unit.toISOString()}'`;Z.unsetRoot(),Z.reduceLeftBound(U,Q);return}}return KL(Z,Q)},mU,OL=(Z,X)=>Z.scanner.lookaheadIs("=")?`${X}${Z.scanner.shift()}`:X,xU=(Z,X,Q,U)=>{if(Q.extends(R.intrinsic.number)){if(typeof X!=="number")return M(r8(Z,X,U));return Z==="=="?["min","max"]:Z[0]===">"?["min"]:["max"]}if(Q.extends(R.intrinsic.lengthBoundable)){if(typeof X!=="number")return M(r8(Z,X,U));return Z==="=="?["exactLength"]:Z[0]===">"?["minLength"]:["maxLength"]}if(Q.extends(R.intrinsic.Date))return Z==="=="?["after","before"]:Z[0]===">"?["after"]:["before"];return M(H5(Q.expression))},RL=(Z)=>({rule:TU(Z.limit)?DU(Z.limit):Z.limit,exclusive:Z.comparator.length===1}),KL=(Z,X)=>{let Q=Z.unsetRoot(),U=Z.scanner.location;Z.parseOperand();let J=Z.unsetRoot(),q=Z.scanner.sliceChars(U,Z.scanner.location);if(Z.root=Q,!J.hasKind("unit")||typeof J.unit!=="number"&&!(J.unit instanceof Date))return Z.error(r8(X,q,"right"));let Y=J.unit,W=X.length===1,$=xU(X,typeof Y==="number"?Y:q,Q,"right");for(let _ of $)Z.constrainRoot(_,X==="=="?{rule:Y}:{rule:Y,exclusive:W});if(!Z.branches.leftBound)return;if(!L0(X,yU))return Z.error(Q9(X));let L=xU(Z.branches.leftBound.comparator,Z.branches.leftBound.limit,Q,"left");Z.constrainRoot(L[0],RL(Z.branches.leftBound)),Z.branches.leftBound=null},r8=(Z,X,Q)=>`Comparator ${Q==="left"?g2[Z]:Z} must be ${Q==="left"?"preceded":"followed"} by a corresponding literal (was ${X})`;var uU=O(()=>{q0();E();a8();u8();mU={"<":1,">":1,"=":1}});var pU=(Z)=>{Z.scanner.shiftUntilNonWhitespace();let X=Z.scanner.shiftUntilLookahead(Y1);Z.root=Z.root.brand(X)};var lU=O(()=>{y2()});var cU=(Z)=>{Z.scanner.shiftUntilNonWhitespace();let X=Z.scanner.shiftUntilLookahead(Y1),Q=hQ(X,{errorOnFail:dU(X)});if(Q===0)Z.error(dU(0));Z.root=Z.root.constrain("divisor",Q)},dU=(Z)=>`% operator must be followed by a non-zero integer literal (was ${Z})`;var iU=O(()=>{E();y2()});var o8=(Z)=>{let X=Z.scanner.shift();return X===""?Z.finalize(""):X==="["?Z.scanner.shift()==="]"?Z.setRoot(Z.root.array()):Z.error(TL):X==="|"?Z.scanner.lookahead===">"?Z.shiftedBy(1).pushRootToBranch("|>"):Z.pushRootToBranch(X):X==="&"?Z.pushRootToBranch(X):X===")"?Z.finalizeGroup():jU(X,Z.scanner.unscanned)?Z.finalize(X):L0(X,mU)?hU(Z,X):X==="%"?cU(Z):X==="#"?pU(Z):(X in S1)?o8(Z):Z.error(U9(X))},U9=(Z,X="")=>`'${Z}' is not allowed here${X&&` (should be ${X})`}`,TL="Missing expected ']'";var n8=O(()=>{E();y2();uU();lU();iU()});var sU=(Z)=>{let X=Z.unsetRoot();Z.parseOperand();let Q=Z.unsetRoot();if(!Q.hasKind("unit"))return Z.error(DL(Q.expression));let U=Q.unit instanceof Date?()=>new Date(Q.unit):Q.unit;return[X,"=",U]},DL=(Z)=>`Default value '${Z}' must be a literal value`;var t8=(Z,X)=>{let Q=X.$.maybeResolveRoot(Z);if(Q)return Q;if(Z.endsWith("[]")){let q=X.$.maybeResolveRoot(Z.slice(0,-2));if(q)return q.array()}let U=new v2(new T6(Z),X),J=wL(U);if(U.finalizer===">")M(U9(">"));return J},wL=(Z)=>{Z.parseOperand();let X=h6(Z).root;if(!X)return u(`Root was unexpectedly unset after parsing string '${Z.scanner.scanned}'`);if(Z.finalizer==="=")X=sU(Z);else if(Z.finalizer==="?")X=[X,"?"];if(Z.scanner.shiftUntilNonWhitespace(),Z.scanner.lookahead)M(U9(Z.scanner.lookahead));return X},h6=(Z)=>{while(Z.finalizer===void 0)PL(Z);return Z},PL=(Z)=>Z.hasRoot()?Z.parseOperator():Z.parseOperand();var J9=O(()=>{E();e8();n8()});class v2{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor(Z,X){this.scanner=Z,this.ctx=X}error(Z){return M(Z)}hasRoot(){return this.root!==void 0}setRoot(Z){this.root=Z}unsetRoot(){let Z=this.root;return this.root=void 0,Z}constrainRoot(...Z){this.root=this.root.constrain(Z[0],Z[1])}finalize(Z){if(this.groups.length)return this.error(b4(")"));this.finalizeBranches(),this.finalizer=Z}reduceLeftBound(Z,X){let Q=g2[X];if(!L0(Q,kU))return this.error(Q9(X));if(this.branches.leftBound)return this.error(vU(this.branches.leftBound.limit,this.branches.leftBound.comparator,Z,Q));this.branches.leftBound={comparator:Q,limit:Z}}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 Z=this.groups.pop();if(!Z)return this.error(iQ(")",this.scanner.unscanned));this.branches=Z}addPrefix(Z){this.branches.prefixes.push(Z)}applyPrefixes(){while(this.branches.prefixes.length){let Z=this.branches.prefixes.pop();this.root=Z==="keyof"?this.root.keyof():u(`Unexpected prefix '${Z}'`)}}pushRootToBranch(Z){this.assertRangeUnset(),this.applyPrefixes();let X=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(X)??X,Z==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,Z==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return h6(new v2(this.scanner,this.ctx))}parseOperator(){return o8(this)}parseOperand(){return s8(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(gU(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(Z){return this.scanner.jumpForward(Z),this}}var e8=O(()=>{E();fU();n8();J9();a8()});var AL="An empty string is not a valid generic parameter name",q9=(Z,X,Q)=>{Z.shiftUntilNonWhitespace();let U=Z.shiftUntilLookahead(Y1);if(U===""){if(Z.lookahead===""&&X.length)return X;return M(AL)}return Z.shiftUntilNonWhitespace(),SL(Z,U,X,Q)},aU="extends ",SL=(Z,X,Q,U)=>{if(Z.shiftUntilNonWhitespace(),Z.unscanned.startsWith(aU))Z.jumpForward(aU.length);else{if(Z.lookahead===",")Z.shift();return Q.push(X),q9(Z,Q,U)}let J=h6(new v2(Z,U));return Q.push([X,J.root]),q9(Z,Q,U)};var ZX=O(()=>{q0();E();e8();y2();J9()});var XX,rU,CL=`":" must be followed by exactly one return type e.g:
46
+ fn("string", ":", "number")(s => s.length)`;var oU=O(()=>{E();XX=class XX extends S0{constructor(Z){let X={$:Z,raw:Z.fn};super((...Q)=>{let U=Q.indexOf(":"),J=U===-1?Q.length-1:U-1,q=Q.slice(0,J+1),Y=Z.parse(q).assertHasKind("intersection"),W=Z.intrinsic.unknown;if(U!==-1){if(U!==Q.length-2)return M(CL);W=Z.parse(Q[U+1])}return($)=>new rU($,Y,W)},{attach:X})}};rU=class rU extends S0{raw;params;returns;expression;constructor(Z,X,Q){let U=`typed ${Z.name}`,J={[U]:(...Y)=>{let W=X.assert(Y),$=Z(...W);return Q.assert($)}}[U];super(J);this.raw=Z,this.params=X,this.returns=Q;let q=X.expression;if(q[0]==="["&&q[q.length-1]==="]")q=q.slice(1,-1);else if(q.endsWith("[]"))q=`...${q}`;this.expression=`(${q}) => ${Q?.expression??"unknown"}`}}});var QX,m6,nU=(Z)=>Z.throw(),NL="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",jL="At most one key matcher may be specified per expression";var tU=O(()=>{q0();E();QX=class QX extends S0{$;constructor(Z){super((...X)=>new m6(Z)(...X),{bind:Z});this.$=Z}in(Z){return new m6(this.$,Z===void 0?void 0:this.$.parse(Z))}at(Z,X){return new m6(this.$).at(Z,X)}case(Z,X){return new m6(this.$).case(Z,X)}};m6=class m6 extends S0{$;in;key;branches=[];constructor(Z,X){super((Q)=>this.caseEntries(Object.entries(Q).map(([U,J])=>U==="default"?[U,J]:[this.$.parse(U),J])));this.$=Z,this.in=X}at(Z,X){if(this.key)M(jL);if(this.branches.length)M(NL);return this.key=Z,X?this.match(X):this}case(Z,X){return this.caseEntry(this.$.parse(Z),X)}caseEntry(Z,X){let U=(this.key?this.$.parse({[this.key]:Z}):Z).pipe(X);return this.branches.push(U),this}match(Z){return this(Z)}strings(Z){return this.caseEntries(Object.entries(Z).map(([X,Q])=>X==="default"?[X,Q]:[this.$.node("unit",{unit:X}),Q]))}caseEntries(Z){for(let X=0;X<Z.length;X++){let[Q,U]=Z[X];if(Q==="default"){if(X!==Z.length-1)M("default may only be specified as the last key of a switch definition");return this.default(U)}if(typeof U!=="function")return M(`Value for case "${Q}" must be a function (was ${$0(U)})`);this.caseEntry(Q,U)}return this}default(Z){if(typeof Z==="function")this.case(I.unknown,Z);let X={branches:this.branches,ordered:!0};if(Z==="never"||Z==="assert")X.meta={onFail:nU};let Q=this.$.node("union",X);if(!this.in)return this.$.finalize(Q);let U=this.in.pipe(Q);if(Z==="never"||Z==="assert")U=U.configureReferences({onFail:nU},"self");return this.$.finalize(U)}}});var Y9=(Z,X)=>{if(r(Z)){if(Z[1]==="=")return[X.$.parseOwnDefinitionFormat(Z[0],X),"=",Z[2]];if(Z[1]==="?")return[X.$.parseOwnDefinitionFormat(Z[0],X),"?"]}return W9(Z,X)},eU="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",Z7="Only required keys may specify default values, e.g. { value: 'number = 0' }";var UX=O(()=>{E();JX()});var X7=(Z,X)=>{let Q,U={},J=t1(Z);for(let[Y,W]of J){let $=IL(Y);if($.kind==="spread"){if(!U1(U))return M(bL);let z=X.$.parseOwnDefinitionFormat(W,X);if(z.equals(I.object))continue;if(!z.hasKind("intersection")||!z.basis?.equals(I.object))return M(fL(z.expression));Q=z.structure;continue}if($.kind==="undeclared"){if(W!=="reject"&&W!=="delete"&&W!=="ignore")M(EL(W));U.undeclared=W;continue}let L=Y9(W,X),_=$;if($.kind==="required"){if(!r(L))qX(U,"required",{key:$.normalized,value:L},X);else qX(U,"optional",L[1]==="="?{key:$.normalized,value:L[0],default:L[2]}:{key:$.normalized,value:L[0]},X);continue}if(r(L)){if(L[1]==="?")M(eU);if(L[1]==="=")M(Z7)}if($.kind==="optional"){qX(U,"optional",{key:$.normalized,value:L},X);continue}let G=X.$.parseOwnDefinitionFormat(_.normalized,X),V=a4(G,L,X.$);if(V.index)U.index=m(U.index,V.index);if(V.required)U.required=m(U.required,V.required)}let q=X.$.node("structure",U);return X.$.parseSchema({domain:"object",structure:Q?.merge(q)??q})},qX=(Z,X,Q,U)=>{Z[X]=m(Z[X],U.$.node(X,Q))},EL=(Z)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${y(Z)})`,bL="Spread operator may only be used as the first key in an object",IL=(Z)=>typeof Z==="symbol"?{kind:"required",normalized:Z}:Z[Z.length-1]==="?"?Z[Z.length-2]===Z2?{kind:"required",normalized:`${Z.slice(0,-2)}?`}:{kind:"optional",normalized:Z.slice(0,-1)}:Z[0]==="["&&Z[Z.length-1]==="]"?{kind:"index",normalized:Z.slice(1,-1)}:Z[0]===Z2&&Z[1]==="["&&Z[Z.length-1]==="]"?{kind:"required",normalized:Z.slice(1)}:Z==="..."?{kind:"spread"}:Z==="+"?{kind:"undeclared"}:{kind:"required",normalized:Z==="\\..."?"...":Z==="\\+"?"+":Z},fL=(Z)=>`Spread operand must resolve to an object literal type (was ${Z})`;var Q7=O(()=>{q0();E();UX()});var J7=(Z,X)=>lL(Z)?$7[Z[0]](Z,X):uL(Z)?W7[Z[1]](Z,X):null,kL=(Z,X)=>X.$.parseOwnDefinitionFormat(Z[1],X).keyof(),YX=(Z,X)=>{if(Z[2]===void 0)return M(c8(Z[1],""));let Q=X.$.parseOwnDefinitionFormat(Z[0],X),U=X.$.parseOwnDefinitionFormat(Z[2],X);if(Z[1]==="|")return X.$.node("union",{branches:[Q,U]});let J=Z[1]==="&"?j0(Q,U,X.$):C6(Q,U,X.$);if(J instanceof A)return J.throw();return J},yL=(Z,X)=>X.$.parseOwnDefinitionFormat(Z[0],X).array(),gL=(Z,X)=>{if(typeof Z[2]!=="function")return M(q7("=>",Z[2]));return X.$.parseOwnDefinitionFormat(Z[0],X).pipe(Z[2])},q7=(Z,X)=>`${Z===":"?"Narrow":"Morph"} expression requires a function following '${Z}' (was ${typeof X})`,vL=(Z,X)=>{if(typeof Z[2]!=="function")return M(q7(":",Z[2]));return X.$.parseOwnDefinitionFormat(Z[0],X).constrain("predicate",Z[2])},xL=(Z,X)=>X.$.parseOwnDefinitionFormat(Z[0],X).configure(Z[2],Z[3]),Y7=(Z)=>Z,hL,mL,W7,uL=(Z)=>W7[Z[1]]!==void 0,pL=(Z)=>Z,$7,lL=(Z)=>$7[Z[0]]!==void 0,U7=(Z)=>`Expected a constructor following 'instanceof' operator (was ${Z})`;var L7=O(()=>{q0();E();i8();hL=Y7({"[]":yL,"?":()=>M(e4)}),mL=Y7({"|":YX,"&":YX,":":vL,"=>":gL,"|>":YX,"@":xL,"=":()=>M(Z9)}),W7={...hL,...mL},$7=pL({keyof:kL,instanceof:(Z,X)=>{if(typeof Z[1]!=="function")return M(U7(H6(Z[1])));let Q=Z.slice(1).map((U)=>typeof U==="function"?X.$.node("proto",{proto:U}):M(U7(H6(U))));return Q.length===1?Q[0]:X.$.node("union",{branches:Q})},"===":(Z,X)=>X.$.units(Z.slice(1))})});var V7=(Z,X)=>{let Q=[{}],U=0;while(U<Z.length){let J=!1;if(Z[U]==="..."&&U<Z.length-1)J=!0,U++;let q=Y9(Z[U],X),[Y,W,$]=!r(q)?[q]:q;if(U++,J){if(!Y.extends(R.intrinsic.Array))return M(iL(Y.expression));Q=Q.flatMap((L)=>Y.distribute((_)=>cL(f4(L),_)))}else Q=Q.map((L)=>{if(W==="?")return H7(L,Y);if(W==="=")return dL(L,Y,$);return WX(L,Y)})}return X.$.parseSchema(Q.map((J)=>U1(J)?{proto:Array,exactLength:0}:{proto:Array,sequence:J}))},WX=(Z,X)=>{if(Z.defaultables||Z.optionals)return M(Z.variadic?C8:sL);if(Z.variadic)Z.postfix=m(Z.postfix,X);else Z.prefix=m(Z.prefix,X);return Z},H7=(Z,X)=>{if(Z.variadic)return M(z7);return Z.optionals=m(Z.optionals,X),Z},dL=(Z,X,Q)=>{if(Z.variadic)return M(z7);if(Z.optionals)return M(aL);return Z.defaultables=m(Z.defaultables,[[X,Q]]),Z},G7=(Z,X)=>{if(Z.postfix)M(_7);if(Z.variadic){if(!Z.variadic.equals(X))M(_7)}else Z.variadic=X.internal;return Z},cL=(Z,X)=>{let Q=X.select({method:"find",kind:"sequence"});if(!Q)return G7(Z,R.intrinsic.unknown);if(Q.prefix)for(let U of Q.prefix)WX(Z,U);if(Q.optionals)for(let U of Q.optionals)H7(Z,U);if(Q.variadic)G7(Z,Q.variadic);if(Q.postfix)for(let U of Q.postfix)WX(Z,U);return Z},iL=(Z)=>`Spread element must be an array (was ${Z})`,_7="A tuple may have at most one variadic element",sL="A required element may not follow an optional element",z7="An optional element may not follow a variadic element",aL="A defaultable element may not follow an optional element without a default";var F7=O(()=>{q0();E();UX()});var rL,W9=(Z,X)=>{if(typeof Z==="string"){if(X.args&&Object.keys(X.args).some((U)=>Z.includes(U)))return t8(Z,X);let Q=rL[X.$.name]??={};return Q[Z]??=t8(Z,X)}return w0(Z,"object")?oL(Z,X):M($X($0(Z)))},oL=(Z,X)=>{let Q=V6(Z);switch(Q){case void 0:if(b(Z,"root"))return Z;if("~standard"in Z)return nL(Z,X);return X7(Z,X);case"Array":return tL(Z,X);case"RegExp":return X.$.node("intersection",{domain:"string",pattern:Z},{prereduced:!0});case"Function":{let U=A1(Z)?Z():Z;if(b(U,"root"))return U;return M($X("Function"))}default:return M($X(Q??y(Z)))}},nL=(Z,X)=>X.$.intrinsic.unknown.pipe((Q,U)=>{let J=Z["~standard"].validate(Q);if(!J.issues)return J.value;for(let{message:q,path:Y}of J.issues)if(Y)if(Y.length)U.error({problem:bQ(q),relativePath:Y.map((W)=>typeof W==="object"?W.key:W)});else U.error({message:q});else U.error({message:q})}),tL=(Z,X)=>J7(Z,X)??V7(Z,X),$X=(Z)=>`Type definitions must be strings or objects (was ${Z})`;var JX=O(()=>{q0();E();Q7();J9();L7();F7();rL={}});var LX;var GX=O(()=>{q0();E();LX=class LX extends S0{constructor(Z){let X=Object.assign({errors:C0,hkt:H0,$:Z,raw:Z.parse,module:Z.constructor.module,scope:Z.constructor.scope,declare:Z.declare,define:Z.define,match:Z.match,generic:Z.generic,schema:Z.schema,keywords:Z.ambient,unit:Z.unit,enumerated:Z.enumerated,instanceOf:Z.instanceOf,valueOf:Z.valueOf,or:Z.or,and:Z.and,merge:Z.merge,pipe:Z.pipe,fn:Z.fn},Z.ambientAttachments);super((...Q)=>{if(Q.length===1)return Z.parse(Q[0]);if(Q.length===2&&typeof Q[0]==="string"&&Q[0][0]==="<"&&Q[0][Q[0].length-1]===">"){let U=Q[0].slice(1,-1),J=Z.parseGenericParams(U,{});return new I1(J,Q[1],Z,Z,null)}return Z.parse(Q)},{attach:X})}}});var x2,$9,u6,h;var n0=O(()=>{q0();E();oU();ZX();tU();JX();GX();x2=R;$9=class $9 extends r4{get ambientAttachments(){if(!x2.typeAttachments)return;return this.cacheGetter("ambientAttachments",k(x2.typeAttachments,(Z,X)=>[Z,this.bindReference(X)]))}preparseOwnAliasEntry(Z,X){let Q=Z.indexOf("<");if(Q===-1){if(b(X,"module")||b(X,"generic"))return[Z,X];let q=this.name==="ark"?Z:Z==="root"?this.name:`${this.name}.${Z}`,Y=this.resolvedConfig.keywords?.[q];if(Y)X=[X,"@",Y];return[Z,X]}if(Z[Z.length-1]!==">")M("'>' must be the last character of a generic declaration in a scope");let U=Z.slice(0,Q),J=Z.slice(Q+1,-1);return[U,()=>{let q=this.parseGenericParams(J,{alias:U});return G5(q,X,this)}]}parseGenericParams(Z,X){return q9(new T6(Z),[],this.createParseContext({...X,def:Z,prefix:"generic"}))}normalizeRootScopeValue(Z){if(A1(Z)&&!b(Z,"generic"))return Z();return Z}preparseOwnDefinitionFormat(Z,X){return{...X,def:Z,prefix:X.alias??"type"}}parseOwnDefinitionFormat(Z,X){if(!(X.alias&&(X.alias in this.aliases))&&!X.args)X.args={this:X.id};let U=W9(Z,X);if(r(U)){if(U[1]==="=")return M(Z9);if(U[1]==="?")return M(e4)}return U}unit=(Z)=>this.units([Z]);valueOf=(Z)=>this.units(FQ(Z));enumerated=(...Z)=>this.units(Z);instanceOf=(Z)=>this.node("proto",{proto:Z},{prereduced:!0});or=(...Z)=>this.schema(Z.map((X)=>this.parse(X)));and=(...Z)=>Z.reduce((X,Q)=>X.and(this.parse(Q)),this.intrinsic.unknown);merge=(...Z)=>Z.reduce((X,Q)=>X.merge(this.parse(Q)),this.intrinsic.object);pipe=(...Z)=>this.intrinsic.unknown.pipe(...Z);fn=new XX(this);match=new QX(this);declare=()=>({type:this.type});define(Z){return Z}type=new LX(this);static scope=(Z,X={})=>new $9(Z,X);static module=(Z,X={})=>this.scope(Z,X).export()};u6=Object.assign($9.scope,{define:(Z)=>Z}),h=$9});var B7,eL,M7;var O7=O(()=>{q0();E();n0();B7=class B7 extends H0{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'};eL=u0(["base",I.object],["props",I.object])((Z)=>Z.base.merge(Z.props),B7),M7=h.module({Key:I.key,Merge:eL})});var R7,ZG,K7;var T7=O(()=>{q0();E();n0();R7=class R7 extends H0{};ZG=u0("element")((Z)=>{let X=Z.element.exclude(I.Array),Q=X.array();return X.rawOr(Q).pipe(P1).distribute((U)=>U.assertHasKind("morph").declareOut(Q),c)},R7),K7=h.module({root:I.Array,readonly:"root",index:I.nonNegativeIntegerString,liftFrom:ZG},{name:"Array"})});var _X,XG,D7,w7;var P7=O(()=>{q0();E();n0();_X=c(["string",X2.FileConstructor]),XG=_X.rawOr(_X.array()),D7=c({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:XG}}),w7=h.module({root:["instanceof",FormData],value:_X,parsed:D7,parse:c({in:FormData,morphs:(Z)=>{let X={};for(let[Q,U]of Z)if(Q in X){let J=X[Q];if(typeof J==="string"||J instanceof X2.FileConstructor)X[Q]=[J,U];else J.push(U)}else X[Q]=U;return X},declaredOut:D7})},{name:"FormData"})});var A7;var S7=O(()=>{n0();A7=h.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 QG,C7;var N7=O(()=>{E();n0();T7();P7();S7();QG={Boolean:1,Number:1,String:1},C7=h.module({...k({...MZ,...RZ},(Z,X)=>(Z in QG)?[]:[Z,["instanceof",X]]),Array:K7,TypedArray:A7,FormData:w7})});var UG,JG,L9;var VX=O(()=>{q0();n0();UG=c({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"}),JG=c({domain:"number",divisor:1}),L9=h.module({root:I.number,integer:JG,epoch:UG,safe:c({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 e=(Z,X,Q)=>{let U={domain:"string",pattern:{rule:Z.source,flags:Z.flags,meta:X}};if(Q)U.meta={format:Q};return k2("intersection",U)},j7,u7,qG,YG,E7,WG,$G=(Z)=>{let X=Z.replace(/[ -]+/g,""),Q=0,U,J,q=!1;for(let Y=X.length-1;Y>=0;Y--){if(U=X.substring(Y,Y+1),J=Number.parseInt(U,10),q)J*=2,Q+=J>=10?J%10+1:J;else Q+=J;q=!q}return!!(Q%10===0?X:!1)},LG,GG,_G,VG=(Z)=>!Number.isNaN(new Date(Z).valueOf()),b7,I7,HG,f7,zG,FG,BG,k7="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",k1,MG,Y0="(?:[0-9a-fA-F]{1,4})",OG,RG,h2="a JSON string",p7=(Z)=>{if(!(Z instanceof SyntaxError))throw Z;return`must be ${h2} (${Z})`},KG,TG=(Z,X)=>{if(Z.length===0)return X.error({code:"predicate",expected:h2,actual:"empty"});try{return JSON.parse(Z)}catch(Q){return X.error({code:"predicate",expected:h2,problem:p7(Q)})}},DG,y7,wG,l7,p6,G9,PG,AG,SG,CG,NG,g7,jG,v7="a regex pattern",EG,bG,IG,x7,fG,h7,kG,yG=(Z)=>URL.canParse(Z),m7,gG,vG,d7;var c7=O(()=>{q0();E();n0();VX();j7=e(B6,"a well-formed integer string"),u7=h.module({root:j7,parse:c({in:j7,morphs:(Z,X)=>{let Q=Number.parseInt(Z);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"}),qG=e(/^[\dA-Fa-f]+$/,"hex characters only"),YG=h.module({root:e(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:e(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),E7=e(/^[A-Z].*$/,"capitalized"),WG=h.module({root:c({in:"string",morphs:(Z)=>Z.charAt(0).toUpperCase()+Z.slice(1),declaredOut:E7}),preformatted:E7},{name:"string.capitalize"}),LG=/^(?: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}))$/,GG=c({domain:"string",pattern:{meta:"a credit card number",rule:LG.source},predicate:{meta:"a credit card number",predicate:$G}}),_G=/^([+-]?\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)?)?)?)?$/,b7=c({domain:"string",predicate:{meta:"a parsable date",predicate:VG}}).assertHasKind("intersection"),I7=u7.root.internal.narrow((Z,X)=>{let Q=Number.parseInt(Z),U=L9.epoch(Q);if(U instanceof C0)return X.errors.merge(U),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),HG=h.module({root:I7,parse:c({in:I7,morphs:(Z)=>new Date(Z),declaredOut:I.Date})},{name:"string.date.epoch"}),f7=e(_G,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),zG=h.module({root:f7,parse:c({in:f7,morphs:(Z)=>new Date(Z),declaredOut:I.Date})},{name:"string.date.iso"}),FG=h.module({root:b7,parse:c({declaredIn:b7,in:"string",morphs:(Z,X)=>{let Q=new Date(Z);if(Number.isNaN(Q.valueOf()))return X.error("a parsable date");return Q},declaredOut:I.Date}),iso:zG,epoch:HG},{name:"string.date"}),BG=e(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),k1=`(${k7}[.]){3}${k7}`,MG=new RegExp(`^${k1}$`),OG=new RegExp(`^((?:${Y0}:){7}(?:${Y0}|:)|(?:${Y0}:){6}(?:${k1}|:${Y0}|:)|(?:${Y0}:){5}(?::${k1}|(:${Y0}){1,2}|:)|(?:${Y0}:){4}(?:(:${Y0}){0,1}:${k1}|(:${Y0}){1,3}|:)|(?:${Y0}:){3}(?:(:${Y0}){0,2}:${k1}|(:${Y0}){1,4}|:)|(?:${Y0}:){2}(?:(:${Y0}){0,3}:${k1}|(:${Y0}){1,5}|:)|(?:${Y0}:){1}(?:(:${Y0}){0,4}:${k1}|(:${Y0}){1,6}|:)|(?::((?::${Y0}){0,5}:${k1}|(?::${Y0}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),RG=h.module({root:["v4 | v6","@","an IP address"],v4:e(MG,"an IPv4 address","ipv4"),v6:e(OG,"an IPv6 address","ipv6")},{name:"string.ip"}),KG=c({meta:h2,domain:"string",predicate:{meta:h2,predicate:(Z,X)=>{try{return JSON.parse(Z),!0}catch(Q){return X.reject({code:"predicate",expected:h2,problem:p7(Q)})}}}}),DG=h.module({root:KG,parse:c({meta:"safe JSON string parser",in:"string",morphs:TG,declaredOut:I.jsonObject})},{name:"string.json"}),y7=e(/^[a-z]*$/,"only lowercase letters"),wG=h.module({root:c({in:"string",morphs:(Z)=>Z.toLowerCase(),declaredOut:y7}),preformatted:y7},{name:"string.lower"}),l7=["NFC","NFD","NFKC","NFKD"],p6=k(l7,(Z,X)=>[X,c({domain:"string",predicate:(Q)=>Q.normalize(X)===Q,meta:`${X}-normalized unicode`})]),G9=k(l7,(Z,X)=>[X,c({in:"string",morphs:(Q)=>Q.normalize(X),declaredOut:p6[X]})]),PG=h.module({root:G9.NFC,preformatted:p6.NFC},{name:"string.normalize.NFC"}),AG=h.module({root:G9.NFD,preformatted:p6.NFD},{name:"string.normalize.NFD"}),SG=h.module({root:G9.NFKC,preformatted:p6.NFKC},{name:"string.normalize.NFKC"}),CG=h.module({root:G9.NFKD,preformatted:p6.NFKD},{name:"string.normalize.NFKD"}),NG=h.module({root:"NFC",NFC:PG,NFD:AG,NFKC:SG,NFKD:CG},{name:"string.normalize"}),g7=e(N4,"a well-formed numeric string"),jG=h.module({root:g7,parse:c({in:g7,morphs:(Z)=>Number.parseFloat(Z),declaredOut:I.number})},{name:"string.numeric"}),EG=c({domain:"string",predicate:{meta:v7,predicate:(Z,X)=>{try{return new RegExp(Z),!0}catch(Q){return X.reject({code:"predicate",expected:v7,problem:String(Q)})}}},meta:{format:"regex"}}),bG=/^(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-]+)*))?$/,IG=e(bG,"a semantic version (see https://semver.org/)"),x7=e(/^\S.*\S$|^\S?$/,"trimmed"),fG=h.module({root:c({in:"string",morphs:(Z)=>Z.trim(),declaredOut:x7}),preformatted:x7},{name:"string.trim"}),h7=e(/^[A-Z]*$/,"only uppercase letters"),kG=h.module({root:c({in:"string",morphs:(Z)=>Z.toUpperCase(),declaredOut:h7}),preformatted:h7},{name:"string.upper"}),m7=c({domain:"string",predicate:{meta:"a URL string",predicate:yG},meta:{format:"uri"}}),gG=h.module({root:m7,parse:c({declaredIn:m7,in:"string",morphs:(Z,X)=>{try{return new URL(Z)}catch{return X.error("a URL string")}},declaredOut:c(URL)})},{name:"string.url"}),vG=h.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:e(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:e(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:e(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:e(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:e(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:e(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:e(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:e(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),d7=h.module({root:I.string,alpha:e(/^[A-Za-z]*$/,"only letters"),alphanumeric:e(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:qG,base64:YG,capitalize:WG,creditCard:GG,date:FG,digits:e(/^\d*$/,"only digits 0-9"),email:BG,integer:u7,ip:RG,json:DG,lower:wG,normalize:NG,numeric:jG,regex:EG,semver:IG,trim:fG,upper:kG,url:gG,uuid:vG},{name:"string"})});var i7,s7,xG,a7,r7,hG,o7,mG,n7,uG,t7,pG,e7,lG,ZJ,dG,XJ,cG,QJ;var UJ=O(()=>{q0();E();n0();i7=h.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}),s7=h.module({root:I.unknown,any:I.unknown},{name:"unknown"}),xG=h.module({root:I.jsonObject,stringify:k2("morph",{in:I.jsonObject,morphs:(Z)=>JSON.stringify(Z),declaredOut:I.string})},{name:"object.json"}),a7=h.module({root:I.object,json:xG},{name:"object"});r7=class r7 extends H0{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'};hG=u0(["K",I.key],"V")((Z)=>({domain:"object",index:{signature:Z.K,value:Z.V}}),r7);o7=class o7 extends H0{description='pick a set of properties from an object like `Pick(User, "name | age")`'};mG=u0(["T",I.object],["K",I.key])((Z)=>Z.T.pick(Z.K),o7);n7=class n7 extends H0{description='omit a set of properties from an object like `Omit(User, "age")`'};uG=u0(["T",I.object],["K",I.key])((Z)=>Z.T.omit(Z.K),n7);t7=class t7 extends H0{description="make all named properties of an object optional like `Partial(User)`"};pG=u0(["T",I.object])((Z)=>Z.T.partial(),t7);e7=class e7 extends H0{description="make all named properties of an object required like `Required(User)`"};lG=u0(["T",I.object])((Z)=>Z.T.required(),e7);ZJ=class ZJ extends H0{description='exclude branches of a union like `Exclude("boolean", "true")`'};dG=u0("T","U")((Z)=>Z.T.exclude(Z.U),ZJ);XJ=class XJ extends H0{description='extract branches of a union like `Extract("0 | false | 1", "number")`'};cG=u0("T","U")((Z)=>Z.T.extract(Z.U),XJ),QJ=h.module({Exclude:dG,Extract:cG,Omit:uG,Partial:pG,Pick:mG,Record:hG,Required:lG})});var K1,G0,i,iG,sG,aG,_b,rG,oG;var JJ=O(()=>{n0();O7();N7();VX();c7();UJ();K1=u6({...i7,...QJ,...C7,...M7,string:d7,number:L9,object:a7,unknown:s7},{prereducedAliases:!0,name:"ark"}),G0=K1.export();Object.assign(x2.ambient,G0);x2.typeAttachments={string:G0.string.root,number:G0.number.root,bigint:G0.bigint,boolean:G0.boolean,symbol:G0.symbol,undefined:G0.undefined,null:G0.null,object:G0.object.root,unknown:G0.unknown.root,false:G0.false,true:G0.true,never:G0.never,arrayIndex:G0.Array.index,Key:G0.Key,Record:G0.Record,Array:G0.Array.root,Date:G0.Date};i=Object.assign(K1.type,x2.typeAttachments),iG=K1.match,sG=K1.fn,aG=K1.generic,_b=K1.schema,rG=K1.define,oG=K1.declare});var qJ=O(()=>{q0()});var HX=O(()=>{q0();E();OU();ZX();JJ();qJ();n0();GX();RU()});class E0{static evaluate(Z,X){if(Z===null||Z===void 0)return console.error(`Error evaluating expression: ${Z}`),null;try{if(Z.includes("${")){let Q=this.interpolate(Z,X);if(!isNaN(Number(Q))&&Q.trim()!=="")return Number(Q);return Q}return this.evaluateExpression(Z,X)}catch(Q){return console.error(`Error evaluating expression: ${Z}`,Q),null}}static interpolate(Z,X){return Z.replace(_9.TEMPLATE_INTERPOLATION,(Q,U)=>{try{let J=this.evaluateExpression(U,X);if(J===void 0||J===null)return"undefined";return String(J)}catch(J){return console.error(`Error in interpolation: ${Q}`,J),Q}})}static evaluateMathExpression(Z){try{return Function("Math",`return ${Z}`)(Math)}catch(X){throw Error(`Error evaluating mathematical expression: ${Z}`)}}static evaluateExpression(Z,X){if(_9.NESTED_PROPERTY_ACCESS.test(Z))return this.getNestedValue(Z,X);if(_9.SINGLE_LEVEL_ACCESS.test(Z))return this.getNestedValue(Z,X);try{return Function("context","with(context) { return "+Z+" }")(X)}catch(Q){return console.error(`ERROR evaluating expression '${Z}':`,Q),Z}}static getNestedValue(Z,X){let Q=Z.split("."),U=X;for(let J of Q){if(U===null||U===void 0||typeof U!=="object"||!(J in U))return;U=U[J]}return U}static findVariableInContext(Z,X){let Q=this.getNestedValue(Z,X);if(Q!==void 0)return Q;for(let U of YJ){let J=`${U}.${Z}`,q=this.getNestedValue(J,X);if(q!==void 0)return q}return}static evaluateMath(Z,X){let Q=Z;Q=Q.replace(/\b(data|vars|env|state|request|computed)(\.[a-zA-Z_][a-zA-Z0-9_]*)+/g,(U)=>{let J=this.getNestedValue(U,X);if(J!==void 0)return typeof J==="string"?`"${J}"`:String(J);return U}),Q=Q.replace(_9.WORD_BOUNDARY,(U)=>{if(tG.includes(U))return U;if(YJ.has(U))return U;let J=this.findVariableInContext(U,X);if(J!==void 0)return typeof J==="string"?`"${J}"`:String(J);return U});try{return this.evaluateMathExpression(Q)}catch(U){return console.error(`Error in mathematical evaluation: ${Z}`,U),NaN}}}var nG,YJ,p0,tG,_9;var V9=O(()=>{nG={DATA:"data",VARS:"vars",REQUEST:"request",COMPUTED:"computed",ENV:"env",STATE:"state",EVENT:"event",TIMESTAMP:"timestamp"},YJ=new Set(Object.values(nG)),p0={RANDOM:"random",FLOOR:"floor",CEIL:"ceil",ROUND:"round",SQRT:"sqrt",ABS:"abs",POW:"pow",MIN:"min",MAX:"max",SIN:"sin",COS:"cos",TAN:"tan"},tG=[p0.RANDOM,p0.FLOOR,p0.CEIL,p0.ROUND,p0.SQRT,p0.ABS,p0.POW,p0.MIN,p0.MAX,p0.SIN,p0.COS,p0.TAN],_9={TEMPLATE_INTERPOLATION:/\$\{([^}]+)\}/g,NESTED_PROPERTY_ACCESS:/^(data|vars|request|computed|env|state)(\.[a-zA-Z0-9_]+)+$/,SINGLE_LEVEL_ACCESS:/^(vars|env|state)(\.[a-zA-Z0-9_]+)$/,WORD_BOUNDARY:/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g}});class zX{store=new Map;async loadState(){return new Map(this.store)}async saveState(Z,X){this.store.set(Z,X)}async deleteState(Z){this.store.delete(Z)}async clearState(){this.store.clear()}}class F0{static instance;state;persistence;constructor(){this.state={},this.persistence=new zX}static getInstance(){if(!F0.instance)F0.instance=new F0;return F0.instance}setPersistence(Z){this.persistence=Z}async initialize(){let Z=await this.persistence.loadState();if(Z instanceof Map)this.state=Object.fromEntries(Z);else this.state=Z||{};console.log(`[StateManager] Initialized with ${Object.keys(this.state).length} root keys.`)}get(Z){return this.state[Z]}async set(Z,X){this.state[Z]=X,await this.persistence.saveState(Z,X)}async increment(Z,X=1){let Q=this.state[Z]||0,U=Number(Q)+X;return this.state[Z]=U,await this.persistence.saveState(Z,U),U}async decrement(Z,X=1){return this.increment(Z,-X)}async delete(Z){if(Z in this.state)return delete this.state[Z],await this.persistence.deleteState(Z),!0;return!1}async clear(){this.state={},await this.persistence.clearState()}async applyConfig(Z){if(!Z.state)return;for(let[X,Q]of Object.entries(Z.state))if(typeof Q!=="object"||Q===null||!("value"in Q)){if(this.state[X]===void 0)await this.set(X,Q)}else{let U=Q;if(this.state[X]===void 0)await this.set(X,U.value);if(U.lifecycle?.ttl)this.setupTTL(X,U.lifecycle.ttl)}}setupTTL(Z,X){let Q=0;if(typeof X==="number")Q=X;else{let U=X.match(/^(\d+)([smhd])$/);if(U&&U[1]&&U[2]){let J=parseInt(U[1]),q=U[2];Q=J*({s:1000,m:60000,h:3600000,d:86400000}[q]||0)}}if(Q>0)setTimeout(()=>{this.delete(Z).catch(console.error)},Q)}getAll(){return{...this.state}}getLiveProxy(){let Z=this;function X(Q,U=[]){return new Proxy(Q,{get(J,q){let Y=J[q];if(Y&&typeof Y==="object"&&!Array.isArray(Y))return X(Y,[...U,q]);return Y},set(J,q,Y){if(typeof q!=="string")return!1;J[q]=Y;let W=U.length>0?U[0]:q;if(W)Z.persistence.saveState(W,Z.state[W]);return!0}})}return X(this.state)}}var l6=()=>{};var FX={};oY(FX,{BuiltInAction:()=>K0,ActionRegistry:()=>d6});class d6{static instance;actions=new Map;constructor(Z=!0){if(Z)this.registerDefaults()}static getInstance(Z=!0){if(!this.instance)this.instance=new d6(Z);return this.instance}register(Z,X){let Q=Z.toUpperCase();if(typeof X==="function")this.actions.set(Q,{handler:X});else this.actions.set(Q,X)}get(Z){return this.actions.get(Z.toUpperCase())?.handler}getDefinition(Z){return this.actions.get(Z.toUpperCase())}getDefinitions(){let Z={};return this.actions.forEach((X,Q)=>{Z[Q]=X}),Z}get Handlers(){let Z=new Map;return this.actions.forEach((X,Q)=>{Z.set(Q,X.handler)}),Z}registerDefaults(){this.register(K0.LOG,{description:"Logs a message to the console with string interpolation support",params:i({"message?":"string","content?":"string"}),returns:i({message:"string"}),handler:(Z,X)=>{let Q=Z.params?.message||Z.params?.content||"Log Trigger",U=typeof Q==="string"?E0.interpolate(Q,X):String(Q);return console.log(`[TriggerLog] ${U}`),{message:U}}}),this.register(K0.MATH,{description:"Evaluates a mathematical expression or performs string concatenation",params:i({expression:"string"}),returns:i("number | string"),handler:(Z,X)=>{let Q=String(Z.params?.expression||"0");return E0.evaluate(Q,X)}}),this.register(K0.RESPONSE,{description:"Constructs a standardized response object (useful for webhooks/APIs)",params:i({"content?":"string","body?":"string","statusCode?":"number","headers?":"Record<string, string>"}),returns:i({statusCode:"number",headers:"Record<string, string>",body:"string"}),handler:(Z,X)=>{let Q=Z.params?.content||Z.params?.body||"",U=typeof Q==="string"?E0.interpolate(Q,X):String(Q);return{statusCode:Z.params?.statusCode||200,headers:Z.params?.headers||{"Content-Type":"application/json"},body:U}}}),this.register(K0.EXECUTE,{description:"Spawns a shell command and returns the output (Bun only)",params:i({"command?":"string","content?":"string","safe?":"boolean"}),returns:i({command:"string",stdout:"string",stderr:"string",exitCode:"number"}).or(i({command:"string",error:"string"})),handler:async(Z,X)=>{let Q=Z.params?.command||Z.params?.content||"",U=typeof Q==="string"?E0.interpolate(Q,X):String(Q);if(!Z.params?.safe)console.warn(`[Trigger] Executing unsafe command: ${U}`);try{if(typeof Bun>"u")return{command:U,error:"Bun is required for 'execute' action"};let J=Bun.spawn(U.split(" "),{stdout:"pipe",stderr:"pipe"}),[q,Y]=await Promise.all([new Response(J.stdout).text(),new Response(J.stderr).text()]);return{command:U,stdout:q,stderr:Y,exitCode:await J.exited}}catch(J){return{command:U,error:String(J)}}}}),this.register(K0.FORWARD,{description:"Forwards the current event data to a remote URL via HTTP",params:i({url:"string","method?":"'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'","headers?":"Record<string, string>"}),returns:i({url:"string",method:"string",status:"number",headers:"Record<string, string>",body:"string"}).or(i({url:"string",method:"string",error:"string"})),handler:async(Z,X)=>{let Q=Z.params?.url||"",U=typeof Q==="string"?E0.interpolate(Q,X):String(Q),J=String(Z.params?.method||"POST").toUpperCase(),Y=["POST","PUT","PATCH"].includes(J);try{let W=await fetch(U,{method:J,headers:{"Content-Type":"application/json",...typeof Z.params?.headers==="object"&&Z.params.headers!==null&&!Array.isArray(Z.params.headers)?Z.params.headers:{}},...Y?{body:JSON.stringify(X.data)}:{}});return{url:U,method:J,status:W.status,headers:(()=>{let $={};return W.headers.forEach((L,_)=>$[_]=L),$})(),body:await W.text()}}catch(W){return{url:U,method:J,error:String(W)}}}}),this.register(K0.STATE_SET,{description:"Sets a value in the persistent state",params:i({key:"string",value:"unknown"}),returns:i({key:"string",value:"unknown"}),handler:async(Z,X)=>{let Q=String(Z.params?.key||""),U=Z.params?.value;if(!Q)return{error:"Missing key for STATE_SET"};let J=U;if(typeof U==="string"&&U.includes("${"))J=E0.interpolate(U,X);return await F0.getInstance().set(Q,J),{key:Q,value:J}}}),this.register(K0.STATE_INCREMENT,{description:"Increments a numeric value in the persistent state",params:i({key:"string","amount?":"number"}),returns:i({key:"string",newValue:"number"}),handler:async(Z,X)=>{let Q=String(Z.params?.key||""),U=Number(Z.params?.amount)||1;if(!Q)return{error:"Missing key for STATE_INCREMENT"};let J=await F0.getInstance().increment(Q,U);return{key:Q,newValue:J}}}),this.register(K0.STATE_GET,{description:"Reads a value from state and optionally stores it in context.env",params:i({key:"string","as?":"string"}),returns:i({key:"string",value:"unknown","storedAs?":"string"}),handler:async(Z,X)=>{let Q=String(Z.params?.key||""),U=String(Z.params?.as||Q);if(!Q)return{error:"Missing key for STATE_GET"};let J=await F0.getInstance().get(Q);if(!X.env)X.env={};return X.env[U]=J,{key:Q,value:J,storedAs:U}}}),this.register(K0.STATE_DELETE,{description:"Deletes a key from the persistent state",params:i({key:"string"}),returns:i({key:"string",deleted:"boolean"}),handler:async(Z,X)=>{let Q=String(Z.params?.key||"");if(!Q)return{error:"Missing key for STATE_DELETE"};let U=await F0.getInstance().delete(Q);return{key:Q,deleted:U}}}),this.register(K0.EMIT_EVENT,{description:"Emits a new event back into the system",params:i({event:"string","data?":"object"}),returns:i({event:"string",payload:"object"}),handler:(Z,X)=>{return{event:String(Z.params?.event||""),payload:Z.params?.data||{}}}}),this.register(K0.NOTIFY,{description:"Sends a notification to a specific target",params:i({"message?":"string","content?":"string","target?":"string"}),returns:i({target:"string",message:"string"}),handler:(Z,X)=>{let Q=Z.params?.message||Z.params?.content||"Notification",U=Z.params?.target||"default";return console.log(`[Notification] To: ${U}, Msg: ${Q}`),{target:U,message:Q}}}),this.register(K0.STATE_OP,{description:"Executes a custom JavaScript block with access to context and state",params:i({run:"string"}),returns:i("unknown"),handler:(Z,X)=>{if(Z.params?.run)return Function("context","state","data","vars","env","helpers",`with(context) { ${Z.params.run} }`)(X,X.state,X.data,X.vars,X.env,X.helpers);return{warning:"Missing 'run' param for STATE_OP"}}})}}var K0;var m2=O(()=>{HX();V9();l6();K0={LOG:"LOG",MATH:"MATH",RESPONSE:"RESPONSE",EXECUTE:"EXECUTE",FORWARD:"FORWARD",STATE_SET:"STATE_SET",STATE_INCREMENT:"STATE_INCREMENT",STATE_GET:"STATE_GET",STATE_DELETE:"STATE_DELETE",EMIT_EVENT:"EMIT_EVENT",NOTIFY:"NOTIFY",STATE_OP:"STATE_OP"}});var l=C((R_)=>{var EX=Symbol.for("yaml.alias"),TJ=Symbol.for("yaml.document"),D9=Symbol.for("yaml.map"),DJ=Symbol.for("yaml.pair"),bX=Symbol.for("yaml.scalar"),w9=Symbol.for("yaml.seq"),D1=Symbol.for("yaml.node.type"),V_=(Z)=>!!Z&&typeof Z==="object"&&Z[D1]===EX,H_=(Z)=>!!Z&&typeof Z==="object"&&Z[D1]===TJ,z_=(Z)=>!!Z&&typeof Z==="object"&&Z[D1]===D9,F_=(Z)=>!!Z&&typeof Z==="object"&&Z[D1]===DJ,wJ=(Z)=>!!Z&&typeof Z==="object"&&Z[D1]===bX,B_=(Z)=>!!Z&&typeof Z==="object"&&Z[D1]===w9;function PJ(Z){if(Z&&typeof Z==="object")switch(Z[D1]){case D9:case w9:return!0}return!1}function M_(Z){if(Z&&typeof Z==="object")switch(Z[D1]){case EX:case D9:case bX:case w9:return!0}return!1}var O_=(Z)=>(wJ(Z)||PJ(Z))&&!!Z.anchor;R_.ALIAS=EX;R_.DOC=TJ;R_.MAP=D9;R_.NODE_TYPE=D1;R_.PAIR=DJ;R_.SCALAR=bX;R_.SEQ=w9;R_.hasAnchor=O_;R_.isAlias=V_;R_.isCollection=PJ;R_.isDocument=H_;R_.isMap=z_;R_.isNode=M_;R_.isPair=F_;R_.isScalar=wJ;R_.isSeq=B_});var o6=C((g_)=>{var _0=l(),b0=Symbol("break visit"),AJ=Symbol("skip children"),$1=Symbol("remove node");function P9(Z,X){let Q=SJ(X);if(_0.isDocument(Z)){if(d2(null,Z.contents,Q,Object.freeze([Z]))===$1)Z.contents=null}else d2(null,Z,Q,Object.freeze([]))}P9.BREAK=b0;P9.SKIP=AJ;P9.REMOVE=$1;function d2(Z,X,Q,U){let J=CJ(Z,X,Q,U);if(_0.isNode(J)||_0.isPair(J))return NJ(Z,U,J),d2(Z,J,Q,U);if(typeof J!=="symbol"){if(_0.isCollection(X)){U=Object.freeze(U.concat(X));for(let q=0;q<X.items.length;++q){let Y=d2(q,X.items[q],Q,U);if(typeof Y==="number")q=Y-1;else if(Y===b0)return b0;else if(Y===$1)X.items.splice(q,1),q-=1}}else if(_0.isPair(X)){U=Object.freeze(U.concat(X));let q=d2("key",X.key,Q,U);if(q===b0)return b0;else if(q===$1)X.key=null;let Y=d2("value",X.value,Q,U);if(Y===b0)return b0;else if(Y===$1)X.value=null}}return J}async function A9(Z,X){let Q=SJ(X);if(_0.isDocument(Z)){if(await c2(null,Z.contents,Q,Object.freeze([Z]))===$1)Z.contents=null}else await c2(null,Z,Q,Object.freeze([]))}A9.BREAK=b0;A9.SKIP=AJ;A9.REMOVE=$1;async function c2(Z,X,Q,U){let J=await CJ(Z,X,Q,U);if(_0.isNode(J)||_0.isPair(J))return NJ(Z,U,J),c2(Z,J,Q,U);if(typeof J!=="symbol"){if(_0.isCollection(X)){U=Object.freeze(U.concat(X));for(let q=0;q<X.items.length;++q){let Y=await c2(q,X.items[q],Q,U);if(typeof Y==="number")q=Y-1;else if(Y===b0)return b0;else if(Y===$1)X.items.splice(q,1),q-=1}}else if(_0.isPair(X)){U=Object.freeze(U.concat(X));let q=await c2("key",X.key,Q,U);if(q===b0)return b0;else if(q===$1)X.key=null;let Y=await c2("value",X.value,Q,U);if(Y===b0)return b0;else if(Y===$1)X.value=null}}return J}function SJ(Z){if(typeof Z==="object"&&(Z.Collection||Z.Node||Z.Value))return Object.assign({Alias:Z.Node,Map:Z.Node,Scalar:Z.Node,Seq:Z.Node},Z.Value&&{Map:Z.Value,Scalar:Z.Value,Seq:Z.Value},Z.Collection&&{Map:Z.Collection,Seq:Z.Collection},Z);return Z}function CJ(Z,X,Q,U){if(typeof Q==="function")return Q(Z,X,U);if(_0.isMap(X))return Q.Map?.(Z,X,U);if(_0.isSeq(X))return Q.Seq?.(Z,X,U);if(_0.isPair(X))return Q.Pair?.(Z,X,U);if(_0.isScalar(X))return Q.Scalar?.(Z,X,U);if(_0.isAlias(X))return Q.Alias?.(Z,X,U);return}function NJ(Z,X,Q){let U=X[X.length-1];if(_0.isCollection(U))U.items[Z]=Q;else if(_0.isPair(U))if(Z==="key")U.key=Q;else U.value=Q;else if(_0.isDocument(U))U.contents=Q;else{let J=_0.isAlias(U)?"alias":"scalar";throw Error(`Cannot replace node with ${J} parent`)}}g_.visit=P9;g_.visitAsync=A9});var IX=C((p_)=>{var jJ=l(),h_=o6(),m_={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},u_=(Z)=>Z.replace(/[!,[\]{}]/g,(X)=>m_[X]);class d0{constructor(Z,X){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},d0.defaultYaml,Z),this.tags=Object.assign({},d0.defaultTags,X)}clone(){let Z=new d0(this.yaml,this.tags);return Z.docStart=this.docStart,Z}atDocument(){let Z=new d0(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:d0.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},d0.defaultTags);break}return Z}add(Z,X){if(this.atNextDocument)this.yaml={explicit:d0.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},d0.defaultTags),this.atNextDocument=!1;let Q=Z.trim().split(/[ \t]+/),U=Q.shift();switch(U){case"%TAG":{if(Q.length!==2){if(X(0,"%TAG directive should contain exactly two parts"),Q.length<2)return!1}let[J,q]=Q;return this.tags[J]=q,!0}case"%YAML":{if(this.yaml.explicit=!0,Q.length!==1)return X(0,"%YAML directive should contain exactly one part"),!1;let[J]=Q;if(J==="1.1"||J==="1.2")return this.yaml.version=J,!0;else{let q=/^\d+\.\d+$/.test(J);return X(6,`Unsupported YAML version ${J}`,q),!1}}default:return X(0,`Unknown directive ${U}`,!0),!1}}tagName(Z,X){if(Z==="!")return"!";if(Z[0]!=="!")return X(`Not a valid tag: ${Z}`),null;if(Z[1]==="<"){let q=Z.slice(2,-1);if(q==="!"||q==="!!")return X(`Verbatim tags aren't resolved, so ${Z} is invalid.`),null;if(Z[Z.length-1]!==">")X("Verbatim tags must end with a >");return q}let[,Q,U]=Z.match(/^(.*!)([^!]*)$/s);if(!U)X(`The ${Z} tag has no suffix`);let J=this.tags[Q];if(J)try{return J+decodeURIComponent(U)}catch(q){return X(String(q)),null}if(Q==="!")return Z;return X(`Could not resolve tag: ${Z}`),null}tagString(Z){for(let[X,Q]of Object.entries(this.tags))if(Z.startsWith(Q))return X+u_(Z.substring(Q.length));return Z[0]==="!"?Z:`!<${Z}>`}toString(Z){let X=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],Q=Object.entries(this.tags),U;if(Z&&Q.length>0&&jJ.isNode(Z.contents)){let J={};h_.visit(Z.contents,(q,Y)=>{if(jJ.isNode(Y)&&Y.tag)J[Y.tag]=!0}),U=Object.keys(J)}else U=[];for(let[J,q]of Q){if(J==="!!"&&q==="tag:yaml.org,2002:")continue;if(!Z||U.some((Y)=>Y.startsWith(q)))X.push(`%TAG ${J} ${q}`)}return X.join(`
47
+ `)}}d0.defaultYaml={explicit:!1,version:"1.2"};d0.defaultTags={"!!":"tag:yaml.org,2002:"};p_.Directives=d0});var S9=C((s_)=>{var EJ=l(),d_=o6();function c_(Z){if(/[\x00-\x19\s,[\]{}]/.test(Z)){let Q=`Anchor must not contain whitespace or control characters: ${JSON.stringify(Z)}`;throw Error(Q)}return!0}function bJ(Z){let X=new Set;return d_.visit(Z,{Value(Q,U){if(U.anchor)X.add(U.anchor)}}),X}function IJ(Z,X){for(let Q=1;;++Q){let U=`${Z}${Q}`;if(!X.has(U))return U}}function i_(Z,X){let Q=[],U=new Map,J=null;return{onAnchor:(q)=>{Q.push(q),J??(J=bJ(Z));let Y=IJ(X,J);return J.add(Y),Y},setAnchors:()=>{for(let q of Q){let Y=U.get(q);if(typeof Y==="object"&&Y.anchor&&(EJ.isScalar(Y.node)||EJ.isCollection(Y.node)))Y.node.anchor=Y.anchor;else{let W=Error("Failed to resolve repeated object (this should not happen)");throw W.source=q,W}}},sourceObjects:U}}s_.anchorIsValid=c_;s_.anchorNames=bJ;s_.createNodeAnchors=i_;s_.findNewAnchor=IJ});var fX=C((t_)=>{function n6(Z,X,Q,U){if(U&&typeof U==="object")if(Array.isArray(U))for(let J=0,q=U.length;J<q;++J){let Y=U[J],W=n6(Z,U,String(J),Y);if(W===void 0)delete U[J];else if(W!==Y)U[J]=W}else if(U instanceof Map)for(let J of Array.from(U.keys())){let q=U.get(J),Y=n6(Z,U,J,q);if(Y===void 0)U.delete(J);else if(Y!==q)U.set(J,Y)}else if(U instanceof Set)for(let J of Array.from(U)){let q=n6(Z,U,J,J);if(q===void 0)U.delete(J);else if(q!==J)U.delete(J),U.add(q)}else for(let[J,q]of Object.entries(U)){let Y=n6(Z,U,J,q);if(Y===void 0)delete U[J];else if(Y!==q)U[J]=Y}return Z.call(X,Q,U)}t_.applyReviver=n6});var x1=C((XV)=>{var ZV=l();function fJ(Z,X,Q){if(Array.isArray(Z))return Z.map((U,J)=>fJ(U,String(J),Q));if(Z&&typeof Z.toJSON==="function"){if(!Q||!ZV.hasAnchor(Z))return Z.toJSON(X,Q);let U={aliasCount:0,count:1,res:void 0};Q.anchors.set(Z,U),Q.onCreate=(q)=>{U.res=q,delete Q.onCreate};let J=Z.toJSON(X,Q);if(Q.onCreate)Q.onCreate(J);return J}if(typeof Z==="bigint"&&!Q?.keep)return Number(Z);return Z}XV.toJS=fJ});var C9=C((qV)=>{var UV=fX(),kJ=l(),JV=x1();class yJ{constructor(Z){Object.defineProperty(this,kJ.NODE_TYPE,{value:Z})}clone(){let Z=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)Z.range=this.range.slice();return Z}toJS(Z,{mapAsMap:X,maxAliasCount:Q,onAnchor:U,reviver:J}={}){if(!kJ.isDocument(Z))throw TypeError("A document argument is required");let q={anchors:new Map,doc:Z,keep:!0,mapAsMap:X===!0,mapKeyWarned:!1,maxAliasCount:typeof Q==="number"?Q:100},Y=JV.toJS(this,"",q);if(typeof U==="function")for(let{count:W,res:$}of q.anchors.values())U($,W);return typeof J==="function"?UV.applyReviver(J,{"":Y},"",Y):Y}}qV.NodeBase=yJ});var t6=C((_V)=>{var WV=S9(),$V=o6(),i2=l(),LV=C9(),GV=x1();class gJ extends LV.NodeBase{constructor(Z){super(i2.ALIAS);this.source=Z,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(Z,X){let Q;if(X?.aliasResolveCache)Q=X.aliasResolveCache;else if(Q=[],$V.visit(Z,{Node:(J,q)=>{if(i2.isAlias(q)||i2.hasAnchor(q))Q.push(q)}}),X)X.aliasResolveCache=Q;let U=void 0;for(let J of Q){if(J===this)break;if(J.anchor===this.source)U=J}return U}toJSON(Z,X){if(!X)return{source:this.source};let{anchors:Q,doc:U,maxAliasCount:J}=X,q=this.resolve(U,X);if(!q){let W=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(W)}let Y=Q.get(q);if(!Y)GV.toJS(q,null,X),Y=Q.get(q);if(Y?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(J>=0){if(Y.count+=1,Y.aliasCount===0)Y.aliasCount=N9(U,q,Q);if(Y.count*Y.aliasCount>J)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return Y.res}toString(Z,X,Q){let U=`*${this.source}`;if(Z){if(WV.anchorIsValid(this.source),Z.options.verifyAliasOrder&&!Z.anchors.has(this.source)){let J=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(J)}if(Z.implicitKey)return`${U} `}return U}}function N9(Z,X,Q){if(i2.isAlias(X)){let U=X.resolve(Z),J=Q&&U&&Q.get(U);return J?J.count*J.aliasCount:0}else if(i2.isCollection(X)){let U=0;for(let J of X.items){let q=N9(Z,J,Q);if(q>U)U=q}return U}else if(i2.isPair(X)){let U=N9(Z,X.key,Q),J=N9(Z,X.value,Q);return Math.max(U,J)}return 1}_V.Alias=gJ});var W0=C((MV)=>{var HV=l(),zV=C9(),FV=x1(),BV=(Z)=>!Z||typeof Z!=="function"&&typeof Z!=="object";class Y2 extends zV.NodeBase{constructor(Z){super(HV.SCALAR);this.value=Z}toJSON(Z,X){return X?.keep?this.value:FV.toJS(this.value,Z,X)}toString(){return String(this.value)}}Y2.BLOCK_FOLDED="BLOCK_FOLDED";Y2.BLOCK_LITERAL="BLOCK_LITERAL";Y2.PLAIN="PLAIN";Y2.QUOTE_DOUBLE="QUOTE_DOUBLE";Y2.QUOTE_SINGLE="QUOTE_SINGLE";MV.Scalar=Y2;MV.isScalarValue=BV});var e6=C((PV)=>{var KV=t6(),W2=l(),vJ=W0(),TV="tag:yaml.org,2002:";function DV(Z,X,Q){if(X){let U=Q.filter((q)=>q.tag===X),J=U.find((q)=>!q.format)??U[0];if(!J)throw Error(`Tag ${X} not found`);return J}return Q.find((U)=>U.identify?.(Z)&&!U.format)}function wV(Z,X,Q){if(W2.isDocument(Z))Z=Z.contents;if(W2.isNode(Z))return Z;if(W2.isPair(Z)){let G=Q.schema[W2.MAP].createNode?.(Q.schema,null,Q);return G.items.push(Z),G}if(Z instanceof String||Z instanceof Number||Z instanceof Boolean||typeof BigInt<"u"&&Z instanceof BigInt)Z=Z.valueOf();let{aliasDuplicateObjects:U,onAnchor:J,onTagObj:q,schema:Y,sourceObjects:W}=Q,$=void 0;if(U&&Z&&typeof Z==="object")if($=W.get(Z),$)return $.anchor??($.anchor=J(Z)),new KV.Alias($.anchor);else $={anchor:null,node:null},W.set(Z,$);if(X?.startsWith("!!"))X=TV+X.slice(2);let L=DV(Z,X,Y.tags);if(!L){if(Z&&typeof Z.toJSON==="function")Z=Z.toJSON();if(!Z||typeof Z!=="object"){let G=new vJ.Scalar(Z);if($)$.node=G;return G}L=Z instanceof Map?Y[W2.MAP]:(Symbol.iterator in Object(Z))?Y[W2.SEQ]:Y[W2.MAP]}if(q)q(L),delete Q.onTagObj;let _=L?.createNode?L.createNode(Q.schema,Z,Q):typeof L?.nodeClass?.from==="function"?L.nodeClass.from(Q.schema,Z,Q):new vJ.Scalar(Z);if(X)_.tag=X;else if(!L.default)_.tag=L.tag;if($)$.node=_;return _}PV.createNode=wV});var j9=C((NV)=>{var SV=e6(),L1=l(),CV=C9();function kX(Z,X,Q){let U=Q;for(let J=X.length-1;J>=0;--J){let q=X[J];if(typeof q==="number"&&Number.isInteger(q)&&q>=0){let Y=[];Y[q]=U,U=Y}else U=new Map([[q,U]])}return SV.createNode(U,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:Z,sourceObjects:new Map})}var xJ=(Z)=>Z==null||typeof Z==="object"&&!!Z[Symbol.iterator]().next().done;class hJ extends CV.NodeBase{constructor(Z,X){super(Z);Object.defineProperty(this,"schema",{value:X,configurable:!0,enumerable:!1,writable:!0})}clone(Z){let X=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(Z)X.schema=Z;if(X.items=X.items.map((Q)=>L1.isNode(Q)||L1.isPair(Q)?Q.clone(Z):Q),this.range)X.range=this.range.slice();return X}addIn(Z,X){if(xJ(Z))this.add(X);else{let[Q,...U]=Z,J=this.get(Q,!0);if(L1.isCollection(J))J.addIn(U,X);else if(J===void 0&&this.schema)this.set(Q,kX(this.schema,U,X));else throw Error(`Expected YAML collection at ${Q}. Remaining path: ${U}`)}}deleteIn(Z){let[X,...Q]=Z;if(Q.length===0)return this.delete(X);let U=this.get(X,!0);if(L1.isCollection(U))return U.deleteIn(Q);else throw Error(`Expected YAML collection at ${X}. Remaining path: ${Q}`)}getIn(Z,X){let[Q,...U]=Z,J=this.get(Q,!0);if(U.length===0)return!X&&L1.isScalar(J)?J.value:J;else return L1.isCollection(J)?J.getIn(U,X):void 0}hasAllNullValues(Z){return this.items.every((X)=>{if(!L1.isPair(X))return!1;let Q=X.value;return Q==null||Z&&L1.isScalar(Q)&&Q.value==null&&!Q.commentBefore&&!Q.comment&&!Q.tag})}hasIn(Z){let[X,...Q]=Z;if(Q.length===0)return this.has(X);let U=this.get(X,!0);return L1.isCollection(U)?U.hasIn(Q):!1}setIn(Z,X){let[Q,...U]=Z;if(U.length===0)this.set(Q,X);else{let J=this.get(Q,!0);if(L1.isCollection(J))J.setIn(U,X);else if(J===void 0&&this.schema)this.set(Q,kX(this.schema,U,X));else throw Error(`Expected YAML collection at ${Q}. Remaining path: ${U}`)}}}NV.Collection=hJ;NV.collectionFromPath=kX;NV.isEmptyPath=xJ});var Z4=C((kV)=>{var IV=(Z)=>Z.replace(/^(?!$)(?: $)?/gm,"#");function yX(Z,X){if(/^\n+$/.test(Z))return Z.substring(1);return X?Z.replace(/^(?! *$)/gm,X):Z}var fV=(Z,X,Q)=>Z.endsWith(`
48
+ `)?yX(Q,X):Q.includes(`
4
49
  `)?`
5
- `+ZX(q,U):(X.endsWith(" ")?"":" ")+q;SH.indentComment=ZX;SH.lineComment=CH;SH.stringifyComment=NH});var Q3=R((gH)=>{function fH(X,U,q="flow",{indentAtStart:Z,lineWidth:Q=80,minContentWidth:G=20,onFold:Y,onOverflow:J}={}){if(!Q||Q<0)return X;if(Q<G)G=0;let H=Math.max(1+G,1+Q-U.length);if(X.length<=H)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,V=void 0,B=!1,z=-1,O=-1,D=-1;if(q==="block"){if(z=Z3(X,z,U.length),z!==-1)_=z+H}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=Z3(X,z,U.length);_=z+U.length+H,L=void 0}else{if(K===" "&&V&&V!==" "&&V!==`
7
- `&&V!=="\t"){let C=X[z+1];if(C&&C!==" "&&C!==`
8
- `&&C!=="\t")L=z}if(z>=_)if(L)W.push(L),_=L+H,L=void 0;else if(q==="quoted"){while(V===" "||V==="\t")V=K,K=X[z+=1],B=!0;let C=z>D+1?z-2:O-1;if($[C])return X;W.push(C),$[C]=!0,_=C+H,L=void 0}else B=!0}V=K}if(B&&J)J();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 Z3(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}gH.FOLD_BLOCK="block";gH.FOLD_FLOW="flow";gH.FOLD_QUOTED="quoted";gH.foldFlowLines=fH});var l2=R((pH)=>{var I0=i(),t0=Q3(),t6=(X,U)=>({indentAtStart:U?X.indent.length:X.indentAtStart,lineWidth:X.options.lineWidth,minContentWidth:X.options.minContentWidth}),e6=(X)=>/^(%|---|\.\.\.)/m.test(X);function xH(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 p2(X,U){let q=JSON.stringify(X);if(U.options.doubleQuotedAsJSON)return q;let{implicitKey:Z}=U,Q=U.options.doubleQuotedMinMultiLineLength,G=U.indent||(e6(X)?" ":""),Y="",J=0;for(let H=0,W=q[H];W;W=q[++H]){if(W===" "&&q[H+1]==="\\"&&q[H+2]==="n")Y+=q.slice(J,H)+"\\ ",H+=1,J=H,W="\\";if(W==="\\")switch(q[H+1]){case"u":{Y+=q.slice(J,H);let $=q.substr(H+2,4);switch($){case"0000":Y+="\\0";break;case"0007":Y+="\\a";break;case"000b":Y+="\\v";break;case"001b":Y+="\\e";break;case"0085":Y+="\\N";break;case"00a0":Y+="\\_";break;case"2028":Y+="\\L";break;case"2029":Y+="\\P";break;default:if($.substr(0,2)==="00")Y+="\\x"+$.substr(2);else Y+=q.substr(H,6)}H+=5,J=H+1}break;case"n":if(Z||q[H+2]==='"'||q.length<Q)H+=1;else{Y+=q.slice(J,H)+`
50
+ `+yX(Q,X):(Z.endsWith(" ")?"":" ")+Q;kV.indentComment=yX;kV.lineComment=fV;kV.stringifyComment=IV});var uJ=C((hV)=>{function xV(Z,X,Q="flow",{indentAtStart:U,lineWidth:J=80,minContentWidth:q=20,onFold:Y,onOverflow:W}={}){if(!J||J<0)return Z;if(J<q)q=0;let $=Math.max(1+q,1+J-X.length);if(Z.length<=$)return Z;let L=[],_={},G=J-X.length;if(typeof U==="number")if(U>J-Math.max(2,q))L.push(0);else G=J-U;let V=void 0,z=void 0,F=!1,H=-1,B=-1,T=-1;if(Q==="block"){if(H=mJ(Z,H,X.length),H!==-1)G=H+$}for(let K;K=Z[H+=1];){if(Q==="quoted"&&K==="\\"){switch(B=H,Z[H+1]){case"x":H+=3;break;case"u":H+=5;break;case"U":H+=9;break;default:H+=1}T=H}if(K===`
51
+ `){if(Q==="block")H=mJ(Z,H,X.length);G=H+X.length+$,V=void 0}else{if(K===" "&&z&&z!==" "&&z!==`
52
+ `&&z!=="\t"){let w=Z[H+1];if(w&&w!==" "&&w!==`
53
+ `&&w!=="\t")V=H}if(H>=G)if(V)L.push(V),G=V+$,V=void 0;else if(Q==="quoted"){while(z===" "||z==="\t")z=K,K=Z[H+=1],F=!0;let w=H>T+1?H-2:B-1;if(_[w])return Z;L.push(w),_[w]=!0,G=w+$,V=void 0}else F=!0}z=K}if(F&&W)W();if(L.length===0)return Z;if(Y)Y();let D=Z.slice(0,L[0]);for(let K=0;K<L.length;++K){let w=L[K],S=L[K+1]||Z.length;if(w===0)D=`
54
+ ${X}${Z.slice(0,S)}`;else{if(Q==="quoted"&&_[w])D+=`${Z[w]}\\`;D+=`
55
+ ${X}${Z.slice(w+1,S)}`}}return D}function mJ(Z,X,Q){let U=X,J=X+1,q=Z[J];while(q===" "||q==="\t")if(X<J+Q)q=Z[++X];else{do q=Z[++X];while(q&&q!==`
56
+ `);U=X,J=X+1,q=Z[J]}return U}hV.FOLD_BLOCK="block";hV.FOLD_FLOW="flow";hV.FOLD_QUOTED="quoted";hV.foldFlowLines=xV});var Q4=C((sV)=>{var e0=W0(),h1=uJ(),b9=(Z,X)=>({indentAtStart:X?Z.indent.length:Z.indentAtStart,lineWidth:Z.options.lineWidth,minContentWidth:Z.options.minContentWidth}),I9=(Z)=>/^(%|---|\.\.\.)/m.test(Z);function dV(Z,X,Q){if(!X||X<0)return!1;let U=X-Q,J=Z.length;if(J<=U)return!1;for(let q=0,Y=0;q<J;++q)if(Z[q]===`
57
+ `){if(q-Y>U)return!0;if(Y=q+1,J-Y<=U)return!1}return!0}function X4(Z,X){let Q=JSON.stringify(Z);if(X.options.doubleQuotedAsJSON)return Q;let{implicitKey:U}=X,J=X.options.doubleQuotedMinMultiLineLength,q=X.indent||(I9(Z)?" ":""),Y="",W=0;for(let $=0,L=Q[$];L;L=Q[++$]){if(L===" "&&Q[$+1]==="\\"&&Q[$+2]==="n")Y+=Q.slice(W,$)+"\\ ",$+=1,W=$,L="\\";if(L==="\\")switch(Q[$+1]){case"u":{Y+=Q.slice(W,$);let _=Q.substr($+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($,6)}$+=5,W=$+1}break;case"n":if(U||Q[$+2]==='"'||Q.length<J)$+=1;else{Y+=Q.slice(W,$)+`
13
58
 
14
- `;while(q[H+2]==="\\"&&q[H+3]==="n"&&q[H+4]!=='"')Y+=`
15
- `,H+=2;if(Y+=G,q[H+2]===" ")Y+="\\";H+=1,J=H+1}break;default:H+=1}}return Y=J?Y+q.slice(J):q,Z?Y:t0.foldFlowLines(Y,G,t0.FOLD_QUOTED,t6(U,!1))}function QX(X,U){if(U.options.singleQuote===!1||U.implicitKey&&X.includes(`
16
- `)||/[ \t]\n|\n[ \t]/.test(X))return p2(X,U);let q=U.indent||(e6(X)?" ":""),Z="'"+X.replace(/'/g,"''").replace(/\n+/g,`$&
17
- ${q}`)+"'";return U.implicitKey?Z:t0.foldFlowLines(Z,q,t0.FOLD_FLOW,t6(U,!1))}function o1(X,U){let{singleQuote:q}=U.options,Z;if(q===!1)Z=p2;else{let Q=X.includes('"'),G=X.includes("'");if(Q&&!G)Z=QX;else if(G&&!Q)Z=p2;else Z=q?QX:p2}return Z(X,U)}var GX;try{GX=new RegExp(`(^|(?<!
59
+ `;while(Q[$+2]==="\\"&&Q[$+3]==="n"&&Q[$+4]!=='"')Y+=`
60
+ `,$+=2;if(Y+=q,Q[$+2]===" ")Y+="\\";$+=1,W=$+1}break;default:$+=1}}return Y=W?Y+Q.slice(W):Q,U?Y:h1.foldFlowLines(Y,q,h1.FOLD_QUOTED,b9(X,!1))}function gX(Z,X){if(X.options.singleQuote===!1||X.implicitKey&&Z.includes(`
61
+ `)||/[ \t]\n|\n[ \t]/.test(Z))return X4(Z,X);let Q=X.indent||(I9(Z)?" ":""),U="'"+Z.replace(/'/g,"''").replace(/\n+/g,`$&
62
+ ${Q}`)+"'";return X.implicitKey?U:h1.foldFlowLines(U,Q,h1.FOLD_FLOW,b9(X,!1))}function s2(Z,X){let{singleQuote:Q}=X.options,U;if(Q===!1)U=X4;else{let J=Z.includes('"'),q=Z.includes("'");if(J&&!q)U=gX;else if(q&&!J)U=X4;else U=Q?gX:X4}return U(Z,X)}var vX;try{vX=new RegExp(`(^|(?<!
18
63
  ))
19
64
  +(?!
20
- |$)`,"g")}catch{GX=/\n+(?!\n|$)/g}function n6({comment:X,type:U,value:q},Z,Q,G){let{blockQuote:Y,commentString:J,lineWidth:H}=Z.options;if(!Y||/\n[\t ]+$/.test(q))return o1(q,Z);let W=Z.indent||(Z.forceBlockIndent||e6(q)?" ":""),$=Y==="literal"?!0:Y==="folded"||U===I0.Scalar.BLOCK_FOLDED?!1:U===I0.Scalar.BLOCK_LITERAL?!0:!xH(q,H,W.length);if(!q)return $?`|
65
+ |$)`,"g")}catch{vX=/\n+(?!\n|$)/g}function E9({comment:Z,type:X,value:Q},U,J,q){let{blockQuote:Y,commentString:W,lineWidth:$}=U.options;if(!Y||/\n[\t ]+$/.test(Q))return s2(Q,U);let L=U.indent||(U.forceBlockIndent||I9(Q)?" ":""),_=Y==="literal"?!0:Y==="folded"||X===e0.Scalar.BLOCK_FOLDED?!1:X===e0.Scalar.BLOCK_LITERAL?!0:!dV(Q,$,L.length);if(!Q)return _?`|
21
66
  `:`>
22
- `;let _,L;for(L=q.length;L>0;--L){let N=q[L-1];if(N!==`
23
- `&&N!=="\t"&&N!==" ")break}let V=q.substring(L),B=V.indexOf(`
24
- `);if(B===-1)_="-";else if(q===V||B!==V.length-1){if(_="+",G)G()}else _="";if(V){if(q=q.slice(0,-V.length),V[V.length-1]===`
25
- `)V=V.slice(0,-1);V=V.replace(GX,`$&${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+=" "+J(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}`),b=!1,m=t6(Z,!0);if(Y!=="folded"&&U!==I0.Scalar.BLOCK_FOLDED)m.onOverflow=()=>{b=!0};let w=t0.foldFlowLines(`${P}${N}${V}`,W,t0.FOLD_BLOCK,m);if(!b)return`>${C}
28
- ${W}${w}`}return q=q.replace(/\n+/g,`$&${W}`),`|${C}
29
- ${W}${P}${q}${V}`}function uH(X,U,q,Z){let{type:Q,value:G}=X,{actualString:Y,implicitKey:J,indent:H,indentStep:W,inFlow:$}=U;if(J&&G.includes(`
30
- `)||$&&/[[\]{},]/.test(G))return o1(G,U);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(G))return J||$||!G.includes(`
31
- `)?o1(G,U):n6(X,U,q,Z);if(!J&&!$&&Q!==I0.Scalar.PLAIN&&G.includes(`
32
- `))return n6(X,U,q,Z);if(e6(G)){if(H==="")return U.forceBlockIndent=!0,n6(X,U,q,Z);else if(J&&H===W)return o1(G,U)}let _=G.replace(/\n+/g,`$&
33
- ${H}`);if(Y){let L=(z)=>z.default&&z.tag!=="tag:yaml.org,2002:str"&&z.test?.test(_),{compat:V,tags:B}=U.doc.schema;if(B.some(L)||V?.some(L))return o1(G,U)}return J?_:t0.foldFlowLines(_,H,t0.FOLD_FLOW,t6(U,!1))}function mH(X,U,q,Z){let{implicitKey:Q,inFlow:G}=U,Y=typeof X.value==="string"?X:Object.assign({},X,{value:String(X.value)}),{type:J}=X;if(J!==I0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(Y.value))J=I0.Scalar.QUOTE_DOUBLE}let H=($)=>{switch($){case I0.Scalar.BLOCK_FOLDED:case I0.Scalar.BLOCK_LITERAL:return Q||G?o1(Y.value,U):n6(Y,U,q,Z);case I0.Scalar.QUOTE_DOUBLE:return p2(Y.value,U);case I0.Scalar.QUOTE_SINGLE:return QX(Y.value,U);case I0.Scalar.PLAIN:return uH(Y,U,q,Z);default:return null}},W=H(J);if(W===null){let{defaultKeyType:$,defaultStringType:_}=U.options,L=Q&&$||_;if(W=H(L),W===null)throw Error(`Unsupported default string type ${L}`)}return W}pH.stringifyString=mH});var d2=R((nH)=>{var dH=s6(),e0=k(),cH=m2(),iH=l2();function sH(X,U){let q=Object.assign({blockQuote:!0,commentString:cH.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},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 oH(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(e0.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 rH(X,U,{anchors:q,doc:Z}){if(!Z.directives)return"";let Q=[],G=(e0.isScalar(X)||e0.isCollection(X))&&X.anchor;if(G&&dH.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 aH(X,U,q,Z){if(e0.isPair(X))return X.toString(U,q,Z);if(e0.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=e0.isNode(X)?X:U.doc.createNode(X,{onTagObj:(H)=>Q=H});Q??(Q=oH(U.doc.schema.tags,G));let Y=rH(G,Q,U);if(Y.length>0)U.indentAtStart=(U.indentAtStart??0)+Y.length+1;let J=typeof Q.stringify==="function"?Q.stringify(G,U,q,Z):e0.isScalar(G)?iH.stringifyString(G,U,q,Z):G.toString(U,q,Z);if(!Y)return J;return e0.isScalar(G)||J[0]==="{"||J[0]==="["?`${Y} ${J}`:`${Y}
34
- ${U.indent}${J}`}nH.createStringifyContext=sH;nH.stringify=aH});var J3=R((UW)=>{var m0=k(),G3=i(),Y3=d2(),c2=m2();function XW({key:X,value:U},q,Z,Q){let{allNullValues:G,doc:Y,indent:J,indentStep:H,options:{commentString:W,indentSeq:$,simpleKeys:_}}=q,L=m0.isNode(X)&&X.comment||null;if(_){if(L)throw Error("With simple keys, key nodes cannot have comments");if(m0.isCollection(X)||!m0.isNode(X)&&typeof X==="object")throw Error("With simple keys, collection cannot be used as a key value")}let V=!_&&(!X||L&&U==null&&!q.inFlow||m0.isCollection(X)||(m0.isScalar(X)?X.type===G3.Scalar.BLOCK_FOLDED||X.type===G3.Scalar.BLOCK_LITERAL:typeof X==="object"));q=Object.assign({},q,{allNullValues:!1,implicitKey:!V&&(_||!G),indent:J+H});let B=!1,z=!1,O=Y3.stringify(X,q,()=>B=!0,()=>z=!0);if(!V&&!q.inFlow&&O.length>1024){if(_)throw Error("With simple keys, single line scalar must not span more than 1024 characters");V=!0}if(q.inFlow){if(G||U==null){if(B&&Z)Z();return O===""?"?":V?`? ${O}`:O}}else if(G&&!_||U==null&&V){if(O=`? ${O}`,L&&!B)O+=c2.lineComment(O,q.indent,W(L));else if(z&&Q)Q();return O}if(B)L=null;if(V){if(L)O+=c2.lineComment(O,q.indent,W(L));O=`? ${O}
35
- ${J}:`}else if(O=`${O}:`,L)O+=c2.lineComment(O,q.indent,W(L));let D,P,K;if(m0.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,!V&&!L&&m0.isScalar(U))q.indentAtStart=O.length+1;if(z=!1,!$&&H.length>=2&&!q.inFlow&&!V&&m0.isSeq(U)&&!U.flow&&!U.tag&&!U.anchor)q.indent=q.indent.substring(2);let C=!1,N=Y3.stringify(U,q,()=>C=!0,()=>z=!0),b=" ";if(L||D||P){if(b=D?`
36
- `:"",P){let m=W(P);b+=`
37
- ${c2.indentComment(m,q.indent)}`}if(N===""&&!q.inFlow){if(b===`
38
- `&&K)b=`
67
+ `;let G,V;for(V=Q.length;V>0;--V){let S=Q[V-1];if(S!==`
68
+ `&&S!=="\t"&&S!==" ")break}let z=Q.substring(V),F=z.indexOf(`
69
+ `);if(F===-1)G="-";else if(Q===z||F!==z.length-1){if(G="+",q)q()}else G="";if(z){if(Q=Q.slice(0,-z.length),z[z.length-1]===`
70
+ `)z=z.slice(0,-1);z=z.replace(vX,`$&${L}`)}let H=!1,B,T=-1;for(B=0;B<Q.length;++B){let S=Q[B];if(S===" ")H=!0;else if(S===`
71
+ `)T=B;else break}let D=Q.substring(0,T<B?T+1:B);if(D)Q=Q.substring(D.length),D=D.replace(/\n+/g,`$&${L}`);let w=(H?L?"2":"1":"")+G;if(Z){if(w+=" "+W(Z.replace(/ ?[\r\n]+/g," ")),J)J()}if(!_){let S=Q.replace(/\n+/g,`
72
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${L}`),j=!1,v=b9(U,!0);if(Y!=="folded"&&X!==e0.Scalar.BLOCK_FOLDED)v.onOverflow=()=>{j=!0};let N=h1.foldFlowLines(`${D}${S}${z}`,L,h1.FOLD_BLOCK,v);if(!j)return`>${w}
73
+ ${L}${N}`}return Q=Q.replace(/\n+/g,`$&${L}`),`|${w}
74
+ ${L}${D}${Q}${z}`}function cV(Z,X,Q,U){let{type:J,value:q}=Z,{actualString:Y,implicitKey:W,indent:$,indentStep:L,inFlow:_}=X;if(W&&q.includes(`
75
+ `)||_&&/[[\]{},]/.test(q))return s2(q,X);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(q))return W||_||!q.includes(`
76
+ `)?s2(q,X):E9(Z,X,Q,U);if(!W&&!_&&J!==e0.Scalar.PLAIN&&q.includes(`
77
+ `))return E9(Z,X,Q,U);if(I9(q)){if($==="")return X.forceBlockIndent=!0,E9(Z,X,Q,U);else if(W&&$===L)return s2(q,X)}let G=q.replace(/\n+/g,`$&
78
+ ${$}`);if(Y){let V=(H)=>H.default&&H.tag!=="tag:yaml.org,2002:str"&&H.test?.test(G),{compat:z,tags:F}=X.doc.schema;if(F.some(V)||z?.some(V))return s2(q,X)}return W?G:h1.foldFlowLines(G,$,h1.FOLD_FLOW,b9(X,!1))}function iV(Z,X,Q,U){let{implicitKey:J,inFlow:q}=X,Y=typeof Z.value==="string"?Z:Object.assign({},Z,{value:String(Z.value)}),{type:W}=Z;if(W!==e0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(Y.value))W=e0.Scalar.QUOTE_DOUBLE}let $=(_)=>{switch(_){case e0.Scalar.BLOCK_FOLDED:case e0.Scalar.BLOCK_LITERAL:return J||q?s2(Y.value,X):E9(Y,X,Q,U);case e0.Scalar.QUOTE_DOUBLE:return X4(Y.value,X);case e0.Scalar.QUOTE_SINGLE:return gX(Y.value,X);case e0.Scalar.PLAIN:return cV(Y,X,Q,U);default:return null}},L=$(W);if(L===null){let{defaultKeyType:_,defaultStringType:G}=X.options,V=J&&_||G;if(L=$(V),L===null)throw Error(`Unsupported default string type ${V}`)}return L}sV.stringifyString=iV});var U4=C((QH)=>{var rV=S9(),m1=l(),oV=Z4(),nV=Q4();function tV(Z,X){let Q=Object.assign({blockQuote:!0,commentString:oV.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},Z.schema.toStringOptions,X),U;switch(Q.collectionStyle){case"block":U=!1;break;case"flow":U=!0;break;default:U=null}return{anchors:new Set,doc:Z,flowCollectionPadding:Q.flowCollectionPadding?" ":"",indent:"",indentStep:typeof Q.indent==="number"?" ".repeat(Q.indent):" ",inFlow:U,options:Q}}function eV(Z,X){if(X.tag){let J=Z.filter((q)=>q.tag===X.tag);if(J.length>0)return J.find((q)=>q.format===X.format)??J[0]}let Q=void 0,U;if(m1.isScalar(X)){U=X.value;let J=Z.filter((q)=>q.identify?.(U));if(J.length>1){let q=J.filter((Y)=>Y.test);if(q.length>0)J=q}Q=J.find((q)=>q.format===X.format)??J.find((q)=>!q.format)}else U=X,Q=Z.find((J)=>J.nodeClass&&U instanceof J.nodeClass);if(!Q){let J=U?.constructor?.name??(U===null?"null":typeof U);throw Error(`Tag not resolved for ${J} value`)}return Q}function ZH(Z,X,{anchors:Q,doc:U}){if(!U.directives)return"";let J=[],q=(m1.isScalar(Z)||m1.isCollection(Z))&&Z.anchor;if(q&&rV.anchorIsValid(q))Q.add(q),J.push(`&${q}`);let Y=Z.tag??(X.default?null:X.tag);if(Y)J.push(U.directives.tagString(Y));return J.join(" ")}function XH(Z,X,Q,U){if(m1.isPair(Z))return Z.toString(X,Q,U);if(m1.isAlias(Z)){if(X.doc.directives)return Z.toString(X);if(X.resolvedAliases?.has(Z))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(X.resolvedAliases)X.resolvedAliases.add(Z);else X.resolvedAliases=new Set([Z]);Z=Z.resolve(X.doc)}}let J=void 0,q=m1.isNode(Z)?Z:X.doc.createNode(Z,{onTagObj:($)=>J=$});J??(J=eV(X.doc.schema.tags,q));let Y=ZH(q,J,X);if(Y.length>0)X.indentAtStart=(X.indentAtStart??0)+Y.length+1;let W=typeof J.stringify==="function"?J.stringify(q,X,Q,U):m1.isScalar(q)?nV.stringifyString(q,X,Q,U):q.toString(X,Q,U);if(!Y)return W;return m1.isScalar(q)||W[0]==="{"||W[0]==="["?`${Y} ${W}`:`${Y}
79
+ ${X.indent}${W}`}QH.createStringifyContext=tV;QH.stringify=XH});var dJ=C((YH)=>{var w1=l(),pJ=W0(),lJ=U4(),J4=Z4();function qH({key:Z,value:X},Q,U,J){let{allNullValues:q,doc:Y,indent:W,indentStep:$,options:{commentString:L,indentSeq:_,simpleKeys:G}}=Q,V=w1.isNode(Z)&&Z.comment||null;if(G){if(V)throw Error("With simple keys, key nodes cannot have comments");if(w1.isCollection(Z)||!w1.isNode(Z)&&typeof Z==="object")throw Error("With simple keys, collection cannot be used as a key value")}let z=!G&&(!Z||V&&X==null&&!Q.inFlow||w1.isCollection(Z)||(w1.isScalar(Z)?Z.type===pJ.Scalar.BLOCK_FOLDED||Z.type===pJ.Scalar.BLOCK_LITERAL:typeof Z==="object"));Q=Object.assign({},Q,{allNullValues:!1,implicitKey:!z&&(G||!q),indent:W+$});let F=!1,H=!1,B=lJ.stringify(Z,Q,()=>F=!0,()=>H=!0);if(!z&&!Q.inFlow&&B.length>1024){if(G)throw Error("With simple keys, single line scalar must not span more than 1024 characters");z=!0}if(Q.inFlow){if(q||X==null){if(F&&U)U();return B===""?"?":z?`? ${B}`:B}}else if(q&&!G||X==null&&z){if(B=`? ${B}`,V&&!F)B+=J4.lineComment(B,Q.indent,L(V));else if(H&&J)J();return B}if(F)V=null;if(z){if(V)B+=J4.lineComment(B,Q.indent,L(V));B=`? ${B}
80
+ ${W}:`}else if(B=`${B}:`,V)B+=J4.lineComment(B,Q.indent,L(V));let T,D,K;if(w1.isNode(X))T=!!X.spaceBefore,D=X.commentBefore,K=X.comment;else if(T=!1,D=null,K=null,X&&typeof X==="object")X=Y.createNode(X);if(Q.implicitKey=!1,!z&&!V&&w1.isScalar(X))Q.indentAtStart=B.length+1;if(H=!1,!_&&$.length>=2&&!Q.inFlow&&!z&&w1.isSeq(X)&&!X.flow&&!X.tag&&!X.anchor)Q.indent=Q.indent.substring(2);let w=!1,S=lJ.stringify(X,Q,()=>w=!0,()=>H=!0),j=" ";if(V||T||D){if(j=T?`
81
+ `:"",D){let v=L(D);j+=`
82
+ ${J4.indentComment(v,Q.indent)}`}if(S===""&&!Q.inFlow){if(j===`
83
+ `&&K)j=`
39
84
 
40
- `}else b+=`
41
- ${q.indent}`}else if(!V&&m0.isCollection(U)){let m=N[0],w=N.indexOf(`
42
- `),s=w!==-1,p0=q.inFlow??U.flow??U.items.length===0;if(s||!p0){let M1=!1;if(s&&(m==="&"||m==="!")){let o=N.indexOf(" ");if(m==="&"&&o!==-1&&o<w&&N[o+1]==="!")o=N.indexOf(" ",o+1);if(o===-1||w<o)M1=!0}if(!M1)b=`
43
- ${q.indent}`}}else if(N===""||N[0]===`
44
- `)b="";if(O+=b+N,q.inFlow){if(C&&Z)Z()}else if(K&&!C)O+=c2.lineComment(O,q.indent,W(K));else if(z&&Q)Q();return O}UW.stringifyPair=XW});var YX=R((GW)=>{var H3=w1("process");function ZW(X,...U){if(X==="debug")console.log(...U)}function QW(X,U){if(X==="debug"||X==="warn")if(typeof H3.emitWarning==="function")H3.emitWarning(U);else console.warn(U)}GW.debug=ZW;GW.warn=QW});var q4=R((WW)=>{var i2=k(),W3=i(),X4="<<",U4={identify:(X)=>X===X4||typeof X==="symbol"&&X.description===X4,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new W3.Scalar(Symbol(X4)),{addToJSMap:_3}),stringify:()=>X4},HW=(X,U)=>(U4.identify(U)||i2.isScalar(U)&&(!U.type||U.type===W3.Scalar.PLAIN)&&U4.identify(U.value))&&X?.doc.schema.tags.some((q)=>q.tag===U4.tag&&q.default);function _3(X,U,q){if(q=X&&i2.isAlias(q)?q.resolve(X.doc):q,i2.isSeq(q))for(let Z of q.items)JX(X,U,Z);else if(Array.isArray(q))for(let Z of q)JX(X,U,Z);else JX(X,U,q)}function JX(X,U,q){let Z=X&&i2.isAlias(q)?q.resolve(X.doc):q;if(!i2.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}WW.addMergeToJSMap=_3;WW.isMergeKey=HW;WW.merge=U4});var WX=R((OW)=>{var zW=YX(),$3=q4(),FW=d2(),L3=k(),HX=n0();function VW(X,U,{key:q,value:Z}){if(L3.isNode(q)&&q.addToJSMap)q.addToJSMap(X,U,Z);else if($3.isMergeKey(X,q))$3.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=AW(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 AW(X,U,q){if(U===null)return"";if(typeof U!=="object")return String(U);if(L3.isNode(X)&&q?.doc){let Z=FW.createStringifyContext(q.doc,{});Z.anchors=new Set;for(let G of q.anchors.keys())Z.anchors.add(G.anchor);Z.inFlow=!0,Z.inStringifyKey=!0;let Q=X.toString(Z);if(!q.mapKeyWarned){let G=JSON.stringify(Q);if(G.length>40)G=G.substring(0,36)+'..."';zW.warn(q.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${G}. Set mapAsMap: true to use object keys.`),q.mapKeyWarned=!0}return Q}return JSON.stringify(U)}OW.addPairToJSMap=VW});var X1=R((MW)=>{var z3=u2(),BW=J3(),RW=WX(),Z4=k();function DW(X,U,q){let Z=z3.createNode(X,void 0,q),Q=z3.createNode(U,void 0,q);return new Q4(Z,Q)}class Q4{constructor(X,U=null){Object.defineProperty(this,Z4.NODE_TYPE,{value:Z4.PAIR}),this.key=X,this.value=U}clone(X){let{key:U,value:q}=this;if(Z4.isNode(U))U=U.clone(X);if(Z4.isNode(q))q=q.clone(X);return new Q4(U,q)}toJSON(X,U){let q=U?.mapAsMap?new Map:{};return RW.addPairToJSMap(U,q,this)}toString(X,U,q){return X?.doc?BW.stringifyPair(this,X,U,q):JSON.stringify(this)}}MW.Pair=Q4;MW.createPair=DW});var _X=R((CW)=>{var A1=k(),F3=d2(),G4=m2();function IW(X,U,q){return(U.inFlow??X.flow?NW:KW)(X,U,q)}function KW({comment:X,items:U},q,{blockItemPrefix:Z,flowChars:Q,itemIndent:G,onChompKeep:Y,onComment:J}){let{indent:H,options:{commentString:W}}=q,$=Object.assign({},q,{indent:G,type:null}),_=!1,L=[];for(let B=0;B<U.length;++B){let z=U[B],O=null;if(A1.isNode(z)){if(!_&&z.spaceBefore)L.push("");if(Y4(q,L,z.commentBefore,_),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("");Y4(q,L,P.commentBefore,_)}}_=!1;let D=F3.stringify(z,$,()=>O=null,()=>_=!0);if(O)D+=G4.lineComment(D,G,W(O));if(_&&O)_=!1;L.push(Z+D)}let V;if(L.length===0)V=Q.start+Q.end;else{V=L[0];for(let B=1;B<L.length;++B){let z=L[B];V+=z?`
45
- ${H}${z}`:`
46
- `}}if(X){if(V+=`
47
- `+G4.indentComment(W(X),H),J)J()}else if(_&&Y)Y();return V}function NW({items:X},U,{flowChars:q,itemIndent:Z}){let{indent:Q,indentStep:G,flowCollectionPadding:Y,options:{commentString:J}}=U;Z+=G;let H=Object.assign({},U,{indent:Z,inFlow:!0,type:null}),W=!1,$=0,_=[];for(let B=0;B<X.length;++B){let z=X[B],O=null;if(A1.isNode(z)){if(z.spaceBefore)_.push("");if(Y4(U,_,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)_.push("");if(Y4(U,_,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=F3.stringify(z,H,()=>O=null);if(B<X.length-1)D+=",";if(O)D+=G4.lineComment(D,Z,J(O));if(!W&&(_.length>$||D.includes(`
48
- `)))W=!0;_.push(D),$=_.length}let{start:L,end:V}=q;if(_.length===0)return L+V;else{if(!W){let B=_.reduce((z,O)=>z+O.length+2,2);W=U.options.lineWidth>0&&B>U.options.lineWidth}if(W){let B=L;for(let z of _)B+=z?`
49
- ${G}${Q}${z}`:`
50
- `;return`${B}
51
- ${Q}${V}`}else return`${L}${Y}${_.join(" ")}${Y}${V}`}}function Y4({indent:X,options:{commentString:U}},q,Z,Q){if(Z&&Q)Z=Z.replace(/^\n+/,"");if(Z){let G=G4.indentComment(U(Z),X);q.push(G.trimStart())}}CW.stringifyCollection=IW});var q1=R((gW)=>{var EW=_X(),jW=WX(),bW=a6(),U1=k(),J4=X1(),fW=i();function s2(X,U){let q=U1.isScalar(U)?U.value:U;for(let Z of X)if(U1.isPair(Z)){if(Z.key===U||Z.key===q)return Z;if(U1.isScalar(Z.key)&&Z.key.value===q)return Z}return}class V3 extends bW.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(X){super(U1.MAP,X);this.items=[]}static from(X,U,q){let{keepUndefined:Z,replacer:Q}=q,G=new this(X),Y=(J,H)=>{if(typeof Q==="function")H=Q.call(U,J,H);else if(Array.isArray(Q)&&!Q.includes(J))return;if(H!==void 0||Z)G.items.push(J4.createPair(J,H,q))};if(U instanceof Map)for(let[J,H]of U)Y(J,H);else if(U&&typeof U==="object")for(let J of Object.keys(U))Y(J,U[J]);if(typeof X.sortMapEntries==="function")G.items.sort(X.sortMapEntries);return G}add(X,U){let q;if(U1.isPair(X))q=X;else if(!X||typeof X!=="object"||!("key"in X))q=new J4.Pair(X,X?.value);else q=new J4.Pair(X.key,X.value);let Z=s2(this.items,q.key),Q=this.schema?.sortMapEntries;if(Z){if(!U)throw Error(`Key ${q.key} already set`);if(U1.isScalar(Z.value)&&fW.isScalarValue(q.value))Z.value.value=q.value;else Z.value=q.value}else if(Q){let G=this.items.findIndex((Y)=>Q(q,Y)<0);if(G===-1)this.items.push(q);else this.items.splice(G,0,q)}else this.items.push(q)}delete(X){let U=s2(this.items,X);if(!U)return!1;return this.items.splice(this.items.indexOf(U),1).length>0}get(X,U){let Z=s2(this.items,X)?.value;return(!U&&U1.isScalar(Z)?Z.value:Z)??void 0}has(X){return!!s2(this.items,X)}set(X,U){this.add(new J4.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)jW.addPairToJSMap(U,Z,Q);return Z}toString(X,U,q){if(!X)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(!X.allNullValues&&this.hasAllNullValues(!1))X=Object.assign({},X,{allNullValues:!0});return EW.stringifyCollection(this,X,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:X.indent||"",onChompKeep:q,onComment:U})}}gW.YAMLMap=V3;gW.findPair=s2});var r1=R((xW)=>{var vW=k(),A3=q1(),hW={collection:"map",default:!0,nodeClass:A3.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(X,U){if(!vW.isMap(X))U("Expected a mapping for this tag");return X},createNode:(X,U,q)=>A3.YAMLMap.from(X,U,q)};xW.map=hW});var Z1=R((iW)=>{var mW=u2(),pW=_X(),lW=a6(),W4=k(),dW=i(),cW=n0();class O3 extends lW.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(X){super(W4.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&&W4.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(W4.isScalar(Z)&&dW.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(cW.toJS(Q,String(Z++),U));return q}toString(X,U,q){if(!X)return JSON.stringify(this);return pW.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 J=U instanceof Set?Y:String(G++);Y=Z.call(U,J,Y)}Q.items.push(mW.createNode(Y,void 0,q))}}return Q}}function H4(X){let U=W4.isScalar(X)?X.value:X;if(U&&typeof U==="string")U=Number(U);return typeof U==="number"&&Number.isInteger(U)&&U>=0?U:null}iW.YAMLSeq=O3});var a1=R((aW)=>{var oW=k(),T3=Z1(),rW={collection:"seq",default:!0,nodeClass:T3.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(X,U){if(!oW.isSeq(X))U("Expected a sequence for this tag");return X},createNode:(X,U,q)=>T3.YAMLSeq.from(X,U,q)};aW.seq=rW});var o2=R((X_)=>{var tW=l2(),eW={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),tW.stringifyString(X,U,q,Z)}};X_.string=eW});var _4=R((q_)=>{var B3=i(),R3={identify:(X)=>X==null,createNode:()=>new B3.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new B3.Scalar(null),stringify:({source:X},U)=>typeof X==="string"&&R3.test.test(X)?X:U.options.nullStr};q_.nullTag=R3});var $X=R((G_)=>{var Q_=i(),D3={identify:(X)=>typeof X==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(X)=>new Q_.Scalar(X[0]==="t"||X[0]==="T"),stringify({source:X,value:U},q){if(X&&D3.test.test(X)){let Z=X[0]==="t"||X[0]==="T";if(U===Z)return X}return U?q.options.trueStr:q.options.falseStr}};G_.boolTag=D3});var n1=R((H_)=>{function J_({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 J=U-(G.length-Y-1);while(J-- >0)G+="0"}return G}H_.stringifyNumber=J_});var zX=R((F_)=>{var __=i(),LX=n1(),$_={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:LX.stringifyNumber},L_={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():LX.stringifyNumber(X)}},z_={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 __.Scalar(parseFloat(X)),q=X.indexOf(".");if(q!==-1&&X[X.length-1]==="0")U.minFractionDigits=X.length-q-1;return U},stringify:LX.stringifyNumber};F_.float=z_;F_.floatExp=L_;F_.floatNaN=$_});var VX=R((D_)=>{var M3=n1(),$4=(X)=>typeof X==="bigint"||Number.isInteger(X),FX=(X,U,q,{intAsBigInt:Z})=>Z?BigInt(X):parseInt(X.substring(U),q);function w3(X,U,q){let{value:Z}=X;if($4(Z)&&Z>=0)return q+Z.toString(U);return M3.stringifyNumber(X)}var T_={identify:(X)=>$4(X)&&X>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(X,U,q)=>FX(X,2,8,q),stringify:(X)=>w3(X,8,"0o")},B_={identify:$4,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(X,U,q)=>FX(X,0,10,q),stringify:M3.stringifyNumber},R_={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)=>FX(X,2,16,q),stringify:(X)=>w3(X,16,"0x")};D_.int=B_;D_.intHex=R_;D_.intOct=T_});var P3=R((j_)=>{var I_=r1(),K_=_4(),N_=a1(),C_=o2(),S_=$X(),AX=zX(),OX=VX(),E_=[I_.map,N_.seq,C_.string,K_.nullTag,S_.boolTag,OX.intOct,OX.int,OX.intHex,AX.floatNaN,AX.floatExp,AX.float];j_.schema=E_});var K3=R((x_)=>{var f_=i(),g_=r1(),y_=a1();function I3(X){return typeof X==="bigint"||Number.isInteger(X)}var L4=({value:X})=>JSON.stringify(X),k_=[{identify:(X)=>typeof X==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(X)=>X,stringify:L4},{identify:(X)=>X==null,createNode:()=>new f_.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:L4},{identify:(X)=>typeof X==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(X)=>X==="true",stringify:L4},{identify:I3,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})=>I3(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:L4}],v_={default:!0,tag:"",test:/^/,resolve(X,U){return U(`Unresolved plain scalar ${JSON.stringify(X)}`),X}},h_=[g_.map,y_.seq].concat(k_,v_);x_.schema=h_});var BX=R((l_)=>{var r2=w1("buffer"),TX=i(),m_=l2(),p_={identify:(X)=>X instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(X,U){if(typeof r2.Buffer==="function")return r2.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,J;if(typeof r2.Buffer==="function")J=Y instanceof r2.Buffer?Y.toString("base64"):r2.Buffer.from(Y.buffer).toString("base64");else if(typeof btoa==="function"){let H="";for(let W=0;W<Y.length;++W)H+=String.fromCharCode(Y[W]);J=btoa(H)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(U??(U=TX.Scalar.BLOCK_LITERAL),U!==TX.Scalar.QUOTE_DOUBLE){let H=Math.max(Z.options.lineWidth-Z.indent.length,Z.options.minContentWidth),W=Math.ceil(J.length/H),$=Array(W);for(let _=0,L=0;_<W;++_,L+=H)$[_]=J.substr(L,H);J=$.join(U===TX.Scalar.BLOCK_LITERAL?`
52
- `:" ")}return m_.stringifyString({comment:X,type:U,value:J},Z,Q,G)}};l_.binary=p_});var F4=R((o_)=>{var z4=k(),RX=X1(),c_=i(),i_=Z1();function N3(X,U){if(z4.isSeq(X))for(let q=0;q<X.items.length;++q){let Z=X.items[q];if(z4.isPair(Z))continue;else if(z4.isMap(Z)){if(Z.items.length>1)U("Each pair must have its own sequence indicator");let Q=Z.items[0]||new RX.Pair(new c_.Scalar(null));if(Z.commentBefore)Q.key.commentBefore=Q.key.commentBefore?`${Z.commentBefore}
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}X.items[q]=z4.isPair(Z)?Z:new RX.Pair(Z)}else U("Expected a sequence for this tag");return X}function C3(X,U,q){let{replacer:Z}=q,Q=new i_.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 J,H;if(Array.isArray(Y))if(Y.length===2)J=Y[0],H=Y[1];else throw TypeError(`Expected [key, value] tuple: ${Y}`);else if(Y&&Y instanceof Object){let W=Object.keys(Y);if(W.length===1)J=W[0],H=Y[J];else throw TypeError(`Expected tuple with one key, not ${W.length} keys`)}else J=Y;Q.items.push(RX.createPair(J,H,q))}return Q}var s_={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:N3,createNode:C3};o_.createPairs=C3;o_.pairs=s_;o_.resolvePairs=N3});var MX=R((X$)=>{var S3=k(),DX=n0(),a2=q1(),t_=Z1(),E3=F4();class O1 extends t_.YAMLSeq{constructor(){super();this.add=a2.YAMLMap.prototype.add.bind(this),this.delete=a2.YAMLMap.prototype.delete.bind(this),this.get=a2.YAMLMap.prototype.get.bind(this),this.has=a2.YAMLMap.prototype.has.bind(this),this.set=a2.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(S3.isPair(Z))Q=DX.toJS(Z.key,"",U),G=DX.toJS(Z.value,Q,U);else Q=DX.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=E3.createPairs(X,U,q),Q=new this;return Q.items=Z.items,Q}}O1.tag="tag:yaml.org,2002:omap";var e_={collection:"seq",identify:(X)=>X instanceof Map,nodeClass:O1,default:!1,tag:"tag:yaml.org,2002:omap",resolve(X,U){let q=E3.resolvePairs(X,U),Z=[];for(let{key:Q}of q.items)if(S3.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)};X$.YAMLOMap=O1;X$.omap=e_});var y3=R((Z$)=>{var j3=i();function b3({value:X,source:U},q){if(U&&(X?f3:g3).test.test(U))return U;return X?q.options.trueStr:q.options.falseStr}var f3={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 j3.Scalar(!0),stringify:b3},g3={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 j3.Scalar(!1),stringify:b3};Z$.falseTag=g3;Z$.trueTag=f3});var k3=R((_$)=>{var Y$=i(),wX=n1(),J$={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:wX.stringifyNumber},H$={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():wX.stringifyNumber(X)}},W$={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 Y$.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:wX.stringifyNumber};_$.float=W$;_$.floatExp=H$;_$.floatNaN=J$});var h3=R((T$)=>{var v3=n1(),n2=(X)=>typeof X==="bigint"||Number.isInteger(X);function V4(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 PX(X,U,q){let{value:Z}=X;if(n2(Z)){let Q=Z.toString(U);return Z<0?"-"+q+Q.substr(1):q+Q}return v3.stringifyNumber(X)}var F$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(X,U,q)=>V4(X,2,2,q),stringify:(X)=>PX(X,2,"0b")},V$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(X,U,q)=>V4(X,1,8,q),stringify:(X)=>PX(X,8,"0")},A$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(X,U,q)=>V4(X,0,10,q),stringify:v3.stringifyNumber},O$={identify:n2,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(X,U,q)=>V4(X,2,16,q),stringify:(X)=>PX(X,16,"0x")};T$.int=A$;T$.intBin=F$;T$.intHex=O$;T$.intOct=V$});var IX=R((P$)=>{var T4=k(),A4=X1(),O4=q1();class T1 extends O4.YAMLMap{constructor(X){super(X);this.tag=T1.tag}add(X){let U;if(T4.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(!O4.findPair(this.items,U.key))this.items.push(U)}get(X,U){let q=O4.findPair(this.items,X);return!U&&T4.isPair(q)?T4.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=O4.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}}T1.tag="tag:yaml.org,2002:set";var w$={collection:"map",identify:(X)=>X instanceof Set,nodeClass:T1,default:!1,tag:"tag:yaml.org,2002:set",createNode:(X,U,q)=>T1.from(X,U,q),resolve(X,U){if(T4.isMap(X))if(X.hasAllNullValues(!0))return Object.assign(new T1,X);else U("Set items must all have null values");else U("Expected a mapping for this tag");return X}};P$.YAMLSet=T1;P$.set=w$});var NX=R((E$)=>{var N$=n1();function KX(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,J)=>Y*Q(60)+Q(J),Q(0));return q==="-"?Q(-1)*G:G}function x3(X){let{value:U}=X,q=(Y)=>Y;if(typeof U==="bigint")q=(Y)=>BigInt(Y);else if(isNaN(U)||!isFinite(U))return N$.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 C$={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})=>KX(X,q),stringify:x3},S$={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)=>KX(X,!1),stringify:x3},u3={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(u3.test);if(!U)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,q,Z,Q,G,Y,J]=U.map(Number),H=U[7]?Number((U[7]+"00").substr(1,3)):0,W=Date.UTC(q,Z-1,Q,G||0,Y||0,J||0,H),$=U[8];if($&&$!=="Z"){let _=KX($,!1);if(Math.abs(_)<30)_*=60;W-=60000*_}return new Date(W)},stringify:({value:X})=>X?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};E$.floatTime=S$;E$.intTime=C$;E$.timestamp=u3});var p3=R((d$)=>{var g$=r1(),y$=_4(),k$=a1(),v$=o2(),h$=BX(),m3=y3(),CX=k3(),B4=h3(),x$=q4(),u$=MX(),m$=F4(),p$=IX(),SX=NX(),l$=[g$.map,k$.seq,v$.string,y$.nullTag,m3.trueTag,m3.falseTag,B4.intBin,B4.intOct,B4.int,B4.intHex,CX.floatNaN,CX.floatExp,CX.float,h$.binary,x$.merge,u$.omap,m$.pairs,p$.set,SX.intTime,SX.floatTime,SX.timestamp];d$.schema=l$});var t3=R((e$)=>{var i3=r1(),i$=_4(),s3=a1(),s$=o2(),o$=$X(),EX=zX(),jX=VX(),r$=P3(),a$=K3(),o3=BX(),t2=q4(),r3=MX(),a3=F4(),l3=p3(),n3=IX(),R4=NX(),d3=new Map([["core",r$.schema],["failsafe",[i3.map,s3.seq,s$.string]],["json",a$.schema],["yaml11",l3.schema],["yaml-1.1",l3.schema]]),c3={binary:o3.binary,bool:o$.boolTag,float:EX.float,floatExp:EX.floatExp,floatNaN:EX.floatNaN,floatTime:R4.floatTime,int:jX.int,intHex:jX.intHex,intOct:jX.intOct,intTime:R4.intTime,map:i3.map,merge:t2.merge,null:i$.nullTag,omap:r3.omap,pairs:a3.pairs,seq:s3.seq,set:n3.set,timestamp:R4.timestamp},n$={"tag:yaml.org,2002:binary":o3.binary,"tag:yaml.org,2002:merge":t2.merge,"tag:yaml.org,2002:omap":r3.omap,"tag:yaml.org,2002:pairs":a3.pairs,"tag:yaml.org,2002:set":n3.set,"tag:yaml.org,2002:timestamp":R4.timestamp};function t$(X,U,q){let Z=d3.get(U);if(Z&&!X)return q&&!Z.includes(t2.merge)?Z.concat(t2.merge):Z.slice();let Q=Z;if(!Q)if(Array.isArray(X))Q=[];else{let G=Array.from(d3.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(t2.merge);return Q.reduce((G,Y)=>{let J=typeof Y==="string"?c3[Y]:Y;if(!J){let H=JSON.stringify(Y),W=Object.keys(c3).map(($)=>JSON.stringify($)).join(", ");throw Error(`Unknown custom tag ${H}; use one of ${W}`)}if(!G.includes(J))G.push(J);return G},[])}e$.coreKnownTags=n$;e$.getTags=t$});var gX=R((YL)=>{var bX=k(),qL=r1(),ZL=a1(),QL=o2(),D4=t3(),GL=(X,U)=>X.key<U.key?-1:X.key>U.key?1:0;class fX{constructor({compat:X,customTags:U,merge:q,resolveKnownTags:Z,schema:Q,sortMapEntries:G,toStringDefaults:Y}){this.compat=Array.isArray(X)?D4.getTags(X,"compat"):X?D4.getTags(null,X):null,this.name=typeof Q==="string"&&Q||"core",this.knownTags=Z?D4.coreKnownTags:{},this.tags=D4.getTags(U,this.name,q),this.toStringOptions=Y??null,Object.defineProperty(this,bX.MAP,{value:qL.map}),Object.defineProperty(this,bX.SCALAR,{value:QL.string}),Object.defineProperty(this,bX.SEQ,{value:ZL.seq}),this.sortMapEntries=typeof G==="function"?G:G===!0?GL:null}clone(){let X=Object.create(fX.prototype,Object.getOwnPropertyDescriptors(this));return X.tags=this.tags.slice(),X}}YL.Schema=fX});var e3=R((_L)=>{var HL=k(),yX=d2(),e2=m2();function WL(X,U){let q=[],Z=U.directives===!0;if(U.directives!==!1&&X.directives){let H=X.directives.toString(X);if(H)q.push(H),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 H=G(X.commentBefore);q.unshift(e2.indentComment(H,""))}let Y=!1,J=null;if(X.contents){if(HL.isNode(X.contents)){if(X.contents.spaceBefore&&Z)q.push("");if(X.contents.commentBefore){let $=G(X.contents.commentBefore);q.push(e2.indentComment($,""))}Q.forceBlockIndent=!!X.comment,J=X.contents.comment}let H=J?void 0:()=>Y=!0,W=yX.stringify(X.contents,Q,()=>J=null,H);if(J)W+=e2.lineComment(W,"",G(J));if((W[0]==="|"||W[0]===">")&&q[q.length-1]==="---")q[q.length-1]=`--- ${W}`;else q.push(W)}else q.push(yX.stringify(X.contents,Q));if(X.directives?.docEnd)if(X.comment){let H=G(X.comment);if(H.includes(`
55
- `))q.push("..."),q.push(e2.indentComment(H,""));else q.push(`... ${H}`)}else q.push("...");else{let H=X.comment;if(H&&Y)H=H.replace(/^\n+/,"");if(H){if((!Y||J)&&q[q.length-1]!=="")q.push("");q.push(e2.indentComment(G(H),""))}}return q.join(`
85
+ `}else j+=`
86
+ ${Q.indent}`}else if(!z&&w1.isCollection(X)){let v=S[0],N=S.indexOf(`
87
+ `),x=N!==-1,s=Q.inFlow??X.flow??X.items.length===0;if(x||!s){let Q0=!1;if(x&&(v==="&"||v==="!")){let a=S.indexOf(" ");if(v==="&"&&a!==-1&&a<N&&S[a+1]==="!")a=S.indexOf(" ",a+1);if(a===-1||N<a)Q0=!0}if(!Q0)j=`
88
+ ${Q.indent}`}}else if(S===""||S[0]===`
89
+ `)j="";if(B+=j+S,Q.inFlow){if(w&&U)U()}else if(K&&!w)B+=J4.lineComment(B,Q.indent,L(K));else if(H&&J)J();return B}YH.stringifyPair=qH});var xX=C((GH)=>{var cJ=z2("process");function $H(Z,...X){if(Z==="debug")console.log(...X)}function LH(Z,X){if(Z==="debug"||Z==="warn")if(typeof cJ.emitWarning==="function")cJ.emitWarning(X);else console.warn(X)}GH.debug=$H;GH.warn=LH});var y9=C((zH)=>{var q4=l(),iJ=W0(),f9="<<",k9={identify:(Z)=>Z===f9||typeof Z==="symbol"&&Z.description===f9,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new iJ.Scalar(Symbol(f9)),{addToJSMap:sJ}),stringify:()=>f9},HH=(Z,X)=>(k9.identify(X)||q4.isScalar(X)&&(!X.type||X.type===iJ.Scalar.PLAIN)&&k9.identify(X.value))&&Z?.doc.schema.tags.some((Q)=>Q.tag===k9.tag&&Q.default);function sJ(Z,X,Q){if(Q=Z&&q4.isAlias(Q)?Q.resolve(Z.doc):Q,q4.isSeq(Q))for(let U of Q.items)hX(Z,X,U);else if(Array.isArray(Q))for(let U of Q)hX(Z,X,U);else hX(Z,X,Q)}function hX(Z,X,Q){let U=Z&&q4.isAlias(Q)?Q.resolve(Z.doc):Q;if(!q4.isMap(U))throw Error("Merge sources must be maps or map aliases");let J=U.toJSON(null,Z,Map);for(let[q,Y]of J)if(X instanceof Map){if(!X.has(q))X.set(q,Y)}else if(X instanceof Set)X.add(q);else if(!Object.prototype.hasOwnProperty.call(X,q))Object.defineProperty(X,q,{value:Y,writable:!0,enumerable:!0,configurable:!0});return X}zH.addMergeToJSMap=sJ;zH.isMergeKey=HH;zH.merge=k9});var uX=C((DH)=>{var OH=xX(),aJ=y9(),RH=U4(),rJ=l(),mX=x1();function KH(Z,X,{key:Q,value:U}){if(rJ.isNode(Q)&&Q.addToJSMap)Q.addToJSMap(Z,X,U);else if(aJ.isMergeKey(Z,Q))aJ.addMergeToJSMap(Z,X,U);else{let J=mX.toJS(Q,"",Z);if(X instanceof Map)X.set(J,mX.toJS(U,J,Z));else if(X instanceof Set)X.add(J);else{let q=TH(Q,J,Z),Y=mX.toJS(U,q,Z);if(q in X)Object.defineProperty(X,q,{value:Y,writable:!0,enumerable:!0,configurable:!0});else X[q]=Y}}return X}function TH(Z,X,Q){if(X===null)return"";if(typeof X!=="object")return String(X);if(rJ.isNode(Z)&&Q?.doc){let U=RH.createStringifyContext(Q.doc,{});U.anchors=new Set;for(let q of Q.anchors.keys())U.anchors.add(q.anchor);U.inFlow=!0,U.inStringifyKey=!0;let J=Z.toString(U);if(!Q.mapKeyWarned){let q=JSON.stringify(J);if(q.length>40)q=q.substring(0,36)+'..."';OH.warn(Q.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${q}. Set mapAsMap: true to use object keys.`),Q.mapKeyWarned=!0}return J}return JSON.stringify(X)}DH.addPairToJSMap=KH});var u1=C((CH)=>{var oJ=e6(),PH=dJ(),AH=uX(),g9=l();function SH(Z,X,Q){let U=oJ.createNode(Z,void 0,Q),J=oJ.createNode(X,void 0,Q);return new v9(U,J)}class v9{constructor(Z,X=null){Object.defineProperty(this,g9.NODE_TYPE,{value:g9.PAIR}),this.key=Z,this.value=X}clone(Z){let{key:X,value:Q}=this;if(g9.isNode(X))X=X.clone(Z);if(g9.isNode(Q))Q=Q.clone(Z);return new v9(X,Q)}toJSON(Z,X){let Q=X?.mapAsMap?new Map:{};return AH.addPairToJSMap(X,Q,this)}toString(Z,X,Q){return Z?.doc?PH.stringifyPair(this,Z,X,Q):JSON.stringify(this)}}CH.Pair=v9;CH.createPair=SH});var pX=C((fH)=>{var $2=l(),nJ=U4(),x9=Z4();function EH(Z,X,Q){return(X.inFlow??Z.flow?IH:bH)(Z,X,Q)}function bH({comment:Z,items:X},Q,{blockItemPrefix:U,flowChars:J,itemIndent:q,onChompKeep:Y,onComment:W}){let{indent:$,options:{commentString:L}}=Q,_=Object.assign({},Q,{indent:q,type:null}),G=!1,V=[];for(let F=0;F<X.length;++F){let H=X[F],B=null;if($2.isNode(H)){if(!G&&H.spaceBefore)V.push("");if(h9(Q,V,H.commentBefore,G),H.comment)B=H.comment}else if($2.isPair(H)){let D=$2.isNode(H.key)?H.key:null;if(D){if(!G&&D.spaceBefore)V.push("");h9(Q,V,D.commentBefore,G)}}G=!1;let T=nJ.stringify(H,_,()=>B=null,()=>G=!0);if(B)T+=x9.lineComment(T,q,L(B));if(G&&B)G=!1;V.push(U+T)}let z;if(V.length===0)z=J.start+J.end;else{z=V[0];for(let F=1;F<V.length;++F){let H=V[F];z+=H?`
90
+ ${$}${H}`:`
91
+ `}}if(Z){if(z+=`
92
+ `+x9.indentComment(L(Z),$),W)W()}else if(G&&Y)Y();return z}function IH({items:Z},X,{flowChars:Q,itemIndent:U}){let{indent:J,indentStep:q,flowCollectionPadding:Y,options:{commentString:W}}=X;U+=q;let $=Object.assign({},X,{indent:U,inFlow:!0,type:null}),L=!1,_=0,G=[];for(let F=0;F<Z.length;++F){let H=Z[F],B=null;if($2.isNode(H)){if(H.spaceBefore)G.push("");if(h9(X,G,H.commentBefore,!1),H.comment)B=H.comment}else if($2.isPair(H)){let D=$2.isNode(H.key)?H.key:null;if(D){if(D.spaceBefore)G.push("");if(h9(X,G,D.commentBefore,!1),D.comment)L=!0}let K=$2.isNode(H.value)?H.value:null;if(K){if(K.comment)B=K.comment;if(K.commentBefore)L=!0}else if(H.value==null&&D?.comment)B=D.comment}if(B)L=!0;let T=nJ.stringify(H,$,()=>B=null);if(F<Z.length-1)T+=",";if(B)T+=x9.lineComment(T,U,W(B));if(!L&&(G.length>_||T.includes(`
93
+ `)))L=!0;G.push(T),_=G.length}let{start:V,end:z}=Q;if(G.length===0)return V+z;else{if(!L){let F=G.reduce((H,B)=>H+B.length+2,2);L=X.options.lineWidth>0&&F>X.options.lineWidth}if(L){let F=V;for(let H of G)F+=H?`
94
+ ${q}${J}${H}`:`
95
+ `;return`${F}
96
+ ${J}${z}`}else return`${V}${Y}${G.join(" ")}${Y}${z}`}}function h9({indent:Z,options:{commentString:X}},Q,U,J){if(U&&J)U=U.replace(/^\n+/,"");if(U){let q=x9.indentComment(X(U),Z);Q.push(q.trimStart())}}fH.stringifyCollection=EH});var l1=C((hH)=>{var yH=pX(),gH=uX(),vH=j9(),p1=l(),m9=u1(),xH=W0();function Y4(Z,X){let Q=p1.isScalar(X)?X.value:X;for(let U of Z)if(p1.isPair(U)){if(U.key===X||U.key===Q)return U;if(p1.isScalar(U.key)&&U.key.value===Q)return U}return}class tJ extends vH.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(Z){super(p1.MAP,Z);this.items=[]}static from(Z,X,Q){let{keepUndefined:U,replacer:J}=Q,q=new this(Z),Y=(W,$)=>{if(typeof J==="function")$=J.call(X,W,$);else if(Array.isArray(J)&&!J.includes(W))return;if($!==void 0||U)q.items.push(m9.createPair(W,$,Q))};if(X instanceof Map)for(let[W,$]of X)Y(W,$);else if(X&&typeof X==="object")for(let W of Object.keys(X))Y(W,X[W]);if(typeof Z.sortMapEntries==="function")q.items.sort(Z.sortMapEntries);return q}add(Z,X){let Q;if(p1.isPair(Z))Q=Z;else if(!Z||typeof Z!=="object"||!("key"in Z))Q=new m9.Pair(Z,Z?.value);else Q=new m9.Pair(Z.key,Z.value);let U=Y4(this.items,Q.key),J=this.schema?.sortMapEntries;if(U){if(!X)throw Error(`Key ${Q.key} already set`);if(p1.isScalar(U.value)&&xH.isScalarValue(Q.value))U.value.value=Q.value;else U.value=Q.value}else if(J){let q=this.items.findIndex((Y)=>J(Q,Y)<0);if(q===-1)this.items.push(Q);else this.items.splice(q,0,Q)}else this.items.push(Q)}delete(Z){let X=Y4(this.items,Z);if(!X)return!1;return this.items.splice(this.items.indexOf(X),1).length>0}get(Z,X){let U=Y4(this.items,Z)?.value;return(!X&&p1.isScalar(U)?U.value:U)??void 0}has(Z){return!!Y4(this.items,Z)}set(Z,X){this.add(new m9.Pair(Z,X),!0)}toJSON(Z,X,Q){let U=Q?new Q:X?.mapAsMap?new Map:{};if(X?.onCreate)X.onCreate(U);for(let J of this.items)gH.addPairToJSMap(X,U,J);return U}toString(Z,X,Q){if(!Z)return JSON.stringify(this);for(let U of this.items)if(!p1.isPair(U))throw Error(`Map items must all be pairs; found ${JSON.stringify(U)} instead`);if(!Z.allNullValues&&this.hasAllNullValues(!1))Z=Object.assign({},Z,{allNullValues:!0});return yH.stringifyCollection(this,Z,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:Z.indent||"",onChompKeep:Q,onComment:X})}}hH.YAMLMap=tJ;hH.findPair=Y4});var a2=C((dH)=>{var pH=l(),eJ=l1(),lH={collection:"map",default:!0,nodeClass:eJ.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(Z,X){if(!pH.isMap(Z))X("Expected a mapping for this tag");return Z},createNode:(Z,X,Q)=>eJ.YAMLMap.from(Z,X,Q)};dH.map=lH});var d1=C((nH)=>{var iH=e6(),sH=pX(),aH=j9(),p9=l(),rH=W0(),oH=x1();class Zq extends aH.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(Z){super(p9.SEQ,Z);this.items=[]}add(Z){this.items.push(Z)}delete(Z){let X=u9(Z);if(typeof X!=="number")return!1;return this.items.splice(X,1).length>0}get(Z,X){let Q=u9(Z);if(typeof Q!=="number")return;let U=this.items[Q];return!X&&p9.isScalar(U)?U.value:U}has(Z){let X=u9(Z);return typeof X==="number"&&X<this.items.length}set(Z,X){let Q=u9(Z);if(typeof Q!=="number")throw Error(`Expected a valid index, not ${Z}.`);let U=this.items[Q];if(p9.isScalar(U)&&rH.isScalarValue(X))U.value=X;else this.items[Q]=X}toJSON(Z,X){let Q=[];if(X?.onCreate)X.onCreate(Q);let U=0;for(let J of this.items)Q.push(oH.toJS(J,String(U++),X));return Q}toString(Z,X,Q){if(!Z)return JSON.stringify(this);return sH.stringifyCollection(this,Z,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(Z.indent||"")+" ",onChompKeep:Q,onComment:X})}static from(Z,X,Q){let{replacer:U}=Q,J=new this(Z);if(X&&Symbol.iterator in Object(X)){let q=0;for(let Y of X){if(typeof U==="function"){let W=X instanceof Set?Y:String(q++);Y=U.call(X,W,Y)}J.items.push(iH.createNode(Y,void 0,Q))}}return J}}function u9(Z){let X=p9.isScalar(Z)?Z.value:Z;if(X&&typeof X==="string")X=Number(X);return typeof X==="number"&&Number.isInteger(X)&&X>=0?X:null}nH.YAMLSeq=Zq});var r2=C((Xz)=>{var eH=l(),Xq=d1(),Zz={collection:"seq",default:!0,nodeClass:Xq.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(Z,X){if(!eH.isSeq(Z))X("Expected a sequence for this tag");return Z},createNode:(Z,X,Q)=>Xq.YAMLSeq.from(Z,X,Q)};Xz.seq=Zz});var W4=C((qz)=>{var Uz=Q4(),Jz={identify:(Z)=>typeof Z==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(Z)=>Z,stringify(Z,X,Q,U){return X=Object.assign({actualString:!0},X),Uz.stringifyString(Z,X,Q,U)}};qz.string=Jz});var l9=C((Wz)=>{var Qq=W0(),Uq={identify:(Z)=>Z==null,createNode:()=>new Qq.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Qq.Scalar(null),stringify:({source:Z},X)=>typeof Z==="string"&&Uq.test.test(Z)?Z:X.options.nullStr};Wz.nullTag=Uq});var lX=C((Gz)=>{var Lz=W0(),Jq={identify:(Z)=>typeof Z==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(Z)=>new Lz.Scalar(Z[0]==="t"||Z[0]==="T"),stringify({source:Z,value:X},Q){if(Z&&Jq.test.test(Z)){let U=Z[0]==="t"||Z[0]==="T";if(X===U)return Z}return X?Q.options.trueStr:Q.options.falseStr}};Gz.boolTag=Jq});var o2=C((Hz)=>{function Vz({format:Z,minFractionDigits:X,tag:Q,value:U}){if(typeof U==="bigint")return String(U);let J=typeof U==="number"?U:Number(U);if(!isFinite(J))return isNaN(J)?".nan":J<0?"-.inf":".inf";let q=Object.is(U,-0)?"-0":JSON.stringify(U);if(!Z&&X&&(!Q||Q==="tag:yaml.org,2002:float")&&/^\d/.test(q)){let Y=q.indexOf(".");if(Y<0)Y=q.length,q+=".";let W=X-(q.length-Y-1);while(W-- >0)q+="0"}return q}Hz.stringifyNumber=Vz});var cX=C((Rz)=>{var Fz=W0(),dX=o2(),Bz={identify:(Z)=>typeof Z==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(Z)=>Z.slice(-3).toLowerCase()==="nan"?NaN:Z[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:dX.stringifyNumber},Mz={identify:(Z)=>typeof Z==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(Z)=>parseFloat(Z),stringify(Z){let X=Number(Z.value);return isFinite(X)?X.toExponential():dX.stringifyNumber(Z)}},Oz={identify:(Z)=>typeof Z==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(Z){let X=new Fz.Scalar(parseFloat(Z)),Q=Z.indexOf(".");if(Q!==-1&&Z[Z.length-1]==="0")X.minFractionDigits=Z.length-Q-1;return X},stringify:dX.stringifyNumber};Rz.float=Oz;Rz.floatExp=Mz;Rz.floatNaN=Bz});var sX=C((Sz)=>{var qq=o2(),d9=(Z)=>typeof Z==="bigint"||Number.isInteger(Z),iX=(Z,X,Q,{intAsBigInt:U})=>U?BigInt(Z):parseInt(Z.substring(X),Q);function Yq(Z,X,Q){let{value:U}=Z;if(d9(U)&&U>=0)return Q+U.toString(X);return qq.stringifyNumber(Z)}var wz={identify:(Z)=>d9(Z)&&Z>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(Z,X,Q)=>iX(Z,2,8,Q),stringify:(Z)=>Yq(Z,8,"0o")},Pz={identify:d9,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(Z,X,Q)=>iX(Z,0,10,Q),stringify:qq.stringifyNumber},Az={identify:(Z)=>d9(Z)&&Z>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(Z,X,Q)=>iX(Z,2,16,Q),stringify:(Z)=>Yq(Z,16,"0x")};Sz.int=Pz;Sz.intHex=Az;Sz.intOct=wz});var Wq=C((gz)=>{var Ez=a2(),bz=l9(),Iz=r2(),fz=W4(),kz=lX(),aX=cX(),rX=sX(),yz=[Ez.map,Iz.seq,fz.string,bz.nullTag,kz.boolTag,rX.intOct,rX.int,rX.intHex,aX.floatNaN,aX.floatExp,aX.float];gz.schema=yz});var Lq=C((dz)=>{var xz=W0(),hz=a2(),mz=r2();function $q(Z){return typeof Z==="bigint"||Number.isInteger(Z)}var c9=({value:Z})=>JSON.stringify(Z),uz=[{identify:(Z)=>typeof Z==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(Z)=>Z,stringify:c9},{identify:(Z)=>Z==null,createNode:()=>new xz.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:c9},{identify:(Z)=>typeof Z==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(Z)=>Z==="true",stringify:c9},{identify:$q,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(Z,X,{intAsBigInt:Q})=>Q?BigInt(Z):parseInt(Z,10),stringify:({value:Z})=>$q(Z)?Z.toString():JSON.stringify(Z)},{identify:(Z)=>typeof Z==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(Z)=>parseFloat(Z),stringify:c9}],pz={default:!0,tag:"",test:/^/,resolve(Z,X){return X(`Unresolved plain scalar ${JSON.stringify(Z)}`),Z}},lz=[hz.map,mz.seq].concat(uz,pz);dz.schema=lz});var nX=C((az)=>{var $4=z2("buffer"),oX=W0(),iz=Q4(),sz={identify:(Z)=>Z instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(Z,X){if(typeof $4.Buffer==="function")return $4.Buffer.from(Z,"base64");else if(typeof atob==="function"){let Q=atob(Z.replace(/[\n\r]/g,"")),U=new Uint8Array(Q.length);for(let J=0;J<Q.length;++J)U[J]=Q.charCodeAt(J);return U}else return X("This environment does not support reading binary tags; either Buffer or atob is required"),Z},stringify({comment:Z,type:X,value:Q},U,J,q){if(!Q)return"";let Y=Q,W;if(typeof $4.Buffer==="function")W=Y instanceof $4.Buffer?Y.toString("base64"):$4.Buffer.from(Y.buffer).toString("base64");else if(typeof btoa==="function"){let $="";for(let L=0;L<Y.length;++L)$+=String.fromCharCode(Y[L]);W=btoa($)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(X??(X=oX.Scalar.BLOCK_LITERAL),X!==oX.Scalar.QUOTE_DOUBLE){let $=Math.max(U.options.lineWidth-U.indent.length,U.options.minContentWidth),L=Math.ceil(W.length/$),_=Array(L);for(let G=0,V=0;G<L;++G,V+=$)_[G]=W.substr(V,$);W=_.join(X===oX.Scalar.BLOCK_LITERAL?`
97
+ `:" ")}return iz.stringifyString({comment:Z,type:X,value:W},U,J,q)}};az.binary=sz});var s9=C((ez)=>{var i9=l(),tX=u1(),oz=W0(),nz=d1();function Gq(Z,X){if(i9.isSeq(Z))for(let Q=0;Q<Z.items.length;++Q){let U=Z.items[Q];if(i9.isPair(U))continue;else if(i9.isMap(U)){if(U.items.length>1)X("Each pair must have its own sequence indicator");let J=U.items[0]||new tX.Pair(new oz.Scalar(null));if(U.commentBefore)J.key.commentBefore=J.key.commentBefore?`${U.commentBefore}
98
+ ${J.key.commentBefore}`:U.commentBefore;if(U.comment){let q=J.value??J.key;q.comment=q.comment?`${U.comment}
99
+ ${q.comment}`:U.comment}U=J}Z.items[Q]=i9.isPair(U)?U:new tX.Pair(U)}else X("Expected a sequence for this tag");return Z}function _q(Z,X,Q){let{replacer:U}=Q,J=new nz.YAMLSeq(Z);J.tag="tag:yaml.org,2002:pairs";let q=0;if(X&&Symbol.iterator in Object(X))for(let Y of X){if(typeof U==="function")Y=U.call(X,String(q++),Y);let W,$;if(Array.isArray(Y))if(Y.length===2)W=Y[0],$=Y[1];else throw TypeError(`Expected [key, value] tuple: ${Y}`);else if(Y&&Y instanceof Object){let L=Object.keys(Y);if(L.length===1)W=L[0],$=Y[W];else throw TypeError(`Expected tuple with one key, not ${L.length} keys`)}else W=Y;J.items.push(tX.createPair(W,$,Q))}return J}var tz={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Gq,createNode:_q};ez.createPairs=_q;ez.pairs=tz;ez.resolvePairs=Gq});var Z3=C((qF)=>{var Vq=l(),eX=x1(),L4=l1(),UF=d1(),Hq=s9();class L2 extends UF.YAMLSeq{constructor(){super();this.add=L4.YAMLMap.prototype.add.bind(this),this.delete=L4.YAMLMap.prototype.delete.bind(this),this.get=L4.YAMLMap.prototype.get.bind(this),this.has=L4.YAMLMap.prototype.has.bind(this),this.set=L4.YAMLMap.prototype.set.bind(this),this.tag=L2.tag}toJSON(Z,X){if(!X)return super.toJSON(Z);let Q=new Map;if(X?.onCreate)X.onCreate(Q);for(let U of this.items){let J,q;if(Vq.isPair(U))J=eX.toJS(U.key,"",X),q=eX.toJS(U.value,J,X);else J=eX.toJS(U,"",X);if(Q.has(J))throw Error("Ordered maps must not include duplicate keys");Q.set(J,q)}return Q}static from(Z,X,Q){let U=Hq.createPairs(Z,X,Q),J=new this;return J.items=U.items,J}}L2.tag="tag:yaml.org,2002:omap";var JF={collection:"seq",identify:(Z)=>Z instanceof Map,nodeClass:L2,default:!1,tag:"tag:yaml.org,2002:omap",resolve(Z,X){let Q=Hq.resolvePairs(Z,X),U=[];for(let{key:J}of Q.items)if(Vq.isScalar(J))if(U.includes(J.value))X(`Ordered maps must not include duplicate keys: ${J.value}`);else U.push(J.value);return Object.assign(new L2,Q)},createNode:(Z,X,Q)=>L2.from(Z,X,Q)};qF.YAMLOMap=L2;qF.omap=JF});var Oq=C(($F)=>{var zq=W0();function Fq({value:Z,source:X},Q){if(X&&(Z?Bq:Mq).test.test(X))return X;return Z?Q.options.trueStr:Q.options.falseStr}var Bq={identify:(Z)=>Z===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new zq.Scalar(!0),stringify:Fq},Mq={identify:(Z)=>Z===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new zq.Scalar(!1),stringify:Fq};$F.falseTag=Mq;$F.trueTag=Bq});var Rq=C((FF)=>{var _F=W0(),X3=o2(),VF={identify:(Z)=>typeof Z==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(Z)=>Z.slice(-3).toLowerCase()==="nan"?NaN:Z[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:X3.stringifyNumber},HF={identify:(Z)=>typeof Z==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(Z)=>parseFloat(Z.replace(/_/g,"")),stringify(Z){let X=Number(Z.value);return isFinite(X)?X.toExponential():X3.stringifyNumber(Z)}},zF={identify:(Z)=>typeof Z==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(Z){let X=new _F.Scalar(parseFloat(Z.replace(/_/g,""))),Q=Z.indexOf(".");if(Q!==-1){let U=Z.substring(Q+1).replace(/_/g,"");if(U[U.length-1]==="0")X.minFractionDigits=U.length}return X},stringify:X3.stringifyNumber};FF.float=zF;FF.floatExp=HF;FF.floatNaN=VF});var Tq=C((wF)=>{var Kq=o2(),G4=(Z)=>typeof Z==="bigint"||Number.isInteger(Z);function a9(Z,X,Q,{intAsBigInt:U}){let J=Z[0];if(J==="-"||J==="+")X+=1;if(Z=Z.substring(X).replace(/_/g,""),U){switch(Q){case 2:Z=`0b${Z}`;break;case 8:Z=`0o${Z}`;break;case 16:Z=`0x${Z}`;break}let Y=BigInt(Z);return J==="-"?BigInt(-1)*Y:Y}let q=parseInt(Z,Q);return J==="-"?-1*q:q}function Q3(Z,X,Q){let{value:U}=Z;if(G4(U)){let J=U.toString(X);return U<0?"-"+Q+J.substr(1):Q+J}return Kq.stringifyNumber(Z)}var RF={identify:G4,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(Z,X,Q)=>a9(Z,2,2,Q),stringify:(Z)=>Q3(Z,2,"0b")},KF={identify:G4,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(Z,X,Q)=>a9(Z,1,8,Q),stringify:(Z)=>Q3(Z,8,"0")},TF={identify:G4,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(Z,X,Q)=>a9(Z,0,10,Q),stringify:Kq.stringifyNumber},DF={identify:G4,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(Z,X,Q)=>a9(Z,2,16,Q),stringify:(Z)=>Q3(Z,16,"0x")};wF.int=TF;wF.intBin=RF;wF.intHex=DF;wF.intOct=KF});var U3=C((jF)=>{var n9=l(),r9=u1(),o9=l1();class G2 extends o9.YAMLMap{constructor(Z){super(Z);this.tag=G2.tag}add(Z){let X;if(n9.isPair(Z))X=Z;else if(Z&&typeof Z==="object"&&"key"in Z&&"value"in Z&&Z.value===null)X=new r9.Pair(Z.key,null);else X=new r9.Pair(Z,null);if(!o9.findPair(this.items,X.key))this.items.push(X)}get(Z,X){let Q=o9.findPair(this.items,Z);return!X&&n9.isPair(Q)?n9.isScalar(Q.key)?Q.key.value:Q.key:Q}set(Z,X){if(typeof X!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof X}`);let Q=o9.findPair(this.items,Z);if(Q&&!X)this.items.splice(this.items.indexOf(Q),1);else if(!Q&&X)this.items.push(new r9.Pair(Z))}toJSON(Z,X){return super.toJSON(Z,X,Set)}toString(Z,X,Q){if(!Z)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},Z,{allNullValues:!0}),X,Q);else throw Error("Set items must all have null values")}static from(Z,X,Q){let{replacer:U}=Q,J=new this(Z);if(X&&Symbol.iterator in Object(X))for(let q of X){if(typeof U==="function")q=U.call(X,q,q);J.items.push(r9.createPair(q,null,Q))}return J}}G2.tag="tag:yaml.org,2002:set";var NF={collection:"map",identify:(Z)=>Z instanceof Set,nodeClass:G2,default:!1,tag:"tag:yaml.org,2002:set",createNode:(Z,X,Q)=>G2.from(Z,X,Q),resolve(Z,X){if(n9.isMap(Z))if(Z.hasAllNullValues(!0))return Object.assign(new G2,Z);else X("Set items must all have null values");else X("Expected a mapping for this tag");return Z}};jF.YAMLSet=G2;jF.set=NF});var q3=C((yF)=>{var IF=o2();function J3(Z,X){let Q=Z[0],U=Q==="-"||Q==="+"?Z.substring(1):Z,J=(Y)=>X?BigInt(Y):Number(Y),q=U.replace(/_/g,"").split(":").reduce((Y,W)=>Y*J(60)+J(W),J(0));return Q==="-"?J(-1)*q:q}function Dq(Z){let{value:X}=Z,Q=(Y)=>Y;if(typeof X==="bigint")Q=(Y)=>BigInt(Y);else if(isNaN(X)||!isFinite(X))return IF.stringifyNumber(Z);let U="";if(X<0)U="-",X*=Q(-1);let J=Q(60),q=[X%J];if(X<60)q.unshift(0);else if(X=(X-q[0])/J,q.unshift(X%J),X>=60)X=(X-q[0])/J,q.unshift(X);return U+q.map((Y)=>String(Y).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var fF={identify:(Z)=>typeof Z==="bigint"||Number.isInteger(Z),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(Z,X,{intAsBigInt:Q})=>J3(Z,Q),stringify:Dq},kF={identify:(Z)=>typeof Z==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(Z)=>J3(Z,!1),stringify:Dq},wq={identify:(Z)=>Z 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(Z){let X=Z.match(wq.test);if(!X)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,Q,U,J,q,Y,W]=X.map(Number),$=X[7]?Number((X[7]+"00").substr(1,3)):0,L=Date.UTC(Q,U-1,J,q||0,Y||0,W||0,$),_=X[8];if(_&&_!=="Z"){let G=J3(_,!1);if(Math.abs(G)<30)G*=60;L-=60000*G}return new Date(L)},stringify:({value:Z})=>Z?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};yF.floatTime=kF;yF.intTime=fF;yF.timestamp=wq});var Aq=C((rF)=>{var hF=a2(),mF=l9(),uF=r2(),pF=W4(),lF=nX(),Pq=Oq(),Y3=Rq(),t9=Tq(),dF=y9(),cF=Z3(),iF=s9(),sF=U3(),W3=q3(),aF=[hF.map,uF.seq,pF.string,mF.nullTag,Pq.trueTag,Pq.falseTag,t9.intBin,t9.intOct,t9.int,t9.intHex,Y3.floatNaN,Y3.floatExp,Y3.float,lF.binary,dF.merge,cF.omap,iF.pairs,sF.set,W3.intTime,W3.floatTime,W3.timestamp];rF.schema=aF});var yq=C((JB)=>{var jq=a2(),nF=l9(),Eq=r2(),tF=W4(),eF=lX(),$3=cX(),L3=sX(),ZB=Wq(),XB=Lq(),bq=nX(),_4=y9(),Iq=Z3(),fq=s9(),Sq=Aq(),kq=U3(),e9=q3(),Cq=new Map([["core",ZB.schema],["failsafe",[jq.map,Eq.seq,tF.string]],["json",XB.schema],["yaml11",Sq.schema],["yaml-1.1",Sq.schema]]),Nq={binary:bq.binary,bool:eF.boolTag,float:$3.float,floatExp:$3.floatExp,floatNaN:$3.floatNaN,floatTime:e9.floatTime,int:L3.int,intHex:L3.intHex,intOct:L3.intOct,intTime:e9.intTime,map:jq.map,merge:_4.merge,null:nF.nullTag,omap:Iq.omap,pairs:fq.pairs,seq:Eq.seq,set:kq.set,timestamp:e9.timestamp},QB={"tag:yaml.org,2002:binary":bq.binary,"tag:yaml.org,2002:merge":_4.merge,"tag:yaml.org,2002:omap":Iq.omap,"tag:yaml.org,2002:pairs":fq.pairs,"tag:yaml.org,2002:set":kq.set,"tag:yaml.org,2002:timestamp":e9.timestamp};function UB(Z,X,Q){let U=Cq.get(X);if(U&&!Z)return Q&&!U.includes(_4.merge)?U.concat(_4.merge):U.slice();let J=U;if(!J)if(Array.isArray(Z))J=[];else{let q=Array.from(Cq.keys()).filter((Y)=>Y!=="yaml11").map((Y)=>JSON.stringify(Y)).join(", ");throw Error(`Unknown schema "${X}"; use one of ${q} or define customTags array`)}if(Array.isArray(Z))for(let q of Z)J=J.concat(q);else if(typeof Z==="function")J=Z(J.slice());if(Q)J=J.concat(_4.merge);return J.reduce((q,Y)=>{let W=typeof Y==="string"?Nq[Y]:Y;if(!W){let $=JSON.stringify(Y),L=Object.keys(Nq).map((_)=>JSON.stringify(_)).join(", ");throw Error(`Unknown custom tag ${$}; use one of ${L}`)}if(!q.includes(W))q.push(W);return q},[])}JB.coreKnownTags=QB;JB.getTags=UB});var V3=C((_B)=>{var G3=l(),WB=a2(),$B=r2(),LB=W4(),ZZ=yq(),GB=(Z,X)=>Z.key<X.key?-1:Z.key>X.key?1:0;class _3{constructor({compat:Z,customTags:X,merge:Q,resolveKnownTags:U,schema:J,sortMapEntries:q,toStringDefaults:Y}){this.compat=Array.isArray(Z)?ZZ.getTags(Z,"compat"):Z?ZZ.getTags(null,Z):null,this.name=typeof J==="string"&&J||"core",this.knownTags=U?ZZ.coreKnownTags:{},this.tags=ZZ.getTags(X,this.name,Q),this.toStringOptions=Y??null,Object.defineProperty(this,G3.MAP,{value:WB.map}),Object.defineProperty(this,G3.SCALAR,{value:LB.string}),Object.defineProperty(this,G3.SEQ,{value:$B.seq}),this.sortMapEntries=typeof q==="function"?q:q===!0?GB:null}clone(){let Z=Object.create(_3.prototype,Object.getOwnPropertyDescriptors(this));return Z.tags=this.tags.slice(),Z}}_B.Schema=_3});var gq=C((FB)=>{var HB=l(),H3=U4(),V4=Z4();function zB(Z,X){let Q=[],U=X.directives===!0;if(X.directives!==!1&&Z.directives){let $=Z.directives.toString(Z);if($)Q.push($),U=!0;else if(Z.directives.docStart)U=!0}if(U)Q.push("---");let J=H3.createStringifyContext(Z,X),{commentString:q}=J.options;if(Z.commentBefore){if(Q.length!==1)Q.unshift("");let $=q(Z.commentBefore);Q.unshift(V4.indentComment($,""))}let Y=!1,W=null;if(Z.contents){if(HB.isNode(Z.contents)){if(Z.contents.spaceBefore&&U)Q.push("");if(Z.contents.commentBefore){let _=q(Z.contents.commentBefore);Q.push(V4.indentComment(_,""))}J.forceBlockIndent=!!Z.comment,W=Z.contents.comment}let $=W?void 0:()=>Y=!0,L=H3.stringify(Z.contents,J,()=>W=null,$);if(W)L+=V4.lineComment(L,"",q(W));if((L[0]==="|"||L[0]===">")&&Q[Q.length-1]==="---")Q[Q.length-1]=`--- ${L}`;else Q.push(L)}else Q.push(H3.stringify(Z.contents,J));if(Z.directives?.docEnd)if(Z.comment){let $=q(Z.comment);if($.includes(`
100
+ `))Q.push("..."),Q.push(V4.indentComment($,""));else Q.push(`... ${$}`)}else Q.push("...");else{let $=Z.comment;if($&&Y)$=$.replace(/^\n+/,"");if($){if((!Y||W)&&Q[Q.length-1]!=="")Q.push("");Q.push(V4.indentComment(q($),""))}}return Q.join(`
56
101
  `)+`
57
- `}_L.stringifyDocument=WL});var X6=R((BL)=>{var LL=x2(),t1=a6(),R0=k(),zL=X1(),FL=n0(),VL=gX(),AL=e3(),kX=s6(),OL=UX(),TL=u2(),vX=XX();class hX{constructor(X,U,q){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,R0.NODE_TYPE,{value:R0.DOC});let Z=null;if(typeof 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 vX.Directives({version:G});this.setSchema(G,q),this.contents=X===void 0?null:this.createNode(X,Z,q)}clone(){let X=Object.create(hX.prototype,{[R0.NODE_TYPE]:{value:R0.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=R0.isNode(this.contents)?this.contents.clone(X.schema):this.contents,this.range)X.range=this.range.slice();return X}add(X){if(e1(this.contents))this.contents.add(X)}addIn(X,U){if(e1(this.contents))this.contents.addIn(X,U)}createAlias(X,U){if(!X.anchor){let q=kX.anchorNames(this);X.anchor=!U||q.has(U)?kX.findNewAnchor(U||"a",q):U}return new LL.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:J,onTagObj:H,tag:W}=q??{},{onAnchor:$,setAnchors:_,sourceObjects:L}=kX.createNodeAnchors(this,G||"a"),V={aliasDuplicateObjects:Q??!0,keepUndefined:J??!1,onAnchor:$,onTagObj:H,replacer:Z,schema:this.schema,sourceObjects:L},B=TL.createNode(X,W,V);if(Y&&R0.isCollection(B))B.flow=!0;return _(),B}createPair(X,U,q={}){let Z=this.createNode(X,null,q),Q=this.createNode(U,null,q);return new zL.Pair(Z,Q)}delete(X){return e1(this.contents)?this.contents.delete(X):!1}deleteIn(X){if(t1.isEmptyPath(X)){if(this.contents==null)return!1;return this.contents=null,!0}return e1(this.contents)?this.contents.deleteIn(X):!1}get(X,U){return R0.isCollection(this.contents)?this.contents.get(X,U):void 0}getIn(X,U){if(t1.isEmptyPath(X))return!U&&R0.isScalar(this.contents)?this.contents.value:this.contents;return R0.isCollection(this.contents)?this.contents.getIn(X,U):void 0}has(X){return R0.isCollection(this.contents)?this.contents.has(X):!1}hasIn(X){if(t1.isEmptyPath(X))return this.contents!==void 0;return R0.isCollection(this.contents)?this.contents.hasIn(X):!1}set(X,U){if(this.contents==null)this.contents=t1.collectionFromPath(this.schema,[X],U);else if(e1(this.contents))this.contents.set(X,U)}setIn(X,U){if(t1.isEmptyPath(X))this.contents=U;else if(this.contents==null)this.contents=t1.collectionFromPath(this.schema,Array.from(X),U);else if(e1(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 vX.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 vX.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 VL.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},J=FL.toJS(this.contents,U??"",Y);if(typeof Q==="function")for(let{count:H,res:W}of Y.anchors.values())Q(W,H);return typeof G==="function"?OL.applyReviver(G,{"":J},"",J):J}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 AL.stringifyDocument(this,X)}}function e1(X){if(R0.isCollection(X))return!0;throw Error("Expected a YAML collection as document contents")}BL.Document=hX});var U6=R((ML)=>{class M4 extends Error{constructor(X,U,q,Z){super();this.name=X,this.code=q,this.message=Z,this.pos=U}}class XQ extends M4{constructor(X,U,q){super("YAMLParseError",X,U,q)}}class UQ extends M4{constructor(X,U,q){super("YAMLWarning",X,U,q)}}var DL=(X,U)=>(q)=>{if(q.pos[0]===-1)return;q.linePos=q.pos.map((J)=>U.linePos(J));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 J=Math.min(G-39,Y.length-79);Y="…"+Y.substring(J),G-=J-1}if(Y.length>80)Y=Y.substring(0,79)+"…";if(Z>1&&/^ *$/.test(Y.substring(0,G))){let J=X.substring(U.lineStarts[Z-2],U.lineStarts[Z-1]);if(J.length>80)J=J.substring(0,79)+`…
58
- `;Y=J+Y}if(/[^ ]/.test(Y)){let J=1,H=q.linePos[1];if(H?.line===Z&&H.col>Q)J=Math.max(1,Math.min(H.col-Q,80-G));let W=" ".repeat(G)+"^".repeat(J);q.message+=`:
102
+ `}FB.stringifyDocument=zB});var H4=C((PB)=>{var MB=t6(),n2=j9(),c0=l(),OB=u1(),RB=x1(),KB=V3(),TB=gq(),z3=S9(),DB=fX(),wB=e6(),F3=IX();class B3{constructor(Z,X,Q){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,c0.NODE_TYPE,{value:c0.DOC});let U=null;if(typeof X==="function"||Array.isArray(X))U=X;else if(Q===void 0&&X)Q=X,X=void 0;let J=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},Q);this.options=J;let{version:q}=J;if(Q?._directives){if(this.directives=Q._directives.atDocument(),this.directives.yaml.explicit)q=this.directives.yaml.version}else this.directives=new F3.Directives({version:q});this.setSchema(q,Q),this.contents=Z===void 0?null:this.createNode(Z,U,Q)}clone(){let Z=Object.create(B3.prototype,{[c0.NODE_TYPE]:{value:c0.DOC}});if(Z.commentBefore=this.commentBefore,Z.comment=this.comment,Z.errors=this.errors.slice(),Z.warnings=this.warnings.slice(),Z.options=Object.assign({},this.options),this.directives)Z.directives=this.directives.clone();if(Z.schema=this.schema.clone(),Z.contents=c0.isNode(this.contents)?this.contents.clone(Z.schema):this.contents,this.range)Z.range=this.range.slice();return Z}add(Z){if(t2(this.contents))this.contents.add(Z)}addIn(Z,X){if(t2(this.contents))this.contents.addIn(Z,X)}createAlias(Z,X){if(!Z.anchor){let Q=z3.anchorNames(this);Z.anchor=!X||Q.has(X)?z3.findNewAnchor(X||"a",Q):X}return new MB.Alias(Z.anchor)}createNode(Z,X,Q){let U=void 0;if(typeof X==="function")Z=X.call({"":Z},"",Z),U=X;else if(Array.isArray(X)){let H=(T)=>typeof T==="number"||T instanceof String||T instanceof Number,B=X.filter(H).map(String);if(B.length>0)X=X.concat(B);U=X}else if(Q===void 0&&X)Q=X,X=void 0;let{aliasDuplicateObjects:J,anchorPrefix:q,flow:Y,keepUndefined:W,onTagObj:$,tag:L}=Q??{},{onAnchor:_,setAnchors:G,sourceObjects:V}=z3.createNodeAnchors(this,q||"a"),z={aliasDuplicateObjects:J??!0,keepUndefined:W??!1,onAnchor:_,onTagObj:$,replacer:U,schema:this.schema,sourceObjects:V},F=wB.createNode(Z,L,z);if(Y&&c0.isCollection(F))F.flow=!0;return G(),F}createPair(Z,X,Q={}){let U=this.createNode(Z,null,Q),J=this.createNode(X,null,Q);return new OB.Pair(U,J)}delete(Z){return t2(this.contents)?this.contents.delete(Z):!1}deleteIn(Z){if(n2.isEmptyPath(Z)){if(this.contents==null)return!1;return this.contents=null,!0}return t2(this.contents)?this.contents.deleteIn(Z):!1}get(Z,X){return c0.isCollection(this.contents)?this.contents.get(Z,X):void 0}getIn(Z,X){if(n2.isEmptyPath(Z))return!X&&c0.isScalar(this.contents)?this.contents.value:this.contents;return c0.isCollection(this.contents)?this.contents.getIn(Z,X):void 0}has(Z){return c0.isCollection(this.contents)?this.contents.has(Z):!1}hasIn(Z){if(n2.isEmptyPath(Z))return this.contents!==void 0;return c0.isCollection(this.contents)?this.contents.hasIn(Z):!1}set(Z,X){if(this.contents==null)this.contents=n2.collectionFromPath(this.schema,[Z],X);else if(t2(this.contents))this.contents.set(Z,X)}setIn(Z,X){if(n2.isEmptyPath(Z))this.contents=X;else if(this.contents==null)this.contents=n2.collectionFromPath(this.schema,Array.from(Z),X);else if(t2(this.contents))this.contents.setIn(Z,X)}setSchema(Z,X={}){if(typeof Z==="number")Z=String(Z);let Q;switch(Z){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new F3.Directives({version:"1.1"});Q={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=Z;else this.directives=new F3.Directives({version:Z});Q={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;Q=null;break;default:{let U=JSON.stringify(Z);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${U}`)}}if(X.schema instanceof Object)this.schema=X.schema;else if(Q)this.schema=new KB.Schema(Object.assign(Q,X));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:Z,jsonArg:X,mapAsMap:Q,maxAliasCount:U,onAnchor:J,reviver:q}={}){let Y={anchors:new Map,doc:this,keep:!Z,mapAsMap:Q===!0,mapKeyWarned:!1,maxAliasCount:typeof U==="number"?U:100},W=RB.toJS(this.contents,X??"",Y);if(typeof J==="function")for(let{count:$,res:L}of Y.anchors.values())J(L,$);return typeof q==="function"?DB.applyReviver(q,{"":W},"",W):W}toJSON(Z,X){return this.toJS({json:!0,jsonArg:Z,mapAsMap:!1,onAnchor:X})}toString(Z={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in Z&&(!Number.isInteger(Z.indent)||Number(Z.indent)<=0)){let X=JSON.stringify(Z.indent);throw Error(`"indent" option must be a positive integer, not ${X}`)}return TB.stringifyDocument(this,Z)}}function t2(Z){if(c0.isCollection(Z))return!0;throw Error("Expected a YAML collection as document contents")}PB.Document=B3});var z4=C((CB)=>{class XZ extends Error{constructor(Z,X,Q,U){super();this.name=Z,this.code=Q,this.message=U,this.pos=X}}class vq extends XZ{constructor(Z,X,Q){super("YAMLParseError",Z,X,Q)}}class xq extends XZ{constructor(Z,X,Q){super("YAMLWarning",Z,X,Q)}}var SB=(Z,X)=>(Q)=>{if(Q.pos[0]===-1)return;Q.linePos=Q.pos.map((W)=>X.linePos(W));let{line:U,col:J}=Q.linePos[0];Q.message+=` at line ${U}, column ${J}`;let q=J-1,Y=Z.substring(X.lineStarts[U-1],X.lineStarts[U]).replace(/[\n\r]+$/,"");if(q>=60&&Y.length>80){let W=Math.min(q-39,Y.length-79);Y="…"+Y.substring(W),q-=W-1}if(Y.length>80)Y=Y.substring(0,79)+"…";if(U>1&&/^ *$/.test(Y.substring(0,q))){let W=Z.substring(X.lineStarts[U-2],X.lineStarts[U-1]);if(W.length>80)W=W.substring(0,79)+`…
103
+ `;Y=W+Y}if(/[^ ]/.test(Y)){let W=1,$=Q.linePos[1];if($?.line===U&&$.col>J)W=Math.max(1,Math.min($.col-J,80-q));let L=" ".repeat(q)+"^".repeat(W);Q.message+=`:
59
104
 
60
105
  ${Y}
61
- ${W}
62
- `}};ML.YAMLError=M4;ML.YAMLParseError=XQ;ML.YAMLWarning=UQ;ML.prettifyError=DL});var q6=R((CL)=>{function NL(X,{flow:U,indicator:q,next:Z,offset:Q,onError:G,parentIndent:Y,startOnNewline:J}){let H=!1,W=J,$=J,_="",L="",V=!1,B=!1,z=null,O=null,D=null,P=null,K=null,C=null,N=null;for(let w of X){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(!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")H=!0}else L+=w.source;if(W=!0,V=!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 ${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 b=X[X.length-1],m=b?b.offset+b.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:H,comment:_,hasNewline:V,anchor:O,tag:D,newlineAfterProp:P,end:m,start:N??m}}CL.resolveProps=NL});var w4=R((EL)=>{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}}EL.containsNewline=xX});var uX=R((gL)=>{var bL=w4();function fL(X,U,q){if(U?.type==="flow-collection"){let Z=U.end[0];if(Z.indent===X&&(Z.source==="]"||Z.source==="}")&&bL.containsNewline(U))q(Z,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}gL.flowIndentCheck=fL});var mX=R((vL)=>{var qQ=k();function kL(X,U,q){let{uniqueKeys:Z}=X.options;if(Z===!1)return!1;let Q=typeof Z==="function"?Z:(G,Y)=>G===Y||qQ.isScalar(G)&&qQ.isScalar(Y)&&G.value===Y.value;return U.some((G)=>Q(G.key,q))}vL.mapIncludes=kL});var JQ=R((lL)=>{var ZQ=X1(),xL=q1(),QQ=q6(),uL=w4(),GQ=uX(),mL=mX(),YQ="All mapping items must start at the same column";function pL({composeNode:X,composeEmptyNode:U},q,Z,Q,G){let J=new(G?.nodeClass??xL.YAMLMap)(q.schema);if(q.atRoot)q.atRoot=!1;let H=Z.offset,W=null;for(let $ of Z.items){let{start:_,key:L,sep:V,value:B}=$,z=QQ.resolveProps(_,{indicator:"explicit-key-ind",next:L??V?.[0],offset:H,onError:Q,parentIndent:Z.indent,startOnNewline:!0}),O=!z.found;if(O){if(L){if(L.type==="block-seq")Q(H,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in L&&L.indent!==Z.indent)Q(H,"BAD_INDENT",YQ)}if(!z.anchor&&!z.tag&&!V){if(W=z.end,z.comment)if(J.comment)J.comment+=`
64
- `+z.comment;else J.comment=z.comment;continue}if(z.newlineAfterProp||uL.containsNewline(L))Q(L??_[_.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(z.found?.indent!==Z.indent)Q(H,"BAD_INDENT",YQ);q.atKey=!0;let D=z.end,P=L?X(q,L,z,Q):U(q,D,_,null,z,Q);if(q.schema.compat)GQ.flowIndentCheck(Z.indent,L,Q);if(q.atKey=!1,mL.mapIncludes(q,J.items,P))Q(D,"DUPLICATE_KEY","Map keys must be unique");let K=QQ.resolveProps(V??[],{indicator:"map-value-ind",next:B,offset:P.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!L||L.type==="block-scalar"});if(H=K.end,K.found){if(O){if(B?.type==="block-map"&&!K.hasNewline)Q(H,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(q.options.strict&&z.start<K.found.offset-1024)Q(P.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let C=B?X(q,B,K,Q):U(q,H,V,null,K,Q);if(q.schema.compat)GQ.flowIndentCheck(Z.indent,B,Q);H=C.range[2];let N=new ZQ.Pair(P,C);if(q.options.keepSourceTokens)N.srcToken=$;J.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 ZQ.Pair(P);if(q.options.keepSourceTokens)C.srcToken=$;J.items.push(C)}}if(W&&W<H)Q(W,"IMPOSSIBLE","Map comment with trailing content");return J.range=[Z.offset,H,W??H],J}lL.resolveBlockMap=pL});var HQ=R((rL)=>{var cL=Z1(),iL=q6(),sL=uX();function oL({composeNode:X,composeEmptyNode:U},q,Z,Q,G){let J=new(G?.nodeClass??cL.YAMLSeq)(q.schema);if(q.atRoot)q.atRoot=!1;if(q.atKey)q.atKey=!1;let H=Z.offset,W=null;for(let{start:$,value:_}of Z.items){let L=iL.resolveProps($,{indicator:"seq-item-ind",next:_,offset:H,onError:Q,parentIndent:Z.indent,startOnNewline:!0});if(!L.found)if(L.anchor||L.tag||_)if(_?.type==="block-seq")Q(L.end,"BAD_INDENT","All sequence items must start at the same column");else Q(H,"MISSING_CHAR","Sequence item without - indicator");else{if(W=L.end,L.comment)J.comment=L.comment;continue}let V=_?X(q,_,L,Q):U(q,L.end,$,null,L,Q);if(q.schema.compat)sL.flowIndentCheck(Z.indent,_,Q);H=V.range[2],J.items.push(V)}return J.range=[Z.offset,H,W??H],J}rL.resolveBlockSeq=oL});var X2=R((tL)=>{function nL(X,U,q,Z){let Q="";if(X){let G=!1,Y="";for(let J of X){let{source:H,type:W}=J;switch(W){case"space":G=!0;break;case"comment":{if(q&&!G)Z(J,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let $=H.substring(1)||" ";if(!Q)Q=$;else Q+=Y+$;Y="";break}case"newline":if(Q)Y+=H;G=!0;break;default:Z(J,"UNEXPECTED_TOKEN",`Unexpected ${W} at node end`)}U+=H.length}}return{comment:Q,offset:U}}tL.resolveEnd=nL});var $Q=R((Jz)=>{var Xz=k(),Uz=X1(),WQ=q1(),qz=Z1(),Zz=X2(),_Q=q6(),Qz=w4(),Gz=mX(),pX="Block collections are not allowed within flow collections",lX=(X)=>X&&(X.type==="block-map"||X.type==="block-seq");function Yz({composeNode:X,composeEmptyNode:U},q,Z,Q,G){let Y=Z.start.source==="{",J=Y?"flow map":"flow sequence",W=new(G?.nodeClass??(Y?WQ.YAMLMap:qz.YAMLSeq))(q.schema);W.flow=!0;let $=q.atRoot;if($)q.atRoot=!1;if(q.atKey)q.atKey=!1;let _=Z.offset+Z.start.source.length;for(let O=0;O<Z.items.length;++O){let D=Z.items[O],{start:P,key:K,sep:C,value:N}=D,b=_Q.resolveProps(P,{flow:J,indicator:"explicit-key-ind",next:K??C?.[0],offset:_,onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(!b.found){if(!b.anchor&&!b.tag&&!C&&!N){if(O===0&&b.comma)Q(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${J}`);else if(O<Z.items.length-1)Q(b.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${J}`);if(b.comment)if(W.comment)W.comment+=`
66
- `+b.comment;else W.comment=b.comment;_=b.end;continue}if(!Y&&q.options.strict&&Qz.containsNewline(K))Q(K,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(O===0){if(b.comma)Q(b.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${J}`)}else{if(!b.comma)Q(b.start,"MISSING_CHAR",`Missing , between ${J} items`);if(b.comment){let m="";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(Xz.isPair(w))w=w.value??w.key;if(w.comment)w.comment+=`
67
- `+m;else w.comment=m;b.comment=b.comment.substring(m.length+1)}}}if(!Y&&!C&&!b.found){let m=N?X(q,N,b,Q):U(q,b.end,C,null,b,Q);if(W.items.push(m),_=m.range[2],lX(N))Q(m.range,"BLOCK_IN_FLOW",pX)}else{q.atKey=!0;let m=b.end,w=K?X(q,K,b,Q):U(q,m,P,null,b,Q);if(lX(K))Q(w.range,"BLOCK_IN_FLOW",pX);q.atKey=!1;let s=_Q.resolveProps(C??[],{flow:J,indicator:"map-value-ind",next:N,offset:w.range[2],onError:Q,parentIndent:Z.indent,startOnNewline:!1});if(s.found){if(!Y&&!b.found&&q.options.strict){if(C)for(let o of C){if(o===s.found)break;if(o.type==="newline"){Q(o,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(b.start<s.found.offset-1024)Q(s.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(N)if("source"in N&&N.source?.[0]===":")Q(N,"MISSING_CHAR",`Missing space after : in ${J}`);else Q(s.start,"MISSING_CHAR",`Missing , or : between ${J} items`);let p0=N?X(q,N,s,Q):s.found?U(q,s.end,C,null,s,Q):null;if(p0){if(lX(N))Q(p0.range,"BLOCK_IN_FLOW",pX)}else if(s.comment)if(w.comment)w.comment+=`
68
- `+s.comment;else w.comment=s.comment;let M1=new Uz.Pair(w,p0);if(q.options.keepSourceTokens)M1.srcToken=D;if(Y){let o=W;if(Gz.mapIncludes(q,o.items,w))Q(m,"DUPLICATE_KEY","Map keys must be unique");o.items.push(M1)}else{let o=new WQ.YAMLMap(q.schema);o.flow=!0,o.items.push(M1);let _U=(p0??w).range;o.range=[w.range[0],_U[1],_U[2]],W.items.push(o)}_=p0?p0.range[2]:s.end}}let L=Y?"}":"]",[V,...B]=Z.end,z=_;if(V?.source===L)z=V.offset+V.source.length;else{let O=J[0].toUpperCase()+J.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),V&&V.source.length!==1)B.unshift(V)}if(B.length>0){let O=Zz.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}Jz.resolveFlowCollection=Yz});var LQ=R((Oz)=>{var Wz=k(),_z=i(),$z=q1(),Lz=Z1(),zz=JQ(),Fz=HQ(),Vz=$Q();function dX(X,U,q,Z,Q,G){let Y=q.type==="block-map"?zz.resolveBlockMap(X,U,q,Z,G):q.type==="block-seq"?Fz.resolveBlockSeq(X,U,q,Z,G):Vz.resolveFlowCollection(X,U,q,Z,G),J=Y.constructor;if(Q==="!"||Q===J.tagName)return Y.tag=J.tagName,Y;if(Q)Y.tag=Q;return Y}function Az(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:V}=Z,B=L&&G?L.offset>G.offset?L:G:L??G;if(B&&(!V||V.offset<B.offset))Q(B,"MISSING_CHAR","Missing newline after block sequence props")}let J=q.type==="block-map"?"map":q.type==="block-seq"?"seq":q.start.source==="{"?"map":"seq";if(!G||!Y||Y==="!"||Y===$z.YAMLMap.tagName&&J==="map"||Y===Lz.YAMLSeq.tagName&&J==="seq")return dX(X,U,q,Q,Y);let H=U.schema.tags.find((L)=>L.tag===Y&&L.collection===J);if(!H){let L=U.schema.knownTags[Y];if(L?.collection===J)U.schema.tags.push(Object.assign({},L,{default:!1})),H=L;else{if(L)Q(G,"BAD_COLLECTION_TYPE",`${L.tag} used for ${J} collection, but expects ${L.collection??"scalar"}`,!0);else Q(G,"TAG_RESOLVE_FAILED",`Unresolved tag: ${Y}`,!0);return dX(X,U,q,Q,Y)}}let W=dX(X,U,q,Q,Y,H),$=H.resolve?.(W,(L)=>Q(G,"TAG_RESOLVE_FAILED",L),U.options)??W,_=Wz.isNode($)?$:new _z.Scalar($);if(_.range=W.range,_.tag=Y,H?.format)_.format=H.format;return _}Oz.composeCollection=Az});var iX=R((Mz)=>{var cX=i();function Bz(X,U,q){let Z=U.offset,Q=Rz(U,X.options.strict,q);if(!Q)return{value:"",type:null,comment:"",range:[Z,Z,Z]};let G=Q.mode===">"?cX.Scalar.BLOCK_FOLDED:cX.Scalar.BLOCK_LITERAL,Y=U.source?Dz(U.source):[],J=Y.length;for(let z=Y.length-1;z>=0;--z){let O=Y[z][1];if(O===""||O==="\r")J=z;else break}if(J===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 H=U.indent+Q.indent,W=U.offset+Q.length,$=0;for(let z=0;z<J;++z){let[O,D]=Y[z];if(D===""||D==="\r"){if(Q.indent===0&&O.length>H)H=O.length}else{if(O.length<H)q(W+O.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(Q.indent===0)H=O.length;if($=z,H===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>=J;--z)if(Y[z][0].length>H)J=z+1;let _="",L="",V=!1;for(let z=0;z<$;++z)_+=Y[z][0].slice(H)+`
71
- `;for(let z=$;z<J;++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<H){let C=`Block scalar lines must not be less indented than their ${Q.indent?"explicit indentation indicator":"first line"}`;q(W-D.length-(P?2:1),"BAD_INDENT",C),O=""}if(G===cX.Scalar.BLOCK_LITERAL)_+=L+O.slice(H)+D,L=`
72
- `;else if(O.length>H||D[0]==="\t"){if(L===" ")L=`
73
- `;else if(!V&&L===`
74
- `)L=`
106
+ ${L}
107
+ `}};CB.YAMLError=XZ;CB.YAMLParseError=vq;CB.YAMLWarning=xq;CB.prettifyError=SB});var F4=C((fB)=>{function IB(Z,{flow:X,indicator:Q,next:U,offset:J,onError:q,parentIndent:Y,startOnNewline:W}){let $=!1,L=W,_=W,G="",V="",z=!1,F=!1,H=null,B=null,T=null,D=null,K=null,w=null,S=null;for(let N of Z){if(F){if(N.type!=="space"&&N.type!=="newline"&&N.type!=="comma")q(N.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");F=!1}if(H){if(L&&N.type!=="comment"&&N.type!=="newline")q(H,"TAB_AS_INDENT","Tabs are not allowed as indentation");H=null}switch(N.type){case"space":if(!X&&(Q!=="doc-start"||U?.type!=="flow-collection")&&N.source.includes("\t"))H=N;_=!0;break;case"comment":{if(!_)q(N,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let x=N.source.substring(1)||" ";if(!G)G=x;else G+=V+x;V="",L=!1;break}case"newline":if(L){if(G)G+=N.source;else if(!w||Q!=="seq-item-ind")$=!0}else V+=N.source;if(L=!0,z=!0,B||T)D=N;_=!0;break;case"anchor":if(B)q(N,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(N.source.endsWith(":"))q(N.offset+N.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);B=N,S??(S=N.offset),L=!1,_=!1,F=!0;break;case"tag":{if(T)q(N,"MULTIPLE_TAGS","A node can have at most one tag");T=N,S??(S=N.offset),L=!1,_=!1,F=!0;break}case Q:if(B||T)q(N,"BAD_PROP_ORDER",`Anchors and tags must be after the ${N.source} indicator`);if(w)q(N,"UNEXPECTED_TOKEN",`Unexpected ${N.source} in ${X??"collection"}`);w=N,L=Q==="seq-item-ind"||Q==="explicit-key-ind",_=!1;break;case"comma":if(X){if(K)q(N,"UNEXPECTED_TOKEN",`Unexpected , in ${X}`);K=N,L=!1,_=!1;break}default:q(N,"UNEXPECTED_TOKEN",`Unexpected ${N.type} token`),L=!1,_=!1}}let j=Z[Z.length-1],v=j?j.offset+j.source.length:J;if(F&&U&&U.type!=="space"&&U.type!=="newline"&&U.type!=="comma"&&(U.type!=="scalar"||U.source!==""))q(U.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(H&&(L&&H.indent<=Y||U?.type==="block-map"||U?.type==="block-seq"))q(H,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:K,found:w,spaceBefore:$,comment:G,hasNewline:z,anchor:B,tag:T,newlineAfterProp:D,end:v,start:S??v}}fB.resolveProps=IB});var QZ=C((yB)=>{function M3(Z){if(!Z)return null;switch(Z.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(Z.source.includes(`
108
+ `))return!0;if(Z.end){for(let X of Z.end)if(X.type==="newline")return!0}return!1;case"flow-collection":for(let X of Z.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(M3(X.key)||M3(X.value))return!0}return!1;default:return!0}}yB.containsNewline=M3});var O3=C((hB)=>{var vB=QZ();function xB(Z,X,Q){if(X?.type==="flow-collection"){let U=X.end[0];if(U.indent===Z&&(U.source==="]"||U.source==="}")&&vB.containsNewline(X))Q(U,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}hB.flowIndentCheck=xB});var R3=C((pB)=>{var hq=l();function uB(Z,X,Q){let{uniqueKeys:U}=Z.options;if(U===!1)return!1;let J=typeof U==="function"?U:(q,Y)=>q===Y||hq.isScalar(q)&&hq.isScalar(Y)&&q.value===Y.value;return X.some((q)=>J(q.key,Q))}pB.mapIncludes=uB});var dq=C((aB)=>{var mq=u1(),dB=l1(),uq=F4(),cB=QZ(),pq=O3(),iB=R3(),lq="All mapping items must start at the same column";function sB({composeNode:Z,composeEmptyNode:X},Q,U,J,q){let W=new(q?.nodeClass??dB.YAMLMap)(Q.schema);if(Q.atRoot)Q.atRoot=!1;let $=U.offset,L=null;for(let _ of U.items){let{start:G,key:V,sep:z,value:F}=_,H=uq.resolveProps(G,{indicator:"explicit-key-ind",next:V??z?.[0],offset:$,onError:J,parentIndent:U.indent,startOnNewline:!0}),B=!H.found;if(B){if(V){if(V.type==="block-seq")J($,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in V&&V.indent!==U.indent)J($,"BAD_INDENT",lq)}if(!H.anchor&&!H.tag&&!z){if(L=H.end,H.comment)if(W.comment)W.comment+=`
109
+ `+H.comment;else W.comment=H.comment;continue}if(H.newlineAfterProp||cB.containsNewline(V))J(V??G[G.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(H.found?.indent!==U.indent)J($,"BAD_INDENT",lq);Q.atKey=!0;let T=H.end,D=V?Z(Q,V,H,J):X(Q,T,G,null,H,J);if(Q.schema.compat)pq.flowIndentCheck(U.indent,V,J);if(Q.atKey=!1,iB.mapIncludes(Q,W.items,D))J(T,"DUPLICATE_KEY","Map keys must be unique");let K=uq.resolveProps(z??[],{indicator:"map-value-ind",next:F,offset:D.range[2],onError:J,parentIndent:U.indent,startOnNewline:!V||V.type==="block-scalar"});if($=K.end,K.found){if(B){if(F?.type==="block-map"&&!K.hasNewline)J($,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(Q.options.strict&&H.start<K.found.offset-1024)J(D.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let w=F?Z(Q,F,K,J):X(Q,$,z,null,K,J);if(Q.schema.compat)pq.flowIndentCheck(U.indent,F,J);$=w.range[2];let S=new mq.Pair(D,w);if(Q.options.keepSourceTokens)S.srcToken=_;W.items.push(S)}else{if(B)J(D.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(K.comment)if(D.comment)D.comment+=`
110
+ `+K.comment;else D.comment=K.comment;let w=new mq.Pair(D);if(Q.options.keepSourceTokens)w.srcToken=_;W.items.push(w)}}if(L&&L<$)J(L,"IMPOSSIBLE","Map comment with trailing content");return W.range=[U.offset,$,L??$],W}aB.resolveBlockMap=sB});var cq=C((ZM)=>{var oB=d1(),nB=F4(),tB=O3();function eB({composeNode:Z,composeEmptyNode:X},Q,U,J,q){let W=new(q?.nodeClass??oB.YAMLSeq)(Q.schema);if(Q.atRoot)Q.atRoot=!1;if(Q.atKey)Q.atKey=!1;let $=U.offset,L=null;for(let{start:_,value:G}of U.items){let V=nB.resolveProps(_,{indicator:"seq-item-ind",next:G,offset:$,onError:J,parentIndent:U.indent,startOnNewline:!0});if(!V.found)if(V.anchor||V.tag||G)if(G?.type==="block-seq")J(V.end,"BAD_INDENT","All sequence items must start at the same column");else J($,"MISSING_CHAR","Sequence item without - indicator");else{if(L=V.end,V.comment)W.comment=V.comment;continue}let z=G?Z(Q,G,V,J):X(Q,V.end,_,null,V,J);if(Q.schema.compat)tB.flowIndentCheck(U.indent,G,J);$=z.range[2],W.items.push(z)}return W.range=[U.offset,$,L??$],W}ZM.resolveBlockSeq=eB});var e2=C((UM)=>{function QM(Z,X,Q,U){let J="";if(Z){let q=!1,Y="";for(let W of Z){let{source:$,type:L}=W;switch(L){case"space":q=!0;break;case"comment":{if(Q&&!q)U(W,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=$.substring(1)||" ";if(!J)J=_;else J+=Y+_;Y="";break}case"newline":if(J)Y+=$;q=!0;break;default:U(W,"UNEXPECTED_TOKEN",`Unexpected ${L} at node end`)}X+=$.length}}return{comment:J,offset:X}}UM.resolveEnd=QM});var aq=C((VM)=>{var qM=l(),YM=u1(),iq=l1(),WM=d1(),$M=e2(),sq=F4(),LM=QZ(),GM=R3(),K3="Block collections are not allowed within flow collections",T3=(Z)=>Z&&(Z.type==="block-map"||Z.type==="block-seq");function _M({composeNode:Z,composeEmptyNode:X},Q,U,J,q){let Y=U.start.source==="{",W=Y?"flow map":"flow sequence",L=new(q?.nodeClass??(Y?iq.YAMLMap:WM.YAMLSeq))(Q.schema);L.flow=!0;let _=Q.atRoot;if(_)Q.atRoot=!1;if(Q.atKey)Q.atKey=!1;let G=U.offset+U.start.source.length;for(let B=0;B<U.items.length;++B){let T=U.items[B],{start:D,key:K,sep:w,value:S}=T,j=sq.resolveProps(D,{flow:W,indicator:"explicit-key-ind",next:K??w?.[0],offset:G,onError:J,parentIndent:U.indent,startOnNewline:!1});if(!j.found){if(!j.anchor&&!j.tag&&!w&&!S){if(B===0&&j.comma)J(j.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${W}`);else if(B<U.items.length-1)J(j.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${W}`);if(j.comment)if(L.comment)L.comment+=`
111
+ `+j.comment;else L.comment=j.comment;G=j.end;continue}if(!Y&&Q.options.strict&&LM.containsNewline(K))J(K,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(B===0){if(j.comma)J(j.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${W}`)}else{if(!j.comma)J(j.start,"MISSING_CHAR",`Missing , between ${W} items`);if(j.comment){let v="";Z:for(let N of D)switch(N.type){case"comma":case"space":break;case"comment":v=N.source.substring(1);break Z;default:break Z}if(v){let N=L.items[L.items.length-1];if(qM.isPair(N))N=N.value??N.key;if(N.comment)N.comment+=`
112
+ `+v;else N.comment=v;j.comment=j.comment.substring(v.length+1)}}}if(!Y&&!w&&!j.found){let v=S?Z(Q,S,j,J):X(Q,j.end,w,null,j,J);if(L.items.push(v),G=v.range[2],T3(S))J(v.range,"BLOCK_IN_FLOW",K3)}else{Q.atKey=!0;let v=j.end,N=K?Z(Q,K,j,J):X(Q,v,D,null,j,J);if(T3(K))J(N.range,"BLOCK_IN_FLOW",K3);Q.atKey=!1;let x=sq.resolveProps(w??[],{flow:W,indicator:"map-value-ind",next:S,offset:N.range[2],onError:J,parentIndent:U.indent,startOnNewline:!1});if(x.found){if(!Y&&!j.found&&Q.options.strict){if(w)for(let a of w){if(a===x.found)break;if(a.type==="newline"){J(a,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(j.start<x.found.offset-1024)J(x.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(S)if("source"in S&&S.source?.[0]===":")J(S,"MISSING_CHAR",`Missing space after : in ${W}`);else J(x.start,"MISSING_CHAR",`Missing , or : between ${W} items`);let s=S?Z(Q,S,x,J):x.found?X(Q,x.end,w,null,x,J):null;if(s){if(T3(S))J(s.range,"BLOCK_IN_FLOW",K3)}else if(x.comment)if(N.comment)N.comment+=`
113
+ `+x.comment;else N.comment=x.comment;let Q0=new YM.Pair(N,s);if(Q.options.keepSourceTokens)Q0.srcToken=T;if(Y){let a=L;if(GM.mapIncludes(Q,a.items,N))J(v,"DUPLICATE_KEY","Map keys must be unique");a.items.push(Q0)}else{let a=new iq.YAMLMap(Q.schema);a.flow=!0,a.items.push(Q0);let V0=(s??N).range;a.range=[N.range[0],V0[1],V0[2]],L.items.push(a)}G=s?s.range[2]:x.end}}let V=Y?"}":"]",[z,...F]=U.end,H=G;if(z?.source===V)H=z.offset+z.source.length;else{let B=W[0].toUpperCase()+W.substring(1),T=_?`${B} must end with a ${V}`:`${B} in block collection must be sufficiently indented and end with a ${V}`;if(J(G,_?"MISSING_CHAR":"BAD_INDENT",T),z&&z.source.length!==1)F.unshift(z)}if(F.length>0){let B=$M.resolveEnd(F,H,Q.options.strict,J);if(B.comment)if(L.comment)L.comment+=`
114
+ `+B.comment;else L.comment=B.comment;L.range=[U.offset,H,B.offset]}else L.range=[U.offset,H,H];return L}VM.resolveFlowCollection=_M});var rq=C((DM)=>{var zM=l(),FM=W0(),BM=l1(),MM=d1(),OM=dq(),RM=cq(),KM=aq();function D3(Z,X,Q,U,J,q){let Y=Q.type==="block-map"?OM.resolveBlockMap(Z,X,Q,U,q):Q.type==="block-seq"?RM.resolveBlockSeq(Z,X,Q,U,q):KM.resolveFlowCollection(Z,X,Q,U,q),W=Y.constructor;if(J==="!"||J===W.tagName)return Y.tag=W.tagName,Y;if(J)Y.tag=J;return Y}function TM(Z,X,Q,U,J){let q=U.tag,Y=!q?null:X.directives.tagName(q.source,(V)=>J(q,"TAG_RESOLVE_FAILED",V));if(Q.type==="block-seq"){let{anchor:V,newlineAfterProp:z}=U,F=V&&q?V.offset>q.offset?V:q:V??q;if(F&&(!z||z.offset<F.offset))J(F,"MISSING_CHAR","Missing newline after block sequence props")}let W=Q.type==="block-map"?"map":Q.type==="block-seq"?"seq":Q.start.source==="{"?"map":"seq";if(!q||!Y||Y==="!"||Y===BM.YAMLMap.tagName&&W==="map"||Y===MM.YAMLSeq.tagName&&W==="seq")return D3(Z,X,Q,J,Y);let $=X.schema.tags.find((V)=>V.tag===Y&&V.collection===W);if(!$){let V=X.schema.knownTags[Y];if(V?.collection===W)X.schema.tags.push(Object.assign({},V,{default:!1})),$=V;else{if(V)J(q,"BAD_COLLECTION_TYPE",`${V.tag} used for ${W} collection, but expects ${V.collection??"scalar"}`,!0);else J(q,"TAG_RESOLVE_FAILED",`Unresolved tag: ${Y}`,!0);return D3(Z,X,Q,J,Y)}}let L=D3(Z,X,Q,J,Y,$),_=$.resolve?.(L,(V)=>J(q,"TAG_RESOLVE_FAILED",V),X.options)??L,G=zM.isNode(_)?_:new FM.Scalar(_);if(G.range=L.range,G.tag=Y,$?.format)G.format=$.format;return G}DM.composeCollection=TM});var P3=C((CM)=>{var w3=W0();function PM(Z,X,Q){let U=X.offset,J=AM(X,Z.options.strict,Q);if(!J)return{value:"",type:null,comment:"",range:[U,U,U]};let q=J.mode===">"?w3.Scalar.BLOCK_FOLDED:w3.Scalar.BLOCK_LITERAL,Y=X.source?SM(X.source):[],W=Y.length;for(let H=Y.length-1;H>=0;--H){let B=Y[H][1];if(B===""||B==="\r")W=H;else break}if(W===0){let H=J.chomp==="+"&&Y.length>0?`
115
+ `.repeat(Math.max(1,Y.length-1)):"",B=U+J.length;if(X.source)B+=X.source.length;return{value:H,type:q,comment:J.comment,range:[U,B,B]}}let $=X.indent+J.indent,L=X.offset+J.length,_=0;for(let H=0;H<W;++H){let[B,T]=Y[H];if(T===""||T==="\r"){if(J.indent===0&&B.length>$)$=B.length}else{if(B.length<$)Q(L+B.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(J.indent===0)$=B.length;if(_=H,$===0&&!Z.atRoot)Q(L,"BAD_INDENT","Block scalar values in collections must be indented");break}L+=B.length+T.length+1}for(let H=Y.length-1;H>=W;--H)if(Y[H][0].length>$)W=H+1;let G="",V="",z=!1;for(let H=0;H<_;++H)G+=Y[H][0].slice($)+`
116
+ `;for(let H=_;H<W;++H){let[B,T]=Y[H];L+=B.length+T.length+1;let D=T[T.length-1]==="\r";if(D)T=T.slice(0,-1);if(T&&B.length<$){let w=`Block scalar lines must not be less indented than their ${J.indent?"explicit indentation indicator":"first line"}`;Q(L-T.length-(D?2:1),"BAD_INDENT",w),B=""}if(q===w3.Scalar.BLOCK_LITERAL)G+=V+B.slice($)+T,V=`
117
+ `;else if(B.length>$||T[0]==="\t"){if(V===" ")V=`
118
+ `;else if(!z&&V===`
119
+ `)V=`
75
120
 
76
- `;_+=L+O.slice(H)+D,L=`
77
- `,V=!0}else if(D==="")if(L===`
78
- `)_+=`
79
- `;else L=`
80
- `;else _+=L+D,L=" ",V=!1}switch(Q.chomp){case"-":break;case"+":for(let z=J;z<Y.length;++z)_+=`
81
- `+Y[z][0].slice(H);if(_[_.length-1]!==`
82
- `)_+=`
83
- `;break;default:_+=`
84
- `}let B=Z+Q.length+U.source.length;return{value:_,type:G,comment:Q.comment,range:[Z,B,B]}}function Rz({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,J="",H=-1;for(let L=1;L<Q.length;++L){let V=Q[L];if(!J&&(V==="-"||V==="+"))J=V;else{let B=Number(V);if(!Y&&B)Y=B;else if(H===-1)H=X+L}}if(H!==-1)Z(H,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${Q}`);let W=!1,$="",_=Q.length;for(let L=1;L<U.length;++L){let V=U[L];switch(V.type){case"space":W=!0;case"newline":_+=V.source.length;break;case"comment":if(q&&!W)Z(V,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");_+=V.source.length,$=V.source.substring(1);break;case"error":Z(V,"UNEXPECTED_TOKEN",V.message),_+=V.source.length;break;default:{let B=`Unexpected token in block scalar header: ${V.type}`;Z(V,"UNEXPECTED_TOKEN",B);let z=V.source;if(z&&typeof z==="string")_+=z.length}}}return{mode:G,indent:Y,chomp:J,comment:$,length:_}}function Dz(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}Mz.resolveBlockScalar=Bz});var oX=R((bz)=>{var sX=i(),Pz=X2();function Iz(X,U,q){let{offset:Z,type:Q,source:G,end:Y}=X,J,H,W=(L,V,B)=>q(Z+L,V,B);switch(Q){case"scalar":J=sX.Scalar.PLAIN,H=Kz(G,W);break;case"single-quoted-scalar":J=sX.Scalar.QUOTE_SINGLE,H=Nz(G,W);break;case"double-quoted-scalar":J=sX.Scalar.QUOTE_DOUBLE,H=Cz(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,_=Pz.resolveEnd(Y,$,U,q);return{value:H,type:J,comment:_.comment,range:[Z,$,_.offset]}}function Kz(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 zQ(X)}function Nz(X,U){if(X[X.length-1]!=="'"||X.length===1)U(X.length,"MISSING_CHAR","Missing closing 'quote");return zQ(X.slice(1,-1)).replace(/''/g,"'")}function zQ(X){let U,q;try{U=new RegExp(`(.*?)(?<![ ])[ ]*\r?
85
- `,"sy"),q=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
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
- `)Q+=G;else G=`
88
- `;else Q+=G+Z[1],G=" ";Y=q.lastIndex}let J=/[ \t]*(.*)/sy;return J.lastIndex=Y,Z=J.exec(X),Q+G+(Z?.[1]??"")}function Cz(X,U){let q="";for(let Z=1;Z<X.length-1;++Z){let Q=X[Z];if(Q==="\r"&&X[Z+1]===`
89
- `)continue;if(Q===`
90
- `){let{fold:G,offset:Y}=Sz(X,Z);q+=G,Z=Y}else if(Q==="\\"){let G=X[++Z],Y=Ez[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 J={x:2,u:4,U:8}[G];q+=jz(X,Z+1,J,U),Z+=J}else{let J=X.substr(Z-1,2);U(Z-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${J}`),q+=J}}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 Sz(X,U){let q="",Z=X[U+1];while(Z===" "||Z==="\t"||Z===`
95
- `||Z==="\r"){if(Z==="\r"&&X[U+2]!==`
96
- `)break;if(Z===`
97
- `)q+=`
98
- `;U+=1,Z=X[U+1]}if(!q)q=" ";return{fold:q,offset:U}}var Ez={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
- `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function jz(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 J=X.substr(U-2,q+2);return Z(U-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${J}`),J}return String.fromCodePoint(Y)}bz.resolveFlowScalar=Iz});var VQ=R((xz)=>{var B1=k(),FQ=i(),gz=iX(),yz=oX();function kz(X,U,q,Z){let{value:Q,type:G,comment:Y,range:J}=U.type==="block-scalar"?gz.resolveBlockScalar(X,U,Z):yz.resolveFlowScalar(U,X.options.strict,Z),H=q?X.directives.tagName(q.source,(_)=>Z(q,"TAG_RESOLVE_FAILED",_)):null,W;if(X.options.stringKeys&&X.atKey)W=X.schema[B1.SCALAR];else if(H)W=vz(X.schema,Q,H,q,Z);else if(U.type==="scalar")W=hz(X,Q,U,Z);else W=X.schema[B1.SCALAR];let $;try{let _=W.resolve(Q,(L)=>Z(q??U,"TAG_RESOLVE_FAILED",L),X.options);$=B1.isScalar(_)?_:new FQ.Scalar(_)}catch(_){let L=_ instanceof Error?_.message:String(_);Z(q??U,"TAG_RESOLVE_FAILED",L),$=new FQ.Scalar(Q)}if($.range=J,$.source=Q,G)$.type=G;if(H)$.tag=H;if(W.format)$.format=W.format;if(Y)$.comment=Y;return $}function vz(X,U,q,Z,Q){if(q==="!")return X[B1.SCALAR];let G=[];for(let J of X.tags)if(!J.collection&&J.tag===q)if(J.default&&J.test)G.push(J);else return J;for(let J of G)if(J.test?.test(U))return J;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[B1.SCALAR]}function hz({atKey:X,directives:U,schema:q},Z,Q,G){let Y=q.tags.find((J)=>(J.default===!0||X&&J.default==="key")&&J.test?.test(Z))||q[B1.SCALAR];if(q.compat){let J=q.compat.find((H)=>H.default&&H.test?.test(Z))??q[B1.SCALAR];if(Y.tag!==J.tag){let H=U.tagString(Y.tag),W=U.tagString(J.tag),$=`Value may be parsed as either ${H} or ${W}`;G(Q,"TAG_RESOLVE_FAILED",$,!0)}}return Y}xz.composeScalar=kz});var AQ=R((pz)=>{function mz(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}pz.emptyScalarPosition=mz});var BQ=R((nz)=>{var dz=x2(),cz=k(),iz=LQ(),OQ=VQ(),sz=X2(),oz=AQ(),rz={composeNode:TQ,composeEmptyNode:rX};function TQ(X,U,q,Z){let Q=X.atKey,{spaceBefore:G,comment:Y,anchor:J,tag:H}=q,W,$=!0;switch(U.type){case"alias":if(W=az(X,U,Z),J||H)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=OQ.composeScalar(X,U,H,Z),J)W.anchor=J.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(W=iz.composeCollection(rz,X,U,q,Z),J)W.anchor=J.source.substring(1);break;default:{let _=U.type==="error"?U.message:`Unsupported token (type: ${U.type})`;Z(U,"UNEXPECTED_TOKEN",_),W=rX(X,U.offset,void 0,null,q,Z),$=!1}}if(J&&W.anchor==="")Z(J,"BAD_ALIAS","Anchor cannot be an empty string");if(Q&&X.options.stringKeys&&(!cz.isScalar(W)||typeof W.value!=="string"||W.tag&&W.tag!=="tag:yaml.org,2002:str"))Z(H??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 rX(X,U,q,Z,{spaceBefore:Q,comment:G,anchor:Y,tag:J,end:H},W){let $={type:"scalar",offset:oz.emptyScalarPosition(U,q,Z),indent:-1,source:""},_=OQ.composeScalar(X,$,J,W);if(Y){if(_.anchor=Y.source.substring(1),_.anchor==="")W(Y,"BAD_ALIAS","Anchor cannot be an empty string")}if(Q)_.spaceBefore=!0;if(G)_.comment=G,_.range[2]=H;return _}function az({options:X},{offset:U,source:q,end:Z},Q){let G=new dz.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,J=sz.resolveEnd(Z,Y,X.strict,Q);if(G.range=[U,Y,J.offset],J.comment)G.comment=J.comment;return G}nz.composeEmptyNode=rX;nz.composeNode=TQ});var DQ=R((QF)=>{var XF=X6(),RQ=BQ(),UF=X2(),qF=q6();function ZF(X,U,{offset:q,start:Z,value:Q,end:G},Y){let J=Object.assign({_directives:U},X),H=new XF.Document(void 0,J),W={atKey:!1,atRoot:!0,directives:H.directives,options:H.options,schema:H.schema},$=qF.resolveProps(Z,{indicator:"doc-start",next:Q??G?.[0],offset:q,onError:Y,parentIndent:0,startOnNewline:!0});if($.found){if(H.directives.docStart=!0,Q&&(Q.type==="block-map"||Q.type==="block-seq")&&!$.hasNewline)Y($.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}H.contents=Q?RQ.composeNode(W,Q,$,Y):RQ.composeEmptyNode(W,$.end,Z,null,$,Y);let _=H.contents.range[2],L=UF.resolveEnd(G,_,!1,Y);if(L.comment)H.comment=L.comment;return H.range=[q,_,L.offset],H}QF.composeDoc=ZF});var aX=R(($F)=>{var YF=w1("process"),JF=XX(),HF=X6(),Z6=U6(),MQ=k(),WF=DQ(),_F=X2();function Q6(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 wQ(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?`
121
+ `;G+=V+B.slice($)+T,V=`
122
+ `,z=!0}else if(T==="")if(V===`
123
+ `)G+=`
124
+ `;else V=`
125
+ `;else G+=V+T,V=" ",z=!1}switch(J.chomp){case"-":break;case"+":for(let H=W;H<Y.length;++H)G+=`
126
+ `+Y[H][0].slice($);if(G[G.length-1]!==`
127
+ `)G+=`
128
+ `;break;default:G+=`
129
+ `}let F=U+J.length+X.source.length;return{value:G,type:q,comment:J.comment,range:[U,F,F]}}function AM({offset:Z,props:X},Q,U){if(X[0].type!=="block-scalar-header")return U(X[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:J}=X[0],q=J[0],Y=0,W="",$=-1;for(let V=1;V<J.length;++V){let z=J[V];if(!W&&(z==="-"||z==="+"))W=z;else{let F=Number(z);if(!Y&&F)Y=F;else if($===-1)$=Z+V}}if($!==-1)U($,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${J}`);let L=!1,_="",G=J.length;for(let V=1;V<X.length;++V){let z=X[V];switch(z.type){case"space":L=!0;case"newline":G+=z.source.length;break;case"comment":if(Q&&!L)U(z,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");G+=z.source.length,_=z.source.substring(1);break;case"error":U(z,"UNEXPECTED_TOKEN",z.message),G+=z.source.length;break;default:{let F=`Unexpected token in block scalar header: ${z.type}`;U(z,"UNEXPECTED_TOKEN",F);let H=z.source;if(H&&typeof H==="string")G+=H.length}}}return{mode:q,indent:Y,chomp:W,comment:_,length:G}}function SM(Z){let X=Z.split(/\n( *)/),Q=X[0],U=Q.match(/^( *)/),q=[U?.[1]?[U[1],Q.slice(U[1].length)]:["",Q]];for(let Y=1;Y<X.length;Y+=2)q.push([X[Y],X[Y+1]]);return q}CM.resolveBlockScalar=PM});var S3=C((vM)=>{var A3=W0(),jM=e2();function EM(Z,X,Q){let{offset:U,type:J,source:q,end:Y}=Z,W,$,L=(V,z,F)=>Q(U+V,z,F);switch(J){case"scalar":W=A3.Scalar.PLAIN,$=bM(q,L);break;case"single-quoted-scalar":W=A3.Scalar.QUOTE_SINGLE,$=IM(q,L);break;case"double-quoted-scalar":W=A3.Scalar.QUOTE_DOUBLE,$=fM(q,L);break;default:return Q(Z,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${J}`),{value:"",type:null,comment:"",range:[U,U+q.length,U+q.length]}}let _=U+q.length,G=jM.resolveEnd(Y,_,X,Q);return{value:$,type:W,comment:G.comment,range:[U,_,G.offset]}}function bM(Z,X){let Q="";switch(Z[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 ${Z[0]}`;break}case"@":case"`":{Q=`reserved character ${Z[0]}`;break}}if(Q)X(0,"BAD_SCALAR_START",`Plain value cannot start with ${Q}`);return oq(Z)}function IM(Z,X){if(Z[Z.length-1]!=="'"||Z.length===1)X(Z.length,"MISSING_CHAR","Missing closing 'quote");return oq(Z.slice(1,-1)).replace(/''/g,"'")}function oq(Z){let X,Q;try{X=new RegExp(`(.*?)(?<![ ])[ ]*\r?
130
+ `,"sy"),Q=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
131
+ `,"sy")}catch{X=/(.*?)[ \t]*\r?\n/sy,Q=/[ \t]*(.*?)[ \t]*\r?\n/sy}let U=X.exec(Z);if(!U)return Z;let J=U[1],q=" ",Y=X.lastIndex;Q.lastIndex=Y;while(U=Q.exec(Z)){if(U[1]==="")if(q===`
132
+ `)J+=q;else q=`
133
+ `;else J+=q+U[1],q=" ";Y=Q.lastIndex}let W=/[ \t]*(.*)/sy;return W.lastIndex=Y,U=W.exec(Z),J+q+(U?.[1]??"")}function fM(Z,X){let Q="";for(let U=1;U<Z.length-1;++U){let J=Z[U];if(J==="\r"&&Z[U+1]===`
134
+ `)continue;if(J===`
135
+ `){let{fold:q,offset:Y}=kM(Z,U);Q+=q,U=Y}else if(J==="\\"){let q=Z[++U],Y=yM[q];if(Y)Q+=Y;else if(q===`
136
+ `){q=Z[U+1];while(q===" "||q==="\t")q=Z[++U+1]}else if(q==="\r"&&Z[U+1]===`
137
+ `){q=Z[++U+1];while(q===" "||q==="\t")q=Z[++U+1]}else if(q==="x"||q==="u"||q==="U"){let W={x:2,u:4,U:8}[q];Q+=gM(Z,U+1,W,X),U+=W}else{let W=Z.substr(U-1,2);X(U-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${W}`),Q+=W}}else if(J===" "||J==="\t"){let q=U,Y=Z[U+1];while(Y===" "||Y==="\t")Y=Z[++U+1];if(Y!==`
138
+ `&&!(Y==="\r"&&Z[U+2]===`
139
+ `))Q+=U>q?Z.slice(q,U+1):J}else Q+=J}if(Z[Z.length-1]!=='"'||Z.length===1)X(Z.length,"MISSING_CHAR",'Missing closing "quote');return Q}function kM(Z,X){let Q="",U=Z[X+1];while(U===" "||U==="\t"||U===`
140
+ `||U==="\r"){if(U==="\r"&&Z[X+2]!==`
141
+ `)break;if(U===`
142
+ `)Q+=`
143
+ `;X+=1,U=Z[X+1]}if(!Q)Q=" ";return{fold:Q,offset:X}}var yM={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
144
+ `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function gM(Z,X,Q,U){let J=Z.substr(X,Q),Y=J.length===Q&&/^[0-9a-fA-F]+$/.test(J)?parseInt(J,16):NaN;if(isNaN(Y)){let W=Z.substr(X-2,Q+2);return U(X-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${W}`),W}return String.fromCodePoint(Y)}vM.resolveFlowScalar=EM});var tq=C((dM)=>{var _2=l(),nq=W0(),hM=P3(),mM=S3();function uM(Z,X,Q,U){let{value:J,type:q,comment:Y,range:W}=X.type==="block-scalar"?hM.resolveBlockScalar(Z,X,U):mM.resolveFlowScalar(X,Z.options.strict,U),$=Q?Z.directives.tagName(Q.source,(G)=>U(Q,"TAG_RESOLVE_FAILED",G)):null,L;if(Z.options.stringKeys&&Z.atKey)L=Z.schema[_2.SCALAR];else if($)L=pM(Z.schema,J,$,Q,U);else if(X.type==="scalar")L=lM(Z,J,X,U);else L=Z.schema[_2.SCALAR];let _;try{let G=L.resolve(J,(V)=>U(Q??X,"TAG_RESOLVE_FAILED",V),Z.options);_=_2.isScalar(G)?G:new nq.Scalar(G)}catch(G){let V=G instanceof Error?G.message:String(G);U(Q??X,"TAG_RESOLVE_FAILED",V),_=new nq.Scalar(J)}if(_.range=W,_.source=J,q)_.type=q;if($)_.tag=$;if(L.format)_.format=L.format;if(Y)_.comment=Y;return _}function pM(Z,X,Q,U,J){if(Q==="!")return Z[_2.SCALAR];let q=[];for(let W of Z.tags)if(!W.collection&&W.tag===Q)if(W.default&&W.test)q.push(W);else return W;for(let W of q)if(W.test?.test(X))return W;let Y=Z.knownTags[Q];if(Y&&!Y.collection)return Z.tags.push(Object.assign({},Y,{default:!1,test:void 0})),Y;return J(U,"TAG_RESOLVE_FAILED",`Unresolved tag: ${Q}`,Q!=="tag:yaml.org,2002:str"),Z[_2.SCALAR]}function lM({atKey:Z,directives:X,schema:Q},U,J,q){let Y=Q.tags.find((W)=>(W.default===!0||Z&&W.default==="key")&&W.test?.test(U))||Q[_2.SCALAR];if(Q.compat){let W=Q.compat.find(($)=>$.default&&$.test?.test(U))??Q[_2.SCALAR];if(Y.tag!==W.tag){let $=X.tagString(Y.tag),L=X.tagString(W.tag),_=`Value may be parsed as either ${$} or ${L}`;q(J,"TAG_RESOLVE_FAILED",_,!0)}}return Y}dM.composeScalar=uM});var eq=C((sM)=>{function iM(Z,X,Q){if(X){Q??(Q=X.length);for(let U=Q-1;U>=0;--U){let J=X[U];switch(J.type){case"space":case"comment":case"newline":Z-=J.source.length;continue}J=X[++U];while(J?.type==="space")Z+=J.source.length,J=X[++U];break}}return Z}sM.emptyScalarPosition=iM});var QY=C((QO)=>{var rM=t6(),oM=l(),nM=rq(),ZY=tq(),tM=e2(),eM=eq(),ZO={composeNode:XY,composeEmptyNode:C3};function XY(Z,X,Q,U){let J=Z.atKey,{spaceBefore:q,comment:Y,anchor:W,tag:$}=Q,L,_=!0;switch(X.type){case"alias":if(L=XO(Z,X,U),W||$)U(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(L=ZY.composeScalar(Z,X,$,U),W)L.anchor=W.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(L=nM.composeCollection(ZO,Z,X,Q,U),W)L.anchor=W.source.substring(1);break;default:{let G=X.type==="error"?X.message:`Unsupported token (type: ${X.type})`;U(X,"UNEXPECTED_TOKEN",G),L=C3(Z,X.offset,void 0,null,Q,U),_=!1}}if(W&&L.anchor==="")U(W,"BAD_ALIAS","Anchor cannot be an empty string");if(J&&Z.options.stringKeys&&(!oM.isScalar(L)||typeof L.value!=="string"||L.tag&&L.tag!=="tag:yaml.org,2002:str"))U($??X,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(q)L.spaceBefore=!0;if(Y)if(X.type==="scalar"&&X.source==="")L.comment=Y;else L.commentBefore=Y;if(Z.options.keepSourceTokens&&_)L.srcToken=X;return L}function C3(Z,X,Q,U,{spaceBefore:J,comment:q,anchor:Y,tag:W,end:$},L){let _={type:"scalar",offset:eM.emptyScalarPosition(X,Q,U),indent:-1,source:""},G=ZY.composeScalar(Z,_,W,L);if(Y){if(G.anchor=Y.source.substring(1),G.anchor==="")L(Y,"BAD_ALIAS","Anchor cannot be an empty string")}if(J)G.spaceBefore=!0;if(q)G.comment=q,G.range[2]=$;return G}function XO({options:Z},{offset:X,source:Q,end:U},J){let q=new rM.Alias(Q.substring(1));if(q.source==="")J(X,"BAD_ALIAS","Alias cannot be an empty string");if(q.source.endsWith(":"))J(X+Q.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let Y=X+Q.length,W=tM.resolveEnd(U,Y,Z.strict,J);if(q.range=[X,Y,W.offset],W.comment)q.comment=W.comment;return q}QO.composeEmptyNode=C3;QO.composeNode=XY});var JY=C((LO)=>{var qO=H4(),UY=QY(),YO=e2(),WO=F4();function $O(Z,X,{offset:Q,start:U,value:J,end:q},Y){let W=Object.assign({_directives:X},Z),$=new qO.Document(void 0,W),L={atKey:!1,atRoot:!0,directives:$.directives,options:$.options,schema:$.schema},_=WO.resolveProps(U,{indicator:"doc-start",next:J??q?.[0],offset:Q,onError:Y,parentIndent:0,startOnNewline:!0});if(_.found){if($.directives.docStart=!0,J&&(J.type==="block-map"||J.type==="block-seq")&&!_.hasNewline)Y(_.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}$.contents=J?UY.composeNode(L,J,_,Y):UY.composeEmptyNode(L,_.end,U,null,_,Y);let G=$.contents.range[2],V=YO.resolveEnd(q,G,!1,Y);if(V.comment)$.comment=V.comment;return $.range=[Q,G,V.offset],$}LO.composeDoc=$O});var N3=C((BO)=>{var _O=z2("process"),VO=IX(),HO=H4(),B4=z4(),qY=l(),zO=JY(),FO=e2();function M4(Z){if(typeof Z==="number")return[Z,Z+1];if(Array.isArray(Z))return Z.length===2?Z:[Z[0],Z[1]];let{offset:X,source:Q}=Z;return[X,X+(typeof Q==="string"?Q.length:1)]}function YY(Z){let X="",Q=!1,U=!1;for(let J=0;J<Z.length;++J){let q=Z[J];switch(q[0]){case"#":X+=(X===""?"":U?`
100
145
 
101
146
  `:`
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 PQ{constructor(X={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(U,q,Z,Q)=>{let G=Q6(U);if(Q)this.warnings.push(new Z6.YAMLWarning(G,q,Z));else this.errors.push(new Z6.YAMLParseError(G,q,Z))},this.directives=new JF.Directives({version:X.version||"1.2"}),this.options=X}decorate(X,U){let{comment:q,afterEmptyLine:Z}=wQ(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(MQ.isCollection(Q)&&!Q.flow&&Q.items.length>0){let G=Q.items[0];if(MQ.isPair(G))G=G.key;let Y=G.commentBefore;G.commentBefore=Y?`${q}
104
- ${Y}`:q}else{let G=Q.commentBefore;Q.commentBefore=G?`${q}
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:wQ(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(YF.env.LOG_STREAM)console.dir(X,{depth:null});switch(X.type){case"directive":this.directives.add(X.source,(U,q,Z)=>{let Q=Q6(X);Q[0]+=U,this.onError(Q,"BAD_DIRECTIVE",q,Z)}),this.prelude.push(X.source),this.atDirectives=!0;break;case"document":{let U=WF.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 Z6.YAMLParseError(Q6(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 Z6.YAMLParseError(Q6(X),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let U=_F.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 Z6.YAMLParseError(Q6(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 HF.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}}}$F.Composer=PQ});var NQ=R((RF)=>{var zF=iX(),FF=oX(),VF=U6(),IQ=l2();function AF(X,U=!0,q){if(X){let Z=(Q,G,Y)=>{let J=typeof Q==="number"?Q:Array.isArray(Q)?Q[0]:Q.offset;if(q)q(J,G,Y);else throw new VF.YAMLParseError([J,J+1],G,Y)};switch(X.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return FF.resolveFlowScalar(X,U,Z);case"block-scalar":return zF.resolveBlockScalar({options:{strict:U}},X,Z)}}return null}function OF(X,U){let{implicitKey:q=!1,indent:Z,inFlow:Q=!1,offset:G=-1,type:Y="PLAIN"}=U,J=IQ.stringifyString({type:Y,value:X},{implicitKey:q,indent:Z>0?" ".repeat(Z):"",inFlow:Q,options:{blockQuote:!0,lineWidth:-1}}),H=U.end??[{type:"newline",offset:-1,indent:Z,source:`
107
- `}];switch(J[0]){case"|":case">":{let W=J.indexOf(`
108
- `),$=J.substring(0,W),_=J.substring(W+1)+`
109
- `,L=[{type:"block-scalar-header",offset:G,indent:Z,source:$}];if(!KQ(L,H))L.push({type:"newline",offset:-1,indent:Z,source:`
110
- `});return{type:"block-scalar",offset:G,indent:Z,props:L,source:_}}case'"':return{type:"double-quoted-scalar",offset:G,indent:Z,source:J,end:H};case"'":return{type:"single-quoted-scalar",offset:G,indent:Z,source:J,end:H};default:return{type:"scalar",offset:G,indent:Z,source:J,end:H}}}function TF(X,U,q={}){let{afterKey:Z=!1,implicitKey:Q=!1,inFlow:G=!1,type:Y}=q,J="indent"in X?X.indent:null;if(Z&&typeof J==="number")J+=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 H=IQ.stringifyString({type:Y,value:U},{implicitKey:Q||J===null,indent:J!==null&&J>0?" ".repeat(J):"",inFlow:G,options:{blockQuote:!0,lineWidth:-1}});switch(H[0]){case"|":case">":BF(X,H);break;case'"':nX(X,H,"double-quoted-scalar");break;case"'":nX(X,H,"single-quoted-scalar");break;default:nX(X,H,"scalar")}}function BF(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,J=[{type:"block-scalar-header",offset:G,indent:Y,source:Z}];if(!KQ(J,"end"in X?X.end:void 0))J.push({type:"newline",offset:-1,indent:Y,source:`
113
- `});for(let H of Object.keys(X))if(H!=="type"&&H!=="offset")delete X[H];Object.assign(X,{type:"block-scalar",indent:Y,props:J,source:Q})}}function KQ(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 nX(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})}}}RF.createScalarToken=OF;RF.resolveAsScalar=AF;RF.setScalarValue=TF});var CQ=R((IF)=>{var PF=(X)=>("type"in X)?I4(X):P4(X);function I4(X){switch(X.type){case"block-scalar":{let U="";for(let q of X.props)U+=I4(q);return U+X.source}case"block-map":case"block-seq":{let U="";for(let q of X.items)U+=P4(q);return U}case"flow-collection":{let U=X.start.source;for(let q of X.items)U+=P4(q);for(let q of X.end)U+=q.source;return U}case"document":{let U=P4(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 P4({start:X,key:U,sep:q,value:Z}){let Q="";for(let G of X)Q+=G.source;if(U)Q+=I4(U);if(q)for(let G of q)Q+=G.source;if(Z)Q+=I4(Z);return Q}IF.stringify=PF});var jQ=R((CF)=>{var tX=Symbol("break visit"),NF=Symbol("skip children"),SQ=Symbol("remove item");function R1(X,U){if("type"in X&&X.type==="document")X={start:X.start,value:X.value};EQ(Object.freeze([]),X,U)}R1.BREAK=tX;R1.SKIP=NF;R1.REMOVE=SQ;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 EQ(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 J=EQ(Object.freeze(X.concat([[Q,Y]])),G.items[Y],q);if(typeof J==="number")Y=J-1;else if(J===tX)return tX;else if(J===SQ)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}CF.visit=R1});var K4=R((kF)=>{var eX=NQ(),EF=CQ(),jF=jQ(),XU="\uFEFF",UU="\x02",qU="\x18",ZU="\x1F",bF=(X)=>!!X&&("items"in X),fF=(X)=>!!X&&(X.type==="scalar"||X.type==="single-quoted-scalar"||X.type==="double-quoted-scalar"||X.type==="block-scalar");function gF(X){switch(X){case XU:return"<BOM>";case UU:return"<DOC>";case qU:return"<FLOW_END>";case ZU:return"<SCALAR>";default:return JSON.stringify(X)}}function yF(X){switch(X){case XU:return"byte-order-mark";case UU:return"doc-mode";case qU:return"flow-error-end";case ZU:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
147
+ `)+(q.substring(1)||" "),Q=!0,U=!1;break;case"%":if(Z[J+1]?.[0]!=="#")J+=1;Q=!1;break;default:if(!Q)U=!0;Q=!1}}return{comment:X,afterEmptyLine:U}}class WY{constructor(Z={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(X,Q,U,J)=>{let q=M4(X);if(J)this.warnings.push(new B4.YAMLWarning(q,Q,U));else this.errors.push(new B4.YAMLParseError(q,Q,U))},this.directives=new VO.Directives({version:Z.version||"1.2"}),this.options=Z}decorate(Z,X){let{comment:Q,afterEmptyLine:U}=YY(this.prelude);if(Q){let J=Z.contents;if(X)Z.comment=Z.comment?`${Z.comment}
148
+ ${Q}`:Q;else if(U||Z.directives.docStart||!J)Z.commentBefore=Q;else if(qY.isCollection(J)&&!J.flow&&J.items.length>0){let q=J.items[0];if(qY.isPair(q))q=q.key;let Y=q.commentBefore;q.commentBefore=Y?`${Q}
149
+ ${Y}`:Q}else{let q=J.commentBefore;J.commentBefore=q?`${Q}
150
+ ${q}`:Q}}if(X)Array.prototype.push.apply(Z.errors,this.errors),Array.prototype.push.apply(Z.warnings,this.warnings);else Z.errors=this.errors,Z.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:YY(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(Z,X=!1,Q=-1){for(let U of Z)yield*this.next(U);yield*this.end(X,Q)}*next(Z){if(_O.env.LOG_STREAM)console.dir(Z,{depth:null});switch(Z.type){case"directive":this.directives.add(Z.source,(X,Q,U)=>{let J=M4(Z);J[0]+=X,this.onError(J,"BAD_DIRECTIVE",Q,U)}),this.prelude.push(Z.source),this.atDirectives=!0;break;case"document":{let X=zO.composeDoc(this.options,this.directives,Z,this.onError);if(this.atDirectives&&!X.directives.docStart)this.onError(Z,"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(Z.source);break;case"error":{let X=Z.source?`${Z.message}: ${JSON.stringify(Z.source)}`:Z.message,Q=new B4.YAMLParseError(M4(Z),"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 B4.YAMLParseError(M4(Z),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let X=FO.resolveEnd(Z.end,Z.offset+Z.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}
151
+ ${X.comment}`:X.comment}this.doc.range[2]=X.offset;break}default:this.errors.push(new B4.YAMLParseError(M4(Z),"UNEXPECTED_TOKEN",`Unsupported token ${Z.type}`))}}*end(Z=!1,X=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(Z){let Q=Object.assign({_directives:this.directives},this.options),U=new HO.Document(void 0,Q);if(this.atDirectives)this.onError(X,"MISSING_CHAR","Missing directives-end indicator line");U.range=[0,X,X],this.decorate(U,!1),yield U}}}BO.Composer=WY});var GY=C((AO)=>{var OO=P3(),RO=S3(),KO=z4(),$Y=Q4();function TO(Z,X=!0,Q){if(Z){let U=(J,q,Y)=>{let W=typeof J==="number"?J:Array.isArray(J)?J[0]:J.offset;if(Q)Q(W,q,Y);else throw new KO.YAMLParseError([W,W+1],q,Y)};switch(Z.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return RO.resolveFlowScalar(Z,X,U);case"block-scalar":return OO.resolveBlockScalar({options:{strict:X}},Z,U)}}return null}function DO(Z,X){let{implicitKey:Q=!1,indent:U,inFlow:J=!1,offset:q=-1,type:Y="PLAIN"}=X,W=$Y.stringifyString({type:Y,value:Z},{implicitKey:Q,indent:U>0?" ".repeat(U):"",inFlow:J,options:{blockQuote:!0,lineWidth:-1}}),$=X.end??[{type:"newline",offset:-1,indent:U,source:`
152
+ `}];switch(W[0]){case"|":case">":{let L=W.indexOf(`
153
+ `),_=W.substring(0,L),G=W.substring(L+1)+`
154
+ `,V=[{type:"block-scalar-header",offset:q,indent:U,source:_}];if(!LY(V,$))V.push({type:"newline",offset:-1,indent:U,source:`
155
+ `});return{type:"block-scalar",offset:q,indent:U,props:V,source:G}}case'"':return{type:"double-quoted-scalar",offset:q,indent:U,source:W,end:$};case"'":return{type:"single-quoted-scalar",offset:q,indent:U,source:W,end:$};default:return{type:"scalar",offset:q,indent:U,source:W,end:$}}}function wO(Z,X,Q={}){let{afterKey:U=!1,implicitKey:J=!1,inFlow:q=!1,type:Y}=Q,W="indent"in Z?Z.indent:null;if(U&&typeof W==="number")W+=2;if(!Y)switch(Z.type){case"single-quoted-scalar":Y="QUOTE_SINGLE";break;case"double-quoted-scalar":Y="QUOTE_DOUBLE";break;case"block-scalar":{let L=Z.props[0];if(L.type!=="block-scalar-header")throw Error("Invalid block scalar header");Y=L.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:Y="PLAIN"}let $=$Y.stringifyString({type:Y,value:X},{implicitKey:J||W===null,indent:W!==null&&W>0?" ".repeat(W):"",inFlow:q,options:{blockQuote:!0,lineWidth:-1}});switch($[0]){case"|":case">":PO(Z,$);break;case'"':j3(Z,$,"double-quoted-scalar");break;case"'":j3(Z,$,"single-quoted-scalar");break;default:j3(Z,$,"scalar")}}function PO(Z,X){let Q=X.indexOf(`
156
+ `),U=X.substring(0,Q),J=X.substring(Q+1)+`
157
+ `;if(Z.type==="block-scalar"){let q=Z.props[0];if(q.type!=="block-scalar-header")throw Error("Invalid block scalar header");q.source=U,Z.source=J}else{let{offset:q}=Z,Y="indent"in Z?Z.indent:-1,W=[{type:"block-scalar-header",offset:q,indent:Y,source:U}];if(!LY(W,"end"in Z?Z.end:void 0))W.push({type:"newline",offset:-1,indent:Y,source:`
158
+ `});for(let $ of Object.keys(Z))if($!=="type"&&$!=="offset")delete Z[$];Object.assign(Z,{type:"block-scalar",indent:Y,props:W,source:J})}}function LY(Z,X){if(X)for(let Q of X)switch(Q.type){case"space":case"comment":Z.push(Q);break;case"newline":return Z.push(Q),!0}return!1}function j3(Z,X,Q){switch(Z.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":Z.type=Q,Z.source=X;break;case"block-scalar":{let U=Z.props.slice(1),J=X.length;if(Z.props[0].type==="block-scalar-header")J-=Z.props[0].source.length;for(let q of U)q.offset+=J;delete Z.props,Object.assign(Z,{type:Q,source:X,end:U});break}case"block-map":case"block-seq":{let J={type:"newline",offset:Z.offset+X.length,indent:Z.indent,source:`
159
+ `};delete Z.items,Object.assign(Z,{type:Q,source:X,end:[J]});break}default:{let U="indent"in Z?Z.indent:-1,J="end"in Z&&Array.isArray(Z.end)?Z.end.filter((q)=>q.type==="space"||q.type==="comment"||q.type==="newline"):[];for(let q of Object.keys(Z))if(q!=="type"&&q!=="offset")delete Z[q];Object.assign(Z,{type:Q,indent:U,source:X,end:J})}}}AO.createScalarToken=DO;AO.resolveAsScalar=TO;AO.setScalarValue=wO});var _Y=C((EO)=>{var jO=(Z)=>("type"in Z)?JZ(Z):UZ(Z);function JZ(Z){switch(Z.type){case"block-scalar":{let X="";for(let Q of Z.props)X+=JZ(Q);return X+Z.source}case"block-map":case"block-seq":{let X="";for(let Q of Z.items)X+=UZ(Q);return X}case"flow-collection":{let X=Z.start.source;for(let Q of Z.items)X+=UZ(Q);for(let Q of Z.end)X+=Q.source;return X}case"document":{let X=UZ(Z);if(Z.end)for(let Q of Z.end)X+=Q.source;return X}default:{let X=Z.source;if("end"in Z&&Z.end)for(let Q of Z.end)X+=Q.source;return X}}}function UZ({start:Z,key:X,sep:Q,value:U}){let J="";for(let q of Z)J+=q.source;if(X)J+=JZ(X);if(Q)for(let q of Q)J+=q.source;if(U)J+=JZ(U);return J}EO.stringify=jO});var zY=C((fO)=>{var E3=Symbol("break visit"),IO=Symbol("skip children"),VY=Symbol("remove item");function V2(Z,X){if("type"in Z&&Z.type==="document")Z={start:Z.start,value:Z.value};HY(Object.freeze([]),Z,X)}V2.BREAK=E3;V2.SKIP=IO;V2.REMOVE=VY;V2.itemAtPath=(Z,X)=>{let Q=Z;for(let[U,J]of X){let q=Q?.[U];if(q&&"items"in q)Q=q.items[J];else return}return Q};V2.parentCollection=(Z,X)=>{let Q=V2.itemAtPath(Z,X.slice(0,-1)),U=X[X.length-1][0],J=Q?.[U];if(J&&"items"in J)return J;throw Error("Parent collection not found")};function HY(Z,X,Q){let U=Q(X,Z);if(typeof U==="symbol")return U;for(let J of["key","value"]){let q=X[J];if(q&&"items"in q){for(let Y=0;Y<q.items.length;++Y){let W=HY(Object.freeze(Z.concat([[J,Y]])),q.items[Y],Q);if(typeof W==="number")Y=W-1;else if(W===E3)return E3;else if(W===VY)q.items.splice(Y,1),Y-=1}if(typeof U==="function"&&J==="key")U=U(X,Z)}}return typeof U==="function"?U(X,Z):U}fO.visit=V2});var qZ=C((uO)=>{var b3=GY(),yO=_Y(),gO=zY(),I3="\uFEFF",f3="\x02",k3="\x18",y3="\x1F",vO=(Z)=>!!Z&&("items"in Z),xO=(Z)=>!!Z&&(Z.type==="scalar"||Z.type==="single-quoted-scalar"||Z.type==="double-quoted-scalar"||Z.type==="block-scalar");function hO(Z){switch(Z){case I3:return"<BOM>";case f3:return"<DOC>";case k3:return"<FLOW_END>";case y3:return"<SCALAR>";default:return JSON.stringify(Z)}}function mO(Z){switch(Z){case I3:return"byte-order-mark";case f3:return"doc-mode";case k3:return"flow-error-end";case y3:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
160
  `: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(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}kF.createScalarToken=eX.createScalarToken;kF.resolveAsScalar=eX.resolveAsScalar;kF.setScalarValue=eX.setScalarValue;kF.stringify=EF.stringify;kF.visit=jF.visit;kF.BOM=XU;kF.DOCUMENT=UU;kF.FLOW_END=qU;kF.SCALAR=ZU;kF.isCollection=bF;kF.isScalar=fF;kF.prettyToken=gF;kF.tokenType=yF});var GU=R((tF)=>{var G6=K4();function K0(X){switch(X){case void 0:case" ":case`
117
- `:case"\r":case"\t":return!0;default:return!1}}var bQ=new Set("0123456789ABCDEFabcdef"),aF=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),N4=new Set(",[]{}"),nF=new Set(` ,[]{}
118
- \r `),QU=(X)=>!X||nF.has(X);class fQ{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(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]===G6.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 G6.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(QU),"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 G6.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(QU),"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
- `,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)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 G6.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&&N4.has(Q))break;U=q}else if(K0(Z)){let Q=this.buffer[q+1];if(Z==="\r")if(Q===`
131
- `)q+=1,Z=`
132
- `,Q=this.buffer[q+1];else U=q;if(Q==="#"||X&&N4.has(Q))break;if(Z===`
133
- `){let G=this.continueScalar(q+1);if(G===-1)break;q=Math.max(q,G-2)}}else{if(X&&N4.has(Z))break;U=q}if(!Z&&!this.atEnd)return this.setNext("plain-scalar");return yield G6.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(QU))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let X=this.flowLevel>0,U=this.charAt(1);if(K0(U)||X&&N4.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(aF.has(U))U=this.buffer[++X];else if(U==="%"&&bQ.has(this.buffer[X+1])&&bQ.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)}}tF.Lexer=fQ});var YU=R((XV)=>{class gQ{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}}}}XV.LineCounter=gQ});var JU=R((QV)=>{var qV=w1("process"),yQ=K4(),ZV=GU();function Q1(X,U){for(let q=0;q<X.length;++q)if(X[q].type===U)return!0;return!1}function kQ(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 hQ(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 C4(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 U2(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 vQ(X){if(X.start.type==="flow-seq-start"){for(let U of X.items)if(U.sep&&!U.value&&!Q1(U.start,"explicit-key-ind")&&!Q1(U.sep,"map-value-ind")){if(U.key)U.value=U.key;if(delete U.key,hQ(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 xQ{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 ZV.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,qV.env.LOG_TOKENS)console.log("|",yQ.prettyToken(X));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=X.length;return}let U=yQ.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")vQ(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&&kQ(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(kQ(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=C4(this.peek(2)),q=U2(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 J=U.sep[Y];switch(J.type){case"newline":G.push(Y);break;case"space":break;case"comment":if(J.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(Q1(U.start,"newline"))Object.assign(U,{key:null,sep:[this.sourceToken]});else{let G=U2(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(Q1(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(hQ(U.key)&&!Q1(U.sep,"newline")){let G=U2(U.start),Y=U.key,J=U.sep;J.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:J}]})}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(Q1(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&&!Q1(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||Q1(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=C4(q),Q=U2(Z);vQ(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=C4(X),q=U2(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=C4(X),q=U2(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()}}}QV.Parser=xQ});var dQ=R((zV)=>{var uQ=aX(),YV=X6(),Y6=U6(),JV=YX(),HV=k(),WV=YU(),mQ=JU();function pQ(X){let U=X.prettyErrors!==!1;return{lineCounter:X.lineCounter||U&&new WV.LineCounter||null,prettyErrors:U}}function _V(X,U={}){let{lineCounter:q,prettyErrors:Z}=pQ(U),Q=new mQ.Parser(q?.addNewLine),G=new uQ.Composer(U),Y=Array.from(G.compose(Q.parse(X)));if(Z&&q)for(let J of Y)J.errors.forEach(Y6.prettifyError(X,q)),J.warnings.forEach(Y6.prettifyError(X,q));if(Y.length>0)return Y;return Object.assign([],{empty:!0},G.streamInfo())}function lQ(X,U={}){let{lineCounter:q,prettyErrors:Z}=pQ(U),Q=new mQ.Parser(q?.addNewLine),G=new uQ.Composer(U),Y=null;for(let J of G.compose(Q.parse(X),!0,X.length))if(!Y)Y=J;else if(Y.options.logLevel!=="silent"){Y.errors.push(new Y6.YAMLParseError(J.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(Z&&q)Y.errors.forEach(Y6.prettifyError(X,q)),Y.warnings.forEach(Y6.prettifyError(X,q));return Y}function $V(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=lQ(X,q);if(!Q)return null;if(Q.warnings.forEach((G)=>JV.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 LV(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(HV.isDocument(X)&&!Z)return X.toString(q);return new YV.Document(X,Z,q).toString(q)}zV.parse=$V;zV.parseAllDocuments=_V;zV.parseDocument=lQ;zV.stringify=LV});var WU=R((EV)=>{var TV=aX(),BV=X6(),RV=gX(),HU=U6(),DV=x2(),G1=k(),MV=X1(),wV=i(),PV=q1(),IV=Z1(),KV=K4(),NV=GU(),CV=YU(),SV=JU(),S4=dQ(),cQ=v2();EV.Composer=TV.Composer;EV.Document=BV.Document;EV.Schema=RV.Schema;EV.YAMLError=HU.YAMLError;EV.YAMLParseError=HU.YAMLParseError;EV.YAMLWarning=HU.YAMLWarning;EV.Alias=DV.Alias;EV.isAlias=G1.isAlias;EV.isCollection=G1.isCollection;EV.isDocument=G1.isDocument;EV.isMap=G1.isMap;EV.isNode=G1.isNode;EV.isPair=G1.isPair;EV.isScalar=G1.isScalar;EV.isSeq=G1.isSeq;EV.Pair=MV.Pair;EV.Scalar=wV.Scalar;EV.YAMLMap=PV.YAMLMap;EV.YAMLSeq=IV.YAMLSeq;EV.CST=KV;EV.Lexer=NV.Lexer;EV.LineCounter=CV.LineCounter;EV.Parser=SV.Parser;EV.parse=S4.parse;EV.parseAllDocuments=S4.parseAllDocuments;EV.parseDocument=S4.parseDocument;EV.stringify=S4.stringify;EV.visit=cQ.visit;EV.visitAsync=cQ.visitAsync});class ZG{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 QG{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;if(typeof Z==="object"&&Z!==null&&Q in Z)Z=Z[Q];else return}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){let Z=(G)=>{if(G instanceof Date)return G.getTime();if(typeof G==="number")return G;if(typeof G==="string"){let Y=new Date(G);return isNaN(Y.getTime())?0:Y.getTime()}return 0},Q=(G)=>{if(typeof G==="number")return G;if(G===null||G===void 0||G==="")return null;let Y=Number(G);return isNaN(Y)?null:Y};switch(U){case"EQ":case"==":return X==q;case"NEQ":case"!=":return X!=q;case"GT":case">":{let G=Q(X),Y=Q(q);return G!==null&&Y!==null&&G>Y}case"GTE":case">=":{let G=Q(X),Y=Q(q);return G!==null&&Y!==null&&G>=Y}case"LT":case"<":{let G=Q(X),Y=Q(q);return G!==null&&Y!==null&&G<Y}case"LTE":case"<=":{let G=Q(X),Y=Q(q);return G!==null&&Y!==null&&G<=Y}case"IN":return Array.isArray(q)&&q.some((G)=>G===X);case"NOT_IN":return Array.isArray(q)&&!q.some((G)=>G===X);case"CONTAINS":if(Array.isArray(q))return q.some((G)=>String(X).includes(String(G)));if(Array.isArray(X)||typeof X==="string")return X.includes(q);return!1;case"NOT_CONTAINS":if(Array.isArray(q))return!q.some((G)=>String(X).includes(String(G)));if(Array.isArray(X)||typeof X==="string")return!X.includes(q);return!1;case"STARTS_WITH":if(Array.isArray(q))return q.some((G)=>String(X).startsWith(String(G)));if(typeof X==="string"&&typeof q==="string")return X.startsWith(q);return!1;case"ENDS_WITH":if(Array.isArray(q))return q.some((G)=>String(X).endsWith(String(G)));if(typeof X==="string"&&typeof q==="string")return X.endsWith(q);return!1;case"IS_EMPTY":{let G=!1;if(typeof X==="string")G=X==="";else if(Array.isArray(X))G=X.length===0;else if(X===null||X===void 0)G=!0;else if(typeof X==="object")G=Object.keys(X).length===0;return q===!1?!G:G}case"IS_NULL":case"IS_NONE":{let G=X===null||X===void 0;return q===!1?!G:G}case"HAS_KEY":if(typeof X==="object"&&X!==null&&typeof q==="string")return q in X;return!1;case"MATCHES":if(typeof q==="string")return new RegExp(q).test(String(X));return!1;case"RANGE":if(Array.isArray(q)&&q.length===2){let G=Q(X),Y=Q(q[0]),J=Q(q[1]);return G!==null&&Y!==null&&J!==null&&G>=Y&&G<=J}return!1;case"SINCE":case"AFTER":return Z(X)>=Z(q);case"BEFORE":case"UNTIL":return Z(X)<Z(q);default:return console.warn(`Unknown operator: ${U}`),!1}}}var J6;((G)=>{G.ENGINE_START="engine:start";G.ENGINE_DONE="engine:done";G.RULE_MATCH="rule:match";G.ACTION_SUCCESS="action:success";G.ACTION_ERROR="action:error"})(J6||={});var BU;((Z)=>{Z.RULE_ADDED="rule:added";Z.RULE_REMOVED="rule:removed";Z.RULE_UPDATED="rule:updated"})(BU||={});var BA=J6,H6=BU;class f4{static instance;handlers=new Map;constructor(){}static getInstance(){if(!this.instance)this.instance=new f4;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 N0=f4.getInstance();class Y2{_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=[];if(!X.state)X.state={};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))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,vars:q,timestamp:Date.now(),state:this.getStateContext?this.getStateContext():{}};return this.processEvent(Z)}updateRules(X){let U=this.getRules(),q=new Set(U.map((Y)=>Y.id)),Z=new Set(X.map((Y)=>Y.id)),Q=X.filter((Y)=>!q.has(Y.id)),G=U.filter((Y)=>!Z.has(Y.id));this.rules=[...X],this.sortRules(),Q.forEach((Y)=>{this.emitRuleEvent(H6.RULE_ADDED,{ruleId:Y.id,timestamp:Date.now()})}),G.forEach((Y)=>{this.emitRuleEvent(H6.RULE_REMOVED,{ruleId:Y.id,timestamp:Date.now()})}),this.emitRuleEvent(H6.RULE_UPDATED,{count:X.length,added:Q.length,removed:G.length,unchanged:X.length-Q.length,timestamp:Date.now()})}emitRuleEvent(X,U){try{if(N0)N0.emit(X,{...U,timestamp:Date.now()})}catch(q){console.warn(`Could not emit event ${X}:`,q)}}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=e.evaluate(q.field,U),Q=q.value;if(typeof Q==="string"&&Q.includes("${"))Q=e.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(X&&typeof X==="object"&&"mode"in X&&"actions"in X){let Y=X;Q=Y.mode,Z=Y.actions}else Z=[X];if(Q==="EITHER"&&Z.length>0){let Y=Z.reduce((W,$)=>W+($.probability||1),0),J=Math.random()*Y,H;for(let W of Z){let $=W.probability||1;if(J-=$,J<=0){H=W;break}}if(!H&&Z.length>0)H=Z[Z.length-1];if(H)Z=[H];else Z=[]}let G=!1;for(let Y of Z){if(G)break;if("if"in Y&&Y.if&&(Y.then||Y.else)){let H=this.evaluateConditions(Y.if,U);if(H&&Y.then){let W=await this.executeRuleActions(Y.then,U);q.push(...W)}else if(!H&&Y.else){let W=await this.executeRuleActions(Y.else,U);q.push(...W)}continue}if("if"in Y&&Y.if){if(!this.evaluateConditions(Y.if,U))continue}if(Y.break){G=!0,q.push({type:"BREAK",result:"Breaking action execution",timestamp:Date.now()});break}if(Y.continue){q.push({type:"CONTINUE",result:"Skipping remaining actions",timestamp:Date.now()});continue}let J=await this.executeSingleAction(Y,U);q.push(J)}return q}async executeSingleAction(X,U){if(!X.type&&!X.run&&!X.break&&!X.continue){let G=["params","run","delay","probability","if","then","else","break","continue","mode","actions"],Y=Object.keys(X).filter((J)=>!G.includes(J));for(let J of Y){if(X.type=J,typeof X[J]==="string")X.params={...X.params,message:X[J],content:X[J]};else if(typeof X[J]==="object"&&X[J]!==null)X.params={...X.params,...X[J]};break}}if(X.run)try{return{type:"RUN",result:Function("context","state","data","vars","env","helpers",`with(context) { ${X.run} }`)(U,U.state,U.data,U.vars,U.env,U.helpers),timestamp:Date.now()}}catch(G){return{type:"RUN",error:String(G),timestamp:Date.now()}}let q=X.probability;if(typeof q==="string"){let G=e.evaluate(q,U);q=typeof G==="number"?G:Number(G)}if(q!==void 0&&Math.random()>q)return{type:X.type||"skipped",timestamp:Date.now(),result:{skipped:"probability check failed"}};let Z=X.delay;if(typeof Z==="string"){let G=e.evaluate(Z,U);Z=typeof G==="number"?G:Number(G)}if(Z&&Z>0)await new Promise((G)=>setTimeout(G,Z));let Q=this.interpolateParams(X.params||{},U);try{let G;try{let{ActionRegistry:J}=await Promise.resolve().then(() => (G2(),RU)),H=J.getInstance().get(X.type);if(H)G=(W)=>H({...X,params:W},U)}catch{G=this.actionHandlers.get(X.type)}let Y;if(G)Y=await G(Q,U);else{let J=`No handler registered for action type: ${X.type}`;console.warn(J),Y={warning:J}}return{type:X.type,result:Y,timestamp:Date.now()}}catch(G){return console.error(`Error executing action ${X.type}:`,G),{type:X.type,error:String(G),timestamp:Date.now()}}}interpolateParams(X,U){let q={};for(let[Z,Q]of Object.entries(X))if(typeof Q==="string")q[Z]=e.interpolate(Q,U);else if(typeof Q==="object"&&Q!==null&&!Array.isArray(Q))q[Z]=this.interpolateDeep(Q,U);else q[Z]=Q;return q}interpolateDeep(X,U){if(typeof X==="string")return e.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()}}G2();P1();class g4 extends Y2{actionRegistry;stateManager;constructor(X){super(X);this.actionRegistry=I1.getInstance(),this.stateManager=X0.getInstance()}async processEvent(X){let U=[];if(X.state=this.stateManager.getLiveProxy(),this.config?.stateConfig)await this.stateManager.applyConfig(this.config.stateConfig);if(N0.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}`);N0.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 N0.emit("engine:done",{results:U,context:X}),U}async processEventSimple(X,U={},q={}){let Z={event:X,data:U,vars:q,timestamp:Date.now(),state:this.stateManager.getLiveProxy()};return this.processEvent(Z)}async executeRuleActionsWithRegistry(X,U){let q=[],Z=[],Q="ALL";if(Array.isArray(X))Z=X;else if(this.isActionGroup(X)){let Y=X;Q=Y.mode,Z=Y.actions}else Z=[X];if(Q==="EITHER"&&Z.length>0){let Y=Z.reduce((W,$)=>W+($.probability||1),0),J=Math.random()*Y,H;for(let W of Z){let $=W.probability||1;if(J-=$,J<=0){H=W;break}}if(H)Z=[H]}let G=!1;for(let Y of Z){if(G)break;if("if"in Y&&Y.if&&(Y.then||Y.else)){let H=this.evaluateConditions(Y.if,U);if(H&&Y.then){let W=await this.executeRuleActionsWithRegistry(Y.then,U);q.push(...W)}else if(!H&&Y.else){let W=await this.executeRuleActionsWithRegistry(Y.else,U);q.push(...W)}continue}if("if"in Y&&Y.if){if(!this.evaluateConditions(Y.if,U))continue}if(Y.break){G=!0,q.push({type:"BREAK",result:"Breaking action execution",timestamp:Date.now()});break}if(Y.continue){q.push({type:"CONTINUE",result:"Skipping remaining actions",timestamp:Date.now()});continue}let J=await this.executeSingleActionWithRegistry(Y,U);q.push(J)}return q}isActionGroup(X){return typeof X==="object"&&X!==null&&"mode"in X&&"actions"in X}async executeSingleActionWithRegistry(X,U){if(!X.type&&!X.run&&!X.break&&!X.continue){let G=Object.keys(X);for(let Y of G)if(this.actionRegistry.get(Y)){if(X.type=Y,typeof X[Y]==="string")X.params={...X.params,message:X[Y],content:X[Y]};else if(typeof X[Y]==="object"&&X[Y]!==null)X.params={...X.params,...X[Y]};break}}if(X.run)try{return{type:"RUN",result:Function("context","state","data","vars","env","helpers",`with(context) { ${X.run} }`)(U,U.state,U.data,U.vars,U.env,U.helpers),timestamp:Date.now()}}catch(G){return{type:"RUN",error:String(G),timestamp:Date.now()}}let q=X.probability;if(typeof q==="string"){let{ExpressionEngine:G}=AU(j4),Y=G.evaluate(q,U);q=typeof Y==="number"?Y:Number(Y)}if(q!==void 0&&Math.random()>q)return{type:X.type||"unknown",timestamp:Date.now(),result:{skipped:"probability check failed"}};if(X.break)return{type:"BREAK",result:"Break action",timestamp:Date.now()};if(X.continue)return{type:"CONTINUE",result:"Continue action",timestamp:Date.now()};let Z=X.delay;if(typeof Z==="string"){let{ExpressionEngine:G}=AU(j4),Y=G.evaluate(Z,U);Z=typeof Y==="number"?Y:Number(Y)}if(Z&&Z>0)await new Promise((G)=>setTimeout(G,Z));let Q=this.interpolateParams(X.params||{},U);try{let G=this.actionRegistry.get(X.type),Y;if(G)Y=await G({...X,params:Q},U);else{let J=`Generic or unknown action type: ${X.type}`;if(this.config?.globalSettings?.strictActions)throw Error(J);console.warn(J),Y={warning:`Generic action executed: ${X.type}`}}return N0.emit("action:success",{action:{...X,params:Q},context:U,result:Y}),{type:X.type,result:Y,timestamp:Date.now()}}catch(G){return console.error("Error executing action:",X,G),N0.emit("action:error",{action:X,context:U,error:String(G)}),{type:X.type,error:String(G),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)}}G2();P1();class GG{static create(X,U,q={}){return{event:X,timestamp:Date.now(),data:typeof U==="object"&&U!==null?U:{value:U},vars:q,state:X0.getInstance().getLiveProxy(),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||{}},vars:{...q,ip:X.headers.get("x-forwarded-for")||"unknown"},state:X0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static fromWebhook(X,U,q,Z={}){return{event:`WEBHOOK_${X.toUpperCase()}_${U.toUpperCase()}`,timestamp:Date.now(),data:q,vars:{...Z,provider:X},state:X0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static getDefaultHelpers(){return{now:()=>Date.now(),uuid:()=>crypto.randomUUID(),jsonParse:(X)=>{try{return typeof X==="string"?JSON.parse(X):null}catch{return null}},jsonStringify:(X)=>{try{return JSON.stringify(X)}catch{return null}}}}}P1();G2();P1();var l0=(X)=>Array.isArray(X)?X:[X],DU=(X,U)=>{let q=[[],[]];for(let Z of X)if(U(Z))q[0].push(Z);else q[1].push(Z);return q},W6=Array,F0=(X,U)=>X.includes(U),MU=(X,U=0)=>[...Array(X)].map((q,Z)=>Z+U),g=(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},g0=(X,U)=>{if(U===void 0||U===null)return X??[];if(X===void 0||X===null)return l0(U);return X.concat(U)},wU=(...X)=>X.reduce(g0,[]),C0=(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 l0(U))if(!X.some((G)=>Z(G,Q)))X.push(Q);return X},PU=(X,U)=>X.reduce((q,Z)=>{let Q=Z[U];return q[Q]=g(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 G0=(X,U)=>r(X)===U,r=(X)=>{let U=typeof X;return U==="object"?X===null?"null":"object":U==="function"?"object":U},Y0={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},IU={...Y0,function:"a function"};class KU extends Error{}var y=(X)=>Y1(X,KU),Y1=(X,U=Error)=>{throw new U(X)};class J2 extends Error{name="ParseError"}var F=(X)=>Y1(X,J2),D0=(X)=>` ${X}`,NU="​";var S=(X,U)=>{let q={},Z=Array.isArray(X),Q=!1;for(let[G,Y]of Object.entries(X).entries()){let J=Z?U(G,Y[1]):U(...Y,G);Q||=typeof J[0]==="number";let H=Array.isArray(J[0])||J.length===0?J:[J];for(let[W,$]of H)if(typeof W==="object")q[W.group]=g(q[W.group],$);else q[W]=$}return Q?Object.values(q):q};var y4=Object.entries;var a=(X,U)=>(X in U),K1=(X,U)=>(U in X);class k4{constructor(X){Object.assign(this,X)}}var CU=class{};class H2 extends CU{}var YG=(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 _6=(X,U)=>YG(X,U)[1],S0=(X)=>Object.keys(X).length===0,J1=(X)=>[...Object.entries(X),...Object.getOwnPropertySymbols(X).map((U)=>[U,X[U]])],SU=(X,U)=>Object.defineProperties(X,Object.getOwnPropertyDescriptors(U)),EU=(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 J0=D0(`unset${NU}`),jU=(X)=>Object.values(X).filter((U)=>{if(typeof U==="number")return!0;return typeof X[U]!=="number"});var v4={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},h4=globalThis.File??Blob,x4={ArrayBuffer,Blob,File:h4,FormData,Headers,Request,Response,URL},JG={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},H1={...v4,...x4,...JG,String,Number,Boolean},W2=(X)=>{let U=Object.getPrototypeOf(X);while(U?.constructor&&(!a(U.constructor.name,H1)||!(X instanceof H1[U.constructor.name])))U=Object.getPrototypeOf(U);let q=U?.constructor?.name;if(q===void 0||q==="Object")return;return q},_2=(X)=>typeof X==="object"&&X!==null?W2(X)??"object":r(X);var h=Array.isArray,HG={Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},WG={ArrayBuffer:"an ArrayBuffer instance",Blob:"a Blob instance",File:"a File instance",FormData:"a FormData instance",Headers:"a Headers instance",Request:"a Request instance",Response:"a Response instance",URL:"a URL instance"},_G={Int8Array:"an Int8Array",Uint8Array:"a Uint8Array",Uint8ClampedArray:"a Uint8ClampedArray",Int16Array:"an Int16Array",Uint16Array:"a Uint16Array",Int32Array:"an Int32Array",Uint32Array:"a Uint32Array",Float32Array:"a Float32Array",Float64Array:"a Float64Array",BigInt64Array:"a BigInt64Array",BigUint64Array:"a BigUint64Array"},bU={...HG,...WG,..._G},$2=(X)=>{let U=Object(X).name??null;return U&&a(U,H1)&&H1[U]===X?U:null};var u4=(X,U)=>{let q=X.prototype;while(q!==null){if(q===U.prototype)return!0;q=Object.getPrototypeOf(q)}return!1};var fU=(X)=>gU(X,new Map),gU=(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=gU(Y.value,U)}}return Object.defineProperties(Z,Q),Z};var $G=(X)=>{let U=J0;return()=>U===J0?U=X():U},d0=(X)=>typeof X==="function"&&X.length===0;var yU=class extends Function{constructor(...X){let U=X.slice(0,-1),q=X[X.length-1];try{super(...U,q)}catch(Z){return y(`Encountered an unexpected error while compiling your definition:
140
- Message: ${Z}
141
- Source: (${X.slice(0,-1)}) => {
142
- ${X[X.length-1]}
143
- }`)}}};class H0{constructor(X,...[U]){return Object.assign(Object.setPrototypeOf(X.bind(U?.bind??this),this.constructor.prototype),U?.attach)}}var kU=$G(()=>{try{return Function("return false")()}catch{return!0}});var IO=D0("brand");var vU=D0("arkInferred");var CO=D0("args");class U0{constructor(){}}var LG=()=>{try{return((Error().stack?.split(`
144
- `)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},zG=globalThis.process?.env??{},hU={fileName:LG,env:zG};var xU=(X)=>X[0].toUpperCase()+X.slice(1),uU=(X)=>X[0].toLowerCase()+X.slice(1),m4=(X)=>new RegExp(FG(X),typeof X==="string"?"":X.flags);var FG=(X)=>{return`^(?:${typeof X==="string"?X:X.source})$`};var k0={negativeLookahead:(X)=>`(?!${X})`,nonCapturingGroup:(X)=>`(?:${X})`},W1="\\",c0={" ":1,"\n":1,"\t":1};var VG=/^-0\.?0*$/.source,pU=/[1-9]\d*/.source,AG=/\.\d+/.source,OG=/\.\d*[1-9]/.source,lU=(X)=>m4(k0.negativeLookahead(VG)+k0.nonCapturingGroup("-?"+k0.nonCapturingGroup(k0.nonCapturingGroup("0|"+pU)+k0.nonCapturingGroup(X.decimalPattern)+"?")+(X.allowDecimalOnly?"|"+X.decimalPattern:"")+"?")),mU=lU({decimalPattern:OG,allowDecimalOnly:!1}),TG=mU.test.bind(mU),$6=lU({decimalPattern:AG,allowDecimalOnly:!0}),yO=$6.test.bind($6),BG=/^-?\d*\.?\d*$/,RG=(X)=>X.length!==0&&BG.test(X),L2=m4(k0.negativeLookahead("^-0$")+"-?"+k0.nonCapturingGroup(k0.nonCapturingGroup("0|"+pU))),DG=L2.test.bind(L2),p4=/^-?\d+$/,MG=p4.test.bind(p4),dU={number:"a number",bigint:"a bigint",integer:"an integer"},cU=(X,U)=>`'${X}' was parsed as ${dU[U]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,wG=(X,U)=>U==="number"?TG(X):DG(X),PG=(X,U)=>U==="number"?Number(X):Number.parseInt(X),IG=(X,U)=>U==="number"?RG(X):MG(X),iU=(X,U)=>l4(X,"number",U),sU=(X,U)=>l4(X,"number",{...U,strict:!0}),oU=(X,U)=>l4(X,"integer",U),l4=(X,U,q)=>{let Z=PG(X,U);if(!Number.isNaN(Z)){if(IG(X,U)){if(q?.strict)return wG(X,U)?Z:F(cU(X,U));return Z}}return q?.errorOnFail?F(q?.errorOnFail===!0?`Failed to parse ${dU[U]} from '${X}'`:q?.errorOnFail):void 0},rU=(X)=>{if(X[X.length-1]!=="n")return;let U=X.slice(0,-1),q;try{q=BigInt(U)}catch{return}if(L2.test(U))return q;if(p4.test(U))return F(cU(X,"bigint"))};var KG="0.56.0",NG={version:KG,filename:hU.fileName(),FileConstructor:h4},_1=NG,aU=new Map,d4=Object.create(null),z2=(X)=>{let U=aU.get(X);if(U)return U;let q=CG(X);if(d4[q])q=`${q}${d4[q]++}`;else d4[q]=1;return _1[q]=X,aU.set(X,q),q},i0=(X)=>/^[$A-Z_a-z][\w$]*$/.test(X),CG=(X)=>{switch(typeof X){case"object":{if(X===null)break;let U=W2(X)??"object";return U[0].toLowerCase()+U.slice(1)}case"function":return i0(X.name)?X.name:"fn";case"symbol":return X.description&&i0(X.description)?X.description:"symbol"}return y(`Unexpected attempt to register serializable value of type ${r(X)}`)};var F2=(X)=>typeof X==="string"?JSON.stringify(X):typeof X==="bigint"?`${X}n`:`${X}`;var nU=(X,U={})=>V2(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?L6(q,U?.indent??0,""):JSON.stringify(V2(q,N1,[]),null,U?.indent):L6(q,U?.indent??0,"");case"symbol":return N1.onSymbol(X);default:return F2(X)}},L6=(X,U,q)=>{if(typeof X==="function")return N1.onFunction(X);if(typeof X!=="object"||X===null)return F2(X);let Z=q+" ".repeat(U);if(Array.isArray(X)){if(X.length===0)return"[]";let G=X.map((Y)=>L6(Y,U,Z)).join(`,
145
- `+Z);return U?`[
146
- ${Z}${G}
147
- ${q}]`:`[${G}]`}let Q=X.constructor?.name??"Object";if(Q==="Object"){let G=J1(X).map(([Y,J])=>{let H=typeof Y==="symbol"?N1.onSymbol(Y):i0(Y)?Y:JSON.stringify(Y),W=L6(J,U,Z);return`${Z}${H}: ${W}`});if(G.length===0)return"{}";return U?`{
148
- ${G.join(`,
149
- `)}
150
- ${q}}`:`{${G.join(", ")}}`}if(X instanceof Date)return $1(X);if("expression"in X&&typeof X.expression==="string")return X.expression;return Q},N1={onCycle:()=>"(cycle)",onSymbol:(X)=>`Symbol(${z2(X)})`,onFunction:(X)=>`Function(${z2(X)})`},V2=(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 N1.onFunction(Z);if(q.includes(Z))return"(cycle)";let Q=[...q,Z];if(Array.isArray(Z))return Z.map((Y)=>V2(Y,U,Q));if(Z instanceof Date)return Z.toDateString();let G={};for(let Y in Z)G[Y]=V2(Z[Y],U,Q);for(let Y of Object.getOwnPropertySymbols(Z))G[U.onSymbol?.(Y)??Y.toString()]=V2(Z[Y],U,Q);return G}case"symbol":return N1.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(),J=X.getMilliseconds();if(q===0&&Z===1&&Q===0&&G===0&&Y===0&&J===0)return`${U}`;let H=`${SG[q]} ${Z}, ${U}`;if(Q===0&&G===0&&Y===0&&J===0)return H;let W=X.toLocaleTimeString(),$=W.endsWith(" AM")||W.endsWith(" PM")?W.slice(-3):"";if($)W=W.slice(0,-$.length);if(J)W+=`.${jG(J,3)}`;else if(EG.test(W))W=W.slice(0,-3);return`${W+$}, ${H}`},SG=["January","February","March","April","May","June","July","August","September","October","November","December"],EG=/:\d\d:00$/,jG=(X,U)=>String(X).padStart(U,"0");var tU=(X,U,...[q])=>{let Z=q?.stringifySymbol??E,Q=X;switch(typeof U){case"string":Q=i0(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},v0=(X,...U)=>X.reduce((q,Z)=>tU(q,Z,...U),"");class A2 extends W6{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=v0(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let X="",U=[X];for(let q of this)X=tU(X,q),U.push(X);return this.cache.stringifyAncestors=U}}class O2{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 c0))}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 eU=(X,U)=>`Unmatched ${X}${U===""?"":` before ${U}`}`,z6=(X)=>`Missing ${X}`;var YT=D0("implementedTraits");var c4="$ark",bG=2;while(c4 in globalThis)c4=`$ark${bG++}`;var Xq=c4;globalThis[Xq]=_1;var A=_1,fG=(X)=>`${Xq}.${X}`,d=(X)=>fG(z2(X));class F6 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 i4(X,U)}index(X,U=!1){return Uq(`${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 yU(...this.argNames,this.body)}}var M0=(X)=>G0(X,"object")||typeof X==="symbol"?d(X):F2(X),i4=(X,U=!1)=>{if(typeof X==="string"&&i0(X))return`${U?"?":""}.${X}`;return Uq(gG(X),U)},gG=(X)=>typeof X==="symbol"?d(X):JSON.stringify(X),Uq=(X,U=!1)=>`${U?"?.":""}[${X}]`;class T2 extends F6{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 V6=(X)=>S(X,(U,q)=>[U,h(q)?[...q]:q]),Z0=D0("arkKind"),M=(X,U)=>X?.[Z0]===U,x=(X)=>M(X,"root")||M(X,"constraint");var qq=["unit","proto","domain"],C1=["required","optional","index","sequence"],s4=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],o4=[...s4,"structure","predicate"],A6=[...o4,...C1],S1=["alias","union","morph","unit","intersection","proto","domain"],yG=[...S1,...A6],O6=S(A6,(X,U)=>[U,1]),Zq=S([...C1,"undeclared"],(X,U)=>[U,1]),Qq=S(yG,(X,U)=>[U,X]),E1=(X)=>typeof X==="string"&&(X in Qq);var j1=(X)=>Qq[X],T6=(X)=>S1.slice(j1(X)+1),lT=[...T6("union"),"alias"],dT=[...T6("morph"),"alias"],V0=(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)},s0=(X)=>{let U="{ ";for(let[q,Z]of Object.entries(X))U+=`${q}: ${M0(Z)}, `;return U+" }"},j=(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 Gq 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 kG={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:Gq,throw:(...X)=>{throw new p.Error(...X)},throwInternalOperandError:(X,U)=>y(`Unexpected JSON Schema input for ${X}: ${E(U)}`),defaultConfig:kG};A.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]=r4(X.toJsonSchema,U.toJsonSchema);else if(E1(Z))q[Z]={...X[Z],...U[Z]};else q[Z]=U[Z]}return q},vG={"draft-2020-12":"https://json-schema.org/draft/2020-12/schema","draft-07":"http://json-schema.org/draft-07/schema#"},r4=(X,U)=>{if(!X)return Yq(U??{},void 0);if(!U)return X;let q={...X},Z;for(Z in U)if(Z==="fallback")q.fallback=hG(X.fallback,U.fallback);else q[Z]=U[Z];return Yq(q,U)},Yq=(X,U)=>{if(U?.dialect!==void 0)return X;if(U?.target!==void 0)return{...X,dialect:vG[U.target]};return X},hG=(X,U)=>{X=Jq(X),U=Jq(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},Jq=(X)=>typeof X==="function"?{default:X}:X??{};class o0 extends H2{[Z0]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:X,relativePath:U,...q},Z){super();this.input=q,this.ctx=Z,SU(this,q);let Q=Z.data;if(q.code==="union")q.errors=q.errors.flatMap((Y)=>{let J=Y.hasCode("union")?Y.errors:[Y];if(!X&&!U)return J;return J.map((H)=>H.transform((W)=>({...W,path:wU(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 o0(X({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode(X){return this.code===X}get propString(){return v0(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 W0 extends W6{[Z0]="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 a4(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 o0({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 W0(this.ctx);for(let q of this)U.add(X(q));return U}merge(X){for(let U of X)this.add(new o0({...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]=g(this.byAncestorPath[U],X)}}class a4 extends Error{name="TraversalError";constructor(X){if(X.length===1)super(X.summary);else super(`
155
- `+X.map((U)=>` • ${xG(U)}`).join(`
156
- `));Object.defineProperty(this,"arkErrors",{value:X,enumerable:!1})}}var xG=(X)=>X.toString().split(`
157
- `).join(`
158
- `);class w0{path=[];errors=new W0(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 v0(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 o0(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=x(Q),Y=Q(Z===void 0?this.root:Z[q],this);if(Y instanceof o0){if(!this.errors.includes(Y))this.errors.add(Y);break}if(Y instanceof W0){if(!G)this.errors.merge(Y);this.queuedMorphs=[];break}if(Z===void 0)this.root=Y;else Z[q]=Y;this.applyQueuedMorphs()}}}var _0=(X,U,q)=>{if(!q)return U();q.path.push(X);let Z=U();return q.path.pop(),Z};class D2 extends H0{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)=>lG(Z,Q.shallowReferences),[this]);let q=this.isStructural();this.flatRefs=[],this.flatMorphs=[];for(let Z=0;Z<this.children.length;Z++){if(this.includesTransform||=this.children[Z].includesTransform,this.includesContextualPredicate||=this.children[Z].includesContextualPredicate,this.isCyclic||=this.children[Z].isCyclic,!q){let Q=this.children[Z].flatRefs;for(let G=0;G<Q.length;G++){let Y=Q[G];if(!this.flatRefs.some((J)=>Wq(J,Y))){this.flatRefs.push(Y);for(let J of Y.node.branches)if(J.hasKind("morph")||J.hasKind("intersection")&&J.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:Y.path,propString:Y.propString,node:J})}}}Object.assign(this.referencesById,this.children[Z].referencesById)}this.flatRefs.sort((Z,Q)=>Z.path.length>Q.path.length?1:Z.path.length<Q.path.length?-1:Z.propString>Q.propString?1:Z.propString<Q.propString?-1:Z.node.expression<Q.node.expression?-1:1),this.allowsRequiresContext=this.includesContextualPredicate||this.isCyclic,this.rootApplyStrategy=!this.allowsRequiresContext&&this.flatMorphs.length===0?this.shallowMorphs.length===0?"allows":this.shallowMorphs.every((Z)=>Z.length===1||Z.name==="$arkStructuralMorph")?this.hasKind("union")?this.branches.some((Z)=>Z.shallowMorphs.length>1)?"contextual":"branchedOptimistic":this.shallowMorphs.length>1?"contextual":"optimistic":"contextual":"contextual",this.rootApply=this.createRootApply(),this.allows=this.allowsRequiresContext?(Z)=>this.traverseAllows(Z,new w0(Z,this.$.resolvedConfig)):(Z)=>this.traverseAllows(Z)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(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,y(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=pG(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=j1(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]=h(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=x(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(!F0(X,this.kind))Y1(`${this.kind} node was not one of asserted kinds ${X}`);return this}isBasis(){return F0(qq,this.kind)}isConstraint(){return F0(A6,this.kind)}isStructural(){return F0(C1,this.kind)}isRefinement(){return F0(o4,this.kind)}isRoot(){return F0(S1,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit(X){return this.hasKind("unit")&&this.allows(X)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select(X){let U=R2.normalize(X);return this._select(U)}_select(X){let U=R2.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 R2.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(!h(_)){let V=_._transform(X,U);return V?[W,V]:[]}if(_.length===0)return[W,$];let L=_.flatMap((V)=>{return V._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(x(Y))return Z=Y;let J=Object.keys(Y);if((J.length===0||J.length===1&&J[0]==="meta")&&!S0(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in Y))return U.undeclaredKeyHandling?{...Y,value:A.intrinsic.unknown}:null;if(this.kind==="morph")Y.in??=A.intrinsic.unknown;return Z=q.node(this.kind,Y,U.parseOptions)}configureReferences(X,U="references"){let q=R2.normalize(U),Z=typeof X==="string"?(J,H)=>({...H,meta:{...H.meta,description:X}}):typeof X==="function"?(J,H)=>({...H,meta:X(H.meta)}):(J,H)=>({...H,meta:{...H.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&&l0(Q),Y=q.boundary==="child"?(J,H)=>H.root.children.includes(J):q.boundary==="shallow"?(J)=>J.kind!=="structure":()=>!0;return this.$.finalize(this.transform(Z,{shouldTransform:Y,selected:G}))}}var R2={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(Hq(U,q));return X},find:(X)=>X[0],assertFind:(X,U,q)=>{if(X.length===0)Y1(Hq(U,q));return X[0]}},normalize:(X)=>typeof X==="function"?{boundary:"references",method:"filter",where:X}:typeof X==="string"?a(X,R2.applyBoundary)?{method:"filter",boundary:X}:{boundary:"references",method:"filter",kind:X}:{boundary:"references",method:"filter",...X}},Hq=(X,U)=>`${X} had no references matching ${E(U)}.`,uG=(X)=>v0(X,{stringifyNonKey:(U)=>U.expression}),mG=/"(\$ark\.[^"]+)"/g,pG=(X)=>JSON.stringify(X).replace(mG,"$1"),P0=(X,U)=>({path:X,node:U,propString:uG(X)}),Wq=(X,U)=>X.propString===U.propString&&X.node.equals(U.node),n4=(X,U)=>C0(X,U,{isEqual:Wq}),lG=(X,U)=>C0(X,U,{isEqual:(q,Z)=>q.equals(Z)});class T extends Array{static init(X,U,q,Z){return new T({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=v0(X);return e4(`Intersection${Z&&` at ${Z}`} of ${_q(U,q)}`)}return`The following intersections result in unsatisfiable types:
159
- • ${this.map(({path:X,l:U,r:q})=>`${X}: ${_q(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 T))return new T(...X);return X}withPrefixKey(X,U){return this.map((q)=>({...q,path:[X,...q.path],optional:q.optional||U==="optional"}))}toNeverIfDisjoint(){return A.intrinsic.never}}var _q=(X,U)=>`${t4(X)} and ${t4(U)}`,t4=(X)=>x(X)?X.expression:h(X)?X.map(t4).join(" | ")||"never":String(X),e4=(X)=>`${X} results in an unsatisfiable type`;var b1={},$0=(X,U,q)=>u(X,U,{$:q,invert:!1,pipe:!1}),M2=(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 J=`${U.hash}${Z}${X.hash}`;if(b1[J]!==void 0){let H=b1[J],W=H instanceof T?H.invert():H;return b1[Q]=W,W}}let G=!q.pipe||!X.includesTransform&&!U.includesTransform;if(G&&X.equals(U))return X;let Y=G?X9(X,U,q):X.hasKindIn(...S1)?dG(X,U,q):X9(X,U,q);if(x(Y)){if(X.equals(Y))Y=X;else if(U.equals(Y))Y=U}return b1[Q]=Y,Y},X9=(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 T)G=G.invert();return G}},dG=(X,U,q)=>X.includesTransform||U.includesTransform?q.invert?$q(U,X,q):$q(X,U,q):X9(X,U,q),$q=(X,U,q)=>X.distribute((Z)=>cG(Z,U,q),(Z)=>{let Q=Z.filter(x);if(Q.length===0)return T.init("union",X.branches,U.branches);if(Q.length<X.branches.length||!X.branches.every((J,H)=>J.rawIn.equals(Q[H].rawIn)))return q.$.parseSchema(Q);let G;if(Q.length===1){let J=Q[0];if(!G)return J;return q.$.node("morph",{...J.inner,in:J.rawIn.configure(G,"self")})}let Y={branches:Q};if(G)Y.meta=G;return q.$.parseSchema(Y)}),cG=(X,U,q)=>{if(X.hasKind("morph")){let Q=[...X.morphs];if(X.lastMorphIfNode){let G=u(X.lastMorphIfNode,U,q);if(G instanceof T)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 T)return Q;return q.$.node("morph",{morphs:[U],in:Q})}return q.$.node("morph",{morphs:[U],in:X})};class A0 extends D2{constructor(X,U){super(X,U);Object.defineProperty(this,Z0,{value:"constraint",enumerable:!1})}impliedSiblings;intersect(X){return $0(this,X,this.$)}}class h0 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 s0(this.errorContext)}}var q0=(X)=>(U,q)=>{if(h(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},f1=(X)=>{let U=X.r.shift();if(!U){let Z=X.l.length===0&&X.kind==="structure"?A.intrinsic.unknown.internal:X.ctx.$.node(X.kind,Object.assign(X.baseInner,iG(X.l)),{prereduced:!0});for(let Q of X.roots){if(Z instanceof T)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 T)return Q;if(Q.isRoot())return X.roots.push(Q),X.l.splice(Z),f1(X);if(!q)X.l[Z]=Q,q=!0;else if(!X.l.includes(Q))return y(`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)C0(X.r,Z)}return f1(X)},g1=(X)=>{return Object.entries(X).flatMap(([q,Z])=>(q in O6)?Z:[]).sort((q,Z)=>q.precedence<Z.precedence?-1:q.precedence>Z.precedence?1:q.kind==="predicate"&&Z.kind==="predicate"?0:q.hash<Z.hash?-1:1)},iG=(X)=>{let U={};for(let q of X)if(q.hasOpenIntersection())U[q.kind]=g(U[q.kind],q);else{if(U[q.kind])return y(`Unexpected intersection of closed refinements of kind ${q.kind}`);U[q.kind]=q}return U},Lq=(...X)=>F(zq(...X)),zq=(X,U,q)=>{let Z=q.hasKind("morph")?"a morph":q.isUnknown()?"unknown":q.exclude(U).defaultShortDescription;return`${xU(X)} operand must be ${U.description} (was ${Z})`};var Fq=(X,U,q)=>new r0(X,U,q,q,null);class B6 extends H0{}class r0 extends H0{[Z0]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor(X,U,q,Z,Q){super((...G)=>{let Y=S(this.names,(J,H)=>{let W=this.arg$.parse(G[J]);if(!W.extends(this.constraints[J]))F(sG(H,this.constraints[J].expression,W.expression));return[H,W]});if(this.defIsLazy()){let J=this.bodyDef(Y);return this.$.parse(J)}return this.$.parse(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:nU(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map((X)=>typeof X==="string"?[X,A.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 sG=(X,U,q)=>`${X} must be assignable to ${U} (was ${q})`;var oG=j({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 Vq 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=s0(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 U9={implementation:oG,Node:Vq};var rG=j({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:(X)=>Number.isInteger(X)?X:F(aG(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/nG(X.rule,U.rule))})},obviatesBasisDescription:!0});class Aq extends h0{traverseAllows=(X)=>X%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=A.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema(X){if(X.type="integer",this.rule===1)return X;return X.multipleOf=this.rule,X}}var q9={implementation:rG,Node:Aq};var aG=(X)=>`divisor must be an integer (was ${X})`,nG=(X,U)=>{let q,Z=X,Q=U;while(Q!==0)q=Q,Q=Z%Q,Z=q;return Z};class z0 extends h0{boundOperandKind=U5[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=q5(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${tG[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?Z5(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan(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 tG={"<":">=","<=":">",">":"<=",">=":"<"},eG={min:"max",minLength:"maxLength",after:"before"},R6={parse:(X)=>X||void 0},D6=(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},M6=(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},w6=(X)=>typeof X==="string"||typeof X==="number"?new Date(X):X,X5=(X,U)=>`${X} bound must be a positive integer (was ${U})`,y1=(X)=>(U)=>{if(!Number.isInteger(U)||U<0)F(X5(X,U));return U},U5={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},q5=(X,U)=>`${a(X,eG)?">":"<"}${U?"":"="}`,Z5=(X)=>typeof X==="string"?X:new Date(X).toLocaleString(),Oq=(X)=>`Bounded expression ${X} must be exactly one of number, string, Array, or Date`;var Q5=j({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:w6,serialize:(X)=>X.toISOString()}},normalize:M6("after"),defaults:{description:(X)=>`${X.collapsibleLimitString} or later`,actual:$1},intersections:{after:(X,U)=>X.isStricterThan(U)?X:U}});class Tq extends z0{impliedBasis=A.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 Z9={implementation:Q5,Node:Tq};var G5=j({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:w6,serialize:(X)=>X.toISOString()}},normalize:M6("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:T.init("range",X,U)}});class Bq extends z0{collapsibleLimitString=$1(this.rule);traverseAllows=(X)=>X<=this.rule;impliedBasis=A.intrinsic.Date.internal;reduceJsonSchema(X,U){return U.fallback.date({code:"date",base:X,before:this.rule})}}var Q9={implementation:G5,Node:Bq};var Y5=j({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)=>T.init("unit",q.$.node("unit",{unit:X.rule}),q.$.node("unit",{unit:U.rule}),{path:["length"]}),minLength:(X,U)=>X.rule>=U.rule?X:T.init("range",X,U),maxLength:(X,U)=>X.rule<=U.rule?X:T.init("range",X,U)}});class Rq extends h0{traverseAllows=(X)=>X.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=A.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 G9={implementation:Y5,Node:Rq};var J5=j({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:R6},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:T.init("range",X,U)},obviatesBasisDescription:!0});class Dq extends z0{impliedBasis=A.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 Y9={implementation:J5,Node:Dq};var H5=j({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:y1("maxLength")}},reduce:(X,U)=>X.rule===0?U.node("exactLength",X):void 0,normalize:D6("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:T.init("range",X,U)}});class Mq extends z0{impliedBasis=A.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 J9={implementation:H5,Node:Mq};var W5=j({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:R6},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 wq extends z0{impliedBasis=A.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:W5,Node:wq};var _5=j({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:y1("minLength")}},reduce:(X)=>X.rule===0?A.intrinsic.unknown:void 0,normalize:D6("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 Pq extends z0{impliedBasis=A.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 W9={implementation:_5,Node:Pq};var Iq={min:H9.implementation,max:Y9.implementation,minLength:W9.implementation,maxLength:J9.implementation,exactLength:G9.implementation,after:Z9.implementation,before:Q9.implementation},Kq={min:H9.Node,max:Y9.Node,minLength:W9.Node,maxLength:J9.Node,exactLength:G9.Node,after:Z9.Node,before:Q9.Node};var $5=j({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:(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 Nq extends h0{instance=new RegExp(this.rule,this.flags);expression=`${this.instance}`;traverseAllows=this.instance.test.bind(this.instance);compiledCondition=`${this.expression}.test(data)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=A.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 _9={implementation:$5,Node:Nq};var w2=(X,U)=>{let q=L5(X);if(U&&!U.includes(q))return F(`Root of kind ${q} should be one of ${U}`);return q},L5=(X)=>{if(M(X,"root"))return X.kind;if(typeof X==="string")return X[0]==="$"?"alias":(X in Y0)?"domain":"proto";if(typeof X==="function")return"proto";if(typeof X!=="object"||X===null)return F(Cq(X));if("morphs"in X)return"morph";if("branches"in X||h(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 O6)))return"intersection";if("proto"in X)return"proto";if("domain"in X)return"domain";return F(Cq(X))},Cq=(X)=>`${E(X)} is not a valid type schema`,Sq={},z5=(X)=>h(X)?X.map((U)=>U.collapsibleJson):X.collapsibleJson,Q0={};A.nodesByRegisteredId=Q0;var $9=(X)=>{return Sq[X]??=0,`${X}${++Sq[X]}`},L9=(X)=>{let U=k1[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,J=y4(G).sort(([W],[$])=>E1(W)?E1($)?j1(W)-j1($):1:E1($)?-1:W<$?-1:1).filter(([W,$])=>{if(W.startsWith("meta.")){let _=W.slice(5);return Y[_]=$,!1}return!0});for(let W of J){let $=W[0],_=U.keys[$];if(!_)return F(`Key ${$} is not valid on ${X.kind} schema`);let L=_.parse?_.parse(W[1],X):W[1];if(L!==J0&&(L!==void 0||_.preserveUndefined))Z[$]=L}if(U.reduce&&!X.prereduced){let W=U.reduce(Z,X.$);if(W){if(W instanceof T)return W.throw();return F5(W,Y)}}return z9({id:X.id,kind:X.kind,inner:Z,meta:Y,$:X.$})},z9=({id:X,kind:U,inner:q,meta:Z,$:Q,ignoreCache:G})=>{let Y=k1[U],J=y4(q),H=[],W={};for(let[D,P]of J){let K=Y.keys[D],C=K.serialize??(K.child?z5:V0);if(W[D]=C(P),K.child===!0){let N=P;if(h(N))H.push(...N);else H.push(N)}else if(typeof K.child==="function")H.push(...K.child(P))}if(Y.finalizeInnerJson)W=Y.finalizeInnerJson(W);let $={...W},_={};if(!S0(Z))_=S(Z,(D,P)=>[D,D==="examples"?P:V0(P)]),$.meta=P6(_,"description",!0);W=P6(W,Y.collapsibleKey,!1);let L=JSON.stringify({kind:U,...W});$=P6($,Y.collapsibleKey,!1);let V=P6($,Y.collapsibleKey,!0),B=JSON.stringify({kind:U,...$});if(Q.nodesByHash[B]&&!G)return Q.nodesByHash[B];let z={id:X,kind:U,impl:Y,inner:q,innerEntries:J,innerJson:W,innerHash:L,meta:Z,metaJson:_,json:$,hash:B,collapsibleJson:V,children:H};if(U!=="intersection"){for(let D in q)if(D!=="in"&&D!=="out")z[D]=q[D]}let O=new jq[U](z,Q);return Q.nodesByHash[B]=O},Eq=(X,U)=>{if(X.id===U)return X;if(x(Q0[U]))y(`Unexpected attempt to overwrite node id ${U}`);return z9({id:U,kind:X.kind,inner:X.inner,meta:X.meta,$:X.$,ignoreCache:!0})},F5=(X,U,q)=>{if(q&&x(Q0[q]))y(`Unexpected attempt to overwrite node id ${q}`);return z9({id:q??$9(U.alias??X.kind),kind:X.kind,inner:X.inner,meta:U,$:X.$})},P6=(X,U,q)=>{let Z=Object.keys(X);if(Z.length===1&&Z[0]===U){let Q=X[U];if(q)return Q;if(G0(Q,"object")&&(Object.keys(Q).length===1||Array.isArray(Q)))return Q}return X};var P2=(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 T)if(G==="optional")Q=A.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(F9(X.default,U.default)):X.default:U.hasDefault()?U.default:J0;return q.$.node("optional",{key:Z,value:Q,default:Y})};class I2 extends A0{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=A.intrinsic.object.internal;serializedKey=M0(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=g(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 _0(this.key,()=>this.value.traverseAllows(X[this.key],U),U);return this.optional};traverseApply=(X,U)=>{if(this.key in X)_0(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 F9=(X,U)=>`Invalid intersection of default values ${E(X)} & ${E(U)}`;var V5=j({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:P2}});class bq extends I2{constructor(...X){super(...X);if("default"in this.inner)N2(this.value,this.inner.default,this.key)}get rawIn(){let X=super.rawIn;if(!this.hasDefault())return X;return this.$.node("optional",_6(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=O5(this);defaultValueMorphRef=this.defaultValueMorph&&d(this.defaultValueMorph)}var K2={implementation:V5,Node:bq},A5={},O5=(X)=>{if(!X.hasDefault())return;let U=`{${X.compiledKey}: ${X.value.id} = ${V0(X.default)}}`;return A5[U]??=V9(X.key,X.value,X.default)},V9=(X,U,q)=>{if(typeof q==="function")return U.includesTransform?(Q,G)=>{return _0(X,()=>U(Q[X]=q(),G),G),Q}:(Q)=>{return Q[X]=q(),Q};let Z=U.includesTransform?U.assert(q):q;return G0(Z,"object")?(Q,G)=>{return _0(X,()=>U(Q[X]=q,G),G),Q}:(Q)=>{return Q[X]=Z,Q}},N2=(X,U,q)=>{let Z=d0(U);if(G0(U,"object")&&!Z)F(T5(q));let Q=X.in(Z?U():U);if(Q instanceof W0){if(q===null)F(`Default ${Q.summary}`);let G=Q.transform((Y)=>Y.transform((J)=>({...J,prefixPath:[q]})));F(`Default for ${G.summary}`)}return U},T5=(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 O0 extends D2{constructor(X,U){super(X,U);Object.defineProperty(this,Z0,{value:"root",enumerable:!1})}get rawIn(){return super.rawIn}get rawOut(){return super.rawOut}get internal(){return this}get "~standard"(){return{vendor:"arktype",version:1,validate:(X)=>{let U=this(X);if(U instanceof W0)return U;return{value:U}},jsonSchema:{input:(X)=>this.rawIn.toJsonSchema({target:fq(X.target),...X.libraryOptions}),output:(X)=>this.rawOut.toJsonSchema({target:fq(X.target),...X.libraryOptions})}}}as(){return this}brand(X){if(X==="")return F(B5);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=r4(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 T)return q;return this.$.finalize(q)}rawIntersect(X){return $0(this,X,this.$)}toNeverIfDisjoint(){return this}and(X){let U=this.intersect(X);return U instanceof T?U.throw():U}rawAnd(X){let U=this.rawIntersect(X);return U instanceof T?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(),A.intrinsic.unknown.internal);if(X.branches.length===0)F(e4(`keyof ${this.expression}`));return this._keyof=this.$.finalize(X)}get props(){if(this.branches.length!==1)return F(D5(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge(X){let U=this.$.parseDefinition(X);return this.$.schema(U.distribute((q)=>this.applyStructuralOperation("merge",[gq(q)??F(yq("merge",q.expression))])))}applyStructuralOperation(X,U){return this.distribute((q)=>{if(q.equals(A.intrinsic.object)&&X!=="merge")return q;let Z=gq(q);if(!Z)F(yq(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 T)}extends(X){if(this.isNever())return!0;let U=this.intersect(X);return!(U instanceof T)&&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 N2(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
- ${Y}
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=M2(this,X,this.$);if(U instanceof T)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:y(`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 Lq(U,Z.impliedBasis,this);let G=this.$.node("intersection",{[Z.kind]:Z}),Y=X==="out"?M2(this,G,this.$):$0(this,G,this.$);if(Y instanceof T)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"?_6(Q,{undeclared:1}):{...Q,undeclared:U}:Q,q?void 0:{shouldTransform:(Z)=>!F0(C1,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",v1(X))}lessThan(X){return this.constrain("max",v1(X))}atLeastLength(X){return this.constrain("minLength",X)}atMostLength(X){return this.constrain("maxLength",X)}moreThanLength(X){return this.constrain("minLength",v1(X))}lessThanLength(X){return this.constrain("maxLength",v1(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",v1(X))}earlierThan(X){return this.constrain("before",v1(X))}}var B5="Expected a non-empty brand name after #",kq=["draft-2020-12","draft-07"],R5=(X)=>`JSONSchema target '${X}' is not supported (must be ${kq.map((U)=>`"${U}"`).join(" or ")})`,fq=(X)=>{if(!F0(kq,X))F(R5(X));return X},v1=(X)=>typeof X==="object"&&!(X instanceof Date)?{...X,exclusive:!0}:{rule:X,exclusive:!0},C2=(X,U)=>M(U,"root")?M(X,"root")?X.extends(U):U.allows(X):M(X,"root")?X.hasUnit(U):U===X,gq=(X)=>{if(X.hasKind("morph"))return null;if(X.hasKind("intersection"))return X.inner.structure??(X.basis?.domain==="object"?X.$.bindReference(A.intrinsic.emptyStructure):null);if(X.isBasis()&&X.domain==="object")return X.$.bindReference(A.intrinsic.emptyStructure);return null},D5=(X)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
163
- ${X}`,yq=(X,U)=>`${X} operand must be an object (was ${U})`;var E0=(X,U)=>S(T6(X),(q,Z)=>[Z,U]);var M5=(X)=>typeof X==="string"?{reference:X}:X,vq=(X)=>X instanceof T?A.intrinsic.never.internal:X,w5=j({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:(X)=>X.startsWith("$")?X:`$ark.${X}`},resolve:{}},normalize:M5,defaults:{description:(X)=>X.reference},intersections:{alias:(X,U,q)=>q.$.lazilyResolve(()=>vq(u(X.resolution,U.resolution,q)),`${X.reference}${q.pipe?"=>":"&"}${U.reference}`),...E0("alias",(X,U,q)=>{if(U.isUnknown())return X;if(U.isNever())return U;if(U.isBasis()&&!U.overlaps(A.intrinsic.object))return T.init("assignability",A.intrinsic.object,U);return q.$.lazilyResolve(()=>vq(u(X.resolution,U,q)),`${X.reference}${q.pipe?"=>":"&"}${U.id}`)})}});class hq extends O0{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(P5(U.id,q));q.push(U.id),U=Q0[U.id]}if(!M(U,"root"))return y(`Unexpected resolution for reference ${this.reference}
164
- Seen: [${q.join("->")}]
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 y(`Unexpected resolution for reference ${this.reference}: ${E(U)}`)}get defaultShortDescription(){return Y0.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]=g(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]=g(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 P5=(X,U)=>`Alias '${X}' has a shallow resolution cycle: ${[...U,X].join("->")}`,S2={implementation:w5,Node:hq};class L1 extends O0{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 s0(this.errorContext)}compile(X){if(X.traversalKind==="Allows")X.return(this.compiledCondition);else X.if(this.compiledNegation,()=>X.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}}var I5=j({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:(X)=>typeof X==="string"?{domain:X}:K1(X,"numberAllowsNaN")&&X.domain!=="number"?F(I6.writeBadAllowNanMessage(X.domain)):X,applyConfig:(X,U)=>X.numberAllowsNaN===void 0&&X.domain==="number"&&U.numberAllowsNaN?{...X,numberAllowsNaN:!0}:X,defaults:{description:(X)=>Y0[X.domain],actual:(X)=>Number.isNaN(X)?"NaN":Y0[r(X)]},intersections:{domain:(X,U)=>X.domain==="number"&&U.domain==="number"?X.numberAllowsNaN?U:X:T.init("domain",X,U)}});class xq 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 Y0[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 I6={implementation:I5,Node:xq,writeBadAllowNanMessage:(X)=>`numberAllowsNaN may only be specified with domain "number" (was ${X})`};var K5=j({kind:"intersection",hasAssociatedError:!0,normalize:(X)=>{if(x(X))return X;let{structure:U,...q}=X,Z=!!U,Q=U??{},G=S(q,(Y,J)=>{if(a(Y,Zq)){if(Z)F(`Flattened structure key ${Y} cannot be specified alongside a root 'structure' key.`);return Q[Y]=J,[]}return[Y,J]});if(M(Q,"constraint")||!S0(Q))G.structure=Q;return G},finalizeInnerJson:({structure:X,...U})=>G0(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:q0("divisor")},max:{child:!0,parse:q0("max")},min:{child:!0,parse:q0("min")},maxLength:{child:!0,parse:q0("maxLength")},minLength:{child:!0,parse:q0("minLength")},exactLength:{child:!0,parse:q0("exactLength")},before:{child:!0,parse:q0("before")},after:{child:!0,parse:q0("after")},pattern:{child:!0,parse:q0("pattern")},predicate:{child:!0,parse:q0("predicate")}},reduce:(X,U)=>uq({},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)=>uq(X.inner,U.inner,q),...E0("intersection",(X,U,q)=>{if(X.children.length===0)return U;let{domain:Z,proto:Q,...G}=X.inner,Y=Q??Z,J=Y?u(Y,U,q):U;return J instanceof T?J:X?.basis?.equals(J)?X:X.$.node("intersection",{...G,[J.kind]:J},{prereduced:!0})})}});class mq extends O0{basis=this.inner.domain??this.inner.proto??null;prestructurals=[];refinements=this.children.filter((X)=>{if(!X.isRefinement())return!1;if(F0(s4,X.kind))this.prestructurals.push(X);return!0});structure=this.inner.structure;expression=N5(this);get shallowMorphs(){return this.inner.structure?.structuralMorph?[this.inner.structure.structuralMorph]:[]}get defaultShortDescription(){return this.basis?.defaultShortDescription??"present"}innerToJsonSchema(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:K5,Node:mq},N5=(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"},uq=(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 T)return Y;if(Y)Z[Y.kind]=Y;return f1({kind:"intersection",baseInner:Z,l:g1(X),r:g1(U),roots:[],ctx:q})};var C5=j({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:(X,U)=>U.$.parseSchema(X)},morphs:{parse:l0,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(S5(X.expression,U.expression));let Z=u(X.rawIn,U.rawIn,q);if(Z instanceof T)return Z;let Q={morphs:X.morphs};if(X.declaredIn||U.declaredIn){let G=u(X.rawIn,U.rawIn,q);if(G instanceof T)return G.throw();else Q.declaredIn=G}if(X.declaredOut||U.declaredOut){let G=u(X.rawOut,U.rawOut,q);if(G instanceof T)return G.throw();else Q.declaredOut=G}return Z.distribute((G)=>q.$.node("morph",{...Q,in:G}),q.$.parseSchema)},...E0("morph",(X,U,q)=>{let Z=X.inner.in?u(X.inner.in,U,q):U;return Z instanceof T?Z:Z.equals(X.inner.in)?X:q.$.node("morph",{...X.inner,in:Z})})}});class pq extends O0{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??A.intrinsic.unknown.internal}get rawOut(){return this.declaredOut??this.introspectableOut??A.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 O9={implementation:C5,Node:pq},S5=(X,U)=>`The intersection of distinct morphs at a single path is indeterminate:
168
- Left: ${X}
169
- Right: ${U}`;var E5=j({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:(X)=>$2(X)??V0(X)},dateAllowsInvalid:{}},normalize:(X)=>{let U=typeof X==="string"?{proto:H1[X]}:typeof X==="function"?x(X)?X:{proto:X}:typeof X.proto==="string"?{...X,proto:H1[X.proto]}:X;if(typeof U.proto!=="function")F(E2.writeInvalidSchemaMessage(U.proto));if(K1(U,"dateAllowsInvalid")&&U.proto!==Date)F(E2.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?bU[X.builtinName]:`an instance of ${X.proto.name}`,actual:(X)=>X instanceof Date&&X.toString()==="Invalid Date"?"an invalid Date":_2(X)},intersections:{proto:(X,U)=>X.proto===Date&&U.proto===Date?X.dateAllowsInvalid?U:X:u4(X.proto,U.proto)?X:u4(U.proto,X.proto)?U:T.init("proto",X,U),domain:(X,U)=>U.domain==="object"?X:T.init("domain",A.intrinsic.object.internal,U)}});class lq 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 E2={implementation:E5,Node:lq,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 j5=j({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((J)=>J.hasKind("morph")&&J.hasEqualMorphs(G));if(Y===-1)q.push(G);else{let J=q[Y];q[Y]=U.$.node("morph",{...J.inner,in:J.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)=>h(X)?{branches:X}:X,reduce:(X,U)=>{let q=m5(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,h1),expected:(X)=>{let U=PU(X.errors,"propString"),q=Object.entries(U).map(([Z,Q])=>{let G=[];for(let H of Q)C0(G,H.expected);let Y=h1(G),J=Q.every((H)=>H.actual===Q[0].actual)?Q[0].actual:E(Q[0].data);return`${Z&&`${Z} `}must be ${Y}${J&&` (was ${J})`}`});return h1(q)},problem:(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 T.init("presence",X,U);let Z;if(X.ordered){if(U.ordered)F(l5(X.expression,U.expression));if(Z=T9(U.branches,X.branches,q),Z instanceof T)Z.invert()}else Z=T9(X.branches,U.branches,q);if(Z instanceof T)return Z;return q.$.parseSchema(X.ordered||U.ordered?{branches:Z,ordered:!0}:{branches:Z})},...E0("union",(X,U,q)=>{let Z=T9(X.branches,[U],q);if(Z instanceof T)return Z;if(Z.length===1)return Z[0];return q.$.parseSchema(X.ordered?{branches:Z,ordered:!0}:{branches:Z})})}});class iq extends O0{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]=A.intrinsic.boolean;continue}X.push(q)}return X}unitBranches=this.branches.filter((X)=>X.rawIn.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?h5(this.discriminant):null;expression=this.distribute((X)=>X.nestableExpression,u5);createBranchedOptimisticRootApply(){return(X,U)=>{let q=this.traverseOptimistic(X);if(q!==J0)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)=>C0(X,U.shallowMorphs),[])}get defaultShortDescription(){return this.distribute((X)=>X.defaultShortDescription,h1)}innerToJsonSchema(X){if(this.branchGroups.length===1&&this.branchGroups[0].equals(A.intrinsic.boolean))return{type:"boolean"};let U=this.branchGroups.map((q)=>q.toJsonSchemaRecurse(X));if(U.every((q)=>Object.keys(q).length===1&&K1(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 J0};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) : "${J0}"`;else L=`${X.invoke($)} ? data : "${J0}"`;else L=X.invoke($);X.line(`${_}: return ${L}`)}return X}),X.traversalKind==="Allows"){X.return(Q?`"${J0}"`:!1);return}let G=h1(this.discriminant.kind==="domain"?Z.map((W)=>{let $=W.slice(1,-1);return $==="function"?Y0.object:Y0[$]}):Z),Y=this.discriminant.path.map((W)=>typeof W==="symbol"?d(W):JSON.stringify(W)),J=JSON.stringify(G),H=this.discriminant.kind==="domain"?`${k5}[${U}]`:`${v5}(${U})`;X.line(`ctx.errorFromNodeContext({
170
- code: "predicate",
171
- expected: ${J},
172
- actual: ${H},
173
- relativePath: [${Y}],
174
- meta: ${this.compiledMeta}
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?`"${J0}"`:!1)}}get nestableExpression(){return this.isBoolean?"boolean":`(${this.expression})`}discriminate(){if(this.branches.length<2||this.isCyclic)return null;if(this.unitBranches.length===this.branches.length){let Q=S(this.unitBranches,(G,Y)=>[`${Y.rawIn.serializedValue}`,Y.hasKind("morph")?Y:!0]);return{kind:"unit",path:[],optionallyChainedPropString:"data",cases:Q}}let 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 J=this.branches[Y],H=$0(G.rawIn,J.rawIn,G.$);if(!(H instanceof T))continue;for(let W of H){if(!W.kind||W.optional)continue;let $,_;if(W.kind==="domain"){let{l:V,r:B}=W;$=`"${typeof V==="string"?V:V.domain}"`,_=`"${typeof B==="string"?B:B.domain}"`}else if(W.kind==="unit")$=W.l.serializedValue,_=W.r.serializedValue;else continue;let L=X.find((V)=>y0(V.path,W.path)&&V.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=C0(L.cases[$].branchIndices,Q);else L.cases[$]??={branchIndices:[Q],condition:W.l};if(L.cases[_])L.cases[_].branchIndices=C0(L.cases[_].branchIndices,Y);else L.cases[_]??={branchIndices:[Y],condition:W.r}}}}}let U=this.ordered?g5(X,this.branches):X;if(!U.length)return null;let q=b5(U,this),Z={};for(let Q in q.best.cases){let G=f5(q,Q);if(G===null){Z[Q]=!0;continue}if(G.length===this.branches.length)return null;if(this.ordered)G.sort((H,W)=>H.originalIndex-W.originalIndex);let Y=G.map((H)=>H.branch),J=Y.length===1?Y[0]:this.$.node("union",this.ordered?{branches:Y,ordered:!0}:Y);Object.assign(this.referencesById,J.referencesById),Z[Q]=J}if(q.defaultEntries.length){let Q=q.defaultEntries.map((G)=>G.branch);Z.default=this.$.node("union",this.ordered?{branches:Q,ordered:!0}:Q,{prereduced:!0}),Object.assign(this.referencesById,Z.default.referencesById)}return Object.assign(q.location,{cases:Z})}}var b5=(X,U)=>{let Z=X.sort((Y,J)=>Y.path.length===J.path.length?Object.keys(J.cases).length-Object.keys(Y.cases).length:Y.path.length-J.path.length)[0],Q={kind:Z.kind,path:Z.path,optionallyChainedPropString:sq(Z.path)},G=U.branches.map((Y,J)=>({originalIndex:J,branch:Y}));return{best:Z,location:Q,defaultEntries:G,node:U}},f5=(X,U)=>{let q=X.best.cases[U],Z=y5(q.condition,X.location.path,X.node.$),Q=[],G=[];for(let Y=0;Y<X.defaultEntries.length;Y++){let J=X.defaultEntries[Y];if(q.branchIndices.includes(J.originalIndex)){let H=dq(X.node.branches[J.originalIndex],X.location);if(H===null)Q=null;else Q?.push({originalIndex:J.originalIndex,branch:H})}else if(J.branch.hasKind("alias")&&Z.hasKind("domain")&&Z.domain==="object")Q?.push(J);else{if(J.branch.rawIn.overlaps(Z)){let H=dq(J.branch,X.location);Q?.push({originalIndex:J.originalIndex,branch:H})}G.push(J)}}return X.defaultEntries=G,Q},g5=(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 J=G+1;J<Q.length;J++){let H=Q[J];for(let W of Y)for(let $ of H)if(W>$){if(U[W].overlaps(U[$]))return!1}}}return!0})},y5=(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:[...MU(G).map((Y)=>({})),Z]}:{domain:"object",required:[{key:G,value:Z}]})}return Z},sq=(X)=>X.reduce((U,q)=>U+i4(q,!0),"data"),k5=d(IU),v5=d(E),B9={implementation:j5,Node:iq},h5=(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])}),x5={delimiter:" | ",finalDelimiter:" | "},u5=(X)=>h1(X,x5),h1=(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((J)=>Q[J]?!1:Q[J]=!0),Y=G.pop();return`${G.join(q)}${G.length?Z:""}${Y}`},T9=(X,U,q)=>{let Z=U.map(()=>[]);for(let G=0;G<X.length;G++){let Y={};for(let J=0;J<U.length;J++){if(Z[J]===null)continue;if(X[G].equals(U[J])){Z[J]=null,Y={};break}let H=u(X[G],U[J],q);if(H instanceof T)continue;if(H.equals(X[G])){Z[J].push(X[G]),Y={};break}if(H.equals(U[J]))Z[J]=null;else Y[J]=H}for(let J in Y)Z[J][G]=Y[J]}let Q=Z.flatMap((G,Y)=>G?.flatMap((J)=>J.branches)??U[Y]);return Q.length===0?T.init("union",X,U):Q},m5=({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=$0(X[Z].rawIn,X[Q].rawIn,X[0].$);if(G instanceof T)continue;if(!U)p5(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])},p5=(X,U)=>{if(!X.includesTransform&&!U.includesTransform)return;if(!y0(X.shallowMorphs,U.shallowMorphs))F(cq(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(cq(X.expression,U.expression))},dq=(X,U)=>X.transform((q,Z)=>{if(q==="domain"||q==="unit")return null;return Z},{shouldTransform:(q,Z)=>{let Q=sq(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"}}),cq=(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}`,l5=(X,U)=>`The intersection of two ordered unions is indeterminate:
178
- Left: ${X}
179
- Right: ${U}`;var d5=j({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:(X)=>X instanceof Date?X.toISOString():V0(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)=>T.init("unit",X,U),...E0("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:A.intrinsic.object;if(X.domain!==Z.domain){let Q=X.domain==="undefined"||X.domain==="null"||X.domain==="boolean"?X.domain:A.intrinsic[X.domain];return T.init("domain",Q,Z)}}return T.init("assignability",X,U.hasKind("intersection")?U.children.find((Z)=>!Z.allows(X.unit)):U)})}});class rq extends L1{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=oq(this.unit,this.serializedValue);compiledNegation=oq(this.unit,this.serializedValue,"negated");expression=E(this.unit);domain=r(this.unit);get defaultShortDescription(){return this.domain==="object"?Y0.object:this.description}innerToJsonSchema(X){return this.unit===null?{type:"null"}:A.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 R9={implementation:d5,Node:rq},oq=(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 c5=j({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:(X,U)=>{let q=U.$.parseSchema(X);if(!q.extends(A.intrinsic.key))return F(s5(q.expression));let Z=q.branches.filter((Q)=>Q.hasKind("unit"));if(Z.length)return F(i5(Z.map((Q)=>E(Q.unit))));return q}},value:{child:!0,parse:(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 T?A.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 aq extends A0{impliedBasis=A.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=g(this.value.flatRefs.map((X)=>P0([this.signature,...X.path],X.node)),P0([this.signature],this.value));traverseAllows=(X,U)=>J1(X).every((q)=>{if(this.signature.traverseAllows(q[0],U))return _0(q[0],()=>this.value.traverseAllows(q[1],U),U);return!0});traverseApply=(X,U)=>{for(let q of J1(X))if(this.signature.traverseAllows(q[0],U))_0(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 D9={implementation:c5,Node:aq},i5=(X)=>`Index keys ${X.join(", ")} should be specified as named props.`,s5=(X)=>`Indexed key definition '${X}' must be a string or symbol`;var o5=j({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:P2,optional:P2}});class nq extends I2{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=s0(this.errorContext)}var M9={implementation:o5,Node:nq};var r5=j({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 N2(Z,q[1],null),[Z,q[1]]})},serialize:(X)=>X.map((U)=>[U[0].collapsibleJson,V0(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(e5);if(X.optionals?.length||X.defaultables?.length)return F(P9)}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=j2({l:X.tuple,r:U.tuple,disjoint:new T,result:[],fixedVariants:[],ctx:q}),Q=Z.disjoint.length===0?[Z,...Z.fixedVariants]:Z.fixedVariants;return Q.length===0?Z.disjoint:Q.length===1?q.$.node("sequence",tq(Q[0].result)):q.$.node("union",Q.map((G)=>({proto:Array,sequence:tq(G.result)})))}}});class XZ extends A0{impliedBasis=A.intrinsic.Array.internal;tuple=t5(this.inner);prefixLength=this.prefix?.length??0;defaultablesLength=this.defaultables?.length??0;optionalsLength=this.optionals?.length??0;postfixLength=this.postfix?.length??0;defaultablesAndOptionals=[];prevariadic=this.tuple.filter((X)=>{if(X.kind==="defaultables"||X.kind==="optionals")return this.defaultablesAndOptionals.push(X.node),!0;return X.kind==="prefix"});variadicOrPostfix=g0(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return n4(this.flatRefs,this.prevariadic.flatMap((X,U)=>g(X.node.flatRefs.map((q)=>P0([`${U}`,...q.path],q.node)),P0([`${U}`],X.node)))),n4(this.flatRefs,this.variadicOrPostfix.flatMap((X)=>g(X.flatRefs.map((U)=>P0([A.intrinsic.nonNegativeIntegerString.internal,...U.path],U.node)),P0([A.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=n5(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??y(`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++)_0(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(A.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=A.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 a5={},n5=(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(V9(Q,G,Y)),q+=`${Q}: ${G.id} = ${V0(Y)}, `}return q+="]",a5[q]??=U},w9={implementation:r5,Node:XZ},t5=(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},tq=(X)=>X.reduce((U,q)=>{if(q.kind==="variadic")U.variadic=q.node;else if(q.kind==="defaultables")U.defaultables=g(U.defaultables,[[q.node,q.default]]);else U[q.kind]=g(U[q.kind],q.node);return U},{}),P9="A postfix required element cannot follow an optional or defaultable element",e5="A postfix element requires a variadic element",j2=(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",J=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 _=j2({...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 _=j2({...X,fixedVariants:[],l:q.map((L)=>({...L,kind:"prefix"}))});if(_.disjoint.length===0)X.fixedVariants.push(_)}let H=u(U.node,Z.node,X.ctx);if(H instanceof T)if(J==="prefix"||J==="postfix")X.disjoint.push(...H.withPrefixKey(J==="prefix"?X.result.length:`-${q.length+1}`,eq(U)&&eq(Z)?"required":"optional")),X.result=[...X.result,{kind:J,node:A.intrinsic.never.internal}];else if(J==="optionals"||J==="defaultables")return X;else return j2({...X,fixedVariants:[],l:q.map((_)=>({..._,kind:"prefix"})),r:q.map((_)=>({..._,kind:"prefix"}))});else if(J==="defaultables"){if(U.kind==="defaultables"&&Z.kind==="defaultables"&&U.default!==Z.default)F(F9(U.default,Z.default));X.result=[...X.result,{kind:J,node:H,default:U.kind==="defaultables"?U.default:Z.kind==="defaultables"?Z.default:y(`Unexpected defaultable intersection from ${U.kind} and ${Z.kind} elements.`)}]}else X.result=[...X.result,{kind:J,node:H}];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 j2(X)},eq=(X)=>X.kind==="prefix"||X.kind==="postfix";var QZ=(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??"{}"},X7=QZ("description"),U7=QZ("expression"),UZ=(X,U,q)=>{let Z=X.required?"required":"optional";if(!U.signature.allows(X.key))return null;let Q=$0(X.value,U.value,q);if(Q instanceof T)return Z==="optional"?q.node("optional",{key:X.key,value:A.intrinsic.never.internal}):Q.withPrefixKey(X.key,X.kind);return null},q7=j({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:q0("required"),reduceIo:(X,U,q)=>{U.required=g(U.required,q.map((Z)=>X==="in"?Z.rawIn:Z.rawOut));return}},optional:{child:!0,parse:q0("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]=g(U[Z.outProp.kind],Z.outProp.rawOut)}},index:{child:!0,parse:q0("index")},sequence:{child:!0,parse:q0("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:X7},intersections:{structure:(X,U,q)=>{let Z={...X.inner},Q={...U.inner},G=new T;if(X.undeclared){let H=X.keyof();for(let W of U.requiredKeys)if(!H.allows(W))G.add("presence",A.intrinsic.never.internal,U.propsByKey[W].value,{path:[W]});if(Q.optional)Q.optional=Q.optional.filter((W)=>H.allows(W.key));if(Q.index)Q.index=Q.index.flatMap((W)=>{if(W.signature.extends(H))return W;let $=$0(H,W.signature,q.$);if($ instanceof T)return[];let _=K6($,W.value,q.$);if(_.required)Q.required=g0(Q.required,_.required);if(_.optional)Q.optional=g0(Q.optional,_.optional);return _.index??[]})}if(U.undeclared){let H=U.keyof();for(let W of X.requiredKeys)if(!H.allows(W))G.add("presence",X.propsByKey[W].value,A.intrinsic.never.internal,{path:[W]});if(Z.optional)Z.optional=Z.optional.filter((W)=>H.allows(W.key));if(Z.index)Z.index=Z.index.flatMap((W)=>{if(W.signature.extends(H))return W;let $=$0(H,W.signature,q.$);if($ instanceof T)return[];let _=K6($,W.value,q.$);if(_.required)Z.required=g0(Z.required,_.required);if(_.optional)Z.optional=g0(Z.optional,_.optional);return _.index??[]})}let Y={};if(X.undeclared||U.undeclared)Y.undeclared=X.undeclared==="reject"||U.undeclared==="reject"?"reject":"delete";let J=f1({kind:"structure",baseInner:Y,l:g1(Z),r:g1(Q),roots:[],ctx:q});if(J instanceof T)G.push(...J);if(G.length)return G;return J}},reduce:(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(ZZ(Y.key));if(q[Y.key]=!0,X.index)for(let J of X.index){let H=UZ(Y,J,U);if(H instanceof T)return H}}if(X.optional)for(let G=0;G<X.optional.length;G++){let Y=X.optional[G];if(Y.key in q)F(ZZ(Y.key));if(q[Y.key]=!0,X.index)for(let J of X.index){let H=UZ(Y,J,U);if(H instanceof T)return H;if(H!==null)Q[G]=H,Z=!0}}if(Z)return U.node("structure",{...X,optional:Q},{prereduced:!0})}});class GZ extends A0{impliedBasis=A.intrinsic.object.internal;impliedSiblings=this.children.flatMap((X)=>X.impliedSiblings??[]);props=g0(this.required,this.optional);propsByKey=S(this.props,(X,U)=>[U.key,U]);propsByKeyReference=d(this.propsByKey);expression=U7(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(x(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]=g(U[q.kind],q),U}let Q=q.kind??Z?.kind??"required",G=S(q,(Y,J)=>(Y in K2.implementation.keys)?[Y,J]:[]);return U[Q]=g(U[Q],this.$.node(Q,G)),U},{}))}assertHasKeys(X){let U=X.filter((q)=>!C2(q,this.keyof()));if(U.length)return F(qZ(this.expression,U))}get(X,...U){let q,Z=!1,Q=Y7(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(C2(Q,Y.signature))q=q?.and(Y.value)??Y.value}if(this.sequence&&C2(Q,A.intrinsic.nonNegativeIntegerString))if(M(Q,"root")){if(this.sequence.variadic)q=q?.and(this.sequence.element)??this.sequence.element}else{let Y=Number.parseInt(Q);if(Y<this.sequence.prevariadic.length){let J=this.sequence.prevariadic[Y].node;q=q?.and(J)??J,Z||=Y<this.sequence.prefixLength}else if(this.sequence.variadic){let J=this.$.node("union",this.sequence.variadicOrPostfix);q=q?.and(J)??J}}if(!q){if(this.sequence?.variadic&&M(Q,"root")&&Q.extends(A.intrinsic.number))return F(J7(Q.expression,this.sequence.expression));return F(qZ(this.expression,[Q]))}let G=q.get(...U);return Z?G:G.or(A.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=g(U.required,X.required);if(X.optional)U.optional=g(U.optional,X.optional);if(X.index)U.index=g(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=V6(this.inner),Z=(Q)=>{let G=U.some((Y)=>C2(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 J of this.index)if(J.signature.traverseAllows(Y,q)){if(X==="Allows"){if(!_0(Y,()=>J.value.traverseAllows(U[Y],q),q))return!1}else if(_0(Y,()=>J.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&&A.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",Q7(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(["),G7(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=A.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(A.intrinsic.string)){X.additionalProperties=Z;continue}for(let Q of q.signature.branches){if(!Q.extends(A.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 y(`Unexpected index branch kind ${Q.kind}.`);let{pattern:Y}=Q.inner;if(Y){let J=Object.assign(G,{pattern:Y[0].rule});for(let H=1;H<Y.length;H++)G=U.fallback.patternIntersection({code:"patternIntersection",base:J,pattern:Y[H].rule});X.patternProperties??={},X.patternProperties[J.pattern]=Z}}}if(this.undeclared&&!X.additionalProperties)X.additionalProperties=!1;return X}}var I9={},Z7=(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},Q7=(X)=>{let U=Z7(X);if(!U)return;if(I9[U])return I9[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 I9[U]=q},G7=(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:J}=U.defaultable[G];Q.if(`!(${Y} in data)`,(H)=>H.line(`${J}${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")})},K9={implementation:q7,Node:GZ},Y7=(X)=>{if(M(X,"root")&&X.hasKind("unit"))X=X.unit;if(typeof X==="number")X=`${X}`;return X},J7=(X,U)=>`${X} is not allowed as an array index on ${U}. Use the 'nonNegativeIntegerString' keyword instead.`,K6=(X,U,q)=>{let[Z,Q]=DU(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 J=q.node("required",{key:Y.unit,value:U});G[J.kind]=g(G[J.kind],J)}if(Q.length)G.index=q.node("index",{signature:Q,value:U});return G},H7=(X)=>M(X,"root")?X.expression:E(X),qZ=(X,U)=>`Key${U.length===1?"":"s"} ${U.map(H7).join(", ")} ${U.length===1?"does":"do"} not exist on ${X}`,ZZ=(X)=>`Duplicate key ${M0(X)}`;var k1={...Iq,alias:S2.implementation,domain:I6.implementation,unit:R9.implementation,proto:E2.implementation,union:B9.implementation,morph:O9.implementation,intersection:A9.implementation,divisor:q9.implementation,pattern:_9.implementation,predicate:U9.implementation,required:M9.implementation,optional:K2.implementation,index:D9.implementation,sequence:w9.implementation,structure:K9.implementation};A.defaultConfig=EU(Object.assign(S(k1,(X,U)=>[X,U.defaults]),{jitless:kU(),clone:fU,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:p.defaultConfig}));A.resolvedConfig=B2(A.defaultConfig,A.config);var jq={...Kq,alias:S2.Node,domain:I6.Node,unit:R9.Node,proto:E2.Node,union:B9.Node,morph:O9.Node,intersection:A9.Node,divisor:q9.Node,pattern:_9.Node,predicate:U9.Node,required:M9.Node,optional:K2.Node,index:D9.Node,sequence:w9.Node,structure:K9.Node};class x1 extends k4{get[Z0](){return"module"}}var N9=(X,U)=>new x1(S(X,(q,Z)=>[q,M(Z,"module")?N9(Z,U):U.bindReference(Z)]));var W7=(X)=>h(X)?X:("branches"in X)&&h(X.branches)?X.branches:void 0,_7=(X,U)=>F(`Node of kind ${U} is not valid as a ${X} definition`),YZ=(X)=>`#${X} duplicates public alias ${X}`,C9={};A.ambient??={};var JZ,WZ="function $",$7=(X)=>_Z(X,$Z(X)),_Z=(X,U)=>{let q=U.write(WZ,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}},$Z=(X)=>new F6().return(X.reduce((U,q)=>{let Z=new T2({kind:"Allows"}).indent();q.compile(Z);let Q=Z.write(`${q.id}Allows`),G=new T2({kind:"Apply"}).indent();q.compile(G);let Y=G.write(`${q.id}Apply`),J=`${U}${Q},
180
- ${Y},
181
- `;if(!q.hasKind("union"))return J;let H=new T2({kind:"Allows",optimistic:!0}).indent();q.compile(H);let W=H.write(`${q.id}Optimistic`);return`${J}${W},
182
- `},`{
183
- `)+"}");class N6{config;resolvedConfig;name;get[Z0](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(X,U){if(this.config=B2(A.config,U),this.resolvedConfig=B2(A.resolvedConfig,U),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(C9).length}`,this.name in C9)F(`A Scope already named ${this.name} already exists`);C9[this.name]=this;let q=Object.entries(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(YZ(G));this.aliases[G]=Q}else{if(G in this.aliases)F(YZ(Z));this.aliases[G]=Q,this.exportedNames.push(G)}if(!M(Q,"module")&&!M(Q,"generic")&&!d0(Q)){let Y=this.preparseOwnDefinitionFormat(Q,{alias:G});this.resolutions[G]=M(Y,"root")?this.bindReference(Y):this.createParseContext(Y).id}}JZ??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[JZ.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=A.intrinsic?S(A.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 r0(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(w2(X),X,U);preparseNode(X,U,q){let Z=typeof X==="string"?X:w2(U,X);if(x(U)&&U.kind===Z)return U;if(Z==="alias"&&!q?.prereduced){let{reference:Y}=S2.implementation.normalize(U,this);if(Y.startsWith("$")){let J=this.resolveRoot(Y.slice(1));U=J,Z=J.kind}}else if(Z==="union"&&G0(U,"object")){let Y=W7(U);if(Y?.length===1)U=Y[0],Z=w2(U)}if(x(U)&&U.kind===Z)return U;let G=k1[Z].normalize?.(U,this)??U;if(x(G))return G.kind===Z?G:_7(Z,G.kind);return{...q,$:this,kind:Z,def:G,prefix:q.alias??Z}}bindReference(X){let U;if(x(X))U=X.$===this?X:new X.constructor(X.attachments,this);else U=X.$===this?X:new r0(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(j9(X))}maybeResolveRoot(X){let U=this.maybeResolve(X);if(M(U,"generic"))return;return U}maybeResolveSubalias(X){return S9(this.aliases,X)??S9(this.ambient,X)}get ambient(){return A.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 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[X]=Q}return y(`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(FZ(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,{[Z0]:"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")?N9(Z,this):HZ(this.maybeResolve(q))}for(let q of this.lazyResolutions)q.resolution;if(this._exportedResolutions=zZ(this,this._exports),this._json=LZ(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let q=$Z(this.references);this.precompilation=q.write(WZ,4),_Z(this.references,q)}this.resolved=!0}let 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(x(Z))return this.bindReference(Z);let Q=this.createParseContext(Z),G=L9(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=Eq(Q,Z.id);return Q0[Z.id]=Q,Q}finalize(X){if(HZ(X),!X.precompilation&&!this.resolvedConfig.jitless)$7(X.references);return X}}class E9 extends N6{parseOwnDefinitionFormat(X,U){return L9(U)}preparseOwnDefinitionFormat(X,U){return this.preparseNode(w2(X),X,U)}preparseOwnAliasEntry(X,U){return[X,U]}normalizeRootScopeValue(X){return X}}var HZ=(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},LZ=(X)=>S(X,(U,q)=>[U,M(q,"root")||M(q,"generic")?q.json:M(q,"module")?LZ(q):y(`Unexpected resolution ${E(q)}`)]),S9=(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(L7(Z));let G=U.slice(q+1),Y=Q[G];if(Y===void 0)return S9(Q,G);if(M(Y,"root")||M(Y,"generic"))return Y;if(M(Y,"module"))return Y.root??F(FZ(U));y(`Unexpected resolution for alias '${U}': ${E(Y)}`)},C6=(X,U)=>new E9(X,U),b2=new E9({});var zZ=(X,U)=>{let q={};for(let Z in U){let Q=U[Z];if(M(Q,"module")){let G=zZ(X,Q),Y=S(G,(J,H)=>[`${Z}.${J}`,H]);Object.assign(q,Y)}else if(M(Q,"root")||M(Q,"generic"))q[Z]=Q;else y(`Unexpected scope resolution ${E(Q)}`)}return q},j9=(X)=>`'${X}' is unresolvable`,L7=(X)=>`'${X}' must reference a module to be accessed using dot syntax`,FZ=(X)=>`Reference to submodule '${X}' must specify an alias`;b2.export();var{schema:v,node:u1,defineSchema:aw,generic:T0}=b2;var b9="^(?:0|[1-9]\\d*)$",z7=new RegExp(b9),ew=d(z7);var VZ=C6({bigint:"bigint",boolean:[{unit:!1},{unit:!0}],false:{unit:!1},never:[],null:{unit:null},number:"number",object:"object",string:"string",symbol:"symbol",true:{unit:!0},unknown:{},undefined:{unit:void 0},Array,Date},{prereducedAliases:!0}).export();A.intrinsic={...VZ};var AZ=C6({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:b9}},{prereducedAliases:!0}).export();Object.assign(A.intrinsic,AZ);var F7=C6({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),I={...VZ,...AZ,...F7,emptyStructure:u1("structure",{},{prereduced:!0})};A.intrinsic={...I};var S6=(X,U)=>new RegExp(X,U);Object.assign(S6,{as:S6});var TZ=(X)=>typeof X==="string"&&X[0]==="d"&&(X[1]==="'"||X[1]==='"')&&X[X.length-1]===X[1],OZ=(X)=>X.toString()!=="Invalid Date",BZ=(X)=>X.slice(2,-1),f9=(X)=>`'${X}' could not be parsed by the Date constructor`,RZ=(X,U)=>V7(X,U),V7=(X,U)=>{let q=new Date(X);if(OZ(q))return q;let Z=iU(X);if(Z!==void 0){let Q=new Date(Z);if(OZ(Q))return Q}return U?F(U===!0?f9(X):U):void 0};var A7=v({proto:"Array",sequence:"string",required:{key:"groups",value:["object",{unit:void 0}]}}),E6=(X,U)=>{let q=X.scanner.shiftUntilEscapable(T7[wZ[U]]);if(X.scanner.lookahead==="")return X.error(R7(q,U));if(X.scanner.shift(),U in MZ){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:A7})}else if(a(U,g9))X.root=X.ctx.$.node("unit",{unit:q});else{let Z=RZ(q,f9(q));X.root=X.ctx.$.node("unit",{meta:q,unit:Z})}},g9={"'":1,'"':1},DZ={"/":1,"'":1,'"':1},O7={"d'":"'",'d"':'"',"'":"'",'"':'"'},MZ={"/":"/","x/":"/"},wZ={...O7,...MZ},T7={"'":(X)=>X.lookahead==="'",'"':(X)=>X.lookahead==='"',"/":(X)=>X.lookahead==="/"},B7={'"':"double-quote","'":"single-quote","/":"forward slash"},R7=(X,U)=>`${U}${X} requires a closing ${B7[wZ[U]]}`;var PZ=(X)=>`Private type references should not include '#'. Use '${X}' instead.`,j6="Optional definitions like 'string?' are only valid as properties in an object or tuple",b6="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var j0={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...c0};var IZ=(X,U)=>X===">"?U[0]==="="?U[1]==="=":U.trimStart()===""||a(U.trimStart()[0],j0):X==="="?U[0]!=="=":X===","||X==="?";var KZ=(X,U,q)=>NZ(X,U,q,[]),NZ=(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 NZ(X,U,q,Z);return Q.error(z6(">"))},y9=(X,U,q)=>`${X}<${U.join(", ")}> requires exactly ${U.length} args (got ${q.length}${q.length===0?"":`: ${q.join(", ")}`})`;var f6=(X)=>{let U=X.scanner.shiftUntilLookahead(j0);if(U==="keyof")X.addPrefix("keyof");else X.root=M7(X,U)},D7=(X,U,q)=>{if(q.scanner.shiftUntilNonWhitespace(),q.scanner.shift()!=="<")return q.error(y9(X,U.names,[]));let Q=KZ(X,U,q);return U(...Q)},M7=(X,U)=>w7(X,U)??P7(X,U)??X.error(U===""?X.scanner.lookahead==="#"?PZ(X.shiftedBy(1).scanner.shiftUntilLookahead(j0)):k9(X):j9(U)),w7=(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 D7(U,q,X);return F(`Unexpected resolution ${E(q)}`)},P7=(X,U)=>{let q=sU(U);if(q!==void 0)return X.ctx.$.node("unit",{unit:q});let Z=rU(U);if(Z!==void 0)return X.ctx.$.node("unit",{unit:Z})},k9=(X)=>{let U=X.previousOperator();return U?v9(U,X.scanner.unscanned):I7(X.scanner.unscanned)},v9=(X,U="")=>`Token '${X}' requires a right operand${U?` before '${U}'`:""}`,I7=(X)=>`Expected an expression${X?` before '${X}'`:""}`;var h9=(X)=>X.scanner.lookahead===""?X.error(k9(X)):X.scanner.lookahead==="("?X.shiftedBy(1).reduceGroupOpen():X.scanner.lookaheadIsIn(DZ)?E6(X,X.scanner.shift()):X.scanner.lookaheadIsIn(c0)?h9(X.shiftedBy(1)):X.scanner.lookahead==="d"?X.scanner.nextLookahead in g9?E6(X,`${X.scanner.shift()}${X.scanner.shift()}`):f6(X):X.scanner.lookahead==="x"?X.scanner.nextLookahead==="/"?X.shiftedBy(2)&&E6(X,"x/"):f6(X):f6(X);var CZ={">":!0,">=":!0},SZ={"<":!0,"<=":!0};var m1={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},EZ=(X,U)=>`Left bounds are only valid when paired with right bounds (try ...${U}${X})`,g6=(X)=>`Left-bounded expressions must specify their limits using < or <= (was ${X})`,jZ=(X,U,q,Z)=>`An expression may have at most one left bound (parsed ${X}${m1[U]}, ${q}${m1[Z]})`;var fZ=(X,U)=>{let q=K7(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 C7(X,q)},gZ={"<":1,">":1,"=":1},K7=(X,U)=>X.scanner.lookaheadIs("=")?`${U}${X.scanner.shift()}`:U;var bZ=(X,U,q,Z)=>{if(q.extends(A.intrinsic.number)){if(typeof U!=="number")return F(x9(X,U,Z));return X==="=="?["min","max"]:X[0]===">"?["min"]:["max"]}if(q.extends(A.intrinsic.lengthBoundable)){if(typeof U!=="number")return F(x9(X,U,Z));return X==="=="?["exactLength"]:X[0]===">"?["minLength"]:["maxLength"]}if(q.extends(A.intrinsic.Date))return X==="=="?["after","before"]:X[0]===">"?["after"]:["before"];return F(Oq(q.expression))},N7=(X)=>({rule:TZ(X.limit)?BZ(X.limit):X.limit,exclusive:X.comparator.length===1}),C7=(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,J=U.length===1,H=bZ(U,typeof Y==="number"?Y:G,q,"right");for(let $ of H)X.constrainRoot($,U==="=="?{rule:Y}:{rule:Y,exclusive:J});if(!X.branches.leftBound)return;if(!a(U,SZ))return X.error(g6(U));let W=bZ(X.branches.leftBound.comparator,X.branches.leftBound.limit,q,"left");X.constrainRoot(W[0],N7(X.branches.leftBound)),X.branches.leftBound=null},x9=(X,U,q)=>`Comparator ${q==="left"?m1[X]:X} must be ${q==="left"?"preceded":"followed"} by a corresponding literal (was ${U})`;var yZ=(X)=>{X.scanner.shiftUntilNonWhitespace();let U=X.scanner.shiftUntilLookahead(j0);X.root=X.root.brand(U)};var vZ=(X)=>{X.scanner.shiftUntilNonWhitespace();let U=X.scanner.shiftUntilLookahead(j0),q=oU(U,{errorOnFail:kZ(U)});if(q===0)X.error(kZ(0));X.root=X.root.constrain("divisor",q)},kZ=(X)=>`% operator must be followed by a non-zero integer literal (was ${X})`;var u9=(X)=>{let U=X.scanner.shift();return U===""?X.finalize(""):U==="["?X.scanner.shift()==="]"?X.setRoot(X.root.array()):X.error(S7):U==="|"?X.scanner.lookahead===">"?X.shiftedBy(1).pushRootToBranch("|>"):X.pushRootToBranch(U):U==="&"?X.pushRootToBranch(U):U===")"?X.finalizeGroup():IZ(U,X.scanner.unscanned)?X.finalize(U):a(U,gZ)?fZ(X,U):U==="%"?vZ(X):U==="#"?yZ(X):(U in c0)?u9(X):X.error(y6(U))},y6=(X,U="")=>`'${X}' is not allowed here${U&&` (should be ${U})`}`,S7="Missing expected ']'";var hZ=(X)=>{let U=X.unsetRoot();X.parseOperand();let q=X.unsetRoot();if(!q.hasKind("unit"))return X.error(E7(q.expression));let Z=q.unit instanceof Date?()=>new Date(q.unit):q.unit;return[U,"=",Z]},E7=(X)=>`Default value '${X}' must be a literal value`;var m9=(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 p1(new O2(X),U),Q=j7(Z);if(Z.finalizer===">")F(y6(">"));return Q},j7=(X)=>{X.parseOperand();let U=f2(X).root;if(!U)return y(`Root was unexpectedly unset after parsing string '${X.scanner.scanned}'`);if(X.finalizer==="=")U=hZ(X);else if(X.finalizer==="?")U=[U,"?"];if(X.scanner.shiftUntilNonWhitespace(),X.scanner.lookahead)F(y6(X.scanner.lookahead));return U},f2=(X)=>{while(X.finalizer===void 0)b7(X);return X},b7=(X)=>X.hasRoot()?X.parseOperator():X.parseOperand();class p1{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(z6(")"));this.finalizeBranches(),this.finalizer=X}reduceLeftBound(X,U){let q=m1[U];if(!a(q,CZ))return this.error(g6(U));if(this.branches.leftBound)return this.error(jZ(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(eU(")",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():y(`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 f2(new p1(this.scanner,this.ctx))}parseOperator(){return u9(this)}parseOperand(){return h9(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(EZ(this.branches.leftBound.limit,this.branches.leftBound.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={prefixes:[],leftBound:null,union:null,intersection:null,pipe:null}}previousOperator(){return this.branches.leftBound?.comparator??this.branches.prefixes[this.branches.prefixes.length-1]??(this.branches.intersection?"&":this.branches.union?"|":this.branches.pipe?"|>":void 0)}shiftedBy(X){return this.scanner.jumpForward(X),this}}var f7="An empty string is not a valid generic parameter name",k6=(X,U,q)=>{X.shiftUntilNonWhitespace();let Z=X.shiftUntilLookahead(j0);if(Z===""){if(X.lookahead===""&&U.length)return U;return F(f7)}return X.shiftUntilNonWhitespace(),g7(X,Z,U,q)},xZ="extends ",g7=(X,U,q,Z)=>{if(X.shiftUntilNonWhitespace(),X.unscanned.startsWith(xZ))X.jumpForward(xZ.length);else{if(X.lookahead===",")X.shift();return q.push(U),k6(X,q,Z)}let Q=f2(new p1(X,Z));return q.push([U,Q.root]),k6(X,q,Z)};class p9 extends H0{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"),J=X.intrinsic.unknown;if(Z!==-1){if(Z!==q.length-2)return F(y7);J=X.parse(q[Z+1])}return(H)=>new uZ(H,Y,J)},{attach:U})}}class uZ extends H0{raw;params;returns;expression;constructor(X,U,q){let Z=`typed ${X.name}`,Q={[Z]:(...Y)=>{let J=U.assert(Y),H=X(...J);return q.assert(H)}}[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 y7=`":" must be followed by exactly one return type e.g:
184
- fn("string", ":", "number")(s => s.length)`;class l9 extends H0{$;constructor(X){super((...U)=>new g2(X)(...U),{bind:X});this.$=X}in(X){return new g2(this.$,X===void 0?void 0:this.$.parse(X))}at(X,U){return new g2(this.$).at(X,U)}case(X,U){return new g2(this.$).case(X,U)}}class g2 extends H0{$;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(v7);if(this.branches.length)F(k7);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:mZ};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:mZ},"self");return this.$.finalize(Z)}}var mZ=(X)=>X.throw(),k7="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",v7="At most one key matcher may be specified per expression";var v6=(X,U)=>{if(h(X)){if(X[1]==="=")return[U.$.parseOwnDefinitionFormat(X[0],U),"=",X[2]];if(X[1]==="?")return[U.$.parseOwnDefinitionFormat(X[0],U),"?"]}return h6(X,U)},pZ="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",lZ="Only required keys may specify default values, e.g. { value: 'number = 0' }";var dZ=(X,U)=>{let q,Z={},Q=J1(X);for(let[Y,J]of Q){let H=u7(Y);if(H.kind==="spread"){if(!S0(Z))return F(x7);let V=U.$.parseOwnDefinitionFormat(J,U);if(V.equals(I.object))continue;if(!V.hasKind("intersection")||!V.basis?.equals(I.object))return F(m7(V.expression));q=V.structure;continue}if(H.kind==="undeclared"){if(J!=="reject"&&J!=="delete"&&J!=="ignore")F(h7(J));Z.undeclared=J;continue}let W=v6(J,U),$=H;if(H.kind==="required"){if(!h(W))d9(Z,"required",{key:H.normalized,value:W},U);else d9(Z,"optional",W[1]==="="?{key:H.normalized,value:W[0],default:W[2]}:{key:H.normalized,value:W[0]},U);continue}if(h(W)){if(W[1]==="?")F(pZ);if(W[1]==="=")F(lZ)}if(H.kind==="optional"){d9(Z,"optional",{key:H.normalized,value:W},U);continue}let _=U.$.parseOwnDefinitionFormat($.normalized,U),L=K6(_,W,U.$);if(L.index)Z.index=g(Z.index,L.index);if(L.required)Z.required=g(Z.required,L.required)}let G=U.$.node("structure",Z);return U.$.parseSchema({domain:"object",structure:q?.merge(G)??G})},d9=(X,U,q,Z)=>{X[U]=g(X[U],Z.$.node(U,q))},h7=(X)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${E(X)})`,x7="Spread operator may only be used as the first key in an object",u7=(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},m7=(X)=>`Spread operand must resolve to an object literal type (was ${X})`;var iZ=(X,U)=>n7(X)?aZ[X[0]](X,U):r7(X)?rZ[X[1]](X,U):null,p7=(X,U)=>U.$.parseOwnDefinitionFormat(X[1],U).keyof(),c9=(X,U)=>{if(X[2]===void 0)return F(v9(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]==="&"?$0(q,Z,U.$):M2(q,Z,U.$);if(Q instanceof T)return Q.throw();return Q},l7=(X,U)=>U.$.parseOwnDefinitionFormat(X[0],U).array(),d7=(X,U)=>{if(typeof X[2]!=="function")return F(sZ("=>",X[2]));return U.$.parseOwnDefinitionFormat(X[0],U).pipe(X[2])},sZ=(X,U)=>`${X===":"?"Narrow":"Morph"} expression requires a function following '${X}' (was ${typeof U})`,c7=(X,U)=>{if(typeof X[2]!=="function")return F(sZ(":",X[2]));return U.$.parseOwnDefinitionFormat(X[0],U).constrain("predicate",X[2])},i7=(X,U)=>U.$.parseOwnDefinitionFormat(X[0],U).configure(X[2],X[3]),oZ=(X)=>X,s7=oZ({"[]":l7,"?":()=>F(j6)}),o7=oZ({"|":c9,"&":c9,":":c7,"=>":d7,"|>":c9,"@":i7,"=":()=>F(b6)}),rZ={...s7,...o7},r7=(X)=>rZ[X[1]]!==void 0,a7=(X)=>X,aZ=a7({keyof:p7,instanceof:(X,U)=>{if(typeof X[1]!=="function")return F(cZ(_2(X[1])));let q=X.slice(1).map((Z)=>typeof Z==="function"?U.$.node("proto",{proto:Z}):F(cZ(_2(Z))));return q.length===1?q[0]:U.$.node("union",{branches:q})},"===":(X,U)=>U.$.units(X.slice(1))}),n7=(X)=>aZ[X[0]]!==void 0,cZ=(X)=>`Expected a constructor following 'instanceof' operator (was ${X})`;var eZ=(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=v6(X[Z],U),[Y,J,H]=!h(G)?[G]:G;if(Z++,Q){if(!Y.extends(A.intrinsic.Array))return F(XY(Y.expression));q=q.flatMap((W)=>Y.distribute(($)=>e7(V6(W),$)))}else q=q.map((W)=>{if(J==="?")return X8(W,Y);if(J==="=")return t7(W,Y,H);return i9(W,Y)})}return U.$.parseSchema(q.map((Q)=>S0(Q)?{proto:Array,exactLength:0}:{proto:Array,sequence:Q}))},i9=(X,U)=>{if(X.defaultables||X.optionals)return F(X.variadic?P9:UY);if(X.variadic)X.postfix=g(X.postfix,U);else X.prefix=g(X.prefix,U);return X},X8=(X,U)=>{if(X.variadic)return F(U8);return X.optionals=g(X.optionals,U),X},t7=(X,U,q)=>{if(X.variadic)return F(U8);if(X.optionals)return F(qY);return X.defaultables=g(X.defaultables,[[U,q]]),X},nZ=(X,U)=>{if(X.postfix)F(tZ);if(X.variadic){if(!X.variadic.equals(U))F(tZ)}else X.variadic=U.internal;return X},e7=(X,U)=>{let q=U.select({method:"find",kind:"sequence"});if(!q)return nZ(X,A.intrinsic.unknown);if(q.prefix)for(let Z of q.prefix)i9(X,Z);if(q.optionals)for(let Z of q.optionals)X8(X,Z);if(q.variadic)nZ(X,q.variadic);if(q.postfix)for(let Z of q.postfix)i9(X,Z);return X},XY=(X)=>`Spread element must be an array (was ${X})`,tZ="A tuple may have at most one variadic element",UY="A required element may not follow an optional element",U8="An optional element may not follow a variadic element";var qY="A defaultable element may not follow an optional element without a default";var ZY={},h6=(X,U)=>{if(typeof X==="string"){if(U.args&&Object.keys(U.args).some((Z)=>X.includes(Z)))return m9(X,U);let q=ZY[U.$.name]??={};return q[X]??=m9(X,U)}return G0(X,"object")?QY(X,U):F(s9(r(X)))},QY=(X,U)=>{let q=W2(X);switch(q){case void 0:if(M(X,"root"))return X;if("~standard"in X)return GY(X,U);return dZ(X,U);case"Array":return YY(X,U);case"RegExp":return U.$.node("intersection",{domain:"string",pattern:X},{prereduced:!0});case"Function":{let Z=d0(X)?X():X;if(M(Z,"root"))return Z;return F(s9("Function"))}default:return F(s9(q??E(X)))}},GY=(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:uU(G),relativePath:Y.map((J)=>typeof J==="object"?J.key:J)});else Z.error({message:G});else Z.error({message:G})}),YY=(X,U)=>iZ(X,U)??eZ(X,U),s9=(X)=>`Type definitions must be strings or objects (was ${X})`;class o9 extends H0{constructor(X){let U=Object.assign({errors:W0,hkt:U0,$: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 r0(Q,q[1],X,X,null)}return X.parse(q)},{attach:U})}}var l1=A;class x6 extends N6{get ambientAttachments(){if(!l1.typeAttachments)return;return this.cacheGetter("ambientAttachments",S(l1.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 Fq(G,U,this)}]}parseGenericParams(X,U){return k6(new O2(X),[],this.createParseContext({...U,def:X,prefix:"generic"}))}normalizeRootScopeValue(X){if(d0(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=h6(X,U);if(h(Z)){if(Z[1]==="=")return F(b6);if(Z[1]==="?")return F(j6)}return Z}unit=(X)=>this.units([X]);valueOf=(X)=>this.units(jU(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 p9(this);match=new l9(this);declare=()=>({type:this.type});define(X){return X}type=new o9(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 q8 extends U0{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var JY=T0(["base",I.object],["props",I.object])((X)=>X.base.merge(X.props),q8),Z8=f.module({Key:I.key,Merge:JY});class Q8 extends U0{}var HY=T0("element")((X)=>{let U=X.element.exclude(I.Array),q=U.array();return U.rawOr(q).pipe(l0).distribute((Z)=>Z.assertHasKind("morph").declareOut(q),v)},Q8),G8=f.module({root:I.Array,readonly:"root",index:I.nonNegativeIntegerString,liftFrom:HY},{name:"Array"});var r9=v(["string",_1.FileConstructor]),WY=r9.rawOr(r9.array()),Y8=v({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:WY}}),J8=f.module({root:["instanceof",FormData],value:r9,parsed:Y8,parse:v({in:FormData,morphs:(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:Y8})},{name:"FormData"});var H8=f.module({Int8:["instanceof",Int8Array],Uint8:["instanceof",Uint8Array],Uint8Clamped:["instanceof",Uint8ClampedArray],Int16:["instanceof",Int16Array],Uint16:["instanceof",Uint16Array],Int32:["instanceof",Int32Array],Uint32:["instanceof",Uint32Array],Float32:["instanceof",Float32Array],Float64:["instanceof",Float64Array],BigInt64:["instanceof",BigInt64Array],BigUint64:["instanceof",BigUint64Array]},{name:"TypedArray"});var _Y={Boolean:1,Number:1,String:1},W8=f.module({...S({...v4,...x4},(X,U)=>(X in _Y)?[]:[X,["instanceof",U]]),Array:G8,TypedArray:H8,FormData:J8});var $Y=v({domain:{domain:"number",meta:"a number representing a Unix timestamp"},divisor:{rule:1,meta:"an integer representing a Unix timestamp"},min:{rule:-8640000000000000,meta:"a Unix timestamp after -8640000000000000"},max:{rule:8640000000000000,meta:"a Unix timestamp before 8640000000000000"},meta:"an integer representing a safe Unix timestamp"}),LY=v({domain:"number",divisor:1}),u6=f.module({root:I.number,integer:LY,epoch:$Y,safe:v({domain:{domain:"number",numberAllowsNaN:!1},min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}),NaN:["===",Number.NaN],Infinity:["===",Number.POSITIVE_INFINITY],NegativeInfinity:["===",Number.NEGATIVE_INFINITY]},{name:"number"});var l=(X,U,q)=>{let Z={domain:"string",pattern:{rule:X.source,flags:X.flags,meta:U}};if(q)Z.meta={format:q};return u1("intersection",Z)},_8=l(L2,"a well-formed integer string"),M8=f.module({root:_8,parse:v({in:_8,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"}),zY=l(/^[\dA-Fa-f]+$/,"hex characters only"),FY=f.module({root:l(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:l(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),$8=l(/^[A-Z].*$/,"capitalized"),VY=f.module({root:v({in:"string",morphs:(X)=>X.charAt(0).toUpperCase()+X.slice(1),declaredOut:$8}),preformatted:$8},{name:"string.capitalize"}),AY=(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)},OY=/^(?:4\d{12}(?:\d{3,6})?|5[1-5]\d{14}|(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}|6(?:011|5\d\d)\d{12,15}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|(?:2131|1800|35\d{3})\d{11}|6[27]\d{14}|^(81\d{14,17}))$/,TY=v({domain:"string",pattern:{meta:"a credit card number",rule:OY.source},predicate:{meta:"a credit card number",predicate:AY}});var BY=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([,.]\d+(?!:))?)?(\17[0-5]\d([,.]\d+)?)?([Zz]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;var RY=(X)=>!Number.isNaN(new Date(X).valueOf()),L8=v({domain:"string",predicate:{meta:"a parsable date",predicate:RY}}).assertHasKind("intersection"),z8=M8.root.internal.narrow((X,U)=>{let q=Number.parseInt(X),Z=u6.epoch(q);if(Z instanceof W0)return U.errors.merge(Z),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),DY=f.module({root:z8,parse:v({in:z8,morphs:(X)=>new Date(X),declaredOut:I.Date})},{name:"string.date.epoch"}),F8=l(BY,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),MY=f.module({root:F8,parse:v({in:F8,morphs:(X)=>new Date(X),declaredOut:I.Date})},{name:"string.date.iso"}),wY=f.module({root:L8,parse:v({declaredIn:L8,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:MY,epoch:DY},{name:"string.date"}),PY=l(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),V8="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",a0=`(${V8}[.]){3}${V8}`,IY=new RegExp(`^${a0}$`),c="(?:[0-9a-fA-F]{1,4})",KY=new RegExp(`^((?:${c}:){7}(?:${c}|:)|(?:${c}:){6}(?:${a0}|:${c}|:)|(?:${c}:){5}(?::${a0}|(:${c}){1,2}|:)|(?:${c}:){4}(?:(:${c}){0,1}:${a0}|(:${c}){1,3}|:)|(?:${c}:){3}(?:(:${c}){0,2}:${a0}|(:${c}){1,4}|:)|(?:${c}:){2}(?:(:${c}){0,3}:${a0}|(:${c}){1,5}|:)|(?:${c}:){1}(?:(:${c}){0,4}:${a0}|(:${c}){1,6}|:)|(?::((?::${c}){0,5}:${a0}|(?::${c}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),NY=f.module({root:["v4 | v6","@","an IP address"],v4:l(IY,"an IPv4 address","ipv4"),v6:l(KY,"an IPv6 address","ipv6")},{name:"string.ip"}),d1="a JSON string",w8=(X)=>{if(!(X instanceof SyntaxError))throw X;return`must be ${d1} (${X})`},CY=v({meta:d1,domain:"string",predicate:{meta:d1,predicate:(X,U)=>{try{return JSON.parse(X),!0}catch(q){return U.reject({code:"predicate",expected:d1,problem:w8(q)})}}}}),SY=(X,U)=>{if(X.length===0)return U.error({code:"predicate",expected:d1,actual:"empty"});try{return JSON.parse(X)}catch(q){return U.error({code:"predicate",expected:d1,problem:w8(q)})}},EY=f.module({root:CY,parse:v({meta:"safe JSON string parser",in:"string",morphs:SY,declaredOut:I.jsonObject})},{name:"string.json"}),A8=l(/^[a-z]*$/,"only lowercase letters"),jY=f.module({root:v({in:"string",morphs:(X)=>X.toLowerCase(),declaredOut:A8}),preformatted:A8},{name:"string.lower"}),P8=["NFC","NFD","NFKC","NFKD"],k2=S(P8,(X,U)=>[U,v({domain:"string",predicate:(q)=>q.normalize(U)===q,meta:`${U}-normalized unicode`})]),m6=S(P8,(X,U)=>[U,v({in:"string",morphs:(q)=>q.normalize(U),declaredOut:k2[U]})]),bY=f.module({root:m6.NFC,preformatted:k2.NFC},{name:"string.normalize.NFC"}),fY=f.module({root:m6.NFD,preformatted:k2.NFD},{name:"string.normalize.NFD"}),gY=f.module({root:m6.NFKC,preformatted:k2.NFKC},{name:"string.normalize.NFKC"}),yY=f.module({root:m6.NFKD,preformatted:k2.NFKD},{name:"string.normalize.NFKD"}),kY=f.module({root:"NFC",NFC:bY,NFD:fY,NFKC:gY,NFKD:yY},{name:"string.normalize"}),O8=l($6,"a well-formed numeric string"),vY=f.module({root:O8,parse:v({in:O8,morphs:(X)=>Number.parseFloat(X),declaredOut:I.number})},{name:"string.numeric"}),T8="a regex pattern",hY=v({domain:"string",predicate:{meta:T8,predicate:(X,U)=>{try{return new RegExp(X),!0}catch(q){return U.reject({code:"predicate",expected:T8,problem:String(q)})}}},meta:{format:"regex"}}),xY=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/,uY=l(xY,"a semantic version (see https://semver.org/)"),B8=l(/^\S.*\S$|^\S?$/,"trimmed"),mY=f.module({root:v({in:"string",morphs:(X)=>X.trim(),declaredOut:B8}),preformatted:B8},{name:"string.trim"}),R8=l(/^[A-Z]*$/,"only uppercase letters"),pY=f.module({root:v({in:"string",morphs:(X)=>X.toUpperCase(),declaredOut:R8}),preformatted:R8},{name:"string.upper"}),lY=(X)=>URL.canParse(X),D8=v({domain:"string",predicate:{meta:"a URL string",predicate:lY},meta:{format:"uri"}}),dY=f.module({root:D8,parse:v({declaredIn:D8,in:"string",morphs:(X,U)=>{try{return new URL(X)}catch{return U.error("a URL string")}},declaredOut:v(URL)})},{name:"string.url"}),cY=f.module({root:["versioned | nil | max","@",{description:"a UUID",format:"uuid"}],"#nil":"'00000000-0000-0000-0000-000000000000'","#max":"'ffffffff-ffff-ffff-ffff-ffffffffffff'","#versioned":/[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}/i,v1:l(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:l(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:l(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:l(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:l(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:l(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:l(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:l(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),I8=f.module({root:I.string,alpha:l(/^[A-Za-z]*$/,"only letters"),alphanumeric:l(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:zY,base64:FY,capitalize:VY,creditCard:TY,date:wY,digits:l(/^\d*$/,"only digits 0-9"),email:PY,integer:M8,ip:NY,json:EY,lower:jY,normalize:kY,numeric:vY,regex:hY,semver:uY,trim:mY,upper:pY,url:dY,uuid:cY},{name:"string"});var K8=f.module({bigint:I.bigint,boolean:I.boolean,false:I.false,never:I.never,null:I.null,number:I.number,object:I.object,string:I.string,symbol:I.symbol,true:I.true,unknown:I.unknown,undefined:I.undefined}),N8=f.module({root:I.unknown,any:I.unknown},{name:"unknown"}),iY=f.module({root:I.jsonObject,stringify:u1("morph",{in:I.jsonObject,morphs:(X)=>JSON.stringify(X),declaredOut:I.string})},{name:"object.json"}),C8=f.module({root:I.object,json:iY},{name:"object"});class S8 extends U0{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var sY=T0(["K",I.key],"V")((X)=>({domain:"object",index:{signature:X.K,value:X.V}}),S8);class E8 extends U0{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var oY=T0(["T",I.object],["K",I.key])((X)=>X.T.pick(X.K),E8);class j8 extends U0{description='omit a set of properties from an object like `Omit(User, "age")`'}var rY=T0(["T",I.object],["K",I.key])((X)=>X.T.omit(X.K),j8);class b8 extends U0{description="make all named properties of an object optional like `Partial(User)`"}var aY=T0(["T",I.object])((X)=>X.T.partial(),b8);class f8 extends U0{description="make all named properties of an object required like `Required(User)`"}var nY=T0(["T",I.object])((X)=>X.T.required(),f8);class g8 extends U0{description='exclude branches of a union like `Exclude("boolean", "true")`'}var tY=T0("T","U")((X)=>X.T.exclude(X.U),g8);class y8 extends U0{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var eY=T0("T","U")((X)=>X.T.extract(X.U),y8),k8=f.module({Exclude:tY,Extract:eY,Omit:rY,Partial:aY,Pick:oY,Record:sY,Required:nY});var x0=y2({...K8,...k8,...W8,...Z8,string:I8,number:u6,object:C8,unknown:N8},{prereducedAliases:!0,name:"ark"}),n=x0.export();Object.assign(l1.ambient,n);l1.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 a9=Object.assign(x0.type,l1.typeAttachments),XJ=x0.match,UJ=x0.fn,qJ=x0.generic,jN=x0.schema,ZJ=x0.define,QJ=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 | StringOperatorCondition | HasKeyCondition | NullCondition | EmptyCondition | BasicCondition",RangeCondition:{field:"string > 0",operator:"'RANGE'",value:"unknown[] == 2"},ListCondition:{field:"string > 0",operator:"'IN' | 'NOT_IN'",value:"unknown[]"},ContainsCondition:{field:"string > 0",operator:"'CONTAINS' | 'NOT_CONTAINS'",value:"string | unknown[]"},StringOperatorCondition:{field:"string > 0",operator:"'STARTS_WITH' | 'ENDS_WITH'",value:"string"},HasKeyCondition:{field:"string > 0",operator:"'HAS_KEY'",value:"string"},NullCondition:{field:"string > 0",operator:"'IS_NULL' | 'IS_NONE'","value?":"boolean | null"},EmptyCondition:{field:"string > 0",operator:"'IS_EMPTY'","value?":"boolean | null"},NumericCondition:{field:"string > 0",operator:"'>' | '>=' | '<' | '<=' | 'GT' | 'GTE' | 'LT' | 'LTE'",value:"number | string"},RegexCondition:{field:"string > 0",operator:"'MATCHES'",value:"string"},BasicCondition:{field:"string > 0",operator:"Operator",value:"unknown"},ConditionGroup:{operator:"'AND' | 'OR'",conditions:"(Condition | ConditionGroup)[] >= 1"},RuleCondition:"Condition | ConditionGroup",Action:{"type?":"string > 0","params?":"object","delay?":"number.integer >= 0 | string","probability?":"0 <= number <= 1 | string","if?":"RuleCondition | RuleCondition[]","then?":"Action | ActionGroup","else?":"Action | ActionGroup","break?":"boolean","continue?":"boolean"},ActionGroup:{"mode?":"'ALL' | 'EITHER' | 'SEQUENCE'",actions:"(Action | ActionGroup)[] >= 1"},RuleAction:"Action | ActionGroup",TriggerRule:{id:"string > 0","name?":"string","description?":"string","priority?":"number.integer","enabled?":"boolean","cooldown?":"number.integer >= 0","tags?":"string[]",on:"string > 0","if?":"RuleCondition | RuleCondition[]",do:"RuleAction | RuleAction[]","comment?":"string"}}).export(),rN=z1.Operator,aN=z1.Condition,nN=z1.ConditionGroup,tN=z1.RuleCondition,eN=z1.Action,XC=z1.ActionGroup,GJ=z1.TriggerRule;class n9{static validate(X){let U=GJ(X);if(U instanceof a9.errors){let Q=[];for(let G of U){let Y=G.path.join("."),J=G.message,H=void 0;if(Y.endsWith("on")&&(J.includes("string")||J.includes("must be")))if(typeof X==="object"&&X!==null&&"on"in X&&X.on===!0)J="The 'on' field is incorrect (boolean true found).",H=`In YAML, 'on' is a boolean keyword (true). Quote it: "on": "EventName"`;else H="Ensure 'on' is a string event name.";Q.push({path:Y,message:J,suggestion:H,severity:"error"})}return{valid:!1,issues:Q}}let q=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(typeof X==="object"&&X!==null&&"conditions"in X&&Array.isArray(X.conditions)){X.conditions.forEach((Z,Q)=>{this.validateConditionsRecursive(Z,U,`${q}.conditions.${Q}`)});return}if(typeof X==="object"&&X!==null&&"operator"in X&&"value"in X)this.validateConditionValue(X,U,q)}static validateConditionValue(X,U,q){let{operator:Z,value:Q}=X;if(typeof Z==="string"&&["IN","NOT_IN","RANGE","CONTAINS","NOT_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(typeof Z==="string"&&["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"})}else if(typeof Z==="string"&&["STARTS_WITH","ENDS_WITH"].includes(Z)){if(typeof Q!=="string")U.push({path:`${q}.value`,message:`Incorrect value type: Operator '${Z}' expects a string, but received ${typeof Q}.`,severity:"error"})}else if(Z==="HAS_KEY"){if(typeof Q!=="string")U.push({path:`${q}.value`,message:`Incorrect value type: Operator 'HAS_KEY' expects a string (key name), but received ${typeof Q}.`,severity:"error"})}}}class p6{conditions=[];op="AND";constructor(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 p6("AND");return this.conditions.push(X(U).build()),this}or(X){let U=new p6("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 v8{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 YJ{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 p6,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 v8,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 iQ=VU(WU(),1);class YA{static toYaml(X){let U=Array.isArray(X)?X:[X];return iQ.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 sQ,mkdirSync as JA,readFileSync as HA,writeFileSync as WA}from"fs";import{dirname as _A}from"path";class $A{filePath;cache=new Map;isLoaded=!1;constructor(X){this.filePath=X}ensureLoaded(){if(this.isLoaded)return;try{if(sQ(this.filePath)){let X=HA(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=_A(this.filePath);if(!sQ(X))JA(X,{recursive:!0});let U=Object.fromEntries(this.cache);WA(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 q2 from"path";import*as D1 from"fs";var oQ=VU(WU(),1);class LA{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=q2.resolve(Z,G.name);if(G.isDirectory())await q(Y);else if(Y.toLowerCase().endsWith(".yaml")||Y.toLowerCase().endsWith(".yml"))try{let J=await this.loadRule(Y);U.push(...J)}catch(J){console.error(`Failed to load rule from ${Y}:`,J)}}};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=oQ.parseAllDocuments(U);for(let Y of q)if(Y.errors&&Y.errors.length>0)throw Error(`YAML syntax error in ${X}: ${Y.errors.map((J)=>J.message).join(", ")}`);let Z=q.map((Y)=>Y.toJS()),Q=[],G=[];return Z.forEach((Y)=>{if(Array.isArray(Y))G.push(...Y);else G.push(Y)}),G.forEach((Y,J)=>{if(Y&&typeof Y==="object"&&Y!==null&&"actions"in Y&&!Y.do)Y.do=Y.actions;let H=n9.validate(Y);if(H.valid){let W=H.rule;if(!W.id&&typeof Y==="object"&&Y!==null){let $=q2.basename(X,q2.extname(X));W.id=G.length>1?`${$}-${J}`:$}Q.push(W)}else console.error(`
185
- [TriggerLoader] ⚠️ Validation Problem in ${X} (item #${J+1})`),H.issues.forEach((W)=>{if(console.error(` - [${W.path}] ${W.message}`),W.suggestion)console.error(` \uD83D\uDCA1 Suggestion: ${W.suggestion}`)})}),Q}catch(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{N0 as triggerEmitter,H6 as ruleEvents,BA as engineEvents,n9 as TriggerValidator,Q2 as TriggerUtils,GJ as TriggerRuleSchema,LA as TriggerLoader,Y2 as TriggerEngine,f4 as TriggerEmitter,X0 as StateManager,YA as RuleExporter,BU as RuleEvent,g4 as RuleEngine,tN as RuleConditionSchema,YJ as RuleBuilder,b4 as InMemoryPersistence,$A as FilePersistence,e as ExpressionEngine,ZG as EventQueue,J6 as EngineEvent,Y2 as Engine,GG as ContextAdapter,aN as ConditionSchema,nN as ConditionGroupSchema,p6 as ConditionBuilder,rN as ComparisonOperatorSchema,QG as BrowserPersistence,g4 as AdvancedRuleEngine,eN as ActionSchema,I1 as ActionRegistry,XC as ActionGroupSchema,v8 as ActionBuilder};
161
+ `: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(Z[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}uO.createScalarToken=b3.createScalarToken;uO.resolveAsScalar=b3.resolveAsScalar;uO.setScalarValue=b3.setScalarValue;uO.stringify=yO.stringify;uO.visit=gO.visit;uO.BOM=I3;uO.DOCUMENT=f3;uO.FLOW_END=k3;uO.SCALAR=y3;uO.isCollection=vO;uO.isScalar=xO;uO.prettyToken=hO;uO.tokenType=mO});var v3=C((UR)=>{var O4=qZ();function Z1(Z){switch(Z){case void 0:case" ":case`
162
+ `:case"\r":case"\t":return!0;default:return!1}}var FY=new Set("0123456789ABCDEFabcdef"),XR=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),YZ=new Set(",[]{}"),QR=new Set(` ,[]{}
163
+ \r `),g3=(Z)=>!Z||QR.has(Z);class BY{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(Z,X=!1){if(Z){if(typeof Z!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+Z:Z,this.lineEndPos=null}this.atEnd=!X;let Q=this.next??"stream";while(Q&&(X||this.hasChars(1)))Q=yield*this.parseNext(Q)}atLineEnd(){let Z=this.pos,X=this.buffer[Z];while(X===" "||X==="\t")X=this.buffer[++Z];if(!X||X==="#"||X===`
164
+ `)return!0;if(X==="\r")return this.buffer[Z+1]===`
165
+ `;return!1}charAt(Z){return this.buffer[this.pos+Z]}continueScalar(Z){let X=this.buffer[Z];if(this.indentNext>0){let Q=0;while(X===" ")X=this.buffer[++Q+Z];if(X==="\r"){let U=this.buffer[Q+Z+1];if(U===`
166
+ `||!U&&!this.atEnd)return Z+Q+1}return X===`
167
+ `||Q>=this.indentNext||!X&&!this.atEnd?Z+Q:-1}if(X==="-"||X==="."){let Q=this.buffer.substr(Z,3);if((Q==="---"||Q==="...")&&Z1(this.buffer[Z+3]))return-1}return Z}getLine(){let Z=this.lineEndPos;if(typeof Z!=="number"||Z!==-1&&Z<this.pos)Z=this.buffer.indexOf(`
168
+ `,this.pos),this.lineEndPos=Z;if(Z===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[Z-1]==="\r")Z-=1;return this.buffer.substring(this.pos,Z)}hasChars(Z){return this.pos+Z<=this.buffer.length}setNext(Z){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=Z,null}peek(Z){return this.buffer.substr(this.pos,Z)}*parseNext(Z){switch(Z){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 Z=this.getLine();if(Z===null)return this.setNext("stream");if(Z[0]===O4.BOM)yield*this.pushCount(1),Z=Z.substring(1);if(Z[0]==="%"){let X=Z.length,Q=Z.indexOf("#");while(Q!==-1){let J=Z[Q-1];if(J===" "||J==="\t"){X=Q-1;break}else Q=Z.indexOf("#",Q+1)}while(!0){let J=Z[X-1];if(J===" "||J==="\t")X-=1;else break}let U=(yield*this.pushCount(X))+(yield*this.pushSpaces(!0));return yield*this.pushCount(Z.length-U),this.pushNewline(),"stream"}if(this.atLineEnd()){let X=yield*this.pushSpaces(!0);return yield*this.pushCount(Z.length-X),yield*this.pushNewline(),"stream"}return yield O4.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let Z=this.charAt(0);if(!Z&&!this.atEnd)return this.setNext("line-start");if(Z==="-"||Z==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let X=this.peek(3);if((X==="---"||X==="...")&&Z1(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&&!Z1(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[Z,X]=this.peek(2);if(!X&&!this.atEnd)return this.setNext("block-start");if((Z==="-"||Z==="?"||Z===":")&&Z1(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 Z=this.getLine();if(Z===null)return this.setNext("doc");let X=yield*this.pushIndicators();switch(Z[X]){case"#":yield*this.pushCount(Z.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(g3),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return X+=yield*this.parseBlockScalarHeader(),X+=yield*this.pushSpaces(!0),yield*this.pushCount(Z.length-X),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let Z,X,Q=-1;do{if(Z=yield*this.pushNewline(),Z>0)X=yield*this.pushSpaces(!1),this.indentValue=Q=X;else X=0;X+=yield*this.pushSpaces(!0)}while(Z+X>0);let U=this.getLine();if(U===null)return this.setNext("flow");if(Q!==-1&&Q<this.indentNext&&U[0]!=="#"||Q===0&&(U.startsWith("---")||U.startsWith("..."))&&Z1(U[3])){if(!(Q===this.indentNext-1&&this.flowLevel===1&&(U[0]==="]"||U[0]==="}")))return this.flowLevel=0,yield O4.FLOW_END,yield*this.parseLineStart()}let J=0;while(U[J]===",")J+=yield*this.pushCount(1),J+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(J+=yield*this.pushIndicators(),U[J]){case void 0:return"flow";case"#":return yield*this.pushCount(U.length-J),"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(g3),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let q=this.charAt(1);if(this.flowKey||Z1(q)||q===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let Z=this.charAt(0),X=this.buffer.indexOf(Z,this.pos+1);if(Z==="'")while(X!==-1&&this.buffer[X+1]==="'")X=this.buffer.indexOf("'",X+2);else while(X!==-1){let J=0;while(this.buffer[X-1-J]==="\\")J+=1;if(J%2===0)break;X=this.buffer.indexOf('"',X+1)}let Q=this.buffer.substring(0,X),U=Q.indexOf(`
169
+ `,this.pos);if(U!==-1){while(U!==-1){let J=this.continueScalar(U+1);if(J===-1)break;U=Q.indexOf(`
170
+ `,J)}if(U!==-1)X=U-(Q[U-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 Z=this.pos;while(!0){let X=this.buffer[++Z];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)=>Z1(X)||X==="#")}*parseBlockScalar(){let Z=this.pos-1,X=0,Q;Z:for(let J=this.pos;Q=this.buffer[J];++J)switch(Q){case" ":X+=1;break;case`
171
+ `:Z=J,X=0;break;case"\r":{let q=this.buffer[J+1];if(!q&&!this.atEnd)return this.setNext("block-scalar");if(q===`
172
+ `)break}default:break Z}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 J=this.continueScalar(Z+1);if(J===-1)break;Z=this.buffer.indexOf(`
173
+ `,J)}while(Z!==-1);if(Z===-1){if(!this.atEnd)return this.setNext("block-scalar");Z=this.buffer.length}}let U=Z+1;Q=this.buffer[U];while(Q===" ")Q=this.buffer[++U];if(Q==="\t"){while(Q==="\t"||Q===" "||Q==="\r"||Q===`
174
+ `)Q=this.buffer[++U];Z=U-1}else if(!this.blockScalarKeep)do{let J=Z-1,q=this.buffer[J];if(q==="\r")q=this.buffer[--J];let Y=J;while(q===" ")q=this.buffer[--J];if(q===`
175
+ `&&J>=this.pos&&J+1+X>Y)Z=J;else break}while(!0);return yield O4.SCALAR,yield*this.pushToIndex(Z+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let Z=this.flowLevel>0,X=this.pos-1,Q=this.pos-1,U;while(U=this.buffer[++Q])if(U===":"){let J=this.buffer[Q+1];if(Z1(J)||Z&&YZ.has(J))break;X=Q}else if(Z1(U)){let J=this.buffer[Q+1];if(U==="\r")if(J===`
176
+ `)Q+=1,U=`
177
+ `,J=this.buffer[Q+1];else X=Q;if(J==="#"||Z&&YZ.has(J))break;if(U===`
178
+ `){let q=this.continueScalar(Q+1);if(q===-1)break;Q=Math.max(Q,q-2)}}else{if(Z&&YZ.has(U))break;X=Q}if(!U&&!this.atEnd)return this.setNext("plain-scalar");return yield O4.SCALAR,yield*this.pushToIndex(X+1,!0),Z?"flow":"doc"}*pushCount(Z){if(Z>0)return yield this.buffer.substr(this.pos,Z),this.pos+=Z,Z;return 0}*pushToIndex(Z,X){let Q=this.buffer.slice(this.pos,Z);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(g3))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let Z=this.flowLevel>0,X=this.charAt(1);if(Z1(X)||Z&&YZ.has(X)){if(!Z)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 Z=this.pos+2,X=this.buffer[Z];while(!Z1(X)&&X!==">")X=this.buffer[++Z];return yield*this.pushToIndex(X===">"?Z+1:Z,!1)}else{let Z=this.pos+1,X=this.buffer[Z];while(X)if(XR.has(X))X=this.buffer[++Z];else if(X==="%"&&FY.has(this.buffer[Z+1])&&FY.has(this.buffer[Z+2]))X=this.buffer[Z+=3];else break;return yield*this.pushToIndex(Z,!1)}}*pushNewline(){let Z=this.buffer[this.pos];if(Z===`
179
+ `)return yield*this.pushCount(1);else if(Z==="\r"&&this.charAt(1)===`
180
+ `)return yield*this.pushCount(2);else return 0}*pushSpaces(Z){let X=this.pos-1,Q;do Q=this.buffer[++X];while(Q===" "||Z&&Q==="\t");let U=X-this.pos;if(U>0)yield this.buffer.substr(this.pos,U),this.pos=X;return U}*pushUntil(Z){let X=this.pos,Q=this.buffer[X];while(!Z(Q))Q=this.buffer[++X];return yield*this.pushToIndex(X,!1)}}UR.Lexer=BY});var x3=C((qR)=>{class MY{constructor(){this.lineStarts=[],this.addNewLine=(Z)=>this.lineStarts.push(Z),this.linePos=(Z)=>{let X=0,Q=this.lineStarts.length;while(X<Q){let J=X+Q>>1;if(this.lineStarts[J]<Z)X=J+1;else Q=J}if(this.lineStarts[X]===Z)return{line:X+1,col:1};if(X===0)return{line:0,col:Z};let U=this.lineStarts[X-1];return{line:X,col:Z-U+1}}}}qR.LineCounter=MY});var h3=C((LR)=>{var WR=z2("process"),OY=qZ(),$R=v3();function c1(Z,X){for(let Q=0;Q<Z.length;++Q)if(Z[Q].type===X)return!0;return!1}function RY(Z){for(let X=0;X<Z.length;++X)switch(Z[X].type){case"space":case"comment":case"newline":break;default:return X}return-1}function TY(Z){switch(Z?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function WZ(Z){switch(Z.type){case"document":return Z.start;case"block-map":{let X=Z.items[Z.items.length-1];return X.sep??X.start}case"block-seq":return Z.items[Z.items.length-1].start;default:return[]}}function Z6(Z){if(Z.length===0)return[];let X=Z.length;Z:while(--X>=0)switch(Z[X].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break Z}while(Z[++X]?.type==="space");return Z.splice(X,Z.length)}function KY(Z){if(Z.start.type==="flow-seq-start"){for(let X of Z.items)if(X.sep&&!X.value&&!c1(X.start,"explicit-key-ind")&&!c1(X.sep,"map-value-ind")){if(X.key)X.value=X.key;if(delete X.key,TY(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 DY{constructor(Z){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new $R.Lexer,this.onNewLine=Z}*parse(Z,X=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let Q of this.lexer.lex(Z,X))yield*this.next(Q);if(!X)yield*this.end()}*next(Z){if(this.source=Z,WR.env.LOG_TOKENS)console.log("|",OY.prettyToken(Z));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=Z.length;return}let X=OY.tokenType(Z);if(!X){let Q=`Not a YAML token: ${Z}`;yield*this.pop({type:"error",offset:this.offset,message:Q,source:Z}),this.offset+=Z.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+Z.length);break;case"space":if(this.atNewLine&&Z[0]===" ")this.indent+=Z.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=Z.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=Z.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 Z=this.peek(1);if(this.type==="doc-end"&&Z?.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(!Z)return yield*this.stream();switch(Z.type){case"document":return yield*this.document(Z);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(Z);case"block-scalar":return yield*this.blockScalar(Z);case"block-map":return yield*this.blockMap(Z);case"block-seq":return yield*this.blockSequence(Z);case"flow-collection":return yield*this.flowCollection(Z);case"doc-end":return yield*this.documentEnd(Z)}yield*this.pop()}peek(Z){return this.stack[this.stack.length-Z]}*pop(Z){let X=Z??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")KY(X);switch(Q.type){case"document":Q.value=X;break;case"block-scalar":Q.props.push(X);break;case"block-map":{let U=Q.items[Q.items.length-1];if(U.value){Q.items.push({start:[],key:X,sep:[]}),this.onKeyLine=!0;return}else if(U.sep)U.value=X;else{Object.assign(U,{key:X,sep:[]}),this.onKeyLine=!U.explicitKey;return}break}case"block-seq":{let U=Q.items[Q.items.length-1];if(U.value)Q.items.push({start:[],value:X});else U.value=X;break}case"flow-collection":{let U=Q.items[Q.items.length-1];if(!U||U.value)Q.items.push({start:[],key:X,sep:[]});else if(U.sep)U.value=X;else Object.assign(U,{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 U=X.items[X.items.length-1];if(U&&!U.sep&&!U.value&&U.start.length>0&&RY(U.start)===-1&&(X.indent===0||U.start.every((J)=>J.type!=="comment"||J.indent<X.indent))){if(Q.type==="document")Q.end=U.start;else Q.items.push({start:U.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 Z={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")Z.start.push(this.sourceToken);this.stack.push(Z);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(Z){if(Z.value)return yield*this.lineEnd(Z);switch(this.type){case"doc-start":{if(RY(Z.start)!==-1)yield*this.pop(),yield*this.step();else Z.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":Z.start.push(this.sourceToken);return}let X=this.startBlockValue(Z);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(Z){if(this.type==="map-value-ind"){let X=WZ(this.peek(2)),Q=Z6(X),U;if(Z.end)U=Z.end,U.push(this.sourceToken),delete Z.end;else U=[this.sourceToken];let J={type:"block-map",offset:Z.offset,indent:Z.indent,items:[{start:Q,key:Z,sep:U}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=J}else yield*this.lineEnd(Z)}*blockScalar(Z){switch(this.type){case"space":case"comment":case"newline":Z.props.push(this.sourceToken);return;case"scalar":if(Z.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let X=this.source.indexOf(`
181
+ `)+1;while(X!==0)this.onNewLine(this.offset+X),X=this.source.indexOf(`
182
+ `,X)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(Z){let X=Z.items[Z.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 Z.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)Z.items.push({start:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else{if(this.atIndentedComment(X.start,Z.indent)){let U=Z.items[Z.items.length-2]?.value?.end;if(Array.isArray(U)){Array.prototype.push.apply(U,X.start),U.push(this.sourceToken),Z.items.pop();return}}X.start.push(this.sourceToken)}return}if(this.indent>=Z.indent){let Q=!this.onKeyLine&&this.indent===Z.indent,U=Q&&(X.sep||X.explicitKey)&&this.type!=="seq-item-ind",J=[];if(U&&X.sep&&!X.value){let q=[];for(let Y=0;Y<X.sep.length;++Y){let W=X.sep[Y];switch(W.type){case"newline":q.push(Y);break;case"space":break;case"comment":if(W.indent>Z.indent)q.length=0;break;default:q.length=0}}if(q.length>=2)J=X.sep.splice(q[1])}switch(this.type){case"anchor":case"tag":if(U||X.value)J.push(this.sourceToken),Z.items.push({start:J}),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(U||X.value)J.push(this.sourceToken),Z.items.push({start:J,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(c1(X.start,"newline"))Object.assign(X,{key:null,sep:[this.sourceToken]});else{let q=Z6(X.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]})}else if(X.value)Z.items.push({start:[],key:null,sep:[this.sourceToken]});else if(c1(X.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:J,key:null,sep:[this.sourceToken]}]});else if(TY(X.key)&&!c1(X.sep,"newline")){let q=Z6(X.start),Y=X.key,W=X.sep;W.push(this.sourceToken),delete X.key,delete X.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:Y,sep:W}]})}else if(J.length>0)X.sep=X.sep.concat(J,this.sourceToken);else X.sep.push(this.sourceToken);else if(!X.sep)Object.assign(X,{key:null,sep:[this.sourceToken]});else if(X.value||U)Z.items.push({start:J,key:null,sep:[this.sourceToken]});else if(c1(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 q=this.flowScalar(this.type);if(U||X.value)Z.items.push({start:J,key:q,sep:[]}),this.onKeyLine=!0;else if(X.sep)this.stack.push(q);else Object.assign(X,{key:q,sep:[]}),this.onKeyLine=!0;return}default:{let q=this.startBlockValue(Z);if(q){if(q.type==="block-seq"){if(!X.explicitKey&&X.sep&&!c1(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)Z.items.push({start:J});this.stack.push(q);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(Z){let X=Z.items[Z.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 Z.items.push({start:[this.sourceToken]})}else X.start.push(this.sourceToken);return;case"space":case"comment":if(X.value)Z.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(X.start,Z.indent)){let U=Z.items[Z.items.length-2]?.value?.end;if(Array.isArray(U)){Array.prototype.push.apply(U,X.start),U.push(this.sourceToken),Z.items.pop();return}}X.start.push(this.sourceToken)}return;case"anchor":case"tag":if(X.value||this.indent<=Z.indent)break;X.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==Z.indent)break;if(X.value||c1(X.start,"seq-item-ind"))Z.items.push({start:[this.sourceToken]});else X.start.push(this.sourceToken);return}if(this.indent>Z.indent){let Q=this.startBlockValue(Z);if(Q){this.stack.push(Q);return}}yield*this.pop(),yield*this.step()}*flowCollection(Z){let X=Z.items[Z.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(Z.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!X||X.sep)Z.items.push({start:[this.sourceToken]});else X.start.push(this.sourceToken);return;case"map-value-ind":if(!X||X.value)Z.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)Z.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 U=this.flowScalar(this.type);if(!X||X.value)Z.items.push({start:[],key:U,sep:[]});else if(X.sep)this.stack.push(U);else Object.assign(X,{key:U,sep:[]});return}case"flow-map-end":case"flow-seq-end":Z.end.push(this.sourceToken);return}let Q=this.startBlockValue(Z);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===Z.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 U=WZ(Q),J=Z6(U);KY(Z);let q=Z.end.splice(1,Z.end.length);q.push(this.sourceToken);let Y={type:"block-map",offset:Z.offset,indent:Z.indent,items:[{start:J,key:Z,sep:q}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=Y}else yield*this.lineEnd(Z)}}flowScalar(Z){if(this.onNewLine){let X=this.source.indexOf(`
183
+ `)+1;while(X!==0)this.onNewLine(this.offset+X),X=this.source.indexOf(`
184
+ `,X)+1}return{type:Z,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(Z){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=WZ(Z),Q=Z6(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=WZ(Z),Q=Z6(X);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Q,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(Z,X){if(this.type!=="comment")return!1;if(this.indent<=X)return!1;return Z.every((Q)=>Q.type==="newline"||Q.type==="space")}*documentEnd(Z){if(this.type!=="doc-mode"){if(Z.end)Z.end.push(this.sourceToken);else Z.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(Z){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(Z.end)Z.end.push(this.sourceToken);else Z.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}LR.Parser=DY});var CY=C((OR)=>{var wY=N3(),_R=H4(),R4=z4(),VR=xX(),HR=l(),zR=x3(),PY=h3();function AY(Z){let X=Z.prettyErrors!==!1;return{lineCounter:Z.lineCounter||X&&new zR.LineCounter||null,prettyErrors:X}}function FR(Z,X={}){let{lineCounter:Q,prettyErrors:U}=AY(X),J=new PY.Parser(Q?.addNewLine),q=new wY.Composer(X),Y=Array.from(q.compose(J.parse(Z)));if(U&&Q)for(let W of Y)W.errors.forEach(R4.prettifyError(Z,Q)),W.warnings.forEach(R4.prettifyError(Z,Q));if(Y.length>0)return Y;return Object.assign([],{empty:!0},q.streamInfo())}function SY(Z,X={}){let{lineCounter:Q,prettyErrors:U}=AY(X),J=new PY.Parser(Q?.addNewLine),q=new wY.Composer(X),Y=null;for(let W of q.compose(J.parse(Z),!0,Z.length))if(!Y)Y=W;else if(Y.options.logLevel!=="silent"){Y.errors.push(new R4.YAMLParseError(W.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(U&&Q)Y.errors.forEach(R4.prettifyError(Z,Q)),Y.warnings.forEach(R4.prettifyError(Z,Q));return Y}function BR(Z,X,Q){let U=void 0;if(typeof X==="function")U=X;else if(Q===void 0&&X&&typeof X==="object")Q=X;let J=SY(Z,Q);if(!J)return null;if(J.warnings.forEach((q)=>VR.warn(J.options.logLevel,q)),J.errors.length>0)if(J.options.logLevel!=="silent")throw J.errors[0];else J.errors=[];return J.toJS(Object.assign({reviver:U},Q))}function MR(Z,X,Q){let U=null;if(typeof X==="function"||Array.isArray(X))U=X;else if(Q===void 0&&X)Q=X;if(typeof Q==="string")Q=Q.length;if(typeof Q==="number"){let J=Math.round(Q);Q=J<1?void 0:J>8?{indent:8}:{indent:J}}if(Z===void 0){let{keepUndefined:J}=Q??X??{};if(!J)return}if(HR.isDocument(Z)&&!U)return Z.toString(Q);return new _R.Document(Z,U,Q).toString(Q)}OR.parse=BR;OR.parseAllDocuments=FR;OR.parseDocument=SY;OR.stringify=MR});var u3=C((yR)=>{var wR=N3(),PR=H4(),AR=V3(),m3=z4(),SR=t6(),i1=l(),CR=u1(),NR=W0(),jR=l1(),ER=d1(),bR=qZ(),IR=v3(),fR=x3(),kR=h3(),$Z=CY(),NY=o6();yR.Composer=wR.Composer;yR.Document=PR.Document;yR.Schema=AR.Schema;yR.YAMLError=m3.YAMLError;yR.YAMLParseError=m3.YAMLParseError;yR.YAMLWarning=m3.YAMLWarning;yR.Alias=SR.Alias;yR.isAlias=i1.isAlias;yR.isCollection=i1.isCollection;yR.isDocument=i1.isDocument;yR.isMap=i1.isMap;yR.isNode=i1.isNode;yR.isPair=i1.isPair;yR.isScalar=i1.isScalar;yR.isSeq=i1.isSeq;yR.Pair=CR.Pair;yR.Scalar=NR.Scalar;yR.YAMLMap=jR.YAMLMap;yR.YAMLSeq=ER.YAMLSeq;yR.CST=bR;yR.Lexer=IR.Lexer;yR.LineCounter=fR.LineCounter;yR.Parser=kR.Parser;yR.parse=$Z.parse;yR.parseAllDocuments=$Z.parseAllDocuments;yR.parseDocument=$Z.parseDocument;yR.stringify=$Z.stringify;yR.visit=NY.visit;yR.visitAsync=NY.visitAsync});m2();var u2;((q)=>{q.ENGINE_START="engine:start";q.ENGINE_DONE="engine:done";q.RULE_MATCH="rule:match";q.ACTION_SUCCESS="action:success";q.ACTION_ERROR="action:error"})(u2||={});var H9;((U)=>{U.RULE_ADDED="rule:added";U.RULE_REMOVED="rule:removed";U.RULE_UPDATED="rule:updated"})(H9||={});var yb=u2,z9=H9;class BX{static instance;handlers=new Map;constructor(){}static getInstance(){if(!this.instance)this.instance=new BX;return this.instance}on(Z,X){let Q=Z;if(!this.handlers.has(Q))this.handlers.set(Q,new Set);return this.handlers.get(Q).add(X),()=>this.off(Q,X)}off(Z,X){let Q=Z,U=this.handlers.get(Q);if(U)U.delete(X)}emit(Z,X){let Q=Z,U=this.handlers.get(Q);if(U)U.forEach((J)=>{try{J(X)}catch(q){console.error(`Error in event handler for ${Q}:`,q)}})}}var l0=BX.getInstance();var eG=K0,Z_=u2,X_=H9,MX={IF:"if",THEN:"then",ELSE:"else",BREAK:"break",CONTINUE:"continue",MODE:"mode",ACTIONS:"actions",RUN:"run",DELAY:"delay",PROBABILITY:"probability",PARAMS:"params",TYPE:"type",ON:"on"},OX={UNKNOWN_ACTION:"Unknown or generic action type",MISSING_ACTION_TYPE:"Action has no type and no control flow properties",PROBABILITY_FAILED:"probability check failed",BUN_REQUIRED:"Bun is required for 'execute' action",MISSING_KEY:"Missing key for state operation"},F9={RULE_ENGINE_EVALUATING:(Z,X)=>`[RuleEngine] Evaluating context with ${Z} rules for event: ${X}`,TRIGGER_ENGINE_EVALUATING:(Z,X)=>`[TriggerEngine] Evaluating context with ${Z} rules for event: ${X}`},hb={Actions:eG,Events:Z_,RuleEvents:X_,ControlFlow:MX,ErrorMessages:OX,DebugMessages:F9};V9();class Q_{queue=[];engine;config;timer=null;isProcessing=!1;constructor(Z,X={maxBatchSize:10,flushIntervalMs:100}){this.engine=Z,this.config=X}push(Z){if(this.queue.push(Z),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 Z=this.queue.splice(0,this.config.maxBatchSize);if(Z.length===0){this.isProcessing=!1;return}console.debug(`[EventQueue] Processing batch of ${Z.length} events.`);for(let X of Z)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 U_{keyPrefix;cache=new Map;isLoaded=!1;pendingWrite=null;writeDelay;dirty=!1;constructor(Z="trigger_system:",X){this.keyPrefix=Z,this.writeDelay=X?.writeDelay??0}flush(){this.dirty=!0,this.persist()}getCache(){return this.ensureLoaded(),new Map(this.cache)}isDirty(){return this.dirty}isAvailable(){return typeof window<"u"&&typeof window.localStorage<"u"}ensureLoaded(){if(this.isLoaded)return;if(this.isAvailable())try{let Z=window.localStorage.getItem(this.keyPrefix+"state");if(Z){let X=JSON.parse(Z);this.cache=new Map(Object.entries(X))}}catch(Z){console.error("[BrowserPersistence] Failed to load from localStorage:",Z)}this.isLoaded=!0}schedulePersist(){if(this.writeDelay<=0){this.persist();return}if(this.pendingWrite)clearTimeout(this.pendingWrite);this.dirty=!0,this.pendingWrite=setTimeout(()=>{this.persist(),this.pendingWrite=null},this.writeDelay)}persist(){if(this.pendingWrite)clearTimeout(this.pendingWrite),this.pendingWrite=null;if(this.isAvailable())try{let Z=Object.fromEntries(this.cache);window.localStorage.setItem(this.keyPrefix+"state",JSON.stringify(Z)),this.dirty=!1}catch(Z){console.error("[BrowserPersistence] Failed to save to localStorage:",Z)}}async loadState(){return this.ensureLoaded(),new Map(this.cache)}async saveState(Z,X){this.ensureLoaded(),this.cache.set(Z,X),this.schedulePersist()}async deleteState(Z){this.ensureLoaded(),this.cache.delete(Z),this.schedulePersist()}async clearState(){this.cache.clear(),this.schedulePersist()}}class RX{static getNestedValue(Z,X){let Q=Z.split("."),U=X;for(let J of Q){if(U===null||U===void 0)return;if(typeof U==="object"&&U!==null&&J in U)U=U[J];else return}return U}static interpolate(Z,X){if(typeof Z!=="string")return Z;return Z.replace(/\$\{([^}]+)\}/g,(Q,U)=>{let J=this.getNestedValue(U,X);if(J!==void 0)return String(J);return Q})}static compare(Z,X,Q){let U=(q)=>{if(q instanceof Date)return q.getTime();if(typeof q==="number")return q;if(typeof q==="string"){let Y=new Date(q);return isNaN(Y.getTime())?0:Y.getTime()}return 0},J=(q)=>{if(typeof q==="number")return q;if(q===null||q===void 0||q==="")return null;let Y=Number(q);return isNaN(Y)?null:Y};switch(X){case"EQ":case"==":return Z==Q;case"NEQ":case"!=":return Z!=Q;case"GT":case">":{let q=J(Z),Y=J(Q);return q!==null&&Y!==null&&q>Y}case"GTE":case">=":{let q=J(Z),Y=J(Q);return q!==null&&Y!==null&&q>=Y}case"LT":case"<":{let q=J(Z),Y=J(Q);return q!==null&&Y!==null&&q<Y}case"LTE":case"<=":{let q=J(Z),Y=J(Q);return q!==null&&Y!==null&&q<=Y}case"IN":return Array.isArray(Q)&&Q.some((q)=>q===Z);case"NOT_IN":return Array.isArray(Q)&&!Q.some((q)=>q===Z);case"CONTAINS":if(Array.isArray(Q))return Q.some((q)=>String(Z).includes(String(q)));if(Array.isArray(Z)||typeof Z==="string")return Z.includes(Q);return!1;case"NOT_CONTAINS":if(Array.isArray(Q))return!Q.some((q)=>String(Z).includes(String(q)));if(Array.isArray(Z)||typeof Z==="string")return!Z.includes(Q);return!1;case"STARTS_WITH":if(Array.isArray(Q))return Q.some((q)=>String(Z).startsWith(String(q)));if(typeof Z==="string"&&typeof Q==="string")return Z.startsWith(Q);return!1;case"ENDS_WITH":if(Array.isArray(Q))return Q.some((q)=>String(Z).endsWith(String(q)));if(typeof Z==="string"&&typeof Q==="string")return Z.endsWith(Q);return!1;case"IS_EMPTY":{let q=!1;if(typeof Z==="string")q=Z==="";else if(Array.isArray(Z))q=Z.length===0;else if(Z===null||Z===void 0)q=!0;else if(typeof Z==="object")q=Object.keys(Z).length===0;return Q===!1?!q:q}case"IS_NULL":case"IS_NONE":{let q=Z===null||Z===void 0;return Q===!1?!q:q}case"HAS_KEY":if(typeof Z==="object"&&Z!==null&&typeof Q==="string")return Q in Z;return!1;case"MATCHES":if(typeof Q==="string")return new RegExp(Q).test(String(Z));return!1;case"RANGE":if(Array.isArray(Q)&&Q.length===2){let q=J(Z),Y=J(Q[0]),W=J(Q[1]);return q!==null&&Y!==null&&W!==null&&q>=Y&&q<=W}return!1;case"SINCE":case"AFTER":return U(Z)>=U(Q);case"BEFORE":case"UNTIL":return U(Z)<U(Q);default:return console.warn(`Unknown operator: ${X}`),!1}}}V9();class y1{static evaluateConditions(Z,X){if(!Z)return!0;if(Array.isArray(Z))return Z.every((Q)=>this.evaluateRecursiveCondition(Q,X));return this.evaluateRecursiveCondition(Z,X)}static evaluateRecursiveCondition(Z,X){if("conditions"in Z&&"operator"in Z){let U=Z;if(U.operator==="OR")return U.conditions.some((J)=>this.evaluateRecursiveCondition(J,X));else return U.conditions.every((J)=>this.evaluateRecursiveCondition(J,X))}let Q=Z;try{let U=E0.evaluate(Q.field,X),J=Q.value;if(typeof J==="string"&&J.includes("${"))J=E0.interpolate(J,X);return RX.compare(U,Q.operator,J)}catch(U){return console.error("Error evaluating condition:",Q,U),!1}}static async processSingleActionBase(Z,X,Q){let U={...Z};if(!U.type&&!U.run&&!U.break&&!U.continue){let Y=Object.values(MX),W=Object.keys(U).filter(($)=>!Y.includes($));for(let $ of W)if(Q?!!Q.get($):!0){U.type=$;let _=U[$];if(typeof _==="string")U.params={...U.params,message:_,content:_};else if(typeof _==="object"&&_!==null)U.params={...U.params,..._};break}}if(U.run)try{return{shouldExecute:!1,executedAction:{type:"RUN",result:Function("context","state","data","vars","env","helpers",`with(context) { ${U.run} }`)(X,X.state,X.data,X.vars,X.env,X.helpers),timestamp:Date.now()},normalizedAction:U}}catch(Y){return{shouldExecute:!1,executedAction:{type:"RUN",error:String(Y),timestamp:Date.now()},normalizedAction:U}}if(U.break)return{shouldExecute:!1,executedAction:{type:"BREAK",result:"Break execution",timestamp:Date.now()},normalizedAction:U};if(U.continue)return{shouldExecute:!1,executedAction:{type:"CONTINUE",result:"Continue execution",timestamp:Date.now()},normalizedAction:U};let J=U.probability;if(typeof J==="string"){let Y=E0.evaluate(J,X);J=typeof Y==="number"?Y:Number(Y)}if(J!==void 0&&Math.random()>J)return{shouldExecute:!1,executedAction:{type:U.type||"skipped",result:{skipped:"probability check failed"},timestamp:Date.now()},normalizedAction:U};let q=U.delay;if(typeof q==="string"){let Y=E0.evaluate(q,X);q=typeof Y==="number"?Y:Number(Y)}if(q&&q>0)await new Promise((Y)=>setTimeout(Y,q));return U.params=this.interpolateParams(U.params||{},X),{shouldExecute:!0,normalizedAction:U}}static selectActions(Z){let X=[],Q="ALL";if(Array.isArray(Z))X=Z;else if(Z&&typeof Z==="object"&&"mode"in Z&&"actions"in Z){let U=Z;Q=U.mode,X=U.actions}else X=[Z];if(Q==="EITHER"&&X.length>0){let U=(W)=>("probability"in W)?W.probability:1,J=X.reduce((W,$)=>W+U($),0),q=Math.random()*J;for(let W of X){let $=U(W);if(q-=$,q<=0)return{actionsToExecute:[W],mode:Q}}let Y=X[X.length-1];return{actionsToExecute:Y?[Y]:[],mode:Q}}return{actionsToExecute:X,mode:Q}}static interpolateParams(Z,X){let Q={};for(let[U,J]of Object.entries(Z))Q[U]=this.interpolateDeep(J,X);return Q}static interpolateDeep(Z,X){if(typeof Z==="string"&&Z.includes("${"))return E0.interpolate(Z,X);if(Array.isArray(Z))return Z.map((Q)=>this.interpolateDeep(Q,X));if(typeof Z==="object"&&Z!==null){let Q={};for(let[U,J]of Object.entries(Z))Q[U]=this.interpolateDeep(J,X);return Q}return Z}}class c6{_rules=[];actionHandlers=new Map;lastExecution=new Map;_config;constructor(Z=[]){if(Array.isArray(Z))this._rules=Z;else this._config=Z,this._rules=[...Z.rules];try{let{ActionRegistry:X}=(m2(),JQ(FX));X.getInstance(!0)}catch{}this.sortRules()}sortRules(){this._rules.sort((Z,X)=>(X.priority||0)-(Z.priority||0))}registerAction(Z,X){this.actionHandlers.set(Z,X)}async processEvent(Z){let X=[];if(!Z.state)Z.state=this.getStateContext?this.getStateContext():{};let Q=this._rules.filter((U)=>U.enabled!==!1&&U.on===Z.event);for(let U of Q){if(U.cooldown&&this.checkCooldown(U.id,U.cooldown))continue;let J=y1.evaluateConditions(U.if,Z),q;if(J)l0.emit("rule:match",{rule:U,context:Z}),q=U.do;else if(U.else)q=U.else;if(q){let Y=await this.executeRuleActions(q,Z);this.lastExecution.set(U.id,Date.now()),X.push({ruleId:U.id,success:!0,executedActions:Y})}if(!J&&!U.else&&!this.shouldEvaluateAll())break;if(J&&!this.shouldEvaluateAll())break}return X}async processEventSimple(Z,X={},Q={}){let U={event:Z,data:X,vars:Q,timestamp:Date.now(),state:this.getStateContext?this.getStateContext():{}};return this.processEvent(U)}updateRules(Z){let X=this.getRules(),Q=new Set(X.map((Y)=>Y.id)),U=new Set(Z.map((Y)=>Y.id)),J=Z.filter((Y)=>!Q.has(Y.id)),q=X.filter((Y)=>!U.has(Y.id));this._rules=[...Z],this.sortRules(),J.forEach((Y)=>{this.emitRuleEvent(z9.RULE_ADDED,{ruleId:Y.id,timestamp:Date.now()})}),q.forEach((Y)=>{this.emitRuleEvent(z9.RULE_REMOVED,{ruleId:Y.id,timestamp:Date.now()})}),this.emitRuleEvent(z9.RULE_UPDATED,{count:Z.length,added:J.length,removed:q.length,unchanged:Z.length-J.length,timestamp:Date.now()})}emitRuleEvent(Z,X){try{if(l0)l0.emit(Z,{...X,timestamp:Date.now()})}catch(Q){console.warn(`Could not emit event ${Z}:`,Q)}}getRules(){return[...this._rules]}checkCooldown(Z,X){let Q=this.lastExecution.get(Z);if(!Q)return!1;return Date.now()-Q<X}shouldEvaluateAll(){return this._config?.globalSettings?.evaluateAll??!0}getStateContext(){return{}}evaluateConditions(Z,X){return y1.evaluateConditions(Z,X)}evaluateSingleCondition(Z,X){return y1.evaluateConditions(Z,X)}async executeRuleActions(Z,X){let{actionsToExecute:Q}=y1.selectActions(Z),U=[];for(let J of Q){if("actions"in J&&"mode"in J){U.push(...await this.executeRuleActions(J,X));continue}let q=J;if("if"in q&&q.if&&(q.then||q.else||q.do)){let W=this.evaluateConditions(q.if,X),$=q.then||q.do;if(W&&$)U.push(...await this.executeRuleActions($,X));else if(!W&&q.else)U.push(...await this.executeRuleActions(q.else,X));continue}if("if"in q&&q.if){if(!this.evaluateConditions(q.if,X))continue}let Y=await this.executeSingleAction(q,X);if(U.push(Y),Y.type==="BREAK")break}return U}async executeSingleAction(Z,X){let{shouldExecute:Q,executedAction:U,normalizedAction:J}=await y1.processSingleActionBase(Z,X);if(!Q)return U;try{let q=this.actionHandlers.get(J.type);if(q){let W=await q(J.params||{},X);return l0.emit("action:success",{action:J,context:X,result:W}),{type:J.type,result:W,timestamp:Date.now()}}try{let{ActionRegistry:W}=(m2(),JQ(FX)),$=W.getInstance().get(J.type);if($){let L=await $(J,X);return l0.emit("action:success",{action:J,context:X,result:L}),{type:J.type,result:L,timestamp:Date.now()}}}catch{}let Y=`${OX.UNKNOWN_ACTION}: ${J.type}`;if(this._config?.globalSettings?.strictActions)throw Error(Y);return console.warn(Y),{type:J.type,result:{warning:Y},timestamp:Date.now()}}catch(q){return console.error(`Error executing action ${J.type}:`,q),l0.emit("action:error",{action:J,context:X,error:String(q)}),{type:J.type,error:String(q),timestamp:Date.now()}}}interpolateParams(Z,X){return y1.interpolateParams(Z,X)}get rules(){return[...this._rules]}get config(){return this._config}set rules(Z){this._rules=[...Z],this.sortRules()}}m2();l6();class WJ extends c6{actionRegistry;stateManager;constructor(Z){super(Z);this.actionRegistry=d6.getInstance(!0),this.stateManager=F0.getInstance()}async evaluateContext(Z){if(!Z.state)Z.state=this.stateManager.getLiveProxy();if(this._config?.stateConfig)await this.stateManager.applyConfig(this._config.stateConfig);if(!Z.env)Z.env={};if(this._config?.globalSettings?.debugMode)console.log(F9.RULE_ENGINE_EVALUATING(this._rules.length,Z.event));l0.emit("engine:start",{context:Z,rulesCount:this._rules.length});let X=await this.processEvent(Z);return l0.emit("engine:done",{results:X,context:Z}),X}async processEvent(Z,X={},Q={}){if(typeof Z==="string"){let q={event:Z,data:X,vars:Q,timestamp:Date.now(),state:this.stateManager.getLiveProxy()};return this.processEvent(q)}let U=Z;if(U.state=this.stateManager.getLiveProxy(),this._config?.stateConfig)await this.stateManager.applyConfig(this._config.stateConfig);if(l0.emit("engine:start",{context:U,rulesCount:this._rules.length}),this._config?.globalSettings?.debugMode)console.log(F9.RULE_ENGINE_EVALUATING(this._rules.length,U.event));let J=await super.processEvent(U);return l0.emit("engine:done",{results:J,context:U}),J}getStateContext(){return this.stateManager.getLiveProxy()}get ActionRegistry(){return this.actionRegistry}get StateManager(){return this.stateManager}}m2();l6();class J_{static create(Z,X,Q={}){return{event:Z,timestamp:Date.now(),data:typeof X==="object"&&X!==null?X:{value:X},vars:Q,state:F0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static fromRequest(Z,X,Q={}){let U=new URL(Z.url);return{event:"HTTP_REQUEST",timestamp:Date.now(),data:{method:Z.method,path:U.pathname,query:Object.fromEntries(U.searchParams),headers:(()=>{let J={};return Z.headers.forEach((q,Y)=>J[Y]=q),J})(),body:X||{}},vars:{...Q,ip:Z.headers.get("x-forwarded-for")||"unknown"},state:F0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static fromWebhook(Z,X,Q,U={}){return{event:`WEBHOOK_${Z.toUpperCase()}_${X.toUpperCase()}`,timestamp:Date.now(),data:Q,vars:{...U,provider:Z},state:F0.getInstance().getLiveProxy(),helpers:this.getDefaultHelpers()}}static getDefaultHelpers(){return{now:()=>Date.now(),uuid:()=>crypto.randomUUID(),jsonParse:(Z)=>{try{return typeof Z==="string"?JSON.parse(Z):null}catch{return null}},jsonStringify:(Z)=>{try{return JSON.stringify(Z)}catch{return null}}}}}l6();HX();var q_=["EQ","==","NEQ","!="],$J=["GT",">","GTE",">=","LT","<","LTE","<="],LJ=["IN","NOT_IN","RANGE"],GJ=["CONTAINS","NOT_CONTAINS","STARTS_WITH","ENDS_WITH"],Y_=["IS_NULL","IS_NONE"],W_=["IS_EMPTY","HAS_KEY","MATCHES","SINCE","AFTER","BEFORE","UNTIL"],RI=[...q_,...$J,...LJ,...GJ,...Y_,...W_];function _J(Z){return LJ.includes(Z)}function VJ(Z){return GJ.includes(Z)}function HJ(Z){return $J.includes(Z)}var g1=u6({Operator:"'EQ' | '==' | 'NEQ' | '!=' | 'GT' | '>' | 'GTE' | '>=' | 'LT' | '<' | 'LTE' | '<=' | 'IN' | 'NOT_IN' | 'CONTAINS' | 'NOT_CONTAINS' | 'STARTS_WITH' | 'ENDS_WITH' | 'MATCHES' | 'RANGE' | 'SINCE' | 'AFTER' | 'BEFORE' | 'UNTIL'",Condition:"RangeCondition | ListCondition | ContainsCondition | NumericCondition | RegexCondition | StringOperatorCondition | HasKeyCondition | NullCondition | EmptyCondition | BasicCondition",RangeCondition:{field:"string > 0",operator:"'RANGE'",value:"unknown[] == 2"},ListCondition:{field:"string > 0",operator:"'IN' | 'NOT_IN'",value:"unknown[]"},ContainsCondition:{field:"string > 0",operator:"'CONTAINS' | 'NOT_CONTAINS'",value:"string | unknown[]"},StringOperatorCondition:{field:"string > 0",operator:"'STARTS_WITH' | 'ENDS_WITH'",value:"string"},HasKeyCondition:{field:"string > 0",operator:"'HAS_KEY'",value:"string"},NullCondition:{field:"string > 0",operator:"'IS_NULL' | 'IS_NONE'","value?":"boolean | null"},EmptyCondition:{field:"string > 0",operator:"'IS_EMPTY'","value?":"boolean | null"},NumericCondition:{field:"string > 0",operator:"'>' | '>=' | '<' | '<=' | 'GT' | 'GTE' | 'LT' | 'LTE'",value:"number | string"},RegexCondition:{field:"string > 0",operator:"'MATCHES'",value:"string"},BasicCondition:{field:"string > 0",operator:"Operator",value:"unknown"},ConditionGroup:{operator:"'AND' | 'OR'",conditions:"(Condition | ConditionGroup)[] >= 1"},RuleCondition:"Condition | ConditionGroup",Action:{"type?":"string > 0","params?":"object","delay?":"number.integer >= 0 | string","probability?":"0 <= number <= 1 | string","if?":"RuleCondition | RuleCondition[]","then?":"Action | ActionGroup","else?":"Action | ActionGroup","break?":"boolean","continue?":"boolean"},ActionGroup:{"mode?":"'ALL' | 'EITHER' | 'SEQUENCE'",actions:"(Action | ActionGroup)[] >= 1"},RuleAction:"Action | ActionGroup",InlineConditionalAction:{if:"RuleCondition | RuleCondition[]","then?":"Action | ActionGroup","do?":"Action | ActionGroup","else?":"Action | ActionGroup","break?":"boolean","continue?":"boolean"},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[] | InlineConditionalAction","else?":"RuleAction | RuleAction[]","comment?":"string"}}).export(),SI=g1.Operator,CI=g1.Condition,NI=g1.ConditionGroup,jI=g1.RuleCondition,EI=g1.Action,bI=g1.ActionGroup,II=g1.InlineConditionalAction,$_=g1.TriggerRule;class KX{static validate(Z){let X=$_(Z);if(X instanceof i.errors){let J=[];for(let q of X){let Y=q.path.join("."),W=q.message,$=void 0;if(Y.endsWith("on")&&(W.includes("string")||W.includes("must be")))if(typeof Z==="object"&&Z!==null&&"on"in Z&&Z.on===!0)W="The 'on' field is incorrect (boolean true found).",$=`In YAML, 'on' is a boolean keyword (true). Quote it: "on": "EventName"`;else $="Ensure 'on' is a string event name.";J.push({path:Y,message:W,suggestion:$,severity:"error"})}return{valid:!1,issues:J}}let Q=X,U=[];if(this.validateConditionsRecursive(Q.if,U,"if"),this.validateInlineConditionalRecursive(Q.do,U,"do"),Q.else)this.validateInlineConditionalRecursive(Q.else,U,"else");if(U.length>0)return{valid:!1,issues:U};return{valid:!0,rule:Q}}static validateInlineConditionalRecursive(Z,X,Q){if(!Z)return;if(Array.isArray(Z)){Z.forEach((U,J)=>{this.validateInlineConditionalRecursive(U,X,`${Q}.${J}`)});return}if(typeof Z==="object"&&Z!==null&&"mode"in Z&&"actions"in Z){let U=Z;if(Array.isArray(U.actions))U.actions.forEach((J,q)=>{this.validateInlineConditionalRecursive(J,X,`${Q}.actions.${q}`)});return}if(typeof Z==="object"&&Z!==null&&"if"in Z){let U=Z;if(this.validateConditionsRecursive(U.if,X,`${Q}.if`),U.then)this.validateInlineConditionalRecursive(U.then,X,`${Q}.then`);if(U.do)this.validateInlineConditionalRecursive(U.do,X,`${Q}.do`);if(U.else)this.validateInlineConditionalRecursive(U.else,X,`${Q}.else`);return}}static validateConditionsRecursive(Z,X,Q){if(!Z)return;if(Array.isArray(Z)){Z.forEach((U,J)=>{this.validateConditionsRecursive(U,X,`${Q}.${J}`)});return}if(typeof Z==="object"&&Z!==null&&"conditions"in Z&&Array.isArray(Z.conditions)){Z.conditions.forEach((U,J)=>{this.validateConditionsRecursive(U,X,`${Q}.conditions.${J}`)});return}if(typeof Z==="object"&&Z!==null&&"operator"in Z&&"value"in Z)this.validateConditionValue(Z,X,Q)}static validateConditionValue(Z,X,Q){let{operator:U,value:J}=Z,q=U;if(_J(q)){if(!Array.isArray(J)){X.push({path:`${Q}.value`,message:`Incorrect value type: Operator '${q}' expects a List (Array), but received ${typeof J}.`,suggestion:q==="RANGE"?"Use format [min, max]":"Use format [item1, item2]",severity:"error"});return}if(q==="RANGE"){if(J.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 J[0]!=="number"&&typeof J[0]!=="string")X.push({path:`${Q}.value`,message:"Incorrect range type: Range values must be numbers or expression strings.",severity:"error"})}}else if(q==="CONTAINS"||q==="NOT_CONTAINS"){if(typeof J!=="string"&&!Array.isArray(J))X.push({path:`${Q}.value`,message:`Incorrect value type: Operator 'CONTAINS' expects a String or List (Array), but received ${typeof J}.`,suggestion:"Use a substring or a list of items.",severity:"error"})}else if(VJ(q)){if(typeof J!=="string"&&!Array.isArray(J))X.push({path:`${Q}.value`,message:`Incorrect value type: Operator '${q}' expects a String or List (Array), but received ${typeof J}.`,suggestion:"Use a string prefix/suffix or a list of prefixes/suffixes.",severity:"error"})}else if(q==="MATCHES")if(typeof J!=="string")X.push({path:`${Q}.value`,message:`Incorrect value type: Operator 'MATCHES' expects a string (regex pattern), but received ${typeof J}.`,severity:"error"});else try{new RegExp(J)}catch(Y){X.push({path:`${Q}.value`,message:`Invalid Regex pattern: ${Y.message}`,severity:"error"})}else if(HJ(q)){if(typeof J!=="number"&&typeof J!=="string")X.push({path:`${Q}.value`,message:`Incorrect value type: Operator '${q}' expects a number or expression string, but received ${typeof J}.`,severity:"error"})}else if(q==="HAS_KEY"){if(typeof J!=="string")X.push({path:`${Q}.value`,message:`Incorrect value type: Operator 'HAS_KEY' expects a string (key name), but received ${typeof J}.`,severity:"error"})}}}function B9(Z,X){let Q=new Map,U=[];for(let q of Z){let W=q[X];if(W!==void 0&&W!==null){let $=String(W);if(!Q.has($))Q.set($,q)}else U.push(q)}let J=Array.from(new Set(U.map((q)=>JSON.stringify(q)))).map((q)=>JSON.parse(q));return[...Array.from(Q.values()),...J]}function i6(Z,X={}){let{deduplicate:Q=!0,uniqueIdField:U}=X;if(!Z)return;if(Array.isArray(Z)){let J=Z.map((Y)=>i6(Y,X)).filter((Y)=>Y!==void 0);if(!Q)return J.length===0?void 0:J.length===1?J[0]:J;let q=U?B9(J,U):Array.from(new Set(J.map((Y)=>JSON.stringify(Y)))).map((Y)=>JSON.parse(Y));return q.length===0?void 0:q.length===1?q[0]:q}if("operator"in Z&&"conditions"in Z){let J=Z,q=i6(J.conditions,X);if(!q)return;if(!Array.isArray(q))q=[q];let Y=[];for(let $ of q)if("operator"in $&&"conditions"in $&&$.operator===J.operator)Y.push(...$.conditions);else Y.push($);let W;if(!Q)W=Y;else if(U)W=B9(Y,U);else W=Array.from(new Set(Y.map(($)=>JSON.stringify($)))).map(($)=>JSON.parse($));if(W.length===0)return;if(W.length===1)return W[0];return{operator:J.operator,conditions:W}}return Z}function s6(Z,X={}){let{deduplicate:Q=!1,uniqueIdField:U}=X;if(!Z)return;if(Array.isArray(Z)){let J=Z.map(($)=>s6($,X)).filter(($)=>$!==void 0);if(!Q){let $=J.flatMap((_)=>Array.isArray(_)?_:[_]),L=[];for(let _ of $)if("mode"in _&&"actions"in _&&_.mode==="ALL")L.push(..._.actions);else L.push(_);if(L.length===0)return;if(L.length===1)return L[0];return L}let q=J.flatMap(($)=>Array.isArray($)?$:[$]),Y=[];for(let $ of q)if("mode"in $&&"actions"in $&&$.mode==="ALL")Y.push(...$.actions);else Y.push($);if(Y.length===0)return;if(Y.length===1)return Y[0];let W;if(U)W=B9(Y,U);else W=Array.from(new Set(Y.map(($)=>JSON.stringify($)))).map(($)=>JSON.parse($));return W}if("mode"in Z&&"actions"in Z){let J=Z,q=s6(J.actions,X);if(!q)return;if(!Array.isArray(q))q=[q];let Y=[];for(let $ of q)if("mode"in $&&"actions"in $&&$.mode===J.mode)Y.push(...$.actions);else Y.push($);if(Y.length===0)return;if(Y.length===1)return Y[0];let W;if(!Q)W=Y;else if(U)W=B9(Y,U);else W=Array.from(new Set(Y.map(($)=>JSON.stringify($)))).map(($)=>JSON.parse($));return{mode:J.mode,actions:W}}return Z}class v1{conditions=[];op="AND";constructor(Z="AND"){this.op=Z}where(Z,X,Q){return this.conditions.push({field:Z,operator:X,value:Q}),this}and(Z){let X=new v1("AND");return this.conditions.push(Z(X).build()),this}or(Z){let X=new v1("OR");return this.conditions.push(Z(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 a6{actions=[];mode="ALL";setMode(Z){return this.mode=Z,this}add(Z,X,Q){return this.actions.push({type:Z,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 TX{params={};set(Z,X){return this.params[Z]=X,this}setAll(Z){return Object.assign(this.params,Z),this}setNested(Z,X){let Q=Z.split("."),U=this.params;for(let q=0;q<Q.length-1;q++){let Y=Q[q];if(!Y)continue;if(!(Y in U))U[Y]={};U=U[Y]}let J=Q[Q.length-1];if(J)U[J]=X;return this}addItem(Z,X){if(!(Z in this.params)||!Array.isArray(this.params[Z]))this.params[Z]=[];return this.params[Z].push(X),this}remove(Z){return delete this.params[Z],this}has(Z){return Z in this.params}get(Z){return this.params[Z]}build(){return{...this.params}}getRaw(){return this.params}}var f={EVENT:"event",CONDITION:"condition",CONDITION_GROUP:"condition_group",ACTION:"action",ACTION_GROUP:"action_group",DO:"do"},P={EVENT_OUTPUT:"event-output",CONDITION_INPUT:"condition-input",CONDITION_OUTPUT:"output",CONDITION_OUTPUT_LEGACY:"condition-output",THEN_OUTPUT:"then-output",ELSE_OUTPUT:"else-output",CONDITION_GROUP_INPUT:"input",CONDITION_GROUP_OUTPUT:"cond-output",ACTION_INPUT:"action-input",ACTION_OUTPUT:"action-output",ACTION_OUTPUT_LEGACY:"action-group-output",ACTION_GROUP_INPUT:"input",ACTION_GROUP_OUTPUT:"action-output",ACTION_GROUP_CONDITION_OUTPUT:"condition-output",DO_INPUT:"do-input",DO_OUTPUT:"do-output",DO_CONDITION_OUTPUT:"do-condition-output"},k0={DO:"do",ELSE:"else"},DX={AND:"AND",OR:"OR"};var O9=(Z)=>Z.type===f.EVENT,T1=(Z)=>Z.type===f.CONDITION||Z.type===f.CONDITION_GROUP,W1=(Z)=>Z.type===f.ACTION||Z.type===f.ACTION_GROUP||Z.type===f.DO,R9=(Z)=>Z.type===f.DO;var p2=(Z)=>{return Z.data?.branchType===k0.ELSE?k0.ELSE:k0.DO};function wX(Z){let X=Z.data||{};return{id:X.id,on:X.event,name:X.name,description:X.description,priority:X.priority!==void 0?Number(X.priority):void 0,enabled:X.enabled!==void 0?!!X.enabled:void 0,cooldown:X.cooldown!==void 0?Number(X.cooldown):void 0,tags:X.tags}}function X0(Z,X,Q){let U=[...Q];return Z.edges.filter((J)=>J.source===X&&U.includes(J.sourceHandle||""))}var t0={CONDITION_OUTPUT:[P.CONDITION_OUTPUT,P.CONDITION_OUTPUT_LEGACY],ACTION_OUTPUT:[P.ACTION_OUTPUT,P.ACTION_OUTPUT_LEGACY],DO_OUTPUT:[P.DO_OUTPUT,""],THEN_ELSE:[P.THEN_OUTPUT,P.ELSE_OUTPUT],DO_CONDITION:[P.DO_CONDITION_OUTPUT],CONDITION_CHAIN:[P.CONDITION_OUTPUT,P.CONDITION_OUTPUT_LEGACY,P.THEN_OUTPUT,P.ELSE_OUTPUT],ANY:[P.CONDITION_OUTPUT,P.CONDITION_OUTPUT_LEGACY,""]};class zJ{convert(Z,X){return{field:Z.field||"data",operator:Z.operator||"EQ",value:Z.value!==void 0?Z.value:""}}validate(Z){let X=[];if(!Z.field&&!Z.value)X.push("Condition must have at least a field or value");return{valid:X.length===0,errors:X.length>0?X:void 0}}}class FJ{convert(Z,X){let Q={};try{if(Z.params)Q=typeof Z.params==="string"?JSON.parse(Z.params):Z.params}catch{Q={}}let U={type:Z.type||"log",params:Q};if(Z.delay!==void 0)U.delay=Number(Z.delay);if(Z.probability!==void 0)U.probability=Number(Z.probability);return U}validate(Z){let X=[];if(!Z.type)X.push('Action type defaults to "log"');return{valid:!0,warnings:X.length>0?X:void 0}}}class BJ{convert(Z,X){return{id:Z.id,on:Z.event,name:Z.name,description:Z.description,priority:Z.priority!==void 0?Number(Z.priority):void 0,enabled:Z.enabled!==void 0?!!Z.enabled:void 0,cooldown:Z.cooldown!==void 0?Number(Z.cooldown):void 0,tags:Z.tags}}validate(Z){let X=[],Q=[];if(!Z.id)X.push("Event must have an ID");if(!Z.event)X.push("Event must have an event name");if(!Z.name)Q.push("Event should have a name");return{valid:X.length===0,errors:X.length>0?X:void 0,warnings:Q.length>0?Q:void 0}}}class MJ{conditionConverter=new zJ;actionConverter=new FJ;eventConverter=new BJ;getConditionConverter(){return this.conditionConverter}getActionConverter(){return this.actionConverter}getEventConverter(){return this.eventConverter}createContext(Z,X,Q,U){return{nodes:Z,edges:X,currentNode:Q,options:U}}}var OJ=new MJ;function PX(Z){let X=Z.data||{};return OJ.getConditionConverter().convert(X,{nodes:[],edges:[]})}function AX(Z){let X=Z.data||{};return OJ.getActionConverter().convert(X,{nodes:[],edges:[]})}function K9(Z,X){let Q=X.options.isCondNode||T1,U=X.nodes.find((L)=>L.id===Z);if(!U||U.type!==f.CONDITION_GROUP)return{conditions:[],operator:DX.AND};let J=U.data.operator||DX.AND,q=[],Y=new Set;function W(L){if(Y.has(L))return;Y.add(L);let _=X.nodes.find((z)=>z.id===L);if(!_||!Q(_)||_.type===f.CONDITION_GROUP)return;let G=PX(_);q.push(G);let V=X0(X,L,[...t0.CONDITION_OUTPUT,P.THEN_OUTPUT]).filter((z)=>{let F=X.nodes.find((H)=>H.id===z.target);return F&&Q(F)});for(let z of V)W(z.target)}let $=X0(X,Z,[P.CONDITION_GROUP_OUTPUT]).filter((L)=>{let _=X.nodes.find((G)=>G.id===L.target);return _&&Q(_)});for(let L of $)W(L.target);return{conditions:q,operator:J}}function q2(Z,X){if(X.options.resolveCondition&&X.options.resolveCondition!==q2)return X.options.resolveCondition(Z,X);if(X.visitedConds.has(Z))return null;X.visitedConds.add(Z);let Q=X.nodes.find((Y)=>Y.id===Z),U=X.options.isCondNode||T1;if(!Q||!U(Q))return null;if(Q.type===f.CONDITION_GROUP){let{conditions:Y,operator:W}=K9(Z,X);if(Y.length===0)return null;if(Y.length===1)return Y[0];return{operator:W,conditions:Y}}let J=PX(Q);if(X.transformers?.condition){let Y=X.transformers.condition(J,Q);if(Y===null)return null;return Y}let q=X0(X,Z,t0.CONDITION_OUTPUT).filter((Y)=>{let W=X.nodes.find(($)=>$.id===Y.target);return W&&U(W)});if(q.length>0){let Y=q.map((W)=>q2(W.target,X)).filter((W)=>W!==null);if(Y.length>0)return{operator:"AND",conditions:[J,...Y]}}return J}function SX(Z,X){let Q=X.options.isCondNode||T1,U,J;function q(Y){let W=X.nodes.find((_)=>_.id===Y);if(!W||!Q(W))return;let $=X.edges.filter((_)=>_.source===Y);for(let _ of $){let G=X.nodes.find((V)=>V.id===_.target);if(!G)continue;if(G.type===f.ACTION||G.type===f.ACTION_GROUP||G.type===f.DO)if(_.sourceHandle===P.ELSE_OUTPUT)J=_.target;else U=_.target}let L=X0(X,Y,t0.CONDITION_OUTPUT).filter((_)=>{let G=X.nodes.find((V)=>V.id===_.target);return G&&Q(G)});for(let _ of L)q(_.target)}return q(Z),{thenActionId:U,elseActionId:J}}function l2(Z,X){let Q=X.options.isActNode||W1,U=X.nodes.find((_)=>_.id===Z);if(!U||U.type!==f.ACTION_GROUP)return{actions:[],mode:"ALL"};let J=U.data.mode||"ALL",q=[],Y=new Set;function W(_){if(Y.has(_))return;Y.add(_);let G=X.nodes.find((F)=>F.id===_);if(!G||!Q(G)||G.type===f.ACTION_GROUP)return;let V=AX(G);q.push(V);let z=X0(X,_,t0.ACTION_OUTPUT).filter((F)=>{let H=X.nodes.find((B)=>B.id===F.target);return H&&Q(H)});for(let F of z)W(F.target)}let $=X0(X,Z,[P.ACTION_GROUP_OUTPUT,P.DO_OUTPUT,"do-output","action-output","action-group-output"]).filter((_)=>{let G=X.nodes.find((V)=>V.id===_.target);return G&&Q(G)});for(let _ of $)W(_.target);let L=X0(X,Z,[P.ACTION_GROUP_CONDITION_OUTPUT,"condition-output"]);for(let _ of L){let G=B0(_.target,X);if(G)q.push(G)}return{actions:q,mode:J}}function B0(Z,X){if(X.options.resolveAction&&X.options.resolveAction!==B0)return X.options.resolveAction(Z,X);let Q=X.nodes.find((q)=>q.id===Z);if(!Q)return null;if(Q.type===f.ACTION_GROUP){if(X.visitedActs?.has(Z))return null;X.visitedActs?.add(Z);let{actions:q,mode:Y}=l2(Z,X);if(q.length===0)return null;return{mode:Y,actions:q}}if(Q.type===f.CONDITION){if(X.options.resolveCondition){let q=X.options.resolveCondition(Z,X);if(q){let{doBranches:Y,elseBranches:W}=r6(Z,X),$=null,L=null;if(Y.length>0){let _=Y[0],G=RJ(_,X);if(G.length>0)$=G.length===1?G[0]:{mode:"ALL",actions:G}}if(W.length>0){let _=W[0],G=RJ(_,X);if(G.length>0)L=G.length===1?G[0]:{mode:"ALL",actions:G}}if(!$&&!L){let _=SX(Z,X);if(_.thenActionId)$=B0(_.thenActionId,X);if(_.elseActionId)L=B0(_.elseActionId,X)}if($||L)return{if:q,then:$??void 0,do:$??void 0,else:L??void 0}}}}if(!(X.options.isActNode||W1)(Q))return null;if(X.visitedActs?.has(Z))return null;X.visitedActs?.add(Z);let J=AX(Q);if(X.transformers?.action){let q=X.transformers.action(J,Q);if(q===null)return null;return q}return J}function RJ(Z,X){let Q=X.options.isActNode||W1,U=[],J=X0(X,Z,[P.DO_OUTPUT,P.ELSE_OUTPUT,"do-output","else-output","action-output",""]).filter((q)=>{let Y=X.nodes.find((W)=>W.id===q.target);return Y&&Q(Y)});for(let q of J){let Y=B0(q.target,X);if(Y)U.push(Y)}return U}function r6(Z,X){let Q=X.options.isActNode?($)=>$.type===f.CONDITION||$.type===f.CONDITION_GROUP:($)=>$.type===f.CONDITION||$.type===f.CONDITION_GROUP,U=($)=>$.type===f.DO,J=[],q=[],Y=new Set;function W($){if(Y.has($))return;Y.add($);let L=X0(X,$,[...t0.CONDITION_OUTPUT,P.THEN_OUTPUT]).filter((G)=>{let V=X.nodes.find((z)=>z.id===G.target);return V&&U(V)});for(let G of L){let V=X.nodes.find((F)=>F.id===G.target);if(!V)continue;if(p2(V)===k0.ELSE){if(!q.includes(G.target))q.push(G.target)}else if(!J.includes(G.target))J.push(G.target)}let _=X0(X,$,t0.CONDITION_OUTPUT).filter((G)=>{let V=X.nodes.find((z)=>z.id===G.target);return V&&Q(V)});for(let G of _)W(G.target)}return W(Z),{doBranches:J,elseBranches:q}}function L_(Z,X,Q={},U){let J={...Q,resolveCondition:Q.resolveCondition||q2,resolveAction:Q.resolveAction||B0};return{nodes:Z,edges:X,visitedConds:new Set,visitedActs:new Set,options:J,transformers:U}}var Nf=p2,G_=wX;function __(Z,X,Q){let U=X.options.isCondNode||T1,J=R9,q=X0(X,Z,[P.DO_CONDITION_OUTPUT]).find((F)=>{let H=X.nodes.find((B)=>B.id===F.target);return H&&U(H)}),Y;if(q)Y=q.target;if(!Y)return null;let W=new Set(X.visitedConds);X.visitedConds.clear();let $=q2(Y,X);if(X.visitedConds=W,!$)return null;let{thenActionId:L,elseActionId:_}=CX(Y,X),G=X0(X,Z,[P.DO_CONDITION_OUTPUT]).find((F)=>{let H=X.nodes.find((B)=>B.id===F.target);return H&&(X.options.isActNode?.(H)??W1(H))});if(G&&!_)_=G.target;let V=L?B0(L,X):void 0,z=_?B0(_,X):void 0;return{if:$,do:V??void 0,else:z??void 0}}function T9(Z,X,Q){let U=X.options.isActNode||W1,J=[],q=X0(X,Z,t0.DO_OUTPUT).filter((W)=>{let $=X.nodes.find((L)=>L.id===W.target);return $&&U($)});for(let W of q){let $=B0(W.target,X);if($)J.push($)}let Y=__(Z,X,Q);if(Y)J.push(Y);return J}function CX(Z,X){let Q=X.options.isCondNode||T1,U=X.options.isActNode||W1,J=R9,q,Y;function W($){let L=X.nodes.find((V)=>V.id===$);if(!L||!Q(L))return;let _=X0(X,$,[P.THEN_OUTPUT,P.ELSE_OUTPUT,P.CONDITION_OUTPUT,P.CONDITION_OUTPUT_LEGACY,P.DO_OUTPUT,""]);for(let V of _){let z=X.nodes.find((F)=>F.id===V.target);if(!z)continue;if(J(z)){let F=X0(X,z.id,[P.DO_OUTPUT,""]).filter((K)=>{let w=X.nodes.find((S)=>S.id===K.target);return w&&U(w)}),H=p2(z);for(let K of F)if(H===k0.ELSE)Y=K.target;else q=K.target;let B=X0(X,z.id,[P.DO_CONDITION_OUTPUT]),T=B.find((K)=>{let w=X.nodes.find((S)=>S.id===K.target);return w&&Q(w)}),D=B.find((K)=>{let w=X.nodes.find((S)=>S.id===K.target);return w&&U(w)});if(D&&!Y)Y=D.target;continue}if(z.type===f.ACTION_GROUP){q=V.target;continue}if(!U(z))continue;if(V.sourceHandle===P.ELSE_OUTPUT)Y=V.target;else q=V.target}let G=X0(X,$,t0.CONDITION_OUTPUT).filter((V)=>{let z=X.nodes.find((F)=>F.id===V.target);return z&&Q(z)});for(let V of G)W(V.target)}return W(Z),{thenActionId:q,elseActionId:Y}}function NX(Z,X,Q={},U){let J=new jX;if(Q.optimizeOptions)J.withOptimizeOptions(Q.optimizeOptions);let q=Q.isEventNode||O9,Y=Q.isCondNode||T1,W=Q.isActNode||W1,$=Q.extractEventData||G_,L=Z.find((K)=>q(K));if(!L)throw Error("Missing Event Trigger node");let _=$(L);if(!_.id||!_.on)throw Error("Rule ID and Event Name are required");if(J.id(_.id).on(_.on),_.name)J.name(_.name);if(_.description)J.description(_.description);if(_.priority!==void 0)J.priority(Number(_.priority));if(_.enabled!==void 0)J.enabled(!!_.enabled);if(_.cooldown!==void 0)J.cooldown(Number(_.cooldown));if(_.tags)J.tags(_.tags);let G=L_(Z,X,Q,U),V=X.filter((K)=>K.source===L.id),z=[],F=[],H=[],B=[];for(let K of V){let w=G.nodes.find((S)=>S.id===K.target);if(!w)continue;if(w.type===f.CONDITION_GROUP)z.push(K.target);else if(Y(w))F.push(K.target);else if(w.type===f.ACTION_GROUP)H.push(K.target);else if(W(w))B.push(K.target)}for(let K of z){let{conditions:w,operator:S}=K9(K,G);if(w.length>0){let j={operator:S,conditions:w};J.withIf(j);let v=G.edges.filter((s)=>s.source===K&&s.sourceHandle?.startsWith("cond")).map((s)=>s.target),N=null,x=null;for(let s of v){let Q0=CX(s,G),a=Q0.thenActionId?B0(Q0.thenActionId,G):null,V0=Q0.elseActionId?B0(Q0.elseActionId,G):null,{doBranches:D0,elseBranches:y0}=r6(s,G),_1=[];for(let $6 of D0){let HZ=T9($6,G,s);_1.push(...HZ)}if(_1.length>0)a=_1.length===1?_1[0]:{mode:"ALL",actions:_1};let V1=[];for(let $6 of y0){let HZ=T9($6,G,s);V1.push(...HZ)}if(V1.length>0)V0=V1.length===1?V1[0]:{mode:"ALL",actions:V1};if(a)N=a;if(V0)x=V0}if(N)J.withDo(N);if(x)J.elseRule(x)}}if(F.length>0&&z.length===0){let K=[],w,S;for(let V0 of F){let D0=q2(V0,G);if(D0)K.push(D0);let y0=CX(V0,G);if(y0.thenActionId)w=y0.thenActionId;if(y0.elseActionId)S=y0.elseActionId}if(K.length===1)J.withIf(K[0]);else if(K.length>1)J.withIf({operator:"AND",conditions:K});let j=F[0];if(!j)return J;let{doBranches:v,elseBranches:N}=r6(j,G),x=[];for(let V0 of v){let D0=T9(V0,G,j);x.push(...D0)}let s=x.length===1?x[0]:x.length>1?{mode:"ALL",actions:x}:w?B0(w,G):null,Q0=[];for(let V0 of N){let D0=T9(V0,G,j);Q0.push(...D0)}let a=Q0.length===1?Q0[0]:Q0.length>1?{mode:"ALL",actions:Q0}:S?B0(S,G):null;if(s)J.withDo(s);if(a)J.elseRule(a);if(!w&&!x.length)for(let V0 of F){let D0=X0(G,V0,[P.THEN_OUTPUT,P.CONDITION_OUTPUT,"condition-output","then-output","output",""]).filter((y0)=>{return G.nodes.find((V1)=>V1.id===y0.target)?.type===f.ACTION_GROUP});for(let y0 of D0){let{actions:_1,mode:V1}=l2(y0.target,G);if(_1.length>0){let $6={mode:V1,actions:_1};J.withDo($6);break}}}}let T=new Set;if(F.length>0&&z.length===0)for(let K of F){let w=X0(G,K,[P.THEN_OUTPUT,P.CONDITION_OUTPUT,"condition-output","then-output","output",""]).filter((S)=>{return G.nodes.find((v)=>v.id===S.target)?.type===f.ACTION_GROUP});for(let S of w)T.add(S.target)}let D=H.filter((K)=>!T.has(K));if(D.length>0)for(let K of D)if(X0(G,K,[P.ACTION_GROUP_CONDITION_OUTPUT,"condition-output"]).filter((S)=>{let j=G.nodes.find((v)=>v.id===S.target);return j&&Y(j)}).length>0){let{actions:S,mode:j}=l2(K,G);if(S.length>0){let v={mode:j,actions:S};J.withDo(v)}}else{let{actions:S,mode:j}=l2(K,G);if(S.length>0)J.withDo({mode:j,actions:S})}if(B.length>0&&F.length===0&&z.length===0)for(let K of B){let w=B0(K,G);if(w)J.withDo(w)}return J}function KJ(Z,X,Q={},U){let J=Q.isEventNode||O9,q=Z.filter(($)=>J($));if(q.length===0)return{rules:[],errors:["No Event nodes found in the graph"]};let Y=[],W=[];for(let $ of q)try{let L=$.id,_=new Set([L]),G=[L];while(G.length>0){let B=G.shift(),T=X.filter((D)=>D.source===B);for(let D of T)if(!_.has(D.target))_.add(D.target),G.push(D.target)}let V=Z.filter((B)=>_.has(B.id)),z=X.filter((B)=>_.has(B.source)&&_.has(B.target)),H=NX(V,z,Q,U).build();Y.push(H)}catch(L){let _=L instanceof Error?L.message:String(L);W.push(`Failed to parse rule for event ${$.id}: ${_}`)}return{rules:Y,errors:W}}class jX{rule={enabled:!0,priority:0};optimizeOptions={};static fromGraph(Z,X,Q,U){return NX(Z,X,Q,U)}static fromGraphMultiple(Z,X,Q,U){return KJ(Z,X,Q,U)}withId(Z){return this.rule.id=Z,this}withName(Z){return this.rule.name=Z,this}withDescription(Z){return this.rule.description=Z,this}withPriority(Z){return this.rule.priority=Z,this}withCooldown(Z){return this.rule.cooldown=Z,this}withTags(Z){return this.rule.tags=Z,this}withEnabled(Z){return this.rule.enabled=Z,this}withOptimizeOptions(Z){return this.optimizeOptions=Z,this}id(Z){return this.withId(Z)}name(Z){return this.withName(Z)}description(Z){return this.withDescription(Z)}priority(Z){return this.withPriority(Z)}enabled(Z){return this.withEnabled(Z)}cooldown(Z){return this.withCooldown(Z)}tags(Z){return this.withTags(Z)}optimize(Z){return this.withOptimizeOptions(Z)}on(Z){return this.rule.on=Z,this}if(Z,X,Q){if(!this.rule.if)this.rule.if={field:Z,operator:X,value:Q};else if(Array.isArray(this.rule.if))this.rule.if.push({field:Z,operator:X,value:Q});else this.rule.if=[this.rule.if,{field:Z,operator:X,value:Q}];return this}ifComplex(Z){let X=new v1,Q=Z(X).build();return this.rule.if=Q,this}withIf(Z){return this.rule.if=Z,this}do(Z,X,Q){let U={type:Z,params:X,...Q};if(!this.rule.do)this.rule.do=U;else if(Array.isArray(this.rule.do))this.rule.do.push(U);else if(this.rule.do&&typeof this.rule.do==="object"&&"actions"in this.rule.do)this.rule.do.actions.push(U);else this.rule.do=[this.rule.do,U];return this}doComplex(Z){let X=new a6,Q=Z(X).build();return this.rule.do=Q,this}withDo(Z){return this.rule.do=Z,this}elseRule(Z){return this.rule.else=Z,this}when(Z,X,Q){return new M9(this,Z,X,Q)}whenComplex(Z){let X=new v1,Q=Z(X).build();return new M9(this,Q)}then(Z,X,Q){return this.do(Z,X,Q)}ifAction(Z,X,Q){let U=this.rule.do;if(!U)throw Error("Cannot add condition: no action defined. Use do() or then() first.");let J=(q)=>({...q,if:{field:Z,operator:X,value:Q}});if(Array.isArray(U)){let q=U.length-1,Y=U[q];if(Y&&"actions"in Y){let W=Y.actions,$=W.length-1;if($>=0)W[$]=J(W[$])}else if(Y)U[q]=J(Y)}else if(U&&"actions"in U){let q=U.actions,Y=q.length-1;if(Y>=0)q[Y]=J(q[Y])}else if(U)this.rule.do=J(U);return this}thenAction(Z){let X=this.rule.do;if(!X)throw Error("Cannot add then: no action defined. Use do() or then() first.");let Q=(U)=>({...U,then:Z});if(Array.isArray(X)){let U=X.length-1,J=X[U];if(J&&"actions"in J){let q=J.actions,Y=q.length-1;if(Y>=0)q[Y]=Q(q[Y])}else if(J)X[U]=Q(J)}else if(X&&"actions"in X){let U=X.actions,J=U.length-1;if(J>=0)U[J]=Q(U[J])}else if(X)this.rule.do=Q(X);return this}else(Z){let X=this.rule.do;if(!X)throw Error("Cannot add else: no action defined. Use do() or then() first.");let Q=(U)=>({...U,else:Z});if(Array.isArray(X)){let U=X.length-1,J=X[U];if(J&&"actions"in J){let q=J.actions,Y=q.length-1;if(Y>=0)q[Y]=Q(q[Y])}else if(J)X[U]=Q(J)}else if(X&&"actions"in X){let U=X.actions,J=U.length-1;if(J>=0)U[J]=Q(U[J])}else if(X)this.rule.do=[Q(X)];return this}elseAction(Z){return this.else(Z)}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");if(this.rule.if)this.rule.if=i6(this.rule.if,this.optimizeOptions);if(this.rule.do){let Z=s6(this.rule.do,this.optimizeOptions);this.rule.do=Z?Z:this.rule.do}return this.rule}}class M9{parent;condition;thenActions;elseActions;constructor(Z,X,Q,U){if(this.parent=Z,typeof X==="string")this.condition={field:X,operator:Q,value:U};else this.condition=X}then(Z,X,Q){if(typeof Z==="string")this.thenActions={type:Z,params:X,...Q};else this.thenActions=Z;return this}do(Z,X,Q){return this.then(Z,X,Q)}done(){return this.build()}else(Z,X,Q){if(typeof Z==="string")this.elseActions={type:Z,params:X,...Q};else this.elseActions=Z;return this.build()}build(){let Z={if:this.condition};if(this.thenActions)Z.then=this.thenActions;if(this.elseActions)Z.else=this.elseActions;let X=this.parent.rule.do;if(!X)this.parent.rule.do=Z;else if(Array.isArray(X))X.push(Z);else this.parent.rule.do=[X,Z];return this.parent}}var p3=UQ(u3(),1);class l3{static toYaml(Z){let X=Array.isArray(Z)?Z:[Z];return p3.default.stringify(X)}static toJson(Z,X=!0){let Q=Array.isArray(Z)?Z:[Z];return JSON.stringify(Q,null,X?2:0)}static cleanRule(Z){let X={};if(X.id=Z.id,Z.name)X.name=Z.name;if(Z.description)X.description=Z.description;if(X.on=Z.on,Z.priority!==void 0&&Z.priority!==0)X.priority=Z.priority;if(Z.enabled!==void 0&&Z.enabled!==!0)X.enabled=Z.enabled;if(Z.cooldown!==void 0&&Z.cooldown!==0)X.cooldown=Z.cooldown;if(Z.tags&&Z.tags.length>0)X.tags=Z.tags;if(Z.if)X.if=Z.if;if(X.do=Z.do,Z.else)X.else=Z.else;return X}static toCleanYaml(Z){let Q=(Array.isArray(Z)?Z:[Z]).map((U)=>this.cleanRule(U));return p3.default.stringify(Q,{indent:2,lineWidth:0})}static toCleanJson(Z,X=!0){let U=(Array.isArray(Z)?Z:[Z]).map((J)=>this.cleanRule(J));return JSON.stringify(U,null,X?2:0)}static async saveToFile(Z,X){let Q=this.toYaml(Z);if(typeof process<"u"&&process.versions&&process.versions.node){let U=await import("fs/promises"),q=(await import("path")).dirname(X);await U.mkdir(q,{recursive:!0}),await U.writeFile(X,Q,"utf8")}else throw Error("saveToFile is only supported in Node.js/Bun environments")}}var _Z=UQ(u3(),1);var _K=["EQ","==","NEQ","!="],VK=["GT",">","GTE",">=","LT","<","LTE","<="],HK=["IN","NOT_IN","RANGE"],zK=["CONTAINS","NOT_CONTAINS","STARTS_WITH","ENDS_WITH"];var jY=[..._K,...VK,...HK,...zK,"IS_EMPTY","HAS_KEY","MATCHES","SINCE","AFTER","BEFORE","UNTIL","RANGE"],EY=["AND","OR"],bY=["ALL","EITHER","SEQUENCE"];function T0(Z){return typeof Z==="object"&&Z!==null&&!Array.isArray(Z)}function FK(Z){return typeof Z==="string"&&Z.length>0}function BK(Z){return typeof Z==="number"&&!isNaN(Z)}function MK(Z){return typeof Z==="boolean"}function s1(Z){return"operator"in Z&&"conditions"in Z&&(Z.operator==="AND"||Z.operator==="OR")}function a1(Z){return"field"in Z&&"operator"in Z}function d3(Z){return typeof Z==="object"&&Z!==null&&"mode"in Z&&"actions"in Z&&Array.isArray(Z.actions)}function LZ(Z){return typeof Z==="object"&&Z!==null&&"if"in Z}function OK(Z){return typeof Z==="object"&&Z!==null&&"type"in Z}function c3(Z){return typeof Z==="string"&&bY.includes(Z)}function RK(Z){return typeof Z==="string"&&EY.includes(Z)}function KK(Z){return typeof Z==="string"&&SK(jY,Z)}function K4(Z){return Z.type||"log"}function T4(Z){if(!Z.params)return"{}";return typeof Z.params==="string"?Z.params:JSON.stringify(Z.params)}function X6(Z){if(a1(Z))return Z.field||"data";return"data"}function Q6(Z){if(a1(Z))return Z.operator||"EQ";if(s1(Z))return Z.operator==="OR"?"OR":"AND";return"EQ"}function U6(Z){if(a1(Z))return Z.value;return}function i3(Z=0){let X=Z;return()=>`node_${X++}`}function s3(){let Z=0;return()=>`edge_${Date.now()}_${Z++}`}function a3(Z=100,X=100,Q=300,U=150){return(J,q,Y)=>({x:Z+J*Q,y:X+q*U-Y*U/2})}function J6(Z){if(Z===void 0)return[];if(Array.isArray(Z))return Z;return[Z]}function TK(Z){if(!Z)return[];if(Array.isArray(Z))return Z;return[Z]}function DK(Z){if(!Z)return[];if(Array.isArray(Z))return Z;return[Z]}function wK(Z){return Z.replace(/\.(ya?ml)$/i,"")}function PK(Z){return{"==":"EQ","!=":"NEQ",">":"GT",">=":"GTE","<":"LT","<=":"LTE"}[Z]||Z}function AK(Z,X){if(!(X in Z)||Z[X]===void 0||Z[X]===null)throw Error(`Missing required field: ${X}`)}function SK(Z,X){return Z.includes(X)}function CK(Z,X,Q){let U=typeof Z;if(U!==X)throw Error(`Field "${Q}" expected type "${X}", got "${U}"`)}function NK(Z,X,Q){if(typeof Z!=="string"||!X.includes(Z))throw Error(`Field "${Q}" must be one of: ${X.join(", ")}`)}function D4(Z,X,Q,U){if(!T0(Z))throw Error(`Rule at index ${X} is not an object`);let J={...Z};if("actions"in J&&!("do"in J))J.do=J.actions,delete J.actions;if(!("enabled"in J))J.enabled=!0;if(!("priority"in J))J.priority=0;if(!J.id){if(U===!0&&Q){let q=Q.replace(/\.(ya?ml)$/i,"");J.id=q}else if(typeof U==="string")J.id=`${U}-${X}`}if("if"in J&&J.if!==void 0)J.if=GZ(J.if);if("do"in J&&J.do!==void 0)J.do=kY(J.do);if("else"in J&&J.else!==void 0)J.else=yY(J.else);return J}function GZ(Z){if(!Z)return[];if(T0(Z))return IY(Z);if(Array.isArray(Z))return Z.map((X,Q)=>{if(T0(X))return IY(X);throw Error(`Invalid condition at index ${Q}: expected object`)});throw Error("Invalid condition format: expected object or array")}function IY(Z){let X="operator"in Z&&(Z.operator==="AND"||Z.operator==="OR"),Q="conditions"in Z&&Array.isArray(Z.conditions);if(X&&Q){let Y=Z.operator,W=GZ(Z.conditions);return{operator:Y,conditions:Array.isArray(W)?W:[W]}}let{field:U,operator:J,value:q}=Z;return{field:U||"data",operator:J||"EQ",value:q}}function kY(Z){if(!Z)return[];if(T0(Z)&&"mode"in Z&&"actions"in Z)return H2(Z);if(T0(Z))return r1(Z);if(Array.isArray(Z))return Z.map((X,Q)=>{if(T0(X)){if("mode"in X&&"actions"in X)return H2(X);return r1(X)}throw Error(`Invalid action at index ${Q}: expected object`)});throw Error("Invalid do field format: expected object or array")}function yY(Z){if(!Z)return[];if(T0(Z)&&"mode"in Z&&"actions"in Z)return H2(Z);if(T0(Z))return r1(Z);if(Array.isArray(Z))return Z.map((X,Q)=>{if(T0(X)){if("mode"in X&&"actions"in X)return H2(X);return r1(X)}throw Error(`Invalid action at index ${Q}: expected object`)});throw Error("Invalid else field format: expected object or array")}function r1(Z){let X={...Z};if("do"in X&&!("then"in X))X.then=X.do,delete X.do;if("if"in X&&X.if!==void 0){let U={if:GZ(X.if)};if("then"in X&&X.then!==void 0)U.then=fY(X.then);if("else"in X&&X.else!==void 0)U.else=fY(X.else);if("break"in X)U.break=X.break;if("continue"in X)U.continue=X.continue;return U}let Q={};if("type"in X)Q.type=X.type;if("params"in X)Q.params=X.params;if("run"in X)Q.run=X.run;if("delay"in X)Q.delay=X.delay;if("probability"in X)Q.probability=X.probability;if("name"in X)Q.name=X.name;if("break"in X)Q.break=X.break;if("continue"in X)Q.continue=X.continue;return Q}function fY(Z){if(!Z)return[];if(T0(Z)&&"mode"in Z&&"actions"in Z)return H2(Z);if(T0(Z))return r1(Z);if(Array.isArray(Z)){let X=[];for(let Q=0;Q<Z.length;Q++){let U=Z[Q];if(T0(U))if("mode"in U&&"actions"in U){let J=H2(U);for(let q of J.actions)X.push(q)}else X.push(r1(U));else throw Error(`Invalid action in branch at index ${Q}: expected object`)}return X}throw Error("Invalid action branch format: expected object or array")}function H2(Z){let X=Z.mode||"ALL";if(!c3(X))throw Error(`Invalid execution mode: ${X}`);let Q=Z.actions;if(!Q||!Array.isArray(Q))throw Error("Action group must have an actions array");let U=Q.map((J,q)=>{if(T0(J)){if("mode"in J&&"actions"in J)return H2(J);return r1(J)}throw Error(`Invalid action in group at index ${q}: expected object`)});return{mode:X,actions:U}}function jK(Z,X,Q,U){let J=D4(Z,X,Q,U);if(!J.on)throw Error(`Rule at index ${X} missing required field: on`);return J}function EK(Z){let X=[];if(!Z.on)X.push("Missing required field: on");if(!Z.do&&Z.do!=="")X.push("Missing required field: do");if(Z.else&&!Z.if)X.push('Field "else" requires "if" to be present');return{valid:X.length===0,errors:X}}function gY(Z,X,Q){return{id:X,type:f.EVENT,position:Q,data:{id:Z.id||"rule-1",name:Z.name||"Imported Rule",description:Z.description||"",event:Z.on||"",priority:Z.priority||0,enabled:Z.enabled!==!1,cooldown:Z.cooldown,tags:Z.tags}}}function vY(Z,X,Q){return{id:X,type:f.CONDITION_GROUP,position:Q,data:{operator:Z}}}function w4(Z,X,Q,U,J){return{id:U,type:f.CONDITION,position:J,data:{field:Z||"data",operator:X||"EQ",value:Q??""}}}function r3(Z,X,Q){return{id:X,type:f.DO,position:Q,data:{branchType:Z}}}function xY(Z,X,Q){let U,J,q,Y,W,$,L;if(LZ(Z)){let G=Z.if;if(G){let H=(Array.isArray(G)?G:[G])[0];if(H&&a1(H))U=H.field,J=H.operator,q=H.value!==void 0?typeof H.value==="string"?H.value:JSON.stringify(H.value):void 0}let V=Z.then;if(V){let F=Array.isArray(V)?V:[V];if(F[0])Y=K4(F[0]),W=T4(F[0])}let z=Z.else;if(z){let F=Array.isArray(z)?z:[z];if(F[0])$=K4(F[0]),L=T4(F[0])}}let _={type:K4(Z),params:T4(Z)};if(U)_.conditionField=U;if(J)_.conditionOperator=J;if(q!==void 0)_.conditionValue=q;if(Y)_.thenType=Y;if(W)_.thenParams=W;if($)_.elseType=$;if(L)_.elseParams=L;return{id:X,type:f.ACTION,position:Q,data:_}}function hY(Z,X,Q){return{id:X,type:f.ACTION_GROUP,position:Q,data:{mode:Z||"SEQUENCE"}}}function i0(Z,X,Q,U,J){return{id:J?J():`edge_${Z}_${X}_${Date.now()}`,source:Z,target:X,sourceHandle:Q??null,targetHandle:U??null}}function bK(Z,X={}){let Q=[],U=[],J=[];if(!Z.id)J.push("Missing required field: id");if(!Z.on)J.push("Missing required field: on (event trigger)");if(!Z.do&&Z.do!=="")J.push("Missing required field: do (actions)");if(J.length>0)return{nodes:[],edges:[],valid:!1,errors:J};let q=X.startNodeId||"event-node",Y=i3(0),W=s3(),$=a3();try{let L=gY(Z,q,X.startPosition||{x:100,y:300});Q.push(L);let _=J6(Z.if);if(_.length>0){let{conditionNodes:G,groupNodeId:V}=IK(_,Q,U,L.id,Y,$),z=J6(Z.do);if(z.length>0){let H=G.length>0?G[G.length-1].id:V||L.id;q6(z,Q,U,H,Y,W,$,"do")}let F=J6(Z.else);if(F.length>0){let H=G.length>0?G[G.length-1].id:V||L.id;q6(F,Q,U,H,Y,W,$,"else")}}else{let G=J6(Z.do);if(G.length>0)q6(G,Q,U,L.id,Y,W,$,"do")}return{nodes:Q,edges:U,valid:!0,errors:[]}}catch(L){let _=L instanceof Error?L.message:"Unknown error during conversion";return J.push(_),{nodes:Q,edges:U,valid:!1,errors:J}}}function IK(Z,X,Q,U,J,q){let Y=[],W,$=Z.length>1,L=Z.some(s1);if($||L){W=J();let _="AND",G=Z.find(s1);if(G&&s1(G))_=G.operator;let V=vY(_,W,q(1,0,1));X.push(V),Q.push(i0(U,W,null,P.CONDITION_GROUP_INPUT,void 0));let z=null;Z.forEach((F,H)=>{let B,T;if(s1(F)){if(F.conditions)F.conditions.forEach((D,K)=>{if(s1(D))return;if(B=J(),T=w4(X6(D),Q6(D),U6(D),B,q(2,H*2+K,Z.length*2)),X.push(T),Y.push(T),z)Q.push(i0(z,B,P.CONDITION_OUTPUT,P.CONDITION_INPUT,void 0));else Q.push(i0(W,B,P.CONDITION_GROUP_OUTPUT,P.CONDITION_INPUT,void 0));z=B})}else{if(B=J(),T=w4(X6(F),Q6(F),U6(F),B,q(2,H,Z.length)),X.push(T),Y.push(T),z)Q.push(i0(z,B,P.CONDITION_OUTPUT,P.CONDITION_INPUT,void 0));else Q.push(i0(W,B,P.CONDITION_GROUP_OUTPUT,P.CONDITION_INPUT,void 0));z=B}})}else{let _=J(),G=w4(X6(Z[0]),Q6(Z[0]),U6(Z[0]),_,q(1,0,1));X.push(G),Y.push(G),Q.push(i0(U,_,null,P.CONDITION_INPUT,void 0))}return{conditionNodes:Y,groupNodeId:W}}function q6(Z,X,Q,U,J,q,Y,W){Z.forEach(($,L)=>{if(d3($)){let H=J(),B=X.find((w)=>w.id===U)?.position||{x:100,y:100},T=hY($.mode,H,{x:B.x+300,y:B.y+L*75});X.push(T);let D=X.find((w)=>w.id===U),K;if(D?.type===f.EVENT)K=P.EVENT_OUTPUT;else if(D?.type===f.CONDITION)K=P.CONDITION_OUTPUT;else if(D?.type===f.CONDITION_GROUP)K=P.CONDITION_GROUP_OUTPUT;else if(D?.type===f.ACTION_GROUP)K=P.ACTION_GROUP_OUTPUT;else if(D?.type===f.DO)K=P.DO_OUTPUT;else K=W===k0.ELSE?P.ELSE_OUTPUT:P.THEN_OUTPUT;Q.push(i0(U,H,K,P.ACTION_GROUP_INPUT,q)),q6($.actions,X,Q,H,J,q,Y,W);return}if(LZ($)){let B=$.if,T=Array.isArray(B)?B[0]:B;if(T&&a1(T)){let D=J(),K=Y(2,L,Z.length),w=w4(X6(T),Q6(T),U6(T),D,{x:K.x+300,y:K.y});X.push(w);let S=X.find((x)=>x.id===U),j;if(S?.type===f.EVENT)j=P.EVENT_OUTPUT;else if(S?.type===f.ACTION_GROUP)j=P.ACTION_GROUP_CONDITION_OUTPUT;else if(S?.type===f.CONDITION)j=P.CONDITION_OUTPUT;else if(S?.type===f.DO)j=P.DO_OUTPUT;else j=W===k0.ELSE?P.CONDITION_OUTPUT:P.CONDITION_OUTPUT;Q.push(i0(U,D,j,P.CONDITION_INPUT,q));let v=$.then;if(v){let x=J(),s=r3("do",x,{x:w.position.x+300,y:w.position.y-100});X.push(s),Q.push(i0(D,x,P.CONDITION_OUTPUT,P.DO_INPUT,q));let Q0=Array.isArray(v)?v:[v];q6(Q0,X,Q,x,J,q,(V0,D0,y0)=>{return{x:s.position.x+300,y:s.position.y-D0*150}},"do")}let N=$.else;if(N){let x=J(),s=r3("else",x,{x:w.position.x+300,y:w.position.y+100});X.push(s),Q.push(i0(D,x,P.CONDITION_OUTPUT,P.DO_INPUT,q));let Q0=Array.isArray(N)?N:[N];q6(Q0,X,Q,x,J,q,(V0,D0,y0)=>{return{x:s.position.x+300,y:s.position.y+D0*150}},"else")}}return}let _=J(),G=X.find((H)=>H.id===U)?.position||{x:700,y:100},V=xY($,_,{x:G.x+300,y:G.y+L*150});X.push(V);let z=X.find((H)=>H.id===U),F;if(z?.type===f.EVENT)F=P.EVENT_OUTPUT;else if(z?.type===f.CONDITION)F=P.CONDITION_OUTPUT;else if(z?.type===f.CONDITION_GROUP)F=P.CONDITION_GROUP_OUTPUT;else if(z?.type===f.ACTION_GROUP)F=P.ACTION_GROUP_OUTPUT;else if(z?.type===f.DO)F=P.DO_OUTPUT;else F=W===k0.ELSE?P.CONDITION_OUTPUT:P.CONDITION_OUTPUT;Q.push(i0(U,_,F,P.ACTION_INPUT,q))})}function Y6(Z,X={}){let{autoId:Q=!1,filename:U,throwOnError:J=!1,multiDocument:q=!0}=X,Y=[],W=[];try{let L;if(q){let G=_Z.parseAllDocuments(Z);for(let V of G)if(V.errors&&V.errors.length>0){let z=V.errors.map((F)=>F.message).join(", ");throw Error(`YAML syntax error: ${z}`)}L=G.map((V)=>V.toJS())}else{let G=_Z.parse(Z);L=Array.isArray(G)?[G]:[G]}let _=[];L.forEach((G)=>{if(Array.isArray(G))_.push(...G);else _.push(G)}),_.forEach((G,V)=>{try{let z;if(Q&&!U)z={...D4(G,V),id:`rule-${V}`};else z=D4(G,V,U,Q);let F=KX.validate(z);if(F.valid)W.push(F.rule);else Y.push({index:V,message:`Validation failed for rule at index ${V}`,issues:F.issues.map((H)=>({path:H.path,message:H.message,suggestion:H.suggestion}))})}catch(z){let F=z instanceof Error?z.message:`Unknown error at index ${V}`;Y.push({index:V,message:F})}})}catch(L){let _=L instanceof Error?L.message:"Unknown parsing error";Y.push({index:-1,message:`Failed to parse YAML: ${_}`})}let $={rules:W,errors:Y,valid:Y.length===0&&W.length>0};if(J&&!$.valid){let L=$.errors.map((_)=>{let G=`Rule ${_.index}: ${_.message}`;if(_.issues)G+=`
185
+ Issues:
186
+ `+_.issues.map((V)=>` - [${V.path}] ${V.message}`).join(`
187
+ `);return G}).join(`
188
+ `);throw Error(`YAML parsing failed:
189
+ ${L}`)}return $}function Py(Z,X={}){return Y6(Z,{...X,multiDocument:!1})}function Ay(Z,X={}){let Q=Y6(Z,{...X,throwOnError:!0});if(Q.rules.length===0)throw Error("No valid rules found in YAML");return Q.rules[0]}var xy={id:{description:"Unique identifier for this rule",examples:["my-rule-1","donation-handler","user-login-tracker"]},name:{description:"Human-readable name for the rule",examples:["Donation Handler","User Login Tracker"]},description:{description:"Detailed description of what this rule does"},on:{description:"The event name that triggers this rule",values:"String event name (e.g., `Donation`, `UserLogin`, `minecraft:player_join`)",examples:["Donation","UserLogin","minecraft:player_join","COMMAND"]},if:{description:"Condition(s) that must be met for the rule to execute",values:"Single condition object, array of conditions, or condition group with AND/OR operator"},do:{description:"Action(s) to execute when conditions are met",values:"Single action object, array of actions, or action group with mode (ALL, SEQUENCE, EITHER)"},priority:{description:"Execution priority (higher values execute first)",values:"Integer number",examples:["1","10","100"]},enabled:{description:"Whether this rule is active",values:"Boolean: `true` or `false`",examples:["true","false"]},cooldown:{description:"Minimum time in milliseconds between executions",values:"Non-negative integer (milliseconds)",examples:["1000","5000","60000"]},tags:{description:"Tags for categorizing and organizing rules",values:"Array of strings",examples:['["gameplay", "monetization"]','["debug", "test"]']},comment:{description:"Internal developer note (not used in execution)"}},hy={EQ:{description:"Equal to (==)",valueType:"Any value",examples:["value: 100",'value: "hello"',"value: true"]},"==":{description:"Equal to (same as EQ)",valueType:"Any value",examples:["value: 100",'value: "hello"']},NEQ:{description:"Not equal to (!=)",valueType:"Any value",examples:["value: 0",'value: "goodbye"']},"!=":{description:"Not equal to (same as NEQ)",valueType:"Any value",examples:["value: 0"]},GT:{description:"Greater than (>)",valueType:"Number or expression string",examples:["value: 100",'value: "${state.count}"']},">":{description:"Greater than (same as GT)",valueType:"Number or expression string",examples:["value: 50"]},GTE:{description:"Greater than or equal to (>=)",valueType:"Number or expression string",examples:["value: 100"]},">=":{description:"Greater than or equal to (same as GTE)",valueType:"Number or expression string",examples:["value: 100"]},LT:{description:"Less than (<)",valueType:"Number or expression string",examples:["value: 100"]},"<":{description:"Less than (same as LT)",valueType:"Number or expression string",examples:["value: 50"]},LTE:{description:"Less than or equal to (<=)",valueType:"Number or expression string",examples:["value: 100"]},"<=":{description:"Less than or equal to (same as LTE)",valueType:"Number or expression string",examples:["value: 100"]},IN:{description:"Value is in the given list",valueType:"Array of values",examples:["value: [1, 2, 3]",'value: ["a", "b", "c"]']},NOT_IN:{description:"Value is not in the given list",valueType:"Array of values",examples:["value: [0, null]"]},CONTAINS:{description:"String contains substring, or array includes item",valueType:"String (for substring) or Array (for item check)",examples:['value: "hello"','value: ["item1", "item2"]']},NOT_CONTAINS:{description:"String does not contain substring, or array does not include item",valueType:"String (for substring) or Array (for item check)",examples:['value: "spam"','value: ["excluded"]']},STARTS_WITH:{description:"String starts with the specified prefix",valueType:"String",examples:['value: "https://"','value: "user_"']},ENDS_WITH:{description:"String ends with the specified suffix",valueType:"String",examples:['value: ".com"','value: "_admin"']},IS_EMPTY:{description:"Value is empty (string, array, object, or null)",valueType:"No value required",examples:["(no value needed)"]},IS_NULL:{description:"Value is null or undefined",valueType:"No value required",examples:["(no value needed)"]},IS_NONE:{description:"Alias for IS_NULL",valueType:"No value required",examples:["(no value needed)"]},HAS_KEY:{description:"Object has the specified key",valueType:"String (key name)",examples:['value: "userId"','value: "role"']},MATCHES:{description:"Value matches the regular expression pattern",valueType:"String (regex pattern)",examples:['value: "^[A-Z].*"','value: "\\\\d{3}-\\\\d{4}"']},RANGE:{description:"Value is within the specified range [min, max] (inclusive)",valueType:"Array of exactly 2 numbers: [min, max]",examples:["value: [0, 100]","value: [1, 10]"]},SINCE:{description:"Date/time is after or equal to the specified value",valueType:"Date string or timestamp",examples:['value: "2024-01-01"']},AFTER:{description:"Date/time is after the specified value (alias for SINCE)",valueType:"Date string or timestamp",examples:['value: "2024-01-01T00:00:00Z"']},BEFORE:{description:"Date/time is before the specified value",valueType:"Date string or timestamp",examples:['value: "2024-12-31"']},UNTIL:{description:"Date/time is before or equal to the specified value (alias for BEFORE)",valueType:"Date string or timestamp",examples:['value: "2024-12-31T23:59:59Z"']},AND:{description:"Logical AND - all conditions must be true",valueType:"Used in condition groups",examples:[`operator: AND
190
+ conditions:
191
+ - field: data.x
192
+ operator: GT
193
+ value: 0`]},OR:{description:"Logical OR - at least one condition must be true",valueType:"Used in condition groups",examples:[`operator: OR
194
+ conditions:
195
+ - field: data.x
196
+ operator: EQ
197
+ value: 1`]}},my={field:{description:"The field path to check (e.g., `data.amount`, `event.user.id`)",values:"String path using dot notation"},operator:{description:"The comparison operator to use",values:"One of: EQ, ==, NEQ, !=, GT, >, GTE, >=, LT, <, LTE, <=, IN, NOT_IN, CONTAINS, NOT_CONTAINS, STARTS_WITH, ENDS_WITH, IS_EMPTY, IS_NULL, HAS_KEY, MATCHES, RANGE, SINCE, AFTER, BEFORE, UNTIL"},value:{description:"The value to compare against (type depends on operator)",values:"Varies by operator - see operator documentation for details"},conditions:{description:"Array of sub-conditions for AND/OR groups",values:"Array of condition objects"}},uy={type:{description:"The type of action to perform",values:"String action type (e.g., `log`, `execute`, `notify`, `STATE_SET`, `EMIT_EVENT`)"},params:{description:"Parameters for the action (varies by action type)",values:"Object with action-specific parameters"},run:{description:"Direct script execution block (JavaScript-like syntax)",values:"String block of code"},delay:{description:"Delay in milliseconds before executing this action",values:"Non-negative integer (milliseconds)"},probability:{description:"Probability of executing this action (0.0 to 1.0)"},mode:{description:"Execution mode for action groups",values:"ALL (execute all), SEQUENCE (execute in order), or EITHER (execute one randomly)"},actions:{description:"Array of sub-actions for action groups",values:"Array of action objects"},then:{description:"Actions to execute when condition is true",values:"Action object or array of actions"},else:{description:"Actions to execute when condition is false",values:"Action object or array of actions"}},py={log:{description:"Prints a message to the engine console for debugging",params:["message: string (supports interpolation)"]},math:{description:`Expression to evaluate (e.g. "1 + 2" or "'Hi ' + data.user")`,params:[`expression: string (e.g. "1 + 2" or "'Hello ' + data.name")`]},execute:{description:"Runs a shell command on the host (Node.js only)",params:["command: string","safe: boolean"]},notify:{description:"Sends a notification to a specified target",params:["message: string","target: string"]},STATE_SET:{description:"Updates a value in the global state manager",params:["key: string","value: any"]},STATE_OP:{description:"Performs direct operations on state using a script",params:["run: string"]}};import{existsSync as mY,mkdirSync as fK,readFileSync as kK,writeFileSync as yK}from"fs";import{dirname as gK}from"path";class vK{filePath;cache=new Map;isLoaded=!1;pendingWrite=null;writeDelay;dirty=!1;constructor(Z,X){this.filePath=Z,this.writeDelay=X?.writeDelay??0}flush(){this.dirty=!0,this.persist()}getCache(){return this.ensureLoaded(),new Map(this.cache)}isDirty(){return this.dirty}ensureLoaded(){if(this.isLoaded)return;try{if(mY(this.filePath)){let Z=kK(this.filePath,"utf-8"),X=JSON.parse(Z);this.cache=new Map(Object.entries(X))}}catch(Z){console.error(`[FilePersistence] Failed to load state from ${this.filePath}:`,Z),this.cache=new Map}this.isLoaded=!0}schedulePersist(){if(this.writeDelay<=0){this.persist();return}if(this.pendingWrite)clearTimeout(this.pendingWrite);this.dirty=!0,this.pendingWrite=setTimeout(()=>{this.persist(),this.pendingWrite=null},this.writeDelay)}persist(){if(this.pendingWrite)clearTimeout(this.pendingWrite),this.pendingWrite=null;try{let Z=gK(this.filePath);if(!mY(Z))fK(Z,{recursive:!0});let X=Object.fromEntries(this.cache);yK(this.filePath,JSON.stringify(X,null,2),"utf-8"),this.dirty=!1}catch(Z){console.error(`[FilePersistence] Failed to save state to ${this.filePath}:`,Z)}}async loadState(){return this.ensureLoaded(),new Map(this.cache)}async saveState(Z,X){this.ensureLoaded(),this.cache.set(Z,X),this.schedulePersist()}async deleteState(Z){this.ensureLoaded(),this.cache.delete(Z),this.schedulePersist()}async clearState(){this.cache.clear(),this.schedulePersist()}}import*as W6 from"path";import*as G1 from"fs";class o3{registry=new Map;defaultDir="./rules";clear(){this.registry.clear(),console.log("[RuleRegistry] Cleared")}setDefaultDir(Z){this.defaultDir=Z}getDefaultDir(){return this.defaultDir}register(Z,X){if(!Z.id)throw Error("[RuleRegistry] Cannot register rule without ID");this.registry.set(Z.id,{rule:{...Z},filePath:X,loadedAt:Date.now(),modified:!1})}registerAll(Z,X){for(let Q of Z){let U;if(X&&Q.id)U=`${X}/${Q.id}.yaml`;this.register(Q,U)}}get(Z){return this.registry.get(Z)?.rule}getAll(){return Array.from(this.registry.values()).map((Z)=>Z.rule)}has(Z){return this.registry.has(Z)}size(){return this.registry.size}getEntry(Z){return this.registry.get(Z)}add(Z,X){if(!Z.id)Z.id=this.generateId();if(this.has(Z.id))throw Error(`[RuleRegistry] Rule "${Z.id}" already exists`);let Q=X||(Z.id?`${this.defaultDir}/${Z.id}.yaml`:void 0);return this.register(Z,Q),Z}update(Z,X){let Q=this.registry.get(Z);if(!Q)throw Error(`[RuleRegistry] Rule "${Z}" not found`);let U={...Q.rule,...X};return U.id=Z,this.registry.set(Z,{...Q,rule:U,modified:!0,loadedAt:Date.now()}),U}remove(Z){return this.registry.delete(Z)}getModified(){return Array.from(this.registry.values()).filter((Z)=>Z.modified).map((Z)=>Z.rule)}hasModified(){return Array.from(this.registry.values()).some((Z)=>Z.modified)}markAsSaved(Z,X){let Q=this.registry.get(Z);if(Q)this.registry.set(Z,{...Q,filePath:X||Q.filePath,modified:!1})}generateId(){return`rule-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}entries(){return this.registry.entries()}values(){return this.registry.values()}}import*as o1 from"path";import*as M0 from"fs";class VZ{static async loadFromDir(Z){let X=[],Q=async(U)=>{let J;try{J=await M0.promises.readdir(U,{withFileTypes:!0})}catch(q){console.error(`[RulePersistence] Failed to readdir ${U}:`,q);return}for(let q of J){let Y=o1.resolve(U,q.name);if(q.isDirectory())await Q(Y);else if(Y.toLowerCase().endsWith(".yaml")||Y.toLowerCase().endsWith(".yml"))try{let W=await VZ.loadFile(Y);X.push(...W)}catch(W){console.error(`Failed to load rule from ${Y}:`,W)}}};if(M0.existsSync(Z))await Q(Z);else console.warn(`[RulePersistence] Directory not found: ${Z}`);return X}static async loadFile(Z,X=()=>{}){let Q=await M0.promises.readFile(Z,"utf-8"),U=Y6(Q,{filename:Z,throwOnError:!1});if(U.errors.length>0)console.error(`Validation rule path: ${Z}`),U.errors.forEach((J)=>X(J));return U.rules.map((J,q)=>{if(!J.id){let Y=o1.basename(Z,o1.extname(Z));J.id=U.rules.length>1?`${Y}-${q}`:Y}return J})}static async saveRule(Z,X){let Q=o1.dirname(X);if(!M0.existsSync(Q))M0.mkdirSync(Q,{recursive:!0});let U=l3.toCleanYaml(Z);await M0.promises.writeFile(X,U,"utf-8")}static async saveAll(Z,X,Q=(U)=>`${X}/${U}.yaml`){if(!M0.existsSync(X))M0.mkdirSync(X,{recursive:!0});let U=[];for(let J of Z){let q=Q(J.id);await this.saveRule(J,q),U.push(q)}return U}static async deleteFile(Z){if(!M0.existsSync(Z))return!1;return await M0.promises.unlink(Z),!0}static fileExists(Z){return M0.existsSync(Z)}static ensureDir(Z){if(!M0.existsSync(Z))M0.mkdirSync(Z,{recursive:!0})}}class n3{static findByTag(Z,X){let Q=[],U=X.toLowerCase();for(let J of Z)if(J.rule.tags){for(let q of J.rule.tags)if(q.toLowerCase()===U){Q.push(J.rule);break}}return Q}static findByEvent(Z,X){let Q=[],U=X.toLowerCase();for(let J of Z)if(J.rule.on&&J.rule.on.toLowerCase()===U)Q.push(J.rule);return Q}static findByName(Z,X){let Q=[],U=X.toLowerCase();for(let J of Z)if(J.rule.name&&J.rule.name.toLowerCase().includes(U))Q.push(J.rule);return Q}static find(Z,X){let Q=[];for(let U of Z)if(X(U.rule))Q.push(U.rule);return Q}static groupByTag(Z){let X=new Map;for(let Q of Z){let U=Q.rule;if(U.tags)for(let J of U.tags){let q=X.get(J)||[];q.push(U),X.set(J,q)}}return X}static groupByEvent(Z){let X=new Map;for(let Q of Z){let U=Q.rule;if(U.on){let J=X.get(U.on)||[];J.push(U),X.set(U.on,J)}}return X}static enable(Z,X){let Q=Z.get(X);if(!Q)throw Error(`[RuleQuery] Rule "${X}" not found`);let U={...Q.rule,enabled:!0};return Z.set(X,{...Q,rule:U,modified:!0}),U}static disable(Z,X){let Q=Z.get(X);if(!Q)throw Error(`[RuleQuery] Rule "${X}" not found`);let U={...Q.rule,enabled:!1};return Z.set(X,{...Q,rule:U,modified:!0}),U}static toggle(Z,X){let Q=Z.get(X);if(!Q)throw Error(`[RuleQuery] Rule "${X}" not found`);let U={...Q.rule,enabled:!Q.rule.enabled};return Z.set(X,{...Q,rule:U,modified:!0}),U}}import*as uY from"fs";class t3{watcher=null;dirPath="";callback=null;loadFn=null;start(Z,X,Q){this.stop(),this.dirPath=Z,this.loadFn=X,this.callback=Q||null,X(Z).then((U)=>{if(this.callback)this.callback(U)}),console.log(`[RuleWatcher] Watching: ${Z}`),this.watcher=uY.watch(Z,{recursive:!0},async(U,J)=>{if(J&&(String(J).endsWith(".yaml")||String(J).endsWith(".yml"))){console.log(`[RuleWatcher] Change detected: ${J} (${U})`);try{let q=await X(Z);if(this.callback)this.callback(q)}catch(q){console.error("[RuleWatcher] Failed to reload:",q)}}})}stop(){if(this.watcher)this.watcher.close(),this.watcher=null,console.log("[RuleWatcher] Stopped")}isWatching(){return this.watcher!==null}getWatchPath(){return this.dirPath}}class pY{static defaultDir="./rules";static watcher=null;static setDefaultDir(Z){if(this.defaultDir=Z,!G1.existsSync(Z))G1.mkdirSync(Z,{recursive:!0});console.log(`[TriggerLoader] Default directory set to: ${Z}`)}static getDefaultDir(){return this.defaultDir}static async loadRulesFromDir(Z){let X=[],Q=async(U)=>{let J;try{J=await G1.promises.readdir(U,{withFileTypes:!0})}catch(q){console.error(`[TriggerLoader] Failed to readdir ${U}:`,q);return}for(let q of J){let Y=W6.resolve(U,q.name);if(q.isDirectory())await Q(Y);else if(Y.toLowerCase().endsWith(".yaml")||Y.toLowerCase().endsWith(".yml"))try{let W=await this.loadRule(Y);X.push(...W)}catch(W){console.error(`Failed to load rule from ${Y}:`,W)}}};if(G1.existsSync(Z))await Q(Z);else console.warn(`[TriggerLoader] Directory not found: ${Z}`);return X}static async loadRule(Z,X=(Q)=>{}){try{let Q=await G1.promises.readFile(Z,"utf-8"),U=Y6(Q,{filename:Z,throwOnError:!1});if(U.errors.length>0)console.error(`Validation rule path: ${Z}`),U.errors.forEach((q)=>X(q));return U.rules.map((q,Y)=>{if(!q.id){let W=W6.basename(Z,W6.extname(Z));q.id=U.rules.length>1?`${W}-${Y}`:W}return q})}catch(Q){throw X({error:Q,filePath:Z}),Q}}static watchRules(Z,X){return this.loadRulesFromDir(Z).then(X),console.log(`[TriggerLoader] Watching for changes in ${Z}...`),G1.watch(Z,{recursive:!0},async(U,J)=>{if(J&&(String(J).endsWith(".yaml")||String(J).endsWith(".yml"))){console.log(`[TriggerLoader] Detected change in ${J} (${U}). Reloading rules...`);try{let q=await this.loadRulesFromDir(Z);X(q),console.log(`[TriggerLoader] Reloaded ${q.length} rules.`)}catch(q){console.error("[TriggerLoader] Failed to reload rules:",q)}}})}static stopWatching(){if(this.watcher)this.watcher.close(),this.watcher=null,console.log("[TriggerLoader] Stopped watching")}}export{EK as validateRule,NK as validateFieldValue,CK as validateFieldType,bK as triggerRuleToNodes,l0 as triggerEmitter,z9 as ruleEvents,AK as requireField,Y6 as parseYamlRules,Ay as parseYamlRuleStrict,Py as parseYamlRule,KJ as parseGraphToRules,NX as parseGraph,i6 as optimizeCondition,s6 as optimizeAction,jK as normalizeRuleAdvanced,D4 as normalizeRule,PK as normalizeOperator,yY as normalizeElseField,kY as normalizeDoField,DK as normalizeConditionsUtils,GZ as normalizeConditions,TK as normalizeActions,r1 as normalizeAction,BK as isValidNumber,c3 as isValidExecutionMode,RK as isValidConditionOperator,KK as isValidComparisonOperator,a1 as isSimpleCondition,OK as isSimpleAction,T0 as isObject,FK as isNonEmptyString,s1 as isConditionGroup,MK as isBoolean,d3 as isActionGroup,LZ as hasConditionalExecution,U6 as getConditionValue,Q6 as getConditionOperator,X6 as getConditionField,K4 as getActionType,T4 as getActionParams,wK as generateRuleIdFromFilename,CX as findTerminalActions,J6 as ensureArray,yb as engineEvents,Nf as defaultGetDoBranchType,G_ as defaultExtractEventData,a3 as createPositionCalculator,L_ as createParserContext,i3 as createNodeIdGenerator,s3 as createEdgeIdGenerator,T9 as collectDoActions,gY as buildEventNode,i0 as buildEdge,r3 as buildDoNode,w4 as buildConditionNode,vY as buildConditionGroupNode,xY as buildActionNode,hY as buildActionGroupNode,KX as TriggerValidator,RX as TriggerUtils,hb as TriggerSystem,$_ as TriggerRuleSchema,pY as TriggerLoader,c6 as TriggerEngine,BX as TriggerEmitter,F0 as StateManager,t3 as RuleWatcher,o3 as RuleRegistry,n3 as RuleQuery,VZ as RulePersistence,l3 as RuleExporter,X_ as RuleEvents,H9 as RuleEvent,WJ as RuleEngine,jI as RuleConditionSchema,jX as RuleBuilder,TX as ParamsBuilder,hy as OPERATOR_DOCS,f as NodeType,p0 as MathFunctions,II as InlineConditionalActionSchema,zX as InMemoryPersistence,P as HandleId,vK as FilePersistence,xy as FIELD_DOCS,E0 as ExpressionEngine,Z_ as Events,Q_ as EventQueue,OX as ErrorMessages,u2 as EngineEvent,c6 as Engine,F9 as DebugMessages,MX as ControlFlow,nG as ContextKeys,J_ as ContextAdapter,M9 as ConditionalActionBuilder,CI as ConditionSchema,DX as ConditionOperator,NI as ConditionGroupSchema,v1 as ConditionBuilder,SI as ComparisonOperatorSchema,my as CONDITION_FIELD_DOCS,K0 as BuiltInAction,U_ as BrowserPersistence,k0 as BranchType,eG as Actions,EI as ActionSchema,d6 as ActionRegistry,bI as ActionGroupSchema,a6 as ActionBuilder,py as ACTION_TYPE_DOCS,uy as ACTION_FIELD_DOCS};
186
198
 
187
- //# debugId=9C4DDC4AFB40E48D64756E2164756E21
199
+ //# debugId=B24681473A9E361664756E2164756E21