"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatbotFootnote = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
// Import Patternfly components
const react_core_1 = require("@patternfly/react-core");
// Import Patternfly icons
const info_circle_icon_1 = require("@patternfly/react-icons/dist/esm/icons/info-circle-icon");
const external_link_alt_icon_1 = require("@patternfly/react-icons/dist/esm/icons/external-link-alt-icon");
// Import Chatbot components
const ChatbotPopover_1 = __importDefault(require("../ChatbotPopover/ChatbotPopover"));
const ChatbotFootnote = (_a) => {
    var _b, _c, _d, _e, _f;
    var { label, popover, className } = _a, props = __rest(_a, ["label", "popover", "className"]);
    // Popover visibility state
    const [isVisible, setIsVisible] = (0, react_1.useState)(false);
    // Define popover body content
    const popoverBodyContent = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(popover === null || popover === void 0 ? void 0 : popover.bannerImage) && (0, jsx_runtime_1.jsx)("img", { src: popover.bannerImage.src, alt: popover.bannerImage.alt }), (0, jsx_runtime_1.jsx)(react_core_1.Content, { component: react_core_1.ContentVariants.h3, children: popover === null || popover === void 0 ? void 0 : popover.title }), (0, jsx_runtime_1.jsx)(react_core_1.Content, { component: react_core_1.ContentVariants.p, children: popover === null || popover === void 0 ? void 0 : popover.description })] }));
    // Define popover footer content
    const popoverFooterContent = ((0, jsx_runtime_1.jsxs)(react_core_1.Flex, { gap: { default: 'gapSm' }, children: [(popover === null || popover === void 0 ? void 0 : popover.cta) && ((0, jsx_runtime_1.jsx)(react_core_1.Button, { variant: "secondary", onClick: () => {
                    var _a;
                    setIsVisible(false);
                    (_a = popover.cta) === null || _a === void 0 ? void 0 : _a.onClick();
                }, children: ((_b = popover.cta) === null || _b === void 0 ? void 0 : _b.label) || 'Dismiss' })), (popover === null || popover === void 0 ? void 0 : popover.link) && ((0, jsx_runtime_1.jsx)(react_core_1.Button, { variant: "link", component: "a", href: popover.link.url, target: "_blank", icon: (0, jsx_runtime_1.jsx)(external_link_alt_icon_1.ExternalLinkAltIcon, {}), iconPosition: "end", children: popover.link.label }))] }));
    return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `pf-chatbot__footnote ${className !== null && className !== void 0 ? className : ''}` }, props, { children: [popover && ((0, jsx_runtime_1.jsx)(ChatbotPopover_1.default, Object.assign({ className: "pf-chatbot__popover--footnote", "aria-label": ((_c = popover.popoverProps) === null || _c === void 0 ? void 0 : _c['aria-label']) || 'More information', isVisible: isVisible, shouldOpen: (_event, _fn) => setIsVisible(true), shouldClose: (_event, _fn) => setIsVisible(false), bodyContent: popoverBodyContent, footerContent: popoverFooterContent, minWidth: ((_d = popover.popoverProps) === null || _d === void 0 ? void 0 : _d.minWidth) || '432', maxWidth: ((_e = popover.popoverProps) === null || _e === void 0 ? void 0 : _e.maxWidth) || '432', distance: ((_f = popover.popoverProps) === null || _f === void 0 ? void 0 : _f.distance) || 16, showClose: false }, popover.popoverProps, { children: (0, jsx_runtime_1.jsxs)(react_core_1.Button, { variant: "link", size: "sm", children: [label, " ", (0, jsx_runtime_1.jsx)(info_circle_icon_1.InfoCircleIcon, {})] }) }))), !popover && (0, jsx_runtime_1.jsx)(react_core_1.Content, { component: react_core_1.ContentVariants.small, children: label })] })));
};
exports.ChatbotFootnote = ChatbotFootnote;
exports.default = exports.ChatbotFootnote;
