import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
/**
 * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
 *
 * Generates Typescript types for analytics events from analytics.spec.yaml
 *
 * @codegen <<SignedSource::268e746266cde1271e40a794eb774cf3>>
 * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen smart-card
 */

var createEventPayload = function createEventPayload(eventKey) {
  for (var _len = arguments.length, _ref = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    _ref[_key - 1] = arguments[_key];
  }
  var attributes = _ref[0];
  var _ref2 = eventKey.split('.'),
    _ref3 = _slicedToArray(_ref2, 4),
    eventType = _ref3[0],
    actionSubject = _ref3[1],
    action = _ref3[2],
    actionSubjectId = _ref3[3];
  if (eventType === 'screen') {
    return {
      eventType: eventType,
      name: actionSubject,
      action: 'viewed',
      attributes: attributes
    };
  }
  return {
    eventType: eventType,
    actionSubject: actionSubject,
    action: action,
    actionSubjectId: actionSubjectId,
    attributes: attributes
  };
};
export default createEventPayload;