<?php
if(!defined('ABSPATH')) exit;
$bizcalendar_web_key = basename(__FILE__, '.php');
if(!empty($args['args']['type']) && $args['args']['type'] == 'input'){
    // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
	$args['args']['model_suffix'] = '_value';
	setrio_bizcal_get_template_part('vue/part/input', $args);
	return;
}
$bizcalendar_web_a = shortcode_atts(array_replace_recursive(array(
	'label' => setrio_bizcal_message('lblAppointmentDate'),
	'atts' => 'full-width',
	'calendar' => !empty($args['rargs']) && !empty($args['rargs']['calendar']) ? $args['rargs']['calendar'] : 'inline',
	'first-day-of-week' => '1',
	'class' => 'mb-5',
	'locale' => 'ro',
	'type' => 'date',
	'hide-details' =>"'auto'",
	'texts' => array(
		'required' => setrio_bizcal_message('lblAppointmentDate'),
	),
	'rules' =>  "[v => (!!v && !!v.trim().length) || objVal(\$data,'texts." . $bizcalendar_web_key . ".required') || '']",
), (isset($args['wargs']) ? $args['wargs'] : array())), (isset($args['args']) ? $args['args'] : array()), (isset($args['tag']) ? $args['tag'] : ''));
if($bizcalendar_web_a['calendar'] === 'inline') {
?>
<v-date-picker 
	ref="<?php echo esc_attr($bizcalendar_web_key); ?>_picker" 
	<?php echo esc_attr($bizcalendar_web_a['atts']); ?>
	first-day-of-week="<?php echo esc_attr($bizcalendar_web_a['first-day-of-week']); ?>" 
	locale="<?php echo esc_attr($bizcalendar_web_a['locale']); ?>"
	v-model="<?php echo esc_attr($bizcalendar_web_key); ?>_value" 
	class="<?php echo esc_attr($bizcalendar_web_a['class']); ?>"
	:class="loading_ajax ? 'loading_ajax' : ''" 
	:events="Object.keys(datepicker_events)"
	:picker-date.sync="pickerDate"
	:event-color="function(date){return datepicker_events[date].color}"
	:days="Object.keys(datepicker_days)"
	:day-color="function(date){return datepicker_days[date].color}"
	:loading="<?php echo esc_attr($bizcalendar_web_key); ?>_lock"
	:min="$data['min_date']"
	v-bind="props('date-picker')"
	v-bind:color="datepicker_color"
>
</v-date-picker>
<v-input
	<?php if ($bizcalendar_web_a['rules']) { ?>:rules="<?php echo esc_attr($bizcalendar_web_a['rules']); ?>"<?php } ?>
	ref="<?php echo esc_attr($bizcalendar_web_key); ?>" 
	v-model="<?php echo esc_attr($bizcalendar_web_key); ?>_value"
	:hide-details="<?php echo esc_attr($bizcalendar_web_a['hide-details']); ?>"
></v-input>
<?php } else {?>
<v-menu
	eager
	:init="$data.date_menu = false"
	v-model="$data.date_menu"
	:close-on-content-click="false"
	:nudge-right="40"
	transition="scale-transition"
	offset-y
	min-width="auto"
	v-bind="props('menu')"
>
<template v-slot:activator="{ on, attrs }">
  <v-text-field
	ref="<?php echo esc_attr($bizcalendar_web_key); ?>" 
	v-model="<?php echo esc_attr($bizcalendar_web_key); ?>_value"
	label="<?php echo esc_attr($bizcalendar_web_a['label']); ?>"
	class="<?php echo esc_attr($bizcalendar_web_a['class']); ?>"
	:class="loading_ajax ? 'loading_ajax' : ''" 
	prepend-icon="mdi-calendar"
	:hide-details="<?php echo esc_attr($bizcalendar_web_a['hide-details']); ?>"
	:loading="<?php echo esc_attr($bizcalendar_web_key); ?>_lock"
	readonly
	v-bind:class="datepicker_color + '--text'"
	v-bind:color="datepicker_color"
	v-bind="props('text-field')"
	v-on="on"
  ></v-text-field>
</template>
<v-date-picker
	ref="<?php echo esc_attr($bizcalendar_web_key); ?>_picker" 
	v-model="<?php echo esc_attr($bizcalendar_web_key); ?>_value"
	locale="<?php echo esc_attr($bizcalendar_web_a['locale']); ?>"
	v-on:input="$data.date_menu = false"
	:min="$data['min_date']"
	<?php echo esc_attr($bizcalendar_web_a['atts']); ?>
	first-day-of-week="<?php echo esc_attr($bizcalendar_web_a['first-day-of-week']); ?>" 
	v-bind="props('date-picker')"
	v-bind:color="datepicker_color"
></v-date-picker>
</v-menu>
<?php }?>
<component is="script">SetrioBizCalendarVueApps[{{ app_index }}].setData('texts_<?php echo esc_attr($bizcalendar_web_key); ?>',<?php BizCalendar\wp_kses_post(htmlspecialchars(json_encode(array('texts' => array($bizcalendar_web_key => $bizcalendar_web_a['texts']))), ENT_QUOTES, 'UTF-8')); ?>)</component>