"use strict";

exports.__esModule = true;
exports.default = exports.Wrapper = exports.Switch = exports.ContainedCheckbox = exports.Caption = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _Text = _interopRequireDefault(require("./Text"));
var _utils = require("../utils");
var _withId = _interopRequireDefault(require("../hocs/withId"));
var _excluded = ["onColor", "offColor", "onCaption", "offCaption"],
  _excluded2 = ["value", "onCaption", "offCaption", "onColor", "offColor", "id"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var switchSpeed = 200;
var FilteredLabel = function FilteredLabel(_ref) {
  var onColor = _ref.onColor,
    offColor = _ref.offColor,
    onCaption = _ref.onCaption,
    offCaption = _ref.offCaption,
    props = _objectWithoutProperties(_ref, _excluded);
  return /*#__PURE__*/_react.default.createElement("label", props);
};
var Wrapper = exports.Wrapper = (0, _styledComponents.default)(FilteredLabel).withConfig({
  displayName: "Switch__Wrapper",
  componentId: "sc-11t3swg-0"
})(["display:inline-block;position:relative;height:1.2em;width:5em;border-radius:0.6em;display:flex;cursor:pointer;", ";transition:background-color ", "ms ease-in,color ", "ms ease-in;&::after{content:\"\";position:absolute;top:2px;height:calc(1.2em - 4px);left:calc(50% - (0.5 * (1.2em - 4px)));width:calc(1.2em - 4px);background-color:#ffffff;border-radius:50%;transition:transform ", "ms ease-in;", ";}&:focus-within,&:hover{box-shadow:0 0 4px #4fa1f0;}"], (0, _utils.ifFlag)("value", (0, _styledComponents.css)(["color:#ffffff;background-color:", ";"], (0, _utils.ifFlag)("onColor", function (props) {
  return props.onColor;
}, (0, _utils.getThemeProp)(["colors", "application", "base"], "#ff0000"))), (0, _styledComponents.css)(["color:", ";background-color:", ";"], (0, _utils.getThemeProp)(["colors", "text"], "#333333"), (0, _utils.ifFlag)("offColor", function (props) {
  return props.offColor;
}, (0, _utils.getThemeProp)(["colors", "borderLight"], "#cccccc")))), switchSpeed, switchSpeed, switchSpeed, (0, _utils.ifFlag)("value", (0, _styledComponents.css)(["transform:translateX(-1.9em);"]), (0, _styledComponents.css)(["transform:translateX(1.9em);"])));
var Caption = exports.Caption = _styledComponents.default.span.withConfig({
  displayName: "Switch__Caption",
  componentId: "sc-11t3swg-1"
})(["position:absolute;left:1.4em;right:1.4em;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-align:center;font-size:0.8em;", ";"], (0, _utils.ifFlag)("value", (0, _styledComponents.css)(["opacity:1;transition:opacity ", "ms ", "ms ease-in;"], 0.7 * switchSpeed, 0.3 * switchSpeed), (0, _styledComponents.css)(["opacity:0;transition:opacity ", "ms ease-in;"], 0.7 * switchSpeed)));
var ContainedCheckbox = exports.ContainedCheckbox = _styledComponents.default.input.attrs(function () {
  return {
    type: "checkbox"
  };
}).withConfig({
  displayName: "Switch__ContainedCheckbox",
  componentId: "sc-11t3swg-2"
})(["position:absolute;opacity:0;"]);
var Switch = exports.Switch = function Switch(_ref2) {
  var value = _ref2.value,
    onCaption = _ref2.onCaption,
    offCaption = _ref2.offCaption,
    onColor = _ref2.onColor,
    offColor = _ref2.offColor,
    id = _ref2.id,
    checkboxProps = _objectWithoutProperties(_ref2, _excluded2);
  return /*#__PURE__*/_react.default.createElement(Wrapper, {
    htmlFor: id,
    value: value,
    onColor: onColor,
    offColor: offColor
  }, /*#__PURE__*/_react.default.createElement(ContainedCheckbox, _extends({
    id: id
  }, checkboxProps, {
    checked: value
  })), onCaption ? /*#__PURE__*/_react.default.createElement(Caption, {
    value: value
  }, /*#__PURE__*/_react.default.createElement(_Text.default, {
    message: onCaption
  })) : null, offCaption ? /*#__PURE__*/_react.default.createElement(Caption, {
    value: !value
  }, /*#__PURE__*/_react.default.createElement(_Text.default, {
    message: offCaption
  })) : null);
};
var _default = (0, _withId.default)("switch")(Switch);
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(switchSpeed, "switchSpeed", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(FilteredLabel, "FilteredLabel", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(Wrapper, "Wrapper", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(Caption, "Caption", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(ContainedCheckbox, "ContainedCheckbox", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(Switch, "Switch", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/Switch.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(switchSpeed, "switchSpeed", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(FilteredLabel, "FilteredLabel", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(Wrapper, "Wrapper", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(Caption, "Caption", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(ContainedCheckbox, "ContainedCheckbox", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(Switch, "Switch", "/home/vsts/work/1/s/src/components/Switch.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/Switch.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();