import { useEffect, useState } from 'react';

export function useIsPWA(): boolean {
  const [isPWA, setIsPWA] = useState(false);

  useEffect(() => {
    const isStandalone = window.matchMedia('(display-mode: standalone)').matches;
    const isIOSStandalone = 'standalone' in window.navigator && (window.navigator as any).standalone;

    setIsPWA(isStandalone || isIOSStandalone);
  }, []);

  return isPWA;
}
