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","BUILTIN_OPPONENTS","DELETED_SNAPSHOT","isDeletedSnapshot","raw","ballTight","p","clampNum","v","r","fallback","n","c","pick","allowed","sanitizeSculptParams","input","src","out","k","cleanTatText","cleanTatImg","isInkKey","sanitizeGear","sanitizeMat"],"sources":["../../../../../../src/lib/sculpt/params.ts"],"sourcesContent":["// Sculpt parameters: the only data a sculpt is made of. Shared by the client editor and the server,\n// so every value that reaches the database or another user's screen goes through sanitizeSculptParams.\n\nimport { sanitizeGear, type SculptGear } from './gear';\nimport { cleanTatImg, cleanTatText, isInkKey, type InkKey } from './ink';\nimport { sanitizeMat, type MaterialId } from './material';\n\nexport const HAIR_STYLES = ['none', 'trimmed', 'natural', 'bush', 'hairy'] as const;\n/** Hair on the sac, on top of the pubic style ('light' = the style's own few strays). */\nexport const BALL_HAIRS = ['none', 'light', 'hairy'] as const;\nexport const HAIR_COLORS = ['black', 'dark', 'brown', 'blond', 'red', 'grey'] as const;\n/** Tattoos that cost nothing. The full catalog with prices is INK_CATALOG ($lib/sculpt/ink). */\nexport const FREE_TATTOOS = ['heart', 'stars'] as const satisfies readonly InkKey[];\n\nexport type HairStyle = (typeof HAIR_STYLES)[number];\nexport type HairColor = (typeof HAIR_COLORS)[number];\nexport type BallHair = (typeof BALL_HAIRS)[number];\n/** A free tattoo. Any catalog key is InkKey; params.tat can hold any of them. */\nexport type TattooId = (typeof FREE_TATTOOS)[number];\n\nexport interface SculptParams {\n\t/** Body type. The penis sanitizer always sets 'penis'; vulva params live in vulva-params.ts. */\n\tbody: 'penis';\n\tlength: number; // cm, erect, bone-pressed not assumed\n\tgirth: number; // cm around\n\tcurveUp: number;\n\tcurveSide: number;\n\ttaper: number;\n\tglans: number; // head width\n\tglansL: number; // head length\n\tgShape: number; // 0 blunt .. 1 pointed\n\tflare: number; // base thickness\n\tcut: boolean;\n\tforeskin: number;\n\toverhang: number;\n\tballs: number;\n\t/** 0..1 how low the sac hangs; below 0 it pulls up tight (ballTight). */\n\thang: number;\n\tasym: number;\n\twrinkle: number;\n\tveins: number;\n\tveinSize: number;\n\ttone: number; // index into SKIN_TONES\n\tgloss: number;\n\tseed: number;\n\thair: HairStyle;\n\thairCol: HairColor;\n\tballHair: BallHair;\n\t/** Any catalog key. Ownership of a paid one is checked on save (server/sculpt-ink.ts), not here. */\n\ttat: InkKey | null;\n\t/** The word of the 'text' tattoo (cleanTatText), kept when another tattoo is picked. */\n\ttatText: string | null;\n\t/** Storage path of the 'upload' tattoo's image (cleanTatImg). The upload itself is not built yet. */\n\ttatImg: string | null;\n\ttatS: number;\n\ttatA: number;\n\ttatSize: number;\n\ttatRot: number;\n\t/** Paid gear (hair styles, piercings, jewellery, charms, fun wear, hats): sanitizeGear, null when none.\n\t *  Ownership is checked on save (server/sculpt-ink.ts), not here. */\n\tgear: SculptGear | null;\n\t/** Whole-model material (material.ts), null = skin. Ownership is checked on save, not here. */\n\tmat: MaterialId | null;\n}\n\ntype Range = { min: number; max: number; int?: boolean };\nexport const RANGES: Record<\n\tExclude<\n\t\tkeyof SculptParams,\n\t\t'body' | 'cut' | 'hair' | 'hairCol' | 'ballHair' | 'tat' | 'tatText' | 'tatImg' | 'gear' | 'mat'\n\t>,\n\tRange\n> = {\n\tlength: { min: 8, max: 26 },\n\tgirth: { min: 8, max: 18 },\n\t// the shaft's frame (engine/sdf.ts) projects world up, so the head must stay short of pointing\n\t// straight up: that flips past curveUp ~1.68. Side bend twists the head's frame (~32° at 1.6 / 1)\n\tcurveUp: { min: -1.6, max: 1.6 },\n\tcurveSide: { min: -1, max: 1 },\n\ttaper: { min: 0, max: 1 },\n\tglans: { min: 0.8, max: 1.35 },\n\tglansL: { min: 0.7, max: 1.35 },\n\tgShape: { min: 0, max: 1 },\n\tflare: { min: 0, max: 1 },\n\tforeskin: { min: 0.1, max: 1 },\n\toverhang: { min: 0, max: 1 },\n\tballs: { min: 0.6, max: 1.5 },\n\thang: { min: -1, max: 1 },\n\tasym: { min: 0, max: 1 },\n\twrinkle: { min: 0, max: 1 },\n\tveins: { min: 0, max: 8, int: true },\n\tveinSize: { min: 0, max: 1 },\n\ttone: { min: 0, max: 7, int: true },\n\tgloss: { min: 0, max: 1 },\n\tseed: { min: 1, max: 9999, int: true },\n\ttatS: { min: 0.15, max: 0.85 },\n\ttatA: { min: -180, max: 180 },\n\ttatSize: { min: 2, max: 8 },\n\ttatRot: { min: -180, max: 180 }\n};\n\nexport const DEFAULT_SCULPT: SculptParams = {\n\tbody: 'penis',\n\tmat: null,\n\tlength: 16, girth: 12.5, curveUp: 0.1, curveSide: 0, taper: 0.35, glans: 1, glansL: 1, gShape: 0.4, flare: 0.5,\n\tcut: true, foreskin: 0.9, overhang: 0.3, balls: 1, hang: 0.4, asym: 0.35, wrinkle: 0.7, veins: 4, veinSize: 0.5,\n\ttone: 2, gloss: 0.35, seed: 11, hair: 'natural', hairCol: 'dark', ballHair: 'light', tat: null, tatS: 0.5, tatA: 90, tatSize: 4.5, tatRot: 0,\n\ttatText: null, tatImg: null, gear: null\n};\n\n/** Erect means, Veale et al., BJU International 2015 (15,521 men). */\nexport const AVERAGE_SIZE = { length: 13.1, girth: 11.7 } as const;\n\n/** Built-in opponents for a clash: no account behind them. */\nexport const BUILTIN_OPPONENTS = {\n\tavg: { name: 'Average guy', params: { ...DEFAULT_SCULPT, ...AVERAGE_SIZE, tone: 3, veins: 2, seed: 7, hair: 'natural', hairCol: 'brown' } },\n\tgiant: { name: 'The Giant', params: { ...DEFAULT_SCULPT, length: 24, girth: 16.5, tone: 6, curveUp: 0.15, veins: 6, veinSize: 0.8, seed: 21, hair: 'trimmed', hairCol: 'black' } }\n} satisfies Record<string, { name: string; params: SculptParams }>;\nexport type BuiltinOpponent = keyof typeof BUILTIN_OPPONENTS;\n\n/** A clash side whose owner deleted their sculpt: its snapshot is overwritten with this marker\n *  (src/lib/server/sculpt-delete.ts), so the measurements leave the clash as well. */\nexport const DELETED_SNAPSHOT = { deleted: true } as const;\nexport const isDeletedSnapshot = (raw: unknown): boolean =>\n\t!!raw && typeof raw === 'object' && (raw as { deleted?: unknown }).deleted === true;\n\n/** How tight the sac is pulled up, 0 (relaxed or hanging) .. 1 (tight): the hang slider below 0. */\nexport const ballTight = (p: Pick<SculptParams, 'hang'>) => Math.max(0, -p.hang);\n\nconst clampNum = (v: unknown, r: Range, fallback: number) => {\n\tconst n = typeof v === 'number' && Number.isFinite(v) ? v : fallback;\n\tconst c = Math.min(r.max, Math.max(r.min, n));\n\treturn r.int ? Math.round(c) : Math.round(c * 1000) / 1000;\n};\nconst pick = <T extends string>(v: unknown, allowed: readonly T[], fallback: T): T =>\n\ttypeof v === 'string' && (allowed as readonly string[]).includes(v) ? (v as T) : fallback;\n\n/** Coerce anything (client JSON, old rows) into valid params. Unknown keys are dropped. Never throws. */\nexport function sanitizeSculptParams(input: unknown): SculptParams {\n\t// arrays are objects too, and [].length would read as the `length` param\n\tconst src = input && typeof input === 'object' && !Array.isArray(input) ? (input as Record<string, unknown>) : {};\n\tconst out = { ...DEFAULT_SCULPT };\n\tfor (const k of Object.keys(RANGES) as (keyof typeof RANGES)[]) out[k] = clampNum(src[k], RANGES[k], DEFAULT_SCULPT[k]);\n\tout.cut = typeof src.cut === 'boolean' ? src.cut : DEFAULT_SCULPT.cut;\n\tout.hair = pick(src.hair, HAIR_STYLES, DEFAULT_SCULPT.hair);\n\tout.hairCol = pick(src.hairCol, HAIR_COLORS, DEFAULT_SCULPT.hairCol);\n\tout.ballHair = pick(src.ballHair, BALL_HAIRS, DEFAULT_SCULPT.ballHair);\n\tout.tatText = cleanTatText(src.tatText);\n\tout.tatImg = cleanTatImg(src.tatImg);\n\tout.tat = isInkKey(src.tat) ? src.tat : null;\n\t// a text / upload tattoo with nothing to show is no tattoo\n\tif ((out.tat === 'text' && !out.tatText) || (out.tat === 'upload' && !out.tatImg)) out.tat = null;\n\tout.gear = sanitizeGear(src.gear);\n\tout.mat = sanitizeMat(src.mat);\n\treturn out;\n}\n"],"version":3}