/**
 * Context provider for the info-tile component.
 *
 * This provider contributes contextual information about an info tile
 * to the AI chat feature, including the limetype, filter, aggregation
 * method, and current value.
 *
 * @alpha
 */
export class InfoTileContextProvider {
    /**
     * Create an InfoTileContextProvider.
     *
     * @param getState - Function that returns the current tile state
     */
    constructor(getState) {
        this.getState = getState;
        this.contextType = 'info-tile';
    }
    getContext() {
        const { limetype, filterId, filterName, aggregateOperator, propertyName, value, label, } = this.getState();
        if (!limetype || !filterId) {
            console.debug('InfoTileContextProvider: No limetype or filterId available');
            return null;
        }
        const data = {
            widgetType: 'info-tile',
            limetype,
            filterId,
        };
        if (filterName) {
            data.filterName = filterName;
        }
        data.aggregateOperator = aggregateOperator;
        if (propertyName) {
            data.propertyName = propertyName;
        }
        if (value !== undefined) {
            data.value = value;
        }
        if (label) {
            data.label = label;
        }
        return {
            data,
            purpose: 'Shows an aggregated value from a filter. ' +
                'Clicking navigates to the explorer with that filter applied.',
        };
    }
}
