{"version":3,"sources":["../../src/utilities/appendUploadSelectFields.ts"],"sourcesContent":["import type { ClientCollectionConfig, SanitizedCollectionConfig, SelectType } from '../index.js'\n\n/**\n * Mutates the incoming select object to append fields required for upload thumbnails\n * @param collectionConfig\n * @param select\n */\nexport const appendUploadSelectFields = ({\n collectionConfig,\n select,\n}: {\n collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig\n select: SelectType\n}) => {\n if (!collectionConfig.upload || !select) {\n return\n }\n\n select.mimeType = true\n select.thumbnailURL = true\n\n if (collectionConfig.upload.imageSizes && collectionConfig.upload.imageSizes.length > 0) {\n if (\n collectionConfig.upload.adminThumbnail &&\n typeof collectionConfig.upload.adminThumbnail === 'string'\n ) {\n /** Only return image size properties that are required to generate the adminThumbnailURL */\n select.sizes = {\n [collectionConfig.upload.adminThumbnail]: {\n filename: true,\n },\n }\n } else {\n /** Only return image size properties that are required for thumbnails */\n select.sizes = collectionConfig.upload.imageSizes.reduce((acc, imageSizeConfig) => {\n return {\n ...acc,\n [imageSizeConfig.name]: {\n filename: true,\n url: true,\n width: true,\n },\n }\n }, {})\n }\n } else {\n select.url = true\n }\n}\n"],"names":["appendUploadSelectFields","collectionConfig","select","upload","mimeType","thumbnailURL","imageSizes","length","adminThumbnail","sizes","filename","reduce","acc","imageSizeConfig","name","url","width"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,2BAA2B,CAAC,EACvCC,gBAAgB,EAChBC,MAAM,EAIP;IACC,IAAI,CAACD,iBAAiBE,MAAM,IAAI,CAACD,QAAQ;QACvC;IACF;IAEAA,OAAOE,QAAQ,GAAG;IAClBF,OAAOG,YAAY,GAAG;IAEtB,IAAIJ,iBAAiBE,MAAM,CAACG,UAAU,IAAIL,iBAAiBE,MAAM,CAACG,UAAU,CAACC,MAAM,GAAG,GAAG;QACvF,IACEN,iBAAiBE,MAAM,CAACK,cAAc,IACtC,OAAOP,iBAAiBE,MAAM,CAACK,cAAc,KAAK,UAClD;YACA,0FAA0F,GAC1FN,OAAOO,KAAK,GAAG;gBACb,CAACR,iBAAiBE,MAAM,CAACK,cAAc,CAAC,EAAE;oBACxCE,UAAU;gBACZ;YACF;QACF,OAAO;YACL,uEAAuE,GACvER,OAAOO,KAAK,GAAGR,iBAAiBE,MAAM,CAACG,UAAU,CAACK,MAAM,CAAC,CAACC,KAAKC;gBAC7D,OAAO;oBACL,GAAGD,GAAG;oBACN,CAACC,gBAAgBC,IAAI,CAAC,EAAE;wBACtBJ,UAAU;wBACVK,KAAK;wBACLC,OAAO;oBACT;gBACF;YACF,GAAG,CAAC;QACN;IACF,OAAO;QACLd,OAAOa,GAAG,GAAG;IACf;AACF,EAAC"}