'use strict';
import { getObjectValues } from '../../../../fd-toolbox/lib/utils.js';
import { isPropertyExpandForDescription, getODataSelectIfExpandForDescription } from '../../../meta/odata/odata-selects.js';
import { getManyToManySecondResourceName } from '../../../meta/relations/meta-relations.js';
import { getODataExpandIfExpandForDescription } from '../../../meta/odata/expands.js';
import { oDataDefaultTop } from '../../../../fd-toolbox/odata/odata-constants.js';
import { getResources } from '../../../meta/server/services/resource-provider.js';
import { getUserId } from '../../../meta/server/auth/users/current-user-id-provider.js';
import { getUiResourceMeta, getUiResourceMetas } from '../../../meta/server/ui/ui-metas.js';
import { relationTypes } from '../../../../fd-toolbox/enums/enums.js';
import { getODataBuilder } from '../../../../fd-toolbox/odata/odata-builder-funcs.js';
import { removeDuplicates } from '../../../../fd-toolbox/collections/internal-arrays.js';

var __defProp=Object['defineProperty'],__name=(_0x25c7bf,_0x48d98c)=>__defProp(_0x25c7bf,'name',{'value':_0x48d98c,'configurable':!![]});async function getViewPageResourcesMetas(_0x360352){const _0x32cb46=await getUiResourceMeta(_0x360352),_0x4d3224=_0x32cb46['resourceMeta'],_0x1a3af9=new Set();for(const _0x367c8a of getObjectValues(_0x4d3224['properties'])){isPropertyExpandForDescription(_0x367c8a)&&_0x367c8a['relation']?.['relatedResourceName']&&_0x1a3af9['add'](_0x367c8a['relation']['relatedResourceName']);if(_0x367c8a['relation']?.['type']===relationTypes['manyToMany']){const _0x442b3f=getManyToManySecondResourceName(_0x4d3224['resourceName'],_0x367c8a);_0x442b3f&&_0x1a3af9['add'](_0x442b3f);}}const _0x162713=await getUiResourceMetas(Array['from'](_0x1a3af9));return [_0x32cb46,...getObjectValues(_0x162713)];}__name(getViewPageResourcesMetas,'getViewPageResourcesMetas');async function getViewPageResourceListResources(_0x396e0d,_0x4c7f32){const _0x3fddc1=await _0x4c7f32,_0x41712d=_0x3fddc1['map'](_0x198a9d=>_0x198a9d['resourceMeta']),_0x27f28a=_0x41712d['find'](_0x1002b5=>_0x1002b5['resourceName']===_0x396e0d),_0x5d5be0=getResourceODataConfig(_0x27f28a,_0x41712d),_0x29720e=await getUserId();return getResources(_0x27f28a['resourceName'],_0x29720e,_0x5d5be0);}__name(getViewPageResourceListResources,'getViewPageResourceListResources');function getResourceODataConfig(_0x4c61d5,_0x401a1f){const _0x463c07=getODataBuilder(),_0x60ca43=removeDuplicates(getODataSelectIfExpandForDescription(_0x4c61d5,_0x401a1f));return _0x463c07['selectArray'](_0x60ca43),_0x60ca43['length']===0x1b2f*-0x1+-0x5*0x112+0x2089&&_0x463c07['expandMany'](getODataExpandIfExpandForDescription(_0x4c61d5)),_0x463c07['top'](oDataDefaultTop+(0x3*0xb7+0x23bd*0x1+-0x25e1)),_0x463c07['build']();}__name(getResourceODataConfig,'getResourceODataConfig');

export { getViewPageResourceListResources, getViewPageResourcesMetas };
