<?php
namespace SabaiApps\Directories\Component\Faker\Generator;

use SabaiApps\Directories\Component\Field\IField;
use SabaiApps\Directories\Component\Field\Type\ColorType;
use SabaiApps\Directories\Component\Entity\Type\IEntity;

class FieldGenerator extends AbstractGenerator {

	protected $_colors, $_users, $_userCount, $_icons;

	protected function _fakerGeneratorInfo() {
		$info = array(
			'field_types'     => array( substr( $this->_name, 6 ) ), // remove field_ part
			'add_probability' => true,
		);
		switch ( $this->_name ) {
			case 'field_string':
				$info += array(
					'default_settings' => array(
						'length' => array(
							'min' => 30,
							'max' => 80,
						),
						'max'    => 5,
					),
				);
				break;
			case 'field_text':
				$info += array(
					'default_settings' => array(
						'length' => array(
							'min' => 300,
							'max' => 1000,
						),
						'max'    => 5,
					),
				);
				break;
			case 'field_string_predefined':
				$info               += array(
					'label'            => __( 'Predefined String', 'directories-pro' ),
					'default_settings' => array(
						'predefined' => '',
						'max'        => 5,
					),
				);
				$info['field_types'] = array( 'string', 'entity_title' );
				break;
			case 'field_number':
			case 'field_range':
			case 'field_price':
				$info += array(
					'default_settings' => array(
						'range' => array(
							'min' => 0,
							'max' => 100,
						),
						'max'   => 5,
					),
				);
				break;
			case 'field_user':
				$info += array(
					'default_settings' => array(
						'type'  => 'admin',
						'num'   => 10,
						'users' => array( $this->_application->getUser()->id ),
						'max'   => 5,
					),
				);
				break;
			case 'field_video':
				$info += array(
					'default_settings' => array(
						'videos' => array(
							'nHXVc_cQqyI',
							'TN-pwblNxU4',
							'b7WD-SpNX_I',
							'CbdARMu6lCA',
							'DX48mJjL7oU',
							'u3APNJYMrLo',
							'bMUxpTb_wWc',
							'1La4QzGeaaQ',
							'PsrPTpg6mNo',
							'nRt4Duf7GoI',
							'xYYYT48Iv_c',
						),
						'max'    => 5,
					),
				);
				break;
			case 'field_email':
				$info                 += array(
					'default_settings' => array(
						'max' => 5,
					),
				);
				$info['field_types'][] = 'user_email';
				break;
			case 'field_phone':
				$info += array(
					'default_settings' => array(
						'max' => 5,
					),
				);
				break;
			case 'field_url':
				$info                 += array(
					'default_settings' => array(
						'max' => 5,
					),
				);
				$info['field_types'][] = 'user_url';
				break;
			case 'field_name':
				$info                 += array(
					'default_settings' => array(
						'max' => 5,
					),
				);
				$info['field_types'][] = 'user_name';
				break;
			case 'field_date':
				$info += array(
					'default_settings' => array(
						'range' => array(
							time() - 86400 * 365 * 10, // 10 years ago
							time(),
						),
						'max'   => 5,
					),
				);
				break;
			case 'field_time':
				$info                 += array(
					'default_settings' => array(
						'max' => 7,
					),
				);
				$info['field_types'][] = 'directory_opening_hours';
				break;
			case 'field_color':
				$info += array(
					'default_settings' => array(
						'max' => 4,
					),
				);
				break;
			case 'field_icon':
				$info += array(
					'default_settings' => array(
						'max' => 5,
					),
				);
				break;
		}

		return $info;
	}

