<?php
/**
 * Costudio_Article_Types
 *
 * Canonical article type definitions and legacy normalization.
 *
 * @package Contentosapp_Studio
 * @since   3.2.0
 */

defined( 'ABSPATH' ) || exit;

class Costudio_Article_Types {

	const PILLAR     = 'pillar';
	const SATELLITE  = 'satellite';
	const COMPARISON = 'comparison';
	const NEWS       = 'news';
	const UPDATE     = 'update';

	/**
	 * Normalize a legacy or raw article type string into its canonical slug.
	 */
	public static function normalize( string $value ): string {
		$value = strtolower( trim( $value ) );
		switch ( $value ) {
			case 'pilar':
				return self::PILLAR;
			case 'satélite':
			case 'satelite':
				return self::SATELLITE;
			case 'comparativo':
				return self::COMPARISON;
			case 'notícia':
			case 'noticia':
				return self::NEWS;
			case 'atualização':
			case 'atualizacao':
				return self::UPDATE;
			default:
				if ( in_array( $value, [ self::PILLAR, self::SATELLITE, self::COMPARISON, self::NEWS, self::UPDATE ], true ) ) {
					return $value;
				}
				return self::SATELLITE; // Fallback
		}
	}

	/**
	 * Get the translated UI labels for the canonical types.
	 */
	public static function get_labels(): array {
		return [
			self::PILLAR     => __( 'Pillar', 'contentosapp-studio' ),
			self::SATELLITE  => __( 'Satellite', 'contentosapp-studio' ),
			self::COMPARISON => __( 'Comparison', 'contentosapp-studio' ),
			self::NEWS       => __( 'News', 'contentosapp-studio' ),
			self::UPDATE     => __( 'Update', 'contentosapp-studio' ),
		];
	}
}
