<div class="card border border-agi-100 bg-white rounded-lg shadow-md overflow-hidden">
    <div class="card-header bg-agi-50">
        <h3 class="card-title uppercase">
            Order Penilaian
        </h3>
        <div class="flex items-center gap-2">
            <a href="{{ url()->previous() }}" class="btn btn-xs btn-info">
                <i class="ki-filled ki-exit-left"></i> Back
            </a>
        </div>
    </div>
    <div class="card-body">
        <div class="grid gap-5 grid-cols-2">

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Tujuan Penilaian</label>
                <div class="flex flex-wrap items-baseline w-full">
                    @if (isset($permohonan->tujuanPenilaian))
                        <p class="text-2sm text-gray-700">{{ $permohonan->tujuanPenilaian->name }}</p>
                    @endif
                </div>
            </div>
            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Tanggal Dibuat</label>
                <div class="flex flex-wrap items-base line w-full">
                    <p class="text-2sm text-gray-700">{{ $permohonan->created_at->format('d/m/Y') }}</p>
                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Cab/Direktorat</label>
                <div class="flex flex-wrap items-baseline w-full">
                    @if (isset($permohonan->branch))
                        <p class="text-2sm text-gray-700">{{ $permohonan->branch->name }}</p>
                    @endif
                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">AO</label>
                <div class="flex flex-wrap items-baseline w-full">
                    @if (isset($permohonan->user))
                        <p class="text-2sm text-gray-700">{{ $permohonan->user->name }}</p>
                    @endif
                </div>
            </div>

        </div>

        <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 mt-5">
            <label class="form-label max-w-56">Tanggal Survey</label>
            <div class="flex flex-wrap items-baseline w-full">
                <input type="date" name="tanggal_survey" class="input"
                    placeholder="Masukkan Hubungan Calon Debitur" value="{{ $forminspeksi['tanggal_survey'] ?? "" }}">
                <em id="error-tanggal_survey" class="alert text-danger text-sm"></em>
            </div>
        </div>
    </div>
</div>



<div class="card border border-agi-100 bg-white rounded-lg shadow-md overflow-hidden">
    <div class="card-header bg-agi-50">
        <h3 class="card-title uppercase">
            Identitas Debitur
        </h3>
    </div>
    <div class="card-body">

        <div class="grid gap-5">

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Nama Calon Debitur</label>
                <div class="flex flex-wrap items-baseline w-full">
                    @if (isset($permohonan->debiture->name))
                        <p class="text-2sm text-gray-700">{{ $permohonan->debiture->name }}</p>
                    @endif
                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Nama Wakil Debitur</label>
                <div class="flex flex-wrap items-baseline w-full">
                    <input type="text" name="nama_wakil" class="input"
                        placeholder="Masukkan Hubungan Calon Debitur" value="{{ $forminspeksi['nama_wakil'] ?? '' }}">

                    <em id="error-nama_wakil" class="alert text-danger text-sm"></em>

                </div>
            </div>
            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Hubungan Calon Debitur</label>
                <div class="flex flex-wrap items-baseline w-full">
                    <input type="text" name="hub_calon_debitur" class="input"
                        placeholder="Masukkan Hubungan Calon Debitur" value="{{$forminspeksi['hub_calon_debitur'] ?? ''}}">

                    <em id="error-hub_calon_debitur" class="alert text-danger text-sm"></em>

                </div>
            </div>
        </div>

        {{-- lokasi jaminan --}}
    </div>
</div>

<div class="card border border-agi-100 rounded-lg shadow-md">
    @include('lpj::surveyor.components.lokasi-jaminan')
</div>