	public function fakerGeneratorSettingsForm( IField $field, array $settings, $mode, array $parents = array() ) {
		switch ( $this->_name ) {
			case 'field_string':
			case 'field_text':
				$field_settings = $field->getFieldSettings();
				$min            = empty( $field_settings['min_length'] ) || $field_settings['min_length'] < 5 ? null : $field_settings['min_length'];
				$max            = empty( $field_settings['max_length'] ) || $field_settings['max_length'] < 5 ? null : $field_settings['max_length'];
				return array(
					'length' => array(
						'#type'          => 'range',
						'#title'         => __( 'Text length range', 'directories-pro' ),
						'#integer'       => true,
						'#min_value'     => isset( $min ) ? $min : min( array( 5, $settings['length']['min'] ) ),
						'#max_value'     => isset( $max ) ? $max : max( 100, $settings['length']['max'] ),
						'#default_value' => array(
							'min' => isset( $min ) ? max( array( $min, $settings['length']['min'] ) ) : $settings['length']['min'],
							'max' => isset( $max ) ? min( array( $max, $settings['length']['max'] ) ) : $settings['length']['max'],
						),
					),
					'max'    => $this->_getMaxNumItemsSettingForm( $field, $settings['max'] ),
				);
			case 'field_string_predefined':
				return array(
					'predefined' => array(
						'#title'         => __( 'Predefined words', 'directories-pro' ),
						'#type'          => 'textfield',
						'#separator'     => ',',
						'#default_value' => '',
						'#description'   => __( 'Enter predefined words separated with commas.', 'directories-pro' ),
					),
					'max'        => $this->_getMaxNumItemsSettingForm( $field, $settings['max'] ),
				);
			case 'field_name':
				return array(
					'gender' => array(
						'#type'          => 'select',
						'#title'         => __( 'Gender', 'directories-pro' ),
						'#options'       => array(
							''       => __( 'Any', 'directories-pro' ),
							'male'   => __( 'Male', 'directories-pro' ),
							'female' => __( 'Female', 'directories-pro' ),
						),
						'#default_value' => '',
					),
					'max'    => $this->_getMaxNumItemsSettingForm( $field, $settings['max'] ),
				);
			case 'field_email':
			case 'field_phone':
			case 'field_url':
			case 'field_time':
			case 'field_color':
			case 'field_icon':
				return array(
					'max' => $this->_getMaxNumItemsSettingForm( $field, $settings['max'] ),
				);
			case 'field_number':
			case 'field_range':
			case 'field_price':
				$field_settings = $field->getFieldSettings();
				$min            = empty( $field_settings['min'] ) ? null : $field_settings['min'];
				$max            = empty( $field_settings['max'] ) ? null : $field_settings['max'];
				return array(
					'range' => array(
						'#type'          => 'range',
						'#title'         => __( 'Number range', 'directories-pro' ),
						'#integer'       => true,
						'#min_value'     => isset( $min ) ? $min : min( array( 0, $settings['range']['min'] ) ),
						'#max_value'     => isset( $max ) ? $max : max( 100, $settings['range']['max'] ),
						'#default_value' => array(
							'min' => isset( $min ) ? max( array( $min, $settings['range']['min'] ) ) : $settings['range']['min'],
							'max' => isset( $max ) ? min( array( $max, $settings['range']['max'] ) ) : $settings['range']['max'],
						),
					),
					'max'   => $this->_getMaxNumItemsSettingForm( $field, $settings['max'] ),
				);
			case 'field_video':
				return array(
					'videos' => array(
						'#type'          => 'textfield',
						'#title'         => __( 'YouTube videos', 'directories-pro' ),
						'#separator'     => ',',
						'#default_value' => $settings['videos'],
						'#description'   => __( 'Enter YouTube video IDs separated with commas.' ),
					),
					'max'    => $this->_getMaxNumItemsSettingForm( $field, $settings['max'] ),
				);
			case 'field_user':
				return array(
					'type'  => array(
						'#type'          => 'select',
						'#title'         => __( '— Select —', 'directories-pro' ),
						'#options'       => array(
							'admin'  => __( 'Administrators', 'directories-pro' ),
							'users'  => __( 'Specific users', 'directories-pro' ),
							'newest' => __( 'Newest users', 'directories-pro' ),
						),
						'#default_value' => $settings['type'],
					),
					'users' => array(
						'#type'          => 'user',
						'#multiple'      => true,
						'#default_value' => $settings['users'],
						'#states'        => array(
							'visible' => array(
								sprintf( 'select[name="%s[type]"]', $this->_application->Form_Form_fieldName( $parents ) ) => array( 'value' => 'users' ),
							),
						),
						'#required'      => function ( $form ) use ( $parents ) {
							return $form->getValue( array_merge( $parents, array( 'type' ) ) ) === 'users'; },
					),
					'num'   => array(
						'#type'          => 'slider',
						'#title'         => __( 'Max number of users', 'directories-pro' ),
						'#min_value'     => 1,
						'#max_value'     => 100,
						'#default_value' => $settings['num'],
						'#states'        => array(
							'visible' => array(
								sprintf( 'select[name="%s[type]"]', $this->_application->Form_Form_fieldName( $parents ) ) => array( 'value' => 'newest' ),
							),
						),
						'#required'      => function ( $form ) use ( $parents ) {
							return $form->getValue( array_merge( $parents, array( 'type' ) ) ) === 'newest'; },
					),
					'max'   => $this->_getMaxNumItemsSettingForm( $field, $settings['max'] ),
				);
			case 'field_date':
				return array(
					'range' => $this->_getTimestampSettingForm( $settings['range'] ),
					'max'   => $this->_getMaxNumItemsSettingForm( $field, $settings['max'] ),
				);
			case 'field_choice':
				$field_settings = $field->getFieldSettings();
				return array(
					'options' => array(
						'#title'         => $field->getFieldLabel(),
						'#type'          => 'checkboxes',
						'#columns'       => 3,
						'#options'       => $field_settings['options']['options'],
						'#default_value' => array_keys( $field_settings['options']['options'] ),
					),
				);
			default:
				return array();
		}
	}

