import { jsx as i, Fragment as u } from "react/jsx-runtime";
import { Icon as g } from "./index-Icon.js";
import { IconNames as y } from "./index-IconNames.js";
import { LottieBase as S } from "./index-LottieBase.js";
import { useState as N, useEffect as w } from "react";
const P = (s) => {
  const {
    src: n,
    placeholder: c,
    translations: f
  } = s, [a, o] = N(null), m = (t) => {
    if (!t)
      return !1;
    if (typeof t == "string")
      o(null), fetch(t).then((e) => e.json()).then((e) => {
        const r = l(e, f);
        o(r);
      });
    else if (t) {
      const e = l(t, f);
      o(e);
    }
  }, l = (t, e) => {
    if (!t)
      return !1;
    if (!e)
      return t;
    let r = JSON.stringify(t);
    if (typeof e == "string" && (e = JSON.parse(e)), typeof e != "string")
      for (const p in e) {
        const d = `${p}`, h = new RegExp(d, "g");
        r = r.replace(h, e[p]);
      }
    return JSON.parse(r);
  };
  return w(() => {
    m(n);
  }, [n]), a ? i(S, {
    animationData: a
  }) : c ? i(u, {
    children: c
  }) : i(g, {
    spin: !0,
    forceSize: 90,
    children: y.settings
  });
};
export {
  P as LottieAnimationLoader
};
