"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}});Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i);e[r]=t[i]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(){var e=function(t){e=Object.getOwnPropertyNames||function(e){var t=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[t.length]=i);return t};return e(t)};return function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var r=e(t),n=0;n<r.length;n++)"default"!==r[n]&&__createBinding(i,t,r[n]);__setModuleDefault(i,t);return i}}();Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const errors_1=require("@b/utils/schema/errors");exports.metadata={summary:"Get Notification Settings",description:"Retrieve current notification service configuration",operationId:"getNotificationSettings",tags:["Admin","Notification","Settings"],requiresAuth:!0,permission:"access.notification.settings",responses:{200:{description:"Settings retrieved successfully",content:{"application/json":{schema:{type:"object",properties:{channels:{type:"object"},providers:{type:"object"},features:{type:"object"}}}}}},401:errors_1.unauthorizedResponse,500:errors_1.serverErrorResponse}};exports.default=async e=>{var t,i,r;const{ctx:n}=e;try{null===(t=null==n?void 0:n.step)||void 0===t||t.call(n,"Fetching notification settings");const{notificationService:e}=await Promise.resolve().then(()=>__importStar(require("@b/services/notification"))),r=e.getRegisteredChannels(),s=!(!process.env.VAPID_PUBLIC_KEY||!process.env.VAPID_PRIVATE_KEY),o=!!process.env.FCM_PROJECT_ID;let c="none";s?c="vapid (Web Push)":o&&(c="fcm (Firebase)");const a={channels:{inApp:{enabled:r.includes("IN_APP"),description:"In-app notifications via WebSocket"},email:{enabled:r.includes("EMAIL"),provider:process.env.EMAIL_PROVIDER||"nodemailer",from:process.env.EMAIL_FROM},sms:{enabled:r.includes("SMS"),provider:process.env.SMS_PROVIDER||"twilio"},push:{enabled:r.includes("PUSH"),provider:c,description:s?"Web Push via VAPID (no Firebase required)":o?"Push via Firebase Cloud Messaging":"Push notifications not configured"}},providers:{sendgrid:{configured:!!process.env.SENDGRID_API_KEY},nodemailer:{configured:!(!process.env.APP_NODEMAILER_SMTP_HOST&&!process.env.SMTP_HOST||!process.env.APP_NODEMAILER_SMTP_PORT&&!process.env.SMTP_PORT)},twilio:{configured:!(!process.env.APP_TWILIO_ACCOUNT_SID||!process.env.APP_TWILIO_AUTH_TOKEN)},vapid:{configured:s,description:"Web Push Protocol (VAPID keys)"},fcm:{configured:o,description:"Firebase Cloud Messaging"}},features:{idempotency:{enabled:!0,ttl:"30 days"},userPreferences:{enabled:!0,cacheTTL:"1 hour"},deliveryTracking:{enabled:!0,ttl:"30 days"},priorityLevels:["LOW","NORMAL","HIGH","URGENT"],notificationTypes:["SYSTEM","INVESTMENT","TRADE","P2P","COPY_TRADING","ICO","STAKING","WALLET","SECURITY","MARKETING","FOREX","BINARY","FUTURES","ECOMMERCE","NFT","ALERT","MESSAGE","USER"]}};null===(i=null==n?void 0:n.success)||void 0===i||i.call(n,"Notification settings retrieved");return{timestamp:(new Date).toISOString(),...a}}catch(e){null===(r=null==n?void 0:n.fail)||void 0===r||r.call(n,e.message);throw e}};