"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const exchange_1=__importDefault(require("@b/utils/exchange")),query_1=require("@b/utils/query"),utils_1=require("./utils"),db_1=require("@b/db");exports.metadata={summary:"Retrieves the currently active (enabled) exchange provider",operationId:"getActiveExchange",tags:["Admin","Exchanges"],responses:{200:{description:"Active exchange details or no active provider message",content:{"application/json":{schema:{type:"object",properties:{exchange:utils_1.baseExchangeSchema,result:{type:"object",properties:{status:{type:"boolean"},message:{type:"string"}}},noActiveProvider:{type:"boolean"}}}}}},401:query_1.unauthorizedResponse,500:query_1.serverErrorResponse},permission:"view.exchange",requiresAuth:!0};exports.default=async e=>{const{ctx:t}=e,r=await db_1.models.exchange.findOne({where:{status:!0}});if(!r)return{noActiveProvider:!0,exchange:null,result:null};return{exchange:r,result:await exchange_1.default.testExchangeCredentials(r.name,t),noActiveProvider:!1}};