import { DropdownLayoutUniDriver, PopoverMenuUniDriver, } from '@wix/design-system/dist/testkit/unidriver';
import { baseUniDriverFactory } from '../../unidriver';
export const ManageViewPopoverUniDriver = (base, body) => {
    const manageViewPopoverDriverBase = () => base.$('[data-hook="manage-view-popover"]');
    const manageViewPopoverDriver = () => PopoverMenuUniDriver(manageViewPopoverDriverBase(), body);
    const getContentElement = async () => {
        const popoverDriverBase = manageViewPopoverDriverBase();
        const contentDataHook = await popoverDriverBase.attr('data-content-hook');
        if (contentDataHook) {
            return body.$(`[data-content-element="${contentDataHook}"]`);
        }
        const baseDataHook = await popoverDriverBase.attr('data-hook');
        return body.$(`[data-hook="${baseDataHook}-content"]`);
    };
    const getDropdownLayoutDriver = async () => {
        const contentElement = await getContentElement();
        return DropdownLayoutUniDriver(contentElement.$(`[data-hook="dropdown-base-dropdownlayout"]`), body);
    };
    return {
        ...baseUniDriverFactory(base),
        exists: () => manageViewPopoverDriver().exists(),
        /** Opens the manage view popover */
        open: () => manageViewPopoverDriver()
            .getTriggerElement('manage-view-popover-button')
            .click(),
        /** Indicates whether the manage view popover is open */
        isOpen: () => manageViewPopoverDriver().isMenuOpen(),
        /** Trigger save changes action */
        clickSaveChanges: () => manageViewPopoverDriver().clickAtChildByDataHook('save-changes-to-view'),
        /** Trigger save new view action */
        clickSaveNewView: () => manageViewPopoverDriver().clickAtChildByDataHook('save-new-view'),
        /** Trigger rename view action */
        clickRenameView: () => manageViewPopoverDriver().clickAtChildByDataHook('rename-view'),
        /** Trigger set as default view action */
        clickSetAsDefaultView: () => manageViewPopoverDriver().clickAtChildByDataHook('set-as-default-view'),
        /** Trigger delete view action */
        clickDeleteView: () => manageViewPopoverDriver().clickAtChildByDataHook('delete-view'),
        /** Get save changes btn */
        getSaveChangesBtn: async () => {
            const dropdownLayoutDriver = await getDropdownLayoutDriver();
            return dropdownLayoutDriver.optionById(0);
        },
        /** Get save new view btn */
        getSaveNewViewBtn: async () => {
            const dropdownLayoutDriver = await getDropdownLayoutDriver();
            return dropdownLayoutDriver.optionById(1);
        },
        /** Get rename view btn */
        getRenameViewBtn: async () => {
            const dropdownLayoutDriver = await getDropdownLayoutDriver();
            return dropdownLayoutDriver.optionById(2);
        },
        /** Get set as default view btn */
        getSetAsDefaultViewBtn: async () => {
            const dropdownLayoutDriver = await getDropdownLayoutDriver();
            return dropdownLayoutDriver.optionById(3);
        },
        /** Get delete view btn */
        getDeleteViewBtn: async () => {
            const dropdownLayoutDriver = await getDropdownLayoutDriver();
            return dropdownLayoutDriver.optionById(4);
        },
    };
};
//# sourceMappingURL=ManageViewPopover.uni.driver.js.map