@if (!$is_sso)
    @if (UserConfig::isSocialMediaLoginEnabled())
        <p>@lang('auth.social_register')</p>
        @include(Theme::viewName('partials.social_login_providers'))
        <p class="mt-5 mb-4">@lang('auth.email_password_register')</p>
    @endif
@else
    <p class="mb-4">@lang('auth.email_password_register_sso')</p>
@endif

<form role="form" method="POST" action="{{ url('/register') }}">
    {{ csrf_field() }}

    <div class="form-group row">
        <label for="name" class="col-md-4 col-form-label text-md-right">@lang('forms.realname_label')</label>

        <div class="col-md-6">
            <input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" value="{{ old('name', $is_sso ? $register_data['name'] : '') }}"{{ !$is_sso ? ' autofocus' : '' }}>

            @if ($errors->has('name'))
                <div class="invalid-feedback">
                    <strong>{{ $errors->first('name') }}</strong>
                </div>
            @endif
        </div>
    </div>

    <div class="form-group row">
        <label for="email" class="col-md-4 col-form-label text-md-right">@lang('forms.email_label')</label>

        <div class="col-md-6">
            @if ($is_sso && !empty($register_data['email']))
                <input type="hidden" name="email" value="{{ $register_data['email'] }}">
                <input id="email" type="email" class="form-control" value="{{ $register_data['email'] }}" readonly>
            @else
                <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email', $is_sso ? $register_data['email'] : '') }}"{{ $is_sso && empty($register_data['email']) ? ' autofocus' : '' }}>
            @endif

            @if ($errors->has('email'))
                <div class="invalid-feedback">
                    <strong>{{ $errors->first('email') }}</strong>
                </div>
            @endif
        </div>
    </div>

    <div class="form-group row">
        <label for="password" class="col-md-4 col-form-label text-md-right">@lang('forms.password_label')</label>

        <div class="col-md-6">
            <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password"{{ $is_sso && !empty($register_data['email']) ? ' autofocus' : '' }}>

            @if ($errors->has('password'))
                <div class="invalid-feedback">
                    <strong>{{ $errors->first('password') }}</strong>
                </div>
            @endif
        </div>
    </div>

    <div class="form-group row">
        <label for="password-confirm" class="col-md-4 col-form-label text-md-right">@lang('forms.password_confirm_label')</label>

        <div class="col-md-6">
            <input id="password-confirm" type="password" class="form-control{{ $errors->has('password_confirmation') ? ' is-invalid' : '' }}" name="password_confirmation">

            @if ($errors->has('password_confirmation'))
                <div class="invalid-feedback">
                    <strong>{{ $errors->first('password_confirmation') }}</strong>
                </div>
            @endif
        </div>
    </div>

    @if (UserConfig::get('recaptcha_enabled_registration'))
        <div class="form-group row">
            @if ($errors->has('recaptcha'))
                <div class="col-md-12">
                    <div class="alert alert-danger">
                        <i class="fa fa-fw fa-warning"></i>
                        {{ $errors->first('recaptcha') }}
                    </div>
                </div>
            @endif

            <div class="col-md-2"><!-- --></div>
            <div class="col-md-8">
                <div class="g-recaptcha" data-sitekey="{{ UserConfig::get('recaptcha_site_key') }}"></div>
            </div>
        </div>
    @endif

    <div class="form-group row">
        <div class="col-md-2"><!-- --></div>
        <div class="col-md-8 text-right">
            <a href="{{ route('home') }}" class="btn btn-link">@lang('forms.cancel_action')</a>
            <button type="submit" class="btn btn-success"><i class="fa fa-fw fa-check"></i> @lang('forms.register_action')</button>
        </div>
    </div>
</form>

@if (UserConfig::get('recaptcha_enabled_registration'))
    @push('scripts')
        <script src="https://www.google.com/recaptcha/api.js"></script>
    @endpush
@endif