/**
 * Flag indicating if the code is executing within a browser environment.
 */
export const IS_BROWSER = typeof window !== 'undefined';

/**
 * The environment the application is running within.
 */
export const NODE_ENV = IS_BROWSER
  ? 'browser'
  : process.env.NODE_ENV || 'development';

/**
 * Flag indicating whether the application is running with a
 * "development" context (eg. a local development server).
 */
export const IS_DEV = IS_BROWSER
  ? window && window.location.hostname === 'localhost'
  : NODE_ENV !== 'production' && NODE_ENV !== 'prod';
export const IS_PROD = !IS_DEV;

/**
 * Flag indicating if currently running within the storybook runtime.
 */
export const IS_STORYBOOK =
  IS_BROWSER &&
  window.frameElement &&
  window.frameElement.id.startsWith('storybook');
