import { BookOpen, Code2, MousePointer2, Play, SlidersHorizontal, X } from 'lucide-react'
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
import { useStudioLanguage } from '@/i18n'
const runtimeInstallExample = 'npm install @bible-strong/avatar-react react react-dom'
const webInstallExample = 'npm install @bible-strong/avatar-web'
const webAvatarExample = (
animationKey: string | undefined
) => `import { createAvatar } from '@bible-strong/avatar-web'
import definition from './avatar.avatar.json'
const avatar = createAvatar('#avatar', {
definition,
${animationKey ? `defaultAnimation: '${animationKey}',` : `defaultExpression: 'neutral',`}
})
avatar.play(${animationKey ? `'${animationKey}'` : `'idle'`})
avatar.pause()
avatar.setExpression('neutral')
avatar.stop()`
const nativeBrowserExample = `
`
const createAvatarExample = (
animationKey: string | undefined
) => `import { createAvatar } from '@bible-strong/avatar-react'
import '@bible-strong/avatar-react/styles.css'
import avatarJson from './avatar.avatar.json'
const StrobiAvatar = createAvatar(avatarJson)
export function Strobi() {
return
}`
const genericAvatarExample = `import { Avatar } from '@bible-strong/avatar-react'
import type { AvatarDefinition, ExpressionKey } from '@bible-strong/avatar-core'
import '@bible-strong/avatar-react/styles.css'
export function DynamicAvatar({
definition,
expression,
}: {
definition: AvatarDefinition
expression: ExpressionKey
}) {
return (
console.error(error)}
/>
)
}`
const imperativeExample = (
animationKey: string | undefined
) => `import { createAvatar, type AvatarController } from '@bible-strong/avatar-react'
import { useRef } from 'react'
import avatarJson from './avatar.avatar.json'
const StrobiAvatar = createAvatar(avatarJson)
export function Controls() {
const avatar = useRef(null)
return <>
${
animationKey
? `
`
: ''
}
>
}`
const codeTokenPattern =
/(\/\/.*|'.*?'|".*?"|@[a-z0-9-/]+|<\/?[A-Z][A-Za-z]*|\b(?:npm|install|import|from|const|if|throw|new|export|function|return|onClick|ref|useRef)\b)/g
const highlightedCode = (source: string) =>
source.split(codeTokenPattern).map((token, index) => {
if (!token) return null
const kind = token.startsWith('//')
? 'comment'
: token.startsWith("'") || token.startsWith('"') || token.startsWith('@')
? 'string'
: token.startsWith('<')
? 'tag'
: /^(?:npm|install|import|from|const|if|throw|new|export|function|return|onClick|ref|useRef)$/.test(
token
)
? 'keyword'
: 'plain'
return (
{token}
)
})
function GuideCode({ children }: { children: string }) {
return (
{highlightedCode(children)}
)
}
function PropRow({ name, type, description }: { name: string; type: string; description: string }) {
return (
{name}
{type}
{description}
)
}
export function RuntimeGuideDialog({
animationKey,
integration = 'react',
onOpenChange,
open,
}: {
animationKey?: string
integration?: 'react' | 'javascript'
onOpenChange: (open: boolean) => void
open: boolean
}) {
const { t } = useStudioLanguage()
return (
)
}