@getmicdrop/venue-calendar 4.1.15 → 4.1.17

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.
Files changed (53) hide show
  1. package/dist/{CartView-C5f1j5Hs.js → CartView-J0qckr8X.js} +9 -9
  2. package/dist/{CartView-C5f1j5Hs.js.map → CartView-J0qckr8X.js.map} +1 -1
  3. package/dist/{Checkout-DvecNf3c.js → Checkout-DQIVk8NT.js} +7 -7
  4. package/dist/{Checkout-DvecNf3c.js.map → Checkout-DQIVk8NT.js.map} +1 -1
  5. package/dist/{Checkout-CBo7hA62.js → Checkout-hmfkDuYF.js} +9 -9
  6. package/dist/{Checkout-CBo7hA62.js.map → Checkout-hmfkDuYF.js.map} +1 -1
  7. package/dist/{CheckoutTimer-DKEkJsj6.js → CheckoutTimer-D6qbPXmL.js} +5 -5
  8. package/dist/{CheckoutTimer-DKEkJsj6.js.map → CheckoutTimer-D6qbPXmL.js.map} +1 -1
  9. package/dist/{ClockIcon-CmMqPYTc.js → ClockIcon-CeZ6tDgN.js} +2 -2
  10. package/dist/{ClockIcon-CmMqPYTc.js.map → ClockIcon-CeZ6tDgN.js.map} +1 -1
  11. package/dist/{CollectionView-JLn9DbvF.js → CollectionView-ClJC-3Ot.js} +5 -5
  12. package/dist/{CollectionView-JLn9DbvF.js.map → CollectionView-ClJC-3Ot.js.map} +1 -1
  13. package/dist/{Event-XctRpVD-.js → Event-DnguMKoM.js} +9 -9
  14. package/dist/{Event-XctRpVD-.js.map → Event-DnguMKoM.js.map} +1 -1
  15. package/dist/{EventPage-B-q_x22S.js → EventPage-CicdCaIY.js} +8 -8
  16. package/dist/{EventPage-B-q_x22S.js.map → EventPage-CicdCaIY.js.map} +1 -1
  17. package/dist/{Heading-LLAkeTId.js → Heading-Dpc12_QS.js} +2 -2
  18. package/dist/{Heading-LLAkeTId.js.map → Heading-Dpc12_QS.js.map} +1 -1
  19. package/dist/{ScarcityBadge-DDLJvGtf.js → ScarcityBadge-CyrniwIo.js} +2 -2
  20. package/dist/{ScarcityBadge-DDLJvGtf.js.map → ScarcityBadge-CyrniwIo.js.map} +1 -1
  21. package/dist/{SeriesPage-DqQH12gK.js → SeriesPage-BmPai8Z4.js} +5 -5
  22. package/dist/{SeriesPage-DqQH12gK.js.map → SeriesPage-BmPai8Z4.js.map} +1 -1
  23. package/dist/{Spinner-CkMnUr96.js → Spinner-CRWt7IYY.js} +2 -2
  24. package/dist/{Spinner-CkMnUr96.js.map → Spinner-CRWt7IYY.js.map} +1 -1
  25. package/dist/{Success-DrGDRgwr.js → Success-Cwhbg_gL.js} +9 -9
  26. package/dist/{Success-DrGDRgwr.js.map → Success-Cwhbg_gL.js.map} +1 -1
  27. package/dist/{Text-Brn9wgwJ.js → Text-CfL6ex6f.js} +2 -2
  28. package/dist/{Text-Brn9wgwJ.js.map → Text-CfL6ex6f.js.map} +1 -1
  29. package/dist/{VenueCalendar-61UHjI0X.js → VenueCalendar-DHAmKNT-.js} +13 -13
  30. package/dist/{VenueCalendar-61UHjI0X.js.map → VenueCalendar-DHAmKNT-.js.map} +1 -1
  31. package/dist/{ViewTicketsEmbed-BsN2t6ci.js → ViewTicketsEmbed-otZKZMFe.js} +5 -5
  32. package/dist/{ViewTicketsEmbed-BsN2t6ci.js.map → ViewTicketsEmbed-otZKZMFe.js.map} +1 -1
  33. package/dist/{index-C5CqqHOv.js → index-CwsI9tPj.js} +3 -3
  34. package/dist/{index-C5CqqHOv.js.map → index-CwsI9tPj.js.map} +1 -1
  35. package/dist/{modalManager.svelte-BA3spi6s.js → modalManager.svelte-BDEfA4mR.js} +2 -2
  36. package/dist/{modalManager.svelte-BA3spi6s.js.map → modalManager.svelte-BDEfA4mR.js.map} +1 -1
  37. package/dist/{promo-CsNOVD7R.js → promo-BYT85gME.js} +2 -2
  38. package/dist/{promo-CsNOVD7R.js.map → promo-BYT85gME.js.map} +1 -1
  39. package/dist/{serverTotals-DpIBNMeu.js → serverTotals-CxpmLBUi.js} +2 -2
  40. package/dist/{serverTotals-DpIBNMeu.js.map → serverTotals-CxpmLBUi.js.map} +1 -1
  41. package/dist/{shareCopyFeedback.svelte-Bw2rZ70L.js → shareCopyFeedback.svelte-BVLGQMN_.js} +2 -2
  42. package/dist/{shareCopyFeedback.svelte-Bw2rZ70L.js.map → shareCopyFeedback.svelte-BVLGQMN_.js.map} +1 -1
  43. package/dist/{showcase-state-options-BtFe4ghP.js → showcase-state-options-y0ZwSjmL.js} +2 -2
  44. package/dist/{showcase-state-options-BtFe4ghP.js.map → showcase-state-options-y0ZwSjmL.js.map} +1 -1
  45. package/dist/{transform-BAUS_LFt.js → transform-C4GBIj6D.js} +2 -2
  46. package/dist/{transform-BAUS_LFt.js.map → transform-C4GBIj6D.js.map} +1 -1
  47. package/dist/{utm-ChiZKwVY.js → utm-DUS9p3Ww.js} +2 -2
  48. package/dist/{utm-ChiZKwVY.js.map → utm-DUS9p3Ww.js.map} +1 -1
  49. package/dist/venue-calendar.css +1 -1
  50. package/dist/venue-calendar.es.js +2 -2
  51. package/dist/venue-calendar.iife.js +2 -2
  52. package/dist/venue-calendar.umd.js +1 -1
  53. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"utm-ChiZKwVY.js","sources":["../node_modules/js-cookie/dist/js.cookie.mjs","../src/lib/utils/cookies.ts","../src/lib/utils/checkoutState.ts","../src/lib/utils/orderApi.ts","../src/lib/utils/utm.ts"],"sourcesContent":["/*! js-cookie v3.0.8 | MIT */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (key === '__proto__') continue\n target[key] = source[key];\n }\n }\n return target\n}\n\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n\nfunction init(converter, defaultAttributes) {\n function set(name, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n name = encodeURIComponent(name)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n name + '=' + converter.write(value, name) + stringifiedAttributes)\n }\n\n function get(name) {\n if (typeof document === 'undefined' || (arguments.length && !name)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var found = decodeURIComponent(parts[0]);\n if (!(found in jar)) jar[found] = converter.read(value, found);\n if (name === found) {\n break\n }\n } catch (_e) {\n // Do nothing...\n }\n }\n\n return name ? jar[name] : jar\n }\n\n return Object.create(\n {\n set: set,\n get: get,\n remove: function (name, attributes) {\n set(\n name,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n\nexport { api as default };\n","/**\r\n * Cookie management wrappers around js-cookie.\r\n *\r\n * DIVERGENCE (no-shadowed-helper rename-keep): SC 6.24.109 exports canonical\r\n * `setCookie`/`getCookie`, but those are typed to the branded `CookieName`\r\n * registry (`COOKIE_NAMES` + builders), return `string | null`, and take a\r\n * `{ maxAge, path }` options shape while writing `document.cookie` directly\r\n * with a hardcoded `.get-micdrop.com` production domain. VC is a STANDALONE\r\n * embeddable widget: it reads/writes many widget-owned cookie names that are\r\n * NOT in SC's registry (`order-id-${eventId}`, `checkout-promo-reveal-*`,\r\n * `checkout-promo-discount-type-*`, …), passes plain `string` names, relies on\r\n * `string | undefined` reads, and uses js-cookie's `CookieAttributes` options\r\n * (@stale-doc-comment-allow: CookieAttributes — js-cookie ships no .d.ts of its\r\n * own and @types/js-cookie is not installed, so nothing in the tree can confirm\r\n * this name; it is a real js-cookie API, not a deleted local component.)\r\n * (`{ expires, path, … }`). Adopting SC's branded surface would be a large\r\n * behavioral migration (expiry semantics, branded-name minting, registry\r\n * additions in SC's repo) with no user-facing benefit, so the local js-cookie\r\n * wrapper is kept and re-exported under the public `setCookie`/`getCookie`\r\n * names. The aliased re-export satisfies `micdrop/no-shadowed-helper` without\r\n * suppression — no eslint-disable.\r\n */\r\nimport Cookies from 'js-cookie';\r\n\r\nfunction setCookieLocal(\r\n name: string,\r\n value: string,\r\n options: Parameters<typeof Cookies.set>[2] = {}\r\n): void {\r\n Cookies.set(name, value, options);\r\n}\r\n\r\nfunction getCookieLocal(name: string): string | undefined {\r\n return Cookies.get(name);\r\n}\r\n\r\nfunction removeCookieLocal(name: string): void {\r\n Cookies.remove(name);\r\n}\r\n\r\nexport {\r\n setCookieLocal as setCookie,\r\n getCookieLocal as getCookie,\r\n removeCookieLocal as removeCookie,\r\n};\r\n","// @storage-escape: Canonical checkout-state persistence wrapper — this\n// module IS the localStorage layer for checkout state (cart, promo,\n// totals) across page refreshes. utility-storage record documents\n// the persistence-wrapper shape as exempt.\n\nimport { createLogger } from '@getmicdrop/svelte-components';\n/**\n * Checkout state persistence: localStorage with cookie fallback for migration\n */\nimport { getCookie, setCookie, removeCookie } from './cookies';\n\nconst logger = createLogger('checkoutState');\n\ninterface CheckoutTicket {\n ID: number | string;\n name: string;\n price: number;\n type?: string;\n visibility?: string;\n salesChannel?: string;\n [key: string]: unknown;\n}\n\ninterface CheckoutState {\n quantities: Record<string, number>;\n donationAmounts: Record<string, number>;\n promocode: string;\n promoDiscountAmount: number;\n tickets: CheckoutTicket[];\n}\n\ninterface PersistCheckoutParams {\n eventID: string;\n quantities: Record<string, number>;\n donationAmounts?: Record<string, number>;\n promocode: string;\n promoDiscountAmount: number;\n tickets: CheckoutTicket[];\n}\n\n/**\n * Load checkout state from localStorage (preferred) with cookie fallback for migration\n */\nexport function loadCheckoutStateFromCookies(eventID: string): CheckoutState {\n let quantities: Record<string, number> = {};\n let donationAmounts: Record<string, number> = {};\n let tickets: CheckoutTicket[] = [];\n let promocode = '';\n let promoDiscountAmount = 0;\n\n if (typeof window === 'undefined') {\n return {\n quantities,\n donationAmounts,\n promocode,\n promoDiscountAmount,\n tickets,\n };\n }\n\n // Try localStorage first (new approach)\n try {\n const stored = localStorage.getItem(`checkout-state-${eventID}`); // @storage-escape: canonical checkout-state persistence wrapper — this module IS the localStorage layer (see file header)\n if (stored) {\n const parsed = JSON.parse(stored);\n return {\n quantities: parsed.quantities || {},\n donationAmounts: parsed.donationAmounts || {},\n promocode: parsed.promocode || '',\n promoDiscountAmount: parseFloat(parsed.promoDiscountAmount) || 0,\n tickets: parsed.tickets || [],\n };\n }\n } catch (e) {\n logger.warn('Failed to parse checkout state from localStorage:', e);\n }\n\n // Fallback to cookies for migration (old approach)\n try {\n quantities = JSON.parse(\n getCookie(`checkout-quantities-${eventID}`) || '{}'\n );\n } catch (e) {\n logger.warn('Failed to parse checkout quantities cookie:', e);\n quantities = {};\n }\n\n try {\n tickets = JSON.parse(getCookie(`checkout-tickets-${eventID}`) || '[]');\n } catch (e) {\n logger.warn('Failed to parse checkout tickets cookie:', e);\n tickets = [];\n }\n\n promocode = getCookie(`checkout-promocode-${eventID}`) || '';\n // Per-event, like every other promo cookie. Temporary local key —\n // `converge-promo-cookie-onto-sc-canonical` replaces it with the\n // svelte-components builder. See PromocodeInput.svelte for the full note.\n promoDiscountAmount = parseFloat(\n getCookie(`checkout-promo-discount-${eventID}`) || '0'\n );\n\n // If we found data in cookies, migrate it to localStorage and drop the\n // cookies we just migrated. Only those — the promo REVEAL cookies have no\n // localStorage home (CheckoutState has no reveal field; CartView reads them\n // straight from the jar), so a blanket clear here would silently revoke a\n // live reveal on the next page load, for a buyer still holding a valid code.\n if (Object.keys(quantities).length > 0 || tickets.length > 0 || promocode) {\n persistCheckoutState({\n eventID,\n quantities,\n donationAmounts,\n promocode,\n promoDiscountAmount,\n tickets,\n });\n clearMigratedCheckoutCookies(eventID);\n }\n\n return {\n quantities,\n donationAmounts,\n promocode,\n promoDiscountAmount,\n tickets,\n };\n}\n\n/**\n * The legacy cookies whose payload `loadCheckoutStateFromCookies` migrates into\n * localStorage. Cleared once they've been migrated — nothing is lost, the data\n * now lives in `checkout-state-${eventID}`.\n */\nfunction clearMigratedCheckoutCookies(eventID: string): void {\n removeCookie(`checkout-quantities-${eventID}`);\n removeCookie(`checkout-tickets-${eventID}`);\n removeCookie(`checkout-promocode-${eventID}`);\n removeCookie(`checkout-promo-discount-${eventID}`);\n}\n\n/**\n * Clear checkout state from both localStorage and cookies\n *\n * @stale-doc-comment-allow: Remove — the button's visible LABEL, not a component.\n *\n * This is the ONE cleanup point for a finished checkout — Success.svelte calls it\n * after a purchase, CartView calls it when the buyer abandons the cart. EVERY\n * cookie the checkout/promo flow writes for an event must die here; do not\n * sprinkle removeCookie() at call sites. The five promo cookies below are exactly\n * what PromocodeInput.svelte writes (its `Remove` button clears the same five),\n * two of which CartView.svelte also re-writes on a promo change.\n *\n * The three promo cookies past the code+amount pair used to survive checkout on a\n * 1-day expiry. `checkout-promo-reveal-*` is the ONLY thing hiding hidden tickets\n * — /tickets/event/{id} ships them in the payload with no promo code and there is\n * no server-side backstop — so a reveal cookie outliving the purchase left comps,\n * industry seats and VIP holds buyable, with no code entered, to whoever opened\n * the event next on that browser.\n */\nexport function clearCheckoutCookies(eventID: string): void {\n // Clear localStorage (new approach)\n if (typeof window !== 'undefined') {\n localStorage.removeItem(`checkout-state-${eventID}`); // @storage-escape: canonical checkout-state persistence wrapper — this module IS the localStorage layer (see file header)\n }\n\n clearMigratedCheckoutCookies(eventID);\n\n // The rest of what the promo flow writes. No localStorage home, no other\n // owner — the checkout ending is the only thing that retires them.\n removeCookie(`checkout-promo-discount-type-${eventID}`);\n removeCookie(`checkout-promo-reveal-${eventID}`);\n removeCookie(`checkout-promo-reveal-ids-${eventID}`);\n}\n\n/**\n * Persist checkout state to localStorage\n * Uses localStorage instead of cookies to avoid size limits and reduce request overhead\n */\nexport function persistCheckoutState({\n eventID,\n quantities,\n donationAmounts,\n promocode,\n promoDiscountAmount,\n tickets,\n}: PersistCheckoutParams): void {\n if (typeof window === 'undefined') return;\n\n // Store minimal ticket data to avoid storage bloat\n const minimalTickets = (tickets || []).map(t => ({\n ID: t.ID,\n name: t.name,\n price: t.price,\n type: t.type, // Include type for donation ticket detection\n visibility: t.visibility,\n salesChannel: t.salesChannel,\n }));\n\n const state = {\n quantities: quantities || {},\n donationAmounts: donationAmounts || {},\n promocode: promocode || '',\n promoDiscountAmount: promoDiscountAmount || 0,\n tickets: minimalTickets,\n updatedAt: Date.now(),\n };\n\n try {\n localStorage.setItem(`checkout-state-${eventID}`, JSON.stringify(state)); // @storage-escape: canonical checkout-state persistence wrapper — this module IS the localStorage layer (see file header)\n } catch (e) {\n logger.warn('Failed to persist checkout state to localStorage:', e);\n }\n}\n\n/**\n * Ensure order ID exists, create if not\n */\nexport async function ensureOrderIdExists(eventId: string): Promise<string> {\n const existingOrderId = getCookie(`order-id-${eventId}`);\n\n if (existingOrderId) {\n return existingOrderId;\n }\n\n const newOrderId = `order-${eventId}-${Date.now()}`;\n // SameSite=None; Secure survives iframe embeds on third-party origins, but is\n // dropped by the browser over plain HTTP — so fall back to Lax on a non-HTTPS\n // origin (local dev / self-hosted HTTP staging). See the same guard in\n // orderApi.ts's checkout-cartid write.\n const httpsOrigin =\n typeof window !== 'undefined' && window.location.protocol === 'https:';\n setCookie(`order-id-${eventId}`, newOrderId, {\n secure: httpsOrigin,\n sameSite: httpsOrigin ? ('none' as const) : ('lax' as const),\n path: '/',\n });\n\n return newOrderId;\n}\n","import { COOKIE_NAMES, createLogger } from '@getmicdrop/svelte-components';\nimport { ApiError } from '@getmicdrop/svelte-components/errors';\n/**\n * Order-related API calls: getVenueDetails, initiateOrder, getOrder,\n * createPaymentIntent, validatePaymentIntent, getClientIP\n *\n * @legacy-retire-with=?legacy=1\n * LEGACY — slated for deletion. Do NOT add new code here and do NOT build\n * canonicals against the untyped `[key: string]: unknown` bag interfaces below\n * (VenueResponse / PaymentIntentResponse / ValidatePaymentResponse /\n * OrderResponse). They survive only via `as` casts and exist purely for\n * backward compat. The canonical, typed wire->domain home for all of this is\n * `src/lib/api/transformers/*` (parseOrder, parseCart, parseGiftCardApplication,\n * parseEventPerformers, parseVenue, parseEvent) composed by the `src/lib/api/*`\n * clients (orders.ts, gift-cards.ts, events.ts). Retire this module behind the\n * `?legacy=1` flag once its remaining consumer is migrated to `$lib/api/*`.\n *\n * Live consumer (as of this change): `src/lib/utils/utils.js` re-exports\n * getClientIP / getVenueDetails / initiateOrder / getOrder / createPaymentIntent\n * / validatePaymentIntent from here (the `$lib/utils/utils.js` back-compat\n * barrel). That barrel is the single retirement blocker to plan around.\n */\nimport { apiGet, apiPost } from '$lib/api/client';\nimport { buildAuthHeaders } from '$lib/api/authHeaders';\nimport { getCookie, setCookie } from './cookies';\n\nconst logger = createLogger('orderApi');\n\ninterface OrderResult {\n success: boolean;\n uuid?: string;\n serviceFee?: number;\n subtotal?: number;\n error?: string;\n errorType?: 'inventory' | 'server' | 'network';\n}\n\ninterface CartData {\n eventID?: string | number;\n quantities?: Record<string, number>;\n donationAmounts?: Record<string, number>;\n [key: string]: unknown;\n}\n\ninterface PaymentIntentResponse {\n clientSecret?: string;\n stripe_publishable_key?: string;\n [key: string]: unknown;\n}\n\ninterface ValidatePaymentResponse {\n [key: string]: unknown;\n}\n\ninterface OrderResponse {\n [key: string]: unknown;\n}\n\ninterface VenueResponse {\n [key: string]: unknown;\n}\n\n/**\n * @deprecated IP is now resolved server-side via request headers\n */\nexport async function getClientIP(): Promise<string | null> {\n return null;\n}\n\nexport async function getVenueDetails(\n venueID: string | number\n): Promise<VenueResponse> {\n try {\n const result = await apiGet<VenueResponse>(`/venues/${venueID}`);\n\n if (!result.success) {\n throw new ApiError(\n result.error ?? `API error: ${result.statusCode}`,\n result.statusCode ?? 0,\n { endpoint: `/venues/${venueID}`, method: 'GET' }\n );\n }\n\n return result.data as VenueResponse;\n } catch (error) {\n logger.error('getVenueDetails error:', error);\n throw error;\n }\n}\n\nexport async function initiateOrder(\n cartData: CartData = {}\n): Promise<OrderResult> {\n try {\n const ip = await getClientIP();\n\n const { eventID, quantities, donationAmounts, ...restCartData } = cartData;\n\n // Convert quantities keys to numbers and eventID to number (API expects numeric types)\n const numericQuantities = quantities\n ? Object.fromEntries(\n Object.entries(quantities).map(([k, v]) => [parseInt(k, 10), v])\n )\n : {};\n\n // Convert donationAmounts keys to numbers and values to floats\n const numericDonationAmounts = donationAmounts\n ? Object.fromEntries(\n Object.entries(donationAmounts)\n .filter(([, v]) => parseFloat(String(v)) > 0)\n .map(([k, v]) => [parseInt(k, 10), parseFloat(String(v))])\n )\n : undefined;\n\n const orderPayload = {\n purchaserIP: ip,\n eventID: eventID ? parseInt(String(eventID), 10) : undefined,\n quantities: numericQuantities,\n ...(numericDonationAmounts &&\n Object.keys(numericDonationAmounts).length > 0\n ? { donationAmounts: numericDonationAmounts }\n : {}),\n ...restCartData,\n };\n\n const result = await apiPost<Record<string, unknown>>(\n `/orders/create`,\n orderPayload\n );\n\n const data = result.data ?? {};\n\n // Check for API errors (including 200-with-error-field pattern)\n if (!result.success || data['error']) {\n const errorMessage =\n (data['error'] as string) ||\n (data['message'] as string) ||\n result.error ||\n 'Order creation failed';\n // Check for inventory-related errors\n const isInventoryError =\n errorMessage.toLowerCase().includes('inventory') ||\n errorMessage.toLowerCase().includes('sold out') ||\n errorMessage.toLowerCase().includes('not available') ||\n errorMessage.toLowerCase().includes('insufficient') ||\n result.statusCode === 409; // Conflict status often used for inventory issues\n\n return {\n success: false,\n error: errorMessage,\n errorType: isInventoryError ? 'inventory' : 'server',\n };\n }\n\n // SameSite=None; Secure lets the cart cookie survive iframe embeds on\n // third-party origins (Safari ITP / Chrome SameSite-Lax-by-default).\n // Without this, embedding the calendar in another venue's site silently\n // drops the cart on every navigation. BUT a Secure cookie is dropped by the\n // browser over plain HTTP, so on a non-HTTPS origin (local dev / a\n // self-hosted HTTP staging host) fall back to Lax without Secure — else the\n // checkout page finds no session (\"select tickets first\"). A first-party\n // HTTP page is never an embed context, so Lax is correct there.\n const httpsOrigin =\n typeof window !== 'undefined' && window.location.protocol === 'https:';\n setCookie(\n 'checkout-cartid',\n (data['uuid'] as string) || (data['cartUUID'] as string),\n {\n secure: httpsOrigin,\n sameSite: httpsOrigin ? ('none' as const) : ('lax' as const),\n path: '/',\n }\n );\n return {\n success: true,\n uuid: (data['uuid'] as string) || (data['cartUUID'] as string),\n serviceFee: (data['serviceFee'] as number) ?? 0,\n subtotal: (data['subtotal'] as number) ?? 0,\n };\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Network error';\n logger.error('Order initiation failed:', err);\n return {\n success: false,\n error: message,\n errorType: 'network',\n };\n }\n}\n\nexport async function getOrder(orderId: string): Promise<OrderResponse> {\n try {\n const result = await apiGet<OrderResponse>(`/orders/${orderId}`);\n\n if (!result.success) {\n const errorMessage =\n result.error ?? `Failed to fetch order (${result.statusCode})`;\n logger.error('getOrder error response:', errorMessage);\n throw new ApiError(errorMessage, result.statusCode ?? 0, {\n endpoint: `/orders/${orderId}`,\n method: 'GET',\n });\n }\n\n return result.data as OrderResponse;\n } catch (err) {\n logger.error('getOrder error:', err);\n throw err;\n }\n}\n\nexport async function createPaymentIntent(\n cartId: string,\n quantities: Record<string, number>,\n donationAmounts?: Record<string, number>\n): Promise<PaymentIntentResponse> {\n const token = getCookie(COOKIE_NAMES.OPERATOR_TOKEN);\n\n try {\n const result = await apiPost<PaymentIntentResponse>(\n `/orders/${cartId}/payment-intent`,\n {\n productQuantities: quantities,\n ...(donationAmounts && Object.keys(donationAmounts).length > 0\n ? { donationAmounts }\n : {}),\n },\n {\n headers: buildAuthHeaders(token),\n }\n );\n\n if (!result.success) {\n logger.error('Payment intent creation failed:', result.error);\n throw new ApiError(\n result.error === 'Request timed out'\n ? 'Request timed out. Please check your connection and try again.'\n : result.error?.includes('Failed to fetch')\n ? 'Unable to connect to payment server. Please check your internet connection or try again later.'\n : (result.error ??\n `Failed to create payment intent: ${result.statusCode}`),\n result.statusCode ?? 0,\n { endpoint: `/orders/${cartId}/payment-intent`, method: 'POST' }\n );\n }\n\n return result.data as PaymentIntentResponse;\n } catch (err: unknown) {\n logger.error('createPaymentIntent error:', err);\n // Re-throw the error so the caller can handle it\n throw err;\n }\n}\n\nexport async function validatePaymentIntent(\n cartId: string,\n payload: Record<string, unknown>\n): Promise<ValidatePaymentResponse | null> {\n try {\n const token = getCookie(COOKIE_NAMES.OPERATOR_TOKEN);\n\n const result = await apiPost<ValidatePaymentResponse>(\n `/orders/${cartId}/validate-payment`,\n payload,\n {\n headers: buildAuthHeaders(token),\n }\n );\n\n return result.data ?? null;\n } catch (err) {\n logger.error('validatePaymentIntent error:', err);\n return null;\n }\n}\n","// @fetch-escape: widget-intentional.\n// @api-client-escape: fire-and-forget UTM beacon — keeps raw fetch (GET, no body, response ignored).\n// Migrating to apiPost broke the GET contract; apiGet would parse JSON on a no-body 200 and log a false-positive error.\nimport { createLogger } from '@getmicdrop/svelte-components';\nimport { getPublicBaseUrl } from '../api/client.js';\nimport { normalizeUtmValue, DIRECT_SOURCE } from '../tracking/normalize.js';\nimport { trackEventView } from '../tracking/index.js';\nconst logger = createLogger('utm');\n\n/**\n * UTM source tracking\n */\n\n/**\n * Track UTM source for an event (parameter named venueID for backwards compatibility\n * but actually represents eventID).\n *\n * Bumps the legacy per-source click COUNTERS (utm_counters) that power the old\n * UTM analytics page. The source is normalized at write time (lowercased, spaces\n * → underscores) and an empty source resolves to the ONE canonical default\n * `direct` — so the counter buckets match the beacon + order buckets (the\n * historical `Direct`/`''`/`direct` split is dead).\n */\nexport async function trackUTMSource(venueID: string | number): Promise<void> {\n const urlParams = new URLSearchParams(window.location.search);\n const utmSource =\n normalizeUtmValue(urlParams.get('utm_source')) || DIRECT_SOURCE;\n\n try {\n // Route through the configured base (getPublicBaseUrl) instead of a\n // hard-coded prod origin, so a first-party host that points the client at\n // its own backend (QA/staging via configureVenueCalendar → same-origin) has\n // this beacon follow suit. Stays a raw fire-and-forget GET (see the escapes\n // above); getPublicBaseUrl already appends `/api/v2/public`.\n await fetch(\n `${getPublicBaseUrl()}/utm/${venueID}/${encodeURIComponent(utmSource)}`\n );\n } catch (err) {\n logger.error('UTM tracking failed:', err);\n }\n}\n\n/**\n * Event-detail page-view tracking — the `event_view` funnel moment.\n *\n * Delegates to the canonical funnel-beacon service (`$lib/tracking`), which\n * fires the extended `POST /track/pageview` beacon carrying the normalized utm\n * set, persistent visitorId (consent-gated), sessionId, widgetId, deviceType,\n * referrer and pageUrl, and keeps the first-party attribution store fresh. The\n * beacon is deduplicated per session and fire-and-forget.\n *\n * Kept as a thin wrapper (rather than inlining `trackEventView` at the call\n * site) so the existing `trackPageView(eventId)` call in EventPage stays\n * unchanged and the pre-tracking-rebuild external surface is preserved.\n */\nexport async function trackPageView(eventID: string | number): Promise<void> {\n await trackEventView(eventID);\n}\n"],"names":["assign","target","i","source","key","defaultConverter","value","init","converter","defaultAttributes","set","name","attributes","stringifiedAttributes","attributeName","get","cookies","jar","parts","found","api","setCookieLocal","options","Cookies","getCookieLocal","removeCookieLocal","logger","createLogger","loadCheckoutStateFromCookies","eventID","quantities","donationAmounts","tickets","promocode","promoDiscountAmount","stored","parsed","e","getCookie","persistCheckoutState","clearMigratedCheckoutCookies","removeCookie","clearCheckoutCookies","minimalTickets","t","state","ensureOrderIdExists","eventId","existingOrderId","newOrderId","httpsOrigin","setCookie","getClientIP","getVenueDetails","venueID","result","apiGet","ApiError","error","initiateOrder","cartData","ip","restCartData","numericQuantities","k","v","numericDonationAmounts","orderPayload","apiPost","data","errorMessage","isInventoryError","err","message","getOrder","orderId","trackUTMSource","urlParams","utmSource","normalizeUtmValue","DIRECT_SOURCE","getPublicBaseUrl"],"mappings":";AACA,SAASA,EAAQC,GAAQ;AACvB,WAASC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AACzC,QAAIC,IAAS,UAAUD,CAAC;AACxB,aAASE,KAAOD;AACd,MAAIC,MAAQ,gBACZH,EAAOG,CAAG,IAAID,EAAOC,CAAG;AAAA,EAE5B;AACA,SAAOH;AACT;AAEA,IAAII,IAAmB;AAAA,EACrB,MAAM,SAAUC,GAAO;AACrB,WAAIA,EAAM,CAAC,MAAM,QACfA,IAAQA,EAAM,MAAM,GAAG,EAAE,IAEpBA,EAAM,QAAQ,oBAAoB,kBAAkB;AAAA,EAC7D;AAAA,EACA,OAAO,SAAUA,GAAO;AACtB,WAAO,mBAAmBA,CAAK,EAAE;AAAA,MAC/B;AAAA,MACA;AAAA,IACN;AAAA,EACE;AACF;AAEA,SAASC,EAAKC,GAAWC,GAAmB;AAC1C,WAASC,EAAIC,GAAML,GAAOM,GAAY;AACpC,QAAI,SAAO,WAAa,MAIxB;AAAA,MAAAA,IAAaZ,EAAO,IAAIS,GAAmBG,CAAU,GAEjD,OAAOA,EAAW,WAAY,aAChCA,EAAW,UAAU,IAAI,KAAK,KAAK,QAAQA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AAA,EAEf;AACF;AAEA,eAAsBC,EAASC,GAAyC;AACtE,MAAI;AACF,UAAMpB,IAAS,MAAMC,EAAsB,WAAWmB,CAAO,EAAE;AAE/D,QAAI,CAACpB,EAAO,SAAS;AACnB,YAAMe,IACJf,EAAO,SAAS,0BAA0BA,EAAO,UAAU;AAC7D7B,YAAAA,EAAO,MAAM,4BAA4B4C,CAAY,GAC/C,IAAIb,EAASa,GAAcf,EAAO,cAAc,GAAG;AAAA,QACvD,UAAU,WAAWoB,CAAO;AAAA,QAC5B,QAAQ;AAAA,MAAA,CACT;AAAA,IACH;AAEA,WAAOpB,EAAO;AAAA,EAChB,SAASiB,GAAK;AACZ9C,UAAAA,EAAO,MAAM,mBAAmB8C,CAAG,GAC7BA;AAAA,EACR;AACF;AC1MA,MAAM9C,IAASC,EAAa,KAAK;AAgBjC,eAAsBiD,EAAetB,GAAyC;AAC5E,QAAMuB,IAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM,GACtDC,IACJC,EAAkBF,EAAU,IAAI,YAAY,CAAC,KAAKG;AAEpD,MAAI;AAMF,UAAM;AAAA,MACJ,GAAGC,GAAkB,QAAQ3B,CAAO,IAAI,mBAAmBwB,CAAS,CAAC;AAAA,IAAA;AAAA,EAEzE,SAASN,GAAK;AACZ,IAAA9C,EAAO,MAAM,wBAAwB8C,CAAG;AAAA,EAC1C;AACF;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"utm-DUS9p3Ww.js","sources":["../node_modules/js-cookie/dist/js.cookie.mjs","../src/lib/utils/cookies.ts","../src/lib/utils/checkoutState.ts","../src/lib/utils/orderApi.ts","../src/lib/utils/utm.ts"],"sourcesContent":["/*! js-cookie v3.0.8 | MIT */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (key === '__proto__') continue\n target[key] = source[key];\n }\n }\n return target\n}\n\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n\nfunction init(converter, defaultAttributes) {\n function set(name, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n name = encodeURIComponent(name)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n name + '=' + converter.write(value, name) + stringifiedAttributes)\n }\n\n function get(name) {\n if (typeof document === 'undefined' || (arguments.length && !name)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var found = decodeURIComponent(parts[0]);\n if (!(found in jar)) jar[found] = converter.read(value, found);\n if (name === found) {\n break\n }\n } catch (_e) {\n // Do nothing...\n }\n }\n\n return name ? jar[name] : jar\n }\n\n return Object.create(\n {\n set: set,\n get: get,\n remove: function (name, attributes) {\n set(\n name,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n\nexport { api as default };\n","/**\r\n * Cookie management wrappers around js-cookie.\r\n *\r\n * DIVERGENCE (no-shadowed-helper rename-keep): SC 6.24.109 exports canonical\r\n * `setCookie`/`getCookie`, but those are typed to the branded `CookieName`\r\n * registry (`COOKIE_NAMES` + builders), return `string | null`, and take a\r\n * `{ maxAge, path }` options shape while writing `document.cookie` directly\r\n * with a hardcoded `.get-micdrop.com` production domain. VC is a STANDALONE\r\n * embeddable widget: it reads/writes many widget-owned cookie names that are\r\n * NOT in SC's registry (`order-id-${eventId}`, `checkout-promo-reveal-*`,\r\n * `checkout-promo-discount-type-*`, …), passes plain `string` names, relies on\r\n * `string | undefined` reads, and uses js-cookie's `CookieAttributes` options\r\n * (@stale-doc-comment-allow: CookieAttributes — js-cookie ships no .d.ts of its\r\n * own and @types/js-cookie is not installed, so nothing in the tree can confirm\r\n * this name; it is a real js-cookie API, not a deleted local component.)\r\n * (`{ expires, path, … }`). Adopting SC's branded surface would be a large\r\n * behavioral migration (expiry semantics, branded-name minting, registry\r\n * additions in SC's repo) with no user-facing benefit, so the local js-cookie\r\n * wrapper is kept and re-exported under the public `setCookie`/`getCookie`\r\n * names. The aliased re-export satisfies `micdrop/no-shadowed-helper` without\r\n * suppression — no eslint-disable.\r\n */\r\nimport Cookies from 'js-cookie';\r\n\r\nfunction setCookieLocal(\r\n name: string,\r\n value: string,\r\n options: Parameters<typeof Cookies.set>[2] = {}\r\n): void {\r\n Cookies.set(name, value, options);\r\n}\r\n\r\nfunction getCookieLocal(name: string): string | undefined {\r\n return Cookies.get(name);\r\n}\r\n\r\nfunction removeCookieLocal(name: string): void {\r\n Cookies.remove(name);\r\n}\r\n\r\nexport {\r\n setCookieLocal as setCookie,\r\n getCookieLocal as getCookie,\r\n removeCookieLocal as removeCookie,\r\n};\r\n","// @storage-escape: Canonical checkout-state persistence wrapper — this\n// module IS the localStorage layer for checkout state (cart, promo,\n// totals) across page refreshes. utility-storage record documents\n// the persistence-wrapper shape as exempt.\n\nimport { createLogger } from '@getmicdrop/svelte-components';\n/**\n * Checkout state persistence: localStorage with cookie fallback for migration\n */\nimport { getCookie, setCookie, removeCookie } from './cookies';\n\nconst logger = createLogger('checkoutState');\n\ninterface CheckoutTicket {\n ID: number | string;\n name: string;\n price: number;\n type?: string;\n visibility?: string;\n salesChannel?: string;\n [key: string]: unknown;\n}\n\ninterface CheckoutState {\n quantities: Record<string, number>;\n donationAmounts: Record<string, number>;\n promocode: string;\n promoDiscountAmount: number;\n tickets: CheckoutTicket[];\n}\n\ninterface PersistCheckoutParams {\n eventID: string;\n quantities: Record<string, number>;\n donationAmounts?: Record<string, number>;\n promocode: string;\n promoDiscountAmount: number;\n tickets: CheckoutTicket[];\n}\n\n/**\n * Load checkout state from localStorage (preferred) with cookie fallback for migration\n */\nexport function loadCheckoutStateFromCookies(eventID: string): CheckoutState {\n let quantities: Record<string, number> = {};\n let donationAmounts: Record<string, number> = {};\n let tickets: CheckoutTicket[] = [];\n let promocode = '';\n let promoDiscountAmount = 0;\n\n if (typeof window === 'undefined') {\n return {\n quantities,\n donationAmounts,\n promocode,\n promoDiscountAmount,\n tickets,\n };\n }\n\n // Try localStorage first (new approach)\n try {\n const stored = localStorage.getItem(`checkout-state-${eventID}`); // @storage-escape: canonical checkout-state persistence wrapper — this module IS the localStorage layer (see file header)\n if (stored) {\n const parsed = JSON.parse(stored);\n return {\n quantities: parsed.quantities || {},\n donationAmounts: parsed.donationAmounts || {},\n promocode: parsed.promocode || '',\n promoDiscountAmount: parseFloat(parsed.promoDiscountAmount) || 0,\n tickets: parsed.tickets || [],\n };\n }\n } catch (e) {\n logger.warn('Failed to parse checkout state from localStorage:', e);\n }\n\n // Fallback to cookies for migration (old approach)\n try {\n quantities = JSON.parse(\n getCookie(`checkout-quantities-${eventID}`) || '{}'\n );\n } catch (e) {\n logger.warn('Failed to parse checkout quantities cookie:', e);\n quantities = {};\n }\n\n try {\n tickets = JSON.parse(getCookie(`checkout-tickets-${eventID}`) || '[]');\n } catch (e) {\n logger.warn('Failed to parse checkout tickets cookie:', e);\n tickets = [];\n }\n\n promocode = getCookie(`checkout-promocode-${eventID}`) || '';\n // Per-event, like every other promo cookie. Temporary local key —\n // `converge-promo-cookie-onto-sc-canonical` replaces it with the\n // svelte-components builder. See PromocodeInput.svelte for the full note.\n promoDiscountAmount = parseFloat(\n getCookie(`checkout-promo-discount-${eventID}`) || '0'\n );\n\n // If we found data in cookies, migrate it to localStorage and drop the\n // cookies we just migrated. Only those — the promo REVEAL cookies have no\n // localStorage home (CheckoutState has no reveal field; CartView reads them\n // straight from the jar), so a blanket clear here would silently revoke a\n // live reveal on the next page load, for a buyer still holding a valid code.\n if (Object.keys(quantities).length > 0 || tickets.length > 0 || promocode) {\n persistCheckoutState({\n eventID,\n quantities,\n donationAmounts,\n promocode,\n promoDiscountAmount,\n tickets,\n });\n clearMigratedCheckoutCookies(eventID);\n }\n\n return {\n quantities,\n donationAmounts,\n promocode,\n promoDiscountAmount,\n tickets,\n };\n}\n\n/**\n * The legacy cookies whose payload `loadCheckoutStateFromCookies` migrates into\n * localStorage. Cleared once they've been migrated — nothing is lost, the data\n * now lives in `checkout-state-${eventID}`.\n */\nfunction clearMigratedCheckoutCookies(eventID: string): void {\n removeCookie(`checkout-quantities-${eventID}`);\n removeCookie(`checkout-tickets-${eventID}`);\n removeCookie(`checkout-promocode-${eventID}`);\n removeCookie(`checkout-promo-discount-${eventID}`);\n}\n\n/**\n * Clear checkout state from both localStorage and cookies\n *\n * @stale-doc-comment-allow: Remove — the button's visible LABEL, not a component.\n *\n * This is the ONE cleanup point for a finished checkout — Success.svelte calls it\n * after a purchase, CartView calls it when the buyer abandons the cart. EVERY\n * cookie the checkout/promo flow writes for an event must die here; do not\n * sprinkle removeCookie() at call sites. The five promo cookies below are exactly\n * what PromocodeInput.svelte writes (its `Remove` button clears the same five),\n * two of which CartView.svelte also re-writes on a promo change.\n *\n * The three promo cookies past the code+amount pair used to survive checkout on a\n * 1-day expiry. `checkout-promo-reveal-*` is the ONLY thing hiding hidden tickets\n * — /tickets/event/{id} ships them in the payload with no promo code and there is\n * no server-side backstop — so a reveal cookie outliving the purchase left comps,\n * industry seats and VIP holds buyable, with no code entered, to whoever opened\n * the event next on that browser.\n */\nexport function clearCheckoutCookies(eventID: string): void {\n // Clear localStorage (new approach)\n if (typeof window !== 'undefined') {\n localStorage.removeItem(`checkout-state-${eventID}`); // @storage-escape: canonical checkout-state persistence wrapper — this module IS the localStorage layer (see file header)\n }\n\n clearMigratedCheckoutCookies(eventID);\n\n // The rest of what the promo flow writes. No localStorage home, no other\n // owner — the checkout ending is the only thing that retires them.\n removeCookie(`checkout-promo-discount-type-${eventID}`);\n removeCookie(`checkout-promo-reveal-${eventID}`);\n removeCookie(`checkout-promo-reveal-ids-${eventID}`);\n}\n\n/**\n * Persist checkout state to localStorage\n * Uses localStorage instead of cookies to avoid size limits and reduce request overhead\n */\nexport function persistCheckoutState({\n eventID,\n quantities,\n donationAmounts,\n promocode,\n promoDiscountAmount,\n tickets,\n}: PersistCheckoutParams): void {\n if (typeof window === 'undefined') return;\n\n // Store minimal ticket data to avoid storage bloat\n const minimalTickets = (tickets || []).map(t => ({\n ID: t.ID,\n name: t.name,\n price: t.price,\n type: t.type, // Include type for donation ticket detection\n visibility: t.visibility,\n salesChannel: t.salesChannel,\n }));\n\n const state = {\n quantities: quantities || {},\n donationAmounts: donationAmounts || {},\n promocode: promocode || '',\n promoDiscountAmount: promoDiscountAmount || 0,\n tickets: minimalTickets,\n updatedAt: Date.now(),\n };\n\n try {\n localStorage.setItem(`checkout-state-${eventID}`, JSON.stringify(state)); // @storage-escape: canonical checkout-state persistence wrapper — this module IS the localStorage layer (see file header)\n } catch (e) {\n logger.warn('Failed to persist checkout state to localStorage:', e);\n }\n}\n\n/**\n * Ensure order ID exists, create if not\n */\nexport async function ensureOrderIdExists(eventId: string): Promise<string> {\n const existingOrderId = getCookie(`order-id-${eventId}`);\n\n if (existingOrderId) {\n return existingOrderId;\n }\n\n const newOrderId = `order-${eventId}-${Date.now()}`;\n // SameSite=None; Secure survives iframe embeds on third-party origins, but is\n // dropped by the browser over plain HTTP — so fall back to Lax on a non-HTTPS\n // origin (local dev / self-hosted HTTP staging). See the same guard in\n // orderApi.ts's checkout-cartid write.\n const httpsOrigin =\n typeof window !== 'undefined' && window.location.protocol === 'https:';\n setCookie(`order-id-${eventId}`, newOrderId, {\n secure: httpsOrigin,\n sameSite: httpsOrigin ? ('none' as const) : ('lax' as const),\n path: '/',\n });\n\n return newOrderId;\n}\n","import { COOKIE_NAMES, createLogger } from '@getmicdrop/svelte-components';\nimport { ApiError } from '@getmicdrop/svelte-components/errors';\n/**\n * Order-related API calls: getVenueDetails, initiateOrder, getOrder,\n * createPaymentIntent, validatePaymentIntent, getClientIP\n *\n * @legacy-retire-with=?legacy=1\n * LEGACY — slated for deletion. Do NOT add new code here and do NOT build\n * canonicals against the untyped `[key: string]: unknown` bag interfaces below\n * (VenueResponse / PaymentIntentResponse / ValidatePaymentResponse /\n * OrderResponse). They survive only via `as` casts and exist purely for\n * backward compat. The canonical, typed wire->domain home for all of this is\n * `src/lib/api/transformers/*` (parseOrder, parseCart, parseGiftCardApplication,\n * parseEventPerformers, parseVenue, parseEvent) composed by the `src/lib/api/*`\n * clients (orders.ts, gift-cards.ts, events.ts). Retire this module behind the\n * `?legacy=1` flag once its remaining consumer is migrated to `$lib/api/*`.\n *\n * Live consumer (as of this change): `src/lib/utils/utils.js` re-exports\n * getClientIP / getVenueDetails / initiateOrder / getOrder / createPaymentIntent\n * / validatePaymentIntent from here (the `$lib/utils/utils.js` back-compat\n * barrel). That barrel is the single retirement blocker to plan around.\n */\nimport { apiGet, apiPost } from '$lib/api/client';\nimport { buildAuthHeaders } from '$lib/api/authHeaders';\nimport { getCookie, setCookie } from './cookies';\n\nconst logger = createLogger('orderApi');\n\ninterface OrderResult {\n success: boolean;\n uuid?: string;\n serviceFee?: number;\n subtotal?: number;\n error?: string;\n errorType?: 'inventory' | 'server' | 'network';\n}\n\ninterface CartData {\n eventID?: string | number;\n quantities?: Record<string, number>;\n donationAmounts?: Record<string, number>;\n [key: string]: unknown;\n}\n\ninterface PaymentIntentResponse {\n clientSecret?: string;\n stripe_publishable_key?: string;\n [key: string]: unknown;\n}\n\ninterface ValidatePaymentResponse {\n [key: string]: unknown;\n}\n\ninterface OrderResponse {\n [key: string]: unknown;\n}\n\ninterface VenueResponse {\n [key: string]: unknown;\n}\n\n/**\n * @deprecated IP is now resolved server-side via request headers\n */\nexport async function getClientIP(): Promise<string | null> {\n return null;\n}\n\nexport async function getVenueDetails(\n venueID: string | number\n): Promise<VenueResponse> {\n try {\n const result = await apiGet<VenueResponse>(`/venues/${venueID}`);\n\n if (!result.success) {\n throw new ApiError(\n result.error ?? `API error: ${result.statusCode}`,\n result.statusCode ?? 0,\n { endpoint: `/venues/${venueID}`, method: 'GET' }\n );\n }\n\n return result.data as VenueResponse;\n } catch (error) {\n logger.error('getVenueDetails error:', error);\n throw error;\n }\n}\n\nexport async function initiateOrder(\n cartData: CartData = {}\n): Promise<OrderResult> {\n try {\n const ip = await getClientIP();\n\n const { eventID, quantities, donationAmounts, ...restCartData } = cartData;\n\n // Convert quantities keys to numbers and eventID to number (API expects numeric types)\n const numericQuantities = quantities\n ? Object.fromEntries(\n Object.entries(quantities).map(([k, v]) => [parseInt(k, 10), v])\n )\n : {};\n\n // Convert donationAmounts keys to numbers and values to floats\n const numericDonationAmounts = donationAmounts\n ? Object.fromEntries(\n Object.entries(donationAmounts)\n .filter(([, v]) => parseFloat(String(v)) > 0)\n .map(([k, v]) => [parseInt(k, 10), parseFloat(String(v))])\n )\n : undefined;\n\n const orderPayload = {\n purchaserIP: ip,\n eventID: eventID ? parseInt(String(eventID), 10) : undefined,\n quantities: numericQuantities,\n ...(numericDonationAmounts &&\n Object.keys(numericDonationAmounts).length > 0\n ? { donationAmounts: numericDonationAmounts }\n : {}),\n ...restCartData,\n };\n\n const result = await apiPost<Record<string, unknown>>(\n `/orders/create`,\n orderPayload\n );\n\n const data = result.data ?? {};\n\n // Check for API errors (including 200-with-error-field pattern)\n if (!result.success || data['error']) {\n const errorMessage =\n (data['error'] as string) ||\n (data['message'] as string) ||\n result.error ||\n 'Order creation failed';\n // Check for inventory-related errors\n const isInventoryError =\n errorMessage.toLowerCase().includes('inventory') ||\n errorMessage.toLowerCase().includes('sold out') ||\n errorMessage.toLowerCase().includes('not available') ||\n errorMessage.toLowerCase().includes('insufficient') ||\n result.statusCode === 409; // Conflict status often used for inventory issues\n\n return {\n success: false,\n error: errorMessage,\n errorType: isInventoryError ? 'inventory' : 'server',\n };\n }\n\n // SameSite=None; Secure lets the cart cookie survive iframe embeds on\n // third-party origins (Safari ITP / Chrome SameSite-Lax-by-default).\n // Without this, embedding the calendar in another venue's site silently\n // drops the cart on every navigation. BUT a Secure cookie is dropped by the\n // browser over plain HTTP, so on a non-HTTPS origin (local dev / a\n // self-hosted HTTP staging host) fall back to Lax without Secure — else the\n // checkout page finds no session (\"select tickets first\"). A first-party\n // HTTP page is never an embed context, so Lax is correct there.\n const httpsOrigin =\n typeof window !== 'undefined' && window.location.protocol === 'https:';\n setCookie(\n 'checkout-cartid',\n (data['uuid'] as string) || (data['cartUUID'] as string),\n {\n secure: httpsOrigin,\n sameSite: httpsOrigin ? ('none' as const) : ('lax' as const),\n path: '/',\n }\n );\n return {\n success: true,\n uuid: (data['uuid'] as string) || (data['cartUUID'] as string),\n serviceFee: (data['serviceFee'] as number) ?? 0,\n subtotal: (data['subtotal'] as number) ?? 0,\n };\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : 'Network error';\n logger.error('Order initiation failed:', err);\n return {\n success: false,\n error: message,\n errorType: 'network',\n };\n }\n}\n\nexport async function getOrder(orderId: string): Promise<OrderResponse> {\n try {\n const result = await apiGet<OrderResponse>(`/orders/${orderId}`);\n\n if (!result.success) {\n const errorMessage =\n result.error ?? `Failed to fetch order (${result.statusCode})`;\n logger.error('getOrder error response:', errorMessage);\n throw new ApiError(errorMessage, result.statusCode ?? 0, {\n endpoint: `/orders/${orderId}`,\n method: 'GET',\n });\n }\n\n return result.data as OrderResponse;\n } catch (err) {\n logger.error('getOrder error:', err);\n throw err;\n }\n}\n\nexport async function createPaymentIntent(\n cartId: string,\n quantities: Record<string, number>,\n donationAmounts?: Record<string, number>\n): Promise<PaymentIntentResponse> {\n const token = getCookie(COOKIE_NAMES.OPERATOR_TOKEN);\n\n try {\n const result = await apiPost<PaymentIntentResponse>(\n `/orders/${cartId}/payment-intent`,\n {\n productQuantities: quantities,\n ...(donationAmounts && Object.keys(donationAmounts).length > 0\n ? { donationAmounts }\n : {}),\n },\n {\n headers: buildAuthHeaders(token),\n }\n );\n\n if (!result.success) {\n logger.error('Payment intent creation failed:', result.error);\n throw new ApiError(\n result.error === 'Request timed out'\n ? 'Request timed out. Please check your connection and try again.'\n : result.error?.includes('Failed to fetch')\n ? 'Unable to connect to payment server. Please check your internet connection or try again later.'\n : (result.error ??\n `Failed to create payment intent: ${result.statusCode}`),\n result.statusCode ?? 0,\n { endpoint: `/orders/${cartId}/payment-intent`, method: 'POST' }\n );\n }\n\n return result.data as PaymentIntentResponse;\n } catch (err: unknown) {\n logger.error('createPaymentIntent error:', err);\n // Re-throw the error so the caller can handle it\n throw err;\n }\n}\n\nexport async function validatePaymentIntent(\n cartId: string,\n payload: Record<string, unknown>\n): Promise<ValidatePaymentResponse | null> {\n try {\n const token = getCookie(COOKIE_NAMES.OPERATOR_TOKEN);\n\n const result = await apiPost<ValidatePaymentResponse>(\n `/orders/${cartId}/validate-payment`,\n payload,\n {\n headers: buildAuthHeaders(token),\n }\n );\n\n return result.data ?? null;\n } catch (err) {\n logger.error('validatePaymentIntent error:', err);\n return null;\n }\n}\n","// @fetch-escape: widget-intentional.\n// @api-client-escape: fire-and-forget UTM beacon — keeps raw fetch (GET, no body, response ignored).\n// Migrating to apiPost broke the GET contract; apiGet would parse JSON on a no-body 200 and log a false-positive error.\nimport { createLogger } from '@getmicdrop/svelte-components';\nimport { getPublicBaseUrl } from '../api/client.js';\nimport { normalizeUtmValue, DIRECT_SOURCE } from '../tracking/normalize.js';\nimport { trackEventView } from '../tracking/index.js';\nconst logger = createLogger('utm');\n\n/**\n * UTM source tracking\n */\n\n/**\n * Track UTM source for an event (parameter named venueID for backwards compatibility\n * but actually represents eventID).\n *\n * Bumps the legacy per-source click COUNTERS (utm_counters) that power the old\n * UTM analytics page. The source is normalized at write time (lowercased, spaces\n * → underscores) and an empty source resolves to the ONE canonical default\n * `direct` — so the counter buckets match the beacon + order buckets (the\n * historical `Direct`/`''`/`direct` split is dead).\n */\nexport async function trackUTMSource(venueID: string | number): Promise<void> {\n const urlParams = new URLSearchParams(window.location.search);\n const utmSource =\n normalizeUtmValue(urlParams.get('utm_source')) || DIRECT_SOURCE;\n\n try {\n // Route through the configured base (getPublicBaseUrl) instead of a\n // hard-coded prod origin, so a first-party host that points the client at\n // its own backend (QA/staging via configureVenueCalendar → same-origin) has\n // this beacon follow suit. Stays a raw fire-and-forget GET (see the escapes\n // above); getPublicBaseUrl already appends `/api/v2/public`.\n await fetch(\n `${getPublicBaseUrl()}/utm/${venueID}/${encodeURIComponent(utmSource)}`\n );\n } catch (err) {\n logger.error('UTM tracking failed:', err);\n }\n}\n\n/**\n * Event-detail page-view tracking — the `event_view` funnel moment.\n *\n * Delegates to the canonical funnel-beacon service (`$lib/tracking`), which\n * fires the extended `POST /track/pageview` beacon carrying the normalized utm\n * set, persistent visitorId (consent-gated), sessionId, widgetId, deviceType,\n * referrer and pageUrl, and keeps the first-party attribution store fresh. The\n * beacon is deduplicated per session and fire-and-forget.\n *\n * Kept as a thin wrapper (rather than inlining `trackEventView` at the call\n * site) so the existing `trackPageView(eventId)` call in EventPage stays\n * unchanged and the pre-tracking-rebuild external surface is preserved.\n */\nexport async function trackPageView(eventID: string | number): Promise<void> {\n await trackEventView(eventID);\n}\n"],"names":["assign","target","i","source","key","defaultConverter","value","init","converter","defaultAttributes","set","name","attributes","stringifiedAttributes","attributeName","get","cookies","jar","parts","found","api","setCookieLocal","options","Cookies","getCookieLocal","removeCookieLocal","logger","createLogger","loadCheckoutStateFromCookies","eventID","quantities","donationAmounts","tickets","promocode","promoDiscountAmount","stored","parsed","e","getCookie","persistCheckoutState","clearMigratedCheckoutCookies","removeCookie","clearCheckoutCookies","minimalTickets","t","state","ensureOrderIdExists","eventId","existingOrderId","newOrderId","httpsOrigin","setCookie","getClientIP","getVenueDetails","venueID","result","apiGet","ApiError","error","initiateOrder","cartData","ip","restCartData","numericQuantities","k","v","numericDonationAmounts","orderPayload","apiPost","data","errorMessage","isInventoryError","err","message","getOrder","orderId","trackUTMSource","urlParams","utmSource","normalizeUtmValue","DIRECT_SOURCE","getPublicBaseUrl"],"mappings":";AACA,SAASA,EAAQC,GAAQ;AACvB,WAASC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AACzC,QAAIC,IAAS,UAAUD,CAAC;AACxB,aAASE,KAAOD;AACd,MAAIC,MAAQ,gBACZH,EAAOG,CAAG,IAAID,EAAOC,CAAG;AAAA,EAE5B;AACA,SAAOH;AACT;AAEA,IAAII,IAAmB;AAAA,EACrB,MAAM,SAAUC,GAAO;AACrB,WAAIA,EAAM,CAAC,MAAM,QACfA,IAAQA,EAAM,MAAM,GAAG,EAAE,IAEpBA,EAAM,QAAQ,oBAAoB,kBAAkB;AAAA,EAC7D;AAAA,EACA,OAAO,SAAUA,GAAO;AACtB,WAAO,mBAAmBA,CAAK,EAAE;AAAA,MAC/B;AAAA,MACA;AAAA,IACN;AAAA,EACE;AACF;AAEA,SAASC,EAAKC,GAAWC,GAAmB;AAC1C,WAASC,EAAIC,GAAML,GAAOM,GAAY;AACpC,QAAI,SA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