"use client";
import { useEffect } from "react";
import { useSearchParams } from "next/navigation";
import { useLastAuthMethod } from "./useLastAuthMethod.js";
function useAuthMethodDetector() {
  const searchParams = useSearchParams();
  const { saveAuthMethod } = useLastAuthMethod();
  useEffect(() => {
    const authMethod = searchParams.get("auth_method");
    if (authMethod === "google") {
      saveAuthMethod("google");
      if (typeof window !== "undefined") {
        try {
          const url = new URL(window.location.href);
          url.searchParams.delete("auth_method");
          window.history.replaceState({}, "", url.toString());
        } catch (error) {
        }
      }
    }
  }, [searchParams, saveAuthMethod]);
}
export {
  useAuthMethodDetector
};
