'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),React=require("react"),core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),styles=require("../common/styles.js"),useAccordion=require("../hooks/useAccordion.js"),classes=require("../common/classes.js");const Accordion=({builderProps:e,builderAttrs:s,style:t,children:r,setting:c,styles:i,advanced:a})=>{let{align:l}=i??{},{childItem:n}=c??{},{ref:o,mode:d,accordions:u,handleDropdown:m,activeKey:y}=useAccordion.default({setting:c,children:r,builderProps:e}),p=system.createStyle({...styles.getContainerStyles(t,i)}),j=system.createClass(classes.getContainerClasses(a?.cssClass,d)),x=system.createAttr({...s,"data-id":e?.uid??""}),R=system.createStyle({...core.makeStyleResponsive("jc",l)}),C=system.createClass({"gp-flex":!0}),f=React.useMemo(()=>React.Children.map(r,(s,t)=>{if(!React.isValidElement(s))return s;let r={...s.props,index:t,title:n?.[t],accordions:u,handleDropDown:m,parentSetting:c,parentStyle:i,activeKey:y,childrenIcon:c?.childConfig?.[t],parentUid:e?.uid};return jsxRuntime.jsx("div",{className:C,style:R,children:React.cloneElement(s,r)})}),[u,y,e?.uid,n,r,C,R,m,c,i]);return jsxRuntime.jsx("div",{...x,ref:o,className:j,style:p,children:f})};exports.default=Accordion;
