/*
 * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import classNames from "classnames";
import * as React from "react";
import { ActionButton } from "../base-components/action-button/ActionButton.js";
import { Callout } from "../base-components/callout/Callout.js";
import { AipAgentChatComposer } from "./components/AipAgentChatComposer.js";
import { AipAgentChatMessageList } from "./components/AipAgentChatMessageList.js";
import styles from "./AipAgentChat.module.css.js";
/**
 * OSDK-agnostic chat surface. Manages conversation state, streaming UI,
 * and error display internally; the consumer provides the current state
 * and callbacks for sending messages and managing state.
 */
export const BaseAipAgentChat = /*#__PURE__*/React.memo(function ({
  messages,
  status,
  error,
  onSendMessage,
  onStop,
  onClearError,
  composerFooter,
  className,
  placeholder = "Type a message...",
  enableAutoScroll = true,
  renderEmptyState,
  renderMessage
}) {
  const isInFlight = status === "submitted" || status === "streaming";
  return /*#__PURE__*/React.createElement("div", {
    className: classNames(styles.chat, className)
  }, error != null && /*#__PURE__*/React.createElement(Callout, {
    actions: /*#__PURE__*/React.createElement(ActionButton, {
      onClick: onClearError,
      type: "button"
    }, "Dismiss"),
    intent: "error",
    title: "Something went wrong"
  }, error.message.length > 0 ? error.message : "An unknown error occurred. Try again, or dismiss to keep the conversation."), /*#__PURE__*/React.createElement(AipAgentChatMessageList, {
    enableAutoScroll: enableAutoScroll,
    isStreaming: isInFlight,
    messages: messages,
    renderEmptyState: renderEmptyState,
    renderMessage: renderMessage
  }), /*#__PURE__*/React.createElement(AipAgentChatComposer, {
    footerLeft: composerFooter,
    isInFlight: isInFlight,
    onSendMessage: onSendMessage,
    onStop: onStop,
    placeholder: placeholder
  }));
});
//# sourceMappingURL=BaseAipAgentChat.js.map