"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageHeaderActionButtons = PageHeaderActionButtons;
exports.PageHeaderWrapper = PageHeaderWrapper;
exports.PageHeader = PageHeader;
exports.PageHeaderInfoTitle = PageHeaderInfoTitle;
exports.PageHeaderInfoTooltip = PageHeaderInfoTooltip;
exports.PageHeaderCollapsibleInfoTrigger = PageHeaderCollapsibleInfoTrigger;
exports.PageHeaderCollapsibleInfo = PageHeaderCollapsibleInfo;
const jsx_runtime_1 = require("react/jsx-runtime");
const utils_1 = require("../../lib/utils");
const react_1 = require("react");
const collapsible_1 = require("../../components/ui/collapsible");
const button_1 = require("../ui/button");
const lucide_react_1 = require("lucide-react");
const tooltip_1 = require("../../components/ui/tooltip");
const use_toast_1 = require("../../hooks/use-toast");
const react_tooltip_1 = require("@radix-ui/react-tooltip");
const PageHeaderContext = (0, react_1.createContext)({ isOpen: false });
function PageHeaderActionButtons({ className, ...props }) {
    return ((0, jsx_runtime_1.jsx)("div", { "data-slot": "page-header-action-buttons", className: (0, utils_1.cn)('flex items-center gap-8', className), ...props }));
}
function PageHeaderWrapper({ className, ...props }) {
    const { isOpen } = (0, react_1.useContext)(PageHeaderContext);
    return ((0, jsx_runtime_1.jsx)("div", { "data-slot": "page-header-wrapper", className: (0, utils_1.cn)('flex items-start justify-between', isOpen && 'border-b', className), ...props }));
}
function PageHeader({ children, className }) {
    const [isOpen, setIsOpen] = (0, react_1.useState)(false);
    return ((0, jsx_runtime_1.jsx)(PageHeaderContext.Provider, { value: { isOpen }, children: (0, jsx_runtime_1.jsx)("div", { "data-slot": "page-header", className: (0, utils_1.cn)('mt-12', isOpen && 'mb-12'), children: (0, jsx_runtime_1.jsx)(collapsible_1.Collapsible, { open: isOpen, onOpenChange: setIsOpen, className: className, children: children }) }) }));
}
function PageHeaderInfoTitle({ title, subtitle, className, children }) {
    return ((0, jsx_runtime_1.jsxs)("div", { "data-slot": "page-header-info-title", className: "mb-12 flex flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("h1", { className: (0, utils_1.cn)('text-foreground text-4xl font-bold', className), "data-testid": "title", children: title }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-shadcn-400 text-sm font-medium", children: subtitle }), children] })] }));
}
function PageHeaderInfoTooltip({ subtitle }) {
    const { toast } = (0, use_toast_1.useToast)();
    const handleCopyToClipboard = (value) => {
        navigator.clipboard.writeText(value);
        toast({
            description: 'Copied to clipboard!'
        });
    };
    return ((0, jsx_runtime_1.jsx)("div", { "data-slot": "page-header-info-tooltip", children: (0, jsx_runtime_1.jsx)(tooltip_1.TooltipProvider, { children: (0, jsx_runtime_1.jsxs)(tooltip_1.Tooltip, { delayDuration: 300, children: [(0, jsx_runtime_1.jsx)(tooltip_1.TooltipTrigger, { onClick: () => handleCopyToClipboard(subtitle), children: (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { size: 16, className: "cursor-pointer" }) }), (0, jsx_runtime_1.jsxs)(tooltip_1.TooltipContent, { className: "bg-shadcn-600 border-none", arrowPadding: 0, children: [(0, jsx_runtime_1.jsx)("p", { className: "text-shadcn-400 text-sm font-medium", children: subtitle }), (0, jsx_runtime_1.jsx)("p", { className: "text-center text-white", children: "Click to copy" }), (0, jsx_runtime_1.jsx)(react_tooltip_1.Arrow, { height: 8, width: 15 })] })] }) }) }));
}
function PageHeaderCollapsibleInfoTrigger({ question }) {
    return ((0, jsx_runtime_1.jsx)("div", { "data-slot": "page-header-collapsible-info-trigger", children: (0, jsx_runtime_1.jsx)(collapsible_1.CollapsibleTrigger, { asChild: true, children: (0, jsx_runtime_1.jsxs)(button_1.Button, { variant: "link", className: "flex gap-2 pr-0", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-foreground text-sm font-medium", children: question }), (0, jsx_runtime_1.jsx)(lucide_react_1.HelpCircle, { className: "h-4 w-4" })] }) }) }));
}
function PageHeaderCollapsibleInfo({ question, answer, seeMore, href }) {
    return ((0, jsx_runtime_1.jsx)("div", { "data-slot": "page-header-collapsible-info", children: (0, jsx_runtime_1.jsx)(collapsible_1.CollapsibleContent, { children: (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full justify-between pt-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mt-12 flex grow flex-col gap-3 pr-6", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-foreground text-xl font-bold", children: question }), (0, jsx_runtime_1.jsxs)("p", { className: "text-shadcn-500 text-sm leading-relaxed font-medium", children: [answer, seeMore && href && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [' ', (0, jsx_runtime_1.jsxs)("a", { target: "_blank", rel: "noopener noreferrer", href: href, className: "text-shadcn-600 dark:text-shadcn-400 font-medium", children: [(0, jsx_runtime_1.jsx)("span", { className: "underline underline-offset-4", children: seeMore }), (0, jsx_runtime_1.jsx)(lucide_react_1.ExternalLink, { size: 16, className: "ml-1 inline align-middle" })] })] }))] })] }), (0, jsx_runtime_1.jsx)(collapsible_1.CollapsibleTrigger, { asChild: true, children: (0, jsx_runtime_1.jsx)(button_1.Button, { variant: "link", className: "cursor-pointer self-start", children: (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronUp, { size: 24, className: "text-shadcn-500" }) }) })] }) }) }));
}
