"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.unlinkPayload = exports.buildVisitedNonHyperLinkPayload = exports.buildVisitedLinkPayload = exports.buildOpenedSettingsPayload = exports.buildEditLinkPayload = void 0;
var _enums = require("./types/enums");
var buildEditLinkPayload = exports.buildEditLinkPayload = function buildEditLinkPayload(type) {
  return {
    action: _enums.ACTION.CLICKED,
    actionSubject: type === _enums.ACTION_SUBJECT_ID.HYPERLINK ? _enums.ACTION_SUBJECT.HYPERLINK : _enums.ACTION_SUBJECT.SMART_LINK,
    actionSubjectId: _enums.ACTION_SUBJECT_ID.EDIT_LINK,
    attributes: type !== _enums.ACTION_SUBJECT_ID.HYPERLINK ? {
      // @ts-ignore
      display: type
    } : {},
    eventType: _enums.EVENT_TYPE.UI
  };
};
var mapLinkTypeToCardAppearance = function mapLinkTypeToCardAppearance(type) {
  switch (type) {
    case _enums.ACTION_SUBJECT_ID.CARD_INLINE:
      {
        return 'inline';
      }
    case _enums.ACTION_SUBJECT_ID.CARD_BLOCK:
      {
        return 'block';
      }
    case _enums.ACTION_SUBJECT_ID.EMBEDS:
      {
        return 'embed';
      }
    default:
      {
        return 'url';
      }
  }
};
var buildVisitedLinkPayload = exports.buildVisitedLinkPayload = function buildVisitedLinkPayload(type) {
  return type === _enums.ACTION_SUBJECT_ID.HYPERLINK ? buildVisitedHyperLinkPayload() : buildVisitedNonHyperLinkPayload(type, _enums.INPUT_METHOD.TOOLBAR);
};
var buildVisitedHyperLinkPayload = function buildVisitedHyperLinkPayload() {
  return {
    action: _enums.ACTION.VISITED,
    actionSubject: _enums.ACTION_SUBJECT.HYPERLINK,
    actionSubjectId: undefined,
    attributes: {
      inputMethod: _enums.INPUT_METHOD.TOOLBAR
    },
    eventType: _enums.EVENT_TYPE.TRACK
  };
};
var buildVisitedNonHyperLinkPayload = exports.buildVisitedNonHyperLinkPayload = function buildVisitedNonHyperLinkPayload(type, inputMethod) {
  return {
    action: _enums.ACTION.VISITED,
    actionSubject: _enums.ACTION_SUBJECT.SMART_LINK,
    actionSubjectId: type,
    attributes: {
      inputMethod: inputMethod
    },
    eventType: _enums.EVENT_TYPE.TRACK
  };
};
var buildOpenedSettingsPayload = exports.buildOpenedSettingsPayload = function buildOpenedSettingsPayload(type) {
  return {
    action: _enums.ACTION.CLICKED,
    actionSubject: _enums.ACTION_SUBJECT.BUTTON,
    actionSubjectId: _enums.ACTION_SUBJECT_ID.GOTO_SMART_LINK_SETTINGS,
    attributes: {
      // @ts-ignore
      inputMethod: _enums.INPUT_METHOD.TOOLBAR,
      display: mapLinkTypeToCardAppearance(type)
    },
    eventType: _enums.EVENT_TYPE.UI
  };
};
var unlinkPayload = exports.unlinkPayload = function unlinkPayload(type) {
  return {
    action: _enums.ACTION.UNLINK,
    actionSubject: type === _enums.ACTION_SUBJECT_ID.HYPERLINK ? _enums.ACTION_SUBJECT.HYPERLINK : _enums.ACTION_SUBJECT.SMART_LINK,
    actionSubjectId: type === _enums.ACTION_SUBJECT_ID.HYPERLINK ? undefined : type,
    attributes: {
      inputMethod: _enums.INPUT_METHOD.TOOLBAR
    },
    eventType: _enums.EVENT_TYPE.TRACK
  };
};