"use strict"; function _createForOfIteratorHelper(t, e) { var o; if ("undefined" == typeof Symbol || null == t[Symbol.iterator]) { if (Array.isArray(t) || (o = _unsupportedIterableToArray(t)) || e && t && "number" == typeof t.length) { o && (t = o); var i = 0, n = function() {}; return { s: n, n: function() { return i >= t.length ? { done: !0 } : { done: !1, value: t[i++] } }, e: function(t) { throw t }, f: n } } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") } var c, a = !0, r = !1; return { s: function() { o = t[Symbol.iterator]() }, n: function() { var t = o.next(); return a = t.done, t }, e: function(t) { r = !0, c = t }, f: function() { try { a || null == o.return || o.return() } finally { if (r) throw c } } } } function _unsupportedIterableToArray(t, e) { if (t) { if ("string" == typeof t) return _arrayLikeToArray(t, e); var o = Object.prototype.toString.call(t).slice(8, -1); return "Object" === o && t.constructor && (o = t.constructor.name), "Map" === o || "Set" === o ? Array.from(t) : "Arguments" === o || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o) ? _arrayLikeToArray(t, e) : void 0 } } function _arrayLikeToArray(t, e) { (null == e || e > t.length) && (e = t.length); for (var o = 0, i = new Array(e); o < e; o++) i[o] = t[o]; return i } function _classCallCheck(t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") } function _defineProperties(t, e) { for (var o = 0; o < e.length; o++) { var i = e[o]; i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(t, i.key, i) } } function _createClass(t, e, o) { return e && _defineProperties(t.prototype, e), o && _defineProperties(t, o), t }! function n(c, a, r) { function s(o, t) { if (!a[o]) { if (!c[o]) { var e = "function" == typeof require && require; if (!t && e) return e(o, !0); if (l) return l(o, !0); throw new Error("Cannot find module '" + o + "'") } var i = a[o] = { exports: {} }; c[o][0].call(i.exports, function(t) { var e = c[o][1][t]; return s(e || t) }, i, i.exports, n, c, a, r) } return a[o].exports } for (var l = "function" == typeof require && require, t = 0; t < r.length; t++) s(r[t]); return s }({ 1: [function(t, e, o) { window.hook = function() { return !1 }, new(function() { function t() { _classCallCheck(this, t), this.ver = "1.8_driver", this.scriptTagSRC = document.querySelector("#cookiescript").src, this.barConfig = { enabledCookie: navigator.cookieEnabled, countryCode: this.getParameterByName("countrycode") ? this.getParameterByName("countrycode").toLowerCase() : "en_ww", assetsPath: this.scriptTagSRC.split("/".concat(this.ver, "/"))[0], GTMcontainers: this.getParameterByName("gtmcontainer") ? this.getParameterByName("gtmcontainer").replace(/\ /g, "").replace(/\%20/g, "").split(",") : "", loadCss: !this.getParameterByName("nocss"), domain: window.location.hostname.replace("www.", "."), customClass: this.getParameterByName("customclass") || "", customData: this.getParameterByName("customdata") ? "".concat(this.getParameterByName("customdata"), "/") : "", forceCookies: this.getParameterByName("forcecookies") ? "".concat(this.getParameterByName("forcecookies")) : "0" }, this.firstTime = !0, this.barConfig.loadCss && this.createCSSTag(), this.deleteOldCookies(), this.eventHandler() } return _createClass(t, [{ key: "deleteOldCookies", value: function() { var e = this, t = document.cookie.split("; ").filter(function(t) { return 0 === t.indexOf("cpc_") }).map(function(t) { return t.split("=")[0] }), o = t.filter(function(t) { return !JSON.parse(e.getCookie(t)).version || JSON.parse(e.getCookie(t)).version < 1.8 }); t.forEach(function(t) { document.cookie = "".concat(t, "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.author-wcs.pirelli.com;path=/"), document.cookie = "".concat(t, "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.www-uat.pirelli.com;path=/") }), o.forEach(function(t) { document.cookie = "".concat(t, "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=").concat(window.location.hostname, ";path=/"), document.cookie = "".concat(t, "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.").concat(window.location.hostname, ";path=/"), document.cookie = "".concat(t, "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.").concat(window.location.hostname.replace("www.", ""), ";path=/"), document.cookie = "".concat(t, "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.pirelli.com;path=/"), document.cookie = "".concat(t, "=; expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=.www.pirelli.com;path=/") }), this.barConfig.enabledCookie ? window.location.hostname.indexOf("author-wcs") < 0 && window.location.hostname.indexOf("www-uat") < 0 || "el_gr" === this.barConfig.countryCode || "pt_pt" === this.barConfig.countryCode || "1" === this.barConfig.forceCookies ? this.getCookie("cpc_".concat(this.barConfig.countryCode)) && localStorage.getItem("countryConfig_".concat(this.barConfig.countryCode)) ? this.retriveFromLocal() : this.retriveFromServer() : this.gtmContainerFactory() : this.retriveFromServer(), this.eventHandler() } }, { key: "retriveFromServer", value: function() { var e = this; this.xhrget("".concat(this.barConfig.assetsPath,"/").concat(this.ver,"/","cookie_config_").concat(this.barConfig.countryCode,".json")).then(function(t){ e.countryConfig = JSON.parse(t), e.barConfig.enabledCookie && localStorage.setItem("countryConfig_".concat(e.barConfig.countryCode), t); e.createAndPushPolicyObject(!0), e.gtmContainerFactory(), window.location.href.indexOf("cookie-policy") < 0 && !e.getCookie("cpc_".concat(e.barConfig.countryCode)) && (e.barConfig.enabledCookie, e.cookieBarFactory(!0), e.cookieBarShow()) }).catch(function(t) { console.log("ERR", t) }) } }, { key: "retriveFromLocal", value: function() { this.countryConfig = JSON.parse(localStorage.getItem("countryConfig_".concat(this.barConfig.countryCode))); this.createAndPushPolicyObject(!1), this.gtmContainerFactory() } }, { key: "cookieBarFactory", value: function(t) { this.barConfig.enabledCookie ? (this.cookieBarFactoryStructure(), this.cookieBarFactoryList(t), this.cookieBarEventHandler()) : (this.disabledCookieFactoryStructure(), this.disabledCookieEventHandler()) } }, { key: "disabledCookieFactoryStructure", value: function() { var t = this.countryConfig.no_cookie, e = document.createElement("div"); e.id = "cookie-bar", this.barConfig.customClass && e.classList.add(this.barConfig.customClass), e.innerHTML = '\n "), document.body.appendChild(e) } }, { key: "disabledCookieEventHandler", value: function() { var t = this; document.querySelector("#cookie-intro .noCookieClose").addEventListener("click", function() { t.cookieBarHide() }) } }, { key: "cookieBarFactoryStructure", value: function() { var t, e, o = document.createElement("div"), i = this; o.id = "cookie-bar", this.barConfig.customClass && o.classList.add(this.barConfig.customClass), o.innerHTML = '\n "), document.body.appendChild(o), "pirellicare" === this.barConfig.customClass && (t = document.querySelector("#cookie-bar .descText a"), e = this.barConfig.countryCode.split("_")[0].toUpperCase() + this.barConfig.countryCode.slice(2), t.href = "https://assets.pirellicare.com/docs/legal/PirelliCare_CP_" + e + ".html"), this.countryConfig.closeIcon && document.getElementById("cookieCloseIcon").addEventListener("click", function() { i.savePreferences(!1) }) } }, { key: "cookieBarFactoryList", value: function(i) { var n = this, c = ""; this.countryConfig.cookie_typology.map(function(t) { var e = i ? t.state ? "checked" : "" : "optin" === n.cookiePolicy[t.type + "_policy"] ? "checked" : "", o = ''); c += '
'.concat(t.name, "
\n ").concat(t.editable ? '' : "", '
\n
').concat(t.description, "
") }), document.querySelector("#cookie-accordion").innerHTML = c } }, { key: "createAndPushPolicyObject", value: function(t) { var o; t && !this.getCookie("cpc_".concat(this.barConfig.countryCode)) ? (o = {}, this.countryConfig.cookie_typology.map(function(t) { if (!t.pushToGTM) return !1; var e = t.initial_state ? "optin" : "optout"; o[t.type + "_policy"] = e }), this.cookiePolicy = o) : this.cookiePolicy = JSON.parse(this.getCookie("cpc_".concat(this.barConfig.countryCode))), "localhost" === window.location.hostname ? console.log(this.cookiePolicy) : dataLayer.push(this.cookiePolicy) } }, { key: "getParameterByName", value: function(t) { var e = this.scriptTagSRC; t = t.replace(/[\[\]]/g, "\\$&"); var o = new RegExp("[?&]" + t + "(=([^&#]*)|&|#|$)").exec(e); return o ? o[2] ? decodeURIComponent(o[2].replace(/\+/g, " ")) : "" : null } }, { key: "xhrget", value: function(i) { return new Promise(function(t, e) { var o = new XMLHttpRequest; o.open("GET", i), o.onload = function() { 200 <= o.status && o.status < 300 ? t(o.response) : e({ status: o.status, statusText: o.statusText }) }, o.onerror = function() { e({ status: o.status, statusText: o.statusText }) }, o.send() }) } }, { key: "createCSSTag", value: function() { var t = document.createElement("link"); t.rel = "stylesheet", t.href = "".concat(this.barConfig.assetsPath, "/").concat(this.ver, "/cookieGtm.css"); var e = document.getElementsByTagName("link")[0]; e.parentNode.insertBefore(t, e) } }, { key: "cookieBarShow", value: function() { document.querySelector("body").classList.add("cookies-bar__in") } }, { key: "cookieBarHide", value: function() { document.querySelector("body").classList.remove("cookies-bar__in") } }, { key: "getCookie", value: function(t) { for (var e = t + "=", o = document.cookie.split(";"), i = 0; i < o.length; i++) { for (var n = o[i]; " " === n.charAt(0);) n = n.substring(1); if (-1 !== n.indexOf(e)) return atob(n.substring(e.length, n.length)) } return "" } }, { key: "setCookie", value: function(t, e, o) { var i = this.barConfig.domain; "pirellicare" === this.barConfig.customClass && (i = this.barConfig.domain.replace("qlt-.", ".").replace("qlt-my.", ".").replace("dev-.", ".").replace("dev-my.", ".").replace("my.", ".")), -1 < t.indexOf("cpc_") && (e.version = this.ver); var n = new Date; n.setTime(n.getTime() + 24 * o * 60 * 60 * 1e3); var c = n.toGMTString(); e = btoa(JSON.stringify(e)), document.cookie = "".concat(t, "=").concat(e, ";expires=").concat(c, ";domain=").concat(i, ";path=/") } }, { key: "gtmContainerFactory", value: function() { var t, e = _createForOfIteratorHelper(this.barConfig.GTMcontainers); try { for (e.s(); !(t = e.n()).done;) { var o = t.value; this.gtmContainerInit(window, document, "script", "dataLayer", o) } } catch (t) { e.e(t) } finally { e.f() } } }, { key: "gtmContainerInit", value: function(t, e, o, i, n) { t[i] = t[i] || [], t[i].push({ "gtm.start": (new Date).getTime(), event: "gtm.js" }); var c = e.getElementsByTagName(o)[0], a = e.createElement(o), r = "dataLayer" != i ? "&l=" + i : ""; a.async = !0, a.defer = !0, a.src = "https://www.googletagmanager.com/gtm.js?id=" + n + r, c.parentNode.insertBefore(a, c) } }, { key: "savePreferences", value: function(t) { if (t) { var e = {}, o = {}; this.countryConfig.cookie_typology.map(function(t) { if (!t.pushToGTM) return !1; e[t.type + "_policy"] = "optin", o.event = "".concat(t.eventPrefix, "_").concat("optin"), "localhost" === window.location.hostname ? console.log(o) : dataLayer.push(o) }), this.setCookie("cpc_".concat(this.barConfig.countryCode), e, 365) } else { var i = {}; for (var n in this.cookiePolicy) i.event = "".concat(n.substr(0, n.indexOf("_")), "__").concat(this.cookiePolicy[n]), "localhost" === window.location.hostname ? console.log(i) : dataLayer.push(i); this.setCookie("cpc_".concat(this.barConfig.countryCode), this.cookiePolicy, 365) } this.cookieBarHide() } }, { key: "setState", value: function(t, e) { var o = e ? "optin" : "optout"; this.cookiePolicy[t + "_policy"] = o } }, { key: "cookieBarEventHandler", value: function() { var i = this, n = document.querySelector("#cookie-bar"); n.addEventListener("click", function(t) { var o, e; t.target && (t.target.matches("#cp-accept") && i.savePreferences(!0), t.target.matches("#cp-save") && i.savePreferences(), t.target.matches("#cp-manage") && (document.querySelector("#cookie-intro").classList.add("hide"), document.querySelector("#cookie-options").classList.remove("hide"), i.firstTime && (i.firstTime = !1, o = {}, i.countryConfig.cookie_typology.map(function(t) { if (!t.pushToGTM) return !1; var e = t.state ? "optin" : "optout"; o[t.type + "_policy"] = e }), i.cookiePolicy = o)), t.target.matches("#cp-cancel") && (n.classList.contains("modifyOptions") ? i.cookieBarHide() : (document.querySelector("#cookie-intro").classList.remove("hide"), document.querySelector("#cookie-options").classList.add("hide"))), t.target.matches(".switchSlider") && ((e = t.target.previousSibling).checked ? i.setState(e.getAttribute("data-target"), !1) : i.setState(e.getAttribute("data-target"), !0)), t.target.matches(".accordionHeader") && (t.target.parentNode.classList.contains("on") ? t.target.parentNode.classList.remove("on") : t.target.parentNode.classList.add("on"))) }) } }, { key: "eventHandler", value: function() { var t = this; window.onload = function() { document.querySelector(".openCookieBar") && document.querySelector(".openCookieBar").addEventListener("click", function() { document.querySelector("#cookie-bar") || t.cookieBarFactory(!1), document.querySelector("#cookie-intro").classList.add("hide"), document.querySelector("#cookie-options").classList.remove("hide"), document.querySelector("#cookie-bar").classList.add("modifyOptions"), setTimeout(function() { t.cookieBarShow() }, 1) }) } } }]), t }()) }, {}] }, {}, [1]);