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,KAAMO,EAAM,MAAOD,EAAIR,EAAUS,EAAMxB,EAAOxB,CAAG,CAAA,CAChE,CACA,MAAO,CAAE,IAAK,KAAM,KAAM8C,EAAM,MAAOP,EAAUO,EAAMtB,EAAOxB,CAAG,CAAA,CAClE","names":["DAY","SEASON_1_STARTS_AT","SCULPT_SEASONS","getSeason","id","s","seasonWindow","isSeasonOpen","now","w","seasonEndsIn","fmtEndsIn","ms","SHOP_ITEMS","INK_CATALOG","i","GEAR_CATALOG","MATERIAL_CATALOG","m","BY_KEY","getShopItem","key","PRO_KEYS","STATUE_SET","SHOP_SETS","isFreeNow","priceAt","it","lastFreeDayLabel","d","isPurchasable","entitledKeys","owned","isPro","out","k","isFreeInkOn","body","isFreeInk","paidKeysInUse","p","keys","gearKeysInUse","matKey","unownedInUse","entitled","priceOf","quoteKeys","quoteSet","set","missing","have","setMissingPrice","planBuy","want","q","rest"],"sources":["../../../../../../src/lib/sculpt/season.ts","../../../../../../src/lib/sculpt/shop.ts"],"sourcesContent":["// Sculpt shop seasons: a limited window in which the season's items are sold, then vaulted (never sold\n// again; owners keep them). Shared and pure: the server decides with the server clock\n// (shop.ts isPurchasable), the shop sheet's countdown is cosmetic.\n\nexport interface SculptSeason {\n\tid: 1;\n\tlabel: string;\n\t/** Launch instant (ms since epoch, UTC). null = not started: everything in it is closed. */\n\tstartsAt: number | null;\n\tdays: number;\n}\n\nconst DAY = 86_400_000;\n\n/** Season 1 launch (UTC). The one value to change if the launch moves; it ends 30 days later. */\nexport const SEASON_1_STARTS_AT = Date.UTC(2026, 10, 27, 18, 0, 0); // 2026-11-27T18:00:00Z\n\nexport const SCULPT_SEASONS: readonly SculptSeason[] = [\n\t{ id: 1, label: 'Season 1', startsAt: SEASON_1_STARTS_AT, days: 30 }\n];\n\nexport const getSeason = (id: number): SculptSeason | null => SCULPT_SEASONS.find((s) => s.id === id) ?? null;\n\n/** [start, end) in ms, or null when the season has no start yet. */\nexport function seasonWindow(id: number): { start: number; end: number } | null {\n\tconst s = getSeason(id);\n\tif (!s || s.startsAt === null) return null;\n\treturn { start: s.startsAt, end: s.startsAt + s.days * DAY };\n}\n\n/** Open at `now`: start inclusive, end exclusive. */\nexport function isSeasonOpen(id: number, now: number): boolean {\n\tconst w = seasonWindow(id);\n\treturn !!w && now >= w.start && now < w.end;\n}\n\n/** Ms left while open, else 0. */\nexport function seasonEndsIn(id: number, now: number): number {\n\tconst w = seasonWindow(id);\n\treturn w && now >= w.start && now < w.end ? w.end - now : 0;\n}\n\n/** \"29d\" / \"14h\" / \"45m\" for the tab chip. */\nexport function fmtEndsIn(ms: number): string {\n\tif (ms >= DAY) return `${Math.floor(ms / DAY)}d`;\n\tif (ms >= 3_600_000) return `${Math.floor(ms / 3_600_000)}h`;\n\treturn `${Math.max(1, Math.ceil(ms / 60_000))}m`;\n}\n","// The sculpt gear shop: the one place tiers, entitlement and prices are decided. Shared and pure (no\n// db, no three), so the editor and the server compute the same quote and the same \"what is not owned\"\n// (src/lib/server/sculpt-shop.ts charges from here and never takes a price from the client).\n//   pro     = the pre-shop gear: free for an active subscriber, else bought with tokens\n//   classic = the first paid ink: tokens only, not part of Pro\n//   exotic  = materials, the big ink and the new gear: tokens only, subscribers too\n// Season items are sold only while their season is open (season.ts); owners keep them after.\n\nimport { GEAR_CATALOG, gearKeysInUse, type GearGroup } from './gear';\nimport { INK_CATALOG, isFreeInk } from './ink';\nimport { MATERIAL_CATALOG, matKey } from './material';\nimport type { SculptParams } from './params';\nimport { isSeasonOpen } from './season';\n\nexport type ShopTier = 'pro' | 'classic' | 'exotic';\nexport type ShopGroup = 'materials' | 'ink' | GearGroup;\n\nexport interface ShopItem {\n\tkey: string;\n\tname: string;\n\tprice: number;\n\ttier: ShopTier;\n\tgroup: ShopGroup;\n\tseason?: 1;\n\t/** Built and on sale; false = hidden in the shop and refused by the server. */\n\tlive: boolean;\n\t/** Only for this body (her jewellery); absent: the penis sculpt's or either body's. */\n\tbody?: 'vulva';\n\t/** Free to claim before this (ms, UTC): see priceAt. */\n\tfreeUntil?: number;\n}\n\nexport const SHOP_ITEMS: readonly ShopItem[] = [\n\t...INK_CATALOG.filter((i) => i.price > 0).map(\n\t\t(i): ShopItem => ({ key: i.key, name: i.name, price: i.price, tier: i.tier, group: 'ink', live: i.live })\n\t),\n\t...GEAR_CATALOG.map(\n\t\t(i): ShopItem => ({\n\t\t\tkey: i.key,\n\t\t\tname: i.name,\n\t\t\tprice: i.price,\n\t\t\ttier: i.tier,\n\t\t\tgroup: i.group,\n\t\t\tlive: i.live,\n\t\t\t...(i.season ? { season: i.season } : {}),\n\t\t\t...(i.body ? { body: i.body } : {}),\n\t\t\t...(i.freeUntil ? { freeUntil: i.freeUntil } : {})\n\t\t})\n\t),\n\t...MATERIAL_CATALOG.map(\n\t\t(m): ShopItem => ({\n\t\t\tkey: m.key,\n\t\t\tname: m.name,\n\t\t\tprice: m.price,\n\t\t\ttier: m.tier,\n\t\t\tgroup: 'materials',\n\t\t\tlive: m.live,\n\t\t\t...('season' in m ? { season: m.season } : {})\n\t\t})\n\t)\n];\n\nconst BY_KEY = new Map(SHOP_ITEMS.map((i) => [i.key, i]));\n\nexport const getShopItem = (key: string): ShopItem | null => BY_KEY.get(key) ?? null;\nexport const isShopKey = (v: unknown): v is string => typeof v === 'string' && BY_KEY.has(v);\n\n/** Free with an active subscription: the 34 pre-shop gear items. */\nexport const PRO_KEYS: ReadonlySet<string> = new Set(SHOP_ITEMS.filter((i) => i.tier === 'pro').map((i) => i.key));\n\nexport interface ShopSet {\n\tkey: 'set_s1_statue';\n\tname: string;\n\tseason: 1;\n\tprice: number;\n\titems: readonly string[];\n}\n\n/** Season 1: 24K Gold + Crown + Pedestal for 300 (400 one by one). */\nexport const STATUE_SET: ShopSet = {\n\tkey: 'set_s1_statue',\n\tname: 'The statue',\n\tseason: 1,\n\tprice: 300,\n\titems: ['mat_gold', 'hat_crown', 'pedestal']\n};\n\nexport const SHOP_SETS: readonly ShopSet[] = [STATUE_SET];\nexport const getShopSet = (key: unknown): ShopSet | null => SHOP_SETS.find((s) => s.key === key) ?? null;\n\n/** In its free launch window at `now` (ms): a claim costs 0 tokens and is a normal unlock for good. */\nexport const isFreeNow = (i: Pick<ShopItem, 'freeUntil'> | null, now: number): boolean =>\n\t!!i?.freeUntil && now < i.freeUntil;\n\n/** What an item costs at `now` (ms): 0 in its free window, else its catalog price. Every quote and\n *  the server's charge go through here, so the window closes for everyone at the same instant (the\n *  server's clock). Unknown keys cost 0 (they are refused before any charge). */\nexport function priceAt(key: string, now: number): number {\n\tconst it = getShopItem(key);\n\tif (!it) return 0;\n\treturn isFreeNow(it, now) ? 0 : it.price;\n}\n\n/** The free window's last free day as the shop chip shows it, e.g. 'Dec 6' for a window that closes\n *  at Dec 7 00:00 (UTC, so every viewer reads the same day). */\nexport function lastFreeDayLabel(i: Pick<ShopItem, 'freeUntil'>): string {\n\tif (!i.freeUntil) return '';\n\tconst d = new Date(i.freeUntil - 1);\n\treturn `${['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getUTCMonth()]} ${d.getUTCDate()}`;\n}\n\n/** On sale at `now` (server clock decides): built, and its season (if any) is open. */\nexport function isPurchasable(key: string, now: number): boolean {\n\tconst it = getShopItem(key);\n\tif (!it || !it.live) return false;\n\treturn it.season ? isSeasonOpen(it.season, now) : true;\n}\n\n/** What the user may wear: what they own, plus the Pro tier while they are subscribed. */\nexport function entitledKeys(owned: Iterable<string>, isPro: boolean): Set<string> {\n\tconst out = new Set(owned);\n\tif (isPro) for (const k of PRO_KEYS) out.add(k);\n\treturn out;\n}\n\n/** What a sculpt of either body wears from the shop. Her `tat` is one of VULVA_INKS (vulva-params.ts). */\ntype ShopWorn = Pick<SculptParams, 'gear' | 'mat'> & {\n\ttat?: SculptParams['tat'];\n\tbody?: 'penis' | 'vulva';\n};\n\n/** A tattoo that costs nothing on this body: the free designs on either, and her text (his costs its\n *  catalog price). One unlock of a paid design covers both bodies. */\nexport const isFreeInkOn = (key: unknown, body: 'penis' | 'vulva' | undefined): boolean =>\n\t(body === 'vulva' && key === 'text') || isFreeInk(key);\n\n/** The paid catalog keys a sculpt wears: the tattoo (unless free on its body), gear and the material. */\nexport function paidKeysInUse(p: ShopWorn): string[] {\n\tconst keys: string[] = [];\n\tif (p.tat && !isFreeInkOn(p.tat, p.body)) keys.push(p.tat);\n\tkeys.push(...gearKeysInUse(p.gear));\n\tif (p.mat) keys.push(matKey(p.mat));\n\treturn keys;\n}\n\n/** Worn but not entitled: the try-on items (editor) and what a save strips (server). */\nexport function unownedInUse(p: ShopWorn, entitled: ReadonlySet<string>): string[] {\n\treturn paidKeysInUse(p).filter((k) => !entitled.has(k));\n}\n\nconst priceOf = (k: string) => getShopItem(k)?.price ?? 0;\n\n/** Tokens for these keys at `now`: the price (priceAt) of each one not owned yet. */\nexport function quoteKeys(\n\tkeys: readonly string[],\n\towned: ReadonlySet<string>,\n\tnow: number\n): number {\n\treturn [...new Set(keys)].filter((k) => !owned.has(k)).reduce((s, k) => s + priceAt(k, now), 0);\n}\n\n/** The set's price for this owner: the set price less what they already own of it, never below 0\n *  and never more than buying the missing items one by one. */\nexport function quoteSet(set: ShopSet, owned: ReadonlySet<string>): number {\n\tconst missing = set.items.filter((k) => !owned.has(k)).reduce((s, k) => s + priceOf(k), 0);\n\tconst have = set.items.filter((k) => owned.has(k)).reduce((s, k) => s + priceOf(k), 0);\n\treturn Math.min(missing, Math.max(0, set.price - have));\n}\n\n/** List price of what is still missing from the set (the strike-through next to the set quote). Set\n *  items are never free-window items, so this is their catalog price. */\nexport function setMissingPrice(set: ShopSet, owned: ReadonlySet<string>): number {\n\treturn set.items.filter((k) => !owned.has(k)).reduce((s, k) => s + priceOf(k), 0);\n}\n\n/**\n * How to buy these keys at `now` for the least: an open Season set whenever the keys cover all of it\n * that is still missing and the set quote is cheaper, the other keys one by one. `total` is what the\n * whole plan costs (the try-on bar / unlock sheet show it; the server charges the same quotes).\n */\nexport function planBuy(\n\tkeys: readonly string[],\n\towned: ReadonlySet<string>,\n\tnow: number\n): { set: ShopSet | null; keys: string[]; total: number } {\n\tconst want = [...new Set(keys)].filter((k) => !owned.has(k));\n\tfor (const set of SHOP_SETS) {\n\t\tconst missing = set.items.filter((k) => !owned.has(k));\n\t\tif (!missing.length || !isSeasonOpen(set.season, now) || !missing.every((k) => want.includes(k))) continue;\n\t\tconst q = quoteSet(set, owned);\n\t\tif (q >= quoteKeys(missing, owned, now)) continue;\n\t\tconst rest = want.filter((k) => !set.items.includes(k));\n\t\treturn { set, keys: rest, total: q + quoteKeys(rest, owned, now) };\n\t}\n\treturn { set: null, keys: want, total: quoteKeys(want, owned, now) };\n}\n\n/** Split a set charge over the rows it creates, in proportion to their catalog prices (the\n *  remainder on the last row, so the shares always sum to the charge). A share may be 0. */\nexport function allocateSetPrice(charge: number, missingKeys: readonly string[]): number[] {\n\tif (!missingKeys.length) return [];\n\tconst total = missingKeys.reduce((s, k) => s + priceOf(k), 0);\n\tconst out = missingKeys.map((k) => (total > 0 ? Math.floor((charge * priceOf(k)) / total) : 0));\n\tout[out.length - 1] += charge - out.reduce((s, v) => s + v, 0);\n\treturn out;\n}\n\n/** The shop section an item sits in. */\nexport const itemGroup = (key: string): ShopGroup | null => getShopItem(key)?.group ?? null;\n"],"version":3}