/* @oracle/oraclejet-preact: undefined */
import { jsx, jsxs, Fragment } from 'preact/jsx-runtime';
import { I as IconButton } from './IconButton-7f91481c.js';
import { S as SvgNavLeft, a as SvgCancelS } from './NavLeft-9bb41f35.js';
import { useMemo } from 'preact/hooks';
import './keyboardUtils-986fe923.js';
import 'preact/compat';
import { T as TextFieldInput } from './StyledTextField-7605d76a.js';
import './ObfuscatedTextFieldInputStyles.styles.css';
import './useAccessibleContext-5744de8b.js';
import './logger-c92f309c.js';
import './FormContext-55fb8000.js';
import './FormFieldContext-47ca0c20.js';
import { u as useFormFieldContext } from './useFormFieldContext-daf7a676.js';
import './TabbableModeContext-7d8ad946.js';
import { u as useTranslationBundle } from './useTranslationBundle-4822502f.js';
import './textAlign-ad252afa.js';
import './FormControlUtilsStyles.styles.css';
import './ReadonlyTextFieldInputStyles.styles.css';
import './UNSAFE_TextField/themes/redwood/ReadonlyTextFieldInputVariants.css.js';
import { T as TextField } from './TextField-7884fcd7.js';
import './LiveRegionStyles.styles.css';
import './LayerHost-7931b424.js';
import './UNSAFE_TextField/themes/TextFieldStyles.css.js';
import './SkeletonStyles.styles.css';
import './TextFieldLoadingStyles.styles.css';
import './TextFieldStyles.styles.css';
import './UNSAFE_TextField/themes/redwood/TextFieldBaseTheme.styles.css';
import './UNSAFE_TextField/themes/redwood/TextFieldVariants.css.js';
import { a as DropdownArrow, r as renderItemText } from './useSelectCommon-a3c69d60.js';
import { L as LiveRegion } from './LiveRegion-cebac18d.js';
import './LabelValueLayoutStyles.styles.css';
import './LabelStyles.styles.css';
import './UNSAFE_Label/themes/redwood/LabelBaseTheme.styles.css';
import './UNSAFE_Label/themes/redwood/LabelVariants.css.js';
import './UNSAFE_TextField/themes/FormLayoutStyles.css.js';
import './UNSAFE_TextField/themes/redwood/FormLayoutBaseTheme.styles.css';
import './Flex-03129963.js';
import './LayoutStyles.styles.css';
import './InputGroupContext-20bdbd6e.js';
import './TooltipContentStyles.styles.css';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentBaseTheme.styles.css';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js';
import './tooltipUtils-af0abd38.js';

function SelectSingleField({ children, hasInsideLabel, isBackButtonShown, isClearButtonShown, isDropdownArrowShown, onBackButtonClick, onClearButtonClick, onDropdownArrowClick, ...passThroughTextFieldProps }) {
    const translations = useTranslationBundle('@oracle/oraclejet-preact');
    const { isDisabled, isLoading } = useFormFieldContext();
    const startContent = isBackButtonShown ? (jsx(IconButton, { "aria-label": translations.selectMultiple_back(), size: "xs", variant: "ghost", onAction: onBackButtonClick, children: jsx(SvgNavLeft, {}) })) : null;
    const endContent = isLoading ? undefined : (jsxs(Fragment, { children: [isClearButtonShown && (jsx(IconButton, { "aria-label": translations.formControl_clear(), size: "sm", variant: "ghost", onAction: onClearButtonClick, children: jsx(SvgCancelS, {}) })), isDropdownArrowShown && (jsx(DropdownArrow, { isDisabled: isDisabled, onClick: onDropdownArrowClick, testId: `${passThroughTextFieldProps.testId}_dropdownarrow` }))] }));
    return (jsx(TextField, { startContent: startContent, mainContent: children, endContent: endContent, ...passThroughTextFieldProps }));
}

function SelectSingleFieldInput({ displayValue, isAddToListShown, isAdvancedSearchShown, isUserFiltering, liveRegionText, userInput, virtualKeyboard, ...passThroughTextFieldInputProps }) {
    const translations = useTranslationBundle('@oracle/oraclejet-preact');
    const addToListAccText = translations.select_addToListAvailable();
    const advancedSearchAccText = translations.select_moreSearchOptionsAvailable();
    const combinedLiveRegionText = `${liveRegionText} ${isAddToListShown ? addToListAccText : ''} ${isAdvancedSearchShown ? advancedSearchAccText : ''}`;
    return (jsxs(Fragment, { children: [jsx(TextFieldInput, { ...passThroughTextFieldInputProps, hasEndContent: true, "aria-autocomplete": "list", autoComplete: "off", role: "combobox", spellcheck: false, type: virtualKeyboard === 'auto' ? 'search' : virtualKeyboard, value: isUserFiltering ? userInput : displayValue }), jsx(LiveRegion, { children: combinedLiveRegionText })] }));
}

/**
 * @license
 * Copyright (c) %FIRST_YEAR% %CURRENT_YEAR%, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 * @ignore
 */
function useDisplayValue(itemText, valueItem, componentName = 'SelectSingle') {
    // create the text displayed in the field from the selected value
    const displayValue = useMemo(() => {
        return valueItem === undefined ? '' : renderItemText(valueItem, itemText, componentName) ?? '';
    }, [valueItem, itemText, componentName]);
    return displayValue;
}

export { SelectSingleField as S, SelectSingleFieldInput as a, useDisplayValue as u };
//# sourceMappingURL=useDisplayValue-65bbc74e.js.map
