"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getField = void 0; /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ /** * Helper function to retrieve a field's value (used in combination with the custom hook useGetFieldsData (https://github.com/elastic/kibana/blob/main/x-pack/plugins/security_solution/public/common/hooks/use_get_fields_data.ts) * @param field type unknown or unknown[] * @param emptyValue optional parameter to return if field is incorrect * @return the field's value, or null/emptyValue */ const getField = (field, emptyValue) => { if (typeof field === 'string') { return field; } else if (Array.isArray(field) && field.length > 0 && typeof field[0] === 'string') { return field[0]; } return emptyValue !== null && emptyValue !== void 0 ? emptyValue : null; }; exports.getField = getField;