'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var reactDom = require('react-dom');

function _arrayLikeToArray(r, a) {
  (null == a || a > r.length) && (a = r.length);
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  return n;
}
function _arrayWithHoles(r) {
  if (Array.isArray(r)) return r;
}
function _arrayWithoutHoles(r) {
  if (Array.isArray(r)) return _arrayLikeToArray(r);
}
function _createForOfIteratorHelper(r, e) {
  var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  if (!t) {
    if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
      t && (r = t);
      var n = 0,
        F = function () {};
      return {
        s: F,
        n: function () {
          return n >= r.length ? {
            done: true
          } : {
            done: false,
            value: r[n++]
          };
        },
        e: function (r) {
          throw r;
        },
        f: F
      };
    }
    throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  }
  var o,
    a = true,
    u = false;
  return {
    s: function () {
      t = t.call(r);
    },
    n: function () {
      var r = t.next();
      return a = r.done, r;
    },
    e: function (r) {
      u = true, o = r;
    },
    f: function () {
      try {
        a || null == t.return || t.return();
      } finally {
        if (u) throw o;
      }
    }
  };
}
function _defineProperty(e, r, t) {
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
    value: t,
    enumerable: true,
    configurable: true,
    writable: true
  }) : e[r] = t, e;
}
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 _iterableToArray(r) {
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
}
function _iterableToArrayLimit(r, l) {
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  if (null != t) {
    var e,
      n,
      i,
      u,
      a = [],
      f = true,
      o = false;
    try {
      if (i = (t = t.call(r)).next, 0 === l) {
        if (Object(t) !== t) return;
        f = !1;
      } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
    } catch (r) {
      o = true, n = r;
    } finally {
      try {
        if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
      } finally {
        if (o) throw n;
      }
    }
    return a;
  }
}
function _nonIterableRest() {
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _nonIterableSpread() {
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
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 _objectSpread2(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = null != arguments[r] ? arguments[r] : {};
    r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
      _defineProperty(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;
}
function _objectWithoutProperties(e, t) {
  if (null == e) return {};
  var o,
    r,
    i = _objectWithoutPropertiesLoose(e, t);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(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 (-1 !== e.indexOf(n)) continue;
    t[n] = r[n];
  }
  return t;
}
function _slicedToArray(r, e) {
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _toConsumableArray(r) {
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
}
function _toPrimitive(t, r) {
  if ("object" != typeof t || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (void 0 !== e) {
    var i = e.call(t, r);
    if ("object" != typeof i) return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
  var i = _toPrimitive(t, "string");
  return "symbol" == typeof i ? i : i + "";
}
function _typeof(o) {
  "@babel/helpers - typeof";

  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
    return typeof o;
  } : function (o) {
    return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  }, _typeof(o);
}
function _unsupportedIterableToArray(r, a) {
  if (r) {
    if ("string" == typeof r) return _arrayLikeToArray(r, a);
    var t = {}.toString.call(r).slice(8, -1);
    return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  }
}

function getDefaultExportFromCjs (x) {
	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

var index = {};

var hasRequiredIndex;

function requireIndex () {
	if (hasRequiredIndex) return index;
	hasRequiredIndex = 1;
	var React$1 = React;

	function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

	var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);

	/*
	Based on Glamor's sheet
	https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
	*/ function _defineProperties(target, props) {
	    for(var i = 0; i < props.length; i++){
	        var descriptor = props[i];
	        descriptor.enumerable = descriptor.enumerable || false;
	        descriptor.configurable = true;
	        if ("value" in descriptor) descriptor.writable = true;
	        Object.defineProperty(target, descriptor.key, descriptor);
	    }
	}
	function _createClass(Constructor, protoProps, staticProps) {
	    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
	    return Constructor;
	}
	var isProd = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production";
	var isString = function(o) {
	    return Object.prototype.toString.call(o) === "[object String]";
	};
	var StyleSheet = /*#__PURE__*/ function() {
	    function StyleSheet(param) {
	        var ref = param === void 0 ? {} : param, _name = ref.name, name = _name === void 0 ? "stylesheet" : _name, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? isProd : _optimizeForSpeed;
	        invariant$1(isString(name), "`name` must be a string");
	        this._name = name;
	        this._deletedRulePlaceholder = "#" + name + "-deleted-rule____{}";
	        invariant$1(typeof optimizeForSpeed === "boolean", "`optimizeForSpeed` must be a boolean");
	        this._optimizeForSpeed = optimizeForSpeed;
	        this._serverSheet = undefined;
	        this._tags = [];
	        this._injected = false;
	        this._rulesCount = 0;
	        var node = typeof window !== "undefined" && document.querySelector('meta[property="csp-nonce"]');
	        this._nonce = node ? node.getAttribute("content") : null;
	    }
	    var _proto = StyleSheet.prototype;
	    _proto.setOptimizeForSpeed = function setOptimizeForSpeed(bool) {
	        invariant$1(typeof bool === "boolean", "`setOptimizeForSpeed` accepts a boolean");
	        invariant$1(this._rulesCount === 0, "optimizeForSpeed cannot be when rules have already been inserted");
	        this.flush();
	        this._optimizeForSpeed = bool;
	        this.inject();
	    };
	    _proto.isOptimizeForSpeed = function isOptimizeForSpeed() {
	        return this._optimizeForSpeed;
	    };
	    _proto.inject = function inject() {
	        var _this = this;
	        invariant$1(!this._injected, "sheet already injected");
	        this._injected = true;
	        if (typeof window !== "undefined" && this._optimizeForSpeed) {
	            this._tags[0] = this.makeStyleTag(this._name);
	            this._optimizeForSpeed = "insertRule" in this.getSheet();
	            if (!this._optimizeForSpeed) {
	                if (!isProd) {
	                    console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.");
	                }
	                this.flush();
	                this._injected = true;
	            }
	            return;
	        }
	        this._serverSheet = {
	            cssRules: [],
	            insertRule: function(rule, index) {
	                if (typeof index === "number") {
	                    _this._serverSheet.cssRules[index] = {
	                        cssText: rule
	                    };
	                } else {
	                    _this._serverSheet.cssRules.push({
	                        cssText: rule
	                    });
	                }
	                return index;
	            },
	            deleteRule: function(index) {
	                _this._serverSheet.cssRules[index] = null;
	            }
	        };
	    };
	    _proto.getSheetForTag = function getSheetForTag(tag) {
	        if (tag.sheet) {
	            return tag.sheet;
	        }
	        // this weirdness brought to you by firefox
	        for(var i = 0; i < document.styleSheets.length; i++){
	            if (document.styleSheets[i].ownerNode === tag) {
	                return document.styleSheets[i];
	            }
	        }
	    };
	    _proto.getSheet = function getSheet() {
	        return this.getSheetForTag(this._tags[this._tags.length - 1]);
	    };
	    _proto.insertRule = function insertRule(rule, index) {
	        invariant$1(isString(rule), "`insertRule` accepts only strings");
	        if (typeof window === "undefined") {
	            if (typeof index !== "number") {
	                index = this._serverSheet.cssRules.length;
	            }
	            this._serverSheet.insertRule(rule, index);
	            return this._rulesCount++;
	        }
	        if (this._optimizeForSpeed) {
	            var sheet = this.getSheet();
	            if (typeof index !== "number") {
	                index = sheet.cssRules.length;
	            }
	            // this weirdness for perf, and chrome's weird bug
	            // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
	            try {
	                sheet.insertRule(rule, index);
	            } catch (error) {
	                if (!isProd) {
	                    console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
	                }
	                return -1;
	            }
	        } else {
	            var insertionPoint = this._tags[index];
	            this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint));
	        }
	        return this._rulesCount++;
	    };
	    _proto.replaceRule = function replaceRule(index, rule) {
	        if (this._optimizeForSpeed || typeof window === "undefined") {
	            var sheet = typeof window !== "undefined" ? this.getSheet() : this._serverSheet;
	            if (!rule.trim()) {
	                rule = this._deletedRulePlaceholder;
	            }
	            if (!sheet.cssRules[index]) {
	                // @TBD Should we throw an error?
	                return index;
	            }
	            sheet.deleteRule(index);
	            try {
	                sheet.insertRule(rule, index);
	            } catch (error) {
	                if (!isProd) {
	                    console.warn("StyleSheet: illegal rule: \n\n" + rule + "\n\nSee https://stackoverflow.com/q/20007992 for more info");
	                }
	                // In order to preserve the indices we insert a deleteRulePlaceholder
	                sheet.insertRule(this._deletedRulePlaceholder, index);
	            }
	        } else {
	            var tag = this._tags[index];
	            invariant$1(tag, "old rule at index `" + index + "` not found");
	            tag.textContent = rule;
	        }
	        return index;
	    };
	    _proto.deleteRule = function deleteRule(index) {
	        if (typeof window === "undefined") {
	            this._serverSheet.deleteRule(index);
	            return;
	        }
	        if (this._optimizeForSpeed) {
	            this.replaceRule(index, "");
	        } else {
	            var tag = this._tags[index];
	            invariant$1(tag, "rule at index `" + index + "` not found");
	            tag.parentNode.removeChild(tag);
	            this._tags[index] = null;
	        }
	    };
	    _proto.flush = function flush() {
	        this._injected = false;
	        this._rulesCount = 0;
	        if (typeof window !== "undefined") {
	            this._tags.forEach(function(tag) {
	                return tag && tag.parentNode.removeChild(tag);
	            });
	            this._tags = [];
	        } else {
	            // simpler on server
	            this._serverSheet.cssRules = [];
	        }
	    };
	    _proto.cssRules = function cssRules() {
	        var _this = this;
	        if (typeof window === "undefined") {
	            return this._serverSheet.cssRules;
	        }
	        return this._tags.reduce(function(rules, tag) {
	            if (tag) {
	                rules = rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules, function(rule) {
	                    return rule.cssText === _this._deletedRulePlaceholder ? null : rule;
	                }));
	            } else {
	                rules.push(null);
	            }
	            return rules;
	        }, []);
	    };
	    _proto.makeStyleTag = function makeStyleTag(name, cssString, relativeToTag) {
	        if (cssString) {
	            invariant$1(isString(cssString), "makeStyleTag accepts only strings as second parameter");
	        }
	        var tag = document.createElement("style");
	        if (this._nonce) tag.setAttribute("nonce", this._nonce);
	        tag.type = "text/css";
	        tag.setAttribute("data-" + name, "");
	        if (cssString) {
	            tag.appendChild(document.createTextNode(cssString));
	        }
	        var head = document.head || document.getElementsByTagName("head")[0];
	        if (relativeToTag) {
	            head.insertBefore(tag, relativeToTag);
	        } else {
	            head.appendChild(tag);
	        }
	        return tag;
	    };
	    _createClass(StyleSheet, [
	        {
	            key: "length",
	            get: function get() {
	                return this._rulesCount;
	            }
	        }
	    ]);
	    return StyleSheet;
	}();
	function invariant$1(condition, message) {
	    if (!condition) {
	        throw new Error("StyleSheet: " + message + ".");
	    }
	}

	function hash(str) {
	    var _$hash = 5381, i = str.length;
	    while(i){
	        _$hash = _$hash * 33 ^ str.charCodeAt(--i);
	    }
	    /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
	   * integers. Since we want the results to be always positive, convert the
	   * signed int to an unsigned by doing an unsigned bitshift. */ return _$hash >>> 0;
	}
	var stringHash = hash;

	var sanitize = function(rule) {
	    return rule.replace(/\/style/gi, "\\/style");
	};
	var cache = {};
	/**
	 * computeId
	 *
	 * Compute and memoize a jsx id from a basedId and optionally props.
	 */ function computeId(baseId, props) {
	    if (!props) {
	        return "jsx-" + baseId;
	    }
	    var propsToString = String(props);
	    var key = baseId + propsToString;
	    if (!cache[key]) {
	        cache[key] = "jsx-" + stringHash(baseId + "-" + propsToString);
	    }
	    return cache[key];
	}
	/**
	 * computeSelector
	 *
	 * Compute and memoize dynamic selectors.
	 */ function computeSelector(id, css) {
	    var selectoPlaceholderRegexp = /__jsx-style-dynamic-selector/g;
	    // Sanitize SSR-ed CSS.
	    // Client side code doesn't need to be sanitized since we use
	    // document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod).
	    if (typeof window === "undefined") {
	        css = sanitize(css);
	    }
	    var idcss = id + css;
	    if (!cache[idcss]) {
	        cache[idcss] = css.replace(selectoPlaceholderRegexp, id);
	    }
	    return cache[idcss];
	}

	function mapRulesToStyle(cssRules, options) {
	    if (options === void 0) options = {};
	    return cssRules.map(function(args) {
	        var id = args[0];
	        var css = args[1];
	        return /*#__PURE__*/ React__default["default"].createElement("style", {
	            id: "__" + id,
	            // Avoid warnings upon render with a key
	            key: "__" + id,
	            nonce: options.nonce ? options.nonce : undefined,
	            dangerouslySetInnerHTML: {
	                __html: css
	            }
	        });
	    });
	}
	var StyleSheetRegistry = /*#__PURE__*/ function() {
	    function StyleSheetRegistry(param) {
	        var ref = param === void 0 ? {} : param, _styleSheet = ref.styleSheet, styleSheet = _styleSheet === void 0 ? null : _styleSheet, _optimizeForSpeed = ref.optimizeForSpeed, optimizeForSpeed = _optimizeForSpeed === void 0 ? false : _optimizeForSpeed;
	        this._sheet = styleSheet || new StyleSheet({
	            name: "styled-jsx",
	            optimizeForSpeed: optimizeForSpeed
	        });
	        this._sheet.inject();
	        if (styleSheet && typeof optimizeForSpeed === "boolean") {
	            this._sheet.setOptimizeForSpeed(optimizeForSpeed);
	            this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
	        }
	        this._fromServer = undefined;
	        this._indices = {};
	        this._instancesCounts = {};
	    }
	    var _proto = StyleSheetRegistry.prototype;
	    _proto.add = function add(props) {
	        var _this = this;
	        if (undefined === this._optimizeForSpeed) {
	            this._optimizeForSpeed = Array.isArray(props.children);
	            this._sheet.setOptimizeForSpeed(this._optimizeForSpeed);
	            this._optimizeForSpeed = this._sheet.isOptimizeForSpeed();
	        }
	        if (typeof window !== "undefined" && !this._fromServer) {
	            this._fromServer = this.selectFromServer();
	            this._instancesCounts = Object.keys(this._fromServer).reduce(function(acc, tagName) {
	                acc[tagName] = 0;
	                return acc;
	            }, {});
	        }
	        var ref = this.getIdAndRules(props), styleId = ref.styleId, rules = ref.rules;
	        // Deduping: just increase the instances count.
	        if (styleId in this._instancesCounts) {
	            this._instancesCounts[styleId] += 1;
	            return;
	        }
	        var indices = rules.map(function(rule) {
	            return _this._sheet.insertRule(rule);
	        })// Filter out invalid rules
	        .filter(function(index) {
	            return index !== -1;
	        });
	        this._indices[styleId] = indices;
	        this._instancesCounts[styleId] = 1;
	    };
	    _proto.remove = function remove(props) {
	        var _this = this;
	        var styleId = this.getIdAndRules(props).styleId;
	        invariant(styleId in this._instancesCounts, "styleId: `" + styleId + "` not found");
	        this._instancesCounts[styleId] -= 1;
	        if (this._instancesCounts[styleId] < 1) {
	            var tagFromServer = this._fromServer && this._fromServer[styleId];
	            if (tagFromServer) {
	                tagFromServer.parentNode.removeChild(tagFromServer);
	                delete this._fromServer[styleId];
	            } else {
	                this._indices[styleId].forEach(function(index) {
	                    return _this._sheet.deleteRule(index);
	                });
	                delete this._indices[styleId];
	            }
	            delete this._instancesCounts[styleId];
	        }
	    };
	    _proto.update = function update(props, nextProps) {
	        this.add(nextProps);
	        this.remove(props);
	    };
	    _proto.flush = function flush() {
	        this._sheet.flush();
	        this._sheet.inject();
	        this._fromServer = undefined;
	        this._indices = {};
	        this._instancesCounts = {};
	    };
	    _proto.cssRules = function cssRules() {
	        var _this = this;
	        var fromServer = this._fromServer ? Object.keys(this._fromServer).map(function(styleId) {
	            return [
	                styleId,
	                _this._fromServer[styleId]
	            ];
	        }) : [];
	        var cssRules = this._sheet.cssRules();
	        return fromServer.concat(Object.keys(this._indices).map(function(styleId) {
	            return [
	                styleId,
	                _this._indices[styleId].map(function(index) {
	                    return cssRules[index].cssText;
	                }).join(_this._optimizeForSpeed ? "" : "\n")
	            ];
	        })// filter out empty rules
	        .filter(function(rule) {
	            return Boolean(rule[1]);
	        }));
	    };
	    _proto.styles = function styles(options) {
	        return mapRulesToStyle(this.cssRules(), options);
	    };
	    _proto.getIdAndRules = function getIdAndRules(props) {
	        var css = props.children, dynamic = props.dynamic, id = props.id;
	        if (dynamic) {
	            var styleId = computeId(id, dynamic);
	            return {
	                styleId: styleId,
	                rules: Array.isArray(css) ? css.map(function(rule) {
	                    return computeSelector(styleId, rule);
	                }) : [
	                    computeSelector(styleId, css)
	                ]
	            };
	        }
	        return {
	            styleId: computeId(id),
	            rules: Array.isArray(css) ? css : [
	                css
	            ]
	        };
	    };
	    /**
	   * selectFromServer
	   *
	   * Collects style tags from the document with id __jsx-XXX
	   */ _proto.selectFromServer = function selectFromServer() {
	        var elements = Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));
	        return elements.reduce(function(acc, element) {
	            var id = element.id.slice(2);
	            acc[id] = element;
	            return acc;
	        }, {});
	    };
	    return StyleSheetRegistry;
	}();
	function invariant(condition, message) {
	    if (!condition) {
	        throw new Error("StyleSheetRegistry: " + message + ".");
	    }
	}
	var StyleSheetContext = /*#__PURE__*/ React$1.createContext(null);
	StyleSheetContext.displayName = "StyleSheetContext";
	function createStyleRegistry() {
	    return new StyleSheetRegistry();
	}
	function StyleRegistry(param) {
	    var configuredRegistry = param.registry, children = param.children;
	    var rootRegistry = React$1.useContext(StyleSheetContext);
	    var ref = React$1.useState(function() {
	        return rootRegistry || configuredRegistry || createStyleRegistry();
	    }), registry = ref[0];
	    return /*#__PURE__*/ React__default["default"].createElement(StyleSheetContext.Provider, {
	        value: registry
	    }, children);
	}
	function useStyleRegistry() {
	    return React$1.useContext(StyleSheetContext);
	}

	// Opt-into the new `useInsertionEffect` API in React 18, fallback to `useLayoutEffect`.
	// https://github.com/reactwg/react-18/discussions/110
	var useInsertionEffect = React__default["default"].useInsertionEffect || React$1.useLayoutEffect;
	var defaultRegistry = typeof window !== "undefined" ? createStyleRegistry() : undefined;
	function JSXStyle(props) {
	    var registry = defaultRegistry ? defaultRegistry : useStyleRegistry();
	    var insertionEffectCalled = React$1.useRef(false);
	    // `registry` might not exist while server-side rendering
	    if (!registry) {
	        return null;
	    }
	    if (typeof window === "undefined") {
	        registry.add(props);
	        return null;
	    }
	    useInsertionEffect(function() {
	        // ReactDOM removes all DOM during hydration in certain cases
	        if (!document.head) {
	            return;
	        }
	        registry.add(props);
	        insertionEffectCalled.current = true;
	        return function() {
	            insertionEffectCalled.current = false;
	            registry.remove(props);
	        };
	    }, [
	        props.id,
	        String(props.dynamic)
	    ]);
	    React$1.useLayoutEffect(function() {
	        if (!document.head || insertionEffectCalled.current) {
	            return;
	        }
	        registry.add(props);
	        return function() {
	            registry.remove(props);
	        };
	    // props.children can be string[], will be striped since id is identical
	    }, [
	        props.id,
	        String(props.dynamic)
	    ]);
	    return null;
	}
	JSXStyle.dynamic = function(info) {
	    return info.map(function(tagInfo) {
	        var baseId = tagInfo[0];
	        var props = tagInfo[1];
	        return computeId(baseId, props);
	    }).join(" ");
	};

	index.StyleRegistry = StyleRegistry;
	index.createStyleRegistry = createStyleRegistry;
	index.style = JSXStyle;
	index.useStyleRegistry = useStyleRegistry;
	return index;
}

