# Add the "Ticket Selector" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/ticket-selector) to this Pantheon Content Publisher (P1) Next.js project. Timed-entry admission: visit date, entry-time cards with availability, quantities by ticket type and add-ons in one form.

## Steps

1. Create `components/puck/ticket-selector-block.tsx` with the exact file contents below. If `components/puck/` doesn't exist, find the folder where this project keeps its Puck components (look at the imports in `puck.config.tsx`) and put it there.
2. In `puck.config.tsx`, import it: `import { ticketSelectorBlock } from "./components/puck/ticket-selector-block";`
3. Register it under `components` as `TicketSelectorBlock: ticketSelectorBlock`.
4. Add `"TicketSelectorBlock"` to the best-fitting entry in `categories` (this block's library category is "Ecommerce"). Create a category only if none fits.
5. Run the project's type check (usually `pnpm typecheck`) and resolve anything project-specific.
6. If `package.json` has a `sync:registry` script, tell the user it must run (or that CI will run it) before the new component appears in the P1 editor.

## Rules

- Do not add dependencies. The block is self-contained by design: one type-only import from `@puckeditor/core`, Tailwind v4 classes, no client JavaScript.
- Keep the files as-is unless the user asks for changes. The accent color is `indigo-*`; if the project has brand colors, offer to swap them with a find-and-replace on `indigo-`.
- Images are plain `imageUrl` + `imageAlt` text fields. If this project defines a P1 media-library field (search for `"p1-media"`), offer to switch to it.
- Don't change prop names in `defaultProps`. Content editors' saved pages depend on them.

## File: `components/puck/ticket-selector-block.tsx`

```tsx
import type { ComponentConfig } from "@puckeditor/core";

/**
 * Ticket Selector — timed-entry admission: a visit date, entry-time radio cards with availability,
 * ticket quantities by type and optional add-ons, all in one form that goes to your checkout. No JavaScript.
 * Register: `TicketSelectorBlock: ticketSelectorBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";

type Slot = { time: string; availability: string; soldOut: boolean };
type TicketType = { name: string; detail: string; price: string };
type AddOn = { name: string; detail: string; price: string };

export type TicketSelectorProps = {
  eyebrow: string;
  heading: string;
  headingLevel: Heading;
  intro: string;
  formAction: string;
  formMethod: "get" | "post";
  earliestDate: string;
  slots: Slot[];
  tickets: TicketType[];
  maxPerType: string;
  addOns: AddOn[];
  submitLabel: string;
  policyNote: string;
};

const fieldKey = (s: string) => (s || "ticket").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "") || "ticket";

const legendClass = "flex items-baseline gap-3 text-base leading-7 font-semibold text-neutral-950";
const stepClass = "text-sm font-semibold text-indigo-700 tabular-nums";

