<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * Table - Schedule
 *
 * @package AxcelersBlocks
 */

$axcelersblocks_schedule_responsive = static function ( $desktop, $tablet = null, $mobile = null ) {
	return array(
		'desktop' => $desktop,
		'tablet'  => null === $tablet ? $desktop : $tablet,
		'mobile'  => null === $mobile ? ( null === $tablet ? $desktop : $tablet ) : $mobile,
	);
};

$axcelersblocks_schedule_spacing = static function ( $top, $right, $bottom, $left, $linked = false ) {
	return array(
		'desktop' => array(
			'top'              => $top,
			'right'            => $right,
			'bottom'           => $bottom,
			'left'             => $left,
			'isVHActive'       => false,
			'isSidesAllActive' => $linked,
		),
		'tablet'  => array(
			'top'              => $top,
			'right'            => $right,
			'bottom'           => $bottom,
			'left'             => $left,
			'isVHActive'       => false,
			'isSidesAllActive' => $linked,
		),
		'mobile'  => array(
			'top'              => $top,
			'right'            => $right,
			'bottom'           => $bottom,
			'left'             => $left,
			'isVHActive'       => false,
			'isSidesAllActive' => $linked,
		),
	);
};

$axcelersblocks_schedule_border = static function ( $sides ) {
	return array(
		'desktop' => array(
			'width'        => '',
			'style'        => '',
			'color'        => '',
			'sides'        => $sides,
			'isLinkActive' => false,
		),
		'tablet'  => array(
			'width'        => '',
			'style'        => '',
			'color'        => '',
			'sides'        => $sides,
			'isLinkActive' => false,
		),
		'mobile'  => array(
			'width'        => '',
			'style'        => '',
			'color'        => '',
			'sides'        => $sides,
			'isLinkActive' => false,
		),
	);
};

$axcelersblocks_schedule_cell_border = $axcelersblocks_schedule_border(
	array(
		'right'  => array(
			'width' => '1px',
			'style' => 'solid',
			'color' => '#E5E7EB',
		),
		'bottom' => array(
			'width' => '1px',
			'style' => 'solid',
			'color' => '#E5E7EB',
		),
	)
);

$axcelersblocks_schedule_zero_margin = $axcelersblocks_schedule_spacing( '0px', '0px', '0px', '0px', true );

$axcelersblocks_schedule_bodycopy = static function ( $class, $content, $options = array() ) use ( $axcelersblocks_schedule_responsive, $axcelersblocks_schedule_zero_margin ) {
	$attrs = array_merge(
		array(
			'content'     => $content,
			'tagName'     => 'p',
			'uniqueClass' => $class,
			'margin'      => $axcelersblocks_schedule_zero_margin,
			'fontSize'    => $axcelersblocks_schedule_responsive( '15px', '15px', '14px' ),
			'lineHeight'  => $axcelersblocks_schedule_responsive( '1.5' ),
			'fontWeight'  => $axcelersblocks_schedule_responsive( '400' ),
			'textColor'   => $axcelersblocks_schedule_responsive( '#475467' ),
		),
		$options
	);

	return '<!-- wp:axcelersblocks/bodycopy ' . wp_json_encode( $attrs ) . ' /-->';
};

