<xf:checkboxrow
	label="{$option.title}"
	hint="{$hintHtml}"
	explain="{$explainHtml}"
	html="{$listedHtml}"
	rowclass="{$rowClass}">

	<xf:option name="{$inputName}[messageEnabled]" selected="$option.option_value.messageEnabled" data-hide="true"
		label="{{ phrase('send_welcome_direct_message_on_registration') }}">

		<xf:dependent>
			<div>{{ phrase('other_participants:') }}</div>
			<xf:if is="$option.option_value.messageParticipants AND is_array($option.option_value.messageParticipants)">
				<xf:set var="$users" value="{{ $xf.app.em.getRepository('XF:User').getUsersByIdsOrdered($option.option_value.messageParticipants) }}" />
				<xf:set var="$value" value="{$users.pluckNamed('username')|join(', ')}" />
			<xf:else />
				<xf:set var="$value">{$xf.visitor.username}</xf:set>
			</xf:if>
			<xf:tokeninput name="{$inputName}[messageParticipants]" value="{$value}" href="{{ link('users/find') }}">
				<xf:explain>{{ phrase('list_usernames_of_users_who_will_be_invited_to_this_direct_message') }}</xf:explain>
			</xf:tokeninput>
		</xf:dependent>

		<xf:dependent>
			<div>{{ phrase('direct_message_title:') }}</div>
			<xf:textbox name="{$inputName}[messageTitle]" value="{$option.option_value.messageTitle}" placeholder="{{ phrase('direct_message_title...') }}" maxlength="100" />
		</xf:dependent>

		<xf:dependent>
			<div>{{ phrase('direct_message_body:') }}</div>
			<xf:textarea name="{$inputName}[messageBody]" value="{$option.option_value.messageBody}" rows="5" autosize="true" />
			<p class="formRow-explain">{{ phrase('following_placeholders_will_be_replaced_in_body_for_direct_message') }} {{ phrase('you_may_also_use_phrase_title_which_will_be_replaced') }}</p>
		</xf:dependent>

		<xf:dependent>
			<div>{{ phrase('direct_message_options:') }}</div>
			<xf:checkbox>
				<xf:option name="{$inputName}[messageOpenInvite]" value="1" selected="$option.option_value.messageOpenInvite">
					{{ phrase('allow_anyone_in_direct_message_to_invite_others') }}
				</xf:option>
				<xf:option name="{$inputName}[messageLocked]" value="1" selected="$option.option_value.messageLocked">
					{{ phrase('lock_direct_message_no_responses_will_be_allowed') }}
				</xf:option>
			</xf:checkbox>
		</xf:dependent>

		<xf:dependent>
			<div>{{ phrase('future_message_handling:') }}</div>
			<xf:radio name="{$inputName}[messageDelete]">
				<xf:option value="delete" selected="!$option.option_value.messageDelete OR $option.option_value.messageDelete == 'delete'"
					label="{{ phrase('leave_direct_message_and_accept_future_responses') }}"
					explain="{{ phrase('should_direct_message_receive_responses_restored_to_inbox') }}" />

				<xf:option value="delete_ignore" selected="$option.option_value.messageDelete == 'delete_ignore'"
					label="{{ phrase('leave_direct_message_and_ignore_future_responses') }}"
					explain="{{ phrase('not_notified_of_responses_direct_message_remain_deleted') }}" />

				<xf:option value="no_delete" selected="$option.option_value.messageDelete == 'no_delete'"
					label="{{ phrase('do_not_leave_direct_message') }}"
					explain="{{ phrase('direct_message_remain_in_inbox_and_notified_of_replies') }}" />
			</xf:radio>
		</xf:dependent>

	</xf:option>

	<xf:option name="{$inputName}[emailEnabled]" selected="$option.option_value.emailEnabled" data-hide="true"
		label="{{ phrase('send_welcome_email_on_registration') }}">

		<xf:dependent>
			<div>{{ phrase('from_name:') }}</div>
			<xf:textbox name="{$inputName}[emailFromName]" value="{{ $option.option_value.emailFromName ? $option.option_value.emailFromName : $xf.options.boardTitle }}" />
		</xf:dependent>

		<xf:dependent>
			<div>{{ phrase('from_email:') }}</div>
			<xf:textbox name="{$inputName}[emailFromEmail]" value="{{ $option.option_value.emailFromEmail ? $option.option_value.emailFromEmail : $xf.options.defaultEmailAddress }}" type="email" />
		</xf:dependent>

		<xf:dependent>
			<div>{{ phrase('email_title:') }}</div>
			<xf:textbox name="{$inputName}[emailTitle]" value="{$option.option_value.emailTitle}" />
		</xf:dependent>

		<xf:dependent>
			<div>{{ phrase('email_format:') }}</div>
			<xf:radio name="{$inputName}[emailFormat]" value="{$option.option_value.emailFormat}">
				<xf:option value="plain" label="{{ phrase('plain_text') }}" selected="!$option.option_value.emailFormat OR $option.option_value.emailFormat == 'plain'" />
				<xf:option value="html" label="{{ phrase('html') }}" />
			</xf:radio>
			<p class="formRow-explain">{{ phrase('note_that_email_clients_handle_html_in_widely_varying_ways') }}</p>
		</xf:dependent>

		<xf:dependent>
			<div>{{ phrase('email_body:') }}</div>
			<xf:textarea name="{$inputName}[emailBody]" value="{$option.option_value.emailBody}" rows="5" autosize="true" />
			<p class="formRow-explain">{{ phrase('following_placeholders_will_be_replaced_in_message_for_welcome_email') }} {{ phrase('you_may_also_use_phrase_title_which_will_be_replaced') }}</p>
		</xf:dependent>
	</xf:option>
</xf:checkboxrow>