import Link from 'next/link';
import FlightSearchFormV3, { type FlightSearchFormV3Props } from './FlightSearchFormV3';
import { FlightsTabIcon, HotelsTabIcon } from '@/components/home/v3/icons';
import { PRODUCT_LINKS } from '@/constants/product-links';

/**
 * The flight SRP's search band: the same hero strip the hotel SRP uses, with
 * the flight form in it and Flights as the active tab.
 *
 * The Hotels tab uses the shared product link, so it behaves exactly like the
 * Hotels link in the header and footer: PRODUCT_LINKS.hotels now points at
 * corp's own `/srp/hotels` rather than leaving the site. That used to be
 * unsafe — a bare `/srp/hotels` fired a search from URL params with no
 * location at all and silently returned nothing — but HotelSearchFormV3's
 * own URL-sync effect now backfills a default destination when none is
 * present, the same way this page's own bare visit already resolves to a
 * default itinerary. See that effect's doc comment for the full story.
 */
export default function FlightSearchPanelV3(props: FlightSearchFormV3Props) {
  return (
    /*
     * Hidden below lg — see flight-sticky-bar.css.
     *
     * On a phone this band is a full viewport of form before a single flight,
     * so the results page opens on a search the traveller has already made.
     * There, FlightSearchStickyBar's summary row takes over: what was searched
     * for, and one control to change it. Desktop is untouched.
     */
    <section className="hero-banner-section flight-srp-hero pt-5 d-none d-lg-block">
      <div className="hero-banner-bg">
        {/* eslint-disable-next-line @next/next/no-img-element */}
        <img src="/images/v3/v748-toon-103.jpg" alt="" />
      </div>
      <div className="hero-banner-overlay hero-banner-overlay-light" />

      <div className="search-panel-container text-center text-md-start h-auto mb-0">
        <div className="shape-element">
          <svg className="fill-white" width={406} height={25} viewBox="0 0 406 25" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden>
            <path d="M0 24C0 10.7452 10.7452 2.77559e-06 24 2.6702e-06L347.101 1.01301e-07C354.84 3.97714e-08 361.844 4.58429 364.94 11.6766C367.958 18.5881 374.696 23.1346 382.235 23.3455L405.132 23.986C405.41 23.9938 405.632 24.2216 405.632 24.5H0V24Z" fill="white" />
          </svg>
        </div>

        <div className="hero-tabs d-inline-flex align-items-center gap-2 mb-2 mb-md-0 me-auto me-md-0 ms-auto ms-md-3">
          <Link href={PRODUCT_LINKS.hotels} className="buttons py-1 px-2 bg-transparent text-md d-flex align-items-center gap-2">
            <HotelsTabIcon />
            Hotels
          </Link>
          <button
            type="button"
            className="hero-tab active buttons py-1 px-2 bg-transparent text-md d-flex align-items-center gap-2"
            aria-current="page"
          >
            <FlightsTabIcon />
            Flights
          </button>
        </div>

        <div className="search-form-wrap text-start px-2">
          <div className="search-tab-panel" data-panel="flights">
            <FlightSearchFormV3 {...props} />
          </div>
        </div>
      </div>
    </section>
  );
}
