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