var style;
var hasRequiredStyle;

function requireStyle () {
	if (hasRequiredStyle) return style;
	hasRequiredStyle = 1;
	style = requireIndex().style;
	return style;
}

var styleExports = requireStyle();
var _JSXStyle = /*@__PURE__*/getDefaultExportFromCjs(styleExports);

var defaultFont = {
  sans: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
  mono: 'Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace',
  prism: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,"Liberation Mono", "Courier New", monospace'
};
var defaultBreakpoints = {
  xs: {
    min: '0',
    max: '650px'
  },
  sm: {
    min: '650px',
    max: '900px'
  },
  md: {
    min: '900px',
    max: '1280px'
  },
  lg: {
    min: '1280px',
    max: '1920px'
  },
  xl: {
    min: '1920px',
    max: '10000px'
  }
};
var defaultLayout = {
  gap: '16pt',
  gapNegative: '-16pt',
  gapHalf: '8pt',
  gapHalfNegative: '-8pt',
  gapQuarter: '4pt',
  gapQuarterNegative: '-4pt',
  pageMargin: '16pt',
  pageWidth: '750pt',
  pageWidthWithMargin: '782pt',
  breakpointMobile: defaultBreakpoints.xs.max,
  breakpointTablet: defaultBreakpoints.sm.max,
  radius: '6px',
  unit: '16px'
};

