import{i as t,u as i,A as s,q as o}from"./p-B3dnXEPG.js";import{B as e}from"./p-saW7O-EW.js";class n{host;config;visibilityObserver;elementQueued=!1;elementValidated=!1;elementLoaded=!1;static knownValidationErrors=[];get disabled(){return!t()}get useVerboseLogging(){return this.config?.verboseLogging||e.isDev||i()}constructor(t,i){this.host=t,this.config=i}onRuntimeConfigChange=()=>{t()&&this.checkLazyValidation()};hostDidLoad(){this.elementLoaded=!0,"undefined"!=typeof window&&window.addEventListener(s,this.onRuntimeConfigChange),this.elementQueued||this.elementValidated||("slot"!==this.config?.validationTiming?this.host.validationEl?.checkVisibility?.()&&"load"===this.config?.validationTiming?this.enqueueValidation():this.observeVisibilityOnce():this.observeSlot())}hostDidUpdate(){this.checkLazyValidation()}hostDisconnected(){this.discardVisibilityObserver(),"undefined"!=typeof window&&window.removeEventListener(s,this.onRuntimeConfigChange)}revalidateAria(){this.enqueueValidation()}observeSlot(){this.host.validationSlot?.addEventListener("slotchange",this.enqueueValidation.bind(this))}observeVisibilityOnce(){window.setTimeout((()=>{this.host.validationEl&&(this.visibilityObserver=new IntersectionObserver((t=>{for(const i of t)i.target===this.host.validationEl&&i.isIntersecting&&(this.checkLazyValidation(),this.discardVisibilityObserver())}),{root:this.host.validationEl?.parentElement,rootMargin:"0px",threshold:.01}),this.visibilityObserver.observe(this.host.validationEl))}))}checkLazyValidation(){this.elementLoaded&&(this.config?.reValidateOnPropChanges||!this.elementQueued&&!this.elementValidated)&&this.host.validationEl?.checkVisibility?.()&&this.enqueueValidation()}enqueueValidation(){t()&&(this.elementQueued=!0,o({context:{include:this.host.validationEl,exclude:n.knownValidationErrors},onComplete:(t,i)=>{this.elementValidated=!0;const s=this.host.tagName||this.host.validationEl?.tagName||"Element";if(t)return console.error("Error running ARIA validation:",t,s),void(this.host.validationEl?.tagName||console.dir(this.host));const o=[s];if(!i?.violations.length)return void(this.useVerboseLogging&&(console.log(...o,"has no ARIA violations"),this.host.validationEl?.tagName||console.dir(this.host)));const e=i.violations.length,h=[...o,i.violations.at(0).id,e>1?`(+${e-1} more)`:""].filter(Boolean).join(" ");this.useVerboseLogging?console.group(h):console.groupCollapsed(h);const r=i.violations.flatMap((t=>(console.dir(t,{showHidden:!0,compact:!1}),t.nodes.map((t=>t.target)))));this.host.validationEl?console.log("element:",this.host.validationEl):console.dir(this.host),console.groupEnd(),n.knownValidationErrors.push(...r)}}))}discardVisibilityObserver(){this.visibilityObserver&&(this.visibilityObserver.disconnect(),this.visibilityObserver=void 0)}}class h{controllers=new Set;addController(t){this.controllers.add(t)}removeController(t){this.controllers.delete(t)}get activeControllers(){return Array.from(this.controllers).filter((t=>!t.disabled))}connectedCallback(){this.controllers.size||console.warn("ReactiveControllerHost connected with no controllers registered.",this),this.activeControllers.forEach((t=>t.hostConnected?.()))}disconnectedCallback(){this.activeControllers.forEach((t=>t.hostDisconnected?.()))}componentWillLoad(){this.activeControllers.forEach((t=>t.hostWillLoad?.()))}componentDidLoad(){this.activeControllers.forEach((t=>t.hostDidLoad?.()))}componentWillRender(){this.activeControllers.forEach((t=>t.hostWillRender?.()))}componentDidRender(){this.activeControllers.forEach((t=>t.hostDidRender?.()))}componentWillUpdate(){this.activeControllers.forEach((t=>t.hostWillUpdate?.()))}componentDidUpdate(){this.activeControllers.forEach((t=>t.hostDidUpdate?.()))}}export{n as A,h as R}