(()=>{"use strict";var t={8:(t,e,s)=>{t.exports=s.p+"images/5a9b103dc314a4c73396.png"},133:(t,e,s)=>{t.exports=s.p+"images/2ebcbbf6c232bb00f2a6.png"},323:(t,e,s)=>{t.exports=s.p+"images/de8424720353369deee7.png"},400:(t,e,s)=>{t.exports=s.p+"images/b46f607e557fa86ce5de.png"},408:(t,e,s)=>{t.exports=s.p+"images/5bf5ce672a831fe493f0.png"},439:(t,e,s)=>{t.exports=s.p+"images/cf8cd32effce8f14064b.png"},542:(t,e,s)=>{t.exports=s.p+"images/4cd0bf4f6c3826be20e9.png"},611:(t,e,s)=>{t.exports=s.p+"images/a84c2cd630adcb2fb844.png"},654:(t,e,s)=>{t.exports=s.p+"images/e7566180fedbca0ab884.png"},673:(t,e,s)=>{t.exports=s.p+"images/cb601ecb4902055371fa.png"},728:(t,e,s)=>{t.exports=s.p+"images/0615efa9ac4d4acf62b9.png"},934:(t,e,s)=>{t.exports=s.p+"images/890f12fd1d84b35d3027.png"},939:(t,e,s)=>{t.exports=s.p+"images/f4b9fc927a6cbb785fb7.png"},951:(t,e,s)=>{t.exports=s.p+"images/4c951c42399a4da74eb2.png"},971:(t,e,s)=>{t.exports=s.p+"images/ca96080890acb13f1452.png"}},e={};function s(r){var n=e[r];if(void 0!==n)return n.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,s),o.exports}s.m=t,s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.p="/",s.b=document.baseURI||self.location.href,s.p,new URL(s(400),s.b),new URL(s(542),s.b),new URL(s(971),s.b),new URL(s(439),s.b),new URL(s(654),s.b),new URL(s(323),s.b),new URL(s(951),s.b),new URL(s(934),s.b),new URL(s(133),s.b),new URL(s(408),s.b),new URL(s(939),s.b),new URL(s(611),s.b),new URL(s(673),s.b),new URL(s(728),s.b),new URL(s(8),s.b);class r{constructor(t){this._modal=document.querySelector(t),this._handleEscButton=t=>{"Escape"===t.key&&this.close()},this._handleOverlayClick=t=>{t.target.classList.contains("popup_opened")&&this.close()}}open(){document.querySelector("body").classList.add("body-fixed"),this._modal.classList.add("popup_opened"),document.addEventListener("keydown",this._handleEscButton),this._modal.addEventListener("mousedown",this._handleOverlayClick)}close(){this._modal.classList.remove("popup_opened"),document.removeEventListener("keydown",this._handleEscButton),this._modal.removeEventListener("mousedown",this._handleOverlayClick),document.querySelector("body").classList.remove("body-fixed")}setEventListeners(){this._modal.querySelector(".popup__button-close").addEventListener("mousedown",(()=>{this.close()}))}}function n(t,e,s,r,n){switch(t){case"default":default:e.textContent=s;break;case"loading":e.textContent=r;break;case"sended":e.textContent=n}}const o={inputSelector:".raschet-bem__input",submitButtonSelector:".button-bem_submit",inactiveButtonClass:"ui-button_disabled",inputErrorClass:"ui-button__type_error",errorClass:"raschet-bem__input-error_visible"},i=new class{constructor({baseUrl:t,headers:e}){this._baseUrl=t,this._headers=e}_isResponseOk(t){return t.ok?t.json():Promise.reject(`Ошибка: ${t.status}`)}getInitialCards(){return fetch("https://api.termoblok.ru/blogcards",{headers:this._headers}).then((t=>this._isResponseOk(t)))}getInitiatPartners(){return fetch("https://api.termoblok.ru/partners",{headers:this._headers}).then((t=>this._isResponseOk(t)))}sendCallForm(t){return fetch(`${this._baseUrl}/forms/call-form`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((t=>this._isResponseOk(t)))}sendBigForm(t){return fetch(`${this._baseUrl}/forms/base-form`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((t=>this._isResponseOk(t)))}}({baseUrl:"https://api.dromotron.ru",headers:{Accept:"application/json","Content-Type":"application/json;charset=utf-8"}}),a=document.forms.formCallBack,l=a.querySelector(o.submitButtonSelector),c=document.querySelector(".popup-callback-button"),u=new class{constructor(t,e){this._inputSelector=t.inputSelector,this._inputErrorClass=t.inputErrorClass,this._errorClass=t.errorClass,this._submitButtonSelector=t.submitButtonSelector,this._inactiveButtonClass=t.inactiveButtonClass,this._formElement=e,this._inputList=Array.from(this._formElement.querySelectorAll(this._inputSelector)),this._buttonElement=this._formElement.querySelector(this._submitButtonSelector)}_showInputError(t,e){const s=this._formElement.querySelector(`.${t.id}-error`);t.classList.add(this._inputErrorClass),s.textContent=e,s.classList.add(this._errorClass)}_hideInputError(t){const e=this._formElement.querySelector(`.${t.id}-error`);t.classList.remove(this._inputErrorClass),e.classList.remove(this._errorClass),e.textContent=""}_checkInputValidity(t){t.validity.valid?this._hideInputError(t):this._showInputError(t,t.validationMessage)}_hasInvalidInput(t){return t.some((t=>!t.validity.valid))}_toggleButtonState(t,e){this._hasInvalidInput(t)?(e.classList.add(this._inactiveButtonClass),e.setAttribute("disabled",!0)):(e.classList.remove(this._inactiveButtonClass),e.removeAttribute("disabled"))}_showErrors(t,e){t.forEach((s=>{this._checkInputValidity(s),this._toggleButtonState(t,e)}))}toggleButtonState(){this._toggleButtonState(this._inputList,this._buttonElement)}hasInvalidInput(){return this._hasInvalidInput(this._inputList)}disableSaveButton(){this._buttonElement.classList.add(this._inactiveButtonClass),this._buttonElement.setAttribute("disabled",!0)}cleanAllErrors(){this._inputList.forEach((t=>{this._hideInputError(t)}))}showErrors(){this._inputList.forEach((t=>{this._checkInputValidity(t),this.toggleButtonState(this._inputList,this._buttonElement)}))}showErrorsForStep(t){}_setEventListeners(){this._inputList.forEach((t=>{t.addEventListener("input",(()=>{this._checkInputValidity(t),this.toggleButtonState()}))}))}_setStepEventListeners(t){t.forEach((t=>{const e=t.inputs,s=t.button;console.log(`123 ${s}`),e.forEach((t=>{t.addEventListener("input",(()=>{this._checkInputValidity(t),this._toggleButtonState(e,s)}))}))}))}enableValidation(){this._formElement.addEventListener("submit",(t=>{t.preventDefault()})),this._setEventListeners()}checkStep(t){const e=this._sets[t].inputs,s=this._sets[t].button;return!this._hasInvalidInput(e)||(this._showErrors(e,s),this._toggleButtonState(e,s),!1)}enableStepValidation(){this._sets=[];const t=this._formElement.querySelector(".first-step"),e=t.querySelector(".first-step-button"),s=Array.from(t.querySelectorAll(this._inputSelector));this._sets.push({inputs:s,button:e});const r=this._formElement.querySelector(".second-step"),n=r.querySelector(".second-step-button"),o=Array.from(r.querySelectorAll(this._inputSelector));this._sets.push({inputs:o,button:n}),this._setStepEventListeners(this._sets)}}(o,a);u.enableValidation();const h=new class extends r{constructor({formSubmitHandler:t,formCleanError:e,checherValidation:s},r,n,o){super(r),this._formSubmitHandler=t,this._formCleanError=e,this._formElement=this._modal.querySelector(n),this._heading=this._modal.querySelector(".popup-form__title"),this._inputSelector=o,this._checker=s}_getInputValues(){return this._inputList=this._formElement.querySelectorAll(this._inputSelector),this._formValues={},this._inputList.forEach((t=>{this._formValues[t.name]=t.value})),console.log(this._formValues),this._formValues}open(t,e){this._heading.textContent=t||"Заявка в свободной форме",super.open()}close(){super.close(),this._formElement.reset(),this._formCleanError()}setEventListeners(){super.setEventListeners(),this._formElement.addEventListener("submit",(t=>{t.preventDefault(),this._checker()&&this._formSubmitHandler(this._getInputValues())}))}}({formSubmitHandler:t=>{n("loading",l,"Оставить заявку","Отправляем...","Отправлено успешно!"),i.sendCallForm(t).then((t=>{console.log(t),n("sended",l,"Оставить заявку","Отправляем...","Отправлено успешно!")})).catch((t=>console.log(t))).finally((()=>{setTimeout((()=>{h.close(),u.disableSaveButton(),n("default",l,"Оставить заявку","Отправляем...","Отправлено успешно!")}),900)}))},formCleanError:()=>{u.cleanAllErrors()},checherValidation:t=>!u.hasInvalidInput()||(u.showErrors(),!1)},".popup-callback",".popup__form",".raschet-bem__input");h.setEventListeners(),c.addEventListener("mousedown",(()=>{h.open()}));const p=new r(".popup-menu");p.setEventListeners(),document.querySelector(".nav__mobile-icon").addEventListener("click",(()=>{p.open(),console.log("111")}))})();