/* global React, Icon, SectionHead, MegaFooter, ContactStatus */
const { useState: useStateRentals, useEffect: useEffectRentals } = React;

// ===================================================================
// Rentals — sub-routed
// ===================================================================
// `/rentals`               → RentalsLanding (hero + reviews + FAQ)
// `/rentals/equipment`     → EquipmentPage (Booqable widgets, native)
// `/rentals/contact`       → RentalsContactPage
// `/rentals/open-account`  → OpenAccountPage (slim hero + Notion form)
//
// All sub-pages share the `rentals-light` chrome (light theme, rentals
// nav, rentals footer). The big hero only appears on the landing —
// every sub-page gets its own slim VR—XX header so it feels distinct.
//
// The Booqable JS widget script is loaded on every rentals route via
// `useBooqable()` so the floating cart persists as users move between
// the landing, equipment, FAQs, contact and open-account pages.
// ===================================================================

const BOOQABLE_SRC = 'https://ff981641-1ae6-4700-9720-0b8c06579658.assets.booqable.com/v2/booqable.js';

function useBooqable() {
  const [status, setStatus] = useStateRentals('loading');
  useEffectRentals(() => {
    const existing = document.querySelector(`script[src="${BOOQABLE_SRC}"]`);
    if (existing) {
      setStatus(existing.dataset.bqStatus || 'loaded');
      return;
    }
    const s = document.createElement('script');
    s.src = BOOQABLE_SRC;
    s.async = true;
    s.onload = () => { s.dataset.bqStatus = 'loaded'; setStatus('loaded'); };
    s.onerror = () => { s.dataset.bqStatus = 'error'; setStatus('error'); };
    document.head.appendChild(s);
    const t = setTimeout(() => setStatus((p) => p === 'loading' ? 'error' : p), 8000);
    return () => clearTimeout(t);
  }, []);
  return status;
}


const FAQ = [
{
  q: 'Studio hours',
  a: 'Acton studio (W3) collection & returns: Mon–Fri 08:30–18:00, Sat 08:30–17:00, Sun 10:00–16:00. Bank holidays by arrangement. After-hours collection on a Friday for a Monday shoot is fine — drop us a line.'
},
{
  q: 'Address & parking',
  a: 'Access House, 207-211 The Vale, London W3 7QS. Free on-site parking during collections, returns, and kit prep. Acton Central Station is a five-minute walk.',
  link: { url: 'https://www.google.com/maps/search/?api=1&query=Access+House+207-211+The+Vale+Acton+London+W3+7QS', label: 'Open in Google Maps →' }
},
{
  q: 'Hire periods & late returns',
  a: 'A standard single-day hire means collection after 3pm the previous day and return by 11am the following day — that overnight window is included in the day rate. Multi-day hires follow the same structure. Saturday + Sunday counts as a single hire day. Returns after 11am are charged at a full additional day rate.'
},
{
  q: 'Who can rent from us?',
  a: 'Production companies, agencies, and freelance crew. First-time direct clients complete a quick verification: photo ID held next to face, two recent proofs of address (PDF, dated within 3 months), and two trade references from custom-domain (non-Gmail) email addresses. Hygglo bookings are pre-verified by the platform.'
},
{
  q: 'Payment & accounts',
  a: 'New direct clients book on a Cash Account: full payment in advance via bank transfer or card before any kit is prepped. After a successful first hire you can move to a Credit Account with 30-day terms (invoices over £250 default to 30 days; smaller invoices stay payment-on-collection until a track record is established). Hire-in insurance covering the full replacement value of the kit is required — happy to recommend brokers if you need one.'
},
{
  q: 'Collection & delivery',
  a: 'Collect from our Acton studio within staffed hours. Driven delivery within the M25 is £45 per hour, central London congestion zone is £65 per hour, small deliveries under 10kg are £25 per hour — time is calculated on a return-trip basis. Nationwide courier on request. Weekend slots are limited — book early.'
},
{
  q: 'After-hours collection or return',
  a: 'Outside staffed hours we can usually accommodate, subject to technician availability — flat £25 per collection or return. Confirm the day before via WhatsApp.'
},
{
  q: 'Prep & checkout',
  a: 'Every kit is bench-tested, projected (lenses), and packed by our techs before it leaves the building. You\'re welcome to attend prep and check the rig over.'
},
{
  q: 'Discounts & minimum spend',
  a: 'First-time direct rentals get up to 10% off (excluding third-party platforms). Repeat clients are eligible for further discount at our discretion. Every booking has a £25 minimum spend after any discounts or credits.'
},
{
  q: 'Damage, loss & cancellations',
  a: 'Accidental damage is covered by your hire-in insurance — we\'ll quote any repair or replacement and invoice through Booqable with photos. Missing items not returned within 24 hours are invoiced at full replacement value. Cancellations: free more than 14 days out, 50% of the rental value if cancelled up to 48 hours before, non-refundable within 48 hours. We try to be fair on weather days for outdoor shoots.'
}];


