@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 6.59 kB
JavaScript
import{__esDecorate as s,__runInitializers as l}from"tslib";import{action as M,computed as i,observable as S}from"mobx";import{lineLength as C,lineRectangleIntersections as L,pointInsideRectangle as R,Rect as N}from"simple-geometry";import E from"../tools/settings";import{uiState as j}from"./index";let O=(()=>{let o=[],d,c=[],m=[],u,b=[],g=[],k,p,y,f,_,v,B;return class{static{const t=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;d=[S],u=[S],k=[i({keepAlive:!0})],p=[i({keepAlive:!0})],y=[i({keepAlive:!0})],f=[i({keepAlive:!0})],_=[i({keepAlive:!0})],v=[i],B=[M],s(this,null,k,{kind:"getter",name:"boothById",static:!1,private:!1,access:{has:e=>"boothById"in e,get:e=>e.boothById},metadata:t},null,o),s(this,null,p,{kind:"getter",name:"boothByExternalId",static:!1,private:!1,access:{has:e=>"boothByExternalId"in e,get:e=>e.boothByExternalId},metadata:t},null,o),s(this,null,y,{kind:"getter",name:"boothByName",static:!1,private:!1,access:{has:e=>"boothByName"in e,get:e=>e.boothByName},metadata:t},null,o),s(this,null,f,{kind:"getter",name:"boothBySlug",static:!1,private:!1,access:{has:e=>"boothBySlug"in e,get:e=>e.boothBySlug},metadata:t},null,o),s(this,null,_,{kind:"getter",name:"borderWidth",static:!1,private:!1,access:{has:e=>"borderWidth"in e,get:e=>e.borderWidth},metadata:t},null,o),s(this,null,v,{kind:"getter",name:"bookmarked",static:!1,private:!1,access:{has:e=>"bookmarked"in e,get:e=>e.bookmarked},metadata:t},null,o),s(this,null,B,{kind:"method",name:"replaceBookmarked",static:!1,private:!1,access:{has:e=>"replaceBookmarked"in e,get:e=>e.replaceBookmarked},metadata:t},null,o),s(null,null,d,{kind:"field",name:"booths",static:!1,private:!1,access:{has:e=>"booths"in e,get:e=>e.booths,set:(e,r)=>{e.booths=r}},metadata:t},c,m),s(null,null,u,{kind:"field",name:"highlightedByExternalIds",static:!1,private:!1,access:{has:e=>"highlightedByExternalIds"in e,get:e=>e.highlightedByExternalIds,set:(e,r)=>{e.highlightedByExternalIds=r}},metadata:t},b,g),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}rootStore=l(this,o);booths=l(this,c,[]);highlightedByExternalIds=(l(this,m),l(this,b,[]));get boothById(){return new Map(this.booths.map(t=>[t.id,t]))}get boothByExternalId(){return new Map(this.booths.map(t=>[t.externalId,t]))}get boothByName(){return new Map(this.booths.map(t=>[t.name.toLowerCase(),t]))}get boothBySlug(){return new Map(this.booths.map(t=>[t.slug,t]))}get borderWidth(){if(E.boothBorderWidth)return E.boothBorderWidth;if(E.EXPO==="groomexpo")return .4;const t=this.booths.filter(e=>e.rect).map(e=>e.rect.w+e.rect.h);return t.reduce((e,r)=>e+r,0)/t.length/80}constructor(t){l(this,g),this.rootStore=t}get bookmarked(){return this.booths.filter(t=>t.bookmarkedDirectly)}getNearestBooth(t){var e=null;const x=this.booths.map(a=>{const{x1:n,x2:I,y1:h,y2:D}=a.rect,A=Math.abs(I-n),z=Math.abs(D-h);return{lineLength:C(t,L({p0:t,p1:{x:a.rect.cx,y:a.rect.cy}},new N({x:n,y:h},{x:n+A,y:h},{x:n+A,y:h+z},{x:n,y:h+z}))[0]),name:a.name}}).sort((a,n)=>a.lineLength-n.lineLength)[0];return e=this.booths.find(a=>a.name===x.name),e}getBoothAtPoint(t){return this.booths.find(e=>{const{x1:r,x2:x,y1:a,y2:n}=e.rect,I=Math.abs(x-r),h=Math.abs(n-a),D=new N({x:r,y:a},{x:r+I,y:a},{x:r+I,y:a+h},{x:r,y:a+h});return R(t,D)})}findBooth(t){return this.boothByExternalId.get(t)||this.boothByName.get(t.toLowerCase())||this.boothBySlug.get(t)}replaceBookmarked(t){const e=(t||[]).map(a=>this.boothById.get(a)).filter(a=>a),r=new Set(e),x=this.bookmarked.filter(a=>!r.has(a));for(const a of x)a.bookmarkedDirectly=!1;for(const a of e)a.bookmarkedDirectly=!0}}})();export default O;let w=(()=>{let o=[],d,c=[],m=[],u,b=[],g=[],k,p,y,f,_,v,B;return class{static{const t=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;d=[S],u=[S],k=[i({keepAlive:!0})],p=[i({keepAlive:!0})],y=[i({keepAlive:!0})],f=[i({keepAlive:!0})],_=[i({keepAlive:!0})],v=[i({keepAlive:!0})],B=[i({keepAlive:!0})],s(this,null,k,{kind:"getter",name:"bookmarked",static:!1,private:!1,access:{has:e=>"bookmarked"in e,get:e=>e.bookmarked},metadata:t},null,o),s(this,null,p,{kind:"getter",name:"uiState",static:!1,private:!1,access:{has:e=>"uiState"in e,get:e=>e.uiState},metadata:t},null,o),s(this,null,y,{kind:"getter",name:"fullName",static:!1,private:!1,access:{has:e=>"fullName"in e,get:e=>e.fullName},metadata:t},null,o),s(this,null,f,{kind:"getter",name:"visible",static:!1,private:!1,access:{has:e=>"visible"in e,get:e=>e.visible},metadata:t},null,o),s(this,null,_,{kind:"getter",name:"hover",static:!1,private:!1,access:{has:e=>"hover"in e,get:e=>e.hover},metadata:t},null,o),s(this,null,v,{kind:"getter",name:"selected",static:!1,private:!1,access:{has:e=>"selected"in e,get:e=>e.selected},metadata:t},null,o),s(this,null,B,{kind:"getter",name:"skipDim",static:!1,private:!1,access:{has:e=>"skipDim"in e,get:e=>e.skipDim},metadata:t},null,o),s(null,null,d,{kind:"field",name:"layer",static:!1,private:!1,access:{has:e=>"layer"in e,get:e=>e.layer,set:(e,r)=>{e.layer=r}},metadata:t},c,m),s(null,null,u,{kind:"field",name:"bookmarkedDirectly",static:!1,private:!1,access:{has:e=>"bookmarkedDirectly"in e,get:e=>e.bookmarkedDirectly,set:(e,r)=>{e.bookmarkedDirectly=r}},metadata:t},b,g),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}store=l(this,o);id;name;externalId;title;rect;borderWidth;borderColor;noLabels;rotate;paths;pathsWithRect;slug;error;description;exhibitors;labelColor;schedule;poiTypeId;poiType;poiIcon;meta;layer=l(this,c,void 0);bookmarkedDirectly=(l(this,m),l(this,b,!1));get bookmarked(){return j.disableBookmarked?!1:this.schedule?.some(t=>t.bookmarked)?!0:this.exhibitors.length>0?!!this.exhibitors.find(t=>t.bookmarked):this.bookmarkedDirectly}get uiState(){return this.store.rootStore.uiState}get fullName(){const t=this.meta?Object.entries(this.meta).filter(([e])=>!e.startsWith("_")).map(([e,r])=>`${e} ${r}`).join(" "):"";return`${this.name} ${t}`.replace(/\s+/g," ").trim()}get visible(){return this.layer?.visible??!0}get hover(){return this.uiState.hoveredBooths.has(this)}get selected(){return this.uiState.selectedBooths.has(this)}get skipDim(){return this.uiState.highlightedBooths.has(this.id.toString())}constructor(){l(this,g)}}})();export{w as BoothBase};export class RegularBooth extends w{buyUrl;reserveUrl;type;status;price;entity={type:"booth",variant:"regular"};size;availColor;soldColor;holdColor;onHold;reserved;shapes}export class SpecialBooth extends w{color;shapes;entity={type:"booth",variant:"special"}}