<?php
/**
 * JobPosting 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 JobPosting extends SchemaBase {

	public function schema_data() {
		return array(
			'title'   => 'JobPosting',
			'type'    => 'JobPosting',
			'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_jobposting',
			array(
				array(
					'id'      => 'schema_name',
					'label'   => __( 'Schema Title', 'seovault-ai' ),
					'show'    => true,
					'default' => true,
					'type'    => 'Title',
					'std'     => 'JobPosting',
				),
				array(
					'id'       => '@id',
					'type'     => 'Hidden',
					'std'      => '%current.url%#jobposting',
					'required' => true,
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'       => 'title',
					'label'    => __( 'Job Title', 'seovault-ai' ),
					'desc'     => __( 'The job title as advertised on this page.', 'seovault-ai' ),
					'required' => true,
					'std'      => '',
					'type'     => 'Text',
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'       => 'description',
					'label'    => __( 'Description', 'seovault-ai' ),
					'desc'     => __( 'Full job description visible to applicants. Required for schema readiness.', 'seovault-ai' ),
					'required' => true,
					'default'  => true,
					'show'     => true,
					'std'      => '',
					'type'     => 'Textarea',
				),
				array(
					'id'       => 'datePosted',
					'label'    => __( 'Date Posted', 'seovault-ai' ),
					'desc'     => __( 'When this listing was published. Enter the real posting date — do not invent one.', 'seovault-ai' ),
					'type'     => 'DateTime',
					'required' => true,
					'default'  => true,
					'show'     => true,
					'std'      => '',
				),
				array(
					'id'      => 'validThrough',
					'label'   => __( 'Valid Through', 'seovault-ai' ),
					'desc'    => __( 'Optional application deadline. Expired jobs are not eligible for schema emission.', 'seovault-ai' ),
					'type'    => 'DateTime',
					'default' => true,
					'show'    => true,
					'std'     => '',
				),
				array(
					'id'      => 'employmentType',
					'label'   => __( 'Employment Type', 'seovault-ai' ),
					'desc'    => __( 'Full-time, part-time, contract, temporary, intern, or volunteer.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Enum',
					'options' => array(
						''           => __( '— Select —', 'seovault-ai' ),
						'FULL_TIME'  => __( 'Full-time', 'seovault-ai' ),
						'PART_TIME'  => __( 'Part-time', 'seovault-ai' ),
						'CONTRACTOR' => __( 'Contractor', 'seovault-ai' ),
						'TEMPORARY'  => __( 'Temporary', 'seovault-ai' ),
						'INTERN'     => __( 'Intern', 'seovault-ai' ),
						'VOLUNTEER'  => __( 'Volunteer', 'seovault-ai' ),
						'PER_DIEM'   => __( 'Per diem', 'seovault-ai' ),
						'OTHER'      => __( 'Other', 'seovault-ai' ),
					),
				),
				array(
					'id'       => 'hiringOrganization',
					'label'    => __( 'Hiring Organization', 'seovault-ai' ),
					'desc'     => __( 'The employer. An organization name is required.', 'seovault-ai' ),
					'type'     => 'Group',
					'required' => true,
					'default'  => true,
					'show'     => true,
					'fields'   => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'Organization',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'       => 'name',
							'label'    => __( 'Organization Name', 'seovault-ai' ),
							'desc'     => __( 'Legal or brand name of the hiring organization.', 'seovault-ai' ),
							'required' => true,
							'std'      => '',
							'type'     => 'Text',
							'default'  => true,
							'show'     => true,
						),
						array(
							'id'      => 'sameAs',
							'label'   => __( 'Website', 'seovault-ai' ),
							'desc'    => __( 'Optional employer website URL.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'URL',
							'default' => true,
							'show'    => true,
						),
					),
				),
				array(
					'id'      => 'jobLocationType',
					'label'   => __( 'Remote work', 'seovault-ai' ),
					'desc'    => __( 'Set TELECOMMUTE for fully remote roles. Otherwise provide a physical job location below. Schema readiness requires location or remote mode.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Enum',
					'options' => array(
						''            => __( 'On-site / hybrid (use location below)', 'seovault-ai' ),
						'TELECOMMUTE' => __( 'TELECOMMUTE (fully remote)', 'seovault-ai' ),
					),
				),
				array(
					'id'      => 'jobLocation',
					'label'   => __( 'Job Location', 'seovault-ai' ),
					'desc'    => __( 'Physical workplace address. Required unless remote (TELECOMMUTE) is selected above.', 'seovault-ai' ),
					'type'    => 'Group',
					'default' => true,
					'show'    => true,
					'fields'  => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'Place',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'address',
							'label'   => __( 'Address', 'seovault-ai' ),
							'type'    => 'Group',
							'default' => true,
							'show'    => true,
							'fields'  => array(
								array(
									'id'      => '@type',
									'type'    => 'Hidden',
									'std'     => 'PostalAddress',
									'default' => true,
									'show'    => true,
								),
								array(
									'id'      => 'streetAddress',
									'label'   => __( 'Street address', 'seovault-ai' ),
									'desc'    => __( 'Optional street line.', 'seovault-ai' ),
									'std'     => '',
									'type'    => 'Text',
									'default' => true,
									'show'    => true,
								),
								array(
									'id'      => 'addressLocality',
									'label'   => __( 'City', 'seovault-ai' ),
									'desc'    => __( 'City or locality.', 'seovault-ai' ),
									'std'     => '',
									'type'    => 'Text',
									'default' => true,
									'show'    => true,
								),
								array(
									'id'      => 'addressRegion',
									'label'   => __( 'Region', 'seovault-ai' ),
									'desc'    => __( 'State, province, or region.', 'seovault-ai' ),
									'std'     => '',
									'type'    => 'Text',
									'default' => true,
									'show'    => true,
								),
								array(
									'id'      => 'postalCode',
									'label'   => __( 'Postal code', 'seovault-ai' ),
									'desc'    => __( 'Optional postal or ZIP code.', 'seovault-ai' ),
									'std'     => '',
									'type'    => 'Text',
									'default' => true,
									'show'    => true,
								),
								array(
									'id'      => 'addressCountry',
									'label'   => __( 'Country', 'seovault-ai' ),
									'desc'    => __( 'Country name or ISO country code.', 'seovault-ai' ),
									'std'     => '',
									'type'    => 'Text',
									'default' => true,
									'show'    => true,
								),
							),
						),
					),
				),
			)
		);
	}
}
