/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
/**
 * The `PinController` is responsible for adding pin entities to the viewer canvas
 */
export class PinController {
    constructor(model, mode = 'view', type = 'pin-icon', styleAttributes = undefined) {
        this.model = model;
        this.mode = mode;
        this.type = type;
        this.styleAttributes = styleAttributes;
    }
    /**
     * Registers an entity to place on the canvas and places the pin on the associated part.
     *
     * @param pin The pin entity
     * @returns A void promise
     */
    addPin(pin) {
        this.model.addPin(pin);
    }
    /**
     * Clears all entities and returns a promise that resolves with an empty list
     * of pin results.
     */
    clearPins() {
        this.model.clearPins();
    }
    /**
     * Deregisters an entity and performs a pin if this entity was
     * removed.
     *
     * @param entity The entity to remove.
     * @returns A promise that resolves with the results after removing this
     * entity.
     */
    removePin(pin) {
        this.model.removePin(pin);
    }
    /**
     * Registers a set of entities and adds a pin
     *
     * @param entities The pin entities to draw.
     * @returns A promise that resolves with the results after registering these
     * entities.
     */
    setPins(pins) {
        this.model.setPins(pins);
    }
    /**
     * Sets the set of entities to be placed with the model.
     *
     * @param pin A pin to set
     * @returns `true` if the entity has been added.
     */
    setPin(pin) {
        this.model.setPin(pin);
    }
    /**
     * Updates an existing pin
     * @param pin A pin to set
     * @returns `true` if the entity has been updated, false otherwise
     */
    updatePin(pin) {
        this.model.updatePin(pin);
    }
    /**
     * Tells the controller which pin is selected in the model
     * @param pinId
     */
    setSelectedPinId(pinId) {
        this.model.setSelectedPin(pinId);
    }
    getToolMode() {
        return this.mode;
    }
    getToolType() {
        return this.type;
    }
    setToolMode(mode) {
        this.mode = mode;
    }
    setToolType(type) {
        this.type = type;
    }
    getDraggable() {
        return this.draggable;
    }
    setDraggable(draggable) {
        this.draggable = draggable;
    }
    setPrimaryColor(color) {
        this.styleAttributes = {
            ...this.styleAttributes,
            primaryColor: color,
        };
    }
    setAccentColor(color) {
        this.styleAttributes = {
            ...this.styleAttributes,
            accentColor: color,
        };
    }
    getStyleAttributes() {
        return this.styleAttributes;
    }
    updateDraggable(draggable, worldPosition, partId) {
        if (this.draggable != null) {
            this.draggable = draggable;
        }
        const pin = this.model.getPinById(draggable.id);
        if (pin != null) {
            this.updatePin({
                ...pin,
                worldPosition,
                partId,
            });
        }
    }
}
//# sourceMappingURL=controller.js.map
