// src/data.jsx — fixture data for the prototype
// One Manny's-equivalent store (Kalymnos) is fully built out. A handful of other stores for Home/Search.
// Data shape kept predictable: every product has id, name, category, subcategory, price, unit, tags, and an optional `options` spec for customization.

const STORES = [
  {
    id: "kalymnos",
    name: "Kalymnos Deli & Grocer",
    tagline: "Family-run since 1987 • Lower East Side",
    rating: 4.8,
    reviews: 2431,
    eta: "15–25 min",
    pickupEta: "Ready in 8 min",
    distance: "0.4 mi",
    fee: "$1.99 delivery",
    minOrder: "$10 min",
    hours: "Open · closes 2 AM",
    tags: ["Deli sandwiches", "Beer & wine", "Household", "Late-night"],
    hero: "storefront — Kalymnos",
    img: "bodega,deli,new-york",
  },
  { id: "liu", name: "Liu's 24hr Market", tagline: "Hell's Kitchen · 24hr", rating: 4.7, reviews: 891, eta: "10–20 min", distance: "0.3 mi", hero: "Liu's storefront", tags: ["Convenience", "Late-night"], img: "corner-store,night,neon" },
  { id: "arbor", name: "Arbor Hardware & Supply", tagline: "Tools & home · Greenpoint", rating: 4.9, reviews: 312, eta: "30–40 min", distance: "1.1 mi", hero: "Arbor tools wall", tags: ["Tools", "Hardware"], img: "hardware-store,tools,workshop" },
  { id: "fig", name: "Fig & Thistle Wine", tagline: "Small-batch · Cobble Hill", rating: 4.9, reviews: 1204, eta: "20–35 min", distance: "0.9 mi", hero: "Fig & Thistle shelves", tags: ["Wine", "Beer"], img: "wine-shop,bottles,cellar" },
  { id: "elmo", name: "Elmo's Chicken & Fixins", tagline: "Hot food · Bed-Stuy", rating: 4.6, reviews: 3120, eta: "25–35 min", distance: "0.8 mi", hero: "Elmo's kitchen", tags: ["Hot food", "Restaurant"], img: "fried-chicken,soul-food,kitchen" },
  { id: "verde", name: "Verde Corner Produce", tagline: "Farm-direct · Sunset Park", rating: 4.8, reviews: 642, eta: "20–30 min", distance: "1.3 mi", hero: "Verde produce", tags: ["Produce", "Grocery"], img: "greengrocer,produce,vegetables" },
];

// Categories for the store nav rail
const CATEGORIES = [
  { id: "featured",    label: "Featured",         icon: "Sparkle" },
  { id: "deli",        label: "Deli & Sandwiches", icon: "Baguette" },
  { id: "coffee",      label: "Coffee & Tea",      icon: "Coffee" },
  { id: "drinks",      label: "Drinks",            icon: "Snow" },
  { id: "beer",        label: "Beer & Wine",       icon: "Beer" },
  { id: "snacks",      label: "Snacks",            icon: "Cookie" },
  { id: "produce",     label: "Produce",           icon: "Apple" },
  { id: "pantry",      label: "Pantry",            icon: "Box" },
  { id: "household",   label: "Household",         icon: "Pill" },
  { id: "petcare",     label: "Pet Care",          icon: "Cat" },
];

