function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
import React, { forwardRef } from "react";
import { base as sizeCSS } from "./_size/base";
import { base as toggleSizeCSS } from "./_toggleSize/base";
import { base as viewCSS } from "./_view/base";
import { base as focusedCSS } from "./_focused/base";
import { base as disabledCSS } from "./_disabled/base";
import { cx } from "../../utils";
import { StyledContent, StyledDescription, StyledInput, StyledLabel, StyledTrigger, base } from "./Switch.styles";
import { classes } from "./Switch.tokens";
export var switchRoot = function switchRoot(Root) {
    return /*#__PURE__*/ forwardRef(function(props, ref) {
        var size = props.size, toggleSize = props.toggleSize, view = props.view, focused = props.focused, outlined = props.outlined, disabled = props.disabled, labelPosition = props.labelPosition, label = props.label, description = props.description, _props_singleLine = props.singleLine, singleLine = _props_singleLine === void 0 ? true : _props_singleLine, id = props.id, style = props.style, className = props.className, // singleLine,
        checked = props.checked, pressed = props.pressed, defaultChecked = props.defaultChecked, rest = _object_without_properties(props, [
            "size",
            "toggleSize",
            "view",
            "focused",
            "outlined",
            "disabled",
            "labelPosition",
            "label",
            "description",
            "singleLine",
            "id",
            "style",
            "className",
            "checked",
            "pressed",
            "defaultChecked"
        ]);
        var exactChecked = Boolean((checked !== null && checked !== void 0 ? checked : pressed) !== undefined ? checked !== null && checked !== void 0 ? checked : pressed : defaultChecked);
        return /*#__PURE__*/ React.createElement(Root, {
            view: view,
            size: size,
            toggleSize: toggleSize,
            disabled: disabled,
            focused: focused !== null && focused !== void 0 ? focused : outlined,
            labelPosition: labelPosition,
            id: id,
            style: style,
            className: cx(className)
        }, /*#__PURE__*/ React.createElement(StyledContent, {
            className: cx(classes["".concat(labelPosition, "SwitchLabelPosition")])
        }, /*#__PURE__*/ React.createElement(StyledInput, _object_spread_props(_object_spread({}, rest), {
            ref: ref,
            role: "switch",
            "aria-checked": exactChecked,
            type: "checkbox",
            checked: checked !== null && checked !== void 0 ? checked : pressed,
            defaultChecked: defaultChecked,
            disabled: disabled
        })), /*#__PURE__*/ React.createElement(StyledLabel, {
            tabIndex: -1,
            className: singleLine ? classes.singleLine : ''
        }, label), /*#__PURE__*/ React.createElement(StyledTrigger, {
            "aria-hidden": true
        })), description && /*#__PURE__*/ React.createElement(StyledDescription, null, description));
    });
};
export var switchConfig = {
    name: 'Switch',
    tag: 'label',
    base: base,
    layout: switchRoot,
    variations: {
        size: {
            css: sizeCSS
        },
        view: {
            css: viewCSS
        },
        toggleSize: {
            css: toggleSizeCSS
        },
        disabled: {
            css: disabledCSS,
            attrs: true
        },
        focused: {
            css: focusedCSS
        }
    },
    defaults: {
        size: 's',
        view: 'default'
    }
};
