import{c as o,o as a,a as t,t as s,f as c,w as k,e as f,n as L,F as x,g as _,d as I,u as A,r as d,i as M,b as T,k as S}from"./app-q0jdcHwC.js";import{a as V,S as P}from"./swiper-C0QydVq3.js";import{S as $}from"./SkeletonLoader-DoyP93ZN.js";import{_ as D}from"./BlogCard-BB6ezurd.js";import"./EyeIcon-VDtOleu5.js";function F(m,v){return a(),o("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"})])}const z={class:"main-container py-4 sm:py-6 bg-slate-100 mt-[25px]"},E={class:"w-full p-3 sm:p-6 bg-white rounded-md md:rounded-2xl"},R={key:0},U={class:"text-slate-800 text-lg sm:text-xl md:text-3xl font-bold"},Z={class:"grow overflow-x-auto mt-2 sm:mt-3 md:mt-4"},q=["onClick"],G={key:1},J={class:"mt-3 flex gap-3 flex-wrap"},K={__name:"BlogHeader",props:{categories:Array,categoryId:Number,isLoading:{type:Boolean,default:!0}},emits:["changeCategory"],setup(m,{emit:v}){const g=v,u=l=>{g("changeCategory",l)};return(l,n)=>(a(),o("div",z,[t("div",E,[m.isLoading?(a(),o("div",G,[c($,{class:"w-10/12 h-10 rounded-lg"}),t("div",J,[(a(),o(x,null,_(8,r=>c($,{key:r,class:"w-40 h-12 rounded-lg grow"})),64))])])):(a(),o("div",R,[t("div",U,s(l.$t("Ready Blogs")),1),t("div",Z,[c(f(P),{slidesPerView:"auto",spaceBetween:16,class:"categorySwiper"},{default:k(()=>[c(f(V),null,{default:k(()=>[t("div",{class:L(["px-3 sm:px-4 py-1.5 sm:py-2.5 rounded-md sm:rounded-[10px] border text-base font-normal leading-normal hover:text-primary cursor-pointer transition duration-300 bg-slate-100",m.categoryId?"border-slate-100 text-slate-600":"text-primary border-primary"]),onClick:n[0]||(n[0]=r=>u(""))},s(l.$t("All Blogs")),3)]),_:1}),(a(!0),o(x,null,_(m.categories,r=>(a(),I(f(V),{key:r.id},{default:k(()=>[t("div",{class:L(["px-3 sm:px-4 py-1.5 sm:py-2.5 rounded-md sm:rounded-[10px] border text-base font-normal leading-normal hover:text-primary cursor-pointer transition duration-300 bg-slate-100",r.id==m.categoryId?"text-primary border-primary":"border-slate-100 text-slate-600"]),onClick:i=>u(r.id)},s(r.name),11,q)]),_:2},1024))),128))]),_:1})])]))])]))}},O={class:"main-container py-4 pb-8 md:pb-12"},Q={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-3 sm:gap-6 items-start"},W={key:0,class:"flex justify-center items-center w-full mt-8"},X={class:"text-slate-800 text-base font-normal leading-normal"},Y={class:"flex items-center bg-slate-100 justify-center w-40 h-40 rounded-full"},ee={class:"mt-3 md:mt-6 text-xl md:text-2xl text-slate-600 italic text-center"},te={key:1,class:"flex justify-between items-center w-full mt-8 gap-4 flex-wrap"},ae={class:"text-slate-800 text-base font-normal leading-normal"},h=12,ie={__name:"Blog",setup(m){const v=A(),g=d(!0),u=d(!1),l=d(!1);M(()=>{b(),C()});const n=d([]),r=d([]),i=d(1),y=d(null),w=d(0),H=e=>{y.value=e,i.value=1,l.value=!0,b()},N=e=>{i.value=e,l.value=!0,b()},b=()=>{g.value=!0,l.value||(u.value=!0),axios.get("/blogs",{params:{page:i.value,per_page:h,category_id:y.value},headers:{"Accept-Language":v.locale||"en"}}).then(e=>{w.value=e.data.data.total,n.value=e.data.data.blogs,r.value=e.data.data.categories,setTimeout(()=>{g.value=!1,u.value=!1,l.value=!1,C()},100)}).catch(e=>{g.value=!1,l.value=!1,u.value=!1})},C=()=>{window.scrollTo({top:0,behavior:"smooth"})};return(e,B)=>{const j=T("vue-awesome-paginate");return a(),o("div",null,[c(K,{categories:r.value,isLoading:u.value,categoryId:y.value,onChangeCategory:H},null,8,["categories","isLoading","categoryId"]),t("div",O,[t("div",Q,[g.value?(a(),o(x,{key:1},_(8,p=>c($,{key:p,class:"w-full h-[300px] sm:h-[340px] rounded-lg md:rounded-2xl"})),64)):(a(!0),o(x,{key:0},_(n.value,p=>(a(),I(D,{key:p.id,blog:p},null,8,["blog"]))),128))]),n.value.length==0?(a(),o("div",W,[t("div",X,[t("div",Y,[c(f(F),{class:"w-20 h-20 text-slate-400"})]),t("p",ee,s(e.$t("No blogs found")),1)])])):S("",!0),n.value.length>0?(a(),o("div",te,[t("div",ae,s(e.$t("Showing"))+" "+s(h*(i.value-1)+1)+" "+s(e.$t("to"))+" "+s(h*(i.value-1)+n.value.length)+" "+s(e.$t("of"))+" "+s(w.value)+" "+s(e.$t("results")),1),t("div",null,[c(j,{"total-items":w.value,"items-per-page":h,type:"button","max-pages-shown":5,modelValue:i.value,"onUpdate:modelValue":B[0]||(B[0]=p=>i.value=p),"hide-prev-next-when-ends":!0,onClick:N},null,8,["total-items","modelValue"])])])):S("",!0)])])}}};export{ie as default};
