/** @jsx createElement */ import type { ChatRecord, ChatRecordsStore } from '../../../lib/utils'; import type { RecommendItemComponentProps, RecordWithObjectID, Renderer } from '../../../types'; /** * Shared presentational component for chat comparison tables. Used by the * builtin `algolia_compare_products` tool (`CompareProductsTool`). * * Layout: the compared products run across the top (one column each, rendered * with the same item component as the search results so the comparison reads * as a display), and the comparison criteria run down the side (one row each). * * Products are identified by objectID only: the header is hydrated from the * chat records store (the records the search tools fetched or the user * selected), so the model never names a product that isn't in the catalog. * Criteria are model-authored: a label plus one value per product, which lets * the agent compare on aspects that aren't stored as a single attribute (a * feature buried in the description, a derived "best for" verdict, …). A * missing value renders as an explicit marker, never a made-up one. */ export type ComparisonTableTranslations = { /** Text shown in a cell when there is no value for a product. */ missingValueLabel: string; /** Header of the criteria column (top-left corner of the table). */ criteriaColumnLabel: string; }; export declare const defaultComparisonTableTranslations: ComparisonTableTranslations; /** One row of the table: what is compared, and one value per product. */ export type ComparisonCriterion = { /** Model-authored row label, e.g. "Battery life". */ label: string; /** One value per compared product, aligned to `objectIDs`. */ values: unknown[]; }; /** The display name of a product, sourced ONLY from the catalog record. */ export declare function productLabel(hit: ChatRecord | undefined): unknown; /** * Values are arbitrary JSON. Primitives (and arrays of them) have an obvious * textual form; objects (e.g. `price: { value, currency }`) would stringify to * `[object Object]`, so they render as the missing marker instead — an honest * "no displayable value" beats a garbled cell. */ export declare function formatCellValue(value: unknown): string | undefined; export type GroundedComparisonTableProps = { /** Optional model-authored lead-in (prose, rendered above the table). */ intro?: string; /** Products to compare, one column each, referenced by objectID only. */ objectIDs: string[]; /** Comparison rows, each with one value per product. */ criteria: ComparisonCriterion[]; /** The records the chat has collected, keyed by `objectID`. */ records?: Pick; /** * Renders a product in the header. Defaults to the record's name/title so the * header always comes from the catalog, never from the model. */ itemComponent?: (props: RecommendItemComponentProps>) => JSX.Element; sendEvent?: RecommendItemComponentProps>['sendEvent']; translations: ComparisonTableTranslations; }; export declare function createGroundedComparisonTableComponent({ createElement, Fragment }: Renderer): (props: GroundedComparisonTableProps) => JSX.Element;