"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),c=require("../utils.js"),y=r=>{const o=u.ref([]),l=u.ref(),a=u.ref([]);function s(t=[]){return t.filter(e=>!e.hideInTable).map(e=>{if(e.children?.length){const n=s(e.children);return n?.length?{...e,children:n}:null}return e}).filter(Boolean)}function f(t){return o.value.find(e=>c.getStringKey(e.key)===t)}function i(t){const e=[];for(const n of t)n.children?.length?e.push(...i(n.children)):e.push(c.getStringKey(n.key));return e.filter(Boolean)}const m=u.computed(()=>i(o.value));async function h(t,e){return await c.runPipelineHooks(r.plugins,t,n=>n.beforeColumnsChange?.bind(n),e)}u.watch(()=>r.columns,async()=>{const t=s(r.columns);l.value=h(t,o.value);const e=await l.value;o.value=e,a.value=e,r.onShownColumnsChange?.(e)},{deep:!0,immediate:!0});function d(t){for(const e of t)if(e.children){const n=d(e.children);if(n)return n}else if(e.defaultSortOrder){const n=e.field??e.dataIndex??e.key;return{colKey:e.key,field:n,order:e.defaultSortOrder}}}const g=u.computed(()=>d(s(r.columns)));return{columns:o,shownColumns:a,columnKeys:m,getTargetColumnByKey:f,defaultSortOrder:g,getColKeys:i,awaitedColumns:l}};exports.useColumns=y;
