"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const notification_1=require("@b/services/notification");exports.metadata={summary:"Add Device Token",description:"Register a device token for push notifications",operationId:"addDeviceToken",tags:["User","Notifications","Device Token"],requiresAuth:!0,requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["token"],properties:{token:{type:"string",description:"The device token for push notifications"},deviceId:{type:"string",description:"Optional device identifier"},platform:{type:"string",description:"Device platform (ios, android, web)"}}}}}},responses:{200:{description:"Device token registered successfully",content:{"application/json":{schema:{type:"object",properties:{message:{type:"string"},deviceId:{type:"string"}}}}}},401:{description:"Unauthorized"},400:{description:"Bad Request - Device token is required"},500:{description:"Internal Server Error - Failed to add device token"}}};exports.default=async e=>{const{user:i,body:t}=e;if(!(null==i?void 0:i.id))throw new Error("Unauthorized");const{token:o,deviceId:r,platform:n}=t;if(!o)throw new Error("Device token is required");if(!await(0,notification_1.addDeviceToken)(i.id,o,r,n))throw new Error("Failed to add device token");return{message:"Device token registered successfully",deviceId:r||"auto-generated"}};