import { __ } from "@wordpress/i18n";
import { BookOpen, ArrowUpRight, Sparkles } from "lucide-react";
import "../scss/main/components/_related-guides.scss";

/** Documentation links for admin pages. */
const DocumentationLinks = ({
  guides,
  browseUrl,
  constrained = false,
  onAskAnything,
}) => {
  return (
    <nav
      className={`arraysubs-related-guides${constrained ? " arraysubs-related-guides--constrained" : ""}`}
      aria-label={__("Related guides", "arraysubs")}
    >
      <span className="arraysubs-related-guides__label" aria-hidden="true">
        <BookOpen size={16} aria-hidden="true" />
      </span>
      <a className="arraysubs-related-guides__browse" href={browseUrl} target="_blank" rel="noopener noreferrer">
        {__("Browse all docs", "arraysubs")}
        <ArrowUpRight size={14} aria-hidden="true" />
        <span className="screen-reader-text">{__("(opens in a new tab)", "arraysubs")}</span>
      </a>
      <ul>
        {guides.map(({ href, label }) => (
          <li key={href}>
            <a href={href} target="_blank" rel="noopener noreferrer">
              {label}
              <ArrowUpRight size={14} aria-hidden="true" />
              <span className="screen-reader-text">{__("(opens in a new tab)", "arraysubs")}</span>
            </a>
          </li>
        ))}
      </ul>
      {onAskAnything && (
        <button
          type="button"
          className="arraysubs-related-guides__ask-anything"
          onClick={onAskAnything}
          aria-haspopup="dialog"
        >
          <Sparkles size={16} aria-hidden="true" />
          {__("Ask Anything", "arraysubs")}
        </button>
      )}
    </nav>
  );
};

export default DocumentationLinks;
