'use strict';
import { getResourceMeta } from '../services/metas.js';
import { isEditDisplayable, isFilterDisplayable, isListDisplayAdvisable } from '../services/property-metas.js';
import { getInternalResourceMeta } from '../resources/internal-resource-meta.js';
import { getInternalPropertyMeta } from '../props/property-meta-config-provider.js';
import { comparePriority } from '../../meta-sort.js';
import { createUiRelation } from '../../ui/ui-relation.js';
import { getObjectValues } from '../../../../fd-toolbox/lib/utils.js';
import { dynamicMetaProviderTypes } from '../constants/meta-handler-types.js';
import { getDynamicMetaProvider } from '../basic-crud/resource-meta-handlers.js';

var __defProp=Object['defineProperty'],__name=(_0x5eaca0,_0x59066c)=>__defProp(_0x5eaca0,'name',{'value':_0x59066c,'configurable':!![]});async function getUiResourceMetas(_0xf75fba){const _0x38b72e=_0xf75fba['map'](getUiResourceMeta),_0x176aa2=await Promise['all'](_0x38b72e),_0x431ce1=Object['fromEntries'](_0x176aa2['map'](_0xc21c2e=>[_0xc21c2e['resourceMeta']['resourceName'],_0xc21c2e]));return _0x431ce1;}__name(getUiResourceMetas,'getUiResourceMetas');async function getUiResourceMeta(_0x5ec1f2){const _0x7e2d05=await getResourceMeta(_0x5ec1f2),_0x14b022=await getInternalResourceMeta(_0x5ec1f2),_0x5d197f={};for(const _0x56c5f0 of getObjectValues(_0x7e2d05['properties'])){const _0x527c79=await getInternalPropertyMeta(_0x5ec1f2,_0x56c5f0['name']);_0x5d197f[_0x56c5f0['name']]={'name':_0x56c5f0['name'],'isDisplayable':_0x56c5f0['isDisplayable'],'isListDisplayable':await isListDisplayAdvisable(_0x56c5f0,_0x5ec1f2),'isFilterDisplayable':_0x527c79?isFilterDisplayable(_0x56c5f0,_0x527c79):![],'isEditDisplayable':_0x527c79?isEditDisplayable(_0x14b022,_0x56c5f0,_0x527c79):![],'colorful':_0x527c79?(_0x527c79['colorful']&&!_0x527c79['notColorful'])??![]:![],'isSearchable':_0x527c79?_0x527c79['isSearchable']??![]:![]};if(_0x56c5f0['relation']&&_0x527c79)setUiRelation(_0x5d197f[_0x56c5f0['name']],_0x527c79);}const _0x1fd557={'resourceMeta':_0x7e2d05,'properties':sortUiProperties(_0x7e2d05['properties'],_0x5d197f)};return await fillFromDynamicUiMetaConfig(_0x1fd557),_0x1fd557;}__name(getUiResourceMeta,'getUiResourceMeta');function sortUiProperties(_0x5462c1,_0x36128a){const _0x4e8ea9=Object['entries'](_0x36128a);return _0x4e8ea9['sort'](([,_0x56ce22],[,_0x2a57a1])=>comparePriority(_0x5462c1[_0x56ce22['name']],_0x5462c1[_0x2a57a1['name']],![])),Object['fromEntries'](_0x4e8ea9);}__name(sortUiProperties,'sortUiProperties');async function fillFromDynamicUiMetaConfig(_0x3593b1){let _0x37f449;const _0x3f50f1=await getInternalResourceMeta(_0x3593b1['resourceMeta']['resourceName']);if(!_0x3f50f1['dynamicMetaProviders']?.['includes'](dynamicMetaProviderTypes['getDynamicUiMetaConfig']))return void(0x12aa+-0xf*-0x115+0x1*-0x22e5);const _0x2f1c48=(await getDynamicMetaProvider(_0x3f50f1['name'],dynamicMetaProviderTypes['getDynamicUiMetaConfig']))?.();if(_0x2f1c48)for(const [_0x52e795,_0x105069]of Object['entries'](_0x2f1c48['properties'])){const _0x182359=_0x3593b1['properties'][_0x52e795];_0x105069['isListDisplayable']!==void(0xffb*0x2+0x2*0xb6f+-0x2*0x1b6a)&&(_0x182359['isListDisplayable']=_0x105069['isListDisplayable'],_0x3593b1['properties'][_0x52e795]=_0x182359),_0x105069['isEditDisplayable']!==void(-0x1af7+0xfea+-0x29*-0x45)&&(_0x182359['isEditDisplayable']=_0x105069['isEditDisplayable'],_0x3593b1['properties'][_0x52e795]=_0x182359);}return _0x37f449;}__name(fillFromDynamicUiMetaConfig,'fillFromDynamicUiMetaConfig');function setUiRelation(_0x4ab9c8,_0x4a754c){_0x4ab9c8['uiRelation']=createUiRelation();if(_0x4a754c['uiRelationPriority'])_0x4ab9c8['uiRelation']['uiRelationPriority']=_0x4a754c['uiRelationPriority'];}__name(setUiRelation,'setUiRelation');

export { getUiResourceMeta, getUiResourceMetas, sortUiProperties };
