"use client";

import { memo } from "react";
import { ASSETS, getAssetPath, vectorMarkPath } from "../../../../lib/assetUtils";
import ContentLockup from "../ContentLockup";
import type { AboutHeaderViewProps } from "./AboutHeader.types";

function assetRelativeForInlineIcon(icon: "arrow" | "about"): string {
  return icon === "arrow" ? ASSETS.LOGO : vectorMarkPath("about");
}

/**
 * Figma: "Section / About Header" (22135-889654) — inline marks 32/29, 64/58, 80/80.
 */
function AboutHeaderView({
  segments,
  titleId,
  className = "",
}: AboutHeaderViewProps) {
  return (
    <section
      className={`bg-black px-[var(--spacing-scale-020)] py-[var(--spacing-scale-032)] md:px-[var(--spacing-scale-064)] md:py-[var(--spacing-scale-032)] ${className}`.trim()}
    >
      <ContentLockup
        variant="about"
        alignment="left"
        titleId={titleId}
        titleContent={segments.map((segment, index) => {
          if (segment.type === "word") {
            return (
              <span key={`${segment.text}-${index}`} className="whitespace-nowrap">
                {segment.text}
              </span>
            );
          }

          return (
            <span
              key={`${segment.icon}-${index}`}
              className={
                segment.icon === "arrow"
                  ? "inline-flex size-[32px] shrink-0 items-center self-center md:size-[64px] xl:size-[80px]"
                  : "inline-flex size-[29px] shrink-0 items-center justify-center md:size-[58px] xl:size-[80px]"
              }
            >
              {/* eslint-disable-next-line @next/next/no-img-element -- decorative inline vector */}
              <img
                src={getAssetPath(assetRelativeForInlineIcon(segment.icon))}
                alt=""
                className="size-full object-contain"
                role="presentation"
              />
            </span>
          );
        })}
      />
    </section>
  );
}

AboutHeaderView.displayName = "AboutHeaderView";

export default memo(AboutHeaderView);