var palette$1 = {
  accents_1: '#fafafa',
  accents_2: '#eaeaea',
  accents_3: '#999',
  accents_4: '#888',
  accents_5: '#666',
  accents_6: '#444',
  accents_7: '#333',
  accents_8: '#111',
  background: '#fff',
  foreground: '#000',
  selection: '#79ffe1',
  secondary: '#666',
  code: '#f81ce5',
  border: '#eaeaea',
  error: '#e00',
  errorLight: '#ff1a1a',
  errorLighter: '#f7d4d6',
  errorDark: '#c50000',
  success: '#0070f3',
  successLight: '#3291ff',
  successLighter: '#d3e5ff',
  successDark: '#0761d1',
  warning: '#f5a623',
  warningLight: '#f7b955',
  warningLighter: '#ffefcf',
  warningDark: '#ab570a',
  cyan: '#50e3c2',
  cyanLighter: '#aaffec',
  cyanLight: '#79ffe1',
  cyanDark: '#29bc9b',
  violet: '#7928ca',
  violetLighter: '#e3d7fc',
  violetLight: '#8a63d2',
  violetDark: '#4c2889',
  purple: '#f81ce5',
  alert: '#ff0080',
  magenta: '#eb367f',
  link: '#0070f3'
};
var expressiveness$1 = {
  linkStyle: 'none',
  linkHoverStyle: 'none',
  dropdownBoxShadow: '0 4px 4px 0 rgba(0, 0, 0, 0.02)',
  scrollerStart: 'rgba(255, 255, 255, 1)',
  scrollerEnd: 'rgba(255, 255, 255, 0)',
  shadowSmall: '0 5px 10px rgba(0, 0, 0, 0.12)',
  shadowMedium: '0 8px 30px rgba(0, 0, 0, 0.12)',
  shadowLarge: '0 30px 60px rgba(0, 0, 0, 0.12)',
  portalOpacity: 0.25
};
var font$1 = defaultFont;
var breakpoints$1 = defaultBreakpoints;
var layout$1 = defaultLayout;
var themes$1 = {
  type: 'light',
  font: font$1,
  layout: layout$1,
  palette: palette$1,
  breakpoints: breakpoints$1,
  expressiveness: expressiveness$1
};

var palette = {
  accents_1: '#111',
  accents_2: '#333',
  accents_3: '#444',
  accents_4: '#666',
  accents_5: '#888',
  accents_6: '#999',
  accents_7: '#eaeaea',
  accents_8: '#fafafa',
  background: '#000',
  foreground: '#fff',
  selection: '#f81ce5',
  secondary: '#888',
  code: '#79ffe1',
  border: '#333',
  error: '#e00',
  errorLighter: '#f7d4d6',
  errorLight: '#ff1a1a',
  errorDark: '#c50000',
  success: '#0070f3',
  successLighter: '#d3e5ff',
  successLight: '#3291ff',
  successDark: '#0761d1',
  warning: '#f5a623',
  warningLighter: '#ffefcf',
  warningLight: '#f7b955',
  warningDark: '#ab570a',
  cyan: '#50e3c2',
  cyanLighter: '#aaffec',
  cyanLight: '#79ffe1',
  cyanDark: '#29bc9b',
  violet: '#7928ca',
  violetLighter: '#e3d7fc',
  violetLight: '#8a63d2',
  violetDark: '#4c2889',
  purple: '#f81ce5',
  alert: '#ff0080',
  magenta: '#eb367f',
  link: '#3291ff'
};
var expressiveness = {
  linkStyle: 'none',
  linkHoverStyle: 'none',
  dropdownBoxShadow: '0 0 0 1px #333',
  scrollerStart: 'rgba(255, 255, 255, 1)',
  scrollerEnd: 'rgba(255, 255, 255, 0)',
  shadowSmall: '0 0 0 1px #333',
  shadowMedium: '0 0 0 1px #333',
  shadowLarge: '0 0 0 1px #333',
  portalOpacity: 0.75
};
var font = defaultFont;
var breakpoints = defaultBreakpoints;
var layout = defaultLayout;
var themes = {
  type: 'dark',
  font: font,
  layout: layout,
  palette: palette,
  breakpoints: breakpoints,
  expressiveness: expressiveness
};

var isObject = function isObject(target) {
  return target && _typeof(target) === 'object';
};
var _deepDuplicable = function deepDuplicable(source, target) {
  if (!isObject(target) || !isObject(source)) return source;
  var sourceKeys = Object.keys(source);
  var result = {};
  for (var _i = 0, _sourceKeys = sourceKeys; _i < _sourceKeys.length; _i++) {
    var key = _sourceKeys[_i];
    var sourceValue = source[key];
    var targetValue = target[key];
    if (Array.isArray(sourceValue) && Array.isArray(targetValue)) {
      result[key] = targetValue.concat(sourceValue);
    } else if (isObject(sourceValue) && isObject(targetValue)) {
      result[key] = _deepDuplicable(sourceValue, _objectSpread2({}, targetValue));
    } else if (targetValue) {
      result[key] = targetValue;
    } else {
      result[key] = sourceValue;
    }
  }
  return result;
};
var getPresets = function getPresets() {
  return [themes$1, themes];
};
var getPresetStaticTheme = function getPresetStaticTheme() {
  return themes$1;
};
var isAvailableThemeType = function isAvailableThemeType(type) {
  if (!type) return false;
  var presetThemes = getPresets();
  var hasType = presetThemes.find(function (theme) {
    return theme.type === type;
  });
  return !hasType;
};
var isPresetTheme = function isPresetTheme(themeOrType) {
  if (!themeOrType) return false;
  var isType = typeof themeOrType === 'string';
  var type = isType ? themeOrType : themeOrType.type;
  return !isAvailableThemeType(type);
};
var hasUserCustomTheme = function hasUserCustomTheme() {
  var themes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  return !!themes.find(function (item) {
    return isAvailableThemeType(item.type);
  });
};
var create = function create(base, custom) {
  if (!isAvailableThemeType(custom.type)) {
    throw new Error('Duplicate or unavailable theme type');
  }
  return _deepDuplicable(base, custom);
};
var createFromDark = function createFromDark(custom) {
  return create(themes, custom);
};
var createFromLight = function createFromLight(custom) {
  return create(themes$1, custom);
};
var Themes = {
  isPresetTheme: isPresetTheme,
  isAvailableThemeType: isAvailableThemeType,
  hasUserCustomTheme: hasUserCustomTheme,
  getPresets: getPresets,
  getPresetStaticTheme: getPresetStaticTheme,
  create: create,
  createFromDark: createFromDark,
  createFromLight: createFromLight
};

/* "use client" */

var defaultTheme = Themes.getPresetStaticTheme();
var ThemeContext = /*#__PURE__*/React.createContext(defaultTheme);
var useTheme = function useTheme() {
  return React.useContext(ThemeContext);
};

var useCurrentState = function useCurrentState(initialState) {
  var _useState = React.useState(function () {
      return typeof initialState === 'function' ? initialState() : initialState;
    }),
    _useState2 = _slicedToArray(_useState, 2),
    state = _useState2[0],
    setState = _useState2[1];
  var ref = React.useRef(initialState);
  React.useEffect(function () {
    ref.current = state;
  }, [state]);
  var setValue = function setValue(val) {
    var result = typeof val === 'function' ? val(ref.current) : val;
    ref.current = result;
    setState(result);
  };
  return [state, setValue, ref];
};

/* "use client" */

var getId = function getId() {
  return Math.random().toString(32).slice(2, 10);
};
var pickChildByProps = function pickChildByProps(children, key, value) {
  var target = [];
  var isArray = Array.isArray(value);
  var withoutPropChildren = React.Children.map(children, function (item) {
    if (! /*#__PURE__*/React.isValidElement(item)) return null;
    if (!item.props) return item;
    if (isArray) {
      if (value.includes(item.props[key])) {
        target.push(item);
        return null;
      }
      return item;
    }
    if (item.props[key] === value) {
      target.push(item);
      return null;
    }
    return item;
  });
  var targetChildren = target.length >= 0 ? target : undefined;
  return [withoutPropChildren, targetChildren];
};
var isBrowser = function isBrowser() {
  return Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
};
var isCSSNumberValue = function isCSSNumberValue(value) {
  return value !== undefined && !Number.isNaN(+value);
};

var SelectIconComponent = function SelectIconComponent() {
  return /*#__PURE__*/React.createElement("svg", {
    viewBox: "0 0 24 24",
    strokeWidth: "1",
    strokeLinecap: "round",
    strokeLinejoin: "round",
    fill: "none",
    shapeRendering: "geometricPrecision",
    className: "jsx-2742933678"
  }, /*#__PURE__*/React.createElement("path", {
    d: "M6 9l6 6 6-6",
    className: "jsx-2742933678"
  }), /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "2742933678"
  }, "svg.jsx-2742933678{color:inherit;stroke:currentColor;-webkit-transition:all 200ms ease;transition:all 200ms ease;width:1.214em;height:1.214em;}"));
};
SelectIconComponent.displayName = 'SelectIcon';
var SelectIcon = /*#__PURE__*/React.memo(SelectIconComponent);

/* "use client" */

var defaultContext$1 = {
  visible: false,
  disableAll: false
};
var SelectContext = /*#__PURE__*/React.createContext(defaultContext$1);
var useSelectContext = function useSelectContext() {
  return React.useContext(SelectContext);
};

var useSSR = function useSSR() {
  var _useState = React.useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    browser = _useState2[0],
    setBrowser = _useState2[1];
  React.useEffect(function () {
    setBrowser(isBrowser());
  }, []);
  return {
    isBrowser: browser,
    isServer: !browser
  };
};

var createElement = function createElement(id) {
  var el = document.createElement('div');
  el.setAttribute('id', id);
  return el;
};
var usePortal = function usePortal() {
  var selectId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getId();
  var getContainer = arguments.length > 1 ? arguments[1] : undefined;
  var id = "helpdice-ui-".concat(selectId);
  var _useSSR = useSSR(),
    isBrowser = _useSSR.isBrowser;
  var _useState = React.useState(isBrowser ? createElement(id) : null),
    _useState2 = _slicedToArray(_useState, 2),
    elSnapshot = _useState2[0],
    setElSnapshot = _useState2[1];
  React.useEffect(function () {
    var customContainer = getContainer ? getContainer() : null;
    var parentElement = customContainer || document.body;
    var hasElement = parentElement.querySelector("#".concat(id));
    var el = hasElement || createElement(id);
    if (!hasElement) {
      parentElement.appendChild(el);
    }
    setElSnapshot(el);
  }, []);
  return elSnapshot;
};

/* "use client" */

var useResize = function useResize(callback) {
  var immediatelyInvoke = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  React.useEffect(function () {
    var fn = function fn() {
      return callback();
    };
    if (immediatelyInvoke) {
      fn();
    }
    window.addEventListener('resize', fn);
    return function () {
      return window.removeEventListener('resize', fn);
    };
  }, []);
};

