#  Newsletter Signup

  ` static STYLE_MARKUP = ` ` static createToast = ({type, title, message}) =&gt; { const toast = document.createElement('fc-toast'); toast.setAttribute('data-type', type); toast.setAttribute('data-title', title); toast.setAttribute('data-message', message); return toast; } static createSuccessToast(args) { return fc__Toast.createToast({ title: "Success!", ...args, type: fc__Toast.SUCCESS }); } static createErrorToast(args) { return fc__Toast.createToast({ title: "Error", ...args, type: fc__Toast.ERROR }); } constructor() { super(); this.timeout = fc__Toast.TIMEOUT; const shadowRoot = this.attachShadow({mode: 'open'}); shadowRoot.innerHTML = ` ${fc__Toast.STYLE_MARKUP} ${fc__Toast.TOAST_MARKUP} `; } stopTimeout = () =&gt; { clearTimeout(this.timeoutId); }; hide = () =&gt; { this.stopTimeout(); this.dispatchEvent(new CustomEvent('hide')); this.remove(); }; startTimeout = () =&gt; { this.timeoutId = setTimeout(this.hide, this.timeout); }; get toastElement() { return this.shadowRoot.querySelector('.toast'); } get iconElement() { return this.shadowRoot.querySelector('.toast__icon'); } get titleElement() { return this.shadowRoot.querySelector('.toast__title'); } get messageElement() { return this.shadowRoot.querySelector('.toast__message'); } get closeButtonElement() { return this.shadowRoot.querySelector('.toast__close-button'); } set type(type) { this.toastElement.classList.add(`toast--${type}`); this.iconElement.innerHTML = fc__Toast.ICONS_MAP[type]; } set title(title) { this.titleElement.textContent = title; } set message(message) { this.messageElement.textContent = message; } attributeChangedCallback(attribute, oldValue, newValue) { this[attribute.replace('data-', '')] = newValue; } connectedCallback() { const {toastElement, closeButtonElement, stopTimeout, startTimeout, hide} = this toastElement.addEventListener("mouseenter", stopTimeout); toastElement.addEventListener("mouseleave", startTimeout); closeButtonElement.addEventListener('click', hide); startTimeout(); } } customElements.define('fc-toast', fc__Toast); fc__getToastContainer = (target) =&gt; { const containerClass = "fc--toast__container"; const appendContainer = () =&gt; { const toastContainer = document.createElement("div"); toastContainer.classList.add(containerClass); const form = document.getElementsByClassName(FC__CLASSES.FC_FORM)[0]; const formShadow = target.getRootNode().querySelector("form"); const formToAppend = form || formShadow; formToAppend.appendChild(toastContainer); return toastContainer; }; return ( document.getElementsByClassName(containerClass)[0] ?? appendContainer() ); }; const fc__showToast = async ({type, title, message, target}) =&gt; { return new Promise((resolve) =&gt; { const toast = fc__Toast.createToast({ type, title, message }); toast.addEventListener('hide', function handleHide() { resolve(); toast.removeEventListener('hide', handleHide) }); fc__getToastContainer(target).appendChild(toast); }) } const fc__showSuccessToast = ({ message, target }) =&gt; fc__showToast({ type: fc__Toast.SUCCESS, title: 'Success!', message, target }); const fc__showErrorToast = ({ message, target }) =&gt; fc__showToast({ type: fc__Toast.ERROR, title: 'Error' , message, target }); const fc__isInIframe = () =&gt; { try { return window.self !== window.top; } catch (e) { return true; } }; function fc__handleCancelForm() { const urlDestination = ""; const isInIframe = fc__isInIframe(); if(isInIframe) { window.open(urlDestination, '_blank'); } else { window.location.href = urlDestination; } } const fc__handleValidateMap = { date: fc__handleValidateDate, phoneNumber: fc__handleValidatePhoneNumber, toggle: fc__handleValidateToggle, checkbox: fc__handleValidateCheckbox, } function fc__getSmsCampaigns() { let element = document.getElementsByClassName('fc--sms-number')[0]; const campaignId = element.parentElement.querySelector('.campaign-id').value; const phone = element.value; return {programId: campaignId, phoneNumber: phone}; } function fc__validateForm(formData) { const formRoot = formData.getRootNode(); [...formRoot.querySelectorAll(`[name]:not([type='hidden'])`)].forEach(element =&gt; { const type = element.dataset.fcBlockType; const name = element.attributes.name.value; if(name !== '$sms_consent') { const handleValidate = fc__handleValidateMap[type] ?? fc__handleValidate; handleValidate(element); } }); const errors = formRoot.querySelectorAll(".fc--control-error"); return { numberOfErrors: errors.length, isValid: +errors.length === 0 } } function fc__sendCookie(xmlData) { const parser = new DOMParser(); const xmlDOM = parser.parseFromString(xmlData, 'text/xml'); const spUserId = xmlDOM.getElementsByTagName('spUserId')[0]?.childNodes[0]?.nodeValue; if (spUserId) { document.cookie = `sp-identity-forms-583894300269281280=${spUserId};path=/`; localStorage.setItem(`sp-identity-forms-583894300269281280`, spUserId); }} function fc__handleSubmitErrorMessage(data) { const errorDetails = data?.errorDetails; if(errorDetails) { const errorCode = errorDetails[0]?.errorCode; const errorMessage = errorDetails[0]?.errorMessage; const isInvalidPhoneNumber = errorMessage.includes('ErrorKey: PHONE_FORMAT'); if (isInvalidPhoneNumber){ return FC__SUBMIT_ERRORS_MESSAGES.INVALID_PHONE_NUMBER_VALUE; } else if (Object.keys(FC__SUBMIT_ERRORS_MESSAGES).includes(errorCode)) { return FC__SUBMIT_ERRORS_MESSAGES[errorCode]; } else { return FC__SUBMISSION_MESSAGE.ERROR; } } else { return FC__SUBMISSION_MESSAGE.ERROR; } } function fc__buildConsentGroup(consentGroups) { const parsedConsentGroups = [...consentGroups].reduce((res, { dataset, value }) =&gt; { const { consentChannel, id } = dataset; const consentChannelUpperCase = consentChannel.toUpperCase(); if (!res[id]) { res[id] = { [consentChannelUpperCase]: value, }; } res[id][consentChannelUpperCase] = value; return res; }, {}); const consentGroupsIds = Object.keys(parsedConsentGroups); return consentGroupsIds.map(consentGroupId =&gt; ({ consentGroupId, channels: parsedConsentGroups[consentGroupId], }) ); } function fc__buildConsentOptions() { try { const consentSelections = JSON.parse("[{}]".replaceAll('"','"')) const formType = 'update'; const isDoubleOptIn = formType === 'double-opt-in'; const isSingleOptIn = formType === 'opt-in'; const isOptOut = formType === 'opt-out'; const STATUS_TYPES = { OPT_OUT: "OPT_OUT", OPT_IN: "OPT_IN", OPT_IN_UNVERIFIED: "OPT_IN_UNVERIFIED" }; const CHANNELS_MAP = { EMAIL: "EMAIL", SMS: "SMS", WHATSAPP: "WHATSAPP", }; let channelValue = ""; return consentSelections.map(({id, channels, hasSelections})=&gt; { if(!hasSelections.value) return; const parsedChannels = channels.reduce((acc, value)=&gt; { Object.keys(value).forEach(channel =&gt; { const upperCaseChannel = channel.toUpperCase(); if (isSingleOptIn) channelValue = STATUS_TYPES.OPT_IN; if (isOptOut) channelValue = STATUS_TYPES.OPT_OUT; if (isDoubleOptIn &amp;&amp; upperCaseChannel === CHANNELS_MAP.EMAIL) channelValue = STATUS_TYPES.OPT_IN_UNVERIFIED; if(value[channel].value) { acc[upperCaseChannel] = channelValue; } }); return acc; },{}); return {consentGroupId: id, channels: parsedChannels}; }).filter(Boolean); } catch(e) { console.error(e); } } async function fc__handleSubmit(formData, event) { event.preventDefault(); const target = event.target; const isEmbededForm = target.classList.contains("embeded-form"); const { numberOfErrors, isValid } = fc__validateForm(formData); if (!isValid) { fc__showErrorToast({ message: `The Form submission failed. Review ${numberOfErrors} ${numberOfErrors &gt; 1 ? 'errors' : 'error'} in this form and try again.` , target: target}); return; } const isRecaptcha = $(FC__SELECTORS.RECAPTCHA_ERROR).length &gt; 0; if (isRecaptcha &amp;&amp; grecaptcha.getResponse() == ""){ $(FC__SELECTORS.RECAPTCHA_ERROR).show(); $(FC__SELECTORS.RECAPTCHA_ERROR).parent().parent().addClass("fc--block-error"); return false; } $(FC__SELECTORS.SUBMIT_BUTTON).attr("disabled", true); $(FC__SELECTORS.SUBMIT_BUTTON).css('pointer-events', 'none'); $(FC__SELECTORS.SUBMIT_TEXT).hide(); $(FC__SELECTORS.LOADING_INDICATOR).show(); try { let data = new FormData(formData);const checkboxValues = []; const values = [...new Set([...data.keys()])] .filter((key) =&gt; { const input = document.querySelector(`input[name="${key}"]`); return input &amp;&amp; input.getAttribute("data-fc-block-type") === "checkbox"; }) .forEach((key) =&gt; { const values = data.getAll(key).filter((value) =&gt; !!value); if (!values.length) { values.push(""); } data.delete(key); values.forEach((value) =&gt; { data.append(key, value); checkboxValues.push([`${key.replaceAll(' ', '+')}=${value.replaceAll(' ', '+')}`, [key, value]]); }); }); if(document.getElementsByClassName('fc--sms-number').length &gt; 0) { data.append('send_MO_message', JSON.stringify(fc__getSmsCampaigns())); } const body = new URLSearchParams(data); if (body.get('snooze') === "true" &amp;&amp; !body.get('snooze-days')) { body.delete('snooze'); } const submitUrl = 'https://app.goacoustic.com/content/api/delivery/v1/contact/15249890'; const consentGroupInputs = document.querySelectorAll(`input[data-consent-group]`); if (consentGroupInputs.length) { body.append('consentGroups', JSON.stringify(fc__buildConsentGroup(consentGroupInputs))); } const hasConsentSelections = "false"; const formType = 'update'; const isConsentSettingsFormType = formType === 'opt-in' || formType === 'opt-out' || formType === 'double-opt-in'; if(hasConsentSelections &amp;&amp; isConsentSettingsFormType) { body.append('consentGroups', JSON.stringify(fc__buildConsentOptions())); } const response = await fetch(submitUrl, { method: 'POST', body: body, headers: { 'x-acoustic-region': 'us-east-1', 'x-ibm-dx-tenant-id': '43d24b77-a1cd-4294-b150-75daaba0cad7' }, }); const isConfirmationPageOn = true; const urlDestination = ""; const areCookiesAccepted = localStorage.getItem('cookiesAccepted-583894300269281280'); let isAutoPopulate = false;const responseText = await response.text(); if (areCookiesAccepted || isAutoPopulate) { fc__sendCookie(responseText); } if (response.ok) { if (isEmbededForm) { fc__showSuccessToast({ message: FC__SUBMISSION_MESSAGE.SUCCESS, target: target }) } else { if (isConfirmationPageOn) { window.location.href = `https://content-us-1.content-cms.com/api/43d24b77-a1cd-4294-b150-75daaba0cad7/forms/583894300269281280?rcPage=confirmation`; } else { window.location.href = urlDestination; } } } else { let data = null; try { data = JSON.parse(responseText); } catch (e) { data = null; } fc__showErrorToast({ message: fc__handleSubmitErrorMessage(data), target: target }) $(FC__SELECTORS.SUBMIT_BUTTON).attr("disabled", false); $(FC__SELECTORS.SUBMIT_BUTTON).css('pointer-events', 'auto'); $(FC__SELECTORS.SUBMIT_TEXT).show(); $(FC__SELECTORS.LOADING_INDICATOR).hide(); } } catch (error) { fc__showErrorToast({ message: FC__SUBMISSION_MESSAGE.ERROR, target: target }); } } function fc__toggleDropdownMenu(elem) { $(elem) .parents(FC__SELECTORS.DROPDOWN) .toggleClass(FC__CLASSES.DROPDOWN_OPEN); } function fc__closeDropdownMenu(elem) { $(elem) .parents(FC__SELECTORS.DROPDOWN) .removeClass(FC__CLASSES.DROPDOWN_OPEN); } function fc__openDropdownMenu(elem) { $(elem) .parents(FC__SELECTORS.DROPDOWN) .addClass(FC__CLASSES.DROPDOWN_OPEN); } function fc__focusFirstOption(elem) { $(elem) .parents(FC__SELECTORS.DROPDOWN) .children(FC__SELECTORS.DROPDOWN_MENU) .children(FC__SELECTORS.DROPDOWN_MENU_ITEM) .first() .focus(); } function fc__focusNextOption(elem) { const options = $(elem).parent().children(); const nextElementIndex = options.index($(elem).next()); options .slice(nextElementIndex) .filter(FC__SELECTORS.DROPDOWN_MENU_ITEM) .first() .focus(); } function fc__focusPreviousOption(elem) { const options = $(elem).parents(FC__SELECTORS.DROPDOWN_MENU).children(); const prevElementIndex = options.index(elem); options .slice(0, prevElementIndex) .filter(FC__SELECTORS.DROPDOWN_MENU_ITEM) .last() .focus(); } function fc__focusPlaceholder(elem) { $(elem) .parents(FC__SELECTORS.DROPDOWN) .children(FC__SELECTORS.DROPDOWN_FIELD) .focus(); } function fc__selectOption(elem) { const value = $(elem).closest('.fc--dropdown__menu-item').attr("data-value"); const label = $(elem).closest('.fc--dropdown__menu-item').html(); const dropdown = $(elem).parents(FC__SELECTORS.DROPDOWN); const select = dropdown.children(FC__SELECTORS.DROPDOWN_SELECT) if (dropdown[0].classList.contains(FC__CLASSES.PHONE_DROPDOWN)){ const phoneBlock = elem.closest('.fc--phone-element'); const phoneDropdownField = phoneBlock.querySelector('.fc--phone-dropdown__field'); phoneDropdownField.dataset.value = value; } select.val([value]); dropdown.find(FC__SELECTORS.DROPDOWN_FIELD_VALUE).html(label) ; fc__handleValidate(select[0]); } function fc__showSelectedItem(elem){ const dropdownMenu = elem.closest(FC__SELECTORS.DROPDOWN_MENU); const dropdownMenuList = dropdownMenu.querySelectorAll(FC__SELECTORS.DROPDOWN_MENU_ITEM); dropdownMenuList.forEach(item =&gt; item.classList.remove(FC__CLASSES.DROPDOWN_ITEM_ACTIVE)); elem.closest(FC__SELECTORS.DROPDOWN_MENU_ITEM).classList.add(FC__CLASSES.DROPDOWN_ITEM_ACTIVE); } function fc__handleClick(event) { fc__selectDefaultDropdownItem(event.target); fc__toggleDropdownMenu(event.target); } function fc__selectDefaultDropdownItem(target){ const element = target.closest(FC__SELECTORS.DROPDOWN_FIELD); const dropdown = target.closest(FC__SELECTORS.DROPDOWN); const dropdownMenuList = dropdown.querySelectorAll(FC__SELECTORS.DROPDOWN_MENU_ITEM); const convertToArray = Array.from(dropdownMenuList); let findElement; if (dropdown.classList.contains(FC__CLASSES.PHONE_DROPDOWN)){ findElement = convertToArray.find(item =&gt; item.dataset.value === element.dataset.value); }else { findElement = convertToArray.find(item =&gt; item.textContent.trim() === element.querySelector('span').textContent.trim()); } findElement &amp;&amp; findElement.classList.add(FC__CLASSES.DROPDOWN_ITEM_ACTIVE); } function fc__handleOptionClick(event) { fc__showSelectedItem(event.target); fc__selectOption(event.target); fc__closeDropdownMenu(event.target); fc__focusPlaceholder(event.target); fc__phoneValidationAfterChange(event.target); } function fc__phoneValidationAfterChange(target) { const phoneBlock = target.closest('.fc--phone-element') const phoneDropdown = target.closest('.fc--phone-dropdown') if (phoneBlock &amp;&amp; phoneDropdown){ const inputToStore = phoneBlock.querySelector('.fc--phone--input'); inputToStore.textContent &amp;&amp; fc__handleValidatePhoneNumber(inputToStore); } } function fc__handleKeyDown(event) { switch (event.key) { case FC__KEYS.SPACE: case FC__KEYS.ENTER: fc__toggleDropdownMenu(event.target); break; case FC__KEYS.ARROW_DOWN: case FC__KEYS.ARROW_UP: fc__openDropdownMenu(event.target); fc__focusFirstOption(event.target); break; case FC__KEYS.ESCAPE: fc__focusPlaceholder(event.target); fc__closeDropdownMenu(event.target); break; default: break; } } function fc__handleOptionKeyDown(event) { switch (event.key) { case FC__KEYS.ARROW_DOWN: fc__focusNextOption(event.target); break; case FC__KEYS.ARROW_UP: fc__focusPreviousOption(event.target); break; case FC__KEYS.ESCAPE: fc__closeDropdownMenu(event.target); fc__focusPlaceholder(event.target); break; case FC__KEYS.ENTER: case FC__KEYS.SPACE: fc__selectOption(event.target); fc__closeDropdownMenu(event.target); fc__focusPlaceholder(event.target); break; default: break; } } function fc__phoneSearch(event) { const filter = event.target.value.toUpperCase(); const phoneDropdown = event.target.closest('.fc--phone-dropdown'); const phoneDropdownMenu = phoneDropdown.querySelector('.fc--phone-dropdown__menu'); const phoneDropdownMenuDivider = phoneDropdown.querySelector('.fc--dropdown__menu-divider'); const phoneDropdownMenuItems = phoneDropdownMenu.querySelectorAll(".fc--phone-dropdown__menu-item"); const convertToArray = Array.from(phoneDropdownMenuItems); phoneDropdownMenuItems.forEach((item, key) =&gt; { const textValue = phoneDropdownMenuItems[key].getAttribute('data-value'); const getNumberValue = item.querySelector('.fc--phone-dropdown__number').textContent; if (textValue.toUpperCase().indexOf(filter) &gt; -1 || getNumberValue.indexOf(filter) &gt; -1 ) { phoneDropdownMenuItems[key].style.display = ""; } else { phoneDropdownMenuItems[key].style.display = "none"; } }); const noResultElement = phoneDropdownMenu.querySelector('.fc--phone-dropdown__menu-no-items') const checkList = convertToArray.some(item =&gt; item.style.display === ""); if (!checkList &amp;&amp; !noResultElement){ const noResultEl = document.createElement("p"); noResultEl.classList.add("fc--phone-dropdown__menu-no-items"); const node = document.createTextNode("No results found."); phoneDropdownMenuDivider.style.display = "none"; noResultEl.appendChild(node); phoneDropdownMenu.appendChild(noResultEl); } else if (checkList &amp;&amp; noResultElement){ phoneDropdownMenuDivider.style.display = ""; noResultElement.remove(); } } function fc__handleBodyClick(event) { $(FC__SELECTORS.DROPDOWN_OPEN) .filter((_, dropdown) =&gt; !$(event.target).closest(dropdown).length) .removeClass(FC__CLASSES.DROPDOWN_OPEN); } function fc__handleSelectAll(source) { const checkboxes = source.parentElement.parentElement.parentElement.querySelectorAll('input[type="checkbox"]') ; const toggleValue = !checkboxes[0].checked; checkboxes.forEach(checkbox =&gt; { checkbox.checked = toggleValue; }) } function fc__handleToggle(source, field) { const checkbox = source.querySelector('input[type="checkbox"]') const labelText = source.parentNode.parentNode.querySelector('.fc--toggle-text') const checkIcon = source.parentNode.querySelector('.fc--toggle-icon') const offValue = source.querySelector('[data-toggle="toggle-off-value"]'); offValue.value = checkbox.checked ? '' : 'No'; offValue.name = checkbox.checked ? '' : field; labelText.innerText = checkbox.checked ? source.dataset.onLabel : source.dataset.offLabel checkIcon.style.visibility = checkbox.checked ? 'visible' : 'hidden'; } function fc__handleSelectAllConsent(channel) { const [selectAll, ...consentGroupsChannelToggles] = document.querySelectorAll(`input[data-consent-channel=${channel.toLowerCase()}]`); const isSelectAllToggleChecked = selectAll.checked; consentGroupsChannelToggles.forEach((consentGroupsChannelToggle) =&gt; { if (isSelectAllToggleChecked) { consentGroupsChannelToggle.checked = true; consentGroupsChannelToggle.value = "OPT_IN"; return; } consentGroupsChannelToggle.checked = false; consentGroupsChannelToggle.value = "OPT_OUT"; }) } function fc__handleConsentToggle(source) { if (!source) return; if(source.checked) { source.value = "OPT_IN"; return; } source.value = "OPT_OUT"; } function fc__handleDateChange(source, dateFormat) { const textInput = source.parentElement.parentElement.querySelector('.fc--text-default-value'); const dateInputValue = source.value; if(dateInputValue) { const date = dateInputValue.split('-'); const year = date[0]; const month = date[1]; const day = date[2]; textInput.value = dateFormat.replace('MM', month).replace('DD', day).replace('YYYY', year); } else { textInput.value = ''; } fc__handleValidateDate(textInput) } function fc__handleCalendarClick(source, dateFormat, requirements) { const dateInput = source; const textInput = source.parentElement.parentElement.querySelector('.fc--text-default-value'); const dateIsValid = JSON.stringify(new Date(textInput.value)) !== "null"; const isValidateOn = requirements[1]; if (isValidateOn) { requirements[0]?.forEach(item =&gt; { const calendarFormat = 'YYYY-MM-DD'; if (item.selected === 'dateFrom') { const { dateFrom } = item.dateFrom; dateInput.min = getDate(dateFrom, calendarFormat); } if (item.selected === 'dateTo') { const { dateTo } = item.dateTo; dateInput.max = getDate(dateTo, calendarFormat); } if (item.selected === 'dateRange') { const { dateTo, dateFrom } = item.dateRange; dateInput.min = getDate(dateFrom, calendarFormat); dateInput.max = getDate(dateTo, calendarFormat); } }); } if (dateIsValid) { dateInput.value = correctDateFormat(textInput.value, dateFormat); } else { textInput.value = ''; dateInput.value = ''; } } const yearReg = '([1-2][0-9][0-9][0-9]|20[0-9][0-9])'; const monthReg = '(0[1-9]|1[0-2])'; const dayReg = '(0[1-9]|1[0-9]|2[0-9]|3[0-1])'; const getRegex = format =&gt; { if (format === 'DD/MM/YYYY') return new RegExp(`^${dayReg}/${monthReg}/${yearReg}$`, 'g'); else if (format === 'MM/DD/YYYY') return new RegExp(`^${monthReg}/${dayReg}/${yearReg}$`, 'g'); else if (format === 'YYYY/MM/DD') return new RegExp(`^${yearReg}/${monthReg}/${dayReg}$`, 'g'); return null; }; const correctNumericFormat = (value) =&gt; value 0[1-9]|[1-2]\d|30|31)/; const monthRegExp = /(?0\[1-9\]|10|11|12)/; const yearRegExp = /(?\\d{4})/; const regExpString = dateFormat .replace('YYYY', yearRegExp.source) .replace('MM', monthRegExp.source) .replace('DD', dayRegExp.source) return new RegExp(regExpString); } function convertDate({value, fromFormat, toFormat}) { const { groups: { day, month, year } } = toDateRegExp(fromFormat).exec(value); return toFormat .replace('YYYY', year) .replace('MM', month) .replace('DD', day); } function correctDateFormat (text, dateFormat) { const calendarFormat = "YYYY-MM-DD"; const dateRegExp = toDateRegExp(dateFormat); if (!dateRegExp.test(text)) { return ''; } return convertDate({ value: text, fromFormat: dateFormat, toFormat: calendarFormat, }); } function parseDateErrorMessage(errorMessage, date, format) { const formattedDate = convertDate({ value: date, fromFormat: FC\_\_CALENDAR\_DATE\_FORMAT, toFormat: format, }) return errorMessage.replace(format, formattedDate); } function fc\_\_handleArrowClick(event, source, direction) { event.preventDefault(); const numberInput = source.parentElement.parentElement.querySelector('input\[type="number"\]'); if(direction === 'up') { numberInput.value++; fc\_\_handleValidate(numberInput); } if(direction === 'down') { numberInput.value--; fc\_\_handleValidate(numberInput); } } function fc\_\_validateUrlFormat(value, requirement) { if (!value) { return; } const { errorMessage } = requirement; const regex = /^(((https?:\\/\\/)?www\\.(\[^\\.\\/\]+)+)|((?!https?:\\/\\/)(?!www)(\[^\\.\\/\]+)+)|(https?:\\/\\/(?!www)(\[^\\.\\/\]+)+)|((https?:\\/\\/)?(\[^\\.\\/\]+)(\\.\[^\\.\\/\]+)))(\\.\[^\\.\\/\])\*(\\.\[^\\.\\/\]{2,}).\*$/; const isValid = regex.test(value); if (!isValid) { return errorMessage; } } function fc\_\_validateRegex(value, requirement) { if (!value) { return; } const { errorMessage, regex } = requirement; const regexString = new RegExp(regex); const isValid = regexString.test(value); if (!isValid) { return errorMessage; } } function fc\_\_validateMaxCharacters(value, requirement) { if (!value) { return; } const { errorMessage, maxCharacters } = requirement; const regexString = `^.{0,${maxCharacters}}$`; const regex = new RegExp(regexString); const isValid = regex.test(value); if (!isValid) { return errorMessage; } } function fc\_\_validateMinCharacters(value, requirement) { if (!value) { return; } const { errorMessage, minCharacters } = requirement; const regexString = `^.{${minCharacters},}$`; const regex = new RegExp(regexString); const isValid = regex.test(value); if (!isValid) { return errorMessage; } } function fc\_\_validateNumbersOnly(value, requirement) { if (!value) { return; } const { errorMessage } = requirement; const isValid = /^\[0-9\]+$/.test(value); if (!isValid) { return errorMessage; } } function fc\_\_validateAlphabeticalOnly(value, requirement) { if (!value) { return; } const { errorMessage } = requirement; const isValid = /^\[a-zA-Z\]+$/.test(value); if (!isValid) { return errorMessage; } } function fc\_\_validateZipCode(value, requirement) { if (!value) { return; } const { errorMessage } = requirement; const isValid = /^\[0-9\]{5}(?:-\[0-9\]{4})?$/.test(value); if (!isValid) { return errorMessage; } } function fc\_\_validateExcludeCharacters(value, requirement) { if (!value) { return; } const { errorMessage, excludeCharacters } = requirement; const excludedCharactersArr = excludeCharacters ? excludeCharacters.split(' ') : \[\]; const isValid = !excludedCharactersArr.some(excluded =&gt; value.includes(excluded)); if (!isValid) { return errorMessage; } } function fc\_\_validateRequired(value) { if (!value || (value.className &amp;&amp; !value.value)){ return 'This field is required.'; } } function fc\_\_validateRequiredToggle(value, requirements, context) { if (!/on/i.test(value)) { return 'This field is required.'; } } function fc\_\_validateRequiredCheckbox(value, requirements, context) { const {name} = context; const hasValue = \[...document.querySelectorAll(`\[name="${name}"\]`)\] .filter(e =&gt; e.type === 'checkbox') .some(e =&gt; !!e.checked); if (!hasValue) { return 'This field is required'; } } function fc\_\_validateRequiredPhoneNumber(value, requirements, context) { if(value.value == "" || (value.value.indexOf("+") !== -1 &amp;&amp; value.value.split(" ")\[1\] == "")) { return 'This field is required.'; } } function fc\_\_validateDateFormat(formattedDate, requirement, context) { const { dateFormat } = context; const dateRegExp = toDateRegExp(dateFormat); if (formattedDate &amp;&amp; !dateRegExp.test(formattedDate)) { return `Enter date in ${dateFormat} format.`; } } function fc\_\_validateDateFrom(formattedDate, requirement, context) { const { dateFormat } = context; const dateRegExp = toDateRegExp(dateFormat); if (!dateRegExp.test(formattedDate)) { return; } const { dateFrom: dateFromString, errorMessage } = requirement; const dateString = convertDate({ value: formattedDate, fromFormat: dateFormat, toFormat: FC\_\_CALENDAR\_DATE\_FORMAT, }); const date = new Date(dateString).getTime(); const dateFrom = new Date(dateFromString).getTime(); if (date dateTo) { return parseDateErrorMessage(errorMessage, dateToString, dateFormat); } } function fc\_\_validateDateRange(formattedDate, requirement, context) { const { dateFormat } = context; const dateRegExp = toDateRegExp(dateFormat); if (!dateRegExp.test(formattedDate)) { return; } const { dateTo: dateToString, dateFrom: dateFromString, errorMessage } = requirement; const dateString = convertDate({ value: formattedDate, fromFormat: dateFormat, toFormat: FC\_\_CALENDAR\_DATE\_FORMAT, }); const date = new Date(dateString).getTime(); const dateTo = new Date(dateToString).getTime(); const dateFrom = new Date(dateFromString).getTime(); if (date dateTo) { return errorMessage } } function fc\_\_validateEmailFormat(value, requirement) { if (!value) { return } const { errorMessage } = requirement; const emailFormatRegExp = /.\*@.\*/; if (!emailFormatRegExp.test(value)) { return errorMessage; } } function fc\_\_validateSpecificDomain(value, requirement) { if (!value) { return } const {domainName, errorMessage} = requirement; const regexString = `(\[\\s\]?)@${domainName}`; const regex = new RegExp(regexString, "g"); const isValid = regex.test(value); if(!isValid) { return errorMessage; } } function fc\_\_validateNumberFrom(value, requirement) { if (!value) { return } const { numberFrom, errorMessage } = requirement; if (Number(value) numberTo) { return errorMessage; } } function fc\_\_validateNumberRange(value, requirement) { if (!value) { return } const { numberFrom, numberTo, errorMessage } = requirement; if (Number(value) numberTo) { return errorMessage; } } function fc\_\_validatePhoneNumberCharacters({ value }) { const isValid = /^(\[\\d()+-\]\\s?)+$/.test(value); const splittedValue = value.split(' '); const hasCountryCodeSeparated = value &amp;&amp; splittedValue\[1\] &amp;&amp; value.search(/\[+\]/) &gt; -1; const hasCountryCode = value &amp;&amp; !splittedValue\[1\] &amp;&amp; value.search(/\[+\]/) &gt; -1; let countryCodeLength = 0; if (hasCountryCodeSeparated){ countryCodeLength = value.split(' ')\[0\].length + 1; } if (hasCountryCode){ countryCodeLength = 1; } if (!isValid &amp;&amp; value) { return 'Add numbers, special characters, and space only.'; } else if (value &amp;&amp; value.length -1) { const countryCode = target.value.split(' ')\[0\].replace('+', ''); const dropdownField = phoneBlock.querySelector('.fc--phone-dropdown\_\_field'); const countryNameField = dropdownField || phoneBlock.querySelector('.fc--phone-dropdown\_\_flag'); const countryName = countryNameField ? countryNameField.getAttribute('data-value') : null; const parsePhoneNumber = phoneNumberParsers\[countryCode\]; const phoneNumberErrors = fc\_\_validatePhoneNumberCharacters(target); if (!countryName || !parsePhoneNumber || phoneNumberErrors) { return } if (parsePhoneNumber(phoneNumber) !== countryName) { return dropdownField ? `Enter a phone number from ${countryName} or select a country code matching the number you entered.` : `Enter a phone number from ${countryName}. The phone number you entered is from ${parsePhoneNumber( phoneNumber, )}.` } } } function fc\_\_validatePhoneNumberBrackets({ value, dataset }) { const isValid = /^(\[\\d()+-\]\\s?)+$/.test(value); const characters = value.split(''); const numberOfRightBrackets = characters.filter(item =&gt; item === '(').length; const numberOfLeftBrackets = characters.filter(item =&gt; item === ')').length; if (isValid &amp;&amp; value &amp;&amp; numberOfRightBrackets !== numberOfLeftBrackets &amp;&amp; !dataset.format) { return 'Add a missing bracket.'; } } function fc\_\_validatePhoneNumberCountryCode(target) { const phoneBlock = target.closest('.fc--phone-element'); const inputValueWithPlus = target.value.search(/\[+\]/); if (phoneBlock &amp;&amp; inputValueWithPlus &gt; -1) { const countryCode = target.value.split(' ')\[0\]; const phoneDefaultCodeWrap = phoneBlock.querySelector('.fc--phone-default\_\_item'); const countryCodeList = phoneBlock.querySelectorAll('.fc--phone-dropdown\_\_item'); const countryCodeArray = Array.from(countryCodeList); if (phoneDefaultCodeWrap) { const phoneDefaultItem = phoneBlock.querySelector('.fc--phone-dropdown\_\_number'); const errorText = 'The phone number you enter must have the same country code as the predefined code.'; const condition = phoneDefaultItem.textContent.trim() === countryCode; if (!condition) { return errorText; } } else if (countryCodeArray.length) { const foundCountryCode = countryCodeArray.find( item =&gt; item.querySelector('.fc--phone-dropdown\_\_number').textContent.trim() === countryCode, ); const errorText = 'The phone number you enter must have the same country code as one of the codes on the list.'; if (!foundCountryCode) { return errorText; } } } } function fc\_\_validatePhoneNumberFormatting({value, dataset}) { const isValid = /^(\[\\d()+-\]\\s?)+$/.test(value); if (isValid &amp;&amp; dataset.format){ if (value\[0\] === '+'){ const phoneCode = value.split(' ')\[0\]; return fc\_\_checkPhoneFormatError(value, dataset, phoneCode) }else { return fc\_\_checkPhoneFormatError(value, dataset) } } } function fc\_\_checkPhoneFormatError(value, dataset, phoneCode = -1) { const phoneWithoutCode = value.slice(phoneCode.length + 1).replace(/\[()+-\]?\\s?/g, '').length; if (phoneWithoutCode &amp;&amp; phoneWithoutCode !== 10){ return `The phone number should follow the ${dataset.format} format.`; } } const validationsMap = { numbersOnly: fc\_\_validateNumbersOnly, alphabeticalCharactersOnly: fc\_\_validateAlphabeticalOnly, zipCode: fc\_\_validateZipCode, excludeCharacters: fc\_\_validateExcludeCharacters, maxCharacters: fc\_\_validateMaxCharacters, minCharacters: fc\_\_validateMinCharacters, isRequired: fc\_\_validateRequired, requiredToggle: fc\_\_validateRequiredToggle, requiredCheckbox: fc\_\_validateRequiredCheckbox, requiredPhoneNumber: fc\_\_validateRequiredPhoneNumber, regex: fc\_\_validateRegex, urlFormat: fc\_\_validateUrlFormat, dateFormat: fc\_\_validateDateFormat, dateFrom: fc\_\_validateDateFrom, dateTo: fc\_\_validateDateTo, dateRange: fc\_\_validateDateRange, emailFormat: fc\_\_validateEmailFormat, specificDomain: fc\_\_validateSpecificDomain, numberFrom: fc\_\_validateNumberFrom, numberTo: fc\_\_validateNumberTo, numberRange: fc\_\_validateNumberRange, phoneNumberCharacters: fc\_\_validatePhoneNumberCharacters, phoneNumberCountryCodeMatch: fc\_\_validatePhoneNumberCountryCodeMatch, phoneNumberBrackets: fc\_\_validatePhoneNumberBrackets, phoneNumberCountryCode: fc\_\_validatePhoneNumberCountryCode, phoneNumberFormatting: fc\_\_validatePhoneNumberFormatting, } function fc\_\_validateValue(value, requirements, context) { return requirements.reduce((errors, requirement) =&gt; { const { selected } = requirement; const validate = validationsMap\[selected\]; if (validate) { const error = validate(value, requirement\[selected\], context); if (error) { return \[...errors, error\]; } } return errors; }, \[\]); } function getControlErrorElement(blockElement) { const controlErrorElement = $(blockElement).find('.fc--control-errors'); if (!controlErrorElement.length) { const errorContainer = document.createElement('div') errorContainer.classList.add('fc--control-errors'); blockElement.append(errorContainer); } return $(blockElement).find('.fc--control-errors'); } function fc\_\_setErrors(target, errors) { const blockElement = $(target).parents('.fc--block\_\_element'); const controlErrorElement = getControlErrorElement(blockElement); const isValid = errors.length { const errorElement = document.createElement('div'); errorElement.classList.add('fc--control-error'); errorElement.innerText = error; return errorElement; }); controlErrorElement.empty(); controlErrorElement.html(errorElements); } function fc\_\_parseTargetAttrs(target) { const { name } = target; let value = target.value; const formShadow = target.getRootNode().querySelector("form"); const formElement = formShadow || document.querySelector('form'); if (name &amp;&amp; formElement){ value = new FormData(formElement).getAll(name)?.\[0\]; } const requirements = JSON.parse(target.dataset.fcValidations ?? "\[\]"); const required = JSON.parse(target.dataset.fcRequired ?? "false"); const context = JSON.parse(target.dataset.fcContext ?? "{}"); if (required) { requirements.unshift({ selected: 'isRequired' }); } return { value, requirements, context }; } function fc\_\_handleValidate(target) { if (!target.name) { return; } const { value, requirements, context } = fc\_\_parseTargetAttrs(target); const errors = fc\_\_validateValue(value, requirements, context); fc\_\_setErrors(target, errors); } function fc\_\_handleValidateDate(target) { const { value, requirements, context } = fc\_\_parseTargetAttrs(target); requirements.unshift({selected: 'dateFormat'}); const errors = fc\_\_validateValue(value, requirements, context); fc\_\_setErrors(target, errors); } function fc\_\_handleValidateToggle(target) { const { requirements, context } = fc\_\_parseTargetAttrs(target); const validateRequired = requirements.find(({selected}) =&gt; selected === 'isRequired'); if (validateRequired) { const index = requirements.indexOf(validateRequired); requirements.splice(index, 1); requirements.unshift({ selected: 'requiredToggle' }) } const toggleValue = target.checked ? 'on' : 'off'; const errors = fc\_\_validateValue(toggleValue, requirements, context); fc\_\_setErrors(target, errors); } function fc\_\_handleValidatePhoneNumber(target) { const { requirements, context } = fc\_\_parseTargetAttrs(target); requirements.unshift({selected: 'phoneNumberCharacters'}); requirements.unshift({selected: 'phoneNumberBrackets'}); requirements.unshift({selected: 'phoneNumberCountryCode'}); requirements.unshift({selected: 'phoneNumberFormatting'}); requirements.unshift({selected: 'phoneNumberCountryCodeMatch'}); const validateRequired = requirements.find(({selected}) =&gt; selected === 'isRequired'); if (validateRequired) { const index = requirements.indexOf(validateRequired); requirements.splice(index, 1); requirements.unshift({ selected: 'requiredPhoneNumber' }); } const errors = fc\_\_validateValue(target, requirements, context); fc\_\_setErrors(target, errors); } function fc\_\_handleValidateCheckbox(target) { const { requirements, context } = fc\_\_parseTargetAttrs(target); const validateRequired = requirements.find(({selected}) =&gt; selected === 'isRequired'); if (validateRequired) { const index = requirements.indexOf(validateRequired); requirements.splice(index, 1); requirements.unshift({ selected: 'requiredCheckbox' }) } const errors = fc\_\_validateValue(target, requirements, {...context, name: target.name}); fc\_\_setErrors(target, errors); } document.addEventListener("DOMContentLoaded", function(event) { const recaptchaBlock = document.querySelector(".fc--recaptcha"); if (recaptchaBlock) { recaptchaBlock.style.display = 'none'; } let isPreviewMode = false; try { isPreviewMode = window.parent.location.pathname.search('preview') !== -1; } catch(e) { isPreviewMode = false; } if (isPreviewMode) { const cancelButton = document.querySelector(".fc--cancel-button"); const cookieButton = document.querySelector(".fc--cookie-button"); const submitButton = document.querySelector(".fc--submit-button"); submitButton.classList.add("fc--no-event"); if (cancelButton){ cancelButton.classList.add("fc--no-event"); } if (cookieButton){ cookieButton.style.pointerEvents = 'none'; } const form = document.querySelector(".fc--form"); form.style.maxHeight = 'calc(100vh - 50px)'; form.style.overflow = 'auto'; } const cookieDisclaimer = document.querySelector(".fc--cookie-disclaimer"); const areCookiesAccepted = localStorage.getItem('cookiesAccepted-583894300269281280'); if (!isPreviewMode &amp;&amp; cookieDisclaimer &amp;&amp; !areCookiesAccepted) { cookieDisclaimer.style.display = 'block'; } if (document.querySelector(FC\_\_SELECTORS.RECAPTCHA\_ERROR) &amp;&amp; isPreviewMode) { document.querySelector(".g-recaptcha").style.display = 'none'; document.querySelector(".fc--recaptcha").style.display = 'flex'; } }); document.addEventListener('click', function (event) { if (event.target.closest(FC\_\_SELECTORS.DROPDOWN\_OPEN)) { fc\_\_closeAllDropDownMenu(); const currentElementClassList = event.target.closest(FC\_\_SELECTORS.DROPDOWN).classList; if (currentElementClassList.contains(FC\_\_CLASSES.DROPDOWN\_OPEN)) { currentElementClassList.remove(FC\_\_CLASSES.DROPDOWN\_OPEN); } else { currentElementClassList.add(FC\_\_CLASSES.DROPDOWN\_OPEN); } fc\_\_createUpwardDropdown(event.target); } else { fc\_\_closeAllDropDownMenu(); } }); function fc\_\_closeAllDropDownMenu() { const dropDownList = document.querySelectorAll(FC\_\_SELECTORS.DROPDOWN); if (dropDownList) { dropDownList.forEach(item =&gt; item.classList.remove(FC\_\_CLASSES.DROPDOWN\_OPEN)); } } function fc\_\_createUpwardDropdown(target) { const dropdown = target.closest(FC\_\_SELECTORS.DROPDOWN); const dropdownMenu = dropdown.querySelector(FC\_\_SELECTORS.DROPDOWN\_MENU); const dropdownMenuHeight = dropdownMenu.clientHeight; const dropdownCoordinates = dropdown.getBoundingClientRect(); const checkedDropdownPosition = window.innerHeight - dropdownCoordinates.bottom - dropdownMenuHeight; if (checkedDropdownPosition -1 &amp;&amp; leftSidePhoneCode.length -1) { const phoneWithoutCode = formattedValue.slice(phoneCode.length).replace(/\[+\]/g, ''); checkPhoneFormat(input, phoneWithoutCode, formatType, phoneCode); } else checkPhoneFormat(input, formattedValue, formatType); } fc\_\_handleValidatePhoneNumber(inputToStore); } function fc\_\_phoneWithDropdownValidation(input, phoneBlock, countryCode) { const countryCodeList = phoneBlock.querySelectorAll('.fc--phone-dropdown\_\_item'); const countryCodeArray = Array.from(countryCodeList); const dropdownSearch = phoneBlock.querySelector('.fc--phone-search\_\_input'); const foundCountryCode = countryCodeArray.find( item =&gt; item.querySelector('.fc--phone-dropdown\_\_number').textContent.trim() === countryCode, ); const selectedDropdownField = phoneBlock.querySelector('.fc--phone-dropdown\_\_field'); if (foundCountryCode) { replacePhoneSelectedValue(selectedDropdownField, foundCountryCode); input.value = input.value.slice(countryCode.length).trim(); if (dropdownSearch) { dropdownSearch.value = countryCode; $(dropdownSearch).keyup(); } } } function fc\_\_phoneWithDefaultCodeValidation(input, phoneBlock, countryCode) { const phoneDefaultItem = phoneBlock.querySelector('.fc--phone-dropdown\_\_number'); if (phoneDefaultItem.textContent.trim() === countryCode) { input.value = input.value.slice(countryCode.length).trim(); } } function replacePhoneSelectedValue(selectedDropdownField, foundCountryCode) { const selectedCode = selectedDropdownField.querySelector('.fc--phone-dropdown\_\_number'); const foundedCode = foundCountryCode.querySelector('.fc--phone-dropdown\_\_number'); if (selectedCode.textContent.trim() !== foundedCode.textContent.trim()) { const selectedFlag = selectedDropdownField.querySelector('.fc--phone-dropdown\_\_flag'); const foundedFlag = foundCountryCode.querySelector('.fc--phone-dropdown\_\_flag'); selectedCode.textContent = foundedCode.textContent.trim(); selectedFlag.textContent = foundedFlag.textContent; } } function fc\_\_handleCountryCodeClick(event) { const { target } = event; const blockElement = $(target).parents('.fc--block'); const phoneNumberInput = blockElement.find('.fc--input'); const countryCode = $(target).parents('li').attr('data-code'); const phoneNumber = phoneNumberInput.val(); const fullPhoneNumberInput = blockElement.find(`\[name\]`); fullPhoneNumberInput.val(`+${countryCode} ${phoneNumber}`) const phoneBlock = target.closest('.fc--phone-element'); const inputToStore = phoneBlock.querySelector('.fc--phone--input'); if(countryCode &amp;&amp; phoneNumber) { fc\_\_handleValidatePhoneNumber(inputToStore); } } function fc\_\_handleCheckboxChange(checkbox) { const cookieButton = checkbox.parentElement.parentElement.querySelector('.fc--cookie-button'); if (checkbox.checked) { cookieButton.classList.add('fc--cookie-button--enabled'); cookieButton.classList.remove('fc--cookie-button--disabled'); } else { cookieButton.classList.add('fc--cookie-button--disabled'); cookieButton.classList.remove('fc--cookie-button--enabled'); } } function fc\_\_acceptCookieConsent(button) { const cookieDisclaimer = button.parentElement.parentElement.querySelector( '.fc--cookie-disclaimer', ); localStorage.setItem('cookiesAccepted-583894300269281280', 'true'); cookieDisclaimer.style.display = 'none'; } function fc\_\_handleUrlClick(urlDestination) { window.open(urlDestination, '\_blank'); } const getNumberInfo = fullPhoneNumber =&gt; { try { return libphonenumber.parsePhoneNumber(fullPhoneNumber); } catch (error) { console.error('Failed to load libphonenumber-js: ', error); } } const fc\_\_getCountryCode = fullPhoneNumber =&gt; { const numberInfo = getNumberInfo(fullPhoneNumber); if(numberInfo){ return numberInfo.countryCallingCode; } } const fc\_\_getPhoneNumber = (fullPhoneNumber) =&gt; { if (!fullPhoneNumber.startsWith("+")) { return fullPhoneNumber; } const numberInfo = getNumberInfo(fullPhoneNumber); if(numberInfo){ return numberInfo.nationalNumber; } } const fc\_\_canadaPrefixes = \["204", "226", "236", "249", "250", "289", "306", "343", "365", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "579", "581", "587", "604", "613", "639", "647", "705", "709", "778", "780", "807", "819", "867", "873", "902", "905"\]; const fc\_\_kazakhstanPrefixes = \["6", "7"\]; const fc\_\_svalbardPrefixes = \["79"\]; const fc\_\_mayottePrefixes = \["269", "639"\]; const fc\_\_alandPrefixes = \["18"\]; const fc\_\_southGeorgiaPrefixes = \["4"\]; const fc\_\_curacaoPrefixes = \["9"\]; const fc\_\_crownDependencies = { "1481": "Guernsey", "1534": "Jersey", "1624": "Isle of Man" } const fc\_\_australiaExternalTerritories = { "89162": "Cocos (Keeling) Islands", "89164": "Christmas Island" } const fc\_\_parseByPrefix = (prefixes, prefixCountry, defaultCountry) =&gt; phoneNumber =&gt; { const length = prefixes\[0\].length; return prefixes.includes(phoneNumber.slice(0, length)) ? prefixCountry : defaultCountry; } const fc\_\_parseByMap = (map, defaultCountry) =&gt; phoneNumber =&gt; { const length = Object.keys(map)\[0\].length; return map\[phoneNumber.slice(0, length)\] ?? defaultCountry; } const phoneNumberParsers = { 1: fc\_\_parseByPrefix(fc\_\_canadaPrefixes, "Canada", "United States"), 7: fc\_\_parseByPrefix(fc\_\_kazakhstanPrefixes, "Kazakhstan", "Russia"), 44: fc\_\_parseByMap(fc\_\_crownDependencies, "United Kingdom"), 47: fc\_\_parseByPrefix(fc\_\_svalbardPrefixes, "Svalbard and Jan Mayen", "Norway"), 61: fc\_\_parseByMap(fc\_\_australiaExternalTerritories, "Australia"), 262: fc\_\_parseByPrefix(fc\_\_mayottePrefixes, "Mayotte", "Réunion"), 358: fc\_\_parseByPrefix(fc\_\_alandPrefixes, "Åland Islands", "Finland"), 500: fc\_\_parseByPrefix(fc\_\_southGeorgiaPrefixes, "South Georgia", "Falkland Islands (Malvinas)"), 599: fc\_\_parseByPrefix(fc\_\_curacaoPrefixes, "Curaçao", "Bonaire, Sint Eustatius and Saba"), } const fc\_\_getCountry = (countryCode, phoneNumber) =&gt; { if (!countryCode) { return; } const option = document.querySelector(`\[data-code="${countryCode}"\]`); if (!option) { return; } const parsePhoneNumber = phoneNumberParsers\[countryCode\]; if (parsePhoneNumber) { return parsePhoneNumber(phoneNumber); } return option.getAttribute('data-value'); } const fc\_\_setPhoneNumberValue = (dbField, fullPhoneNumber) =&gt; { const fullPhoneNumberInput = $(`\[name="${dbField}"\]`); const blockElement = fullPhoneNumberInput.parents('.fc--block'); const phoneNumberInput = blockElement.find('.fc--input'); const hasSeparateCountryCode = blockElement.find('.fc--phone-element').length &gt; 0; const phoneNumber = hasSeparateCountryCode ? fc\_\_getPhoneNumber(fullPhoneNumber) : fullPhoneNumber; fullPhoneNumberInput.val(fullPhoneNumber); phoneNumberInput.val(phoneNumber); const countryCode = fc\_\_getCountryCode(fullPhoneNumber); const country = fc\_\_getCountry(countryCode, phoneNumber); if (!country) { return; } const selectedOption = blockElement.find(`li\[data-value="${country}"\]`)\[0\]; if (!selectedOption) { return; } fc\_\_handleOptionClick({target: selectedOption}); } const fc\_\_getFieldsByType = (formData, type) =&gt; Object.keys(formData).filter(dbField =&gt; { const element = document.querySelector(`\[name="${dbField}"\]`); return element?.getAttribute('data-fc-block-type') === type; }) window.onload = () =&gt; { try { const autoPopulateData = JSON.parse("{}".replaceAll(""", '"').replaceAll("\\\\", "").replace(/"consentGroups":"\\\[/, '"consentGroups":\[').replace(/\\\]"/, '\]')); const phoneNumberFields = fc\_\_getFieldsByType(autoPopulateData, "phoneNumber"); phoneNumberFields.forEach((dbField) =&gt; { const fullPhoneNumber = autoPopulateData\[dbField\]; fc\_\_setPhoneNumberValue(dbField, fullPhoneNumber); }) } catch (error) { console.error("Invalid JSON string:", error); } const isRecaptcha = document.querySelectorAll(FC\_\_SELECTORS.RECAPTCHA\_ERROR).length &gt; 0; if(isRecaptcha) { const script = document.createElement('script'); script.src = "https://www.google.com/recaptcha/api.js"; script.async = true; script.defer = true; document.head.appendChild(script); } }  Email

