var k=function(r){if(typeof document>"u")return null;var u=Array.isArray(r)?r[0]:r;return u.ownerDocument.body},f=new WeakMap,o=new WeakMap,p={},h=0,W=function(r){return r&&(r.host||W(r.parentNode))},S=function(r,u){return u.map(function(e){if(r.contains(e))return e;var n=W(e);return n&&r.contains(n)?n:(console.error("aria-hidden",e,"in not contained inside",r,". Doing nothing"),null)}).filter(function(e){return!!e})},D=function(r,u,e,n){var i=S(u,Array.isArray(r)?r:[r]);p[e]||(p[e]=new WeakMap);var c=p[e],l=[],v=new Set,b=new Set(i),y=function(t){!t||v.has(t)||(v.add(t),y(t.parentNode))};i.forEach(y);var A=function(t){!t||b.has(t)||Array.prototype.forEach.call(t.children,function(a){if(v.has(a))A(a);else{var s=a.getAttribute(n),w=s!==null&&s!=="false",M=(f.get(a)||0)+1,d=(c.get(a)||0)+1;f.set(a,M),c.set(a,d),l.push(a),M===1&&w&&o.set(a,!0),d===1&&a.setAttribute(e,"true"),w||a.setAttribute(n,"true")}})};return A(u),v.clear(),h++,function(){l.forEach(function(t){var a=f.get(t)-1,s=c.get(t)-1;f.set(t,a),c.set(t,s),a||(o.has(t)||t.removeAttribute(n),o.delete(t)),s||t.removeAttribute(e)}),h--,h||(f=new WeakMap,f=new WeakMap,o=new WeakMap,p={})}},E=function(r,u,e){e===void 0&&(e="data-aria-hidden");var n=Array.from(Array.isArray(r)?r:[r]),i=u||k(r);return i?(n.push.apply(n,Array.from(i.querySelectorAll("[aria-live]"))),D(n,i,e,"aria-hidden")):function(){return null}};export{E as h};
