(()=>{class o{constructor(){this.controller=new window.jvbForm,document.querySelectorAll(".jvb-form-block form").forEach((o=>{this.controller.registerForm(o,{autosave:!0})})),this.controller.subscribe(((o,t)=>{"form-submit"===o&&this.handleFormSubmission(t)}))}async handleFormSubmission(o){let t=o.formId,e=o.config,r=o.fullData,s=e.element,n={"X-WP-Nonce":jvbSettings.nonce,"Content-Type":"application/json"};s.closest(".jvb-form-block"),this.controller.showFormStatus(t,"uploading");try{const o=await fetch(`${jvbSettings.api}forms`,{method:"POST",headers:n,body:JSON.stringify(r)});if(!o.ok){this.controller.showFormStatus(t,"error");const e=await o.json().catch((()=>({})));throw new Error(e.message||`Request failed with status ${o.status}`)}this.controller.showFormStatus(t,"submitted"),this.controller.showSummary(t,".jvb-form-block")}catch(o){throw o}finally{this.controller.store.delete(t)}}}document.addEventListener("DOMContentLoaded",(function(){new o}))})();