// ===================================================================
// Slim per-page hero — used by every sub-page.
// ===================================================================
function RentalsSubHero({ idx, label, title, lead }) {
  return (
    <section className="rentals-subhero">
      <div className="container">
        <div className="eyebrow"><span className="idx">{idx}</span> {label}</div>
        <h1 dangerouslySetInnerHTML={{ __html: title }} />
        {lead && <p className="lead">{lead}</p>}
      </div>
    </section>);

}

// ===================================================================
// /rentals — landing page (big hero + 4 cards)
// ===================================================================
// ===================================================================
// Reviews — Google reviews shown as a 3-up grid of cards. Each card
// links to Google Maps reviews; the bottom CTA opens the full list.
// REVIEWS_TOTAL is the count Google shows for the listing (update as
// more reviews come in). To swap the featured three, replace entries
// in REVIEWS with text from the Google review you want surfaced.
// ===================================================================
const GOOGLE_REVIEWS_URL = 'https://www.google.com/maps/place/Valley+Rentals/@51.5061014,-0.2620762,17z/data=!4m8!3m7!1s0x48760f2a724d1c33:0xaa5d67f6abb38bfc!8m2!3d51.5060981!4d-0.2595013!9m1!1b1!16s%2Fg%2F11vbw9dmpt';
const REVIEWS_TOTAL = 10;

const REVIEWS = [
{
  author: 'Fenton Dyer',
  rating: 5,
  date: '2 years ago',
  text: "I had a top tier experience with Valley Rentals. Friendly and clear communication, fair prices, and easy to pick up and drop off. Glad to say this is everything you'd want from a rental house!",
  url: ''
},
{
  author: 'Mark Winterlin',
  rating: 5,
  date: '2 months ago',
  text: 'Valley Rentals is my go-to kit hire company. They have excellent service, are always responsive and take the initiative to tackle any problems, and Max and the team are always lovely to work with. Highly recommended!',
  url: ''
},
{
  author: 'Ben Stewart',
  rating: 5,
  date: 'a year ago',
  text: 'Max is super knowledgeable and helpful with the kit he rents out, and the kit is in pristine condition. He is reasonably priced, and very organised with quotes and expectations. Would definitely rent from him again!',
  url: ''
}];


// Single-star SVG — filled-vs-empty driven by parent class. We render
// 5 stars per card and toggle the .filled class up to `rating`.
function ReviewStar({ filled }) {
  return (
    <svg className={`rr-star ${filled ? 'filled' : ''}`} viewBox="0 0 20 20" width="14" height="14" aria-hidden="true">
      <path d="M10 1.5l2.6 5.3 5.9.85-4.25 4.15.99 5.85L10 14.9 4.76 17.65l.99-5.85L1.5 7.65l5.9-.85L10 1.5z" fill="currentColor" />
    </svg>);

}

function ReviewsSection() {
  return (
    <section className="rentals-reviews">
      <div className="container">
        <div className="rr-head">
          <div className="eyebrow"><span className="idx">T—01</span> What clients say</div>
          <h2>Reviewed on <em>Google</em>.</h2>
          <div className="rr-summary">
            <span className="rr-stars-row" aria-label="5 out of 5 stars">
              {Array.from({ length: 5 }, (_, i) => <ReviewStar key={i} filled />)}
            </span>
            <span className="rr-summary-num">5.0</span>
            <span className="rr-summary-source">· {REVIEWS_TOTAL} reviews on Google</span>
          </div>
        </div>

        <div className="rr-grid">
          {REVIEWS.map((r, i) =>
          <a
            key={i}
            href={r.url || GOOGLE_REVIEWS_URL}
            target="_blank"
            rel="noopener noreferrer"
            className="rr-card"
            data-hover="Read">
              <span className="rr-stars-row" aria-label={`${r.rating} out of 5 stars`}>
                {Array.from({ length: 5 }, (_, k) => <ReviewStar key={k} filled={k < r.rating} />)}
              </span>
              <p className="rr-text">{r.text}</p>
              <div className="rr-author-row">
                <span className="rr-author">{r.author}</span>
                {r.date && <span className="rr-date">{r.date}</span>}
              </div>
            </a>
          )}
        </div>

        <div className="rr-cta">
          <a href={GOOGLE_REVIEWS_URL} target="_blank" rel="noopener noreferrer" className="rr-cta-link" data-hover="Open">
            See all reviews on Google
            <Icon name="arrow-up-right" size={14} />
          </a>
        </div>
      </div>
    </section>);

}

