!function(){const e=.4,t=.05,n=60,o=100,i=120;class s{constructor(){document.querySelector("#nectar_fullscreen_rows")||(s.instance&&s.instance.destroy(),this.sections=document.querySelectorAll("div[data-color-change-section-bg-color], section[data-color-change-section-bg-color]"),this.currentSection=null,this.observer=null,this.boundHandleIntersection=this.handleIntersection.bind(this),this.boundOnScroll=this.onScroll.bind(this),this.boundOnResize=this.onResize.bind(this),this.boundOnOrientationChange=this.onOrientationChange.bind(this),this.lastScrollY=window.scrollY,this.scrollDirection="down",this.isRescanScheduled=!1,this.rafId=null,this.resizeDebounceId=null,this.isCoarsePointer=!("undefined"==typeof window||!window.matchMedia)&&(window.matchMedia("(pointer: coarse)").matches||window.matchMedia("(hover: none)").matches),this.setupEditorEvents(),0!==this.sections.length?(this.prepareContainerAttributesIfNeeded(),this.init(),this.setupScrollEvents(),s.instance=this):s.instance=this)}prepareContainerAttributesIfNeeded(){if(!Array.from(this.sections).some(e=>e.closest(".nectar-global-section")))return;const e=document.querySelector(".container-wrap");if(!e)return;const t=getComputedStyle(document.documentElement),n=t.getPropertyValue("--nectar-bg-color").trim(),o=t.getPropertyValue("--nectar-font-color").trim();if(n&&o){e.setAttribute("data-color-change-section-bg-color",n),e.setAttribute("data-color-change-section-text-color",o);const t=Array.from(this.sections);-1===t.indexOf(e)&&(t.push(e),this.sections=t)}}init(){document.documentElement.style.setProperty("--page-color-change-section-transition-time","0s");this.observer=new IntersectionObserver(this.boundHandleIntersection,{root:null,rootMargin:"0px",threshold:[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1]}),this.sections.forEach(e=>{this.observer.observe(e)}),this.scheduleRescan(),setTimeout(()=>{this.sections.forEach(e=>{if(e.classList.contains("container-wrap"))return;const t=e.querySelector(".row-bg.using-bg-color");e.style.backgroundColor="transparent",t&&(t.style.backgroundColor="transparent")})},n),setTimeout(()=>{document.documentElement.style.setProperty("--page-color-change-section-transition-time","0.8s"),this.sections.length>0&&document.body.classList.add("has-color-change-section-bg-color")},o)}reload(){this.observer&&(this.observer.disconnect(),this.observer=null),this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null,this.isRescanScheduled=!1),this.removeScrollEvents(),this.sections=document.querySelectorAll("div[data-color-change-section-bg-color], section[data-color-change-section-bg-color]"),0!==this.sections.length?(this.currentSection=null,this.prepareContainerAttributesIfNeeded(),this.init(),this.setupScrollEvents()):document.body.classList.remove("has-color-change-section-bg-color")}hasVisibleDescendantSection(e){for(let n=0;nt)return!0}return!1}handleIntersection(e){this.updateScrollDirection(window.scrollY),this.scheduleRescan()}shouldConsiderSection(e){if(!this.currentSection)return!0;const t=this.currentSection.getBoundingClientRect(),n=e.getBoundingClientRect();return"down"===this.scrollDirection?n.top>=t.top:n.top<=t.top}calculateVisibility(e){const t=e.getBoundingClientRect(),n=window.innerHeight,o=Math.min(t.bottom,n)-Math.max(t.top,0),i=t.height;return i>n?o/n:o/i}rescanVisibleSections(){let t=null,n=0;const o=Array.isArray(this.sections)?this.sections:Array.from(this.sections);for(let i=0;i=e&&r>n&&this.shouldConsiderSection(s)&&(t=s,n=r)}t&&t!==this.currentSection&&this.applySectionColors(t),this.isRescanScheduled=!1,this.rafId=null}scheduleRescan(){this.isRescanScheduled||(this.isRescanScheduled=!0,"undefined"!=typeof window&&window.requestAnimationFrame?this.rafId=window.requestAnimationFrame(()=>this.rescanVisibleSections()):setTimeout(()=>this.rescanVisibleSections(),16))}onScroll(){this.updateScrollDirection(window.scrollY),this.scheduleRescan()}onResize(){this.resizeDebounceId&&clearTimeout(this.resizeDebounceId),this.resizeDebounceId=setTimeout(()=>{this.scheduleRescan(),this.resizeDebounceId=null},i)}onOrientationChange(){this.scheduleRescan(),setTimeout(()=>this.scheduleRescan(),i)}isInViewport(e){const t=e.getBoundingClientRect(),n=window.innerHeight;return Math.min(t.bottom,n)-Math.max(t.top,0)>0}applySectionColors(e){const t=e.getAttribute("data-color-change-section-bg-color"),n=e.getAttribute("data-color-change-section-text-color");document.documentElement.style.setProperty("--nectar-page-background-color",t),document.documentElement.style.setProperty("--nectar-page-text-color",n),document.documentElement.style.setProperty("--nectar-page-light-text-color",n),this.currentSection=e}updateScrollDirection(e){const t=e>this.lastScrollY?"down":"up";Math.abs(e-this.lastScrollY)>5&&(this.scrollDirection=t,this.lastScrollY=e)}setupEditorEvents(){jQuery(window).off("vc_reload.nectarColorChange"),jQuery(window).on("vc_reload.nectarColorChange",()=>{this.reload()})}setupScrollEvents(){this.removeScrollEvents(),window.addEventListener("scroll",this.boundOnScroll,{passive:!0}),this.isCoarsePointer&&"onorientationchange"in window?window.addEventListener("orientationchange",this.boundOnOrientationChange):window.addEventListener("resize",this.boundOnResize,{passive:!0})}removeScrollEvents(){jQuery(window).off("scroll.nectarColorChange"),window.removeEventListener("scroll",this.boundOnScroll,{capture:!1}),window.removeEventListener("resize",this.boundOnResize,{capture:!1}),window.removeEventListener("orientationchange",this.boundOnOrientationChange,{capture:!1})}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),jQuery(window).off("vc_reload.nectarColorChange"),this.removeScrollEvents(),this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null,this.isRescanScheduled=!1),this.resizeDebounceId&&(clearTimeout(this.resizeDebounceId),this.resizeDebounceId=null),s.instance===this&&(s.instance=null)}}s.instance=null,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function(){new s}):new s}();