"use strict";
// The require scope
var __webpack_require__ = {};
/************************************************************************/ // webpack/runtime/define_property_getters
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
// webpack/runtime/has_own_property
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
// webpack/runtime/make_namespace_object
(()=>{
    // define __esModule on exports
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
/************************************************************************/ var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
    default: ()=>/* binding */ Option_rslib_entry_,
    useSize: ()=>/* binding */ useSize
});
const react_namespaceObject = require("@chakra-ui/react");
/** A typeguard to ensure the default size on the Input component is valid. */ const isSize = (size)=>{
    const isString = 'string' == typeof size;
    return isString && [
        'sm',
        'md',
        'lg'
    ].includes(size);
};
const getDefaultSize = (size)=>{
    if (isSize(size)) return size;
    if ('xs' === size) return 'sm';
    // This shouldn't be necessary but it might help the size get closer to the
    // user's goal if they have `xl` as a custom size.
    if ('xl' === size) return 'lg';
    return 'md';
};
const useSize = (size)=>{
    const chakraTheme = (0, react_namespaceObject.useTheme)();
    const defaultSize = getDefaultSize(chakraTheme.components.Input.defaultProps.size);
    // Ensure that the size used is one of the options, either `sm`, `md`, or `lg`
    const definedSize = size ?? defaultSize;
    // Or, if a breakpoint is passed, get the size based on the current screen size
    const realSize = (0, react_namespaceObject.useBreakpointValue)('string' == typeof definedSize ? [
        definedSize
    ] : definedSize, {
        fallback: 'md'
    }) || defaultSize;
    return realSize;
};
/**
 * The `CheckIcon` component from the Chakra UI Menu
 *
 * @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/menu/src/menu.tsx#L314}
 */ const CheckIcon = (props)=>/*#__PURE__*/ React.createElement(react_namespaceObject.Icon, {
        viewBox: "0 0 14 14",
        w: "1em",
        h: "1em",
        ...props
    }, /*#__PURE__*/ React.createElement("polygon", {
        fill: "currentColor",
        points: "5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039"
    }));
const CustomOption = (props)=>{
    const { className, cx, innerRef, innerProps, children, isFocused, isDisabled, isSelected, selectProps: { chakraStyles, size: sizeProp, isMulti, hideSelectedOptions, selectedOptionStyle, selectedOptionColorScheme } } = props;
    const size = useSize(sizeProp);
    const menuItemStyles = (0, react_namespaceObject.useMultiStyleConfig)('Menu').item;
    const paddings = {
        sm: '0.3rem 0.6rem',
        md: '0.4rem 0.8rem',
        lg: '0.5rem 1rem'
    };
    /**
   * Use the same selected color as the border of the select component
   *
   * @see {@link https://github.com/chakra-ui/chakra-ui/blob/13c6d2e08b61e179773be4722bb81173dd599306/packages/theme/src/components/input.ts#L73}
   */ const selectedBg = (0, react_namespaceObject.useColorModeValue)(`${selectedOptionColorScheme}.500`, `${selectedOptionColorScheme}.300`);
    const selectedColor = (0, react_namespaceObject.useColorModeValue)('white', 'black');
    // Don't create exta space for the checkmark if using a multi select with
    // options that dissapear when they're selected
    const showCheckIcon = 'check' === selectedOptionStyle && (!isMulti || false === hideSelectedOptions);
    const shouldHighlight = 'color' === selectedOptionStyle && isSelected;
    const initialSx = {
        ...menuItemStyles,
        display: 'flex',
        alignItems: 'center',
        width: '100%',
        textAlign: 'start',
        fontSize: size,
        padding: paddings[size],
        ...isFocused && menuItemStyles._focus,
        ...shouldHighlight && {
            bg: selectedBg,
            color: selectedColor,
            _active: {
                bg: selectedBg
            }
        },
        ...isDisabled && menuItemStyles._disabled,
        ...isDisabled && {
            _active: {}
        }
    };
    const sx = chakraStyles?.option ? chakraStyles.option(initialSx, props) : initialSx;
    return /*#__PURE__*/ React.createElement(react_namespaceObject.Box, {
        ...innerProps,
        role: "button",
        className: cx({
            option: true,
            'option--is-disabled': isDisabled,
            'option--is-focused': isFocused,
            'option--is-selected': isSelected
        }, className),
        sx: sx,
        ref: innerRef,
        "data-disabled": !!isDisabled || void 0,
        "aria-disabled": !!isDisabled || void 0
    }, showCheckIcon && /*#__PURE__*/ React.createElement(react_namespaceObject.Menu, null, /*#__PURE__*/ React.createElement(react_namespaceObject.MenuIcon, {
        fontSize: "0.8em",
        marginEnd: "0.75rem",
        opacity: isSelected ? 1 : 0
    }, /*#__PURE__*/ React.createElement(CheckIcon, null))), children);
};
/* ESM default export */ const Option_rslib_entry_ = CustomOption;
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
