import React, { useState } from 'react' import { __, sprintf } from '@wordpress/i18n' import classnames from 'classnames' import { DEMO_EXAMPLES } from './demoScript' import { hasReached } from './types' import type { DemoStage } from './types' type DemoSidebarTab = 'actions' | 'history' interface DemoQuotaWindow { label: string used: number limit: number } /** Sample usage, so the meters the real agent shows have something to draw. */ const DEMO_QUOTA: readonly DemoQuotaWindow[] = [ { label: __('Today', 'code-snippets'), used: 2, limit: 25 }, { label: __('This month', 'code-snippets'), used: 34, limit: 300 } ] const FULL_PERCENT = 100 /** Conversations the scripted library already holds when the demo opens. */ const PAST_CONVERSATIONS: readonly string[] = [ __('Hide the admin bar for subscribers', 'code-snippets'), __('Custom login screen logo', 'code-snippets') ] interface DemoStatus { label: string modifier?: string } /** * How the conversation the walkthrough is having would be labelled in the * history rail at each point of the script. */ const currentStatus = (stage: DemoStage): DemoStatus => { if ('applying' === stage) { return { label: __('Updating', 'code-snippets') } } if (hasReached(stage, 'result-ready')) { return { label: __('Completed', 'code-snippets'), modifier: 'is-done' } } if (hasReached(stage, 'building')) { return { label: __('Building', 'code-snippets') } } if (hasReached(stage, 'plan-ready')) { return { label: __('Plan ready', 'code-snippets'), modifier: 'is-plan' } } return { label: __('Planning', 'code-snippets') } } const DemoQuota: React.FC = () =>

{__('AI usage', 'code-snippets')}

{DEMO_QUOTA.map(({ label, used, limit }) =>
{label} {sprintf( /* translators: 1: used count, 2: limit count. */ __('%1$d / %2$d', 'code-snippets'), used, limit )}
)}
const DemoHistory: React.FC<{ stage: DemoStage }> = ({ stage }) => { const status = currentStatus(stage) return (
) } interface DemoTabProps { tab: DemoSidebarTab current: DemoSidebarTab label: string onSelect: (tab: DemoSidebarTab) => void } const DemoTab: React.FC = ({ tab, current, label, onSelect }) => /** * The sidebar the real agent uses, rendered inert. Only the tabs respond: the * prompt chips, usage meters and conversation list are here for the shape of * the page, not to be operated. */ export const DemoSidebar: React.FC<{ stage: DemoStage }> = ({ stage }) => { const [tab, setTab] = useState('actions') return ( ) }