"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useIsExpanded=useIsExpanded;const react_1=require("react"),react_router_dom_1=require("react-router-dom"),theme_1=require("@redocly/theme"),utils_1=require("../../utils"),useAutoScroll_1=require("../Content/useAutoScroll");function useIsExpanded({item:e,routingBasePath:t}){const r=(0,react_router_dom_1.useLocation)(),o=(0,react_1.useMemo)((()=>(0,utils_1.tryDecodeURIComponent)((0,utils_1.normalizePath)(r.pathname.replace(t,"")))),[r.pathname,t]),s=(0,react_1.useMemo)((()=>{const t=[],r=e=>{e.forEach((e=>{var o;t.push(e),(null===(o=e.items)||void 0===o?void 0:o.length)&&r(e.items)}))};return r([e]),t}),[e]);if("tag"!==e.type)return!1;const u=s.map((e=>e.href));return u.some((e=>{const t=(0,useAutoScroll_1.getLegacyHash)(r.hash);return[e,(0,utils_1.tryDecodeURIComponent)(e)].includes(o)||t&&(e.endsWith(t)||e===(0,theme_1.removeLeadingSlash)(t))}))}
//# sourceMappingURL=useIsExpanded.js.map