var _excluded$6 = ["children", "className", "visible", "enterTime", "leaveTime", "clearTime", "name"];
var CssTransition = function CssTransition(_ref) {
  var children = _ref.children,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? '' : _ref$className,
    _ref$visible = _ref.visible,
    visible = _ref$visible === void 0 ? false : _ref$visible,
    _ref$enterTime = _ref.enterTime,
    enterTime = _ref$enterTime === void 0 ? 60 : _ref$enterTime,
    _ref$leaveTime = _ref.leaveTime,
    leaveTime = _ref$leaveTime === void 0 ? 60 : _ref$leaveTime,
    _ref$clearTime = _ref.clearTime,
    clearTime = _ref$clearTime === void 0 ? 60 : _ref$clearTime,
    _ref$name = _ref.name,
    name = _ref$name === void 0 ? 'transition' : _ref$name,
    props = _objectWithoutProperties(_ref, _excluded$6);
  var _useState = React.useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    classes = _useState2[0],
    setClasses = _useState2[1];
  var _useState3 = React.useState(visible),
    _useState4 = _slicedToArray(_useState3, 2),
    renderable = _useState4[0],
    setRenderable = _useState4[1];
  React.useEffect(function () {
    var statusClassName = visible ? 'enter' : 'leave';
    var time = visible ? enterTime : leaveTime;
    if (visible && !renderable) {
      setRenderable(true);
    }
    setClasses("".concat(name, "-").concat(statusClassName));

    // set class to active
    var timer = setTimeout(function () {
      setClasses("".concat(name, "-").concat(statusClassName, " ").concat(name, "-").concat(statusClassName, "-active"));
      clearTimeout(timer);
    }, time);

    // remove classess when animation over
    var clearClassesTimer = setTimeout(function () {
      if (!visible) {
        setClasses('');
        setRenderable(false);
      }
      clearTimeout(clearClassesTimer);
    }, time + clearTime);
    return function () {
      clearTimeout(timer);
      clearTimeout(clearClassesTimer);
    };
  }, [visible, renderable]);
  if (! /*#__PURE__*/React.isValidElement(children) || !renderable) return null;
  var propsTransition = _objectSpread2(_objectSpread2({}, props), {}, {
    className: "".concat(children.props.className, " ").concat(className, " ").concat(classes)
  });
  return /*#__PURE__*/React.cloneElement(children, propsTransition);
};
CssTransition.displayName = 'CssTransition';

/* "use client" */

var useClickAnyWhere = function useClickAnyWhere(handler) {
  React.useEffect(function () {
    var callback = function callback(event) {
      return handler(event);
    };
    document.addEventListener('click', callback);
    return function () {
      return document.removeEventListener('click', callback);
    };
  }, [handler]);
};

/* "use client" */

var useDOMObserver = function useDOMObserver(ref) {
  var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
  var config = {
    attributes: false,
    childList: true,
    subtree: true
  };
  React.useEffect(function () {
    if (!ref || !ref.current) return;
    var unmount = false;
    var done = function done() {
      if (unmount) return;
      callback.apply(void 0, arguments);
    };
    var observer = new MutationObserver(done);
    observer.observe(ref.current, config);
    return function () {
      unmount = true;
      observer.disconnect();
    };
  }, [ref]);
};

var warningStack = {};
var useWarning = function useWarning(message, component) {
  var tag = component ? " [".concat(component, "]") : ' ';
  var log = "[Helpdice UI]".concat(tag, ": ").concat(message);
  if (typeof console === 'undefined') return;
  if (warningStack[log]) return;
  warningStack[log] = true;
  if (process.env.NODE_ENV !== 'production') {
    return console.error(log);
  }
  console.warn(log);
};

var getElementOffset = function getElementOffset(el) {
  if (!el) return {
    top: 0,
    left: 0
  };
  var _el$getBoundingClient = el.getBoundingClientRect(),
    top = _el$getBoundingClient.top,
    left = _el$getBoundingClient.left;
  return {
    top: top,
    left: left
  };
};
var defaultRect$1 = {
  top: -1e3,
  left: -1e3,
  right: -1e3,
  width: 0,
  height: 0,
  elementTop: -1e3
};
var getRectFromDOMWithContainer = function getRectFromDOMWithContainer(domRect, getContainer) {
  if (!domRect) return defaultRect$1;
  var container = getContainer ? getContainer() : null;
  var scrollElement = container || document.documentElement;
  var _getElementOffset = getElementOffset(container),
    offsetTop = _getElementOffset.top,
    offsetLeft = _getElementOffset.left;
  return _objectSpread2(_objectSpread2({}, domRect), {}, {
    width: domRect.width || domRect.right - domRect.left,
    height: domRect.height || domRect.top - domRect.bottom,
    top: domRect.bottom + scrollElement.scrollTop - offsetTop,
    left: domRect.left + scrollElement.scrollLeft - offsetLeft,
    elementTop: domRect.top + scrollElement.scrollTop - offsetTop
  });
};
var getRefRect = function getRefRect(ref, getContainer) {
  if (!ref || !ref.current) return defaultRect$1;
  var rect = ref.current.getBoundingClientRect();
  return getRectFromDOMWithContainer(rect, getContainer);
};

/* "use client" */

var classObjectToString = function classObjectToString(className) {
  var keys = Object.keys(className);
  var len = keys.length;
  var str = '';
  for (var index = 0; index < len; index++) {
    var key = keys[index];
    var val = className[keys[index]];
    if (!val) continue;
    str = str ? "".concat(str, " ").concat(String(key)) : String(key);
  }
  return str;
};
var isObjectClassName = function isObjectClassName(value) {
  return _typeof(value) === 'object' && !Array.isArray(value);
};
var useClasses = function useClasses() {
  var len = arguments.length;
  var classes = '';
  if (len === 0) return classes;
  for (var index = 0; index < len; index++) {
    var val = index < 0 || arguments.length <= index ? undefined : arguments[index];
    if (!val) continue;
    if (isObjectClassName(val)) {
      classes += " ".concat(classObjectToString(val));
    } else {
      classes += " ".concat(String(val).trim());
    }
  }
  return classes.trim();
};

var defaultRect = {
  top: -1e3,
  left: -1e3,
  right: -1e3,
  width: 0
};
var Dropdown = /*#__PURE__*/React.memo(function (_ref) {
  var children = _ref.children,
    parent = _ref.parent,
    visible = _ref.visible,
    disableMatchWidth = _ref.disableMatchWidth,
    getPopupContainer = _ref.getPopupContainer;
  var el = usePortal('dropdown', getPopupContainer);
  var _useState = React.useState(defaultRect),
    _useState2 = _slicedToArray(_useState, 2),
    rect = _useState2[0],
    setRect = _useState2[1];
  var classes = useClasses('dropdown', disableMatchWidth ? 'disable-match' : 'width-match');
  if (!parent) return null;

  /* istanbul ignore next */
  if (process.env.NODE_ENV !== 'production') {
    if (getPopupContainer && getPopupContainer()) {
      var _el = getPopupContainer();
      var style = window.getComputedStyle(_el);
      if (style.position === 'static') {
        useWarning('The element specified by "getPopupContainer" must have "position" set.');
      }
    }
  }
  var updateRect = function updateRect() {
    var _getRefRect = getRefRect(parent, getPopupContainer),
      top = _getRefRect.top,
      left = _getRefRect.left,
      right = _getRefRect.right,
      nativeWidth = _getRefRect.width;
    setRect({
      top: top,
      left: left,
      right: right,
      width: nativeWidth
    });
  };
  useResize(updateRect);
  useClickAnyWhere(function () {
    var _getRefRect2 = getRefRect(parent, getPopupContainer),
      top = _getRefRect2.top,
      left = _getRefRect2.left;
    var shouldUpdatePosition = top !== rect.top || left !== rect.left;
    if (!shouldUpdatePosition) return;
    updateRect();
  });
  useDOMObserver(parent, function () {
    updateRect();
  });
  React.useEffect(function () {
    if (!parent || !parent.current) return;
    parent.current.addEventListener('mouseenter', updateRect);
    /* istanbul ignore next */
    return function () {
      if (!parent || !parent.current) return;
      parent.current.removeEventListener('mouseenter', updateRect);
    };
  }, [parent]);
  var clickHandler = function clickHandler(event) {
    event.stopPropagation();
    event.nativeEvent.stopImmediatePropagation();
    event.preventDefault();
  };
  var mouseDownHandler = function mouseDownHandler(event) {
    event.preventDefault();
  };
  if (!el) return null;
  return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React.createElement(CssTransition, {
    visible: visible
  }, /*#__PURE__*/React.createElement("div", {
    onClick: clickHandler,
    onMouseDown: mouseDownHandler,
    className: _JSXStyle.dynamic([["1644673105", [rect.top + 2, rect.left, rect.width, rect.width]]]) + " " + (classes || "")
  }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "1644673105",
    dynamic: [rect.top + 2, rect.left, rect.width, rect.width]
  }, ".dropdown.__jsx-style-dynamic-selector{position:absolute;top:".concat(rect.top + 2, "px;left:").concat(rect.left, "px;z-index:1100;}.width-match.__jsx-style-dynamic-selector{width:").concat(rect.width, "px;}.disable-match.__jsx-style-dynamic-selector{min-width:").concat(rect.width, "px;}")))), el);
});

var SelectDropdown = /*#__PURE__*/React.forwardRef(function (_ref, dropdownRef) {
  var visible = _ref.visible,
    children = _ref.children,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? '' : _ref$className,
    _ref$dropdownStyle = _ref.dropdownStyle,
    dropdownStyle = _ref$dropdownStyle === void 0 ? {} : _ref$dropdownStyle,
    disableMatchWidth = _ref.disableMatchWidth,
    getPopupContainer = _ref.getPopupContainer;
  var theme = useTheme();
  var internalDropdownRef = React.useRef(null);
  var _useSelectContext = useSelectContext(),
    ref = _useSelectContext.ref;
  var classes = useClasses('select-dropdown', className);
  React.useImperativeHandle(dropdownRef, function () {
    return internalDropdownRef.current;
  });
  return /*#__PURE__*/React.createElement(Dropdown, {
    parent: ref,
    visible: visible,
    disableMatchWidth: disableMatchWidth,
    getPopupContainer: getPopupContainer
  }, /*#__PURE__*/React.createElement("div", {
    ref: internalDropdownRef,
    style: dropdownStyle,
    className: _JSXStyle.dynamic([["2782510679", [theme.layout.radius, theme.expressiveness.shadowLarge, theme.palette.background]]]) + " " + (classes || "")
  }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "2782510679",
    dynamic: [theme.layout.radius, theme.expressiveness.shadowLarge, theme.palette.background]
  }, ".select-dropdown.__jsx-style-dynamic-selector{border-radius:".concat(theme.layout.radius, ";box-shadow:").concat(theme.expressiveness.shadowLarge, ";background-color:").concat(theme.palette.background, ";max-height:17em;overflow-y:auto;overflow-anchor:none;padding:0.38em 0;-webkit-scroll-behavior:smooth;-moz-scroll-behavior:smooth;-ms-scroll-behavior:smooth;scroll-behavior:smooth;}"))));
});
SelectDropdown.displayName = 'SelectDropdown';

