/* eslint-disable no-multiple-empty-lines */
import AsyncStorage from "@react-native-async-storage/async-storage";
import {getApp, getApps, initializeApp} from "firebase/app";
import {getAuth, initializeAuth} from "firebase/auth";
import {getFirestore, initializeFirestore} from "firebase/firestore";
import {getFunctions} from "firebase/functions";
import {getStorage} from "firebase/storage";
import {getReactNativePersistence} from "./persistence";

export const credentialsDev = {
    apiKey: "AIzaSyBpGWwNsYsitD-yer3bS0jPe1jZgDCvfYI",
    authDomain: "placementt-dev.firebaseapp.com",
    projectId: "placementt-dev",
    storageBucket: "placementt-dev.appspot.com",
    messagingSenderId: "735359304180",
    appId: "1:735359304180:web:0ffd3bb86db13e140339a1",
    measurementId: "G-F34T7Y8YYT"
};

export const credentialsProd = {
    apiKey: "AIzaSyBOSSi4iHxOoAS9tLAJUAC_46HlZ6-D5Ss",
    authDomain: "placementt-dfa17.firebaseapp.com",
    projectId: "placementt-dfa17",
    storageBucket: "placementt-dfa17.appspot.com",
    messagingSenderId: "728019353765",
    appId: "1:728019353765:web:954b5547d62a6dd6a64d4c",
    measurementId: "G-NW5YMC6JN8",
};

console.log(credentialsProd, credentialsDev)

const firebaseConfig = !getApps().length ? initializeApp(credentialsDev) : getApp();

initializeAuth(firebaseConfig, {
    persistence: getReactNativePersistence(AsyncStorage),
});

initializeFirestore(firebaseConfig, {
    ignoreUndefinedProperties: true,
    experimentalAutoDetectLongPolling: true,
});

export const auth = getAuth(firebaseConfig);
export const db = getFirestore(firebaseConfig);
export const functions = getFunctions(firebaseConfig, "europe-west2");
export const storage = getStorage(firebaseConfig);

// connectFunctionsEmulator(functions, "localhost", 5001);


