(()=>{"use strict";class e{constructor(e){this._modal=document.querySelector(e),this._handleEscButton=e=>{"Escape"===e.key&&this.close()},this._handleOverlayClick=e=>{e.target.classList.contains("popup_opened")&&this.close()},this._modal.querySelector(".popup__button-close").innerHTML=''}open(){this._modal.classList.add("popup_opened"),console.log("222"),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)}setEventListeners(){this._modal.querySelector(".popup__button-close").addEventListener("mousedown",(()=>{this.close()}))}}const t=new class extends e{constructor({popupImageSelector:e,popupImageDescSelector:t},o){super(o),this._popupImage=this._modal.querySelector(e),this._popupImageDesc=this._modal.querySelector(t)}open({link:e,desc:t}){this._popupImage.src=e,this._popupImage.alt=t,this._popupImageDesc.textContent=t,super.open()}close(){setTimeout((()=>{this._popupImage.src=""}),500),this._popupImage.alt="",super.close()}}({popupImageSelector:".popup__image",popupImageDescSelector:".popup__image-description"},".popup-image");t.setEventListeners(),document.querySelectorAll(".popup-image-item").forEach((e=>{e.addEventListener("mousedown",(e=>{e.stopPropagation(),console.log(e.target),t.open({link:e.target.querySelector("img")?e.target.querySelector("img").src:e.target.src,desc:e.target.querySelector("img")?e.target.querySelector("img").alt:e.target.alt})}))}))})();