'use client';

export function ExtIcon() {
  return (
    <svg
      viewBox="0 0 24 24"
      width="14"
      height="14"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.8"
      aria-hidden
    >
      <path d="M14 4h6v6M20 4l-9 9" />
      <path d="M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5" />
    </svg>
  );
}

/** The left list of a tab's sections (design `.up-subnav`). */
export function SubNav<T extends string>({
  items,
  value,
  onChange,
}: {
  items: ReadonlyArray<readonly [T, string]>;
  value: T;
  onChange: (next: T) => void;
}) {
  return (
    <nav className="up-subnav" aria-label="Sections">
      {items.map(([id, label]) => (
        <button
          key={id}
          type="button"
          className={id === value ? 'is-active' : undefined}
          aria-current={id === value ? 'page' : undefined}
          onClick={() => onChange(id)}
        >
          {label}
        </button>
      ))}
    </nav>
  );
}
