<h1>{{ heading_title }}</h1>
<p>{{ text_account_already }}</p>

<form id="form-register" action="{{ register }}" data-on="submit:onSubmit">

  <fieldset id="account">

    <legend>{{ text_your_details }}</legend>

    {% if customer_groups.size > 1 %}
      <div class="row mb-3">
        <label for="input-customer-group" class="col-sm-2 col-form-label">{{ entry_customer_group }}</label>
        <div class="col-sm-10">
          <select name="customer_group_id" id="input-customer-group" class="form-select" data-on="change:onChange" required>
            {% for customer_group in customer_groups %}
              <option value="{{ customer_group.customer_group_id }}"{% if customer_group.customer_group_id == customer_group_id %} selected{% endif %}>{{ customer_group.name }}</option>
            {% endfor %}
          </select>
        </div>
      </div>
    {% endif %}

    <div class="row mb-3">
      <label for="input-firstname" class="col-sm-2 col-form-label">{{ entry_firstname }}</label>
      <div class="col-sm-10">
        <input type="text" name="firstname" value="" placeholder="{{ entry_firstname }}" id="input-firstname" class="form-control" required/>
        <div id="error-firstname" class="invalid-feedback"></div>
      </div>
    </div>

    <div class="row mb-3">
      <label for="input-lastname" class="col-sm-2 col-form-label">{{ entry_lastname }}</label>
      <div class="col-sm-10">
        <input type="text" name="lastname" value="" placeholder="{{ entry_lastname }}" id="input-lastname" class="form-control" required/>
        <div id="error-lastname" class="invalid-feedback"></div>
      </div>
    </div>

    <div class="row mb-3">
      <label for="input-email" class="col-sm-2 col-form-label">{{ entry_email }}</label>
      <div class="col-sm-10">
        <input type="email" name="email" value="" placeholder="{{ entry_email }}" id="input-email" class="form-control" required/>
        <div id="error-email" class="invalid-feedback"></div>
      </div>
    </div>

    {% if config_telephone_status %}
      <div class="row mb-3">
        <label for="input-telephone" class="col-sm-2 col-form-label">{{ entry_telephone }}</label>
        <div class="col-sm-10">
          <input type="tel" name="telephone" value="" placeholder="{{ entry_telephone }}" id="input-telephone" class="form-control"{% if config_telephone_required %} required{% endif %}/>
          <div id="error-telephone" class="invalid-feedback"></div>
        </div>
      </div>
    {% endif %}

    {% for custom_field in custom_fields %}

      {% if custom_field.type == 'select' %}
        <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
          <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
          <div class="col-sm-10">

            <select name="custom_field[{{ custom_field.custom_field_id }}]" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-select">
              <option value="">{{ text_select }}</option>
              {% for custom_field_value in custom_field.custom_field_value %}
                <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option>
              {% endfor %}
            </select>
            <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>

          </div>
        </div>
      {% endif %}

      {% if custom_field.type == 'radio' %}
        <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
          <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
          <div class="col-sm-10">

            <div id="input-custom-field-{{ custom_field.custom_field_id }}">
              {% for custom_field_value in custom_field.custom_field_value %}
                <div class="form-check">
                  <input type="radio" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" id="input-custom-value-{{ custom_field_value.custom_field_value_id }}" class="form-check-input"/>
                  <label for="input-custom-value-{{ custom_field_value.custom_field_value_id }}" class="form-check-label">{{ custom_field_value.name }}</label>
                </div>
              {% endfor %}
            </div>
            <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>

          </div>
        </div>
      {% endif %}

      {% if custom_field.type == 'checkbox' %}
        <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
          <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
          <div class="col-sm-10">
            <div id="input-custom-field-{{ custom_field.custom_field_id }}">
              {% for custom_field_value in custom_field.custom_field_value %}
                <div class="form-check">
                  <input type="checkbox" name="custom_field[{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" id="input-custom-value-{{ custom_field_value.custom_field_value_id }}" class="form-check-input"/>
                  <label for="input-custom-value-{{ custom_field_value.custom_field_value_id }}" class="form-check-label">{{ custom_field_value.name }}</label>
                </div>
              {% endfor %}
            </div>
            <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
          </div>
        </div>
      {% endif %}

      {% if custom_field.type == 'text' %}
        <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
          <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
          <div class="col-sm-10">
            <input type="text" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control"/>
            <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
          </div>
        </div>
      {% endif %}

      {% if custom_field.type == 'textarea' %}
        <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
          <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
          <div class="col-sm-10">
            <textarea name="custom_field[{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control">{{ custom_field.value }}</textarea>
            <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
          </div>
        </div>
      {% endif %}

      {% if custom_field.type == 'file' %}
        <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
          <label class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
          <div class="col-sm-10">
            <div>
              <button type="button" data-oc-toggle="upload" data-oc-url="{{ upload }}" data-oc-size-max="{{ config_file_max_size }}" data-oc-size-error="{{ error_upload_size }}" data-oc-target="#input-custom-field-{{ custom_field.custom_field_id }}" class="btn btn-light"><i class="fa-solid fa-upload"></i> {{ button_upload }}</button>
              <input type="hidden" name="custom_field[{{ custom_field.custom_field_id }}]" value="" id="input-custom-field-{{ custom_field.custom_field_id }}"/>
            </div>
            <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
          </div>
        </div>
      {% endif %}

      {% if custom_field.type == 'date' %}
        <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
          <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
          <div class="col-sm-10">
            <input type="date" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control"/>
            <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
          </div>
        </div>
      {% endif %}

      {% if custom_field.type == 'time' %}
        <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
          <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
          <div class="col-sm-10">
            <input type="time" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control"/>
            <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
          </div>
        </div>
      {% endif %}

      {% if custom_field.type == 'datetime' %}
        <div class="row mb-3 custom-field custom-field-{{ custom_field.custom_field_id }}">
          <label for="input-custom-field-{{ custom_field.custom_field_id }}" class="col-sm-2 col-form-label">{{ custom_field.name }}</label>
          <div class="col-sm-10">
            <input type="datetime-local" name="custom_field[{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-custom-field-{{ custom_field.custom_field_id }}" class="form-control"/>
            <div id="error-custom-field-{{ custom_field.custom_field_id }}" class="invalid-feedback"></div>
          </div>
        </div>
      {% endif %}

    {% endfor %}

  </fieldset>

  <fieldset>
    <legend>{{ text_your_password }}</legend>
    <div class="row mb-3">
      <label for="input-password" class="col-sm-2 col-form-label">{{ entry_password }}</label>
      <div class="col-sm-10">
        <input type="password" name="password" value="" placeholder="{{ entry_password }}" id="input-password" class="form-control" required/>
        <div id="error-password" class="invalid-feedback"></div>
      </div>
    </div>
  </fieldset>

  <fieldset>
    <legend>{{ text_newsletter }}</legend>
    <div class="row mb-3">
      <label class="col-sm-2 col-form-label">{{ entry_newsletter }}</label>
      <div class="col-sm-10">
        <x-switch name="newsletter" value="1" input-id="input-newsletter" input-class="form-switch form-switch-lg"></x-switch>
      </div>
    </div>
  </fieldset>

  {{ captcha }}

  <div class="text-end">

    {% if config_account_id %}
      <x-agree name="agree" value="{{ config_account_id }}" target="#button-continue"></x-agree>
    {% endif %}



    <x-button type="submit" data-bind="button" class="primary">{{ button_continue }}</x-button>

    <button type="submit" id="button-continue" data-bind="test" class="btn btn-primary">{{ button_continue }}</button>
  </div>

</form>

