<?php
/**
 * Event Schema Type — guided field definitions.
 *
 * Server-authoritative form metadata. Emission remains gated by readiness.
 *
 * @package SEOvaultSEO\Schema\Types
 */

namespace SEOvaultSEO\Schema\Types;

use SEOvaultSEO\Schema\SchemaBase;

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

class Event extends SchemaBase {

	public function schema_data() {
		return array(
			'title'   => 'Event',
			'type'    => 'Event',
			'show_on' => array(
				'rules'        => array( 'post|post' ),
				'specific'     => array(),
				'specificText' => array(),
			),
			'fields'  => $this->parse_fields( $this->get() ),
		);
	}

	public function get() {
		return apply_filters(
			'seovaultseo_schema_type_event',
			array(
				array(
					'id'      => 'schema_name',
					'label'   => __( 'Schema Title', 'seovault-ai' ),
					'show'    => true,
					'default' => true,
					'type'    => 'Title',
					'std'     => 'Event',
				),
				array(
					'id'       => '@id',
					'type'     => 'Hidden',
					'std'      => '%current.url%#event',
					'required' => true,
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'       => 'name',
					'label'    => __( 'Event Name', 'seovault-ai' ),
					'desc'     => __( 'The official name of the event as it appears on this page.', 'seovault-ai' ),
					'required' => true,
					'std'      => '',
					'type'     => 'Text',
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'      => 'description',
					'label'   => __( 'Description', 'seovault-ai' ),
					'desc'    => __( 'Optional summary of what attendees should expect.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Textarea',
				),
				array(
					'id'       => 'startDate',
					'label'    => __( 'Start Date', 'seovault-ai' ),
					'desc'     => __( 'When the event starts. Use the local date and time for the venue.', 'seovault-ai' ),
					'type'     => 'DateTime',
					'required' => true,
					'default'  => true,
					'show'     => true,
					'std'      => '',
				),
				array(
					'id'      => 'endDate',
					'label'   => __( 'End Date', 'seovault-ai' ),
					'desc'    => __( 'Optional. If set, must be a valid date and must not be in the past when publishing.', 'seovault-ai' ),
					'type'    => 'DateTime',
					'default' => true,
					'show'    => true,
					'std'     => '',
				),
				array(
					'id'      => 'eventStatus',
					'label'   => __( 'Event Status', 'seovault-ai' ),
					'desc'    => __( 'Whether the event is scheduled, cancelled, postponed, or moved online.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Enum',
					'options' => array(
						''                                           => __( '— Select —', 'seovault-ai' ),
						'https://schema.org/EventScheduled'          => __( 'Scheduled', 'seovault-ai' ),
						'https://schema.org/EventCancelled'          => __( 'Cancelled', 'seovault-ai' ),
						'https://schema.org/EventPostponed'          => __( 'Postponed', 'seovault-ai' ),
						'https://schema.org/EventRescheduled'        => __( 'Rescheduled', 'seovault-ai' ),
						'https://schema.org/EventMovedOnline'        => __( 'Moved online', 'seovault-ai' ),
					),
				),
				array(
					'id'      => 'eventAttendanceMode',
					'label'   => __( 'Attendance Mode', 'seovault-ai' ),
					'desc'    => __( 'Offline, online, or mixed attendance.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Enum',
					'options' => array(
						''                                                 => __( '— Select —', 'seovault-ai' ),
						'https://schema.org/OfflineEventAttendanceMode'    => __( 'Offline (in person)', 'seovault-ai' ),
						'https://schema.org/OnlineEventAttendanceMode'     => __( 'Online', 'seovault-ai' ),
						'https://schema.org/MixedEventAttendanceMode'      => __( 'Mixed (online + offline)', 'seovault-ai' ),
					),
				),
				array(
					'id'       => 'location',
					'label'    => __( 'Location', 'seovault-ai' ),
					'desc'     => __( 'Required for schema. Use Place with a venue name or address, or VirtualLocation with a URL for online events.', 'seovault-ai' ),
					'type'     => 'Group',
					'required' => true,
					'default'  => true,
					'show'     => true,
					'fields'   => array(
						array(
							'id'      => '@type',
							'label'   => __( 'Location type', 'seovault-ai' ),
							'desc'    => __( 'Place for a physical venue; VirtualLocation for an online URL.', 'seovault-ai' ),
							'type'    => 'Enum',
							'std'     => '',
							'default' => true,
							'show'    => true,
							'options' => array(
								''                 => __( '— Select —', 'seovault-ai' ),
								'Place'            => __( 'Place (physical)', 'seovault-ai' ),
								'VirtualLocation'  => __( 'VirtualLocation (online)', 'seovault-ai' ),
							),
						),
						array(
							'id'      => 'name',
							'label'   => __( 'Venue Name', 'seovault-ai' ),
							'desc'    => __( 'Name of the physical venue (for Place).', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Text',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'address',
							'label'   => __( 'Address', 'seovault-ai' ),
							'desc'    => __( 'Street or postal address for a physical venue (for Place).', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Text',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'url',
							'label'   => __( 'Online event URL', 'seovault-ai' ),
							'desc'    => __( 'Join URL for VirtualLocation / online attendance.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'URL',
							'default' => true,
							'show'    => true,
						),
					),
				),
				array(
					'id'      => 'image',
					'label'   => __( 'Image', 'seovault-ai' ),
					'desc'    => __( 'Optional event image. Recommended for richer results.', 'seovault-ai' ),
					'std'     => '',
					'type'    => 'Image',
					'default' => true,
					'show'    => true,
				),
				array(
					'id'      => 'offers',
					'label'   => __( 'Offers', 'seovault-ai' ),
					'desc'    => __( 'Optional ticket or registration offer. Leave price blank if free or unknown — do not invent prices.', 'seovault-ai' ),
					'type'    => 'Group',
					'default' => true,
					'show'    => true,
					'fields'  => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'Offer',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'price',
							'label'   => __( 'Price', 'seovault-ai' ),
							'desc'    => __( 'Numeric price only when a real ticket price exists.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Number',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'priceCurrency',
							'label'   => __( 'Currency', 'seovault-ai' ),
							'desc'    => __( 'ISO 4217 currency code (for example USD).', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Text',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'availability',
							'label'   => __( 'Availability', 'seovault-ai' ),
							'desc'    => __( 'Ticket availability status.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Enum',
							'default' => true,
							'show'    => true,
							'options' => array(
								''                              => __( '— Select —', 'seovault-ai' ),
								'https://schema.org/InStock'    => __( 'In stock', 'seovault-ai' ),
								'https://schema.org/SoldOut'    => __( 'Sold out', 'seovault-ai' ),
								'https://schema.org/PreOrder'   => __( 'Pre-order', 'seovault-ai' ),
							),
						),
						array(
							'id'      => 'url',
							'label'   => __( 'Ticket URL', 'seovault-ai' ),
							'desc'    => __( 'Link where tickets or registration are available.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'URL',
							'default' => true,
							'show'    => true,
						),
					),
				),
			)
		);
	}
}