	public function fakerGeneratorGenerate( IField $field, array $settings, array &$formStorage, ?IEntity $entity = null ) {
		switch ( $this->_name ) {
			case 'field_string':
				$ret     = array();
				$min_len = $settings['length']['min'];
				$max_len = $settings['length']['max'];
				$count   = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = str_replace( '.', '', $this->_getFaker()->text( mt_rand( $min_len + 1, $max_len + 1 ) ) ); // remove periods
				}
				return empty( $ret ) ? null : $ret;
			case 'field_text':
				$ret     = array();
				$min_len = $settings['length']['min'];
				$max_len = $settings['length']['max'];
				$count   = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = str_replace( "\n", "\n\n", $this->_getFaker()->text( mt_rand( $min_len, $max_len ) ) );
				}
				return empty( $ret ) ? null : $ret;
			case 'field_string_predefined':
				if ( empty( $settings['predefined'] ) ) {
					return false;
				}
				$ret   = array();
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				$keys  = array_rand( $settings['predefined'], min( $count, count( $settings['predefined'] ) ) );
				foreach ( (array) $keys as $key ) {
					$ret[] = $settings['predefined'][ $key ];
				}
				return empty( $ret ) ? null : $ret;
			case 'field_boolean':
				return array( (bool) mt_rand( 0, 1 ) );
			case 'field_number':
				$ret   = array();
				$min   = $settings['range']['min'];
				$max   = $settings['range']['max'];
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = mt_rand( $min, $max );
				}
				return empty( $ret ) ? null : $ret;
			case 'field_range':
				$ret   = array();
				$min   = $settings['range']['min'];
				$max   = $settings['range']['max'];
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = array(
						'min' => $_min = mt_rand( $min, $max ),
						'max' => mt_rand( $_min, $max ),
					);
				}
				return empty( $ret ) ? null : $ret;
			case 'field_price':
				$field_settings = $field->getFieldSettings();
				$currencies     = empty( $field_settings['currencies'] ) ? array( 'USD' ) : $field_settings['currencies'];
				$ret            = array();
				$min            = $settings['range']['min'];
				$max            = $settings['range']['max'];
				$count          = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = array(
						'value'    => mt_rand( $min, $max ),
						'currency' => $currencies[ array_rand( $currencies ) ],
					);
				}
				return empty( $ret ) ? null : $ret;
			case 'field_name':
				$ret            = array();
				$count          = $this->_getMaxNumItems( $field, $settings['max'] );
				$field_settings = $field->getFieldSettings();
				if ( ! empty( $field_settings['prefixes'] ) ) {
					$prefixes = $field_settings['prefixes'];
				}
				$gender = empty( $settings['gender'] ) ? null : $settings['gender'];
				for ( $i = 0; $i < $count; ++$i ) {
					$prefix = '';
					if ( isset( $prefixes ) ) {
						if ( ! empty( $gender ) ) {
							if ( $title = $this->_getFaker()->title( $gender ) ) {
								$title = strtolower( strtr( $title, array( '.' => '' ) ) );
								if ( in_array( $title, $prefixes ) ) {
									$prefix = $title;
								}
							}
						} else {
							$prefix = $prefixes[ array_rand( $prefixes ) ];
						}
					}
					$ret[] = array(
						'prefix'     => $prefix,
						'first_name' => $this->_getFaker()->firstName( $gender ),
						'last_name'  => $this->_getFaker()->lastName(),
						'suffix'     => $this->_getFaker()->suffix(),
					);
				}
				return empty( $ret ) ? null : $ret;
			case 'field_email':
				$ret   = array();
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = $this->_getFaker()->email();
				}
				return empty( $ret ) ? null : $ret;
			case 'field_phone':
				$ret   = array();
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = $this->_getFaker()->phoneNumber();
				}
				return empty( $ret ) ? null : $ret;
			case 'field_url':
				$ret   = array();
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = $this->_getFaker()->url();
				}
				return empty( $ret ) ? null : $ret;
			case 'field_video':
				if ( empty( $settings['videos'] ) ) {
					return false;
				}
				$ret       = array();
				$count     = $this->_getMaxNumItems( $field, $settings['max'] );
				$max_index = count( $settings['videos'] ) - 1;
				for ( $i = 0; $i < $count; ++$i ) {
					$id         = $settings['videos'][ mt_rand( 0, $max_index ) ];
					$ret[ $id ] = array(
						'id'       => $id,
						'provider' => 'youtube',
					);
				}
				return empty( $ret ) ? null : array_values( $ret );
			case 'field_choice':
				if ( ( $options_count = count( $settings['options'] ) )
					&& ( $max = $this->_getMaxNumItems( $field, $options_count ) )
					&& ( $keys = (array) array_rand( $settings['options'], $max ) )
				) {
					$ret = array();
					foreach ( $keys as $key ) {
						$ret[] = $settings['options'][ $key ];
					}
					return $ret;
				}
				return;
			case 'field_user':
				if ( ! isset( $this->_users ) ) {
					if ( $settings['type'] === 'users' ) {
						$this->_users = $settings['users'];
					} elseif ( $settings['type'] === 'admin' ) {
						$this->_users = array_values( $this->_application->getPlatform()->getAdministrators() );
					} else {
						$this->_users = $this->_application
							->getPlatform()
							->getUserIdentityFetcher()
							->fetch( $settings['num'], 0, 'timestamp', 'ASC' );
					}
					$this->_userCount = count( $this->_users );
				}
				if ( empty( $this->_userCount ) ) {
					return null;
				}

				$ret   = array();
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = $this->_users[ mt_rand( 0, $this->_userCount - 1 ) ];
				}
				return $ret;
			case 'field_date':
				$ret   = array();
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$ret[] = $this->_generateTimestamp( $settings['range'] );
				}
				return empty( $ret ) ? null : $ret;
			case 'field_time':
				$field_settings = $field->getFieldSettings();
				$ret            = array();
				$count          = $this->_getMaxNumItems( $field, $settings['max'] );
				if ( $field->getFieldType() === 'directory_opening_hours' ) {
					for ( $i = 0; $i < $count; ++$i ) {
						$ret[] = array(
							'start' => ( $start = mt_rand( 0, 43200 ) ) - ( $start % 1800 ),
							'end'   => ( $end = mt_rand( 45000, 86400 ) ) - ( $end % 1800 ),
							'day'   => mt_rand( 1, 7 ),
						);
					}
				} else {
					for ( $i = 0; $i < $count; ++$i ) {
						$ret[] = array(
							'start' => mt_rand( 0, 86400 ),
							'end'   => ! empty( $field_settings['enable_end'] ) ? mt_rand( 0, 86400 ) : null,
							'day'   => ! empty( $field_settings['enable_day'] ) ? mt_rand( 1, 7 ) : null,
						);
					}
				}
				return empty( $ret ) ? null : $ret;
			case 'field_color':
				$ret = array();
				if ( ! isset( $this->_colors ) ) {
					$this->_colors = call_user_func_array( 'array_merge', array_values( ColorType::colors() ) );
					srand( (float) microtime() * 10000000 );
				}
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				for ( $i = 0; $i < $count; ++$i ) {
					$value = $this->_colors[ array_rand( $this->_colors ) ];
					$ret[] = array(
						'value'   => '#' . $value,
						'closest' => $value,
					);
				}
				return empty( $ret ) ? null : $ret;
			case 'field_icon':
				$ret = array();
				if ( ! isset( $this->_icons ) ) {
					$this->_icons = array(
						'0',
						'1',
						'2',
						'3',
						'4',
						'5',
						'6',
						'7',
						'8',
						'9',
						'exclamation',
						'hashtag',
						'dollar-sign',
						'percent',
						'asterisk',
						'plus',
						'less-than',
						'equals',
						'greater-than',
						'question',
						'at',
						'faucet',
						'faucet-drip',
						'house-chimney-window',
						'house-signal',
						'temperature-arrow-down',
						'temperature-arrow-up',
						'trailer',
						'bacteria',
						'bacterium',
						'box-tissue',
						'hand-holding-medical',
						'hand-sparkles',
						'hands-bubbles',
						'handshake-slash',
						'head-side-cough',
						'head-side-cough-slash',
						'head-side-mask',
						'head-side-virus',
						'house-chimney-user',
						'house-laptop',
						'lungs-virus',
						'people-arrows',
						'plane-slash',
						'pump-medical',
						'pump-soap',
						'shield-virus',
						'sink',
						'soap',
						'stopwatch-20',
						'shop-slash',
						'store-slash',
						'toilet-paper-slash',
						'users-slash',
						'virus',
						'virus-slash',
						'viruses',
						'vest',
						'vest-patches',
						'arrow-trend-down',
						'arrow-trend-up',
						'arrow-up-from-bracket',
						'austral-sign',
						'baht-sign',
						'bitcoin-sign',
						'bolt-lightning',
						'book-bookmark',
						'camera-rotate',
						'cedi-sign',
						'chart-column',
						'chart-gantt',
						'clapperboard',
						'clover',
						'code-compare',
						'code-fork',
						'code-pull-request',
						'colon-sign',
						'cruzeiro-sign',
						'display',
						'dong-sign',
						'elevator',
						'filter-circle-xmark',
						'florin-sign',
						'folder-closed',
						'franc-sign',
						'guarani-sign',
						'gun',
						'hands-clapping',
						'house-user',
						'indian-rupee-sign',
						'kip-sign',
						'lari-sign',
						'litecoin-sign',
						'manat-sign',
						'mask-face',
						'mill-sign',
						'money-bills',
						'naira-sign',
						'notdef',
						'panorama',
						'peseta-sign',
						'peso-sign',
						'plane-up',
						'rupiah-sign',
						'stairs',
						'timeline',
						'truck-front',
						'turkish-lira-sign',
						'vault',
						'wand-magic-sparkles',
						'wheat-awn',
						'wheelchair-move',
						'bangladeshi-taka-sign',
						'bowl-rice',
						'person-pregnant',
						'house-chimney',
						'house-crack',
						'house-medical',
						'cent-sign',
						'plus-minus',
						'sailboat',
						'section',
						'shrimp',
						'brazilian-real-sign',
						'chart-simple',
						'diagram-next',
						'diagram-predecessor',
						'diagram-successor',
						'earth-oceania',
						'bug-slash',
						'file-circle-plus',
						'shop-lock',
						'virus-covid',
						'virus-covid-slash',
						'anchor-circle-check',
						'anchor-circle-exclamation',
						'anchor-circle-xmark',
						'anchor-lock',
						'arrow-down-up-across-line',
						'arrow-down-up-lock',
						'arrow-right-to-city',
						'arrow-up-from-ground-water',
						'arrow-up-from-water-pump',
						'arrow-up-right-dots',
						'arrows-down-to-line',
						'arrows-down-to-people',
						'arrows-left-right-to-line',
						'arrows-spin',
						'arrows-split-up-and-left',
						'arrows-to-circle',
						'arrows-to-dot',
						'arrows-to-eye',
						'arrows-turn-right',
						'arrows-turn-to-dots',
						'arrows-up-to-line',
						'bore-hole',
						'bottle-droplet',
						'bottle-water',
						'bowl-food',
						'boxes-packing',
						'bridge',
						'bridge-circle-check',
						'bridge-circle-exclamation',
						'bridge-circle-xmark',
						'bridge-lock',
						'bridge-water',
						'bucket',
						'bugs',
						'building-circle-arrow-right',
						'building-circle-check',
						'building-circle-exclamation',
						'building-circle-xmark',
						'building-flag',
						'building-lock',
						'building-ngo',
						'building-shield',
						'building-un',
						'building-user',
						'building-wheat',
						'burst',
						'car-on',
						'car-tunnel',
						'child-combatant',
						'children',
						'circle-nodes',
						'clipboard-question',
						'cloud-showers-water',
						'computer',
						'cubes-stacked',
						'envelope-circle-check',
						'explosion',
						'ferry',
						'file-circle-exclamation',
						'file-circle-minus',
						'file-circle-question',
						'file-shield',
						'fire-burner',
						'fish-fins',
						'flask-vial',
						'glass-water',
						'glass-water-droplet',
						'group-arrows-rotate',
						'hand-holding-hand',
						'handcuffs',
						'hands-bound',
						'hands-holding-child',
						'hands-holding-circle',
						'heart-circle-bolt',
						'heart-circle-check',
						'heart-circle-exclamation',
						'heart-circle-minus',
						'heart-circle-plus',
						'heart-circle-xmark',
						'helicopter-symbol',
						'helmet-un',
						'hill-avalanche',
						'hill-rockslide',
						'house-circle-check',
						'house-circle-exclamation',
						'house-circle-xmark',
						'house-fire',
						'house-flag',
						'house-flood-water',
						'house-flood-water-circle-arrow-right',
						'house-lock',
						'house-medical-circle-check',
						'house-medical-circle-exclamation',
						'house-medical-circle-xmark',
						'house-medical-flag',
						'house-tsunami',
						'jar',
						'jar-wheat',
						'jet-fighter-up',
						'jug-detergent',
						'kitchen-set',
						'land-mine-on',
						'landmark-flag',
						'laptop-file',
						'lines-leaning',
						'location-pin-lock',
						'locust',
						'magnifying-glass-arrow-right',
						'magnifying-glass-chart',
						'mars-and-venus-burst',
						'mask-ventilator',
						'mattress-pillow',
						'mobile-retro',
						'money-bill-transfer',
						'money-bill-trend-up',
						'money-bill-wheat',
						'mosquito',
						'mosquito-net',
						'mound',
						'mountain-city',
						'mountain-sun',
						'oil-well',
						'people-group',
						'people-line',
						'people-pulling',
						'people-robbery',
						'people-roof',
						'person-arrow-down-to-line',
						'person-arrow-up-from-line',
						'person-breastfeeding',
						'person-burst',
						'person-cane',
						'person-chalkboard',
						'person-circle-check',
						'person-circle-exclamation',
						'person-circle-minus',
						'person-circle-plus',
						'person-circle-question',
						'person-circle-xmark',
						'person-dress-burst',
						'person-drowning',
						'person-falling',
						'person-falling-burst',
						'person-half-dress',
						'person-harassing',
						'person-military-pointing',
						'person-military-rifle',
						'person-military-to-person',
						'person-rays',
						'person-rifle',
						'person-shelter',
						'person-walking-arrow-loop-left',
						'person-walking-arrow-right',
						'person-walking-dashed-line-arrow-right',
						'person-walking-luggage',
						'plane-circle-check',
						'plane-circle-exclamation',
						'plane-circle-xmark',
						'plane-lock',
						'plate-wheat',
						'plug-circle-bolt',
						'plug-circle-check',
						'plug-circle-exclamation',
						'plug-circle-minus',
						'plug-circle-plus',
						'plug-circle-xmark',
						'ranking-star',
						'road-barrier',
						'road-bridge',
						'road-circle-check',
						'road-circle-exclamation',
						'road-circle-xmark',
						'road-lock',
						'road-spikes',
						'rug',
						'sack-xmark',
						'school-circle-check',
						'school-circle-exclamation',
						'school-circle-xmark',
						'school-flag',
						'school-lock',
						'sheet-plastic',
						'shield-cat',
						'shield-dog',
						'shield-heart',
						'square-nfi',
						'square-person-confined',
						'square-virus',
						'staff-snake',
						'sun-plant-wilt',
						'tarp',
						'tarp-droplet',
						'tent',
						'tent-arrow-down-to-line',
						'tent-arrow-left-right',
						'tent-arrow-turn-left',
						'tent-arrows-down',
						'tents',
						'toilet-portable',
						'toilets-portable',
						'tower-cell',
						'tower-observation',
						'tree-city',
						'trowel',
						'trowel-bricks',
						'truck-arrow-right',
						'truck-droplet',
						'truck-field',
						'truck-field-un',
						'truck-plane',
						'users-between-lines',
						'users-line',
						'users-rays',
						'users-rectangle',
						'users-viewfinder',
						'vial-circle-check',
						'vial-virus',
						'wheat-awn-circle-exclamation',
						'worm',
						'xmarks-lines',
						'child-dress',
						'child-reaching',
						'file-circle-check',
						'file-circle-xmark',
						'person-through-window',
						'plant-wilt',
						'stapler',
						'train-tram',
						'table-cells-column-lock',
						'table-cells-row-lock',
						'web-awesome',
						'thumbtack-slash',
						'table-cells-row-unlock',
						'chart-diagram',
						'comment-nodes',
						'file-fragment',
						'file-half-dashed',
						'hexagon-nodes',
						'hexagon-nodes-bolt',
						'square-binary',
						'pentagon',
						'non-binary',
						'spiral',
						'mobile-vibrate',
						'single-quote-left',
						'single-quote-right',
						'bus-side',
						'septagon',
						'martini-glass-empty',
						'music',
						'magnifying-glass',
						'heart',
						'star',
						'user',
						'film',
						'table-cells-large',
						'table-cells',
						'table-list',
						'check',
						'xmark',
						'magnifying-glass-plus',
						'magnifying-glass-minus',
						'power-off',
						'signal',
						'gear',
						'house',
						'clock',
						'road',
						'download',
						'inbox',
						'arrow-rotate-right',
						'arrows-rotate',
						'rectangle-list',
						'lock',
						'flag',
						'headphones',
						'volume-off',
						'volume-low',
						'volume-high',
						'qrcode',
						'barcode',
						'tag',
						'tags',
						'book',
						'bookmark',
						'print',
						'camera',
						'font',
						'bold',
						'italic',
						'text-height',
						'text-width',
						'align-left',
						'align-center',
						'align-right',
						'align-justify',
						'list',
						'outdent',
						'indent',
						'video',
						'image',
						'location-pin',
						'circle-half-stroke',
						'droplet',
						'pen-to-square',
						'arrows-up-down-left-right',
						'backward-step',
						'backward-fast',
						'backward',
						'play',
						'pause',
						'stop',
						'forward',
						'forward-fast',
						'forward-step',
						'eject',
						'chevron-left',
						'chevron-right',
						'circle-plus',
						'circle-minus',
						'circle-xmark',
						'circle-check',
						'circle-question',
						'circle-info',
						'crosshairs',
						'ban',
						'arrow-left',
						'arrow-right',
						'arrow-up',
						'arrow-down',
						'share',
						'expand',
						'compress',
						'minus',
						'circle-exclamation',
						'gift',
						'leaf',
						'fire',
						'eye',
						'eye-slash',
						'triangle-exclamation',
						'plane',
						'calendar-days',
						'shuffle',
						'comment',
						'magnet',
						'chevron-up',
						'chevron-down',
						'retweet',
						'cart-shopping',
						'folder',
						'folder-open',
						'arrows-up-down',
						'arrows-left-right',
						'chart-bar',
						'camera-retro',
						'key',
						'gears',
						'comments',
						'star-half',
						'arrow-right-from-bracket',
						'thumbtack',
						'arrow-up-right-from-square',
						'arrow-right-to-bracket',
						'trophy',
						'upload',
						'lemon',
						'phone',
						'square-phone',
						'unlock',
						'credit-card',
						'rss',
						'hard-drive',
						'bullhorn',
						'certificate',
						'hand-point-right',
						'hand-point-left',
						'hand-point-up',
						'hand-point-down',
						'circle-arrow-left',
						'circle-arrow-right',
						'circle-arrow-up',
						'circle-arrow-down',
						'globe',
						'wrench',
						'list-check',
						'filter',
						'briefcase',
						'up-down-left-right',
						'users',
						'link',
						'cloud',
						'flask',
						'scissors',
						'copy',
						'paperclip',
						'floppy-disk',
						'square',
						'bars',
						'list-ul',
						'list-ol',
						'strikethrough',
						'underline',
						'table',
						'wand-magic',
						'truck',
						'money-bill',
						'caret-down',
						'caret-up',
						'caret-left',
						'caret-right',
						'table-columns',
						'sort',
						'sort-down',
						'sort-up',
						'envelope',
						'arrow-rotate-left',
						'gavel',
						'bolt',
						'sitemap',
						'umbrella',
						'paste',
						'lightbulb',
						'arrow-right-arrow-left',
						'cloud-arrow-down',
						'cloud-arrow-up',
						'user-doctor',
						'stethoscope',
						'suitcase',
						'bell',
						'mug-saucer',
						'hospital',
						'truck-medical',
						'suitcase-medical',
						'jet-fighter',
						'beer-mug-empty',
						'square-h',
						'square-plus',
						'angles-left',
						'angles-right',
						'angles-up',
						'angles-down',
						'angle-left',
						'angle-right',
						'angle-up',
						'angle-down',
						'laptop',
						'tablet-button',
						'mobile-button',
						'quote-left',
						'quote-right',
						'spinner',
						'circle',
						'face-smile',
						'face-frown',
						'face-meh',
						'gamepad',
						'keyboard',
						'flag-checkered',
						'terminal',
						'code',
						'reply-all',
						'location-arrow',
						'crop',
						'code-branch',
						'link-slash',
						'info',
						'superscript',
						'subscript',
						'eraser',
						'puzzle-piece',
						'microphone',
						'microphone-slash',
						'shield',
						'calendar',
						'fire-extinguisher',
						'rocket',
						'circle-chevron-left',
						'circle-chevron-right',
						'circle-chevron-up',
						'circle-chevron-down',
						'anchor',
						'unlock-keyhole',
						'bullseye',
						'ellipsis',
						'ellipsis-vertical',
						'square-rss',
						'circle-play',
						'ticket',
						'square-minus',
						'arrow-turn-up',
						'arrow-turn-down',
						'square-check',
						'square-pen',
						'square-arrow-up-right',
						'share-from-square',
						'compass',
						'square-caret-down',
						'square-caret-up',
						'square-caret-right',
						'euro-sign',
						'sterling-sign',
						'rupee-sign',
						'yen-sign',
						'ruble-sign',
						'won-sign',
						'file',
						'file-lines',
						'arrow-down-a-z',
						'arrow-up-a-z',
						'arrow-down-wide-short',
						'arrow-up-wide-short',
						'arrow-down-1-9',
						'arrow-up-1-9',
						'thumbs-up',
						'thumbs-down',
						'arrow-down-long',
						'arrow-up-long',
						'arrow-left-long',
						'arrow-right-long',
						'person-dress',
						'person',
						'sun',
						'moon',
						'box-archive',
						'bug',
						'square-caret-left',
						'circle-dot',
						'wheelchair',
						'lira-sign',
						'shuttle-space',
						'square-envelope',
						'building-columns',
						'graduation-cap',
						'language',
						'fax',
						'building',
						'child',
						'paw',
						'cube',
						'cubes',
						'recycle',
						'car',
						'taxi',
						'tree',
						'database',
						'file-pdf',
						'file-word',
						'file-excel',
						'file-powerpoint',
						'file-image',
						'file-zipper',
						'file-audio',
						'file-video',
						'file-code',
						'life-ring',
						'circle-notch',
						'paper-plane',
						'clock-rotate-left',
						'heading',
						'paragraph',
						'sliders',
						'share-nodes',
						'square-share-nodes',
						'bomb',
						'futbol',
						'tty',
						'binoculars',
						'plug',
						'newspaper',
						'wifi',
						'calculator',
						'bell-slash',
						'trash',
						'copyright',
						'eye-dropper',
						'paintbrush',
						'cake-candles',
						'chart-area',
						'chart-pie',
						'chart-line',
						'toggle-off',
						'toggle-on',
						'bicycle',
						'bus',
						'closed-captioning',
						'shekel-sign',
						'cart-plus',
						'cart-arrow-down',
						'diamond',
						'ship',
						'user-secret',
						'motorcycle',
						'street-view',
						'heart-pulse',
						'venus',
						'mars',
						'mercury',
						'mars-and-venus',
						'transgender',
						'venus-double',
						'mars-double',
						'venus-mars',
						'mars-stroke',
						'mars-stroke-up',
						'mars-stroke-right',
						'neuter',
						'genderless',
						'server',
						'user-plus',
						'user-xmark',
						'bed',
						'train',
						'train-subway',
						'battery-full',
						'battery-three-quarters',
						'battery-half',
						'battery-quarter',
						'battery-empty',
						'arrow-pointer',
						'i-cursor',
						'object-group',
						'object-ungroup',
						'note-sticky',
						'clone',
						'scale-balanced',
						'hourglass-start',
						'hourglass-half',
						'hourglass-end',
						'hourglass',
						'hand-back-fist',
						'hand',
						'hand-scissors',
						'hand-lizard',
						'hand-spock',
						'hand-pointer',
						'hand-peace',
						'trademark',
						'registered',
						'tv',
						'calendar-plus',
						'calendar-minus',
						'calendar-xmark',
						'calendar-check',
						'industry',
						'map-pin',
						'signs-post',
						'map',
						'message',
						'circle-pause',
						'circle-stop',
						'bag-shopping',
						'basket-shopping',
						'universal-access',
						'person-walking-with-cane',
						'audio-description',
						'phone-volume',
						'braille',
						'ear-listen',
						'hands-asl-interpreting',
						'ear-deaf',
						'hands',
						'eye-low-vision',
						'font-awesome',
						'handshake',
						'envelope-open',
						'address-book',
						'address-card',
						'circle-user',
						'id-badge',
						'id-card',
						'temperature-full',
						'temperature-three-quarters',
						'temperature-half',
						'temperature-quarter',
						'temperature-empty',
						'shower',
						'bath',
						'podcast',
						'window-maximize',
						'window-minimize',
						'window-restore',
						'square-xmark',
						'microchip',
						'snowflake',
						'spoon',
						'utensils',
						'rotate-left',
						'trash-can',
						'rotate',
						'stopwatch',
						'right-from-bracket',
						'right-to-bracket',
						'rotate-right',
						'poo',
						'images',
						'pencil',
						'pen',
						'pen-clip',
						'octagon',
						'down-long',
						'left-long',
						'right-long',
						'up-long',
						'hexagon',
						'file-pen',
						'maximize',
						'clipboard',
						'left-right',
						'up-down',
						'alarm-clock',
						'circle-down',
						'circle-left',
						'circle-right',
						'circle-up',
						'up-right-from-square',
						'square-up-right',
						'right-left',
						'repeat',
						'code-commit',
						'code-merge',
						'desktop',
						'gem',
						'turn-down',
						'turn-up',
						'lock-open',
						'location-dot',
						'microphone-lines',
						'mobile-screen-button',
						'mobile',
						'mobile-screen',
						'money-bill-1',
						'phone-slash',
						'image-portrait',
						'reply',
						'shield-halved',
						'tablet-screen-button',
						'tablet',
						'ticket-simple',
						'rectangle-xmark',
						'down-left-and-up-right-to-center',
						'up-right-and-down-left-from-center',
						'baseball-bat-ball',
						'baseball',
						'basketball',
						'bowling-ball',
						'chess',
						'chess-bishop',
						'chess-board',
						'chess-king',
						'chess-knight',
						'chess-pawn',
						'chess-queen',
						'chess-rook',
						'dumbbell',
						'football',
						'golf-ball-tee',
						'hockey-puck',
						'broom-ball',
						'square-full',
						'table-tennis-paddle-ball',
						'volleyball',
						'hand-dots',
						'bandage',
						'box',
						'boxes-stacked',
						'briefcase-medical',
						'fire-flame-simple',
						'capsules',
						'clipboard-check',
						'clipboard-list',
						'person-dots-from-line',
						'dna',
						'dolly',
						'cart-flatbed',
						'file-medical',
						'file-waveform',
						'kit-medical',
						'circle-h',
						'id-card-clip',
						'notes-medical',
						'pallet',
						'pills',
						'prescription-bottle',
						'prescription-bottle-medical',
						'bed-pulse',
						'truck-fast',
						'smoking',
						'syringe',
						'tablets',
						'thermometer',
						'vial',
						'vials',
						'warehouse',
						'weight-scale',
						'x-ray',
						'box-open',
						'comment-dots',
						'comment-slash',
						'couch',
						'circle-dollar-to-slot',
						'dove',
						'hand-holding',
						'hand-holding-heart',
						'hand-holding-dollar',
						'hand-holding-droplet',
						'hands-holding',
						'handshake-angle',
						'parachute-box',
						'people-carry-box',
						'piggy-bank',
						'ribbon',
						'route',
						'seedling',
						'sign-hanging',
						'face-smile-wink',
						'tape',
						'truck-ramp-box',
						'truck-moving',
						'video-slash',
						'wine-glass',
						'user-astronaut',
						'user-check',
						'user-clock',
						'user-gear',
						'user-pen',
						'user-group',
						'user-graduate',
						'user-lock',
						'user-minus',
						'user-ninja',
						'user-shield',
						'user-slash',
						'user-tag',
						'user-tie',
						'users-gear',
						'scale-unbalanced',
						'scale-unbalanced-flip',
						'blender',
						'book-open',
						'tower-broadcast',
						'broom',
						'chalkboard',
						'chalkboard-user',
						'church',
						'coins',
						'compact-disc',
						'crow',
						'crown',
						'dice',
						'dice-five',
						'dice-four',
						'dice-one',
						'dice-six',
						'dice-three',
						'dice-two',
						'divide',
						'door-closed',
						'door-open',
						'feather',
						'frog',
						'gas-pump',
						'glasses',
						'greater-than-equal',
						'helicopter',
						'infinity',
						'kiwi-bird',
						'less-than-equal',
						'memory',
						'microphone-lines-slash',
						'money-bill-wave',
						'money-bill-1-wave',
						'money-check',
						'money-check-dollar',
						'not-equal',
						'palette',
						'square-parking',
						'diagram-project',
						'receipt',
						'robot',
						'ruler',
						'ruler-combined',
						'ruler-horizontal',
						'ruler-vertical',
						'school',
						'screwdriver',
						'shoe-prints',
						'skull',
						'ban-smoking',
						'store',
						'shop',
						'bars-staggered',
						'stroopwafel',
						'toolbox',
						'shirt',
						'person-walking',
						'wallet',
						'face-angry',
						'archway',
						'book-atlas',
						'award',
						'delete-left',
						'bezier-curve',
						'bong',
						'brush',
						'bus-simple',
						'cannabis',
						'check-double',
						'martini-glass-citrus',
						'bell-concierge',
						'cookie',
						'cookie-bite',
						'crop-simple',
						'tachograph-digital',
						'face-dizzy',
						'compass-drafting',
						'drum',
						'drum-steelpan',
						'feather-pointed',
						'file-contract',
						'file-arrow-down',
						'file-export',
						'file-import',
						'file-invoice',
						'file-invoice-dollar',
						'file-prescription',
						'file-signature',
						'file-arrow-up',
						'fill',
						'fill-drip',
						'fingerprint',
						'fish',
						'face-flushed',
						'face-frown-open',
						'martini-glass',
						'earth-africa',
						'earth-americas',
						'earth-asia',
						'face-grimace',
						'face-grin',
						'face-grin-wide',
						'face-grin-beam',
						'face-grin-beam-sweat',
						'face-grin-hearts',
						'face-grin-squint',
						'face-grin-squint-tears',
						'face-grin-stars',
						'face-grin-tears',
						'face-grin-tongue',
						'face-grin-tongue-squint',
						'face-grin-tongue-wink',
						'face-grin-wink',
						'grip',
						'grip-vertical',
						'headset',
						'highlighter',
						'hot-tub-person',
						'hotel',
						'joint',
						'face-kiss',
						'face-kiss-beam',
						'face-kiss-wink-heart',
						'face-laugh',
						'face-laugh-beam',
						'face-laugh-squint',
						'face-laugh-wink',
						'cart-flatbed-suitcase',
						'map-location',
						'map-location-dot',
						'marker',
						'medal',
						'face-meh-blank',
						'face-rolling-eyes',
						'monument',
						'mortar-pestle',
						'paint-roller',
						'passport',
						'pen-fancy',
						'pen-nib',
						'pen-ruler',
						'plane-arrival',
						'plane-departure',
						'prescription',
						'face-sad-cry',
						'face-sad-tear',
						'van-shuttle',
						'signature',
						'face-smile-beam',
						'solar-panel',
						'spa',
						'splotch',
						'spray-can',
						'stamp',
						'star-half-stroke',
						'suitcase-rolling',
						'face-surprise',
						'swatchbook',
						'person-swimming',
						'water-ladder',
						'droplet-slash',
						'face-tired',
						'tooth',
						'umbrella-beach',
						'weight-hanging',
						'wine-glass-empty',
						'spray-can-sparkles',
						'apple-whole',
						'atom',
						'bone',
						'book-open-reader',
						'brain',
						'car-rear',
						'car-battery',
						'car-burst',
						'car-side',
						'charging-station',
						'diamond-turn-right',
						'draw-polygon',
						'laptop-code',
						'layer-group',
						'location-crosshairs',
						'lungs',
						'microscope',
						'oil-can',
						'poop',
						'shapes',
						'star-of-life',
						'gauge',
						'gauge-high',
						'gauge-simple',
						'gauge-simple-high',
						'teeth',
						'teeth-open',
						'masks-theater',
						'traffic-light',
						'truck-monster',
						'truck-pickup',
						'rectangle-ad',
						'ankh',
						'book-bible',
						'business-time',
						'city',
						'comment-dollar',
						'comments-dollar',
						'cross',
						'dharmachakra',
						'envelope-open-text',
						'folder-minus',
						'folder-plus',
						'filter-circle-dollar',
						'gopuram',
						'hamsa',
						'bahai',
						'jedi',
						'book-journal-whills',
						'kaaba',
						'khanda',
						'landmark',
						'envelopes-bulk',
						'menorah',
						'mosque',
						'om',
						'spaghetti-monster-flying',
						'peace',
						'place-of-worship',
						'square-poll-vertical',
						'square-poll-horizontal',
						'person-praying',
						'hands-praying',
						'book-quran',
						'magnifying-glass-dollar',
						'magnifying-glass-location',
						'socks',
						'square-root-variable',
						'star-and-crescent',
						'star-of-david',
						'synagogue',
						'scroll-torah',
						'torii-gate',
						'vihara',
						'volume-xmark',
						'yin-yang',
						'blender-phone',
						'book-skull',
						'campground',
						'cat',
						'chair',
						'cloud-moon',
						'cloud-sun',
						'cow',
						'dice-d20',
						'dice-d6',
						'dog',
						'dragon',
						'drumstick-bite',
						'dungeon',
						'file-csv',
						'hand-fist',
						'ghost',
						'hammer',
						'hanukiah',
						'hat-wizard',
						'person-hiking',
						'hippo',
						'horse',
						'house-chimney-crack',
						'hryvnia-sign',
						'mask',
						'mountain',
						'network-wired',
						'otter',
						'ring',
						'person-running',
						'scroll',
						'skull-crossbones',
						'slash',
						'spider',
						'toilet-paper',
						'tractor',
						'user-injured',
						'vr-cardboard',
						'wand-sparkles',
						'wind',
						'wine-bottle',
						'cloud-meatball',
						'cloud-moon-rain',
						'cloud-rain',
						'cloud-showers-heavy',
						'cloud-sun-rain',
						'democrat',
						'flag-usa',
						'hurricane',
						'landmark-dome',
						'meteor',
						'person-booth',
						'poo-storm',
						'rainbow',
						'republican',
						'smog',
						'temperature-high',
						'temperature-low',
						'cloud-bolt',
						'tornado',
						'volcano',
						'check-to-slot',
						'water',
						'baby',
						'baby-carriage',
						'biohazard',
						'blog',
						'calendar-day',
						'calendar-week',
						'candy-cane',
						'carrot',
						'cash-register',
						'minimize',
						'dumpster',
						'dumpster-fire',
						'ethernet',
						'gifts',
						'champagne-glasses',
						'whiskey-glass',
						'earth-europe',
						'grip-lines',
						'grip-lines-vertical',
						'guitar',
						'heart-crack',
						'holly-berry',
						'horse-head',
						'icicles',
						'igloo',
						'mitten',
						'mug-hot',
						'radiation',
						'circle-radiation',
						'restroom',
						'satellite',
						'satellite-dish',
						'sd-card',
						'sim-card',
						'person-skating',
						'person-skiing',
						'person-skiing-nordic',
						'sleigh',
						'comment-sms',
						'person-snowboarding',
						'snowman',
						'snowplow',
						'tenge-sign',
						'toilet',
						'screwdriver-wrench',
						'cable-car',
						'fire-flame-curved',
						'bacon',
						'book-medical',
						'bread-slice',
						'cheese',
						'house-chimney-medical',
						'clipboard-user',
						'comment-medical',
						'crutch',
						'disease',
						'egg',
						'folder-tree',
						'burger',
						'hand-middle-finger',
						'helmet-safety',
						'hospital-user',
						'hotdog',
						'ice-cream',
						'laptop-medical',
						'pager',
						'pepper-hot',
						'pizza-slice',
						'sack-dollar',
						'book-tanakh',
						'bars-progress',
						'trash-arrow-up',
						'trash-can-arrow-up',
						'user-nurse',
						'wave-square',
						'person-biking',
						'border-all',
						'border-none',
						'border-top-left',
						'person-digging',
						'fan',
						'icons',
						'phone-flip',
						'square-phone-flip',
						'photo-film',
						'text-slash',
						'arrow-down-z-a',
						'arrow-up-z-a',
						'arrow-down-short-wide',
						'arrow-up-short-wide',
						'arrow-down-9-1',
						'arrow-up-9-1',
						'spell-check',
						'voicemail',
						'hat-cowboy',
						'hat-cowboy-side',
						'computer-mouse',
						'radio',
						'record-vinyl',
						'walkie-talkie',
						'caravan',
					);
				}
				$count = $this->_getMaxNumItems( $field, $settings['max'] );
				$keys  = array_rand( $this->_icons, min( $count, count( $this->_icons ) ) );
				foreach ( (array) $keys as $key ) {
					$ret[] = 'fas fa-' . $this->_icons[ $key ];
				}
				return empty( $ret ) ? null : $ret;
		}
	}
}
