'use strict';
import { apiPost, apiPostFile } from '../../../../fd-toolbox/api/api-client.js';
import { wellKnownMetaProps } from '../../../../fd-toolbox-core/constants/meta-constants.js';
import { apiPathNames } from '../../../../fd-toolbox/api/api-path-names.js';
import { getNewUuid } from '../../../../fd-toolbox/uuids.js';
import { resourceNames } from '../../../../fd-toolbox/resources/resource-names.js';
import { getExtension } from '../../../../fd-toolbox/io/io.js';
import { promiseStatuses } from '../../../../fd-toolbox-core/constants/promises.js';
import { mediaConstants } from '../../constants/media-constants.js';
import { deleteBaseApi } from '../../../../fd-toolbox/api/base-api.js';
import { remoteBlobConstants } from '../../../../base-repo/constants/remote-blob-constants.js';

var __defProp=Object['defineProperty'],__name=(_0xa54f90,_0x516e63)=>__defProp(_0xa54f90,'name',{'value':_0x516e63,'configurable':!![]});async function uploadBlobs(_0x5c5d8b,_0x529ca9,_0x34e8e8){const _0x3a9953=_0x5c5d8b['map'](()=>getNewUuid()),_0x1b5601=await Promise['allSettled'](_0x5c5d8b['map']((_0x1c2a21,_0x3ffc33)=>{let _0x48235a=_0x3a9953[_0x3ffc33]+'.'+getExtension(_0x1c2a21['name']);return uploadBlob(_0x48235a,_0x1c2a21);}));let _0x5922b3=_0x1b5601['map'](_0x2c4be6=>{if(_0x2c4be6['status']===promiseStatuses['fulfilled']&&_0x2c4be6['value'])return _0x2c4be6['value'];return '';});const _0xedefc=[];for(let _0x584fec=-0xca*-0x29+-0x197*0x17+0x437;_0x584fec<_0x5922b3['length'];_0x584fec++){const _0x148375=_0x5922b3[_0x584fec],_0x3781ba={'resource':{'id':_0x3a9953[_0x584fec],..._0x34e8e8&&{[_0x34e8e8]:_0x529ca9},'blobUrl':_0x148375},'resourceName':resourceNames['blob']};_0xedefc['push'](apiPost(resourceNames['blob'],_0x3781ba));}await Promise['allSettled'](_0xedefc);const _0x40a2c1=mediaConstants['blob']+'?'+remoteBlobConstants['blobNameParam'];return _0x3a9953['map']((_0x5cc73a,_0x8e0c55)=>_0x40a2c1+'='+_0x5cc73a+'.'+getExtension(_0x5c5d8b[_0x8e0c55]['name']));}__name(uploadBlobs,'uploadBlobs');async function uploadBlob(_0xc3ccce,_0x59e1c8){const _0x111ae6=new FormData();_0x111ae6['append'](mediaConstants['fileKey'],_0x59e1c8),_0x111ae6['append'](wellKnownMetaProps['name'],_0xc3ccce);const _0x1b5a61=await apiPostFile(apiPathNames['blob'],_0x111ae6);return _0x1b5a61['data'];}__name(uploadBlob,'uploadBlob');async function deleteBlob(_0x556cdc){await deleteBaseApi(_0x556cdc);}__name(deleteBlob,'deleteBlob');

export { deleteBlob, uploadBlob, uploadBlobs };
