{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-ai-chat",
  "type": "registry:block",
  "title": "AI chat",
  "description": "An AI assistant home: a model switcher in the top bar, a greeting, and a composer with tools and attachments.",
  "dependencies": [
    "@remixicon/react@^4.9.0"
  ],
  "registryDependencies": [
    "https://wideset.co/r/app-shell.json",
    "https://wideset.co/r/avatar.json",
    "https://wideset.co/r/block-styles.json",
    "https://wideset.co/r/button.json",
    "https://wideset.co/r/chip.json",
    "https://wideset.co/r/dropdown-menu.json",
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/list-item.json",
    "https://wideset.co/r/segmented-control.json",
    "https://wideset.co/r/tooltip.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/ai-chat/brand-mark.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/ai-chat/brand-mark.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nconst TILE =\n  'M0 16C0 8.45753 0 4.68629 2.34315 2.34315C4.68629 0 8.45753 0 16 0C23.5425 0 27.3137 0 29.6569 2.34315C32 4.68629 32 8.45753 32 16C32 23.5425 32 27.3137 29.6569 29.6569C27.3137 32 23.5425 32 16 32C8.45753 32 4.68629 32 2.34315 29.6569C0 27.3137 0 23.5425 0 16Z';\nconst W =\n  'M21.6907 12C21.6907 12 19.618 17.322 19.5381 17.5183C19.4954 17.4215 17.1775 12 17.1775 12H15.0877C15.0877 12 12.7755 17.5183 12.7413 17.5916C12.7042 17.5157 10.2409 12 10.2409 12H8L11.7434 20H13.8047L16.1483 14.3403H16.1853C16.211 14.3953 18.5802 20 18.5802 20H20.7042C20.7042 20 23.9772 12.0707 24 12.0052L21.6935 12H21.6907Z';\n\n/**\n * The Wideset mark: a W on the inverse tile, Figma's workspace Thumbnail. It takes the size of\n * its place (32px in a sidebar or top bar, 36px in a larger switcher) and inverts in dark mode.\n * Decorative beside the product's name; give it a `label` when it stands alone.\n */\nexport function BrandMark({ className, label }: { className?: string; label?: string }) {\n  return (\n    <svg\n      viewBox=\"0 0 32 32\"\n      role={label ? 'img' : undefined}\n      aria-label={label}\n      aria-hidden={label ? undefined : true}\n      className={cn('size-ws-14 shrink-0', className)}\n    >\n      <path d={TILE} className=\"fill-(--ws-static-fill-inverse-background)\" />\n      <path d={W} className=\"fill-(--ws-static-text-inverse-strong)\" />\n    </svg>\n  );\n}\n"
    },
    {
      "path": "src/blocks/ai-chat/composer.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/ai-chat/composer.tsx",
      "content": "'use client';\n\nimport {\n  type RemixiconComponentType,\n  RiArrowRightLine,\n  RiArrowRightSLine,\n  RiAttachment2,\n  RiFirefoxFill,\n  RiGlobalLine,\n  RiImageLine,\n  RiMoreFill,\n  RiRecordCircleLine,\n  RiSearch2Line,\n  RiSettingsLine,\n  RiTelegramFill,\n  RiTimeLine,\n  RiYoutubeFill,\n} from '@remixicon/react';\nimport { Chip } from '@/components/ui/wideset/chip/Chip';\nimport { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';\nimport { type DropdownMenuItemProps } from '@/components/ui/wideset/dropdown/DropdownMenu.types';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { ListItem } from '@/components/ui/wideset/list-item/ListItem';\nimport { SegmentedControl } from '@/components/ui/wideset/segmented-control/SegmentedControl';\nimport { Tooltip } from '@/components/ui/wideset/tooltip/Tooltip';\nimport { type ComponentRef, forwardRef, useId, useState } from 'react';\n\nimport { ATTACHMENTS, type Source } from './data';\n\n/**\n * Figma's prompt composer: the message card (text, tools, send) on a grey tray that also holds\n * the attachments. Enter sends, Shift + Enter starts a new line.\n */\nexport function Composer({ onSend }: { onSend: (text: string) => void }) {\n  const [draft, setDraft] = useState('');\n  const [files, setFiles] = useState(ATTACHMENTS);\n  const attachmentsId = useId();\n\n  const send = (event: { preventDefault: () => void }) => {\n    event.preventDefault();\n    const text = draft.trim();\n    if (!text) return;\n    onSend(text);\n    setDraft('');\n  };\n\n  return (\n    <form\n      onSubmit={send}\n      className=\"bg-ws-static-alpha-subtle p-ws-3 gap-ws-5 flex flex-col rounded-(--ws-radius-600)\"\n    >\n      {/* The textarea draws no outline of its own: the card shows the focus ring around it. */}\n      <div className=\"bg-ws-static-overlay shadow-ws-low rounded-ws-container-xl p-ws-5 gap-ws-3 has-[textarea:focus-visible]:wds-focus-visible flex flex-col\">\n        <div className=\"p-ws-3\">\n          <textarea\n            aria-label=\"Message\"\n            placeholder=\"Ask whatever you want...\"\n            value={draft}\n            onChange={(event) => setDraft(event.target.value)}\n            onKeyDown={(event) => {\n              // Shift + Enter keeps the browser's new line; Enter that confirms an IME word is not a send.\n              if (event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing) {\n                send(event);\n              }\n            }}\n            className=\"typography-body-lg text-ws-static-strong placeholder:text-ws-static-subtle min-h-ws-23 max-h-ws-28 block field-sizing-content w-full resize-none bg-transparent outline-hidden\"\n          />\n        </div>\n        <div className=\"gap-ws-3 flex items-center\">\n          <div className=\"gap-ws-5 flex flex-1 items-center\">\n            <SegmentedControl size=\"sm\" defaultValue=\"web\" aria-label=\"Search mode\">\n              <SegmentedControl.Item value=\"web\" icon={RiGlobalLine} aria-label=\"Web\" />\n              <SegmentedControl.Item value=\"search\" icon={RiSearch2Line} aria-label=\"Search\" />\n            </SegmentedControl>\n            <MoreMenu />\n          </div>\n          <div className=\"gap-ws-9 flex min-w-0 items-center\">\n            <p className=\"typography-body-md text-ws-static-subtle truncate\">\n              Shift + Enter for new line, or Enter to send\n            </p>\n            <IconButton type=\"submit\" size=\"sm\" icon={RiArrowRightLine} aria-label=\"Send\" />\n          </div>\n        </div>\n      </div>\n\n      {files.length > 0 && (\n        <div role=\"group\" aria-labelledby={attachmentsId} className=\"py-ws-5\">\n          <p\n            id={attachmentsId}\n            className=\"typography-label-strong-sm text-ws-static-subtle px-ws-7 py-ws-3\"\n          >\n            Attachments\n          </p>\n          <div className=\"gap-ws-3 px-ws-7 flex flex-wrap\">\n            {files.map((file) => (\n              <Chip key={file.id} size=\"md\" variant=\"secondary\" style=\"border\">\n                <Chip.Icon icon={LOGO[file.source].icon} className={LOGO[file.source].className} />\n                <Chip.Label>{file.name}</Chip.Label>\n                <Chip.IconButton\n                  aria-label={`Remove ${file.name}`}\n                  onClick={() => setFiles((all) => all.filter((item) => item.id !== file.id))}\n                />\n              </Chip>\n            ))}\n          </div>\n        </div>\n      )}\n    </form>\n  );\n}\n\n/** Figma draws the apps' colour logos; these are their Remix glyphs in the nearest palette colour. */\nconst LOGO: Record<Source, { icon: RemixiconComponentType; className: string }> = {\n  youtube: { icon: RiYoutubeFill, className: 'text-(--ws-non-semantic-fill-red-strong)' },\n  telegram: { icon: RiTelegramFill, className: 'text-(--ws-non-semantic-fill-cyan-strong)' },\n  firefox: { icon: RiFirefoxFill, className: 'text-(--ws-non-semantic-fill-orange-strong)' },\n};\n\n/** The \"…\" tools menu; \"Deep research\" says how many runs are left in a tooltip. */\nfunction MoreMenu() {\n  return (\n    <DropdownMenu>\n      <DropdownMenu.Trigger asChild>\n        <IconButton\n          variant=\"secondary\"\n          preset=\"ghost\"\n          size=\"sm\"\n          icon={RiMoreFill}\n          aria-label=\"More tools\"\n        />\n      </DropdownMenu.Trigger>\n      <DropdownMenu.Content align=\"start\" className=\"ws-block-utility w-[14rem]\">\n        <MenuItem icon={RiAttachment2} label=\"Add files\" />\n        <DropdownMenu.Separator />\n        <MenuItem icon={RiImageLine} label=\"Take a screenshot\" />\n        <Tooltip size=\"sm\" arrow={false}>\n          <Tooltip.Trigger asChild>\n            <MenuItem icon={RiTimeLine} label=\"Deep research\" />\n          </Tooltip.Trigger>\n          <Tooltip.Content className=\"ws-block-utility\" side=\"right\" sideOffset={8}>\n            <Tooltip.Label>25 left</Tooltip.Label>\n          </Tooltip.Content>\n        </Tooltip>\n        <MenuItem icon={RiRecordCircleLine} label=\"Help center\" />\n        <DropdownMenu.Separator />\n        <MenuItem icon={RiSettingsLine} label=\"Settings\" />\n        <MenuItem icon={RiMoreFill} label=\"More\">\n          <ListItem.Suffix className=\"size-ws-12 justify-center\">\n            <RiArrowRightSLine aria-hidden className=\"size-ws-9\" />\n          </ListItem.Suffix>\n        </MenuItem>\n      </DropdownMenu.Content>\n    </DropdownMenu>\n  );\n}\n\ntype MenuItemProps = DropdownMenuItemProps & { icon: RemixiconComponentType; label: string };\n\n/** A menu row with Figma's 20px icon slot (a 16px subtle glyph); forwards its ref for a tooltip. */\nconst MenuItem = forwardRef<ComponentRef<typeof DropdownMenu.Item>, MenuItemProps>(\n  function MenuItem({ icon: Icon, label, children, ...props }, ref) {\n    return (\n      <DropdownMenu.Item ref={ref} {...props}>\n        <ListItem.Prefix className=\"size-ws-11 justify-center\">\n          <Icon aria-hidden className=\"size-ws-9 text-ws-static-subtle\" />\n        </ListItem.Prefix>\n        <ListItem.Content>\n          <ListItem.Label>{label}</ListItem.Label>\n        </ListItem.Content>\n        {children}\n      </DropdownMenu.Item>\n    );\n  },\n);\n"
    },
    {
      "path": "src/blocks/ai-chat/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/ai-chat/data.ts",
      "content": "export const USER = { firstName: 'Michał' };\n\nexport const MODELS = ['Wide AI 1.0', 'Wide AI 0.9'];\n\nexport const NAV = [\n  { label: 'Chat', href: '#chat' },\n  { label: 'History', href: '#history' },\n  { label: 'Models', href: '#models' },\n  { label: 'Pricing', href: '#pricing' },\n];\n\n/** The app each attachment came from; the composer draws its logo. */\nexport type Source = 'youtube' | 'telegram' | 'firefox';\n\n/** Files attached to the next message. */\nexport const ATTACHMENTS: { id: string; name: string; source: Source }[] = [\n  { id: 'file-1', name: 'video.mp4', source: 'youtube' },\n  { id: 'file-2', name: 'video.mp4', source: 'telegram' },\n  { id: 'file-3', name: 'video.mp4', source: 'firefox' },\n];\n"
    },
    {
      "path": "src/blocks/ai-chat/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/ai-chat/index.tsx",
      "content": "'use client';\n\nimport '@/styles/wideset-blocks.css';\n\nimport { AppShell } from '@/components/ui/wideset/app-shell/AppShell';\nimport { Avatar } from '@/components/ui/wideset/avatar/Avatar';\nimport { useState } from 'react';\n\nimport { Composer } from './composer';\nimport { USER } from './data';\nimport { TopBar } from './top-bar';\n\n/** AI chat, Flat direction: a top bar on the white page, the greeting and the composer centred. */\nexport default function AiChat() {\n  const [sent, setSent] = useState<{ id: number; text: string }[]>([]);\n\n  return (\n    <AppShell direction=\"flat\" className=\"ws-block-utility relative isolate overflow-hidden\">\n      {/* Figma's glow: a 321px circle, indigo to pink at 4%, blurred; it follows the column. */}\n      <div\n        aria-hidden\n        className=\"rounded-ws-control-full from-ws-non-semantic-indigo-strong to-ws-non-semantic-pink-strong pointer-events-none absolute top-[7.1875rem] left-[calc(50%-29rem)] size-[20.0625rem] bg-linear-to-b/srgb opacity-[0.04] blur-[150px]\"\n      />\n      <AppShell.Main>\n        <TopBar />\n        <div className=\"px-ws-12\">\n          <div className=\"gap-ws-12 pb-ws-12 mx-auto flex w-full max-w-[41.25rem] flex-col pt-[11rem]\">\n            {/* Figma places the composer 26px under the greeting: the column's 24 plus 2 here. */}\n            <div className=\"px-ws-5 pb-ws-2 flex flex-col items-start\">\n              <Avatar agent size=\"lg\" alt=\"\" />\n              {/* Figma's greeting is its own style, 32/32 at -0.2px, not a step of the title scale.\n                  Its gradient runs in sRGB; Tailwind's default (oklab) brightens the middle. */}\n              <h1 className=\"mt-ws-10 text-ws-800 leading-ws-800 tracking-ws-tight-50 font-ws-medium from-ws-non-semantic-brand-strong to-ws-non-semantic-pink-strong bg-linear-to-r/srgb bg-clip-text text-balance text-transparent\">\n                <span className=\"block\">Hello {USER.firstName},</span>\n                <span className=\"block\">What would you like to know?</span>\n              </h1>\n            </div>\n\n            {sent.length > 0 && (\n              <ol aria-label=\"Sent messages\" className=\"gap-ws-5 flex flex-col\">\n                {sent.map((message) => (\n                  <li key={message.id} className=\"flex justify-end\">\n                    <p className=\"bg-ws-dynamic-primary-alpha-strong-default text-ws-non-semantic-indigo-on-subtle rounded-ws-container-sm p-ws-5 typography-body-md max-w-[22.25rem] break-words whitespace-pre-wrap\">\n                      {message.text}\n                    </p>\n                  </li>\n                ))}\n              </ol>\n            )}\n\n            <Composer onSend={(text) => setSent((all) => [...all, { id: Date.now(), text }])} />\n          </div>\n        </div>\n      </AppShell.Main>\n    </AppShell>\n  );\n}\n"
    },
    {
      "path": "src/blocks/ai-chat/top-bar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/ai-chat/top-bar.tsx",
      "content": "'use client';\n\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { cn } from '@/lib/wideset/utils';\nimport { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';\nimport { ListItem } from '@/components/ui/wideset/list-item/ListItem';\nimport { type AnchorHTMLAttributes, useState } from 'react';\n\nimport { BrandMark } from './brand-mark';\nimport { MODELS, NAV } from './data';\n\n/** Figma \"Navigation\" on the white page, no line: brand and model, centred navigation, invite. */\nexport function TopBar() {\n  const [current, setCurrent] = useState(NAV[0].href);\n  const [model, setModel] = useState(MODELS[0]);\n\n  return (\n    <header className=\"h-ws-22 px-ws-12 grid shrink-0 grid-cols-[1fr_auto_1fr] items-center\">\n      <div className=\"gap-ws-12 flex items-center\">\n        <BrandMark label=\"Wide AI\" />\n        <DropdownMenu>\n          <DropdownMenu.Trigger asChild>\n            <Button variant=\"secondary\" preset=\"border\" size=\"sm\">\n              {model}\n            </Button>\n          </DropdownMenu.Trigger>\n          <DropdownMenu.Content className=\"ws-block-utility\" align=\"start\">\n            {MODELS.map((item) => (\n              <DropdownMenu.Item\n                key={item}\n                data-state={item === model ? 'checked' : 'unchecked'}\n                onSelect={() => setModel(item)}\n              >\n                <ListItem.Content>\n                  <ListItem.Label>{item}</ListItem.Label>\n                </ListItem.Content>\n              </DropdownMenu.Item>\n            ))}\n          </DropdownMenu.Content>\n        </DropdownMenu>\n      </div>\n\n      {/* Below md the bar keeps the brand, the model and the invite; the links do not fit. */}\n      <nav aria-label=\"Main\" className=\"gap-ws-3 hidden items-center md:flex\">\n        {NAV.map((item) => (\n          <NavItem\n            key={item.href}\n            href={item.href}\n            active={item.href === current}\n            onClick={() => setCurrent(item.href)}\n          >\n            {item.label}\n          </NavItem>\n        ))}\n      </nav>\n\n      <Button\n        variant=\"secondary\"\n        preset=\"border\"\n        size=\"sm\"\n        className=\"col-start-3 justify-self-end\"\n      >\n        Invite\n      </Button>\n    </header>\n  );\n}\n\ntype NavItemProps = AnchorHTMLAttributes<HTMLAnchorElement> & { active: boolean };\n\n/** Figma \".Assets/Top Navigation/Navigation Item\": a top-bar link, tinted while it is the page. */\nfunction NavItem({ active, className, children, ...props }: NavItemProps) {\n  return (\n    <a\n      aria-current={active ? 'page' : undefined}\n      className={cn(\n        'typography-label-strong-sm rounded-ws-control-lg px-ws-7 py-ws-3 min-h-ws-14 flex items-center',\n        'focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default',\n        active\n          ? 'bg-ws-static-alpha-base text-ws-dynamic-secondary-default'\n          : 'text-ws-static-base hover:bg-ws-dynamic-secondary-alpha-hover active:bg-ws-dynamic-secondary-alpha-pressed',\n        className,\n      )}\n      {...props}\n    >\n      {children}\n    </a>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
