"use strict";const l=require("react/jsx-runtime"),e=require("react"),B=require("./accordion-basic.cjs"),_=require("./accordion-body.cjs"),H=require("./accordion-header.cjs"),O=require("./accordion-item.cjs"),p=function(h){const{alwaysOpen:t,as:w="div",collapsing:C,onChange:r,options:A,...f}=h,k=(A??[]).map((o,c)=>({...o,collapsed:o.collapsed===void 0?!1:o.collapsed,id:o.id??c,show:o.show===void 0?!0:o.show})),[u,q]=e.useState(k),[s,b]=e.useState(u.find(o=>!o.collapsed&&o.show)),j=e.useCallback(o=>{b(o)},[]),v=e.useCallback(o=>{q(c=>c.map((n,i)=>{let a,d;return i===o?(a=!n.collapsed,d=!n.show):t?(a=n.collapsed,d=n.show):(a=i!==o,d=i===o),{...n,collapsed:a,show:d}}))},[t]),y=e.useCallback(o=>{const c=s==null?void 0:s.id;c!==void 0&&(r==null||r(c,o))},[s==null?void 0:s.id,r]);return l.jsx(B.AccordionBasic,{as:w,...f,children:u.map((o,c)=>l.jsxs(O.AccordionItem,{children:[l.jsx(H.AccordionHeader,{buttonProps:{onClick:()=>{j(o),v(c)}},collapsed:o.collapsed,children:o.header}),l.jsx(_.AccordionBody,{collapsing:C,onChange:y,show:o.show,children:o.body})]},o.id))})};p.displayName="BRL.Accordion";exports.Accordion=p;
//# sourceMappingURL=accordion.cjs.map
