1import{n}from"./stimulus-helpers-De2POZIB-2.js";import h from"./ez-base-controller-DGqPqFNh-2.js";import{m as a}from"./ez-custom-events-BYMYvbUc-2.js";import{t as c}from"./media-matcher-BzjwVVkK-2.js";function m(t){let e;return(...i)=>{e&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{t(...i)})}}var l=new c,d=class extends h{constructor(...t){super(...t),this.lastScrolledPosition=window.scrollY,this.topThreshold=50,this.isScrolled=!1,this.setupSticky=()=>{this.setupStickyMediaQueries(),this.initialState()},this.initialState=()=>{this.showElement(),window.addEventListener("scroll",this.dynamicScrollCheck)},this.isScrollingUp=()=>this.lastScrolledPosition>window.scrollY,this.isScrolledToTop=()=>window.scrollY<=0,this.isCloseToTop=(e=!1)=>{const i=this.element,s=e?this.topThreshold:0;return window.scrollY<=i.offsetHeight+s},this.hasScrolledPastLastStickyElement=()=>{const e=document.querySelectorAll('[data-controller~="dynamic-sticky"]'),i=Array.from(e).reduce((s,r)=>{const o=s.offsetTop+s.offsetHeight;return r.offsetTop+r.offsetHeight>o?r:s});return window.scrollY>i.clientHeight},this.showElement=()=>{requestAnimationFrame(()=>{this.element.classList.remove(this.hideElementClass),this.element.classList.add(this.showElementClass),this.isCloseToTop()?this.hideStickyHeaderSearchBar():this.showStickyHeaderSearchBar(),this.applyStickyOffset()})},this.hideElement=()=>{requestAnimationFrame(()=>{this.element.classList.remove(this.showElementClass),this.element.classList.add(this.hideElementClass),this.removeStickyOffset()})},this.showStickyHeaderSearchBar=({mobile:e}={mobile:!1})=>{this.shouldShowStickySearchBar(e)&&requestAnimationFrame(()=>{this.mainSearchBar.classList.add("is-visible"),this.searchField.disabled=!1})},this.applyStickyOffset=()=>{if(!this.hasOffsetElementSelectorValue)return;const e=document.querySelector(this.offsetElementSelectorValue),i=this.element;requestAnimationFrame(()=>{i.style.top=`${e.offsetHeight}px`})},this.removeStickyOffset=()=>{requestAnimationFrame(()=>{this.element.style.top="0"})},this.applyStickyHeader=()=>{this.isScrollingUp()?this.scrollingUpActions():this.scrollingDownActions(),this.lastScrolledPosition=window.scrollY},this.scrollingUpActions=()=>{this.showElement(),requestAnimationFrame(()=>{this.isScrolledToTop()&&(this.element.classList.remove(this.showElementClass),this.element.classList.remove(this.isStuckClass))})},this.scrollingDownActions=()=>{this.hasScrolledPastLastStickyElement()&&requestAnimationFrame(()=>{this.element.classList.add(this.isStuckClass),this.hideElement()})},this.dynamicScrollCheck=m(this.applyStickyHeader)}static{this.classes=["isStuck","showElement","hideElement"]}static{this.values={mobileOnly:{type:Number,default:0},waitToInit:{type:Boolean,default:!1},offsetElementSelector:String,scrollOffset:{type:Number,default:0}}}connect(){this.waitToInitValue?window.addEventListener(a,this.setupSticky):this.setupSticky(),window.addEventListener("resize",this.applyStickyOffset)}disconnect(){window.removeEventListener(a,this.setupSticky),window.removeEventListener("resize",this.applyStickyOffset),window.removeEventListener("scroll",this.dynamicScrollCheck)}setupStickyMediaQueries(){l.addMediaQuery("(max-width: 635px)",()=>this.showStickyHeaderSearchBar({mobile:!0}),this.initialState),l.evaluateAll(),l.addListeners()}hideStickyHeaderSearchBar(){this.shouldHideStickySearchBar()&&requestAnimationFrame(()=>{this.mainSearchBar.classList.remove("is-visible"),this.searchField.disabled=!0})}mobileSearchButtonVisible(){const t=document.querySelector('[data-action*="click->site-header#toggleMobileSearch"]');return t?getComputedStyle(t).display!=="none":!1}shouldShowStickySearchBar(t){return this.mainSearchBar?!!(!this.isCloseToTop(!0)||t):!1}shouldHideStickySearchBar(){return!(this.mobileSearchButtonVisible()||!document.body.classList.contains("main-search-soft-hidden")||!this.mainSearchBar)}get mainSearchBar(){return document.querySelector(".ez-site-header__search-fullwidth")}get searchField(){return this.mainSearchBar.querySelector(".ez-search-form__input")}};n({name:"dynamic-sticky",import:d});export{d as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.