All files / components/anim/SecAnim SecAnim.tsx

95.45% Statements 42/44
66.66% Branches 4/6
100% Functions 7/7
100% Lines 40/40

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123                1x       1x   1x 1x 1x 1x 1x       1x 1x     1x                     1x   1x 3x 24x                 1x 1x             1x 1x 3x 3x 3x       1x 24x 24x 24x 24x     24x 24x 24x 24x 24x     24x 24x 24x 24x 24x     1x     1x 1x     1x                                                        
import React, { useEffect, useRef } from "react";
import { Lock } from "lucide-react";
 
interface SecurityNetworkProps {
  width?: number;
  height?: number;
}
 
export const SecurityNetwork: React.FC<SecurityNetworkProps> = ({
  width = 800,
  height = 400,
}) => {
  const canvasRef = useRef<HTMLCanvasElement>(null);
 
  useEffect(() => {
    const canvas = canvasRef.current;
    Iif (!canvas) return;
    const ctx = canvas.getContext("2d");
    Iif (!ctx) return;
 
    let animationFrameId: number;
 
    const centerX = width / 2;
    const centerY = height / 2;
 
    // Create nodes in rings
    const rings = [
      { radius: 80, count: 6, speed: 0.005 },
      { radius: 140, count: 8, speed: -0.003 },
      { radius: 200, count: 10, speed: 0.002 },
    ];
 
    const nodes: {
      angle: number;
      radius: number;
      speed: number;
      pulse: number;
    }[] = [];
 
    rings.forEach((ring) => {
      for (let i = 0; i < ring.count; i++) {
        nodes.push({
          angle: (i / ring.count) * Math.PI * 2,
          radius: ring.radius,
          speed: ring.speed,
          pulse: Math.random() * Math.PI * 2,
        });
      }
    });
 
    const render = () => {
      ctx.clearRect(0, 0, width, height);
 
      // Background
      //   ctx.fillStyle = "#0f172a"; // slate-900
      //   ctx.fillRect(0, 0, width, height);
 
      // Draw orbit paths
      ctx.strokeStyle = "rgba(59, 130, 246, 0.15)";
      rings.forEach((ring) => {
        ctx.beginPath();
        ctx.arc(centerX, centerY, ring.radius, 0, Math.PI * 2);
        ctx.stroke();
      });
 
      // Draw nodes
      nodes.forEach((node) => {
        node.angle += node.speed;
        node.pulse += 0.05;
        const x = centerX + Math.cos(node.angle) * node.radius;
        const y = centerY + Math.sin(node.angle) * node.radius;
 
        // Connection to center
        ctx.strokeStyle = "rgba(59, 130, 246, 0.3)";
        ctx.beginPath();
        ctx.moveTo(centerX, centerY);
        ctx.lineTo(x, y);
        ctx.stroke();
 
        // Node dot
        ctx.beginPath();
        const r = 5 + Math.sin(node.pulse) * 2;
        ctx.arc(x, y, r, 0, Math.PI * 2);
        ctx.fillStyle = "#3B82F6"; // blue-500
        ctx.fill();
      });
 
      animationFrameId = requestAnimationFrame(render);
    };
 
    render();
    return () => cancelAnimationFrame(animationFrameId);
  }, [width, height]);
 
  return (
    <div className="flex flex-col items-center gap-4 ">
      <h2 className="text-xl font-bold text-blue drop-shadow-lg">
        Ensure LLM Compliance & Security
      </h2>
      <p className="text-center max-w-md">
        Protect and manage encrypted data flows seamlessly across your
        organisational network.
      </p>
      <div className="relative" style={{ width, height }}>
        <canvas
          ref={canvasRef}
          width={width}
          height={height}
          className="absolute inset-0 rounded-lg"
        />
        <div
          className="absolute inset-0 flex items-center justify-center"
          style={{ pointerEvents: "none" }}
        >
          <div className="bg-black rounded-full p-4 shadow-lg">
            <Lock size={32} className="text-white" />
          </div>
        </div>
      </div>
    </div>
  );
};