<?php

namespace Planaday\Config\OptionGroups\Course\Detail;

use Planaday\Config\OptionGroups\Course\CourseOptions;
use Planaday\Config\OptionGroups\Course\Overview\OverviewOptionsEnum;
use Planaday\Config\OptionGroups\OptionCluster;
use Planaday\Config\OptionGroups\OptionGroup;
use Planaday\Config\OptionTypes\BoolOption;
use Planaday\Config\OptionTypes\PageOption;
use Planaday\Platform\WordpressConfig\ShortcodeLinks\CourseShortcodes;
use Planaday\Utility\DependencyInjection\ComponentRegistry;
use Planaday\Utility\DependencyInjection\ComponentRegistryShortCut;
use Planaday\Utility\PluginData;

class DetailOptions extends OptionGroup implements ComponentRegistryShortCut {
	private const NAME = 'Detail';

	private const DESCRIPTION = 'Instellingen voor de detail pagina';

	/** @var BoolOption<bool> */
	private $showSoobLabel;

	/** @var BoolOption<bool> */
	private $showCode95Label;

	/** @var BoolOption<bool> */
	private $showLabels;

	/** @var BoolOption<bool> */
	private $showDayPartCount;

	/** @var BoolOption<bool> */
	private $showDayPartList;

	/** @var BoolOption<bool> */
	private $showLocationDayPart;

	/** @var BoolOption<bool> */
	private $showELearningDayPart;

	/** @var BoolOption<bool> */
	private $showLevelCourse;

	/** @var BoolOption<bool> */
	private $showDescriptionDayPart;

	/** @var BoolOption<bool> */
	private $showAvailability;

	/** @var BoolOption<bool> */
	private $showStartGuaranteeLabel;

	/** @var BoolOption<bool> */
	private $showMoneyBackLabel;

	/** @var BoolOption<bool> */
	private $showFinancialInfo;

	/** @var BoolOption<bool> */
	private $showPrice;

	/** @var BoolOption<bool> */
	private $showPriceWithAndWithoutTax;

	/** @var BoolOption<bool> */
	private $showIcons;

	/** @var BoolOption<bool> */
	private $includeELearningDayParts;

	/** @var BoolOption<bool> */
	private $showELearningIcon;

	/** @var BoolOption<bool> */
	private $showDescription;

	/** @var BoolOption<bool> */
	private $showLabelsDayPart;

	/** @var PageOption<int> */
	private $selectedDetailPage;

	/** @var PageOption<int> */
	private $overriddenDetailPage;

	/** @var PageOption<int> */
	private $courseNotFoundPage;

