import { j as jsxRuntimeExports } from "./jsx-runtime-mMz73N64.js";
import { forwardRef, createElement } from "react";
import { d as f, C as CSS } from "./css-DoalWJF6.js";
const CoreElement = ({ el, children, ...props }, ref) => createElement(el, { ...props, ref }, children);
const Element = forwardRef(CoreElement);
const Generic = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Element
}, Symbol.toStringTag, { value: "Module" }));
const ALIGNMENTS = ["start", "center", "end", "stretch"];
const JUSTIFICATIONS = [
  "start",
  "center",
  "end",
  "spaceBetween",
  "spaceAround",
  "spaceEvenly"
];
const shouldReverse = (direction2, reverse) => reverse ?? (direction2 === "right" || direction2 === "bottom");
const CoreSpace = ({
  style,
  align,
  className,
  grow,
  shrink,
  empty = false,
  size = "medium",
  justify = "start",
  reverse,
  direction: direction_ = "y",
  wrap = false,
  bordered = false,
  rounded = false,
  el = "div",
  ...props
}, ref) => {
  const dir = f.construct(direction_);
  reverse = shouldReverse(direction_, reverse);
  let gap;
  if (empty)
    [size, gap] = [0, 0];
  else if (typeof size === "number")
    gap = `${size}rem`;
  style = {
    gap,
    flexDirection: flexDirection(dir, reverse),
    justifyContent: justifications[justify],
    alignItems: align,
    flexWrap: wrap ? "wrap" : "nowrap",
    ...style
  };
  if (grow != null)
    style.flexGrow = Number(grow);
  if (shrink != null)
    style.flexShrink = Number(shrink);
  return (
    // @ts-expect-error - TODO: fix generic element props
    /* @__PURE__ */ jsxRuntimeExports.jsx(
      Element,
      {
        el,
        ref,
        className: CSS(
          CSS.B("space"),
          CSS.dir(dir),
          CSS.bordered(bordered),
          CSS.rounded(rounded),
          typeof size === "string" && CSS.BM("space", size),
          className
        ),
        style,
        ...props
      }
    )
  );
};
CoreSpace.displayName = "Space";
const Space = forwardRef(CoreSpace);
const flexDirection = (direction2, reverse) => {
  const base = direction2 === "x" ? "row" : "column";
  return reverse ? base + "-reverse" : base;
};
const justifications = {
  start: "flex-start",
  center: "center",
  end: "flex-end",
  spaceBetween: "space-between",
  spaceAround: "space-around",
  spaceEvenly: "space-evenly"
};
const CorePack = ({
  className,
  size = "medium",
  reverse = false,
  direction = "x",
  bordered = true,
  rounded = true,
  shadow = false,
  ...props
}, ref) => (
  // @ts-expect-error
  /* @__PURE__ */ jsxRuntimeExports.jsx(
    Space,
    {
      ref,
      direction,
      reverse,
      className: CSS(
        CSS.B("pack"),
        shadow && CSS.BM("pack", "shadow"),
        CSS.dir(direction),
        typeof size !== "number" && CSS.BM("pack", size),
        reverse && CSS.BM("pack", "reverse"),
        className
      ),
      bordered,
      rounded,
      ...props,
      empty: true
    }
  )
);
const Pack = forwardRef(CorePack);
const CoreCenter = ({ className, justify = "center", align = "center", ...props }, ref) => (
  // @ts-expect-error
  /* @__PURE__ */ jsxRuntimeExports.jsx(
    Space,
    {
      ref,
      justify,
      align,
      className: CSS(CSS.BM("space", "centered"), className),
      ...props
    }
  )
);
const Center = forwardRef(CoreCenter);
export {
  ALIGNMENTS as A,
  Center as C,
  Element as E,
  Generic as G,
  JUSTIFICATIONS as J,
  Pack as P,
  Space as S,
  CoreCenter as a,
  shouldReverse as s
};
//# sourceMappingURL=Center-hbwH7rg9.js.map
