import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useRef } from "react";
import styled from "styled-components";
import { useClickOutside } from "../../../hooks/common";
const Line = styled.span `
  margin: 4px 0;
  display: block;
  width: 100%;
  height: 2px;
  background: #002445;

  transition: 0.2s;
`;
const Container = styled.div `
  position: relative;
`;
const Button = styled.button `
  width: 22px;
  height: 16px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  outline: none;
  z-index: 100;

  ::before,
  ::after {
    content: "";
    display: block;
    width: 100%;
    height: 2px;
    background: #002445;
    transition: all 0.2s;
  }

  &.opened::before {
    transform: rotate(45deg);
  }
  &.opened::after {
    transform: translateY(-2px) rotate(-45deg);
  }
`;
export const Content = styled.div `
  position: absolute;
  z-index: 100;
  right: 0;
  top: 24px;
  display: flex;
  flex-direction: column;
  cursor: default;
  background: ${({ theme }) => theme.new?.burger?.contentBackground ?? "unset"};
  border-top: ${({ theme }) => theme.new?.burger?.borderTop ?? "unset"};

  &.hidden {
    display: none;
  }

  @media (max-width: 1023px) {
    position: fixed;
    top: 47px;
    left: 0px;
    right: 0px;
    touch-action: none;
    width: 100%;
    min-height: calc(100vh - 47px);
    z-index: 100;
    padding: 20px;
    overflow-y: scroll;
    background: white;
  }
`;
const BurgerIcon = ({ opened, className, children, handleClickIcon, handleClickOutside = () => undefined, }) => {
    const ref = useRef(null);
    useClickOutside(ref, handleClickOutside);
    return (_jsxs(Container, { ref: ref, className: `ui-burger-icon ${className ?? ""}`, children: [_jsx(Button, { className: `ui-burger-icon__button${opened ? " opened" : ""}`, onClick: handleClickIcon, children: !opened && _jsx(Line, {}) }), _jsx(Content, { className: `ui-burger-icon__content${opened ? "" : " hidden"}`, children: children })] }));
};
export default BurgerIcon;
//# sourceMappingURL=burger-icon.js.map