'use strict';
import { crudActions, tableDisplayModes, tableSortDirections } from '../../../../fd-toolbox/enums/enums.js';
import { routes } from '../../../../fd-toolbox/routing/routes.js';
import { metaQueryParams } from '../../../../fd-toolbox/constants/meta-query-params.js';
import { internalTableColumnTypes } from '../table-models.js';
import { hasCrudPermission } from '../../auth/permissions/permission-checker.js';
import { shortenWithEllipsis } from '../../../../fd-toolbox/strings/strings.js';
import { elementSuffixes } from '../../../../fd-toolbox/constants/element-suffixes.js';
import { isRightAlignColumn } from '../services/table-column-alignment.js';
import { flexRowReverseStyele } from '../../../fd-component-toolbox/fade-out-text/FadeOutText.js';

var __defProp=Object['defineProperty'],__name=(_0x491452,_0x415174)=>__defProp(_0x491452,'name',{'value':_0x415174,'configurable':!![]});function initTableHeaderCell(_0x260a95,_0x260059,_0x16c1e1,_0x17d911){_0x260059(_0x260a95['internalTableColumn']['displayName']),_0x16c1e1(_0x260a95['internalTableColumn']['displayName']),_0x17d911(_0x260a95['internalTableColumn']['name']+elementSuffixes['header']);}__name(initTableHeaderCell,'initTableHeaderCell');function shouldShowHeaderAction(_0x20286c,_0x51a1c1,_0x430f4e){if(_0x20286c['tableInstance']['uiResourceMeta']?.['resourceMeta']){const _0x12ac15=(_0x20286c['internalTableColumn']['type']===internalTableColumnTypes['action']||_0x20286c['internalTableColumn']['type']===internalTableColumnTypes['customHeaderAction'])&&hasCrudPermission(crudActions['create'],_0x20286c['tableInstance']['uiResourceMeta']['resourceMeta']);if(_0x430f4e===tableDisplayModes['default']&&_0x12ac15)return !![];else {if(_0x430f4e===tableDisplayModes['minimal']&&_0x12ac15)return _0x51a1c1;}}return ![];}__name(shouldShowHeaderAction,'shouldShowHeaderAction');function getNavigateUrl(_0x338bc6){const _0x396c4b=new URLSearchParams();return _0x396c4b['set'](metaQueryParams['resource'],_0x338bc6),routes['edit']+'?'+_0x396c4b['toString']();}__name(getNavigateUrl,'getNavigateUrl');function shouldShowHeaderText(_0x2b7146){return _0x2b7146['internalTableColumn']['type']!==internalTableColumnTypes['action']&&_0x2b7146['internalTableColumn']['type']!==internalTableColumnTypes['customHeaderAction']&&_0x2b7146['internalTableColumn']['type']!==internalTableColumnTypes['checkBox'];}__name(shouldShowHeaderText,'shouldShowHeaderText');function isColumnCheckbox(_0x539c28){return _0x539c28['internalTableColumn']['type']===internalTableColumnTypes['checkBox'];}__name(isColumnCheckbox,'isColumnCheckbox');function handleInit(_0x520ec8,_0x44c967,_0x25adfb,_0x2ad874){initTableHeaderCell(_0x520ec8,_0x44c967,_0x25adfb,_0x2ad874),_0x44c967(_0x20a871=>{if(_0x20a871&&_0x20a871['length']>0xe23+-0x1*-0x1837+-0x263c)return shortenWithEllipsis(_0x20a871,0x6d5+-0xb*0x217+0x1046);return _0x20a871;});}__name(handleInit,'handleInit');function onSortDirectionChange(_0x6372fe,_0x1c6bcf,_0x48266e){if(!_0x48266e)return;const _0x1c81e4=_0x1c6bcf['internalTableColumn'];_0x1c81e4['sortDirection']=_0x1c81e4['sortDirection']===tableSortDirections['asc']?tableSortDirections['desc']:tableSortDirections['asc'],_0x6372fe(_0x1c81e4);}__name(onSortDirectionChange,'onSortDirectionChange');function updateTableHeaderCellHoverState(_0x147a8f,_0x597458,_0x8595e6){let _0x4195e5;return !_0x147a8f&&_0x8595e6(_0x597458),_0x4195e5;}__name(updateTableHeaderCellHoverState,'updateTableHeaderCellHoverState');function getActiveSortPaddingClass(_0x2d6614){let _0x414020;return _0x2d6614['isActiveSort']&&(_0x414020=isRightAlignColumn(_0x2d6614)?'pl-3':'pr-3'),_0x414020;}__name(getActiveSortPaddingClass,'getActiveSortPaddingClass');function runSelectAllCheckboxes(_0x28ce76){return _0x28ce76&&handleSelectAllCheckboxes(_0x28ce76),void(-0x998*0x2+0x2139+-0xe09*0x1);}__name(runSelectAllCheckboxes,'runSelectAllCheckboxes');function checkIfAllSelected(_0xa43fb9){const _0xd67b51=_0xa43fb9;if(!_0xd67b51?.['length'])return ![];return _0xd67b51['every'](_0x54741b=>Boolean(_0x54741b?.['selected']));}__name(checkIfAllSelected,'checkIfAllSelected');function onCustomAction(_0x20c382,_0xa2d08d){if(_0x20c382['shouldTableRefresh'])_0xa2d08d?.();}__name(onCustomAction,'onCustomAction');function getHeaderClasses(_0x337a86){return {'alignmentClass':isRightAlignColumn(_0x337a86)?flexRowReverseStyele:'','activeSortPaddingClass':getActiveSortPaddingClass(_0x337a86),'alignmentArrowClass':isRightAlignColumn(_0x337a86)?'':'right-0'};}__name(getHeaderClasses,'getHeaderClasses');function shouldShowActionSection(_0x4e4c92){return _0x4e4c92['type']===internalTableColumnTypes['action']||_0x4e4c92['type']===internalTableColumnTypes['customHeaderAction'];}__name(shouldShowActionSection,'shouldShowActionSection');function getSortIcon(_0x3b3149){return _0x3b3149===tableSortDirections['asc']?'chevron-up':'chevron-down';}__name(getSortIcon,'getSortIcon');function handleSelectAllCheckboxes(_0x4e78fc){_0x4e78fc(_0x3b6b34=>{const _0x16c11a=_0x3b6b34['every'](_0x239cd0=>_0x239cd0['selected']);return _0x3b6b34['map'](_0x869058=>({..._0x869058,'selected':!_0x16c11a}));});}__name(handleSelectAllCheckboxes,'handleSelectAllCheckboxes');

export { checkIfAllSelected, getActiveSortPaddingClass, getHeaderClasses, getNavigateUrl, getSortIcon, handleInit, initTableHeaderCell, isColumnCheckbox, onCustomAction, onSortDirectionChange, runSelectAllCheckboxes, shouldShowActionSection, shouldShowHeaderAction, shouldShowHeaderText, updateTableHeaderCellHoverState };
