import { UmbMoveDocumentServerDataSource } from '../../../entity-actions/move-to/repository/document-move.server.data-source.js';
import { UmbRepositoryBase } from '../../../../../core/repository/index.js';
import { UMB_NOTIFICATION_CONTEXT } from '../../../../../core/notification/index.js';
export class UmbBulkMoveToDocumentRepository extends UmbRepositoryBase {
    #moveSource = new UmbMoveDocumentServerDataSource(this);
    async requestBulkMoveTo(args) {
        const notificationContext = await this.getContext(UMB_NOTIFICATION_CONTEXT);
        let count = 0;
        const destination = args.destination;
        for (const unique of args.uniques) {
            const { error } = await this.#moveSource.moveTo({ unique, destination });
            if (error) {
                const notification = { data: { message: error.message } };
                notificationContext?.peek('danger', notification);
            }
            else {
                count++;
            }
        }
        if (count > 0) {
            const notification = { data: { message: `Moved ${count} ${count === 1 ? 'document' : 'documents'}` } };
            notificationContext?.peek('positive', notification);
        }
        return {};
    }
}
export { UmbBulkMoveToDocumentRepository as api };
