import React from 'react';
import MusicCard from "./MusicCard";
import Video from "../Video";
import { getPlatformType } from "../..\\utils\\getPlatform";
import { jsonProxy, revokeJsonProxy } from "../..\\utils\\constants";
import Image from "../Image";
import Model from "./Model";
import Audio from "./Audio";
import Download from "./Download";
import { jsx as _jsx } from "react/jsx-runtime";
var Binary = function Binary(_ref) {
  var media = _ref.media,
    mediaVisible = _ref.mediaVisible,
    mediaMimeType = _ref.mediaMimeType,
    autoPlay = _ref.autoPlay,
    getMedia = _ref.getMedia,
    isDetail = _ref.isDetail,
    imgCssStyle = _ref.imgCssStyle;
  var format;
  var processedMedia = revokeJsonProxy(media);
  if (processedMedia.includes('?')) {
    var base = processedMedia.split('?')[0];
    format = base.slice(base.lastIndexOf('.') + 1);
  } else {
    format = processedMedia.slice(processedMedia.lastIndexOf('.') + 1);
  }
  if (getPlatformType(processedMedia) === 'IPFS') {
    processedMedia = jsonProxy(processedMedia);
  }
  switch (format) {
    case 'jpg':
    case 'png':
    case 'jpeg':
    case 'bmp':
    case 'ico':
    case 'webp':
    case 'svg':
    case 'avif':
      return /*#__PURE__*/_jsx(Image, {
        media: processedMedia,
        mediaVisible: mediaVisible,
        isDetail: isDetail,
        imgCssStyle: imgCssStyle,
        mediaMimeType: ''
      });
    case 'gif':
      return /*#__PURE__*/_jsx(Image, {
        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__*/_jsx(Video, {
        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__*/_jsx(Audio, {
        media: processedMedia,
        autoPlay: autoPlay,
        getMedia: getMedia,
        mediaMimeType: '',
        mediaVisible: false,
        isDetail: false
      }) : /*#__PURE__*/_jsx(MusicCard, {});
    case 'glb':
    case 'gltf':
      return /*#__PURE__*/_jsx(Model, {
        media: processedMedia,
        mediaVisible: mediaVisible,
        isDetail: isDetail
      });
    default:
      return /*#__PURE__*/_jsx(Download, {
        media: processedMedia,
        mediaVisible: mediaVisible,
        mediaMimeType: mediaMimeType,
        isDetail: false
      });
  }
};
export default Binary;