window.__BECHTLE_SERVER_CTX__ = {"country":"DE","language":"pt","bid":"44ddd7d6e159446ba76d380f4fc4a12f_1775750647916_5f0eecc6432f88f21656ca100d2663c7","vid":"a701a996db0546b0ab6df0d7eb011548","user":{"context":"anonymous","xInternal":false,"isInCustomerContext":false,"isInternalUser":false},"tenant":"bechtle"};
(function(){"use strict";function I(){document.cookie.indexOf("_dy_cs_gcg")<0&&(!(Math.floor(Math.random()*100)<5)||document.cookie.indexOf("autotest=true")>=0?R("Dynamic Yield Experiences"):R("Control Group"))}function R(n){const e=new Date(Date.now()+3154e10);document.cookie=`_dy_cs_gcg=${n};path=/;expires=${e};`}function S(){document.cookie="_dy_cs_gcg=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;"}function U(){const n={},e={BECHTLE_SERVER_CTX_READY:[],CONSENT_CHANGE:[],PAGE_TYPE_READY:[],GTM_ID_READY:[],PERSISTENCE_ID_CHANGE:[],REALTIME_FILTER_READY:[],BEUS_TRACKING_CTX_READY:[]};return{get currentState(){return n},get listeners(){return e},on(t,o){const i=n[t];i!==void 0&&o(i),e[t].push({listener:o,isOnce:!1})},once(t,o){const i=n[t];if(i!==void 0)return o(i);e[t].push({listener:o,isOnce:!0})},off(t,o){const i=e[t].map(d=>d.listener).indexOf(o);e[t].splice(i,1)},dispatch(t,o){n[t]=o,e[t].forEach(({listener:d})=>{d(o)});const i=e[t].filter(({isOnce:d})=>!d).map(d=>d);e[t]=i},reset(t){n[t]=void 0,e[t].forEach(({listener:o})=>o(void 0))}}}const k=n=>typeof n=="string",L=(n,e,t)=>n&&k(n)?n.split(";").reduce((o,i)=>{const[d,h]=i.split("=").map(u=>u.trim());return o[decodeURIComponent(d)]=decodeURIComponent(h),o},{})[e]:t;let E;const N=new Uint8Array(16);function G(){if(!E&&(E=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!E))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return E(N)}const s=[];for(let n=0;n<256;++n)s.push((n+256).toString(16).slice(1));function H(n,e=0){return s[n[e+0]]+s[n[e+1]]+s[n[e+2]]+s[n[e+3]]+"-"+s[n[e+4]]+s[n[e+5]]+"-"+s[n[e+6]]+s[n[e+7]]+"-"+s[n[e+8]]+s[n[e+9]]+"-"+s[n[e+10]]+s[n[e+11]]+s[n[e+12]]+s[n[e+13]]+s[n[e+14]]+s[n[e+15]]}var D={randomUUID:typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Y(n,e,t){if(D.randomUUID&&!e&&!n)return D.randomUUID();n=n||{};const o=n.random||(n.rng||G)();if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,e){t=t||0;for(let i=0;i<16;++i)e[t+i]=o[i];return e}return H(o)}const M=()=>{if(document.cookie.includes("bechtle-p"))return L(document.cookie,"bechtle-p","");{const n=new Date;n.setMonth(n.getMonth()+13);const e=Y();return document.cookie=`bechtle-p=${e};path=/;expires=${n};`,e}},P=()=>{document.cookie="bechtle-p=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;"};function B(n){window.addEventListener("UC_EVENT",function(e){n(e.detail)})}const V=()=>{window.ACC=window.ACC||{config:{}}},g={portfolioType:0,showDynamicContent:!0};async function O(){return fetch("/api/beus/context/tracking",{credentials:"include",headers:new Headers({accept:"application/json"})}).then(async n=>n.status===200?await n.json():(console.error("Response status was not successful, using default TrackingContext"),g)).catch(()=>(console.error("Error fetching from BeUS, using default TrackingContext"),g))}const F=async n=>{var e,t,o,i;const d=n?await O():g;(t=(e=window.bechtle)==null?void 0:e.events)==null||t.dispatch("BEUS_TRACKING_CTX_READY",d);const{portfolioType:h,showDynamicContent:u}=d,p=h===1?"portfolio":h===2?"special_portfolio":"no_portfolio";(i=(o=window.bechtle)==null?void 0:o.analytics)==null||i.data("init_preferences",{event:"init_preferences",dc_preferences:{portfolio_type:p,show_dynamic_content:u}})},X=n=>{var e,t;const{language:o,country:i,vid:d,user:h}=n,{partnerId:u,hashedEMail:p,customer:m,context:_,seco:C,isProcurementUser:v,xInternal:f,xCustomer:T}=h,c=f?"intern":"extern",a=v?"punchout":"public",r=_==="admin"?"employee-global":_.length!==0?_:"anonymous",l={shop_country:i,shop_language:o,vid:d,context:r,procurement:a,intern:c};u&&(l.partner=u),p&&(l.logged_in="login",l.modus=C?"self":"care",l.hashed_email=p,l.be_nr=T||m),(t=(e=window.bechtle)==null?void 0:e.analytics)==null||t.data("init_session_data",{event:"init_session_data",session_data:l})},W=["init_session_data","init_preferences"],$=()=>{var n;const e=window.dataLayer=(n=window.dataLayer)!=null?n:[],t=[{"gtm.start":new Date().getTime(),event:"gtm.js"}];let o=!1,i=!1;const d=()=>{for(i=!0;t.length;){const c=t.shift();c&&e.push(c)}},h=c=>i?e.push(c):t.push(c),u={};let p=[];const m=c=>c.every(a=>u[a]!==void 0),_=(c,a)=>{const r=typeof c=="function"?c(u):c;a?i=!0:o=!0,Array.isArray(r)?r.forEach(l=>e.push(l)):e.push(r),a&&d()},C=()=>{const{allDepsReady:c,stillWaiting:a}=p.reduce((r,l)=>(m(l.dependentFrom)?r.allDepsReady.push(l):r.stillWaiting.push(l),r),{allDepsReady:[],stillWaiting:[]});p=a,c.forEach(r=>_(r.callback,r.flush))},v=(c,a,r)=>{i&&!r&&e.push(a),u[c]=a,C()},f=(c,a)=>{var r,l;if(typeof c!="function"&&!a){const j=c;c=x=>[x.init_session_data,j,x.init_preferences]}const y={callback:c,dependentFrom:(r=a==null?void 0:a.dependentFrom)!=null?r:W,flush:(l=a==null?void 0:a.flush)!=null?l:!0};m(y.dependentFrom)?_(y.callback,y.flush):p.push(y)},T=window.dataLayer.push;return window.dataLayer.push=function(c){return i||o?(o&&(o=!1),T.apply(window.dataLayer,[c])):(t.push(c),t.length)},{data:v,ready:f,push:h,queue:t,waitingForData:p,dataStorage:u}},A=U(),b=$();window.bechtle?(window.bechtle.events=A,window.bechtle.analytics=b):window.bechtle={events:A,analytics:b},window.dispatchEvent(new CustomEvent("BECHTLE_LIB_READY"));const w=window.__BECHTLE_SERVER_CTX__;window.bechtle.events.dispatch("BECHTLE_SERVER_CTX_READY",w),window.dispatchEvent(new CustomEvent("BECHTLE_SERVER_CTX_READY",{detail:w})),X(w),F(!!w.user.hashedEMail),V(),B(n=>{if(window.bechtle.events.dispatch("CONSENT_CHANGE",n),n["Persistence ID"]){const e=M();window.bechtle.events.dispatch("PERSISTENCE_ID_CHANGE",e)}else P(),window.bechtle.events.dispatch("PERSISTENCE_ID_CHANGE",null);n["Dynamic Yield"]?I():S()})})();
