@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 5.48 kB
JavaScript
import{__esDecorate as o,__runInitializers as g}from"tslib";import{action as D,computed as d,observable as I}from"mobx";import{generateUniqueSlug as w}from"../tools/slug";let y=(()=>{let n=[],m,u,v,h,f,_,i,r,c,k,p;return class{static{const t=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;m=[d],u=[d],v=[d],h=[d],f=[d],_=[d],i=[d],r=[d],c=[d],k=[D],p=[D],o(this,null,m,{kind:"getter",name:"bookmarked",static:!1,private:!1,access:{has:e=>"bookmarked"in e,get:e=>e.bookmarked},metadata:t},null,n),o(this,null,u,{kind:"getter",name:"visited",static:!1,private:!1,access:{has:e=>"visited"in e,get:e=>e.visited},metadata:t},null,n),o(this,null,v,{kind:"getter",name:"tracks",static:!1,private:!1,access:{has:e=>"tracks"in e,get:e=>e.tracks},metadata:t},null,n),o(this,null,h,{kind:"getter",name:"venues",static:!1,private:!1,access:{has:e=>"venues"in e,get:e=>e.venues},metadata:t},null,n),o(this,null,f,{kind:"getter",name:"pastEvents",static:!1,private:!1,access:{has:e=>"pastEvents"in e,get:e=>e.pastEvents},metadata:t},null,n),o(this,null,_,{kind:"getter",name:"futureEvents",static:!1,private:!1,access:{has:e=>"futureEvents"in e,get:e=>e.futureEvents},metadata:t},null,n),o(this,null,i,{kind:"getter",name:"liveEvents",static:!1,private:!1,access:{has:e=>"liveEvents"in e,get:e=>e.liveEvents},metadata:t},null,n),o(this,null,r,{kind:"getter",name:"todayEvents",static:!1,private:!1,access:{has:e=>"todayEvents"in e,get:e=>e.todayEvents},metadata:t},null,n),o(this,null,c,{kind:"getter",name:"tomorrowEvents",static:!1,private:!1,access:{has:e=>"tomorrowEvents"in e,get:e=>e.tomorrowEvents},metadata:t},null,n),o(this,null,k,{kind:"method",name:"replaceBookmarked",static:!1,private:!1,access:{has:e=>"replaceBookmarked"in e,get:e=>e.replaceBookmarked},metadata:t},null,n),o(this,null,p,{kind:"method",name:"replaceVisited",static:!1,private:!1,access:{has:e=>"replaceVisited"in e,get:e=>e.replaceVisited},metadata:t},null,n),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}rootStore=g(this,n);eventItems=[];constructor(t){this.rootStore=t}findByNameOrSlug(t){return this.eventItems.find(e=>e.name===t||e.slug===t||e.externalId===t)}get bookmarked(){return this.eventItems.filter(t=>t.bookmarked)}get visited(){return this.eventItems.filter(t=>t.visited)}get tracks(){const t=new Map;return this.eventItems.forEach(e=>{e.tracks.forEach(a=>{t.set(a.id,a)})}),Array.from(t.values()).sort((e,a)=>e.name.localeCompare(a.name))}getEventsByTrack(t){return this.eventItems.filter(e=>e.tracks.some(a=>a.id===t))}getEventsBySpeaker(t){return this.eventItems.filter(e=>e.speakers.some(a=>a.id===t))}get venues(){const t=new Map;return this.eventItems.forEach(e=>{if(e.boothId){const a=this.rootStore.boothStore.booths.find(l=>l.id===e.boothId);a&&t.set(a.id,a)}}),Array.from(t.values()).sort((e,a)=>e.name.localeCompare(a.name))}getEventsByVenue(t){return this.eventItems.filter(e=>e.boothId===t)}get pastEvents(){const t=new Date;return this.eventItems.filter(e=>new Date(e.endDate)<t)}get futureEvents(){const t=new Date;return this.eventItems.filter(e=>new Date(e.startDate)>t)}get liveEvents(){const t=new Date;return this.eventItems.filter(e=>{const a=new Date(e.startDate),l=new Date(e.endDate);return a<=t&&t<=l})}get todayEvents(){const t=new Date;return t.setHours(0,0,0,0),this.eventItems.filter(e=>{const a=new Date(e.startDate);return a.setHours(0,0,0,0),a.getTime()===t.getTime()})}get tomorrowEvents(){const t=new Date;return t.setDate(t.getDate()+1),t.setHours(0,0,0,0),this.eventItems.filter(e=>{const a=new Date(e.startDate);return a.setHours(0,0,0,0),a.getTime()===t.getTime()})}replaceBookmarked(t){const e=(t||[]).map(s=>this.eventItems.find(b=>b.id===s)).filter(s=>s),a=new Set(e),l=this.bookmarked.filter(s=>!a.has(s));for(const s of l)s.bookmarked=!1;for(const s of e)s.bookmarked=!0}replaceVisited(t){const e=(t||[]).map(s=>this.eventItems.find(b=>b.id===s)).filter(s=>s),a=new Set(e),l=this.visited.filter(s=>!a.has(s));for(const s of l)s.visited=!1;for(const s of e)s.visited=!0}}})();export default y;let S=(()=>{let n,m=[],u=[],v,h=[],f=[];return class{static{const i=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;n=[I],v=[I],o(null,null,n,{kind:"field",name:"bookmarked",static:!1,private:!1,access:{has:r=>"bookmarked"in r,get:r=>r.bookmarked,set:(r,c)=>{r.bookmarked=c}},metadata:i},m,u),o(null,null,v,{kind:"field",name:"visited",static:!1,private:!1,access:{has:r=>"visited"in r,get:r=>r.visited,set:(r,c)=>{r.visited=c}},metadata:i},h,f),i&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:i})}id;externalId;boothId;name;description;startDate;endDate;logoFile;speakers;tracks;entity;slug;bookmarked=g(this,m,!1);visited=(g(this,u),g(this,h,!1));constructor(i,r,c,k,p,E,t,e,a=[],l=[],s={type:"event"}){g(this,f),this.id=i,this.externalId=r,this.boothId=c,this.name=k,this.description=p,this.startDate=E,this.endDate=t,this.logoFile=e,this.speakers=a,this.tracks=l,this.entity=s,this.slug=w(k||`event-${i}`)}get isEnded(){return this.endDate&&new Date(this.endDate).getTime()<new Date().getTime()}get hasSpeakers(){return this.speakers.length>0}get hasTracks(){return this.tracks.length>0}get primaryTrack(){return this.tracks.length>0?this.tracks[0]:null}get speakerNames(){return this.speakers.map(i=>i.name).join(", ")}get trackNames(){return this.tracks.map(i=>i.name).join(", ")}}})();export{S as EventItem};