import { jsx as _jsx } from "react/jsx-runtime";
import { getClassNames } from '@websolutespa/bom-core';
import { useLabel } from '@websolutespa/bom-mixer-hooks';
import { IconLlmArrowRight } from '@websolutespa/bom-mixer-icons';
import { Cta, useLlm, useLlmView } from '@websolutespa/bom-mixer-llm';
import style from './action.module.scss';
export const Action = (props)=>{
    const { item } = props;
    const label = useLabel();
    const { onAction } = useLlm((state)=>state.actions);
    const { open } = useLlmView((state)=>state.actions);
    const dismissable = useLlmView((state)=>state.dismissable);
    const onAction_ = async (event)=>{
        // console.log('Action.onAction', props.id);
        const shouldClose = await onAction(item);
        if (dismissable && shouldClose !== false) {
            open();
        }
    };
    const classNames = getClassNames(style.action, {
        [`llm__action--${item.type}`]: !!item.type
    });
    return /*#__PURE__*/ _jsx(Cta, {
        type: "button",
        className: classNames,
        label: item.title || label('llm.tellMeMore'),
        icon: /*#__PURE__*/ _jsx(IconLlmArrowRight, {}),
        onClick: onAction_
    });
};

//# sourceMappingURL=action.js.map