!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var s in i)("object"==typeof exports?exports:e)[s]=i[s]}}(Depicter,(()=>(()=>{"use strict";var e={};(e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})})(e);const{Layer:t,env:i}=window.Depicter;class s extends t{constructor(e,t,s,o,r,l){super(e,t,s,o,r,l),this.type="form:submit",this.element.setAttribute("type","submit"),this.frame.classList.add(`${i.prefix}-form-submit-layer`),this.frame.classList.add(`${i.prefix}-button-layer`),this.frame.classList.add(`${i.prefix}-no-swipe`)}_setupContent(){this.survey=this.holder.composer?.survey;const e=this.survey?.form??this.element.closest("form"),t=e?.getAttribute("data-local-id")||e?.id;for(this.survey?.form&&(this.element.setAttribute("form",e.id),this._enableOnlyVisibleOnLastStep(),this.element.addEventListener("click",(e=>{this.survey.isProceedRestricted()&&(e.preventDefault(),this.holder.composer.trigger("surveyPreventProceed"))})),this.holder.composer.on("targetIndexChange",(()=>{this.holder.composer.navigator.targetIndex>this.survey.lastStepIndex?this.hide():this.show()}))),this.holder.composer.layersById[t]&&(this.formLayer=this.holder.composer.layersById[t]),this.formLayer?this.formLayer.on("formSubmit, formSubmitted, formSubmitError",this._onFormSubmit.bind(this)):this.holder.composer.on("formSubmit,formSubmitted, formSubmitError",this._onFormSubmit.bind(this)),this.layerForAction=this.formLayer||this.holder.composer,this.loading=document.createElement("div"),this.loading.classList.add(`${i.prefix}-dot-flashing`),[...Array(3)].forEach((()=>{const e=document.createElement("span");this.loading.appendChild(e)})),this.label=document.createElement("span"),this.label.classList.add(`${i.prefix}-button-content`);this.element.firstChild;)this.label.appendChild(this.element.firstChild);this.element.appendChild(this.label),this.element.appendChild(this.loading)}_toggleLoading(e){e?(this.label.style.display="none",this.loading.style.visibility="visible",this.loading.style.opacity=1):(this.label.style.display="block",this.loading.style.visibility="hidden",this.loading.style.opacity=0)}_onFormSubmit(e){this.element.disabled=!1,"formSubmit"===e?this._toggleLoading(!0):this._toggleLoading(!1)}_enableOnlyVisibleOnLastStep(){const e=()=>{this.survey.isLastStep?this.show():this.hide()};e(),this.holder.composer.on("isLastSurveyStep, foregroundLayersStatusCheck",e)}}return window.Depicter.externalLayers["form:submit"]=s,window.Depicter.externalLayers["survey:submit"]=s,e})()));