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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React, { forwardRef, useRef, useId } from "react";
import { cn } from "@utils";
import { ADPIcon } from "../adpIcon";
import { toggleWrapperVariants, toggleContainerVariants, toggleButtonVariants, toggleIconVariants, toggleLabelVariants } from "./toggleVariants";
/**
 * Toggle component for toggling boolean states
 */
export const Toggle = forwardRef((_a, ref) => {
    var { id, className, size = "md", label, toggled, toggledIcon, untoggledIcon, disabled } = _a, restProps = __rest(_a, ["id", "className", "size", "label", "toggled", "toggledIcon", "untoggledIcon", "disabled"]);
    const inputId = useRef(useId());
    const icon = toggled ? toggledIcon : untoggledIcon;
    return (_jsxs("label", { className: cn(toggleWrapperVariants(), className), children: [_jsx("input", Object.assign({}, restProps, { type: "checkbox", id: id || inputId.current, className: "absolute invisible w-0 h-0 outline-none", checked: toggled, disabled: disabled, ref: ref })), _jsx("div", { className: cn(toggleContainerVariants({ size }), toggled && "bg-primary-500 dark:bg-primary-400", disabled && "bg-gray-200 dark:bg-secondary-600 cursor-not-allowed", toggled && disabled && "bg-primary-500/50 dark:bg-primary-400/50", !toggled && !disabled && [
                    "focus-within:shadow-primary-2px",
                    "focus-within:ring-1",
                    "focus-within:ring-primary-100",
                    "focus-within:transition-all",
                    "focus-within:duration-300"
                ], toggled && !disabled && "focus-within:shadow-primary-2px"), children: _jsx("span", { className: cn(toggleButtonVariants({ size }), toggled && "translate-x-full -translate-y-1/2 rtl:-translate-x-full", disabled && "bg-secondary-50 dark:bg-gray-900"), children: icon && (_jsx(ADPIcon, { className: cn(toggleIconVariants()), icon: icon, height: 10, width: 10 })) }) }), typeof label !== "undefined" && (_jsx("span", { className: cn(toggleLabelVariants({ size, disabled })), children: label }))] }));
});
Toggle.displayName = "Toggle";
//# sourceMappingURL=toggle.js.map