'use strict';
import { apiOkResponse } from '../../meta/server/web/responses.js';
import { remoteBlobConstants } from '../../../base-repo/constants/remote-blob-constants.js';
import { httpContentTypes } from '../../../fd-toolbox/constants/header-names.js';
import { responseMessages } from '../../../fd-toolbox/server/web/response-messages.js';
import { supportedImageTypes } from '../../../fd-toolbox/constants/file-loader-data-types.js';
import { metaErrorMessages } from '../../meta/constants/meta-error-messages-constants.js';
import { apiBadRequestError } from '../../../fd-toolbox/server/web/errors.js';
import { getBlobs, uploadBlob } from '../integrations/blob/blob-storage.js';

var __defProp=Object['defineProperty'],__name=(_0x537c8b,_0x6d3b1)=>__defProp(_0x537c8b,'name',{'value':_0x6d3b1,'configurable':!![]});async function uploadGetRoute(_0x349173){const _0x1e0c4c=new URL(_0x349173['url']),_0x4effce=_0x1e0c4c['searchParams']['get'](remoteBlobConstants['fileNameParam'])??'',_0x57d897=await getBlobs(_0x4effce);return apiOkResponse(_0x57d897);}__name(uploadGetRoute,'uploadGetRoute');async function uploadPostRoute(_0x40bbfd){const _0x1f1f00=_0x40bbfd['headers']['get'](httpContentTypes['contentTypeXFileName']),_0x3ddd50=_0x40bbfd['headers']['get'](httpContentTypes['contentTypeHeaderName'])??httpContentTypes['contentTypeHeaderOctetStream'];if(!_0x1f1f00)throw apiBadRequestError(responseMessages['missingFileName']);if(!supportedImageTypes['includes'](_0x3ddd50))throw apiBadRequestError(metaErrorMessages['unsupportedFileType']['replace']('{0}',supportedImageTypes['join'](',\x20')));const _0x5962d3=await _0x40bbfd['arrayBuffer']();if(!_0x5962d3)throw apiBadRequestError(metaErrorMessages['noFileContent']);const _0x11c90e=await uploadBlob(_0x1f1f00,_0x3ddd50,_0x5962d3);return apiOkResponse(_0x11c90e);}__name(uploadPostRoute,'uploadPostRoute');

export { uploadGetRoute, uploadPostRoute };
