1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[51291],{291:(t,e,o)=>{o.r(e),o.d(e,{default:()=>r});class r extends window.PluginBaseClass{init(){this.attachClickEvent()}async trackProductClick(t){var e,o,r,i,n,a,c,d,u,s,l;let h=this.getCookie("2c.cId"),p={dataSource:t.getAttribute("data-source"),productNumber:t.getAttribute("product-number"),productId:t.getAttribute("product-id"),categoryId:t.getAttribute("category-id")},g=((o=document.querySelector(".nosto_search_term"))===null||void 0===o?void 0:(e=o.textContent)===null||void 0===e?void 0:e.trim())||new URLSearchParams(window.location.search).get("search"),v=((n=document.querySelector(".nosto_category"))===null||void 0===n?void 0:(i=n.querySelector(".category_string"))===null||void 0===i?void 0:(r=i.textContent)===null||void 0===r?void 0:r.trim())||window.location.pathname,y=((c=document.querySelector(".nosto_result_id"))===null||void 0===c?void 0:(a=c.textContent)===null||void 0===a?void 0:a.trim())||null,k=((u=document.querySelector(".nosto_search_type"))===null||void 0===u?void 0:(d=u.textContent)===null||void 0===d?void 0:d.trim())||null,m=((l=document.querySelector(".nosto_search_type_reason"))===null||void 0===l?void 0:(s=l.textContent)===null||void 0===s?void 0:s.trim())||null,f=g?"search":v?"category":"unknown";if(!h||!p.dataSource||!p.productNumber||!p.productId)throw Error("Missing required attributes: dataSource, productNumber, 2c.cId, or productId");let w={...p,sessionId:h,trackingType:f,resultId:y,..."search"===f?{query:g,...k?{searchType:k}:{},...m?{searchTypeReason:m}:{}}:{category:v}},b=window.router["frontend.nosto.analytics-tracking"];if(!b)throw Error("API Route is undefined.");let C=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify(w)});if(301===C.status||405===C.status){let t=C.headers.get("Location");if(t||(t=C.url),t)C=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify(w)});else throw Error("`Location` header!")}if(!C.ok)throw Error("Tracking failed, no response received.")}attachClickEvent(){document.addEventListener("click",async t=>{let e=t.target.closest('[nosto-analytics="true"]');if(e&&!e.hasAttribute("data-tracking-in-progress")){e.setAttribute("data-tracking-in-progress","true");try{await this.trackProductClick(e)}catch(t){console.error("Error tracking product:",t)}e.removeAttribute("data-tracking-in-progress")}},!0)}getCookie(t){for(let e of document.cookie.split("; ")){let[o,r]=e.split("=");if(o===t)return r}return null}}}}]);
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.