/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import React, {useEffect, type ReactNode, type ComponentProps} from 'react'; import clsx from 'clsx'; import { isRegexpStringMatch, useCollapsible, Collapsible, } from '@docusaurus/theme-common'; import {isSamePath, useLocalPathname} from '@docusaurus/theme-common/internal'; import {translate} from '@docusaurus/Translate'; import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink'; import NavbarItem, {type LinkLikeNavbarItemProps} from '@theme/NavbarItem'; import type {Props} from '@theme/NavbarItem/DropdownNavbarItem/Mobile'; import styles from './styles.module.css'; function isItemActive( item: LinkLikeNavbarItemProps, localPathname: string, ): boolean { if (isSamePath(item.to, localPathname)) { return true; } if (isRegexpStringMatch(item.activeBaseRegex, localPathname)) { return true; } if (item.activeBasePath && localPathname.startsWith(item.activeBasePath)) { return true; } return false; } function containsActiveItems( items: readonly LinkLikeNavbarItemProps[], localPathname: string, ): boolean { return items.some((item) => isItemActive(item, localPathname)); } function CollapseButton({ collapsed, onClick, }: { collapsed: boolean; onClick: ComponentProps<'button'>['onClick']; }) { return (