import { a as CartStore } from '../store-B6Oh5IPN.js'; export { C as CART_TTL_MS, c as createInMemoryCartStore } from '../store-B6Oh5IPN.js'; import { ShopProduct, CurrencyCode, ShopCart, ShopAddress } from '../types.js'; interface CartContext { store: CartStore; } interface AddItemInput { product: ShopProduct; variantId?: string; quantity?: number; /** Currency to price the item in. Must match an entry in priceByCurrency. */ currency: CurrencyCode; /** Locale to lock onto the cart on first item add. */ locale?: string; } declare function getOrCreateCart(ctx: CartContext, cartId: string | undefined, fallbackCurrency: CurrencyCode, locale?: string): Promise; declare function getCart(ctx: CartContext, cartId: string): Promise; declare function addItem(ctx: CartContext, cartId: string | undefined, input: AddItemInput): Promise; declare function updateItemQuantity(ctx: CartContext, cartId: string, productId: string, variantId: string | undefined, quantity: number): Promise; declare function removeItem(ctx: CartContext, cartId: string, productId: string, variantId?: string): Promise; declare function setShippingAddress(ctx: CartContext, cartId: string, address: ShopAddress): Promise; declare function setEmail(ctx: CartContext, cartId: string, email: string): Promise; declare function clearCart(ctx: CartContext, cartId: string): Promise; /** * F136 Phase 1 — Framework-agnostic cart HTTP handlers. * * Returns plain `Request → Response` functions so consumers can wire * them into Next.js Route Handlers, Hono, Fastify, or Bun.serve with * one line each. * * Cart id transport: `cms_shop_cart` cookie. The handler reads it on * every request, generates one on first add, and re-issues a Set-Cookie * so the client persists it. SameSite=Lax is the default — anything * stricter blocks Stripe Checkout's redirect-back flow. */ interface CartHandlerOptions { store: CartStore; /** * Resolve a product by id from the site's CMS. The shop module is * data-source agnostic so we don't import filesystem readers here — * the host wires this in. */ loadProduct(id: string): Promise; /** Called whenever a cart mutates — useful for analytics/abandonment. */ onCartChanged?(cartId: string): void; /** Cookie domain (default: omit, browser scopes to current host). */ cookieDomain?: string; /** Set Secure flag on the cookie (default: true in prod, false in dev). */ cookieSecure?: boolean; } interface CartHandlers { /** GET — returns the current cart (creates one if cookie missing). */ get(req: Request): Promise; /** POST { productId, variantId?, quantity?, currency, locale? }. */ add(req: Request): Promise; /** PATCH { productId, variantId?, quantity }. */ update(req: Request): Promise; /** DELETE { productId, variantId? }. */ remove(req: Request): Promise; /** POST { email } — captures email for abandonment + receipt. */ setEmail(req: Request): Promise; /** POST { address } — for shipping rate calc + checkout. */ setAddress(req: Request): Promise; /** DELETE — wipes the current cart. */ clear(req: Request): Promise; } declare function createCartHandlers(opts: CartHandlerOptions): CartHandlers; declare const CART_COOKIE_NAME = "cms_shop_cart"; export { type AddItemInput, CART_COOKIE_NAME, type CartContext, type CartHandlerOptions, type CartHandlers, CartStore, addItem, clearCart, createCartHandlers, getCart, getOrCreateCart, removeItem, setEmail, setShippingAddress, updateItemQuantity };