import { createLogger } from "../logger/index.js";
const logger = createLogger("shared").child({ component: "crud" });
const RESOLUTION_WARNING_KEY = "__openMercatoCrudMutationGuardResolutionWarningEmitted__";
function warnResolutionFailureOnce(error) {
  const globalScope = globalThis;
  if (globalScope[RESOLUTION_WARNING_KEY] === true) return;
  globalScope[RESOLUTION_WARNING_KEY] = true;
  logger.warn("CRUD mutation guard service could not be resolved; the legacy guard bridge is disabled", {
    err: error
  });
}
function resolveCrudMutationGuardService(container) {
  if (typeof container.hasRegistration === "function" && !container.hasRegistration("crudMutationGuardService")) {
    return null;
  }
  try {
    const service = container.resolve("crudMutationGuardService");
    if (!service) return null;
    if (typeof service.validateMutation !== "function") return null;
    if (typeof service.afterMutationSuccess !== "function") return null;
    return service;
  } catch (error) {
    warnResolutionFailureOnce(error);
    return null;
  }
}
export {
  resolveCrudMutationGuardService
};
//# sourceMappingURL=mutation-guard-service.js.map
