@php use Illuminate\Support\Carbon; use Illuminate\Support\Str; $tiktokGlyph = ''; $num = fn ($v) => is_null($v) ? '—' : number_format((int) $v); $compact = function ($v) { if ($v === null) return '—'; $v = (int) $v; if ($v >= 1000000) return round($v / 1000000, 1) . 'M'; if ($v >= 1000) return round($v / 1000, 1) . 'K'; return (string) $v; }; $cards = [ ['label' => __('Followers'), 'value' => $kpis['followers'] ?? null, 'sub' => __('total audience')], ['label' => __('Likes'), 'value' => $kpis['likes'] ?? null, 'sub' => __('across all videos')], ['label' => __('Videos'), 'value' => $kpis['videos'] ?? null, 'sub' => __('published')], ['label' => __('Following'), 'value' => $kpis['following'] ?? null, 'sub' => __('accounts')], ]; @endphp
{{-- ===== Header ===== --}}
{{ __('TikTok') }} · {{ __('Analytics') }}

{{ __('Account') }} {{ __('insights') }}

{{ __('Profile stats and your published videos with per-video engagement — live from the TikTok Display API.') }}

@if ($accounts->isEmpty())
{!! $tiktokGlyph !!}

{{ __('No TikTok account connected yet.') }}

{{ __('Connect TikTok') }}
@else {{-- ===== Account identity + switcher (always visible) ===== --}}
@if (!empty($identity['avatar'])) @else {{ strtoupper(mb_substr($identity['name'] ?? 'T', 0, 1)) }} @endif
{{ $identity['name'] ?? $account->open_id }} @if (!empty($identity['verified'])) @endif {{ __('Connected') }}
@if (!empty($identity['username'])){{ '@' . ltrim($identity['username'], '@') }}@endif @if (!empty($identity['bio']))·{{ $identity['bio'] }}@endif
{{ __('Viewing account') }}
@if ($accounts->count() > 1)
{!! $tiktokGlyph !!}
@else {!! $tiktokGlyph !!} {{ $account->display_name ?: ('@' . ltrim((string) $account->username, '@')) }} @endif
{{-- ===== KPI grid ===== --}}
@foreach ($cards as $c)
{{ $c['label'] }}
{{ $num($c['value']) }}
{{ $c['sub'] }}
@endforeach
{{-- ===== Video grid ===== --}}
{{ __('Recent videos') }}
@if ($identity['deeplink'] ?? false) {{ __('Open on TikTok') }} → @endif
@if (empty($videos))
{{ __('No videos found, or the video.list scope was not granted for this account.') }}
@else @endif

{{ __('Live from the TikTok Display API. Video cover images are time-limited by TikTok and refresh on each load.') }}

@endif