<?php

namespace GOS\GravityOps\Core\SuiteCore;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Suite catalog of GravityOps products and their variants.
 */
class SuiteCatalog {

	/**
	 * Catalog items keyed by slug.
	 *
	 * @var array<string,array<string,mixed>>
	 */
	private array $items;

	/**
	 * Constructor method for initializing the class.
	 *
	 * @return void
	 */
	public function __construct() {
		$this->items = $this->build_items();
	}

	/**
	 * Return all catalog items.
	 *
	 * @return array<int,array<string,mixed>>
	 */
	public function all(): array {
		return array_values( $this->items );
	}

	/**
	 * Find a catalog item by slug.
	 *
	 * @param string $slug Item slug.
	 * @return array<string,mixed>|null
	 */
	public function find( string $slug ): ?array {
		return $this->items[ $slug ] ?? null;
	}

	/**
	 * Build the catalog items.
	 *
	 * @return array<string,array<string,mixed>>
	 */
	private function build_items(): array {
		return [
			'integrate-asana-with-gravity-forms'          => [
				'slug'            => 'integrate-asana-with-gravity-forms',
				'type'            => 'plugin',
				'name'            => 'Integrate Asana with Gravity Forms',
				'description'     => 'Turn form submissions into Asana tasks instantly.',
				'marketing_url'   => 'https://brightleafdigital.io/asana-gravity-forms/',
				'docs_url'        => 'https://brightleafdigital.io/asana-gravity-forms/#docs',
				'changelog_url'   => 'https://brightleafdigital.io/docs/changelog/',
				'is_free'         => false,
				'icon_filename'   => 'iawgf-icon.svg',
				'premium_file'    => 'integrate-asana-with-gravity-forms-premium/integrate-asana-with-gravity-forms.php',
				'free_file'       => 'integrate-asana-with-gravity-forms/integrate-asana-with-gravity-forms.php',
				'freemius_helper' => 'iawgf_fs',
				'wporg_slug'      => 'integrate-asana-with-gravity-forms',
			],
			'mass_email_notifications_for_gf'             => [
				'slug'            => 'mass_email_notifications_for_gf',
				'type'            => 'plugin',
				'name'            => 'Mass Email Notifications',
				'description'     => 'Send bulk emails to Gravity Forms entries.',
				'marketing_url'   => 'https://brightleafdigital.io/mass-email-notifications-for-gravity-forms/',
				'docs_url'        => 'https://brightleafdigital.io/mass-email-notifications-for-gravity-forms/#docs',
				'changelog_url'   => 'https://brightleafdigital.io/docs/changelog-2/',
				'is_free'         => false,
				'icon_filename'   => 'menfgf-icon.svg',
				'premium_file'    => 'mass-email-notifications-for-gravity-forms-premium/mass-email-notifications-for-gf.php',
				'free_file'       => 'mass-email-notifications-for-gravity-forms/mass-email-notifications-for-gf.php',
				'freemius_helper' => 'menfgf_fs',
				'wporg_slug'      => 'mass-email-notifications-for-gravity-forms',
			],
			'folders-4-gravity'                           => [
				'slug'            => 'folders-4-gravity',
				'type'            => 'plugin',
				'name'            => 'Folders 4 Gravity',
				'description'     => 'Organize Gravity Forms and GravityView with folders.',
				'marketing_url'   => 'https://brightleafdigital.io/folders-4-gravity/',
				'docs_url'        => 'https://brightleafdigital.io/folders-4-gravity/#docs',
				'changelog_url'   => 'https://brightleafdigital.io/docs/changelog-7/',
				'is_free'         => true,
				'icon_filename'   => 'f4g-icon.svg',
				'premium_file'    => '',
				'free_file'       => 'folders-4-gravity/folders-4-gravity.php',
				'freemius_helper' => '',
				'wporg_slug'      => 'folders-4-gravity',
			],
			'gravityops_search'                           => [
				'slug'            => 'gravityops_search',
				'type'            => 'plugin',
				'name'            => 'GravityOps Search',
				'description'     => 'Supercharge search across Gravity Forms entries.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-search/',
				'docs_url'        => 'https://brightleafdigital.io/gravityops-search/#docs',
				'changelog_url'   => 'https://brightleafdigital.io/docs/changelog-6/',
				'is_free'         => true,
				'icon_filename'   => 'search-icon.svg',
				'premium_file'    => '',
				'free_file'       => 'gravityops-search/gravityops-search.php',
				'freemius_helper' => '',
				'wporg_slug'      => 'gravityops-search',
			],
			'gravity_ops_global_variables'                => [
				'slug'            => 'gravity_ops_global_variables',
				'type'            => 'plugin',
				'name'            => 'Global Variables',
				'description'     => 'Create shared variables for GravityMath formulas.',
				'marketing_url'   => 'https://brightleafdigital.io/global-variables-for-gravity-math/',
				'docs_url'        => 'https://brightleafdigital.io/global-variables-for-gravity-math/#docs',
				'changelog_url'   => 'https://brightleafdigital.io/docs/changelog-5/',
				'is_free'         => false,
				'icon_filename'   => 'gv4gm-icon.svg',
				'premium_file'    => 'global-variables-for-gravity-math-premium/global-variables-for-gravity-math.php',
				'free_file'       => '',
				'freemius_helper' => 'gvfgm_fs',
				'wporg_slug'      => '',
			],
			'Recurring_Form_Submissions_For_Gravity_Form' => [
				'slug'            => 'Recurring_Form_Submissions_For_Gravity_Form',
				'type'            => 'plugin',
				'name'            => 'Recurring Form Submissions',
				'description'     => 'Schedule recurring Gravity Forms submissions.',
				'marketing_url'   => 'https://brightleafdigital.io/recurring-form-submissions-for-gravity-forms/',
				'docs_url'        => 'https://brightleafdigital.io/recurring-form-submissions-for-gravity-forms/#docs',
				'changelog_url'   => 'https://brightleafdigital.io/docs/changelog-4/',
				'is_free'         => false,
				'icon_filename'   => 'rfsfgf-icon.svg',
				'premium_file'    => 'recurring-form-submissions-for-gravity-forms-premium/recurring-form-submissions-for-gravity-form.php',
				'free_file'       => '',
				'freemius_helper' => 'rfsfgf_fs',
				'wporg_slug'      => '',
			],
			'kanban-view-for-gravity-view'                => [
				'slug'            => 'kanban-view-for-gravity-view',
				'type'            => 'plugin',
				'name'            => 'Kanban View for GravityView',
				'description'     => 'Turn GravityView into a kanban project board.',
				'marketing_url'   => 'https://brightleafdigital.io/turn-gravityview-into-a-kanban-project-board/',
				'docs_url'        => 'https://brightleafdigital.io/turn-gravityview-into-a-kanban-project-board/#docs',
				'changelog_url'   => 'https://brightleafdigital.io/docs/changelog-3/',
				'is_free'         => false,
				'icon_filename'   => 'kv4gv-icon.svg',
				'premium_file'    => 'kanban-view-for-gravity-view-premium/kanban-view-for-gv.php',
				'free_file'       => '',
				'freemius_helper' => 'kvfgv_fs',
				'wporg_slug'      => '',
			],

			/*
			'gravityops-forum'                            => [
				'slug'            => 'gravityops-forum',
				'type'            => 'plugin',
				'name'            => 'GravityOps Forum',
				'description'     => 'Turn Gravity Forms entries into a functional forum.',
				'marketing_url'   => 'https://brightleafdigital.io/gravityops-forum/', // todo
				'docs_url'        => 'https://brightleafdigital.io/gravityops-forum/#docs', // todo
				'changelog_url'   => 'https://brightleafdigital.io/docs/changelog-8/', // todo
				'is_free'         => false,
				'icon_filename'   => 'ops-icon.svg', // todo
				'premium_file'    => 'gravityops-forum/gravityops-forum.php',
				'free_file'       => '',
				'freemius_helper' => 'gravityops_forum_fs',
				'wporg_slug'      => '',
			],
			*/
		];
	}
}
