import { getBAEventParameters } from "@elliemae/pui-analytics-so";
import { CMicroAppGuest } from "../utils/micro-frontend/guest.js";
import { getProductAppDetails } from "../utils/helpers.js";
const sendBAEventToSelf = (data) => {
  const eventData = {
    ...getBAEventParameters(),
    ...getProductAppDetails(),
    ...data
  };
  window.gtmDataLayer = window.gtmDataLayer || [];
  window.gtmDataLayer.push(eventData);
};
const sendBAEvent = ({
  data,
  self = true
}) => {
  if (!self) {
    const host = CMicroAppGuest.getInstance()?.getHost();
    const sendEvent = host?.sendBAEvent;
    if (sendEvent) {
      sendEvent(data);
    } else {
      sendBAEventToSelf(data);
    }
  } else {
    sendBAEventToSelf(data);
  }
};
export {
  sendBAEvent
};
