import React from 'react' import { Box, Text } from 'ink' import { Surface } from '../../../ui/Surface.js' import { Select } from '../../../ui/Select.js' import { TextInput } from '../../../ui/TextInput.js' import { TextArea } from '../../../ui/TextArea.js' import { theme } from '../../../ui/theme.js' import { normalizeErc8004RegistryConfig } from '../../registry/erc8004.js' import { networkLabel } from '../shared/model/network.js' import type { Step } from '../reducer.js' import { createStepNumber, CREATE_STEP_LABELS } from '../reducer.js' import { WalletApprovalScreen } from '../shared/components/WalletApprovalScreen.js' import { BusyScreen } from '../shared/components/BusyScreen.js' import { StepHeader } from '../shared/components/StepHeader.js' import { PinataJwtInput } from '../shared/components/PinataJwtInput.js' import type { BrowserWalletReady } from '../../wallet/browserWallet.js' type CreateFlowProps = { step: Extract walletSession: BrowserWalletReady | null onSetStep: (step: Step) => void onNameSubmit: (name: string) => void onDescriptionSubmit: (name: string, description: string) => void onCustodySubmit: (custodyMode: 'simple' | 'advanced') => void onRegistrySubmit: (value: string) => void onStorageSubmit: (input: string) => void onBack: () => void onMenu: () => void } export const CreateFlow: React.FC = ({ step, walletSession, onSetStep, onNameSubmit, onDescriptionSubmit, onCustodySubmit, onRegistrySubmit, onStorageSubmit, onBack, onMenu, }) => { const stepNum = createStepNumber(step) const header = (description?: React.ReactNode): React.ReactNode => stepNum > 0 ? : description ?? null if (step.kind === 'replace-confirm') { return ( options={[ { value: 'back', label: 'Keep Current Agent', role: 'utility' }, { value: 'replace', label: 'Mint and Use New Agent' }, ]} hintLayout="inline" onSubmit={choice => { if (choice === 'back') return onMenu() return onSetStep({ kind: 'create-name' }) }} onCancel={onBack} /> ) } if (step.kind === 'create-name') { return ( {step.error ? {step.error} : null} value.trim().length >= 2 ? null : 'name must be at least 2 characters'} onSubmit={name => onNameSubmit(name.trim())} onCancel={onBack} /> ) } if (step.kind === 'create-description') { return (