import{_ as v,x as C,a as S,e as K,o as l,g as m,h as x,F as f,f as h,w as u,c as p,i as k,t as $,A as M,b2 as A,p as b,cA as w,r as y,E as O,G as E,J as V,M as z}from"./app-DNXD_-wA.js";import{M as B}from"./MailOutlined-C5pn3hGF.js";import{A as F}from"./AppstoreOutlined-ERpFjrTx.js";import{S as I}from"./SettingOutlined-DG8pWqKj.js";const L=C({name:"category-menu",props:["categories"],setup(){const{frontWarehouse:o}=S();return{frontWarehouse:o}}});function N(o,i,c,d,g,_){const t=M,a=K("category-menu"),n=A,s=K("router-link"),e=b;return l(!0),m(f,null,x(o.categories,r=>(l(),m(f,{key:r.xid},[r.children&&r.children.length?(l(),h(n,{key:r.xid,title:r.name},{icon:u(()=>[p(t,{size:16,src:r.image_url},null,8,["src"])]),default:u(()=>[p(a,{categories:r.children},null,8,["categories"])]),_:2},1032,["title"])):(l(),h(e,{key:r.xid},{default:u(()=>[p(s,{to:{name:"front.categories",params:{warehouse:o.frontWarehouse.slug,slug:[r.slug]}}},{default:u(()=>[p(t,{size:16,src:r.image_url},null,8,["src"]),k(" "+$(r.name),1)]),_:2},1032,["to"])]),_:2},1024))],64))),128)}const U=v(L,[["render",N]]),W=C({props:["catSelectedKeys","catOpenKeys"],components:{MailOutlined:B,CalendarOutlined:w,AppstoreOutlined:F,SettingOutlined:I,CategoryMenu:U},setup(o){const i=y([]),c=y([]),d=y([]);O(()=>{c.value=o.catSelectedKeys,g()});const g=()=>{axiosFront.post("front/categories").then(t=>{const a=[];var n=t.data.categories;n.forEach(s=>{if(!s.x_parent_id)return a.push(s);const e=n.findIndex(r=>r.xid===s.x_parent_id);if(!n[e].children)return n[e].children=[s];n[e].children.push(s)}),i.value=a})},_=(t,a)=>{var n,s=t.id;if(!(!t||typeof t!="object"))return t.id===a?[s]:((t.children||[]).some(e=>n=_(e,a)),n&&[s].concat([...n]))};return E(o,(t,a)=>{c.value=t.catSelectedKeys;let n=[];i.value.forEach(s=>{const e=_(s,c.value[0]);e!=null&&e.includes(c.value[0])&&(n=e)}),d.value=n}),{selectedKeys:c,openKeys:d,allCategories:i}}});function j(o,i,c,d,g,_){const t=M,a=K("CategoryMenu"),n=A,s=z;return l(),h(s,{selectedKeys:o.selectedKeys,"onUpdate:selectedKeys":i[0]||(i[0]=e=>o.selectedKeys=e),openKeys:o.openKeys,"onUpdate:openKeys":i[1]||(i[1]=e=>o.openKeys=e),style:{width:"100%"},mode:"inline"},{default:u(()=>[(l(!0),m(f,null,x(o.allCategories,e=>(l(),m(f,{key:e.xid},[e.children&&e.children.length?(l(),h(n,{key:e.xid},{icon:u(()=>[p(t,{size:16,src:e.image_url},null,8,["src"])]),title:u(()=>[k($(e.name),1)]),default:u(()=>[p(a,{categories:e.children},null,8,["categories"])]),_:2},1024)):V("",!0)],64))),128))]),_:1},8,["selectedKeys","openKeys"])}const T=v(W,[["render",j]]);export{T as L};