	public function __construct( string $index, array $data, PluginData $pluginData) {
		$this->selectedDetailPage = new PageOption(
			DetailOptionsEnum::SELECTED_DETAIL_PAGE,
			'Detailpagina',
			'Selecteer welke pagina wordt gebruikt als detail pagina (alleen paginas met de course shortcode)',
			$data[ DetailOptionsEnum::SELECTED_DETAIL_PAGE ] ?? null,
			0,
			$pluginData->getShortPrefix() . CourseShortcodes::COURSE_OVERVIEW_SHORTCODE
		);

		$this->overriddenDetailPage = new PageOption(
			DetailOptionsEnum::OVERRIDDEN_DETAIL_PAGE,
			'Overschrijven detailpagina',
			'Selecteer welke pagina wordt gebruikt als detail pagina (alle pagina\'s, alleen aangeraden als normale optie niet werkt)',
			$data[ DetailOptionsEnum::OVERRIDDEN_DETAIL_PAGE ] ?? null,
			0
		);

		$this->courseNotFoundPage = new PageOption(
			DetailOptionsEnum::COURSE_NOT_FOUND_PAGE,
			'Cursus niet gevonden pagina',
			'Selecteer welke pagina wordt getoond als de cursus niet gevonden is (alleen wanneer padc-course-not-found-redirect is toegevoegd)',
			$data[ DetailOptionsEnum::COURSE_NOT_FOUND_PAGE ] ?? null,
			0
		);

		$this->showSoobLabel = new BoolOption(
			DetailOptionsEnum::SHOW_SOOB_LABEL,
			'Toon SOOB label',
			'Toon het SOOB label bij de cursus',
			$data[ DetailOptionsEnum::SHOW_SOOB_LABEL ] ?? null,
			false
		);

		$this->showCode95Label = new BoolOption(
			DetailOptionsEnum::SHOW_CODE_95_LABEL,
			'Toon CODE 95 label',
			'Toon het CODE 95 label bij de cursus',
			$data[ DetailOptionsEnum::SHOW_CODE_95_LABEL ] ?? null,
			false
		);

		$this->showLabels = new BoolOption(
			DetailOptionsEnum::SHOW_LABELS,
			'Toon labels',
			'Toon de labels bij de cursus',
			$data[ DetailOptionsEnum::SHOW_LABELS ] ?? null,
			false
		);

		$this->showDayPartCount = new BoolOption(
			DetailOptionsEnum::SHOW_DAY_PART_COUNT,
			'Toon dagdeel aantal',
			'Toon het dagdeel aantal bij de cursus',
			$data[ DetailOptionsEnum::SHOW_DAY_PART_COUNT ] ?? null,
			true
		);

		$this->showDayPartList = new BoolOption(
			DetailOptionsEnum::SHOW_DAY_PART_LIST,
			'Toon dagdeel lijst',
			'Toon de dagdeel lijst bij de cursus',
			$data[ DetailOptionsEnum::SHOW_DAY_PART_LIST ] ?? null,
			false
		);

		$this->showLocationDayPart = new BoolOption(
			DetailOptionsEnum::SHOW_LOCATION_DAY_PART,
			'Toon locatie dagdeel',
			'Toon de locatie bij het dagdeel',
			$data[ DetailOptionsEnum::SHOW_LOCATION_DAY_PART ] ?? null,
			false
		);

		$this->showELearningDayPart = new BoolOption(
			DetailOptionsEnum::SHOW_E_LEARNING_DAY_PART,
			'Toon e-learning dagdeel',
			'Toon een e-learning label bij het dagdeel als deze dit heeft',
			$data[ DetailOptionsEnum::SHOW_E_LEARNING_DAY_PART ] ?? null,
			false
		);

		$this->showLevelCourse = new BoolOption(
			DetailOptionsEnum::SHOW_LEVEL_COURSE,
			'Toon niveau cursus',
			'Toon het niveau bij de cursus',
			$data[ DetailOptionsEnum::SHOW_LEVEL_COURSE ] ?? null,
			false
		);

		$this->showDescriptionDayPart = new BoolOption(
			DetailOptionsEnum::SHOW_DESCRIPTION_DAY_PART,
			'Toon beschrijving dagdeel',
			'Toon de beschrijving bij het dagdeel bij de cursus',
			$data[ DetailOptionsEnum::SHOW_DESCRIPTION_DAY_PART ] ?? null,
			false
		);

		$this->showAvailability = new BoolOption(
			DetailOptionsEnum::SHOW_AVAILABILITY,
			'Toon beschikbaarheid',
			'Toon de beschikbaarheid bij de cursus',
			$data[ DetailOptionsEnum::SHOW_AVAILABILITY ] ?? null,
			false
		);

		$this->showStartGuaranteeLabel = new BoolOption(
			DetailOptionsEnum::SHOW_START_GUARANTEE_LABEL,
			'Toon start garantie label',
			'Toon het start garantie label bij de cursus',
			$data[ DetailOptionsEnum::SHOW_START_GUARANTEE_LABEL ] ?? null,
			false
		);

		$this->showMoneyBackLabel = new BoolOption(
			DetailOptionsEnum::SHOW_MONEY_BACK_LABEL,
			'Toon geld terug label',
			'Toon het geld terug label bij de cursus',
			$data[ DetailOptionsEnum::SHOW_MONEY_BACK_LABEL ] ?? null,
			false
		);

		$this->showFinancialInfo = new BoolOption(
			DetailOptionsEnum::SHOW_FINANCIAL_INFO,
			'Toon financiële informatie',
			'Toon de financiële informatie bij de cursus',
			$data[ DetailOptionsEnum::SHOW_FINANCIAL_INFO ] ?? null,
			false
		);

		$this->showPrice = new BoolOption(
			DetailOptionsEnum::SHOW_PRICE,
			'Toon prijs',
			'Toon de prijs bij de cursus',
			$data[ DetailOptionsEnum::SHOW_PRICE ] ?? null,
			true
		);

		$this->showPriceWithAndWithoutTax = new BoolOption(
			DetailOptionsEnum::SHOW_PRICE_WITH_AND_WITHOUT_TAX,
			'Toon prijs inclusief en exclusief belasting',
			'Toon de prijs inclusief en exclusief belasting bij de cursus',
			$data[ DetailOptionsEnum::SHOW_PRICE_WITH_AND_WITHOUT_TAX ] ?? null,
			false
		);

		$this->showIcons = new BoolOption(
			DetailOptionsEnum::SHOW_ICONS,
			'Toon icoon',
			'Toon iconen bij de labels',
			$data[ DetailOptionsEnum::SHOW_ICONS ] ?? null,
			false
		);

		$this->showELearningIcon = new BoolOption(
			DetailOptionsEnum::SHOW_E_LEARNING_ICON,
			'E-learning icoon',
			"Moet er een icoon worden getoond voor e-learning?",
			$data[ DetailOptionsEnum::SHOW_E_LEARNING_ICON ] ?? null,
			false
		);

		$this->showLabelsDayPart = new BoolOption(
			OverviewOptionsEnum::SHOW_LABELS_DAY_PART,
			'Labels dagdelen',
			"Moeten er labels van dagdelen worden getoond?",
			$data[ OverviewOptionsEnum::SHOW_LABELS_DAY_PART ] ?? null,
			false
		);

		$this->includeELearningDayParts = new BoolOption(
			DetailOptionsEnum::INCLUDE_E_LEARNING_DAY_PARTS,
			'Toon e-learning dagdelen',
			'Toon e-learning dagdelen in de lijst met dagdelen',
			$data[ DetailOptionsEnum::INCLUDE_E_LEARNING_DAY_PARTS ] ?? null,
			false
		);

		$this->showDescription = new BoolOption(
			DetailOptionsEnum::SHOW_DESCRIPTION,
			'Omschrijving',
			"Moet er een omschrijving worden getoond?",
			$data[ DetailOptionsEnum::SHOW_DESCRIPTION ] ?? null,
			true
		);

		$layout = [
			new OptionGroup(
				null,
				'Detailpagina',
				'',
				[
					$this->selectedDetailPage,
					$this->overriddenDetailPage,
					$this->courseNotFoundPage,
				]
			),
			new OptionCluster(
				'Zichtbare Labels',
				'Welke labels moeten zichtbaar zijn bij de cursus',
				[
					'Soob'                                            => $this->showSoobLabel,
					'Code 95'                                         => $this->showCode95Label,
					'E-Learning'                                      => $this->showELearningIcon,
					'Labels'                                          => $this->showLabels,
					'Dagdeel aantal'                                  => $this->showDayPartCount,
					'Niveau cursus'                                   => $this->showLevelCourse,
					'Beschikbare plaatsen'                            => $this->showAvailability,
					'Start garantie'                                  => $this->showStartGuaranteeLabel,
					'Geld terug garantie'                             => $this->showMoneyBackLabel,
					'Financiële toelichting (Betalings instellingen)' => $this->showFinancialInfo,
					'Prijs'                                           => $this->showPrice
				]
			),
			$this->showDescription,
			$this->showPriceWithAndWithoutTax,
			$this->showIcons,
			new OptionGroup(
				null,
				'Dagdelen',
				'Opties voor de dagdelen lijst op de detail pagina',
				[
					$this->showDayPartList,
					$this->showELearningDayPart,
					$this->showLocationDayPart,
					$this->showDescriptionDayPart,
					$this->includeELearningDayParts,
					$this->showLabelsDayPart,
				]
			),
		];

		parent::__construct( $index, self::NAME, self::DESCRIPTION, $layout );
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showSoobLabel(): BoolOption {
		return $this->showSoobLabel;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showCode95Label(): BoolOption {
		return $this->showCode95Label;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showLabels(): BoolOption {
		return $this->showLabels;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showDayPartCount(): BoolOption {
		return $this->showDayPartCount;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showDayPartList(): BoolOption {
		return $this->showDayPartList;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showLocationDayPart(): BoolOption {
		return $this->showLocationDayPart;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showELearningDayPart(): BoolOption {
		return $this->showELearningDayPart;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showLevelCourse(): BoolOption {
		return $this->showLevelCourse;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showDescriptionDayPart(): BoolOption {
		return $this->showDescriptionDayPart;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showAvailability(): BoolOption {
		return $this->showAvailability;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showStartGuaranteeLabel(): BoolOption {
		return $this->showStartGuaranteeLabel;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showMoneyBackLabel(): BoolOption {
		return $this->showMoneyBackLabel;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showFinancialInfo(): BoolOption {
		return $this->showFinancialInfo;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showPrice(): BoolOption {
		return $this->showPrice;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showPriceWithAndWithoutTax(): BoolOption {
		return $this->showPriceWithAndWithoutTax;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showIcons(): BoolOption {
		return $this->showIcons;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function includeELearningDayParts(): BoolOption {
		return $this->includeELearningDayParts;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showELearningIcon(): BoolOption {
		return $this->showELearningIcon;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showDescription(): BoolOption {
		return $this->showDescription;
	}

	/**
	 * @return BoolOption<bool>
	 */
	public function showLabelsDayPart(): BoolOption {
		return $this->showLabelsDayPart;
	}

	/**
	 * @return PageOption<int>
	 */
	public function selectedDetailPage(): PageOption {
		return $this->selectedDetailPage;
	}

	/**
	 * @return PageOption<int>
	 */
	public function overriddenDetailPage(): PageOption {
		return $this->overriddenDetailPage;
	}

	public function courseNotFoundPage(): PageOption {
		return $this->courseNotFoundPage;
	}

	public static function componentRegistryConstruct( ComponentRegistry $registry ) {
		return $registry->getComponent(CourseOptions::class)->detailOptions();
	}
}