$axcelersblocks_schedule_cell = static function ( $class, $content, $options = array() ) use ( $axcelersblocks_schedule_responsive, $axcelersblocks_schedule_spacing, $axcelersblocks_schedule_cell_border, $axcelersblocks_schedule_bodycopy ) {
	$is_header = ! empty( $options['header'] );
	$is_time   = ! empty( $options['time'] );

	$cell_attrs = array(
		'uniqueClass'     => $class,
		'tagName'         => $is_header ? 'th' : 'td',
		'padding'         => $options['padding'] ?? $axcelersblocks_schedule_spacing( '16px', '18px', '16px', '18px' ),
		'backgroundColor' => $options['backgroundColor'] ?? $axcelersblocks_schedule_responsive( '#FFFFFF' ),
		'border'          => $axcelersblocks_schedule_cell_border,
		'verticalAlign'   => $axcelersblocks_schedule_responsive( 'middle' ),
		'textAlign'       => $options['textAlign'] ?? $axcelersblocks_schedule_responsive( $is_time ? 'left' : 'left' ),
	);

	if ( $is_header ) {
		$cell_attrs['scope'] = 'col';
	}

	$text_attrs = array(
		'fontWeight' => $axcelersblocks_schedule_responsive( $options['fontWeight'] ?? ( $is_header || $is_time ? '700' : '500' ) ),
		'textColor'  => $axcelersblocks_schedule_responsive( $options['textColor'] ?? ( $is_header ? '#FFFFFF' : '#344054' ) ),
		'fontSize'   => $axcelersblocks_schedule_responsive( $options['fontSize'] ?? ( $is_header ? '14px' : '15px' ), $options['fontSize'] ?? ( $is_header ? '14px' : '15px' ), $options['mobileFontSize'] ?? '14px' ),
		'lineHeight' => $axcelersblocks_schedule_responsive( $options['lineHeight'] ?? '1.45' ),
	);

	return '<!-- wp:axcelersblocks/table-cell ' . wp_json_encode( $cell_attrs ) . ' -->' .
		$axcelersblocks_schedule_bodycopy( $class . '-text', $content, $text_attrs ) .
	'<!-- /wp:axcelersblocks/table-cell -->';
};

$axcelersblocks_schedule_row = static function ( $class, $cells, $options = array() ) use ( $axcelersblocks_schedule_responsive ) {
	$attrs = array(
		'uniqueClass' => $class,
	);

	if ( ! empty( $options['backgroundColor'] ) ) {
		$attrs['backgroundColor'] = $axcelersblocks_schedule_responsive( $options['backgroundColor'] );
	}

	return '<!-- wp:axcelersblocks/table-row ' . wp_json_encode( $attrs ) . ' -->' .
		implode( '', $cells ) .
	'<!-- /wp:axcelersblocks/table-row -->';
};

$axcelersblocks_schedule_section = static function ( $class, $tag_name, $rows ) {
	return '<!-- wp:axcelersblocks/table-section {"uniqueClass":"' . esc_attr( $class ) . '","tagName":"' . esc_attr( $tag_name ) . '"} -->' .
		implode( '', $rows ) .
	'<!-- /wp:axcelersblocks/table-section -->';
};

