import{_ as _extends}from"./_rollupPluginBabelHelpers-B5fk9IVe.js";import React__default,{useContext,useEffect,Fragment}from"react";import PropTypes from"prop-types";import{a as ComboBoxContext,q as qt}from"./ComboBox.component-DMS2vpim.js";import{I as Icon}from"./Icon.component-BVkaZqpA.js";const optionStyles=`
  jn-flex
  jn-pt-[0.6875rem]
  jn-pb-[0.5rem]
  jn-pr-[0.875rem]
  jn-select-none
  data-[headlessui-state=active]:jn-outline-none
  data-[headlessui-state=active]:jn-ring-2
  data-[headlessui-state=active]:jn-ring-inset
  data-[headlessui-state=active]:jn-ring-theme-focus
  data-[headlessui-state=active]:jn-bg-theme-background-lvl-3
`,unselectedOptionStyles=`
  jn-text-theme-default
  jn-pl-[2.375rem]
`,selectedOptionStyles=`
  jn-text-theme-accent
  jn-pl-3.5
`,selectedIconStyles=`
  jn-inline-block
  jn-mr-1.5
`,disabledOptionLabelStyles=`
  jn-opacity-50
  jn-cursor-not-allowed
`,truncateOptionStyles=`
  jn-block
  jn-h-6
  jn-overflow-hidden
  jn-text-ellipsis
  jn-whitespace-nowrap
`,ComboBoxOption=a=>{let{children:b,disabled:e=!1,value:f="",label:c,className:g="",...d}=a;const h=useContext(ComboBoxContext),{selectedValue:i,truncateOptions:j,addOptionValueAndLabel:k}=h||{};useEffect(()=>{k(f,c,b)},[f,c,b]);const l=f||b;return React__default.createElement(qt.Option,{value:l,disabled:e,as:Fragment},React__default.createElement("li",_extends({className:`
          juno-combobox-option 
          ${optionStyles}
          ${i===f?selectedOptionStyles:unselectedOptionStyles}
          ${e?"jn-cursor-not-allowed":""}
          ${g}
        `},d),i===l?React__default.createElement(Icon,{icon:"check",size:"18",className:`${selectedIconStyles}`}):"",React__default.createElement("span",{className:`
            ${e?disabledOptionLabelStyles:""}
            ${j?truncateOptionStyles:""}
          `},b||c||f)))};ComboBoxOption.propTypes={children:PropTypes.string,disabled:PropTypes.bool,value:PropTypes.string,label:PropTypes.string,className:PropTypes.string};export{ComboBoxOption as C};