import "react/jsx-runtime";
import "react";
import b from "string-template";
const f = /(\%)[\(]([A-z0-9,.]+)\)/gi, g = /(\#)[\(]([A-z0-9,.]+)\)/gi, h = /(\#C)[\(]([A-z0-9,.]+)\)/gi, x = /(\$)[\(]([A-z0-9,.]+)\)/gi, A = [
  {
    name: "USD Dollar",
    code: "USD",
    symbol: "$"
  },
  {
    name: "Naira",
    code: "NGN",
    symbol: "₦"
  },
  {
    name: "South Africa Rand",
    code: "ZAR",
    symbol: "R"
  },
  {
    name: "Ethiopian Birr",
    code: "ETB",
    symbol: "Br"
  },
  {
    name: "Zambian Kwacha",
    code: "ZMW",
    symbol: "ZK"
  },
  {
    name: "Kenyan Shilling",
    code: "KES",
    symbol: "KSh"
  }
], i = (r, t, o, e, s) => {
  let n, c = t;
  for (; (n = r.exec(t)) !== null; ) {
    const l = n[2], u = (p, d = 2) => s.formatNumber(e ? p / 100 : p, {
      maximumFractionDigits: d,
      ...o
    }), m = l.split(","), y = m.length > 0 && m[0] ? u.apply(void 0, m) : "No Data";
    c = c.replaceAll(n[0], y);
  }
  return c;
}, S = (r, t) => {
  let o, e = t;
  for (; (o = r.exec(t)) !== null; )
    if (o.length > 2) {
      const s = o[0], n = o[2], c = A.find((l) => a(l.code) == a(n) || a(l.name) == a(n) || a(l.symbol) == a(n));
      c && (e = e.replaceAll(s, c.symbol));
    }
  return e;
}, a = (r) => r && r.trim().toLowerCase(), D = (r, t, o) => {
  let e = b(r, t).replace(/(?:\r\n|\r|\n)/g, "<br>");
  return e = i(f, e, { style: "percent" }, !0, o), e = i(g, e, { style: "decimal" }, !1, o), e = i(h, e, { notation: "compact" }, !1, o), e = S(x, e), e;
};
export {
  D as formatContent
};
