@walkeros/core 3.3.0-next-1776098542393 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,3 @@
1
- import { z } from 'zod';
2
-
3
1
  type MatchExpression = MatchCondition | {
4
2
  and: MatchExpression[];
5
3
  } | {
@@ -2564,12 +2562,15 @@ interface MarketingParameters {
2564
2562
  }
2565
2563
  /**
2566
2564
  * Click-ID registry entry — maps a URL parameter name to a canonical platform.
2565
+ *
2566
+ * Runtime shape only; the corresponding Zod schema lives in
2567
+ * `@walkeros/core/dev` (schemas/marketing.ts) for dev tooling that needs
2568
+ * validation or JSON Schema generation.
2567
2569
  */
2568
- declare const ClickIdEntrySchema: z.ZodObject<{
2569
- param: z.ZodString;
2570
- platform: z.ZodString;
2571
- }, z.core.$strip>;
2572
- type ClickIdEntry = z.infer<typeof ClickIdEntrySchema>;
2570
+ interface ClickIdEntry {
2571
+ param: string;
2572
+ platform: string;
2573
+ }
2573
2574
  /**
2574
2575
  * Default click-ID registry.
2575
2576
  *
@@ -3227,13 +3228,6 @@ declare function isRouteArray(next: Next): next is NextRule[];
3227
3228
  declare function compileNext(next: Next | undefined): CompiledNext | undefined;
3228
3229
  declare function resolveNext(compiled: CompiledNext | undefined, context?: Record<string, unknown>): string | string[] | undefined;
3229
3230
 
3230
- type PackageType = 'source' | 'destination' | 'transformer' | 'store';
3231
- interface PackageSchemas {
3232
- settings?: Record<string, unknown>;
3233
- [key: string]: unknown;
3234
- }
3235
- declare function mergeConfigSchema(type: PackageType, packageSchemas: PackageSchemas): Record<string, unknown>;
3236
-
3237
3231
  interface CompiledCacheRule {
3238
3232
  match: CompiledMatcher;
3239
3233
  key: string[];
@@ -3261,4 +3255,4 @@ declare function checkCache(compiled: CompiledCache, store: Instance$1, context:
3261
3255
  declare function storeCache(store: Instance$1, key: string, value: unknown, ttlSeconds: number): void;
3262
3256
  declare function applyUpdate(value: unknown, update: Record<string, unknown> | undefined, context: Record<string, unknown>): Promise<unknown>;
3263
3257
 
3264
- export { cache as Cache, type CacheResult, type ClickIdEntry, ClickIdEntrySchema, collector as Collector, type CompiledCache, type CompiledNext, type CompiledRoute, Const, context as Context, destination as Destination, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, flow as Flow, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, Level, lifecycle as Lifecycle, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, type SendDataValue, type SendHeaders, type SendResponse, simulation as Simulation, source as Source, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileNext, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isRouteArray, isSameType, isString, mcpError, mcpResult, mergeConfigSchema, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveNext, setByPath, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, walkPath, wrapCondition, wrapFn, wrapValidate };
3258
+ export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, type CompiledNext, type CompiledRoute, Const, context as Context, destination as Destination, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, flow as Flow, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, Level, lifecycle as Lifecycle, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, type SendDataValue, type SendHeaders, type SendResponse, simulation as Simulation, source as Source, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileNext, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isRouteArray, isSameType, isString, mcpError, mcpResult, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveNext, setByPath, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, walkPath, wrapCondition, wrapFn, wrapValidate };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { z } from 'zod';
2
-
3
1
  type MatchExpression = MatchCondition | {
4
2
  and: MatchExpression[];
5
3
  } | {
@@ -2564,12 +2562,15 @@ interface MarketingParameters {
2564
2562
  }
2565
2563
  /**
2566
2564
  * Click-ID registry entry — maps a URL parameter name to a canonical platform.
2565
+ *
2566
+ * Runtime shape only; the corresponding Zod schema lives in
2567
+ * `@walkeros/core/dev` (schemas/marketing.ts) for dev tooling that needs
2568
+ * validation or JSON Schema generation.
2567
2569
  */
2568
- declare const ClickIdEntrySchema: z.ZodObject<{
2569
- param: z.ZodString;
2570
- platform: z.ZodString;
2571
- }, z.core.$strip>;
2572
- type ClickIdEntry = z.infer<typeof ClickIdEntrySchema>;
2570
+ interface ClickIdEntry {
2571
+ param: string;
2572
+ platform: string;
2573
+ }
2573
2574
  /**
2574
2575
  * Default click-ID registry.
2575
2576
  *
@@ -3227,13 +3228,6 @@ declare function isRouteArray(next: Next): next is NextRule[];
3227
3228
  declare function compileNext(next: Next | undefined): CompiledNext | undefined;
3228
3229
  declare function resolveNext(compiled: CompiledNext | undefined, context?: Record<string, unknown>): string | string[] | undefined;
3229
3230
 
3230
- type PackageType = 'source' | 'destination' | 'transformer' | 'store';
3231
- interface PackageSchemas {
3232
- settings?: Record<string, unknown>;
3233
- [key: string]: unknown;
3234
- }
3235
- declare function mergeConfigSchema(type: PackageType, packageSchemas: PackageSchemas): Record<string, unknown>;
3236
-
3237
3231
  interface CompiledCacheRule {
3238
3232
  match: CompiledMatcher;
3239
3233
  key: string[];
@@ -3261,4 +3255,4 @@ declare function checkCache(compiled: CompiledCache, store: Instance$1, context:
3261
3255
  declare function storeCache(store: Instance$1, key: string, value: unknown, ttlSeconds: number): void;
3262
3256
  declare function applyUpdate(value: unknown, update: Record<string, unknown> | undefined, context: Record<string, unknown>): Promise<unknown>;
3263
3257
 
3264
- export { cache as Cache, type CacheResult, type ClickIdEntry, ClickIdEntrySchema, collector as Collector, type CompiledCache, type CompiledNext, type CompiledRoute, Const, context as Context, destination as Destination, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, flow as Flow, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, Level, lifecycle as Lifecycle, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, type SendDataValue, type SendHeaders, type SendResponse, simulation as Simulation, source as Source, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileNext, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isRouteArray, isSameType, isString, mcpError, mcpResult, mergeConfigSchema, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveNext, setByPath, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, walkPath, wrapCondition, wrapFn, wrapValidate };
3258
+ export { cache as Cache, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, type CompiledNext, type CompiledRoute, Const, context as Context, destination as Destination, ENV_MARKER_PREFIX, elb as Elb, type ExampleSummary, flow as Flow, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, Level, lifecycle as Lifecycle, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, on as On, request as Request, type ResolveOptions, type RespondFn, type RespondOptions, type SendDataValue, type SendHeaders, type SendResponse, simulation as Simulation, source as Source, type StorageType, store as Store, transformer as Transformer, trigger as Trigger, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyUpdate, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileNext, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, debounce, deepMerge, defaultClickIds, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isRouteArray, isSameType, isString, mcpError, mcpResult, mergeContractSchemas, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, resolveContracts, resolveNext, setByPath, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, walkPath, wrapCondition, wrapFn, wrapValidate };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(e,n)=>{for(var i in n)t(e,i,{get:n[i],enumerable:!0})},s={};r(s,{Cache:()=>a,ClickIdEntrySchema:()=>we,Collector:()=>c,Const:()=>C,Context:()=>l,Destination:()=>d,ENV_MARKER_PREFIX:()=>U,Elb:()=>p,Flow:()=>u,Hint:()=>O,Hooks:()=>f,Level:()=>g,Lifecycle:()=>j,Logger:()=>b,Mapping:()=>m,Matcher:()=>E,On:()=>h,Request:()=>z,Simulation:()=>x,Source:()=>y,Store:()=>w,Transformer:()=>v,Trigger:()=>k,WalkerOS:()=>S,anonymizeIP:()=>$,applyUpdate:()=>Mi,assign:()=>K,branch:()=>N,buildCacheContext:()=>Ai,castToProperty:()=>De,castValue:()=>ue,checkCache:()=>Ii,clone:()=>ae,compileCache:()=>Di,compileMatcher:()=>gt,compileNext:()=>ht,createDestination:()=>be,createEvent:()=>me,createIngest:()=>P,createLogger:()=>Pe,createMockContext:()=>We,createMockLogger:()=>Je,createRespond:()=>bt,debounce:()=>Se,deepMerge:()=>ge,defaultClickIds:()=>ke,fetchPackage:()=>lt,fetchPackageSchema:()=>pt,filterValues:()=>Ae,flattenIncludeSections:()=>pe,getBrowser:()=>Qe,getBrowserVersion:()=>Xe,getByPath:()=>ce,getDeviceType:()=>tt,getEvent:()=>he,getFlowSettings:()=>V,getGrantedConsent:()=>fe,getHeaders:()=>Fe,getId:()=>ve,getMappingEvent:()=>Me,getMappingValue:()=>Te,getMarketingParameters:()=>je,getOS:()=>Ye,getOSVersion:()=>et,getPlatform:()=>F,isArguments:()=>Z,isArray:()=>Q,isBoolean:()=>X,isCommand:()=>Y,isDefined:()=>ee,isElementOrDocument:()=>te,isFunction:()=>ne,isNumber:()=>ie,isObject:()=>oe,isPropertyType:()=>$e,isRouteArray:()=>mt,isSameType:()=>re,isString:()=>se,mcpError:()=>ft,mcpResult:()=>ut,mergeConfigSchema:()=>Ni,mergeContractSchemas:()=>M,mockEnv:()=>Le,packageNameToVariable:()=>B,parseUserAgent:()=>Ze,processEventMapping:()=>qe,requestToData:()=>Be,requestToParameter:()=>He,resolveContracts:()=>R,resolveNext:()=>vt,setByPath:()=>le,storeCache:()=>Ri,throttle:()=>xe,throwError:()=>A,transformData:()=>Ve,traverseEnv:()=>Ue,trim:()=>Ge,tryCatch:()=>Ie,tryCatchAsync:()=>Re,useHooks:()=>Ke,walkPath:()=>J,wrapCondition:()=>it,wrapFn:()=>ot,wrapValidate:()=>rt}),module.exports=(e=s,((e,r,s,a)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let c of i(r))o.call(e,c)||c===s||t(e,c,{get:()=>r[c],enumerable:!(a=n(r,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={},c={},l={},d={},p={},u={},f={},b={};r(b,{Level:()=>g});var g=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(g||{}),m={},h={},v={},z={},y={},w={},k={},j={},S={},x={},E={},O={},C={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function P(e){return{_meta:{hops:0,path:[e]}}}function N(e,t){return{event:e,next:t}}function $(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function A(e){throw new Error(String(e))}var D=["globals","context","custom","user","consent"],I=new Set(["description","examples","title","$comment"]);function R(e){const t={},n=new Set;function i(o){if(t[o])return t[o];n.has(o)&&A(`Circular extends chain detected: ${[...n,o].join(" → ")}`);const r=e[o];r||A(`Contract "${o}" not found`),n.add(o);let s={};if(r.extends){s=function(e,t){const n={};void 0===e.tagging&&void 0===t.tagging||(n.tagging=t.tagging??e.tagging);void 0===e.description&&void 0===t.description||(n.description=t.description??e.description);for(const i of D){const o=e[i],r=t[i];o&&r?n[i]=M(o,r):(o||r)&&(n[i]={...o||r})}if(e.events||t.events){const i={},o=new Set([...Object.keys(e.events||{}),...Object.keys(t.events||{})]);for(const n of o){const o=e.events?.[n]||{},r=t.events?.[n]||{},s=new Set([...Object.keys(o),...Object.keys(r)]);i[n]={};for(const e of s){const t=o[e],s=r[e];i[n][e]=t&&s?M(t,s):{...t||s}}}n.events=i}return n}(i(r.extends),r)}else s={...r};if(delete s.extends,s.events&&(s.events=function(e){const t={};for(const n of Object.keys(e))if("*"!==n){t[n]={};for(const i of Object.keys(e[n]||{})){let o={};const r=e["*"]?.["*"];r&&(o=M(o,r));const s=e["*"]?.[i];s&&"*"!==i&&(o=M(o,s));const a=e[n]?.["*"];a&&"*"!==i&&(o=M(o,a));const c=e[n]?.[i];c&&(o=M(o,c)),t[n][i]=o}}e["*"]&&(t["*"]={...e["*"]});return t}(s.events)),s.events){const e={};for(const[t,n]of Object.entries(s.events)){e[t]={};for(const[i,o]of Object.entries(n))e[t][i]=T(o)}s.events=e}return n.delete(o),t[o]=s,s}for(const t of Object.keys(e))i(t);return t}function M(e,t){const n={...e};for(const i of Object.keys(t)){const o=e[i],r=t[i];"required"===i&&Array.isArray(o)&&Array.isArray(r)?n[i]=[...new Set([...o,...r])]:_(o)&&_(r)?n[i]=M(o,r):n[i]=r}return n}function T(e){const t={};for(const[n,i]of Object.entries(e))I.has(n)||(null===i||"object"!=typeof i||Array.isArray(i)?t[n]=i:t[n]=T(i));return t}function _(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function q(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function L(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}var U="__WALKEROS_ENV:";function J(e,t,n){const i=t.split(".");let o=e;for(let e=0;e<i.length;e++){const r=i[e];if(null==o||"object"!=typeof o){const o=i.slice(0,e).join(".");A(`Path "${t}" not found in "${n}": "${r}" does not exist${o?` in "${o}"`:""}`)}const s=o;if(!(r in s)){const o=i.slice(0,e).join(".");A(`Path "${t}" not found in "${n}": "${r}" does not exist${o?` in "${o}"`:""}`)}o=s[r]}return o}function W(e,t,n,i,o){if("string"==typeof e){const r=e.match(/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/);if(r){const e=r[1],s=r[2];void 0===n[e]&&A(`Definition "${e}" not found`);let a=W(n[e],t,n,i,o);return s&&(a=J(a,s,`$def.${e}`)),a}const s=e.match(/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/);if(s&&o){const e=s[1],t=s[2];e in o||A(`Contract "${e}" not found`);let n=o[e];return t&&(n=J(n,t,`$contract.${e}`)),n}let a=e.replace(/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,n)=>{if(void 0!==t[n])return String(t[n]);A(`Variable "${n}" not found`)});return a=a.replace(/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,(e,t,n)=>i?.deferred?void 0!==n?`${U}${t}:${n}`:`${U}${t}`:"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==n?n:void A(`Environment variable "${t}" not found and no default provided`)),a}if(Array.isArray(e))return e.map(e=>W(e,t,n,i,o));if(null!==e&&"object"==typeof e){const r={};for(const[s,a]of Object.entries(e))r[s]=W(a,t,n,i,o);return r}return e}function B(e){const t=e.startsWith("@"),n=e.replace("@","").replace(/[/-]/g,"_").split("_").filter(e=>e.length>0).map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return t?"_"+n:n}function H(e,t,n){if(t)return t;if(!e||!n)return;return n[e]?B(e):void 0}function V(e,t,n){const i=Object.keys(e.flows);t||(1===i.length?t=i[0]:A(`Multiple flows found (${i.join(", ")}). Please specify a flow.`));const o=e.flows[t];o||A(`Flow "${t}" not found. Available: ${i.join(", ")}`);const r=JSON.parse(JSON.stringify(o));let s;if(e.contract){const t=q(e.variables,o.variables),i=L(e.definitions,o.definitions);s=R(W(e.contract,t,i,n))}if(r.sources)for(const[t,i]of Object.entries(r.sources)){const a=q(e.variables,o.variables,i.variables),c=L(e.definitions,o.definitions,i.definitions),l=W(i.config,a,c,n,s),d=W(i.env,a,c,n,s),p=H(i.package,i.code,r.bundle?.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.sources[t]={package:i.package,config:l,env:d,primary:i.primary,variables:i.variables,definitions:i.definitions,before:i.before,next:i.next,cache:i.cache,code:f}}if(r.destinations)for(const[t,i]of Object.entries(r.destinations)){const a=q(e.variables,o.variables,i.variables),c=L(e.definitions,o.definitions,i.definitions),l=W(i.config,a,c,n,s),d=W(i.env,a,c,n,s),p=H(i.package,i.code,r.bundle?.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.destinations[t]={package:i.package,config:l,env:d,variables:i.variables,definitions:i.definitions,before:i.before,next:i.next,cache:i.cache,code:f}}if(r.stores)for(const[t,i]of Object.entries(r.stores)){const a=q(e.variables,o.variables,i.variables),c=L(e.definitions,o.definitions,i.definitions),l=W(i.config,a,c,n,s),d=W(i.env,a,c,n,s),p=H(i.package,i.code,r.bundle?.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.stores[t]={package:i.package,config:l,env:d,variables:i.variables,definitions:i.definitions,code:f}}if(r.transformers)for(const[t,i]of Object.entries(r.transformers)){const a=q(e.variables,o.variables,i.variables),c=L(e.definitions,o.definitions,i.definitions),l=W(i.config,a,c,n,s),d=W(i.env,a,c,n,s),p=H(i.package,i.code,r.bundle?.packages),u="string"==typeof i.code||"object"==typeof i.code?i.code:void 0,f=p||u;r.transformers[t]={package:i.package,config:l,env:d,variables:i.variables,definitions:i.definitions,before:i.before,next:i.next,cache:i.cache,code:f}}if(r.collector){const t=q(e.variables,o.variables),i=L(e.definitions,o.definitions),a=W(r.collector,t,i,n,s);r.collector=a}return r}function F(e){return void 0!==e.web?"web":void 0!==e.server?"server":void A("Settings must have web or server key")}var G={merge:!0,shallow:!0,extend:!0};function K(e,t={},n={}){n={...G,...n};const i=Object.entries(t).reduce((t,[i,o])=>{const r=e[i];return n.merge&&Array.isArray(r)&&Array.isArray(o)?t[i]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...r]):(n.extend||i in e)&&(t[i]=o),t},{});return n.shallow?{...e,...i}:(Object.assign(e,i),e)}function Z(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function Q(e){return Array.isArray(e)}function X(e){return"boolean"==typeof e}function Y(e){return"walker"===e}function ee(e){return void 0!==e}function te(e){return!(!e||"object"!=typeof e)&&("body"in e||"tagName"in e)}function ne(e){return"function"==typeof e}function ie(e){return"number"==typeof e&&!Number.isNaN(e)}function oe(e){return"object"==typeof e&&null!==e&&!Q(e)&&"[object Object]"===Object.prototype.toString.call(e)}function re(e,t){return typeof e==typeof t}function se(e){return"string"==typeof e}function ae(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=ae(e[i],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(ae(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function ce(e,t="",n){const i=t.split(".");let o=e;for(let e=0;e<i.length;e++){const t=i[e];if("*"===t&&Q(o)){const t=i.slice(e+1).join("."),r=[];for(const e of o){const i=ce(e,t,n);r.push(i)}return r}if(o=o instanceof Object?o[t]:void 0,void 0===o)break}return ee(o)?o:n}function le(e,t,n){if(!oe(e))return e;const i=ae(e),o=t.split(".");let r=i;for(let e=0;e<o.length;e++){const t=o[e];e===o.length-1?r[t]=n:(t in r&&"object"==typeof r[t]&&null!==r[t]||(r[t]={}),r=r[t])}return i}var de={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,version:e=>e.version,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,group:e.group,count:e.count,timing:e.timing})};function pe(e,t){const n={},i=t.includes("all")?Object.keys(de):t;for(const t of i){const i=de[t];if(!i)continue;const o=i(e);if(oe(o))for(const[e,i]of Object.entries(o)){if(void 0===i)continue;const o="context"===t&&Array.isArray(i)?i[0]:i;n[`${t}_${e}`]=o}}return n}function ue(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function fe(e,t={},n={}){const i={...t,...n},o={};let r=!e||0===Object.keys(e).length;return Object.keys(i).forEach(t=>{i[t]&&(o[t]=!0,e&&e[t]&&(r=!0))}),!!r&&o}function be(e,t){const n={...e};return n.config=K(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=K(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=K(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function ge(e,t){if(!oe(t))return e;for(const n of Object.keys(t)){const i=t[n];void 0!==i&&(oe(i)&&oe(e[n])?ge(e[n],i):e[n]=i)}return e}function me(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",i=e.count||1,o=K({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${t}-${n}-${i}`,trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,group:n,count:i,version:{source:"3.2.0",tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){const[t,n]=e.name.split(" ")??[];t&&n&&(o.entity=t,o.action=n)}return o}function he(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),i={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return me({...{"cart view":{data:{currency:"EUR",value:2*i.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...i.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:i.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...i,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...i,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.walkeros.io/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...i,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...i,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...i.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function ve(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}var ze=require("zod");function ye(e,t,n="draft-7"){return ze.z.toJSONSchema(e,{target:n})}var we=ze.z.object({param:ze.z.string().describe("Lowercase URL parameter name. Match is case-insensitive on lookup."),platform:ze.z.string().describe("Canonical platform identifier (lowercase, kebab-case).")}),ke=[{param:"gclid",platform:"google"},{param:"wbraid",platform:"google"},{param:"gbraid",platform:"google"},{param:"dclid",platform:"google"},{param:"gclsrc",platform:"google"},{param:"fbclid",platform:"meta"},{param:"igshid",platform:"meta"},{param:"msclkid",platform:"microsoft"},{param:"ttclid",platform:"tiktok"},{param:"twclid",platform:"twitter"},{param:"li_fat_id",platform:"linkedin"},{param:"epik",platform:"pinterest"},{param:"sclid",platform:"snapchat"},{param:"sccid",platform:"snapchat"},{param:"rdt_cid",platform:"reddit"},{param:"qclid",platform:"quora"},{param:"yclid",platform:"yandex"},{param:"ymclid",platform:"yandex"},{param:"ysclid",platform:"yandex"},{param:"dicbo",platform:"outbrain"},{param:"obclid",platform:"outbrain"},{param:"tblci",platform:"taboola"},{param:"mc_cid",platform:"mailchimp"},{param:"mc_eid",platform:"mailchimp"},{param:"_kx",platform:"klaviyo"},{param:"_hsenc",platform:"hubspot"},{param:"_hsmi",platform:"hubspot"},{param:"s_kwcid",platform:"adobe"},{param:"ef_id",platform:"adobe"},{param:"mkt_tok",platform:"adobe"},{param:"irclickid",platform:"impact"},{param:"cjevent",platform:"cj"},{param:"_branch_match_id",platform:"branch"}];function je(e,t={},n=[]){const i={};Object.entries(K({utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term"},t)).forEach(([t,n])=>{const o=e.searchParams.get(t);o&&(i[n]=o)});const o=n.length?function(e){const t=new Map(e.map(e=>[e.param,e.platform])),n=new Set(ke.map(e=>e.param));return[...ke.map(e=>t.has(e.param)?{param:e.param,platform:t.get(e.param)}:e),...e.filter(e=>!n.has(e.param))]}(n):ke,r=new Map;e.searchParams.forEach((e,t)=>{e&&r.set(t.toLowerCase(),e)});for(const e of o){const t=r.get(e.param);t&&(i[e.param]=t,i.clickId||(i.clickId=e.param,i.platform=e.platform))}return i}function Se(e,t=1e3,n=!1){let i,o=null,r=!1;return(...s)=>new Promise(a=>{const c=n&&!r;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n&&!r||(i=e(...s),a(i))},t),c&&(r=!0,i=e(...s),a(i))})}function xe(e,t=1e3){let n=null;return function(...i){if(null===n)return n=setTimeout(()=>{n=null},t),e(...i)}}function Ee(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function Oe(e,t){let n,i={};return e instanceof Error?(n=e.message,i.error=Ee(e)):n=e,void 0!==t&&(t instanceof Error?i.error=Ee(t):"object"==typeof t&&null!==t?(i={...i,...t},"error"in i&&i.error instanceof Error&&(i.error=Ee(i.error))):i.value=t),{message:n,context:i}}var Ce=(e,t,n,i)=>{const o=`${g[e]}${i.length>0?` [${i.join(":")}]`:""}`,r=Object.keys(n).length>0,s=0===e?console.error:1===e?console.warn:console.log;r?s(o,t,n):s(o,t)};function Pe(e={}){return Ne({level:void 0!==e.level?function(e){return"string"==typeof e?g[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function Ne(e){const{level:t,handler:n,jsonHandler:i,scope:o}=e,r=(e,i,r)=>{if(e<=t){const t=Oe(i,r);n?n(e,t.message,t.context,o,Ce):Ce(e,t.message,t.context,o)}};return{error:(e,t)=>r(0,e,t),warn:(e,t)=>r(1,e,t),info:(e,t)=>r(2,e,t),debug:(e,t)=>r(3,e,t),throw:(e,t)=>{const i=Oe(e,t);throw n?n(0,i.message,i.context,o,Ce):Ce(0,i.message,i.context,o),new Error(i.message)},json:e=>{i?i(e):console.log(JSON.stringify(e,null,2))},scope:e=>Ne({level:t,handler:n,jsonHandler:i,scope:[...o,e]})}}function $e(e){return X(e)||se(e)||ie(e)||!ee(e)||Q(e)&&e.every($e)||oe(e)&&Object.values(e).every($e)}function Ae(e){return X(e)||se(e)||ie(e)?e:Z(e)?Ae(Array.from(e)):Q(e)?e.map(e=>Ae(e)).filter(e=>void 0!==e):oe(e)?Object.entries(e).reduce((e,[t,n])=>{const i=Ae(n);return void 0!==i&&(e[t]=i),e},{}):void 0}function De(e){return $e(e)?e:void 0}function Ie(e,t,n){return function(...i){try{return e(...i)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function Re(e,t,n){return async function(...i){try{return await e(...i)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function Me(e,t){const[n,i]=(e.name||"").split(" ");if(!t||!n||!i)return{};let o,r="",s=n,a=i;const c=t=>{if(t)return(t=Q(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const l=t[s];return l&&(l[a]||(a="*"),o=c(l[a])),o||(s="*",a="*",o=c(t[s]?.[a])),o&&(r=`${s} ${a}`),{eventMapping:o,mappingKey:r}}async function Te(e,t={},n={}){if(!ee(e))return;const i=oe(e)&&e.consent||n.consent||n.collector?.consent,o=Q(t)?t:[t];for(const t of o){const o=await Re(_e)(e,t,{...n,consent:i});if(ee(o))return o}}async function _e(e,t,n={}){const{collector:i,consent:o}=n;return(Q(t)?t:[t]).reduce(async(t,r)=>{const s=await t;if(s)return s;const a=se(r)?{key:r}:r;if(!Object.keys(a).length)return;const{condition:c,consent:l,fn:d,key:p,loop:u,map:f,set:b,validate:g,value:m}=a;if(c&&!await Re(c)(e,r,i))return;if(l&&!fe(l,o))return m;let h=ee(m)?m:e;if(d&&(h=await Re(d)(e,r,n)),p&&(h=ce(e,p,m)),u){const[t,i]=u,o="this"===t?[e]:await Te(e,t,n);Q(o)&&(h=(await Promise.all(o.map(e=>Te(e,i,n)))).filter(ee))}else f?h=await Object.entries(f).reduce(async(t,[i,o])=>{const r=await t,s=await Te(e,o,n);return ee(s)&&(r[i]=s),r},Promise.resolve({})):b&&(h=await Promise.all(b.map(t=>_e(e,t,n))));g&&!await Re(g)(h)&&(h=void 0);const v=De(h);return ee(v)?v:De(m)},Promise.resolve(void 0))}async function qe(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,i])=>{const o=await Te(e,i,{collector:n});e=le(e,t,o)}));const{eventMapping:i,mappingKey:o}=await Me(e,t.mapping);i?.policy&&await Promise.all(Object.entries(i.policy).map(async([t,i])=>{const o=await Te(e,i,{collector:n});e=le(e,t,o)}));let r=t.data&&await Te(e,t.data,{collector:n});const s=Boolean(i?.skip);if(i){if(i.ignore)return{event:e,data:r,mapping:i,mappingKey:o,ignore:!0,skip:s};if(i.name&&(e.name=i.name),i.data){const t=i.data&&await Te(e,i.data,{collector:n});r=oe(r)&&oe(t)?K(r,t):t}}const a=i?.include??t.include;if(a&&a.length>0){const t=pe(e,a);Object.keys(t).length>0&&(r=oe(r)?K(t,r):r??t)}return{event:e,data:r,mapping:i,mappingKey:o,ignore:!1,skip:s}}function Le(e,t){const n=(e,i=[])=>new Proxy(e,{get(e,o){const r=e[o],s=[...i,o];return"function"==typeof r?r.prototype&&r.prototype.constructor===r?r:(...e)=>{const i=t(s,e,r);if(i&&"object"==typeof i)return n(i,s);const o=r(...e);return o&&"object"==typeof o?n(o,s):i}:r&&"object"==typeof r?n(r,s):r}});return n(e)}function Ue(e,t){const n=(e,i=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[r,s]of Object.entries(e)){const e=[...i,r];Array.isArray(o)?o[Number(r)]=t(s,e):o[r]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(o)?o[Number(r)]=n(s,e):o[r]=n(s,e))}return o};return n(e)}function Je(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=Je();return e.push(n),n});return{error:jest.fn(),warn:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,json:jest.fn(),scope:n,scopedLoggers:e}}function We(e={}){return{collector:{},config:{},env:{},logger:Je(),id:"test",ingest:P("test"),...e}}function Be(e){const t=String(e),n=t.split("?")[1]||t;return Ie(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const i=n.split(/[[\]]+/).filter(Boolean);let o=t;i.forEach((t,n)=>{const r=n===i.length-1;if(Q(o)){const s=parseInt(t,10);r?o[s]=ue(e):(o[s]=o[s]||(isNaN(parseInt(i[n+1],10))?{}:[]),o=o[s])}else oe(o)&&(r?o[t]=ue(e):(o[t]=o[t]||(isNaN(parseInt(i[n+1],10))?{}:[]),o=o[t]))})}),t})()}function He(e){if(!e)return"";const t=[],n=encodeURIComponent;function i(e,o){null!=o&&(Q(o)?o.forEach((t,n)=>i(`${e}[${n}]`,t)):oe(o)?Object.entries(o).forEach(([t,n])=>i(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(o))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>i(e,t)),t.join("&"))}function Ve(e){return void 0===e||re(e,"")?e:JSON.stringify(e)}function Fe(e={}){return K({"Content-Type":"application/json; charset=utf-8"},e)}function Ge(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Ke(e,t,n){return function(...i){let o;const r="post"+t,s=n["pre"+t],a=n[r];return o=s?s({fn:e},...i):e(...i),a&&(o=a({fn:e,result:o},...i)),o}}function Ze(e){return e?{userAgent:e,browser:Qe(e),browserVersion:Xe(e),os:Ye(e),osVersion:et(e),deviceType:tt(e)}:{}}function Qe(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function Xe(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function Ye(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function et(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function tt(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function nt(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function it(e){const t=nt(e);return new Function("value","mapping","collector",t)}function ot(e){const t=nt(e);return new Function("value","mapping","options",t)}function rt(e){const t=nt(e);return new Function("value",t)}var st="https://cdn.jsdelivr.net/npm",at="dist/walkerOS.json";function ct(e){return"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?e:void 0}async function lt(e,t){const n=t?.version||"latest",i=t?.timeout||1e4,o=new AbortController,r=setTimeout(()=>o.abort(),i),s=o.signal;try{let i,o;if(t?.baseUrl){const r=encodeURIComponent(e),a=`${t.baseUrl}/api/packages/${r}`;i=await dt(`${a}?version=${n}&path=package.json`,s),o=await dt(`${a}?version=${n}&path=dist/walkerOS.json`,s)}else{const t=`${st}/${e}@${n}`;i=await dt(`${t}/package.json`,s),o=await dt(`${t}/${at}`,s)}return function(e,t,n,i){const o=i.$meta||{},r=i.schemas||{},s=i.examples||{},a=i.hints,c=a?Object.keys(a):[],l=[],d=s.step||{};for(const[e,t]of Object.entries(d)){const n=t,i={name:e};"string"==typeof n?.description&&(i.description=n.description),l.push(i)}const p="string"==typeof o.docs?o.docs:void 0,u="string"==typeof o.source?o.source:void 0;return{packageName:e,version:"string"==typeof n.version?n.version:t,description:"string"==typeof n.description?n.description:void 0,type:"string"==typeof o.type?o.type:void 0,platform:ct(o.platform),schemas:r,examples:s,...p?{docs:p}:{},...u?{source:u}:{},...a&&Object.keys(a).length>0?{hints:a}:{},hintKeys:c,exampleSummaries:l}}(e,n,i,o)}finally{clearTimeout(r)}}async function dt(e,t){const n=await fetch(e,{signal:t});if(!n.ok)throw new Error(`Failed to fetch ${e} (HTTP ${n.status})`);return await n.json()}async function pt(e,t){const n=await lt(e,t);return{packageName:n.packageName,version:n.version,type:n.type,platform:n.platform,schemas:n.schemas,examples:n.examples,...n.hints?{hints:n.hints}:{}}}function ut(e,t){const n=t?{...e,_hints:t}:e;return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}}function ft(e,t){let n,i,o,r;if(e instanceof Error){n=e.message;const t=e;t.code&&(o=t.code),Array.isArray(t.details)&&(r=t.details)}else if("string"==typeof e)n=e;else if(e&&"object"==typeof e&&"issues"in e&&Array.isArray(e.issues)){const t=e.issues;n=t.map(e=>e.message).join("; "),i=t[0]?.path?.join(".")||void 0}else n=e&&"object"==typeof e&&"message"in e?String(e.message):"Unknown error";const s={error:n};return t&&(s.hint=t),i&&(s.path=i),o&&(s.code=o),r&&(s.details=r),{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s,isError:!0}}function bt(e){let t=!1;return(n={})=>{t||(t=!0,e(n))}}function gt(e){if("*"===e)return()=>!0;if("and"in e){const t=e.and.map(gt);return e=>t.every(t=>t(e))}if("or"in e){const t=e.or.map(gt);return e=>t.some(t=>t(e))}return function(e){const{key:t,operator:n,value:i,not:o}=e,r=function(e,t){switch(e){case"eq":return e=>String(e??"")===t;case"contains":return e=>String(e??"").includes(t);case"prefix":return e=>String(e??"").startsWith(t);case"suffix":return e=>String(e??"").endsWith(t);case"regex":{const e=new RegExp(t);return t=>e.test(String(t??""))}case"gt":{const e=Number(t);return t=>Number(t)>e}case"lt":{const e=Number(t);return t=>Number(t)<e}case"exists":return e=>null!=e}}(n,i);return e=>{const n=ce(e,t),i=r(n);return o?!i:i}}(e)}function mt(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&"match"in e[0]}function ht(e){if(null!=e){if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;if(mt(e)){return{type:"routes",routes:e.map(e=>({match:gt(e.match),next:ht(e.next)}))}}return{type:"chain",value:e}}}}function vt(e,t={}){if(e){if("static"===e.type)return e.value;if("chain"===e.type)return e.value;for(const n of e.routes)if(n.match(t))return vt(n.next,t)}}var zt,yt=ze.z.string(),wt=ze.z.number(),kt=(ze.z.boolean(),ze.z.string().min(1)),jt=ze.z.number().int().positive(),St=ze.z.number().int().nonnegative(),xt=ze.z.number().describe("Tagging version number"),Et=(ze.z.union([ze.z.string(),ze.z.number(),ze.z.boolean()]).optional(),ze.z.enum(["local","session","cookie"]).describe("Storage mechanism: local, session, or cookie")),Ot=ze.z.object({Local:ze.z.literal("local"),Session:ze.z.literal("session"),Cookie:ze.z.literal("cookie")}).describe("Storage type constants for type-safe references"),Ct=ze.z.any().describe("Error handler function: (error, state?) => void"),Pt=ze.z.any().describe("Log handler function: (message, verbose?) => void"),Nt=ze.z.object({Error:Ct.describe("Error handler function"),Log:Pt.describe("Log handler function")}).describe("Handler interface with error and log functions"),$t=(ye(Et),ye(Ot),ye(Ct),ye(Pt),ye(Nt),ze.z.object({onError:Ct.optional().describe("Error handler function: (error, state?) => void"),onLog:Pt.optional().describe("Log handler function: (message, verbose?) => void")}).partial(),ze.z.object({verbose:ze.z.boolean().describe("Enable verbose logging for debugging").optional()}).partial(),ze.z.object({queue:ze.z.boolean().describe("Whether to queue events when consent is not granted").optional()}).partial(),ze.z.object({}).partial(),ze.z.object({init:ze.z.boolean().describe("Whether to initialize immediately").optional(),loadScript:ze.z.boolean().describe("Whether to load external script (for web destinations)").optional()}).partial(),ze.z.object({primary:ze.z.boolean().describe("Mark as primary (only one can be primary)").optional()}).partial(),ze.z.object({settings:ze.z.any().optional().describe("Implementation-specific configuration")}).partial(),ze.z.object({env:ze.z.any().optional().describe("Environment dependencies (platform-specific)")}).partial(),ze.z.object({type:ze.z.string().optional().describe("Instance type identifier"),config:ze.z.unknown().describe("Instance configuration")}).partial(),ze.z.object({collector:ze.z.unknown().describe("Collector instance (runtime object)"),config:ze.z.unknown().describe("Configuration"),env:ze.z.unknown().describe("Environment dependencies")}).partial(),ze.z.object({batch:ze.z.number().optional().describe("Batch size: bundle N events for batch processing"),batched:ze.z.unknown().optional().describe("Batch of events to be processed")}).partial(),ze.z.object({ignore:ze.z.boolean().describe("Set to true to skip processing").optional(),condition:ze.z.string().optional().describe("Condition function: return true to process")}).partial(),ze.z.object({sources:ze.z.record(ze.z.string(),ze.z.unknown()).describe("Map of source instances")}).partial(),ze.z.object({destinations:ze.z.record(ze.z.string(),ze.z.unknown()).describe("Map of destination instances")}).partial(),ze.z.lazy(()=>ze.z.union([ze.z.boolean(),ze.z.string(),ze.z.number(),ze.z.record(ze.z.string(),At)]))),At=ze.z.lazy(()=>ze.z.union([$t,ze.z.array($t)])),Dt=ze.z.record(ze.z.string(),At.optional()).describe("Flexible property collection with optional values"),It=ze.z.record(ze.z.string(),ze.z.tuple([At,ze.z.number()]).optional()).describe("Ordered properties with [value, order] tuples for priority control"),Rt=ze.z.union([ze.z.enum(["web","server","app","other"]),ze.z.string()]).describe("Source type: web, server, app, other, or custom"),Mt=ze.z.record(ze.z.string(),ze.z.boolean()).describe("Consent requirement mapping (group name → state)"),Tt=Dt.and(ze.z.object({id:ze.z.string().optional().describe("User identifier"),device:ze.z.string().optional().describe("Device identifier"),session:ze.z.string().optional().describe("Session identifier"),hash:ze.z.string().optional().describe("Hashed identifier"),address:ze.z.string().optional().describe("User address"),email:ze.z.string().email().optional().describe("User email address"),phone:ze.z.string().optional().describe("User phone number"),userAgent:ze.z.string().optional().describe("Browser user agent string"),browser:ze.z.string().optional().describe("Browser name"),browserVersion:ze.z.string().optional().describe("Browser version"),deviceType:ze.z.string().optional().describe("Device type (mobile, desktop, tablet)"),os:ze.z.string().optional().describe("Operating system"),osVersion:ze.z.string().optional().describe("Operating system version"),screenSize:ze.z.string().optional().describe("Screen dimensions"),language:ze.z.string().optional().describe("User language"),country:ze.z.string().optional().describe("User country"),region:ze.z.string().optional().describe("User region/state"),city:ze.z.string().optional().describe("User city"),zip:ze.z.string().optional().describe("User postal code"),timezone:ze.z.string().optional().describe("User timezone"),ip:ze.z.string().optional().describe("User IP address"),internal:ze.z.boolean().optional().describe("Internal user flag (employee, test user)")})).describe("User identification and properties"),_t=Dt.and(ze.z.object({source:yt.describe('Walker implementation version (e.g., "2.0.0")'),tagging:xt})).describe("Walker version information"),qt=Dt.and(ze.z.object({type:Rt.describe("Source type identifier"),id:yt.describe("Source identifier (typically URL on web)"),previous_id:yt.describe("Previous source identifier (typically referrer on web)")})).describe("Event source information"),Lt=ze.z.lazy(()=>ze.z.object({entity:ze.z.string().describe("Entity name"),data:Dt.describe("Entity-specific properties"),nested:ze.z.array(Lt).describe("Nested child entities"),context:It.describe("Entity context data")})).describe("Nested entity structure with recursive nesting support"),Ut=ze.z.array(Lt).describe("Array of nested entities"),Jt=ze.z.object({name:ze.z.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'),data:Dt.describe("Event-specific properties"),context:It.describe("Ordered context properties with priorities"),globals:Dt.describe("Global properties shared across events"),custom:Dt.describe("Custom implementation-specific properties"),user:Tt.describe("User identification and attributes"),nested:Ut.describe("Related nested entities"),consent:Mt.describe("Consent states at event time"),id:kt.describe("Unique event identifier (timestamp-based)"),trigger:yt.describe("Event trigger identifier"),entity:yt.describe("Parsed entity from event name"),action:yt.describe("Parsed action from event name"),timestamp:jt.describe("Unix timestamp in milliseconds since epoch"),timing:wt.describe("Event processing timing information"),group:yt.describe("Event grouping identifier"),count:St.describe("Event count in session"),version:_t.describe("Walker version information"),source:qt.describe("Event source information")}).describe("Complete walkerOS event structure"),Wt=Jt.partial().describe("Partial event structure with all fields optional"),Bt=(Jt.partial().describe("Partial event structure with all top-level fields optional"),ye(Jt),ye(Wt),ye(Tt),ye(Dt),ye(It),ye(Lt),ye(Rt),ye(Mt),ze.z.lazy(()=>ze.z.union([ze.z.string().describe('String value or property path (e.g., "data.id")'),ze.z.number().describe("Numeric value"),ze.z.boolean().describe("Boolean value"),ze.z.lazy(()=>zt),ze.z.array(Bt).describe("Array of values")]))),Ht=ze.z.array(Bt).describe("Array of transformation values"),Vt=ze.z.lazy(()=>ze.z.tuple([Bt,Bt]).describe("Loop transformation: [source, transform] tuple for array processing")),Ft=ze.z.lazy(()=>ze.z.array(Bt).describe("Set: Array of values for selection or combination")),Gt=ze.z.lazy(()=>ze.z.record(ze.z.string(),Bt).describe("Map: Object mapping keys to transformation values")),Kt=zt=ze.z.object({key:ze.z.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'),value:ze.z.union([ze.z.string(),ze.z.number(),ze.z.boolean()]).optional().describe("Static primitive value"),fn:ze.z.string().optional().describe("Custom transformation function as string (serialized)"),map:Gt.optional().describe("Object mapping: transform event data to structured output"),loop:Vt.optional().describe("Loop transformation: [source, transform] for array processing"),set:Ft.optional().describe("Set of values: combine or select from multiple values"),consent:Mt.optional().describe("Required consent states to include this value"),condition:ze.z.string().optional().describe("Condition function as string: return true to include value"),validate:ze.z.string().optional().describe("Validation function as string: return true if value is valid")}).refine(e=>Object.keys(e).length>0,{message:"ValueConfig must have at least one property"}).describe("Value transformation configuration with multiple strategies"),Zt=ze.z.record(ze.z.string(),Bt).describe("Policy rules for event pre-processing (key → value mapping)"),Qt=ze.z.object({batch:ze.z.number().optional().describe("Batch size: bundle N events for batch processing"),condition:ze.z.string().optional().describe("Condition function as string: return true to process event"),consent:Mt.optional().describe("Required consent states to process this event"),settings:ze.z.any().optional().describe("Destination-specific settings for this event mapping"),data:ze.z.union([Bt,Ht]).optional().describe("Data transformation rules for event"),ignore:ze.z.boolean().optional().describe("Set to true to skip processing this event"),name:ze.z.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'),policy:Zt.optional().describe("Event-level policy overrides (applied after config-level policy)")}).describe("Mapping rule for specific entity-action combination"),Xt=ze.z.record(ze.z.string(),ze.z.record(ze.z.string(),ze.z.union([Qt,ze.z.array(Qt)])).optional()).describe('Event mapping rules: entity → action → Rule. Keys match event name split by space. Use "*" as wildcard for entity or action. Priority: exact > entity wildcard > action wildcard > global wildcard (*→*).'),Yt=ze.z.object({consent:Mt.optional().describe("Required consent states to process any events"),data:ze.z.union([Bt,Ht]).optional().describe("Global data transformation applied to all events"),mapping:Xt.optional().describe("Entity-action specific mapping rules"),policy:Zt.optional().describe("Pre-processing policy rules applied before mapping")}).describe("Shared mapping configuration for sources and destinations"),en=(ze.z.object({eventMapping:Qt.optional().describe("Resolved mapping rule for event"),mappingKey:ze.z.string().optional().describe('Mapping key used (e.g., "product.view")')}).describe("Mapping resolution result"),ye(Bt),ye(Kt),ye(Vt),ye(Ft),ye(Gt),ye(Zt),ye(Qt),ye(Xt),ye(Yt),{});r(en,{BatchSchema:()=>dn,ConfigSchema:()=>tn,ContextSchema:()=>rn,DLQSchema:()=>zn,DataSchema:()=>pn,DestinationPolicySchema:()=>on,DestinationsSchema:()=>gn,InitDestinationsSchema:()=>bn,InitSchema:()=>fn,InstanceSchema:()=>un,PartialConfigSchema:()=>nn,PushBatchContextSchema:()=>an,PushContextSchema:()=>sn,PushEventSchema:()=>cn,PushEventsSchema:()=>ln,PushResultSchema:()=>hn,RefSchema:()=>mn,ResultSchema:()=>vn,batchJsonSchema:()=>Sn,configJsonSchema:()=>yn,contextJsonSchema:()=>kn,instanceJsonSchema:()=>xn,partialConfigJsonSchema:()=>wn,pushContextJsonSchema:()=>jn,resultJsonSchema:()=>En});var tn=ze.z.object({consent:Mt.optional().describe("Required consent states to send events to this destination"),settings:ze.z.any().describe("Implementation-specific configuration").optional(),data:ze.z.union([Bt,Ht]).optional().describe("Global data transformation applied to all events for this destination"),env:ze.z.any().describe("Environment dependencies (platform-specific)").optional(),id:kt.describe("Destination instance identifier (defaults to destination key)").optional(),init:ze.z.boolean().describe("Whether to initialize immediately").optional(),loadScript:ze.z.boolean().describe("Whether to load external script (for web destinations)").optional(),mapping:Xt.optional().describe("Entity-action specific mapping rules for this destination"),policy:Zt.optional().describe("Pre-processing policy rules applied before event mapping"),queue:ze.z.boolean().describe("Whether to queue events when consent is not granted").optional(),require:ze.z.array(ze.z.string()).optional().describe('Defer destination initialization until these collector events fire (e.g., ["consent"])'),logger:ze.z.object({level:ze.z.union([ze.z.number(),ze.z.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:ze.z.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),onError:Ct.optional(),onLog:Pt.optional()}).describe("Destination configuration"),nn=tn.partial().describe("Partial destination configuration with all fields optional"),on=Zt.describe("Destination policy rules for event pre-processing"),rn=ze.z.object({collector:ze.z.unknown().describe("Collector instance (runtime object)"),config:tn.describe("Destination configuration"),data:ze.z.union([ze.z.unknown(),ze.z.array(ze.z.unknown())]).optional().describe("Transformed event data"),env:ze.z.unknown().describe("Environment dependencies")}).describe("Destination context for init and push functions"),sn=rn.extend({mapping:Qt.optional().describe("Resolved mapping rule for this specific event")}).describe("Push context with event-specific mapping"),an=sn.describe("Batch push context with event-specific mapping"),cn=ze.z.object({event:Jt.describe("The event to process"),mapping:Qt.optional().describe("Mapping rule for this event")}).describe("Event with optional mapping for batch processing"),ln=ze.z.array(cn).describe("Array of events with mappings"),dn=ze.z.object({key:ze.z.string().describe('Batch key (usually mapping key like "product.view")'),events:ze.z.array(Jt).describe("Array of events in batch"),data:ze.z.array(ze.z.union([ze.z.unknown(),ze.z.array(ze.z.unknown())]).optional()).describe("Transformed data for each event"),mapping:Qt.optional().describe("Shared mapping rule for batch")}).describe("Batch of events grouped by mapping key"),pn=ze.z.union([ze.z.unknown(),ze.z.array(ze.z.unknown())]).optional().describe("Transformed event data (Property, undefined, or array)"),un=ze.z.object({config:tn.describe("Destination configuration"),queue:ze.z.array(Jt).optional().describe("Queued events awaiting consent"),dlq:ze.z.array(ze.z.tuple([Jt,ze.z.unknown()])).optional().describe("Dead letter queue (failed events with errors)"),type:ze.z.string().optional().describe("Destination type identifier"),env:ze.z.unknown().optional().describe("Environment dependencies"),init:ze.z.unknown().optional().describe("Initialization function"),push:ze.z.unknown().describe("Push function for single events"),pushBatch:ze.z.unknown().optional().describe("Batch push function"),on:ze.z.unknown().optional().describe("Event lifecycle hook function")}).describe("Destination instance (runtime object with functions)"),fn=ze.z.object({code:un.describe("Destination instance with implementation"),config:nn.optional().describe("Partial configuration overrides"),env:ze.z.unknown().optional().describe("Partial environment overrides")}).describe("Destination initialization configuration"),bn=ze.z.record(ze.z.string(),fn).describe("Map of destination IDs to initialization configurations"),gn=ze.z.record(ze.z.string(),un).describe("Map of destination IDs to runtime instances"),mn=ze.z.object({type:ze.z.string().describe('Destination type ("gtag", "meta", "bigquery")'),data:ze.z.unknown().optional().describe("Response from push()"),error:ze.z.unknown().optional().describe("Error if failed")}).describe("Destination reference with type and response data"),hn=ze.z.object({queue:ze.z.array(Jt).optional().describe("Events queued (awaiting consent)"),error:ze.z.unknown().optional().describe("Error if push failed")}).describe("Push operation result"),vn=ze.z.object({ok:ze.z.boolean().describe("True if nothing failed"),event:ze.z.unknown().optional().describe("The processed event"),done:ze.z.record(ze.z.string(),mn).optional().describe("Destinations that processed successfully"),queued:ze.z.record(ze.z.string(),mn).optional().describe("Destinations that queued events"),failed:ze.z.record(ze.z.string(),mn).optional().describe("Destinations that failed to process")}).describe("Push result with destination outcomes"),zn=ze.z.array(ze.z.tuple([Jt,ze.z.unknown()])).describe("Dead letter queue: [(event, error), ...]"),yn=ye(tn),wn=ye(nn),kn=ye(rn),jn=ye(sn),Sn=ye(dn),xn=ye(un),En=ye(vn),On=ze.z.union([ze.z.enum(["action","config","consent","context","destination","elb","globals","hook","init","link","run","user","walker"]),ze.z.string()]).describe("Collector command type: standard commands or custom string for extensions"),Cn=ze.z.object({run:ze.z.boolean().describe("Whether to run collector automatically on initialization").optional(),tagging:xt,globalsStatic:Dt.describe("Static global properties that persist across collector runs"),sessionStatic:ze.z.record(ze.z.string(),ze.z.unknown()).describe("Static session data that persists across collector runs"),verbose:ze.z.boolean().describe("Enable verbose logging for debugging"),onError:Ct.optional(),onLog:Pt.optional()}).describe("Core collector configuration"),Pn=Dt.and(ze.z.object({isStart:ze.z.boolean().describe("Whether this is a new session start"),storage:ze.z.boolean().describe("Whether storage is available"),id:kt.describe("Session identifier").optional(),start:jt.describe("Session start timestamp").optional(),marketing:ze.z.literal(!0).optional().describe("Marketing attribution flag"),updated:jt.describe("Last update timestamp").optional(),isNew:ze.z.boolean().describe("Whether this is a new session").optional(),device:kt.describe("Device identifier").optional(),count:St.describe("Event count in session").optional(),runs:St.describe("Number of runs").optional()})).describe("Session state and tracking data"),Nn=Cn.partial().extend({consent:Mt.optional().describe("Initial consent state"),user:Tt.optional().describe("Initial user data"),globals:Dt.optional().describe("Initial global properties"),sources:ze.z.unknown().optional().describe("Source configurations"),destinations:ze.z.unknown().optional().describe("Destination configurations"),custom:Dt.optional().describe("Initial custom implementation-specific properties")}).describe("Collector initialization configuration with initial state"),$n=ze.z.object({mapping:Yt.optional().describe("Source-level mapping configuration")}).describe("Push context with optional source mapping"),An=ze.z.record(ze.z.string(),ze.z.unknown()).describe("Map of source IDs to source instances"),Dn=ze.z.record(ze.z.string(),ze.z.unknown()).describe("Map of destination IDs to destination instances"),In=ze.z.object({push:ze.z.unknown().describe("Push function for processing events"),command:ze.z.unknown().describe("Command function for walker commands"),allowed:ze.z.boolean().describe("Whether event processing is allowed"),config:Cn.describe("Current collector configuration"),consent:Mt.describe("Current consent state"),count:ze.z.number().describe("Event count (increments with each event)"),custom:Dt.describe("Custom implementation-specific properties"),sources:An.describe("Registered source instances"),destinations:Dn.describe("Registered destination instances"),globals:Dt.describe("Current global properties"),group:ze.z.string().describe("Event grouping identifier"),hooks:ze.z.unknown().describe("Lifecycle hook functions"),on:ze.z.unknown().describe("Event lifecycle configuration"),queue:ze.z.array(Jt).describe("Queued events awaiting processing"),round:ze.z.number().describe("Collector run count (increments with each run)"),session:ze.z.union([Pn]).describe("Current session state"),timing:ze.z.number().describe("Event processing timing information"),user:Tt.describe("Current user data"),version:ze.z.string().describe("Walker implementation version")}).describe("Collector instance with state and methods"),Rn=(ye(On),ye(Cn),ye(Pn),ye(Nn),ye($n),ye(In),{});r(Rn,{BaseEnvSchema:()=>Mn,ConfigSchema:()=>Tn,InitSchema:()=>Ln,InitSourceSchema:()=>Un,InitSourcesSchema:()=>Jn,InstanceSchema:()=>qn,PartialConfigSchema:()=>_n,baseEnvJsonSchema:()=>Wn,configJsonSchema:()=>Bn,initSourceJsonSchema:()=>Fn,initSourcesJsonSchema:()=>Gn,instanceJsonSchema:()=>Vn,partialConfigJsonSchema:()=>Hn});var Mn=ze.z.object({push:ze.z.unknown().describe("Collector push function"),command:ze.z.unknown().describe("Collector command function"),sources:ze.z.unknown().optional().describe("Map of registered source instances"),elb:ze.z.unknown().describe("Public API function (alias for collector.push)")}).catchall(ze.z.unknown()).describe("Base environment for dependency injection - platform-specific sources extend this"),Tn=Yt.extend({settings:ze.z.any().describe("Implementation-specific configuration").optional(),env:Mn.optional().describe("Environment dependencies (platform-specific)"),id:kt.describe("Source identifier (defaults to source key)").optional(),onError:Ct.optional(),primary:ze.z.boolean().describe("Mark as primary (only one can be primary)").optional(),require:ze.z.array(ze.z.string()).optional().describe('Defer source initialization until these collector events fire (e.g., ["consent"])'),logger:ze.z.object({level:ze.z.union([ze.z.number(),ze.z.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:ze.z.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),ingest:ze.z.union([Bt,Ht]).optional().describe("Ingest metadata extraction mapping. Extracts values from raw request objects (Express req, Lambda event) using mapping syntax.")}).describe("Source configuration with mapping and environment"),_n=Tn.partial().describe("Partial source configuration with all fields optional"),qn=ze.z.object({type:ze.z.string().describe('Source type identifier (e.g., "browser", "dataLayer")'),config:Tn.describe("Current source configuration"),push:ze.z.any().describe("Push function - THE HANDLER (flexible signature for platform compatibility)"),destroy:ze.z.any().optional().describe("Cleanup function called when source is removed"),on:ze.z.unknown().optional().describe("Lifecycle hook function for event types")}).describe("Source instance with push handler and lifecycle methods"),Ln=ze.z.any().describe("Source initialization function: (config, env) => Instance | Promise<Instance>"),Un=ze.z.object({code:Ln.describe("Source initialization function"),config:_n.optional().describe("Partial configuration overrides"),env:Mn.partial().optional().describe("Partial environment overrides"),primary:ze.z.boolean().optional().describe("Mark as primary source (only one can be primary)")}).describe("Source initialization configuration"),Jn=ze.z.record(ze.z.string(),Un).describe("Map of source IDs to initialization configurations"),Wn=ye(Mn),Bn=ye(Tn),Hn=ye(_n),Vn=ye(qn),Fn=ye(Un),Gn=ye(Jn),Kn=ze.z.enum(["eq","contains","prefix","suffix","regex","gt","lt","exists"]),Zn=ze.z.object({key:ze.z.string(),operator:Kn,value:ze.z.string(),not:ze.z.boolean().optional()}),Qn=ze.z.union([Zn,ze.z.object({and:ze.z.array(ze.z.lazy(()=>Qn))}),ze.z.object({or:ze.z.array(ze.z.lazy(()=>Qn))})]),Xn=ze.z.union([Qn,ze.z.literal("*")]),Yn=ze.z.union([ze.z.string(),ze.z.array(ze.z.string()),ze.z.array(ze.z.object({match:Xn,next:ze.z.lazy(()=>Yn)}))]),ei=(ze.z.object({match:Xn,next:ze.z.lazy(()=>Yn)}),ze.z.object({match:ze.z.union([Qn,ze.z.literal("*")]).describe("Match expression or wildcard to determine when this rule applies"),key:ze.z.array(ze.z.string()).min(1).describe("Dot-path fields used to build the cache key"),ttl:ze.z.number().positive().describe("Time-to-live in seconds for cached entries"),update:ze.z.record(ze.z.string(),Bt).optional().describe("Response mutations applied on cache hit (key → Value mapping)")})),ti=ze.z.object({full:ze.z.boolean().optional().describe("Stop flow on cache HIT (default: false). When true, skip remaining steps and return cached value."),store:ze.z.string().optional().describe("Store ID for persistent caching (references a configured store)"),rules:ze.z.array(ei).min(1).describe("Cache rules — at least one required")}),ni=ze.z.union([ze.z.string(),ze.z.number(),ze.z.boolean()]).describe("Primitive value: string, number, or boolean"),ii=ze.z.record(ze.z.string(),ni).describe("Variables for interpolation"),oi=ze.z.record(ze.z.string(),ze.z.unknown()).describe("Reusable configuration definitions"),ri=/^(@[a-z0-9\-~][a-z0-9\-._~]*\/)?[a-z0-9\-~][a-z0-9\-._~]*$/,si=ze.z.record(ze.z.string().regex(ri,"Invalid npm package name"),ze.z.object({version:ze.z.string().optional(),imports:ze.z.array(ze.z.string()).optional(),path:ze.z.string().optional()})).describe("NPM packages to bundle"),ai=ze.z.record(ze.z.string().regex(ri,"Invalid npm package name"),ze.z.string().min(1,"Override version cannot be empty")).describe("Transitive dependency version overrides"),ci=ze.z.object({packages:si.optional().describe("NPM packages to bundle"),overrides:ai.optional().describe("Transitive dependency overrides")}).strict().describe("Bundle configuration (packages + overrides)"),li=ze.z.object({windowCollector:ze.z.string().default("collector").optional().describe('Window property name for the collector instance (default: "collector")'),windowElb:ze.z.string().default("elb").optional().describe('Window property name for the elb command queue (default: "elb")')}).describe("Web platform configuration"),di=ze.z.object({}).passthrough().describe("Server platform configuration (reserved for future options)"),pi=ze.z.object({push:ze.z.string().min(1,"Push function cannot be empty").describe('JavaScript function for processing events. Must start with "$code:" prefix. Example: "$code:(event) => { console.log(event); }"'),type:ze.z.string().optional().describe("Optional type identifier for the inline instance"),init:ze.z.string().optional().describe("Optional initialization function. Use $code: prefix for inline JavaScript.")}).describe("Inline code for custom sources/transformers/destinations"),ui=ze.z.object({description:ze.z.string().optional().describe("Human-readable description"),in:ze.z.unknown().optional().describe("Input to the step"),trigger:ze.z.object({type:ze.z.string().optional().describe("Trigger mechanism (e.g., click, POST, load)"),options:ze.z.unknown().optional().describe("Mechanism-specific options")}).optional().describe("Source trigger metadata"),mapping:ze.z.unknown().optional().describe("Mapping configuration"),out:ze.z.unknown().optional().describe("Expected output from the step"),command:ze.z.enum(["config","consent","user","run"]).optional().describe("Invoke elb('walker <command>', in) instead of pushing in as an event")}).describe("Named example with input/output pair"),fi=ze.z.record(ze.z.string(),ui).describe("Named step examples for testing and documentation"),bi=ze.z.object({package:ze.z.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-source-browser@2.0.0")'),code:ze.z.union([ze.z.string(),pi]).optional().describe('Either a named export string (e.g., "sourceExpress") or an inline code object with push function'),config:ze.z.unknown().optional().describe("Source-specific configuration object"),env:ze.z.unknown().optional().describe("Source environment configuration"),primary:ze.z.boolean().optional().describe("Mark as primary source (provides main elb). Only one source should be primary."),variables:ii.optional().describe("Source-level variables (highest priority in cascade)"),definitions:oi.optional().describe("Source-level definitions (highest priority in cascade)"),next:Yn.optional().describe("Pre-collector transformer chain. String, string[], or NextRule[] for conditional routing based on ingest data."),before:Yn.optional().describe("Pre-source transformer chain (consent-exempt). Handles transport-level preprocessing."),examples:fi.optional().describe("Named step examples for testing and documentation (stripped during bundling)"),cache:ti.optional().describe("Cache configuration for this source (match → key → ttl rules)")}).describe("Source package reference with configuration"),gi=ze.z.object({package:ze.z.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/transformer-enricher@1.0.0")'),code:ze.z.union([ze.z.string(),pi]).optional().describe('Either a named export string (e.g., "transformerEnricher") or an inline code object with push function'),config:ze.z.unknown().optional().describe("Transformer-specific configuration object"),env:ze.z.unknown().optional().describe("Transformer environment configuration"),before:Yn.optional().describe("Pre-transformer chain. Runs before this transformer push function."),next:Yn.optional().describe("Next transformer in chain. String, string[], or NextRule[] for conditional routing."),variables:ii.optional().describe("Transformer-level variables (highest priority in cascade)"),definitions:oi.optional().describe("Transformer-level definitions (highest priority in cascade)"),examples:fi.optional().describe("Named step examples for testing and documentation (stripped during bundling)"),cache:ti.optional().describe("Cache configuration for this transformer (match → key → ttl rules)")}).describe("Transformer package reference with configuration"),mi=ze.z.object({package:ze.z.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-destination-gtag@2.0.0")'),code:ze.z.union([ze.z.string(),pi]).optional().describe('Either a named export string (e.g., "destinationAnalytics") or an inline code object with push function'),config:ze.z.unknown().optional().describe("Destination-specific configuration object"),env:ze.z.unknown().optional().describe("Destination environment configuration"),variables:ii.optional().describe("Destination-level variables (highest priority in cascade)"),definitions:oi.optional().describe("Destination-level definitions (highest priority in cascade)"),before:Yn.optional().describe("Post-collector transformer chain. String, string[], or NextRule[] for conditional routing."),next:Yn.optional().describe("Post-push transformer chain. Push response available at context.ingest._response."),examples:fi.optional().describe("Named step examples for testing and documentation (stripped during bundling)"),cache:ti.optional().describe("Cache configuration for this destination (match → key → ttl rules)")}).describe("Destination package reference with configuration"),hi=ze.z.object({package:ze.z.string().min(1,"Package name cannot be empty").optional().describe("Store package specifier with optional version"),code:ze.z.union([ze.z.string(),pi]).optional().describe("Named export string or inline code definition"),config:ze.z.unknown().optional().describe("Store-specific configuration object"),env:ze.z.unknown().optional().describe("Store environment configuration"),variables:ii.optional().describe("Store-level variables (highest priority in cascade)"),definitions:oi.optional().describe("Store-level definitions (highest priority in cascade)"),examples:fi.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Store package reference with configuration"),vi=ze.z.record(ze.z.string(),ze.z.unknown()).describe("JSON Schema object for event validation with description/examples annotations"),zi=ze.z.record(ze.z.string(),vi).describe("Action-level contract entries"),yi=ze.z.record(ze.z.string(),zi).describe("Entity-action event schemas"),wi=ze.z.object({extends:ze.z.string().optional().describe("Inherit from another named contract"),tagging:ze.z.number().int().min(0).optional().describe("Contract version number"),description:ze.z.string().optional().describe("Human-readable description"),globals:vi.optional().describe("JSON Schema for event.globals"),context:vi.optional().describe("JSON Schema for event.context"),custom:vi.optional().describe("JSON Schema for event.custom"),user:vi.optional().describe("JSON Schema for event.user"),consent:vi.optional().describe("JSON Schema for event.consent"),events:yi.optional().describe("Entity-action event schemas")}).describe("Named contract entry with optional sections and events"),ki=ze.z.record(ze.z.string(),wi).describe("Named contracts with optional extends inheritance"),ji=ze.z.object({web:li.optional().describe("Web platform configuration (browser-based tracking). Mutually exclusive with server."),server:di.optional().describe("Server platform configuration (Node.js). Mutually exclusive with web."),sources:ze.z.record(ze.z.string(),bi).optional().describe("Source configurations (data capture) keyed by unique identifier"),destinations:ze.z.record(ze.z.string(),mi).optional().describe("Destination configurations (data output) keyed by unique identifier"),transformers:ze.z.record(ze.z.string(),gi).optional().describe("Transformer configurations (event transformation) keyed by unique identifier"),stores:ze.z.record(ze.z.string(),hi).optional().describe("Store configurations (key-value storage) keyed by unique identifier"),collector:ze.z.unknown().optional().describe("Collector configuration for event processing (uses Collector.InitConfig)"),bundle:ci.optional().describe("Build-time configuration (packages + overrides)"),packages:ze.z.unknown().optional().refine(e=>void 0===e,{message:"`packages` must live under `bundle.packages`. Move your packages block to `flow.<name>.bundle.packages`. This is a breaking change — see CHANGELOG migration guide."}).describe("Legacy top-level packages (moved to bundle.packages)"),variables:ii.optional().describe("Flow-level variables (override Config.variables, overridden by source/destination variables)"),definitions:oi.optional().describe("Flow-level definitions (extend Config.definitions, overridden by source/destination definitions)")}).refine(e=>{const t=void 0!==e.web,n=void 0!==e.server;return(t||n)&&!(t&&n)},{message:'Exactly one of "web" or "server" must be present'}).describe("Single flow settings for one deployment target"),Si=ze.z.object({$schema:ze.z.string().url("Schema URL must be a valid URL").optional().describe('JSON Schema reference for IDE validation (e.g., "https://walkeros.io/schema/flow/v2.json")'),include:ze.z.array(ze.z.string()).optional().describe("Folders to include in the bundle output"),variables:ii.optional().describe("Shared variables for interpolation across all flows (use $var.name syntax)"),definitions:oi.optional().describe("Reusable configuration definitions (use $def.name syntax)"),flows:ze.z.record(ze.z.string(),ji).refine(e=>Object.keys(e).length>0,{message:"At least one flow is required"}).describe("Named flow configurations (e.g., production, staging, development)")}).extend({version:ze.z.literal(3).describe("Configuration schema version"),contract:ki.optional().describe("Named contracts with extends inheritance and dot-path references")}).describe("walkerOS flow configuration (walkeros.config.json)"),xi=(ze.z.toJSONSchema(Si,{target:"draft-7"}),ye(ji),ye(bi),ye(mi),ye(gi),ye(hi),ye(wi),ye(ki),require("zod")),Ei=xi.z.object({lang:xi.z.string().optional().describe("Language identifier (e.g. json, sql, bash, typescript)"),code:xi.z.string().describe("Code snippet")}),Oi=xi.z.object({text:xi.z.string().describe("Short actionable hint text focused on walkerOS usage"),code:xi.z.array(Ei).optional().describe("Optional code snippets")}),Ci=(xi.z.record(xi.z.string(),Oi).describe("Keyed hints for AI consumption — lightweight context beyond schemas and examples"),new Set(["env","onError","onLog","primary"])),Pi={source:Rn.configJsonSchema,destination:en.configJsonSchema};function Ni(e,t){const n=Pi[e];if(!n||!n.properties){return{type:"object",properties:{settings:t.settings?$i(t.settings):{description:"Implementation-specific configuration"}}}}const i=JSON.parse(JSON.stringify(n)),o=i.properties;for(const e of Ci)delete o[e];return t.settings&&(o.settings=$i(t.settings)),i}function $i(e){const{$schema:t,...n}=e;return n}function Ai(e,t){const n={ingest:e??{}};return void 0!==t&&(n.event=t),n}function Di(e){return{full:e.full??!1,storeId:e.store,rules:e.rules.map(e=>({match:gt(e.match),key:e.key,ttl:e.ttl,update:e.update}))}}function Ii(e,t,n,i){const o=e.rules.find(e=>e.match(n));if(!o)return null;const r=o.key.map(e=>String(ce(n,e)??""));if(r.every(e=>""===e))return null;const s=`${i}:${r.join(":")}`,a=t.get(s);return void 0!==a?{status:"HIT",key:s,value:a,rule:o}:{status:"MISS",key:s,rule:o}}function Ri(e,t,n,i){e.set(t,n,1e3*i)}async function Mi(e,t,n){if(!t)return e;let i=e;for(const[e,o]of Object.entries(t)){i=le(i,e,await Te(n,o))}return i}//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},s={};i(s,{Cache:()=>a,Collector:()=>c,Const:()=>E,Context:()=>u,Destination:()=>l,ENV_MARKER_PREFIX:()=>U,Elb:()=>f,Flow:()=>p,Hint:()=>A,Hooks:()=>d,Level:()=>m,Lifecycle:()=>x,Logger:()=>g,Mapping:()=>y,Matcher:()=>S,On:()=>b,Request:()=>v,Simulation:()=>$,Source:()=>w,Store:()=>j,Transformer:()=>h,Trigger:()=>k,WalkerOS:()=>O,anonymizeIP:()=>P,applyUpdate:()=>wt,assign:()=>J,branch:()=>N,buildCacheContext:()=>yt,castToProperty:()=>Ne,castValue:()=>pe,checkCache:()=>ht,clone:()=>ae,compileCache:()=>bt,compileMatcher:()=>pt,compileNext:()=>gt,createDestination:()=>ge,createEvent:()=>ye,createIngest:()=>_,createLogger:()=>Se,createMockContext:()=>He,createMockLogger:()=>Fe,createRespond:()=>ft,debounce:()=>je,deepMerge:()=>me,defaultClickIds:()=>ve,fetchPackage:()=>st,fetchPackageSchema:()=>ct,filterValues:()=>_e,flattenIncludeSections:()=>fe,getBrowser:()=>Ke,getBrowserVersion:()=>Je,getByPath:()=>ce,getDeviceType:()=>Qe,getEvent:()=>be,getFlowSettings:()=>q,getGrantedConsent:()=>de,getHeaders:()=>Be,getId:()=>he,getMappingEvent:()=>Me,getMappingValue:()=>Te,getMarketingParameters:()=>we,getOS:()=>Ge,getOSVersion:()=>Xe,getPlatform:()=>Z,isArguments:()=>G,isArray:()=>X,isBoolean:()=>Q,isCommand:()=>Y,isDefined:()=>ee,isElementOrDocument:()=>te,isFunction:()=>ne,isNumber:()=>re,isObject:()=>oe,isPropertyType:()=>Ee,isRouteArray:()=>dt,isSameType:()=>ie,isString:()=>se,mcpError:()=>lt,mcpResult:()=>ut,mergeContractSchemas:()=>I,mockEnv:()=>De,packageNameToVariable:()=>B,parseUserAgent:()=>Ze,processEventMapping:()=>Ie,requestToData:()=>Ue,requestToParameter:()=>Ve,resolveContracts:()=>R,resolveNext:()=>mt,setByPath:()=>ue,storeCache:()=>vt,throttle:()=>ke,throwError:()=>C,transformData:()=>Le,traverseEnv:()=>ze,trim:()=>We,tryCatch:()=>Pe,tryCatchAsync:()=>Ce,useHooks:()=>qe,walkPath:()=>V,wrapCondition:()=>et,wrapFn:()=>tt,wrapValidate:()=>nt}),module.exports=(e=s,((e,i,s,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of r(i))o.call(e,c)||c===s||t(e,c,{get:()=>i[c],enumerable:!(a=n(i,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={},c={},u={},l={},f={},p={},d={},g={};i(g,{Level:()=>m});var m=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(m||{}),y={},b={},h={},v={},w={},j={},k={},x={},O={},$={},S={},A={},E={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function _(e){return{_meta:{hops:0,path:[e]}}}function N(e,t){return{event:e,next:t}}function P(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function C(e){throw new Error(String(e))}var M=["globals","context","custom","user","consent"],T=new Set(["description","examples","title","$comment"]);function R(e){const t={},n=new Set;function r(o){if(t[o])return t[o];n.has(o)&&C(`Circular extends chain detected: ${[...n,o].join(" → ")}`);const i=e[o];i||C(`Contract "${o}" not found`),n.add(o);let s={};if(i.extends){s=function(e,t){const n={};void 0===e.tagging&&void 0===t.tagging||(n.tagging=t.tagging??e.tagging);void 0===e.description&&void 0===t.description||(n.description=t.description??e.description);for(const r of M){const o=e[r],i=t[r];o&&i?n[r]=I(o,i):(o||i)&&(n[r]={...o||i})}if(e.events||t.events){const r={},o=new Set([...Object.keys(e.events||{}),...Object.keys(t.events||{})]);for(const n of o){const o=e.events?.[n]||{},i=t.events?.[n]||{},s=new Set([...Object.keys(o),...Object.keys(i)]);r[n]={};for(const e of s){const t=o[e],s=i[e];r[n][e]=t&&s?I(t,s):{...t||s}}}n.events=r}return n}(r(i.extends),i)}else s={...i};if(delete s.extends,s.events&&(s.events=function(e){const t={};for(const n of Object.keys(e))if("*"!==n){t[n]={};for(const r of Object.keys(e[n]||{})){let o={};const i=e["*"]?.["*"];i&&(o=I(o,i));const s=e["*"]?.[r];s&&"*"!==r&&(o=I(o,s));const a=e[n]?.["*"];a&&"*"!==r&&(o=I(o,a));const c=e[n]?.[r];c&&(o=I(o,c)),t[n][r]=o}}e["*"]&&(t["*"]={...e["*"]});return t}(s.events)),s.events){const e={};for(const[t,n]of Object.entries(s.events)){e[t]={};for(const[r,o]of Object.entries(n))e[t][r]=D(o)}s.events=e}return n.delete(o),t[o]=s,s}for(const t of Object.keys(e))r(t);return t}function I(e,t){const n={...e};for(const r of Object.keys(t)){const o=e[r],i=t[r];"required"===r&&Array.isArray(o)&&Array.isArray(i)?n[r]=[...new Set([...o,...i])]:z(o)&&z(i)?n[r]=I(o,i):n[r]=i}return n}function D(e){const t={};for(const[n,r]of Object.entries(e))T.has(n)||(null===r||"object"!=typeof r||Array.isArray(r)?t[n]=r:t[n]=D(r));return t}function z(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function F(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function H(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}var U="__WALKEROS_ENV:";function V(e,t,n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const i=r[e];if(null==o||"object"!=typeof o){const o=r.slice(0,e).join(".");C(`Path "${t}" not found in "${n}": "${i}" does not exist${o?` in "${o}"`:""}`)}const s=o;if(!(i in s)){const o=r.slice(0,e).join(".");C(`Path "${t}" not found in "${n}": "${i}" does not exist${o?` in "${o}"`:""}`)}o=s[i]}return o}function L(e,t,n,r,o){if("string"==typeof e){const i=e.match(/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/);if(i){const e=i[1],s=i[2];void 0===n[e]&&C(`Definition "${e}" not found`);let a=L(n[e],t,n,r,o);return s&&(a=V(a,s,`$def.${e}`)),a}const s=e.match(/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/);if(s&&o){const e=s[1],t=s[2];e in o||C(`Contract "${e}" not found`);let n=o[e];return t&&(n=V(n,t,`$contract.${e}`)),n}let a=e.replace(/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,n)=>{if(void 0!==t[n])return String(t[n]);C(`Variable "${n}" not found`)});return a=a.replace(/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,(e,t,n)=>r?.deferred?void 0!==n?`${U}${t}:${n}`:`${U}${t}`:"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==n?n:void C(`Environment variable "${t}" not found and no default provided`)),a}if(Array.isArray(e))return e.map(e=>L(e,t,n,r,o));if(null!==e&&"object"==typeof e){const i={};for(const[s,a]of Object.entries(e))i[s]=L(a,t,n,r,o);return i}return e}function B(e){const t=e.startsWith("@"),n=e.replace("@","").replace(/[/-]/g,"_").split("_").filter(e=>e.length>0).map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return t?"_"+n:n}function W(e,t,n){if(t)return t;if(!e||!n)return;return n[e]?B(e):void 0}function q(e,t,n){const r=Object.keys(e.flows);t||(1===r.length?t=r[0]:C(`Multiple flows found (${r.join(", ")}). Please specify a flow.`));const o=e.flows[t];o||C(`Flow "${t}" not found. Available: ${r.join(", ")}`);const i=JSON.parse(JSON.stringify(o));let s;if(e.contract){const t=F(e.variables,o.variables),r=H(e.definitions,o.definitions);s=R(L(e.contract,t,r,n))}if(i.sources)for(const[t,r]of Object.entries(i.sources)){const a=F(e.variables,o.variables,r.variables),c=H(e.definitions,o.definitions,r.definitions),u=L(r.config,a,c,n,s),l=L(r.env,a,c,n,s),f=W(r.package,r.code,i.bundle?.packages),p="string"==typeof r.code||"object"==typeof r.code?r.code:void 0,d=f||p;i.sources[t]={package:r.package,config:u,env:l,primary:r.primary,variables:r.variables,definitions:r.definitions,before:r.before,next:r.next,cache:r.cache,code:d}}if(i.destinations)for(const[t,r]of Object.entries(i.destinations)){const a=F(e.variables,o.variables,r.variables),c=H(e.definitions,o.definitions,r.definitions),u=L(r.config,a,c,n,s),l=L(r.env,a,c,n,s),f=W(r.package,r.code,i.bundle?.packages),p="string"==typeof r.code||"object"==typeof r.code?r.code:void 0,d=f||p;i.destinations[t]={package:r.package,config:u,env:l,variables:r.variables,definitions:r.definitions,before:r.before,next:r.next,cache:r.cache,code:d}}if(i.stores)for(const[t,r]of Object.entries(i.stores)){const a=F(e.variables,o.variables,r.variables),c=H(e.definitions,o.definitions,r.definitions),u=L(r.config,a,c,n,s),l=L(r.env,a,c,n,s),f=W(r.package,r.code,i.bundle?.packages),p="string"==typeof r.code||"object"==typeof r.code?r.code:void 0,d=f||p;i.stores[t]={package:r.package,config:u,env:l,variables:r.variables,definitions:r.definitions,code:d}}if(i.transformers)for(const[t,r]of Object.entries(i.transformers)){const a=F(e.variables,o.variables,r.variables),c=H(e.definitions,o.definitions,r.definitions),u=L(r.config,a,c,n,s),l=L(r.env,a,c,n,s),f=W(r.package,r.code,i.bundle?.packages),p="string"==typeof r.code||"object"==typeof r.code?r.code:void 0,d=f||p;i.transformers[t]={package:r.package,config:u,env:l,variables:r.variables,definitions:r.definitions,before:r.before,next:r.next,cache:r.cache,code:d}}if(i.collector){const t=F(e.variables,o.variables),r=H(e.definitions,o.definitions),a=L(i.collector,t,r,n,s);i.collector=a}return i}function Z(e){return void 0!==e.web?"web":void 0!==e.server?"server":void C("Settings must have web or server key")}var K={merge:!0,shallow:!0,extend:!0};function J(e,t={},n={}){n={...K,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const i=e[r];return n.merge&&Array.isArray(i)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function G(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function X(e){return Array.isArray(e)}function Q(e){return"boolean"==typeof e}function Y(e){return"walker"===e}function ee(e){return void 0!==e}function te(e){return!(!e||"object"!=typeof e)&&("body"in e||"tagName"in e)}function ne(e){return"function"==typeof e}function re(e){return"number"==typeof e&&!Number.isNaN(e)}function oe(e){return"object"==typeof e&&null!==e&&!X(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ie(e,t){return typeof e==typeof t}function se(e){return"string"==typeof e}function ae(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=ae(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(ae(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function ce(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&X(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=ce(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,void 0===o)break}return ee(o)?o:n}function ue(e,t,n){if(!oe(e))return e;const r=ae(e),o=t.split(".");let i=r;for(let e=0;e<o.length;e++){const t=o[e];e===o.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return r}var le={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,version:e=>e.version,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,group:e.group,count:e.count,timing:e.timing})};function fe(e,t){const n={},r=t.includes("all")?Object.keys(le):t;for(const t of r){const r=le[t];if(!r)continue;const o=r(e);if(oe(o))for(const[e,r]of Object.entries(o)){if(void 0===r)continue;const o="context"===t&&Array.isArray(r)?r[0]:r;n[`${t}_${e}`]=o}}return n}function pe(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function de(e,t={},n={}){const r={...t,...n},o={};let i=!e||0===Object.keys(e).length;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(i=!0))}),!!i&&o}function ge(e,t){const n={...e};return n.config=J(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=J(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=J(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function me(e,t){if(!oe(t))return e;for(const n of Object.keys(t)){const r=t[n];void 0!==r&&(oe(r)&&oe(e[n])?me(e[n],r):e[n]=r)}return e}function ye(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=J({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${t}-${n}-${r}`,trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,group:n,count:r,version:{source:"3.2.0",tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){const[t,n]=e.name.split(" ")??[];t&&n&&(o.entity=t,o.action=n)}return o}function be(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),r={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return ye({...{"cart view":{data:{currency:"EUR",value:2*r.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...r.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:r.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.walkeros.io/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...r,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...r,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...r.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function he(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}var ve=[{param:"gclid",platform:"google"},{param:"wbraid",platform:"google"},{param:"gbraid",platform:"google"},{param:"dclid",platform:"google"},{param:"gclsrc",platform:"google"},{param:"fbclid",platform:"meta"},{param:"igshid",platform:"meta"},{param:"msclkid",platform:"microsoft"},{param:"ttclid",platform:"tiktok"},{param:"twclid",platform:"twitter"},{param:"li_fat_id",platform:"linkedin"},{param:"epik",platform:"pinterest"},{param:"sclid",platform:"snapchat"},{param:"sccid",platform:"snapchat"},{param:"rdt_cid",platform:"reddit"},{param:"qclid",platform:"quora"},{param:"yclid",platform:"yandex"},{param:"ymclid",platform:"yandex"},{param:"ysclid",platform:"yandex"},{param:"dicbo",platform:"outbrain"},{param:"obclid",platform:"outbrain"},{param:"tblci",platform:"taboola"},{param:"mc_cid",platform:"mailchimp"},{param:"mc_eid",platform:"mailchimp"},{param:"_kx",platform:"klaviyo"},{param:"_hsenc",platform:"hubspot"},{param:"_hsmi",platform:"hubspot"},{param:"s_kwcid",platform:"adobe"},{param:"ef_id",platform:"adobe"},{param:"mkt_tok",platform:"adobe"},{param:"irclickid",platform:"impact"},{param:"cjevent",platform:"cj"},{param:"_branch_match_id",platform:"branch"}];function we(e,t={},n=[]){const r={};Object.entries(J({utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term"},t)).forEach(([t,n])=>{const o=e.searchParams.get(t);o&&(r[n]=o)});const o=n.length?function(e){const t=new Map(e.map(e=>[e.param,e.platform])),n=new Set(ve.map(e=>e.param));return[...ve.map(e=>t.has(e.param)?{param:e.param,platform:t.get(e.param)}:e),...e.filter(e=>!n.has(e.param))]}(n):ve,i=new Map;e.searchParams.forEach((e,t)=>{e&&i.set(t.toLowerCase(),e)});for(const e of o){const t=i.get(e.param);t&&(r[e.param]=t,r.clickId||(r.clickId=e.param,r.platform=e.platform))}return r}function je(e,t=1e3,n=!1){let r,o=null,i=!1;return(...s)=>new Promise(a=>{const c=n&&!i;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n&&!i||(r=e(...s),a(r))},t),c&&(i=!0,r=e(...s),a(r))})}function ke(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function xe(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function Oe(e,t){let n,r={};return e instanceof Error?(n=e.message,r.error=xe(e)):n=e,void 0!==t&&(t instanceof Error?r.error=xe(t):"object"==typeof t&&null!==t?(r={...r,...t},"error"in r&&r.error instanceof Error&&(r.error=xe(r.error))):r.value=t),{message:n,context:r}}var $e=(e,t,n,r)=>{const o=`${m[e]}${r.length>0?` [${r.join(":")}]`:""}`,i=Object.keys(n).length>0,s=0===e?console.error:1===e?console.warn:console.log;i?s(o,t,n):s(o,t)};function Se(e={}){return Ae({level:void 0!==e.level?function(e){return"string"==typeof e?m[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function Ae(e){const{level:t,handler:n,jsonHandler:r,scope:o}=e,i=(e,r,i)=>{if(e<=t){const t=Oe(r,i);n?n(e,t.message,t.context,o,$e):$e(e,t.message,t.context,o)}};return{error:(e,t)=>i(0,e,t),warn:(e,t)=>i(1,e,t),info:(e,t)=>i(2,e,t),debug:(e,t)=>i(3,e,t),throw:(e,t)=>{const r=Oe(e,t);throw n?n(0,r.message,r.context,o,$e):$e(0,r.message,r.context,o),new Error(r.message)},json:e=>{r?r(e):console.log(JSON.stringify(e,null,2))},scope:e=>Ae({level:t,handler:n,jsonHandler:r,scope:[...o,e]})}}function Ee(e){return Q(e)||se(e)||re(e)||!ee(e)||X(e)&&e.every(Ee)||oe(e)&&Object.values(e).every(Ee)}function _e(e){return Q(e)||se(e)||re(e)?e:G(e)?_e(Array.from(e)):X(e)?e.map(e=>_e(e)).filter(e=>void 0!==e):oe(e)?Object.entries(e).reduce((e,[t,n])=>{const r=_e(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function Ne(e){return Ee(e)?e:void 0}function Pe(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function Ce(e,t,n){return async function(...r){try{return await e(...r)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function Me(e,t){const[n,r]=(e.name||"").split(" ");if(!t||!n||!r)return{};let o,i="",s=n,a=r;const c=t=>{if(t)return(t=X(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const u=t[s];return u&&(u[a]||(a="*"),o=c(u[a])),o||(s="*",a="*",o=c(t[s]?.[a])),o&&(i=`${s} ${a}`),{eventMapping:o,mappingKey:i}}async function Te(e,t={},n={}){if(!ee(e))return;const r=oe(e)&&e.consent||n.consent||n.collector?.consent,o=X(t)?t:[t];for(const t of o){const o=await Ce(Re)(e,t,{...n,consent:r});if(ee(o))return o}}async function Re(e,t,n={}){const{collector:r,consent:o}=n;return(X(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const a=se(i)?{key:i}:i;if(!Object.keys(a).length)return;const{condition:c,consent:u,fn:l,key:f,loop:p,map:d,set:g,validate:m,value:y}=a;if(c&&!await Ce(c)(e,i,r))return;if(u&&!de(u,o))return y;let b=ee(y)?y:e;if(l&&(b=await Ce(l)(e,i,n)),f&&(b=ce(e,f,y)),p){const[t,r]=p,o="this"===t?[e]:await Te(e,t,n);X(o)&&(b=(await Promise.all(o.map(e=>Te(e,r,n)))).filter(ee))}else d?b=await Object.entries(d).reduce(async(t,[r,o])=>{const i=await t,s=await Te(e,o,n);return ee(s)&&(i[r]=s),i},Promise.resolve({})):g&&(b=await Promise.all(g.map(t=>Re(e,t,n))));m&&!await Ce(m)(b)&&(b=void 0);const h=Ne(b);return ee(h)?h:Ne(y)},Promise.resolve(void 0))}async function Ie(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await Te(e,r,{collector:n});e=ue(e,t,o)}));const{eventMapping:r,mappingKey:o}=await Me(e,t.mapping);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await Te(e,r,{collector:n});e=ue(e,t,o)}));let i=t.data&&await Te(e,t.data,{collector:n});const s=Boolean(r?.skip);if(r){if(r.ignore)return{event:e,data:i,mapping:r,mappingKey:o,ignore:!0,skip:s};if(r.name&&(e.name=r.name),r.data){const t=r.data&&await Te(e,r.data,{collector:n});i=oe(i)&&oe(t)?J(i,t):t}}const a=r?.include??t.include;if(a&&a.length>0){const t=fe(e,a);Object.keys(t).length>0&&(i=oe(i)?J(t,i):i??t)}return{event:e,data:i,mapping:r,mappingKey:o,ignore:!1,skip:s}}function De(e,t){const n=(e,r=[])=>new Proxy(e,{get(e,o){const i=e[o],s=[...r,o];return"function"==typeof i?i.prototype&&i.prototype.constructor===i?i:(...e)=>{const r=t(s,e,i);if(r&&"object"==typeof r)return n(r,s);const o=i(...e);return o&&"object"==typeof o?n(o,s):r}:i&&"object"==typeof i?n(i,s):i}});return n(e)}function ze(e,t){const n=(e,r=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...r,i];Array.isArray(o)?o[Number(i)]=t(s,e):o[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(o)?o[Number(i)]=n(s,e):o[i]=n(s,e))}return o};return n(e)}function Fe(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=Fe();return e.push(n),n});return{error:jest.fn(),warn:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,json:jest.fn(),scope:n,scopedLoggers:e}}function He(e={}){return{collector:{},config:{},env:{},logger:Fe(),id:"test",ingest:_("test"),...e}}function Ue(e){const t=String(e),n=t.split("?")[1]||t;return Pe(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const r=n.split(/[[\]]+/).filter(Boolean);let o=t;r.forEach((t,n)=>{const i=n===r.length-1;if(X(o)){const s=parseInt(t,10);i?o[s]=pe(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else oe(o)&&(i?o[t]=pe(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function Ve(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(X(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):oe(o)?Object.entries(o).forEach(([t,n])=>r(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(o))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>r(e,t)),t.join("&"))}function Le(e){return void 0===e||ie(e,"")?e:JSON.stringify(e)}function Be(e={}){return J({"Content-Type":"application/json; charset=utf-8"},e)}function We(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function qe(e,t,n){return function(...r){let o;const i="post"+t,s=n["pre"+t],a=n[i];return o=s?s({fn:e},...r):e(...r),a&&(o=a({fn:e,result:o},...r)),o}}function Ze(e){return e?{userAgent:e,browser:Ke(e),browserVersion:Je(e),os:Ge(e),osVersion:Xe(e),deviceType:Qe(e)}:{}}function Ke(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function Je(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function Ge(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function Xe(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function Qe(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function Ye(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function et(e){const t=Ye(e);return new Function("value","mapping","collector",t)}function tt(e){const t=Ye(e);return new Function("value","mapping","options",t)}function nt(e){const t=Ye(e);return new Function("value",t)}var rt="https://cdn.jsdelivr.net/npm",ot="dist/walkerOS.json";function it(e){return"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?e:void 0}async function st(e,t){const n=t?.version||"latest",r=t?.timeout||1e4,o=new AbortController,i=setTimeout(()=>o.abort(),r),s=o.signal;try{let r,o;if(t?.baseUrl){const i=encodeURIComponent(e),a=`${t.baseUrl}/api/packages/${i}`;r=await at(`${a}?version=${n}&path=package.json`,s),o=await at(`${a}?version=${n}&path=dist/walkerOS.json`,s)}else{const t=`${rt}/${e}@${n}`;r=await at(`${t}/package.json`,s),o=await at(`${t}/${ot}`,s)}return function(e,t,n,r){const o=r.$meta||{},i=r.schemas||{},s=r.examples||{},a=r.hints,c=a?Object.keys(a):[],u=[],l=s.step||{};for(const[e,t]of Object.entries(l)){const n=t,r={name:e};"string"==typeof n?.description&&(r.description=n.description),u.push(r)}const f="string"==typeof o.docs?o.docs:void 0,p="string"==typeof o.source?o.source:void 0;return{packageName:e,version:"string"==typeof n.version?n.version:t,description:"string"==typeof n.description?n.description:void 0,type:"string"==typeof o.type?o.type:void 0,platform:it(o.platform),schemas:i,examples:s,...f?{docs:f}:{},...p?{source:p}:{},...a&&Object.keys(a).length>0?{hints:a}:{},hintKeys:c,exampleSummaries:u}}(e,n,r,o)}finally{clearTimeout(i)}}async function at(e,t){const n=await fetch(e,{signal:t});if(!n.ok)throw new Error(`Failed to fetch ${e} (HTTP ${n.status})`);return await n.json()}async function ct(e,t){const n=await st(e,t);return{packageName:n.packageName,version:n.version,type:n.type,platform:n.platform,schemas:n.schemas,examples:n.examples,...n.hints?{hints:n.hints}:{}}}function ut(e,t){const n=t?{...e,_hints:t}:e;return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}}function lt(e,t){let n,r,o,i;if(e instanceof Error){n=e.message;const t=e;t.code&&(o=t.code),Array.isArray(t.details)&&(i=t.details)}else if("string"==typeof e)n=e;else if(e&&"object"==typeof e&&"issues"in e&&Array.isArray(e.issues)){const t=e.issues;n=t.map(e=>e.message).join("; "),r=t[0]?.path?.join(".")||void 0}else n=e&&"object"==typeof e&&"message"in e?String(e.message):"Unknown error";const s={error:n};return t&&(s.hint=t),r&&(s.path=r),o&&(s.code=o),i&&(s.details=i),{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s,isError:!0}}function ft(e){let t=!1;return(n={})=>{t||(t=!0,e(n))}}function pt(e){if("*"===e)return()=>!0;if("and"in e){const t=e.and.map(pt);return e=>t.every(t=>t(e))}if("or"in e){const t=e.or.map(pt);return e=>t.some(t=>t(e))}return function(e){const{key:t,operator:n,value:r,not:o}=e,i=function(e,t){switch(e){case"eq":return e=>String(e??"")===t;case"contains":return e=>String(e??"").includes(t);case"prefix":return e=>String(e??"").startsWith(t);case"suffix":return e=>String(e??"").endsWith(t);case"regex":{const e=new RegExp(t);return t=>e.test(String(t??""))}case"gt":{const e=Number(t);return t=>Number(t)>e}case"lt":{const e=Number(t);return t=>Number(t)<e}case"exists":return e=>null!=e}}(n,r);return e=>{const n=ce(e,t),r=i(n);return o?!r:r}}(e)}function dt(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&"match"in e[0]}function gt(e){if(null!=e){if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;if(dt(e)){return{type:"routes",routes:e.map(e=>({match:pt(e.match),next:gt(e.next)}))}}return{type:"chain",value:e}}}}function mt(e,t={}){if(e){if("static"===e.type)return e.value;if("chain"===e.type)return e.value;for(const n of e.routes)if(n.match(t))return mt(n.next,t)}}function yt(e,t){const n={ingest:e??{}};return void 0!==t&&(n.event=t),n}function bt(e){return{full:e.full??!1,storeId:e.store,rules:e.rules.map(e=>({match:pt(e.match),key:e.key,ttl:e.ttl,update:e.update}))}}function ht(e,t,n,r){const o=e.rules.find(e=>e.match(n));if(!o)return null;const i=o.key.map(e=>String(ce(n,e)??""));if(i.every(e=>""===e))return null;const s=`${r}:${i.join(":")}`,a=t.get(s);return void 0!==a?{status:"HIT",key:s,value:a,rule:o}:{status:"MISS",key:s,rule:o}}function vt(e,t,n,r){e.set(t,n,1e3*r)}async function wt(e,t,n){if(!t)return e;let r=e;for(const[e,o]of Object.entries(t)){r=ue(r,e,await Te(n,o))}return r}//# sourceMappingURL=index.js.map