// Store data for Decades on Main — vendors, products, events.
// All exported on window so other script files can read them.
//
// TODO(square): replace these static arrays with API calls.
// - PRODUCTS → GET /api/products (backend fetches Square Catalog API)
// - VENDORS / CATEGORIES / INITIAL_EVENTS → keep in your own DB (not Square's concern)
// See SQUARE_INTEGRATION.md at the project root for the full integration plan.

const VENDORS = [
  {
    id: "magnolia",
    name: "Magnolia & Moss",
    booth: "Booth 12",
    proprietor: "Linda Whitaker",
    blurb: "Painted farmhouse furniture, milk-glass, and gentle florals from the Carolinas.",
    joined: "2021",
  },
  {
    id: "oakridge",
    name: "Oak Ridge Trading Co.",
    booth: "Booth 03",
    proprietor: "Hank & Mary Doss",
    blurb: "Mid-century walnut, brass lighting, and the occasional fishing reel.",
    joined: "2019",
  },
  {
    id: "fernlight",
    name: "Fernlight Studio",
    booth: "Booth 07",
    proprietor: "Esme Caldwell",
    blurb: "Ceramics, hand-thrown stoneware, and Depression-era glass.",
    joined: "2022",
  },
  {
    id: "highspring",
    name: "High Spring Salvage",
    booth: "Booth 18",
    proprietor: "Jonas Reed",
    blurb: "Architectural salvage, garden iron, and old Florida ephemera.",
    joined: "2020",
  },
  {
    id: "twolanterns",
    name: "Two Lanterns",
    booth: "Booth 24",
    proprietor: "Adele & Henry Bishop",
    blurb: "Estate jewelry, silver, watches, and small curiosities.",
    joined: "2018",
  },
  {
    id: "patina",
    name: "Patina House",
    booth: "Booth 09",
    proprietor: "Wren Halloway",
    blurb: "Oil paintings, mirrors with their original gilt, and framed botanicals.",
    joined: "2023",
  },
];

const CATEGORIES = [
  { id: "furniture", name: "Furniture" },
  { id: "lighting", name: "Lighting" },
  { id: "glass", name: "Glassware & Crystal" },
  { id: "ceramics", name: "Pottery & Porcelain" },
  { id: "jewelry", name: "Silver & Jewelry" },
  { id: "art", name: "Art & Mirrors" },
  { id: "clocks", name: "Clocks & Watches" },
  { id: "books", name: "Books & Ephemera" },
  { id: "toys", name: "Vintage Toys" },
  { id: "kitchen", name: "Kitchen & Tableware" },
  { id: "textiles", name: "Linens & Textiles" },
  { id: "candles", name: "Candles & Diffusers" },
  { id: "garden", name: "Primitives & Salvage" },
];

// Tint per category — used to color product placeholders
const CATEGORY_TINT = {
  furniture: { bg: "#5a4636", ink: "#f6ead4" },
  lighting:  { bg: "#c89859", ink: "#2a1d10" },
  glass:     { bg: "#3a5a5a", ink: "#e8f1ef" },
  ceramics:  { bg: "#b06a4a", ink: "#fbf2e6" },
  jewelry:   { bg: "#0f1a2a", ink: "#e8d29a" },
  art:       { bg: "#e8dfc9", ink: "#3a2d1e" },
  clocks:    { bg: "#3e2e1c", ink: "#e8d29a" },
  books:     { bg: "#6b3a2a", ink: "#f6ead4" },
  toys:      { bg: "#a14a2a", ink: "#fbeae0" },
  kitchen:   { bg: "#4a5a4b", ink: "#f6ead4" },
  garden:    { bg: "#4f5d40", ink: "#eef0e3" },
  textiles:  { bg: "#a3534e", ink: "#fbeae0" },
  candles:   { bg: "#7a5a3a", ink: "#f6e8c8" },
};

// Product catalog — empty until real items are added.
const PRODUCTS = [];