// ===================================================================
// /rentals — landing page (hero, reviews, FAQ, footer). Mirrors the
// flow of the films home: editorial sections rather than a card grid.
// ===================================================================
function RentalsLanding({ onGoto }) {
  // Controlled-accordion state — only one FAQ open at a time. Mirrors the
  // pattern used by ServicesAccordion on the films home so the reveal
  // animation can use grid-template-rows: 0fr → 1fr instead of <details>'
  // discrete toggle. First item open by default for affordance.
  const [openFaq, setOpenFaq] = useStateRentals(0);
  // Hover-driven on devices with a fine pointer; click stays as the
  // fallback for keyboards and touch screens. matchMedia gate prevents
  // the open-then-instantly-close flicker when a tap synthesises both
  // mouseenter and click on iOS/Android.
  const [hoverOpens, setHoverOpens] = useStateRentals(false);
  React.useEffect(() => {
    const m = window.matchMedia('(hover: hover) and (pointer: fine)');
    const apply = () => setHoverOpens(m.matches);
    apply();
    m.addEventListener ? m.addEventListener('change', apply) : m.addListener(apply);
    return () => { m.removeEventListener ? m.removeEventListener('change', apply) : m.removeListener(apply); };
  }, []);

  return (
    <main className="page active rentals-light" data-screen-label="03b Rentals">

      {/* FAQPage structured data — surfaces in Google search results.
          The FAQ accordion now lives on the home page, so the schema
          ships from here too. */}
      <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify({
        "@context": "https://schema.org",
        "@type": "FAQPage",
        "mainEntity": FAQ.map((f) => ({
          "@type": "Question",
          "name": f.q,
          "acceptedAnswer": { "@type": "Answer", "text": f.a }
        }))
      }) }} />

      <section className="rentals-hero">
        <div className="rentals-hero-blob" />
        <div className="container">
          <div className="eyebrow"><span className="idx">VR—01</span> Valley Rentals</div>
          <h1>Studio kit, <em>ready</em><br />when you are.</h1>
          <p className="lead">A working rental shelf out of our East Acton location — the same camera, lens and lighting packages we shoot with day-to-day. Hand-checked, prep included, no faff.</p>
          <div className="rentals-hero-stats">
            <div className="stat"><div className="num">120+</div><div className="lbl">Kits in inventory</div></div>
            <div className="stat"><div className="num">2hr</div><div className="lbl">Same-day prep window</div></div>
            <div className="stat"><div className="num">W3</div><div className="lbl">Acton, London</div></div>
          </div>
        </div>
      </section>

      <ReviewsSection />

      <section id="faqs" className="rentals-faq">
        <div className="container">
          <SectionHead idx="VR—01" label="Rental SOP · FAQ" title="The <em>useful</em><br/>fine print." />
          <div className="faq-grid">
            {FAQ.map((f, i) => {
              const isOpen = openFaq === i;
              const toggle = () => setOpenFaq(isOpen ? -1 : i);
              return (
                <div
                  key={i}
                  className={`faq-item${isOpen ? ' is-open' : ''}`}
                  onMouseEnter={hoverOpens ? () => setOpenFaq(i) : undefined}
                  onMouseLeave={hoverOpens ? () => setOpenFaq((prev) => prev === i ? -1 : prev) : undefined}
                  data-hover={isOpen ? 'Close' : 'Open'}>
                  <button
                    type="button"
                    className="faq-head"
                    aria-expanded={isOpen}
                    onClick={toggle}>
                    <span className="faq-num">{String(i + 1).padStart(2, '0')}</span>
                    <span className="faq-q">{f.q}</span>
                    <span className="faq-toggle" aria-hidden="true"><Icon name="plus" size={14} /></span>
                  </button>
                  <div className="faq-body">
                    <div className="faq-body-inner">
                      <div className="faq-a">{f.a}{f.link && <> <a href={f.link.url} target="_blank" rel="noopener noreferrer" className="faq-link">{f.link.label}</a></>}</div>
                    </div>
                  </div>
                </div>);

            })}
          </div>
        </div>
      </section>

      <MegaFooter onGoto={onGoto} isRentals />
    </main>);

}

