import { isEmptyObject } from '@jscrpt/common';
/**
 * Instruction containing data/changes that are needed for data transfer
 */
export class RelationsDataTransferInstructionImpl {
    //######################### public properties - implementation of RelationsDataTransferInstruction #########################
    /**
     * @inheritdoc
     */
    get changes() {
        return this._changes;
    }
    //######################### constructor #########################
    constructor(components) {
        this.components = components;
        //######################### private fields #########################
        /**
         * Changes that are coming into component
         */
        this._changes = {};
    }
    //######################### public methods - implementation of RelationsDataTransferInstruction #########################
    /**
     * @inheritdoc
     */
    applyChanges() {
        for (const component of this.components) {
            if (!component || isEmptyObject(this._changes)) {
                continue;
            }
            for (const key in this._changes) {
                const change = this._changes[key];
                component[key] = change.currentValue;
            }
            component.ngOnChanges?.(this._changes);
            component.invalidateVisuals();
        }
    }
}
//# sourceMappingURL=relationsDataTransferInstruction.js.map