trigger_system 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +127 -0
- package/dist/browser/index.browser.js +48 -0
- package/dist/browser/index.browser.js.map +122 -0
- package/dist/cli/lsp-server.d.ts +3 -0
- package/dist/cli/lsp-server.d.ts.map +1 -0
- package/dist/cli/validate.d.ts +2 -0
- package/dist/cli/validate.d.ts.map +1 -0
- package/dist/core/action-registry.d.ts +12 -0
- package/dist/core/action-registry.d.ts.map +1 -0
- package/dist/core/context-adapter.d.ts +23 -0
- package/dist/core/context-adapter.d.ts.map +1 -0
- package/dist/core/dependency-graph.d.ts +18 -0
- package/dist/core/dependency-graph.d.ts.map +1 -0
- package/dist/core/engine.d.ts +24 -0
- package/dist/core/engine.d.ts.map +1 -0
- package/dist/core/event-queue.d.ts +25 -0
- package/dist/core/event-queue.d.ts.map +1 -0
- package/dist/core/expression-engine.d.ts +31 -0
- package/dist/core/expression-engine.d.ts.map +1 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/persistence-browser.d.ts +20 -0
- package/dist/core/persistence-browser.d.ts.map +1 -0
- package/dist/core/persistence.d.ts +34 -0
- package/dist/core/persistence.d.ts.map +1 -0
- package/dist/core/persistence.node.d.ts +18 -0
- package/dist/core/persistence.node.d.ts.map +1 -0
- package/dist/core/plugin-manager.d.ts +15 -0
- package/dist/core/plugin-manager.d.ts.map +1 -0
- package/dist/core/rule-engine.d.ts +39 -0
- package/dist/core/rule-engine.d.ts.map +1 -0
- package/dist/core/state-manager.d.ts +41 -0
- package/dist/core/state-manager.d.ts.map +1 -0
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/validator.d.ts +2433 -0
- package/dist/domain/validator.d.ts.map +1 -0
- package/dist/index.browser.d.ts +6 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/io/index.d.ts +2 -0
- package/dist/io/index.d.ts.map +1 -0
- package/dist/io/loader.node.d.ts +14 -0
- package/dist/io/loader.node.d.ts.map +1 -0
- package/dist/lsp/completions.d.ts +6 -0
- package/dist/lsp/completions.d.ts.map +1 -0
- package/dist/lsp/completions.js +624 -0
- package/dist/lsp/completions.js.map +1 -0
- package/dist/lsp/data-context.d.ts +60 -0
- package/dist/lsp/data-context.d.ts.map +1 -0
- package/dist/lsp/data-context.js +172 -0
- package/dist/lsp/data-context.js.map +1 -0
- package/dist/lsp/diagnostics.d.ts +7 -0
- package/dist/lsp/diagnostics.d.ts.map +1 -0
- package/dist/lsp/diagnostics.js +373 -0
- package/dist/lsp/diagnostics.js.map +1 -0
- package/dist/lsp/directives.d.ts +44 -0
- package/dist/lsp/directives.d.ts.map +1 -0
- package/dist/lsp/directives.js +232 -0
- package/dist/lsp/directives.js.map +1 -0
- package/dist/lsp/domain/index.d.ts +2 -0
- package/dist/lsp/domain/index.d.ts.map +1 -0
- package/dist/lsp/domain/index.js +18 -0
- package/dist/lsp/domain/index.js.map +1 -0
- package/dist/lsp/domain/validator.d.ts +2433 -0
- package/dist/lsp/domain/validator.d.ts.map +1 -0
- package/dist/lsp/domain/validator.js +225 -0
- package/dist/lsp/domain/validator.js.map +1 -0
- package/dist/lsp/hover.d.ts +7 -0
- package/dist/lsp/hover.d.ts.map +1 -0
- package/dist/lsp/hover.js +462 -0
- package/dist/lsp/hover.js.map +1 -0
- package/dist/lsp/lsp/completions.d.ts +6 -0
- package/dist/lsp/lsp/completions.d.ts.map +1 -0
- package/dist/lsp/lsp/completions.js +624 -0
- package/dist/lsp/lsp/completions.js.map +1 -0
- package/dist/lsp/lsp/data-context.d.ts +60 -0
- package/dist/lsp/lsp/data-context.d.ts.map +1 -0
- package/dist/lsp/lsp/data-context.js +172 -0
- package/dist/lsp/lsp/data-context.js.map +1 -0
- package/dist/lsp/lsp/diagnostics.d.ts +7 -0
- package/dist/lsp/lsp/diagnostics.d.ts.map +1 -0
- package/dist/lsp/lsp/diagnostics.js +373 -0
- package/dist/lsp/lsp/diagnostics.js.map +1 -0
- package/dist/lsp/lsp/directives.d.ts +44 -0
- package/dist/lsp/lsp/directives.d.ts.map +1 -0
- package/dist/lsp/lsp/directives.js +232 -0
- package/dist/lsp/lsp/directives.js.map +1 -0
- package/dist/lsp/lsp/hover.d.ts +7 -0
- package/dist/lsp/lsp/hover.d.ts.map +1 -0
- package/dist/lsp/lsp/hover.js +462 -0
- package/dist/lsp/lsp/hover.js.map +1 -0
- package/dist/lsp/lsp/semantic_tokens.d.ts +4 -0
- package/dist/lsp/lsp/semantic_tokens.d.ts.map +1 -0
- package/dist/lsp/lsp/semantic_tokens.js +158 -0
- package/dist/lsp/lsp/semantic_tokens.js.map +1 -0
- package/dist/lsp/lsp/server.d.ts +2 -0
- package/dist/lsp/lsp/server.d.ts.map +1 -0
- package/dist/lsp/lsp/server.js +216 -0
- package/dist/lsp/lsp/server.js.map +1 -0
- package/dist/lsp/semantic_tokens.d.ts +4 -0
- package/dist/lsp/semantic_tokens.d.ts.map +1 -0
- package/dist/lsp/semantic_tokens.js +158 -0
- package/dist/lsp/semantic_tokens.js.map +1 -0
- package/dist/lsp/server.bundle.d.ts +2 -0
- package/dist/lsp/server.bundle.d.ts.map +1 -0
- package/dist/lsp/server.bundle.js +256 -0
- package/dist/lsp/server.d.ts +2 -0
- package/dist/lsp/server.d.ts.map +1 -0
- package/dist/lsp/server.js +216 -0
- package/dist/lsp/server.js.map +1 -0
- package/dist/lsp/types.d.ts +71 -0
- package/dist/lsp/types.d.ts.map +1 -0
- package/dist/lsp/types.js +4 -0
- package/dist/lsp/types.js.map +1 -0
- package/dist/node/index.js +186 -0
- package/dist/node/index.js.map +196 -0
- package/dist/node/node.js +187 -0
- package/dist/node/node.js.map +198 -0
- package/dist/node.d.ts +4 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/sdk/builder.d.ts +39 -0
- package/dist/sdk/builder.d.ts.map +1 -0
- package/dist/sdk/exporter.d.ts +13 -0
- package/dist/sdk/exporter.d.ts.map +1 -0
- package/dist/sdk/index.d.ts +3 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/emitter.d.ts +25 -0
- package/dist/utils/emitter.d.ts.map +1 -0
- package/dist/utils/utils.d.ts +18 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class u{static evaluate(Q,X){try{if(Q.includes("${")){let Y=this.interpolate(Q,X);if(!isNaN(Number(Y))&&Y.trim()!=="")return Number(Y);return Y}return this.evaluateExpression(Q,X)}catch(Y){return console.error(`Error evaluating expression: ${Q}`,Y),null}}static interpolate(Q,X){return Q.replace(/\$\{([^}]+)\}/g,(Y,U)=>{try{let Z=this.evaluateExpression(U,X);if(Z===void 0||Z===null)return"undefined";return String(Z)}catch(Z){return console.error(`Error en interpolación: ${Y}`,Z),Y}})}static evaluateMathExpression(Q){try{return Function("Math",`return ${Q}`)(Math)}catch(X){throw Error(`Error evaluando expresión matemática: ${Q}`)}}static evaluateExpression(Q,X){if(/^(data|globals|request|computed)(\.[a-zA-Z0-9_]+)+$/.test(Q))return this.getNestedValue(Q,X);try{return Function("context","with(context) { return "+Q+" }")(X)}catch(Y){return console.error(`ERROR evaluating expression '${Q}':`,Y),Q}}static getNestedValue(Q,X){let Y=Q.split("."),U=X;for(let Z of Y){if(U===null||U===void 0||!(Z in U))return;U=U[Z]}return U}static evaluateMath(Q,X){let Y=Q;Y=Y.replace(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g,(U)=>{if(["Math","random","floor","ceil","round","sqrt","abs","pow","min","max","sin","cos","tan"].includes(U))return U;let Z=this.getNestedValue(U,X);if(Z!==void 0)return typeof Z==="string"?`"${Z}"`:String(Z);return U});try{return this.evaluateMathExpression(Y)}catch(U){return console.error(`Error en evaluación matemática: ${Q}`,U),NaN}}}class tY{queue=[];engine;config;timer=null;isProcessing=!1;constructor(Q,X={maxBatchSize:10,flushIntervalMs:100}){this.engine=Q,this.config=X}push(Q){if(this.queue.push(Q),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 Q=this.queue.splice(0,this.config.maxBatchSize);if(Q.length===0){this.isProcessing=!1;return}console.debug(`[EventQueue] Processing batch of ${Q.length} events.`);for(let X of Q)try{await this.engine.evaluateContext(X)}catch(Y){console.error(`[EventQueue] Error processing event ${X.event}:`,Y)}if(this.queue.length>0)setTimeout(()=>this.processQueue(),0);this.isProcessing=!1}getQueueLength(){return this.queue.length}}class A6{store=new Map;async loadState(){return new Map(this.store)}async saveState(Q,X){this.store.set(Q,X)}async deleteState(Q){this.store.delete(Q)}async clearState(){this.store.clear()}}class bQ{keyPrefix;cache=new Map;isLoaded=!1;constructor(Q="trigger_system:"){this.keyPrefix=Q}isAvailable(){return typeof window<"u"&&typeof window.localStorage<"u"}ensureLoaded(){if(this.isLoaded)return;if(this.isAvailable())try{let Q=window.localStorage.getItem(this.keyPrefix+"state");if(Q){let X=JSON.parse(Q);this.cache=new Map(Object.entries(X))}}catch(Q){console.error("[BrowserPersistence] Failed to load from localStorage:",Q)}this.isLoaded=!0}persist(){if(this.isAvailable())try{let Q=Object.fromEntries(this.cache);window.localStorage.setItem(this.keyPrefix+"state",JSON.stringify(Q))}catch(Q){console.error("[BrowserPersistence] Failed to save to localStorage:",Q)}}async loadState(){return this.ensureLoaded(),new Map(this.cache)}async saveState(Q,X){this.ensureLoaded(),this.cache.set(Q,X),this.persist()}async deleteState(Q){this.ensureLoaded(),this.cache.delete(Q),this.persist()}async clearState(){this.cache.clear(),this.persist()}}class W1{static instance;state;persistence;constructor(){this.state=new Map,this.persistence=new A6}static getInstance(){if(!W1.instance)W1.instance=new W1;return W1.instance}setPersistence(Q){this.persistence=Q}async initialize(){let Q=await this.persistence.loadState();this.state=Q,console.log(`[StateManager] Initialized with ${this.state.size} keys.`)}get(Q){return this.state.get(Q)}async set(Q,X){this.state.set(Q,X),await this.persistence.saveState(Q,X)}async increment(Q,X=1){let Y=this.get(Q)||0,U=Number(Y)+X;return await this.set(Q,U),U}async decrement(Q,X=1){return this.increment(Q,-X)}async delete(Q){let X=this.state.delete(Q);if(X)await this.persistence.deleteState(Q);return X}async clear(){this.state.clear(),await this.persistence.clearState()}getAll(){return Object.fromEntries(this.state)}}class j2{static instance;handlers=new Map;constructor(){this.registerDefaults()}static getInstance(){if(!this.instance)this.instance=new j2;return this.instance}register(Q,X){this.handlers.set(Q.toUpperCase(),X)}get(Q){return this.handlers.get(Q.toUpperCase())}registerDefaults(){this.register("log",(Q,X)=>{let Y=Q.params?.message||Q.params?.content||"Log Trigger",U=u.interpolate(Y,X);return console.log(`[TriggerLog] ${U}`),{message:U}}),this.register("response",(Q,X)=>{let Y=Q.params?.content||Q.params?.body||"",U=u.interpolate(Y,X);return{statusCode:Q.params?.statusCode||200,headers:Q.params?.headers||{"Content-Type":"application/json"},body:U}}),this.register("execute",async(Q,X)=>{let Y=Q.params?.command||Q.params?.content||"",U=u.interpolate(Y,X);if(!Q.params?.safe)console.warn(`[Trigger] Ejecutando comando no seguro: ${U}`);try{let Z=Bun.spawn(U.split(" "),{stdout:"pipe",stderr:"pipe"}),[W,G]=await Promise.all([new Response(Z.stdout).text(),new Response(Z.stderr).text()]);return{command:U,stdout:W,stderr:G,exitCode:await Z.exited}}catch(Z){return{command:U,error:String(Z)}}}),this.register("forward",async(Q,X)=>{let Y=Q.params?.url||"",U=u.interpolate(Y,X),Z=Q.params?.method||"POST";try{let W=await fetch(U,{method:Z,headers:{"Content-Type":"application/json",...Q.params?.headers},body:JSON.stringify(X.data)});return{url:U,method:Z,status:W.status,headers:(()=>{let G={};return W.headers.forEach((L,J)=>G[J]=L),G})(),body:await W.text()}}catch(W){return{url:U,method:Z,error:String(W)}}}),this.register("STATE_SET",async(Q,X)=>{let Y=Q.params?.key,U=Q.params?.value;if(!Y)return{error:"Missing key for STATE_SET"};let Z=U;if(typeof U==="string"&&U.includes("${"))Z=u.interpolate(U,X);return await W1.getInstance().set(Y,Z),{key:Y,value:Z}}),this.register("STATE_INCREMENT",async(Q,X)=>{let Y=Q.params?.key,U=Number(Q.params?.amount)||1;if(!Y)return{error:"Missing key for STATE_INCREMENT"};let Z=await W1.getInstance().increment(Y,U);return{key:Y,newValue:Z}}),this.register("EMIT_EVENT",(Q,X)=>{return{event:Q.params?.event,payload:Q.params?.data||{}}})}}class aY{static create(Q,X,Y={}){return{event:Q,timestamp:Date.now(),data:typeof X==="object"?X:{value:X},globals:Y,helpers:this.getDefaultHelpers()}}static fromRequest(Q,X,Y={}){let U=new URL(Q.url);return{event:"HTTP_REQUEST",timestamp:Date.now(),data:{method:Q.method,path:U.pathname,query:Object.fromEntries(U.searchParams),headers:(()=>{let Z={};return Q.headers.forEach((W,G)=>Z[G]=W),Z})(),body:X||{}},globals:{...Y,ip:Q.headers.get("x-forwarded-for")||"unknown"},helpers:this.getDefaultHelpers()}}static fromWebhook(Q,X,Y,U={}){return{event:`WEBHOOK_${Q.toUpperCase()}_${X.toUpperCase()}`,timestamp:Date.now(),data:Y,globals:{...U,provider:Q},helpers:this.getDefaultHelpers()}}static getDefaultHelpers(){return{now:()=>Date.now(),uuid:()=>crypto.randomUUID(),jsonParse:(Q)=>JSON.parse(Q),jsonStringify:(Q)=>JSON.stringify(Q)}}}class $6{static instance;handlers=new Map;constructor(){}static getInstance(){if(!this.instance)this.instance=new $6;return this.instance}on(Q,X){let Y=Q;if(!this.handlers.has(Y))this.handlers.set(Y,new Set);return this.handlers.get(Y).add(X),()=>this.off(Y,X)}off(Q,X){let Y=Q,U=this.handlers.get(Y);if(U)U.delete(X)}emit(Q,X){let Y=Q,U=this.handlers.get(Y);if(U)U.forEach((Z)=>{try{Z(X)}catch(W){console.error(`Error in event handler for ${Y}:`,W)}})}}var y1=$6.getInstance();class eY{rules=[];config;lastExecutionTimes=new Map;actionRegistry;constructor(Q){this.config=Q,this.rules=[...Q.rules],this.rules.sort((X,Y)=>(Y.priority||0)-(X.priority||0)),this.actionRegistry=j2.getInstance()}async processEvent(Q,X={},Y={}){let U={event:Q,data:X,globals:Y,timestamp:Date.now(),state:{}};return this.evaluateContext(U)}async evaluateContext(Q){let X=[];if(Q.state=W1.getInstance().getAll(),this.config.globalSettings.debugMode)console.log(`[RuleEngine] Evaluando contexto con ${this.rules.length} reglas para evento: ${Q.event}`);y1.emit("engine:start",{context:Q,rulesCount:this.rules.length});for(let Y of this.rules){if(Y.enabled===!1)continue;if(Y.on!==Q.event)continue;if(Y.cooldown&&!this.checkCooldown(Y.id,Y.cooldown)){if(this.config.globalSettings.debugMode)console.log(`[RuleEngine] Regla ${Y.id} en cooldown`);continue}if(this.evaluateRuleConditions(Y.if,Q)){if(this.config.globalSettings.debugMode)console.log(`[RuleEngine] Ejecutando regla: ${Y.name||Y.id}`);y1.emit("rule:match",{rule:Y,context:Q});let Z=await this.executeRuleActions(Y.do,Q);if(X.push({ruleId:Y.id,executedActions:Z,success:!0}),this.lastExecutionTimes.set(Y.id,Date.now()),!this.config.globalSettings.evaluateAll)break}}return y1.emit("engine:done",{results:X,context:Q}),X}evaluateRuleConditions(Q,X){if(!Q)return!0;if(Array.isArray(Q))return Q.every((Y)=>this.evaluateRecursiveCondition(Y,X));else return this.evaluateRecursiveCondition(Q,X)}evaluateRecursiveCondition(Q,X){if("conditions"in Q&&"operator"in Q)return this.evaluateConditionGroup(Q,X);else return this.evaluateSingleCondition(Q,X)}evaluateConditionGroup(Q,X){if(Q.operator==="OR")return Q.conditions.some((Y)=>this.evaluateRecursiveCondition(Y,X));else return Q.conditions.every((Y)=>this.evaluateRecursiveCondition(Y,X))}evaluateSingleCondition(Q,X){try{let Y=u.getNestedValue(Q.field,X),U=Q.value;if(typeof U==="string"&&(U.includes("${")||U.startsWith("data.")||U.startsWith("globals.")))U=u.evaluate(U,X);let Z=(G)=>{if(G instanceof Date)return G.getTime();if(typeof G==="number")return G;let L=new Date(G);return isNaN(L.getTime())?0:L.getTime()},W=(G)=>{if(typeof G==="number")return G;if(G===null||G===void 0||G==="")return null;let L=Number(G);return isNaN(L)?null:L};switch(Q.operator){case"EQ":case"==":return Y==U;case"NEQ":case"!=":return Y!=U;case"GT":case">":{let G=W(Y),L=W(U);return G!==null&&L!==null&&G>L}case"GTE":case">=":{let G=W(Y),L=W(U);return G!==null&&L!==null&&G>=L}case"LT":case"<":{let G=W(Y),L=W(U);return G!==null&&L!==null&&G<L}case"LTE":case"<=":{let G=W(Y),L=W(U);return G!==null&&L!==null&&G<=L}case"CONTAINS":return String(Y).includes(String(U));case"MATCHES":return new RegExp(String(U)).test(String(Y));case"IN":return Array.isArray(U)&&U.includes(Y);case"NOT_IN":return Array.isArray(U)&&!U.includes(Y);case"SINCE":case"AFTER":return Z(Y)>=Z(U);case"BEFORE":case"UNTIL":return Z(Y)<Z(U);case"RANGE":if(Array.isArray(U)&&U.length===2){let G=W(Y);return G!==null&&G>=Number(U[0])&&G<=Number(U[1])}return!1;default:return console.error(`Operador desconocido: ${Q.operator}`),!1}}catch(Y){return console.error("Error evaluando condición:",Q,Y),!1}}async executeRuleActions(Q,X){let Y=[],U=[],Z="ALL";if(this.isActionGroup(Q))U=Q.actions,Z=Q.mode;else if(Array.isArray(Q))U=Q;else U=[Q];if(Z==="EITHER"&&U.length>0){let W=Math.floor(Math.random()*U.length),G=U[W];if(G)U=[G]}if(Z==="SEQUENCE")for(let W of U){let G=await this.executeSingleAction(W,X);Y.push(G)}else for(let W of U){let G=await this.executeSingleAction(W,X);Y.push(G)}return Y}isActionGroup(Q){return"mode"in Q&&"actions"in Q}async executeSingleAction(Q,X){if(Q.probability!==void 0&&Math.random()>Q.probability)return{type:Q.type,timestamp:Date.now(),result:{skipped:"probability check failed"}};if(Q.delay&&Q.delay>0)await new Promise((Y)=>setTimeout(Y,Q.delay));try{let Y=this.actionRegistry.get(Q.type),U;if(Y)U=await Y(Q,X);else{let Z=`Tipo de acción genérica o desconocida: ${Q.type}`;if(this.config.globalSettings.strictActions)throw Error(Z);console.warn(Z),U={warning:`Generic action executed: ${Q.type}`}}return y1.emit("action:success",{action:Q,context:X,result:U}),{type:Q.type,result:U,timestamp:Date.now()}}catch(Y){return console.error("Error ejecutando acción:",Q,Y),y1.emit("action:error",{action:Q,context:X,error:String(Y)}),{type:Q.type,error:String(Y),timestamp:Date.now()}}}checkCooldown(Q,X){let Y=this.lastExecutionTimes.get(Q);if(!Y)return!0;return Date.now()-Y>X}updateRules(Q){this.rules=[...Q],this.rules.sort((X,Y)=>(Y.priority||0)-(X.priority||0))}getRules(){return[...this.rules]}}class b2{static getNestedValue(Q,X){let Y=Q.split("."),U=X;for(let Z of Y){if(U===null||U===void 0)return;U=U[Z]}return U}static interpolate(Q,X){if(typeof Q!=="string")return Q;return Q.replace(/\$\{([^}]+)\}/g,(Y,U)=>{let Z=this.getNestedValue(U,X);if(Z!==void 0)return String(Z);return Y})}static compare(Q,X,Y){switch(X){case"EQ":case"==":return Q==Y;case"NEQ":case"!=":return Q!=Y;case"GT":case">":return Number(Q)>Number(Y);case"GTE":case">=":return Number(Q)>=Number(Y);case"LT":case"<":return Number(Q)<Number(Y);case"LTE":case"<=":return Number(Q)<=Number(Y);case"IN":return Array.isArray(Y)&&Y.includes(Q);case"NOT_IN":return Array.isArray(Y)&&!Y.includes(Q);case"CONTAINS":if(Array.isArray(Q)||typeof Q==="string")return Q.includes(Y);return!1;case"MATCHES":return new RegExp(Y).test(String(Q));case"RANGE":if(Array.isArray(Y)&&Y.length===2){let U=Number(Q);return U>=Y[0]&&U<=Y[1]}return!1;default:return console.warn(`Unknown operator: ${X}`),!1}}}class QU{rules=[];actionHandlers=new Map;lastExecution=new Map;constructor(Q=[]){this.rules=Q,this.sortRules()}sortRules(){this.rules.sort((Q,X)=>(X.priority||0)-(Q.priority||0))}registerAction(Q,X){this.actionHandlers.set(Q,X)}async processEvent(Q){let X=[],Y=this.rules.filter((U)=>U.enabled!==!1&&U.on===Q.event);for(let U of Y){if(U.cooldown&&this.checkCooldown(U.id,U.cooldown))continue;if(this.evaluateConditions(U.if,Q)){let Z=await this.executeRuleActions(U.do,Q);this.lastExecution.set(U.id,Date.now()),X.push({ruleId:U.id,success:!0,executedActions:Z})}}return X}checkCooldown(Q,X){let Y=this.lastExecution.get(Q);if(!Y)return!1;return Date.now()-Y<X}evaluateConditions(Q,X){if(!Q)return!0;if(Array.isArray(Q))return Q.every((Y)=>this.evaluateSingleCondition(Y,X));return this.evaluateSingleCondition(Q,X)}evaluateSingleCondition(Q,X){if("operator"in Q&&"conditions"in Q){let W=Q;if(W.operator==="OR")return W.conditions.some((G)=>this.evaluateSingleCondition(G,X));else return W.conditions.every((G)=>this.evaluateSingleCondition(G,X))}let Y=Q,U=b2.getNestedValue(Y.field,X),Z=Y.value;if(typeof Z==="string"&&Z.includes("${"))Z=u.interpolate(Z,X);return b2.compare(U,Y.operator,Z)}async executeRuleActions(Q,X){let Y=[],U=[],Z="ALL";if(Array.isArray(Q))U=Q;else if("mode"in Q&&"actions"in Q){let W=Q;Z=W.mode,U=W.actions}else U=[Q];if(Z==="EITHER"){let W=U.reduce((J,_)=>J+(_.probability||1),0),G=Math.random()*W,L;for(let J of U){let _=J.probability||1;if(G-=_,G<=0){L=J;break}}if(!L&&U.length>0)L=U[U.length-1];if(L)U=[L];else U=[]}for(let W of U){let G=this.interpolateParams(W.params||{},X),L=this.actionHandlers.get(W.type);if(L)try{if(W.delay&&W.delay>0)await new Promise((_)=>setTimeout(_,W.delay));let J=await L(G,X);Y.push({type:W.type,result:J,timestamp:Date.now()})}catch(J){console.error(`Action ${W.type} failed:`,J),Y.push({type:W.type,error:J,timestamp:Date.now()})}else console.warn(`No handler registered for action type: ${W.type}`),Y.push({type:W.type,error:"No handler registered",timestamp:Date.now()})}return Y}interpolateParams(Q,X){let Y={};for(let[U,Z]of Object.entries(Q))if(typeof Z==="string")Y[U]=u.interpolate(Z,X);else if(typeof Z==="object"&&Z!==null)Y[U]=this.interpolateDeep(Z,X);else Y[U]=Z;return Y}interpolateDeep(Q,X){if(typeof Q==="string")return u.interpolate(Q,X);if(Array.isArray(Q))return Q.map((Y)=>this.interpolateDeep(Y,X));if(typeof Q==="object"&&Q!==null){let Y={};for(let U in Q)Y[U]=this.interpolateDeep(Q[U],X);return Y}return Q}}var V1=(Q)=>Array.isArray(Q)?Q:[Q],fQ=(Q,X)=>{let Y=[[],[]];for(let U of Q)if(X(U))Y[0].push(U);else Y[1].push(U);return Y},f2=Array,s=(Q,X)=>Q.includes(X),yQ=(Q,X=0)=>[...Array(Q)].map((Y,U)=>U+X),R=(Q,X,Y)=>{if(Q===void 0)return X===void 0?[]:Array.isArray(X)?X:[X];if(Y?.prepend)if(Array.isArray(X))Q.unshift(...X);else Q.unshift(X);else if(Array.isArray(X))Q.push(...X);else Q.push(X);return Q},F1=(Q,X)=>{if(X===void 0||X===null)return Q??[];if(Q===void 0||Q===null)return V1(X);return Q.concat(X)},vQ=(...Q)=>Q.reduce(F1,[]),G1=(Q,X,Y)=>{if(Q===void 0)return Array.isArray(X)?X:[X];let U=Y?.isEqual??((Z,W)=>Z===W);for(let Z of V1(X))if(!Q.some((W)=>U(W,Z)))Q.push(Z);return Q},gQ=(Q,X)=>Q.reduce((Y,U)=>{let Z=U[X];return Y[Z]=R(Y[Z],U),Y},{}),q1=(Q,X,Y)=>Q.length===X.length&&Q.every(Y?.isEqual?(U,Z)=>Y.isEqual(U,X[Z]):(U,Z)=>U===X[Z]);var p=(Q,X)=>f(Q)===X,f=(Q)=>{let X=typeof Q;return X==="object"?Q===null?"null":"object":X==="function"?"object":X},m={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},kQ={...m,function:"a function"};class xQ extends Error{}var D=(Q)=>K1(Q,xQ),K1=(Q,X=Error)=>{throw new X(Q)};class X2 extends Error{name="ParseError"}var H=(Q)=>K1(Q,X2),Q1=(Q)=>` ${Q}`,hQ="";var V=(Q,X)=>{let Y={},U=Array.isArray(Q),Z=!1;for(let[W,G]of Object.entries(Q).entries()){let L=U?X(W,G[1]):X(...G,W);Z||=typeof L[0]==="number";let J=Array.isArray(L[0])||L.length===0?L:[L];for(let[_,A]of J)if(typeof _==="object")Y[_.group]=R(Y[_.group],A);else Y[_]=A}return Z?Object.values(Y):Y};var z6=Object.entries;var y=(Q,X)=>(Q in X),v1=(Q,X)=>(X in Q);class O6{constructor(Q){Object.assign(this,Q)}}var uQ=class{};class Y2 extends uQ{}var XU=(Q,X)=>{let Y={},U={},Z;for(Z in Q)if(Z in X)Y[Z]=Q[Z];else U[Z]=Q[Z];return[Y,U]};var y2=(Q,X)=>XU(Q,X)[1],L1=(Q)=>Object.keys(Q).length===0,N1=(Q)=>[...Object.entries(Q),...Object.getOwnPropertySymbols(Q).map((X)=>[X,Q[X]])],pQ=(Q,X)=>Object.defineProperties(Q,Object.getOwnPropertyDescriptors(X)),mQ=(Q)=>{let X=Object.keys(Q).sort(),Y={};for(let U=0;U<X.length;U++)Y[X[U]]=Q[X[U]];return Y};var l=Q1(`unset${hQ}`),lQ=(Q)=>Object.values(Q).filter((X)=>{if(typeof X==="number")return!0;return typeof Q[X]!=="number"});var V6={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},T6=globalThis.File??Blob,B6={ArrayBuffer,Blob,File:T6,FormData,Headers,Request,Response,URL},YU={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},P1={...V6,...B6,...YU,String,Number,Boolean},U2=(Q)=>{let X=Object.getPrototypeOf(Q);while(X?.constructor&&(!y(X.constructor.name,P1)||!(Q instanceof P1[X.constructor.name])))X=Object.getPrototypeOf(X);let Y=X?.constructor?.name;if(Y===void 0||Y==="Object")return;return Y},Z2=(Q)=>typeof Q==="object"&&Q!==null?U2(Q)??"object":f(Q);var K=Array.isArray,UU={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"},ZU={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"},WU={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"},dQ={...UU,...ZU,...WU},W2=(Q)=>{let X=Object(Q).name??null;return X&&y(X,P1)&&P1[X]===Q?X:null};var M6=(Q,X)=>{let Y=Q.prototype;while(Y!==null){if(Y===X.prototype)return!0;Y=Object.getPrototypeOf(Y)}return!1};var oQ=(Q)=>cQ(Q,new Map),cQ=(Q,X)=>{if(typeof Q!=="object"||Q===null)return Q;if(X?.has(Q))return X.get(Q);let Y=W2(Q.constructor);if(Y==="Date")return new Date(Q.getTime());if(Y&&Y!=="Array")return Q;let U=Array.isArray(Q)?Q.slice():Object.create(Object.getPrototypeOf(Q)),Z=Object.getOwnPropertyDescriptors(Q);if(X){X.set(Q,U);for(let W in Z){let G=Z[W];if("get"in G||"set"in G)continue;G.value=cQ(G.value,X)}}return Object.defineProperties(U,Z),U};var GU=(Q)=>{let X=l;return()=>X===l?X=Q():X},T1=(Q)=>typeof Q==="function"&&Q.length===0;var iQ=class extends Function{constructor(...Q){let X=Q.slice(0,-1),Y=Q[Q.length-1];try{super(...X,Y)}catch(U){return D(`Encountered an unexpected error while compiling your definition:
|
|
2
|
+
Message: ${U}
|
|
3
|
+
Source: (${Q.slice(0,-1)}) => {
|
|
4
|
+
${Q[Q.length-1]}
|
|
5
|
+
}`)}}};class d{constructor(Q,...[X]){return Object.assign(Object.setPrototypeOf(Q.bind(X?.bind??this),this.constructor.prototype),X?.attach)}}var nQ=GU(()=>{try{return Function("return false")()}catch{return!0}});var a9=Q1("brand");var sQ=Q1("arkInferred");var X0=Q1("args");class g{constructor(){}}var LU=()=>{try{return((Error().stack?.split(`
|
|
6
|
+
`)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},_U=globalThis.process?.env??{},rQ={fileName:LU,env:_U};var tQ=(Q)=>Q[0].toUpperCase()+Q.slice(1),aQ=(Q)=>Q[0].toLowerCase()+Q.slice(1),R6=(Q)=>new RegExp(JU(Q),typeof Q==="string"?"":Q.flags);var JU=(Q)=>{return`^(?:${typeof Q==="string"?Q:Q.source})$`};var A1={negativeLookahead:(Q)=>`(?!${Q})`,nonCapturingGroup:(Q)=>`(?:${Q})`},E1="\\",B1={" ":1,"\n":1,"\t":1};var HU=/^-0\.?0*$/.source,Q4=/[1-9]\d*/.source,FU=/\.\d+/.source,qU=/\.\d*[1-9]/.source,X4=(Q)=>R6(A1.negativeLookahead(HU)+A1.nonCapturingGroup("-?"+A1.nonCapturingGroup(A1.nonCapturingGroup("0|"+Q4)+A1.nonCapturingGroup(Q.decimalPattern)+"?")+(Q.allowDecimalOnly?"|"+Q.decimalPattern:"")+"?")),eQ=X4({decimalPattern:qU,allowDecimalOnly:!1}),AU=eQ.test.bind(eQ),v2=X4({decimalPattern:FU,allowDecimalOnly:!0}),_0=v2.test.bind(v2),$U=/^-?\d*\.?\d*$/,zU=(Q)=>Q.length!==0&&$U.test(Q),G2=R6(A1.negativeLookahead("^-0$")+"-?"+A1.nonCapturingGroup(A1.nonCapturingGroup("0|"+Q4))),OU=G2.test.bind(G2),C6=/^-?\d+$/,VU=C6.test.bind(C6),Y4={number:"a number",bigint:"a bigint",integer:"an integer"},U4=(Q,X)=>`'${Q}' was parsed as ${Y4[X]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,TU=(Q,X)=>X==="number"?AU(Q):OU(Q),BU=(Q,X)=>X==="number"?Number(Q):Number.parseInt(Q),MU=(Q,X)=>X==="number"?zU(Q):VU(Q),Z4=(Q,X)=>D6(Q,"number",X),W4=(Q,X)=>D6(Q,"number",{...X,strict:!0}),G4=(Q,X)=>D6(Q,"integer",X),D6=(Q,X,Y)=>{let U=BU(Q,X);if(!Number.isNaN(U)){if(MU(Q,X)){if(Y?.strict)return TU(Q,X)?U:H(U4(Q,X));return U}}return Y?.errorOnFail?H(Y?.errorOnFail===!0?`Failed to parse ${Y4[X]} from '${Q}'`:Y?.errorOnFail):void 0},L4=(Q)=>{if(Q[Q.length-1]!=="n")return;let X=Q.slice(0,-1),Y;try{Y=BigInt(X)}catch{return}if(G2.test(X))return Y;if(C6.test(X))return H(U4(Q,"bigint"))};var RU="0.56.0",CU={version:RU,filename:rQ.fileName(),FileConstructor:T6},I1=CU,_4=new Map,w6=Object.create(null),L2=(Q)=>{let X=_4.get(Q);if(X)return X;let Y=DU(Q);if(w6[Y])Y=`${Y}${w6[Y]++}`;else w6[Y]=1;return I1[Y]=Q,_4.set(Q,Y),Y},M1=(Q)=>/^[$A-Z_a-z][\w$]*$/.test(Q),DU=(Q)=>{switch(typeof Q){case"object":{if(Q===null)break;let X=U2(Q)??"object";return X[0].toLowerCase()+X.slice(1)}case"function":return M1(Q.name)?Q.name:"fn";case"symbol":return Q.description&&M1(Q.description)?Q.description:"symbol"}return D(`Unexpected attempt to register serializable value of type ${f(Q)}`)};var _2=(Q)=>typeof Q==="string"?JSON.stringify(Q):typeof Q==="bigint"?`${Q}n`:`${Q}`;var J4=(Q,X={})=>J2(Q,{onUndefined:"$ark.undefined",onBigInt:(Y)=>`$ark.bigint-${Y}`,...X},[]);var T=(Q,X)=>{switch(f(Q)){case"object":let Y=Q,U=Y.constructor?.name??"Object";return U==="Object"||U==="Array"?X?.quoteKeys===!1?g2(Y,X?.indent??0,""):JSON.stringify(J2(Y,g1,[]),null,X?.indent):g2(Y,X?.indent??0,"");case"symbol":return g1.onSymbol(Q);default:return _2(Q)}},g2=(Q,X,Y)=>{if(typeof Q==="function")return g1.onFunction(Q);if(typeof Q!=="object"||Q===null)return _2(Q);let U=Y+" ".repeat(X);if(Array.isArray(Q)){if(Q.length===0)return"[]";let W=Q.map((G)=>g2(G,X,U)).join(`,
|
|
7
|
+
`+U);return X?`[
|
|
8
|
+
${U}${W}
|
|
9
|
+
${Y}]`:`[${W}]`}let Z=Q.constructor?.name??"Object";if(Z==="Object"){let W=N1(Q).map(([G,L])=>{let J=typeof G==="symbol"?g1.onSymbol(G):M1(G)?G:JSON.stringify(G),_=g2(L,X,U);return`${U}${J}: ${_}`});if(W.length===0)return"{}";return X?`{
|
|
10
|
+
${W.join(`,
|
|
11
|
+
`)}
|
|
12
|
+
${Y}}`:`{${W.join(", ")}}`}if(Q instanceof Date)return S1(Q);if("expression"in Q&&typeof Q.expression==="string")return Q.expression;return Z},g1={onCycle:()=>"(cycle)",onSymbol:(Q)=>`Symbol(${L2(Q)})`,onFunction:(Q)=>`Function(${L2(Q)})`},J2=(Q,X,Y)=>{switch(f(Q)){case"object":{let U=Q;if("toJSON"in U&&typeof U.toJSON==="function")return U.toJSON();if(typeof U==="function")return g1.onFunction(U);if(Y.includes(U))return"(cycle)";let Z=[...Y,U];if(Array.isArray(U))return U.map((G)=>J2(G,X,Z));if(U instanceof Date)return U.toDateString();let W={};for(let G in U)W[G]=J2(U[G],X,Z);for(let G of Object.getOwnPropertySymbols(U))W[X.onSymbol?.(G)??G.toString()]=J2(U[G],X,Z);return W}case"symbol":return g1.onSymbol(Q);case"bigint":return X.onBigInt?.(Q)??`${Q}n`;case"undefined":return X.onUndefined??"undefined";case"string":return Q.replace(/\\/g,"\\\\");default:return Q}},S1=(Q)=>{let X=Q.getFullYear(),Y=Q.getMonth(),U=Q.getDate(),Z=Q.getHours(),W=Q.getMinutes(),G=Q.getSeconds(),L=Q.getMilliseconds();if(Y===0&&U===1&&Z===0&&W===0&&G===0&&L===0)return`${X}`;let J=`${wU[Y]} ${U}, ${X}`;if(Z===0&&W===0&&G===0&&L===0)return J;let _=Q.toLocaleTimeString(),A=_.endsWith(" AM")||_.endsWith(" PM")?_.slice(-3):"";if(A)_=_.slice(0,-A.length);if(L)_+=`.${NU(L,3)}`;else if(KU.test(_))_=_.slice(0,-3);return`${_+A}, ${J}`},wU=["January","February","March","April","May","June","July","August","September","October","November","December"],KU=/:\d\d:00$/,NU=(Q,X)=>String(Q).padStart(X,"0");var H4=(Q,X,...[Y])=>{let U=Y?.stringifySymbol??T,Z=Q;switch(typeof X){case"string":Z=M1(X)?Q===""?X:`${Q}.${X}`:`${Q}[${JSON.stringify(X)}]`;break;case"number":Z=`${Q}[${X}]`;break;case"symbol":Z=`${Q}[${U(X)}]`;break;default:if(Y?.stringifyNonKey)Z=`${Q}[${Y.stringifyNonKey(X)}]`;else H(`${T(X)} must be a PropertyKey or stringifyNonKey must be passed to options`)}return Z},$1=(Q,...X)=>Q.reduce((Y,U)=>H4(Y,U,...X),"");class H2 extends f2{cache={};constructor(...Q){super();this.push(...Q)}toJSON(){if(this.cache.json)return this.cache.json;this.cache.json=[];for(let Q=0;Q<this.length;Q++)this.cache.json.push(typeof this[Q]==="symbol"?T(this[Q]):this[Q]);return this.cache.json}stringify(){if(this.cache.stringify)return this.cache.stringify;return this.cache.stringify=$1(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let Q="",X=[Q];for(let Y of this)Q=H4(Q,Y),X.push(Q);return this.cache.stringifyAncestors=X}}class F2{chars;i;def;constructor(Q){this.def=Q,this.chars=[...Q],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(Q){let X="";while(this.lookahead)if(Q(this,X))break;else X+=this.shift();return X}shiftUntilEscapable(Q){let X="";while(this.lookahead)if(this.lookahead===E1)if(this.shift(),Q(this,X))X+=this.shift();else if(this.lookahead===E1)X+=this.shift();else X+=`${E1}${this.shift()}`;else if(Q(this,X))break;else X+=this.shift();return X}shiftUntilLookahead(Q){return typeof Q==="string"?this.shiftUntil((X)=>X.lookahead===Q):this.shiftUntil((X)=>(X.lookahead in Q))}shiftUntilNonWhitespace(){return this.shiftUntil(()=>!(this.lookahead in B1))}jumpToIndex(Q){this.i=Q<0?this.length+Q:Q}jumpForward(Q){this.i+=Q}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(Q,X){return this.chars.slice(Q,X).join("")}lookaheadIs(Q){return this.lookahead===Q}lookaheadIsIn(Q){return this.lookahead in Q}}var F4=(Q,X)=>`Unmatched ${Q}${X===""?"":` before ${X}`}`,k2=(Q)=>`Missing ${Q}`;var f0=Q1("implementedTraits");var K6="$ark",PU=2;while(K6 in globalThis)K6=`$ark${PU++}`;var q4=K6;globalThis[q4]=I1;var F=I1,EU=(Q)=>`${q4}.${Q}`,S=(Q)=>EU(L2(Q));class x2 extends Y2{argNames;body="";constructor(...Q){super();this.argNames=Q;for(let X of Q){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(Q,X=!1){return N6(Q,X)}index(Q,X=!1){return A4(`${Q}`,X)}line(Q){return this.body+=`${" ".repeat(this.indentation)}${Q}
|
|
13
|
+
`,this}const(Q,X){return this.line(`const ${Q} = ${X}`),this}let(Q,X){return this.line(`let ${Q} = ${X}`)}set(Q,X){return this.line(`${Q} = ${X}`)}if(Q,X){return this.block(`if (${Q})`,X)}elseIf(Q,X){return this.block(`else if (${Q})`,X)}else(Q){return this.block("else",Q)}for(Q,X,Y=0){return this.block(`for (let i = ${Y}; ${Q}; i++)`,X)}forIn(Q,X){return this.block(`for (const k in ${Q})`,X)}block(Q,X,Y=""){return this.line(`${Q} {`),this.indent(),X(this),this.dedent(),this.line(`}${Y}`)}return(Q=""){return this.line(`return ${Q}`)}write(Q="anonymous",X=0){return`${Q}(${this.argNames.join(", ")}) { ${X?this.body.split(`
|
|
14
|
+
`).map((Y)=>" ".repeat(X)+`${Y}`).join(`
|
|
15
|
+
`):this.body} }`}compile(){return new iQ(...this.argNames,this.body)}}var X1=(Q)=>p(Q,"object")||typeof Q==="symbol"?S(Q):_2(Q),N6=(Q,X=!1)=>{if(typeof Q==="string"&&M1(Q))return`${X?"?":""}.${Q}`;return A4(IU(Q),X)},IU=(Q)=>typeof Q==="symbol"?S(Q):JSON.stringify(Q),A4=(Q,X=!1)=>`${X?"?.":""}[${Q}]`;class q2 extends x2{traversalKind;optimistic;constructor(Q){super("data","ctx");this.traversalKind=Q.kind,this.optimistic=Q.optimistic===!0}invoke(Q,X){let Y=X?.arg??this.data,U=typeof Q==="string"?!0:this.requiresContextFor(Q),Z=typeof Q==="string"?Q:Q.id;if(U)return`${this.referenceToId(Z,X)}(${Y}, ${this.ctx})`;return`${this.referenceToId(Z,X)}(${Y})`}referenceToId(Q,X){let Y=X?.kind??this.traversalKind,U=`this.${Q}${Y}`;return X?.bind?`${U}.bind(${X?.bind})`:U}requiresContextFor(Q){return this.traversalKind==="Apply"||Q.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(Q,X,Y){let U=this.requiresContextFor(Y);if(U)this.line(`${this.ctx}.path.push(${Q})`);if(this.check(Y,{arg:X}),U)this.line(`${this.ctx}.path.pop()`);return this}check(Q,X){return this.traversalKind==="Allows"?this.if(`!${this.invoke(Q,X)}`,()=>this.return(!1)):this.line(this.invoke(Q,X))}}var h2=(Q)=>V(Q,(X,Y)=>[X,K(Y)?[...Y]:Y]),x=Q1("arkKind"),$=(Q,X)=>Q?.[x]===X,N=(Q)=>$(Q,"root")||$(Q,"constraint");var $4=["unit","proto","domain"],k1=["required","optional","index","sequence"],P6=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],E6=[...P6,"structure","predicate"],u2=[...E6,...k1],x1=["alias","union","morph","unit","intersection","proto","domain"],SU=[...x1,...u2],p2=V(u2,(Q,X)=>[X,1]),z4=V([...k1,"undeclared"],(Q,X)=>[X,1]),O4=V(SU,(Q,X)=>[X,Q]),h1=(Q)=>typeof Q==="string"&&(Q in O4);var u1=(Q)=>O4[Q],m2=(Q)=>x1.slice(u1(Q)+1),OW=[...m2("union"),"alias"],VW=[...m2("morph"),"alias"],r=(Q)=>{if(typeof Q==="string"||typeof Q==="boolean"||Q===null)return Q;if(typeof Q==="number"){if(Number.isNaN(Q))return"NaN";if(Q===Number.POSITIVE_INFINITY)return"Infinity";if(Q===Number.NEGATIVE_INFINITY)return"-Infinity";return Q}return X1(Q)},R1=(Q)=>{let X="{ ";for(let[Y,U]of Object.entries(Q))X+=`${Y}: ${X1(U)}, `;return X+" }"},B=(Q)=>{let X=Q;if(X.hasAssociatedError)X.defaults.expected??=(Y)=>("description"in Y)?Y.description:X.defaults.description(Y),X.defaults.actual??=(Y)=>T(Y),X.defaults.problem??=(Y)=>`must be ${Y.expected}${Y.actual?` (was ${Y.actual})`:""}`,X.defaults.message??=(Y)=>{if(Y.path.length===0)return Y.problem;let U=`${Y.propString} ${Y.problem}`;if(U[0]==="[")return`value at ${U}`;return U};return X};class V4 extends Error{name="ToJsonSchemaError";code;context;constructor(Q,X){super(T(X,{quoteKeys:!1,indent:4}));this.code=Q,this.context=X}hasCode(Q){return this.code===Q}}var jU={target:"draft-2020-12",dialect:"https://json-schema.org/draft/2020-12/schema",useRefs:!1,fallback:{arrayObject:(Q)=>E.throw("arrayObject",Q),arrayPostfix:(Q)=>E.throw("arrayPostfix",Q),defaultValue:(Q)=>E.throw("defaultValue",Q),domain:(Q)=>E.throw("domain",Q),morph:(Q)=>E.throw("morph",Q),patternIntersection:(Q)=>E.throw("patternIntersection",Q),predicate:(Q)=>E.throw("predicate",Q),proto:(Q)=>E.throw("proto",Q),symbolKey:(Q)=>E.throw("symbolKey",Q),unit:(Q)=>E.throw("unit",Q),date:(Q)=>E.throw("date",Q)}},E={Error:V4,throw:(...Q)=>{throw new E.Error(...Q)},throwInternalOperandError:(Q,X)=>D(`Unexpected JSON Schema input for ${Q}: ${T(X)}`),defaultConfig:jU};F.config??={};var A2=(Q,X)=>{if(!X)return Q;let Y={...Q},U;for(U in X){let Z={...Q.keywords};if(U==="keywords"){for(let W in X[U]){let G=X.keywords[W];if(G===void 0)continue;Z[W]=typeof G==="string"?{description:G}:G}Y.keywords=Z}else if(U==="toJsonSchema")Y[U]=I6(Q.toJsonSchema,X.toJsonSchema);else if(h1(U))Y[U]={...Q[U],...X[U]};else Y[U]=X[U]}return Y},bU={"draft-2020-12":"https://json-schema.org/draft/2020-12/schema","draft-07":"http://json-schema.org/draft-07/schema#"},I6=(Q,X)=>{if(!Q)return T4(X??{},void 0);if(!X)return Q;let Y={...Q},U;for(U in X)if(U==="fallback")Y.fallback=fU(Q.fallback,X.fallback);else Y[U]=X[U];return T4(Y,X)},T4=(Q,X)=>{if(X?.dialect!==void 0)return Q;if(X?.target!==void 0)return{...Q,dialect:bU[X.target]};return Q},fU=(Q,X)=>{Q=B4(Q),X=B4(X);let Y={},U;for(U in E.defaultConfig.fallback)Y[U]=X[U]??X.default??Q[U]??Q.default??E.defaultConfig.fallback[U];return Y},B4=(Q)=>typeof Q==="function"?{default:Q}:Q??{};class C1 extends Y2{[x]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:Q,relativePath:X,...Y},U){super();this.input=Y,this.ctx=U,pQ(this,Y);let Z=U.data;if(Y.code==="union")Y.errors=Y.errors.flatMap((G)=>{let L=G.hasCode("union")?G.errors:[G];if(!Q&&!X)return L;return L.map((J)=>J.transform((_)=>({..._,path:vQ(Q,_.path,X)})))});this.nodeConfig=U.config[this.code];let W=[...Y.path??U.path];if(X)W.push(...X);if(Q)W.unshift(...Q);this.path=new H2(...W),this.data="data"in Y?Y.data:Z}transform(Q){return new C1(Q({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode(Q){return this.code===Q}get propString(){return $1(this.path)}get expected(){if(this.input.expected)return this.input.expected;let Q=this.meta?.expected??this.nodeConfig.expected;return typeof Q==="function"?Q(this.input):Q}get actual(){if(this.input.actual)return this.input.actual;let Q=this.meta?.actual??this.nodeConfig.actual;return typeof Q==="function"?Q(this.data):Q}get problem(){if(this.input.problem)return this.input.problem;let Q=this.meta?.problem??this.nodeConfig.problem;return typeof Q==="function"?Q(this):Q}get message(){if(this.input.message)return this.input.message;let Q=this.meta?.message??this.nodeConfig.message;return typeof Q==="function"?Q(this):Q}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 o extends f2{[x]="errors";ctx;constructor(Q){super();this.ctx=Q}byPath=Object.create(null);get flatByPath(){return V(this.byPath,(Q,X)=>[Q,X.flat])}get flatProblemsByPath(){return V(this.byPath,(Q,X)=>[Q,X.flat.map((Y)=>Y.problem)])}byAncestorPath=Object.create(null);count=0;mutable=this;throw(){throw this.toTraversalError()}toTraversalError(){return new S6(this)}add(Q){let X=this.byPath[Q.propString];if(X){if(Q===X)return;if(X.hasCode("union")&&X.errors.length===0)return;let Y=Q.hasCode("union")&&Q.errors.length===0?Q:new C1({code:"intersection",errors:X.hasCode("intersection")?[...X.errors,Q]:[X,Q]},this.ctx),U=this.indexOf(X);this.mutable[U===-1?this.length:U]=Y,this.byPath[Q.propString]=Y,this.addAncestorPaths(Q)}else this.byPath[Q.propString]=Q,this.addAncestorPaths(Q),this.mutable.push(Q);this.count++}transform(Q){let X=new o(this.ctx);for(let Y of this)X.add(Q(Y));return X}merge(Q){for(let X of Q)this.add(new C1({...X,path:[...this.ctx.path,...X.path]},this.ctx))}affectsPath(Q){if(this.length===0)return!1;return Q.stringifyAncestors().some((X)=>(X in this.byPath))||Q.stringify()in this.byAncestorPath}get summary(){return this.toString()}get issues(){return this}toJSON(){return[...this.map((Q)=>Q.toJSON())]}toString(){return this.join(`
|
|
16
|
+
`)}addAncestorPaths(Q){for(let X of Q.path.stringifyAncestors())this.byAncestorPath[X]=R(this.byAncestorPath[X],Q)}}class S6 extends Error{name="TraversalError";constructor(Q){if(Q.length===1)super(Q.summary);else super(`
|
|
17
|
+
`+Q.map((X)=>` • ${yU(X)}`).join(`
|
|
18
|
+
`));Object.defineProperty(this,"arkErrors",{value:Q,enumerable:!1})}}var yU=(Q)=>Q.toString().split(`
|
|
19
|
+
`).join(`
|
|
20
|
+
`);class Y1{path=[];errors=new o(this);root;config;queuedMorphs=[];branches=[];seen={};constructor(Q,X){this.root=Q,this.config=X}get data(){let Q=this.root;for(let X of this.path)Q=Q?.[X];return Q}get propString(){return $1(this.path)}reject(Q){return this.error(Q),!1}mustBe(Q){return this.error(Q),!1}error(Q){let X=typeof Q==="object"?Q.code?Q:{...Q,code:"predicate"}:{code:"predicate",expected:Q};return this.errorFromContext(X)}hasError(){return this.currentErrorCount!==0}get currentBranch(){return this.branches[this.branches.length-1]}queueMorphs(Q){let X={path:new H2(...this.path),morphs:Q};if(this.currentBranch)this.currentBranch.queuedMorphs.push(X);else this.queuedMorphs.push(X)}finalize(Q){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 Q?Q(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(Q){return this.errorFromContext(Q)}errorFromContext(Q){let X=new C1(Q,this);if(this.currentBranch)this.currentBranch.error=X;else this.errors.add(X);return X}applyQueuedMorphs(){while(this.queuedMorphs.length){let Q=this.queuedMorphs;this.queuedMorphs=[];for(let{path:X,morphs:Y}of Q){if(this.errors.affectsPath(X))continue;this.applyMorphsAtPath(X,Y)}}}applyMorphsAtPath(Q,X){let Y=Q[Q.length-1],U;if(Y!==void 0){U=this.root;for(let Z=0;Z<Q.length-1;Z++)U=U[Q[Z]]}for(let Z of X){this.path=[...Q];let W=N(Z),G=Z(U===void 0?this.root:U[Y],this);if(G instanceof C1){if(!this.errors.includes(G))this.errors.add(G);break}if(G instanceof o){if(!W)this.errors.merge(G);this.queuedMorphs=[];break}if(U===void 0)this.root=G;else U[Y]=G;this.applyQueuedMorphs()}}}var c=(Q,X,Y)=>{if(!Y)return X();Y.path.push(Q);let U=X();return Y.path.pop(),U};class z2 extends d{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor(Q,X){super((U,Z,W=this.onFail)=>{if(Z)return this.traverseApply(U,Z),Z.hasError()?Z.errors:Z.data;return this.rootApply(U,W)},{attach:Q});this.attachments=Q,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,Z)=>xU(U,Z.shallowReferences),[this]);let Y=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,!Y){let Z=this.children[U].flatRefs;for(let W=0;W<Z.length;W++){let G=Z[W];if(!this.flatRefs.some((L)=>R4(L,G))){this.flatRefs.push(G);for(let L of G.node.branches)if(L.hasKind("morph")||L.hasKind("intersection")&&L.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:G.path,propString:G.propString,node:L})}}}Object.assign(this.referencesById,this.children[U].referencesById)}this.flatRefs.sort((U,Z)=>U.path.length>Z.path.length?1:U.path.length<Z.path.length?-1:U.propString>Z.propString?1:U.propString<Z.propString?-1:U.node.expression<Z.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 Y1(U,this.$.resolvedConfig)):(U)=>this.traverseAllows(U)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(X,Y)=>{if(this.allows(X))return X;let U=new Y1(X,this.$.resolvedConfig);return this.traverseApply(X,U),U.finalize(Y)};case"contextual":return(X,Y)=>{let U=new Y1(X,this.$.resolvedConfig);return this.traverseApply(X,U),U.finalize(Y)};case"optimistic":this.contextFreeMorph=this.shallowMorphs[0];let Q=this.$.resolvedConfig.clone;return(X,Y)=>{if(this.allows(X))return this.contextFreeMorph(Q&&(typeof X==="object"&&X!==null||typeof X==="function")?Q(X):X);let U=new Y1(X,this.$.resolvedConfig);return this.traverseApply(X,U),U.finalize(Y)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,D(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=kU(this.metaJson);cacheGetter(Q,X){return Object.defineProperty(this,Q,{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=u1(this.kind);precompilation;assert=(Q,X)=>this(Q,X,(Y)=>Y.throw());traverse(Q,X){return this(Q,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(Q){if(!this.includesTransform)return this;let X={};for(let[Y,U]of this.innerEntries){let Z=this.impl.keys[Y];if(Z.reduceIo)Z.reduceIo(Q,X,U);else if(Z.child){let W=U;X[Y]=K(W)?W.map((G)=>Q==="in"?G.rawIn:G.rawOut):Q==="in"?W.rawIn:W.rawOut}else X[Y]=U}return this.$.node(this.kind,X)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals(Q){let X=N(Q)?Q:this.$.parseDefinition(Q);return this.innerHash===X.innerHash}ifEquals(Q){return this.equals(Q)?this:void 0}hasKind(Q){return this.kind===Q}assertHasKind(Q){if(this.kind!==Q)K1(`${this.kind} node was not of asserted kind ${Q}`);return this}hasKindIn(...Q){return Q.includes(this.kind)}assertHasKindIn(...Q){if(!s(Q,this.kind))K1(`${this.kind} node was not one of asserted kinds ${Q}`);return this}isBasis(){return s($4,this.kind)}isConstraint(){return s(u2,this.kind)}isStructural(){return s(k1,this.kind)}isRefinement(){return s(E6,this.kind)}isRoot(){return s(x1,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit(Q){return this.hasKind("unit")&&this.allows(Q)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select(Q){let X=$2.normalize(Q);return this._select(X)}_select(Q){let X=$2.applyBoundary[Q.boundary??"references"](this);if(Q.kind)X=X.filter((Y)=>Y.kind===Q.kind);if(Q.where)X=X.filter(Q.where);return $2.applyMethod[Q.method??"filter"](X,this,Q)}transform(Q,X){return this._transform(Q,this._createTransformContext(X))}_createTransformContext(Q){return{root:this,selected:void 0,seen:{},path:[],parseOptions:{prereduced:Q?.prereduced??!1},undeclaredKeyHandling:void 0,...Q}}_transform(Q,X){let Y=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 Z=V(this.inner,(_,A)=>{if(!this.impl.keys[_].child)return[_,A];let O=A;if(!K(O)){let b=O._transform(Q,X);return b?[_,b]:[]}if(O.length===0)return[_,A];let C=O.flatMap((b)=>{return b._transform(Q,X)??[]});return C.length?[_,C]:[]});delete X.seen[this.id];let W=Object.assign(Z,{meta:this.meta}),G=X.selected&&!X.selected.includes(this)?W:Q(this.kind,W,X);if(G===null)return null;if(N(G))return U=G;let L=Object.keys(G);if((L.length===0||L.length===1&&L[0]==="meta")&&!L1(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in G))return X.undeclaredKeyHandling?{...G,value:F.intrinsic.unknown}:null;if(this.kind==="morph")G.in??=F.intrinsic.unknown;return U=Y.node(this.kind,G,X.parseOptions)}configureReferences(Q,X="references"){let Y=$2.normalize(X),U=typeof Q==="string"?(L,J)=>({...J,meta:{...J.meta,description:Q}}):typeof Q==="function"?(L,J)=>({...J,meta:Q(J.meta)}):(L,J)=>({...J,meta:{...J.meta,...Q}});if(Y.boundary==="self")return this.$.node(this.kind,U(this.kind,{...this.inner,meta:this.meta}));let Z=this._select(Y),W=Z&&V1(Z),G=Y.boundary==="child"?(L,J)=>J.root.children.includes(L):Y.boundary==="shallow"?(L)=>L.kind!=="structure":()=>!0;return this.$.finalize(this.transform(U,{shouldTransform:G,selected:W}))}}var $2={applyBoundary:{self:(Q)=>[Q],child:(Q)=>[...Q.children],shallow:(Q)=>[...Q.shallowReferences],references:(Q)=>[...Q.references]},applyMethod:{filter:(Q)=>Q,assertFilter:(Q,X,Y)=>{if(Q.length===0)K1(M4(X,Y));return Q},find:(Q)=>Q[0],assertFind:(Q,X,Y)=>{if(Q.length===0)K1(M4(X,Y));return Q[0]}},normalize:(Q)=>typeof Q==="function"?{boundary:"references",method:"filter",where:Q}:typeof Q==="string"?y(Q,$2.applyBoundary)?{method:"filter",boundary:Q}:{boundary:"references",method:"filter",kind:Q}:{boundary:"references",method:"filter",...Q}},M4=(Q,X)=>`${Q} had no references matching ${T(X)}.`,vU=(Q)=>$1(Q,{stringifyNonKey:(X)=>X.expression}),gU=/"(\$ark\.[^"]+)"/g,kU=(Q)=>JSON.stringify(Q).replace(gU,"$1"),U1=(Q,X)=>({path:Q,node:X,propString:vU(Q)}),R4=(Q,X)=>Q.propString===X.propString&&Q.node.equals(X.node),j6=(Q,X)=>G1(Q,X,{isEqual:R4}),xU=(Q,X)=>G1(Q,X,{isEqual:(Y,U)=>Y.equals(U)});class q extends Array{static init(Q,X,Y,U){return new q({kind:Q,l:X,r:Y,path:U?.path??[],optional:U?.optional??!1})}add(Q,X,Y,U){return this.push({kind:Q,l:X,r:Y,path:U?.path??[],optional:U?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:Q,l:X,r:Y}=this[0],U=$1(Q);return f6(`Intersection${U&&` at ${U}`} of ${C4(X,Y)}`)}return`The following intersections result in unsatisfiable types:
|
|
21
|
+
• ${this.map(({path:Q,l:X,r:Y})=>`${Q}: ${C4(X,Y)}`).join(`
|
|
22
|
+
• `)}`}throw(){return H(this.describeReasons())}invert(){let Q=this.map((X)=>({...X,l:X.r,r:X.l}));if(!(Q instanceof q))return new q(...Q);return Q}withPrefixKey(Q,X){return this.map((Y)=>({...Y,path:[Q,...Y.path],optional:Y.optional||X==="optional"}))}toNeverIfDisjoint(){return F.intrinsic.never}}var C4=(Q,X)=>`${b6(Q)} and ${b6(X)}`,b6=(Q)=>N(Q)?Q.expression:K(Q)?Q.map(b6).join(" | ")||"never":String(Q),f6=(Q)=>`${Q} results in an unsatisfiable type`;var p1={},i=(Q,X,Y)=>P(Q,X,{$:Y,invert:!1,pipe:!1}),O2=(Q,X,Y)=>P(Q,X,{$:Y,invert:!1,pipe:!0}),P=(Q,X,Y)=>{let U=Y.pipe?"|>":"&",Z=`${Q.hash}${U}${X.hash}`;if(p1[Z]!==void 0)return p1[Z];if(!Y.pipe){let L=`${X.hash}${U}${Q.hash}`;if(p1[L]!==void 0){let J=p1[L],_=J instanceof q?J.invert():J;return p1[Z]=_,_}}let W=!Y.pipe||!Q.includesTransform&&!X.includesTransform;if(W&&Q.equals(X))return Q;let G=W?y6(Q,X,Y):Q.hasKindIn(...x1)?hU(Q,X,Y):y6(Q,X,Y);if(N(G)){if(Q.equals(G))G=Q;else if(X.equals(G))G=X}return p1[Z]=G,G},y6=(Q,X,Y)=>{let U=Q.precedence<X.precedence?Q.kind:X.kind,Z=Q.impl.intersections[X.kind]??X.impl.intersections[Q.kind];if(Z===void 0)return null;else if(U===Q.kind)return Z(Q,X,Y);else{let W=Z(X,Q,{...Y,invert:!Y.invert});if(W instanceof q)W=W.invert();return W}},hU=(Q,X,Y)=>Q.includesTransform||X.includesTransform?Y.invert?D4(X,Q,Y):D4(Q,X,Y):y6(Q,X,Y),D4=(Q,X,Y)=>Q.distribute((U)=>uU(U,X,Y),(U)=>{let Z=U.filter(N);if(Z.length===0)return q.init("union",Q.branches,X.branches);if(Z.length<Q.branches.length||!Q.branches.every((L,J)=>L.rawIn.equals(Z[J].rawIn)))return Y.$.parseSchema(Z);let W;if(Z.length===1){let L=Z[0];if(!W)return L;return Y.$.node("morph",{...L.inner,in:L.rawIn.configure(W,"self")})}let G={branches:Z};if(W)G.meta=W;return Y.$.parseSchema(G)}),uU=(Q,X,Y)=>{if(Q.hasKind("morph")){let Z=[...Q.morphs];if(Q.lastMorphIfNode){let W=P(Q.lastMorphIfNode,X,Y);if(W instanceof q)return W;Z[Z.length-1]=W}else Z.push(X);return Y.$.node("morph",{morphs:Z,in:Q.inner.in})}if(X.hasKind("morph")){let Z=P(Q,X.rawIn,Y);if(Z instanceof q)return Z;return Y.$.node("morph",{morphs:[X],in:Z})}return Y.$.node("morph",{morphs:[X],in:Q})};class t extends z2{constructor(Q,X){super(Q,X);Object.defineProperty(this,x,{value:"constraint",enumerable:!1})}impliedSiblings;intersect(Q){return i(this,Q,this.$)}}class z1 extends t{traverseApply=(Q,X)=>{if(!this.traverseAllows(Q,X))X.errorFromNodeContext(this.errorContext)};compile(Q){if(Q.traversalKind==="Allows")Q.return(this.compiledCondition);else Q.if(this.compiledNegation,()=>Q.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return R1(this.errorContext)}}var k=(Q)=>(X,Y)=>{if(K(X)){if(X.length===0)return;let Z=X.map((W)=>Y.$.node(Q,W));if(Q==="predicate")return Z;return Z.sort((W,G)=>W.hash<G.hash?-1:1)}let U=Y.$.node(Q,X);return U.hasOpenIntersection()?[U]:U},m1=(Q)=>{let X=Q.r.shift();if(!X){let U=Q.l.length===0&&Q.kind==="structure"?F.intrinsic.unknown.internal:Q.ctx.$.node(Q.kind,Object.assign(Q.baseInner,pU(Q.l)),{prereduced:!0});for(let Z of Q.roots){if(U instanceof q)return U;U=P(Z,U,Q.ctx)}return U}let Y=!1;for(let U=0;U<Q.l.length;U++){let Z=P(Q.l[U],X,Q.ctx);if(Z===null)continue;if(Z instanceof q)return Z;if(Z.isRoot())return Q.roots.push(Z),Q.l.splice(U),m1(Q);if(!Y)Q.l[U]=Z,Y=!0;else if(!Q.l.includes(Z))return D(`Unexpectedly encountered multiple distinct intersection results for refinement ${X}`)}if(!Y)Q.l.push(X);if(Q.kind==="intersection"){if(X.impliedSiblings)for(let U of X.impliedSiblings)G1(Q.r,U)}return m1(Q)},l1=(Q)=>{return Object.entries(Q).flatMap(([Y,U])=>(Y in p2)?U:[]).sort((Y,U)=>Y.precedence<U.precedence?-1:Y.precedence>U.precedence?1:Y.kind==="predicate"&&U.kind==="predicate"?0:Y.hash<U.hash?-1:1)},pU=(Q)=>{let X={};for(let Y of Q)if(Y.hasOpenIntersection())X[Y.kind]=R(X[Y.kind],Y);else{if(X[Y.kind])return D(`Unexpected intersection of closed refinements of kind ${Y.kind}`);X[Y.kind]=Y}return X},w4=(...Q)=>H(K4(...Q)),K4=(Q,X,Y)=>{let U=Y.hasKind("morph")?"a morph":Y.isUnknown()?"unknown":Y.exclude(X).defaultShortDescription;return`${tQ(Q)} operand must be ${X.description} (was ${U})`};var N4=(Q,X,Y)=>new D1(Q,X,Y,Y,null);class l2 extends d{}class D1 extends d{[x]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor(Q,X,Y,U,Z){super((...W)=>{let G=V(this.names,(L,J)=>{let _=this.arg$.parse(W[L]);if(!_.extends(this.constraints[L]))H(mU(J,this.constraints[L].expression,_.expression));return[J,_]});if(this.defIsLazy()){let L=this.bodyDef(G);return this.$.parse(L)}return this.$.parse(X,{args:G})});this.paramDefs=Q,this.bodyDef=X,this.$=Y,this.arg$=U,this.hkt=Z,this.description=Z?new Z().description??`a generic type for ${Z.constructor.name}`:"a generic type",this.baseInstantiation=this(...this.constraints)}defIsLazy(){return this.bodyDef instanceof l2}cacheGetter(Q,X){return Object.defineProperty(this,Q,{value:X}),X}get json(){return this.cacheGetter("json",{params:this.params.map((Q)=>Q[1].isUnknown()?Q[0]:[Q[0],Q[1].json]),body:J4(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map((Q)=>typeof Q==="string"?[Q,F.intrinsic.unknown]:[Q[0],this.$.parse(Q[1])]))}get names(){return this.cacheGetter("names",this.params.map((Q)=>Q[0]))}get constraints(){return this.cacheGetter("constraints",this.params.map((Q)=>Q[1]))}get internal(){return this}get referencesById(){return this.baseInstantiation.internal.referencesById}get references(){return this.baseInstantiation.internal.references}}var mU=(Q,X,Y)=>`${Q} must be assignable to ${X} (was ${Y})`;var lU=B({kind:"predicate",hasAssociatedError:!0,collapsibleKey:"predicate",keys:{predicate:{}},normalize:(Q)=>typeof Q==="function"?{predicate:Q}:Q,defaults:{description:(Q)=>`valid according to ${Q.predicate.name||"an anonymous predicate"}`},intersectionIsOpen:!0,intersections:{predicate:()=>null}});class P4 extends t{serializedPredicate=S(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=R1(this.errorContext);traverseApply=(Q,X)=>{let Y=X.currentErrorCount;if(!this.predicate(Q,X.external)&&X.currentErrorCount===Y)X.errorFromNodeContext(this.errorContext)};compile(Q){if(Q.traversalKind==="Allows"){Q.return(this.compiledCondition);return}Q.initializeErrorCount(),Q.if(`${this.compiledNegation} && ctx.currentErrorCount === errorCount`,()=>Q.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}reduceJsonSchema(Q,X){return X.fallback.predicate({code:"predicate",base:Q,predicate:this.predicate})}}var v6={implementation:lU,Node:P4};var dU=B({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:(Q)=>Number.isInteger(Q)?Q:H(oU(Q))}},normalize:(Q)=>typeof Q==="number"?{rule:Q}:Q,hasAssociatedError:!0,defaults:{description:(Q)=>Q.rule===1?"an integer":Q.rule===2?"even":`a multiple of ${Q.rule}`},intersections:{divisor:(Q,X,Y)=>Y.$.node("divisor",{rule:Math.abs(Q.rule*X.rule/cU(Q.rule,X.rule))})},obviatesBasisDescription:!0});class E4 extends z1{traverseAllows=(Q)=>Q%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=F.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema(Q){if(Q.type="integer",this.rule===1)return Q;return Q.multipleOf=this.rule,Q}}var g6={implementation:dU,Node:E4};var oU=(Q)=>`divisor must be an integer (was ${Q})`,cU=(Q,X)=>{let Y,U=Q,Z=X;while(Z!==0)Y=Z,Z=U%Z,U=Y;return U};class n extends z1{boundOperandKind=rU[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=tU(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${iU[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?aU(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan(Q){return(this.limitKind==="upper"?this.numericLimit<Q.numericLimit:this.numericLimit>Q.numericLimit)||this.numericLimit===Q.numericLimit&&this.exclusive===!0&&!Q.exclusive}overlapsRange(Q){if(this.isStricterThan(Q))return!1;if(this.numericLimit===Q.numericLimit&&(this.exclusive||Q.exclusive))return!1;return!0}overlapIsUnit(Q){return this.numericLimit===Q.numericLimit&&!this.exclusive&&!Q.exclusive}}var iU={"<":">=","<=":">",">":"<=",">=":"<"},nU={min:"max",minLength:"maxLength",after:"before"},d2={parse:(Q)=>Q||void 0},o2=(Q)=>(X)=>{if(typeof X==="number")return{rule:X};let{exclusive:Y,...U}=X;return Y?{...U,rule:Q==="minLength"?U.rule+1:U.rule-1}:U},c2=(Q)=>(X)=>{if(typeof X==="number"||typeof X==="string"||X instanceof Date)return{rule:X};let{exclusive:Y,...U}=X;if(!Y)return U;let Z=typeof U.rule==="number"?U.rule:typeof U.rule==="string"?new Date(U.rule).valueOf():U.rule.valueOf();return Y?{...U,rule:Q==="after"?Z+1:Z-1}:U},i2=(Q)=>typeof Q==="string"||typeof Q==="number"?new Date(Q):Q,sU=(Q,X)=>`${Q} bound must be a positive integer (was ${X})`,d1=(Q)=>(X)=>{if(!Number.isInteger(X)||X<0)H(sU(Q,X));return X},rU={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},tU=(Q,X)=>`${y(Q,nU)?">":"<"}${X?"":"="}`,aU=(Q)=>typeof Q==="string"?Q:new Date(Q).toLocaleString(),I4=(Q)=>`Bounded expression ${Q} must be exactly one of number, string, Array, or Date`;var eU=B({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:i2,serialize:(Q)=>Q.toISOString()}},normalize:c2("after"),defaults:{description:(Q)=>`${Q.collapsibleLimitString} or later`,actual:S1},intersections:{after:(Q,X)=>Q.isStricterThan(X)?Q:X}});class S4 extends n{impliedBasis=F.intrinsic.Date.internal;collapsibleLimitString=S1(this.rule);traverseAllows=(Q)=>Q>=this.rule;reduceJsonSchema(Q,X){return X.fallback.date({code:"date",base:Q,after:this.rule})}}var k6={implementation:eU,Node:S4};var QZ=B({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:i2,serialize:(Q)=>Q.toISOString()}},normalize:c2("before"),defaults:{description:(Q)=>`${Q.collapsibleLimitString} or earlier`,actual:S1},intersections:{before:(Q,X)=>Q.isStricterThan(X)?Q:X,after:(Q,X,Y)=>Q.overlapsRange(X)?Q.overlapIsUnit(X)?Y.$.node("unit",{unit:Q.rule}):null:q.init("range",Q,X)}});class j4 extends n{collapsibleLimitString=S1(this.rule);traverseAllows=(Q)=>Q<=this.rule;impliedBasis=F.intrinsic.Date.internal;reduceJsonSchema(Q,X){return X.fallback.date({code:"date",base:Q,before:this.rule})}}var x6={implementation:QZ,Node:j4};var XZ=B({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:d1("exactLength")}},normalize:(Q)=>typeof Q==="number"?{rule:Q}:Q,hasAssociatedError:!0,defaults:{description:(Q)=>`exactly length ${Q.rule}`,actual:(Q)=>`${Q.length}`},intersections:{exactLength:(Q,X,Y)=>q.init("unit",Y.$.node("unit",{unit:Q.rule}),Y.$.node("unit",{unit:X.rule}),{path:["length"]}),minLength:(Q,X)=>Q.rule>=X.rule?Q:q.init("range",Q,X),maxLength:(Q,X)=>Q.rule<=X.rule?Q:q.init("range",Q,X)}});class b4 extends z1{traverseAllows=(Q)=>Q.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=F.intrinsic.lengthBoundable.internal;expression=`== ${this.rule}`;reduceJsonSchema(Q){switch(Q.type){case"string":return Q.minLength=this.rule,Q.maxLength=this.rule,Q;case"array":return Q.minItems=this.rule,Q.maxItems=this.rule,Q;default:return E.throwInternalOperandError("exactLength",Q)}}}var h6={implementation:XZ,Node:b4};var YZ=B({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:d2},normalize:(Q)=>typeof Q==="number"?{rule:Q}:Q,defaults:{description:(Q)=>{if(Q.rule===0)return Q.exclusive?"negative":"non-positive";return`${Q.exclusive?"less than":"at most"} ${Q.rule}`}},intersections:{max:(Q,X)=>Q.isStricterThan(X)?Q:X,min:(Q,X,Y)=>Q.overlapsRange(X)?Q.overlapIsUnit(X)?Y.$.node("unit",{unit:Q.rule}):null:q.init("range",Q,X)},obviatesBasisDescription:!0});class f4 extends n{impliedBasis=F.intrinsic.number.internal;traverseAllows=this.exclusive?(Q)=>Q<this.rule:(Q)=>Q<=this.rule;reduceJsonSchema(Q){if(this.exclusive)Q.exclusiveMaximum=this.rule;else Q.maximum=this.rule;return Q}}var u6={implementation:YZ,Node:f4};var UZ=B({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:d1("maxLength")}},reduce:(Q,X)=>Q.rule===0?X.node("exactLength",Q):void 0,normalize:o2("maxLength"),defaults:{description:(Q)=>`at most length ${Q.rule}`,actual:(Q)=>`${Q.length}`},intersections:{maxLength:(Q,X)=>Q.isStricterThan(X)?Q:X,minLength:(Q,X,Y)=>Q.overlapsRange(X)?Q.overlapIsUnit(X)?Y.$.node("exactLength",{rule:Q.rule}):null:q.init("range",Q,X)}});class y4 extends n{impliedBasis=F.intrinsic.lengthBoundable.internal;traverseAllows=(Q)=>Q.length<=this.rule;reduceJsonSchema(Q){switch(Q.type){case"string":return Q.maxLength=this.rule,Q;case"array":return Q.maxItems=this.rule,Q;default:return E.throwInternalOperandError("maxLength",Q)}}}var p6={implementation:UZ,Node:y4};var ZZ=B({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:d2},normalize:(Q)=>typeof Q==="number"?{rule:Q}:Q,defaults:{description:(Q)=>{if(Q.rule===0)return Q.exclusive?"positive":"non-negative";return`${Q.exclusive?"more than":"at least"} ${Q.rule}`}},intersections:{min:(Q,X)=>Q.isStricterThan(X)?Q:X},obviatesBasisDescription:!0});class v4 extends n{impliedBasis=F.intrinsic.number.internal;traverseAllows=this.exclusive?(Q)=>Q>this.rule:(Q)=>Q>=this.rule;reduceJsonSchema(Q){if(this.exclusive)Q.exclusiveMinimum=this.rule;else Q.minimum=this.rule;return Q}}var m6={implementation:ZZ,Node:v4};var WZ=B({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:d1("minLength")}},reduce:(Q)=>Q.rule===0?F.intrinsic.unknown:void 0,normalize:o2("minLength"),defaults:{description:(Q)=>Q.rule===1?"non-empty":`at least length ${Q.rule}`,actual:(Q)=>Q.length===0?"":`${Q.length}`},intersections:{minLength:(Q,X)=>Q.isStricterThan(X)?Q:X}});class g4 extends n{impliedBasis=F.intrinsic.lengthBoundable.internal;traverseAllows=(Q)=>Q.length>=this.rule;reduceJsonSchema(Q){switch(Q.type){case"string":return Q.minLength=this.rule,Q;case"array":return Q.minItems=this.rule,Q;default:return E.throwInternalOperandError("minLength",Q)}}}var l6={implementation:WZ,Node:g4};var k4={min:m6.implementation,max:u6.implementation,minLength:l6.implementation,maxLength:p6.implementation,exactLength:h6.implementation,after:k6.implementation,before:x6.implementation},x4={min:m6.Node,max:u6.Node,minLength:l6.Node,maxLength:p6.Node,exactLength:h6.Node,after:k6.Node,before:x6.Node};var GZ=B({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:(Q)=>typeof Q==="string"?{rule:Q}:Q instanceof RegExp?Q.flags?{rule:Q.source,flags:Q.flags}:{rule:Q.source}:Q,obviatesBasisDescription:!0,obviatesBasisExpression:!0,hasAssociatedError:!0,intersectionIsOpen:!0,defaults:{description:(Q)=>`matched by ${Q.rule}`},intersections:{pattern:()=>null}});class h4 extends z1{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=F.intrinsic.string.internal;reduceJsonSchema(Q,X){if(Q.pattern)return X.fallback.patternIntersection({code:"patternIntersection",base:Q,pattern:this.rule});return Q.pattern=this.rule,Q}}var d6={implementation:GZ,Node:h4};var V2=(Q,X)=>{let Y=LZ(Q);if(X&&!X.includes(Y))return H(`Root of kind ${Y} should be one of ${X}`);return Y},LZ=(Q)=>{if($(Q,"root"))return Q.kind;if(typeof Q==="string")return Q[0]==="$"?"alias":(Q in m)?"domain":"proto";if(typeof Q==="function")return"proto";if(typeof Q!=="object"||Q===null)return H(u4(Q));if("morphs"in Q)return"morph";if("branches"in Q||K(Q))return"union";if("unit"in Q)return"unit";if("reference"in Q)return"alias";let X=Object.keys(Q);if(X.length===0||X.some((Y)=>(Y in p2)))return"intersection";if("proto"in Q)return"proto";if("domain"in Q)return"domain";return H(u4(Q))},u4=(Q)=>`${T(Q)} is not a valid type schema`,p4={},_Z=(Q)=>K(Q)?Q.map((X)=>X.collapsibleJson):Q.collapsibleJson,h={};F.nodesByRegisteredId=h;var o6=(Q)=>{return p4[Q]??=0,`${Q}${++p4[Q]}`},c6=(Q)=>{let X=o1[Q.kind],Y=X.applyConfig?.(Q.def,Q.$.resolvedConfig)??Q.def,U={},{meta:Z,...W}=Y,G=Z===void 0?{}:typeof Z==="string"?{description:Z}:Z,L=z6(W).sort(([_],[A])=>h1(_)?h1(A)?u1(_)-u1(A):1:h1(A)?-1:_<A?-1:1).filter(([_,A])=>{if(_.startsWith("meta.")){let O=_.slice(5);return G[O]=A,!1}return!0});for(let _ of L){let A=_[0],O=X.keys[A];if(!O)return H(`Key ${A} is not valid on ${Q.kind} schema`);let C=O.parse?O.parse(_[1],Q):_[1];if(C!==l&&(C!==void 0||O.preserveUndefined))U[A]=C}if(X.reduce&&!Q.prereduced){let _=X.reduce(U,Q.$);if(_){if(_ instanceof q)return _.throw();return JZ(_,G)}}return i6({id:Q.id,kind:Q.kind,inner:U,meta:G,$:Q.$})},i6=({id:Q,kind:X,inner:Y,meta:U,$:Z,ignoreCache:W})=>{let G=o1[X],L=z6(Y),J=[],_={};for(let[Z1,f1]of L){let Q2=G.keys[Z1],rY=Q2.serialize??(Q2.child?_Z:r);if(_[Z1]=rY(f1),Q2.child===!0){let q6=f1;if(K(q6))J.push(...q6);else J.push(q6)}else if(typeof Q2.child==="function")J.push(...Q2.child(f1))}if(G.finalizeInnerJson)_=G.finalizeInnerJson(_);let A={..._},O={};if(!L1(U))O=V(U,(Z1,f1)=>[Z1,Z1==="examples"?f1:r(f1)]),A.meta=n2(O,"description",!0);_=n2(_,G.collapsibleKey,!1);let C=JSON.stringify({kind:X,..._});A=n2(A,G.collapsibleKey,!1);let b=n2(A,G.collapsibleKey,!0),H1=JSON.stringify({kind:X,...A});if(Z.nodesByHash[H1]&&!W)return Z.nodesByHash[H1];let jQ={id:Q,kind:X,impl:G,inner:Y,innerEntries:L,innerJson:_,innerHash:C,meta:U,metaJson:O,json:A,hash:H1,collapsibleJson:b,children:J};if(X!=="intersection"){for(let Z1 in Y)if(Z1!=="in"&&Z1!=="out")jQ[Z1]=Y[Z1]}let sY=new l4[X](jQ,Z);return Z.nodesByHash[H1]=sY},m4=(Q,X)=>{if(Q.id===X)return Q;if(N(h[X]))D(`Unexpected attempt to overwrite node id ${X}`);return i6({id:X,kind:Q.kind,inner:Q.inner,meta:Q.meta,$:Q.$,ignoreCache:!0})},JZ=(Q,X,Y)=>{if(Y&&N(h[Y]))D(`Unexpected attempt to overwrite node id ${Y}`);return i6({id:Y??o6(X.alias??Q.kind),kind:Q.kind,inner:Q.inner,meta:X,$:Q.$})},n2=(Q,X,Y)=>{let U=Object.keys(Q);if(U.length===1&&U[0]===X){let Z=Q[X];if(Y)return Z;if(p(Z,"object")&&(Object.keys(Z).length===1||Array.isArray(Z)))return Z}return Q};var T2=(Q,X,Y)=>{if(Q.key!==X.key)return null;let U=Q.key,Z=P(Q.value,X.value,Y),W=Q.required||X.required?"required":"optional";if(Z instanceof q)if(W==="optional")Z=F.intrinsic.never.internal;else return Z.withPrefixKey(Q.key,Q.required&&X.required?"required":"optional");if(W==="required")return Y.$.node("required",{key:U,value:Z});let G=Q.hasDefault()?X.hasDefault()?Q.default===X.default?Q.default:H(n6(Q.default,X.default)):Q.default:X.hasDefault()?X.default:l;return Y.$.node("optional",{key:U,value:Z,default:G})};class B2 extends t{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=F.intrinsic.object.internal;serializedKey=X1(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=R(this.value.flatRefs.map((Q)=>U1([this.key,...Q.path],Q.node)),U1([this.key],this.value));_transform(Q,X){X.path.push(this.key);let Y=super._transform(Q,X);return X.path.pop(),Y}hasDefault(){return"default"in this.inner}traverseAllows=(Q,X)=>{if(this.key in Q)return c(this.key,()=>this.value.traverseAllows(Q[this.key],X),X);return this.optional};traverseApply=(Q,X)=>{if(this.key in Q)c(this.key,()=>this.value.traverseApply(Q[this.key],X),X);else if(this.hasKind("required"))X.errorFromNodeContext(this.errorContext)};compile(Q){if(Q.if(`${this.serializedKey} in data`,()=>Q.traverseKey(this.serializedKey,`data${Q.prop(this.key)}`,this.value)),this.hasKind("required"))Q.else(()=>Q.traversalKind==="Apply"?Q.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`):Q.return(!1));if(Q.traversalKind==="Allows")Q.return(!0)}}var n6=(Q,X)=>`Invalid intersection of default values ${T(Q)} & ${T(X)}`;var HZ=B({kind:"optional",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(Q,X)=>X.$.parseSchema(Q)},default:{preserveUndefined:!0}},normalize:(Q)=>Q,reduce:(Q,X)=>{if(X.resolvedConfig.exactOptionalPropertyTypes===!1){if(!Q.value.allows(void 0))return X.node("optional",{...Q,value:Q.value.or(z.undefined)},{prereduced:!0})}},defaults:{description:(Q)=>`${Q.compiledKey}?: ${Q.value.description}`},intersections:{optional:T2}});class d4 extends B2{constructor(...Q){super(...Q);if("default"in this.inner)R2(this.value,this.inner.default,this.key)}get rawIn(){let Q=super.rawIn;if(!this.hasDefault())return Q;return this.$.node("optional",y2(Q.inner,{default:!0}),{prereduced:!0})}get outProp(){if(!this.hasDefault())return this;let{default:Q,...X}=this.inner;return this.cacheGetter("outProp",this.$.node("required",X,{prereduced:!0}))}expression=this.hasDefault()?`${this.compiledKey}: ${this.value.expression} = ${T(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=qZ(this);defaultValueMorphRef=this.defaultValueMorph&&S(this.defaultValueMorph)}var M2={implementation:HZ,Node:d4},FZ={},qZ=(Q)=>{if(!Q.hasDefault())return;let X=`{${Q.compiledKey}: ${Q.value.id} = ${r(Q.default)}}`;return FZ[X]??=s6(Q.key,Q.value,Q.default)},s6=(Q,X,Y)=>{if(typeof Y==="function")return X.includesTransform?(Z,W)=>{return c(Q,()=>X(Z[Q]=Y(),W),W),Z}:(Z)=>{return Z[Q]=Y(),Z};let U=X.includesTransform?X.assert(Y):Y;return p(U,"object")?(Z,W)=>{return c(Q,()=>X(Z[Q]=Y,W),W),Z}:(Z)=>{return Z[Q]=U,Z}},R2=(Q,X,Y)=>{let U=T1(X);if(p(X,"object")&&!U)H(AZ(Y));let Z=Q.in(U?X():X);if(Z instanceof o){if(Y===null)H(`Default ${Z.summary}`);let W=Z.transform((G)=>G.transform((L)=>({...L,prefixPath:[Y]})));H(`Default for ${W.summary}`)}return X},AZ=(Q)=>{return`Non-primitive default ${Q===null?"":typeof Q==="number"?`for value at [${Q}] `:`for ${X1(Q)} `}must be specified as a function like () => ({my: 'object'})`};class a extends z2{constructor(Q,X){super(Q,X);Object.defineProperty(this,x,{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:(Q)=>{let X=this(Q);if(X instanceof o)return X;return{value:X}},jsonSchema:{input:(Q)=>this.rawIn.toJsonSchema({target:o4(Q.target),...Q.libraryOptions}),output:(Q)=>this.rawOut.toJsonSchema({target:o4(Q.target),...Q.libraryOptions})}}}as(){return this}brand(Q){if(Q==="")return H($Z);return this}readonly(){return this}branches=this.hasKind("union")?this.inner.branches:[this];distribute(Q,X){let Y=this.branches.map(Q);return X?.(Y)??Y}get shortDescription(){return this.meta.description??this.defaultShortDescription}toJsonSchema(Q={}){let X=I6(this.$.resolvedConfig.toJsonSchema,Q);X.useRefs||=this.isCyclic;let Y=typeof X.dialect==="string"?{$schema:X.dialect}:{};if(Object.assign(Y,this.toJsonSchemaRecurse(X)),X.useRefs){let U=V(this.references,(Z,W)=>W.isRoot()&&!W.alwaysExpandJsonSchema?[W.id,W.toResolvedJsonSchema(X)]:[]);if(X.target==="draft-07")Object.assign(Y,{definitions:U});else Y.$defs=U}return Y}toJsonSchemaRecurse(Q){if(Q.useRefs&&!this.alwaysExpandJsonSchema)return{$ref:`#/${Q.target==="draft-07"?"definitions":"$defs"}/${this.id}`};return this.toResolvedJsonSchema(Q)}get alwaysExpandJsonSchema(){return this.isBasis()||this.kind==="alias"||this.hasKind("union")&&this.isBoolean}toResolvedJsonSchema(Q){let X=this.innerToJsonSchema(Q);return Object.assign(X,this.metaJson)}intersect(Q){let X=this.$.parseDefinition(Q),Y=this.rawIntersect(X);if(Y instanceof q)return Y;return this.$.finalize(Y)}rawIntersect(Q){return i(this,Q,this.$)}toNeverIfDisjoint(){return this}and(Q){let X=this.intersect(Q);return X instanceof q?X.throw():X}rawAnd(Q){let X=this.rawIntersect(Q);return X instanceof q?X.throw():X}or(Q){let X=this.$.parseDefinition(Q);return this.$.finalize(this.rawOr(X))}rawOr(Q){let X=[...this.branches,...Q.branches];return this.$.node("union",X)}map(Q){return this.$.schema(this.applyStructuralOperation("map",[Q]))}pick(...Q){return this.$.schema(this.applyStructuralOperation("pick",Q))}omit(...Q){return this.$.schema(this.applyStructuralOperation("omit",Q))}required(){return this.$.schema(this.applyStructuralOperation("required",[]))}partial(){return this.$.schema(this.applyStructuralOperation("partial",[]))}_keyof;keyof(){if(this._keyof)return this._keyof;let Q=this.applyStructuralOperation("keyof",[]).reduce((X,Y)=>X.intersect(Y).toNeverIfDisjoint(),F.intrinsic.unknown.internal);if(Q.branches.length===0)H(f6(`keyof ${this.expression}`));return this._keyof=this.$.finalize(Q)}get props(){if(this.branches.length!==1)return H(OZ(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge(Q){let X=this.$.parseDefinition(Q);return this.$.schema(X.distribute((Y)=>this.applyStructuralOperation("merge",[c4(Y)??H(i4("merge",Y.expression))])))}applyStructuralOperation(Q,X){return this.distribute((Y)=>{if(Y.equals(F.intrinsic.object)&&Q!=="merge")return Y;let U=c4(Y);if(!U)H(i4(Q,Y.expression));if(Q==="keyof")return U.keyof();if(Q==="get")return U.get(...X);if(Q==="props")return U.props;let Z=Q==="required"?"require":Q==="partial"?"optionalize":Q;return this.$.node("intersection",{domain:"object",structure:U[Z](...X)})})}get(...Q){if(Q[0]===void 0)return this;return this.$.schema(this.applyStructuralOperation("get",Q))}extract(Q){let X=this.$.parseDefinition(Q);return this.$.schema(this.branches.filter((Y)=>Y.extends(X)))}exclude(Q){let X=this.$.parseDefinition(Q);return this.$.schema(this.branches.filter((Y)=>!Y.extends(X)))}array(){return this.$.schema(this.isUnknown()?{proto:Array}:{proto:Array,sequence:this},{prereduced:!0})}overlaps(Q){return!(this.intersect(Q)instanceof q)}extends(Q){if(this.isNever())return!0;let X=this.intersect(Q);return!(X instanceof q)&&this.equals(X)}ifExtends(Q){return this.extends(Q)?this:void 0}subsumes(Q){return this.$.parseDefinition(Q).extends(this)}configure(Q,X="shallow"){return this.configureReferences(Q,X)}describe(Q,X="shallow"){return this.configure({description:Q},X)}optional(){return[this,"?"]}default(Q){return R2(this,Q,null),[this,"=",Q]}from(Q){return this.assert(Q)}_pipe(...Q){let X=Q.reduce((Y,U)=>Y.rawPipeOnce(U),this);return this.$.finalize(X)}tryPipe(...Q){let X=Q.reduce((Y,U)=>Y.rawPipeOnce($(U,"root")?U:(Z,W)=>{try{return U(Z,W)}catch(G){return W.error({code:"predicate",predicate:U,actual:`aborted due to error:
|
|
23
|
+
${G}
|
|
24
|
+
`})}}),this);return this.$.finalize(X)}pipe=Object.assign(this._pipe.bind(this),{try:this.tryPipe.bind(this)});to(Q){return this.$.finalize(this.toNode(this.$.parseDefinition(Q)))}toNode(Q){let X=O2(this,Q,this.$);if(X instanceof q)return X.throw();return X}rawPipeOnce(Q){if($(Q,"root"))return this.toNode(Q);return this.distribute((X)=>X.hasKind("morph")?this.$.node("morph",{in:X.inner.in,morphs:[...X.morphs,Q]}):this.$.node("morph",{in:X,morphs:[Q]}),this.$.parseSchema)}narrow(Q){return this.constrainOut("predicate",Q)}constrain(Q,X){return this._constrain("root",Q,X)}constrainIn(Q,X){return this._constrain("in",Q,X)}constrainOut(Q,X){return this._constrain("out",Q,X)}_constrain(Q,X,Y){let U=this.$.node(X,Y);if(U.isRoot())return U.isUnknown()?this:D(`Unexpected constraint node ${U}`);let Z=Q==="root"?this:Q==="in"?this.rawIn:this.rawOut;if(Z.hasKind("morph")||U.impliedBasis&&!Z.extends(U.impliedBasis))return w4(X,U.impliedBasis,this);let W=this.$.node("intersection",{[U.kind]:U}),G=Q==="out"?O2(this,W,this.$):i(this,W,this.$);if(G instanceof q)G.throw();return this.$.finalize(G)}onUndeclaredKey(Q){let X=typeof Q==="string"?Q:Q.rule,Y=typeof Q==="string"?!1:Q.deep;return this.$.finalize(this.transform((U,Z)=>U==="structure"?X==="ignore"?y2(Z,{undeclared:1}):{...Z,undeclared:X}:Z,Y?void 0:{shouldTransform:(U)=>!s(k1,U.kind)}))}hasEqualMorphs(Q){if(!this.includesTransform&&!Q.includesTransform)return!0;if(!q1(this.shallowMorphs,Q.shallowMorphs))return!1;if(!q1(this.flatMorphs,Q.flatMorphs,{isEqual:(X,Y)=>X.propString===Y.propString&&(X.node.hasKind("morph")&&Y.node.hasKind("morph")?X.node.hasEqualMorphs(Y.node):X.node.hasKind("intersection")&&Y.node.hasKind("intersection")?X.node.structure?.structuralMorphRef===Y.node.structure?.structuralMorphRef:!1)}))return!1;return!0}onDeepUndeclaredKey(Q){return this.onUndeclaredKey({rule:Q,deep:!0})}filter(Q){return this.constrainIn("predicate",Q)}divisibleBy(Q){return this.constrain("divisor",Q)}matching(Q){return this.constrain("pattern",Q)}atLeast(Q){return this.constrain("min",Q)}atMost(Q){return this.constrain("max",Q)}moreThan(Q){return this.constrain("min",c1(Q))}lessThan(Q){return this.constrain("max",c1(Q))}atLeastLength(Q){return this.constrain("minLength",Q)}atMostLength(Q){return this.constrain("maxLength",Q)}moreThanLength(Q){return this.constrain("minLength",c1(Q))}lessThanLength(Q){return this.constrain("maxLength",c1(Q))}exactlyLength(Q){return this.constrain("exactLength",Q)}atOrAfter(Q){return this.constrain("after",Q)}atOrBefore(Q){return this.constrain("before",Q)}laterThan(Q){return this.constrain("after",c1(Q))}earlierThan(Q){return this.constrain("before",c1(Q))}}var $Z="Expected a non-empty brand name after #",n4=["draft-2020-12","draft-07"],zZ=(Q)=>`JSONSchema target '${Q}' is not supported (must be ${n4.map((X)=>`"${X}"`).join(" or ")})`,o4=(Q)=>{if(!s(n4,Q))H(zZ(Q));return Q},c1=(Q)=>typeof Q==="object"&&!(Q instanceof Date)?{...Q,exclusive:!0}:{rule:Q,exclusive:!0},C2=(Q,X)=>$(X,"root")?$(Q,"root")?Q.extends(X):X.allows(Q):$(Q,"root")?Q.hasUnit(X):X===Q,c4=(Q)=>{if(Q.hasKind("morph"))return null;if(Q.hasKind("intersection"))return Q.inner.structure??(Q.basis?.domain==="object"?Q.$.bindReference(F.intrinsic.emptyStructure):null);if(Q.isBasis()&&Q.domain==="object")return Q.$.bindReference(F.intrinsic.emptyStructure);return null},OZ=(Q)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
|
|
25
|
+
${Q}`,i4=(Q,X)=>`${Q} operand must be an object (was ${X})`;var _1=(Q,X)=>V(m2(Q),(Y,U)=>[U,X]);var VZ=(Q)=>typeof Q==="string"?{reference:Q}:Q,s4=(Q)=>Q instanceof q?F.intrinsic.never.internal:Q,TZ=B({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:(Q)=>Q.startsWith("$")?Q:`$ark.${Q}`},resolve:{}},normalize:VZ,defaults:{description:(Q)=>Q.reference},intersections:{alias:(Q,X,Y)=>Y.$.lazilyResolve(()=>s4(P(Q.resolution,X.resolution,Y)),`${Q.reference}${Y.pipe?"=>":"&"}${X.reference}`),..._1("alias",(Q,X,Y)=>{if(X.isUnknown())return Q;if(X.isNever())return X;if(X.isBasis()&&!X.overlaps(F.intrinsic.object))return q.init("assignability",F.intrinsic.object,X);return Y.$.lazilyResolve(()=>s4(P(Q.resolution,X,Y)),`${Q.reference}${Y.pipe?"=>":"&"}${X.id}`)})}});class r4 extends a{expression=this.reference;structure=void 0;get resolution(){let Q=this._resolve();return h[this.id]=Q}_resolve(){if(this.resolve)return this.resolve();if(this.reference[0]==="$")return this.$.resolveRoot(this.reference.slice(1));let Q=this.reference,X=h[Q],Y=[];while($(X,"context")){if(Y.includes(X.id))return H(BZ(X.id,Y));Y.push(X.id),X=h[X.id]}if(!$(X,"root"))return D(`Unexpected resolution for reference ${this.reference}
|
|
26
|
+
Seen: [${Y.join("->")}]
|
|
27
|
+
Resolution: ${T(X)}`);return X}get resolutionId(){if(this.reference.includes("&")||this.reference.includes("=>"))return this.resolution.id;if(this.reference[0]!=="$")return this.reference;let Q=this.reference.slice(1),X=this.$.resolutions[Q];if(typeof X==="string")return X;if($(X,"root"))return X.id;return D(`Unexpected resolution for reference ${this.reference}: ${T(X)}`)}get defaultShortDescription(){return m.object}innerToJsonSchema(Q){return this.resolution.toJsonSchemaRecurse(Q)}traverseAllows=(Q,X)=>{let Y=X.seen[this.reference];if(Y?.includes(Q))return!0;return X.seen[this.reference]=R(Y,Q),this.resolution.traverseAllows(Q,X)};traverseApply=(Q,X)=>{let Y=X.seen[this.reference];if(Y?.includes(Q))return;X.seen[this.reference]=R(Y,Q),this.resolution.traverseApply(Q,X)};compile(Q){let X=this.resolutionId;Q.if(`ctx.seen.${X} && ctx.seen.${X}.includes(data)`,()=>Q.return(!0)),Q.if(`!ctx.seen.${X}`,()=>Q.line(`ctx.seen.${X} = []`)),Q.line(`ctx.seen.${X}.push(data)`),Q.return(Q.invoke(X))}}var BZ=(Q,X)=>`Alias '${Q}' has a shallow resolution cycle: ${[...X,Q].join("->")}`,D2={implementation:TZ,Node:r4};class j1 extends a{traverseApply=(Q,X)=>{if(!this.traverseAllows(Q,X))X.errorFromNodeContext(this.errorContext)};get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return R1(this.errorContext)}compile(Q){if(Q.traversalKind==="Allows")Q.return(this.compiledCondition);else Q.if(this.compiledNegation,()=>Q.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}}var MZ=B({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:(Q)=>typeof Q==="string"?{domain:Q}:v1(Q,"numberAllowsNaN")&&Q.domain!=="number"?H(s2.writeBadAllowNanMessage(Q.domain)):Q,applyConfig:(Q,X)=>Q.numberAllowsNaN===void 0&&Q.domain==="number"&&X.numberAllowsNaN?{...Q,numberAllowsNaN:!0}:Q,defaults:{description:(Q)=>m[Q.domain],actual:(Q)=>Number.isNaN(Q)?"NaN":m[f(Q)]},intersections:{domain:(Q,X)=>Q.domain==="number"&&X.domain==="number"?Q.numberAllowsNaN?X:Q:q.init("domain",Q,X)}});class t4 extends j1{requiresNaNCheck=this.domain==="number"&&!this.numberAllowsNaN;traverseAllows=this.requiresNaNCheck?(Q)=>typeof Q==="number"&&!Number.isNaN(Q):(Q)=>f(Q)===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 m[this.domain]}innerToJsonSchema(Q){if(this.domain==="bigint"||this.domain==="symbol")return Q.fallback.domain({code:"domain",base:{},domain:this.domain});return{type:this.domain}}}var s2={implementation:MZ,Node:t4,writeBadAllowNanMessage:(Q)=>`numberAllowsNaN may only be specified with domain "number" (was ${Q})`};var RZ=B({kind:"intersection",hasAssociatedError:!0,normalize:(Q)=>{if(N(Q))return Q;let{structure:X,...Y}=Q,U=!!X,Z=X??{},W=V(Y,(G,L)=>{if(y(G,z4)){if(U)H(`Flattened structure key ${G} cannot be specified alongside a root 'structure' key.`);return Z[G]=L,[]}return[G,L]});if($(Z,"constraint")||!L1(Z))W.structure=Z;return W},finalizeInnerJson:({structure:Q,...X})=>p(Q,"object")?{...Q,...X}:X,keys:{domain:{child:!0,parse:(Q,X)=>X.$.node("domain",Q)},proto:{child:!0,parse:(Q,X)=>X.$.node("proto",Q)},structure:{child:!0,parse:(Q,X)=>X.$.node("structure",Q),serialize:(Q)=>{if(!Q.sequence?.minLength)return Q.collapsibleJson;let{sequence:X,...Y}=Q.collapsibleJson,{minVariadicLength:U,...Z}=X,W=Z.variadic&&Object.keys(Z).length===1?Z.variadic:Z;return{...Y,sequence:W}}},divisor:{child:!0,parse:k("divisor")},max:{child:!0,parse:k("max")},min:{child:!0,parse:k("min")},maxLength:{child:!0,parse:k("maxLength")},minLength:{child:!0,parse:k("minLength")},exactLength:{child:!0,parse:k("exactLength")},before:{child:!0,parse:k("before")},after:{child:!0,parse:k("after")},pattern:{child:!0,parse:k("pattern")},predicate:{child:!0,parse:k("predicate")}},reduce:(Q,X)=>a4({},Q,{$:X,invert:!1,pipe:!1}),defaults:{description:(Q)=>{if(Q.children.length===0)return"unknown";if(Q.structure)return Q.structure.description;let X=[];if(Q.basis&&!Q.prestructurals.some((Y)=>Y.impl.obviatesBasisDescription))X.push(Q.basis.description);if(Q.prestructurals.length){let Y=Q.prestructurals.slice().sort((U,Z)=>U.kind==="min"&&Z.kind==="max"?-1:0).map((U)=>U.description);X.push(...Y)}if(Q.inner.predicate)X.push(...Q.inner.predicate.map((Y)=>Y.description));return X.join(" and ")},expected:(Q)=>` ◦ ${Q.errors.map((X)=>X.expected).join(`
|
|
28
|
+
◦ `)}`,problem:(Q)=>`(${Q.actual}) must be...
|
|
29
|
+
${Q.expected}`},intersections:{intersection:(Q,X,Y)=>a4(Q.inner,X.inner,Y),..._1("intersection",(Q,X,Y)=>{if(Q.children.length===0)return X;let{domain:U,proto:Z,...W}=Q.inner,G=Z??U,L=G?P(G,X,Y):X;return L instanceof q?L:Q?.basis?.equals(L)?Q:Q.$.node("intersection",{...W,[L.kind]:L},{prereduced:!0})})}});class e4 extends a{basis=this.inner.domain??this.inner.proto??null;prestructurals=[];refinements=this.children.filter((Q)=>{if(!Q.isRefinement())return!1;if(s(P6,Q.kind))this.prestructurals.push(Q);return!0});structure=this.inner.structure;expression=CZ(this);get shallowMorphs(){return this.inner.structure?.structuralMorph?[this.inner.structure.structuralMorph]:[]}get defaultShortDescription(){return this.basis?.defaultShortDescription??"present"}innerToJsonSchema(Q){return this.children.reduce((X,Y)=>Y.isBasis()?Y.toJsonSchemaRecurse(Q):Y.reduceJsonSchema(X,Q),{})}traverseAllows=(Q,X)=>this.children.every((Y)=>Y.traverseAllows(Q,X));traverseApply=(Q,X)=>{let Y=X.currentErrorCount;if(this.basis){if(this.basis.traverseApply(Q,X),X.currentErrorCount>Y)return}if(this.prestructurals.length){for(let U=0;U<this.prestructurals.length-1;U++)if(this.prestructurals[U].traverseApply(Q,X),X.failFast&&X.currentErrorCount>Y)return;if(this.prestructurals[this.prestructurals.length-1].traverseApply(Q,X),X.currentErrorCount>Y)return}if(this.structure){if(this.structure.traverseApply(Q,X),X.currentErrorCount>Y)return}if(this.inner.predicate){for(let U=0;U<this.inner.predicate.length-1;U++)if(this.inner.predicate[U].traverseApply(Q,X),X.failFast&&X.currentErrorCount>Y)return;this.inner.predicate[this.inner.predicate.length-1].traverseApply(Q,X)}};compile(Q){if(Q.traversalKind==="Allows"){for(let X of this.children)Q.check(X);Q.return(!0);return}if(Q.initializeErrorCount(),this.basis){if(Q.check(this.basis),this.children.length>1)Q.returnIfFail()}if(this.prestructurals.length){for(let X=0;X<this.prestructurals.length-1;X++)Q.check(this.prestructurals[X]),Q.returnIfFailFast();if(Q.check(this.prestructurals[this.prestructurals.length-1]),this.structure||this.inner.predicate)Q.returnIfFail()}if(this.structure){if(Q.check(this.structure),this.inner.predicate)Q.returnIfFail()}if(this.inner.predicate){for(let X=0;X<this.inner.predicate.length-1;X++)Q.check(this.inner.predicate[X]),Q.returnIfFail();Q.check(this.inner.predicate[this.inner.predicate.length-1])}}}var r6={implementation:RZ,Node:e4},CZ=(Q)=>{if(Q.structure?.expression)return Q.structure.expression;let X=Q.basis&&!Q.prestructurals.some((Z)=>Z.impl.obviatesBasisExpression)?Q.basis.nestableExpression:"",Y=Q.prestructurals.map((Z)=>Z.expression).join(" & "),U=`${X}${X?" ":""}${Y}`;if(U==="Array == 0")return"[]";return U||"unknown"},a4=(Q,X,Y)=>{let U={},Z=Q.proto??Q.domain,W=X.proto??X.domain,G=Z?W?P(Z,W,Y):Z:W;if(G instanceof q)return G;if(G)U[G.kind]=G;return m1({kind:"intersection",baseInner:U,l:l1(Q),r:l1(X),roots:[],ctx:Y})};var DZ=B({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:(Q,X)=>X.$.parseSchema(Q)},morphs:{parse:V1,serialize:(Q)=>Q.map((X)=>$(X,"root")?X.json:S(X))},declaredIn:{child:!1,serialize:(Q)=>Q.json},declaredOut:{child:!1,serialize:(Q)=>Q.json}},normalize:(Q)=>Q,defaults:{description:(Q)=>`a morph from ${Q.rawIn.description} to ${Q.rawOut?.description??"unknown"}`},intersections:{morph:(Q,X,Y)=>{if(!Q.hasEqualMorphs(X))return H(wZ(Q.expression,X.expression));let U=P(Q.rawIn,X.rawIn,Y);if(U instanceof q)return U;let Z={morphs:Q.morphs};if(Q.declaredIn||X.declaredIn){let W=P(Q.rawIn,X.rawIn,Y);if(W instanceof q)return W.throw();else Z.declaredIn=W}if(Q.declaredOut||X.declaredOut){let W=P(Q.rawOut,X.rawOut,Y);if(W instanceof q)return W.throw();else Z.declaredOut=W}return U.distribute((W)=>Y.$.node("morph",{...Z,in:W}),Y.$.parseSchema)},..._1("morph",(Q,X,Y)=>{let U=Q.inner.in?P(Q.inner.in,X,Y):X;return U instanceof q?U:U.equals(Q.inner.in)?Q:Y.$.node("morph",{...Q.inner,in:U})})}});class QX extends a{serializedMorphs=this.morphs.map(S);compiledMorphs=`[${this.serializedMorphs}]`;lastMorph=this.inner.morphs[this.inner.morphs.length-1];lastMorphIfNode=$(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??F.intrinsic.unknown.internal}get rawOut(){return this.declaredOut??this.introspectableOut??F.intrinsic.unknown.internal}declareIn(Q){return this.$.node("morph",{...this.inner,declaredIn:Q})}declareOut(Q){return this.$.node("morph",{...this.inner,declaredOut:Q})}expression=`(In: ${this.rawIn.expression}) => ${this.lastMorphIfNode?"To":"Out"}<${this.rawOut.expression}>`;get defaultShortDescription(){return this.rawIn.meta.description??this.rawIn.defaultShortDescription}innerToJsonSchema(Q){return Q.fallback.morph({code:"morph",base:this.rawIn.toJsonSchemaRecurse(Q),out:this.introspectableOut?.toJsonSchemaRecurse(Q)??null})}compile(Q){if(Q.traversalKind==="Allows"){if(!this.introspectableIn)return;Q.return(Q.invoke(this.introspectableIn));return}if(this.introspectableIn)Q.line(Q.invoke(this.introspectableIn));Q.line(`ctx.queueMorphs(${this.compiledMorphs})`)}traverseAllows=(Q,X)=>!this.introspectableIn||this.introspectableIn.traverseAllows(Q,X);traverseApply=(Q,X)=>{if(this.introspectableIn)this.introspectableIn.traverseApply(Q,X);X.queueMorphs(this.morphs)};hasEqualMorphs(Q){return q1(this.morphs,Q.morphs,{isEqual:(X,Y)=>X===Y||$(X,"root")&&$(Y,"root")&&X.equals(Y)})}}var t6={implementation:DZ,Node:QX},wZ=(Q,X)=>`The intersection of distinct morphs at a single path is indeterminate:
|
|
30
|
+
Left: ${Q}
|
|
31
|
+
Right: ${X}`;var KZ=B({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:(Q)=>W2(Q)??r(Q)},dateAllowsInvalid:{}},normalize:(Q)=>{let X=typeof Q==="string"?{proto:P1[Q]}:typeof Q==="function"?N(Q)?Q:{proto:Q}:typeof Q.proto==="string"?{...Q,proto:P1[Q.proto]}:Q;if(typeof X.proto!=="function")H(w2.writeInvalidSchemaMessage(X.proto));if(v1(X,"dateAllowsInvalid")&&X.proto!==Date)H(w2.writeBadInvalidDateMessage(X.proto));return X},applyConfig:(Q,X)=>{if(Q.dateAllowsInvalid===void 0&&Q.proto===Date&&X.dateAllowsInvalid)return{...Q,dateAllowsInvalid:!0};return Q},defaults:{description:(Q)=>Q.builtinName?dQ[Q.builtinName]:`an instance of ${Q.proto.name}`,actual:(Q)=>Q instanceof Date&&Q.toString()==="Invalid Date"?"an invalid Date":Z2(Q)},intersections:{proto:(Q,X)=>Q.proto===Date&&X.proto===Date?Q.dateAllowsInvalid?X:Q:M6(Q.proto,X.proto)?Q:M6(X.proto,Q.proto)?X:q.init("proto",Q,X),domain:(Q,X)=>X.domain==="object"?Q:q.init("domain",F.intrinsic.object.internal,X)}});class XX extends j1{builtinName=W2(this.proto);serializedConstructor=this.json.proto;requiresInvalidDateCheck=this.proto===Date&&!this.dateAllowsInvalid;traverseAllows=this.requiresInvalidDateCheck?(Q)=>Q instanceof Date&&Q.toString()!=="Invalid Date":(Q)=>Q instanceof this.proto;compiledCondition=`data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck?' && data.toString() !== "Invalid Date"':""}`;compiledNegation=`!(${this.compiledCondition})`;innerToJsonSchema(Q){switch(this.builtinName){case"Array":return{type:"array"};case"Date":return Q.fallback.date?.({code:"date",base:{}})??Q.fallback.proto({code:"proto",base:{},proto:this.proto});default:return Q.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 w2={implementation:KZ,Node:XX,writeBadInvalidDateMessage:(Q)=>`dateAllowsInvalid may only be specified with constructor Date (was ${Q.name})`,writeInvalidSchemaMessage:(Q)=>`instanceOf operand must be a function (was ${f(Q)})`};var NZ=B({kind:"union",hasAssociatedError:!0,collapsibleKey:"branches",keys:{ordered:{},branches:{child:!0,parse:(Q,X)=>{let Y=[];for(let U of Q){let Z=$(U,"root")?U.branches:X.$.parseSchema(U).branches;for(let W of Z)if(W.hasKind("morph")){let G=Y.findIndex((L)=>L.hasKind("morph")&&L.hasEqualMorphs(W));if(G===-1)Y.push(W);else{let L=Y[G];Y[G]=X.$.node("morph",{...L.inner,in:L.rawIn.rawOr(W.rawIn)})}}else Y.push(W)}if(!X.def.ordered)Y.sort((U,Z)=>U.hash<Z.hash?-1:1);return Y}}},normalize:(Q)=>K(Q)?{branches:Q}:Q,reduce:(Q,X)=>{let Y=gZ(Q);if(Y.length===1)return Y[0];if(Y.length===Q.branches.length)return;return X.node("union",{...Q,branches:Y},{prereduced:!0})},defaults:{description:(Q)=>Q.distribute((X)=>X.description,i1),expected:(Q)=>{let X=gQ(Q.errors,"propString"),Y=Object.entries(X).map(([U,Z])=>{let W=[];for(let J of Z)G1(W,J.expected);let G=i1(W),L=Z.every((J)=>J.actual===Z[0].actual)?Z[0].actual:T(Z[0].data);return`${U&&`${U} `}must be ${G}${L&&` (was ${L})`}`});return i1(Y)},problem:(Q)=>Q.expected,message:(Q)=>{if(Q.problem[0]==="[")return`value at ${Q.problem}`;return Q.problem}},intersections:{union:(Q,X,Y)=>{if(Q.isNever!==X.isNever)return q.init("presence",Q,X);let U;if(Q.ordered){if(X.ordered)H(xZ(Q.expression,X.expression));if(U=a6(X.branches,Q.branches,Y),U instanceof q)U.invert()}else U=a6(Q.branches,X.branches,Y);if(U instanceof q)return U;return Y.$.parseSchema(Q.ordered||X.ordered?{branches:U,ordered:!0}:{branches:U})},..._1("union",(Q,X,Y)=>{let U=a6(Q.branches,[X],Y);if(U instanceof q)return U;if(U.length===1)return U[0];return Y.$.parseSchema(Q.ordered?{branches:U,ordered:!0}:{branches:U})})}});class ZX extends a{isBoolean=this.branches.length===2&&this.branches[0].hasUnit(!1)&&this.branches[1].hasUnit(!0);get branchGroups(){let Q=[],X=-1;for(let Y of this.branches){if(Y.hasKind("unit")&&Y.domain==="boolean"){if(X===-1)X=Q.length,Q.push(Y);else Q[X]=F.intrinsic.boolean;continue}Q.push(Y)}return Q}unitBranches=this.branches.filter((Q)=>Q.rawIn.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?fZ(this.discriminant):null;expression=this.distribute((Q)=>Q.nestableExpression,vZ);createBranchedOptimisticRootApply(){return(Q,X)=>{let Y=this.traverseOptimistic(Q);if(Y!==l)return Y;let U=new Y1(Q,this.$.resolvedConfig);return this.traverseApply(Q,U),U.finalize(X)}}get shallowMorphs(){return this.branches.reduce((Q,X)=>G1(Q,X.shallowMorphs),[])}get defaultShortDescription(){return this.distribute((Q)=>Q.defaultShortDescription,i1)}innerToJsonSchema(Q){if(this.branchGroups.length===1&&this.branchGroups[0].equals(F.intrinsic.boolean))return{type:"boolean"};let X=this.branchGroups.map((Y)=>Y.toJsonSchemaRecurse(Q));if(X.every((Y)=>Object.keys(Y).length===1&&v1(Y,"const")))return{enum:X.map((Y)=>Y.const)};return{anyOf:X}}traverseAllows=(Q,X)=>this.branches.some((Y)=>Y.traverseAllows(Q,X));traverseApply=(Q,X)=>{let Y=[];for(let U=0;U<this.branches.length;U++){if(X.pushBranch(),this.branches[U].traverseApply(Q,X),!X.hasError()){if(this.branches[U].includesTransform)return X.queuedMorphs.push(...X.popBranch().queuedMorphs);return X.popBranch()}Y.push(X.popBranch().error)}X.errorFromNodeContext({code:"union",errors:Y,meta:this.meta})};traverseOptimistic=(Q)=>{for(let X=0;X<this.branches.length;X++){let Y=this.branches[X];if(Y.traverseAllows(Q)){if(Y.contextFreeMorph)return Y.contextFreeMorph(Q);return Q}}return l};compile(Q){if(!this.discriminant||this.unitBranches.length===this.branches.length&&this.branches.length===2)return this.compileIndiscriminable(Q);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 Y=this.discriminant.cases,U=Object.keys(Y),{optimistic:Z}=Q;if(Q.optimistic=!1,Q.block(`switch(${X})`,()=>{for(let _ in Y){let A=Y[_],O=_==="default"?_:`case ${_}`,C;if(A===!0)C=Z?"data":"true";else if(Z)if(A.rootApplyStrategy==="branchedOptimistic")C=Q.invoke(A,{kind:"Optimistic"});else if(A.contextFreeMorph)C=`${Q.invoke(A)} ? ${S(A.contextFreeMorph)}(data) : "${l}"`;else C=`${Q.invoke(A)} ? data : "${l}"`;else C=Q.invoke(A);Q.line(`${O}: return ${C}`)}return Q}),Q.traversalKind==="Allows"){Q.return(Z?`"${l}"`:!1);return}let W=i1(this.discriminant.kind==="domain"?U.map((_)=>{let A=_.slice(1,-1);return A==="function"?m.object:m[A]}):U),G=this.discriminant.path.map((_)=>typeof _==="symbol"?S(_):JSON.stringify(_)),L=JSON.stringify(W),J=this.discriminant.kind==="domain"?`${jZ}[${X}]`:`${bZ}(${X})`;Q.line(`ctx.errorFromNodeContext({
|
|
32
|
+
code: "predicate",
|
|
33
|
+
expected: ${L},
|
|
34
|
+
actual: ${J},
|
|
35
|
+
relativePath: [${G}],
|
|
36
|
+
meta: ${this.compiledMeta}
|
|
37
|
+
})`)}compileIndiscriminable(Q){if(Q.traversalKind==="Apply"){Q.const("errors","[]");for(let X of this.branches)Q.line("ctx.pushBranch()").line(Q.invoke(X)).if("!ctx.hasError()",()=>Q.return(X.includesTransform?"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)":"ctx.popBranch()")).line("errors.push(ctx.popBranch().error)");Q.line(`ctx.errorFromNodeContext({ code: "union", errors, meta: ${this.compiledMeta} })`)}else{let{optimistic:X}=Q;Q.optimistic=!1;for(let Y of this.branches)Q.if(`${Q.invoke(Y)}`,()=>Q.return(X?Y.contextFreeMorph?`${S(Y.contextFreeMorph)}(data)`:"data":!0));Q.return(X?`"${l}"`:!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 Z=V(this.unitBranches,(W,G)=>[`${G.rawIn.serializedValue}`,G.hasKind("morph")?G:!0]);return{kind:"unit",path:[],optionallyChainedPropString:"data",cases:Z}}let Q=[];for(let Z=0;Z<this.branches.length-1;Z++){let W=this.branches[Z];for(let G=Z+1;G<this.branches.length;G++){let L=this.branches[G],J=i(W.rawIn,L.rawIn,W.$);if(!(J instanceof q))continue;for(let _ of J){if(!_.kind||_.optional)continue;let A,O;if(_.kind==="domain"){let{l:b,r:H1}=_;A=`"${typeof b==="string"?b:b.domain}"`,O=`"${typeof H1==="string"?H1:H1.domain}"`}else if(_.kind==="unit")A=_.l.serializedValue,O=_.r.serializedValue;else continue;let C=Q.find((b)=>q1(b.path,_.path)&&b.kind===_.kind);if(!C)Q.push({kind:_.kind,cases:{[A]:{branchIndices:[Z],condition:_.l},[O]:{branchIndices:[G],condition:_.r}},path:_.path});else{if(C.cases[A])C.cases[A].branchIndices=G1(C.cases[A].branchIndices,Z);else C.cases[A]??={branchIndices:[Z],condition:_.l};if(C.cases[O])C.cases[O].branchIndices=G1(C.cases[O].branchIndices,G);else C.cases[O]??={branchIndices:[G],condition:_.r}}}}}let X=this.ordered?IZ(Q,this.branches):Q;if(!X.length)return null;let Y=PZ(X,this),U={};for(let Z in Y.best.cases){let W=EZ(Y,Z);if(W===null){U[Z]=!0;continue}if(W.length===this.branches.length)return null;if(this.ordered)W.sort((J,_)=>J.originalIndex-_.originalIndex);let G=W.map((J)=>J.branch),L=G.length===1?G[0]:this.$.node("union",this.ordered?{branches:G,ordered:!0}:G);Object.assign(this.referencesById,L.referencesById),U[Z]=L}if(Y.defaultEntries.length){let Z=Y.defaultEntries.map((W)=>W.branch);U.default=this.$.node("union",this.ordered?{branches:Z,ordered:!0}:Z,{prereduced:!0}),Object.assign(this.referencesById,U.default.referencesById)}return Object.assign(Y.location,{cases:U})}}var PZ=(Q,X)=>{let U=Q.sort((G,L)=>G.path.length===L.path.length?Object.keys(L.cases).length-Object.keys(G.cases).length:G.path.length-L.path.length)[0],Z={kind:U.kind,path:U.path,optionallyChainedPropString:WX(U.path)},W=X.branches.map((G,L)=>({originalIndex:L,branch:G}));return{best:U,location:Z,defaultEntries:W,node:X}},EZ=(Q,X)=>{let Y=Q.best.cases[X],U=SZ(Y.condition,Q.location.path,Q.node.$),Z=[],W=[];for(let G=0;G<Q.defaultEntries.length;G++){let L=Q.defaultEntries[G];if(Y.branchIndices.includes(L.originalIndex)){let J=YX(Q.node.branches[L.originalIndex],Q.location);if(J===null)Z=null;else Z?.push({originalIndex:L.originalIndex,branch:J})}else if(L.branch.hasKind("alias")&&U.hasKind("domain")&&U.domain==="object")Z?.push(L);else{if(L.branch.rawIn.overlaps(U)){let J=YX(L.branch,Q.location);Z?.push({originalIndex:L.originalIndex,branch:J})}W.push(L)}}return Q.defaultEntries=W,Z},IZ=(Q,X)=>{return Q.filter((U)=>{let Z=Object.values(U.cases).map((W)=>W.branchIndices);for(let W=0;W<Z.length-1;W++){let G=Z[W];for(let L=W+1;L<Z.length;L++){let J=Z[L];for(let _ of G)for(let A of J)if(_>A){if(X[_].overlaps(X[A]))return!1}}}return!0})},SZ=(Q,X,Y)=>{let U=Q==="undefined"?Y.node("unit",{unit:void 0}):Q==="null"?Y.node("unit",{unit:null}):Q==="boolean"?Y.units([!0,!1]):Q;for(let Z=X.length-1;Z>=0;Z--){let W=X[Z];U=Y.node("intersection",typeof W==="number"?{proto:"Array",sequence:[...yQ(W).map((G)=>({})),U]}:{domain:"object",required:[{key:W,value:U}]})}return U},WX=(Q)=>Q.reduce((X,Y)=>X+N6(Y,!0),"data"),jZ=S(kQ),bZ=S(T),e6={implementation:NZ,Node:ZX},fZ=(Q)=>({kind:Q.kind,path:Q.path.map((X)=>typeof X==="string"?X:X1(X)),cases:V(Q.cases,(X,Y)=>[X,Y===!0?Y:Y.hasKind("union")&&Y.discriminantJson?Y.discriminantJson:Y.json])}),yZ={delimiter:" | ",finalDelimiter:" | "},vZ=(Q)=>i1(Q,yZ),i1=(Q,X)=>{let Y=X?.delimiter??", ",U=X?.finalDelimiter??" or ";if(Q.length===0)return"never";if(Q.length===1)return Q[0];if(Q.length===2&&Q[0]==="false"&&Q[1]==="true"||Q[0]==="true"&&Q[1]==="false")return"boolean";let Z={},W=Q.filter((L)=>Z[L]?!1:Z[L]=!0),G=W.pop();return`${W.join(Y)}${W.length?U:""}${G}`},a6=(Q,X,Y)=>{let U=X.map(()=>[]);for(let W=0;W<Q.length;W++){let G={};for(let L=0;L<X.length;L++){if(U[L]===null)continue;if(Q[W].equals(X[L])){U[L]=null,G={};break}let J=P(Q[W],X[L],Y);if(J instanceof q)continue;if(J.equals(Q[W])){U[L].push(Q[W]),G={};break}if(J.equals(X[L]))U[L]=null;else G[L]=J}for(let L in G)U[L][W]=G[L]}let Z=U.flatMap((W,G)=>W?.flatMap((L)=>L.branches)??X[G]);return Z.length===0?q.init("union",Q,X):Z},gZ=({branches:Q,ordered:X})=>{if(Q.length<2)return Q;let Y=Q.map(()=>!0);for(let U=0;U<Q.length;U++)for(let Z=U+1;Z<Q.length&&Y[U]&&Y[Z];Z++){if(Q[U].equals(Q[Z])){Y[Z]=!1;continue}let W=i(Q[U].rawIn,Q[Z].rawIn,Q[0].$);if(W instanceof q)continue;if(!X)kZ(Q[U],Q[Z]);if(W.equals(Q[U].rawIn))Y[U]=!!X;else if(W.equals(Q[Z].rawIn))Y[Z]=!1}return Q.filter((U,Z)=>Y[Z])},kZ=(Q,X)=>{if(!Q.includesTransform&&!X.includesTransform)return;if(!q1(Q.shallowMorphs,X.shallowMorphs))H(UX(Q.expression,X.expression));if(!q1(Q.flatMorphs,X.flatMorphs,{isEqual:(Y,U)=>Y.propString===U.propString&&(Y.node.hasKind("morph")&&U.node.hasKind("morph")?Y.node.hasEqualMorphs(U.node):Y.node.hasKind("intersection")&&U.node.hasKind("intersection")?Y.node.structure?.structuralMorphRef===U.node.structure?.structuralMorphRef:!1)}))H(UX(Q.expression,X.expression))},YX=(Q,X)=>Q.transform((Y,U)=>{if(Y==="domain"||Y==="unit")return null;return U},{shouldTransform:(Y,U)=>{let Z=WX(U.path);if(!X.optionallyChainedPropString.startsWith(Z))return!1;if(Y.hasKind("domain")&&Y.domain==="object")return!0;if((Y.hasKind("domain")||X.kind==="unit")&&Z===X.optionallyChainedPropString)return!0;return Y.children.length!==0&&Y.kind!=="index"}}),UX=(Q,X)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
|
|
38
|
+
Left: ${Q}
|
|
39
|
+
Right: ${X}`,xZ=(Q,X)=>`The intersection of two ordered unions is indeterminate:
|
|
40
|
+
Left: ${Q}
|
|
41
|
+
Right: ${X}`;var hZ=B({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:(Q)=>Q instanceof Date?Q.toISOString():r(Q)}},normalize:(Q)=>Q,defaults:{description:(Q)=>T(Q.unit),problem:({expected:Q,actual:X})=>`${Q===X?`must be reference equal to ${Q} (serialized to the same value)`:`must be ${Q} (was ${X})`}`},intersections:{unit:(Q,X)=>q.init("unit",Q,X),..._1("unit",(Q,X)=>{if(X.allows(Q.unit))return Q;let Y=X.hasKind("intersection")?X.basis:X;if(Y){let U=Y.hasKind("domain")?Y:F.intrinsic.object;if(Q.domain!==U.domain){let Z=Q.domain==="undefined"||Q.domain==="null"||Q.domain==="boolean"?Q.domain:F.intrinsic[Q.domain];return q.init("domain",Z,U)}}return q.init("assignability",Q,X.hasKind("intersection")?X.children.find((U)=>!U.allows(Q.unit)):X)})}});class LX extends j1{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=GX(this.unit,this.serializedValue);compiledNegation=GX(this.unit,this.serializedValue,"negated");expression=T(this.unit);domain=f(this.unit);get defaultShortDescription(){return this.domain==="object"?m.object:this.description}innerToJsonSchema(Q){return this.unit===null?{type:"null"}:F.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:Q.fallback.unit({code:"unit",base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?(Q)=>Q instanceof Date&&Q.toISOString()===this.compiledValue:Number.isNaN(this.unit)?(Q)=>Number.isNaN(Q):(Q)=>Q===this.unit}var QQ={implementation:hZ,Node:LX},GX=(Q,X,Y)=>{if(Q instanceof Date){let U=`data instanceof Date && data.toISOString() === ${X}`;return Y?`!(${U})`:U}if(Number.isNaN(Q))return`${Y?"!":""}Number.isNaN(data)`;return`data ${Y?"!":"="}== ${X}`};var uZ=B({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:(Q,X)=>{let Y=X.$.parseSchema(Q);if(!Y.extends(F.intrinsic.key))return H(mZ(Y.expression));let U=Y.branches.filter((Z)=>Z.hasKind("unit"));if(U.length)return H(pZ(U.map((Z)=>T(Z.unit))));return Y}},value:{child:!0,parse:(Q,X)=>X.$.parseSchema(Q)}},normalize:(Q)=>Q,defaults:{description:(Q)=>`[${Q.signature.expression}]: ${Q.value.description}`},intersections:{index:(Q,X,Y)=>{if(Q.signature.equals(X.signature)){let U=P(Q.value,X.value,Y),Z=U instanceof q?F.intrinsic.never.internal:U;return Y.$.node("index",{signature:Q.signature,value:Z})}if(Q.signature.extends(X.signature)&&Q.value.subsumes(X.value))return X;if(X.signature.extends(Q.signature)&&X.value.subsumes(Q.value))return Q;return null}}});class _X extends t{impliedBasis=F.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=R(this.value.flatRefs.map((Q)=>U1([this.signature,...Q.path],Q.node)),U1([this.signature],this.value));traverseAllows=(Q,X)=>N1(Q).every((Y)=>{if(this.signature.traverseAllows(Y[0],X))return c(Y[0],()=>this.value.traverseAllows(Y[1],X),X);return!0});traverseApply=(Q,X)=>{for(let Y of N1(Q))if(this.signature.traverseAllows(Y[0],X))c(Y[0],()=>this.value.traverseApply(Y[1],X),X)};_transform(Q,X){X.path.push(this.signature);let Y=super._transform(Q,X);return X.path.pop(),Y}compile(){}}var XQ={implementation:uZ,Node:_X},pZ=(Q)=>`Index keys ${Q.join(", ")} should be specified as named props.`,mZ=(Q)=>`Indexed key definition '${Q}' must be a string or symbol`;var lZ=B({kind:"required",hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(Q,X)=>X.$.parseSchema(Q)}},normalize:(Q)=>Q,defaults:{description:(Q)=>`${Q.compiledKey}: ${Q.value.description}`,expected:(Q)=>Q.missingValueDescription,actual:()=>"missing"},intersections:{required:T2,optional:T2}});class JX extends B2{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=R1(this.errorContext)}var YQ={implementation:lZ,Node:JX};var dZ=B({kind:"sequence",hasAssociatedError:!1,collapsibleKey:"variadic",keys:{prefix:{child:!0,parse:(Q,X)=>{if(Q.length===0)return;return Q.map((Y)=>X.$.parseSchema(Y))}},optionals:{child:!0,parse:(Q,X)=>{if(Q.length===0)return;return Q.map((Y)=>X.$.parseSchema(Y))}},defaultables:{child:(Q)=>Q.map((X)=>X[0]),parse:(Q,X)=>{if(Q.length===0)return;return Q.map((Y)=>{let U=X.$.parseSchema(Y[0]);return R2(U,Y[1],null),[U,Y[1]]})},serialize:(Q)=>Q.map((X)=>[X[0].collapsibleJson,r(X[1])]),reduceIo:(Q,X,Y)=>{if(Q==="in"){X.optionals=Y.map((U)=>U[0].rawIn);return}X.prefix=Y.map((U)=>U[0].rawOut);return}},variadic:{child:!0,parse:(Q,X)=>X.$.parseSchema(Q,X)},minVariadicLength:{parse:(Q)=>Q===0?void 0:Q},postfix:{child:!0,parse:(Q,X)=>{if(Q.length===0)return;return Q.map((Y)=>X.$.parseSchema(Y))}}},normalize:(Q)=>{if(typeof Q==="string")return{variadic:Q};if("variadic"in Q||"prefix"in Q||"defaultables"in Q||"optionals"in Q||"postfix"in Q||"minVariadicLength"in Q){if(Q.postfix?.length){if(!Q.variadic)return H(nZ);if(Q.optionals?.length||Q.defaultables?.length)return H(ZQ)}if(Q.minVariadicLength&&!Q.variadic)return H("minVariadicLength may not be specified without a variadic element");return Q}return{variadic:Q}},reduce:(Q,X)=>{let Y=Q.minVariadicLength??0,U=Q.prefix?.slice()??[],Z=Q.defaultables?.slice()??[],W=Q.optionals?.slice()??[],G=Q.postfix?.slice()??[];if(Q.variadic){while(W[W.length-1]?.equals(Q.variadic))W.pop();if(W.length===0&&Z.length===0)while(U[U.length-1]?.equals(Q.variadic))U.pop(),Y++;while(G[0]?.equals(Q.variadic))G.shift(),Y++}else if(W.length===0&&Z.length===0)U.push(...G.splice(0));if(Y!==Q.minVariadicLength||Q.prefix&&Q.prefix.length!==U.length)return X.node("sequence",{...Q,prefix:U,defaultables:Z,optionals:W,postfix:G,minVariadicLength:Y},{prereduced:!0})},defaults:{description:(Q)=>{if(Q.isVariadicOnly)return`${Q.variadic.nestableExpression}[]`;return`[${Q.tuple.map((Y)=>Y.kind==="defaultables"?`${Y.node.nestableExpression} = ${T(Y.default)}`:Y.kind==="optionals"?`${Y.node.nestableExpression}?`:Y.kind==="variadic"?`...${Y.node.nestableExpression}[]`:Y.node.expression).join(", ")}]`}},intersections:{sequence:(Q,X,Y)=>{let U=K2({l:Q.tuple,r:X.tuple,disjoint:new q,result:[],fixedVariants:[],ctx:Y}),Z=U.disjoint.length===0?[U,...U.fixedVariants]:U.fixedVariants;return Z.length===0?U.disjoint:Z.length===1?Y.$.node("sequence",HX(Z[0].result)):Y.$.node("union",Z.map((W)=>({proto:Array,sequence:HX(W.result)})))}}});class qX extends t{impliedBasis=F.intrinsic.Array.internal;tuple=iZ(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((Q)=>{if(Q.kind==="defaultables"||Q.kind==="optionals")return this.defaultablesAndOptionals.push(Q.node),!0;return Q.kind==="prefix"});variadicOrPostfix=F1(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return j6(this.flatRefs,this.prevariadic.flatMap((Q,X)=>R(Q.node.flatRefs.map((Y)=>U1([`${X}`,...Y.path],Y.node)),U1([`${X}`],Q.node)))),j6(this.flatRefs,this.variadicOrPostfix.flatMap((Q)=>R(Q.flatRefs.map((X)=>U1([F.intrinsic.nonNegativeIntegerString.internal,...X.path],X.node)),U1([F.intrinsic.nonNegativeIntegerString.internal],Q)))),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=cZ(this);defaultValueMorphsReference=this.defaultValueMorphs.length?S(this.defaultValueMorphs):void 0;elementAtIndex(Q,X){if(X<this.prevariadic.length)return this.tuple[X];let Y=Q.length-this.postfixLength;if(X>=Y)return{kind:"postfix",node:this.postfix[X-Y]};return{kind:"variadic",node:this.variadic??D(`Unexpected attempt to access index ${X} on ${this}`)}}traverseAllows=(Q,X)=>{for(let Y=0;Y<Q.length;Y++)if(!this.elementAtIndex(Q,Y).node.traverseAllows(Q[Y],X))return!1;return!0};traverseApply=(Q,X)=>{let Y=0;for(;Y<Q.length;Y++)c(Y,()=>this.elementAtIndex(Q,Y).node.traverseApply(Q[Y],X),X)};get element(){return this.cacheGetter("element",this.$.node("union",this.children))}compile(Q){if(this.prefix)for(let[X,Y]of this.prefix.entries())Q.traverseKey(`${X}`,`data[${X}]`,Y);for(let[X,Y]of this.defaultablesAndOptionals.entries()){let U=`${X+this.prefixLength}`;Q.if(`${U} >= data.length`,()=>Q.traversalKind==="Allows"?Q.return(!0):Q.return()),Q.traverseKey(U,`data[${U}]`,Y)}if(this.variadic){if(this.postfix)Q.const("firstPostfixIndex",`data.length${this.postfix?`- ${this.postfix.length}`:""}`);if(Q.for(`i < ${this.postfix?"firstPostfixIndex":"data.length"}`,()=>Q.traverseKey("i","data[i]",this.variadic),this.prevariadic.length),this.postfix)for(let[X,Y]of this.postfix.entries()){let U=`firstPostfixIndex + ${X}`;Q.traverseKey(U,`data[${U}]`,Y)}}if(Q.traversalKind==="Allows")Q.return(!0)}_transform(Q,X){X.path.push(F.intrinsic.nonNegativeIntegerString.internal);let Y=super._transform(Q,X);return X.path.pop(),Y}expression=this.description;reduceJsonSchema(Q,X){let Y=X.target==="draft-07";if(this.prevariadic.length){let U=this.prevariadic.map((Z)=>{let W=Z.node.toJsonSchemaRecurse(X);if(Z.kind==="defaultables"){let G=typeof Z.default==="function"?Z.default():Z.default;W.default=F.intrinsic.jsonData.allows(G)?G:X.fallback.defaultValue({code:"defaultValue",base:W,value:G})}return W});if(Y)Q.items=U;else Q.prefixItems=U}if(this.minLength)Q.minItems=this.minLength;if(this.variadic){let U=this.variadic.toJsonSchemaRecurse(X);if(Y&&this.prevariadic.length)Q.additionalItems=U;else Q.items=U;if(this.maxLength)Q.maxItems=this.maxLength;if(this.postfix){let Z=this.postfix.map((W)=>W.toJsonSchemaRecurse(X));Q=X.fallback.arrayPostfix({code:"arrayPostfix",base:Q,elements:Z})}}else{if(Y)Q.additionalItems=!1;else Q.items=!1;delete Q.maxItems}return Q}}var oZ={},cZ=(Q)=>{if(!Q.defaultables)return[];let X=[],Y="[",U=Q.prefixLength+Q.defaultablesLength-1;for(let Z=Q.prefixLength;Z<=U;Z++){let[W,G]=Q.defaultables[Z-Q.prefixLength];X.push(s6(Z,W,G)),Y+=`${Z}: ${W.id} = ${r(G)}, `}return Y+="]",oZ[Y]??=X},UQ={implementation:dZ,Node:qX},iZ=(Q)=>{let X=[];if(Q.prefix)for(let Y of Q.prefix)X.push({kind:"prefix",node:Y});if(Q.defaultables)for(let[Y,U]of Q.defaultables)X.push({kind:"defaultables",node:Y,default:U});if(Q.optionals)for(let Y of Q.optionals)X.push({kind:"optionals",node:Y});if(Q.variadic)X.push({kind:"variadic",node:Q.variadic});if(Q.postfix)for(let Y of Q.postfix)X.push({kind:"postfix",node:Y});return X},HX=(Q)=>Q.reduce((X,Y)=>{if(Y.kind==="variadic")X.variadic=Y.node;else if(Y.kind==="defaultables")X.defaultables=R(X.defaultables,[[Y.node,Y.default]]);else X[Y.kind]=R(X[Y.kind],Y.node);return X},{}),ZQ="A postfix required element cannot follow an optional or defaultable element",nZ="A postfix element requires a variadic element",K2=(Q)=>{let[X,...Y]=Q.l,[U,...Z]=Q.r;if(!X||!U)return Q;let W=Y[Y.length-1]?.kind==="postfix",G=Z[Z.length-1]?.kind==="postfix",L=X.kind==="prefix"||U.kind==="prefix"?"prefix":X.kind==="postfix"||U.kind==="postfix"?"postfix":X.kind==="variadic"&&U.kind==="variadic"?"variadic":W||G?"prefix":X.kind==="defaultables"||U.kind==="defaultables"?"defaultables":"optionals";if(X.kind==="prefix"&&U.kind==="variadic"&&G){let O=K2({...Q,fixedVariants:[],r:Z.map((C)=>({...C,kind:"prefix"}))});if(O.disjoint.length===0)Q.fixedVariants.push(O)}else if(U.kind==="prefix"&&X.kind==="variadic"&&W){let O=K2({...Q,fixedVariants:[],l:Y.map((C)=>({...C,kind:"prefix"}))});if(O.disjoint.length===0)Q.fixedVariants.push(O)}let J=P(X.node,U.node,Q.ctx);if(J instanceof q)if(L==="prefix"||L==="postfix")Q.disjoint.push(...J.withPrefixKey(L==="prefix"?Q.result.length:`-${Y.length+1}`,FX(X)&&FX(U)?"required":"optional")),Q.result=[...Q.result,{kind:L,node:F.intrinsic.never.internal}];else if(L==="optionals"||L==="defaultables")return Q;else return K2({...Q,fixedVariants:[],l:Y.map((O)=>({...O,kind:"prefix"})),r:Y.map((O)=>({...O,kind:"prefix"}))});else if(L==="defaultables"){if(X.kind==="defaultables"&&U.kind==="defaultables"&&X.default!==U.default)H(n6(X.default,U.default));Q.result=[...Q.result,{kind:L,node:J,default:X.kind==="defaultables"?X.default:U.kind==="defaultables"?U.default:D(`Unexpected defaultable intersection from ${X.kind} and ${U.kind} elements.`)}]}else Q.result=[...Q.result,{kind:L,node:J}];let _=Q.l.length,A=Q.r.length;if(X.kind!=="variadic"||_>=A&&(U.kind==="variadic"||A===1))Q.l=Y;if(U.kind!=="variadic"||A>=_&&(X.kind==="variadic"||_===1))Q.r=Z;return K2(Q)},FX=(Q)=>Q.kind==="prefix"||Q.kind==="postfix";var OX=(Q)=>(X)=>{if(X.props.length||X.index){let Y=X.index?.map((Z)=>Z[Q])??[];for(let Z of X.props)Y.push(Z[Q]);if(X.undeclared)Y.push(`+ (undeclared): ${X.undeclared}`);let U=`{ ${Y.join(", ")} }`;return X.sequence?`${U} & ${X.sequence.description}`:U}return X.sequence?.description??"{}"},sZ=OX("description"),rZ=OX("expression"),AX=(Q,X,Y)=>{let U=Q.required?"required":"optional";if(!X.signature.allows(Q.key))return null;let Z=i(Q.value,X.value,Y);if(Z instanceof q)return U==="optional"?Y.node("optional",{key:Q.key,value:F.intrinsic.never.internal}):Z.withPrefixKey(Q.key,Q.kind);return null},tZ=B({kind:"structure",hasAssociatedError:!1,normalize:(Q)=>Q,applyConfig:(Q,X)=>{if(!Q.undeclared&&X.onUndeclaredKey!=="ignore")return{...Q,undeclared:X.onUndeclaredKey};return Q},keys:{required:{child:!0,parse:k("required"),reduceIo:(Q,X,Y)=>{X.required=R(X.required,Y.map((U)=>Q==="in"?U.rawIn:U.rawOut));return}},optional:{child:!0,parse:k("optional"),reduceIo:(Q,X,Y)=>{if(Q==="in"){X.optional=Y.map((U)=>U.rawIn);return}for(let U of Y)X[U.outProp.kind]=R(X[U.outProp.kind],U.outProp.rawOut)}},index:{child:!0,parse:k("index")},sequence:{child:!0,parse:k("sequence")},undeclared:{parse:(Q)=>Q==="ignore"?void 0:Q,reduceIo:(Q,X,Y)=>{if(Y==="reject"){X.undeclared="reject";return}if(Q==="in")delete X.undeclared;else X.undeclared="reject"}}},defaults:{description:sZ},intersections:{structure:(Q,X,Y)=>{let U={...Q.inner},Z={...X.inner},W=new q;if(Q.undeclared){let J=Q.keyof();for(let _ of X.requiredKeys)if(!J.allows(_))W.add("presence",F.intrinsic.never.internal,X.propsByKey[_].value,{path:[_]});if(Z.optional)Z.optional=Z.optional.filter((_)=>J.allows(_.key));if(Z.index)Z.index=Z.index.flatMap((_)=>{if(_.signature.extends(J))return _;let A=i(J,_.signature,Y.$);if(A instanceof q)return[];let O=r2(A,_.value,Y.$);if(O.required)Z.required=F1(Z.required,O.required);if(O.optional)Z.optional=F1(Z.optional,O.optional);return O.index??[]})}if(X.undeclared){let J=X.keyof();for(let _ of Q.requiredKeys)if(!J.allows(_))W.add("presence",Q.propsByKey[_].value,F.intrinsic.never.internal,{path:[_]});if(U.optional)U.optional=U.optional.filter((_)=>J.allows(_.key));if(U.index)U.index=U.index.flatMap((_)=>{if(_.signature.extends(J))return _;let A=i(J,_.signature,Y.$);if(A instanceof q)return[];let O=r2(A,_.value,Y.$);if(O.required)U.required=F1(U.required,O.required);if(O.optional)U.optional=F1(U.optional,O.optional);return O.index??[]})}let G={};if(Q.undeclared||X.undeclared)G.undeclared=Q.undeclared==="reject"||X.undeclared==="reject"?"reject":"delete";let L=m1({kind:"structure",baseInner:G,l:l1(U),r:l1(Z),roots:[],ctx:Y});if(L instanceof q)W.push(...L);if(W.length)return W;return L}},reduce:(Q,X)=>{if(!Q.required&&!Q.optional)return;let Y={},U=!1,Z=Q.optional?[...Q.optional]:[];if(Q.required)for(let W=0;W<Q.required.length;W++){let G=Q.required[W];if(G.key in Y)H(zX(G.key));if(Y[G.key]=!0,Q.index)for(let L of Q.index){let J=AX(G,L,X);if(J instanceof q)return J}}if(Q.optional)for(let W=0;W<Q.optional.length;W++){let G=Q.optional[W];if(G.key in Y)H(zX(G.key));if(Y[G.key]=!0,Q.index)for(let L of Q.index){let J=AX(G,L,X);if(J instanceof q)return J;if(J!==null)Z[W]=J,U=!0}}if(U)return X.node("structure",{...Q,optional:Z},{prereduced:!0})}});class VX extends t{impliedBasis=F.intrinsic.object.internal;impliedSiblings=this.children.flatMap((Q)=>Q.impliedSiblings??[]);props=F1(this.required,this.optional);propsByKey=V(this.props,(Q,X)=>[X.key,X]);propsByKeyReference=S(this.propsByKey);expression=rZ(this);requiredKeys=this.required?.map((Q)=>Q.key)??[];optionalKeys=this.optional?.map((Q)=>Q.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let Q=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:X}of this.index)Q=Q.concat(X.branches);return this._keyof=this.$.node("union",Q)}map(Q){return this.$.node("structure",this.props.flatMap(Q).reduce((X,Y)=>{let U=this.propsByKey[Y.key];if(N(Y)){if(Y.kind!=="required"&&Y.kind!=="optional")return H(`Map result must have kind "required" or "optional" (was ${Y.kind})`);return X[Y.kind]=R(X[Y.kind],Y),X}let Z=Y.kind??U?.kind??"required",W=V(Y,(G,L)=>(G in M2.implementation.keys)?[G,L]:[]);return X[Z]=R(X[Z],this.$.node(Z,W)),X},{}))}assertHasKeys(Q){let X=Q.filter((Y)=>!C2(Y,this.keyof()));if(X.length)return H($X(this.expression,X))}get(Q,...X){let Y,U=!1,Z=X8(Q);if((typeof Z==="string"||typeof Z==="symbol")&&this.propsByKey[Z])Y=this.propsByKey[Z].value,U=this.propsByKey[Z].required;if(this.index){for(let G of this.index)if(C2(Z,G.signature))Y=Y?.and(G.value)??G.value}if(this.sequence&&C2(Z,F.intrinsic.nonNegativeIntegerString))if($(Z,"root")){if(this.sequence.variadic)Y=Y?.and(this.sequence.element)??this.sequence.element}else{let G=Number.parseInt(Z);if(G<this.sequence.prevariadic.length){let L=this.sequence.prevariadic[G].node;Y=Y?.and(L)??L,U||=G<this.sequence.prefixLength}else if(this.sequence.variadic){let L=this.$.node("union",this.sequence.variadicOrPostfix);Y=Y?.and(L)??L}}if(!Y){if(this.sequence?.variadic&&$(Z,"root")&&Z.extends(F.intrinsic.number))return H(Y8(Z.expression,this.sequence.expression));return H($X(this.expression,[Z]))}let W=Y.get(...X);return U?W:W.or(F.intrinsic.undefined)}pick(...Q){return this.assertHasKeys(Q),this.$.node("structure",this.filterKeys("pick",Q))}omit(...Q){return this.assertHasKeys(Q),this.$.node("structure",this.filterKeys("omit",Q))}optionalize(){let{required:Q,...X}=this.inner;return this.$.node("structure",{...X,optional:this.props.map((Y)=>Y.hasKind("required")?this.$.node("optional",Y.inner):Y)})}require(){let{optional:Q,...X}=this.inner;return this.$.node("structure",{...X,required:this.props.map((Y)=>Y.hasKind("optional")?{key:Y.key,value:Y.value}:Y)})}merge(Q){let X=this.filterKeys("omit",[Q.keyof()]);if(Q.required)X.required=R(X.required,Q.required);if(Q.optional)X.optional=R(X.optional,Q.optional);if(Q.index)X.index=R(X.index,Q.index);if(Q.sequence)X.sequence=Q.sequence;if(Q.undeclared)X.undeclared=Q.undeclared;else delete X.undeclared;return this.$.node("structure",X)}filterKeys(Q,X){let Y=h2(this.inner),U=(Z)=>{let W=X.some((G)=>C2(Z,G));return Q==="pick"?W:!W};if(Y.required)Y.required=Y.required.filter((Z)=>U(Z.key));if(Y.optional)Y.optional=Y.optional.filter((Z)=>U(Z.key));if(Y.index)Y.index=Y.index.filter((Z)=>U(Z.signature));return Y}traverseAllows=(Q,X)=>this._traverse("Allows",Q,X);traverseApply=(Q,X)=>this._traverse("Apply",Q,X);_traverse=(Q,X,Y)=>{let U=Y?.currentErrorCount??0;for(let Z=0;Z<this.props.length;Z++)if(Q==="Allows"){if(!this.props[Z].traverseAllows(X,Y))return!1}else if(this.props[Z].traverseApply(X,Y),Y.failFast&&Y.currentErrorCount>U)return!1;if(this.sequence){if(Q==="Allows"){if(!this.sequence.traverseAllows(X,Y))return!1}else if(this.sequence.traverseApply(X,Y),Y.failFast&&Y.currentErrorCount>U)return!1}if(this.index||this.undeclared==="reject"){let Z=Object.keys(X);Z.push(...Object.getOwnPropertySymbols(X));for(let W=0;W<Z.length;W++){let G=Z[W];if(this.index){for(let L of this.index)if(L.signature.traverseAllows(G,Y)){if(Q==="Allows"){if(!c(G,()=>L.value.traverseAllows(X[G],Y),Y))return!1}else if(c(G,()=>L.value.traverseApply(X[G],Y),Y),Y.failFast&&Y.currentErrorCount>U)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(G)){if(Q==="Allows")return!1;if(Y.errorFromNodeContext({code:"predicate",expected:"removed",actual:"",relativePath:[G],meta:this.meta}),Y.failFast)return!1}}}if(this.structuralMorph&&Y&&!Y.hasError())Y.queueMorphs([this.structuralMorph]);return!0};get defaultable(){return this.cacheGetter("defaultable",this.optional?.filter((Q)=>Q.hasDefault())??[])}declaresKey=(Q)=>(Q in this.propsByKey)||this.index?.some((X)=>X.signature.allows(Q))||this.sequence!==void 0&&F.intrinsic.nonNegativeIntegerString.allows(Q);_compileDeclaresKey(Q){let X=[];if(this.props.length)X.push(`k in ${this.propsByKeyReference}`);if(this.index)for(let Y of this.index)X.push(Q.invoke(Y.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",eZ(this))}structuralMorphRef=this.structuralMorph&&S(this.structuralMorph);compile(Q){if(Q.traversalKind==="Apply")Q.initializeErrorCount();for(let X of this.props)if(Q.check(X),Q.traversalKind==="Apply")Q.returnIfFailFast();if(this.sequence){if(Q.check(this.sequence),Q.traversalKind==="Apply")Q.returnIfFailFast()}if(this.index||this.undeclared==="reject")Q.const("keys","Object.keys(data)"),Q.line("keys.push(...Object.getOwnPropertySymbols(data))"),Q.for("i < keys.length",()=>this.compileExhaustiveEntry(Q));if(Q.traversalKind==="Allows")return Q.return(!0);if(this.structuralMorphRef)Q.if("ctx && !ctx.hasError()",()=>{return Q.line("ctx.queueMorphs(["),Q8(Q,this),Q.line("])")})}compileExhaustiveEntry(Q){if(Q.const("k","keys[i]"),this.index)for(let X of this.index)Q.if(`${Q.invoke(X.signature,{arg:"k",kind:"Allows"})}`,()=>Q.traverseKey("k","data[k]",X.value));if(this.undeclared==="reject")Q.if(`!(${this._compileDeclaresKey(Q)})`,()=>{if(Q.traversalKind==="Allows")return Q.return(!1);return Q.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast",()=>Q.return())});return Q}reduceJsonSchema(Q,X){switch(Q.type){case"object":return this.reduceObjectJsonSchema(Q,X);case"array":let Y=this.sequence?.reduceJsonSchema(Q,X)??Q;if(this.props.length||this.index)return X.fallback.arrayObject({code:"arrayObject",base:Y,object:this.reduceObjectJsonSchema({type:"object"},X)});return Y;default:return E.throwInternalOperandError("structure",Q)}}reduceObjectJsonSchema(Q,X){if(this.props.length){Q.properties={};for(let Y of this.props){let U=Y.value.toJsonSchemaRecurse(X);if(typeof Y.key==="symbol"){X.fallback.symbolKey({code:"symbolKey",base:Q,key:Y.key,value:U,optional:Y.optional});continue}if(Y.hasDefault()){let Z=typeof Y.default==="function"?Y.default():Y.default;U.default=F.intrinsic.jsonData.allows(Z)?Z:X.fallback.defaultValue({code:"defaultValue",base:U,value:Z})}Q.properties[Y.key]=U}if(this.requiredKeys.length&&Q.properties)Q.required=this.requiredKeys.filter((Y)=>typeof Y==="string"&&(Y in Q.properties))}if(this.index)for(let Y of this.index){let U=Y.value.toJsonSchemaRecurse(X);if(Y.signature.equals(F.intrinsic.string)){Q.additionalProperties=U;continue}for(let Z of Y.signature.branches){if(!Z.extends(F.intrinsic.string)){Q=X.fallback.symbolKey({code:"symbolKey",base:Q,key:null,value:U,optional:!1});continue}let W={type:"string"};if(Z.hasKind("morph"))W=X.fallback.morph({code:"morph",base:Z.rawIn.toJsonSchemaRecurse(X),out:Z.rawOut.toJsonSchemaRecurse(X)});if(!Z.hasKind("intersection"))return D(`Unexpected index branch kind ${Z.kind}.`);let{pattern:G}=Z.inner;if(G){let L=Object.assign(W,{pattern:G[0].rule});for(let J=1;J<G.length;J++)W=X.fallback.patternIntersection({code:"patternIntersection",base:L,pattern:G[J].rule});Q.patternProperties??={},Q.patternProperties[L.pattern]=U}}}if(this.undeclared&&!Q.additionalProperties)Q.additionalProperties=!1;return Q}}var WQ={},aZ=(Q)=>{let X="";for(let Y=0;Y<Q.defaultable.length;Y++)X+=Q.defaultable[Y].defaultValueMorphRef;if(Q.sequence?.defaultValueMorphsReference)X+=Q.sequence?.defaultValueMorphsReference;if(Q.undeclared==="delete"){if(X+="delete !(",Q.required)for(let Y of Q.required)X+=Y.compiledKey+" | ";if(Q.optional)for(let Y of Q.optional)X+=Y.compiledKey+" | ";if(Q.index)for(let Y of Q.index)X+=Y.signature.id+" | ";if(Q.sequence)if(Q.sequence.maxLength===null)X+=z.nonNegativeIntegerString.id;else for(let Y=0;Y<Q.sequence.tuple.length;Y++)X+=Y+" | ";X+=")"}return X},eZ=(Q)=>{let X=aZ(Q);if(!X)return;if(WQ[X])return WQ[X];let Y=(U,Z)=>{for(let W=0;W<Q.defaultable.length;W++)if(!(Q.defaultable[W].key in U))Q.defaultable[W].defaultValueMorph(U,Z);if(Q.sequence?.defaultables)for(let W=U.length-Q.sequence.prefixLength;W<Q.sequence.defaultables.length;W++)Q.sequence.defaultValueMorphs[W](U,Z);if(Q.undeclared==="delete"){for(let W in U)if(!Q.declaresKey(W))delete U[W]}return U};return WQ[X]=Y},Q8=(Q,X)=>{let U=`(data${X.defaultable.some((Z)=>Z.defaultValueMorph.length===2)||X.sequence?.defaultValueMorphs.some((Z)=>Z.length===2)?", ctx":""})`;return Q.block(`${U} => `,(Z)=>{for(let W=0;W<X.defaultable.length;W++){let{serializedKey:G,defaultValueMorphRef:L}=X.defaultable[W];Z.if(`!(${G} in data)`,(J)=>J.line(`${L}${U}`))}if(X.sequence?.defaultables)Z.for(`i < ${X.sequence.defaultables.length}`,(W)=>W.set("data[i]",5),`data.length - ${X.sequence.prefixLength}`);if(X.undeclared==="delete")Z.forIn("data",(W)=>W.if(`!(${X._compileDeclaresKey(W)})`,(G)=>G.line("delete data[k]")));return Z.return("data")})},GQ={implementation:tZ,Node:VX},X8=(Q)=>{if($(Q,"root")&&Q.hasKind("unit"))Q=Q.unit;if(typeof Q==="number")Q=`${Q}`;return Q},Y8=(Q,X)=>`${Q} is not allowed as an array index on ${X}. Use the 'nonNegativeIntegerString' keyword instead.`,r2=(Q,X,Y)=>{let[U,Z]=fQ(Q.branches,(G)=>G.hasKind("unit"));if(!U.length)return{index:Y.node("index",{signature:Q,value:X})};let W={};for(let G of U){let L=Y.node("required",{key:G.unit,value:X});W[L.kind]=R(W[L.kind],L)}if(Z.length)W.index=Y.node("index",{signature:Z,value:X});return W},U8=(Q)=>$(Q,"root")?Q.expression:T(Q),$X=(Q,X)=>`Key${X.length===1?"":"s"} ${X.map(U8).join(", ")} ${X.length===1?"does":"do"} not exist on ${Q}`,zX=(Q)=>`Duplicate key ${X1(Q)}`;var o1={...k4,alias:D2.implementation,domain:s2.implementation,unit:QQ.implementation,proto:w2.implementation,union:e6.implementation,morph:t6.implementation,intersection:r6.implementation,divisor:g6.implementation,pattern:d6.implementation,predicate:v6.implementation,required:YQ.implementation,optional:M2.implementation,index:XQ.implementation,sequence:UQ.implementation,structure:GQ.implementation};F.defaultConfig=mQ(Object.assign(V(o1,(Q,X)=>[Q,X.defaults]),{jitless:nQ(),clone:oQ,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:E.defaultConfig}));F.resolvedConfig=A2(F.defaultConfig,F.config);var l4={...x4,alias:D2.Node,domain:s2.Node,unit:QQ.Node,proto:w2.Node,union:e6.Node,morph:t6.Node,intersection:r6.Node,divisor:g6.Node,pattern:d6.Node,predicate:v6.Node,required:YQ.Node,optional:M2.Node,index:XQ.Node,sequence:UQ.Node,structure:GQ.Node};class n1 extends O6{get[x](){return"module"}}var LQ=(Q,X)=>new n1(V(Q,(Y,U)=>[Y,$(U,"module")?LQ(U,X):X.bindReference(U)]));var Z8=(Q)=>K(Q)?Q:("branches"in Q)&&K(Q.branches)?Q.branches:void 0,W8=(Q,X)=>H(`Node of kind ${X} is not valid as a ${Q} definition`),TX=(Q)=>`#${Q} duplicates public alias ${Q}`,_Q={};F.ambient??={};var BX,RX="function $",G8=(Q)=>CX(Q,DX(Q)),CX=(Q,X)=>{let Y=X.write(RX,4),U=X.compile()();for(let Z of Q){if(Z.precompilation)continue;if(Z.traverseAllows=U[`${Z.id}Allows`].bind(U),Z.isRoot()&&!Z.allowsRequiresContext)Z.allows=Z.traverseAllows;if(Z.traverseApply=U[`${Z.id}Apply`].bind(U),U[`${Z.id}Optimistic`])Z.traverseOptimistic=U[`${Z.id}Optimistic`].bind(U);Z.precompilation=Y}},DX=(Q)=>new x2().return(Q.reduce((X,Y)=>{let U=new q2({kind:"Allows"}).indent();Y.compile(U);let Z=U.write(`${Y.id}Allows`),W=new q2({kind:"Apply"}).indent();Y.compile(W);let G=W.write(`${Y.id}Apply`),L=`${X}${Z},
|
|
42
|
+
${G},
|
|
43
|
+
`;if(!Y.hasKind("union"))return L;let J=new q2({kind:"Allows",optimistic:!0}).indent();Y.compile(J);let _=J.write(`${Y.id}Optimistic`);return`${L}${_},
|
|
44
|
+
`},`{
|
|
45
|
+
`)+"}");class t2{config;resolvedConfig;name;get[x](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(Q,X){if(this.config=A2(F.config,X),this.resolvedConfig=A2(F.resolvedConfig,X),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(_Q).length}`,this.name in _Q)H(`A Scope already named ${this.name} already exists`);_Q[this.name]=this;let Y=Object.entries(Q).map((U)=>this.preparseOwnAliasEntry(...U));for(let[U,Z]of Y){let W=U;if(U[0]==="#"){if(W=U.slice(1),W in this.aliases)H(TX(W));this.aliases[W]=Z}else{if(W in this.aliases)H(TX(U));this.aliases[W]=Z,this.exportedNames.push(W)}if(!$(Z,"module")&&!$(Z,"generic")&&!T1(Z)){let G=this.preparseOwnDefinitionFormat(Z,{alias:W});this.resolutions[W]=$(G,"root")?this.bindReference(G):this.createParseContext(G).id}}BX??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[BX.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=F.intrinsic?V(F.intrinsic,(U,Z)=>U.startsWith("json")?[]:[U,this.bindReference(Z)]):{}}cacheGetter(Q,X){return Object.defineProperty(this,Q,{value:X}),X}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema(Q){return Q}generic=(...Q)=>{let X=this;return(Y,U)=>new D1(Q,U?new l2(Y):Y,X,X,U??null)};units=(Q,X)=>{let Y=[];for(let Z of Q)if(!Y.includes(Z))Y.push(Z);let U=Y.map((Z)=>this.node("unit",{unit:Z},X));return this.node("union",U,{...X,prereduced:!0})};lazyResolutions=[];lazilyResolve(Q,X){let Y=this.node("alias",{reference:X??"synthetic",resolve:Q},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(Y);return Y}schema=(Q,X)=>this.finalize(this.parseSchema(Q,X));parseSchema=(Q,X)=>this.node(V2(Q),Q,X);preparseNode(Q,X,Y){let U=typeof Q==="string"?Q:V2(X,Q);if(N(X)&&X.kind===U)return X;if(U==="alias"&&!Y?.prereduced){let{reference:G}=D2.implementation.normalize(X,this);if(G.startsWith("$")){let L=this.resolveRoot(G.slice(1));X=L,U=L.kind}}else if(U==="union"&&p(X,"object")){let G=Z8(X);if(G?.length===1)X=G[0],U=V2(X)}if(N(X)&&X.kind===U)return X;let W=o1[U].normalize?.(X,this)??X;if(N(W))return W.kind===U?W:W8(U,W.kind);return{...Y,$:this,kind:U,def:W,prefix:Y.alias??U}}bindReference(Q){let X;if(N(Q))X=Q.$===this?Q:new Q.constructor(Q.attachments,this);else X=Q.$===this?Q:new D1(Q.params,Q.bodyDef,Q.$,this,Q.hkt);if(!this.resolved)Object.assign(this.referencesById,X.referencesById);return X}resolveRoot(Q){return this.maybeResolveRoot(Q)??H(FQ(Q))}maybeResolveRoot(Q){let X=this.maybeResolve(Q);if($(X,"generic"))return;return X}maybeResolveSubalias(Q){return JQ(this.aliases,Q)??JQ(this.ambient,Q)}get ambient(){return F.ambient}maybeResolve(Q){let X=this.resolutions[Q];if(X){if(typeof X!=="string")return this.bindReference(X);let U=h[X];if($(U,"root"))return this.resolutions[Q]=U;if($(U,"context")){if(U.phase==="resolving")return this.node("alias",{reference:`$${Q}`},{prereduced:!0});if(U.phase==="resolved")return D(`Unexpected resolved context for was uncached by its scope: ${T(U)}`);U.phase="resolving";let Z=this.bindReference(this.parseOwnDefinitionFormat(U.def,U));return U.phase="resolved",h[Z.id]=Z,h[U.id]=Z,this.resolutions[Q]=Z}return D(`Unexpected nodesById entry for ${X}: ${T(U)}`)}let Y=this.aliases[Q]??this.ambient?.[Q];if(!Y)return this.maybeResolveSubalias(Q);if(Y=this.normalizeRootScopeValue(Y),$(Y,"generic"))return this.resolutions[Q]=this.bindReference(Y);if($(Y,"module")){if(!Y.root)H(NX(Q));return this.resolutions[Q]=this.bindReference(Y.root)}return this.resolutions[Q]=this.parse(Y,{alias:Q})}createParseContext(Q){let X=Q.id??o6(Q.prefix);return h[X]=Object.assign(Q,{[x]:"context",$:this,id:X,phase:"unresolved"})}traversal(Q){return new Y1(Q,this.resolvedConfig)}import(...Q){return new n1(V(this.export(...Q),(X,Y)=>[`#${X}`,Y]))}precompilation;_exportedResolutions;_exports;export(...Q){if(!this._exports){this._exports={};for(let Y of this.exportedNames){let U=this.aliases[Y];this._exports[Y]=$(U,"module")?LQ(U,this):MX(this.maybeResolve(Y))}for(let Y of this.lazyResolutions)Y.resolution;if(this._exportedResolutions=KX(this,this._exports),this._json=wX(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let Y=DX(this.references);this.precompilation=Y.write(RX,4),CX(this.references,Y)}this.resolved=!0}let X=Q.length?Q:this.exportedNames;return new n1(V(X,(Y,U)=>[U,this._exports[U]]))}resolve(Q){return this.export()[Q]}node=(Q,X,Y={})=>{let U=this.preparseNode(Q,X,Y);if(N(U))return this.bindReference(U);let Z=this.createParseContext(U),W=c6(Z),G=this.bindReference(W);return h[Z.id]=G};parse=(Q,X={})=>this.finalize(this.parseDefinition(Q,X));parseDefinition(Q,X={}){if($(Q,"root"))return this.bindReference(Q);let Y=this.preparseOwnDefinitionFormat(Q,X);if($(Y,"root"))return this.bindReference(Y);let U=this.createParseContext(Y);h[U.id]=U;let Z=this.bindReference(this.parseOwnDefinitionFormat(Q,U));if(Z.isCyclic)Z=m4(Z,U.id);return h[U.id]=Z,Z}finalize(Q){if(MX(Q),!Q.precompilation&&!this.resolvedConfig.jitless)G8(Q.references);return Q}}class HQ extends t2{parseOwnDefinitionFormat(Q,X){return c6(X)}preparseOwnDefinitionFormat(Q,X){return this.preparseNode(V2(Q),Q,X)}preparseOwnAliasEntry(Q,X){return[Q,X]}normalizeRootScopeValue(Q){return Q}}var MX=(Q)=>{let X=Q.references.filter((Y)=>Y.hasKind("alias"));for(let Y of X){Object.assign(Y.referencesById,Y.resolution.referencesById);for(let U of Q.references)if(Y.id in U.referencesById)Object.assign(U.referencesById,Y.referencesById)}return Q},wX=(Q)=>V(Q,(X,Y)=>[X,$(Y,"root")||$(Y,"generic")?Y.json:$(Y,"module")?wX(Y):D(`Unexpected resolution ${T(Y)}`)]),JQ=(Q,X)=>{let Y=X.indexOf(".");if(Y===-1)return;let U=X.slice(0,Y),Z=Q[U];if(Z===void 0)return;if(!$(Z,"module"))return H(L8(U));let W=X.slice(Y+1),G=Z[W];if(G===void 0)return JQ(Z,W);if($(G,"root")||$(G,"generic"))return G;if($(G,"module"))return G.root??H(NX(X));D(`Unexpected resolution for alias '${X}': ${T(G)}`)},a2=(Q,X)=>new HQ(Q,X),N2=new HQ({});var KX=(Q,X)=>{let Y={};for(let U in X){let Z=X[U];if($(Z,"module")){let W=KX(Q,Z),G=V(W,(L,J)=>[`${U}.${L}`,J]);Object.assign(Y,G)}else if($(Z,"root")||$(Z,"generic"))Y[U]=Z;else D(`Unexpected scope resolution ${T(Z)}`)}return Y},FQ=(Q)=>`'${Q}' is unresolvable`,L8=(Q)=>`'${Q}' must reference a module to be accessed using dot syntax`,NX=(Q)=>`Reference to submodule '${Q}' must specify an alias`;N2.export();var{schema:w,node:s1,defineSchema:DJ,generic:e}=N2;var qQ="^(?:0|[1-9]\\d*)$",_8=new RegExp(qQ),NJ=S(_8);var PX=a2({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();F.intrinsic={...PX};var EX=a2({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:qQ}},{prereducedAliases:!0}).export();Object.assign(F.intrinsic,EX);var J8=a2({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),z={...PX,...EX,...J8,emptyStructure:s1("structure",{},{prereduced:!0})};F.intrinsic={...z};var e2=(Q,X)=>new RegExp(Q,X);Object.assign(e2,{as:e2});var SX=(Q)=>typeof Q==="string"&&Q[0]==="d"&&(Q[1]==="'"||Q[1]==='"')&&Q[Q.length-1]===Q[1],IX=(Q)=>Q.toString()!=="Invalid Date",jX=(Q)=>Q.slice(2,-1),AQ=(Q)=>`'${Q}' could not be parsed by the Date constructor`,bX=(Q,X)=>H8(Q,X),H8=(Q,X)=>{let Y=new Date(Q);if(IX(Y))return Y;let U=Z4(Q);if(U!==void 0){let Z=new Date(U);if(IX(Z))return Z}return X?H(X===!0?AQ(Q):X):void 0};var F8=w({proto:"Array",sequence:"string",required:{key:"groups",value:["object",{unit:void 0}]}}),Q6=(Q,X)=>{let Y=Q.scanner.shiftUntilEscapable(A8[vX[X]]);if(Q.scanner.lookahead==="")return Q.error(z8(Y,X));if(Q.scanner.shift(),X in yX){let U;try{U=new RegExp(Y)}catch(Z){H(String(Z))}if(Q.root=Q.ctx.$.node("intersection",{domain:"string",pattern:Y},{prereduced:!0}),X==="x/")Q.root=Q.ctx.$.node("morph",{in:Q.root,morphs:(Z)=>U.exec(Z),declaredOut:F8})}else if(y(X,$Q))Q.root=Q.ctx.$.node("unit",{unit:Y});else{let U=bX(Y,AQ(Y));Q.root=Q.ctx.$.node("unit",{meta:Y,unit:U})}},$Q={"'":1,'"':1},fX={"/":1,"'":1,'"':1},q8={"d'":"'",'d"':'"',"'":"'",'"':'"'},yX={"/":"/","x/":"/"},vX={...q8,...yX},A8={"'":(Q)=>Q.lookahead==="'",'"':(Q)=>Q.lookahead==='"',"/":(Q)=>Q.lookahead==="/"},$8={'"':"double-quote","'":"single-quote","/":"forward slash"},z8=(Q,X)=>`${X}${Q} requires a closing ${$8[vX[X]]}`;var gX=(Q)=>`Private type references should not include '#'. Use '${Q}' instead.`,X6="Optional definitions like 'string?' are only valid as properties in an object or tuple",Y6="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var J1={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...B1};var kX=(Q,X)=>Q===">"?X[0]==="="?X[1]==="=":X.trimStart()===""||y(X.trimStart()[0],J1):Q==="="?X[0]!=="=":Q===","||Q==="?";var xX=(Q,X,Y)=>hX(Q,X,Y,[]),hX=(Q,X,Y,U)=>{let Z=Y.parseUntilFinalizer();if(U.push(Z.root),Z.finalizer===">"){if(U.length!==X.params.length)return Y.error(zQ(Q,X.names,U.map((W)=>W.expression)));return U}if(Z.finalizer===",")return hX(Q,X,Y,U);return Z.error(k2(">"))},zQ=(Q,X,Y)=>`${Q}<${X.join(", ")}> requires exactly ${X.length} args (got ${Y.length}${Y.length===0?"":`: ${Y.join(", ")}`})`;var U6=(Q)=>{let X=Q.scanner.shiftUntilLookahead(J1);if(X==="keyof")Q.addPrefix("keyof");else Q.root=V8(Q,X)},O8=(Q,X,Y)=>{if(Y.scanner.shiftUntilNonWhitespace(),Y.scanner.shift()!=="<")return Y.error(zQ(Q,X.names,[]));let Z=xX(Q,X,Y);return X(...Z)},V8=(Q,X)=>T8(Q,X)??B8(Q,X)??Q.error(X===""?Q.scanner.lookahead==="#"?gX(Q.shiftedBy(1).scanner.shiftUntilLookahead(J1)):OQ(Q):FQ(X)),T8=(Q,X)=>{if(Q.ctx.args?.[X]){let U=Q.ctx.args[X];if(typeof U!=="string")return U;return Q.ctx.$.node("alias",{reference:U},{prereduced:!0})}let Y=Q.ctx.$.maybeResolve(X);if($(Y,"root"))return Y;if(Y===void 0)return;if($(Y,"generic"))return O8(X,Y,Q);return H(`Unexpected resolution ${T(Y)}`)},B8=(Q,X)=>{let Y=W4(X);if(Y!==void 0)return Q.ctx.$.node("unit",{unit:Y});let U=L4(X);if(U!==void 0)return Q.ctx.$.node("unit",{unit:U})},OQ=(Q)=>{let X=Q.previousOperator();return X?VQ(X,Q.scanner.unscanned):M8(Q.scanner.unscanned)},VQ=(Q,X="")=>`Token '${Q}' requires a right operand${X?` before '${X}'`:""}`,M8=(Q)=>`Expected an expression${Q?` before '${Q}'`:""}`;var TQ=(Q)=>Q.scanner.lookahead===""?Q.error(OQ(Q)):Q.scanner.lookahead==="("?Q.shiftedBy(1).reduceGroupOpen():Q.scanner.lookaheadIsIn(fX)?Q6(Q,Q.scanner.shift()):Q.scanner.lookaheadIsIn(B1)?TQ(Q.shiftedBy(1)):Q.scanner.lookahead==="d"?Q.scanner.nextLookahead in $Q?Q6(Q,`${Q.scanner.shift()}${Q.scanner.shift()}`):U6(Q):Q.scanner.lookahead==="x"?Q.scanner.nextLookahead==="/"?Q.shiftedBy(2)&&Q6(Q,"x/"):U6(Q):U6(Q);var uX={">":!0,">=":!0},pX={"<":!0,"<=":!0};var r1={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},mX=(Q,X)=>`Left bounds are only valid when paired with right bounds (try ...${X}${Q})`,Z6=(Q)=>`Left-bounded expressions must specify their limits using < or <= (was ${Q})`,lX=(Q,X,Y,U)=>`An expression may have at most one left bound (parsed ${Q}${r1[X]}, ${Y}${r1[U]})`;var oX=(Q,X)=>{let Y=R8(Q,X);if(Q.root.hasKind("unit")){if(typeof Q.root.unit==="number"){Q.reduceLeftBound(Q.root.unit,Y),Q.unsetRoot();return}if(Q.root.unit instanceof Date){let U=`d'${Q.root.description??Q.root.unit.toISOString()}'`;Q.unsetRoot(),Q.reduceLeftBound(U,Y);return}}return D8(Q,Y)},cX={"<":1,">":1,"=":1},R8=(Q,X)=>Q.scanner.lookaheadIs("=")?`${X}${Q.scanner.shift()}`:X;var dX=(Q,X,Y,U)=>{if(Y.extends(F.intrinsic.number)){if(typeof X!=="number")return H(BQ(Q,X,U));return Q==="=="?["min","max"]:Q[0]===">"?["min"]:["max"]}if(Y.extends(F.intrinsic.lengthBoundable)){if(typeof X!=="number")return H(BQ(Q,X,U));return Q==="=="?["exactLength"]:Q[0]===">"?["minLength"]:["maxLength"]}if(Y.extends(F.intrinsic.Date))return Q==="=="?["after","before"]:Q[0]===">"?["after"]:["before"];return H(I4(Y.expression))},C8=(Q)=>({rule:SX(Q.limit)?jX(Q.limit):Q.limit,exclusive:Q.comparator.length===1}),D8=(Q,X)=>{let Y=Q.unsetRoot(),U=Q.scanner.location;Q.parseOperand();let Z=Q.unsetRoot(),W=Q.scanner.sliceChars(U,Q.scanner.location);if(Q.root=Y,!Z.hasKind("unit")||typeof Z.unit!=="number"&&!(Z.unit instanceof Date))return Q.error(BQ(X,W,"right"));let G=Z.unit,L=X.length===1,J=dX(X,typeof G==="number"?G:W,Y,"right");for(let A of J)Q.constrainRoot(A,X==="=="?{rule:G}:{rule:G,exclusive:L});if(!Q.branches.leftBound)return;if(!y(X,pX))return Q.error(Z6(X));let _=dX(Q.branches.leftBound.comparator,Q.branches.leftBound.limit,Y,"left");Q.constrainRoot(_[0],C8(Q.branches.leftBound)),Q.branches.leftBound=null},BQ=(Q,X,Y)=>`Comparator ${Y==="left"?r1[Q]:Q} must be ${Y==="left"?"preceded":"followed"} by a corresponding literal (was ${X})`;var iX=(Q)=>{Q.scanner.shiftUntilNonWhitespace();let X=Q.scanner.shiftUntilLookahead(J1);Q.root=Q.root.brand(X)};var sX=(Q)=>{Q.scanner.shiftUntilNonWhitespace();let X=Q.scanner.shiftUntilLookahead(J1),Y=G4(X,{errorOnFail:nX(X)});if(Y===0)Q.error(nX(0));Q.root=Q.root.constrain("divisor",Y)},nX=(Q)=>`% operator must be followed by a non-zero integer literal (was ${Q})`;var MQ=(Q)=>{let X=Q.scanner.shift();return X===""?Q.finalize(""):X==="["?Q.scanner.shift()==="]"?Q.setRoot(Q.root.array()):Q.error(w8):X==="|"?Q.scanner.lookahead===">"?Q.shiftedBy(1).pushRootToBranch("|>"):Q.pushRootToBranch(X):X==="&"?Q.pushRootToBranch(X):X===")"?Q.finalizeGroup():kX(X,Q.scanner.unscanned)?Q.finalize(X):y(X,cX)?oX(Q,X):X==="%"?sX(Q):X==="#"?iX(Q):(X in B1)?MQ(Q):Q.error(W6(X))},W6=(Q,X="")=>`'${Q}' is not allowed here${X&&` (should be ${X})`}`,w8="Missing expected ']'";var rX=(Q)=>{let X=Q.unsetRoot();Q.parseOperand();let Y=Q.unsetRoot();if(!Y.hasKind("unit"))return Q.error(K8(Y.expression));let U=Y.unit instanceof Date?()=>new Date(Y.unit):Y.unit;return[X,"=",U]},K8=(Q)=>`Default value '${Q}' must be a literal value`;var RQ=(Q,X)=>{let Y=X.$.maybeResolveRoot(Q);if(Y)return Y;if(Q.endsWith("[]")){let W=X.$.maybeResolveRoot(Q.slice(0,-2));if(W)return W.array()}let U=new t1(new F2(Q),X),Z=N8(U);if(U.finalizer===">")H(W6(">"));return Z},N8=(Q)=>{Q.parseOperand();let X=P2(Q).root;if(!X)return D(`Root was unexpectedly unset after parsing string '${Q.scanner.scanned}'`);if(Q.finalizer==="=")X=rX(Q);else if(Q.finalizer==="?")X=[X,"?"];if(Q.scanner.shiftUntilNonWhitespace(),Q.scanner.lookahead)H(W6(Q.scanner.lookahead));return X},P2=(Q)=>{while(Q.finalizer===void 0)P8(Q);return Q},P8=(Q)=>Q.hasRoot()?Q.parseOperator():Q.parseOperand();class t1{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor(Q,X){this.scanner=Q,this.ctx=X}error(Q){return H(Q)}hasRoot(){return this.root!==void 0}setRoot(Q){this.root=Q}unsetRoot(){let Q=this.root;return this.root=void 0,Q}constrainRoot(...Q){this.root=this.root.constrain(Q[0],Q[1])}finalize(Q){if(this.groups.length)return this.error(k2(")"));this.finalizeBranches(),this.finalizer=Q}reduceLeftBound(Q,X){let Y=r1[X];if(!y(Y,uX))return this.error(Z6(X));if(this.branches.leftBound)return this.error(lX(this.branches.leftBound.limit,this.branches.leftBound.comparator,Q,Y));this.branches.leftBound={comparator:Y,limit:Q}}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 Q=this.groups.pop();if(!Q)return this.error(F4(")",this.scanner.unscanned));this.branches=Q}addPrefix(Q){this.branches.prefixes.push(Q)}applyPrefixes(){while(this.branches.prefixes.length){let Q=this.branches.prefixes.pop();this.root=Q==="keyof"?this.root.keyof():D(`Unexpected prefix '${Q}'`)}}pushRootToBranch(Q){this.assertRangeUnset(),this.applyPrefixes();let X=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(X)??X,Q==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,Q==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return P2(new t1(this.scanner,this.ctx))}parseOperator(){return MQ(this)}parseOperand(){return TQ(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(mX(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(Q){return this.scanner.jumpForward(Q),this}}var E8="An empty string is not a valid generic parameter name",G6=(Q,X,Y)=>{Q.shiftUntilNonWhitespace();let U=Q.shiftUntilLookahead(J1);if(U===""){if(Q.lookahead===""&&X.length)return X;return H(E8)}return Q.shiftUntilNonWhitespace(),I8(Q,U,X,Y)},tX="extends ",I8=(Q,X,Y,U)=>{if(Q.shiftUntilNonWhitespace(),Q.unscanned.startsWith(tX))Q.jumpForward(tX.length);else{if(Q.lookahead===",")Q.shift();return Y.push(X),G6(Q,Y,U)}let Z=P2(new t1(Q,U));return Y.push([X,Z.root]),G6(Q,Y,U)};class CQ extends d{constructor(Q){let X={$:Q,raw:Q.fn};super((...Y)=>{let U=Y.indexOf(":"),Z=U===-1?Y.length-1:U-1,W=Y.slice(0,Z+1),G=Q.parse(W).assertHasKind("intersection"),L=Q.intrinsic.unknown;if(U!==-1){if(U!==Y.length-2)return H(S8);L=Q.parse(Y[U+1])}return(J)=>new aX(J,G,L)},{attach:X})}}class aX extends d{raw;params;returns;expression;constructor(Q,X,Y){let U=`typed ${Q.name}`,Z={[U]:(...G)=>{let L=X.assert(G),J=Q(...L);return Y.assert(J)}}[U];super(Z);this.raw=Q,this.params=X,this.returns=Y;let W=X.expression;if(W[0]==="["&&W[W.length-1]==="]")W=W.slice(1,-1);else if(W.endsWith("[]"))W=`...${W}`;this.expression=`(${W}) => ${Y?.expression??"unknown"}`}}var S8=`":" must be followed by exactly one return type e.g:
|
|
46
|
+
fn("string", ":", "number")(s => s.length)`;class DQ extends d{$;constructor(Q){super((...X)=>new E2(Q)(...X),{bind:Q});this.$=Q}in(Q){return new E2(this.$,Q===void 0?void 0:this.$.parse(Q))}at(Q,X){return new E2(this.$).at(Q,X)}case(Q,X){return new E2(this.$).case(Q,X)}}class E2 extends d{$;in;key;branches=[];constructor(Q,X){super((Y)=>this.caseEntries(Object.entries(Y).map(([U,Z])=>U==="default"?[U,Z]:[this.$.parse(U),Z])));this.$=Q,this.in=X}at(Q,X){if(this.key)H(b8);if(this.branches.length)H(j8);return this.key=Q,X?this.match(X):this}case(Q,X){return this.caseEntry(this.$.parse(Q),X)}caseEntry(Q,X){let U=(this.key?this.$.parse({[this.key]:Q}):Q).pipe(X);return this.branches.push(U),this}match(Q){return this(Q)}strings(Q){return this.caseEntries(Object.entries(Q).map(([X,Y])=>X==="default"?[X,Y]:[this.$.node("unit",{unit:X}),Y]))}caseEntries(Q){for(let X=0;X<Q.length;X++){let[Y,U]=Q[X];if(Y==="default"){if(X!==Q.length-1)H("default may only be specified as the last key of a switch definition");return this.default(U)}if(typeof U!=="function")return H(`Value for case "${Y}" must be a function (was ${f(U)})`);this.caseEntry(Y,U)}return this}default(Q){if(typeof Q==="function")this.case(z.unknown,Q);let X={branches:this.branches,ordered:!0};if(Q==="never"||Q==="assert")X.meta={onFail:eX};let Y=this.$.node("union",X);if(!this.in)return this.$.finalize(Y);let U=this.in.pipe(Y);if(Q==="never"||Q==="assert")U=U.configureReferences({onFail:eX},"self");return this.$.finalize(U)}}var eX=(Q)=>Q.throw(),j8="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",b8="At most one key matcher may be specified per expression";var L6=(Q,X)=>{if(K(Q)){if(Q[1]==="=")return[X.$.parseOwnDefinitionFormat(Q[0],X),"=",Q[2]];if(Q[1]==="?")return[X.$.parseOwnDefinitionFormat(Q[0],X),"?"]}return _6(Q,X)},QY="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",XY="Only required keys may specify default values, e.g. { value: 'number = 0' }";var YY=(Q,X)=>{let Y,U={},Z=N1(Q);for(let[G,L]of Z){let J=v8(G);if(J.kind==="spread"){if(!L1(U))return H(y8);let b=X.$.parseOwnDefinitionFormat(L,X);if(b.equals(z.object))continue;if(!b.hasKind("intersection")||!b.basis?.equals(z.object))return H(g8(b.expression));Y=b.structure;continue}if(J.kind==="undeclared"){if(L!=="reject"&&L!=="delete"&&L!=="ignore")H(f8(L));U.undeclared=L;continue}let _=L6(L,X),A=J;if(J.kind==="required"){if(!K(_))wQ(U,"required",{key:J.normalized,value:_},X);else wQ(U,"optional",_[1]==="="?{key:J.normalized,value:_[0],default:_[2]}:{key:J.normalized,value:_[0]},X);continue}if(K(_)){if(_[1]==="?")H(QY);if(_[1]==="=")H(XY)}if(J.kind==="optional"){wQ(U,"optional",{key:J.normalized,value:_},X);continue}let O=X.$.parseOwnDefinitionFormat(A.normalized,X),C=r2(O,_,X.$);if(C.index)U.index=R(U.index,C.index);if(C.required)U.required=R(U.required,C.required)}let W=X.$.node("structure",U);return X.$.parseSchema({domain:"object",structure:Y?.merge(W)??W})},wQ=(Q,X,Y,U)=>{Q[X]=R(Q[X],U.$.node(X,Y))},f8=(Q)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${T(Q)})`,y8="Spread operator may only be used as the first key in an object",v8=(Q)=>typeof Q==="symbol"?{kind:"required",normalized:Q}:Q[Q.length-1]==="?"?Q[Q.length-2]===E1?{kind:"required",normalized:`${Q.slice(0,-2)}?`}:{kind:"optional",normalized:Q.slice(0,-1)}:Q[0]==="["&&Q[Q.length-1]==="]"?{kind:"index",normalized:Q.slice(1,-1)}:Q[0]===E1&&Q[1]==="["&&Q[Q.length-1]==="]"?{kind:"required",normalized:Q.slice(1)}:Q==="..."?{kind:"spread"}:Q==="+"?{kind:"undeclared"}:{kind:"required",normalized:Q==="\\..."?"...":Q==="\\+"?"+":Q},g8=(Q)=>`Spread operand must resolve to an object literal type (was ${Q})`;var ZY=(Q,X)=>c8(Q)?_Y[Q[0]](Q,X):d8(Q)?LY[Q[1]](Q,X):null,k8=(Q,X)=>X.$.parseOwnDefinitionFormat(Q[1],X).keyof(),KQ=(Q,X)=>{if(Q[2]===void 0)return H(VQ(Q[1],""));let Y=X.$.parseOwnDefinitionFormat(Q[0],X),U=X.$.parseOwnDefinitionFormat(Q[2],X);if(Q[1]==="|")return X.$.node("union",{branches:[Y,U]});let Z=Q[1]==="&"?i(Y,U,X.$):O2(Y,U,X.$);if(Z instanceof q)return Z.throw();return Z},x8=(Q,X)=>X.$.parseOwnDefinitionFormat(Q[0],X).array(),h8=(Q,X)=>{if(typeof Q[2]!=="function")return H(WY("=>",Q[2]));return X.$.parseOwnDefinitionFormat(Q[0],X).pipe(Q[2])},WY=(Q,X)=>`${Q===":"?"Narrow":"Morph"} expression requires a function following '${Q}' (was ${typeof X})`,u8=(Q,X)=>{if(typeof Q[2]!=="function")return H(WY(":",Q[2]));return X.$.parseOwnDefinitionFormat(Q[0],X).constrain("predicate",Q[2])},p8=(Q,X)=>X.$.parseOwnDefinitionFormat(Q[0],X).configure(Q[2],Q[3]),GY=(Q)=>Q,m8=GY({"[]":x8,"?":()=>H(X6)}),l8=GY({"|":KQ,"&":KQ,":":u8,"=>":h8,"|>":KQ,"@":p8,"=":()=>H(Y6)}),LY={...m8,...l8},d8=(Q)=>LY[Q[1]]!==void 0,o8=(Q)=>Q,_Y=o8({keyof:k8,instanceof:(Q,X)=>{if(typeof Q[1]!=="function")return H(UY(Z2(Q[1])));let Y=Q.slice(1).map((U)=>typeof U==="function"?X.$.node("proto",{proto:U}):H(UY(Z2(U))));return Y.length===1?Y[0]:X.$.node("union",{branches:Y})},"===":(Q,X)=>X.$.units(Q.slice(1))}),c8=(Q)=>_Y[Q[0]]!==void 0,UY=(Q)=>`Expected a constructor following 'instanceof' operator (was ${Q})`;var FY=(Q,X)=>{let Y=[{}],U=0;while(U<Q.length){let Z=!1;if(Q[U]==="..."&&U<Q.length-1)Z=!0,U++;let W=L6(Q[U],X),[G,L,J]=!K(W)?[W]:W;if(U++,Z){if(!G.extends(F.intrinsic.Array))return H(s8(G.expression));Y=Y.flatMap((_)=>G.distribute((A)=>n8(h2(_),A)))}else Y=Y.map((_)=>{if(L==="?")return qY(_,G);if(L==="=")return i8(_,G,J);return NQ(_,G)})}return X.$.parseSchema(Y.map((Z)=>L1(Z)?{proto:Array,exactLength:0}:{proto:Array,sequence:Z}))},NQ=(Q,X)=>{if(Q.defaultables||Q.optionals)return H(Q.variadic?ZQ:r8);if(Q.variadic)Q.postfix=R(Q.postfix,X);else Q.prefix=R(Q.prefix,X);return Q},qY=(Q,X)=>{if(Q.variadic)return H(AY);return Q.optionals=R(Q.optionals,X),Q},i8=(Q,X,Y)=>{if(Q.variadic)return H(AY);if(Q.optionals)return H(t8);return Q.defaultables=R(Q.defaultables,[[X,Y]]),Q},JY=(Q,X)=>{if(Q.postfix)H(HY);if(Q.variadic){if(!Q.variadic.equals(X))H(HY)}else Q.variadic=X.internal;return Q},n8=(Q,X)=>{let Y=X.select({method:"find",kind:"sequence"});if(!Y)return JY(Q,F.intrinsic.unknown);if(Y.prefix)for(let U of Y.prefix)NQ(Q,U);if(Y.optionals)for(let U of Y.optionals)qY(Q,U);if(Y.variadic)JY(Q,Y.variadic);if(Y.postfix)for(let U of Y.postfix)NQ(Q,U);return Q},s8=(Q)=>`Spread element must be an array (was ${Q})`,HY="A tuple may have at most one variadic element",r8="A required element may not follow an optional element",AY="An optional element may not follow a variadic element";var t8="A defaultable element may not follow an optional element without a default";var a8={},_6=(Q,X)=>{if(typeof Q==="string"){if(X.args&&Object.keys(X.args).some((U)=>Q.includes(U)))return RQ(Q,X);let Y=a8[X.$.name]??={};return Y[Q]??=RQ(Q,X)}return p(Q,"object")?e8(Q,X):H(PQ(f(Q)))},e8=(Q,X)=>{let Y=U2(Q);switch(Y){case void 0:if($(Q,"root"))return Q;if("~standard"in Q)return Q3(Q,X);return YY(Q,X);case"Array":return X3(Q,X);case"RegExp":return X.$.node("intersection",{domain:"string",pattern:Q},{prereduced:!0});case"Function":{let U=T1(Q)?Q():Q;if($(U,"root"))return U;return H(PQ("Function"))}default:return H(PQ(Y??T(Q)))}},Q3=(Q,X)=>X.$.intrinsic.unknown.pipe((Y,U)=>{let Z=Q["~standard"].validate(Y);if(!Z.issues)return Z.value;for(let{message:W,path:G}of Z.issues)if(G)if(G.length)U.error({problem:aQ(W),relativePath:G.map((L)=>typeof L==="object"?L.key:L)});else U.error({message:W});else U.error({message:W})}),X3=(Q,X)=>ZY(Q,X)??FY(Q,X),PQ=(Q)=>`Type definitions must be strings or objects (was ${Q})`;class EQ extends d{constructor(Q){let X=Object.assign({errors:o,hkt:g,$:Q,raw:Q.parse,module:Q.constructor.module,scope:Q.constructor.scope,declare:Q.declare,define:Q.define,match:Q.match,generic:Q.generic,schema:Q.schema,keywords:Q.ambient,unit:Q.unit,enumerated:Q.enumerated,instanceOf:Q.instanceOf,valueOf:Q.valueOf,or:Q.or,and:Q.and,merge:Q.merge,pipe:Q.pipe,fn:Q.fn},Q.ambientAttachments);super((...Y)=>{if(Y.length===1)return Q.parse(Y[0]);if(Y.length===2&&typeof Y[0]==="string"&&Y[0][0]==="<"&&Y[0][Y[0].length-1]===">"){let U=Y[0].slice(1,-1),Z=Q.parseGenericParams(U,{});return new D1(Z,Y[1],Q,Q,null)}return Q.parse(Y)},{attach:X})}}var a1=F;class J6 extends t2{get ambientAttachments(){if(!a1.typeAttachments)return;return this.cacheGetter("ambientAttachments",V(a1.typeAttachments,(Q,X)=>[Q,this.bindReference(X)]))}preparseOwnAliasEntry(Q,X){let Y=Q.indexOf("<");if(Y===-1){if($(X,"module")||$(X,"generic"))return[Q,X];let W=this.name==="ark"?Q:Q==="root"?this.name:`${this.name}.${Q}`,G=this.resolvedConfig.keywords?.[W];if(G)X=[X,"@",G];return[Q,X]}if(Q[Q.length-1]!==">")H("'>' must be the last character of a generic declaration in a scope");let U=Q.slice(0,Y),Z=Q.slice(Y+1,-1);return[U,()=>{let W=this.parseGenericParams(Z,{alias:U});return N4(W,X,this)}]}parseGenericParams(Q,X){return G6(new F2(Q),[],this.createParseContext({...X,def:Q,prefix:"generic"}))}normalizeRootScopeValue(Q){if(T1(Q)&&!$(Q,"generic"))return Q();return Q}preparseOwnDefinitionFormat(Q,X){return{...X,def:Q,prefix:X.alias??"type"}}parseOwnDefinitionFormat(Q,X){if(!(X.alias&&(X.alias in this.aliases))&&!X.args)X.args={this:X.id};let U=_6(Q,X);if(K(U)){if(U[1]==="=")return H(Y6);if(U[1]==="?")return H(X6)}return U}unit=(Q)=>this.units([Q]);valueOf=(Q)=>this.units(lQ(Q));enumerated=(...Q)=>this.units(Q);instanceOf=(Q)=>this.node("proto",{proto:Q},{prereduced:!0});or=(...Q)=>this.schema(Q.map((X)=>this.parse(X)));and=(...Q)=>Q.reduce((X,Y)=>X.and(this.parse(Y)),this.intrinsic.unknown);merge=(...Q)=>Q.reduce((X,Y)=>X.merge(this.parse(Y)),this.intrinsic.object);pipe=(...Q)=>this.intrinsic.unknown.pipe(...Q);fn=new CQ(this);match=new DQ(this);declare=()=>({type:this.type});define(Q){return Q}type=new EQ(this);static scope=(Q,X={})=>new J6(Q,X);static module=(Q,X={})=>this.scope(Q,X).export()}var I2=Object.assign(J6.scope,{define:(Q)=>Q}),M=J6;class $Y extends g{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var Y3=e(["base",z.object],["props",z.object])((Q)=>Q.base.merge(Q.props),$Y),zY=M.module({Key:z.key,Merge:Y3});class OY extends g{}var U3=e("element")((Q)=>{let X=Q.element.exclude(z.Array),Y=X.array();return X.rawOr(Y).pipe(V1).distribute((U)=>U.assertHasKind("morph").declareOut(Y),w)},OY),VY=M.module({root:z.Array,readonly:"root",index:z.nonNegativeIntegerString,liftFrom:U3},{name:"Array"});var IQ=w(["string",I1.FileConstructor]),Z3=IQ.rawOr(IQ.array()),TY=w({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:Z3}}),BY=M.module({root:["instanceof",FormData],value:IQ,parsed:TY,parse:w({in:FormData,morphs:(Q)=>{let X={};for(let[Y,U]of Q)if(Y in X){let Z=X[Y];if(typeof Z==="string"||Z instanceof I1.FileConstructor)X[Y]=[Z,U];else Z.push(U)}else X[Y]=U;return X},declaredOut:TY})},{name:"FormData"});var MY=M.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 W3={Boolean:1,Number:1,String:1},RY=M.module({...V({...V6,...B6},(Q,X)=>(Q in W3)?[]:[Q,["instanceof",X]]),Array:VY,TypedArray:MY,FormData:BY});var G3=w({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"}),L3=w({domain:"number",divisor:1}),H6=M.module({root:z.number,integer:L3,epoch:G3,safe:w({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 I=(Q,X,Y)=>{let U={domain:"string",pattern:{rule:Q.source,flags:Q.flags,meta:X}};if(Y)U.meta={format:Y};return s1("intersection",U)},CY=I(G2,"a well-formed integer string"),yY=M.module({root:CY,parse:w({in:CY,morphs:(Q,X)=>{let Y=Number.parseInt(Q);return Number.isSafeInteger(Y)?Y:X.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:z.integer})},{name:"string.integer"}),_3=I(/^[\dA-Fa-f]+$/,"hex characters only"),J3=M.module({root:I(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:I(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),DY=I(/^[A-Z].*$/,"capitalized"),H3=M.module({root:w({in:"string",morphs:(Q)=>Q.charAt(0).toUpperCase()+Q.slice(1),declaredOut:DY}),preformatted:DY},{name:"string.capitalize"}),F3=(Q)=>{let X=Q.replace(/[ -]+/g,""),Y=0,U,Z,W=!1;for(let G=X.length-1;G>=0;G--){if(U=X.substring(G,G+1),Z=Number.parseInt(U,10),W)Z*=2,Y+=Z>=10?Z%10+1:Z;else Y+=Z;W=!W}return!!(Y%10===0?X:!1)},q3=/^(?: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}))$/,A3=w({domain:"string",pattern:{meta:"a credit card number",rule:q3.source},predicate:{meta:"a credit card number",predicate:F3}});var $3=/^([+-]?\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 z3=(Q)=>!Number.isNaN(new Date(Q).valueOf()),wY=w({domain:"string",predicate:{meta:"a parsable date",predicate:z3}}).assertHasKind("intersection"),KY=yY.root.internal.narrow((Q,X)=>{let Y=Number.parseInt(Q),U=H6.epoch(Y);if(U instanceof o)return X.errors.merge(U),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),O3=M.module({root:KY,parse:w({in:KY,morphs:(Q)=>new Date(Q),declaredOut:z.Date})},{name:"string.date.epoch"}),NY=I($3,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),V3=M.module({root:NY,parse:w({in:NY,morphs:(Q)=>new Date(Q),declaredOut:z.Date})},{name:"string.date.iso"}),T3=M.module({root:wY,parse:w({declaredIn:wY,in:"string",morphs:(Q,X)=>{let Y=new Date(Q);if(Number.isNaN(Y.valueOf()))return X.error("a parsable date");return Y},declaredOut:z.Date}),iso:V3,epoch:O3},{name:"string.date"}),B3=I(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),PY="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",w1=`(${PY}[.]){3}${PY}`,M3=new RegExp(`^${w1}$`),j="(?:[0-9a-fA-F]{1,4})",R3=new RegExp(`^((?:${j}:){7}(?:${j}|:)|(?:${j}:){6}(?:${w1}|:${j}|:)|(?:${j}:){5}(?::${w1}|(:${j}){1,2}|:)|(?:${j}:){4}(?:(:${j}){0,1}:${w1}|(:${j}){1,3}|:)|(?:${j}:){3}(?:(:${j}){0,2}:${w1}|(:${j}){1,4}|:)|(?:${j}:){2}(?:(:${j}){0,3}:${w1}|(:${j}){1,5}|:)|(?:${j}:){1}(?:(:${j}){0,4}:${w1}|(:${j}){1,6}|:)|(?::((?::${j}){0,5}:${w1}|(?::${j}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),C3=M.module({root:["v4 | v6","@","an IP address"],v4:I(M3,"an IPv4 address","ipv4"),v6:I(R3,"an IPv6 address","ipv6")},{name:"string.ip"}),e1="a JSON string",vY=(Q)=>{if(!(Q instanceof SyntaxError))throw Q;return`must be ${e1} (${Q})`},D3=w({meta:e1,domain:"string",predicate:{meta:e1,predicate:(Q,X)=>{try{return JSON.parse(Q),!0}catch(Y){return X.reject({code:"predicate",expected:e1,problem:vY(Y)})}}}}),w3=(Q,X)=>{if(Q.length===0)return X.error({code:"predicate",expected:e1,actual:"empty"});try{return JSON.parse(Q)}catch(Y){return X.error({code:"predicate",expected:e1,problem:vY(Y)})}},K3=M.module({root:D3,parse:w({meta:"safe JSON string parser",in:"string",morphs:w3,declaredOut:z.jsonObject})},{name:"string.json"}),EY=I(/^[a-z]*$/,"only lowercase letters"),N3=M.module({root:w({in:"string",morphs:(Q)=>Q.toLowerCase(),declaredOut:EY}),preformatted:EY},{name:"string.lower"}),gY=["NFC","NFD","NFKC","NFKD"],S2=V(gY,(Q,X)=>[X,w({domain:"string",predicate:(Y)=>Y.normalize(X)===Y,meta:`${X}-normalized unicode`})]),F6=V(gY,(Q,X)=>[X,w({in:"string",morphs:(Y)=>Y.normalize(X),declaredOut:S2[X]})]),P3=M.module({root:F6.NFC,preformatted:S2.NFC},{name:"string.normalize.NFC"}),E3=M.module({root:F6.NFD,preformatted:S2.NFD},{name:"string.normalize.NFD"}),I3=M.module({root:F6.NFKC,preformatted:S2.NFKC},{name:"string.normalize.NFKC"}),S3=M.module({root:F6.NFKD,preformatted:S2.NFKD},{name:"string.normalize.NFKD"}),j3=M.module({root:"NFC",NFC:P3,NFD:E3,NFKC:I3,NFKD:S3},{name:"string.normalize"}),IY=I(v2,"a well-formed numeric string"),b3=M.module({root:IY,parse:w({in:IY,morphs:(Q)=>Number.parseFloat(Q),declaredOut:z.number})},{name:"string.numeric"}),SY="a regex pattern",f3=w({domain:"string",predicate:{meta:SY,predicate:(Q,X)=>{try{return new RegExp(Q),!0}catch(Y){return X.reject({code:"predicate",expected:SY,problem:String(Y)})}}},meta:{format:"regex"}}),y3=/^(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-]+)*))?$/,v3=I(y3,"a semantic version (see https://semver.org/)"),jY=I(/^\S.*\S$|^\S?$/,"trimmed"),g3=M.module({root:w({in:"string",morphs:(Q)=>Q.trim(),declaredOut:jY}),preformatted:jY},{name:"string.trim"}),bY=I(/^[A-Z]*$/,"only uppercase letters"),k3=M.module({root:w({in:"string",morphs:(Q)=>Q.toUpperCase(),declaredOut:bY}),preformatted:bY},{name:"string.upper"}),x3=(Q)=>URL.canParse(Q),fY=w({domain:"string",predicate:{meta:"a URL string",predicate:x3},meta:{format:"uri"}}),h3=M.module({root:fY,parse:w({declaredIn:fY,in:"string",morphs:(Q,X)=>{try{return new URL(Q)}catch{return X.error("a URL string")}},declaredOut:w(URL)})},{name:"string.url"}),u3=M.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:I(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:I(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:I(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:I(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:I(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:I(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:I(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:I(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),kY=M.module({root:z.string,alpha:I(/^[A-Za-z]*$/,"only letters"),alphanumeric:I(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:_3,base64:J3,capitalize:H3,creditCard:A3,date:T3,digits:I(/^\d*$/,"only digits 0-9"),email:B3,integer:yY,ip:C3,json:K3,lower:N3,normalize:j3,numeric:b3,regex:f3,semver:v3,trim:g3,upper:k3,url:h3,uuid:u3},{name:"string"});var xY=M.module({bigint:z.bigint,boolean:z.boolean,false:z.false,never:z.never,null:z.null,number:z.number,object:z.object,string:z.string,symbol:z.symbol,true:z.true,unknown:z.unknown,undefined:z.undefined}),hY=M.module({root:z.unknown,any:z.unknown},{name:"unknown"}),p3=M.module({root:z.jsonObject,stringify:s1("morph",{in:z.jsonObject,morphs:(Q)=>JSON.stringify(Q),declaredOut:z.string})},{name:"object.json"}),uY=M.module({root:z.object,json:p3},{name:"object"});class pY extends g{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var m3=e(["K",z.key],"V")((Q)=>({domain:"object",index:{signature:Q.K,value:Q.V}}),pY);class mY extends g{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var l3=e(["T",z.object],["K",z.key])((Q)=>Q.T.pick(Q.K),mY);class lY extends g{description='omit a set of properties from an object like `Omit(User, "age")`'}var d3=e(["T",z.object],["K",z.key])((Q)=>Q.T.omit(Q.K),lY);class dY extends g{description="make all named properties of an object optional like `Partial(User)`"}var o3=e(["T",z.object])((Q)=>Q.T.partial(),dY);class oY extends g{description="make all named properties of an object required like `Required(User)`"}var c3=e(["T",z.object])((Q)=>Q.T.required(),oY);class cY extends g{description='exclude branches of a union like `Exclude("boolean", "true")`'}var i3=e("T","U")((Q)=>Q.T.exclude(Q.U),cY);class iY extends g{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var n3=e("T","U")((Q)=>Q.T.extract(Q.U),iY),nY=M.module({Exclude:i3,Extract:n3,Omit:d3,Partial:o3,Pick:l3,Record:m3,Required:c3});var O1=I2({...xY,...nY,...RY,...zY,string:kY,number:H6,object:uY,unknown:hY},{prereducedAliases:!0,name:"ark"}),v=O1.export();Object.assign(a1.ambient,v);a1.typeAttachments={string:v.string.root,number:v.number.root,bigint:v.bigint,boolean:v.boolean,symbol:v.symbol,undefined:v.undefined,null:v.null,object:v.object.root,unknown:v.unknown.root,false:v.false,true:v.true,never:v.never,arrayIndex:v.Array.index,Key:v.Key,Record:v.Record,Array:v.Array.root,Date:v.Date};var SQ=Object.assign(O1.type,a1.typeAttachments),s3=O1.match,r3=O1.fn,t3=O1.generic,Zq=O1.schema,a3=O1.define,e3=O1.declare;var b1=I2({Operator:"'EQ' | '==' | 'NEQ' | '!=' | 'GT' | '>' | 'GTE' | '>=' | 'LT' | '<' | 'LTE' | '<=' | 'IN' | 'NOT_IN' | 'CONTAINS' | 'MATCHES' | 'RANGE' | 'SINCE' | 'AFTER' | 'BEFORE' | 'UNTIL'",Condition:"RangeCondition | ListCondition | ContainsCondition | NumericCondition | RegexCondition | BasicCondition",RangeCondition:{field:"string > 0",operator:"'RANGE'",value:"unknown[] == 2"},ListCondition:{field:"string > 0",operator:"'IN' | 'NOT_IN'",value:"unknown[]"},ContainsCondition:{field:"string > 0",operator:"'CONTAINS'",value:"string | unknown[]"},NumericCondition:{field:"string > 0",operator:"'>' | '>=' | '<' | '<=' | 'GT' | 'GTE' | 'LT' | 'LTE'",value:"number | string"},RegexCondition:{field:"string > 0",operator:"'MATCHES'",value:"string"},BasicCondition:{field:"string > 0",operator:"Operator",value:"unknown"},ConditionGroup:{operator:"'AND' | 'OR'",conditions:"(Condition | ConditionGroup)[] >= 1"},RuleCondition:"Condition | ConditionGroup",Action:{type:"string > 0","params?":"object","delay?":"number.integer >= 0","probability?":"0 <= number <= 1"},ActionGroup:{"mode?":"'ALL' | 'EITHER' | 'SEQUENCE'",actions:"(Action | ActionGroup)[] >= 1"},RuleAction:"Action | ActionGroup",TriggerRule:{id:"string > 0","name?":"string","description?":"string","priority?":"number.integer","enabled?":"boolean","cooldown?":"number.integer >= 0","tags?":"string[]",on:"string > 0","if?":"RuleCondition | RuleCondition[]",do:"RuleAction | RuleAction[]","comment?":"string"}}).export(),Cq=b1.Operator,Dq=b1.Condition,wq=b1.ConditionGroup,Kq=b1.RuleCondition,Nq=b1.Action,Pq=b1.ActionGroup,Q9=b1.TriggerRule;class X9{static validate(Q){let X=Q9(Q);if(X instanceof SQ.errors){let Z=[];for(let W of X){let G=W.path.join("."),L=W.message,J=void 0;if(G.endsWith("on")&&(L.includes("string")||L.includes("must be")))if(typeof Q==="object"&&Q&&Q.on===!0)L="The 'on' field is incorrect (boolean true found).",J=`In YAML, 'on' is a boolean keyword (true). Quote it: "on": "EventName"`;else J="Ensure 'on' is a string event name.";Z.push({path:G,message:L,suggestion:J,severity:"error"})}return{valid:!1,issues:Z}}let Y=X,U=[];if(this.validateConditionsRecursive(Y.if,U,"if"),U.length>0)return{valid:!1,issues:U};return{valid:!0,rule:Y}}static validateConditionsRecursive(Q,X,Y){if(!Q)return;if(Array.isArray(Q)){Q.forEach((U,Z)=>{this.validateConditionsRecursive(U,X,`${Y}.${Z}`)});return}if("conditions"in Q&&Array.isArray(Q.conditions)){Q.conditions.forEach((U,Z)=>{this.validateConditionsRecursive(U,X,`${Y}.conditions.${Z}`)});return}if("operator"in Q&&"value"in Q)this.validateConditionValue(Q,X,Y)}static validateConditionValue(Q,X,Y){let{operator:U,value:Z}=Q;if(["IN","NOT_IN","RANGE","CONTAINS"].includes(U)){if(U==="CONTAINS"){if(typeof Z!=="string"&&!Array.isArray(Z))X.push({path:`${Y}.value`,message:`Incorrect value type: Operator 'CONTAINS' expects a String or List (Array), but received ${typeof Z}.`,suggestion:"Use a substring or a list of items.",severity:"error"});return}if(!Array.isArray(Z)){X.push({path:`${Y}.value`,message:`Incorrect value type: Operator '${U}' expects a List (Array), but received ${typeof Z}.`,suggestion:U==="RANGE"?"Use format [min, max]":"Use format [item1, item2]",severity:"error"});return}if(U==="RANGE"){if(Z.length!==2)X.push({path:`${Y}.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 Z[0]!=="number"&&typeof Z[0]!=="string")X.push({path:`${Y}.value`,message:"Incorrect range type: Range values must be numbers or expression strings.",severity:"error"})}}else if(U==="MATCHES")if(typeof Z!=="string")X.push({path:`${Y}.value`,message:`Incorrect value type: Operator 'MATCHES' expects a string (regex pattern), but received ${typeof Z}.`,severity:"error"});else try{new RegExp(Z)}catch(W){X.push({path:`${Y}.value`,message:`Invalid Regex pattern: ${W.message}`,severity:"error"})}else if(["GT","GTE","LT","LTE",">",">=","<","<="].includes(U)){if(typeof Z!=="number"&&typeof Z!=="string")X.push({path:`${Y}.value`,message:`Incorrect value type: Operator '${U}' expects a number or expression string, but received ${typeof Z}.`,severity:"error"})}}}export{X9 as TriggerValidator,b2 as TriggerUtils,Q9 as TriggerRuleSchema,QU as TriggerEngine,W1 as StateManager,eY as RuleEngine,Kq as RuleConditionSchema,A6 as InMemoryPersistence,u as ExpressionEngine,tY as EventQueue,aY as ContextAdapter,Dq as ConditionSchema,wq as ConditionGroupSchema,Cq as ComparisonOperatorSchema,bQ as BrowserPersistence,Nq as ActionSchema,j2 as ActionRegistry,Pq as ActionGroupSchema};
|
|
47
|
+
|
|
48
|
+
//# debugId=C170247C346097F364756E2164756E21
|