"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeepThinking = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
// ============================================================================
// Deep Thinking
// ============================================================================
const react_core_1 = require("@patternfly/react-core");
const react_1 = require("react");
const MarkdownContent_1 = __importDefault(require("../MarkdownContent"));
const DeepThinking = ({ body, cardProps, expandableSectionProps, subheading, toggleContent, isDefaultExpanded = true, cardBodyProps, isToggleContentMarkdown, isSubheadingMarkdown, isBodyMarkdown, markdownContentProps, shouldRetainStyles = false }) => {
    const [isExpanded, setIsExpanded] = (0, react_1.useState)(isDefaultExpanded);
    const onToggle = (_event, isExpanded) => {
        setIsExpanded(isExpanded);
    };
    const renderToggleContent = () => {
        if (isToggleContentMarkdown && typeof toggleContent === 'string') {
            return ((0, jsx_runtime_1.jsx)(MarkdownContent_1.default, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: toggleContent }, markdownContentProps)));
        }
        return toggleContent;
    };
    const renderSubheading = () => {
        if (!subheading) {
            return null;
        }
        if (isSubheadingMarkdown) {
            return (0, jsx_runtime_1.jsx)(MarkdownContent_1.default, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: subheading }, markdownContentProps));
        }
        return subheading;
    };
    const renderBody = () => {
        if (!body) {
            return null;
        }
        if (isBodyMarkdown && typeof body === 'string') {
            return (0, jsx_runtime_1.jsx)(MarkdownContent_1.default, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: body }, markdownContentProps));
        }
        return body;
    };
    return ((0, jsx_runtime_1.jsx)(react_core_1.Card, Object.assign({ isCompact: true, className: "pf-chatbot__deep-thinking" }, cardProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.CardBody, Object.assign({}, cardBodyProps, { children: (0, jsx_runtime_1.jsx)(react_core_1.ExpandableSection, Object.assign({ toggleContent: renderToggleContent(), onToggle: onToggle, isExpanded: isExpanded, isIndented: true, className: "pf-chatbot__deep-thinking-expandable-section" }, expandableSectionProps, { children: (0, jsx_runtime_1.jsxs)("div", { className: "pf-chatbot__deep-thinking-section", children: [subheading && ((0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__deep-thinking-subheading", children: (0, jsx_runtime_1.jsx)("span", { children: renderSubheading() }) })), body && (0, jsx_runtime_1.jsx)("div", { className: "pf-chatbot__deep-thinking-body", children: renderBody() })] }) })) })) })));
};
exports.DeepThinking = DeepThinking;
exports.default = exports.DeepThinking;
