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