package cz.moneta.test.dsl.ufo.operations.ufoOperations;


import cz.moneta.test.dsl.ufo.operations.shared.topmenu.XXX702_SharedTopMenu;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.ufo.UfoEndpoint;
import cz.moneta.test.harness.support.web.*;
import org.junit.jupiter.api.Assertions;

import static cz.moneta.test.dsl.ufo.operations.shared.SharedElements.LOAD_IMG_DIV_CLASS;
import static cz.moneta.test.dsl.ufo.operations.ufoOperations.STO704_S001_ClientConsentsPage.GENERATE_PRINT;

@Wait(GENERATE_PRINT)
public interface STO704_S001_ClientConsentsPage extends WebFlow<STO704_S001_ClientConsentsPage>, XXX702_SharedTopMenu<STO704_S001_ClientConsentsPage>, StoreAccessor {

    String REVOKE_SMS_BUTTON = "STO704_S001_B022";
    String REVOKE_TELEPHONE_BUTTON = "STO704_S001_B023";
    String REVOKE_IB_SB_BUTTON = "STO704_S001_B024";
    String REVOKE_SURVEYS_BUTTON = "STO704_S001_B025";
    String GIVE_ALL_BUTTON = "STO704_S001_B019";
    String REVOKE_POST_BUTTON = "STO704_S001_B021";
    String SMS_LABEL = "STO704_S001_L011";
    String REVOKE_EMAIL_BUTTON = "STO704_S001_B020";
    String REVOKE_WHATSAPP_BUTTON = "STO704_S001_B018";
    String REVOKE_OTHER_CHANNELS_BUTTON = "STO704_S001_B029";
    String GIVE_INSTANT_MESSAGING_BUTTON = "STO704_S001_B001";
    String REVOKE_UNENCRYPTED_COMMUNICATION_BUTTON = "STO704_S001_B026";
    String GIVE_UNENCRYPTED_COMMUNICATION_BUTTON = "STO704_S001_B028";
    String EMAIL_MMB_CONSENTS = "STO704_S001_L009";
    String EMAIL_MA_CONSENTS = "STO704_S001_L016";
    String EMAIL_ML_CONSENTS = "STO704_S001_L023";
    String EMAIL_WHB_CONSENTS = "STO704_S001_L151";
    String EMAIL_MSS_CONSENTS = "STO704_S001_L162";
    String POST_MMB_CONSENTS = "STO704_S001_L010";
    String POST_MA_CONSENTS = "STO704_S001_L017";
    String POST_ML_CONSENTS = "STO704_S001_L024";
    String POST_WHB_CONSENTS = "STO704_S001_L152";
    String POST_MSS_CONSENTS = "STO704_S001_L163";
    String SMS_MMB_CONSENTS = "STO704_S001_L011";
    String TELEPHONE_MMB_CONSENTS = "STO704_S001_L012";
    String IB_SB_MMB_CONSENTS = "STO704_S001_L013";
    String SURVEYS_MMB_CONSENTS = "STO704_S001_L014";
    String UNENCRYPTED_COMMUNICATION_MMB_CONSENT = "STO704_S001_L060";
    String WHATSAPP_MMB_CONSENTS = "STO704_S001_L193";
    String OTHER_CHANNELS_MMB_CONSENTS = "STO704_S001_L194";
    String HISTORY_CONSENTS_BUTTON_XPATH = "//*[@id=\"STO704_S001_V001\"]/div[2]/div/div[2]/div/button";
    String SEARCH_HISTORY_BUTTON = "STO704_S001_B006";
    String DETAIL_OF_LIST_CHANGE = "STO704_S001_P002-1";
    String CONSENT_STATUS_SET = "STO704_S001_L088-1";
    String PRINT_COMBOBOX = "STO704_S001_C010";
    String GENERATE_PRINT = "STO704_S001_B008";
    String TYPE_OF_CONSENT = "STO704_S001_L077-3";
    String TODAY_DATE_IN_CHANGES = "STO704_S001_E002";
    String POST_CONSENT = "STO704_S001_L077-4";
    String IBSB_CONSENT = "STO704_S001_L077-6";
    String SURVEY_CONSENT = "STO704_S001_L077-5";
    String SMS_CONSENT = "STO704_S001_L077-2";
    String EMAIL_CONSENT = "STO704_S001_L077-1";

