import{d as S,a4 as V,a5 as C,f as o,r as p,ah as R,w as z,a6 as D,c as l,a as t,t as i,M as N,F as P,g as $,O as F,b as I,K,N as M,h as q,af as O,ab as U,o as n,ai as G,aj as H}from"./index-DgWYpsy5.js";import{E as J,e as Q}from"./empty-BrNRZSoD.js";import{E as W}from"./el-select-DZLvrCG9.js";import{P as X}from"./index-B7S9Vbvs.js";const Y={class:"container max-w-[1500px] mx-auto px-[4%] md:px-0"},Z={class:"flex flex-row flex-wrap md:flex-nowrap justify-between py-16 items-center"},ee={class:"text-3xl basis-full md:basis-auto"},ae={class:"basis-full md:basis-auto mt-[32px] md:mt-0 whitespace-nowrap overflow-scroll"},te=["href"],se=["href"],oe={class:"grid grid-cols-2 md:grid-cols-4 gap-3 mt-3"},ne=["onClick"],re={class:"relative pt-[100%]"},le={class:"absolute inset-0 hover-card"},ce=["src"],ie={class:"py-2"},ue={class:"text-xl md:text-xl font-semibold mt-2 md:mt-7"},de={class:"text-sm md:text-sm mt-1 md:mt-2 truncate"},me={class:"flex justify-center"},_e=S({__name:"CategoryView",setup(pe){const _=V(),{navTabs:E}=C(_),{curLanKey:v}=C(_),c=o(()=>{var s,m;const e=(m=(s=k.currentRoute.value)==null?void 0:s.params)==null?void 0:m.type;return Array.isArray(e)?e.join("_"):e}),g=o(()=>{var e;return(e=c.value.split("_"))==null?void 0:e[0]}),h=o(()=>E.value.find(e=>e.key===g.value)),T=o(()=>{var e;return(e=h.value)==null?void 0:e.name}),x=o(()=>{var e;return((e=c.value.split("_"))==null?void 0:e[1])??""}),b=o(()=>{var e;return((e=h.value)==null?void 0:e.children)??[]}),j=o(()=>{var e;return((e=b.value.find(s=>s.key===c.value))==null?void 0:e.name)??""});p([{img:G,url:""},{img:H,url:""}]);const u=p(!1),d=p([]),f=p(0),r=R({language:v.value,category:"",category1:"",pageNum:1,pageSize:12});async function y(){u.value=!0;try{r.language=v.value;const e=await X.getProductPage(r);f.value=e.pages,d.value=e.records,u.value=!1}catch(e){f.value=1,d.value=[],u.value=!1,console.error(e)}}const k=O();function A(e){k.push(`/product/${e}`)}return z(v,async()=>await y()),D(async()=>{r.category=T.value,r.category1=j.value,await y()}),(e,s)=>{const m=W,B=J,L=U;return n(),l("main",null,[t("div",Y,[t("div",Z,[t("div",ee,i(e.$t(`productCategory.${g.value}`).replace("::","|")),1),t("div",ae,[t("a",{href:`/category/${g.value}`,class:N(["inline-block text-sm",{"text-[#ff4d00]":x.value==="","font-bold":x.value===""}])},i(e.$t("productCategory.allProducts")),11,te),(n(!0),l(P,null,$(b.value,(a,w)=>(n(),l("a",{key:w,href:`/category/${a.key}`,class:N(["text-sm ml-10 inline-block",{"text-[#ff4d00]":c.value===a.key,"font-bold":c.value===a.key}])},i(e.$t(`productCategory.${a.key}`).replace("::","|")),11,se))),128))])]),F((n(),l("div",oe,[(n(!0),l(P,null,$(d.value,a=>(n(),l("div",{class:"col-span-1 cursor-pointer mb-6 md:mb-14",key:a.id,onClick:w=>A(a.id)},[t("div",re,[t("div",le,[t("img",{src:a.images.split(",")[0],alt:"product",class:"w-full max-w-max"},null,8,ce)])]),t("div",ie,[t("div",ue,i(a.model),1),t("div",de,i(a.desc),1)])],8,ne))),128))])),[[L,u.value]]),t("div",me,[I(m,{"current-page":r.pageNum,"onUpdate:currentPage":s[0]||(s[0]=a=>r.pageNum=a),"page-count":f.value,layout:"prev, pager, next",onChange:y},null,8,["current-page","page-count"])]),d.value.length?q("",!0):(n(),K(B,{key:0,image:M(Q),description:e.$t("empty.product")},null,8,["image","description"]))])])}}});export{_e as default};