Liferay.Loader.define("item-selector-taglib@4.2.11/item_selector_preview/js/Carousel.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', '@frontend-taglib-clay$clayui/icon', '@frontend-taglib-clay$clayui/tabs', 'frontend-js-react-web$react', './NoPreview.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 _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

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

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

    var _NoPreview = _interopRequireDefault(require("./NoPreview.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 _slicedToArray(arr, i) {
      return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
    }

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
          _arr.push(_s.value);if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;_e = err;
      } finally {
        try {
          if (!_n && _i["return"] != null) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }return _arr;
    }

    function _arrayWithHoles(arr) {
      if (Array.isArray(arr)) return arr;
    }

    var Arrow = function Arrow(_ref) {
      var direction = _ref.direction,
          handleClick = _ref.handleClick;
      return (/*#__PURE__*/_react.default.createElement("div", {
          className: "pull-".concat(direction)
        }, /*#__PURE__*/_react.default.createElement(_button.default, {
          borderless: true,
          className: "icon-arrow",
          displayType: "secondary",
          onClick: handleClick,
          size: "lg"
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          symbol: "angle-".concat(direction)
        })))
      );
    };

    var InfoPanel = function InfoPanel(_ref2) {
      var metadata = _ref2.metadata;

      var _useState = (0, _react.useState)(0),
          _useState2 = _slicedToArray(_useState, 2),
          activeTabKeyValue = _useState2[0],
          setActiveTabKeyValue = _useState2[1];

      var imageData = JSON.parse(metadata);
      var itemsHeader = imageData.groups.map(function (group, index) {
        return (/*#__PURE__*/_react.default.createElement(_tabs.default.Item, {
            active: activeTabKeyValue == index,
            key: group.title,
            onClick: function onClick() {
              return setActiveTabKeyValue(index);
            }
          }, group.title)
        );
      });
      var itemsContent = imageData.groups.map(function (group, index) {
        var itemContentTab = group.data.map(function (item) {
          return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
              key: item.key
            }, /*#__PURE__*/_react.default.createElement("dt", {
              className: "sidebar-dt"
            }, item.key), /*#__PURE__*/_react.default.createElement("dd", {
              className: "sidebar-dd"
            }, item.value))
          );
        });
        return (/*#__PURE__*/_react.default.createElement(_tabs.default.TabPane, {
            "aria-labelledby": "tab-".concat(index),
            key: "tabPane-".concat(index)
          }, /*#__PURE__*/_react.default.createElement("dl", {
            className: "sidebar-dl sidebar-section"
          }, itemContentTab))
        );
      });
      return (/*#__PURE__*/_react.default.createElement("div", {
          className: "info-panel sidenav-menu-slider"
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "sidebar-header"
        }, /*#__PURE__*/_react.default.createElement(_tabs.default, {
          modern: true
        }, itemsHeader)), /*#__PURE__*/_react.default.createElement("div", {
          className: "sidebar-body"
        }, /*#__PURE__*/_react.default.createElement(_tabs.default.Content, {
          activeIndex: activeTabKeyValue,
          fade: true
        }, itemsContent)))
      );
    };

    var Carousel = function Carousel(_ref3) {
      var currentItem = _ref3.currentItem,
          handleClickNext = _ref3.handleClickNext,
          handleClickPrevious = _ref3.handleClickPrevious,
          isImage = _ref3.isImage,
          _ref3$showArrows = _ref3.showArrows,
          showArrows = _ref3$showArrows === void 0 ? true : _ref3$showArrows;
      return (/*#__PURE__*/_react.default.createElement("div", {
          className: "carousel closed sidenav-container"
        }, /*#__PURE__*/_react.default.createElement(InfoPanel, {
          metadata: currentItem.metadata
        }), /*#__PURE__*/_react.default.createElement("div", {
          className: "sidenav-content"
        }, showArrows && /*#__PURE__*/_react.default.createElement(Arrow, {
          direction: "left",
          handleClick: handleClickPrevious
        }), isImage ? /*#__PURE__*/_react.default.createElement("img", {
          alt: currentItem.title,
          src: currentItem.url || currentItem.base64
        }) : /*#__PURE__*/_react.default.createElement(_NoPreview.default, null), showArrows && /*#__PURE__*/_react.default.createElement(Arrow, {
          direction: "right",
          handleClick: handleClickNext
        })))
      );
    };

    var _default = Carousel;
    exports.default = _default;
    //# sourceMappingURL=Carousel.es.js.map
  }
});
//# sourceMappingURL=Carousel.es.js.map