// ===================================================================
// /rentals/equipment — native Booqable widget.
// The booqable.js script (loaded by useBooqable() at the RentalsPage
// level) walks the DOM and renders products inside booqable-product-list,
// the date picker inside booqable-datepicker, and a floating cart on
// the bottom-right of the page.
//
// Date selection from step 01 flows through to availability/pricing on
// each product in the live shelf.
// ===================================================================
function EquipmentPage({ onGoto, bqStatus }) {
  return (
    <main className="page active rentals-light" data-screen-label="03b Rentals · Equipment">
      <RentalsSubHero
        idx="VR—02"
        label="Equipment · Live inventory"
        title="Pick your dates,<br/><em>browse</em> the full shelf."
        lead="Live availability and pricing — pulls straight from our Booqable inventory. Add to cart, then we'll confirm with prep and a final invoice." />

      <section id="equipment" className="rentals-shop">
        <div className="container">
          <div className="booqable-frame-head">
            <div className="bf-step">
              <span className="bf-step-num">01</span>
              <span className="bf-step-label">Pick your shoot dates</span>
            </div>
            <div className="booqable-datepicker"></div>
          </div>

          <div className="booqable-frame-head" style={{ marginTop: 32 }}>
            <div className="bf-step">
              <span className="bf-step-num">02</span>
              <span className="bf-step-label">Browse available kit & build your list</span>
            </div>
          </div>
        </div>

        <div className="rentals-shop-full" aria-label="Live shelf">
          <div className="booqable-product-list"></div>
        </div>

        <div className="container">
          {bqStatus === 'error' ? (
            <div className="booqable-fallback booqable-error" role="alert">
              <div className="bf-error-head">
                <Icon name="alert" size={18} />
                <strong>Live inventory unavailable right now.</strong>
              </div>
              <p>Our booking widget hasn't loaded — usually a flaky network or an ad-blocker. We can still take your booking the old-fashioned way: email <a href="mailto:rentals@valley.film">rentals@valley.film</a> with your dates and a kit list, or WhatsApp <a href="https://wa.me/message/UI5I3PDWH5Q3N1" target="_blank" rel="noopener noreferrer">+44 7771 039043</a>. Same-day reply in working hours.</p>
              <p className="bf-retry">Or <button type="button" className="bf-retry-link" onClick={() => window.location.reload()}>reload the page</button> to try again.</p>
            </div>
          ) : (
            <p className="booqable-fallback">
              Trouble seeing the live shelf? Email <a href="mailto:rentals@valley.film">rentals@valley.film</a> with your dates and a kit list — we'll respond same business day.
            </p>
          )}
        </div>
      </section>

      <MegaFooter onGoto={onGoto} isRentals />
    </main>);

}

