'use strict';
import { setInternalResourceMeta, getResourceMetaCacheKey } from './internal-resource-meta.js';
import { internalPropertyMetas } from './internal-property-metas.js';
import { setCoreCache } from '../../../../fd-toolbox/server/cachings/core-cache.js';
import { createError } from '../../../../fd-toolbox/errors/errors.js';
import { resourceNames } from '../../../../fd-toolbox/resources/resource-names.js';
import { removeDynamicModulesFromCoreCache } from '../modules/dynamic-imports.js';
import { generatedPaths } from '../../../../base-repo/app-constants/project-paths.js';
import { fdServerCacheKeys } from '../../../../fd-toolbox/server/constants/fd-server-cache-keys.js';
import { memoryCacheHasKey } from '../../../../fd-toolbox/server/cachings/fd-memory-cache.js';
import _0x1869d0__default from 'path';
import { parseJson } from '../../../../fd-toolbox/lib/utils.js';
import { readFileSync } from 'fs';

var __defProp=Object['defineProperty'],__name=(_0x4adb92,_0x2c84fe)=>__defProp(_0x4adb92,'name',{'value':_0x2c84fe,'configurable':!![]});let metaJsonData;function loadMetaJson(){if(metaJsonData)return metaJsonData;const _0x1b3a4f=readFileSync(_0x1869d0__default['join'](process['cwd'](),generatedPaths['metaJson']),'utf-8');return metaJsonData=parseJson(_0x1b3a4f),metaJsonData;}__name(loadMetaJson,'loadMetaJson');function initInternalResourceMetasCacheFromJson(){const _0x1d1b55=loadMetaJson();if(!_0x1d1b55)throw createError(internalPropertyMetas['noMetaFileError']);removeDynamicModulesFromCoreCache();for(const _0x61afaf in _0x1d1b55){if(Object['hasOwn'](_0x1d1b55,_0x61afaf)){const _0x2d993e=_0x1d1b55[_0x61afaf];setInternalResourceMeta(_0x2d993e);}}}__name(initInternalResourceMetasCacheFromJson,'initInternalResourceMetasCacheFromJson');function getInternalResourceMetasFromJson(){const _0x459601=loadMetaJson();if(!_0x459601)throw createError(internalPropertyMetas['noMetaFileError']);const _0x5d132e={};for(const _0x2645e2 in _0x459601){if(Object['hasOwn'](_0x459601,_0x2645e2)){const _0x2365a6=_0x459601[_0x2645e2];_0x5d132e[_0x2645e2]=_0x2365a6;}}return _0x5d132e;}__name(getInternalResourceMetasFromJson,'getInternalResourceMetasFromJson');function initializeInternalResourceMetaIfNeeded(){!memoryCacheHasKey(getResourceMetaCacheKey(resourceNames['permission']))&&initInternalResourceMetasCacheFromJson();}__name(initializeInternalResourceMetaIfNeeded,'initializeInternalResourceMetaIfNeeded');async function initializeResourceMetaCache(){return setCoreCache(fdServerCacheKeys['resourceMetas'],getInternalResourceMetasFromJson());}__name(initializeResourceMetaCache,'initializeResourceMetaCache');

export { getInternalResourceMetasFromJson, initInternalResourceMetasCacheFromJson, initializeInternalResourceMetaIfNeeded, initializeResourceMetaCache, loadMetaJson };
