import{findActiveElement as t,isParentOf as e}from"../lib/shadow-dom-utils.js";class s{constructor(t,e,s,i){t.addController(this),this.host=t,this.selector=e,this.elements=[],this.callback=s,this.additionalWaiter=i}hostUpdate(){this.activeElement=t()}async hostUpdated(){await(this.additionalWaiter?.());const t=this.elements;this.elements=Array.from(this.host.shadowRoot.querySelectorAll(this.selector));const s=t.filter((t=>!this.elements.includes(t)));if(s.length>0){const i=s.find((t=>t===this.activeElement||e(t,this.activeElement)));if(null!=i){const e=t.indexOf(i),s=Math.min(this.elements.length-1,e),l=s>-1?this.elements[s]:null;this.callback({removedElement:i,focusedElement:this.activeElement,index:e,suggestedElement:l})}}}}export{s as LostFocusController};
//# sourceMappingURL=lost-focus-controller.js.map
