"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const Websocket_1=require("@b/handler/Websocket"),query_1=require("@b/utils/query");exports.metadata={summary:"Updates the status of a support ticket",operationId:"updateSupportTicketStatus",tags:["Admin","CRM","Support Ticket"],parameters:[{index:0,name:"id",in:"path",required:!0,description:"ID of the support ticket to update",schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{status:{type:"string",description:"New status to apply",enum:["PENDING","OPEN","REPLIED","CLOSED"]}},required:["status"]}}}},responses:(0,query_1.updateRecordResponses)("Support Ticket"),requiresAuth:!0,permission:"edit.support.ticket",logModule:"ADMIN_SUP",logTitle:"Update ticket status"};exports.default=async t=>{const{body:e,params:s,ctx:a}=t,{id:r}=s,{status:u}=e;null==a||a.step("Broadcasting status update to clients");Websocket_1.messageBroker.broadcastToSubscribedClients(`/api/user/support/ticket/${r}`,{id:r},{method:"update",data:{status:u,updatedAt:new Date}});null==a||a.step("Updating ticket status");const p=await(0,query_1.updateStatus)("supportTicket",r,u);null==a||a.success("Ticket status updated");return p};