{{ header }}
<section class="container-fluid" id="root" data-info="{{ error_warning }}">

	{% if content_top %}
		{{ content_top }}
	{% endif %}

	{{breadcrumbs}}

	<div class="row">

		<div class="col-md-4 hidden-md-down">
			<div class="content-box js-fixed-on-top">
				{{ account }}
			</div>
		</div>

		<div class="col-xs">
			<div class="content-box">
        <div class="background-base-content">
          <div class="header-card-back">
            <a href="{{ back }}" class="text-small-link">
              <i class="fa-solid fa-arrow-left"></i>
              Voltar
            </a>
          </div>
           <base-content :icon="'fa fa-address-book-o'" title="{{ heading_title }}" subtitle="{{ NickFromValue }}">
            <div style="max-width:780px;">
              <div v-if="loading" class="flex flex-row center-xs padding-large">
                <img src="assets/img/loading-black.svg" alt="Carregando..."/>
              </div>

              <base-alert
                v-show="alert.type"
                :apperance="alert.type"
                @close="alert = {}">
                <span v-html="alert.message"></span>
              </base-alert>

              <validation-observer
                tag="div"
                ref="validationObserver"
                v-slot="{ handleSubmit, invalid }"
                @submit.prevent="onValidationObserverSubmit()">
                <form
                  ref="form"
                  @submit.prevent="handleSubmit(onSubmit)"
                  :action="action"
                  method="post">

                    <div class="row small-space-xs top-margin-medium">
                      <validation-provider
                        tag="div"
                        class="col-xs-12 col-md-6"
                        rules="required"
                        name="firstname"
                        v-slot="{ errors, valid }">
                        <base-input
                          type="text"
                          name="firstname"
                          :label="entry_firstname"
                          :placeholder="entry_firstname_placeholder"
                          v-model="configurations.firstname"
                          :error="errors[0]"
                          :valid="valid"
                          :disabled="disableForm"
                          maxlength="80"
                          mask="alphanumeric"
                          required
                          ></base-input>
                      </validation-provider>
                      <validation-provider
                        tag="div"
                        class="col-xs-12 col-md-6"
                        rules="required"
                        name="lastname"
                        v-slot="{ errors, valid }">
                        <base-input
                          type="text"
                          name="lastname"
                          :label="entry_lastname"
                          :placeholder="entry_lastname_placeholder"
                          v-model="configurations.lastname"
                          :error="errors[0]"
                          :valid="valid"
                          :disabled="disableForm"
                          maxlength="80"
                          mask="alphanumeric"
                          required
                          ></base-input>
                      </validation-provider>
                    </div>

                    <validation-provider
                      tag="div"
                      class="top-margin-medium"
                      rules="required|email"
                      name="email"
                      v-slot="{ errors, valid }">
                      <base-input
                        type="email"
                        name="email"
                        :label="entry_email"
                        :placeholder="entry_email_placeholder"
                        v-model="configurations.email"
                        :error="errors[0]"
                        :valid="valid"
                        :disabled="disableForm"
                        maxlength="80"
                        required
                        ></base-input>
                    </validation-provider>

                    <div class="row small-space-xs top-margin-medium">
                      <validation-provider
                        tag="div"
                        class="col-xs-12 col-md-6"
                        :rules="fields_register_brazil_status_telefone ? 'required' : ''"
                        name="telephone"
                        v-slot="{ errors, valid }">
                        <base-input
                          type="text"
                          name="telephone"
                          :label="entry_telephone"
                          :placeholder="entry_telephone_placeholder"
                          v-model="configurations.telephone"
                          :error="errors[0]"
                          :valid="valid"
                          :disabled="disableForm"
                          mask="telephone"
                          ummask
                          :required="fields_register_brazil_status_telefone"
                          ></base-input>
                      </validation-provider>
                      <validation-provider
                        tag="div"
                        class="col-xs-12 col-md-6"
                        :rules="fields_register_brazil_status_celular ? 'required' : ''"
                        name="celular"
                        v-slot="{ errors, valid }">
                        <base-input
                          type="text"
                          name="celular"
                          label="Celular"
                          :placeholder="entry_celular_placeholder"
                          v-model="configurations.celular"
                          :error="errors[0]"
                          :valid="valid"
                          :disabled="disableForm"
                          mask="cellphone"
                          ummask
                          :required="fields_register_brazil_status_celular"
                          ></base-input>
                      </validation-provider>
                      <validation-provider
                        v-if="feedback_whatsapp"
                        tag="div"
                        class="col-xs-12 col-md-6"
                        rules=""
                        name="feedback_whatsapp_number"
                        v-slot="{ errors, valid }">
                        <base-input
                          type="text"
                          name="feedback_whatsapp_number"
                          :label="entry_whatsapp"
                          :placeholder="entry_whatsapp_placeholder"
                          v-model="configurations.feedback_whatsapp_number"
                          :error="errors[0]"
                          :valid="valid"
                          :disabled="disableForm"
                          mask="cellphone"
                          ummask
                          ></base-input>
                      </validation-provider>
                      <validation-provider
                        v-if="fields_register_brazil_status_telefone2"
                        tag="div"
                        class="col-xs-12 col-md-6"
                        rules=""
                        name="fax"
                        v-slot="{ errors, valid }">
                        <base-input
                          type="text"
                          name="fax"
                          :label="entry_fax"
                          :placeholder="entry_fax_placeholder"
                          v-model="configurations.fax"
                          :error="errors[0]"
                          :valid="valid"
                          :disabled="disableForm"
                          mask="telephone"
                          ummask
                          ></base-input>
                      </validation-provider>
                    </div>

                    <template v-if="configurations.pessoa == tp_fisico">
                      <group-radio label="Sexo" v-if="fields_register_brazil_status_sexo">
                        <div class="flex-inline">
                          <base-radio
                            label="Masculino"
                            name="sexo"
                            v-model="configurations.sexo"
                            value="m"
                            :disabled="disableForm"
                            :inline="true"
                          >
                          </base-radio>
                          <base-radio
                            label="Feminino"
                            name="sexo"
                            v-model="configurations.sexo"
                            value="f"
                            :disabled="disableForm"
                            :inline="true"
                          >
                          </base-radio>
                          <base-radio
                            label="Prefiro não informar"
                            name="sexo"
                            v-model="configurations.sexo"
                            value="o"
                            :disabled="disableForm"
                            :inline="true"
                          >
                          </base-radio>
                        </div>  
                      </group-radio>
                      <validation-provider
                        v-if="fields_register_brazil_status_data_nascimento"
                        tag="div"
                        class="top-margin-medium"
                        :rules="fields_register_brazil_status_data_nascimento_required && configurations.pessoa == 'F' ? 'required|date|date_bigger_than_today' : 'date|date_bigger_than_today'"
                        name="data_nascimento"
                        v-slot="{ errors, valid }">
                        <base-input
                          format="DD/MM/YYYY"
                          type="date"
                          value-type="format"
                          mask="date"
                          name="data_nascimento"
                          label="Data de Nascimento"
                          :placeholder="entry_data_nascimento_placeholder"
                          v-model="configurations.data_nascimento"
                          :error="errors[0]"
                          :valid="valid"
                          :disabled="disableForm"
                          maxlength="32"
                          :required="fields_register_brazil_status_data_nascimento_required"
                          :disabled-date="disabledAfterToday"
                          :error="errors[0]"
                          :valid="valid"
                          :disabled="disableForm"
                        ></base-input>
                      </validation-provider>
                      <div class="row small-space-xs top-margin-medium">
                        <validation-provider
                          tag="div"
                          class="col-xs-12 col-md-6"
                          rules="required"
                          name="cpf"
                          v-slot="{ errors, valid }">
                          <base-input
                            type="text"
                            name="cpf"
                            label="CPF"
                            placeholder="Digite seu CPF"
                            v-model="configurations.cpf"
                            :error="errors[0]"
                            :valid="valid"
                            :disabled="disableForm"
                            mask="cpf"
                            ummask
                            required
                            :readonly="configurations.update != '1'"
                            ></base-input>
                        </validation-provider>
                        <validation-provider
                          v-if="fields_register_brazil_status_rg"
                          tag="div"
                          class="col-xs-12 col-md-6"
                          rules=""
                          name="rg"
                          v-slot="{ errors, valid }">
                          <base-input
                            type="text"
                            name="rg"
                            label="RG"
                            placeholder="Digite seu RG"
                            v-model="configurations.rg"
                            :error="errors[0]"
                            :valid="valid"
                            :disabled="disableForm"
                            maxlength="80"
                            ></base-input>
                        </validation-provider>
                      </div>
                      <input type="hidden" name="pessoa" id="fisica" :value="tp_fisico" checked>

                    </template>
                    <template v-else>
                      <validation-provider
                        tag="div"
                        class="top-margin-medium"
                        rules=""
                        name="razao_social"
                        v-slot="{ errors, valid }">
                        <base-input
                          type="text"
                          name="razao_social"
                          label="Razão Social"
                          placeholder="Digite sua Razão Social"
                          v-model="configurations.razao_social"
                          :error="errors[0]"
                          :valid="valid"
                          :disabled="disableForm"
                          maxlength="80"
                          mask="alphanumeric"
                          ></base-input>
                      </validation-provider>

                      <div class="row small-space-xs top-margin-medium">
                        <validation-provider
                          tag="div"
                          class="col-xs-12 col-md-6"
                          rules="required"
                          name="cnpj"
                          v-slot="{ errors, valid }">
                          <base-input
                            type="text"
                            name="cnpj"
                            label="CNPJ"
                            placeholder="Digite seu CNPJ"
                            v-model="configurations.cnpj"
                            :error="errors[0]"
                            :valid="valid"
                            :disabled="disableForm"
                            mask="cnpj"
                            ummask
                            required
                            readonly
                            ></base-input>
                        </validation-provider>
                        <input type="hidden" name="pessoa" id="juridica" :value="tp_juridico" checked>

                        <validation-provider
                          tag="div"
                          class="col-xs-12 col-md-6"
                          :rules="configurations.contribuinte == 'S' ? 'required' : ''"
                          name="inscricao_estadual"
                          v-slot="{ errors, valid }">
                          <base-input
                            type="text"
                            name="inscricao_estadual"
                            label="Inscrição Estadual"
                            placeholder="Digite sua Inscrição Estadual"
                            v-model="configurations.inscricao_estadual"
                            :error="errors[0]"
                            :valid="valid"
                            :disabled="disableForm"
                            maxlength="30"
                            :required="configurations.contribuinte == 'S'"
                            :readonly="!fields_register_brazil_status_ie_pj"
                            ></base-input>
                        </validation-provider>

                        <validation-provider
                          tag="div"
                          class="col-xs-12 col-md-6"
                          rules=""
                          name="perfil"
                          v-slot="{ errors, valid }">
                            <base-select
                              name="perfil"
                              label="Perfil"
                              v-model="configurations.perfil"
                              :error="errors[0]"
                              :valid="valid"
                              :disabled="disableForm"
                              :readonly="!fields_register_brazil_status_perfil_pj">
                              <option
                                v-for="(value, key) in Type_PerfilCustomerJuridico"
                                :key="key"
                                :value="key"
                              >
                                { value }
                              </option>
                            </base-select>
                        </validation-provider>

                        <validation-provider
                          tag="div"
                          class="col-xs-12 col-md-6"
                          rules=""
                          name="contribuinte"
                          v-slot="{ errors, valid }">
                            <base-select
                              name="contribuinte"
                              :label="text_contribute_icms"
                              v-model="configurations.contribuinte"
                              :error="errors[0]"
                              :valid="valid"
                              :disabled="disableForm"
                              :readonly="!fields_register_brazil_status_contribuinte_pj">
                              <option
                                v-for="(value, key) in Type_PjContribuoIcms"
                                :key="key"
                                :value="key"
                              >
                                { value }
                              </option>
                            </base-select>
                        </validation-provider>
                      </div>  
                    </template>

                    <div class="col-xs-6 col-md-6 top-margin-small">
                      <div class="flex gap-4">
                        <div>
                          <button type="submit" class="btn-base-context" title="Salvar">
                            <i class="fa-solid fa-floppy-disk"></i>
                          </button>
                        </div>
                        <div>
                          <a class="btn-base-context" title="Cancelar" href="{{ back }}">
                            <i class="fa-solid fa-xmark"></i>
                          </a>
                        </div>
                      </div>
							      </div>

                </form>
              </validation-observer>
            </div>
          </base-content>  
        </div>
			</div>
		</div>

		{% if column_right %}
			<div class="col-md-3 hidden-md-down">
				{{ column_right }}
			</div>
		{% endif %}

	</div>

	{% if content_bottom %}
		{{ content_bottom }}
	{% endif %}

</section>

<script>
	window.DATA = {{ dataJs|json_encode() }};
</script>

{{ footer }}