'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _formatHelpers = require('../../../helpers/formatHelpers');

exports.default = function (pluginContext) {
  return function (data, formatterContext) {
    var _pluginContext$record = pluginContext.recordDataHelpers,
        getPart = _pluginContext$record.getPart,
        deepGet = _pluginContext$record.deepGet;


    if (!data) {
      return '';
    }

    var common = getPart(data, 'conditionchecks_common');

    if (!common) {
      return '';
    }

    var conditioncheckRefNumber = common.get('conditionCheckRefNumber');
    var condition = deepGet(common, ['conditionCheckGroupList', 'conditionCheckGroup', 0, 'condition']);
    var formattedCondition = (0, _formatHelpers.formatOption)('conditions', condition, formatterContext);

    return [conditioncheckRefNumber, formattedCondition].filter(function (part) {
      return !!part;
    }).join(' – ');
  };
};