(()=>{"use strict";const t=class{constructor(t,e=!1){const i=t.querySelector(".ablocks-form-multi-step").getAttribute("data-step");this.totalSteps=i,this.editor=e,this.childElements=t.querySelectorAll(".ablocks-form-multi-step-child"),this.formStepsBtn=t?.querySelectorAll(".ablocks-form-multi-step__step-wrapper"),this.currentActive=0;const s=t?.querySelector(".ablocks-form-multi-step__prev-btn");this.prevButton=s;const r=t?.querySelector(".ablocks-form-multi-step__next-btn");this.nextButton=r,this.handleCurrentActive(0),s?.addEventListener("click",()=>this.handlePrevClick(0)),r?.addEventListener("click",()=>this.handleNextClick(0))}handleCurrentActive=function(t){1===Number(this.totalSteps)||this.currentActive+1===Number(this.totalSteps)?(this.nextButton.type="button",this.nextButton.innerText="Submit"):(this.nextButton.innerText="Next 🡢",this.nextButton.type="button"),0===t&&this.prevButton?this.prevButton.style.display="none":t>0&&this.prevButton&&(this.prevButton.style.display="block"),this.formStepsBtn?.forEach(t=>t.classList.remove("ablocks-form-multi-step__step--active")),this.formStepsBtn[t]?.classList.add("ablocks-form-multi-step__step--active"),this.childElements?.forEach(t=>t.classList.remove("ablocks-form-multi-step-child--active")),this.childElements[t]?.classList.add("ablocks-form-multi-step-child--active")};handlePrevClick=function(){this.currentActive-=1,this.handleCurrentActive(this.currentActive)};handleNextClick=function(){if(this.currentActive+1>=Number(this.totalSteps))return void(!1===this.editor&&(this.nextButton.type="submit",this.nextButton.classList.add("ablocks-form-builder__submit-button")));this.nextButton.classList.remove("ablocks-form-builder__submit-button");const t=this.childElements[this.currentActive].querySelectorAll(".ablocks-form-builder__field");let e=!0;t.forEach(t=>{const i="true"===t.getAttribute("data-required"),s=t.querySelector("input, textarea"),r=t.querySelector("select"),c=t.querySelector('input[type="checkbox"]'),l=t.querySelector('input[type="radio"]'),o=t.querySelectorAll(".ablocks-form-builder__radio-option"),n=t.querySelector('input[type="radio"]:checked');if(o?.length>=1){const s=parseInt(t?.getAttribute("data-minimum-value")),r=parseInt(t?.getAttribute("data-maximum-value")),c=Array.from(o).filter(t=>t.classList.contains("checked")).length;(s>c&&i||r<c&&i||i&&c<1)&&(e=!1)}i&&(c&&!c.checked||l&&!n||s&&""===s.value.trim()||r&&""===r.value)&&(e=!1),t.classList.toggle("error-msg",!e)}),e&&(this.currentActive+=1,this.handleCurrentActive(this.currentActive))}};document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".ablocks-block--form-multi-step").forEach(e=>{new t(e,!1)})})})();