# FareHarbor Integration

FareHarbor is the source of truth for tours, availability, pricing, checkout, and confirmations. The site doesn't use the FareHarbor API and doesn't store item IDs.

## How it works

1. `layout.tsx` renders `<FareharborScript />` (a `next/script` with `afterInteractive`) **only if** `getTourBooking().bookingUrl` is valid:

   ```
   https://fareharbor.com/embeds/api/v1/?autolightframe=yes
   ```

2. With `autolightframe=yes`, FareHarbor intercepts clicks on any `<a href="https://fareharbor.com/embeds/book/…">` and opens its **Lightframe** overlay instead of navigating away.
3. `FareharborWidget` renders the *Book now* anchor, styled with `buttonClasses`, or a disabled button reading "Online booking opens soon" if the URL fails `isFareharborBookingUrl()`.
4. The header's **Buy Tickets** is a direct FareHarbor anchor when a URL exists, and otherwise falls back to `/visit/#tours`.

## Configuration

`content/tour-booking.json`, edited via Decap → **Alerts & Booking → Update tour booking links**:

| Key | Required | Used by |
| --- | --- | --- |
| `bookingUrl` | Yes | Header Buy Tickets, self-guided and private/group cards, Visit closing CTA |
| `guidedBookingUrl` | No | Guided Tour card only; falls back to `bookingUrl` |

Validation happens in two places:

- **Decap** (`config.yml` `pattern`): `^https://fareharbor\.com/embeds/book/[^/?#]+/?(?:\?.*)?$` for the default link, and a slightly looser pattern allowing sub-paths for the guided link.
- **Runtime** (`isFareharborBookingUrl`): https scheme, host exactly `fareharbor.com`, path starting `/embeds/book/`. Anything else is treated as empty.

Current default: `https://fareharbor.com/embeds/book/fortadamstrust/?full-items=yes` (company short name `fortadamstrust`).

## Why URLs, not embed code

Editors paste a URL rather than FareHarbor's HTML/JS snippet. The app supplies the script itself, so the CMS never stores arbitrary markup, which would be both brittle and an XSS risk.

## Keeping copy in sync

The Visit page's tour cards (`src/lib/tours.ts`) contain descriptive copy, durations, and "From $…" price labels that FareHarbor doesn't feed. Update them whenever FareHarbor products or prices change. The Visit page itself states that "Tour availability and final pricing are confirmed during booking."