{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "review-17",
  "title": "Connect an app",
  "description": "A permission card for an agent that wants another app, with risk-labelled scopes you can switch off, and a handshake of a line, a travelling dot and two tiles that settle into Connected.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/company-mark.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/drawn-check.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/mesh-tile.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/switch.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-kept-height.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-timeouts.json",
    "https://ui.ndekocode.dev/r/utils.json",
    "https://ui.ndekocode.dev/r/words.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/review/review-17.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useEffect, useId, useImperativeHandle, useRef, useState } from 'react';\n\nimport {\n  useAutoplay,\n  type AutoplayStep,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\nimport {\n  seriesColorOf,\n  type RiskLevel,\n  type RunAgent,\n} from '@/registry/ndeko/lib/agent-run';\nimport {\n  hold,\n  PRESS_LEAD_MS,\n  pressedSolidOf,\n  spokenUnless,\n  usePress,\n} from '@/registry/ndeko/lib/demonstration';\nimport { LockIcon, RotateCcwIcon, XIcon } from '@/registry/ndeko/lib/icons';\nimport { fadePresence } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { countOf } from '@/registry/ndeko/lib/words';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Fold } from '@/registry/ndeko/ui/chat-motion';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\nimport { DrawnCheck } from '@/registry/ndeko/ui/drawn-check';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\nimport { Switch } from '@/registry/ndeko/ui/switch';\n\nimport { RiskBadge } from './_parts/risk-badge';\nimport { SettledLine } from './_parts/settled-line';\nimport { useContainerWidth } from './_parts/use-container-width';\nimport { useFocusHandOff } from './_parts/use-focus-hand-off';\n\nexport type AppScope = {\n  id: string;\n  title: string;\n  description: string;\n  risk: RiskLevel;\n  /** A person can switch it off. A scope that is not optional is always asked for. */\n  isOptional?: boolean;\n  /** What stops working while it is off. */\n  without?: string;\n};\n\nexport type ConnectPhase = 'asking' | 'connecting' | 'connected' | 'declined';\n\n/** The control a demonstration holds down: Connect, Disconnect or a scope by its id. */\nexport type ConnectAppPress = 'connect' | 'disconnect' | `scope-${string}`;\n\nexport type ConnectAppHandle = {\n  toggleScope: (scopeId: string) => void;\n  connect: () => void;\n  disconnect: () => void;\n};\n\nconst HANDSHAKE_MS = 1500;\n\nconst DOT_PX = 8;\n\nconst TILE = 'size-12 rounded-xl';\n\nfunction connectLabelsOf(count: number): Record<MorphState, string> {\n  return {\n    idle: `Connect with ${countOf(count, 'permission')}`,\n    busy: 'Connecting',\n    done: 'Connected',\n  };\n}\n\nfunction connectStateOf(phase: ConnectPhase): MorphState {\n  if (phase === 'connecting') {\n    return 'busy';\n  }\n  return 'idle';\n}\n\nfunction viewOf(phase: ConnectPhase) {\n  if (phase === 'connected') {\n    return 'connected';\n  }\n  if (phase === 'declined') {\n    return 'declined';\n  }\n  return 'asking';\n}\n\nfunction isLinkedPhase(phase: ConnectPhase) {\n  const isConnecting = phase === 'connecting';\n  const isConnected = phase === 'connected';\n  return isConnecting || isConnected;\n}\n\nfunction toggled(ids: string[], id: string) {\n  if (ids.includes(id)) {\n    return ids.filter((entry) => entry !== id);\n  }\n  return [...ids, id];\n}\n\nfunction lineScaleOf(isLinked: boolean) {\n  if (isLinked) {\n    return 'scale-x-100';\n  }\n  return 'scale-x-0';\n}\n\nfunction dashedToneOf(isLinked: boolean) {\n  if (isLinked) {\n    return 'opacity-0';\n  }\n  return 'opacity-100';\n}\n\nfunction dotTargetOf(phase: ConnectPhase, travel: number, isReduced: boolean) {\n  const isConnecting = phase === 'connecting';\n  if (isConnecting && !isReduced) {\n    return { x: [0, travel], opacity: [0, 1, 1, 0] };\n  }\n  if (isLinkedPhase(phase)) {\n    return { x: travel, opacity: 0 };\n  }\n  return { x: 0, opacity: 0 };\n}\n\nfunction dotTransitionOf(phase: ConnectPhase) {\n  if (phase === 'connecting') {\n    return {\n      duration: 0.8,\n      delay: 0.2,\n      times: [0, 0.12, 0.85, 1],\n      ease: 'easeInOut' as const,\n    };\n  }\n  return { duration: 0 };\n}\n\nfunction settleTargetOf(phase: ConnectPhase, isReduced: boolean) {\n  const isConnecting = phase === 'connecting';\n  if (isConnecting && !isReduced) {\n    return { scale: [1, 1.06, 1] };\n  }\n  return { scale: 1 };\n}\n\nfunction settleTransitionOf(phase: ConnectPhase) {\n  if (phase === 'connecting') {\n    return { duration: 0.4, delay: 1 };\n  }\n  return { duration: 0 };\n}\n\nfunction rowPressedOf(isPressed: boolean) {\n  if (isPressed) {\n    return 'scale-[0.985] bg-foreground/[0.06]';\n  }\n  return undefined;\n}\n\nfunction offToneOf(isOn: boolean) {\n  if (isOn) {\n    return undefined;\n  }\n  return 'opacity-60';\n}\n\ntype TileSideProps = {\n  name: string;\n  phase: ConnectPhase;\n  children: React.ReactNode;\n};\n\nfunction TileSide({ name, phase, children }: TileSideProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const target = settleTargetOf(phase, shouldReduceMotion);\n  const transition = settleTransitionOf(phase);\n\n  return (\n    <span className='flex w-20 flex-col items-center gap-1.5 @sm:w-28'>\n      <motion.span\n        animate={target}\n        transition={transition}\n        className='inline-flex'\n      >\n        {children}\n      </motion.span>\n      <span className='text-muted-foreground max-w-full truncate text-xs'>\n        {name}\n      </span>\n    </span>\n  );\n}\n\ntype HandshakeProps = {\n  agent: Pick<RunAgent, 'name' | 'series'>;\n  appName: string;\n  phase: ConnectPhase;\n};\n\nfunction Handshake({ agent, appName, phase }: HandshakeProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const [line, setLine] = useState<HTMLSpanElement | null>(null);\n  const width = useContainerWidth(line, 96);\n  const travel = Math.max(0, width - DOT_PX);\n  const isLinked = isLinkedPhase(phase);\n  const dotTarget = dotTargetOf(phase, travel, shouldReduceMotion);\n  const dotTransition = dotTransitionOf(phase);\n\n  return (\n    <div aria-hidden='true' className='flex items-start justify-center'>\n      <TileSide name={agent.name} phase={phase}>\n        <MeshTile\n          seed={agent.name}\n          color={seriesColorOf(agent.series)}\n          className={TILE}\n        />\n      </TileSide>\n      <span\n        ref={setLine}\n        className='relative mt-6 h-px max-w-40 min-w-12 flex-1'\n      >\n        <span\n          className={cn(\n            'border-foreground/25 absolute inset-x-0 top-0 border-t border-dashed transition-opacity duration-300',\n            dashedToneOf(isLinked)\n          )}\n        />\n        <span\n          className={cn(\n            'bg-primary absolute inset-x-0 top-0 h-px origin-left transition-[scale] duration-500 ease-(--ease-out-strong)',\n            lineScaleOf(isLinked)\n          )}\n        />\n        <motion.span\n          initial={false}\n          animate={dotTarget}\n          transition={dotTransition}\n          className='bg-primary absolute start-0 top-1/2 size-2 -translate-y-1/2 rounded-full'\n        />\n      </span>\n      <TileSide name={appName} phase={phase}>\n        <CompanyMark seed={appName} className={TILE} />\n      </TileSide>\n    </div>\n  );\n}\n\ntype ScopeRowProps = {\n  scope: AppScope;\n  isOn: boolean;\n  isLocked: boolean;\n  isPressed: boolean;\n  onToggle: (scopeId: string) => void;\n};\n\nfunction ScopeRow({\n  scope,\n  isOn,\n  isLocked,\n  isPressed,\n  onToggle,\n}: ScopeRowProps) {\n  const isOptional = scope.isOptional === true;\n  const hasWithout = scope.without !== undefined;\n  const showsWithout = hasWithout && !isOn;\n\n  return (\n    <li\n      className={cn(\n        'flex flex-col rounded-md px-2 py-2 transition-[background-color,scale] duration-150 ease-(--ease-out-strong)',\n        rowPressedOf(isPressed)\n      )}\n    >\n      <div className='flex items-start gap-3'>\n        <span className='mt-0.5 flex h-5 w-8 shrink-0 items-center justify-center'>\n          {isOptional && (\n            <Switch\n              checked={isOn}\n              disabled={isLocked}\n              aria-label={`Allow ${scope.title}`}\n              onCheckedChange={() => onToggle(scope.id)}\n            />\n          )}\n          {!isOptional && (\n            <>\n              <LockIcon\n                aria-hidden='true'\n                className='text-muted-foreground size-3.5'\n              />\n              <span className='sr-only'>Required</span>\n            </>\n          )}\n        </span>\n        <span\n          className={cn(\n            'flex min-w-0 flex-1 flex-col gap-0.5 transition-opacity duration-150',\n            offToneOf(isOn)\n          )}\n        >\n          <span className='text-[13px] font-medium'>{scope.title}</span>\n          <span className='text-muted-foreground text-xs leading-5'>\n            {scope.description}\n          </span>\n          <RiskBadge risk={scope.risk} className='mt-1 @sm:hidden' />\n        </span>\n        <RiskBadge\n          risk={scope.risk}\n          className='mt-0.5 hidden @sm:inline-flex'\n        />\n      </div>\n      <Fold open={showsWithout}>\n        <p className='text-muted-foreground ps-11 pt-1 text-xs leading-5'>\n          Without it: {scope.without}\n        </p>\n      </Fold>\n    </li>\n  );\n}\n\nexport type ConnectAppProps = {\n  agent: Pick<RunAgent, 'name' | 'series'>;\n  appName: string;\n  scopes: AppScope[];\n  /** The scopes switched on when the card first shows. All of them by default. */\n  defaultGrantedIds?: string[];\n  defaultPhase?: 'asking' | 'connected';\n  onConnect?: (grantedIds: string[]) => void;\n  onDisconnect?: () => void;\n  onDecline?: () => void;\n  /** Putting the card back to its first state: change this number. */\n  resetToken?: number;\n  handleRef?: React.Ref<ConnectAppHandle>;\n  pressed?: ConnectAppPress | null;\n  /** A demonstration is not read aloud. */\n  isDemonstrating?: boolean;\n  className?: string;\n};\n\nexport function ConnectApp({\n  agent,\n  appName,\n  scopes,\n  defaultGrantedIds,\n  defaultPhase = 'asking',\n  onConnect,\n  onDisconnect,\n  onDecline,\n  resetToken = 0,\n  handleRef,\n  pressed = null,\n  isDemonstrating = false,\n  className,\n}: ConnectAppProps) {\n  const allIds = scopes.map((scope) => scope.id);\n  const firstIds = defaultGrantedIds ?? allIds;\n  const [grantedIds, setGrantedIds] = useState(firstIds);\n  const [phase, setPhase] = useState<ConnectPhase>(defaultPhase);\n  const [notice, setNotice] = useState('');\n  const [seenToken, setSeenToken] = useState(resetToken);\n  const titleId = useId();\n  const { schedule, clearAll } = useTimeouts();\n  const fade = fadePresence();\n  const view = viewOf(phase);\n  const { rootRef, markIfFocusInside } = useFocusHandOff(view);\n  const requiredIds = scopes\n    .filter((scope) => scope.isOptional !== true)\n    .map((scope) => scope.id);\n  const activeIds = allIds.filter((id) => {\n    const isRequired = requiredIds.includes(id);\n    const isGranted = grantedIds.includes(id);\n    return isRequired || isGranted;\n  });\n  const isLocked = phase === 'connecting';\n  const labels = connectLabelsOf(activeIds.length);\n\n  useEffect(() => {\n    clearAll();\n  }, [resetToken, clearAll]);\n\n  if (seenToken !== resetToken) {\n    setSeenToken(resetToken);\n    setGrantedIds(firstIds);\n    setPhase(defaultPhase);\n  }\n\n  function toggleScope(scopeId: string) {\n    const scope = scopes.find((entry) => entry.id === scopeId);\n    const canToggle = scope?.isOptional === true && !isLocked;\n    if (!canToggle) {\n      return;\n    }\n    setGrantedIds((current) => toggled(current, scopeId));\n  }\n\n  function connect() {\n    if (phase !== 'asking') {\n      return;\n    }\n    const granted = activeIds;\n    setPhase('connecting');\n    setNotice(`Connecting to ${appName}`);\n    schedule(() => {\n      markIfFocusInside();\n      setPhase('connected');\n      setNotice(\n        `Connected to ${appName} with ${countOf(granted.length, 'scope')}`\n      );\n      onConnect?.(granted);\n    }, HANDSHAKE_MS);\n  }\n\n  function disconnect() {\n    markIfFocusInside();\n    setPhase('asking');\n    setNotice(`Disconnected from ${appName}`);\n    onDisconnect?.();\n  }\n\n  function decline() {\n    markIfFocusInside();\n    setPhase('declined');\n    setNotice(`${appName} was not connected`);\n    onDecline?.();\n  }\n\n  function reconsider() {\n    markIfFocusInside();\n    setPhase('asking');\n  }\n\n  useImperativeHandle(handleRef, () => ({ toggleScope, connect, disconnect }));\n\n  return (\n    <div\n      ref={rootRef}\n      className={cn(\n        'surface-raised @container overflow-hidden rounded-xl',\n        className\n      )}\n    >\n      <div className='px-4 pt-5'>\n        <Handshake agent={agent} appName={appName} phase={phase} />\n      </div>\n      <AnimatedSize>\n        <AnimatePresence initial={false} mode='popLayout'>\n          <motion.div key={view} {...fade}>\n            {view === 'connected' && (\n              <SettledLine\n                icon={<DrawnCheck tone='success' entrance='draw' />}\n                actionLabel='Disconnect'\n                actionIcon={<XIcon />}\n                onAction={disconnect}\n                isActionPressed={pressed === 'disconnect'}\n                className='pt-3'\n              >\n                <span className='font-medium'>\n                  Connected, {countOf(activeIds.length, 'scope')}\n                </span>\n                <span className='text-muted-foreground'>\n                  {' '}\n                  for {agent.name} in {appName}\n                </span>\n              </SettledLine>\n            )}\n            {view === 'declined' && (\n              <SettledLine\n                icon={<XIcon className='text-muted-foreground size-4' />}\n                actionLabel='Reconsider'\n                actionIcon={<RotateCcwIcon />}\n                onAction={reconsider}\n                className='pt-3'\n              >\n                <span className='text-muted-foreground'>\n                  Not connected, {agent.name} will not use {appName}\n                </span>\n              </SettledLine>\n            )}\n            {view === 'asking' && (\n              <div\n                role='group'\n                aria-labelledby={titleId}\n                className='flex flex-col gap-3 p-4'\n              >\n                <div className='flex flex-col gap-1 text-center'>\n                  <p id={titleId} className='text-sm font-medium text-balance'>\n                    {agent.name} wants to connect to {appName}\n                  </p>\n                  <p className='text-muted-foreground text-xs'>\n                    Switch off what it should not do\n                  </p>\n                </div>\n                <ul\n                  aria-label='Permissions asked'\n                  className='bg-foreground/[0.04] flex flex-col gap-0.5 rounded-lg p-1'\n                >\n                  {scopes.map((scope) => (\n                    <ScopeRow\n                      key={scope.id}\n                      scope={scope}\n                      isOn={activeIds.includes(scope.id)}\n                      isLocked={isLocked}\n                      isPressed={pressed === `scope-${scope.id}`}\n                      onToggle={toggleScope}\n                    />\n                  ))}\n                </ul>\n                <div className='flex flex-wrap items-center gap-2'>\n                  <MorphButton\n                    type='button'\n                    size='sm'\n                    state={connectStateOf(phase)}\n                    labels={labels}\n                    onClick={connect}\n                    className={pressedSolidOf(pressed === 'connect')}\n                  />\n                  <Button\n                    type='button'\n                    size='sm'\n                    variant='outline'\n                    disabled={isLocked}\n                    onClick={decline}\n                  >\n                    Not now\n                  </Button>\n                </div>\n              </div>\n            )}\n          </motion.div>\n        </AnimatePresence>\n      </AnimatedSize>\n      <LiveRegion message={spokenUnless(isDemonstrating, notice)} />\n    </div>\n  );\n}\n\nconst REVIEWER: Pick<RunAgent, 'name' | 'series'> = {\n  name: 'Reviewer',\n  series: 4,\n};\n\nconst SCOPES: AppScope[] = [\n  {\n    id: 'invoices',\n    title: 'Read invoices',\n    description: 'See invoice lists, amounts and due dates',\n    risk: 'low',\n  },\n  {\n    id: 'contacts',\n    title: 'Read customer contacts',\n    description: 'See names, emails and phone numbers of customers',\n    risk: 'medium',\n    isOptional: true,\n    without: 'it cannot tell who an invoice belongs to',\n  },\n  {\n    id: 'drafts',\n    title: 'Create draft invoices',\n    description: 'Write drafts that stay private until you send them',\n    risk: 'medium',\n    isOptional: true,\n    without: 'it can only read, so it cannot prepare a draft',\n  },\n  {\n    id: 'send',\n    title: 'Send invoices to customers',\n    description: 'Email an invoice to a customer on your behalf',\n    risk: 'high',\n    isOptional: true,\n    without: 'a draft waits for you to send it yourself',\n  },\n];\n\nconst RESTING_IDS = ['contacts', 'drafts'];\n\nfunction restingIdsOf(isResting: boolean) {\n  if (isResting) {\n    return RESTING_IDS;\n  }\n  return undefined;\n}\n\nfunction restingPhaseOf(isResting: boolean) {\n  if (isResting) {\n    return 'connected';\n  }\n  return 'asking';\n}\n\nfunction ConnectDemo({ isResting }: { isResting: boolean }) {\n  const [round, setRound] = useState(0);\n  const card = useRef<ConnectAppHandle>(null);\n  const { pressed, press } = usePress<ConnectAppPress>();\n\n  function resetDemo() {\n    setRound((current) => current + 1);\n  }\n\n  const steps: AutoplayStep[] = [\n    { after: 1600, run: () => press('scope-send') },\n    { after: PRESS_LEAD_MS, run: () => card.current?.toggleScope('send') },\n    { after: 1900, run: () => press('connect') },\n    { after: PRESS_LEAD_MS, run: () => card.current?.connect() },\n    { after: 4200, run: hold },\n  ];\n  const { ref, isAutoplaying } = useAutoplay(steps, {\n    loopAfter: 1800,\n    onReset: resetDemo,\n  });\n\n  useKeptHeight(ref);\n\n  return (\n    <div ref={ref} className='flex min-h-[31rem] w-full max-w-[30rem] flex-col'>\n      <ConnectApp\n        agent={REVIEWER}\n        appName='Kasai Ledger'\n        scopes={SCOPES}\n        defaultGrantedIds={restingIdsOf(isResting)}\n        defaultPhase={restingPhaseOf(isResting)}\n        resetToken={round}\n        handleRef={card}\n        pressed={pressed}\n        isDemonstrating={isAutoplaying}\n      />\n    </div>\n  );\n}\n\nexport default function Review17() {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const restKey = String(shouldReduceMotion);\n\n  return <ConnectDemo key={restKey} isResting={shouldReduceMotion} />;\n}\n",
      "type": "registry:component",
      "target": "components/review/review-17.tsx"
    },
    {
      "path": "registry/ndeko/components/review/_parts/risk-badge.tsx",
      "content": "import type { RiskLevel } from '@/registry/ndeko/lib/agent-run';\nimport {\n  CircleAlertIcon,\n  ShieldCheckIcon,\n  TriangleAlertIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { Badge } from '@/registry/ndeko/ui/badge';\n\ntype RiskLook = {\n  label: string;\n  variant: 'success' | 'warning' | 'destructive';\n  icon: React.ReactNode;\n};\n\nconst RISK_LOOK: Record<RiskLevel, RiskLook> = {\n  low: { label: 'Low risk', variant: 'success', icon: <ShieldCheckIcon /> },\n  medium: {\n    label: 'Medium risk',\n    variant: 'warning',\n    icon: <TriangleAlertIcon />,\n  },\n  high: {\n    label: 'High risk',\n    variant: 'destructive',\n    icon: <CircleAlertIcon />,\n  },\n};\n\ntype RiskBadgeProps = {\n  risk: RiskLevel;\n  className?: string;\n};\n\n/** The level of a risk as a word and a mark, so colour never carries it alone. */\nexport function RiskBadge({ risk, className }: RiskBadgeProps) {\n  const look = RISK_LOOK[risk];\n\n  return (\n    <Badge variant={look.variant} className={className}>\n      {look.icon}\n      {look.label}\n    </Badge>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/review/_parts/risk-badge.tsx"
    },
    {
      "path": "registry/ndeko/components/review/_parts/settled-line.tsx",
      "content": "'use client';\n\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\n\ntype SettledLineProps = {\n  icon: React.ReactNode;\n  actionLabel: string;\n  actionIcon?: React.ReactNode;\n  onAction: () => void;\n  /** Shows the action held down, for a demonstration that presses it. */\n  isActionPressed?: boolean;\n  children: React.ReactNode;\n  className?: string;\n};\n\n/** What a card becomes once it is settled: one line that says what happened, and the way back. */\nexport function SettledLine({\n  icon,\n  actionLabel,\n  actionIcon,\n  onAction,\n  isActionPressed = false,\n  children,\n  className,\n}: SettledLineProps) {\n  return (\n    <div\n      className={cn(\n        'flex items-start gap-2.5 py-2.5 ps-3.5 pe-2.5 text-[13px]',\n        className\n      )}\n    >\n      <span className='mt-1 flex shrink-0 items-center'>{icon}</span>\n      <p className='min-w-0 flex-1 py-1 leading-5'>{children}</p>\n      <Button\n        type='button'\n        variant='ghost'\n        size='sm'\n        data-hand-off=''\n        onClick={onAction}\n        className={cn(\n          'text-muted-foreground shrink-0',\n          pressedQuietOf(isActionPressed)\n        )}\n      >\n        {actionIcon}\n        {actionLabel}\n      </Button>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/review/_parts/settled-line.tsx"
    },
    {
      "path": "registry/ndeko/components/review/_parts/use-container-width.ts",
      "content": "'use client';\n\nimport { useLayoutEffect, useState } from 'react';\n\n/**\n * The width of an element as it resizes. A piece in a narrow column of a wide window switches layout\n * by the room it has, which the viewport cannot tell.\n */\nexport function useContainerWidth(\n  target: HTMLElement | null,\n  fallback: number\n) {\n  const [width, setWidth] = useState(fallback);\n\n  useLayoutEffect(() => {\n    if (!target) {\n      return;\n    }\n    const observer = new ResizeObserver(([entry]) => {\n      const box = entry.contentBoxSize[0];\n      setWidth(box.inlineSize);\n    });\n    observer.observe(target);\n    return () => observer.disconnect();\n  }, [target]);\n\n  return width;\n}\n",
      "type": "registry:component",
      "target": "components/review/_parts/use-container-width.ts"
    },
    {
      "path": "registry/ndeko/components/review/_parts/use-focus-hand-off.ts",
      "content": "'use client';\n\nimport { useCallback, useEffect, useRef } from 'react';\n\n/**\n * When a card turns into another view, the control a person just used is gone and focus would fall\n * to the page. If focus was inside the card, it goes to the last element marked `data-hand-off`\n * once the new view is in place; a demonstration never had focus there, so it never moves it.\n */\nexport function useFocusHandOff(phase: string) {\n  const rootRef = useRef<HTMLDivElement>(null);\n  const isPending = useRef(false);\n\n  const markIfFocusInside = useCallback(() => {\n    const root = rootRef.current;\n    if (!root) {\n      return;\n    }\n    isPending.current = root.contains(document.activeElement);\n  }, []);\n\n  useEffect(() => {\n    if (!isPending.current) {\n      return;\n    }\n    isPending.current = false;\n    const root = rootRef.current;\n    if (!root) {\n      return;\n    }\n    const targets = root.querySelectorAll<HTMLElement>('[data-hand-off]');\n    const target = targets[targets.length - 1];\n    target?.focus();\n  }, [phase]);\n\n  return { rootRef, markIfFocusInside };\n}\n",
      "type": "registry:component",
      "target": "components/review/_parts/use-focus-hand-off.ts"
    }
  ],
  "categories": [
    "components",
    "review"
  ],
  "type": "registry:component"
}