/* "use client" */

var ScalePropKeys = ['width', 'height', 'padding', 'margin', 'w', 'h', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'pl', 'pr', 'pt', 'pb', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom', 'ml', 'mr', 'mt', 'mb', 'px', 'py', 'mx', 'my', 'font', 'unit', 'scale'];
var defaultDynamicLayoutPipe = function defaultDynamicLayoutPipe(scale1x) {
  return "".concat(scale1x);
};
var defaultContext = {
  getScaleProps: function getScaleProps() {
    return undefined;
  },
  getAllScaleProps: function getAllScaleProps() {
    return {};
  },
  SCALES: {
    pl: defaultDynamicLayoutPipe,
    pr: defaultDynamicLayoutPipe,
    pb: defaultDynamicLayoutPipe,
    pt: defaultDynamicLayoutPipe,
    px: defaultDynamicLayoutPipe,
    py: defaultDynamicLayoutPipe,
    mb: defaultDynamicLayoutPipe,
    ml: defaultDynamicLayoutPipe,
    mr: defaultDynamicLayoutPipe,
    mt: defaultDynamicLayoutPipe,
    mx: defaultDynamicLayoutPipe,
    my: defaultDynamicLayoutPipe,
    width: defaultDynamicLayoutPipe,
    height: defaultDynamicLayoutPipe,
    font: defaultDynamicLayoutPipe
  },
  unit: '16px'
};
var ScaleContext = /*#__PURE__*/React.createContext(defaultContext);
var useScale = function useScale() {
  return React.useContext(ScaleContext);
};

var generateGetScaleProps = function generateGetScaleProps(props) {
  var getScaleProps = function getScaleProps(keyOrKeys) {
    if (!Array.isArray(keyOrKeys)) return props[keyOrKeys];
    var value = undefined;
    var _iterator = _createForOfIteratorHelper(keyOrKeys),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var key = _step.value;
        var currentValue = props[key];
        if (typeof currentValue !== 'undefined') {
          value = currentValue;
        }
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    return value;
  };
  return getScaleProps;
};
var generateGetAllScaleProps = function generateGetAllScaleProps(props) {
  var getAllScaleProps = function getAllScaleProps() {
    var scaleProps = {};
    var _iterator2 = _createForOfIteratorHelper(ScalePropKeys),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var key = _step2.value;
        var value = props[key];
        if (typeof value !== 'undefined') {
          scaleProps[key] = value;
        }
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    return scaleProps;
  };
  return getAllScaleProps;
};

var _excluded$5 = ["children"];
var reduceScaleCoefficient = function reduceScaleCoefficient(scale) {
  if (scale === 1) return scale;
  var diff = Math.abs((scale - 1) / 2);
  return scale > 1 ? 1 + diff : 1 - diff;
};
var withScale = function withScale(Render) {
  var ScaleFC = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
    var _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref0, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26, _ref27, _ref28, _ref29, _ref30, _ref31;
    var children = _ref.children,
      props = _objectWithoutProperties(_ref, _excluded$5);
    var _useTheme = useTheme(),
      layout = _useTheme.layout;
    var paddingLeft = props.paddingLeft,
      pl = props.pl,
      paddingRight = props.paddingRight,
      pr = props.pr,
      paddingTop = props.paddingTop,
      pt = props.pt,
      paddingBottom = props.paddingBottom,
      pb = props.pb,
      marginTop = props.marginTop,
      mt = props.mt,
      marginRight = props.marginRight,
      mr = props.mr,
      marginBottom = props.marginBottom,
      mb = props.mb,
      marginLeft = props.marginLeft,
      ml = props.ml,
      px = props.px,
      py = props.py,
      mx = props.mx,
      my = props.my,
      width = props.width,
      height = props.height,
      font = props.font,
      w = props.w,
      h = props.h,
      margin = props.margin,
      padding = props.padding,
      _props$unit = props.unit,
      unit = _props$unit === void 0 ? layout.unit : _props$unit,
      _props$scale = props.scale,
      scale = _props$scale === void 0 ? 1 : _props$scale;
    var makeScaleHandler = function makeScaleHandler(attrValue) {
      return function (scale1x, defaultValue) {
        // 0 means disable scale and the default value is 0
        if (scale1x === 0) {
          scale1x = 1;
          defaultValue = defaultValue || 0;
        }
        var factor = reduceScaleCoefficient(scale) * scale1x;
        if (typeof attrValue === 'undefined') {
          if (typeof defaultValue !== 'undefined') return "".concat(defaultValue);
          return "calc(".concat(factor, " * ").concat(unit, ")");
        }
        if (!isCSSNumberValue(attrValue)) return "".concat(attrValue);
        var customFactor = factor * Number(attrValue);
        return "calc(".concat(customFactor, " * ").concat(unit, ")");
      };
    };
    var value = {
      unit: unit,
      SCALES: {
        pt: makeScaleHandler((_ref2 = (_ref3 = paddingTop !== null && paddingTop !== void 0 ? paddingTop : pt) !== null && _ref3 !== void 0 ? _ref3 : py) !== null && _ref2 !== void 0 ? _ref2 : padding),
        pr: makeScaleHandler((_ref4 = (_ref5 = paddingRight !== null && paddingRight !== void 0 ? paddingRight : pr) !== null && _ref5 !== void 0 ? _ref5 : px) !== null && _ref4 !== void 0 ? _ref4 : padding),
        pb: makeScaleHandler((_ref6 = (_ref7 = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : pb) !== null && _ref7 !== void 0 ? _ref7 : py) !== null && _ref6 !== void 0 ? _ref6 : padding),
        pl: makeScaleHandler((_ref8 = (_ref9 = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : pl) !== null && _ref9 !== void 0 ? _ref9 : px) !== null && _ref8 !== void 0 ? _ref8 : padding),
        px: makeScaleHandler((_ref0 = (_ref1 = (_ref10 = (_ref11 = px !== null && px !== void 0 ? px : paddingLeft) !== null && _ref11 !== void 0 ? _ref11 : paddingRight) !== null && _ref10 !== void 0 ? _ref10 : pl) !== null && _ref1 !== void 0 ? _ref1 : pr) !== null && _ref0 !== void 0 ? _ref0 : padding),
        py: makeScaleHandler((_ref12 = (_ref13 = (_ref14 = (_ref15 = py !== null && py !== void 0 ? py : paddingTop) !== null && _ref15 !== void 0 ? _ref15 : paddingBottom) !== null && _ref14 !== void 0 ? _ref14 : pt) !== null && _ref13 !== void 0 ? _ref13 : pb) !== null && _ref12 !== void 0 ? _ref12 : padding),
        mt: makeScaleHandler((_ref16 = (_ref17 = marginTop !== null && marginTop !== void 0 ? marginTop : mt) !== null && _ref17 !== void 0 ? _ref17 : my) !== null && _ref16 !== void 0 ? _ref16 : margin),
        mr: makeScaleHandler((_ref18 = (_ref19 = marginRight !== null && marginRight !== void 0 ? marginRight : mr) !== null && _ref19 !== void 0 ? _ref19 : mx) !== null && _ref18 !== void 0 ? _ref18 : margin),
        mb: makeScaleHandler((_ref20 = (_ref21 = marginBottom !== null && marginBottom !== void 0 ? marginBottom : mb) !== null && _ref21 !== void 0 ? _ref21 : my) !== null && _ref20 !== void 0 ? _ref20 : margin),
        ml: makeScaleHandler((_ref22 = (_ref23 = marginLeft !== null && marginLeft !== void 0 ? marginLeft : ml) !== null && _ref23 !== void 0 ? _ref23 : mx) !== null && _ref22 !== void 0 ? _ref22 : margin),
        mx: makeScaleHandler((_ref24 = (_ref25 = (_ref26 = (_ref27 = mx !== null && mx !== void 0 ? mx : marginLeft) !== null && _ref27 !== void 0 ? _ref27 : marginRight) !== null && _ref26 !== void 0 ? _ref26 : ml) !== null && _ref25 !== void 0 ? _ref25 : mr) !== null && _ref24 !== void 0 ? _ref24 : margin),
        my: makeScaleHandler((_ref28 = (_ref29 = (_ref30 = (_ref31 = my !== null && my !== void 0 ? my : marginTop) !== null && _ref31 !== void 0 ? _ref31 : marginBottom) !== null && _ref30 !== void 0 ? _ref30 : mt) !== null && _ref29 !== void 0 ? _ref29 : mb) !== null && _ref28 !== void 0 ? _ref28 : margin),
        width: makeScaleHandler(width !== null && width !== void 0 ? width : w),
        height: makeScaleHandler(height !== null && height !== void 0 ? height : h),
        font: makeScaleHandler(font)
      },
      getScaleProps: generateGetScaleProps(props),
      getAllScaleProps: generateGetAllScaleProps(props)
    };
    return /*#__PURE__*/React.createElement(ScaleContext.Provider, {
      value: value
    }, /*#__PURE__*/React.createElement(Render, _extends({}, props, {
      ref: ref
    }), children));
  });
  ScaleFC.displayName = "Scale".concat(Render.displayName || 'Wrapper');
  return ScaleFC;
};

