package cz.moneta.test.dsl.hypos.components;

import cz.moneta.test.dsl.hypos.pages.HyposMainPage;
import cz.moneta.test.dsl.hypos.pages.contract.ContractHistoryPage;
import cz.moneta.test.dsl.hypos.pages.contract.SearchContractPage;
import cz.moneta.test.dsl.hypos.pages.contract.approval.ScoringPage;
import cz.moneta.test.dsl.hypos.pages.contract.approvalchecklist.ApprovalChecklistPage;
import cz.moneta.test.dsl.hypos.pages.contract.backoffice.BackOfficePage;
import cz.moneta.test.dsl.hypos.pages.contract.clients.ClientsListPage;
import cz.moneta.test.dsl.hypos.pages.contract.clients.LoadCifPage;
import cz.moneta.test.dsl.hypos.pages.contract.communication.CommunicationPage;
import cz.moneta.test.dsl.hypos.pages.contract.complaints.ComplaintsPage;
import cz.moneta.test.dsl.hypos.pages.contract.documents.DocumentsPage;
import cz.moneta.test.dsl.hypos.pages.contract.externalsources.ExternalSourcesPage;
import cz.moneta.test.dsl.hypos.pages.contract.fees.FeesPage;
import cz.moneta.test.dsl.hypos.pages.contract.forms.FormsPage;
import cz.moneta.test.dsl.hypos.pages.contract.lifeinsurance.LifeInsurancePage;
import cz.moneta.test.dsl.hypos.pages.contract.loan.LoanPage;
import cz.moneta.test.dsl.hypos.pages.contract.notifications.NotificationsPage;
import cz.moneta.test.dsl.hypos.pages.contract.pktu.PktuPage;
import cz.moneta.test.dsl.hypos.pages.contract.processchecklist.ProcessChecklistPage;
import cz.moneta.test.dsl.hypos.pages.contract.realty.RealtyPage;
import cz.moneta.test.dsl.hypos.pages.contract.realtyinsurance.RealtyInsurancePage;
import cz.moneta.test.dsl.hypos.pages.contract.retention.RetentionPage;
import cz.moneta.test.dsl.hypos.pages.contract.service.ServicePage;
import cz.moneta.test.dsl.hypos.pages.contract.urgent.UrgentPage;
import cz.moneta.test.dsl.hypos.pages.contract.withdrawal.WithdrawalRequestsPage;
import cz.moneta.test.dsl.hypos.pages.hypokalkulacka.HypokalkulackaPage;
import cz.moneta.test.dsl.hypos.pages.structure.StructurePage;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.hypos.HyposEndpoint;
import cz.moneta.test.harness.support.web.*;

public interface Menu extends Builder, StoreAccessor {
    //iframes present on Hypos pages, Hypokom and Hypokalkulačka do not use iframes
    String HEADER_FRAME_XPATH = "//frameset/frame[@id='header']";
    String MAIN_FRAME_XPATH = "//frameset/frame[@id='main']";

    //Horizontal menus
    String HYPOS_LINK = "//a[text()='Hypos']";
    String HYPOKALKULACKA_LINK = "//div[@class='headermenu']//a[text()='Hypokalkulačka']";
    String HYPOKOM_LINK = "//div[@class='headermenu']//a[text()='Hypokom']";
    String USER_DETAIL_LINK = "//div[@class='headermenu']//a[@href='/Hypos/user.php?cmd=detail']";

