import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

window.Pusher = Pusher;

const cfg = window.reverbConfig ?? {};

window.Echo = new Echo({
    broadcaster:       'reverb',
    key:               cfg.key    ?? import.meta.env.VITE_REVERB_APP_KEY,
    wsHost:            cfg.host   ?? import.meta.env.VITE_REVERB_HOST,
    wsPort:            cfg.port   ?? import.meta.env.VITE_REVERB_PORT ?? 80,
    wssPort:           cfg.port   ?? import.meta.env.VITE_REVERB_PORT ?? 443,
    forceTLS:          cfg.forceTLS ?? false,
    enabledTransports: ['ws', 'wss'],
});
