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 = () =>