import { useState, useEffect } from "react";

export function useParentWindow() {
  const [isBrightSign, setIsBrightSign] = useState(false);
  const [isDeviceAPIAvailable, setIsDeviceAPIAvailable] = useState(false);
  useEffect(() => {
    try {
      setIsBrightSign(
        window.parent &&
          typeof window.parent.window.IsBSLocalFilePresent === "function"
      );

      setIsDeviceAPIAvailable(
        window.parent && typeof window.parent.window.DeviceAPI === "object"
      );
    } catch {
      setIsBrightSign(false);
      setIsDeviceAPIAvailable(false);
    }
  }, []);
  return { isBrightSign, isDeviceAPIAvailable };
}