// Deli customization spec — reused by the product-detail sandwich builder.
const DELI_BUILDER = {
  sections: [
    { id: "bread", label: "Bread", required: true, multi: false, options: [
      { id: "hero",     label: "Hero",                price: 0 },
      { id: "sourdough", label: "Sourdough",          price: 0.50 },
      { id: "ciabatta", label: "Ciabatta",            price: 0.50 },
      { id: "wrap",     label: "Spinach Wrap",        price: 0 },
      { id: "gf",       label: "Gluten-free",         price: 1.50 },
    ] },
    { id: "protein", label: "Protein", required: true, multi: false, options: [
      { id: "turkey",   label: "Roast Turkey",        price: 0, popular: true },
      { id: "ham",      label: "Black Forest Ham",    price: 0 },
      { id: "roastbeef", label: "Roast Beef",         price: 1.50 },
      { id: "italian",  label: "Italian Combo",       price: 2.00, popular: true },
      { id: "tuna",     label: "House Tuna Salad",    price: 0.50 },
      { id: "veggie",   label: "No protein — veg",    price: -2.00 },
    ] },
    { id: "cheese", label: "Cheese", required: false, multi: false, options: [
      { id: "provolone", label: "Provolone",          price: 0 },
      { id: "swiss",    label: "Swiss",               price: 0 },
      { id: "cheddar",  label: "Sharp Cheddar",       price: 0 },
      { id: "fresh",    label: "Fresh Mozzarella",    price: 1.00 },
      { id: "none",     label: "No cheese",           price: 0 },
    ] },
    { id: "toppings", label: "Toppings", required: false, multi: true, max: 5, options: [
      { id: "lettuce",  label: "Lettuce",             price: 0 },
      { id: "tomato",   label: "Tomato",              price: 0 },
      { id: "onion",    label: "Red Onion",           price: 0 },
      { id: "pickle",   label: "Pickles",             price: 0 },
      { id: "pepper",   label: "Hot Peppers",         price: 0 },
      { id: "sprouts",  label: "Sprouts",             price: 0.50 },
      { id: "avocado",  label: "Avocado",             price: 1.50, popular: true },
      { id: "bacon",    label: "Applewood Bacon",     price: 2.00 },
    ] },
    { id: "sauce", label: "Sauce", required: false, multi: true, max: 3, options: [
      { id: "mayo",     label: "House Mayo",          price: 0 },
      { id: "mustard",  label: "Spicy Brown Mustard", price: 0 },
      { id: "oilvinegar", label: "Oil & Vinegar",     price: 0 },
      { id: "chipotle", label: "Chipotle Aioli",      price: 0.50 },
      { id: "pesto",    label: "Basil Pesto",         price: 0.50 },
    ] },
    { id: "prep", label: "Prep", required: false, multi: false, options: [
      { id: "cold",    label: "Serve cold",           price: 0 },
      { id: "pressed", label: "Pressed hot",          price: 0 },
      { id: "halved",  label: "Cut in half",          price: 0 },
    ] },
  ],
  basePrice: 9.75,
};

// Products — pared down but representative of 500+ SKU feel. Each has a stable id.
// Price/unit/tags/trending/popular flags drive the UI.
const P = (id, name, category, subcategory, price, unit, extra = {}) => ({
  id, name, category, subcategory, price, unit, ...extra
});

