export function isWeChatBrowser(): boolean {
  if (typeof window === 'undefined') return false;
  return /MicroMessenger/i.test(navigator.userAgent);
}

export function getOpenidFromUrl(): string | null {
  if (typeof window === 'undefined') return null;
  const params = new URLSearchParams(window.location.search);
  return params.get('openid');
}

export function isMiniProgram(): boolean {
  if (typeof window === 'undefined') return false;
  return /miniProgram/i.test(navigator.userAgent) || !!getOpenidFromUrl();
}
