"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.ManageViewPopover = void 0;
var _designSystem = require("@wix/design-system");
var _react = _interopRequireDefault(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _react2 = require("@wix/bex-core/react");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/CollectionViewsDropdown/ManageViewPopover.tsx";
function _ManageViewPopover(props) {
  var _views$currentView, _views$currentView2, _views$currentView3;
  const container = (0, _react2.useWixPatternsContainer)();
  const {
    state
  } = props;
  const {
    views,
    table,
    emitter,
    isViewChanged
  } = state;
  const {
    translate: t
  } = container;
  return /*#__PURE__*/_react.default.createElement(_designSystem.PopoverMenu, {
    minWidth: 271,
    onShow: () => {
      emitter.emit('openManageViewPopoverMenu');
    },
    dataHook: "manage-view-popover",
    triggerElement: /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
      size: "small",
      as: "button",
      dataHook: "manage-view-popover-button",
      suffixIcon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.ChevronDown, {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 43,
          columnNumber: 23
        }
      }),
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 39,
        columnNumber: 9
      }
    }, t('cairo.manageView.CTA')),
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 32,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.PopoverMenu.MenuItem, {
    text: t('cairo.manageView.saveChanges.CTA'),
    dataHook: "save-changes-to-view",
    disabled: !views.isCurrentViewSelected || !isViewChanged || ((_views$currentView = views.currentView) == null ? void 0 : _views$currentView.isPreset)
    // subtitle={
    //   views.currentView?.isPreset
    //     ? t('cairo.manageView.saveChanges.disabled.predefinedView.tooltip')
    //     : !isViewChanged
    //     ? t('cairo.manageView.saveChanges.disabled.tooltip')
    //     : undefined
    // }
    ,
    prefixIcon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.Confirm, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 64,
        columnNumber: 21
      }
    }),
    onClick: () => {
      state.saveViewChanges();
    },
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 49,
      columnNumber: 7
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.PopoverMenu.MenuItem, {
    dataHook: "save-new-view",
    disabled: views.reachedViewsLimit,
    onClick: () => {
      views.saveViewModal.open();
      table.closeSidePanel();
    },
    text: t('cairo.manageView.saveNewView.CTA'),
    prefixIcon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.Duplicate, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 77,
        columnNumber: 21
      }
    }),
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 69,
      columnNumber: 7
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.PopoverMenu.MenuItem, {
    dataHook: "rename-view",
    disabled: ((_views$currentView2 = views.currentView) == null ? void 0 : _views$currentView2.isPreset) || isViewChanged
    // subtitle={
    //   views.currentView?.isPreset
    //     ? t('cairo.manageView.Rename.disabled.predefinedView.tooltip')
    //     : isViewChanged
    //     ? t('cairo.manageView.Rename.disabled.tooltip')
    //     : undefined
    // }
    ,
    onClick: () => {
      views.renameViewModal.open();
      table.closeSidePanel();
    },
    text: t('cairo.manageView.Rename.CTA'),
    prefixIcon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.Edit, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 94,
        columnNumber: 21
      }
    }),
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 79,
      columnNumber: 7
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.PopoverMenu.MenuItem, {
    dataHook: "set-as-default-view",
    disabled: !views.currentView || isViewChanged && !views.isDefaultView
    // subtitle={
    //   isViewChanged && !views.isDefaultView
    //     ? t('cairo.manageView.setAsDefault.tooltip')
    //     : undefined
    // }
    ,
    onClick: () => {
      state.setAsDefaultView();
    },
    text: views.isDefaultView ? t('cairo.manageView.setAsDefault.reset.CTA') : t('cairo.manageView.setAsDefault.CTA'),
    prefixIcon: views.isDefaultView ? /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.FlagDismiss, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 112,
        columnNumber: 43
      }
    }) : /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.Flag, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 112,
        columnNumber: 61
      }
    }),
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 96,
      columnNumber: 7
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.PopoverMenu.MenuItem, {
    dataHook: "delete-view",
    disabled: !views.isCurrentViewSelected || ((_views$currentView3 = views.currentView) == null ? void 0 : _views$currentView3.isPreset)
    // subtitle={
    //   views.isCurrentViewSelected && views.currentView?.isPreset
    //     ? t('cairo.manageView.Delete.disabled.predefinedView.tooltip')
    //     : undefined
    // }
    ,
    onClick: () => {
      state.deleteView();
    },
    text: t('cairo.manageView.Delete.CTA'),
    prefixIcon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.Delete, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 126,
        columnNumber: 21
      }
    }),
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 114,
      columnNumber: 7
    }
  }));
}
const ManageViewPopover = exports.ManageViewPopover = (0, _mobxReactLite.observer)(_ManageViewPopover);
//# sourceMappingURL=ManageViewPopover.js.map