import { UFOExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
import { fg } from '@atlaskit/platform-feature-flags';
const packageName = "@atlaskit/media-viewer";
const packageVersion = "0.0.0-development";
let ufoExperience;
const getExperience = () => {
  if (!ufoExperience) {
    const inlineExperience = {
      platform: {
        component: 'media-viewer'
      },
      type: ExperienceTypes.Experience,
      performanceType: ExperiencePerformanceTypes.InlineResult,
      featureFlags: getFeatureFlagKeysAllProducts()
    };
    ufoExperience = new UFOExperience('media-file', inlineExperience);
  }
  return ufoExperience;
};
export const startMediaFileUfoExperience = () => {
  getExperience().start();
};
export const succeedMediaFileUfoExperience = properties => {
  getExperience().success({
    metadata: {
      ...properties,
      packageName,
      packageVersion,
      mediaEnvironment: getMediaEnvironment(),
      mediaRegion: getMediaRegion(),
      isMediaDocumentViewerEnabled: fg('media_document_viewer')
    }
  });
};
export const failMediaFileUfoExperience = properties => {
  const refinedMetadata = {
    ...properties,
    packageName,
    packageVersion,
    mediaEnvironment: getMediaEnvironment(),
    mediaRegion: getMediaRegion(),
    isMediaDocumentViewerEnabled: fg('media_document_viewer')
  };
  getExperience().failure({
    metadata: refinedMetadata
  });
};