"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _objectSpread2=_interopRequireDefault(require("@babel/runtime/helpers/objectSpread")),_extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_react=_interopRequireWildcard(require("react")),_propTypes=_interopRequireDefault(require("prop-types")),_classnames=_interopRequireDefault(require("classnames")),_get=_interopRequireDefault(require("lodash/get")),_smartTruncate=_interopRequireDefault(require("smart-truncate")),_withStyles=_interopRequireDefault(require("../../hoc/withStyles")),_types=require("../../config/types"),_styles=_interopRequireDefault(require("./styles")),FileBlock=/*#__PURE__*/function(_Component){function FileBlock(){return(0,_classCallCheck2.default)(this,FileBlock),(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(FileBlock).apply(this,arguments))}return(0,_inherits2.default)(FileBlock,_Component),(0,_createClass2.default)(FileBlock,[{key:"render",value:function render(){var WrapComponent,_this$props=this.props,classes=_this$props.classes,file=_this$props.file,showRemoveButton=_this$props.showRemoveButton,variant=_this$props.variant,onRemoveClick=_this$props.onRemoveClick,extPos=(0,_get.default)(file,"name","").lastIndexOf("."),ext=(0,_get.default)(file,"name","").substring(extPos+1),extraProps={};return"link"===variant&&(0,_get.default)(file,"url")?(WrapComponent="a",extraProps={href:(0,_get.default)(file,"url"),target:"_blank"}):WrapComponent="div",_react.default.createElement(WrapComponent,(0,_extends2.default)({className:classes.component},extraProps),_react.default.createElement("div",{className:classes.icon},_react.default.createElement("img",{src:require("../../assets/images/file-icon.png"),className:classes.iconImage}),_react.default.createElement("div",{className:classes.ext},ext)),_react.default.createElement("div",{className:classes.filename},(0,_smartTruncate.default)(file.name||"",12,{position:5})),"interactive"===variant&&_react.default.createElement("div",{className:classes.hoverIconWrapper},(0,_get.default)(file,"url")&&_react.default.createElement("a",{href:(0,_get.default)(file,"url"),target:"_blank",rel:"noopener noreferrer",className:classes.linkIconWrapper,onClick:function onClick(e){e.stopPropagation()}},_react.default.createElement("i",{className:(0,_classnames.default)("fa fa-link",classes.linkIcon)})),showRemoveButton&&_react.default.createElement("div",{className:classes.closeIconWrapper},_react.default.createElement("i",{className:(0,_classnames.default)("fa fa-times",classes.closeIcon),onClick:onRemoveClick}))))}}]),FileBlock}(_react.Component);(0,_defineProperty2.default)(FileBlock,"propTypes",(0,_objectSpread2.default)({file:_propTypes.default.any,onRemoveClick:_propTypes.default.func,showRemoveButton:_propTypes.default.bool,variant:_propTypes.default.oneOf(["none","interactive","link"])},_types.withStylesProps)),(0,_defineProperty2.default)(FileBlock,"defaultProps",{onRemoveClick:function onRemoveClick(){},showRemoveButton:!0,variant:"none"});var _default=(0,_withStyles.default)(_styles.default)(FileBlock);exports.default=_default;