"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.componentName = exports.component = void 0;
exports.fireAnalytics = fireAnalytics;
exports.getFileAttributes = getFileAttributes;
exports.packageVersion = exports.packageName = void 0;
var _analytics = require("@atlaskit/media-common/analytics");
var componentName = exports.component = exports.componentName = 'mediaViewer';
var packageName = exports.packageName = "@atlaskit/media-viewer";
var packageVersion = exports.packageVersion = "0.0.0-development";
function getFileAttributes(fileState) {
  if (!fileState) {
    return {
      fileId: 'undefined'
    };
  }
  var fileId = fileState.id;
  switch (fileState.status) {
    case 'uploading':
    case 'failed-processing':
    case 'processing':
    case 'processed':
      var fileMediatype = fileState.mediaType,
        fileMimetype = fileState.mimeType,
        fileSize = fileState.size;
      return {
        fileId: fileId,
        fileMediatype: fileMediatype,
        fileMimetype: fileMimetype,
        fileSize: fileSize
      };
    case 'error':
      return {
        fileId: fileId
      };
  }
}

/** This type takes FailureAttributes and redefines `failReason` to be the strong media-viewer type */

function fireAnalytics(payload, createAnalyticsEvent) {
  if (createAnalyticsEvent) {
    var ev = createAnalyticsEvent((0, _analytics.sanitiseAnalyticsPayload)(payload));
    ev.fire(_analytics.ANALYTICS_MEDIA_CHANNEL);
  }
}