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