"use strict";async function createNotification(i,t){var e,o,n;try{null===(e=null==t?void 0:t.step)||void 0===e||e.call(t,"Creating notification");const n=await notification_1.notificationService.send({userId:i.userId,type:mapNotificationType(i.type),channels:["IN_APP"],data:{title:i.title||"Notification",message:i.message,details:i.details,link:i.link,actions:i.actions,relatedId:i.relatedId},priority:getPriorityFromType(i.type),idempotencyKey:`notification-${i.userId}-${Date.now()}`});null===(o=null==t?void 0:t.success)||void 0===o||o.call(t,"Notification created successfully");return n.notificationId}catch(i){console_1.logger.error("Failed to create notification",i);null===(n=null==t?void 0:t.fail)||void 0===n||n.call(t,i.message);throw i}}async function createAdminNotification(i,t,e,o,n,a,c,s){var r,l,d;try{null===(r=null==s?void 0:s.step)||void 0===r||r.call(s,`Finding users with ${i} permission`);await notification_1.notificationService.sendToPermission({permissionName:i,type:mapNotificationType(o),channels:["IN_APP"],data:{title:t,message:e,details:a,link:n,actions:c},priority:getPriorityFromType(o)});null===(l=null==s?void 0:s.success)||void 0===l||l.call(s,"Admin notifications sent successfully")}catch(i){console_1.logger.error("Failed to create admin notification",i);null===(d=null==s?void 0:s.fail)||void 0===d||d.call(s,i.message);throw i}}function mapNotificationType(i){return{investment:"INVESTMENT",message:"MESSAGE",user:"USER",alert:"ALERT",system:"SYSTEM"}[i]||"SYSTEM"}function getPriorityFromType(i){switch(i){case"alert":case"investment":return"HIGH";default:return"NORMAL"}}Object.defineProperty(exports,"__esModule",{value:!0});exports.createNotification=createNotification;exports.createAdminNotification=createAdminNotification;const notification_1=require("@b/services/notification"),console_1=require("./console");