import _Skeleton from "@mui/material/Skeleton";
/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */

import styled from "@emotion/styled";
import { memo } from "react";
import { useOdysseyDesignTokens } from "../../OdysseyDesignTokensContext.js";
import { Heading5 } from "../../Typography.js";
import { useUiShellContext } from "../../ui-shell/UiShellProvider.js";
import { UiShellLogo } from "../UiShellLogo.js";
import { TOP_NAV_HEIGHT, UI_SHELL_BASE_Z_INDEX } from "../uiShellSharedConstants.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const SideNavHeaderContainer = styled("div")({
  position: "relative",
  display: "flex",
  flexDirection: "column",
  zIndex: UI_SHELL_BASE_Z_INDEX
});
const SideNavLogoContainer = styled("div", {
  shouldForwardProp: prop => prop !== "headerBackgroundColor" && prop !== "isSameBackgroundAsMain" && prop !== "odysseyDesignTokens"
})(({
  headerBackgroundColor,
  isSameBackgroundAsMain,
  odysseyDesignTokens
}) => ({
  display: "flex",
  alignItems: "center",
  height: TOP_NAV_HEIGHT,
  paddingBlock: odysseyDesignTokens.Spacing4,
  paddingInline: odysseyDesignTokens.Spacing5,
  backgroundColor: isSameBackgroundAsMain ? headerBackgroundColor : odysseyDesignTokens.HueNeutralWhite,
  "svg, img": {
    maxHeight: "100%",
    width: "auto",
    maxWidth: "100%"
  }
}));
const SideNavHeadingContainer = styled("div", {
  shouldForwardProp: prop => prop !== "odysseyDesignTokens" && prop !== "contrastFontColor"
})(({
  contrastFontColor,
  odysseyDesignTokens
}) => ({
  display: "flex",
  justifyContent: "space-between",
  alignItems: "center",
  paddingBlock: odysseyDesignTokens.Spacing4,
  paddingInline: odysseyDesignTokens.Spacing5,
  width: "100%",
  ["& .MuiTypography-root"]: {
    margin: 0,
    width: "100%",
    color: contrastFontColor || "inherit"
  }
}));
const SideNavHeader = ({
  appName,
  isLoading,
  logoProps
}) => {
  const odysseyDesignTokens = useOdysseyDesignTokens();
  const uiShellContext = useUiShellContext();
  return _jsxs(SideNavHeaderContainer, {
    children: [_jsx(SideNavLogoContainer, {
      "data-se": "sidenav-header-logo-container",
      headerBackgroundColor: uiShellContext?.sideNavBackgroundColor,
      isSameBackgroundAsMain: logoProps?.isSameBackgroundAsMain,
      odysseyDesignTokens: odysseyDesignTokens,
      children: isLoading ? _jsx(_Skeleton, {
        height: 24,
        variant: "rounded",
        width: 67
      }) : _jsx(UiShellLogo, {
        ...logoProps
      })
    }), appName && _jsx(SideNavHeadingContainer, {
      contrastFontColor: uiShellContext?.sideNavContrastColors?.fontColor,
      odysseyDesignTokens: odysseyDesignTokens,
      children: _jsx(Heading5, {
        component: "h2",
        children: isLoading ? _jsx(_Skeleton, {}) : appName
      })
    })]
  });
};
const MemoizedSideNavHeader = memo(SideNavHeader);
MemoizedSideNavHeader.displayName = "SideNavHeader";
export { MemoizedSideNavHeader as SideNavHeader };
//# sourceMappingURL=SideNavHeader.js.map