// SVG glyphs per category — drawn over a tinted background as the product image
function categoryGlyph(category, ink) {
  const c = { stroke: ink, fill: "none", "stroke-width": 1.4, "stroke-linecap": "round", "stroke-linejoin": "round" };
  const props = Object.entries(c).map(([k,v]) => `${k}="${v}"`).join(" ");
  switch (category) {
    case "furniture":
      // Chair
      return `<svg viewBox="0 0 100 100" ${props}>
        <path d="M30 30 Q30 22 38 22 L62 22 Q70 22 70 30 L70 56 L30 56 Z" />
        <path d="M26 56 L74 56" />
        <path d="M30 56 L26 86" />
        <path d="M70 56 L74 86" />
        <path d="M36 62 L36 80" /><path d="M64 62 L64 80" />
      </svg>`;
    case "lighting":
      return `<svg viewBox="0 0 100 100" ${props}>
        <path d="M35 32 L65 32 L60 52 L40 52 Z" />
        <path d="M50 52 L50 78" />
        <ellipse cx="50" cy="82" rx="14" ry="3" />
        <path d="M50 18 L50 30" />
        <path d="M42 24 L58 24" />
      </svg>`;
    case "glass":
      return `<svg viewBox="0 0 100 100" ${props}>
        <path d="M40 18 L60 18 L62 30 Q62 48 50 50 Q38 48 38 30 Z" />
        <path d="M50 50 L50 78" />
        <ellipse cx="50" cy="82" rx="14" ry="3" />
        <path d="M44 24 Q50 26 56 24" />
      </svg>`;
    case "ceramics":
      return `<svg viewBox="0 0 100 100" ${props}>
        <path d="M34 30 Q34 22 50 22 Q66 22 66 30 L70 78 Q60 84 50 84 Q40 84 30 78 Z" />
        <path d="M34 38 Q50 42 66 38" />
      </svg>`;
    case "jewelry":
      return `<svg viewBox="0 0 100 100" ${props}>
        <circle cx="50" cy="56" r="22" />
        <path d="M50 34 L46 26 L54 26 Z" />
        <path d="M50 50 L46 56 L50 62 L54 56 Z" />
      </svg>`;
    case "art":
      return `<svg viewBox="0 0 100 100" ${props}>
        <rect x="22" y="22" width="56" height="56" />
        <rect x="28" y="28" width="44" height="44" />
        <path d="M34 60 L42 50 L50 56 L58 44 L66 60" />
        <circle cx="58" cy="38" r="3" />
      </svg>`;
    case "garden":
      return `<svg viewBox="0 0 100 100" ${props}>
        <path d="M50 22 Q44 32 50 42 Q56 32 50 22 Z" />
        <path d="M40 32 Q34 42 42 50 Q50 44 40 32 Z" />
        <path d="M60 32 Q66 42 58 50 Q50 44 60 32 Z" />
        <path d="M50 42 L50 80" />
        <path d="M40 80 L60 80" />
      </svg>`;
    case "textiles":
      return `<svg viewBox="0 0 100 100" ${props}>
        <path d="M22 28 L78 28 L74 78 L26 78 Z" />
        <path d="M30 28 L34 78" /><path d="M42 28 L42 78" />
        <path d="M54 28 L54 78" /><path d="M66 28 L70 78" />
      </svg>`;
    case "clocks":
      return `<svg viewBox="0 0 100 100" ${props}>
        <circle cx="50" cy="52" r="26" />
        <path d="M50 36 L50 52 L62 60" />
        <circle cx="50" cy="52" r="1.5" fill="${ink}" stroke="none" />
        <path d="M50 22 L50 26" /><path d="M50 78 L50 82" />
        <path d="M22 52 L26 52" /><path d="M74 52 L78 52" />
      </svg>`;
    case "books":
      return `<svg viewBox="0 0 100 100" ${props}>
        <path d="M22 28 L42 24 L42 78 L22 82 Z" />
        <path d="M42 24 L62 28 L62 80 L42 78 Z" />
        <path d="M62 28 L78 32 L78 76 L62 80 Z" />
        <path d="M28 38 L36 36" /><path d="M28 50 L36 48" />
      </svg>`;
    case "toys":
      return `<svg viewBox="0 0 100 100" ${props}>
        <circle cx="50" cy="48" r="22" />
        <circle cx="50" cy="48" r="14" />
        <path d="M50 26 L50 70" /><path d="M28 48 L72 48" />
        <path d="M34 32 L66 64" /><path d="M66 32 L34 64" />
      </svg>`;
    case "kitchen":
      return `<svg viewBox="0 0 100 100" ${props}>
        <path d="M30 36 Q30 30 36 30 L64 30 Q70 30 70 36 L66 76 L34 76 Z" />
        <path d="M44 18 L44 30" /><path d="M50 18 L50 30" /><path d="M56 18 L56 30" />
        <path d="M30 46 L70 46" />
      </svg>`;
    case "candles":
      // A candle in a jar + a wisp of smoke
      return `<svg viewBox="0 0 100 100" ${props}>
        <path d="M38 38 L62 38 L60 78 Q50 82 40 78 Z" />
        <path d="M38 44 L62 44" />
        <path d="M50 26 L50 38" />
        <path d="M50 14 Q44 18 46 22 Q50 26 50 26 Q50 26 54 22 Q56 18 50 14 Z" />
      </svg>`;
    default:
      return `<svg viewBox="0 0 100 100" ${props}><circle cx="50" cy="50" r="22"/></svg>`;
  }
}

// ─── EVENTS (seed data — store edits via admin panel persist to localStorage) ──
const INITIAL_EVENTS = [
  {
    id: "ev-1",
    title: "Summer Sidewalk Sale",
    date: "2026-06-13",
    time: "11:00 AM – 6:00 PM",
    location: "Out front, weather permitting",
    description: "All vendors marking down their summer pieces. Lemonade on the porch and live acoustic music from 1 to 4.",
    tag: "Sale",
    status: "live",
  },
  {
    id: "ev-2",
    title: "Pickers' Brunch",
    date: "2026-06-21",
    time: "10:00 AM",
    location: "On the porch",
    description: "Bring a piece you're stuck on — we'll trade stories and have a coffee. Free and open to anyone who collects.",
    tag: "Social",
    status: "live",
  },
];

Object.assign(window, {
  VENDORS, CATEGORIES, CATEGORY_TINT, PRODUCTS,
  categoryGlyph,
  INITIAL_EVENTS,
});
