import{r as u,y as a,J as i,K as p,z as f,S as m,Q as g,I as l,D as o,P as h}from"./EchoChannel-Bg1-kez_.js";import{_}from"./PostCard-DlF_9FHh.js";import b from"./SpinnerLoader-WkHXMWXk.js";import"./dayjs.min-Bx9f1rse.js";import"./Tape.vue_vue_type_script_setup_true_lang-C9KTCQTt.js";import"./premium-Ui5zlKac.js";import"./Arrow-Right-CuiMYOZx.js";const x={class:"grid content-start text-base"},B={class:"flex justify-center col-span-full"},y=["disabled"],$={__name:"CardLoader",props:{url:{type:String,required:!0},initialLoad:{type:Boolean,required:!0},past:{default:!1,type:Boolean}},setup(d){const e=u({page:0,content:[],hideLoadButton:!1,loading:!1}),s=d,n=async()=>{e.page++,e.loading=!0;try{const t=await(await fetch(`${s.url}&page=${e.page}`,{headers:{"X-Requested-With":"XMLHttpRequest"}})).json();t.length<12&&(e.hideLoadButton=!0),e.loading=!1,e.content=e.content.concat(t)}catch(r){console.error(r),e.hideLoadButton=!0,e.loading=!1}};return s.initialLoad&&n(),(r,t)=>(o(),a(i,null,[(o(!0),a(i,null,p(e.content,c=>(o(),a("div",x,[h(_,{post:c},null,8,["post"])]))),256)),f("div",B,[e.hideLoadButton?l("",!0):(o(),a("button",{key:0,onClick:n,disabled:e.loading,class:"w-fit flex gap-x-4 items-center border-qorus-purple border-2 text-qorus-purple p-2 cursor-pointer hover:bg-qorus-purple hover:text-white disabled:cursor-not-allowed disabled:bg-qorus-purple disabled:text-white"},[t[0]||(t[0]=m(" View more ")),e.loading?(o(),g(b,{key:0})):l("",!0)],8,y))])],64))}};export{$ as default};