@walkeros/core 4.0.0-next-1777463920154 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,t={},n={},o={},r={},i={},s={},a={};((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(a,{Level:()=>c});var c=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(c||{}),f={},l={},u={},p={},d={},m={},g={},y={},b={},h={},v={},w={},j={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function k(e){return{_meta:{hops:0,path:[e]}}}function $(e,t){return{event:e,next:t}}function x(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function O(e){throw new Error(String(e))}var S=["globals","context","custom","user","consent"],A=new Set(["description","examples","title","$comment"]);function E(e){const t={},n=new Set;function o(r){if(t[r])return t[r];n.has(r)&&O(`Circular extends chain detected: ${[...n,r].join(" → ")}`);const i=e[r];i||O(`Contract "${r}" not found`),n.add(r);let s={};if(i.extends){s=function(e,t){const n={};void 0===e.description&&void 0===t.description||(n.description=t.description??e.description);for(const o of S){const r=e[o],i=t[o];r&&i?n[o]=_(r,i):(r||i)&&(n[o]={...r||i})}if(e.events||t.events){const o={},r=new Set([...Object.keys(e.events||{}),...Object.keys(t.events||{})]);for(const n of r){const r=e.events?.[n]||{},i=t.events?.[n]||{},s=new Set([...Object.keys(r),...Object.keys(i)]);o[n]={};for(const e of s){const t=r[e],s=i[e];o[n][e]=t&&s?_(t,s):{...t||s}}}n.events=o}return n}(o(i.extends),i)}else s={...i};if(delete s.extends,s.events&&(s.events=function(e){const t={};for(const n of Object.keys(e))if("*"!==n){t[n]={};for(const o of Object.keys(e[n]||{})){let r={};const i=e["*"]?.["*"];i&&(r=_(r,i));const s=e["*"]?.[o];s&&"*"!==o&&(r=_(r,s));const a=e[n]?.["*"];a&&"*"!==o&&(r=_(r,a));const c=e[n]?.[o];c&&(r=_(r,c)),t[n][o]=r}}e["*"]&&(t["*"]={...e["*"]});return t}(s.events)),s.events){const e={};for(const[t,n]of Object.entries(s.events)){e[t]={};for(const[o,r]of Object.entries(n))e[t][o]=N(r)}s.events=e}return n.delete(r),t[r]=s,s}for(const t of Object.keys(e))o(t);return t}function _(e,t){const n={...e};for(const o of Object.keys(t)){const r=e[o],i=t[o];"required"===o&&Array.isArray(r)&&Array.isArray(i)?n[o]=[...new Set([...r,...i])]:C(r)&&C(i)?n[o]=_(r,i):n[o]=i}return n}function N(e){const t={};for(const[n,o]of Object.entries(e))A.has(n)||(null===o||"object"!=typeof o||Array.isArray(o)?t[n]=o:t[n]=N(o));return t}function C(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var P=/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,M=/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,R=/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,T=/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,z=/^\$flow\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z0-9_.]+))?$/,I=/^\$store\.([a-zA-Z_][a-zA-Z0-9_]*)$/,H=/^\$secret\.([A-Z0-9_]+)$/,W="$code:";function F(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function U(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}var Z="__WALKEROS_ENV:";function D(e,t,n){const o=`$flow.${e}${t?`.${t}`:""}`;if("unknown-flow"===n)return`${o} cannot resolve: flow "${e}" does not exist in this config.`;return`${o} is empty. Set ${t?`flows.${e}.config.${t}`:`flows.${e}.config`}, or run \`walkeros deploy ${e}\` first.`}function L(e,t,n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const i=o[e];if(null==r||"object"!=typeof r){const r=o.slice(0,e).join(".");O(`Path "${t}" not found in "${n}": "${i}" does not exist${r?` in "${r}"`:""}`)}const s=r;if(!(i in s)){const r=o.slice(0,e).join(".");O(`Path "${t}" not found in "${n}": "${i}" does not exist${r?` in "${r}"`:""}`)}r=s[i]}return r}function K(e,t,n,o,r,i){if("string"==typeof e){const s=e.match(M);if(s){const e=s[1],a=s[2];void 0===n[e]&&O(`Definition "${e}" not found`);let c=K(n[e],t,n,o,r,i);return a&&(c=L(c,a,`$def.${e}`)),c}const a=e.match(T);if(a&&r){const e=a[1],t=a[2];e in r||O(`Contract "${e}" not found`);let n=r[e];return t&&(n=L(n,t,`$contract.${e}`)),n}const c=e.match(z);if(c){const t=c[1],n=c[2],r=!1===o?.strictFlowRefs;i||O(`$flow.${t}${n?`.${n}`:""} cannot be resolved without a flow resolver`);const s=i(t);if(!s){if(r)return o?.onWarning?.(D(t,n,"unknown-flow")),e;O(`Flow "${t}" not found in $flow.${t}`)}let a=s;if(n)if(r){try{a=L(a,n,`$flow.${t}`)}catch{return o?.onWarning?.(D(t,n,"missing-key")),e}if(null==a||""===a)return o?.onWarning?.(D(t,n,"missing-key")),e}else a=L(a,n,`$flow.${t}`);return a}let f=e.replace(P,(e,n)=>{if(void 0!==t[n])return String(t[n]);O(`Variable "${n}" not found`)});return f=f.replace(R,(e,t,n)=>o?.deferred?void 0!==n?`${Z}${t}:${n}`:`${Z}${t}`:"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==n?n:void O(`Environment variable "${t}" not found and no default provided`)),f}if(Array.isArray(e))return e.map(e=>K(e,t,n,o,r,i));if(null!==e&&"object"==typeof e){const s={};for(const[a,c]of Object.entries(e))s[a]=K(c,t,n,o,r,i);return s}return e}function B(e){const t=e.startsWith("@"),n=e.replace("@","").replace(/[/-]/g,"_").split("_").filter(e=>e.length>0).map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return t?"_"+n:n}function J(e,t,n){if(t)return t;if(!e||!n)return;return n[e]?B(e):void 0}function V(e,t,n){const o=new Map,r=new Set,i=[],s=t=>{if(o.has(t))return o.get(t);const a=e.flows[t];if(a){if(r.has(t)){O(`Cyclic $flow reference: ${[...i,t].join(" -> ")}`)}r.add(t),i.push(t);try{const r=F(e.variables,a.variables),i=U(e.definitions,a.definitions),c=K(a.config??{},r,i,n,void 0,s);return o.set(t,c),c}finally{r.delete(t),i.pop()}}},a=Object.keys(e.flows);t||(1===a.length?t=a[0]:O(`Multiple flows found (${a.join(", ")}). Please specify a flow.`));const c=e.flows[t];c||O(`Flow "${t}" not found. Available: ${a.join(", ")}`),r.add(t),i.push(t);try{return function(e,t,n,o){const r=JSON.parse(JSON.stringify(t));let i;if(e.contract){const r=F(e.variables,t.variables),s=U(e.definitions,t.definitions);i=E(K(e.contract,r,s,n,void 0,o))}if(r.config){const s=F(e.variables,t.variables),a=U(e.definitions,t.definitions);r.config=K(r.config,s,a,n,i,o)}if(r.sources)for(const[s,a]of Object.entries(r.sources)){const c=F(e.variables,t.variables,a.variables),f=U(e.definitions,t.definitions,a.definitions),l=K(a.config,c,f,n,i,o),u=K(a.env,c,f,n,i,o),p=J(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.sources[s]={package:a.package,config:l,env:u,primary:a.primary,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.destinations)for(const[s,a]of Object.entries(r.destinations)){const c=F(e.variables,t.variables,a.variables),f=U(e.definitions,t.definitions,a.definitions),l=K(a.config,c,f,n,i,o),u=K(a.env,c,f,n,i,o),p=J(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.destinations[s]={package:a.package,config:l,env:u,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.stores)for(const[s,a]of Object.entries(r.stores)){const c=F(e.variables,t.variables,a.variables),f=U(e.definitions,t.definitions,a.definitions),l=K(a.config,c,f,n,i,o),u=K(a.env,c,f,n,i,o),p=J(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.stores[s]={package:a.package,config:l,env:u,variables:a.variables,definitions:a.definitions,code:m}}if(r.transformers)for(const[s,a]of Object.entries(r.transformers)){const c=F(e.variables,t.variables,a.variables),f=U(e.definitions,t.definitions,a.definitions),l=K(a.config,c,f,n,i,o),u=K(a.env,c,f,n,i,o),p=J(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.transformers[s]={package:a.package,config:l,env:u,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.collector){const s=F(e.variables,t.variables),a=U(e.definitions,t.definitions),c=K(r.collector,s,a,n,i,o);r.collector=c}return r}(e,c,n,s)}finally{r.delete(t),i.pop()}}function q(e){const t=e.config?.platform;if("web"===t||"server"===t)return t;O('Flow must have config.platform set to "web" or "server"')}var X={merge:!0,shallow:!0,extend:!0};function G(e,t={},n={}){n={...X,...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 Q(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function Y(e){return Array.isArray(e)}function ee(e){return"boolean"==typeof e}function te(e){return"walker"===e}function ne(e){return void 0!==e}function oe(e){return!(!e||"object"!=typeof e)&&("body"in e||"tagName"in e)}function re(e){return"function"==typeof e}function ie(e){return"number"==typeof e&&!Number.isNaN(e)}function se(e){return"object"==typeof e&&null!==e&&!Y(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ae(e,t){return typeof e==typeof t}function ce(e){return"string"==typeof e}function fe(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]=fe(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(fe(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 le(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&Y(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=le(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,void 0===r)break}return ne(r)?r:n}function ue(e,t,n){if(!se(e))return e;const o=fe(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}var pe={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,timing:e.timing})};function de(e,t){const n={},o=t.includes("all")?Object.keys(pe):t;for(const t of o){const o=pe[t];if(!o)continue;const r=o(e);if(se(r))for(const[e,o]of Object.entries(r)){if(void 0===o)continue;const r="context"===t&&Array.isArray(o)?o[0]:o;n[`${t}_${e}`]=r}}return n}function me(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function ge(e,t={},n={}){const o={...t,...n},r={};let i=!e||0===Object.keys(e).length;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function ye(e,t){const n={...e};return n.config=G(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=G(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=G(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function be(e,t){if(!se(t))return e;for(const n of Object.keys(t)){const o=t[n];void 0!==o&&(se(o)&&se(e[n])?be(e[n],o):e[n]=o)}return e}function he(){let e="";for(let t=0;t<16;t++)e+=(16*Math.random()|0).toString(16);return e}function ve(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=G({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"}}],consent:{functional:!0},id:e.id||he(),trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,source:{type:"collector",schema:"4"}},e,{merge:!1});if(e.name){const[t,o]=e.name.split(" ")??[];t&&o&&(n.entity=t,n.action=o)}return n}function we(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},r={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return ve({...{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...o.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+r.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"product",...r,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.walkeros.io/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...o,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...o,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...o.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function je(e=6,t){if(t){const n=t.length;let o="";for(let r=0;r<e;r++)o+=t[Math.random()*n|0];return o}let n="";for(let t=36;n.length<e;)n+=(Math.random()*t|0).toString(t);return n}var ke=[{param:"gclid",platform:"google"},{param:"wbraid",platform:"google"},{param:"gbraid",platform:"google"},{param:"dclid",platform:"google"},{param:"gclsrc",platform:"google"},{param:"fbclid",platform:"meta"},{param:"igshid",platform:"meta"},{param:"msclkid",platform:"microsoft"},{param:"ttclid",platform:"tiktok"},{param:"twclid",platform:"twitter"},{param:"li_fat_id",platform:"linkedin"},{param:"epik",platform:"pinterest"},{param:"sclid",platform:"snapchat"},{param:"sccid",platform:"snapchat"},{param:"rdt_cid",platform:"reddit"},{param:"qclid",platform:"quora"},{param:"yclid",platform:"yandex"},{param:"ymclid",platform:"yandex"},{param:"ysclid",platform:"yandex"},{param:"dicbo",platform:"outbrain"},{param:"obclid",platform:"outbrain"},{param:"tblci",platform:"taboola"},{param:"mc_cid",platform:"mailchimp"},{param:"mc_eid",platform:"mailchimp"},{param:"_kx",platform:"klaviyo"},{param:"_hsenc",platform:"hubspot"},{param:"_hsmi",platform:"hubspot"},{param:"s_kwcid",platform:"adobe"},{param:"ef_id",platform:"adobe"},{param:"mkt_tok",platform:"adobe"},{param:"irclickid",platform:"impact"},{param:"cjevent",platform:"cj"},{param:"_branch_match_id",platform:"branch"}];function $e(e,t={},n=[]){const o={};Object.entries(G({utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term"},t)).forEach(([t,n])=>{const r=e.searchParams.get(t);r&&(o[n]=r)});const r=n.length?function(e){const t=new Map(e.map(e=>[e.param,e.platform])),n=new Set(ke.map(e=>e.param));return[...ke.map(e=>t.has(e.param)?{param:e.param,platform:t.get(e.param)}:e),...e.filter(e=>!n.has(e.param))]}(n):ke,i=new Map;e.searchParams.forEach((e,t)=>{e&&i.set(t.toLowerCase(),e)});for(const e of r){const t=i.get(e.param);t&&(o[e.param]=t,o.clickId||(o.clickId=e.param,o.platform=e.platform))}return o}function xe(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 Oe(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}function Se(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function Ae(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=Se(e)):n=e,void 0!==t&&(t instanceof Error?o.error=Se(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=Se(o.error))):o.value=t),{message:n,context:o}}var Ee=(e,t,n,o)=>{const r=`${c[e]}${o.length>0?` [${o.join(":")}]`:""}`,i=Object.keys(n).length>0,s=0===e?console.error:1===e?console.warn:console.log;i?s(r,t,n):s(r,t)};function _e(e={}){return Ne({level:void 0!==e.level?function(e){return"string"==typeof e?c[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function Ne(e){const{level:t,handler:n,jsonHandler:o,scope:r}=e,i=(e,o,i)=>{if(e<=t){const t=Ae(o,i);n?n(e,t.message,t.context,r,Ee):Ee(e,t.message,t.context,r)}};return{error:(e,t)=>i(0,e,t),warn:(e,t)=>i(1,e,t),info:(e,t)=>i(2,e,t),debug:(e,t)=>i(3,e,t),throw:(e,t)=>{const o=Ae(e,t);throw n?n(0,o.message,o.context,r,Ee):Ee(0,o.message,o.context,r),new Error(o.message)},json:e=>{o?o(e):console.log(JSON.stringify(e,null,2))},scope:e=>Ne({level:t,handler:n,jsonHandler:o,scope:[...r,e]})}}function Ce(e){return ee(e)||ce(e)||ie(e)||!ne(e)||Y(e)&&e.every(Ce)||se(e)&&Object.values(e).every(Ce)}function Pe(e){return ee(e)||ce(e)||ie(e)?e:Q(e)?Pe(Array.from(e)):Y(e)?e.map(e=>Pe(e)).filter(e=>void 0!==e):se(e)?Object.entries(e).reduce((e,[t,n])=>{const o=Pe(n);return void 0!==o&&(e[t]=o),e},{}):void 0}function Me(e){return Ce(e)?e:void 0}function Re(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function Te(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function ze(e,t){const[n,o]=(e.name||"").split(" ");if(!t||!n||!o)return{};let r,i="",s=n,a=o;const c=t=>{if(t)return(t=Y(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const f=t[s];return f&&(f[a]||(a="*"),r=c(f[a])),r||(s="*",a="*",r=c(t[s]?.[a])),r&&(i=`${s} ${a}`),{eventMapping:r,mappingKey:i}}async function Ie(e,t={},n={}){if(!ne(e))return;const o=se(e)&&e.consent||n.consent||n.collector?.consent,r=Y(t)?t:[t];for(const t of r){const r=await Te(He)(e,t,{...n,consent:o});if(ne(r))return r}}async function He(e,t,n={}){const{collector:o,consent:r}=n;return(Y(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const a=ce(i)?{key:i}:i;if(!Object.keys(a).length)return;const{condition:c,consent:f,fn:l,key:u,loop:p,map:d,set:m,validate:g,value:y}=a;if(c&&!await Te(c)(e,i,o))return;if(f&&!ge(f,r))return y;let b=ne(y)?y:e;if(l&&(b=await Te(l)(e,i,n)),u&&(b=le(e,u,y)),p){const[t,o]=p,r="this"===t?[e]:await Ie(e,t,n);Y(r)&&(b=(await Promise.all(r.map(e=>Ie(e,o,n)))).filter(ne))}else d?b=await Object.entries(d).reduce(async(t,[o,r])=>{const i=await t,s=await Ie(e,r,n);return ne(s)&&(i[o]=s),i},Promise.resolve({})):m&&(b=await Promise.all(m.map(t=>He(e,t,n))));g&&!await Te(g)(b)&&(b=void 0);const h=Me(b);return ne(h)?h:Me(y)},Promise.resolve(void 0))}async function We(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await Ie(e,o,{collector:n});e=ue(e,t,r)}));const{eventMapping:o,mappingKey:r}=await ze(e,t.mapping);o?.policy&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await Ie(e,o,{collector:n});e=ue(e,t,r)}));let i=t.data&&await Ie(e,t.data,{collector:n});const s=Boolean(o?.silent);if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0,silent:s};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await Ie(e,o.data,{collector:n});i=se(i)&&se(t)?G(i,t):t}}const a=o?.include??t.include;if(a&&a.length>0){const t=de(e,a);Object.keys(t).length>0&&(i=se(i)?G(t,i):i??t)}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1,silent:s}}function Fe(e,t){const n=(e,o=[])=>new Proxy(e,{get(e,r){const i=e[r],s=[...o,r];return"function"==typeof i?i.prototype&&i.prototype.constructor===i?i:(...e)=>{const o=t(s,e,i);if(o&&"object"==typeof o)return n(o,s);const r=i(...e);return r&&"object"==typeof r?n(r,s):o}:i&&"object"==typeof i?n(i,s):i}});return n(e)}function Ue(e,t){const n=(e,o=[])=>{if(!e||"object"!=typeof e)return e;const r=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...o,i];Array.isArray(r)?r[Number(i)]=t(s,e):r[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(r)?r[Number(i)]=n(s,e):r[i]=n(s,e))}return r};return n(e)}function Ze(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=Ze();return e.push(n),n});return{error:jest.fn(),warn:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,json:jest.fn(),scope:n,scopedLoggers:e}}function De(e={}){return{collector:{},config:{},env:{},logger:Ze(),id:"test",ingest:k("test"),...e}}function Le(e){const t=String(e),n=t.split("?")[1]||t;return Re(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const o=n.split(/[[\]]+/).filter(Boolean);let r=t;o.forEach((t,n)=>{const i=n===o.length-1;if(Y(r)){const s=parseInt(t,10);i?r[s]=me(e):(r[s]=r[s]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[s])}else se(r)&&(i?r[t]=me(e):(r[t]=r[t]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[t]))})}),t})()}function Ke(e){if(!e)return"";const t=[],n=encodeURIComponent;function o(e,r){null!=r&&(Y(r)?r.forEach((t,n)=>o(`${e}[${n}]`,t)):se(r)?Object.entries(r).forEach(([t,n])=>o(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(r))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>o(e,t)),t.join("&"))}function Be(e){return void 0===e||ae(e,"")?e:JSON.stringify(e)}function Je(e={}){return G({"Content-Type":"application/json; charset=utf-8"},e)}function Ve(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function qe(e,t,n,o){return function(...r){let i;const s="pre"+t,a="post"+t,c=n[s],f=n[a],l=(e,t)=>{o?o.warn(e,{error:t}):console.warn(e,t)};if(c)try{i=c({fn:e},...r)}catch(t){l(`Hook ${String(s)} failed, falling back to original function`,t),i=e(...r)}else i=e(...r);if(f)try{i=f({fn:e,result:i},...r)}catch(e){l(`Hook ${String(a)} failed, keeping original result`,e)}return i}}function Xe(e){return e?{userAgent:e,browser:Ge(e),browserVersion:Qe(e),os:Ye(e),osVersion:et(e),deviceType:tt(e)}:{}}function Ge(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function Qe(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function Ye(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function et(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function tt(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function nt(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function ot(e){const t=nt(e);return new Function("value","mapping","collector",t)}function rt(e){const t=nt(e);return new Function("value","mapping","options",t)}function it(e){const t=nt(e);return new Function("value",t)}function st(e){return"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?e:void 0}async function at(e,t){const n=t?.version||"latest",o=t?.timeout||1e4,r=new AbortController,i=setTimeout(()=>r.abort(),o),s=r.signal,a=t?.client?{"X-Walkeros-Client":t.client}:void 0;try{if(t?.baseUrl){const o=`${t.baseUrl}/api/packages/${encodeURIComponent(e)}?version=${encodeURIComponent(n)}&expand=all`,r=await fetch(o,{signal:s,...a&&{headers:a}});if(!r.ok)throw new Error(`Failed to fetch ${o} (HTTP ${r.status})`);return function(e,t,n){const o=n.schemas||{},r=n.examples||{},i=n.hints,s=n.hintKeys??(i?Object.keys(i):[]),a=n.exampleSummaries??[],c=n.platform;return{packageName:n.package||e,version:"string"==typeof n.version?n.version:t,...void 0!==n.description&&{description:n.description},...void 0!==n.type&&{type:n.type},...void 0!==c&&{platform:c},schemas:o,examples:r,...void 0!==n.docs&&{docs:n.docs},...void 0!==n.source&&{source:n.source},...i&&Object.keys(i).length>0?{hints:i}:{},hintKeys:s,exampleSummaries:a}}(e,n,await r.json())}const o=`https://cdn.jsdelivr.net/npm/${e}@${n}`,r=await ct(`${o}/package.json`,s,a);return function(e,t,n,o){const r=o.$meta||{},i=o.schemas||{},s=o.examples||{},a=o.hints,c=a?Object.keys(a):[],f=[],l=s.step||{};for(const[e,t]of Object.entries(l)){const n=t,o={name:e};"string"==typeof n?.description&&(o.description=n.description),f.push(o)}const u="string"==typeof r.docs?r.docs:void 0,p="string"==typeof r.source?r.source:void 0;return{packageName:e,version:"string"==typeof n.version?n.version:t,description:"string"==typeof n.description?n.description:void 0,type:"string"==typeof r.type?r.type:void 0,platform:st(r.platform),schemas:i,examples:s,...u?{docs:u}:{},...p?{source:p}:{},...a&&Object.keys(a).length>0?{hints:a}:{},hintKeys:c,exampleSummaries:f}}(e,n,r,await ct(`${o}/dist/walkerOS.json`,s,a))}finally{clearTimeout(i)}}async function ct(e,t,n){const o=await fetch(e,{signal:t,...n&&{headers:n}});if(!o.ok)throw new Error(`Failed to fetch ${e} (HTTP ${o.status})`);return await o.json()}async function ft(e,t){const n=await at(e,t);return{packageName:n.packageName,version:n.version,type:n.type,platform:n.platform,schemas:n.schemas,examples:n.examples,...n.hints?{hints:n.hints}:{}}}function lt(e,t){const n=t?{...e,_hints:t}:e;return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}}function ut(e,t){let n,o,r,i;if(e instanceof Error){n=e.message;const t=e;t.code&&(r=t.code),Array.isArray(t.details)&&(i=t.details)}else if("string"==typeof e)n=e;else if(e&&"object"==typeof e&&"issues"in e&&Array.isArray(e.issues)){const t=e.issues;n=t.map(e=>e.message).join("; "),o=t[0]?.path?.join(".")||void 0}else n=e&&"object"==typeof e&&"message"in e?String(e.message):"Unknown error";const s={error:n};return t&&(s.hint=t),o&&(s.path=o),r&&(s.code=r),i&&(s.details=i),{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s,isError:!0}}function pt(e){let t=!1;return(n={})=>{t||(t=!0,e(n))}}function dt(e){if("*"===e)return()=>!0;if("and"in e){const t=e.and.map(dt);return e=>t.every(t=>t(e))}if("or"in e){const t=e.or.map(dt);return e=>t.some(t=>t(e))}return function(e){const{key:t,operator:n,value:o,not:r}=e,i=function(e,t){switch(e){case"eq":return e=>String(e??"")===t;case"contains":return e=>String(e??"").includes(t);case"prefix":return e=>String(e??"").startsWith(t);case"suffix":return e=>String(e??"").endsWith(t);case"regex":{const e=new RegExp(t);return t=>e.test(String(t??""))}case"gt":{const e=Number(t);return t=>Number(t)>e}case"lt":{const e=Number(t);return t=>Number(t)<e}case"exists":return e=>null!=e}}(n,o);return e=>{const n=le(e,t),o=i(n);return r?!o:o}}(e)}function mt(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&"match"in e[0]}function gt(e){if(null!=e){if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;if(mt(e)){return{type:"routes",routes:e.map(e=>({match:dt(e.match),next:gt(e.next)}))}}return{type:"chain",value:e}}}}function yt(e,t={}){if(e){if("static"===e.type)return e.value;if("chain"===e.type)return e.value;for(const n of e.routes)if(n.match(t))return yt(n.next,t)}}function bt(e,t){const n={ingest:e??{}};return void 0!==t&&(n.event=t),n}function ht(e){return{full:e.full??!1,storeId:e.store,rules:e.rules.map(e=>({match:dt(e.match),key:e.key,ttl:e.ttl,update:e.update}))}}function vt(e,t,n,o){const r=e.rules.find(e=>e.match(n));if(!r)return null;const i=r.key.map(e=>String(le(n,e)??""));if(i.every(e=>""===e))return null;const s=`${o}:${i.join(":")}`,a=t.get(s);return void 0!==a?{status:"HIT",key:s,value:a,rule:r}:{status:"MISS",key:s,rule:r}}function wt(e,t,n,o){e.set(t,n,1e3*o)}async function jt(e,t,n){if(!t)return e;let o=e;for(const[e,r]of Object.entries(t)){o=ue(o,e,await Ie(n,r))}return o}function kt(e){return 0===e.length?"// no output":e.map($t).join(";\n\n")}function $t(e){const[t,...n]=e,o=n.map(xt).join(", ");return"return"===t?o?`return ${o}`:"return":`${t}(${o})`}function xt(e){return void 0===e?"undefined":null===e?"null":"function"==typeof e?"[Function]":JSON.stringify(e,null,2)}export{t as Cache,n as Collector,j as Const,o as Context,r as Destination,Z as ENV_MARKER_PREFIX,i as Elb,w as Hint,s as Hooks,c as Level,y as Lifecycle,a as Logger,f as Mapping,v as Matcher,l as On,W as REF_CODE_PREFIX,T as REF_CONTRACT,M as REF_DEF,R as REF_ENV,H as REF_SECRET,I as REF_STORE,P as REF_VAR,p as Request,h as Simulation,d as Source,m as Store,u as Transformer,g as Trigger,b as WalkerOS,x as anonymizeIP,jt as applyUpdate,G as assign,$ as branch,bt as buildCacheContext,Me as castToProperty,me as castValue,vt as checkCache,fe as clone,ht as compileCache,dt as compileMatcher,gt as compileNext,ye as createDestination,ve as createEvent,k as createIngest,_e as createLogger,De as createMockContext,Ze as createMockLogger,pt as createRespond,xe as debounce,be as deepMerge,ke as defaultClickIds,at as fetchPackage,ft as fetchPackageSchema,Pe as filterValues,de as flattenIncludeSections,kt as formatOut,Ge as getBrowser,Qe as getBrowserVersion,le as getByPath,tt as getDeviceType,we as getEvent,V as getFlowSettings,ge as getGrantedConsent,Je as getHeaders,je as getId,ze as getMappingEvent,Ie as getMappingValue,$e as getMarketingParameters,Ye as getOS,et as getOSVersion,q as getPlatform,he as getSpanId,Q as isArguments,Y as isArray,ee as isBoolean,te as isCommand,ne as isDefined,oe as isElementOrDocument,re as isFunction,ie as isNumber,se as isObject,Ce as isPropertyType,mt as isRouteArray,ae as isSameType,ce as isString,ut as mcpError,lt as mcpResult,_ as mergeContractSchemas,Fe as mockEnv,B as packageNameToVariable,Xe as parseUserAgent,We as processEventMapping,Le as requestToData,Ke as requestToParameter,E as resolveContracts,yt as resolveNext,ue as setByPath,wt as storeCache,Oe as throttle,O as throwError,Be as transformData,Ue as traverseEnv,Ve as trim,Re as tryCatch,Te as tryCatchAsync,qe as useHooks,L as walkPath,ot as wrapCondition,rt as wrapFn,it as wrapValidate};//# sourceMappingURL=index.mjs.map
1
+ var e=Object.defineProperty,t={},n={},o={},r={},i={},s={},a={};((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(a,{Level:()=>c});var c=(e=>(e[e.ERROR=0]="ERROR",e[e.WARN=1]="WARN",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e))(c||{}),l={},f={},u={},p={},d={},m={},g={},y={},b={},h={},v={},w={},j={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function k(e){return{_meta:{hops:0,path:[e]}}}function $(e,t){return{event:e,next:t}}function x(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function O(e){throw new Error(String(e))}var S=["globals","context","custom","user","consent"],A=new Set(["description","examples","title","$comment"]);function E(e){const t={},n=new Set;function o(r){if(t[r])return t[r];n.has(r)&&O(`Circular extends chain detected: ${[...n,r].join(" → ")}`);const i=e[r];i||O(`Contract "${r}" not found`),n.add(r);let s={};if(i.extends){s=function(e,t){const n={};void 0===e.description&&void 0===t.description||(n.description=t.description??e.description);for(const o of S){const r=e[o],i=t[o];r&&i?n[o]=_(r,i):(r||i)&&(n[o]={...r||i})}if(e.events||t.events){const o={},r=new Set([...Object.keys(e.events||{}),...Object.keys(t.events||{})]);for(const n of r){const r=e.events?.[n]||{},i=t.events?.[n]||{},s=new Set([...Object.keys(r),...Object.keys(i)]);o[n]={};for(const e of s){const t=r[e],s=i[e];o[n][e]=t&&s?_(t,s):{...t||s}}}n.events=o}return n}(o(i.extends),i)}else s={...i};if(delete s.extends,s.events&&(s.events=function(e){const t={};for(const n of Object.keys(e))if("*"!==n){t[n]={};for(const o of Object.keys(e[n]||{})){let r={};const i=e["*"]?.["*"];i&&(r=_(r,i));const s=e["*"]?.[o];s&&"*"!==o&&(r=_(r,s));const a=e[n]?.["*"];a&&"*"!==o&&(r=_(r,a));const c=e[n]?.[o];c&&(r=_(r,c)),t[n][o]=r}}e["*"]&&(t["*"]={...e["*"]});return t}(s.events)),s.events){const e={};for(const[t,n]of Object.entries(s.events)){e[t]={};for(const[o,r]of Object.entries(n))e[t][o]=N(r)}s.events=e}return n.delete(r),t[r]=s,s}for(const t of Object.keys(e))o(t);return t}function _(e,t){const n={...e};for(const o of Object.keys(t)){const r=e[o],i=t[o];"required"===o&&Array.isArray(r)&&Array.isArray(i)?n[o]=[...new Set([...r,...i])]:C(r)&&C(i)?n[o]=_(r,i):n[o]=i}return n}function N(e){const t={};for(const[n,o]of Object.entries(e))A.has(n)||(null===o||"object"!=typeof o||Array.isArray(o)?t[n]=o:t[n]=N(o));return t}function C(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var P=/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,M=/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,R=/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,T=/^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/,z=/^\$flow\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z0-9_.]+))?$/,I=/^\$store\.([a-zA-Z_][a-zA-Z0-9_]*)$/,H=/^\$secret\.([A-Z0-9_]+)$/,W="$code:";function F(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function U(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}var Z="__WALKEROS_ENV:";function D(e,t,n){const o=`$flow.${e}${t?`.${t}`:""}`;if("unknown-flow"===n)return`${o} cannot resolve: flow "${e}" does not exist in this config.`;return`${o} is empty. Set ${t?`flows.${e}.config.${t}`:`flows.${e}.config`}, or run \`walkeros deploy ${e}\` first.`}function L(e,t,n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const i=o[e];if(null==r||"object"!=typeof r){const r=o.slice(0,e).join(".");O(`Path "${t}" not found in "${n}": "${i}" does not exist${r?` in "${r}"`:""}`)}const s=r;if(!(i in s)){const r=o.slice(0,e).join(".");O(`Path "${t}" not found in "${n}": "${i}" does not exist${r?` in "${r}"`:""}`)}r=s[i]}return r}function B(e,t,n,o,r,i){if("string"==typeof e){const s=e.match(M);if(s){const e=s[1],a=s[2];void 0===n[e]&&O(`Definition "${e}" not found`);let c=B(n[e],t,n,o,r,i);return a&&(c=L(c,a,`$def.${e}`)),c}const a=e.match(T);if(a&&r){const e=a[1],t=a[2];e in r||O(`Contract "${e}" not found`);let n=r[e];return t&&(n=L(n,t,`$contract.${e}`)),n}const c=e.match(z);if(c){const t=c[1],n=c[2],r=!1===o?.strictFlowRefs;i||O(`$flow.${t}${n?`.${n}`:""} cannot be resolved without a flow resolver`);const s=i(t);if(!s){if(r)return o?.onWarning?.(D(t,n,"unknown-flow")),e;O(`Flow "${t}" not found in $flow.${t}`)}let a=s;if(n)if(r){try{a=L(a,n,`$flow.${t}`)}catch{return o?.onWarning?.(D(t,n,"missing-key")),e}if(null==a||""===a)return o?.onWarning?.(D(t,n,"missing-key")),e}else a=L(a,n,`$flow.${t}`);return a}let l=e.replace(P,(e,n)=>{if(void 0!==t[n])return String(t[n]);O(`Variable "${n}" not found`)});return l=l.replace(R,(e,t,n)=>o?.deferred?void 0!==n?`${Z}${t}:${n}`:`${Z}${t}`:"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==n?n:void O(`Environment variable "${t}" not found and no default provided`)),l}if(Array.isArray(e))return e.map(e=>B(e,t,n,o,r,i));if(null!==e&&"object"==typeof e){const s={};for(const[a,c]of Object.entries(e))s[a]=B(c,t,n,o,r,i);return s}return e}function K(e){const t=e.startsWith("@"),n=e.replace("@","").replace(/[/-]/g,"_").split("_").filter(e=>e.length>0).map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return t?"_"+n:n}function V(e,t,n){if(t)return t;if(!e||!n)return;return n[e]?K(e):void 0}function q(e,t,n){const o=new Map,r=new Set,i=[],s=t=>{if(o.has(t))return o.get(t);const a=e.flows[t];if(a){if(r.has(t)){O(`Cyclic $flow reference: ${[...i,t].join(" -> ")}`)}r.add(t),i.push(t);try{const r=F(e.variables,a.variables),i=U(e.definitions,a.definitions),c=B(a.config??{},r,i,n,void 0,s);return o.set(t,c),c}finally{r.delete(t),i.pop()}}},a=Object.keys(e.flows);t||(1===a.length?t=a[0]:O(`Multiple flows found (${a.join(", ")}). Please specify a flow.`));const c=e.flows[t];c||O(`Flow "${t}" not found. Available: ${a.join(", ")}`),r.add(t),i.push(t);try{return function(e,t,n,o){const r=JSON.parse(JSON.stringify(t));let i;if(e.contract){const r=F(e.variables,t.variables),s=U(e.definitions,t.definitions);i=E(B(e.contract,r,s,n,void 0,o))}if(r.config){const s=F(e.variables,t.variables),a=U(e.definitions,t.definitions);r.config=B(r.config,s,a,n,i,o)}if(r.sources)for(const[s,a]of Object.entries(r.sources)){const c=F(e.variables,t.variables,a.variables),l=U(e.definitions,t.definitions,a.definitions),f=B(a.config,c,l,n,i,o),u=B(a.env,c,l,n,i,o),p=V(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.sources[s]={package:a.package,config:f,env:u,primary:a.primary,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.destinations)for(const[s,a]of Object.entries(r.destinations)){const c=F(e.variables,t.variables,a.variables),l=U(e.definitions,t.definitions,a.definitions),f=B(a.config,c,l,n,i,o),u=B(a.env,c,l,n,i,o),p=V(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.destinations[s]={package:a.package,config:f,env:u,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.stores)for(const[s,a]of Object.entries(r.stores)){const c=F(e.variables,t.variables,a.variables),l=U(e.definitions,t.definitions,a.definitions),f=B(a.config,c,l,n,i,o),u=B(a.env,c,l,n,i,o),p=V(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.stores[s]={package:a.package,config:f,env:u,variables:a.variables,definitions:a.definitions,code:m}}if(r.transformers)for(const[s,a]of Object.entries(r.transformers)){const c=F(e.variables,t.variables,a.variables),l=U(e.definitions,t.definitions,a.definitions),f=B(a.config,c,l,n,i,o),u=B(a.env,c,l,n,i,o),p=V(a.package,a.code,r.config?.bundle?.packages),d="string"==typeof a.code||"object"==typeof a.code?a.code:void 0,m=p||d;r.transformers[s]={package:a.package,config:f,env:u,variables:a.variables,definitions:a.definitions,before:a.before,next:a.next,cache:a.cache,code:m}}if(r.collector){const s=F(e.variables,t.variables),a=U(e.definitions,t.definitions),c=B(r.collector,s,a,n,i,o);r.collector=c}return r}(e,c,n,s)}finally{r.delete(t),i.pop()}}function J(e){const t=e.config?.platform;if("web"===t||"server"===t)return t;O('Flow must have config.platform set to "web" or "server"')}var X={merge:!0,shallow:!0,extend:!0};function G(e,t={},n={}){n={...X,...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 Q(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function Y(e){return Array.isArray(e)}function ee(e){return"boolean"==typeof e}function te(e){return"walker"===e}function ne(e){return void 0!==e}function oe(e){return!(!e||"object"!=typeof e)&&("body"in e||"tagName"in e)}function re(e){return"function"==typeof e}function ie(e){return"number"==typeof e&&!Number.isNaN(e)}function se(e){return"object"==typeof e&&null!==e&&!Y(e)&&"[object Object]"===Object.prototype.toString.call(e)}function ae(e,t){return typeof e==typeof t}function ce(e){return"string"==typeof e}function le(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]=le(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(le(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 fe(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&Y(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=fe(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,void 0===r)break}return ne(r)?r:n}function ue(e,t,n){if(!se(e))return e;const o=le(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}var pe={data:e=>e.data,globals:e=>e.globals,context:e=>e.context,user:e=>e.user,source:e=>e.source,event:e=>({entity:e.entity,action:e.action,id:e.id,timestamp:e.timestamp,name:e.name,trigger:e.trigger,timing:e.timing})};function de(e,t){const n={},o=t.includes("all")?Object.keys(pe):t;for(const t of o){const o=pe[t];if(!o)continue;const r=o(e);if(se(r))for(const[e,o]of Object.entries(r)){if(void 0===o)continue;const r="context"===t&&Array.isArray(o)?o[0]:o;n[`${t}_${e}`]=r}}return n}function me(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function ge(e,t={},n={}){const o={...t,...n},r={};let i=!e||0===Object.keys(e).length;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function ye(e,t){const n={...e};return n.config=G(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=G(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=G(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function be(e,t){if(!se(t))return e;for(const n of Object.keys(t)){const o=t[n];void 0!==o&&(se(o)&&se(e[n])?be(e[n],o):e[n]=o)}return e}function he(){let e="";for(let t=0;t<16;t++)e+=(16*Math.random()|0).toString(16);return e}function ve(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=G({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"}}],consent:{functional:!0},id:e.id||he(),trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,source:{type:"collector",schema:"4"}},e,{merge:!1});if(e.name){const[t,o]=e.name.split(" ")??[];t&&o&&(n.entity=t,n.action=o)}return n}function we(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},r={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return ve({...{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...o.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+r.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"product",...r,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.walkeros.io/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...o,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...o,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...o.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function je(e=6,t){if(t){const n=t.length;let o="";for(let r=0;r<e;r++)o+=t[Math.random()*n|0];return o}let n="";for(let t=36;n.length<e;)n+=(Math.random()*t|0).toString(t);return n}var ke=[{param:"gclid",platform:"google"},{param:"wbraid",platform:"google"},{param:"gbraid",platform:"google"},{param:"dclid",platform:"google"},{param:"gclsrc",platform:"google"},{param:"fbclid",platform:"meta"},{param:"igshid",platform:"meta"},{param:"msclkid",platform:"microsoft"},{param:"ttclid",platform:"tiktok"},{param:"twclid",platform:"twitter"},{param:"li_fat_id",platform:"linkedin"},{param:"epik",platform:"pinterest"},{param:"sclid",platform:"snapchat"},{param:"sccid",platform:"snapchat"},{param:"rdt_cid",platform:"reddit"},{param:"qclid",platform:"quora"},{param:"yclid",platform:"yandex"},{param:"ymclid",platform:"yandex"},{param:"ysclid",platform:"yandex"},{param:"dicbo",platform:"outbrain"},{param:"obclid",platform:"outbrain"},{param:"tblci",platform:"taboola"},{param:"mc_cid",platform:"mailchimp"},{param:"mc_eid",platform:"mailchimp"},{param:"_kx",platform:"klaviyo"},{param:"_hsenc",platform:"hubspot"},{param:"_hsmi",platform:"hubspot"},{param:"s_kwcid",platform:"adobe"},{param:"ef_id",platform:"adobe"},{param:"mkt_tok",platform:"adobe"},{param:"irclickid",platform:"impact"},{param:"cjevent",platform:"cj"},{param:"_branch_match_id",platform:"branch"}];function $e(e,t={},n=[]){const o={};Object.entries(G({utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term"},t)).forEach(([t,n])=>{const r=e.searchParams.get(t);r&&(o[n]=r)});const r=n.length?function(e){const t=new Map(e.map(e=>[e.param,e.platform])),n=new Set(ke.map(e=>e.param));return[...ke.map(e=>t.has(e.param)?{param:e.param,platform:t.get(e.param)}:e),...e.filter(e=>!n.has(e.param))]}(n):ke,i=new Map;e.searchParams.forEach((e,t)=>{e&&i.set(t.toLowerCase(),e)});for(const e of r){const t=i.get(e.param);t&&(o[e.param]=t,o.clickId||(o.clickId=e.param,o.platform=e.platform))}return o}function xe(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 Oe(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}function Se(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function Ae(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=Se(e)):n=e,void 0!==t&&(t instanceof Error?o.error=Se(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=Se(o.error))):o.value=t),{message:n,context:o}}var Ee=(e,t,n,o)=>{const r=`${c[e]}${o.length>0?` [${o.join(":")}]`:""}`,i=Object.keys(n).length>0,s=0===e?console.error:1===e?console.warn:console.log;i?s(r,t,n):s(r,t)};function _e(e={}){return Ne({level:void 0!==e.level?function(e){return"string"==typeof e?c[e]:e}(e.level):0,handler:e.handler,jsonHandler:e.jsonHandler,scope:[]})}function Ne(e){const{level:t,handler:n,jsonHandler:o,scope:r}=e,i=(e,o,i)=>{if(e<=t){const t=Ae(o,i);n?n(e,t.message,t.context,r,Ee):Ee(e,t.message,t.context,r)}};return{error:(e,t)=>i(0,e,t),warn:(e,t)=>i(1,e,t),info:(e,t)=>i(2,e,t),debug:(e,t)=>i(3,e,t),throw:(e,t)=>{const o=Ae(e,t);throw n?n(0,o.message,o.context,r,Ee):Ee(0,o.message,o.context,r),new Error(o.message)},json:e=>{o?o(e):console.log(JSON.stringify(e,null,2))},scope:e=>Ne({level:t,handler:n,jsonHandler:o,scope:[...r,e]})}}function Ce(e){return ee(e)||ce(e)||ie(e)||!ne(e)||Y(e)&&e.every(Ce)||se(e)&&Object.values(e).every(Ce)}function Pe(e){return ee(e)||ce(e)||ie(e)?e:Q(e)?Pe(Array.from(e)):Y(e)?e.map(e=>Pe(e)).filter(e=>void 0!==e):se(e)?Object.entries(e).reduce((e,[t,n])=>{const o=Pe(n);return void 0!==o&&(e[t]=o),e},{}):void 0}function Me(e){return Ce(e)?e:void 0}function Re(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function Te(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function ze(e,t,n){const[o,r]=(e.name||"").split(" ");if(!t||!o||!r)return{};let i,s="",a=o,c=r;const l=t=>{if(!t)return;return(Y(t)?t:[t]).find(t=>{if(!t.condition)return!0;if(!n)return Boolean(t.condition(e,void 0));const o={event:e,mapping:t,collector:n,logger:n.logger,consent:se(e)&&e.consent||n.consent};return Boolean(t.condition(e,o))})};t[a]||(a="*");const f=t[a];return f&&(f[c]||(c="*"),i=l(f[c])),i||(a="*",c="*",i=l(t[a]?.[c])),i&&(s=`${a} ${c}`),{eventMapping:i,mappingKey:s}}async function Ie(e,t={},n={}){if(!ne(e))return;const o=se(e)&&e.consent||n.consent||n.collector?.consent,r=n.event??(se(e)?e:{});if(!n.collector)throw new Error("getMappingValue: context.collector is required");const i={event:r,mapping:t,collector:n.collector,logger:n.collector.logger,consent:o},s=Y(t)?t:[t];for(const t of s){const n=await Te(He)(e,t,{...i,mapping:t});if(ne(n))return n}}async function He(e,t,n){return(Y(t)?t:[t]).reduce(async(t,o)=>{const r=await t;if(r)return r;const i=ce(o)?{key:o}:o;if(!Object.keys(i).length)return;const{condition:s,consent:a,fn:c,key:l,loop:f,map:u,set:p,validate:d,value:m}=i,g={...n,mapping:o};if(s&&!await Te(s)(e,g))return;if(a&&!ge(a,g.consent))return m;let y=ne(m)?m:e;if(c&&(y=await Te(c)(e,g)),l&&(y=fe(e,l,m)),f){const[t,n]=f,o="this"===t?[e]:await Ie(e,t,g);Y(o)&&(y=(await Promise.all(o.map(e=>Ie(e,n,g)))).filter(ne))}else u?y=await Object.entries(u).reduce(async(t,[n,o])=>{const r=await t,i=await Ie(e,o,g);return ne(i)&&(r[n]=i),r},Promise.resolve({})):p&&(y=await Promise.all(p.map(t=>He(e,t,g))));d&&!await Te(d)(y,g)&&(y=void 0);const b=Me(y);return ne(b)?b:Me(m)},Promise.resolve(void 0))}async function We(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await Ie(e,o,{collector:n,event:e});e=ue(e,t,r)}));const{eventMapping:o,mappingKey:r}=await ze(e,t.mapping,n);o?.policy&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await Ie(e,o,{collector:n,event:e});e=ue(e,t,r)}));let i=t.data&&await Ie(e,t.data,{collector:n,event:e});const s=Boolean(o?.silent);if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0,silent:s};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await Ie(e,o.data,{collector:n,event:e});i=se(i)&&se(t)?G(i,t):t}}const a=o?.include??t.include;if(a&&a.length>0){const t=de(e,a);Object.keys(t).length>0&&(i=se(i)?G(t,i):i??t)}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1,silent:s}}function Fe(e,t){const n=(e,o=[])=>new Proxy(e,{get(e,r){const i=e[r],s=[...o,r];return"function"==typeof i?i.prototype&&i.prototype.constructor===i?i:(...e)=>{const o=t(s,e,i);if(o&&"object"==typeof o)return n(o,s);const r=i(...e);return r&&"object"==typeof r?n(r,s):o}:i&&"object"==typeof i?n(i,s):i}});return n(e)}function Ue(e,t){const n=(e,o=[])=>{if(!e||"object"!=typeof e)return e;const r=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...o,i];Array.isArray(r)?r[Number(i)]=t(s,e):r[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(r)?r[Number(i)]=n(s,e):r[i]=n(s,e))}return r};return n(e)}function Ze(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=Ze();return e.push(n),n});return{error:jest.fn(),warn:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,json:jest.fn(),scope:n,scopedLoggers:e}}function De(e={}){return{collector:{},config:{},env:{},logger:Ze(),id:"test",ingest:k("test"),...e}}function Le(e){const t=String(e),n=t.split("?")[1]||t;return Re(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const o=n.split(/[[\]]+/).filter(Boolean);let r=t;o.forEach((t,n)=>{const i=n===o.length-1;if(Y(r)){const s=parseInt(t,10);i?r[s]=me(e):(r[s]=r[s]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[s])}else se(r)&&(i?r[t]=me(e):(r[t]=r[t]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[t]))})}),t})()}function Be(e){if(!e)return"";const t=[],n=encodeURIComponent;function o(e,r){null!=r&&(Y(r)?r.forEach((t,n)=>o(`${e}[${n}]`,t)):se(r)?Object.entries(r).forEach(([t,n])=>o(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(r))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>o(e,t)),t.join("&"))}function Ke(e){return void 0===e||ae(e,"")?e:JSON.stringify(e)}function Ve(e={}){return G({"Content-Type":"application/json; charset=utf-8"},e)}function qe(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Je(e,t,n,o){return function(...r){let i;const s="pre"+t,a="post"+t,c=n[s],l=n[a],f=(e,t)=>{o?o.warn(e,{error:t}):console.warn(e,t)};if(c)try{i=c({fn:e},...r)}catch(t){f(`Hook ${String(s)} failed, falling back to original function`,t),i=e(...r)}else i=e(...r);if(l)try{i=l({fn:e,result:i},...r)}catch(e){f(`Hook ${String(a)} failed, keeping original result`,e)}return i}}function Xe(e){return e?{userAgent:e,browser:Ge(e),browserVersion:Qe(e),os:Ye(e),osVersion:et(e),deviceType:tt(e)}:{}}function Ge(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function Qe(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function Ye(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function et(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function tt(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function nt(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function ot(e){const t=nt(e);return new Function("value","context",t)}function rt(e){const t=nt(e);return new Function("value","context",t)}function it(e){const t=nt(e);return new Function("value","context",t)}function st(e){return"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?e:void 0}async function at(e,t){const n=t?.version||"latest",o=t?.timeout||1e4,r=new AbortController,i=setTimeout(()=>r.abort(),o),s=r.signal,a=t?.client?{"X-Walkeros-Client":t.client}:void 0;try{if(t?.baseUrl){const o=`${t.baseUrl}/api/packages/${encodeURIComponent(e)}?version=${encodeURIComponent(n)}&expand=all`,r=await fetch(o,{signal:s,...a&&{headers:a}});if(!r.ok)throw new Error(`Failed to fetch ${o} (HTTP ${r.status})`);return function(e,t,n){const o=n.schemas||{},r=n.examples||{},i=n.hints,s=n.hintKeys??(i?Object.keys(i):[]),a=n.exampleSummaries??[],c=n.platform;return{packageName:n.package||e,version:"string"==typeof n.version?n.version:t,...void 0!==n.description&&{description:n.description},...void 0!==n.type&&{type:n.type},...void 0!==c&&{platform:c},schemas:o,examples:r,...void 0!==n.docs&&{docs:n.docs},...void 0!==n.source&&{source:n.source},...i&&Object.keys(i).length>0?{hints:i}:{},hintKeys:s,exampleSummaries:a}}(e,n,await r.json())}const o=`https://cdn.jsdelivr.net/npm/${e}@${n}`,r=await ct(`${o}/package.json`,s,a);return function(e,t,n,o){const r=o.$meta||{},i=o.schemas||{},s=o.examples||{},a=o.hints,c=a?Object.keys(a):[],l=[],f=s.step||{};for(const[e,t]of Object.entries(f)){const n=t,o={name:e};"string"==typeof n?.description&&(o.description=n.description),l.push(o)}const u="string"==typeof r.docs?r.docs:void 0,p="string"==typeof r.source?r.source:void 0;return{packageName:e,version:"string"==typeof n.version?n.version:t,description:"string"==typeof n.description?n.description:void 0,type:"string"==typeof r.type?r.type:void 0,platform:st(r.platform),schemas:i,examples:s,...u?{docs:u}:{},...p?{source:p}:{},...a&&Object.keys(a).length>0?{hints:a}:{},hintKeys:c,exampleSummaries:l}}(e,n,r,await ct(`${o}/dist/walkerOS.json`,s,a))}finally{clearTimeout(i)}}async function ct(e,t,n){const o=await fetch(e,{signal:t,...n&&{headers:n}});if(!o.ok)throw new Error(`Failed to fetch ${e} (HTTP ${o.status})`);return await o.json()}async function lt(e,t){const n=await at(e,t);return{packageName:n.packageName,version:n.version,type:n.type,platform:n.platform,schemas:n.schemas,examples:n.examples,...n.hints?{hints:n.hints}:{}}}function ft(e,t){const n=t?{...e,_hints:t}:e;return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}}function ut(e,t){let n,o,r,i;if(e instanceof Error){n=e.message;const t=e;t.code&&(r=t.code),Array.isArray(t.details)&&(i=t.details)}else if("string"==typeof e)n=e;else if(e&&"object"==typeof e&&"issues"in e&&Array.isArray(e.issues)){const t=e.issues;n=t.map(e=>e.message).join("; "),o=t[0]?.path?.join(".")||void 0}else n=e&&"object"==typeof e&&"message"in e?String(e.message):"Unknown error";const s={error:n};return t&&(s.hint=t),o&&(s.path=o),r&&(s.code=r),i&&(s.details=i),{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s,isError:!0}}function pt(e){let t=!1;return(n={})=>{t||(t=!0,e(n))}}function dt(e){if("*"===e)return()=>!0;if("and"in e){const t=e.and.map(dt);return e=>t.every(t=>t(e))}if("or"in e){const t=e.or.map(dt);return e=>t.some(t=>t(e))}return function(e){const{key:t,operator:n,value:o,not:r}=e,i=function(e,t){switch(e){case"eq":return e=>String(e??"")===t;case"contains":return e=>String(e??"").includes(t);case"prefix":return e=>String(e??"").startsWith(t);case"suffix":return e=>String(e??"").endsWith(t);case"regex":{const e=new RegExp(t);return t=>e.test(String(t??""))}case"gt":{const e=Number(t);return t=>Number(t)>e}case"lt":{const e=Number(t);return t=>Number(t)<e}case"exists":return e=>null!=e}}(n,o);return e=>{const n=fe(e,t),o=i(n);return r?!o:o}}(e)}function mt(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&"match"in e[0]}function gt(e){if(null!=e){if("string"==typeof e)return{type:"static",value:e};if(Array.isArray(e)){if(0===e.length)return;if(mt(e)){return{type:"routes",routes:e.map(e=>({match:dt(e.match),next:gt(e.next)}))}}return{type:"chain",value:e}}}}function yt(e,t={}){if(e){if("static"===e.type)return e.value;if("chain"===e.type)return e.value;for(const n of e.routes)if(n.match(t))return yt(n.next,t)}}function bt(e,t){const n={ingest:e??{}};return void 0!==t&&(n.event=t),n}function ht(e){return{full:e.full??!1,storeId:e.store,rules:e.rules.map(e=>({match:dt(e.match),key:e.key,ttl:e.ttl,update:e.update}))}}function vt(e,t,n,o){const r=e.rules.find(e=>e.match(n));if(!r)return null;const i=r.key.map(e=>String(fe(n,e)??""));if(i.every(e=>""===e))return null;const s=`${o}:${i.join(":")}`,a=t.get(s);return void 0!==a?{status:"HIT",key:s,value:a,rule:r}:{status:"MISS",key:s,rule:r}}function wt(e,t,n,o){e.set(t,n,1e3*o)}async function jt(e,t,n,o){if(!t)return e;let r=e;for(const[e,i]of Object.entries(t)){r=ue(r,e,await Ie(n,i,{collector:o}))}return r}function kt(e){return 0===e.length?"// no output":e.map($t).join(";\n\n")}function $t(e){const[t,...n]=e,o=n.map(xt).join(", ");return"return"===t?o?`return ${o}`:"return":`${t}(${o})`}function xt(e){return void 0===e?"undefined":null===e?"null":"function"==typeof e?"[Function]":JSON.stringify(e,null,2)}export{t as Cache,n as Collector,j as Const,o as Context,r as Destination,Z as ENV_MARKER_PREFIX,i as Elb,w as Hint,s as Hooks,c as Level,y as Lifecycle,a as Logger,l as Mapping,v as Matcher,f as On,W as REF_CODE_PREFIX,T as REF_CONTRACT,M as REF_DEF,R as REF_ENV,z as REF_FLOW,H as REF_SECRET,I as REF_STORE,P as REF_VAR,p as Request,h as Simulation,d as Source,m as Store,u as Transformer,g as Trigger,b as WalkerOS,x as anonymizeIP,jt as applyUpdate,G as assign,$ as branch,bt as buildCacheContext,Me as castToProperty,me as castValue,vt as checkCache,le as clone,ht as compileCache,dt as compileMatcher,gt as compileNext,ye as createDestination,ve as createEvent,k as createIngest,_e as createLogger,De as createMockContext,Ze as createMockLogger,pt as createRespond,xe as debounce,be as deepMerge,ke as defaultClickIds,at as fetchPackage,lt as fetchPackageSchema,Pe as filterValues,de as flattenIncludeSections,kt as formatOut,Ge as getBrowser,Qe as getBrowserVersion,fe as getByPath,tt as getDeviceType,we as getEvent,q as getFlowSettings,ge as getGrantedConsent,Ve as getHeaders,je as getId,ze as getMappingEvent,Ie as getMappingValue,$e as getMarketingParameters,Ye as getOS,et as getOSVersion,J as getPlatform,he as getSpanId,Q as isArguments,Y as isArray,ee as isBoolean,te as isCommand,ne as isDefined,oe as isElementOrDocument,re as isFunction,ie as isNumber,se as isObject,Ce as isPropertyType,mt as isRouteArray,ae as isSameType,ce as isString,ut as mcpError,ft as mcpResult,_ as mergeContractSchemas,Fe as mockEnv,K as packageNameToVariable,Xe as parseUserAgent,We as processEventMapping,Le as requestToData,Be as requestToParameter,E as resolveContracts,yt as resolveNext,ue as setByPath,wt as storeCache,Oe as throttle,O as throwError,Ke as transformData,Ue as traverseEnv,qe as trim,Re as tryCatch,Te as tryCatchAsync,Je as useHooks,L as walkPath,ot as wrapCondition,rt as wrapFn,it as wrapValidate};//# sourceMappingURL=index.mjs.map