"use strict";
const React = require("react");
const classNames = require("../_util/classNames.js");
const omit = require("../_util/omit.js");
const index = require("../ConfigProvider/index.js");
const responsiveObserve = require("../_util/responsiveObserve.js");
const useMergeProps = require("../_util/hooks/useMergeProps.js");
const context = require("./context.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
var __rest = globalThis && globalThis.__rest || function(s, e) {
  var t = {};
  for (var p in s)
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
      t[p] = s[p];
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
      if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
        t[p[i]] = s[p[i]];
    }
  return t;
};
var __read = globalThis && globalThis.__read || function(o, n) {
  var m = typeof Symbol === "function" && o[Symbol.iterator];
  if (!m)
    return o;
  var i = m.call(o), r, ar = [], e;
  try {
    while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
      ar.push(r.value);
  } catch (error) {
    e = {
      error
    };
  } finally {
    try {
      if (r && !r.done && (m = i["return"]))
        m.call(i);
    } finally {
      if (e)
        throw e.error;
    }
  }
  return ar;
};
var defaultProps = {
  gutter: 0,
  align: "start",
  justify: "start"
};
function Row(baseProps, ref) {
  var _a;
  var _b = React.useContext(index.ConfigContext), getPrefixCls = _b.getPrefixCls, componentConfig = _b.componentConfig, rtl = _b.rtl;
  var props = useMergeProps(baseProps, defaultProps, componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig["Grid.Row"]);
  var className = props.className, style = props.style, children = props.children, div = props.div, align = props.align, justify = props.justify, gutter = props.gutter, rest = __rest(props, ["className", "style", "children", "div", "align", "justify", "gutter"]);
  var _c = __read(React.useState({
    xs: true,
    sm: true,
    md: true,
    lg: true,
    xl: true,
    xxl: true,
    xxxl: true
  }), 2), screens = _c[0], setScreens = _c[1];
  var token = React.useRef();
  React.useEffect(function() {
    token.current = responsiveObserve.default.subscribe(function(screens2) {
      if (!Array.isArray(gutter) && typeof gutter === "object" || Array.isArray(gutter) && (typeof gutter[0] === "object" || typeof gutter[1] === "object")) {
        setScreens(screens2);
      }
    });
    return function() {
      responsiveObserve.default.unsubscribe(token.current);
    };
  }, []);
  function getGutter(gutter2) {
    var result = 0;
    if (typeof gutter2 === "object") {
      for (var i = 0; i < responsiveObserve.responsiveArray.length; i++) {
        var breakpoint = responsiveObserve.responsiveArray[i];
        if (screens[breakpoint] && gutter2[breakpoint] !== void 0) {
          result = gutter2[breakpoint];
          break;
        }
      }
    } else {
      result = gutter2;
    }
    return result;
  }
  var prefixCls = getPrefixCls("row");
  var classNames$1 = classNames((_a = {}, _a["" + prefixCls] = !div, _a[prefixCls + "-align-" + align] = align, _a[prefixCls + "-justify-" + justify] = justify, _a[prefixCls + "-rtl"] = rtl, _a), className);
  var marginStyle = {};
  var gutterHorizontal = getGutter(Array.isArray(gutter) ? gutter[0] : gutter);
  var gutterVertical = getGutter(Array.isArray(gutter) ? gutter[1] : 0);
  if ((gutterHorizontal || gutterVertical) && !div) {
    var marginHorizontal = -gutterHorizontal / 2;
    var marginVertical = -gutterVertical / 2;
    if (marginHorizontal) {
      marginStyle.marginLeft = marginHorizontal;
      marginStyle.marginRight = marginHorizontal;
    }
    if (marginVertical) {
      marginStyle.marginTop = marginVertical;
      marginStyle.marginBottom = marginVertical;
    }
  }
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
    ...__assign({
      ref
    }, omit(rest, ["gutter"]), {
      style: __assign(__assign({}, style), marginStyle),
      className: classNames$1
    }),
    children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(context.RowContext.Provider, {
      value: {
        gutter: [gutterHorizontal, gutterVertical],
        div
      },
      children
    })
  });
}
var RowComponent = React.forwardRef(Row);
RowComponent.displayName = "Row";
const Row$1 = RowComponent;
module.exports = Row$1;
//# sourceMappingURL=row.js.map
