@walkeros/core 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -182,10 +182,11 @@ interface BaseEnv$1 {
182
182
  }
183
183
  /**
184
184
  * Type bundle for destination generics.
185
- * Groups Settings, Mapping, and Env into a single type parameter.
185
+ * Groups Settings, InitSettings, Mapping, and Env into a single type parameter.
186
186
  */
187
- interface Types$2<S = unknown, M = unknown, E = BaseEnv$1> {
187
+ interface Types$2<S = unknown, M = unknown, E = BaseEnv$1, I = S> {
188
188
  settings: S;
189
+ initSettings: I;
189
190
  mapping: M;
190
191
  env: E;
191
192
  }
@@ -194,6 +195,7 @@ interface Types$2<S = unknown, M = unknown, E = BaseEnv$1> {
194
195
  */
195
196
  type TypesGeneric$1 = {
196
197
  settings: any;
198
+ initSettings: any;
197
199
  mapping: any;
198
200
  env: any;
199
201
  };
@@ -201,6 +203,7 @@ type TypesGeneric$1 = {
201
203
  * Type extractors for consistent usage with Types bundle
202
204
  */
203
205
  type Settings$1<T extends TypesGeneric$1 = Types$2> = T['settings'];
206
+ type InitSettings$1<T extends TypesGeneric$1 = Types$2> = T['initSettings'];
204
207
  type Mapping$1<T extends TypesGeneric$1 = Types$2> = T['mapping'];
205
208
  type Env$1<T extends TypesGeneric$1 = Types$2> = T['env'];
206
209
  /**
@@ -220,7 +223,7 @@ interface Instance$1<T extends TypesGeneric$1 = Types$2> {
220
223
  }
221
224
  interface Config$4<T extends TypesGeneric$1 = Types$2> {
222
225
  consent?: Consent;
223
- settings?: Settings$1<T>;
226
+ settings?: InitSettings$1<T>;
224
227
  data?: Value | Values;
225
228
  env?: Env$1<T>;
226
229
  id?: string;
@@ -310,7 +313,7 @@ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
310
313
  type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
311
314
  type destination_Ref = Ref;
312
315
  declare namespace destination {
313
- export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$4 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, Instance$1 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 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, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
316
+ export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$4 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, InitSettings$1 as InitSettings, Instance$1 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 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, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
314
317
  }
315
318
 
316
319
  interface EventFn<R = Promise<PushResult>> {
@@ -1015,15 +1018,17 @@ interface BaseEnv {
1015
1018
  }
1016
1019
  /**
1017
1020
  * Type bundle for source generics.
1018
- * Groups Settings, Mapping, Push, and Env into a single type parameter.
1021
+ * Groups Settings, Mapping, Push, Env, and InitSettings into a single type parameter.
1019
1022
  *
1020
1023
  * @template S - Settings configuration type
1021
1024
  * @template M - Mapping configuration type
1022
1025
  * @template P - Push function signature (flexible to support HTTP handlers, etc.)
1023
1026
  * @template E - Environment dependencies type
1027
+ * @template I - InitSettings configuration type (user input)
1024
1028
  */
1025
- interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> {
1029
+ interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> {
1026
1030
  settings: S;
1031
+ initSettings: I;
1027
1032
  mapping: M;
1028
1033
  push: P;
1029
1034
  env: E;
@@ -1033,6 +1038,7 @@ interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> {
1033
1038
  */
1034
1039
  type TypesGeneric = {
1035
1040
  settings: any;
1041
+ initSettings: any;
1036
1042
  mapping: any;
1037
1043
  push: any;
1038
1044
  env: any;
@@ -1041,6 +1047,7 @@ type TypesGeneric = {
1041
1047
  * Type extractors for consistent usage with Types bundle
1042
1048
  */
1043
1049
  type Settings<T extends TypesGeneric = Types> = T['settings'];
1050
+ type InitSettings<T extends TypesGeneric = Types> = T['initSettings'];
1044
1051
  type Mapping<T extends TypesGeneric = Types> = T['mapping'];
1045
1052
  type Push<T extends TypesGeneric = Types> = T['push'];
1046
1053
  type Env<T extends TypesGeneric = Types> = T['env'];
@@ -1049,7 +1056,7 @@ type Env<T extends TypesGeneric = Types> = T['env'];
1049
1056
  */
1050
1057
  type TypesOf<I> = I extends Instance<infer T> ? T : never;
1051
1058
  interface Config<T extends TypesGeneric = Types> extends Config$2<Mapping<T>> {
1052
- settings?: Settings<T>;
1059
+ settings?: InitSettings<T>;
1053
1060
  env?: Env<T>;
1054
1061
  id?: string;
1055
1062
  onError?: Error;
@@ -1083,6 +1090,7 @@ type source_BaseEnv = BaseEnv;
1083
1090
  type source_Config<T extends TypesGeneric = Types> = Config<T>;
1084
1091
  type source_Env<T extends TypesGeneric = Types> = Env<T>;
1085
1092
  type source_Init<T extends TypesGeneric = Types> = Init<T>;
1093
+ type source_InitSettings<T extends TypesGeneric = Types> = InitSettings<T>;
1086
1094
  type source_InitSource<T extends TypesGeneric = Types> = InitSource<T>;
1087
1095
  type source_InitSources = InitSources;
1088
1096
  type source_Instance<T extends TypesGeneric = Types> = Instance<T>;
@@ -1090,11 +1098,11 @@ type source_Mapping<T extends TypesGeneric = Types> = Mapping<T>;
1090
1098
  type source_PartialConfig<T extends TypesGeneric = Types> = PartialConfig<T>;
1091
1099
  type source_Push<T extends TypesGeneric = Types> = Push<T>;
1092
1100
  type source_Settings<T extends TypesGeneric = Types> = Settings<T>;
1093
- type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> = Types<S, M, P, E>;
1101
+ type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> = Types<S, M, P, E, I>;
1094
1102
  type source_TypesGeneric = TypesGeneric;
1095
1103
  type source_TypesOf<I> = TypesOf<I>;
1096
1104
  declare namespace source {
1097
- export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Env as Env, source_Init as Init, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Settings as Settings, source_Types as Types, source_TypesGeneric as TypesGeneric, source_TypesOf as TypesOf };
1105
+ export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Env as Env, source_Init as Init, source_InitSettings as InitSettings, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Settings as Settings, source_Types as Types, source_TypesGeneric as TypesGeneric, source_TypesOf as TypesOf };
1098
1106
  }
1099
1107
 
1100
1108
  type AnyObject<T = unknown> = Record<string, T>;
package/dist/index.d.ts CHANGED
@@ -182,10 +182,11 @@ interface BaseEnv$1 {
182
182
  }
183
183
  /**
184
184
  * Type bundle for destination generics.
185
- * Groups Settings, Mapping, and Env into a single type parameter.
185
+ * Groups Settings, InitSettings, Mapping, and Env into a single type parameter.
186
186
  */
187
- interface Types$2<S = unknown, M = unknown, E = BaseEnv$1> {
187
+ interface Types$2<S = unknown, M = unknown, E = BaseEnv$1, I = S> {
188
188
  settings: S;
189
+ initSettings: I;
189
190
  mapping: M;
190
191
  env: E;
191
192
  }
@@ -194,6 +195,7 @@ interface Types$2<S = unknown, M = unknown, E = BaseEnv$1> {
194
195
  */
195
196
  type TypesGeneric$1 = {
196
197
  settings: any;
198
+ initSettings: any;
197
199
  mapping: any;
198
200
  env: any;
199
201
  };
@@ -201,6 +203,7 @@ type TypesGeneric$1 = {
201
203
  * Type extractors for consistent usage with Types bundle
202
204
  */
203
205
  type Settings$1<T extends TypesGeneric$1 = Types$2> = T['settings'];
206
+ type InitSettings$1<T extends TypesGeneric$1 = Types$2> = T['initSettings'];
204
207
  type Mapping$1<T extends TypesGeneric$1 = Types$2> = T['mapping'];
205
208
  type Env$1<T extends TypesGeneric$1 = Types$2> = T['env'];
206
209
  /**
@@ -220,7 +223,7 @@ interface Instance$1<T extends TypesGeneric$1 = Types$2> {
220
223
  }
221
224
  interface Config$4<T extends TypesGeneric$1 = Types$2> {
222
225
  consent?: Consent;
223
- settings?: Settings$1<T>;
226
+ settings?: InitSettings$1<T>;
224
227
  data?: Value | Values;
225
228
  env?: Env$1<T>;
226
229
  id?: string;
@@ -310,7 +313,7 @@ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
310
313
  type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
311
314
  type destination_Ref = Ref;
312
315
  declare namespace destination {
313
- export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$4 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, Instance$1 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 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, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
316
+ export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$4 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, InitSettings$1 as InitSettings, Instance$1 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 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, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
314
317
  }
315
318
 
316
319
  interface EventFn<R = Promise<PushResult>> {
@@ -1015,15 +1018,17 @@ interface BaseEnv {
1015
1018
  }
1016
1019
  /**
1017
1020
  * Type bundle for source generics.
1018
- * Groups Settings, Mapping, Push, and Env into a single type parameter.
1021
+ * Groups Settings, Mapping, Push, Env, and InitSettings into a single type parameter.
1019
1022
  *
1020
1023
  * @template S - Settings configuration type
1021
1024
  * @template M - Mapping configuration type
1022
1025
  * @template P - Push function signature (flexible to support HTTP handlers, etc.)
1023
1026
  * @template E - Environment dependencies type
1027
+ * @template I - InitSettings configuration type (user input)
1024
1028
  */
1025
- interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> {
1029
+ interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> {
1026
1030
  settings: S;
1031
+ initSettings: I;
1027
1032
  mapping: M;
1028
1033
  push: P;
1029
1034
  env: E;
@@ -1033,6 +1038,7 @@ interface Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> {
1033
1038
  */
1034
1039
  type TypesGeneric = {
1035
1040
  settings: any;
1041
+ initSettings: any;
1036
1042
  mapping: any;
1037
1043
  push: any;
1038
1044
  env: any;
@@ -1041,6 +1047,7 @@ type TypesGeneric = {
1041
1047
  * Type extractors for consistent usage with Types bundle
1042
1048
  */
1043
1049
  type Settings<T extends TypesGeneric = Types> = T['settings'];
1050
+ type InitSettings<T extends TypesGeneric = Types> = T['initSettings'];
1044
1051
  type Mapping<T extends TypesGeneric = Types> = T['mapping'];
1045
1052
  type Push<T extends TypesGeneric = Types> = T['push'];
1046
1053
  type Env<T extends TypesGeneric = Types> = T['env'];
@@ -1049,7 +1056,7 @@ type Env<T extends TypesGeneric = Types> = T['env'];
1049
1056
  */
1050
1057
  type TypesOf<I> = I extends Instance<infer T> ? T : never;
1051
1058
  interface Config<T extends TypesGeneric = Types> extends Config$2<Mapping<T>> {
1052
- settings?: Settings<T>;
1059
+ settings?: InitSettings<T>;
1053
1060
  env?: Env<T>;
1054
1061
  id?: string;
1055
1062
  onError?: Error;
@@ -1083,6 +1090,7 @@ type source_BaseEnv = BaseEnv;
1083
1090
  type source_Config<T extends TypesGeneric = Types> = Config<T>;
1084
1091
  type source_Env<T extends TypesGeneric = Types> = Env<T>;
1085
1092
  type source_Init<T extends TypesGeneric = Types> = Init<T>;
1093
+ type source_InitSettings<T extends TypesGeneric = Types> = InitSettings<T>;
1086
1094
  type source_InitSource<T extends TypesGeneric = Types> = InitSource<T>;
1087
1095
  type source_InitSources = InitSources;
1088
1096
  type source_Instance<T extends TypesGeneric = Types> = Instance<T>;
@@ -1090,11 +1098,11 @@ type source_Mapping<T extends TypesGeneric = Types> = Mapping<T>;
1090
1098
  type source_PartialConfig<T extends TypesGeneric = Types> = PartialConfig<T>;
1091
1099
  type source_Push<T extends TypesGeneric = Types> = Push<T>;
1092
1100
  type source_Settings<T extends TypesGeneric = Types> = Settings<T>;
1093
- type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv> = Types<S, M, P, E>;
1101
+ type source_Types<S = unknown, M = unknown, P = Fn$1, E = BaseEnv, I = S> = Types<S, M, P, E, I>;
1094
1102
  type source_TypesGeneric = TypesGeneric;
1095
1103
  type source_TypesOf<I> = TypesOf<I>;
1096
1104
  declare namespace source {
1097
- export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Env as Env, source_Init as Init, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Settings as Settings, source_Types as Types, source_TypesGeneric as TypesGeneric, source_TypesOf as TypesOf };
1105
+ export type { source_BaseEnv as BaseEnv, source_Config as Config, source_Env as Env, source_Init as Init, source_InitSettings as InitSettings, source_InitSource as InitSource, source_InitSources as InitSources, source_Instance as Instance, source_Mapping as Mapping, source_PartialConfig as PartialConfig, source_Push as Push, source_Settings as Settings, source_Types as Types, source_TypesGeneric as TypesGeneric, source_TypesOf as TypesOf };
1098
1106
  }
1099
1107
 
1100
1108
  type AnyObject<T = unknown> = Record<string, T>;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(i,{Collector:()=>s,Const:()=>w,Data:()=>a,Destination:()=>c,Elb:()=>u,Flow:()=>l,Handler:()=>p,Hooks:()=>d,Mapping:()=>g,On:()=>f,Request:()=>m,Schema:()=>y,Source:()=>b,WalkerOS:()=>h,anonymizeIP:()=>v,assign:()=>O,castToProperty:()=>X,castValue:()=>_,clone:()=>N,createDestination:()=>L,createEvent:()=>B,debounce:()=>q,filterValues:()=>F,getBrowser:()=>de,getBrowserVersion:()=>ge,getByPath:()=>I,getDeviceType:()=>ye,getEvent:()=>H,getGrantedConsent:()=>K,getHeaders:()=>ae,getId:()=>R,getMappingEvent:()=>Q,getMappingValue:()=>Y,getMarketingParameters:()=>z,getOS:()=>fe,getOSVersion:()=>me,isArguments:()=>j,isArray:()=>S,isBoolean:()=>k,isCommand:()=>E,isDefined:()=>P,isElementOrDocument:()=>A,isFunction:()=>M,isNumber:()=>T,isObject:()=>D,isPropertyType:()=>W,isSameType:()=>$,isString:()=>C,mockEnv:()=>te,onLog:()=>re,parseUserAgent:()=>pe,processEventMapping:()=>ee,requestToData:()=>oe,requestToParameter:()=>ie,setByPath:()=>V,throttle:()=>U,throwError:()=>ce,transformData:()=>se,traverseEnv:()=>ne,trim:()=>ue,tryCatch:()=>G,tryCatchAsync:()=>J,useHooks:()=>le,validateEvent:()=>be,validateProperty:()=>he}),module.exports=(e=i,((e,i,s,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of r(i))o.call(e,c)||c===s||t(e,c,{get:()=>i[c],enumerable:!(a=n(i,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={},a={},c={},u={},l={},p={},d={},g={},f={},m={},y={},b={},h={},w={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function v(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var x={merge:!0,shallow:!0,extend:!0};function O(e,t={},n={}){n={...x,...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 S(e){return Array.isArray(e)}function k(e){return"boolean"==typeof e}function E(e){return"walker"===e}function P(e){return void 0!==e}function A(e){return e===document||e instanceof Element}function M(e){return"function"==typeof e}function T(e){return"number"==typeof e&&!Number.isNaN(e)}function D(e){return"object"==typeof e&&null!==e&&!S(e)&&"[object Object]"===Object.prototype.toString.call(e)}function $(e,t){return typeof e==typeof t}function C(e){return"string"==typeof e}function N(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]=N(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(N(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 I(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&S(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=I(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return P(o)?o:n}function V(e,t,n){if(!D(e))return e;const r=N(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 _(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function K(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 L(e,t){const n={...e};return n.config=O(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=O(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=O(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function B(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=O({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:"0.3.1",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 H(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 B({...{"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 R(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function z(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(O(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}function q(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 U(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function W(e){return k(e)||C(e)||T(e)||!P(e)||S(e)&&e.every(W)||D(e)&&Object.values(e).every(W)}function F(e){return k(e)||C(e)||T(e)?e:j(e)?F(Array.from(e)):S(e)?e.map(e=>F(e)).filter(e=>void 0!==e):D(e)?Object.entries(e).reduce((e,[t,n])=>{const r=F(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function X(e){return W(e)?e:void 0}function G(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function J(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 Q(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=S(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 Y(e,t={},n={}){if(!P(e))return;const r=D(e)&&e.consent||n.consent||n.collector?.consent,o=S(t)?t:[t];for(const t of o){const o=await J(Z)(e,t,{...n,consent:r});if(P(o))return o}}async function Z(e,t,n={}){const{collector:r,consent:o}=n;return(S(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const a=C(i)?{key:i}:i;if(!Object.keys(a).length)return;const{condition:c,consent:u,fn:l,key:p,loop:d,map:g,set:f,validate:m,value:y}=a;if(c&&!await J(c)(e,i,r))return;if(u&&!K(u,o))return y;let b=P(y)?y:e;if(l&&(b=await J(l)(e,i,n)),p&&(b=I(e,p,y)),d){const[t,r]=d,o="this"===t?[e]:await Y(e,t,n);S(o)&&(b=(await Promise.all(o.map(e=>Y(e,r,n)))).filter(P))}else g?b=await Object.entries(g).reduce(async(t,[r,o])=>{const i=await t,s=await Y(e,o,n);return P(s)&&(i[r]=s),i},Promise.resolve({})):f&&(b=await Promise.all(f.map(t=>Z(e,t,n))));m&&!await J(m)(b)&&(b=void 0);const h=X(b);return P(h)?h:X(y)},Promise.resolve(void 0))}async function ee(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await Y(e,r,{collector:n});e=V(e,t,o)}));const{eventMapping:r,mappingKey:o}=await Q(e,t.mapping);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await Y(e,r,{collector:n});e=V(e,t,o)}));let i=t.data&&await Y(e,t.data,{collector:n});if(r){if(r.ignore)return{event:e,data:i,mapping:r,mappingKey:o,ignore:!0};if(r.name&&(e.name=r.name),r.data){const t=r.data&&await Y(e,r.data,{collector:n});i=D(i)&&D(t)?O(i,t):t}}return{event:e,data:i,mapping:r,mappingKey:o,ignore:!1}}function te(e,t){const n=(e,r=[])=>new Proxy(e,{get(e,o){const i=e[o],s=[...r,o];return"function"==typeof i?(...e)=>t(s,e,i):i&&"object"==typeof i?n(i,s):i}});return n(e)}function ne(e,t){const n=(e,r=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...r,i];Array.isArray(o)?o[Number(i)]=t(s,e):o[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(o)?o[Number(i)]=n(s,e):o[i]=n(s,e))}return o};return n(e)}function re(e,t=!1){t&&console.dir(e,{depth:4})}function oe(e){const t=String(e),n=t.split("?")[1]||t;return G(()=>{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(S(o)){const s=parseInt(t,10);i?o[s]=_(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else D(o)&&(i?o[t]=_(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function ie(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(S(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):D(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 se(e){return void 0===e||$(e,"")?e:JSON.stringify(e)}function ae(e={}){return O({"Content-Type":"application/json; charset=utf-8"},e)}function ce(e){throw new Error(String(e))}function ue(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function le(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:de(e),browserVersion:ge(e),os:fe(e),osVersion:me(e),deviceType:ye(e)}:{}}function de(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 ge(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 me(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function ye(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;$(e,{})||ce("Invalid object"),$(e.name,"")?(n=e.name,[r,o]=n.split(" "),r&&o||ce("Invalid event name")):$(e.entity,"")&&$(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):ce("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=G(he,e=>{ce(String(e))})(t,r,i,o)),$(i,t[r])&&(t[r]=i),t},t)},i)}function he(e,t,n,r){if(r.validate&&(n=G(r.validate,e=>{ce(String(e))})(n,t,e)),r.required&&void 0===n&&ce("Missing required property"),$(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&ce("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if($(n,1))$(r.min,1)&&n<r.min?(r.strict&&ce("Value below min"),n=r.min):$(r.max,1)&&n>r.max&&(r.strict&&ce("Value exceeds max"),n=r.max);else if($(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&&ce(`Type doesn't match (${n})`),o=G(he,e=>{ce(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&ce("Key not allowed"),delete n[e])}return n}//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(i,{Collector:()=>s,Const:()=>w,Data:()=>a,Destination:()=>c,Elb:()=>u,Flow:()=>l,Handler:()=>p,Hooks:()=>d,Mapping:()=>g,On:()=>f,Request:()=>m,Schema:()=>y,Source:()=>b,WalkerOS:()=>h,anonymizeIP:()=>v,assign:()=>O,castToProperty:()=>X,castValue:()=>_,clone:()=>N,createDestination:()=>L,createEvent:()=>B,debounce:()=>q,filterValues:()=>F,getBrowser:()=>de,getBrowserVersion:()=>ge,getByPath:()=>I,getDeviceType:()=>ye,getEvent:()=>H,getGrantedConsent:()=>K,getHeaders:()=>ae,getId:()=>R,getMappingEvent:()=>Q,getMappingValue:()=>Y,getMarketingParameters:()=>z,getOS:()=>fe,getOSVersion:()=>me,isArguments:()=>j,isArray:()=>S,isBoolean:()=>k,isCommand:()=>E,isDefined:()=>P,isElementOrDocument:()=>A,isFunction:()=>M,isNumber:()=>T,isObject:()=>D,isPropertyType:()=>W,isSameType:()=>$,isString:()=>C,mockEnv:()=>te,onLog:()=>re,parseUserAgent:()=>pe,processEventMapping:()=>ee,requestToData:()=>oe,requestToParameter:()=>ie,setByPath:()=>V,throttle:()=>U,throwError:()=>ce,transformData:()=>se,traverseEnv:()=>ne,trim:()=>ue,tryCatch:()=>G,tryCatchAsync:()=>J,useHooks:()=>le,validateEvent:()=>be,validateProperty:()=>he}),module.exports=(e=i,((e,i,s,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of r(i))o.call(e,c)||c===s||t(e,c,{get:()=>i[c],enumerable:!(a=n(i,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={},a={},c={},u={},l={},p={},d={},g={},f={},m={},y={},b={},h={},w={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function v(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var x={merge:!0,shallow:!0,extend:!0};function O(e,t={},n={}){n={...x,...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 S(e){return Array.isArray(e)}function k(e){return"boolean"==typeof e}function E(e){return"walker"===e}function P(e){return void 0!==e}function A(e){return e===document||e instanceof Element}function M(e){return"function"==typeof e}function T(e){return"number"==typeof e&&!Number.isNaN(e)}function D(e){return"object"==typeof e&&null!==e&&!S(e)&&"[object Object]"===Object.prototype.toString.call(e)}function $(e,t){return typeof e==typeof t}function C(e){return"string"==typeof e}function N(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]=N(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(N(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 I(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&S(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=I(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return P(o)?o:n}function V(e,t,n){if(!D(e))return e;const r=N(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 _(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function K(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 L(e,t){const n={...e};return n.config=O(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=O(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=O(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function B(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=O({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:"0.4.1",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 H(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 B({...{"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 R(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function z(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(O(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}function q(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 U(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function W(e){return k(e)||C(e)||T(e)||!P(e)||S(e)&&e.every(W)||D(e)&&Object.values(e).every(W)}function F(e){return k(e)||C(e)||T(e)?e:j(e)?F(Array.from(e)):S(e)?e.map(e=>F(e)).filter(e=>void 0!==e):D(e)?Object.entries(e).reduce((e,[t,n])=>{const r=F(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function X(e){return W(e)?e:void 0}function G(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function J(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 Q(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=S(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 Y(e,t={},n={}){if(!P(e))return;const r=D(e)&&e.consent||n.consent||n.collector?.consent,o=S(t)?t:[t];for(const t of o){const o=await J(Z)(e,t,{...n,consent:r});if(P(o))return o}}async function Z(e,t,n={}){const{collector:r,consent:o}=n;return(S(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const a=C(i)?{key:i}:i;if(!Object.keys(a).length)return;const{condition:c,consent:u,fn:l,key:p,loop:d,map:g,set:f,validate:m,value:y}=a;if(c&&!await J(c)(e,i,r))return;if(u&&!K(u,o))return y;let b=P(y)?y:e;if(l&&(b=await J(l)(e,i,n)),p&&(b=I(e,p,y)),d){const[t,r]=d,o="this"===t?[e]:await Y(e,t,n);S(o)&&(b=(await Promise.all(o.map(e=>Y(e,r,n)))).filter(P))}else g?b=await Object.entries(g).reduce(async(t,[r,o])=>{const i=await t,s=await Y(e,o,n);return P(s)&&(i[r]=s),i},Promise.resolve({})):f&&(b=await Promise.all(f.map(t=>Z(e,t,n))));m&&!await J(m)(b)&&(b=void 0);const h=X(b);return P(h)?h:X(y)},Promise.resolve(void 0))}async function ee(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await Y(e,r,{collector:n});e=V(e,t,o)}));const{eventMapping:r,mappingKey:o}=await Q(e,t.mapping);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await Y(e,r,{collector:n});e=V(e,t,o)}));let i=t.data&&await Y(e,t.data,{collector:n});if(r){if(r.ignore)return{event:e,data:i,mapping:r,mappingKey:o,ignore:!0};if(r.name&&(e.name=r.name),r.data){const t=r.data&&await Y(e,r.data,{collector:n});i=D(i)&&D(t)?O(i,t):t}}return{event:e,data:i,mapping:r,mappingKey:o,ignore:!1}}function te(e,t){const n=(e,r=[])=>new Proxy(e,{get(e,o){const i=e[o],s=[...r,o];return"function"==typeof i?(...e)=>t(s,e,i):i&&"object"==typeof i?n(i,s):i}});return n(e)}function ne(e,t){const n=(e,r=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...r,i];Array.isArray(o)?o[Number(i)]=t(s,e):o[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(o)?o[Number(i)]=n(s,e):o[i]=n(s,e))}return o};return n(e)}function re(e,t=!1){t&&console.dir(e,{depth:4})}function oe(e){const t=String(e),n=t.split("?")[1]||t;return G(()=>{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(S(o)){const s=parseInt(t,10);i?o[s]=_(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else D(o)&&(i?o[t]=_(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function ie(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(S(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):D(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 se(e){return void 0===e||$(e,"")?e:JSON.stringify(e)}function ae(e={}){return O({"Content-Type":"application/json; charset=utf-8"},e)}function ce(e){throw new Error(String(e))}function ue(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function le(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:de(e),browserVersion:ge(e),os:fe(e),osVersion:me(e),deviceType:ye(e)}:{}}function de(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 ge(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 me(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function ye(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;$(e,{})||ce("Invalid object"),$(e.name,"")?(n=e.name,[r,o]=n.split(" "),r&&o||ce("Invalid event name")):$(e.entity,"")&&$(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):ce("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=G(he,e=>{ce(String(e))})(t,r,i,o)),$(i,t[r])&&(t[r]=i),t},t)},i)}function he(e,t,n,r){if(r.validate&&(n=G(r.validate,e=>{ce(String(e))})(n,t,e)),r.required&&void 0===n&&ce("Missing required property"),$(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&ce("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if($(n,1))$(r.min,1)&&n<r.min?(r.strict&&ce("Value below min"),n=r.min):$(r.max,1)&&n>r.max&&(r.strict&&ce("Value exceeds max"),n=r.max);else if($(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&&ce(`Type doesn't match (${n})`),o=G(he,e=>{ce(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&ce("Key not allowed"),delete n[e])}return n}//# sourceMappingURL=index.js.map