'use strict';

require('core-js/modules/es.array.concat.js');
require('core-js/modules/es.array.filter.js');
require('core-js/modules/es.array.find.js');
require('core-js/modules/es.array.map.js');
require('core-js/modules/es.object.to-string.js');
var React = require('react');
var PropTypes = require('prop-types');
var react = require('@carbon/react');
var Settings = require('../../../../constants/Settings.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);

var iotPrefix = Settings.settings.iotPrefix;
var propTypes = {
  /**
   *  array of items to be moved
   */
  selectedItems: PropTypes__default.default.arrayOf(PropTypes__default.default.object),
  /**
   *  callback that sets the selectedItem
   */
  setSelectedItem: PropTypes__default.default.func,
  /**
   *  string representing the selected item
   */
  selectedItem: PropTypes__default.default.string,
  /**
   *  array of ids that will be moved to selected location
   */
  selectedIds: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
  /**
   * Callback to handle list item click - will call setSelectedItems and set the breadcrumbs
   */
  handleLineItemClicked: PropTypes__default.default.func
};

/* istanbul ignore next */
var noop = function noop() {};
var defaultProps = {
  selectedItems: [],
  setSelectedItem: noop,
  selectedItem: null,
  selectedIds: [],
  handleLineItemClicked: noop
};
var HierarchyReorderModalRadioGroup = function HierarchyReorderModalRadioGroup(_ref) {
  var selectedItems = _ref.selectedItems,
    setSelectedItem = _ref.setSelectedItem,
    selectedItem = _ref.selectedItem,
    selectedIds = _ref.selectedIds,
    handleLineItemClicked = _ref.handleLineItemClicked;
  return /*#__PURE__*/React__default.default.createElement("div", {
    className: "".concat(iotPrefix, "--hierarchy-list-bulk-modal--list")
  }, selectedItems.filter(function (item) {
    return selectedIds.find(function (id) {
      return id === item.id;
    }) !== item.id;
  }).map(function (item) {
    return /*#__PURE__*/React__default.default.createElement("div", {
      className: "".concat(iotPrefix, "--hierarchy-list-bulk-modal--list-item"),
      key: "".concat(item.id, "-bulk-reorder-list-item-").concat(item.content.value)
    }, /*#__PURE__*/React__default.default.createElement(react.RadioButton, {
      className: "".concat(iotPrefix, "--hierarchy-list-bulk-modal--radio"),
      name: item.id,
      key: "radio-".concat(item.content.value),
      value: item.content.value,
      hideLabel: true,
      labelText: item.content.value,
      onChange: function onChange() {
        setSelectedItem(item.id);
      },
      tabIndex: 0,
      checked: item.id === selectedItem
    }), /*#__PURE__*/React__default.default.createElement("div", {
      role: "button",
      className: "".concat(iotPrefix, "--hierarchy-list-bulk-modal--list-item-button"),
      tabIndex: 0,
      onClick: function onClick() {
        return handleLineItemClicked(item);
      },
      onKeyPress: function onKeyPress(_ref2) {
        var key = _ref2.key;
        return key === 'Enter' && handleLineItemClicked(item);
      }
    }, /*#__PURE__*/React__default.default.createElement("div", {
      className: "".concat(iotPrefix, "--hierarchy-list-bulk-modal--list-item-value")
    }, item.content.value)));
  }));
};
HierarchyReorderModalRadioGroup.propTypes = propTypes;
HierarchyReorderModalRadioGroup.defaultProps = defaultProps;
HierarchyReorderModalRadioGroup.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "HierarchyReorderModalRadioGroup",
  "props": {
    "selectedItems": {
      "defaultValue": {
        "value": "[]",
        "computed": false
      },
      "description": "array of items to be moved",
      "type": {
        "name": "arrayOf",
        "value": {
          "name": "object"
        }
      },
      "required": false
    },
    "setSelectedItem": {
      "defaultValue": {
        "value": "() => {}",
        "computed": false
      },
      "description": "callback that sets the selectedItem",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "selectedItem": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "string representing the selected item",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "selectedIds": {
      "defaultValue": {
        "value": "[]",
        "computed": false
      },
      "description": "array of ids that will be moved to selected location",
      "type": {
        "name": "arrayOf",
        "value": {
          "name": "string"
        }
      },
      "required": false
    },
    "handleLineItemClicked": {
      "defaultValue": {
        "value": "() => {}",
        "computed": false
      },
      "description": "Callback to handle list item click - will call setSelectedItems and set the breadcrumbs",
      "type": {
        "name": "func"
      },
      "required": false
    }
  }
};
var RadioButtonGroup = HierarchyReorderModalRadioGroup;

module.exports = RadioButtonGroup;
