"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("lodash-unified"),f=require("vue"),q=require("../../ap-grid/utils/col.js"),x=require("../../ap-table/utils.js");require("../../config-provider/index.js");require("../../utils/index.js");require("../components/body-cell/index.vue.js");require("../components/header-cell/index.vue.js");require("../components/tooltip/index.vue.js");const C=require("../renderer/index.js"),R=require("../utils.js"),k=require("../../config-provider/hooks/use-global-config.js"),I=require("../../config-provider/hooks/use-namespace.js"),P=require("../components/body-cell/index.vue2.js"),G=require("../components/tooltip/index.vue2.js"),M=require("../../utils/is.js"),g=require("../components/header-cell/index.vue2.js");function V(t){return u.isNumber(t)&&t>1}function F(t,s){return c=>({...u.isFunction(s)?s(c):s??{},...t})}function N(t,s){if(s.bodyCellTooltip)return u.isFunction(s.bodyCellTooltip)?s.bodyCellTooltip(t.value,t.data):s.bodyCellTooltip;if(s.renderText)return s.renderText({value:t.value,record:t.data,column:s,text:t.value});const c=s.valueType||"text",p=C.rendererMap[c];if(p){const y=x.getTableRenderProps({...s,valueType:c},{value:t.value,text:t.value,record:t.data,column:t.column,rowIndex:t.node?.rowIndex,pinned:t.node?.rowPinned});return p(y)}return x.objectToString(t.value)}const K=(t,s,c,p)=>{const T=k.useGlobalConfig("valueTypeMap"),y=f.ref(),{em:b}=I.useNamespace("ag-grid"),w=r=>{const l={cellRenderer:P.default,cellRendererParams:{column:r,extraValueType:f.unref(T),rowKey:s.rowKey}};if(r.customRender)return l;if(r.renderText)return{valueFormatter:e=>{const o=e.colDef.colId,n=e.context.masks||{},d=o?n[o]:!1;return r.renderText({value:e.value,record:e.data,column:r,text:e.value,maskVisible:d})}};const a=r.valueType||"text",i=C.rendererMap[a];return i?{valueFormatter:e=>{const o=e.colDef.colId,n=e.context.masks||{};if(o?n[o]:!1)return"****";const v=x.getTableRenderProps({...r,valueType:a},{value:e.value,text:e.value,record:e.data,column:e.column,rowIndex:e.node?.rowIndex,pinned:e.node?.rowPinned});return i(v)}}:l},h=r=>{const l=r.valueType||"text",a=C.rendererMap[l],i={},e=r.bodyCellTooltip||!r.customRender&&a&&(r.ellipsis===!0||r.ellipsis==="tooltip"||u.isNumber(r.ellipsis)),o=u.isNumber(r.ellipsis)&&r.ellipsis>1,n=u.isNumber(r.ellipsis)?r.ellipsis:1;return i.tooltipValueGetter=e?d=>N(d,r):void 0,i.wrapText=!r.ellipsis||o,i.cellStyle=F({"--ag-grid-line-clamp":n},r.cellStyle),i.tooltipComponent=G.default,i.tooltipComponentParams={lineClamp:n,gridWrapperRef:y},i},_=(r,l)=>{const a=l.colKey&&r.key===l.colKey;if(!(l.rowDragEntireRow||!a))return l.rowDragCallback??!0},D=f.computed(()=>{const r=f.unref(t),l=R.getRowDragConfig(s.rowDrag);function a(i){return i.map(e=>{const o={field:q.dataIndexToField(e.dataIndex),colId:M.isDef(e.key)?String(e.key):void 0,sortable:!!e.sorter,comparator:e.sorter===!0?()=>0:e.sorter,headerComponentParams:{column:e,headerCell:p},resizable:e.resizable,width:e.width,minWidth:e.minWidth,maxWidth:e.maxWidth,suppressKeyboardEvent:()=>!0,flex:e.width?void 0:e.flex??1,pinned:e.fixed||null,colSpan:e.colSpan,spanRows:e.spanRows,cellClass:c(n=>{const d=e.cellClass||"",v=u.isFunction(d)?d(n.data,n.node):d;return[`${b("cell",e.align||"left")}`,V(e.ellipsis)?b("cell","multiline"):null,v].flat().filter(Boolean)}),cellStyle:e.cellStyle,headerStyle:e.headerStyle,headerClass:e.headerClass,columnGroupShow:e.columnGroupShow,autoHeight:!0,rowDrag:_(e,l),...h(e),...w(e)};return e.children?.length?{...o,headerGroupComponent:g.default,headerGroupComponentParams:{column:e,headerCell:p},children:a(e.children)}:o})}return a(r)}),S=f.computed(()=>({headerComponent:g.default,resizable:s.columnResizable,suppressMovable:!0,cellDataType:!1}));return{columnDefs:D,defaultColDef:S,gridWrapperRef:y}};exports.useColumnsDef=K;
