@php
    // PRC-816 — Cost-of-sale bağlantı seçici (Expense + RecurringExpense formları ortak).
    // $linkModel: düzenlenen Expense/RecurringExpense ya da null (create).
    $linkModel = $linkModel ?? null;
    $curKey = ($linkModel && $linkModel->linkable_type)
        ? \App\Support\CostOfSale\LinkableResolver::keyForClass($linkModel->linkable_type) : '';
    $curId = $linkModel->linkable_id ?? '';
    $curLabel = ($linkModel && $linkModel->linkable)
        ? \App\Support\CostOfSale\LinkableResolver::label($linkModel->linkable) : '';
@endphp

<div class="col-12">
    <hr class="my-1">
    <label class="form-label fw-semibold mb-2">{{ __('admin/expenses.field_link_section') }}</label>
</div>
<div class="col-md-4">
    <label class="form-label">{{ __('admin/expenses.field_link_type') }}</label>
    <select name="linkable_key" id="linkable_key" class="form-select">
        <option value="">{{ __('admin/expenses.field_link_none') }}</option>
        @foreach($linkableTypeKeys as $k)
            <option value="{{ $k }}" @selected(old('linkable_key', $curKey) === $k)>{{ __('admin/expenses.link_type_'.$k) }}</option>
        @endforeach
    </select>
</div>
<div class="col-md-8">
    <label class="form-label">{{ __('admin/expenses.field_link_target') }}</label>
    <select name="linkable_id" id="linkable_id" class="form-select"
            data-current-id="{{ old('linkable_id', $curId) }}" data-current-label="{{ $curLabel }}">
        @if($curId && $curLabel)
            <option value="{{ $curId }}" selected>{{ $curLabel }}</option>
        @endif
    </select>
    <div id="linkable_reference" class="form-text small text-info mt-1"></div>
</div>
