import { Handle, Position } from "@xyflow/react";
import type { NodeProps } from "@xyflow/react";

import type { DiagramNode } from "../graph";

export function BpmnTimerEventNode({ data }: NodeProps) {
  const d = data as unknown as DiagramNode & { label: string };

  return (
    <div className="bpmn-event-node">
      <svg width={36} height={36} viewBox="0 0 36 36">
        <circle
          cx={18}
          cy={18}
          r={17}
          fill="none"
          style={{ stroke: "var(--bpmn-timer-event)", strokeWidth: 2 }}
        />
        <circle
          cx={18}
          cy={18}
          r={13}
          fill="none"
          style={{ stroke: "var(--bpmn-timer-event)", strokeWidth: 1 }}
        />
        <line
          x1={18}
          y1={18}
          x2={18}
          y2={11}
          style={{ stroke: "var(--bpmn-timer-event)", strokeWidth: 1.5 }}
        />
        <line
          x1={18}
          y1={18}
          x2={23}
          y2={20}
          style={{ stroke: "var(--bpmn-timer-event)", strokeWidth: 1.5 }}
        />
      </svg>
      {d.label && <div className="bpmn-event-label">{d.label}</div>}
      <Handle type="target" position={Position.Top} style={{ opacity: 0 }} />
      <Handle
        type="target"
        position={Position.Left}
        id="left"
        style={{ opacity: 0 }}
      />
      <Handle type="source" position={Position.Bottom} style={{ opacity: 0 }} />
      <Handle
        type="source"
        position={Position.Right}
        id="right"
        style={{ opacity: 0 }}
      />
    </div>
  );
}
