"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("vue"),w=require("../../_util/classNames.js"),S=require("../context/TableContext.js"),h=require("./HeaderRow.js");function b(u){const o=[];function p(t,r,a=0){o[a]=o[a]||[];let c=r;return t.filter(Boolean).map(e=>{const n={key:e.key,class:w.default(e.className,e.class),column:e,colStart:c};let s=1;const l=e.children;return l&&l.length>0&&(s=p(l,c,a+1).reduce((C,m)=>C+m,0),n.hasSubColumns=!0),"colSpan"in e&&({colSpan:s}=e),"rowSpan"in e&&(n.rowSpan=e.rowSpan),n.colSpan=s,n.colEnd=n.colStart+s-1,o[a].push(n),c+=s,s})}p(u,0);const i=o.length;for(let t=0;t<i;t+=1)o[t].forEach(r=>{!("rowSpan"in r)&&!r.hasSubColumns&&(r.rowSpan=i-t)});return o}const y=d.defineComponent({name:"TableHeader",inheritAttrs:!1,props:["columns","flattenColumns","stickyOffsets","customHeaderRow"],setup(u){const o=S.useInjectTable(),p=d.computed(()=>b(u.columns));return()=>{const{prefixCls:i,getComponent:t}=o,{stickyOffsets:r,flattenColumns:a,customHeaderRow:c}=u,f=t(["header","wrapper"],"thead"),e=t(["header","row"],"tr"),n=t(["header","cell"],"th");return d.createVNode(f,{class:`${i}-thead`},{default:()=>[p.value.map((s,l)=>d.createVNode(h.default,{key:l,flattenColumns:a,cells:s,stickyOffsets:r,rowComponent:e,cellComponent:n,customHeaderRow:c,index:l},null))]})}}});exports.default=y;
