@asteby/storefront-react 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context.tsx","../src/cookie.ts","../src/cart.tsx","../src/components.tsx","../src/variants.tsx","../src/seo.ts","../src/json-ld.tsx","../src/sections.tsx","../src/theme.tsx"],"names":["createContext","useMemo","createStorefrontClient","jsx","useContext","isStorefrontError","useRef","useState","useCallback","p","useEffect","formatMoney","createElement","parseMoney","jsxs","Fragment"],"mappings":";;;;;;;AAaA,IAAM,iBAAA,GAAoBA,oBAA6C,IAAI,CAAA;AAkBpE,SAAS,kBAAA,CAAmB,EAAE,MAAA,EAAQ,MAAA,EAAQ,OAAO,IAAA,EAAM,MAAA,EAAQ,QAAA,EAAU,QAAA,EAAS,EAA4B;AACvH,EAAA,MAAM,YAAY,MAAA,GAAS,CAAA,EAAG,MAAA,CAAO,OAAO,IAAI,MAAA,CAAO,KAAK,CAAA,CAAA,EAAI,MAAA,CAAO,UAAU,EAAE,CAAA,CAAA,EAAI,MAAA,CAAO,aAAA,IAAiB,EAAE,CAAA,CAAA,GAAK,EAAA;AACtH,EAAA,MAAM,cAAA,GAAiBC,aAAA;AAAA,IACrB,MAAM,MAAA,KAAW,MAAA,GAASC,iCAAA,CAAuB,MAAM,CAAA,GAAI,IAAA,CAAA;AAAA,IAC3D,CAAC,QAAQ,SAAS;AAAA,GACpB;AACA,EAAA,MAAM,KAAA,GAAQD,aAAA;AAAA,IACZ,OAAO;AAAA,MACL,MAAA,EAAQ,cAAA;AAAA,MACR,IAAA;AAAA,MACA,MAAA,EAAQ,MAAA,IAAU,MAAA,EAAQ,MAAA,IAAU,MAAM,MAAA,IAAU,OAAA;AAAA,MACpD,QAAA,EAAU,QAAA,IAAY,IAAA,EAAM,aAAA,IAAiB;AAAA,KAC/C,CAAA;AAAA,IACA,CAAC,cAAA,EAAgB,IAAA,EAAM,MAAA,E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,IAAA,CAAK,GAAG,CAAC,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAC7H,EAAA,OAAO,qCAAqC,MAAM,CAAA,aAAA,CAAA;AACpD;AASO,SAAS,UAAA,CAAW,EAAE,KAAA,EAAO,KAAA,EAAO,KAAK,kBAAA,EAAoB,GAAG,SAAQ,EAAoB;AACjG,EAAA,MAAM,GAAA,GAAM,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA;AACrC,EAAA,IAAI,CAAC,KAAK,OAAO,IAAA;AACjB,EAAA,uBAAOA,cAAAA,CAAC,OAAA,EAAA,EAAM,EAAA,EAAQ,KAAA,EAAc,uBAAA,EAAsB,EAAA,EAAG,uBAAA,EAAyB,EAAE,MAAA,EAAQ,GAAA,EAAI,EAAG,CAAA;AACzG","file":"index.cjs","sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport { createStorefrontClient, type Shop, type StorefrontClient, type StorefrontClientOptions } from '@asteby/storefront'\n\nexport type StorefrontContextValue = {\n /** Client for browser-side calls (use a public `pk_` token). */\n client: StorefrontClient | null\n shop: Shop | null\n /** BCP 47 locale used for formatting (defaults to `shop.locale`, then `es-MX`). */\n locale: string\n /** ISO 4217 currency (defaults to `shop.currency_code`, then `MXN`). */\n currency: string\n}\n\nconst StorefrontContext = createContext<StorefrontContextValue | null>(null)\n\nexport type StorefrontProviderProps = {\n /** A ready client. Takes precedence over `config`. */\n client?: StorefrontClient\n /** Options to create the browser client (use a `pk_` token). */\n config?: StorefrontClientOptions\n /** Shop info loaded on the server (root loader). */\n shop?: Shop | null\n locale?: string\n currency?: string\n children?: ReactNode\n}\n\n/**\n * Makes the storefront client, shop, locale and currency available to the\n * tree. SSR-safe: creating the client does not touch `window`.\n */\nexport function StorefrontProvider({ client, config, shop = null, locale, currency, children }: StorefrontProviderProps) {\n const configKey = config ? `${config.baseUrl}|${config.token}|${config.locale ?? ''}|${config.customerToken ?? ''}` : ''\n const resolvedClient = useMemo(\n () => client ?? (config ? createStorefrontClient(config) : null),\n [client, configKey],\n )\n const value = useMemo<StorefrontContextValue>(\n () => ({\n client: resolvedClient,\n shop,\n locale: locale ?? config?.locale ?? shop?.locale ?? 'es-MX',\n currency: currency ?? shop?.currency_code ?? 'MXN',\n }),\n [resolvedClient, shop, locale, currency, config?.locale],\n )\n return <StorefrontContext.Provider value={value}>{children}</StorefrontContext.Provider>\n}\n\n/** Storefront context. Throws outside `<StorefrontProvider>`. */\nexport function useStorefront(): StorefrontContextValue {\n const ctx = useContext(StorefrontContext)\n if (!ctx) throw new Error('useStorefront must be used inside <StorefrontProvider>')\n return ctx\n}\n\n/** Storefront context or `null` outside a provider (for components that work standalone). */\nexport function useOptionalStorefront(): StorefrontContextValue | null {\n return useContext(StorefrontContext)\n}\n\n/** The client from context; throws when the provider has none. */\nexport function useStorefrontClient(): StorefrontClient {\n const { client } = useStorefront()\n if (!client) throw new Error('<StorefrontProvider> needs a `client` or `config` for browser-side calls')\n return client\n}\n","/** Default name of the cookie that holds the cart id. */\nexport const CART_COOKIE_NAME = 'sf_cart'\n\nexport type CartCookieOptions = {\n /** Cookie name (default `sf_cart`). */\n name?: string\n /** Lifetime in days (default 30). */\n maxAgeDays?: number\n path?: string\n domain?: string\n sameSite?: 'Lax' | 'Strict' | 'None'\n /** Defaults to true on https pages / when `sameSite` is `None`. */\n secure?: boolean\n}\n\n/**\n * Reads the cart id from a `Cookie` header. Use it in SSR loaders:\n * `getCartIdFromCookie(request.headers.get('Cookie'))`.\n */\nexport function getCartIdFromCookie(cookieHeader: string | null | undefined, name: string = CART_COOKIE_NAME): string | null {\n if (!cookieHeader) return null\n for (const part of cookieHeader.split(';')) {\n const eq = part.indexOf('=')\n if (eq < 0) continue\n if (part.slice(0, eq).trim() !== name) continue\n const raw = part.slice(eq + 1).trim().replace(/^\"(.*)\"$/, '$1')\n if (!raw) return null\n try {\n return decodeURIComponent(raw)\n } catch {\n return raw\n }\n }\n return null\n}\n\n/**\n * Serializes the cart cookie for a `Set-Cookie` header (SSR actions) or for\n * `document.cookie`. Pass `null` to clear it.\n */\nexport function serializeCartCookie(cartId: string | null, options: CartCookieOptions = {}): string {\n const name = options.name ?? CART_COOKIE_NAME\n const parts = [`${name}=${cartId ? encodeURIComponent(cartId) : ''}`]\n parts.push(`Path=${options.path ?? '/'}`)\n const maxAge = cartId ? Math.round((options.maxAgeDays ?? 30) * 86_400) : 0\n parts.push(`Max-Age=${maxAge}`)\n if (options.domain) parts.push(`Domain=${options.domain}`)\n const sameSite = options.sameSite ?? 'Lax'\n parts.push(`SameSite=${sameSite}`)\n if (options.secure ?? sameSite === 'None') parts.push('Secure')\n return parts.join('; ')\n}\n\n/** Browser-only: writes the cart cookie. No-op on the server. */\nexport function writeCartCookie(cartId: string | null, options: CartCookieOptions = {}): void {\n if (typeof document === 'undefined') return\n const secure = options.secure ?? (typeof location !== 'undefined' && location.protocol === 'https:')\n document.cookie = serializeCartCookie(cartId, { ...options, secure })\n}\n\n/** Browser-only: reads the cart cookie. `null` on the server. */\nexport function readCartCookie(name: string = CART_COOKIE_NAME): string | null {\n if (typeof document === 'undefined') return null\n return getCartIdFromCookie(document.cookie, name)\n}\n","import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport {\n isStorefrontError,\n type AddressInput,\n type Cart,\n type CartBuyerInput,\n type CartLine,\n type CartLineInput,\n type CartLineMerchandise,\n type CartLineUpdateInput,\n type DeliveryInput,\n type DeliveryOptions,\n type Money,\n type StorefrontClient,\n} from '@asteby/storefront'\nimport { useOptionalStorefront } from './context.js'\nimport { CART_COOKIE_NAME, readCartCookie, writeCartCookie, type CartCookieOptions } from './cookie.js'\n\nexport type CartLineAddInput = CartLineInput & {\n /** Variant data for an instant optimistic line (otherwise only the count updates until the server answers). */\n merchandise?: CartLineMerchandise\n}\n\nexport type CartStatus = 'idle' | 'loading' | 'updating'\n\nexport type CartContextValue = {\n cart: Cart | null\n cartId: string | null\n status: CartStatus\n /** Last mutation error (cleared on the next successful mutation). */\n error: Error | null\n totalQuantity: number\n /** Adds lines, creating the cart on first use. Optimistic. */\n addLines: (lines: CartLineAddInput[]) => Promise<Cart | null>\n /** Sets line quantities (`0` removes). Optimistic. */\n updateLines: (lines: CartLineUpdateInput[]) => Promise<Cart | null>\n /** Removes lines. Optimistic. */\n removeLines: (lineIds: string[]) => Promise<Cart | null>\n setDiscountCodes: (codes: string[]) => Promise<Cart | null>\n setBuyer: (buyer: CartBuyerInput) => Promise<Cart | null>\n setShippingAddress: (address: AddressInput) => Promise<Cart | null>\n setDelivery: (delivery: DeliveryInput) => Promise<Cart | null>\n deliveryOptions: () => Promise<DeliveryOptions | null>\n /** Reloads the cart from the API. */\n refresh: () => Promise<Cart | null>\n /** Forgets the cart (clears state and cookie), e.g. after checkout. */\n clear: () => void\n}\n\nconst CartContext = createContext<CartContextValue | null>(null)\n\nexport type CartProviderProps = {\n /** Cart loaded in the SSR loader (hydrates without a client fetch). */\n initialCart?: Cart | null\n /** Cart id known on the server when `initialCart` is not loaded. */\n cartId?: string | null\n /** Client override (defaults to the `StorefrontProvider` client). */\n client?: StorefrontClient\n /** Cookie settings for the persisted cart id (`sf_cart`). Pass `false` to disable the cookie. */\n cookie?: CartCookieOptions | false\n /** Currency for the optimistic placeholder cart (defaults to the provider currency). */\n currency?: string\n onError?: (error: Error) => void\n onCartChange?: (cart: Cart | null) => void\n children?: ReactNode\n}\n\ntype PendingOp = { id: number; apply: (cart: Cart | null) => Cart | null }\n\nconst toCents = (m: Money | null | undefined) => (m ? Math.round(Number.parseFloat(m.amount) * 100) : 0)\nconst money = (cents: number, currency: string): Money => ({ amount: (cents / 100).toFixed(2), currency_code: currency })\n\nfunction emptyCart(currency: string): Cart {\n const zero = money(0, currency)\n return {\n id: '',\n lines: [],\n total_quantity: 0,\n discount_codes: [],\n buyer: { email: null, phone: null, customer_id: null },\n shipping_address: null,\n delivery: { method: null, rate_id: null, branch_id: null },\n cost: { subtotal: zero, discount: zero, shipping: null, tax: null, total: zero, tax_included: true },\n updated_at: new Date(0).toISOString(),\n }\n}\n\nfunction withLines(cart: Cart, lines: CartLine[], totalQuantity?: number): Cart {\n const currency = cart.cost.subtotal.currency_code\n const subtotal = lines.reduce((sum, l) => sum + toCents(l.cost.total), 0)\n const total = Math.max(0, subtotal - toCents(cart.cost.discount) + toCents(cart.cost.shipping))\n return {\n ...cart,\n lines,\n total_quantity: totalQuantity ?? lines.reduce((sum, l) => sum + l.quantity, 0),\n cost: { ...cart.cost, subtotal: money(subtotal, currency), total: money(total, currency) },\n }\n}\n\nfunction lineWithQuantity(line: CartLine, quantity: number): CartLine {\n const unit = toCents(line.cost.unit)\n return { ...line, quantity, cost: { ...line.cost, total: money(unit * quantity, line.cost.unit.currency_code) } }\n}\n\n/** Pure optimistic reducers (exported for tests and custom carts). */\nexport const optimisticCart = {\n add(cart: Cart | null, input: CartLineAddInput[], currency: string): Cart {\n const base = cart ?? emptyCart(currency)\n let lines = base.lines.slice()\n let unknownQuantity = 0\n for (const l of input) {\n const idx = lines.findIndex((x) => x.merchandise.id === l.variant_id)\n if (idx >= 0) lines[idx] = lineWithQuantity(lines[idx]!, lines[idx]!.quantity + l.quantity)\n else if (l.merchandise) {\n const unit = l.merchandise.price\n lines.push({\n id: `optimistic:${l.variant_id}`,\n quantity: l.quantity,\n merchandise: l.merchandise,\n cost: { unit, compare_at_unit: l.merchandise.compare_at_price, total: money(toCents(unit) * l.quantity, unit.currency_code) },\n })\n } else unknownQuantity += l.quantity\n }\n const known = lines.reduce((sum, l) => sum + l.quantity, 0)\n return withLines(base, lines, known + unknownQuantity + (base.total_quantity - base.lines.reduce((s, l) => s + l.quantity, 0)))\n },\n update(cart: Cart | null, input: CartLineUpdateInput[]): Cart | null {\n if (!cart) return cart\n const byId = new Map(input.map((l) => [l.id, l.quantity]))\n const lines = cart.lines\n .map((l) => (byId.has(l.id) ? lineWithQuantity(l, byId.get(l.id)!) : l))\n .filter((l) => l.quantity > 0)\n return withLines(cart, lines)\n },\n remove(cart: Cart | null, lineIds: string[]): Cart | null {\n if (!cart) return cart\n return withLines(cart, cart.lines.filter((l) => !lineIds.includes(l.id)))\n },\n}\n\nconst isNotFound = (err: unknown) => isStorefrontError(err) && err.status === 404\n\n/**\n * Holds the cart and exposes optimistic mutations. Mutations run one at a\n * time in order; a failed one is rolled back without discarding the others.\n * The cart id is persisted in the `sf_cart` cookie (read it in loaders with\n * `getCartIdFromCookie`). No `window`/`document` access during render.\n */\nexport function CartProvider({\n initialCart = null,\n cartId: initialCartId = null,\n client: clientProp,\n cookie,\n currency: currencyProp,\n onError,\n onCartChange,\n children,\n}: CartProviderProps) {\n const sf = useOptionalStorefront()\n const client = clientProp ?? sf?.client ?? null\n const currency = currencyProp ?? initialCart?.cost.subtotal.currency_code ?? sf?.currency ?? 'MXN'\n const cookieOptions = cookie === false ? null : (cookie ?? {})\n\n const confirmedRef = useRef<Cart | null>(initialCart)\n const pendingRef = useRef<PendingOp[]>([])\n const idRef = useRef<string | null>(initialCart?.id ?? initialCartId ?? null)\n const queueRef = useRef<Promise<unknown>>(Promise.resolve())\n const seqRef = useRef(0)\n const callbacks = useRef({ onError, onCartChange })\n callbacks.current = { onError, onCartChange }\n\n const [cart, setCart] = useState<Cart | null>(initialCart)\n const [cartId, setCartId] = useState<string | null>(idRef.current)\n const [pending, setPending] = useState(0)\n const [loading, setLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const render = useCallback(() => {\n const next = pendingRef.current.reduce<Cart | null>((acc, op) => op.apply(acc), confirmedRef.current)\n setCart(next)\n }, [])\n\n const persistId = useCallback(\n (id: string | null) => {\n if (idRef.current === id) return\n idRef.current = id\n setCartId(id)\n if (cookieOptions) writeCartCookie(id, cookieOptions)\n },\n // cookieOptions is a plain options bag; its identity is irrelevant\n [cookie === false, cookieOptions?.name],\n )\n\n const confirm = useCallback(\n (next: Cart | null) => {\n confirmedRef.current = next\n if (next) persistId(next.id)\n callbacks.current.onCartChange?.(next)\n },\n [persistId],\n )\n\n const requireClient = useCallback((): StorefrontClient => {\n if (!client) throw new Error('CartProvider needs a client: pass `client` or wrap it in <StorefrontProvider config|client>')\n return client\n }, [client])\n\n /** Queues a remote mutation with an optional optimistic layer. */\n const mutate = useCallback(\n <T,>(remote: (c: StorefrontClient) => Promise<T>, toCart: (r: T) => Cart | null, optimistic?: PendingOp['apply']): Promise<T | null> => {\n const op: PendingOp | null = optimistic ? { id: ++seqRef.current, apply: optimistic } : null\n if (op) {\n pendingRef.current = [...pendingRef.current, op]\n render()\n }\n setPending((n) => n + 1)\n const run = async (): Promise<T | null> => {\n try {\n const result = await remote(requireClient())\n const next = toCart(result)\n if (next) confirm(next)\n setError(null)\n return result\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err))\n setError(e)\n callbacks.current.onError?.(e)\n return null\n } finally {\n if (op) pendingRef.current = pendingRef.current.filter((p) => p !== op)\n render()\n setPending((n) => n - 1)\n }\n }\n const p = queueRef.current.then(run, run)\n queueRef.current = p\n return p\n },\n [confirm, render, requireClient],\n )\n\n const asCart = (c: Cart) => c\n\n // Hydrate from the cookie / id on the client when the server did not load the cart.\n useEffect(() => {\n if (confirmedRef.current) {\n if (cookieOptions && idRef.current) writeCartCookie(idRef.current, cookieOptions)\n return\n }\n const id = idRef.current ?? (cookieOptions ? readCartCookie(cookieOptions.name ?? CART_COOKIE_NAME) : null)\n if (!id || !client) return\n idRef.current = id\n setCartId(id)\n let cancelled = false\n setLoading(true)\n client.carts\n .get(id)\n .then((loaded) => {\n if (cancelled) return\n if (loaded) confirm(loaded)\n else persistId(null)\n render()\n })\n .catch((err: unknown) => {\n if (cancelled) return\n const e = err instanceof Error ? err : new Error(String(err))\n setError(e)\n callbacks.current.onError?.(e)\n })\n .finally(() => !cancelled && setLoading(false))\n return () => {\n cancelled = true\n }\n // Runs once on mount.\n }, [])\n\n const value = useMemo<CartContextValue>(() => {\n const withId = <T,>(fn: (c: StorefrontClient, id: string) => Promise<T>) => async (c: StorefrontClient) => {\n if (!idRef.current) throw new Error('No cart yet: add a line first')\n return fn(c, idRef.current)\n }\n return {\n cart,\n cartId,\n status: loading ? 'loading' : pending > 0 ? 'updating' : 'idle',\n error,\n totalQuantity: cart?.total_quantity ?? 0,\n addLines: (lines) => {\n const payload = lines.map(({ variant_id, quantity }) => ({ variant_id, quantity }))\n return mutate(\n async (c) => {\n if (!idRef.current) return c.carts.create({ lines: payload })\n try {\n return await c.carts.addLines(idRef.current, payload)\n } catch (err) {\n // Expired or unknown cart: start a new one.\n if (isNotFound(err)) return c.carts.create({ lines: payload })\n throw err\n }\n },\n asCart,\n (current) => optimisticCart.add(current, lines, currency),\n )\n },\n updateLines: (lines) => mutate(withId((c, id) => c.carts.updateLines(id, lines)), asCart, (current) => optimisticCart.update(current, lines)),\n removeLines: (lineIds) => mutate(withId((c, id) => c.carts.removeLines(id, lineIds)), asCart, (current) => optimisticCart.remove(current, lineIds)),\n setDiscountCodes: (codes) => mutate(withId((c, id) => c.carts.setDiscountCodes(id, codes)), asCart),\n setBuyer: (buyer) => mutate(withId((c, id) => c.carts.setBuyer(id, buyer)), asCart),\n setShippingAddress: (address) => mutate(withId((c, id) => c.carts.setShippingAddress(id, address)), asCart),\n setDelivery: (delivery) => mutate(withId((c, id) => c.carts.setDelivery(id, delivery)), asCart),\n deliveryOptions: () => mutate(withId((c, id) => c.carts.deliveryOptions(id)), () => null),\n refresh: () =>\n mutate(\n async (c) => (idRef.current ? c.carts.get(idRef.current) : null),\n (r) => {\n if (r === null) {\n confirmedRef.current = null\n persistId(null)\n }\n return r\n },\n ),\n clear: () => {\n confirmedRef.current = null\n pendingRef.current = []\n persistId(null)\n render()\n callbacks.current.onCartChange?.(null)\n },\n }\n }, [cart, cartId, loading, pending, error, mutate, currency, persistId, render])\n\n return <CartContext.Provider value={value}>{children}</CartContext.Provider>\n}\n\n/** Cart state and actions. Throws outside `<CartProvider>`. */\nexport function useCart(): CartContextValue {\n const ctx = useContext(CartContext)\n if (!ctx) throw new Error('useCart must be used inside <CartProvider>')\n return ctx\n}\n\n/** Cart context or `null` outside a provider. */\nexport function useOptionalCart(): CartContextValue | null {\n return useContext(CartContext)\n}\n","import { createElement, type ComponentPropsWithoutRef, type ElementType, type ReactNode } from 'react'\nimport { formatMoney, parseMoney, type FormatMoneyOptions, type Image as ImageData, type Money as MoneyData, type Product, type ProductVariant } from '@asteby/storefront'\nimport { useOptionalStorefront } from './context.js'\n\n// ---------------------------------------------------------------------------\n// Money\n// ---------------------------------------------------------------------------\n\nexport type MoneyProps<As extends ElementType = 'span'> = FormatMoneyOptions & {\n data: MoneyData\n /** Element to render (default `span`). */\n as?: As\n /** Overrides the provider locale. */\n locale?: string\n} & Omit<ComponentPropsWithoutRef<As>, 'children' | 'as'>\n\n/** Formats `Money` with the provider locale (or `locale`). */\nexport function Money<As extends ElementType = 'span'>({\n data,\n as,\n locale,\n withoutTrailingZeros,\n withoutCurrency,\n currencyDisplay,\n ...rest\n}: MoneyProps<As>) {\n const sf = useOptionalStorefront()\n const text = formatMoney(data, locale ?? sf?.locale, {\n ...(withoutTrailingZeros !== undefined ? { withoutTrailingZeros } : {}),\n ...(withoutCurrency !== undefined ? { withoutCurrency } : {}),\n ...(currencyDisplay !== undefined ? { currencyDisplay } : {}),\n })\n return createElement(as ?? 'span', rest, text)\n}\n\n// ---------------------------------------------------------------------------\n// Image\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_IMAGE_WIDTHS = [320, 480, 640, 768, 1024, 1280, 1600] as const\n\n/** Builds the URL for one srcset width. */\nexport type ImageLoader = (src: string, width: number, height?: number) => string\n\n/**\n * Default loader: adds `?width=<w>` (the convention of most image CDNs and of\n * the OPS image proxy). URLs that cannot be parsed are returned unchanged.\n */\nexport const defaultImageLoader: ImageLoader = (src, width, height) => {\n try {\n const isAbsolute = /^[a-z][a-z0-9+.-]*:/i.test(src)\n const url = new URL(src, 'http://relative.invalid')\n url.searchParams.set('width', String(width))\n if (height) url.searchParams.set('height', String(height))\n return isAbsolute ? url.toString() : url.pathname + url.search + url.hash\n } catch {\n return src\n }\n}\n\nexport type ImageProps = Omit<ComponentPropsWithoutRef<'img'>, 'src' | 'srcSet' | 'width' | 'height'> & {\n data: ImageData\n /** `sizes` attribute (default `100vw`). */\n sizes?: string\n /** Candidate widths for `srcset` (capped at the intrinsic width when known). */\n widths?: readonly number[]\n /** URL builder per width (default adds `?width=`). Pass `null` to disable srcset. */\n loader?: ImageLoader | null\n /** Above-the-fold image: eager loading and `fetchpriority=\"high\"`. */\n priority?: boolean\n /** Forces an aspect ratio, e.g. `1/1` or `4/3`, used for width/height and srcset heights. */\n aspectRatio?: string\n}\n\nfunction parseRatio(ratio: string | undefined): number | null {\n if (!ratio) return null\n const [w, h] = ratio.split(/[/:]/).map((n) => Number.parseFloat(n))\n return w && h ? w / h : null\n}\n\n/** Responsive `<img>` with `srcset`, lazy by default, intrinsic size to avoid layout shift. */\nexport function Image({\n data,\n sizes = '100vw',\n widths = DEFAULT_IMAGE_WIDTHS,\n loader = defaultImageLoader,\n priority = false,\n aspectRatio,\n alt,\n loading,\n decoding,\n ...rest\n}: ImageProps) {\n const ratio = parseRatio(aspectRatio) ?? (data.width && data.height ? data.width / data.height : null)\n let candidates = [...widths].sort((a, b) => a - b)\n if (data.width) {\n const capped = candidates.filter((w) => w <= data.width!)\n candidates = capped.length ? capped : [data.width]\n }\n const srcSet = loader\n ? candidates.map((w) => `${loader(data.url, w, ratio ? Math.round(w / ratio) : undefined)} ${w}w`).join(', ')\n : undefined\n const width = data.width ?? candidates[candidates.length - 1]\n const height = data.height ?? (ratio && width ? Math.round(width / ratio) : undefined)\n return (\n <img\n src={data.url}\n alt={alt ?? data.alt ?? ''}\n {...(srcSet ? { srcSet, sizes } : {})}\n {...(width ? { width } : {})}\n {...(height ? { height } : {})}\n loading={loading ?? (priority ? 'eager' : 'lazy')}\n decoding={decoding ?? (priority ? 'auto' : 'async')}\n {...(priority ? { fetchPriority: 'high' as const } : {})}\n {...rest}\n />\n )\n}\n\n// ---------------------------------------------------------------------------\n// ProductPrice\n// ---------------------------------------------------------------------------\n\nconst VISUALLY_HIDDEN = {\n position: 'absolute',\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n border: 0,\n} as const\n\nexport type ProductPriceProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'> & {\n product?: Pick<Product, 'price_range' | 'compare_at_price_range'> | null\n variant?: Pick<ProductVariant, 'price' | 'compare_at_price'> | null\n /** Prefix shown when the product has a price range and no variant is selected (default `Desde`). */\n fromLabel?: ReactNode\n /** Accessible label for the compare-at price (default `Precio anterior`). */\n compareAtLabel?: string\n locale?: string\n withoutTrailingZeros?: boolean\n}\n\n/**\n * Price with optional compare-at (strikethrough). With a `variant` it shows\n * that variant; otherwise the product's minimum price (prefixed with\n * `fromLabel` when prices vary).\n */\nexport function ProductPrice({\n product,\n variant,\n fromLabel = 'Desde',\n compareAtLabel = 'Precio anterior',\n locale,\n withoutTrailingZeros,\n ...rest\n}: ProductPriceProps) {\n let price: MoneyData | null = null\n let compareAt: MoneyData | null = null\n let isRange = false\n if (variant) {\n price = variant.price\n compareAt = variant.compare_at_price\n } else if (product) {\n price = product.price_range.min\n compareAt = product.compare_at_price_range?.min ?? null\n isRange = product.price_range.min.amount !== product.price_range.max.amount\n }\n if (!price) return null\n const onSale = compareAt !== null && parseMoney(compareAt) > parseMoney(price)\n const opts = { ...(locale ? { locale } : {}), ...(withoutTrailingZeros !== undefined ? { withoutTrailingZeros } : {}) }\n return (\n <div data-on-sale={onSale || undefined} {...rest}>\n {isRange ? <span data-price-prefix=\"\">{fromLabel} </span> : null}\n <Money data={price} data-price=\"\" {...opts} />\n {onSale && compareAt ? (\n <>\n {' '}\n <s data-compare-at-price=\"\">\n <span style={VISUALLY_HIDDEN}>{compareAtLabel}: </span>\n <Money data={compareAt} {...opts} />\n </s>\n </>\n ) : null}\n </div>\n )\n}\n","import { Fragment, useCallback, useMemo, useRef, useState, type ComponentPropsWithoutRef, type ReactNode } from 'react'\nimport type { CartLineMerchandise, Product, ProductVariant } from '@asteby/storefront'\nimport { useCart } from './cart.js'\n\nexport type ProductOptionValueState = {\n value: string\n /** Part of the current selection. */\n selected: boolean\n /** A variant with this value (and the other selected options) exists. */\n exists: boolean\n /** That variant is available for sale. */\n available: boolean\n /** The variant this value would select, if it exists. */\n variant: ProductVariant | null\n /** Query string (`?Talla=M&Color=Rojo`) selecting this value, preserving other params. */\n search: string\n}\n\nexport type ProductOptionState = { name: string; values: ProductOptionValueState[] }\n\nexport type ProductOptionsState = {\n options: ProductOptionState[]\n selectedOptions: Record<string, string>\n /** Variant matching every selected option, or `null` while incomplete. */\n selectedVariant: ProductVariant | null\n setOption: (name: string, value: string) => void\n}\n\nexport type UseProductOptionsConfig = {\n /** Current URL search params; option names are read as keys (`?Talla=M`), plus `variant=<id>`. */\n searchParams?: URLSearchParams | string | null\n /** Select the first available variant when nothing is in the URL (default true). */\n defaultToFirstAvailable?: boolean\n onChange?: (variant: ProductVariant | null, selectedOptions: Record<string, string>) => void\n}\n\ntype ProductLike = Pick<Product, 'options' | 'variants'> & { id?: string }\n\nfunction toParams(input: URLSearchParams | string | null | undefined): URLSearchParams {\n if (!input) return new URLSearchParams()\n return input instanceof URLSearchParams ? new URLSearchParams(input) : new URLSearchParams(input)\n}\n\nfunction optionsOf(variant: ProductVariant): Record<string, string> {\n return Object.fromEntries(variant.selected_options.map((o) => [o.name, o.value]))\n}\n\nfunction findVariant(product: ProductLike, selection: Record<string, string>): ProductVariant | null {\n if (product.options.length === 0) return product.variants[0] ?? null\n return (\n product.variants.find((v) => v.selected_options.length > 0 && v.selected_options.every((o) => selection[o.name] === o.value)) ?? null\n )\n}\n\nfunction initialSelection(product: ProductLike, params: URLSearchParams, defaultToFirstAvailable: boolean): Record<string, string> {\n const byId = params.get('variant')\n const fromId = byId ? product.variants.find((v) => v.id === byId) : undefined\n if (fromId) return optionsOf(fromId)\n const selection: Record<string, string> = {}\n for (const opt of product.options) {\n const v = params.get(opt.name)\n if (v !== null && opt.values.includes(v)) selection[opt.name] = v\n }\n if (Object.keys(selection).length === 0 && defaultToFirstAvailable) {\n const first = product.variants.find((v) => v.available_for_sale) ?? product.variants[0]\n return first ? optionsOf(first) : {}\n }\n return selection\n}\n\n/**\n * Option → values matrix with availability, the selected variant (from the\n * URL or local state) and links for each value. Pure React: works in SSR.\n */\nexport function useProductOptions(product: ProductLike, config: UseProductOptionsConfig = {}): ProductOptionsState {\n const { defaultToFirstAvailable = true, onChange } = config\n const params = useMemo(() => toParams(config.searchParams), [String(config.searchParams ?? '')])\n const sourceKey = `${product.id ?? ''}|${params.toString()}`\n const fromSource = useMemo(\n () => initialSelection(product, params, defaultToFirstAvailable),\n // product identity is keyed by id + params\n [sourceKey, defaultToFirstAvailable],\n )\n\n // Local selection overrides the URL until the URL (or product) changes.\n const [local, setLocal] = useState<{ key: string; selection: Record<string, string> } | null>(null)\n const selectedOptions = local && local.key === sourceKey ? local.selection : fromSource\n\n const onChangeRef = useRef(onChange)\n onChangeRef.current = onChange\n\n const setOption = useCallback(\n (name: string, value: string) => {\n const next = { ...selectedOptions, [name]: value }\n setLocal({ key: sourceKey, selection: next })\n onChangeRef.current?.(findVariant(product, next), next)\n },\n [selectedOptions, sourceKey, product],\n )\n\n const selectedVariant = useMemo(() => findVariant(product, selectedOptions), [product, selectedOptions])\n\n const options = useMemo<ProductOptionState[]>(\n () =>\n product.options.map((opt) => ({\n name: opt.name,\n values: opt.values.map((value) => {\n const candidate = { ...selectedOptions, [opt.name]: value }\n const exact = findVariant(product, candidate)\n // When other options are not chosen yet, availability = any available variant with this value.\n const loose = product.variants.filter((v) => v.selected_options.some((o) => o.name === opt.name && o.value === value))\n const search = new URLSearchParams(params)\n search.delete('variant')\n for (const [k, v] of Object.entries(candidate)) search.set(k, v)\n return {\n value,\n selected: selectedOptions[opt.name] === value,\n exists: exact ? true : loose.length > 0 && Object.keys(selectedOptions).length < product.options.length,\n available: exact ? exact.available_for_sale : Object.keys(selectedOptions).length < product.options.length && loose.some((v) => v.available_for_sale),\n variant: exact,\n search: `?${search.toString()}`,\n }\n }),\n })),\n [product, selectedOptions, params],\n )\n\n return { options, selectedOptions, selectedVariant, setOption }\n}\n\nexport type VariantSelectorRenderProps = {\n option: ProductOptionState\n selectedVariant: ProductVariant | null\n selectedOptions: Record<string, string>\n setOption: (name: string, value: string) => void\n}\n\nexport type VariantSelectorProps = UseProductOptionsConfig & {\n product: ProductLike\n /** Called once per option; render the buttons/links for `option.values`. */\n children: (props: VariantSelectorRenderProps) => ReactNode\n}\n\n/**\n * Render-prop variant picker. Example:\n *\n * <VariantSelector product={product} searchParams={searchParams}>\n * {({ option }) => (\n * <fieldset>\n * <legend>{option.name}</legend>\n * {option.values.map((v) => (\n * <Link key={v.value} to={v.search} replace preventScrollReset aria-current={v.selected}\n * aria-disabled={!v.available}>{v.value}</Link>\n * ))}\n * </fieldset>\n * )}\n * </VariantSelector>\n */\nexport function VariantSelector({ product, children, ...config }: VariantSelectorProps) {\n const state = useProductOptions(product, config)\n return (\n <>\n {state.options.map((option) => (\n <Fragment key={option.name}>\n {children({ option, selectedVariant: state.selectedVariant, selectedOptions: state.selectedOptions, setOption: state.setOption })}\n </Fragment>\n ))}\n </>\n )\n}\n\n/** Builds the optimistic cart-line merchandise for a product variant. */\nexport function toMerchandise(product: Pick<Product, 'handle' | 'title' | 'featured_image'>, variant: ProductVariant): CartLineMerchandise {\n return { ...variant, product: { handle: product.handle, title: product.title, featured_image: product.featured_image } }\n}\n\nexport type AddToCartButtonProps = Omit<ComponentPropsWithoutRef<'button'>, 'onClick'> & {\n variantId: string | null | undefined\n quantity?: number\n /** Variant data for an instant optimistic cart line. */\n merchandise?: CartLineMerchandise\n onAdded?: () => void\n onClick?: ComponentPropsWithoutRef<'button'>['onClick']\n}\n\n/** Adds a variant to the cart via `useCart().addLines`. Disabled without a variant or while adding. */\nexport function AddToCartButton({\n variantId,\n quantity = 1,\n merchandise,\n onAdded,\n onClick,\n disabled,\n children = 'Agregar al carrito',\n type = 'button',\n ...rest\n}: AddToCartButtonProps) {\n const cart = useCart()\n const [adding, setAdding] = useState(false)\n return (\n <button\n type={type}\n disabled={disabled || !variantId || adding}\n aria-busy={adding || undefined}\n data-adding={adding || undefined}\n onClick={async (event) => {\n onClick?.(event)\n if (event.defaultPrevented || !variantId) return\n setAdding(true)\n try {\n const result = await cart.addLines([{ variant_id: variantId, quantity, ...(merchandise ? { merchandise } : {}) }])\n if (result) onAdded?.()\n } finally {\n setAdding(false)\n }\n }}\n {...rest}\n >\n {children}\n </button>\n )\n}\n","/**\n * SEO helpers: pure functions returning meta descriptors (React Router v7\n * `meta` export shape) and schema.org JSON-LD objects (`<JsonLd>` renders them).\n * Nothing here touches the DOM, so it is safe in loaders and SSR.\n */\nimport type { Collection, Image, Product, SEO, Shop } from '@asteby/storefront'\n\n/** Same shape as React Router's `MetaDescriptor`. */\nexport type MetaDescriptor =\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { tagName: 'link'; rel: string; href: string; [attr: string]: string }\n | { 'script:ld+json': JsonLdObject | JsonLdObject[] }\n\nexport type JsonLdObject = { '@context'?: string; '@type': string | string[]; [key: string]: unknown }\n\nexport type SeoMetaInput = {\n title?: string | null\n description?: string | null\n /** Canonical absolute URL. */\n url?: string | null\n image?: Image | string | null\n /** `og:type` (default `website`). */\n type?: string\n siteName?: string | null\n locale?: string | null\n noindex?: boolean\n /** Appended to the title as `Title | Suffix` unless already present. */\n titleSuffix?: string | null\n}\n\nconst clean = (s: string | null | undefined, max?: number): string | undefined => {\n if (!s) return undefined\n const text = s.replace(/<[^>]*>/g, ' ').replace(/\\s+/g, ' ').trim()\n if (!text) return undefined\n return max && text.length > max ? text.slice(0, max - 1).trimEnd() + '…' : text\n}\n\n/** Generic title/description/canonical/Open Graph/Twitter descriptors. */\nexport function seoMeta(input: SeoMetaInput): MetaDescriptor[] {\n const out: MetaDescriptor[] = []\n let title = clean(input.title)\n if (title && input.titleSuffix && !title.includes(input.titleSuffix)) title = `${title} | ${input.titleSuffix}`\n const description = clean(input.description, 160)\n const image = typeof input.image === 'string' ? { url: input.image, alt: null } : (input.image ?? null)\n if (title) out.push({ title }, { property: 'og:title', content: title }, { name: 'twitter:title', content: title })\n if (description) {\n out.push({ name: 'description', content: description }, { property: 'og:description', content: description }, { name: 'twitter:description', content: description })\n }\n if (input.url) out.push({ tagName: 'link', rel: 'canonical', href: input.url }, { property: 'og:url', content: input.url })\n out.push({ property: 'og:type', content: input.type ?? 'website' })\n if (input.siteName) out.push({ property: 'og:site_name', content: input.siteName })\n if (input.locale) out.push({ property: 'og:locale', content: input.locale.replace('-', '_') })\n if (image) {\n out.push({ property: 'og:image', content: image.url })\n if (image.width) out.push({ property: 'og:image:width', content: String(image.width) })\n if (image.height) out.push({ property: 'og:image:height', content: String(image.height) })\n if (image.alt) out.push({ property: 'og:image:alt', content: image.alt })\n }\n out.push({ name: 'twitter:card', content: image ? 'summary_large_image' : 'summary' })\n if (input.noindex) out.push({ name: 'robots', content: 'noindex, nofollow' })\n return out\n}\n\nfunction seoOf(seo: SEO, fallbackTitle: string, fallbackDescription: string | null | undefined) {\n return { title: seo.title ?? fallbackTitle, description: seo.description ?? fallbackDescription ?? null }\n}\n\n/** Product page descriptors (`og:type=product` and price tags). */\nexport function productMeta(product: Product, shop: Pick<Shop, 'name' | 'locale'> | null, url: string): MetaDescriptor[] {\n const { title, description } = seoOf(product.seo, product.title, product.description)\n const meta = seoMeta({\n title,\n description,\n url,\n image: product.featured_image,\n type: 'product',\n siteName: shop?.name ?? null,\n locale: shop?.locale ?? null,\n titleSuffix: shop?.name ?? null,\n })\n meta.push(\n { property: 'product:price:amount', content: product.price_range.min.amount },\n { property: 'product:price:currency', content: product.price_range.min.currency_code },\n { property: 'product:availability', content: product.available_for_sale ? 'in stock' : 'out of stock' },\n )\n if (product.vendor) meta.push({ property: 'product:brand', content: product.vendor })\n return meta\n}\n\n/** Collection page descriptors. */\nexport function collectionMeta(collection: Collection, shop: Pick<Shop, 'name' | 'locale'> | null, url: string): MetaDescriptor[] {\n const { title, description } = seoOf(collection.seo, collection.title, collection.description)\n return seoMeta({ title, description, url, image: collection.image, siteName: shop?.name ?? null, locale: shop?.locale ?? null, titleSuffix: shop?.name ?? null })\n}\n\n// ---------------------------------------------------------------------------\n// JSON-LD\n// ---------------------------------------------------------------------------\n\nconst CONTEXT = 'https://schema.org'\n\nfunction shopUrl(shop: Pick<Shop, 'domain'>, fallback?: string): string | undefined {\n if (shop.domain) return /^https?:\\/\\//.test(shop.domain) ? shop.domain : `https://${shop.domain}`\n if (fallback) {\n try {\n return new URL(fallback).origin\n } catch {\n return undefined\n }\n }\n return undefined\n}\n\nfunction compact<T extends Record<string, unknown>>(obj: T): T {\n for (const k of Object.keys(obj)) {\n const v = obj[k]\n if (v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0)) delete obj[k]\n }\n return obj\n}\n\nfunction withVariant(url: string, variantId: string): string {\n try {\n const u = new URL(url)\n u.searchParams.set('variant', variantId)\n return u.toString()\n } catch {\n return `${url}${url.includes('?') ? '&' : '?'}variant=${encodeURIComponent(variantId)}`\n }\n}\n\n/** schema.org `Product` with one `Offer` per variant. */\nexport function productJsonLd(product: Product, shop: Pick<Shop, 'name' | 'domain'> | null, url: string): JsonLdObject {\n const images = product.images.length ? product.images.map((i) => i.url) : product.featured_image ? [product.featured_image.url] : []\n const offers = product.variants.map((v) =>\n compact({\n '@type': 'Offer',\n sku: v.sku,\n gtin: v.barcode ?? undefined,\n name: product.variants.length > 1 ? `${product.title} - ${v.title}` : undefined,\n price: v.price.amount,\n priceCurrency: v.price.currency_code,\n availability: v.available_for_sale ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',\n itemCondition: 'https://schema.org/NewCondition',\n url: product.variants.length > 1 ? withVariant(url, v.id) : url,\n seller: shop ? { '@type': 'Organization', name: shop.name } : undefined,\n }),\n )\n const additionalProperty = Object.entries(product.attributes).map(([name, value]) => ({ '@type': 'PropertyValue', name, value }))\n return compact({\n '@context': CONTEXT,\n '@type': 'Product',\n '@id': `${url}#product`,\n name: product.title,\n description: clean(product.description) ?? undefined,\n url,\n image: images,\n sku: product.variants.length === 1 ? product.variants[0]!.sku : undefined,\n brand: product.vendor ? { '@type': 'Brand', name: product.vendor } : undefined,\n category: product.category?.title ?? product.product_type ?? undefined,\n additionalProperty,\n offers: offers.length === 1 ? offers[0] : offers,\n })\n}\n\n/** schema.org `Organization` for the shop (logo, contact, url). */\nexport function organizationJsonLd(shop: Shop, url?: string): JsonLdObject {\n const site = shopUrl(shop, url)\n const contactPoint = shop.contact.email || shop.contact.phone\n ? [compact({ '@type': 'ContactPoint', contactType: 'customer service', email: shop.contact.email ?? undefined, telephone: shop.contact.phone ?? undefined })]\n : []\n return compact({\n '@context': CONTEXT,\n '@type': 'Organization',\n '@id': site ? `${site}#organization` : undefined,\n name: shop.name,\n description: shop.description ?? undefined,\n url: site,\n logo: shop.logo?.url,\n email: shop.contact.email ?? undefined,\n telephone: shop.contact.phone ?? undefined,\n contactPoint,\n })\n}\n\nexport type LocalBusinessOptions = {\n /** schema.org type (default `Store`), e.g. `AutoPartsStore`, `ClothingStore`. */\n type?: string\n /** Shop URL fallback when `shop.domain` is empty. */\n url?: string\n priceRange?: string\n}\n\n/** One schema.org `LocalBusiness` (default `Store`) per shop branch. */\nexport function localBusinessJsonLd(shop: Shop, options: LocalBusinessOptions = {}): JsonLdObject[] {\n const site = shopUrl(shop, options.url)\n return shop.branches.map((b) =>\n compact({\n '@context': CONTEXT,\n '@type': options.type ?? 'Store',\n '@id': site ? `${site}#branch-${b.id}` : undefined,\n name: `${shop.name} - ${b.name}`,\n url: site,\n image: shop.logo?.url,\n telephone: b.phone ?? shop.contact.phone ?? undefined,\n priceRange: options.priceRange,\n address: compact({ '@type': 'PostalAddress', streetAddress: b.address, addressLocality: b.city, addressCountry: shop.country_code }),\n geo: b.lat !== null && b.lng !== null ? { '@type': 'GeoCoordinates', latitude: b.lat, longitude: b.lng } : undefined,\n openingHours: b.hours ? b.hours.split(/\\s*,\\s*/).filter(Boolean) : undefined,\n parentOrganization: site ? { '@id': `${site}#organization` } : { '@type': 'Organization', name: shop.name },\n }),\n )\n}\n\nexport type BreadcrumbItem = { name: string; url: string }\n\nexport function breadcrumbJsonLd(items: BreadcrumbItem[]): JsonLdObject {\n return {\n '@context': CONTEXT,\n '@type': 'BreadcrumbList',\n itemListElement: items.map((item, i) => ({ '@type': 'ListItem', position: i + 1, name: item.name, item: item.url })),\n }\n}\n\nexport type FaqItem = { question: string; answer: string }\n\nexport function faqJsonLd(items: FaqItem[]): JsonLdObject {\n return {\n '@context': CONTEXT,\n '@type': 'FAQPage',\n mainEntity: items.map((item) => ({\n '@type': 'Question',\n name: item.question,\n acceptedAnswer: { '@type': 'Answer', text: item.answer },\n })),\n }\n}\n\n/** schema.org `CollectionPage` with an `ItemList` of the products shown. */\nexport function collectionJsonLd(\n collection: Collection,\n products: Pick<Product, 'handle' | 'title' | 'featured_image'>[],\n url: string,\n options: { productUrl?: (handle: string) => string } = {},\n): JsonLdObject {\n const origin = (() => {\n try {\n return new URL(url).origin\n } catch {\n return ''\n }\n })()\n const productUrl = options.productUrl ?? ((handle: string) => `${origin}/products/${handle}`)\n return compact({\n '@context': CONTEXT,\n '@type': 'CollectionPage',\n name: collection.seo.title ?? collection.title,\n description: clean(collection.seo.description ?? collection.description) ?? undefined,\n url,\n image: collection.image?.url,\n mainEntity: {\n '@type': 'ItemList',\n numberOfItems: products.length,\n itemListElement: products.map((p, i) =>\n compact({ '@type': 'ListItem', position: i + 1, url: productUrl(p.handle), name: p.title, image: p.featured_image?.url }),\n ),\n },\n })\n}\n\n/**\n * Serializes JSON-LD for a `<script>` tag, escaping `<`, `>`, `&` and line\n * separators so the payload cannot close the tag or inject markup.\n */\nexport function serializeJsonLd(data: unknown): string {\n return JSON.stringify(data)\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029')\n}\n","import { serializeJsonLd, type JsonLdObject } from './seo.js'\n\nexport type JsonLdProps = { data: JsonLdObject | JsonLdObject[] | null | undefined; nonce?: string }\n\n/** Renders `<script type=\"application/ld+json\">` safely (works in SSR). */\nexport function JsonLd({ data, nonce }: JsonLdProps) {\n if (!data || (Array.isArray(data) && data.length === 0)) return null\n return <script type=\"application/ld+json\" nonce={nonce} dangerouslySetInnerHTML={{ __html: serializeJsonLd(data) }} />\n}\n","/**\n * Section registry: pages are ordered lists of `{ id, type, props }` (from\n * `content.page()`), and each `type` maps to a React component with a closed\n * props schema. The schema is what the OPS editor (and its AI agent) uses to\n * know which props exist, so props are validated and defaults merged before\n * rendering — the content is data, never markup.\n */\nimport { Fragment, type ComponentType, type ReactNode } from 'react'\nimport type { Section } from '@asteby/storefront'\n\nexport type SectionPropKind =\n | 'text'\n | 'textarea'\n | 'richtext'\n | 'number'\n | 'boolean'\n | 'url'\n | 'image'\n | 'color'\n | 'select'\n | 'collection'\n | 'product'\n | 'products'\n | 'list'\n\nexport type SectionPropSchema = {\n label: string\n kind: SectionPropKind\n description?: string\n default?: unknown\n required?: boolean\n /** `select` choices. */\n options?: readonly { value: string; label: string }[]\n /** `number` bounds. */\n min?: number\n max?: number\n /** `list` item schema. */\n items?: SectionSchema\n}\n\nexport type SectionSchema = { readonly [prop: string]: SectionPropSchema }\n\ntype KindType<P extends SectionPropSchema> = P['kind'] extends 'number'\n ? number\n : P['kind'] extends 'boolean'\n ? boolean\n : P['kind'] extends 'products'\n ? string[]\n : P['kind'] extends 'list'\n ? P['items'] extends SectionSchema\n ? InferSectionProps<P['items']>[]\n : Record<string, unknown>[]\n : P['kind'] extends 'select'\n ? P['options'] extends readonly { value: infer V }[]\n ? V\n : string\n : string\n\ntype RequiredKeys<S extends SectionSchema> = {\n [K in keyof S]: S[K]['required'] extends true ? K : 'default' extends keyof S[K] ? K : never\n}[keyof S]\n\n/** Props type derived from a section schema (props with `default` or `required` are non-optional). */\nexport type InferSectionProps<S extends SectionSchema> = { [K in RequiredKeys<S>]: KindType<S[K]> } & {\n [K in Exclude<keyof S, RequiredKeys<S>>]?: KindType<S[K]>\n}\n\nexport type SectionComponentProps<P, C = unknown> = P & {\n section: { id: string; type: string }\n /** Arbitrary data passed to `<Sections context>` (e.g. loader data). */\n context: C\n}\n\nexport type SectionDefinition<P = Record<string, unknown>, C = any> = {\n type: string\n label?: string\n description?: string\n schema: SectionSchema\n component: ComponentType<SectionComponentProps<P, C>>\n}\n\n/**\n * Declares a section. Prop types are inferred from the schema:\n *\n * export const hero = defineSection({\n * type: 'hero',\n * label: 'Hero',\n * schema: {\n * title: { label: 'Título', kind: 'text', required: true },\n * cta_url: { label: 'Enlace', kind: 'url', default: '/' },\n * },\n * component: ({ title, cta_url }) => <section><h1>{title}</h1><a href={cta_url}>Ver</a></section>,\n * })\n */\nexport function defineSection<const S extends SectionSchema, C = any>(definition: {\n type: string\n label?: string\n description?: string\n schema: S\n component: ComponentType<SectionComponentProps<InferSectionProps<S>, C>>\n}): SectionDefinition<InferSectionProps<S>, C> {\n return definition as SectionDefinition<InferSectionProps<S>, C>\n}\n\nexport type SectionPropError = { prop: string; message: string }\n\nconst STRING_KINDS = new Set<SectionPropKind>(['text', 'textarea', 'richtext', 'url', 'image', 'color', 'collection', 'product'])\n\nfunction cloneDefault(value: unknown): unknown {\n return value !== null && typeof value === 'object' ? structuredClone(value) : value\n}\n\n/**\n * Validates raw props against a schema: merges defaults, coerces numeric\n * strings, drops unknown props and replaces invalid values with the default.\n */\nexport function resolveSectionProps(schema: SectionSchema, raw: Record<string, unknown> | null | undefined, path = ''): { props: Record<string, unknown>; errors: SectionPropError[] } {\n const props: Record<string, unknown> = {}\n const errors: SectionPropError[] = []\n const input = raw ?? {}\n for (const [name, spec] of Object.entries(schema)) {\n const key = path ? `${path}.${name}` : name\n let value = input[name]\n const fail = (message: string) => {\n errors.push({ prop: key, message })\n if ('default' in spec) props[name] = cloneDefault(spec.default)\n }\n if (value === undefined || value === null || value === '') {\n if ('default' in spec) props[name] = cloneDefault(spec.default)\n else if (spec.required) errors.push({ prop: key, message: 'is required' })\n continue\n }\n if (STRING_KINDS.has(spec.kind)) {\n if (typeof value !== 'string') {\n fail('must be a string')\n continue\n }\n } else if (spec.kind === 'number') {\n if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value))) value = Number(value)\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n fail('must be a number')\n continue\n }\n if ((spec.min !== undefined && value < spec.min) || (spec.max !== undefined && value > spec.max)) {\n fail(`must be between ${spec.min ?? '-∞'} and ${spec.max ?? '∞'}`)\n continue\n }\n } else if (spec.kind === 'boolean') {\n if (typeof value !== 'boolean') {\n fail('must be a boolean')\n continue\n }\n } else if (spec.kind === 'select') {\n if (typeof value !== 'string' || (spec.options && !spec.options.some((o) => o.value === value))) {\n fail(`must be one of ${(spec.options ?? []).map((o) => o.value).join(', ')}`)\n continue\n }\n } else if (spec.kind === 'products') {\n if (!Array.isArray(value) || value.some((v) => typeof v !== 'string')) {\n fail('must be a list of product handles')\n continue\n }\n } else if (spec.kind === 'list') {\n if (!Array.isArray(value)) {\n fail('must be a list')\n continue\n }\n const items: unknown[] = []\n value.forEach((item, i) => {\n if (!spec.items) {\n items.push(item)\n return\n }\n if (typeof item !== 'object' || item === null || Array.isArray(item)) {\n errors.push({ prop: `${key}[${i}]`, message: 'must be an object' })\n return\n }\n const resolved = resolveSectionProps(spec.items, item as Record<string, unknown>, `${key}[${i}]`)\n errors.push(...resolved.errors)\n items.push(resolved.props)\n })\n value = items\n }\n props[name] = value\n }\n return { props, errors }\n}\n\n/** JSON Schema (draft 2020-12) of a section, for the OPS editor (`section.schema.json`). */\nexport function sectionJsonSchema(definition: Pick<SectionDefinition, 'type' | 'label' | 'description' | 'schema'>): Record<string, unknown> {\n const toSchema = (schema: SectionSchema): Record<string, unknown> => {\n const properties: Record<string, unknown> = {}\n const required: string[] = []\n for (const [name, spec] of Object.entries(schema)) {\n const base: Record<string, unknown> = { title: spec.label, 'x-kind': spec.kind }\n if (spec.description) base.description = spec.description\n if ('default' in spec) base.default = spec.default\n if (spec.required) required.push(name)\n switch (spec.kind) {\n case 'number':\n Object.assign(base, { type: 'number' }, spec.min !== undefined ? { minimum: spec.min } : {}, spec.max !== undefined ? { maximum: spec.max } : {})\n break\n case 'boolean':\n base.type = 'boolean'\n break\n case 'select':\n Object.assign(base, { type: 'string', enum: (spec.options ?? []).map((o) => o.value), 'x-options': spec.options ?? [] })\n break\n case 'products':\n Object.assign(base, { type: 'array', items: { type: 'string' } })\n break\n case 'list':\n Object.assign(base, { type: 'array', items: spec.items ? toSchema(spec.items) : { type: 'object' } })\n break\n case 'url':\n Object.assign(base, { type: 'string', format: 'uri-reference' })\n break\n default:\n base.type = 'string'\n }\n properties[name] = base\n }\n return { type: 'object', additionalProperties: false, properties, ...(required.length ? { required } : {}) }\n }\n return {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `section:${definition.type}`,\n title: definition.label ?? definition.type,\n ...(definition.description ? { description: definition.description } : {}),\n ...toSchema(definition.schema),\n }\n}\n\n/** Map of section `type` → definition. */\nexport class SectionRegistry {\n private readonly defs = new Map<string, SectionDefinition<any, any>>()\n\n constructor(definitions: readonly SectionDefinition<any, any>[] = []) {\n for (const d of definitions) this.register(d)\n }\n\n register(definition: SectionDefinition<any, any>): this {\n this.defs.set(definition.type, definition)\n return this\n }\n\n get(type: string): SectionDefinition<any, any> | undefined {\n return this.defs.get(type)\n }\n\n has(type: string): boolean {\n return this.defs.has(type)\n }\n\n types(): string[] {\n return [...this.defs.keys()]\n }\n\n definitions(): SectionDefinition<any, any>[] {\n return [...this.defs.values()]\n }\n\n /** JSON Schemas of every registered section, keyed by type. */\n toJSONSchema(): Record<string, Record<string, unknown>> {\n return Object.fromEntries(this.definitions().map((d) => [d.type, sectionJsonSchema(d)]))\n }\n}\n\nexport function createSectionRegistry(definitions: readonly SectionDefinition<any, any>[] = []): SectionRegistry {\n return new SectionRegistry(definitions)\n}\n\nconst isDev = () => {\n const p = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n return p?.env?.NODE_ENV !== 'production'\n}\n\nexport type SectionsProps<C = unknown> = {\n sections: readonly Section[] | null | undefined\n registry: SectionRegistry\n /** Passed to every section component as `context`. */\n context?: C\n /** Rendered for unknown types (default: nothing). */\n renderUnknown?: (section: Section) => ReactNode\n /** Called with validation problems (default: `console.warn` outside production). */\n onInvalid?: (section: Section, errors: SectionPropError[]) => void\n}\n\n/**\n * Renders sections in order. Unknown types are skipped (with a dev warning),\n * props are validated against the schema and defaults are merged; a section\n * missing a required prop is skipped.\n */\nexport function Sections<C = unknown>({ sections, registry, context, renderUnknown, onInvalid }: SectionsProps<C>) {\n if (!sections?.length) return null\n return (\n <>\n {sections.map((section, index) => {\n const key = section.id || `${section.type}-${index}`\n const def = registry.get(section.type)\n if (!def) {\n if (isDev()) console.warn(`[storefront-react] Unknown section type \"${section.type}\" (id ${section.id}); skipping.`)\n return renderUnknown ? <Fragment key={key}>{renderUnknown(section)}</Fragment> : null\n }\n const { props, errors } = resolveSectionProps(def.schema, section.props)\n if (errors.length) {\n if (onInvalid) onInvalid(section, errors)\n else if (isDev()) console.warn(`[storefront-react] Section \"${section.type}\" (id ${section.id}) has invalid props:`, errors)\n }\n // A missing required prop would break the component: skip the section.\n if (errors.some((e) => e.message === 'is required' && !e.prop.includes('[') && !e.prop.includes('.'))) return null\n const Component = def.component\n return <Component key={key} {...props} section={{ id: section.id, type: section.type }} context={context} />\n })}\n </>\n )\n}\n","/**\n * Server-side theme (S3): turns the content theme from\n * `content.theme()` into CSS custom properties so the first SSR byte already\n * carries the store's brand — no localStorage, no anti-flicker script.\n *\n * Token naming follows `@asteby/metacore-theme`: camelCase keys become\n * kebab-case (`primaryForeground` → `--primary-foreground`), and each color is\n * also exposed as a Tailwind 4 theme variable (`--color-primary-foreground`).\n * metacore-theme ships its tokens as static CSS with no reusable naming\n * helper, so this module is standalone and does not depend on it.\n */\nimport type { Theme } from '@asteby/storefront'\n\nexport type ThemeCssOptions = {\n /** Selector that receives the variables (default `:root`). */\n selector?: string\n /**\n * Variable names for color tokens:\n * `both` (default) → `--color-<name>` and `--<name>`;\n * `color` → only `--color-<name>` (Tailwind 4); `metacore` → only `--<name>`.\n */\n naming?: 'both' | 'color' | 'metacore'\n /** Fallback stack appended to every font (default system sans-serif). */\n fontFallback?: string\n}\n\nconst DEFAULT_FONT_FALLBACK = 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif'\nconst MONO_FALLBACK = 'ui-monospace, SFMono-Regular, Menlo, monospace'\n\n/** `primaryForeground`, `primary_foreground`, `--color-primary-foreground` → `primary-foreground`. */\nexport function tokenName(key: string): string {\n return key\n .trim()\n .replace(/^-+/, '')\n .replace(/^color-/, '')\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[\\s_.]+/g, '-')\n .toLowerCase()\n .replace(/[^a-z0-9-]/g, '')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n}\n\n/** Rejects values that could escape the declaration or the `<style>` element. */\nexport function isSafeCssValue(value: string): boolean {\n if (!value || value.length > 200) return false\n if (/[;{}<>\\\\]/.test(value)) return false\n if (/url\\s*\\(|expression\\s*\\(|@import/i.test(value)) return false\n return true\n}\n\nfunction fontStack(family: string, role: string, fallback: string): string | null {\n const name = family.replace(/[\"']/g, '').trim()\n if (!name || !isSafeCssValue(name)) return null\n return `\"${name}\", ${role === 'mono' ? MONO_FALLBACK : fallback}`\n}\n\n/** CSS declarations (`--x:value`) for a theme, without selector. */\nexport function themeToCssVariables(theme: Partial<Theme> | null | undefined, options: ThemeCssOptions = {}): Record<string, string> {\n const naming = options.naming ?? 'both'\n const vars: Record<string, string> = {}\n for (const [key, raw] of Object.entries(theme?.tokens ?? {})) {\n const name = tokenName(key)\n const value = String(raw).trim()\n if (!name || !isSafeCssValue(value)) continue\n if (naming !== 'metacore') vars[`--color-${name}`] = value\n if (naming !== 'color') vars[`--${name}`] = value\n }\n const fallback = options.fontFallback ?? DEFAULT_FONT_FALLBACK\n for (const [role, family] of Object.entries(theme?.fonts ?? {})) {\n const name = tokenName(role)\n const stack = typeof family === 'string' ? fontStack(family, name, fallback) : null\n if (name && stack) vars[`--font-${name}`] = stack\n }\n if (theme?.radius && isSafeCssValue(theme.radius.trim())) vars['--radius'] = theme.radius.trim()\n return vars\n}\n\n/** `:root{--color-primary:#0f766e;--primary:#0f766e;...}` from a content theme. */\nexport function themeToCss(theme: Partial<Theme> | null | undefined, options: ThemeCssOptions = {}): string {\n const vars = themeToCssVariables(theme, options)\n const body = Object.entries(vars)\n .map(([k, v]) => `${k}:${v}`)\n .join(';')\n if (!body) return ''\n const selector = (options.selector ?? ':root').replace(/[{}<>]/g, '')\n return `${selector}{${body}}`\n}\n\n/** Google Fonts stylesheet URL for the theme fonts (or `null` when there are none). */\nexport function themeFontsHref(theme: Partial<Theme> | null | undefined, weights: number[] = [400, 500, 600, 700]): string | null {\n const families = [...new Set(Object.values(theme?.fonts ?? {}).map((f) => String(f).replace(/[\"']/g, '').trim()).filter((f) => f && isSafeCssValue(f)))]\n if (!families.length) return null\n const params = families.map((f) => `family=${encodeURIComponent(f).replace(/%20/g, '+')}:wght@${weights.join(';')}`).join('&')\n return `https://fonts.googleapis.com/css2?${params}&display=swap`\n}\n\nexport type ThemeStyleProps = ThemeCssOptions & {\n theme: Partial<Theme> | null | undefined\n nonce?: string\n id?: string\n}\n\n/** Emits the theme variables as a `<style>` (render it in `<head>` from the root route). */\nexport function ThemeStyle({ theme, nonce, id = 'storefront-theme', ...options }: ThemeStyleProps) {\n const css = themeToCss(theme, options)\n if (!css) return null\n return <style id={id} nonce={nonce} data-storefront-theme=\"\" dangerouslySetInnerHTML={{ __html: css }} />\n}\n"]}
1
+ {"version":3,"sources":["../src/context.tsx","../src/cookie.ts","../src/cart.tsx","../src/components.tsx","../src/variants.tsx","../src/seo.ts","../src/json-ld.tsx","../src/sections.tsx","../src/theme.tsx","../src/geolocation.ts","../src/nearest.ts","../src/selected-location.ts","../src/locations.tsx"],"names":["createContext","useMemo","createStorefrontClient","jsx","useContext","isStorefrontError","useRef","useState","useCallback","p","useEffect","formatMoney","createElement","parseMoney","jsxs","Fragment","toSchemaOpeningHours","isValidPoint","fail","rankByDistance","EMPTY","location","openStatus","directionsUrl","useId"],"mappings":";;;;;;;;AAaA,IAAM,iBAAA,GAAoBA,oBAA6C,IAAI,CAAA;AAkBpE,SAAS,kBAAA,CAAmB,EAAE,MAAA,EAAQ,MAAA,EAAQ,OAAO,IAAA,EAAM,MAAA,EAAQ,QAAA,EAAU,QAAA,EAAS,EAA4B;AACvH,EAAA,MAAM,YAAY,MAAA,GAAS,CAAA,EAAG,MAAA,CAAO,OAAO,IAAI,MAAA,CAAO,KAAK,CAAA,CAAA,EAAI,MAAA,CAAO,UAAU,EAAE,CAAA,CAAA,EAAI,MAAA,CAAO,aAAA,IAAiB,EAAE,CAAA,CAAA,GAAK,EAAA;AACtH,EAAA,MAAM,cAAA,GAAiBC,aAAA;AAAA,IACrB,MAAM,MAAA,KAAW,MAAA,GAASC,iCAAA,CAAuB,MAAM,CAAA,GAAI,IAAA,CAAA;AAAA,IAC3D,CAAC,QAAQ,SAAS;AAAA,GACpB;AACA,EAAA,MAAM,KAAA,GAAQD,aAAA;AAAA,IACZ,OAAO;AAAA,MACL,MAAA,EAAQ,cAAA;AAAA,MACR,IAAA;AAAA,MACA,MAAA,EAAQ,MAAA,IAAU,MAAA,EAAQ,MAAA,IAAU,MAAM,MAAA,IAAU,OAAA;AAAA,MACpD,QAAA,EAAU,QAAA,IAAY,IAAA,EAAM,aAAA,IAAiB;AAAA,KAC/C,CAAA;AAAA,IACA,CAAC,cAAA,EAAgB,IAAA,EAAM,MAAA,EAAQ,QAAA,EAAU,QAAQ,MAAM;AAAA,GACzD;AAC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QACnD;AAAA;AAAA;AAAA,GACH;AAEJ","file":"index.cjs","sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport { createStorefrontClient, type Shop, type StorefrontClient, type StorefrontClientOptions } from '@asteby/storefront'\n\nexport type StorefrontContextValue = {\n /** Client for browser-side calls (use a public `pk_` token). */\n client: StorefrontClient | null\n shop: Shop | null\n /** BCP 47 locale used for formatting (defaults to `shop.locale`, then `es-MX`). */\n locale: string\n /** ISO 4217 currency (defaults to `shop.currency_code`, then `MXN`). */\n currency: string\n}\n\nconst StorefrontContext = createContext<StorefrontContextValue | null>(null)\n\nexport type StorefrontProviderProps = {\n /** A ready client. Takes precedence over `config`. */\n client?: StorefrontClient\n /** Options to create the browser client (use a `pk_` token). */\n config?: StorefrontClientOptions\n /** Shop info loaded on the server (root loader). */\n shop?: Shop | null\n locale?: string\n currency?: string\n children?: ReactNode\n}\n\n/**\n * Makes the storefront client, shop, locale and currency available to the\n * tree. SSR-safe: creating the client does not touch `window`.\n */\nexport function StorefrontProvider({ client, config, shop = null, locale, currency, children }: StorefrontProviderProps) {\n const configKey = config ? `${config.baseUrl}|${config.token}|${config.locale ?? ''}|${config.customerToken ?? ''}` : ''\n const resolvedClient = useMemo(\n () => client ?? (config ? createStorefrontClient(config) : null),\n [client, configKey],\n )\n const value = useMemo<StorefrontContextValue>(\n () => ({\n client: resolvedClient,\n shop,\n locale: locale ?? config?.locale ?? shop?.locale ?? 'es-MX',\n currency: currency ?? shop?.currency_code ?? 'MXN',\n }),\n [resolvedClient, shop, locale, currency, config?.locale],\n )\n return <StorefrontContext.Provider value={value}>{children}</StorefrontContext.Provider>\n}\n\n/** Storefront context. Throws outside `<StorefrontProvider>`. */\nexport function useStorefront(): StorefrontContextValue {\n const ctx = useContext(StorefrontContext)\n if (!ctx) throw new Error('useStorefront must be used inside <StorefrontProvider>')\n return ctx\n}\n\n/** Storefront context or `null` outside a provider (for components that work standalone). */\nexport function useOptionalStorefront(): StorefrontContextValue | null {\n return useContext(StorefrontContext)\n}\n\n/** The client from context; throws when the provider has none. */\nexport function useStorefrontClient(): StorefrontClient {\n const { client } = useStorefront()\n if (!client) throw new Error('<StorefrontProvider> needs a `client` or `config` for browser-side calls')\n return client\n}\n","/** Default name of the cookie that holds the cart id. */\nexport const CART_COOKIE_NAME = 'sf_cart'\n\nexport type CartCookieOptions = {\n /** Cookie name (default `sf_cart`). */\n name?: string\n /** Lifetime in days (default 30). */\n maxAgeDays?: number\n path?: string\n domain?: string\n sameSite?: 'Lax' | 'Strict' | 'None'\n /** Defaults to true on https pages / when `sameSite` is `None`. */\n secure?: boolean\n}\n\n/**\n * Reads the cart id from a `Cookie` header. Use it in SSR loaders:\n * `getCartIdFromCookie(request.headers.get('Cookie'))`.\n */\nexport function getCartIdFromCookie(cookieHeader: string | null | undefined, name: string = CART_COOKIE_NAME): string | null {\n if (!cookieHeader) return null\n for (const part of cookieHeader.split(';')) {\n const eq = part.indexOf('=')\n if (eq < 0) continue\n if (part.slice(0, eq).trim() !== name) continue\n const raw = part.slice(eq + 1).trim().replace(/^\"(.*)\"$/, '$1')\n if (!raw) return null\n try {\n return decodeURIComponent(raw)\n } catch {\n return raw\n }\n }\n return null\n}\n\n/**\n * Serializes the cart cookie for a `Set-Cookie` header (SSR actions) or for\n * `document.cookie`. Pass `null` to clear it.\n */\nexport function serializeCartCookie(cartId: string | null, options: CartCookieOptions = {}): string {\n const name = options.name ?? CART_COOKIE_NAME\n const parts = [`${name}=${cartId ? encodeURIComponent(cartId) : ''}`]\n parts.push(`Path=${options.path ?? '/'}`)\n const maxAge = cartId ? Math.round((options.maxAgeDays ?? 30) * 86_400) : 0\n parts.push(`Max-Age=${maxAge}`)\n if (options.domain) parts.push(`Domain=${options.domain}`)\n const sameSite = options.sameSite ?? 'Lax'\n parts.push(`SameSite=${sameSite}`)\n if (options.secure ?? sameSite === 'None') parts.push('Secure')\n return parts.join('; ')\n}\n\n/** Browser-only: writes the cart cookie. No-op on the server. */\nexport function writeCartCookie(cartId: string | null, options: CartCookieOptions = {}): void {\n if (typeof document === 'undefined') return\n const secure = options.secure ?? (typeof location !== 'undefined' && location.protocol === 'https:')\n document.cookie = serializeCartCookie(cartId, { ...options, secure })\n}\n\n/** Browser-only: reads the cart cookie. `null` on the server. */\nexport function readCartCookie(name: string = CART_COOKIE_NAME): string | null {\n if (typeof document === 'undefined') return null\n return getCartIdFromCookie(document.cookie, name)\n}\n","import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport {\n isStorefrontError,\n type AddressInput,\n type Cart,\n type CartBuyerInput,\n type CartLine,\n type CartLineInput,\n type CartLineMerchandise,\n type CartLineUpdateInput,\n type DeliveryInput,\n type DeliveryOptions,\n type Money,\n type StorefrontClient,\n} from '@asteby/storefront'\nimport { useOptionalStorefront } from './context.js'\nimport { CART_COOKIE_NAME, readCartCookie, writeCartCookie, type CartCookieOptions } from './cookie.js'\n\nexport type CartLineAddInput = CartLineInput & {\n /** Variant data for an instant optimistic line (otherwise only the count updates until the server answers). */\n merchandise?: CartLineMerchandise\n}\n\nexport type CartStatus = 'idle' | 'loading' | 'updating'\n\nexport type CartContextValue = {\n cart: Cart | null\n cartId: string | null\n status: CartStatus\n /** Last mutation error (cleared on the next successful mutation). */\n error: Error | null\n totalQuantity: number\n /** Adds lines, creating the cart on first use. Optimistic. */\n addLines: (lines: CartLineAddInput[]) => Promise<Cart | null>\n /** Sets line quantities (`0` removes). Optimistic. */\n updateLines: (lines: CartLineUpdateInput[]) => Promise<Cart | null>\n /** Removes lines. Optimistic. */\n removeLines: (lineIds: string[]) => Promise<Cart | null>\n setDiscountCodes: (codes: string[]) => Promise<Cart | null>\n setBuyer: (buyer: CartBuyerInput) => Promise<Cart | null>\n setShippingAddress: (address: AddressInput) => Promise<Cart | null>\n setDelivery: (delivery: DeliveryInput) => Promise<Cart | null>\n deliveryOptions: () => Promise<DeliveryOptions | null>\n /** Reloads the cart from the API. */\n refresh: () => Promise<Cart | null>\n /** Forgets the cart (clears state and cookie), e.g. after checkout. */\n clear: () => void\n}\n\nconst CartContext = createContext<CartContextValue | null>(null)\n\nexport type CartProviderProps = {\n /** Cart loaded in the SSR loader (hydrates without a client fetch). */\n initialCart?: Cart | null\n /** Cart id known on the server when `initialCart` is not loaded. */\n cartId?: string | null\n /** Client override (defaults to the `StorefrontProvider` client). */\n client?: StorefrontClient\n /** Cookie settings for the persisted cart id (`sf_cart`). Pass `false` to disable the cookie. */\n cookie?: CartCookieOptions | false\n /** Currency for the optimistic placeholder cart (defaults to the provider currency). */\n currency?: string\n onError?: (error: Error) => void\n onCartChange?: (cart: Cart | null) => void\n children?: ReactNode\n}\n\ntype PendingOp = { id: number; apply: (cart: Cart | null) => Cart | null }\n\nconst toCents = (m: Money | null | undefined) => (m ? Math.round(Number.parseFloat(m.amount) * 100) : 0)\nconst money = (cents: number, currency: string): Money => ({ amount: (cents / 100).toFixed(2), currency_code: currency })\n\nfunction emptyCart(currency: string): Cart {\n const zero = money(0, currency)\n return {\n id: '',\n lines: [],\n total_quantity: 0,\n discount_codes: [],\n buyer: { email: null, phone: null, customer_id: null },\n shipping_address: null,\n delivery: { method: null, rate_id: null, branch_id: null },\n cost: { subtotal: zero, discount: zero, shipping: null, tax: null, total: zero, tax_included: true },\n updated_at: new Date(0).toISOString(),\n }\n}\n\nfunction withLines(cart: Cart, lines: CartLine[], totalQuantity?: number): Cart {\n const currency = cart.cost.subtotal.currency_code\n const subtotal = lines.reduce((sum, l) => sum + toCents(l.cost.total), 0)\n const total = Math.max(0, subtotal - toCents(cart.cost.discount) + toCents(cart.cost.shipping))\n return {\n ...cart,\n lines,\n total_quantity: totalQuantity ?? lines.reduce((sum, l) => sum + l.quantity, 0),\n cost: { ...cart.cost, subtotal: money(subtotal, currency), total: money(total, currency) },\n }\n}\n\nfunction lineWithQuantity(line: CartLine, quantity: number): CartLine {\n const unit = toCents(line.cost.unit)\n return { ...line, quantity, cost: { ...line.cost, total: money(unit * quantity, line.cost.unit.currency_code) } }\n}\n\n/** Pure optimistic reducers (exported for tests and custom carts). */\nexport const optimisticCart = {\n add(cart: Cart | null, input: CartLineAddInput[], currency: string): Cart {\n const base = cart ?? emptyCart(currency)\n let lines = base.lines.slice()\n let unknownQuantity = 0\n for (const l of input) {\n const idx = lines.findIndex((x) => x.merchandise.id === l.variant_id)\n if (idx >= 0) lines[idx] = lineWithQuantity(lines[idx]!, lines[idx]!.quantity + l.quantity)\n else if (l.merchandise) {\n const unit = l.merchandise.price\n lines.push({\n id: `optimistic:${l.variant_id}`,\n quantity: l.quantity,\n merchandise: l.merchandise,\n cost: { unit, compare_at_unit: l.merchandise.compare_at_price, total: money(toCents(unit) * l.quantity, unit.currency_code) },\n })\n } else unknownQuantity += l.quantity\n }\n const known = lines.reduce((sum, l) => sum + l.quantity, 0)\n return withLines(base, lines, known + unknownQuantity + (base.total_quantity - base.lines.reduce((s, l) => s + l.quantity, 0)))\n },\n update(cart: Cart | null, input: CartLineUpdateInput[]): Cart | null {\n if (!cart) return cart\n const byId = new Map(input.map((l) => [l.id, l.quantity]))\n const lines = cart.lines\n .map((l) => (byId.has(l.id) ? lineWithQuantity(l, byId.get(l.id)!) : l))\n .filter((l) => l.quantity > 0)\n return withLines(cart, lines)\n },\n remove(cart: Cart | null, lineIds: string[]): Cart | null {\n if (!cart) return cart\n return withLines(cart, cart.lines.filter((l) => !lineIds.includes(l.id)))\n },\n}\n\nconst isNotFound = (err: unknown) => isStorefrontError(err) && err.status === 404\n\n/**\n * Holds the cart and exposes optimistic mutations. Mutations run one at a\n * time in order; a failed one is rolled back without discarding the others.\n * The cart id is persisted in the `sf_cart` cookie (read it in loaders with\n * `getCartIdFromCookie`). No `window`/`document` access during render.\n */\nexport function CartProvider({\n initialCart = null,\n cartId: initialCartId = null,\n client: clientProp,\n cookie,\n currency: currencyProp,\n onError,\n onCartChange,\n children,\n}: CartProviderProps) {\n const sf = useOptionalStorefront()\n const client = clientProp ?? sf?.client ?? null\n const currency = currencyProp ?? initialCart?.cost.subtotal.currency_code ?? sf?.currency ?? 'MXN'\n const cookieOptions = cookie === false ? null : (cookie ?? {})\n\n const confirmedRef = useRef<Cart | null>(initialCart)\n const pendingRef = useRef<PendingOp[]>([])\n const idRef = useRef<string | null>(initialCart?.id ?? initialCartId ?? null)\n const queueRef = useRef<Promise<unknown>>(Promise.resolve())\n const seqRef = useRef(0)\n const callbacks = useRef({ onError, onCartChange })\n callbacks.current = { onError, onCartChange }\n\n const [cart, setCart] = useState<Cart | null>(initialCart)\n const [cartId, setCartId] = useState<string | null>(idRef.current)\n const [pending, setPending] = useState(0)\n const [loading, setLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const render = useCallback(() => {\n const next = pendingRef.current.reduce<Cart | null>((acc, op) => op.apply(acc), confirmedRef.current)\n setCart(next)\n }, [])\n\n const persistId = useCallback(\n (id: string | null) => {\n if (idRef.current === id) return\n idRef.current = id\n setCartId(id)\n if (cookieOptions) writeCartCookie(id, cookieOptions)\n },\n // cookieOptions is a plain options bag; its identity is irrelevant\n [cookie === false, cookieOptions?.name],\n )\n\n const confirm = useCallback(\n (next: Cart | null) => {\n confirmedRef.current = next\n if (next) persistId(next.id)\n callbacks.current.onCartChange?.(next)\n },\n [persistId],\n )\n\n const requireClient = useCallback((): StorefrontClient => {\n if (!client) throw new Error('CartProvider needs a client: pass `client` or wrap it in <StorefrontProvider config|client>')\n return client\n }, [client])\n\n /** Queues a remote mutation with an optional optimistic layer. */\n const mutate = useCallback(\n <T,>(remote: (c: StorefrontClient) => Promise<T>, toCart: (r: T) => Cart | null, optimistic?: PendingOp['apply']): Promise<T | null> => {\n const op: PendingOp | null = optimistic ? { id: ++seqRef.current, apply: optimistic } : null\n if (op) {\n pendingRef.current = [...pendingRef.current, op]\n render()\n }\n setPending((n) => n + 1)\n const run = async (): Promise<T | null> => {\n try {\n const result = await remote(requireClient())\n const next = toCart(result)\n if (next) confirm(next)\n setError(null)\n return result\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err))\n setError(e)\n callbacks.current.onError?.(e)\n return null\n } finally {\n if (op) pendingRef.current = pendingRef.current.filter((p) => p !== op)\n render()\n setPending((n) => n - 1)\n }\n }\n const p = queueRef.current.then(run, run)\n queueRef.current = p\n return p\n },\n [confirm, render, requireClient],\n )\n\n const asCart = (c: Cart) => c\n\n // Hydrate from the cookie / id on the client when the server did not load the cart.\n useEffect(() => {\n if (confirmedRef.current) {\n if (cookieOptions && idRef.current) writeCartCookie(idRef.current, cookieOptions)\n return\n }\n const id = idRef.current ?? (cookieOptions ? readCartCookie(cookieOptions.name ?? CART_COOKIE_NAME) : null)\n if (!id || !client) return\n idRef.current = id\n setCartId(id)\n let cancelled = false\n setLoading(true)\n client.carts\n .get(id)\n .then((loaded) => {\n if (cancelled) return\n if (loaded) confirm(loaded)\n else persistId(null)\n render()\n })\n .catch((err: unknown) => {\n if (cancelled) return\n const e = err instanceof Error ? err : new Error(String(err))\n setError(e)\n callbacks.current.onError?.(e)\n })\n .finally(() => !cancelled && setLoading(false))\n return () => {\n cancelled = true\n }\n // Runs once on mount.\n }, [])\n\n const value = useMemo<CartContextValue>(() => {\n const withId = <T,>(fn: (c: StorefrontClient, id: string) => Promise<T>) => async (c: StorefrontClient) => {\n if (!idRef.current) throw new Error('No cart yet: add a line first')\n return fn(c, idRef.current)\n }\n return {\n cart,\n cartId,\n status: loading ? 'loading' : pending > 0 ? 'updating' : 'idle',\n error,\n totalQuantity: cart?.total_quantity ?? 0,\n addLines: (lines) => {\n const payload = lines.map(({ variant_id, quantity }) => ({ variant_id, quantity }))\n return mutate(\n async (c) => {\n if (!idRef.current) return c.carts.create({ lines: payload })\n try {\n return await c.carts.addLines(idRef.current, payload)\n } catch (err) {\n // Expired or unknown cart: start a new one.\n if (isNotFound(err)) return c.carts.create({ lines: payload })\n throw err\n }\n },\n asCart,\n (current) => optimisticCart.add(current, lines, currency),\n )\n },\n updateLines: (lines) => mutate(withId((c, id) => c.carts.updateLines(id, lines)), asCart, (current) => optimisticCart.update(current, lines)),\n removeLines: (lineIds) => mutate(withId((c, id) => c.carts.removeLines(id, lineIds)), asCart, (current) => optimisticCart.remove(current, lineIds)),\n setDiscountCodes: (codes) => mutate(withId((c, id) => c.carts.setDiscountCodes(id, codes)), asCart),\n setBuyer: (buyer) => mutate(withId((c, id) => c.carts.setBuyer(id, buyer)), asCart),\n setShippingAddress: (address) => mutate(withId((c, id) => c.carts.setShippingAddress(id, address)), asCart),\n setDelivery: (delivery) => mutate(withId((c, id) => c.carts.setDelivery(id, delivery)), asCart),\n deliveryOptions: () => mutate(withId((c, id) => c.carts.deliveryOptions(id)), () => null),\n refresh: () =>\n mutate(\n async (c) => (idRef.current ? c.carts.get(idRef.current) : null),\n (r) => {\n if (r === null) {\n confirmedRef.current = null\n persistId(null)\n }\n return r\n },\n ),\n clear: () => {\n confirmedRef.current = null\n pendingRef.current = []\n persistId(null)\n render()\n callbacks.current.onCartChange?.(null)\n },\n }\n }, [cart, cartId, loading, pending, error, mutate, currency, persistId, render])\n\n return <CartContext.Provider value={value}>{children}</CartContext.Provider>\n}\n\n/** Cart state and actions. Throws outside `<CartProvider>`. */\nexport function useCart(): CartContextValue {\n const ctx = useContext(CartContext)\n if (!ctx) throw new Error('useCart must be used inside <CartProvider>')\n return ctx\n}\n\n/** Cart context or `null` outside a provider. */\nexport function useOptionalCart(): CartContextValue | null {\n return useContext(CartContext)\n}\n","import { createElement, type ComponentPropsWithoutRef, type ElementType, type ReactNode } from 'react'\nimport { formatMoney, parseMoney, type FormatMoneyOptions, type Image as ImageData, type Money as MoneyData, type Product, type ProductVariant } from '@asteby/storefront'\nimport { useOptionalStorefront } from './context.js'\n\n// ---------------------------------------------------------------------------\n// Money\n// ---------------------------------------------------------------------------\n\nexport type MoneyProps<As extends ElementType = 'span'> = FormatMoneyOptions & {\n data: MoneyData\n /** Element to render (default `span`). */\n as?: As\n /** Overrides the provider locale. */\n locale?: string\n} & Omit<ComponentPropsWithoutRef<As>, 'children' | 'as'>\n\n/** Formats `Money` with the provider locale (or `locale`). */\nexport function Money<As extends ElementType = 'span'>({\n data,\n as,\n locale,\n withoutTrailingZeros,\n withoutCurrency,\n currencyDisplay,\n ...rest\n}: MoneyProps<As>) {\n const sf = useOptionalStorefront()\n const text = formatMoney(data, locale ?? sf?.locale, {\n ...(withoutTrailingZeros !== undefined ? { withoutTrailingZeros } : {}),\n ...(withoutCurrency !== undefined ? { withoutCurrency } : {}),\n ...(currencyDisplay !== undefined ? { currencyDisplay } : {}),\n })\n return createElement(as ?? 'span', rest, text)\n}\n\n// ---------------------------------------------------------------------------\n// Image\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_IMAGE_WIDTHS = [320, 480, 640, 768, 1024, 1280, 1600] as const\n\n/** Builds the URL for one srcset width. */\nexport type ImageLoader = (src: string, width: number, height?: number) => string\n\n/**\n * Default loader: adds `?width=<w>` (the convention of most image CDNs and of\n * the OPS image proxy). URLs that cannot be parsed are returned unchanged.\n */\nexport const defaultImageLoader: ImageLoader = (src, width, height) => {\n try {\n const isAbsolute = /^[a-z][a-z0-9+.-]*:/i.test(src)\n const url = new URL(src, 'http://relative.invalid')\n url.searchParams.set('width', String(width))\n if (height) url.searchParams.set('height', String(height))\n return isAbsolute ? url.toString() : url.pathname + url.search + url.hash\n } catch {\n return src\n }\n}\n\nexport type ImageProps = Omit<ComponentPropsWithoutRef<'img'>, 'src' | 'srcSet' | 'width' | 'height'> & {\n data: ImageData\n /** `sizes` attribute (default `100vw`). */\n sizes?: string\n /** Candidate widths for `srcset` (capped at the intrinsic width when known). */\n widths?: readonly number[]\n /** URL builder per width (default adds `?width=`). Pass `null` to disable srcset. */\n loader?: ImageLoader | null\n /** Above-the-fold image: eager loading and `fetchpriority=\"high\"`. */\n priority?: boolean\n /** Forces an aspect ratio, e.g. `1/1` or `4/3`, used for width/height and srcset heights. */\n aspectRatio?: string\n}\n\nfunction parseRatio(ratio: string | undefined): number | null {\n if (!ratio) return null\n const [w, h] = ratio.split(/[/:]/).map((n) => Number.parseFloat(n))\n return w && h ? w / h : null\n}\n\n/** Responsive `<img>` with `srcset`, lazy by default, intrinsic size to avoid layout shift. */\nexport function Image({\n data,\n sizes = '100vw',\n widths = DEFAULT_IMAGE_WIDTHS,\n loader = defaultImageLoader,\n priority = false,\n aspectRatio,\n alt,\n loading,\n decoding,\n ...rest\n}: ImageProps) {\n const ratio = parseRatio(aspectRatio) ?? (data.width && data.height ? data.width / data.height : null)\n let candidates = [...widths].sort((a, b) => a - b)\n if (data.width) {\n const capped = candidates.filter((w) => w <= data.width!)\n candidates = capped.length ? capped : [data.width]\n }\n const srcSet = loader\n ? candidates.map((w) => `${loader(data.url, w, ratio ? Math.round(w / ratio) : undefined)} ${w}w`).join(', ')\n : undefined\n const width = data.width ?? candidates[candidates.length - 1]\n const height = data.height ?? (ratio && width ? Math.round(width / ratio) : undefined)\n return (\n <img\n src={data.url}\n alt={alt ?? data.alt ?? ''}\n {...(srcSet ? { srcSet, sizes } : {})}\n {...(width ? { width } : {})}\n {...(height ? { height } : {})}\n loading={loading ?? (priority ? 'eager' : 'lazy')}\n decoding={decoding ?? (priority ? 'auto' : 'async')}\n {...(priority ? { fetchPriority: 'high' as const } : {})}\n {...rest}\n />\n )\n}\n\n// ---------------------------------------------------------------------------\n// ProductPrice\n// ---------------------------------------------------------------------------\n\nconst VISUALLY_HIDDEN = {\n position: 'absolute',\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n border: 0,\n} as const\n\nexport type ProductPriceProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'> & {\n product?: Pick<Product, 'price_range' | 'compare_at_price_range'> | null\n variant?: Pick<ProductVariant, 'price' | 'compare_at_price'> | null\n /** Prefix shown when the product has a price range and no variant is selected (default `Desde`). */\n fromLabel?: ReactNode\n /** Accessible label for the compare-at price (default `Precio anterior`). */\n compareAtLabel?: string\n locale?: string\n withoutTrailingZeros?: boolean\n}\n\n/**\n * Price with optional compare-at (strikethrough). With a `variant` it shows\n * that variant; otherwise the product's minimum price (prefixed with\n * `fromLabel` when prices vary).\n */\nexport function ProductPrice({\n product,\n variant,\n fromLabel = 'Desde',\n compareAtLabel = 'Precio anterior',\n locale,\n withoutTrailingZeros,\n ...rest\n}: ProductPriceProps) {\n let price: MoneyData | null = null\n let compareAt: MoneyData | null = null\n let isRange = false\n if (variant) {\n price = variant.price\n compareAt = variant.compare_at_price\n } else if (product) {\n price = product.price_range.min\n compareAt = product.compare_at_price_range?.min ?? null\n isRange = product.price_range.min.amount !== product.price_range.max.amount\n }\n if (!price) return null\n const onSale = compareAt !== null && parseMoney(compareAt) > parseMoney(price)\n const opts = { ...(locale ? { locale } : {}), ...(withoutTrailingZeros !== undefined ? { withoutTrailingZeros } : {}) }\n return (\n <div data-on-sale={onSale || undefined} {...rest}>\n {isRange ? <span data-price-prefix=\"\">{fromLabel} </span> : null}\n <Money data={price} data-price=\"\" {...opts} />\n {onSale && compareAt ? (\n <>\n {' '}\n <s data-compare-at-price=\"\">\n <span style={VISUALLY_HIDDEN}>{compareAtLabel}: </span>\n <Money data={compareAt} {...opts} />\n </s>\n </>\n ) : null}\n </div>\n )\n}\n","import { Fragment, useCallback, useMemo, useRef, useState, type ComponentPropsWithoutRef, type ReactNode } from 'react'\nimport type { CartLineMerchandise, Product, ProductVariant } from '@asteby/storefront'\nimport { useCart } from './cart.js'\n\nexport type ProductOptionValueState = {\n value: string\n /** Part of the current selection. */\n selected: boolean\n /** A variant with this value (and the other selected options) exists. */\n exists: boolean\n /** That variant is available for sale. */\n available: boolean\n /** The variant this value would select, if it exists. */\n variant: ProductVariant | null\n /** Query string (`?Talla=M&Color=Rojo`) selecting this value, preserving other params. */\n search: string\n}\n\nexport type ProductOptionState = { name: string; values: ProductOptionValueState[] }\n\nexport type ProductOptionsState = {\n options: ProductOptionState[]\n selectedOptions: Record<string, string>\n /** Variant matching every selected option, or `null` while incomplete. */\n selectedVariant: ProductVariant | null\n setOption: (name: string, value: string) => void\n}\n\nexport type UseProductOptionsConfig = {\n /** Current URL search params; option names are read as keys (`?Talla=M`), plus `variant=<id>`. */\n searchParams?: URLSearchParams | string | null\n /** Select the first available variant when nothing is in the URL (default true). */\n defaultToFirstAvailable?: boolean\n onChange?: (variant: ProductVariant | null, selectedOptions: Record<string, string>) => void\n}\n\ntype ProductLike = Pick<Product, 'options' | 'variants'> & { id?: string }\n\nfunction toParams(input: URLSearchParams | string | null | undefined): URLSearchParams {\n if (!input) return new URLSearchParams()\n return input instanceof URLSearchParams ? new URLSearchParams(input) : new URLSearchParams(input)\n}\n\nfunction optionsOf(variant: ProductVariant): Record<string, string> {\n return Object.fromEntries(variant.selected_options.map((o) => [o.name, o.value]))\n}\n\nfunction findVariant(product: ProductLike, selection: Record<string, string>): ProductVariant | null {\n if (product.options.length === 0) return product.variants[0] ?? null\n return (\n product.variants.find((v) => v.selected_options.length > 0 && v.selected_options.every((o) => selection[o.name] === o.value)) ?? null\n )\n}\n\nfunction initialSelection(product: ProductLike, params: URLSearchParams, defaultToFirstAvailable: boolean): Record<string, string> {\n const byId = params.get('variant')\n const fromId = byId ? product.variants.find((v) => v.id === byId) : undefined\n if (fromId) return optionsOf(fromId)\n const selection: Record<string, string> = {}\n for (const opt of product.options) {\n const v = params.get(opt.name)\n if (v !== null && opt.values.includes(v)) selection[opt.name] = v\n }\n if (Object.keys(selection).length === 0 && defaultToFirstAvailable) {\n const first = product.variants.find((v) => v.available_for_sale) ?? product.variants[0]\n return first ? optionsOf(first) : {}\n }\n return selection\n}\n\n/**\n * Option → values matrix with availability, the selected variant (from the\n * URL or local state) and links for each value. Pure React: works in SSR.\n */\nexport function useProductOptions(product: ProductLike, config: UseProductOptionsConfig = {}): ProductOptionsState {\n const { defaultToFirstAvailable = true, onChange } = config\n const params = useMemo(() => toParams(config.searchParams), [String(config.searchParams ?? '')])\n const sourceKey = `${product.id ?? ''}|${params.toString()}`\n const fromSource = useMemo(\n () => initialSelection(product, params, defaultToFirstAvailable),\n // product identity is keyed by id + params\n [sourceKey, defaultToFirstAvailable],\n )\n\n // Local selection overrides the URL until the URL (or product) changes.\n const [local, setLocal] = useState<{ key: string; selection: Record<string, string> } | null>(null)\n const selectedOptions = local && local.key === sourceKey ? local.selection : fromSource\n\n const onChangeRef = useRef(onChange)\n onChangeRef.current = onChange\n\n const setOption = useCallback(\n (name: string, value: string) => {\n const next = { ...selectedOptions, [name]: value }\n setLocal({ key: sourceKey, selection: next })\n onChangeRef.current?.(findVariant(product, next), next)\n },\n [selectedOptions, sourceKey, product],\n )\n\n const selectedVariant = useMemo(() => findVariant(product, selectedOptions), [product, selectedOptions])\n\n const options = useMemo<ProductOptionState[]>(\n () =>\n product.options.map((opt) => ({\n name: opt.name,\n values: opt.values.map((value) => {\n const candidate = { ...selectedOptions, [opt.name]: value }\n const exact = findVariant(product, candidate)\n // When other options are not chosen yet, availability = any available variant with this value.\n const loose = product.variants.filter((v) => v.selected_options.some((o) => o.name === opt.name && o.value === value))\n const search = new URLSearchParams(params)\n search.delete('variant')\n for (const [k, v] of Object.entries(candidate)) search.set(k, v)\n return {\n value,\n selected: selectedOptions[opt.name] === value,\n exists: exact ? true : loose.length > 0 && Object.keys(selectedOptions).length < product.options.length,\n available: exact ? exact.available_for_sale : Object.keys(selectedOptions).length < product.options.length && loose.some((v) => v.available_for_sale),\n variant: exact,\n search: `?${search.toString()}`,\n }\n }),\n })),\n [product, selectedOptions, params],\n )\n\n return { options, selectedOptions, selectedVariant, setOption }\n}\n\nexport type VariantSelectorRenderProps = {\n option: ProductOptionState\n selectedVariant: ProductVariant | null\n selectedOptions: Record<string, string>\n setOption: (name: string, value: string) => void\n}\n\nexport type VariantSelectorProps = UseProductOptionsConfig & {\n product: ProductLike\n /** Called once per option; render the buttons/links for `option.values`. */\n children: (props: VariantSelectorRenderProps) => ReactNode\n}\n\n/**\n * Render-prop variant picker. Example:\n *\n * <VariantSelector product={product} searchParams={searchParams}>\n * {({ option }) => (\n * <fieldset>\n * <legend>{option.name}</legend>\n * {option.values.map((v) => (\n * <Link key={v.value} to={v.search} replace preventScrollReset aria-current={v.selected}\n * aria-disabled={!v.available}>{v.value}</Link>\n * ))}\n * </fieldset>\n * )}\n * </VariantSelector>\n */\nexport function VariantSelector({ product, children, ...config }: VariantSelectorProps) {\n const state = useProductOptions(product, config)\n return (\n <>\n {state.options.map((option) => (\n <Fragment key={option.name}>\n {children({ option, selectedVariant: state.selectedVariant, selectedOptions: state.selectedOptions, setOption: state.setOption })}\n </Fragment>\n ))}\n </>\n )\n}\n\n/** Builds the optimistic cart-line merchandise for a product variant. */\nexport function toMerchandise(product: Pick<Product, 'handle' | 'title' | 'featured_image'>, variant: ProductVariant): CartLineMerchandise {\n return { ...variant, product: { handle: product.handle, title: product.title, featured_image: product.featured_image } }\n}\n\nexport type AddToCartButtonProps = Omit<ComponentPropsWithoutRef<'button'>, 'onClick'> & {\n variantId: string | null | undefined\n quantity?: number\n /** Variant data for an instant optimistic cart line. */\n merchandise?: CartLineMerchandise\n onAdded?: () => void\n onClick?: ComponentPropsWithoutRef<'button'>['onClick']\n}\n\n/** Adds a variant to the cart via `useCart().addLines`. Disabled without a variant or while adding. */\nexport function AddToCartButton({\n variantId,\n quantity = 1,\n merchandise,\n onAdded,\n onClick,\n disabled,\n children = 'Agregar al carrito',\n type = 'button',\n ...rest\n}: AddToCartButtonProps) {\n const cart = useCart()\n const [adding, setAdding] = useState(false)\n return (\n <button\n type={type}\n disabled={disabled || !variantId || adding}\n aria-busy={adding || undefined}\n data-adding={adding || undefined}\n onClick={async (event) => {\n onClick?.(event)\n if (event.defaultPrevented || !variantId) return\n setAdding(true)\n try {\n const result = await cart.addLines([{ variant_id: variantId, quantity, ...(merchandise ? { merchandise } : {}) }])\n if (result) onAdded?.()\n } finally {\n setAdding(false)\n }\n }}\n {...rest}\n >\n {children}\n </button>\n )\n}\n","/**\n * SEO helpers: pure functions returning meta descriptors (React Router v7\n * `meta` export shape) and schema.org JSON-LD objects (`<JsonLd>` renders them).\n * Nothing here touches the DOM, so it is safe in loaders and SSR.\n */\nimport type { Collection, Image, Product, SEO, Shop } from '@asteby/storefront'\nimport { isValidPoint, toSchemaOpeningHours, type OpeningHours } from '@asteby/storefront/geo'\n\n/** Same shape as React Router's `MetaDescriptor`. */\nexport type MetaDescriptor =\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { tagName: 'link'; rel: string; href: string; [attr: string]: string }\n | { 'script:ld+json': JsonLdObject | JsonLdObject[] }\n\nexport type JsonLdObject = { '@context'?: string; '@type': string | string[]; [key: string]: unknown }\n\nexport type SeoMetaInput = {\n title?: string | null\n description?: string | null\n /** Canonical absolute URL. */\n url?: string | null\n image?: Image | string | null\n /** `og:type` (default `website`). */\n type?: string\n siteName?: string | null\n locale?: string | null\n noindex?: boolean\n /** Appended to the title as `Title | Suffix` unless already present. */\n titleSuffix?: string | null\n}\n\nconst clean = (s: string | null | undefined, max?: number): string | undefined => {\n if (!s) return undefined\n const text = s.replace(/<[^>]*>/g, ' ').replace(/\\s+/g, ' ').trim()\n if (!text) return undefined\n return max && text.length > max ? text.slice(0, max - 1).trimEnd() + '…' : text\n}\n\n/** Generic title/description/canonical/Open Graph/Twitter descriptors. */\nexport function seoMeta(input: SeoMetaInput): MetaDescriptor[] {\n const out: MetaDescriptor[] = []\n let title = clean(input.title)\n if (title && input.titleSuffix && !title.includes(input.titleSuffix)) title = `${title} | ${input.titleSuffix}`\n const description = clean(input.description, 160)\n const image = typeof input.image === 'string' ? { url: input.image, alt: null } : (input.image ?? null)\n if (title) out.push({ title }, { property: 'og:title', content: title }, { name: 'twitter:title', content: title })\n if (description) {\n out.push({ name: 'description', content: description }, { property: 'og:description', content: description }, { name: 'twitter:description', content: description })\n }\n if (input.url) out.push({ tagName: 'link', rel: 'canonical', href: input.url }, { property: 'og:url', content: input.url })\n out.push({ property: 'og:type', content: input.type ?? 'website' })\n if (input.siteName) out.push({ property: 'og:site_name', content: input.siteName })\n if (input.locale) out.push({ property: 'og:locale', content: input.locale.replace('-', '_') })\n if (image) {\n out.push({ property: 'og:image', content: image.url })\n if (image.width) out.push({ property: 'og:image:width', content: String(image.width) })\n if (image.height) out.push({ property: 'og:image:height', content: String(image.height) })\n if (image.alt) out.push({ property: 'og:image:alt', content: image.alt })\n }\n out.push({ name: 'twitter:card', content: image ? 'summary_large_image' : 'summary' })\n if (input.noindex) out.push({ name: 'robots', content: 'noindex, nofollow' })\n return out\n}\n\nfunction seoOf(seo: SEO, fallbackTitle: string, fallbackDescription: string | null | undefined) {\n return { title: seo.title ?? fallbackTitle, description: seo.description ?? fallbackDescription ?? null }\n}\n\n/** Product page descriptors (`og:type=product` and price tags). */\nexport function productMeta(product: Product, shop: Pick<Shop, 'name' | 'locale'> | null, url: string): MetaDescriptor[] {\n const { title, description } = seoOf(product.seo, product.title, product.description)\n const meta = seoMeta({\n title,\n description,\n url,\n image: product.featured_image,\n type: 'product',\n siteName: shop?.name ?? null,\n locale: shop?.locale ?? null,\n titleSuffix: shop?.name ?? null,\n })\n meta.push(\n { property: 'product:price:amount', content: product.price_range.min.amount },\n { property: 'product:price:currency', content: product.price_range.min.currency_code },\n { property: 'product:availability', content: product.available_for_sale ? 'in stock' : 'out of stock' },\n )\n if (product.vendor) meta.push({ property: 'product:brand', content: product.vendor })\n return meta\n}\n\n/** Collection page descriptors. */\nexport function collectionMeta(collection: Collection, shop: Pick<Shop, 'name' | 'locale'> | null, url: string): MetaDescriptor[] {\n const { title, description } = seoOf(collection.seo, collection.title, collection.description)\n return seoMeta({ title, description, url, image: collection.image, siteName: shop?.name ?? null, locale: shop?.locale ?? null, titleSuffix: shop?.name ?? null })\n}\n\n// ---------------------------------------------------------------------------\n// JSON-LD\n// ---------------------------------------------------------------------------\n\nconst CONTEXT = 'https://schema.org'\n\nfunction shopUrl(shop: Pick<Shop, 'domain'>, fallback?: string): string | undefined {\n if (shop.domain) return /^https?:\\/\\//.test(shop.domain) ? shop.domain : `https://${shop.domain}`\n if (fallback) {\n try {\n return new URL(fallback).origin\n } catch {\n return undefined\n }\n }\n return undefined\n}\n\nfunction compact<T extends Record<string, unknown>>(obj: T): T {\n for (const k of Object.keys(obj)) {\n const v = obj[k]\n if (v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0)) delete obj[k]\n }\n return obj\n}\n\nfunction withVariant(url: string, variantId: string): string {\n try {\n const u = new URL(url)\n u.searchParams.set('variant', variantId)\n return u.toString()\n } catch {\n return `${url}${url.includes('?') ? '&' : '?'}variant=${encodeURIComponent(variantId)}`\n }\n}\n\n/** schema.org `Product` with one `Offer` per variant. */\nexport function productJsonLd(product: Product, shop: Pick<Shop, 'name' | 'domain'> | null, url: string): JsonLdObject {\n const images = product.images.length ? product.images.map((i) => i.url) : product.featured_image ? [product.featured_image.url] : []\n const offers = product.variants.map((v) =>\n compact({\n '@type': 'Offer',\n sku: v.sku,\n gtin: v.barcode ?? undefined,\n name: product.variants.length > 1 ? `${product.title} - ${v.title}` : undefined,\n price: v.price.amount,\n priceCurrency: v.price.currency_code,\n availability: v.available_for_sale ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',\n itemCondition: 'https://schema.org/NewCondition',\n url: product.variants.length > 1 ? withVariant(url, v.id) : url,\n seller: shop ? { '@type': 'Organization', name: shop.name } : undefined,\n }),\n )\n const additionalProperty = Object.entries(product.attributes).map(([name, value]) => ({ '@type': 'PropertyValue', name, value }))\n return compact({\n '@context': CONTEXT,\n '@type': 'Product',\n '@id': `${url}#product`,\n name: product.title,\n description: clean(product.description) ?? undefined,\n url,\n image: images,\n sku: product.variants.length === 1 ? product.variants[0]!.sku : undefined,\n brand: product.vendor ? { '@type': 'Brand', name: product.vendor } : undefined,\n category: product.category?.title ?? product.product_type ?? undefined,\n additionalProperty,\n offers: offers.length === 1 ? offers[0] : offers,\n })\n}\n\n/** schema.org `Organization` for the shop (logo, contact, url). */\nexport function organizationJsonLd(shop: Shop, url?: string): JsonLdObject {\n const site = shopUrl(shop, url)\n const contactPoint = shop.contact.email || shop.contact.phone\n ? [compact({ '@type': 'ContactPoint', contactType: 'customer service', email: shop.contact.email ?? undefined, telephone: shop.contact.phone ?? undefined })]\n : []\n return compact({\n '@context': CONTEXT,\n '@type': 'Organization',\n '@id': site ? `${site}#organization` : undefined,\n name: shop.name,\n description: shop.description ?? undefined,\n url: site,\n logo: shop.logo?.url,\n email: shop.contact.email ?? undefined,\n telephone: shop.contact.phone ?? undefined,\n contactPoint,\n })\n}\n\nexport type LocalBusinessOptions = {\n /** schema.org type (default `Store`), e.g. `AutoPartsStore`, `ClothingStore`. */\n type?: string\n /** Shop URL fallback when `shop.domain` is empty. */\n url?: string\n priceRange?: string\n}\n\nconst SCHEMA_HOURS = /^(Mo|Tu|We|Th|Fr|Sa|Su)(-(Mo|Tu|We|Th|Fr|Sa|Su))?( \\d{2}:\\d{2}-\\d{2}:\\d{2})?$/\n\n/**\n * schema.org `openingHours` values from structured hours or a legacy string.\n * A string is accepted only if EVERY comma-separated token is strict schema.org\n * syntax (`Mo-Fr 09:00-19:00`); free text such as `Lun-Sáb 8:00 a 18:00` yields\n * `undefined` so no invalid markup is ever emitted.\n */\nexport function openingHoursJsonLd(hours: OpeningHours | string | null | undefined): string[] | undefined {\n if (!hours) return undefined\n if (typeof hours !== 'string') {\n const list = hours.weekly ? toSchemaOpeningHours(hours) : []\n return list.length ? list : undefined\n }\n const tokens = hours.split(',').map((t) => t.trim())\n return tokens.length && tokens.every((t) => SCHEMA_HOURS.test(t)) ? tokens : undefined\n}\n\n/**\n * One schema.org `LocalBusiness` (default `Store`) per shop branch. Hours come\n * from `opening_hours` when present, else from the legacy `hours` string.\n */\nexport function localBusinessJsonLd(shop: Shop, options: LocalBusinessOptions = {}): JsonLdObject[] {\n const site = shopUrl(shop, options.url)\n return shop.branches.map((b) =>\n compact({\n '@context': CONTEXT,\n '@type': options.type ?? 'Store',\n '@id': site ? `${site}#branch-${b.id}` : undefined,\n name: `${shop.name} - ${b.name}`,\n url: site,\n image: shop.logo?.url,\n telephone: b.phone ?? shop.contact.phone ?? undefined,\n priceRange: options.priceRange,\n address: compact({ '@type': 'PostalAddress', streetAddress: b.address, addressLocality: b.city, addressCountry: shop.country_code }),\n geo: isValidPoint(b) ? { '@type': 'GeoCoordinates', latitude: b.lat, longitude: b.lng } : undefined,\n openingHours: openingHoursJsonLd(b.opening_hours ?? b.hours),\n parentOrganization: site ? { '@id': `${site}#organization` } : { '@type': 'Organization', name: shop.name },\n }),\n )\n}\n\nexport type BreadcrumbItem = { name: string; url: string }\n\nexport function breadcrumbJsonLd(items: BreadcrumbItem[]): JsonLdObject {\n return {\n '@context': CONTEXT,\n '@type': 'BreadcrumbList',\n itemListElement: items.map((item, i) => ({ '@type': 'ListItem', position: i + 1, name: item.name, item: item.url })),\n }\n}\n\nexport type FaqItem = { question: string; answer: string }\n\nexport function faqJsonLd(items: FaqItem[]): JsonLdObject {\n return {\n '@context': CONTEXT,\n '@type': 'FAQPage',\n mainEntity: items.map((item) => ({\n '@type': 'Question',\n name: item.question,\n acceptedAnswer: { '@type': 'Answer', text: item.answer },\n })),\n }\n}\n\n/** schema.org `CollectionPage` with an `ItemList` of the products shown. */\nexport function collectionJsonLd(\n collection: Collection,\n products: Pick<Product, 'handle' | 'title' | 'featured_image'>[],\n url: string,\n options: { productUrl?: (handle: string) => string } = {},\n): JsonLdObject {\n const origin = (() => {\n try {\n return new URL(url).origin\n } catch {\n return ''\n }\n })()\n const productUrl = options.productUrl ?? ((handle: string) => `${origin}/products/${handle}`)\n return compact({\n '@context': CONTEXT,\n '@type': 'CollectionPage',\n name: collection.seo.title ?? collection.title,\n description: clean(collection.seo.description ?? collection.description) ?? undefined,\n url,\n image: collection.image?.url,\n mainEntity: {\n '@type': 'ItemList',\n numberOfItems: products.length,\n itemListElement: products.map((p, i) =>\n compact({ '@type': 'ListItem', position: i + 1, url: productUrl(p.handle), name: p.title, image: p.featured_image?.url }),\n ),\n },\n })\n}\n\n/**\n * Serializes JSON-LD for a `<script>` tag, escaping `<`, `>`, `&` and line\n * separators so the payload cannot close the tag or inject markup.\n */\nexport function serializeJsonLd(data: unknown): string {\n return JSON.stringify(data)\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029')\n}\n","import { serializeJsonLd, type JsonLdObject } from './seo.js'\n\nexport type JsonLdProps = { data: JsonLdObject | JsonLdObject[] | null | undefined; nonce?: string }\n\n/** Renders `<script type=\"application/ld+json\">` safely (works in SSR). */\nexport function JsonLd({ data, nonce }: JsonLdProps) {\n if (!data || (Array.isArray(data) && data.length === 0)) return null\n return <script type=\"application/ld+json\" nonce={nonce} dangerouslySetInnerHTML={{ __html: serializeJsonLd(data) }} />\n}\n","/**\n * Section registry: pages are ordered lists of `{ id, type, props }` (from\n * `content.page()`), and each `type` maps to a React component with a closed\n * props schema. The schema is what the OPS editor (and its AI agent) uses to\n * know which props exist, so props are validated and defaults merged before\n * rendering — the content is data, never markup.\n */\nimport { Fragment, type ComponentType, type ReactNode } from 'react'\nimport type { Section } from '@asteby/storefront'\n\nexport type SectionPropKind =\n | 'text'\n | 'textarea'\n | 'richtext'\n | 'number'\n | 'boolean'\n | 'url'\n | 'image'\n | 'color'\n | 'select'\n | 'collection'\n | 'product'\n | 'products'\n | 'list'\n\nexport type SectionPropSchema = {\n label: string\n kind: SectionPropKind\n description?: string\n default?: unknown\n required?: boolean\n /** `select` choices. */\n options?: readonly { value: string; label: string }[]\n /** `number` bounds. */\n min?: number\n max?: number\n /** `list` item schema. */\n items?: SectionSchema\n}\n\nexport type SectionSchema = { readonly [prop: string]: SectionPropSchema }\n\ntype KindType<P extends SectionPropSchema> = P['kind'] extends 'number'\n ? number\n : P['kind'] extends 'boolean'\n ? boolean\n : P['kind'] extends 'products'\n ? string[]\n : P['kind'] extends 'list'\n ? P['items'] extends SectionSchema\n ? InferSectionProps<P['items']>[]\n : Record<string, unknown>[]\n : P['kind'] extends 'select'\n ? P['options'] extends readonly { value: infer V }[]\n ? V\n : string\n : string\n\ntype RequiredKeys<S extends SectionSchema> = {\n [K in keyof S]: S[K]['required'] extends true ? K : 'default' extends keyof S[K] ? K : never\n}[keyof S]\n\n/** Props type derived from a section schema (props with `default` or `required` are non-optional). */\nexport type InferSectionProps<S extends SectionSchema> = { [K in RequiredKeys<S>]: KindType<S[K]> } & {\n [K in Exclude<keyof S, RequiredKeys<S>>]?: KindType<S[K]>\n}\n\nexport type SectionComponentProps<P, C = unknown> = P & {\n section: { id: string; type: string }\n /** Arbitrary data passed to `<Sections context>` (e.g. loader data). */\n context: C\n}\n\nexport type SectionDefinition<P = Record<string, unknown>, C = any> = {\n type: string\n label?: string\n description?: string\n schema: SectionSchema\n component: ComponentType<SectionComponentProps<P, C>>\n}\n\n/**\n * Declares a section. Prop types are inferred from the schema:\n *\n * export const hero = defineSection({\n * type: 'hero',\n * label: 'Hero',\n * schema: {\n * title: { label: 'Título', kind: 'text', required: true },\n * cta_url: { label: 'Enlace', kind: 'url', default: '/' },\n * },\n * component: ({ title, cta_url }) => <section><h1>{title}</h1><a href={cta_url}>Ver</a></section>,\n * })\n */\nexport function defineSection<const S extends SectionSchema, C = any>(definition: {\n type: string\n label?: string\n description?: string\n schema: S\n component: ComponentType<SectionComponentProps<InferSectionProps<S>, C>>\n}): SectionDefinition<InferSectionProps<S>, C> {\n return definition as SectionDefinition<InferSectionProps<S>, C>\n}\n\nexport type SectionPropError = { prop: string; message: string }\n\nconst STRING_KINDS = new Set<SectionPropKind>(['text', 'textarea', 'richtext', 'url', 'image', 'color', 'collection', 'product'])\n\nfunction cloneDefault(value: unknown): unknown {\n return value !== null && typeof value === 'object' ? structuredClone(value) : value\n}\n\n/**\n * Validates raw props against a schema: merges defaults, coerces numeric\n * strings, drops unknown props and replaces invalid values with the default.\n */\nexport function resolveSectionProps(schema: SectionSchema, raw: Record<string, unknown> | null | undefined, path = ''): { props: Record<string, unknown>; errors: SectionPropError[] } {\n const props: Record<string, unknown> = {}\n const errors: SectionPropError[] = []\n const input = raw ?? {}\n for (const [name, spec] of Object.entries(schema)) {\n const key = path ? `${path}.${name}` : name\n let value = input[name]\n const fail = (message: string) => {\n errors.push({ prop: key, message })\n if ('default' in spec) props[name] = cloneDefault(spec.default)\n }\n if (value === undefined || value === null || value === '') {\n if ('default' in spec) props[name] = cloneDefault(spec.default)\n else if (spec.required) errors.push({ prop: key, message: 'is required' })\n continue\n }\n if (STRING_KINDS.has(spec.kind)) {\n if (typeof value !== 'string') {\n fail('must be a string')\n continue\n }\n } else if (spec.kind === 'number') {\n if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value))) value = Number(value)\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n fail('must be a number')\n continue\n }\n if ((spec.min !== undefined && value < spec.min) || (spec.max !== undefined && value > spec.max)) {\n fail(`must be between ${spec.min ?? '-∞'} and ${spec.max ?? '∞'}`)\n continue\n }\n } else if (spec.kind === 'boolean') {\n if (typeof value !== 'boolean') {\n fail('must be a boolean')\n continue\n }\n } else if (spec.kind === 'select') {\n if (typeof value !== 'string' || (spec.options && !spec.options.some((o) => o.value === value))) {\n fail(`must be one of ${(spec.options ?? []).map((o) => o.value).join(', ')}`)\n continue\n }\n } else if (spec.kind === 'products') {\n if (!Array.isArray(value) || value.some((v) => typeof v !== 'string')) {\n fail('must be a list of product handles')\n continue\n }\n } else if (spec.kind === 'list') {\n if (!Array.isArray(value)) {\n fail('must be a list')\n continue\n }\n const items: unknown[] = []\n value.forEach((item, i) => {\n if (!spec.items) {\n items.push(item)\n return\n }\n if (typeof item !== 'object' || item === null || Array.isArray(item)) {\n errors.push({ prop: `${key}[${i}]`, message: 'must be an object' })\n return\n }\n const resolved = resolveSectionProps(spec.items, item as Record<string, unknown>, `${key}[${i}]`)\n errors.push(...resolved.errors)\n items.push(resolved.props)\n })\n value = items\n }\n props[name] = value\n }\n return { props, errors }\n}\n\n/** JSON Schema (draft 2020-12) of a section, for the OPS editor (`section.schema.json`). */\nexport function sectionJsonSchema(definition: Pick<SectionDefinition, 'type' | 'label' | 'description' | 'schema'>): Record<string, unknown> {\n const toSchema = (schema: SectionSchema): Record<string, unknown> => {\n const properties: Record<string, unknown> = {}\n const required: string[] = []\n for (const [name, spec] of Object.entries(schema)) {\n const base: Record<string, unknown> = { title: spec.label, 'x-kind': spec.kind }\n if (spec.description) base.description = spec.description\n if ('default' in spec) base.default = spec.default\n if (spec.required) required.push(name)\n switch (spec.kind) {\n case 'number':\n Object.assign(base, { type: 'number' }, spec.min !== undefined ? { minimum: spec.min } : {}, spec.max !== undefined ? { maximum: spec.max } : {})\n break\n case 'boolean':\n base.type = 'boolean'\n break\n case 'select':\n Object.assign(base, { type: 'string', enum: (spec.options ?? []).map((o) => o.value), 'x-options': spec.options ?? [] })\n break\n case 'products':\n Object.assign(base, { type: 'array', items: { type: 'string' } })\n break\n case 'list':\n Object.assign(base, { type: 'array', items: spec.items ? toSchema(spec.items) : { type: 'object' } })\n break\n case 'url':\n Object.assign(base, { type: 'string', format: 'uri-reference' })\n break\n default:\n base.type = 'string'\n }\n properties[name] = base\n }\n return { type: 'object', additionalProperties: false, properties, ...(required.length ? { required } : {}) }\n }\n return {\n $schema: 'https://json-schema.org/draft/2020-12/schema',\n $id: `section:${definition.type}`,\n title: definition.label ?? definition.type,\n ...(definition.description ? { description: definition.description } : {}),\n ...toSchema(definition.schema),\n }\n}\n\n/** Map of section `type` → definition. */\nexport class SectionRegistry {\n private readonly defs = new Map<string, SectionDefinition<any, any>>()\n\n constructor(definitions: readonly SectionDefinition<any, any>[] = []) {\n for (const d of definitions) this.register(d)\n }\n\n register(definition: SectionDefinition<any, any>): this {\n this.defs.set(definition.type, definition)\n return this\n }\n\n get(type: string): SectionDefinition<any, any> | undefined {\n return this.defs.get(type)\n }\n\n has(type: string): boolean {\n return this.defs.has(type)\n }\n\n types(): string[] {\n return [...this.defs.keys()]\n }\n\n definitions(): SectionDefinition<any, any>[] {\n return [...this.defs.values()]\n }\n\n /** JSON Schemas of every registered section, keyed by type. */\n toJSONSchema(): Record<string, Record<string, unknown>> {\n return Object.fromEntries(this.definitions().map((d) => [d.type, sectionJsonSchema(d)]))\n }\n}\n\nexport function createSectionRegistry(definitions: readonly SectionDefinition<any, any>[] = []): SectionRegistry {\n return new SectionRegistry(definitions)\n}\n\nconst isDev = () => {\n const p = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n return p?.env?.NODE_ENV !== 'production'\n}\n\nexport type SectionsProps<C = unknown> = {\n sections: readonly Section[] | null | undefined\n registry: SectionRegistry\n /** Passed to every section component as `context`. */\n context?: C\n /** Rendered for unknown types (default: nothing). */\n renderUnknown?: (section: Section) => ReactNode\n /** Called with validation problems (default: `console.warn` outside production). */\n onInvalid?: (section: Section, errors: SectionPropError[]) => void\n}\n\n/**\n * Renders sections in order. Unknown types are skipped (with a dev warning),\n * props are validated against the schema and defaults are merged; a section\n * missing a required prop is skipped.\n */\nexport function Sections<C = unknown>({ sections, registry, context, renderUnknown, onInvalid }: SectionsProps<C>) {\n if (!sections?.length) return null\n return (\n <>\n {sections.map((section, index) => {\n const key = section.id || `${section.type}-${index}`\n const def = registry.get(section.type)\n if (!def) {\n if (isDev()) console.warn(`[storefront-react] Unknown section type \"${section.type}\" (id ${section.id}); skipping.`)\n return renderUnknown ? <Fragment key={key}>{renderUnknown(section)}</Fragment> : null\n }\n const { props, errors } = resolveSectionProps(def.schema, section.props)\n if (errors.length) {\n if (onInvalid) onInvalid(section, errors)\n else if (isDev()) console.warn(`[storefront-react] Section \"${section.type}\" (id ${section.id}) has invalid props:`, errors)\n }\n // A missing required prop would break the component: skip the section.\n if (errors.some((e) => e.message === 'is required' && !e.prop.includes('[') && !e.prop.includes('.'))) return null\n const Component = def.component\n return <Component key={key} {...props} section={{ id: section.id, type: section.type }} context={context} />\n })}\n </>\n )\n}\n","/**\n * Server-side theme (S3): turns the content theme from\n * `content.theme()` into CSS custom properties so the first SSR byte already\n * carries the store's brand — no localStorage, no anti-flicker script.\n *\n * Token naming follows `@asteby/metacore-theme`: camelCase keys become\n * kebab-case (`primaryForeground` → `--primary-foreground`), and each color is\n * also exposed as a Tailwind 4 theme variable (`--color-primary-foreground`).\n * metacore-theme ships its tokens as static CSS with no reusable naming\n * helper, so this module is standalone and does not depend on it.\n */\nimport type { Theme } from '@asteby/storefront'\n\nexport type ThemeCssOptions = {\n /** Selector that receives the variables (default `:root`). */\n selector?: string\n /**\n * Variable names for color tokens:\n * `both` (default) → `--color-<name>` and `--<name>`;\n * `color` → only `--color-<name>` (Tailwind 4); `metacore` → only `--<name>`.\n */\n naming?: 'both' | 'color' | 'metacore'\n /** Fallback stack appended to every font (default system sans-serif). */\n fontFallback?: string\n}\n\nconst DEFAULT_FONT_FALLBACK = 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif'\nconst MONO_FALLBACK = 'ui-monospace, SFMono-Regular, Menlo, monospace'\n\n/** `primaryForeground`, `primary_foreground`, `--color-primary-foreground` → `primary-foreground`. */\nexport function tokenName(key: string): string {\n return key\n .trim()\n .replace(/^-+/, '')\n .replace(/^color-/, '')\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[\\s_.]+/g, '-')\n .toLowerCase()\n .replace(/[^a-z0-9-]/g, '')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n}\n\n/** Rejects values that could escape the declaration or the `<style>` element. */\nexport function isSafeCssValue(value: string): boolean {\n if (!value || value.length > 200) return false\n if (/[;{}<>\\\\]/.test(value)) return false\n if (/url\\s*\\(|expression\\s*\\(|@import/i.test(value)) return false\n return true\n}\n\nfunction fontStack(family: string, role: string, fallback: string): string | null {\n const name = family.replace(/[\"']/g, '').trim()\n if (!name || !isSafeCssValue(name)) return null\n return `\"${name}\", ${role === 'mono' ? MONO_FALLBACK : fallback}`\n}\n\n/** CSS declarations (`--x:value`) for a theme, without selector. */\nexport function themeToCssVariables(theme: Partial<Theme> | null | undefined, options: ThemeCssOptions = {}): Record<string, string> {\n const naming = options.naming ?? 'both'\n const vars: Record<string, string> = {}\n for (const [key, raw] of Object.entries(theme?.tokens ?? {})) {\n const name = tokenName(key)\n const value = String(raw).trim()\n if (!name || !isSafeCssValue(value)) continue\n if (naming !== 'metacore') vars[`--color-${name}`] = value\n if (naming !== 'color') vars[`--${name}`] = value\n }\n const fallback = options.fontFallback ?? DEFAULT_FONT_FALLBACK\n for (const [role, family] of Object.entries(theme?.fonts ?? {})) {\n const name = tokenName(role)\n const stack = typeof family === 'string' ? fontStack(family, name, fallback) : null\n if (name && stack) vars[`--font-${name}`] = stack\n }\n if (theme?.radius && isSafeCssValue(theme.radius.trim())) vars['--radius'] = theme.radius.trim()\n return vars\n}\n\n/** `:root{--color-primary:#0f766e;--primary:#0f766e;...}` from a content theme. */\nexport function themeToCss(theme: Partial<Theme> | null | undefined, options: ThemeCssOptions = {}): string {\n const vars = themeToCssVariables(theme, options)\n const body = Object.entries(vars)\n .map(([k, v]) => `${k}:${v}`)\n .join(';')\n if (!body) return ''\n const selector = (options.selector ?? ':root').replace(/[{}<>]/g, '')\n return `${selector}{${body}}`\n}\n\n/** Google Fonts stylesheet URL for the theme fonts (or `null` when there are none). */\nexport function themeFontsHref(theme: Partial<Theme> | null | undefined, weights: number[] = [400, 500, 600, 700]): string | null {\n const families = [...new Set(Object.values(theme?.fonts ?? {}).map((f) => String(f).replace(/[\"']/g, '').trim()).filter((f) => f && isSafeCssValue(f)))]\n if (!families.length) return null\n const params = families.map((f) => `family=${encodeURIComponent(f).replace(/%20/g, '+')}:wght@${weights.join(';')}`).join('&')\n return `https://fonts.googleapis.com/css2?${params}&display=swap`\n}\n\nexport type ThemeStyleProps = ThemeCssOptions & {\n theme: Partial<Theme> | null | undefined\n nonce?: string\n id?: string\n}\n\n/** Emits the theme variables as a `<style>` (render it in `<head>` from the root route). */\nexport function ThemeStyle({ theme, nonce, id = 'storefront-theme', ...options }: ThemeStyleProps) {\n const css = themeToCss(theme, options)\n if (!css) return null\n return <style id={id} nonce={nonce} data-storefront-theme=\"\" dangerouslySetInnerHTML={{ __html: css }} />\n}\n","import { useCallback, useEffect, useRef, useState } from 'react'\nimport type { GeoPoint } from '@asteby/storefront'\n\nexport type GeolocationErrorCode = 'unsupported' | 'insecure' | 'denied' | 'unavailable' | 'timeout'\n\n/** Typed failure of `request()`. `message` is a ready-to-show es-MX text. */\nexport type GeolocationFailure = { code: GeolocationErrorCode; message: string }\n\n/** State of the browser permission. `unknown` when the Permissions API is missing. */\nexport type GeolocationPermission = 'granted' | 'denied' | 'prompt' | 'unknown'\n\nexport type UseGeolocationOptions = {\n enableHighAccuracy?: boolean\n /** Give up after this long (default 10 s). */\n timeoutMs?: number\n /** Accept a cached position up to this old (default 5 min). */\n maximumAge?: number\n}\n\nexport type UseGeolocationResult = {\n /** `false` on the server and until mounted, so SSR and hydration agree. */\n supported: boolean\n permission: GeolocationPermission\n status: 'idle' | 'locating' | 'success' | 'error'\n position: GeoPoint | null\n error: GeolocationFailure | null\n /**\n * Asks the browser for the position. Call it ONLY from a user gesture (a button's onClick): the hook never\n * asks by itself. Resolves to the point, or `null` on failure (see `error`).\n */\n request: () => Promise<GeoPoint | null>\n reset: () => void\n}\n\nconst MESSAGES: Record<GeolocationErrorCode, string> = {\n unsupported: 'Tu navegador no permite obtener tu ubicación.',\n insecure: 'La ubicación solo está disponible en conexiones seguras (HTTPS).',\n denied: 'No tenemos permiso para usar tu ubicación. Puedes activarlo en el navegador o escribir tu código postal.',\n unavailable: 'No pudimos determinar tu ubicación. Escribe tu código postal.',\n timeout: 'Tardó demasiado en obtener tu ubicación. Intenta de nuevo o escribe tu código postal.',\n}\n\nconst fail = (code: GeolocationErrorCode): GeolocationFailure => ({ code, message: MESSAGES[code] })\n\nconst hasGeolocation = () => typeof navigator !== 'undefined' && !!navigator.geolocation\n\n/**\n * Browser geolocation that only runs under a user action. Reading the permission state (when the Permissions\n * API exists) does not prompt. The point stays in React state: it is never stored or sent anywhere here.\n */\nexport function useGeolocation(options: UseGeolocationOptions = {}): UseGeolocationResult {\n const { enableHighAccuracy = false, timeoutMs = 10_000, maximumAge = 300_000 } = options\n const [supported, setSupported] = useState(false)\n const [permission, setPermission] = useState<GeolocationPermission>('unknown')\n const [status, setStatus] = useState<UseGeolocationResult['status']>('idle')\n const [position, setPosition] = useState<GeoPoint | null>(null)\n const [error, setError] = useState<GeolocationFailure | null>(null)\n const alive = useRef(true)\n\n useEffect(() => {\n alive.current = true\n setSupported(hasGeolocation())\n let off = () => {}\n try {\n const perms = typeof navigator !== 'undefined' ? navigator.permissions : undefined\n void perms?.query({ name: 'geolocation' }).then((p) => {\n if (!alive.current) return\n const sync = () => setPermission(p.state)\n sync()\n p.addEventListener?.('change', sync)\n off = () => p.removeEventListener?.('change', sync)\n }, () => {})\n } catch {\n // Permissions API unavailable or rejects 'geolocation': stay `unknown`.\n }\n return () => {\n alive.current = false\n off()\n }\n }, [])\n\n const request = useCallback((): Promise<GeoPoint | null> => {\n const failWith = (code: GeolocationErrorCode) => {\n if (alive.current) {\n setStatus('error')\n setError(fail(code))\n }\n return null\n }\n if (!hasGeolocation()) return Promise.resolve(failWith('unsupported'))\n if (typeof window !== 'undefined' && window.isSecureContext === false) return Promise.resolve(failWith('insecure'))\n setStatus('locating')\n setError(null)\n return new Promise((resolve) => {\n navigator.geolocation.getCurrentPosition(\n (pos) => {\n const point = { lat: pos.coords.latitude, lng: pos.coords.longitude }\n if (alive.current) {\n setPosition(point)\n setStatus('success')\n setPermission('granted')\n }\n resolve(point)\n },\n (err) => resolve(failWith(err.code === 1 ? 'denied' : err.code === 3 ? 'timeout' : 'unavailable')),\n { enableHighAccuracy, timeout: timeoutMs, maximumAge },\n )\n })\n }, [enableHighAccuracy, timeoutMs, maximumAge])\n\n const reset = useCallback(() => {\n setStatus('idle')\n setPosition(null)\n setError(null)\n }, [])\n\n return { supported, permission, status, position, error, request, reset }\n}\n","import { useEffect, useMemo, useState } from 'react'\nimport type { ShopBranch, StorefrontClient } from '@asteby/storefront'\nimport { rankByDistance, type GeoPoint } from '@asteby/storefront/geo'\nimport { useOptionalStorefront } from './context.js'\n\nexport type NearbyLocation<L extends ShopBranch = ShopBranch> = L & { distance_km: number | null }\n\nexport type UseNearestLocationsOptions<L extends ShopBranch = ShopBranch> = {\n /** The buyer's point (from `useGeolocation().request()`). */\n origin?: GeoPoint | null\n /** Postal code typed by the buyer (5 digits). The server resolves it to coordinates, so this always asks the server. */\n postalCode?: string | null\n /** Branches to rank. Defaults to `shop.branches` from the provider. */\n locations?: readonly L[]\n /** Keep the closest N. */\n limit?: number\n /** Keep those within this many km. */\n radiusKm?: number\n /** Force the server (`locations.nearest`) for `origin` instead of ranking `locations` in the browser. */\n remote?: boolean\n /** Defaults to the provider's client. */\n client?: StorefrontClient\n}\n\nexport type UseNearestLocationsResult<L extends ShopBranch = ShopBranch> = {\n locations: NearbyLocation<L>[]\n status: 'idle' | 'loading' | 'success' | 'error'\n error: Error | null\n /** `local`: ranked in the browser, the point never leaves it. `remote`: answered by the server. */\n source: 'local' | 'remote' | null\n}\n\nconst EMPTY: readonly ShopBranch[] = []\nconst IDLE = { locations: [], status: 'idle', error: null, source: null } as const\n\n/**\n * Branches ordered by distance. With an `origin` and branches at hand (explicit or `shop.branches`) the ranking\n * runs in the browser with haversine and the coordinates are sent nowhere. `postalCode` (or `remote`) asks the\n * server, which rounds and never stores the point. With zero branches, or neither origin nor postal code, the\n * result is empty and `idle`.\n */\nexport function useNearestLocations<L extends ShopBranch = ShopBranch>(options: UseNearestLocationsOptions<L> = {}): UseNearestLocationsResult<L> {\n const { origin = null, postalCode = null, limit, radiusKm, remote = false } = options\n const sf = useOptionalStorefront()\n const client = options.client ?? sf?.client ?? null\n const branches = (options.locations ?? sf?.shop?.branches ?? EMPTY) as readonly L[]\n const lat = origin?.lat\n const lng = origin?.lng\n const hasOrigin = lat !== undefined && lng !== undefined\n const cp = postalCode?.trim() || null\n\n const mode = useMemo<'local' | 'remote' | null>(() => {\n if (cp) return client ? 'remote' : null\n if (!hasOrigin) return null\n if (remote) return client ? 'remote' : null\n return branches.length ? 'local' : null\n }, [cp, hasOrigin, remote, client, branches.length])\n\n const local = useMemo<NearbyLocation<L>[]>(() => {\n if (mode !== 'local' || !hasOrigin) return []\n return rankByDistance(branches, { lat, lng }, { ...(radiusKm !== undefined ? { radiusKm } : {}), ...(limit !== undefined ? { limit } : {}) })\n .map(({ item, distanceKm }) => ({ ...item, distance_km: distanceKm }))\n }, [mode, branches, lat, lng, radiusKm, limit, hasOrigin])\n\n const [remoteState, setRemoteState] = useState<{ key: string; nodes: NearbyLocation<L>[] } | { key: string; error: Error } | null>(null)\n const key = mode === 'remote' ? (cp ? `cp:${cp}` : `ll:${lat},${lng}`) : ''\n\n useEffect(() => {\n if (mode !== 'remote' || !client) return\n const ctrl = new AbortController()\n const req = cp\n ? client.locations.list({ postal_code: cp }, { signal: ctrl.signal })\n : client.locations.nearest({ lat: lat!, lng: lng! }, { signal: ctrl.signal })\n req.then(\n (res) => !ctrl.signal.aborted && setRemoteState({ key, nodes: res.nodes as unknown as NearbyLocation<L>[] }),\n (err: unknown) => !ctrl.signal.aborted && setRemoteState({ key, error: err instanceof Error ? err : new Error(String(err)) }),\n )\n return () => ctrl.abort()\n }, [mode, client, key, cp, lat, lng])\n\n return useMemo(() => {\n if (mode === 'local') return { locations: local, status: 'success', error: null, source: 'local' } as const\n if (mode !== 'remote') return IDLE as unknown as UseNearestLocationsResult<L>\n if (!remoteState || remoteState.key !== key) return { locations: [], status: 'loading', error: null, source: 'remote' } as const\n if ('error' in remoteState) return { locations: [], status: 'error', error: remoteState.error, source: 'remote' } as const\n let nodes = remoteState.nodes\n if (radiusKm !== undefined) nodes = nodes.filter((n) => n.distance_km == null || n.distance_km <= radiusKm)\n if (limit !== undefined) nodes = nodes.slice(0, Math.max(0, limit))\n return { locations: nodes, status: 'success', error: null, source: 'remote' } as const\n }, [mode, local, remoteState, key, radiusKm, limit])\n}\n","import { useCallback, useEffect, useMemo, useState } from 'react'\nimport type { ShopBranch } from '@asteby/storefront'\nimport { useOptionalStorefront } from './context.js'\n\n/** Query param that carries the chosen branch (also the default `name` of `<LocationPicker>`). */\nexport const SELECTED_LOCATION_PARAM = 'sucursal'\n/** localStorage key of \"Mi sucursal\". Never a cookie: the choice is per browser and is not sent to the server. */\nexport const SELECTED_LOCATION_STORAGE_KEY = 'sf_sucursal'\n\nconst CHANGE_EVENT = 'storefront:selected-location'\n\nconst storage = (): Storage | null => {\n try {\n return typeof localStorage === 'undefined' ? null : localStorage\n } catch {\n return null // blocked storage throws on access\n }\n}\n\n/**\n * The saved branch id: `?sucursal=` wins over localStorage. Pure helper for loaders and tests; on the server\n * pass the request's search string (`new URL(request.url).search`) and no storage.\n */\nexport function readSelectedLocationId(\n { search = typeof location === 'undefined' ? '' : location.search, store = storage(), param = SELECTED_LOCATION_PARAM, storageKey = SELECTED_LOCATION_STORAGE_KEY }:\n { search?: string; store?: Pick<Storage, 'getItem'> | null; param?: string; storageKey?: string } = {},\n): string | null {\n const fromUrl = new URLSearchParams(search).get(param)\n if (fromUrl) return fromUrl\n try {\n return store?.getItem(storageKey) || null\n } catch {\n return null\n }\n}\n\nexport type UseSelectedLocationOptions = {\n /** Branches to validate against. Defaults to `shop.branches` from `<StorefrontProvider>`. */\n locations?: readonly ShopBranch[]\n /** Id already known on the server (from `?sucursal=`), so SSR and hydration render the same. */\n initialId?: string | null\n param?: string\n storageKey?: string\n /** Mirror the choice in the address bar with `history.replaceState` (default true). */\n syncUrl?: boolean\n}\n\nexport type UseSelectedLocationResult<L extends ShopBranch = ShopBranch> = {\n id: string | null\n location: L | null\n /** `false` until the saved choice has been read on the client. */\n ready: boolean\n select: (id: string) => void\n clear: () => void\n}\n\nconst EMPTY: readonly ShopBranch[] = []\n\n/**\n * \"Mi sucursal\": the chosen branch lives in the URL (`?sucursal=<id>`, shareable) and in localStorage. It is\n * never written to a cookie, so it does not travel with every request. An id that is not among `locations`\n * is ignored and forgotten; with zero branches nothing is ever selected.\n */\nexport function useSelectedLocation<L extends ShopBranch = ShopBranch>(options: UseSelectedLocationOptions & { locations?: readonly L[] } = {}): UseSelectedLocationResult<L> {\n const { initialId = null, param = SELECTED_LOCATION_PARAM, storageKey = SELECTED_LOCATION_STORAGE_KEY, syncUrl = true } = options\n const sf = useOptionalStorefront()\n const locations = (options.locations ?? sf?.shop?.branches ?? EMPTY) as readonly L[]\n const [raw, setRaw] = useState<string | null>(initialId)\n const [ready, setReady] = useState(false)\n\n useEffect(() => {\n const read = () => setRaw(readSelectedLocationId({ param, storageKey }))\n read()\n setReady(true)\n window.addEventListener(CHANGE_EVENT, read)\n window.addEventListener('storage', read)\n window.addEventListener('popstate', read)\n return () => {\n window.removeEventListener(CHANGE_EVENT, read)\n window.removeEventListener('storage', read)\n window.removeEventListener('popstate', read)\n }\n }, [param, storageKey])\n\n const location = useMemo(() => (raw ? locations.find((l) => l.id === raw) ?? null : null), [raw, locations])\n const id = location?.id ?? null\n\n // A valid choice that came from a shared link is remembered; a stale id (branch removed or hidden) is forgotten.\n useEffect(() => {\n if (!ready || !raw || !locations.length) return\n try {\n if (location) storage()?.setItem(storageKey, raw)\n else storage()?.removeItem(storageKey)\n } catch { /* storage blocked */ }\n }, [ready, raw, locations, location, storageKey])\n\n const write = useCallback(\n (next: string | null) => {\n try {\n if (next) storage()?.setItem(storageKey, next)\n else storage()?.removeItem(storageKey)\n } catch {\n // Storage full or blocked: the URL (if synced) and React state still carry the choice.\n }\n if (syncUrl && typeof history !== 'undefined') {\n const url = new URL(window.location.href)\n if (next) url.searchParams.set(param, next)\n else url.searchParams.delete(param)\n history.replaceState(history.state, '', url)\n }\n setRaw(next)\n window.dispatchEvent(new Event(CHANGE_EVENT))\n },\n [param, storageKey, syncUrl],\n )\n\n const select = useCallback((next: string) => write(next), [write])\n const clear = useCallback(() => write(null), [write])\n return { id, location, ready, select, clear }\n}\n","import {\n useEffect,\n useId,\n useState,\n type ComponentPropsWithoutRef,\n type FormEvent,\n type ReactNode,\n} from 'react'\nimport { formatMoney, type Money, type ShopBranch } from '@asteby/storefront'\nimport { directionsUrl, openStatus, type GeoPoint, type OpeningHours, type OpenStatus as OpenStatusData } from '@asteby/storefront/geo'\nimport { useOptionalStorefront } from './context.js'\nimport { useGeolocation } from './geolocation.js'\nimport { SELECTED_LOCATION_PARAM } from './selected-location.js'\n\n// Headless: no styles and no class names. Every component renders `null` when there are no branches.\n\nconst EMPTY: readonly ShopBranch[] = []\n\n/** `locations` prop, else `shop.branches` from the provider, else none. */\nfunction useLocationsOrShop<L extends ShopBranch>(locations: readonly L[] | undefined): readonly L[] {\n const sf = useOptionalStorefront()\n return locations ?? ((sf?.shop?.branches ?? EMPTY) as readonly L[])\n}\n\n// ---------------------------------------------------------------------------\n// LocationList\n// ---------------------------------------------------------------------------\n\nexport type LocationItemState = { index: number; selected: boolean }\n\nexport type LocationListProps<L extends ShopBranch = ShopBranch> = {\n locations?: readonly L[]\n /** Marks one item with `data-selected` / `aria-current`. */\n selectedId?: string | null\n /** Renders each item's content. Defaults to name and address. */\n children?: (location: L, state: LocationItemState) => ReactNode\n} & Omit<ComponentPropsWithoutRef<'ul'>, 'children'>\n\n/** `<ul>` of branches; the content of every `<li>` is yours (render prop). */\nexport function LocationList<L extends ShopBranch = ShopBranch>({ locations, selectedId, children, ...rest }: LocationListProps<L>) {\n const list = useLocationsOrShop(locations)\n if (!list.length) return null\n return (\n <ul {...rest}>\n {list.map((loc, index) => {\n const selected = loc.id === selectedId\n return (\n <li key={loc.id} data-selected={selected || undefined} aria-current={selected || undefined}>\n {children ? children(loc, { index, selected }) : (\n <>\n <span>{loc.name}</span> <span>{loc.address}</span>\n </>\n )}\n </li>\n )\n })}\n </ul>\n )\n}\n\n// ---------------------------------------------------------------------------\n// LocationPicker\n// ---------------------------------------------------------------------------\n\nexport type LocationPickerProps<L extends ShopBranch = ShopBranch> = {\n /** Accessible name of the group (rendered as `<legend>`). */\n legend: ReactNode\n locations?: readonly L[]\n /** Controlled value (branch id). */\n value?: string | null\n defaultValue?: string | null\n onChange?: (id: string, location: L) => void\n /** Radio `name` (default `sucursal`, the same param `useSelectedLocation` reads). */\n name?: string\n /** Content of each option next to its radio. Defaults to name and address. */\n children?: (location: L, state: { checked: boolean }) => ReactNode\n} & Omit<ComponentPropsWithoutRef<'fieldset'>, 'children' | 'onChange' | 'defaultValue'>\n\n/**\n * `<fieldset>` of native radio buttons: keyboard and screen-reader behaviour comes from the browser, and inside\n * a GET `<form>` it submits `?sucursal=<id>` without JavaScript.\n */\nexport function LocationPicker<L extends ShopBranch = ShopBranch>({\n legend, locations, value, defaultValue = null, onChange, name = SELECTED_LOCATION_PARAM, children, ...rest\n}: LocationPickerProps<L>) {\n const list = useLocationsOrShop(locations)\n const [inner, setInner] = useState<string | null>(defaultValue)\n if (!list.length) return null\n const current = value !== undefined ? value : inner\n return (\n <fieldset {...rest}>\n <legend>{legend}</legend>\n {list.map((loc) => {\n const checked = loc.id === current\n return (\n <label key={loc.id} data-checked={checked || undefined}>\n <input\n type=\"radio\"\n name={name}\n value={loc.id}\n checked={checked}\n onChange={() => {\n if (value === undefined) setInner(loc.id)\n onChange?.(loc.id, loc)\n }}\n />{' '}\n {children ? children(loc, { checked }) : (\n <>\n <span>{loc.name}</span> <span>{loc.address}</span>\n </>\n )}\n </label>\n )\n })}\n </fieldset>\n )\n}\n\n// ---------------------------------------------------------------------------\n// OpenStatus\n// ---------------------------------------------------------------------------\n\nexport type OpenStatusLabels = { open: string; closed: string }\n\nexport type OpenStatusProps = {\n /** Reads `opening_hours` and `timezone` from it. */\n location?: Pick<ShopBranch, 'opening_hours' | 'timezone'>\n hours?: OpeningHours\n /** IANA zone (default: the branch's, else `America/Mexico_City`). */\n timezone?: string\n /** Fixed instant, for tests and SSR snapshots. Without it the status is computed after mount and refreshed every minute. */\n now?: Date\n labels?: Partial<OpenStatusLabels>\n children?: (status: OpenStatusData) => ReactNode\n} & Omit<ComponentPropsWithoutRef<'span'>, 'children'>\n\nconst DEFAULT_TZ = 'America/Mexico_City'\n\n/**\n * \"Abierto\" / \"Cerrado\" from `openStatus`. The clock makes server and client disagree, so without `now` it\n * renders nothing until mounted. Renders `null` without hours or with an unknown time zone.\n */\nexport function OpenStatus({ location, hours, timezone, now, labels, children, ...rest }: OpenStatusProps) {\n const h = hours ?? location?.opening_hours\n const tz = timezone ?? location?.timezone ?? DEFAULT_TZ\n const [tick, setTick] = useState<Date | null>(null)\n useEffect(() => {\n if (now) return\n setTick(new Date())\n const t = setInterval(() => setTick(new Date()), 60_000)\n return () => clearInterval(t)\n }, [now])\n const at = now ?? tick\n if (!h || !at) return null\n let status: OpenStatusData\n try {\n status = openStatus(h, tz, at)\n } catch {\n return null // RangeError: unknown time zone\n }\n const text = { open: 'Abierto', closed: 'Cerrado', ...labels }\n return (\n <span data-state={status.open ? 'open' : 'closed'} {...rest}>\n {children ? children(status) : status.open ? text.open : text.closed}\n </span>\n )\n}\n\n// ---------------------------------------------------------------------------\n// DirectionsLink\n// ---------------------------------------------------------------------------\n\nexport type DirectionsLinkProps = {\n location: Pick<ShopBranch, 'lat' | 'lng' | 'address' | 'city'>\n provider?: 'google' | 'apple' | 'geo'\n children?: ReactNode\n} & Omit<ComponentPropsWithoutRef<'a'>, 'href' | 'children'>\n\n/** Link to directions in the maps app. `null` when the branch has neither coordinates nor address. */\nexport function DirectionsLink({ location, provider, children = 'Cómo llegar', ...rest }: DirectionsLinkProps) {\n const href = directionsUrl(location, provider ? { provider } : {})\n if (!href) return null\n return (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...rest} href={href}>\n {children}\n </a>\n )\n}\n\n// ---------------------------------------------------------------------------\n// PickupOption\n// ---------------------------------------------------------------------------\n\nexport type PickupInfo<L extends ShopBranch = ShopBranch> = {\n location: L\n /** `null` = free. Amount as sent by OPS; nothing is calculated here. */\n fee: Money | null\n free: boolean\n /** Formatted `fee` (`null` when free). */\n feeText: string | null\n prepDays: number\n}\n\nexport type PickupOptionProps<L extends ShopBranch = ShopBranch> = {\n location: L\n locale?: string\n children?: (info: PickupInfo<L>) => ReactNode\n} & Omit<ComponentPropsWithoutRef<'span'>, 'children'>\n\nconst readyText = (days: number) => (days <= 0 ? 'listo hoy' : days === 1 ? 'listo en 1 día' : `listo en ${days} días`)\n\n/** \"Recoge en sucursal\" terms: fee and preparation time. `null` when the branch does not offer pickup. */\nexport function PickupOption<L extends ShopBranch = ShopBranch>({ location, locale, children, ...rest }: PickupOptionProps<L>) {\n const sf = useOptionalStorefront()\n const p = location.pickup\n if (!p?.enabled) return null\n const free = !p.fee || Number(p.fee.amount) === 0\n const feeText = free ? null : formatMoney(p.fee!, locale ?? sf?.locale)\n const info: PickupInfo<L> = { location, fee: free ? null : p.fee, free, feeText, prepDays: p.prep_days }\n return (\n <span {...rest}>\n {children ? children(info) : `Recoge en sucursal · ${free ? 'gratis' : feeText} · ${readyText(p.prep_days)}`}\n </span>\n )\n}\n\n// ---------------------------------------------------------------------------\n// NearestLocationForm\n// ---------------------------------------------------------------------------\n\nexport type NearestLocationFormLabels = { postalCode: string; submit: string; locate: string; locating: string }\n\nexport type NearestLocationFormProps<L extends ShopBranch = ShopBranch> = {\n locations?: readonly L[]\n /** Destination of the GET (default: the current page). */\n action?: string\n /** Query param and input name (default `cp`). */\n name?: string\n defaultValue?: string\n /** With JavaScript: intercept the submit and receive the postal code. Without it the browser navigates to `?cp=`. */\n onSubmitPostalCode?: (postalCode: string, event: FormEvent<HTMLFormElement>) => void\n /** Shows a \"use my location\" button (only when the browser supports it); it asks permission on click. */\n onLocate?: (point: GeoPoint) => void\n labels?: Partial<NearestLocationFormLabels>\n} & Omit<ComponentPropsWithoutRef<'form'>, 'action' | 'method' | 'onSubmit' | 'defaultValue'>\n\n/**\n * `<form method=\"get\">` with a postal-code field: works without JavaScript (navigates to `?cp=06000`). Add\n * `onSubmitPostalCode` / `onLocate` to enhance it. Renders `null` when there are no branches.\n */\nexport function NearestLocationForm<L extends ShopBranch = ShopBranch>({\n locations, action, name = 'cp', defaultValue, onSubmitPostalCode, onLocate, labels, children, ...rest\n}: NearestLocationFormProps<L>) {\n const list = useLocationsOrShop(locations)\n const id = useId()\n const geo = useGeolocation()\n if (!list.length) return null\n const text = { postalCode: 'Código postal', submit: 'Buscar sucursales', locate: 'Usar mi ubicación', locating: 'Buscando…', ...labels }\n return (\n <form\n method=\"get\"\n {...(action !== undefined ? { action } : {})}\n {...rest}\n onSubmit={onSubmitPostalCode ? (e) => {\n e.preventDefault()\n const value = new FormData(e.currentTarget).get(name)\n onSubmitPostalCode(typeof value === 'string' ? value.trim() : '', e)\n } : undefined}\n >\n <label htmlFor={id}>{text.postalCode}</label>{' '}\n <input\n id={id}\n name={name}\n type=\"text\"\n inputMode=\"numeric\"\n autoComplete=\"postal-code\"\n pattern=\"[0-9]{5}\"\n maxLength={5}\n required\n {...(defaultValue !== undefined ? { defaultValue } : {})}\n />{' '}\n <button type=\"submit\">{text.submit}</button>\n {onLocate && geo.supported && (\n <button\n type=\"button\"\n disabled={geo.status === 'locating'}\n onClick={() => void geo.request().then((p) => p && onLocate(p))}\n >\n {geo.status === 'locating' ? text.locating : text.locate}\n </button>\n )}\n {geo.error && <span role=\"alert\">{geo.error.message}</span>}\n {children}\n </form>\n )\n}\n"]}