import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import { base as base$1 } from './_size/base.js';
import { base as base$3 } from './_toggleSize/base.js';
import { base as base$2 } from './_view/base.js';
import { base as base$5 } from './_focused/base.js';
import { base as base$4 } from './_disabled/base.js';
import { cx } from '../../utils/index.js';
import { StyledContent, StyledInput, StyledLabel, StyledTrigger, StyledDescription, base } from './Switch.styles.js';
import { classes } from './Switch.tokens.js';

var _StyledTrigger;
var _excluded = ["size", "toggleSize", "view", "focused", "outlined", "disabled", "labelPosition", "label", "description", "singleLine", "id", "style", "className", "checked", "pressed", "defaultChecked"];
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,
      checked = props.checked,
      pressed = props.pressed,
      defaultChecked = props.defaultChecked,
      rest = _objectWithoutProperties(props, _excluded);
    var exactChecked = Boolean((checked !== null && checked !== void 0 ? checked : pressed) !== undefined ? checked !== null && checked !== void 0 ? checked : pressed : defaultChecked);
    return /*#__PURE__*/React__default.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__default.createElement(StyledContent, {
      className: cx(classes["".concat(labelPosition, "SwitchLabelPosition")])
    }, /*#__PURE__*/React__default.createElement(StyledInput, _extends({}, rest, {
      ref: ref,
      role: "switch",
      "aria-checked": exactChecked,
      type: "checkbox",
      checked: checked !== null && checked !== void 0 ? checked : pressed,
      defaultChecked: defaultChecked,
      disabled: disabled
    })), label && /*#__PURE__*/React__default.createElement(StyledLabel, {
      tabIndex: -1,
      className: singleLine ? classes.singleLine : ''
    }, label), _StyledTrigger || (_StyledTrigger = /*#__PURE__*/React__default.createElement(StyledTrigger, {
      "aria-hidden": true
    }))), description && /*#__PURE__*/React__default.createElement(StyledDescription, null, description));
  });
};
var switchConfig = {
  name: 'Switch',
  tag: 'label',
  base: base,
  layout: switchRoot,
  variations: {
    size: {
      css: base$1
    },
    view: {
      css: base$2
    },
    toggleSize: {
      css: base$3
    },
    disabled: {
      css: base$4,
      attrs: true
    },
    focused: {
      css: base$5
    }
  },
  defaults: {
    size: 's',
    view: 'default'
  }
};

export { switchConfig, switchRoot };
