{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kit-snapshot",
  "type": "registry:lib",
  "title": "Kit snapshot",
  "description": "Helpers shared by the snapshot blocks.",
  "dependencies": [
    "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/text-link.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/_shared/snapshot-kit.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/_shared/snapshot-kit.tsx",
      "content": "// Shared by the snapshot blocks. Everything here draws untrusted data (crawled pages, search results) as text only.\nimport { Text } from '../../editing';\nimport { useEditing } from './kit';\nimport { cn } from '../../lib/utils';\nimport { safeHref } from '../../ui/button';\nimport { linkClass } from '../../ui/text-link';\n\nexport { KIND_WORDS, SOURCE_KINDS, kindWordsSchema, sourceSchema, type Source, type SourceKind } from './snapshot-schema';\nimport type { Source, SourceKind } from './snapshot-schema';\n\n/** Only http(s) addresses leave the page; everything else (javascript:, data:, a relative path) is '#'. */\nexport const externalHref = (url: string | undefined): string => {\n  const h = safeHref(url);\n  return /^https?:\\/\\//i.test(h) ? h : '#';\n};\nexport const EXTERNAL = { target: '_blank', rel: 'noopener nofollow' } as const;\n\n/** host and path of an address, the path cut to `max` characters; the whole string when it is not an address. */\nexport function hostPath(url: string, max = 48): string {\n  let host = '';\n  let path = '';\n  try {\n    const u = new URL(url);\n    host = u.host;\n    path = `${u.pathname === '/' ? '' : u.pathname}${u.search}`;\n  } catch {\n    return url.length > max ? `${url.slice(0, max - 1)}…` : url;\n  }\n  return path.length > max ? `${host}${path.slice(0, max - 1)}…` : `${host}${path}`;\n}\n\n/** YYYY-MM-DD from an ISO time, '' when it is not one. No locale and no clock: the same on the server and in the browser. */\nexport const dayOf = (iso: string | undefined): string => /^\\d{4}-\\d{2}-\\d{2}/.test(iso ?? '') ? iso!.slice(0, 10) : '';\n/** HH:MM from an ISO time (as written, UTC), '' when it is not one. */\nexport const clockOf = (iso: string | undefined): string => /T(\\d{2}:\\d{2})/.exec(iso ?? '')?.[1] ?? '';\n\nexport const WRAP = '[overflow-wrap:anywhere]';\n\n/** The numbered list of sources. `idPrefix` makes the anchors (`${idPrefix}-s1`, ...) that item markers link to; unique per card. */\nexport function SourceRows({ sources, idPrefix, numbered, kindWords, base = ['sources'], className }: {\n  sources: Source[]; idPrefix: string; numbered: boolean; kindWords: Record<SourceKind, string>; base?: (string | number)[]; className?: string;\n}) {\n  const List = numbered ? 'ol' : 'ul';\n  const editing = useEditing();\n  return (\n    <List className={cn('divide-y divide-kh-line border-y border-kh-line', className)}>\n      {sources.map((s, i) => (\n        <li key={`${s.id}-${i}`} id={`${idPrefix}-s${i + 1}`} className=\"scroll-mt-20 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 py-3 text-kh-small @2xl:grid-cols-[2rem_1fr_auto]\">\n          <span aria-hidden className=\"tabular-nums text-kh-muted\">{numbered ? `[${i + 1}]` : ''}</span>\n          <a href={externalHref(s.url)} {...EXTERNAL} className={cn(linkClass(), 'min-w-0', WRAP)}>\n            {editing ? <Text path={[...base, i, 'url']} value={s.url} as=\"span\" /> : <span>{hostPath(s.url)}</span>}\n          </a>\n          <span className=\"col-start-2 flex flex-wrap gap-x-3 text-kh-caption text-kh-muted @2xl:col-start-3\">\n            <span className={cn(\"max-w-full\", WRAP)}>{kindWords[s.kind]}</span>\n            {dayOf(s.fetchedAt) && <time dateTime={dayOf(s.fetchedAt)}>{dayOf(s.fetchedAt)}</time>}\n          </span>\n        </li>\n      ))}\n    </List>\n  );\n}\n"
    },
    {
      "path": "src/blocks/_shared/snapshot-schema.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/_shared/snapshot-schema.ts",
      "content": "// The source shape shared by the snapshot specs. No React: specs are imported by the worker and MCP.\nimport { z } from 'zod';\nimport { req, t } from './schema';\n\nexport const SOURCE_KINDS = ['crawl', 'search', 'ai_answer', 'dataset', 'brief'] as const;\nexport type SourceKind = (typeof SOURCE_KINDS)[number];\n\n/** One place something was read: a page, a search, an AI answer, a dataset or a brief. */\nexport const sourceSchema = z.object({ id: req(60), url: req(2000), kind: z.enum(SOURCE_KINDS), fetchedAt: t(40) });\nexport type Source = z.infer<typeof sourceSchema>;\n\n/** How each kind of source is said. Optional on a block: English defaults. */\nexport const kindWordsSchema = z.object({ crawl: t(40), search: t(40), ai_answer: t(40), dataset: t(40), brief: t(40) }).partial().optional();\nexport const KIND_WORDS: Record<SourceKind, string> = { crawl: 'Page read', search: 'Search', ai_answer: 'AI answer', dataset: 'Dataset', brief: 'Brief' };\n"
    }
  ]
}
