import{Component}from"@theme/component";import{onDocumentReady,changeMetaThemeColor}from"@theme/utilities";class HeaderComponent extends Component{requiredRefs=["headerDrawerContainer","headerMenu","headerRowTop"];#menuDrawerHiddenWidth=null;#intersectionObserver=null;#offscreen=!1;#lastScrollTop=0;#timeout=null;#animationDelay=150;#resizeObserver=new ResizeObserver(([entry])=>{if(!entry)return;const{height}=entry.target.getBoundingClientRect();document.body.style.setProperty("--header-height",`${height}px`),this.#menuDrawerHiddenWidth&&window.innerWidth>this.#menuDrawerHiddenWidth&&this.#updateMenuVisibility(!1)});#observeStickyPosition=(alwaysSticky=!0)=>{if(this.#intersectionObserver)return;const config={threshold:alwaysSticky?1:0};this.#intersectionObserver=new IntersectionObserver(([entry])=>{if(!entry)return;const{isIntersecting}=entry;alwaysSticky?(this.dataset.stickyState=isIntersecting?"inactive":"active",changeMetaThemeColor(this.refs.headerRowTop)):this.#offscreen=!isIntersecting||this.dataset.stickyState==="active"},config),this.#intersectionObserver.observe(this)};#handleOverflowMinimum=event=>{this.#updateMenuVisibility(event.detail.minimumReached)};#updateMenuVisibility(hideMenu){hideMenu?(this.refs.headerDrawerContainer.classList.remove("desktop:hidden"),this.#menuDrawerHiddenWidth=window.innerWidth,this.refs.headerMenu.classList.add("hidden")):(this.refs.headerDrawerContainer.classList.add("desktop:hidden"),this.#menuDrawerHiddenWidth=null,this.refs.headerMenu.classList.remove("hidden"))}#handleWindowScroll=()=>{const stickyMode=this.getAttribute("sticky");if(!this.#offscreen&&stickyMode!=="always")return;const scrollTop=document.scrollingElement?.scrollTop??0,isScrollingUp=scrollTop<this.#lastScrollTop;if(this.#timeout&&(clearTimeout(this.#timeout),this.#timeout=null),stickyMode==="always"){isScrollingUp?this.getBoundingClientRect().top>=0?this.dataset.scrollDirection="none":this.dataset.scrollDirection="up":this.dataset.scrollDirection="down",this.#lastScrollTop=scrollTop;return}isScrollingUp?(this.removeAttribute("data-animating"),this.getBoundingClientRect().top>=0?(this.#offscreen=!1,this.dataset.stickyState="inactive",this.dataset.scrollDirection="none"):(this.dataset.stickyState="active",this.dataset.scrollDirection="up")):this.dataset.stickyState==="active"?(this.dataset.scrollDirection="none",this.setAttribute("data-animating",""),this.#timeout=setTimeout(()=>{this.dataset.stickyState="idle",this.removeAttribute("data-animating")},this.#animationDelay)):(this.dataset.scrollDirection="none",this.dataset.stickyState="idle"),this.#lastScrollTop=scrollTop};connectedCallback(){super.connectedCallback(),this.#resizeObserver.observe(this),this.addEventListener("overflowMinimum",this.#handleOverflowMinimum);const stickyMode=this.getAttribute("sticky");stickyMode&&(this.#observeStickyPosition(stickyMode==="always"),(stickyMode==="scroll-up"||stickyMode==="always")&&document.addEventListener("scroll",this.#handleWindowScroll))}disconnectedCallback(){super.disconnectedCallback(),this.#resizeObserver.disconnect(),this.#intersectionObserver?.disconnect(),this.removeEventListener("overflowMinimum",this.#handleOverflowMinimum),document.removeEventListener("scroll",this.#handleWindowScroll),document.body.style.setProperty("--header-height","0px")}}customElements.get("header-component")||customElements.define("header-component",HeaderComponent),onDocumentReady(()=>{const header=document.querySelector("#header-component"),headerGroup=document.querySelector("#header-group");if(headerGroup){const resizeObserver=new ResizeObserver(()=>calculateHeaderGroupHeight(header,headerGroup)),children=headerGroup.children;for(let i=0;i<children.length;i++){const element=children[i];element===header||!(element instanceof HTMLElement)||resizeObserver.observe(element)}new MutationObserver(mutations=>{for(const mutation of mutations)if(mutation.type==="childList"){const children2=headerGroup.children;for(let i=0;i<children2.length;i++){const element=children2[i];element===header||!(element instanceof HTMLElement)||resizeObserver.observe(element)}}}).observe(headerGroup,{childList:!0})}});
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/header.js.map?v=1783128505

/* Decor Cedar cached header repair 20260704 */
(() => {
  const marker = "sd-cache-header-repair-20260704";
  const links = [
    ["Sofa Covers", "/collections/sofa-covers"],
    ["Couch Covers", "/collections/couch-covers"],
    ["Pet-Friendly Covers", "/collections/pet-friendly-sofa-covers"],
    ["Water Resistant Covers", "/collections/water-resistant-sofa-covers"],
    ["Size Guide", "/pages/how-to-measure-sofa-covers"],
    ["Reviews", "/pages/reviews"]
  ];
  function ensureCss() {
    if (document.getElementById(marker)) return;
    const style = document.createElement("style");
    style.id = marker;
    style.textContent = '#header-component .sd-cache-logo-link{display:inline-flex;align-items:center;justify-content:center;text-decoration:none;color:#223227;min-width:116px}#header-component .sd-cache-logo-link img{display:block;width:auto;height:58px;max-width:150px;object-fit:contain}#header-component .sd-cache-nav{display:flex;align-items:center;justify-content:center;width:100%}#header-component .sd-cache-nav ul{display:flex;align-items:center;justify-content:center;gap:22px;list-style:none;margin:0;padding:0;flex-wrap:wrap}#header-component .sd-cache-nav a{display:inline-flex;align-items:center;gap:7px;text-decoration:none;color:#26362a;font-weight:650;font-size:.94rem;line-height:1.1;white-space:nowrap}#header-component .sd-cache-nav a:before{content:"";width:7px;height:7px;border-radius:999px;background:linear-gradient(135deg,#2f5a3d,#9a7248);box-shadow:0 0 0 3px rgba(47,90,61,.08);opacity:.82}#header-component .sd-cache-nav a:hover,#header-component .sd-cache-nav a:focus-visible{color:#8a643b}@media(max-width:749px){#header-component .sd-cache-logo-link img{height:46px}#header-component .sd-cache-nav{display:none}}';
    document.head.appendChild(style);
  }
  function linkHtml(cls) {
    return '<ul>' + links.map(([label, href]) => '<li><a class="' + cls + '" href="' + href + '">' + label + '</a></li>').join('') + '</ul>';
  }
  function fixAnnouncement() {
    const text = document.querySelector('.announcement-bar__text');
    if (text && /welcome to our store/i.test(text.textContent || '')) text.textContent = 'Summer Home Refresh Sale: up to 50% off. Free shipping over $149.';
  }
  function fixLogo() {
    const logo = document.querySelector('#header-component .header-logo');
    if (!logo || logo.classList.contains('sd-cache-logo-link')) return;
    logo.classList.add('sd-cache-logo-link');
    logo.setAttribute('aria-label', 'Decor Cedar home');
    logo.innerHTML = '<img src="//decorcedar.com/cdn/shop/files/decor-cedar-header-logo.png" alt="Decor Cedar" loading="eager">';
  }
  function fixDesktop() {
    const host = document.querySelector('#header-component header-menu .header-menu__inner') || document.querySelector('#header-component header-menu') || document.querySelector('#header-component nav[header-menu]');
    if (!host || host.querySelector('.sd-cache-nav')) return;
    const nav = document.createElement('nav');
    nav.className = 'sd-cache-nav';
    nav.setAttribute('aria-label', 'Primary navigation');
    nav.innerHTML = linkHtml('sd-cache-nav__link');
    host.replaceChildren(nav);
  }
  function fixMobile() {
    const list = document.querySelector('#header-component .menu-drawer__menu');
    if (!list || list.dataset.sdCacheFixed === 'true') return;
    list.dataset.sdCacheFixed = 'true';
    list.innerHTML = links.map(([label, href], i) => '<li class="menu-drawer__list-item--flat" style="--menu-drawer-animation-index:' + (i + 1) + '"><a href="' + href + '" class="menu-drawer__menu-item menu-drawer__menu-item--mainlist menu-drawer__animated-element focus-inset"><span class="menu-drawer__menu-item-text wrap-text">' + label + '</span></a></li>').join('');
  }
  function run() {
    ensureCss(); fixAnnouncement(); fixLogo(); fixDesktop(); fixMobile();
    document.documentElement.classList.add(marker);
  }
  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run, { once: true }); else run();
  setTimeout(run, 250); setTimeout(run, 1200); setTimeout(run, 2500);
})();
