var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React, { forwardRef } from "react";
import { BodyShort, ErrorMessage, Label } from "../../typography/index.js";
import { Floating } from "../../utils/components/floating/Floating.js";
import { cl } from "../../utils/helpers/index.js";
import { ReadOnlyIconWithTitle } from "../ReadOnlyIcon.js";
import ComboboxWrapper from "./ComboboxWrapper.js";
import FilteredOptions from "./FilteredOptions/FilteredOptions.js";
import { useInputContext } from "./Input/Input.context.js";
import { InputController } from "./Input/InputController.js";
export const Combobox = forwardRef((props, ref) => {
    const { className, hideLabel = false, description, label } = props, rest = __rest(props, ["className", "hideLabel", "description", "label"]);
    const { error, errorId, hasError, inputDescriptionId, inputProps, showErrorMsg, size = "medium", readOnly, } = useInputContext();
    return (React.createElement(Floating, null,
        React.createElement(ComboboxWrapper, { className: className, hasError: hasError, inputProps: inputProps, inputSize: size },
            React.createElement(Label, { htmlFor: inputProps.id, size: size, className: cl("aksel-form-field__label", {
                    "aksel-sr-only": hideLabel,
                }) },
                readOnly && React.createElement(ReadOnlyIconWithTitle, null),
                label),
            !!description && (React.createElement(BodyShort, { as: "div", className: cl("aksel-form-field__description", {
                    "aksel-sr-only": hideLabel,
                }), id: inputDescriptionId, size: size }, description)),
            React.createElement("div", { className: "aksel-combobox__wrapper" },
                React.createElement(InputController, Object.assign({ ref: ref }, rest)),
                React.createElement(FilteredOptions, null)),
            React.createElement("div", { className: "aksel-form-field__error", id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (React.createElement(ErrorMessage, { size: size, showIcon: true }, error))))));
});
export default Combobox;
//# sourceMappingURL=Combobox.js.map