
/**
 *   VERSION: 2.239.0-alpha.0
 *   BUILD_TIMESTAMP: 1780012993002
 *   BUILD_DATE: Fri May 29 2026 00:03:13 GMT+0000 (Coordinated Universal Time)
 *   BUILD_COMMIT: 3344b6c0fd9fa858907db310cfb1ef5e0d224da2
 */
import { j as o, F as E, J as P, i as R, r as h, s as H, l as J } from "../sheerid.js";
import { u as K } from "./downshift.esm-drVP4Tic.js";
const A = ({
  getItemProps: t,
  getMenuProps: s,
  highlightedIndex: i,
  options: n,
  itemToString: a,
  ariaLabel: e,
  isOpen: c,
  isLoading: p = !1
}) => {
  const u = (r, l) => /* @__PURE__ */ o.jsx(
    "div",
    {
      className: `sid-input-select-list__item ${i === l ? "sid-input-select-list__item--highlighted" : ""}`,
      ...t({
        item: r,
        index: l,
        key: r.value
      }),
      children: a(n[l])
    }
  ), f = n.length > 0 ? n.map((r, l) => u(r, l)) : /* @__PURE__ */ o.jsx("div", { className: "sid-input-select-list__message", children: /* @__PURE__ */ o.jsx(E, { id: "noOptions", defaultMessage: "No Options" }) });
  return /* @__PURE__ */ o.jsx("div", { ...s({ "aria-label": e }), children: c ? /* @__PURE__ */ o.jsx("div", { className: "sid-input-select-list__menu", children: p ? /* @__PURE__ */ o.jsx("div", { className: "sid-input-select-list__loading-spinner", children: /* @__PURE__ */ o.jsx(P, {}) }) : f }) : null });
}, D = A, U = ({
  clearSelection: t,
  disabled: s,
  getToggleButtonProps: i,
  isOpen: n,
  isClearable: a,
  intl: e
}) => {
  const {
    onClick: c,
    "aria-haspopup": p,
    "data-toggle": u,
    onKeyUp: f,
    onKeyDown: r,
    onBlur: l
  } = i(), g = a ? e.formatMessage({
    id: "clearAndOpenMenu",
    defaultMessage: "Clear selection and open menu"
  }) : e.formatMessage({ id: "openMenu", defaultMessage: "Open menu" });
  return /* @__PURE__ */ o.jsx(
    "button",
    {
      "aria-label": g,
      "aria-haspopup": p,
      "data-toggle": u,
      onKeyUp: f,
      onKeyDown: r,
      onBlur: l,
      className: "sid-input-select-button",
      disabled: s,
      type: "button",
      onClick: (m) => {
        typeof t == "function" && t(), typeof c == "function" && c(m);
      },
      children: /* @__PURE__ */ o.jsx(
        "svg",
        {
          viewBox: "0 0 20 20",
          preserveAspectRatio: "none",
          width: 16,
          fill: "transparent",
          stroke: "#8E95A4",
          strokeWidth: "1.1px",
          transform: n ? "rotate(180)" : void 0,
          children: /* @__PURE__ */ o.jsx("path", { d: "M1,6 L10,15 L19,6" })
        }
      )
    }
  );
}, q = R(U), y = (t) => t ? t.label : "", W = (t, s) => t.filter(
  (n) => !s || n.label.toLowerCase().includes(s.toLowerCase()) || n.value.toString().toLowerCase().includes(s.toLowerCase())
), I = ({
  className: t,
  inputId: s,
  disabled: i,
  fieldId: n,
  fieldLabelId: a,
  isErrored: e,
  options: c,
  onKeyDown: p,
  onChange: u,
  placeholder: f,
  // Most invokers want placeholder hidden by css, so it can be easily shown when
  // customizing the implementation. Birth date is an example of an exception.
  suppressPlaceholder: r = !0,
  value: l,
  autoFocus: g,
  ariaLabel: m,
  ariaDescribedBy: j,
  isRequired: O,
  isLoading: L = !1,
  role: M = "combobox",
  autoComplete: N
}) => {
  const [x, w] = h.useState(""), b = x ? W(c, x) : c, {
    getInputProps: _,
    getItemProps: $,
    getMenuProps: v,
    getToggleButtonProps: B,
    highlightedIndex: F,
    isOpen: C,
    selectItem: k
  } = K({
    id: s,
    items: b,
    onInputValueChange({ inputValue: d }) {
      w(d);
    },
    onSelectedItemChange: ({ selectedItem: d }) => u(d),
    itemToString: y,
    selectedItem: l && l.value && l.label ? l : null,
    defaultHighlightedIndex: 0
  }), T = (d) => {
    typeof p == "function" && p(d);
  }, S = h.useRef(null);
  return h.useEffect(() => {
    H(n, S.current);
  }), /* @__PURE__ */ o.jsxs("div", { className: `sid-input-select-list ${t || ""}`, children: [
    /* @__PURE__ */ o.jsx(
      "input",
      {
        ..._({
          ref: S,
          onKeyDown: (d) => T(d),
          "aria-labelledby": a
        }),
        autoFocus: g,
        id: s,
        className: `sid-l-full-width sid-text-input ${r ? "sid-hidden-placeholder" : ""} ${e ? "sid-text-input--error" : ""}`,
        disabled: i,
        placeholder: f,
        "aria-required": O,
        "aria-describedby": j,
        "aria-invalid": e,
        role: M,
        autoComplete: N
      }
    ),
    /* @__PURE__ */ o.jsx(
      q,
      {
        disabled: i,
        getToggleButtonProps: B,
        isOpen: C,
        isClearable: !!l?.value,
        clearSelection: () => k(void 0)
      }
    ),
    /* @__PURE__ */ o.jsx(
      D,
      {
        highlightedIndex: F,
        itemToString: y,
        options: b,
        getItemProps: $,
        getMenuProps: v,
        ariaLabel: m,
        isOpen: C,
        isLoading: L
      }
    )
  ] });
};
I.defaultProps = {
  className: void 0,
  disabled: !1,
  inputId: void 0,
  isErrored: !1,
  onKeyDown: void 0,
  placeholder: "",
  value: void 0,
  autoComplete: void 0
};
const V = I, z = (t, s) => {
  let i;
  try {
    i = t.label.toUpperCase() > s.label.toUpperCase() ? 1 : -1;
  } catch {
    i = 1;
  }
  return i;
}, X = (t) => t.sort(z), Y = (t, s = [], i) => {
  const n = [], a = [];
  return s.forEach((e) => {
    if (typeof e > "u") return a.push("undefined");
    if (!e || typeof e == "number" || typeof e == "string" && !e.trim())
      return a.push(JSON.stringify(e));
    n.push({
      value: e,
      label: i.formatHTMLMessage({
        id: `${t}.${e}`,
        defaultMessage: `{${t}.${e}}`
      })
    });
  }), a.length > 0 && J.warn(
    `FormSelectChoice.getFormFieldSelectOptions contains unexpected values (${a.length}): ${a.join(", ")}`
  ), n;
};
export {
  V as I,
  X as S,
  Y as g
};
