"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.ReferenceView = void 0;
var _react = _interopRequireDefault(require("react"));
var _patternsFields = require("@wix/patterns-fields");
var _CellViewLayout = require("../CellViewLayout");
var _getImageFieldId = require("./getImageFieldId");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/EditableTable/cellTypes/reference/View.tsx";
const ReferenceView = ({
  value,
  typeConfig
}) => {
  const config = typeConfig;
  if (!value || !(config != null && config.refSchema)) {
    return /*#__PURE__*/_react.default.createElement(_CellViewLayout.CellViewLayout, {
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 16,
        columnNumber: 12
      }
    }, null);
  }
  const {
    displayField,
    fields
  } = config.refSchema;
  const imageField = (0, _getImageFieldId.getImageFieldId)(fields);
  const name = String(value[displayField] ?? '');
  const imageUrl = imageField ? value[imageField] : undefined;
  return /*#__PURE__*/_react.default.createElement(_patternsFields.CellReferenceView, {
    name: name,
    imageUrl: imageUrl,
    dataHook: "reference-view",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 27,
      columnNumber: 5
    }
  });
};
exports.ReferenceView = ReferenceView;
//# sourceMappingURL=View.js.map