@extends('admin.layout') @section('title', __('admin.workbench.title').' · '.__('admin.brand')) @section('content')
{{ __('admin.workbench.eyebrow') }}

{{ __('admin.workbench.title') }}

{{ __('admin.workbench.subtitle') }}

{{ __('admin.workbench.manage_providers') }}

{{ __('admin.workbench.search_hint') }}

@if ($query !== '')
@forelse ($providerStates as $provider)
{{ $provider['name'] }}{{ $provider['count'] }} {{ __('admin.workbench.results_short') }}
@empty
{{ __('admin.workbench.no_external_provider') }}
@endforelse

{{ __('admin.workbench.results_title', ['query' => $query]) }}

{{ __('admin.workbench.results_hint') }}

{{ count($results) }} {{ __('admin.workbench.results_short') }}
@if ($results === [])
{{ __('admin.workbench.no_results') }}
@else
@foreach ($results as $result) @php $resultType = in_array($result['entity_type'], ['park','coaster','attraction'], true) ? $result['entity_type'] : 'attraction'; @endphp
{{ strtoupper($resultType) }}

{{ $result['name'] }}

{{ $result['provider_name'] }}

@if (!empty($result['canonical'])) {{ __('admin.workbench.in_database') }} @else {{ __('admin.workbench.external') }} @endif
@if (($result['fields'] ?? []) !== [])
@foreach (array_slice($result['fields'], 0, 6, true) as $field => $value) @if ($value !== null && $value !== '') {{ $field }}{{ is_scalar($value) ? $value : '—' }} @endif @endforeach
@endif
@if (!empty($result['source_url'])) {{ __('admin.workbench.open_source') }} @endif
@csrf @if (!empty($result['canonical'])) @elseif (in_array($resultType, ['attraction','coaster'], true)) @endif
@endforeach
@endif
@endif @if ($mission && $simpleReview) @php $review = $simpleReview['field_review'] ?? []; $missingFields = $simpleReview['missing_fields'] ?? []; $providerReviewStates = $simpleReview['provider_states'] ?? []; $isCompleted = $mission->status === 'completed'; @endphp
{{ __('admin.workbench.review_eyebrow') }}

{{ $mission->target_name }}

{{ $isCompleted ? __('admin.workbench.review_completed_hint') : __('admin.workbench.review_hint') }}

{{ $isCompleted ? __('admin.workbench.saved') : __('admin.workbench.awaiting_review') }}
{{ $mission->stats['providers'] ?? count($providerReviewStates) }}{{ __('admin.workbench.providers_consulted') }}
{{ $mission->stats['fields_found'] ?? 0 }}/{{ $mission->stats['fields_total'] ?? count($review) }}{{ __('admin.workbench.fields_found') }}
{{ $mission->stats['conflicts'] ?? 0 }}{{ __('admin.workbench.conflicts_found') }}
{{ $mission->stats['fields_missing'] ?? count($missingFields) }}{{ __('admin.workbench.fields_missing') }}
@foreach ($providerReviewStates as $provider)
{{ $provider['name'] ?? $provider['code'] }} {{ $provider['count'] ?? 0 }} {{ __('admin.workbench.results_short') }}
@endforeach
@if (!$isCompleted)
@csrf
@foreach ($review as $fieldKey => $row) @php $hasSuggestion = ($row['recommended'] ?? null) !== null && ($row['recommended'] ?? '') !== ''; $confidence = isset($row['confidence']) && is_numeric($row['confidence']) ? (float) $row['confidence'] : null; $currentValue = $row['current'] ?? null; $suggestedValue = $row['recommended'] ?? null; $sameAsCurrent = $currentValue !== null && $suggestedValue !== null && (string) $currentValue === (string) $suggestedValue; $shouldSelect = $hasSuggestion && empty($row['conflict']) && ($currentValue === null || $currentValue === '' || $sameAsCurrent); @endphp @endforeach
{{ __('admin.workbench.use_field') }} {{ __('admin.workbench.field') }} {{ __('admin.workbench.current_value') }} {{ __('admin.workbench.suggested_value') }} {{ __('admin.workbench.best_source') }} {{ __('admin.workbench.confidence') }}
{{ __('admin.enrichment.fields.'.$fieldKey) }} {{ $row['importance'] ?? '' }} @if (!empty($row['conflict'])){{ __('admin.workbench.conflict') }}@endif {{ $currentValue instanceof \DateTimeInterface ? $currentValue->format('Y-m-d') : (is_scalar($currentValue) && $currentValue !== '' ? $currentValue : '—') }} {{ is_scalar($suggestedValue) && $suggestedValue !== '' ? $suggestedValue : '—' }} {{ $row['source_name'] ?? '—' }} @if (!empty($row['source_url']))↗@endif @if (count($row['alternatives'] ?? []) > 1)
{{ __('admin.workbench.other_sources', ['count' => count($row['alternatives']) - 1]) }} @foreach (array_slice($row['alternatives'], 1) as $alternative) {{ $alternative['source_name'] }} {{ $alternative['value'] }} @endforeach
@endif
{{ $confidence !== null ? number_format($confidence * 100, 0).'%' : '—' }}
@else
{{ __('admin.workbench.saved_title') }}

{{ __('admin.workbench.saved_hint', ['count' => $mission->stats['applied_fields'] ?? 0, 'percent' => number_format((float) ($mission->stats['final_completeness'] ?? 0), 0)]) }}

@if (session('workbench_entity_url')) {{ __('admin.workbench.open_database_record') }} @elseif (!empty($simpleReview['canonical_public_id'])) {{ __('admin.workbench.open_database_record') }} @endif
@endif @if ($missingFields !== [])
{{ __('admin.workbench.ai_eyebrow') }}

{{ __('admin.workbench.ai_title') }}

{{ $aiEnabled ? __('admin.workbench.ai_ready_hint') : __('admin.workbench.ai_disabled_hint') }}

@foreach (array_slice($missingFields, 0, 18) as $missing) {{ __('admin.enrichment.fields.'.$missing['field_key']) }} @endforeach
{{ __('admin.workbench.ai_driver', ['driver' => $aiDriver]) }}
@endif
{{ __('admin.workbench.advanced_details') }}
@elseif ($mission)
{{ __('admin.workbench.mission_eyebrow') }}

{{ $mission->target_name }}

{{ __('admin.workbench.mission_hint') }}

{{ __('admin.workbench.plan_ready') }}
{{ $mission->latestAssessment?->overall_percent ?? 0 }}%{{ __('admin.workbench.completeness') }}
{{ $mission->steps->where('step_type', 'provider')->count() }}{{ __('admin.workbench.provider_steps') }}
{{ $mission->steps->where('step_type', 'agent')->count() }}{{ __('admin.workbench.ai_steps') }}
{{ $mission->steps->where('requires_review', true)->count() }}{{ __('admin.workbench.review_steps') }}
{{ __('admin.workbench.advanced_details') }}
@endif @if ($recentMissions->isNotEmpty())

{{ __('admin.workbench.recent_title') }}

{{ __('admin.workbench.recent_hint') }}

@foreach ($recentMissions as $recent) {{ $recent->target_name }}{{ $recent->target_type }} · {{ $recent->created_at?->diffForHumans() }} @endforeach
@endif @endsection