{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "map-store-locator",
  "type": "registry:component",
  "title": "Map Store Locator",
  "description": "A location list beside a stylized map. Choosing a store pans and zooms the map to its pin, and clicking a pin selects the store. Stacks into a map with a swipeable card row below 520px.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "maps",
    "map",
    "store locator",
    "locations",
    "list",
    "zoom",
    "responsive"
  ],
  "docs": "https://hyperblur.dev/effects/map-store-locator",
  "files": [
    {
      "path": "registry/hyperblur/map-store-locator.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/map-store-locator.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface StoreLocation {\n  id: string;\n  name: string;\n  address: string;\n  hours: string;\n  status?: \"open\" | \"closing\" | \"closed\";\n  distance: string;\n  x: number;\n  y: number;\n}\n\nexport interface MapStoreLocatorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\" | \"onChange\" | \"defaultValue\"> {\n  locations?: StoreLocation[];\n  value?: string;\n  defaultValue?: string;\n  onChange?: (id: string, location: StoreLocation) => void;\n  accent?: string;\n  zoom?: number;\n  title?: string;\n}\n\nexport const defaultStoreLocations: StoreLocation[] = [\n  { id: \"harbor\", name: \"Harbor Street\", address: \"214 Harbor St\", hours: \"Open until 8 PM\", status: \"open\", distance: \"0.3 mi\", x: 30, y: 36 },\n  { id: \"mill\", name: \"Old Mill\", address: \"9 Mill Lane\", hours: \"Closes soon, 6 PM\", status: \"closing\", distance: \"0.8 mi\", x: 64, y: 24 },\n  { id: \"kestrel\", name: \"Kestrel Park\", address: \"1180 Kestrel Ave\", hours: \"Open until 9 PM\", status: \"open\", distance: \"1.2 mi\", x: 74, y: 62 },\n  { id: \"union\", name: \"Union Square\", address: \"47 Union Sq\", hours: \"Closed, opens 7 AM\", status: \"closed\", distance: \"1.6 mi\", x: 20, y: 70 },\n  { id: \"quay\", name: \"Riverside Quay\", address: \"302 Quay Rd\", hours: \"Open until 10 PM\", status: \"open\", distance: \"2.1 mi\", x: 50, y: 84 },\n];\n\nfunction mix32(n: number) {\n  let x = n | 0;\n  x = Math.imul(x ^ (x >>> 16), 0x7feb352d);\n  x = Math.imul(x ^ (x >>> 15), 0x846ca68b);\n  x ^= x >>> 16;\n  return (x >>> 0) / 4294967296;\n}\n\nfunction rnd(a: number, b = 0) {\n  return mix32(a * 668265263 + b * 2246822519 + 374761393);\n}\n\nconst MAP = (() => {\n  const blocks: { x: number; y: number; w: number; h: number; f: string }[] = [];\n  const cols = [0, 42, 90, 128, 176, 222, 262, 310, 352, 400];\n  const rows = [0, 36, 78, 114, 160, 198, 240, 278, 300];\n  for (let j = 0; j < rows.length - 1; j++) {\n    for (let i = 0; i < cols.length - 1; i++) {\n      const x = cols[i] + 3.5;\n      const y = rows[j] + 3.5;\n      const w = cols[i + 1] - cols[i] - 7;\n      const h = rows[j + 1] - rows[j] - 7;\n      const r = rnd(i, j);\n      const park = (i === 5 || i === 6) && (j === 4 || j === 5);\n      if (park) {\n        blocks.push({ x, y, w, h, f: \"#13271f\" });\n      } else if (r < 0.45 && w > 30) {\n        const m = Math.round(w / 2);\n        blocks.push({ x, y, w: m - 2, h, f: \"#171b23\" }, { x: x + m + 2, y, w: w - m - 2, h, f: r < 0.2 ? \"#1c212b\" : \"#161920\" });\n      } else {\n        blocks.push({ x, y, w, h, f: r > 0.85 ? \"#1c212b\" : \"#161a22\" });\n      }\n    }\n  }\n  return blocks;\n})();\n\nconst css = `\n.hb-ub4 {\n  --hb-ub4-a: #2f7bff;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  height: 380px;\n  overflow: hidden;\n  border-radius: 14px;\n  border: 1px solid rgba(255, 255, 255, 0.09);\n  background: #0e0e0f;\n  color: #ededed;\n  font-family: inherit;\n  container-type: inline-size;\n}\n.hb-ub4 *, .hb-ub4 *::before, .hb-ub4 *::after { box-sizing: border-box; }\n.hb-ub4-in { display: grid; grid-template-columns: minmax(220px, 38%) minmax(0, 1fr); height: 100%; }\n.hb-ub4-side { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid #222; background: #111111; }\n.hb-ub4-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; }\n.hb-ub4-ti { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-ub4-ct { font: 600 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.14em; text-transform: uppercase; color: #8f8f8f; white-space: nowrap; }\n.hb-ub4-list {\n  position: relative;\n  display: flex;\n  flex-direction: column;\n  gap: 4px;\n  min-height: 0;\n  margin: 0;\n  padding: 0 8px 8px;\n  overflow-y: auto;\n  scrollbar-width: thin;\n  scrollbar-color: #2a2a2a transparent;\n  outline: none;\n}\n.hb-ub4-item {\n  position: relative;\n  display: grid;\n  grid-template-columns: 20px minmax(0, 1fr) auto;\n  column-gap: 9px;\n  row-gap: 2px;\n  align-items: center;\n  width: 100%;\n  margin: 0;\n  padding: 9px 10px;\n  border: 1px solid transparent;\n  border-radius: 10px;\n  background: transparent;\n  color: inherit;\n  font: inherit;\n  text-align: left;\n  cursor: pointer;\n  transition: background 0.2s ease, border-color 0.2s ease;\n}\n.hb-ub4-item:hover { background: rgba(255, 255, 255, 0.035); }\n.hb-ub4-item[aria-selected=\"true\"] {\n  background: color-mix(in srgb, var(--hb-ub4-a) 10%, transparent);\n  border-color: color-mix(in srgb, var(--hb-ub4-a) 38%, transparent);\n}\n.hb-ub4-item:focus-visible { outline: 2px solid var(--hb-ub4-a); outline-offset: -1px; }\n.hb-ub4-n {\n  grid-row: 1 / span 3;\n  align-self: start;\n  display: grid;\n  place-items: center;\n  width: 20px;\n  height: 20px;\n  border-radius: 7px;\n  background: #1c1c1e;\n  border: 1px solid #2a2a2a;\n  font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;\n  color: #a1a1a1;\n  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;\n}\n.hb-ub4-item[aria-selected=\"true\"] .hb-ub4-n { background: var(--hb-ub4-a); border-color: transparent; color: #fff; }\n.hb-ub4-nm { font-size: 12.5px; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-ub4-d { font: 500 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #8f8f8f; white-space: nowrap; }\n.hb-ub4-ad, .hb-ub4-hr { grid-column: 2 / span 2; font-size: 11px; line-height: 1.3; color: #8f8f8f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-ub4-hr { display: flex; align-items: center; gap: 6px; color: #a1a1a1; }\n.hb-ub4-hr::before { content: \"\"; flex: none; width: 6px; height: 6px; border-radius: 50%; background: #3ecf8e; }\n.hb-ub4-hr[data-s=\"closing\"]::before { background: #f5a524; }\n.hb-ub4-hr[data-s=\"closed\"]::before { background: #6b6b6b; }\n.hb-ub4-map { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #0b0d12; }\n.hb-ub4-layer {\n  --hb-ub4-z: 1;\n  position: absolute;\n  inset: 0;\n  transform-origin: 0 0;\n  transition: transform 0.7s cubic-bezier(0.22, 0.8, 0.2, 1);\n  will-change: transform;\n}\n.hb-ub4-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }\n.hb-ub4-pin {\n  position: absolute;\n  z-index: 1;\n  display: grid;\n  place-items: center;\n  width: 22px;\n  height: 22px;\n  margin: 0;\n  padding: 0;\n  border: 1.5px solid var(--hb-ub4-a);\n  border-radius: 50% 50% 50% 4px;\n  background: #101318;\n  color: #ededed;\n  font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;\n  cursor: pointer;\n  transform-origin: 0 100%;\n  transform: translate(0, -100%) scale(calc(1 / var(--hb-ub4-z))) rotate(0deg);\n  transition: transform 0.7s cubic-bezier(0.22, 0.8, 0.2, 1), background 0.2s ease, box-shadow 0.2s ease;\n  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);\n}\n.hb-ub4-pin:hover { background: #18202e; }\n.hb-ub4-pin[aria-pressed=\"true\"] {\n  z-index: 2;\n  background: var(--hb-ub4-a);\n  border-color: #fff;\n  color: #fff;\n  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55), 0 0 0 6px color-mix(in srgb, var(--hb-ub4-a) 22%, transparent);\n  animation: hb-ub4-halo 2.2s ease-out infinite;\n}\n.hb-ub4-pin:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }\n.hb-ub4-route { fill: none; stroke: var(--hb-ub4-a); stroke-width: 2; stroke-dasharray: 3 4; stroke-linecap: round; opacity: 0.85; }\n.hb-ub4-me {\n  position: absolute;\n  left: 42%;\n  top: 52%;\n  width: 11px;\n  height: 11px;\n  margin: -5.5px 0 0 -5.5px;\n  border-radius: 50%;\n  background: #ededed;\n  border: 2px solid #0b0d12;\n  box-shadow: 0 0 0 7px rgba(237, 237, 237, 0.14);\n  transform: scale(calc(1 / var(--hb-ub4-z)));\n  transition: transform 0.7s cubic-bezier(0.22, 0.8, 0.2, 1);\n  pointer-events: none;\n}\n.hb-ub4-ctl {\n  position: absolute;\n  right: 10px;\n  bottom: 10px;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  height: 26px;\n  margin: 0;\n  padding: 0 10px;\n  border-radius: 999px;\n  border: 1px solid rgba(255, 255, 255, 0.1);\n  background: rgba(10, 10, 12, 0.78);\n  color: #ededed;\n  font: inherit;\n  font-size: 11px;\n  cursor: pointer;\n  -webkit-backdrop-filter: blur(8px);\n  backdrop-filter: blur(8px);\n  transition: opacity 0.2s ease, transform 0.2s ease;\n}\n.hb-ub4-ctl[data-hide=\"true\"] { opacity: 0; transform: translateY(4px); pointer-events: none; }\n.hb-ub4-ctl:focus-visible { outline: 2px solid var(--hb-ub4-a); outline-offset: 2px; }\n.hb-ub4-ctl svg { width: 12px; height: 12px; }\n.hb-ub4-shade { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(130% 100% at 50% 45%, transparent 55%, rgba(5, 6, 9, 0.5)); }\n@keyframes hb-ub4-halo {\n  0% { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55), 0 0 0 0 color-mix(in srgb, var(--hb-ub4-a) 45%, transparent); }\n  100% { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55), 0 0 0 12px color-mix(in srgb, var(--hb-ub4-a) 0%, transparent); }\n}\n@container (max-width: 520px) {\n  .hb-ub4-in { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }\n  .hb-ub4-map { grid-row: 1; }\n  .hb-ub4-side { grid-row: 2; border-right: 0; border-top: 1px solid #222; }\n  .hb-ub4-head { display: none; }\n  .hb-ub4-list {\n    flex-direction: row;\n    gap: 6px;\n    padding: 7px;\n    overflow-x: auto;\n    overflow-y: hidden;\n    scroll-snap-type: x mandatory;\n    scrollbar-width: none;\n  }\n  .hb-ub4-list::-webkit-scrollbar { display: none; }\n  .hb-ub4-item {\n    flex: 0 0 min(206px, 72%);\n    scroll-snap-align: start;\n    padding: 7px 9px;\n    border-color: #232323;\n    background: #151515;\n  }\n  .hb-ub4-ad { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-ub4-layer, .hb-ub4-pin, .hb-ub4-me, .hb-ub4-item, .hb-ub4-n, .hb-ub4-ctl { transition: none; }\n  .hb-ub4-pin[aria-pressed=\"true\"] { animation: none; }\n}\n`;\n\nexport function MapStoreLocator({\n  locations = defaultStoreLocations,\n  value,\n  defaultValue,\n  onChange,\n  accent = \"#2f7bff\",\n  zoom = 2,\n  title = \"Brightwater Coffee\",\n  className = \"\",\n  style,\n  ...rest\n}: MapStoreLocatorProps) {\n  const [inner, setInner] = React.useState<string | undefined>(defaultValue ?? locations[0]?.id);\n  const [zoomed, setZoomed] = React.useState(true);\n  const listRef = React.useRef<HTMLDivElement>(null);\n  const items = React.useRef(new Map<string, HTMLButtonElement>());\n  const uid = React.useId();\n  const selId = value ?? inner;\n  const selected = locations.find((l) => l.id === selId) ?? null;\n\n  React.useEffect(() => {\n    const list = listRef.current;\n    const el = selId ? items.current.get(selId) : undefined;\n    if (!list || !el) return;\n    const smooth = !window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const behavior: ScrollBehavior = smooth ? \"smooth\" : \"auto\";\n    if (list.scrollWidth > list.clientWidth + 2) {\n      const left = el.offsetLeft - (list.clientWidth - el.offsetWidth) / 2;\n      list.scrollTo({ left: Math.max(0, left), behavior });\n    } else if (list.scrollHeight > list.clientHeight + 2) {\n      const top = el.offsetTop - (list.clientHeight - el.offsetHeight) / 2;\n      list.scrollTo({ top: Math.max(0, top), behavior });\n    }\n  }, [selId]);\n\n  const select = (loc: StoreLocation) => {\n    if (value === undefined) setInner(loc.id);\n    setZoomed(true);\n    onChange?.(loc.id, loc);\n  };\n\n  const onKey = (e: React.KeyboardEvent<HTMLButtonElement>, index: number) => {\n    const map: Record<string, number> = { ArrowDown: 1, ArrowRight: 1, ArrowUp: -1, ArrowLeft: -1 };\n    let next = -1;\n    if (e.key in map) next = (index + map[e.key] + locations.length) % locations.length;\n    else if (e.key === \"Home\") next = 0;\n    else if (e.key === \"End\") next = locations.length - 1;\n    if (next < 0) return;\n    e.preventDefault();\n    const loc = locations[next];\n    select(loc);\n    items.current.get(loc.id)?.focus();\n  };\n\n  const z = zoomed && selected ? Math.max(1, zoom) : 1;\n  let tx = 0;\n  let ty = 0;\n  if (selected && z > 1) {\n    tx = Math.min(0, Math.max(100 - 100 * z, 50 - selected.x * z));\n    ty = Math.min(0, Math.max(100 - 100 * z, 50 - selected.y * z));\n  }\n  const near = selected ?? locations[0];\n\n  return (\n    <div\n      className={`hb-ub4 ${className}`.trim()}\n      style={{ \"--hb-ub4-a\": accent, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-map-store-locator\" precedence=\"default\">\n        {css}\n      </style>\n      <div className=\"hb-ub4-in\">\n        <div className=\"hb-ub4-side\">\n          <div className=\"hb-ub4-head\">\n            <span className=\"hb-ub4-ti\">{title}</span>\n            <span className=\"hb-ub4-ct\">{locations.length} stores</span>\n          </div>\n          <div ref={listRef} className=\"hb-ub4-list\" role=\"listbox\" aria-label={`${title} locations`} aria-orientation=\"vertical\">\n            {locations.map((loc, i) => {\n              const on = loc.id === selId;\n              return (\n                <button\n                  key={loc.id}\n                  ref={(el) => {\n                    if (el) items.current.set(loc.id, el);\n                    else items.current.delete(loc.id);\n                  }}\n                  id={`${uid}-${loc.id}`}\n                  type=\"button\"\n                  role=\"option\"\n                  aria-selected={on}\n                  tabIndex={on || (!selected && i === 0) ? 0 : -1}\n                  className=\"hb-ub4-item\"\n                  onClick={() => select(loc)}\n                  onKeyDown={(e) => onKey(e, i)}\n                >\n                  <span className=\"hb-ub4-n\">{i + 1}</span>\n                  <span className=\"hb-ub4-nm\">{loc.name}</span>\n                  <span className=\"hb-ub4-d\">{loc.distance}</span>\n                  <span className=\"hb-ub4-ad\">{loc.address}</span>\n                  <span className=\"hb-ub4-hr\" data-s={loc.status ?? \"open\"}>\n                    {loc.hours}\n                  </span>\n                </button>\n              );\n            })}\n          </div>\n        </div>\n        <div className=\"hb-ub4-map\">\n          <div\n            className=\"hb-ub4-layer\"\n            style={\n              {\n                \"--hb-ub4-z\": z.toFixed(3),\n                transform: `translate(${tx.toFixed(3)}%, ${ty.toFixed(3)}%) scale(${z.toFixed(3)})`,\n              } as React.CSSProperties\n            }\n          >\n            <svg className=\"hb-ub4-svg\" viewBox=\"0 0 400 300\" preserveAspectRatio=\"none\" aria-hidden=\"true\">\n              <rect width=\"400\" height=\"300\" fill=\"#0b0d12\" />\n              {MAP.map((b, i) => (\n                <rect key={i} x={b.x} y={b.y} width={b.w} height={b.h} rx=\"2.5\" fill={b.f} />\n              ))}\n              <path d=\"M-10 250 C 80 230, 140 280, 220 262 S 340 214, 410 236\" fill=\"none\" stroke=\"#0e2340\" strokeWidth=\"24\" />\n              <path d=\"M-10 250 C 80 230, 140 280, 220 262 S 340 214, 410 236\" fill=\"none\" stroke=\"#12345c\" strokeWidth=\"17\" />\n              <path d=\"M-10 30 L 410 140\" stroke=\"#0b0d12\" strokeWidth=\"8\" />\n              <path d=\"M-10 30 L 410 140\" stroke=\"#262c38\" strokeWidth=\"0.8\" strokeDasharray=\"4 5\" />\n              {near ? (\n                <path\n                  className=\"hb-ub4-route\"\n                  d={`M 168 156 L ${((near.x / 100) * 400).toFixed(1)} 156 L ${((near.x / 100) * 400).toFixed(1)} ${((near.y / 100) * 300).toFixed(1)}`}\n                  vectorEffect=\"non-scaling-stroke\"\n                />\n              ) : null}\n            </svg>\n            <span className=\"hb-ub4-me\" aria-hidden=\"true\" />\n            {locations.map((loc, i) => (\n              <button\n                key={loc.id}\n                type=\"button\"\n                className=\"hb-ub4-pin\"\n                aria-pressed={loc.id === selId}\n                aria-label={`${loc.name}, ${loc.distance}`}\n                tabIndex={-1}\n                style={{ left: `${loc.x}%`, top: `${loc.y}%` }}\n                onClick={() => select(loc)}\n              >\n                {i + 1}\n              </button>\n            ))}\n          </div>\n          <div className=\"hb-ub4-shade\" />\n          <button\n            type=\"button\"\n            className=\"hb-ub4-ctl\"\n            data-hide={z > 1 ? \"false\" : \"true\"}\n            tabIndex={z > 1 ? 0 : -1}\n            aria-hidden={z > 1 ? undefined : true}\n            onClick={() => setZoomed(false)}\n          >\n            <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinecap=\"round\" aria-hidden=\"true\">\n              <path d=\"M1.5 4.5v-3h3M10.5 4.5v-3h-3M1.5 7.5v3h3M10.5 7.5v3h-3\" />\n            </svg>\n            Show all\n          </button>\n        </div>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}