@version(2)
@load('./lang')
<article class="hrb-read">

	<header class="hrb-read-head">
		<h1 class="hrb-read-title">
			@if ($oDocument->isNotice())<span class="hrb-read-badge">{{ $lang->notice ?? $lang->hrb_notice }}</span>@endif
			@if (($module_info->use_category ?? 'N') === 'Y' && $oDocument->get('category_srl') && isset($category_list[$oDocument->get('category_srl')]))
			<a class="hrb-read-badge is-cat" href="{{ getUrl('category', $oDocument->get('category_srl'), 'document_srl', '', 'page', '') }}">{{ $category_list[$oDocument->get('category_srl')]->title }}</a>
			@endif
			@if ($oDocument->isSecret())<svg class="hrb-ico" viewBox="0 0 16 16" aria-label="{{ $lang->hrb_secret }}"><path d="M4 7V5a4 4 0 1 1 8 0v2h.5A1.5 1.5 0 0 1 14 8.5v5A1.5 1.5 0 0 1 12.5 15h-9A1.5 1.5 0 0 1 2 13.5v-5A1.5 1.5 0 0 1 3.5 7H4zm1.5 0h5V5a2.5 2.5 0 0 0-5 0v2z"/></svg>@endif
			{{ $oDocument->getTitleText() }}
		</h1>

		@php
		$hrb_photo_on = ($module_info->hr_show_photo ?? 'Y') === 'Y';
		$hrb_sign_on = ($module_info->hr_show_sign ?? 'Y') === 'Y';
		$hrb_author_photo = $hrb_photo_on ? $oDocument->getProfileImage() : '';
		@endphp
		<div class="hrb-read-meta">
			<span class="hrb-read-author">
				@if ($hrb_author_photo)<img class="hrb-photo" src="{{ $hrb_author_photo }}" alt="" />@endif
				@if ($oDocument->get('member_srl') > 0)
				<a href="#popup_menu_area" class="member_{{ $oDocument->get('member_srl') }}" onclick="return false">{{ $oDocument->getNickName() }}</a>
				@else
				{{ $oDocument->getNickName() }}
				@endif
			</span>
			<span>{{ $oDocument->getRegdate('Y.m.d H:i') }}</span>
			<span>{{ $lang->readed_count ?? $lang->hrb_read_count }} {{ number_format($oDocument->get('readed_count')) }}</span>
			@if ($oDocument->get('voted_count'))<span>{{ $lang->voted_count ?? $lang->hrb_vote }} {{ number_format($oDocument->get('voted_count')) }}</span>@endif
			@if ($is_logged)
			<a href="#popup_menu_area" class="document_{{ $oDocument->document_srl }} hrb-read-more" onclick="return false" title="{{ $lang->cmd_document_do ?? $lang->hrb_doc_menu }}">&#8943;</a>
			@endif
		</div>
	</header>

	@if (!$oDocument->isAccessible())
	<div class="hrb-secret">
		<form action="./" method="get" onsubmit="return procFilter(this, input_password)">
			<input type="hidden" name="mid" value="{{ $mid }}" />
			<input type="hidden" name="page" value="{{ $page }}" />
			<input type="hidden" name="document_srl" value="{{ $oDocument->document_srl }}" />
			<p>{{ $lang->msg_is_secret }} {{ $lang->msg_input_password }}</p>
			<div class="hrb-secret-row">
				<input type="password" name="password" required autofocus />
				<button type="submit" class="hr-btn hr-btn-primary">{{ $lang->cmd_input }}</button>
			</div>
		</form>
	</div>
	@else

	<div class="hrb-content rhymix_content Zittme_content">{!! $oDocument->getContent(false) !!}</div>

	@php $hrb_sign = $hrb_sign_on ? $oDocument->getSignature() : ''; @endphp
	@if ($hrb_sign)
	<div class="hrb-sign">
		@if ($hrb_author_photo)<img class="hrb-sign-photo" src="{{ $hrb_author_photo }}" alt="" />@endif
		<div class="hrb-sign-body">
			<strong class="hrb-sign-name">{{ $oDocument->getNickName() }}</strong>
			<div class="hrb-sign-text">{!! $hrb_sign !!}</div>
		</div>
	</div>
	@endif

	@if ($oDocument->isExtraVarsExists())
	<dl class="hrb-extras">
		@foreach ($oDocument->getExtraVars() as $hrb_ev)
		@if ($hrb_ev->hasValue())
		<div class="hrb-extra-row">
			<dt>{{ $hrb_ev->name }}</dt>
			<dd>{!! $hrb_ev->getValueHTML() !!}</dd>
		</div>
		@endif
		@endforeach
	</dl>
	@endif

	@if ($oDocument->hasUploadedFiles() && ($module_info->hr_show_files ?? 'Y') === 'Y')
	<div class="hrb-files">
		<strong>{{ $lang->uploaded_file ?? $lang->hrb_attach }} <em>{{ $oDocument->get('uploaded_count') }}</em></strong>
		<ul>
			@foreach ($oDocument->getUploadedFiles() as $hrb_file)
			<li>
				<a href="{{ getUrl('') }}{{ $hrb_file->download_url }}">{{ $hrb_file->source_filename }}</a>
				<span class="hrb-file-size">{{ FileHandler::filesize($hrb_file->file_size) }} · {{ number_format($hrb_file->download_count) }}</span>
			</li>
			@endforeach
		</ul>
	</div>
	@endif

	@if ($oDocument->get('tag_list'))
	<div class="hrb-tags">
		@foreach ($oDocument->get('tag_list') as $hrb_tag)
		<a class="hr-chip" href="{{ getUrl('', 'mid', $mid, 'search_target', 'tag', 'search_keyword', $hrb_tag) }}">#{{ $hrb_tag }}</a>
		@endforeach
	</div>
	@endif

	@php
	$hrb_vote_up_on = ($module_info->hr_use_vote_up ?? 'Y') === 'Y' && ($board_features->document->vote_up ?? false);
	$hrb_vote_down_on = ($module_info->hr_use_vote_down ?? 'N') === 'Y' && ($board_features->document->vote_down ?? false);
	@endphp
	@if ($hrb_vote_up_on || $hrb_vote_down_on)
	<div class="hrb-vote">
		@if ($hrb_vote_up_on)
			@php $hrb_voted_up = $oDocument->getMyVote() !== false && $oDocument->getMyVote() > 0; @endphp
			<button type="button" class="hrb-vote-btn is-up @if ($hrb_voted_up) is-voted @endif"
				onclick="doCallModuleAction('document','{{ $hrb_voted_up ? 'procDocumentVoteUpCancel' : 'procDocumentVoteUp' }}','{{ $oDocument->document_srl }}');return false;">
				<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 3.2 4.6 10.4h4.2V20h6.4v-9.6h4.2L12 3.2z"/></svg>
				<span>{{ $lang->cmd_vote ?? $lang->hrb_vote }}</span>
				<b>{{ number_format($oDocument->get('voted_count')) }}</b>
			</button>
		@endif
		@if ($hrb_vote_down_on)
			@php $hrb_voted_down = $oDocument->getMyVote() !== false && $oDocument->getMyVote() < 0; @endphp
			<button type="button" class="hrb-vote-btn is-down @if ($hrb_voted_down) is-voted @endif"
				onclick="doCallModuleAction('document','{{ $hrb_voted_down ? 'procDocumentVoteDownCancel' : 'procDocumentVoteDown' }}','{{ $oDocument->document_srl }}');return false;">
				<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 20.8l7.4-7.2h-4.2V4H8.8v9.6H4.6L12 20.8z"/></svg>
				<span>{{ $lang->cmd_vote_down ?? $lang->hrb_unvote }}</span>
				<b>{{ number_format($oDocument->get('blamed_count')) }}</b>
			</button>
		@endif
	</div>
	@endif

	@endif

	<div class="hrb-read-actions">
		<a class="hr-btn" href="{{ getUrl('document_srl', '') }}">{{ $lang->cmd_list ?? $lang->hrb_list }}</a>
		<span class="hrb-read-actions-right">
			@if ($oDocument->isEditable())
			<a class="hr-btn" href="{{ getUrl('act', 'dispBoardWrite', 'document_srl', $oDocument->document_srl) }}">{{ $lang->cmd_modify ?? $lang->hrb_modify }}</a>
			@endif
			@if ($oDocument->isGranted())
			<a class="hr-btn" href="{{ getUrl('act', 'dispBoardDelete', 'document_srl', $oDocument->document_srl) }}">{{ $lang->cmd_delete ?? $lang->hrb_delete }}</a>
			@endif
			@if ($grant->write_document)
			<a class="hr-btn hr-btn-primary" href="{{ getUrl('act', 'dispBoardWrite', 'document_srl', '') }}">{{ $lang->cmd_write ?? $lang->hrb_write }}</a>
			@endif
		</span>
	</div>

</article>
