`,document.body.appendChild(i);const a=()=>{i.classList.remove("mo"),setTimeout((()=>i.remove()),200)};return i.onclick=e=>(e.target===i||"IMG"===e.target.tagName||e.target.closest(".mx"))&&a(),setTimeout((()=>i.classList.add("mo")),10),a},$=(e,t=document)=>t.querySelector(e),$$=(e,t=document)=>t.querySelectorAll(e);class PriceModalManager{static init(){const e=$(".prices__cards"),t=$(".prices__table");e&&PriceModalManager.attachCardClickListener(e,t),t&&PriceModalManager.attachRowClickToTable(t)}static attachCardClickListener(e,t){e.addEventListener("click",(e=>{e.preventDefault();const n=e.target.closest(".prices__card");if(!n)return;const i=`Стоимость › ${$(".prices__card-title",n)?.textContent||""}`,a=$(".prices__card-picts",n);if(!a)return;const s=Array.from($$("img",a)).map((e=>e.src)),o=Array.from($$(".prices__row",t)).filter((e=>{const t=$("img",$(".prices__pict",e));return t&&s.includes(t.src)})),r=document.createElement("table");r.className="prices__table";const c=document.createElement("tbody");o.forEach((e=>c.appendChild(e.cloneNode(!0)))),r.appendChild(c),PriceModalManager.openTableModal(r.outerHTML,i)}))}static attachRowClickToTable(e){$$(".prices__row",e).forEach((e=>e.addEventListener("click",PriceModalManager.handleRowClick)))}static openTableModal(e,t){createModal(e,t,1),setTimeout((()=>{const e=$('[role="dialog"] .prices__table');e&&PriceModalManager.attachRowClickToTable(e)}),0)}static handleRowClick(e){e.preventDefault();const t=e.currentTarget,n=PriceModalManager.extractRowDetails(t);if(!n.rowImage)return;const i=PriceModalManager.generateModalContent(n);createModal(i,n.itemInfo,1)}static extractRowDetails(e){return{rowImage:$("img",$(".prices__pict",e))?.src||"",itemInfo:$(".prices__item strong",e)?.innerHTML||""}}static generateModalContent({rowImage:e,itemInfo:t}){return`
`}}PriceModalManager.init(),$(".about__summary")?.addEventListener("click",(e=>{e.preventDefault(),createModal($(".about__details .features").outerHTML,e.target.getAttribute("title")||"")})),$$(".ratings__card").forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault();const n=e.getAttribute("id");createModal({yandex:'',tripadvisor:'
',google:''}[n],e.querySelector(".ratings__platform").textContent,1)}))}));class PickerUtils{static styles="";static $(e,t=document){return t.querySelector(e)}static $$(e,t=document){return Array.from(t.querySelectorAll(e))}static createContainer(e){const t=this.$(e);if(!t)throw new Error(`Container not found: ${e}`);return t}static setKeyEvents(e){e.addEventListener("keydown",(t=>{["Enter"," "].includes(t.key)&&(t.preventDefault(),e.click())}))}static updateDisplay(e,t,n=""){PickerUtils.$(e).innerText=`${t||"не указано"}${t?n:""}`}}class DatePicker extends PickerUtils{#e;#t;#n;#i;constructor(){super(),this.#t=null}getDateString(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}formatDate(e){return{day:e.getDate(),month:e.toLocaleString(this.#e,{month:"short"}),weekday:e.toLocaleString(this.#e,{weekday:"short"})}}generate(e="UTC"){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate());this.#i.innerHTML="";for(let e=0;e<14;e++){const i=new Date(n);i.setDate(n.getDate()+e);const a=this.getDateString(i),s=a===this.getDateString(t)&&t.getHours()>=18,{day:o,month:r,weekday:c}=this.formatDate(i),l=document.createElement("div");l.className="date-picker-item",l.dataset.date=a,l.tabIndex=0,l.innerHTML=`${c}${o}${r}`,0!==i.getDay()&&6!==i.getDay()||l.classList.add("weekend"),s?l.classList.add("disabled"):(l.addEventListener("click",(()=>this.#a(l,a))),this.constructor.setKeyEvents(l)),this.#t===a&&l.classList.add("selected"),this.#i.appendChild(l)}}#a(e,t){const n=e.classList.contains("selected");this.constructor.$$(".date-picker-item",this.#i).forEach((e=>e.classList.remove("selected"))),n?this.#t=null:(e.classList.add("selected"),this.#t=t),this.#n?.(this.#t)}init({containerSelector:e,initialDate:t=null,localeString:n="default",timeZone:i="UTC",onChange:a=()=>{}}){this.#i=this.constructor.createContainer(e),this.#e=n,this.#t=t,this.#n=a,this.#i.classList.add("date-picker-container"),this.generate(i)}destroy(){this.#i.innerHTML="",this.#t=null,this.#n=null,this.#i=null}}class TimePicker extends PickerUtils{#s;#n;#i;#o;#r;#t;constructor(){super(),this.#s=null,this.#o=0,this.#r=23,this.#t=null}getDateString(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}generate(e=0,t=23,n=null){this.#i.innerHTML="";const i=new Date,a=this.getDateString(i),s=(n||a)===a,o=s&&i.getHours()>=18;for(let n=e;n<=t;n++){const e=`${n}:00`,t=s&&i.getHours()>n,a=o||t,r=document.createElement("div");r.className="time-picker-item date-picker-item",r.dataset.time=e,r.tabIndex=0,r.innerHTML=`≈${e.split(":")[0]}:00 `,a?r.classList.add("disabled"):(r.addEventListener("click",(()=>this.#a(r,e))),this.constructor.setKeyEvents(r)),this.#s===e&&r.classList.add("selected"),this.#i.appendChild(r)}}#a(e,t){const n=e.classList.contains("selected");this.constructor.$$(".time-picker-item",this.#i).forEach((e=>e.classList.remove("selected"))),n?this.#s=null:(e.classList.add("selected"),this.#s=t),this.#n?.(this.#s)}init({containerSelector:e,initialTime:t=null,startHour:n=0,endHour:i=23,selectedDate:a=null,onChange:s=()=>{}}){this.#i=this.constructor.createContainer(e),this.#s=t,this.#n=s,this.#o=n,this.#r=i,this.#t=a,this.#i.classList.add("time-picker-container"),this.generate(n,i,a)}update(e){this.#t=e,this.#s=null,this.generate(this.#o,this.#r,e),this.#n?.(this.#s)}destroy(){this.#i.innerHTML="",this.#s=null,this.#n=null,this.#i=null,this.#o=0,this.#r=23,this.#t=null}}class NumberPicker extends PickerUtils{#c;#n;#i;constructor(){super(),this.#c=null}generate(e,t,n){const i=this.#c||e;this.#i.innerHTML=``;const a=this.constructor.$(".number-picker-slider",this.#i),s=this.constructor.$(".decrement",this.#i),o=this.constructor.$(".increment",this.#i);a.addEventListener("input",(()=>{this.#c=a.value,this.#n?.(a.value)})),s.addEventListener("click",(e=>{e.preventDefault(),a.stepDown(),a.dispatchEvent(new Event("input"))})),o.addEventListener("click",(e=>{e.preventDefault(),a.stepUp(),a.dispatchEvent(new Event("input"))}))}init({containerSelector:e,initialValue:t=0,min:n=0,max:i=100,step:a=1,onChange:s=()=>{}}){this.#i=this.constructor.createContainer(e),this.#c=t,this.#n=s,this.#i.classList.add("number-picker-container"),this.generate(n,i,a)}destroy(){this.#i.innerHTML="",this.#c=null,this.#n=null,this.#i=null}}class PhoneNumberPicker extends PickerUtils{#l="+375";#n=null;formatPhoneNumber(e){const t=e.replace(/[^\d]+/g,""),n=t.match(/^375(\d{0,2})(\d{0,3})(\d{0,2})(\d{0,2})$/);if(n){const[,e,t,i,a]=n;return`+375 ${e?`(${e})`:""} ${t||""}${i?`-${i}`:""}${a?`-${a}`:""}`}return t.length>=12?this.formatPhoneNumber(t.slice(0,12)):e}updateDisplay(e){this.constructor.$(".phone-display",e).textContent=this.#l}generateKeyboard(e){const t=document.createElement("div");t.className="phone-keyboard",[["(25)","(29)","(33)","(44)"],["1","2","3","⌫"],["4","5","6","✕"],["7","8","9","0"]].forEach((n=>{const i=document.createElement("div");i.className="phone-keyboard-row",n.forEach((t=>{const n=document.createElement("div");n.className="phone-key",t.startsWith("(")&&n.classList.add("phone-key--area-code"),"⌫"===t&&(n.classList.add("phone-key--delete"),n.classList.add("elli"),t+="исправить"),"✕"===t&&(n.classList.add("phone-key--reset"),n.classList.add("elli"),t+="очистить"),isNaN(t)||n.classList.add("phone-key--digit"),n.innerHTML=t,n.addEventListener("click",(()=>{if(t.startsWith("⌫")&&this.#l.length>7)this.#l=this.formatPhoneNumber(this.#l.replace(/[^\d]+/g,"").slice(0,-1));else if(t.startsWith("✕"))this.#l="+375";else if(isNaN(t)){if(t.startsWith("(")){const e=this.#l.replace(/[^\d]+/g,""),n=t.replace(/[^\d]+/g,"");this.#l=this.formatPhoneNumber(e.slice(0,3)+n+e.slice(5))}}else this.#l+=t;this.#l=this.formatPhoneNumber(this.#l),this.updateDisplay(e),this.updateAreaCodeSelection(e),this.#n?.(this.#l)})),i.appendChild(n)})),t.appendChild(i)})),e.appendChild(t)}generate(e){e.innerHTML="";const t=document.createElement("input");t.type="tel",t.style.position="absolute",t.style.opacity="0",t.style.pointerEvents="none",t.style.height="0",e.appendChild(t);const n=document.createElement("div");n.className="phone-display",n.textContent=this.#l,n.addEventListener("click",(()=>{t.focus()})),t.addEventListener("keydown",(t=>{const n=t.key;n>="0"&&n<="9"?this.#l+=n:"Backspace"===n&&this.#l.length>7&&(this.#l=this.formatPhoneNumber(this.#l.replace(/[^\d]+/g,"").slice(0,-1))),this.#l=this.formatPhoneNumber(this.#l),this.updateDisplay(e),this.updateAreaCodeSelection(e),this.#n?.(this.#l)})),e.appendChild(n),this.generateKeyboard(e),this.updateDisplay(e),this.updateAreaCodeSelection(e)}updateAreaCodeSelection(e){const t=e.querySelectorAll(".phone-key--area-code"),n=this.#l.replace(/[^\d]+/g,"");t.forEach((e=>{const t=e.textContent.replace(/[^\d]+/g,"");n.slice(3,5)===t?e.classList.add("selected"):e.classList.remove("selected")}))}init({containerSelector:e,onNumberChange:t,initialNumber:n="+375"}){const i=this.constructor.createContainer(e);i&&(i.classList.add("phone-input-container"),this.#n=t,this.#l=this.formatPhoneNumber(n),this.generate(i))}destroy(){this.#l="+375",this.#n=null}getPhoneNumber(){return this.#l}clear(){this.#l="+375";const e=this.constructor.$(".phone-input-container");e&&this.updateDisplay(e)}}class MultiSelectPicker extends PickerUtils{#i;#d=new Set;#n;#m;constructor(e){super(),this.#m=e}#a(e){e.classList.toggle("selected");const t=PickerUtils.$("small",e)?.innerText;e.classList.contains("selected")?this.#d.add(t):this.#d.delete(t);const n=Array.from(this.#d);this.#n?.({items:n.join(", "),count:n.length})}init({containerSelector:e,initialItems:t=[],onChange:n=()=>{}}){this.#i=this.constructor.createContainer(e),this.#n=n,this.#d=new Set(t),this.#i.classList.add("multi-select-picker-container"),this.constructor.$$(`.${this.#m}`,this.#i).forEach((e=>{this.constructor.setKeyEvents(e);const t=e.querySelector("small")?.textContent;this.#d.has(t)&&e.classList.add("selected"),e.addEventListener("click",(t=>{t.preventDefault(),this.#a(e)}))}))}destroy(){this.#i.innerHTML="",this.#d.clear(),this.#n=null,this.#i=null}}class Booking{static tpl="";static msg="";static mem={};static getTodayDateByMinskTime(){const e=new Date;return new Date(e.getTime()+108e5).toISOString().split("T")[0]}static saveToStorage(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){Booking.mem[e]=t}}static loadFromStorage(e){try{const t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch(t){return Booking.mem[e]}}static mdl=Booking.loadFromStorage("bkng_mdl")||{};static storeOnRender(){Booking.saveToStorage("bkng_mdl",Booking.mdl)}static renderSummary(){const e=[["Мобильный",Booking.mdl.phnn||""],["Имя",Booking.mdl.name||""],["Дата / время",(Booking.mdl.date||"")+(Booking.mdl.date&&Booking.mdl.time?" / ":"")+(Booking.mdl.time||"")],["Транспорт",Booking.mdl.tech||""],["Кол-во чел.",(Booking.mdl.nmbr?Booking.mdl.nmbr+" чел.":"не знаем")+" "+(Booking.mdl.opts||"")+""],["Примечание",Booking.mdl.cmnt||""]];$(".phone-display")?.classList[Booking.mdl.phnn?"add":"remove"]("phone-valid"),Booking.mdl.phnn&&($(".pckd__phnn").innerText=Booking.mdl.phnn),$("#summ").innerHTML=e.map((e=>e[1]?`${e[0]}
${e[1]}
`:"")).join(""),Booking.msg=e.map((e=>e[1]?`${e[0]}\n*${e[1]}*\n\n`:"")).join(""),Booking.storeOnRender()}static async cftt(e,t={particleCount:50,spread:70,origin:{y:.8}}){try{"confetti"in window||await import("https://unpkg.com/canvas-confetti@1.9.3/dist/confetti.browser.js"),e&&confetti(t)}catch(e){}}}const bron=e=>{e.preventDefault(),Booking.cftt(),Booking.tpl||(Booking.tpl=$("#bkng").innerHTML,$("#bkng").innerHTML="");const t=createModal(Booking.tpl,"Онлайн-бронирование",1);setTimeout((()=>{$("#mdl_name").value=Booking.mdl.name||"",$("#mdl_name")?.addEventListener("input",(e=>{Booking.mdl.name=e.target.value,Booking.renderSummary()})),$("#mdl_cmnt").value=Booking.mdl.cmnt||"",$("#mdl_cmnt")?.addEventListener("input",(e=>{Booking.mdl.cmnt=e.target.value,Booking.renderSummary();const t=Booking.mdl.cmnt.length;$(".tpdlnght").innerText=t?`${t}/400`:""})),$("#submit-btn")?.addEventListener("click",(async e=>{e.preventDefault();const n=createModal('',"Отправка данных..."),i=e=>new Promise((t=>setTimeout(t,e)));await i(200),await fetch("/api/v1/bookings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Booking.mdl)}),n(),await i(300);const a=$("#summ").innerHTML;t(),await i(300);const s=createModal(``,"Бронирование успешно",1);$("#x0").addEventListener("click",(()=>s())),await i(200),Booking.cftt(1,{particleCount:50,origin:{y:.8}}),await i(200),Booking.cftt(1,{particleCount:50,origin:{y:.8,x:.3}}),Booking.cftt(1,{particleCount:50,origin:{y:.8,x:.7}}),await i(200),Booking.cftt(1,{particleCount:100,origin:{y:.9}})}));const e=new TimePicker;e.init({containerSelector:"#time-picker",initialTime:Booking.mdl.time,startHour:9,endHour:18,selectedDate:Booking.mdl.date,onChange:e=>{Booking.mdl.time=e,Booking.renderSummary(),PickerUtils.updateDisplay(".pckd__time",e)}}),(new DatePicker).init({containerSelector:"#date-picker",initialDate:Booking.mdl.date,timeZone:"Europe/Minsk",localeString:"ru-RU",onChange:t=>{Booking.mdl.date=t,Booking.renderSummary(),PickerUtils.updateDisplay(".pckd__date",t),e.update(t)}}),(new NumberPicker).init({containerSelector:"#number-picker",initialValue:Booking.mdl.nmbr,min:0,max:20,step:1,onChange:e=>{Booking.mdl.nmbr=e,Booking.renderSummary(),PickerUtils.updateDisplay(".pckd__nmbr",e," чел.")}}),new MultiSelectPicker("kidspets-picker-item").init({containerSelector:"#kidspets-picker",initialItems:(Booking.mdl.opts||"").split(", ").filter(Boolean),onChange:({items:e})=>{Booking.mdl.opts=e,Booking.renderSummary()}}),new MultiSelectPicker("tech-picker-item").init({containerSelector:"#tech-picker",initialItems:(Booking.mdl.tech||"").split(", ").filter(Boolean),onChange:({items:e,count:t})=>{Booking.mdl.tech=e,Booking.renderSummary(),PickerUtils.updateDisplay(".pckd__tech",t?`${t} выбрано`:"")}}),Booking.mdl.tech&&PickerUtils.updateDisplay(".pckd__tech",Booking.mdl.tech?`${Booking.mdl.tech.split(",").length} выбрано`:""),Booking.mdl.date&&PickerUtils.updateDisplay(".pckd__date",Booking.mdl.date),Booking.mdl.time&&PickerUtils.updateDisplay(".pckd__time",Booking.mdl.time),Booking.mdl.nmbr&&PickerUtils.updateDisplay(".pckd__nmbr",Booking.mdl.nmbr," чел."),(new PhoneNumberPicker).init({containerSelector:"#phone-input",onNumberChange:e=>{Booking.mdl.phnn=19===e.length?e:"",Booking.renderSummary()},initialNumber:Booking.mdl.phnn||"+375"}),Booking.renderSummary()}),10)};$(".hero__button.header__button")?.addEventListener("click",bron);