import type {
SchemaArrayItem,
SchemaNumberNode,
SchemaObjectField,
SchemaStringNode,
SchemaUnionOption,
} from '@sanity/presentation-comlink'
import {
BlockContentIcon,
CheckmarkCircleIcon,
CubeIcon,
ImageIcon,
NumberIcon,
StringIcon,
ThListIcon,
} from '@sanity/icons'
type Option =
| SchemaNumberNode
| SchemaStringNode
| SchemaArrayItem
| SchemaObjectField
| SchemaUnionOption
export function getNodeIcon(option: Option | undefined): React.JSX.Element {
if (!option) return
if (option.type === 'string') {
return
}
if (option.type === 'number') {
return
}
const {value: node} = option
if ('icon' in option && option.icon) {
return
}
const {type} = node
if (type === 'string') {
return
}
if (type === 'boolean') {
return
}
if (type === 'number') {
return
}
if (type === 'array' || type === 'union') {
const of = Array.isArray(node.of) ? node.of : [node.of]
if (of.some((n) => 'name' in n && n.name === 'block')) {
return
}
return
}
if (type === 'object') {
if (option.name === 'image') {
return
}
if (option.name === 'block') {
return
}
}
return
}