import { jsx as t, Fragment as m } from "react/jsx-runtime";
import { useRef as u, useState as _, useEffect as x } from "react";
import { d as a } from "../../../dayjs.min-KYonM6tp.js";
import { cn as o, formatAmountCo as d } from "../../../utils/functions.js";
import { WrapperTableTdComponents as T } from "./TdComponents/WrapperTableTdComponents.js";
import { TableTdItem as i } from "./variants.js";
import { m as p } from "../../../motion-dVICNqWI.js";
import "../../../_commonjsHelpers-2ufMB8rV.js";
import "../../../clsx-7d8NmkQq.js";
import "../../../useQuery-n4ls1rLk.js";
import "../../../index-xVF7D3FM.js";
import "../../../SVGVisualElement-aqO4D4Z5.js";
import "../../../LayoutGroupContext-3euHzeKi.js";
const R = ({ data: r, dataConfig: e }) => {
  const l = r[e.cellParam];
  if (e.customCellComponent)
    return /* @__PURE__ */ t(
      "td",
      {
        className: o(
          i({ variant: "govco" }),
          "_max-w-[200px] [&>div]:_min-h-[30px]",
          e.isAction ? "_w-5 _max-w-[50px] _pl-5" : "",
          e.tdClassName
        ),
        children: e.customCellComponent(r)
      }
    );
  if (e.cellComponent) {
    const { componentKey: c, ...s } = e.cellComponent, n = Object.assign(
      {},
      { ...s, infotoshow: `${l}`, cellparam: e.cellParam, data: r, componentKey: c }
    );
    return /* @__PURE__ */ t("td", { className: o("_max-w-[200px] _min-h-[30px]", e.isAction ? "_w-5 _max-w-[50px] _pl-5" : "", e.tdClassName), children: /* @__PURE__ */ t(T, { ...n }) });
  }
  return (
    // <td>{data[dataConfig.cellParam] || `No hay ${dataConfig.columnName}`}</td>
    /* @__PURE__ */ t(m, { children: e.cellType == "longText" ? /* @__PURE__ */ t(b, { data: r, dataConfig: e }) : /* @__PURE__ */ t(
      "td",
      {
        "data-type": e.cellType,
        className: o(
          i({ variant: "govco" }),
          "_max-w-[200px] [&>div]:_min-h-[30px]",
          e.isAction ? "_w-5 _max-w-[50px] _pl-5" : "",
          e.tdClassName
        ),
        children: {
          "": l ?? "-",
          amount: /* @__PURE__ */ t(w, { value: l }),
          date: /* @__PURE__ */ t(v, { value: l }),
          text: /* @__PURE__ */ t(m, { children: r[e.cellParam] || `Sin ${e.columnName}` }),
          unixDate: /* @__PURE__ */ t(f, { value: l }),
          tag: /* @__PURE__ */ t(N, { value: l })
        }[e.cellType ?? ""]
      }
    ) })
  );
}, w = ({ value: r }) => /* @__PURE__ */ t("div", { className: "_text-right _pr-5 _whitespace-nowrap _font-main", children: d(r) }), v = ({ value: r }) => !r || r === null ? /* @__PURE__ */ t(m, { children: "----" }) : /* @__PURE__ */ t("div", { children: a(r).format("DD/MM/YYYY").toString().split("T")[0] }), f = ({ value: r }) => !r || r === null ? /* @__PURE__ */ t(m, { children: "----" }) : /* @__PURE__ */ t("div", { children: a(+r).format("DD/MM/YYYY") }), b = ({ dataConfig: r, data: e }) => {
  const l = u(null), [c, s] = _(!1);
  return x(() => {
    const n = l.current;
    if (n) {
      const h = n.offsetHeight < n.scrollHeight || n.offsetWidth < n.scrollWidth;
      s(h);
      return;
    }
  }, [l.current]), /* @__PURE__ */ t(
    p.td,
    {
      whileHover: c ? {
        backgroundColor: "rgba(200,200,200)",
        transition: { backgroundColor: { duration: 0.2, type: "tween" } }
      } : {},
      children: /* @__PURE__ */ t(
        p.div,
        {
          className: o(i({ variant: "govco" }), "_font-main _line-clamp-1 hover:_line-clamp-3 hover:_transition-all _min-h-[25px]"),
          ref: l,
          children: e[r.cellParam]
        }
      )
    }
  );
}, N = ({ value: r }) => /* @__PURE__ */ t("p", { className: "_font-main _text-center _w-fit _rounded-3xl _py-1 _px-2", children: r });
export {
  R as TableTd
};
