"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const designSystem = require("@choiceform/design-system");
const index = require("../../_vendor/@lottiefiles/dotlottie-react/dist-browser-index.cjs");
const React = require("react");
const LottiePlayer = React.memo(function LottiePlayer2(props) {
  const { isStreaming, src, className } = props;
  const [dotLottie, setDotLottie] = React.useState(null);
  const dotLottieRefCallback = (dotLottie2) => {
    setDotLottie(dotLottie2);
  };
  React.useEffect(() => {
    if (!dotLottie) return;
    const onLoaded = () => {
      dotLottie.setFrame(1);
      if (isStreaming) {
        dotLottie.play();
      }
    };
    if (isStreaming) {
      const anyDot2 = dotLottie;
      if (anyDot2.isLoaded) {
        dotLottie.play();
      }
    } else {
      dotLottie.setFrame(1);
      dotLottie.pause();
    }
    const anyDot = dotLottie;
    anyDot?.addEventListener?.("load", onLoaded);
    anyDot?.addEventListener?.("ready", onLoaded);
    return () => {
      anyDot?.removeEventListener?.("load", onLoaded);
      anyDot?.removeEventListener?.("ready", onLoaded);
    };
  }, [isStreaming, dotLottie]);
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: designSystem.tcx("relative flex size-6 items-center justify-center", className), children: /* @__PURE__ */ jsxRuntime.jsx(
    index.DotLottieReact,
    {
      className: "absolute -left-2 -top-2 size-10",
      src,
      loop: true,
      dotLottieRefCallback,
      renderConfig: {
        devicePixelRatio: 3
      }
    }
  ) });
});
exports.LottiePlayer = LottiePlayer;
//# sourceMappingURL=lottie-player.cjs.map
