import "server-only";
import { SCHEDULED_ACTIONS_REGISTRY } from "@nextsparkjs/registries/scheduled-actions-registry";
const globalForInit = globalThis;
function getActiveTheme() {
  var _a;
  return ((_a = process.env.NEXT_PUBLIC_ACTIVE_THEME) == null ? void 0 : _a.replace(/'/g, "")) || "default";
}
function initializeScheduledActions() {
  if (globalForInit.__scheduledActionsHandlersInitialized) {
    console.log("[ScheduledActions] Handlers already initialized, skipping...");
    return;
  }
  const themeName = getActiveTheme();
  const module = SCHEDULED_ACTIONS_REGISTRY[themeName];
  if (module) {
    console.log(`[ScheduledActions] Initializing handlers for theme: ${themeName}`);
    module.registerAllHandlers();
    globalForInit.__scheduledActionsHandlersInitialized = true;
    console.log(`[ScheduledActions] \u2705 Handlers initialized successfully`);
  } else {
    console.warn(`[ScheduledActions] No handlers found for theme: ${themeName}`);
  }
}
async function initializeRecurringActions() {
  if (globalForInit.__scheduledActionsRecurringInitialized) {
    console.log("[ScheduledActions] Recurring actions already initialized, skipping...");
    return;
  }
  const themeName = getActiveTheme();
  const module = SCHEDULED_ACTIONS_REGISTRY[themeName];
  if (module) {
    console.log(`[ScheduledActions] Initializing recurring actions for theme: ${themeName}`);
    await module.registerRecurringActions();
    globalForInit.__scheduledActionsRecurringInitialized = true;
    console.log(`[ScheduledActions] \u2705 Recurring actions initialized successfully`);
  } else {
    console.warn(`[ScheduledActions] No recurring actions found for theme: ${themeName}`);
  }
}
export {
  initializeRecurringActions,
  initializeScheduledActions
};