const PRODUCTS = [
  // DELI
  P("deli-custom", "Build Your Sandwich", "deli", "Custom", 9.75, "sandwich", { popular: true, customizable: "deli", desc: "6-inch hero. Pick your bread, protein, cheese, toppings + sauces.", trending: true }),
  P("deli-italian",  "Manny's Italian Combo",  "deli", "Signatures", 11.50, "sandwich", { popular: true, desc: "Ham, salami, capicola, provolone, oil & vin, hot peps.", customizable: "deli" }),
  P("deli-turkey",   "Turkey Club",            "deli", "Signatures", 10.75, "sandwich", { desc: "Roast turkey, bacon, lettuce, tomato, avocado.", customizable: "deli" }),
  P("deli-cuban",    "Pressed Cuban",          "deli", "Signatures", 11.25, "sandwich", { desc: "Slow-roast pork, ham, swiss, pickles, mustard." }),
  P("deli-tuna",     "Albacore Tuna Melt",     "deli", "Signatures", 9.95, "sandwich", { desc: "House tuna, swiss, tomato on sourdough." }),
  P("deli-blt",      "B.L.T.A.",               "deli", "Classics", 9.50, "sandwich", { desc: "Bacon, lettuce, tomato, avocado." }),
  P("deli-eggcheese","Bacon Egg & Cheese",     "deli", "Breakfast", 6.50, "sandwich", { popular: true, desc: "Roll, two eggs, Am. cheese, crispy bacon.", stock: "Cut-off 10:30 AM" }),

  // COFFEE
  P("cof-coldbrew",  "Cold Brew, 16oz",        "coffee", "Cold", 4.25, "cup", { trending: true }),
  P("cof-latte",     "House Latte",            "coffee", "Espresso", 4.75, "12oz"),
  P("cof-drip",      "Drip Coffee, 12oz",      "coffee", "Brewed", 2.50, "cup"),
  P("cof-matcha",    "Iced Matcha Latte",      "coffee", "Tea", 5.25, "16oz"),
  P("cof-chai",      "Spiced Chai",            "coffee", "Tea", 4.50, "12oz"),

  // DRINKS
  P("drk-cocacola",  "Coca-Cola Classic",      "drinks", "Soda", 2.49, "20oz btl", { popular: true }),
  P("drk-dietcoke",  "Diet Coke",              "drinks", "Soda", 2.49, "20oz btl"),
  P("drk-sprite",    "Sprite",                 "drinks", "Soda", 2.49, "20oz btl"),
  P("drk-topo",      "Topo Chico Sparkling",   "drinks", "Sparkling", 2.25, "12oz btl", { trending: true }),
  P("drk-liquiddeath","Liquid Death Still",    "drinks", "Water", 2.75, "16oz can"),
  P("drk-poland",    "Poland Spring Water",    "drinks", "Water", 1.75, "1L btl"),
  P("drk-gatorade",  "Gatorade Lemon-Lime",    "drinks", "Sports", 2.99, "32oz btl", { popular: true, deal: "Buy 2, get 1" }),
  P("drk-celsius",   "Celsius Peach Mango",    "drinks", "Energy", 3.49, "12oz can", { trending: true }),
  P("drk-redbull",   "Red Bull, 12oz",         "drinks", "Energy", 3.99, "can"),
  P("drk-ouj",       "Simply OJ",              "drinks", "Juice", 4.50, "52oz"),

  // BEER & WINE
  P("bw-modelo",     "Modelo Especial 12pk",   "beer", "Beer — Mexican", 18.99, "12×12oz cans", { popular: true, deal: "Save $3 this week" }),
  P("bw-heineken",   "Heineken 6pk",           "beer", "Beer — Import", 11.99, "6×12oz btl"),
  P("bw-stellacan",  "Stella 6pk Cans",        "beer", "Beer — Import", 12.99, "6×12oz cans"),
  P("bw-othalf",     "Other Half Green Citra", "beer", "Beer — IPA", 18.99, "4×16oz cans", { trending: true, stock: "Back Thursday" }),
  P("bw-montauk",    "Montauk Wave Chaser",    "beer", "Beer — IPA", 12.49, "6×12oz cans"),
  P("bw-guinness",   "Guinness Draught 4pk",   "beer", "Beer — Stout", 10.99, "4×14oz cans"),
  P("bw-whiteclaw",  "White Claw Variety 12",  "beer", "Seltzer", 19.99, "12×12oz cans"),
  P("bw-roseall",    "Whispering Angel Rosé",  "beer", "Wine — Rosé", 22.99, "750ml"),
  P("bw-meiomi",     "Meiomi Pinot Noir",      "beer", "Wine — Red", 19.99, "750ml", { popular: true, deal: "Staff pick · $3 off" }),
  P("bw-sauvb",      "Kim Crawford Sauv Blanc","beer", "Wine — White", 15.99, "750ml"),

  // SNACKS
  P("snk-flamin",    "Flamin' Hot Cheetos",    "snacks", "Chips", 2.49, "bag", { popular: true, deal: "2 for $4" }),
  P("snk-lays",      "Lay's Classic",          "snacks", "Chips", 2.49, "bag"),
  P("snk-doritos",   "Doritos Cool Ranch",     "snacks", "Chips", 2.49, "bag"),
  P("snk-popchips",  "Popcorners Sea Salt",    "snacks", "Chips", 3.25, "bag"),
  P("snk-oreo",      "Oreo Original",          "snacks", "Cookies", 3.99, "family pk", { deal: "15% off" }),
  P("snk-chipsahoy", "Chips Ahoy!",            "snacks", "Cookies", 3.99, "family pk"),
  P("snk-kind",      "Kind Dark Choc Almond",  "snacks", "Bars", 1.75, "bar"),
  P("snk-rxbar",     "RX Bar Peanut Butter",   "snacks", "Bars", 2.75, "bar"),
  P("snk-peanuts",   "Planters Peanuts",       "snacks", "Nuts", 3.50, "can"),
  P("snk-trail",     "Trader's Trail Mix",     "snacks", "Nuts", 4.50, "bag"),
  P("snk-sour",      "Sour Patch Kids",        "snacks", "Candy", 2.99, "bag"),
  P("snk-reeses",    "Reese's Cups",           "snacks", "Candy", 1.75, "pack"),

  // PRODUCE
  P("prd-banana",    "Bananas",                "produce", "Fruit", 0.35, "each"),
  P("prd-apple",     "Honeycrisp Apple",       "produce", "Fruit", 1.25, "each"),
  P("prd-avocado",   "Hass Avocado",           "produce", "Fruit", 1.99, "each", { popular: true, stock: "8 left today" }),
  P("prd-lemon",     "Lemon",                  "produce", "Citrus", 0.85, "each"),
  P("prd-lime",      "Lime",                   "produce", "Citrus", 0.60, "each"),
  P("prd-spinach",   "Baby Spinach",           "produce", "Greens", 4.49, "5oz"),
  P("prd-tomato",    "Vine Tomatoes",          "produce", "Vegetable", 3.99, "lb"),
  P("prd-onion",     "Yellow Onion",           "produce", "Vegetable", 0.99, "each"),

  // PANTRY
  P("pan-bread",     "Martin's Potato Rolls",  "pantry", "Bread", 4.99, "8pk"),
  P("pan-eggs",      "Vital Farms Eggs",       "pantry", "Dairy", 8.99, "dozen", { popular: true }),
  P("pan-milk",      "Organic Whole Milk",     "pantry", "Dairy", 6.49, "half gal"),
  P("pan-butter",    "Kerrygold Butter",       "pantry", "Dairy", 5.99, "8oz", { stock: "3 left" }),
  P("pan-pasta",     "Rao's Marinara",         "pantry", "Canned", 8.99, "24oz jar"),
  P("pan-olive",     "Partanna Olive Oil",     "pantry", "Oil", 18.99, "1L"),

  // HOUSEHOLD
  P("hh-advil",      "Advil, 50ct",            "household", "Meds", 9.99, "btl", { popular: true }),
  P("hh-tylenol",    "Tylenol Extra Strength", "household", "Meds", 10.49, "100ct"),
  P("hh-tp",         "Charmin Ultra Soft 6rl", "household", "Paper", 12.99, "6 rolls"),
  P("hh-ptowel",     "Bounty Paper Towels",    "household", "Paper", 8.99, "4 rolls"),
  P("hh-tide",       "Tide Pods 32ct",         "household", "Laundry", 14.99, "pack"),
  P("hh-soap",       "Dr. Bronner's Pure",     "household", "Soap", 12.99, "16oz"),
  P("hh-lightbulb",  "LED Bulb 60W eq. 4pk",   "household", "Home", 14.99, "4pk"),
  P("hh-toothpaste", "Colgate Total",          "household", "Personal", 4.99, "tube"),
  P("hw-hammer",     "16oz Claw Hammer",       "household", "Hardware", 18.99, "each"),
  P("hw-level",      "9-inch Torpedo Level",   "household", "Hardware", 11.49, "each"),
  P("hw-hooks",      "Picture Hooks, 12-pack", "household", "Hardware", 7.99, "12pk", { popular: true }),
  P("hw-anchors",    "Drywall Anchors, 20pk",  "household", "Hardware", 6.49, "20pk"),
  P("hw-tape",       "Painter's Tape, 1.5in",  "household", "Hardware", 8.99, "roll"),
  P("hw-pencil",     "Carpenter's Pencil",     "household", "Hardware", 2.49, "each"),

  // PET
  P("pet-cat",       "Fancy Feast 12pk",       "petcare", "Cat food", 11.99, "12×3oz"),
  P("pet-treat",     "Greenies Dental Treats", "petcare", "Treats", 9.99, "bag"),
];

