"use client";
import { j as a } from "./index.esm38.js";
import { forwardRef as H, useState as m, useCallback as d } from "react";
import h from "./index.esm40.js";
import t from "./index.esm64.js";
import { HeartIcon as I } from "./index.esm65.js";
import { Typography as P } from "./index.esm9.js";
const R = H(
  ({
    liked: u,
    defaultLiked: x = !1,
    count: n,
    onLike: s,
    onClick: o,
    className: B,
    testId: j,
    disabled: r,
    ...N
  }, v) => {
    const i = u !== void 0, [y, E] = m(x), [g, c] = m(!1), [k, f] = m(!1), e = i ? u : y, A = d(
      (l) => {
        if (r) return;
        const p = !e;
        i || E(p), s == null || s(p), o == null || o(l), p && (c(!0), n !== void 0 && f(!0));
      },
      [r, e, i, s, o, n]
    ), b = d(() => {
      c(!1);
    }, []), W = d((l) => {
      l.stopPropagation(), f(!1);
    }, []);
    return /* @__PURE__ */ a.jsxs(
      "button",
      {
        ref: v,
        type: "button",
        "data-atme-ui": !0,
        className: h(
          t.likeButton,
          e && t["likeButton--liked"],
          g && t["likeButton--pop"],
          r && t["likeButton--disabled"],
          B
        ),
        "aria-pressed": e,
        "aria-label": e ? "Убрать лайк" : "Поставить лайк",
        disabled: r,
        "data-testid": j,
        onClick: A,
        onAnimationEnd: b,
        ...N,
        children: [
          /* @__PURE__ */ a.jsx("span", { className: t.heartWrap, children: /* @__PURE__ */ a.jsx(I, { filled: e, className: t.heart, decorative: !0 }) }),
          n !== void 0 && /* @__PURE__ */ a.jsx(
            "span",
            {
              className: h(t.countWrap, k && t["countWrap--bump"]),
              onAnimationEnd: W,
              children: /* @__PURE__ */ a.jsx(P, { variant: "caption", className: t.count, as: "span", children: n })
            }
          )
        ]
      }
    );
  }
);
R.displayName = "LikeButton";
export {
  R as LikeButton
};
//# sourceMappingURL=index.esm21.js.map
