"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("lodash-unified"),F=require("vue"),V=require("./useKeepAliveFlag.js");function q(l){const r=F.ref(null),{isShowRowSelection:d=!0,clearSelectionOnRequest:f=!0,transformSearchFormValues:o,api:a,tableRefresh:s=!0,clearDataOnDeactivated:g=!0,...v}=l||{};let n=null;const u=()=>{r.value?.rowSelection?.clearAll()},i=e=>{r.value?.submitWith(e)},p=()=>{r.value?.reset()},{isDeactivated:S}=V.useKeepAliveFlag({afterActivated(){(c.isFunction(s)?s():s)&&i()},afterDeactivated:()=>g&&i()}),h=async e=>{if(S())return{data:[],total:0};n=e.sort;const t=o?o(e):e;if(!a)throw new Error("api is not defined");const{records:m,total:A}=await a(t);return f&&u(),{data:m,total:A}};return[c.merge({columnResizable:!0,request:a?h:void 0,rowSelection:d?{fixed:"left",columnWidth:38}:void 0,onVnodeBeforeMount(e){r.value=e.component?.exposed},card:!0},v),{reload:i,reset:p,getSearchFormValues:(e=!0)=>{const t=r.value?.getSearchFormValues(!!e)||{};return o?o(t):t},getAgGridInstance:()=>r.value,getSearchFormValuesAndSorted:(e=!0)=>{const t=r.value?.getSearchFormValues(!!e)||{};return t.sort=n&&c.cloneDeep(n),o?o(t):t},clearSelection:u}]}exports.usePageListAgGrid=q;
