import { BaseInputElement, OptionElement } from "./index";
import { ElementType } from "../../../constants/UIKitConstants";
/**
 * Represents a dropdown input element.
 */
export class DropdownElement extends BaseInputElement {
    /**
     * The label of the input element.
     */
    label;
    /**
     * The default value to be selected in the dropdown.
     */
    defaultValue;
    /**
     * The options available for the dropdown input element.
     */
    options;
    /**
     * Creates a new instance of DropdownInput.
     * @param elementId - The ID of the input element.
     * @param label - The label of the input element.
     * @param options - The options available for the dropdown input element.
     */
    constructor(elementId, label, options = []) {
        super(elementId, ElementType.dropdown);
        this.label = label || "";
        this.options = options.map((option) => {
            if (option instanceof OptionElement) {
                return option;
            }
            else {
                return OptionElement.fromJSON(option);
            }
        });
    }
    /**
     * Gets the label of the input element.
     * @returns The label of the input element.
     */
    getLabel() {
        return this.label;
    }
    /**
     * Gets the default value to be selected in the dropdown.
     * @returns The default value to be selected in the dropdown.
     */
    getDefaultValue() {
        return this.defaultValue;
    }
    /**
     * Sets the default value to be selected in the dropdown.
     * @param defaultValue - The default value to be selected in the dropdown.
     */
    setDefaultValue(defaultValue) {
        this.defaultValue = defaultValue;
    }
    /**
     * Gets the options available for the dropdown input element.
     * @returns The options available for the dropdown input element.
     */
    getOptions() {
        return this.options;
    }
    static fromJSON(json) {
        const options = (json?.options || []).map((option) => {
            return OptionElement.fromJSON(option);
        });
        const dropdownElement = new DropdownElement(json.elementId, json.label, options);
        if (json.defaultValue)
            dropdownElement.setDefaultValue(json.defaultValue);
        return dropdownElement;
    }
}
//# sourceMappingURL=DropdownElement.js.map