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