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U,CAC1D,CAIO,SAASI,EAAaJ,EAAsD,CAClF,MAAMJ,EAASK,EAAA,EACTC,EAAQN,EAASD,EAAWC,EAAQI,EAAI,EAAE,EAAI,KACpD,OAAOG,EAAYD,GAASN,EAASE,EAASF,EAAQM,EAAM,KAAK,EAAIF,EAAI,UAAU,CACpF,CAEA,SAASC,GAA+B,CACvC,MAAMI,EAAOC,EAAK,MAAM,cACxB,OAAOD,EAAOhB,EAAQgB,CAAI,EAAI,IAC/B","names":["REGIONS","formatMoney","minor","currency","locale","amount","localPrice","region","packageId","usdCents","packPrice","pkg","currentRegion","local","formatPrice","packUsdPrice","code","page"],"sources":["../../../../../../src/lib/local-pricing.ts","../../../../../../src/lib/pricing-display.ts"],"sourcesContent":["/**\n * Local prices for the markets that sign up but don't pay (RAT-583): Brazil\n * 0.5 payers per 1,000 visitors, Spain 0, Mexico 2.0, against 7.4 in the US.\n * A price in the visitor's own currency, set for what money is worth there,\n * and in Brazil the way people actually pay online: Pix.\n *\n * TEST PRICES. The numbers below are placeholders to build and measure with —\n * the real ones are decided in Stripe before this goes live. Nothing here\n * applies until LOCAL_PRICING=on (server env); Pix needs STRIPE_PIX=on as well,\n * and Pix enabled on the Stripe account.\n *\n * Client-safe: the pricing surfaces format from this table, and the checkout\n * charges from it — never from a price the browser sends.\n */\n\nexport type RegionCode = 'BR' | 'MX' | 'ES';\n\nexport interface Region {\n\tcode: RegionCode;\n\tcurrency: 'BRL' | 'MXN' | 'EUR';\n\t/** how prices are written there */\n\tlocale: string;\n\t/** USD per one unit of the currency, for revenue and commissions in USD.\n\t *  A fixed planning rate: what was charged is in Stripe in the real currency. */\n\tusdPerUnit: number;\n\t/** price per package id, in the currency's minor unit (centavos, cents) */\n\tprices: Record<string, number>;\n\t/** Pix at checkout (Brazil) — only with STRIPE_PIX=on */\n\tpix?: boolean;\n}\n\nexport const REGIONS: Record<RegionCode, Region> = {\n\t// About 55% of the US price at R$5.4 to the dollar: the R$ 9,90 / 29,90\n\t// steps people are used to seeing.\n\tBR: {\n\t\tcode: 'BR',\n\t\tcurrency: 'BRL',\n\t\tlocale: 'pt-BR',\n\t\tusdPerUnit: 0.185,\n\t\tprices: { starter: 990, dipper: 1490, regular: 2990, obsessed: 5990, whale: 14990 },\n\t\tpix: true\n\t},\n\t// About 75% of the US price at MX$18.5 to the dollar, on round peso steps.\n\tMX: {\n\t\tcode: 'MX',\n\t\tcurrency: 'MXN',\n\t\tlocale: 'es-MX',\n\t\tusdPerUnit: 0.054,\n\t\tprices: { starter: 3900, dipper: 6900, regular: 13900, obsessed: 27900, whale: 69900 }\n\t},\n\t// Spain pays in euros at the same sticker as the dollar price: the gap there\n\t// is the currency and the language, not the amount.\n\tES: {\n\t\tcode: 'ES',\n\t\tcurrency: 'EUR',\n\t\tlocale: 'es-ES',\n\t\tusdPerUnit: 1.08,\n\t\tprices: { starter: 299, dipper: 499, regular: 999, obsessed: 1999, whale: 4999 }\n\t}\n};\n\nexport function regionFor(country: string | null | undefined): Region | null {\n\tif (!country) return null;\n\tconst code = country.toUpperCase();\n\treturn code in REGIONS ? REGIONS[code as RegionCode] : null;\n}\n\nexport function formatMoney(minor: number, currency: string, locale: string): string {\n\tconst amount = minor / 100;\n\treturn new Intl.NumberFormat(locale, {\n\t\tstyle: 'currency',\n\t\tcurrency,\n\t\tminimumFractionDigits: Number.isInteger(amount) ? 0 : 2,\n\t\tmaximumFractionDigits: 2\n\t}).format(amount);\n}\n\n/** The local price of a package, or null when this region has none for it. */\nexport function localPrice(\n\tregion: Region,\n\tpackageId: string\n): { minor: number; display: string } | null {\n\tconst minor = region.prices[packageId];\n\tif (minor == null) return null;\n\treturn { minor, display: formatMoney(minor, region.currency, region.locale) };\n}\n\n/** A local amount in US cents, for revenue reporting and affiliate commissions. */\nexport function usdCents(region: Region, minor: number): number {\n\treturn Math.round(minor * region.usdPerUnit);\n}\n","import { page } from '$app/state';\nimport { REGIONS, localPrice, usdCents, type Region, type RegionCode } from './local-pricing';\nimport { formatPrice, type TokenPackage } from './token-packages';\n\n/** A pack's price as the visitor will be charged it (RAT-583): the local price\n *  in their currency where local pricing is on for their country, else the\n *  dollar price. Read during render, like `page`. */\nexport function packPrice(pkg: Pick<TokenPackage, 'id' | 'priceCents'>): string {\n\tconst region = currentRegion();\n\tconst local = region ? localPrice(region, pkg.id) : null;\n\treturn local ? local.display : formatPrice(pkg.priceCents);\n}\n\n/** The same price in dollars (\"$2.71\"), for analytics: GA4 and PostHog count\n *  every checkout in USD, as the webhook does with the purchase itself. */\nexport function packUsdPrice(pkg: Pick<TokenPackage, 'id' | 'priceCents'>): string {\n\tconst region = currentRegion();\n\tconst local = region ? localPrice(region, pkg.id) : null;\n\treturn formatPrice(local && region ? usdCents(region, local.minor) : pkg.priceCents);\n}\n\nfunction currentRegion(): Region | null {\n\tconst code = page.data?.pricingRegion as RegionCode | null | undefined;\n\treturn code ? REGIONS[code] : null;\n}\n"],"version":3}