@walkeros/core 0.0.7 → 0.1.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
@@ -2,8 +2,6 @@
2
2
  * Core collector configuration interface
3
3
  */
4
4
  interface Config$4 {
5
- /** Run in dry mode without executing events */
6
- dryRun: boolean;
7
5
  /** Whether to run collector automatically */
8
6
  run?: boolean;
9
7
  /** Initial consent state */
@@ -56,7 +54,7 @@ interface CollectorSource {
56
54
  }
57
55
  type CommandType = 'action' | 'config' | 'consent' | 'context' | 'destination' | 'elb' | 'globals' | 'hook' | 'init' | 'link' | 'run' | 'user' | 'walker' | string;
58
56
  interface Instance$2 {
59
- push: Fn$2;
57
+ push: Fn$1;
60
58
  allowed: boolean;
61
59
  config: Config$4;
62
60
  consent: Consent;
@@ -141,6 +139,7 @@ interface Instance$1<Settings = unknown, Mapping = unknown> {
141
139
  queue?: Events;
142
140
  dlq?: DLQ;
143
141
  type?: string;
142
+ env?: Environment;
144
143
  init?: InitFn<Settings, Mapping>;
145
144
  push: PushFn<Settings, Mapping>;
146
145
  pushBatch?: PushBatchFn<Settings, Mapping>;
@@ -149,16 +148,15 @@ interface Config$3<Settings = unknown, Mapping = unknown> {
149
148
  consent?: Consent;
150
149
  settings?: Settings;
151
150
  data?: Value | Values;
152
- dryRun?: boolean;
151
+ env?: Environment;
153
152
  id?: string;
154
153
  init?: boolean;
155
154
  loadScript?: boolean;
156
155
  mapping?: Rules<Rule<Mapping>>;
157
- on?: Config$2;
156
+ on?: Config$1;
158
157
  policy?: Policy;
159
158
  queue?: boolean;
160
159
  verbose?: boolean;
161
- wrapper?: Config;
162
160
  onError?: Error;
163
161
  onLog?: Log;
164
162
  }
@@ -180,7 +178,7 @@ interface Context$1<Settings = unknown, Mapping = unknown> {
180
178
  collector: Instance$2;
181
179
  config: Config$3<Settings, Mapping>;
182
180
  data?: Data$1;
183
- wrap: Wrap;
181
+ env: Environment;
184
182
  }
185
183
  interface PushContext<Settings = unknown, Mapping = unknown> extends Context$1<Settings, Mapping> {
186
184
  mapping?: Rule<Mapping>;
@@ -217,10 +215,25 @@ type Result$1 = {
217
215
  queued: Array<Ref>;
218
216
  failed: Array<Ref>;
219
217
  };
218
+ /**
219
+ * Base environment requirements interface for walkerOS destinations
220
+ *
221
+ * This defines the core interface that destinations can use to declare
222
+ * their runtime environment requirements. Platform-specific extensions
223
+ * should extend this interface.
224
+ */
225
+ interface Environment {
226
+ /**
227
+ * Generic global properties that destinations may require
228
+ * Platform-specific implementations can extend this interface
229
+ */
230
+ [key: string]: unknown;
231
+ }
220
232
 
221
233
  type destination_Batch<Mapping> = Batch<Mapping>;
222
234
  type destination_DLQ = DLQ;
223
235
  type destination_Destinations = Destinations;
236
+ type destination_Environment = Environment;
224
237
  type destination_InitDestination<Settings = unknown, Mapping = unknown> = InitDestination<Settings, Mapping>;
225
238
  type destination_InitDestinations = InitDestinations;
226
239
  type destination_InitFn<Settings, Mapping> = InitFn<Settings, Mapping>;
@@ -235,7 +248,7 @@ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
235
248
  type destination_PushFn<Settings, Mapping> = PushFn<Settings, Mapping>;
236
249
  type destination_Ref = Ref;
237
250
  declare namespace destination {
238
- export type { destination_Batch as Batch, Config$3 as Config, Context$1 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Init$1 as Init, destination_InitDestination as InitDestination, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, Instance$1 as Instance, destination_PartialConfig as PartialConfig, destination_Policy as Policy, destination_Push as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Result$1 as Result };
251
+ export type { destination_Batch as Batch, Config$3 as Config, Context$1 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, destination_Environment as Environment, Init$1 as Init, destination_InitDestination as InitDestination, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, Instance$1 as Instance, destination_PartialConfig as PartialConfig, destination_Policy as Policy, destination_Push as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Result$1 as Result };
239
252
  }
240
253
 
241
254
  interface EventFn<R = Promise<PushResult>> {
@@ -243,7 +256,7 @@ interface EventFn<R = Promise<PushResult>> {
243
256
  (event: string): R;
244
257
  (event: string, data: Properties): R;
245
258
  }
246
- interface Fn$2<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, WalkerCommands<R, Config> {
259
+ interface Fn$1<R = Promise<PushResult>, Config = unknown> extends EventFn<R>, WalkerCommands<R, Config> {
247
260
  }
248
261
  interface WalkerCommands<R = Promise<PushResult>, Config = unknown> {
249
262
  (event: 'walker config', config: Partial<Config>): R;
@@ -277,7 +290,22 @@ type elb_PushResult = PushResult;
277
290
  type elb_RegisterDestination<Destination, Config> = RegisterDestination<Destination, Config>;
278
291
  type elb_WalkerCommands<R = Promise<PushResult>, Config = unknown> = WalkerCommands<R, Config>;
279
292
  declare namespace elb {
280
- 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_RegisterDestination as RegisterDestination, elb_WalkerCommands as WalkerCommands };
293
+ export type { Event$1 as Event, elb_EventFn as EventFn, Fn$1 as Fn, elb_Layer as Layer, elb_PushData as PushData, elb_PushResult as PushResult, elb_RegisterDestination as RegisterDestination, elb_WalkerCommands as WalkerCommands };
294
+ }
295
+
296
+ /**
297
+ * Flow configuration interface for dynamic walkerOS setup
298
+ * Used by bundlers and other tools to configure walkerOS dynamically
299
+ */
300
+ interface Config$2 {
301
+ /** Collector configuration - uses existing Collector.Config from core */
302
+ collector: Config$4;
303
+ /** NPM packages required for this configuration */
304
+ packages: Record<string, string>;
305
+ }
306
+
307
+ declare namespace flow {
308
+ export type { Config$2 as Config };
281
309
  }
282
310
 
283
311
  type Error = (error: unknown, state?: unknown) => void;
@@ -330,7 +358,7 @@ type ValueType = string | ValueConfig;
330
358
  interface ValueConfig {
331
359
  condition?: Condition;
332
360
  consent?: Consent;
333
- fn?: Fn$1;
361
+ fn?: Fn;
334
362
  key?: string;
335
363
  loop?: Loop;
336
364
  map?: Map;
@@ -339,7 +367,7 @@ interface ValueConfig {
339
367
  value?: PropertyType;
340
368
  }
341
369
  type Condition = (value: DeepPartialEvent | unknown, mapping?: Value, collector?: Instance$2) => PromiseOrValue<boolean>;
342
- type Fn$1 = (value: DeepPartialEvent | unknown, mapping: Value, options: Options$1) => PromiseOrValue<Property | unknown>;
370
+ type Fn = (value: DeepPartialEvent | unknown, mapping: Value, options: Options$1) => PromiseOrValue<Property | unknown>;
343
371
  type Loop = [Value, Value];
344
372
  type Map = {
345
373
  [key: string]: Value;
@@ -353,6 +381,7 @@ type Validate = (value?: unknown) => PromiseOrValue<boolean>;
353
381
 
354
382
  type mapping_Condition = Condition;
355
383
  type mapping_Data = Data;
384
+ type mapping_Fn = Fn;
356
385
  type mapping_Loop = Loop;
357
386
  type mapping_Map = Map;
358
387
  type mapping_Result = Result;
@@ -364,16 +393,16 @@ type mapping_ValueConfig = ValueConfig;
364
393
  type mapping_ValueType = ValueType;
365
394
  type mapping_Values = Values;
366
395
  declare namespace mapping {
367
- export type { mapping_Condition as Condition, mapping_Data as Data, Fn$1 as Fn, mapping_Loop as Loop, mapping_Map as Map, Options$1 as Options, mapping_Result 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 };
396
+ export type { mapping_Condition as Condition, mapping_Data as Data, mapping_Fn as Fn, mapping_Loop as Loop, mapping_Map as Map, Options$1 as Options, mapping_Result 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 };
368
397
  }
369
398
 
370
- type Config$2 = {
399
+ type Config$1 = {
371
400
  consent?: Array<ConsentConfig>;
372
401
  ready?: Array<ReadyConfig>;
373
402
  run?: Array<RunConfig>;
374
403
  session?: Array<SessionConfig>;
375
404
  };
376
- type Types = keyof Config$2;
405
+ type Types = keyof Config$1;
377
406
  type Options = ConsentConfig | ReadyConfig | RunConfig | SessionConfig;
378
407
  interface ConsentConfig {
379
408
  [key: string]: ConsentFn;
@@ -405,7 +434,7 @@ type on_SessionConfig = SessionConfig;
405
434
  type on_SessionFn = SessionFn;
406
435
  type on_Types = Types;
407
436
  declare namespace on {
408
- export type { Config$2 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, on_OnConfig as OnConfig, 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, on_Types as Types };
437
+ export type { Config$1 as Config, on_ConsentConfig as ConsentConfig, on_ConsentFn as ConsentFn, on_OnConfig as OnConfig, 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, on_Types as Types };
409
438
  }
410
439
 
411
440
  interface Context {
@@ -454,34 +483,35 @@ declare namespace schema {
454
483
  export type { schema_Contract as Contract, schema_Contracts as Contracts, Properties$1 as Properties, Property$1 as Property };
455
484
  }
456
485
 
457
- interface Config$1 {
486
+ interface Config {
458
487
  type: string;
459
488
  id?: string;
460
489
  disabled?: boolean;
461
490
  settings: AnyObject;
462
491
  onError?: AnyFunction;
463
492
  }
464
- type InitConfig = Partial<Config$1>;
465
- interface Init<T extends Config$1 = Config$1, E = AnyFunction> {
493
+ type InitConfig = Partial<Config>;
494
+ interface Init<T extends Config = Config, E = AnyFunction> {
466
495
  (collector: Instance$2, config: T): CreateSource<T, E> | Promise<CreateSource<T, E>>;
467
496
  }
468
- interface CreateSource<T extends Config$1 = Config$1, E = AnyFunction> {
497
+ interface CreateSource<T extends Config = Config, E = AnyFunction> {
469
498
  source?: Instance<T>;
470
499
  elb?: E;
471
500
  }
472
- interface Instance<T extends Config$1 = Config$1> {
501
+ interface Instance<T extends Config = Config> {
473
502
  type: string;
474
503
  config: T;
475
504
  collector: Instance$2;
476
505
  destroy?(): void | Promise<void>;
477
506
  }
478
507
 
479
- type source_CreateSource<T extends Config$1 = Config$1, E = AnyFunction> = CreateSource<T, E>;
480
- type source_Init<T extends Config$1 = Config$1, E = AnyFunction> = Init<T, E>;
508
+ type source_Config = Config;
509
+ type source_CreateSource<T extends Config = Config, E = AnyFunction> = CreateSource<T, E>;
510
+ type source_Init<T extends Config = Config, E = AnyFunction> = Init<T, E>;
481
511
  type source_InitConfig = InitConfig;
482
- type source_Instance<T extends Config$1 = Config$1> = Instance<T>;
512
+ type source_Instance<T extends Config = Config> = Instance<T>;
483
513
  declare namespace source {
484
- export type { Config$1 as Config, source_CreateSource as CreateSource, source_Init as Init, source_InitConfig as InitConfig, source_Instance as Instance };
514
+ export type { source_Config as Config, source_CreateSource as CreateSource, source_Init as Init, source_InitConfig as InitConfig, source_Instance as Instance };
485
515
  }
486
516
 
487
517
  type AnyObject<T = unknown> = Record<string, T>;
@@ -490,7 +520,7 @@ type AnyFunction = (...args: unknown[]) => unknown;
490
520
  type SingleOrArray<T> = T | Array<T>;
491
521
  declare global {
492
522
  namespace WalkerOS {
493
- interface Elb extends Fn$2 {
523
+ interface Elb extends Fn$1 {
494
524
  }
495
525
  }
496
526
  }
@@ -498,7 +528,7 @@ type Events = Array<Event>;
498
528
  type PartialEvent = Partial<Event>;
499
529
  type DeepPartialEvent = DeepPartial<Event>;
500
530
  interface Event {
501
- event: string;
531
+ name: string;
502
532
  data: Properties;
503
533
  context: OrderedProperties;
504
534
  globals: Properties;
@@ -566,7 +596,7 @@ interface OrderedProperties {
566
596
  }
567
597
  type Entities = Array<Entity>;
568
598
  interface Entity {
569
- type: string;
599
+ entity: string;
570
600
  data: Properties;
571
601
  nested: Entities;
572
602
  context: OrderedProperties;
@@ -605,26 +635,6 @@ declare namespace walkeros {
605
635
  export type { walkeros_ActionHandler as ActionHandler, walkeros_AnyFunction as AnyFunction, walkeros_AnyObject as AnyObject, walkeros_Consent as Consent, walkeros_ConsentHandler as ConsentHandler, walkeros_DeepPartial as DeepPartial, walkeros_DeepPartialEvent as DeepPartialEvent, walkeros_Elb as Elb, walkeros_Entities as Entities, walkeros_Entity as Entity, walkeros_Event as Event, walkeros_Events as Events, walkeros_OrderedProperties as OrderedProperties, walkeros_PartialEvent as PartialEvent, walkeros_PromiseOrValue as PromiseOrValue, walkeros_Properties as Properties, walkeros_Property as Property, walkeros_PropertyType as PropertyType, walkeros_SingleOrArray as SingleOrArray, walkeros_Source as Source, walkeros_SourceType as SourceType, walkeros_User as User, walkeros_Version as Version };
606
636
  }
607
637
 
608
- interface Fn {
609
- name: string;
610
- type?: string;
611
- }
612
- type OnCall = (context: Fn, args: unknown[]) => void;
613
- interface Config {
614
- dryRun?: boolean;
615
- mockReturn?: unknown;
616
- onCall?: OnCall;
617
- }
618
- type Wrap = <T>(name: string, originalFn: T) => T;
619
-
620
- type wrapper_Config = Config;
621
- type wrapper_Fn = Fn;
622
- type wrapper_OnCall = OnCall;
623
- type wrapper_Wrap = Wrap;
624
- declare namespace wrapper {
625
- export type { wrapper_Config as Config, wrapper_Fn as Fn, wrapper_OnCall as OnCall, wrapper_Wrap as Wrap };
626
- }
627
-
628
638
  type StorageType = 'local' | 'session' | 'cookie';
629
639
  declare const Const: {
630
640
  readonly Utils: {
@@ -778,7 +788,7 @@ declare function createDestination<Settings = unknown, Mapping = unknown>(baseDe
778
788
  * });
779
789
  * ```
780
790
  */
781
- declare function createSource<T extends Config$1, E = unknown>(source: Init<T, E>, config: Partial<T>): Init<T, E>;
791
+ declare function createSource<T extends Config, E = unknown>(source: Init<T, E>, config: Partial<T>): Init<T, E>;
782
792
 
783
793
  /**
784
794
  * Creates a complete event with default values.
@@ -1110,13 +1120,4 @@ declare function validateEvent(obj: unknown, customContracts?: Contracts): Event
1110
1120
  */
1111
1121
  declare function validateProperty(obj: AnyObject, key: string, value: unknown, schema: Property$1): Property | never;
1112
1122
 
1113
- /**
1114
- * Creates a wrapper function that can be used to wrap other functions.
1115
- *
1116
- * @param type The type of the wrapper.
1117
- * @param config The configuration for the wrapper.
1118
- * @returns A wrapper function.
1119
- */
1120
- declare function createWrapper(type?: string, { dryRun, mockReturn, onCall }?: Config): Wrap;
1121
-
1122
- export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, handler as Handler, hooks as Hooks, mapping as Mapping, type MarketingParameters, on as On, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, source as Source, type StorageType, walkeros as WalkerOS, wrapper as Wrapper, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, createSource, createWrapper, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, onLog, parseUserAgent, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty };
1123
+ export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, handler as Handler, hooks as Hooks, mapping as Mapping, type MarketingParameters, on as On, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, source as Source, type StorageType, walkeros as WalkerOS, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, createSource, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, onLog, parseUserAgent, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[o(e)[0]])((t={exports:{}}).exports,t),t.exports}),c={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(c,{Collector:()=>a,Const:()=>k,Data:()=>u,Destination:()=>l,Elb:()=>p,Handler:()=>d,Hooks:()=>g,Mapping:()=>f,On:()=>m,Request:()=>y,Schema:()=>h,Source:()=>b,WalkerOS:()=>w,Wrapper:()=>v,anonymizeIP:()=>x,assign:()=>S,castToProperty:()=>Y,castValue:()=>H,clone:()=>V,createDestination:()=>B,createEvent:()=>q,createSource:()=>z,createWrapper:()=>ve,debounce:()=>G,filterValues:()=>Q,getBrowser:()=>ge,getBrowserVersion:()=>fe,getByPath:()=>_,getDeviceType:()=>he,getEvent:()=>K,getGrantedConsent:()=>L,getHeaders:()=>ae,getId:()=>U,getMappingEvent:()=>te,getMappingValue:()=>ne,getMarketingParameters:()=>F,getOS:()=>me,getOSVersion:()=>ye,isArguments:()=>j,isArray:()=>E,isBoolean:()=>P,isCommand:()=>T,isDefined:()=>A,isElementOrDocument:()=>M,isFunction:()=>C,isNumber:()=>D,isObject:()=>$,isPropertyType:()=>J,isSameType:()=>I,isString:()=>N,onLog:()=>oe,parseUserAgent:()=>de,requestToData:()=>ie,requestToParameter:()=>se,setByPath:()=>R,throttle:()=>X,throwError:()=>ue,transformData:()=>ce,trim:()=>le,tryCatch:()=>Z,tryCatchAsync:()=>ee,useHooks:()=>pe,validateEvent:()=>be,validateProperty:()=>we}),module.exports=(e=>((e,t,s,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of o(t))i.call(e,a)||a===s||n(e,a,{get:()=>t[a],enumerable:!(c=r(t,a))||c.enumerable});return e})(n({},"__esModule",{value:!0}),e))(c);var a={},u={},l={},p={},d={},g={},f={},m={},y={},h={},b={},w={},v={},k={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function x(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var O={merge:!0,shallow:!0,extend:!0};function S(e,t={},n={}){n={...O,...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 j(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function E(e){return Array.isArray(e)}function P(e){return"boolean"==typeof e}function T(e){return"walker"===e}function A(e){return void 0!==e}function M(e){return e===document||e instanceof Element}function C(e){return"function"==typeof e}function D(e){return"number"==typeof e&&!Number.isNaN(e)}function $(e){return"object"==typeof e&&null!==e&&!E(e)&&"[object Object]"===Object.prototype.toString.call(e)}function I(e,t){return typeof e==typeof t}function N(e){return"string"==typeof e}function V(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]=V(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(V(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 _(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&E(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=_(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return A(o)?o:n}function R(e,t,n){const r=V(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}function H(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function L(e,t={},n={}){const r={...t,...n},o={};let i=void 0===e;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(i=!0))}),!!i&&o}function B(e,t){const n={...e};return n.config=S(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=S(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=S(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function z(e,t){return async(n,r)=>{const o=S(r,t,{shallow:!0,merge:!0,extend:!0});return r.settings&&t.settings&&(o.settings=S(r.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e(n,o)}}var{version:W}=s();function q(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=S({event:"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:[{type:"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:W,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.event){const[t,n]=e.event.split(" ")??[];t&&n&&(o.entity=t,o.action=n)}return o}function K(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 q({...{"cart view":{data:{currency:"EUR",value:2*r.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"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:[{type:"product",...r,context:{shopping:["checkout",0]},nested:[]},{type:"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:[{type:"product",...r,context:{shopping:["complete",0]},nested:[]},{type:"product",...o,context:{shopping:["complete",0]},nested:[]},{type:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.elbwalker.com/",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,event:e})}function U(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function F(e,t={}){const n="clickId",r={},o={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:n,fbclid:n,gclid:n,msclkid:n,ttclid:n,twclid:n,igshid:n,sclid:n};return Object.entries(S(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}function G(e,t=1e3,n=!1){let r,o=null,i=!1;return(...s)=>new Promise(c=>{const a=n&&!i;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n&&!i||(r=e(...s),c(r))},t),a&&(i=!0,r=e(...s),c(r))})}function X(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function J(e){return P(e)||N(e)||D(e)||!A(e)||E(e)&&e.every(J)||$(e)&&Object.values(e).every(J)}function Q(e){return P(e)||N(e)||D(e)?e:j(e)?Q(Array.from(e)):E(e)?e.map(e=>Q(e)).filter(e=>void 0!==e):$(e)?Object.entries(e).reduce((e,[t,n])=>{const r=Q(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function Y(e){return J(e)?e:void 0}function Z(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function ee(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 te(e,t){const[n,r]=(e.event||"").split(" ");if(!t||!n||!r)return{};let o,i="",s=n,c=r;const a=t=>{if(t)return(t=E(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const u=t[s];return u&&(u[c]||(c="*"),o=a(u[c])),o||(s="*",c="*",o=a(t[s]?.[c])),o&&(i=`${s} ${c}`),{eventMapping:o,mappingKey:i}}async function ne(e,t={},n={}){if(!A(e))return;const r=$(e)&&e.consent||n.consent||n.collector?.consent,o=E(t)?t:[t];for(const t of o){const o=await ee(re)(e,t,{...n,consent:r});if(A(o))return o}}async function re(e,t,n={}){const{collector:r,consent:o}=n;return(E(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const c=N(i)?{key:i}:i;if(!Object.keys(c).length)return;const{condition:a,consent:u,fn:l,key:p,loop:d,map:g,set:f,validate:m,value:y}=c;if(a&&!await ee(a)(e,i,r))return;if(u&&!L(u,o))return y;let h=A(y)?y:e;if(l&&(h=await ee(l)(e,i,n)),p&&(h=_(e,p,y)),d){const[t,r]=d,o="this"===t?[e]:await ne(e,t,n);E(o)&&(h=(await Promise.all(o.map(e=>ne(e,r,n)))).filter(A))}else g?h=await Object.entries(g).reduce(async(t,[r,o])=>{const i=await t,s=await ne(e,o,n);return A(s)&&(i[r]=s),i},Promise.resolve({})):f&&(h=await Promise.all(f.map(t=>re(e,t,n))));m&&!await ee(m)(h)&&(h=void 0);const b=Y(h);return A(b)?b:Y(y)},Promise.resolve(void 0))}function oe(e,t=!1){t&&console.dir(e,{depth:4})}function ie(e){const t=String(e),n=t.split("?")[1]||t;return Z(()=>{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(E(o)){const s=parseInt(t,10);i?o[s]=H(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else $(o)&&(i?o[t]=H(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function se(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(E(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):$(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 ce(e){return void 0===e||I(e,"")?e:JSON.stringify(e)}function ae(e={}){return S({"Content-Type":"application/json; charset=utf-8"},e)}function ue(e){throw new Error(String(e))}function le(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function pe(e,t,n){return function(...r){let o;const i="post"+t,s=n["pre"+t],c=n[i];return o=s?s({fn:e},...r):e(...r),c&&(o=c({fn:e,result:o},...r)),o}}function de(e){return e?{userAgent:e,browser:ge(e),browserVersion:fe(e),os:me(e),osVersion:ye(e),deviceType:he(e)}:{}}function ge(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 fe(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 me(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 ye(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function he(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 be(e,t=[]){let n,r,o;I(e,{})||ue("Invalid object"),I(e.event,"")?(n=e.event,[r,o]=n.split(" "),r&&o||ue("Invalid event name")):I(e.entity,"")&&I(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):ue("Missing or invalid event, entity, or action");const i={event:n,data:{},context:{},custom:{},globals:{},user:{},nested:[],consent:{},id:"",trigger:"",entity:r,action:o,timestamp:0,timing:0,group:"",count:0,version:{source:"",tagging:0},source:{type:"",id:"",previous_id:""}};return[{"*":{"*":{event:{maxLength:255},user:{allowedKeys:["id","device","session"]},consent:{allowedValues:[!0,!1]},timestamp:{min:0},timing:{min:0},count:{min:0},version:{allowedKeys:["source","tagging"]},source:{allowedKeys:["type","id","previous_id"]}}}}].concat(t).reduce((e,t)=>["*",r].reduce((e,n)=>["*",o].reduce((e,r)=>{const o=t[n]?.[r];return o?e.concat([o]):e},e),e),[]).reduce((t,n)=>{const r=Object.keys(n).filter(e=>{const t=n[e];return!0===t?.required});return[...Object.keys(e),...r].reduce((t,r)=>{const o=n[r];let i=e[r];return o&&(i=Z(we,e=>{ue(String(e))})(t,r,i,o)),I(i,t[r])&&(t[r]=i),t},t)},i)}function we(e,t,n,r){if(r.validate&&(n=Z(r.validate,e=>{ue(String(e))})(n,t,e)),r.required&&void 0===n&&ue("Missing required property"),I(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&ue("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if(I(n,1))I(r.min,1)&&n<r.min?(r.strict&&ue("Value below min"),n=r.min):I(r.max,1)&&n>r.max&&(r.strict&&ue("Value exceeds max"),n=r.max);else if(I(n,{})){if(r.schema){const e=r.schema;Object.keys(e).reduce((t,n)=>{const r=e[n];let o=t[n];return r&&(r.type&&typeof o!==r.type&&ue(`Type doesn't match (${n})`),o=Z(we,e=>{ue(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&ue("Key not allowed"),delete n[e])}return n}function ve(e="unknown",{dryRun:t=!1,mockReturn:n,onCall:r}={}){return function(o,i){return"function"!=typeof i?i:(...s)=>(r&&r({name:o,type:e},s),t?n:i(...s))}}//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.0",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[o(e)[0]])((t={exports:{}}).exports,t),t.exports}),a={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(a,{Collector:()=>c,Const:()=>x,Data:()=>u,Destination:()=>l,Elb:()=>d,Flow:()=>p,Handler:()=>g,Hooks:()=>m,Mapping:()=>f,On:()=>y,Request:()=>h,Schema:()=>b,Source:()=>w,WalkerOS:()=>v,anonymizeIP:()=>k,assign:()=>S,castToProperty:()=>Y,castValue:()=>L,clone:()=>V,createDestination:()=>R,createEvent:()=>K,createSource:()=>z,debounce:()=>G,filterValues:()=>Q,getBrowser:()=>ge,getBrowserVersion:()=>me,getByPath:()=>_,getDeviceType:()=>he,getEvent:()=>U,getGrantedConsent:()=>B,getHeaders:()=>ce,getId:()=>W,getMappingEvent:()=>te,getMappingValue:()=>ne,getMarketingParameters:()=>F,getOS:()=>fe,getOSVersion:()=>ye,isArguments:()=>j,isArray:()=>E,isBoolean:()=>P,isCommand:()=>T,isDefined:()=>A,isElementOrDocument:()=>M,isFunction:()=>D,isNumber:()=>C,isObject:()=>$,isPropertyType:()=>J,isSameType:()=>I,isString:()=>N,onLog:()=>oe,parseUserAgent:()=>pe,requestToData:()=>ie,requestToParameter:()=>se,setByPath:()=>H,throttle:()=>X,throwError:()=>ue,transformData:()=>ae,trim:()=>le,tryCatch:()=>Z,tryCatchAsync:()=>ee,useHooks:()=>de,validateEvent:()=>be,validateProperty:()=>we}),module.exports=(e=>((e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of o(t))i.call(e,c)||c===s||n(e,c,{get:()=>t[c],enumerable:!(a=r(t,c))||a.enumerable});return e})(n({},"__esModule",{value:!0}),e))(a);var c={},u={},l={},d={},p={},g={},m={},f={},y={},h={},b={},w={},v={},x={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function k(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var O={merge:!0,shallow:!0,extend:!0};function S(e,t={},n={}){n={...O,...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 j(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function E(e){return Array.isArray(e)}function P(e){return"boolean"==typeof e}function T(e){return"walker"===e}function A(e){return void 0!==e}function M(e){return e===document||e instanceof Element}function D(e){return"function"==typeof e}function C(e){return"number"==typeof e&&!Number.isNaN(e)}function $(e){return"object"==typeof e&&null!==e&&!E(e)&&"[object Object]"===Object.prototype.toString.call(e)}function I(e,t){return typeof e==typeof t}function N(e){return"string"==typeof e}function V(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]=V(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(V(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 _(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&E(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=_(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return A(o)?o:n}function H(e,t,n){const r=V(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}function L(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function B(e,t={},n={}){const r={...t,...n},o={};let i=void 0===e;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(i=!0))}),!!i&&o}function R(e,t){const n={...e};return n.config=S(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=S(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=S(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function z(e,t){return async(n,r)=>{const o=S(r,t,{shallow:!0,merge:!0,extend:!0});return r.settings&&t.settings&&(o.settings=S(r.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e(n,o)}}var{version:q}=s();function K(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=S({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:q,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 U(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 K({...{"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.elbwalker.com/",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 W(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function F(e,t={}){const n="clickId",r={},o={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:n,fbclid:n,gclid:n,msclkid:n,ttclid:n,twclid:n,igshid:n,sclid:n};return Object.entries(S(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}function G(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 X(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function J(e){return P(e)||N(e)||C(e)||!A(e)||E(e)&&e.every(J)||$(e)&&Object.values(e).every(J)}function Q(e){return P(e)||N(e)||C(e)?e:j(e)?Q(Array.from(e)):E(e)?e.map(e=>Q(e)).filter(e=>void 0!==e):$(e)?Object.entries(e).reduce((e,[t,n])=>{const r=Q(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function Y(e){return J(e)?e:void 0}function Z(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function ee(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 te(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=E(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 ne(e,t={},n={}){if(!A(e))return;const r=$(e)&&e.consent||n.consent||n.collector?.consent,o=E(t)?t:[t];for(const t of o){const o=await ee(re)(e,t,{...n,consent:r});if(A(o))return o}}async function re(e,t,n={}){const{collector:r,consent:o}=n;return(E(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const a=N(i)?{key:i}:i;if(!Object.keys(a).length)return;const{condition:c,consent:u,fn:l,key:d,loop:p,map:g,set:m,validate:f,value:y}=a;if(c&&!await ee(c)(e,i,r))return;if(u&&!B(u,o))return y;let h=A(y)?y:e;if(l&&(h=await ee(l)(e,i,n)),d&&(h=_(e,d,y)),p){const[t,r]=p,o="this"===t?[e]:await ne(e,t,n);E(o)&&(h=(await Promise.all(o.map(e=>ne(e,r,n)))).filter(A))}else g?h=await Object.entries(g).reduce(async(t,[r,o])=>{const i=await t,s=await ne(e,o,n);return A(s)&&(i[r]=s),i},Promise.resolve({})):m&&(h=await Promise.all(m.map(t=>re(e,t,n))));f&&!await ee(f)(h)&&(h=void 0);const b=Y(h);return A(b)?b:Y(y)},Promise.resolve(void 0))}function oe(e,t=!1){t&&console.dir(e,{depth:4})}function ie(e){const t=String(e),n=t.split("?")[1]||t;return Z(()=>{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(E(o)){const s=parseInt(t,10);i?o[s]=L(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else $(o)&&(i?o[t]=L(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function se(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(E(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):$(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 ae(e){return void 0===e||I(e,"")?e:JSON.stringify(e)}function ce(e={}){return S({"Content-Type":"application/json; charset=utf-8"},e)}function ue(e){throw new Error(String(e))}function le(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function de(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 pe(e){return e?{userAgent:e,browser:ge(e),browserVersion:me(e),os:fe(e),osVersion:ye(e),deviceType:he(e)}:{}}function ge(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 me(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 fe(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 ye(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function he(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 be(e,t=[]){let n,r,o;I(e,{})||ue("Invalid object"),I(e.name,"")?(n=e.name,[r,o]=n.split(" "),r&&o||ue("Invalid event name")):I(e.entity,"")&&I(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):ue("Missing or invalid name, entity, or action");const i={name:n,data:{},context:{},custom:{},globals:{},user:{},nested:[],consent:{},id:"",trigger:"",entity:r,action:o,timestamp:0,timing:0,group:"",count:0,version:{source:"",tagging:0},source:{type:"",id:"",previous_id:""}};return[{"*":{"*":{name:{maxLength:255},user:{allowedKeys:["id","device","session"]},consent:{allowedValues:[!0,!1]},timestamp:{min:0},timing:{min:0},count:{min:0},version:{allowedKeys:["source","tagging"]},source:{allowedKeys:["type","id","previous_id"]}}}}].concat(t).reduce((e,t)=>["*",r].reduce((e,n)=>["*",o].reduce((e,r)=>{const o=t[n]?.[r];return o?e.concat([o]):e},e),e),[]).reduce((t,n)=>{const r=Object.keys(n).filter(e=>{const t=n[e];return!0===t?.required});return[...Object.keys(e),...r].reduce((t,r)=>{const o=n[r];let i=e[r];return o&&(i=Z(we,e=>{ue(String(e))})(t,r,i,o)),I(i,t[r])&&(t[r]=i),t},t)},i)}function we(e,t,n,r){if(r.validate&&(n=Z(r.validate,e=>{ue(String(e))})(n,t,e)),r.required&&void 0===n&&ue("Missing required property"),I(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&ue("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if(I(n,1))I(r.min,1)&&n<r.min?(r.strict&&ue("Value below min"),n=r.min):I(r.max,1)&&n>r.max&&(r.strict&&ue("Value exceeds max"),n=r.max);else if(I(n,{})){if(r.schema){const e=r.schema;Object.keys(e).reduce((t,n)=>{const r=e[n];let o=t[n];return r&&(r.type&&typeof o!==r.type&&ue(`Type doesn't match (${n})`),o=Z(we,e=>{ue(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&ue("Key not allowed"),delete n[e])}return n}//# sourceMappingURL=index.js.map