// Before/after commission pairs for the "camera roll → wall" showcase. // // Each pair is a single composition: the customer's raw phone snap sits // as a tilted polaroid leaning against the corner of the finished framed // portrait. ALL_PAIRS is the full data set; HOME_PAIRS is the featured // trio on the home page and GALLERY_PAIRS is everything else — the // gallery never repeats a home feature. Both derive from ALL_PAIRS. import type { PortraitPromptId } from './styleCatalog'; import type { FrameId, MatteId } from './frames'; import type { ProductId } from '../lib/pricing'; export type TransformPair = { n: string; before: { src: string; alt: string; ratio: string }; after: { src: string; alt: string }; name: string; medium: string; blurb: string; // The product family pictured (matted vs canvas — visually distinct // from the photo, since canvas has no mat border). Drives the // gallery's "From $X" price via startingSalePrice() in pricing.ts. productId: ProductId; // sizeId is RETAINED for legacy reasons but the gallery no longer // displays it or forwards it to the builder — the AI-generated // lifestyle photos don't faithfully depict a specific frame size, so // claiming one would be misleading. Customer picks size in the // builder. Safe to delete once no other consumer relies on it. sizeId: string; // Catalog style this commission used — when set, the pair's "Start a // portrait" CTA opens the builder with that style preselected. styleId?: PortraitPromptId; // Frame + matte the lifestyle shot is composed with. Passed to the // builder via the "Make one like this" CTA so the customer lands on // the same finish they just saw. frameId?: FrameId; matteId?: MatteId; // Per-pair polaroid placement so the pairs don't all read identically. tilt: number; tapeRotate: number; corner: 'br' | 'tr' | 'bl'; }; /** The full set — every commission, shown on the /gallery page. */ export const ALL_PAIRS: TransformPair[] = [ { n: '01', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-daisy.jpg/public', alt: 'Phone snapshot of a long-haired cream dog with two blue bows, resting on a leather couch.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/yorkie-impasto.jpg/public', alt: 'Heavy impasto portrait of a long-haired cream dog with two blue-grey bows, soft-white canvas float frame on a weathered wood plank wall.', }, name: 'Cimba', medium: 'Impasto · ivory frame', blurb: "Bon Bon's Boshay Pabu Cimba, bred by Bonnie Murphy, Lhasa Love.", productId: 'matted', sizeId: '16x20', styleId: 'mixedmedia', frameId: 'white', matteId: 'offwhite', tilt: -5.2, tapeRotate: 1.8, corner: 'br', }, { n: '02', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-gg.jpg/public', alt: 'Phone snapshot of a fluffy tan-and-white Lhasa Apso with a single top-knot in soft window light.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-gg-landscape.jpg/public', alt: 'Landscape-style oil portrait of a fluffy tan Lhasa Apso in a Romantic lakeside autumn scene, soft-white canvas float frame above a wood credenza.', }, name: 'GG', medium: 'Landscape style · ivory frame', blurb: "Bon Bon's Boshay Pabu Sunrise Xhmeroni, bred by Bonnie Murphy, Lhasa Love.", productId: 'matted', sizeId: '16x20', styleId: 'landscape-oil', frameId: 'white', matteId: 'offwhite', tilt: 4.4, tapeRotate: -2.1, corner: 'tr', }, { n: '03', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-pepper.jpg/public', alt: 'Phone snapshot of a black-and-white long-haired dog on a sunlit windowsill.', ratio: '4 / 3', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-pepper-popart.jpg/public', alt: 'Pop-art portrait of a black-and-white long-haired dog, ivory frame on a weathered wood wall.', }, name: 'Moki', medium: 'Pop art · ivory frame', blurb: 'Bon Bon’s Moki Boy Wonder, bred by Bonnie Murphy, Lhasa Love.', productId: 'matted', sizeId: '16x20', styleId: 'popart', frameId: 'white', matteId: 'snowwhite', tilt: -4.5, tapeRotate: 2.2, corner: 'bl', }, { n: '04', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-goldenretriever.jpg/public', alt: 'Phone snapshot of a happy golden retriever sitting on a living-room rug surrounded by toys.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-cooper-vector-v4.jpg/public', alt: 'Vector-outline portrait of a golden retriever, ivory frame on weathered wood.', }, name: 'Cooper', medium: 'Vector outline · ivory frame', blurb: 'Golden retriever, toys underfoot. Caught mid-grin. Joy with absolutely no notes.', productId: 'matted', sizeId: '16x20', styleId: 'vector', frameId: 'white', matteId: 'snowwhite', tilt: 5.0, tapeRotate: -2.4, corner: 'bl', }, { n: '06', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-koda.jpg/public', alt: 'Phone snapshot of a blue merle Australian Shepherd sitting on a hardwood living-room floor in window light.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-koda-named-v4.jpg/public', alt: 'Named-portrait painting of a blue merle Australian Shepherd, “Koda” lettered above on a soft white ground.', }, name: 'Koda', medium: 'Named portrait · walnut frame', blurb: 'Blue merle Aussie, ears at attention. Caught mid-thought. Equal parts mischief and devotion.', productId: 'matted', sizeId: '16x20', styleId: 'named', frameId: 'walnut', matteId: 'snowwhite', tilt: 4.6, tapeRotate: -2.0, corner: 'tr', }, { n: '07', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-maple.jpg/public', alt: 'Phone snapshot of a Cavalier King Charles Spaniel in soft window light.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-maple-watercolor-v2.jpg/public', alt: 'Watercolor portrait of a Cavalier King Charles Spaniel, soft pigment washes on clean white, ivory frame.', }, name: 'Maple', medium: 'Watercolor · ivory frame', blurb: 'Cavalier in afternoon window light. Caught mid-tilt. Velvet ears, deeply unimpressed.', productId: 'matted', sizeId: '16x20', styleId: 'watercolor', frameId: 'white', matteId: 'snowwhite', tilt: -4.8, tapeRotate: 1.9, corner: 'br', }, { n: '08', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-juno.jpg/public', alt: 'Phone snapshot of an Italian Greyhound curled on a green velvet sofa.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-juno-lineart-v3.jpg/public', alt: 'Refined ink line-drawing portrait of an Italian Greyhound, "Juno" lettered above on clean white, ivory frame in a modern minimalist home office.', }, name: 'Juno', medium: 'Line drawing · ivory frame', blurb: 'Italian Greyhound, ears at ease. Caught mid-tilt. Refined ink, no second-guesses.', productId: 'matted', sizeId: '16x20', styleId: 'lineart', frameId: 'white', matteId: 'snowwhite', tilt: 4.0, tapeRotate: -1.6, corner: 'tr', }, { n: '11', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-sakura.jpg/public', alt: 'Phone snapshot of a Shiba Inu standing on a sunny garden path.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-sakura-ukiyoe.jpg/public', alt: 'Ukiyo-e woodblock portrait of a Shiba Inu with sumi-black outlines and Edo-period colour, ivory frame.', }, name: 'Sakura', medium: 'Ukiyo-e · ivory frame', blurb: 'Shiba Inu in spring air. Caught mid-glance. A small fox with a long memory.', productId: 'matted', sizeId: '16x20', styleId: 'ukiyoe', frameId: 'white', matteId: 'offwhite', tilt: -4.6, tapeRotate: 1.7, corner: 'tr', }, // ─── Neo-Expressionist ────────────────────────────────────────────── { n: '32', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-rex.jpg/public', alt: 'Phone snapshot of a fawn French bulldog standing alert on a tile floor.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-rex-neoexpressionist-v2.jpg/public', alt: 'Neo-expressionist standing portrait of a French bulldog, matte black frame on a moody downtown loft wall with polished concrete floors and a low leather sofa.', }, name: 'Rex', medium: 'Neo-Expressionist · matte black frame', blurb: 'French bulldog, king of the alley. Caught mid-stand. Gold crown, no apology.', productId: 'matted', sizeId: '16x20', styleId: 'neoexpressionist', frameId: 'black', matteId: 'black', tilt: 4.2, tapeRotate: -2.1, corner: 'br', }, { n: '12', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-tenzin.jpg/public', alt: 'Phone snapshot of a Tibetan Mastiff resting on a rug in soft daylight.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-tenzin-thangka-v3.jpg/public', alt: 'Thangka-style portrait of a Tibetan Mastiff, mineral pigments and gold-leaf halo, gilt frame.', }, name: 'Tenzin', medium: 'Thangka · warm gold frame', blurb: 'Tibetan Mastiff under a gold-leaf halo. Caught mid-sit. Sacred, with snacks at stake.', productId: 'canvas', sizeId: '16x20', styleId: 'thangka', frameId: 'gold', matteId: 'offwhite', tilt: 4.2, tapeRotate: -1.9, corner: 'bl', }, { n: '13', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-sable.jpg/public', alt: 'Phone snapshot of a whippet curled on a linen sofa.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-sable-charcoal-v2.jpg/public', alt: 'Charcoal drawing of a whippet on cotton paper, name hand-lettered above, ivory frame.', }, name: 'Sable', medium: 'Charcoal · ivory frame', blurb: 'Whippet curled like a comma. Caught mid-dream. Vine charcoal, no eraser used.', productId: 'matted', sizeId: '16x20', styleId: 'charcoal', frameId: 'white', matteId: 'snowwhite', tilt: -4.4, tapeRotate: 2.1, corner: 'br', }, { n: '16', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-clover.jpg/public', alt: 'Phone snapshot of a Holland Lop rabbit sitting on a hardwood floor.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-clover-charcoal-v3.jpg/public', alt: 'Charcoal portrait of a Holland Lop rabbit, white frame in a bright nursery corner.', }, name: 'Clover', medium: 'Charcoal · white frame', blurb: 'Holland Lop, ears down. Caught mid-nibble. Charcoal, soft as the fur.', productId: 'matted', sizeId: '12x16', styleId: 'charcoal', frameId: 'white', matteId: 'snowwhite', tilt: 4.6, tapeRotate: -1.9, corner: 'br', }, { n: '17', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-wren.jpg/public', alt: 'Phone snapshot of a Northern Cardinal perched on a leafy branch.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-wren-ukiyoe.jpg/public', alt: 'Ukiyo-e woodblock portrait of a cardinal, walnut frame in a book-lined library nook.', }, name: 'Wren', medium: 'Ukiyo-e · walnut frame', blurb: 'Cardinal on a branch. Caught mid-glance. Edo lines, modern bird.', productId: 'matted', sizeId: '12x16', styleId: 'ukiyoe', frameId: 'walnut', matteId: 'offwhite', tilt: -4.0, tapeRotate: 1.8, corner: 'tr', }, { n: '18', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-hamlet.jpg/public', alt: 'Phone snapshot of a spotted Juliana mini pig standing on a grassy lawn.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-hamlet-popart.jpg/public', alt: 'Pop-art portrait of a Juliana mini pig, matte black frame in a bright cheerful kitchen.', }, name: 'Hamlet', medium: 'Pop art · matte black frame', blurb: 'Mini pig, spots and all. Caught mid-snort. Bold colour, no apology.', productId: 'matted', sizeId: '16x20', styleId: 'popart', frameId: 'black', matteId: 'snowwhite', tilt: 5.0, tapeRotate: -2.2, corner: 'bl', }, { n: '20', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-quill.jpg/public', alt: 'Phone snapshot of a small pet hedgehog held gently in cupped hands.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-quill-mixedmedia.jpg/public', alt: 'Mixed-media impasto portrait of a hedgehog, walnut frame in a cozy attic studio.', }, name: 'Quill', medium: 'Mixed-media · walnut frame', blurb: 'Hedgehog in cupped hands. Caught mid-squeak. Impasto for the texture of him.', productId: 'matted', sizeId: '12x16', styleId: 'mixedmedia', frameId: 'walnut', matteId: 'offwhite', tilt: 4.3, tapeRotate: -1.5, corner: 'tr', }, { n: '22', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-major.jpg/public', alt: 'Phone snapshot of an Arabian horse standing alert in a sunlit barn aisle.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-major-lineart.jpg/public', alt: 'Continuous-line drawing of an Arabian horse, matte black frame in a modern minimalist office.', }, name: 'Major', medium: 'Line drawing · black frame', blurb: 'Arabian in barn light. Caught mid-breath. One line, no fuss, all horse.', productId: 'matted', sizeId: '16x20', styleId: 'lineart', frameId: 'black', matteId: 'snowwhite', tilt: 4.0, tapeRotate: -1.7, corner: 'tr', }, { n: '23', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-marlow.jpg/public', alt: 'Phone snapshot of a vibrant red-and-blue Betta fish in a glass aquarium.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-marlow-cubist.jpg/public', alt: 'Cubist portrait of a Betta fish in fractured planes of colour, natural oak frame in an eclectic mid-century study.', }, name: 'Marlow', medium: 'Cubist · oak frame', blurb: 'Betta in full sail. Caught mid-drift. Fractured into something better.', productId: 'matted', sizeId: '12x16', styleId: 'cubist', frameId: 'oak', matteId: 'snowwhite', tilt: -4.4, tapeRotate: 2.0, corner: 'br', }, // ─── Risograph ────────────────────────────────────────────────────── { n: '26', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-murph.jpg/public', alt: 'Phone snapshot of a Pembroke Welsh Corgi sitting in soft window light.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-murph-risograph-v3.jpg/public', alt: 'Risograph portrait of a Pembroke Welsh Corgi in a honey oak frame, leaning on a print-shop studio wall with a desk lamp and stacked art prints.', }, name: 'Murph', medium: 'Risograph · honey oak frame', blurb: 'Pembroke Welsh Corgi, ears at full mast. Caught mid-grin. Two inks, pulled bright.', productId: 'matted', sizeId: '16x20', styleId: 'risograph', frameId: 'oak', matteId: 'snowwhite', tilt: 4.4, tapeRotate: -2.0, corner: 'br', }, { n: '28', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-chip.jpg/public', alt: 'Phone snapshot of a sky-blue budgerigar perched on a wooden dowel.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-chip-risograph-v3.jpg/public', alt: 'Risograph portrait of a budgerigar in a soft white frame, hung in a small-press design studio with neutral plaster walls and a vintage Anglepoise lamp.', }, name: 'Chip', medium: 'Risograph · ivory frame', blurb: 'Budgerigar on a perch. Caught mid-tilt. Sky-blue, screen-printed, sound on.', productId: 'matted', sizeId: '12x16', styleId: 'risograph', frameId: 'white', matteId: 'snowwhite', tilt: 4.0, tapeRotate: -1.7, corner: 'bl', }, // ─── At Home (retro disco kitchen) ────────────────────────────────── { n: '30', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-marmalade.jpg/public', alt: 'Phone snapshot of an orange tabby cat resting in soft daylight.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-marmalade-athome-v4.jpg/public', alt: 'Retro-modern photograph of an orange tabby in a richly-styled mid-century-modern kitchen-living room, honey oak frame hung above a walnut credenza beside a mustard velvet lounge chair.', }, name: 'Marmalade', medium: 'Retro Home · honey oak frame', blurb: 'Orange tabby in a sunlit mid-century kitchen. Caught mid-sit. Mint tiles, all heart.', productId: 'matted', sizeId: '16x20', styleId: 'athome', frameId: 'oak', matteId: 'offwhite', tilt: 4.6, tapeRotate: -1.9, corner: 'tr', }, { n: '05', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-bowie.jpg/public', alt: 'Phone snapshot of a fawn French bulldog sitting on a living-room couch.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-bowie-popart-v2.jpg/public', alt: 'Pop-art portrait of a French bulldog, ivory frame on a weathered wood wall.', }, name: 'Bowie', medium: 'Pop art · ivory frame', blurb: 'French bulldog, ears up. Caught mid-ponder. Mostly ears, entirely certain.', productId: 'matted', sizeId: '16x20', styleId: 'popart', frameId: 'white', matteId: 'snowwhite', tilt: -4.2, tapeRotate: 2.0, corner: 'br', }, // ─── Pop art (cat) — home-feature trio ────────────────────────────── { n: '33', before: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/before-ziggy.jpg/public', alt: 'Phone snapshot of a ginger orange tabby cat sitting in soft window light.', ratio: '3 / 4', }, after: { src: 'https://imagedelivery.net/UI7TTlrLGypjCwT_wfSMNA/portraits/lifestyle-ziggy-popart.jpg/public', alt: 'Pop-art portrait of a ginger tabby cat in bold saturated colour, soft-white frame in a bright breakfast nook.', }, name: 'Ziggy', medium: 'Pop art · ivory frame', blurb: 'Ginger tabby, cranked to full saturation. Caught mid-blink. A small sun with strong opinions.', productId: 'matted', sizeId: '16x20', styleId: 'popart', frameId: 'white', matteId: 'snowwhite', tilt: -4.5, tapeRotate: 2.2, corner: 'bl', }, ]; // ── Rotating home vs gallery split ────────────────────────────────── // Both views derive from ALL_PAIRS so there's a single source of truth. // Rather than a fixed home trio, WHICH pairs land on the home page (and // in what order the gallery shows the rest) rotates on a daily cycle so // the site never feels static. Both lists come out of one seeded shuffle // in rotatedPairs(seed), so the gallery can never repeat whatever the // home page is currently featuring — the home trio is simply removed // from the gallery remainder for that same seed. // Number of commissions featured on the home page. const HOME_COUNT = 3; // Retired — never shown on the home page or in the gallery. const GALLERY_RETIRED_NAMES: readonly string[] = ['Cooper']; // Every commission still in circulation (retired pieces removed). This // is the pool the rotation draws from. const ACTIVE_PAIRS: TransformPair[] = ALL_PAIRS.filter( (p) => !GALLERY_RETIRED_NAMES.includes(p.name), ); // mulberry32 — a tiny deterministic PRNG. A given seed always yields the // same sequence, so both pages compute an identical shuffle (and thus an // identical home/gallery split) without sharing state across renders. function mulberry32(seed: number): () => number { let a = seed >>> 0; return () => { a |= 0; a = (a + 0x6d2b79f5) | 0; let t = Math.imul(a ^ (a >>> 15), 1 | a); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; } // Deterministic Fisher–Yates shuffle seeded by `seed`. function seededShuffle(items: readonly T[], seed: number): T[] { const rng = mulberry32(seed); const out = items.slice(); for (let i = out.length - 1; i > 0; i--) { const j = Math.floor(rng() * (i + 1)); [out[i], out[j]] = [out[j], out[i]]; } return out; } // The style a pair reads as, for "no repeats" purposes. Falls back to the // pair's (unique) name when it has no catalog style, so a style-less pair // never counts as a duplicate of anything. function styleKey(p: TransformPair): string { return p.styleId ?? p.name; } // Pick the HOME_COUNT featured pairs from a shuffled pool, taking only // DISTINCT styles so the trio is never two of the same style (no two // pop-art frames side by side). With 20+ active pairs across many styles // there are always enough; the trailing fill is a safety net for a // hypothetical tiny catalog and would still avoid a repeat unless there // genuinely aren't HOME_COUNT distinct styles to choose from. function pickHomeTrio(shuffled: TransformPair[]): TransformPair[] { const picked: TransformPair[] = []; const usedStyles = new Set(); for (const p of shuffled) { if (picked.length >= HOME_COUNT) break; if (usedStyles.has(styleKey(p))) continue; usedStyles.add(styleKey(p)); picked.push(p); } // Safety net only: if the catalog were ever too small to yield // HOME_COUNT distinct styles, fill the rest (still preferring unused // styles first so a repeat is the genuine last resort). if (picked.length < HOME_COUNT) { for (const p of shuffled) { if (picked.length >= HOME_COUNT) break; if (!picked.includes(p)) picked.push(p); } } return picked; } // Reorder an already-shuffled list so no two ADJACENT pairs share a style // (e.g. two charcoals never sit next to each other in the gallery). Greedy // "most-frequent remaining style first, never equal to the previous one" — // the classic no-two-adjacent reorder, which always succeeds when feasible // (i.e. when no single style is more than half the list, which holds here). // Ties are broken by the incoming shuffle order, so the result still varies // with the daily seed. If a style is ever unavoidably over-represented, the // only forced adjacencies happen at the very end. function spaceOutStyles(shuffled: TransformPair[]): TransformPair[] { const remaining = shuffled.slice(); const result: TransformPair[] = []; let prevStyle: string | null = null; while (remaining.length > 0) { const counts = new Map(); for (const p of remaining) { counts.set(styleKey(p), (counts.get(styleKey(p)) ?? 0) + 1); } // Among pairs whose style differs from the previous one, take the pair // belonging to the most-common remaining style (earliest in shuffle // order on a tie). Picking the scarcest-to-place style first is what // prevents painting ourselves into a forced adjacency later. let bestIdx = -1; let bestCount = -1; for (let i = 0; i < remaining.length; i++) { const style = styleKey(remaining[i]); if (style === prevStyle) continue; const count = counts.get(style)!; if (count > bestCount) { bestCount = count; bestIdx = i; } } // Only the previous style remains — forced to repeat it (rare/last item). if (bestIdx === -1) bestIdx = 0; const [chosen] = remaining.splice(bestIdx, 1); result.push(chosen); prevStyle = styleKey(chosen); } return result; } export type RotatedPairs = { home: TransformPair[]; gallery: TransformPair[] }; /** * Split every active commission into a home trio + the gallery remainder * for a given integer seed. Deterministic: the same seed always produces * the same split, so the gallery never shows a pair the home page is * currently featuring. Each list is renumbered 01, 02, 03… for its own * "№" labels. */ export function rotatedPairs(seed: number): RotatedPairs { const shuffled = seededShuffle(ACTIVE_PAIRS, seed); const home = pickHomeTrio(shuffled); const homeNames = new Set(home.map((p) => p.name)); // Gallery = the shuffle remainder, then de-clustered so two same-style // pairs never land next to each other. const gallery = spaceOutStyles(shuffled.filter((p) => !homeNames.has(p.name))); const number = (p: TransformPair, i: number): TransformPair => ({ ...p, n: String(i + 1).padStart(2, '0'), }); return { home: home.map(number), gallery: gallery.map(number) }; } // Seconds per rotation step. Also the ISR `revalidate` window set on the // home and gallery pages — keep them in sync (currently one day). NOTE: // Next requires `revalidate` to be a literal, so the pages hard-code // 86400; if you change this, change those too. export const ROTATION_PERIOD_SECONDS = 86400; /** The current rotation seed, advancing once per ROTATION_PERIOD_SECONDS. */ export function currentRotationSeed(): number { return Math.floor(Date.now() / 1000 / ROTATION_PERIOD_SECONDS); }