// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getMessaging, getToken, onMessage, isSupported } from "firebase/messaging";

// Your web app's Firebase configuration
const firebaseConfig = {
  apiKey: "AIzaSyAUT0imAg9TczCLklswFQa7x-XMooQj9mA",
  authDomain: "wfc-12.firebaseapp.com",
  projectId: "wfc-12",
  storageBucket: "wfc-12.firebasestorage.app",
  messagingSenderId: "66146494395",
  appId: "1:66146494395:web:128f0bdbc1e39f173e469e"
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);

// Initialize Firebase Cloud Messaging and get a reference to the service
let messaging: any = null;

if (typeof window !== 'undefined') {
  // Only initialize messaging on client side
  isSupported().then((supported) => {
    if (supported) {
      messaging = getMessaging(app);
    }
  });
}

export { app, messaging };

// VAPID key for push notifications
// You need to generate this in Firebase Console: Project Settings > Cloud Messaging > Web Push certificates
// For now, we'll use a placeholder that will be replaced with environment variable
export const VAPID_KEY = process.env.NEXT_PUBLIC_FIREBASE_VAPID_KEY || "BLbgIpvcVG5DBXwn6QVVYMXuNix9RfmGkeJORDEaYrJWyKnozbXtLmSsfAfwm0xfshOk0b6uipKLhXbba3ZV7eU"; // Default key for development

export { getToken, onMessage };
