"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _MusicCard = _interopRequireDefault(require("./MusicCard"));
var _Video = _interopRequireDefault(require("../Video"));
var _getPlatform = require("../..\\utils\\getPlatform");
var _constants = require("../..\\utils\\constants");
var _Image = _interopRequireDefault(require("../Image"));
var _Model = _interopRequireDefault(require("./Model"));
var _Audio = _interopRequireDefault(require("./Audio"));
var _Download = _interopRequireDefault(require("./Download"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const Binary = ({
  media,
  mediaVisible,
  mediaMimeType,
  autoPlay,
  getMedia,
  isDetail,
  imgCssStyle
}) => {
  let format;
  let processedMedia = (0, _constants.revokeJsonProxy)(media);
  if (processedMedia.includes('?')) {
    const base = processedMedia.split('?')[0];
    format = base.slice(base.lastIndexOf('.') + 1);
  } else {
    format = processedMedia.slice(processedMedia.lastIndexOf('.') + 1);
  }
  if ((0, _getPlatform.getPlatformType)(processedMedia) === 'IPFS') {
    processedMedia = (0, _constants.jsonProxy)(processedMedia);
  }
  switch (format) {
    case 'jpg':
    case 'png':
    case 'jpeg':
    case 'bmp':
    case 'ico':
    case 'webp':
    case 'svg':
    case 'avif':
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image.default, {
        media: processedMedia,
        mediaVisible: mediaVisible,
        isDetail: isDetail,
        imgCssStyle: imgCssStyle,
        mediaMimeType: ''
      });
    case 'gif':
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image.default, {
        media: processedMedia,
        mediaVisible: mediaVisible,
        mediaMimeType: "image/gif",
        isDetail: isDetail,
        imgCssStyle: imgCssStyle
      });
    case 'mp4':
    case 'mov':
    case 'ogv':
    case 'Ogg':
    case 'ogg':
    case 'mkv':
    case 'webm':
    case 'f4v':
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Video.default, {
        media: processedMedia,
        autoPlay: autoPlay,
        getMedia: getMedia,
        mediaVisible: mediaVisible,
        mediaMimeType: '',
        isDetail: false
      });
    case 'mp3':
    case 'flac':
    case 'wav':
    case 'aac':
    case 'm4r':
    case 'm4a':
      return mediaVisible ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Audio.default, {
        media: processedMedia,
        autoPlay: autoPlay,
        getMedia: getMedia,
        mediaMimeType: '',
        mediaVisible: false,
        isDetail: false
      }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_MusicCard.default, {});
    case 'glb':
    case 'gltf':
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Model.default, {
        media: processedMedia,
        mediaVisible: mediaVisible,
        isDetail: isDetail
      });
    default:
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Download.default, {
        media: processedMedia,
        mediaVisible: mediaVisible,
        mediaMimeType: mediaMimeType,
        isDetail: false
      });
  }
};
var _default = Binary;
exports.default = _default;