@walkeros/walker.js 0.5.0 → 0.6.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/CHANGELOG.md +22 -0
- package/dist/__tests__/setup.d.ts.map +1 -1
- package/dist/__tests__/setup.js +0 -15
- package/dist/__tests__/setup.js.map +1 -1
- package/dist/dev.d.ts +5 -2
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +36 -3
- package/dist/dev.js.map +1 -1
- package/dist/index.d.mts +1 -15
- package/dist/index.d.ts +1 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es5.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walker.js +1 -1
- package/package.json +10 -10
- package/src/dev.ts +45 -7
- package/dist/schemas.d.ts +0 -6
- package/dist/schemas.d.ts.map +0 -1
- package/dist/schemas.js +0 -101
- package/dist/schemas.js.map +0 -1
- package/src/schemas.ts +0 -109
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=Object.defineProperty;((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})({},{Level:()=>o});var n,o=((n=o||{})[n.ERROR=0]="ERROR",n[n.INFO=1]="INFO",n[n.DEBUG=2]="DEBUG",n),r={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},i={merge:!0,shallow:!0,extend:!0};function a(e,t={},n={}){n={...i,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function s(e){return Array.isArray(e)}function c(e){return void 0!==e}function u(e){return"object"==typeof e&&null!==e&&!s(e)&&"[object Object]"===Object.prototype.toString.call(e)}function l(e){return"string"==typeof e}function d(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=d(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(d(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 f(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&s(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=f(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,!r)break}return c(r)?r:n}function g(e,t,n){if(!u(e))return e;const o=d(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function p(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function m(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function y(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function h(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=y(e)):n=e,void 0!==t&&(t instanceof Error?o.error=y(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=y(o.error))):o.value=t),{message:n,context:o}}var b=(e,t,n,r)=>{const i=`${o[e]}${r.length>0?` [${r.join(":")}]`:""}`,a=Object.keys(n).length>0;0===e?a?console.error(i,t,n):console.error(i,t):a?console.log(i,t,n):console.log(i,t)};function v(e={}){return w({level:void 0!==e.level?(t=e.level,"string"==typeof t?o[t]:t):0,handler:e.handler,scope:[]});var t}function w(e){const{level:t,handler:n,scope:o}=e,r=(e,r,i)=>{if(e<=t){const t=h(r,i);n?n(e,t.message,t.context,o,b):b(e,t.message,t.context,o)}};return{error:(e,t)=>r(0,e,t),info:(e,t)=>r(1,e,t),debug:(e,t)=>r(2,e,t),throw:(e,t)=>{const r=h(e,t);throw n?n(0,r.message,r.context,o,b):b(0,r.message,r.context,o),new Error(r.message)},scope:e=>w({level:t,handler:n,scope:[...o,e]})}}function k(e){return function(e){return"boolean"==typeof e}(e)||l(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!c(e)||s(e)&&e.every(k)||u(e)&&Object.values(e).every(k)}function E(e){return k(e)?e:void 0}function j(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function S(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(null==n?void 0:n())}}}async function O(e,t={},n={}){var o;if(!c(e))return;const r=u(e)&&e.consent||n.consent||(null==(o=n.collector)?void 0:o.consent),i=s(t)?t:[t];for(const t of i){const o=await S(x)(e,t,{...n,consent:r});if(c(o))return o}}async function x(e,t,n={}){const{collector:o,consent:r}=n;return(s(t)?t:[t]).reduce(async(t,i)=>{const a=await t;if(a)return a;const u=l(i)?{key:i}:i;if(!Object.keys(u).length)return;const{condition:d,consent:g,fn:m,key:y,loop:h,map:b,set:v,validate:w,value:k}=u;if(d&&!await S(d)(e,i,o))return;if(g&&!p(g,r))return k;let j=c(k)?k:e;if(m&&(j=await S(m)(e,i,n)),y&&(j=f(e,y,k)),h){const[t,o]=h,r="this"===t?[e]:await O(e,t,n);s(r)&&(j=(await Promise.all(r.map(e=>O(e,o,n)))).filter(c))}else b?j=await Object.entries(b).reduce(async(t,[o,r])=>{const i=await t,a=await O(e,r,n);return c(a)&&(i[o]=a),i},Promise.resolve({})):v&&(j=await Promise.all(v.map(t=>x(e,t,n))));w&&!await S(w)(j)&&(j=void 0);const _=E(j);return c(_)?_:E(k)},Promise.resolve(void 0))}async function _(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=g(e,t,r)}));const{eventMapping:o,mappingKey:r}=await async function(e,t){var n;const[o,r]=(e.name||"").split(" ");if(!t||!o||!r)return{};let i,a="",c=o,u=r;const l=t=>{if(t)return(t=s(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[c]||(c="*");const d=t[c];return d&&(d[u]||(u="*"),i=l(d[u])),i||(c="*",u="*",i=l(null==(n=t[c])?void 0:n[u])),i&&(a=`${c} ${u}`),{eventMapping:i,mappingKey:a}}(e,t.mapping);(null==o?void 0:o.policy)&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=g(e,t,r)}));let i=t.data&&await O(e,t.data,{collector:n});if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await O(e,o.data,{collector:n});i=u(i)&&u(t)?a(i,t):t}}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1}}function L(e,t,n){return function(...o){let r;const i="post"+t,a=n["pre"+t],s=n[i];return r=a?a({fn:e},...o):e(...o),s&&(r=s({fn:e,result:r},...o)),r}}var A={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"},C={type:"code",config:{},init(e){var t;const{config:n,logger:o}=e,r=null==(t=n.settings)?void 0:t.init;if(r)try{new Function("context",r)(e)}catch(e){o.error("Code destination init error:",e)}},push(e,t){var n,o;const{mapping:r,config:i,logger:a}=t,s=null!=(o=null==r?void 0:r.push)?o:null==(n=i.settings)?void 0:n.push;if(s)try{new Function("event","context",s)(e,t)}catch(e){a.error("Code destination push error:",e)}},pushBatch(e,t){var n,o;const{mapping:r,config:i,logger:a}=t,s=null!=(o=null==r?void 0:r.pushBatch)?o:null==(n=i.settings)?void 0:n.pushBatch;if(s)try{new Function("batch","context",s)(e,t)}catch(e){a.error("Code destination pushBatch error:",e)}},on(e,t){var n;const{config:o,logger:r}=t,i=null==(n=o.settings)?void 0:n.on;if(i)try{new Function("type","context",i)(e,t)}catch(e){r.error("Code destination on error:",e)}}};function $(e){return!0===e?C:e}async function P(e,t,n){const{allowed:o,consent:r,globals:i,user:s}=e;if(!o)return D({ok:!1});t&&e.queue.push(t),n||(n=e.destinations);const c=await Promise.all(Object.entries(n||{}).map(async([n,o])=>{let c=(o.queue||[]).map(e=>({...e,consent:r}));if(o.queue=[],t){const e=d(t);c.push(e)}if(!c.length)return{id:n,destination:o,skipped:!0};const u=[],l=c.filter(e=>{const t=p(o.config.consent,r,e.consent);return!t||(e.consent=t,u.push(e),!1)});if(o.queue.concat(l),!u.length)return{id:n,destination:o,queue:c};if(!await S(q)(e,o))return{id:n,destination:o,queue:c};let f=!1;return o.dlq||(o.dlq=[]),await Promise.all(u.map(async t=>(t.globals=a(i,t.globals),t.user=a(s,t.user),await S(R,n=>{const r=o.type||"unknown";return e.logger.scope(r).error("Push failed",{error:n,event:t.name}),f=!0,o.dlq.push([t,n]),!1})(e,o,t),t))),{id:n,destination:o,error:f}})),u=[],l=[],f=[];for(const e of c){if(e.skipped)continue;const t=e.destination,n={id:e.id,destination:t};e.error?f.push(n):e.queue&&e.queue.length?(t.queue=(t.queue||[]).concat(e.queue),l.push(n)):u.push(n)}return D({ok:!f.length,event:t,successful:u,queued:l,failed:f})}async function q(e,t){if(t.init&&!t.config.init){const n=t.type||"unknown",o=e.logger.scope(n),r={collector:e,config:t.config,env:I(t.env,t.config.env),logger:o};o.debug("init");const i=await L(t.init,"DestinationInit",e.hooks)(r);if(!1===i)return i;t.config={...i||t.config,init:!0},o.debug("init done")}return!0}async function R(e,t,n){var o;const{config:r}=t,i=await _(n,r,e);if(i.ignore)return!1;const a=t.type||"unknown",s=e.logger.scope(a),u={collector:e,config:r,data:i.data,mapping:i.mapping,env:I(t.env,r.env),logger:s},l=i.mapping;if((null==l?void 0:l.batch)&&t.pushBatch){const n=l.batched||{key:i.mappingKey||"",events:[],data:[]};n.events.push(i.event),c(i.data)&&n.data.push(i.data),l.batchFn=l.batchFn||function(e,t=1e3,n=!1){let o,r=null,i=!1;return(...a)=>new Promise(s=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...a),s(o))},t),c&&(i=!0,o=e(...a),s(o))})}((e,t)=>{const o=e.type||"unknown",a=t.logger.scope(o),s={collector:t,config:r,data:i.data,mapping:l,env:I(e.env,r.env),logger:a};a.debug("push batch",{events:n.events.length}),L(e.pushBatch,"DestinationPushBatch",t.hooks)(n,s),a.debug("push batch done"),n.events=[],n.data=[]},l.batch),l.batched=n,null==(o=l.batchFn)||o.call(l,t,e)}else s.debug("push",{event:i.event.name}),await L(t.push,"DestinationPush",e.hooks)(i.event,u),s.debug("push done");return!0}function D(e){var t;return a({ok:!(null==(t=null==e?void 0:e.failed)?void 0:t.length),successful:[],queued:[],failed:[]},e)}function I(e,t){return e||t?t?e&&u(e)&&u(t)?{...e,...t}:t:e:{}}function N(e,t,n,o){let r,i=n||[];switch(n||(i=e.on[t]||[]),t){case A.Consent:r=o||e.consent;break;case A.Session:r=e.session;break;case A.Ready:case A.Run:default:r=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&j(e.on)(t,r)}),Object.values(e.destinations).forEach(n=>{if(n.on){const o=n.type||"unknown",i=e.logger.scope(o).scope("on").scope(t),a={collector:e,config:n.config,data:r,env:I(n.env,n.config.env),logger:i};j(n.on)(t,a)}}),i.length)switch(t){case A.Consent:!function(e,t,n){const o=n||e.consent;t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{j(t[n])(e,o)})})}(e,i,o);break;case A.Ready:case A.Run:s=i,(a=e).allowed&&s.forEach(e=>{j(e)(a)});break;case A.Session:!function(e,t){e.session&&t.forEach(t=>{j(t)(e,e.session)})}(e,i)}var a,s}async function X(e,t,n,o){let r;switch(t){case A.Config:u(n)&&a(e.config,n,{shallow:!1});break;case A.Consent:u(n)&&(r=await async function(e,t){const{consent:n}=e;let o=!1;const r={};return Object.entries(t).forEach(([e,t])=>{const n=!!t;r[e]=n,o=o||n}),e.consent=a(n,r),N(e,"consent",void 0,r),o?P(e):D({ok:!0})}(e,n));break;case A.Custom:u(n)&&(e.custom=a(e.custom,n));break;case A.Destination:u(n)&&function(e){return"function"==typeof e}(n.push)&&(r=await async function(e,t,n){const{code:o,config:r={},env:i={}}=t,a=n||r||{init:!1},s=$(o),c={...s,config:a,env:I(s.env,i)};let u=c.config.id;if(!u)do{u=m(4)}while(e.destinations[u]);return e.destinations[u]=c,!1!==c.config.queue&&(c.queue=[...e.queue]),P(e,void 0,{[u]:c})}(e,{code:n},o));break;case A.Globals:u(n)&&(e.globals=a(e.globals,n));break;case A.On:l(n)&&function(e,t,n){const o=e.on,r=o[t]||[],i=s(n)?n:[n];i.forEach(e=>{r.push(e)}),o[t]=r,N(e,t,i)}(e,n,o);break;case A.Ready:N(e,"ready");break;case A.Run:r=await async function(e,t){e.allowed=!0,e.count=0,e.group=m(),e.timing=Date.now(),t&&(t.consent&&(e.consent=a(e.consent,t.consent)),t.user&&(e.user=a(e.user,t.user)),t.globals&&(e.globals=a(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=a(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const n=await P(e);return N(e,"run"),n}(e,n);break;case A.Session:N(e,"session");break;case A.User:u(n)&&a(e.user,n,{shallow:!1})}return r||{ok:!0,successful:[],queued:[],failed:[]}}function W(e,t){return L(async(n,o={})=>await S(async()=>{let r=n;if(o.mapping){const t=await _(r,o.mapping,e);if(t.ignore)return D({ok:!0});if(o.mapping.consent&&!p(o.mapping.consent,e.consent,t.event.consent))return D({ok:!0});r=t.event}const i=t(r),a=function(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:i=e.group,count:a=e.count}=t,{name:s=`${n} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:d={},user:f=e.user,nested:g=[],consent:p=e.consent,id:m=`${r}-${i}-${a}`,trigger:y="",entity:h=n,action:b=o,timing:v=0,version:w={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=t;return{name:s,data:c,context:u,globals:l,custom:d,user:f,nested:g,consent:p,id:m,trigger:y,entity:h,action:b,timestamp:r,timing:v,group:i,count:a,version:w,source:k}}(e,i);return await P(e,a)},()=>D({ok:!1}))(),"Push",e.hooks)}async function T(e){var t,n;const o=a({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),r=v({level:null==(t=e.logger)?void 0:t.level,handler:null==(n=e.logger)?void 0:n.handler}),i={...o.globalsStatic,...e.globals},s={allowed:!1,config:o,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:i,group:"",hooks:{},logger:r,on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.5.0",sources:{},push:void 0,command:void 0};return s.push=W(s,e=>({timing:Math.round((Date.now()-s.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),s.command=(u=X,L(async(e,t,n)=>await S(async()=>await u(c,e,t,n),()=>D({ok:!1}))(),"Command",(c=s).hooks)),s.destinations=await async function(e,t={}){const n={};for(const[e,o]of Object.entries(t)){const{code:t,config:r={},env:i={}}=o,a=$(t),s={...a.config,...r},c=I(a.env,i);n[e]={...a,config:s,env:c}}return n}(0,e.destinations||{}),s;var c,u}async function U(e){e=e||{};const t=await T(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,r,i,a)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,t,n)}let s;if("string"==typeof e)s={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(s.data=t);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};s=e,t&&"object"==typeof t&&!Array.isArray(t)&&(s.data={...s.data||{},...t})}return r&&"object"==typeof r&&(s.context=r),i&&Array.isArray(i)&&(s.nested=i),a&&"object"==typeof a&&(s.custom=a),o.push(s)}});var o;t.sources.elb=n;const r=await async function(e,t={}){const n={};for(const[o,r]of Object.entries(t)){const{code:t,config:i={},env:a={},primary:s}=r,c=(t,n={})=>e.push(t,{...n,mapping:i}),u=e.logger.scope("source").scope(o),l={push:c,command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:u,...a},d=await S(t)(i,l);if(!d)continue;const f=d.type||"unknown",g=e.logger.scope(f).scope(o);l.logger=g,s&&(d.config={...d.config,primary:s}),n[o]=d}return n}(t,e.sources||{});Object.assign(t.sources,r);const{consent:i,user:a,globals:s,custom:c}=e;i&&await t.command("consent",i),a&&await t.command("user",a),s&&Object.assign(t.globals,s),c&&Object.assign(t.custom,c),t.config.run&&await t.command("run");let u=n.push;const l=Object.values(t.sources).filter(e=>"elb"!==e.type),d=l.find(e=>e.config.primary);return d?u=d.push:l.length>0&&(u=l[0].push),{collector:t,elb:u}}function B(e,t){return(e.getAttribute(t)||"").trim()}var M=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function G(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const o=window.innerHeight,r=e.getBoundingClientRect(),i=r.height,a=r.y,s=a+i,c={x:r.x+e.offsetWidth/2,y:r.y+e.offsetHeight/2};if(i<=o){if(e.offsetWidth+r.width===0||e.offsetHeight+r.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=o/2;if(a<0&&s<e)return!1;if(s>o&&a>e)return!1;n=document.elementFromPoint(c.x,o/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function F(e,t,n){return!1===n?e:(n||(n=H),n(e,t,H))}var H=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):M("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):M({name:"session start",data:e})),e};function K(e,t=r.Storage.Session){var n;function o(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let i,a;switch(t){case r.Storage.Cookie:i=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case r.Storage.Local:a=o(window.localStorage.getItem(e));break;case r.Storage.Session:a=o(window.sessionStorage.getItem(e))}return a&&(i=a.v,0!=a.e&&a.e<Date.now()&&(function(e,t=r.Storage.Session){switch(t){case r.Storage.Cookie:J(e,"",0,t);break;case r.Storage.Local:window.localStorage.removeItem(e);break;case r.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),i="")),function(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}(i||"")}function J(e,t,n=30,o=r.Storage.Session,i){const a={e:Date.now()+6e4*n,v:String(t)},s=JSON.stringify(a);switch(o){case r.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let o=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;i&&(o+="; domain="+i),document.cookie=o;break}case r.Storage.Local:window.localStorage.setItem(e,s);break;case r.Storage.Session:window.sessionStorage.setItem(e,s)}return K(e,o)}function z(e={}){const t=Date.now(),{length:n=30,deviceKey:o="elbDeviceId",deviceStorage:r="local",deviceAge:i=30,sessionKey:a="elbSessionId",sessionStorage:s="local",pulse:c=!1}=e,u=Y(e);let l=!1;const d=j((e,t,n)=>{let o=K(e,n);return o||(o=m(8),J(e,o,1440*t,n)),String(o)})(o,i,r),f=j((e,o)=>{const r=JSON.parse(String(K(e,o)));return c||(r.isNew=!1,u.marketing&&(Object.assign(r,u),l=!0),l||r.updated+6e4*n<t?(delete r.id,delete r.referrer,r.start=t,r.count++,r.runs=1,l=!0):r.runs++),r},()=>{l=!0})(a,s)||{},g={id:m(12),start:t,isNew:!0,count:1,runs:1},p=Object.assign(g,u,f,{device:d},{isStart:l,storage:!0,updated:t},e.data);return J(a,JSON.stringify(p),2*n,s),p}function Y(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const o=new URL(e.url||window.location.href),r=e.referrer||document.referrer,i=r&&new URL(r).hostname,s=function(e,t={}){const n="clickId",o={},r={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(a(r,t)).forEach(([t,r])=>{const i=e.searchParams.get(t);i&&(r===n&&(r=t,o[n]=t),o[r]=i)}),o}(o,e.parameters);if(Object.keys(s).length&&(s.marketing||(s.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(o.hostname),t=!n.includes(i)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:m(12),referrer:i},s,e.data):n}var V,Q=Object.defineProperty,Z=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},ee=Object.defineProperty;((e,t)=>{for(var n in t)ee(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>te});var te=((V=te||{})[V.ERROR=0]="ERROR",V[V.INFO=1]="INFO",V[V.DEBUG=2]="DEBUG",V),ne={merge:!0,shallow:!0,extend:!0};function oe(e,t={},n={}){n={...ne,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function re(e){return Array.isArray(e)}function ie(e){return e===document||e instanceof Element}function ae(e){return"object"==typeof e&&null!==e&&!re(e)&&"[object Object]"===Object.prototype.toString.call(e)}function se(e){return"string"==typeof e}function ce(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function ue(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function le(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function de(e,t,n=!0){return e+(null!=t?(n?"-":"")+t:"")}function fe(e,t,n,o=!0){return je(B(t,de(e,n,o))||"").reduce((e,n)=>{let[o,r]=Se(n);if(!o)return e;if(r||(o.endsWith(":")&&(o=o.slice(0,-1)),r=""),r.startsWith("#")){r=r.slice(1);try{let e=t[r];e||"selected"!==r||(e=t.options[t.selectedIndex].text),r=String(e)}catch(e){r=""}}return o.endsWith("[]")?(o=o.slice(0,-2),re(e[o])||(e[o]=[]),e[o].push(ce(r))):e[o]=ce(r),e},{})}function ge(e,t=A.Prefix){var n;const o=e||document.body;if(!o)return[];let r=[];const i=A.Action,a=`[${de(t,i,!1)}]`,s=e=>{Object.keys(fe(t,e,i,!1)).forEach(n=>{r=r.concat(pe(e,n,t))})};return o!==document&&(null==(n=o.matches)?void 0:n.call(o,a))&&s(o),Ee(o,a,s),r}function pe(e,t,n=A.Prefix){const o=[],{actions:r,nearestOnly:i}=function(e,t,n){let o=t;for(;o;){const t=B(o,de(e,A.Actions,!1));if(t){const e=he(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const r=B(o,de(e,A.Action,!1));if(r){const e=he(r);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}o=we(e,o)}return{actions:[],nearestOnly:!1}}(n,e,t);return r.length?(r.forEach(r=>{const a=je(r.actionParams||"",",").reduce((e,t)=>(e[le(t)]=!0,e),{}),s=be(n,e,a,i);if(!s.length){const t="page",o=`[${de(n,t)}]`,[r,i]=ke(e,o,n,t);s.push({entity:t,data:r,nested:[],context:i})}s.forEach(e=>{o.push({entity:e.entity,action:r.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),o):o}function me(e=A.Prefix,t=document){const n=de(e,A.Globals,!1);let o={};return Ee(t,`[${n}]`,t=>{o=oe(o,fe(e,t,A.Globals,!1))}),o}function ye(e,t){const n=window.location,o="page",r=t===document?document.body:t,[i,a]=ke(r,`[${de(e,o)}]`,e,o);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,a]}function he(e){const t={};return je(e).forEach(e=>{const[n,o]=Se(e),[r,i]=Oe(n);if(!r)return;let[a,s]=Oe(o||"");a=a||r,t[r]||(t[r]=[]),t[r].push({trigger:r,triggerParams:i,action:a,actionParams:s})}),t}function be(e,t,n,o=!1){const r=[];let i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){const a=ve(e,i,t,n);if(a&&(r.push(a),o))break;i=we(e,i)}return r}function ve(e,t,n,o){const r=B(t,de(e));if(!r||o&&!o[r])return null;const i=[t],a=`[${de(e,r)}],[${de(e,"")}]`,s=de(e,A.Link,!1);let c={};const u=[],[l,d]=ke(n||t,a,e,r);Ee(t,`[${s}]`,t=>{const[n,o]=Se(B(t,s));"parent"===o&&Ee(document.body,`[${s}="${n}:child"]`,t=>{i.push(t);const n=ve(e,t);n&&u.push(n)})});const f=[];i.forEach(e=>{e.matches(a)&&f.push(e),Ee(e,a,e=>f.push(e))});let g={};return f.forEach(t=>{g=oe(g,fe(e,t,"")),c=oe(c,fe(e,t,r))}),c=oe(oe(g,c),l),i.forEach(t=>{Ee(t,`[${de(e)}]`,t=>{const n=ve(e,t);n&&u.push(n)})}),{entity:r,data:c,context:d,nested:u}}function we(e,t){const n=de(e,A.Link,!1);if(t.matches(`[${n}]`)){const[e,o]=Se(B(t,n));if("child"===o)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function ke(e,t,n,o){let r={};const i={};let a=e;const s=`[${de(n,A.Context,!1)}]`;let c=0;for(;a;)a.matches(t)&&(r=oe(fe(n,a,""),r),r=oe(fe(n,a,o),r)),a.matches(s)&&(Object.entries(fe(n,a,A.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,c])}),++c),a=we(n,a);return[r,i]}function Ee(e,t,n){e.querySelectorAll(t).forEach(n)}function je(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function Se(e){const[t,n]=e.split(/:(.+)/,2);return[le(t),le(n)]}function Oe(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var xe,_e=new WeakMap,Le=new WeakMap,Ae=new WeakMap;function Ce(e){const t=Date.now();let n=Le.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:G(e),lastChecked:t},Le.set(e,n)),n.isVisible}function $e(e){if(window.IntersectionObserver)return ue(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,o;const r=t.target,i=Ae.get(e);if(!i)return;const a=i.timers.get(r);if(t.intersectionRatio>0){const o=Date.now();let s=_e.get(r);if((!s||o-s.lastChecked>1e3)&&(s={isLarge:r.offsetHeight>window.innerHeight,lastChecked:o},_e.set(r,s)),t.intersectionRatio>=.5||s.isLarge&&Ce(r)){const t=null==(n=i.elementConfigs)?void 0:n.get(r);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!a){const t=window.setTimeout(async()=>{var t,n;if(Ce(r)){const o=null==(t=i.elementConfigs)?void 0:t.get(r);(null==o?void 0:o.context)&&await Ge(o.context,r,o.trigger);const a=null==(n=i.elementConfigs)?void 0:n.get(r);(null==a?void 0:a.multiple)?a.blocked=!0:function(e,t){const n=Ae.get(e);if(!n)return;n.observer&&n.observer.unobserve(t);const o=n.timers.get(t);o&&(clearTimeout(o),n.timers.delete(t)),_e.delete(t),Le.delete(t)}(e,r)}},i.duration);i.timers.set(r,t)}return}}a&&(clearTimeout(a),i.timers.delete(r));const s=null==(o=i.elementConfigs)?void 0:o.get(r);(null==s?void 0:s.multiple)&&(s.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function Pe(e,t,n={multiple:!1}){var o;const r=e.settings.scope||document,i=Ae.get(r);(null==i?void 0:i.observer)&&t&&(i.elementConfigs||(i.elementConfigs=new WeakMap),i.elementConfigs.set(t,{multiple:null!=(o=n.multiple)&&o,blocked:!1,context:e,trigger:n.multiple?"visible":"impression"}),i.observer.observe(t))}function qe(e){if(!e)return;const t=Ae.get(e);t&&(t.observer&&t.observer.disconnect(),Ae.delete(e))}function Re(e,t,n,o,r,i,a){const{elb:s,settings:c}=e;if(se(t)&&t.startsWith("walker "))return s(t,n);if(ae(t)){const e=t;return e.source||(e.source=De()),e.globals||(e.globals=me(c.prefix,c.scope||document)),s(e)}const[u]=String(ae(t)?t.name:t).split(" ");let l,d=ae(n)?n:{},f={},g=!1;if(ie(n)&&(l=n,g=!0),ie(r)?l=r:ae(r)&&Object.keys(r).length&&(f=r),l){const e=be(c.prefix||"data-elb",l).find(e=>e.entity===u);e&&(g&&(d=e.data),f=e.context)}"page"===u&&(d.id=d.id||window.location.pathname);const p=me(c.prefix,c.scope);return s({name:String(t||""),data:d,context:f,globals:p,nested:i,custom:a,trigger:se(o)?o:"",source:De()})}function De(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var Ie=[],Ne="hover",Xe="load",We="pulse",Te="scroll",Ue="wait";function Be(e,t){t.scope&&function(e,t){const n=t.scope;n&&(n.addEventListener("click",ue(function(t){He.call(this,e,t)})),n.addEventListener("submit",ue(function(t){Ke.call(this,e,t)})))}(e,t)}function Me(e,t){t.scope&&function(e,t){const n=t.scope;Ie=[];const o=n||document;qe(o),function(e,t=1e3){Ae.has(e)||Ae.set(e,{observer:$e(e),timers:new WeakMap,duration:t})}(o,1e3);const r=de(t.prefix,A.Action,!1);o!==document&&Fe(e,o,r,t),o.querySelectorAll(`[${r}]`).forEach(n=>{Fe(e,n,r,t)}),Ie.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const o=window.scrollY+window.innerHeight,r=e.offsetTop;if(o<r)return!0;const i=e.clientHeight;return!(100*(1-(r+i-o)/(i||1))>=n&&(Ge(t,e,Te),1))});xe||(xe=function(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}(function(){Ie=n.call(t,Ie,e)}),t.addEventListener("scroll",xe))}(e,o)}(e,t)}async function Ge(e,t,n){const o=pe(t,n,e.settings.prefix);return Promise.all(o.map(t=>Re(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function Fe(e,t,n,o){const r=B(t,n);r&&Object.values(he(r)).forEach(n=>n.forEach(n=>{switch(n.trigger){case Ne:o=e,t.addEventListener("mouseenter",ue(function(e){e.target instanceof Element&&Ge(o,e.target,Ne)}));break;case Xe:!function(e,t){Ge(e,t,Xe)}(e,t);break;case We:!function(e,t,n=""){setInterval(()=>{document.hidden||Ge(e,t,We)},parseInt(n||"")||15e3)}(e,t,n.triggerParams);break;case Te:!function(e,t=""){const n=parseInt(t||"")||50;n<0||n>100||Ie.push([e,n])}(t,n.triggerParams);break;case"impression":Pe(e,t);break;case"visible":Pe(e,t,{multiple:!0});break;case Ue:!function(e,t,n=""){setTimeout(()=>Ge(e,t,Ue),parseInt(n||"")||15e3)}(e,t,n.triggerParams)}var o}))}function He(e,t){Ge(e,t.target,"click")}function Ke(e,t){t.target&&Ge(e,t.target,"submit")}function Je(e,t,n,o){const r=[];let i=!0;n.forEach(e=>{const t=Ye(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const a=t[0],s=!ae(a)&&se(a)&&a.startsWith("walker ");if(ae(a)){if("object"==typeof a&&0===Object.keys(a).length)return}else{const e=Array.from(t);if(!se(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(o&&s||!o&&!s)&&r.push(t)}),r.forEach(n=>{ze(e,t,n)})}function ze(e,t="data-elb",n){ue(()=>{if(Array.isArray(n)){const[o,...r]=n;if(!o||se(o)&&""===o.trim())return;if(se(o)&&o.startsWith("walker "))return void e(o,r[0]);Re({elb:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},o,...r)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e(n)}},()=>{})()}function Ye(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function Ve(e,t={},n){return function(e={}){const{cb:t,consent:n,collector:o,storage:r}=e;if(!n)return F((r?z:Y)(e),o,t);{const r=function(e,t){let n;return(o,r)=>{if(c(n)&&n===(null==o?void 0:o.group))return;n=null==o?void 0:o.group;let i=()=>Y(e);return e.consent&&p((s(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),r)&&(i=()=>z(e)),F(i(),o,t)}}(e,t),i=(s(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{});o?o.command("on","consent",i):M("walker on","consent",i)}}({...t,collector:{push:e,group:void 0,command:n}})}Z({},{env:()=>Qe});var Qe={};Z(Qe,{push:()=>nt});var Ze=()=>{},et=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),tt={error:Ze,info:Ze,debug:Ze,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>tt},nt={get push(){return et()},get command(){return et()},get elb(){return et()},get window(){return{addEventListener:Ze,removeEventListener:Ze,location:{href:"https://example.com/page",pathname:"/page",search:"?query=test",hash:"#section",host:"example.com",hostname:"example.com",origin:"https://example.com",protocol:"https:"},document:{},navigator:{language:"en-US",userAgent:"Mozilla/5.0 (Test)"},screen:{width:1920,height:1080},innerWidth:1920,innerHeight:1080,pageXOffset:0,pageYOffset:0,scrollX:0,scrollY:0}},get document(){return{addEventListener:Ze,removeEventListener:Ze,querySelector:Ze,querySelectorAll:()=>[],getElementById:Ze,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:Ze,getAttribute:Ze,addEventListener:Ze,removeEventListener:Ze}),body:{appendChild:Ze,removeChild:Ze},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}},logger:tt},ot=async(e,t)=>{const{elb:n,command:o,window:r,document:i}=t,a=(null==e?void 0:e.settings)||{},s=r||(void 0!==globalThis.window?globalThis.window:void 0),c=i||(void 0!==globalThis.document?globalThis.document:void 0),u=function(e={},t){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}(a,c),l={settings:u},d={elb:n,settings:u};if(s&&c){if(!1!==u.elbLayer&&n&&function(e,t={}){const n=t.name||"elbLayer",o=t.window||window;if(!o)return;const r=o;r[n]||(r[n]=[]);const i=r[n];i.push=function(...n){if(Ye(n[0])){const o=[...Array.from(n[0])],r=Array.prototype.push.apply(this,[o]);return ze(e,t.prefix,o),r}const o=Array.prototype.push.apply(this,n);return n.forEach(n=>{ze(e,t.prefix,n)}),o},Array.isArray(i)&&i.length>0&&function(e,t="data-elb",n){Je(e,t,n,!0),Je(e,t,n,!1),n.length=0}(e,t.prefix,i)}(n,{name:se(u.elbLayer)?u.elbLayer:"elbLayer",prefix:u.prefix,window:s}),u.session&&n){const e="boolean"==typeof u.session?{}:u.session;Ve(n,e,o)}await async function(e,t,n){const o=()=>{e(t,n)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)}(Be,d,u),(()=>{if(Me(d,u),u.pageview){const[e,t]=ye(u.prefix||"data-elb",u.scope);Re(d,"page view",e,"load",t)}})(),se(u.elb)&&u.elb&&(s[u.elb]=(...e)=>{const[t,n,o,r,i,a]=e;return Re(d,t,n,o,r,i,a)})}return{type:"browser",config:l,push:(...e)=>{const[t,n,o,r,i,a]=e;return Re(d,t,n,o,r,i,a)},destroy:async()=>{c&&qe(u.scope||c)},on:async(e,t)=>{switch(e){case"consent":if(u.session&&t&&n){const e="boolean"==typeof u.session?{}:u.session;Ve(n,e,o)}break;case"session":case"ready":default:break;case"run":if(c&&s&&(Me(d,u),u.pageview)){const[e,t]=ye(u.prefix||"data-elb",u.scope);Re(d,"page view",e,"load",t)}}}}},rt=Object.defineProperty,it=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})},at=!1;function st(e,t={},n){if(t.filter&&!0===j(()=>t.filter(n),()=>!1)())return;const o=function(e){if(u(e)&&l(e.event)){const{event:t,...n}=e;return{name:t,...n}}return s(e)&&e.length>=2?ct(e):null!=(t=e)&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>0?ct(Array.from(e)):null;var t}(n);if(!o)return;const r=`${t.prefix||"dataLayer"} ${o.name}`,{name:i,...a}=o,c={name:r,data:a};j(()=>e(c),()=>{})()}function ct(e){const[t,n,o]=e;if(!l(t))return null;let r,i={};switch(t){case"consent":if(!l(n)||e.length<3)return null;if("default"!==n&&"update"!==n)return null;if(!u(o)||null===o)return null;r=`${t} ${n}`,i={...o};break;case"event":if(!l(n))return null;r=n,u(o)&&(i={...o});break;case"config":if(!l(n))return null;r=`${t} ${n}`,u(o)&&(i={...o});break;case"set":if(l(n))r=`${t} ${n}`,u(o)&&(i={...o});else{if(!u(n))return null;r=`${t} custom`,i={...n}}break;default:return null}return{name:r,...i}}it({},{push:()=>ft});var ut=()=>{},lt=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),dt={error:ut,info:ut,debug:ut,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>dt},ft={get push(){return lt()},get command(){return lt()},get elb(){return lt()},get window(){return{dataLayer:[],addEventListener:ut,removeEventListener:ut}},logger:dt};function gt(){return["consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"denied",analytics_storage:"granted"}]}function pt(){return["consent","default",{ad_storage:"denied",analytics_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}]}function mt(){return["event","purchase",{transaction_id:"T_12345",value:25.42,currency:"EUR",items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",quantity:1,price:25.42}]}]}function yt(){return["event","add_to_cart",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_variant:"red",quantity:1,price:15.25}]}]}function ht(){return["event","view_item",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",price:15.25}]}]}function bt(){return["config","G-XXXXXXXXXX",{page_title:"Custom Page Title",page_location:"https://example.com/page",send_page_view:!1}]}function vt(){return["set",{currency:"EUR",country:"DE"}]}function wt(){return{event:"custom_event",custom_parameter:"custom_value",user_id:"user123"}}it({},{add_to_cart:()=>yt,config:()=>bt,consentDefault:()=>pt,consentUpdate:()=>gt,directDataLayerEvent:()=>wt,purchase:()=>mt,setCustom:()=>vt,view_item:()=>ht});it({},{add_to_cart:()=>jt,config:()=>_t,configGA4:()=>Ot,consentOnlyMapping:()=>Lt,consentUpdate:()=>kt,customEvent:()=>xt,purchase:()=>Et,view_item:()=>St});var kt={name:"walker consent",settings:{command:{map:{functional:{value:!0},analytics:{key:"analytics_storage",fn:e=>"granted"===e},marketing:{key:"ad_storage",fn:e=>"granted"===e}}}}},Et={name:"order complete",data:{map:{id:"transaction_id",total:"value",currency:"currency",nested:{loop:["items",{map:{type:{value:"product"},data:{map:{id:"item_id",name:"item_name",category:"item_category",quantity:"quantity",price:"price"}}}}]}}}},jt={name:"product add",data:{map:{id:"items.0.item_id",name:"items.0.item_name",price:"value",currency:"currency",color:"items.0.item_variant",quantity:"items.0.quantity"}}},St={name:"product view",data:{map:{id:"items.0.item_id",name:"items.0.item_name",category:"items.0.item_category",price:"items.0.price",currency:"currency"}}},Ot={name:"page view",data:{map:{title:"page_title",url:"page_location"}}},xt={data:{map:{user_id:"user_id",custom_parameter:"custom_parameter"}}},_t={consent:{update:kt},purchase:Et,add_to_cart:jt,view_item:St,"config G-XXXXXXXXXX":Ot,custom_event:xt,"*":{data:{}}},Lt={consent:{update:kt}},At=async(e,t)=>{const{elb:n,window:o}=t,r={name:"dataLayer",prefix:"dataLayer",...null==e?void 0:e.settings},i={settings:r};return o&&(function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer",r=window[o];if(Array.isArray(r)&&!at){at=!0;try{for(const t of r)st(e,n,t)}finally{at=!1}}}(n,i),function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer";window[o]||(window[o]=[]);const r=window[o];if(!Array.isArray(r))return;const i=r.push.bind(r);r.push=function(...t){if(at)return i(...t);at=!0;try{for(const o of t)st(e,n,o)}finally{at=!1}return i(...t)}}(n,i)),{type:"dataLayer",config:i,push:n,destroy:async()=>{const e=r.name||"dataLayer";o&&o[e]&&Array.isArray(o[e])}}};function Ct(){window.dataLayer=window.dataLayer||[];const e=e=>{u(e)&&u(e.source)&&String(e.source.type).includes("dataLayer")||window.dataLayer.push(e)};return{type:"dataLayer",config:{},push:(t,n)=>{e(n.data||t)},pushBatch:t=>{e({name:"batch",batched_event:t.key,events:t.data.length?t.data:t.events})}}}var $t={},Pt={};((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(Pt,{browserConfig:()=>Rt,collectorConfig:()=>It,dataLayerConfig:()=>Dt,settings:()=>qt});var qt={type:"object",properties:{elb:{type:"string",default:"elb",description:"Global function name for event tracking"},name:{type:"string",default:"walkerjs",description:"Global instance name"},run:{type:"boolean",default:!0,description:"Auto-initialize walker.js on load"},browser:{type:"object",default:{run:!0,session:!0,scope:"document.body",pageview:!0},description:"Browser source configuration. Set to false to disable. See browser configuration section below for details."},dataLayer:{type:"object",default:!1,description:"DataLayer source configuration. Set to true for defaults or object for custom config. See dataLayer configuration section below."},collector:{type:"object",default:{},description:"Collector configuration including destinations and consent settings. See collector configuration section below."}}},Rt={type:"object",properties:{"browser.run":{type:"boolean",default:!0,description:"Auto-start DOM tracking"},"browser.session":{type:"boolean",default:!0,description:"Enable session tracking"},"browser.scope":{type:"string",default:"document.body",description:"DOM element scope for tracking"},"browser.pageview":{type:"boolean",default:!0,description:"Enable automatic page view events"}}},Dt={type:"object",properties:{dataLayer:{type:"boolean",default:!1,description:"Enable dataLayer integration with defaults"},"dataLayer.name":{type:"string",default:"dataLayer",description:"DataLayer variable name"},"dataLayer.prefix":{type:"string",default:"dataLayer",description:"Event prefix for dataLayer events"}}},It={type:"object",properties:{"collector.consent":{type:"object",default:{functional:!0},description:"Default consent state"},"collector.destinations":{type:"object",default:{},description:"Destination configurations. See destinations documentation for available options."}}};async function Nt(e={}){const t=a({collector:{destinations:{dataLayer:{code:Ct()}}},browser:{session:!0},dataLayer:!1,elb:"elb",run:!0},e),n={...t.collector,sources:{browser:{code:ot,config:{settings:t.browser},env:{window:"undefined"!=typeof window?window:void 0,document:"undefined"!=typeof document?document:void 0}}}};if(t.dataLayer){const e=u(t.dataLayer)?t.dataLayer:{};n.sources&&(n.sources.dataLayer={code:At,config:{settings:e}})}const o=await U(n);return"undefined"!=typeof window&&(t.elb&&(window[t.elb]=o.elb),t.name&&(window[t.name]=o.collector)),o}var Xt=Nt;export{$t as Walkerjs,Nt as createWalkerjs,Xt as default,ge as getAllEvents,pe as getEvents,me as getGlobals,Pt as schemas};//# sourceMappingURL=index.mjs.map
|
|
1
|
+
var e=Object.defineProperty;((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})({},{Level:()=>n});var t,n=((t=n||{})[t.ERROR=0]="ERROR",t[t.INFO=1]="INFO",t[t.DEBUG=2]="DEBUG",t),o={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},r={merge:!0,shallow:!0,extend:!0};function i(e,t={},n={}){n={...r,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function s(e){return Array.isArray(e)}function a(e){return void 0!==e}function c(e){return"object"==typeof e&&null!==e&&!s(e)&&"[object Object]"===Object.prototype.toString.call(e)}function u(e){return"string"==typeof e}function l(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=l(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(l(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 d(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&s(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=d(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,!r)break}return a(r)?r:n}function f(e,t,n){if(!c(e))return e;const o=l(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function g(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function m(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function p(e,t=1e3,n=!1){let o,r=null,i=!1;return(...s)=>new Promise(a=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...s),a(o))},t),c&&(i=!0,o=e(...s),a(o))})}function h(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function y(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=h(e)):n=e,void 0!==t&&(t instanceof Error?o.error=h(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=h(o.error))):o.value=t),{message:n,context:o}}var b=(e,t,o,r)=>{const i=`${n[e]}${r.length>0?` [${r.join(":")}]`:""}`,s=Object.keys(o).length>0;0===e?s?console.error(i,t,o):console.error(i,t):s?console.log(i,t,o):console.log(i,t)};function v(e={}){return w({level:void 0!==e.level?(t=e.level,"string"==typeof t?n[t]:t):0,handler:e.handler,scope:[]});var t}function w(e){const{level:t,handler:n,scope:o}=e,r=(e,r,i)=>{if(e<=t){const t=y(r,i);n?n(e,t.message,t.context,o,b):b(e,t.message,t.context,o)}};return{error:(e,t)=>r(0,e,t),info:(e,t)=>r(1,e,t),debug:(e,t)=>r(2,e,t),throw:(e,t)=>{const r=y(e,t);throw n?n(0,r.message,r.context,o,b):b(0,r.message,r.context,o),new Error(r.message)},scope:e=>w({level:t,handler:n,scope:[...o,e]})}}function k(e){return function(e){return"boolean"==typeof e}(e)||u(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!a(e)||s(e)&&e.every(k)||c(e)&&Object.values(e).every(k)}function E(e){return k(e)?e:void 0}function S(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function j(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(null==n?void 0:n())}}}async function O(e,t={},n={}){var o;if(!a(e))return;const r=c(e)&&e.consent||n.consent||(null==(o=n.collector)?void 0:o.consent),i=s(t)?t:[t];for(const t of i){const o=await j(_)(e,t,{...n,consent:r});if(a(o))return o}}async function _(e,t,n={}){const{collector:o,consent:r}=n;return(s(t)?t:[t]).reduce(async(t,i)=>{const c=await t;if(c)return c;const l=u(i)?{key:i}:i;if(!Object.keys(l).length)return;const{condition:f,consent:m,fn:p,key:h,loop:y,map:b,set:v,validate:w,value:k}=l;if(f&&!await j(f)(e,i,o))return;if(m&&!g(m,r))return k;let S=a(k)?k:e;if(p&&(S=await j(p)(e,i,n)),h&&(S=d(e,h,k)),y){const[t,o]=y,r="this"===t?[e]:await O(e,t,n);s(r)&&(S=(await Promise.all(r.map(e=>O(e,o,n)))).filter(a))}else b?S=await Object.entries(b).reduce(async(t,[o,r])=>{const i=await t,s=await O(e,r,n);return a(s)&&(i[o]=s),i},Promise.resolve({})):v&&(S=await Promise.all(v.map(t=>_(e,t,n))));w&&!await j(w)(S)&&(S=void 0);const x=E(S);return a(x)?x:E(k)},Promise.resolve(void 0))}async function x(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=f(e,t,r)}));const{eventMapping:o,mappingKey:r}=await async function(e,t){var n;const[o,r]=(e.name||"").split(" ");if(!t||!o||!r)return{};let i,a="",c=o,u=r;const l=t=>{if(t)return(t=s(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[c]||(c="*");const d=t[c];return d&&(d[u]||(u="*"),i=l(d[u])),i||(c="*",u="*",i=l(null==(n=t[c])?void 0:n[u])),i&&(a=`${c} ${u}`),{eventMapping:i,mappingKey:a}}(e,t.mapping);(null==o?void 0:o.policy)&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=f(e,t,r)}));let a=t.data&&await O(e,t.data,{collector:n});if(o){if(o.ignore)return{event:e,data:a,mapping:o,mappingKey:r,ignore:!0};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await O(e,o.data,{collector:n});a=c(a)&&c(t)?i(a,t):t}}return{event:e,data:a,mapping:o,mappingKey:r,ignore:!1}}function L(e,t,n){return function(...o){let r;const i="post"+t,s=n["pre"+t],a=n[i];return r=s?s({fn:e},...o):e(...o),a&&(r=a({fn:e,result:r},...o)),r}}var A={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"},C={type:"code",config:{},init(e){const{config:t,logger:n}=e,o=t.settings,r=null==o?void 0:o.scripts;if(r&&"undefined"!=typeof document)for(const e of r){const t=document.createElement("script");t.src=e,t.async=!0,document.head.appendChild(t)}const i=null==o?void 0:o.init;if(i)try{new Function("context",i)(e)}catch(e){n.error("Code destination init error:",e)}},push(e,t){var n,o;const{mapping:r,config:i,logger:s}=t,a=null!=(o=null==r?void 0:r.push)?o:null==(n=i.settings)?void 0:n.push;if(a)try{new Function("event","context",a)(e,t)}catch(e){s.error("Code destination push error:",e)}},pushBatch(e,t){var n,o;const{mapping:r,config:i,logger:s}=t,a=null!=(o=null==r?void 0:r.pushBatch)?o:null==(n=i.settings)?void 0:n.pushBatch;if(a)try{new Function("batch","context",a)(e,t)}catch(e){s.error("Code destination pushBatch error:",e)}},on(e,t){var n;const{config:o,logger:r}=t,i=null==(n=o.settings)?void 0:n.on;if(i)try{new Function("type","context",i)(e,t)}catch(e){r.error("Code destination on error:",e)}}};function $(e){return!0===e?C:e}async function q(e,t,n){const{allowed:o,consent:r,globals:s,user:a}=e;if(!o)return D({ok:!1});t&&e.queue.push(t),n||(n=e.destinations);const c=await Promise.all(Object.entries(n||{}).map(async([n,o])=>{let c=(o.queue||[]).map(e=>({...e,consent:r}));if(o.queue=[],t){const e=l(t);c.push(e)}if(!c.length)return{id:n,destination:o,skipped:!0};const u=[],d=c.filter(e=>{const t=g(o.config.consent,r,e.consent);return!t||(e.consent=t,u.push(e),!1)});if(o.queue.concat(d),!u.length)return{id:n,destination:o,queue:c};if(!await j(P)(e,o))return{id:n,destination:o,queue:c};let f=!1;return o.dlq||(o.dlq=[]),await Promise.all(u.map(async t=>(t.globals=i(s,t.globals),t.user=i(a,t.user),await j(R,n=>{const r=o.type||"unknown";return e.logger.scope(r).error("Push failed",{error:n,event:t.name}),f=!0,o.dlq.push([t,n]),!1})(e,o,t),t))),{id:n,destination:o,error:f}})),u=[],d=[],f=[];for(const e of c){if(e.skipped)continue;const t=e.destination,n={id:e.id,destination:t};e.error?f.push(n):e.queue&&e.queue.length?(t.queue=(t.queue||[]).concat(e.queue),d.push(n)):u.push(n)}return D({ok:!f.length,event:t,successful:u,queued:d,failed:f})}async function P(e,t){if(t.init&&!t.config.init){const n=t.type||"unknown",o=e.logger.scope(n),r={collector:e,config:t.config,env:I(t.env,t.config.env),logger:o};o.debug("init");const i=await L(t.init,"DestinationInit",e.hooks)(r);if(!1===i)return i;t.config={...i||t.config,init:!0},o.debug("init done")}return!0}async function R(e,t,n){const{config:o}=t,r=await x(n,o,e);if(r.ignore)return!1;const i=t.type||"unknown",s=e.logger.scope(i),c={collector:e,config:o,data:r.data,mapping:r.mapping,env:I(t.env,o.env),logger:s},u=r.mapping,l=r.mappingKey||"* *";if((null==u?void 0:u.batch)&&t.pushBatch){if(t.batches=t.batches||{},!t.batches[l]){const n={key:l,events:[],data:[]};t.batches[l]={batched:n,batchFn:p(()=>{const n=t.batches[l].batched,r={collector:e,config:o,data:void 0,mapping:u,env:I(t.env,o.env),logger:s};s.debug("push batch",{events:n.events.length}),L(t.pushBatch,"DestinationPushBatch",e.hooks)(n,r),s.debug("push batch done"),n.events=[],n.data=[]},u.batch)}}const n=t.batches[l];n.batched.events.push(r.event),a(r.data)&&n.batched.data.push(r.data),n.batchFn()}else s.debug("push",{event:r.event.name}),await L(t.push,"DestinationPush",e.hooks)(r.event,c),s.debug("push done");return!0}function D(e){var t;return i({ok:!(null==(t=null==e?void 0:e.failed)?void 0:t.length),successful:[],queued:[],failed:[]},e)}function I(e,t){return e||t?t?e&&c(e)&&c(t)?{...e,...t}:t:e:{}}function N(e,t,n,o){let r,i=n||[];switch(n||(i=e.on[t]||[]),t){case A.Consent:r=o||e.consent;break;case A.Session:r=e.session;break;case A.Ready:case A.Run:default:r=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&S(e.on)(t,r)}),Object.values(e.destinations).forEach(n=>{if(n.on){const o=n.type||"unknown",i=e.logger.scope(o).scope("on").scope(t),s={collector:e,config:n.config,data:r,env:I(n.env,n.config.env),logger:i};S(n.on)(t,s)}}),i.length)switch(t){case A.Consent:!function(e,t,n){const o=n||e.consent;t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{S(t[n])(e,o)})})}(e,i,o);break;case A.Ready:case A.Run:a=i,(s=e).allowed&&a.forEach(e=>{S(e)(s)});break;case A.Session:!function(e,t){e.session&&t.forEach(t=>{S(t)(e,e.session)})}(e,i)}var s,a}async function X(e,t,n,o){let r;switch(t){case A.Config:c(n)&&i(e.config,n,{shallow:!1});break;case A.Consent:c(n)&&(r=await async function(e,t){const{consent:n}=e;let o=!1;const r={};return Object.entries(t).forEach(([e,t])=>{const n=!!t;r[e]=n,o=o||n}),e.consent=i(n,r),N(e,"consent",void 0,r),o?q(e):D({ok:!0})}(e,n));break;case A.Custom:c(n)&&(e.custom=i(e.custom,n));break;case A.Destination:c(n)&&function(e){return"function"==typeof e}(n.push)&&(r=await async function(e,t,n){const{code:o,config:r={},env:i={}}=t,s=n||r||{init:!1},a=$(o),c={...a,config:s,env:I(a.env,i)};let u=c.config.id;if(!u)do{u=m(4)}while(e.destinations[u]);return e.destinations[u]=c,!1!==c.config.queue&&(c.queue=[...e.queue]),q(e,void 0,{[u]:c})}(e,{code:n},o));break;case A.Globals:c(n)&&(e.globals=i(e.globals,n));break;case A.On:u(n)&&function(e,t,n){const o=e.on,r=o[t]||[],i=s(n)?n:[n];i.forEach(e=>{r.push(e)}),o[t]=r,N(e,t,i)}(e,n,o);break;case A.Ready:N(e,"ready");break;case A.Run:r=await async function(e,t){e.allowed=!0,e.count=0,e.group=m(),e.timing=Date.now(),t&&(t.consent&&(e.consent=i(e.consent,t.consent)),t.user&&(e.user=i(e.user,t.user)),t.globals&&(e.globals=i(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=i(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const n=await q(e);return N(e,"run"),n}(e,n);break;case A.Session:N(e,"session");break;case A.User:c(n)&&i(e.user,n,{shallow:!1})}return r||{ok:!0,successful:[],queued:[],failed:[]}}function W(e,t){return L(async(n,o={})=>await j(async()=>{let r=n;if(o.mapping){const t=await x(r,o.mapping,e);if(t.ignore)return D({ok:!0});if(o.mapping.consent&&!g(o.mapping.consent,e.consent,t.event.consent))return D({ok:!0});r=t.event}const i=t(r),s=function(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:i=e.group,count:s=e.count}=t,{name:a=`${n} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:d={},user:f=e.user,nested:g=[],consent:m=e.consent,id:p=`${r}-${i}-${s}`,trigger:h="",entity:y=n,action:b=o,timing:v=0,version:w={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=t;return{name:a,data:c,context:u,globals:l,custom:d,user:f,nested:g,consent:m,id:p,trigger:h,entity:y,action:b,timestamp:r,timing:v,group:i,count:s,version:w,source:k}}(e,i);return await q(e,s)},()=>D({ok:!1}))(),"Push",e.hooks)}async function T(e){var t,n;const o=i({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),r=v({level:null==(t=e.logger)?void 0:t.level,handler:null==(n=e.logger)?void 0:n.handler}),s={...o.globalsStatic,...e.globals},a={allowed:!1,config:o,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:s,group:"",hooks:{},logger:r,on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.6.0",sources:{},push:void 0,command:void 0};return a.push=W(a,e=>({timing:Math.round((Date.now()-a.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),a.command=(u=X,L(async(e,t,n)=>await j(async()=>await u(c,e,t,n),()=>D({ok:!1}))(),"Command",(c=a).hooks)),a.destinations=await async function(e,t={}){const n={};for(const[e,o]of Object.entries(t)){const{code:t,config:r={},env:i={}}=o,s=$(t),a={...s.config,...r},c=I(s.env,i);n[e]={...s,config:a,env:c}}return n}(0,e.destinations||{}),a;var c,u}async function U(e){e=e||{};const t=await T(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,r,i,s)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,t,n)}let a;if("string"==typeof e)a={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(a.data=t);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};a=e,t&&"object"==typeof t&&!Array.isArray(t)&&(a.data={...a.data||{},...t})}return r&&"object"==typeof r&&(a.context=r),i&&Array.isArray(i)&&(a.nested=i),s&&"object"==typeof s&&(a.custom=s),o.push(a)}});var o;t.sources.elb=n;const r=await async function(e,t={}){const n={};for(const[o,r]of Object.entries(t)){const{code:t,config:i={},env:s={},primary:a}=r,c=(t,n={})=>e.push(t,{...n,mapping:i}),u=e.logger.scope("source").scope(o),l={push:c,command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:u,...s},d=await j(t)(i,l);if(!d)continue;const f=d.type||"unknown",g=e.logger.scope(f).scope(o);l.logger=g,a&&(d.config={...d.config,primary:a}),n[o]=d}return n}(t,e.sources||{});Object.assign(t.sources,r);const{consent:i,user:s,globals:a,custom:c}=e;i&&await t.command("consent",i),s&&await t.command("user",s),a&&Object.assign(t.globals,a),c&&Object.assign(t.custom,c),t.config.run&&await t.command("run");let u=n.push;const l=Object.values(t.sources).filter(e=>"elb"!==e.type),d=l.find(e=>e.config.primary);return d?u=d.push:l.length>0&&(u=l[0].push),{collector:t,elb:u}}function B(e,t){return(e.getAttribute(t)||"").trim()}var M=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function F(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const o=window.innerHeight,r=e.getBoundingClientRect(),i=r.height,s=r.y,a=s+i,c={x:r.x+e.offsetWidth/2,y:r.y+e.offsetHeight/2};if(i<=o){if(e.offsetWidth+r.width===0||e.offsetHeight+r.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=o/2;if(s<0&&a<e)return!1;if(a>o&&s>e)return!1;n=document.elementFromPoint(c.x,o/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function G(e,t,n){return!1===n?e:(n||(n=H),n(e,t,H))}var H=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):M("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):M({name:"session start",data:e})),e};function K(e,t=o.Storage.Session){var n;function r(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let i,s;switch(t){case o.Storage.Cookie:i=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case o.Storage.Local:s=r(window.localStorage.getItem(e));break;case o.Storage.Session:s=r(window.sessionStorage.getItem(e))}return s&&(i=s.v,0!=s.e&&s.e<Date.now()&&(function(e,t=o.Storage.Session){switch(t){case o.Storage.Cookie:J(e,"",0,t);break;case o.Storage.Local:window.localStorage.removeItem(e);break;case o.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),i="")),function(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}(i||"")}function J(e,t,n=30,r=o.Storage.Session,i){const s={e:Date.now()+6e4*n,v:String(t)},a=JSON.stringify(s);switch(r){case o.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let o=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;i&&(o+="; domain="+i),document.cookie=o;break}case o.Storage.Local:window.localStorage.setItem(e,a);break;case o.Storage.Session:window.sessionStorage.setItem(e,a)}return K(e,r)}function z(e={}){const t=Date.now(),{length:n=30,deviceKey:o="elbDeviceId",deviceStorage:r="local",deviceAge:i=30,sessionKey:s="elbSessionId",sessionStorage:a="local",pulse:c=!1}=e,u=Y(e);let l=!1;const d=S((e,t,n)=>{let o=K(e,n);return o||(o=m(8),J(e,o,1440*t,n)),String(o)})(o,i,r),f=S((e,o)=>{const r=JSON.parse(String(K(e,o)));return c||(r.isNew=!1,u.marketing&&(Object.assign(r,u),l=!0),l||r.updated+6e4*n<t?(delete r.id,delete r.referrer,r.start=t,r.count++,r.runs=1,l=!0):r.runs++),r},()=>{l=!0})(s,a)||{},g={id:m(12),start:t,isNew:!0,count:1,runs:1},p=Object.assign(g,u,f,{device:d},{isStart:l,storage:!0,updated:t},e.data);return J(s,JSON.stringify(p),2*n,a),p}function Y(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const o=new URL(e.url||window.location.href),r=e.referrer||document.referrer,s=r&&new URL(r).hostname,a=function(e,t={}){const n="clickId",o={},r={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(i(r,t)).forEach(([t,r])=>{const i=e.searchParams.get(t);i&&(r===n&&(r=t,o[n]=t),o[r]=i)}),o}(o,e.parameters);if(Object.keys(a).length&&(a.marketing||(a.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(o.hostname),t=!n.includes(s)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:m(12),referrer:s},a,e.data):n}var V,Q=Object.defineProperty,Z=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},ee=Object.defineProperty;((e,t)=>{for(var n in t)ee(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>te});var te=((V=te||{})[V.ERROR=0]="ERROR",V[V.INFO=1]="INFO",V[V.DEBUG=2]="DEBUG",V),ne={merge:!0,shallow:!0,extend:!0};function oe(e,t={},n={}){n={...ne,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function re(e){return Array.isArray(e)}function ie(e){return e===document||e instanceof Element}function se(e){return"object"==typeof e&&null!==e&&!re(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ae(e){return"string"==typeof e}function ce(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function ue(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function le(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function de(e,t,n=!0){return e+(null!=t?(n?"-":"")+t:"")}function fe(e,t,n,o=!0){return Se(B(t,de(e,n,o))||"").reduce((e,n)=>{let[o,r]=je(n);if(!o)return e;if(r||(o.endsWith(":")&&(o=o.slice(0,-1)),r=""),r.startsWith("#")){r=r.slice(1);try{let e=t[r];e||"selected"!==r||(e=t.options[t.selectedIndex].text),r=String(e)}catch(e){r=""}}return o.endsWith("[]")?(o=o.slice(0,-2),re(e[o])||(e[o]=[]),e[o].push(ce(r))):e[o]=ce(r),e},{})}function ge(e,t=A.Prefix){var n;const o=e||document.body;if(!o)return[];let r=[];const i=A.Action,s=`[${de(t,i,!1)}]`,a=e=>{Object.keys(fe(t,e,i,!1)).forEach(n=>{r=r.concat(me(e,n,t))})};return o!==document&&(null==(n=o.matches)?void 0:n.call(o,s))&&a(o),Ee(o,s,a),r}function me(e,t,n=A.Prefix){const o=[],{actions:r,nearestOnly:i}=function(e,t,n){let o=t;for(;o;){const t=B(o,de(e,A.Actions,!1));if(t){const e=ye(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const r=B(o,de(e,A.Action,!1));if(r){const e=ye(r);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}o=we(e,o)}return{actions:[],nearestOnly:!1}}(n,e,t);return r.length?(r.forEach(r=>{const s=Se(r.actionParams||"",",").reduce((e,t)=>(e[le(t)]=!0,e),{}),a=be(n,e,s,i);if(!a.length){const t="page",o=`[${de(n,t)}]`,[r,i]=ke(e,o,n,t);a.push({entity:t,data:r,nested:[],context:i})}a.forEach(e=>{o.push({entity:e.entity,action:r.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),o):o}function pe(e=A.Prefix,t=document){const n=de(e,A.Globals,!1);let o={};return Ee(t,`[${n}]`,t=>{o=oe(o,fe(e,t,A.Globals,!1))}),o}function he(e,t){const n=window.location,o="page",r=t===document?document.body:t,[i,s]=ke(r,`[${de(e,o)}]`,e,o);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,s]}function ye(e){const t={};return Se(e).forEach(e=>{const[n,o]=je(e),[r,i]=Oe(n);if(!r)return;let[s,a]=Oe(o||"");s=s||r,t[r]||(t[r]=[]),t[r].push({trigger:r,triggerParams:i,action:s,actionParams:a})}),t}function be(e,t,n,o=!1){const r=[];let i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){const s=ve(e,i,t,n);if(s&&(r.push(s),o))break;i=we(e,i)}return r}function ve(e,t,n,o){const r=B(t,de(e));if(!r||o&&!o[r])return null;const i=[t],s=`[${de(e,r)}],[${de(e,"")}]`,a=de(e,A.Link,!1);let c={};const u=[],[l,d]=ke(n||t,s,e,r);Ee(t,`[${a}]`,t=>{const[n,o]=je(B(t,a));"parent"===o&&Ee(document.body,`[${a}="${n}:child"]`,t=>{i.push(t);const n=ve(e,t);n&&u.push(n)})});const f=[];i.forEach(e=>{e.matches(s)&&f.push(e),Ee(e,s,e=>f.push(e))});let g={};return f.forEach(t=>{g=oe(g,fe(e,t,"")),c=oe(c,fe(e,t,r))}),c=oe(oe(g,c),l),i.forEach(t=>{Ee(t,`[${de(e)}]`,t=>{const n=ve(e,t);n&&u.push(n)})}),{entity:r,data:c,context:d,nested:u}}function we(e,t){const n=de(e,A.Link,!1);if(t.matches(`[${n}]`)){const[e,o]=je(B(t,n));if("child"===o)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function ke(e,t,n,o){let r={};const i={};let s=e;const a=`[${de(n,A.Context,!1)}]`;let c=0;for(;s;)s.matches(t)&&(r=oe(fe(n,s,""),r),r=oe(fe(n,s,o),r)),s.matches(a)&&(Object.entries(fe(n,s,A.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,c])}),++c),s=we(n,s);return[r,i]}function Ee(e,t,n){e.querySelectorAll(t).forEach(n)}function Se(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function je(e){const[t,n]=e.split(/:(.+)/,2);return[le(t),le(n)]}function Oe(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var _e,xe=new WeakMap,Le=new WeakMap,Ae=new WeakMap;function Ce(e){const t=Date.now();let n=Le.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:F(e),lastChecked:t},Le.set(e,n)),n.isVisible}function $e(e){if(window.IntersectionObserver)return ue(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,o;const r=t.target,i=Ae.get(e);if(!i)return;const s=i.timers.get(r);if(t.intersectionRatio>0){const o=Date.now();let a=xe.get(r);if((!a||o-a.lastChecked>1e3)&&(a={isLarge:r.offsetHeight>window.innerHeight,lastChecked:o},xe.set(r,a)),t.intersectionRatio>=.5||a.isLarge&&Ce(r)){const t=null==(n=i.elementConfigs)?void 0:n.get(r);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!s){const t=window.setTimeout(async()=>{var t,n;if(Ce(r)){const o=null==(t=i.elementConfigs)?void 0:t.get(r);(null==o?void 0:o.context)&&await Fe(o.context,r,o.trigger);const s=null==(n=i.elementConfigs)?void 0:n.get(r);(null==s?void 0:s.multiple)?s.blocked=!0:function(e,t){const n=Ae.get(e);if(!n)return;n.observer&&n.observer.unobserve(t);const o=n.timers.get(t);o&&(clearTimeout(o),n.timers.delete(t)),xe.delete(t),Le.delete(t)}(e,r)}},i.duration);i.timers.set(r,t)}return}}s&&(clearTimeout(s),i.timers.delete(r));const a=null==(o=i.elementConfigs)?void 0:o.get(r);(null==a?void 0:a.multiple)&&(a.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function qe(e,t,n={multiple:!1}){var o;const r=e.settings.scope||document,i=Ae.get(r);(null==i?void 0:i.observer)&&t&&(i.elementConfigs||(i.elementConfigs=new WeakMap),i.elementConfigs.set(t,{multiple:null!=(o=n.multiple)&&o,blocked:!1,context:e,trigger:n.multiple?"visible":"impression"}),i.observer.observe(t))}function Pe(e){if(!e)return;const t=Ae.get(e);t&&(t.observer&&t.observer.disconnect(),Ae.delete(e))}function Re(e,t,n,o,r,i,s){const{elb:a,settings:c}=e;if(ae(t)&&t.startsWith("walker "))return a(t,n);if(se(t)){const e=t;return e.source||(e.source=De()),e.globals||(e.globals=pe(c.prefix,c.scope||document)),a(e)}const[u]=String(se(t)?t.name:t).split(" ");let l,d=se(n)?n:{},f={},g=!1;if(ie(n)&&(l=n,g=!0),ie(r)?l=r:se(r)&&Object.keys(r).length&&(f=r),l){const e=be(c.prefix||"data-elb",l).find(e=>e.entity===u);e&&(g&&(d=e.data),f=e.context)}"page"===u&&(d.id=d.id||window.location.pathname);const m=pe(c.prefix,c.scope);return a({name:String(t||""),data:d,context:f,globals:m,nested:i,custom:s,trigger:ae(o)?o:"",source:De()})}function De(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var Ie=[],Ne="hover",Xe="load",We="pulse",Te="scroll",Ue="wait";function Be(e,t){t.scope&&function(e,t){const n=t.scope;n&&(n.addEventListener("click",ue(function(t){He.call(this,e,t)})),n.addEventListener("submit",ue(function(t){Ke.call(this,e,t)})))}(e,t)}function Me(e,t){t.scope&&function(e,t){const n=t.scope;Ie=[];const o=n||document;Pe(o),function(e,t=1e3){Ae.has(e)||Ae.set(e,{observer:$e(e),timers:new WeakMap,duration:t})}(o,1e3);const r=de(t.prefix,A.Action,!1);o!==document&&Ge(e,o,r,t),o.querySelectorAll(`[${r}]`).forEach(n=>{Ge(e,n,r,t)}),Ie.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const o=window.scrollY+window.innerHeight,r=e.offsetTop;if(o<r)return!0;const i=e.clientHeight;return!(100*(1-(r+i-o)/(i||1))>=n&&(Fe(t,e,Te),1))});_e||(_e=function(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}(function(){Ie=n.call(t,Ie,e)}),t.addEventListener("scroll",_e))}(e,o)}(e,t)}async function Fe(e,t,n){const o=me(t,n,e.settings.prefix);return Promise.all(o.map(t=>Re(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function Ge(e,t,n,o){const r=B(t,n);r&&Object.values(ye(r)).forEach(n=>n.forEach(n=>{switch(n.trigger){case Ne:o=e,t.addEventListener("mouseenter",ue(function(e){e.target instanceof Element&&Fe(o,e.target,Ne)}));break;case Xe:!function(e,t){Fe(e,t,Xe)}(e,t);break;case We:!function(e,t,n=""){setInterval(()=>{document.hidden||Fe(e,t,We)},parseInt(n||"")||15e3)}(e,t,n.triggerParams);break;case Te:!function(e,t=""){const n=parseInt(t||"")||50;n<0||n>100||Ie.push([e,n])}(t,n.triggerParams);break;case"impression":qe(e,t);break;case"visible":qe(e,t,{multiple:!0});break;case Ue:!function(e,t,n=""){setTimeout(()=>Fe(e,t,Ue),parseInt(n||"")||15e3)}(e,t,n.triggerParams)}var o}))}function He(e,t){Fe(e,t.target,"click")}function Ke(e,t){t.target&&Fe(e,t.target,"submit")}function Je(e,t,n,o){const r=[];let i=!0;n.forEach(e=>{const t=Ye(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const s=t[0],a=!se(s)&&ae(s)&&s.startsWith("walker ");if(se(s)){if("object"==typeof s&&0===Object.keys(s).length)return}else{const e=Array.from(t);if(!ae(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(o&&a||!o&&!a)&&r.push(t)}),r.forEach(n=>{ze(e,t,n)})}function ze(e,t="data-elb",n){ue(()=>{if(Array.isArray(n)){const[o,...r]=n;if(!o||ae(o)&&""===o.trim())return;if(ae(o)&&o.startsWith("walker "))return void e(o,r[0]);Re({elb:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},o,...r)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e(n)}},()=>{})()}function Ye(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function Ve(e,t={},n){return function(e={}){const{cb:t,consent:n,collector:o,storage:r}=e;if(!n)return G((r?z:Y)(e),o,t);{const r=function(e,t){let n;return(o,r)=>{if(a(n)&&n===(null==o?void 0:o.group))return;n=null==o?void 0:o.group;let i=()=>Y(e);return e.consent&&g((s(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),r)&&(i=()=>z(e)),G(i(),o,t)}}(e,t),i=(s(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{});o?o.command("on","consent",i):M("walker on","consent",i)}}({...t,collector:{push:e,group:void 0,command:n}})}Z({},{env:()=>Qe});var Qe={};Z(Qe,{push:()=>nt});var Ze=()=>{},et=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),tt={error:Ze,info:Ze,debug:Ze,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>tt},nt={get push(){return et()},get command(){return et()},get elb(){return et()},get window(){return{addEventListener:Ze,removeEventListener:Ze,location:{href:"https://example.com/page",pathname:"/page",search:"?query=test",hash:"#section",host:"example.com",hostname:"example.com",origin:"https://example.com",protocol:"https:"},document:{},navigator:{language:"en-US",userAgent:"Mozilla/5.0 (Test)"},screen:{width:1920,height:1080},innerWidth:1920,innerHeight:1080,pageXOffset:0,pageYOffset:0,scrollX:0,scrollY:0}},get document(){return{addEventListener:Ze,removeEventListener:Ze,querySelector:Ze,querySelectorAll:()=>[],getElementById:Ze,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:Ze,getAttribute:Ze,addEventListener:Ze,removeEventListener:Ze}),body:{appendChild:Ze,removeChild:Ze},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}},logger:tt},ot=async(e,t)=>{const{elb:n,command:o,window:r,document:i}=t,s=(null==e?void 0:e.settings)||{},a=r||(void 0!==globalThis.window?globalThis.window:void 0),c=i||(void 0!==globalThis.document?globalThis.document:void 0),u=function(e={},t){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}(s,c),l={settings:u},d={elb:n,settings:u};if(a&&c){if(!1!==u.elbLayer&&n&&function(e,t={}){const n=t.name||"elbLayer",o=t.window||window;if(!o)return;const r=o;r[n]||(r[n]=[]);const i=r[n];i.push=function(...n){if(Ye(n[0])){const o=[...Array.from(n[0])],r=Array.prototype.push.apply(this,[o]);return ze(e,t.prefix,o),r}const o=Array.prototype.push.apply(this,n);return n.forEach(n=>{ze(e,t.prefix,n)}),o},Array.isArray(i)&&i.length>0&&function(e,t="data-elb",n){Je(e,t,n,!0),Je(e,t,n,!1),n.length=0}(e,t.prefix,i)}(n,{name:ae(u.elbLayer)?u.elbLayer:"elbLayer",prefix:u.prefix,window:a}),u.session&&n){const e="boolean"==typeof u.session?{}:u.session;Ve(n,e,o)}await async function(e,t,n){const o=()=>{e(t,n)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)}(Be,d,u),(()=>{if(Me(d,u),u.pageview){const[e,t]=he(u.prefix||"data-elb",u.scope);Re(d,"page view",e,"load",t)}})(),ae(u.elb)&&u.elb&&(a[u.elb]=(...e)=>{const[t,n,o,r,i,s]=e;return Re(d,t,n,o,r,i,s)})}return{type:"browser",config:l,push:(...e)=>{const[t,n,o,r,i,s]=e;return Re(d,t,n,o,r,i,s)},destroy:async()=>{c&&Pe(u.scope||c)},on:async(e,t)=>{switch(e){case"consent":if(u.session&&t&&n){const e="boolean"==typeof u.session?{}:u.session;Ve(n,e,o)}break;case"session":case"ready":default:break;case"run":if(c&&a&&(Me(d,u),u.pageview)){const[e,t]=he(u.prefix||"data-elb",u.scope);Re(d,"page view",e,"load",t)}}}}},rt=Object.defineProperty,it=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})},st=!1;function at(e,t={},n){if(t.filter&&!0===S(()=>t.filter(n),()=>!1)())return;const o=function(e){if(c(e)&&u(e.event)){const{event:t,...n}=e;return{name:t,...n}}return s(e)&&e.length>=2?ct(e):null!=(t=e)&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>0?ct(Array.from(e)):null;var t}(n);if(!o)return;const r=`${t.prefix||"dataLayer"} ${o.name}`,{name:i,...a}=o,l={name:r,data:a};S(()=>e(l),()=>{})()}function ct(e){const[t,n,o]=e;if(!u(t))return null;let r,i={};switch(t){case"consent":if(!u(n)||e.length<3)return null;if("default"!==n&&"update"!==n)return null;if(!c(o)||null===o)return null;r=`${t} ${n}`,i={...o};break;case"event":if(!u(n))return null;r=n,c(o)&&(i={...o});break;case"config":if(!u(n))return null;r=`${t} ${n}`,c(o)&&(i={...o});break;case"set":if(u(n))r=`${t} ${n}`,c(o)&&(i={...o});else{if(!c(n))return null;r=`${t} custom`,i={...n}}break;default:return null}return{name:r,...i}}it({},{push:()=>ft});var ut=()=>{},lt=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),dt={error:ut,info:ut,debug:ut,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>dt},ft={get push(){return lt()},get command(){return lt()},get elb(){return lt()},get window(){return{dataLayer:[],addEventListener:ut,removeEventListener:ut}},logger:dt};function gt(){return["consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"denied",analytics_storage:"granted"}]}function mt(){return["consent","default",{ad_storage:"denied",analytics_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}]}function pt(){return["event","purchase",{transaction_id:"T_12345",value:25.42,currency:"EUR",items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",quantity:1,price:25.42}]}]}function ht(){return["event","add_to_cart",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_variant:"red",quantity:1,price:15.25}]}]}function yt(){return["event","view_item",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",price:15.25}]}]}function bt(){return["config","G-XXXXXXXXXX",{page_title:"Custom Page Title",page_location:"https://example.com/page",send_page_view:!1}]}function vt(){return["set",{currency:"EUR",country:"DE"}]}function wt(){return{event:"custom_event",custom_parameter:"custom_value",user_id:"user123"}}it({},{add_to_cart:()=>ht,config:()=>bt,consentDefault:()=>mt,consentUpdate:()=>gt,directDataLayerEvent:()=>wt,purchase:()=>pt,setCustom:()=>vt,view_item:()=>yt});it({},{add_to_cart:()=>St,config:()=>xt,configGA4:()=>Ot,consentOnlyMapping:()=>Lt,consentUpdate:()=>kt,customEvent:()=>_t,purchase:()=>Et,view_item:()=>jt});var kt={name:"walker consent",settings:{command:{map:{functional:{value:!0},analytics:{key:"analytics_storage",fn:e=>"granted"===e},marketing:{key:"ad_storage",fn:e=>"granted"===e}}}}},Et={name:"order complete",data:{map:{id:"transaction_id",total:"value",currency:"currency",nested:{loop:["items",{map:{type:{value:"product"},data:{map:{id:"item_id",name:"item_name",category:"item_category",quantity:"quantity",price:"price"}}}}]}}}},St={name:"product add",data:{map:{id:"items.0.item_id",name:"items.0.item_name",price:"value",currency:"currency",color:"items.0.item_variant",quantity:"items.0.quantity"}}},jt={name:"product view",data:{map:{id:"items.0.item_id",name:"items.0.item_name",category:"items.0.item_category",price:"items.0.price",currency:"currency"}}},Ot={name:"page view",data:{map:{title:"page_title",url:"page_location"}}},_t={data:{map:{user_id:"user_id",custom_parameter:"custom_parameter"}}},xt={consent:{update:kt},purchase:Et,add_to_cart:St,view_item:jt,"config G-XXXXXXXXXX":Ot,custom_event:_t,"*":{data:{}}},Lt={consent:{update:kt}},At=async(e,t)=>{const{elb:n,window:o}=t,r={name:"dataLayer",prefix:"dataLayer",...null==e?void 0:e.settings},i={settings:r};return o&&(function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer",r=window[o];if(Array.isArray(r)&&!st){st=!0;try{for(const t of r)at(e,n,t)}finally{st=!1}}}(n,i),function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer";window[o]||(window[o]=[]);const r=window[o];if(!Array.isArray(r))return;const i=r.push.bind(r);r.push=function(...t){if(st)return i(...t);st=!0;try{for(const o of t)at(e,n,o)}finally{st=!1}return i(...t)}}(n,i)),{type:"dataLayer",config:i,push:n,destroy:async()=>{const e=r.name||"dataLayer";o&&o[e]&&Array.isArray(o[e])}}};function Ct(){window.dataLayer=window.dataLayer||[];const e=e=>{c(e)&&c(e.source)&&String(e.source.type).includes("dataLayer")||window.dataLayer.push(e)};return{type:"dataLayer",config:{},push:(t,n)=>{e(n.data||t)},pushBatch:t=>{e({name:"batch",batched_event:t.key,events:t.data.length?t.data:t.events})}}}var $t={};async function qt(e={}){const t=i({collector:{destinations:{dataLayer:{code:Ct()}}},browser:{session:!0},dataLayer:!1,elb:"elb",run:!0},e),n={...t.collector,sources:{browser:{code:ot,config:{settings:t.browser},env:{window:"undefined"!=typeof window?window:void 0,document:"undefined"!=typeof document?document:void 0}}}};if(t.dataLayer){const e=c(t.dataLayer)?t.dataLayer:{};n.sources&&(n.sources.dataLayer={code:At,config:{settings:e}})}const o=await U(n);return"undefined"!=typeof window&&(t.elb&&(window[t.elb]=o.elb),t.name&&(window[t.name]=o.collector)),o}var Pt=qt;export{$t as Walkerjs,qt as createWalkerjs,Pt as default,ge as getAllEvents,me as getEvents,pe as getGlobals};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/destination.ts","../src/types/index.ts","../src/schemas.ts","../src/index.ts"],"sourcesContent":["import type { Destination } from '@walkeros/core';\nimport type { DataLayer } from './types';\nimport { isObject } from '@walkeros/core';\n\nexport function dataLayerDestination(): Destination.Instance {\n window.dataLayer = window.dataLayer || [];\n const dataLayerPush = (event: unknown) => {\n // Do not process events from dataLayer source\n if (\n isObject(event) &&\n isObject(event.source) &&\n String(event.source.type).includes('dataLayer')\n )\n return;\n\n (window.dataLayer as DataLayer)!.push(event);\n };\n const destination: Destination.Instance = {\n type: 'dataLayer',\n config: {},\n push: (event, context) => {\n dataLayerPush(context.data || event);\n },\n pushBatch: (batch) => {\n dataLayerPush({\n name: 'batch',\n batched_event: batch.key,\n events: batch.data.length ? batch.data : batch.events,\n });\n },\n };\n\n return destination;\n}\n","import type { Collector, Source, WalkerOS } from '@walkeros/core';\nimport type { SourceBrowser } from '@walkeros/web-source-browser';\nimport type { SourceDataLayer } from '@walkeros/web-source-datalayer';\n\ndeclare global {\n interface Window {\n [key: string]: DataLayer;\n }\n}\n\n// Instance interface\nexport interface Instance {\n collector: Collector.Instance;\n elb: SourceBrowser.BrowserPush;\n}\n\n// Configuration interface\nexport interface Config {\n // Collector configuration\n collector?: Collector.InitConfig;\n\n // Browser source configuration\n browser?: Partial<SourceBrowser.Settings>;\n\n // DataLayer configuration\n dataLayer?: boolean | Partial<SourceDataLayer.Settings>;\n\n // Global configuration\n elb?: string; // Name for the global elb function\n name?: string; // Name for the global instance\n run?: boolean; // Auto-run on initialization (default: true)\n}\n\nexport type DataLayer = undefined | Array<unknown>;\n","import type { RJSFSchema } from '@rjsf/utils';\n\nexport const settings: RJSFSchema = {\n type: 'object',\n properties: {\n elb: {\n type: 'string',\n default: 'elb',\n description: 'Global function name for event tracking',\n },\n name: {\n type: 'string',\n default: 'walkerjs',\n description: 'Global instance name',\n },\n run: {\n type: 'boolean',\n default: true,\n description: 'Auto-initialize walker.js on load',\n },\n browser: {\n type: 'object',\n default: {\n run: true,\n session: true,\n scope: 'document.body',\n pageview: true,\n },\n description:\n 'Browser source configuration. Set to false to disable. See browser configuration section below for details.',\n },\n dataLayer: {\n type: 'object',\n default: false,\n description:\n 'DataLayer source configuration. Set to true for defaults or object for custom config. See dataLayer configuration section below.',\n },\n collector: {\n type: 'object',\n default: {},\n description:\n 'Collector configuration including destinations and consent settings. See collector configuration section below.',\n },\n },\n};\n\nexport const browserConfig: RJSFSchema = {\n type: 'object',\n properties: {\n 'browser.run': {\n type: 'boolean',\n default: true,\n description: 'Auto-start DOM tracking',\n },\n 'browser.session': {\n type: 'boolean',\n default: true,\n description: 'Enable session tracking',\n },\n 'browser.scope': {\n type: 'string',\n default: 'document.body',\n description: 'DOM element scope for tracking',\n },\n 'browser.pageview': {\n type: 'boolean',\n default: true,\n description: 'Enable automatic page view events',\n },\n },\n};\n\nexport const dataLayerConfig: RJSFSchema = {\n type: 'object',\n properties: {\n dataLayer: {\n type: 'boolean',\n default: false,\n description: 'Enable dataLayer integration with defaults',\n },\n 'dataLayer.name': {\n type: 'string',\n default: 'dataLayer',\n description: 'DataLayer variable name',\n },\n 'dataLayer.prefix': {\n type: 'string',\n default: 'dataLayer',\n description: 'Event prefix for dataLayer events',\n },\n },\n};\n\nexport const collectorConfig: RJSFSchema = {\n type: 'object',\n properties: {\n 'collector.consent': {\n type: 'object',\n default: { functional: true },\n description: 'Default consent state',\n },\n 'collector.destinations': {\n type: 'object',\n default: {},\n description:\n 'Destination configurations. See destinations documentation for available options.',\n },\n },\n};\n","import type { Config, Instance } from './types';\nimport type { Collector, Elb, WalkerOS } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport { assign, isObject } from '@walkeros/core';\nimport {\n sourceBrowser,\n getAllEvents,\n getEvents,\n getGlobals,\n SourceBrowser,\n} from '@walkeros/web-source-browser';\nimport { sourceDataLayer } from '@walkeros/web-source-datalayer';\nimport { dataLayerDestination } from './destination';\n\n// Re-export types\nexport * as Walkerjs from './types';\n\n// Export schemas\nexport * as schemas from './schemas';\n\nexport { getAllEvents, getEvents, getGlobals };\n\n// Factory function to create walker.js instance\nexport async function createWalkerjs(config: Config = {}): Promise<Instance> {\n // Default configuration\n const defaultConfig: Config = {\n collector: {\n destinations: {\n dataLayer: { code: dataLayerDestination() },\n },\n },\n browser: {\n session: true,\n },\n dataLayer: false,\n elb: 'elb',\n run: true,\n };\n\n const fullConfig = assign(defaultConfig, config);\n\n // Build collector config with sources\n const collectorConfig: Collector.InitConfig = {\n ...fullConfig.collector,\n sources: {\n browser: {\n code: sourceBrowser,\n config: {\n settings: fullConfig.browser,\n },\n env: {\n window: typeof window !== 'undefined' ? window : undefined,\n document: typeof document !== 'undefined' ? document : undefined,\n },\n },\n },\n };\n\n // Add dataLayer source if configured\n if (fullConfig.dataLayer) {\n const dataLayerSettings = isObject(fullConfig.dataLayer)\n ? fullConfig.dataLayer\n : {};\n\n if (collectorConfig.sources) {\n collectorConfig.sources.dataLayer = {\n code: sourceDataLayer,\n config: {\n settings: dataLayerSettings,\n },\n };\n }\n }\n\n const flow = await startFlow<SourceBrowser.BrowserPush>(collectorConfig);\n\n // Set up global variables if configured (only in browser environments)\n if (typeof window !== 'undefined') {\n if (fullConfig.elb) window[fullConfig.elb] = flow.elb;\n if (fullConfig.name) window[fullConfig.name] = flow.collector;\n }\n\n return flow;\n}\n\n// Export factory function as default\nexport default createWalkerjs;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,uBAA6C;AAC3D,SAAO,YAAY,OAAO,aAAa,CAAC;AACxC,QAAM,gBAAgB,CAAC,UAAmB;AAExC,QACE,EAAS,KAAK,KACd,EAAS,MAAM,MAAM,KACrB,OAAO,MAAM,OAAO,IAAI,EAAE,SAAS,WAAW;AAE9C;AAEF,IAAC,OAAO,UAAyB,KAAK,KAAK;AAAA,EAC7C;AACA,QAAM,cAAoC;AAAA,IACxC,MAAM;AAAA,IACN,QAAQ,CAAC;AAAA,IACT,MAAM,CAAC,OAAO,YAAY;AACxB,oBAAc,QAAQ,QAAQ,KAAK;AAAA,IACrC;AAAA,IACA,WAAW,CAAC,UAAU;AACpB,oBAAc;AAAA,QACZ,MAAM;AAAA,QACN,eAAe,MAAM;AAAA,QACrB,QAAQ,MAAM,KAAK,SAAS,MAAM,OAAO,MAAM;AAAA,MACjD,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;;;ACjCA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,WAAuB;AAAA,EAClC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,KAAK;AAAA,MACH,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,QACP,KAAK;AAAA,QACL,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,MACZ;AAAA,MACA,aACE;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACE;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,aACE;AAAA,IACJ;AAAA,EACF;AACF;AAEO,IAAM,gBAA4B;AAAA,EACvC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,eAAe;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,mBAAmB;AAAA,MACjB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,oBAAoB;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AACF;AAEO,IAAM,kBAA8B;AAAA,EACzC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,kBAAkB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA,oBAAoB;AAAA,MAClB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AACF;AAEO,IAAM,kBAA8B;AAAA,EACzC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,qBAAqB;AAAA,MACnB,MAAM;AAAA,MACN,SAAS,EAAE,YAAY,KAAK;AAAA,MAC5B,aAAa;AAAA,IACf;AAAA,IACA,0BAA0B;AAAA,MACxB,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,aACE;AAAA,IACJ;AAAA,EACF;AACF;;;ACrFA,eAAsB,eAAe,SAAiB,CAAC,GAAsB;AAE3E,QAAM,gBAAwB;AAAA,IAC5B,WAAW;AAAA,MACT,cAAc;AAAA,QACZ,WAAW,EAAE,MAAM,qBAAqB,EAAE;AAAA,MAC5C;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AAAA,EACP;AAEA,QAAM,aAAa,EAAO,eAAe,MAAM;AAG/C,QAAMA,mBAAwC;AAAA,IAC5C,GAAG,WAAW;AAAA,IACd,SAAS;AAAA,MACP,SAAS;AAAA,QACP,MAAM;AAAA,QACN,QAAQ;AAAA,UACN,UAAU,WAAW;AAAA,QACvB;AAAA,QACA,KAAK;AAAA,UACH,QAAQ,OAAO,WAAW,cAAc,SAAS;AAAA,UACjD,UAAU,OAAO,aAAa,cAAc,WAAW;AAAA,QACzD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,MAAI,WAAW,WAAW;AACxB,UAAM,oBAAoB,EAAS,WAAW,SAAS,IACnD,WAAW,YACX,CAAC;AAEL,QAAIA,iBAAgB,SAAS;AAC3B,MAAAA,iBAAgB,QAAQ,YAAY;AAAA,QAClC,MAAMC;AAAA,QACN,QAAQ;AAAA,UACN,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,OAAO,MAAMC,GAAqCF,gBAAe;AAGvE,MAAI,OAAO,WAAW,aAAa;AACjC,QAAI,WAAW,IAAK,QAAO,WAAW,GAAG,IAAI,KAAK;AAClD,QAAI,WAAW,KAAM,QAAO,WAAW,IAAI,IAAI,KAAK;AAAA,EACtD;AAEA,SAAO;AACT;AAGA,IAAO,gBAAQ;","names":["collectorConfig","D","Q"]}
|
|
1
|
+
{"version":3,"sources":["../src/destination.ts","../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type { Destination } from '@walkeros/core';\nimport type { DataLayer } from './types';\nimport { isObject } from '@walkeros/core';\n\nexport function dataLayerDestination(): Destination.Instance {\n window.dataLayer = window.dataLayer || [];\n const dataLayerPush = (event: unknown) => {\n // Do not process events from dataLayer source\n if (\n isObject(event) &&\n isObject(event.source) &&\n String(event.source.type).includes('dataLayer')\n )\n return;\n\n (window.dataLayer as DataLayer)!.push(event);\n };\n const destination: Destination.Instance = {\n type: 'dataLayer',\n config: {},\n push: (event, context) => {\n dataLayerPush(context.data || event);\n },\n pushBatch: (batch) => {\n dataLayerPush({\n name: 'batch',\n batched_event: batch.key,\n events: batch.data.length ? batch.data : batch.events,\n });\n },\n };\n\n return destination;\n}\n","import type { Collector, Source, WalkerOS } from '@walkeros/core';\nimport type { SourceBrowser } from '@walkeros/web-source-browser';\nimport type { SourceDataLayer } from '@walkeros/web-source-datalayer';\n\ndeclare global {\n interface Window {\n [key: string]: DataLayer;\n }\n}\n\n// Instance interface\nexport interface Instance {\n collector: Collector.Instance;\n elb: SourceBrowser.BrowserPush;\n}\n\n// Configuration interface\nexport interface Config {\n // Collector configuration\n collector?: Collector.InitConfig;\n\n // Browser source configuration\n browser?: Partial<SourceBrowser.Settings>;\n\n // DataLayer configuration\n dataLayer?: boolean | Partial<SourceDataLayer.Settings>;\n\n // Global configuration\n elb?: string; // Name for the global elb function\n name?: string; // Name for the global instance\n run?: boolean; // Auto-run on initialization (default: true)\n}\n\nexport type DataLayer = undefined | Array<unknown>;\n","import type { Config, Instance } from './types';\nimport type { Collector, Elb, WalkerOS } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport { assign, isObject } from '@walkeros/core';\nimport {\n sourceBrowser,\n getAllEvents,\n getEvents,\n getGlobals,\n SourceBrowser,\n} from '@walkeros/web-source-browser';\nimport { sourceDataLayer } from '@walkeros/web-source-datalayer';\nimport { dataLayerDestination } from './destination';\n\n// Re-export types\nexport * as Walkerjs from './types';\n\nexport { getAllEvents, getEvents, getGlobals };\n\n// Factory function to create walker.js instance\nexport async function createWalkerjs(config: Config = {}): Promise<Instance> {\n // Default configuration\n const defaultConfig: Config = {\n collector: {\n destinations: {\n dataLayer: { code: dataLayerDestination() },\n },\n },\n browser: {\n session: true,\n },\n dataLayer: false,\n elb: 'elb',\n run: true,\n };\n\n const fullConfig = assign(defaultConfig, config);\n\n // Build collector config with sources\n const collectorConfig: Collector.InitConfig = {\n ...fullConfig.collector,\n sources: {\n browser: {\n code: sourceBrowser,\n config: {\n settings: fullConfig.browser,\n },\n env: {\n window: typeof window !== 'undefined' ? window : undefined,\n document: typeof document !== 'undefined' ? document : undefined,\n },\n },\n },\n };\n\n // Add dataLayer source if configured\n if (fullConfig.dataLayer) {\n const dataLayerSettings = isObject(fullConfig.dataLayer)\n ? fullConfig.dataLayer\n : {};\n\n if (collectorConfig.sources) {\n collectorConfig.sources.dataLayer = {\n code: sourceDataLayer,\n config: {\n settings: dataLayerSettings,\n },\n };\n }\n }\n\n const flow = await startFlow<SourceBrowser.BrowserPush>(collectorConfig);\n\n // Set up global variables if configured (only in browser environments)\n if (typeof window !== 'undefined') {\n if (fullConfig.elb) window[fullConfig.elb] = flow.elb;\n if (fullConfig.name) window[fullConfig.name] = flow.collector;\n }\n\n return flow;\n}\n\n// Export factory function as default\nexport default createWalkerjs;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAAS,uBAA6C;AAC3D,SAAO,YAAY,OAAO,aAAa,CAAC;AACxC,QAAM,gBAAgB,CAAC,UAAmB;AAExC,QACE,EAAS,KAAK,KACd,EAAS,MAAM,MAAM,KACrB,OAAO,MAAM,OAAO,IAAI,EAAE,SAAS,WAAW;AAE9C;AAEF,IAAC,OAAO,UAAyB,KAAK,KAAK;AAAA,EAC7C;AACA,QAAM,cAAoC;AAAA,IACxC,MAAM;AAAA,IACN,QAAQ,CAAC;AAAA,IACT,MAAM,CAAC,OAAO,YAAY;AACxB,oBAAc,QAAQ,QAAQ,KAAK;AAAA,IACrC;AAAA,IACA,WAAW,CAAC,UAAU;AACpB,oBAAc;AAAA,QACZ,MAAM;AAAA,QACN,eAAe,MAAM;AAAA,QACrB,QAAQ,MAAM,KAAK,SAAS,MAAM,OAAO,MAAM;AAAA,MACjD,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;;;ACjCA;;;ACoBA,eAAsB,eAAe,SAAiB,CAAC,GAAsB;AAE3E,QAAM,gBAAwB;AAAA,IAC5B,WAAW;AAAA,MACT,cAAc;AAAA,QACZ,WAAW,EAAE,MAAM,qBAAqB,EAAE;AAAA,MAC5C;AAAA,IACF;AAAA,IACA,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,KAAK;AAAA,IACL,KAAK;AAAA,EACP;AAEA,QAAM,aAAa,EAAO,eAAe,MAAM;AAG/C,QAAM,kBAAwC;AAAA,IAC5C,GAAG,WAAW;AAAA,IACd,SAAS;AAAA,MACP,SAAS;AAAA,QACP,MAAM;AAAA,QACN,QAAQ;AAAA,UACN,UAAU,WAAW;AAAA,QACvB;AAAA,QACA,KAAK;AAAA,UACH,QAAQ,OAAO,WAAW,cAAc,SAAS;AAAA,UACjD,UAAU,OAAO,aAAa,cAAc,WAAW;AAAA,QACzD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,MAAI,WAAW,WAAW;AACxB,UAAM,oBAAoB,EAAS,WAAW,SAAS,IACnD,WAAW,YACX,CAAC;AAEL,QAAI,gBAAgB,SAAS;AAC3B,sBAAgB,QAAQ,YAAY;AAAA,QAClC,MAAMA;AAAA,QACN,QAAQ;AAAA,UACN,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,OAAO,MAAMC,GAAqC,eAAe;AAGvE,MAAI,OAAO,WAAW,aAAa;AACjC,QAAI,WAAW,IAAK,QAAO,WAAW,GAAG,IAAI,KAAK;AAClD,QAAI,WAAW,KAAM,QAAO,WAAW,IAAI,IAAI,KAAK;AAAA,EACtD;AAEA,SAAO;AACT;AAGA,IAAO,gBAAQ;","names":["D","Q"]}
|
package/dist/walker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var e=Object.defineProperty,t=Object.defineProperty;((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})({},{Level:()=>o});var n,o=((n=o||{})[n.ERROR=0]="ERROR",n[n.INFO=1]="INFO",n[n.DEBUG=2]="DEBUG",n),r={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},i={merge:!0,shallow:!0,extend:!0};function a(e,t={},n={}){n={...i,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function s(e){return Array.isArray(e)}function c(e){return void 0!==e}function u(e){return"object"==typeof e&&null!==e&&!s(e)&&"[object Object]"===Object.prototype.toString.call(e)}function l(e){return"string"==typeof e}function d(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=d(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(d(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 f(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&s(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=f(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,!r)break}return c(r)?r:n}function g(e,t,n){if(!u(e))return e;const o=d(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function p(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function m(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function y(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function h(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=y(e)):n=e,void 0!==t&&(t instanceof Error?o.error=y(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=y(o.error))):o.value=t),{message:n,context:o}}var b=(e,t,n,r)=>{const i=`${o[e]}${r.length>0?` [${r.join(":")}]`:""}`,a=Object.keys(n).length>0;0===e?a?console.error(i,t,n):console.error(i,t):a?console.log(i,t,n):console.log(i,t)};function v(e={}){return w({level:void 0!==e.level?(t=e.level,"string"==typeof t?o[t]:t):0,handler:e.handler,scope:[]});var t}function w(e){const{level:t,handler:n,scope:o}=e,r=(e,r,i)=>{if(e<=t){const t=h(r,i);n?n(e,t.message,t.context,o,b):b(e,t.message,t.context,o)}};return{error:(e,t)=>r(0,e,t),info:(e,t)=>r(1,e,t),debug:(e,t)=>r(2,e,t),throw:(e,t)=>{const r=h(e,t);throw n?n(0,r.message,r.context,o,b):b(0,r.message,r.context,o),new Error(r.message)},scope:e=>w({level:t,handler:n,scope:[...o,e]})}}function k(e){return function(e){return"boolean"==typeof e}(e)||l(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!c(e)||s(e)&&e.every(k)||u(e)&&Object.values(e).every(k)}function E(e){return k(e)?e:void 0}function j(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function S(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(null==n?void 0:n())}}}async function O(e,t={},n={}){var o;if(!c(e))return;const r=u(e)&&e.consent||n.consent||(null==(o=n.collector)?void 0:o.consent),i=s(t)?t:[t];for(const t of i){const o=await S(L)(e,t,{...n,consent:r});if(c(o))return o}}async function L(e,t,n={}){const{collector:o,consent:r}=n;return(s(t)?t:[t]).reduce(async(t,i)=>{const a=await t;if(a)return a;const u=l(i)?{key:i}:i;if(!Object.keys(u).length)return;const{condition:d,consent:g,fn:m,key:y,loop:h,map:b,set:v,validate:w,value:k}=u;if(d&&!await S(d)(e,i,o))return;if(g&&!p(g,r))return k;let j=c(k)?k:e;if(m&&(j=await S(m)(e,i,n)),y&&(j=f(e,y,k)),h){const[t,o]=h,r="this"===t?[e]:await O(e,t,n);s(r)&&(j=(await Promise.all(r.map(e=>O(e,o,n)))).filter(c))}else b?j=await Object.entries(b).reduce(async(t,[o,r])=>{const i=await t,a=await O(e,r,n);return c(a)&&(i[o]=a),i},Promise.resolve({})):v&&(j=await Promise.all(v.map(t=>L(e,t,n))));w&&!await S(w)(j)&&(j=void 0);const _=E(j);return c(_)?_:E(k)},Promise.resolve(void 0))}async function _(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=g(e,t,r)}));const{eventMapping:o,mappingKey:r}=await async function(e,t){var n;const[o,r]=(e.name||"").split(" ");if(!t||!o||!r)return{};let i,a="",c=o,u=r;const l=t=>{if(t)return(t=s(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[c]||(c="*");const d=t[c];return d&&(d[u]||(u="*"),i=l(d[u])),i||(c="*",u="*",i=l(null==(n=t[c])?void 0:n[u])),i&&(a=`${c} ${u}`),{eventMapping:i,mappingKey:a}}(e,t.mapping);(null==o?void 0:o.policy)&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await O(e,o,{collector:n});e=g(e,t,r)}));let i=t.data&&await O(e,t.data,{collector:n});if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await O(e,o.data,{collector:n});i=u(i)&&u(t)?a(i,t):t}}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1}}function x(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function A(e,t,n){return function(...o){let r;const i="post"+t,a=n["pre"+t],s=n[i];return r=a?a({fn:e},...o):e(...o),s&&(r=s({fn:e,result:r},...o)),r}}function C(e,t){return(e.getAttribute(t)||"").trim()}function $(e){const t={};return function(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}(e).forEach(e=>{const[n,o]=function(e){const[t,n]=e.split(/:(.+)/,2);return[x(t||""),x(n||"")]}(e);n&&("true"===o?t[n]=!0:"false"===o?t[n]=!1:o&&/^\d+$/.test(o)?t[n]=parseInt(o,10):o&&/^\d+\.\d+$/.test(o)?t[n]=parseFloat(o):t[n]=o||!0)}),t}var q=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function P(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const o=window.innerHeight,r=e.getBoundingClientRect(),i=r.height,a=r.y,s=a+i,c={x:r.x+e.offsetWidth/2,y:r.y+e.offsetHeight/2};if(i<=o){if(e.offsetWidth+r.width===0||e.offsetHeight+r.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=o/2;if(a<0&&s<e)return!1;if(s>o&&a>e)return!1;n=document.elementFromPoint(c.x,o/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function R(e,t,n){return!1===n?e:(n||(n=D),n(e,t,D))}var D=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):q("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):q({name:"session start",data:e})),e};function I(e,t=r.Storage.Session){var n;function o(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let i,a;switch(t){case r.Storage.Cookie:i=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case r.Storage.Local:a=o(window.localStorage.getItem(e));break;case r.Storage.Session:a=o(window.sessionStorage.getItem(e))}return a&&(i=a.v,0!=a.e&&a.e<Date.now()&&(function(e,t=r.Storage.Session){switch(t){case r.Storage.Cookie:N(e,"",0,t);break;case r.Storage.Local:window.localStorage.removeItem(e);break;case r.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),i="")),function(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}(i||"")}function N(e,t,n=30,o=r.Storage.Session,i){const a={e:Date.now()+6e4*n,v:String(t)},s=JSON.stringify(a);switch(o){case r.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let o=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;i&&(o+="; domain="+i),document.cookie=o;break}case r.Storage.Local:window.localStorage.setItem(e,s);break;case r.Storage.Session:window.sessionStorage.setItem(e,s)}return I(e,o)}function X(e={}){const t=Date.now(),{length:n=30,deviceKey:o="elbDeviceId",deviceStorage:r="local",deviceAge:i=30,sessionKey:a="elbSessionId",sessionStorage:s="local",pulse:c=!1}=e,u=T(e);let l=!1;const d=j((e,t,n)=>{let o=I(e,n);return o||(o=m(8),N(e,o,1440*t,n)),String(o)})(o,i,r),f=j((e,o)=>{const r=JSON.parse(String(I(e,o)));return c||(r.isNew=!1,u.marketing&&(Object.assign(r,u),l=!0),l||r.updated+6e4*n<t?(delete r.id,delete r.referrer,r.start=t,r.count++,r.runs=1,l=!0):r.runs++),r},()=>{l=!0})(a,s)||{},g={id:m(12),start:t,isNew:!0,count:1,runs:1},p=Object.assign(g,u,f,{device:d},{isStart:l,storage:!0,updated:t},e.data);return N(a,JSON.stringify(p),2*n,s),p}function T(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const o=new URL(e.url||window.location.href),r=e.referrer||document.referrer,i=r&&new URL(r).hostname,s=function(e,t={}){const n="clickId",o={},r={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(a(r,t)).forEach(([t,r])=>{const i=e.searchParams.get(t);i&&(r===n&&(r=t,o[n]=t),o[r]=i)}),o}(o,e.parameters);if(Object.keys(s).length&&(s.marketing||(s.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(o.hostname),t=!n.includes(i)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:m(12),referrer:i},s,e.data):n}var U={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"},W={type:"code",config:{},init(e){var t;const{config:n,logger:o}=e,r=null==(t=n.settings)?void 0:t.init;if(r)try{new Function("context",r)(e)}catch(e){o.error("Code destination init error:",e)}},push(e,t){var n,o;const{mapping:r,config:i,logger:a}=t,s=null!=(o=null==r?void 0:r.push)?o:null==(n=i.settings)?void 0:n.push;if(s)try{new Function("event","context",s)(e,t)}catch(e){a.error("Code destination push error:",e)}},pushBatch(e,t){var n,o;const{mapping:r,config:i,logger:a}=t,s=null!=(o=null==r?void 0:r.pushBatch)?o:null==(n=i.settings)?void 0:n.pushBatch;if(s)try{new Function("batch","context",s)(e,t)}catch(e){a.error("Code destination pushBatch error:",e)}},on(e,t){var n;const{config:o,logger:r}=t,i=null==(n=o.settings)?void 0:n.on;if(i)try{new Function("type","context",i)(e,t)}catch(e){r.error("Code destination on error:",e)}}};function B(e){return!0===e?W:e}async function M(e,t,n){const{allowed:o,consent:r,globals:i,user:s}=e;if(!o)return H({ok:!1});t&&e.queue.push(t),n||(n=e.destinations);const c=await Promise.all(Object.entries(n||{}).map(async([n,o])=>{let c=(o.queue||[]).map(e=>({...e,consent:r}));if(o.queue=[],t){const e=d(t);c.push(e)}if(!c.length)return{id:n,destination:o,skipped:!0};const u=[],l=c.filter(e=>{const t=p(o.config.consent,r,e.consent);return!t||(e.consent=t,u.push(e),!1)});if(o.queue.concat(l),!u.length)return{id:n,destination:o,queue:c};if(!await S(F)(e,o))return{id:n,destination:o,queue:c};let f=!1;return o.dlq||(o.dlq=[]),await Promise.all(u.map(async t=>(t.globals=a(i,t.globals),t.user=a(s,t.user),await S(G,n=>{const r=o.type||"unknown";return e.logger.scope(r).error("Push failed",{error:n,event:t.name}),f=!0,o.dlq.push([t,n]),!1})(e,o,t),t))),{id:n,destination:o,error:f}})),u=[],l=[],f=[];for(const e of c){if(e.skipped)continue;const t=e.destination,n={id:e.id,destination:t};e.error?f.push(n):e.queue&&e.queue.length?(t.queue=(t.queue||[]).concat(e.queue),l.push(n)):u.push(n)}return H({ok:!f.length,event:t,successful:u,queued:l,failed:f})}async function F(e,t){if(t.init&&!t.config.init){const n=t.type||"unknown",o=e.logger.scope(n),r={collector:e,config:t.config,env:K(t.env,t.config.env),logger:o};o.debug("init");const i=await A(t.init,"DestinationInit",e.hooks)(r);if(!1===i)return i;t.config={...i||t.config,init:!0},o.debug("init done")}return!0}async function G(e,t,n){var o;const{config:r}=t,i=await _(n,r,e);if(i.ignore)return!1;const a=t.type||"unknown",s=e.logger.scope(a),u={collector:e,config:r,data:i.data,mapping:i.mapping,env:K(t.env,r.env),logger:s},l=i.mapping;if((null==l?void 0:l.batch)&&t.pushBatch){const n=l.batched||{key:i.mappingKey||"",events:[],data:[]};n.events.push(i.event),c(i.data)&&n.data.push(i.data),l.batchFn=l.batchFn||function(e,t=1e3,n=!1){let o,r=null,i=!1;return(...a)=>new Promise(s=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...a),s(o))},t),c&&(i=!0,o=e(...a),s(o))})}((e,t)=>{const o=e.type||"unknown",a=t.logger.scope(o),s={collector:t,config:r,data:i.data,mapping:l,env:K(e.env,r.env),logger:a};a.debug("push batch",{events:n.events.length}),A(e.pushBatch,"DestinationPushBatch",t.hooks)(n,s),a.debug("push batch done"),n.events=[],n.data=[]},l.batch),l.batched=n,null==(o=l.batchFn)||o.call(l,t,e)}else s.debug("push",{event:i.event.name}),await A(t.push,"DestinationPush",e.hooks)(i.event,u),s.debug("push done");return!0}function H(e){var t;return a({ok:!(null==(t=null==e?void 0:e.failed)?void 0:t.length),successful:[],queued:[],failed:[]},e)}function K(e,t){return e||t?t?e&&u(e)&&u(t)?{...e,...t}:t:e:{}}function J(e,t,n,o){let r,i=n||[];switch(n||(i=e.on[t]||[]),t){case U.Consent:r=o||e.consent;break;case U.Session:r=e.session;break;case U.Ready:case U.Run:default:r=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&j(e.on)(t,r)}),Object.values(e.destinations).forEach(n=>{if(n.on){const o=n.type||"unknown",i=e.logger.scope(o).scope("on").scope(t),a={collector:e,config:n.config,data:r,env:K(n.env,n.config.env),logger:i};j(n.on)(t,a)}}),i.length)switch(t){case U.Consent:!function(e,t,n){const o=n||e.consent;t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{j(t[n])(e,o)})})}(e,i,o);break;case U.Ready:case U.Run:s=i,(a=e).allowed&&s.forEach(e=>{j(e)(a)});break;case U.Session:!function(e,t){e.session&&t.forEach(t=>{j(t)(e,e.session)})}(e,i)}var a,s}async function z(e,t,n,o){let r;switch(t){case U.Config:u(n)&&a(e.config,n,{shallow:!1});break;case U.Consent:u(n)&&(r=await async function(e,t){const{consent:n}=e;let o=!1;const r={};return Object.entries(t).forEach(([e,t])=>{const n=!!t;r[e]=n,o=o||n}),e.consent=a(n,r),J(e,"consent",void 0,r),o?M(e):H({ok:!0})}(e,n));break;case U.Custom:u(n)&&(e.custom=a(e.custom,n));break;case U.Destination:u(n)&&function(e){return"function"==typeof e}(n.push)&&(r=await async function(e,t,n){const{code:o,config:r={},env:i={}}=t,a=n||r||{init:!1},s=B(o),c={...s,config:a,env:K(s.env,i)};let u=c.config.id;if(!u)do{u=m(4)}while(e.destinations[u]);return e.destinations[u]=c,!1!==c.config.queue&&(c.queue=[...e.queue]),M(e,void 0,{[u]:c})}(e,{code:n},o));break;case U.Globals:u(n)&&(e.globals=a(e.globals,n));break;case U.On:l(n)&&function(e,t,n){const o=e.on,r=o[t]||[],i=s(n)?n:[n];i.forEach(e=>{r.push(e)}),o[t]=r,J(e,t,i)}(e,n,o);break;case U.Ready:J(e,"ready");break;case U.Run:r=await async function(e,t){e.allowed=!0,e.count=0,e.group=m(),e.timing=Date.now(),t&&(t.consent&&(e.consent=a(e.consent,t.consent)),t.user&&(e.user=a(e.user,t.user)),t.globals&&(e.globals=a(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=a(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const n=await M(e);return J(e,"run"),n}(e,n);break;case U.Session:J(e,"session");break;case U.User:u(n)&&a(e.user,n,{shallow:!1})}return r||{ok:!0,successful:[],queued:[],failed:[]}}function Y(e,t){return A(async(n,o={})=>await S(async()=>{let r=n;if(o.mapping){const t=await _(r,o.mapping,e);if(t.ignore)return H({ok:!0});if(o.mapping.consent&&!p(o.mapping.consent,e.consent,t.event.consent))return H({ok:!0});r=t.event}const i=t(r),a=function(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:i=e.group,count:a=e.count}=t,{name:s=`${n} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:d={},user:f=e.user,nested:g=[],consent:p=e.consent,id:m=`${r}-${i}-${a}`,trigger:y="",entity:h=n,action:b=o,timing:v=0,version:w={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=t;return{name:s,data:c,context:u,globals:l,custom:d,user:f,nested:g,consent:p,id:m,trigger:y,entity:h,action:b,timestamp:r,timing:v,group:i,count:a,version:w,source:k}}(e,i);return await M(e,a)},()=>H({ok:!1}))(),"Push",e.hooks)}async function V(e){var t,n;const o=a({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),r=v({level:null==(t=e.logger)?void 0:t.level,handler:null==(n=e.logger)?void 0:n.handler}),i={...o.globalsStatic,...e.globals},s={allowed:!1,config:o,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:i,group:"",hooks:{},logger:r,on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.5.0",sources:{},push:void 0,command:void 0};return s.push=Y(s,e=>({timing:Math.round((Date.now()-s.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),s.command=(u=z,A(async(e,t,n)=>await S(async()=>await u(c,e,t,n),()=>H({ok:!1}))(),"Command",(c=s).hooks)),s.destinations=await async function(e,t={}){const n={};for(const[e,o]of Object.entries(t)){const{code:t,config:r={},env:i={}}=o,a=B(t),s={...a.config,...r},c=K(a.env,i);n[e]={...a,config:s,env:c}}return n}(0,e.destinations||{}),s;var c,u}async function Q(e){e=e||{};const t=await V(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,r,i,a)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,t,n)}let s;if("string"==typeof e)s={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(s.data=t);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};s=e,t&&"object"==typeof t&&!Array.isArray(t)&&(s.data={...s.data||{},...t})}return r&&"object"==typeof r&&(s.context=r),i&&Array.isArray(i)&&(s.nested=i),a&&"object"==typeof a&&(s.custom=a),o.push(s)}});var o;t.sources.elb=n;const r=await async function(e,t={}){const n={};for(const[o,r]of Object.entries(t)){const{code:t,config:i={},env:a={},primary:s}=r,c=(t,n={})=>e.push(t,{...n,mapping:i}),u=e.logger.scope("source").scope(o),l={push:c,command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:u,...a},d=await S(t)(i,l);if(!d)continue;const f=d.type||"unknown",g=e.logger.scope(f).scope(o);l.logger=g,s&&(d.config={...d.config,primary:s}),n[o]=d}return n}(t,e.sources||{});Object.assign(t.sources,r);const{consent:i,user:a,globals:s,custom:c}=e;i&&await t.command("consent",i),a&&await t.command("user",a),s&&Object.assign(t.globals,s),c&&Object.assign(t.custom,c),t.config.run&&await t.command("run");let u=n.push;const l=Object.values(t.sources).filter(e=>"elb"!==e.type),d=l.find(e=>e.config.primary);return d?u=d.push:l.length>0&&(u=l[0].push),{collector:t,elb:u}}var Z,ee=Object.defineProperty,te=(e,t)=>{for(var n in t)ee(e,n,{get:t[n],enumerable:!0})},ne=Object.defineProperty;((e,t)=>{for(var n in t)ne(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>oe});var oe=((Z=oe||{})[Z.ERROR=0]="ERROR",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=2]="DEBUG",Z),re={merge:!0,shallow:!0,extend:!0};function ie(e,t={},n={}){n={...re,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function ae(e){return Array.isArray(e)}function se(e){return e===document||e instanceof Element}function ce(e){return"object"==typeof e&&null!==e&&!ae(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ue(e){return"string"==typeof e}function le(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function de(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function fe(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function ge(e,t,n=!0){return e+(null!=t?(n?"-":"")+t:"")}function pe(e,t,n,o=!0){return je(C(t,ge(e,n,o))||"").reduce((e,n)=>{let[o,r]=Se(n);if(!o)return e;if(r||(o.endsWith(":")&&(o=o.slice(0,-1)),r=""),r.startsWith("#")){r=r.slice(1);try{let e=t[r];e||"selected"!==r||(e=t.options[t.selectedIndex].text),r=String(e)}catch(e){r=""}}return o.endsWith("[]")?(o=o.slice(0,-2),ae(e[o])||(e[o]=[]),e[o].push(le(r))):e[o]=le(r),e},{})}function me(e=U.Prefix,t=document){const n=ge(e,U.Globals,!1);let o={};return Ee(t,`[${n}]`,t=>{o=ie(o,pe(e,t,U.Globals,!1))}),o}function ye(e,t){const n=window.location,o="page",r=t===document?document.body:t,[i,a]=ke(r,`[${ge(e,o)}]`,e,o);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,a]}function he(e){const t={};return je(e).forEach(e=>{const[n,o]=Se(e),[r,i]=Oe(n);if(!r)return;let[a,s]=Oe(o||"");a=a||r,t[r]||(t[r]=[]),t[r].push({trigger:r,triggerParams:i,action:a,actionParams:s})}),t}function be(e,t,n,o=!1){const r=[];let i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){const a=ve(e,i,t,n);if(a&&(r.push(a),o))break;i=we(e,i)}return r}function ve(e,t,n,o){const r=C(t,ge(e));if(!r||o&&!o[r])return null;const i=[t],a=`[${ge(e,r)}],[${ge(e,"")}]`,s=ge(e,U.Link,!1);let c={};const u=[],[l,d]=ke(n||t,a,e,r);Ee(t,`[${s}]`,t=>{const[n,o]=Se(C(t,s));"parent"===o&&Ee(document.body,`[${s}="${n}:child"]`,t=>{i.push(t);const n=ve(e,t);n&&u.push(n)})});const f=[];i.forEach(e=>{e.matches(a)&&f.push(e),Ee(e,a,e=>f.push(e))});let g={};return f.forEach(t=>{g=ie(g,pe(e,t,"")),c=ie(c,pe(e,t,r))}),c=ie(ie(g,c),l),i.forEach(t=>{Ee(t,`[${ge(e)}]`,t=>{const n=ve(e,t);n&&u.push(n)})}),{entity:r,data:c,context:d,nested:u}}function we(e,t){const n=ge(e,U.Link,!1);if(t.matches(`[${n}]`)){const[e,o]=Se(C(t,n));if("child"===o)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function ke(e,t,n,o){let r={};const i={};let a=e;const s=`[${ge(n,U.Context,!1)}]`;let c=0;for(;a;)a.matches(t)&&(r=ie(pe(n,a,""),r),r=ie(pe(n,a,o),r)),a.matches(s)&&(Object.entries(pe(n,a,U.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,c])}),++c),a=we(n,a);return[r,i]}function Ee(e,t,n){e.querySelectorAll(t).forEach(n)}function je(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function Se(e){const[t,n]=e.split(/:(.+)/,2);return[fe(t),fe(n)]}function Oe(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var Le,_e=new WeakMap,xe=new WeakMap,Ae=new WeakMap;function Ce(e){const t=Date.now();let n=xe.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:P(e),lastChecked:t},xe.set(e,n)),n.isVisible}function $e(e){if(window.IntersectionObserver)return de(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,o;const r=t.target,i=Ae.get(e);if(!i)return;const a=i.timers.get(r);if(t.intersectionRatio>0){const o=Date.now();let s=_e.get(r);if((!s||o-s.lastChecked>1e3)&&(s={isLarge:r.offsetHeight>window.innerHeight,lastChecked:o},_e.set(r,s)),t.intersectionRatio>=.5||s.isLarge&&Ce(r)){const t=null==(n=i.elementConfigs)?void 0:n.get(r);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!a){const t=window.setTimeout(async()=>{var t,n;if(Ce(r)){const o=null==(t=i.elementConfigs)?void 0:t.get(r);(null==o?void 0:o.context)&&await Fe(o.context,r,o.trigger);const a=null==(n=i.elementConfigs)?void 0:n.get(r);(null==a?void 0:a.multiple)?a.blocked=!0:function(e,t){const n=Ae.get(e);if(!n)return;n.observer&&n.observer.unobserve(t);const o=n.timers.get(t);o&&(clearTimeout(o),n.timers.delete(t)),_e.delete(t),xe.delete(t)}(e,r)}},i.duration);i.timers.set(r,t)}return}}a&&(clearTimeout(a),i.timers.delete(r));const s=null==(o=i.elementConfigs)?void 0:o.get(r);(null==s?void 0:s.multiple)&&(s.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function qe(e,t,n={multiple:!1}){var o;const r=e.settings.scope||document,i=Ae.get(r);(null==i?void 0:i.observer)&&t&&(i.elementConfigs||(i.elementConfigs=new WeakMap),i.elementConfigs.set(t,{multiple:null!=(o=n.multiple)&&o,blocked:!1,context:e,trigger:n.multiple?"visible":"impression"}),i.observer.observe(t))}function Pe(e){if(!e)return;const t=Ae.get(e);t&&(t.observer&&t.observer.disconnect(),Ae.delete(e))}function Re(e,t,n,o,r,i,a){const{elb:s,settings:c}=e;if(ue(t)&&t.startsWith("walker "))return s(t,n);if(ce(t)){const e=t;return e.source||(e.source=De()),e.globals||(e.globals=me(c.prefix,c.scope||document)),s(e)}const[u]=String(ce(t)?t.name:t).split(" ");let l,d=ce(n)?n:{},f={},g=!1;if(se(n)&&(l=n,g=!0),se(r)?l=r:ce(r)&&Object.keys(r).length&&(f=r),l){const e=be(c.prefix||"data-elb",l).find(e=>e.entity===u);e&&(g&&(d=e.data),f=e.context)}"page"===u&&(d.id=d.id||window.location.pathname);const p=me(c.prefix,c.scope);return s({name:String(t||""),data:d,context:f,globals:p,nested:i,custom:a,trigger:ue(o)?o:"",source:De()})}function De(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var Ie=[],Ne="hover",Xe="load",Te="pulse",Ue="scroll",We="wait";function Be(e,t){t.scope&&function(e,t){const n=t.scope;n&&(n.addEventListener("click",de(function(t){He.call(this,e,t)})),n.addEventListener("submit",de(function(t){Ke.call(this,e,t)})))}(e,t)}function Me(e,t){t.scope&&function(e,t){const n=t.scope;Ie=[];const o=n||document;Pe(o),function(e,t=1e3){Ae.has(e)||Ae.set(e,{observer:$e(e),timers:new WeakMap,duration:t})}(o,1e3);const r=ge(t.prefix,U.Action,!1);o!==document&&Ge(e,o,r,t),o.querySelectorAll(`[${r}]`).forEach(n=>{Ge(e,n,r,t)}),Ie.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const o=window.scrollY+window.innerHeight,r=e.offsetTop;if(o<r)return!0;const i=e.clientHeight;return!(100*(1-(r+i-o)/(i||1))>=n&&(Fe(t,e,Ue),1))});Le||(Le=function(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}(function(){Ie=n.call(t,Ie,e)}),t.addEventListener("scroll",Le))}(e,o)}(e,t)}async function Fe(e,t,n){const o=function(e,t,n=U.Prefix){const o=[],{actions:r,nearestOnly:i}=function(e,t,n){let o=t;for(;o;){const t=C(o,ge(e,U.Actions,!1));if(t){const e=he(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const r=C(o,ge(e,U.Action,!1));if(r){const e=he(r);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}o=we(e,o)}return{actions:[],nearestOnly:!1}}(n,e,t);return r.length?(r.forEach(r=>{const a=je(r.actionParams||"",",").reduce((e,t)=>(e[fe(t)]=!0,e),{}),s=be(n,e,a,i);if(!s.length){const t="page",o=`[${ge(n,t)}]`,[r,i]=ke(e,o,n,t);s.push({entity:t,data:r,nested:[],context:i})}s.forEach(e=>{o.push({entity:e.entity,action:r.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),o):o}(t,n,e.settings.prefix);return Promise.all(o.map(t=>Re(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function Ge(e,t,n,o){const r=C(t,n);r&&Object.values(he(r)).forEach(n=>n.forEach(n=>{switch(n.trigger){case Ne:o=e,t.addEventListener("mouseenter",de(function(e){e.target instanceof Element&&Fe(o,e.target,Ne)}));break;case Xe:!function(e,t){Fe(e,t,Xe)}(e,t);break;case Te:!function(e,t,n=""){setInterval(()=>{document.hidden||Fe(e,t,Te)},parseInt(n||"")||15e3)}(e,t,n.triggerParams);break;case Ue:!function(e,t=""){const n=parseInt(t||"")||50;n<0||n>100||Ie.push([e,n])}(t,n.triggerParams);break;case"impression":qe(e,t);break;case"visible":qe(e,t,{multiple:!0});break;case We:!function(e,t,n=""){setTimeout(()=>Fe(e,t,We),parseInt(n||"")||15e3)}(e,t,n.triggerParams)}var o}))}function He(e,t){Fe(e,t.target,"click")}function Ke(e,t){t.target&&Fe(e,t.target,"submit")}function Je(e,t,n,o){const r=[];let i=!0;n.forEach(e=>{const t=Ye(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const a=t[0],s=!ce(a)&&ue(a)&&a.startsWith("walker ");if(ce(a)){if("object"==typeof a&&0===Object.keys(a).length)return}else{const e=Array.from(t);if(!ue(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(o&&s||!o&&!s)&&r.push(t)}),r.forEach(n=>{ze(e,t,n)})}function ze(e,t="data-elb",n){de(()=>{if(Array.isArray(n)){const[o,...r]=n;if(!o||ue(o)&&""===o.trim())return;if(ue(o)&&o.startsWith("walker "))return void e(o,r[0]);Re({elb:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},o,...r)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e(n)}},()=>{})()}function Ye(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function Ve(e,t={},n){return function(e={}){const{cb:t,consent:n,collector:o,storage:r}=e;if(!n)return R((r?X:T)(e),o,t);{const r=function(e,t){let n;return(o,r)=>{if(c(n)&&n===(null==o?void 0:o.group))return;n=null==o?void 0:o.group;let i=()=>T(e);return e.consent&&p((s(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),r)&&(i=()=>X(e)),R(i(),o,t)}}(e,t),i=(s(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{});o?o.command("on","consent",i):q("walker on","consent",i)}}({...t,collector:{push:e,group:void 0,command:n}})}te({},{env:()=>Qe});var Qe={};te(Qe,{push:()=>nt});var Ze=()=>{},et=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),tt={error:Ze,info:Ze,debug:Ze,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>tt},nt={get push(){return et()},get command(){return et()},get elb(){return et()},get window(){return{addEventListener:Ze,removeEventListener:Ze,location:{href:"https://example.com/page",pathname:"/page",search:"?query=test",hash:"#section",host:"example.com",hostname:"example.com",origin:"https://example.com",protocol:"https:"},document:{},navigator:{language:"en-US",userAgent:"Mozilla/5.0 (Test)"},screen:{width:1920,height:1080},innerWidth:1920,innerHeight:1080,pageXOffset:0,pageYOffset:0,scrollX:0,scrollY:0}},get document(){return{addEventListener:Ze,removeEventListener:Ze,querySelector:Ze,querySelectorAll:()=>[],getElementById:Ze,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:Ze,getAttribute:Ze,addEventListener:Ze,removeEventListener:Ze}),body:{appendChild:Ze,removeChild:Ze},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}},logger:tt},ot=async(e,t)=>{const{elb:n,command:o,window:r,document:i}=t,a=(null==e?void 0:e.settings)||{},s=r||(void 0!==globalThis.window?globalThis.window:void 0),c=i||(void 0!==globalThis.document?globalThis.document:void 0),u=function(e={},t){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}(a,c),l={settings:u},d={elb:n,settings:u};if(s&&c){if(!1!==u.elbLayer&&n&&function(e,t={}){const n=t.name||"elbLayer",o=t.window||window;if(!o)return;const r=o;r[n]||(r[n]=[]);const i=r[n];i.push=function(...n){if(Ye(n[0])){const o=[...Array.from(n[0])],r=Array.prototype.push.apply(this,[o]);return ze(e,t.prefix,o),r}const o=Array.prototype.push.apply(this,n);return n.forEach(n=>{ze(e,t.prefix,n)}),o},Array.isArray(i)&&i.length>0&&function(e,t="data-elb",n){Je(e,t,n,!0),Je(e,t,n,!1),n.length=0}(e,t.prefix,i)}(n,{name:ue(u.elbLayer)?u.elbLayer:"elbLayer",prefix:u.prefix,window:s}),u.session&&n){const e="boolean"==typeof u.session?{}:u.session;Ve(n,e,o)}await async function(e,t,n){const o=()=>{e(t,n)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)}(Be,d,u),(()=>{if(Me(d,u),u.pageview){const[e,t]=ye(u.prefix||"data-elb",u.scope);Re(d,"page view",e,"load",t)}})(),ue(u.elb)&&u.elb&&(s[u.elb]=(...e)=>{const[t,n,o,r,i,a]=e;return Re(d,t,n,o,r,i,a)})}return{type:"browser",config:l,push:(...e)=>{const[t,n,o,r,i,a]=e;return Re(d,t,n,o,r,i,a)},destroy:async()=>{c&&Pe(u.scope||c)},on:async(e,t)=>{switch(e){case"consent":if(u.session&&t&&n){const e="boolean"==typeof u.session?{}:u.session;Ve(n,e,o)}break;case"session":case"ready":default:break;case"run":if(c&&s&&(Me(d,u),u.pageview)){const[e,t]=ye(u.prefix||"data-elb",u.scope);Re(d,"page view",e,"load",t)}}}}},rt=Object.defineProperty,it=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})},at=!1;function st(e,t={},n){if(t.filter&&!0===j(()=>t.filter(n),()=>!1)())return;const o=function(e){if(u(e)&&l(e.event)){const{event:t,...n}=e;return{name:t,...n}}return s(e)&&e.length>=2?ct(e):null!=(t=e)&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>0?ct(Array.from(e)):null;var t}(n);if(!o)return;const r=`${t.prefix||"dataLayer"} ${o.name}`,{name:i,...a}=o,c={name:r,data:a};j(()=>e(c),()=>{})()}function ct(e){const[t,n,o]=e;if(!l(t))return null;let r,i={};switch(t){case"consent":if(!l(n)||e.length<3)return null;if("default"!==n&&"update"!==n)return null;if(!u(o)||null===o)return null;r=`${t} ${n}`,i={...o};break;case"event":if(!l(n))return null;r=n,u(o)&&(i={...o});break;case"config":if(!l(n))return null;r=`${t} ${n}`,u(o)&&(i={...o});break;case"set":if(l(n))r=`${t} ${n}`,u(o)&&(i={...o});else{if(!u(n))return null;r=`${t} custom`,i={...n}}break;default:return null}return{name:r,...i}}it({},{push:()=>ft});var ut=()=>{},lt=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),dt={error:ut,info:ut,debug:ut,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>dt},ft={get push(){return lt()},get command(){return lt()},get elb(){return lt()},get window(){return{dataLayer:[],addEventListener:ut,removeEventListener:ut}},logger:dt};function gt(){return["consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"denied",analytics_storage:"granted"}]}function pt(){return["consent","default",{ad_storage:"denied",analytics_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}]}function mt(){return["event","purchase",{transaction_id:"T_12345",value:25.42,currency:"EUR",items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",quantity:1,price:25.42}]}]}function yt(){return["event","add_to_cart",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_variant:"red",quantity:1,price:15.25}]}]}function ht(){return["event","view_item",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",price:15.25}]}]}function bt(){return["config","G-XXXXXXXXXX",{page_title:"Custom Page Title",page_location:"https://example.com/page",send_page_view:!1}]}function vt(){return["set",{currency:"EUR",country:"DE"}]}function wt(){return{event:"custom_event",custom_parameter:"custom_value",user_id:"user123"}}it({},{add_to_cart:()=>yt,config:()=>bt,consentDefault:()=>pt,consentUpdate:()=>gt,directDataLayerEvent:()=>wt,purchase:()=>mt,setCustom:()=>vt,view_item:()=>ht});it({},{add_to_cart:()=>jt,config:()=>_t,configGA4:()=>Ot,consentOnlyMapping:()=>xt,consentUpdate:()=>kt,customEvent:()=>Lt,purchase:()=>Et,view_item:()=>St});var kt={name:"walker consent",settings:{command:{map:{functional:{value:!0},analytics:{key:"analytics_storage",fn:e=>"granted"===e},marketing:{key:"ad_storage",fn:e=>"granted"===e}}}}},Et={name:"order complete",data:{map:{id:"transaction_id",total:"value",currency:"currency",nested:{loop:["items",{map:{type:{value:"product"},data:{map:{id:"item_id",name:"item_name",category:"item_category",quantity:"quantity",price:"price"}}}}]}}}},jt={name:"product add",data:{map:{id:"items.0.item_id",name:"items.0.item_name",price:"value",currency:"currency",color:"items.0.item_variant",quantity:"items.0.quantity"}}},St={name:"product view",data:{map:{id:"items.0.item_id",name:"items.0.item_name",category:"items.0.item_category",price:"items.0.price",currency:"currency"}}},Ot={name:"page view",data:{map:{title:"page_title",url:"page_location"}}},Lt={data:{map:{user_id:"user_id",custom_parameter:"custom_parameter"}}},_t={consent:{update:kt},purchase:Et,add_to_cart:jt,view_item:St,"config G-XXXXXXXXXX":Ot,custom_event:Lt,"*":{data:{}}},xt={consent:{update:kt}},At=async(e,t)=>{const{elb:n,window:o}=t,r={name:"dataLayer",prefix:"dataLayer",...null==e?void 0:e.settings},i={settings:r};return o&&(function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer",r=window[o];if(Array.isArray(r)&&!at){at=!0;try{for(const t of r)st(e,n,t)}finally{at=!1}}}(n,i),function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer";window[o]||(window[o]=[]);const r=window[o];if(!Array.isArray(r))return;const i=r.push.bind(r);r.push=function(...t){if(at)return i(...t);at=!0;try{for(const o of t)st(e,n,o)}finally{at=!1}return i(...t)}}(n,i)),{type:"dataLayer",config:i,push:n,destroy:async()=>{const e=r.name||"dataLayer";o&&o[e]&&Array.isArray(o[e])}}};function Ct(){window.dataLayer=window.dataLayer||[];const e=e=>{u(e)&&u(e.source)&&String(e.source.type).includes("dataLayer")||window.dataLayer.push(e)};return{type:"dataLayer",config:{},push:(t,n)=>{e(n.data||t)},pushBatch:t=>{e({name:"batch",batched_event:t.key,events:t.data.length?t.data:t.events})}}}((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})({},{browserConfig:()=>qt,collectorConfig:()=>Rt,dataLayerConfig:()=>Pt,settings:()=>$t});var $t={type:"object",properties:{elb:{type:"string",default:"elb",description:"Global function name for event tracking"},name:{type:"string",default:"walkerjs",description:"Global instance name"},run:{type:"boolean",default:!0,description:"Auto-initialize walker.js on load"},browser:{type:"object",default:{run:!0,session:!0,scope:"document.body",pageview:!0},description:"Browser source configuration. Set to false to disable. See browser configuration section below for details."},dataLayer:{type:"object",default:!1,description:"DataLayer source configuration. Set to true for defaults or object for custom config. See dataLayer configuration section below."},collector:{type:"object",default:{},description:"Collector configuration including destinations and consent settings. See collector configuration section below."}}},qt={type:"object",properties:{"browser.run":{type:"boolean",default:!0,description:"Auto-start DOM tracking"},"browser.session":{type:"boolean",default:!0,description:"Enable session tracking"},"browser.scope":{type:"string",default:"document.body",description:"DOM element scope for tracking"},"browser.pageview":{type:"boolean",default:!0,description:"Enable automatic page view events"}}},Pt={type:"object",properties:{dataLayer:{type:"boolean",default:!1,description:"Enable dataLayer integration with defaults"},"dataLayer.name":{type:"string",default:"dataLayer",description:"DataLayer variable name"},"dataLayer.prefix":{type:"string",default:"dataLayer",description:"Event prefix for dataLayer events"}}},Rt={type:"object",properties:{"collector.consent":{type:"object",default:{functional:!0},description:"Default consent state"},"collector.destinations":{type:"object",default:{},description:"Destination configurations. See destinations documentation for available options."}}};if(window&&document){const e=async()=>{let e;const t=document.querySelector("script[data-elbconfig]");if(t){const n=t.getAttribute("data-elbconfig")||"";n.includes(":")?e=$(n):n&&(e=window[n])}e||(e=window.elbConfig),e&&await async function(e={}){const t=a({collector:{destinations:{dataLayer:{code:Ct()}}},browser:{session:!0},dataLayer:!1,elb:"elb",run:!0},e),n={...t.collector,sources:{browser:{code:ot,config:{settings:t.browser},env:{window:"undefined"!=typeof window?window:void 0,document:"undefined"!=typeof document?document:void 0}}}};if(t.dataLayer){const e=u(t.dataLayer)?t.dataLayer:{};n.sources&&(n.sources.dataLayer={code:At,config:{settings:e}})}const o=await Q(n);return"undefined"!=typeof window&&(t.elb&&(window[t.elb]=o.elb),t.name&&(window[t.name]=o.collector)),o}(e)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}})();
|
|
1
|
+
"use strict";(()=>{var e=Object.defineProperty;((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})({},{Level:()=>n});var t,n=((t=n||{})[t.ERROR=0]="ERROR",t[t.INFO=1]="INFO",t[t.DEBUG=2]="DEBUG",t),o={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},r={merge:!0,shallow:!0,extend:!0};function i(e,t={},n={}){n={...r,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function s(e){return Array.isArray(e)}function a(e){return void 0!==e}function c(e){return"object"==typeof e&&null!==e&&!s(e)&&"[object Object]"===Object.prototype.toString.call(e)}function u(e){return"string"==typeof e}function l(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=l(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(l(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 d(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&s(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=d(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,!r)break}return a(r)?r:n}function f(e,t,n){if(!c(e))return e;const o=l(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function g(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function m(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function p(e,t=1e3,n=!1){let o,r=null,i=!1;return(...s)=>new Promise(a=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...s),a(o))},t),c&&(i=!0,o=e(...s),a(o))})}function h(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function y(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=h(e)):n=e,void 0!==t&&(t instanceof Error?o.error=h(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=h(o.error))):o.value=t),{message:n,context:o}}var b=(e,t,o,r)=>{const i=`${n[e]}${r.length>0?` [${r.join(":")}]`:""}`,s=Object.keys(o).length>0;0===e?s?console.error(i,t,o):console.error(i,t):s?console.log(i,t,o):console.log(i,t)};function v(e={}){return w({level:void 0!==e.level?(t=e.level,"string"==typeof t?n[t]:t):0,handler:e.handler,scope:[]});var t}function w(e){const{level:t,handler:n,scope:o}=e,r=(e,r,i)=>{if(e<=t){const t=y(r,i);n?n(e,t.message,t.context,o,b):b(e,t.message,t.context,o)}};return{error:(e,t)=>r(0,e,t),info:(e,t)=>r(1,e,t),debug:(e,t)=>r(2,e,t),throw:(e,t)=>{const r=y(e,t);throw n?n(0,r.message,r.context,o,b):b(0,r.message,r.context,o),new Error(r.message)},scope:e=>w({level:t,handler:n,scope:[...o,e]})}}function k(e){return function(e){return"boolean"==typeof e}(e)||u(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!a(e)||s(e)&&e.every(k)||c(e)&&Object.values(e).every(k)}function E(e){return k(e)?e:void 0}function S(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function O(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(null==n?void 0:n())}}}async function j(e,t={},n={}){var o;if(!a(e))return;const r=c(e)&&e.consent||n.consent||(null==(o=n.collector)?void 0:o.consent),i=s(t)?t:[t];for(const t of i){const o=await O(_)(e,t,{...n,consent:r});if(a(o))return o}}async function _(e,t,n={}){const{collector:o,consent:r}=n;return(s(t)?t:[t]).reduce(async(t,i)=>{const c=await t;if(c)return c;const l=u(i)?{key:i}:i;if(!Object.keys(l).length)return;const{condition:f,consent:m,fn:p,key:h,loop:y,map:b,set:v,validate:w,value:k}=l;if(f&&!await O(f)(e,i,o))return;if(m&&!g(m,r))return k;let S=a(k)?k:e;if(p&&(S=await O(p)(e,i,n)),h&&(S=d(e,h,k)),y){const[t,o]=y,r="this"===t?[e]:await j(e,t,n);s(r)&&(S=(await Promise.all(r.map(e=>j(e,o,n)))).filter(a))}else b?S=await Object.entries(b).reduce(async(t,[o,r])=>{const i=await t,s=await j(e,r,n);return a(s)&&(i[o]=s),i},Promise.resolve({})):v&&(S=await Promise.all(v.map(t=>_(e,t,n))));w&&!await O(w)(S)&&(S=void 0);const x=E(S);return a(x)?x:E(k)},Promise.resolve(void 0))}async function x(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await j(e,o,{collector:n});e=f(e,t,r)}));const{eventMapping:o,mappingKey:r}=await async function(e,t){var n;const[o,r]=(e.name||"").split(" ");if(!t||!o||!r)return{};let i,a="",c=o,u=r;const l=t=>{if(t)return(t=s(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[c]||(c="*");const d=t[c];return d&&(d[u]||(u="*"),i=l(d[u])),i||(c="*",u="*",i=l(null==(n=t[c])?void 0:n[u])),i&&(a=`${c} ${u}`),{eventMapping:i,mappingKey:a}}(e,t.mapping);(null==o?void 0:o.policy)&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await j(e,o,{collector:n});e=f(e,t,r)}));let a=t.data&&await j(e,t.data,{collector:n});if(o){if(o.ignore)return{event:e,data:a,mapping:o,mappingKey:r,ignore:!0};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await j(e,o.data,{collector:n});a=c(a)&&c(t)?i(a,t):t}}return{event:e,data:a,mapping:o,mappingKey:r,ignore:!1}}function L(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function A(e,t,n){return function(...o){let r;const i="post"+t,s=n["pre"+t],a=n[i];return r=s?s({fn:e},...o):e(...o),a&&(r=a({fn:e,result:r},...o)),r}}function C(e,t){return(e.getAttribute(t)||"").trim()}function $(e){const t={};return function(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}(e).forEach(e=>{const[n,o]=function(e){const[t,n]=e.split(/:(.+)/,2);return[L(t||""),L(n||"")]}(e);n&&("true"===o?t[n]=!0:"false"===o?t[n]=!1:o&&/^\d+$/.test(o)?t[n]=parseInt(o,10):o&&/^\d+\.\d+$/.test(o)?t[n]=parseFloat(o):t[n]=o||!0)}),t}var q=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function R(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const o=window.innerHeight,r=e.getBoundingClientRect(),i=r.height,s=r.y,a=s+i,c={x:r.x+e.offsetWidth/2,y:r.y+e.offsetHeight/2};if(i<=o){if(e.offsetWidth+r.width===0||e.offsetHeight+r.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=o/2;if(s<0&&a<e)return!1;if(a>o&&s>e)return!1;n=document.elementFromPoint(c.x,o/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function P(e,t,n){return!1===n?e:(n||(n=D),n(e,t,D))}var D=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):q("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):q({name:"session start",data:e})),e};function I(e,t=o.Storage.Session){var n;function r(e){try{return JSON.parse(e||"")}catch(t){let n=1,o="";return e&&(n=0,o=e),{e:n,v:o}}}let i,s;switch(t){case o.Storage.Cookie:i=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case o.Storage.Local:s=r(window.localStorage.getItem(e));break;case o.Storage.Session:s=r(window.sessionStorage.getItem(e))}return s&&(i=s.v,0!=s.e&&s.e<Date.now()&&(function(e,t=o.Storage.Session){switch(t){case o.Storage.Cookie:N(e,"",0,t);break;case o.Storage.Local:window.localStorage.removeItem(e);break;case o.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),i="")),function(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}(i||"")}function N(e,t,n=30,r=o.Storage.Session,i){const s={e:Date.now()+6e4*n,v:String(t)},a=JSON.stringify(s);switch(r){case o.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let o=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;i&&(o+="; domain="+i),document.cookie=o;break}case o.Storage.Local:window.localStorage.setItem(e,a);break;case o.Storage.Session:window.sessionStorage.setItem(e,a)}return I(e,r)}function X(e={}){const t=Date.now(),{length:n=30,deviceKey:o="elbDeviceId",deviceStorage:r="local",deviceAge:i=30,sessionKey:s="elbSessionId",sessionStorage:a="local",pulse:c=!1}=e,u=T(e);let l=!1;const d=S((e,t,n)=>{let o=I(e,n);return o||(o=m(8),N(e,o,1440*t,n)),String(o)})(o,i,r),f=S((e,o)=>{const r=JSON.parse(String(I(e,o)));return c||(r.isNew=!1,u.marketing&&(Object.assign(r,u),l=!0),l||r.updated+6e4*n<t?(delete r.id,delete r.referrer,r.start=t,r.count++,r.runs=1,l=!0):r.runs++),r},()=>{l=!0})(s,a)||{},g={id:m(12),start:t,isNew:!0,count:1,runs:1},p=Object.assign(g,u,f,{device:d},{isStart:l,storage:!0,updated:t},e.data);return N(s,JSON.stringify(p),2*n,a),p}function T(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const o=new URL(e.url||window.location.href),r=e.referrer||document.referrer,s=r&&new URL(r).hostname,a=function(e,t={}){const n="clickId",o={},r={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(i(r,t)).forEach(([t,r])=>{const i=e.searchParams.get(t);i&&(r===n&&(r=t,o[n]=t),o[r]=i)}),o}(o,e.parameters);if(Object.keys(a).length&&(a.marketing||(a.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(o.hostname),t=!n.includes(s)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:m(12),referrer:s},a,e.data):n}var U={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"},W={type:"code",config:{},init(e){const{config:t,logger:n}=e,o=t.settings,r=null==o?void 0:o.scripts;if(r&&"undefined"!=typeof document)for(const e of r){const t=document.createElement("script");t.src=e,t.async=!0,document.head.appendChild(t)}const i=null==o?void 0:o.init;if(i)try{new Function("context",i)(e)}catch(e){n.error("Code destination init error:",e)}},push(e,t){var n,o;const{mapping:r,config:i,logger:s}=t,a=null!=(o=null==r?void 0:r.push)?o:null==(n=i.settings)?void 0:n.push;if(a)try{new Function("event","context",a)(e,t)}catch(e){s.error("Code destination push error:",e)}},pushBatch(e,t){var n,o;const{mapping:r,config:i,logger:s}=t,a=null!=(o=null==r?void 0:r.pushBatch)?o:null==(n=i.settings)?void 0:n.pushBatch;if(a)try{new Function("batch","context",a)(e,t)}catch(e){s.error("Code destination pushBatch error:",e)}},on(e,t){var n;const{config:o,logger:r}=t,i=null==(n=o.settings)?void 0:n.on;if(i)try{new Function("type","context",i)(e,t)}catch(e){r.error("Code destination on error:",e)}}};function B(e){return!0===e?W:e}async function M(e,t,n){const{allowed:o,consent:r,globals:s,user:a}=e;if(!o)return H({ok:!1});t&&e.queue.push(t),n||(n=e.destinations);const c=await Promise.all(Object.entries(n||{}).map(async([n,o])=>{let c=(o.queue||[]).map(e=>({...e,consent:r}));if(o.queue=[],t){const e=l(t);c.push(e)}if(!c.length)return{id:n,destination:o,skipped:!0};const u=[],d=c.filter(e=>{const t=g(o.config.consent,r,e.consent);return!t||(e.consent=t,u.push(e),!1)});if(o.queue.concat(d),!u.length)return{id:n,destination:o,queue:c};if(!await O(F)(e,o))return{id:n,destination:o,queue:c};let f=!1;return o.dlq||(o.dlq=[]),await Promise.all(u.map(async t=>(t.globals=i(s,t.globals),t.user=i(a,t.user),await O(G,n=>{const r=o.type||"unknown";return e.logger.scope(r).error("Push failed",{error:n,event:t.name}),f=!0,o.dlq.push([t,n]),!1})(e,o,t),t))),{id:n,destination:o,error:f}})),u=[],d=[],f=[];for(const e of c){if(e.skipped)continue;const t=e.destination,n={id:e.id,destination:t};e.error?f.push(n):e.queue&&e.queue.length?(t.queue=(t.queue||[]).concat(e.queue),d.push(n)):u.push(n)}return H({ok:!f.length,event:t,successful:u,queued:d,failed:f})}async function F(e,t){if(t.init&&!t.config.init){const n=t.type||"unknown",o=e.logger.scope(n),r={collector:e,config:t.config,env:K(t.env,t.config.env),logger:o};o.debug("init");const i=await A(t.init,"DestinationInit",e.hooks)(r);if(!1===i)return i;t.config={...i||t.config,init:!0},o.debug("init done")}return!0}async function G(e,t,n){const{config:o}=t,r=await x(n,o,e);if(r.ignore)return!1;const i=t.type||"unknown",s=e.logger.scope(i),c={collector:e,config:o,data:r.data,mapping:r.mapping,env:K(t.env,o.env),logger:s},u=r.mapping,l=r.mappingKey||"* *";if((null==u?void 0:u.batch)&&t.pushBatch){if(t.batches=t.batches||{},!t.batches[l]){const n={key:l,events:[],data:[]};t.batches[l]={batched:n,batchFn:p(()=>{const n=t.batches[l].batched,r={collector:e,config:o,data:void 0,mapping:u,env:K(t.env,o.env),logger:s};s.debug("push batch",{events:n.events.length}),A(t.pushBatch,"DestinationPushBatch",e.hooks)(n,r),s.debug("push batch done"),n.events=[],n.data=[]},u.batch)}}const n=t.batches[l];n.batched.events.push(r.event),a(r.data)&&n.batched.data.push(r.data),n.batchFn()}else s.debug("push",{event:r.event.name}),await A(t.push,"DestinationPush",e.hooks)(r.event,c),s.debug("push done");return!0}function H(e){var t;return i({ok:!(null==(t=null==e?void 0:e.failed)?void 0:t.length),successful:[],queued:[],failed:[]},e)}function K(e,t){return e||t?t?e&&c(e)&&c(t)?{...e,...t}:t:e:{}}function J(e,t,n,o){let r,i=n||[];switch(n||(i=e.on[t]||[]),t){case U.Consent:r=o||e.consent;break;case U.Session:r=e.session;break;case U.Ready:case U.Run:default:r=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&S(e.on)(t,r)}),Object.values(e.destinations).forEach(n=>{if(n.on){const o=n.type||"unknown",i=e.logger.scope(o).scope("on").scope(t),s={collector:e,config:n.config,data:r,env:K(n.env,n.config.env),logger:i};S(n.on)(t,s)}}),i.length)switch(t){case U.Consent:!function(e,t,n){const o=n||e.consent;t.forEach(t=>{Object.keys(o).filter(e=>e in t).forEach(n=>{S(t[n])(e,o)})})}(e,i,o);break;case U.Ready:case U.Run:a=i,(s=e).allowed&&a.forEach(e=>{S(e)(s)});break;case U.Session:!function(e,t){e.session&&t.forEach(t=>{S(t)(e,e.session)})}(e,i)}var s,a}async function z(e,t,n,o){let r;switch(t){case U.Config:c(n)&&i(e.config,n,{shallow:!1});break;case U.Consent:c(n)&&(r=await async function(e,t){const{consent:n}=e;let o=!1;const r={};return Object.entries(t).forEach(([e,t])=>{const n=!!t;r[e]=n,o=o||n}),e.consent=i(n,r),J(e,"consent",void 0,r),o?M(e):H({ok:!0})}(e,n));break;case U.Custom:c(n)&&(e.custom=i(e.custom,n));break;case U.Destination:c(n)&&function(e){return"function"==typeof e}(n.push)&&(r=await async function(e,t,n){const{code:o,config:r={},env:i={}}=t,s=n||r||{init:!1},a=B(o),c={...a,config:s,env:K(a.env,i)};let u=c.config.id;if(!u)do{u=m(4)}while(e.destinations[u]);return e.destinations[u]=c,!1!==c.config.queue&&(c.queue=[...e.queue]),M(e,void 0,{[u]:c})}(e,{code:n},o));break;case U.Globals:c(n)&&(e.globals=i(e.globals,n));break;case U.On:u(n)&&function(e,t,n){const o=e.on,r=o[t]||[],i=s(n)?n:[n];i.forEach(e=>{r.push(e)}),o[t]=r,J(e,t,i)}(e,n,o);break;case U.Ready:J(e,"ready");break;case U.Run:r=await async function(e,t){e.allowed=!0,e.count=0,e.group=m(),e.timing=Date.now(),t&&(t.consent&&(e.consent=i(e.consent,t.consent)),t.user&&(e.user=i(e.user,t.user)),t.globals&&(e.globals=i(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=i(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const n=await M(e);return J(e,"run"),n}(e,n);break;case U.Session:J(e,"session");break;case U.User:c(n)&&i(e.user,n,{shallow:!1})}return r||{ok:!0,successful:[],queued:[],failed:[]}}function Y(e,t){return A(async(n,o={})=>await O(async()=>{let r=n;if(o.mapping){const t=await x(r,o.mapping,e);if(t.ignore)return H({ok:!0});if(o.mapping.consent&&!g(o.mapping.consent,e.consent,t.event.consent))return H({ok:!0});r=t.event}const i=t(r),s=function(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:r=Date.now(),group:i=e.group,count:s=e.count}=t,{name:a=`${n} ${o}`,data:c={},context:u={},globals:l=e.globals,custom:d={},user:f=e.user,nested:g=[],consent:m=e.consent,id:p=`${r}-${i}-${s}`,trigger:h="",entity:y=n,action:b=o,timing:v=0,version:w={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=t;return{name:a,data:c,context:u,globals:l,custom:d,user:f,nested:g,consent:m,id:p,trigger:h,entity:y,action:b,timestamp:r,timing:v,group:i,count:s,version:w,source:k}}(e,i);return await M(e,s)},()=>H({ok:!1}))(),"Push",e.hooks)}async function V(e){var t,n;const o=i({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),r=v({level:null==(t=e.logger)?void 0:t.level,handler:null==(n=e.logger)?void 0:n.handler}),s={...o.globalsStatic,...e.globals},a={allowed:!1,config:o,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:s,group:"",hooks:{},logger:r,on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.6.0",sources:{},push:void 0,command:void 0};return a.push=Y(a,e=>({timing:Math.round((Date.now()-a.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),a.command=(u=z,A(async(e,t,n)=>await O(async()=>await u(c,e,t,n),()=>H({ok:!1}))(),"Command",(c=a).hooks)),a.destinations=await async function(e,t={}){const n={};for(const[e,o]of Object.entries(t)){const{code:t,config:r={},env:i={}}=o,s=B(t),a={...s.config,...r},c=K(s.env,i);n[e]={...s,config:a,env:c}}return n}(0,e.destinations||{}),a;var c,u}async function Q(e){e=e||{};const t=await V(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,r,i,s)=>{if("string"==typeof e&&e.startsWith("walker ")){const r=e.replace("walker ","");return o.command(r,t,n)}let a;if("string"==typeof e)a={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(a.data=t);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};a=e,t&&"object"==typeof t&&!Array.isArray(t)&&(a.data={...a.data||{},...t})}return r&&"object"==typeof r&&(a.context=r),i&&Array.isArray(i)&&(a.nested=i),s&&"object"==typeof s&&(a.custom=s),o.push(a)}});var o;t.sources.elb=n;const r=await async function(e,t={}){const n={};for(const[o,r]of Object.entries(t)){const{code:t,config:i={},env:s={},primary:a}=r,c=(t,n={})=>e.push(t,{...n,mapping:i}),u=e.logger.scope("source").scope(o),l={push:c,command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:u,...s},d=await O(t)(i,l);if(!d)continue;const f=d.type||"unknown",g=e.logger.scope(f).scope(o);l.logger=g,a&&(d.config={...d.config,primary:a}),n[o]=d}return n}(t,e.sources||{});Object.assign(t.sources,r);const{consent:i,user:s,globals:a,custom:c}=e;i&&await t.command("consent",i),s&&await t.command("user",s),a&&Object.assign(t.globals,a),c&&Object.assign(t.custom,c),t.config.run&&await t.command("run");let u=n.push;const l=Object.values(t.sources).filter(e=>"elb"!==e.type),d=l.find(e=>e.config.primary);return d?u=d.push:l.length>0&&(u=l[0].push),{collector:t,elb:u}}var Z,ee=Object.defineProperty,te=(e,t)=>{for(var n in t)ee(e,n,{get:t[n],enumerable:!0})},ne=Object.defineProperty;((e,t)=>{for(var n in t)ne(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>oe});var oe=((Z=oe||{})[Z.ERROR=0]="ERROR",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=2]="DEBUG",Z),re={merge:!0,shallow:!0,extend:!0};function ie(e,t={},n={}){n={...re,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function se(e){return Array.isArray(e)}function ae(e){return e===document||e instanceof Element}function ce(e){return"object"==typeof e&&null!==e&&!se(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ue(e){return"string"==typeof e}function le(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function de(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function fe(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function ge(e,t,n=!0){return e+(null!=t?(n?"-":"")+t:"")}function me(e,t,n,o=!0){return Se(C(t,ge(e,n,o))||"").reduce((e,n)=>{let[o,r]=Oe(n);if(!o)return e;if(r||(o.endsWith(":")&&(o=o.slice(0,-1)),r=""),r.startsWith("#")){r=r.slice(1);try{let e=t[r];e||"selected"!==r||(e=t.options[t.selectedIndex].text),r=String(e)}catch(e){r=""}}return o.endsWith("[]")?(o=o.slice(0,-2),se(e[o])||(e[o]=[]),e[o].push(le(r))):e[o]=le(r),e},{})}function pe(e=U.Prefix,t=document){const n=ge(e,U.Globals,!1);let o={};return Ee(t,`[${n}]`,t=>{o=ie(o,me(e,t,U.Globals,!1))}),o}function he(e,t){const n=window.location,o="page",r=t===document?document.body:t,[i,s]=ke(r,`[${ge(e,o)}]`,e,o);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,s]}function ye(e){const t={};return Se(e).forEach(e=>{const[n,o]=Oe(e),[r,i]=je(n);if(!r)return;let[s,a]=je(o||"");s=s||r,t[r]||(t[r]=[]),t[r].push({trigger:r,triggerParams:i,action:s,actionParams:a})}),t}function be(e,t,n,o=!1){const r=[];let i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){const s=ve(e,i,t,n);if(s&&(r.push(s),o))break;i=we(e,i)}return r}function ve(e,t,n,o){const r=C(t,ge(e));if(!r||o&&!o[r])return null;const i=[t],s=`[${ge(e,r)}],[${ge(e,"")}]`,a=ge(e,U.Link,!1);let c={};const u=[],[l,d]=ke(n||t,s,e,r);Ee(t,`[${a}]`,t=>{const[n,o]=Oe(C(t,a));"parent"===o&&Ee(document.body,`[${a}="${n}:child"]`,t=>{i.push(t);const n=ve(e,t);n&&u.push(n)})});const f=[];i.forEach(e=>{e.matches(s)&&f.push(e),Ee(e,s,e=>f.push(e))});let g={};return f.forEach(t=>{g=ie(g,me(e,t,"")),c=ie(c,me(e,t,r))}),c=ie(ie(g,c),l),i.forEach(t=>{Ee(t,`[${ge(e)}]`,t=>{const n=ve(e,t);n&&u.push(n)})}),{entity:r,data:c,context:d,nested:u}}function we(e,t){const n=ge(e,U.Link,!1);if(t.matches(`[${n}]`)){const[e,o]=Oe(C(t,n));if("child"===o)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function ke(e,t,n,o){let r={};const i={};let s=e;const a=`[${ge(n,U.Context,!1)}]`;let c=0;for(;s;)s.matches(t)&&(r=ie(me(n,s,""),r),r=ie(me(n,s,o),r)),s.matches(a)&&(Object.entries(me(n,s,U.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,c])}),++c),s=we(n,s);return[r,i]}function Ee(e,t,n){e.querySelectorAll(t).forEach(n)}function Se(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function Oe(e){const[t,n]=e.split(/:(.+)/,2);return[fe(t),fe(n)]}function je(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var _e,xe=new WeakMap,Le=new WeakMap,Ae=new WeakMap;function Ce(e){const t=Date.now();let n=Le.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:R(e),lastChecked:t},Le.set(e,n)),n.isVisible}function $e(e){if(window.IntersectionObserver)return de(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,o;const r=t.target,i=Ae.get(e);if(!i)return;const s=i.timers.get(r);if(t.intersectionRatio>0){const o=Date.now();let a=xe.get(r);if((!a||o-a.lastChecked>1e3)&&(a={isLarge:r.offsetHeight>window.innerHeight,lastChecked:o},xe.set(r,a)),t.intersectionRatio>=.5||a.isLarge&&Ce(r)){const t=null==(n=i.elementConfigs)?void 0:n.get(r);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!s){const t=window.setTimeout(async()=>{var t,n;if(Ce(r)){const o=null==(t=i.elementConfigs)?void 0:t.get(r);(null==o?void 0:o.context)&&await Fe(o.context,r,o.trigger);const s=null==(n=i.elementConfigs)?void 0:n.get(r);(null==s?void 0:s.multiple)?s.blocked=!0:function(e,t){const n=Ae.get(e);if(!n)return;n.observer&&n.observer.unobserve(t);const o=n.timers.get(t);o&&(clearTimeout(o),n.timers.delete(t)),xe.delete(t),Le.delete(t)}(e,r)}},i.duration);i.timers.set(r,t)}return}}s&&(clearTimeout(s),i.timers.delete(r));const a=null==(o=i.elementConfigs)?void 0:o.get(r);(null==a?void 0:a.multiple)&&(a.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function qe(e,t,n={multiple:!1}){var o;const r=e.settings.scope||document,i=Ae.get(r);(null==i?void 0:i.observer)&&t&&(i.elementConfigs||(i.elementConfigs=new WeakMap),i.elementConfigs.set(t,{multiple:null!=(o=n.multiple)&&o,blocked:!1,context:e,trigger:n.multiple?"visible":"impression"}),i.observer.observe(t))}function Re(e){if(!e)return;const t=Ae.get(e);t&&(t.observer&&t.observer.disconnect(),Ae.delete(e))}function Pe(e,t,n,o,r,i,s){const{elb:a,settings:c}=e;if(ue(t)&&t.startsWith("walker "))return a(t,n);if(ce(t)){const e=t;return e.source||(e.source=De()),e.globals||(e.globals=pe(c.prefix,c.scope||document)),a(e)}const[u]=String(ce(t)?t.name:t).split(" ");let l,d=ce(n)?n:{},f={},g=!1;if(ae(n)&&(l=n,g=!0),ae(r)?l=r:ce(r)&&Object.keys(r).length&&(f=r),l){const e=be(c.prefix||"data-elb",l).find(e=>e.entity===u);e&&(g&&(d=e.data),f=e.context)}"page"===u&&(d.id=d.id||window.location.pathname);const m=pe(c.prefix,c.scope);return a({name:String(t||""),data:d,context:f,globals:m,nested:i,custom:s,trigger:ue(o)?o:"",source:De()})}function De(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var Ie=[],Ne="hover",Xe="load",Te="pulse",Ue="scroll",We="wait";function Be(e,t){t.scope&&function(e,t){const n=t.scope;n&&(n.addEventListener("click",de(function(t){He.call(this,e,t)})),n.addEventListener("submit",de(function(t){Ke.call(this,e,t)})))}(e,t)}function Me(e,t){t.scope&&function(e,t){const n=t.scope;Ie=[];const o=n||document;Re(o),function(e,t=1e3){Ae.has(e)||Ae.set(e,{observer:$e(e),timers:new WeakMap,duration:t})}(o,1e3);const r=ge(t.prefix,U.Action,!1);o!==document&&Ge(e,o,r,t),o.querySelectorAll(`[${r}]`).forEach(n=>{Ge(e,n,r,t)}),Ie.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const o=window.scrollY+window.innerHeight,r=e.offsetTop;if(o<r)return!0;const i=e.clientHeight;return!(100*(1-(r+i-o)/(i||1))>=n&&(Fe(t,e,Ue),1))});_e||(_e=function(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}(function(){Ie=n.call(t,Ie,e)}),t.addEventListener("scroll",_e))}(e,o)}(e,t)}async function Fe(e,t,n){const o=function(e,t,n=U.Prefix){const o=[],{actions:r,nearestOnly:i}=function(e,t,n){let o=t;for(;o;){const t=C(o,ge(e,U.Actions,!1));if(t){const e=ye(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const r=C(o,ge(e,U.Action,!1));if(r){const e=ye(r);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}o=we(e,o)}return{actions:[],nearestOnly:!1}}(n,e,t);return r.length?(r.forEach(r=>{const s=Se(r.actionParams||"",",").reduce((e,t)=>(e[fe(t)]=!0,e),{}),a=be(n,e,s,i);if(!a.length){const t="page",o=`[${ge(n,t)}]`,[r,i]=ke(e,o,n,t);a.push({entity:t,data:r,nested:[],context:i})}a.forEach(e=>{o.push({entity:e.entity,action:r.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),o):o}(t,n,e.settings.prefix);return Promise.all(o.map(t=>Pe(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function Ge(e,t,n,o){const r=C(t,n);r&&Object.values(ye(r)).forEach(n=>n.forEach(n=>{switch(n.trigger){case Ne:o=e,t.addEventListener("mouseenter",de(function(e){e.target instanceof Element&&Fe(o,e.target,Ne)}));break;case Xe:!function(e,t){Fe(e,t,Xe)}(e,t);break;case Te:!function(e,t,n=""){setInterval(()=>{document.hidden||Fe(e,t,Te)},parseInt(n||"")||15e3)}(e,t,n.triggerParams);break;case Ue:!function(e,t=""){const n=parseInt(t||"")||50;n<0||n>100||Ie.push([e,n])}(t,n.triggerParams);break;case"impression":qe(e,t);break;case"visible":qe(e,t,{multiple:!0});break;case We:!function(e,t,n=""){setTimeout(()=>Fe(e,t,We),parseInt(n||"")||15e3)}(e,t,n.triggerParams)}var o}))}function He(e,t){Fe(e,t.target,"click")}function Ke(e,t){t.target&&Fe(e,t.target,"submit")}function Je(e,t,n,o){const r=[];let i=!0;n.forEach(e=>{const t=Ye(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const s=t[0],a=!ce(s)&&ue(s)&&s.startsWith("walker ");if(ce(s)){if("object"==typeof s&&0===Object.keys(s).length)return}else{const e=Array.from(t);if(!ue(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(o&&a||!o&&!a)&&r.push(t)}),r.forEach(n=>{ze(e,t,n)})}function ze(e,t="data-elb",n){de(()=>{if(Array.isArray(n)){const[o,...r]=n;if(!o||ue(o)&&""===o.trim())return;if(ue(o)&&o.startsWith("walker "))return void e(o,r[0]);Pe({elb:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},o,...r)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e(n)}},()=>{})()}function Ye(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function Ve(e,t={},n){return function(e={}){const{cb:t,consent:n,collector:o,storage:r}=e;if(!n)return P((r?X:T)(e),o,t);{const r=function(e,t){let n;return(o,r)=>{if(a(n)&&n===(null==o?void 0:o.group))return;n=null==o?void 0:o.group;let i=()=>T(e);return e.consent&&g((s(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),r)&&(i=()=>X(e)),P(i(),o,t)}}(e,t),i=(s(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{});o?o.command("on","consent",i):q("walker on","consent",i)}}({...t,collector:{push:e,group:void 0,command:n}})}te({},{env:()=>Qe});var Qe={};te(Qe,{push:()=>nt});var Ze=()=>{},et=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),tt={error:Ze,info:Ze,debug:Ze,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>tt},nt={get push(){return et()},get command(){return et()},get elb(){return et()},get window(){return{addEventListener:Ze,removeEventListener:Ze,location:{href:"https://example.com/page",pathname:"/page",search:"?query=test",hash:"#section",host:"example.com",hostname:"example.com",origin:"https://example.com",protocol:"https:"},document:{},navigator:{language:"en-US",userAgent:"Mozilla/5.0 (Test)"},screen:{width:1920,height:1080},innerWidth:1920,innerHeight:1080,pageXOffset:0,pageYOffset:0,scrollX:0,scrollY:0}},get document(){return{addEventListener:Ze,removeEventListener:Ze,querySelector:Ze,querySelectorAll:()=>[],getElementById:Ze,getElementsByClassName:()=>[],getElementsByTagName:()=>[],createElement:()=>({setAttribute:Ze,getAttribute:Ze,addEventListener:Ze,removeEventListener:Ze}),body:{appendChild:Ze,removeChild:Ze},documentElement:{scrollTop:0,scrollLeft:0},readyState:"complete",title:"Test Page",referrer:"",cookie:""}},logger:tt},ot=async(e,t)=>{const{elb:n,command:o,window:r,document:i}=t,s=(null==e?void 0:e.settings)||{},a=r||(void 0!==globalThis.window?globalThis.window:void 0),c=i||(void 0!==globalThis.document?globalThis.document:void 0),u=function(e={},t){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}(s,c),l={settings:u},d={elb:n,settings:u};if(a&&c){if(!1!==u.elbLayer&&n&&function(e,t={}){const n=t.name||"elbLayer",o=t.window||window;if(!o)return;const r=o;r[n]||(r[n]=[]);const i=r[n];i.push=function(...n){if(Ye(n[0])){const o=[...Array.from(n[0])],r=Array.prototype.push.apply(this,[o]);return ze(e,t.prefix,o),r}const o=Array.prototype.push.apply(this,n);return n.forEach(n=>{ze(e,t.prefix,n)}),o},Array.isArray(i)&&i.length>0&&function(e,t="data-elb",n){Je(e,t,n,!0),Je(e,t,n,!1),n.length=0}(e,t.prefix,i)}(n,{name:ue(u.elbLayer)?u.elbLayer:"elbLayer",prefix:u.prefix,window:a}),u.session&&n){const e="boolean"==typeof u.session?{}:u.session;Ve(n,e,o)}await async function(e,t,n){const o=()=>{e(t,n)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)}(Be,d,u),(()=>{if(Me(d,u),u.pageview){const[e,t]=he(u.prefix||"data-elb",u.scope);Pe(d,"page view",e,"load",t)}})(),ue(u.elb)&&u.elb&&(a[u.elb]=(...e)=>{const[t,n,o,r,i,s]=e;return Pe(d,t,n,o,r,i,s)})}return{type:"browser",config:l,push:(...e)=>{const[t,n,o,r,i,s]=e;return Pe(d,t,n,o,r,i,s)},destroy:async()=>{c&&Re(u.scope||c)},on:async(e,t)=>{switch(e){case"consent":if(u.session&&t&&n){const e="boolean"==typeof u.session?{}:u.session;Ve(n,e,o)}break;case"session":case"ready":default:break;case"run":if(c&&a&&(Me(d,u),u.pageview)){const[e,t]=he(u.prefix||"data-elb",u.scope);Pe(d,"page view",e,"load",t)}}}}},rt=Object.defineProperty,it=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})},st=!1;function at(e,t={},n){if(t.filter&&!0===S(()=>t.filter(n),()=>!1)())return;const o=function(e){if(c(e)&&u(e.event)){const{event:t,...n}=e;return{name:t,...n}}return s(e)&&e.length>=2?ct(e):null!=(t=e)&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&t.length>0?ct(Array.from(e)):null;var t}(n);if(!o)return;const r=`${t.prefix||"dataLayer"} ${o.name}`,{name:i,...a}=o,l={name:r,data:a};S(()=>e(l),()=>{})()}function ct(e){const[t,n,o]=e;if(!u(t))return null;let r,i={};switch(t){case"consent":if(!u(n)||e.length<3)return null;if("default"!==n&&"update"!==n)return null;if(!c(o)||null===o)return null;r=`${t} ${n}`,i={...o};break;case"event":if(!u(n))return null;r=n,c(o)&&(i={...o});break;case"config":if(!u(n))return null;r=`${t} ${n}`,c(o)&&(i={...o});break;case"set":if(u(n))r=`${t} ${n}`,c(o)&&(i={...o});else{if(!c(n))return null;r=`${t} custom`,i={...n}}break;default:return null}return{name:r,...i}}it({},{push:()=>ft});var ut=()=>{},lt=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),dt={error:ut,info:ut,debug:ut,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>dt},ft={get push(){return lt()},get command(){return lt()},get elb(){return lt()},get window(){return{dataLayer:[],addEventListener:ut,removeEventListener:ut}},logger:dt};function gt(){return["consent","update",{ad_user_data:"granted",ad_personalization:"granted",ad_storage:"denied",analytics_storage:"granted"}]}function mt(){return["consent","default",{ad_storage:"denied",analytics_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}]}function pt(){return["event","purchase",{transaction_id:"T_12345",value:25.42,currency:"EUR",items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",quantity:1,price:25.42}]}]}function ht(){return["event","add_to_cart",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_variant:"red",quantity:1,price:15.25}]}]}function yt(){return["event","view_item",{currency:"EUR",value:15.25,items:[{item_id:"SKU_12345",item_name:"Product Name",item_category:"Category",price:15.25}]}]}function bt(){return["config","G-XXXXXXXXXX",{page_title:"Custom Page Title",page_location:"https://example.com/page",send_page_view:!1}]}function vt(){return["set",{currency:"EUR",country:"DE"}]}function wt(){return{event:"custom_event",custom_parameter:"custom_value",user_id:"user123"}}it({},{add_to_cart:()=>ht,config:()=>bt,consentDefault:()=>mt,consentUpdate:()=>gt,directDataLayerEvent:()=>wt,purchase:()=>pt,setCustom:()=>vt,view_item:()=>yt});it({},{add_to_cart:()=>St,config:()=>xt,configGA4:()=>jt,consentOnlyMapping:()=>Lt,consentUpdate:()=>kt,customEvent:()=>_t,purchase:()=>Et,view_item:()=>Ot});var kt={name:"walker consent",settings:{command:{map:{functional:{value:!0},analytics:{key:"analytics_storage",fn:e=>"granted"===e},marketing:{key:"ad_storage",fn:e=>"granted"===e}}}}},Et={name:"order complete",data:{map:{id:"transaction_id",total:"value",currency:"currency",nested:{loop:["items",{map:{type:{value:"product"},data:{map:{id:"item_id",name:"item_name",category:"item_category",quantity:"quantity",price:"price"}}}}]}}}},St={name:"product add",data:{map:{id:"items.0.item_id",name:"items.0.item_name",price:"value",currency:"currency",color:"items.0.item_variant",quantity:"items.0.quantity"}}},Ot={name:"product view",data:{map:{id:"items.0.item_id",name:"items.0.item_name",category:"items.0.item_category",price:"items.0.price",currency:"currency"}}},jt={name:"page view",data:{map:{title:"page_title",url:"page_location"}}},_t={data:{map:{user_id:"user_id",custom_parameter:"custom_parameter"}}},xt={consent:{update:kt},purchase:Et,add_to_cart:St,view_item:Ot,"config G-XXXXXXXXXX":jt,custom_event:_t,"*":{data:{}}},Lt={consent:{update:kt}},At=async(e,t)=>{const{elb:n,window:o}=t,r={name:"dataLayer",prefix:"dataLayer",...null==e?void 0:e.settings},i={settings:r};return o&&(function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer",r=window[o];if(Array.isArray(r)&&!st){st=!0;try{for(const t of r)at(e,n,t)}finally{st=!1}}}(n,i),function(e,t){const n=t.settings,o=(null==n?void 0:n.name)||"dataLayer";window[o]||(window[o]=[]);const r=window[o];if(!Array.isArray(r))return;const i=r.push.bind(r);r.push=function(...t){if(st)return i(...t);st=!0;try{for(const o of t)at(e,n,o)}finally{st=!1}return i(...t)}}(n,i)),{type:"dataLayer",config:i,push:n,destroy:async()=>{const e=r.name||"dataLayer";o&&o[e]&&Array.isArray(o[e])}}};function Ct(){window.dataLayer=window.dataLayer||[];const e=e=>{c(e)&&c(e.source)&&String(e.source.type).includes("dataLayer")||window.dataLayer.push(e)};return{type:"dataLayer",config:{},push:(t,n)=>{e(n.data||t)},pushBatch:t=>{e({name:"batch",batched_event:t.key,events:t.data.length?t.data:t.events})}}}if(window&&document){const e=async()=>{let e;const t=document.querySelector("script[data-elbconfig]");if(t){const n=t.getAttribute("data-elbconfig")||"";n.includes(":")?e=$(n):n&&(e=window[n])}e||(e=window.elbConfig),e&&await async function(e={}){const t=i({collector:{destinations:{dataLayer:{code:Ct()}}},browser:{session:!0},dataLayer:!1,elb:"elb",run:!0},e),n={...t.collector,sources:{browser:{code:ot,config:{settings:t.browser},env:{window:"undefined"!=typeof window?window:void 0,document:"undefined"!=typeof document?document:void 0}}}};if(t.dataLayer){const e=c(t.dataLayer)?t.dataLayer:{};n.sources&&(n.sources.dataLayer={code:At,config:{settings:e}})}const o=await Q(n);return"undefined"!=typeof window&&(t.elb&&(window[t.elb]=o.elb),t.name&&(window[t.name]=o.collector)),o}(e)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/walker.js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Ready-to-use walkerOS bundle with browser source, collector, and dataLayer support",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"preview": "npm run build && npx serve -l 3333 examples"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@walkeros/core": "0.
|
|
42
|
-
"@walkeros/collector": "0.
|
|
43
|
-
"@walkeros/web-core": "0.
|
|
44
|
-
"@walkeros/web-source-browser": "0.
|
|
45
|
-
"@walkeros/web-source-datalayer": "0.
|
|
41
|
+
"@walkeros/core": "0.6.0",
|
|
42
|
+
"@walkeros/collector": "0.6.0",
|
|
43
|
+
"@walkeros/web-core": "0.6.0",
|
|
44
|
+
"@walkeros/web-source-browser": "0.6.0",
|
|
45
|
+
"@walkeros/web-source-datalayer": "0.6.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@swc/jest": "^0.2.
|
|
49
|
-
"@types/jest": "^
|
|
50
|
-
"jest": "^
|
|
51
|
-
"jest-environment-jsdom": "^
|
|
48
|
+
"@swc/jest": "^0.2.39",
|
|
49
|
+
"@types/jest": "^30.0.0",
|
|
50
|
+
"jest": "^30.2.0",
|
|
51
|
+
"jest-environment-jsdom": "^30.2.0"
|
|
52
52
|
},
|
|
53
53
|
"repository": {
|
|
54
54
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|
package/src/dev.ts
CHANGED
|
@@ -1,8 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
schemas as coreSchemas,
|
|
3
|
+
z,
|
|
4
|
+
zodToSchema,
|
|
5
|
+
type JSONSchema,
|
|
6
|
+
} from '@walkeros/core/dev';
|
|
7
|
+
import { schemas as browserSchemas } from '@walkeros/web-source-browser/dev';
|
|
8
|
+
import { schemas as dataLayerSchemas } from '@walkeros/web-source-datalayer/dev';
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Walker.js Config schema
|
|
12
|
+
*
|
|
13
|
+
* Matches the Config interface in types/index.ts
|
|
14
|
+
*/
|
|
15
|
+
const ConfigSchema = z.object({
|
|
16
|
+
collector: z
|
|
17
|
+
.any()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Collector configuration (Collector.InitConfig)'),
|
|
20
|
+
browser: z
|
|
21
|
+
.any()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Browser source configuration (Partial<SourceBrowser.Settings>)'),
|
|
24
|
+
dataLayer: z
|
|
25
|
+
.union([z.boolean(), z.any()])
|
|
26
|
+
.optional()
|
|
27
|
+
.describe(
|
|
28
|
+
'DataLayer configuration (boolean | Partial<SourceDataLayer.Settings>)',
|
|
29
|
+
),
|
|
30
|
+
elb: z
|
|
31
|
+
.string()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('Name for the global elb function (default: "elb")'),
|
|
34
|
+
name: z.string().optional().describe('Name for the global instance'),
|
|
35
|
+
run: z
|
|
36
|
+
.boolean()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Auto-run on initialization (default: true)'),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Named exports for MDX PropertyTable usage
|
|
42
|
+
export const settings: JSONSchema = zodToSchema(ConfigSchema);
|
|
43
|
+
export const browserConfig: JSONSchema = browserSchemas.settings;
|
|
44
|
+
export const dataLayerConfig: JSONSchema = dataLayerSchemas.settings;
|
|
45
|
+
export const collectorConfig: JSONSchema =
|
|
46
|
+
coreSchemas.CollectorSchemas.initConfigJsonSchema;
|
package/dist/schemas.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { RJSFSchema } from '@rjsf/utils';
|
|
2
|
-
export declare const settings: RJSFSchema;
|
|
3
|
-
export declare const browserConfig: RJSFSchema;
|
|
4
|
-
export declare const dataLayerConfig: RJSFSchema;
|
|
5
|
-
export declare const collectorConfig: RJSFSchema;
|
|
6
|
-
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/schemas.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,UA0CtB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,UAwB3B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,UAmB7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,UAe7B,CAAC"}
|