"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var logrocket_exports = {};
__export(logrocket_exports, {
  getLogRocket: () => getLogRocket,
  lrIdentify: () => lrIdentify,
  lrTrack: () => lrTrack,
  setLogRocket: () => setLogRocket
});
module.exports = __toCommonJS(logrocket_exports);
var import_pui_analytics_so = require("@elliemae/pui-analytics-so");
var import_helpers = require("./helpers.js");
let gLogRocket = null;
const getLogRocket = () => gLogRocket;
const setLogRocket = (logrocket) => {
  gLogRocket = logrocket || null;
};
const cleanupData = (data) => {
  const cleanedData = {};
  Object.entries(data).forEach(([key, value]) => {
    cleanedData[key] = value === void 0 || value === null ? "" : value;
  });
  return cleanedData;
};
const getEventData = (eventEx) => {
  const eventData = {
    ...eventEx,
    ...(0, import_pui_analytics_so.getBAEventParameters)(),
    ...(0, import_helpers.getProductAppDetails)()
  };
  return cleanupData(eventData);
};
const lrTrack = (event, eventEx = {}) => {
  const logRocket = getLogRocket();
  if (logRocket) {
    logRocket.track(event, getEventData(eventEx));
  }
};
const lrIdentify = (userId, eventEx) => {
  const logRocket = getLogRocket();
  if (logRocket) {
    logRocket.identify(userId, cleanupData(eventEx));
  }
};