var _excluded$4 = ["xs", "sm", "md", "lg", "xl", "justify", "direction", "alignItems", "alignContent", "children", "className"];
var getItemLayout = function getItemLayout(val) {
  var display = val === 0 ? 'display: none;' : 'display: inherit;';
  if (typeof val === 'number') {
    var width = 100 / 24 * val;
    var ratio = width > 100 ? '100%' : width < 0 ? '0' : "".concat(width, "%");
    return {
      grow: 0,
      display: display,
      width: ratio,
      basis: ratio
    };
  }
  return {
    grow: 1,
    display: display,
    width: '100%',
    basis: '0'
  };
};
var GridBasicItem = function GridBasicItem(_ref) {
  var _ref$xs = _ref.xs,
    xs = _ref$xs === void 0 ? false : _ref$xs,
    _ref$sm = _ref.sm,
    sm = _ref$sm === void 0 ? false : _ref$sm,
    _ref$md = _ref.md,
    md = _ref$md === void 0 ? false : _ref$md,
    _ref$lg = _ref.lg,
    lg = _ref$lg === void 0 ? false : _ref$lg,
    _ref$xl = _ref.xl,
    xl = _ref$xl === void 0 ? false : _ref$xl,
    justify = _ref.justify,
    direction = _ref.direction,
    alignItems = _ref.alignItems,
    alignContent = _ref.alignContent,
    children = _ref.children,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? '' : _ref$className,
    props = _objectWithoutProperties(_ref, _excluded$4);
  var theme = useTheme();
  var _useScale = useScale(),
    SCALES = _useScale.SCALES;
  var classes = React.useMemo(function () {
    var aligns = {
      justify: justify,
      direction: direction,
      alignItems: alignItems,
      alignContent: alignContent,
      xs: xs,
      sm: sm,
      md: md,
      lg: lg,
      xl: xl
    };
    var classString = Object.keys(aligns).reduce(function (pre, name) {
      if (aligns[name] !== undefined && aligns[name] !== false) return "".concat(pre, " ").concat(name);
      return pre;
    }, '');
    return classString.trim();
  }, [justify, direction, alignItems, alignContent, xs, sm, md, lg, xl]);
  var layout = React.useMemo(function () {
    return {
      xs: getItemLayout(xs),
      sm: getItemLayout(sm),
      md: getItemLayout(md),
      lg: getItemLayout(lg),
      xl: getItemLayout(xl)
    };
  }, [xs, sm, md, lg, xl]);
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
    className: _JSXStyle.dynamic([["568430467", [SCALES.font(1, 'inherit'), SCALES.height(1, 'auto'), justify, direction, alignContent, alignItems, layout.xs.grow, layout.xs.width, layout.xs.basis, layout.xs.display, theme.breakpoints.sm.min, layout.sm.grow, layout.sm.width, layout.sm.basis, layout.sm.display, theme.breakpoints.md.min, layout.md.grow, layout.md.width, layout.md.basis, layout.md.display, theme.breakpoints.lg.min, layout.lg.grow, layout.lg.width, layout.lg.basis, layout.lg.display, theme.breakpoints.xl.min, layout.xl.grow, layout.xl.width, layout.xl.basis, layout.xl.display]]]) + " " + (props && props.className != null && props.className || useClasses('item', classes, className) || "")
  }), children, /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "568430467",
    dynamic: [SCALES.font(1, 'inherit'), SCALES.height(1, 'auto'), justify, direction, alignContent, alignItems, layout.xs.grow, layout.xs.width, layout.xs.basis, layout.xs.display, theme.breakpoints.sm.min, layout.sm.grow, layout.sm.width, layout.sm.basis, layout.sm.display, theme.breakpoints.md.min, layout.md.grow, layout.md.width, layout.md.basis, layout.md.display, theme.breakpoints.lg.min, layout.lg.grow, layout.lg.width, layout.lg.basis, layout.lg.display, theme.breakpoints.xl.min, layout.xl.grow, layout.xl.width, layout.xl.basis, layout.xl.display]
  }, ".item.__jsx-style-dynamic-selector{font-size:".concat(SCALES.font(1, 'inherit'), ";height:").concat(SCALES.height(1, 'auto'), ";}.justify.__jsx-style-dynamic-selector{-webkit-box-pack:").concat(justify, ";-webkit-justify-content:").concat(justify, ";-ms-flex-pack:").concat(justify, ";justify-content:").concat(justify, ";}.direction.__jsx-style-dynamic-selector{-webkit-flex-direction:").concat(direction, ";-ms-flex-direction:").concat(direction, ";flex-direction:").concat(direction, ";}.alignContent.__jsx-style-dynamic-selector{-webkit-align-content:").concat(alignContent, ";-ms-flex-line-pack:").concat(alignContent, ";align-content:").concat(alignContent, ";}.alignItems.__jsx-style-dynamic-selector{-webkit-align-items:").concat(alignItems, ";-webkit-box-align:").concat(alignItems, ";-ms-flex-align:").concat(alignItems, ";align-items:").concat(alignItems, ";}.xs.__jsx-style-dynamic-selector{-webkit-box-flex:").concat(layout.xs.grow, ";-webkit-flex-grow:").concat(layout.xs.grow, ";-ms-flex-positive:").concat(layout.xs.grow, ";flex-grow:").concat(layout.xs.grow, ";max-width:").concat(layout.xs.width, ";-webkit-flex-basis:").concat(layout.xs.basis, ";-ms-flex-preferred-size:").concat(layout.xs.basis, ";flex-basis:").concat(layout.xs.basis, ";").concat(layout.xs.display, ";}@media only screen and (min-width:").concat(theme.breakpoints.sm.min, "){.sm.__jsx-style-dynamic-selector{-webkit-box-flex:").concat(layout.sm.grow, ";-webkit-flex-grow:").concat(layout.sm.grow, ";-ms-flex-positive:").concat(layout.sm.grow, ";flex-grow:").concat(layout.sm.grow, ";max-width:").concat(layout.sm.width, ";-webkit-flex-basis:").concat(layout.sm.basis, ";-ms-flex-preferred-size:").concat(layout.sm.basis, ";flex-basis:").concat(layout.sm.basis, ";").concat(layout.sm.display, ";}}@media only screen and (min-width:").concat(theme.breakpoints.md.min, "){.md.__jsx-style-dynamic-selector{-webkit-box-flex:").concat(layout.md.grow, ";-webkit-flex-grow:").concat(layout.md.grow, ";-ms-flex-positive:").concat(layout.md.grow, ";flex-grow:").concat(layout.md.grow, ";max-width:").concat(layout.md.width, ";-webkit-flex-basis:").concat(layout.md.basis, ";-ms-flex-preferred-size:").concat(layout.md.basis, ";flex-basis:").concat(layout.md.basis, ";").concat(layout.md.display, ";}}@media only screen and (min-width:").concat(theme.breakpoints.lg.min, "){.lg.__jsx-style-dynamic-selector{-webkit-box-flex:").concat(layout.lg.grow, ";-webkit-flex-grow:").concat(layout.lg.grow, ";-ms-flex-positive:").concat(layout.lg.grow, ";flex-grow:").concat(layout.lg.grow, ";max-width:").concat(layout.lg.width, ";-webkit-flex-basis:").concat(layout.lg.basis, ";-ms-flex-preferred-size:").concat(layout.lg.basis, ";flex-basis:").concat(layout.lg.basis, ";").concat(layout.lg.display, ";}}@media only screen and (min-width:").concat(theme.breakpoints.xl.min, "){.xl.__jsx-style-dynamic-selector{-webkit-box-flex:").concat(layout.xl.grow, ";-webkit-flex-grow:").concat(layout.xl.grow, ";-ms-flex-positive:").concat(layout.xl.grow, ";flex-grow:").concat(layout.xl.grow, ";max-width:").concat(layout.xl.width, ";-webkit-flex-basis:").concat(layout.xl.basis, ";-ms-flex-preferred-size:").concat(layout.xl.basis, ";flex-basis:").concat(layout.xl.basis, ";").concat(layout.xl.display, ";}}")));
};
GridBasicItem.displayName = 'GridBasicItem';

var _excluded$3 = ["children", "className"];
var GridComponent = function GridComponent(_ref) {
  var children = _ref.children,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? '' : _ref$className,
    props = _objectWithoutProperties(_ref, _excluded$3);
  var _useScale = useScale(),
    SCALES = _useScale.SCALES;
  var _styles$className = {
      styles: /*#__PURE__*/React.createElement(_JSXStyle, {
        id: "1271839607",
        dynamic: [SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0, 'var(--grid-gap-unit)'), SCALES.pr(0, 'var(--grid-gap-unit)'), SCALES.pb(0, 'var(--grid-gap-unit)'), SCALES.pl(0, 'var(--grid-gap-unit)')]
      }, "div.__jsx-style-dynamic-selector{margin:".concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";box-sizing:border-box;padding:").concat(SCALES.pt(0, 'var(--grid-gap-unit)'), " ").concat(SCALES.pr(0, 'var(--grid-gap-unit)'), " ").concat(SCALES.pb(0, 'var(--grid-gap-unit)'), " ").concat(SCALES.pl(0, 'var(--grid-gap-unit)'), ";}")),
      className: _JSXStyle.dynamic([["1271839607", [SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0, 'var(--grid-gap-unit)'), SCALES.pr(0, 'var(--grid-gap-unit)'), SCALES.pb(0, 'var(--grid-gap-unit)'), SCALES.pl(0, 'var(--grid-gap-unit)')]]])
    },
    resolveClassName = _styles$className.className,
    styles = _styles$className.styles;
  var classes = useClasses(resolveClassName, className);
  return /*#__PURE__*/React.createElement(GridBasicItem, _extends({
    className: classes
  }, props), children, styles);
};
GridComponent.displayName = 'Grid';
var Grid = withScale(GridComponent);

var _excluded$2 = ["gap", "wrap", "children", "className"];
var GridContainerComponent = function GridContainerComponent(_ref) {
  var _ref$gap = _ref.gap,
    gap = _ref$gap === void 0 ? 0 : _ref$gap,
    _ref$wrap = _ref.wrap,
    wrap = _ref$wrap === void 0 ? 'wrap' : _ref$wrap,
    children = _ref.children,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? '' : _ref$className,
    props = _objectWithoutProperties(_ref, _excluded$2);
  var _useScale = useScale(),
    unit = _useScale.unit,
    SCALES = _useScale.SCALES;
  var gapUnit = React.useMemo(function () {
    return "calc(".concat(gap, " * ").concat(unit, " * 1/3)");
  }, [gap, unit]);
  var _styles$className = {
      styles: /*#__PURE__*/React.createElement(_JSXStyle, {
        id: "3631618093",
        dynamic: [gapUnit, wrap, SCALES.width(1, 'var(--grid-container-width)'), SCALES.mt(0, 'var(--grid-container-margin)'), SCALES.mr(0, 'var(--grid-container-margin)'), SCALES.mb(0, 'var(--grid-container-margin)'), SCALES.ml(0, 'var(--grid-container-margin)')]
      }, "div.__jsx-style-dynamic-selector{--grid-gap-unit:".concat(gapUnit, ";--grid-container-margin:calc(-1 * var(--grid-gap-unit));--grid-container-width:calc(100% + var(--grid-gap-unit) * 2);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:").concat(wrap, ";-ms-flex-wrap:").concat(wrap, ";flex-wrap:").concat(wrap, ";box-sizing:border-box;width:").concat(SCALES.width(1, 'var(--grid-container-width)'), ";margin:").concat(SCALES.mt(0, 'var(--grid-container-margin)'), " ").concat(SCALES.mr(0, 'var(--grid-container-margin)'), " ").concat(SCALES.mb(0, 'var(--grid-container-margin)'), " ").concat(SCALES.ml(0, 'var(--grid-container-margin)'), ";}")),
      className: _JSXStyle.dynamic([["3631618093", [gapUnit, wrap, SCALES.width(1, 'var(--grid-container-width)'), SCALES.mt(0, 'var(--grid-container-margin)'), SCALES.mr(0, 'var(--grid-container-margin)'), SCALES.mb(0, 'var(--grid-container-margin)'), SCALES.ml(0, 'var(--grid-container-margin)')]]])
    },
    resolveClassName = _styles$className.className,
    styles = _styles$className.styles;
  var classes = useClasses(resolveClassName, className);
  return /*#__PURE__*/React.createElement(GridBasicItem, _extends({
    className: classes
  }, props), children, styles);
};
GridContainerComponent.displayName = 'GridContainer';
var GridContainer = withScale(GridContainerComponent);

Grid.Container = GridContainer;

