import{$ as e,$r as t,Aa as n,Da as r,Ua as i,ka as a,ti as o,tt as s,xa as c}from"./stores-EFfd1fcK.js";import{t as l}from"./api-dpZxEEWu.js";import{t as u}from"./api-BmGEY1lp.js";var d=async(e,t,n,r,i)=>{let a=e?.length;if(!(!e||!a))try{if(!t||!n)throw Error(`数据异常`);let o=await h(t,n,r,i),s=new Map;o.forEach(e=>s.set(e.uuid,e));for(let i=0;i<a;i++){let a=e[i];s.get(a.uuid)||await v(a,t,n,r)}}catch{}},f=async e=>{let t=e.baseInfo?.tavigationConfigData;if(!e||!t||!t.tableData)return;let r=t.tableData?.length,i=e.zxlPrdId,o=e.uuid,s=e.moduleObId||``,c=e.accessPortalObId||``;try{let l=e._source;l&&(t.hasTabBar!=l.isBelongNavigation||t.tabBarStyle!==l.note)&&await n({isBelongNavigation:typeof t.hasTabBar==`boolean`?t.hasTabBar?1:0:1,note:t.tabBarStyle||`pic-text`,zxlPrdId:i,menuObId:o});let u=await _(i,o),d=new Map;u.forEach(e=>d.set(e.id,e));for(let e=0;e<r;e++){let n=t.tableData[e];if(!d.get(n.id))await y(n,i,o,s,c);else{d.delete(n.id);let e=n._source;if(e){let{menuObId:t,menuItemObId:r,formObId:o,functionObId:s,sortNo:c,name:l,icon:u,isBelongNavigation:d}=e,f=c.toString();(n.no!==f||n.name!==l||n.icon!==u||n.isApplyTarbar!==d)&&await a({menuObId:t,menuItemObId:r,zxlPrdId:i,sortNo:n.no,name:n.name,icon:n.icon,isBelongNavigation:n.isApplyTarbar?1:0})}}}let f=d.values();for(let e of f)await b(e,i)}catch{}},p=/^App_(.*)_.{36}$/,m=async(e,t,n,r)=>{if(!e||!t)return[];try{return await h(e,t,n,r)}catch{}return[]},h=async(t,n,r,i)=>{if(!t||!n)return[];try{return((await e.getByCondition({zxlPrdId:t,isPaging:!1}))?.data||[]).filter(e=>e.accessPortalObId===n&&e.title&&p.test(e.name)).map(e=>({name:e.title,zxlPrdId:e.zxlPrdId,uuid:e.menuObId,favicon:e.icon,baseInfo:null,_source:e,accessPortalObId:n,accessPortalName:e.title,identifyObId:r,moduleObId:e.moduleObId,platForm:i}))}catch{}return[]},g=async e=>{let t=e._source,n=e.zxlPrdId,r=e.uuid,i={hasTabBar:t?t.isBelongNavigation:!0,tabBarStyle:t?t.note:`pic-text`,defaultRouteName:``,defaultRoutePath:``,tableData:[]};try{let e=await _(n,r),t=e[0];i.defaultRouteName=t?.route?.split(`/`).join(`_`)||t?.id||``,i.tableData=e}catch{}return i},_=async(t,n)=>{if(!t||!n)return[];try{return((await e.getByConditionItem({zxlPrdId:t,menuObId:n,isPaging:!1}))?.data||[]).map(e=>{let{menuObId:t,menuItemObId:n,formObId:r,functionObId:i,sortNo:a,name:o,icon:s,isBelongNavigation:c}=e;return{id:n,relatedId:r,no:a?a.toFixed():`1`,title:``,name:o,icon:s,iconType:`vant`,pageType:`normal`,isApplyTarbar:c,route:`/${n}`,functionObId:i,_source:e}})}catch{}return[]};async function v(e,t,r,a){if(!e||!e.uuid)return;let{favicon:o,name:s,uuid:c}=e;try{let o=e.accessPortalName,c=`App_${s}_${r}`,l=await i({url:`/zxl_pm/request/module.svc?cmd=saveOrUpdate`,method:`post`,data:{zxlPrdId:t,moduleName:o,identifyObId:a,clientType:`MOBILE`,note:s}}),u=e.baseInfo?.tavigationConfigData?.hasTabBar,d=e.baseInfo?.tavigationConfigData?.tabBarStyle,f={accessPortalObId:r,title:o,sortNo:``,moduleObId:l?.moduleObId||``,name:c,isBelongNavigation:typeof u==`boolean`?u?1:0:1,icon:``,iconFileId:``,pluginGxId:``,note:d||`pic-text`,zxlPrdId:t},p=await n(f);e.moduleObId=f.moduleObId,e.uuid=p?.menuObId||e.uuid,e._source=p||void 0}catch{}}async function y(e,n,r,s,c){if(!e||!n||!r||!s||!c)return;let{id:l,relatedId:u,no:d,icon:f,iconType:p,pageType:m,isApplyTarbar:h,name:g}=e;try{let l={title:g,menuObId:r,sortNo:d,accessPortalObId:c,formObId:u,functionObId:(await i({url:`/zxl_pm/request/function.svc?cmd=saveOrUpdate`,method:`post`,data:{functionName:g,functionType:``,moduleObId:s,note:``,zxlPrdId:n}}))?.functionObId||``,name:g,isBelongNavigation:h?1:0,icon:f,iconFileId:``,pluginGxId:``,note:``,zxlPrdId:n},p=await a(l),m=p?.menuItemObId;if(e.functionObId=l.functionObId,e.id=m||e.id,e.route=`/${e.id}`,e._source=p||void 0,u){let r=null;try{r=await o(u)}catch{}r||await t({zxlPrdId:n,userIntfId:u,userIntfName:g,functionId:l.functionObId,note:``,protoType:`GENERATE`,accessPortalObId:c,formType:`PAGE`,formFunctionType:`Other`,formTemplateObId:``,entryFormObId:``,sourceEntryObjectObid:e.id,sourceEntryType:`MENU_ITEM`,sourceEntryObjectName:g})}}catch{}}async function b(t,n){try{let i=t.id,a=(await e.getByConditionAction({zxlPrdId:n,menuItemObId:i,isPaging:!1}))?.data||[];if(await Promise.all(a.map(e=>s.deleteMenuAction({menuOperationObId:e.menuOperationObId,zxlPrdId:n}))),await r({menuItemObId:t.id,zxlPrdId:n}),t.functionObId){let e=t.functionObId,r=(await c({productId:n,objectType:`ZxlPrdRequestSubfunction`,scopeIdValue:e}))?.data||[];await Promise.all(r.map(e=>u({subfunctionObId:e.subfunctionObId,zxlPrdId:n}))),await l({functionObId:e,zxlPrdId:n})}}catch{}}export{d as a,g as i,h as n,f as o,m as r,p as t};