/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require('./DataTable.css');const e=require("vue"),t=require("../../../node_modules/@tanstack/vue-table/build/lib/index.js"),l=require("./ColumnFilter.vue.js"),o=require("./CellEditor.vue.js"),n=require("../../../hooks/useLocale.js"),c=require("../../../Button/index.js");;/* empty css                */const r=require("../../../_virtual/_plugin-vue_export-helper.js"),a={class:"w-full"},i={class:"gsc-table"},u={class:"gsc-thead sticky top-0 z-10"},s=["checked",".indeterminate"],d=["onDrop"],m={class:"flex items-center gap-2 min-w-0"},p=["onClick"],g=["title","onDragstart"],k={class:"truncate"},f={key:0,class:"text-[rgba(0,0,0,0.45)] text-xs"},v=["onMousedown"],h=["checked","onChange"],y=["onDblclick"],B={key:1,class:"flex items-start gap-2"},x={class:"min-w-0 flex-1"},b={key:1,class:"break-words"},C={key:0},w=["colspan"],S={key:1,class:"w-full"},E={class:"gsc-table"},V={class:"gsc-thead sticky top-0 z-10"},N=["checked",".indeterminate"],D=["onDrop"],z={class:"flex items-center gap-2 min-w-0"},R=["onClick"],M=["title","onDragstart"],$={class:"truncate"},F={key:0,class:"text-[rgba(0,0,0,0.45)] text-xs"},I=["onMousedown"],L={class:"gsc-table"},_=["checked","onChange"],P=["onDblclick"],A={key:1,class:"break-words"},j={key:0},T=["colspan"],q={__name:"DataTable",props:{table:{type:Object,required:!0},mode:{type:String,default:"server"},loading:{type:Boolean,default:!1},virtual:{type:Boolean,default:!1},height:{type:[Number,String],default:400},rowHeight:{type:Number,default:40},enableRowSelection:{type:Boolean,default:!1}},emits:["selection-change","cell-change","server-filter-change"],setup(r,{emit:q}){const H=r,O=q,{t:U}=n.useLocale(),G=e.computed(()=>H.table),W=e.computed(()=>{try{return G.value.getHeaderGroups?.()||[]}catch{return[]}}),K=e.computed(()=>{try{return G.value.getRowModel?.().rows||[]}catch{return[]}}),J=e.computed(()=>(G.value.getVisibleLeafColumns?.()||[]).length+(H.enableRowSelection?1:0));function Q(e){const t=e.getIsSorted?.();return"asc"===t?"↑":"desc"===t?"↓":""}function X(e,t){const l=t.column;if(!l.getCanSort?.())return;const o=!!e?.shiftKey;l.toggleSorting?.(void 0,o)}const Y=e.ref(null);function Z(e,t){Y.value=t?.id??null;try{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",String(t?.id??""))}catch{}}function ee(e){const t=e?.getIsPinned?.();return"left"===t?"left":"right"===t?"right":"center"}function te(e,t,l){const o=e.indexOf(t),n=e.indexOf(l);if(-1===o||-1===n)return e;if(o===n)return e;const c=e.slice();return c.splice(o,1),c.splice(n,0,t),c}function le(e,t){const l=t?.id;let o=Y.value;try{const t=e.dataTransfer.getData("text/plain");t&&(o=t)}catch{}if(!o||!l||o===l)return void(Y.value=null);const n=(G.value.getAllLeafColumns?.()||[]).filter(Boolean),c=n.find(e=>e.id===o),r=n.find(e=>e.id===l);if(!c||!r)return void(Y.value=null);const a=ee(c);if(a!==ee(r))return void(Y.value=null);const i=n.filter(e=>"left"===ee(e)).map(e=>e.id),u=n.filter(e=>"center"===ee(e)).map(e=>e.id),s=n.filter(e=>"right"===ee(e)).map(e=>e.id);let d=i,m=u,p=s;"left"===a?d=te(i,o,l):"right"===a?p=te(s,o,l):m=te(u,o,l),G.value.setColumnOrder?.([...d,...m,...p]),Y.value=null}function oe(e){const t=e.getIsPinned?.();if("left"===t){return{position:"sticky",left:`${(e.getStart?.("left")??0)+(H.enableRowSelection?44:0)}px`,zIndex:2}}if("right"===t){return{position:"sticky",right:`${e.getAfter?.("right")??0}px`,zIndex:2}}return{}}const ne=e.computed(()=>H.enableRowSelection?{width:"44px",minWidth:"44px",position:"sticky",left:"0px",zIndex:4}:{}),ce=e.computed(()=>H.enableRowSelection?{width:"44px",minWidth:"44px",position:"sticky",left:"0px",zIndex:3}:{}),re=e.computed(()=>{if(H.virtual)return{};const e=H.height;return null==e||""===e?{}:"number"==typeof e?{height:`${e}px`,overflow:"auto"}:"auto"===e||"100%"===e?{height:"100%",overflow:"auto"}:{height:String(e),overflow:"auto"}});function ae(e){const t=e.column,l=e.getSize?.();return{width:l?`${l}px`:void 0,minWidth:t.columnDef?.minSize?`${t.columnDef.minSize}px`:void 0,position:"relative",...oe(t)}}function ie(e){const t=e.column,l=t.getSize?.();return{width:l?`${l}px`:void 0,minWidth:t.columnDef?.minSize?`${t.columnDef.minSize}px`:void 0,...oe(t)}}const ue=e.ref(null),se=e.reactive({});function de(e){const t=e?.columnDef?.meta?.col;return!!(t?.filterable||t?.filterType||t?.filterOptions)}function me(e){const t=e?.columnDef?.meta?.col;return t?.filterType||"text"}function pe(e){const t=e?.columnDef?.meta?.col;return t?.filterOptions||[]}function ge(e){ue.value=ue.value===e?null:e}function ke(e,t){se[e]=t}function fe(e){if("server"===H.mode)return O("server-filter-change",{key:e,value:se[e]}),void(ue.value=null);const t=G.value.getColumn?.(e);t?.setFilterValue?.(se[e]),ue.value=null}function ve(e){if(se[e]="","server"===H.mode)return O("server-filter-change",{key:e,value:""}),void(ue.value=null);const t=G.value.getColumn?.(e);t?.setFilterValue?.(""),ue.value=null}function he(){ue.value=null}e.onMounted(()=>{document.addEventListener("click",he)}),e.onBeforeUnmount(()=>{document.removeEventListener("click",he)}),e.watch(()=>G.value.getState?.().rowSelection,()=>{if(H.enableRowSelection)try{const e=G.value.getSelectedRowModel?.().rows||[];O("selection-change",e.map(e=>e.original))}catch{}},{deep:!0});const ye=e.reactive({});function Be(e,t){return`${e.id}::${t.id}`}function xe(e){const t=e?.columnDef?.meta?.col;return!!t?.editor}function be(e){const t=e?.columnDef?.meta?.col;return t?.editor?"input"===t.editor?"text":t.editor:"text"}function Ce(e){const t=e?.columnDef?.meta?.col;return t?.options||[]}function we(e,t){if(!xe(t))return;const l=Be(e,t);ye[l]=e.original?.[t.id]}function Se(e,t){const l=Be(e,t);return Object.prototype.hasOwnProperty.call(ye,l)}function Ee(e,t){const l=Be(e,t);return ye[l]}function Ve(e,t,l){const o=Be(e,t);ye[o]=l}function Ne(e,t){const l=Be(e,t);delete ye[l]}function De(e,t,l){const o=Be(e,t);try{e.original[t.id]=l}catch{}O("cell-change",{row:e.original,rowId:e.id,column:t.id,value:l}),delete ye[o]}const ze=e.ref(0);function Re(e){ze.value=e.target.scrollTop||0}const Me=e.computed(()=>Math.ceil(H.height/H.rowHeight)+6),$e=e.computed(()=>Math.max(0,Math.floor((ze.value||0)/H.rowHeight))),Fe=e.computed(()=>$e.value+Me.value),Ie=e.computed(()=>K.value.slice($e.value,Fe.value)),Le=e.computed(()=>$e.value*H.rowHeight),_e=e.computed(()=>Math.max(0,(K.value.length-Fe.value)*H.rowHeight));return(n,q)=>(e.openBlock(),e.createElementBlock("div",a,[r.virtual?(e.openBlock(),e.createElementBlock("div",S,[e.createElementVNode("table",E,[e.createElementVNode("thead",V,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,o=>(e.openBlock(),e.createElementBlock("tr",{key:o.id},[r.enableRowSelection?(e.openBlock(),e.createElementBlock("th",{key:0,class:"gsc-th text-center",style:e.normalizeStyle(ne.value)},[e.createElementVNode("input",{type:"checkbox",class:"gsc-checkbox",checked:G.value.getIsAllPageRowsSelected?.(),".indeterminate":G.value.getIsSomePageRowsSelected?.(),onChange:q[2]||(q[2]=e=>G.value.toggleAllPageRowsSelected?.(!!e.target.checked))},null,40,N)],4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.headers,o=>(e.openBlock(),e.createElementBlock("th",{key:o.id,class:"gsc-th",style:e.normalizeStyle(ae(o)),onDragover:q[3]||(q[3]=e.withModifiers(()=>{},["prevent"])),onDrop:e=>le(e,o.column)},[e.createElementVNode("div",z,[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-1 min-w-0",o.column.getCanSort?.()?"cursor-pointer":""]),onClick:e=>X(e,o)},[e.createElementVNode("span",{class:"text-[rgba(0,0,0,0.25)] hover:text-[rgba(0,0,0,0.45)] cursor-grab select-none",title:e.unref(U)("gsc.grid.table.dragReorder"),draggable:"true",onDragstart:e=>Z(e,o.column)}," ⋮⋮ ",40,M),e.createElementVNode("span",$,[o.isPlaceholder?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(t.FlexRender),{key:0,render:o.column.columnDef.header,props:o.getContext()},null,8,["render","props"]))]),o.column.getCanSort?.()?(e.openBlock(),e.createElementBlock("span",F,e.toDisplayString(Q(o.column)),1)):e.createCommentVNode("",!0)],10,R),de(o.column)?(e.openBlock(),e.createBlock(e.unref(c.GscButton),{key:0,type:"button",variant:"text",size:"icon",class:"ml-auto gsc-btn-icon-sm",title:e.unref(U)("gsc.grid.table.filter"),"aria-label":e.unref(U)("gsc.grid.table.filter"),onClick:e.withModifiers(e=>ge(o.column.id),["stop"])},{default:e.withCtx(()=>[...q[6]||(q[6]=[e.createElementVNode("i",{class:"i-material-symbols:filter-alt-outline","aria-hidden":"true"},null,-1)])]),_:1},8,["title","aria-label","onClick"])):e.createCommentVNode("",!0)]),ue.value===o.column.id?(e.openBlock(),e.createBlock(l.default,{key:0,value:se[o.column.id],type:me(o.column),options:pe(o.column),"onUpdate:value":e=>ke(o.column.id,e),onApply:e=>fe(o.column.id),onClear:e=>ve(o.column.id)},null,8,["value","type","options","onUpdate:value","onApply","onClear"])):e.createCommentVNode("",!0),o.column.getCanResize?.()?(e.openBlock(),e.createElementBlock("div",{key:1,class:"absolute right-0 top-0 h-full w-2 cursor-col-resize",onMousedown:e.withModifiers(e=>o.getResizeHandler?.()(e),["prevent"])},null,40,I)):e.createCommentVNode("",!0)],44,D))),128))]))),128))])]),e.createElementVNode("div",{class:"overflow-auto",style:e.normalizeStyle({height:`${r.height}px`}),onScroll:Re},[e.createElementVNode("div",{style:e.normalizeStyle({height:`${Le.value}px`})},null,4),e.createElementVNode("table",L,[e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ie.value,l=>(e.openBlock(),e.createElementBlock("tr",{key:l.id,class:"gsc-tr",style:e.normalizeStyle({height:`${r.rowHeight}px`})},[r.enableRowSelection?(e.openBlock(),e.createElementBlock("td",{key:0,class:"gsc-td text-center",style:e.normalizeStyle(ce.value)},[e.createElementVNode("input",{type:"checkbox",class:"gsc-checkbox",checked:l.getIsSelected?.(),onChange:e=>l.toggleSelected?.(!!e.target.checked)},null,40,_)],4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.getVisibleCells(),n=>(e.openBlock(),e.createElementBlock("td",{key:n.id,class:"gsc-td align-top",style:e.normalizeStyle(ie(n)),onDblclick:e=>we(l,n.column)},[Se(l,n.column)?(e.openBlock(),e.createBlock(o.default,{key:0,"model-value":Ee(l,n.column),type:be(n.column),options:Ce(n.column),onUpdateModelValue:e=>Ve(l,n.column,e),onCommit:e=>De(l,n.column,e),onCancel:e=>Ne(l,n.column)},null,8,["model-value","type","options","onUpdateModelValue","onCommit","onCancel"])):(e.openBlock(),e.createElementBlock("span",A,[e.createVNode(e.unref(t.FlexRender),{render:n.column.columnDef.cell,props:n.getContext()},null,8,["render","props"])]))],44,P))),128))],4))),128)),0===Ie.value.length?(e.openBlock(),e.createElementBlock("tr",j,[e.createElementVNode("td",{colspan:J.value,class:"px-3 py-10 text-center text-sm text-[rgba(0,0,0,0.45)]"},e.toDisplayString(r.loading?e.unref(U)("gsc.grid.table.loading"):e.unref(U)("gsc.grid.table.empty")),9,T)])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{style:e.normalizeStyle({height:`${_e.value}px`})},null,4)],36)])):(e.openBlock(),e.createElementBlock("div",{key:0,class:"overflow-auto",style:e.normalizeStyle(re.value)},[e.createElementVNode("table",i,[e.createElementVNode("thead",u,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,o=>(e.openBlock(),e.createElementBlock("tr",{key:o.id},[r.enableRowSelection?(e.openBlock(),e.createElementBlock("th",{key:0,class:"gsc-th text-center",style:e.normalizeStyle(ne.value)},[e.createElementVNode("input",{type:"checkbox",class:"gsc-checkbox",checked:G.value.getIsAllPageRowsSelected?.(),".indeterminate":G.value.getIsSomePageRowsSelected?.(),onChange:q[0]||(q[0]=e=>G.value.toggleAllPageRowsSelected?.(!!e.target.checked))},null,40,s)],4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.headers,o=>(e.openBlock(),e.createElementBlock("th",{key:o.id,class:"gsc-th",style:e.normalizeStyle(ae(o)),onDragover:q[1]||(q[1]=e.withModifiers(()=>{},["prevent"])),onDrop:e=>le(e,o.column)},[e.createElementVNode("div",m,[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-1 min-w-0",o.column.getCanSort?.()?"cursor-pointer":""]),onClick:e=>X(e,o)},[e.createElementVNode("span",{class:"text-[rgba(0,0,0,0.25)] hover:text-[rgba(0,0,0,0.45)] cursor-grab select-none",title:e.unref(U)("gsc.grid.table.dragReorder"),draggable:"true",onDragstart:e=>Z(e,o.column)}," ⋮⋮ ",40,g),e.createElementVNode("span",k,[o.isPlaceholder?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(t.FlexRender),{key:0,render:o.column.columnDef.header,props:o.getContext()},null,8,["render","props"]))]),o.column.getCanSort?.()?(e.openBlock(),e.createElementBlock("span",f,e.toDisplayString(Q(o.column)),1)):e.createCommentVNode("",!0)],10,p),de(o.column)?(e.openBlock(),e.createBlock(e.unref(c.GscButton),{key:0,type:"button",variant:"text",size:"icon",class:"ml-auto gsc-btn-icon-sm",title:e.unref(U)("gsc.grid.table.filter"),"aria-label":e.unref(U)("gsc.grid.table.filter"),onClick:e.withModifiers(e=>ge(o.column.id),["stop"])},{default:e.withCtx(()=>[...q[4]||(q[4]=[e.createElementVNode("i",{class:"i-material-symbols:filter-alt-outline","aria-hidden":"true"},null,-1)])]),_:1},8,["title","aria-label","onClick"])):e.createCommentVNode("",!0)]),ue.value===o.column.id?(e.openBlock(),e.createBlock(l.default,{key:0,value:se[o.column.id],type:me(o.column),options:pe(o.column),"onUpdate:value":e=>ke(o.column.id,e),onApply:e=>fe(o.column.id),onClear:e=>ve(o.column.id)},null,8,["value","type","options","onUpdate:value","onApply","onClear"])):e.createCommentVNode("",!0),o.column.getCanResize?.()?(e.openBlock(),e.createElementBlock("div",{key:1,class:"absolute right-0 top-0 h-full w-2 cursor-col-resize",onMousedown:e.withModifiers(e=>o.getResizeHandler?.()(e),["prevent"])},null,40,v)):e.createCommentVNode("",!0)],44,d))),128))]))),128))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.value,l=>(e.openBlock(),e.createElementBlock("tr",{key:l.id,class:"gsc-tr"},[r.enableRowSelection?(e.openBlock(),e.createElementBlock("td",{key:0,class:"gsc-td text-center",style:e.normalizeStyle(ce.value)},[e.createElementVNode("input",{type:"checkbox",class:"gsc-checkbox",checked:l.getIsSelected?.(),onChange:e=>l.toggleSelected?.(!!e.target.checked)},null,40,h)],4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.getVisibleCells(),r=>(e.openBlock(),e.createElementBlock("td",{key:r.id,class:"gsc-td align-top",style:e.normalizeStyle(ie(r)),onDblclick:e=>we(l,r.column)},[n.$slots[`cell-${r.column.id}`]?e.renderSlot(n.$slots,`cell-${r.column.id}`,{key:0,value:r.getValue(),row:l.original},void 0,!0):(e.openBlock(),e.createElementBlock("div",B,[e.createElementVNode("div",x,[Se(l,r.column)?(e.openBlock(),e.createBlock(o.default,{key:0,"model-value":Ee(l,r.column),type:be(r.column),options:Ce(r.column),onUpdateModelValue:e=>Ve(l,r.column,e),onCommit:e=>De(l,r.column,e),onCancel:e=>Ne(l,r.column)},null,8,["model-value","type","options","onUpdateModelValue","onCommit","onCancel"])):(e.openBlock(),e.createElementBlock("span",b,[e.createVNode(e.unref(t.FlexRender),{render:r.column.columnDef.cell,props:r.getContext()},null,8,["render","props"])]))]),xe(r.column)&&!Se(l,r.column)?(e.openBlock(),e.createBlock(e.unref(c.GscButton),{key:0,variant:"default",class:"shrink-0 mt-0.5 px-2 h-6 text-xs",onClick:e.withModifiers(e=>we(l,r.column),["stop"])},{default:e.withCtx(()=>[...q[5]||(q[5]=[e.createTextVNode(" ✎ ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0)]))],44,y))),128))]))),128)),0===K.value.length?(e.openBlock(),e.createElementBlock("tr",C,[e.createElementVNode("td",{colspan:J.value,class:"px-3 py-10 text-center text-sm text-[rgba(0,0,0,0.45)]"},e.toDisplayString(r.loading?e.unref(U)("gsc.grid.table.loading"):e.unref(U)("gsc.grid.table.empty")),9,w)])):e.createCommentVNode("",!0)])])],4))]))}},H=r.default(q,[["__scopeId","data-v-41fc8372"]]);exports.default=H;