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