    {{-- analisa fakta --}}
    <div class="card border border-agi-100 rounded-lg  overflow-hidden">
        <div class="card-header light:bg-agi-50">
            <h3 class="card-title uppercase">
                Analisa 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']['fakta_positif']))
                            @foreach ($forminspeksi['fakta']['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']['fakta_negatif']))
                            @foreach ($forminspeksi['fakta']['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']['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">Rute Menuju</label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <textarea class="textarea mt-2" name="rute_menuju" rows="10">{{ old('rute_menuju.0', $forminspeksi['fakta']['rute_menuju'] ?? '') }}</textarea>
                        <em id="error-rute_menuju" 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">Batas Batas</label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <div class="grid grid-cols-1 gap-4 items-center w-full">
                            @if (isset($basicData['arahMataAngin']))
                                @foreach ($basicData['arahMataAngin'] as $item)
                                    @php
                                        $isChecked = in_array(
                                            $item->name,
                                            old('batas_batas', $forminspeksi['fakta']['batas_batas'] ?? []),
                                        );
                                        $inputValue = old(
                                            'batas_batas_input.' . $item->name,
                                            $forminspeksi['fakta']['batas_batas_input'][$item->name] ?? '',
                                        );
                                    @endphp
                                    <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="batas_batas[]" type="checkbox"
                                                value="{{ $item->name }}" {{ $isChecked ? 'checked' : '' }} />
                                            {{ $item->name }}
                                        </label>
                                        <input type="text" name="batas_batas_input[{{ $item->name }}]"
                                            class="input w-full" placeholder="Masukkan Batas {{ $item->name }}..."
                                            value="{{ $inputValue }}">
                                    </div>
                                @endforeach
                            @endif
                        </div>
                        <em id="error-batas_batas" 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 lain terkait lingkungan</label>
                    <div class="flex flex-wrap items-baseline w-full" id="kondisi-lingkungan-container">


                        @if (!empty($forminspeksi['fakta']['kondisi_lingkungan']))
                            @foreach ($forminspeksi['fakta']['kondisi_lingkungan'] as $index => $kondisi_lingkungan)
                                <div class="kondisi_lingkungan flex items-center gap-2 mt-2 textarea-group w-full">
                                    <textarea class="textarea mt-2" name="kondisi_lingkungan[]" rows="10">{{ old("kondisi_lingkungan.$index", $kondisi_lingkungan) }}</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="kondisi_lingkungan flex items-center gap-2 mt-2 textarea-group w-full">
                                <textarea class="textarea mt-2" name="kondisi_lingkungan[]" rows="10" placeholder="Tambahkan keterangan">
                                {{ old('kondisi_lingkungan.0', $forminspeksi['fakta']['kondisi_lingkungan'][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-kondisi_lingkungan" class="alert text-danger text-sm"></em>
                            </div>
                        @endif
                        <button class="btn btn-primary btn-sm mt-5" type="button"
                            onclick="addClonableItem('kondisi-lingkungan-container', 'kondisi_lingkungan')">
                            <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">Kondisi lain terkait Bangunan</label>
                    <div id="kondisi-lain-bangunan-container" class="flex flex-wrap items-baseline w-full">

                        @if (!empty($forminspeksi['fakta']['kondisi_lain_bangunan']))
                            @foreach ($forminspeksi['fakta']['kondisi_lain_bangunan'] as $index => $kondisi_lain_bangunan)
                                <div class="kondisi_lain_bangunan flex items-center gap-2 mt-2 textarea-group w-full">
                                    <textarea class="textarea mt-2" name="kondisi_lain_bangunan[]" rows="10">{{ old("kondisi_lain_bangunan.$index", $kondisi_lain_bangunan) }}</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="kondisi_lain_bangunan flex items-center gap-2 mt-2 textarea-group w-full">
                                <textarea class="textarea mt-2" name="kondisi_lain_bangunan[]" rows="10">{{ old('kondisi_lain_bangunan.0', $forminspeksi['fakta']['kondisi_lain_bangunan'][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-kondisi_lain_bangunan" class="alert text-danger text-sm"></em>
                            </div>
                        @endif
                        <button type="button"
                            onclick="addClonableItem('kondisi-lain-bangunan-container', 'kondisi_lain_bangunan')"
                            class="btn btn-primary btn-sm mt-5 ">
                            <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">Informasi Terkait Dokumen</label>
                    <div id="informasi-dokument-container" class="flex flex-wrap items-baseline w-full">
                        @php
                            $informasi_dokument = isset($forminspeksi['fakta']['informasi_dokument'])
                                ? (array) $forminspeksi['fakta']['informasi_dokument']
                                : [];
                        @endphp

                        @if (!empty($informasi_dokument))

                            @foreach ($informasi_dokument as $index => $document)
                                <div class="informasi_dokument flex items-center gap-2 mt-2 textarea-group w-full">
                                    <textarea class="textarea mt-2" name="informasi_dokument[]" rows="10">{{ old("informasi_dokument.$index", $document) }}</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="informasi_dokument flex items-center gap-2 mt-2 textarea-group w-full">
                                <textarea class="textarea mt-2" name="informasi_dokument[]" rows="10">{{ old('informasi_dokument.0', isset($forminspeksi['fakta']['informasi_dokument'][0]) ? $forminspeksi['fakta']['informasi_dokument'][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-informasi_dokument" class="alert text-danger text-sm"></em>
                            </div>
                        @endif
                        <button class="btn btn-primary btn-sm mt-5" type="button"
                            onclick="addClonableItem('informasi-dokument-container', 'informasi_dokument')">
                            <i class="ki-outline ki-plus"></i>
                        </button>
                    </div>
                </div>


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