{"version":3,"sources":["node_modules/browser-pack/_prelude.js","src/public/js/em-cookie-notification-public.js"],"names":["r","e","n","t","o","i","f","c","require","u","a","Error","code","p","exports","call","length","1","module","$","EmCookieNotification","window","hideInUS","hide_in_us","googleAPIKey","api","cookieActiveClass","createCookie","name","value","days","expires","date","Date","setTime","getTime","toUTCString","document","cookie","readCookie","nameEQ","ca","split","charAt","substring","indexOf","getDateNow","today","dd","getDate","mm","getMonth","yyyy","getFullYear","parseInt","countryDetection","accepted_cookies","ajax","type","url","data","JSON","stringify","considerIp","contentType","success","undefined","location","lat","lng","get","country_short_name","addrComponents","types","short_name","getCountry","results","address_components","initCookieNotification","error","_error","console","log","showCookie","cookieValue","parse","serverEffectiveDate","effective","dateAccepted","show","addClass","click","preventDefault","expiry","css","setTimeout","removeClass","ready","jQuery"],"mappings":"CAAA,SAAAA,EAAAC,EAAAC,EAAAC,GAAA,SAAAC,EAAAC,EAAAC,GAAA,IAAAJ,EAAAG,GAAA,CAAA,IAAAJ,EAAAI,GAAA,CAAA,IAAAE,EAAA,mBAAAC,SAAAA,QAAA,IAAAF,GAAAC,EAAA,OAAAA,EAAAF,GAAA,GAAA,GAAAI,EAAA,OAAAA,EAAAJ,GAAA,GAAA,IAAAK,EAAA,IAAAC,MAAA,uBAAAN,EAAA,KAAA,MAAAK,EAAAE,KAAA,mBAAAF,EAAA,IAAAG,EAAAX,EAAAG,GAAA,CAAAS,QAAA,IAAAb,EAAAI,GAAA,GAAAU,KAAAF,EAAAC,QAAA,SAAAd,GAAA,OAAAI,EAAAH,EAAAI,GAAA,GAAAL,IAAAA,IAAAa,EAAAA,EAAAC,QAAAd,EAAAC,EAAAC,EAAAC,GAAA,OAAAD,EAAAG,GAAAS,QAAA,IAAA,IAAAL,EAAA,mBAAAD,SAAAA,QAAAH,EAAA,EAAAA,EAAAF,EAAAa,OAAAX,IAAAD,EAAAD,EAAAE,IAAA,OAAAD,EAAA,CAAA,CAAAa,EAAA,CAAA,SAAAT,EAAAU,EAA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E5BuC,KAKuB,IAAbxD,GAEVwD,MAhRJ,CAsRIoB","file":"../em-cookie-notification/em-cookie-notification-public.js","sourcesContent":["(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i` tag.\n\t * @var {String}\n\t */\n\tvar cookieActiveClass = 'has-cookie';\n\n\t/**\n\t * Creates a cookie.\n\t * @param {String} name The name of the cookie.\n\t * @param {String} value The value of the cookie.\n\t * @param {Integer} days The number of days to store the cookie for.\n\t */\n\tfunction createCookie(name,value,days) {\n\t\tvar expires = \"\";\n\t\tif (days) {\n\t\t\tvar date = new Date();\n\t\t\tdate.setTime(date.getTime() + (days*24*60*60*1000));\n\t\t\texpires = \"; expires=\" + date.toUTCString();\n\t\t}\n\t\tdocument.cookie = name + \"=\" + value + expires + \"; path=/\";\n\t}\n\n\t/**\n\t * Reads a cookie.\n\t * @param {String} name The name of the cookie.\n\t */\n\tfunction readCookie(name) {\n\t\tvar nameEQ = name + \"=\";\n\t\tvar ca = document.cookie.split(';');\n\t\tfor(var i=0;i < ca.length;i++) {\n\t\t\tvar c = ca[i];\n\t\t\twhile (c.charAt(0)==' ') c = c.substring(1,c.length);\n\t\t\tif (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Erases a cookie.\n\t * @param {String} name The name of the cookie.\n\t */\n\tfunction eraseCookie(name) {\n\t\tcreateCookie(name,\"\",-1);\n\t}\n\n\t/**\n\t * Displays the cookie notification.\n\t */\n\tfunction showCookieNotification() {\n\t\t// Make sure cookie notification is displayed.\n\t\t$('.cookie-notification').show();\n\t\t// Add class to body for CSS styling.\n\t\t$('body').addClass(cookieActiveClass);\n\t}\n\n\t/**\n\t * Hides the cookie notification.\n\t */\n\tfunction hideCookieNotification() {\n\t\t// Make sure cookie notification is hidden.\n\t\t$('.cookie-notification').css('opacity', '0');\n\t\tsetTimeout( function() {\n\t\t\t$('.cookie-notification').css('display', 'none');\n\t\t}, 300 );\n\t\t// Add class to body for CSS styling.\n\t\t$('body').removeClass(cookieActiveClass);\n\t}\n\n\t/**\n\t * Returns today's date as an integer in yyyymmdd format.\n\t */\n\tfunction getDateNow() {\n\t\t// New Date instance.\n\t\tconst today = new Date();\n\t\t// Day.\n\t\tlet dd = today.getDate();\n\t\t// Month. January is 0!\n\t\tlet mm = today.getMonth() + 1;\n\t\t// Year.\n\t\tconst yyyy = today.getFullYear();\n\n\t\t// Leading '0' on day.\n\t\tif( dd < 10 ) {\n\t\t\tdd = '0' + dd;\n\t\t}\n\t\t// Leading '0' on month.\n\t\tif (mm < 10 ) {\n\t\t\tmm = '0' + mm;\n\t\t}\n\n\t\treturn parseInt( `${yyyy}${mm}${dd}` );\n\t}\n\n\t// extract country short name (e.g. GB for Great Britain) from google geocode API result\n\tfunction getCountry( addrComponents ) {\n\t\tfor (var i = 0; i < addrComponents.length; i++) {\n\t\t\tif (addrComponents[i].types[0] == \"country\") {\n\t\t\t\treturn addrComponents[i].short_name;\n\t\t\t}\n\t\t\tif (addrComponents[i].types.length == 2) {\n\t\t\t\tif (addrComponents[i].types[0] == \"political\") {\n\t\t\t\t\treturn addrComponents[i].short_name;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Detects country.\n\t * accepted_cookies default value is false.\n\t */\n\tfunction countryDetection( accepted_cookies ) {\n\n\t\t$.ajax({\n\t\t\ttype: \"POST\",\n\t\t\turl: \"https://www.googleapis.com/geolocation/v1/geolocate?key=\" + googleAPIKey,\n\t\t\tdata: JSON.stringify({\n\t\t\t\t\"considerIp\": \"true\",\n\t\t\t}),\n\t\t\tcontentType: 'application/json',\n\t\t\tsuccess: function( data ){\n\n\t\t\t\t// If coordinates are defined...\n\t\t\t\tif ( data.location.lat !== undefined && data.location.lng !== undefined ) {\n\n\t\t\t\t\t/**\n\t\t\t\t\t * Get Country Name\n\t\t\t\t\t * @type {String}\n\t\t\t\t\t */\n\t\t\t\t\t$.get( \"https://maps.googleapis.com/maps/api/geocode/json?latlng=\" + data.location.lat + \", \" + data.location.lng + \"&key=\" + googleAPIKey, function( data ) {\n\n\t\t\t\t\t\tvar country_short_name = getCountry(data.results[0].address_components);\n\n\t\t\t\t\t\t// If the country is not the US.\n\t\t\t\t\t\tif ( country_short_name !== \"US\" ) {\n\t\t\t\t\t\t\t// Display the notification.\n\t\t\t\t\t\t\tinitCookieNotification();\n\n\t\t\t\t\t\t\t// If user accepted cookies, create cookie.\n\t\t\t\t\t\t\tif ( accepted_cookies === true ) {\n\t\t\t\t\t\t\t\t// Create the \"country\" cookie and store it for 31 days.\n\t\t\t\t\t\t\t\tcreateCookie( \"em_cookie_notification_country\", country_short_name, 31 );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// ( Only in the US ) Create the \"country\" cookie and store it for 31 days.\n\t\t\t\t\t\t\tcreateCookie( \"em_cookie_notification_country\", country_short_name, 31 );\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: function( error ){\n\t\t\t\t// Diplay error.\n\t\t\t\tconsole.log( \"💥 Ups! We have an error: \" );\n\t\t\t\tconsole.log( error );\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Initialize the cookie notification.\n\t * Kicks things off.\n\t */\n\tfunction initCookieNotification() {\n\n\t\t// By default, do not show cookie.\n\t\tlet showCookie = false;\n\n\t\t// If there is no cookie set, show notification\n\t\tif ( ! readCookie( 'em_cookie_notification' ) ) {\n\t\t\tshowCookie = true;\n\t\t} else {\n\t\t\tconst cookieValue = JSON.parse( readCookie( 'em_cookie_notification' ) );\n\t\t\t// If effective date is greater than accepted date, continue. User must reacknowledge cookie notification.\n\t\t\t// Also, the effective date must be less than today's date, in case the reackknowledgment is scheduled.\n\t\t\tconst serverEffectiveDate = parseInt( EmCookieNotification.effective ); // The value set in the CMS.\n\t\t\t// If cookie doesn't exist, get today's date.\n\t\t\tconst cookieDateAccepted = ( typeof( cookieValue ) !== \"undefined\" ? cookieValue.dateAccepted : getDateNow() );\n\n\t\t\t// If server effective date is greater than the date user accepted:\n\t\t\tif ( serverEffectiveDate > cookieDateAccepted ) {\n\t\t\t\t// If server effective date has already passed or is equal to today's date:\n\t\t\t\tif ( serverEffectiveDate <= getDateNow() ) {\n\t\t\t\t\tshowCookie = true;\n\t\t\t\t} else {\n\t\t\t\t\t// Don't show cookie.\n\t\t\t\t\t// The effective date is in the future.\n\t\t\t\t\t// User will have to reacknowledge on ' + serverEffectiveDate.\n\t\t\t\t\tshowCookie = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If showCookie is true, show cookie notification and add event handlers.\n\t\tif ( showCookie ) {\n\n\t\t\t// Display the notification.\n\t\t\tshowCookieNotification();\n\n\t\t\t// Add click event to notification button.\n\t\t\t$( '.cookie-notification__button button' ).click(function( e ){\n\t\t\t\te.preventDefault();\n\t\t\t\t// Set the cookie with today's date as the accepted date.\n\t\t\t\tconst cookieValue = {\n\t\t\t\t\tdateAccepted: getDateNow()\n\t\t\t\t}\n\n\t\t\t\t// Only if it's hidden in the US.\n\t\t\t\tif ( hideInUS ) {\n\t\t\t\t\t// Create contry cookie.\n\t\t\t\t\tcountryDetection( true );\n\t\t\t\t}\n\n\t\t\t\t// Create the cookie. Use server setting for expiry date (EmCookieNotification.expiry).\n\t\t\t\tcreateCookie( 'em_cookie_notification', JSON.stringify( cookieValue ), parseInt( EmCookieNotification.expiry ) );\n\n\t\t\t\t// Hide the notification.\n\t\t\t\thideCookieNotification();\n\t\t\t});\n\n\t\t}\n\n\t}\n\n\t/**\n\t * Waits until the document is loaded before kicking things off.\n\t */\n\n\t$(document).ready(function() {\n\n\t\t/**\n\t\t * If we don't want to display the notification in the US\n\t\t * and the \"country\" cookie doesn't exists..\n\t\t * Create one using the \"short name\" version of the country.\n\t\t */\n\t\tif ( hideInUS && ! readCookie( 'em_cookie_notification_country' ) ) {\n\t\t\tcountryDetection();\n\t\t} else {\n\t\t\t/**\n\t\t\t * If we don't want to display the notification in the US\n\t\t\t */\n\t\t\tif ( hideInUS && readCookie( 'em_cookie_notification_country' ) !== \"US\" ) {\n\t\t\t\t// Display the notification.\n\t\t\t\tinitCookieNotification();\n\n\t\t\t/**\n\t\t\t * If we don't care about displaying the notification in the US.\n\t\t\t */\n\t\t\t} else if( hideInUS === false ) {\n\t\t\t\t// Display the notification.\n\t\t\t\tinitCookieNotification();\n\t\t\t}\n\t\t}\n\n\t});\n\n})( jQuery );\n"]}