import { createLogger } from "@open-mercato/shared/lib/logger";
const logger = createLogger("notifications").child({ component: "mapper" });
function toNotificationDto(notification) {
  const createdAt = notification.createdAt instanceof Date ? notification.createdAt : (() => {
    if (process.env.NODE_ENV !== "test") {
      logger.warn("Invalid createdAt on notification entity, falling back to current time", { id: notification.id, createdAt: notification.createdAt });
    }
    return /* @__PURE__ */ new Date();
  })();
  return {
    id: notification.id,
    type: notification.type,
    title: notification.title,
    body: notification.body,
    titleKey: notification.titleKey,
    bodyKey: notification.bodyKey,
    titleVariables: notification.titleVariables,
    bodyVariables: notification.bodyVariables,
    icon: notification.icon,
    severity: notification.severity,
    status: notification.status,
    actions: notification.actionData?.actions?.map((action) => ({
      id: action.id,
      label: action.label,
      labelKey: action.labelKey,
      variant: action.variant,
      icon: action.icon
    })) ?? [],
    primaryActionId: notification.actionData?.primaryActionId,
    sourceModule: notification.sourceModule,
    sourceEntityType: notification.sourceEntityType,
    sourceEntityId: notification.sourceEntityId,
    linkHref: notification.linkHref,
    createdAt: createdAt.toISOString(),
    readAt: notification.readAt?.toISOString() ?? null,
    actionTaken: notification.actionTaken
  };
}
export {
  toNotificationDto
};
//# sourceMappingURL=notificationMapper.js.map
