@mappedin/dynamic-focus 6.5.0-beta.0 → 6.7.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ var Ht=Object.defineProperty,po=Object.defineProperties;var go=Object.getOwnPropertyDescriptors;var qt=Object.getOwnPropertySymbols;var Fo=Object.prototype.hasOwnProperty,yo=Object.prototype.propertyIsEnumerable;var zt=r=>{throw TypeError(r)};var Vt=(r,t,e)=>t in r?Ht(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_=(r,t)=>{for(var e in t||(t={}))Fo.call(t,e)&&Vt(r,e,t[e]);if(qt)for(var e of qt(t))yo.call(t,e)&&Vt(r,e,t[e]);return r},at=(r,t)=>po(r,go(t)),s=(r,t)=>Ht(r,"name",{value:t,configurable:!0});var p=(r,t,e)=>Vt(r,typeof t!="symbol"?t+"":t,e),Mt=(r,t,e)=>t.has(r)||zt("Cannot "+e);var o=(r,t,e)=>(Mt(r,t,"read from private field"),e?e.call(r):t.get(r)),d=(r,t,e)=>t.has(r)?zt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,i)=>(Mt(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),E=(r,t,e)=>(Mt(r,t,"access private method"),e);var b={env:{NODE_ENV:"production",npm_package_version:"6.7.0-beta.0"}};import{Floor as Lo,getMultiFloorState as Co}from"@mappedin/mappedin-js";function Wt(r,t){if(r==null||t==null)return r===t;if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}s(Wt,"arraysEqual");var xt=class xt{constructor(){p(this,"_subscribers",{});p(this,"_abortController",new AbortController);p(this,"_cleanupFunctions",[])}get signal(){return this._abortController.signal}publish(t,e){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,e,i){let n=i==null?void 0:i.signal;if(n!=null&&n.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e);let a=s(()=>this.off(t,e),"cleanup");return n&&n.addEventListener("abort",a,{once:!0}),this._cleanupFunctions.push(a),a}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){if(!this.signal.aborted){for(let t of this._cleanupFunctions)t();this._cleanupFunctions=[],this._subscribers={},this._abortController.abort()}}};s(xt,"PubSub");var St=xt;import{Facade as So,Floor as Eo,FloorStack as vo}from"@mappedin/mappedin-js";var w,st,N,v,S,I,W,K,Ot=class Ot{constructor(t,e){p(this,"__type","building");d(this,w);d(this,st,new Map);d(this,N,new Map);d(this,v,[]);d(this,S);d(this,I);p(this,"defaultFloor");p(this,"activeFloor");p(this,"excluded",!1);p(this,"floorsAltitudesMap",new Map);p(this,"aboveGroundFloors",[]);d(this,W);d(this,K);var n;c(this,w,t),c(this,st,new Map(t.floors.map(a=>[a.id,a]))),c(this,N,new Map(t.floors.map(a=>[a.elevation,a]))),c(this,v,Array.from(o(this,N).values()).sort((a,h)=>a.elevation-h.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,c(this,S,e),this.aboveGroundFloors=o(this,v).filter(a=>a.elevation>=0);let i=(n=t.facade)==null?void 0:n.spaces.map(a=>o(this,S).getState(a)).sort((a,h)=>a.altitude-h.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let a in this.aboveGroundFloors){let h=this.aboveGroundFloors[a],u=i[a];this.floorsAltitudesMap.set(h.elevation,{altitude:u.altitude,effectiveHeight:u.height})}}get id(){return o(this,w).id}get name(){return o(this,w).name}get floors(){return o(this,w).floors}get floorStack(){return o(this,w)}get facade(){return o(this,w).facade}get isCurrentFloorStack(){return this.id===o(this,S).currentFloorStack.id}get isIndoor(){let t=o(this,S).getState(this.facade);return this.isCurrentFloorStack||(t==null?void 0:t.visible)===!1&&(t==null?void 0:t.opacity)===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,W)==null&&c(this,W,Math.max(...o(this,N).keys())),o(this,W)}get minElevation(){return o(this,K)==null&&c(this,K,Math.min(...o(this,N).keys())),o(this,K)}has(t){return Eo.is(t)?o(this,st).has(t.id):vo.is(t)?t.id===o(this,w).id:So.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,N).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,v)[o(this,v).length-1];for(let i=o(this,v).length-1;i>=0;i--){let n=o(this,v)[i];if(n.elevation<=t)return n}}else{if(t<this.minElevation)return o(this,v)[0];for(let i of o(this,v))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,v)[o(this,v).length-1]}cancelAnimation(){o(this,I)&&(o(this,I).animation.cancel(),c(this,I,void 0))}async animateFacade(t,e={duration:150}){var h;let i=((h=o(this,I))==null?void 0:h.state)||o(this,S).getState(this.facade);if(!i||!t||(i==null?void 0:i.opacity)===t.opacity&&(i==null?void 0:i.visible)===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:n,visible:a}=t;if(o(this,S).updateState(this.facade,{visible:!0}),n!==void 0){c(this,I,{animation:o(this,S).animateState(this.facade,{opacity:n},{duration:e.duration}),state:t});let u=await o(this,I).animation;if(c(this,I,void 0),u.result==="cancelled")return u}return a===!1&&o(this,S).updateState(this.facade,{visible:a}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,w).floors.forEach(t=>{o(this,S).updateState(t,{visible:t.id===o(this,S).currentFloor.id})}),this.has(o(this,S).currentFloor)||o(this,S).updateState(this.facade,{visible:!0,opacity:1})}};w=new WeakMap,st=new WeakMap,N=new WeakMap,v=new WeakMap,S=new WeakMap,I=new WeakMap,W=new WeakMap,K=new WeakMap,s(Ot,"Building");var Et=Ot;function Kt(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}s(Kt,"getZoomState");function vt(r,t,e){if(r.__type==="outdoors"&&"floor"in r)return r.floor;let i=r;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}s(vt,"getFloorToShow");function wo(r,t,e){return t?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:r,state:{type:"facade",visible:!0,opacity:.2}}:{facade:r,state:{type:"facade",visible:!0,opacity:1}}}s(wo,"getFacadeState");function ko(r,t,e){return{outdoorOpacity:"initial",floorStates:r.floors.map(i=>{let n=i.id===t.id&&e;return{floor:i,state:{type:"floor",visible:n,geometry:{visible:n},labels:{enabled:n},markers:{enabled:n},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}s(ko,"getSingleBuildingState");function Qt(r,t){if(!t.includes("lock-elevation"))return"initial";for(let e of r)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}s(Qt,"getOutdoorOpacity");function Jt(r,t,e){var i;switch(e){case"in-range":return(i=r[0])!=null&&i.canSetFloor?r[0]:void 0;case"out-of-range":return t;case"transition":default:return}}s(Jt,"getSetFloorTargetFromZoomState");function Xt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:n,mode:a,elevation:h,floorIdsInNavigation:u,floorStackIdsInNavigation:f,multiFloorView:P,getMultiFloorState:R,dynamicBuildingInteriors:bt,isolateBelowGroundView:it,currentElevation:rt}=r,A=new Map,D=it&&rt<0;for(let F of t){let H=e.has(F.id),nt=D&&F.minElevation>=0,It=nt?!1:H,z=nt?!1:At({building:F,currentFloor:i,inRange:n==="in-range",inFocus:H,mode:a,elevation:h,inNavigation:f.includes(F.id),dynamicBuildingInteriors:bt}),Tt=i.floorStack.id===F.id?F.activeFloor:vt(F,a,h),mo=P.enabled?R(F.floors,Tt||F.activeFloor,P==null?void 0:P.floorGap,u,F.floorsAltitudesMap):ko(F.floorStack,Tt||F.activeFloor,z),fo=wo(F.facade,z,it&&rt<0);A.set(F.id,{building:F,showIndoor:z,floorStackState:mo,facadeState:fo,inFocus:It,floorToShow:Tt})}return A}s(Xt,"getBuildingStates");function to(r,t){return r.excluded?"none":t?"indoor":"outdoor"}s(to,"getBuildingAnimationType");function At(r){let{building:t,currentFloor:e,inRange:i,inFocus:n,mode:a,elevation:h,inNavigation:u,dynamicBuildingInteriors:f}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(u===!0)return!0;if(!f)return e.floorStack.type!=="Outdoor";if(!i||!n)return!1;switch(a){case"lock-elevation":return t.getFloorByElevation(h)!=null;default:break}return!0}s(At,"shouldShowIndoor");function oo(r,t,e){return r!==t&&!e}s(oo,"shouldDeferSetFloor");var eo=["default-floor","lock-elevation","nearest-elevation"];import{Floor as Io,FloorStack as To}from"@mappedin/mappedin-js";var Dt="[MappedinJS]";function _t(r="",{prefix:t=Dt}={}){let e="".concat(t).concat(r?"-".concat(r):""),i=s((n,a)=>{if(typeof window<"u"&&window.rnDebug){let h=a.map(u=>u instanceof Error&&u.stack?"".concat(u.message,"\n").concat(u.stack):u);window.rnDebug("".concat(r," ").concat(n,": ").concat(h.join(" ")))}},"rnDebug");return{logState:b.env.NODE_ENV==="test"?3:0,log(...n){this.logState<=0&&(console.log(e,...n),i("log",n))},warn(...n){this.logState<=1&&(console.warn(e,...n),i("warn",n))},error(...n){this.logState<=2&&(console.error(e,...n),i("error",n))},assert(...n){console.assert(...n)},time(n){console.time(n)},timeEnd(n){console.timeEnd(n)},setLevel(n){0<=n&&n<=3&&(this.logState=n)}}}s(_t,"createLogger");var Bo=_t();var Q=Bo;function io(r,t,e,i){return(r<t||r>e)&&Q.warn(i),Math.min(e,Math.max(t,r))}s(io,"clampWithWarning");function Nt(r,t){return!Io.is(r)||(r==null?void 0:r.floorStack)==null||!To.is(t)?!1:r.floorStack.id!==t.id?(Q.warn("Floor (".concat(r.id,") does not belong to floor stack (").concat(t.id,").")),!1):!0}s(Nt,"validateFloorForStack");function Lt(r,t,e,i){return io(r,t,e,"".concat(i," must be between ").concat(t," and ").concat(e,"."))}s(Lt,"validateZoomThreshold");var J=_t("",{prefix:"[DynamicFocus]"});var T,X,lt,Ct,Zt=class Zt{constructor(t,e){d(this,lt);p(this,"__type","outdoors");d(this,T);d(this,X);c(this,T,t),c(this,X,e)}get id(){return o(this,T).id}get floorStack(){return o(this,T)}get floor(){return o(this,T).defaultFloor}matchesFloorStack(t){return t===o(this,T)||t===o(this,T).id}show(){E(this,lt,Ct).call(this,!0)}hide(){E(this,lt,Ct).call(this,!1)}destroy(){this.matchesFloorStack(o(this,X).currentFloorStack)||this.hide()}};T=new WeakMap,X=new WeakMap,lt=new WeakSet,Ct=s(function(t){for(let e of o(this,T).floors)o(this,X).updateState(e,{visible:t})},"#setVisible"),s(Zt,"Outdoors");var wt=Zt;function ro(r,t){var h;let e=r.getByType("floor-stack"),i=e.find(u=>{var f;return((f=u.type)==null?void 0:f.toLowerCase())==="outdoor"}),n=(h=r.getByType("enterprise-venue"))==null?void 0:h.defaultFloor;if(n){let u=r.getById("floor",n);if(u)return u.floorStack}if(i)return i;let a=e.find(u=>u.facade==null&&!t.has(u.id));return a||(J.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}s(ro,"getOutdoorFloorStack");import{getMultiFloorState as Vo}from"@mappedin/mappedin-js";var no={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,customMultiFloorVisibilityState:Vo,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1},ve=.2,we=.4;function Mo(r,t){return"".concat(t," ").concat(r)}s(Mo,"formatMessage");var Gt=class Gt extends Error{constructor(t,e=Dt){super(Mo(t,e)),this.name="MappedinError"}};s(Gt,"MappedinError");var kt=Gt;var xo=s(r=>r,"linearEase"),Oo=s(r=>r*r,"quadEaseIn"),Ao=s(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Do=s(r=>1-(1-r)*(1-r),"quadEaseOut"),_o={linear:xo,"ease-in":Oo,"ease-out":Do,"ease-in-out":Ao};function No(r,t){let e=0;if(t.length<2)return e;let n=t[0]<t[1]?(a,h)=>a>h:(a,h)=>a<h;for(;e<t.length-1&&n(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}s(No,"getInterpolationBreakpoint");function ao(r,t,e,i="ease-in"){if(t.length!==e.length)throw new kt("Input and output ranges must have the same number of values.");r=Math.max(t[0],Math.min(r,t[t.length-1]));let n=No(r,t),a=(r-t[n])/(t[n+1]-t[n]),h=typeof i=="function"?i(a):_o[i](a);return e[n]+h*(e[n+1]-e[n])}s(ao,"interpolateMulti");var V,ut,dt,x,ct,Rt=class Rt{constructor(t,e,i){p(this,"layers");p(this,"visible");d(this,V);d(this,ut,[]);d(this,dt,!1);d(this,x,new Map);p(this,"interpolationFn");d(this,ct,1);this.layers=t,this.visible=e,c(this,V,i)}processLayerGroup(t,e,i){if(!o(this,dt)&&(this.layers.forEach(n=>{let a=t[n];a&&o(this,ut).push(...a)}),c(this,dt,!0),this.visible)){let n=[e,i],a=[1,0];this.interpolationFn=h=>ao(h,n,a)}}setOpacity(t){var e,i,n;c(this,ct,t);for(let a of o(this,ut))if(a.startsWith("img_")){let h=o(this,V).Image3D.getById(a);if(h){let u=o(this,V).getState(h.image);o(this,x).has(a)||o(this,x).set(a,(e=u==null?void 0:u.opacity)!=null?e:1);let f=Math.min(o(this,x).get(a),t);o(this,V).updateState(h.image,{opacity:f})}}else{let h=(i=o(this,V).getMapData())==null?void 0:i.getById("space",a);if(!h)continue;let u=o(this,V).getState(h);o(this,x).has(a)||o(this,x).set(a,(n=u==null?void 0:u.opacity)!=null?n:1);let f=Math.min(o(this,x).get(a),t);o(this,V).updateState(h,{opacity:f,visible:f>0})}}get opacity(){return o(this,ct)}};V=new WeakMap,ut=new WeakMap,dt=new WeakMap,x=new WeakMap,ct=new WeakMap,s(Rt,"LayerGroup");var Bt=Rt;function Pt(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}s(Pt,"runLayerGroupInterpolations");var k,l,L,m,j,U,y,O,$,Y,B,tt,ht,mt,ft,M,C,ot,Z,G,g,jt,lo,uo,Ut,pt,gt,Ft,yt,et,$t,co,ho,q,Yt=class Yt{constructor(t){d(this,g);d(this,k);d(this,l);d(this,L);d(this,m,no);d(this,j,[]);d(this,U,new Set);d(this,y,new Map);d(this,O);d(this,$,!1);d(this,Y,!1);d(this,B,0);d(this,tt,0);d(this,ht,[]);d(this,mt,{});d(this,ft,{});d(this,M,"transition");d(this,C,"outdoor");d(this,ot,[]);d(this,Z,!1);d(this,G,[]);p(this,"sceneUpdateQueue",Promise.resolve());p(this,"on",s((t,e)=>{o(this,k).on(t,e)},"on"));p(this,"off",s((t,e)=>{o(this,k).off(t,e)},"off"));d(this,pt,s(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(Wt(e,this.focusedFacades)&&o(this,C)==="transition"&&!o(this,Y))return;c(this,Y,!1),c(this,j,[]),o(this,U).clear();let i=o(this,m).isolateBelowGroundView&&o(this,B)<0;if(e.length>0)for(let n of e){let a=o(this,y).get(n.floorStack.id);if(a){if(i&&a.minElevation>=0)continue;o(this,U).add(a.id),o(this,j).push(a)}}o(this,m).autoFocus&&this.focus()},"#handleFacadesInViewChange"));d(this,gt,s(async t=>{var n,a,h,u;if(!this.isEnabled)return;let{floor:e}=t,i=o(this,y).get(e.floorStack.id);if(i&&(i.activeFloor=e),(i==null?void 0:i.excluded)===!1&&!o(this,O).matchesFloorStack(e.floorStack)&&c(this,B,e.elevation),o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(await o(this,q).call(this,e),o(this,k).publish("focus",{facades:this.focusedFacades}));let f=(a=(n=i==null?void 0:i.floorsAltitudesMap.get(e.elevation))==null?void 0:n.altitude)!=null?a:0;o(this,l).options.multiFloorView!=null&&((h=o(this,l).options.multiFloorView)!=null&&h.enabled)&&((u=o(this,l).options.multiFloorView)!=null&&u.updateCameraElevationOnFloorChange)&&o(this,l).Camera.elevation!==f&&o(this,l).Camera.animateElevation(f,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));d(this,Ft,s(()=>{c(this,$,!0)},"#handleUserInteractionStart"));d(this,yt,s(()=>{c(this,$,!1)},"#handleUserInteractionEnd"));d(this,et,s(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=Kt(e,o(this,m).indoorZoomThreshold,o(this,m).outdoorZoomThreshold);o(this,M)!==i&&(c(this,M,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Pt(o(this,G),e)},"#handleCameraChange"));d(this,q,s(async t=>{var u,f,P;if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).options.multiFloorView,n=((f=(u=o(this,l).Navigation)==null?void 0:u.floors)==null?void 0:f.map(R=>R.id))||[],a=((P=o(this,l).Navigation)==null?void 0:P.floorStacks.map(R=>R.id))||[],h=new Promise(async R=>{var rt;await this.sceneUpdateQueue;let bt=Xt({buildings:Array.from(o(this,y).values()),inViewSet:o(this,U),currentFloor:e,zoomState:o(this,M),mode:o(this,m).mode,elevation:o(this,B),floorIdsInNavigation:n,floorStackIdsInNavigation:a,multiFloorView:i,getMultiFloorState:(rt=o(this,m).customMultiFloorVisibilityState)!=null?rt:Co,dynamicBuildingInteriors:o(this,m).dynamicBuildingInteriors,isolateBelowGroundView:o(this,m).isolateBelowGroundView,currentElevation:o(this,B)}),it=[];await Promise.all(Array.from(bt.values()).map(async A=>{let{building:D,showIndoor:F,floorStackState:H,facadeState:nt,inFocus:It}=A;it.push(H);let z=to(D,F);if(z==="indoor")return E(this,g,co).call(this,D,H,nt,It);if(z==="outdoor")return E(this,g,ho).call(this,D,H,nt,a)})),o(this,l).Outdoor.setOpacity(Qt(it,o(this,m).mode)),c(this,ot,o(this,j).filter(A=>{var D;return((D=bt.get(A.id))==null?void 0:D.showIndoor)===!0}).map(A=>A.facade)),o(this,k).publish("focus",{facades:o(this,ot)}),R()});return this.sceneUpdateQueue=h,h},"#applyBuildingStates"));c(this,k,new St),c(this,l,t),J.setLevel(Q.logState),c(this,L,o(this,l).getMapData()),c(this,B,o(this,l).currentFloor.elevation),c(this,tt,o(this,l).Camera.elevation);for(let e of o(this,L).getByType("facade"))o(this,y).set(e.floorStack.id,new Et(e.floorStack,o(this,l)));E(this,g,uo).call(this),c(this,O,new wt(ro(o(this,L),o(this,y)),o(this,l))),o(this,l).on("floor-change-start",o(this,gt)),o(this,l).on("camera-change",o(this,et)),o(this,l).on("facades-in-view-change",o(this,pt)),o(this,l).on("user-interaction-start",o(this,Ft)),o(this,l).on("user-interaction-end",o(this,yt))}enable(t){if(o(this,Z)){J.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,Z,!0),o(this,l).manualFloorVisibility=!0,o(this,O).show(),this.updateState(_(_({},o(this,m)),t)),E(this,g,lo).call(this),o(this,et).call(this,{zoomLevel:o(this,l).Camera.zoomLevel,center:o(this,l).Camera.center,bearing:o(this,l).Camera.bearing,pitch:o(this,l).Camera.pitch}),o(this,l).Camera.updateFacadesInView()}disable(){if(!o(this,Z)){J.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,Z,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,Z)}get isIndoor(){return o(this,C)==="indoor"}get isOutdoor(){return o(this,C)==="outdoor"}get outdoorsFloorStack(){return o(this,O).floorStack}get layers(){return o(this,ht)}get layersBySpaceId(){return o(this,mt)}setIndoor(){c(this,C,"indoor"),c(this,M,"in-range"),E(this,g,jt).call(this)}setOutdoor(){c(this,C,"outdoor"),c(this,M,"out-of-range"),E(this,g,jt).call(this)}get focusedFacades(){return[...o(this,ot)]}getState(){return _({},o(this,m))}updateState(t){var i,n;let e=!1;t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=Lt(t.indoorZoomThreshold,(i=t==null?void 0:t.outdoorZoomThreshold)!=null?i:o(this,m).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=Lt(t.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,(n=t==null?void 0:t.indoorZoomThreshold)!=null?n:o(this,m).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=eo.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(o(this,m).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==o(this,m).dynamicBuildingInteriors&&(e=!0),t.isolateBelowGroundView!=null&&t.isolateBelowGroundView!==o(this,m).isolateBelowGroundView&&(e=!0),c(this,m,Object.assign({},o(this,m),Object.fromEntries(Object.entries(t).filter(([,a])=>a!=null)))),t.mode!=null&&t.preloadFloors&&E(this,g,Ut).call(this,t.mode),e&&o(this,q).call(this)}destroy(){this.disable(),o(this,l).off("facades-in-view-change",o(this,pt)),o(this,l).off("floor-change-start",o(this,gt)),o(this,l).off("camera-change",o(this,et)),o(this,l).off("user-interaction-start",o(this,Ft)),o(this,l).off("user-interaction-end",o(this,yt)),o(this,y).forEach(t=>t.destroy()),o(this,O).destroy(),o(this,k).destroy(),c(this,G,[])}async focus(t=o(this,m).setFloorOnFocus){if(t)if(oo(o(this,tt),o(this,l).Camera.elevation,o(this,$)))c(this,tt,o(this,l).Camera.elevation),c(this,Y,!0);else{let e=Jt(o(this,j),o(this,O),o(this,M)),i=e?vt(e,o(this,m).mode,o(this,B)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,q).call(this),o(this,k).publish("focus",{facades:this.focusedFacades})}preloadFloors(){E(this,g,Ut).call(this,o(this,m).mode)}setDefaultFloorForStack(t,e){if(!Nt(e,t))return;let i=o(this,y).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,y).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){var e;return((e=o(this,y).get(t.id))==null?void 0:e.defaultFloor)||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Nt(e,t))return;let i=o(this,y).get(t.id);i&&(i.activeFloor=e,o(this,q).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let n=o(this,y).get(i.id);n&&(n.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let n=o(this,y).get(i.id);n&&(n.excluded=!1)}}getCurrentFloorForStack(t){var e;return((e=o(this,y).get(t.id))==null?void 0:e.activeFloor)||this.getDefaultFloorForStack(t)}};k=new WeakMap,l=new WeakMap,L=new WeakMap,m=new WeakMap,j=new WeakMap,U=new WeakMap,y=new WeakMap,O=new WeakMap,$=new WeakMap,Y=new WeakMap,B=new WeakMap,tt=new WeakMap,ht=new WeakMap,mt=new WeakMap,ft=new WeakMap,M=new WeakMap,C=new WeakMap,ot=new WeakMap,Z=new WeakMap,G=new WeakMap,g=new WeakSet,jt=s(function(){o(this,m).autoFocus&&(o(this,$)?this.focus():c(this,Y,!0)),o(this,k).publish("state-change")},"#handleViewStateChange"),lo=s(function(){c(this,G,[]);for(let t of o(this,m).dynamicLayers){let e=new Bt([t],!0,o(this,l));e.processLayerGroup(o(this,ft),o(this,m).outdoorZoomThreshold,o(this,m).indoorZoomThreshold),o(this,G).push(e)}Pt(o(this,G),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),uo=s(function(){var n,a,h;let t=(h=(a=(n=o(this,L).internal.mvf)==null?void 0:n.enterprise)==null?void 0:a.layers)!=null?h:[],e={},i={};t.forEach(u=>{e[u.name]||(e[u.name]=[]),e[u.name].push(...u.spaces.map(({spaceId:f})=>f));for(let{spaceId:f}of u.spaces)i[f]==null&&(i[f]=[]),i[f].push(u.name)}),c(this,ht,t.map(({name:u})=>u)),c(this,mt,i),c(this,ft,e)},"#setupLayers"),Ut=s(function(t){o(this,l).preloadFloors(o(this,L).getByType("facade").map(e=>vt(o(this,y).get(e.floorStack.id),t,o(this,B))).filter(e=>e!=null&&Lo.is(e)))},"#preloadFloors"),pt=new WeakMap,gt=new WeakMap,Ft=new WeakMap,yt=new WeakMap,et=new WeakMap,$t=s(function(t,e,i){t.forEach(n=>{if(n.floor)if(e){let a=i!==void 0?at(_({},n.state),{labels:at(_({},n.state.labels),{enabled:n.state.labels.enabled&&i}),markers:at(_({},n.state.markers),{enabled:n.state.markers.enabled&&i}),occlusion:at(_({},n.state.occlusion),{enabled:n.state.occlusion.enabled&&i})}):n.state;o(this,l).updateState(n.floor,a)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),co=s(async function(t,e,i,n){return E(this,g,$t).call(this,e.floorStates,!0,n),t.animateFacade(i.state,o(this,m).indoorAnimationOptions)},"#animateIndoorSequence"),ho=s(async function(t,e,i,n){let a=await t.animateFacade(i.state,o(this,m).outdoorAnimationOptions);return a.result==="completed"&&E(this,g,$t).call(this,e.floorStates,At({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,M)==="in-range",inFocus:o(this,U).has(t.id),mode:o(this,m).mode,elevation:o(this,B),inNavigation:n.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,m).dynamicBuildingInteriors})),a},"#animateOutdoorSequence"),q=new WeakMap,s(Yt,"DynamicFocus");var so=Yt;export{s as a,ve as b,we as c,so as d};
@@ -43,7 +43,7 @@ type DynamicFocusState = {
43
43
  * The zoom level at which the camera will fade in the facades and fade out the indoor floors.
44
44
  * @default 17
45
45
  */
46
- outdoorZoomThreshold: number;
46
+ outdoorZoomThreshold?: number;
47
47
  /**
48
48
  * Whether to set the floor to the outdoors when the camera moves in range.
49
49
  * @default true
@@ -72,6 +72,12 @@ type DynamicFocusState = {
72
72
  * @default true
73
73
  */
74
74
  dynamicBuildingInteriors: boolean;
75
+ /**
76
+ * Whether to automatically hide all above ground buildings and floors when the camera transitions to a below-ground elevation.
77
+ * @experimental
78
+ * @default false
79
+ */
80
+ isolateBelowGroundView: boolean;
75
81
  /**
76
82
  * Whether to preload the geometry of the initial floors in each building. Improves performance when rendering the building for the first time.
77
83
  * @default true
@@ -84,6 +90,11 @@ type DynamicFocusState = {
84
90
  * This is useful for customizing the floor visibility state for a specific building.
85
91
  */
86
92
  customMultiFloorVisibilityState?: MultiFloorVisibilityState;
93
+ /**
94
+ * Dynamic layers
95
+ * @experimental
96
+ */
97
+ dynamicLayers: string[];
87
98
  };
88
99
  /**
89
100
  * Events emitted by the Dynamic Focus controller.
@@ -800,6 +811,20 @@ declare class DynamicFocus implements MapViewExtension<DynamicFocusState> {
800
811
  * Returns true if the current view state is outdoor.
801
812
  */
802
813
  get isOutdoor(): boolean;
814
+ /**
815
+ * Returns outdoor floor stack.
816
+ */
817
+ get outdoorsFloorStack(): FloorStack;
818
+ /**
819
+ * Returns the list of layers.
820
+ * @experimental
821
+ */
822
+ get layers(): string[];
823
+ /**
824
+ * Returns the layers organized by space ID.
825
+ * @experimental
826
+ */
827
+ get layersBySpaceId(): Record<string, string[]>;
803
828
  /**
804
829
  * Sets the view state to indoor, regardless of the current zoom level.
805
830
  */
@@ -883,4 +908,41 @@ declare class DynamicFocus implements MapViewExtension<DynamicFocusState> {
883
908
  getCurrentFloorForStack(floorStack: FloorStack): Floor;
884
909
  }
885
910
  //#endregion
886
- export { DynamicFocus, type DynamicFocusAnimationOptions, type DynamicFocusEventPayload, type DynamicFocusEvents, type DynamicFocusMode, type DynamicFocusState };
911
+ //#region src/zoom-thresholds.d.ts
912
+ /**
913
+ * Options for {@link calculateZoomThresholds}.
914
+ */
915
+ type CalculateZoomThresholdsOptions = {
916
+ /**
917
+ * Determines which view is considered the starting point when computing thresholds.
918
+ * - 'outdoor-first' (default): thresholds are placed slightly ABOVE the base zoom level
919
+ * so that zooming in reveals indoor content after passing the offsets.
920
+ * - 'indoor-first': thresholds are placed slightly BELOW the base zoom level so that
921
+ * zooming out reveals outdoor content after passing the offsets.
922
+ */
923
+ initialVisibility?: 'indoor-first' | 'outdoor-first';
924
+ /**
925
+ * A list of layer names that represent the primary focus for indoor content. When provided,
926
+ * the base zoom level will prefer the camera transform that focuses on spaces which belong
927
+ * to these layers (see {@link layersBySpaceId}) on the {@link defaultFloor}. If not provided
928
+ * or if no spaces match, the base zoom level falls back to the {@link defaultFloor} focus.
929
+ */
930
+ focusLayers?: string[];
931
+ /**
932
+ * A mapping of Space.id to the list of layer names that space belongs to. This is used to
933
+ * determine which spaces are part of the {@link focusLayers} set. Only spaces on the
934
+ * {@link defaultFloor} are considered when selecting the preferred base zoom level.
935
+ */
936
+ layersBySpaceId?: Record<string, string[]>;
937
+ /**
938
+ * The floor used when computing the default base zoom level in absence of matching
939
+ * {@link focusLayers}. Defaults to the MapView's currentFloor.
940
+ */
941
+ defaultFloor?: Floor;
942
+ };
943
+ declare const calculateZoomThresholds: (mapView: MapView, userOptions: CalculateZoomThresholdsOptions) => {
944
+ indoorZoomThreshold: number;
945
+ outdoorZoomThreshold: number;
946
+ };
947
+ //#endregion
948
+ export { type CalculateZoomThresholdsOptions, DynamicFocus, type DynamicFocusAnimationOptions, type DynamicFocusEventPayload, type DynamicFocusEvents, type DynamicFocusMode, type DynamicFocusState, type MultiFloorVisibilityState, calculateZoomThresholds };
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{b as o}from"./chunk-D4Z7IQAJ.js";export{o as DynamicFocus};
1
+ import{a as d,b as u,c as y,d as F}from"./chunk-63EXGJIK.js";var p=d((t,o)=>{var l,i,s,a;let n={initialVisibility:(l=o.initialVisibility)!=null?l:"outdoor-first",layersBySpaceId:(i=o.layersBySpaceId)!=null?i:{},focusLayers:(s=o.focusLayers)!=null?s:[],defaultFloor:(a=o.defaultFloor)!=null?a:t.currentFloor},e=O(t,n),c=e+y,r=e+u;return n.initialVisibility==="indoor-first"&&(c=e-u,r=e-y),{indoorZoomThreshold:c,outdoorZoomThreshold:r}},"calculateZoomThresholds");function O(t,o){var l;let n=t.getMapData().getByType("space"),e=o.focusLayers.length?n.filter(i=>{var a,f,m;let s=(a=o.layersBySpaceId[i.id])==null?void 0:a[0];return typeof s=="string"&&i.floor.id===((f=o.defaultFloor)==null?void 0:f.id)&&((m=o.focusLayers)==null?void 0:m.indexOf(s))!==-1}):void 0,c=(l=t.Camera.getFocusOnTransform(o.defaultFloor,{}).zoomLevel)!=null?l:0,r=e!=null&&e.length?t.Camera.getFocusOnTransform(e,{}).zoomLevel:void 0;return r!=null?r:c}d(O,"getDefaultZoomLevel");export{F as DynamicFocus,p as calculateZoomThresholds};
@@ -43,7 +43,7 @@ type DynamicFocusState = {
43
43
  * The zoom level at which the camera will fade in the facades and fade out the indoor floors.
44
44
  * @default 17
45
45
  */
46
- outdoorZoomThreshold: number;
46
+ outdoorZoomThreshold?: number;
47
47
  /**
48
48
  * Whether to set the floor to the outdoors when the camera moves in range.
49
49
  * @default true
@@ -72,6 +72,12 @@ type DynamicFocusState = {
72
72
  * @default true
73
73
  */
74
74
  dynamicBuildingInteriors: boolean;
75
+ /**
76
+ * Whether to automatically hide all above ground buildings and floors when the camera transitions to a below-ground elevation.
77
+ * @experimental
78
+ * @default false
79
+ */
80
+ isolateBelowGroundView: boolean;
75
81
  /**
76
82
  * Whether to preload the geometry of the initial floors in each building. Improves performance when rendering the building for the first time.
77
83
  * @default true
@@ -84,6 +90,11 @@ type DynamicFocusState = {
84
90
  * This is useful for customizing the floor visibility state for a specific building.
85
91
  */
86
92
  customMultiFloorVisibilityState?: MultiFloorVisibilityState;
93
+ /**
94
+ * Dynamic layers
95
+ * @experimental
96
+ */
97
+ dynamicLayers: string[];
87
98
  };
88
99
  /**
89
100
  * Events emitted by the Dynamic Focus controller.
@@ -800,6 +811,20 @@ declare class DynamicFocus implements MapViewExtension<DynamicFocusState> {
800
811
  * Returns true if the current view state is outdoor.
801
812
  */
802
813
  get isOutdoor(): boolean;
814
+ /**
815
+ * Returns outdoor floor stack.
816
+ */
817
+ get outdoorsFloorStack(): FloorStack;
818
+ /**
819
+ * Returns the list of layers.
820
+ * @experimental
821
+ */
822
+ get layers(): string[];
823
+ /**
824
+ * Returns the layers organized by space ID.
825
+ * @experimental
826
+ */
827
+ get layersBySpaceId(): Record<string, string[]>;
803
828
  /**
804
829
  * Sets the view state to indoor, regardless of the current zoom level.
805
830
  */
@@ -1 +1 @@
1
- import{a as t,b as a}from"../chunk-D4Z7IQAJ.js";import{useCallback as y,useState as p,useMemo as F}from"react";import{useMap as l,useMapViewExtension as D}from"@mappedin/react-sdk";function d(){let[,n]=p({});return y(()=>n({}),[])}t(d,"useForceUpdate");function i(){let{mapView:n}=l(),r=d(),{register:o}=D("dynamic-focus",{onRegister:t(()=>{let e=new a(n);return e.on("state-change",r),e},"onRegister"),onDeregister:t(e=>{e.off("state-change",r),e.destroy()},"onDeregister")}),s=o();if(!s)throw new Error("DynamicFocus is not initialized");return F(()=>{let e=new WeakMap;return new Proxy(s,{get(u,m){let c=u[m];return typeof c=="function"?(e.has(c)||e.set(c,c.bind(u)),e.get(c)):c}})},[s])}t(i,"useDynamicFocus");import{useCallback as w,useEffect as E,useRef as k}from"react";function x(n,r){let o=i(),s=k(r);s.current=r;let e=w(u=>{s.current(u)},[]);E(()=>{if(o!=null)return o.on(n,e),()=>{o!=null&&o.off(n,e)}},[o,n,e])}t(x,"useDynamicFocusEvent");export{i as useDynamicFocus,x as useDynamicFocusEvent};
1
+ import{a as t,d as a}from"../chunk-63EXGJIK.js";import{useCallback as y,useState as p,useMemo as F}from"react";import{useMap as l,useMapViewExtension as D}from"@mappedin/react-sdk";function d(){let[,n]=p({});return y(()=>n({}),[])}t(d,"useForceUpdate");function i(){let{mapView:n}=l(),r=d(),{register:o}=D("dynamic-focus",{onRegister:t(()=>{let e=new a(n);return e.on("state-change",r),e},"onRegister"),onDeregister:t(e=>{e.off("state-change",r),e.destroy()},"onDeregister")}),s=o();if(!s)throw new Error("DynamicFocus is not initialized");return F(()=>{let e=new WeakMap;return new Proxy(s,{get(u,m){let c=u[m];return typeof c=="function"?(e.has(c)||e.set(c,c.bind(u)),e.get(c)):c}})},[s])}t(i,"useDynamicFocus");import{useCallback as w,useEffect as E,useRef as k}from"react";function x(n,r){let o=i(),s=k(r);s.current=r;let e=w(u=>{s.current(u)},[]);E(()=>{if(o!=null)return o.on(n,e),()=>{o!=null&&o.off(n,e)}},[o,n,e])}t(x,"useDynamicFocusEvent");export{i as useDynamicFocus,x as useDynamicFocusEvent};
@@ -0,0 +1,33 @@
1
+ import type { MapView, TAnimateStateResult, TFacadeState } from '@mappedin/mappedin-js';
2
+ import { Facade, Floor, FloorStack } from '@mappedin/mappedin-js';
3
+ import type { DynamicFocusAnimationOptions } from './types';
4
+ export declare class Building {
5
+ #private;
6
+ __type: string;
7
+ defaultFloor: Floor;
8
+ activeFloor: Floor;
9
+ excluded: boolean;
10
+ floorsAltitudesMap: Map<number, {
11
+ altitude: number;
12
+ effectiveHeight: number;
13
+ }>;
14
+ aboveGroundFloors: Floor[];
15
+ constructor(floorStack: FloorStack, mapView: MapView);
16
+ get id(): string;
17
+ get name(): string;
18
+ get floors(): [Floor, ...Floor[]];
19
+ get floorStack(): FloorStack;
20
+ get facade(): Facade;
21
+ get isCurrentFloorStack(): boolean;
22
+ get isIndoor(): boolean;
23
+ get canSetFloor(): boolean;
24
+ get maxElevation(): number;
25
+ get minElevation(): number;
26
+ has(f: Floor | FloorStack | Facade): boolean;
27
+ getFloorByElevation(elevation: number): Floor | undefined;
28
+ getNearestFloorByElevation(targetElevation: number): Floor | undefined;
29
+ getHighestFloor(): Floor;
30
+ cancelAnimation(): void;
31
+ animateFacade(newState: TFacadeState, options?: DynamicFocusAnimationOptions): Promise<TAnimateStateResult>;
32
+ destroy(): void;
33
+ }
@@ -1,5 +1,5 @@
1
- var W=Object.defineProperty,l=(e,i)=>W(e,"name",{value:i,configurable:!0});import{useState as _,useCallback as c,useContext as T,useRef as A}from"react";import{MappedinContext as I}from"@mappedin/react-native-sdk";import{useCallback as B,useContext as Z}from"react";var $="[MappedinJS]";function m(e="",{prefix:i=$}={}){const o=`${i}${e?`-${e}`:""}`,a=l((t,d)=>{if(typeof window<"u"&&window.rnDebug){const f=d.map(s=>s instanceof Error&&s.stack?`${s.message}
2
- ${s.stack}`:s);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:0,log(...t){this.logState<=0&&(console.log(o,...t),a("log",t))},warn(...t){this.logState<=1&&(console.warn(o,...t),a("warn",t))},error(...t){this.logState<=2&&(console.error(o,...t),a("error",t))},assert(...t){console.assert(...t)},time(t){console.time(t)},timeEnd(t){console.timeEnd(t)},setLevel(t){0<=t&&t<=3&&(this.logState=t)}}}l(m,"createLogger");var U=m(),w=m("",{prefix:"[DynamicFocus]"});import{MappedinContext as j,useEventCallback as L,createEventSetupScript as R,createEventCleanupScript as V}from"@mappedin/react-native-sdk";function v(e,i){return i.map(o=>o&&o.id&&e.getById("facade",o.id)||o)}l(v,"hydrateFacades");import{useRegisterExtension as N}from"@mappedin/react-native-sdk";var P=`
1
+ var C=Object.defineProperty,l=(e,i)=>C(e,"name",{value:i,configurable:!0});import{useState as W,useCallback as h,useContext as _,useRef as T}from"react";import{MappedinContext as D}from"@mappedin/react-native-sdk";import{useCallback as L,useContext as V}from"react";var A="[MappedinJS]";function g(e="",{prefix:i=A}={}){const o=`${i}${e?`-${e}`:""}`,r=l((t,c)=>{if(typeof window<"u"&&window.rnDebug){const f=c.map(s=>s instanceof Error&&s.stack?`${s.message}
2
+ ${s.stack}`:s);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:0,log(...t){this.logState<=0&&(console.log(o,...t),r("log",t))},warn(...t){this.logState<=1&&(console.warn(o,...t),r("warn",t))},error(...t){this.logState<=2&&(console.error(o,...t),r("error",t))},assert(...t){console.assert(...t)},time(t){console.time(t)},timeEnd(t){console.timeEnd(t)},setLevel(t){0<=t&&t<=3&&(this.logState=t)}}}l(g,"createLogger");var z=g(),w=g("",{prefix:"[DynamicFocus]"});import{MappedinContext as Z,useEventCallback as $,createEventSetupScript as N,createEventCleanupScript as R}from"@mappedin/react-native-sdk";function v(e,i){return i.map(o=>o&&o.id&&e.getById("facade",o.id)||o)}l(v,"hydrateFacades");import{useRegisterExtension as j}from"@mappedin/react-native-sdk";var G=`
3
3
  // Define require function that uses bridge.modules for external dependencies
4
4
  globalThis.require = globalThis.require || ((id) => {
5
5
  if (window.bridge?.modules?.[id]) {
@@ -8,8 +8,8 @@ ${s.stack}`:s);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{l
8
8
  throw new Error('Module not found: ' + id);
9
9
  });
10
10
 
11
- "use strict";var DynamicFocus=(()=>{var J=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Ht=Object.prototype.hasOwnProperty;var Mt=r=>{throw TypeError(r)};var qt=(r,t,e)=>t in r?J(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var s=(r,t)=>J(r,"name",{value:t,configurable:!0}),st=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Wt=(r,t)=>{for(var e in t)J(r,e,{get:t[e],enumerable:!0})},Kt=(r,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $t(t))!Ht.call(r,i)&&i!==e&&J(r,i,{get:()=>t[i],enumerable:!(a=Ut(t,i))||a.enumerable});return r};var zt=r=>Kt(J({},"__esModule",{value:!0}),r);var m=(r,t,e)=>qt(r,typeof t!="symbol"?t+"":t,e),pt=(r,t,e)=>t.has(r)||Mt("Cannot "+e);var o=(r,t,e)=>(pt(r,t,"read from private field"),e?e.call(r):t.get(r)),u=(r,t,e)=>t.has(r)?Mt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),l=(r,t,e,a)=>(pt(r,t,"write to private field"),a?a.call(r,e):t.set(r,e),e),b=(r,t,e)=>(pt(r,t,"access private method"),e);var oo={};Wt(oo,{DynamicFocus:()=>ft});var mt=st("@mappedin/mappedin-js");function Vt(r,t){if(r==null||t==null)return r===t;if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}s(Vt,"arraysEqual");var Ft=class Ft{constructor(){m(this,"_subscribers",{});m(this,"_destroyed",!1)}publish(t,e){!this._subscribers||!this._subscribers[t]||this._destroyed||this._subscribers[t].forEach(function(a){typeof a=="function"&&a(e)})}on(t,e){(!this._subscribers||this._destroyed)&&(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e)}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this._destroyed)return;let a=this._subscribers[t].indexOf(e);a!==-1&&this._subscribers[t].splice(a,1)}destroy(){this._destroyed=!0,this._subscribers={}}};s(Ft,"PubSub");var lt=Ft;var Y=st("@mappedin/mappedin-js");var E,X,w,S,F,k,G,j,gt=class gt{constructor(t,e){m(this,"__type","building");u(this,E);u(this,X,new Map);u(this,w,new Map);u(this,S,[]);u(this,F);u(this,k);m(this,"defaultFloor");m(this,"activeFloor");m(this,"excluded",!1);m(this,"floorsAltitudesMap",new Map);m(this,"aboveGroundFloors",[]);u(this,G);u(this,j);l(this,E,t),l(this,X,new Map(t.floors.map(i=>[i.id,i]))),l(this,w,new Map(t.floors.map(i=>[i.elevation,i]))),l(this,S,Array.from(o(this,w).values()).sort((i,c)=>i.elevation-c.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,l(this,F,e),this.aboveGroundFloors=o(this,S).filter(i=>i.elevation>=0);let a=t.facade?.spaces.map(i=>o(this,F).getState(i)).sort((i,c)=>i.altitude-c.altitude);if(a&&a.length===this.aboveGroundFloors.length)for(let i in this.aboveGroundFloors){let c=this.aboveGroundFloors[i],y=a[i];this.floorsAltitudesMap.set(c.elevation,{altitude:y.altitude,effectiveHeight:y.height})}}get id(){return o(this,E).id}get name(){return o(this,E).name}get floors(){return o(this,E).floors}get floorStack(){return o(this,E)}get facade(){return o(this,E).facade}get isCurrentFloorStack(){return this.id===o(this,F).currentFloorStack.id}get isIndoor(){let t=o(this,F).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,G)==null&&l(this,G,Math.max(...o(this,w).keys())),o(this,G)}get minElevation(){return o(this,j)==null&&l(this,j,Math.min(...o(this,w).keys())),o(this,j)}has(t){return Y.Floor.is(t)?o(this,X).has(t.id):Y.FloorStack.is(t)?t.id===o(this,E).id:Y.Facade.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,w).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,S)[o(this,S).length-1];for(let a=o(this,S).length-1;a>=0;a--){let i=o(this,S)[a];if(i.elevation<=t)return i}}else{if(t<this.minElevation)return o(this,S)[0];for(let a of o(this,S))if(a.elevation>=t)return a}}getHighestFloor(){return o(this,S)[o(this,S).length-1]}cancelAnimation(){o(this,k)&&(o(this,k).animation.cancel(),l(this,k,void 0))}async animateFacade(t,e={duration:150}){let a=o(this,k)?.state||o(this,F).getState(this.facade);if(!a||!t||a?.opacity===t.opacity&&a?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:i,visible:c}=t;if(o(this,F).updateState(this.facade,{visible:!0}),i!==void 0){l(this,k,{animation:o(this,F).animateState(this.facade,{opacity:i},{duration:e.duration}),state:t});let y=await o(this,k).animation;if(l(this,k,void 0),y.result==="cancelled")return y}return c===!1&&o(this,F).updateState(this.facade,{visible:c}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,E).floors.forEach(t=>{o(this,F).updateState(t,{visible:t.id===o(this,F).currentFloor.id})}),this.has(o(this,F).currentFloor)||o(this,F).updateState(this.facade,{visible:!0,opacity:1})}};E=new WeakMap,X=new WeakMap,w=new WeakMap,S=new WeakMap,F=new WeakMap,k=new WeakMap,G=new WeakMap,j=new WeakMap,s(gt,"Building");var ut=gt;function xt(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}s(xt,"getZoomState");function dt(r,t,e){if(r.__type==="outdoors"&&"floor"in r)return r.floor;let a=r;if(a.excluded)return a.activeFloor;switch(t){case"lock-elevation":return a.getFloorByElevation(e);case"nearest-elevation":return a.getNearestFloorByElevation(e);default:break}return a.isIndoor?a.activeFloor:a.defaultFloor}s(dt,"getFloorToShow");function Qt(r,t){return{facade:r,state:{type:"facade",visible:!t,opacity:t?0:1}}}s(Qt,"getFacadeState");function Jt(r,t,e){return{outdoorOpacity:"initial",floorStates:r.floors.map(a=>{let i=a.id===t.id&&e;return{floor:a,state:{type:"floor",visible:i,geometry:{visible:i},labels:{enabled:i},markers:{enabled:i},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}s(Jt,"getSingleBuildingState");function Ot(r,t){if(!t.includes("lock-elevation"))return"initial";for(let e of r)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}s(Ot,"getOutdoorOpacity");function Bt(r,t,e){switch(e){case"in-range":return r[0]?.canSetFloor?r[0]:void 0;case"out-of-range":return t;case"transition":default:return}}s(Bt,"getSetFloorTargetFromZoomState");function _t(r,t,e,a,i,c,y,p,z,rt,O){let C=new Map;for(let f of r){let P=t.has(f.id),R=yt(f,e,a==="in-range",P,i,c,p.includes(f.id),O),Q=e.floorStack.id===f.id?f.activeFloor:dt(f,i,c),nt=z.enabled?rt(f.floors,Q||f.activeFloor,z?.floorGap,y,f.floorsAltitudesMap):Jt(f.floorStack,Q||f.activeFloor,R),Yt=Qt(f.facade,R);C.set(f.id,{building:f,showIndoor:R,floorStackState:nt,facadeState:Yt,inFocus:P,floorToShow:Q})}return C}s(_t,"getBuildingStates");function Nt(r,t){return r.excluded?"none":t?"indoor":"outdoor"}s(Nt,"getBuildingAnimationType");function yt(r,t,e,a,i,c,y,p){if(r.id===t.floorStack.id)return!0;if(r.excluded)return!1;if(y===!0)return!0;if(!p)return t.floorStack.type!=="Outdoor";if(!e||!a)return!1;switch(i){case"lock-elevation":return r.getFloorByElevation(c)!=null;default:break}return!0}s(yt,"shouldShowIndoor");function It(r,t,e){return r!==t&&!e}s(It,"shouldDeferSetFloor");var Lt=["default-floor","lock-elevation","nearest-elevation"];var ct=st("@mappedin/mappedin-js");var Xt="[MappedinJS]";function St(r="",{prefix:t=Xt}={}){let e=\`\${t}\${r?\`-\${r}\`:""}\`,a=s((i,c)=>{if(typeof window<"u"&&window.rnDebug){let y=c.map(p=>p instanceof Error&&p.stack?\`\${p.message}
12
- \${p.stack}\`:p);window.rnDebug(\`\${r} \${i}: \${y.join(" ")}\`)}},"rnDebug");return{logState:0,log(...i){this.logState<=0&&(console.log(e,...i),a("log",i))},warn(...i){this.logState<=1&&(console.warn(e,...i),a("warn",i))},error(...i){this.logState<=2&&(console.error(e,...i),a("error",i))},assert(...i){console.assert(...i)},time(i){console.time(i)},timeEnd(i){console.timeEnd(i)},setLevel(i){0<=i&&i<=3&&(this.logState=i)}}}s(St,"createLogger");var to=St();var U=to;function Zt(r,t,e,a){return(r<t||r>e)&&U.warn(a),Math.min(e,Math.max(t,r))}s(Zt,"clampWithWarning");function bt(r,t){return!ct.Floor.is(r)||r?.floorStack==null||!ct.FloorStack.is(t)?!1:r.floorStack.id!==t.id?(U.warn(\`Floor (\${r.id}) does not belong to floor stack (\${t.id}).\`),!1):!0}s(bt,"validateFloorForStack");function Et(r,t,e,a){return Zt(r,t,e,\`\${a} must be between \${t} and \${e}.\`)}s(Et,"validateZoomThreshold");var $=St("",{prefix:"[DynamicFocus]"});var D,H,tt,vt,kt=class kt{constructor(t,e){u(this,tt);m(this,"__type","outdoors");u(this,D);u(this,H);l(this,D,t),l(this,H,e)}get id(){return o(this,D).id}get floorStack(){return o(this,D)}get floor(){return o(this,D).defaultFloor}matchesFloorStack(t){return t===o(this,D)||t===o(this,D).id}show(){b(this,tt,vt).call(this,!0)}hide(){b(this,tt,vt).call(this,!1)}destroy(){this.matchesFloorStack(o(this,H).currentFloorStack)||this.hide()}};D=new WeakMap,H=new WeakMap,tt=new WeakSet,vt=s(function(t){for(let e of o(this,D).floors)o(this,H).updateState(e,{visible:t})},"#setVisible"),s(kt,"Outdoors");var ht=kt;function Ct(r,t){let e=r.find(i=>i.type?.toLowerCase()==="outdoor");if(e)return e;let a=r.find(i=>i.facade==null&&!t.has(i.id));return a||($.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),r[0])}s(Ct,"getOutdoorFloorStack");var Pt=st("@mappedin/mappedin-js"),Rt={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,customMultiFloorVisibilityState:Pt.getMultiFloorState,dynamicBuildingInteriors:!0};var v,n,B,d,_,N,h,M,I,L,A,q,T,V,W,x,g,Dt,Tt,ot,et,it,at,K,At,Gt,jt,Z,wt=class wt{constructor(t){u(this,g);u(this,v);u(this,n);u(this,B);u(this,d,Rt);u(this,_,[]);u(this,N,new Set);u(this,h,new Map);u(this,M);u(this,I,!1);u(this,L,!1);u(this,A,0);u(this,q,0);u(this,T,"transition");u(this,V,"outdoor");u(this,W,[]);u(this,x,!1);m(this,"sceneUpdateQueue",Promise.resolve());m(this,"on",s((t,e)=>{o(this,v).on(t,e)},"on"));m(this,"off",s((t,e)=>{o(this,v).off(t,e)},"off"));u(this,ot,s(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(!(Vt(e,this.focusedFacades)&&o(this,V)==="transition"&&!o(this,L))){if(l(this,L,!1),l(this,_,[]),o(this,N).clear(),e.length>0)for(let a of e){let i=o(this,h).get(a.floorStack.id);i&&(o(this,N).add(i.id),o(this,_).push(i))}o(this,d).autoFocus&&this.focus()}},"#handleFacadesInViewChange"));u(this,et,s(async t=>{if(!this.isEnabled)return;let{floor:e}=t,a=o(this,h).get(e.floorStack.id);if(a&&(a.activeFloor=e),a?.excluded===!1&&!o(this,M).matchesFloorStack(e.floorStack)&&l(this,A,e.elevation),o(this,n).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(await o(this,Z).call(this,e),o(this,v).publish("focus",{facades:this.focusedFacades}));let i=a?.floorsAltitudesMap.get(e.elevation)?.altitude??0;o(this,n).options.multiFloorView!=null&&o(this,n).options.multiFloorView?.enabled&&o(this,n).options.multiFloorView?.updateCameraElevationOnFloorChange&&o(this,n).Camera.elevation!==i&&o(this,n).Camera.animateElevation(i,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));u(this,it,s(()=>{l(this,I,!0)},"#handleUserInteractionStart"));u(this,at,s(()=>{l(this,I,!1)},"#handleUserInteractionEnd"));u(this,K,s(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,a=xt(e,o(this,d).indoorZoomThreshold,o(this,d).outdoorZoomThreshold);o(this,T)!==a&&(l(this,T,a),a==="in-range"?this.setIndoor():a==="out-of-range"&&this.setOutdoor())},"#handleCameraChange"));u(this,Z,s(async t=>{if(o(this,n).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,n).currentFloor,a=o(this,n).options.multiFloorView,i=o(this,n).Navigation?.floors?.map(p=>p.id)||[],c=o(this,n).Navigation?.floorStacks.map(p=>p.id)||[],y=new Promise(async p=>{await this.sceneUpdateQueue;let z=_t(Array.from(o(this,h).values()),o(this,N),e,o(this,T),o(this,d).mode,o(this,A),i,c,a,o(this,d).customMultiFloorVisibilityState??mt.getMultiFloorState,o(this,d).dynamicBuildingInteriors),rt=[];await Promise.all(Array.from(z.values()).map(async O=>{let{building:C,showIndoor:f,floorStackState:P,facadeState:R,inFocus:Q}=O;rt.push(P);let nt=Nt(C,f);if(nt==="indoor")return b(this,g,Gt).call(this,C,P,R,Q);if(nt==="outdoor")return b(this,g,jt).call(this,C,P,R,c)})),o(this,n).Outdoor.setOpacity(Ot(rt,o(this,d).mode)),l(this,W,o(this,_).filter(O=>z.get(O.id)?.showIndoor===!0).map(O=>O.facade)),o(this,v).publish("focus",{facades:o(this,W)}),p()});return this.sceneUpdateQueue=y,y},"#applyBuildingStates"));l(this,v,new lt),l(this,n,t),$.setLevel(U.logState),l(this,B,o(this,n).getMapData()),l(this,A,o(this,n).currentFloor.elevation),l(this,q,o(this,n).Camera.elevation);for(let e of o(this,B).getByType("facade"))o(this,h).set(e.floorStack.id,new ut(e.floorStack,o(this,n)));l(this,M,new ht(Ct(o(this,B).getByType("floor-stack"),o(this,h)),o(this,n))),o(this,n).on("floor-change-start",o(this,et)),o(this,n).on("camera-change",o(this,K)),o(this,n).on("facades-in-view-change",o(this,ot)),o(this,n).on("user-interaction-start",o(this,it)),o(this,n).on("user-interaction-end",o(this,at))}enable(t){if(o(this,x)){$.warn("enable() called on an already enabled Dynamic Focus instance.");return}l(this,x,!0),o(this,n).manualFloorVisibility=!0,o(this,M).show(),this.updateState({...o(this,d),...t}),o(this,K).call(this,{zoomLevel:o(this,n).Camera.zoomLevel,center:o(this,n).Camera.center,bearing:o(this,n).Camera.bearing,pitch:o(this,n).Camera.pitch}),o(this,n).Camera.updateFacadesInView()}disable(){if(!o(this,x)){$.warn("disable() called on an already disabled Dynamic Focus instance.");return}l(this,x,!1),o(this,n).manualFloorVisibility=!1}get isEnabled(){return o(this,x)}get isIndoor(){return o(this,V)==="indoor"}get isOutdoor(){return o(this,V)==="outdoor"}setIndoor(){l(this,V,"indoor"),l(this,T,"in-range"),b(this,g,Dt).call(this)}setOutdoor(){l(this,V,"outdoor"),l(this,T,"out-of-range"),b(this,g,Dt).call(this)}get focusedFacades(){return[...o(this,W)]}getState(){return{...o(this,d)}}updateState(t){let e=!1;t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=Et(t.indoorZoomThreshold,t?.outdoorZoomThreshold??o(this,d).outdoorZoomThreshold,o(this,n).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=Et(t.outdoorZoomThreshold,o(this,n).Camera.minZoomLevel,t?.indoorZoomThreshold??o(this,d).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=Lt.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(o(this,d).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==o(this,d).dynamicBuildingInteriors&&(e=!0),l(this,d,Object.assign({},o(this,d),Object.fromEntries(Object.entries(t).filter(([,a])=>a!=null)))),t.mode!=null&&t.preloadFloors&&b(this,g,Tt).call(this,t.mode),e&&o(this,Z).call(this)}destroy(){this.disable(),o(this,n).off("facades-in-view-change",o(this,ot)),o(this,n).off("floor-change-start",o(this,et)),o(this,n).off("camera-change",o(this,K)),o(this,n).off("user-interaction-start",o(this,it)),o(this,n).off("user-interaction-end",o(this,at)),o(this,h).forEach(t=>t.destroy()),o(this,M).destroy(),o(this,v).destroy()}async focus(t=o(this,d).setFloorOnFocus){if(t)if(It(o(this,q),o(this,n).Camera.elevation,o(this,I)))l(this,q,o(this,n).Camera.elevation),l(this,L,!0);else{let e=Bt(o(this,_),o(this,M),o(this,T)),a=e?dt(e,o(this,d).mode,o(this,A)):void 0;a&&a.id!==o(this,n).currentFloor.id&&o(this,n).setFloor(a,{context:"dynamic-focus"})}await o(this,Z).call(this),o(this,v).publish("focus",{facades:this.focusedFacades})}preloadFloors(){b(this,g,Tt).call(this,o(this,d).mode)}setDefaultFloorForStack(t,e){if(!bt(e,t))return;let a=o(this,h).get(t.id);a&&(a.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,h).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){return o(this,h).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!bt(e,t))return;let a=o(this,h).get(t.id);a&&(a.activeFloor=e,o(this,Z).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let a of e){let i=o(this,h).get(a.id);i&&(i.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let a of e){let i=o(this,h).get(a.id);i&&(i.excluded=!1)}}getCurrentFloorForStack(t){return o(this,h).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};v=new WeakMap,n=new WeakMap,B=new WeakMap,d=new WeakMap,_=new WeakMap,N=new WeakMap,h=new WeakMap,M=new WeakMap,I=new WeakMap,L=new WeakMap,A=new WeakMap,q=new WeakMap,T=new WeakMap,V=new WeakMap,W=new WeakMap,x=new WeakMap,g=new WeakSet,Dt=s(function(){o(this,d).autoFocus&&(o(this,I)?this.focus():l(this,L,!0)),o(this,v).publish("state-change")},"#handleViewStateChange"),Tt=s(function(t){o(this,n).preloadFloors(o(this,B).getByType("facade").map(e=>dt(o(this,h).get(e.floorStack.id),t,o(this,A))).filter(e=>e!=null&&mt.Floor.is(e)))},"#preloadFloors"),ot=new WeakMap,et=new WeakMap,it=new WeakMap,at=new WeakMap,K=new WeakMap,At=s(function(t,e,a){t.forEach(i=>{if(i.floor)if(e){let c=a!==void 0?{...i.state,labels:{...i.state.labels,enabled:i.state.labels.enabled&&a},markers:{...i.state.markers,enabled:i.state.markers.enabled&&a},occlusion:{...i.state.occlusion,enabled:i.state.occlusion.enabled&&a}}:i.state;o(this,n).updateState(i.floor,c)}else o(this,n).updateState(i.floor,{visible:!1})})},"#updateFloorVisibility"),Gt=s(async function(t,e,a,i){return b(this,g,At).call(this,e.floorStates,!0,i),t.animateFacade(a.state,o(this,d).indoorAnimationOptions)},"#animateIndoorSequence"),jt=s(async function(t,e,a,i){let c=await t.animateFacade(a.state,o(this,d).outdoorAnimationOptions);return c.result==="completed"&&b(this,g,At).call(this,e.floorStates,yt(t,o(this,n).currentFloor,o(this,T)==="in-range",o(this,N).has(t.id),o(this,d).mode,o(this,A),i.includes(t.floorStack.id),o(this,d).dynamicBuildingInteriors)),c},"#animateOutdoorSequence"),Z=new WeakMap,s(wt,"DynamicFocus");var ft=wt;return zt(oo);})();
11
+ "use strict";var DynamicFocus=(()=>{var ot=Object.defineProperty;var yo=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var So=Object.prototype.hasOwnProperty;var Wt=n=>{throw TypeError(n)};var Eo=(n,t,e)=>t in n?ot(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var a=(n,t)=>ot(n,"name",{value:t,configurable:!0}),pt=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var vo=(n,t)=>{for(var e in t)ot(n,e,{get:t[e],enumerable:!0})},wo=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of bo(t))!So.call(n,r)&&r!==e&&ot(n,r,{get:()=>t[r],enumerable:!(i=yo(t,r))||i.enumerable});return n};var To=n=>wo(ot({},"__esModule",{value:!0}),n);var f=(n,t,e)=>Eo(n,typeof t!="symbol"?t+"":t,e),It=(n,t,e)=>t.has(n)||Wt("Cannot "+e);var o=(n,t,e)=>(It(n,t,"read from private field"),e?e.call(n):t.get(n)),u=(n,t,e)=>t.has(n)?Wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),c=(n,t,e,i)=>(It(n,t,"write to private field"),i?i.call(n,e):t.set(n,e),e),b=(n,t,e)=>(It(n,t,"access private method"),e);var No={};vo(No,{DynamicFocus:()=>wt,calculateZoomThresholds:()=>mo});var Tt=pt("@mappedin/mappedin-js");function Kt(n,t){if(n==null||t==null)return n===t;if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==t[e])return!1;return!0}a(Kt,"arraysEqual");var Mt=class Mt{constructor(){f(this,"_subscribers",{});f(this,"_abortController",new AbortController);f(this,"_cleanupFunctions",[])}get signal(){return this._abortController.signal}publish(t,e){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,e,i){let r=i?.signal;if(r?.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e);let s=a(()=>this.off(t,e),"cleanup");return r&&r.addEventListener("abort",s,{once:!0}),this._cleanupFunctions.push(s),s}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){if(!this.signal.aborted){for(let t of this._cleanupFunctions)t();this._cleanupFunctions=[],this._subscribers={},this._abortController.abort()}}};a(Mt,"PubSub");var gt=Mt;var Y=pt("@mappedin/mappedin-js");var E,et,V,S,y,T,j,$,Vt=class Vt{constructor(t,e){f(this,"__type","building");u(this,E);u(this,et,new Map);u(this,V,new Map);u(this,S,[]);u(this,y);u(this,T);f(this,"defaultFloor");f(this,"activeFloor");f(this,"excluded",!1);f(this,"floorsAltitudesMap",new Map);f(this,"aboveGroundFloors",[]);u(this,j);u(this,$);c(this,E,t),c(this,et,new Map(t.floors.map(r=>[r.id,r]))),c(this,V,new Map(t.floors.map(r=>[r.elevation,r]))),c(this,S,Array.from(o(this,V).values()).sort((r,s)=>r.elevation-s.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,c(this,y,e),this.aboveGroundFloors=o(this,S).filter(r=>r.elevation>=0);let i=t.facade?.spaces.map(r=>o(this,y).getState(r)).sort((r,s)=>r.altitude-s.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let r in this.aboveGroundFloors){let s=this.aboveGroundFloors[r],d=i[r];this.floorsAltitudesMap.set(s.elevation,{altitude:d.altitude,effectiveHeight:d.height})}}get id(){return o(this,E).id}get name(){return o(this,E).name}get floors(){return o(this,E).floors}get floorStack(){return o(this,E)}get facade(){return o(this,E).facade}get isCurrentFloorStack(){return this.id===o(this,y).currentFloorStack.id}get isIndoor(){let t=o(this,y).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,j)==null&&c(this,j,Math.max(...o(this,V).keys())),o(this,j)}get minElevation(){return o(this,$)==null&&c(this,$,Math.min(...o(this,V).keys())),o(this,$)}has(t){return Y.Floor.is(t)?o(this,et).has(t.id):Y.FloorStack.is(t)?t.id===o(this,E).id:Y.Facade.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,V).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,S)[o(this,S).length-1];for(let i=o(this,S).length-1;i>=0;i--){let r=o(this,S)[i];if(r.elevation<=t)return r}}else{if(t<this.minElevation)return o(this,S)[0];for(let i of o(this,S))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,S)[o(this,S).length-1]}cancelAnimation(){o(this,T)&&(o(this,T).animation.cancel(),c(this,T,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,T)?.state||o(this,y).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:r,visible:s}=t;if(o(this,y).updateState(this.facade,{visible:!0}),r!==void 0){c(this,T,{animation:o(this,y).animateState(this.facade,{opacity:r},{duration:e.duration}),state:t});let d=await o(this,T).animation;if(c(this,T,void 0),d.result==="cancelled")return d}return s===!1&&o(this,y).updateState(this.facade,{visible:s}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,E).floors.forEach(t=>{o(this,y).updateState(t,{visible:t.id===o(this,y).currentFloor.id})}),this.has(o(this,y).currentFloor)||o(this,y).updateState(this.facade,{visible:!0,opacity:1})}};E=new WeakMap,et=new WeakMap,V=new WeakMap,S=new WeakMap,y=new WeakMap,T=new WeakMap,j=new WeakMap,$=new WeakMap,a(Vt,"Building");var Ft=Vt;function Qt(n,t,e){return n>=t?"in-range":n<=e?"out-of-range":"transition"}a(Qt,"getZoomState");function yt(n,t,e){if(n.__type==="outdoors"&&"floor"in n)return n.floor;let i=n;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(yt,"getFloorToShow");function Bo(n,t,e){return t?{facade:n,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:n,state:{type:"facade",visible:!0,opacity:.2}}:{facade:n,state:{type:"facade",visible:!0,opacity:1}}}a(Bo,"getFacadeState");function Oo(n,t,e){return{outdoorOpacity:"initial",floorStates:n.floors.map(i=>{let r=i.id===t.id&&e;return{floor:i,state:{type:"floor",visible:r,geometry:{visible:r},labels:{enabled:r},markers:{enabled:r},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}a(Oo,"getSingleBuildingState");function Jt(n,t){if(!t.includes("lock-elevation"))return"initial";for(let e of n)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(Jt,"getOutdoorOpacity");function Xt(n,t,e){switch(e){case"in-range":return n[0]?.canSetFloor?n[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(Xt,"getSetFloorTargetFromZoomState");function to(n){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:r,mode:s,elevation:d,floorIdsInNavigation:m,floorStackIdsInNavigation:P,multiFloorView:J,getMultiFloorState:_,dynamicBuildingInteriors:X,isolateBelowGroundView:mt,currentElevation:U}=n,tt=new Map,Bt=mt&&U<0;for(let g of t){let zt=e.has(g.id),Ht=Bt&&g.minElevation>=0,po=Ht?!1:zt,Ot=Ht?!1:xt({building:g,currentFloor:i,inRange:r==="in-range",inFocus:zt,mode:s,elevation:d,inNavigation:P.includes(g.id),dynamicBuildingInteriors:X}),kt=i.floorStack.id===g.id?g.activeFloor:yt(g,s,d),go=J.enabled?_(g.floors,kt||g.activeFloor,J?.floorGap,m,g.floorsAltitudesMap):Oo(g.floorStack,kt||g.activeFloor,Ot),Fo=Bo(g.facade,Ot,mt&&U<0);tt.set(g.id,{building:g,showIndoor:Ot,floorStackState:go,facadeState:Fo,inFocus:po,floorToShow:kt})}return tt}a(to,"getBuildingStates");function oo(n,t){return n.excluded?"none":t?"indoor":"outdoor"}a(oo,"getBuildingAnimationType");function xt(n){let{building:t,currentFloor:e,inRange:i,inFocus:r,mode:s,elevation:d,inNavigation:m,dynamicBuildingInteriors:P}=n;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(m===!0)return!0;if(!P)return e.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(s){case"lock-elevation":return t.getFloorByElevation(d)!=null;default:break}return!0}a(xt,"shouldShowIndoor");function eo(n,t,e){return n!==t&&!e}a(eo,"shouldDeferSetFloor");var io=["default-floor","lock-elevation","nearest-elevation"];var bt=pt("@mappedin/mappedin-js");var Dt="[MappedinJS]";function At(n="",{prefix:t=Dt}={}){let e=\`\${t}\${n?\`-\${n}\`:""}\`,i=a((r,s)=>{if(typeof window<"u"&&window.rnDebug){let d=s.map(m=>m instanceof Error&&m.stack?\`\${m.message}
12
+ \${m.stack}\`:m);window.rnDebug(\`\${n} \${r}: \${d.join(" ")}\`)}},"rnDebug");return{logState:0,log(...r){this.logState<=0&&(console.log(e,...r),i("log",r))},warn(...r){this.logState<=1&&(console.warn(e,...r),i("warn",r))},error(...r){this.logState<=2&&(console.error(e,...r),i("error",r))},assert(...r){console.assert(...r)},time(r){console.time(r)},timeEnd(r){console.timeEnd(r)},setLevel(r){0<=r&&r<=3&&(this.logState=r)}}}a(At,"createLogger");var ko=At();var q=ko;function ro(n,t,e,i){return(n<t||n>e)&&q.warn(i),Math.min(e,Math.max(t,n))}a(ro,"clampWithWarning");function Lt(n,t){return!bt.Floor.is(n)||n?.floorStack==null||!bt.FloorStack.is(t)?!1:n.floorStack.id!==t.id?(q.warn(\`Floor (\${n.id}) does not belong to floor stack (\${t.id}).\`),!1):!0}a(Lt,"validateFloorForStack");function _t(n,t,e,i){return ro(n,t,e,\`\${i} must be between \${t} and \${e}.\`)}a(_t,"validateZoomThreshold");var z=At("",{prefix:"[DynamicFocus]"});var B,H,it,Nt,Ct=class Ct{constructor(t,e){u(this,it);f(this,"__type","outdoors");u(this,B);u(this,H);c(this,B,t),c(this,H,e)}get id(){return o(this,B).id}get floorStack(){return o(this,B)}get floor(){return o(this,B).defaultFloor}matchesFloorStack(t){return t===o(this,B)||t===o(this,B).id}show(){b(this,it,Nt).call(this,!0)}hide(){b(this,it,Nt).call(this,!1)}destroy(){this.matchesFloorStack(o(this,H).currentFloorStack)||this.hide()}};B=new WeakMap,H=new WeakMap,it=new WeakSet,Nt=a(function(t){for(let e of o(this,B).floors)o(this,H).updateState(e,{visible:t})},"#setVisible"),a(Ct,"Outdoors");var St=Ct;function no(n,t){let e=n.getByType("floor-stack"),i=e.find(d=>d.type?.toLowerCase()==="outdoor"),r=n.getByType("enterprise-venue")?.defaultFloor;if(r){let d=n.getById("floor",r);if(d)return d.floorStack}if(i)return i;let s=e.find(d=>d.facade==null&&!t.has(d.id));return s||(z.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(no,"getOutdoorFloorStack");var ao=pt("@mappedin/mappedin-js"),so={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,customMultiFloorVisibilityState:ao.getMultiFloorState,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1},Zt=.2,Gt=.4;function Io(n,t){return\`\${t} \${n}\`}a(Io,"formatMessage");var Rt=class Rt extends Error{constructor(t,e=Dt){super(Io(t,e)),this.name="MappedinError"}};a(Rt,"MappedinError");var Et=Rt;var Mo=a(n=>n,"linearEase"),Vo=a(n=>n*n,"quadEaseIn"),xo=a(n=>1-Math.cos(n*Math.PI/2),"easeIn"),Do=a(n=>1-(1-n)*(1-n),"quadEaseOut"),Ao={linear:Mo,"ease-in":Vo,"ease-out":Do,"ease-in-out":xo};function Lo(n,t){let e=0;if(t.length<2)return e;let r=t[0]<t[1]?(s,d)=>s>d:(s,d)=>s<d;for(;e<t.length-1&&r(n,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Lo,"getInterpolationBreakpoint");function lo(n,t,e,i="ease-in"){if(t.length!==e.length)throw new Et("Input and output ranges must have the same number of values.");n=Math.max(t[0],Math.min(n,t[t.length-1]));let r=Lo(n,t),s=(n-t[r])/(t[r+1]-t[r]),d=typeof i=="function"?i(s):Ao[i](s);return e[r]+d*(e[r+1]-e[r])}a(lo,"interpolateMulti");var O,rt,nt,I,at,Ut=class Ut{constructor(t,e,i){f(this,"layers");f(this,"visible");u(this,O);u(this,rt,[]);u(this,nt,!1);u(this,I,new Map);f(this,"interpolationFn");u(this,at,1);this.layers=t,this.visible=e,c(this,O,i)}processLayerGroup(t,e,i){if(!o(this,nt)&&(this.layers.forEach(r=>{let s=t[r];s&&o(this,rt).push(...s)}),c(this,nt,!0),this.visible)){let r=[e,i],s=[1,0];this.interpolationFn=d=>lo(d,r,s)}}setOpacity(t){c(this,at,t);for(let e of o(this,rt))if(e.startsWith("img_")){let i=o(this,O).Image3D.getById(e);if(i){let r=o(this,O).getState(i.image);o(this,I).has(e)||o(this,I).set(e,r?.opacity??1);let s=Math.min(o(this,I).get(e),t);o(this,O).updateState(i.image,{opacity:s})}}else{let i=o(this,O).getMapData()?.getById("space",e);if(!i)continue;let r=o(this,O).getState(i);o(this,I).has(e)||o(this,I).set(e,r?.opacity??1);let s=Math.min(o(this,I).get(e),t);o(this,O).updateState(i,{opacity:s,visible:s>0})}}get opacity(){return o(this,at)}};O=new WeakMap,rt=new WeakMap,nt=new WeakMap,I=new WeakMap,at=new WeakMap,a(Ut,"LayerGroup");var vt=Ut;function Pt(n,t){n.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(Pt,"runLayerGroupInterpolations");var v,l,x,h,N,C,F,M,Z,G,w,W,st,lt,ut,k,D,K,A,L,p,jt,uo,co,$t,ct,dt,ht,ft,Q,Yt,ho,fo,R,qt=class qt{constructor(t){u(this,p);u(this,v);u(this,l);u(this,x);u(this,h,so);u(this,N,[]);u(this,C,new Set);u(this,F,new Map);u(this,M);u(this,Z,!1);u(this,G,!1);u(this,w,0);u(this,W,0);u(this,st,[]);u(this,lt,{});u(this,ut,{});u(this,k,"transition");u(this,D,"outdoor");u(this,K,[]);u(this,A,!1);u(this,L,[]);f(this,"sceneUpdateQueue",Promise.resolve());f(this,"on",a((t,e)=>{o(this,v).on(t,e)},"on"));f(this,"off",a((t,e)=>{o(this,v).off(t,e)},"off"));u(this,ct,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(Kt(e,this.focusedFacades)&&o(this,D)==="transition"&&!o(this,G))return;c(this,G,!1),c(this,N,[]),o(this,C).clear();let i=o(this,h).isolateBelowGroundView&&o(this,w)<0;if(e.length>0)for(let r of e){let s=o(this,F).get(r.floorStack.id);if(s){if(i&&s.minElevation>=0)continue;o(this,C).add(s.id),o(this,N).push(s)}}o(this,h).autoFocus&&this.focus()},"#handleFacadesInViewChange"));u(this,dt,a(async t=>{if(!this.isEnabled)return;let{floor:e}=t,i=o(this,F).get(e.floorStack.id);if(i&&(i.activeFloor=e),i?.excluded===!1&&!o(this,M).matchesFloorStack(e.floorStack)&&c(this,w,e.elevation),o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(await o(this,R).call(this,e),o(this,v).publish("focus",{facades:this.focusedFacades}));let r=i?.floorsAltitudesMap.get(e.elevation)?.altitude??0;o(this,l).options.multiFloorView!=null&&o(this,l).options.multiFloorView?.enabled&&o(this,l).options.multiFloorView?.updateCameraElevationOnFloorChange&&o(this,l).Camera.elevation!==r&&o(this,l).Camera.animateElevation(r,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));u(this,ht,a(()=>{c(this,Z,!0)},"#handleUserInteractionStart"));u(this,ft,a(()=>{c(this,Z,!1)},"#handleUserInteractionEnd"));u(this,Q,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=Qt(e,o(this,h).indoorZoomThreshold,o(this,h).outdoorZoomThreshold);o(this,k)!==i&&(c(this,k,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Pt(o(this,L),e)},"#handleCameraChange"));u(this,R,a(async t=>{if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).options.multiFloorView,r=o(this,l).Navigation?.floors?.map(m=>m.id)||[],s=o(this,l).Navigation?.floorStacks.map(m=>m.id)||[],d=new Promise(async m=>{await this.sceneUpdateQueue;let P=to({buildings:Array.from(o(this,F).values()),inViewSet:o(this,C),currentFloor:e,zoomState:o(this,k),mode:o(this,h).mode,elevation:o(this,w),floorIdsInNavigation:r,floorStackIdsInNavigation:s,multiFloorView:i,getMultiFloorState:o(this,h).customMultiFloorVisibilityState??Tt.getMultiFloorState,dynamicBuildingInteriors:o(this,h).dynamicBuildingInteriors,isolateBelowGroundView:o(this,h).isolateBelowGroundView,currentElevation:o(this,w)}),J=[];await Promise.all(Array.from(P.values()).map(async _=>{let{building:X,showIndoor:mt,floorStackState:U,facadeState:tt,inFocus:Bt}=_;J.push(U);let g=oo(X,mt);if(g==="indoor")return b(this,p,ho).call(this,X,U,tt,Bt);if(g==="outdoor")return b(this,p,fo).call(this,X,U,tt,s)})),o(this,l).Outdoor.setOpacity(Jt(J,o(this,h).mode)),c(this,K,o(this,N).filter(_=>P.get(_.id)?.showIndoor===!0).map(_=>_.facade)),o(this,v).publish("focus",{facades:o(this,K)}),m()});return this.sceneUpdateQueue=d,d},"#applyBuildingStates"));c(this,v,new gt),c(this,l,t),z.setLevel(q.logState),c(this,x,o(this,l).getMapData()),c(this,w,o(this,l).currentFloor.elevation),c(this,W,o(this,l).Camera.elevation);for(let e of o(this,x).getByType("facade"))o(this,F).set(e.floorStack.id,new Ft(e.floorStack,o(this,l)));b(this,p,co).call(this),c(this,M,new St(no(o(this,x),o(this,F)),o(this,l))),o(this,l).on("floor-change-start",o(this,dt)),o(this,l).on("camera-change",o(this,Q)),o(this,l).on("facades-in-view-change",o(this,ct)),o(this,l).on("user-interaction-start",o(this,ht)),o(this,l).on("user-interaction-end",o(this,ft))}enable(t){if(o(this,A)){z.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,A,!0),o(this,l).manualFloorVisibility=!0,o(this,M).show(),this.updateState({...o(this,h),...t}),b(this,p,uo).call(this),o(this,Q).call(this,{zoomLevel:o(this,l).Camera.zoomLevel,center:o(this,l).Camera.center,bearing:o(this,l).Camera.bearing,pitch:o(this,l).Camera.pitch}),o(this,l).Camera.updateFacadesInView()}disable(){if(!o(this,A)){z.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,A,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,A)}get isIndoor(){return o(this,D)==="indoor"}get isOutdoor(){return o(this,D)==="outdoor"}get outdoorsFloorStack(){return o(this,M).floorStack}get layers(){return o(this,st)}get layersBySpaceId(){return o(this,lt)}setIndoor(){c(this,D,"indoor"),c(this,k,"in-range"),b(this,p,jt).call(this)}setOutdoor(){c(this,D,"outdoor"),c(this,k,"out-of-range"),b(this,p,jt).call(this)}get focusedFacades(){return[...o(this,K)]}getState(){return{...o(this,h)}}updateState(t){let e=!1;t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=_t(t.indoorZoomThreshold,t?.outdoorZoomThreshold??o(this,h).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=_t(t.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,t?.indoorZoomThreshold??o(this,h).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=io.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(o(this,h).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==o(this,h).dynamicBuildingInteriors&&(e=!0),t.isolateBelowGroundView!=null&&t.isolateBelowGroundView!==o(this,h).isolateBelowGroundView&&(e=!0),c(this,h,Object.assign({},o(this,h),Object.fromEntries(Object.entries(t).filter(([,i])=>i!=null)))),t.mode!=null&&t.preloadFloors&&b(this,p,$t).call(this,t.mode),e&&o(this,R).call(this)}destroy(){this.disable(),o(this,l).off("facades-in-view-change",o(this,ct)),o(this,l).off("floor-change-start",o(this,dt)),o(this,l).off("camera-change",o(this,Q)),o(this,l).off("user-interaction-start",o(this,ht)),o(this,l).off("user-interaction-end",o(this,ft)),o(this,F).forEach(t=>t.destroy()),o(this,M).destroy(),o(this,v).destroy(),c(this,L,[])}async focus(t=o(this,h).setFloorOnFocus){if(t)if(eo(o(this,W),o(this,l).Camera.elevation,o(this,Z)))c(this,W,o(this,l).Camera.elevation),c(this,G,!0);else{let e=Xt(o(this,N),o(this,M),o(this,k)),i=e?yt(e,o(this,h).mode,o(this,w)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,R).call(this),o(this,v).publish("focus",{facades:this.focusedFacades})}preloadFloors(){b(this,p,$t).call(this,o(this,h).mode)}setDefaultFloorForStack(t,e){if(!Lt(e,t))return;let i=o(this,F).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,F).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){return o(this,F).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Lt(e,t))return;let i=o(this,F).get(t.id);i&&(i.activeFloor=e,o(this,R).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,F).get(i.id);r&&(r.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,F).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){return o(this,F).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};v=new WeakMap,l=new WeakMap,x=new WeakMap,h=new WeakMap,N=new WeakMap,C=new WeakMap,F=new WeakMap,M=new WeakMap,Z=new WeakMap,G=new WeakMap,w=new WeakMap,W=new WeakMap,st=new WeakMap,lt=new WeakMap,ut=new WeakMap,k=new WeakMap,D=new WeakMap,K=new WeakMap,A=new WeakMap,L=new WeakMap,p=new WeakSet,jt=a(function(){o(this,h).autoFocus&&(o(this,Z)?this.focus():c(this,G,!0)),o(this,v).publish("state-change")},"#handleViewStateChange"),uo=a(function(){c(this,L,[]);for(let t of o(this,h).dynamicLayers){let e=new vt([t],!0,o(this,l));e.processLayerGroup(o(this,ut),o(this,h).outdoorZoomThreshold,o(this,h).indoorZoomThreshold),o(this,L).push(e)}Pt(o(this,L),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),co=a(function(){let t=o(this,x).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(r=>{e[r.name]||(e[r.name]=[]),e[r.name].push(...r.spaces.map(({spaceId:s})=>s));for(let{spaceId:s}of r.spaces)i[s]==null&&(i[s]=[]),i[s].push(r.name)}),c(this,st,t.map(({name:r})=>r)),c(this,lt,i),c(this,ut,e)},"#setupLayers"),$t=a(function(t){o(this,l).preloadFloors(o(this,x).getByType("facade").map(e=>yt(o(this,F).get(e.floorStack.id),t,o(this,w))).filter(e=>e!=null&&Tt.Floor.is(e)))},"#preloadFloors"),ct=new WeakMap,dt=new WeakMap,ht=new WeakMap,ft=new WeakMap,Q=new WeakMap,Yt=a(function(t,e,i){t.forEach(r=>{if(r.floor)if(e){let s=i!==void 0?{...r.state,labels:{...r.state.labels,enabled:r.state.labels.enabled&&i},markers:{...r.state.markers,enabled:r.state.markers.enabled&&i},occlusion:{...r.state.occlusion,enabled:r.state.occlusion.enabled&&i}}:r.state;o(this,l).updateState(r.floor,s)}else o(this,l).updateState(r.floor,{visible:!1})})},"#updateFloorVisibility"),ho=a(async function(t,e,i,r){return b(this,p,Yt).call(this,e.floorStates,!0,r),t.animateFacade(i.state,o(this,h).indoorAnimationOptions)},"#animateIndoorSequence"),fo=a(async function(t,e,i,r){let s=await t.animateFacade(i.state,o(this,h).outdoorAnimationOptions);return s.result==="completed"&&b(this,p,Yt).call(this,e.floorStates,xt({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,k)==="in-range",inFocus:o(this,C).has(t.id),mode:o(this,h).mode,elevation:o(this,w),inNavigation:r.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,h).dynamicBuildingInteriors})),s},"#animateOutdoorSequence"),R=new WeakMap,a(qt,"DynamicFocus");var wt=qt;var mo=a((n,t)=>{let e={initialVisibility:t.initialVisibility??"outdoor-first",layersBySpaceId:t.layersBySpaceId??{},focusLayers:t.focusLayers??[],defaultFloor:t.defaultFloor??n.currentFloor},i=_o(n,e),r=i+Gt,s=i+Zt;return e.initialVisibility==="indoor-first"&&(r=i-Zt,s=i-Gt),{indoorZoomThreshold:r,outdoorZoomThreshold:s}},"calculateZoomThresholds");function _o(n,t){let e=n.getMapData().getByType("space"),i=t.focusLayers.length?e.filter(d=>{let m=t.layersBySpaceId[d.id]?.[0];return typeof m=="string"&&d.floor.id===t.defaultFloor?.id&&t.focusLayers?.indexOf(m)!==-1}):void 0,r=n.Camera.getFocusOnTransform(t.defaultFloor,{}).zoomLevel??0;return(i?.length?n.Camera.getFocusOnTransform(i,{}).zoomLevel:void 0)??r}a(_o,"getDefaultZoomLevel");return To(No);})();
13
13
 
14
14
 
15
15
  // Register the extension
@@ -22,4 +22,4 @@ if (window.bridge && window.bridge.extensions) {
22
22
  }
23
23
  } else {
24
24
  if (window.rnDebug) window.rnDebug('Bridge or extensions not available for registration');
25
- }`;function S(){return P}l(S,"getRegistrationScript");function g(){N({extensionName:"dynamic-focus",getRegistrationScript:S,logger:w})}l(g,"useDynamicFocusRegistration");function b(e,i){if(typeof e!="string"||e.length===0)throw new Error("Event parameter must be a non-empty string");if(typeof i!="function")throw new Error("Callback parameter must be a function");const o=Z(j),{extensions:a,mapData:t}=o;if(!t)throw new Error("Map data is not available");g();const f=(a?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",s=B(h=>{try{let u=h;e==="focus"&&h.facades&&(u={...h,facades:v(t,h.facades)}),i(u)}catch(u){w.error(`Error in dynamic focus event callback for ${String(e)}:`,u)}},[e,t,i]);L({eventKey:`dynamic-focus:${String(e)}`,callback:s,setupScript:l(()=>R({extensionName:"dynamic-focus",eventName:String(e)}),"setupScript"),cleanupScript:l(()=>V({extensionName:"dynamic-focus",eventName:String(e)}),"cleanupScript"),shouldInject:f})}l(b,"useDynamicFocusEvent");function k(){const e=T(I),{bridge:i,extensions:o,updateExtensionState:a}=e;g();const t=o["dynamic-focus"],d=t?.registrationState||"unregistered",f=d==="registered",s=t?.isEnabled||!1,[h,u]=_(t?.focusedFacades||[]),y=A(o);y.current=o,b("focus",c(n=>{const p=n.facades;u(p),a("dynamic-focus",F=>({...F,registrationState:d,focusedFacades:p}))},[d,a]));const r=c(async(n,p=[])=>{if(!i?.isReady)throw new Error("Bridge is not ready. Ensure the WebView is loaded.");return await i.instruct({type:"extension",payload:{name:"dynamic-focus",method:n,args:p}})},[i]),E=c(async n=>{y.current?.["dynamic-focus"]?.isEnabled||(await r("enable",[n]),a("dynamic-focus",D=>({...D,isEnabled:!0})))},[r,a]),M=c(async n=>await r("updateState",[n]),[r]),x=c(async()=>await r("getState"),[r]),C=c(async n=>await r("focus",[n]),[r]),O=c(async()=>{await r("disable"),u([]),a("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[r,u,a]);return{isReady:f,isEnabled:s,focusedFacades:h,updateState:M,getState:x,focus:C,disable:O,enable:E}}l(k,"useDynamicFocus");export{k as useDynamicFocus,b as useDynamicFocusEvent};
25
+ }`;function S(){return G}l(S,"getRegistrationScript");function m(){j({extensionName:"dynamic-focus",getRegistrationScript:S,logger:w})}l(m,"useDynamicFocusRegistration");function y(e,i){if(typeof e!="string"||e.length===0)throw new Error("Event parameter must be a non-empty string");if(typeof i!="function")throw new Error("Callback parameter must be a function");const o=V(Z),{extensions:r,mapData:t}=o;if(!t)throw new Error("Map data is not available");m();const f=(r?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",s=L(d=>{try{let u=d;e==="focus"&&d.facades&&(u={...d,facades:v(t,d.facades)}),i(u)}catch(u){w.error(`Error in dynamic focus event callback for ${String(e)}:`,u)}},[e,t,i]);$({eventKey:`dynamic-focus:${String(e)}`,callback:s,setupScript:l(()=>N({extensionName:"dynamic-focus",eventName:String(e)}),"setupScript"),cleanupScript:l(()=>R({extensionName:"dynamic-focus",eventName:String(e)}),"cleanupScript"),shouldInject:f})}l(y,"useDynamicFocusEvent");function k(){const e=_(D),{bridge:i,extensions:o,updateExtensionState:r}=e;m();const t=o["dynamic-focus"],c=t?.registrationState||"unregistered",f=c==="registered",s=t?.isEnabled||!1,[d,u]=W(t?.focusedFacades||[]),b=T(o);b.current=o,y("focus",h(n=>{const p=n.facades;u(p),r("dynamic-focus",F=>({...F,registrationState:c,focusedFacades:p}))},[c,r]));const a=h(async(n,p=[])=>{if(!i?.isReady)throw new Error("Bridge is not ready. Ensure the WebView is loaded.");return await i.instruct({type:"extension",payload:{name:"dynamic-focus",method:n,args:p}})},[i]),M=h(async n=>{b.current?.["dynamic-focus"]?.isEnabled||(await a("enable",[n]),r("dynamic-focus",O=>({...O,isEnabled:!0})))},[a,r]),E=h(async n=>await a("updateState",[n]),[a]),I=h(async()=>await a("getState"),[a]),x=h(async n=>await a("focus",[n]),[a]),B=h(async()=>{await a("disable"),u([]),r("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[a,u,r]);return{isReady:f,isEnabled:s,focusedFacades:d,updateState:E,getState:I,focus:x,disable:B,enable:M}}l(k,"useDynamicFocus");export{k as useDynamicFocus,y as useDynamicFocusEvent};
package/lib/rn/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Facade, Floor, TFacadeState, VisibilityState as BuildingFloorStackState } from '@mappedin/mappedin-js';
2
+ import { Building } from './building';
2
3
  export type MultiFloorVisibilityState = (floors: Floor[], currentFloor: Floor, floorGap: number, floorIdsInNavigation: Floor['id'][], floorsVisualHeightMap?: Map<number, {
3
4
  altitude: number;
4
5
  effectiveHeight: number;
@@ -41,7 +42,7 @@ export type DynamicFocusState = {
41
42
  * The zoom level at which the camera will fade in the facades and fade out the indoor floors.
42
43
  * @default 17
43
44
  */
44
- outdoorZoomThreshold: number;
45
+ outdoorZoomThreshold?: number;
45
46
  /**
46
47
  * Whether to set the floor to the outdoors when the camera moves in range.
47
48
  * @default true
@@ -70,6 +71,12 @@ export type DynamicFocusState = {
70
71
  * @default true
71
72
  */
72
73
  dynamicBuildingInteriors: boolean;
74
+ /**
75
+ * Whether to automatically hide all above ground buildings and floors when the camera transitions to a below-ground elevation.
76
+ * @experimental
77
+ * @default false
78
+ */
79
+ isolateBelowGroundView: boolean;
73
80
  /**
74
81
  * Whether to preload the geometry of the initial floors in each building. Improves performance when rendering the building for the first time.
75
82
  * @default true
@@ -82,6 +89,11 @@ export type DynamicFocusState = {
82
89
  * This is useful for customizing the floor visibility state for a specific building.
83
90
  */
84
91
  customMultiFloorVisibilityState?: MultiFloorVisibilityState;
92
+ /**
93
+ * Dynamic layers
94
+ * @experimental
95
+ */
96
+ dynamicLayers: string[];
85
97
  };
86
98
  /**
87
99
  * Internal events emitted for updating React state.
@@ -107,7 +119,12 @@ export type BuildingFacadeState = {
107
119
  facade: Facade;
108
120
  state: TFacadeState;
109
121
  };
110
- export type BuildingState = BuildingFloorStackState & {
122
+ export type BuildingState = {
123
+ building: Building;
124
+ showIndoor: boolean;
125
+ floorStackState: BuildingFloorStackState;
126
+ inFocus: boolean;
127
+ floorToShow: Floor | undefined;
111
128
  facadeState: BuildingFacadeState;
112
129
  };
113
130
  export type ZoomState = 'in-range' | 'out-of-range' | 'transition';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappedin/dynamic-focus",
3
- "version": "6.5.0-beta.0",
3
+ "version": "6.7.0-beta.0",
4
4
  "homepage": "https://developer.mappedin.com/",
5
5
  "private": false,
6
6
  "main": "lib/esm/index.js",
@@ -37,9 +37,9 @@
37
37
  "license": "SEE LICENSE IN LICENSE.txt",
38
38
  "peerDependencies": {
39
39
  "react": ">=16.8.0",
40
- "@mappedin/mappedin-js": "^6.5.0",
41
- "@mappedin/react-native-sdk": "^6.5.0",
42
- "@mappedin/react-sdk": "^6.5.0"
40
+ "@mappedin/react-native-sdk": "^6.7.0",
41
+ "@mappedin/react-sdk": "^6.7.0",
42
+ "@mappedin/mappedin-js": "^6.7.0"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@mappedin/react-sdk": {
@@ -59,7 +59,7 @@
59
59
  "dependencies": {},
60
60
  "scripts": {
61
61
  "start": "pnpm build && concurrently \"node scripts/build.mjs --watchChanges\" \"node scripts/start.mjs\"",
62
- "build": "pnpm clean && tsc -b && node scripts/build.mjs",
62
+ "build": "pnpm clean && tsc -b tsconfig.build.json && node scripts/build.mjs",
63
63
  "build:prod": "cross-env NODE_ENV=production RN_BUILD=true pnpm build",
64
64
  "build:rn": "cross-env RN_BUILD=true pnpm build",
65
65
  "build:examples": "node ../scripts/build-examples.mjs dynamic-focus",
@@ -1 +0,0 @@
1
- var Ot=Object.defineProperty,qt=Object.defineProperties;var Wt=Object.getOwnPropertyDescriptors;var xt=Object.getOwnPropertySymbols;var Kt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var Vt=a=>{throw TypeError(a)};var ft=(a,t,e)=>t in a?Ot(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,V=(a,t)=>{for(var e in t||(t={}))Kt.call(t,e)&&ft(a,e,t[e]);if(xt)for(var e of xt(t))zt.call(t,e)&&ft(a,e,t[e]);return a},tt=(a,t)=>qt(a,Wt(t)),s=(a,t)=>Ot(a,"name",{value:t,configurable:!0});var F=(a,t,e)=>ft(a,typeof t!="symbol"?t+"":t,e),mt=(a,t,e)=>t.has(a)||Vt("Cannot "+e);var o=(a,t,e)=>(mt(a,t,"read from private field"),e?e.call(a):t.get(a)),u=(a,t,e)=>t.has(a)?Vt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,e),d=(a,t,e,i)=>(mt(a,t,"write to private field"),i?i.call(a,e):t.set(a,e),e),E=(a,t,e)=>(mt(a,t,"access private method"),e);var y={env:{NODE_ENV:"production",npm_package_version:"6.5.0-beta.0"}};import{Floor as lo,getMultiFloorState as uo}from"@mappedin/mappedin-js";function _t(a,t){if(a==null||t==null)return a===t;if(a.length!==t.length)return!1;for(let e=0;e<a.length;e++)if(a[e]!==t[e])return!1;return!0}s(_t,"arraysEqual");var pt=class pt{constructor(){F(this,"_subscribers",{});F(this,"_destroyed",!1)}publish(t,e){!this._subscribers||!this._subscribers[t]||this._destroyed||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}on(t,e){(!this._subscribers||this._destroyed)&&(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e)}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this._destroyed)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){this._destroyed=!0,this._subscribers={}}};s(pt,"PubSub");var lt=pt;import{Facade as Jt,Floor as Xt,FloorStack as to}from"@mappedin/mappedin-js";var v,ot,_,b,g,A,Y,U,Ft=class Ft{constructor(t,e){F(this,"__type","building");u(this,v);u(this,ot,new Map);u(this,_,new Map);u(this,b,[]);u(this,g);u(this,A);F(this,"defaultFloor");F(this,"activeFloor");F(this,"excluded",!1);F(this,"floorsAltitudesMap",new Map);F(this,"aboveGroundFloors",[]);u(this,Y);u(this,U);var r;d(this,v,t),d(this,ot,new Map(t.floors.map(l=>[l.id,l]))),d(this,_,new Map(t.floors.map(l=>[l.elevation,l]))),d(this,b,Array.from(o(this,_).values()).sort((l,f)=>l.elevation-f.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,d(this,g,e),this.aboveGroundFloors=o(this,b).filter(l=>l.elevation>=0);let i=(r=t.facade)==null?void 0:r.spaces.map(l=>o(this,g).getState(l)).sort((l,f)=>l.altitude-f.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let l in this.aboveGroundFloors){let f=this.aboveGroundFloors[l],h=i[l];this.floorsAltitudesMap.set(f.elevation,{altitude:h.altitude,effectiveHeight:h.height})}}get id(){return o(this,v).id}get name(){return o(this,v).name}get floors(){return o(this,v).floors}get floorStack(){return o(this,v)}get facade(){return o(this,v).facade}get isCurrentFloorStack(){return this.id===o(this,g).currentFloorStack.id}get isIndoor(){let t=o(this,g).getState(this.facade);return this.isCurrentFloorStack||(t==null?void 0:t.visible)===!1&&(t==null?void 0:t.opacity)===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,Y)==null&&d(this,Y,Math.max(...o(this,_).keys())),o(this,Y)}get minElevation(){return o(this,U)==null&&d(this,U,Math.min(...o(this,_).keys())),o(this,U)}has(t){return Xt.is(t)?o(this,ot).has(t.id):to.is(t)?t.id===o(this,v).id:Jt.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,_).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,b)[o(this,b).length-1];for(let i=o(this,b).length-1;i>=0;i--){let r=o(this,b)[i];if(r.elevation<=t)return r}}else{if(t<this.minElevation)return o(this,b)[0];for(let i of o(this,b))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,b)[o(this,b).length-1]}cancelAnimation(){o(this,A)&&(o(this,A).animation.cancel(),d(this,A,void 0))}async animateFacade(t,e={duration:150}){var f;let i=((f=o(this,A))==null?void 0:f.state)||o(this,g).getState(this.facade);if(!i||!t||(i==null?void 0:i.opacity)===t.opacity&&(i==null?void 0:i.visible)===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:r,visible:l}=t;if(o(this,g).updateState(this.facade,{visible:!0}),r!==void 0){d(this,A,{animation:o(this,g).animateState(this.facade,{opacity:r},{duration:e.duration}),state:t});let h=await o(this,A).animation;if(d(this,A,void 0),h.result==="cancelled")return h}return l===!1&&o(this,g).updateState(this.facade,{visible:l}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,v).floors.forEach(t=>{o(this,g).updateState(t,{visible:t.id===o(this,g).currentFloor.id})}),this.has(o(this,g).currentFloor)||o(this,g).updateState(this.facade,{visible:!0,opacity:1})}};v=new WeakMap,ot=new WeakMap,_=new WeakMap,b=new WeakMap,g=new WeakMap,A=new WeakMap,Y=new WeakMap,U=new WeakMap,s(Ft,"Building");var dt=Ft;function Bt(a,t,e){return a>=t?"in-range":a<=e?"out-of-range":"transition"}s(Bt,"getZoomState");function ut(a,t,e){if(a.__type==="outdoors"&&"floor"in a)return a.floor;let i=a;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}s(ut,"getFloorToShow");function oo(a,t){return{facade:a,state:{type:"facade",visible:!t,opacity:t?0:1}}}s(oo,"getFacadeState");function eo(a,t,e){return{outdoorOpacity:"initial",floorStates:a.floors.map(i=>{let r=i.id===t.id&&e;return{floor:i,state:{type:"floor",visible:r,geometry:{visible:r},labels:{enabled:r},markers:{enabled:r},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}s(eo,"getSingleBuildingState");function Nt(a,t){if(!t.includes("lock-elevation"))return"initial";for(let e of a)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}s(Nt,"getOutdoorOpacity");function It(a,t,e){var i;switch(e){case"in-range":return(i=a[0])!=null&&i.canSetFloor?a[0]:void 0;case"out-of-range":return t;case"transition":default:return}}s(It,"getSetFloorTargetFromZoomState");function Lt(a,t,e,i,r,l,f,h,T,st,L){let Q=new Map;for(let m of a){let J=t.has(m.id),x=gt(m,e,i==="in-range",J,r,l,h.includes(m.id),L),D=e.floorStack.id===m.id?m.activeFloor:ut(m,r,l),ht=T.enabled?st(m.floors,D||m.activeFloor,T==null?void 0:T.floorGap,f,m.floorsAltitudesMap):eo(m.floorStack,D||m.activeFloor,x),X=oo(m.facade,x);Q.set(m.id,{building:m,showIndoor:x,floorStackState:ht,facadeState:X,inFocus:J,floorToShow:D})}return Q}s(Lt,"getBuildingStates");function Zt(a,t){return a.excluded?"none":t?"indoor":"outdoor"}s(Zt,"getBuildingAnimationType");function gt(a,t,e,i,r,l,f,h){if(a.id===t.floorStack.id)return!0;if(a.excluded)return!1;if(f===!0)return!0;if(!h)return t.floorStack.type!=="Outdoor";if(!e||!i)return!1;switch(r){case"lock-elevation":return a.getFloorByElevation(l)!=null;default:break}return!0}s(gt,"shouldShowIndoor");function Ct(a,t,e){return a!==t&&!e}s(Ct,"shouldDeferSetFloor");var Pt=["default-floor","lock-elevation","nearest-elevation"];import{Floor as ro,FloorStack as no}from"@mappedin/mappedin-js";var io="[MappedinJS]";function St(a="",{prefix:t=io}={}){let e="".concat(t).concat(a?"-".concat(a):""),i=s((r,l)=>{if(typeof window<"u"&&window.rnDebug){let f=l.map(h=>h instanceof Error&&h.stack?"".concat(h.message,"\n").concat(h.stack):h);window.rnDebug("".concat(a," ").concat(r,": ").concat(f.join(" ")))}},"rnDebug");return{logState:y.env.NODE_ENV==="test"?3:0,log(...r){this.logState<=0&&(console.log(e,...r),i("log",r))},warn(...r){this.logState<=1&&(console.warn(e,...r),i("warn",r))},error(...r){this.logState<=2&&(console.error(e,...r),i("error",r))},assert(...r){console.assert(...r)},time(r){console.time(r)},timeEnd(r){console.timeEnd(r)},setLevel(r){0<=r&&r<=3&&(this.logState=r)}}}s(St,"createLogger");var ao=St();var $=ao;function Rt(a,t,e,i){return(a<t||a>e)&&$.warn(i),Math.min(e,Math.max(t,a))}s(Rt,"clampWithWarning");function yt(a,t){return!ro.is(a)||(a==null?void 0:a.floorStack)==null||!no.is(t)?!1:a.floorStack.id!==t.id?($.warn("Floor (".concat(a.id,") does not belong to floor stack (").concat(t.id,").")),!1):!0}s(yt,"validateFloorForStack");function bt(a,t,e,i){return Rt(a,t,e,"".concat(i," must be between ").concat(t," and ").concat(e,"."))}s(bt,"validateZoomThreshold");var H=St("",{prefix:"[DynamicFocus]"});var M,q,et,Et,vt=class vt{constructor(t,e){u(this,et);F(this,"__type","outdoors");u(this,M);u(this,q);d(this,M,t),d(this,q,e)}get id(){return o(this,M).id}get floorStack(){return o(this,M)}get floor(){return o(this,M).defaultFloor}matchesFloorStack(t){return t===o(this,M)||t===o(this,M).id}show(){E(this,et,Et).call(this,!0)}hide(){E(this,et,Et).call(this,!1)}destroy(){this.matchesFloorStack(o(this,q).currentFloorStack)||this.hide()}};M=new WeakMap,q=new WeakMap,et=new WeakSet,Et=s(function(t){for(let e of o(this,M).floors)o(this,q).updateState(e,{visible:t})},"#setVisible"),s(vt,"Outdoors");var ct=vt;function Gt(a,t){let e=a.find(r=>{var l;return((l=r.type)==null?void 0:l.toLowerCase())==="outdoor"});if(e)return e;let i=a.find(r=>r.facade==null&&!t.has(r.id));return i||(H.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),a[0])}s(Gt,"getOutdoorFloorStack");import{getMultiFloorState as so}from"@mappedin/mappedin-js";var jt={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,customMultiFloorVisibilityState:so,dynamicBuildingInteriors:!0};var k,n,Z,c,C,P,p,B,R,G,O,W,w,N,K,I,S,kt,Tt,it,at,rt,nt,z,Dt,Ut,$t,j,At=class At{constructor(t){u(this,S);u(this,k);u(this,n);u(this,Z);u(this,c,jt);u(this,C,[]);u(this,P,new Set);u(this,p,new Map);u(this,B);u(this,R,!1);u(this,G,!1);u(this,O,0);u(this,W,0);u(this,w,"transition");u(this,N,"outdoor");u(this,K,[]);u(this,I,!1);F(this,"sceneUpdateQueue",Promise.resolve());F(this,"on",s((t,e)=>{o(this,k).on(t,e)},"on"));F(this,"off",s((t,e)=>{o(this,k).off(t,e)},"off"));u(this,it,s(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(!(_t(e,this.focusedFacades)&&o(this,N)==="transition"&&!o(this,G))){if(d(this,G,!1),d(this,C,[]),o(this,P).clear(),e.length>0)for(let i of e){let r=o(this,p).get(i.floorStack.id);r&&(o(this,P).add(r.id),o(this,C).push(r))}o(this,c).autoFocus&&this.focus()}},"#handleFacadesInViewChange"));u(this,at,s(async t=>{var r,l,f,h;if(!this.isEnabled)return;let{floor:e}=t,i=o(this,p).get(e.floorStack.id);if(i&&(i.activeFloor=e),(i==null?void 0:i.excluded)===!1&&!o(this,B).matchesFloorStack(e.floorStack)&&d(this,O,e.elevation),o(this,n).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(await o(this,j).call(this,e),o(this,k).publish("focus",{facades:this.focusedFacades}));let T=(l=(r=i==null?void 0:i.floorsAltitudesMap.get(e.elevation))==null?void 0:r.altitude)!=null?l:0;o(this,n).options.multiFloorView!=null&&((f=o(this,n).options.multiFloorView)!=null&&f.enabled)&&((h=o(this,n).options.multiFloorView)!=null&&h.updateCameraElevationOnFloorChange)&&o(this,n).Camera.elevation!==T&&o(this,n).Camera.animateElevation(T,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));u(this,rt,s(()=>{d(this,R,!0)},"#handleUserInteractionStart"));u(this,nt,s(()=>{d(this,R,!1)},"#handleUserInteractionEnd"));u(this,z,s(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=Bt(e,o(this,c).indoorZoomThreshold,o(this,c).outdoorZoomThreshold);o(this,w)!==i&&(d(this,w,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor())},"#handleCameraChange"));u(this,j,s(async t=>{var h,T,st;if(o(this,n).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,n).currentFloor,i=o(this,n).options.multiFloorView,r=((T=(h=o(this,n).Navigation)==null?void 0:h.floors)==null?void 0:T.map(L=>L.id))||[],l=((st=o(this,n).Navigation)==null?void 0:st.floorStacks.map(L=>L.id))||[],f=new Promise(async L=>{var J;await this.sceneUpdateQueue;let Q=Lt(Array.from(o(this,p).values()),o(this,P),e,o(this,w),o(this,c).mode,o(this,O),r,l,i,(J=o(this,c).customMultiFloorVisibilityState)!=null?J:uo,o(this,c).dynamicBuildingInteriors),m=[];await Promise.all(Array.from(Q.values()).map(async x=>{let{building:D,showIndoor:ht,floorStackState:X,facadeState:Mt,inFocus:Ht}=x;m.push(X);let wt=Zt(D,ht);if(wt==="indoor")return E(this,S,Ut).call(this,D,X,Mt,Ht);if(wt==="outdoor")return E(this,S,$t).call(this,D,X,Mt,l)})),o(this,n).Outdoor.setOpacity(Nt(m,o(this,c).mode)),d(this,K,o(this,C).filter(x=>{var D;return((D=Q.get(x.id))==null?void 0:D.showIndoor)===!0}).map(x=>x.facade)),o(this,k).publish("focus",{facades:o(this,K)}),L()});return this.sceneUpdateQueue=f,f},"#applyBuildingStates"));d(this,k,new lt),d(this,n,t),H.setLevel($.logState),d(this,Z,o(this,n).getMapData()),d(this,O,o(this,n).currentFloor.elevation),d(this,W,o(this,n).Camera.elevation);for(let e of o(this,Z).getByType("facade"))o(this,p).set(e.floorStack.id,new dt(e.floorStack,o(this,n)));d(this,B,new ct(Gt(o(this,Z).getByType("floor-stack"),o(this,p)),o(this,n))),o(this,n).on("floor-change-start",o(this,at)),o(this,n).on("camera-change",o(this,z)),o(this,n).on("facades-in-view-change",o(this,it)),o(this,n).on("user-interaction-start",o(this,rt)),o(this,n).on("user-interaction-end",o(this,nt))}enable(t){if(o(this,I)){H.warn("enable() called on an already enabled Dynamic Focus instance.");return}d(this,I,!0),o(this,n).manualFloorVisibility=!0,o(this,B).show(),this.updateState(V(V({},o(this,c)),t)),o(this,z).call(this,{zoomLevel:o(this,n).Camera.zoomLevel,center:o(this,n).Camera.center,bearing:o(this,n).Camera.bearing,pitch:o(this,n).Camera.pitch}),o(this,n).Camera.updateFacadesInView()}disable(){if(!o(this,I)){H.warn("disable() called on an already disabled Dynamic Focus instance.");return}d(this,I,!1),o(this,n).manualFloorVisibility=!1}get isEnabled(){return o(this,I)}get isIndoor(){return o(this,N)==="indoor"}get isOutdoor(){return o(this,N)==="outdoor"}setIndoor(){d(this,N,"indoor"),d(this,w,"in-range"),E(this,S,kt).call(this)}setOutdoor(){d(this,N,"outdoor"),d(this,w,"out-of-range"),E(this,S,kt).call(this)}get focusedFacades(){return[...o(this,K)]}getState(){return V({},o(this,c))}updateState(t){var i,r;let e=!1;t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=bt(t.indoorZoomThreshold,(i=t==null?void 0:t.outdoorZoomThreshold)!=null?i:o(this,c).outdoorZoomThreshold,o(this,n).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=bt(t.outdoorZoomThreshold,o(this,n).Camera.minZoomLevel,(r=t==null?void 0:t.indoorZoomThreshold)!=null?r:o(this,c).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=Pt.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(o(this,c).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==o(this,c).dynamicBuildingInteriors&&(e=!0),d(this,c,Object.assign({},o(this,c),Object.fromEntries(Object.entries(t).filter(([,l])=>l!=null)))),t.mode!=null&&t.preloadFloors&&E(this,S,Tt).call(this,t.mode),e&&o(this,j).call(this)}destroy(){this.disable(),o(this,n).off("facades-in-view-change",o(this,it)),o(this,n).off("floor-change-start",o(this,at)),o(this,n).off("camera-change",o(this,z)),o(this,n).off("user-interaction-start",o(this,rt)),o(this,n).off("user-interaction-end",o(this,nt)),o(this,p).forEach(t=>t.destroy()),o(this,B).destroy(),o(this,k).destroy()}async focus(t=o(this,c).setFloorOnFocus){if(t)if(Ct(o(this,W),o(this,n).Camera.elevation,o(this,R)))d(this,W,o(this,n).Camera.elevation),d(this,G,!0);else{let e=It(o(this,C),o(this,B),o(this,w)),i=e?ut(e,o(this,c).mode,o(this,O)):void 0;i&&i.id!==o(this,n).currentFloor.id&&o(this,n).setFloor(i,{context:"dynamic-focus"})}await o(this,j).call(this),o(this,k).publish("focus",{facades:this.focusedFacades})}preloadFloors(){E(this,S,Tt).call(this,o(this,c).mode)}setDefaultFloorForStack(t,e){if(!yt(e,t))return;let i=o(this,p).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,p).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){var e;return((e=o(this,p).get(t.id))==null?void 0:e.defaultFloor)||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!yt(e,t))return;let i=o(this,p).get(t.id);i&&(i.activeFloor=e,o(this,j).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,p).get(i.id);r&&(r.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,p).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){var e;return((e=o(this,p).get(t.id))==null?void 0:e.activeFloor)||this.getDefaultFloorForStack(t)}};k=new WeakMap,n=new WeakMap,Z=new WeakMap,c=new WeakMap,C=new WeakMap,P=new WeakMap,p=new WeakMap,B=new WeakMap,R=new WeakMap,G=new WeakMap,O=new WeakMap,W=new WeakMap,w=new WeakMap,N=new WeakMap,K=new WeakMap,I=new WeakMap,S=new WeakSet,kt=s(function(){o(this,c).autoFocus&&(o(this,R)?this.focus():d(this,G,!0)),o(this,k).publish("state-change")},"#handleViewStateChange"),Tt=s(function(t){o(this,n).preloadFloors(o(this,Z).getByType("facade").map(e=>ut(o(this,p).get(e.floorStack.id),t,o(this,O))).filter(e=>e!=null&&lo.is(e)))},"#preloadFloors"),it=new WeakMap,at=new WeakMap,rt=new WeakMap,nt=new WeakMap,z=new WeakMap,Dt=s(function(t,e,i){t.forEach(r=>{if(r.floor)if(e){let l=i!==void 0?tt(V({},r.state),{labels:tt(V({},r.state.labels),{enabled:r.state.labels.enabled&&i}),markers:tt(V({},r.state.markers),{enabled:r.state.markers.enabled&&i}),occlusion:tt(V({},r.state.occlusion),{enabled:r.state.occlusion.enabled&&i})}):r.state;o(this,n).updateState(r.floor,l)}else o(this,n).updateState(r.floor,{visible:!1})})},"#updateFloorVisibility"),Ut=s(async function(t,e,i,r){return E(this,S,Dt).call(this,e.floorStates,!0,r),t.animateFacade(i.state,o(this,c).indoorAnimationOptions)},"#animateIndoorSequence"),$t=s(async function(t,e,i,r){let l=await t.animateFacade(i.state,o(this,c).outdoorAnimationOptions);return l.result==="completed"&&E(this,S,Dt).call(this,e.floorStates,gt(t,o(this,n).currentFloor,o(this,w)==="in-range",o(this,P).has(t.id),o(this,c).mode,o(this,O),r.includes(t.floorStack.id),o(this,c).dynamicBuildingInteriors)),l},"#animateOutdoorSequence"),j=new WeakMap,s(At,"DynamicFocus");var Yt=At;export{s as a,Yt as b};