import{computed as m,createVNode as U}from"vue";import{customRenderSlot as X}from"../../_util/vnode.mjs";import{useInjectSlots as $}from"../../table/context.mjs";import{EXPAND_COLUMN as a}from"../constant.mjs";import{INTERNAL_COL_DEFINE as b}from"../utils/legacyUtil.mjs";function x(o){return o.reduce((l,n)=>{const{fixed:r}=n,u=r===!0?"left":r,i=n.children;return i&&i.length>0?[...l,...x(i).map(f=>({fixed:u,...f}))]:[...l,{...n,fixed:u}]},[])}function j(o){return o.map(l=>{const{fixed:n,...r}=l;let u=n;return n==="left"?u="right":n==="right"&&(u="left"),{fixed:u,...r}})}function H({prefixCls:o,columns:l,expandable:n,expandedKeys:r,getRowKey:u,onTriggerExpand:i,expandIcon:f,rowExpandable:w,expandIconColumnIndex:d,direction:R,expandRowByClick:V,expandColumnWidth:y,expandFixed:s},C){const L=$(),O=m(()=>{if(n.value){let e=l.value.slice();if(!e.includes(a)){const t=d.value||0;t>=0&&e.splice(t,0,a)}const h=e.indexOf(a);e=e.filter((t,p)=>t!==a||p===h);const g=l.value[h];let c;(s.value==="left"||s.value)&&!d.value?c="left":(s.value==="right"||s.value)&&d.value===l.value.length?c="right":c=g?g.fixed:null;const _=r.value,E=w.value,A=f.value,D=o.value,S=V.value,T={[b]:{class:`${o.value}-expand-icon-col`,columnType:"EXPAND_COLUMN"},title:X(L.value,"expandColumnTitle",{},()=>[""]),fixed:c,class:`${o.value}-row-expand-icon-cell`,width:y.value,customRender:({record:t,index:p})=>{const k=u.value(t,p),I=_.has(k),K=E?E(t):!0,N=A({prefixCls:D,expanded:I,expandable:K,record:t,onExpand:i});return S?U("span",{onClick:M=>M.stopPropagation()},[N]):N}};return e.map(t=>t===a?T:t)}return l.value.filter(e=>e!==a)}),v=m(()=>{let e=O.value;return C.value&&(e=C.value(e)),e.length||(e=[{customRender:()=>null}]),e}),P=m(()=>R.value==="rtl"?j(x(v.value)):x(v.value));return[v,P]}export{H as default};
