import { Pipe, inject } from '@angular/core';
import { extend } from '@jscrpt/common';
import { RELATIONS_DEFAULTS_OVERRIDE } from '../../misc/tokens';
import * as i0 from "@angular/core";
/**
 * Transforms NodesPaletteItem item to RelationsNodeDragData
 */
export class ToRelationsDragDataSAPipe {
    constructor() {
        //######################### protected properties #########################
        /**
         * Default options override service
         */
        this.defaultsOverride = inject(RELATIONS_DEFAULTS_OVERRIDE, { optional: true });
    }
    //######################### public methods - implementation of PipeTransform #########################
    /**
     * Transforms NodesPaletteItem item to RelationsNodeDragData
     * @param value - Palette item to be transformed
     * @param id - Unique id to be used for new node
     * @param singleton - Indication whether is new node singleton, can be used only once
     * @param scope - Current scope that is being used
     */
    transform(value, id, singleton, scope) {
        const newId = singleton ? value.itemSource.name : `${value.itemSource.name}-${id}`;
        return {
            metadata: {
                id: newId,
                displayName: singleton ? this.defaultsOverride?.getDisplayName(value.itemSource.package, value.itemSource.name, value.metadata.displayName) || value.metadata.displayName || value.itemSource.name : undefined,
                package: value.itemSource.package,
                name: value.itemSource.name,
                scope,
                relationsOptions: extend(true, {}, this.defaultsOverride?.getOptions(value.itemSource.package, value.itemSource.name, value.metadata.metaInfo?.defaultOptions) ?? value.metadata.metaInfo?.defaultOptions),
                outputs: [],
                nodeMetadata: {
                    scopeConfigurable: !singleton ?? false,
                    coordinates: {
                        x: 0,
                        y: 0
                    },
                    options: null,
                }
            },
        };
    }
}
ToRelationsDragDataSAPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: ToRelationsDragDataSAPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
ToRelationsDragDataSAPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.4", ngImport: i0, type: ToRelationsDragDataSAPipe, isStandalone: true, name: "toRelationsDragData" });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: ToRelationsDragDataSAPipe, decorators: [{
            type: Pipe,
            args: [{ name: 'toRelationsDragData', standalone: true }]
        }] });
//# sourceMappingURL=toRelationsDragData.pipe.js.map