"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Panel", {
    enumerable: true,
    get: function() {
        return Panel;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _collapsible = require("../collapsible");
const _collapseContext = require("./collapseContext");
const _css = require("../../utils/css");
const _lucidereact = require("lucide-react");
const Panel = (props)=>{
    const { activeKey, setActiveKey } = (0, _collapseContext.useCollapseContext)();
    const header = (0, _react.useMemo)(()=>{
        if (typeof props.header === "string") {
            return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: (0, _css.cn)("orderly-py-2 orderly-border-b orderly-border-divider flex items-center orderly-group orderly-cursor-pointer", props.headerClassName),
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                        className: "orderly-flex-1 group-data-[state=open]:orderly-font-semibold",
                        children: props.header
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_lucidereact.ChevronDown, {
                        size: 16,
                        className: "group-data-[state=open]:orderly-rotate-180 orderly-transition-transform"
                    })
                ]
            });
        }
        return props.header;
    }, [
        props.header,
        props.headerClassName
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_collapsible.Collapsible, {
        disabled: props.disabled,
        open: props.itemKey === activeKey,
        onOpenChange: (open)=>{
            if (open) {
                setActiveKey(props.itemKey);
            } else {
                setActiveKey("");
            }
        },
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_collapsible.CollapsibleTrigger, {
                asChild: true,
                children: header
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_collapsible.CollapsibleContent, {
                className: "orderly-py-3",
                children: props.children
            })
        ]
    });
};

//# sourceMappingURL=panel.js.map