export const ticketSelectorBlock: ComponentConfig<TicketSelectorProps> = {
  label: "Ticket Selector",
  fields: {
    eyebrow: { type: "text", label: "Eyebrow", metadata: { help: "Small line above the heading. Leave blank to hide it." } },
    heading: { type: "text", label: "Heading" },
    headingLevel: {
      type: "select",
      label: "Heading level",
      options: [
        { label: "H1", value: "h1" },
        { label: "H2", value: "h2" },
        { label: "H3", value: "h3" },
        { label: "H4", value: "h4" },
      ],
      metadata: { help: "Sets the page outline for screen readers and search. The look doesn't change." },
    },
    intro: { type: "textarea", label: "Intro" },
    formAction: {
      type: "text",
      label: "Checkout URL",
      metadata: { help: "Your ticketing checkout. Sends visit_date, entry_time, one qty_ field per ticket type (such as qty_adult) and addons." },
    },
    formMethod: {
      type: "radio",
      label: "Send with",
      options: [
        { label: "GET (in the URL)", value: "get" },
        { label: "POST", value: "post" },
      ],
      metadata: { help: "Use GET if your checkout reads choices from the URL; POST if it expects a form submission." },
    },
    earliestDate: { type: "text", label: "Earliest date", metadata: { help: "Optional, as YYYY-MM-DD. Visitors can't pick a date before it." } },
    slots: {
      type: "array",
      label: "Entry times",
      min: 0,
      max: 12,
      getItemSummary: (item) => `${item?.time || "Time"}${item?.soldOut ? " (sold out)" : ""}`,
      defaultItemProps: { time: "1:00 p.m.", availability: "Plenty of space", soldOut: false },
      arrayFields: {
        time: { type: "text", label: "Time" },
        availability: { type: "text", label: "Availability", metadata: { help: "Such as \"12 left\". Can be bound to a data source." } },
        soldOut: {
          type: "radio",
          label: "Sold out",
          options: [
            { label: "Yes", value: true },
            { label: "No", value: false },
          ],
          metadata: { help: "Sold-out times stay visible but can't be picked." },
        },
      },
    },
    tickets: {
      type: "array",
      label: "Ticket types",
      min: 1,
      max: 8,
      getItemSummary: (item) => `${item?.name || "Ticket"}${item?.price ? ` · ${item.price}` : ""}`,
      defaultItemProps: { name: "Student", detail: "With a valid ID", price: "$15" },
      arrayFields: {
        name: { type: "text", label: "Name", metadata: { help: "Also names the form field, so Adult is sent as qty_adult." } },
        detail: { type: "text", label: "Who it's for", metadata: { help: "Such as \"Ages 3–12\". Leave blank to hide it." } },
        price: { type: "text", label: "Price", metadata: { help: "Shown as typed, such as $22 or Free. Can be bound to a data source." } },
      },
    },
    maxPerType: { type: "text", label: "Most tickets per type", metadata: { help: "Largest number allowed in each quantity box. Leave blank for 10." } },
    addOns: {
      type: "array",
      label: "Add-ons",
      min: 0,
      max: 6,
      getItemSummary: (item) => item?.name || "Add-on",
      defaultItemProps: { name: "Audio guide", detail: "", price: "$5" },
      arrayFields: {
        name: { type: "text", label: "Name" },
        detail: { type: "text", label: "Detail", metadata: { help: "One line, such as the show time. Leave blank to hide it." } },
        price: { type: "text", label: "Price", metadata: { help: "Shown as typed, per person or per order as you describe it." } },
      },
    },
    submitLabel: { type: "text", label: "Button text" },
    policyNote: { type: "textarea", label: "Policy note", metadata: { help: "Small print under the button, such as refunds and member entry. Leave blank to hide it." } },
  },
  defaultProps: {
    eyebrow: "Plan your visit",
    heading: "Get timed-entry tickets",
    headingLevel: "h2",
    intro: "Choose a day and an entry time, then tell us who's coming. Once inside, stay as long as you like. The zoo is open daily 9 a.m. to 5 p.m.",
    formAction: "/tickets/checkout",
    formMethod: "get",
    earliestDate: "",
    slots: [
      { time: "9:00 a.m.", availability: "Sold out", soldOut: true },
      { time: "10:00 a.m.", availability: "4 left", soldOut: false },
      { time: "11:00 a.m.", availability: "18 left", soldOut: false },
      { time: "12:30 p.m.", availability: "Plenty of space", soldOut: false },
      { time: "2:00 p.m.", availability: "Plenty of space", soldOut: false },
      { time: "3:30 p.m.", availability: "Plenty of space", soldOut: false },
    ],
    tickets: [
      { name: "Adult", detail: "Ages 13–64", price: "$22" },
      { name: "Child", detail: "Ages 3–12", price: "$16" },
      { name: "Senior", detail: "Ages 65 and up", price: "$18" },
      { name: "Member", detail: "Show your card at the gate", price: "Free" },
    ],
    maxPerType: "10",
    addOns: [
      { name: "Giraffe feeding", detail: "Daily at 11:30 a.m. and 2:30 p.m.", price: "$6 each" },
      { name: "Unlimited carousel and train rides", detail: "", price: "$9 each" },
      { name: "Parking pass", detail: "One vehicle, all day", price: "$8 per car" },
    ],
    submitLabel: "Continue to checkout",
    policyNote: "Children under 3 and members enter free but still need a timed ticket. Tickets can be changed up to 24 hours before your visit. Prices and availability are sample data.",
  },
  render: ({ id, eyebrow, heading, headingLevel, intro, formAction, formMethod, earliestDate, slots, tickets, maxPerType, addOns, submitLabel, policyNote }) => {
    const H = headingLevel || "h2";
    const uid = `ts-${id || "tickets"}`;
    const times = (slots ?? []).filter((s) => s?.time);
    const types = (tickets ?? []).filter((t) => t?.name);
    const extras = (addOns ?? []).filter((a) => a?.name);
    const max = (maxPerType || "").replace(/[^\d]/g, "") || "10";
    const minDate = /^\d{4}-\d{2}-\d{2}$/.test((earliestDate || "").trim()) ? earliestDate.trim() : undefined;
    const firstOpen = times.findIndex((s) => !s.soldOut);
    let step = 0;
    const next = () => String(++step).padStart(2, "0");
    const hasIntro = Boolean(eyebrow || heading || intro);

    return (
      <section className="bg-white px-4 py-16 sm:px-6 sm:py-20 lg:px-8 lg:py-24">
        <div className={`mx-auto grid grid-cols-1 gap-10 lg:gap-16 ${hasIntro ? "max-w-6xl lg:grid-cols-12" : "max-w-3xl"}`}>
          {hasIntro ? (
            <div className="lg:col-span-4">
              <div className="lg:sticky lg:top-8">
                {eyebrow ? <p className="text-sm font-semibold tracking-wide text-indigo-700 uppercase">{eyebrow}</p> : null}
                {heading ? <H className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl ${eyebrow ? "mt-3" : ""}`}>{heading}</H> : null}
                {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
              </div>
            </div>
          ) : null}

          <form action={formAction || undefined} method={formMethod === "post" ? "post" : "get"} className={`divide-y divide-neutral-200 rounded-2xl bg-neutral-50 ring-1 ring-neutral-200 ${hasIntro ? "lg:col-span-8" : ""}`}>
            <div className="p-6 sm:p-8">
              <label htmlFor={`${uid}-date`} className={legendClass}>
                <span aria-hidden="true" className={stepClass}>
                  {next()}
                </span>
                Visit date
              </label>
              <input
                id={`${uid}-date`}
                name="visit_date"
                type="date"
                required
                min={minDate}
                className="mt-3 block min-h-11 w-full rounded-lg border-0 bg-white px-3.5 py-2.5 text-base text-neutral-950 shadow-xs ring-1 ring-neutral-300 ring-inset focus:ring-2 focus:ring-indigo-600 focus:outline-none sm:max-w-xs"
              />
            </div>

            {times.length ? (
              <fieldset className="p-6 sm:p-8">
                <legend className="block">
                  <span className={legendClass}>
                    <span aria-hidden="true" className={stepClass}>
                      {next()}
                    </span>
                    Entry time
                  </span>
                </legend>
                <div className="mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3">
                  {times.map((s, i) => (
                    <label
                      key={`${s.time}-${i}`}
                      className={`relative flex min-h-16 flex-col justify-center rounded-xl px-4 py-3 ring-1 transition select-none ring-inset ${
                        s.soldOut
                          ? "cursor-not-allowed bg-neutral-100 text-neutral-600 ring-neutral-200"
                          : "cursor-pointer bg-white ring-neutral-300 hover:ring-indigo-400 has-checked:bg-indigo-50 has-checked:ring-2 has-checked:ring-indigo-600 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-indigo-600"
                      }`}
                    >
                      <input type="radio" name="entry_time" value={s.time} required disabled={s.soldOut} defaultChecked={i === firstOpen} className="sr-only" />
                      <span className={`text-base font-semibold tabular-nums ${s.soldOut ? "text-neutral-600 line-through" : "text-neutral-950"}`}>{s.time}</span>
                      {s.availability || s.soldOut ? <span className="text-sm leading-5 text-neutral-600">{s.soldOut ? s.availability || "Sold out" : s.availability}</span> : null}
                    </label>
                  ))}
                </div>
              </fieldset>
            ) : null}

            {types.length ? (
              <fieldset className="p-6 sm:p-8">
                <legend className="block">
                  <span className={legendClass}>
                    <span aria-hidden="true" className={stepClass}>
                      {next()}
                    </span>
                    Tickets
                  </span>
                </legend>
                <p id={`${uid}-qty-hint`} className="mt-1 text-sm leading-6 text-neutral-600">
                  Enter how many of each. Up to {max} per type.
                </p>
                <ul role="list" className="mt-4 divide-y divide-neutral-200 rounded-xl bg-white ring-1 ring-neutral-200">
                  {types.map((t, i) => {
                    const qid = `${uid}-qty-${i}`;
                    return (
                      <li key={`${t.name}-${i}`} className="flex items-center justify-between gap-4 px-4 py-3 sm:px-5">
                        <label htmlFor={qid} className="min-w-0 flex-1 cursor-pointer">
                          <span className="block text-base leading-6 font-semibold text-neutral-950">
                            {t.name}
                            {t.price ? <span className="ml-2 font-normal text-neutral-700 tabular-nums">{t.price}</span> : null}
                          </span>
                          {t.detail ? <span className="block text-sm leading-5 text-neutral-600">{t.detail}</span> : null}
                        </label>
                        <input
                          id={qid}
                          name={`qty_${fieldKey(t.name)}`}
                          type="number"
                          inputMode="numeric"
                          min="0"
                          max={max}
                          step="1"
                          defaultValue="0"
                          aria-describedby={`${uid}-qty-hint`}
                          className="block min-h-11 w-20 shrink-0 rounded-lg border-0 bg-white px-2 py-2 text-center text-base text-neutral-950 tabular-nums ring-1 ring-neutral-300 ring-inset focus:ring-2 focus:ring-indigo-600 focus:outline-none"
                        />
                      </li>
                    );
                  })}
                </ul>
              </fieldset>
            ) : null}

            {extras.length ? (
              <fieldset className="p-6 sm:p-8">
                <legend className="block">
                  <span className={legendClass}>
                    <span aria-hidden="true" className={stepClass}>
                      {next()}
                    </span>
                    Add-ons <span className="text-sm font-normal text-neutral-600">(optional)</span>
                  </span>
                </legend>
                <div className="mt-4 space-y-2">
                  {extras.map((a, i) => (
                    <label
                      key={`${a.name}-${i}`}
                      className="flex min-h-11 cursor-pointer items-start gap-3 rounded-xl bg-white px-4 py-3 ring-1 ring-neutral-200 transition ring-inset hover:ring-neutral-400 has-checked:ring-2 has-checked:ring-indigo-600"
                    >
                      <span className="flex h-6 items-center">
                        <input
                          type="checkbox"
                          name="addons"
                          value={fieldKey(a.name)}
                          className="size-5 rounded border-neutral-400 accent-indigo-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
                        />
                      </span>
                      <span className="min-w-0 flex-1 text-sm leading-6">
                        <span className="flex flex-wrap items-baseline justify-between gap-x-3">
                          <span className="font-semibold text-neutral-950">{a.name}</span>
                          {a.price ? <span className="text-neutral-700 tabular-nums">{a.price}</span> : null}
                        </span>
                        {a.detail ? <span className="block text-neutral-600">{a.detail}</span> : null}
                      </span>
                    </label>
                  ))}
                </div>
              </fieldset>
            ) : null}

            <div className="p-6 sm:p-8">
              <button
                type="submit"
                className="inline-flex min-h-12 w-full items-center justify-center gap-2 rounded-lg bg-indigo-600 px-6 py-3 text-base font-semibold text-white shadow-xs transition hover:bg-indigo-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
              >
                {submitLabel || "Continue to checkout"}
                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5">
                  <path fillRule="evenodd" d="M3 10a.75.75 0 0 1 .75-.75h10.64l-3.22-3.22a.75.75 0 1 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 1 1-1.06-1.06l3.22-3.22H3.75A.75.75 0 0 1 3 10Z" clipRule="evenodd" />
                </svg>
              </button>
              {policyNote ? <p className="mt-4 text-xs leading-5 text-pretty text-neutral-600">{policyNote}</p> : null}
            </div>
          </form>
        </div>
      </section>
    );
  },
};
```