    @Click(value = REVOKE_POST_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickRevokePostConsent();

    @Wait(GIVE_ALL_BUTTON)
    @Click(value = GIVE_ALL_BUTTON)
    STO704_S001_ClientConsentsPage clickGiveAllConsents();

    @Click(value = REVOKE_SMS_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickRevokeSmsConsent();

    @Click(value = REVOKE_TELEPHONE_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickRevokeTelephoneConsent();

    @Click(value = REVOKE_IB_SB_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickRevokeIbSbConsent();

    @Click(value = REVOKE_SURVEYS_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickRevokeSurveysConsent();

    @CheckElementContent("STO704_S001_L011")
    STO704_S001_ClientConsentsPage assertSmsConsentRevoked(String smsConsent);

    @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME)
    @CheckElementContent("STO704_S001_L013")
    STO704_S001_ClientConsentsPage assertIbSBConsentRevoked(String ibSbConsent);

    @Wait(value = LOAD_IMG_DIV_CLASS, until = Until.GONE, by = Lookup.CLASSNAME)
    @CheckElementContent("STO704_S001_L011")
    STO704_S001_ClientConsentsPage assertAllConsentsValid(String allConsents);

    @CheckElementContent("STO704_S001_L010")
    STO704_S001_ClientConsentsPage assertPostConsentRevoked(String postConsent);

    @CustomAction
    default STO704_S001_ClientConsentsPage clickOkButton() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        endpoint.acceptAlert(3);
        return null;
    }

    @Wait(value = REVOKE_EMAIL_BUTTON, until = Until.CLICKABLE)
    @Click(value = REVOKE_EMAIL_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickRevokeEmail();

    @Wait(value = REVOKE_WHATSAPP_BUTTON, until = Until.CLICKABLE)
    @Click(value = REVOKE_WHATSAPP_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickRevokeWhatsapp();

    @Wait(value = REVOKE_OTHER_CHANNELS_BUTTON, until = Until.CLICKABLE)
    @Click(value = REVOKE_OTHER_CHANNELS_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickRevokeOtherChannels();

    @Click(value = GIVE_INSTANT_MESSAGING_BUTTON)
    @AcceptAlert(waitSecondsForAlert = 10)
    STO704_S001_ClientConsentsPage clickGiveInstantMessagingConsents();

    @Wait(value = REVOKE_UNENCRYPTED_COMMUNICATION_BUTTON, until = Until.CLICKABLE)
    @Click(value = REVOKE_UNENCRYPTED_COMMUNICATION_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickRevokeUnencryptedCommunication();

    @Click(value = GIVE_UNENCRYPTED_COMMUNICATION_BUTTON)
    @AcceptAlert(waitSecondsForAlert = 10)
    STO704_S001_ClientConsentsPage clickGiveUnencryptedCommunicationConsents();

    @Wait(value = EMAIL_MMB_CONSENTS, until = Until.VISIBLE)
    @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE)
    @CheckElementContent(EMAIL_MMB_CONSENTS)
    STO704_S001_ClientConsentsPage checkEmailMMBConsents(String text);

    @Wait(value = EMAIL_MA_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(EMAIL_MA_CONSENTS)
    STO704_S001_ClientConsentsPage checkEmailMAConsents(String text);

    @Wait(value = EMAIL_ML_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(EMAIL_ML_CONSENTS)
    STO704_S001_ClientConsentsPage checkEmailMLConsents(String text);

    @Wait(value = EMAIL_WHB_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(EMAIL_WHB_CONSENTS)
    STO704_S001_ClientConsentsPage checkEmailWHBConsents(String text);

    @Wait(value = EMAIL_MSS_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(EMAIL_MSS_CONSENTS)
    STO704_S001_ClientConsentsPage checkEmailMSSConsents(String text);

    @Wait(value = HISTORY_CONSENTS_BUTTON_XPATH, by = Lookup.XPATH)
    @Click(value = HISTORY_CONSENTS_BUTTON_XPATH, by = Lookup.XPATH, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickHistoryConsents();

    @Click(value = SEARCH_HISTORY_BUTTON, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickSearchHistory();

    @Wait(value = DETAIL_OF_LIST_CHANGE, until = Until.VISIBLE)
    @Click(value = DETAIL_OF_LIST_CHANGE, andWait = @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE))
    STO704_S001_ClientConsentsPage clickdetailOfListChange();

    @Wait(value = CONSENT_STATUS_SET, until = Until.VISIBLE)
    @CheckElementContent(CONSENT_STATUS_SET)
    STO704_S001_ClientConsentsPage checkConsentsStatusSet(String consent);

    @Select(value = PRINT_COMBOBOX, selectByOrder = true)
    STO704_S001_ClientConsentsPage selectTypeOfPrint(int order);

    @Click(GENERATE_PRINT)
    PSP701_S001_AmortizationPage clickGeneratePrint();

    @Wait(value = TYPE_OF_CONSENT, until = Until.VISIBLE)
    @CheckElementContent(TYPE_OF_CONSENT)
    STO704_S001_ClientConsentsPage checkTypeOfConsent(String consent);

    @Wait(value = EMAIL_CONSENT, until = Until.VISIBLE)
    @CheckElementContent(EMAIL_CONSENT)
    STO704_S001_ClientConsentsPage checkTypeOfConsentEmail(String consent);

    @AcceptAlert(waitSecondsForAlert = 10, expectedAlertText = "Souhlasím se zpracováním svých osobních údajů, zejména, informací o bankovních obchodech a údajů vzniklých v průběhu využívání produktů a služeb které sdělím, nebo které oprávněným způsobem získají společnosti koncernu MONETA (MONETA Money Bank, a. s., MONETA Auto, s.r.o., MONETA Leasing, s.r.o. a MONETA Stavební Spořitelna a.s.) pro přípravu nabídky na míru a oslovení s nabídkou produktů nebo služeb. Více na www.moneta.cz v sekci Ochrana osobních údajů.")
    STO704_S001_ClientConsentsPage acceptAlert();

    @Wait(value = POST_CONSENT, until = Until.VISIBLE)
    @CheckElementContent(POST_CONSENT)
    STO704_S001_ClientConsentsPage checkPostConsent(String post);

    @Wait(value = IBSB_CONSENT, until = Until.VISIBLE)
    @CheckElementContent(IBSB_CONSENT)
    STO704_S001_ClientConsentsPage checkIBSBConsent(String IBSB);

    @Wait(value = SURVEY_CONSENT, until = Until.VISIBLE)
    @CheckElementContent(SURVEY_CONSENT)
    STO704_S001_ClientConsentsPage checkSurveyConsent(String survey);

    @Wait(value = SMS_CONSENT, until = Until.VISIBLE)
    @CheckElementContent(SMS_CONSENT)
    STO704_S001_ClientConsentsPage checkSMSConsent(String sms);

    @Wait(value = EMAIL_CONSENT, until = Until.VISIBLE)
    @CheckElementContent(EMAIL_CONSENT)
    STO704_S001_ClientConsentsPage checkEmailConsent(String email);

    @Wait(value = POST_MMB_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(POST_MMB_CONSENTS)
    STO704_S001_ClientConsentsPage checkPostMMBConsents(String text);

    @Wait(value = POST_MA_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(POST_MA_CONSENTS)
    STO704_S001_ClientConsentsPage checkPostMAConsents(String text);

    @Wait(value = POST_ML_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(POST_ML_CONSENTS)
    STO704_S001_ClientConsentsPage checkPostMLConsents(String text);

    @Wait(value = POST_WHB_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(POST_WHB_CONSENTS)
    STO704_S001_ClientConsentsPage checkPostWHBConsents(String text);

    @Wait(value = POST_MSS_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(POST_MSS_CONSENTS)
    STO704_S001_ClientConsentsPage checkPostMSSConsents(String text);

    @Wait(value = SMS_MMB_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(SMS_MMB_CONSENTS)
    STO704_S001_ClientConsentsPage checkSmsMMBConsents(String text);

    @Wait(value = TELEPHONE_MMB_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(TELEPHONE_MMB_CONSENTS)
    STO704_S001_ClientConsentsPage checkTelephoneMMBConsents(String text);

    @Wait(value = IB_SB_MMB_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(IB_SB_MMB_CONSENTS)
    STO704_S001_ClientConsentsPage checkIbSbMMBConsents(String text);

    @Wait(value = SURVEYS_MMB_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(SURVEYS_MMB_CONSENTS)
    STO704_S001_ClientConsentsPage checkSurveysMMBConsents(String text);

    @Wait(value = LOAD_IMG_DIV_CLASS, by = Lookup.CLASSNAME, until = Until.GONE)
    @CheckElementContent(UNENCRYPTED_COMMUNICATION_MMB_CONSENT)
    STO704_S001_ClientConsentsPage checkUnencryptedCommunicationMMBConsents(String text);

    @Wait(value = WHATSAPP_MMB_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(WHATSAPP_MMB_CONSENTS)
    STO704_S001_ClientConsentsPage checkWhatsappMMBConsents(String text);

    @Wait(value = OTHER_CHANNELS_MMB_CONSENTS, until = Until.VISIBLE)
    @CheckElementContent(OTHER_CHANNELS_MMB_CONSENTS)
    STO704_S001_ClientConsentsPage checkOtherChannelsMMBConsents(String text);

    @Wait(value = TODAY_DATE_IN_CHANGES, until = Until.VISIBLE)
    @CustomAction
    default STO704_S001_ClientConsentsPage checkIfIsSelectedTodayDate() {
        UfoEndpoint endpoint = getEndpoint(UfoEndpoint.class);
        String todayDateInChanges = endpoint.getAttribute(TODAY_DATE_IN_CHANGES, "value");
        String todayDate = getActualDate();
        Assertions.assertEquals(todayDate, todayDateInChanges, "Dates aren't same.");
        return null;
    }
}