var SelectIconClear = function SelectIconClear(_ref) {
  var onClick = _ref.onClick;
  var theme = useTheme();
  var clickHandler = function clickHandler(event) {
    event.preventDefault();
    event.stopPropagation();
    event.nativeEvent.stopImmediatePropagation();
    onClick && onClick(event);
  };
  return /*#__PURE__*/React.createElement("div", {
    onClick: clickHandler,
    className: _JSXStyle.dynamic([["1984024521", [theme.palette.accents_3, theme.palette.foreground]]]) + " " + "clear-icon"
  }, /*#__PURE__*/React.createElement("svg", {
    viewBox: "0 0 24 24",
    stroke: "currentColor",
    strokeWidth: "1.5",
    strokeLinecap: "round",
    strokeLinejoin: "round",
    fill: "none",
    shapeRendering: "geometricPrecision",
    className: _JSXStyle.dynamic([["1984024521", [theme.palette.accents_3, theme.palette.foreground]]])
  }, /*#__PURE__*/React.createElement("path", {
    d: "M18 6L6 18",
    className: _JSXStyle.dynamic([["1984024521", [theme.palette.accents_3, theme.palette.foreground]]])
  }), /*#__PURE__*/React.createElement("path", {
    d: "M6 6l12 12",
    className: _JSXStyle.dynamic([["1984024521", [theme.palette.accents_3, theme.palette.foreground]]])
  })), /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "1984024521",
    dynamic: [theme.palette.accents_3, theme.palette.foreground]
  }, ".clear-icon.__jsx-style-dynamic-selector{padding:0 0 0 0.5em;margin:0;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:100%;cursor:pointer;box-sizing:border-box;-webkit-transition:color 150ms ease 0s;transition:color 150ms ease 0s;color:".concat(theme.palette.accents_3, ";visibility:visible;opacity:1;}.clear-icon.__jsx-style-dynamic-selector:hover{color:").concat(theme.palette.foreground, ";}svg.__jsx-style-dynamic-selector{color:currentColor;width:1em;height:1em;}")));
};
var MemoSelectIconClear = /*#__PURE__*/React.memo(SelectIconClear);

var SelectMultipleValue = function SelectMultipleValue(_ref) {
  var disabled = _ref.disabled,
    onClear = _ref.onClear,
    children = _ref.children;
  var theme = useTheme();
  return /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement("div", {
    className: _JSXStyle.dynamic([["3357578496", [theme.layout.radius, theme.palette.accents_2, disabled ? theme.palette.accents_4 : theme.palette.accents_6]]]) + " " + "item"
  }, children, !!onClear && /*#__PURE__*/React.createElement(MemoSelectIconClear, {
    onClick: onClear
  })), /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "3357578496",
    dynamic: [theme.layout.radius, theme.palette.accents_2, disabled ? theme.palette.accents_4 : theme.palette.accents_6]
  }, ".item.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;justify-items:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;line-height:1;padding:0 0.5em;font-size:var(--select-font-size);height:calc(var(--select-font-size) * 2);border-radius:".concat(theme.layout.radius, ";background-color:").concat(theme.palette.accents_2, ";color:").concat(disabled ? theme.palette.accents_4 : theme.palette.accents_6, ";}.item.__jsx-style-dynamic-selector>div:not(.clear-icon),.item.__jsx-style-dynamic-selector>div:not(.clear-icon):hover{border-radius:0;background-color:transparent;padding:0;margin:0;color:inherit;}")));
};
SelectMultipleValue.displayName = 'SelectMultipleValue';

var getColors = function getColors(palette, status) {
  var colors = {
    "default": {
      border: palette.border,
      borderActive: palette.foreground,
      iconBorder: palette.accents_5,
      placeholderColor: palette.accents_3
    },
    secondary: {
      border: palette.border,
      borderActive: palette.foreground,
      iconBorder: palette.accents_5,
      placeholderColor: palette.accents_3
    },
    success: {
      border: palette.successLight,
      borderActive: palette.successDark,
      iconBorder: palette.success,
      placeholderColor: palette.accents_3
    },
    warning: {
      border: palette.warningLight,
      borderActive: palette.warningDark,
      iconBorder: palette.warning,
      placeholderColor: palette.accents_3
    },
    error: {
      border: palette.errorLight,
      borderActive: palette.errorDark,
      iconBorder: palette.error,
      placeholderColor: palette.error
    }
  };
  if (!status) return colors["default"];
  return colors[status];
};

var Ellipsis = function Ellipsis(_ref) {
  var children = _ref.children,
    height = _ref.height;
  return /*#__PURE__*/React.createElement("span", {
    className: _JSXStyle.dynamic([["822089635", [height]]])
  }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "822089635",
    dynamic: [height]
  }, "span.__jsx-style-dynamic-selector{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:".concat(height, ";min-width:0;}")));
};
var Ellipsis$1 = /*#__PURE__*/React.memo(Ellipsis);

var SelectInput = /*#__PURE__*/React.forwardRef(function (_ref, inputRef) {
  var visible = _ref.visible,
    onBlur = _ref.onBlur,
    onFocus = _ref.onFocus;
  var ref = React.useRef(null);
  React.useImperativeHandle(inputRef, function () {
    return ref.current;
  });
  React.useEffect(function () {
    if (visible) {
      var _ref$current;
      (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
    }
  }, [visible]);
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", {
    ref: ref,
    type: "search",
    role: "combobox",
    "aria-haspopup": "listbox",
    readOnly: true,
    unselectable: "on",
    "aria-expanded": visible,
    onBlur: onBlur,
    onFocus: onFocus,
    className: "jsx-2813108835"
  }), /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "2813108835"
  }, "input.jsx-2813108835{position:fixed;top:-10000px;left:-10000px;opacity:0;z-index:-1;width:0;height:0;padding:0;font-size:0;border:none;}"));
});
SelectInput.displayName = 'SelectInput';

var _excluded$1 = ["children", "label", "type", "disabled", "initialValue", "value", "icon", "onChange", "pure", "multiple", "clearable", "placeholder", "className", "dropdownClassName", "dropdownStyle", "disableMatchWidth", "getPopupContainer", "onDropdownVisibleChange"];
var SelectComponent = /*#__PURE__*/React.forwardRef(function (_ref, selectRef) {
  var children = _ref.children,
    label = _ref.label,
    _ref$type = _ref.type,
    type = _ref$type === void 0 ? 'default' : _ref$type,
    _ref$disabled = _ref.disabled,
    disabled = _ref$disabled === void 0 ? false : _ref$disabled,
    init = _ref.initialValue,
    customValue = _ref.value,
    _ref$icon = _ref.icon,
    Icon = _ref$icon === void 0 ? SelectIcon : _ref$icon,
    onChange = _ref.onChange,
    _ref$pure = _ref.pure,
    pure = _ref$pure === void 0 ? false : _ref$pure,
    _ref$multiple = _ref.multiple,
    multiple = _ref$multiple === void 0 ? false : _ref$multiple,
    _ref$clearable = _ref.clearable,
    clearable = _ref$clearable === void 0 ? true : _ref$clearable,
    placeholder = _ref.placeholder,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? '' : _ref$className,
    dropdownClassName = _ref.dropdownClassName,
    dropdownStyle = _ref.dropdownStyle,
    _ref$disableMatchWidt = _ref.disableMatchWidth,
    disableMatchWidth = _ref$disableMatchWidt === void 0 ? false : _ref$disableMatchWidt,
    getPopupContainer = _ref.getPopupContainer,
    _ref$onDropdownVisibl = _ref.onDropdownVisibleChange,
    onDropdownVisibleChange = _ref$onDropdownVisibl === void 0 ? function () {} : _ref$onDropdownVisibl,
    props = _objectWithoutProperties(_ref, _excluded$1);
  var theme = useTheme();
  var _useScale = useScale(),
    SCALES = _useScale.SCALES;
  var ref = React.useRef(null);
  var inputRef = React.useRef(null);
  var dropdownRef = React.useRef(null);
  var _useState = React.useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    visible = _useState2[0],
    setVisible = _useState2[1];
  var _useState3 = React.useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    selectFocus = _useState4[0],
    setSelectFocus = _useState4[1];
  var _useCurrentState = useCurrentState(function () {
      if (!multiple) return init;
      if (Array.isArray(init)) return init;
      return typeof init === 'undefined' ? [] : [init];
    }),
    _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
    value = _useCurrentState2[0],
    setValue = _useCurrentState2[1],
    valueRef = _useCurrentState2[2];
  var isEmpty = React.useMemo(function () {
    if (!Array.isArray(value)) return !value;
    return value.length === 0;
  }, [value]);
  var _useMemo = React.useMemo(function () {
      return getColors(theme.palette, type);
    }, [theme.palette, type]),
    border = _useMemo.border,
    borderActive = _useMemo.borderActive,
    iconBorder = _useMemo.iconBorder,
    placeholderColor = _useMemo.placeholderColor;
  var updateVisible = function updateVisible(next) {
    onDropdownVisibleChange(next);
    setVisible(next);
  };
  var updateValue = function updateValue(next) {
    setValue(function (last) {
      if (!Array.isArray(last)) return next;
      if (!last.includes(next)) return [].concat(_toConsumableArray(last), [next]);
      return last.filter(function (item) {
        return item !== next;
      });
    });
    onChange && onChange(valueRef.current);
    if (!multiple) {
      updateVisible(false);
    }
  };
  var initialValue = React.useMemo(function () {
    return {
      value: value,
      visible: visible,
      updateValue: updateValue,
      updateVisible: updateVisible,
      ref: ref,
      disableAll: disabled
    };
  }, [visible, disabled, ref, value, multiple]);
  var clickHandler = function clickHandler(event) {
    event.stopPropagation();
    event.nativeEvent.stopImmediatePropagation();
    event.preventDefault();
    if (disabled) return;
    updateVisible(!visible);
    event.preventDefault();
  };
  var mouseDownHandler = function mouseDownHandler(event) {
    /* istanbul ignore next */
    if (visible) {
      event.preventDefault();
    }
  };
  React.useEffect(function () {
    if (customValue === undefined) return;
    setValue(customValue);
  }, [customValue]);
  React.useImperativeHandle(selectRef, function () {
    return {
      focus: function focus() {
        var _inputRef$current;
        return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
      },
      blur: function blur() {
        var _inputRef$current2;
        return (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.blur();
      },
      scrollTo: function scrollTo(options) {
        var _dropdownRef$current;
        return (_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.scrollTo(options);
      }
    };
  }, [inputRef, dropdownRef]);
  var selectedChild = React.useMemo(function () {
    var _pickChildByProps = pickChildByProps(children, 'value', value),
      _pickChildByProps2 = _slicedToArray(_pickChildByProps, 2),
      optionChildren = _pickChildByProps2[1];
    return React.Children.map(optionChildren, function (child) {
      if (! /*#__PURE__*/React.isValidElement(child)) return null;
      var el = /*#__PURE__*/React.cloneElement(child); // { preventAllEvents: true }
      if (!multiple) return el;
      return /*#__PURE__*/React.createElement(SelectMultipleValue, {
        disabled: disabled,
        onClear: clearable ? function () {
          return updateValue(child.props.value);
        } : null
      }, el);
    });
  }, [value, children, multiple]);
  var onInputBlur = function onInputBlur() {
    updateVisible(false);
    setSelectFocus(false);
  };
  var classes = useClasses('select', {
    active: selectFocus || visible,
    multiple: multiple
  }, className);
  return /*#__PURE__*/React.createElement("div", {
    className: _JSXStyle.dynamic([["3282295248", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]])
  }, label && /*#__PURE__*/React.createElement("label", {
    style: {
      display: 'block',
      marginBottom: '0.4rem',
      fontSize: '14px',
      fontWeight: 'light'
    },
    className: _JSXStyle.dynamic([["3282295248", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]])
  }, label), /*#__PURE__*/React.createElement(SelectContext.Provider, {
    value: initialValue
  }, /*#__PURE__*/React.createElement("div", _extends({
    ref: ref,
    onClick: clickHandler,
    onMouseDown: mouseDownHandler
  }, props, {
    className: _JSXStyle.dynamic([["3282295248", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]]) + " " + (props && props.className != null && props.className || classes || "")
  }), /*#__PURE__*/React.createElement(SelectInput, {
    ref: inputRef,
    visible: visible,
    onBlur: onInputBlur,
    onFocus: function onFocus() {
      return setSelectFocus(true);
    }
  }), isEmpty && /*#__PURE__*/React.createElement("span", {
    className: _JSXStyle.dynamic([["3282295248", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]]) + " " + "value placeholder"
  }, /*#__PURE__*/React.createElement(Ellipsis$1, {
    height: "var(--select-height)"
  }, placeholder)), value && !multiple && /*#__PURE__*/React.createElement("span", {
    className: _JSXStyle.dynamic([["3282295248", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]]) + " " + "value"
  }, selectedChild), value && multiple && /*#__PURE__*/React.createElement(Grid.Container, {
    gap: 0.5
  }, selectedChild), /*#__PURE__*/React.createElement(SelectDropdown, {
    ref: dropdownRef,
    visible: visible,
    className: dropdownClassName,
    dropdownStyle: dropdownStyle,
    disableMatchWidth: disableMatchWidth,
    getPopupContainer: getPopupContainer
  }, children), !pure && /*#__PURE__*/React.createElement("div", {
    className: _JSXStyle.dynamic([["3282295248", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]]) + " " + "icon"
  }, /*#__PURE__*/React.createElement(Icon, {
    className: _JSXStyle.dynamic([["3282295248", [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]]])
  })))), /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "3282295248",
    dynamic: [disabled ? 'not-allowed' : 'pointer', border, theme.layout.radius, disabled ? theme.palette.accents_1 : theme.palette.background, SCALES.font(0.875), SCALES.height(2.25), SCALES.width(1, 'initial'), SCALES.pt(0), SCALES.pr(0.334), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0.334), SCALES.pr(0.334), SCALES.pb(0.334), SCALES.pl(0.667), disabled ? theme.palette.border : borderActive, disabled ? theme.palette.accents_5 : borderActive, disabled ? theme.palette.accents_4 : theme.palette.foreground, placeholderColor, theme.layout.gapQuarter, visible ? '180' : '0', iconBorder]
  }, ".select.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;position:relative;cursor:".concat(disabled ? 'not-allowed' : 'pointer', ";max-width:90vw;overflow:hidden;-webkit-transition:border 150ms ease-in 0s,color 200ms ease-out 0s, box-shadow 200ms ease 0s;transition:border 150ms ease-in 0s,color 200ms ease-out 0s, box-shadow 200ms ease 0s;border:1px solid ").concat(border, ";border-radius:").concat(theme.layout.radius, ";background-color:").concat(disabled ? theme.palette.accents_1 : theme.palette.background, ";--select-font-size:").concat(SCALES.font(0.875), ";--select-height:").concat(SCALES.height(2.25), ";min-width:11.5em;width:").concat(SCALES.width(1, 'initial'), ";height:var(--select-height);padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0.334), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0.667), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.multiple.__jsx-style-dynamic-selector{height:auto;min-height:var(--select-height);padding:").concat(SCALES.pt(0.334), " ").concat(SCALES.pr(0.334), " ").concat(SCALES.pb(0.334), " ").concat(SCALES.pl(0.667), ";}.select.active.__jsx-style-dynamic-selector,.select.__jsx-style-dynamic-selector:hover{border-color:").concat(disabled ? theme.palette.border : borderActive, ";}.select.active.icon.__jsx-style-dynamic-selector,.select.__jsx-style-dynamic-selector:hover .icon.__jsx-style-dynamic-selector{color:").concat(disabled ? theme.palette.accents_5 : borderActive, ";}.value.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex:1;-ms-flex:1;flex:1;height:100%;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;line-height:1;padding:0;margin-right:1.25em;font-size:var(--select-font-size);color:").concat(disabled ? theme.palette.accents_4 : theme.palette.foreground, ";width:calc(100% - 1.25em);}.value.__jsx-style-dynamic-selector>div,.value.__jsx-style-dynamic-selector>div:hover{border-radius:0;background-color:transparent;padding:0;margin:0;color:inherit;}.placeholder.__jsx-style-dynamic-selector{color:").concat(placeholderColor, ";}.icon.__jsx-style-dynamic-selector{position:absolute;right:").concat(theme.layout.gapQuarter, ";font-size:var(--select-font-size);top:50%;bottom:0;-webkit-transform:translateY(-50%) rotate(").concat(visible ? '180' : '0', "deg);-ms-transform:translateY(-50%) rotate(").concat(visible ? '180' : '0', "deg);transform:translateY(-50%) rotate(").concat(visible ? '180' : '0', "deg);pointer-events:none;-webkit-transition:-webkit-transform 200ms ease;-webkit-transition:transform 200ms ease;transition:transform 200ms ease;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:").concat(iconBorder, ";}")));
});
SelectComponent.displayName = 'Select';
var Select = withScale(SelectComponent);

