"use strict";
const jsxRuntime = require("./jsx-runtime-B3vWrP5x.cjs");
const React = require("react");
const css = require("./css-Pf9qxhQ4.cjs");
const CoreElement = ({ el, children, ...props }, ref) => React.createElement(el, { ...props, ref }, children);
const Element = React.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 = css.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__ */ jsxRuntime.jsxRuntimeExports.jsx(
      Element,
      {
        el,
        ref,
        className: css.CSS(
          css.CSS.B("space"),
          css.CSS.dir(dir),
          css.CSS.bordered(bordered),
          css.CSS.rounded(rounded),
          typeof size === "string" && css.CSS.BM("space", size),
          className
        ),
        style,
        ...props
      }
    )
  );
};
CoreSpace.displayName = "Space";
const Space = React.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__ */ jsxRuntime.jsxRuntimeExports.jsx(
    Space,
    {
      ref,
      direction,
      reverse,
      className: css.CSS(
        css.CSS.B("pack"),
        shadow && css.CSS.BM("pack", "shadow"),
        css.CSS.dir(direction),
        typeof size !== "number" && css.CSS.BM("pack", size),
        reverse && css.CSS.BM("pack", "reverse"),
        className
      ),
      bordered,
      rounded,
      ...props,
      empty: true
    }
  )
);
const Pack = React.forwardRef(CorePack);
const CoreCenter = ({ className, justify = "center", align = "center", ...props }, ref) => (
  // @ts-expect-error
  /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
    Space,
    {
      ref,
      justify,
      align,
      className: css.CSS(css.CSS.BM("space", "centered"), className),
      ...props
    }
  )
);
const Center = React.forwardRef(CoreCenter);
exports.ALIGNMENTS = ALIGNMENTS;
exports.Center = Center;
exports.CoreCenter = CoreCenter;
exports.Element = Element;
exports.Generic = Generic;
exports.JUSTIFICATIONS = JUSTIFICATIONS;
exports.Pack = Pack;
exports.Space = Space;
exports.shouldReverse = shouldReverse;
//# sourceMappingURL=Center-5NJ61qfA.cjs.map
