const libxmljs=require("libxmljs"),{readFile:readFile,readDir:readDir,stat:stat,isPrefabProject:isPrefabProject,getWmProjectPropertiesFilePath:getWmProjectPropertiesFilePath,getAuthInfoFilePath:getAuthInfoFilePath,getSecurityConfigPath:getSecurityConfigPath,getPagesConfigPath:getPagesConfigPath,getPrefabsDirPath:getPrefabsDirPath,getPrefabConfigPath:getPrefabConfigPath}=require("./wm-utils"),{join:join}=require("path"),getWmProjectProperties=async e=>{let t=await readFile(getWmProjectPropertiesFilePath(e),"utf8");const r=libxmljs.parseXml(t),a={};return r.find("//entry").forEach(e=>a[e.attr("key").value()]=e.text()),a},getSecurityConfig=async e=>stat(getAuthInfoFilePath(e)).then(()=>new Promise(async(t,r)=>{let a=null;JSON.parse(await readFile(getAuthInfoFilePath(e))).enforceSecurity&&(a=JSON.parse(await readFile(getSecurityConfigPath(e),"utf8"))),t(a)}),()=>Promise.resolve(null)),getPagesConfig=async e=>{let t=await readFile(getPagesConfigPath(e),"utf8");return t=JSON.parse(t)},getPrefabConfigsUsedInApp=async(e,t)=>{const r=new Map,a=getPrefabsDirPath(t);return stat(a).then(()=>new Promise(async(i,s)=>{for(const e of await readDir(a))(await stat(join(a,e))).isDirectory()&&r.set(e,await readFile(getPrefabConfigPath(t,e)));isPrefabProject(e)&&r.set("__self__",await readFile(`${t}/src/main/webapp/config.json`)),i(r)}),()=>Promise.resolve(r))};module.exports={getWmProjectProperties:getWmProjectProperties,getSecurityConfig:getSecurityConfig,getPagesConfig:getPagesConfig,getPrefabConfigsUsedInApp:getPrefabConfigsUsedInApp};