{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checkpoint-solid",
  "title": "Checkpoint (Solid)",
  "description": "A marker in the conversation that restores to that point, after a dialog asks what to restore and says what's lost.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-alert-dialog-solid",
    "@kind-ui/internal-radio-solid",
    "@kind-ui/internal-tooltip-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/checkpoint.tsx",
      "content": "import {\n  type CheckpointDialogState,\n  type CheckpointScopeState,\n  checkpointPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, omit, Show } from \"solid-js\";\nimport {\n  KindAlertDialog,\n  KindAlertDialogBackdrop,\n  KindAlertDialogContent,\n  KindAlertDialogDescription,\n  KindAlertDialogTitle,\n  KindAlertDialogTrigger,\n} from \"./internal/alert-dialog\";\nimport { KindRadio, KindRadioGroup, KindRadioIndicator } from \"./internal/radio\";\nimport { KindTooltip, KindTooltipContent, KindTooltipTrigger } from \"./internal/tooltip\";\n\nconst parts = createParts(checkpointPrimitive, {\n  root: \"div\",\n  label: \"span\",\n  description: \"span\",\n  line: \"span\",\n  restore: \"div\",\n  restored: \"span\",\n  scope: \"div\",\n  compare: \"button\",\n  error: \"span\",\n  cancel: \"button\",\n  confirm: \"button\",\n});\n\nexport type CheckpointProps = ComponentProps<typeof parts.Root>;\n\n/**\n * A marker in the conversation that a person can restore. Restore opens a dialog that asks before calling\n * `onRestore`. Any `children` replace the default parts.\n */\nexport function Checkpoint(props: CheckpointProps) {\n  return <parts.Root {...omit(props, \"children\")}>{props.children ?? <DefaultParts />}</parts.Root>;\n}\n\nexport const CheckpointLine = parts.Line;\n\nexport type CheckpointLabelProps = ComponentProps<typeof parts.Label>;\n\n/** The `label`, unless you pass children. */\nexport function CheckpointLabel(props: CheckpointLabelProps) {\n  return (\n    <parts.Label {...omit(props, \"children\")}>\n      {props.children ?? ((state: { label: string }) => state.label)}\n    </parts.Label>\n  );\n}\n\nexport type CheckpointDescriptionProps = ComponentProps<typeof parts.Description>;\n\n/** The `description`, unless you pass children. Rendered only with one. */\nexport function CheckpointDescription(props: CheckpointDescriptionProps) {\n  return (\n    <parts.Description {...omit(props, \"children\")}>\n      {props.children ?? ((state: { description: string | undefined }) => state.description)}\n    </parts.Description>\n  );\n}\n\nexport type CheckpointRestoreProps = ComponentProps<typeof parts.Restore>;\n\n/**\n * Restore and its dialog, unless you pass children: a function that gets the Alert Dialog's props. Rendered only\n * while `onRestore` is set and the checkpoint isn't `restored`.\n */\nexport function CheckpointRestore(props: CheckpointRestoreProps) {\n  return (\n    <parts.Restore {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: CheckpointDialogState) => (\n          <KindAlertDialog controller={state.controller} dismissible={state.dismissible}>\n            <KindTooltip type=\"label\">\n              <KindTooltipTrigger\n                render={(trigger) => <KindAlertDialogTrigger {...trigger} />}\n                data-checkpoint-trigger=\"\"\n                data-kind-icon-button=\"\"\n              />\n              <KindTooltipContent>Restore checkpoint</KindTooltipContent>\n            </KindTooltip>\n            <CheckpointDialog\n              title={state.title}\n              point={state.point}\n              description={state.description}\n              note={state.note}\n              initialFocus={state.initialFocus}\n              busy={state.busy}\n            />\n          </KindAlertDialog>\n        ))}\n    </parts.Restore>\n  );\n}\n\nexport type CheckpointDialogProps = Omit<CheckpointDialogState, \"controller\" | \"dismissible\" | \"busy\"> & {\n  busy?: boolean;\n  children?: JSX.Element;\n};\n\n/**\n * The dialog's backdrop and content: its title, the checkpoint's description, the scope, the loss sentence as its\n * description, and the answers, unless you pass children, which replace the scope and the answers.\n */\nexport function CheckpointDialog(props: CheckpointDialogProps) {\n  return (\n    <>\n      <KindAlertDialogBackdrop />\n      <KindAlertDialogContent initialFocus={props.initialFocus} aria-busy={props.busy ? \"true\" : undefined}>\n        <KindAlertDialogTitle>{props.title}</KindAlertDialogTitle>\n        <Show when={props.point}>\n          <p data-checkpoint-point=\"\">{props.point}</p>\n        </Show>\n        {props.children ?? (\n          <>\n            <CheckpointScope />\n            <CheckpointLoss description={props.description} note={props.note} />\n            <DefaultAnswers />\n          </>\n        )}\n      </KindAlertDialogContent>\n    </>\n  );\n}\n\nexport type CheckpointLossProps = Pick<CheckpointDialogState, \"description\" | \"note\">;\n\n/** The loss sentence, then the note, as the dialog's description, so both are read as it opens. */\nexport function CheckpointLoss(props: CheckpointLossProps) {\n  return (\n    <KindAlertDialogDescription data-checkpoint-loss=\"\">\n      <span data-checkpoint-loss-text=\"\">{props.description}</span>\n      <span data-checkpoint-note=\"\">{props.note}</span>\n    </KindAlertDialogDescription>\n  );\n}\n\nexport type CheckpointScopeProps = ComponentProps<typeof parts.Scope>;\n\n/**\n * \"Restore\" and a radio per scope, unless you pass children: a function that gets the Radio group's props. Rendered\n * only while the host offers more than one scope.\n */\nexport function CheckpointScope(props: CheckpointScopeProps) {\n  return (\n    <parts.Scope {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: CheckpointScopeState) => (\n          <>\n            <span aria-hidden=\"true\" data-checkpoint-scope-label=\"\">\n              {state.label}\n            </span>\n            <KindRadioGroup\n              controller={state.controller}\n              defaultValue={state.defaultValue}\n              aria-label={state.label}\n              data-agent-hidden=\"\"\n            >\n              <For each={state.options} keyed={(option) => option.value}>\n                {(option) => (\n                  // biome-ignore lint/a11y/noLabelWithoutControl: the label wraps UI SDK's radio, which it names.\n                  <label data-checkpoint-option=\"\">\n                    <KindRadio value={option().value}>\n                      <KindRadioIndicator />\n                    </KindRadio>\n                    {option().label}\n                  </label>\n                )}\n              </For>\n            </KindRadioGroup>\n          </>\n        ))}\n    </parts.Scope>\n  );\n}\n\nexport type CheckpointCompareProps = ComponentProps<typeof parts.Compare>;\n\n/** Calls `onCompare`. Reads \"Compare\" with its icon unless you pass children. Rendered only with `onCompare`. */\nexport function CheckpointCompare(props: CheckpointCompareProps) {\n  return (\n    <parts.Compare {...omit(props, \"children\")}>\n      {props.children ?? (\n        <>\n          <span data-checkpoint-compare-icon=\"\" aria-hidden=\"true\" />\n          Compare\n        </>\n      )}\n    </parts.Compare>\n  );\n}\n\nexport type CheckpointRestoredProps = ComponentProps<typeof parts.Restored>;\n\n/**\n * \"Restored code and conversation\" with a check and what it brought back, in Restore's place once the host restores\n * the checkpoint, unless you pass children.\n */\nexport function CheckpointRestored(props: CheckpointRestoredProps) {\n  return (\n    <parts.Restored {...omit(props, \"children\")}>\n      {props.children ??\n        ((state: { outcome: string; meta: string }) => (\n          <>\n            <span aria-hidden=\"true\" data-status-mark=\"\" data-status=\"complete\" />\n            {state.outcome}\n            <Show when={state.meta}>\n              <span data-checkpoint-outcome-meta=\"\">{state.meta}</span>\n            </Show>\n          </>\n        ))}\n    </parts.Restored>\n  );\n}\n\nexport type CheckpointErrorProps = ComponentProps<typeof parts.Error>;\n\n/** \"Couldn't restore. Try again.\" after a restore fails, unless you pass children. */\nexport function CheckpointError(props: CheckpointErrorProps) {\n  return (\n    <parts.Error {...omit(props, \"children\")}>{props.children ?? \"Couldn't restore. Try again.\"}</parts.Error>\n  );\n}\n\nexport type CheckpointCancelProps = ComponentProps<typeof parts.Cancel>;\n\n/** Closes the dialog. Reads \"Cancel\" unless you pass children. */\nexport function CheckpointCancel(props: CheckpointCancelProps) {\n  return <parts.Cancel {...omit(props, \"children\")}>{props.children ?? \"Cancel\"}</parts.Cancel>;\n}\n\nexport type CheckpointConfirmProps = ComponentProps<typeof parts.Confirm>;\n\n/** Calls `onRestore`. Reads \"Restore\", with a running mark while the restore is pending, unless you pass children. */\nexport function CheckpointConfirm(props: CheckpointConfirmProps) {\n  return (\n    <parts.Confirm {...omit(props, \"children\")}>\n      {\n        // The mark shows only while the restore is pending (controls.css).\n        props.children ?? (\n          <>\n            <span data-kind-pending-mark=\"\" data-status-mark=\"\" data-status=\"running\" aria-hidden=\"true\" />\n            Restore\n          </>\n        )\n      }\n    </parts.Confirm>\n  );\n}\n\nfunction DefaultAnswers() {\n  return (\n    <div data-checkpoint-answers=\"\">\n      <CheckpointCompare />\n      <CheckpointError />\n      <CheckpointCancel />\n      <CheckpointConfirm />\n    </div>\n  );\n}\n\nfunction DefaultParts() {\n  return (\n    <>\n      <CheckpointLabel />\n      <CheckpointDescription />\n      <CheckpointLine />\n      <CheckpointRestore />\n      <CheckpointRestored />\n    </>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/checkpoint.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
