import{u as e,M as t,P as i,gq as r,bE as a,C as s,gr as n,R as l}from"./utils-lib.js?v=1761009159";import{r as o}from"./base-lib.js?v=1761009159";import{g as d}from"./useStore.js?v=1761009159";const{isRefreshMenu:u}=e(),h=o(),c=async e=>{try{const a={hide_list:JSON.stringify([e.id])};if(e.parentId){a.site_menu=1;const i=h.value.find(t=>t.id===e.parentId);if(i.children){if(0===i.children.filter(e=>e.show).length&&i.show)return t.error("子项至少保留一个显示"),void(u.value=!0)}}if("memuAsite"===e.id){const e=h.value.find(e=>"memuAsite"===e.id);if(0===e.children.filter(e=>e.show).length&&e.show)return t.error("请先开启任意一项网站子栏目"),void(u.value=!0)}await i({request:r(a),message:!0,success:()=>{u.value=!0;const{refs:{panelConfig:t}}=d(),i=t.value.menuHide.indexOf(e.title);t.value.menuHide=i>-1?t.value.menuHide.split("、").filter(t=>t!==e.title).join("、"):t.value.menuHide?"".concat(t.value.menuHide,"、").concat(e.title):e.title}})}catch(a){}},m=async()=>{try{const e=await i({request:a(),data:Array}),t=e.map(({id:e,title:t,show:i,children:r})=>{const a=n(e);return r=!(!r||!l(r))&&r.map(({id:t,title:i,show:r})=>("proxy"===t&&(t="nginx"),{show:r,parentId:e,id:t,title:i})),{name:a,title:t,show:i,id:e,children:r}});return s.value=((e,t)=>e.map((e,i)=>{var r;const a=(null==(r=e.children)?void 0:r.length)?e.children.map((e,r)=>Array.isArray(t[i].children)?{...e,show:t[i].children[r].show}:e):[];return{...e,show:t[i].show,children:a}}))(s.value,t),h.value=t,{data:t,total:t.length,other:{}}}catch(e){return{data:[],total:0,other:{}}}};export{c as h,m as u};
