# BookingProductDetailModal

Prepared-only, controlled detail shell. This directory does not load products, register OS modules, calculate prices, assign Holders, add products or submit orders. Existing `skuDetailModal` consumers are unchanged.

The visual structure follows the current bigsales demo: bounded desktop panel, full-screen phone layout, one scrolling body and fixed title/actions. `CompensatedPisellContainer` owns portals, body-scale compensation and the same automatic layer stack as nested SKU OptionsModal. The local focus hook handles focus entry/return, Tab containment, top-layer Escape and background scroll. Nested SKU overlays remain above this shell; no explicit zIndex is exposed. Browser integration verification is still required.

## Preparing

The scoped host must finish its complete-detail request before setting `plan`. Keep the list loading/error/retry state outside the modal. Use `prepareProductDetailPlan` only after checking request generation, customer/menu/day scope and response identity.

```ts
const result = prepareProductDetailPlan({
  productDetail: completeProductData,
  requestedProductId: productId,
  completeness: 'complete',
  // Only if the actual endpoint guarantees omission means no group:
  missingGroupPolicy: 'absent-means-none',
  mode: 'ticket-booking', // or product-configuration
  openId, scopeKey, detailRevision, selectionKey,
  intent: 'create', // edit-draft forces preserve initialization
});
```

Results:

- `ready`: immutable `PreparedPlan`; the first screen has its final step structure.
- `no-configuration`: Party should continue its outside booking flow without opening a modal.
- `invalid`: structural/identity problems; do not turn these into an empty configuration.

The inspector retains the complete detail record and only normalizes the numeric `id`. Existing SKU Flow passes complete ProductData directly to the selector. Do not pick only `DataSource`'s declared fields: the runtime also needs variant `sku_ids`, inventory, bundle child fields, nested option groups and other source metadata. `transformOptionGroup`/`transformBundleGroup`/`transformVariantGroup` create selector JSX; they are not detail-fetch normalizers.

Choice inspection validates groups/items, required empty groups (including advanced minimum option types), variant item parent IDs and each variant's `sku_ids` mapping. Sparse combinations are allowed. Optional choices, existing defaults, sole-required choices and sold-out choices remain configuration. Explicitly disabled groups and their nested choices do not become choices; `status: 0` is not treated as disabled. Explicit empty arrays are not overridden by coarse is_variant/is_bundle flags. Missing arrays are rejected unless the caller opts into the endpoint's omission guarantee. Complete nested detail remains the loader's responsibility; this helper does not certify a partial DTO as complete.

## Controlled use

Import the component and types from this directory. `plan=null` closes/destroys the current session. Every opening gets a new `openId`; a different scope/revision/mode/selectionKey remounts the session. Do not mutate a plan while open.

```tsx
<BookingProductDetailModal
  plan={ticketPlan}
  title={productTitle}
  configuration={configuration}
  onConfigurationChange={setConfiguration}
  onCancel={() => setPlan(null)}
  locale="en"
  bookingReady={booking.ready}
  selectionRevision={booking.revision}
  renderBooking={({ configuration, busy, scrollContainer }) => (
    <BookingSelectionPanel
      configuration={configuration}
      disabled={busy}
      scrollContainer={scrollContainer}
    />
  )}
  footerContent={({ busy, step }) => (
    <HostQuantityAndPrice disabled={busy} step={step} />
  )}
  onConfirm={async (configuration, guard) => {
    await hostValidateCurrentSelection(configuration);
    if (!guard.isCurrent()) return false;
    await hostCommitCurrentSelection(configuration, guard.signal);
    setPlan(null);
  }}
/>
```

The panel above is illustrative; this shell does not define or import it. `TicketBookingContext` supplies the prepared ticket plan, controlled configuration, busy flag, scrolling body DOM node and `backToConfiguration()`. It is evaluated only in the Tickets booking step. The host owns candidate/resource state, same-group radio choices, unified-date actions and scroll-to-resource behavior.

`ConfigurationState = { skuValue, variantDraft }`. Apply both in the same parent update. The selector's change callback can run during default initialization. Keep the full result; `variantDraft` is session UI state and must not be serialized into an order.

Pass the host's resolved over-sold flag in `skuOptions.config.overSold`, and required-options policy in the separate `requiredOptionValidation` prop (default true). The beta SKU Flow may override product `over_sold` according to active sales settings. This shell gives explicit config priority, with product `over_sold` only as a fallback. A false required-options policy skips the selector's required-field validation; canonical serialization and the existing SKU structural/stock validator still apply, including a real chosen variant. The exported `validateBookingProductConfiguration` uses the same validator with only group required minima relaxed for this policy. Host-side final availability/price validation remains mandatory.

`refreshBookingProductConfiguration(product, skuValue, policy)` is a pure helper for quoting an existing selection against current complete detail. It retains only selected identities and quantities, reuses the selector's two-way serialization for current option/bundle price semantics, and rejects a changed selection fingerprint or changed bundle product identity. Both serializer inputs are explicit; it does not read the legacy selector store. This prevents saved order prices from overriding freshly loaded detail prices. Required-options policy is caller-owned; final submission must still perform its resolved required validation.

Tickets with configuration first validate and call `getTransformValues()`, report canonical configuration, optionally await `onConfigurationContinue`, then show the booking screen. Without configuration they begin on booking. Going back preserves both controlled values and uses `initializationPolicy="preserve"`; edit-draft also always preserves. No later detail request may change the step count.

Party props instead require `onConfigurationConfirm(configuration, guard)`. They forbid `renderBooking`, `bookingReady`, `onConfirm` and `onConfigurationContinue`. Party only mounts the SKU selector; after validation it returns the configuration without any booking effect or write. The outside Party controller retains date → main configuration → room → time.

Both callback modes resolve `false` to keep the session editable. Success resolves `void/true`, locks duplicate confirmation and expects the host to close with `plan=null`. Rejection shows a local generic error and calls optional `onError`. Host-specific explanations can be supplied through `error` or localized `labels`.

## Busy, cancellation and host guards

Cancel before confirmation only calls `onCancel`. During async validation/confirmation, interactive controls and close/back are blocked; cancellation cannot promise to undo an order write. Programmatic close or a new plan aborts the old signal and invalidates its callbacks. The host must check `guard.isCurrent()` immediately before mutation and implement its own order idempotency/unknown-result recovery.

For booking confirmation, changing `selectionRevision` invalidates the guard when date/time/resource/quantity/quote inputs change outside the shell. Configuration-next can legitimately refresh downstream state, so this revision is not a cancellation token for the configuration step. An external configuration change invalidates either mode; acknowledging the shell's canonical serialization does not. Changing the plan identity invalidates both modes.

`footerContent` receives mode, step, controlled configuration and busy; place the host's quantity and authoritative price here. Host-rendered inputs must honor busy. The shell never computes a subtotal or labels a preview as payment due. `labels.confirmBooking` can be changed for draft editing. `summary`, `getContainer`, `width`, `style` and `className` support host composition. CSS is scoped under `pisell-booking-product-detail-root`; color/surface tokens can be overridden there.

No Vitest/build/bundle was run for this directory. Source syntax and focused TypeScript diagnostics are the allowed static verification boundary; integration, long content, phone viewport and nested option dialogs need subsequent browser verification.
