import 'core-js/modules/es.array.concat.js';
import 'core-js/modules/es.array.filter.js';
import 'core-js/modules/es.array.find.js';
import 'core-js/modules/es.array.map.js';
import 'core-js/modules/es.object.to-string.js';
import React__default from 'react';
import PropTypes from 'prop-types';
import { RadioButton } from '@carbon/react';
import { settings } from '../../../../constants/Settings.js';

var iotPrefix = settings.iotPrefix;
var propTypes = {
  /**
   *  array of items to be moved
   */
  selectedItems: PropTypes.arrayOf(PropTypes.object),
  /**
   *  callback that sets the selectedItem
   */
  setSelectedItem: PropTypes.func,
  /**
   *  string representing the selected item
   */
  selectedItem: PropTypes.string,
  /**
   *  array of ids that will be moved to selected location
   */
  selectedIds: PropTypes.arrayOf(PropTypes.string),
  /**
   * Callback to handle list item click - will call setSelectedItems and set the breadcrumbs
   */
  handleLineItemClicked: PropTypes.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.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.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.createElement(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.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.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;

export { RadioButtonGroup as default };
