{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chat-message",
  "type": "registry:item",
  "title": "Chat Message",
  "description": "One message: avatar, author, time, text (with @mentions and links picked out), the message it replies to, and reactions. `me` is the signed-in user's name: their messages, mentions of them and their reactions are marked.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "app"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/chat-message.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/chat-message.js",
      "content": "// Generated by zubra from chat-message.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { emit } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"chat-message\";\n\nexport default $define(tag, {\n  props: {\n    \"me\": { attribute: \"me\", default: \"\", required: false },\n    \"message\": { attribute: \"message\", default: {\"id\":\"\",\"author\":\"\",\"text\":\"\",\"time\":0,\"reactions\":{},\"replyTo\":null}, required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [\"reacttoggle\", \"reply\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (chat-message) to ([data-zb-slotted=\\\"chat-message\\\"]) {\\n  :scope { display: block; }\\n  article { position: relative; display: grid; grid-template-columns: 2.25rem 1fr; gap: 0 0.7rem; padding: 0.45rem 1.25rem; }\\n  article:hover { background: var(--accent, #f2f4f8); }\\n  article.mentioned { background: var(--mention-wash, color-mix(in oklab, var(--mention, #b07800) 20%, transparent)); box-shadow: inset 3px 0 var(--mention, #8a5a00); }\\n  .avatar { grid-row: span 3; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: calc(var(--radius, 0.625rem) * 0.96); color: white; font-weight: 800; font-size: 0.8rem; }\\n  header { display: flex; align-items: baseline; gap: 0.5rem; }\\n  .author { font-weight: 700; }\\n  .you { font-size: 0.7rem; font-weight: 700; color: var(--muted-foreground, #667085); }\\n  time { font-size: 0.75rem; color: var(--muted-foreground, #667085); }\\n  .quote { margin: 0.15rem 0 0.25rem; padding-left: 0.6rem; border-left: 3px solid var(--border, #d9dce3); color: var(--muted-foreground, #667085); font-size: 0.875rem; }\\n  p { margin: 0; white-space: pre-wrap; word-break: break-word; }\\n  .mention { padding: 0 0.15rem; border-radius: calc(var(--radius, 0.625rem) * 0.48); background: var(--mention-wash, color-mix(in oklab, var(--mention, #b07800) 20%, transparent)); color: inherit; font-weight: 600; }\\n  .mention.me { background: var(--mention, #8a5a00); color: white; }\\n  a { color: var(--primary, #2563eb); }\\n  .reactions { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }\\n  .reactions button { display: inline-flex; gap: 0.3rem; align-items: center; padding: 0.05rem 0.5rem; border: 1px solid var(--border, #d9dce3); border-radius: 999px; background: var(--card, #ffffff); color: inherit; font: inherit; font-size: 0.8125rem; cursor: pointer; }\\n  .reactions button[aria-pressed=true] { border-color: var(--primary, #2563eb); background: var(--mention-wash, color-mix(in oklab, var(--mention, #b07800) 20%, transparent)); }\\n  .tools { position: absolute; top: -0.9rem; right: 1rem; display: flex; opacity: 0; gap: 0.1rem; padding: 0.15rem; border: 1px solid var(--border, #d9dce3); border-radius: calc(var(--radius, 0.625rem) * 0.88); background: var(--card, #ffffff); box-shadow: 0 2px 8px #0002; }\\n  /* Transparent rather than hidden, so the keyboard can reach it; it shows on hover or focus. */\\n  article:hover .tools, .tools:focus-within { opacity: 1; }\\n  .tools button { border: 0; background: none; padding: 0.15rem 0.35rem; border-radius: calc(var(--radius, 0.625rem) * 0.56); cursor: pointer; font: inherit; color: inherit; }\\n  .tools button:hover { background: var(--accent, #f2f4f8); }\\n}\\n}\\n\",\n  template: \"\\n  <article>\\n    <span class=\\\"avatar\\\" aria-hidden=\\\"true\\\"></span>\\n    <header><span class=\\\"author\\\"></span><!--[--><!--]--><time></time></header>\\n    <!--[--><!--]-->\\n    <p><!--[--><!--]--></p>\\n    <!--[--><!--]-->\\n    <div class=\\\"tools\\\" role=\\\"toolbar\\\" aria-label=\\\"Message actions\\\">\\n      <!--[--><!--]-->\\n      <button type=\\\"button\\\" class=\\\"reply\\\">Reply</button>\\n    </div>\\n  </article>\\n\",\n  setup($p, $emit) {\n    const emit = $emit;\n                                       \n\n  const QUICK = [\"👍\", \"🎉\", \"❤️\", \"😂\"]\n  const mine = __zubraComputed(() => ($p.message.author === $p.me))\n  // Plain string methods, so the server renders them too (a pattern is the browser's alone): a\n  // tab or line break between the names counts as a space.\n  const initials = __zubraComputed(() => ($p.message.author.replaceAll(\"\\t\", \" \").replaceAll(\"\\n\", \" \").replaceAll(\"\\r\", \" \").trim().split(\" \").filter((part) => part !== \"\").map((part) => part[0]).join(\"\").slice(0, 2)))\n  const hue = __zubraComputed(() => ([...$p.message.author].reduce((sum, char) => sum + char.charCodeAt(0) * 47, 0) % 360))\n  const time = __zubraComputed(() => (new Date($p.message.time).toLocaleTimeString(\"en-US\", { hour: \"numeric\", minute: \"2-digit\" })))\n  const reactions = __zubraComputed(() => (Object.entries($p.message.reactions ?? {}).filter(([, people]) => people.length > 0)))\n  // Text as pieces, so mentions and links are elements, not HTML strings.\n  const pieces = __zubraComputed(() => ($p.message.text.split(/(@[A-Za-z]+|https?:\\/\\/\\S+)/g).filter(Boolean).map((text, index) => ({\n    index,\n    text,\n    kind: text.startsWith(\"@\") ? \"mention\" : /^https?:/.test(text) ? \"link\" : \"text\",\n    me: text.startsWith(\"@\") && $p.me.toLowerCase().startsWith(text.slice(1).toLowerCase()),\n  }))))\n    return [\n      { path: [0], toggle: \"mentioned\", value: () => (pieces.get().some((piece) => piece.me)) },\n      { path: [0], attribute: \"data-mine\", value: () => ($r(mine) ? \"true\" : \"false\") },\n      { path: [0, 0], style: \"background\", value: () => (`hsl(${hue.get()} 60% 28%)`) },\n      { path: [0, 0], text: () => $t($r(initials)) },\n      { path: [0, 1, 0], text: () => $t($p.message.author) },\n      { path: [0, 1, 1], when: () => $r(mine), blocks: [{ template: \"<span class=\\\"you\\\">YOU</span>\", parts: () => [] }, null] },\n      { path: [0, 1, 2], text: () => $t($r(time)) },\n      { path: [0, 2], when: () => $p.message.replyTo, blocks: [{ template: \"<div class=\\\"quote\\\"></div>\", parts: () => [{ path: [0], text: () => $t($p.message.replyTo?.author) + \": \" + $t($p.message.replyTo?.text) }] }, null] },\n      { path: [0, 3, 0], each: () => $r(pieces), key: (piece, $index) => $r(piece).index, block: { template: \"<!--[--><!--]-->\", parts: (piece, $index) => [{ path: [0], when: () => ($r(piece).kind === \"mention\"), blocks: [{ template: \"<span class=\\\"mention\\\"></span>\", parts: () => [{ path: [0], toggle: \"me\", value: () => $r(piece).me }, { path: [0], text: () => $t($r(piece).text) }] }, { template: \"<!--[--><!--]-->\", parts: () => [{ path: [0], when: () => ($r(piece).kind === \"link\"), blocks: [{ template: \"<a target=\\\"_blank\\\" rel=\\\"noopener\\\"></a>\", parts: () => [{ path: [0], attribute: \"href\", url: true, value: () => $r(piece).text }, { path: [0], text: () => $t($r(piece).text) }] }, { template: \"<!---->\", parts: () => [{ path: [0], anchor: () => $t($r(piece).text) }] }] }] }] }] } },\n      { path: [0, 4], when: () => ($r(reactions).length > 0), blocks: [{ template: \"<div class=\\\"reactions\\\">\\n      <!--[--><!--]-->\\n    </div>\", parts: () => [{ path: [0, 0], each: () => $r(reactions), key: (reaction, $index) => $r(reaction)[0], block: { template: \"\\n        <button type=\\\"button\\\"><!----><b></b></button>\\n      \", parts: (reaction, $index) => [{ path: [0], attribute: \"aria-pressed\", value: () => ($r(reaction)[1].includes($p.me) ? \"true\" : \"false\") }, { path: [0], attribute: \"title\", value: () => ($r(reaction)[1].join(\", \")) }, { path: [0], on: \"click\", handler: () => (() => emit('reacttoggle', $r(reaction)[0])) }, { path: [0, 0], anchor: () => $t($r(reaction)[0]) + \" \" }, { path: [0, 1], text: () => $t($r(reaction)[1].length) }] } }] }, null] },\n      { path: [0, 5, 0], each: () => $r(QUICK), key: (emoji, $index) => $r(emoji), block: { template: \"<button type=\\\"button\\\"></button>\", parts: (emoji, $index) => [{ path: [0], attribute: \"aria-label\", value: () => (`React ${$r(emoji)}`) }, { path: [0], on: \"click\", handler: () => (() => emit('reacttoggle', $r(emoji))) }, { path: [0], text: () => $t($r(emoji)) }] } },\n      { path: [0, 5, 1], on: \"click\", handler: () => (() => emit('reply')) },\n    ];\n  },\n});\n"
    }
  ]
}
