'use strict';
import { httpStatusCodes } from '../../../../fd-toolbox/constants/http-status-codes.js';
import { httpContentTypes } from '../../../../fd-toolbox/constants/header-names.js';
import { openAsBlob } from 'fs';
import { getContentTypeByExtension, getExtension } from '../../../../fd-toolbox/io/io.js';
import { getCacheHeaders } from '../../../../fd-toolbox/api/cache-headers.js';

var __defProp=Object['defineProperty'],__name=(_0x4b3381,_0x4ee5d3)=>__defProp(_0x4b3381,'name',{'value':_0x4ee5d3,'configurable':!![]});function getJsonResponse(_0x4d0cad,_0x4bbd2a,_0x1c5d01){return Response['json'](_0x4d0cad,{'status':_0x4bbd2a,'headers':_0x1c5d01});}__name(getJsonResponse,'getJsonResponse');function apiOkResponse(_0x1271a4,_0x35af15){return getJsonResponse({'data':_0x1271a4},httpStatusCodes['ok'],_0x35af15);}__name(apiOkResponse,'apiOkResponse');function apiCreatedResponse(_0x3be44f=void(-0x3*0x83+-0x13a9+0xa99*0x2),_0x23d80e){return getJsonResponse({'data':_0x3be44f},httpStatusCodes['created'],_0x23d80e);}__name(apiCreatedResponse,'apiCreatedResponse');function apiNoContentResponse(_0x1be6ed){return new Response(void(-0x1a03+0x10f8+0x90b),{'status':httpStatusCodes['noContent'],'headers':_0x1be6ed});}__name(apiNoContentResponse,'apiNoContentResponse');function apiBadRequestResponse(_0x20dfac,_0x5cc511){return getJsonResponse({'data':_0x20dfac},httpStatusCodes['badRequest'],_0x5cc511);}__name(apiBadRequestResponse,'apiBadRequestResponse');function apiTooManyRequestsResponse(_0x2f5540,_0x3b0447){return apiResponse(_0x2f5540,{..._0x3b0447,'status':httpStatusCodes['tooManyRequests']});}__name(apiTooManyRequestsResponse,'apiTooManyRequestsResponse');function apiInternalServerErrorResponse(_0x386044,_0x1a6d74){return apiResponse(_0x386044,{..._0x1a6d74,'status':httpStatusCodes['internalServerError']});}__name(apiInternalServerErrorResponse,'apiInternalServerErrorResponse');function apiNotFoundResponse(_0x50304f,_0x1615ec){return getJsonResponse({'data':_0x50304f},httpStatusCodes['notFound'],_0x1615ec);}__name(apiNotFoundResponse,'apiNotFoundResponse');async function getImageResponse(_0x46e659){const _0x3f519f=await openAsBlob(_0x46e659),_0x38bc19=new Headers({'Content-Type':''+getContentTypeByExtension(getExtension(_0x46e659)),...getCacheHeaders(_0x46e659)});return new Response(_0x3f519f,{'status':httpStatusCodes['ok'],'headers':_0x38bc19});}__name(getImageResponse,'getImageResponse');function apiResponse(_0x2d7f72,_0x4a710e){return new Response(JSON['stringify'](_0x2d7f72),{..._0x4a710e,'headers':{[httpContentTypes['contentTypeHeaderName']]:httpContentTypes['contentTypeApplicationJson'],..._0x4a710e?.['headers']}});}__name(apiResponse,'apiResponse');

export { apiBadRequestResponse, apiCreatedResponse, apiInternalServerErrorResponse, apiNoContentResponse, apiNotFoundResponse, apiOkResponse, apiResponse, apiTooManyRequestsResponse, getImageResponse, getJsonResponse };
