@mappedin/dynamic-focus 6.0.1-beta.62 → 6.5.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.
- package/lib/esm/chunk-D4Z7IQAJ.js +1 -0
- package/lib/esm/index.d.ts +848 -20440
- package/lib/esm/index.js +1 -1
- package/lib/esm/react/index.d.ts +862 -20432
- package/lib/esm/react/index.js +1 -1
- package/lib/rn/index-rn.js +2 -2
- package/lib/rn/types.d.ts +1 -2
- package/package.json +4 -4
- package/lib/esm/chunk-YG54MHZY.js +0 -1
package/lib/esm/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,b as a}from"../chunk-
|
|
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};
|
package/lib/rn/index-rn.js
CHANGED
|
@@ -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,j,
|
|
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,jt,Gt,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,jt).call(this,C,P,R,Q);if(nt==="outdoor")return b(this,g,Gt).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"),jt=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"),Gt=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 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);})();
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
// Register the extension
|
package/lib/rn/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Facade, Floor, TFacadeState } from '@mappedin/mappedin-js';
|
|
2
|
-
import type { VisibilityState as BuildingFloorStackState } from '../../mappedin-js/src/api-geojson/multi-floor';
|
|
1
|
+
import type { Facade, Floor, TFacadeState, VisibilityState as BuildingFloorStackState } from '@mappedin/mappedin-js';
|
|
3
2
|
export type MultiFloorVisibilityState = (floors: Floor[], currentFloor: Floor, floorGap: number, floorIdsInNavigation: Floor['id'][], floorsVisualHeightMap?: Map<number, {
|
|
4
3
|
altitude: number;
|
|
5
4
|
effectiveHeight: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mappedin/dynamic-focus",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.5.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.
|
|
41
|
-
"@mappedin/react-native-sdk": "^6.
|
|
42
|
-
"@mappedin/react-sdk": "^6.
|
|
40
|
+
"@mappedin/mappedin-js": "^6.5.0",
|
|
41
|
+
"@mappedin/react-native-sdk": "^6.5.0",
|
|
42
|
+
"@mappedin/react-sdk": "^6.5.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@mappedin/react-sdk": {
|
|
@@ -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 S={env:{NODE_ENV:"production",npm_package_version:"6.0.1-beta.62"}};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 yt(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:S.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(yt,"createLogger");var ao=yt();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 St(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(St,"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=yt("",{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 jt(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(jt,"getOutdoorFloorStack");import{getMultiFloorState as so}from"@mappedin/mappedin-js";var Gt={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,j,O,W,w,N,K,I,y,kt,Tt,it,at,rt,nt,z,Dt,Ut,$t,G,At=class At{constructor(t){u(this,y);u(this,k);u(this,n);u(this,Z);u(this,c,Gt);u(this,C,[]);u(this,P,new Set);u(this,p,new Map);u(this,B);u(this,R,!1);u(this,j,!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,j))){if(d(this,j,!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,G).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,G,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,y,Ut).call(this,D,X,Mt,Ht);if(wt==="outdoor")return E(this,y,$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(jt(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,y,kt).call(this)}setOutdoor(){d(this,N,"outdoor"),d(this,w,"out-of-range"),E(this,y,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,y,Tt).call(this,t.mode),e&&o(this,G).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,j,!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,G).call(this),o(this,k).publish("focus",{facades:this.focusedFacades})}preloadFloors(){E(this,y,Tt).call(this,o(this,c).mode)}setDefaultFloorForStack(t,e){if(!St(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(!St(e,t))return;let i=o(this,p).get(t.id);i&&(i.activeFloor=e,o(this,G).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,j=new WeakMap,O=new WeakMap,W=new WeakMap,w=new WeakMap,N=new WeakMap,K=new WeakMap,I=new WeakMap,y=new WeakSet,kt=s(function(){o(this,c).autoFocus&&(o(this,R)?this.focus():d(this,j,!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,y,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,y,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"),G=new WeakMap,s(At,"DynamicFocus");var Yt=At;export{s as a,Yt as b};
|