{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "settings-04",
  "title": "API keys",
  "description": "Live and test keys whose spend this month rolls as calls come in, with idle keys flagged; Create key unfolds a form in place and shows the secret once with Copy, a row opens to its scopes, its creator and two weeks of requests, and Revoke fills across a two-second hold before the row folds away.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/avatar.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/chip.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.json",
    "https://ui.ndekocode.dev/r/label.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/segments.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.json",
    "https://ui.ndekocode.dev/r/use-timeouts.json",
    "https://ui.ndekocode.dev/r/utils.json",
    "https://ui.ndekocode.dev/r/wash.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/settings/settings-04/index.tsx",
      "content": "'use client';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\nimport {\n  pressedSolidOf,\n  spokenUnless,\n} from '@/registry/ndeko/lib/demonstration';\nimport { KeyIcon, PlusIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport { CreateSlot } from './create-key';\nimport { IDLE_AFTER_DAYS, WORKSPACE_NAME, type ApiKey } from './data';\nimport { KeyList, MONEY_FORMAT } from './key-rows';\nimport {\n  CREATE_MS,\n  INITIAL,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  SCRIPT,\n} from './session';\nimport { SettingsFrame, SettingsSection, SURFACE } from './settings-frame';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nfunction totalSpendOf(keys: ApiKey[]) {\n  let cents = 0;\n  for (const key of keys) {\n    cents += key.spendCents;\n  }\n  return cents / 100;\n}\n\nfunction keysWordOf(count: number) {\n  if (count === 1) {\n    return 'key';\n  }\n  return 'keys';\n}\n\n/** The fill of a held Revoke belongs to the demonstration only while it plays. */\nfunction demoHoldOf(isAutoplaying: boolean, holdingId: string | null) {\n  if (isAutoplaying) {\n    return holdingId;\n  }\n  return null;\n}\n\n/** A revoked row takes its button with it: the focus goes to the row after it, or before it. */\nfunction focusAfterRevokeOf(keys: ApiKey[], id: string) {\n  const index = keys.findIndex((key) => key.id === id);\n  const neighbour = keys[index + 1] ?? keys[index - 1];\n  if (neighbour) {\n    return `[data-row-toggle=\"${neighbour.id}\"]`;\n  }\n  return '[data-create-key]';\n}\n\nfunction EmptyKeys() {\n  return (\n    <div className='flex flex-col items-center gap-2 px-4 py-10 text-center'>\n      <span className='keycap-3d text-muted-foreground flex size-10 items-center justify-center rounded-lg'>\n        <KeyIcon className='size-5' />\n      </span>\n      <p className='text-[13px] font-medium'>No API keys</p>\n      <p className='text-muted-foreground max-w-xs text-xs text-pretty'>\n        Create a key to call the Tidewell API from your own servers\n      </p>\n    </div>\n  );\n}\n\nexport default function Settings04() {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const { schedule, clearAll } = useTimeouts();\n  const count = state.keys.length;\n  const isEmpty = count === 0;\n  const isSlotClosed = state.status === 'closed';\n  const showsEmpty = isEmpty && isSlotClosed;\n  const totalSpend = totalSpendOf(state.keys);\n  const demoHoldingId = demoHoldOf(isAutoplaying, state.holdingId);\n  const message = spokenUnless(isAutoplaying, state.spoken);\n  const canReplay = isFinished && !isAutoplaying;\n\n  function focusLater(selector: string) {\n    requestAnimationFrame(() => {\n      const target = ref.current?.querySelector<HTMLElement>(selector);\n      target?.focus();\n    });\n  }\n\n  function openCreate() {\n    act({ type: 'createOpened' });\n    focusLater('[data-key-name]');\n  }\n\n  function closeCreate() {\n    const isEditing = state.status === 'editing';\n    if (!isEditing) {\n      return;\n    }\n    act({ type: 'createClosed' });\n    focusLater('[data-create-key]');\n  }\n\n  function revealCreated() {\n    act({ type: 'keyCreated' });\n    focusLater('[data-secret-copy]');\n  }\n\n  function submit() {\n    const after = reducer(state, { type: 'createSubmitted' });\n    act({ type: 'createSubmitted' });\n    if (after.status !== 'creating') {\n      focusLater('[data-key-name]');\n      return;\n    }\n    schedule(revealCreated, CREATE_MS);\n  }\n\n  async function copy() {\n    const value = state.secret?.value;\n    if (!value) {\n      return;\n    }\n    try {\n      await navigator.clipboard.writeText(value);\n    } catch {\n      act({ type: 'copyFailed' });\n      return;\n    }\n    act({ type: 'secretCopied' });\n  }\n\n  function hide() {\n    const keyId = state.secret?.keyId;\n    act({ type: 'secretHidden' });\n    if (keyId) {\n      focusLater(`[data-row-toggle=\"${keyId}\"]`);\n    }\n  }\n\n  function toggle(id: string) {\n    act({ type: 'rowToggled', id });\n  }\n\n  function revoke(id: string) {\n    const target = focusAfterRevokeOf(state.keys, id);\n    act({ type: 'revoked', id });\n    focusLater(target);\n  }\n\n  /** A key on its way belongs to the round it was asked for in. */\n  function replay() {\n    clearAll();\n    restart();\n  }\n\n  const createButton = (\n    <Button\n      type='button'\n      data-create-key\n      disabled={!isSlotClosed}\n      focusableWhenDisabled\n      onClick={openCreate}\n      className={pressedSolidOf(pressed === 'create')}\n    >\n      <PlusIcon />\n      Create key\n    </Button>\n  );\n\n  const replayButton = (\n    <ReplayButton isShown={canReplay} onReplay={replay} label='Replay' />\n  );\n\n  return (\n    <ClockGate isActive={isInView}>\n      <SettingsFrame\n        ref={ref}\n        title='API keys'\n        line={`Keys let your own servers call the Tidewell API for ${WORKSPACE_NAME}. Each one reaches only what its access allows.`}\n        aside={replayButton}\n      >\n        <SettingsSection\n          title='Keys'\n          line={\n            <span className='flex flex-wrap items-center gap-x-1.5 gap-y-1 tabular-nums'>\n              <span>\n                <MotionNumber value={count} /> {keysWordOf(count)}\n              </span>\n              <span aria-hidden='true'>·</span>\n              <span>\n                <MotionNumber value={totalSpend} format={MONEY_FORMAT} /> this\n                month\n              </span>\n              <Badge variant='secondary'>Illustrative</Badge>\n            </span>\n          }\n          action={createButton}\n        >\n          <div className={cn(SURFACE, 'overflow-hidden')}>\n            <CreateSlot\n              state={state}\n              pressed={pressed}\n              onAction={act}\n              onSubmit={submit}\n              onClose={closeCreate}\n              onCopy={copy}\n              onHide={hide}\n            />\n            <KeyList\n              keys={state.keys}\n              openId={state.openId}\n              pressed={pressed}\n              demoHoldingId={demoHoldingId}\n              onToggle={toggle}\n              onRevoke={revoke}\n            />\n            {showsEmpty && <EmptyKeys />}\n          </div>\n        </SettingsSection>\n        <p className='text-muted-foreground text-xs text-pretty'>\n          {`Keys that make no request for ${IDLE_AFTER_DAYS} days are flagged as idle. Revoking asks for a two-second hold, so it never happens by accident.`}\n        </p>\n        <LiveRegion message={message} />\n      </SettingsFrame>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/settings-04/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/settings/settings-04/create-key.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId } from 'react';\n\nimport {\n  pressedQuietOf,\n  pressedSolidOf,\n} from '@/registry/ndeko/lib/demonstration';\nimport {\n  CheckIcon,\n  CopyIcon,\n  TriangleAlertIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { fadePresence } from '@/registry/ndeko/lib/motion-presets';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport { Label } from '@/registry/ndeko/ui/label';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\nimport { Segments, type Segment } from '@/registry/ndeko/ui/segments';\nimport { Wash } from '@/registry/ndeko/ui/wash';\n\nimport {\n  ACCESS_LABEL,\n  ENVIRONMENT_LABEL,\n  NAME_MAX_LENGTH,\n  type Access,\n  type Environment,\n} from './data';\nimport type { CreateStatus, KeysAction, KeysState, Secret } from './session';\nimport { describedByOf, ErrorLine } from './settings-frame';\n\nconst ENVIRONMENTS: Segment<Environment>[] = [\n  { value: 'live', label: ENVIRONMENT_LABEL.live },\n  { value: 'test', label: ENVIRONMENT_LABEL.test },\n];\n\nconst ACCESSES: Segment<Access>[] = [\n  { value: 'full', label: ACCESS_LABEL.full },\n  { value: 'read', label: ACCESS_LABEL.read },\n];\n\nconst ENVIRONMENT_LINE: Record<Environment, string> = {\n  live: 'Reaches your real data and is billed',\n  test: 'Reaches a sandbox and costs nothing',\n};\n\nconst CREATE_LABELS: Record<MorphState, string> = {\n  idle: 'Create key',\n  busy: 'Creating',\n  done: 'Created',\n};\n\nfunction morphOf(status: CreateStatus): MorphState {\n  if (status === 'creating') {\n    return 'busy';\n  }\n  return 'idle';\n}\n\nfunction isFormStatus(status: CreateStatus) {\n  const isEditing = status === 'editing';\n  const isCreating = status === 'creating';\n  return isEditing || isCreating;\n}\n\nfunction shownSecretOf(state: KeysState) {\n  if (state.status !== 'revealed') {\n    return null;\n  }\n  return state.secret;\n}\n\nfunction copyLabelOf(isCopied: boolean) {\n  if (isCopied) {\n    return 'Copied';\n  }\n  return 'Copy key';\n}\n\ntype KeyFormProps = {\n  state: KeysState;\n  pressed: string | null;\n  onAction: (action: KeysAction) => void;\n  onSubmit: () => void;\n  onClose: () => void;\n};\n\nfunction KeyForm({\n  state,\n  pressed,\n  onAction,\n  onSubmit,\n  onClose,\n}: KeyFormProps) {\n  const nameId = useId();\n  const errorId = useId();\n  const draft = state.draft;\n  const isCreating = state.status === 'creating';\n  const hasError = state.nameError !== null;\n  const environmentLine = ENVIRONMENT_LINE[draft.environment];\n\n  function submit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    onSubmit();\n  }\n\n  function closeOnEscape(event: React.KeyboardEvent<HTMLFormElement>) {\n    if (event.key !== 'Escape') {\n      return;\n    }\n    event.preventDefault();\n    onClose();\n  }\n\n  return (\n    <form\n      noValidate\n      onSubmit={submit}\n      onKeyDown={closeOnEscape}\n      className='bg-foreground/[0.025] flex flex-col gap-4 p-4'\n    >\n      <div className='flex flex-col gap-1.5'>\n        <Label htmlFor={nameId}>Name</Label>\n        <Input\n          id={nameId}\n          data-key-name\n          value={draft.name}\n          maxLength={NAME_MAX_LENGTH}\n          autoComplete='off'\n          spellCheck={false}\n          placeholder='Where the key is used'\n          readOnly={isCreating}\n          aria-invalid={hasError}\n          aria-describedby={describedByOf(hasError, errorId)}\n          onChange={(event) =>\n            onAction({ type: 'named', value: event.target.value })\n          }\n          className='@lg:max-w-80'\n        />\n        <ErrorLine\n          id={errorId}\n          error={state.nameError}\n          attempts={state.attempts}\n        />\n      </div>\n      <div className='flex flex-wrap gap-x-8 gap-y-4'>\n        <div className='flex flex-col gap-1.5'>\n          <span className='text-[13px] leading-none font-medium'>\n            Environment\n          </span>\n          <Segments\n            value={draft.environment}\n            segments={ENVIRONMENTS}\n            label='Environment'\n            onValueChange={(environment) =>\n              onAction({ type: 'environmentPicked', environment })\n            }\n            className='w-fit'\n          />\n          <span className='text-muted-foreground flex text-xs'>\n            <Swap swapKey={draft.environment}>{environmentLine}</Swap>\n          </span>\n        </div>\n        <div className='flex flex-col gap-1.5'>\n          <span className='text-[13px] leading-none font-medium'>Access</span>\n          <Segments\n            value={draft.access}\n            segments={ACCESSES}\n            label='Access'\n            onValueChange={(access) =>\n              onAction({ type: 'accessPicked', access })\n            }\n            className='w-fit'\n          />\n        </div>\n      </div>\n      <div className='flex flex-wrap items-center justify-end gap-2'>\n        <Button\n          type='button'\n          variant='ghost'\n          disabled={isCreating}\n          onClick={onClose}\n        >\n          Cancel\n        </Button>\n        <MorphButton\n          type='submit'\n          state={morphOf(state.status)}\n          labels={CREATE_LABELS}\n          className={pressedSolidOf(pressed === 'submit')}\n        />\n      </div>\n    </form>\n  );\n}\n\ntype SecretPanelProps = {\n  secret: Secret;\n  pressed: string | null;\n  onCopy: () => void;\n  onHide: () => void;\n};\n\n/** Waits on the person until they hide it, so it wears the warning wash while it is there. */\nfunction SecretPanel({ secret, pressed, onCopy, onHide }: SecretPanelProps) {\n  const isCopied = secret.isCopied;\n  const copyLabel = copyLabelOf(isCopied);\n\n  return (\n    <div className='relative isolate flex flex-col gap-3 p-4'>\n      <Wash color='var(--warning)' />\n      <p className='flex items-start gap-2 text-[13px] text-pretty'>\n        <TriangleAlertIcon className='text-warning-foreground mt-0.5 size-4 shrink-0' />\n        <span>\n          <span className='font-medium'>{`Copy the key for ${secret.name} now.`}</span>{' '}\n          It is shown once: after you hide it, only its last four characters\n          stay.\n        </span>\n      </p>\n      <div className='bg-foreground/[0.05] flex flex-wrap items-center gap-2 rounded-lg p-1.5 ps-3'>\n        <code className='min-w-0 flex-1 basis-48 font-mono text-[13px] break-all select-all'>\n          {secret.value}\n        </code>\n        <Button\n          type='button'\n          size='sm'\n          data-secret-copy\n          onClick={onCopy}\n          className={pressedSolidOf(pressed === 'copy')}\n        >\n          <Swap swapKey={String(isCopied)}>\n            {isCopied && <CheckIcon />}\n            {!isCopied && <CopyIcon />}\n          </Swap>\n          <AnimatedSize as='span' axis='width' contentClassName='relative flex'>\n            <Swap swapKey={copyLabel}>{copyLabel}</Swap>\n          </AnimatedSize>\n        </Button>\n      </div>\n      <div className='flex flex-wrap items-center justify-between gap-x-4 gap-y-2'>\n        <p className='text-muted-foreground text-xs'>\n          A sample key: it opens nothing in this preview\n        </p>\n        <Button\n          type='button'\n          variant='outline'\n          size='sm'\n          onClick={onHide}\n          className={pressedQuietOf(pressed === 'hide')}\n        >\n          Hide key\n        </Button>\n      </div>\n    </div>\n  );\n}\n\ntype CreateSlotProps = {\n  state: KeysState;\n  pressed: string | null;\n  onAction: (action: KeysAction) => void;\n  onSubmit: () => void;\n  onClose: () => void;\n  onCopy: () => void;\n  onHide: () => void;\n};\n\n/** The top of the card grows into the form, the form gives way to the secret, then it all folds away. */\nexport function CreateSlot({\n  state,\n  pressed,\n  onAction,\n  onSubmit,\n  onClose,\n  onCopy,\n  onHide,\n}: CreateSlotProps) {\n  const fade = fadePresence();\n  const isForm = isFormStatus(state.status);\n  const secret = shownSecretOf(state);\n\n  return (\n    <AnimatedSize contentClassName='relative'>\n      <AnimatePresence mode='popLayout' initial={false}>\n        {isForm && (\n          <motion.div key='form' {...fade}>\n            <KeyForm\n              state={state}\n              pressed={pressed}\n              onAction={onAction}\n              onSubmit={onSubmit}\n              onClose={onClose}\n            />\n          </motion.div>\n        )}\n        {secret && (\n          <motion.div key='secret' {...fade}>\n            <SecretPanel\n              secret={secret}\n              pressed={pressed}\n              onCopy={onCopy}\n              onHide={onHide}\n            />\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </AnimatedSize>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/settings-04/create-key.tsx"
    },
    {
      "path": "registry/ndeko/blocks/settings/settings-04/key-rows.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport {\n  ChevronDownIcon,\n  HourglassIcon,\n  KeyIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Chip } from '@/registry/ndeko/ui/chip';\n\nimport {\n  ENVIRONMENT_LABEL,\n  IDLE_AFTER_DAYS,\n  SCOPES,\n  type ApiKey,\n  type Environment,\n} from './data';\nimport { HoldButton } from './hold-button';\nimport { maskedKeyOf } from './session';\n\nexport const MONEY_FORMAT: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'USD',\n};\n\nconst COUNT = new Intl.NumberFormat('en-US');\n\nconst ENVIRONMENT_COLOR: Record<Environment, string> = {\n  live: 'var(--success)',\n  test: 'var(--info)',\n};\n\nfunction isIdle(key: ApiKey) {\n  if (key.idleDays === null) {\n    return false;\n  }\n  return key.idleDays >= IDLE_AFTER_DAYS;\n}\n\nfunction controlsOf(isOpen: boolean, id: string) {\n  if (isOpen) {\n    return id;\n  }\n  return undefined;\n}\n\nfunction chevronTurnOf(isOpen: boolean) {\n  if (isOpen) {\n    return 'rotate-180';\n  }\n  return undefined;\n}\n\nfunction totalOf(values: number[]) {\n  let total = 0;\n  for (const value of values) {\n    total += value;\n  }\n  return total;\n}\n\nfunction requestsLineOf(total: number) {\n  if (total === 1) {\n    return '1 request';\n  }\n  return `${COUNT.format(total)} requests`;\n}\n\n/** A day without requests keeps a sliver, so the fourteen days stay countable. */\nconst LOWEST_BAR_PERCENT = 6;\n\nconst BAR_STAGGER_MS = 18;\n\n/** Each bar grows from the floor when the row opens, a beat after the one before it. */\nfunction barStyleOf(count: number, highest: number, index: number) {\n  const share = count / highest;\n  const sharePercent = share * 100;\n  const percent = Math.max(sharePercent, LOWEST_BAR_PERCENT);\n  const delay = index * BAR_STAGGER_MS;\n  return { height: `${percent}%`, transitionDelay: `${delay}ms` };\n}\n\nfunction UsageBars({ requests }: { requests: number[] }) {\n  const highest = Math.max(...requests);\n  const total = totalOf(requests);\n  const hasRequests = highest > 0;\n  const summary = `${requestsLineOf(total)} over the last 14 days, ${COUNT.format(highest)} on the busiest day`;\n\n  if (!hasRequests) {\n    return (\n      <p className='bg-foreground/[0.03] text-muted-foreground flex h-10 items-center justify-center rounded-md text-xs'>\n        No requests in the last 14 days\n      </p>\n    );\n  }\n\n  return (\n    <div role='img' aria-label={summary} className='flex h-10 items-end gap-1'>\n      {requests.map((count, index) => (\n        <span\n          key={`day-${index}`}\n          style={barStyleOf(count, highest, index)}\n          className='bg-primary w-full max-w-4 origin-bottom scale-y-100 rounded-t-[3px] transition-[scale] duration-300 ease-(--ease-out-strong) starting:scale-y-0'\n        />\n      ))}\n    </div>\n  );\n}\n\ntype KeyDetailsProps = {\n  apiKey: ApiKey;\n  isDemoHolding: boolean;\n  onRevoke: (id: string) => void;\n};\n\nfunction KeyDetails({ apiKey, isDemoHolding, onRevoke }: KeyDetailsProps) {\n  const scopes = SCOPES[apiKey.access];\n  const total = totalOf(apiKey.requests);\n  const showsIdleNote = isIdle(apiKey);\n\n  return (\n    <div className='flex flex-col gap-4 px-4 pt-1 pb-4 @xl:ps-[3.75rem]'>\n      <dl className='grid gap-x-6 gap-y-3 @xl:grid-cols-2'>\n        <div className='flex flex-col gap-1.5'>\n          <dt className='text-muted-foreground text-xs'>Scopes</dt>\n          <dd className='flex flex-wrap gap-1'>\n            {scopes.map((scope) => (\n              <Badge\n                key={scope}\n                variant='secondary'\n                className='font-mono text-[11px] font-normal'\n              >\n                {scope}\n              </Badge>\n            ))}\n          </dd>\n        </div>\n        <div className='flex flex-col gap-1.5'>\n          <dt className='text-muted-foreground text-xs'>Created</dt>\n          <dd className='flex min-w-0 items-center gap-2 text-[13px]'>\n            <Avatar seed={apiKey.createdBy} className='size-5' />\n            <span className='truncate'>\n              {apiKey.createdBy}, {apiKey.createdOn}\n            </span>\n          </dd>\n        </div>\n      </dl>\n      <div className='flex flex-col gap-2'>\n        <p className='text-muted-foreground flex items-baseline justify-between gap-3 text-xs'>\n          <span>Requests, last 14 days</span>\n          <span className='tabular-nums'>{requestsLineOf(total)}</span>\n        </p>\n        <UsageBars requests={apiKey.requests} />\n      </div>\n      {showsIdleNote && (\n        <p className='text-warning-foreground text-xs text-pretty'>\n          {`No request since ${apiKey.lastUsed}. If nothing needs it any more, revoke it.`}\n        </p>\n      )}\n      <div className='flex flex-wrap items-center justify-between gap-x-4 gap-y-2'>\n        <p className='text-muted-foreground min-w-0 flex-1 basis-48 text-xs text-pretty'>\n          Apps that use this key stop working at once\n        </p>\n        <HoldButton\n          label='Hold to revoke'\n          hint={`Press and hold for two seconds to revoke ${apiKey.name}`}\n          isDemoHolding={isDemoHolding}\n          onComplete={() => onRevoke(apiKey.id)}\n        />\n      </div>\n    </div>\n  );\n}\n\ntype KeyRowProps = {\n  apiKey: ApiKey;\n  isOpen: boolean;\n  isPressed: boolean;\n  isDemoHolding: boolean;\n  onToggle: (id: string) => void;\n  onRevoke: (id: string) => void;\n};\n\nfunction KeyRow({\n  apiKey,\n  isOpen,\n  isPressed,\n  isDemoHolding,\n  onToggle,\n  onRevoke,\n}: KeyRowProps) {\n  const detailsId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const presence = rowPresenceOf(shouldReduceMotion);\n  const showsIdle = isIdle(apiKey);\n  const spend = apiKey.spendCents / 100;\n  const masked = maskedKeyOf(apiKey.environment, apiKey.tail);\n\n  return (\n    <div className='flex flex-col'>\n      <button\n        type='button'\n        data-row-toggle={apiKey.id}\n        aria-expanded={isOpen}\n        aria-controls={controlsOf(isOpen, detailsId)}\n        onClick={() => onToggle(apiKey.id)}\n        className='hover:bg-foreground/[0.025] focus-visible:ring-ring/25 grid w-full cursor-pointer grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-x-3 px-4 py-3 text-start transition-colors duration-150 outline-none focus-visible:ring-[3px] focus-visible:ring-inset'\n      >\n        <span className='keycap-3d text-muted-foreground flex size-8 items-center justify-center rounded-lg'>\n          <KeyIcon className='size-4' />\n        </span>\n        <span className='flex min-w-0 flex-col gap-1'>\n          <span className='flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1'>\n            <span className='min-w-0 truncate text-[13px] font-medium'>\n              {apiKey.name}\n            </span>\n            <Chip color={ENVIRONMENT_COLOR[apiKey.environment]}>\n              {ENVIRONMENT_LABEL[apiKey.environment]}\n            </Chip>\n            {showsIdle && (\n              <Badge variant='warning'>\n                <HourglassIcon />\n                {`Idle for ${apiKey.idleDays} days`}\n              </Badge>\n            )}\n          </span>\n          <span className='text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs'>\n            <code className='font-mono'>{masked}</code>\n            <span aria-hidden='true'>·</span>\n            <span>Created {apiKey.createdOn}</span>\n            <span aria-hidden='true'>·</span>\n            <span>Last used {apiKey.lastUsed}</span>\n          </span>\n        </span>\n        <span className='flex items-center gap-2'>\n          <span className='flex flex-col items-end'>\n            <MotionNumber\n              value={spend}\n              format={MONEY_FORMAT}\n              className='text-[13px] font-medium'\n            />\n            <span className='text-muted-foreground text-xs'>this month</span>\n          </span>\n          <span\n            className={cn(\n              'flex size-7 items-center justify-center rounded-md transition-[background-color,scale] duration-150 ease-(--ease-out-strong)',\n              pressedQuietOf(isPressed)\n            )}\n          >\n            <ChevronDownIcon\n              className={cn(\n                'text-muted-foreground size-4 transition-[rotate] duration-200 ease-(--ease-out-strong)',\n                chevronTurnOf(isOpen)\n              )}\n            />\n          </span>\n        </span>\n      </button>\n      <AnimatePresence initial={false}>\n        {isOpen && (\n          <motion.div\n            key='details'\n            id={detailsId}\n            className='overflow-hidden'\n            {...presence}\n          >\n            <KeyDetails\n              apiKey={apiKey}\n              isDemoHolding={isDemoHolding}\n              onRevoke={onRevoke}\n            />\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\ntype KeyListProps = {\n  keys: ApiKey[];\n  openId: string | null;\n  pressed: string | null;\n  /** The key whose Revoke the demonstration holds, while it plays. */\n  demoHoldingId: string | null;\n  onToggle: (id: string) => void;\n  onRevoke: (id: string) => void;\n};\n\n/** A key made here grows in at the top; a revoked one folds away faster than it came. */\nexport function KeyList({\n  keys,\n  openId,\n  pressed,\n  demoHoldingId,\n  onToggle,\n  onRevoke,\n}: KeyListProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const presence = rowPresenceOf(shouldReduceMotion);\n\n  return (\n    <ul className='hairline-divide-y divide-border flex flex-col'>\n      <AnimatePresence initial={false}>\n        {keys.map((apiKey) => (\n          <motion.li key={apiKey.id} className='overflow-hidden' {...presence}>\n            <KeyRow\n              apiKey={apiKey}\n              isOpen={openId === apiKey.id}\n              isPressed={pressed === `row-${apiKey.id}`}\n              isDemoHolding={demoHoldingId === apiKey.id}\n              onToggle={onToggle}\n              onRevoke={onRevoke}\n            />\n          </motion.li>\n        ))}\n      </AnimatePresence>\n    </ul>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/settings-04/key-rows.tsx"
    },
    {
      "path": "registry/ndeko/blocks/settings/settings-04/hold-button.tsx",
      "content": "'use client';\n\nimport { useEffect, useId, useRef, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\n\nimport { HOLD_MS } from './session';\n\ntype Timer = ReturnType<typeof setTimeout>;\n\nconst HOLDING_LABEL = 'Keep holding';\n\n/** The fill crosses the pill on a transform; reduced motion keeps the same two seconds as a fade. */\nfunction fillClassOf(isFilling: boolean, shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return cn(\n      'opacity-0 transition-opacity duration-200',\n      isFilling && 'opacity-100 duration-[2000ms] ease-linear'\n    );\n  }\n  return cn(\n    'origin-left scale-x-0 transition-[scale] duration-200 ease-(--ease-out-strong) rtl:origin-right',\n    isFilling && 'scale-x-100 duration-[2000ms] ease-linear'\n  );\n}\n\nfunction labelOf(isFilling: boolean, label: string) {\n  if (isFilling) {\n    return HOLDING_LABEL;\n  }\n  return label;\n}\n\nfunction isHoldKey(event: React.KeyboardEvent) {\n  const isSpace = event.key === ' ';\n  const isEnter = event.key === 'Enter';\n  return isSpace || isEnter;\n}\n\nfunction demoPressOf(isDemoHolding: boolean) {\n  if (isDemoHolding) {\n    return 'scale-[0.97]';\n  }\n  return undefined;\n}\n\ntype HoldButtonProps = {\n  label: string;\n  /** Read after the label: what holding does, and for how long. */\n  hint: string;\n  /** The demonstration holds the button down: the fill runs as it would under a finger. */\n  isDemoHolding: boolean;\n  onComplete: () => void;\n};\n\n/** A destructive action that asks for intent: two seconds pressed fill the pill, a release drains it in 200ms. */\nexport function HoldButton({\n  label,\n  hint,\n  isDemoHolding,\n  onComplete,\n}: HoldButtonProps) {\n  const [isHolding, setIsHolding] = useState(false);\n  const timer = useRef<Timer | null>(null);\n  const latestComplete = useRef(onComplete);\n  const hintId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const isFilling = isHolding || isDemoHolding;\n  const fillClass = fillClassOf(isFilling, shouldReduceMotion);\n  const shownLabel = labelOf(isFilling, label);\n\n  useEffect(() => {\n    latestComplete.current = onComplete;\n  });\n\n  useEffect(() => {\n    return () => {\n      if (timer.current) {\n        clearTimeout(timer.current);\n      }\n    };\n  }, []);\n\n  function startHold() {\n    if (timer.current) {\n      return;\n    }\n    setIsHolding(true);\n    timer.current = setTimeout(() => {\n      timer.current = null;\n      setIsHolding(false);\n      latestComplete.current();\n    }, HOLD_MS);\n  }\n\n  function stopHold() {\n    if (timer.current) {\n      clearTimeout(timer.current);\n      timer.current = null;\n    }\n    setIsHolding(false);\n  }\n\n  function pressPointer(event: React.PointerEvent<HTMLButtonElement>) {\n    const isMainButton = event.button === 0;\n    if (isMainButton) {\n      startHold();\n    }\n  }\n\n  function pressKey(event: React.KeyboardEvent<HTMLButtonElement>) {\n    if (!isHoldKey(event)) {\n      return;\n    }\n    event.preventDefault();\n    if (!event.repeat) {\n      startHold();\n    }\n  }\n\n  function releaseKey(event: React.KeyboardEvent<HTMLButtonElement>) {\n    if (isHoldKey(event)) {\n      stopHold();\n    }\n  }\n\n  function keepMenuAway(event: React.MouseEvent<HTMLButtonElement>) {\n    event.preventDefault();\n  }\n\n  return (\n    <>\n      <Button\n        type='button'\n        variant='outline'\n        size='sm'\n        aria-describedby={hintId}\n        onPointerDown={pressPointer}\n        onPointerUp={stopHold}\n        onPointerLeave={stopHold}\n        onPointerCancel={stopHold}\n        onKeyDown={pressKey}\n        onKeyUp={releaseKey}\n        onBlur={stopHold}\n        onContextMenu={keepMenuAway}\n        className={cn(\n          'text-destructive-ink touch-none overflow-hidden select-none [-webkit-touch-callout:none]',\n          demoPressOf(isDemoHolding)\n        )}\n      >\n        <span\n          aria-hidden='true'\n          className={cn('bg-destructive/15 absolute inset-0', fillClass)}\n        />\n        <AnimatedSize as='span' axis='width' contentClassName='relative flex'>\n          <Swap swapKey={shownLabel}>{shownLabel}</Swap>\n        </AnimatedSize>\n      </Button>\n      <span id={hintId} className='sr-only'>\n        {hint}\n      </span>\n    </>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/settings-04/hold-button.tsx"
    },
    {
      "path": "registry/ndeko/blocks/settings/settings-04/settings-frame.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { rowPresenceOf, SPRING } from '@/registry/ndeko/lib/motion-presets';\n\nexport const SURFACE =\n  'bg-card hairline-ring ring-border rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)] dark:bg-foreground/[0.03]';\n\nconst NUDGE = { initial: { x: 4 }, animate: { x: 0 } };\n\nconst STILL = { initial: false, animate: { x: 0 } };\n\nfunction nudgeOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return STILL;\n  }\n  return NUDGE;\n}\n\nexport function describedByOf(hasError: boolean, errorId: string) {\n  if (hasError) {\n    return errorId;\n  }\n  return undefined;\n}\n\ntype SettingsFrameProps = {\n  ref?: React.Ref<HTMLDivElement>;\n  title: string;\n  line: string;\n  /** Sits beside the title: the Replay of the demonstration. */\n  aside?: React.ReactNode;\n  children: React.ReactNode;\n};\n\n/** A settings page that follows its own width: one column, the title above, the sections under it. */\nexport function SettingsFrame({\n  ref,\n  title,\n  line,\n  aside,\n  children,\n}: SettingsFrameProps) {\n  return (\n    <div\n      ref={ref}\n      className='bg-background text-foreground @container min-h-dvh w-full'\n    >\n      <div className='mx-auto flex w-full max-w-3xl flex-col gap-8 px-4 py-8 @2xl:px-6 @2xl:py-10'>\n        <header className='flex flex-wrap items-start gap-x-3 gap-y-2'>\n          <div className='flex min-w-0 flex-1 basis-64 flex-col gap-1'>\n            <h1 className='text-2xl font-semibold text-balance @xl:text-3xl'>\n              {title}\n            </h1>\n            <p className='text-muted-foreground text-[13px] text-pretty'>\n              {line}\n            </p>\n          </div>\n          {aside}\n        </header>\n        {children}\n      </div>\n    </div>\n  );\n}\n\ntype SettingsSectionProps = {\n  title: string;\n  line?: React.ReactNode;\n  action?: React.ReactNode;\n  children: React.ReactNode;\n};\n\nexport function SettingsSection({\n  title,\n  line,\n  action,\n  children,\n}: SettingsSectionProps) {\n  const headingId = useId();\n\n  return (\n    <section aria-labelledby={headingId} className='flex flex-col gap-3'>\n      <div className='flex flex-wrap items-end justify-between gap-x-3 gap-y-2'>\n        <div className='flex min-w-0 flex-col gap-0.5'>\n          <h2 id={headingId} className='text-sm font-medium'>\n            {title}\n          </h2>\n          {line && (\n            <p className='text-muted-foreground text-xs text-pretty'>{line}</p>\n          )}\n        </div>\n        {action}\n      </div>\n      {children}\n    </section>\n  );\n}\n\ntype ErrorLineProps = {\n  /** The field points to it with `aria-describedby` while it shows. */\n  id: string;\n  error: string | null;\n  /** A new refusal of the same entry nudges the line again. */\n  attempts: number;\n};\n\n/** A refusal grows in under its field, nudges 4px, and folds away once the person types again. */\nexport function ErrorLine({ id, error, attempts }: ErrorLineProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const presence = rowPresenceOf(shouldReduceMotion);\n  const nudge = nudgeOf(shouldReduceMotion);\n\n  return (\n    <AnimatePresence initial={false}>\n      {error && (\n        <motion.div key='error' className='overflow-hidden' {...presence}>\n          <motion.p\n            key={attempts}\n            id={id}\n            className='text-destructive-ink pt-0.5 text-xs text-pretty'\n            transition={SPRING}\n            {...nudge}\n          >\n            {error}\n          </motion.p>\n        </motion.div>\n      )}\n    </AnimatePresence>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/settings-04/settings-frame.tsx"
    },
    {
      "path": "registry/ndeko/blocks/settings/settings-04/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\nimport { keyDelayOf, prefixesOf } from '@/registry/ndeko/lib/demonstration';\n\nimport {\n  KEYS,\n  SAMPLE_SECRETS,\n  TODAY,\n  YOU,\n  type Access,\n  type ApiKey,\n  type Environment,\n} from './data';\n\n/** Closed, the form, the key being made, then the secret shown once. */\nexport type CreateStatus = 'closed' | 'editing' | 'creating' | 'revealed';\n\nexport type Draft = {\n  name: string;\n  environment: Environment;\n  access: Access;\n};\n\nexport type Secret = {\n  keyId: string;\n  name: string;\n  value: string;\n  isCopied: boolean;\n};\n\nexport type KeysState = {\n  keys: ApiKey[];\n  status: CreateStatus;\n  draft: Draft;\n  nameError: string | null;\n  /** Counts the refused entries, so a message that comes back nudges again. */\n  attempts: number;\n  secret: Secret | null;\n  openId: string | null;\n  /** The key whose Revoke the demonstration is holding down. */\n  holdingId: string | null;\n  /** Keys made since the page loaded: the next one takes the next sample secret. */\n  made: number;\n  spoken: string;\n};\n\nexport type KeysAction =\n  | { type: 'createOpened' }\n  | { type: 'createClosed' }\n  | { type: 'named'; value: string }\n  | { type: 'environmentPicked'; environment: Environment }\n  | { type: 'accessPicked'; access: Access }\n  | { type: 'createSubmitted' }\n  | { type: 'keyCreated' }\n  | { type: 'secretCopied' }\n  | { type: 'copyFailed' }\n  | { type: 'secretHidden' }\n  | { type: 'rowToggled'; id: string }\n  | { type: 'holdStarted'; id: string }\n  | { type: 'revoked'; id: string }\n  | { type: 'used'; id: string; cents: number };\n\ntype Step = SessionStep<KeysState, KeysAction>;\n\n/** How long the server takes to make a key. */\nexport const CREATE_MS = 900;\n\n/** The two seconds the Hold pattern asks for. */\nexport const HOLD_MS = 2000;\n\nconst EMPTY_DRAFT: Draft = { name: '', environment: 'live', access: 'full' };\n\nexport const INITIAL: KeysState = {\n  keys: KEYS,\n  status: 'closed',\n  draft: EMPTY_DRAFT,\n  nameError: null,\n  attempts: 0,\n  secret: null,\n  openId: null,\n  holdingId: null,\n  made: 0,\n  spoken: '',\n};\n\nexport function maskedKeyOf(environment: Environment, tail: string) {\n  return `tw_${environment}_…${tail}`;\n}\n\nfunction keyById(state: KeysState, id: string) {\n  return state.keys.find((key) => key.id === id);\n}\n\nfunction isNameTaken(state: KeysState, name: string) {\n  const lowered = name.toLowerCase();\n  return state.keys.some((key) => key.name.toLowerCase() === lowered);\n}\n\nfunction nameProblemOf(state: KeysState, name: string) {\n  if (name === '') {\n    return 'Name the key so you can tell where it is used';\n  }\n  if (isNameTaken(state, name)) {\n    return `A key named ${name} already exists`;\n  }\n  return null;\n}\n\nfunction createOpened(state: KeysState): KeysState {\n  if (state.status !== 'closed') {\n    return state;\n  }\n  return {\n    ...state,\n    status: 'editing',\n    draft: EMPTY_DRAFT,\n    nameError: null,\n    spoken: 'New key form opened',\n  };\n}\n\nfunction createClosed(state: KeysState): KeysState {\n  if (state.status !== 'editing') {\n    return state;\n  }\n  return { ...state, status: 'closed', nameError: null, spoken: '' };\n}\n\nfunction withDraft(state: KeysState, change: Partial<Draft>): KeysState {\n  if (state.status !== 'editing') {\n    return state;\n  }\n  return { ...state, draft: { ...state.draft, ...change } };\n}\n\nfunction named(state: KeysState, value: string): KeysState {\n  const next = withDraft(state, { name: value });\n  return { ...next, nameError: null };\n}\n\nfunction createSubmitted(state: KeysState): KeysState {\n  if (state.status !== 'editing') {\n    return state;\n  }\n  const name = state.draft.name.trim();\n  const problem = nameProblemOf(state, name);\n  if (problem) {\n    return {\n      ...state,\n      nameError: problem,\n      attempts: state.attempts + 1,\n      spoken: problem,\n    };\n  }\n  return { ...state, status: 'creating', spoken: 'Creating the key' };\n}\n\nfunction secretSuffixOf(made: number) {\n  const index = made % SAMPLE_SECRETS.length;\n  return SAMPLE_SECRETS[index];\n}\n\nfunction keyCreated(state: KeysState): KeysState {\n  if (state.status !== 'creating') {\n    return state;\n  }\n  const draft = state.draft;\n  const made = state.made + 1;\n  const suffix = secretSuffixOf(state.made);\n  const name = draft.name.trim();\n  const key: ApiKey = {\n    id: `made-${made}`,\n    name,\n    environment: draft.environment,\n    tail: suffix.slice(-4),\n    createdOn: TODAY,\n    createdBy: YOU,\n    lastUsed: 'never',\n    idleDays: null,\n    spendCents: 0,\n    access: draft.access,\n    requests: Array.from({ length: 14 }, () => 0),\n  };\n  const secret: Secret = {\n    keyId: key.id,\n    name,\n    value: `tw_${draft.environment}_${suffix}`,\n    isCopied: false,\n  };\n  return {\n    ...state,\n    keys: [key, ...state.keys],\n    status: 'revealed',\n    secret,\n    made,\n    spoken: `${name} created. Copy the key now: it is shown once`,\n  };\n}\n\nfunction secretCopied(state: KeysState): KeysState {\n  if (!state.secret) {\n    return state;\n  }\n  const secret = { ...state.secret, isCopied: true };\n  return { ...state, secret, spoken: 'Key copied' };\n}\n\nfunction secretHidden(state: KeysState): KeysState {\n  if (state.status !== 'revealed') {\n    return state;\n  }\n  return {\n    ...state,\n    status: 'closed',\n    secret: null,\n    spoken: 'Key hidden. Only its last four characters stay visible',\n  };\n}\n\nfunction toggledId(openId: string | null, id: string) {\n  if (openId === id) {\n    return null;\n  }\n  return id;\n}\n\ntype SecretSlot = Pick<KeysState, 'status' | 'secret'>;\n\n/** Revoking a key whose secret is still on screen takes the secret away with it. */\nfunction secretAfterRevokeOf(state: KeysState, id: string): SecretSlot {\n  const isShowingIt = state.secret?.keyId === id;\n  if (isShowingIt) {\n    return { status: 'closed', secret: null };\n  }\n  return { status: state.status, secret: state.secret };\n}\n\nfunction openIdAfterRevokeOf(openId: string | null, id: string) {\n  if (openId === id) {\n    return null;\n  }\n  return openId;\n}\n\nfunction revoked(state: KeysState, id: string): KeysState {\n  const key = keyById(state, id);\n  if (!key) {\n    return state;\n  }\n  const keys = state.keys.filter((candidate) => candidate.id !== id);\n  const slot = secretAfterRevokeOf(state, id);\n  return {\n    ...state,\n    ...slot,\n    keys,\n    openId: openIdAfterRevokeOf(state.openId, id),\n    holdingId: null,\n    spoken: `${key.name} revoked. Apps that use it can no longer call the API`,\n  };\n}\n\n/** Test keys call a sandbox that costs nothing. */\nfunction used(state: KeysState, id: string, cents: number): KeysState {\n  const keys = state.keys.map((key) => {\n    const isLiveMatch = key.id === id && key.environment === 'live';\n    if (!isLiveMatch) {\n      return key;\n    }\n    return {\n      ...key,\n      spendCents: key.spendCents + cents,\n      lastUsed: 'just now',\n    };\n  });\n  return { ...state, keys };\n}\n\nexport function reducer(state: KeysState, action: KeysAction): KeysState {\n  switch (action.type) {\n    case 'createOpened':\n      return createOpened(state);\n    case 'createClosed':\n      return createClosed(state);\n    case 'named':\n      return named(state, action.value);\n    case 'environmentPicked':\n      return withDraft(state, { environment: action.environment });\n    case 'accessPicked':\n      return withDraft(state, { access: action.access });\n    case 'createSubmitted':\n      return createSubmitted(state);\n    case 'keyCreated':\n      return keyCreated(state);\n    case 'secretCopied':\n      return secretCopied(state);\n    case 'copyFailed':\n      return {\n        ...state,\n        spoken: 'Copy did not work. Select the key and copy it',\n      };\n    case 'secretHidden':\n      return secretHidden(state);\n    case 'rowToggled':\n      return { ...state, openId: toggledId(state.openId, action.id) };\n    case 'holdStarted':\n      return { ...state, holdingId: action.id };\n    case 'revoked':\n      return revoked(state, action.id);\n    case 'used':\n      return used(state, action.id, action.cents);\n  }\n}\n\nconst KEY_MS = 55;\n\nconst TYPED_NAME = 'Analytics export';\n\nfunction typingSteps(text: string, startAfter: number): Step[] {\n  const prefixes = prefixesOf(text);\n  return prefixes.map((value, index) => ({\n    after: keyDelayOf(index, startAfter, KEY_MS),\n    by: 'demo',\n    action: { type: 'named', value },\n  }));\n}\n\n/**\n * A key is made, copied and hidden, then the idle one is opened. That is where the page rests\n * under reduced motion: the idle marker and the Revoke a person would hold.\n */\nconst BEFORE_REVOKE: Step[] = [\n  {\n    after: 1200,\n    by: 'demo',\n    press: 'create',\n    action: { type: 'createOpened' },\n  },\n  ...typingSteps(TYPED_NAME, 500),\n  {\n    after: 650,\n    by: 'demo',\n    action: { type: 'accessPicked', access: 'read' },\n  },\n  {\n    after: 700,\n    by: 'demo',\n    press: 'submit',\n    action: { type: 'createSubmitted' },\n  },\n  { after: CREATE_MS, action: { type: 'keyCreated' } },\n  { after: 1500, by: 'demo', press: 'copy', action: { type: 'secretCopied' } },\n  { after: 900, action: { type: 'used', id: 'production', cents: 42 } },\n  { after: 1100, by: 'demo', press: 'hide', action: { type: 'secretHidden' } },\n  {\n    after: 1100,\n    by: 'demo',\n    press: 'row-old-import',\n    action: { type: 'rowToggled', id: 'old-import' },\n  },\n];\n\nexport const SCRIPT: Step[] = [\n  ...BEFORE_REVOKE,\n  {\n    after: 1600,\n    by: 'demo',\n    action: { type: 'holdStarted', id: 'old-import' },\n  },\n  {\n    after: HOLD_MS,\n    by: 'demo',\n    action: { type: 'revoked', id: 'old-import' },\n  },\n  { after: 1300, action: { type: 'used', id: 'production', cents: 31 } },\n];\n\nfunction endOf(steps: Step[]) {\n  let state = INITIAL;\n  for (const step of steps) {\n    state = reducer(state, step.action);\n  }\n  return state;\n}\n\nexport const RESTING: KeysState = { ...endOf(BEFORE_REVOKE), spoken: '' };\n\nexport const LOOP_AFTER_MS = 3200;\n",
      "type": "registry:component",
      "target": "components/blocks/settings-04/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/settings/settings-04/data.ts",
      "content": "export type Environment = 'live' | 'test';\n\nexport type Access = 'read' | 'full';\n\nexport type ApiKey = {\n  id: string;\n  name: string;\n  environment: Environment;\n  /** The last characters of the secret: all a row ever shows of it. */\n  tail: string;\n  createdOn: string;\n  createdBy: string;\n  lastUsed: string;\n  /** Days since the last request, once a key has gone quiet long enough to be flagged. */\n  idleDays: number | null;\n  /** Spend this month, in cents. */\n  spendCents: number;\n  access: Access;\n  /** Requests on each of the last 14 days, oldest first. */\n  requests: number[];\n};\n\nexport const WORKSPACE_NAME = 'Tidewell Studio';\n\nexport const YOU = 'Dana Whitfield';\n\nexport const TODAY = 'Nov 12, 2026';\n\n/** A key that has not called the API for this long is flagged as idle. */\nexport const IDLE_AFTER_DAYS = 30;\n\nexport const NAME_MAX_LENGTH = 40;\n\nexport const ENVIRONMENT_LABEL: Record<Environment, string> = {\n  live: 'Live',\n  test: 'Test',\n};\n\nexport const ACCESS_LABEL: Record<Access, string> = {\n  read: 'Read only',\n  full: 'Full access',\n};\n\nexport const SCOPES: Record<Access, string[]> = {\n  read: ['projects.read', 'time.read', 'reports.read'],\n  full: ['projects.write', 'time.write', 'reports.read', 'invoices.read'],\n};\n\n/**\n * Sample secrets, shown once when a key is made. They open nothing: the word \"example\" in each\n * says so to anyone who copies one.\n */\nexport const SAMPLE_SECRETS = [\n  'example8fM3sQ1vX6nB',\n  'example2Hc9Lp5Rz7Ka',\n  'example6Tn4Wd8Ye3Gs',\n  'example9Jb7Fx2Mq5Ur',\n];\n\nexport const KEYS: ApiKey[] = [\n  {\n    id: 'production',\n    name: 'Production server',\n    environment: 'live',\n    tail: 'Q7xk',\n    createdOn: 'Mar 4, 2026',\n    createdBy: 'Amara Okafor',\n    lastUsed: '2 min ago',\n    idleDays: null,\n    spendCents: 18420,\n    access: 'full',\n    requests: [\n      1180, 1240, 960, 1310, 1420, 890, 770, 1260, 1390, 1450, 1330, 980, 860,\n      1210,\n    ],\n  },\n  {\n    id: 'billing-worker',\n    name: 'Billing worker',\n    environment: 'live',\n    tail: 'm3Rd',\n    createdOn: 'Jan 12, 2026',\n    createdBy: 'Lucas Moreau',\n    lastUsed: '1 hour ago',\n    idleDays: null,\n    spendCents: 4175,\n    access: 'read',\n    requests: [\n      210, 190, 240, 260, 180, 90, 70, 230, 250, 270, 220, 110, 80, 240,\n    ],\n  },\n  {\n    id: 'staging',\n    name: 'Staging',\n    environment: 'test',\n    tail: 'v8Wn',\n    createdOn: 'Feb 2, 2026',\n    createdBy: 'Priya Raman',\n    lastUsed: 'today',\n    idleDays: null,\n    spendCents: 0,\n    access: 'full',\n    requests: [40, 65, 30, 80, 55, 0, 0, 70, 90, 45, 60, 0, 10, 85],\n  },\n  {\n    id: 'old-import',\n    name: 'Old import script',\n    environment: 'live',\n    tail: 'b2Tf',\n    createdOn: 'Aug 19, 2025',\n    createdBy: 'Mateo Silva',\n    lastUsed: 'Oct 1',\n    idleDays: 42,\n    spendCents: 0,\n    access: 'full',\n    requests: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n  },\n];\n",
      "type": "registry:component",
      "target": "components/blocks/settings-04/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "settings"
  ],
  "type": "registry:block"
}