    //Vertical menus
    String VERTICAL_MENU_LIST = "//ul[@class='vert-menu']";
    String SEARCH_CONTRACT_LINK = VERTICAL_MENU_LIST + "//a[contains(@href, 'search.contract')]"; //link Oprava údajů, vstup dat
    String STRUCTURE_LINK = VERTICAL_MENU_LIST + "//a/div[text()='Sestavy']";
    String LOAN_LINK = VERTICAL_MENU_LIST + "//a[text()='Úvěr']";
    String REALTY_LINK = VERTICAL_MENU_LIST + "//a[text()='Nemovitosti']";
    String SCORING_LINK = VERTICAL_MENU_LIST + "//a[text()='Schvalování']";
    String CLIENTS_LINK = VERTICAL_MENU_LIST + "//a[text()='Klienti']";
    String LIFE_INSURANCE_LINK = VERTICAL_MENU_LIST + "//a[text()='Životní pojištění']";
    String DOCUMENTS_LINK = VERTICAL_MENU_LIST + "//a[text()='Dokumenty']";
    String WITHDRAWAL_REQUESTS_LINK = VERTICAL_MENU_LIST + "//a[text()='Žádosti o čerpání']";
    String VERTICAL_MENU_HYPOKALKULACKA_LINK = VERTICAL_MENU_LIST + "//a[text()='Hypokalkulačka']";
    String CONTRACT_HOMEPAGE_LINK = VERTICAL_MENU_LIST + "//a[text()='Úvodní stránka']";
    String CLOSE_CONTRACT_LINK = VERTICAL_MENU_LIST + "//a[text()='KONEC PRÁCE']";
    String APPROVAL_CHECKLIST_LINK = VERTICAL_MENU_LIST + "//a[text()='Schvalovací checklist']";
    String FEES_LINK = VERTICAL_MENU_LIST + "//a[text()='Poplatky']";
    String REALTY_INSURANCE_LINK = VERTICAL_MENU_LIST + "//a[text()='Sjednání pojištění majetku']";
    String FORMS_LINK = VERTICAL_MENU_LIST + "//a[text()='Formuláře']";
    String PROCESS_CHECKLIST_LINK = VERTICAL_MENU_LIST + "//a[text()='Checklist procesních kroků']";
    String COMMUNICATION_LINK = VERTICAL_MENU_LIST + "//a[text()='Sdělení']";
    String NOTIFICATIONS_LINK = VERTICAL_MENU_LIST + "//a[text()='Notifikace klienta']";
    String PKTU_LINK = VERTICAL_MENU_LIST + "//a[text()='PKTÚ']";
    String EXTERNAL_SOURCES_LINK = VERTICAL_MENU_LIST + "//a[text()='Externí zdroje']";
    String URGENT_LINK = VERTICAL_MENU_LIST + "//a[text()='Urgenty']";
    String RETENTION_LINK = VERTICAL_MENU_LIST + "//a[text()='Retence']";
    String SERVICE_LINK = VERTICAL_MENU_LIST + "//a[text()='Servis']";
    String BACKOFFICE_LINK = VERTICAL_MENU_LIST + "//a[text()='BackOffice']";
    String COMPLAINTS_LINK = VERTICAL_MENU_LIST + "//a[text()='Úkoly na centrálu']";

    @Click(SEARCH_CONTRACT_LINK)
    SearchContractPage clickSearchContract();

    @Click(CONTRACT_HOMEPAGE_LINK)
    ContractHistoryPage clickHomepage();

    @Click(CLOSE_CONTRACT_LINK)
    HyposMainPage clickCloseContract();

    @Click(CLIENTS_LINK)
    ClientsListPage clickClients();

    @Click(LIFE_INSURANCE_LINK)
    LifeInsurancePage clickLifeInsurance();

    @Click(CLIENTS_LINK)
    LoadCifPage clickClientsToSetCif();

    @Click(LOAN_LINK)
    LoanPage clickLoan();

    @Click(REALTY_LINK)
    RealtyPage clickRealty();

    @Click(DOCUMENTS_LINK)
    DocumentsPage clickDocuments();

    @Click(APPROVAL_CHECKLIST_LINK)
    ApprovalChecklistPage clickApprovalChecklist();

    @Click(WITHDRAWAL_REQUESTS_LINK)
    WithdrawalRequestsPage clickWithdrawalRequests();

    @Click(SCORING_LINK)
    ScoringPage clickScoring();

    @Click(STRUCTURE_LINK)
    StructurePage clickStructure();

    @Click(FEES_LINK)
    FeesPage clickFees();

    @Click(REALTY_INSURANCE_LINK)
    RealtyInsurancePage clickRealtyInsurance();

    @Click(FORMS_LINK)
    FormsPage clickForms();

    @Click(PROCESS_CHECKLIST_LINK)
    ProcessChecklistPage clickProcessChecklist();

    @Click(COMMUNICATION_LINK)
    CommunicationPage clickCommunication();

    @Click(NOTIFICATIONS_LINK)
    NotificationsPage clickNotifications();

    @Click(PKTU_LINK)
    PktuPage clickPktu();

    @Click(EXTERNAL_SOURCES_LINK)
    ExternalSourcesPage clickExternalSources();

    @Click(URGENT_LINK)
    UrgentPage clickUrgent();

    @Click(RETENTION_LINK)
    RetentionPage clickRetention();

    @Click(SERVICE_LINK)
    ServicePage clickService();

    @Click(BACKOFFICE_LINK)
    BackOfficePage clickBackOffice();

    @Click(COMPLAINTS_LINK)
    ComplaintsPage clickComplaints();

    @CustomAction
    default HypokalkulackaPage clickHypokalkulacka() {
        HyposEndpoint endpoint = getEndpoint(HyposEndpoint.class);
        endpoint.click(() -> VERTICAL_MENU_HYPOKALKULACKA_LINK);
        endpoint.focusToNewPopup(20);
        endpoint.maximizeBrowserWindow();
        return null;
    }
}