import{aE as t,L as n}from"./p-BTBbFFOR.js";import{M as e}from"./p-IaOu_o-M.js";var r=function(t,n,e,r){var o,i=arguments.length,s=i<3?n:null===r?r=Object.getOwnPropertyDescriptor(n,e):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,n,e,r);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(s=(i<3?o(s):i>3?o(n,e,s):o(n,e))||s);return i>3&&s&&Object.defineProperty(n,e,s),s};class o extends e{componentDidLoad(){this.performMapping(),super.componentDidLoad&&super.componentDidLoad()}componentDidRender(){this.performMapping()}constructor(t,n){super({options:{attributes:!0,attributeFilter:Array.from(new Set(Object.values(n).reduce(((t,n)=>t.concat(n.dependency)),[])))},callback:()=>{}}),this.targetGetter=t,this.ariaMap=n,this.observerEntry.callback=t=>{this.handleMutations(t)}}handleMutations(t){const n=new Set;if(t&&t.length)for(const e of t)e.attributeName&&n.add(e.attributeName);this.performMapping(n.size?n:void 0)}performMapping(t){const e=this.targetGetter?this.targetGetter():null;if(!e)return;const r=this.host;Object.keys(this.ariaMap).forEach((o=>{const{dependency:i,defaultValue:s}=this.ariaMap[o];if(t&&!i.some((n=>t.has(n))))return;let l=null;for(const t of i){let n=r.getAttribute(t);if(null==n||""===n){const e=t.replace(/-([a-z])/g,((t,n)=>n.toUpperCase())),o=r[t],i=r[e];null!=o?n=String(o):null!=i&&(n=String(i))}if(null!=n&&""!==String(n).trim()){l=n;break}}null!=l&&""!==String(l).trim()||(l=s);try{if(""===String(l).trim())return void e.removeAttribute(o);const t=e.getAttribute(o);if(null==l)return void(null!==t&&e.removeAttribute(o));const n=String(l);t!==n&&e.setAttribute(o,n)}catch(t){n.warn("Errors occurred when setting aria attribute:",{ariaAttr:o,finalValue:l,error:t})}}))}}r([t("componentDidLoad")],o.prototype,"componentDidLoad",null),r([t("componentDidRender")],o.prototype,"componentDidRender",null);export{o as A}