import * as e from "react";
const t = (t2) => (r2) => {
  try {
    if ("string" == typeof t2) {
      if (t2.includes("=>") || t2.includes("function") || t2.includes("React.createElement"))
        return ((t3, r3) => {
          try {
            return new Function("React", "data", "value", "row", `return ${t3};`)(e, r3.data, r3.value, r3.row);
          } catch (e2) {
            return console.error("Error evaluating JSX string:", e2), r3.value;
          }
        })(t2, r2);
      const n2 = ((e2, t3) => e2.replace(/\${([^}]+)}/g, (e3, r3) => {
        try {
          return new Function("data", "value", "row", "indexItem", `return ${r3}`)(t3.data, t3.value, t3.row, t3.index);
        } catch (t4) {
          return console.error("Error processing template string:", t4), e3;
        }
      }))(t2, r2);
      return ((t3) => {
        try {
          if (t3.trim().startsWith("<") && t3.trim().endsWith(">")) {
            const r3 = document.createElement("div");
            r3.innerHTML = t3.trim();
            const n3 = r3.firstChild;
            if (n3) {
              const t4 = {};
              return Array.from(n3.attributes).forEach((e2) => {
                "style" === e2.name ? t4.style = ((e3) => {
                  const t5 = {};
                  if (!e3)
                    return t5;
                  const r4 = e3.split(";");
                  for (const e4 of r4) {
                    const [r5, n4] = e4.split(":").map((e5) => e5.trim());
                    r5 && n4 && (t5[r5.replace(/-([a-z])/g, (e5, t6) => t6.toUpperCase())] = n4);
                  }
                  return t5;
                })(e2.value) : t4[e2.name] = e2.value;
              }), n3.innerHTML && !n3.innerHTML.includes("<") && (t4.children = n3.innerHTML), e.createElement(n3.tagName.toLowerCase(), t4);
            }
          }
          return t3;
        } catch (e2) {
          return console.error("Error converting HTML to React:", e2), t3;
        }
      })(n2);
    }
    if ("function" == typeof t2)
      return t2(r2);
  } catch (e2) {
    return console.error("Error in cell renderer:", e2), r2.value;
  }
  return r2.value;
}, r = { maxWidth: "100px", maxHeight: "60px", objectFit: "contain", verticalAlign: "middle" }, n = (t2) => {
  const { value: n2, data: o2 } = t2;
  return n2 ? e.createElement("img", { src: n2, alt: o2.altText || "Image", style: r }) : null;
}, o = (t2) => {
  const { value: r2, text: n2, data: o2 } = t2;
  return r2 ? e.createElement("a", { href: r2, target: "_blank", rel: "noopener noreferrer", style: { color: "#1890ff", textDecoration: "none" }, onMouseEnter: (e2) => {
    e2.currentTarget.style.textDecoration = "underline";
  }, onMouseLeave: (e2) => {
    e2.currentTarget.style.textDecoration = "none";
  } }, n2 || o2.linkText || r2) : null;
}, a = (t2) => {
  const { value: r2, text: n2 } = t2;
  return r2 ? e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px" } }, [e.createElement("div", { key: "color-box", style: { backgroundColor: r2, width: "24px", height: "24px", borderRadius: "4px", border: "1px solid #ddd" } }), n2 && e.createElement("span", { key: "color-text" }, n2)].filter(Boolean)) : null;
}, l = (t2) => {
  const { value: r2, column: n2 } = t2, o2 = (n2 == null ? void 0 : n2.trueText) || "✓", a2 = (n2 == null ? void 0 : n2.falseText) || "✗";
  return e.createElement("span", { style: { color: r2 ? "#52c41a" : "#ff4d4f", fontWeight: "bold" } }, r2 ? o2 : a2);
}, c = (t2) => {
  const { value: r2, data: n2, column: o2 } = t2, a2 = o2 == null ? void 0 : o2.onClick;
  return a2 ? e.createElement("button", { onClick: (e2) => {
    e2.stopPropagation(), a2(n2, e2);
  }, style: { padding: "4px 15px", borderRadius: "2px", border: "1px solid #d9d9d9", cursor: "pointer", backgroundColor: "#fff", transition: "all 0.3s" } }, r2) : r2;
}, i = (e2) => {
  if (e2)
    return e2.customRender ? t(e2.customRender) : void 0;
};
export {
  l as booleanRenderer,
  c as buttonRenderer,
  a as colorRenderer,
  t as createCellRenderer,
  i as getCellRenderer,
  n as imageRenderer,
  o as linkRenderer
};
