"use strict";

exports.__esModule = true;
exports.useCollectionPageChild = useCollectionPageChild;
var _react = _interopRequireWildcard(require("react"));
var _CollectionPageHeaderNew = require("../../components/CollectionPageHeaderNew");
var _CollectionPageContent = require("../../components/CollectionPageContent");
var _CollectionPageFooter = require("../../components/CollectionPageFooter");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function useCollectionPageChild(children) {
  // Mapping to raw WDS components since original Page filtering none expected components: https://github.com/wix-private/wix-design-systems/blob/master/packages/wix-style-react/src/Page/Page.js#L626
  return _react.Children.toArray(children).map((child, index) => {
    let newChild = null;
    if (/*#__PURE__*/(0, _react.isValidElement)(child)) {
      switch (child.type) {
        case _CollectionPageHeaderNew.CollectionPageHeader:
          const header = child;
          newChild = header.type.useCollectionPageHeader(header);
          break;
        case _CollectionPageContent.CollectionPageContent:
          const content = child;
          newChild = content.type.useCollectionPageContent(content);
          break;
        case _CollectionPageFooter.CollectionPageFooter:
          const footer = child;
          newChild = footer.type.useCollectionPageFooter(footer);
          break;
        default:
          // WIP: Eventually once we will support all child types this will return null
          newChild = child;
      }
    }
    if (newChild === null) {
      return null;
    }
    return /*#__PURE__*/_react.default.cloneElement(newChild, {
      key: index
    });
  }).filter(c => c);
}
//# sourceMappingURL=useCollectionPageChild.js.map