package ctbrec.ui.sites.xlovecam;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import ctbrec.recorder.Recorder;
import ctbrec.sites.xlovecam.XloveCam;
import ctbrec.ui.tabs.PaginatedScheduledService;
import ctbrec.ui.tabs.TabProvider;
import ctbrec.ui.tabs.ThumbOverviewTab;
import javafx.scene.Scene;
import javafx.scene.control.Tab;

public class XloveCamTabProvider implements TabProvider {

    private XloveCam site;
    private Recorder recorder;

    public XloveCamTabProvider(XloveCam xloveCam) {
        this.site = xloveCam;
        this.recorder = xloveCam.getRecorder();
    }

    @Override
    public List<Tab> getTabs(Scene scene) {
        List<Tab> tabs = new ArrayList<>();

        // all
        var updateService = new XloveCamUpdateService(site, Collections.emptyMap());
        tabs.add(createTab("All", updateService));

        // Young Women
        updateService = new XloveCamUpdateService(site, Map.of("config[filter][10][]", "1"));
        tabs.add(createTab("Young Women", updateService));

        // Ladies
        updateService = new XloveCamUpdateService(site, Map.of("config[filter][10][]", "13"));
        tabs.add(createTab("Ladies", updateService));

        // Mature
        updateService = new XloveCamUpdateService(site, Map.of("config[filter][10][]", "6"));
        tabs.add(createTab("Mature Female", updateService));

        // Couples
        updateService = new XloveCamUpdateService(site, Map.of("config[filter][10][]", "2"));
        tabs.add(createTab("Couples", updateService));

        // Lesbian
        updateService = new XloveCamUpdateService(site, Map.of("config[filter][10][]", "3"));
        tabs.add(createTab("Lesbian", updateService));

        // Male
        updateService = new XloveCamUpdateService(site, Map.of("config[filter][10][]", "7"));
        tabs.add(createTab("Male", updateService));

        // Trans
        updateService = new XloveCamUpdateService(site, Map.of("config[filter][10][]", "5"));
        tabs.add(createTab("Trans", updateService));

        return tabs;
    }

    @Override
    public Tab getFollowedTab() {
        return null;
    }

    private Tab createTab(String title, PaginatedScheduledService updateService) {
        var tab = new ThumbOverviewTab(title, updateService, site);
        tab.setRecorder(recorder);
        return tab;
    }

}