<div class="card border border-agi-100 bg-white rounded-lg shadow-md overflow-hidden">
    <div class="card-header bg-agi-50">
        <h1 class="text-md font-medium text-gray-900 uppercase">Data Data Jaminan</h1>
    </div>
    <div class="card-body">
        <div class="grid gap-5">
            @include('lpj::component.detail-jaminan', ['status' => true])

            @php
                $inputDataJaminan = [
                    [
                        'label' => 'Masa Berlaku STNK',
                        'name' => 'masa_stnk',
                        'index' => 7,
                        'value' => old('masa_stnk', $forminspeksi['masa_stnk'] ?? '')
                    ],
                    [
                        'label' => 'Masa Berlaku Pajak',
                        'name' => 'masa_pajak',
                        'index' => 8,
                        'value' => old('masa_pajak', $forminspeksi['masa_pajak'] ?? '')
                    ],
                ];
            @endphp

            @if (count($inputDataJaminan) > 0)
                @foreach ($inputDataJaminan as $item)
                    <!-- Nomor Lambung -->
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">{{ $item['label'] }}</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <input type="date" name="{{ $item['name'] }}" class="input"
                                placeholder="Masukkan {{ $item['label'] }}" value="{{$item['value'] ?? ''}}">
                                <em id="error-{{ $item['name'] }}" class="alert text-danger text-sm"></em>
                        </div>
                    </div>
                @endforeach
            @endif
        </div>
    </div>
</div>