// ===================================================================
// /rentals/contact — rentals-flavoured contact form
// ===================================================================
function RentalsContactPage({ onGoto }) {
  const [sent, setSent] = useStateRentals(false);
  const [sending, setSending] = useStateRentals(false);
  const [error, setError] = useStateRentals('');
  const [form, setForm] = useStateRentals({ name: '', company: '', email: '', brief: '', honeypot: '' });
  const set = (k) => (e) => setForm({ ...form, [k]: e.target.value });

  const progress = (() => {
    const has = (s) => (s || '').trim().length > 0;
    const emailOk = /\S+@\S+\.\S+/.test(form.email || '');
    const briefLen = (form.brief || '').trim().length;
    const briefScore = Math.min(1, briefLen / 80);
    const parts = [
    has(form.name) ? 1 : 0,
    has(form.company) ? 1 : 0,
    emailOk ? 1 : has(form.email) ? 0.4 : 0,
    briefScore];

    return parts.reduce((a, b) => a + b, 0) / parts.length;
  })();

  return (
    <main className="page active rentals-light" data-screen-label="03b Rentals · Contact">
      <RentalsSubHero
        idx="VR—04"
        label="Get in touch"
        title="Drop us your <em>dates</em><br/>and a kit list."
        lead="Same-day reply in working hours. For an active booking, reply to your Booqable email — that'll thread the conversation cleanly." />

      <section className="contact rentals-contact">
        <div className="container">
          <div>
            <div className="meta-block">
              <div className="meta-row">
                <div className="ico"><Icon name="mail" /></div>
                <div><div className="lbl">Email</div><a className="val val-link" href="mailto:rentals@valley.film">rentals@valley.film</a></div>
              </div>
              <div className="meta-row">
                <div className="ico"><Icon name="phone" /></div>
                <div><div className="lbl">WhatsApp</div><a className="val val-link" href="https://wa.me/message/UI5I3PDWH5Q3N1" target="_blank" rel="noopener noreferrer">+44 7771 039043</a></div>
              </div>
              <div className="meta-row">
                <div className="ico"><Icon name="instagram" /></div>
                <div><div className="lbl">Instagram</div><a className="val val-link" href="https://instagram.com/rentals.valley" target="_blank" rel="noopener noreferrer">@rentals.valley</a></div>
              </div>
              <div className="meta-row">
                <div className="ico"><Icon name="pin" /></div>
                <div><div className="lbl">Studio</div><a className="val val-link" href="https://www.google.com/maps/search/?api=1&query=Access+House+207-211+The+Vale+Acton+London+W3+7QS" target="_blank" rel="noopener noreferrer">Access House, 207–211 The Vale,<br />Acton, London W3 7QS</a></div>
              </div>
            </div>

            <div className="rentals-hours">
              <h3>Staffed hours</h3>
              <p className="rentals-hours-sub">When the team is at the desk for calls, emails and live booking support.</p>
              <dl>
                <div><dt>Mon–Fri</dt><dd>09:00 – 17:00</dd></div>
                <div><dt>Sat–Sun</dt><dd>Closed</dd></div>
                <div><dt>Bank holidays</dt><dd>Closed</dd></div>
              </dl>
            </div>

            <div className="rentals-hours">
              <h3>Collection &amp; returns</h3>
              <p className="rentals-hours-sub">When you can pick kit up or drop it back at the studio.</p>
              <dl>
                <div><dt>Mon–Fri</dt><dd>08:30 – 18:00</dd></div>
                <div><dt>Saturday</dt><dd>08:30 – 17:00</dd></div>
                <div><dt>Sunday</dt><dd>10:00 – 16:00</dd></div>
                <div><dt>Bank holidays</dt><dd>By arrangement</dd></div>
              </dl>
              <p className="rentals-hours-note">After-hours collection or return is usually available — confirm the day before via WhatsApp.</p>
            </div>
          </div>

          <div className="form-card">
            {sent ?
            <div className="contact-sent">
                <div className="check"><Icon name="check" /></div>
                <h3>Thanks — that's with us.</h3>
                <p>We'll come back to you within one business day. Reply to the email confirmation if anything urgent comes up before then.</p>
                <button className="btn-pri" style={{ marginTop: 24 }} onClick={() => setSent(false)} data-hover="New">Send another</button>
              </div> :

            <React.Fragment>
                <h3>Rental enquiry</h3>
                <p className="desc">A few lines is plenty — dates, a kit list, anything weird about the shoot.</p>
                <ContactStatus />
                <div className="step-indicator" aria-hidden="true">
                  {[0, 1, 2].map((i) => {
                  const segStart = i / 3;
                  const segEnd = (i + 1) / 3;
                  const fill = Math.max(0, Math.min(1, (progress - segStart) / (segEnd - segStart)));
                  return (
                    <div key={i} className={`dot ${fill > 0 ? 'filling' : ''}`}>
                        <span className="fill" style={{ transform: `scaleX(${fill})` }} />
                      </div>);

                })}
                </div>

                <div className="field-row">
                  <div className="field"><label>Your name</label><input value={form.name} onChange={set('name')} placeholder="Jordan Reeves" /></div>
                  <div className="field"><label>Company</label><input value={form.company} onChange={set('company')} placeholder="Company or production" /></div>
                </div>
                <div className="field-row">
                  <div className="field full"><label>Email</label><input type="email" value={form.email} onChange={set('email')} placeholder="jordan@brand.com" /></div>
                </div>

                <div className="field-row">
                  <div className="field full">
                    <label>Tell us about the shoot</label>
                    <textarea rows="4" value={form.brief} onChange={set('brief')} placeholder="Dates, kit list, anything that helps us prep cleanly." />
                  </div>
                </div>

                {/* Honeypot — hidden field. Real users leave it blank, bots fill it. */}
                <div aria-hidden="true" style={{ position: 'absolute', left: '-9999px', height: 0, overflow: 'hidden' }}>
                  <label>Don't fill this in <input type="text" tabIndex={-1} autoComplete="off" value={form.honeypot} onChange={set('honeypot')} /></label>
                </div>

                {error && <div className="form-error" role="alert">{error}</div>}

                <button className="submit" disabled={sending} onClick={async (e) => {
                e.preventDefault();
                setError('');
                if (!form.name.trim() || !form.email.trim() || !form.brief.trim()) {
                  setError('Please fill in your name, email, and a few lines about the shoot.');
                  return;
                }
                if (!/^\S+@\S+\.\S+$/.test(form.email)) {
                  setError('That email doesn\'t look right — please double-check.');
                  return;
                }
                setSending(true);
                try {
                  const resp = await fetch('/api/contact', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ ...form, kind: 'rentals' })
                  });
                  if (!resp.ok) throw new Error((await resp.json().catch(() => ({}))).error || 'Send failed');
                  setSent(true);
                } catch (err) {
                  setError('Couldn\'t send right now — please email rentals@valley.film directly.');
                } finally {
                  setSending(false);
                }
              }} data-hover="Send">
                  {sending ? 'Sending…' : <>Send enquiry <Icon name="arrow-right" /></>}
                </button>
              </React.Fragment>
            }
          </div>
        </div>
      </section>

      <MegaFooter onGoto={onGoto} isRentals />
    </main>);

}

