import m, { PureComponent as b, Component as s } from "react";
import y from "../../../../../../lodash-es@4.17.21/node_modules/lodash-es/debounce.js";
import { toState as c, simpleCheckForValidColor as v } from "../../helpers/color.js";
var l = Object.assign || function(o) {
  for (var e = 1; e < arguments.length; e++) {
    var r = arguments[e];
    for (var a in r)
      Object.prototype.hasOwnProperty.call(r, a) && (o[a] = r[a]);
  }
  return o;
}, d = /* @__PURE__ */ function() {
  function o(e, r) {
    for (var a = 0; a < r.length; a++) {
      var n = r[a];
      n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
    }
  }
  return function(e, r, a) {
    return r && o(e.prototype, r), a && o(e, a), e;
  };
}();
function g(o, e) {
  if (!(o instanceof e))
    throw new TypeError("Cannot call a class as a function");
}
function _(o, e) {
  if (!o)
    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  return e && (typeof e == "object" || typeof e == "function") ? e : o;
}
function w(o, e) {
  if (typeof e != "function" && e !== null)
    throw new TypeError("Super expression must either be null or a function, not " + typeof e);
  o.prototype = Object.create(e && e.prototype, { constructor: { value: o, enumerable: !1, writable: !0, configurable: !0 } }), e && (Object.setPrototypeOf ? Object.setPrototypeOf(o, e) : o.__proto__ = e);
}
var H = function(e) {
  var r = function(a) {
    w(n, a);
    function n(h) {
      g(this, n);
      var t = _(this, (n.__proto__ || Object.getPrototypeOf(n)).call(this));
      return t.handleChange = function(i, f) {
        var u = v(i);
        if (u) {
          var p = c(i, i.h || t.state.oldHue);
          t.setState(p), t.props.onChangeComplete && t.debounce(t.props.onChangeComplete, p, f), t.props.onChange && t.props.onChange(p, f);
        }
      }, t.handleSwatchHover = function(i, f) {
        var u = v(i);
        if (u) {
          var p = c(i, i.h || t.state.oldHue);
          t.props.onSwatchHover && t.props.onSwatchHover(p, f);
        }
      }, t.state = l({}, c(h.color, 0)), t.debounce = y(function(i, f, u) {
        i(f, u);
      }, 100), t;
    }
    return d(n, [{
      key: "render",
      value: function() {
        var t = {};
        return this.props.onSwatchHover && (t.onSwatchHover = this.handleSwatchHover), m.createElement(e, l({}, this.props, this.state, {
          onChange: this.handleChange
        }, t));
      }
    }], [{
      key: "getDerivedStateFromProps",
      value: function(t, i) {
        return l({}, c(t.color, i.oldHue));
      }
    }]), n;
  }(b || s);
  return r.propTypes = l({}, e.propTypes), r.defaultProps = l({}, e.defaultProps, {
    color: {
      h: 250,
      s: 0.5,
      l: 0.2,
      a: 1
    }
  }), r;
};
export {
  H as ColorWrap,
  H as default
};
//# sourceMappingURL=ColorWrap.js.map
