# BigSale HDLKiosk integration

This directory is the compatibility boundary between BigSale/SalesSDK and the
independent `components/HDLKiosk` material.

## Structure

- `index.tsx`: outer composition only; renders device owners, HDLKiosk and the
  embedded payment runtime.
- `hooks/`: template-level React hooks, including stable Host assembly, cart
  presentation, login-module registration and entry preparation feedback.
- `adapter/createHost.ts`: pure Host composition, capabilities and fulfillment
  writer.
- `utils/transactionState.ts`: derives only dispatch-time write/payment
  safety facts; UI receives raw order/catalog/customer fields through `sourceData`.
- `adapter/devicePort.ts`: raw BigSale device sources converted to HDLKiosk ports.
- `adapter/sales/index.ts`: Sales Port entry for direct session, identity,
  fulfillment and payment delegation.
- `adapter/sales/`: substantive catalog, cart and weighted-product modules.
- `utils/`: pure TypeScript helpers for transaction state, scale bridging,
  result normalization and primary weighted-product lookup.
- `BigSaleScaleRuntimeOwner.tsx`: the only React owner of the native
  scale Hook; publishes exclusively through ScaleBridge.
- `payment/`: payment runtime, EFTPOS execution, staff authorization and result
  normalization.
- `HDLKioskIdentityAuthPanel.tsx`: BigSale login/register UI integration.
- `tests/`: all tests and test-only fixtures, grouped by production concern.

## Boundary rules

1. Raw BigSale, SalesSDK and OS objects stop in this directory.
2. HDLKiosk Core receives only contracts from `components/HDLKiosk/app`.
3. UI reads `sourceData` directly; writes use explicit Host operations.
4. `readTransactionState()` is not a UI store. It exists only for a write or
   payment command to re-read current cart/payment/amount facts at dispatch.
5. React-owned capabilities are assembled in `hooks/useBigSaleHDLKioskAdapter`; do
   not add new controller refs to `index.tsx`.
6. Keep one-line delegation in `adapter/sales/index.ts`; split out only logic
   with its own projection, validation or mutation algorithm.
7. Keep production folders free of tests; all test files and fixtures belong
   under `tests/`.

## Catalog product details

Catalog card, cover and title clicks send `cart.addProduct` with `intent: 'detail'`.
The plus button omits the intent and keeps the existing add/selection decision.
`adapter/sales/cart.ts` maps a detail intent to SalesSdk `type: 'detail'` only for
products accepted by the shared `skuDetailModal/customerDetailPolicy`.
Bundles, booking/session and weighed products keep their existing route.

BigSale supplies the HDLKiosk template's default `resolveAppearance`, selecting
`immersive` for eligible products after hydration; explicit host appearance
settings take precedence. The shared modal uses its existing phone/desktop/Kiosk
layout settings and `flat` SKU selection, without changing the configured steps.
The adapter waits for confirmation and preserves cancellation and cart receipts.
Customization continues through `primaryProductOperations` with its prepared
selection data and is independent of this catalog intent.

## Main-product entry policy

The current merchant template explicitly sets `customizationReentryMode` to
`editExisting` and `anotherBowlEnabled` to `false`. A normal customization entry
edits the first configured primary product in the current cart's line order.
An explicit cart edit always uses the clicked line ID. With no primary line,
the customer selects and adds a product normally. In-flow edits proceed through
the workflow; explicit cart edits return to their source page.

The standalone HDLKiosk default remains `selectNew`. Other merchant integrations
can select that policy and enable `anotherBowlEnabled` to restore the retained
multi-bowl question and scale exchange flow. No bowl modal or exchange step is
removed. Disabling `anotherBowlEnabled` bypasses both the question and exchange,
including when an old scale measurement remains after removing a cart line.