<div class="card border border-agi-100 bg-white rounded-lg shadow-md overflow-hidden">
    <div class="card-header bg-agi-50">
        <h3 class="card-title uppercase">
            Kondisi Fisik Objek
        </h3>
    </div>
    <div class="card-body">

        <div class="grid gap-5">

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Kendaraan</label>
                <div class="flex flex-wrap items-baseline w-full">
                    <div class="flex flex-col items-start gap-4">
                        @if (isset($basicData['jenisKendaraan']))
                            @foreach ($basicData['jenisKendaraan'] as $item)
                                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                                    <label class="form-label max-w-56 gap-2.5" style="width: 500px">
                                        <input class="checkbox" name="kendaraan[]" type="checkbox"
                                            value="{{ $item->name }}"
                                            {{ in_array($item->name, old('kendaraan', $forminspeksi['kendaraan'] ?? [])) ? 'checked' : '' }} />
                                        {{ $item->name }}
                                    </label>
                                    <input type="text" name="kendaraan_input[]" class="input w-full"
                                        id="kendaraan_input" placeholder="Masukkan {{ $item->name }}..."
                                        value="{{ old('kendaraan_input.' . $loop->index, $forminspeksi['kendaraan_input'][$loop->index] ?? '') }}">
                                </div>
                            @endforeach
                        @endif
                    </div>
                    <em id="error-kendaraan" class="alert text-danger text-sm"></em>
                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Kondisi</label>
                <div class="flex flex-wrap items-baseline w-full">
                    <input type="text" name="kondisi" class="input" placeholder="Masukkan Kondisi" value="{{ $forminspeksi['kondisi'] ?? '' }}">
                        <em id="error-kondisi" class="alert text-danger text-sm"></em>

                </div>
            </div>



            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Nomor polisi</label>
                <div class="mt-2">
                    @if (isset($permohonan->documents))
                        @foreach ($permohonan->documents as $item)
                            @php
                                $details = json_decode($item->detail);
                                $nomo_polisi = isset($details['nomo_polisi']) ? $details['nomo_polisi'] : 'N/A';
                            @endphp
                            <p class="text-2sm text-gray-700">{{ $nomo_polisi }} </p>
                        @endforeach
                    @endif
                    <div class="flex-wrap items-stretch">
                        <div class="flex flex-wrap items-baseline w-full">
                            <div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
                                <label class="form-label flex items-center gap-3 text-nowrap">
                                    <input type="radio" class="radio" name="nomor_polisi" value="sesuai"
                                        onclick="toggleTidakSesuai('nomor_polisi', 'nomor_polis_tidak_sesuai')"
                                        {{ old('nomor_polisi', $forminspeksi['nomor_polisi'] ?? '') == 'sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Sesuai</span>
                                </label>
                                <label class="form-label flex items-center gap-2.5 text-nowrap">
                                    <input type="radio" class="radio" name="nomor_polisi" value="tidak sesuai"
                                        onclick="toggleTidakSesuai('nomor_polisi', 'nomor_polis_tidak_sesuai')"
                                        {{ old('nomor_polisi', $forminspeksi['nomor_polisi'] ?? '') == 'tidak sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Tidak Sesuai</span>
                                </label>
                                <input type="text" name="nomor_polis_tidak_sesuai" id="nomor_polis_tidak_sesuai"
                                    class="input w-full" placeholder="Masukan Nomor polisi"
                                    value="{{ old('nomor_polis_tidak_sesuai', $forminspeksi['nomor_polis_tidak_sesuai'] ?? '') }}"
                                    style="{{ old('nomor_polisi', $forminspeksi['nomor_polisi'] ?? '') == 'tidak sesuai' ? '' : 'display: none;' }}">
                            </div>
                            <em id="error-nomor_polisi" class="alert text-danger text-sm"></em>
                        </div>
                    </div>
                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Merek</label>
                <div class="mt-2">
                    @if (isset($permohonan->documents))
                        @foreach ($permohonan->documents as $item)
                            @php
                                $details = json_decode($item->detail);
                                $merek = isset($details['merek']) ? $details['merek'] : 'N/A';
                            @endphp
                            <p class="text-2sm text-gray-700">{{ $merek }} </p>
                        @endforeach
                    @endif
                    <div class="flex-wrap items-stretch">
                        <div class="flex flex-wrap items-baseline w-full">
                            <div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
                                <label class="form-label flex items-center gap-3 text-nowrap">
                                    <input type="radio" class="radio" name="merek" value="sesuai"
                                        onclick="toggleTidakSesuai('merek', 'merek_tidak_sesuai')"
                                        {{ old('merek', $forminspeksi['merek'] ?? '') == 'sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Sesuai</span>
                                </label>
                                <label class="form-label flex items-center gap-2.5 text-nowrap">
                                    <input type="radio" class="radio" name="merek" value="tidak sesuai"
                                        onclick="toggleTidakSesuai('merek', 'merek_tidak_sesuai')"
                                        {{ old('merek', $forminspeksi['merek'] ?? '') == 'tidak sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Tidak Sesuai</span>
                                </label>
                                <input type="text" name="merek_tidak_sesuai" id="merek_tidak_sesuai"
                                    class="input w-full" placeholder="Masukan Merek"
                                    value="{{ old('merek_tidak_sesuai', $forminspeksi['merek_tidak_sesuai'] ?? '') }}"
                                    style="{{ old('merek', $forminspeksi['merek'] ?? '') == 'tidak sesuai' ? '' : 'display: none;' }}">
                            </div>
                            <em id="error-merek" class="alert text-danger text-sm"></em>
                        </div>
                    </div>
                </div>
            </div>


            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Warna</label>
                <div class="mt-2">
                    @if (isset($permohonan->documents))
                        @foreach ($permohonan->documents as $item)
                            @php
                                $details = json_decode($item->detail);
                                $warna = isset($details['warna']) ? $details['warna'] : 'N/A';
                            @endphp
                            <p class="text-2sm text-gray-700">{{ $warna }} </p>
                        @endforeach
                    @endif
                    <div class="flex-wrap items-stretch">
                        <div class="flex flex-wrap items-baseline w-full">
                            <div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
                                <label class="form-label flex items-center gap-3 text-nowrap">
                                    <input type="radio" class="radio" name="warna" value="sesuai"
                                        onclick="toggleTidakSesuai('warna', 'warna_tidak_sesuai')"
                                        {{ old('warna', $forminspeksi['warna'] ?? '') == 'sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Sesuai</span>
                                </label>
                                <label class="form-label flex items-center gap-2.5 text-nowrap">
                                    <input type="radio" class="radio" name="warna" value="tidak sesuai"
                                        onclick="toggleTidakSesuai('warna', 'warna_tidak_sesuai')"
                                        {{ old('warna', $forminspeksi['warna'] ?? '') == 'tidak sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Tidak Sesuai</span>
                                </label>
                                <input type="text" name="warna_tidak_sesuai" id="warna_tidak_sesuai"
                                    class="input w-full" placeholder="Masukan Warna"
                                    value="{{ old('warna_tidak_sesuai', $forminspeksi['warna_tidak_sesuai'] ?? '') }}"
                                    style="{{ old('warna', $forminspeksi['warna'] ?? '') == 'tidak sesuai' ? '' : 'display: none;' }}">
                            </div>
                            <em id="error-warna" class="alert text-danger text-sm"></em>
                        </div>
                    </div>
                </div>
            </div>


            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Nomor Rangka</label>
                <div class="mt-2">
                    @if (isset($permohonan->documents))
                        @foreach ($permohonan->documents as $item)
                            @php
                                $details = json_decode($item->detail);
                                $nomor_rangka = isset($details['nomor_rangka']) ? $details['nomor_rangka'] : 'N/A';
                            @endphp
                            <p class="text-2sm text-gray-700">{{ $nomor_rangka }} </p>
                        @endforeach
                    @endif
                    <div class="flex-wrap items-stretch">
                        <div class="flex flex-wrap items-baseline w-full">
                            <div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
                                <label class="form-label flex items-center gap-3 text-nowrap">
                                    <input type="radio" class="radio" name="nomor_rangka" value="sesuai"
                                        onclick="toggleTidakSesuai('nomor_rangka', 'nomor_rangka_tidak_sesuai')"
                                        {{ old('nomor_rangka', $forminspeksi['nomor_rangka'] ?? '') == 'sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Sesuai</span>
                                </label>
                                <label class="form-label flex items-center gap-2.5 text-nowrap">
                                    <input type="radio" class="radio" name="nomor_rangka" value="tidak sesuai"
                                        onclick="toggleTidakSesuai('nomor_rangka', 'nomor_rangka_tidak_sesuai')"
                                        {{ old('nomor_rangka', $forminspeksi['nomor_rangka'] ?? '') == 'tidak sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Tidak Sesuai</span>
                                </label>
                                <input type="text" name="nomor_rangka_tidak_sesuai" id="nomor_rangka_tidak_sesuai"
                                    class="input w-full" placeholder="Masukan Nomor Rangka"
                                    value="{{ old('nomor_rangka_tidak_sesuai', $forminspeksi['nomor_rangka_tidak_sesuai'] ?? '') }}"
                                    style="{{ old('nomor_rangka', $forminspeksi['nomor_rangka'] ?? '') == 'tidak sesuai' ? '' : 'display: none;' }}">
                            </div>
                            <em id="error-nomor_rangka" class="alert text-danger text-sm"></em>
                        </div>
                    </div>
                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Nomor Mesin</label>
                <div class="mt-2">
                    @if (isset($permohonan->documents))
                        @foreach ($permohonan->documents as $item)
                            @php
                                $details = json_decode($item->detail);
                                $nomor_mesin = isset($details['nomor_mesin']) ? $details['nomor_mesin'] : 'N/A';
                            @endphp
                            <p class="text-2sm text-gray-700">{{ $nomor_mesin }} </p>
                        @endforeach
                    @endif
                    <div class="flex-wrap items-stretch">
                        <div class="flex flex-wrap items-baseline w-full">
                            <div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
                                <label class="form-label flex items-center gap-3 text-nowrap">
                                    <input type="radio" class="radio" name="nomor_mesin" value="sesuai"
                                        onclick="toggleTidakSesuai('nomor_mesin', 'nomor_mesin_tidak_sesuai')"
                                        {{ old('nomor_mesin', $forminspeksi['nomor_mesin'] ?? '') == 'sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Sesuai</span>
                                </label>
                                <label class="form-label flex items-center gap-2.5 text-nowrap">
                                    <input type="radio" class="radio" name="nomor_mesin" value="tidak sesuai"
                                        onclick="toggleTidakSesuai('nomor_mesin', 'nomor_mesin_tidak_sesuai')"
                                        {{ old('nomor_mesin', $forminspeksi['nomor_mesin'] ?? '') == 'tidak sesuai' ? 'checked' : '' }}>
                                    <span class="ml-2">Tidak Sesuai</span>
                                </label>
                                <input type="text" name="nomor_mesin_tidak_sesuai" id="nomor_mesin_tidak_sesuai"
                                    class="input w-full" placeholder="Masukan Nomor Mesin"
                                    value="{{ old('nomor_mesin_tidak_sesuai', $forminspeksi['nomor_mesin_tidak_sesuai'] ?? '') }}"
                                    style="{{ old('nomor_mesin', $forminspeksi['nomor_mesin'] ?? '') == 'tidak sesuai' ? '' : 'display: none;' }}">
                            </div>
                            <em id="error-nomor_mesin" class="alert text-danger text-sm"></em>
                        </div>
                    </div>
                </div>
            </div>



            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Posisi Kilometer</label>
                <div class="flex flex-wrap items-baseline w-full">
                    <input type="text" name="posisi_kilometer" class="input" placeholder="Posisi Kilometer" value="{{ $forminspeksi['posisi_kilometer'] ?? '' }}">

                    <em id="error-posisi_kilometer" class="alert text-danger text-sm"></em>
                </div>
            </div>

            @php
                $inputDataJaminan = [
                    [
                        'label' => 'Transmisi',
                        'value' => ['Otomatis', 'Manual'],
                        'name' => 'transmisi',
                        'index' => 0,
                    ],
                    [
                        'label' => 'Mesin dan panel Instrument',
                        'value' => ['Terawat', 'Cukup Terawat', 'Tidak Terawat'],
                        'name' => 'mesin_panel_instrument',
                        'index' => 1,
                    ],
                    [
                        'label' => 'Fungsi Mesin dan panel Instument',
                        'value' => ['Berfungsi', 'Rusak'],
                        'name' => 'fungsi_mesin_panel_instrument',
                        'index' => 2,
                    ],
                    [
                        'label' => 'Interior',
                        'value' => ['Terawat', 'Cukup Terawat', 'Tidak Terawat'],
                        'name' => 'interior',
                        'index' => 3,
                    ],
                    [
                        'label' => 'Jumlah pintu',
                        'value' => ['Dua Pintu', 'Empat Pintu', 'Lain-Lain'],
                        'name' => 'jumlah_pintu',
                        'index' => 4,
                    ],
                    [
                        'label' => 'Rangka dan karoseri',
                        'value' => ['Terawat', 'Cukup Terawat', 'Tidak Terawat'],
                        'name' => 'rangka_karoseri',
                        'index' => 5,
                    ],
                    [
                        'label' => 'Ban',
                        'value' => ['Standard', 'Tidak Standard'],
                        'name' => 'ban',
                        'index' => 6,
                    ],
                    [
                        'label' => 'Velg',
                        'value' => ['Standard', 'Tidak Standard'],
                        'name' => 'velg',
                        'index' => 7,
                    ],
                    [
                        'label' => 'Bamper Depan',
                        'value' => ['Terawat', 'Cukup Terawat', 'Tidak Terawat'],
                        'name' => 'bamper_depan',
                        'index' => 8,
                    ],
                    [
                        'label' => 'Bamper Belakang',
                        'value' => ['Terawat', 'Cukup Terawat', 'Tidak Terawat'],
                        'name' => 'bamper_belakang',
                        'index' => 9,
                    ],
                    [
                        'label' => 'Lampu depan',
                        'value' => ['Terawat', 'Cukup Terawat', 'Tidak Terawat'],
                        'name' => 'lampu_depan',
                        'index' => 10,
                    ],
                    [
                        'label' => 'Lampu belakang',
                        'value' => ['Terawat', 'Cukup Terawat', 'Tidak Terawat'],
                        'name' => 'lampu_belakang',
                        'index' => 11,
                    ],
                    [
                        'label' => 'Kaca kendaraan',
                        'value' => ['Terawat', 'Cukup Terawat', 'Tidak Terawat'],
                        'name' => 'kaca_kendaraan',
                        'index' => 12,
                    ],
                    [
                        'label' => 'Air Conditioner',
                        'value' => ['Ada', 'Tidak Ada'],
                        'name' => 'air_conditioner',
                        'index' => 13,
                    ],
                    [
                        'label' => 'Tape/Radio/CD dan perlengkapan (Equalizer, Booster, dll)',
                        'value' => ['Ada', 'Tidak Ada'],
                        'name' => 'tape_radio_cd',
                        'index' => 14,
                    ],
                    [
                        'label' => 'Sensor parkir',
                        'value' => ['Ada', 'Tidak Ada'],
                        'name' => 'sensor_parkir',
                        'index' => 15,
                    ],
                    [
                        'label' => 'Sensor Camera (360), Recorder',
                        'value' => ['Ada', 'Tidak Ada'],
                        'name' => 'sensor_camera_recorder',
                        'index' => 16,
                    ],
                    [
                        'label' => 'Lcd',
                        'value' => ['Ada', 'Tidak Ada'],
                        'name' => 'lcd',
                        'index' => 17,
                    ],
                    [
                        'label' => 'Sabuk Keselamatan',
                        'value' => ['Ada', 'Tidak Ada'],
                        'name' => 'sabuk_keselamatan',
                        'index' => 18,
                    ],
                    [
                        'label' => 'Airbag',
                        'value' => ['Ada', 'Tidak Ada'],
                        'name' => 'airbag',
                        'index' => 19,
                    ],
                    [
                        'label' => 'Asuransi',
                        'value' => ['Ada', 'Tidak Ada'],
                        'name' => 'asuransi',
                        'index' => 20,
                    ],
                ];
            @endphp

            @if (count($inputDataJaminan) > 0)
                @foreach ($inputDataJaminan as $item)
                    <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                        <label class="form-label max-w-56">{{ $item['label'] }}</label>
                        <div class="flex flex-wrap items-baseline w-full">
                            <div class="flex flex-col items-start gap-4">
                                @if (isset($item['value']))
                                    @foreach ($item['value'] as $value)
                                        <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                                            <label class="form-label max-w-56 gap-2.5" style="width: 500px">
                                                <input class="checkbox" name="{{ $item['name'] }}[]" type="checkbox"
                                                    value="{{ $value }}"
                                                    {{ in_array($value, old($item['name'], $forminspeksi[$item['name']] ?? [])) ? 'checked' : '' }} />
                                                {{ $value }}
                                            </label>
                                            <input type="text" name="{{ $item['name'] }}_input[]"
                                                class="input w-full"
                                                id="bentukTanahInput-{{ $loop->parent->index }}-{{ $loop->index }}"
                                                placeholder="Masukkan {{ $value }}..."
                                                value="{{ old($item['name'] . '_input.' . $loop->index, $forminspeksi[$item['name'] . '_input'][$loop->index] ?? '') }}">
                                        </div>
                                    @endforeach
                                @endif
                            </div>
                            <div class="w-full">
                                <em id="error-{{ $item['name'] }}" class="alert text-danger text-sm"></em>
                                <em id="error-{{ $item['name'] }}-input-{{ $loop->index }}"
                                    class="alert text-danger text-sm"></em>
                            </div>
                        </div>
                    </div>
                @endforeach
            @endif


            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Perusahaan Asuransi</label>
                <div class="flex flex-wrap items-baseline w-full">
                    <input type="text" name="perusahaan_asuransi" class="input"
                        placeholder="Pesurahaan Asuransi" value="{{ $forminspeksi['perusahaan_asuransi'] ?? '' }}">
                    <em class="alert text-danger text-sm"></em>

                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Tahun Berakhir</label>
                <div class="flex flex-wrap items-baseline w-full">
                    <input type="date" name="tahun_berakhir" class="input" placeholder="Tahun berakhir" value="{{ $forminspeksi['tahun_berakhir'] ?? "" }}">
                    <em class="alert text-danger text-sm"></em>

                </div>
            </div>
        </div>
    </div>
</div>


<div class="card border border-agi-100 bg-white rounded-lg  overflow-hidden">
    <div class="card-header bg-agi-50">
        <h3 class="card-title uppercase">
            Analisis Fakta
        </h3>
    </div>
    <div class="card-body">
        <div class="grid gap-5">
            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Faktor Positif</label>
                <div id="fakta-positif-container" class="flex flex-wrap items-baseline w-full">
                    @if (!empty($forminspeksi['fakta_positif']))
                        @foreach ($forminspeksi['fakta_positif'] as $index => $positif)
                            <div class="fakta_positif flex items-center gap-2 mt-2 textarea-group w-full">
                                <textarea class="textarea mt-2" name="fakta_positif[]" rows="10">{{ old("fakta_positif.$index", $positif) }}</textarea>
                                <button class="btn btn-danger btn-sm remove-btn" type="button"
                                    style="display: none;">
                                    <i class="ki-outline ki-trash"></i>
                                </button>
                            </div>
                        @endforeach
                    @else
                        <div class="fakta_positif flex items-center gap-2 mt-2 textarea-group w-full">
                            <textarea class="textarea mt-2" name="fakta_positif[]" rows="10">{{ old('fakta_positif.0', '') }}</textarea>
                            <button class="btn btn-danger btn-sm remove-btn" type="button" style="display: none;">
                                <i class="ki-outline ki-trash"></i>
                            </button>
                        </div>
                    @endif
                    <button type="button" class="btn btn-primary btn-sm mt-5"
                        onclick="addClonableItem('fakta-positif-container', 'fakta_positif')">
                        <i class="ki-outline ki-plus"></i>
                    </button>
                </div>
            </div>


            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Faktor Negatif</label>
                <div id="fakta-negatif-container" class="flex flex-wrap items-baseline w-full">

                    @if (!empty($forminspeksi['fakta_negatif']))
                        @foreach ($forminspeksi['fakta_negatif'] as $index => $negatif)
                            <div class="fakta_negatif flex items-center gap-2 mt-2 textarea-group w-full">
                                <textarea class="textarea mt-2" name="fakta_negatif[]" rows="10">{{ old("fakta_negatif.$index", $negatif) }}</textarea>
                                <button class="btn btn-danger btn-sm remove-btn" type="button"
                                    style="display: none;">
                                    <i class="ki-outline ki-trash"></i>
                                </button>
                            </div>
                        @endforeach
                    @else
                        <div class="fakta_negatif flex items-center gap-2 mt-2 textarea-group w-full">
                            <textarea class="textarea mt-2" name="fakta_negatif[]" rows="10">{{ old('fakta_negatif.0', $forminspeksi['fakta_negatif'][0] ?? '') }}</textarea>
                            <button class="btn btn-danger btn-sm remove-btn" type="button" style="display: none;">
                                <i class="ki-outline ki-trash"></i>
                            </button>
                            <em id="error-fakta_negatif" class="alert text-danger text-sm"></em>
                        </div>
                    @endif
                    <button type="button" class="btn btn-primary btn-sm mt-5"
                        onclick="addClonableItem('fakta-negatif-container', 'fakta_negatif')">
                        <i class="ki-outline ki-plus"></i>
                    </button>
                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Analisa makro</label>
                <div id="analisa_makro-container" class="flex flex-wrap items-baseline w-full">

                    @if (!empty($forminspeksi['analisa_makro']))
                        @foreach ($forminspeksi['analisa_makro'] as $index => $negatif)
                            <div class="analisa_makro flex items-center gap-2 mt-2 textarea-group w-full">
                                <textarea class="textarea mt-2" name="analisa_makro[]" rows="10">{{ old("analisa_makro.$index", $negatif) }}</textarea>
                                <button class="btn btn-danger btn-sm remove-btn" type="button"
                                    style="display: none;">
                                    <i class="ki-outline ki-trash"></i>
                                </button>
                            </div>
                        @endforeach
                    @else
                        <div class="analisa_makro flex items-center gap-2 mt-2 textarea-group w-full">
                            <textarea class="textarea mt-2" name="analisa_makro[]" rows="10">{{ old('analisa_makro.0', $forminspeksi['analisa_makro'][0] ?? '') }}</textarea>
                            <button class="btn btn-danger btn-sm remove-btn" type="button" style="display: none;">
                                <i class="ki-outline ki-trash"></i>
                            </button>
                            <em id="error-analisa_makro" class="alert text-danger text-sm"></em>
                        </div>
                    @endif
                    <button type="button" class="btn btn-primary btn-sm mt-5"
                        onclick="addClonableItem('analisa_makro-container', 'analisa_makro')">
                        <i class="ki-outline ki-plus"></i>
                    </button>
                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Kesimpulan</label>
                <div id="kesimpulan-container" class="flex flex-wrap items-baseline w-full">
                    @if (!empty($forminspeksi['kesimpulan']))
                        @foreach ($forminspeksi['kesimpulan'] as $index => $negatif)
                            <div class="kesimpulan flex items-center gap-2 mt-2 textarea-group w-full">
                                <textarea class="textarea mt-2" name="kesimpulan[]" rows="10">{{ old("kesimpulan.$index", $negatif) }}</textarea>
                                <button class="btn btn-danger btn-sm remove-btn" type="button"
                                    style="display: none;">
                                    <i class="ki-outline ki-trash"></i>
                                </button>
                            </div>
                        @endforeach
                    @else
                        <div class="kesimpulan flex items-center gap-2 mt-2 textarea-group w-full">
                            <textarea class="textarea mt-2" name="kesimpulan[]" rows="10">{{ old('kesimpulan.0', $forminspeksi['kesimpulan'][0] ?? '') }}</textarea>
                            <button class="btn btn-danger btn-sm remove-btn" type="button" style="display: none;">
                                <i class="ki-outline ki-trash"></i>
                            </button>
                            <em id="error-kesimpulan" class="alert text-danger text-sm"></em>
                        </div>
                    @endif
                    <button type="button" class="btn btn-primary btn-sm mt-5"
                        onclick="addClonableItem('kesimpulan-container', 'kesimpulan')">
                        <i class="ki-outline ki-plus"></i>
                    </button>
                </div>
            </div>

            <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                <label class="form-label max-w-56">Kesimpulan</label>
                <div id="catatan-container" class="flex flex-wrap items-baseline w-full">
                    @if (!empty($forminspeksi['catatan']))
                        @foreach ($forminspeksi['catatan'] as $index => $negatif)
                            <div class="catatan flex items-center gap-2 mt-2 textarea-group w-full">
                                <textarea class="textarea mt-2" name="catatan[]" rows="10">{{ old("catatan.$index", $negatif) }}</textarea>
                                <button class="btn btn-danger btn-sm remove-btn" type="button"
                                    style="display: none;">
                                    <i class="ki-outline ki-trash"></i>
                                </button>
                            </div>
                        @endforeach
                    @else
                        <div class="catatan flex items-center gap-2 mt-2 textarea-group w-full">
                            <textarea class="textarea mt-2" name="catatan[]" rows="10">{{ old('catatan.0', $forminspeksi['catatan'][0] ?? '') }}</textarea>
                            <button class="btn btn-danger btn-sm remove-btn" type="button" style="display: none;">
                                <i class="ki-outline ki-trash"></i>
                            </button>
                            <em id="error-catatan" class="alert text-danger text-sm"></em>
                        </div>
                    @endif
                    <button type="button" class="btn btn-primary btn-sm mt-5"
                        onclick="addClonableItem('catatan-container', 'catatan')">
                        <i class="ki-outline ki-plus"></i>
                    </button>
                </div>
            </div>

        </div>
    </div>
</div>
