import { html, nothing } from "lit";
import { classMap } from "lit/directives/class-map.js";
import { when } from "lit/directives/when.js";
import { renderCopyButton } from "./copy-button.js";
import { renderFeedbackButton } from "./feedback-button.js";
import { hasClipboardSupport } from "./generated-answer-utils.js";
const renderFeedbackAndCopyButtons = ({ props })=>{
    const { i18n, generatedAnswerActionsState, copied, copyError, getCopyToClipboardTooltip, onClickLike, onClickDislike, onCopyToClipboard } = props;
    const { liked, disliked, answer, isStreaming, isLoading } = generatedAnswerActionsState ?? {};
    const shouldShowButtons = !!answer && !isStreaming && !isLoading;
    return html`${when(shouldShowButtons, ()=>html`
      <div
        class="${classMap({
            'feedback-buttons flex h-9 items-center shrink-0 gap-2': true
        })}"
      >
        ${renderFeedbackButton({
            props: {
                title: i18n.t('this-answer-was-helpful'),
                variant: 'like',
                active: !!liked,
                onClick: onClickLike
            }
        })}
        ${renderFeedbackButton({
            props: {
                title: i18n.t('this-answer-was-not-helpful'),
                variant: 'dislike',
                active: !!disliked,
                onClick: onClickDislike
            }
        })}
        ${hasClipboardSupport() ? renderCopyButton({
            props: {
                title: getCopyToClipboardTooltip(),
                isCopied: copied,
                error: copyError,
                onClick: async ()=>{
                    if (answer) await onCopyToClipboard(answer);
                }
            }
        }) : nothing}
      </div>
    `)}`;
};
export { renderFeedbackAndCopyButtons };
