'use strict';

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

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


    if (!data) {
      return '';
    }

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

    if (!common) {
      return '';
    }

    var loanInNumber = common.get('loanInNumber');
    var borrower = getDisplayName(deepGet(common, ['lenderGroupList', 'lenderGroup', 0, 'lender']));

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