"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireWildcard(require("react"));
var _index = _interopRequireDefault(require("../index"));
var _storybookSnapper = require("storybook-snapper");
var _visual = require("../../utils/test-utils/visual");
var _constants = require("../constants");
var _excluded = ["componentDidMount"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/ColorPicker/test/ColorPicker.visual.jsx",
  _this = void 0;
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var dataHook = 'interactive';
var clickConverter = function clickConverter(converter) {
  var dataHookSelector = '';
  switch (converter) {
    case 'hex':
      dataHookSelector = _constants.DataHooks.hexConverterBtn;
      break;
    case 'rgb':
      dataHookSelector = _constants.DataHooks.rgbConverterBtn;
      break;
    case 'hsb':
      dataHookSelector = _constants.DataHooks.hsbConverterBtn;
      break;
  }
  (0, _visual.clickElement)(dataHookSelector);
  (0, _visual.focusElement)(dataHookSelector);
};
var ColorPickerWrapper = function ColorPickerWrapper(_ref) {
  var componentDidMount = _ref.componentDidMount,
    rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
  (0, _react.useEffect)(function () {
    componentDidMount && componentDidMount();
  }, [componentDidMount]);
  return /*#__PURE__*/_react["default"].createElement(_index["default"], (0, _extends2["default"])({
    dataHook: dataHook
  }, rest, {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 31,
      columnNumber: 10
    }
  }));
};
var defaultProps = {
  value: '#3899eb',
  emptyPlaceholder: 'No Fill'
};
// showConverter={false} showInput={false}
var tests = [{
  describe: 'ColorPicker',
  its: [{
    it: 'should render with input and converter',
    props: _objectSpread({}, defaultProps)
  }, {
    it: 'should render with input and  without converter',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showConverter: false
    })
  }, {
    it: 'should render without input and converter',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showInput: false,
      showConverter: false
    })
  }, {
    it: 'should render without action buttons',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showActionButtons: false
    })
  }, {
    it: 'should render the RGB inputs when clicking on the RGB tab',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showConverter: true
    }),
    componentDidMount: function componentDidMount() {
      return clickConverter('rgb');
    }
  }, {
    it: 'should render the HSB inputs when clicking on the HSB tab',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showConverter: true
    }),
    componentDidMount: function () {
      var _componentDidMount = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
        return _regenerator["default"].wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              return _context.abrupt("return", clickConverter('hsb'));
            case 1:
            case "end":
              return _context.stop();
          }
        }, _callee);
      }));
      function componentDidMount() {
        return _componentDidMount.apply(this, arguments);
      }
      return componentDidMount;
    }()
  }, {
    it: 'should render with padding (default)',
    props: _objectSpread({}, defaultProps)
  }, {
    it: 'should render without padding',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      removePadding: true
    })
  }]
}];
tests.forEach(function (_ref2) {
  var describe = _ref2.describe,
    its = _ref2.its;
  its.forEach(function (_ref3) {
    var it = _ref3.it,
      props = _ref3.props,
      componentDidMount = _ref3.componentDidMount;
    (0, _storybookSnapper.visualize)(describe, function () {
      (0, _storybookSnapper.snap)(it, function (done) {
        return /*#__PURE__*/_react["default"].createElement(ColorPickerWrapper, (0, _extends2["default"])({}, props, {
          componentDidMount: componentDidMount,
          onDone: done,
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 106,
            columnNumber: 9
          }
        }));
      });
    });
  });
});