PageSourceSearch

https://www.bestbuy.com/~assets/bby/_com/deo-client-script.js

js bestbuy.com collected 2026-09-24 09:07:10 UTC 59,751 bytes, 2 lines download raw bytes

1!function(){const e="www.bestbuy.com"===window.location.hostname?"6LeP0dgrAAAAAFn_1X2rBkI8vJKKsU0-LOJOsczw":"6LdestgrAAAAAC-8l8FPkkeLN5yugxpBmtxY0vr7",t="bby_rc",r={name:"s_channel"},n={name:"vt"},o={name:"ut"},a={name:"pt"},s={name:"testBucket"},i={name:"bby_rdp"},c={name:"CartItemCount"},d={name:"locStoreId"},u="digital-experience-event",l="employee-digital-experience-event",h="cjc-page-requests",p={id:"0a3112b5-31dc-4cad-8f36-11274f8aaa35",version:"2"},m={[u]:p,[l]:p,[h]:{id:"1a80fcb3-aab5-4d59-ba15-f76959ba2137",version:"2"}},g=({name:e})=>{if(!e)throw new Error("name required");return t=window?.document?.cookie?.match(new RegExp(`(^| )${e}=([^;]*)`))?.[2],void 0!==t?t.replace(/[^\w-_. ]/gi,"").replace(/ /g,""):void 0;var t};function y(e,t){return e="string"==typeof e?e:"No log label provided",t=t?.name&&t?.message?t:{name:"No name provided for error log",message:"No message provided for error log"},console.error(`CJ: ${e}`,t.name,t.message),window?.dtrum?.reportCustomError(`CJ: ${e}`,t.name,t.message,!0),!1}const w=()=>(new Date).toISOString().slice(0,19),f=()=>{try{const e=e=>"00".substring(0,2-e.length)+e,t=(new Date).getTimezoneOffset(),r=e(`${parseInt(Math.abs(t)/60)}`);return`${t>0?"UTC-":"UTC+"}${r}:${e(`${Math.abs(t%60)}`)}`}catch(e){y("timeZone",e)}},v=()=>{const e=document.cookie&&document.cookie.split("MCMID")[1]?decodeURI(document.cookie.split("MCMID")[1]):"";return""!==e?e.split("|")[1].split(";")[0]:""},b=()=>{if(window?.crypto?.randomUUID)return window.crypto.randomUUID();const e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=(e+16*Math.random())%16|0;return("x"===t?r:3&r|8).toString(16)})},S={_generateSessionId:()=>b(),_generateLocalSessionObject:(e,t,r,n)=>({sessionId:e,startTimestamp:t,lastEvent:r,sessionCount:n}),_getLocalSessionObject:()=>{try{return localStorage.getItem("cj_session_object")}catch(e){console.error("Error reading localStorage: ",e)}return null},_formatSessionForReturn:e=>{if(!e?.startTimestamp)throw new Error("Session startTimestamp is invalid");return{...e,startTimestamp:new Date(e.startTimestamp).toISOString()}},getSessionData:()=>{const e=S._getLocalSessionObject(),t=Date.now();if(e){const r=JSON.parse(e),n=t-Date.parse(r.lastEvent)>18e5,o=t-Date.parse(r.sessionStart)>864e5;if(n||o||!r.sessionUuid){const e=S._generateLocalSessionObject(S._generateSessionId(),t,t,r.sessionCount+1);try{return localStorage.setItem("cj_session_object",JSON.stringify(e)),S._formatSessionForReturn(e)}catch(t){return console.error("Error creating new session: ",t),S._formatSessionForReturn(e)}}else try{return r.lastEvent=t,localStorage.setItem("cj_session_object",JSON.stringify(r)),S._formatSessionForReturn(r)}catch(e){return console.error("Error updating session: ",e),S._formatSessionForReturn(r)}}else try{const e=S._generateLocalSessionObject(S._generateSessionId(),t,t,1);return localStorage.setItem("cj_session_object",JSON.stringify(e)),S._formatSessionForReturn(e)}catch(e){console.error("Error creating new session: ",e);const r=S._generateLocalSessionObject(S._generateSessionId(),t,t,1);return S._formatSessionForReturn(r)}}},A={PAGELOAD:0,FIRST_INTERACTION:0};async function E(e,t){try{const r=function(e,t){const r=window?.navigator,s=window?.screen,c=S.getSessionData();return{eventUuid:b(),recaptcha:{token:e,action:t},appState:{deeAppStateUuid:window?._BBY_DATA_?.appState?.uuid,previousName:window?._BBY_DATA_?.appState?.previousName,previousUuid:window?._BBY_DATA_?.appState?.previousUuid,referrerUrl:document?.referrer?document.referrer:""},source:{viewType:g(i)||"NA",userAgent:r?.userAgent},device:{screenHeight:s?.height?parseInt(window.screen.height):0,screenWidth:s?.width?parseInt(window.screen.width):0,orientation:s?.orientation?.type,timeZone:f(),time:w(),connectionDownlink:r?.connection?.downlink?parseInt(window.navigator.connection.downlink):void 0,connectionEffectiveType:r?.connection?.effectiveType},browser:{height:window.innerHeight,width:window.innerWidth,isCookiesDisabled:!r?.cookieEnabled,language:r?.language,title:document?.title,url:window?.location?.href,pathName:window?.location?.pathname,queryParams:window?.location?.search,hash:window?.location?.hash},identities:{visitorId:g(n)?g(n):void 0,userId:g(o)?g(o):void 0,partyId:g(a)?g(a):void 0},session:{id:c?.sessionId}}}(e,t),s={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)},c=await window.fetch("/cj-recaptcha/v1/submit",s);c.ok||y("CJ: reCAPTCHA sendDataToRCVR",{name:c.status,message:"Non 200 response from cj-recaptcha"})}catch(e){y("CJ: reCAPTCHA sendDataToRCVR",{name:e.name,message:e.message})}}async function I(t){try{const r=await function(t){return"function"==typeof window?.grecaptcha?.enterprise?.ready?new Promise((r,n)=>{window.grecaptcha.enterprise.ready(async()=>{try{const n=await window.grecaptcha.enterprise.execute(e,{action:t});r(n)}catch(e){y("CJ: reCAPTCHA getRecaptchaToken",{name:e.name,message:e.message}),n(e)}})}):null}(t);r&&await E(r,t)}catch(e){y("CJ: reCAPTCHA processRecaptchaAction",{name:e.name,message:e.message})}}function C(e,r){try{const n=JSON.parse(sessionStorage.getItem(t)||"{}");return n[e]<r&&(n[e]+=1,sessionStorage.setItem(t,JSON.stringify(n)),!0)}catch(e){return y("CJ: reCAPTCHA processActionCount",{name:e.name,message:e.message}),!1}}async function N(e=!1){if("function"==typeof window?.grecaptcha?.enterprise?.ready)try{sessionStorage.getItem(t)||sessionStorage.setItem(t,JSON.stringify(A)),C("PAGELOAD",3)&&await I("PAGELOAD"),e||window.addEventListener("click",async e=>{const t=e.target.closest("button, a");t&&("add-to-cart"===t.getAttribute("data-test-id")||"ADD_TO_CART"===t.getAttribute("data-button-state")||t.getAttribute("data-testid")?.includes("add-to-cart")||"add to cart"===t.innerText?.trim().toLowerCase()?(await I("ATC"),C("FIRST_INT
1ERACTION",3)):C("FIRST_INTERACTION",3)&&await I("FIRST_INTERACTION"))},!0)}catch(e){y("CJ: reCAPTCHA",{name:e.name,message:e.message})}}function T(e=!1){const t="cj-recaptcha-badge-style";if(!document.getElementById(t)){const e=document.createElement("style");e.id=t,e.textContent=".grecaptcha-badge { display: none !important; }",document.head.insertAdjacentElement("afterend",e)}window?.grecaptcha?.enterprise?N(e):"complete"===document.readyState?setTimeout(()=>{N(e)},0):window.addEventListener("load",()=>{setTimeout(()=>{N(e)},0)})}const D="cjcDataLayers",x="cj_session_object",$="events",P={contract:[]},L=["load","launch","interaction","impression"],O=["interaction","impression","launch"],U={batchSize:3,waitTime:1e3,retentionTime:14,eventTypes:[],schemaNames:[]},j={environments:{dotcom_prod:{esasBasePath:"https://streams.bestbuy.com",esasAuthNeeded:!1},dotcom_stage:{esasBasePath:"https://streams.stage.bestbuy.com",esasAuthNeeded:!0},dotcom_test:{esasBasePath:"https://streams.test.bestbuy.com",esasAuthNeeded:!0},dotcom_develop:{esasBasePath:"https://streams.test.bestbuy.com",esasAuthNeeded:!0},app_release:{esasBasePath:"https://streams.bestbuy.com",esasAuthNeeded:!1},app_debug:{esasBasePath:"https://streams.stage.bestbuy.com",esasAuthNeeded:!0}}},_="CJ: SDK";function k(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function B(e,t,r){if(!e||"object"!=typeof e)throw new Error(`${r}: contract object must be provided`);if(!Object.prototype.hasOwnProperty.call(e,"id")||!Object.prototype.hasOwnProperty.call(e,"version"))throw new Error(`${r}: contractObj must have id and version properties`);if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(`${r}: data object must be provided`)}function R(e,t){if(null==e)throw new Error(`${t}: name is required`);if("string"!=typeof e||""===e.trim())throw new Error(`${t}: name must be a non-empty string`)}function F(e,t){if(void 0===e)throw new Error(`${t}: data object is required`);if("object"!=typeof e||null===e||Array.isArray(e))throw new Error(`${t}: data object must be a non-null object`)}function M(e,t){if(void 0===e)throw new Error(`${t}: limit must be set`);if("number"!=typeof e)throw new Error(`${t}: limit must be an integer`)}function J(e,t){if(!Array.isArray(e))throw new Error(`${t} must be an array`);if(0!==e.length)for(let r=0;r<e.length;r++){const n=e[r];if("string"!=typeof n)throw new Error(`${t} array must contain only strings`);const o=n.trim();if(0===o.length)throw new Error(`${t} array must contain only non-empty strings`);if("eventTypes"===t&&!L.includes(o))throw new Error(`${t} contains invalid event type: ${o}`)}}function V(e,t){if(void 0===e)throw new Error(`${t}: name must be set`);if("string"!=typeof e)throw new Error(`${t}: name must be a string`)}function q(e,t){if(void 0===e)throw new Error(`${t}: value must be set`);if("object"!=typeof e||null===e)throw new Error(`${t}: value must be an object`)}let W=class{constructor(e){this.severity=e}log(e,t){if(function(e,t){if(null==t||!Number.isInteger(t))throw new Error("CJ Logger: level must be set and must be an integer");if(null==e||!Number.isInteger(e))throw new Error("CJ Logger: severity must be set and must be an integer");if(e<1||e>5||t<1||t>5)throw new Error(`CJ Logger: ${e<1||e>5?"severity":"level"} must be between 1 and 5`)}(this.severity,t),t<=this.severity)return{details:e,level:t}}},z=class{constructor(e=5){this.untypedListeners=[],this.typedListeners=new Map,this.logger=new W(e)}subscribe(e,t,r){if("function"!=typeof e)return;const n={fn:e,meta:t,type:r};if("string"==typeof r&&r.length>0){const e=this.typedListeners.get(r);return e?void e.push(n):void this.typedListeners.set(r,[n])}this.untypedListeners.push(n)}unsubscribe(e){this.untypedListeners=this.untypedListeners.filter(t=>t.fn!==e);for(const[t,r]of this.typedListeners.entries()){const n=r.filter(t=>t.fn!==e);0!==n.length?n.length!==r.length&&this.typedListeners.set(t,n):this.typedListeners.delete(t)}}log(e,t=5){const r=`${_} ${e}`;if(!this.logger.log(r,t))return;const n={details:r,level:t};return this.notify(n),n}notify(e,t){const r=t?this.typedListeners.get(t):this.untypedListeners;if(r&&0!==r.length)for(let t=0;t<r.length;t++){const{fn:n,meta:o}=r[t];try{if(void 0===o){n(e);continue}n(Object.assign({},e,{meta:o}))}catch(e){console.error(`${_} | Logger: notify error`,e)}}}},H=new z(5);function G(e=5){return H=new z(e),H}const Z={subscribe:(e,t,r)=>H.subscribe(e,t,r),unsubscribe:e=>H.unsubscribe(e),notify:(e,t)=>H.notify(e,t),fatal:e=>H.log(e,1),error:e=>H.log(e,2),warn:e=>H.log(e,3),info:e=>H.log(e,4),debug:e=>H.log(e,5)};function Y(e){return(e?new Date(e):new Date).toISOString()}let K=class{constructor(e={}){const{timeoutDuration:t=18e5,maxSessionDuration:r=864e5}=e;this.timeoutDuration=t,this.maxSessionDuration=r,this.session=this.createStorage()}createStorage(){const e="createStorage must be implemented by subclass";throw Z.error(e),new Error(e)}get(){return this.session.getSync(x)}set(){try{const e=this.get(),t=Y(),r=k(),n="web"===this.platform?e?.startTimestamp:e?.sessionStart;if(!e||!e?.startTimestamp||!e?.sessionStart){const e={lastEvent:t,sessionCount:1,sessionId:r,startTimestamp:t,sessionStart:t,sessionUuid:r};return void this.session.setSync(x,e)}const o=Date.now()-new Date(n).getTime();if(o>this.timeoutDuration||o>this.maxSessionDuration){const t=Y(),r=k();e.lastEvent=t,e.sessionCount+=1,e.startTimestamp=t,e.sessionId=r,e.sessionStart=t,e.sessionUuid=r}else e.startTimestamp&&!e.sessionStart&&(e.sessionStart=e.startTimestamp),e.sessionId&&!e.sessionUuid&&(e.sessionUuid=e.sessionId),e.sessionStart&&!e.startTimestamp&&(e.startTimestamp=e.sessionStart),e.sessionUuid&&!e.sessionId&&(e.sessionId=e.sessionUuid),e.lastEvent=Y();this.session.setSync(x,e)}catch(e){throw Z.warn(`Failed to update session data: ${e.message}`),e}}};function Q(e=[],t){e&&Array.isArray(e)||(e=[]);for(let r=0;r<e.length;r++){const n=e[r];if(n?.eventUuid===t)return{index:r,event:n}}return{index:-1,event:null}}let X=class{constructor(e){this.adapter=e}get(e){return(void 0!==e?this.adapter.read(e):this.adapter.read()).then(t=>{if(!t)return e===D?[]:{};if("string"==typeof t)try{return JSON.parse(t)}catch(e){return Promise.reject(e)}return t})}set(e,t){return 1===arguments.length?this.adapter.write(e):this.adapter.write(e,t)}remove(e){return this.adapter.remove(e)}claimPendingEvents(e,t,r){return"function"==typeof this.adapter.claimPendingEvents?this.adapter.claimPendingEvents(e,t,r):this.get(e)}releaseInFlightClaims(e,t){return"function"==typeof this.adapter.releaseInFlightClaims?this.adapter.releaseInFlightClaims(e,t):Promise.resolve()}getByEventUuid(e){return void 0===e?Promise.reject(new Error("getByEventUuid: key must be set")):"string"!=typeof e?Promise.reject(new Error("getByEventUuid: key must be a string")):this.adapter.readEventUuid(e).then(t=>{if(!t)return null;try{const r="string"==typeof t?JSON.parse(t):t,{event:n}=Q(r,e);return n||null}catch(e){return Promise.reject(e)}})}},ee=class extends X{constructor(e="sessionStorage"){const t="cjcStorage";super({read:r=>new Promise((n,o)=>{V(r,t);const a=window[e].getItem(r);n(a?JSON.parse(a):null)}),write:(r,n)=>new Promise((o,a)=>{try{V(r,t),q(n,t),window[e].setItem(r,JSON.stringify(n)),o()}catch(e){a(e)}})}
1),this.getSync=r=>{V(r,t);const n=window[e].getItem(r);return n?JSON.parse(n):null},this.setSync=(r,n)=>{V(r,t),q(n,t),window[e].setItem(r,JSON.stringify(n))}}},te=class extends K{constructor(e={}){super(e),this.platform="web"}createStorage(){return new ee("localStorage")}};function re(e,t){if(e||(e={}),!t)return e;if(JSON.stringify(e)===JSON.stringify(t))return e;const r=e=>(e=>!!e&&"object"==typeof e)(e)&&!(e=>{const t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t})(e),n=(e,t)=>{return!1!==t.clone&&r(e)?i((n=e,Array.isArray(n)?[]:{}),e,t):e;var n},o=e=>{const t=Object.keys(e);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(let n=0;n<r.length;n++)Object.prototype.propertyIsEnumerable.call(e,r[n])&&t.push(r[n])}return t},a=(e,t)=>t in e&&!(Object.hasOwnProperty.call(e,t)&&Object.prototype.propertyIsEnumerable.call(e,t)),s=(e,t,r)=>{const s={};if(r.isMergeableObject(e)){const t=o(e);for(let o=0;o<t.length;o++){const a=t[o];s[a]=n(e[a],r)}}if(r.isMergeableObject(t)){const c=o(t);for(let o=0;o<c.length;o++){const d=c[o];a(e,d)||(d in e&&r.isMergeableObject(t[d])&&r.isMergeableObject(e[d])?s[d]=i(e[d],t[d],r):s[d]=n(t[d],r))}}return s};function i(e,t,r={}){const o=Array.isArray(t);return o!==Array.isArray(e)?n(t,r):o?r.arrayMerge(e,t,r):s(e,t,r)}return i(e,t,{arrayMerge:(e,t,r)=>{const o=e.slice();for(let e=0;e<t.length;e++)o.push(n(t[e],r));return o},isMergeableObject:r,cloneUnlessOtherwiseSpecified:n})}function ne(e=[],t){for(let r=0;r<e.length;r++){const n=e[r];if(Object.hasOwnProperty.call(n,t))return{index:r,dataLayer:n[t]}}return{index:-1,dataLayer:null}}const oe="contextLifecycle",ae="contextReady",se="READY",ie="CJ: context lifecycle update",ce=new Map;function de(e){const t=ce.get(e);if(t)return t;const r={state:"UNINITIALIZED",cycle:0,readyEventCycle:0,updatedAt:Date.now()};return ce.set(e,r),r}function ue(e,t){R(e,"contextLifecycle.transitionState");const r=de(e);return r.state=t,r.updatedAt=Date.now(),r}function le(e,t,r,n){return{details:ie,contextName:e,dataLayerName:e,state:t.state,cycle:t.cycle,eventType:n,source:r,timestamp:Date.now()}}function he(e,t,r="unknown",n){const o=le(e,t,r,n);return Z.notify(o,oe),o}function pe(e,t="unknown"){const r=de(e);return 0===r.cycle&&(r.cycle=1),r.state=se,r.updatedAt=Date.now(),r.readyEventCycle===r.cycle?(he(e,r,t),le(e,r,t,ae)):(r.readyEventCycle=r.cycle,he(e,r,t),he(e,r,t,ae))}function me(e){R(e,"contextLifecycle.getContextLifecycleState");const t=de(e);return{state:t.state,cycle:t.cycle,readyEventCycle:t.readyEventCycle,updatedAt:t.updatedAt}}function ge(e){return R(e,"contextLifecycle.isContextReady"),de(e).state===se}function ye(e,t,r={}){if(R(e,"contextLifecycle.onContextReady"),"function"!=typeof t)throw new Error("contextLifecycle.onContextReady: listener must be a function");const n=!1!==r.once;let o=!1;const a=r=>{r&&r.contextName===e&&r.eventType===ae&&(t(r),n&&(Z.unsubscribe(a),o=!0))};return Z.subscribe(a,void 0,oe),ge(e)&&Promise.resolve().then(()=>{if(o)return;const t=me(e);a({details:ie,contextName:e,dataLayerName:e,state:t.state,cycle:t.cycle,eventType:ae,source:"state-check",timestamp:Date.now()})}),()=>{o=!0,Z.unsubscribe(a)}}function we(e,t={}){R(e,"contextLifecycle.waitForContextReady");const r=Number.isFinite(t.timeoutMs)?t.timeoutMs:5e3,n=Number.isFinite(t.pollMs)?t.pollMs:50,o="function"==typeof t.readinessCheck?t.readinessCheck:null;if(ge(e)){const t=me(e);return Promise.resolve({details:ie,contextName:e,dataLayerName:e,state:t.state,cycle:t.cycle,eventType:ae,source:"state-check",timestamp:Date.now()})}return new Promise((t,a)=>{let s=!1,i=null,c=null,d=null;const u=()=>{i&&clearTimeout(i),c&&clearTimeout(c),"function"==typeof d&&d()},l=e=>{s||(s=!0,u(),t(e))};if(d=ye(e,l),o){const t=()=>{s||(o(e)?l(pe(e,"readiness-check")):c=setTimeout(t,n))};t()}i=setTimeout(()=>{s||(s=!0,u(),a(new Error(`Timed out waiting for context '${e}'`)))},r)})}const fe="dataLayerSettled",ve=new Map,be=new ee;function Se(e){const t=ve.get(e);return Number.isInteger(t)&&t>0?t:0}function Ae(e,t){return{details:"CJ: sdk ready",dataLayerName:e,ready:!0,source:t,timestamp:Date.now()}}function Ee(e,t){return{details:"CJ: sdk settled",dataLayerName:e,settled:!0,source:t,timestamp:Date.now()}}function Ie(e){return R(e,"sdkReady.isDataLayerReady"),!!ge(e)||!!function(e){const t=be.getSync(D);if(!Array.isArray(t))return null;const{dataLayer:r}=ne(t,e);return r||null}(e)&&(pe(e,"storage-check"),!0)}function Ce(e,t="unknown"){R(e,"sdkReady.emitDataLayerReady"),pe(e,t),Z.notify(Ae(e,t),"dataLayerReady")}function Ne(e){return R(e,"sdkReady.isDataLayerSettled"),Ie(e)&&0===Se(e)}function Te(e,t,r){if("function"!=typeof r)throw new Error("sdkReady.runWithDataLayerMutation: callback must be a function");const n=function(e,t="unknown"){R(e,"sdkReady.beginDataLayerMutation");const r=Se(e);ve.set(e,r+1);let n=!1;return()=>{if(n)return;n=!0;const r=Se(e);if(r<=1)return ve.delete(e),void(Ie(e)&&function(e,t="unknown"){R(e,"sdkReady.emitDataLayerSettled"),Z.notify(Ee(e,t),fe)}(e,t));ve.set(e,r-1)}}(e,t);try{const e=r();return e&&"function"==typeof e.then?e.finally(n):(n(),e)}catch(e){throw n(),e}}function De(e,t={}){R(e,"sdkReady.waitForDataLayerReady");const r=Number.isFinite(t.timeoutMs)?t.timeoutMs:5e3,n=Number.isFinite(t.pollMs)?t.pollMs:50;return we(e,{timeoutMs:r,pollMs:n,readinessCheck:Ie}).then(t=>Ae(e,t?.source||"context-lifecycle")).catch(t=>{if(t?.message===`Timed out waiting for context '${e}'`)throw new Error(`Timed out waiting for data layer '${e}'`);throw t})}function xe(e,t={}){R(e,"sdkReady.waitForDataLayerSettled");const r=Number.isFinite(t.timeoutMs)?t.timeoutMs:5e3,n=Number.isFinite(t.pollMs)?t.pollMs:50;return De(e,{timeoutMs:r,pollMs:n}).then(()=>Ne(e)?Ee(e,"state-check"):new Promise((t,o)=>{let a=!1,s=null,i=null,c=null;const d=()=>{s&&clearTimeout(s),i&&clearTimeout(i),"function"==typeof c&&c()},u=e=>{a||(a=!0,d(),t(e))};c=function(e,t,r={}){if(R(e,"sdkReady.onDataLayerSettled"),"function"!=typeof t)throw new Error("sdkReady.onDataLayerSettled: listener must be a function");const n=!1!==r.once;let o=!1;const a=r=>{r&&r.dataLayerName===e&&(t(r),n&&(Z.unsubscribe(a),o=!0))};return Z.subscribe(a,void 0,fe),Ne(e)&&Promise.resolve().then(()=>{o||a(Ee(e,"state-check"))}),()=>{o=!0,Z.unsubscribe(a)}}(e,u);const l=()=>{a||(Ne(e)?u(Ee(e,"state-check")):i=setTimeout(l,n))};l(),s=setTimeout(()=>{a||(a=!0,d(),o(new Error(`Timed out waiting for data layer '${e}' to settle`)))},r)}))}class $e{constructor(){this.storage=new ee}getDataLayer(e){R(e,"dataLayerManager.get");try{const t=this.storage.getSync(D);if(!t)return;const{dataLayer:r}=ne(t,e);return r||void Z.error(`Data layer not found: ${e}`)}catch(e){const t=`Failed to get data layer: ${e.message}`;throw Z.error(t),new Error(t)}}get(e){const t=this.getDataLayer(e);return t?.payload?t.payload:null}merge(e,t){R(e,"dataLayerManager.merge"),F(t,"dataLayerManager.merge");try{const r=this.get(e),n=re(r&&"object"==typeof r?r:{},t);return this.set(e,n)}catch(e){const t="Failed to merge data layer";throw Z.error(`${t}: ${e.message}`),new Error(t,{cause:e})}}set(e,t){R(e,"dataLayerManager.set"),F(t,"dataLayerManager.set");try{const r=this.storage.getSync(D),{index:n,dataLayer:o}=ne(r,e);if(!o)return void Z.error(`Data layer not found: ${e}`);const a={protected:o.protected,payload:t};return r.splice(n,1,{[e]:a}),this.storage.setSync(D,r),{[e]:a}}catch(e){const t=`Failed to set data layer: ${e.message}`;throw Z.error(t),new Error(t)}}reset(e){return R(e,"dataLayerManager.reset"),Te(e,"dataLayerManager.reset",()=>{try{const t=this.storage.getSync(D);if(!t)return;const{index:r,dataLayer:n}=ne(t,e);if(!n)return void Z.error(`Data layer not found: ${e}`);t.splice(r,1,{[e]:{...n,payload:P}}),this.storage.setSync(D,t)}catch(t){const r=`Failed to reset data layer '${e}': ${t.message}`;throw Z.error(r),new Error(r)}})}}const Pe=(e,t,r,n)=>{const o="eventComposer";R(e,o),function(e,t){if(null==e)throw new Error(`${t}: eventType is required`);if("string"!=typeof e||""===e.trim())throw new Error(`${t}: eventType must be a non-empty string`)}(t,o);const a=new te,s=(new $e).getDataLayer(e);a.set();const i=a.get();let c=s?.protected&&s?.payload?re({},{...s?.payload}):{};O.includes(t)&&(n&&(c=re(c,n)),r&&(c=re(c,{contract:[r]}))),c=re(c,{eventUuid:k(),batch:{captured:0,eventCreationTime:Y()},application:{source:"cj-capture-sdk",version:"2.1.0"}});const d=re(c,{...s?.protected,session:{id:i.sessionUuid,startTimestamp:Y(i.sessionStart),sessionCount:i.sessionCount}});return t&&(d.event=d.event||{},d.event.type=t),Z.debug(`${o}: Composed event of type "${t}" for data layer "${e}"; eventUuid: ${d.eventUuid}`),Promise.resolve(d)};function Le(){return new Promise((e,t)=>
1{const r=indexedDB.open("cjcEvents",1);r.onupgradeneeded=e=>{const t=e.target.result;let n;n=t.objectStoreNames.contains($)?r.transaction.objectStore($):t.createObjectStore($,{keyPath:"eventUuid"}),n.indexNames.contains("batch.eventCreationTime")||n.createIndex("batch.eventCreationTime","batch.eventCreationTime",{unique:!1}),n.indexNames.contains("batch.captured")||n.createIndex("batch.captured","batch.captured",{unique:!1}),n.indexNames.contains("eventUuid")||n.createIndex("eventUuid","eventUuid",{unique:!0})},r.onsuccess=()=>{e(r.result)},r.onerror=()=>{t(r.error)}})}function Oe(e,t,r){return new Promise((n,o)=>{const a=e.transaction($,"readonly").objectStore($).index(t),s=[],i=a.openCursor(r);i.onsuccess=e=>{const t=e.target.result;t?(s.push(t.value),t.continue()):n(s)},i.onerror=()=>o(i.error)})}class Ue extends X{constructor(){const e=Le(),t="eventStore";super({remove:(e=[])=>this._withDb(r=>new Promise((n,o)=>{if(null===e)return o(new Error(`${t}.remove: eventUuids must be provided`));if("string"==typeof e&&(e=[e]),!Array.isArray(e))return o(new Error(`${t}.remove: eventUuids must be an array`));if(0===e.length)return n();const a=r.transaction($,"readwrite"),s=a.objectStore($);for(let r=0;r<e.length;r++){const n=e[r];if("string"!=typeof n)return o(new Error(`${t}.remove: each eventUuid must be a string`));s.delete(n)}a.oncomplete=()=>n(),a.onerror=()=>o(a.error)})),read:(e=20)=>(M(e,t),this.findByCapturedKey(e).then(e=>e)),readEventUuid:e=>void 0===e?Promise.reject(new Error(`${t}.getUuid: key must be set`)):"string"!=typeof e?Promise.reject(new Error(`${t}.get: key must be a string`)):this.findByEventUuid(e).then(e=>e),write:e=>this._withDb(r=>new Promise((n,o)=>{q(e,t);const a=r.transaction($,"readwrite").objectStore($).put(e);a.onsuccess=()=>n(),a.onerror=()=>o(a.error)})),claimPendingEvents:(e=20,r=500,n="")=>this._withDb(o=>new Promise((a,s)=>{M(e,t);const i=Date.now(),c="string"==typeof n&&n.length>0?n:`owner-${i}-${Math.random().toString(36).slice(2,10)}`,d=o.transaction($,"readwrite"),u=d.objectStore($),l=u.index("batch.captured"),h=[],p=l.openCursor(IDBKeyRange.only(0));let m=!1;p.onsuccess=t=>{const n=t.target.result;if(n){const e=n.value;return((e,t,r)=>{if(0!==e?.batch?.captured)return!1;if(!e?.batch?.inFlight)return!0;const n=(e=>{const t=e?.batch?.inFlightAt;if("number"==typeof t&&Number.isFinite(t))return t;if("string"==typeof t){const e=new Date(t).getTime();if(!Number.isNaN(e))return e}return null})(e);return null!==n&&t-n>=r})(e,i,r)&&h.push(e),void n.continue()}h.sort((e,t)=>{const r=e.batch?.eventCreationTime,n=t.batch?.eventCreationTime;return r||n?r?n?new Date(n).getTime()-new Date(r).getTime():-1:1:0}),(e=>{if(0===e.length)return m=!0,void a([]);let t=e.length;for(let r=0;r<e.length;r++){const n=e[r];n.batch=n.batch||{},n.batch.inFlight=!0,n.batch.inFlightAt=i,n.batch.inFlightOwner=c;const o=u.put(n);o.onsuccess=()=>{t--,0===t&&(m=!0,a(e))},o.onerror=()=>s(o.error)}})(h.slice(0,e))},p.onerror=()=>s(p.error),d.onerror=()=>s(d.error),d.onabort=()=>s(d.error||new Error("Transaction aborted while claiming events")),d.oncomplete=()=>{m||a([])}})),releaseInFlightClaims:(e=[],t="")=>this._withDb(r=>new Promise((n,o)=>{if("string"==typeof e&&(e=[e]),!Array.isArray(e)||0===e.length)return void n();const a=new Set(e),s="string"==typeof t&&t.length>0,i=r.transaction($,"readwrite"),c=i.objectStore($);let d=0,u=!1;const l=()=>{u&&0===d&&n()},h=c.openCursor();h.onsuccess=e=>{const r=e.target.result;if(r){const e=r.value;if(a.has(e?.eventUuid)&&(e.batch=e.batch||{},!s||!e.batch.inFlightOwner||e.batch.inFlightOwner===t)){e.batch.inFlight=!1,delete e.batch.inFlightAt,delete e.batch.inFlightOwner,d++;const t=c.put(e);t.onsuccess=()=>{d--,l()},t.onerror=()=>o(t.error)}return void r.continue()}u=!0,l()},h.onerror=()=>o(h.error),i.onerror=()=>o(i.error),i.onabort=()=>o(i.error||new Error("Transaction aborted while releasing in-flight events"))}))}),this.platform="web",this.type="indexeddb",this._dbPromise=e,e.then(e=>{e.onversionchange=()=>{try{e.close(),this._dbPromise=null}catch(e){Z.error(`Failed to close DB on version change: ${e.message}`)}}})}_withDb(e){return this._dbPromise||(this._dbPromise=Le().then(e=>(e.onversionchange=()=>{try{e.close(),this._dbPromise=null}catch(e){Z.warn(`Failed to close DB on version change: ${e.message}`)}},e))),this._dbPromise.then(t=>e(t))}findByEventCreationTime(e){return this._withDb(t=>Oe(t,"batch.eventCreationTime",e))}findByCapturedKey(e=20){return this._withDb(e=>Oe(e,"batch.captured",IDBKeyRange.only(0))).then(t=>Array.isArray(t)&&0!==t.length?(t.sort((e,t)=>
1{const r=e.batch?.eventCreationTime,n=t.batch?.eventCreationTime;return r||n?r?n?new Date(n).getTime()-new Date(r).getTime():-1:1:0}),t.slice(0,e)):[])}findByEventUuid(e){return this._withDb(t=>Oe(t,"eventUuid",e))}getEvents(){return this._withDb(e=>new Promise((t,r)=>{try{const n=e.transaction($,"readonly"),o=n.objectStore($);if("function"==typeof o.getAll){const e=o.getAll();e.onsuccess=()=>t(e.result||[]),e.onerror=()=>r(e.error)}else{const e=[],n=o.openCursor();n.onsuccess=r=>{const n=r.target.result;n?(e.push(n.value),n.continue()):t(e)},n.onerror=()=>r(n.error)}n.onabort=()=>r(n.error||new Error("Transaction aborted while reading events"))}catch(e){r(e)}}))}getUncapturedEvents(){return this.getEvents().then(e=>{const t=function(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];0===n?.batch?.captured&&t.push(n)}return t}(e);return t}).catch(e=>Promise.reject(e))}close(){return this._dbPromise?this._dbPromise.then(e=>{try{e.close()}catch(e){Z.error(`Failed to close DB connection: ${e.message}`)}this._dbPromise=null}):Promise.resolve()}}const je=new Set,_e=e=>!!e&&je.delete(e),ke=(e,t=14)=>{const r=864e5*t,n=2*r;let o;return o="app"===e.platform?new Promise((t,r)=>{try{const{events:r}=e.getEvents();t(r)}catch(e){r(e)}}):e.getEvents(),o.then(t=>{if(!Array.isArray(t))return Z.error("Event Store Manager Garbage Collect: No events found in store"),{deleted:0,garbageArray:[]};const o=[];for(let e=0;e<t.length;e++){const a=t[e];if(!a?.batch)continue;const s=a.batch.eventCreationTime;let i=new Date(s).getTime();Number.isNaN(i)&&(i="number"==typeof s?s:Date.now());const c=a.batch.captured,d=Date.now()-i;(d>=r&&(1===c||2===c)||d>=n&&0===c)&&o.push(a.eventUuid)}if(0===o.length)return{deleted:0,garbageArray:[]};const a=e.remove?.bind(e);return(a?a(o):Promise.reject(new Error("No delete implementation available on store"))).then(()=>({deleted:o.length,garbageArray:o})).catch(e=>(Z.error(`Event Store Manager Garbage Collect: Failed to delete events: ${e.message}`),{deleted:0,garbageArray:[]}))}).catch(e=>(Z.error(`Event Store Manager Garbage Collect: Failed to read events: ${e.message}`),{deleted:0,garbageArray:[]}))},Be=e=>{e.batch=e.batch||{},e.batch.inFlight=!1,delete e.batch.inFlightAt,delete e.batch.inFlightOwner},Re=new ee,Fe=()=>{const e=Re.getSync("cjcEnvironmentOverride");return{isLowerEnvironment:e?.isLowerEnvironment,userAgentOverride:e?.userAgentOverride}};function Me(e){if(!e||"object"!=typeof e)return e;if(!e.batch||"object"!=typeof e.batch)return e;const t={...e.batch};return delete t.inFlight,delete t.inFlightAt,delete t.inFlightOwner,{...e,batch:t}}function Je(e){if(!Array.isArray(e)||0===e.length)return k();const t=[];for(let r=0;r<e.length;r++){const n=e[r]?.eventUuid;"string"==typeof n&&n.length>0&&t.push(n)}if(0===t.length)return k();t.sort();const r=t.join("|");let n=5381;for(let e=0;e<r.length;e++)n=33*n^r.charCodeAt(e);return`batch-${(n>>>0).toString(16)}-${t.length}`}function Ve(e,t,r){!function(e,t,r){if(!r&&!t)throw new Error("No event data provided");if(!e||"string"!=typeof e)throw new Error("No event type provided");if("single"!==e&&"batch"!==e)throw new Error("Invalid event type");if("single"===e&&!t)throw new Error("No event provided for single event type");if("batch"===e&&!r)throw new Error("No events provided for batch event type")}(e,t,r);const n=navigator?.userAgent,{userAgentOverride:o}=Fe(),a=((e,t)=>{const r=e=>new RegExp(`(BestBuy/|Bby-Android/).*[a-zA-Z0-9].(${e})`),n=r("APPSTORE"),o=r("PROD"),a=r("CDC"),s=r("MAN_TEST"),i=r("STAGE"),c=r("PREVIEW"),d=r("SFT"),u=Fe(),l=e||u?.userAgentOverride;let h="dotcom_develop";switch(Z.debug(`Determining environment with User-Agent: ${l} and Hostname: ${t}; ${JSON.stringify(u)}`),!0){case a.test(l)||s.test(l)||i.test(l)||c.test(l)||d.test(l)||(e=>/^(?:BestBuy\/|Bby-Android\/)/.test(e||navigator?.userAgent))(l)&&u?.isLowerEnvironment:h="app_debug";break;case n.test(l)||o.test(l):h="app_release";break;case"www.bestbuy.com"===t:h="dotcom_prod";break;case"www.stage.bestbuy.com"===t:h="dotcom_stage";break;case"www.test.bestbuy.com"===t:h="dotcom_test"}return h})(o||n,window?.location?.hostname);n||o||Z.warn("send: navigator.userAgent and userAgentOverride are both empty; using default environment resolution");let s={},i=j.environments[a].esasBasePath;"single"===e?(i+=`/customer/web-streams/v1/events/${t?.application?.schemaName}`,s=Me(t)):"batch"===e&&(i+="/customer/web-streams/v1/batch",s=Array.isArray(r)?r.map(e=>Me(e)):r),s=JSON.stringify(s);const c={method:"POST",headers:{"Content-type":"application/json","Idempotency-Key":"single"===e?t?.eventUuid:Je(r)},maxRedirects:10,redirect:"follow",body:s};o&&(c.headers["User-Agent"]=o);const d=new AbortController;c.signal=d.signal;const u=setTimeout(()=>{d.abort()},3e3);return fetch(i,c).then(t=>t?function(e,t,r){const n="eventStoreManager",o=new Ue;return e?.ok?Promise.all([e.json(),o.get()]).then(async([a,s])=>
1{if(200===e?.status){if(!a?.results||!Array.isArray(a.results)){await ke(o,r);return void Z.error(`${n} Error: Response JSON did not contain results array`)}const e=[];for(let t=0;t<a.results.length;t++){const r=a.results[t];if("SUCCESS"!==r?.status)continue;const{event:n}=Q(s,r?.eventUuid);n&&(n.batch=n.batch||{},n.batch.captured?0===n.batch.captured?n.batch.captured=1:2===n.batch.captured?n.batch.captured=2:n.batch.captured=1:n.batch.captured=1,Be(n),e.push(o.set(n)))}return await Promise.all(e),void await ke(o,r)}if([404,408,409,425,429].includes(e.status)||e.status>=500&&e.status<=599){if("batch"===t)return;if(!a?.results||!Array.isArray(a.results)){const e=`${n} 4xx Error: Response JSON did not contain results array`;throw Z.error(e),new Error(e)}const e=a?.results?.[0],i=e?.eventUuid,{event:c}=Q(s,i);return c&&(c.batch=c.batch||{},c.batch.captured=0,Be(c),await o.set(c)),void await ke(o,r)}if([400,401,403,413,415].includes(e.status)){if("single"===t)return;if(!a?.results||!Array.isArray(a.results)){const e=`${n} 4xx Error: Response JSON did not contain results array`;throw Z.error(e),new Error(e)}const e=[];for(let t=0;t<a.results.length;t++){const r=a.results[t],n=r?.eventUuid,{event:i}=Q(s,n);if(i){switch(i.batch=i.batch||{},r.status){case"FAILED":i.batch.captured=2;break;case"SUCCESS":i.batch.captured=1;break;default:i.batch.captured=0}Be(i),e.push(o.set(i))}}await Promise.all(e),await ke(o,r)}}).catch(e=>{const t=`${n} Error: Failed to process response JSON or update event store: ${e.message}`;Z.error(t)}):Promise.resolve()}(t,e):Promise.reject(new Error("send: No response received from fetch"))).finally(()=>{clearTimeout(u)}).catch(e=>{throw Z.error(`cj-capture-sdk error name: ${e.name}, message: ${e.message}`),e})}let qe;const We=(e={})=>{const t=new Ue;let{batchSize:r,waitTime:n}=e;const{eventTypes:o,schemaNames:a}=e,s=Array.isArray(o)?o:[],i=Array.isArray(a)?a:[],c=parseInt(r,10);r=isNaN(c)?3:c;const d=r<1?1:r,u=parseInt(n,10);n=isNaN(u)?1e3:u;const l=`event-batcher-${Math.random().toString(36).slice(2,10)}`,h=e=>{if(!Array.isArray(e)||0===e.length)return Promise.resolve();if("function"!=typeof t.releaseInFlightClaims)return Promise.resolve();const r=[];for(let t=0;t<e.length;t++)e[t]?.eventUuid&&r.push(e[t].eventUuid);return 0===r.length?Promise.resolve():t.releaseInFlightClaims(r,l).catch(e=>{Z.error(`eventBatcher: failed to release persistent in-flight claims: ${e.message}`)})};return("function"==typeof t.claimPendingEvents?t.claimPendingEvents(d,500,l):t.get(d)).then(e=>{if(!Array.isArray(e)||0===e.length)return;const t=[];for(let r=0;r<e.length;r++){const n=e[r];n.eventUuid&&!je.has(n.eventUuid)&&t.push(n)}if(0===(e=t).length)return;const o=e.length,a=Date.now();"number"!=typeof qe&&(qe=a);const c=a-qe,d=s.length>0||i.length>0?e.find(e=>{const t=e?.event?.type,r=e?.application?.schemaName,n=s.length>0&&"string"==typeof t&&s.includes(t),o=i.length>0&&"string"==typeof r&&i.includes(r);return n||o}):null,u=o>=r,l=c>=n,p=Boolean(d);if(u||l||p){const t=u||l,r=t?1===o?"single":"batch":"single",n=t?1===o?e[0]:null:d,a=t&&o>1?e:null;if(!n&&!a)return h(e);const s=a||[n],i=new Set(s.map(e=>e?.eventUuid).filter(Boolean)),c=e.filter(e=>e?.eventUuid&&!i.has(e.eventUuid));for(let e=0;e<s.length;e++)je.add(s[e].eventUuid);const p=()=>{for(let e=0;e<s.length;e++)je.delete(s[e].eventUuid)};return h(c).then(()=>Ve(r,n,a)).then(()=>(qe=void 0,h(s).then(()=>{p()}))).catch(e=>h(s).then(()=>{p();const t=`eventBatcher: error sending events: ${e.message}`;throw Z.error(t),new Error(t)}))}return h(e)}).catch(e=>Promise.reject(e))},ze=(e,t)=>{F(e,"eventQueue"),t.eventType=e?.event?.type||"unknown";const{batchSize:r,waitTime:n,eventTypes:o,schemaNames:a}=t,{type:s}=e.event||{},i=new Ue;return 0===r||0===n||o&&Array.isArray(o)&&s&&o.includes(s)||a&&Array.isArray(a)&&e?.application?.schemaName&&a.includes(e.application.schemaName)?(e?.eventUuid&&(c=e.eventUuid)&&!je.has(c)&&je.add(c),i.set(e).then(()=>Ve("single",e)).then(t=>(e?.eventUuid&&_e(e.eventUuid),t)).catch(t=>{e?.eventUuid&&_e(e.eventUuid),Z.error(`eventQueue: error storing event or processing batch: ${t.message}`)})):i.set(e).then(()=>{e?.batch?(void 0===e.batch.eventCreationTime&&(e.batch.eventCreationTime=Y()),void 0===e.batch.captured&&(e.batch.captured=0)):e.batch={eventCreationTime:Y(),captured:0},We(t)}).catch(e=>{Z.error(`eventQueue: error storing event or processing batch: ${e.message}`)});var c};let He=!1,Ge=null;function Ze(e=U.batchSize,t=U.waitTime,r=U.retentionTime,n=U.eventTypes,o=U.schemaNames){if
1(He)return Ge;!function(e,t,r,n,o){if(!Number.isInteger(e)||e<0||e>20)throw new Error("BatchSize must be non-negative integer and cannot exceed 20");if(!Number.isInteger(t)||t<0||t>1e4)throw new Error("WaitTime must be a non-negative integer and cannot exceed 10000ms");if(!Number.isInteger(r)||r<1||r>30)throw new Error("RetentionTime must be a positive integer and cannot exceed 30 days");J(n,"eventTypes"),J(o,"schemaNames")}(e,t,r,n,o);const a=Array.isArray(n)?n:[],s=Array.isArray(o)?o:[];return Ge=Object.freeze({batchSize:e,waitTime:t,retentionTime:r,eventTypes:a,schemaNames:s}),He=!0,Ge}function Ye(e){let t=U;try{const e=Ze();t=e&&"object"==typeof e?re(U,e):U}catch(r){Z.error(`${e}: error configuring event batcher: ${r.message}`),t=U}return t}const Ke=(e,t,r={},n={})=>{const o={impression:"sendImpression",interaction:"sendInteraction",launch:"sendLaunch"}[e]||"sendInteraction";try{return B(r,n,"sendEventTypeApiMethod"),R(t,"sendEventTypeApiMethod"),xe(t).then(()=>Pe(t,e,r,n)).then(e=>ze(e,Ye(o))).catch(e=>{Z.error(`${o}: error composing event: ${e.message}`)})}catch(e){Z.error(`CJ: ${o}: ${e.message}`)}};function Qe(e,t){const r={...e},{application:n,source:o,...a}=r,s={protected:{application:{schemaName:n?.schemaName,schemaVersion:n?.schemaVersion,schemaUri:n?.schemaUri},source:{name:o?.name}},payload:{...a,application:et(Xe(n)),source:et(Xe(o))}};return Object.keys(s.payload.application||{}).length||delete s.payload.application,Object.keys(s.payload.source||{}).length||delete s.payload.source,s}function Xe(e={}){const t={...e};return delete t.schemaName,delete t.schemaVersion,delete t.schemaUri,delete t.name,t}function et(e){return e&&0===Object.keys(e).length?{}:e}function tt(e){const t=e?.application?.schemaName,r=re({[t]:{protected:{application:{schemaName:"STRING",schemaUri:"STRING",schemaVersion:"STRING"},source:{name:"STRING"}},payload:{contract:[]}}},{[t]:Qe(e)}),n=new ee;if("string"==typeof t&&t.trim())return function(e,t="unknown"){const r=ue(e,"INITIALIZING");r.cycle+=1,he(e,r,t)}(t,"createDataLayer.start"),Te(t,"createDataLayer",()=>{try{const o=n.getSync(D),a=Array.isArray(o)?o:[];let s;if(a.length){for(let e=0;e<a.length&&(s=a[e]?.[t],!s);e++);if(function(e,t){return e&&(t.application.schemaName!==e?.protected?.application?.schemaName||t.application.schemaVersion!==e?.protected?.application?.schemaVersion||t.application.schemaUri!==e?.protected?.application?.schemaUri||t.source.name!==e?.protected?.source?.name)}(s,e)){const e="Data layer mismatch:",t=new Error(e);throw t.code="DATA_LAYER_MISMATCH",Z.error(`${e} ${t.code}`),t}if(function(e,t){return e&&t.application.schemaName===e?.protected?.application?.schemaName&&t.application.schemaVersion===e?.protected?.application?.schemaVersion&&t.application.schemaUri===e?.protected?.application?.schemaUri&&t.source.name===e?.protected?.source?.name}(s,e))return Z.warn("Existing data layer matches. No need to set a new one."),void Ce(t,"createDataLayer.exactMatch")}a.push(r),n.setSync(D,a),Ce(t,"createDataLayer.persisted")}catch(e){const t=`Error updating data layer: ${e.message}`;throw Z.error(t),new Error(t)}});try{const e=n.getSync(D),t=Array.isArray(e)?e:[];t.push(r),n.setSync(D,t)}catch(e){const t=`Error updating data layer: ${e.message}`;throw Z.error(t),new Error(t)}}class rt{constructor(){this.storage=new ee}set(e,t){return function(e,t){if(!e){const e="Environment is required to set the data layer.";throw Z.error(e),new Error(e)}if("string"!=typeof e){const e="Environment must be a valid string.";throw Z.error(e),new Error(e)}if(!t||"object"!=typeof t){const e="dar must be a valid object";throw Z.error(e),new Error(e)}if(!t?.application?.schemaName||"string"!=typeof t?.application?.schemaName){const e="dar.application must include a valid schemaName string";throw Z.error(e),new Error(e)}if(!t?.application?.schemaVersion||"string"!=typeof t?.application?.schemaVersion){const e="dar.application must include a valid schemaVersion string";throw Z.error(e),new Error(e)}if(!t?.application?.schemaUri||"string"!=typeof t?.application?.schemaUri){const e="dar.application must include a valid schemaUri string";throw Z.error(e),new Error(e)}if(!t?.source?.name||"string"!=typeof t?.source?.name){const e="dar.source must include a valid name string";throw Z.error(e),new Error(e)}}(e,t),tt(t)}}const nt=new class{setDataLayer(e,t){return(new rt).set(e,t)}setPageData(e,t,r){return((e,t,r)=>{const n="setPageData";try{return R(e,n),B(t,r,n),Te(e,"setPageData",()=>{!function(e,t="unknown"){he(e,ue(e,"UPDATING"),t)}(e,"setPageData.start");try{Array.isArray(r?.contract)||(r.contract=[]);const n=re(r,{contract:[t]}),o=(new $e).merge(e,n);return o?.[e]?.payload&&Z.notify({dataLayerName:e,payload:o[e].payload,details:"CJ: setPageData success"},"setPageDataSuccess"),o}finally{!function(e,t="unknown"){he(e,ue(e,se),t)}(e,"setPageData.complete")}})}catch(e){Z.error(`CJ: ${n}: ${e.message}`)}})(e,t,r)}dataLayerManager(){const e=new $e;return{reset:t=>e.reset(t)}}sendLoad(e){return(e=>{try{return R(e,"sendLoad"),xe(e).then(()=>Pe(e,"load")).then(e=>ze(e,Ye("sendLoad"))).catch(e=>{Z.error(`sendLoad: error composing event: ${e.message}`)})}catch(e){Z.error(`CJ: sendLoad: ${e.message}`)}})(e)}sendImpression(e,t,r){return Promise.resolve(Ke("impression",e,t,r))}sendInteraction(e,t,r){return Promise.resolve(Ke("interaction",e,t,r))}
1sendLaunch(e,t,r){return Promise.resolve(Ke("launch",e,t,r))}sendNow(){return Promise.resolve(((e="sendNow")=>(new Ue).getUncapturedEvents().then(t=>{if(0===t.length)return void Z.warn(`${e}: No uncaptured events to process`);const r=Ye("sendNow");r.batchSize=20,r.waitTime=1e3;let n=Math.ceil(t.length/r.batchSize);const o=setInterval(()=>{n--,0===n&&clearInterval(o),We(r).catch(t=>{const r=`${e}: error in event batcher: ${t.message}`;throw Z.error(r),new Error(r)})},r.waitTime)}))())}onDataLayerReady(e,t,r){return function(e,t,r={}){if(R(e,"sdkReady.onDataLayerReady"),"function"!=typeof t)throw new Error("sdkReady.onDataLayerReady: listener must be a function");const n=!1!==r.once;return ye(e,r=>{t(Ae(e,r?.source||"context-lifecycle"))},{once:n})}(e,t,r)}waitForDataLayerReady(e,t){return De(e,t)}onContextReady(e,t,r){return ye(e,t,r)}waitForContextReady(e,t){return we(e,t)}},ot=nt.setDataLayer,at=nt.dataLayerManager(),st=nt.setPageData,it=nt.sendLoad;function ct(e,t="v1"){return{schemaName:e,schemaVersion:t,schemaUri:`dar://dar.edp.bestbuy.com/entries/engagement/${e}/${t}`}}function dt(){const e=new URLSearchParams(window.location.search),t=Array.from(e.entries(),([e,t])=>({id:e,value:t}));return{height:window.innerHeight,width:window.innerWidth,isWrapped:document.cookie.indexOf("s_channel")>-1,isCookiesDisabled:!window?.navigator?.cookieEnabled,language:window?.navigator?.language,title:window?.document?.title,url:window?.location?.href,pathName:window?.location?.pathname,hash:""!==window?.location?.hash?window.location.hash:void 0,queryParams:t.length>0?t:void 0}}nt.sendImpression,nt.sendInteraction,nt.sendLaunch,nt.sendNow,nt.onDataLayerReady,nt.waitForDataLayerReady,nt.onContextReady,nt.waitForContextReady;function ut(){const e=g(i)?g(i):"NA";return{name:g(r)?"BBY-US-ConsumerApp":"BBY-US-Web",viewType:e,userAgent:navigator?.userAgent}}const lt=e=>{let t;const r=window.localStorage.getItem("cjcDataLayers")||"[]";try{const n=JSON.parse(r);let o=0;for(;o<n.length;o++)if(t=n[o][e],t)return t;return t}catch(e){return t}};function ht(){return Z}const pt="s_channel",mt="digital-experience-event",gt="employee-digital-experience-event",yt="cjc_route_determination";class wt{constructor(e){this.adapter=e}get(e="cjcDataLayers"){return this.adapter.read(e)||[]}set(e,t){return this.adapter.write(e,t)}}function ft(e,t){if(void 0===e)throw new Error(`${t}: name must be set`);if("string"!=typeof e)throw new Error(`${t}: name must be a string`)}function vt(e,t){if(void 0===e)throw new Error(`${t}: value must be set`);if("string"!=typeof e)throw new Error(`${t}: value must be a string`);if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/.test(e))throw new Error(`${t}: value must be a  timestamp string`)}class bt extends wt{constructor(e="sessionStorage"){const t="cjcStorage";super({read:r=>{ft(r,t);const n=window[e].getItem(r);return n?"string"==typeof n?JSON.parse(n):n:null},write:(r,n)=>{ft(r,t),function(e,t){if(void 0===e)throw new Error(`${t}: value must be set`);if("object"!=typeof e||null===e)throw new Error(`${t}: value must be an object`)}(n,t),window[e].setItem(r,JSON.stringify(n))}}),this.platform="web"}}const St=e=>new bt(e),At=e=>/^(?:BestBuy\/|Bby-Android\/)/.test(e||navigator.userAgent);function Et({userAgent:e}={}){return e||navigator?.userAgent}function It({pageViewId:e,userAgent:t}={}){return At(Et({userAgent:t}))?e:"undefined"!=typeof window&&window?._pageCJAppStateUuid?window?._pageCJAppStateUuid:e}let Ct=!1;function Nt(e){const t=e?.payload?.appState?.name;if(!t||"string"!=typeof t)return;const r=St("localStorage")?.get(yt)||{};St("localStorage")?.set(yt,{...r,name:t})}function Tt(e,t){const r=At(t);r||Ct||"function"==typeof Z?.subscribe&&(Z.subscribe(Nt,void 0,"setPageDataSuccess"),Ct=!0);const n=St("localStorage")?.get(yt)||{},o=r?e?.name:function(){if("undefined"!=typeof window&&window?.location)return window.location.pathname}(),a=e?.pageViewId,s=n?.pageViewId;let i=n?.sharedAppStateUuid;const c=Boolean(a)&&a!==s,d=n?.routeName,u=t=>{St("localStorage")?.set(yt,{sharedAppStateUuid:t,routeName:o,pageViewId:a,name:e?.name,hitIncrement:n?.hitIncrement})},l=n?.sharedAppStateUuid;c?(i=a,u(i)):Boolean(o&&d&&o!==d)&&(i=(()=>{const e=k();return u(e),e})());const h=n?.name,p=l??e?.uuid,m=r?e?.referrerUrl:document?.referrer,g={uuid:i};return h&&(g.previousName=h),p&&(g.previousUuid=p),e?.name&&(g.name=e.name),m&&(g.referrerUrl=m),g}const Dt=e=>{if(!e)throw new Error("name required");const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return(e=>void 0!==e?e.replace(/[^\w-_. ]/gi,"").replace(/ /g,""):void 0)(window?.document?.cookie?.match(new RegExp(`(^| )${t}=([^;]*)`))?.[2])};function xt(e={},t){const{displayCount:r}=e;let n=0;if(!At(t)){const e=Dt("CartItemCount");n=e?parseInt(e,10):0}return{displayCount:r||n}}function $t(e={},t){const{height:r,width:n,isCookiesDisabled:o,language:a,title:s,url:i,pathName:c,hash:d,queryParams:u=[]}=e,l=Array.isArray(e?.services)?e?.services:[],h={};if(!At(t)){h.height=window.innerHeight,h.width=window.innerWidth;const e=Dt(pt);h.isWrapped=!!e,h.isCookiesDisabled=!navigator.cookieEnabled,h.language=navigator.language,h.title=document.title,h.url=window.location.href,h.pathName=window.location.pathname,h.hash=window.location.hash;const t=new URLSearchParams(window.location.search);h.queryParams=Array.from(t.entries(),([e,t])=>({id:e,value:t}))||void 0}return void 0!==r&&(h.height=r),void 0!==n&&(h.width=n),void 0!==o&&(h.isCookiesDisabled=o),void 0!==a&&(h.language=a),void 0!==s&&(h.title=s),void 0!==i&&(h.url=i),void 0!==c&&(h.pathName=c),void 0!==d&&(h.hash=d),u.length>0&&(h.queryParams=Array.from(u.entries(),([e,t])=>({id:e,value:t}))||void 0),l.length>0&&(h.services=l),h}const Pt=()=>{try{const e=e=>"00".substring(0,2-e.length)+e,t=(new Date).getTimezoneOffset();return`${t>0?"UTC-":"UTC+"}${e(`${parseInt(Math.abs(t)/60)}`)}:${e(`${Math.abs(t%60)}`)}`}catch(e){ht().error("CJ: ContextProvider - timeZone",e)}};async function Lt(e={},t){const{carrierName:r,name:n,orientation:o,osVersion:a,screenHeight:s,screenWidth:i}=e,c={timeZone:Pt(),time:(new Date).toISOString()};if(At(t))return c.carrierName=r,c.name=n,c.orientation=o,c.osVersion=a,c.screenHeight=s,c.screenWidth=i,c;const d=await(navigator?.userAgentData&&navigator?.userAgentData?.getHighEntropyValues?navigator?.userAgentData?.getHighEntropyValues(["platformVersion"])?.then(e=>{if(e?.platformVersion&&"Windows"===navigator?.userAgentData?.platform){const t=parseInt(e?.platformVersion?.split(".")[0]);return isNaN(t)?null:t>=13?"Windows 11 or later":t>=1?"Windows 10":"Before Windows 10"}return null}):Promise.resolve(null));return d&&(c.osVersion=d),c}const Ot=()=>{const e=document.cookie&&document.cookie.split("MCMID")[1]?decodeURI(document.cookie.split("MCMID")[1]):"";return""!==e?e.split("|")[1].split(";")[0]:""},Ut=(e=!1)=>e||!!Dt("et");function jt(e={},t){const{adobeId:r=Ot(),branchId:n,browserSessionId:o,isEmployeeApp:a,partyId:s,userId:i,visitorId:c}=e,d={};if(!At(t)){const e=Dt("vt"),t=Dt("pt"),r=Dt("ut"),n=Dt("SID");e&&(d.visitorId=e),t&&(d.partyId=t),r&&(d.userId=r),n&&(d.browserSessionId=n),d.isEmployeeMode=Ut(a)}return r&&(d.adobeId=r),c&&(d.visitorId=c),i&&(d.userId=i),s&&(d.partyId=s),n&&(d.branchId=n),o&&(d.browserSessionId=o),d}function _t(e={}){if(0===Object.keys(e).length)return;const{bundleId:t,isPushNotificationAuthorized:r}=e;return{bundleId:t,isPushNotificationAuthorized:r}}function kt(e={}){const{activeBundleVersion:t,baseBundleVersion:r,OTABucketName:n,versionId:o,isEmployeeApp:a,userAgent:s}=e,i=Et({userAgent:s});let c="a";if(!At(i)){c=Dt("bby_rdp")||"NA"}const d={name:"BBY-US-Web",viewType:c,userAgent:i};return At(i)&&(d.name=Ut(a)?"BBY-US-EmployeeApp":"BBY-US-ConsumerApp"),t&&(d.activeBundleVersion=t),r&&(d.baseBundleVersion=r),At(i)&&(d.framework="ReactNative"),n&&(d.OTABucketName=n),o&&(
1d.versionId=o),d}async function Bt({cacheOverrides:e,defaultDataLayerObject:t,isEmployeeApp:r,overrides:n={},pageViewId:o}={}){const{cachedPayload:a,cachedProtected:s}=e||{},i=Et({userAgent:n?.source?.userAgent}),c=function(e=18e5,t=864e5){try{const r=St("localStorage")?.get("cj_session_object");if(!r||!r.sessionStart)return!1;const n=Date.now()-new Date(r.sessionStart).getTime();return!(n>e||n>t)}catch(e){const t=e&&e.message||"";return ht().error(`Failed to validate session: ${t}`),!1}}(),d=n?.appState?.referrerUrl,u=Tt({name:n?.appState?.name,referrerUrl:d,pageViewId:It({pageViewId:o,userAgent:i})},i),l=function(e={},t){const r=[];if(At(t)){const t=e?.decisions||[];if(!Array.isArray(t))return r;for(let e=0;e<t.length;e++){const n=t[e];n&&"object"==typeof n&&r.push(n)}}else"1"===Dt("e_dns")&&r.push({name:"Do Not Sell",type:"privacy"}),Dt("global_privacy_control")&&r.push({name:"Global Privacy Control",type:"privacy"});return r}({decisions:n?.decisions},i),h=await Lt(n?.device||{},i),p=await async function(e={},t){const{defaultStoreId:r,defaultStoreZipCode:n,isBluetoothEnabled:o,isInStore:a,isLocationServicesEnabled:s}=e,i={};return At(t)||(i.defaultStoreId=Dt("locStoreId"),i.defaultStoreZipCode=Dt("locDestZip"),i.isBluetoothEnabled=await(navigator?.bluetooth?.getAvailability())||!1),r&&(i.defaultStoreId=r),n&&(i.defaultStoreZipCode=n),"boolean"==typeof o&&(i.isBluetoothEnabled=o),"boolean"==typeof a&&(i.isInStore=a),"boolean"==typeof s&&(i.isLocationServicesEnabled=s),i}(n?.location||{},i);let m=a?.decisions||[];if(0===l.length)m=[];else{const e=[];for(let t=0;t<m.length;t+=1){const r=m[t];"privacy"===r.type&&"Do Not Sell"===r.name&&e.push(r)}m=e}const g=[...m,...l],y=Array.from(new Map(g.map(e=>[JSON.stringify(e,Object.keys(e).sort()),e])).values());r&&(n.identities=n?.identities||{},n.identities.isEmployeeApp=!0,n.source=n?.source||{},n.source.isEmployeeApp=!0);const w=St("localStorage")?.get(yt)||{},f=function({hitIncrement:e=0}={}){return{hitIncrement:e+1}}({hitIncrement:c&&w?.hitIncrement||0}),v=St("localStorage")?.get(yt)||{};return St("localStorage")?.set(yt,{...v,hitIncrement:f.hitIncrement}),{appState:u,application:{...t?.application,...s?.application},basket:xt({displayCount:n?.basket?.displayCount}),browser:$t(n?.browser||{},i),decisions:y,device:h,event:f,identities:jt(n?.identities||{}
1,i),location:p,mobileApp:_t(n?.mobileApp||{}),source:{...t?.source,...kt(n?.source||{}),...s?.source}}}let Rt=null;function Ft({providerOptions:e={},replayProvider:t}={}){if("undefined"==typeof window)return;const r=Dt("cjcSessionInfo");if(Dt(pt)&&"string"==typeof r)try{const e=decodeURIComponent(r);((e,t)=>{const r="overrideSessionData";At(t)||(ft(e.sessionUuid,r),vt(e.sessionStart,r),vt(e.lastEvent,r),St("localStorage")?.set("cj_session_object",e))})(JSON.parse(e),navigator?.userAgent)}catch(e){throw new Error(`Failed to parse session cookie for wrapped page: ${e.message}`)}Rt&&window.removeEventListener("pageshow",Rt);const{schemaName:n,contractObject:o,env:a,eventBatcherConfig:s,loggerConfig:i,loggerListener:c,isEmployeeApp:d,overrides:u}=e,l=Array.isArray(u?.browser?.services)?u.browser.services:[];let h=!1;for(let e=0;e<l.length;e++)if("BFCache"===l[e]?.name){h=!0;break}const p=h?l:[...l,{name:"BFCache"}],m={schemaName:n,contractObject:o,env:a,eventBatcherConfig:s,loggerConfig:i,loggerListener:c,isEmployeeApp:d,throwOnError:!0,overrides:{...u,browser:{...u?.browser,services:p}}};Rt=e=>{if(e.persisted){const e=k();window._pageCJAppStateUuid=e,t({...m,pageViewId:e}).catch(e=>{Z.error(`Context Provider BFCache replay: ${e.message}`)})}},window.addEventListener("pageshow",Rt)}let Mt=!1,Jt=!1;async function Vt({schemaName:e,contractObject:t,env:r="local",eventBatcherConfig:n,loggerConfig:o,loggerListener:a,overrides:s,pageViewId:i,isEmployeeApp:c,throwOnError:d=!1,replayProvider:u=Vt}){try{if(o&&!Mt){const e="number"==typeof o?o:o?.severity;try{!function({severity:e,listener:t}={}){"number"==typeof e&&G(e),"function"==typeof t&&Z.subscribe(t)}({severity:e,listener:a})}catch(e){throw new Error(`Failed to configure SDK logger: ${e.message}`)}Mt=!0}if(n&&!Jt)try{const{batchSize:e,waitTime:t,retentionTime:r,eventTypes:o,schemaNames:a}=n;Ze(e,t,r,o,a),Jt=!0}catch(e){throw new Error(`Invalid event batcher configuration: ${e.message}`)}const d=function(e,t,r){e&&t||ht().error("setEsasDefaults called without required parameters");const n={application:{schemaName:e,schemaVersion:t,schemaUri:`dar://dar.edp.bestbuy.com/entries/engagement/${e}/${t}`},source:{}};return n.source.name=At(r)?"BBY-US-ConsumerApp":"BBY-US-Web",n}(e,"v1",Et({userAgent:s?.source?.userAgent}));try{await ot(r,d)}catch(e){throw new Error(`Failed to set initial data layer: ${e.message}`)}let l={...d,...s};const{cachedProtected:h,cachedPayload:p}=function(e){const t=St("sessionStorage")?.get("cjcDataLayers")||[];for(let r=0;r<t.length;r++){const n=t[r];if(!n||!Object.prototype.hasOwnProperty.call(n,e))continue;const o=n[e];return o?{cachedProtected:o.protected,cachedPayload:o.payload}:{cachedProtected:void 0,cachedPayload:void 0}}return{cachedProtected:void 0,cachedPayload:void 0}}(e);try{p&&await at.reset(e)}catch(e){throw new Error(`Failed to reset data layer: ${e.message}`)}Ft({providerOptions:{schemaName:e,contractObject:t,env:r,eventBatcherConfig:n,loggerConfig:o,loggerListener:a,overrides:s,pageViewId:i,isEmployeeApp:c},replayProvider:u}),e!==mt&&e!==gt||(l=await Bt({cacheOverrides:{cachedProtected:h,cachedPayload:p},defaultDataLayerObject:d,overrides:s,pageViewId:i,isEmployeeApp:c}).catch(e=>{throw new Error(`Failed to set experience event node: ${e.message}`)}));try{await st(e,t,l)}catch(e){throw new Error(`Failed to set page data: ${e.message}`)}return l}catch(e){if(Z.error(`Context Provider: ${e.message}`),d)throw e}}const qt=function(e=!1){return Ut(e)?gt:mt};function Wt(){const e=navigator.userAgent,t=window.location.hostname;let r="dotcom_develop";const n=e=>new RegExp(`(BestBuy/|Bby-Android/).*[a-zA-Z0-9].(${e})`),o=n("APPSTORE"),a=n("PROD"),s=n("CDC"),i=n("MAN_TEST"),c=n("STAGE"),d=n("PREVIEW"),u=n("SFT");switch(!0){case o.test(e)||a.test(e):r="app_release";break;case s.test(e)||i.test(e)||c.test(e)||d.test(e)||u.test(e):r="app_debug";break;case"www.bestbuy.com"===t:r="dotcom_prod";break;case"www.stage.bestbuy.com"===t:r="dotcom_stage";break;case"www.test.bestbuy.com"===t:r="dotcom_test"}return r}const zt=async e=>await async function({schemaName:e,contractObject:t,env:r="local",eventBatcherConfig:n,loggerConfig:o,loggerListener:a,overrides:s,pageViewId:i,isEmployeeApp:c}={}){if(t)try{const d=Et({userAgent:s?.source?.userAgent});At(d)||"undefined"==typeof window||window._pageCJAppStateUuid||(window._pageCJAppStateUuid=i||k());const u=It({pageViewId:i,userAgent:d});return await Vt({schemaName:e,contractObject:t,env:r,eventBatcherConfig:n,loggerConfig:o,loggerListener:a,pageViewId:u,isEmployeeApp:c,overrides:s})}catch(e){Z.error(`Context Provider: ${e.message}`)}}({schemaName:qt(),contractObject:p,env:Wt(),pageViewId:e});async function Ht(e=!1){try{window._pageCJAppStateUuid=e?k():window._pageCJAppStateUuid||k();const t="[DEO Client Script]",r=Wt(),s="dotcom_prod"===r,{batchSize:i,waitTime:u,retentionTime:l,eventTypes:p,schemaNames:w}={batchSize:3,waitTime:1e3,retentionTime:s?4:14,eventTypes:["load","interaction"],schemaNames:["cjc-page-requests"]},b=window._pageCJAppStateUuid;await Ze(i,u,l,p,w),e||(G(s?2:5),Z.subscribe(e=>{if(e.level<=2)y("Capture SDK error",{name:1===e?.level?"Fatal":"Error",message:e?.details||"No log details provided"});
1else if(!s){if(3===e.level)return void console.warn(`${e?.details||"No log details provided"}`);console.log(`${e?.details||"No log details provided"}`)}}),await zt(b));const S=h,A=((e,t)=>{const r=lt(e);let s={};try{r&&(s=JSON.parse(r)[e]?.payload)}catch(e){s={}}return{application:ct(e),appState:{uuid:t,name:"www.bestbuy.com"!==window.location.hostname&&"www.test.bestbuy.com"!==window.location.hostname&&"www.stage.bestbuy.com"!==window.location.hostname||"/"!==window.location.pathname&&"/home"!==window.location.pathname?"search"===window?.deoMetaData?.queryType?"Search Results":"browse"===window?.deoMetaData?.queryType?"Browse List Page":"promo"===window?.deoMetaData?.queryType?"Promo List Page":window.location.pathname?.includes("cart")?"Checkout: Cart - Index":window.location.pathname?.includes("checkout")?"Checkout:":window.location.pathname?.includes("thank-you")?"Thank you:":window.location.pathname?.includes("deal-of-the-day")?"promo: Deal of the Day":window.location.pathname?.includes("sale-page")?"promo: Special Sale":window?.deoMetaData?.type&&window.deoMetaData.type.includes("Deals")?"deals:":window?.deoMetaData?.type&&window.deoMetaData.type.includes("DeptCat")?"category:":"":"homepage: Best Buy",referrerUrl:""!==document.referrer?document.referrer:void 0,previousName:s?.appState?.name,previousUuid:s?.appState?.uuid},basket:{displayCount:g(c)?parseInt(g(c)):0},browser:dt(),device:{carrierName:void 0,connectionDownlink:window?.navigator?.connection?.downlink?parseInt(window.navigator.connection.downlink):void 0,connectionEffectiveType:window?.navigator?.connection?.effectiveType?window.navigator.connection.effectiveType:void 0,name:void 0,orientation:window?.screen?.orientation?.type,osVersion:void 0,screenHeight:window?.screen?.height?parseInt(window.screen.height):0,screenWidth:window?.screen?.width?parseInt(window.screen.width):0,timeZone:f(),time:(new Date).toISOString()},identities:{visitorId:g(n)?g(n):void 0,userId:g(o)?g(o):void 0,partyId:g(a)?g(a):void 0,adobeId:v()},location:{defaultStoreId:g(d)?g(d):void 0},source:ut()}})(S,b);lt(S)&&at.reset(S);try{await ot(r,{application:A.application,source:A.source}),Z.info(`${t} Data layer set successfully`)}catch(e){Z.error(`${t} Error setting data layer: ${e.message}`)}try{await st(S,m[S],{appState:A.appState,basket:A.basket,browser:A.browser,device:A.device,identities:A.identities,location:A.location,source:A.source}),Z.info(`${t} Page data set successfully`)}catch(e){Z.error(`${t} Error setting page data: ${e.message}`)}try{await it(S),Z.info(`${t} Load event sent successfully`)}catch(e){Z.error(`${t} Error sending load event: ${e.message}`)}}catch(e){y("Data Layer error",{name:e.name,message:e.message})}}(()=>{const e=g(r)?.trim();return/^(?:BestBuy\/|Bby-Android\/)/.test(navigator?.userAgent)||e||""===e})()||(Ht(),g(s)||T(),window.addEventListener("pageshow",e=>{e.persisted&&(Ht(e.persisted),g(s)||T(e.persisted))}))}();
2//# sourceMappingURL=deo-client-script.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.