<?php
if(!defined('ABSPATH')) exit;
$bizcalendar_web_key = basename(__FILE__, '.php');
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$bizcalendar_web_tenDigitPhone = (bool)get_option('setrio_bizcal_ten_digit_phone', false);
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$args['key'] = $bizcalendar_web_key;
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$args['wargs'] = array_replace((isset($args['wargs']) ? $args['wargs'] : array()), array(
	'label' => setrio_bizcal_message('lblPatientPhone'),
	'texts' => array(
		'required' => setrio_bizcal_message('lblFieldMissing') . ' ' . setrio_bizcal_message('lblPhoneField'),
		'invalid' => setrio_bizcal_message('lblPhoneFieldNotValid'),
		'min_max' => !$bizcalendar_web_tenDigitPhone ? setrio_bizcal_message('lblPhoneFieldMinMax') : setrio_bizcal_message('lblPhoneFieldExact'),
	),
	'rules' => "[
		v => (!!v && !!v.trim().length) || objVal(\$data,'texts." . $bizcalendar_web_key . ".required') || '',
		v => /^([0-9])+$/.test(v) || objVal(\$data,'texts." . $bizcalendar_web_key . ".invalid') || '',
		v => (('' + (v || '')).trim().replace(/(.)\\1+/g, '\$1')).length > 3 || objVal(\$data,'texts." . $bizcalendar_web_key . ".min_max') || '',
		v => /^([0-9]{10" . ($bizcalendar_web_tenDigitPhone ? '' : ',15') . "})+$/.test(v) || objVal(\$data,'texts." . $bizcalendar_web_key . ".min_max') || '',
	]",
));
setrio_bizcal_get_template_part('vue/part/text', $args);