{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./assets/src/js/grecaptcha-api.js","webpack:///./assets/src/js/events/site-events.js","webpack:///./assets/src/js/utils/url-utils.js","webpack:///./assets/src/js/utils/browser-utils.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","GrecaptchaApi","grecaptcha","window","this","apiScript","document","getElementById","assessmentUrl","siteKeysUrl","actionLogsUrl","challengeKey","challengeUrl","scoreKey","scoreThreshold","getScoreThreshold","currentScore","addOnClickActionLogs","score","options","challengeId","challengeSize","challengeWrapperId","recaptchaInputId","recaptchaChallengeIpt","displayChallenge","getChallenge","callback","classList","remove","verifyCallback","response","keys","retreiveFromSessionStorage","Promise","resolve","url","reject","fetch","method","then","ok","json","data","saveToSessionStorage","action","sitekey","enterprise","ready","execute","token","text","grecaptchaChallengeScript","createElement","src","body","appendChild","addEventListener","recaptchaChallenge","render","size","getKeys","getToken","catch","getParameterByName","getAssessmentScore","event","riskAnalysis","expectedAction","error","that","getRecaptchaActionLogs","actions","forEach","item","href","target","logAction","grecaptchaApi","onRecaptchaChallangeLoad","getScore","dispatchSiteEvent","siteEventNames","ON_RECAPTCHA_LOAD","eventName","siteEventRegistry","dispatchEvent","getEventData","initSiteEvents","Event","detectProduction","location","indexOf","results","RegExp","replace","exec","decodeURIComponent","removeUrlParams","shortUrl","match","history","replaceState","title","deleteFromSessionStorage","sessionStorage","removeItem","JSON","parse","getItem","console","setItem","stringify"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAA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AAS,IACnCuD,EAAWvD,GAAOjC,OAAOwF,SAAShB,KAElCkB,EADQ,IAAIC,OAAJ,OAAkBtH,EAAKuH,QAAQ,UAAW,QAA1C,qBACQC,KAAKL,GAHa,OAInCE,GAGAA,EAAQ,GAGNI,mBAAmBJ,EAAQ,GAAGE,QAAQ,MAAO,MAL3C,I,EAgCTG,gBAxBsB,WAAO,IACzB9D,EAAMjC,OAAOwF,SAAShB,KAEpBwB,EAAW/D,EAAIgE,MADT,aAEK,OAAb,IACFhE,EAAM+D,EAAS,GACfhG,OAAOkG,QAAQC,aAAa,GAAIhG,SAASiG,MAAOnE,M,gFCIlDoE,yBAjB+B,SAAChH,GAGhC,OAF2BW,OAAnBsG,eACOC,WAAWlH,IAC1B,G,EAeAyC,2BAZiC,SAACzC,GAAS,IACnCiH,EAAmBtG,OAAnBsG,eACR,IACE,OAAOE,KAAKC,MAAMH,EAAeI,QAAQrH,IACzC,MAAO6E,GAEP,OADAyC,QAAQzC,MAAMA,GACP,O,EAOTzB,qBAzB2B,SAACpD,EAAKmD,GAGjC,OAF2BxC,OAAnBsG,eACOM,QAAQvH,EAAKmH,KAAKK,UAAUrE,KAC3C","file":"grecaptcha-api.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","import {\n dispatchSiteEvent,\n siteEventNames,\n} from './events/site-events';\nimport { getParameterByName } from './utils/url-utils';\nimport {\n retreiveFromSessionStorage,\n saveToSessionStorage,\n} from './utils/browser-utils';\n\nexport default class GrecaptchaApi {\n constructor() {\n const { grecaptcha } = window;\n this.grecaptcha = grecaptcha;\n this.apiScript = document.getElementById('grecaptcha-api');\n this.assessmentUrl = '/GetRecaptchaAssessmentScore';\n this.siteKeysUrl = '/InitializeRecaptcha';\n this.actionLogsUrl = '/GetRecaptchaActionLogs';\n this.challengeKey = '';\n this.challengeUrl = '';\n this.scoreKey = '';\n this.scoreThreshold = this.getScoreThreshold();\n this.currentScore = -1;\n this.addOnClickActionLogs();\n }\n\n displayChallenge(score) {\n const { scoreThreshold } = this;\n return score < scoreThreshold;\n }\n\n enableFormRecaptcha(options) {\n const {\n challengeId,\n challengeSize,\n challengeWrapperId,\n recaptchaInputId,\n } = options;\n const recaptchaChallengeIpt = document.getElementById(recaptchaInputId);\n if (recaptchaChallengeIpt === null) {\n return;\n }\n if (recaptchaChallengeIpt.value !== '') {\n return;\n }\n if (this.displayChallenge(this.currentScore)) {\n this.getChallenge({\n callback: () => {\n const wrapper = document.getElementById(challengeWrapperId);\n wrapper.classList.remove('hidden');\n },\n challengeId,\n challengeSize,\n verifyCallback: (response) => {\n recaptchaChallengeIpt.value = response;\n },\n });\n } else {\n recaptchaChallengeIpt.value = 'no-challenge-needed';\n }\n }\n\n getKeys() {\n // Check sessionStorage for site keys\n // If they exist, pass along\n const keys = retreiveFromSessionStorage('__grecaptchakeys');\n if (keys) {\n const {\n challengeKey,\n challengeUrl,\n scoreKey,\n } = keys;\n if (challengeKey && challengeUrl && scoreKey) {\n return new Promise((resolve) => {\n // console.log('grecaptcha ----> get keys from sessionStorage');\n resolve(keys);\n });\n }\n }\n // console.log('grecaptcha ----> only execute if no keys found in sessionStorage');\n const url = this.siteKeysUrl;\n return new Promise((resolve, reject) => {\n fetch(url, {\n method: 'POST',\n })\n .then((response) => {\n if (response.ok) {\n response.json().then((data) => {\n saveToSessionStorage('__grecaptchakeys', data);\n resolve(data);\n });\n } else {\n response.json().then(reject);\n }\n });\n });\n }\n\n getToken(action, sitekey) {\n const { grecaptcha } = this;\n return new Promise((resolve, reject) => {\n grecaptcha.enterprise.ready(() => {\n grecaptcha.enterprise.execute(sitekey, { action })\n .then((data) => {\n if (data) {\n resolve(data);\n } else {\n reject();\n }\n });\n });\n });\n }\n\n getAssessmentScore(action, token) {\n const url = `${this.assessmentUrl}?expectedAction=${action}&token=${token}`;\n return new Promise((resolve, reject) => {\n fetch(url, {\n method: 'POST',\n })\n .then((response) => {\n if (response.ok) {\n response.json().then(resolve);\n } else {\n response.text().then(reject);\n }\n });\n });\n }\n\n getChallenge(options) {\n const {\n challengeKey,\n challengeUrl,\n grecaptcha,\n } = this;\n const {\n callback,\n challengeId,\n challengeSize,\n verifyCallback,\n } = options;\n if (!grecaptcha) {\n return -1;\n }\n // Add script\n const grecaptchaChallengeScript = document.createElement('script');\n grecaptchaChallengeScript.src = challengeUrl;\n document.body.appendChild(grecaptchaChallengeScript);\n grecaptchaChallengeScript.addEventListener('load', () => {\n const recaptchaChallenge = grecaptcha.enterprise.render(challengeId, {\n callback: verifyCallback,\n sitekey: challengeKey,\n size: challengeSize || 'normal',\n });\n if (callback) {\n callback(recaptchaChallenge);\n }\n });\n return false;\n }\n\n logAction(options) {\n const { grecaptcha } = this;\n const {\n action,\n callback,\n } = options;\n if (!grecaptcha) {\n if (callback) {\n callback('');\n }\n return;\n }\n // Get keys\n this.getKeys()\n .then((keys) => {\n const {\n challengeKey,\n challengeUrl,\n scoreKey,\n } = keys;\n this.challengeKey = challengeKey;\n this.challengeUrl = challengeUrl;\n this.scoreKey = scoreKey;\n this.getToken(action, this.scoreKey)\n .then((token) => {\n if (callback) {\n callback(token);\n }\n })\n .catch(() => {\n if (callback) {\n callback('');\n }\n });\n });\n }\n\n getScoreThreshold() {\n const { apiScript } = this;\n let scoreThreshold = '';\n if (apiScript) {\n scoreThreshold = getParameterByName('scoreThreshold', apiScript.src);\n }\n return scoreThreshold !== '' ? scoreThreshold : '.5';\n }\n\n /*\n Returns an assessment score for the likelihood user is a human\n Error Codes:\n 0: Error retrieving token, show highest form of RECAPTCHA\n -1: Error loading RECAPTCHA\n -2: Asssessment service not available\n -3: No score available\n -4: expectedAction returned from the RECAPTCHA endpoint does not match submitted action\n */\n getScore(options) {\n const { grecaptcha } = this;\n const {\n action,\n callback,\n } = options;\n if (!grecaptcha || !callback) {\n this.currentScore = -1;\n return this.currentScore;\n }\n // Get keys\n this.getKeys()\n .then((keys) => {\n const {\n challengeKey,\n challengeUrl,\n scoreKey,\n } = keys;\n this.challengeKey = challengeKey;\n this.challengeUrl = challengeUrl;\n this.scoreKey = scoreKey;\n this.getToken(action, this.scoreKey)\n .then((token) => {\n this.getAssessmentScore(action, token)\n .then((data) => {\n try {\n const { event, riskAnalysis } = data;\n const { score } = riskAnalysis;\n const { expectedAction } = event;\n if (expectedAction !== action) {\n this.currentScore = -4;\n callback(this.currentScore);\n }\n this.currentScore = score;\n callback(score);\n } catch (error) {\n this.currentScore = -3;\n callback(this.currentScore);\n }\n })\n .catch(() => {\n this.currentScore = -2;\n callback(this.currentScore);\n });\n })\n .catch(() => {\n this.currentScore = 0;\n callback(this.currentScore);\n });\n });\n this.currentScore = -1;\n return this.currentScore;\n }\n\n getRecaptchaActionLogs() {\n const url = this.actionLogsUrl;\n return new Promise((resolve, reject) => {\n fetch(url, {\n method: 'POST',\n })\n .then((response) => {\n if (response.ok) {\n response.json().then(resolve);\n } else {\n response.json().then(reject);\n }\n });\n });\n }\n\n addOnClickActionLogs() {\n const that = this;\n this.getRecaptchaActionLogs()\n .then((actions) => {\n actions.forEach((item) => {\n const {\n action,\n url,\n } = item;\n document.addEventListener('click', (event) => {\n const { target } = event;\n const { href } = target;\n if (href && href === url) {\n that.logAction({ action });\n }\n });\n });\n });\n }\n}\n\nwindow.grecaptchaApi = new GrecaptchaApi();\nwindow.onRecaptchaChallangeLoad = () => {};\nwindow.grecaptchaApi.getScore({\n action: 'page_load',\n callback: () => {\n dispatchSiteEvent(siteEventNames.ON_RECAPTCHA_LOAD);\n },\n});\n","const siteEventNames = {\n ON_RECAPTCHA_LOAD: 'onrecaptchaload',\n};\n\nconst initSiteEvents = () => {\n if (window.siteEventRegistry) {\n return;\n }\n // Init events and add them to window scope here\n window.siteEventRegistry = {};\n Object.keys(siteEventNames).forEach((key) => {\n const value = siteEventNames[key];\n siteEventRegistry[value] = {\n event: new Event(value),\n data: {},\n }\n });\n};\n\nconst getEventData = (eventName) => {\n const { siteEventRegistry } = window;\n let data = {};\n Object.keys(siteEventRegistry).forEach((key) => {\n if (key === eventName) {\n data = siteEventRegistry[key].data;\n }\n });\n return data;\n}\n\nconst dispatchSiteEvent = (eventName, data) => {\n const { siteEventRegistry } = window;\n Object.keys(siteEventRegistry).forEach((key) => {\n if (key === eventName) {\n const event = siteEventRegistry[key].event;\n siteEventRegistry[key].data = data;\n window.dispatchEvent(event);\n }\n });\n};\n\nexport {\n dispatchSiteEvent,\n getEventData,\n initSiteEvents,\n siteEventNames,\n};\n","const getParameterByName = (name, url) => {\n const location = url || window.location.href;\n const regex = new RegExp(`[?&]${name.replace(/[\\[\\]]/g, '\\\\$&')}(=([^&#]*)|&|#|$)`);\n const results = regex.exec(location);\n if (!results) {\n return '';\n }\n if (!results[2]) {\n return '';\n }\n return decodeURIComponent(results[2].replace(/\\+/g, ' '));\n};\n\nconst removeUrlParams = () => {\n let url = window.location.href;\n const reg = /.+?(?=\\?)/;\n const shortUrl = url.match(reg);\n if (shortUrl !== null) {\n url = shortUrl[0]; // eslint-disable-line prefer-destructuring\n window.history.replaceState({}, document.title, url);\n }\n};\n\n\nconst detectProduction = function() {\n if (\n window.location.href.indexOf('www.horizonshades.com') !== -1 ||\n window.location.href.indexOf('https://horizonshades.com') !== -1 ||\n window.location.href.indexOf('http://horizonshades.com') !== -1\n ) {\n return true;\n }\n return false;\n};\nexport {\n detectProduction,\n getParameterByName,\n removeUrlParams,\n};\n","const saveToSessionStorage = (key, data) => {\n const { sessionStorage } = window;\n sessionStorage.setItem(key, JSON.stringify(data));\n return true;\n};\n\nconst deleteFromSessionStorage = (key) => {\n const { sessionStorage } = window;\n sessionStorage.removeItem(key);\n return true;\n};\n\nconst retreiveFromSessionStorage = (key) => {\n const { sessionStorage } = window;\n try {\n return JSON.parse(sessionStorage.getItem(key));\n } catch (error) {\n console.error(error);\n return null;\n }\n};\n\nexport {\n deleteFromSessionStorage,\n retreiveFromSessionStorage,\n saveToSessionStorage,\n};\n"],"sourceRoot":""}