'use client'; 'use strict'; var randomId = require('../utils/random-id/random-id.cjs'); function createAriaHider(containerNode, selector = "body > :not(script)") { const id = randomId.randomId(); const rootNodes = Array.from( document.querySelectorAll(selector) ).map((node) => { if (node?.shadowRoot?.contains(containerNode) || node.contains(containerNode)) { return void 0; } const ariaHidden = node.getAttribute("aria-hidden"); const prevAriaHidden = node.getAttribute("data-hidden"); const prevFocusId = node.getAttribute("data-focus-id"); node.setAttribute("data-focus-id", id); if (ariaHidden === null || ariaHidden === "false") { node.setAttribute("aria-hidden", "true"); } else if (!prevAriaHidden && !prevFocusId) { node.setAttribute("data-hidden", ariaHidden); } return { node, ariaHidden: prevAriaHidden || null }; }); return () => { rootNodes.forEach((item) => { if (!item || id !== item.node.getAttribute("data-focus-id")) { return; } if (item.ariaHidden === null) { item.node.removeAttribute("aria-hidden"); } else { item.node.setAttribute("aria-hidden", item.ariaHidden); } item.node.removeAttribute("data-focus-id"); item.node.removeAttribute("data-hidden"); }); }; } exports.createAriaHider = createAriaHider; //# sourceMappingURL=create-aria-hider.cjs.map