import { __exports as g } from "./index-_virtual67.js";
import ae from "react";
import { __require as oe } from "./index-prop-types.js";
import { __require as se } from "./index-classnames2.js";
import ue from "./index-_virtual62.js";
import ie from "./index-_virtual41.js";
import le from "./index-_virtual68.js";
import fe from "./index-_virtual51.js";
import de from "./index-_virtual55.js";
import ce from "./index-_virtual61.js";
var K;
function Pe() {
  if (K) return g;
  K = 1;
  function P(e) {
    "@babel/helpers - typeof";
    return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? P = function(t) {
      return typeof t;
    } : P = function(t) {
      return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
    }, P(e);
  }
  Object.defineProperty(g, "__esModule", {
    value: !0
  }), g.default = g.rangeShape = void 0;
  var O = F(ae), a = _(/* @__PURE__ */ oe()), S = _(se()), q = _(ue), R = _(ie), j = _(le), w = _(fe), B = _(de), I = _(ce);
  function _(e) {
    return e && e.__esModule ? e : { default: e };
  }
  function T(e) {
    if (typeof WeakMap != "function") return null;
    var r = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap();
    return (T = function(d) {
      return d ? t : r;
    })(e);
  }
  function F(e, r) {
    if (e && e.__esModule)
      return e;
    if (e === null || P(e) !== "object" && typeof e != "function")
      return { default: e };
    var t = T(r);
    if (t && t.has(e))
      return t.get(e);
    var n = {}, d = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for (var s in e)
      if (s !== "default" && Object.prototype.hasOwnProperty.call(e, s)) {
        var o = d ? Object.getOwnPropertyDescriptor(e, s) : null;
        o && (o.get || o.set) ? Object.defineProperty(n, s, o) : n[s] = e[s];
      }
    return n.default = e, t && t.set(e, n), n;
  }
  function C() {
    return C = Object.assign || function(e) {
      for (var r = 1; r < arguments.length; r++) {
        var t = arguments[r];
        for (var n in t)
          Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
      }
      return e;
    }, C.apply(this, arguments);
  }
  function A(e, r) {
    var t = Object.keys(e);
    if (Object.getOwnPropertySymbols) {
      var n = Object.getOwnPropertySymbols(e);
      r && (n = n.filter(function(d) {
        return Object.getOwnPropertyDescriptor(e, d).enumerable;
      })), t.push.apply(t, n);
    }
    return t;
  }
  function H(e) {
    for (var r = 1; r < arguments.length; r++) {
      var t = arguments[r] != null ? arguments[r] : {};
      r % 2 ? A(Object(t), !0).forEach(function(n) {
        l(e, n, t[n]);
      }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : A(Object(t)).forEach(function(n) {
        Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
      });
    }
    return e;
  }
  function z(e) {
    return Q(e) || J(e) || G(e) || L();
  }
  function L() {
    throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
  }
  function G(e, r) {
    if (e) {
      if (typeof e == "string") return k(e, r);
      var t = Object.prototype.toString.call(e).slice(8, -1);
      if (t === "Object" && e.constructor && (t = e.constructor.name), t === "Map" || t === "Set") return Array.from(e);
      if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)) return k(e, r);
    }
  }
  function J(e) {
    if (typeof Symbol < "u" && e[Symbol.iterator] != null || e["@@iterator"] != null) return Array.from(e);
  }
  function Q(e) {
    if (Array.isArray(e)) return k(e);
  }
  function k(e, r) {
    (r == null || r > e.length) && (r = e.length);
    for (var t = 0, n = new Array(r); t < r; t++)
      n[t] = e[t];
    return n;
  }
  function V(e, r) {
    if (!(e instanceof r))
      throw new TypeError("Cannot call a class as a function");
  }
  function X(e, r) {
    for (var t = 0; t < r.length; t++) {
      var n = r[t];
      n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
    }
  }
  function Y(e, r, t) {
    return r && X(e.prototype, r), e;
  }
  function Z(e, r) {
    if (typeof r != "function" && r !== null)
      throw new TypeError("Super expression must either be null or a function");
    e.prototype = Object.create(r && r.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), r && W(e, r);
  }
  function W(e, r) {
    return W = Object.setPrototypeOf || function(n, d) {
      return n.__proto__ = d, n;
    }, W(e, r);
  }
  function ee(e) {
    var r = re();
    return function() {
      var n = D(e), d;
      if (r) {
        var s = D(this).constructor;
        d = Reflect.construct(n, arguments, s);
      } else
        d = n.apply(this, arguments);
      return te(this, d);
    };
  }
  function te(e, r) {
    return r && (P(r) === "object" || typeof r == "function") ? r : E(e);
  }
  function E(e) {
    if (e === void 0)
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return e;
  }
  function re() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
      })), !0;
    } catch {
      return !1;
    }
  }
  function D(e) {
    return D = Object.setPrototypeOf ? Object.getPrototypeOf : function(t) {
      return t.__proto__ || Object.getPrototypeOf(t);
    }, D(e);
  }
  function l(e, r, t) {
    return r in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e;
  }
  var $ = /* @__PURE__ */ (function(e) {
    Z(t, e);
    var r = ee(t);
    function t(n, d) {
      var s;
      return V(this, t), s = r.call(this, n, d), l(E(s), "handleKeyEvent", function(o) {
        var u = s.props, f = u.day, c = u.onMouseDown, h = u.onMouseUp;
        [
          13,
          32
          /* enter */
        ].includes(o.keyCode) && (o.type === "keydown" ? c(f) : h(f));
      }), l(E(s), "handleMouseEvent", function(o) {
        var u = s.props, f = u.day, c = u.disabled, h = u.onPreviewChange, b = u.onMouseEnter, p = u.onMouseDown, m = u.onMouseUp, i = {};
        if (c) {
          h();
          return;
        }
        switch (o.type) {
          case "mouseenter":
            b(f), h(f), i.hover = !0;
            break;
          case "blur":
          case "mouseleave":
            i.hover = !1;
            break;
          case "mousedown":
            i.active = !0, p(f);
            break;
          case "mouseup":
            o.stopPropagation(), i.active = !1, m(f);
            break;
          case "focus":
            h(f);
            break;
        }
        Object.keys(i).length && s.setState(i);
      }), l(E(s), "getClassNames", function() {
        var o, u = s.props, f = u.isPassive, c = u.isToday, h = u.isWeekend, b = u.isStartOfWeek, p = u.isEndOfWeek, m = u.isStartOfMonth, i = u.isEndOfMonth, y = u.disabled, v = u.styles;
        return (0, S.default)(v.day, (o = {}, l(o, v.dayPassive, f), l(o, v.dayDisabled, y), l(o, v.dayToday, c), l(o, v.dayWeekend, h), l(o, v.dayStartOfWeek, b), l(o, v.dayEndOfWeek, p), l(o, v.dayStartOfMonth, m), l(o, v.dayEndOfMonth, i), l(o, v.dayHovered, s.state.hover), l(o, v.dayActive, s.state.active), o));
      }), l(E(s), "renderPreviewPlaceholder", function() {
        var o, u = s.props, f = u.preview, c = u.day, h = u.styles;
        if (!f) return null;
        var b = f.startDate ? (0, q.default)(f.startDate) : null, p = f.endDate ? (0, I.default)(f.endDate) : null, m = (!b || (0, j.default)(c, b)) && (!p || (0, R.default)(c, p)), i = !m && (0, w.default)(c, b), y = !m && (0, w.default)(c, p);
        return /* @__PURE__ */ O.default.createElement("span", {
          className: (0, S.default)((o = {}, l(o, h.dayStartPreview, i), l(o, h.dayInPreview, m), l(o, h.dayEndPreview, y), o)),
          style: {
            color: f.color
          }
        });
      }), l(E(s), "renderSelectionPlaceholders", function() {
        var o = s.props, u = o.styles, f = o.ranges, c = o.day;
        if (s.props.displayMode === "date") {
          var h = (0, w.default)(s.props.day, s.props.date);
          return h ? /* @__PURE__ */ O.default.createElement("span", {
            className: u.selected,
            style: {
              color: s.props.color
            }
          }) : null;
        }
        var b = f.reduce(function(p, m) {
          var i = m.startDate, y = m.endDate;
          if (i && y && (0, R.default)(y, i)) {
            var v = [y, i];
            i = v[0], y = v[1];
          }
          i = i ? (0, q.default)(i) : null, y = y ? (0, I.default)(y) : null;
          var M = (!i || (0, j.default)(c, i)) && (!y || (0, R.default)(c, y)), U = !M && (0, w.default)(c, i), x = !M && (0, w.default)(c, y);
          return M || U || x ? [].concat(z(p), [H({
            isStartEdge: U,
            isEndEdge: x,
            isInRange: M
          }, m)]) : p;
        }, []);
        return b.map(function(p, m) {
          var i;
          return /* @__PURE__ */ O.default.createElement("span", {
            key: m,
            className: (0, S.default)((i = {}, l(i, u.startEdge, p.isStartEdge), l(i, u.endEdge, p.isEndEdge), l(i, u.inRange, p.isInRange), i)),
            style: {
              color: p.color || s.props.color
            }
          });
        });
      }), s.state = {
        hover: !1,
        active: !1
      }, s;
    }
    return Y(t, [{
      key: "render",
      value: function() {
        var d = this.props.dayContentRenderer;
        return /* @__PURE__ */ O.default.createElement("button", C({
          type: "button",
          onMouseEnter: this.handleMouseEvent,
          onMouseLeave: this.handleMouseEvent,
          onFocus: this.handleMouseEvent,
          onMouseDown: this.handleMouseEvent,
          onMouseUp: this.handleMouseEvent,
          onBlur: this.handleMouseEvent,
          onPauseCapture: this.handleMouseEvent,
          onKeyDown: this.handleKeyEvent,
          onKeyUp: this.handleKeyEvent,
          className: this.getClassNames(this.props.styles)
        }, this.props.disabled || this.props.isPassive ? {
          tabIndex: -1
        } : {}, {
          style: {
            color: this.props.color
          }
        }), this.renderSelectionPlaceholders(), this.renderPreviewPlaceholder(), /* @__PURE__ */ O.default.createElement("span", {
          className: this.props.styles.dayNumber
        }, (d == null ? void 0 : d(this.props.day)) || /* @__PURE__ */ O.default.createElement("span", null, (0, B.default)(this.props.day, this.props.dayDisplayFormat))));
      }
    }]), t;
  })(O.Component);
  $.defaultProps = {};
  var N = a.default.shape({
    startDate: a.default.object,
    endDate: a.default.object,
    color: a.default.string,
    key: a.default.string,
    autoFocus: a.default.bool,
    disabled: a.default.bool,
    showDateDisplay: a.default.bool
  });
  g.rangeShape = N, $.propTypes = {
    day: a.default.object.isRequired,
    dayDisplayFormat: a.default.string,
    date: a.default.object,
    ranges: a.default.arrayOf(N),
    preview: a.default.shape({
      startDate: a.default.object,
      endDate: a.default.object,
      color: a.default.string
    }),
    onPreviewChange: a.default.func,
    previewColor: a.default.string,
    disabled: a.default.bool,
    isPassive: a.default.bool,
    isToday: a.default.bool,
    isWeekend: a.default.bool,
    isStartOfWeek: a.default.bool,
    isEndOfWeek: a.default.bool,
    isStartOfMonth: a.default.bool,
    isEndOfMonth: a.default.bool,
    color: a.default.string,
    displayMode: a.default.oneOf(["dateRange", "date"]),
    styles: a.default.object,
    onMouseDown: a.default.func,
    onMouseUp: a.default.func,
    onMouseEnter: a.default.func,
    dayContentRenderer: a.default.func
  };
  var ne = $;
  return g.default = ne, g;
}
export {
  Pe as __require
};
