var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
    for (var name in all) __defProp(target, name, {
      get: all[name],
      enumerable: !0
    });
  },
  __copyProps = (to, from, except, desc) => {
    if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
      get: () => from[key],
      enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
    });
    return to;
  };
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
  value: !0
}), mod);
var Grid_exports = {};
__export(Grid_exports, {
  Grid: () => Grid
});
module.exports = __toCommonJS(Grid_exports);
var import_react = require("react"),
  import_tamagui = require("tamagui"),
  import_jsx_runtime = require("react/jsx-runtime");
function Container({
  children,
  gap = "$spacing.form_gap",
  ...props
}) {
  let rowSpan = 0,
    currentRow = [];
  const rows = [],
    media = (0, import_tamagui.useMedia)();
  return import_react.Children.forEach(children, (child, index) => {
    let childSpan = media?.compact ? child?.props?.compact : media?.medium ? child?.props?.medium : media?.expanded ? child?.props?.exp : 12;
    childSpan || (childSpan = 12), childSpan && (rowSpan + childSpan > 12 && (12 - rowSpan > 0 && currentRow.push(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.View, {
      flex: 12 - rowSpan
    }, `filler-${index}`)), rows.push(currentRow), currentRow = [], rowSpan = 0), currentRow.push(child), rowSpan += childSpan);
  }), currentRow?.length > 0 && (rowSpan < 12 && currentRow.push(/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.View, {
    flex: 12 - rowSpan
  }, "final-row")), rows.push(currentRow)), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.View, {
    display: "flex",
    flexDirection: "column",
    width: "100%",
    ...props,
    gap,
    children: rows.map((row, index) => /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.View, {
      display: "flex",
      flexDirection: "row",
      gap,
      width: "100%",
      children: row
    }, `grid-row-${index}`))
  });
}
function Item({
  children,
  exp = 12,
  compact = 12,
  medium = 12,
  ...props
}) {
  const media = (0, import_tamagui.useMedia)(),
    flex = media?.compact ? compact : media?.medium ? medium : (media?.expanded, exp);
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.View, {
    ...props,
    flex,
    width: 0,
    children
  });
}
const Grid = (0, import_tamagui.withStaticProperties)(Container, {
  Item
});