{"version":3,"sources":["../../src/islands/index.ts","../../src/islands/client.ts","../../src/islands/format.ts","../../src/islands/product-card.ts","../../src/islands/cart.ts","../../src/islands/checkout-status.ts"],"sourcesContent":["/**\n * F136 Phase 1 — Browser-side shop islands.\n *\n * Mount-and-go widgets the host site loads on its product / cart /\n * checkout pages. Each island is a function that scans the document\n * for its mount selector and wires up event handlers; the cart-changed\n * `CustomEvent` keeps multiple islands in sync without a global store.\n *\n * Convenience entry-point that mounts all three at once:\n *   import { mountShopIslands } from '@webhouse/cms-shop/islands';\n *   mountShopIslands();\n */\nexport { ShopClient, SHOP_CART_EVENT, type ShopClientOptions, type AddPayload } from './client';\nexport { formatMoney } from './format';\nexport { mountProductCards, type MountProductCardsOptions } from './product-card';\nexport { mountCart, type MountCartOptions } from './cart';\nexport {\n  mountCheckoutStatus,\n  type MountCheckoutStatusOptions,\n} from './checkout-status';\n\nimport { mountProductCards, type MountProductCardsOptions } from './product-card';\nimport { mountCart, type MountCartOptions } from './cart';\nimport {\n  mountCheckoutStatus,\n  type MountCheckoutStatusOptions,\n} from './checkout-status';\n\nexport interface MountShopIslandsOptions {\n  productCard?: MountProductCardsOptions;\n  cart?: MountCartOptions;\n  checkoutStatus?: MountCheckoutStatusOptions;\n}\n\nexport function mountShopIslands(\n  opts: MountShopIslandsOptions = {},\n): () => void {\n  const cleanups = [\n    mountProductCards(opts.productCard),\n    mountCart(opts.cart),\n    mountCheckoutStatus(opts.checkoutStatus),\n  ];\n  return () => cleanups.forEach((fn) => fn());\n}\n","/**\n * F136 Phase 1 — Browser-side cart client.\n *\n * Talks to the cart HTTP handlers via fetch + JSON. Keeps a lightweight\n * `CustomEvent` stream so multiple islands on the same page (header\n * badge, cart drawer, mini-cart) stay in sync without a global state\n * library.\n *\n * Usage from inside an island:\n *   import { ShopClient } from '@webhouse/cms-shop/islands';\n *   const shop = new ShopClient({ basePath: '/api/shop' });\n *   await shop.add({ productId, currency: 'DKK', quantity: 1 });\n */\nimport type { ShopAddress, ShopCart } from '../types';\n\nexport interface ShopClientOptions {\n  /** Base path where cart endpoints are mounted. Default: `/api/shop`. */\n  basePath?: string;\n  /** Custom fetch (testing). Default: globalThis.fetch. */\n  fetchFn?: typeof fetch;\n}\n\nexport interface AddPayload {\n  productId: string;\n  currency: string;\n  quantity?: number;\n  variantId?: string;\n  locale?: string;\n}\n\nexport interface CartChangeEvent extends CustomEvent<{ cart: ShopCart | null }> {}\n\nconst EVENT_NAME = 'cms-shop:cart-changed';\n\nexport class ShopClient {\n  private base: string;\n  private fetchFn: typeof fetch;\n  private current: ShopCart | null = null;\n\n  constructor(opts: ShopClientOptions = {}) {\n    this.base = (opts.basePath ?? '/api/shop').replace(/\\/$/, '');\n    this.fetchFn = opts.fetchFn ?? globalThis.fetch.bind(globalThis);\n  }\n\n  get cart(): ShopCart | null {\n    return this.current;\n  }\n\n  on(handler: (cart: ShopCart | null) => void): () => void {\n    if (typeof window === 'undefined') return () => {};\n    const wrap = (e: Event) => handler((e as CartChangeEvent).detail.cart);\n    window.addEventListener(EVENT_NAME, wrap);\n    return () => window.removeEventListener(EVENT_NAME, wrap);\n  }\n\n  private dispatch(cart: ShopCart | null): void {\n    this.current = cart;\n    if (typeof window === 'undefined') return;\n    window.dispatchEvent(\n      new CustomEvent(EVENT_NAME, { detail: { cart } }),\n    );\n  }\n\n  private async request(\n    path: string,\n    init: RequestInit = {},\n  ): Promise<{ cart: ShopCart | null; error?: string }> {\n    const res = await this.fetchFn(`${this.base}${path}`, {\n      credentials: 'same-origin',\n      headers: { 'content-type': 'application/json' },\n      ...init,\n    });\n    let body: { cart?: ShopCart | null; error?: string } = {};\n    try {\n      body = (await res.json()) as typeof body;\n    } catch {\n      // ignore — empty body\n    }\n    if (!res.ok) {\n      return { cart: this.current, error: body.error ?? `HTTP ${res.status}` };\n    }\n    const cart = body.cart ?? null;\n    this.dispatch(cart);\n    return { cart };\n  }\n\n  async refresh(): Promise<ShopCart | null> {\n    const { cart } = await this.request('/cart');\n    return cart;\n  }\n\n  async add(payload: AddPayload): Promise<ShopCart | null> {\n    const { cart, error } = await this.request('/cart', {\n      method: 'POST',\n      body: JSON.stringify(payload),\n    });\n    if (error) throw new Error(error);\n    return cart;\n  }\n\n  async update(\n    productId: string,\n    quantity: number,\n    variantId?: string,\n  ): Promise<ShopCart | null> {\n    const { cart, error } = await this.request('/cart', {\n      method: 'PATCH',\n      body: JSON.stringify({ productId, quantity, variantId }),\n    });\n    if (error) throw new Error(error);\n    return cart;\n  }\n\n  async remove(\n    productId: string,\n    variantId?: string,\n  ): Promise<ShopCart | null> {\n    const { cart, error } = await this.request('/cart', {\n      method: 'DELETE',\n      body: JSON.stringify({ productId, variantId }),\n    });\n    if (error) throw new Error(error);\n    return cart;\n  }\n\n  async setEmail(email: string): Promise<ShopCart | null> {\n    const { cart, error } = await this.request('/cart/email', {\n      method: 'POST',\n      body: JSON.stringify({ email }),\n    });\n    if (error) throw new Error(error);\n    return cart;\n  }\n\n  async setAddress(address: ShopAddress): Promise<ShopCart | null> {\n    const { cart, error } = await this.request('/cart/address', {\n      method: 'POST',\n      body: JSON.stringify({ address }),\n    });\n    if (error) throw new Error(error);\n    return cart;\n  }\n\n  async clear(): Promise<void> {\n    await this.request('/cart', { method: 'DELETE' });\n    this.dispatch(null);\n  }\n\n  async checkout(): Promise<{ url: string } | { error: string }> {\n    const res = await this.fetchFn(`${this.base}/checkout`, {\n      method: 'POST',\n      credentials: 'same-origin',\n      headers: { 'content-type': 'application/json' },\n    });\n    const body = (await res.json().catch(() => ({}))) as {\n      url?: string;\n      error?: string;\n    };\n    if (!res.ok || !body.url) {\n      return { error: body.error ?? `HTTP ${res.status}` };\n    }\n    return { url: body.url };\n  }\n}\n\nexport const SHOP_CART_EVENT = EVENT_NAME;\n","/**\n * F136 Phase 1 — Currency formatting helpers.\n *\n * Used by both server-side (storefront page renderer) and client-side\n * (cart island totals). Lives in /islands so islands can import without\n * pulling Stripe-SDK code into the browser bundle.\n */\nimport type { CurrencyCode, MoneyAmount } from '../types';\n\nconst FRACTIONLESS = new Set(['JPY', 'KRW', 'VND', 'IDR']);\n\nexport function formatMoney(\n  amount: MoneyAmount,\n  currency: CurrencyCode,\n  locale = 'da-DK',\n): string {\n  const cur = currency.toUpperCase();\n  const minor = FRACTIONLESS.has(cur) ? amount : amount / 100;\n  try {\n    return new Intl.NumberFormat(locale, {\n      style: 'currency',\n      currency: cur,\n      minimumFractionDigits: FRACTIONLESS.has(cur) ? 0 : 2,\n    }).format(minor);\n  } catch {\n    return `${minor.toFixed(2)} ${cur}`;\n  }\n}\n","/**\n * F136 Phase 1 — Product card island.\n *\n * Mounts inside any element with `data-cms-shop=\"product-card\"`. The\n * server-rendered markup carries product id + currency in data\n * attributes; the island wires up the \"Add to cart\" button.\n *\n * Usage:\n *   <div data-cms-shop=\"product-card\"\n *        data-product-id=\"abc123\"\n *        data-currency=\"DKK\"\n *        data-variant-id=\"optional\">\n *     <button type=\"button\" data-cms-shop-add>Add to cart</button>\n *     <span data-cms-shop-status></span>\n *   </div>\n *   <script type=\"module\">\n *     import { mountProductCards } from '/_shop/islands.js';\n *     mountProductCards();\n *   </script>\n */\nimport { ShopClient, type ShopClientOptions } from './client';\n\nexport interface MountProductCardsOptions extends ShopClientOptions {\n  /** CSS selector for product card root elements. */\n  selector?: string;\n  /** Optional callback after successful add — useful for opening the cart drawer. */\n  onAdded?(productId: string): void;\n}\n\nconst DEFAULT_SELECTOR = '[data-cms-shop=\"product-card\"]';\n\nexport function mountProductCards(\n  opts: MountProductCardsOptions = {},\n): () => void {\n  if (typeof document === 'undefined') return () => {};\n  const client = new ShopClient(opts);\n  const selector = opts.selector ?? DEFAULT_SELECTOR;\n  const cards = document.querySelectorAll<HTMLElement>(selector);\n\n  const cleanups: Array<() => void> = [];\n\n  cards.forEach((root) => {\n    const productId = root.dataset['productId'];\n    const currency = root.dataset['currency'];\n    const variantId = root.dataset['variantId'];\n    if (!productId || !currency) return;\n\n    const button = root.querySelector<HTMLButtonElement>(\n      '[data-cms-shop-add]',\n    );\n    const status = root.querySelector<HTMLElement>('[data-cms-shop-status]');\n    if (!button) return;\n\n    const handler = async (ev: Event) => {\n      ev.preventDefault();\n      button.disabled = true;\n      const original = button.textContent;\n      button.textContent = '…';\n      if (status) status.textContent = '';\n      try {\n        await client.add({\n          productId,\n          currency,\n          ...(variantId ? { variantId } : {}),\n        });\n        button.textContent = original;\n        if (status) status.textContent = 'Added ✓';\n        opts.onAdded?.(productId);\n      } catch (err) {\n        button.textContent = original;\n        const msg = err instanceof Error ? err.message : 'Failed';\n        if (status) status.textContent = msg;\n      } finally {\n        button.disabled = false;\n      }\n    };\n\n    button.addEventListener('click', handler);\n    cleanups.push(() => button.removeEventListener('click', handler));\n  });\n\n  return () => cleanups.forEach((fn) => fn());\n}\n","/**\n * F136 Phase 1 — Cart island.\n *\n * Renders into any element with `data-cms-shop=\"cart\"`. Subscribes to\n * cart changes and re-renders. Includes a Checkout button that POSTs to\n * `/api/shop/checkout` and redirects to Stripe.\n *\n *   <div data-cms-shop=\"cart\" data-locale=\"da-DK\"></div>\n *\n * Styling: minimal inline classes prefixed `cms-shop-` so consumers can\n * target them from their own CSS. We avoid pulling in any external CSS\n * — sites style their own shop.\n */\nimport { ShopClient, type ShopClientOptions } from './client';\nimport { formatMoney } from './format';\nimport type { ShopCart } from '../types';\n\nexport interface MountCartOptions extends ShopClientOptions {\n  selector?: string;\n  /** Locale for currency formatting. Default: cart.locale or 'da-DK'. */\n  locale?: string;\n  /** Strings — override for i18n. */\n  labels?: Partial<typeof DEFAULT_LABELS>;\n}\n\nconst DEFAULT_LABELS = {\n  empty: 'Your cart is empty.',\n  remove: 'Remove',\n  subtotal: 'Subtotal',\n  shipping: 'Shipping',\n  tax: 'Tax',\n  total: 'Total',\n  checkout: 'Checkout',\n  checkoutLoading: 'Redirecting…',\n  checkoutFailed: 'Checkout failed:',\n};\n\nconst DEFAULT_SELECTOR = '[data-cms-shop=\"cart\"]';\n\nexport function mountCart(opts: MountCartOptions = {}): () => void {\n  if (typeof document === 'undefined') return () => {};\n  const client = new ShopClient(opts);\n  const labels = { ...DEFAULT_LABELS, ...(opts.labels ?? {}) };\n  const roots = document.querySelectorAll<HTMLElement>(\n    opts.selector ?? DEFAULT_SELECTOR,\n  );\n  if (roots.length === 0) return () => {};\n\n  function render(root: HTMLElement, cart: ShopCart | null) {\n    const locale = opts.locale ?? root.dataset['locale'] ?? 'da-DK';\n    if (!cart || cart.items.length === 0) {\n      root.innerHTML = `<p class=\"cms-shop-cart-empty\">${escape(labels.empty)}</p>`;\n      return;\n    }\n    const lines = cart.items\n      .map((line) => {\n        const lineTotal = line.unitPrice * line.quantity;\n        return `\n          <li class=\"cms-shop-cart-line\" data-product-id=\"${escape(line.productId)}\" ${line.variantId ? `data-variant-id=\"${escape(line.variantId)}\"` : ''}>\n            ${line.imageSnapshot ? `<img class=\"cms-shop-cart-img\" src=\"${escape(line.imageSnapshot)}\" alt=\"\">` : ''}\n            <div class=\"cms-shop-cart-meta\">\n              <span class=\"cms-shop-cart-title\">${escape(line.titleSnapshot)}</span>\n              <span class=\"cms-shop-cart-unit\">${escape(formatMoney(line.unitPrice, line.currency, locale))}</span>\n            </div>\n            <input class=\"cms-shop-cart-qty\" type=\"number\" min=\"0\" value=\"${line.quantity}\" data-cms-shop-qty>\n            <span class=\"cms-shop-cart-line-total\">${escape(formatMoney(lineTotal, line.currency, locale))}</span>\n            <button type=\"button\" class=\"cms-shop-cart-remove\" data-cms-shop-remove>${escape(labels.remove)}</button>\n          </li>`;\n      })\n      .join('');\n\n    root.innerHTML = `\n      <ul class=\"cms-shop-cart-lines\">${lines}</ul>\n      <dl class=\"cms-shop-cart-totals\">\n        <dt>${escape(labels.subtotal)}</dt><dd>${escape(formatMoney(cart.subtotal, cart.currency, locale))}</dd>\n        ${cart.shippingTotal ? `<dt>${escape(labels.shipping)}</dt><dd>${escape(formatMoney(cart.shippingTotal, cart.currency, locale))}</dd>` : ''}\n        ${cart.taxTotal ? `<dt>${escape(labels.tax)}</dt><dd>${escape(formatMoney(cart.taxTotal, cart.currency, locale))}</dd>` : ''}\n        <dt class=\"cms-shop-cart-total-label\">${escape(labels.total)}</dt><dd class=\"cms-shop-cart-total\">${escape(formatMoney(cart.total, cart.currency, locale))}</dd>\n      </dl>\n      <button type=\"button\" class=\"cms-shop-cart-checkout\" data-cms-shop-checkout>${escape(labels.checkout)}</button>\n      <p class=\"cms-shop-cart-error\" data-cms-shop-error hidden></p>\n    `;\n\n    root.querySelectorAll<HTMLElement>('.cms-shop-cart-line').forEach((li) => {\n      const productId = li.dataset['productId']!;\n      const variantId = li.dataset['variantId'];\n      const qtyInput = li.querySelector<HTMLInputElement>('[data-cms-shop-qty]');\n      const removeBtn = li.querySelector<HTMLButtonElement>(\n        '[data-cms-shop-remove]',\n      );\n      qtyInput?.addEventListener('change', async () => {\n        const next = Math.max(0, parseInt(qtyInput.value, 10) || 0);\n        await client.update(productId, next, variantId);\n      });\n      removeBtn?.addEventListener('click', async () => {\n        await client.remove(productId, variantId);\n      });\n    });\n\n    const checkoutBtn = root.querySelector<HTMLButtonElement>(\n      '[data-cms-shop-checkout]',\n    );\n    const errorEl = root.querySelector<HTMLElement>('[data-cms-shop-error]');\n    checkoutBtn?.addEventListener('click', async () => {\n      checkoutBtn.disabled = true;\n      const originalText = checkoutBtn.textContent;\n      checkoutBtn.textContent = labels.checkoutLoading;\n      if (errorEl) errorEl.hidden = true;\n      const result = await client.checkout();\n      if ('url' in result) {\n        window.location.href = result.url;\n      } else {\n        checkoutBtn.disabled = false;\n        checkoutBtn.textContent = originalText;\n        if (errorEl) {\n          errorEl.textContent = `${labels.checkoutFailed} ${result.error}`;\n          errorEl.hidden = false;\n        }\n      }\n    });\n  }\n\n  // Initial render + subscription\n  const cleanups: Array<() => void> = [];\n  client.refresh().then((cart) => {\n    roots.forEach((root) => render(root, cart));\n  });\n  const off = client.on((cart) => {\n    roots.forEach((root) => render(root, cart));\n  });\n  cleanups.push(off);\n  return () => cleanups.forEach((fn) => fn());\n}\n\nfunction escape(s: string): string {\n  return String(s)\n    .replace(/&/g, '&amp;')\n    .replace(/</g, '&lt;')\n    .replace(/>/g, '&gt;')\n    .replace(/\"/g, '&quot;');\n}\n","/**\n * F136 Phase 1 — Checkout status island.\n *\n * For the success/cancel page after Stripe redirects back. Reads\n * `?session_id=…` from the URL, calls `/api/shop/checkout/session/:id`\n * to look up status, renders one of three states.\n *\n *   <div data-cms-shop=\"checkout-status\"></div>\n *\n * The host MUST mount a `/api/shop/checkout/session/:id` endpoint that\n * returns `{ status: 'paid' | 'pending' | 'failed', orderSlug?: string }`\n * — Phase 1 doesn't ship that endpoint inside the npm package because\n * order persistence is host-side.\n */\nexport interface MountCheckoutStatusOptions {\n  selector?: string;\n  basePath?: string;\n  labels?: Partial<typeof DEFAULT_LABELS>;\n  /** Optional callback when paid — host can clear local cart UI / track conversion. */\n  onPaid?(orderSlug?: string): void;\n}\n\nconst DEFAULT_LABELS = {\n  loading: 'Confirming your order…',\n  paid: 'Thank you! Your order is confirmed.',\n  pending: 'Your payment is processing — we’ll email you when it clears.',\n  failed: 'Something went wrong with the payment.',\n  retry: 'Try again',\n  noSession: 'No checkout session found.',\n  orderNumber: 'Order #',\n};\n\nconst DEFAULT_SELECTOR = '[data-cms-shop=\"checkout-status\"]';\n\nexport function mountCheckoutStatus(\n  opts: MountCheckoutStatusOptions = {},\n): () => void {\n  if (typeof document === 'undefined') return () => {};\n  const labels = { ...DEFAULT_LABELS, ...(opts.labels ?? {}) };\n  const root = document.querySelector<HTMLElement>(\n    opts.selector ?? DEFAULT_SELECTOR,\n  );\n  if (!root) return () => {};\n\n  const params = new URLSearchParams(window.location.search);\n  const sessionId = params.get('session_id');\n  if (!sessionId) {\n    root.innerHTML = `<p class=\"cms-shop-checkout-status cms-shop-status-none\">${escape(labels.noSession)}</p>`;\n    return () => {};\n  }\n\n  root.innerHTML = `<p class=\"cms-shop-checkout-status cms-shop-status-loading\">${escape(labels.loading)}</p>`;\n\n  const base = (opts.basePath ?? '/api/shop').replace(/\\/$/, '');\n  fetch(`${base}/checkout/session/${encodeURIComponent(sessionId)}`, {\n    credentials: 'same-origin',\n  })\n    .then((res) => res.json().catch(() => ({})) as Promise<{ status?: string; orderSlug?: string }>)\n    .then((body) => {\n      const status = body.status ?? 'failed';\n      const orderLine = body.orderSlug\n        ? `<p class=\"cms-shop-checkout-order\">${escape(labels.orderNumber)}${escape(body.orderSlug)}</p>`\n        : '';\n      if (status === 'paid') {\n        root.innerHTML = `\n          <p class=\"cms-shop-checkout-status cms-shop-status-paid\">${escape(labels.paid)}</p>\n          ${orderLine}\n        `;\n        opts.onPaid?.(body.orderSlug);\n      } else if (status === 'pending') {\n        root.innerHTML = `<p class=\"cms-shop-checkout-status cms-shop-status-pending\">${escape(labels.pending)}</p>${orderLine}`;\n      } else {\n        root.innerHTML = `<p class=\"cms-shop-checkout-status cms-shop-status-failed\">${escape(labels.failed)}</p>`;\n      }\n    })\n    .catch(() => {\n      root.innerHTML = `<p class=\"cms-shop-checkout-status cms-shop-status-failed\">${escape(labels.failed)}</p>`;\n    });\n\n  return () => {};\n}\n\nfunction escape(s: string): string {\n  return String(s)\n    .replace(/&/g, '&amp;')\n    .replace(/</g, '&lt;')\n    .replace(/>/g, '&gt;')\n    .replace(/\"/g, '&quot;');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgCA,IAAM,aAAa;AAEZ,IAAM,aAAN,MAAiB;AAAA,EACd;AAAA,EACA;AAAA,EACA,UAA2B;AAAA,EAEnC,YAAY,OAA0B,CAAC,GAAG;AACxC,SAAK,QAAQ,KAAK,YAAY,aAAa,QAAQ,OAAO,EAAE;AAC5D,SAAK,UAAU,KAAK,WAAW,WAAW,MAAM,KAAK,UAAU;AAAA,EACjE;AAAA,EAEA,IAAI,OAAwB;AAC1B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,GAAG,SAAsD;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