!async function(){if(!0===window.tpHeaderLoaded)return;window.tpHeaderLoaded=!0;const t="//ecommplugins-trustboxpreview.trustpilot.com/v1.0/trustboxpreview.min.js",e="//ecommplugins-scripts.trustpilot.com/v2.1/css/preview.min.css",o="TRUSTPILOT_SKU_VALUE_";function r(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}))}const n=new URL(document.currentScript.src),i=n.searchParams?n.searchParams.get("settings"):void 0,s=i?JSON.parse((p=i,decodeURIComponent(Array.prototype.map.call(atob(p),function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)}).join("")))):{};var p;"undefined"==typeof TrustpilotObject&&function(t,e,o,r,n){t.TrustpilotObject=n,t.tp=t.tp||function(){(t.tp.q=t.tp.q||[]).push(arguments)},a=e.createElement(o),a.async=1,a.src="https://invitejs.trustpilot.com/tp.min.js",a.type="text/java"+o,f=e.getElementsByTagName(o)[0],f.parentNode.insertBefore(a,f)}(window,document,"script",0,"tp"),tp("register",s.key);const u=new CustomEvent("trustpilotScriptLoaded");if(dispatchEvent(u),function(t){return t&&t.searchParams&&"true"===t.searchParams.get("tpTrustBoxPreview")?(window.sessionStorage.setItem("tpTrustBoxPreview",!0),!0):window.localStorage.getItem("tpTrustBoxPreview")?(window.localStorage.removeItem("tpTrustBoxPreview"),window.sessionStorage.setItem("tpTrustBoxPreview",!0),!0):!!window.sessionStorage.getItem("tpTrustBoxPreview")}(new URL(window.location.href))){document.body.style.paddingTop="75px";var d=document.createElement("script");if(d.type="text/javascript",d.src="//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js",d.async=!0,document.head.appendChild(d),"undefined"==typeof TrustpilotPreview)try{var c=document.createElement("script");c.type="text/javascript",c.src="//ecommplugins-scripts.trustpilot.com/v2.1/js/preview_shopify.js",c.onload=function(t){const e=document.createElement("iframe");e.id="pixel_iframe",e.src="//ecommscript-integrationapp.trustpilot.com/pixel/index.html",e.setAttribute("style","display: none; width: 1px; height: 1px;"),e.onload=function(t){document.getElementById("pixel_iframe").contentWindow.postMessage(JSON.stringify({basis:"iframe",action:"initialLoad"}),"https://ecommscript-integrationapp.trustpilot.com")},document.body.appendChild(e)},document.head.appendChild(c)}catch(u){console.log("TrustpilotPreview couldn't load")}window.addEventListener("message",function(a){var o=new URL(window.location).hostname;!a.data||-1===a.origin.indexOf(o)&&"https://ecommscript-integrationapp.trustpilot.com"!==a.origin||"undefined"!=typeof TrustpilotPreview&&("string"==typeof a.data&&"submit"===a.data?TrustpilotPreview.sendTrustboxes():"string"==typeof a.data&&(jsonData=JSON.parse(a.data),jsonData.trustbox?TrustpilotPreview.setSettings(jsonData.trustbox):"updatePageUrls"===jsonData.type||"newTrustBox"===jsonData.type||"deletePageTrustBoxes"===jsonData.type?TrustpilotPreview.sendDataTransfer(a.data):"loadCategoryProductInfo"===jsonData.type?function(){const t=$("a.product").toArray().map(t=>t.href.split("/").pop());return Promise.all(t.map(t=>new Promise((e,a)=>{Shopify.getProduct(t,e)}))).then(t=>{const e=w(),a=t.map(t=>({productUrl:t.url,id:t.id.toString(),variationIds:t.variants.map(t=>t.id.toString()),variationSkus:t.variants.map(t=>t[e]),name:t.title}));return a})}().then(t=>{window.postMessage(JSON.stringify(t),window.origin)}):jsonData.customised?TrustpilotPreview.updateActive(jsonData.customised):jsonData.loadData&&async function(a){var o=document.createElement("div");o.id="trustpilot_initial_data",o.setAttribute("data-page-urls",r(JSON.stringify(a.loadData.trustbox.pageUrls))),o.setAttribute("data-custom-trustboxes",a.loadData.customTrustBoxes),o.setAttribute("data-settings",r(JSON.stringify(a.loadData))),o.setAttribute("id","trustpilot-trustbox-preview"),o.setAttribute("data-source","Shopify"),o.setAttribute("data-sku","product"===y()?await m(s.s):""),document.body.appendChild(o);var n=document.createElement("script");n.type="text/javascript",n.src=t,n.async=!0,n.onload=function(){const t=JSON.stringify({basis:"iframe",TrustBoxPreviewMode:{integrationKey:s.key},enable:!0,widgets:a.widgets});window.postMessage(t,window.origin)},document.head.appendChild(n),TrustpilotPreview.init([e],a.loadData.trustbox,window,document.getElementById("pixel_iframe").contentWindow)}(jsonData)))})}else"undefined"!=typeof trustpilot_trustbox_settings?await v():addEventListener("trustpilotTrustboxSettingsLoaded",async function(){await v()});async function l(t){var e=(await m(t)).join(","),a=function(){var t=ShopifyAnalytics&&ShopifyAnalytics.meta||t;if(t&&t.product&&t.product.variants&&t.product.variants.length>0){var e=t.product.variants;if(t.product.selectedVariantId)for(var a=0;a{const a=new XMLHttpRequest;a.onreadystatechange=function(){if(4===a.readyState&&200==a.status)try{t(JSON.parse(a.response))}catch(t){e()}},a.open("GET",window.location.href,!0),a.setRequestHeader("Accept","application/json"),a.send(null)})).product)}catch(t){}return e}function g(t,e,a){t.push(`${o}${a.id}`);var r=a.variants;for(var n in r)t.push(`${o}${r[n].id}`),r[n][e]&&t.push(r[n][e])}function w(t){return t||(t="sku"),t}function y(){const t=document.head.querySelector("[property~='og:type'][content]"),e=t?t.content:"",a=location.pathname;if(meta&&meta.page&&"home"===meta.page.pageType||"/"===location.pathname)return"landing";if(meta&&meta.page&&"collection"===meta.page.pageType||"product.group"===e||/^\/collections(\/[a-z0-9-_]+\/?$)?\/?$/.test(a))return"category";return meta&&meta.page&&"product"===meta.page.pageType||meta&&void 0!==meta.product||"product"===e||/^\/(collections\/[a-z0-9-_]+\/)?products\/[a-z0-9-_]+\/?$/.test(a)?"product":void 0}async function v(){const t=y();if("product"===t){const t=s.s;await l(t)}trustpilot_trustbox_settings.trustboxes=trustpilot_trustbox_settings.trustboxes.filter(function(e){return t===e.page||h(e.page)===h(location.origin+location.pathname)||e.page.toLowerCase()===btoa(location.origin+location.pathname).toLowerCase()}),tp("trustBox",trustpilot_trustbox_settings)}function h(t){return"string"==typeof t?t.replace(/\/+$/,""):t}}(); //# sourceMappingURL=header.min.js.map