<form name="f_comment_write" method="post" accept-charset="UTF-8" autocomplete="off" rel="nofollow">
    @csrf
    <input type="hidden" name="mode" value="write"/>
    <input type="hidden" name="bid" value=""/>
    <input type="hidden" name="pid" value=""/>
    <input type="hidden" name="cid" value=""/>
    <input type="hidden" name="uid" value=""/>
    <input type="hidden" name="length" value="0"/>
    <input type="hidden" name="min_length" value="{{ $boardMeta->comment_min_length }}"/>
    <input type="hidden" name="max_length" value="{{ $boardMeta->comment_max_length }}"/>

    @can('create', ['App\Models\Comment', $boardMeta])
        {{-- 익명 게시판 --}}
        @guest
        <div class="row mb-3">
            <label class="col-auto col-form-label">이름</label>
            <div class="col">
                <input type="text" name="username" class="form-control" value="{{ old('username') }}"/>
            </div>
            <label class="col-auto col-form-label">비밀번호</label>
            <div class="col">
                <input type="password" name="password" class="form-control" value=""/>
            </div>
        </div>
        @endguest
        <textarea name="content" class="form-control comment-content @if($boardMeta->use_personal) tinymce-editor @endif" rows="2" data-autoresize placeholder="{{ $boardMeta->comment_default_content }}"></textarea>
        <div class="row">
            <div class="col">
                @if($boardMeta->comment_max_length)
                    <div class="form-text text-muted text-start">
                        <span class="comment-length">0</span> / {{ $boardMeta->comment_max_length }}
                    </div>
                @endif
            </div>
            <div class="col text-end">
                @auth
                    @if($boardMeta->use_comment_secret == '1')
                        <label class="form-check-label me-3">
                            <input type="checkbox" name="is_secret" class="form-check-input" value="1" @if($boardMeta->use_post_secret_selected == '1') checked @endif />
                            <span class="ms-1">비밀글</span>
                        </label>
                    @endif
                @endauth
                <button type="button" name="btn_comment_submit" class="btn btn-success btn-comment-submit">등록</button>
                <button type="button" name="btn_comment_cancel" class="btn btn-light btn-comment-cancel">취소</button>
            </div>
        </div>
    @else
        <textarea name="content" class="form-control comment-content" rows="2" placeholder="로그인 후 댓글을 입력하실 수 있습니다." readonly data-autoresize></textarea>
    @endcan
</form>

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

@push('scripts')
    @if($boardMeta->use_personal)
    <script>
        {{-- 1:1 문의 게시판은 에디터를 사용한다. --}}
        window.addEventListener('DOMContentLoaded', function () {
            Comment.setInitEditor();
        });
    </script>
    @endif
@endpush
