let localeGroups=[],localeNames=["country","state","city"],fI=window.location.pathname.split("/"),fid=fI[2],aid=fI[3];function checkGroup(type,value){return new Promise((res,rej)=>{localeGroups.length||localeGroups.push({country:!1,state:!1,city:!1});for(let i=0;iDon\'t see your city? Click
Here
',node.parentElement.appendChild(notFound)}function convertToInput(node){let input=document.createElement("input");input.type="text",input.classList.add("input"),input.name=node.attributes.getNamedItem("name").nodeValue,node.attributes.getNamedItem("placeholder")?input.placeholder=node.attributes.getNamedItem("placeholder").nodeValue:input.placeholder=input.name,node.parentElement.removeChild(node.parentElement.childNodes[0]),node.parentNode.parentElement.replaceChild(input,node.parentNode.parentElement.childNodes[1])}function addCity(elm){let input=document.createElement("input");input.type="text",input.classList.add("input"),input.name=elm.parentNode.previousElementSibling.attributes.getNamedItem("name").value,input.placeholder="City",input.dataset.add=!0,elm.parentNode.parentElement.removeChild(elm.parentNode.parentElement.childNodes[0]),elm.parentNode.parentElement.removeChild(elm.parentNode.parentElement.childNodes[0]),elm.parentNode.parentElement.removeChild(elm.parentNode.parentElement.childNodes[0]),elm.parentNode.parentElement.classList.remove("select"),elm.parentElement.classList.add("is-hidden"),elm.parentNode.parentElement.appendChild(input),input.focus()}async function changeCountry(node){let i=node.dataset.group;removeAll(localeGroups[i].state),localeGroups[i].state&&(await requestOptions(`${window.location.origin}/form/api/locale/state?countryname=${localeGroups[i].country.value}`,localeGroups[i].state),localeGroups[i].city&&changeState(localeGroups[i].city))}function changeState(node){let i=node.dataset.group;removeAll(localeGroups[i].city),localeGroups[i].state&&requestOptions(`${window.location.origin}/form/api/locale/city?statename=${localeGroups[i].state.value}`,localeGroups[i].city)}function requestOptions(url,node){return new Promise((resolve,rej)=>{window.fetch(url,{method:"GET",headers:{"Content-Type":"application/json"}}).then(res=>res.json()).then(data=>{data.length&&(node.remove(0),data.forEach(opt=>{let option=document.createElement("option");option.text=opt.Name,option.value=opt.Name,node.add(option)})),resolve()})})}function removeAll(node){if(node){for(;node.options.length>0;)node.remove(0);let option;document.createElement("option").text="Select "+localeNames[parseInt(node.dataset.select)-1]}}function submitted(event){event.preventDefault();let form=document.getElementById(fid),valid=!0;for(const e of form)!1===e.valid&&(toggleMessage(e.id,!1,!0),valid=!1,scrollToID(e.id)),"FIELDSET"===e.nodeName&&e.attributes.getNamedItem("valid")&&"false"==e.attributes.getNamedItem("valid").value&&"true"==e.attributes.getNamedItem("required").value&&(toggleMessage(e.id,!1,!0),valid=!1,scrollToID(e.id));valid&&constructPost(form)}function constructPost(form){let post=[],fieldSets=[],inputs=Object.entries(form),pos=0;for(let i=0;i{fs.id===e.id&&"INPUT"===e.nodeName&&e.checked&&post[fs.p].value.push(e.attributes.getNamedItem("checkvalue").value)}):"INPUT"!==e.nodeName&&"TEXTAREA"!==e.nodeName&&"SELECT"!==e.nodeName||"submit"!==e.type&&("hidden"==e.type?(post.push(e.name),pos++):(post.push({key:e.name,value:"on"===e.value?"Yes":e.value,id:e.id}),pos++)),"FIELDSET"===e.nodeName&&(fieldSets.push({q:e.previousElementSibling.innerText,id:e.id,p:pos}),post.push({key:e.previousElementSibling.innerText,value:[],id:e.id}),pos++)}sendData(post)}function sendData(data){addProgress(),window.fetch(`${window.location.href}`,{method:"POST",headers:{"Content-Type":"application/json",aid:aid,ptc:tc},body:JSON.stringify(data)}).then(res=>res.text()).then(data=>confirmationMessage())}function addProgress(){let f;document.querySelector(".progress").classList.remove("is-hidden")}function confirmationMessage(){let d;document.querySelector(".progress").classList.add("is-hidden");let f=document.getElementById(fid),c;document.querySelector(".confirmation").classList.remove("is-hidden"),f.classList.add("is-hidden"),rd&&setTimeout(()=>{window.parent.location.href=rd},3e3)}function scrollToID(id){let div=document.getElementById(id);div&&div.scrollIntoView({behavior:"smooth",block:"start"})}window.onload=function(){let form=document.getElementById(fid);form.onsubmit=submitted.bind(form),populateSelects()};