"use strict";

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

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

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

function flattenData(data) {
  var flattenItems = [];

  function loop(data, _parent) {
    if (!Array.isArray(data)) {
      return;
    }

    data.forEach(function (item) {
      item._parent = _parent; // @ts-ignore

      flattenItems.push((0, _objectSpread2["default"])({}, item));

      if (item.children) {
        loop(item.children, item);
      }
    });
  }

  loop(data, null);
  return flattenItems;
}

var _default = flattenData;
exports["default"] = _default;
//# sourceMappingURL=flattenData.js.map
