@walkeros/core 0.2.0 → 0.2.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.mjs CHANGED
@@ -1 +1 @@
1
- var e={},t={},n={},r={},o={},i={},s={},c={},a={},u={},l={},d={},p={},f={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function g(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var m={merge:!0,shallow:!0,extend:!0};function y(e,t={},n={}){n={...m,...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 h(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function b(e){return Array.isArray(e)}function w(e){return"boolean"==typeof e}function v(e){return"walker"===e}function x(e){return void 0!==e}function j(e){return e===document||e instanceof Element}function k(e){return"function"==typeof e}function S(e){return"number"==typeof e&&!Number.isNaN(e)}function O(e){return"object"==typeof e&&null!==e&&!b(e)&&"[object Object]"===Object.prototype.toString.call(e)}function E(e,t){return typeof e==typeof t}function A(e){return"string"==typeof e}function $(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]=$(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push($(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 M(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&b(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=M(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return x(o)?o:n}function P(e,t,n){const r=$(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 N(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function T(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 I(e,t){const n={...e};return n.config=y(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=y(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=y(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function C(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=y({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.2.0",tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){const[t,n]=e.name.split(" ")??[];t&&n&&(o.entity=t,o.action=n)}return o}function _(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 C({...{"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 D(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function L(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(y(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}function R(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 V(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function z(e){return w(e)||A(e)||S(e)||!x(e)||b(e)&&e.every(z)||O(e)&&Object.values(e).every(z)}function H(e){return w(e)||A(e)||S(e)?e:h(e)?H(Array.from(e)):b(e)?e.map(e=>H(e)).filter(e=>void 0!==e):O(e)?Object.entries(e).reduce((e,[t,n])=>{const r=H(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function K(e){return z(e)?e:void 0}function U(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function W(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,c=r;const a=t=>{if(t)return(t=b(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 B(e,t={},n={}){if(!x(e))return;const r=O(e)&&e.consent||n.consent||n.collector?.consent,o=b(t)?t:[t];for(const t of o){const o=await W(F)(e,t,{...n,consent:r});if(x(o))return o}}async function F(e,t,n={}){const{collector:r,consent:o}=n;return(b(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const c=A(i)?{key:i}:i;if(!Object.keys(c).length)return;const{condition:a,consent:u,fn:l,key:d,loop:p,map:f,set:g,validate:m,value:y}=c;if(a&&!await W(a)(e,i,r))return;if(u&&!T(u,o))return y;let h=x(y)?y:e;if(l&&(h=await W(l)(e,i,n)),d&&(h=M(e,d,y)),p){const[t,r]=p,o="this"===t?[e]:await B(e,t,n);b(o)&&(h=(await Promise.all(o.map(e=>B(e,r,n)))).filter(x))}else f?h=await Object.entries(f).reduce(async(t,[r,o])=>{const i=await t,s=await B(e,o,n);return x(s)&&(i[r]=s),i},Promise.resolve({})):g&&(h=await Promise.all(g.map(t=>F(e,t,n))));m&&!await W(m)(h)&&(h=void 0);const w=K(h);return x(w)?w:K(y)},Promise.resolve(void 0))}function X(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 J(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 G(e,t=!1){t&&console.dir(e,{depth:4})}function Q(e){const t=String(e),n=t.split("?")[1]||t;return U(()=>{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(b(o)){const s=parseInt(t,10);i?o[s]=N(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else O(o)&&(i?o[t]=N(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function Y(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(b(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):O(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 Z(e){return void 0===e||E(e,"")?e:JSON.stringify(e)}function ee(e={}){return y({"Content-Type":"application/json; charset=utf-8"},e)}function te(e){throw new Error(String(e))}function ne(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function re(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 oe(e){return e?{userAgent:e,browser:ie(e),browserVersion:se(e),os:ce(e),osVersion:ae(e),deviceType:ue(e)}:{}}function ie(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 se(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 ce(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 ae(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function ue(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 le(e,t=[]){let n,r,o;E(e,{})||te("Invalid object"),E(e.name,"")?(n=e.name,[r,o]=n.split(" "),r&&o||te("Invalid event name")):E(e.entity,"")&&E(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):te("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=U(de,e=>{te(String(e))})(t,r,i,o)),E(i,t[r])&&(t[r]=i),t},t)},i)}function de(e,t,n,r){if(r.validate&&(n=U(r.validate,e=>{te(String(e))})(n,t,e)),r.required&&void 0===n&&te("Missing required property"),E(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&te("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if(E(n,1))E(r.min,1)&&n<r.min?(r.strict&&te("Value below min"),n=r.min):E(r.max,1)&&n>r.max&&(r.strict&&te("Value exceeds max"),n=r.max);else if(E(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&&te(`Type doesn't match (${n})`),o=U(de,e=>{te(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&te("Key not allowed"),delete n[e])}return n}export{e as Collector,f as Const,t as Data,n as Destination,r as Elb,o as Flow,i as Handler,s as Hooks,c as Mapping,a as On,u as Request,l as Schema,d as Source,p as WalkerOS,g as anonymizeIP,y as assign,K as castToProperty,N as castValue,$ as clone,I as createDestination,C as createEvent,R as debounce,H as filterValues,ie as getBrowser,se as getBrowserVersion,M as getByPath,ue as getDeviceType,_ as getEvent,T as getGrantedConsent,ee as getHeaders,D as getId,q as getMappingEvent,B as getMappingValue,L as getMarketingParameters,ce as getOS,ae as getOSVersion,h as isArguments,b as isArray,w as isBoolean,v as isCommand,x as isDefined,j as isElementOrDocument,k as isFunction,S as isNumber,O as isObject,z as isPropertyType,E as isSameType,A as isString,X as mockEnv,G as onLog,oe as parseUserAgent,Q as requestToData,Y as requestToParameter,P as setByPath,V as throttle,te as throwError,Z as transformData,J as traverseEnv,ne as trim,U as tryCatch,W as tryCatchAsync,re as useHooks,le as validateEvent,de as validateProperty};//# sourceMappingURL=index.mjs.map
1
+ var e={},t={},n={},r={},o={},i={},s={},a={},c={},u={},l={},p={},m={},d={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};import{z as f}from"zod";import{zodToJsonSchema as g}from"zod-to-json-schema";var y=f.record(f.string(),f.boolean()).describe("Consent requirement mapping"),b=f.lazy(()=>f.union([f.string(),f.number(),f.boolean(),x,f.array(b)])),h=f.tuple([b,b]).describe("Loop: [source, transform] tuple for array transformations"),v=f.array(b).describe("Set: Array of values"),w=f.record(f.string(),b).describe("Map: Object mapping keys to values"),x=f.object({key:f.string().optional().describe('Property path (e.g., "data.id")'),value:f.union([f.string(),f.number(),f.boolean()]).optional().describe("Static primitive value"),fn:f.string().optional().describe("Function string for custom transformation"),map:w.optional().describe("Object with key-value mappings"),loop:h.optional().describe("Tuple [source, transform]"),set:v.optional().describe("Array of values"),consent:y.optional().describe("Required consent states"),condition:f.string().optional().describe("Condition function string"),validate:f.string().optional().describe("Validation function string")}).refine(e=>Object.keys(e).length>0,{message:"ValueConfig must have at least one property"}).describe("Value configuration for transformations"),j=b,S=h,O=v,k=w,E=x,A=g(E,{target:"jsonSchema7",$refStrategy:"relative",name:"ValueConfig"}),L=g(S,{target:"jsonSchema7",$refStrategy:"relative",name:"Loop"}),$=g(O,{target:"jsonSchema7",$refStrategy:"relative",name:"Set"}),I=g(k,{target:"jsonSchema7",$refStrategy:"relative",name:"Map"});function M(e,t){const n=[],r={};for(const[t,o]of Object.entries(e)){o.required&&n.push(t);const e={type:o.type};if(o.description&&(e.description=o.description),o.pattern&&(e.pattern=o.pattern),void 0!==o.minLength&&(e.minLength=o.minLength),void 0!==o.maxLength&&(e.maxLength=o.maxLength),void 0!==o.minimum&&(e.minimum=o.minimum),void 0!==o.maximum&&(e.maximum=o.maximum),o.enum&&(e.enum=[...o.enum]),void 0!==o.default&&(e.default=o.default),"object"===o.type&&o.properties){const t={};for(const[e,n]of Object.entries(o.properties))t[e]=P(n);e.properties=t}"array"===o.type&&o.items&&(e.items=P(o.items)),r[t]=e}const o={type:"object",properties:r};return t&&(o.title=t),n.length>0&&(o.required=n),o}function P(e){const t={type:e.type};if(e.description&&(t.description=e.description),e.pattern&&(t.pattern=e.pattern),void 0!==e.minLength&&(t.minLength=e.minLength),void 0!==e.maxLength&&(t.maxLength=e.maxLength),void 0!==e.minimum&&(t.minimum=e.minimum),void 0!==e.maximum&&(t.maximum=e.maximum),e.enum&&(t.enum=[...e.enum]),void 0!==e.default&&(t.default=e.default),"object"===e.type&&e.properties){const n={};for(const[t,r]of Object.entries(e.properties))n[t]=P(r);t.properties=n}return"array"===e.type&&e.items&&(t.items=P(e.items)),t}function T(e,t){const n={type:"array",items:P(e)};return void 0!==t?.minItems&&(n.minItems=t.minItems),void 0!==t?.maxItems&&(n.maxItems=t.maxItems),t?.description&&(n.description=t.description),t?.title&&(n.title=t.title),n}function C(e,t="string",n){const r={type:t,enum:[...e]};return n?.description&&(r.description=n.description),n?.title&&(r.title=n.title),r}function N(e,t,n){return T({type:"object"},{minItems:2,maxItems:2,description:n||"Tuple with exactly 2 elements [source, transform]"})}function V(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var _={merge:!0,shallow:!0,extend:!0};function z(e,t={},n={}){n={..._,...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 D(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function K(e){return Array.isArray(e)}function R(e){return"boolean"==typeof e}function q(e){return"walker"===e}function H(e){return void 0!==e}function U(e){return e===document||e instanceof Element}function W(e){return"function"==typeof e}function F(e){return"number"==typeof e&&!Number.isNaN(e)}function B(e){return"object"==typeof e&&null!==e&&!K(e)&&"[object Object]"===Object.prototype.toString.call(e)}function X(e,t){return typeof e==typeof t}function J(e){return"string"==typeof e}function G(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]=G(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(G(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 Q(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&K(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=Q(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return H(o)?o:n}function Y(e,t,n){if(!B(e))return e;const r=G(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 Z(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function ee(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 te(e,t){const n={...e};return n.config=z(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=z(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=z(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function ne(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=z({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.2.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 re(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 ne({...{"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 oe(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function ie(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(z(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}function se(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 ae(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function ce(e){return R(e)||J(e)||F(e)||!H(e)||K(e)&&e.every(ce)||B(e)&&Object.values(e).every(ce)}function ue(e){return R(e)||J(e)||F(e)?e:D(e)?ue(Array.from(e)):K(e)?e.map(e=>ue(e)).filter(e=>void 0!==e):B(e)?Object.entries(e).reduce((e,[t,n])=>{const r=ue(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function le(e){return ce(e)?e:void 0}function pe(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function me(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 de(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=K(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 fe(e,t={},n={}){if(!H(e))return;const r=B(e)&&e.consent||n.consent||n.collector?.consent,o=K(t)?t:[t];for(const t of o){const o=await me(ge)(e,t,{...n,consent:r});if(H(o))return o}}async function ge(e,t,n={}){const{collector:r,consent:o}=n;return(K(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const a=J(i)?{key:i}:i;if(!Object.keys(a).length)return;const{condition:c,consent:u,fn:l,key:p,loop:m,map:d,set:f,validate:g,value:y}=a;if(c&&!await me(c)(e,i,r))return;if(u&&!ee(u,o))return y;let b=H(y)?y:e;if(l&&(b=await me(l)(e,i,n)),p&&(b=Q(e,p,y)),m){const[t,r]=m,o="this"===t?[e]:await fe(e,t,n);K(o)&&(b=(await Promise.all(o.map(e=>fe(e,r,n)))).filter(H))}else d?b=await Object.entries(d).reduce(async(t,[r,o])=>{const i=await t,s=await fe(e,o,n);return H(s)&&(i[r]=s),i},Promise.resolve({})):f&&(b=await Promise.all(f.map(t=>ge(e,t,n))));g&&!await me(g)(b)&&(b=void 0);const h=le(b);return H(h)?h:le(y)},Promise.resolve(void 0))}async function ye(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await fe(e,r,{collector:n});e=Y(e,t,o)}));const{eventMapping:r,mappingKey:o}=await de(e,t.mapping);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await fe(e,r,{collector:n});e=Y(e,t,o)}));let i=t.data&&await fe(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 fe(e,r.data,{collector:n});i=B(i)&&B(t)?z(i,t):t}}return{event:e,data:i,mapping:r,mappingKey:o,ignore:!1}}function be(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 he(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 ve(e,t=!1){t&&console.dir(e,{depth:4})}function we(e){const t=String(e),n=t.split("?")[1]||t;return pe(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const r=n.split(/[[\]]+/).filter(Boolean);let o=t;r.forEach((t,n)=>{const i=n===r.length-1;if(K(o)){const s=parseInt(t,10);i?o[s]=Z(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else B(o)&&(i?o[t]=Z(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function xe(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(K(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):B(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 je(e){return void 0===e||X(e,"")?e:JSON.stringify(e)}function Se(e={}){return z({"Content-Type":"application/json; charset=utf-8"},e)}function Oe(e){throw new Error(String(e))}function ke(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Ee(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 Ae(e){return e?{userAgent:e,browser:Le(e),browserVersion:$e(e),os:Ie(e),osVersion:Me(e),deviceType:Pe(e)}:{}}function Le(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 $e(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 Ie(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 Pe(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 Te(e,t=[]){let n,r,o;X(e,{})||Oe("Invalid object"),X(e.name,"")?(n=e.name,[r,o]=n.split(" "),r&&o||Oe("Invalid event name")):X(e.entity,"")&&X(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):Oe("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=pe(Ce,e=>{Oe(String(e))})(t,r,i,o)),X(i,t[r])&&(t[r]=i),t},t)},i)}function Ce(e,t,n,r){if(r.validate&&(n=pe(r.validate,e=>{Oe(String(e))})(n,t,e)),r.required&&void 0===n&&Oe("Missing required property"),X(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&Oe("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if(X(n,1))X(r.min,1)&&n<r.min?(r.strict&&Oe("Value below min"),n=r.min):X(r.max,1)&&n>r.max&&(r.strict&&Oe("Value exceeds max"),n=r.max);else if(X(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&&Oe(`Type doesn't match (${n})`),o=pe(Ce,e=>{Oe(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&Oe("Key not allowed"),delete n[e])}return n}export{e as Collector,y as ConsentSchema,d as Const,t as Data,n as Destination,r as Elb,o as Flow,i as Handler,s as Hooks,S as LoopSchema,k as MapSchema,a as Mapping,c as On,u as Request,l as Schema,O as SetSchema,p as Source,E as ValueConfigSchema,j as ValueSchema,m as WalkerOS,V as anonymizeIP,z as assign,le as castToProperty,Z as castValue,G as clone,T as createArraySchema,te as createDestination,C as createEnumSchema,ne as createEvent,M as createObjectSchema,N as createTupleSchema,se as debounce,ue as filterValues,Le as getBrowser,$e as getBrowserVersion,Q as getByPath,Pe as getDeviceType,re as getEvent,ee as getGrantedConsent,Se as getHeaders,oe as getId,de as getMappingEvent,fe as getMappingValue,ie as getMarketingParameters,Ie as getOS,Me as getOSVersion,D as isArguments,K as isArray,R as isBoolean,q as isCommand,H as isDefined,U as isElementOrDocument,W as isFunction,F as isNumber,B as isObject,ce as isPropertyType,X as isSameType,J as isString,L as loopJsonSchema,I as mapJsonSchema,be as mockEnv,ve as onLog,Ae as parseUserAgent,ye as processEventMapping,we as requestToData,xe as requestToParameter,Y as setByPath,$ as setJsonSchema,ae as throttle,Oe as throwError,je as transformData,he as traverseEnv,ke as trim,pe as tryCatch,me as tryCatchAsync,Ee as useHooks,Te as validateEvent,Ce as validateProperty,A as valueConfigJsonSchema};//# sourceMappingURL=index.mjs.map