var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellRecordBoard/utils/partitionShellFrameChildren.tsx
var partitionShellFrameChildren_exports = {};
__export(partitionShellFrameChildren_exports, {
  RECORD_BOARD_CALENDAR_DISPLAY_NAME: () => RECORD_BOARD_CALENDAR_DISPLAY_NAME,
  RECORD_BOARD_FLOOR_MAP_DISPLAY_NAME: () => RECORD_BOARD_FLOOR_MAP_DISPLAY_NAME,
  RECORD_BOARD_RESOURCE_WALL_DISPLAY_NAME: () => RECORD_BOARD_RESOURCE_WALL_DISPLAY_NAME,
  partitionShellFrameChildren: () => partitionShellFrameChildren
});
module.exports = __toCommonJS(partitionShellFrameChildren_exports);
var import_react = __toESM(require("react"));
var import_FloorMap = __toESM(require("../shellFrame/FloorMap"));
var import_RecordBoardCalendar = __toESM(require("../shellFrame/Calendar/RecordBoardCalendar"));
var import_RecordBoardResourceWall = __toESM(require("../shellFrame/ResourceWall/RecordBoardResourceWall"));
var RECORD_BOARD_FLOOR_MAP_DISPLAY_NAME = "RecordBoard.FloorMap";
var RECORD_BOARD_CALENDAR_DISPLAY_NAME = "RecordBoard.Calendar";
var RECORD_BOARD_RESOURCE_WALL_DISPLAY_NAME = "RecordBoard.ResourceWall";
function isRecordBoardFloorMapElementType(type) {
  if (type === import_FloorMap.default) return true;
  const dn = type == null ? void 0 : type.displayName;
  return dn === RECORD_BOARD_FLOOR_MAP_DISPLAY_NAME;
}
function isRecordBoardCalendarElementType(type) {
  if (type === import_RecordBoardCalendar.default) return true;
  const dn = type == null ? void 0 : type.displayName;
  return dn === RECORD_BOARD_CALENDAR_DISPLAY_NAME;
}
function isRecordBoardResourceWallElementType(type) {
  if (type === import_RecordBoardResourceWall.default) return true;
  const dn = type == null ? void 0 : type.displayName;
  return dn === RECORD_BOARD_RESOURCE_WALL_DISPLAY_NAME;
}
function partitionShellFrameChildren(children) {
  let foundFloorMap = false;
  let floorProps;
  let foundCalendar = false;
  let calendarProps;
  let foundResourceWall = false;
  let resourceWallProps;
  const gridChunks = [];
  const walk = (node) => {
    import_react.default.Children.forEach(node, (child) => {
      if (child == null || child === false) return;
      if (!import_react.default.isValidElement(child)) {
        gridChunks.push(child);
        return;
      }
      if (child.type === import_react.default.Fragment) {
        walk(child.props.children);
        return;
      }
      if (isRecordBoardFloorMapElementType(child.type)) {
        foundFloorMap = true;
        floorProps = child.props;
        return;
      }
      if (isRecordBoardCalendarElementType(child.type)) {
        foundCalendar = true;
        calendarProps = child.props;
        return;
      }
      if (isRecordBoardResourceWallElementType(child.type)) {
        foundResourceWall = true;
        resourceWallProps = child.props;
        return;
      }
      gridChunks.push(child);
    });
  };
  walk(children);
  const hasGridContent = gridChunks.length > 0;
  let gridChildren;
  if (!hasGridContent) {
    gridChildren = null;
  } else if (gridChunks.length === 1) {
    gridChildren = gridChunks[0];
  } else {
    gridChildren = /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, gridChunks);
  }
  return {
    gridChildren,
    hasFloorMapChild: foundFloorMap,
    floorMapPropsFromChild: floorProps,
    hasCalendarChild: foundCalendar,
    calendarPropsFromChild: calendarProps,
    hasResourceWallChild: foundResourceWall,
    resourceWallPropsFromChild: resourceWallProps,
    hasGridContent
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  RECORD_BOARD_CALENDAR_DISPLAY_NAME,
  RECORD_BOARD_FLOOR_MAP_DISPLAY_NAME,
  RECORD_BOARD_RESOURCE_WALL_DISPLAY_NAME,
  partitionShellFrameChildren
});
