<?php

namespace Limb_Chatbot\Includes\Services\Channel_Events;

/**
 * Central registry of all channel event type slugs.
 *
 * This is the single source of truth for every typed event that can flow
 * through the channel-event queue, regardless of which feature produces or
 * consumes it.  New features should register their types here so the whole
 * system stays discoverable in one place.
 *
 * Namespacing convention: {feature}.{action}
 *   admin.*       — events consumed by the WordPress admin area
 *
 * @package Limb_Chatbot
 * @subpackage Services\Channel_Events
 * @since 2.1.0
 */
final class Channel_Event_Types {

	// ── Admin events ─────────────────────────────────────────────────────────

	/**
	 * A new chat was started by a visitor (any chatbot).
	 */
	const ADMIN_NEW_CHAT = 'admin.new_chat';

	/**
	 * A new lead was captured via a chatbot form.
	 */
	const ADMIN_NEW_LEAD = 'admin.new_lead';

	/**
	 * A new chatbot user (visitor) was created/registered on the site.
	 */
	const ADMIN_NEW_CHATBOT_USER = 'admin.new_chatbot_user';

	/**
	 * A new chatbot form entry was submitted, but no new lead was created
	 * (e.g. no configured lead fields were captured).
	 */
	const ADMIN_NEW_FORM_ENTRY = 'admin.new_form_entry';

	// ─────────────────────────────────────────────────────────────────────────

	/**
	 * Human-readable labels, keyed by event type slug.
	 *
	 * @var array<string,string>
	 */
	private const LABELS = [
		self::ADMIN_NEW_CHAT            => 'New Chat',
		self::ADMIN_NEW_LEAD            => 'New Contact',
		self::ADMIN_NEW_CHATBOT_USER    => 'New Visitor',
		self::ADMIN_NEW_FORM_ENTRY     => 'New Form Entry',
	];

	/**
	 * No public instantiation — this is a pure constants class.
	 */
	private function __construct() {
	}

	/**
	 * Return the human-readable label for an event type slug.
	 *
	 * Falls back to the raw slug when no label is registered.
	 *
	 * @param  string  $type
	 *
	 * @return string
	 */
	public static function get_label( string $type ): string {
		return self::LABELS[ $type ] ?? $type;
	}

	/**
	 * Return all registered event type slugs.
	 *
	 * @return string[]
	 */
	public static function all(): array {
		return array_keys( self::LABELS );
	}
}
