@walkeros/core 4.0.0-next-1777463920154 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -62,7 +62,7 @@ type ValueType = string | ValueConfig;
62
62
  interface ValueConfig {
63
63
  condition?: Condition;
64
64
  consent?: Consent;
65
- fn?: Fn$3;
65
+ fn?: Fn$4;
66
66
  key?: string;
67
67
  loop?: Loop;
68
68
  map?: Map;
@@ -70,18 +70,21 @@ interface ValueConfig {
70
70
  validate?: Validate;
71
71
  value?: PropertyType;
72
72
  }
73
- type Condition = (value: DeepPartialEvent | unknown, mapping?: Value, collector?: Instance$6) => PromiseOrValue<boolean>;
74
- type Fn$3 = (value: DeepPartialEvent | unknown, mapping: Value, options: Options$1) => PromiseOrValue<Property | unknown>;
73
+ interface Context$6 {
74
+ event: DeepPartialEvent;
75
+ /** The surrounding mapping config: a Value (value-level) or a Rule (rule-level). */
76
+ mapping: Value | Rule;
77
+ collector: Instance$6;
78
+ logger: Instance$4;
79
+ consent?: Consent;
80
+ }
81
+ type Fn$4 = (value: unknown, context: Context$6) => PromiseOrValue<Property | unknown>;
82
+ type Condition = (value: unknown, context: Context$6) => PromiseOrValue<boolean>;
83
+ type Validate = (value: unknown, context: Context$6) => PromiseOrValue<boolean>;
75
84
  type Loop = [Value, Value];
76
85
  type Map = {
77
86
  [key: string]: Value;
78
87
  };
79
- interface Options$1 {
80
- consent?: Consent;
81
- collector?: Instance$6;
82
- props?: unknown;
83
- }
84
- type Validate = (value?: unknown) => PromiseOrValue<boolean>;
85
88
 
86
89
  type mapping_Condition = Condition;
87
90
  type mapping_Loop = Loop;
@@ -94,7 +97,7 @@ type mapping_ValueConfig = ValueConfig;
94
97
  type mapping_ValueType = ValueType;
95
98
  type mapping_Values = Values;
96
99
  declare namespace mapping {
97
- export type { mapping_Condition as Condition, Config$7 as Config, Data$1 as Data, Fn$3 as Fn, mapping_Loop as Loop, mapping_Map as Map, Options$1 as Options, Policy$1 as Policy, Result$2 as Result, mapping_Rule as Rule, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
100
+ export type { mapping_Condition as Condition, Config$7 as Config, Context$6 as Context, Data$1 as Data, Fn$4 as Fn, mapping_Loop as Loop, mapping_Map as Map, Policy$1 as Policy, Result$2 as Result, mapping_Rule as Rule, mapping_Rules as Rules, mapping_Validate as Validate, mapping_Value as Value, mapping_ValueConfig as ValueConfig, mapping_ValueType as ValueType, mapping_Values as Values };
98
101
  }
99
102
 
100
103
  interface CacheRule {
@@ -277,7 +280,7 @@ interface CommandFn {
277
280
  (command: 'consent', consent: Consent): Promise<PushResult>;
278
281
  <T extends Types$4>(command: 'destination', destination: Init$3<T> | Instance$5<T>, config?: Config$5<T>): Promise<PushResult>;
279
282
  <K extends keyof Functions>(command: 'hook', name: K, hookFn: Functions[K]): Promise<PushResult>;
280
- (command: 'on', type: Types$3, rules: SingleOrArray<Options>): Promise<PushResult>;
283
+ (command: 'on', type: Types$3, rules: SingleOrArray<Subscription>): Promise<PushResult>;
281
284
  (command: 'user', user: User): Promise<PushResult>;
282
285
  (command: 'run', runState?: {
283
286
  consent?: Consent;
@@ -563,14 +566,14 @@ interface EventFn<R = Promise<PushResult>> {
563
566
  (event: string): R;
564
567
  (event: string, data: Properties): R;
565
568
  }
566
- interface Fn$2<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, WalkerCommands<R, Config> {
569
+ interface Fn$3<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, WalkerCommands<R, Config> {
567
570
  }
568
571
  interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
569
572
  (event: 'walker config', config: Partial<Config>): R;
570
573
  (event: 'walker consent', consent: Consent): R;
571
574
  <T extends Types$4>(event: 'walker destination', destination: Init$3<T> | Instance$5<T>, config?: Config$5<T>): R;
572
575
  <K extends keyof Functions>(event: 'walker hook', name: K, hookFn: Functions[K]): R;
573
- (event: 'walker on', type: Types$3, rules: SingleOrArray<Options>): R;
576
+ (event: 'walker on', type: Types$3, rules: SingleOrArray<Subscription>): R;
574
577
  (event: 'walker user', user: User): R;
575
578
  (event: 'walker run', runState: {
576
579
  consent?: Consent;
@@ -596,7 +599,7 @@ type elb_PushData<Config = unknown> = PushData<Config>;
596
599
  type elb_PushResult = PushResult;
597
600
  type elb_WalkerCommands<R = Promise<PushResult>, Config = unknown> = WalkerCommands<R, Config>;
598
601
  declare namespace elb {
599
- export type { Event$1 as Event, elb_EventFn as EventFn, Fn$2 as Fn, elb_Layer as Layer, elb_PushData as PushData, elb_PushResult as PushResult, elb_WalkerCommands as WalkerCommands };
602
+ export type { Event$1 as Event, elb_EventFn as EventFn, Fn$3 as Fn, elb_Layer as Layer, elb_PushData as PushData, elb_PushResult as PushResult, elb_WalkerCommands as WalkerCommands };
600
603
  }
601
604
 
602
605
  /**
@@ -1299,83 +1302,95 @@ declare namespace logger {
1299
1302
  export { type Config$4 as Config, type logger_DefaultHandler as DefaultHandler, type logger_ErrorContext as ErrorContext, type logger_Factory as Factory, type logger_Handler as Handler, type Instance$4 as Instance, type logger_InternalConfig as InternalConfig, logger_Level as Level, type logger_LogContext as LogContext, type logger_LogFn as LogFn, type logger_ThrowFn as ThrowFn };
1300
1303
  }
1301
1304
 
1305
+ /** Collector state mapping for the `on` actions. */
1302
1306
  type Config$3 = {
1303
- config?: Array<GenericConfig>;
1304
- consent?: Array<ConsentConfig>;
1305
- custom?: Array<GenericConfig>;
1306
- globals?: Array<GenericConfig>;
1307
- ready?: Array<ReadyConfig>;
1308
- run?: Array<RunConfig>;
1309
- session?: Array<SessionConfig>;
1310
- user?: Array<UserConfig>;
1307
+ config?: Array<GenericFn>;
1308
+ consent?: Array<ConsentRule>;
1309
+ custom?: Array<GenericFn>;
1310
+ globals?: Array<GenericFn>;
1311
+ ready?: Array<ReadyFn>;
1312
+ run?: Array<RunFn>;
1313
+ session?: Array<SessionFn>;
1314
+ user?: Array<UserFn>;
1311
1315
  };
1316
+ /** Allow arbitrary string events via `(string & {})`. */
1312
1317
  type Types$3 = keyof Config$3 | (string & {});
1313
- interface EventContextMap {
1318
+ /** Map each event type to its expected data payload type. */
1319
+ interface EventDataMap {
1314
1320
  config: Partial<Config$6>;
1315
1321
  consent: Consent;
1316
1322
  custom: Properties;
1317
1323
  globals: Properties;
1318
- ready: undefined;
1319
- run: undefined;
1320
- session: SessionData;
1324
+ ready: void;
1325
+ run: void;
1326
+ session: SessionData | undefined;
1321
1327
  user: User;
1322
1328
  }
1323
- type EventContext<T extends keyof EventContextMap> = EventContextMap[T];
1324
- type AnyEventContext = EventContextMap[keyof EventContextMap];
1329
+ /** Extract the data type for a specific event. */
1330
+ type EventData<T extends keyof EventDataMap> = EventDataMap[T];
1331
+ /** Union of all possible data types. */
1332
+ type AnyEventData = EventDataMap[keyof EventDataMap];
1333
+ /**
1334
+ * Context provided to every `on` callback.
1335
+ * Same posture as Mapping.Context: collector + logger only;
1336
+ * subscriptions are a collector-level concern, not a stage-level one.
1337
+ */
1325
1338
  interface Context$4 {
1326
- consent?: Consent;
1327
- session?: unknown;
1339
+ collector: Instance$6;
1340
+ logger: Instance$4;
1328
1341
  }
1329
- type Options = ConsentConfig | GenericConfig | ReadyConfig | RunConfig | SessionConfig | UserConfig;
1330
- interface ConsentConfig {
1342
+ /** Unified subscription callback shape. */
1343
+ type Fn$2<TData = unknown> = (data: TData, context: Context$4) => PromiseOrValue<void>;
1344
+ /** Typed-data variants for readability and IntelliSense. All reduce to Fn<TData>. */
1345
+ type ConsentFn = Fn$2<Consent>;
1346
+ type GenericFn = Fn$2<unknown>;
1347
+ type ReadyFn = Fn$2<void>;
1348
+ type RunFn = Fn$2<void>;
1349
+ type SessionFn = Fn$2<SessionData | undefined>;
1350
+ type UserFn = Fn$2<User>;
1351
+ /**
1352
+ * Consent rule: a record of `{ [consentKey]: ConsentFn }`.
1353
+ * Only the consent action uses this shape (per-key handler dispatch).
1354
+ */
1355
+ interface ConsentRule {
1331
1356
  [key: string]: ConsentFn;
1332
1357
  }
1333
- type ConsentFn = (collector: Instance$6, consent: Consent) => void;
1334
- type GenericConfig = GenericFn;
1335
- type GenericFn = (collector: Instance$6, data: unknown) => void;
1336
- type ReadyConfig = ReadyFn;
1337
- type ReadyFn = (collector: Instance$6) => void;
1338
- type RunConfig = RunFn;
1339
- type RunFn = (collector: Instance$6) => void;
1340
- type SessionConfig = SessionFn;
1341
- type SessionFn = (collector: Instance$6, session?: unknown) => void;
1342
- type UserConfig = UserFn;
1343
- type UserFn = (collector: Instance$6, user: User) => void;
1358
+ /** Anything registerable via `walker.on(action, X)`: a typed callback or a consent rule record. */
1359
+ type Subscription = ConsentRule | GenericFn | ReadyFn | RunFn | SessionFn | UserFn;
1344
1360
  interface OnConfig {
1345
- config?: GenericConfig[];
1346
- consent?: ConsentConfig[];
1347
- custom?: GenericConfig[];
1348
- globals?: GenericConfig[];
1349
- ready?: ReadyConfig[];
1350
- run?: RunConfig[];
1351
- session?: SessionConfig[];
1352
- user?: UserConfig[];
1353
- [key: string]: ConsentConfig[] | GenericConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | UserConfig[] | undefined;
1361
+ config?: GenericFn[];
1362
+ consent?: ConsentRule[];
1363
+ custom?: GenericFn[];
1364
+ globals?: GenericFn[];
1365
+ ready?: ReadyFn[];
1366
+ run?: RunFn[];
1367
+ session?: SessionFn[];
1368
+ user?: UserFn[];
1369
+ [key: string]: ConsentRule[] | GenericFn[] | ReadyFn[] | RunFn[] | SessionFn[] | UserFn[] | undefined;
1354
1370
  }
1371
+ /**
1372
+ * Destination `on` handler: receives the action type and a destination context.
1373
+ * Already context-style; kept for compatibility with the destination interface.
1374
+ */
1355
1375
  type OnFn<T extends TypesGeneric$3 = Types$4> = (type: Types$3, context: Context$5<T>) => PromiseOrValue<void>;
1356
1376
  type OnFnRuntime = (type: Types$3, context: Context$5) => PromiseOrValue<void>;
1357
1377
 
1358
- type on_AnyEventContext = AnyEventContext;
1359
- type on_ConsentConfig = ConsentConfig;
1378
+ type on_AnyEventData = AnyEventData;
1360
1379
  type on_ConsentFn = ConsentFn;
1361
- type on_EventContext<T extends keyof EventContextMap> = EventContext<T>;
1362
- type on_EventContextMap = EventContextMap;
1363
- type on_GenericConfig = GenericConfig;
1380
+ type on_ConsentRule = ConsentRule;
1381
+ type on_EventData<T extends keyof EventDataMap> = EventData<T>;
1382
+ type on_EventDataMap = EventDataMap;
1364
1383
  type on_GenericFn = GenericFn;
1365
1384
  type on_OnConfig = OnConfig;
1366
1385
  type on_OnFn<T extends TypesGeneric$3 = Types$4> = OnFn<T>;
1367
1386
  type on_OnFnRuntime = OnFnRuntime;
1368
- type on_Options = Options;
1369
- type on_ReadyConfig = ReadyConfig;
1370
1387
  type on_ReadyFn = ReadyFn;
1371
- type on_RunConfig = RunConfig;
1372
1388
  type on_RunFn = RunFn;
1373
- type on_SessionConfig = SessionConfig;
1374
1389
  type on_SessionFn = SessionFn;
1375
- type on_UserConfig = UserConfig;
1390
+ type on_Subscription = Subscription;
1376
1391
  type on_UserFn = UserFn;
1377
1392
  declare namespace on {
1378
- export type { on_AnyEventContext as AnyEventContext, Config$3 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, Context$4 as Context, on_EventContext as EventContext, on_EventContextMap as EventContextMap, on_GenericConfig as GenericConfig, on_GenericFn as GenericFn, on_OnConfig as OnConfig, on_OnFn as OnFn, on_OnFnRuntime as OnFnRuntime, on_Options as Options, on_ReadyConfig as ReadyConfig, on_ReadyFn as ReadyFn, on_RunConfig as RunConfig, on_RunFn as RunFn, on_SessionConfig as SessionConfig, on_SessionFn as SessionFn, Types$3 as Types, on_UserConfig as UserConfig, on_UserFn as UserFn };
1393
+ export type { on_AnyEventData as AnyEventData, Config$3 as Config, on_ConsentFn as ConsentFn, on_ConsentRule as ConsentRule, Context$4 as Context, on_EventData as EventData, on_EventDataMap as EventDataMap, Fn$2 as Fn, on_GenericFn as GenericFn, on_OnConfig as OnConfig, on_OnFn as OnFn, on_OnFnRuntime as OnFnRuntime, on_ReadyFn as ReadyFn, on_RunFn as RunFn, on_SessionFn as SessionFn, on_Subscription as Subscription, Types$3 as Types, on_UserFn as UserFn };
1379
1394
  }
1380
1395
 
1381
1396
  interface NextRule {
@@ -1575,7 +1590,7 @@ interface BaseEnv$1 {
1575
1590
  push: PushFn$1;
1576
1591
  command: CommandFn;
1577
1592
  sources?: Sources;
1578
- elb: Fn$2;
1593
+ elb: Fn$3;
1579
1594
  logger: Instance$4;
1580
1595
  }
1581
1596
  /**
@@ -1588,7 +1603,7 @@ interface BaseEnv$1 {
1588
1603
  * @template E - Environment dependencies type
1589
1604
  * @template I - InitSettings configuration type (user input)
1590
1605
  */
1591
- interface Types$1<S = unknown, M = unknown, P = Fn$2, E = BaseEnv$1, I = S> {
1606
+ interface Types$1<S = unknown, M = unknown, P = Fn$3, E = BaseEnv$1, I = S> {
1592
1607
  settings: S;
1593
1608
  initSettings: I;
1594
1609
  mapping: M;
@@ -1794,7 +1809,7 @@ interface FlowHandle {
1794
1809
  /** The collector instance created by startFlow. */
1795
1810
  collector: Instance$6;
1796
1811
  /** The elb push function for direct event injection. */
1797
- elb: Fn$2;
1812
+ elb: Fn$3;
1798
1813
  }
1799
1814
  /** What createTrigger returns — a flow handle (lazy) and a trigger function. */
1800
1815
  interface Instance<TContent = unknown, TResult = unknown> {
@@ -1862,7 +1877,7 @@ declare namespace trigger {
1862
1877
  }
1863
1878
 
1864
1879
  type AnyObject<T = unknown> = Record<string, T>;
1865
- type Elb = Fn$2;
1880
+ type Elb = Fn$3;
1866
1881
  type AnyFunction = (...args: unknown[]) => unknown;
1867
1882
  type SingleOrArray<T> = T | Array<T>;
1868
1883
  type Events = Array<Event>;
@@ -2492,9 +2507,10 @@ declare function createLogger(config?: Config$4): Instance$4;
2492
2507
  *
2493
2508
  * @param event The event to get the mapping for (can be partial or full).
2494
2509
  * @param mapping The mapping rules.
2510
+ * @param collector Required to evaluate rule-level conditions against the unified Context. Legacy callers may omit; rule-level conditions then run with `undefined as never` (defensive).
2495
2511
  * @returns The mapping result.
2496
2512
  */
2497
- declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event, mapping?: Rules): Promise<Result$2>;
2513
+ declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event, mapping?: Rules, collector?: Instance$6): Promise<Result$2>;
2498
2514
  /**
2499
2515
  * Gets a value from a mapping.
2500
2516
  *
@@ -2503,7 +2519,7 @@ declare function getMappingEvent(event: DeepPartialEvent | PartialEvent | Event,
2503
2519
  * @param options The mapping options.
2504
2520
  * @returns The mapped value.
2505
2521
  */
2506
- declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data?: Data$1, options?: Options$1): Promise<Property | undefined>;
2522
+ declare function getMappingValue(value: DeepPartialEvent | unknown | undefined, data?: Data$1, context?: Partial<Context$6>): Promise<Property | undefined>;
2507
2523
  /**
2508
2524
  * Processes an event through mapping configuration.
2509
2525
  *
@@ -2821,82 +2837,52 @@ declare function getDeviceType(userAgent: string): string | undefined;
2821
2837
  /**
2822
2838
  * Inline Code Wrapping Utilities
2823
2839
  *
2824
- * Converts inline code strings to executable functions.
2825
- * Used for mapping properties: condition, fn, validate.
2840
+ * Converts inline code strings to executable functions for the three mapping
2841
+ * callbacks: condition, fn, validate. All three share a single signature:
2842
+ *
2843
+ * (value, context) => result
2844
+ *
2845
+ * Inside the inline body, the available bindings are:
2846
+ * - value: unknown - the value being mapped/validated/checked
2847
+ * - context: Mapping.Context with these fields:
2848
+ * event: WalkerOS.DeepPartialEvent
2849
+ * mapping: Mapping.Value | Mapping.Rule
2850
+ * collector: Collector.Instance
2851
+ * logger: Logger.Instance
2852
+ * consent?: WalkerOS.Consent
2853
+ *
2854
+ * If the body has no explicit `return`, it is auto-wrapped with `return`.
2826
2855
  *
2827
2856
  * @packageDocumentation
2828
2857
  */
2829
2858
 
2830
2859
  /**
2831
- * Wrap inline code string as Condition function.
2832
- *
2833
- * @param code - Inline code string
2834
- * @returns Condition function matching Mapping.Condition signature
2835
- *
2836
- * @remarks
2837
- * Available parameters in code:
2838
- * - `value` - The event or partial event being processed
2839
- * - `mapping` - Current mapping configuration
2840
- * - `collector` - Collector instance
2841
- *
2842
- * If code has no explicit return, it's auto-wrapped with `return`.
2860
+ * Wrap inline code as a Mapping.Condition.
2843
2861
  *
2844
2862
  * @example
2845
- * ```typescript
2846
- * // One-liner (auto-wrapped)
2847
- * const fn = wrapCondition('value.data.total > 100');
2848
- * fn(event, mapping, collector); // returns boolean
2849
- *
2850
- * // Multi-statement (explicit return)
2851
- * const fn = wrapCondition('const threshold = 100; return value.data.total > threshold');
2863
+ * ```ts
2864
+ * const c = wrapCondition('context.consent?.marketing === true');
2865
+ * c(value, context); // boolean
2852
2866
  * ```
2853
2867
  */
2854
2868
  declare function wrapCondition(code: string): Condition;
2855
2869
  /**
2856
- * Wrap inline code string as Fn function.
2857
- *
2858
- * @param code - Inline code string
2859
- * @returns Fn function matching Mapping.Fn signature
2860
- *
2861
- * @remarks
2862
- * Available parameters in code:
2863
- * - `value` - The event or partial event being processed
2864
- * - `mapping` - Current mapping configuration
2865
- * - `options` - Options object with consent and collector
2866
- *
2867
- * If code has no explicit return, it's auto-wrapped with `return`.
2870
+ * Wrap inline code as a Mapping.Fn.
2868
2871
  *
2869
2872
  * @example
2870
- * ```typescript
2871
- * // One-liner (auto-wrapped)
2873
+ * ```ts
2872
2874
  * const fn = wrapFn('value.user.email.split("@")[1]');
2873
- * fn(event, mapping, options); // returns domain
2874
- *
2875
- * // Multi-statement (explicit return)
2876
- * const fn = wrapFn('const parts = value.user.email.split("@"); return parts[1].toUpperCase()');
2875
+ * fn(value, context); // domain
2877
2876
  * ```
2878
2877
  */
2879
- declare function wrapFn(code: string): Fn$3;
2878
+ declare function wrapFn(code: string): Fn$4;
2880
2879
  /**
2881
- * Wrap inline code string as Validate function.
2882
- *
2883
- * @param code - Inline code string
2884
- * @returns Validate function matching Mapping.Validate signature
2885
- *
2886
- * @remarks
2887
- * Available parameters in code:
2888
- * - `value` - The current value being validated
2889
- *
2890
- * If code has no explicit return, it's auto-wrapped with `return`.
2880
+ * Wrap inline code as a Mapping.Validate.
2891
2881
  *
2892
2882
  * @example
2893
- * ```typescript
2894
- * // One-liner (auto-wrapped)
2895
- * const fn = wrapValidate('value && value.length > 0');
2896
- * fn('hello'); // returns true
2897
- *
2898
- * // Multi-statement (explicit return)
2899
- * const fn = wrapValidate('if (!value) return false; return value.length > 0');
2883
+ * ```ts
2884
+ * const v = wrapValidate('typeof value === "string" && value.length > 0');
2885
+ * v(value, context); // boolean
2900
2886
  * ```
2901
2887
  */
2902
2888
  declare function wrapValidate(code: string): Validate;
@@ -3030,7 +3016,7 @@ declare function buildCacheContext(ingest?: unknown, event?: unknown): Record<st
3030
3016
  declare function compileCache(cache: Cache): CompiledCache;
3031
3017
  declare function checkCache(compiled: CompiledCache, store: Instance$1, context: Record<string, unknown>, namespace: string): CacheResult | null;
3032
3018
  declare function storeCache(store: Instance$1, key: string, value: unknown, ttlSeconds: number): void;
3033
- declare function applyUpdate(value: unknown, update: Record<string, unknown> | undefined, context: Record<string, unknown>): Promise<unknown>;
3019
+ declare function applyUpdate(value: unknown, update: Record<string, unknown> | undefined, context: Record<string, unknown>, collector: Instance$6): Promise<unknown>;
3034
3020
 
3035
3021
  type StepOut = Flow.StepOut;
3036
3022
  /**
@@ -3064,8 +3050,10 @@ declare const REF_VAR: RegExp;
3064
3050
  declare const REF_DEF: RegExp;
3065
3051
  declare const REF_ENV: RegExp;
3066
3052
  declare const REF_CONTRACT: RegExp;
3053
+ /** Whole-string `$flow.<name>(.<path>)?`: cross-flow value reference. */
3054
+ declare const REF_FLOW: RegExp;
3067
3055
  declare const REF_STORE: RegExp;
3068
3056
  declare const REF_SECRET: RegExp;
3069
3057
  declare const REF_CODE_PREFIX = "$code:";
3070
3058
 
3071
- 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, type FlowConfigResolver, 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, REF_CODE_PREFIX, REF_CONTRACT, REF_DEF, REF_ENV, REF_SECRET, REF_STORE, REF_VAR, 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, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, getSpanId, 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 };
3059
+ 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, type FlowConfigResolver, 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, REF_CODE_PREFIX, REF_CONTRACT, REF_DEF, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR, 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, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, getSpanId, 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,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},s={};i(s,{Cache:()=>a,Collector:()=>c,Const:()=>A,Context:()=>l,Destination:()=>f,ENV_MARKER_PREFIX:()=>q,Elb:()=>u,Hint:()=>S,Hooks:()=>p,Level:()=>m,Lifecycle:()=>k,Logger:()=>d,Mapping:()=>g,Matcher:()=>O,On:()=>y,REF_CODE_PREFIX:()=>L,REF_CONTRACT:()=>V,REF_DEF:()=>D,REF_ENV:()=>H,REF_SECRET:()=>Z,REF_STORE:()=>W,REF_VAR:()=>z,Request:()=>h,Simulation:()=>x,Source:()=>v,Store:()=>w,Transformer:()=>b,Trigger:()=>j,WalkerOS:()=>$,anonymizeIP:()=>C,applyUpdate:()=>_t,assign:()=>oe,branch:()=>_,buildCacheContext:()=>Ot,castToProperty:()=>De,castValue:()=>we,checkCache:()=>At,clone:()=>ge,compileCache:()=>St,compileMatcher:()=>jt,compileNext:()=>$t,createDestination:()=>ke,createEvent:()=>Oe,createIngest:()=>E,createLogger:()=>Me,createMockContext:()=>Je,createMockLogger:()=>qe,createRespond:()=>wt,debounce:()=>Ce,deepMerge:()=>$e,defaultClickIds:()=>Ee,fetchPackage:()=>gt,fetchPackageSchema:()=>bt,filterValues:()=>ze,flattenIncludeSections:()=>ve,formatOut:()=>Ct,getBrowser:()=>ot,getBrowserVersion:()=>rt,getByPath:()=>ye,getDeviceType:()=>at,getEvent:()=>Se,getFlowSettings:()=>ee,getGrantedConsent:()=>je,getHeaders:()=>Ye,getId:()=>Ae,getMappingEvent:()=>Ue,getMappingValue:()=>We,getMarketingParameters:()=>_e,getOS:()=>it,getOSVersion:()=>st,getPlatform:()=>te,getSpanId:()=>xe,isArguments:()=>re,isArray:()=>ie,isBoolean:()=>se,isCommand:()=>ae,isDefined:()=>ce,isElementOrDocument:()=>le,isFunction:()=>fe,isNumber:()=>ue,isObject:()=>pe,isPropertyType:()=>Ie,isRouteArray:()=>kt,isSameType:()=>de,isString:()=>me,mcpError:()=>vt,mcpResult:()=>ht,mergeContractSchemas:()=>M,mockEnv:()=>Be,packageNameToVariable:()=>Q,parseUserAgent:()=>nt,processEventMapping:()=>Le,requestToData:()=>Xe,requestToParameter:()=>Ge,resolveContracts:()=>T,resolveNext:()=>xt,setByPath:()=>be,storeCache:()=>Et,throttle:()=>Ne,throwError:()=>N,transformData:()=>Qe,traverseEnv:()=>Ke,trim:()=>et,tryCatch:()=>He,tryCatchAsync:()=>Ve,useHooks:()=>tt,walkPath:()=>X,wrapCondition:()=>lt,wrapFn:()=>ft,wrapValidate:()=>ut}),module.exports=(e=s,((e,i,s,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of o(i))r.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={},l={},f={},u={},p={},d={};i(d,{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||{}),g={},y={},b={},h={},v={},w={},j={},k={},$={},x={},O={},S={},A={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function E(e){return{_meta:{hops:0,path:[e]}}}function _(e,t){return{event:e,next:t}}function C(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function N(e){throw new Error(String(e))}var P=["globals","context","custom","user","consent"],R=new Set(["description","examples","title","$comment"]);function T(e){const t={},n=new Set;function o(r){if(t[r])return t[r];n.has(r)&&N(`Circular extends chain detected: ${[...n,r].join(" → ")}`);const i=e[r];i||N(`Contract "${r}" not found`),n.add(r);let s={};if(i.extends){s=function(e,t){const n={};void 0===e.description&&void 0===t.description||(n.description=t.description??e.description);for(const o of P){const r=e[o],i=t[o];r&&i?n[o]=M(r,i):(r||i)&&(n[o]={...r||i})}if(e.events||t.events){const o={},r=new Set([...Object.keys(e.events||{}),...Object.keys(t.events||{})]);for(const n of r){const r=e.events?.[n]||{},i=t.events?.[n]||{},s=new Set([...Object.keys(r),...Object.keys(i)]);o[n]={};for(const e of s){const t=r[e],s=i[e];o[n][e]=t&&s?M(t,s):{...t||s}}}n.events=o}return n}(o(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 o of Object.keys(e[n]||{})){let r={};const i=e["*"]?.["*"];i&&(r=M(r,i));const s=e["*"]?.[o];s&&"*"!==o&&(r=M(r,s));const a=e[n]?.["*"];a&&"*"!==o&&(r=M(r,a));const c=e[n]?.[o];c&&(r=M(r,c)),t[n][o]=r}}e["*"]&&(t["*"]={...e["*"]});return t}(s.events)),s.events){const e={};for(const[t,n]of Object.entries(s.events)){e[t]={};for(const[o,r]of Object.entries(n))e[t][o]=F(r)}s.events=e}return n.delete(r),t[r]=s,s}for(const t of Object.keys(e))o(t);return t}function M(e,t){const n={...e};for(const o of Object.keys(t)){const r=e[o],i=t[o];"required"===o&&Array.isArray(r)&&Array.isArray(i)?n[o]=[...new Set([...r,...i])]:I(r)&&I(i)?n[o]=M(r,i):n[o]=i}return n}function F(e){const t={};for(const[n,o]of Object.entries(e))R.has(n)||(null===o||"object"!=typeof o||Array.isArray(o)?t[n]=o:t[n]=F(o));return t}function I(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var z=/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,D=/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,H=/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,V=/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,U=/^\$flow\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z0-9_.]+))?$/,W=/^\$store\.([a-zA-Z_][a-zA-Z0-9_]*)$/,Z=/^\$secret\.([A-Z0-9_]+)$/,L="$code:";function B(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function K(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}var q="__WALKEROS_ENV:";function J(e,t,n){const o=`$flow.${e}${t?`.${t}`:""}`;if("unknown-flow"===n)return`${o} cannot resolve: flow "${e}" does not exist in this config.`;return`${o} is empty. Set ${t?`flows.${e}.config.${t}`:`flows.${e}.config`}, or run \`walkeros deploy ${e}\` first.`}function X(e,t,n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const i=o[e];if(null==r||"object"!=typeof r){const r=o.slice(0,e).join(".");N(`Path "${t}" not found in "${n}": "${i}" does not exist${r?` in "${r}"`:""}`)}const s=r;if(!(i in s)){const r=o.slice(0,e).join(".");N(`Path "${t}" not found in "${n}": "${i}" does not exist${r?` in "${r}"`:""}`)}r=s[i]}return r}function G(e,t,n,o,r,i){if("string"==typeof e){const s=e.match(D);if(s){const e=s[1],a=s[2];void 0===n[e]&&N(`Definition "${e}" not found`);let c=G(n[e],t,n,o,r,i);return a&&(c=X(c,a,`$def.${e}`)),c}const a=e.match(V);if(a&&r){const e=a[1],t=a[2];e in r||N(`Contract "${e}" not found`);let n=r[e];return t&&(n=X(n,t,`$contract.${e}`)),n}const c=e.match(U);if(c){const t=c[1],n=c[2],r=!1===o?.strictFlowRefs;i||N(`$flow.${t}${n?`.${n}`:""} cannot be resolved without a flow resolver`);const s=i(t);if(!s){if(r)return o?.onWarning?.(J(t,n,"unknown-flow")),e;N(`Flow "${t}" not found in $flow.${t}`)}let a=s;if(n)if(r){try{a=X(a,n,`$flow.${t}`)}catch{return o?.onWarning?.(J(t,n,"missing-key")),e}if(null==a||""===a)return o?.onWarning?.(J(t,n,"missing-key")),e}else a=X(a,n,`$flow.${t}`);return a}let l=e.replace(z,(e,n)=>{if(void 0!==t[n])return String(t[n]);N(`Variable "${n}" not found`)});return l=l.replace(H,(e,t,n)=>o?.deferred?void 0!==n?`${q}${t}:${n}`:`${q}${t}`:"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==n?n:void N(`Environment variable "${t}" not found and no default provided`)),l}if(Array.isArray(e))return e.map(e=>G(e,t,n,o,r,i));if(null!==e&&"object"==typeof e){const s={};for(const[a,c]of Object.entries(e))s[a]=G(c,t,n,o,r,i);return s}return e}function Q(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 Y(e,t,n){if(t)return t;if(!e||!n)return;return n[e]?Q(e):void 0}function ee(e,t,n){const o=new Map,r=new Set,i=[],s=t=>{if(o.has(t))return o.get(t);const a=e.flows[t];if(a){if(r.has(t)){N(`Cyclic $flow reference: ${[...i,t].join(" -> ")}`)}r.add(t),i.push(t);try{const r=B(e.variables,a.variables),i=K(e.definitions,a.definitions),c=G(a.config??{},r,i,n,void 0,s);return o.set(t,c),c}finally{r.delete(t),i.pop()}}},a=Object.keys(e.flows);t||(1===a.length?t=a[0]:N(`Multiple flows found (${a.join(", ")}). Please specify a flow.`));const c=e.flows[t];c||N(`Flow "${t}" not found. Available: ${a.join(", ")}`),r.add(t),i.push(t);try{return function(e,t,n,o){const r=JSON.parse(JSON.stringify(t));let i;if(e.contract){const r=B(e.variables,t.variables),s=K(e.definitions,t.definitions);i=T(G(e.contract,r,s,n,void 0,o))}if(r.config){const s=B(e.variables,t.variables),a=K(e.definitions,t.definitions);r.config=G(r.config,s,a,n,i,o)}if(r.sources)for(const[s,a]of Object.entries(r.sources)){const c=B(e.variables,t.variables,a.variables),l=K(e.definitions,t.definitions,a.definitions),f=G(a.config,c,l,n,i,o),u=G(a.env,c,l,n,i,o),p=Y(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.sources[s]={package:a.package,config:f,env:u,primary:a.primary,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.destinations)for(const[s,a]of Object.entries(r.destinations)){const c=B(e.variables,t.variables,a.variables),l=K(e.definitions,t.definitions,a.definitions),f=G(a.config,c,l,n,i,o),u=G(a.env,c,l,n,i,o),p=Y(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.destinations[s]={package:a.package,config:f,env:u,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.stores)for(const[s,a]of Object.entries(r.stores)){const c=B(e.variables,t.variables,a.variables),l=K(e.definitions,t.definitions,a.definitions),f=G(a.config,c,l,n,i,o),u=G(a.env,c,l,n,i,o),p=Y(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.stores[s]={package:a.package,config:f,env:u,variables:a.variables,definitions:a.definitions,code:m}}if(r.transformers)for(const[s,a]of Object.entries(r.transformers)){const c=B(e.variables,t.variables,a.variables),l=K(e.definitions,t.definitions,a.definitions),f=G(a.config,c,l,n,i,o),u=G(a.env,c,l,n,i,o),p=Y(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.transformers[s]={package:a.package,config:f,env:u,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.collector){const s=B(e.variables,t.variables),a=K(e.definitions,t.definitions),c=G(r.collector,s,a,n,i,o);r.collector=c}return r}(e,c,n,s)}finally{r.delete(t),i.pop()}}function te(e){const t=e.config?.platform;if("web"===t||"server"===t)return t;N('Flow must have config.platform set to "web" or "server"')}var ne={merge:!0,shallow:!0,extend:!0};function oe(e,t={},n={}){n={...ne,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function re(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function ie(e){return Array.isArray(e)}function se(e){return"boolean"==typeof e}function ae(e){return"walker"===e}function ce(e){return void 0!==e}function le(e){return!(!e||"object"!=typeof e)&&("body"in e||"tagName"in e)}function fe(e){return"function"==typeof e}function ue(e){return"number"==typeof e&&!Number.isNaN(e)}function pe(e){return"object"==typeof e&&null!==e&&!ie(e)&&"[object Object]"===Object.prototype.toString.call(e)}function de(e,t){return typeof e==typeof t}function me(e){return"string"==typeof e}function ge(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 o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=ge(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(ge(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 ye(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&ie(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=ye(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,void 0===r)break}return ce(r)?r:n}function be(e,t,n){if(!pe(e))return e;const o=ge(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}var he={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,timing:e.timing})};function ve(e,t){const n={},o=t.includes("all")?Object.keys(he):t;for(const t of o){const o=he[t];if(!o)continue;const r=o(e);if(pe(r))for(const[e,o]of Object.entries(r)){if(void 0===o)continue;const r="context"===t&&Array.isArray(o)?o[0]:o;n[`${t}_${e}`]=r}}return n}function we(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function je(e,t={},n={}){const o={...t,...n},r={};let i=!e||0===Object.keys(e).length;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function ke(e,t){const n={...e};return n.config=oe(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=oe(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=oe(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function $e(e,t){if(!pe(t))return e;for(const n of Object.keys(t)){const o=t[n];void 0!==o&&(pe(o)&&pe(e[n])?$e(e[n],o):e[n]=o)}return e}function xe(){let e="";for(let t=0;t<16;t++)e+=(16*Math.random()|0).toString(16);return e}function Oe(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=oe({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"}}],consent:{functional:!0},id:e.id||xe(),trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,source:{type:"collector",schema:"4"}},e,{merge:!1});if(e.name){const[t,o]=e.name.split(" ")??[];t&&o&&(n.entity=t,n.action=o)}return n}function Se(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},r={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return Oe({...{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...o.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+r.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...r,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",...o,context:{shopping:["complete",0]},nested:[]},{entity:"product",...r,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":{...o,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...o,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...o.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 Ae(e=6,t){if(t){const n=t.length;let o="";for(let r=0;r<e;r++)o+=t[Math.random()*n|0];return o}let n="";for(let t=36;n.length<e;)n+=(Math.random()*t|0).toString(t);return n}var Ee=[{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 _e(e,t={},n=[]){const o={};Object.entries(oe({utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term"},t)).forEach(([t,n])=>{const r=e.searchParams.get(t);r&&(o[n]=r)});const r=n.length?function(e){const t=new Map(e.map(e=>[e.param,e.platform])),n=new Set(Ee.map(e=>e.param));return[...Ee.map(e=>t.has(e.param)?{param:e.param,platform:t.get(e.param)}:e),...e.filter(e=>!n.has(e.param))]}(n):Ee,i=new Map;e.searchParams.forEach((e,t)=>{e&&i.set(t.toLowerCase(),e)});for(const e of r){const t=i.get(e.param);t&&(o[e.param]=t,o.clickId||(o.clickId=e.param,o.platform=e.platform))}return o}function Ce(e,t=1e3,n=!1){let o,r=null,i=!1;return(...s)=>new Promise(a=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...s),a(o))},t),c&&(i=!0,o=e(...s),a(o))})}function Ne(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}function Pe(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function Re(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=Pe(e)):n=e,void 0!==t&&(t instanceof Error?o.error=Pe(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=Pe(o.error))):o.value=t),{message:n,context:o}}var Te=(e,t,n,o)=>{const r=`${m[e]}${o.length>0?` [${o.join(":")}]`:""}`,i=Object.keys(n).length>0,s=0===e?console.error:1===e?console.warn:console.log;i?s(r,t,n):s(r,t)};function Me(e={}){return Fe({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 Fe(e){const{level:t,handler:n,jsonHandler:o,scope:r}=e,i=(e,o,i)=>{if(e<=t){const t=Re(o,i);n?n(e,t.message,t.context,r,Te):Te(e,t.message,t.context,r)}};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 o=Re(e,t);throw n?n(0,o.message,o.context,r,Te):Te(0,o.message,o.context,r),new Error(o.message)},json:e=>{o?o(e):console.log(JSON.stringify(e,null,2))},scope:e=>Fe({level:t,handler:n,jsonHandler:o,scope:[...r,e]})}}function Ie(e){return se(e)||me(e)||ue(e)||!ce(e)||ie(e)&&e.every(Ie)||pe(e)&&Object.values(e).every(Ie)}function ze(e){return se(e)||me(e)||ue(e)?e:re(e)?ze(Array.from(e)):ie(e)?e.map(e=>ze(e)).filter(e=>void 0!==e):pe(e)?Object.entries(e).reduce((e,[t,n])=>{const o=ze(n);return void 0!==o&&(e[t]=o),e},{}):void 0}function De(e){return Ie(e)?e:void 0}function He(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function Ve(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function Ue(e,t){const[n,o]=(e.name||"").split(" ");if(!t||!n||!o)return{};let r,i="",s=n,a=o;const c=t=>{if(t)return(t=ie(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const l=t[s];return l&&(l[a]||(a="*"),r=c(l[a])),r||(s="*",a="*",r=c(t[s]?.[a])),r&&(i=`${s} ${a}`),{eventMapping:r,mappingKey:i}}async function We(e,t={},n={}){if(!ce(e))return;const o=pe(e)&&e.consent||n.consent||n.collector?.consent,r=ie(t)?t:[t];for(const t of r){const r=await Ve(Ze)(e,t,{...n,consent:o});if(ce(r))return r}}async function Ze(e,t,n={}){const{collector:o,consent:r}=n;return(ie(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const a=me(i)?{key:i}:i;if(!Object.keys(a).length)return;const{condition:c,consent:l,fn:f,key:u,loop:p,map:d,set:m,validate:g,value:y}=a;if(c&&!await Ve(c)(e,i,o))return;if(l&&!je(l,r))return y;let b=ce(y)?y:e;if(f&&(b=await Ve(f)(e,i,n)),u&&(b=ye(e,u,y)),p){const[t,o]=p,r="this"===t?[e]:await We(e,t,n);ie(r)&&(b=(await Promise.all(r.map(e=>We(e,o,n)))).filter(ce))}else d?b=await Object.entries(d).reduce(async(t,[o,r])=>{const i=await t,s=await We(e,r,n);return ce(s)&&(i[o]=s),i},Promise.resolve({})):m&&(b=await Promise.all(m.map(t=>Ze(e,t,n))));g&&!await Ve(g)(b)&&(b=void 0);const h=De(b);return ce(h)?h:De(y)},Promise.resolve(void 0))}async function Le(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await We(e,o,{collector:n});e=be(e,t,r)}));const{eventMapping:o,mappingKey:r}=await Ue(e,t.mapping);o?.policy&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await We(e,o,{collector:n});e=be(e,t,r)}));let i=t.data&&await We(e,t.data,{collector:n});const s=Boolean(o?.silent);if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0,silent:s};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await We(e,o.data,{collector:n});i=pe(i)&&pe(t)?oe(i,t):t}}const a=o?.include??t.include;if(a&&a.length>0){const t=ve(e,a);Object.keys(t).length>0&&(i=pe(i)?oe(t,i):i??t)}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1,silent:s}}function Be(e,t){const n=(e,o=[])=>new Proxy(e,{get(e,r){const i=e[r],s=[...o,r];return"function"==typeof i?i.prototype&&i.prototype.constructor===i?i:(...e)=>{const o=t(s,e,i);if(o&&"object"==typeof o)return n(o,s);const r=i(...e);return r&&"object"==typeof r?n(r,s):o}:i&&"object"==typeof i?n(i,s):i}});return n(e)}function Ke(e,t){const n=(e,o=[])=>{if(!e||"object"!=typeof e)return e;const r=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...o,i];Array.isArray(r)?r[Number(i)]=t(s,e):r[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(r)?r[Number(i)]=n(s,e):r[i]=n(s,e))}return r};return n(e)}function qe(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=qe();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 Je(e={}){return{collector:{},config:{},env:{},logger:qe(),id:"test",ingest:E("test"),...e}}function Xe(e){const t=String(e),n=t.split("?")[1]||t;return He(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const o=n.split(/[[\]]+/).filter(Boolean);let r=t;o.forEach((t,n)=>{const i=n===o.length-1;if(ie(r)){const s=parseInt(t,10);i?r[s]=we(e):(r[s]=r[s]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[s])}else pe(r)&&(i?r[t]=we(e):(r[t]=r[t]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[t]))})}),t})()}function Ge(e){if(!e)return"";const t=[],n=encodeURIComponent;function o(e,r){null!=r&&(ie(r)?r.forEach((t,n)=>o(`${e}[${n}]`,t)):pe(r)?Object.entries(r).forEach(([t,n])=>o(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(r))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>o(e,t)),t.join("&"))}function Qe(e){return void 0===e||de(e,"")?e:JSON.stringify(e)}function Ye(e={}){return oe({"Content-Type":"application/json; charset=utf-8"},e)}function et(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function tt(e,t,n,o){return function(...r){let i;const s="pre"+t,a="post"+t,c=n[s],l=n[a],f=(e,t)=>{o?o.warn(e,{error:t}):console.warn(e,t)};if(c)try{i=c({fn:e},...r)}catch(t){f(`Hook ${String(s)} failed, falling back to original function`,t),i=e(...r)}else i=e(...r);if(l)try{i=l({fn:e,result:i},...r)}catch(e){f(`Hook ${String(a)} failed, keeping original result`,e)}return i}}function nt(e){return e?{userAgent:e,browser:ot(e),browserVersion:rt(e),os:it(e),osVersion:st(e),deviceType:at(e)}:{}}function ot(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 rt(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 it(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 st(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function at(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 ct(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function lt(e){const t=ct(e);return new Function("value","mapping","collector",t)}function ft(e){const t=ct(e);return new Function("value","mapping","options",t)}function ut(e){const t=ct(e);return new Function("value",t)}var pt="https://cdn.jsdelivr.net/npm",dt="dist/walkerOS.json";function mt(e){return"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?e:void 0}async function gt(e,t){const n=t?.version||"latest",o=t?.timeout||1e4,r=new AbortController,i=setTimeout(()=>r.abort(),o),s=r.signal,a=t?.client?{"X-Walkeros-Client":t.client}:void 0;try{if(t?.baseUrl){const o=`${t.baseUrl}/api/packages/${encodeURIComponent(e)}?version=${encodeURIComponent(n)}&expand=all`,r=await fetch(o,{signal:s,...a&&{headers:a}});if(!r.ok)throw new Error(`Failed to fetch ${o} (HTTP ${r.status})`);return function(e,t,n){const o=n.schemas||{},r=n.examples||{},i=n.hints,s=n.hintKeys??(i?Object.keys(i):[]),a=n.exampleSummaries??[],c=n.platform;return{packageName:n.package||e,version:"string"==typeof n.version?n.version:t,...void 0!==n.description&&{description:n.description},...void 0!==n.type&&{type:n.type},...void 0!==c&&{platform:c},schemas:o,examples:r,...void 0!==n.docs&&{docs:n.docs},...void 0!==n.source&&{source:n.source},...i&&Object.keys(i).length>0?{hints:i}:{},hintKeys:s,exampleSummaries:a}}(e,n,await r.json())}const o=`${pt}/${e}@${n}`,r=await yt(`${o}/package.json`,s,a);return function(e,t,n,o){const r=o.$meta||{},i=o.schemas||{},s=o.examples||{},a=o.hints,c=a?Object.keys(a):[],l=[],f=s.step||{};for(const[e,t]of Object.entries(f)){const n=t,o={name:e};"string"==typeof n?.description&&(o.description=n.description),l.push(o)}const u="string"==typeof r.docs?r.docs:void 0,p="string"==typeof r.source?r.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 r.type?r.type:void 0,platform:mt(r.platform),schemas:i,examples:s,...u?{docs:u}:{},...p?{source:p}:{},...a&&Object.keys(a).length>0?{hints:a}:{},hintKeys:c,exampleSummaries:l}}(e,n,r,await yt(`${o}/${dt}`,s,a))}finally{clearTimeout(i)}}async function yt(e,t,n){const o=await fetch(e,{signal:t,...n&&{headers:n}});if(!o.ok)throw new Error(`Failed to fetch ${e} (HTTP ${o.status})`);return await o.json()}async function bt(e,t){const n=await gt(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 ht(e,t){const n=t?{...e,_hints:t}:e;return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}}function vt(e,t){let n,o,r,i;if(e instanceof Error){n=e.message;const t=e;t.code&&(r=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("; "),o=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),o&&(s.path=o),r&&(s.code=r),i&&(s.details=i),{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s,isError:!0}}function wt(e){let t=!1;return(n={})=>{t||(t=!0,e(n))}}function jt(e){if("*"===e)return()=>!0;if("and"in e){const t=e.and.map(jt);return e=>t.every(t=>t(e))}if("or"in e){const t=e.or.map(jt);return e=>t.some(t=>t(e))}return function(e){const{key:t,operator:n,value:o,not:r}=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,o);return e=>{const n=ye(e,t),o=i(n);return r?!o:o}}(e)}function kt(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&"match"in e[0]}function $t(e){if(null!=e){if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;if(kt(e)){return{type:"routes",routes:e.map(e=>({match:jt(e.match),next:$t(e.next)}))}}return{type:"chain",value:e}}}}function xt(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 xt(n.next,t)}}function Ot(e,t){const n={ingest:e??{}};return void 0!==t&&(n.event=t),n}function St(e){return{full:e.full??!1,storeId:e.store,rules:e.rules.map(e=>({match:jt(e.match),key:e.key,ttl:e.ttl,update:e.update}))}}function At(e,t,n,o){const r=e.rules.find(e=>e.match(n));if(!r)return null;const i=r.key.map(e=>String(ye(n,e)??""));if(i.every(e=>""===e))return null;const s=`${o}:${i.join(":")}`,a=t.get(s);return void 0!==a?{status:"HIT",key:s,value:a,rule:r}:{status:"MISS",key:s,rule:r}}function Et(e,t,n,o){e.set(t,n,1e3*o)}async function _t(e,t,n){if(!t)return e;let o=e;for(const[e,r]of Object.entries(t)){o=be(o,e,await We(n,r))}return o}function Ct(e){return 0===e.length?"// no output":e.map(Nt).join(";\n\n")}function Nt(e){const[t,...n]=e,o=n.map(Pt).join(", ");return"return"===t?o?`return ${o}`:"return":`${t}(${o})`}function Pt(e){return void 0===e?"undefined":null===e?"null":"function"==typeof e?"[Function]":JSON.stringify(e,null,2)}//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},s={};i(s,{Cache:()=>a,Collector:()=>c,Const:()=>E,Context:()=>l,Destination:()=>f,ENV_MARKER_PREFIX:()=>K,Elb:()=>u,Hint:()=>S,Hooks:()=>p,Level:()=>m,Lifecycle:()=>k,Logger:()=>d,Mapping:()=>g,Matcher:()=>O,On:()=>y,REF_CODE_PREFIX:()=>L,REF_CONTRACT:()=>V,REF_DEF:()=>D,REF_ENV:()=>H,REF_FLOW:()=>W,REF_SECRET:()=>B,REF_STORE:()=>U,REF_VAR:()=>z,Request:()=>h,Simulation:()=>x,Source:()=>v,Store:()=>w,Transformer:()=>b,Trigger:()=>j,WalkerOS:()=>$,anonymizeIP:()=>C,applyUpdate:()=>_t,assign:()=>oe,branch:()=>_,buildCacheContext:()=>Ot,castToProperty:()=>De,castValue:()=>we,checkCache:()=>Et,clone:()=>ge,compileCache:()=>St,compileMatcher:()=>jt,compileNext:()=>$t,createDestination:()=>ke,createEvent:()=>Oe,createIngest:()=>A,createLogger:()=>Te,createMockContext:()=>Je,createMockLogger:()=>Ke,createRespond:()=>wt,debounce:()=>Ce,deepMerge:()=>$e,defaultClickIds:()=>Ae,fetchPackage:()=>gt,fetchPackageSchema:()=>bt,filterValues:()=>ze,flattenIncludeSections:()=>ve,formatOut:()=>Ct,getBrowser:()=>ot,getBrowserVersion:()=>rt,getByPath:()=>ye,getDeviceType:()=>at,getEvent:()=>Se,getFlowSettings:()=>ee,getGrantedConsent:()=>je,getHeaders:()=>Ye,getId:()=>Ee,getMappingEvent:()=>We,getMappingValue:()=>Ue,getMarketingParameters:()=>_e,getOS:()=>it,getOSVersion:()=>st,getPlatform:()=>te,getSpanId:()=>xe,isArguments:()=>re,isArray:()=>ie,isBoolean:()=>se,isCommand:()=>ae,isDefined:()=>ce,isElementOrDocument:()=>le,isFunction:()=>fe,isNumber:()=>ue,isObject:()=>pe,isPropertyType:()=>Ie,isRouteArray:()=>kt,isSameType:()=>de,isString:()=>me,mcpError:()=>vt,mcpResult:()=>ht,mergeContractSchemas:()=>T,mockEnv:()=>Ze,packageNameToVariable:()=>Q,parseUserAgent:()=>nt,processEventMapping:()=>Le,requestToData:()=>Xe,requestToParameter:()=>Ge,resolveContracts:()=>M,resolveNext:()=>xt,setByPath:()=>be,storeCache:()=>At,throttle:()=>Ne,throwError:()=>N,transformData:()=>Qe,traverseEnv:()=>qe,trim:()=>et,tryCatch:()=>He,tryCatchAsync:()=>Ve,useHooks:()=>tt,walkPath:()=>X,wrapCondition:()=>lt,wrapFn:()=>ft,wrapValidate:()=>ut}),module.exports=(e=s,((e,i,s,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of o(i))r.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={},l={},f={},u={},p={},d={};i(d,{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||{}),g={},y={},b={},h={},v={},w={},j={},k={},$={},x={},O={},S={},E={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function A(e){return{_meta:{hops:0,path:[e]}}}function _(e,t){return{event:e,next:t}}function C(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function N(e){throw new Error(String(e))}var R=["globals","context","custom","user","consent"],P=new Set(["description","examples","title","$comment"]);function M(e){const t={},n=new Set;function o(r){if(t[r])return t[r];n.has(r)&&N(`Circular extends chain detected: ${[...n,r].join(" → ")}`);const i=e[r];i||N(`Contract "${r}" not found`),n.add(r);let s={};if(i.extends){s=function(e,t){const n={};void 0===e.description&&void 0===t.description||(n.description=t.description??e.description);for(const o of R){const r=e[o],i=t[o];r&&i?n[o]=T(r,i):(r||i)&&(n[o]={...r||i})}if(e.events||t.events){const o={},r=new Set([...Object.keys(e.events||{}),...Object.keys(t.events||{})]);for(const n of r){const r=e.events?.[n]||{},i=t.events?.[n]||{},s=new Set([...Object.keys(r),...Object.keys(i)]);o[n]={};for(const e of s){const t=r[e],s=i[e];o[n][e]=t&&s?T(t,s):{...t||s}}}n.events=o}return n}(o(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 o of Object.keys(e[n]||{})){let r={};const i=e["*"]?.["*"];i&&(r=T(r,i));const s=e["*"]?.[o];s&&"*"!==o&&(r=T(r,s));const a=e[n]?.["*"];a&&"*"!==o&&(r=T(r,a));const c=e[n]?.[o];c&&(r=T(r,c)),t[n][o]=r}}e["*"]&&(t["*"]={...e["*"]});return t}(s.events)),s.events){const e={};for(const[t,n]of Object.entries(s.events)){e[t]={};for(const[o,r]of Object.entries(n))e[t][o]=F(r)}s.events=e}return n.delete(r),t[r]=s,s}for(const t of Object.keys(e))o(t);return t}function T(e,t){const n={...e};for(const o of Object.keys(t)){const r=e[o],i=t[o];"required"===o&&Array.isArray(r)&&Array.isArray(i)?n[o]=[...new Set([...r,...i])]:I(r)&&I(i)?n[o]=T(r,i):n[o]=i}return n}function F(e){const t={};for(const[n,o]of Object.entries(e))P.has(n)||(null===o||"object"!=typeof o||Array.isArray(o)?t[n]=o:t[n]=F(o));return t}function I(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var z=/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,D=/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,H=/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,V=/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,W=/^\$flow\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z0-9_.]+))?$/,U=/^\$store\.([a-zA-Z_][a-zA-Z0-9_]*)$/,B=/^\$secret\.([A-Z0-9_]+)$/,L="$code:";function Z(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function q(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}var K="__WALKEROS_ENV:";function J(e,t,n){const o=`$flow.${e}${t?`.${t}`:""}`;if("unknown-flow"===n)return`${o} cannot resolve: flow "${e}" does not exist in this config.`;return`${o} is empty. Set ${t?`flows.${e}.config.${t}`:`flows.${e}.config`}, or run \`walkeros deploy ${e}\` first.`}function X(e,t,n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const i=o[e];if(null==r||"object"!=typeof r){const r=o.slice(0,e).join(".");N(`Path "${t}" not found in "${n}": "${i}" does not exist${r?` in "${r}"`:""}`)}const s=r;if(!(i in s)){const r=o.slice(0,e).join(".");N(`Path "${t}" not found in "${n}": "${i}" does not exist${r?` in "${r}"`:""}`)}r=s[i]}return r}function G(e,t,n,o,r,i){if("string"==typeof e){const s=e.match(D);if(s){const e=s[1],a=s[2];void 0===n[e]&&N(`Definition "${e}" not found`);let c=G(n[e],t,n,o,r,i);return a&&(c=X(c,a,`$def.${e}`)),c}const a=e.match(V);if(a&&r){const e=a[1],t=a[2];e in r||N(`Contract "${e}" not found`);let n=r[e];return t&&(n=X(n,t,`$contract.${e}`)),n}const c=e.match(W);if(c){const t=c[1],n=c[2],r=!1===o?.strictFlowRefs;i||N(`$flow.${t}${n?`.${n}`:""} cannot be resolved without a flow resolver`);const s=i(t);if(!s){if(r)return o?.onWarning?.(J(t,n,"unknown-flow")),e;N(`Flow "${t}" not found in $flow.${t}`)}let a=s;if(n)if(r){try{a=X(a,n,`$flow.${t}`)}catch{return o?.onWarning?.(J(t,n,"missing-key")),e}if(null==a||""===a)return o?.onWarning?.(J(t,n,"missing-key")),e}else a=X(a,n,`$flow.${t}`);return a}let l=e.replace(z,(e,n)=>{if(void 0!==t[n])return String(t[n]);N(`Variable "${n}" not found`)});return l=l.replace(H,(e,t,n)=>o?.deferred?void 0!==n?`${K}${t}:${n}`:`${K}${t}`:"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==n?n:void N(`Environment variable "${t}" not found and no default provided`)),l}if(Array.isArray(e))return e.map(e=>G(e,t,n,o,r,i));if(null!==e&&"object"==typeof e){const s={};for(const[a,c]of Object.entries(e))s[a]=G(c,t,n,o,r,i);return s}return e}function Q(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 Y(e,t,n){if(t)return t;if(!e||!n)return;return n[e]?Q(e):void 0}function ee(e,t,n){const o=new Map,r=new Set,i=[],s=t=>{if(o.has(t))return o.get(t);const a=e.flows[t];if(a){if(r.has(t)){N(`Cyclic $flow reference: ${[...i,t].join(" -> ")}`)}r.add(t),i.push(t);try{const r=Z(e.variables,a.variables),i=q(e.definitions,a.definitions),c=G(a.config??{},r,i,n,void 0,s);return o.set(t,c),c}finally{r.delete(t),i.pop()}}},a=Object.keys(e.flows);t||(1===a.length?t=a[0]:N(`Multiple flows found (${a.join(", ")}). Please specify a flow.`));const c=e.flows[t];c||N(`Flow "${t}" not found. Available: ${a.join(", ")}`),r.add(t),i.push(t);try{return function(e,t,n,o){const r=JSON.parse(JSON.stringify(t));let i;if(e.contract){const r=Z(e.variables,t.variables),s=q(e.definitions,t.definitions);i=M(G(e.contract,r,s,n,void 0,o))}if(r.config){const s=Z(e.variables,t.variables),a=q(e.definitions,t.definitions);r.config=G(r.config,s,a,n,i,o)}if(r.sources)for(const[s,a]of Object.entries(r.sources)){const c=Z(e.variables,t.variables,a.variables),l=q(e.definitions,t.definitions,a.definitions),f=G(a.config,c,l,n,i,o),u=G(a.env,c,l,n,i,o),p=Y(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.sources[s]={package:a.package,config:f,env:u,primary:a.primary,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.destinations)for(const[s,a]of Object.entries(r.destinations)){const c=Z(e.variables,t.variables,a.variables),l=q(e.definitions,t.definitions,a.definitions),f=G(a.config,c,l,n,i,o),u=G(a.env,c,l,n,i,o),p=Y(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.destinations[s]={package:a.package,config:f,env:u,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.stores)for(const[s,a]of Object.entries(r.stores)){const c=Z(e.variables,t.variables,a.variables),l=q(e.definitions,t.definitions,a.definitions),f=G(a.config,c,l,n,i,o),u=G(a.env,c,l,n,i,o),p=Y(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.stores[s]={package:a.package,config:f,env:u,variables:a.variables,definitions:a.definitions,code:m}}if(r.transformers)for(const[s,a]of Object.entries(r.transformers)){const c=Z(e.variables,t.variables,a.variables),l=q(e.definitions,t.definitions,a.definitions),f=G(a.config,c,l,n,i,o),u=G(a.env,c,l,n,i,o),p=Y(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.transformers[s]={package:a.package,config:f,env:u,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.collector){const s=Z(e.variables,t.variables),a=q(e.definitions,t.definitions),c=G(r.collector,s,a,n,i,o);r.collector=c}return r}(e,c,n,s)}finally{r.delete(t),i.pop()}}function te(e){const t=e.config?.platform;if("web"===t||"server"===t)return t;N('Flow must have config.platform set to "web" or "server"')}var ne={merge:!0,shallow:!0,extend:!0};function oe(e,t={},n={}){n={...ne,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function re(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function ie(e){return Array.isArray(e)}function se(e){return"boolean"==typeof e}function ae(e){return"walker"===e}function ce(e){return void 0!==e}function le(e){return!(!e||"object"!=typeof e)&&("body"in e||"tagName"in e)}function fe(e){return"function"==typeof e}function ue(e){return"number"==typeof e&&!Number.isNaN(e)}function pe(e){return"object"==typeof e&&null!==e&&!ie(e)&&"[object Object]"===Object.prototype.toString.call(e)}function de(e,t){return typeof e==typeof t}function me(e){return"string"==typeof e}function ge(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 o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=ge(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(ge(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 ye(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&ie(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=ye(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,void 0===r)break}return ce(r)?r:n}function be(e,t,n){if(!pe(e))return e;const o=ge(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}var he={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,timing:e.timing})};function ve(e,t){const n={},o=t.includes("all")?Object.keys(he):t;for(const t of o){const o=he[t];if(!o)continue;const r=o(e);if(pe(r))for(const[e,o]of Object.entries(r)){if(void 0===o)continue;const r="context"===t&&Array.isArray(o)?o[0]:o;n[`${t}_${e}`]=r}}return n}function we(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function je(e,t={},n={}){const o={...t,...n},r={};let i=!e||0===Object.keys(e).length;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function ke(e,t){const n={...e};return n.config=oe(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=oe(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=oe(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function $e(e,t){if(!pe(t))return e;for(const n of Object.keys(t)){const o=t[n];void 0!==o&&(pe(o)&&pe(e[n])?$e(e[n],o):e[n]=o)}return e}function xe(){let e="";for(let t=0;t<16;t++)e+=(16*Math.random()|0).toString(16);return e}function Oe(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=oe({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"}}],consent:{functional:!0},id:e.id||xe(),trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,source:{type:"collector",schema:"4"}},e,{merge:!1});if(e.name){const[t,o]=e.name.split(" ")??[];t&&o&&(n.entity=t,n.action=o)}return n}function Se(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},r={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return Oe({...{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...o.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+r.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...r,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",...o,context:{shopping:["complete",0]},nested:[]},{entity:"product",...r,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":{...o,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...o,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...o.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 Ee(e=6,t){if(t){const n=t.length;let o="";for(let r=0;r<e;r++)o+=t[Math.random()*n|0];return o}let n="";for(let t=36;n.length<e;)n+=(Math.random()*t|0).toString(t);return n}var Ae=[{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 _e(e,t={},n=[]){const o={};Object.entries(oe({utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term"},t)).forEach(([t,n])=>{const r=e.searchParams.get(t);r&&(o[n]=r)});const r=n.length?function(e){const t=new Map(e.map(e=>[e.param,e.platform])),n=new Set(Ae.map(e=>e.param));return[...Ae.map(e=>t.has(e.param)?{param:e.param,platform:t.get(e.param)}:e),...e.filter(e=>!n.has(e.param))]}(n):Ae,i=new Map;e.searchParams.forEach((e,t)=>{e&&i.set(t.toLowerCase(),e)});for(const e of r){const t=i.get(e.param);t&&(o[e.param]=t,o.clickId||(o.clickId=e.param,o.platform=e.platform))}return o}function Ce(e,t=1e3,n=!1){let o,r=null,i=!1;return(...s)=>new Promise(a=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...s),a(o))},t),c&&(i=!0,o=e(...s),a(o))})}function Ne(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}function Re(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function Pe(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=Re(e)):n=e,void 0!==t&&(t instanceof Error?o.error=Re(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=Re(o.error))):o.value=t),{message:n,context:o}}var Me=(e,t,n,o)=>{const r=`${m[e]}${o.length>0?` [${o.join(":")}]`:""}`,i=Object.keys(n).length>0,s=0===e?console.error:1===e?console.warn:console.log;i?s(r,t,n):s(r,t)};function Te(e={}){return Fe({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 Fe(e){const{level:t,handler:n,jsonHandler:o,scope:r}=e,i=(e,o,i)=>{if(e<=t){const t=Pe(o,i);n?n(e,t.message,t.context,r,Me):Me(e,t.message,t.context,r)}};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 o=Pe(e,t);throw n?n(0,o.message,o.context,r,Me):Me(0,o.message,o.context,r),new Error(o.message)},json:e=>{o?o(e):console.log(JSON.stringify(e,null,2))},scope:e=>Fe({level:t,handler:n,jsonHandler:o,scope:[...r,e]})}}function Ie(e){return se(e)||me(e)||ue(e)||!ce(e)||ie(e)&&e.every(Ie)||pe(e)&&Object.values(e).every(Ie)}function ze(e){return se(e)||me(e)||ue(e)?e:re(e)?ze(Array.from(e)):ie(e)?e.map(e=>ze(e)).filter(e=>void 0!==e):pe(e)?Object.entries(e).reduce((e,[t,n])=>{const o=ze(n);return void 0!==o&&(e[t]=o),e},{}):void 0}function De(e){return Ie(e)?e:void 0}function He(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function Ve(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function We(e,t,n){const[o,r]=(e.name||"").split(" ");if(!t||!o||!r)return{};let i,s="",a=o,c=r;const l=t=>{if(!t)return;return(ie(t)?t:[t]).find(t=>{if(!t.condition)return!0;if(!n)return Boolean(t.condition(e,void 0));const o={event:e,mapping:t,collector:n,logger:n.logger,consent:pe(e)&&e.consent||n.consent};return Boolean(t.condition(e,o))})};t[a]||(a="*");const f=t[a];return f&&(f[c]||(c="*"),i=l(f[c])),i||(a="*",c="*",i=l(t[a]?.[c])),i&&(s=`${a} ${c}`),{eventMapping:i,mappingKey:s}}async function Ue(e,t={},n={}){if(!ce(e))return;const o=pe(e)&&e.consent||n.consent||n.collector?.consent,r=n.event??(pe(e)?e:{});if(!n.collector)throw new Error("getMappingValue: context.collector is required");const i={event:r,mapping:t,collector:n.collector,logger:n.collector.logger,consent:o},s=ie(t)?t:[t];for(const t of s){const n=await Ve(Be)(e,t,{...i,mapping:t});if(ce(n))return n}}async function Be(e,t,n){return(ie(t)?t:[t]).reduce(async(t,o)=>{const r=await t;if(r)return r;const i=me(o)?{key:o}:o;if(!Object.keys(i).length)return;const{condition:s,consent:a,fn:c,key:l,loop:f,map:u,set:p,validate:d,value:m}=i,g={...n,mapping:o};if(s&&!await Ve(s)(e,g))return;if(a&&!je(a,g.consent))return m;let y=ce(m)?m:e;if(c&&(y=await Ve(c)(e,g)),l&&(y=ye(e,l,m)),f){const[t,n]=f,o="this"===t?[e]:await Ue(e,t,g);ie(o)&&(y=(await Promise.all(o.map(e=>Ue(e,n,g)))).filter(ce))}else u?y=await Object.entries(u).reduce(async(t,[n,o])=>{const r=await t,i=await Ue(e,o,g);return ce(i)&&(r[n]=i),r},Promise.resolve({})):p&&(y=await Promise.all(p.map(t=>Be(e,t,g))));d&&!await Ve(d)(y,g)&&(y=void 0);const b=De(y);return ce(b)?b:De(m)},Promise.resolve(void 0))}async function Le(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await Ue(e,o,{collector:n,event:e});e=be(e,t,r)}));const{eventMapping:o,mappingKey:r}=await We(e,t.mapping,n);o?.policy&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await Ue(e,o,{collector:n,event:e});e=be(e,t,r)}));let i=t.data&&await Ue(e,t.data,{collector:n,event:e});const s=Boolean(o?.silent);if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0,silent:s};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await Ue(e,o.data,{collector:n,event:e});i=pe(i)&&pe(t)?oe(i,t):t}}const a=o?.include??t.include;if(a&&a.length>0){const t=ve(e,a);Object.keys(t).length>0&&(i=pe(i)?oe(t,i):i??t)}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1,silent:s}}function Ze(e,t){const n=(e,o=[])=>new Proxy(e,{get(e,r){const i=e[r],s=[...o,r];return"function"==typeof i?i.prototype&&i.prototype.constructor===i?i:(...e)=>{const o=t(s,e,i);if(o&&"object"==typeof o)return n(o,s);const r=i(...e);return r&&"object"==typeof r?n(r,s):o}:i&&"object"==typeof i?n(i,s):i}});return n(e)}function qe(e,t){const n=(e,o=[])=>{if(!e||"object"!=typeof e)return e;const r=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...o,i];Array.isArray(r)?r[Number(i)]=t(s,e):r[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(r)?r[Number(i)]=n(s,e):r[i]=n(s,e))}return r};return n(e)}function Ke(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=Ke();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 Je(e={}){return{collector:{},config:{},env:{},logger:Ke(),id:"test",ingest:A("test"),...e}}function Xe(e){const t=String(e),n=t.split("?")[1]||t;return He(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const o=n.split(/[[\]]+/).filter(Boolean);let r=t;o.forEach((t,n)=>{const i=n===o.length-1;if(ie(r)){const s=parseInt(t,10);i?r[s]=we(e):(r[s]=r[s]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[s])}else pe(r)&&(i?r[t]=we(e):(r[t]=r[t]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[t]))})}),t})()}function Ge(e){if(!e)return"";const t=[],n=encodeURIComponent;function o(e,r){null!=r&&(ie(r)?r.forEach((t,n)=>o(`${e}[${n}]`,t)):pe(r)?Object.entries(r).forEach(([t,n])=>o(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(r))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>o(e,t)),t.join("&"))}function Qe(e){return void 0===e||de(e,"")?e:JSON.stringify(e)}function Ye(e={}){return oe({"Content-Type":"application/json; charset=utf-8"},e)}function et(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function tt(e,t,n,o){return function(...r){let i;const s="pre"+t,a="post"+t,c=n[s],l=n[a],f=(e,t)=>{o?o.warn(e,{error:t}):console.warn(e,t)};if(c)try{i=c({fn:e},...r)}catch(t){f(`Hook ${String(s)} failed, falling back to original function`,t),i=e(...r)}else i=e(...r);if(l)try{i=l({fn:e,result:i},...r)}catch(e){f(`Hook ${String(a)} failed, keeping original result`,e)}return i}}function nt(e){return e?{userAgent:e,browser:ot(e),browserVersion:rt(e),os:it(e),osVersion:st(e),deviceType:at(e)}:{}}function ot(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 rt(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 it(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 st(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function at(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 ct(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function lt(e){const t=ct(e);return new Function("value","context",t)}function ft(e){const t=ct(e);return new Function("value","context",t)}function ut(e){const t=ct(e);return new Function("value","context",t)}var pt="https://cdn.jsdelivr.net/npm",dt="dist/walkerOS.json";function mt(e){return"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?e:void 0}async function gt(e,t){const n=t?.version||"latest",o=t?.timeout||1e4,r=new AbortController,i=setTimeout(()=>r.abort(),o),s=r.signal,a=t?.client?{"X-Walkeros-Client":t.client}:void 0;try{if(t?.baseUrl){const o=`${t.baseUrl}/api/packages/${encodeURIComponent(e)}?version=${encodeURIComponent(n)}&expand=all`,r=await fetch(o,{signal:s,...a&&{headers:a}});if(!r.ok)throw new Error(`Failed to fetch ${o} (HTTP ${r.status})`);return function(e,t,n){const o=n.schemas||{},r=n.examples||{},i=n.hints,s=n.hintKeys??(i?Object.keys(i):[]),a=n.exampleSummaries??[],c=n.platform;return{packageName:n.package||e,version:"string"==typeof n.version?n.version:t,...void 0!==n.description&&{description:n.description},...void 0!==n.type&&{type:n.type},...void 0!==c&&{platform:c},schemas:o,examples:r,...void 0!==n.docs&&{docs:n.docs},...void 0!==n.source&&{source:n.source},...i&&Object.keys(i).length>0?{hints:i}:{},hintKeys:s,exampleSummaries:a}}(e,n,await r.json())}const o=`${pt}/${e}@${n}`,r=await yt(`${o}/package.json`,s,a);return function(e,t,n,o){const r=o.$meta||{},i=o.schemas||{},s=o.examples||{},a=o.hints,c=a?Object.keys(a):[],l=[],f=s.step||{};for(const[e,t]of Object.entries(f)){const n=t,o={name:e};"string"==typeof n?.description&&(o.description=n.description),l.push(o)}const u="string"==typeof r.docs?r.docs:void 0,p="string"==typeof r.source?r.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 r.type?r.type:void 0,platform:mt(r.platform),schemas:i,examples:s,...u?{docs:u}:{},...p?{source:p}:{},...a&&Object.keys(a).length>0?{hints:a}:{},hintKeys:c,exampleSummaries:l}}(e,n,r,await yt(`${o}/${dt}`,s,a))}finally{clearTimeout(i)}}async function yt(e,t,n){const o=await fetch(e,{signal:t,...n&&{headers:n}});if(!o.ok)throw new Error(`Failed to fetch ${e} (HTTP ${o.status})`);return await o.json()}async function bt(e,t){const n=await gt(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 ht(e,t){const n=t?{...e,_hints:t}:e;return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}}function vt(e,t){let n,o,r,i;if(e instanceof Error){n=e.message;const t=e;t.code&&(r=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("; "),o=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),o&&(s.path=o),r&&(s.code=r),i&&(s.details=i),{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s,isError:!0}}function wt(e){let t=!1;return(n={})=>{t||(t=!0,e(n))}}function jt(e){if("*"===e)return()=>!0;if("and"in e){const t=e.and.map(jt);return e=>t.every(t=>t(e))}if("or"in e){const t=e.or.map(jt);return e=>t.some(t=>t(e))}return function(e){const{key:t,operator:n,value:o,not:r}=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,o);return e=>{const n=ye(e,t),o=i(n);return r?!o:o}}(e)}function kt(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&"match"in e[0]}function $t(e){if(null!=e){if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;if(kt(e)){return{type:"routes",routes:e.map(e=>({match:jt(e.match),next:$t(e.next)}))}}return{type:"chain",value:e}}}}function xt(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 xt(n.next,t)}}function Ot(e,t){const n={ingest:e??{}};return void 0!==t&&(n.event=t),n}function St(e){return{full:e.full??!1,storeId:e.store,rules:e.rules.map(e=>({match:jt(e.match),key:e.key,ttl:e.ttl,update:e.update}))}}function Et(e,t,n,o){const r=e.rules.find(e=>e.match(n));if(!r)return null;const i=r.key.map(e=>String(ye(n,e)??""));if(i.every(e=>""===e))return null;const s=`${o}:${i.join(":")}`,a=t.get(s);return void 0!==a?{status:"HIT",key:s,value:a,rule:r}:{status:"MISS",key:s,rule:r}}function At(e,t,n,o){e.set(t,n,1e3*o)}async function _t(e,t,n,o){if(!t)return e;let r=e;for(const[e,i]of Object.entries(t)){r=be(r,e,await Ue(n,i,{collector:o}))}return r}function Ct(e){return 0===e.length?"// no output":e.map(Nt).join(";\n\n")}function Nt(e){const[t,...n]=e,o=n.map(Rt).join(", ");return"return"===t?o?`return ${o}`:"return":`${t}(${o})`}function Rt(e){return void 0===e?"undefined":null===e?"null":"function"==typeof e?"[Function]":JSON.stringify(e,null,2)}//# sourceMappingURL=index.js.map