{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "comms",
  "title": "Comms",
  "description": "Contacts, a message thread, and replies to choose from.",
  "dependencies": [
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json",
    "https://www.cyberspec.dev/r/avatar.json",
    "https://www.cyberspec.dev/r/badge.json",
    "https://www.cyberspec.dev/r/button.json",
    "https://www.cyberspec.dev/r/choice-list.json",
    "https://www.cyberspec.dev/r/feed.json",
    "https://www.cyberspec.dev/r/glitch-text.json",
    "https://www.cyberspec.dev/r/item-list.json",
    "https://www.cyberspec.dev/r/meter.json",
    "https://www.cyberspec.dev/r/micro.json",
    "https://www.cyberspec.dev/r/panel.json",
    "https://www.cyberspec.dev/r/readout.json",
    "https://www.cyberspec.dev/r/screen.json",
    "https://www.cyberspec.dev/r/scroll-area.json",
    "https://www.cyberspec.dev/r/select.json",
    "https://www.cyberspec.dev/r/switch.json",
    "https://www.cyberspec.dev/r/toaster.json"
  ],
  "files": [
    {
      "path": "registry/cyber/blocks/comms/comms.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n@layer cyber.blocks {\n  [data-skin=\"cyber\"] [data-comms-screen] {\n    container: comms / inline-size;\n    grid-template-columns: minmax(0, 1fr);\n  }\n\n  /* The conversation keeps the largest column. On tablet the directory\n     and record share a rail beside it. */\n  [data-skin=\"cyber\"] [data-kit=\"comms\"] {\n    display: grid;\n    grid-template-columns: minmax(206px, 1fr) minmax(190px, 0.9fr) minmax(0, 2.4fr);\n    grid-template-rows: auto 1fr;\n    grid-template-areas:\n      \"list record thread\"\n      \"deck record thread\";\n    align-items: start;\n    gap: 22px 28px;\n\n    @container comms (max-width: 940px) {\n      grid-template-columns: minmax(190px, 0.55fr) minmax(0, 1fr);\n      grid-template-rows: auto auto 1fr;\n      grid-template-areas:\n        \"list thread\"\n        \"record thread\"\n        \"deck thread\";\n      gap: 20px;\n    }\n\n    @container comms (max-width: 620px) {\n      grid-template-columns: minmax(0, 1fr);\n      grid-template-rows: none;\n      grid-template-areas: \"list\" \"record\" \"thread\" \"deck\";\n      gap: 16px;\n    }\n  }\n\n  [data-skin=\"cyber\"] :is([data-comms-picker], [data-comms-disclosure]) {\n    display: none;\n  }\n\n  [data-skin=\"cyber\"] [data-comms-list] {\n    grid-area: list;\n    min-width: 0;\n  }\n\n  [data-skin=\"cyber\"] [data-comms-deck] {\n    grid-area: deck;\n    min-width: 0;\n  }\n\n  /* The status strip's trailing end: what the line is doing, and the key\n     that puts the inbox back. */\n  [data-skin=\"cyber\"] [data-comms-line] {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    gap: 8px 12px;\n  }\n\n  /* ── The record ───────────────────────────────────────────────────── */\n\n  [data-skin=\"cyber\"] [data-comms-record] {\n    grid-area: record;\n    display: grid;\n    gap: 12px;\n    min-width: 0;\n  }\n\n  [data-skin=\"cyber\"] [data-comms-record-head] {\n    display: flex;\n    align-items: baseline;\n    justify-content: space-between;\n    gap: 8px;\n    padding-block-end: 6px;\n    border-block-end: 1px solid var(--cy-line-deco);\n\n    & h2 {\n      margin: 0;\n    }\n  }\n\n  /* The viewer: a plate that tears in when the contact changes. */\n  [data-skin=\"cyber\"] [data-comms-plate] {\n    --frame-cut: var(--cy-cut);\n    --frame-line: var(--cy-line-ctl);\n    --frame-fill: var(--cy-panel);\n\n    display: grid;\n    aspect-ratio: 7 / 6;\n    max-height: 280px;\n    width: 100%;\n    animation: var(--cy-fx-in) 260ms var(--cy-ease-snap) backwards;\n\n    & [data-comms-portrait] {\n      display: block;\n      width: 100%;\n      height: 100%;\n      min-height: 0;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-comms-plate-code] {\n    position: absolute;\n    inset-block-start: 9px;\n    inset-inline-start: 26px;\n  }\n\n  [data-skin=\"cyber\"] [data-comms-plate-bars] {\n    position: absolute;\n    inset-block-start: 18px;\n    inset-inline-end: 10px;\n  }\n\n  [data-skin=\"cyber\"] [data-comms-who] {\n    display: grid;\n    grid-template-columns: minmax(0, 1fr) auto;\n    align-items: center;\n    gap: 2px 10px;\n  }\n\n  [data-skin=\"cyber\"] [data-comms-name] {\n    grid-column: 1 / -1;\n    margin: 0;\n    font-size: var(--cy-text-xl);\n    font-weight: 700;\n    line-height: 1.1;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n    color: var(--cy-ink-hi);\n  }\n\n  [data-skin=\"cyber\"] [data-comms-role] {\n    margin: 0;\n    font-size: var(--cy-text-sm);\n    font-weight: 600;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n    color: var(--cy-ink);\n  }\n\n  /* Label on the left, reading on the right, a rule under each. */\n  [data-skin=\"cyber\"] [data-comms-facts] {\n    display: grid;\n    margin: 0;\n\n    & div {\n      display: flex;\n      align-items: baseline;\n      justify-content: space-between;\n      gap: 12px;\n      padding-block: 5px;\n      border-block-end: 1px solid var(--cy-line-deco);\n    }\n\n    & dt {\n      font-size: var(--cy-text-sm);\n      font-weight: 600;\n      letter-spacing: var(--cy-track);\n      text-transform: uppercase;\n      color: var(--cy-ink-mute);\n    }\n\n    & dd {\n      margin: 0;\n      font-family: var(--cy-mono);\n      font-size: var(--cy-text-xs);\n      text-align: end;\n      color: var(--cy-signal);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-comms-call] {\n    width: 100%;\n  }\n\n  [data-skin=\"cyber\"] [data-comms-contact-actions] { order: 1; }\n\n  [data-skin=\"cyber\"] [data-comms-details] {\n    display: grid;\n    gap: 12px;\n  }\n\n  [data-skin=\"cyber\"] [data-comms-message] {\n    font-size: var(--cy-text-md);\n    line-height: 1.45;\n  }\n\n  /* ── The thread ───────────────────────────────────────────────────── */\n\n  [data-skin=\"cyber\"] [data-comms-thread] {\n    grid-area: thread;\n    display: grid;\n    gap: 14px;\n    min-width: 0;\n    animation: var(--cy-fx-in) 240ms var(--cy-ease-snap) backwards;\n  }\n\n  /* The brief: a frame inside the panel, edged in yellow while the offer is\n     open and in the resting line once it's been answered. */\n  [data-skin=\"cyber\"] [data-comms-brief] {\n    --frame-cut: var(--cy-cut);\n    --frame-line: var(--cy-line-ctl);\n    --frame-fill: var(--cy-panel);\n    --brief-ink: var(--cy-ink);\n\n    display: grid;\n    gap: 8px;\n    padding: 10px 14px 12px;\n\n    &[data-state=\"open\"] {\n      --frame-line: var(--cy-flag);\n      --frame-fill: var(--cy-flag-fill);\n      --brief-ink: var(--cy-flag);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-comms-brief-head] {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    justify-content: space-between;\n    gap: 4px 12px;\n\n    & [data-kit=\"hint\"] {\n      font-family: var(--cy-mono);\n      font-size: var(--cy-text-xs);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-comms-brief-title] {\n    margin: 0;\n    font-size: var(--cy-text-lg);\n    font-weight: 700;\n    line-height: 1.2;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n    color: var(--brief-ink);\n  }\n\n  [data-skin=\"cyber\"] [data-comms-terms] {\n    display: grid;\n    gap: 6px;\n    margin: 0;\n\n    & div {\n      display: grid;\n      grid-template-columns: 84px minmax(0, 1fr);\n      align-items: baseline;\n      gap: 2px 12px;\n    }\n\n    & dt {\n      font-size: var(--cy-text-sm);\n      font-weight: 600;\n      letter-spacing: var(--cy-track);\n      text-transform: uppercase;\n      color: var(--brief-ink);\n    }\n\n    & dd {\n      margin: 0;\n      font-size: var(--cy-text-md);\n      color: var(--cy-ink-hi);\n      text-wrap: pretty;\n    }\n\n    @container comms (max-width: 360px) {\n      & div {\n        grid-template-columns: minmax(0, 1fr);\n      }\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-comms-brief-foot] {\n    display: flex;\n    order: 1;\n    flex-wrap: wrap;\n    align-items: center;\n    justify-content: space-between;\n    gap: 8px 16px;\n    padding-block-start: 8px;\n    border-block-start: 1px solid color-mix(in srgb, var(--frame-line) 40%, transparent);\n  }\n\n  [data-skin=\"cyber\"] [data-comms-pay] {\n    display: inline-flex;\n    align-items: baseline;\n    gap: 8px;\n\n    & [data-kit=\"value\"] {\n      font-size: var(--cy-text-md);\n    }\n  }\n\n  /* Under the panel: what the thread is doing, the replies, the Send key.\n     It keeps its height while the replies are away, so the foot of the\n     screen doesn't jump each time one is sent. */\n  [data-skin=\"cyber\"] [data-comms-answer] {\n    display: grid;\n    align-content: start;\n    gap: 10px;\n    min-height: 236px;\n\n    & [data-kit=\"actions\"] {\n      justify-content: flex-end;\n    }\n\n    @container comms (max-width: 620px) {\n      min-height: 0;\n\n      & [data-kit=\"actions\"] > button {\n        width: 100%;\n      }\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-comms-state] {\n    margin: 0;\n    padding-inline-start: 10px;\n    border-inline-start: 2px solid var(--cy-signal-dim);\n    font-size: var(--cy-text-sm);\n    color: var(--cy-ink-mute);\n  }\n\n  [data-skin=\"cyber\"] [data-comms-replies] {\n    min-width: 0;\n  }\n\n  /* On a phone the picker opens the directory on demand. The selected\n     person's photo, presence and call key stay beside the conversation. */\n  @container comms (max-width: 620px) {\n    [data-skin=\"cyber\"] [data-comms-directory],\n    [data-skin=\"cyber\"] [data-comms-call-name],\n    [data-skin=\"cyber\"] [data-comms-plate-code],\n    [data-skin=\"cyber\"] [data-comms-plate-bars],\n    [data-skin=\"cyber\"] [data-comms-brief]:not([data-expanded]) :is([data-comms-terms], [data-comms-crew]),\n    [data-skin=\"cyber\"] [data-comms-details]:not([data-expanded]) {\n      display: none;\n    }\n\n    [data-skin=\"cyber\"] [data-comms-picker] { display: block; }\n    [data-skin=\"cyber\"] [data-comms-record] {\n      grid-template-columns: clamp(76px, 25cqi, 112px) minmax(0, 1fr);\n      grid-template-areas: \"plate who\" \"actions actions\" \"details details\";\n      gap: 0 14px;\n      align-items: center;\n    }\n    [data-skin=\"cyber\"] [data-comms-record-head] {\n      position: absolute;\n      width: 1px;\n      height: 1px;\n      overflow: hidden;\n      clip-path: inset(50%);\n    }\n    [data-skin=\"cyber\"] [data-comms-plate] { grid-area: plate; }\n    [data-skin=\"cyber\"] [data-comms-who] {\n      grid-area: who;\n      grid-template-columns: 1fr;\n      justify-items: start;\n      gap: 4px;\n    }\n    [data-skin=\"cyber\"] [data-comms-contact-actions] {\n      grid-area: actions;\n      display: grid;\n      grid-template-columns: 1fr 1fr;\n      gap: var(--cy-gap);\n      margin-block-start: 10px;\n    }\n    [data-skin=\"cyber\"] [data-comms-disclosure] {\n      display: inline-flex;\n      min-height: 44px;\n\n      &[aria-expanded=\"true\"] svg { rotate: 180deg; }\n    }\n    [data-skin=\"cyber\"] [data-comms-details] {\n      grid-area: details;\n      margin-block-start: 12px;\n    }\n    [data-skin=\"cyber\"] [data-comms-brief-head] { order: -3; }\n    [data-skin=\"cyber\"] [data-comms-brief-title] { order: -2; }\n    [data-skin=\"cyber\"] [data-comms-brief-foot] { order: -1; }\n    [data-skin=\"cyber\"] [data-comms-crew] { flex-basis: 100%; order: 1; }\n  }\n}\n",
      "type": "registry:file",
      "target": "@components/blocks/comms/comms.css"
    },
    {
      "path": "registry/cyber/blocks/comms/comms.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronDown, Phone, PhoneOff, RotateCcw, Send } from \"lucide-react\"\nimport { contacts, creditsOf, earlierCalls, type Line, type Offer, type Presence } from \"@/registry/cyber/blocks/comms/data\"\nimport { Portrait } from \"@/registry/cyber/blocks/comms/portrait\"\nimport { Avatar, AvatarStack } from \"@/registry/cyber/ui/avatar\"\nimport { Badge } from \"@/registry/cyber/ui/badge\"\nimport { Button } from \"@/registry/cyber/ui/button\"\nimport { ChoiceList } from \"@/registry/cyber/ui/choice-list\"\nimport { Feed, type FeedItem } from \"@/registry/cyber/ui/feed\"\nimport { GlitchText } from \"@/registry/cyber/ui/glitch-text\"\nimport { ItemList } from \"@/registry/cyber/ui/item-list\"\nimport { Meter } from \"@/registry/cyber/ui/meter\"\nimport { Barcode, Corners, Micro } from \"@/registry/cyber/ui/micro\"\nimport { Panel } from \"@/registry/cyber/ui/panel\"\nimport { Readout } from \"@/registry/cyber/ui/readout\"\nimport { Screen } from \"@/registry/cyber/ui/screen\"\nimport { ScrollArea } from \"@/registry/cyber/ui/scroll-area\"\nimport { Select } from \"@/registry/cyber/ui/select\"\nimport { Switch } from \"@/registry/cyber/ui/switch\"\nimport { notify } from \"@/registry/cyber/ui/toaster\"\nimport \"@/registry/cyber/blocks/comms/comms.css\"\n\n// Contacts and messages: who's on the list, the record of whoever is\n// chosen, and the thread with them. A thread whose job offer hasn't been\n// answered is the flagged one, on the list and in its title bar.\n//\n// A reply is chosen with the arrow keys and sent with Enter or the Send\n// key, so walking the replies never sends one. Sending takes the replies\n// away while the contact answers, so focus goes to the line that says what\n// the thread is doing, which is always there. Choosing a contact leaves\n// focus in the list.\n\ntype Message = Line & { id: string }\ntype OfferState = \"open\" | \"accepted\" | \"declined\"\n\ntype Thread = {\n  lines: Message[]\n  // The replies on offer, as a key into the contact's script. None: the\n  // thread has run out.\n  node: string | null\n  waiting: boolean\n  unread: number\n  offer: OfferState | null\n  standing: number\n}\n\nconst startThreads = (): Record<string, Thread> =>\n  Object.fromEntries(\n    contacts.map((contact) => [\n      contact.id,\n      {\n        lines: contact.history.map((line, index) => ({ ...line, id: `${contact.id}-${index}` })),\n        node: contact.start,\n        waiting: false,\n        unread: contact.unread,\n        offer: contact.offer ? \"open\" : null,\n        standing: contact.standing,\n      },\n    ]),\n  )\n\nconst days = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"]\nconst two = (value: number) => String(value).padStart(2, \"0\")\nconst stamp = () => {\n  const now = new Date()\n  return `${days[now.getDay()]} ${two(now.getHours())}:${two(now.getMinutes())}`\n}\nconst clock = (seconds: number) => `${two(Math.floor(seconds / 60))}:${two(seconds % 60)}`\nconst nameOf = (id: string) => contacts.find((contact) => contact.id === id)?.name ?? \"\"\n\nfunction PresenceBadge({ presence }: { presence: Presence }) {\n  if (presence === \"online\")\n    return (\n      <Badge tone=\"ok\" status live>\n        Online\n      </Badge>\n    )\n  return presence === \"busy\" ? (\n    <Badge status>Busy</Badge>\n  ) : (\n    <Badge tone=\"mute\" status>\n      Away\n    </Badge>\n  )\n}\n\n// The attached brief: what the job is, in a frame of its own. It stays in\n// the thread after it's answered, and says how.\nfunction Brief({ offer, state }: { offer: Offer; state: OfferState }) {\n  const [expanded, setExpanded] = React.useState(false)\n  const terms = React.useId()\n  return (\n    <div data-comms-brief=\"\" data-frame=\"tl br\" data-state={state} data-expanded={expanded || undefined}>\n      <div data-comms-brief-head=\"\">\n        <span data-kit=\"hint\">Brief received {offer.received}</span>\n        {state === \"open\" ? <Badge tone=\"flag\">Open offer</Badge> : state === \"accepted\" ? <Badge tone=\"ok\">Accepted</Badge> : <Badge tone=\"mute\">Declined</Badge>}\n      </div>\n      <h3 data-comms-brief-title=\"\">{offer.name}</h3>\n      <div data-comms-brief-foot=\"\">\n        <div data-comms-crew=\"\">\n          <AvatarStack label=\"Crew on this job\" size=\"sm\">\n            {offer.crew.map((name) => (\n              <Avatar key={name} name={name} />\n            ))}\n          </AvatarStack>\n        </div>\n        <Button size=\"sm\" data-comms-disclosure=\"\" aria-controls={terms} aria-expanded={expanded} onClick={() => setExpanded(!expanded)}>\n          {expanded ? \"Hide brief\" : \"View brief\"} <ChevronDown aria-hidden />\n        </Button>\n        <span data-comms-pay=\"\">\n          <span data-kit=\"label\">Pays</span>\n          <span data-kit=\"value\">{creditsOf(offer.pay)}</span>\n        </span>\n      </div>\n      <dl id={terms} data-comms-terms=\"\">\n        <div>\n          <dt>Type</dt>\n          <dd>{offer.kind}</dd>\n        </div>\n        <div>\n          <dt>Objective</dt>\n          <dd>{offer.objective}</dd>\n        </div>\n        <div>\n          <dt>Location</dt>\n          <dd>{offer.location}</dd>\n        </div>\n      </dl>\n    </div>\n  )\n}\n\nexport default function Comms() {\n  const [threads, setThreads] = React.useState(startThreads)\n  const [selected, setSelected] = React.useState(\"mara\")\n  const [choice, setChoice] = React.useState<string | null>(null)\n  const [held, setHeld] = React.useState(false)\n  const [taken, setTaken] = React.useState(0)\n  const [ringing, setRinging] = React.useState<string | null>(null)\n  const [call, setCall] = React.useState<{ id: string; since: number } | null>(null)\n  const [elapsed, setElapsed] = React.useState(0)\n  const [calls, setCalls] = React.useState<FeedItem[]>(earlierCalls)\n  const [showDetails, setShowDetails] = React.useState(false)\n\n  // What a timer needs to know when it fires, long after the render that\n  // set it: who's on screen now, and whether toasts are being held.\n  const now = React.useRef({ selected, held })\n  React.useEffect(() => {\n    now.current = { selected, held }\n  }, [selected, held])\n\n  // Every pause on this screen is a timer in this set. Restoring the inbox\n  // moves the epoch on, so a timer set before it finds it has nothing to do.\n  const timers = React.useRef(new Set<ReturnType<typeof setTimeout>>())\n  const epoch = React.useRef(0)\n  const later = (ms: number, run: (current: boolean) => void) => {\n    const from = epoch.current\n    const timer = setTimeout(() => {\n      timers.current.delete(timer)\n      run(from === epoch.current)\n    }, ms)\n    timers.current.add(timer)\n  }\n  React.useEffect(() => {\n    const pending = timers.current\n    return () => pending.forEach(clearTimeout)\n  }, [])\n\n  // The line under the thread takes focus when what had it leaves: the\n  // replies after one is sent, a toast after its key is pressed.\n  const stateLine = React.useRef<HTMLParagraphElement>(null)\n  const [focusTick, setFocusTick] = React.useState(0)\n  React.useEffect(() => {\n    if (focusTick) stateLine.current?.focus()\n  }, [focusTick])\n\n  React.useEffect(() => {\n    if (!call) return\n    const timer = setInterval(() => setElapsed(Math.floor((Date.now() - call.since) / 1000)), 1000)\n    return () => clearInterval(timer)\n  }, [call])\n\n  const contact = contacts.find((entry) => entry.id === selected) ?? contacts[0]\n  const thread = threads[contact.id]\n  const replies = thread.waiting || !thread.node ? [] : (contact.script[thread.node] ?? [])\n  // The first reply is the chosen one until another is, as on any radio\n  // group that has to have an answer.\n  const reply = replies.find((entry) => entry.value === choice) ?? replies[0]\n\n  const unread = Object.values(threads).reduce((sum, entry) => sum + entry.unread, 0)\n  const offers = Object.values(threads).filter((entry) => entry.offer === \"open\").length\n\n  // Opening a thread reads it.\n  const open = (id: string) => {\n    setSelected(id)\n    setChoice(null)\n    setThreads((all) => (all[id].unread ? { ...all, [id]: { ...all[id], unread: 0 } } : all))\n  }\n\n  const send = () => {\n    if (!reply) return\n    const { id, name } = contact\n    const sent = reply\n    const at = stamp()\n    setThreads((all) => {\n      const before = all[id]\n      const shift = sent.outcome === \"accept\" ? 6 : sent.outcome === \"decline\" ? -9 : 1\n      return {\n        ...all,\n        [id]: {\n          ...before,\n          lines: [...before.lines, { id: `${id}-${before.lines.length}`, from: \"me\", time: at, text: sent.label }],\n          waiting: true,\n          offer: sent.outcome === \"accept\" ? \"accepted\" : sent.outcome === \"decline\" ? \"declined\" : before.offer,\n          standing: Math.max(0, Math.min(100, before.standing + shift)),\n        },\n      }\n    })\n    if (sent.outcome === \"accept\") setTaken((count) => count + 1)\n    setChoice(null)\n    setFocusTick((tick) => tick + 1)\n\n    // They answer after about as long as it takes to type it.\n    later(1300 + sent.answer.length * 14, (current) => {\n      if (!current) return\n      const viewing = now.current.selected === id\n      const back = stamp()\n      setThreads((all) => {\n        const before = all[id]\n        return {\n          ...all,\n          [id]: {\n            ...before,\n            lines: [...before.lines, { id: `${id}-${before.lines.length}`, from: \"them\", time: back, text: sent.answer }],\n            waiting: false,\n            node: sent.next ?? null,\n            unread: viewing ? 0 : before.unread + 1,\n          },\n        }\n      })\n      if (now.current.held) return\n      notify(`${name} replied`, {\n        description: sent.answer,\n        action: viewing\n          ? undefined\n          : {\n              label: `Open thread with ${name}`,\n              onAction: () => {\n                open(id)\n                setFocusTick((tick) => tick + 1)\n              },\n            },\n      })\n    })\n  }\n\n  const log = (actor: string, text: string, missed?: boolean) =>\n    setCalls((entries) => [...entries, { id: `call-${entries.length}-${Date.now()}`, time: stamp(), actor, text, tone: missed ? (\"flag\" as const) : undefined }].slice(-5))\n\n  // The Call key: hangs up if this contact is on the line, refuses if\n  // someone else is, and otherwise rings. The promise it returns keeps the\n  // key pending while it rings.\n  const dial = () => {\n    const { id, name } = contact\n    if (call?.id === id) {\n      const length = clock(Math.floor((Date.now() - call.since) / 1000))\n      setCall(null)\n      log(name, `Call ended after ${length}.`)\n      notify(\"Call ended\", { description: `${name}, ${length} on the line.` })\n      return\n    }\n    if (call) {\n      notify(\"Line in use\", { tone: \"warning\", description: `End the call with ${nameOf(call.id)} first.` })\n      return\n    }\n    if (ringing) return\n    setRinging(id)\n    return new Promise<void>((resolve) => {\n      later(1500, (current) => {\n        resolve()\n        if (!current) return\n        setRinging(null)\n        if (contact.call.connects) {\n          setElapsed(0)\n          setCall({ id, since: Date.now() })\n          log(name, \"Connected.\")\n          notify(`Connected to ${name}`, { tone: \"success\", description: contact.call.line })\n        } else {\n          log(name, \"No answer.\", true)\n          notify(\"No answer\", { tone: \"warning\", description: `${name}. ${contact.call.line}` })\n        }\n      })\n    })\n  }\n\n  const restore = () => {\n    epoch.current += 1\n    setThreads(startThreads())\n    setSelected(\"mara\")\n    setChoice(null)\n    setTaken(0)\n    setRinging(null)\n    setCall(null)\n    setCalls(earlierCalls)\n    notify(\"Inbox restored\", { description: \"Six threads, two offers waiting.\" })\n  }\n\n  // C calls, from anywhere on the screen. The key is only listened for\n  // while focus is inside the screen, and it presses the Call key itself so\n  // the key shows the ringing.\n  const callKey = React.useRef<HTMLButtonElement>(null)\n  const recordId = React.useId()\n  const detailsId = React.useId()\n  const onScreenKey = (event: React.KeyboardEvent) => {\n    if (event.key.toLowerCase() !== \"c\" || event.repeat || event.metaKey || event.ctrlKey || event.altKey) return\n    if ((event.target as Element).closest(\"input, textarea, select, [contenteditable]\")) return\n    callKey.current?.click()\n  }\n\n  const onLine = call?.id === contact.id\n  const offer = contact.offer\n  const last = thread.lines[thread.lines.length - 1]\n\n  const messages: FeedItem[] = thread.lines.map((line) => ({\n    id: line.id,\n    time: line.time,\n    actor: line.from === \"me\" ? \"You\" : contact.name,\n    text: <span data-comms-message={line.from}>{line.text}</span>,\n    tone: line.offer ? \"flag\" : undefined,\n  }))\n\n  const state = thread.waiting\n    ? `Sent. ${contact.name} is typing.`\n    : replies.length\n      ? `${replies.length} replies ready. Choose one and send it.`\n      : \"Nothing left to answer. The thread is quiet.\"\n\n  return (\n    <Screen\n      label=\"Comms\"\n      data-comms-screen=\"\"\n      onKeyDown={onScreenKey}\n      status={\n        <>\n          <Readout label=\"Unread\" value={unread} size=\"sm\" tone={unread ? \"flag\" : \"signal\"} />\n          <Readout label=\"Open offers\" value={offers} size=\"sm\" tone=\"accent\" />\n          <Readout label=\"Jobs taken\" value={taken} size=\"sm\" />\n        </>\n      }\n      aside={\n        <div data-comms-line=\"\">\n          <span role=\"status\">\n            {call ? (\n              <Badge tone=\"signal\" status live>\n                On call: {nameOf(call.id)}\n              </Badge>\n            ) : ringing ? (\n              <Badge status live>\n                Ringing {nameOf(ringing)}\n              </Badge>\n            ) : (\n              <Badge tone=\"mute\" status>\n                Line idle\n              </Badge>\n            )}\n          </span>\n          {call && (\n            <span data-kit=\"value\" role=\"timer\" aria-label=\"Call time\">\n              {clock(elapsed)}\n            </span>\n          )}\n          <Button\n            size=\"sm\"\n            tone=\"ghost\"\n            data-agent-confirm=\"Restores the inbox to how it started. Every reply sent this session and the call log are discarded.\"\n            onClick={restore}\n          >\n            <RotateCcw aria-hidden />\n            Restore inbox\n          </Button>\n        </div>\n      }\n      hints={[\n        { keys: [\"↑\", \"↓\"], label: \"Browse\" },\n        { keys: \"↵\", label: \"Send reply\" },\n        { keys: \"C\", label: \"Call\" },\n      ]}\n      code=\"CS-C4 // COMMS // VANTA RELAY LT-04 // PROTOCOL 7741-C\"\n    >\n      <div data-kit=\"comms\">\n        <div data-comms-list=\"\">\n          <h2 data-sr-only>Contact list</h2>\n          <div data-comms-directory=\"\">\n            <ItemList\n              label=\"Contacts\"\n              countLabel=\"unread\"\n              value={selected}\n              // Pressing the chosen row again would clear the choice; the\n              // record and the thread always show someone, so that's ignored.\n              onValueChange={(value) => value && open(value)}\n              items={contacts.map((entry) => ({\n                value: entry.id,\n                label: entry.name,\n                meta: entry.role,\n                flag: threads[entry.id].offer === \"open\" ? \"Job offer waiting\" : undefined,\n                count: threads[entry.id].unread || undefined,\n              }))}\n            />\n          </div>\n          <div data-comms-picker=\"\">\n            <Select\n              label=\"Contacts\"\n              options={contacts.map((entry) => {\n                const { unread, offer } = threads[entry.id]\n                const status = [unread ? `${unread} unread` : \"\", offer === \"open\" ? \"Open offer\" : \"\"].filter(Boolean).join(\" · \")\n                return { value: entry.id, label: status ? `${entry.name} · ${status}` : entry.name }\n              })}\n              value={selected}\n              onValueChange={(value) => value && open(value)}\n            />\n          </div>\n        </div>\n\n        <section data-comms-record=\"\" aria-labelledby={recordId}>\n          <div data-comms-record-head=\"\">\n            <h2 id={recordId} data-kit=\"label\">\n              Contact record\n            </h2>\n            <Micro>{contact.channel} // Rev 0.1</Micro>\n          </div>\n          <div data-comms-plate=\"\" data-frame=\"tl br\" key={contact.id}>\n            <Corners size={8} inset={7} />\n            <Portrait look={contact.look} seed={contact.name} />\n            <Micro data-comms-plate-code=\"\">\n              ID plate 0{contact.look + 1} // {contact.district}\n            </Micro>\n            <Barcode data-comms-plate-bars=\"\" value={`${contact.channel} ${contact.name}`} vertical size={10} />\n          </div>\n          <div data-comms-who=\"\">\n            <GlitchText as=\"p\" data-comms-name=\"\">\n              {contact.name}\n            </GlitchText>\n            <p data-comms-role=\"\">\n              {contact.role}\n              <span aria-hidden> // </span>\n              <span data-sr-only>, </span>\n              {contact.district}\n            </p>\n            {onLine ? (\n              <Badge tone=\"signal\" status live>\n                On call\n              </Badge>\n            ) : (\n              <PresenceBadge presence={contact.presence} />\n            )}\n          </div>\n          <div data-comms-contact-actions=\"\">\n            <Button data-comms-disclosure=\"\" aria-controls={detailsId} aria-expanded={showDetails} onClick={() => setShowDetails(!showDetails)}>\n              Details <ChevronDown aria-hidden />\n            </Button>\n            <Button ref={callKey} tone=\"signal\" data-comms-call=\"\" onClick={dial} aria-label={`${onLine ? \"End call with\" : \"Call\"} ${contact.name}`}>\n              {onLine ? <PhoneOff aria-hidden /> : <Phone aria-hidden />}\n              {onLine ? \"End call\" : \"Call\"} <span data-comms-call-name=\"\">{onLine ? `with ${contact.name}` : contact.name}</span>\n            </Button>\n          </div>\n          <div data-comms-details=\"\" id={detailsId} data-expanded={showDetails || undefined}>\n            <dl data-comms-facts=\"\">\n              <div>\n                <dt>Channel</dt>\n                <dd>{contact.channel}</dd>\n              </div>\n              <div>\n                <dt>Last contact</dt>\n                <dd>{last.time}</dd>\n              </div>\n              <div>\n                <dt>Jobs together</dt>\n                <dd>{two(contact.jobs + (thread.offer === \"accepted\" ? 1 : 0))}</dd>\n              </div>\n            </dl>\n            <Meter label=\"Standing\" value={thread.standing} />\n          </div>\n        </section>\n\n        <div data-comms-thread=\"\" key={contact.id}>\n          <Panel\n            variant=\"titled\"\n            tone={thread.offer === \"open\" ? \"flag\" : \"default\"}\n            title=\"Message thread\"\n            level={2}\n            code={`${contact.channel} // ${thread.offer === \"open\" ? \"INBOUND // ANSWER BEFORE 04:00\" : \"THREAD SYNCED\"}`}\n            actions={`${two(thread.lines.length)} messages`}\n          >\n            <ScrollArea label={`Messages with ${contact.name}`} maxHeight={264} stickToEnd>\n              <Feed label={`Thread with ${contact.name}`} items={messages} live={thread.waiting} />\n            </ScrollArea>\n            {offer && thread.offer && <Brief offer={offer} state={thread.offer} />}\n          </Panel>\n\n          <div data-comms-answer=\"\">\n            <p data-comms-state=\"\" role=\"status\" tabIndex={-1} ref={stateLine}>\n              {state}\n            </p>\n            {reply && (\n              // Enter sends the chosen reply. The arrow keys only choose.\n              <div\n                data-comms-replies=\"\"\n                onKeyDown={(event) => {\n                  if (event.key !== \"Enter\" || event.repeat || !(event.target as Element).closest('[data-kit=\"choice\"]')) return\n                  event.preventDefault()\n                  send()\n                }}\n              >\n                <ChoiceList\n                  key={thread.node}\n                  label={`Reply to ${contact.name}`}\n                  options={replies.map((entry) => ({ value: entry.value, label: entry.label }))}\n                  value={reply.value}\n                  onValueChange={(value) => setChoice(value)}\n                />\n              </div>\n            )}\n            <div data-kit=\"actions\">\n              <Button\n                tone={reply ? \"flag\" : \"secondary\"}\n                disabled={!reply}\n                // Turning a job down can't be taken back, so an agent has to ask first.\n                data-agent-confirm={\n                  reply?.outcome === \"decline\" && offer ? `Declines the job offer \"${offer.name}\" from ${contact.name}. It won't be offered again.` : undefined\n                }\n                onClick={send}\n              >\n                <Send aria-hidden />\n                Send reply\n              </Button>\n            </div>\n          </div>\n        </div>\n\n        <div data-comms-deck=\"\">\n          <Panel title=\"Line\" level={2} tone=\"signal\" code=\"VANTA MK.II // RELAY LT-04\" actions={call ? \"In use\" : ringing ? \"Ringing\" : \"Idle\"}>\n            <Switch label=\"Hold notifications\" checked={held} onCheckedChange={(next) => setHeld(next)} />\n            <p data-kit=\"hint\">Replies still arrive and are counted. The deck just stays quiet.</p>\n            <Feed label=\"Call log\" items={calls} />\n          </Panel>\n        </div>\n      </div>\n    </Screen>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/blocks/comms/comms.tsx"
    },
    {
      "path": "registry/cyber/blocks/comms/data.ts",
      "content": "// The people on the deck's contact list, what's been said so far, and what\n// each of them says back. Nothing here is fetched or generated: a thread is\n// a short script, one or two exchanges deep.\n\ntype Presence = \"online\" | \"busy\" | \"away\"\n\ntype Offer = {\n  name: string\n  received: string\n  kind: string\n  objective: string\n  location: string\n  pay: number\n  crew: string[]\n}\n\ntype Line = {\n  from: \"them\" | \"me\"\n  time: string\n  text: string\n  // The line that carries the job offer.\n  offer?: boolean\n}\n\ntype Reply = {\n  value: string\n  label: string\n  // What comes back, after a pause.\n  answer: string\n  // The replies offered after that answer. None ends the thread.\n  next?: string\n  // Settles an open job offer.\n  outcome?: \"accept\" | \"decline\"\n}\n\ntype Contact = {\n  id: string\n  name: string\n  role: string\n  district: string\n  presence: Presence\n  // The channel the deck reaches them on. Decoration with a label.\n  channel: string\n  // Which head the portrait plate draws.\n  look: number\n  standing: number\n  jobs: number\n  unread: number\n  history: Line[]\n  offer?: Offer\n  start: string\n  script: Record<string, Reply[]>\n  // A call either connects or it doesn't; either way there's a line for it.\n  call: { connects: boolean; line: string }\n}\n\nconst contacts: Contact[] = [\n  {\n    id: \"mara\",\n    name: \"Mara Voss\",\n    role: \"Fixer\",\n    district: \"Lowtide\",\n    presence: \"online\",\n    channel: \"VX-221\",\n    look: 0,\n    standing: 72,\n    jobs: 7,\n    unread: 0,\n    history: [\n      { from: \"them\", time: \"Sat 22:40\", text: \"Payment for the Cinder Row run cleared. ¤ 2 400, minus the Union's cut.\" },\n      { from: \"me\", time: \"Sat 22:41\", text: \"Received. The cut gets bigger every month.\" },\n      { from: \"them\", time: \"Sat 22:43\", text: \"So does the Union. Stay reachable, something bigger is coming.\" },\n      { from: \"them\", time: \"Sun 08:26\", text: \"Job offer: The Glass Ledger. The brief is attached.\", offer: true },\n    ],\n    offer: {\n      name: \"The Glass Ledger\",\n      received: \"Sun 08:26\",\n      kind: \"Recovery, quiet\",\n      objective: \"Lift the audit ledger from the Onyx annex before the morning shift badges in.\",\n      location: \"Onyx Dynamics annex, Pier 9, Glasswater\",\n      pay: 4200,\n      crew: [\"Dex Marlowe\", \"Sable Quinn\"],\n    },\n    start: \"offer\",\n    script: {\n      offer: [\n        { value: \"mara-in\", label: \"Send the route. I'm in.\", answer: \"Good. Dex has the wheel, Sable goes in with you. Route is on your deck.\", next: \"crew\", outcome: \"accept\" },\n        { value: \"mara-terms\", label: \"What does it pay, and who else is on it?\", answer: \"¤ 4 200 on delivery. Dex drives, Sable takes the fourth floor with you. Nobody else knows.\", next: \"terms\" },\n        { value: \"mara-later\", label: \"Mid-run. Ask me again after dark.\", answer: \"It walks at 04:00, with or without you. I'll hold it until then.\", next: \"terms\" },\n        { value: \"mara-out\", label: \"Not this one, Mara.\", answer: \"Your call. It goes to the Static Saints.\", outcome: \"decline\" },\n      ],\n      terms: [\n        { value: \"mara-terms-in\", label: \"Then I'm in. Send the route.\", answer: \"Route's on your deck. The morning shift badges in at 06:00.\", outcome: \"accept\" },\n        { value: \"mara-terms-out\", label: \"Too thin for Onyx. I'm out.\", answer: \"Your call. It goes to the Static Saints.\", outcome: \"decline\" },\n      ],\n      crew: [\n        { value: \"mara-crew-mark\", label: \"Tell Sable to wait for my mark.\", answer: \"She'll wait. Don't make her wait long.\" },\n        { value: \"mara-crew-solo\", label: \"I work better alone on the floor.\", answer: \"Not on this one. Sable goes in. That's the deal.\" },\n      ],\n    },\n    call: { connects: true, line: \"Line open. She gives you ninety seconds.\" },\n  },\n  {\n    id: \"ilya\",\n    name: \"Ilya Brandt\",\n    role: \"Tech\",\n    district: \"The Stacks\",\n    presence: \"busy\",\n    channel: \"VX-304\",\n    look: 1,\n    standing: 58,\n    jobs: 3,\n    unread: 0,\n    history: [\n      { from: \"them\", time: \"Fri 19:12\", text: \"Your Vanta deck is on my bench. The relay board is cooked, not the core.\" },\n      { from: \"me\", time: \"Fri 19:15\", text: \"How long?\" },\n      { from: \"them\", time: \"Fri 19:16\", text: \"Two days if the part ships from Glasswater. One if you stop asking.\" },\n      { from: \"them\", time: \"Sun 23:02\", text: \"Deck's done. I flashed Null Ping while it was open. You're welcome.\" },\n    ],\n    start: \"pickup\",\n    script: {\n      pickup: [\n        { value: \"ilya-owe\", label: \"On my way to the Stacks. What do I owe you?\", answer: \"¤ 380 and the old relay board. I want to see how it failed.\", next: \"pay\" },\n        { value: \"ilya-build\", label: \"Did you touch my Ghostwrite build?\", answer: \"Didn't touch it. Looked at it. It's ugly, but it's yours.\", next: \"pay\" },\n        { value: \"ilya-hold\", label: \"Hold it until tomorrow.\", answer: \"Shelf fee starts at midnight. Kidding. Mostly.\" },\n      ],\n      pay: [\n        { value: \"ilya-credits\", label: \"Credits are on the way.\", answer: \"Received. Level 27, the bench by the window.\" },\n        { value: \"ilya-tab\", label: \"Put it on Mara's tab.\", answer: \"Mara's tab is longer than my arm. Fine. Once.\" },\n      ],\n    },\n    call: { connects: false, line: \"The bench light is on. Ilya doesn't pick up mid-solder.\" },\n  },\n  {\n    id: \"juno\",\n    name: \"Juno Okafor\",\n    role: \"Medic\",\n    district: \"Cinder Row\",\n    presence: \"online\",\n    channel: \"VX-118\",\n    look: 2,\n    standing: 81,\n    jobs: 5,\n    unread: 0,\n    history: [\n      { from: \"me\", time: \"Mon 02:14\", text: \"Coming in. Left arm, a graze from something Kestrel makes.\" },\n      { from: \"them\", time: \"Mon 02:15\", text: \"Back door. Mind the stairs, Solace only just paid for the cleaning.\" },\n      { from: \"them\", time: \"Mon 04:40\", text: \"Sealed. The reflex booster needs recalibrating. Come back in a week.\" },\n      { from: \"them\", time: \"Sun 11:30\", text: \"It's been a week. Booster check: today or tomorrow?\" },\n    ],\n    start: \"check\",\n    script: {\n      check: [\n        { value: \"juno-today\", label: \"Today. After dark.\", answer: \"Back door, 21:00. Eat something first.\" },\n        { value: \"juno-tomorrow\", label: \"Tomorrow. I'm on a job tonight.\", answer: \"Then don't push the left arm. I mean it.\", next: \"arm\" },\n        { value: \"juno-skip\", label: \"It feels fine. Skip it.\", answer: \"It feels fine until it fires on its own. Tomorrow, then. Not a question.\" },\n      ],\n      arm: [\n        { value: \"juno-right\", label: \"Understood. Right hand only.\", answer: \"Good. I'll keep the table free.\" },\n        { value: \"juno-promise\", label: \"No promises.\", answer: \"There never are. Solace has your policy number. I checked.\" },\n      ],\n    },\n    call: { connects: true, line: \"Line open. Juno has you on speaker, gloves on.\" },\n  },\n  {\n    id: \"dex\",\n    name: \"Dex Marlowe\",\n    role: \"Driver\",\n    district: \"Lowtide\",\n    presence: \"away\",\n    channel: \"VX-077\",\n    look: 3,\n    standing: 64,\n    jobs: 9,\n    unread: 1,\n    history: [\n      { from: \"them\", time: \"Sat 17:50\", text: \"New plates on the van. The old ones are at the bottom of the canal.\" },\n      { from: \"me\", time: \"Sat 17:52\", text: \"Which canal?\" },\n      { from: \"them\", time: \"Sat 17:52\", text: \"Exactly.\" },\n      { from: \"them\", time: \"Mon 06:10\", text: \"Job offer: Cold Chain. The brief is attached.\", offer: true },\n    ],\n    offer: {\n      name: \"Cold Chain\",\n      received: \"Mon 06:10\",\n      kind: \"Courier, timed\",\n      objective: \"Move one sealed Meridian cooler across the river before it warms.\",\n      location: \"Dock 4, Lowtide, to the Heights clinic\",\n      pay: 1800,\n      crew: [\"Dex Marlowe\"],\n    },\n    start: \"offer\",\n    script: {\n      offer: [\n        { value: \"dex-in\", label: \"I'll ride along. When?\", answer: \"Dock 4 at 23:00. Bring the Wraith jacket, the cooler leaks cold.\", outcome: \"accept\" },\n        { value: \"dex-what\", label: \"What's in the cooler?\", answer: \"Didn't ask. Meridian label, Solace seal. That's all I want to know.\", next: \"cooler\" },\n        { value: \"dex-out\", label: \"Find another pair of hands.\", answer: \"Fair. I'll ask the Union.\", outcome: \"decline\" },\n      ],\n      cooler: [\n        { value: \"dex-cooler-in\", label: \"Good enough. I'm in.\", answer: \"Dock 4 at 23:00. Bring the Wraith jacket, the cooler leaks cold.\", outcome: \"accept\" },\n        { value: \"dex-cooler-out\", label: \"Sealed boxes aren't my thing. Pass.\", answer: \"Fair. I'll ask the Union.\", outcome: \"decline\" },\n      ],\n    },\n    call: { connects: false, line: \"Driving. He'll call back from the next red light.\" },\n  },\n  {\n    id: \"sable\",\n    name: \"Sable Quinn\",\n    role: \"Runner\",\n    district: \"The Stacks\",\n    presence: \"away\",\n    channel: \"VX-412\",\n    look: 4,\n    standing: 49,\n    jobs: 4,\n    unread: 0,\n    history: [\n      { from: \"them\", time: \"Thu 21:41\", text: \"Inside. Fourth floor, east stair.\" },\n      { from: \"them\", time: \"Thu 21:58\", text: \"Out. Roof to roof. Tell Dex the van can go.\" },\n      { from: \"me\", time: \"Thu 22:03\", text: \"Clean?\" },\n      { from: \"them\", time: \"Thu 22:04\", text: \"Clean enough. I owe the Neon Jackals a favor now. Long story.\" },\n    ],\n    start: \"favor\",\n    script: {\n      favor: [\n        { value: \"sable-what\", label: \"What kind of favor?\", answer: \"The kind you don't put in writing. Ask me in person.\", next: \"meet\" },\n        { value: \"sable-out\", label: \"Keep me out of it.\", answer: \"Already did. You were never on that roof.\" },\n      ],\n      meet: [\n        { value: \"sable-noodles\", label: \"Noodle bar under the Stacks, midnight.\", answer: \"Midnight. You're buying.\" },\n        { value: \"sable-pass\", label: \"Then I don't want to know.\", answer: \"Smart. I wouldn't either.\" },\n      ],\n    },\n    call: { connects: false, line: \"Sable doesn't take calls on a roof.\" },\n  },\n  {\n    id: \"ren\",\n    name: \"Ren Aoki\",\n    role: \"Broker\",\n    district: \"Meridian Heights\",\n    presence: \"online\",\n    channel: \"VX-560\",\n    look: 5,\n    standing: 37,\n    jobs: 2,\n    unread: 2,\n    history: [\n      { from: \"them\", time: \"Sun 16:20\", text: \"A buyer in the Heights wants Onyx Lumen optics, unopened. Do you still have the pair?\" },\n      { from: \"them\", time: \"Sun 16:45\", text: \"The offer stands at ¤ 950. It will not stand long.\" },\n    ],\n    start: \"optics\",\n    script: {\n      optics: [\n        { value: \"ren-counter\", label: \"¤ 1 200 and they're yours.\", answer: \"¤ 1 050. Final. Brokers have rent too.\", next: \"price\" },\n        { value: \"ren-sold\", label: \"Sold at ¤ 950.\", answer: \"A pleasure. A courier will find you by evening.\" },\n        { value: \"ren-keep\", label: \"I'm keeping them.\", answer: \"A shame. The offer becomes a memory at midnight.\" },\n      ],\n      price: [\n        { value: \"ren-done\", label: \"Done at ¤ 1 050.\", answer: \"Done. Credits on delivery, as always.\" },\n        { value: \"ren-no\", label: \"Then no deal.\", answer: \"Then we never spoke.\" },\n      ],\n    },\n    call: { connects: true, line: \"Line open. Ren is already talking to someone else as well.\" },\n  },\n]\n\n// Calls from before this session, so the log starts with something in it.\nconst earlierCalls = [\n  { id: \"call-a\", time: \"Sat 17:40\", actor: \"Dex Marlowe\", text: \"Connected. 02:10 on the line.\" },\n  { id: \"call-b\", time: \"Sun 09:02\", actor: \"Ilya Brandt\", text: \"No answer.\" },\n]\n\nconst creditsOf = (amount: number) => `¤ ${String(amount).replace(/\\B(?=(\\d{3})+(?!\\d))/g, \" \")}`\n\nexport { contacts, creditsOf, earlierCalls }\nexport type { Contact, Line, Offer, Presence, Reply }\n",
      "type": "registry:component",
      "target": "@components/blocks/comms/data.ts"
    },
    {
      "path": "registry/cyber/blocks/comms/portrait.tsx",
      "content": "\"use client\"\n\n// The picture on a contact's record, drawn rather than fetched: a stack of\n// ID plates seen at an angle, the front one carrying a faceted bust. Nobody\n// here has a face; they have a haircut, a band of optics and a serial strip.\n// The same contact always draws the same plate.\n\n// Six heads, as the outline of what's on top of the same bust: a bob, a crop\n// under bench goggles, a knot, a peaked cap, a hood and a long side part.\nconst tops = [\n  \"M36 82 38 50 56 38 74 50 76 82 70 62 56 54 42 62Z\",\n  \"M38 58 42 44 56 38 70 44 74 58 66 50 46 50Z\",\n  \"M38 60 40 46 56 40 72 46 74 60 64 50 48 50Z M48 40 50 29 62 29 64 40Z\",\n  \"M36 57 40 44 56 38 72 44 76 56 92 60 76 63H36Z\",\n  \"M28 106 34 48 56 28 78 48 84 106 73 70 56 45 39 70Z\",\n  \"M36 98 40 46 56 38 74 46 76 68 68 52 50 50 44 98Z\",\n]\n\n// A small deterministic stream of numbers from a string.\nfunction seeded(seed: string) {\n  let state = [...seed].reduce((sum, letter) => (sum * 31 + letter.charCodeAt(0)) >>> 0, 11)\n  return () => {\n    state = (state * 1664525 + 1013904223) >>> 0\n    return state / 4294967296\n  }\n}\n\n// One plate, 112 by 150, in its own coordinates.\nfunction Plate({ depth }: { depth: number }) {\n  return (\n    <path\n      d=\"M0 0H104l8 8V150H8l-8-8Z\"\n      fill={depth ? \"var(--cy-panel)\" : \"var(--cy-panel-2)\"}\n      stroke={depth ? \"var(--cy-line-deco)\" : \"var(--cy-line-ctl)\"}\n      strokeWidth=\"1\"\n    />\n  )\n}\n\nfunction Portrait({ look, seed }: { look: number; seed: string }) {\n  const next = seeded(seed)\n  const strip = Array.from({ length: 16 }, () => ({ wide: next() > 0.55, tall: 5 + Math.round(next() * 7) }))\n  const wear = Array.from({ length: 5 }, () => ({ y: 20 + Math.round(next() * 110), width: 10 + Math.round(next() * 40), x: Math.round(next() * 60) }))\n  return (\n    <svg data-comms-portrait=\"\" viewBox=\"0 0 280 240\" preserveAspectRatio=\"xMidYMid meet\" aria-hidden focusable=\"false\">\n      {/* The bed the plates sit on: a field of registration dots, a height\n          rule down one side. */}\n      {Array.from({ length: 9 }, (_, row) =>\n        Array.from({ length: 11 }, (_, column) => (\n          <rect key={`${row}-${column}`} x={19 + column * 24} y={19 + row * 24} width=\"2\" height=\"2\" fill=\"var(--cy-line-deco)\" />\n        )),\n      )}\n      {Array.from({ length: 17 }, (_, tick) => (\n        <path key={tick} d={`M8 ${24 + tick * 12}h${tick % 4 === 0 ? 10 : 5}`} stroke=\"var(--cy-line-ctl)\" strokeWidth=\"1\" />\n      ))}\n\n      {/* Three older plates behind, each a step back and up. */}\n      {[3, 2, 1].map((depth) => (\n        <g key={depth} transform={`translate(${84 + depth * 24} ${78 - depth * 13}) skewY(-11)`} opacity={1 - depth * 0.22}>\n          <Plate depth={depth} />\n          <path d=\"M0 18H112\" stroke=\"var(--cy-line-deco)\" strokeWidth=\"1\" />\n        </g>\n      ))}\n\n      {/* The current plate. */}\n      <g transform=\"translate(84 78) skewY(-11)\">\n        <Plate depth={0} />\n        <path d=\"M0 0H104l8 8v10H0Z\" fill=\"var(--cy-fill-active)\" />\n        <path d=\"M8 9h34M48 9h10\" stroke=\"var(--cy-ink-hi)\" strokeWidth=\"2\" />\n        {wear.map((line, index) => (\n          <path key={index} d={`M${4 + line.x} ${line.y}h${line.width}`} stroke=\"var(--cy-line-deco)\" strokeWidth=\"1\" />\n        ))}\n        {/* Shoulders, neck, head, then whatever is on top of it. */}\n        <path d=\"M10 132 16 114 44 103h24l28 11 6 18Z\" fill=\"var(--cy-fill-hover)\" stroke=\"var(--cy-line-ctl)\" strokeWidth=\"1\" />\n        <path d=\"M48 88h16v14l-8 6-8-6Z\" fill=\"var(--cy-fill-hover)\" stroke=\"var(--cy-line-ctl)\" strokeWidth=\"1\" />\n        <path d=\"M40 52 56 44 72 52 74 76 65 90H47L38 76Z\" fill=\"var(--cy-panel)\" stroke=\"var(--cy-ink)\" strokeWidth=\"1\" />\n        <path d=\"M56 108 49 97M56 108l7-11M44 103l12 9 12-9\" fill=\"none\" stroke=\"var(--cy-line-ctl)\" strokeWidth=\"1\" />\n        <path d={tops[look % tops.length]} fill=\"var(--cy-fill-active)\" stroke=\"var(--cy-accent)\" strokeWidth=\"1\" />\n        {/* The optics: one lit band across the eyes. The tech wears goggles. */}\n        <path d={look === 1 ? \"M39 58h34v10H39Z\" : \"M42 62h28v5H42Z\"} fill=\"var(--cy-signal)\" />\n        {look === 1 && <path d=\"M55 58v10\" stroke=\"var(--cy-on-solid)\" strokeWidth=\"2\" />}\n        {/* The serial strip along the foot. */}\n        {strip.map((bar, index) => (\n          <rect key={index} x={10 + index * 6} y={146 - bar.tall} width={bar.wide ? 4 : 2} height={bar.tall} fill=\"var(--cy-line-ctl)\" />\n        ))}\n      </g>\n\n      {/* A lock bracket around the head. */}\n      <path d=\"M114 96v-9l9-2M172 85l9-2v9M114 150v9l9-2M172 146l9-2v9\" fill=\"none\" stroke=\"var(--cy-signal)\" strokeWidth=\"1\" />\n    </svg>\n  )\n}\n\nexport { Portrait }\n",
      "type": "registry:component",
      "target": "@components/blocks/comms/portrait.tsx"
    }
  ],
  "categories": [
    "screen"
  ],
  "type": "registry:block"
}
