'use strict';
import { fetchUiResourceMeta } from '../ui-meta-providers.js';
import { tableDisplayModes, tableSortDirections } from '../../../fd-toolbox/enums/enums.js';
import { tableSortItems, getDefaultSortColumn } from './services/fd-table-private-sorting.js';
import { calculateAndSetColumnDimensions } from './services/fd-table-private-column-calculation.js';
import { createColumnsAndPrepareTable } from './services/fd-table-private-create-columns.js';
import { ifShouldDisplayPropertyInList } from './services/fd-table-private-properties.js';
import { tableElementSuffixes } from '../../fd-component-toolbox/constants/table-element-suffixes.js';
import { getObjectValues } from '../../../fd-toolbox/lib/utils.js';

var __defProp=Object['defineProperty'],__name=(_0x47534a,_0x388e4a)=>__defProp(_0x47534a,'name',{'value':_0x388e4a,'configurable':!![]});function onTableSort(_0x4c4ec1,_0x5474c4,_0x30381b,_0x3b2b2c,_0x450c36,_0x282a1b){let _0x3eb52b=tableSortItems(_0x4c4ec1,_0x5474c4,!!_0x282a1b,_0x30381b,_0x450c36);!_0x282a1b&&_0x3eb52b&&_0x3eb52b['length']>0x2049+0x17*0x6+-0x20d3&&_0x3b2b2c(_0x3eb52b);}__name(onTableSort,'onTableSort');function getHeight(_0x4fc242){const _0x2f3404=-0x139f+0x13b3+-0x1*0x13+0.75,_0x4a5f22=-0x12d*-0x1+-0x1f3f+0x9a*0x32,_0x1d1012=_0x4fc242*_0x2f3404,_0x197f70=_0x4fc242*_0x4a5f22;return 'min-h-['+_0x1d1012+'rem]\x20lg:min-h-['+_0x197f70+'rem]';}__name(getHeight,'getHeight');function onPagingChange(_0x12e33b,_0x5e552f,_0x5c12e7){_0x5e552f(_0x12e33b['pageSize']),_0x5c12e7?.(_0x12e33b);}__name(onPagingChange,'onPagingChange');function setTableConfig(_0x268787,_0x127c8a){_0x268787([]),_0x127c8a([]);}__name(setTableConfig,'setTableConfig');async function initializeTable(_0x7e6111,_0x1cb45f,_0x30c78b,_0x389858,_0x28ccd7,_0x5ab2ba,_0xa1c0eb,_0x4bc218,_0x365e29,_0x52563f,_0x2274d7,_0xffca17,_0x18db95,_0x35f2b7,_0x2fb847,_0x5f21e7,_0x5ebf9f,_0x16bf46,_0x130bc4){return _0x18db95(0x1*0x1b7f+-0xb9*-0x2f+-0x3d75*0x1),setupTableInstance(_0xa1c0eb,_0x4bc218,_0x1cb45f,_0x30c78b,_0x5ab2ba,_0x28ccd7,_0x389858,_0x7e6111,_0x52563f,_0x2274d7,_0xffca17,_0x35f2b7,_0x16bf46,_0x2fb847,_0x5f21e7,_0x5ebf9f,_0x365e29,_0x130bc4);}__name(initializeTable,'initializeTable');async function onInitTable(_0x1fd955,_0x41a40a,_0x2e22d4,_0x5af25c,_0x4c1052,_0x33f728,_0x358a35,_0x487f41,_0x445730,_0x2302e4,_0x46e20b,_0x50a17b,_0x342c48,_0x15022e,_0x50598b){setTableColumnDimensions(_0x445730,_0x2302e4,_0x2e22d4);const _0xa9a461=_0x2302e4?.['getBoundingClientRect']()['width'];await loadTableData(_0x4c1052,_0x33f728,_0x358a35,_0x487f41,_0x1fd955,_0x41a40a,_0x5af25c,_0x2e22d4,_0x46e20b,_0xa9a461,_0x50a17b,_0x342c48,_0x15022e,_0x50598b);}__name(onInitTable,'onInitTable');function createInternalTableColumns(_0x3a7b64,_0x567250,_0x1c709c,_0xb6f5bf,_0x1746c4,_0x3af8dd,_0x543f9a,_0x4dfd76,_0x1417b4,_0x24c059){_0x3a7b64([]);const _0x3a571c=createColumnsAndPrepareTable(_0x567250,_0x1c709c,_0xb6f5bf,_0x1746c4,_0x1417b4,_0x543f9a,_0x4dfd76,_0x3af8dd,_0x24c059);return _0x3a7b64(_0x3a571c),_0x3a571c;}__name(createInternalTableColumns,'createInternalTableColumns');function onMouseEnter(_0x5bf926,_0x434634){_0x5bf926===tableDisplayModes['minimal']&&_0x434634(!![]);}__name(onMouseEnter,'onMouseEnter');function onMouseLeave(_0xff09,_0x3bf9b0){_0xff09===tableDisplayModes['minimal']&&_0x3bf9b0(![]);}__name(onMouseLeave,'onMouseLeave');function setupTableInstance(_0x49e252,_0x3f9e4e,_0x304cdf,_0x335153,_0x2ae7e0,_0x4ba928,_0x5951e5,_0x5af2ee,_0x4f2a36,_0x4760ce,_0x36aa36,_0x2edd8a,_0x464e7f,_0x27b759,_0x13b01c,_0x55e570,_0x5036e8,_0x498c72){if(_0x5036e8&&_0x5036e8===tableElementSuffixes['table'])_0x3f9e4e(_0x5036e8+_0x49e252);onInitTable(_0x304cdf,_0x335153,_0x2ae7e0,_0x4ba928,_0x5951e5,_0x5af2ee,_0x4f2a36,_0x4760ce,_0x36aa36,_0x2edd8a,_0x464e7f,_0x27b759,_0x13b01c,_0x55e570,_0x498c72);}__name(setupTableInstance,'setupTableInstance');function setTableSortDirectionAndActiveSort(_0x556f96,_0x423332){if(!_0x423332)return;for(let _0x5e58b3 of _0x556f96){_0x5e58b3['isActiveSort']=![],_0x5e58b3['itemPropertyName']===_0x423332['columnName']||_0x5e58b3['name']===_0x423332['columnName']?(_0x5e58b3['isActiveSort']=!![],_0x5e58b3['sortDirection']=_0x423332['direction']):_0x5e58b3['isActiveSort']=![];}}__name(setTableSortDirectionAndActiveSort,'setTableSortDirectionAndActiveSort');async function getTableRelatedResourcesMeta(_0x3dd553,_0x301537,_0x10d29e){if(!_0x10d29e)return [];const _0x55e2b7=getObjectValues(_0x10d29e['properties']),_0x5d966f=[];for(const _0x1bb4ab of _0x55e2b7){const _0x261e66=_0x10d29e['resourceMeta']['properties'][_0x1bb4ab['name']],_0x3d1084=ifShouldDisplayPropertyInList(_0x1bb4ab,_0x261e66,_0x3dd553,_0x301537)&&_0x261e66['relation']?.['expandForDescription'];if(_0x3d1084&&_0x261e66['relation']){const _0x45bf29=_0x261e66['relation']['relatedResourceName'],_0x18c44c=await fetchUiResourceMeta(_0x45bf29);_0x5d966f['push'](Promise['resolve'](_0x18c44c['resourceMeta']));}}return _0x5d966f['length']>0x1*0x72e+-0x57*0x57+0x1663?Promise['all'](_0x5d966f):[];}__name(getTableRelatedResourcesMeta,'getTableRelatedResourcesMeta');function defaultTableSortInternalTableColumns(_0x44219f,_0x25a4f7,_0x541ec2){let _0x28396a;if(_0x25a4f7&&_0x44219f['length']>0x6*0x623+0x371*0x8+-0x405a){let _0x3949ad;if(!_0x541ec2)_0x3949ad=getDefaultSortColumn(_0x25a4f7,_0x44219f);else _0x541ec2?.['isLocalSort']&&(_0x3949ad=_0x44219f['find'](_0x35d69f=>_0x35d69f['name']===_0x541ec2['columnName']),_0x3949ad&&(_0x3949ad['sortDirection']=_0x541ec2['direction']===tableSortDirections['desc']?tableSortDirections['asc']:tableSortDirections['desc']));_0x28396a=_0x3949ad;}return _0x28396a;}__name(defaultTableSortInternalTableColumns,'defaultTableSortInternalTableColumns');async function loadTableData(_0x48ef75,_0x50ef7f,_0x2c1370,_0x5e0e9b,_0x3aa310,_0x2c085f,_0x190731,_0x2e857d,_0x49380f,_0x4dff66,_0x4e81dd,_0x5bb201,_0x2d2e94,_0x3261f4){const _0xeda0cb=await getTableRelatedResourcesMeta(_0x48ef75,_0x3aa310,_0x49380f),_0x46de92=createInternalTableColumns(_0x50ef7f,_0x3aa310,_0x2c085f,_0x48ef75,_0x190731,_0x2e857d,_0x49380f,_0x4dff66,_0xeda0cb,_0x3261f4);setTableSortDirectionAndActiveSort(_0x46de92,_0x4e81dd);let _0x9c2a5e=defaultTableSortInternalTableColumns(_0x46de92,_0x49380f?.['resourceMeta'],_0x4e81dd);_0x9c2a5e&&onTableSort(_0x9c2a5e,_0x46de92,_0x5e0e9b,_0x2c1370,_0x5bb201,!!_0x2d2e94),_0x50ef7f([..._0x46de92]);}__name(loadTableData,'loadTableData');function setTableColumnDimensions(_0x4d9c32,_0x2d3bb2,_0x3ccf3b){if(_0x3ccf3b===tableDisplayModes['minimal'])return;let _0x1bd1ac=_0x2d3bb2?.['getBoundingClientRect']();if(!_0x1bd1ac)return;calculateAndSetColumnDimensions(_0x4d9c32,_0x1bd1ac['width'],_0x3ccf3b===0x7bc+0x2059+-0x1*0x2815?-0x1*-0x812+-0x19*-0x3a+-0xdbc:-0x1*-0xdf9+-0x1d88+0x31d*0x5);}__name(setTableColumnDimensions,'setTableColumnDimensions');

export { createInternalTableColumns, getHeight, initializeTable, onInitTable, onMouseEnter, onMouseLeave, onPagingChange, onTableSort, setTableConfig };