// Aisles in a bodega don't always obey neat rules — include some cross-category surprises.
const BUNDLES = [
  { id: "hangover", label: "Hangover Kit", desc: "What actually helps at 10 AM.", items: ["hh-advil", "drk-gatorade", "deli-eggcheese", "drk-poland"] },
  { id: "gameday",  label: "Game-Day Run", desc: "Snacks, beer, and the backup six-pack.", items: ["bw-modelo", "snk-doritos", "snk-flamin", "snk-peanuts"] },
  { id: "movienight", label: "Movie Night", desc: "Picked by a regular.", items: ["snk-popchips", "snk-oreo", "bw-meiomi", "drk-topo"] },
];

// "Goes with" hints — shown contextually as users browse.
const GOES_WITH = {
  "bw-modelo":    ["snk-flamin", "snk-doritos", "prd-lime"],
  "deli-italian": ["drk-topo", "snk-lays"],
  "drk-gatorade": ["hh-advil", "deli-eggcheese"],
  "snk-oreo":     ["pan-milk"],
};

// Flat map for lookups
const PRODUCT_INDEX = Object.fromEntries(PRODUCTS.map(p => [p.id, p]));

// Mock "which store carries this" — stores don't have inventory feeds in this
// prototype, so we infer a plausible source by category + id prefix. Tools go
// to Arbor, wine/beer bias to Fig & Thistle, produce to Verde, late-night to
// Liu, everything-else to Kalymnos.
const STORE_FOR_CATEGORY = {
  deli: "kalymnos",
  coffee: "kalymnos",
  drinks: "liu",
  beer: "fig",
  snacks: "kalymnos",
  produce: "verde",
  pantry: "kalymnos",
  household: "kalymnos",
  petcare: "kalymnos",
};
function storeForProduct(p) {
  if (!p) return STORES[0];
  if (p.id?.startsWith("hw-")) return STORES.find(s => s.id === "arbor") || STORES[0];
  const id = STORE_FOR_CATEGORY[p.category] || "kalymnos";
  return STORES.find(s => s.id === id) || STORES[0];
}
window.storeForProduct = storeForProduct;

