import { ricosBICallbacks } from "./ricos-bi-callbacks.js";
import { RicosBILogger } from "./ricos-bi-logger.js";
import { uuid } from "./uuid.js";
const rce_session_id = uuid();
function biStrategy(appDefId, metaSiteId, wixRicosVersion, ricosVersion, biSettings) {
  const { biCallbacks, postId: settingsPostId, contentId: settingsContentId, ...rest } = biSettings;
  const postId = settingsPostId || settingsContentId || "";
  const essentials = {
    ...rest.defaultParams,
    bsi: rest.defaultParams?.bsi || typeof window !== "undefined" && window.commonConfig?.bsi
  };
  const biLogger = new RicosBILogger({
    logger: rest.logger,
    webBiLogger: rest.webBiLogger,
    genericParams: {
      container: rest.consumer || "default",
      container_id: appDefId,
      container_platform: rest.platform,
      container_usage: rest.usage,
      post_id: postId,
      rce_session_id,
      msid: metaSiteId,
      wixRicosVersion,
      version: ricosVersion
    },
    essentials
  });
  const logger = ricosBICallbacks(biLogger, {
    postId
  });
  return {
    biLogger,
    helpers: {
      onModalAction: (args) => {
        logger.onModalAction(args);
        biCallbacks?.onModalAction?.(args);
      },
      onPluginAdd: (pluginId, entryPoint, version, contentId) => {
        logger.onPluginAdd(pluginId, entryPoint, version, contentId);
        biCallbacks?.onPluginAdd?.(pluginId, entryPoint, version, contentId);
      },
      onPluginAddStep: (args) => {
        logger.onPluginAddStep(args);
        biCallbacks?.onPluginAddStep?.(args);
      },
      onPluginAddSuccess: (pluginId, entryPoint, params, version, contentId) => {
        logger.onPluginAddSuccess(pluginId, entryPoint, params, version, contentId);
        biCallbacks?.onPluginAddSuccess?.(pluginId, entryPoint, params, version, contentId);
      },
      onPluginDelete: (args) => {
        logger.onPluginDelete(args);
        biCallbacks?.onPluginDelete?.(args);
      },
      onPublish: (postId2, pluginsCount, pluginsDetails, version, contentId) => {
        const appliedContentId = postId2 || settingsPostId || settingsContentId;
        logger.onPublish(appliedContentId, pluginsCount, pluginsDetails, version, contentId);
        biCallbacks?.onPublish?.(
          appliedContentId,
          pluginsCount,
          pluginsDetails,
          version,
          contentId
        );
      },
      onMenuLoad: (args) => {
        logger.onMenuLoad(args);
        biCallbacks?.onMenuLoad?.(args);
      },
      onPluginModalOpened: (args) => {
        logger.onPluginModalOpened(args);
        biCallbacks?.onPluginModalOpened?.(args);
      },
      onViewerAction: (pluginId, actionName, value, contentId, partialNode) => {
        logger.onViewerAction(pluginId, actionName, value, contentId, partialNode);
        biCallbacks?.onViewerAction?.(pluginId, actionName, value, contentId, partialNode);
      },
      onViewerLoaded: (args) => {
        logger.onViewerLoaded(args);
        biCallbacks?.onViewerLoaded?.(args);
      },
      onOpenEditorSuccess: (version, toolbarType, contentId) => {
        logger.onOpenEditorSuccess(version, toolbarType, contentId);
        biCallbacks?.onOpenEditorSuccess?.(version, toolbarType, contentId);
      },
      onContentEdited: (args) => {
        logger.onContentEdited(args);
        biCallbacks?.onContentEdited?.(args);
      },
      onInlineToolbarOpen: (args) => {
        logger.onInlineToolbarOpen(args);
        biCallbacks?.onInlineToolbarOpen?.(args);
      },
      onToolbarButtonClick: (args) => {
        logger.onToolbarButtonClick(args);
        biCallbacks?.onToolbarButtonClick?.(args);
      },
      onKeyboardShortcutAction: (args) => {
        logger.onKeyboardShortcutAction(args);
        biCallbacks?.onKeyboardShortcutAction?.(args);
      },
      onMediaUploadStart: (correlationId, pluginId, fileSize, mediaType, version, contentId) => {
        logger.onMediaUploadStart(correlationId, pluginId, fileSize, mediaType, version, contentId);
        biCallbacks?.onMediaUploadStart?.(
          correlationId,
          pluginId,
          fileSize,
          mediaType,
          version,
          contentId
        );
      },
      onMediaUploadEnd: (correlationId, pluginId, duration, fileSize, mediaType, isSuccess, errorType, version, contentId) => {
        logger.onMediaUploadEnd(
          correlationId,
          pluginId,
          duration,
          fileSize,
          mediaType,
          isSuccess,
          errorType,
          version,
          contentId
        );
        biCallbacks?.onMediaUploadEnd?.(
          correlationId,
          pluginId,
          duration,
          fileSize,
          mediaType,
          isSuccess,
          errorType,
          version,
          contentId
        );
      },
      onPluginAction: (eventName, params) => {
        logger.onPluginAction(eventName, params);
        biCallbacks?.onPluginAction?.(eventName, params);
      },
      onPluginsPopOverTabSwitch: (args) => {
        logger.onPluginsPopOverTabSwitch(args);
        biCallbacks?.onPluginsPopOverTabSwitch?.(args);
      },
      onPluginsPopOverClick: (args) => {
        logger.onPluginsPopOverClick(args);
        biCallbacks?.onPluginsPopOverClick?.(args);
      },
      onChangePluginSettings: (args) => {
        logger.onChangePluginSettings(args);
        biCallbacks?.onChangePluginSettings?.(args);
      },
      mediaPluginsDetails: (args) => {
        logger.mediaPluginsDetails(args);
        biCallbacks?.mediaPluginsDetails?.(args);
      }
    }
  };
}
export {
  biStrategy
};
//# sourceMappingURL=bi-strategy.js.map
