"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _ = require("..");

var _Field = _interopRequireDefault(require("../Field"));

var _jsxRuntime = require("react/jsx-runtime");

var _react = require("react");

var _excluded = ["formData", "schema", "uiSchema"];

var _default = function _default(_ref) {
  var formData = _ref.formData,
      schema = _ref.schema,
      uiSchema = _ref.uiSchema,
      otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);

  if (formData === null || formData === void 0 ? void 0 : formData.length) {
    var _uiSchema$uiOptions;

    if (uiSchema === null || uiSchema === void 0 ? void 0 : (_uiSchema$uiOptions = uiSchema['ui:options']) === null || _uiSchema$uiOptions === void 0 ? void 0 : _uiSchema$uiOptions.inline) {
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Field["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, otherProps), {}, {
        schema: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, schema.items), {}, {
          inline: true
        }),
        uiSchema: uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.items,
        formData: formData
      }));
    } else {
      var _uiSchema$items, _uiSchema$items2, _uiSchema$items2$uiO;

      var itemOptions = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, uiSchema === null || uiSchema === void 0 ? void 0 : (_uiSchema$items = uiSchema.items) === null || _uiSchema$items === void 0 ? void 0 : _uiSchema$items['ui:options']), {}, {
        element: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, uiSchema === null || uiSchema === void 0 ? void 0 : (_uiSchema$items2 = uiSchema.items) === null || _uiSchema$items2 === void 0 ? void 0 : (_uiSchema$items2$uiO = _uiSchema$items2['ui:options']) === null || _uiSchema$items2$uiO === void 0 ? void 0 : _uiSchema$items2$uiO.element), {}, {
          indent: 0
        })
      });
      return formData.map(function (data, index) {
        return /*#__PURE__*/(0, _react.createElement)(_Field["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, otherProps), {}, {
          key: index,
          lastItem: formData.length === index + 1,
          schema: schema.items,
          uiSchema: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.items), {}, {
            'ui:options': itemOptions
          }),
          formData: data
        }));
      });
    }
  } else {
    return _.empty;
  }
};

exports["default"] = _default;
//# sourceMappingURL=array.cjs.map