PageSourceSearch

https://www.royalenfield.com/etc.clientlibs/RE-Platform-Revamp/cli…stomer-support-form.36d333659c1c5842a45f.js

js royalenfield.com collected 2026-10-01 10:31:43 UTC 16,651 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkaem_maven_archetype=self.webpackChunkaem_maven_archetype||[]).push([[6564],{3404:function(e,t,n){n.d(t,{Qe:function(){return l},rl:function(){return i},v6:function(){return c}});var o=n(639),r=n.n(o);const a=async e=>{const t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`HTTP ${t.status} for ${e}`);return t.json()},s=(e,t,n)=>{const o=document.querySelector(t),a=document.querySelector(n);if(!o||!a)return void console.warn("[locationDropdown] Template or target not found:",t,n);const s=r().compile(o.innerHTML);a.innerHTML=s(e)},i=async(e,t,n)=>{try{const o=await a(`${e}/countries.json`);if(!Array.isArray(o))return void console.warn("[locationDropdown] Countries response is not an array");const r=[...o].sort(((e,t)=>(e.name||"").localeCompare(t.name||"")));s(r,t,n);const i=document.querySelector(n);i&&(i.disabled=!1)}catch(e){console.error("[locationDropdown] Failed to load countries:",e)}},c=async(e,t,n,o)=>{if(t)try{const r=`${e}/countries/${t.toUpperCase()}/states.json`,i=await a(r);if(!Array.isArray(i))return void console.warn("[locationDropdown] States response is not an array");const c=[...i].sort(((e,t)=>(e.name||"").localeCompare(t.name||"")));s(c,n,o);const l=document.querySelector(o);l&&(l.disabled=!1)}catch(e){console.error("[locationDropdown] Failed to load states:",e)}},l=async(e,t,n,o,r)=>{if(t&&n)try{const i=`${e}/countries/${t.toUpperCase()}/states/${n.toUpperCase()}/cities.json`,c=await a(i);if(!Array.isArray(c))return void console.warn("[locationDropdown] Cities response is not an array");const l=[...c].sort(((e,t)=>(e.name||"").localeCompare(t.name||"")));s(l,o,r);const d=document.querySelector(r);d&&(d.disabled=!1)}catch(e){console.error("[locationDropdown] Failed to load cities:",e)}}},3866:function(e,t,n){n.r(t),n.d(t,{default:function(){return p}});var o=n(113),r=n(463),a=n(133),s=n(3404);function i(e,t,n,o,r){dataLayer.push({event:e,eventCategory:e,eventAction:t,eventLabel:n,sectionHeading:o,pageType:r})}function c(e,t,n,o,r,a){dataLayer.push({event:e,eventCategory:e,eventAction:t,eventLabel:n,errorMessage:o,sectionHeading:r,pageType:a})}const l=(()=>{const e=window.location.pathname.split("/").filter(Boolean);return"content"===e[0]?.toLowerCase()?e[2]||"in":e[0]||"in"})();function d(e,t,n=!1){const o="in"===e.toLowerCase()?"india":"intl";t.querySelectorAll("[data-india-restrict], [data-india-regex]").forEach((e=>{const t=e.getAttribute(`data-${o}-restrict`),a=e.getAttribute(`data-${o}-regex`),s=e.getAttribute(`data-${o}-min-length`),i=e.getAttribute(`data-${o}-max-length`),c=e.getAttribute(`data-${o}-error-message`);if(t&&e.setAttribute("data-restrict",t),a&&e.setAttribute("data-regex",a),s&&e.setAttribute("data-min-length",s),i&&e.setAttribute("maxlength",i),c&&e.setAttribute("data-error-message",c),n){["first_name","last_name","mobileNumber"].includes(e.name)||(e.value="",(0,r.ET)(e))}}))}function u(){const e=document.querySelector(".cs-contact-section");if(!e)return;const t=document.querySelector(".customer-support-form"),n="true"===t?.dataset.isEuropePage;e.style.display=n?"":"none"}let m=!1;function y(e=!1){const t=document.querySelector(".cs-contact-section");if(!t||"none"===window.getComputedStyle(t).display||m)return!0;const n=function(){const e=document.querySelector(".cs-contact-section");if(!e||"none"===window.getComputedStyle(e).display)return!0;const t=e.querySelectorAll('input[type="checkbox"]');return Array.from(t).some((e=>e.checked))}();if(!n&&e){return function(e){const t=document.querySelector(".customer-support-model");if(!t)return;const n=t.querySelector(".model-title"),o=t.querySelector(".model-text");n&&(n.textContent="Consent Required"),o&&(o.textContent=e||"Please select at least one contact preference to proceed."),t.setAttribute("data-is-consent-warning","true"),t.classList.remove("d-none"),t.classList.add("show-model")}(t.querySelector(".error-messages")?.textContent?.trim()||"Please select at least one contact preference to proceed."),m=!0,!1}return n}var p={formSelector:document.querySelector(".customer-support-form"),submitBtn:document.querySelector(".customer-support-btn"),modelSelector:document.querySelector(".customer-support-model"),modelCloseBtn:document.querySelectorAll(".customer-support-model .close-btn"),countryTemplate:".cs-country-template",countryListing:".cs-country-listing",stateTemplate:".cs-state-template",stateListing:".cs-state-listing",cityTemplate:".cs-city-template",cityListing:".cs-city-listing",sanitizeV
1alue:function(e){if(!e||!e.dataset)return;const t=String(e.dataset.restrict||"").toLowerCase(),n=String(e.name||"");"alphanumeric"===t||"alpha-numeric"===t||"alpha_numeric"===t||"motorcycleVIN"===n||"cs-chassisNumber"===e.id?e.value=String(e.value||"").replace(/[^A-Za-z0-9]/g,""):t.includes("alpha")&&!t.includes("numeric")?e.value="alpha"===t?String(e.value||"").replace(/[^A-Za-z]/g,""):String(e.value||"").replace(/[^A-Za-z\s'-]/g,"").replace(/^\s+/,""):t.includes("numeric")&&(e.value=String(e.value||"").replace(/\D/g,""))},init:function(){const e=this.formSelector.dataset.countryJsonApi;d(l,this.formSelector),u(),e&&(0,o.z)(e),setTimeout((()=>{const e=this.formSelector.querySelector(".calling__code-listing");e&&(e.removeAttribute("style"),"in"!==l.toLowerCase()?e.disabled=!1:(e.disabled=!0,e.style.color="#a6a6a6"))}),200),e&&(0,s.rl)(e,this.countryTemplate,this.countryListing);const t=document.querySelector(this.countryListing),n=document.querySelector(this.stateListing),m=document.querySelector(this.cityListing);t&&(n&&!n.hasAttribute("data-original-mandatory")&&(n.setAttribute("data-original-mandatory",n.getAttribute("data-mandatory")||"false"),n.disabled&&n.setAttribute("data-mandatory","false")),m&&!m.hasAttribute("data-original-mandatory")&&(m.setAttribute("data-original-mandatory",m.getAttribute("data-mandatory")||"false"),m.disabled&&m.setAttribute("data-mandatory","false")),t.addEventListener("change",(async t=>{const o=t.target.value,a=t.target.selectedOptions[0],i=a?.dataset.code||"";o&&(d(i||o,this.formSelector,!0),u()),n.innerHTML='<option value="">Select State</option>',n.disabled=!0,n.setAttribute("data-mandatory","false"),m.innerHTML='<option value="">Select City</option>',m.disabled=!0,m.setAttribute("data-mandatory","false");const c=n.closest(".contact-input-group"),l=m.closest(".contact-input-group");l&&(l.style.display="none"),i&&e?(await(0,s.v6)(e,i,this.stateTemplate,this.stateListing),n.options.length>1?(n.disabled=!1,n.setAttribute("data-mandatory",n.getAttribute("data-original-mandatory")),c&&(c.style.display="")):(n.disabled=!0,n.setAttribute("data-mandatory","false"),c&&(c.style.display="none"),(0,r.ET)(n))):(n.setAttribute("data-mandatory","false"),c&&(c.style.display="none"),(0,r.ET)(n))}))),n&&n.addEventListener("change",(async n=>{const o=n.target.selectedOptions[0],a=o?.dataset.code||"",i=t?.selectedOptions[0],c=i?.dataset.code||"";m.innerHTML='<option value="">Select City</option>',m.disabled=!0,m.setAttribute("data-mandatory","false"),(0,r.ET)(m);const l=m.closest(".contact-input-group");c&&a&&e?(await(0,s.Qe)(e,c,a,this.cityTemplate,this.cityListing),m.options.length>1?(m.disabled=!1,m.setAttribute("data-mandatory",m.getAttribute("data-original-mandatory")),l&&(l.style.display="")):(m.disabled=!0,m.setAttribute("data-mandatory","false"),l&&(l.style.display="none"),(0,r.ET)(m))):(m.setAttribute("data-mandatory","false"),l&&(l.style.display="none"),(0,r.ET)(m))}));const p=(0,r.ig)(this.formSelector);this.formSelector.addEventListener("input",(e=>{e.preventDefault(),(0,r.ET)(e.target),this.sanitizeValue(e.target)})),this.formSelector.addEventListener("change",(function(e){(0,r.ET)(e.target)}));const f=document.getElementById("cs-contactAll");if(f){const e=document.querySelector(".cs-contact-section").querySelectorAll(".contact-us-tnc-input:not(#cs-contactAll)");f.addEventListener("change",(t=>{const n=t.target.checked;e.forEach((e=>e.checked=n))})),e.forEach((t=>{t.addEventListener("change",(()=>{if(t.checked){const t=Array.from(e).every((e=>e.checked));f.checked=t}else f.checked=!1}))}))}const g=document.querySelector(".customer-support-section"),h=g?.dataset.gaComponent||"",v=this.formSelector.closest(".customer-support-section")?.dataset.gaSectionHeading?.trim(),S=document.title,b=["first_name","last_name","email","mobileNumber","callingCode"];this.formSelector.addEventListener("focusout",(function(e){const t=e.target;if(!h)return;if("INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName||"checkbox"===t.type)return;if(!t.value.trim()||"select-countries-search"===t.id)return;const n=t.closest(".entry-city-wrap")?.querySelector("label")?.textContent.trim()||t.placeholder||t.name,o=b.includes(t.name)?"NA":t.value.trim();i(h,n,o,v,S)})),function(e){const t=document.getElementById("cs-visitingCountry"),n=document.getElementById("select-countries-search"),o=document.getElementById("country-dropdown-list"),r=document.getElementById("selected-countries-wrap"),a=document.getElementById("city-state-table");if(!t||!n)return;const s=Array.from(t.options).filter((e=>""!==e.value));let i=new Set;const c=document.querySelector(".visiting-country-row-template"),l=c?c.innerHTML:"",d=document.querySelector(".visiting-country-chip-template"),u=d?d.innerHTML:"",m=ne
1w Date,y=`${m.getFullYear()}-${String(m.getMonth()+1).padStart(2,"0")}-${String(m.getDate()).padStart(2,"0")}`,p=()=>{i.size>0?(t.value=Array.from(i)[0],t.dataset.selected="true"):(t.value="",t.dataset.selected="false")},f=()=>{i.size>0?a.style.display="block":a.style.display="none",i.forEach((e=>{const t=e.replace(/[^a-zA-Z0-9]/g,"_");if(!document.getElementById(`row-${t}`)){const n=s.find((t=>t.value===e)),o=n?n.textContent.trim():e,r=l.replace(/\{\{safeVal\}\}/g,t).replace(/\{\{val\}\}/g,e.replace(/"/g,"&quot;")).replace(/\{\{label\}\}/g,o),i=document.createElement("div");i.innerHTML=r;const c=i.firstElementChild;if(c){const e=c.querySelector(`[name="${t}-entryDate"]`),n=c.querySelector(`[name="${t}-exitDate"]`);if(e&&n){e.setAttribute("min",y),n.setAttribute("min",y);const t=()=>{if(e.value&&n.value&&new Date(n.value)<new Date(e.value)){const e=document.querySelector(".customer-support-model");if(e){const t=e.querySelector(".model-title"),n=e.querySelector(".model-text");t&&(t.textContent=""),n&&(n.textContent="Exit date cannot be earlier than entry date."),e.setAttribute("data-is-validation-warning","true"),e.classList.remove("d-none"),e.classList.add("show-model")}n.value=""}};e.addEventListener("change",(()=>{t()})),n.addEventListener("change",(()=>{t()}))}a.appendChild(c)}}})),Array.from(a.children).forEach((e=>{const t=e.id.replace("row-","");let n=!1;i.forEach((e=>{e.replace(/[^a-zA-Z0-9]/g,"_")===t&&(n=!0)})),n||a.removeChild(e)}))},g=()=>{r.innerHTML="",i.forEach((e=>{const n=s.find((t=>t.value===e)),o=n?n.textContent.trim():e,a=e.replace(/[^a-zA-Z0-9]/g,"_"),c=u.replace(/\{\{safeVal\}\}/g,a).replace(/\{\{label\}\}/g,o),l=document.createElement("div");l.innerHTML=c;const d=l.firstElementChild;d&&(d.addEventListener("click",(n=>{n.preventDefault(),n.stopPropagation(),i.delete(e);const o=t.closest(".row");if(o){o.classList.remove("field-has-error");const e=o.querySelector(".error-messages");e&&e.classList.add("d-none")}h(),g(),f(),p()})),r.appendChild(d))}))},h=(r="")=>{o.innerHTML="";let a=!1;const c=r.toLowerCase();s.forEach((s=>{const l=s.textContent.trim(),d=s.value;if(i.has(d))return;if(r&&!l.toLowerCase().includes(c))return;a=!0;const u=document.createElement("li");u.textContent=l,u.style.padding="10px 16px",u.style.color="#ffffff",u.style.cursor="pointer",u.style.fontSize="14px",u.dataset.value=d,u.addEventListener("mouseover",(()=>{u.style.backgroundColor="#474747"})),u.addEventListener("mouseout",(()=>{u.style.backgroundColor="transparent"})),u.addEventListener("click",(()=>{const o=t.closest(".row");if(i.size>=5){if(o){o.classList.add("field-has-error");const e=o.querySelector(".error-messages");e&&(e.textContent="You can select a maximum of 5 visiting countries.",e.classList.remove("d-none"))}}else{if(o){o.classList.remove("field-has-error");const e=o.querySelector(".error-messages");e&&e.classList.add("d-none")}i.add(d),"function"==typeof e&&e(l,d),n.value="",h(),g(),f(),p()}})),o.appendChild(u)})),a?o.classList.remove("d-none"):o.classList.add("d-none")};n.addEventListener("click",(()=>{h(n.value)})),n.addEventListener("focus",(()=>{h(n.value)})),n.addEventListener("input",(e=>{h(e.target.value)})),n.addEventListener("keydown",(e=>{"Enter"===e.key&&(e.preventDefault(),o.firstElementChild&&o.firstElementChild.click())})),document.addEventListener("click",(e=>{const t=document.getElementById("visitingCountry-wrapper");t&&!t.contains(e.target)&&(o.classList.add("d-none"),n.value="")}))}((function(e){if(!h)return;const t=document.querySelector('label[for="cs-visitingCountry"]')?.textContent.trim()||"visiting_country";i(h,t,e,v,S)})),this.formSelector.addEventListener("change",(function(e){const t=e.target;if(h)if("SELECT"===t.tagName&&t.value&&!t.classList.contains("visiting-country-field")){const e=document.querySelector(`label[for="${t.id}"]`)?.textContent.trim()||t.name,n=b.includes(t.name)?"NA":t.value;i(h,e,n,v,S)}else"checkbox"===t.type&&"contactTermPolicy"===t.name&&i(h,"term_and_condition",t.checked?"check":"uncheck",v,S)})),this.submitBtn.addEventListener("click",(async e=>{e.preventDefault();const t=p.validate(),n=this.submitBtn.textContent.trim();if(t.isValid){if(!y(!0)){const e=document.querySelector(".cs-contact-section .error-messages")?.textContent?.trim()||"Please select at least one contact preference to proceed.";return void c(h,n,"fail",e,v,S)}const e={},t=this.formSelector.elements;for(let n=0;n<t.length;n++){const o=t[n];!o.name||o.disabled||"checkbox"===o.type||"button"===o.type||"submit"===o.type||o.classList.contains("visiting-country-field")||"visitingCountry"===o.name||(this.sanitizeV
1alue(o),e[o.name]=o.value)}const o=function(){const e=[],t=document.getElementById("city-state-table");t&&t.querySelectorAll(".table-item").forEach((t=>{const n=t.id.replace("row-",""),o=t.getAttribute("data-country-val")||"",r=t.querySelector(`[name="${n}-entryCity"]`)?.value||"";let a=t.querySelector(`[name="${n}-entryDate"]`)?.value||"";const s=t.querySelector(`[name="${n}-exitCity"]`)?.value||"";let i=t.querySelector(`[name="${n}-exitDate"]`)?.value||"";if(a&&a.includes("-")){const[e,t,n]=a.split("-");a=`${n}/${t}/${e}`}if(i&&i.includes("-")){const[e,t,n]=i.split("-");i=`${n}/${t}/${e}`}const c={country:o};r&&(c.entryCity=r),a&&(c.entryDate=a),s&&(c.exitCity=s),i&&(c.exitDate=i),e.push(c)}));return e}();o.length>0&&(e.visitingCountry=o);const{category:r,formName:s}=this.submitBtn.dataset;r&&(e.category=r),s&&(e.formName=s);const i=this.formSelector.dataset.customerSupportApi;if(console.log("customer support payload",e,"sending to",i),i)try{const t=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...a.b,location:a.b["x-custom-country"].toUpperCase()},body:JSON.stringify(e)}),o=await t.json();if(!t.ok)throw new Error(o.message||"Submission failed");if(200===o.code)this.modelSelector.querySelector(".model-text").textContent=this.modelSelector.dataset.successMessage,this.modelSelector.classList.remove("d-none"),this.modelSelector.classList.add("show-model"),document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",c(h,n,"success","NA",v,S);else{const e=this.modelSelector.dataset.errorMessage||"NA";this.modelSelector.querySelector(".model-text").textContent=e,this.modelSelector.classList.remove("d-none"),this.modelSelector.classList.add("show-model"),document.body.style.overflow="",document.documentElement.style.overflow="",c(h,n,"fail",e,v,S)}}catch(e){console.error("submit error",e),c(h,n,"fail",e.message||"NA",v,S)}}else{const e=t.errors?.[0]?.element,o=e?.closest(".form-group")||e?.parentElement,r=o?.querySelector(".error-messages"),a=r?.textContent?.trim()||function(e){const t=e.querySelectorAll(".error-messages");for(const e of t){const t=e.textContent?.trim();if(t&&!e.classList.contains("d-none")&&"none"!==e.style.display)return t}return"Form validation failed"}(this.formSelector);c(h,n,"fail",a,v,S)}})),this.modelCloseBtn.forEach((e=>{e.addEventListener("click",(()=>{const e=document.querySelector(".customer-support-model"),t="true"===e?.getAttribute("data-is-consent-warning"),n="true"===e?.getAttribute("data-is-validation-warning");t||n?(e.classList.remove("show-model"),e.classList.add("d-none"),e.removeAttribute("data-is-consent-warning"),e.removeAttribute("data-is-validation-warning")):window.location.reload()}))}))}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.