import type { Asset } from './Asset'; import { isPlaceableType } from './AssetTypes'; import { containerReaches } from './container'; import type { ObjectHolder, Project } from './Project'; /** * Why `asset` cannot be placed into `holder`, or '' when it can. A drag needs the answer while * it hovers, `PlaceAssetCommand` needs it at the drop; both ask here so the preview cannot * promise a placement the command then refuses. */ export function placementRejection(project: Project, holder: ObjectHolder, asset: Asset): string { if (!isPlaceableType(asset.type)) return 'A scene cannot be placed into a scene'; if (asset.type === 'container' && containerReaches(project, asset, holder.id)) return `${asset.name} cannot contain ${holder.name}: that nests forever`; return ''; }