import { APIError } from '../../../errors/index.js';
import { getFileByPath } from '../../../uploads/getFileByPath.js';
import { createLocalReq } from '../../../utilities/createLocalReq.js';
import { updateOperation } from '../update.js';
import { updateByIDOperation } from '../updateByID.js';
async function updateLocal(payload, options) {
    const { id, autosave, collection: collectionSlug, data, depth, disableTransaction, draft, file, filePath, limit, overrideAccess = true, overrideLock, overwriteExistingFiles = false, publishSpecificLocale, showHiddenFields, where } = options;
    const collection = payload.collections[collectionSlug];
    if (!collection) {
        throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found. Update Operation.`);
    }
    const req = await createLocalReq(options, payload);
    req.file = file ?? await getFileByPath(filePath);
    const args = {
        id,
        autosave,
        collection,
        data,
        depth,
        disableTransaction,
        draft,
        limit,
        overrideAccess,
        overrideLock,
        overwriteExistingFiles,
        payload,
        publishSpecificLocale,
        req,
        showHiddenFields,
        where
    };
    if (options.id) {
        return updateByIDOperation(args);
    }
    return updateOperation(args);
}
export default updateLocal;

//# sourceMappingURL=update.js.map