"use strict";

exports.__esModule = true;
exports.FilePreview = FilePreview;
var _react = _interopRequireWildcard(require("react"));
var _designSystem = require("@wix/design-system");
var _useDownloadFile = require("./useDownloadFile");
var _FilePreviewModal = require("./FilePreviewModal");
var _FileCard = require("./FileCard");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/FileCard/FilePreview.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function FilePreview({
  file,
  showDownloadCTA,
  showDetails
}) {
  const {
    mediaType
  } = file;
  const [isPreviewOpen, setIsPreviewOpen] = (0, _react.useState)(false);
  const {
    downloadFile
  } = (0, _useDownloadFile.useDownloadFile)({
    file
  });
  const supportedPreviewTypes = ['picture', 'video'];
  return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    marginBottom: "SP1",
    direction: "vertical",
    width: showDetails ? '100%' : 'fit-content',
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 19,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.TableListItem, {
    verticalPadding: "xxTiny",
    horizontalPadding: "xxTiny",
    border: true,
    onClick: e => {
      e.stopPropagation();
      if (!supportedPreviewTypes.includes(mediaType)) {
        downloadFile();
        return;
      }
      setIsPreviewOpen(true);
    },
    options: [{
      value: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
        height: showDetails ? 48 : 36,
        overflow: "hidden",
        dataHook: `file-upload-formatted-${file.mediaId}`,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 39,
          columnNumber: 15
        }
      }, /*#__PURE__*/_react.default.createElement(_FileCard.FileCard, {
        file: file,
        showDownloadCTA: showDownloadCTA,
        showDetails: showDetails,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 44,
          columnNumber: 17
        }
      }))
    }],
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 24,
      columnNumber: 7
    }
  }), supportedPreviewTypes.includes(mediaType) ? /*#__PURE__*/_react.default.createElement(_FilePreviewModal.FilePreviewModal, {
    file: file,
    showDetails: showDetails,
    isOpen: isPreviewOpen,
    close: () => {
      setIsPreviewOpen(false);
    },
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 55,
      columnNumber: 9
    }
  }) : null);
}
//# sourceMappingURL=FilePreview.js.map