{{-- /devices when active engine = twilio. Renders the operator's connected Twilio account or the connect form. Mirrors the WABA section's empty-state + card layout so multi-engine workspaces feel consistent when they switch between modes. Vars expected (passed from DevicesController): $twilioAccount — WaProviderConfig row for provider=twilio, or null $twilioAdminDefaults — ['account_sid' => str, 'whatsapp_number' => str] — soft-hint admin-shared creds the user can inherit by leaving fields blank --}} @php $tw = $twilioAccount ?? null; $creds = $tw ? $tw->creds() : []; $sandbox = !empty($tw?->meta_json['sandbox']); $isConnected = $tw && $tw->isConnected(); $defaults = is_array($twilioAdminDefaults ?? null) ? $twilioAdminDefaults : ['account_sid' => '', 'whatsapp_number' => '']; $hasAdminDefaults = $defaults['account_sid'] !== '' && $defaults['whatsapp_number'] !== ''; @endphp
@if (!$isConnected) @if (!empty($multiEngine)) {{-- Multi-engine: NO big connect card on the page. Connect happens via "Add device" → Twilio modal. Just a slim "not connected" line. --}}
{{ __('No Twilio sender connected yet. Click "Add device" above, then choose Twilio.') }}
@else {{-- Single-engine empty state: full inline connect form. --}}
{{ __('Twilio · WhatsApp') }}

{{ __('Connect your Twilio account') }}

@include('user.devices._twilio_form')
@endif @else {{-- Connected — show the account card with disconnect + rotate options. --}}
{{ __('Workspace · Twilio account') }} {{ $sandbox ? __('Sandbox') : __('Production') }} {{ __('connected') }}
@csrf
{{ __('From number') }}
{{ $tw->phone_number ?: '—' }}
{{ __('Account SID') }}
{{ $creds['account_sid'] ? substr($creds['account_sid'], 0, 8) . '…' . substr($creds['account_sid'], -4) : '—' }}
{{ __('Connected at') }}
{{ optional($tw->connected_at)->diffForHumans() ?: '—' }}

{{ __('All broadcasts, campaigns, scheduled sends, auto-replies, and team-inbox replies on this workspace use this Twilio account. Inbound messages from your customers will be received via the Twilio webhook configured in your Twilio console.') }}

@endif