This email address is being protected from spambots. You need JavaScript enabled to view it.

Last Name

First Name

Address

City

State

Zip

 ![](https://skiburke.com/data:image/svg+xml;base64,PHN2ZyBmb2N1c2FibGU9ImZhbHNlIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2IiBhcmlhLWhpZGRlbj0idHJ1ZSIgY2xhc3M9ImJ4LS10b2dnbGVfX2ljb24iIHN0eWxlPSJ3aWxsLWNoYW5nZTogdHJhbnNmb3JtO2ZpbGw6d2hpdGU7c3Ryb2tlOndoaXRlO3N0cm9rZS13aWR0aDoyIj48cGF0aCBkPSJNNiAxMC42TDIuNSA3LjFsLS43LjcgMy41IDMuNS43LjcgNy4xLTcuMS0uNy0uN3oiPjwvcGF0aD48L3N2Zz4=)   Bear Essentials Newsletter

 ![](https://skiburke.com/data:image/svg+xml;base64,PHN2ZyBmb2N1c2FibGU9ImZhbHNlIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2IiBhcmlhLWhpZGRlbj0idHJ1ZSIgY2xhc3M9ImJ4LS10b2dnbGVfX2ljb24iIHN0eWxlPSJ3aWxsLWNoYW5nZTogdHJhbnNmb3JtO2ZpbGw6d2hpdGU7c3Ryb2tlOndoaXRlO3N0cm9rZS13aWR0aDoyIj48cGF0aCBkPSJNNiAxMC42TDIuNSA3LjFsLS43LjcgMy41IDMuNS43LjcgNy4xLTcuMS0uNy0uN3oiPjwvcGF0aD48L3N2Zz4=)   Daily Snow Report

 ![](https://skiburke.com/data:image/svg+xml;base64,PHN2ZyBmb2N1c2FibGU9ImZhbHNlIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2IiBhcmlhLWhpZGRlbj0idHJ1ZSIgY2xhc3M9ImJ4LS10b2dnbGVfX2ljb24iIHN0eWxlPSJ3aWxsLWNoYW5nZTogdHJhbnNmb3JtO2ZpbGw6d2hpdGU7c3Ryb2tlOndoaXRlO3N0cm9rZS13aWR0aDoyIj48cGF0aCBkPSJNNiAxMC42TDIuNSA3LjFsLS43LjcgMy41IDMuNS43LjcgNy4xLTcuMS0uNy0uN3oiPjwvcGF0aD48L3N2Zz4=)   Downhill Park Report

 ![](https://skiburke.com/data:image/svg+xml;base64,PHN2ZyBmb2N1c2FibGU9ImZhbHNlIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2IiBhcmlhLWhpZGRlbj0idHJ1ZSIgY2xhc3M9ImJ4LS10b2dnbGVfX2ljb24iIHN0eWxlPSJ3aWxsLWNoYW5nZTogdHJhbnNmb3JtO2ZpbGw6d2hpdGU7c3Ryb2tlOndoaXRlO3N0cm9rZS13aWR0aDoyIj48cGF0aCBkPSJNNiAxMC42TDIuNSA3LjFsLS43LjcgMy41IDMuNS43LjcgNy4xLTcuMS0uNy0uN3oiPjwvcGF0aD48L3N2Zz4=)   Lodging Deals

reCAPTCHA

I'm not a robot

![recaptcha-image](https://content-us-1.content-cms.com/43d24b77-a1cd-4294-b150-75daaba0cad7//acoustic/form/images/Recaptcha.svg)reCAPTCHA

Privacy - Terms

Please verify that you are not a robot
