@use(App\Models\Domain)
@use(App\Models\DomainRegistrar)
@use(App\Models\Service\Domain,ServiceDomain)

<!-- o=Service\Domain::class -->
<div class="row">
	<div class="col-12 col-sm-9 col-md-12 col-xl-7">
		<x-form.domain name="domain" label="Domain Name" :name_value="$o->domain_name" :tld_value="$o->tld_id"/>
	</div>

	<div class="col-12 col-sm-9 col-md-6 col-xl-5">
		<x-leenooks::form.date id="expire_at" name="domain[expire_at]" icon="fa-calendar" label="Expiry" old="domain.expire_at" :value="$o->expire_at?->format('Y-m-d')"/>
	</div>
</div>

<hr>
<p class="h6">Registrar Details</p>

<div class="row">
	<div class="col-12 col-sm-9 col-md-6 col-xl-5">
		<x-leenooks::form.select id="domain_registrar_id" name="domain[domain_registrar_id]" icon="fa-handshake" label="Registrar" :value="$o->domain_registrar_id" :options="DomainRegistrar::active()->orderBy('name')->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
	</div>

	<div class="col-12 col-sm-9 col-md-12 col-xl-6">
		<x-leenooks::form.text id="registrar_account" name="domain[registrar_account]" icon="fa-user-circle" label="Registrar Username" :value="$o->registrar_account"/>
	</div>
</div>

<div class="row">
	<div class="col-12 col-sm-9 col-md-6 col-xl-5">
		<x-leenooks::form.select id="registrar_ns" name="domain[registrar_ns]" icon="fa-project-diagram" label="DNS Location" :value="$o->registrar_ns" :options="ServiceDomain::select('registrar_ns')->distinct()->orderBy('registrar_ns')->get()->map(fn($item)=>['id'=>$item->registrar_ns,'value'=>$item->registrar_ns])"/>
	</div>

	<div class="col-12 col-sm-9 col-md-12 col-xl-6">
		<x-leenooks::form.text id="registrar_username" name="domain[registrar_username]" icon="fa-user" label="Registrar Username" :value="$o->registrar_username"/>
	</div>
</div>

@pa(select2,autofocus)

@section('page-scripts')
	<script type="text/javascript">
		$(document).ready(function() {
			$('#tld_id').select2({
				dropdownAutoWidth: true,
				width: 'style',
			});
		});
	</script>
@append