import { jsx as n } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { InteractionKeyCode as r } from "../../../../types.js";
import { ButtonVariant as u } from "../../../Button/types.js";
import s from "classnames";
import { Fragment as f } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js";
import { Icon as e } from "../../../Icon/Icon.js";
import b from "../../../Button/Button.js";
function C({
  label: i,
  isOpen: d,
  isInvalid: t,
  onClick: p,
  onClear: a,
  showClearButton: c,
  buttonRef: l,
  isReadOnly: m
}) {
  return /* @__PURE__ */ n(
    b,
    {
      ref: l,
      onClick: (o) => {
        o.preventDefault(), p();
      },
      variant: u.SECONDARY,
      "aria-haspopup": "dialog",
      "aria-expanded": d,
      "aria-invalid": t ? "true" : void 0,
      disabled: m,
      className: s("adyen-pe-button adyen-pe-dropdown__button", {
        "adyen-pe-button--invalid": t
      }),
      iconRight: c ? /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n(
        "span",
        {
          role: "button",
          tabIndex: 0,
          "data-testid": "calendar-input-clear-button",
          className: "adyen-pe-dropdown__button-clear",
          onClick: (o) => {
            o.preventDefault(), o.stopPropagation(), a?.(o);
          },
          onKeyDown: (o) => {
            (o.code === r.ENTER || o.code === r.SPACE) && (o.preventDefault(), o.stopPropagation(), a?.(o));
          },
          children: /* @__PURE__ */ n(e, { name: "cross-circle-fill" })
        }
      ) }) : /* @__PURE__ */ n(e, { className: "adyen-pe-dropdown__button-collapse-indicator", name: "chevron-down" }),
      children: /* @__PURE__ */ n("span", { children: i })
    }
  );
}
export {
  C as CalendarInputButton
};
