@php use GletraChatBox\App\Support\SocialVideoParser; use GletraChatBox\App\Models\Status as StatusModel; $msgType = $message->effectiveType(); $meta = $message->metadata ?? []; $isStatusReply = $msgType === 'status_reply' || !empty($meta['status_id']); $isSent = $message->sender_id == auth()->id(); $socialVideos = ($msgType === 'text' && $message->message) ? SocialVideoParser::collect($message->message) : []; $plainMessageText = $socialVideos ? SocialVideoParser::stripSocialUrls($message->message ?? '') : ($message->message ?? ''); @endphp @if($isStatusReply) @php $statusMeta = $meta; $statusOwnerName = $statusMeta['status_owner_name'] ?? 'Status'; $isReaction = ($statusMeta['status_interaction'] ?? 'reply') === 'reaction'; $statusLabel = $isReaction ? ($isSent ? '@ Reacted to '.$statusOwnerName."'s status" : '@ Reacted to your status') : ($isSent ? '@ Reply to '.$statusOwnerName."'s status" : '@ Reply to your status'); $statusType = $statusMeta['status_type'] ?? 'text'; $statusSnippet = match ($statusType) { 'image' => 'Photo', 'video' => 'Video', 'audio' => 'Voice status', default => Str::limit($statusMeta['status_content'] ?? 'Text status', 80), }; $statusPreviewUrl = $statusMeta['status_preview_url'] ?? null; if (! $statusPreviewUrl && ! empty($statusMeta['status_id'])) { $statusModel = StatusModel::query()->find($statusMeta['status_id']); if ($statusModel) { $statusPreviewUrl = $statusModel->replyPreviewUrl(); } } if (! $statusPreviewUrl && $statusType === 'image' && ! empty($statusMeta['status_media_url'])) { $statusPreviewUrl = $statusMeta['status_media_url']; } @endphp @if(!empty($message->sticker_id)) Sticker @elseif(!empty($message->gif_url)) GIF @endif @if($message->message)

{{ $message->message }}

@endif @elseif($msgType === 'sticker') Sticker @elseif($msgType === 'gif') GIF @elseif($msgType === 'contact')
@foreach($meta['contacts'] ?? [] as $contact)
@if(!empty($contact['avatar'])) @else @endif
{{ $contact['name'] ?? 'Contact' }} @if(!empty($contact['phone'])) {{ $contact['phone'] }} @endif
@endforeach
@elseif(in_array($msgType, ['location', 'live_location']))
{{ $meta['label'] ?? 'Location' }} @if($msgType === 'live_location') Live ยท {{ $meta['duration_minutes'] ?? 15 }} min @else {{ number_format($meta['latitude'] ?? 0, 5) }}, {{ number_format($meta['longitude'] ?? 0, 5) }} @endif
@elseif($msgType === 'product') @if(!empty($meta['image'])) @else
@endif
@if(!empty($meta['category'])) {{ $meta['category'] }} @endif {{ $meta['name'] ?? $message->message }} @if(!empty($meta['price_label'])) {{ $meta['price_label'] }} @endif
@elseif($msgType === 'link') @if(!empty($meta['image'])) @else @endif @elseif($msgType === 'poll')
{{ $meta['question'] ?? $message->message }} @foreach($meta['options'] ?? [] as $idx => $option) @php $totals = $meta['totals'] ?? []; $count = $totals[$idx] ?? 0; $totalVotes = max(1, array_sum($totals)); $pct = round(($count / $totalVotes) * 100); @endphp @endforeach
@elseif($msgType === 'call') @php $callMeta = $meta; $isVideo = ($callMeta['call_type'] ?? '') === 'video'; $callStatus = $callMeta['call_status'] ?? 'ended'; $isMissed = in_array($callStatus, ['missed', 'declined', 'cancelled', 'busy'], true); $isOutgoing = ($callMeta['initiator_id'] ?? null) == auth()->id(); @endphp
@php $callLabel = $message->message; $isGenericCallLabel = in_array($callLabel, ['Voice call', 'Video call'], true); @endphp @if(!$isGenericCallLabel) {{ $callLabel }} @endif
@if($selectedUser ?? null) @endif
@elseif($message->isMedia() && $message->media_path) @if($msgType === 'image')
Image
@include('chat.partials.msg-meta', ['message' => $message, 'msgType' => $msgType])
@elseif($msgType === 'video')
@if($message->thumbnail_path) @else @endif
@include('chat.partials.msg-meta', ['message' => $message, 'msgType' => $msgType])
@elseif(in_array($msgType, ['voice', 'voice_note'])) @elseif($msgType === 'audio')
@else
{{ $meta['original_name'] ?? 'Document' }} {{ $meta['file_size_label'] ?? '' }}
@endif @endif @if($socialVideos !== []) @include('chat.partials.social-video-cards', ['videos' => $socialVideos]) @endif @if($plainMessageText && !in_array($msgType, ['sticker', 'gif', 'poll', 'contact', 'location', 'live_location', 'link', 'voice', 'voice_note', 'call', 'status_reply']) && !$isStatusReply)

{{ $plainMessageText }}

@endif