'use client'
import {
ChipSelect,
ChipSwitch,
ChipTag,
chipFieldSurfaceClass,
chipFieldTextClass,
cn,
FieldDivider,
Label,
} from '@sim/emcn'
import { BookOpen, Pencil } from 'lucide-react'
import { resolveIcon } from '@/components/workflow-preview/block-icons'
import { formatReferences } from '@/components/workflow-preview/format-references'
type FieldKind = 'select' | 'input' | 'textarea' | 'code' | 'slider' | 'toggle'
interface InspectorField {
label: string
required?: boolean
kind?: FieldKind
/** Shown inside the control. For 'toggle', "on"/"off". For 'slider', the number. */
value?: string
/** Muted placeholder when there's no value. */
placeholder?: string
/** Slider fill, 0–100. */
percent?: number
}
interface InspectorTool {
type: string
name: string
bgColor: string
}
interface BlockInspectorProps {
/** Block name in the header, e.g. "Agent 1". */
name: string
/** Block type, for the header icon. */
type?: string
color?: string
fields: InspectorField[]
tools?: InspectorTool[]
/** Render as a borderless panel filling its parent (the lightbox sidebar). */
embedded?: boolean
}
const NOOP = () => {}
/**
* Read-only facsimile of one configuration field, composed from emcn chip
* chrome: `select`→{@link ChipSelect}, `toggle`→{@link ChipSwitch}; text fields
* (`input`/`textarea`/`code`) render the value with `<...>`/`{{...}}` references
* highlighted via {@link formatReferences} in the canonical chip field surface.
* `slider` has no chip equivalent and stays a minimal app-token bar.
*/
function FieldControl({ field }: { field: InspectorField }) {
const kind = field.kind ?? 'input'
const value = field.value ?? ''
const placeholder = field.placeholder ?? '—'
if (kind === 'select') {
return (