var _excluded = ["value", "className", "children", "disabled", "divider", "label", "preventAllEvents"];
var SelectOptionComponent = function SelectOptionComponent(_ref) {
  var identValue = _ref.value,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? '' : _ref$className,
    children = _ref.children,
    _ref$disabled = _ref.disabled,
    disabled = _ref$disabled === void 0 ? false : _ref$disabled,
    _ref$divider = _ref.divider,
    divider = _ref$divider === void 0 ? false : _ref$divider,
    _ref$label = _ref.label,
    label = _ref$label === void 0 ? false : _ref$label,
    _ref$preventAllEvents = _ref.preventAllEvents,
    preventAllEvents = _ref$preventAllEvents === void 0 ? false : _ref$preventAllEvents,
    props = _objectWithoutProperties(_ref, _excluded);
  var theme = useTheme();
  var _useScale = useScale(),
    SCALES = _useScale.SCALES;
  var _useSelectContext = useSelectContext(),
    updateValue = _useSelectContext.updateValue,
    value = _useSelectContext.value,
    disableAll = _useSelectContext.disableAll;
  var isDisabled = React.useMemo(function () {
    return disabled || disableAll;
  }, [disabled, disableAll]);
  var isLabel = React.useMemo(function () {
    return label || divider;
  }, [label, divider]);
  var classes = useClasses('option', {
    divider: divider,
    label: label
  }, className);
  if (!isLabel && identValue === undefined) {
    useWarning('The props "value" is required.', 'Select Option');
  }
  var selected = React.useMemo(function () {
    if (!value) return false;
    if (typeof value === 'string') {
      return identValue === value;
    }
    return value.includes("".concat(identValue));
  }, [identValue, value]);
  var bgColor = React.useMemo(function () {
    if (isDisabled) return theme.palette.accents_1;
    return selected ? theme.palette.accents_2 : theme.palette.background;
  }, [selected, isDisabled, theme.palette]);
  var hoverBgColor = React.useMemo(function () {
    if (isDisabled || isLabel || selected) return bgColor;
    return theme.palette.accents_1;
  }, [selected, isDisabled, theme.palette, isLabel, bgColor]);
  var color = React.useMemo(function () {
    if (isDisabled) return theme.palette.accents_4;
    return selected ? theme.palette.foreground : theme.palette.accents_5;
  }, [selected, isDisabled, theme.palette]);
  var clickHandler = function clickHandler(event) {
    if (preventAllEvents) return;
    event.stopPropagation();
    event.nativeEvent.stopImmediatePropagation();
    event.preventDefault();
    if (isDisabled || isLabel) return;
    updateValue && updateValue(identValue);
  };
  return /*#__PURE__*/React.createElement("div", _extends({
    onClick: clickHandler
  }, props, {
    className: _JSXStyle.dynamic([["199367556", [bgColor, color, isDisabled ? 'not-allowed' : 'pointer', SCALES.font(0.75), SCALES.width(1, '100%'), SCALES.height(2.25), SCALES.pt(0), SCALES.pr(0.667), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hoverBgColor, theme.palette.accents_7, theme.palette.border, SCALES.width(1, '100%'), SCALES.height(1, 0), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0.5), SCALES.mr(0), SCALES.mb(0.5), SCALES.ml(0), theme.palette.accents_7, theme.palette.border, SCALES.font(0.875), SCALES.width(1, '100%')]]]) + " " + (props && props.className != null && props.className || classes || "")
  }), /*#__PURE__*/React.createElement(Ellipsis$1, {
    height: SCALES.height(2.25)
  }, children), /*#__PURE__*/React.createElement(_JSXStyle, {
    id: "199367556",
    dynamic: [bgColor, color, isDisabled ? 'not-allowed' : 'pointer', SCALES.font(0.75), SCALES.width(1, '100%'), SCALES.height(2.25), SCALES.pt(0), SCALES.pr(0.667), SCALES.pb(0), SCALES.pl(0.667), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hoverBgColor, theme.palette.accents_7, theme.palette.border, SCALES.width(1, '100%'), SCALES.height(1, 0), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0.5), SCALES.mr(0), SCALES.mb(0.5), SCALES.ml(0), theme.palette.accents_7, theme.palette.border, SCALES.font(0.875), SCALES.width(1, '100%')]
  }, ".option.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;max-width:100%;box-sizing:border-box;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-weight:normal;background-color:".concat(bgColor, ";color:").concat(color, ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:0;cursor:").concat(isDisabled ? 'not-allowed' : 'pointer', ";-webkit-transition:background 0.2s ease 0s,border-color 0.2s ease 0s;transition:background 0.2s ease 0s,border-color 0.2s ease 0s;--select-font-size:").concat(SCALES.font(0.75), ";font-size:var(--select-font-size);width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(2.25), ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0.667), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0.667), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.option.__jsx-style-dynamic-selector:hover{background-color:").concat(hoverBgColor, ";color:").concat(theme.palette.accents_7, ";}.divider.__jsx-style-dynamic-selector{line-height:0;overflow:hidden;border-top:1px solid ").concat(theme.palette.border, ";width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, 0), ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0.5), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0.5), " ").concat(SCALES.ml(0), ";}.label.__jsx-style-dynamic-selector{color:").concat(theme.palette.accents_7, ";border-bottom:1px solid ").concat(theme.palette.border, ";text-transform:capitalize;cursor:default;font-size:").concat(SCALES.font(0.875), ";width:").concat(SCALES.width(1, '100%'), ";font-weight:500;}")));
};
SelectOptionComponent.displayName = 'SelectOption';
var SelectOption = withScale(SelectOptionComponent);

Select.Option = SelectOption;

exports.default = Select;