return array(
	'title'         => __( 'AXB: Table - Schedule', 'axcelersblocks' ),
	'description'   => __( 'A polished schedule table for events, courses, agendas, and operations.', 'axcelersblocks' ),
	'categories'    => array( 'axcelersblocks-table' ),
	'keywords'      => array( 'table', 'schedule', 'agenda', 'event', 'course', 'timeline', 'axcelersblocks' ),
	'viewportWidth' => 1200,
	'content'       =>

	'<!-- wp:axcelersblocks/box {"tagName":"section","align":"full","uniqueClass":"axb-table-03","padding":{"desktop":{"top":"88px","right":"24px","bottom":"88px","left":"24px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"72px","right":"20px","bottom":"72px","left":"20px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"56px","right":"16px","bottom":"56px","left":"16px","isVHActive":false,"isSidesAllActive":true}},"backgroundColor":{"desktop":"#F9FAFB","tablet":"#F9FAFB","mobile":"#F9FAFB"}} -->' .

		'<!-- wp:axcelersblocks/box {"uniqueClass":"axb-table-03__container","maxWidth":{"desktop":"1040px","tablet":"1040px","mobile":"1040px"},"margin":{"desktop":{"top":"","right":"auto","bottom":"","left":"auto","isVHActive":false,"isSidesAllActive":false},"tablet":{"top":"","right":"auto","bottom":"","left":"auto","isVHActive":false,"isSidesAllActive":false},"mobile":{"top":"","right":"auto","bottom":"","left":"auto","isVHActive":false,"isSidesAllActive":false}},"padding":{"desktop":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true}},"display":{"desktop":"flex","tablet":"flex","mobile":"flex"},"flexDirection":{"desktop":"column","tablet":"column","mobile":"column"},"rowGap":{"desktop":"26px","tablet":"24px","mobile":"20px"}} -->' .

			'<!-- wp:axcelersblocks/box {"uniqueClass":"axb-table-03__intro","maxWidth":{"desktop":"720px","tablet":"720px","mobile":"100%"},"padding":{"desktop":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true}},"display":{"desktop":"flex","tablet":"flex","mobile":"flex"},"flexDirection":{"desktop":"column","tablet":"column","mobile":"column"},"rowGap":{"desktop":"12px","tablet":"12px","mobile":"10px"}} -->' .
				'<!-- wp:axcelersblocks/heading {"content":"Event schedule","tagName":"h2","textAlign":{"desktop":"left","tablet":"left","mobile":"left"},"fontSize":{"desktop":"36px","tablet":"30px","mobile":"26px"},"lineHeight":{"desktop":"1.16","tablet":"1.2","mobile":"1.22"},"fontWeight":{"desktop":"700","tablet":"700","mobile":"700"},"textColor":{"desktop":"#111827","tablet":"#111827","mobile":"#111827"}} /-->' .
				'<!-- wp:axcelersblocks/bodycopy {"content":"A clear agenda table for workshops, events, courses, webinars, or operations planning.","fontSize":{"desktop":"16px","tablet":"16px","mobile":"15px"},"lineHeight":{"desktop":"1.65","tablet":"1.65","mobile":"1.6"},"textColor":{"desktop":"#475467","tablet":"#475467","mobile":"#475467"},"margin":{"desktop":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true}}} /-->' .
			'<!-- /wp:axcelersblocks/box -->' .

			'<!-- wp:axcelersblocks/box {"uniqueClass":"axb-table-03__scroll","overflowX":{"desktop":"auto","tablet":"auto","mobile":"auto"},"overflowY":{"desktop":"hidden","tablet":"hidden","mobile":"hidden"},"backgroundColor":{"desktop":"#FFFFFF","tablet":"#FFFFFF","mobile":"#FFFFFF"},"borderRadius":{"desktop":{"value":"8px","corners":{},"isLinkActive":true},"tablet":{"value":"8px","corners":{},"isLinkActive":true},"mobile":{"value":"8px","corners":{},"isLinkActive":true}},"effect":{"desktop":{"boxShadow":{"xOffset":"0px","yOffset":"16px","blurRadius":"44px","spreadRadius":"-30px","color":"rgba(15,23,42,0.24)","inset":false},"transition":{"property":"","duration":"","timingFunction":"","delay":""},"filter":{"blur":"","brightness":"","contrast":"","grayscale":"","hueRotate":"","invert":"","opacity":"","saturate":"","sepia":""},"textShadow":{"xOffset":"","yOffset":"","blurRadius":"","color":""},"transform":{"translateX":"","translateY":"","translateZ":"","scaleX":"","scaleY":"","rotate":"","rotateX":"","rotateY":"","rotateZ":"","skewX":"","skewY":""},"opacity":"","visibility":""},"tablet":{"boxShadow":{"xOffset":"0px","yOffset":"12px","blurRadius":"34px","spreadRadius":"-24px","color":"rgba(15,23,42,0.22)","inset":false},"transition":{"property":"","duration":"","timingFunction":"","delay":""},"filter":{"blur":"","brightness":"","contrast":"","grayscale":"","hueRotate":"","invert":"","opacity":"","saturate":"","sepia":""},"textShadow":{"xOffset":"","yOffset":"","blurRadius":"","color":""},"transform":{"translateX":"","translateY":"","translateZ":"","scaleX":"","scaleY":"","rotate":"","rotateX":"","rotateY":"","rotateZ":"","skewX":"","skewY":""},"opacity":"","visibility":""},"mobile":{"boxShadow":{"xOffset":"0px","yOffset":"8px","blurRadius":"26px","spreadRadius":"-18px","color":"rgba(15,23,42,0.2)","inset":false},"transition":{"property":"","duration":"","timingFunction":"","delay":""},"filter":{"blur":"","brightness":"","contrast":"","grayscale":"","hueRotate":"","invert":"","opacity":"","saturate":"","sepia":""},"textShadow":{"xOffset":"","yOffset":"","blurRadius":"","color":""},"transform":{"translateX":"","translateY":"","translateZ":"","scaleX":"","scaleY":"","rotate":"","rotateX":"","rotateY":"","rotateZ":"","skewX":"","skewY":""},"opacity":"","visibility":""}},"padding":{"desktop":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"tablet":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true},"mobile":{"top":"0px","right":"0px","bottom":"0px","left":"0px","isVHActive":false,"isSidesAllActive":true}}} -->' .

				'<!-- wp:axcelersblocks/table {"uniqueClass":"axb-table-03__table","cols":[{"width":"18%","backgroundColor":"#F8FAFC"},{"width":"38%"},{"width":"24%"},{"width":"20%"}],"borderSpacing":{"desktop":"0","tablet":"0","mobile":"0"},"width":{"desktop":"100%","tablet":"100%","mobile":"100%"},"minWidth":{"desktop":"780px","tablet":"760px","mobile":"720px"},"backgroundColor":{"desktop":"#FFFFFF","tablet":"#FFFFFF","mobile":"#FFFFFF"},"border":{"desktop":{"width":"","style":"","color":"","sides":{"top":{"width":"1px","style":"solid","color":"#E5E7EB"},"left":{"width":"1px","style":"solid","color":"#E5E7EB"}},"isLinkActive":false},"tablet":{"width":"","style":"","color":"","sides":{"top":{"width":"1px","style":"solid","color":"#E5E7EB"},"left":{"width":"1px","style":"solid","color":"#E5E7EB"}},"isLinkActive":false},"mobile":{"width":"","style":"","color":"","sides":{"top":{"width":"1px","style":"solid","color":"#E5E7EB"},"left":{"width":"1px","style":"solid","color":"#E5E7EB"}},"isLinkActive":false}}} -->' .

					$axcelersblocks_schedule_section(
						'axb-table-03__head',
						'thead',
						array(
							$axcelersblocks_schedule_row(
								'axb-table-03__head-row',
								array(
									$axcelersblocks_schedule_cell( 'axb-table-03__h-time', 'Time', array( 'header' => true, 'backgroundColor' => $axcelersblocks_schedule_responsive( '#111827' ) ) ),
									$axcelersblocks_schedule_cell( 'axb-table-03__h-session', 'Session', array( 'header' => true, 'backgroundColor' => $axcelersblocks_schedule_responsive( '#111827' ) ) ),
									$axcelersblocks_schedule_cell( 'axb-table-03__h-owner', 'Owner', array( 'header' => true, 'backgroundColor' => $axcelersblocks_schedule_responsive( '#111827' ) ) ),
									$axcelersblocks_schedule_cell( 'axb-table-03__h-status', 'Status', array( 'header' => true, 'backgroundColor' => $axcelersblocks_schedule_responsive( '#111827' ) ) ),
								)
							),
						)
					) .

					$axcelersblocks_schedule_section(
						'axb-table-03__body',
						'tbody',
						array(
							$axcelersblocks_schedule_row(
								'axb-table-03__row-checkin',
								array(
									$axcelersblocks_schedule_cell( 'axb-table-03__checkin-time', '09:00', array( 'time' => true, 'backgroundColor' => $axcelersblocks_schedule_responsive( '#F8FAFC' ), 'textColor' => '#111827' ) ),
									$axcelersblocks_schedule_cell( 'axb-table-03__checkin-session', 'Registration and coffee' ),
									$axcelersblocks_schedule_cell( 'axb-table-03__checkin-owner', 'Operations team' ),
									$axcelersblocks_schedule_cell( 'axb-table-03__checkin-status', 'Open', array( 'backgroundColor' => $axcelersblocks_schedule_responsive( '#EFF6FF' ), 'textColor' => '#1D4ED8', 'fontWeight' => '700', 'textAlign' => $axcelersblocks_schedule_responsive( 'center' ) ) ),
								)
							),
							$axcelersblocks_schedule_row(
								'axb-table-03__row-keynote',
								array(
									$axcelersblocks_schedule_cell( 'axb-table-03__keynote-time', '10:00', array( 'time' => true, 'backgroundColor' => $axcelersblocks_schedule_responsive( '#F8FAFC' ), 'textColor' => '#111827' ) ),
									$axcelersblocks_schedule_cell( 'axb-table-03__keynote-session', 'Product roadmap keynote', array( 'fontWeight' => '700', 'textColor' => '#111827' ) ),
									$axcelersblocks_schedule_cell( 'axb-table-03__keynote-owner', 'Product lead' ),
									$axcelersblocks_schedule_cell( 'axb-table-03__keynote-status', 'Featured', array( 'backgroundColor' => $axcelersblocks_schedule_responsive( '#FEF3C7' ), 'textColor' => '#92400E', 'fontWeight' => '700', 'textAlign' => $axcelersblocks_schedule_responsive( 'center' ) ) ),
								)
							),
							$axcelersblocks_schedule_row(
								'axb-table-03__row-workshop',
								array(
									$axcelersblocks_schedule_cell( 'axb-table-03__workshop-time', '11:30', array( 'time' => true, 'backgroundColor' => $axcelersblocks_schedule_responsive( '#F8FAFC' ), 'textColor' => '#111827' ) ),
									$axcelersblocks_schedule_cell( 'axb-table-03__workshop-session', 'Hands-on design workshop' ),
									$axcelersblocks_schedule_cell( 'axb-table-03__workshop-owner', 'Design systems team' ),
									$axcelersblocks_schedule_cell( 'axb-table-03__workshop-status', 'Limited seats', array( 'backgroundColor' => $axcelersblocks_schedule_responsive( '#FDF2F8' ), 'textColor' => '#BE185D', 'fontWeight' => '700', 'textAlign' => $axcelersblocks_schedule_responsive( 'center' ) ) ),
								)
							),
							$axcelersblocks_schedule_row(
								'axb-table-03__row-break',
								array(
									$axcelersblocks_schedule_cell( 'axb-table-03__break-time', '13:00', array( 'time' => true, 'backgroundColor' => $axcelersblocks_schedule_responsive( '#F8FAFC' ), 'textColor' => '#111827' ) ),
									$axcelersblocks_schedule_cell( 'axb-table-03__break-session', 'Lunch break and networking' ),
									$axcelersblocks_schedule_cell( 'axb-table-03__break-owner', 'Venue team' ),
									$axcelersblocks_schedule_cell( 'axb-table-03__break-status', 'Break', array( 'backgroundColor' => $axcelersblocks_schedule_responsive( '#F3F4F6' ), 'textColor' => '#374151', 'fontWeight' => '700', 'textAlign' => $axcelersblocks_schedule_responsive( 'center' ) ) ),
								)
							),
							$axcelersblocks_schedule_row(
								'axb-table-03__row-lab',
								array(
									$axcelersblocks_schedule_cell( 'axb-table-03__lab-time', '14:00', array( 'time' => true, 'backgroundColor' => $axcelersblocks_schedule_responsive( '#F8FAFC' ), 'textColor' => '#111827' ) ),
									$axcelersblocks_schedule_cell( 'axb-table-03__lab-session', 'Implementation lab' ),
									$axcelersblocks_schedule_cell( 'axb-table-03__lab-owner', 'Engineering team' ),
									$axcelersblocks_schedule_cell( 'axb-table-03__lab-status', 'Active', array( 'backgroundColor' => $axcelersblocks_schedule_responsive( '#ECFDF3' ), 'textColor' => '#166534', 'fontWeight' => '700', 'textAlign' => $axcelersblocks_schedule_responsive( 'center' ) ) ),
								)
							),
						)
					) .

				'<!-- /wp:axcelersblocks/table -->' .

			'<!-- /wp:axcelersblocks/box -->' .

		'<!-- /wp:axcelersblocks/box -->' .

	'<!-- /wp:axcelersblocks/box -->',
);
