"use strict";
const jsxRuntime = require("./jsx-runtime-B3vWrP5x.cjs");
const React = require("react");
const aggregator = require("./aggregator-Ca8xiVD2.cjs");
const Center = require("./Center-5NJ61qfA.cjs");
const Toggle = require("./Toggle-CAW20E9V.cjs");
const css = require("./css-Pf9qxhQ4.cjs");
const Context = React.createContext({
  divided: false,
  level: "h1"
});
const useContext = () => React.useContext(Context);
const Header = ({
  children,
  className,
  level = "h1",
  divided = false,
  ...props
}) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Context.Provider, { value: { level, divided }, children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
  Center.Space,
  {
    el: "header",
    direction: "x",
    justify: "spaceBetween",
    className: css.CSS(
      css.CSS.B("header"),
      css.CSS.bordered("bottom"),
      divided && css.CSS.BM("header", "divided"),
      className
    ),
    ...props,
    children
  }
) });
const Actions = ({ children = [] }) => {
  const { level, divided } = useContext();
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
    Center.Space,
    {
      direction: "x",
      size: "small",
      align: "center",
      className: css.CSS.BE("header", "actions"),
      children: aggregator.A(children).map((action, i) => /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Action, { index: i, level, divided, children: action }, i))
    }
  );
};
const Action = ({ index, level, children, divided }) => {
  let content = children;
  if (!React.isValidElement(children)) {
    const props = children;
    content = /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
      Toggle.Icon,
      {
        onClick: (e) => {
          var _a;
          e.stopPropagation();
          e.preventDefault();
          (_a = props.onClick) == null ? void 0 : _a.call(props, e);
        },
        size: aggregator.LevelComponentSizes[level],
        ...props
      },
      index
    );
  }
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(React.Fragment, { children: [
    divided && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(Toggle.Divider, {}),
    content
  ] }, index);
};
const ButtonTitle = ({
  children = "",
  className,
  onClick,
  ...props
}) => {
  const { level } = useContext();
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
    Toggle.Button,
    {
      variant: "text",
      size: aggregator.LevelComponentSizes[level],
      onClick,
      className: css.CSS(css.CSS.B("header-button-title"), className),
      sharp: true,
      ...props,
      children
    }
  );
};
const Title = ({
  className,
  level: propsLevel,
  ...props
}) => {
  const { level, divided } = useContext();
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
    Toggle.WithIcon,
    {
      className: css.CSS(css.CSS.BE("header", "text"), className),
      level: propsLevel ?? level,
      divided,
      size: 1.5,
      ...props
    }
  );
};
const external = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Actions,
  ButtonTitle,
  Header,
  Title,
  useContext
}, Symbol.toStringTag, { value: "Module" }));
exports.Actions = Actions;
exports.ButtonTitle = ButtonTitle;
exports.Header = Header;
exports.external = external;
//# sourceMappingURL=external-Drem1ngI.cjs.map