// ===================================================================
// /rentals/open-account — Notion-form embed inside our shell
// ===================================================================
function OpenAccountPage({ onGoto }) {
  return (
    <main className="page active rentals-light" data-screen-label="03b Rentals · Open Account">
      <RentalsSubHero
        idx="VR—05"
        label="Open Account"
        title="One verification.<br/><em>Faster</em> bookings, credit terms."
        lead="Open a Valley Rentals account once and skip verification on every future booking. After a successful first hire, accounts unlock 30-day credit terms on invoices over £250 and access to repeat-client rates." />

      <section id="open-account" className="rentals-open-account">
        <div className="container">
          <div className="oa-intro">
            <h3>What you'll need to apply</h3>
            <ul className="oa-checklist">
              <li>Photo ID — passport, UK driving licence or national ID, held next to your face in the photo.</li>
              <li>Two proofs of address — utility bill, bank statement, council tax or mobile contract, dated within three months. PDF only.</li>
              <li>A link to your professional portfolio.</li>
              <li>Two trade references — business email and phone number for each. Custom-domain emails only (no Gmail).</li>
            </ul>
            <p className="oa-time">Takes about five minutes to complete.</p>
          </div>
        </div>

        <div className="oa-form-full">
          <iframe
            className="oa-form-iframe"
            src="https://valleyfilms.notion.site/ebd/13e47fd0362080819a2afdcb9d5a0275"
            title="Valley Rentals — Open Account application"
            loading="lazy"
            allow="clipboard-write" />

        </div>

        <div className="container">
          <p className="oa-alt">Already an account holder? Email <a href="mailto:rentals@valley.film">rentals@valley.film</a> to book directly.</p>
        </div>
      </section>

      <MegaFooter onGoto={onGoto} isRentals />
    </main>);

}

// ===================================================================
// Top-level switch — picks a sub-page based on rentalsSection prop.
// ===================================================================
function RentalsPage({ onGoto, rentalsSection }) {
  // Load the Booqable script on every rentals route so the floating
  // cart persists as the user moves between landing → equipment →
  // contact, etc. Returns the load status; the equipment page uses it
  // to swap in a fallback message if the script ever fails.
  const bqStatus = useBooqable();

  if (rentalsSection === 'equipment')    return <EquipmentPage onGoto={onGoto} bqStatus={bqStatus} />;
  if (rentalsSection === 'contact')      return <RentalsContactPage onGoto={onGoto} />;
  if (rentalsSection === 'open-account') return <OpenAccountPage onGoto={onGoto} />;
  return <RentalsLanding onGoto={onGoto} />;
}

Object.assign(window, { RentalsPage });
