app.addModule(function(){var nav=document.querySelector('.cnav');if(!nav||nav.dataset.skipscroll){return}
var scrollBusy=!1;var sections=document.querySelectorAll('.sect');var navSections=document.querySelectorAll('.cnav__section');if(!navSections||!navSections.length){return}
var busyTimeout=null;var navigateSection=function(sectionIndex){clearTimeout(busyTimeout);scrollBusy=!0;var currentScrollTop=document.documentElement.scrollTop;var targetScrollTop=sections[sectionIndex].offsetTop-75;highlightSection(sectionIndex);var diff=targetScrollTop-currentScrollTop;if(Math.abs(diff)>1000){if(diff>1000){window.scroll({top:targetScrollTop-1000})}else if(diff<1000){window.scroll({top:targetScrollTop+1000})}}
setTimeout(function(){window.scroll({top:targetScrollTop,behavior:'smooth'});busyTimeout=setTimeout(function(){scrollBusy=!1},1000)},1)};var recalcCurrentSectionIndex=function(){var current=0;for(var i=0;i<sections.length;i++){var top=sections[i].getBoundingClientRect().top;if(top>=80){break}else{current=i}}
highlightSection(current);scrollBusy=!1};var highlightSection=function(index){var active=document.querySelector('.cnav__section--active');if(active){active.classList.remove('cnav__section--active')}
navSections[index].classList.add('cnav__section--active')};var onWindowScroll=function(){if(!scrollBusy){scrollBusy=!0;recalcCurrentSectionIndex()}};window.addEventListener('scroll',onWindowScroll);document.querySelector('.cnav__sections').addEventListener('click',function(e){var item=e.target.closest('.cnav__section');if(!item){return}
navigateSection(item.dataset.index);e.preventDefault()});recalcCurrentSectionIndex()});app.addModule(function(){var debug=!0;var el=document.querySelector('.cnav');var container=el.parentElement;var elBounds=el.getBoundingClientRect();var containerBounds=container.getBoundingClientRect();var windowHeight=window.innerHeight;var scrollTop=null;var scrollDirection='down';var headerHeight=document.querySelector('.hwarn__content')?90:60;if(el.dataset.skipsticky){return}
var createFSM=function(params){var state=params.state;var handlers=params.handlers;return{state:state,run:function(id,cbk){if(id){state.id=id}
for(var i=0;i<handlers.length;i++){if(handlers[i].accept[state.id]){var newStateId=handlers[i].handle(state);if(newStateId){if(debug){}
state.timestamp=Date.now();this.run(newStateId);break}}}
cbk&&cbk()}}};var fsm=createFSM({state:{id:'DEFAULT',timestamp:0},handlers:[{accept:{'DEFAULT':1},handle:function(){var suitedSticky=elBounds.height<=windowHeight-headerHeight||elBounds.height>=containerBounds.height;if(suitedSticky){return'STICKY'}
return'SCROLL'}},{accept:{'STICKY':1},handle:function(){if(el.dataset.mode!=='STICKY'){el.dataset.mode='STICKY'}}},{accept:{'SCROLL':1},handle:function(){elBounds=el.getBoundingClientRect();containerBounds=container.getBoundingClientRect();if(el.dataset.mode!=='SCROLL'){var offset=(containerBounds.top-elBounds.top)*-1;if(offset<60){offset=0}
el.style.transform='translateY('+offset+'px)';el.dataset.mode='SCROLL'}
if(scrollDirection==='down'){if(elBounds.bottom-windowHeight<0){return'FIXED_BOTTOM'}}else{if(elBounds.top>60&&scrollTop>60){return'FIXED_TOP'}}}},{accept:{'FIXED_TOP':1},handle:function(){if(el.dataset.mode!=='FIXED_TOP'){el.dataset.mode='FIXED_TOP'}
if(scrollTop<=60){return'SCROLL'}
if(scrollDirection==='down'){return'SCROLL'}}},{accept:{'FIXED_BOTTOM':1},handle:function(){if(el.dataset.mode!=='FIXED_BOTTOM'){el.dataset.mode='FIXED_BOTTOM'}
if(scrollDirection==='up'){return'SCROLL'}
elBounds=el.getBoundingClientRect();containerBounds=container.getBoundingClientRect();if(containerBounds.bottom<=elBounds.bottom){return'STUCK_BOTTOM'}}},{accept:{'STUCK_BOTTOM':1},handle:function(){if(el.dataset.mode!=='STUCK_BOTTOM'){el.dataset.mode='STUCK_BOTTOM'}
if(scrollDirection==='up'){return'SCROLL'}}}]});var resetFsm=function(){fsm.run('DEFAULT')};window.addEventListener('resize',function(){windowHeight=window.innerHeight;resetFsm()});var busy=!1;document.addEventListener('scroll',function(){var curScrollTop=document.documentElement.scrollTop;scrollDirection=curScrollTop<scrollTop?'up':'down';scrollTop=curScrollTop;if(!busy){busy=!0;window.requestAnimationFrame(function(){fsm.run(null,function(){busy=!1})})}});fsm.run();try{const resizeObserver=new ResizeObserver(resetFsm);const contentEl=document.querySelector('.company');contentEl&&resizeObserver.observe(contentEl)}catch(e){console.error(e.message)}});app.addModule(function(){const address=document.querySelector('.npage__link--address');if(!address){return}
address.addEventListener('click',()=>{PubSub.publish('showContactModalWindow',address.dataset.company)})});app.addModule(function(){const el=document.querySelector('.hcity');if(!el){return}
const store=JSON.parse(el.dataset.store);const select=app.tippyDropdown({arrow:!1,element:el,theme:'city',trigger:'click',placement:'bottom-start',offset:[-7,10],list:store.cities,onSelect:function(city){var cart=app.store.state.cart;if(cart&&cart.amount.sum){if(cart.company.id===city.id){return}
if(!window.confirm(store.locMenuSwitchConfirm)){return}}
window.location.assign(city.url)}});if(location.pathname&&location.pathname.length>1){return}
if(localStorage.getItem('isCorrectCity')){return}
const container={el:document.querySelector('.hcity__container'),show(){this.el.classList.add('hcity__container--visible')},hide(){this.el.classList.remove('hcity__container--visible')}};const correct=(isCorrect)=>{container.hide();localStorage.setItem('isCorrectCity','true');!isCorrect&&setTimeout(select.show,150)};container.el.addEventListener('click',(event)=>{event.stopPropagation();event.target.closest('[name="yes"]')&&correct(!0);event.target.closest('[name="no"]')&&correct()});document.addEventListener('click',()=>{container.hide()},{once:!0});window.addEventListener('load',()=>{container.show()})})