'use strict';
import { getInternalResourceMeta } from '../../resources/internal-resource-meta.js';
import { withIdProps } from '../../../../../fd-toolbox-core/types/resource-with-id.js';
import { oDataOrderByDirections, tableSortDirections } from '../../../../../fd-toolbox/enums/enums.js';
import { convertFromPascalToCamelCase } from '../../../../../fd-toolbox/strings/casing-converter.js';

var __defProp=Object['defineProperty'],__name=(_0x46020d,_0x3bacee)=>__defProp(_0x46020d,'name',{'value':_0x3bacee,'configurable':!![]});function setDefaultOrderBy(_0x3f2720){if(_0x3f2720['length']===-0x120+0x3*0x1f9+-0x3*0x199){const _0xf1526d={'direction':oDataOrderByDirections['asc'],'propertyName':withIdProps['id'],'priority':0x0};_0x3f2720['push'](_0xf1526d);}}__name(setDefaultOrderBy,'setDefaultOrderBy');async function getMetaOrderBys(_0x100f1){const _0x4529d1=[],_0xb7de8a=await getInternalResourceMeta(_0x100f1['resourceName']);addOrderBys(_0x4529d1,_0xb7de8a['orderByProperty'],_0xb7de8a['orderByPriority']);const _0x271d0c=_0xb7de8a['properties'];for(const [_0x2e7b2d,_0x48b765]of Object['entries'](_0x100f1['properties'])){addOrderBys(_0x4529d1,_0x271d0c[_0x2e7b2d]?.['orderByProperty'],_0x271d0c[_0x2e7b2d]?.['orderByPriority'],_0x48b765);}return setDefaultOrderBy(_0x4529d1),_0x4529d1;}__name(getMetaOrderBys,'getMetaOrderBys');async function fillOdataConfigForMany(_0x4a3b29,_0x4cf09f){if(_0x4cf09f&&!_0x4cf09f['orderBys']?.['length']){const _0x2847c6=await getMetaOrderBys(_0x4a3b29),_0x145e93=[];for(const _0x29e04a of _0x2847c6){const _0x272c39={'propertyName':convertFromPascalToCamelCase(_0x29e04a['propertyName']),'priority':_0x29e04a['priority'],'direction':_0x29e04a['direction']};_0x145e93['push'](_0x272c39);}_0x4cf09f['orderBys']=_0x145e93;}return _0x4cf09f;}__name(fillOdataConfigForMany,'fillOdataConfigForMany');function addOrderBys(_0x1ddab6,_0x374a85,_0x18e616,_0x59827b){if(_0x18e616){const _0x249983=_0x59827b?.['name']??_0x374a85??withIdProps['id'];if(_0x1ddab6['some'](_0x269b19=>_0x269b19['propertyName']===_0x249983))return;const _0x127f24={'propertyName':_0x249983,'direction':tableSortDirections['asc'],'priority':_0x18e616};_0x1ddab6['push'](_0x127f24);}}__name(addOrderBys,'addOrderBys');

export { fillOdataConfigForMany, getMetaOrderBys, setDefaultOrderBy };
