export class DeclarativeShadowElement extends HTMLElement{connectedCallback(){if(!this.shadowRoot){const template=this.querySelector(':scope > template[shadowrootmode="open"]');if(!(template instanceof HTMLTemplateElement))return;this.attachShadow({mode:"open"}).append(template.content.cloneNode(!0))}}}export class ResizeNotifier extends ResizeObserver{#initialized=!1;constructor(callback){super(entries=>{if(this.#initialized)return callback(entries,this);this.#initialized=!0})}disconnect(){this.#initialized=!1,super.disconnect()}}export class OverflowMinimumEvent extends Event{constructor(minimumReached){super("overflowMinimum",{bubbles:!0}),this.detail={minimumReached}}}export class ReflowEvent extends Event{constructor(lastVisibleElement){super("reflow",{bubbles:!0}),this.detail={lastVisibleElement}}}export class OverflowList extends DeclarativeShadowElement{static get observedAttributes(){return["disabled","minimum-items"]}attributeChangedCallback(name,oldValue,newValue){name==="disabled"&&(newValue==="true"?this.#reset():this.#reflowItems())}connectedCallback(){if(super.connectedCallback(),this.hasAttribute("defer")){const deferredReflow=()=>{this.removeAttribute("defer"),this.#initialize()},{schedule}=this;(typeof window.requestIdleCallback=="function"?window.requestIdleCallback:setTimeout)(()=>schedule(deferredReflow))}else this.shadowRoot?this.#initialize():setTimeout(()=>{this.#initialize()},0)}#initialize(){const{shadowRoot}=this;if(!shadowRoot)throw new Error("Missing shadow root");const defaultSlot=shadowRoot.querySelector("slot:not([name])"),overflowSlot=shadowRoot.querySelector('slot[name="overflow"]'),moreSlot=shadowRoot.querySelector('slot[name="more"]'),overflow=shadowRoot.querySelector('[part="overflow"]'),list=shadowRoot.querySelector('[part="list"]'),placeholder=shadowRoot.querySelector('[part="placeholder"]');if(!(defaultSlot instanceof HTMLSlotElement)||!(overflowSlot instanceof HTMLSlotElement)||!(moreSlot instanceof HTMLSlotElement)||!(overflow instanceof HTMLElement)||!(list instanceof HTMLUListElement)||!(placeholder instanceof HTMLLIElement))throw new Error("Invalid element types in ");this.#refs={defaultSlot,overflowSlot,moreSlot,overflow,list,placeholder},this.addEventListener("reflow",event=>{this.#reflowItems(event.detail.lastVisibleElement)}),this.#reflowItems()}disconnectedCallback(){this.#resizeObserver.disconnect()}get schedule(){return typeof Theme?.utilities?.scheduler?.schedule=="function"?Theme.utilities.scheduler.schedule:callback=>requestAnimationFrame(()=>setTimeout(callback,0))}#scheduled=!1;get minimumItems(){const value=this.getAttribute("minimum-items");return value?parseInt(value,10):null}get overflowSlot(){const{overflowSlot}=this.#refs;return overflowSlot}get defaultSlot(){const{defaultSlot}=this.#refs;return defaultSlot}#lastDimensions={width:null,height:null};#handleChange=event=>{if(this.#scheduled)return;let width=null,height=null,isResize=!1;for(const[,entry]of event.entries()){if(!(entry instanceof ResizeObserverEntry))break;isResize=!0,width=Math.round(entry.contentRect.width),height=Math.round(entry.contentRect.height)}if(isResize){if(!width||!height||width===this.#lastDimensions.width&&height===this.#lastDimensions.height)return;this.#lastDimensions={width:Math.round(width),height:Math.round(height)}}this.#scheduled=!0,this.schedule(()=>{this.#reflowItems(),this.#scheduled=!1})};#moveItemsToDefaultSlot(){const{defaultSlot,overflowSlot}=this.#refs;for(const element of overflowSlot.assignedElements())element.slot=defaultSlot.name}#reset(){const{list}=this.#refs;this.#mutationObserver.disconnect(),this.#resizeObserver.disconnect(),this.#moveItemsToDefaultSlot(),list.style.removeProperty("height"),this.style.setProperty("--overflow-count","0")}#updateMinimumReached(visibleElements){if(this.minimumItems!==null){const minimumReached=visibleElements.length{const{defaultSlot,overflowSlot,moreSlot,list,placeholder}=this.#refs;this.#resizeObserver.disconnect(),this.#mutationObserver.disconnect();const{height}=this.firstElementChild?.getBoundingClientRect()??{};height&&(list.style.height=`${height}px`),list.style.setProperty("overflow","hidden"),this.#moveItemsToDefaultSlot();const elements=defaultSlot.assignedElements();moreSlot.hidden=!0,placeholder.hidden=!0;const rootRect=list.getBoundingClientRect();this.#lastDimensions={width:Math.round(rootRect.width),height:Math.round(rootRect.height)};const getVisibleElements=()=>elements.filter(el=>el.getBoundingClientRect().top<=rootRect.top);let visibleElements=getVisibleElements();if(visibleElements.length!==elements.length||lastVisibleElement){if(moreSlot.style.setProperty("order","-1"),moreSlot.hidden=!1,moreSlot.style.setProperty("height",`${height}px`),lastVisibleElement&&lastVisibleElement.style.setProperty("order","-1"),visibleElements=getVisibleElements(),moreSlot.style.removeProperty("order"),lastVisibleElement&&lastVisibleElement.style.removeProperty("order"),lastVisibleElement){const visibleIndex=visibleElements.indexOf(lastVisibleElement);visibleIndex!==-1&&(visibleElements.splice(visibleIndex,1),visibleElements.push(lastVisibleElement))}moreSlot.style.setProperty("height","auto")}const overflowingElements=elements.filter(element=>!visibleElements.includes(element)),[firstOverflowingElement]=overflowingElements,hasOverflow=overflowingElements.length>0,placeholderWidth=firstOverflowingElement?firstOverflowingElement.clientWidth:0;for(const element of elements)element.slot=overflowingElements.includes(element)?overflowSlot.name:defaultSlot.name;moreSlot.hidden=!hasOverflow,hasOverflow&&(placeholder.style.width=`${placeholderWidth}px`,placeholder.hidden=!1),list.style.setProperty("counter-reset",`overflow-count ${overflowingElements.length}`),this.style.setProperty("--overflow-count",`${overflowingElements.length}`),list.style.removeProperty("overflow"),hasOverflow&&this.#updateMinimumReached(visibleElements),this.#resizeObserver.observe(this),this.#mutationObserver.observe(this,{childList:!0})};#refs;#resizeObserver=new ResizeNotifier(this.#handleChange);#mutationObserver=new MutationObserver(this.#handleChange)}customElements.get("overflow-list")||customElements.define("overflow-list",OverflowList);export function calculateHeaderGroupHeight(header=document.querySelector("#header-component"),headerGroup=document.querySelector("#header-group")){if(!headerGroup)return 0;let totalHeight=0;const children=headerGroup.children;for(let i=0;i