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QAASR,QACjC,IAAIvB,EAAI8B,gBAAiB,CAC9BhB,EAAWO,kBAAkB,IAC7B,IAAIY,EAAYjC,EAAIkC,qBAChBC,EAAajB,EAASe,GAC1BnB,EAAWO,kBAAkBc,GAC7BrB,EAAWQ,eAAe,CAAC,EAC7B,CACF,CACF,GACJ,CAEA,SAASd,EAAM4B,GACb5F,MAAM,8CAA+C,CAAEK,QAAS,CAAE,OAAU,sBACzEC,MAAMmC,GAASA,EAAKjC,SACpBI,OAAM,KACE,CACLiF,QAAS,SAGZvF,MAAMmC,GAASmD,EAASnD,EAAKoD,UAClC,C","sources":["webpack://narconon-us-site/./node_modules/@able-sbcadmin/narconon-npm/dist/forms.js"],"sourcesContent":["/*******************************************************************************************************************\n * File: /assets/js/form.js\n * JS for any HTML form related work\n * Author: ABLE Dev \n *******************************************************************************************************************/\n\nexport function formSubmission() {\n let payload = {};\n let form = document.getElementById('get-help-form');\n form?.addEventListener('submit', (e)=> {\n e.preventDefault();\n let formData = new FormData(form);\n for(const pair of formData.entries()) {\n payload[pair[0]] = pair[1];\n }\n if(window.__ctm) {\n payload.visitor_sid = window.__ctm.config.sid;\n payload.gid = window.__ctm.config.gid;\n payload.aid = window.__ctm.config.aid; \n payload.form_completion_location = window.__ctm.config.windowLocation;\n } else {\n payload.aid = '74005';\n }\n var whoFor = ''; \n var options1 = document.getElementById(\"optionsRadios1\");\n var options2 = document.getElementById(\"optionsRadios1\");\n if (options1 != null && options2 != null){\n if(document.getElementById('optionsRadios1').checked) {whoFor = 'For Yourself';}\n if(document.getElementById('optionsRadios2').checked) {whoFor = 'Someone You Know';}\n payload.who_for = whoFor;\n }\n let formType = document.getElementById('form-type').value;\n payload.form_name = formType;\n sendForm(payload, form, formType);\n });\n}\n\nfunction sendForm(payload, form, formType) {\n if (document.getElementById('contactEmail').value === '1') {\n formResponseHandler(203, 'Data', form, formType);\n } else {\n fetch('https://api.sbcdevsite.org/tosf', {\n method: 'POST',\n body: JSON.stringify(payload), \n headers: {\n 'Origin': '*', \n 'Content-Type': 'application/json'\n }\n }).then( response => \n response.json().then( data => ({\n data: data,\n status: response.status\n })).then(res => {\n formResponseHandler(res.status, res.data, form, formType)\n }))\n .catch(( error ) => {\n console.log('error here', error);\n })\n //fetch and if succesful modal with success, else modal with error.\n //if download start download on success\n } \n}\n\nfunction formResponseHandler(status, data, form, formType) {\n let alertBox = document.getElementById('success-alert');\n let errorAlertBox = document.getElementById('error-alert')\n if (status === 200 || status === 201 || status === 202) {\n // Push to Tag Manager\n if(window.dataLayer) {\n window.dataLayer = window.dataLayer || [];\n window.dataLayer.push({\n 'event': 'formSubmission',\n 'formType': formType,\n });\n }\n alertBox.classList.add('open');\n window.scrollTo({top: 0, behavior: 'smooth'});\n document.getElementById('alertBox-close').addEventListener('click', (e) => {\n alertBox.classList.remove('open');\n });\n form.reset()\n if (!formType.match('Download')) {\n } else {\n // Downloader scriptif(term == 'download-booklet') {\n var pageLang = getLanguage();\n var pageURL = window.location.href.split('?')[0];\n var fileName;\n if (formType.match('Download Booklet')) {\n fileName = \"drug-booklet_\";\n }\n if (formType.match('Download Brochure')) {\n fileName = \"narconon-program-brochure_\";\n }\n var pdfName = fileName + pageLang + \".pdf\";\n // Allow a method to define a new PDF download eg. for the topics pages\n if (document.getElementById('booklet_PDF')) {\n pdfName = document.getElementById('booklet_PDF').dataset.download;\n }\n var fileURL = pageURL + pdfName;\n downloadFile(pdfName, fileURL);\n document.getElementById('form-download-link').href = fileURL; \n }\n } else { // not 200\n errorAlertBox.classList.add('open');\n window.scrollTo({top: 0, behavior: 'smooth'});\n document.getElementById('errorAlertBox-close').addEventListener('click', (e) => {\n errorAlertBox.classList.remove('open');\n });\n }\n}\n\n function downloadFile(pdfName, fileURL) {\n fetch(fileURL, {\n method: 'GET'\n}).then(resp => resp.blob())\n .then(blob => {\n const url = window.URL.createObjectURL(blob);\n const a = document.createElement('a');\n a.style.display = 'none';\n a.href = url;\n a.download = pdfName; // the filename you want\n document.body.appendChild(a);\n a.click();\n window.URL.revokeObjectURL(url);\n })\n}\n\nfunction getLanguage(){\n let langTag = document.documentElement.lang\n return langTag;\n}\n\n//ipinfo.io/[IP address]?token=6cd7559cfc64f3\n//Function included in main js\nexport function countryCode() {\n var input = document.getElementById('phone');\n var iti = window.intlTelInput(input, {\n initialCountry: \"auto\",\n hiddenInput: \"full_phone\",\n separateDialCode: true,\n preferredCountries: [],\n autoPlaceholder: \"aggressive\",\n geoIpLookup: getIp,\n customPlaceholder: function(selectedCountryPlaceholder, selectedCountryData) {\n return selectedCountryPlaceholder.replace(/[0-9-]/g, \" \");\n },\n utilsScript: \"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.13/js/utils.min.js\"\n });\n \n // Adding on blur event to set phone values and validate\n const phoneInput = document.querySelector(\"#phone\");\n const getForm = document.querySelector(\".form-container\");\n const countryNumberInput = document.getElementById('e-164_country_code');\n const e164NumberInput = document.getElementById('e-164_number');\n // here, the index maps to the error code returned from getValidationError - see readme\n\n const daErrorMap = [\"Kontroller venligst det indtastede telefonnummer\", \"Kontroller venligst landekoden\", \"Kontroller venligst, om der mangler et ciffer\", \"Tjek venligst telefonnummeret, det virker for langt.\", \"Dette synes at være et ugyldigt nummer\"];\n const enErrorMap = [\"Please check the phone # entered\", \"Seems to be a wrong country code\", \"Please check if a # is missing\", \"Their are possibly too many #'s\", \"This seems to be an invalid number\"];\n const esErrorMap = [\"Por favor, compruebe el número de teléfono introducido\", \"Parece ser un código de país equivocado\", \"Por favor, compruebe si falta algún dígito\", \"Es posible que haya demasiados dígitos en este número de teléfono\", \"Esto parece ser un número de teléfono inválido\"];\n const frErrorMap = [\"Veuillez vérifier le numéro de téléphone saisi\", \"Il semble que le code pays soit erroné\", \"Veuillez vérifier si un chiffre est manquant\", \"Il y a probablement trop de chiffres dans ce numéro de téléphone.\", \"Cela semble être un numéro de téléphone invalide.\"];\n const itErrorMap = [\"Si prega di controllare il numero di telefono inserito\", \"Sembra che il codice del paese sia sbagliato\", \"Controlla se manca una cifra\", \"Ci sono probabilmente troppe cifre in questo numero di telefono\", \"Questo sembra essere un numero di telefono non valido\"];\n var errorMap = [\"Please check the phone # entered\", \"Seems to be a wrong country code\", \"Please check if a # is missing\", \"Their are possibly too many #'s\", \"This seems to be an invalid number\"];\n \n var formLang = document.documentElement.lang;\n if (formLang.startsWith(\"da\")) { \n errorMap = daErrorMap;\n } else if (formLang.startsWith(\"es\")) { \n errorMap = esErrorMap;\n } else if (formLang.startsWith(\"fr\")) { \n errorMap = frErrorMap;\n } else if (formLang.startsWith(\"it\")) { \n errorMap = itErrorMap;\n }\n\n //turns off error message when continuing input\n phoneInput.addEventListener('input', function() {\n phoneInput.setCustomValidity('');\n phoneInput.reportValidity({});\n });\n\n // on blue if not good sends error message if good just continues along\n phoneInput.addEventListener('blur', function() {\n if (phoneInput.value) {\n phoneInput.setCustomValidity('');\n var number = iti.getNumber(intlTelInputUtils.numberFormat.E164);\n var countryData = iti.getSelectedCountryData();\n if (iti.isValidNumber()) {\n countryNumberInput.setAttribute(\"value\", countryData.dialCode);\n e164NumberInput.setAttribute(\"value\", number);\n } else if(!iti.isValidNumber()) {\n phoneInput.setCustomValidity('');\n var errorCode = iti.getValidationError();\n var invalidMsg = errorMap[errorCode];\n phoneInput.setCustomValidity(invalidMsg);\n phoneInput.reportValidity({}); \n }\n }\n });\n}; \n\nfunction getIp(callback) {\n fetch('https://ipinfo.io/json?token=6cd7559cfc64f3', { headers: { 'Accept': 'application/json' }})\n .then((resp) => resp.json())\n .catch(() => {\n return {\n country: 'dk',\n };\n })\n .then((resp) => callback(resp.country));\n}\n"],"names":["formSubmission","payload","form","document","getElementById","addEventListener","e","preventDefault","formData","FormData","pair","entries","window","__ctm","visitor_sid","config","sid","gid","aid","form_completion_location","windowLocation","whoFor","options1","options2","checked","who_for","formType","value","form_name","formResponseHandler","fetch","method","body","JSON","stringify","headers","then","response","json","data","status","res","catch","error","console","log","sendForm","alertBox","errorAlertBox","dataLayer","push","classList","add","scrollTo","top","behavior","remove","reset","match","fileName","pageLang","documentElement","lang","pageURL","location","href","split","pdfName","dataset","download","fileURL","resp","blob","url","URL","createObjectURL","a","createElement","style","display","appendChild","click","revokeObjectURL","downloadFile","countryCode","input","iti","intlTelInput","initialCountry","hiddenInput","separateDialCode","preferredCountries","autoPlaceholder","geoIpLookup","getIp","customPlaceholder","selectedCountryPlaceholder","selectedCountryData","replace","utilsScript","phoneInput","querySelector","countryNumberInput","e164NumberInput","errorMap","formLang","startsWith","setCustomValidity","reportValidity","number","getNumber","intlTelInputUtils","numberFormat","E164","countryData","getSelectedCountryData","isValidNumber","setAttribute","dialCode","errorCode","getValidationError","invalidMsg","callback","country"],"sourceRoot":""}