"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const React = require("react");
const classNames = require("../_util/classNames.js");
const sider = require("./sider.js");
const header = require("./header.js");
const footer = require("./footer.js");
const content = require("./content.js");
const index = require("../ConfigProvider/index.js");
const useMergeProps = require("../_util/hooks/useMergeProps.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");
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
const React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
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 __spreadArray = globalThis && globalThis.__spreadArray || function(to, from, pack) {
  if (pack || arguments.length === 2)
    for (var i = 0, l = from.length, ar; i < l; i++) {
      if (ar || !(i in from)) {
        if (!ar)
          ar = Array.prototype.slice.call(from, 0, i);
        ar[i] = from[i];
      }
    }
  return to.concat(ar || Array.prototype.slice.call(from));
};
function Layout(baseProps, ref) {
  var _a;
  var _b = React.useContext(index.ConfigContext), getPrefixCls = _b.getPrefixCls, componentConfig = _b.componentConfig;
  var props = useMergeProps(baseProps, {}, componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.Layout);
  var className = props.className, hasSider = props.hasSider, children = props.children, rest = __rest(props, ["className", "hasSider", "children"]);
  var _c = __read(React.useState([]), 2), siders = _c[0], setSiders = _c[1];
  var prefixCls = getPrefixCls("layout");
  var classNames$1 = classNames(prefixCls, (_a = {}, _a[prefixCls + "-has-sider"] = typeof hasSider === "boolean" ? hasSider : siders.length > 0, _a), className);
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("section", {
    ...__assign({
      ref
    }, rest, {
      className: classNames$1
    }),
    children: React__default.default.Children.map(children, function(child) {
      if (child && child.props && child.props.sign === "sider") {
        return React__default.default.cloneElement(child, {
          onSiderMount: function(id) {
            return setSiders(__spreadArray(__spreadArray([], __read(siders), false), [id], false));
          },
          onSiderUnmount: function(id) {
            return setSiders(siders.filter(function(currentId) {
              return currentId !== id;
            }));
          }
        });
      }
      return child;
    })
  });
}
var ForwardRefLayout = React.forwardRef(Layout);
var LayoutComponent = ForwardRefLayout;
LayoutComponent.displayName = "Layout";
LayoutComponent.Sider = sider.default;
LayoutComponent.Header = header;
LayoutComponent.Footer = footer;
LayoutComponent.Content = content;
exports.SiderContext = sider.SiderContext;
exports.default = LayoutComponent;
//# sourceMappingURL=index.js.map
