<input type="hidden" name="total" id="total" value="{{ $comment->total }}"/>
<input type="hidden" name="page" id="page" value="{{ $params->page }}"/>
<input type="hidden" name="per_page" id="perPage" value="{{ $params->perPage }}"/>

@if($comment->total > 0)
    @foreach($comment->list as $row)
    <ul id="comment_{{ $row->id }}" style="margin-left: {{ ($row->depth > 0 ? $row->depth * 25 : 0) }}px;">
        <li class="media">
            @if($row->is_delete)
                @if($row->isBlind)
                    관리자에 의해 차단된 댓글입니다.
                @else
                    작성자에 의해 삭제된 댓글입니다.
                @endif
            @elseif($row->isBlame)
                신고 누적으로 비공개 처리되었습니다. 해당 댓글은 관리자 확인 후 이용규칙에 따라 처리됩니다.
            @else
                @if($boardMeta->show_user_thumb_in_comment)
                    <img src="{{ $row->user->thumb }}" class="media-thumb" width="82" height="82" alt="{{ $row->username }}" onerror="this.src='{{ NO_IMAGE_THUMB_SRC }}'"/>
                @endif
                <div class="media-body">
                    <form name="f_comment_list" id="fCommentList_{{ $row->id }}" accept-charset="UTF-8" autocomplete="off" rel="nofollow">
                        @csrf
                        <input type="hidden" name="bid" value="{{ $row->board_id }}"/>
                        <input type="hidden" name="pid" value="{{ $row->post_id }}"/>
                        <input type="hidden" name="cid" value="{{ $row->id }}"/>
                        <input type="hidden" name="uid" value="{{ $row->user_id }}"/>
                        <input type="hidden" name="username" value="{{ $row->username }}"/>
                        <input type="hidden" name="content" value="{{ $row->content }}"/>
                        <input type="hidden" name="is_secret" value="{{ $row->is_secret }}"/>
                        <dl>
                            <dt>
                                <div class="row">
                                    <div class="col">
                                        <strong>{{ $row->username }}</strong>
                                        <span>{{ $row->createdAt }}</span>
                                        @if($boardMeta->show_comment_ip || IS_ADMIN)
                                            <span>{!! $row->ipAddress !!}</span>
                                        @endif
                                    </div>
                                    <div class="col-auto">
                                        <div class="btn-group">
                                            <button type="button" name="btn_comment_manager" class="btn btn-link dropdown-toggle" aria-expanded="false" data-bs-toggle="dropdown" data-bs-offset="0,5">관리</button>
                                            <div class="dropdown-menu dropdown-menu-end">
                                                @can('update', [$row, $boardMeta])
                                                    <button type="button" name="btn_comment_edit" class="dropdown-item btn-comment-edit">수정</button>
                                                @endcan
                                                @can('delete', [$row, $boardMeta])
                                                    <button type="button" name="btn_comment_delete" class="dropdown-item btn-comment-delete">삭제</button>
                                                @endcan
                                                @if($boardMeta->use_comment_blame)
                                                    <button type="button" name="btn_comment_blame" class="dropdown-item btn-comment-blame" data-bs-toggle="modal" data-bs-target="#commentBlameModal">신고</button>
                                                @endif
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </dt>
                            <dd>
                                <p>
                                    @can('view', $row)
                                        @if($row->is_secret) <i class="fas fa-lock me-1"></i> @endif {!! nl2br($row->content) !!}
                                    @else
                                        <i class="fas fa-lock"></i> <span class="ms-1">비밀글입니다.</span>
                                    @endcan
                                </p>
                            </dd>
                            <dd>
                                @if($boardMeta->use_comment_like)
                                <button type="button" name="btn_comment_like" class="btn-comment-like" value="1" data-active="{{ $row->isLike ? 1 : 0 }}" data-rows="{{ $row->like }}">
                                    @if($row->isLike)
                                        <i class="fas fa-thumbs-up"></i>
                                    @else
                                        <i class="far fa-thumbs-up"></i>
                                    @endif
                                    <span>{{ $row->like }}</span>
                                </button>
                                @endif
                                @if($boardMeta->use_comment_dislike)
                                <button type="button" name="btn_comment_dislike" class="btn-comment-dislike" value="2" data-active="{{ $row->isDislike ? 1 : 0 }}" data-rows="{{ $row->dislike }}">
                                    @if($row->isDislike)
                                        <i class="fas fa-thumbs-down"></i>
                                    @else
                                        <i class="far fa-thumbs-down"></i>
                                    @endif
                                    <span>{{ $row->dislike }}</span>
                                </button>
                                @endif
                                <button type="button" name="btn_comment_reply" class="btn-comment-reply">답글</button>
                            </dd>
                        </dl>
                    </form>
                    <div id="fCommentWrite_{{ $row->id }}"></div>
                </div>
            @endif
        </li>
    </ul>
    <hr/>
    @endforeach

    {{ $comment->list->onEachSide($params->pageCount)->links('board.comment.pagination') }}
@endif

@if($boardMeta->use_comment_blame)
{{-- 신고하기 --}}
<div class="modal fade" id="commentBlameModal" tabindex="-1" aria-labelledby="commentBlameModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header bg-dark text-white">
                <h5 class="modal-title" id="commentBlameModalLabel">댓글 신고하기</h5>
                <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form name="f_comment_blame" id="fCommentBlame" autocomplete="off">
                    <div class="mb-3">
                        <label for="type" class="form-label">신고 유형</label>
                        <select name="type" class="form-select">
                            <option value="">신고 유형을 선택해주세요.</option>
                            @foreach(MAP_BLAME_TYPE as $k => $v)
                                <option value="{{ $k }}">{{ $v }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="mb-3">
                        <label for="reason" class="form-label">신고 내용</label>
                        <textarea name="reason" class="form-control" rows="4" minlength="1" maxlength="1000" placeholder="신고 내용을 상세하게 입력해주세요."></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer justify-content-center">
                <button type="submit" class="btn btn-primary" form="fCommentBlame">확인</button>
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">취소</button>
            </div>
        </div>
    </div>
</div>
@endif

@push('styles')
    <link rel="stylesheet" href="{{ asset('css/desktop/board/comment.css') }}"/>
@endpush

