import { jsx as f } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { Fragment as d } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js";
import { useMemo as F } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import g from "../../../core/Context/preact/useCoreContext.js";
import v from "../../../utils/random/uniqueId.js";
import { isFunction as x } from "../../../utils/value/is.js";
const h = (o) => x(o) ? o : () => o, q = ({ count: o, defaultFill: u, fills: e, translationKey: c }) => {
  const { i18n: l } = g(), p = F(() => {
    const n = h(u);
    return e !== void 0 ? (...r) => {
      const [s, i] = r;
      for (const m of [s, i]) {
        const t = h(e[m])(...r);
        if (t != null) return t;
      }
      return n(...r);
    } : n;
  }, [e, u]);
  return F(() => {
    const n = [], r = v("translation"), s = (...t) => (n.push(p(...t) ?? null), r), [i, ...m] = l.get(c, { count: o, values: s }).split(r);
    return /* @__PURE__ */ f(d, { children: [
      i,
      m.map((t, a) => /* @__PURE__ */ f(d, { children: [
        n[a],
        t
      ] }, `${r}__${a}`))
    ] });
  }, [l, o, p, c]);
};
export {
  q as Translation
};
