import{a as p,o as b,y as c,z as v,J as g,K as x,A as C,I as u,P as k,D as s,Q as y}from"./EchoChannel-Bg1-kez_.js";import h from"./UserCard-B-8955vz.js";import{_ as L}from"./PostCard-DlF_9FHh.js";import U from"./AccountCard-hDdZxS6e.js";import _ from"./ContactPopUp-BjUONe1c.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 N=["onClick","name"],S={key:0,class:"w-full flex justify-center pt-8"},M={__name:"ListCards",props:{data:{type:[Array,Object],required:!1},resourceType:{type:String},resourceId:{type:String},cardType:{type:String,default:"posts"},showUntil:{type:Number,default:0},columns:{type:String,default:5}},setup(a){const e=a,r=p({}),l=p({}),n=p(!0),i=p(null);function w(){return n.value=!1,l.value=r.value}const T=async()=>{let d=e.cardType;switch(e.cardType){case"people":d="speakers";break}try{const o=await fetch(`/${e.resourceType}/${d}/${e.resourceId}`,{headers:{"X-Requested-With":"XMLHttpRequest"}});r.value=await o.json();let t=Object.keys(r.value);l.value=t.slice(0,e.showUntil).reduce((m,f)=>(m[f]=r.value[f],m),{}),n.value=t.length>e.showUntil}catch(o){console.error(o),r.value=[],l.value=[]}};function $(){n.value=e.data.length>e.showUntil,r.value=e.data,l.value=e.data.slice(0,e.showUntil)}return b(()=>{e.data&&$(),e.resourceId&&e.resourceType&&e.cardType&&T()}),(d,o)=>(s(),c(g,null,[v("ul",{class:C(["list_cards grid grid-cols-2 gap-8 pt-8",a.columns!=="5"?`md:grid-cols-${a.columns}`:"md:grid-cols-3 lg:grid-cols-5 xl:grid-cols-6"])},[(s(!0),c(g,null,x(l.value,t=>(s(),c("li",{key:t},[a.cardType==="speakers"?(s(),c("button",{key:0,onClick:m=>i.value=t.id,name:`See more about ${t.fullName}.`,class:"text-left"},[k(h,{user:t},null,8,["user"])],8,N)):u("",!0),a.cardType==="people"?(s(),y(h,{key:1,user:t},null,8,["user"])):u("",!0),a.cardType==="posts"?(s(),y(L,{key:2,post:t},null,8,["post"])):u("",!0),["accounts","sponsors","institutions"].includes(a.cardType)?(s(),y(U,{key:3,account:t},null,8,["account"])):u("",!0)]))),128))],2),n.value?(s(),c("div",S,[v("button",{onClick:w,class:"py-2 px-8 bg-qorus-purple text-white text-center"},"View more ")])):u("",!0),k(_,{popup:i.value!==null,"contact-id":i.value,onClose:o[0]||(o[0]=t=>i.value=null)},null,8,["popup","contact-id"])],64))}};export{M as default};