"use strict";const s=require("react/jsx-runtime"),o=require("react"),y=require("../tools/tools.cjs"),z=require("./table-caption.cjs"),L=require("./table-responsive.cjs"),M=require("./table-tbody.cjs"),W=require("./table-td.cjs"),A=require("./table-tfoot.cjs"),R=require("./table-th.cjs"),G=require("./table-thead.cjs"),C=require("./table-tr.cjs"),X=a=>y.isPlainObject(a)&&!o.isValidElement(a),O=(a=[])=>a.map((i,l)=>({...i,id:i.id??l})),Y=(a,i,l,h,c,b)=>{const r=`${i.key??i.id}${l.id}`,t=X(a),d=t?a.colSpan:void 0,v=t?a.rowSpan:void 0,u=t?a.variant:void 0,f=t?a.active:void 0,P=t?a.thProps:void 0,q=t?a.tdProps:void 0,j=t?a.value:a;return b&&c===0?o.createElement(R.TableTh,{...P,active:f,colSpan:d,key:r,rowSpan:v,scope:l.scope,variant:u},j):o.createElement(W.TableTd,{...q,active:f,colSpan:d,key:r,rowSpan:v,variant:u},j)},x=({headOptions:a,rowIndex:i,rowItem:l,type:h="values"})=>a.map((c,b)=>{const r=l[h],t=r.find(d=>"key"in c&&y.isPlainObject(d)&&d.key===c.key)??r[b];return t?Y(t,c,l,i,b,l.scope==="row"):null}),n=function(i){const{as:l="table",body:h=[],bodyProps:c,bordered:b,borderless:r,caption:t,captionProps:d,className:v,dropOldClass:u,foot:f=[],footProps:P,head:q=[],headProps:j,hover:S,middle:g,responsive:E,responsiveProps:H,size:_,striped:B,stripedColumns:$,style:D,variables:N,variant:k,...J}=i,[T]=o.useState(O(q)),[F]=o.useState(O(f)),[K]=o.useState(O(h)),Q=o.useMemo(()=>{const e=y.classx(!u&&"table",k&&`table-${k}`,B&&"table-striped",$&&"table-striped-columns",S&&"table-hover",b&&"table-bordered",r&&"table-borderless",_&&`table-${_}`,g&&"table align-middle",v),p=y.stylex((Z,U)=>({tKey:y.convertBsKeyToVar(U)}),N,D);return{className:e,style:p}},[b,r,v,u,S,g,_,B,$,D,N,k]),V=s.jsxs(l,{...J,...Q,children:[t&&s.jsx(z.TableCaption,{...d,children:t}),T.length>0&&s.jsx(G.TableThead,{...j,children:s.jsx(C.TableTr,{children:T.map(e=>o.createElement(R.TableTh,{...e.props,active:e.active,key:e.key??e.id,scope:e.scope,variant:e.variant},e.label))})}),K.length>0&&s.jsx(M.TableTbody,{...c,children:K.map((e,p)=>o.createElement(C.TableTr,{...e.props,active:e.active,key:e.id,variant:e.variant},e.values?s.jsx(x,{headOptions:T,rowIndex:p,rowItem:e,type:"values"}):e.cells?s.jsx(x,{headOptions:T,rowIndex:p,rowItem:e,type:"cells"}):s.jsx(s.Fragment,{})))}),F.length>0&&s.jsx(A.TableTfoot,{...P,children:F.map((e,p)=>o.createElement(C.TableTr,{...e.props,active:e.active,key:e.id,variant:e.variant},e.values?s.jsx(x,{headOptions:T,rowIndex:p,rowItem:e,type:"values"}):e.cells?s.jsx(x,{headOptions:T,rowIndex:p,rowItem:e,type:"cells"}):s.jsx(s.Fragment,{})))})]});return E?s.jsx(L.TableResponsive,{...H,responsive:E,children:V}):V};n.Caption=z.TableCaption;n.Responsive=L.TableResponsive;n.Tbody=M.TableTbody;n.Td=W.TableTd;n.Tfoot=A.TableTfoot;n.Th=R.TableTh;n.Thead=G.TableThead;n.Tr=C.TableTr;n.displayName="BRL.Table";exports.Table=n;
//# sourceMappingURL=table.cjs.map
