"use strict";(globalThis.webpackChunkglobalheaderweb=globalThis.webpackChunkglobalheaderweb||[]).push([[94],{$ERSP_NIKe$:(t,i,e)=>{e.r(i),e.d(i,{default:()=>c});var s=e("$ERSP_5EI7$");const o="sticky",l="down",h="transform 0.22s cubic-bezier(0.33, 1, 0.68, 1)",c=class{constructor(t,i){(0,s.Z)(this,"headerHeight",void 0),(0,s.Z)(this,"stickySectionOffsetTop",void 0),(0,s.Z)(this,"stickySectionOffsetBottom",void 0),(0,s.Z)(this,"scrollPosition",void 0),(0,s.Z)(this,"lastScrollDirection",l),(0,s.Z)(this,"upScrollStartPosition",0),(0,s.Z)(this,"downScrollStartPosition",0),(0,s.Z)(this,"isSticky",!1),(0,s.Z)(this,"visiblePercentage",0),(0,s.Z)(this,"initialStateApplied",!1),(0,s.Z)(this,"scrollTimeout",null),(0,s.Z)(this,"resizeTimeout",null),(0,s.Z)(this,"placeholder",null),(0,s.Z)(this,"listenersAttached",!1),this.headerSection=t,this.stickySection=i,this.scrollPosition=window.scrollY,this.stickySectionOffsetTop=i.offsetTop,this.stickySectionOffsetBottom=i.offsetTop+i.offsetHeight,this.headerHeight=i.offsetHeight,this.stickySection.style.willChange="transform"}initializeStickyTreatment(){this.headerSection&&this.stickySection&&(this.stickySection.style.width=`${this.headerSection.offsetWidth}px`,this.placeholder=document.createElement("div"),this.placeholder.className="gh-header-placeholder",this.placeholder.style.height=`${this.stickySection.offsetHeight}px`,this.placeholder.style.display="none",this.stickySection.parentNode?.insertBefore(this.placeholder,this.stickySection.nextSibling),window.addEventListener("scroll",(()=>this.handleScroll())),window.addEventListener("resize",(()=>this.handleResize())),(document.documentElement.scrollTop||document.body.scrollTop)>this.stickySectionOffsetBottom&&(this.initialStateApplied=!0,this.updateDOM(!0,0,!0)))}handleScroll(){null===this.scrollTimeout&&(this.scrollTimeout=window.requestAnimationFrame((()=>{const t=document.documentElement.scrollTop||document.body.scrollTop;if(this.initialStateApplied)return this.initialStateApplied=!1,this.scrollPosition=t,void(this.scrollTimeout=null);const i=this.getScrollDirection(t);if(i===l&&t>this.stickySectionOffsetBottom&&!this.isSticky)return this.updateDOM(!0,0,!0),this.scrollPosition=t,void(this.scrollTimeout=null);const e=this.shouldStick(t,i),s=this.calculateVisibility(t,i);e===this.isSticky&&s===this.visiblePercentage||this.updateDOM(e,s),this.scrollPosition=t,this.scrollTimeout=null})))}handleResize(){null===this.resizeTimeout&&(this.resizeTimeout=window.setTimeout((()=>{this.stickySection.style.width=`${this.headerSection.offsetWidth}px`,this.headerHeight=this.stickySection.offsetHeight,this.placeholder&&(this.placeholder.style.height=`${this.headerHeight}px`),this.resizeTimeout=null}),100))}getScrollDirection(t){const i=t>this.scrollPosition?l:"up";return i!==this.lastScrollDirection&&(this["up"===i?"upScrollStartPosition":"downScrollStartPosition"]=this.scrollPosition,this.lastScrollDirection=i),i}shouldStick(t,i){const e=t>this.stickySectionOffsetBottom;return i===l?e:e||this.isSticky&&t>this.stickySectionOffsetTop}applyEasing(t,i){const e=t/100;return"easeOut"===i?100*(1-(1-e)**3):"easeIn"===i?100*e**3:t}calculateVisibility(t,i){if(i===l){if(!this.isSticky)return 0;if(this.downScrollStartPosition>0){const i=this.visiblePercentage-(t-this.downScrollStartPosition)/this.headerHeight*100;return Math.max(0,this.applyEasing(i,"easeIn"))}return this.visiblePercentage}if(t>this.stickySectionOffsetBottom){const i=this.upScrollStartPosition-t;if(i<100)return 0;const e=(i-100)/this.headerHeight*100;return Math.min(100,Math.max(0,this.applyEasing(e,"easeOut")))}return this.isSticky&&this.visiblePercentage<100?Math.min(100,this.visiblePercentage+5):this.visiblePercentage}updateDOM(t,i){let e=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=this.isSticky;if(this.isSticky=t,this.visiblePercentage=e?0:i,t){if(!s&&!this.listenersAttached){const t=()=>{this.isSticky&&this.visiblePercentage<100&&this.updateDOM(!0,100)};this.stickySection.addEventListener("click",t);const i=document.querySelector(".gh-search-input");i&&i.addEventListener("click",t),this.listenersAttached=!0}!this.stickySection.classList.contains(o)&&this.stickySection.classList.add(o),this.placeholder&&(this.placeholder.style.display="block");const t=e?this.headerHeight:this.headerHeight*(1-this.visiblePercentage/100);this.stickySection.style.transform=`translateY(-${t}px)`,this.stickySection.style.transition=e?"":h,i<100&&window.eBayAC?.helpers?.hideSuggestions(window.eBayAC)}else this.stickySection.classList.remove(o),this.stickySection.style.transform="",this.stickySection.style.transition=h,this.placeholder&&(this.placeholder.style.display="none")}}}}]);