"use strict";
var import_Accordion = require("../Accordion.css");
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const antd = require("antd");
const kit_internal_ConditionalWrapper = require("./internal/ConditionalWrapper.cjs");
const kit_Theme_UI = require("./Theme/UI.cjs");
require("./Theme/themeUtils.cjs");
require("./Theme/themes.cjs");
const base = "Accordion_base_a76e3";
const css = {
  base
};
const AccordionGroup = ({
  exclusive,
  children,
  openKey,
  defaultOpenKey
}) => {
  const activeProp = openKey !== void 0 ? { activeKey: openKey } : {};
  const defaultActiveKey = defaultOpenKey ? defaultOpenKey : exclusive ? [] : void 0;
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Collapse, { accordion: exclusive, ...activeProp, defaultActiveKey, children });
};
const Accordion = ({
  title,
  children,
  open,
  defaultOpen,
  mountChildren = "once-on-open",
  ...otherProps
}) => {
  const {
    themeSettings: { className: themeClass }
  } = kit_Theme_UI.useTheme();
  const inGroup = "panelKey" in otherProps;
  const key = -1;
  const wrapper = (c) => {
    let collapseProps = {};
    if (defaultOpen !== void 0) {
      collapseProps = { defaultActiveKey: defaultOpen ? key : "" };
    }
    if (open !== void 0) {
      collapseProps = { activeKey: open ? key : "" };
    }
    return /* @__PURE__ */ jsxRuntime.jsx(antd.Collapse, { ...collapseProps, children: c });
  };
  let panelProps = {};
  switch (mountChildren) {
    case "immediately": {
      panelProps = { forceRender: true };
      break;
    }
    case "on-open": {
      panelProps = { destroyInactivePanel: true };
      break;
    }
    case "once-on-open":
    default: {
      panelProps = {};
    }
  }
  return /* @__PURE__ */ jsxRuntime.jsx(kit_internal_ConditionalWrapper.ConditionalWrapper, { condition: !inGroup, wrapper, children: /* @__PURE__ */ React.createElement(
    antd.Collapse.Panel,
    {
      className: [css.base, themeClass].join(" "),
      header: title,
      ...otherProps,
      ...panelProps,
      key
    },
    children
  ) });
};
Accordion.Group = AccordionGroup;
module.exports = Accordion;
