import { jsxs as t, jsx as e, Fragment as j } from "react/jsx-runtime";
import { Handle as x, Position as N, getStraightPath as U, BaseEdge as V } from "reactflow";
import { Tooltip as $, Chip as q } from "@mui/material";
import { GrTrigger as ke } from "react-icons/gr";
import { createContext as ve, useContext as we } from "react";
import { d as Se } from "./messages-CO299wPN.js";
import { MdOutlineModeEdit as D, MdInfoOutline as B, MdInput as fe, MdDeleteOutline as F, MdCheckCircle as Ce, MdPeople as Te, MdSchedule as Ee, MdWebhook as de, MdNotifications as O, MdSms as ze, MdEmail as Ie, MdContentCopy as Pe, MdHttp as Ae, MdCallSplit as De, MdAccountTree as Le, MdOpenInNew as Re } from "react-icons/md";
import { FaCheckCircle as ae, FaTimesCircle as pe } from "react-icons/fa";
import { FiFilter as We } from "react-icons/fi";
import { a as K, H as Fe, B as Y } from "./canvasTokens-CAD6G24b.js";
const $e = ve({
  onEditNode: () => {
  },
  onDeleteNode: () => {
  },
  onAddStep: () => {
  },
  onClickAddTrigger: () => {
  },
  messages: Se,
  nodeRegistry: null,
  nodeBody: "full"
}), P = () => we($e), je = () => /* @__PURE__ */ t("div", { style: { width: 350, display: "flex", justifyContent: "center" }, children: [
  /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0, left: "50%" } }),
  /* @__PURE__ */ e("div", { style: { padding: "8px 28px", borderRadius: 999, background: "#f5f5f5", border: "1.5px solid #bdbdbd", fontSize: 13, fontWeight: 500, color: "#424242", userSelect: "none" }, children: "Start" })
] }), Be = () => /* @__PURE__ */ t("div", { style: { width: 350, display: "flex", justifyContent: "center" }, children: [
  /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0, left: "50%" } }),
  /* @__PURE__ */ e("div", { style: { padding: "8px 28px", borderRadius: 999, background: "#f5f5f5", border: "1.5px solid #bdbdbd", fontSize: 13, fontWeight: 500, color: "#424242", userSelect: "none" }, children: "End" })
] }), Ke = () => {
  const { onClickAddTrigger: n, messages: i } = P();
  return /* @__PURE__ */ t("div", { style: { width: 350, display: "flex", justifyContent: "center" }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0, left: "50%" } }),
    /* @__PURE__ */ e($, { title: i.addTriggerTooltip, placement: "top", arrow: !0, children: /* @__PURE__ */ t(
      "div",
      {
        onClick: n,
        role: "button",
        tabIndex: 0,
        onKeyDown: (f) => {
          f.key === "Enter" && n();
        },
        style: { padding: "10px 24px", borderRadius: 8, border: "1.5px dashed #d0d0d0", background: "#fff", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", gap: 8 },
        children: [
          /* @__PURE__ */ e(ke, { size: 16 }),
          /* @__PURE__ */ e("span", { className: "ff-text-black", style: { fontSize: 13 }, "data-testid": "add-trigger-btn-text", children: i.addTriggerButton })
        ]
      }
    ) }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0, left: "50%" } })
  ] });
}, Me = ({ id: n }) => {
  const { onAddStep: i } = P();
  return /* @__PURE__ */ t(
    "div",
    {
      onClick: () => i(n),
      role: "button",
      tabIndex: 0,
      onKeyDown: (f) => {
        f.key === "Enter" && i(n);
      },
      style: { width: 28, height: 28, borderRadius: "50%", border: "1.5px solid #9e9e9e", background: "#fff", display: "flex", alignItems: "center", justifyContent: "center", cursor: "pointer", fontSize: 18, color: "#757575", lineHeight: 1, userSelect: "none" },
      children: [
        /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
        "+",
        /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } })
      ]
    }
  );
};
function ge(n) {
  return n ? n.replace(/[_-]+/g, " ").toLowerCase().replace(/\b\w/g, (i) => i.toUpperCase()) : "";
}
function _e(n) {
  if (typeof n != "string" && n.label) return n.label;
  const i = typeof n == "string" ? n : n.value ?? "";
  return ge(i);
}
const He = ({ data: n }) => {
  const { onClickAddTrigger: i } = P(), {
    type: f,
    eventType: p,
    sources: c,
    label: r,
    source: h,
    previewWorkflow: o,
    executionStatus: l,
    infoText: d = "This node decides the flow trigger type and configuration."
  } = n ?? {}, u = (m) => {
    m == null || m.stopPropagation(), i();
  }, y = Array.isArray(c) && c.length > 0, k = !!(r || h), g = f === "scheduler" ? "Scheduler Trigger" : f === "event" || y || k ? "Event Trigger Source" : "Select Trigger", s = (() => {
    if (f === "scheduler")
      return /* @__PURE__ */ e("span", { children: "Scheduler to be configured" });
    if (f === "event" || y) {
      const m = r || ge(p);
      return /* @__PURE__ */ t("div", { children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center", children: [
          /* @__PURE__ */ e("span", { style: { fontWeight: 600 }, children: m }),
          /* @__PURE__ */ e("span", { className: "ff-ms-2 ff-text-muted", style: { fontSize: 12 }, children: "via" })
        ] }),
        /* @__PURE__ */ e("div", { className: "ff-d-flex ff-flex-wrap ff-mt-2", style: { gap: 4 }, children: y ? c.map((C, v) => /* @__PURE__ */ e(
          q,
          {
            label: _e(C),
            variant: "outlined",
            size: "small",
            className: "ff-text-dark"
          },
          v
        )) : /* @__PURE__ */ e("span", { className: "ff-text-muted", style: { fontSize: 12 }, children: "No source selected" }) })
      ] });
    }
    return k ? /* @__PURE__ */ t("div", { className: "ff-d-flex ff-flex-wrap ff-align-items-center", style: { gap: 6 }, children: [
      r && /* @__PURE__ */ e("span", { style: { fontWeight: 600 }, children: r }),
      h && /* @__PURE__ */ e(q, { label: h, variant: "outlined", size: "small" })
    ] }) : /* @__PURE__ */ e(
      "span",
      {
        role: "button",
        tabIndex: 0,
        onClick: u,
        onKeyDown: (m) => {
          (m.key === "Enter" || m.key === " ") && u(m);
        },
        style: { cursor: "pointer", color: "#1e88e5" },
        children: "Click to select a trigger to start your workflow"
      }
    );
  })(), S = l ? /* @__PURE__ */ t(j, { children: [
    l.status === "success" && /* @__PURE__ */ e(ae, { size: 16, color: "#1DBF60", style: { marginRight: 8 } }),
    l.status === "failed" && /* @__PURE__ */ e(pe, { size: 16, color: "#f44336", style: { marginRight: 8 } })
  ] }) : /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center", children: [
    !o && /* @__PURE__ */ e(
      "div",
      {
        role: "button",
        tabIndex: 0,
        onClick: u,
        onKeyDown: (m) => {
          (m.key === "Enter" || m.key === " ") && u(m);
        },
        className: "ff-me-2",
        style: { cursor: "pointer", color: "#212121" },
        "aria-label": "Edit trigger",
        children: /* @__PURE__ */ e(D, { size: 16 })
      }
    ),
    /* @__PURE__ */ e($, { title: /* @__PURE__ */ e("div", { children: d }), placement: "right", arrow: !0, children: /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(B, { color: "gray", size: 16 }) }) })
  ] });
  return /* @__PURE__ */ t("div", { style: { width: 350 }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #a5d6a7", borderRadius: 8, background: "#fff", overflow: "hidden" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "12px 14px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e(
            "div",
            {
              style: {
                width: 28,
                height: 28,
                borderRadius: 6,
                background: "rgba(76,175,80,0.1)",
                display: "flex",
                alignItems: "center",
                justifyContent: "center",
                flexShrink: 0
              },
              children: /* @__PURE__ */ e(fe, { size: 16, color: "#388e3c" })
            }
          ),
          /* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 500, color: "#212121" }, children: g })
        ] }),
        /* @__PURE__ */ e("div", { className: "ff-d-flex ff-align-items-center", children: S })
      ] }),
      /* @__PURE__ */ e(
        "div",
        {
          style: {
            background: "#f5f5f5",
            fontSize: 12,
            color: "#212121",
            padding: "14px 16px",
            margin: "0 10px 12px",
            borderRadius: 6,
            textAlign: "left"
          },
          children: s
        }
      )
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 }, id: "1" })
  ] });
};
function he(n) {
  return n ? n.replace(/[_-]+/g, " ").replace(/\b\w/g, (i) => i.toUpperCase()) : "";
}
function Oe(n) {
  if (typeof n != "string" && n.label) return n.label;
  const i = typeof n == "string" ? n : n.value ?? "";
  return he(i);
}
const Ue = ({ data: n }) => {
  const {
    header: i = "Event",
    title: f,
    eventType: p,
    sources: c,
    executionStatus: r,
    infoText: h = "This event is raised by the system. It cannot be configured."
  } = n ?? {}, o = f || he(p) || "—";
  return /* @__PURE__ */ t("div", { style: { width: 350 }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #a5d6a7", borderRadius: 8, background: "#fff", overflow: "hidden" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "12px 14px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e(
            "div",
            {
              style: {
                width: 28,
                height: 28,
                borderRadius: 6,
                background: "rgba(76,175,80,0.1)",
                display: "flex",
                alignItems: "center",
                justifyContent: "center",
                flexShrink: 0
              },
              children: /* @__PURE__ */ e(fe, { size: 16, color: "#388e3c" })
            }
          ),
          /* @__PURE__ */ e("span", { style: { fontSize: 14, fontWeight: 500, color: "#212121" }, children: i })
        ] }),
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center", children: [
          (r == null ? void 0 : r.status) === "success" && /* @__PURE__ */ e(ae, { size: 16, color: "#1DBF60", style: { marginRight: 8 } }),
          (r == null ? void 0 : r.status) === "failed" && /* @__PURE__ */ e(pe, { size: 16, color: "#f44336", style: { marginRight: 8 } }),
          !r && /* @__PURE__ */ e($, { title: /* @__PURE__ */ e("div", { children: h }), placement: "right", arrow: !0, children: /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(B, { color: "gray", size: 16 }) }) })
        ] })
      ] }),
      /* @__PURE__ */ t(
        "div",
        {
          style: {
            background: "#f5f5f5",
            fontSize: 13,
            color: "#212121",
            padding: "14px 16px",
            margin: "0 10px 12px",
            borderRadius: 6,
            textAlign: "left"
          },
          children: [
            /* @__PURE__ */ e("div", { style: { fontWeight: 600 }, children: o }),
            Array.isArray(c) && c.length > 0 && /* @__PURE__ */ t(j, { children: [
              /* @__PURE__ */ e("div", { className: "ff-text-muted", style: { fontSize: 12, marginTop: 4 }, children: "via" }),
              /* @__PURE__ */ e("div", { className: "ff-d-flex ff-flex-wrap ff-mt-1", style: { gap: 4 }, children: c.map((l, d) => /* @__PURE__ */ e(
                q,
                {
                  label: Oe(l),
                  variant: "outlined",
                  size: "small",
                  className: "ff-text-dark"
                },
                d
              )) })
            ] })
          ]
        }
      )
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 }, id: "1" })
  ] });
}, ye = ({ rail: n, cardWidth: i }) => {
  const f = i / 2;
  i / 2 + n.indent;
  const p = "var(--ff-edge-color, #b0bec5)";
  return /* @__PURE__ */ t(
    "svg",
    {
      width: i + n.indent + 200,
      height: n.height,
      style: { position: "absolute", left: 0, top: "100%", pointerEvents: "none", overflow: "visible" },
      children: [
        /* @__PURE__ */ e("line", { x1: f, y1: 0, x2: f, y2: n.height, stroke: p, strokeWidth: 1.5 }),
        n.branches.map((c, r) => {
          const h = c.y;
          return /* @__PURE__ */ t("g", { transform: `translate(0, ${h})`, children: [
            /* @__PURE__ */ e(
              "rect",
              {
                x: f - 5,
                y: -5,
                width: 10,
                height: 10,
                fill: "#fff",
                stroke: p,
                strokeWidth: 1.5,
                transform: `rotate(45, ${f}, 0)`
              }
            ),
            /* @__PURE__ */ e(
              "text",
              {
                x: f + 14,
                y: 4,
                fontSize: 12,
                fontWeight: 500,
                fill: "var(--ff-text, #212121)",
                style: { fontFamily: "sans-serif" },
                children: c.label
              }
            )
          ] }, r);
        })
      ]
    }
  );
}, Ve = ({ id: n, data: i }) => {
  const { onEditNode: f, onDeleteNode: p } = P(), { conditions: c = [], infoText: r = "Filter conditions applied to workflow data", _branchRail: h } = i;
  return /* @__PURE__ */ t("div", { style: { width: 350, position: "relative" }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #ffe082", borderRadius: 8, background: "#fff" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "10px 6px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center", children: [
          /* @__PURE__ */ e("div", { className: "ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded", style: { width: 25, height: 25, background: "rgba(255,160,0,0.1)" }, children: /* @__PURE__ */ e(We, { className: "ff-text-warning", size: 16 }) }),
          /* @__PURE__ */ e("span", { className: "ff-ms-2 ff-fw-medium ff-text-dark", style: { fontSize: 14 }, children: "Filter" })
        ] }),
        /* @__PURE__ */ t("div", { className: "node-actions ff-d-flex ff-align-items-center", children: [
          /* @__PURE__ */ e(
            "div",
            {
              role: "button",
              tabIndex: 0,
              onClick: (o) => {
                o.stopPropagation(), f(n);
              },
              onKeyDown: (o) => {
                o.key === "Enter" && (o.stopPropagation(), f(n));
              },
              children: /* @__PURE__ */ e(D, { size: 16 })
            }
          ),
          /* @__PURE__ */ e(
            "div",
            {
              className: "ff-ms-2",
              role: "button",
              tabIndex: 0,
              onClick: (o) => {
                o.stopPropagation(), p(n);
              },
              onKeyDown: (o) => {
                o.key === "Enter" && (o.stopPropagation(), p(n));
              },
              children: /* @__PURE__ */ e(F, { color: "red", size: 16 })
            }
          ),
          /* @__PURE__ */ e($, { title: r, placement: "right", arrow: !0, children: /* @__PURE__ */ e("div", { className: "ff-ms-2", children: /* @__PURE__ */ e(B, { color: "gray", size: 16 }) }) })
        ] })
      ] }),
      /* @__PURE__ */ e("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: "#fafafa", fontSize: 12 }, children: c.length === 0 ? /* @__PURE__ */ e("span", { className: "ff-text-muted", children: "No conditions configured" }) : c.map((o, l) => /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-mb-1", children: [
        /* @__PURE__ */ e("p", { className: "ff-m-0 ff-fw-bold ff-me-1 ff-text-truncate", style: { maxWidth: 100 }, title: o.field, children: o.field }),
        /* @__PURE__ */ e("span", { className: "ff-text-muted", children: o.operator }),
        /* @__PURE__ */ e("p", { className: "ff-text-dark ff-text-truncate ff-mx-1 ff-m-0", title: o.value, children: o.value }),
        l < c.length - 1 && /* @__PURE__ */ e("p", { className: "ff-bg-primary ff-text-white ff-fw-bold ff-ms-1 ff-px-1 ff-rounded-1 ff-m-0", children: o.logicalOperator })
      ] }, l)) })
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } }),
    h && /* @__PURE__ */ e(ye, { rail: h, cardWidth: 350 })
  ] });
}, Ge = ({ id: n, data: i }) => {
  const { onEditNode: f, onDeleteNode: p, nodeRegistry: c, nodeBody: r = "full" } = P(), { title: h = "Task", descriptorType: o, groupBlocks: l, groups: d, roles: u, groupId: y, roleId: k, infoText: g = "" } = i, s = o ? c == null ? void 0 : c.forType(o) : void 0, S = s == null ? void 0 : s.icon, m = (a) => a == null ? "" : typeof a == "string" ? a : typeof a == "object" && "label" in a ? String(a.label) : String(a), C = (a) => Array.isArray(a) ? a.map(m).filter(Boolean) : a != null && a !== "" ? [m(a)] : [], v = /* @__PURE__ */ new Set([
    "descriptorType",
    "title",
    "header",
    "icon",
    "infoText",
    "label",
    "conditionConfig",
    "_conditionConfig"
  ]), L = s == null ? void 0 : s.formSchema, E = (a) => {
    if (Array.isArray(L)) {
      const b = L.find((w) => (w == null ? void 0 : w.id) === a || (w == null ? void 0 : w.name) === a);
      if (b != null && b.label) return b.label;
    }
    return a.replace(/[_-]+/g, " ").replace(/\b\w/g, (b) => b.toUpperCase());
  }, A = (a) => {
    if (Array.isArray(a)) {
      const b = a.map(
        (W) => typeof W == "object" && W ? W.label ?? W.name ?? W.value ?? "" : String(W)
      ).filter(Boolean), w = b.slice(0, 3).join(", ");
      return b.length > 3 ? `${w} +${b.length - 3}` : w;
    }
    if (a && typeof a == "object") {
      const b = a;
      return b.label ?? b.name ?? b.value ?? JSON.stringify(a);
    }
    return String(a);
  }, I = Object.entries(i || {}).filter(
    ([a, b]) => !v.has(a) && b !== "" && b !== null && b !== void 0 && !(Array.isArray(b) && b.length === 0)
  ), z = (i == null ? void 0 : i.conditionConfig) ?? (i == null ? void 0 : i._conditionConfig), T = z && typeof z == "object" ? Object.entries(z).filter(([, a]) => Array.isArray(a) && a.length > 0).map(([a, b]) => ({
    path: a,
    entries: b
  })) : [], R = (l == null ? void 0 : l.flatMap((a) => a.groups ?? [])) ?? [...C(d), ...C(u), ...C(y), ...C(k)], G = R.length > 0;
  return /* @__PURE__ */ t("div", { style: { width: 350 }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #b0bec5", borderRadius: 8, background: "#fff" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "10px 6px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          S && /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center" }, children: S }),
          /* @__PURE__ */ e("span", { className: "ff-text-dark", style: { fontSize: 14, fontWeight: 500 }, children: h })
        ] }),
        /* @__PURE__ */ t("div", { className: "node-actions ff-d-flex ff-align-items-center", children: [
          /* @__PURE__ */ e(
            "div",
            {
              role: "button",
              tabIndex: 0,
              onClick: (a) => {
                a.stopPropagation(), f(n);
              },
              onKeyDown: (a) => {
                a.key === "Enter" && (a.stopPropagation(), f(n));
              },
              children: /* @__PURE__ */ e(D, { size: 16 })
            }
          ),
          /* @__PURE__ */ e(
            "div",
            {
              className: "ff-ms-2",
              role: "button",
              tabIndex: 0,
              onClick: (a) => {
                a.stopPropagation(), p(n);
              },
              onKeyDown: (a) => {
                a.key === "Enter" && (a.stopPropagation(), p(n));
              },
              children: /* @__PURE__ */ e(F, { color: "red", size: 16 })
            }
          ),
          g && /* @__PURE__ */ e($, { title: g, placement: "right", arrow: !0, children: /* @__PURE__ */ e("div", { className: "ff-ms-2", children: /* @__PURE__ */ e(B, { color: "gray", size: 16 }) }) })
        ] })
      ] }),
      r !== "title-only" && /* @__PURE__ */ e(
        "div",
        {
          style: {
            margin: "0 8px 8px",
            padding: 8,
            borderRadius: 4,
            background: "#f8f9fa",
            fontSize: 12,
            textAlign: "left",
            color: "#212529",
            lineHeight: 1.4
          },
          children: s != null && s.renderNode ? s.renderNode(i) : I.length > 0 || T.length > 0 ? /* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column" }, children: [
            T.map((a, b) => /* @__PURE__ */ t("div", { children: [
              /* @__PURE__ */ e("div", { style: { color: "#6c757d" }, children: "When" }),
              a.entries.slice(0, 3).map((w, W, ue) => {
                const me = w.field || "", be = w.fieldLabel || E(me), xe = w.operator || "", Z = w.value == null ? "" : typeof w.value == "object" ? A(w.value) : String(w.value), Ne = w.connector || "and";
                return /* @__PURE__ */ t(
                  "div",
                  {
                    style: {
                      display: "flex",
                      alignItems: "center",
                      flexWrap: "wrap",
                      marginTop: 4
                    },
                    children: [
                      /* @__PURE__ */ e("span", { style: { fontWeight: 700, marginRight: 4, color: "#212529" }, children: be }),
                      /* @__PURE__ */ e("span", { style: { color: "#6c757d", marginRight: 4 }, children: xe }),
                      /* @__PURE__ */ e("span", { style: { color: "#212529", marginRight: 4 }, title: Z, children: Z }),
                      W < ue.length - 1 && /* @__PURE__ */ e(
                        "span",
                        {
                          style: {
                            background: "#0d6efd",
                            color: "#fff",
                            fontWeight: 700,
                            marginLeft: 4,
                            padding: "0 4px",
                            borderRadius: 2,
                            textTransform: "uppercase",
                            fontSize: 10
                          },
                          children: Ne
                        }
                      )
                    ]
                  },
                  W
                );
              }),
              a.entries.length > 3 && /* @__PURE__ */ t("div", { style: { color: "#6c757d", fontSize: 11, marginTop: 2 }, children: [
                "+",
                a.entries.length - 3,
                " more"
              ] })
            ] }, `cond-${b}`)),
            I.length > 0 && /* @__PURE__ */ e(
              "div",
              {
                style: {
                  marginTop: 4,
                  color: "#212529",
                  display: "flex",
                  justifyContent: "flex-start"
                },
                children: (s == null ? void 0 : s.label) || h
              }
            ),
            I.length > 0 && /* @__PURE__ */ t("div", { style: { display: "flex", flexWrap: "wrap", gap: 4, marginTop: 4 }, children: [
              I.slice(0, 6).map(([a, b]) => /* @__PURE__ */ e(
                "span",
                {
                  title: `${E(a)}: ${A(b)}`,
                  style: {
                    background: "#212529",
                    color: "#fff",
                    padding: "4px 8px",
                    borderRadius: 4,
                    fontSize: 11
                  },
                  children: A(b)
                },
                a
              )),
              I.length > 6 && /* @__PURE__ */ t("span", { style: { color: "#6c757d", fontSize: 11, alignSelf: "center" }, children: [
                "+",
                I.length - 6
              ] })
            ] })
          ] }) : G ? (
            // Legacy display fallback: dark badges for old-shape data
            // (groupBlocks/groups/roles/groupId/roleId on the slot)
            /* @__PURE__ */ e("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: R.map((a, b) => /* @__PURE__ */ e(
              "span",
              {
                title: a,
                style: {
                  background: "#212529",
                  color: "#fff",
                  padding: "4px 8px",
                  borderRadius: 4,
                  fontSize: 11
                },
                children: a
              },
              b
            )) })
          ) : /* @__PURE__ */ e("span", { style: { color: "#6c757d" }, children: "Click edit to configure" })
        }
      )
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } })
  ] });
}, J = 5, qe = ({ id: n, data: i }) => {
  const { onEditNode: f, onDeleteNode: p } = P(), { approvalData: c, isPreview: r = !1, _branchRail: h } = i, o = (c == null ? void 0 : c.policy) ?? {}, l = o.stages ?? [], d = l.length, u = l.slice(0, J), y = d - J, k = o.name ?? o.policyName ?? "Untitled Policy";
  return /* @__PURE__ */ t("div", { style: { width: 350, position: "relative" }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #ffe082", borderRadius: 8, background: "#fff" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "10px 6px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e("div", { className: "ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded", style: { width: 25, height: 25, background: "rgba(251,192,45,0.2)" }, children: /* @__PURE__ */ e(Ce, { style: { color: "#FBC02D" }, size: 16 }) }),
          /* @__PURE__ */ e("span", { className: "ff-fw-medium ff-text-dark", style: { fontSize: 14 }, children: "Approval Policy" })
        ] }),
        /* @__PURE__ */ t("div", { className: "node-actions ff-d-flex ff-align-items-center", children: [
          !r && /* @__PURE__ */ e(
            "div",
            {
              role: "button",
              tabIndex: 0,
              style: { cursor: "pointer" },
              onClick: (g) => {
                g.stopPropagation(), f(n);
              },
              onKeyDown: (g) => {
                g.key === "Enter" && (g.stopPropagation(), f(n));
              },
              children: /* @__PURE__ */ e(D, { size: 16, className: "ff-text-secondary" })
            }
          ),
          !r && /* @__PURE__ */ e(
            "div",
            {
              className: "ff-ms-2",
              role: "button",
              tabIndex: 0,
              style: { cursor: "pointer" },
              onClick: (g) => {
                g.stopPropagation(), p(n);
              },
              onKeyDown: (g) => {
                g.key === "Enter" && (g.stopPropagation(), p(n));
              },
              children: /* @__PURE__ */ e(F, { color: "red", size: 16 })
            }
          ),
          /* @__PURE__ */ e($, { title: "This approval policy determines who must approve a request before the workflow continues.", arrow: !0, placement: "right", children: /* @__PURE__ */ e("span", { className: "ff-ms-2 ff-d-inline-flex", children: /* @__PURE__ */ e(B, { color: "gray", size: 16 }) }) })
        ] })
      ] }),
      /* @__PURE__ */ t("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: "#FCFCFC" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-start ff-align-items-center ff-mb-2", children: [
          /* @__PURE__ */ e("h6", { className: "ff-text-dark ff-mb-0 ff-text-truncate ff-flex-grow-1 ff-me-2", style: { fontSize: 13, fontWeight: 700 }, title: k, children: k }),
          /* @__PURE__ */ t("span", { className: "ff-badge ff-rounded-pill ff-px-2 ff-py-1 ff-flex-shrink-0", style: { background: "#FFF9C4", color: "#616161", fontSize: 11, fontWeight: 600 }, children: [
            d,
            " Stage",
            d !== 1 ? "s" : ""
          ] })
        ] }),
        l.length > 0 ? /* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
          u.map((g, s) => {
            var A, I, z;
            const S = ((A = g.stageName) == null ? void 0 : A.trim()) || `Stage ${s + 1}`, m = Array.isArray(g.userIds) ? g.userIds.length : 0, C = ((I = g.groupName) == null ? void 0 : I.trim()) ?? "", v = ((z = g.roleName) == null ? void 0 : z.trim()) ?? "", L = m > 0 || C || v;
            let E = "Not configured";
            return C ? E = `Group: ${C}` : v ? E = `Role: ${v}` : m > 0 && (E = `${m} approver${m !== 1 ? "s" : ""}`), /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
              /* @__PURE__ */ e("div", { className: "ff-rounded-circle ff-d-flex ff-align-items-center ff-justify-content-center ff-flex-shrink-0", style: { width: 28, height: 28, background: "#FFF9C4", color: "#5D4037", fontSize: 12, fontWeight: 700 }, children: s + 1 }),
              /* @__PURE__ */ t("div", { className: "ff-flex-grow-1 ff-rounded ff-p-2 ff-d-flex ff-justify-content-between ff-align-items-center ff-border", style: { background: "#FFFDE7", borderColor: "#FEE79A" }, children: [
                /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 700, color: "#212121" }, children: S }),
                /* @__PURE__ */ t("span", { className: `ff-d-flex ff-align-items-center ff-gap-1 ${L ? "ff-text-dark" : "ff-text-muted"}`, style: { fontSize: 12 }, children: [
                  /* @__PURE__ */ e(Te, { size: 16, className: "ff-flex-shrink-0", style: { color: L ? "#5D4037" : "#9E9E9E" } }),
                  E
                ] })
              ] })
            ] }, s);
          }),
          y > 0 && /* @__PURE__ */ t(
            "div",
            {
              className: "ff-text-center ff-fw-bold ff-py-2 ff-border ff-rounded",
              style: { fontSize: 11, color: "#1976d2", borderColor: "#FEE79A", background: "#FFFDE7", borderStyle: "dashed", cursor: r ? "default" : "pointer" },
              role: r ? void 0 : "button",
              tabIndex: r ? void 0 : 0,
              onClick: (g) => {
                r || (g.stopPropagation(), f(n));
              },
              onKeyDown: (g) => {
                r || g.key !== "Enter" || (g.stopPropagation(), f(n));
              },
              children: [
                "+ ",
                y,
                " More Stage",
                y > 1 ? "s" : ""
              ]
            }
          )
        ] }) : /* @__PURE__ */ e("div", { className: "ff-text-center ff-py-3 ff-rounded ff-border", style: { fontSize: 12, color: "#9e9e9e", background: "#FFFDE7", borderColor: "#FEE79A", borderStyle: "dashed" }, children: "No stages configured" })
      ] })
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } }),
    h && /* @__PURE__ */ e(ye, { rail: h, cardWidth: 350 })
  ] });
}, Ze = ({ id: n, data: i }) => {
  const { onEditNode: f, onDeleteNode: p } = P(), { duration: c, unit: r } = i, h = c != null && r, o = h ? `Wait ${c} ${r}` : "Not configured";
  return /* @__PURE__ */ t("div", { style: { width: 350 }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #b0bec5", borderRadius: 8, background: "#fff" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1", children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e("div", { className: "ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded", style: { width: 25, height: 25, background: "rgba(33,150,243,0.1)" }, children: /* @__PURE__ */ e(Ee, { size: 16, color: "#1976d2" }) }),
          /* @__PURE__ */ e("span", { className: "ff-fw-medium ff-text-dark", style: { fontSize: 14 }, children: "Delay" })
        ] }),
        /* @__PURE__ */ t("div", { className: "node-actions ff-d-flex ff-align-items-center", children: [
          /* @__PURE__ */ e(
            "div",
            {
              role: "button",
              tabIndex: 0,
              onClick: (l) => {
                l.stopPropagation(), f(n);
              },
              onKeyDown: (l) => {
                l.key === "Enter" && (l.stopPropagation(), f(n));
              },
              children: /* @__PURE__ */ e(D, { size: 16 })
            }
          ),
          /* @__PURE__ */ e(
            "div",
            {
              className: "ff-ms-2",
              role: "button",
              tabIndex: 0,
              onClick: (l) => {
                l.stopPropagation(), p(n);
              },
              onKeyDown: (l) => {
                l.key === "Enter" && (l.stopPropagation(), p(n));
              },
              children: /* @__PURE__ */ e(F, { color: "red", size: 16 })
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ e("div", { className: "ff-mx-2 ff-mb-2 ff-p-2 ff-rounded", style: { background: "#fafafa", fontSize: 12 }, children: /* @__PURE__ */ e("span", { className: h ? "ff-text-dark ff-fw-medium" : "ff-text-muted", children: o }) })
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } })
  ] });
}, Q = {
  email: { label: "Email", bg: "#e3f2fd", color: "#1565c0", iconType: Ie },
  slack: { label: "Slack", bg: "#e8f5e9", color: "#2e7d32", iconType: O },
  teams: { label: "MS Teams", bg: "#ede7f6", color: "#4527a0", iconType: O },
  sms: { label: "SMS", bg: "#fce4ec", color: "#880e4f", iconType: ze },
  "in-app": { label: "In-App", bg: "#fff3e0", color: "#e65100", iconType: O },
  webhook: { label: "Webhook", bg: "#f3e5f5", color: "#6a1b9a", iconType: de }
}, Ye = {
  label: "Notification",
  bg: "rgba(156,39,176,0.1)",
  color: "#7b1fa2",
  iconType: O
};
function Je(n) {
  var i;
  switch (n.channel) {
    case "email":
      return ((i = n.emailTo) == null ? void 0 : i.join(", ")) ?? n.recipient ?? null;
    case "slack":
      return n.slackChannel ?? null;
    case "teams":
      return n.teamsMessage ? "Message configured" : null;
    case "sms":
      return n.smsTo ?? null;
    case "in-app":
      return n.inAppRecipient ?? null;
    case "webhook":
      return n.webhookUrl ?? null;
    default:
      return n.recipient ?? null;
  }
}
function Qe(n) {
  switch (n.channel) {
    case "email":
      return n.emailSubject ?? n.subject ?? null;
    case "slack": {
      const i = n.slackMessage;
      return i ? i.length > 60 ? `${i.slice(0, 60)}…` : i : null;
    }
    case "in-app":
      return n.inAppTitle ?? null;
    default:
      return n.subject ?? null;
  }
}
const Xe = ({ id: n, data: i }) => {
  const { onEditNode: f, onDeleteNode: p } = P(), c = i, r = c.channel && Q[c.channel] ? Q[c.channel] : Ye, h = Je(c), o = Qe(c), l = !!(c.channel && h), d = r.iconType;
  return /* @__PURE__ */ t("div", { style: { width: K }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #b0bec5", borderRadius: 8, background: "#fff" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "10px 6px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e("div", { className: "ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded", style: { width: 25, height: 25, background: r.bg }, children: /* @__PURE__ */ e(d, { size: 16, color: r.color }) }),
          /* @__PURE__ */ e("span", { className: "ff-fw-medium ff-text-dark", style: { fontSize: 14 }, children: c.channel ? `${r.label} Notification` : "Notification" })
        ] }),
        /* @__PURE__ */ t("div", { className: "node-actions ff-d-flex ff-align-items-center", children: [
          /* @__PURE__ */ e(
            "div",
            {
              role: "button",
              tabIndex: 0,
              onClick: (u) => {
                u.stopPropagation(), f(n);
              },
              onKeyDown: (u) => {
                (u.key === "Enter" || u.key === " ") && (u.stopPropagation(), f(n));
              },
              children: /* @__PURE__ */ e(D, { size: 16 })
            }
          ),
          /* @__PURE__ */ e(
            "div",
            {
              className: "ff-ms-2",
              role: "button",
              tabIndex: 0,
              onClick: (u) => {
                u.stopPropagation(), p(n);
              },
              onKeyDown: (u) => {
                (u.key === "Enter" || u.key === " ") && (u.stopPropagation(), p(n));
              },
              children: /* @__PURE__ */ e(F, { color: "red", size: 16 })
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ e("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: "#fafafa", fontSize: 12 }, children: l ? /* @__PURE__ */ t("div", { className: "ff-d-flex ff-flex-column ff-gap-1", children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e("span", { className: "ff-px-2 ff-py-1 ff-rounded", style: { fontSize: 10, background: r.bg, color: r.color, fontWeight: 600, flexShrink: 0 }, children: r.label }),
          /* @__PURE__ */ e("span", { className: "ff-text-dark ff-text-truncate", style: { maxWidth: 220 }, children: h })
        ] }),
        o && /* @__PURE__ */ e("span", { className: "ff-text-muted ff-text-truncate", style: { maxWidth: 280 }, children: o })
      ] }) : /* @__PURE__ */ e("span", { className: "ff-text-muted", children: "Not configured" }) })
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } })
  ] });
}, X = {
  "api-key": "API Key",
  hmac: "HMAC"
}, et = ({ data: n }) => {
  const { onClickAddTrigger: i } = P(), { label: f = "Webhook Trigger", endpointUrl: p, authMethod: c, source: r } = n, h = (l) => {
    l.stopPropagation(), i();
  }, o = (l) => {
    l.stopPropagation(), p && navigator.clipboard.writeText(p).catch(() => {
    });
  };
  return /* @__PURE__ */ t("div", { style: { width: K }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #90caf9", borderRadius: 8, background: "#fff", overflow: "hidden" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "10px 6px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e("div", { style: { width: 28, height: 28, borderRadius: 6, background: "rgba(33,150,243,0.1)", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0 }, children: /* @__PURE__ */ e(de, { size: 16, color: "#1565c0" }) }),
          /* @__PURE__ */ e("span", { style: { fontSize: 13, fontWeight: 600, color: "#212121" }, children: "Webhook Trigger" })
        ] }),
        /* @__PURE__ */ e(
          "div",
          {
            role: "button",
            tabIndex: 0,
            onClick: h,
            onKeyDown: (l) => {
              (l.key === "Enter" || l.key === " ") && h(l);
            },
            className: "ff-d-flex ff-align-items-center",
            style: { paddingRight: 4, cursor: "pointer" },
            children: /* @__PURE__ */ e(D, { size: 16, color: "#555" })
          }
        )
      ] }),
      /* @__PURE__ */ t("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: "#e3f2fd", border: "1px solid #90caf9" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-flex-wrap ff-gap-2 ff-mb-1", children: [
          /* @__PURE__ */ e("span", { style: { fontSize: 12, color: "#1565c0", fontWeight: 600 }, children: f }),
          r && /* @__PURE__ */ e("span", { className: "ff-px-2 ff-py-1 ff-rounded", style: { fontSize: 11, background: "#fff", border: "1px solid #90caf9", color: "#1565c0" }, children: r }),
          c && c !== "none" && X[c] && /* @__PURE__ */ e("span", { className: "ff-px-2 ff-py-1 ff-rounded", style: { fontSize: 10, background: "#1565c0", color: "#fff", fontWeight: 600 }, children: X[c] })
        ] }),
        p && /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-1", style: { marginTop: 4 }, children: [
          /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "#1565c0", fontFamily: "monospace", flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: p }),
          /* @__PURE__ */ e($, { title: "Copy URL", placement: "top", arrow: !0, children: /* @__PURE__ */ e(
            "div",
            {
              role: "button",
              tabIndex: 0,
              onClick: o,
              onKeyDown: (l) => {
                (l.key === "Enter" || l.key === " ") && o(l);
              },
              style: { cursor: "pointer", flexShrink: 0 },
              children: /* @__PURE__ */ e(Pe, { size: 12, color: "#1565c0" })
            }
          ) })
        ] })
      ] })
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } })
  ] });
}, tt = ({ id: n, data: i }) => {
  var k;
  const { onEditNode: f, onDeleteNode: p, nodeRegistry: c } = P(), { method: r, url: h, descriptorType: o } = i, l = o ? (k = c == null ? void 0 : c.forType(o)) == null ? void 0 : k.icon : /* @__PURE__ */ e(Ae, { size: 16, color: "#546e7a" }), d = !!(r && h), u = (r == null ? void 0 : r.toUpperCase()) ?? "", y = Fe[u] ?? null;
  return /* @__PURE__ */ t("div", { style: { width: K }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #b0bec5", borderRadius: 8, background: "#fff" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "10px 6px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e("div", { style: { width: 25, height: 25, display: "flex", alignItems: "center", justifyContent: "center" }, children: l }),
          /* @__PURE__ */ e("span", { className: "ff-fw-medium ff-text-dark", style: { fontSize: 14 }, children: "REST API Call" })
        ] }),
        /* @__PURE__ */ t("div", { className: "node-actions ff-d-flex ff-align-items-center", children: [
          /* @__PURE__ */ e(
            "div",
            {
              role: "button",
              tabIndex: 0,
              onClick: (g) => {
                g.stopPropagation(), f(n);
              },
              onKeyDown: (g) => {
                (g.key === "Enter" || g.key === " ") && (g.stopPropagation(), f(n));
              },
              children: /* @__PURE__ */ e(D, { size: 16 })
            }
          ),
          /* @__PURE__ */ e(
            "div",
            {
              className: "ff-ms-2",
              role: "button",
              tabIndex: 0,
              onClick: (g) => {
                g.stopPropagation(), p(n);
              },
              onKeyDown: (g) => {
                (g.key === "Enter" || g.key === " ") && (g.stopPropagation(), p(n));
              },
              children: /* @__PURE__ */ e(F, { color: "red", size: 16 })
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ e("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: "#fafafa", fontSize: 12 }, children: d ? /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
        y && /* @__PURE__ */ e("span", { style: { fontSize: 10, fontWeight: 700, padding: "2px 6px", borderRadius: 4, background: y.bg, color: y.color, flexShrink: 0 }, children: u }),
        /* @__PURE__ */ e("span", { className: "ff-text-dark ff-text-truncate", style: { fontFamily: "monospace", fontSize: 11 }, title: h, children: h })
      ] }) : /* @__PURE__ */ e("span", { className: "ff-text-muted", children: "Not configured" }) })
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } })
  ] });
}, nt = {
  eq: "=",
  neq: "≠",
  gt: ">",
  gte: "≥",
  lt: "<",
  lte: "≤",
  contains: "contains",
  startsWith: "starts with",
  endsWith: "ends with",
  isEmpty: "is empty",
  isNotEmpty: "is not empty"
}, ot = ({ id: n, data: i }) => {
  const { onEditNode: f, onDeleteNode: p } = P(), { title: c = "Condition Branch", branchConfigs: r = [], defaultBranch: h } = i, o = r.length > 0;
  return /* @__PURE__ */ t("div", { style: { width: K }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #b39ddb", borderRadius: 8, background: "#fff" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "10px 6px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e("div", { style: { width: 25, height: 25, borderRadius: 6, background: "rgba(103,58,183,0.1)", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(De, { size: 16, color: "#512da8" }) }),
          /* @__PURE__ */ e("span", { className: "ff-fw-medium ff-text-dark", style: { fontSize: 14 }, children: c })
        ] }),
        /* @__PURE__ */ t("div", { className: "node-actions ff-d-flex ff-align-items-center", children: [
          /* @__PURE__ */ e(
            "div",
            {
              role: "button",
              tabIndex: 0,
              onClick: (l) => {
                l.stopPropagation(), f(n);
              },
              onKeyDown: (l) => {
                (l.key === "Enter" || l.key === " ") && (l.stopPropagation(), f(n));
              },
              children: /* @__PURE__ */ e(D, { size: 16 })
            }
          ),
          /* @__PURE__ */ e(
            "div",
            {
              className: "ff-ms-2",
              role: "button",
              tabIndex: 0,
              onClick: (l) => {
                l.stopPropagation(), p(n);
              },
              onKeyDown: (l) => {
                (l.key === "Enter" || l.key === " ") && (l.stopPropagation(), p(n));
              },
              children: /* @__PURE__ */ e(F, { color: "red", size: 16 })
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ e("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: "#fafafa", fontSize: 12 }, children: o ? /* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
        r.map((l, d) => {
          var g, s;
          const u = Y[d % Y.length], y = (g = l.conditions) == null ? void 0 : g[0], k = (((s = l.conditions) == null ? void 0 : s.length) ?? 0) - 1;
          return /* @__PURE__ */ t("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
            /* @__PURE__ */ e("span", { style: { fontSize: 10, fontWeight: 600, padding: "2px 7px", borderRadius: 10, background: u.bg, color: u.color, flexShrink: 0 }, children: l.label || l.key }),
            y ? /* @__PURE__ */ t("span", { style: { fontSize: 11, color: "#616161", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
              y.field,
              " ",
              nt[y.operator] ?? y.operator,
              y.value ? ` ${y.value}` : "",
              k > 0 ? ` +${k} more` : ""
            ] }) : /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#9e9e9e" }, children: "No conditions yet" })
          ] }, l.key);
        }),
        h && /* @__PURE__ */ t("div", { style: { display: "flex", alignItems: "center", gap: 6, marginTop: 2 }, children: [
          /* @__PURE__ */ e("span", { style: { fontSize: 10, fontWeight: 600, padding: "2px 7px", borderRadius: 10, background: "#f5f5f5", color: "#757575", flexShrink: 0 }, children: "Default" }),
          /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#9e9e9e" }, children: "fallback path" })
        ] })
      ] }) : /* @__PURE__ */ e("span", { className: "ff-text-muted", children: "Not configured — click edit to add branches" }) })
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } })
  ] });
}, it = ({ id: n, data: i }) => {
  var g;
  const { onEditNode: f, onDeleteNode: p, nodeRegistry: c } = P(), { title: r = "Sub-Workflow", workflowId: h, workflowLabel: o, descriptorType: l, onPreview: d } = i, u = l ? (g = c == null ? void 0 : c.forType(l)) == null ? void 0 : g.icon : /* @__PURE__ */ e(Le, { size: 16, color: "#00695c" }), y = !!h, k = (s) => {
    s.stopPropagation(), h && d && d(h);
  };
  return /* @__PURE__ */ t("div", { style: { width: K }, children: [
    /* @__PURE__ */ e(x, { type: "target", position: N.Top, style: { opacity: 0 } }),
    /* @__PURE__ */ t("div", { style: { border: "1.5px solid #80cbc4", borderRadius: 8, background: "#fff" }, children: [
      /* @__PURE__ */ t("div", { className: "ff-d-flex ff-justify-content-between ff-align-items-center", style: { padding: "10px 6px" }, children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-gap-2", children: [
          /* @__PURE__ */ e("div", { style: { width: 25, height: 25, borderRadius: 6, background: "rgba(0,137,123,0.1)", display: "flex", alignItems: "center", justifyContent: "center" }, children: u }),
          /* @__PURE__ */ e("span", { className: "ff-fw-medium ff-text-dark", style: { fontSize: 14 }, children: r })
        ] }),
        /* @__PURE__ */ t("div", { className: "node-actions ff-d-flex ff-align-items-center", children: [
          /* @__PURE__ */ e(
            "div",
            {
              role: "button",
              tabIndex: 0,
              onClick: (s) => {
                s.stopPropagation(), f(n);
              },
              onKeyDown: (s) => {
                (s.key === "Enter" || s.key === " ") && (s.stopPropagation(), f(n));
              },
              children: /* @__PURE__ */ e(D, { size: 16 })
            }
          ),
          /* @__PURE__ */ e(
            "div",
            {
              className: "ff-ms-2",
              role: "button",
              tabIndex: 0,
              onClick: (s) => {
                s.stopPropagation(), p(n);
              },
              onKeyDown: (s) => {
                (s.key === "Enter" || s.key === " ") && (s.stopPropagation(), p(n));
              },
              children: /* @__PURE__ */ e(F, { color: "red", size: 16 })
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ e("div", { style: { margin: "0 6px 10px", padding: "10px 12px", borderRadius: 6, background: y ? "#e0f2f1" : "#fafafa", fontSize: 12, border: y ? "1px solid #b2dfdb" : "none" }, children: y ? /* @__PURE__ */ t("div", { className: "ff-d-flex ff-align-items-center ff-justify-content-between", children: [
        /* @__PURE__ */ t("div", { className: "ff-d-flex ff-flex-column ff-gap-1", children: [
          /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 600, color: "#00695c" }, children: o || h }),
          /* @__PURE__ */ t("span", { style: { fontSize: 10, color: "#80cbc4", fontFamily: "monospace" }, children: [
            "ID: ",
            h
          ] })
        ] }),
        d && /* @__PURE__ */ t(
          "div",
          {
            role: "button",
            tabIndex: 0,
            onClick: k,
            onKeyDown: (s) => {
              (s.key === "Enter" || s.key === " ") && k(s);
            },
            style: { cursor: "pointer", display: "flex", alignItems: "center", gap: 3, fontSize: 11, color: "#00897b" },
            children: [
              /* @__PURE__ */ e(Re, { size: 13 }),
              "Preview"
            ]
          }
        )
      ] }) : /* @__PURE__ */ e("span", { className: "ff-text-muted", children: "Not configured — select a workflow" }) })
    ] }),
    /* @__PURE__ */ e(x, { type: "source", position: N.Bottom, style: { opacity: 0 } })
  ] });
}, xt = {
  startNode: je,
  endNode: Be,
  addTriggerNode: Ke,
  addStepNode: Me,
  triggerNode: He,
  eventNode: Ue,
  filterNode: Ve,
  actionNode: Ge,
  approvalNode: qe,
  delayNode: Ze,
  notificationNode: Xe,
  webhookTriggerNode: et,
  restApiNode: tt,
  conditionBranchNode: ot,
  subWorkflowNode: it
}, lt = 11.5, ee = 2, M = 6, te = 40, ne = 20, oe = 4, Nt = ({
  id: n,
  sourceX: i,
  sourceY: f,
  targetX: p,
  targetY: c,
  sourcePosition: r,
  targetPosition: h,
  source: o,
  target: l,
  data: d
}) => {
  const [u, y, k] = U({
    sourceX: i,
    sourceY: f,
    targetX: p,
    targetY: c
  }), g = d == null ? void 0 : d.label, s = g === "Pass", S = s || g === "Fail", m = i + (p - i) / 3, C = f + (c - f) / 3, v = i + 2 * (p - i) / 3, L = f + 2 * (c - f) / 3, E = d == null ? void 0 : d.onAddStepClick, A = (R) => {
    if (R.stopPropagation(), typeof E != "function") return;
    const G = {
      edgeId: n,
      nodeId: o,
      sourceNodeId: o,
      targetNodeId: l,
      position: "between",
      referenceNodeId: o,
      referenceNodeType: d == null ? void 0 : d.referenceNodeType,
      stepVisibility: d == null ? void 0 : d.stepVisibility
    };
    E(o, G);
  }, I = (R) => {
    (R.key === "Enter" || R.key === " ") && (R.preventDefault(), A(R));
  }, z = () => /* @__PURE__ */ t(j, { children: [
    /* @__PURE__ */ t("g", { className: "plus-icon-container", children: [
      /* @__PURE__ */ e("circle", { r: lt, className: "edge-plus-circle" }),
      /* @__PURE__ */ e("line", { x1: 0, y1: -M, x2: 0, y2: M, strokeWidth: ee, strokeLinecap: "round", className: "plus-line" }),
      /* @__PURE__ */ e("line", { x1: -M, y1: 0, x2: M, y2: 0, strokeWidth: ee, strokeLinecap: "round", className: "plus-line" })
    ] }),
    /* @__PURE__ */ t("g", { className: "edge-plus-tooltip", transform: "translate(18, 0)", children: [
      /* @__PURE__ */ e("rect", { x: 0, y: -10, width: 65, height: 20, rx: 4, className: "tooltip-bg" }),
      /* @__PURE__ */ e("path", { d: "M0 -4 L-4 0 L0 4 Z", className: "tooltip-bg" }),
      /* @__PURE__ */ e("text", { x: 32, y: 0, textAnchor: "middle", dominantBaseline: "central", fill: "white", style: { fontSize: 10, fontWeight: 600, pointerEvents: "none" }, children: "Add Step" })
    ] })
  ] }), T = E ? {
    onClick: A,
    onKeyDown: I,
    role: "button",
    tabIndex: 0,
    style: { cursor: "pointer", pointerEvents: "all" }
  } : {
    style: { cursor: "default", pointerEvents: "all" }
  };
  return /* @__PURE__ */ t("g", { className: "edge-with-plus-wrapper", children: [
    /* @__PURE__ */ e(V, { id: n, path: u }),
    S ? /* @__PURE__ */ t(j, { children: [
      /* @__PURE__ */ t("g", { transform: `translate(${m}, ${C})`, children: [
        /* @__PURE__ */ e("rect", { x: -te / 2, y: -ne / 2, width: te, height: ne, rx: oe, ry: oe, fill: s ? "#ADE6C5" : "#FDBFBF" }),
        /* @__PURE__ */ e("text", { textAnchor: "middle", dominantBaseline: "central", fill: s ? "#1DBF60" : "#C50000", style: { fontSize: 12, fontWeight: 500 }, children: g })
      ] }),
      /* @__PURE__ */ e("g", { className: "nodrag nopan edge-plus-svg", transform: `translate(${v}, ${L})`, "data-testid": "plus-node-icon", ...T, children: /* @__PURE__ */ e(z, {}) })
    ] }) : /* @__PURE__ */ e("g", { className: "nodrag nopan edge-plus-svg", transform: `translate(${y}, ${k})`, "data-testid": "plus-node-icon", ...T, children: /* @__PURE__ */ e(z, {}) })
  ] });
}, rt = 11.5, ie = 2, _ = 6, kt = ({
  id: n,
  sourceX: i,
  sourceY: f,
  targetX: p,
  targetY: c,
  source: r,
  target: h,
  data: o
}) => {
  const [l, d, u] = U({
    sourceX: i,
    sourceY: f,
    targetX: p,
    targetY: c
  }), y = o == null ? void 0 : o.onAddStepClick, k = (s) => {
    s.stopPropagation(), typeof y == "function" && y(r, {
      edgeId: n,
      nodeId: r,
      sourceNodeId: r,
      targetNodeId: h,
      position: "between",
      referenceNodeId: r,
      referenceNodeType: o == null ? void 0 : o.referenceNodeType,
      stepVisibility: o == null ? void 0 : o.stepVisibility,
      filterId: o == null ? void 0 : o.filterId,
      branch: o == null ? void 0 : o.branch
    });
  }, g = (s) => {
    (s.key === "Enter" || s.key === " ") && (s.preventDefault(), k(s));
  };
  return /* @__PURE__ */ t("g", { className: "edge-with-plus-wrapper", children: [
    /* @__PURE__ */ e(V, { id: n, path: l, style: { stroke: "#b0bec5" } }),
    /* @__PURE__ */ t(
      "g",
      {
        className: "nodrag nopan edge-plus-svg",
        transform: `translate(${d}, ${u})`,
        style: {
          cursor: y ? "pointer" : "default",
          pointerEvents: "all",
          outline: "none"
        },
        onClick: y ? k : void 0,
        onKeyDown: y ? g : void 0,
        role: y ? "button" : void 0,
        tabIndex: y ? 0 : void 0,
        "data-testid": "plus-node-icon",
        children: [
          /* @__PURE__ */ e("circle", { r: rt, className: "edge-plus-circle" }),
          /* @__PURE__ */ e(
            "line",
            {
              x1: 0,
              y1: -_,
              x2: 0,
              y2: _,
              strokeWidth: ie,
              strokeLinecap: "round",
              className: "plus-line"
            }
          ),
          /* @__PURE__ */ e(
            "line",
            {
              x1: -_,
              y1: 0,
              x2: _,
              y2: 0,
              strokeWidth: ie,
              strokeLinecap: "round",
              className: "plus-line"
            }
          ),
          /* @__PURE__ */ t("g", { className: "edge-plus-tooltip", transform: "translate(18, 0)", children: [
            /* @__PURE__ */ e(
              "rect",
              {
                x: 0,
                y: -10,
                width: 65,
                height: 20,
                rx: 4,
                className: "tooltip-bg"
              }
            ),
            /* @__PURE__ */ e("path", { d: "M0 -4 L-4 0 L0 4 Z", className: "tooltip-bg" }),
            /* @__PURE__ */ e(
              "text",
              {
                x: 32,
                y: 0,
                textAnchor: "middle",
                dominantBaseline: "central",
                fill: "white",
                style: { fontSize: 10, fontWeight: 600, pointerEvents: "none" },
                children: "Add Step"
              }
            )
          ] })
        ]
      }
    )
  ] });
}, vt = ({ id: n, sourceX: i, sourceY: f, targetX: p, targetY: c }) => {
  const [r] = U({ sourceX: i, sourceY: f, targetX: p, targetY: c });
  return /* @__PURE__ */ e(V, { id: n, path: r, style: { stroke: "#b0bec5" } });
}, st = 11.5, le = 2, H = 6, ct = -24, re = 40, se = 20, ce = 4, wt = ({
  id: n,
  sourceX: i,
  sourceY: f,
  targetX: p,
  targetY: c,
  source: r,
  target: h,
  data: o
}) => {
  const [l, d, u] = U({ sourceX: i, sourceY: f, targetX: p, targetY: c }), y = o == null ? void 0 : o.label, k = y === "Pass", g = k || y === "Fail", s = o == null ? void 0 : o.onAddStepClick, S = (o == null ? void 0 : o.showPlus) !== !1 && !!s, m = (v) => {
    v.stopPropagation(), typeof s == "function" && s(r, {
      edgeId: n,
      nodeId: r,
      sourceNodeId: r,
      targetNodeId: h,
      position: "between",
      referenceNodeId: r,
      referenceNodeType: o == null ? void 0 : o.referenceNodeType,
      stepVisibility: o == null ? void 0 : o.stepVisibility
    });
  }, C = (v) => {
    (v.key === "Enter" || v.key === " ") && (v.preventDefault(), m(v));
  };
  return /* @__PURE__ */ t("g", { className: "edge-with-plus-wrapper", children: [
    /* @__PURE__ */ e(V, { id: n, path: l, style: { stroke: "#b0bec5" } }),
    /* @__PURE__ */ t(
      "g",
      {
        className: "nodrag nopan edge-plus-svg",
        transform: `translate(${d}, ${u})`,
        style: { cursor: s ? "pointer" : "default", pointerEvents: "all", outline: "none" },
        onClick: s ? m : void 0,
        onKeyDown: s ? C : void 0,
        role: s ? "button" : void 0,
        tabIndex: s ? 0 : void 0,
        children: [
          g && /* @__PURE__ */ t("g", { transform: `translate(0, ${S ? ct : 0})`, children: [
            /* @__PURE__ */ e(
              "rect",
              {
                x: -re / 2,
                y: -se / 2,
                width: re,
                height: se,
                rx: ce,
                ry: ce,
                fill: k ? "#ADE6C5" : "#FDBFBF"
              }
            ),
            /* @__PURE__ */ e("text", { textAnchor: "middle", dominantBaseline: "central", fill: k ? "#1DBF60" : "#C50000", style: { fontSize: 12, fontWeight: 500 }, children: y })
          ] }),
          S && /* @__PURE__ */ t("g", { className: "plus-icon-container", children: [
            /* @__PURE__ */ e("circle", { r: st, className: "edge-plus-circle" }),
            /* @__PURE__ */ e("line", { x1: 0, y1: -H, x2: 0, y2: H, strokeWidth: le, strokeLinecap: "round", className: "plus-line" }),
            /* @__PURE__ */ e("line", { x1: -H, y1: 0, x2: H, y2: 0, strokeWidth: le, strokeLinecap: "round", className: "plus-line" })
          ] }),
          S && /* @__PURE__ */ t("g", { className: "edge-plus-tooltip", transform: "translate(22, 0)", children: [
            /* @__PURE__ */ e("rect", { x: 0, y: -10, width: 65, height: 20, rx: 4, className: "tooltip-bg" }),
            /* @__PURE__ */ e("path", { d: "M0 -4 L-4 0 L0 4 Z", className: "tooltip-bg" }),
            /* @__PURE__ */ e("text", { x: 32, y: 0, textAnchor: "middle", dominantBaseline: "central", fill: "white", style: { fontSize: 10, fontWeight: 600, pointerEvents: "none" }, children: "Add Step" })
          ] })
        ]
      }
    )
  ] });
}, St = ({
  id: n,
  source: i,
  target: f,
  sourceX: p,
  sourceY: c,
  targetX: r,
  targetY: h,
  style: o = {},
  markerEnd: l,
  data: d
}) => {
  const u = (d == null ? void 0 : d.verticalRouting) ?? !1, y = 30, k = u ? (() => {
    const T = h - y;
    return `M ${p},${T} L ${r},${T} L ${r},${h}`;
  })() : (() => {
    const T = c + 30;
    return `M ${p},${c} L ${p},${T} L ${r},${T} L ${r},${h}`;
  })(), g = o.stroke || "#d1d5db", s = d == null ? void 0 : d.label, S = (d == null ? void 0 : d.isFirst) ?? !1, m = d == null ? void 0 : d.onAddStepClick, C = u ? h - y : c + 30, v = p + (r - p) * (u ? 0.25 : 0.35), L = p + (r - p) * (u ? 0.65 : 0.7), E = C, A = (T) => {
    T.stopPropagation(), m && m(i, {
      edgeId: n,
      nodeId: i,
      sourceNodeId: i,
      targetNodeId: f,
      position: "between",
      referenceNodeId: i,
      filterId: d == null ? void 0 : d.filterId,
      branch: d == null ? void 0 : d.branch
    });
  }, I = 11.5, z = 6;
  return /* @__PURE__ */ t("g", { children: [
    /* @__PURE__ */ e("path", { id: n, d: k, fill: "none", stroke: g, strokeWidth: 1.5, markerEnd: l }),
    s && !u && /* @__PURE__ */ e("g", { transform: `translate(${v}, ${E})`, children: (() => {
      const T = Math.max(44, s.length * 7 + 20);
      return /* @__PURE__ */ t(j, { children: [
        /* @__PURE__ */ e(
          "rect",
          {
            x: -T / 2,
            y: -11,
            width: T,
            height: 22,
            rx: 11,
            fill: S ? "#e8f5e9" : "#ffebee",
            stroke: S ? "#81c784" : "#e57373",
            strokeWidth: 1
          }
        ),
        /* @__PURE__ */ e(
          "text",
          {
            x: 0,
            y: 4,
            textAnchor: "middle",
            fontSize: 10,
            fontWeight: 600,
            fill: S ? "#2e7d32" : "#c62828",
            style: { fontFamily: "sans-serif", pointerEvents: "none" },
            children: s
          }
        )
      ] });
    })() }),
    m && /* @__PURE__ */ t(
      "g",
      {
        transform: `translate(${L}, ${E})`,
        onClick: A,
        style: { cursor: "pointer", pointerEvents: "all" },
        className: "nodrag nopan edge-plus-svg",
        children: [
          /* @__PURE__ */ e("circle", { r: I, className: "edge-plus-circle" }),
          /* @__PURE__ */ e("line", { x1: 0, y1: -z, x2: 0, y2: z, strokeWidth: 2, strokeLinecap: "round", className: "plus-line" }),
          /* @__PURE__ */ e("line", { x1: -z, y1: 0, x2: z, y2: 0, strokeWidth: 2, strokeLinecap: "round", className: "plus-line" })
        ]
      }
    )
  ] });
};
export {
  Ge as A,
  Ze as D,
  Nt as E,
  Ve as F,
  St as G,
  wt as L,
  Xe as N,
  vt as P,
  tt as R,
  je as S,
  He as T,
  et as W,
  Ke as a,
  qe as b,
  Be as c,
  kt as d,
  xt as e,
  $e as f
};
//# sourceMappingURL=GatewayBranchEdge-BWz43Sat.js.map