// Curated Unsplash photo IDs. Each maps to a known-good direct CDN URL:
//   https://images.unsplash.com/photo-{id}?w=800&q=75&auto=format&fit=crop
// These photos were hand-picked; we prefer specific category overrides to loremflickr's keyword search
// which was returning wildly irrelevant results (tangerines for bodegas, cat statues for markets).
// Fallback chain: product-specific -> category -> loremflickr keyword.
const UNSPLASH = {
  // Stores
  "store-kalymnos":   "1534723452862-4c874018d66d", // bodega / corner store produce
  "store-liu":        "1578916171728-46686eac8d58", // neon corner store night
  "store-elmo":       "1626082927389-6cd097cdc6ec", // fried chicken shop
  "store-verde":      "1488459716781-31db52582fe9", // fresh produce market

  // Category defaults (used when no product-specific image exists)
  "cat-deli":         "1528735602780-2552fd46c7af", // deli sandwich
  "cat-coffee":       "1509042239860-f550ce710b93", // coffee cup
  "cat-beer":         "1535958636474-b021ee887b13", // beer bottles
  "cat-snacks":       "1599490659213-e2b9527bd087", // snack bags
  "cat-produce":      "1542838132-92c53300491e",   // produce market
  "cat-household":    "1610557892470-55d9e80c0bce", // household supplies
  "cat-petcare":      "1583337130417-3346a1be7dee", // pet food

  // Notable product-specifics (highlights)
  "p-deli-italian":   "1528735602780-2552fd46c7af", // italian sub
  "p-deli-eggcheese": "1528207776546-365bb710ee93", // breakfast sandwich
  "p-cof-coldbrew":   "1461023058943-07fcbe16d735", // iced coffee
  "p-cof-latte":      "1509042239860-f550ce710b93", // latte
  "p-drk-cocacola":   "1554866585-cd94860890b7",   // coca-cola bottle
  "p-drk-gatorade":   "1625772299848-391b6a87d7b3", // sports drink
  "p-drk-poland":     "1548839140-29a749e1cf4d",   // water bottle
  "p-bw-modelo":      "1618885472179-5e474019f2a9", // beer can
  "p-bw-heineken":    "1535958636474-b021ee887b13", // green beer bottles
  "p-bw-roseall":     "1558346547-4439467bd1d5",   // rosé bottle
  "p-snk-oreo":       "1590080875515-8a3a8dc5735e", // cookies
  "p-snk-lays":       "1566478989037-eec170784d0b", // chips bag
  "p-prd-banana":     "1528825871115-3581a5387919", // bananas
  "p-prd-apple":      "1568702846914-96b305d2aaeb", // red apples
  "p-prd-avocado":    "1601039641847-7857b994d704", // avocado
  "p-pan-milk":       "1550583724-b2692b85b150",   // milk
};

