{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "contact-offices",
  "type": "registry:block",
  "title": "Contact, offices",
  "description": "Where to find us: one card per office or shop (up to eight) with address, its own opening hours (a line per run of days), email, phone and a directions link. No form, no map picture. Email and phone become links; leave a field empty to drop the line.",
  "categories": [
    "contact"
  ],
  "dependencies": [
    "lucide-react@^1.49.0",
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-c-proof.json",
    "https://ui.klarhimmel.com/r/text-link.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/contact-offices/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/contact-offices/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, t } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60),\n  title: t(120),\n  description: t(300),\n  offices: z.array(z.object({\n    city: t(40),\n    address: t(160),\n    /** One line per run of days ('Mon to Fri 8:00 to 18:00\\nSat and Sun 9:00 to 17:00'). */\n    hours: t(160),\n    email: t(80),\n    phone: t(40),\n    /** The route to this place (a maps link). Empty: no link. */\n    directions: link.optional(),\n  })).min(1).max(8),\n  note: t(160),\n});\n\nexport const spec = defineSpec({\n  type: 'contact-offices',\n  aliases: ['contact/offices'],\n  name: 'Contact, offices',\n  category: 'contact',\n  role: 'body',\n  description: 'Where to find us: one card per office or shop (up to eight) with address, its own opening hours (a line per run of days), email, phone and a directions link. No form, no map picture. Email and phone become links; leave a field empty to drop the line.',\n  schema,\n  defaults: {\n    eyebrow: 'Name the topic',\n    title: 'Say how they can reach you',\n    description: 'Say in one or two sentences where you are and how people get an answer.',\n    offices: [\n      { city: 'First place', address: 'Give the street address\\nGive the town', hours: 'Give the days, 00:00 to 00:00\\nGive the day, 00:00 to 00:00', email: 'first@company.example', phone: '+00 00 000 00 00', directions: { label: 'Main action', href: '#directions' } },\n      { city: 'Second place', address: 'Give the street address\\nGive the town', hours: 'Give the days, 00:00 to 00:00', email: 'second@company.example', phone: '+00 0 000 00 00', directions: { label: 'Main action', href: '#directions' } },\n      { city: 'Third place', address: 'Say where it is based', hours: 'Give the days, 00:00 to 00:00', email: 'third@company.example', phone: '', directions: { label: '', href: '' } },\n    ],\n    note: 'Say who to write to about something else.',\n  },\n});\n"
    },
    {
      "path": "src/blocks/contact-offices/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/contact-offices/index.tsx",
      "content": "import { ArrowUpRight, Clock, Globe, Mail, MapPin, Phone } from 'lucide-react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { safeHref } from '../../ui/button';\nimport { linkClass } from '../../ui/text-link';\nimport { Container, Opt, Section, useEditing } from '../_shared/kit';\nimport { Heading, useHeadingId } from '../_shared/c-proof-kit';\nimport { cn } from '../../lib/utils';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\n// Four or eight places fill rows of four; three, five, six or seven rows of three (a shop list of six reads as two full rows).\nconst cols = (n: number) => (n === 1 ? '' : n === 2 ? '@2xl:grid-cols-2' : n % 4 === 0 ? '@2xl:grid-cols-2 @5xl:grid-cols-4' : '@2xl:grid-cols-2 @4xl:grid-cols-3');\n\nconst REMOTE = /\\b(remote|online|everywhere|distans)\\b/i;\nconst CONTACT = /([\\w.+-]+@[\\w-]+(?:\\.[\\w-]+)+|\\+\\d[\\d ()-]{6,}\\d)/g;\n\n/** The note as text, with any email address or phone number turned into a link. */\nfunction linkify(text: string) {\n  return text.split(CONTACT).map((part, i) => {\n    if (i % 2 === 0) return part;\n    const href = part.includes('@') ? `mailto:${part}` : `tel:${part.replace(/[^+\\d]/g, '')}`;\n    return <a key={i} href={href} className={cn(linkClass(), 'inline-flex min-h-6 items-center')}>{part}</a>;\n  });\n}\n\nfunction ContactOffices({ props }: BlockProps<Props>) {\n  const id = useHeadingId(props.title);\n  const editing = useEditing();\n  const row = 'flex items-start gap-3 text-kh-small';\n  const ico = 'mt-0.5 size-4 shrink-0 text-kh-muted';\n  return (\n    <Section labelledBy={id}>\n      <Container>\n        <Heading id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n        <ul className={cn('mt-14 grid gap-5', cols(props.offices.length))}>\n          {props.offices.map((o, i) => (\n            <li key={i} className=\"flex flex-col rounded-kh-xl border border-kh-line bg-kh-surface p-7\">\n              <Text path={['offices', i, 'city']} value={o.city} as=\"h3\" className=\"text-kh-heading font-semibold\" />\n              <ul className=\"mt-6 space-y-4\">\n                <li className={row}>\n                  {REMOTE.test(o.address) ? <Globe aria-hidden className={ico} /> : <MapPin aria-hidden className={ico} />}\n                  <Text path={['offices', i, 'address']} value={o.address} as=\"span\" multiline className=\"min-w-0 whitespace-pre-line\" />\n                </li>\n                {(o.hours || editing) && (\n                  <li className={row}>\n                    <Clock aria-hidden className={ico} />\n                    <Text path={['offices', i, 'hours']} value={o.hours} as=\"span\" multiline className=\"min-w-0 whitespace-pre-line tabular-nums\" placeholder=\"Opening hours\" />\n                  </li>\n                )}\n                {(o.email || editing) && (\n                  <li className={row}>\n                    <Mail aria-hidden className={ico} />\n                    <a href={o.email ? `mailto:${o.email}` : '#'} className={cn(linkClass(), 'inline-flex min-h-6 min-w-0 items-center break-words')}>\n                      <Text path={['offices', i, 'email']} value={o.email} as=\"span\" placeholder=\"Email\" />\n                    </a>\n                  </li>\n                )}\n                {(o.phone || editing) && (\n                  <li className={row}>\n                    <Phone aria-hidden className={ico} />\n                    <a href={o.phone ? `tel:${o.phone.replace(/[^+\\d]/g, '')}` : '#'} className={cn(linkClass(), 'inline-flex min-h-6 items-center')}>\n                      <Text path={['offices', i, 'phone']} value={o.phone} as=\"span\" placeholder=\"Phone\" />\n                    </a>\n                  </li>\n                )}\n              </ul>\n              {(o.directions?.label || editing) && (\n                <a href={safeHref(o.directions?.href ?? '')} className={cn(linkClass(), 'mt-auto inline-flex min-h-11 items-center gap-1 self-start pt-4 text-kh-small font-medium no-underline')}>\n                  <Text path={['offices', i, 'directions', 'label']} value={o.directions?.label ?? ''} as=\"span\" placeholder=\"Directions\" />\n                  <ArrowUpRight aria-hidden className=\"size-4\" />\n                </a>\n              )}\n            </li>\n          ))}\n        </ul>\n        {editing ? (\n          <Opt path={['note']} value={props.note} className=\"mt-8 text-kh-small text-kh-muted\" placeholder=\"Note\" />\n        ) : (\n          props.note && <p className=\"mt-8 text-kh-small text-kh-muted\">{linkify(props.note)}</p>\n        )}\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(ContactOffices);\n"
    }
  ]
}
