Liferay.Loader.define("depot-web@1.0.90/js/LanguagesList.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', '@frontend-taglib-clay$clayui/table', 'frontend-js-react-web$prop-types', 'frontend-js-react-web$react', 'frontend-js-react-web$react-dnd', 'frontend-js-react-web$react-dnd-html5-backend', './LanguageListItem.es', './LanguageListItemEditable.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

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

    var _button = _interopRequireDefault(require("@frontend-taglib-clay$clayui/button"));

    var _table = _interopRequireDefault(require("@frontend-taglib-clay$clayui/table"));

    var _propTypes = _interopRequireDefault(require("frontend-js-react-web$prop-types"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _reactDnd = require("frontend-js-react-web$react-dnd");

    var _reactDndHtml5Backend = require("frontend-js-react-web$react-dnd-html5-backend");

    var _LanguageListItem = _interopRequireDefault(require("./LanguageListItem.es"));

    var _LanguageListItemEditable = _interopRequireDefault(require("./LanguageListItemEditable.es"));

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    function ownKeys(object, enumerableOnly) {
      var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {
          return Object.getOwnPropertyDescriptor(object, sym).enumerable;
        });keys.push.apply(keys, symbols);
      }return keys;
    }

    function _objectSpread(target) {
      for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {
          ownKeys(Object(source), true).forEach(function (key) {
            _defineProperty(target, key, source[key]);
          });
        } else if (Object.getOwnPropertyDescriptors) {
          Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
        } else {
          ownKeys(Object(source)).forEach(function (key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
          });
        }
      }return target;
    }

    function _defineProperty(obj, key, value) {
      if (key in obj) {
        Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
      } else {
        obj[key] = value;
      }return obj;
    }

    var noop = function noop() {};

    var LanguagesList = function LanguagesList(_ref) {
      var defaultLocaleId = _ref.defaultLocaleId,
          locales = _ref.locales,
          _ref$isEditable = _ref.isEditable,
          isEditable = _ref$isEditable === void 0 ? false : _ref$isEditable,
          _ref$onMakeDefault = _ref.onMakeDefault,
          onMakeDefault = _ref$onMakeDefault === void 0 ? noop : _ref$onMakeDefault,
          _ref$onEditBtnClick = _ref.onEditBtnClick,
          onEditBtnClick = _ref$onEditBtnClick === void 0 ? noop : _ref$onEditBtnClick,
          _ref$onItemDrop = _ref.onItemDrop,
          onItemDrop = _ref$onItemDrop === void 0 ? noop : _ref$onItemDrop,
          _ref$moveItem = _ref.moveItem,
          moveItem = _ref$moveItem === void 0 ? noop : _ref$moveItem;
      var manager = (0, _react.useRef)((0, _reactDnd.createDndContext)(_reactDndHtml5Backend.HTML5Backend));
      return (/*#__PURE__*/_react.default.createElement(_table.default, {
          borderless: true,
          headVerticalAlignment: "middle",
          hover: false
        }, /*#__PURE__*/_react.default.createElement(_table.default.Head, null, /*#__PURE__*/_react.default.createElement(_table.default.Row, null, /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          expanded: true,
          headingCell: true,
          headingTitle: true
        }, Liferay.Language.get('active-language')), isEditable && /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          align: "center"
        }, /*#__PURE__*/_react.default.createElement(_button.default, {
          displayType: "secondary",
          onClick: onEditBtnClick,
          small: true
        }, Liferay.Language.get('edit'))))), /*#__PURE__*/_react.default.createElement(_table.default.Body, null, /*#__PURE__*/_react.default.createElement(_reactDnd.DndProvider, {
          manager: manager.current.dragDropManager
        }, locales.map(function (locale, index) {
          var baseProps = _objectSpread(_objectSpread({}, locale), {}, {
            index: index,
            isDefault: defaultLocaleId === locale.localeId,
            key: locale.localeId
          });

          return isEditable ? /*#__PURE__*/_react.default.createElement(_LanguageListItemEditable.default, _extends({}, baseProps, {
            isFirst: index === 0,
            isLast: index === locales.length - 1,
            onItemDrop: onItemDrop,
            onMakeDefault: onMakeDefault,
            onMoveDown: function onMoveDown() {
              return moveItem(index, index + 1);
            },
            onMoveUp: function onMoveUp() {
              return moveItem(index, index - 1);
            }
          })) : /*#__PURE__*/_react.default.createElement(_LanguageListItem.default, baseProps);
        }))))
      );
    };

    LanguagesList.prototypes = {
      isEditable: _propTypes.default.bool,
      moveItem: _propTypes.default.func,
      onEditBtnClick: _propTypes.default.func,
      onItemDrop: _propTypes.default.func,
      onMakeDefault: _propTypes.default.func
    };
    var _default = LanguagesList;
    exports.default = _default;
    //# sourceMappingURL=LanguagesList.es.js.map
  }
});
//# sourceMappingURL=LanguagesList.es.js.map