// Keyword fallbacks (loremflickr) for anything not in UNSPLASH above
const CATEGORY_IMG = {
  deli: "sandwich,deli",
  coffee: "coffee,cafe",
  drinks: "beverage,soda,bottle",
  beer: "beer,bottle,drink",
  snacks: "snack,chips,food",
  produce: "fresh-produce,fruit,vegetable",
  pantry: "pantry,grocery",
  household: "household,supplies",
  petcare: "pet-food,pet",
};
// Per-product loremflickr keywords (fallback only — UNSPLASH curated above wins)
const PRODUCT_IMG = {
  "deli-custom": "sandwich,hero,build",
  "deli-italian": "italian-sandwich,hoagie",
  "deli-turkey": "turkey-club,sandwich",
  "deli-cuban": "cuban-sandwich,pressed",
  "deli-tuna": "tuna-melt,sandwich",
  "deli-blt": "blt,sandwich,bacon",
  "deli-eggcheese": "bacon-egg-cheese,breakfast-sandwich",
  "cof-coldbrew": "cold-brew,iced-coffee",
  "cof-latte": "latte,espresso",
  "cof-drip": "drip-coffee,black-coffee",
  "cof-matcha": "matcha-latte,green",
  "cof-chai": "chai-latte,spiced",
  "drk-cocacola": "coca-cola,bottle",
  "drk-dietcoke": "diet-coke,silver,bottle",
  "drk-sprite": "sprite,lemon-lime,bottle",
  "drk-topo": "topo-chico,sparkling-water,glass-bottle",
  "drk-liquiddeath": "canned-water,black-can",
  "drk-poland": "spring-water,bottle",
  "drk-gatorade": "gatorade,sports-drink,lemon-lime",
  "drk-celsius": "energy-drink,peach,can",
  "drk-redbull": "red-bull,energy,can",
  "drk-ouj": "orange-juice,carton",
  "bw-modelo": "modelo,mexican-beer,can",
  "bw-heineken": "heineken,green-bottle,beer",
  "bw-stellacan": "stella-artois,beer,can",
  "bw-othalf": "craft-beer,ipa,can",
  "bw-montauk": "craft-beer,cans,ipa",
  "bw-guinness": "guinness,stout,beer",
  "bw-whiteclaw": "white-claw,seltzer,can",
  "bw-roseall": "rose-wine,bottle",
  "bw-meiomi": "pinot-noir,red-wine,bottle",
  "bw-sauvb": "sauvignon-blanc,white-wine",
  "snk-flamin": "hot-cheetos,red-snack",
  "snk-lays": "lays,potato-chips,bag",
  "snk-doritos": "doritos,chips,blue-bag",
  "snk-popchips": "popcorn,kettle-corn,bag",
  "snk-oreo": "oreo,cookies,package",
  "snk-chipsahoy": "chocolate-chip-cookies,package",
  "snk-kind": "kind-bar,snack-bar",
  "snk-rxbar": "rx-bar,protein-bar",
  "snk-peanuts": "peanuts,planters,can",
  "snk-trail": "trail-mix,bag",
  "snk-sour": "gummy-candy,sour-patch",
  "snk-reeses": "peanut-butter-cups,candy",
  "prd-banana": "bananas,yellow",
  "prd-apple": "honeycrisp,red-apple",
  "prd-avocado": "avocado,hass,green",
  "prd-lemon": "lemon,citrus",
  "prd-lime": "lime,green,citrus",
  "prd-spinach": "baby-spinach,leafy-greens",
  "prd-tomato": "vine-tomatoes,red",
  "prd-onion": "yellow-onion",
  "pan-bread": "potato-rolls,bread,bag",
  "pan-eggs": "eggs,carton,dozen",
  "pan-milk": "whole-milk,carton",
  "pan-butter": "kerrygold,butter,gold",
  "pan-pasta": "marinara-jar,tomato-sauce",
  "pan-olive": "olive-oil,bottle,italian",
  "hh-advil": "advil,pain-reliever,bottle",
  "hh-tylenol": "tylenol,pills,bottle",
  "hh-tp": "toilet-paper,rolls",
  "hh-ptowel": "paper-towels,rolls",
  "hh-tide": "tide-pods,laundry",
  "hh-soap": "castile-soap,bottle",
  "hh-lightbulb": "led-bulb,lighting",
  "hh-toothpaste": "toothpaste,tube",
  "hw-hammer": "claw-hammer,tool",
  "hw-level": "torpedo-level,spirit-level",
  "hw-hooks": "picture-hooks,wall-hanging",
  "hw-anchors": "drywall-anchors,screws",
  "hw-tape": "painters-tape,blue",
  "hw-pencil": "carpenter-pencil,flat",
  "pet-cat": "cat-food,cans",
  "pet-treat": "dog-treats,bag",
};
function unsplashUrl(id, w = 800) {
  return `https://images.unsplash.com/photo-${id}?w=${w}&q=75&auto=format&fit=crop`;
}
// Resolver returns either a URL (real photo) or a keyword string (loremflickr fallback).
// Callers use the shape: { url } or { keyword } to pick the right CDN.
function productImage(p) {
  if (!p) return undefined;
  if (p.img) return { keyword: p.img };
  const curated = UNSPLASH["p-" + p.id];
  if (curated) return { url: unsplashUrl(curated) };
  const catCurated = UNSPLASH["cat-" + p.category];
  if (catCurated) return { url: unsplashUrl(catCurated) };
  return { keyword: PRODUCT_IMG[p.id] || CATEGORY_IMG[p.category] || "food,product" };
}
function storeImage(s, w = 1600) {
  if (!s) return undefined;
  const curated = UNSPLASH["store-" + s.id];
  if (curated) return { url: unsplashUrl(curated, w) };
  return { keyword: s.img || "storefront" };
}

// Formatting
const money = (n) => `$${n.toFixed(2)}`;

window.STORES = STORES;
window.CATEGORIES = CATEGORIES;
window.PRODUCTS = PRODUCTS;
window.PRODUCT_INDEX = PRODUCT_INDEX;
window.PRODUCT_IMG = PRODUCT_IMG;
window.CATEGORY_IMG = CATEGORY_IMG;
window.productImage = productImage;
window.storeImage = storeImage;
window.unsplashUrl = unsplashUrl;
window.UNSPLASH = UNSPLASH;
window.BUNDLES = BUNDLES;
window.GOES_WITH = GOES_WITH;
window.DELI_BUILDER = DELI_BUILDER;
window.money = money;
