Liferay.Loader.define("layout-content-page-editor-web@2.0.157/page_editor/plugins/comments/components/FragmentComments", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', '@frontend-taglib-clay$clayui/icon', 'frontend-js-react-web$prop-types', 'frontend-js-react-web$react', '../../../app/actions/editFragmentEntryLinkComment', '../../../app/components/Controls', '../../../app/store/index', '../../../common/components/SidebarPanelContent', '../../../common/components/SidebarPanelHeader', './AddCommentForm', './FragmentComment', './ResolvedCommentsToggle'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = FragmentComments;

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

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

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

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

    var _editFragmentEntryLinkComment = _interopRequireDefault(require("../../../app/actions/editFragmentEntryLinkComment"));

    var _Controls = require("../../../app/components/Controls");

    var _index = require("../../../app/store/index");

    var _SidebarPanelContent = _interopRequireDefault(require("../../../common/components/SidebarPanelContent"));

    var _SidebarPanelHeader = _interopRequireDefault(require("../../../common/components/SidebarPanelHeader"));

    var _AddCommentForm = _interopRequireDefault(require("./AddCommentForm"));

    var _FragmentComment = _interopRequireDefault(require("./FragmentComment"));

    var _ResolvedCommentsToggle = _interopRequireDefault(require("./ResolvedCommentsToggle"));

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

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */
    function FragmentComments(_ref) {
      var fragmentEntryLink = _ref.fragmentEntryLink;
      var _fragmentEntryLink$co = fragmentEntryLink.comments,
          comments = _fragmentEntryLink$co === void 0 ? [] : _fragmentEntryLink$co,
          fragmentEntryLinkId = fragmentEntryLink.fragmentEntryLinkId,
          name = fragmentEntryLink.name;
      var selectItem = (0, _Controls.useSelectItem)();
      var dispatch = (0, _index.useDispatch)();
      var showResolvedComments = (0, _index.useSelector)(function (state) {
        return state.showResolvedComments;
      });
      var fragmentEntryLinkComments = showResolvedComments ? comments : comments.filter(function (_ref2) {
        var resolved = _ref2.resolved;
        return !resolved;
      });
      return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_SidebarPanelHeader.default, {
          className: "comments-sidebar-title",
          padded: false
        }, /*#__PURE__*/_react.default.createElement(_button.default, {
          borderless: true,
          className: "mx-1 text-dark",
          displayType: "secondary",
          onClick: function onClick() {
            return selectItem(null);
          },
          small: true
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          symbol: "angle-left"
        })), /*#__PURE__*/_react.default.createElement("span", null, name)), /*#__PURE__*/_react.default.createElement(_SidebarPanelContent.default, {
          padded: false
        }, /*#__PURE__*/_react.default.createElement(_ResolvedCommentsToggle.default, null), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_AddCommentForm.default, {
          fragmentEntryLinkId: fragmentEntryLinkId
        }), fragmentEntryLinkComments.map(function (_, i) {
          var comment = fragmentEntryLinkComments[fragmentEntryLinkComments.length - 1 - i];
          return (/*#__PURE__*/_react.default.createElement(_FragmentComment.default, {
              comment: comment,
              fragmentEntryLinkId: fragmentEntryLinkId,
              key: comment.commentId,
              onEdit: function onEdit(fragmentEntryLinkComment) {
                return dispatch((0, _editFragmentEntryLinkComment.default)({
                  fragmentEntryLinkComment: fragmentEntryLinkComment,
                  fragmentEntryLinkId: fragmentEntryLinkId
                }));
              }
            })
          );
        }))))
      );
    }
    //# sourceMappingURL=FragmentComments.js.map
  }
});
//# sourceMappingURL=FragmentComments.js.map