1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-12-21 01:52:19 +01:00
hugo-theme-bootstrap4-blog/assets/js/haven.umd.min.js

13 lines
27 KiB
JavaScript

/*!
* @chiiya/haven v0.6.1
* (c) Elisha Witte <elishawitte@gmail.com>
* Released under the MIT License.
*/
/*!
* @chiiya/haven v0.6.1
* (c) Elisha Witte <elishawitte@gmail.com>
* Released under the MIT License.
*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).haven={})}(this,(function(e){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function t(e,n){for(var o=0;o<n.length;o++){var t=n[o];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function i(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}function a(e,n,o){return n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,e}function r(e,n){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),o.push.apply(o,t)}return o}function c(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(n){a(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function s(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,n){if(e){if("string"==typeof e)return u(e,n);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?u(e,n):void 0}}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var o=0,t=new Array(n);o<n;o++)t[o]=e[o];return t}function f(e,n){var o;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(o=l(e))||n&&e&&"number"==typeof e.length){o&&(e=o);var t=0,i=function(){};return{s:i,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:i}}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 a,r=!0,c=!1;return{s:function(){o=e[Symbol.iterator]()},n:function(){var e=o.next();return r=e.done,e},e:function(e){c=!0,a=e},f:function(){try{r||null==o.return||o.return()}finally{if(c)throw a}}}}function d(e){return e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)}var v=function(){function e(){o(this,e)}return i(e,null,[{key:"set",value:function(e,n,o){var t=this.resolveOptions(o),i=encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),a=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),r=this.encodeAttributes(t);document.cookie="".concat(a,"=").concat(i).concat(r)}},{key:"get",value:function(e){var n,o=f(document.cookie?document.cookie.split("; "):[]);try{for(o.s();!(n=o.n()).done;){var t=n.value.split("=");if(e===d(t[0])){var i=t.slice(1).join("=");return'"'===i.charAt(0)&&(i=i.slice(1,-1)),i=d(i)}}}catch(e){o.e(e)}finally{o.f()}}},{key:"getAll",value:function(){var e,n={},o=f(document.cookie?document.cookie.split("; "):[]);try{for(o.s();!(e=o.n()).done;){var t=e.value.split("="),i=d(t[0]),a=t.slice(1).join("=");'"'===a.charAt(0)&&(a=a.slice(1,-1)),a=d(a),n[i]=a}}catch(e){o.e(e)}finally{o.f()}return n}},{key:"remove",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.resolveOptions(Object.assign(n,{expires:-1}));if(e instanceof RegExp)return this.removeByRegex(e,o);var t=this.encodeAttributes(o);document.cookie="".concat(e,"=''").concat(t),this.set(e,"",o)}},{key:"removeByRegex",value:function(e,n){var o=this;Object.keys(this.getAll()).map((function(t){if(e.test(t)){var i=o.encodeAttributes(n);document.cookie="".concat(t,"=''").concat(i),o.set(t,"",n)}}))}},{key:"encodeAttributes",value:function(e){for(var n="",o=0,t=Object.keys(e);o<t.length;o++){var i=t[o],a=e[i];a&&(n+="; ".concat(i),!0!==a&&(n+="=".concat(a.split(";")[0])))}return n}},{key:"resolveOptions",value:function(e){return e&&"number"==typeof e.expires&&(e.expires=new Date(Date.now()+864e5*e.expires)),e&&e.expires instanceof Date&&(e.expires=e.expires.toUTCString()),Object.assign({path:"/"},e)}}]),e}(),p=new(function(){function e(){o(this,e),this.subscriptions={},this.counter=0}return i(e,[{key:"on",value:function(e,n){var o=this,t=this.counter+=1;return void 0===this.subscriptions[e]&&(this.subscriptions[e]={}),this.subscriptions[e][t]=n,{unsubscribe:function(){delete o.subscriptions[e][t]}}}},{key:"emit",value:function(e,n){if(void 0!==this.subscriptions[e])for(var o=0,t=Object.keys(this.subscriptions[e]);o<t.length;o++){var i=t[o];this.subscriptions[e][i](n)}}}]),e}()),h={prefix:"cookies",cookieAttributes:{expires:365},domains:[],cookies:{},lang:"en",type:"opt-in",services:[],notification:{position:"bottom",policyUrl:"/cookie-policy",styles:{background:"#3C366B",textColor:"#FFF",linkColor:"#F7FAFC",buttonBackgroundColor:"#F1D600",buttonBackgroundColorHover:"#F6E05E",buttonTextColor:"#1A202C"}},preferences:{styles:{textColor:"#666666",toggleBorder:"#666666",toggleBackground:"#9FD6AE"}},translations:{en:{notification:{message:"This website uses cookies to ensure you get the best experience on our website.",policy:"Learn more",accept:"Allow cookies",decline:"Decline"},preferences:{description:"This website uses the following cookies:"},purposes:{functional:{name:"Functional",description:"Functional cookies are absolutely necessary for core functions such as navigating the page or accessing secure areas. The website cannot function properly without these cookies.\n"},analytics:{name:"Analytics",description:"Analytics cookies serve to improve the performance and functionality of this website by collecting and reporting information anonymously.\n"},marketing:{name:"Marketing",description:"Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.\n"},preferences:{name:"Preferences",description:"Preference cookies are used to remember settings and customizations that change the way the website behaves or looks.\n"}}},de:{notification:{message:"Wir verwenden Cookies, um Ihnen den bestmöglichen Service auf unserer Website zu bieten.",policy:"Cookie-Einstellungen ändern",accept:"Annehmen",decline:"Ablehnen"},preferences:{description:"Diese Website setzt folgende Cookies ein:"},purposes:{functional:{name:"Funktionale Cookies",description:"Funktionale Cookies sind für Kernfunktionen wie das Navigieren auf der Seite oder den Zugriff auf geschützte Bereiche zwingend erforderlich. Ohne diese Cookies kann die Website nicht richtig funktionieren.\n"},analytics:{name:"Analyse-Cookies",description:"Analyse-Cookies dienen dazu, die Leistung und Funktionalität dieser Website zu verbessern, indem sie Informationen anonym sammeln und melden.\n"},marketing:{name:"Marketing-Cookies",description:"Marketing-Cookies werden verwendet, um Besucher auf Websites zu tracken. Ziel ist es, Anzeigen zu schalten, die für den einzelnen Nutzer relevant und ansprechend sind und damit für Publisher und Drittwerber wertvoller sind.\n"},preferences:{name:"Präferenz-Cookies",description:"Präferenz-Cookies werden verwendet, um Einstellungen und Anpassungen zu speichern, die das Verhalten oder das Aussehen der Website verändern.\n"}}}}},k=function(e){var n=h.translations[h.lang];if(void 0!==n){var o,t=n,i=f(e.split("."));try{for(i.s();!(o=i.n()).done;){var a=o.value;if(!t[a])return;t=t[a]}}catch(e){i.e(e)}finally{i.f()}return t}console.error("HAVEN: No translations found for language `".concat(h.lang,"`"))},g=function(){if(h.purposes)return h.purposes;var e=h.services.map((function(e){return e.purposes||[]})).flat();return s(new Set(s(e)))};function y(e){return e&&"object"===n(e)&&!Array.isArray(e)}function m(e,n){var o=Object.assign({},e);return y(e)&&y(n)&&Object.keys(n).forEach((function(t){y(n[t])&&t in e?o[t]=m(e[t],n[t]):Object.assign(o,a({},t,n[t]))})),o}function b(e){return null!==document.querySelector('script[src="'.concat(e,'"]'))}var w=function(){function e(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"opt-in",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};o(this,e),this.prefix=n,this.type=t,this.attributes=i}return i(e,[{key:"enableFunctionalCookie",value:function(){e.setCookie("".concat(this.prefix,"-functional"),"true",this.attributes),p.emit("functional-enabled")}},{key:"hasFunctionalCookie",value:function(){return e.cookieExists("".concat(this.prefix,"-functional"))}},{key:"enableCookies",value:function(n){e.setCookie("".concat(this.prefix,"-").concat(n),"true",this.attributes),p.emit("".concat(n,"-enabled"))}},{key:"disableCookies",value:function(n){e.setCookie("".concat(this.prefix,"-").concat(n),"false",this.attributes),p.emit("".concat(n,"-disabled"))}},{key:"hasAllCookiesSet",value:function(){var n,o=f(g());try{for(o.s();!(n=o.n()).done;){var t=n.value;if(!e.cookieExists("".concat(this.prefix,"-").concat(t)))return!1}}catch(e){o.e(e)}finally{o.f()}return!0}},{key:"hasCookiesEnabled",value:function(n){var o=e.getCookie("".concat(this.prefix,"-").concat(n));return"opt-in"===this.type?"true"===o:void 0===o||"true"===o}},{key:"hasAllNecessaryCookiesEnabled",value:function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=f(n);try{for(o.s();!(e=o.n()).done;){var t=e.value;if(!this.hasCookiesEnabled(t))return!1}}catch(e){o.e(e)}finally{o.f()}return!0}},{key:"enableAllCookies",value:function(){var e=this;["functional"].concat(s(g())).map((function(n){return e.enableCookies(n)}))}},{key:"disableAllCookies",value:function(){var e=this;g().map((function(n){return e.disableCookies(n)}))}}],[{key:"getCookie",value:function(e){return v.get(e)}},{key:"setCookie",value:function(e,n,o){v.set(e,n,o)}},{key:"removeCookie",value:function(e,n){v.remove(e,n)}},{key:"cookieExists",value:function(e){return void 0!==v.get(e)&&""!==v.get(e)}}]),e}(),C=function(){function e(){o(this,e)}return i(e,null,[{key:"resolve",value:function(e){e.domains&&Array.isArray(e.domains)&&(e.domains=this.normalizeDomains(e.domains)),this.resolveBaseConfiguration(e),h.notification=m(h.notification,e.notification),h.translations=m(h.translations,e.translations)}},{key:"resolveBaseConfiguration",value:function(e){for(var n=0,o=["prefix","cookies","type","services","purposes"];n<o.length;n++){var t=o[n];void 0!==e[t]&&(h[t]=e[t])}var i=e.domains||[];h.domains=i.length>0?i:this.getDomains(),h.lang=this.detectLanguage(e),void 0!==e.cookieAttributes&&(h.cookieAttributes=Object.assign(h.cookieAttributes,e.cookieAttributes))}},{key:"detectLanguage",value:function(e){var n=(e.lang||document.documentElement.lang||"en").toLowerCase(),o=/^(\w{2})-(\w{2})$/.exec(n);return null===o?n:o[1]}},{key:"getDomains",value:function(){var e=[],n=window.location.hostname,o=n.match(/(?:[A-Za-z0-9-]+\.)*([A-Za-z0-9-]+\.co.uk|\.com.br|\.co.jp|\.com.au)\b/);null!==o&&e.push(o[1]);var t=n.match(/(?:[A-Za-z0-9-]+\.)*([A-Za-z0-9-]+\.(?:[A-za-z]{2}|[A-Za-z]{3,}))\b/);return null!==t&&e.push(t[1]),e.push(n),this.normalizeDomains(e)}},{key:"normalizeDomains",value:function(e){return e.map((function(e){return e.startsWith(".")?e:".".concat(e)}))}}]),e}(),x=["-apple-system","BlinkMacSystemFont",'"Segoe UI"',"Roboto","Oxygen","Ubuntu","Cantarell",'"Fira Sans"','"Droid Sans"','"Helvetica Neue"',"Arial",'"Noto Sans"',"sans-serif",'"Apple Color Emoji"','"Segoe UI Emoji"','"Segoe UI Symbol"','"Noto Color Emoji"'],A=function(){function e(){o(this,e)}return i(e,null,[{key:"create",value:function(){var e,n=document.createElement("style");n.type="text/css",n.appendChild(document.createTextNode((e=h.notification.styles,"\n .hv-notification {\n align-items: center;\n background: ".concat(e.background,";\n box-sizing: border-box;\n color: ").concat(e.textColor,";\n display: flex;\n font-family: ").concat(x.join(", "),";\n font-size: 16px;\n justify-content: space-between;\n left: 0;\n line-height: 1.5;\n opacity: 1;\n overflow: hidden;\n padding: 16px 32px;\n position: fixed;\n right: 0;\n transition: opacity 1s ease;\n width: 100%;\n z-index: 9999;\n }\n\n .hv-notification--hidden {\n opacity: 0;\n }\n\n .hv-notification--top {\n top: 0;\n }\n\n .hv-notification--bottom {\n bottom: 0;\n }\n\n .hv-notification__message {\n margin: 0 16px 0 0;\n }\n\n .hv-notification__message a {\n color: ").concat(e.linkColor,";\n text-decoration: underline;\n }\n\n .hv-notification__message a:hover {\n color: ").concat(e.textColor,";\n }\n\n .hv-notification-button {\n align-items: center;\n border: 0;\n cursor: pointer;\n display: inline-flex;\n font-size: 14px;\n font-weight: 500;\n justify-content: center;\n outline: 0;\n padding: 8px 32px;\n transition: background-color 0.2s ease, color 0.2s ease;\n }\n\n .hv-notification__decline {\n background: transparent;\n color: ").concat(e.textColor,";\n }\n\n .hv-notification__decline:hover {\n text-decoration: underline;\n }\n\n .hv-notification__accept {\n background: ").concat(e.buttonBackgroundColor,";\n color: ").concat(e.buttonTextColor,";\n }\n\n .hv-notification__accept:hover {\n background: ").concat(e.buttonBackgroundColorHover,";\n }\n ")))),document.head.appendChild(n);var o=document.createElement("div");o.innerHTML=function(){var e=h.notification;return'\n <div id="cookie-notification" role="alert" class="hv-notification hv-notification--'.concat(e.position,'" data-display="flex" style="display: none;">\n <p class="hv-notification__message">\n ').concat(k("notification.message"),' <a href="').concat(e.policyUrl,'" target="_blank">').concat(k("notification.policy"),'</a>\n </p>\n <div class="hv-notification__actions">\n <button id="cookie-notification__decline" class="hv-notification-button hv-notification__decline">').concat(k("notification.decline"),'</button>\n <button id="cookie-notification__accept" class="hv-notification-button hv-notification__accept">').concat(k("notification.accept"),"</button>\n </div>\n </div>\n ")}(),document.body.appendChild(o)}}]),e}(),j=!0,S=!1,_=function(){function e(){o(this,e),this.cookieNotification=null,this.cookiesAccept=null,this.cookiesDecline=null,this.cookieManager=new w(h.prefix,h.type,h.cookieAttributes)}return i(e,[{key:"init",value:function(){var e=this;this.cookieNotification=document.getElementById("cookie-notification"),null===this.cookieNotification&&(A.create(),this.cookieNotification=document.getElementById("cookie-notification")),this.cookiesAccept=document.getElementById("cookie-notification__accept"),this.cookiesDecline=document.getElementById("cookie-notification__decline"),null===this.cookieNotification||this.cookieManager.hasAllCookiesSet()||this.showCookieNotification(),null!==this.cookiesAccept&&this.cookiesAccept.addEventListener("click",(function(n){n.preventDefault(),e.cookieManager.enableAllCookies(),e.hideCookieNotification(),e.togglePreferences(j)})),null!==this.cookiesDecline&&this.cookiesDecline.addEventListener("click",(function(n){n.preventDefault(),e.cookieManager.disableAllCookies(),e.cookieManager.enableFunctionalCookie(),e.hideCookieNotification(),e.togglePreferences(S)}))}},{key:"showCookieNotification",value:function(){null!==this.cookieNotification&&(this.cookieNotification.style.display=this.cookieNotification.dataset.display||"block",this.cookieNotification.classList.remove("hv-notification--hidden"))}},{key:"hideCookieNotification",value:function(){null!==this.cookieNotification&&(this.cookieNotification.style.display="none")}},{key:"togglePreferences",value:function(e){var n,o=f(g());try{for(o.s();!(n=o.n()).done;){var t=n.value,i=document.getElementById("cookie-preferences--".concat(t));i&&(i.checked=e)}}catch(e){o.e(e)}finally{o.f()}}}]),e}(),E=["-apple-system","BlinkMacSystemFont",'"Segoe UI"',"Roboto","Oxygen","Ubuntu","Cantarell",'"Fira Sans"','"Droid Sans"','"Helvetica Neue"',"Arial",'"Noto Sans"',"sans-serif",'"Apple Color Emoji"','"Segoe UI Emoji"','"Segoe UI Symbol"','"Noto Color Emoji"'],I=function(){function e(){o(this,e)}return i(e,null,[{key:"create",value:function(e){var n,o=document.createElement("style");o.type="text/css",o.appendChild(document.createTextNode((n=h.preferences.styles,"\n .hv-preference {\n align-items: center;\n box-sizing: border-box;\n display: flex;\n font-family: ".concat(E.join(", "),";\n font-size: 16px;\n justify-content: space-between;\n line-height: 1.5;\n width: 100%;\n }\n\n .hv-preference__purpose {\n font-size: 20px;\n margin: 0;\n }\n\n .hv-preference__description {\n margin-top: 10px;\n width: 100%;\n }\n\n .hv-toggle {\n display: none;\n }\n\n .hv-toggle:checked + label::before {\n background: ").concat(n.toggleBackground,";\n left: auto;\n right: 20px;\n transform: translateX(16px);\n }\n\n .hv-toggle:disabled + label {\n cursor: not-allowed;\n opacity: .5;\n }\n\n .hv-toggle-label {\n border: 1px solid ").concat(n.toggleBorder,";\n border-radius: 9999px;\n cursor: pointer;\n display: inline-block;\n height: 24px;\n margin: 0;\n position: relative;\n width: 48px;\n }\n\n .hv-toggle-label::before {\n background: ").concat(n.toggleBorder,';\n border-radius: 9999px;\n content: "";\n height: 16px;\n left: 4px;\n position: absolute;\n transition: transform .3s ease, background-color .3s ease;\n top: 3px;\n width: 16px;\n }\n ')))),document.head.appendChild(o);var t,i=document.createElement("div");i.innerHTML=(t=["functional"].concat(s(g())),"\n <p>".concat(k("preferences.description"),"</p>\n ").concat(t.map((function(e){return'\n <div class="hv-preference">\n <h3 class="hv-preference__purpose">'.concat(k("purposes.".concat(e,".name")),'</h3>\n <input type="checkbox" class="hv-toggle" id="cookie-preferences--').concat(e,'" ').concat("functional"===e?"disabled checked":"",'>\n <label for="cookie-preferences--').concat(e,'" class="hv-toggle-label"></label>\n </div>\n <p class="hv-preference__description">').concat(k("purposes.".concat(e,".description")),"</p>\n ")})).join(""),"\n ")),e.appendChild(i)}}]),e}(),N=function(){function e(){o(this,e),this.saveButton=null,this.cookieManager=new w(h.prefix,h.type,h.cookieAttributes)}return i(e,[{key:"init",value:function(){var e=document.getElementById("cookie-preferences");null!==e&&I.create(e),this.attachListeners()}},{key:"attachListeners",value:function(){var e,n=this,o=g(),t={},i=f(o);try{var a=function(){var o=e.value,i=document.getElementById("cookie-preferences--".concat(o));null!==i&&(t[o]=i,i.checked=n.cookieManager.hasCookiesEnabled(o),i.addEventListener("change",(function(){n.cookieManager.enableFunctionalCookie(),i.checked?n.cookieManager.enableCookies(o):n.cookieManager.disableCookies(o)})))};for(i.s();!(e=i.n()).done;)a()}catch(e){i.e(e)}finally{i.f()}var r=document.getElementById("cookie-preferences__save");null!==r&&r.addEventListener("click",(function(){n.cookieManager.enableFunctionalCookie();var e,i=f(o);try{for(i.s();!(e=i.n()).done;){var a=e.value;t[a].checked?n.cookieManager.enableCookies(a):n.cookieManager.disableCookies(a)}}catch(e){i.e(e)}finally{i.f()}var r=document.getElementById("cookie-notification");null!==r&&(r.style.display="none")}))}}]),e}(),O=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==e.id?(b("https://connect.facebook.net/en_US/fbevents.js")||B(),window.fbq("init",e.id),window.fbq("track","PageView")):console.error("FACEBOOK_PIXEL: No ID specified. Please specify an ID using `options.id`.")},B=function(){if(!window.fbq){var e=window.fbq=function(){e.callMethod?e.callMethod.apply(e,arguments):e.queue.push(arguments)};window._fbq||(window._fbq=e),e.push=e,e.loaded=!0,e.version="2.0",e.queue=[];var n=document.createElement("script");n.async=!0,n.src="https://connect.facebook.net/en_US/fbevents.js";var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(n,o)}},D=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==e.id?(b("https://www.google-analytics.com/analytics.js")||z(),void 0!==e.name?M(e):P(e)):console.error("GOOGLE_ANALYTICS: No ID specified. Please specify an ID using `options.id`.")},z=function(){window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=+new Date;var e=document.getElementsByTagName("script")[0],n=document.createElement("script");n.src="https://www.google-analytics.com/analytics.js",e.parentNode.insertBefore(n,e)},M=function(e){window.ga("create",e.id,"auto",e.name),!1!==e.anonymizeIp&&window.ga("".concat(e.name,".set"),"anonymizeIp",!0),window.ga("".concat(e.name,".send"),"pageview")},P=function(e){window.ga("create",e.id,"auto"),!1!==e.anonymizeIp&&window.ga("set","anonymizeIp",!0),window.ga("send","pageview")},F=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==e.id?b("https://www.googletagmanager.com/gtm.js?id=".concat(e.id))||L(e):console.error("GOOGLE_TAG_MANAGER: No ID specified. Please specify an ID using `options.id`.")},L=function(e){window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"gtm.js","gtm.start":(new Date).getTime()});var n=document.getElementsByTagName("script")[0],o=document.createElement("script");o.src="https://www.googletagmanager.com/gtm.js?id=".concat(e.id),n.parentNode.insertBefore(o,n)},T=function(){function e(){o(this,e),this.injected={},this.cookieManager=new w(h.prefix,h.type,h.cookieAttributes)}return i(e,[{key:"injectServices",value:function(){var e,n=f(h.services);try{for(n.s();!(e=n.n()).done;){var o=e.value;this.injectService(o)}}catch(e){n.e(e)}finally{n.f()}}},{key:"injectService",value:function(e){if(this.shouldBeInjected(e)){var n=this.getInjectorFunction(e);void 0!==n&&(n(e.options||{}),p.emit("service-loaded",e.name)),this.injected[e.name]=!0}}},{key:"shouldBeInjected",value:function(e){return!1!==e.inject&&!this.injected[e.name]&&(e.required||this.cookieManager.hasAllNecessaryCookiesEnabled(e.purposes))}},{key:"getInjectorFunction",value:function(e){var n;if(!0===e.inject){var o=e.type||e.name;return void 0===(n=this.getDefaultInjector(o))?void console.error("No default injector found for ".concat(o,". Please specify your own implementation.")):n}if(e.inject)return e.inject}},{key:"getDefaultInjector",value:function(e){switch(e){case"google-analytics":return D;case"google-tag-manager":return F;case"facebook-pixel":return O;default:return}}},{key:"registerService",value:function(e,n,o){var t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=c({name:e,purposes:n,inject:o},t);h.services.push(i),this.injectService(i)}}]),e}(),U=function(){function e(){o(this,e)}return i(e,null,[{key:"removeCookies",value:function(){var e,n=this,o=f(h.services);try{for(o.s();!(e=o.n()).done;){var t=e.value;this.removeCookiesSetByService(t)}}catch(e){o.e(e)}finally{o.f()}h.cookies&&Object.values(h.cookies).map((function(e){return n.removeSimpleCookies(e)})),window.location.reload()}},{key:"removeCookiesForPurpose",value:function(e){var n,o=f(h.services);try{for(o.s();!(n=o.n()).done;){var t=n.value;-1!==t.purposes.indexOf(e)&&this.removeCookiesSetByService(t)}}catch(e){o.e(e)}finally{o.f()}h.cookies&&h.cookies[e]&&this.removeSimpleCookies(h.cookies[e])}},{key:"removeCookiesSetByService",value:function(e){e.cookies&&e.cookies.length&&this.removeSimpleCookies(e.cookies);var n=e.type||e.name;"google-analytics"===n&&this.removeGoogleAnalyticsCookies(e.options),"facebook-pixel"===n&&this.removeFacebookPixelCookies(e.options)}},{key:"removeGoogleAnalyticsCookies",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=["_ga","_gid","_gat","AMP_TOKEN"],o=["_dc_gtm_","_gac_","_gat_gtag_","_gat_"];this.removeSimpleCookies(n),void 0!==e.id&&this.removeCompositeCookies(o,e.id),void 0!==e.name&&this.removeCompositeCookies(o,e.name)}},{key:"removeFacebookPixelCookies",value:function(){this.removeSimpleCookies(["_fbp"])}},{key:"removeSimpleCookies",value:function(e){var n,o=f(e);try{for(o.s();!(n=o.n()).done;){var t,i=n.value,a=f(h.domains);try{for(a.s();!(t=a.n()).done;){var r=t.value;w.removeCookie(i,{domain:r})}}catch(e){a.e(e)}finally{a.f()}w.removeCookie(i)}}catch(e){o.e(e)}finally{o.f()}}},{key:"removeCompositeCookies",value:function(e,n){var o,t=f(e);try{for(t.s();!(o=t.n()).done;){var i,a=o.value,r=f(h.domains);try{for(r.s();!(i=r.n()).done;){var c=i.value;w.removeCookie("".concat(a).concat(n),{domain:c})}}catch(e){r.e(e)}finally{r.f()}w.removeCookie("".concat(a).concat(n))}}catch(e){t.e(e)}finally{t.f()}}}]),e}(),q=function(){function e(n){o(this,e),C.resolve(n),this.cookieNotification=new _,this.cookiePreferences=new N,this.cookieManager=new w(h.prefix,h.type,h.cookieAttributes),this.serviceLoader=new T}return i(e,[{key:"init",value:function(){var e=this;/complete|interactive|loaded/.test(document.readyState)?(this.cookieNotification.init(),this.cookiePreferences.init()):document.addEventListener("DOMContentLoaded",(function(){e.cookieNotification.init(),e.cookiePreferences.init()})),this.registerDefaultListeners(),this.checkInitialState()}},{key:"checkInitialState",value:function(){var e,n=f(g());try{for(n.s();!(e=n.n()).done;){var o=e.value;this.cookieManager.hasCookiesEnabled(o)&&p.emit("".concat(o,"-enabled"))}}catch(e){n.e(e)}finally{n.f()}}},{key:"registerDefaultListeners",value:function(){var e,n=this,o=f(g());try{var t=function(){var o=e.value;p.on("".concat(o,"-enabled"),(function(){n.serviceLoader.injectServices()})),p.on("".concat(o,"-disabled"),(function(){U.removeCookiesForPurpose(o)}))};for(o.s();!(e=o.n()).done;)t()}catch(e){o.e(e)}finally{o.f()}}},{key:"registerService",value:function(e,n,o){var t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this.serviceLoader.registerService(e,n,o,t)}},{key:"preferences",get:function(){return this.cookiePreferences}},{key:"notification",get:function(){return this.cookieNotification}}],[{key:"on",value:function(e,n){return p.on(e,n)}},{key:"create",value:function(n){return e.instance&&console.warn("Replacing an existing Haven instance. Are you sure this behaviour is intended?"),e.instance=new e(n),e.instance.init(),e.instance}},{key:"getInstance",value:function(){if(e.instance)return e.instance;console.error("No Haven instance found. Make sure to create a Haven instance before attempting to access it.")}},{key:"removeCookies",value:function(e,n){var o,t=f(e);try{for(t.s();!(o=t.n()).done;){var i=o.value;w.removeCookie(i,n)}}catch(e){t.e(e)}finally{t.f()}}}]),e}();"undefined"!=typeof window&&(window.Haven=q),e.CookieManager=w,e.Haven=q,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=haven.umd.min.js.map