import { TextButton, PopoverMenu } from '@wix/design-system';
import React from 'react';
import { observer } from 'mobx-react-lite';
import { ChevronDown, Confirm, Duplicate, Edit, Delete, Flag, FlagDismiss, } from '@wix/wix-ui-icons-common';
import { useWixPatternsContainer } from '@wix/bex-core/react';
function _ManageViewPopover(props) {
    const container = useWixPatternsContainer();
    const { state } = props;
    const { views, table, emitter, isViewChanged } = state;
    const { translate: t } = container;
    return (React.createElement(PopoverMenu, { minWidth: 271, onShow: () => {
            emitter.emit('openManageViewPopoverMenu');
        }, dataHook: "manage-view-popover", triggerElement: React.createElement(TextButton, { size: "small", as: "button", dataHook: "manage-view-popover-button", suffixIcon: React.createElement(ChevronDown, null) }, t('cairo.manageView.CTA')) },
        React.createElement(PopoverMenu.MenuItem, { text: t('cairo.manageView.saveChanges.CTA'), dataHook: "save-changes-to-view", disabled: !views.isCurrentViewSelected ||
                !isViewChanged ||
                views.currentView?.isPreset, 
            // subtitle={
            //   views.currentView?.isPreset
            //     ? t('cairo.manageView.saveChanges.disabled.predefinedView.tooltip')
            //     : !isViewChanged
            //     ? t('cairo.manageView.saveChanges.disabled.tooltip')
            //     : undefined
            // }
            prefixIcon: React.createElement(Confirm, null), onClick: () => {
                state.saveViewChanges();
            } }),
        React.createElement(PopoverMenu.MenuItem, { dataHook: "save-new-view", disabled: views.reachedViewsLimit, onClick: () => {
                views.saveViewModal.open();
                table.closeSidePanel();
            }, text: t('cairo.manageView.saveNewView.CTA'), prefixIcon: React.createElement(Duplicate, null) }),
        React.createElement(PopoverMenu.MenuItem, { dataHook: "rename-view", disabled: views.currentView?.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: React.createElement(Edit, null) }),
        React.createElement(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 ? React.createElement(FlagDismiss, null) : React.createElement(Flag, null) }),
        React.createElement(PopoverMenu.MenuItem, { dataHook: "delete-view", disabled: !views.isCurrentViewSelected || views.currentView?.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: React.createElement(Delete, null) })));
}
export const ManageViewPopover = observer(_ManageViewPopover);
//# sourceMappingURL=ManageViewPopover.js.map