@php
// Route the "open" icon to the source-specific detail
// page instead of `/chat` for every row. The id field
// is source-prefixed (`sch-26`, `brd-58`, `camp-12`,
// `inbox-1234`, `auto-7`, `leg-…`) — strip the prefix
// and link to the right module so a scheduled row
// jumps to /scheduled/26, a broadcast jumps to
// /broadcasts/58, etc. Inbox/legacy/auto-reply
// currently live in /chat (no per-message page) so
// they keep the existing destination.
$rid = (string) ($r['id'] ?? '');
$source = (string) ($r['source'] ?? '');
$numeric = preg_replace('/^[a-z]+-/i', '', $rid);
$openHref = match ($source) {
'scheduled' => url('/scheduled/' . $numeric),
'broadcast' => url('/broadcasts/' . $numeric),
'campaign' => url('/wa-campaigns/' . ($r['meta']['campaign_id'] ?? $numeric)),
default => url('/chat'),
};
@endphp
@empty
@include('user.partials.empty-state', [
'message' =>
'No messages match the current filters. Try clearing search or picking a wider date range.',
'resetHref' => url('/message-history'),
])