@mappedin/dynamic-focus 6.17.1-beta.0 → 6.19.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,2 @@
1
+ var Xo=Object.defineProperty;var ot=r=>{throw TypeError(r)};var Tt=(r,t,e)=>t in r?Xo(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>Xo(r,"name",{value:t,configurable:!0});var y=(r,t,e)=>Tt(r,typeof t!="symbol"?t+"":t,e),Mo=(r,t,e)=>t.has(r)||ot("Cannot "+e);var o=(r,t,e)=>(Mo(r,t,"read from private field"),e?e.call(r):t.get(r)),c=(r,t,e)=>t.has(r)?ot("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),d=(r,t,e,i)=>(Mo(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>(Mo(r,t,"access private method"),e);var S={env:{NODE_ENV:"production",npm_package_version:"6.19.0-beta.0"}};var eo={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},io=.2,Zo=.4;var xo="[MappedinJS]";function Lo(r="",{prefix:t=xo}={}){let e=`${t}${r?`-${r}`:""}`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(m=>m instanceof Error&&m.stack?`${m.message}
2
+ ${m.stack}`:m);window.rnDebug(`${r} ${s}: ${f.join(" ")}`)}},"rnDebug");return{logState:S.env.NODE_ENV==="test"?3:0,log(...s){this.logState<=0&&(console.log(e,...s),i("log",s))},warn(...s){this.logState<=1&&(console.warn(e,...s),i("warn",s))},error(...s){this.logState<=2&&(console.error(e,...s),i("error",s))},assert(...s){console.assert(...s)},time(s){console.time(s)},timeEnd(s){console.timeEnd(s)},setLevel(s){0<=s&&s<=3&&(this.logState=s)}}}a(Lo,"createLogger");var vt=Lo();var W=vt;var k=Lo("",{prefix:"[DynamicFocus]"});var tt=a((r,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Ot(r,e);if(i===void 0)return k.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:eo.indoorZoomThreshold,outdoorZoomThreshold:eo.outdoorZoomThreshold};let s=i+Zo,n=i+io;return e.initialVisibility==="indoor-first"&&(s=i-io,n=i-Zo),{indoorZoomThreshold:s,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Ot(r,t){let i=r.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),s=1/0,n;for(let f of i){let m=r.Camera.getFocusOnTransform(f).zoomLevel??1/0;m<s&&(s=m,n=f)}if(s!==1/0)return t.debug&&n&&r.Camera.getFocusOnTransform(n,{debugColor:"blue"}),s}a(Ot,"getDefaultZoomLevel");import{Floor as Rt,getMultiFloorState as Ut}from"@mappedin/mappedin-js";function et(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}a(et,"arraysEqual");var _o=class _o{_subscribers={};_abortController=new AbortController;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 s=i?.signal;if(s?.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e);let n=a(()=>{this.off(t,e)},"cleanup");return s&&s.addEventListener("abort",n,{once:!0}),n}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(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(_o,"PubSub");var To=_o;import{Facade as Vt,Floor as It,FloorStack as Bt}from"@mappedin/mappedin-js";var I,so,C,v,T,A,H,K,No=class No{constructor(t,e){y(this,"__type","building");c(this,I);c(this,so,new Map);c(this,C,new Map);c(this,v,[]);c(this,T);c(this,A);y(this,"defaultFloor");y(this,"activeFloor");y(this,"excluded",!1);y(this,"floorsAltitudesMap",new Map);y(this,"aboveGroundFloors",[]);c(this,H);c(this,K);d(this,I,t),d(this,so,new Map(t.floors.map(s=>[s.id,s]))),d(this,C,new Map(t.floors.map(s=>[s.elevation,s]))),d(this,v,Array.from(o(this,C).values()).sort((s,n)=>s.elevation-n.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,d(this,T,e),this.aboveGroundFloors=o(this,v).filter(s=>s.elevation>=0);let i=t.facade?.spaces.map(s=>o(this,T).getState(s)).sort((s,n)=>s.altitude-n.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let s in this.aboveGroundFloors){let n=this.aboveGroundFloors[s],f=i[s];this.floorsAltitudesMap.set(n.elevation,{altitude:f.altitude,visualHeight:f.height})}}get id(){return o(this,I).id}get name(){return o(this,I).name}get floors(){return o(this,I).floors}get floorStack(){return o(this,I)}get facade(){return o(this,I).facade}get isCurrentFloorStack(){return this.id===o(this,T).currentFloorStack.id}get isIndoor(){let t=o(this,T).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,H)==null&&d(this,H,Math.max(...o(this,C).keys())),o(this,H)}get minElevation(){return o(this,K)==null&&d(this,K,Math.min(...o(this,C).keys())),o(this,K)}has(t){return It.is(t)?o(this,so).has(t.id):Bt.is(t)?t.id===o(this,I).id:Vt.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,C).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 s=o(this,v)[i];if(s.elevation<=t)return s}}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,A)&&(o(this,A).animation.cancel(),d(this,A,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,A)?.state||o(this,T).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:s,visible:n}=t;if(o(this,T).updateState(this.facade,{visible:!0}),s!==void 0){d(this,A,{animation:o(this,T).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let f=await o(this,A).animation;if(d(this,A,void 0),f.result==="cancelled")return f}return n===!1&&o(this,T).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,I).floors.forEach(t=>{o(this,T).updateState(t,{visible:t.id===o(this,T).currentFloor.id})}),this.has(o(this,T).currentFloor)||o(this,T).updateState(this.facade,{visible:!0,opacity:1})}};I=new WeakMap,so=new WeakMap,C=new WeakMap,v=new WeakMap,T=new WeakMap,A=new WeakMap,H=new WeakMap,K=new WeakMap,a(No,"Building");var wo=No;function it(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(it,"getZoomState");function vo(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}a(vo,"getFloorToShow");function kt(r,t,e,i){return i?{facade:r,state:{type:"facade",visible:!1,opacity:0}}: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}}}a(kt,"getFacadeState");function At(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}}}})}}a(At,"getSingleBuildingState");function st(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"}a(st,"getOutdoorOpacity");function rt(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}}a(rt,"getSetFloorTargetFromZoomState");function nt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:f,floorIdsInNavigation:m,floorStackIdsInNavigation:h,multiFloorView:g,getMultiFloorState:j,dynamicBuildingInteriors:V,isolateBelowGroundView:q,currentElevation:bo,forceInteriorsVisible:to,getFloorStackAltitudeData:yo}=r,So=new Map,ko=q&&bo<0&&s==="in-range";for(let b of t){let Jo=e.has(b.id),Eo=ko&&b.minElevation>=0,bt=Eo?!1:Jo,Ao=Eo?!1:Co({building:b,currentFloor:i,inRange:s==="in-range",inFocus:Jo,mode:n,elevation:f,inNavigation:h.includes(b.id),dynamicBuildingInteriors:V,forceInteriorsVisible:to}),Do=i.floorStack.id===b.id?b.activeFloor:vo(b,n,f),yt=g?.enabled?j(b.floors,Do||b.activeFloor,m,yo?.(b.id)??b.floorsAltitudesMap,{color:g?.footprintColor,spacesOpenToBelowEnabled:g?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:g?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:g?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:g?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:g?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:g?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:g?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:g?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:g?.footprintOpacity,outline:g?.footprintOutline}):At(b.floorStack,Do||b.activeFloor,Ao),St=q&&bo<0&&s==="in-range",Et=kt(b.facade,Ao,St,Eo);So.set(b.id,{building:b,showIndoor:Ao,floorStackState:yt,facadeState:Et,inFocus:bt,floorToShow:Do,isAboveGroundInIsolation:Eo})}return So}a(nt,"getBuildingStates");function at(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(at,"getBuildingAnimationType");function Co(r){let{building:t,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:f,inNavigation:m,dynamicBuildingInteriors:h,forceInteriorsVisible:g}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(g===!0||m===!0)return!0;if(!h)return e.floorStack.type!=="Outdoor";if(!i||!s)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(f)!=null;default:break}return!0}a(Co,"shouldShowIndoor");function lt(r,t,e){return r!==t&&!e}a(lt,"shouldDeferSetFloor");var ut=["default-floor","lock-elevation","nearest-elevation"];import{Floor as Dt,FloorStack as Mt}from"@mappedin/mappedin-js";function dt(r,t,e,i){return(r<t||r>e)&&W.warn(i),Math.min(e,Math.max(t,r))}a(dt,"clampWithWarning");function Go(r,t){return!Dt.is(r)||r?.floorStack==null||!Mt.is(t)?!1:r.floorStack.id!==t.id?(W.warn(`Floor (${r.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(Go,"validateFloorForStack");function Po(r,t,e,i){return dt(r,t,e,`${i} must be between ${t} and ${e}.`)}a(Po,"validateZoomThreshold");var D,Q,ro,Ro,Uo=class Uo{constructor(t,e){c(this,ro);y(this,"__type","outdoors");c(this,D);c(this,Q);d(this,D,t),d(this,Q,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(){F(this,ro,Ro).call(this,!0)}hide(){F(this,ro,Ro).call(this,!1)}destroy(){this.matchesFloorStack(o(this,Q).currentFloorStack)||this.hide()}};D=new WeakMap,Q=new WeakMap,ro=new WeakSet,Ro=a(function(t){for(let e of o(this,D).floors)o(this,Q).updateState(e,{visible:t})},"#setVisible"),a(Uo,"Outdoors");var Oo=Uo;function ct(r,t){let e=r.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let s=e.find(n=>n.facade==null&&!t.has(n.id));return s||(k.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(ct,"getOutdoorFloorStack");function Zt(r,t){return`${t} ${r}`}a(Zt,"formatMessage");var jo=class jo extends Error{constructor(t,e=xo){super(Zt(t,e)),this.name="MappedinError"}};a(jo,"MappedinError");var Vo=jo;var xt=a(r=>r,"linearEase"),Lt=a(r=>r*r,"quadEaseIn"),_t=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Nt=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Ct=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),Gt={linear:xt,"ease-in":Lt,"ease-out":Nt,"ease-in-out":_t,"ease-out-cubic":Ct};function Pt(r,t){let e=0;if(t.length<2)return e;let s=t[0]<t[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<t.length-1&&s(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Pt,"getInterpolationBreakpoint");function ht(r,t,e,i="ease-in"){if(t.length!==e.length)throw new Vo("Input and output ranges must have the same number of values.");r=Math.max(t[0],Math.min(r,t[t.length-1]));let s=Pt(r,t),n=(r-t[s])/(t[s+1]-t[s]),f=typeof i=="function"?i(n):Gt[i](n);return e[s]+f*(e[s+1]-e[s])}a(ht,"interpolateMulti");var M,no,ao,x,lo,$o=class $o{constructor(t,e,i){y(this,"layers");y(this,"visible");c(this,M);c(this,no,[]);c(this,ao,!1);c(this,x,new Map);y(this,"interpolationFn");c(this,lo,1);this.layers=t,this.visible=e,d(this,M,i)}processLayerGroup(t,e){o(this,ao)||(this.layers.forEach(i=>{let s=t[i];s&&o(this,no).push(...s)}),d(this,ao,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:s,indoorZoomThreshold:n}=e();return ht(i,[s,n],[1,0])}))}setOpacity(t){d(this,lo,t);for(let e of o(this,no))if(e.startsWith("img_")){let i=o(this,M).Image3D.getById(e);if(i){let s=o(this,M).getState(i.image);o(this,x).has(e)||o(this,x).set(e,s?.opacity??1);let n=Math.min(o(this,x).get(e),t);o(this,M).updateState(i.image,{opacity:n})}}else{let i=o(this,M).getMapData()?.getById("space",e);if(!i)continue;let s=o(this,M).getState(i);o(this,x).has(e)||o(this,x).set(e,s?.opacity??1);let n=Math.min(o(this,x).get(e),t);o(this,M).updateState(i,{opacity:n,visible:n>0})}}get opacity(){return o(this,lo)}};M=new WeakMap,no=new WeakMap,ao=new WeakMap,x=new WeakMap,lo=new WeakMap,a($o,"LayerGroup");var Io=$o;function zo(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(zo,"runLayerGroupInterpolations");var O,l,G,u,z,$,E,L,Y,_,w,J,uo,co,ho,Z,P,X,N,R,U,p,Yo,mt,qo,Wo,Ho,pt,Ko,fo,mo,po,go,Fo,oo,Bo,gt,Ft,B,Qo=class Qo{constructor(t){c(this,p);c(this,O);c(this,l);c(this,G);c(this,u,eo);c(this,z,[]);c(this,$,new Set);c(this,E,new Map);c(this,L);c(this,Y,!1);c(this,_,!1);c(this,w,0);c(this,J,0);c(this,uo,[]);c(this,co,{});c(this,ho,{});c(this,Z,"transition");c(this,P,"outdoor");c(this,X,[]);c(this,N,!1);c(this,R,[]);c(this,U,null);y(this,"sceneUpdateQueue",Promise.resolve());y(this,"on",a((t,e)=>{o(this,O).on(t,e)},"on"));y(this,"off",a((t,e)=>{o(this,O).off(t,e)},"off"));c(this,fo,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(et(e,this.focusedFacades)&&o(this,P)==="transition"&&!o(this,_))return;d(this,_,!1),d(this,z,[]),o(this,$).clear();let i=o(this,u).isolateBelowGroundView&&o(this,w)<0;if(e.length>0)for(let s of e){let n=o(this,E).get(s.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;o(this,$).add(n.id),o(this,z).push(n)}}o(this,u).autoFocus&&this.focus()},"#handleFacadesInViewChange"));c(this,mo,a(async t=>{if(!this.isEnabled)return;let{floor:e}=t,i=o(this,E).get(e.floorStack.id);i&&(i.activeFloor=e);let s=o(this,u).isolateBelowGroundView&&o(this,w)<0;i?.excluded===!1&&!o(this,L).matchesFloorStack(e.floorStack)&&d(this,w,e.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,w)<0,f=s&&!n;if(o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(f?(d(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||(await o(this,B).call(this,e),o(this,O).publish("focus",{facades:this.focusedFacades}))):(await o(this,B).call(this,e),o(this,O).publish("focus",{facades:this.focusedFacades})));let m=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!==m&&o(this,l).Camera.animateElevation(m,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));c(this,po,a(()=>{d(this,Y,!0)},"#handleUserInteractionStart"));c(this,go,a(()=>{d(this,Y,!1)},"#handleUserInteractionEnd"));c(this,Fo,a(()=>{o(this,B).call(this)},"#handleGlobalStateChange"));c(this,oo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=it(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,Z)!==i&&(d(this,Z,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),zo(o(this,R),e)},"#handleCameraChange"));c(this,B,a(async t=>{if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,s=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(h=>h.id)||[],f=o(this,l).Navigation?.floorStacks.map(h=>h.id)||[],m=new Promise(async h=>{await this.sceneUpdateQueue;let g=nt({buildings:Array.from(o(this,E).values()),inViewSet:o(this,$),currentFloor:e,zoomState:o(this,Z),mode:o(this,u).mode,elevation:o(this,w),floorIdsInNavigation:n,floorStackIdsInNavigation:f,multiFloorView:s,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Ut,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,w),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(V=>o(this,l).getFloorStackAltitudeData(V),"getFloorStackAltitudeData")}),j=[];await Promise.all(Array.from(g.values()).map(async V=>{let{building:q,showIndoor:bo,floorStackState:to,facadeState:yo,inFocus:So,isAboveGroundInIsolation:ko}=V;j.push(to);let b=at(q,bo);if(b==="indoor")return F(this,p,gt).call(this,q,to,yo,So);if(b==="outdoor")return F(this,p,Ft).call(this,q,to,yo,f,ko)})),o(this,l).Outdoor.setOpacity(st(j,o(this,u).mode)),d(this,X,o(this,z).filter(V=>g.get(V.id)?.showIndoor===!0).map(V=>V.facade)),o(this,O).publish("focus",{facades:o(this,X)}),h()});return this.sceneUpdateQueue=m,m},"#applyBuildingStates"));d(this,O,new To),d(this,l,t),k.setLevel(W.logState),d(this,G,o(this,l).getMapData()),d(this,w,o(this,l).currentFloor.elevation),d(this,J,o(this,l).Camera.elevation);for(let e of o(this,G).getByType("facade"))o(this,E).set(e.floorStack.id,new wo(e.floorStack,o(this,l)));F(this,p,pt).call(this),d(this,L,new Oo(ct(o(this,G),o(this,E)),o(this,l))),o(this,l).on("floor-change-start",o(this,mo)),o(this,l).on("camera-change",o(this,oo)),o(this,l).on("facades-in-view-change",o(this,fo)),o(this,l).on("user-interaction-start",o(this,po)),o(this,l).on("user-interaction-end",o(this,go)),o(this,l).on("global-state-change",o(this,Fo))}enable(t){if(o(this,N)){k.warn("enable() called on an already enabled Dynamic Focus instance.");return}d(this,N,!0),o(this,l).manualFloorVisibility=!0,o(this,L).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&k.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,p,mt).call(this),o(this,oo).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,N)){k.warn("disable() called on an already disabled Dynamic Focus instance.");return}d(this,N,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,N)}get isIndoor(){return o(this,P)==="indoor"}get isOutdoor(){return o(this,P)==="outdoor"}get outdoorsFloorStack(){return o(this,L).floorStack}get layers(){return o(this,uo)}get layersBySpaceId(){return o(this,co)}setIndoor(){d(this,P,"indoor"),d(this,Z,"in-range"),F(this,p,Yo).call(this)}setOutdoor(){d(this,P,"outdoor"),d(this,Z,"out-of-range"),F(this,p,Yo).call(this)}get focusedFacades(){return[...o(this,X)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,s=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,w)<0,f=!!o(this,u).autoZoomThresholds,m=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:f,h=t;if(m&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){k.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:j,...V}=h;h=V}if(!f&&m?(d(this,U,()=>{if(!o(this,N))return;let g=o(this,u).indoorZoomThreshold,j=o(this,u).outdoorZoomThreshold;F(this,p,Wo).call(this),F(this,p,Ho).call(this,g,j),o(this,B).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,U))):f&&!m&&F(this,p,qo).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=Po(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=Po(h.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,h?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),h.mode!=null&&(h.mode=ut.includes(h.mode)?h.mode:"default-floor"),h.autoAdjustFacadeHeights!=null&&(o(this,u).autoAdjustFacadeHeights=h.autoAdjustFacadeHeights),h.dynamicBuildingInteriors!=null&&h.dynamicBuildingInteriors!==o(this,u).dynamicBuildingInteriors&&(e=!0),h.isolateBelowGroundView!=null&&h.isolateBelowGroundView!==o(this,u).isolateBelowGroundView&&(e=!0),h.forceInteriorsVisible!=null&&h.forceInteriorsVisible!==o(this,u).forceInteriorsVisible&&(e=!0),h.showLabelsAndMarkersOnAllVisibleFloors!=null&&h.showLabelsAndMarkersOnAllVisibleFloors!==o(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),m&&h.autoZoomThresholds!==void 0&&(F(this,p,Wo).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,p,Ko).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,w)<0;n&&!g?(d(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||o(this,B).call(this)):o(this,B).call(this)}F(this,p,Ho).call(this,i,s)}destroy(){this.disable(),F(this,p,qo).call(this),o(this,l).off("facades-in-view-change",o(this,fo)),o(this,l).off("floor-change-start",o(this,mo)),o(this,l).off("camera-change",o(this,oo)),o(this,l).off("user-interaction-start",o(this,po)),o(this,l).off("user-interaction-end",o(this,go)),o(this,l).off("global-state-change",o(this,Fo)),o(this,E).forEach(t=>t.destroy()),o(this,L).destroy(),o(this,O).destroy(),d(this,R,[])}async focus(t=o(this,u).setFloorOnFocus){if(t)if(lt(o(this,J),o(this,l).Camera.elevation,o(this,Y)))d(this,J,o(this,l).Camera.elevation),d(this,_,!0);else{let e=rt(o(this,z),o(this,L),o(this,Z)),i=e?vo(e,o(this,u).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,B).call(this),o(this,O).publish("focus",{facades:this.focusedFacades})}preloadFloors(){F(this,p,Ko).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!Go(e,t))return;let i=o(this,E).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,E).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){return o(this,E).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Go(e,t))return;let i=o(this,E).get(t.id);i&&(i.activeFloor=e,o(this,B).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,E).get(i.id);s&&(s.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,E).get(i.id);s&&(s.excluded=!1)}}getCurrentFloorForStack(t){return o(this,E).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};O=new WeakMap,l=new WeakMap,G=new WeakMap,u=new WeakMap,z=new WeakMap,$=new WeakMap,E=new WeakMap,L=new WeakMap,Y=new WeakMap,_=new WeakMap,w=new WeakMap,J=new WeakMap,uo=new WeakMap,co=new WeakMap,ho=new WeakMap,Z=new WeakMap,P=new WeakMap,X=new WeakMap,N=new WeakMap,R=new WeakMap,U=new WeakMap,p=new WeakSet,Yo=a(function(){o(this,u).autoFocus&&(o(this,Y)?this.focus():d(this,_,!0)),o(this,O).publish("state-change")},"#handleViewStateChange"),mt=a(function(){d(this,R,[]);for(let t of o(this,u).dynamicLayers){let e=new Io([t],!0,o(this,l));e.processLayerGroup(o(this,ho),()=>o(this,u)),o(this,R).push(e)}zo(o(this,R),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),qo=a(function(){o(this,U)&&(o(this,l).off("camera-screen-offsets-change",o(this,U)),d(this,U,null))},"#unsubscribeScreenOffsets"),Wo=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:s}=tt(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=s,(e.expandMinZoom??!0)&&s<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(s-io)},"#recalcThresholds"),Ho=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,O).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),pt=a(function(){let t=o(this,G).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(s=>{e[s.name]||(e[s.name]=[]),e[s.name].push(...s.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of s.spaces)i[n]==null&&(i[n]=[]),i[n].push(s.name)}),d(this,uo,t.map(({name:s})=>s)),d(this,co,i),d(this,ho,e)},"#setupLayers"),Ko=a(function(t){o(this,l).preloadFloors(o(this,G).getByType("facade").map(e=>vo(o(this,E).get(e.floorStack.id),t,o(this,w))).filter(e=>e!=null&&Rt.is(e)))},"#preloadFloors"),fo=new WeakMap,mo=new WeakMap,po=new WeakMap,go=new WeakMap,Fo=new WeakMap,oo=new WeakMap,Bo=a(function(t,e,i,s=!1){t.forEach(n=>{if(n.floor)if(e){let m=i!==void 0&&!s?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,m)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),gt=a(async function(t,e,i,s){return F(this,p,Bo).call(this,e.floorStates,!0,s,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Ft=a(async function(t,e,i,s,n){let f=n;f&&F(this,p,Bo).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let m=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return m.result==="completed"&&!f&&F(this,p,Bo).call(this,e.floorStates,Co({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,Z)==="in-range",inFocus:o(this,$).has(t.id),mode:o(this,u).mode,elevation:o(this,w),inNavigation:s.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),m},"#animateOutdoorSequence"),B=new WeakMap,a(Qo,"DynamicFocus");var ft=Qo;export{a,tt as b,ft as c};
@@ -1,5 +1,66 @@
1
1
  import { Facade, Floor, FloorStack, FootprintConfig, MapView, TFloorAltitudeData, VisibilityState as BuildingFloorStackState } from "@mappedin/mappedin-js";
2
2
 
3
+ //#region src/zoom-thresholds.d.ts
4
+
5
+ /**
6
+ * Options for {@link calculateZoomThresholds}.
7
+ */
8
+ type CalculateZoomThresholdsOptions = {
9
+ /**
10
+ * Determines which view is considered the starting point when computing thresholds.
11
+ * - 'indoor-first' (default): thresholds are placed slightly BELOW the base zoom level so that
12
+ * zooming out reveals outdoor content after passing the offsets.
13
+ * - 'outdoor-first': thresholds are placed slightly ABOVE the base zoom level
14
+ * so that zooming in reveals indoor content after passing the offsets.
15
+ */
16
+ initialVisibility?: 'indoor-first' | 'outdoor-first';
17
+ /**
18
+ * When true, visualizes the winning zoom threshold target via `getFocusOnTransform`
19
+ * debug overlays (point cloud + camera-space OBB). Only the winning target is
20
+ * visualized to avoid cluttering the debug view.
21
+ */
22
+ debug?: boolean;
23
+ /**
24
+ * When true, automatically lowers `Camera.minZoomLevel` if it would prevent
25
+ * the camera from reaching the outdoor zoom threshold.
26
+ * A buffer of {@link OUTDOOR_ZOOM_OFFSET} is applied below the threshold.
27
+ * @default true
28
+ */
29
+ expandMinZoom?: boolean;
30
+ };
31
+ /**
32
+ * Computes indoor and outdoor zoom thresholds for transitioning between map views.
33
+ *
34
+ * The base zoom level is determined by the minimum zoom across all indoor building floor-stacks
35
+ * (altitude-aware, accounting for the full 3D volume of each building). If no indoor floor stacks
36
+ * exist, hardcoded defaults (18/17) are returned with a logged error.
37
+ *
38
+ * Fixed offsets are then applied above or below this base depending on
39
+ * {@link CalculateZoomThresholdsOptions.initialVisibility | initialVisibility}.
40
+ *
41
+ * @param mapView - The active MapView instance.
42
+ * @param userOptions - Optional threshold configuration.
43
+ * @returns `{ indoorZoomThreshold, outdoorZoomThreshold }` — zoom levels at which
44
+ * the scene should transition between indoor and outdoor presentation.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const { indoorZoomThreshold, outdoorZoomThreshold } = calculateZoomThresholds(mapView);
49
+ *
50
+ * const dynamicFocus = new DynamicFocus(mapView, {
51
+ * indoorZoomThreshold,
52
+ * outdoorZoomThreshold,
53
+ * });
54
+ * ```
55
+ *
56
+ * @see {@link CalculateZoomThresholdsOptions} for all configuration options.
57
+ * @deprecated Use the {@link DynamicFocusState.autoZoomThresholds | autoZoomThresholds} option in DynamicFocus state instead.
58
+ */
59
+ declare const calculateZoomThresholds: (mapView: MapView, userOptions?: CalculateZoomThresholdsOptions) => {
60
+ indoorZoomThreshold: number;
61
+ outdoorZoomThreshold: number;
62
+ };
63
+ //#endregion
3
64
  //#region src/types.d.ts
4
65
  type MultiFloorVisibilityState = (floors: Floor[], currentFloor: Floor, floorIdsInNavigation: Floor['id'][], floorsVisualHeightMap: Map<number, TFloorAltitudeData>, footprintConfig?: Partial<FootprintConfig>) => BuildingFloorStackState;
5
66
  type DynamicFocusAnimationOptions = {
@@ -40,7 +101,7 @@ type DynamicFocusState = {
40
101
  * The zoom level at which the camera will fade in the facades and fade out the indoor floors.
41
102
  * @default 17
42
103
  */
43
- outdoorZoomThreshold?: number;
104
+ outdoorZoomThreshold: number;
44
105
  /**
45
106
  * Whether to set the floor to the outdoors when the camera moves in range.
46
107
  * @default true
@@ -107,6 +168,22 @@ type DynamicFocusState = {
107
168
  * @default false
108
169
  */
109
170
  showLabelsAndMarkersOnAllVisibleFloors: boolean;
171
+ /**
172
+ * Automatically calculates zoom thresholds using {@link calculateZoomThresholds} and
173
+ * recalculates whenever screen offsets change. When enabled, manual `indoorZoomThreshold`
174
+ * and `outdoorZoomThreshold` values are ignored with a console warning.
175
+ *
176
+ * When enabled, `Camera.minZoomLevel` is automatically lowered if it would prevent
177
+ * the camera from reaching the outdoor zoom threshold (see {@link CalculateZoomThresholdsOptions.expandMinZoom | expandMinZoom},
178
+ * defaults to `true`). Pass `{ expandMinZoom: false }` to opt out.
179
+ *
180
+ * - `true` — enable with default options
181
+ * - `CalculateZoomThresholdsOptions` — enable with custom options (e.g. `{ debug: true }`)
182
+ * - `false` — disable (default)
183
+ *
184
+ * @default false
185
+ */
186
+ autoZoomThresholds: boolean | CalculateZoomThresholdsOptions;
110
187
  };
111
188
  /**
112
189
  * Events emitted by the Dynamic Focus controller.
@@ -118,6 +195,13 @@ type DynamicFocusEvents = {
118
195
  focus: {
119
196
  facades: Facade[];
120
197
  };
198
+ /**
199
+ * Emitted when zoom thresholds change, either from manual `updateState()` calls or automatic recalculation via `autoZoomThresholds`.
200
+ */
201
+ 'zoom-threshold-change': {
202
+ indoorZoomThreshold: number;
203
+ outdoorZoomThreshold: number;
204
+ };
121
205
  };
122
206
  type DynamicFocusEventPayload<EventName extends keyof DynamicFocusEvents> = DynamicFocusEvents[EventName] extends {
123
207
  data: null;
@@ -696,7 +780,6 @@ type Merge<Destination, Source> = Destination extends unknown // For distributin
696
780
  : never;
697
781
  //#endregion
698
782
  //#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/internal/object.d.ts
699
-
700
783
  /**
701
784
  Merges user specified options with default options.
702
785
 
@@ -973,7 +1056,7 @@ declare class DynamicFocus implements MapViewExtension<DynamicFocusState> {
973
1056
  * Updates the state of the Dynamic Focus controller.
974
1057
  * @param state - The state to update.
975
1058
  */
976
- updateState(state: Partial<DynamicFocusState>): void;
1059
+ updateState(incomingState: Partial<DynamicFocusState>): void;
977
1060
  /**
978
1061
  * Destroys the Dynamic Focus instance and unsubscribes all MapView event listeners.
979
1062
  */
@@ -1028,41 +1111,4 @@ declare class DynamicFocus implements MapViewExtension<DynamicFocusState> {
1028
1111
  getCurrentFloorForStack(floorStack: FloorStack): Floor;
1029
1112
  }
1030
1113
  //#endregion
1031
- //#region src/zoom-thresholds.d.ts
1032
- /**
1033
- * Options for {@link calculateZoomThresholds}.
1034
- */
1035
- type CalculateZoomThresholdsOptions = {
1036
- /**
1037
- * Determines which view is considered the starting point when computing thresholds.
1038
- * - 'outdoor-first' (default): thresholds are placed slightly ABOVE the base zoom level
1039
- * so that zooming in reveals indoor content after passing the offsets.
1040
- * - 'indoor-first': thresholds are placed slightly BELOW the base zoom level so that
1041
- * zooming out reveals outdoor content after passing the offsets.
1042
- */
1043
- initialVisibility?: 'indoor-first' | 'outdoor-first';
1044
- /**
1045
- * A list of layer names that represent the primary focus for indoor content. When provided,
1046
- * the base zoom level will prefer the camera transform that focuses on spaces which belong
1047
- * to these layers (see {@link layersBySpaceId}) on the {@link defaultFloor}. If not provided
1048
- * or if no spaces match, the base zoom level falls back to the {@link defaultFloor} focus.
1049
- */
1050
- focusLayers?: string[];
1051
- /**
1052
- * A mapping of Space.id to the list of layer names that space belongs to. This is used to
1053
- * determine which spaces are part of the {@link focusLayers} set. Only spaces on the
1054
- * {@link defaultFloor} are considered when selecting the preferred base zoom level.
1055
- */
1056
- layersBySpaceId?: Record<string, string[]>;
1057
- /**
1058
- * The floor used when computing the default base zoom level in absence of matching
1059
- * {@link focusLayers}. Defaults to the MapView's currentFloor.
1060
- */
1061
- defaultFloor?: Floor;
1062
- };
1063
- declare const calculateZoomThresholds: (mapView: MapView, userOptions: CalculateZoomThresholdsOptions) => {
1064
- indoorZoomThreshold: number;
1065
- outdoorZoomThreshold: number;
1066
- };
1067
- //#endregion
1068
1114
  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{a as f,b as u,c as y,d as F}from"./chunk-FOQKL4S4.js";var O=f((t,e)=>{var n,c,s,o;let l={initialVisibility:(n=e.initialVisibility)!=null?n:"outdoor-first",layersBySpaceId:(c=e.layersBySpaceId)!=null?c:{},focusLayers:(s=e.focusLayers)!=null?s:[],defaultFloor:(o=e.defaultFloor)!=null?o:t.currentFloor},i=T(t,l),r=i+y,a=i+u;return l.initialVisibility==="indoor-first"&&(r=i-u,a=i-y),{indoorZoomThreshold:r,outdoorZoomThreshold:a}},"calculateZoomThresholds");function T(t,e){var a,n;let l=t.getMapData();if(e.focusLayers.length){let s=l.getByType("space").filter(o=>{var d,p;let m=(d=e.layersBySpaceId[o.id])==null?void 0:d[0];return typeof m=="string"&&o.floor.id===((p=e.defaultFloor)==null?void 0:p.id)&&e.focusLayers.indexOf(m)!==-1});if(s.length){let o=t.Camera.getFocusOnTransform(s,{}).zoomLevel;if(o!==void 0)return o}}let i=l.getByType("floor-stack"),r=1/0;for(let c of i)for(let s of c.floors){let o=(a=t.Camera.getFocusOnTransform(s,{}).zoomLevel)!=null?a:1/0;o<r&&(r=o)}return r!==1/0?r:(n=t.Camera.getFocusOnTransform(e.defaultFloor,{}).zoomLevel)!=null?n:0}f(T,"getDefaultZoomLevel");export{F as DynamicFocus,O as calculateZoomThresholds};
1
+ import{b as o,c as t}from"./chunk-FOQNAZDG.js";export{t as DynamicFocus,o as calculateZoomThresholds};
@@ -1,5 +1,34 @@
1
1
  import { Facade, Floor, FloorStack, FootprintConfig, MapView, TFloorAltitudeData, VisibilityState as BuildingFloorStackState } from "@mappedin/mappedin-js";
2
2
 
3
+ //#region src/zoom-thresholds.d.ts
4
+
5
+ /**
6
+ * Options for {@link calculateZoomThresholds}.
7
+ */
8
+ type CalculateZoomThresholdsOptions = {
9
+ /**
10
+ * Determines which view is considered the starting point when computing thresholds.
11
+ * - 'indoor-first' (default): thresholds are placed slightly BELOW the base zoom level so that
12
+ * zooming out reveals outdoor content after passing the offsets.
13
+ * - 'outdoor-first': thresholds are placed slightly ABOVE the base zoom level
14
+ * so that zooming in reveals indoor content after passing the offsets.
15
+ */
16
+ initialVisibility?: 'indoor-first' | 'outdoor-first';
17
+ /**
18
+ * When true, visualizes the winning zoom threshold target via `getFocusOnTransform`
19
+ * debug overlays (point cloud + camera-space OBB). Only the winning target is
20
+ * visualized to avoid cluttering the debug view.
21
+ */
22
+ debug?: boolean;
23
+ /**
24
+ * When true, automatically lowers `Camera.minZoomLevel` if it would prevent
25
+ * the camera from reaching the outdoor zoom threshold.
26
+ * A buffer of {@link OUTDOOR_ZOOM_OFFSET} is applied below the threshold.
27
+ * @default true
28
+ */
29
+ expandMinZoom?: boolean;
30
+ };
31
+ //#endregion
3
32
  //#region src/types.d.ts
4
33
  type MultiFloorVisibilityState = (floors: Floor[], currentFloor: Floor, floorIdsInNavigation: Floor['id'][], floorsVisualHeightMap: Map<number, TFloorAltitudeData>, footprintConfig?: Partial<FootprintConfig>) => BuildingFloorStackState;
5
34
  type DynamicFocusAnimationOptions = {
@@ -40,7 +69,7 @@ type DynamicFocusState = {
40
69
  * The zoom level at which the camera will fade in the facades and fade out the indoor floors.
41
70
  * @default 17
42
71
  */
43
- outdoorZoomThreshold?: number;
72
+ outdoorZoomThreshold: number;
44
73
  /**
45
74
  * Whether to set the floor to the outdoors when the camera moves in range.
46
75
  * @default true
@@ -107,6 +136,22 @@ type DynamicFocusState = {
107
136
  * @default false
108
137
  */
109
138
  showLabelsAndMarkersOnAllVisibleFloors: boolean;
139
+ /**
140
+ * Automatically calculates zoom thresholds using {@link calculateZoomThresholds} and
141
+ * recalculates whenever screen offsets change. When enabled, manual `indoorZoomThreshold`
142
+ * and `outdoorZoomThreshold` values are ignored with a console warning.
143
+ *
144
+ * When enabled, `Camera.minZoomLevel` is automatically lowered if it would prevent
145
+ * the camera from reaching the outdoor zoom threshold (see {@link CalculateZoomThresholdsOptions.expandMinZoom | expandMinZoom},
146
+ * defaults to `true`). Pass `{ expandMinZoom: false }` to opt out.
147
+ *
148
+ * - `true` — enable with default options
149
+ * - `CalculateZoomThresholdsOptions` — enable with custom options (e.g. `{ debug: true }`)
150
+ * - `false` — disable (default)
151
+ *
152
+ * @default false
153
+ */
154
+ autoZoomThresholds: boolean | CalculateZoomThresholdsOptions;
110
155
  };
111
156
  /**
112
157
  * Events emitted by the Dynamic Focus controller.
@@ -118,6 +163,13 @@ type DynamicFocusEvents = {
118
163
  focus: {
119
164
  facades: Facade[];
120
165
  };
166
+ /**
167
+ * Emitted when zoom thresholds change, either from manual `updateState()` calls or automatic recalculation via `autoZoomThresholds`.
168
+ */
169
+ 'zoom-threshold-change': {
170
+ indoorZoomThreshold: number;
171
+ outdoorZoomThreshold: number;
172
+ };
121
173
  };
122
174
  type DynamicFocusEventPayload<EventName extends keyof DynamicFocusEvents> = DynamicFocusEvents[EventName] extends {
123
175
  data: null;
@@ -973,7 +1025,7 @@ declare class DynamicFocus implements MapViewExtension<DynamicFocusState> {
973
1025
  * Updates the state of the Dynamic Focus controller.
974
1026
  * @param state - The state to update.
975
1027
  */
976
- updateState(state: Partial<DynamicFocusState>): void;
1028
+ updateState(incomingState: Partial<DynamicFocusState>): void;
977
1029
  /**
978
1030
  * Destroys the Dynamic Focus instance and unsubscribes all MapView event listeners.
979
1031
  */
@@ -1 +1 @@
1
- import{a as t,d as a}from"../chunk-FOQKL4S4.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,c as a}from"../chunk-FOQNAZDG.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?.off(n,e)}},[o,n,e])}t(x,"useDynamicFocusEvent");export{i as useDynamicFocus,x as useDynamicFocusEvent};
@@ -0,0 +1,14 @@
1
+ import type { RequiredDeep } from 'type-fest';
2
+ import type { DynamicFocusState } from './types';
3
+ export declare const DEFAULT_STATE: RequiredDeep<Omit<DynamicFocusState, 'customMultiFloorVisibilityState'>>;
4
+ /**
5
+ * Controls building visibility transition point. Small value (0.2) ensures smooth transition between indoor/outdoor views without
6
+ * freezing elements in semi-transparent state. Based on value from appolo-v2.
7
+ */
8
+ export declare const OUTDOOR_ZOOM_OFFSET = 0.2;
9
+ /**
10
+ * Controls indoor elements visibility transition point. Small value (0.4) ensures smooth transition between indoor/outdoor views without
11
+ * freezing elements in semi-transparent state. Twice the building offset for clear
12
+ * separation. Based on value from appolo-v2.
13
+ */
14
+ export declare const INDOOR_ZOOM_OFFSET = 0.4;
@@ -1,5 +1,5 @@
1
- var D=Object.defineProperty,l=(e,i)=>D(e,"name",{value:i,configurable:!0});import{useState as x,useCallback as c,useContext as T,useRef as A}from"react";import{MappedinContext as C}from"@mappedin/react-native-sdk";import{useCallback as W,useContext as L}from"react";var _="[MappedinJS]";function g(e="",{prefix:i=_}={}){const o=`${i}${e?`-${e}`:""}`,s=l((t,h)=>{if(typeof window<"u"&&window.rnDebug){const f=h.map(r=>r instanceof Error&&r.stack?`${r.message}
2
- ${r.stack}`:r);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:0,log(...t){this.logState<=0&&(console.log(o,...t),s("log",t))},warn(...t){this.logState<=1&&(console.warn(o,...t),s("warn",t))},error(...t){this.logState<=2&&(console.error(o,...t),s("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(),F=g("",{prefix:"[DynamicFocus]"});import{MappedinContext as Z,useEventCallback as G,createEventSetupScript as R,createEventCleanupScript as $}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 j=`
1
+ var I=Object.defineProperty,l=(o,i)=>I(o,"name",{value:i,configurable:!0});import{useState as B,useCallback as u,useContext as x,useRef as C}from"react";import{MappedinContext as D}from"@mappedin/react-native-sdk";import{useCallback as A,useContext as W}from"react";var L="[MappedinJS]";function p(o="",{prefix:i=L}={}){const e=`${i}${o?`-${o}`:""}`,s=l((t,d)=>{if(typeof window<"u"&&window.rnDebug){const f=d.map(a=>a instanceof Error&&a.stack?`${a.message}
2
+ ${a.stack}`:a);window.rnDebug(`${o} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:0,log(...t){this.logState<=0&&(console.log(e,...t),s("log",t))},warn(...t){this.logState<=1&&(console.warn(e,...t),s("warn",t))},error(...t){this.logState<=2&&(console.error(e,...t),s("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(p,"createLogger");var z=p(),F=p("",{prefix:"[DynamicFocus]"});import{MappedinContext as _,useEventCallback as G,createEventSetupScript as N,createEventCleanupScript as $}from"@mappedin/react-native-sdk";function v(o,i){return i.map(e=>e&&e.id&&o.getById("facade",e.id)||e)}l(v,"hydrateFacades");import{useRegisterExtension as R}from"@mappedin/react-native-sdk";var j=`
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 @@ ${r.stack}`:r);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 tt=Object.defineProperty;var Eo=Object.getOwnPropertyDescriptor;var vo=Object.getOwnPropertyNames;var wo=Object.prototype.hasOwnProperty;var Jt=s=>{throw TypeError(s)};var Vo=(s,t,e)=>t in s?tt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t)=>tt(s,"name",{value:t,configurable:!0}),Mt=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Oo=(s,t)=>{for(var e in t)tt(s,e,{get:t[e],enumerable:!0})},To=(s,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of vo(t))!wo.call(s,r)&&r!==e&&tt(s,r,{get:()=>t[r],enumerable:!(i=Eo(t,r))||i.enumerable});return s};var Io=s=>To(tt({},"__esModule",{value:!0}),s);var m=(s,t,e)=>Vo(s,typeof t!="symbol"?t+"":t,e),xt=(s,t,e)=>t.has(s)||Jt("Cannot "+e);var o=(s,t,e)=>(xt(s,t,"read from private field"),e?e.call(s):t.get(s)),c=(s,t,e)=>t.has(s)?Jt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),u=(s,t,e,i)=>(xt(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e),y=(s,t,e)=>(xt(s,t,"access private method"),e);var Ro={};Oo(Ro,{DynamicFocus:()=>It,calculateZoomThresholds:()=>go});var Bt=Mt("@mappedin/mappedin-js");function Xt(s,t){if(s==null||t==null)return s===t;if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return!1;return!0}a(Xt,"arraysEqual");var Lt=class Lt{constructor(){m(this,"_subscribers",{});m(this,"_abortController",new AbortController);m(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 n=a(()=>this.off(t,e),"cleanup");return r&&r.addEventListener("abort",n,{once:!0}),this._cleanupFunctions.push(n),n}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(Lt,"PubSub");var yt=Lt;var Y=Mt("@mappedin/mappedin-js");var O,ot,_,v,S,T,z,$,_t=class _t{constructor(t,e){m(this,"__type","building");c(this,O);c(this,ot,new Map);c(this,_,new Map);c(this,v,[]);c(this,S);c(this,T);m(this,"defaultFloor");m(this,"activeFloor");m(this,"excluded",!1);m(this,"floorsAltitudesMap",new Map);m(this,"aboveGroundFloors",[]);c(this,z);c(this,$);u(this,O,t),u(this,ot,new Map(t.floors.map(r=>[r.id,r]))),u(this,_,new Map(t.floors.map(r=>[r.elevation,r]))),u(this,v,Array.from(o(this,_).values()).sort((r,n)=>r.elevation-n.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,u(this,S,e),this.aboveGroundFloors=o(this,v).filter(r=>r.elevation>=0);let i=t.facade?.spaces.map(r=>o(this,S).getState(r)).sort((r,n)=>r.altitude-n.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let r in this.aboveGroundFloors){let n=this.aboveGroundFloors[r],h=i[r];this.floorsAltitudesMap.set(n.elevation,{altitude:h.altitude,visualHeight:h.height})}}get id(){return o(this,O).id}get name(){return o(this,O).name}get floors(){return o(this,O).floors}get floorStack(){return o(this,O)}get facade(){return o(this,O).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?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,z)==null&&u(this,z,Math.max(...o(this,_).keys())),o(this,z)}get minElevation(){return o(this,$)==null&&u(this,$,Math.min(...o(this,_).keys())),o(this,$)}has(t){return Y.Floor.is(t)?o(this,ot).has(t.id):Y.FloorStack.is(t)?t.id===o(this,O).id:Y.Facade.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,v)[o(this,v).length-1];for(let i=o(this,v).length-1;i>=0;i--){let r=o(this,v)[i];if(r.elevation<=t)return r}}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,T)&&(o(this,T).animation.cancel(),u(this,T,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,T)?.state||o(this,S).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:r,visible:n}=t;if(o(this,S).updateState(this.facade,{visible:!0}),r!==void 0){u(this,T,{animation:o(this,S).animateState(this.facade,{opacity:r},{duration:e.duration}),state:t});let h=await o(this,T).animation;if(u(this,T,void 0),h.result==="cancelled")return h}return n===!1&&o(this,S).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,O).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})}};O=new WeakMap,ot=new WeakMap,_=new WeakMap,v=new WeakMap,S=new WeakMap,T=new WeakMap,z=new WeakMap,$=new WeakMap,a(_t,"Building");var St=_t;function to(s,t,e){return s>=t?"in-range":s<=e?"out-of-range":"transition"}a(to,"getZoomState");function Et(s,t,e){if(s.__type==="outdoors"&&"floor"in s)return s.floor;let i=s;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(Et,"getFloorToShow");function Bo(s,t,e,i){return i?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:s,state:{type:"facade",visible:!0,opacity:.2}}:{facade:s,state:{type:"facade",visible:!0,opacity:1}}}a(Bo,"getFacadeState");function Ao(s,t,e){return{outdoorOpacity:"initial",floorStates:s.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}}}})}}a(Ao,"getSingleBuildingState");function oo(s,t){if(!t.includes("lock-elevation"))return"initial";for(let e of s)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(oo,"getOutdoorOpacity");function eo(s,t,e){switch(e){case"in-range":return s[0]?.canSetFloor?s[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(eo,"getSetFloorTargetFromZoomState");function io(s){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:r,mode:n,elevation:h,floorIdsInNavigation:f,floorStackIdsInNavigation:w,multiFloorView:F,getMultiFloorState:mt,dynamicBuildingInteriors:D,isolateBelowGroundView:j,currentElevation:pt,forceInteriorsVisible:X,getFloorStackAltitudeData:gt}=s,Ft=new Map,At=j&&pt<0&&r==="in-range";for(let g of t){let Qt=e.has(g.id),bt=At&&g.minElevation>=0,Fo=bt?!1:Qt,kt=bt?!1:Nt({building:g,currentFloor:i,inRange:r==="in-range",inFocus:Qt,mode:n,elevation:h,inNavigation:w.includes(g.id),dynamicBuildingInteriors:D,forceInteriorsVisible:X}),Dt=i.floorStack.id===g.id?g.activeFloor:Et(g,n,h),bo=F?.enabled?mt(g.floors,Dt||g.activeFloor,f,gt?.(g.id)??g.floorsAltitudesMap,{color:F?.footprintColor,spacesOpenToBelowEnabled:F?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:F?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:F?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:F?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:F?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:F?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:F?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:F?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:F?.footprintOpacity,outline:F?.footprintOutline}):Ao(g.floorStack,Dt||g.activeFloor,kt),yo=j&&pt<0&&r==="in-range",So=Bo(g.facade,kt,yo,bt);Ft.set(g.id,{building:g,showIndoor:kt,floorStackState:bo,facadeState:So,inFocus:Fo,floorToShow:Dt,isAboveGroundInIsolation:bt})}return Ft}a(io,"getBuildingStates");function so(s,t){return s.excluded?"none":t?"indoor":"outdoor"}a(so,"getBuildingAnimationType");function Nt(s){let{building:t,currentFloor:e,inRange:i,inFocus:r,mode:n,elevation:h,inNavigation:f,dynamicBuildingInteriors:w,forceInteriorsVisible:F}=s;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(F===!0||f===!0)return!0;if(!w)return e.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(h)!=null;default:break}return!0}a(Nt,"shouldShowIndoor");function ro(s,t,e){return s!==t&&!e}a(ro,"shouldDeferSetFloor");var no=["default-floor","lock-elevation","nearest-elevation"];var vt=Mt("@mappedin/mappedin-js");var Ct="[MappedinJS]";function Zt(s="",{prefix:t=Ct}={}){let e=\`\${t}\${s?\`-\${s}\`:""}\`,i=a((r,n)=>{if(typeof window<"u"&&window.rnDebug){let h=n.map(f=>f instanceof Error&&f.stack?\`\${f.message}
12
- \${f.stack}\`:f);window.rnDebug(\`\${s} \${r}: \${h.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(Zt,"createLogger");var ko=Zt();var q=ko;function ao(s,t,e,i){return(s<t||s>e)&&q.warn(i),Math.min(e,Math.max(t,s))}a(ao,"clampWithWarning");function Gt(s,t){return!vt.Floor.is(s)||s?.floorStack==null||!vt.FloorStack.is(t)?!1:s.floorStack.id!==t.id?(q.warn(\`Floor (\${s.id}) does not belong to floor stack (\${t.id}).\`),!1):!0}a(Gt,"validateFloorForStack");function Rt(s,t,e,i){return ao(s,t,e,\`\${i} must be between \${t} and \${e}.\`)}a(Rt,"validateZoomThreshold");var W=Zt("",{prefix:"[DynamicFocus]"});var I,H,et,Pt,Ut=class Ut{constructor(t,e){c(this,et);m(this,"__type","outdoors");c(this,I);c(this,H);u(this,I,t),u(this,H,e)}get id(){return o(this,I).id}get floorStack(){return o(this,I)}get floor(){return o(this,I).defaultFloor}matchesFloorStack(t){return t===o(this,I)||t===o(this,I).id}show(){y(this,et,Pt).call(this,!0)}hide(){y(this,et,Pt).call(this,!1)}destroy(){this.matchesFloorStack(o(this,H).currentFloorStack)||this.hide()}};I=new WeakMap,H=new WeakMap,et=new WeakSet,Pt=a(function(t){for(let e of o(this,I).floors)o(this,H).updateState(e,{visible:t})},"#setVisible"),a(Ut,"Outdoors");var wt=Ut;function lo(s,t){let e=s.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let r=e.find(n=>n.facade==null&&!t.has(n.id));return r||(W.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(lo,"getOutdoorFloorStack");var uo={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1},jt=.2,zt=.4;function Do(s,t){return\`\${t} \${s}\`}a(Do,"formatMessage");var $t=class $t extends Error{constructor(t,e=Ct){super(Do(t,e)),this.name="MappedinError"}};a($t,"MappedinError");var Vt=$t;var Mo=a(s=>s,"linearEase"),xo=a(s=>s*s,"quadEaseIn"),Lo=a(s=>1-Math.cos(s*Math.PI/2),"easeIn"),_o=a(s=>1-(1-s)*(1-s),"quadEaseOut"),No=a(s=>1-Math.pow(1-s,3),"cubicEaseOut"),Co={linear:Mo,"ease-in":xo,"ease-out":_o,"ease-in-out":Lo,"ease-out-cubic":No};function Zo(s,t){let e=0;if(t.length<2)return e;let r=t[0]<t[1]?(n,h)=>n>h:(n,h)=>n<h;for(;e<t.length-1&&r(s,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Zo,"getInterpolationBreakpoint");function co(s,t,e,i="ease-in"){if(t.length!==e.length)throw new Vt("Input and output ranges must have the same number of values.");s=Math.max(t[0],Math.min(s,t[t.length-1]));let r=Zo(s,t),n=(s-t[r])/(t[r+1]-t[r]),h=typeof i=="function"?i(n):Co[i](n);return e[r]+h*(e[r+1]-e[r])}a(co,"interpolateMulti");var B,it,st,M,rt,qt=class qt{constructor(t,e,i){m(this,"layers");m(this,"visible");c(this,B);c(this,it,[]);c(this,st,!1);c(this,M,new Map);m(this,"interpolationFn");c(this,rt,1);this.layers=t,this.visible=e,u(this,B,i)}processLayerGroup(t,e,i){if(!o(this,st)&&(this.layers.forEach(r=>{let n=t[r];n&&o(this,it).push(...n)}),u(this,st,!0),this.visible)){let r=[e,i],n=[1,0];this.interpolationFn=h=>co(h,r,n)}}setOpacity(t){u(this,rt,t);for(let e of o(this,it))if(e.startsWith("img_")){let i=o(this,B).Image3D.getById(e);if(i){let r=o(this,B).getState(i.image);o(this,M).has(e)||o(this,M).set(e,r?.opacity??1);let n=Math.min(o(this,M).get(e),t);o(this,B).updateState(i.image,{opacity:n})}}else{let i=o(this,B).getMapData()?.getById("space",e);if(!i)continue;let r=o(this,B).getState(i);o(this,M).has(e)||o(this,M).set(e,r?.opacity??1);let n=Math.min(o(this,M).get(e),t);o(this,B).updateState(i,{opacity:n,visible:n>0})}}get opacity(){return o(this,rt)}};B=new WeakMap,it=new WeakMap,st=new WeakMap,M=new WeakMap,rt=new WeakMap,a(qt,"LayerGroup");var Ot=qt;function Yt(s,t){s.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(Yt,"runLayerGroupInterpolations");var V,l,N,d,R,P,b,x,U,L,E,K,nt,at,lt,A,C,Q,Z,G,p,Wt,ho,fo,Ht,ut,ct,dt,ht,ft,J,Tt,mo,po,k,Kt=class Kt{constructor(t){c(this,p);c(this,V);c(this,l);c(this,N);c(this,d,uo);c(this,R,[]);c(this,P,new Set);c(this,b,new Map);c(this,x);c(this,U,!1);c(this,L,!1);c(this,E,0);c(this,K,0);c(this,nt,[]);c(this,at,{});c(this,lt,{});c(this,A,"transition");c(this,C,"outdoor");c(this,Q,[]);c(this,Z,!1);c(this,G,[]);m(this,"sceneUpdateQueue",Promise.resolve());m(this,"on",a((t,e)=>{o(this,V).on(t,e)},"on"));m(this,"off",a((t,e)=>{o(this,V).off(t,e)},"off"));c(this,ut,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(Xt(e,this.focusedFacades)&&o(this,C)==="transition"&&!o(this,L))return;u(this,L,!1),u(this,R,[]),o(this,P).clear();let i=o(this,d).isolateBelowGroundView&&o(this,E)<0;if(e.length>0)for(let r of e){let n=o(this,b).get(r.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;o(this,P).add(n.id),o(this,R).push(n)}}o(this,d).autoFocus&&this.focus()},"#handleFacadesInViewChange"));c(this,ct,a(async t=>{if(!this.isEnabled)return;let{floor:e}=t,i=o(this,b).get(e.floorStack.id);i&&(i.activeFloor=e);let r=o(this,d).isolateBelowGroundView&&o(this,E)<0;i?.excluded===!1&&!o(this,x).matchesFloorStack(e.floorStack)&&u(this,E,e.elevation);let n=o(this,d).isolateBelowGroundView&&o(this,E)<0,h=r&&!n;if(o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(h?(u(this,L,!0),o(this,l).Camera.updateFacadesInView(),o(this,d).autoFocus||(await o(this,k).call(this,e),o(this,V).publish("focus",{facades:this.focusedFacades}))):(await o(this,k).call(this,e),o(this,V).publish("focus",{facades:this.focusedFacades})));let f=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!==f&&o(this,l).Camera.animateElevation(f,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));c(this,dt,a(()=>{u(this,U,!0)},"#handleUserInteractionStart"));c(this,ht,a(()=>{u(this,U,!1)},"#handleUserInteractionEnd"));c(this,ft,a(()=>{o(this,k).call(this)},"#handleGlobalStateChange"));c(this,J,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=to(e,o(this,d).indoorZoomThreshold,o(this,d).outdoorZoomThreshold);o(this,A)!==i&&(u(this,A,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Yt(o(this,G),e)},"#handleCameraChange"));c(this,k,a(async t=>{if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,r=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(w=>w.id)||[],h=o(this,l).Navigation?.floorStacks.map(w=>w.id)||[],f=new Promise(async w=>{await this.sceneUpdateQueue;let F=io({buildings:Array.from(o(this,b).values()),inViewSet:o(this,P),currentFloor:e,zoomState:o(this,A),mode:o(this,d).mode,elevation:o(this,E),floorIdsInNavigation:n,floorStackIdsInNavigation:h,multiFloorView:r,getMultiFloorState:o(this,d).customMultiFloorVisibilityState??Bt.getMultiFloorState,dynamicBuildingInteriors:o(this,d).dynamicBuildingInteriors,isolateBelowGroundView:o(this,d).isolateBelowGroundView,currentElevation:o(this,E),forceInteriorsVisible:o(this,d).forceInteriorsVisible,getFloorStackAltitudeData:a(D=>o(this,l).getFloorStackAltitudeData(D),"getFloorStackAltitudeData")}),mt=[];await Promise.all(Array.from(F.values()).map(async D=>{let{building:j,showIndoor:pt,floorStackState:X,facadeState:gt,inFocus:Ft,isAboveGroundInIsolation:At}=D;mt.push(X);let g=so(j,pt);if(g==="indoor")return y(this,p,mo).call(this,j,X,gt,Ft);if(g==="outdoor")return y(this,p,po).call(this,j,X,gt,h,At)})),o(this,l).Outdoor.setOpacity(oo(mt,o(this,d).mode)),u(this,Q,o(this,R).filter(D=>F.get(D.id)?.showIndoor===!0).map(D=>D.facade)),o(this,V).publish("focus",{facades:o(this,Q)}),w()});return this.sceneUpdateQueue=f,f},"#applyBuildingStates"));u(this,V,new yt),u(this,l,t),W.setLevel(q.logState),u(this,N,o(this,l).getMapData()),u(this,E,o(this,l).currentFloor.elevation),u(this,K,o(this,l).Camera.elevation);for(let e of o(this,N).getByType("facade"))o(this,b).set(e.floorStack.id,new St(e.floorStack,o(this,l)));y(this,p,fo).call(this),u(this,x,new wt(lo(o(this,N),o(this,b)),o(this,l))),o(this,l).on("floor-change-start",o(this,ct)),o(this,l).on("camera-change",o(this,J)),o(this,l).on("facades-in-view-change",o(this,ut)),o(this,l).on("user-interaction-start",o(this,dt)),o(this,l).on("user-interaction-end",o(this,ht)),o(this,l).on("global-state-change",o(this,ft))}enable(t){if(o(this,Z)){W.warn("enable() called on an already enabled Dynamic Focus instance.");return}u(this,Z,!0),o(this,l).manualFloorVisibility=!0,o(this,x).show(),this.updateState({...o(this,d),...t}),y(this,p,ho).call(this),o(this,J).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)){W.warn("disable() called on an already disabled Dynamic Focus instance.");return}u(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,x).floorStack}get layers(){return o(this,nt)}get layersBySpaceId(){return o(this,at)}setIndoor(){u(this,C,"indoor"),u(this,A,"in-range"),y(this,p,Wt).call(this)}setOutdoor(){u(this,C,"outdoor"),u(this,A,"out-of-range"),y(this,p,Wt).call(this)}get focusedFacades(){return[...o(this,Q)]}getState(){return{...o(this,d)}}updateState(t){let e=!1,i=o(this,d).isolateBelowGroundView&&o(this,E)<0;if(t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=Rt(t.indoorZoomThreshold,t?.outdoorZoomThreshold??o(this,d).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=Rt(t.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,t?.indoorZoomThreshold??o(this,d).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=no.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),t.isolateBelowGroundView!=null&&t.isolateBelowGroundView!==o(this,d).isolateBelowGroundView&&(e=!0),t.forceInteriorsVisible!=null&&t.forceInteriorsVisible!==o(this,d).forceInteriorsVisible&&(e=!0),t.showLabelsAndMarkersOnAllVisibleFloors!=null&&t.showLabelsAndMarkersOnAllVisibleFloors!==o(this,d).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),u(this,d,Object.assign({},o(this,d),Object.fromEntries(Object.entries(t).filter(([,r])=>r!=null)))),t.mode!=null&&t.preloadFloors&&y(this,p,Ht).call(this,t.mode),e){let r=o(this,d).isolateBelowGroundView&&o(this,E)<0;i&&!r?(u(this,L,!0),o(this,l).Camera.updateFacadesInView(),o(this,d).autoFocus||o(this,k).call(this)):o(this,k).call(this)}}destroy(){this.disable(),o(this,l).off("facades-in-view-change",o(this,ut)),o(this,l).off("floor-change-start",o(this,ct)),o(this,l).off("camera-change",o(this,J)),o(this,l).off("user-interaction-start",o(this,dt)),o(this,l).off("user-interaction-end",o(this,ht)),o(this,l).off("global-state-change",o(this,ft)),o(this,b).forEach(t=>t.destroy()),o(this,x).destroy(),o(this,V).destroy(),u(this,G,[])}async focus(t=o(this,d).setFloorOnFocus){if(t)if(ro(o(this,K),o(this,l).Camera.elevation,o(this,U)))u(this,K,o(this,l).Camera.elevation),u(this,L,!0);else{let e=eo(o(this,R),o(this,x),o(this,A)),i=e?Et(e,o(this,d).mode,o(this,E)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,k).call(this),o(this,V).publish("focus",{facades:this.focusedFacades})}preloadFloors(){y(this,p,Ht).call(this,o(this,d).mode)}setDefaultFloorForStack(t,e){if(!Gt(e,t))return;let i=o(this,b).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,b).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){return o(this,b).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Gt(e,t))return;let i=o(this,b).get(t.id);i&&(i.activeFloor=e,o(this,k).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,b).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,b).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){return o(this,b).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};V=new WeakMap,l=new WeakMap,N=new WeakMap,d=new WeakMap,R=new WeakMap,P=new WeakMap,b=new WeakMap,x=new WeakMap,U=new WeakMap,L=new WeakMap,E=new WeakMap,K=new WeakMap,nt=new WeakMap,at=new WeakMap,lt=new WeakMap,A=new WeakMap,C=new WeakMap,Q=new WeakMap,Z=new WeakMap,G=new WeakMap,p=new WeakSet,Wt=a(function(){o(this,d).autoFocus&&(o(this,U)?this.focus():u(this,L,!0)),o(this,V).publish("state-change")},"#handleViewStateChange"),ho=a(function(){u(this,G,[]);for(let t of o(this,d).dynamicLayers){let e=new Ot([t],!0,o(this,l));e.processLayerGroup(o(this,lt),o(this,d).outdoorZoomThreshold,o(this,d).indoorZoomThreshold),o(this,G).push(e)}Yt(o(this,G),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),fo=a(function(){let t=o(this,N).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(r=>{e[r.name]||(e[r.name]=[]),e[r.name].push(...r.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of r.spaces)i[n]==null&&(i[n]=[]),i[n].push(r.name)}),u(this,nt,t.map(({name:r})=>r)),u(this,at,i),u(this,lt,e)},"#setupLayers"),Ht=a(function(t){o(this,l).preloadFloors(o(this,N).getByType("facade").map(e=>Et(o(this,b).get(e.floorStack.id),t,o(this,E))).filter(e=>e!=null&&Bt.Floor.is(e)))},"#preloadFloors"),ut=new WeakMap,ct=new WeakMap,dt=new WeakMap,ht=new WeakMap,ft=new WeakMap,J=new WeakMap,Tt=a(function(t,e,i,r=!1){t.forEach(n=>{if(n.floor)if(e){let f=i!==void 0&&!r?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,f)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),mo=a(async function(t,e,i,r){return y(this,p,Tt).call(this,e.floorStates,!0,r,o(this,d).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,d).indoorAnimationOptions)},"#animateIndoorSequence"),po=a(async function(t,e,i,r,n){let h=n;h&&y(this,p,Tt).call(this,e.floorStates,!1,void 0,o(this,d).showLabelsAndMarkersOnAllVisibleFloors);let f=await t.animateFacade(i.state,o(this,d).outdoorAnimationOptions);return f.result==="completed"&&!h&&y(this,p,Tt).call(this,e.floorStates,Nt({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,A)==="in-range",inFocus:o(this,P).has(t.id),mode:o(this,d).mode,elevation:o(this,E),inNavigation:r.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,d).dynamicBuildingInteriors,forceInteriorsVisible:o(this,d).forceInteriorsVisible}),void 0,o(this,d).showLabelsAndMarkersOnAllVisibleFloors),f},"#animateOutdoorSequence"),k=new WeakMap,a(Kt,"DynamicFocus");var It=Kt;var go=a((s,t)=>{let e={initialVisibility:t.initialVisibility??"outdoor-first",layersBySpaceId:t.layersBySpaceId??{},focusLayers:t.focusLayers??[],defaultFloor:t.defaultFloor??s.currentFloor},i=Go(s,e),r=i+zt,n=i+jt;return e.initialVisibility==="indoor-first"&&(r=i-jt,n=i-zt),{indoorZoomThreshold:r,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Go(s,t){let e=s.getMapData();if(t.focusLayers.length){let h=e.getByType("space").filter(f=>{let w=t.layersBySpaceId[f.id]?.[0];return typeof w=="string"&&f.floor.id===t.defaultFloor?.id&&t.focusLayers.indexOf(w)!==-1});if(h.length){let f=s.Camera.getFocusOnTransform(h,{}).zoomLevel;if(f!==void 0)return f}}let i=e.getByType("floor-stack"),r=1/0;for(let n of i)for(let h of n.floors){let f=s.Camera.getFocusOnTransform(h,{}).zoomLevel??1/0;f<r&&(r=f)}return r!==1/0?r:s.Camera.getFocusOnTransform(t.defaultFloor,{}).zoomLevel??0}a(Go,"getDefaultZoomLevel");return Io(Ro);})();
11
+ "use strict";var DynamicFocus=(()=>{var eo=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var rt=r=>{throw TypeError(r)};var Bt=(r,t,e)=>t in r?eo(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>eo(r,"name",{value:t,configurable:!0}),No=(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 At=(r,t)=>{for(var e in t)eo(r,e,{get:t[e],enumerable:!0})},Dt=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Vt(t))!It.call(r,s)&&s!==e&&eo(r,s,{get:()=>t[s],enumerable:!(i=Ot(t,s))||i.enumerable});return r};var kt=r=>Dt(eo({},"__esModule",{value:!0}),r);var b=(r,t,e)=>Bt(r,typeof t!="symbol"?t+"":t,e),Co=(r,t,e)=>t.has(r)||rt("Cannot "+e);var o=(r,t,e)=>(Co(r,t,"read from private field"),e?e.call(r):t.get(r)),c=(r,t,e)=>t.has(r)?rt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),d=(r,t,e,i)=>(Co(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>(Co(r,t,"access private method"),e);var zt={};At(zt,{DynamicFocus:()=>Mo,calculateZoomThresholds:()=>Bo});var Zo=No("@mappedin/mappedin-js");function nt(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}a(nt,"arraysEqual");var Go=class Go{constructor(){b(this,"_subscribers",{});b(this,"_abortController",new AbortController)}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 s=i?.signal;if(s?.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e);let n=a(()=>{this.off(t,e)},"cleanup");return s&&s.addEventListener("abort",n,{once:!0}),n}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(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(Go,"PubSub");var wo=Go;var H=No("@mappedin/mappedin-js");var V,io,N,w,E,B,q,W,Po=class Po{constructor(t,e){b(this,"__type","building");c(this,V);c(this,io,new Map);c(this,N,new Map);c(this,w,[]);c(this,E);c(this,B);b(this,"defaultFloor");b(this,"activeFloor");b(this,"excluded",!1);b(this,"floorsAltitudesMap",new Map);b(this,"aboveGroundFloors",[]);c(this,q);c(this,W);d(this,V,t),d(this,io,new Map(t.floors.map(s=>[s.id,s]))),d(this,N,new Map(t.floors.map(s=>[s.elevation,s]))),d(this,w,Array.from(o(this,N).values()).sort((s,n)=>s.elevation-n.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,d(this,E,e),this.aboveGroundFloors=o(this,w).filter(s=>s.elevation>=0);let i=t.facade?.spaces.map(s=>o(this,E).getState(s)).sort((s,n)=>s.altitude-n.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let s in this.aboveGroundFloors){let n=this.aboveGroundFloors[s],m=i[s];this.floorsAltitudesMap.set(n.elevation,{altitude:m.altitude,visualHeight:m.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,E).currentFloorStack.id}get isIndoor(){let t=o(this,E).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,q)==null&&d(this,q,Math.max(...o(this,N).keys())),o(this,q)}get minElevation(){return o(this,W)==null&&d(this,W,Math.min(...o(this,N).keys())),o(this,W)}has(t){return H.Floor.is(t)?o(this,io).has(t.id):H.FloorStack.is(t)?t.id===o(this,V).id:H.Facade.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,w)[o(this,w).length-1];for(let i=o(this,w).length-1;i>=0;i--){let s=o(this,w)[i];if(s.elevation<=t)return s}}else{if(t<this.minElevation)return o(this,w)[0];for(let i of o(this,w))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,w)[o(this,w).length-1]}cancelAnimation(){o(this,B)&&(o(this,B).animation.cancel(),d(this,B,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,B)?.state||o(this,E).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:s,visible:n}=t;if(o(this,E).updateState(this.facade,{visible:!0}),s!==void 0){d(this,B,{animation:o(this,E).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let m=await o(this,B).animation;if(d(this,B,void 0),m.result==="cancelled")return m}return n===!1&&o(this,E).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,V).floors.forEach(t=>{o(this,E).updateState(t,{visible:t.id===o(this,E).currentFloor.id})}),this.has(o(this,E).currentFloor)||o(this,E).updateState(this.facade,{visible:!0,opacity:1})}};V=new WeakMap,io=new WeakMap,N=new WeakMap,w=new WeakMap,E=new WeakMap,B=new WeakMap,q=new WeakMap,W=new WeakMap,a(Po,"Building");var vo=Po;function at(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(at,"getZoomState");function Oo(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}a(Oo,"getFloorToShow");function Mt(r,t,e,i){return i?{facade:r,state:{type:"facade",visible:!1,opacity:0}}: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}}}a(Mt,"getFacadeState");function Zt(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}}}})}}a(Zt,"getSingleBuildingState");function lt(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"}a(lt,"getOutdoorOpacity");function ut(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}}a(ut,"getSetFloorTargetFromZoomState");function dt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:m,floorIdsInNavigation:f,floorStackIdsInNavigation:h,multiFloorView:g,getMultiFloorState:U,dynamicBuildingInteriors:O,isolateBelowGroundView:Y,currentElevation:yo,forceInteriorsVisible:to,getFloorStackAltitudeData:So}=r,Eo=new Map,xo=Y&&yo<0&&s==="in-range";for(let y of t){let st=e.has(y.id),To=xo&&y.minElevation>=0,Et=To?!1:st,Lo=To?!1:Ro({building:y,currentFloor:i,inRange:s==="in-range",inFocus:st,mode:n,elevation:m,inNavigation:h.includes(y.id),dynamicBuildingInteriors:O,forceInteriorsVisible:to}),_o=i.floorStack.id===y.id?y.activeFloor:Oo(y,n,m),Tt=g?.enabled?U(y.floors,_o||y.activeFloor,f,So?.(y.id)??y.floorsAltitudesMap,{color:g?.footprintColor,spacesOpenToBelowEnabled:g?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:g?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:g?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:g?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:g?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:g?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:g?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:g?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:g?.footprintOpacity,outline:g?.footprintOutline}):Zt(y.floorStack,_o||y.activeFloor,Lo),wt=Y&&yo<0&&s==="in-range",vt=Mt(y.facade,Lo,wt,To);Eo.set(y.id,{building:y,showIndoor:Lo,floorStackState:Tt,facadeState:vt,inFocus:Et,floorToShow:_o,isAboveGroundInIsolation:To})}return Eo}a(dt,"getBuildingStates");function ct(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(ct,"getBuildingAnimationType");function Ro(r){let{building:t,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:m,inNavigation:f,dynamicBuildingInteriors:h,forceInteriorsVisible:g}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(g===!0||f===!0)return!0;if(!h)return e.floorStack.type!=="Outdoor";if(!i||!s)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(m)!=null;default:break}return!0}a(Ro,"shouldShowIndoor");function ht(r,t,e){return r!==t&&!e}a(ht,"shouldDeferSetFloor");var mt=["default-floor","lock-elevation","nearest-elevation"];var Vo=No("@mappedin/mappedin-js");var Uo="[MappedinJS]";function jo(r="",{prefix:t=Uo}={}){let e=\`\${t}\${r?\`-\${r}\`:""}\`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let m=n.map(f=>f instanceof Error&&f.stack?\`\${f.message}
12
+ \${f.stack}\`:f);window.rnDebug(\`\${r} \${s}: \${m.join(" ")}\`)}},"rnDebug");return{logState:0,log(...s){this.logState<=0&&(console.log(e,...s),i("log",s))},warn(...s){this.logState<=1&&(console.warn(e,...s),i("warn",s))},error(...s){this.logState<=2&&(console.error(e,...s),i("error",s))},assert(...s){console.assert(...s)},time(s){console.time(s)},timeEnd(s){console.timeEnd(s)},setLevel(s){0<=s&&s<=3&&(this.logState=s)}}}a(jo,"createLogger");var xt=jo();var K=xt;function ft(r,t,e,i){return(r<t||r>e)&&K.warn(i),Math.min(e,Math.max(t,r))}a(ft,"clampWithWarning");function zo(r,t){return!Vo.Floor.is(r)||r?.floorStack==null||!Vo.FloorStack.is(t)?!1:r.floorStack.id!==t.id?(K.warn(\`Floor (\${r.id}) does not belong to floor stack (\${t.id}).\`),!1):!0}a(zo,"validateFloorForStack");function $o(r,t,e,i){return ft(r,t,e,\`\${i} must be between \${t} and \${e}.\`)}a($o,"validateZoomThreshold");var A=jo("",{prefix:"[DynamicFocus]"});var D,Q,so,Yo,qo=class qo{constructor(t,e){c(this,so);b(this,"__type","outdoors");c(this,D);c(this,Q);d(this,D,t),d(this,Q,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(){F(this,so,Yo).call(this,!0)}hide(){F(this,so,Yo).call(this,!1)}destroy(){this.matchesFloorStack(o(this,Q).currentFloorStack)||this.hide()}};D=new WeakMap,Q=new WeakMap,so=new WeakSet,Yo=a(function(t){for(let e of o(this,D).floors)o(this,Q).updateState(e,{visible:t})},"#setVisible"),a(qo,"Outdoors");var Io=qo;function pt(r,t){let e=r.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let s=e.find(n=>n.facade==null&&!t.has(n.id));return s||(A.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(pt,"getOutdoorFloorStack");var ro={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},no=.2,Wo=.4;var Bo=a((r,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Lt(r,e);if(i===void 0)return A.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:ro.indoorZoomThreshold,outdoorZoomThreshold:ro.outdoorZoomThreshold};let s=i+Wo,n=i+no;return e.initialVisibility==="indoor-first"&&(s=i-no,n=i-Wo),{indoorZoomThreshold:s,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Lt(r,t){let i=r.getMapData().getByType("floor-stack").filter(m=>m.type!=="Outdoor"),s=1/0,n;for(let m of i){let f=r.Camera.getFocusOnTransform(m).zoomLevel??1/0;f<s&&(s=f,n=m)}if(s!==1/0)return t.debug&&n&&r.Camera.getFocusOnTransform(n,{debugColor:"blue"}),s}a(Lt,"getDefaultZoomLevel");function _t(r,t){return\`\${t} \${r}\`}a(_t,"formatMessage");var Ho=class Ho extends Error{constructor(t,e=Uo){super(_t(t,e)),this.name="MappedinError"}};a(Ho,"MappedinError");var Ao=Ho;var Nt=a(r=>r,"linearEase"),Ct=a(r=>r*r,"quadEaseIn"),Gt=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Pt=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Rt=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),Ut={linear:Nt,"ease-in":Ct,"ease-out":Pt,"ease-in-out":Gt,"ease-out-cubic":Rt};function jt(r,t){let e=0;if(t.length<2)return e;let s=t[0]<t[1]?(n,m)=>n>m:(n,m)=>n<m;for(;e<t.length-1&&s(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(jt,"getInterpolationBreakpoint");function gt(r,t,e,i="ease-in"){if(t.length!==e.length)throw new Ao("Input and output ranges must have the same number of values.");r=Math.max(t[0],Math.min(r,t[t.length-1]));let s=jt(r,t),n=(r-t[s])/(t[s+1]-t[s]),m=typeof i=="function"?i(n):Ut[i](n);return e[s]+m*(e[s+1]-e[s])}a(gt,"interpolateMulti");var k,ao,lo,Z,uo,Qo=class Qo{constructor(t,e,i){b(this,"layers");b(this,"visible");c(this,k);c(this,ao,[]);c(this,lo,!1);c(this,Z,new Map);b(this,"interpolationFn");c(this,uo,1);this.layers=t,this.visible=e,d(this,k,i)}processLayerGroup(t,e){o(this,lo)||(this.layers.forEach(i=>{let s=t[i];s&&o(this,ao).push(...s)}),d(this,lo,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:s,indoorZoomThreshold:n}=e();return gt(i,[s,n],[1,0])}))}setOpacity(t){d(this,uo,t);for(let e of o(this,ao))if(e.startsWith("img_")){let i=o(this,k).Image3D.getById(e);if(i){let s=o(this,k).getState(i.image);o(this,Z).has(e)||o(this,Z).set(e,s?.opacity??1);let n=Math.min(o(this,Z).get(e),t);o(this,k).updateState(i.image,{opacity:n})}}else{let i=o(this,k).getMapData()?.getById("space",e);if(!i)continue;let s=o(this,k).getState(i);o(this,Z).has(e)||o(this,Z).set(e,s?.opacity??1);let n=Math.min(o(this,Z).get(e),t);o(this,k).updateState(i,{opacity:n,visible:n>0})}}get opacity(){return o(this,uo)}};k=new WeakMap,ao=new WeakMap,lo=new WeakMap,Z=new WeakMap,uo=new WeakMap,a(Qo,"LayerGroup");var Do=Qo;function Ko(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(Ko,"runLayerGroupInterpolations");var v,l,C,u,j,z,S,x,$,L,T,J,co,ho,mo,M,G,X,_,P,R,p,Jo,Ft,Xo,ot,tt,bt,et,fo,po,go,Fo,bo,oo,ko,yt,St,I,it=class it{constructor(t){c(this,p);c(this,v);c(this,l);c(this,C);c(this,u,ro);c(this,j,[]);c(this,z,new Set);c(this,S,new Map);c(this,x);c(this,$,!1);c(this,L,!1);c(this,T,0);c(this,J,0);c(this,co,[]);c(this,ho,{});c(this,mo,{});c(this,M,"transition");c(this,G,"outdoor");c(this,X,[]);c(this,_,!1);c(this,P,[]);c(this,R,null);b(this,"sceneUpdateQueue",Promise.resolve());b(this,"on",a((t,e)=>{o(this,v).on(t,e)},"on"));b(this,"off",a((t,e)=>{o(this,v).off(t,e)},"off"));c(this,fo,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(nt(e,this.focusedFacades)&&o(this,G)==="transition"&&!o(this,L))return;d(this,L,!1),d(this,j,[]),o(this,z).clear();let i=o(this,u).isolateBelowGroundView&&o(this,T)<0;if(e.length>0)for(let s of e){let n=o(this,S).get(s.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;o(this,z).add(n.id),o(this,j).push(n)}}o(this,u).autoFocus&&this.focus()},"#handleFacadesInViewChange"));c(this,po,a(async t=>{if(!this.isEnabled)return;let{floor:e}=t,i=o(this,S).get(e.floorStack.id);i&&(i.activeFloor=e);let s=o(this,u).isolateBelowGroundView&&o(this,T)<0;i?.excluded===!1&&!o(this,x).matchesFloorStack(e.floorStack)&&d(this,T,e.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,T)<0,m=s&&!n;if(o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(m?(d(this,L,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||(await o(this,I).call(this,e),o(this,v).publish("focus",{facades:this.focusedFacades}))):(await o(this,I).call(this,e),o(this,v).publish("focus",{facades:this.focusedFacades})));let f=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!==f&&o(this,l).Camera.animateElevation(f,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));c(this,go,a(()=>{d(this,$,!0)},"#handleUserInteractionStart"));c(this,Fo,a(()=>{d(this,$,!1)},"#handleUserInteractionEnd"));c(this,bo,a(()=>{o(this,I).call(this)},"#handleGlobalStateChange"));c(this,oo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=at(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,M)!==i&&(d(this,M,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Ko(o(this,P),e)},"#handleCameraChange"));c(this,I,a(async t=>{if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,s=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(h=>h.id)||[],m=o(this,l).Navigation?.floorStacks.map(h=>h.id)||[],f=new Promise(async h=>{await this.sceneUpdateQueue;let g=dt({buildings:Array.from(o(this,S).values()),inViewSet:o(this,z),currentFloor:e,zoomState:o(this,M),mode:o(this,u).mode,elevation:o(this,T),floorIdsInNavigation:n,floorStackIdsInNavigation:m,multiFloorView:s,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Zo.getMultiFloorState,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,T),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(O=>o(this,l).getFloorStackAltitudeData(O),"getFloorStackAltitudeData")}),U=[];await Promise.all(Array.from(g.values()).map(async O=>{let{building:Y,showIndoor:yo,floorStackState:to,facadeState:So,inFocus:Eo,isAboveGroundInIsolation:xo}=O;U.push(to);let y=ct(Y,yo);if(y==="indoor")return F(this,p,yt).call(this,Y,to,So,Eo);if(y==="outdoor")return F(this,p,St).call(this,Y,to,So,m,xo)})),o(this,l).Outdoor.setOpacity(lt(U,o(this,u).mode)),d(this,X,o(this,j).filter(O=>g.get(O.id)?.showIndoor===!0).map(O=>O.facade)),o(this,v).publish("focus",{facades:o(this,X)}),h()});return this.sceneUpdateQueue=f,f},"#applyBuildingStates"));d(this,v,new wo),d(this,l,t),A.setLevel(K.logState),d(this,C,o(this,l).getMapData()),d(this,T,o(this,l).currentFloor.elevation),d(this,J,o(this,l).Camera.elevation);for(let e of o(this,C).getByType("facade"))o(this,S).set(e.floorStack.id,new vo(e.floorStack,o(this,l)));F(this,p,bt).call(this),d(this,x,new Io(pt(o(this,C),o(this,S)),o(this,l))),o(this,l).on("floor-change-start",o(this,po)),o(this,l).on("camera-change",o(this,oo)),o(this,l).on("facades-in-view-change",o(this,fo)),o(this,l).on("user-interaction-start",o(this,go)),o(this,l).on("user-interaction-end",o(this,Fo)),o(this,l).on("global-state-change",o(this,bo))}enable(t){if(o(this,_)){A.warn("enable() called on an already enabled Dynamic Focus instance.");return}d(this,_,!0),o(this,l).manualFloorVisibility=!0,o(this,x).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&A.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,p,Ft).call(this),o(this,oo).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.warn("disable() called on an already disabled Dynamic Focus instance.");return}d(this,_,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,_)}get isIndoor(){return o(this,G)==="indoor"}get isOutdoor(){return o(this,G)==="outdoor"}get outdoorsFloorStack(){return o(this,x).floorStack}get layers(){return o(this,co)}get layersBySpaceId(){return o(this,ho)}setIndoor(){d(this,G,"indoor"),d(this,M,"in-range"),F(this,p,Jo).call(this)}setOutdoor(){d(this,G,"outdoor"),d(this,M,"out-of-range"),F(this,p,Jo).call(this)}get focusedFacades(){return[...o(this,X)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,s=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,T)<0,m=!!o(this,u).autoZoomThresholds,f=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:m,h=t;if(f&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){A.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:U,...O}=h;h=O}if(!m&&f?(d(this,R,()=>{if(!o(this,_))return;let g=o(this,u).indoorZoomThreshold,U=o(this,u).outdoorZoomThreshold;F(this,p,ot).call(this),F(this,p,tt).call(this,g,U),o(this,I).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,R))):m&&!f&&F(this,p,Xo).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=$o(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=$o(h.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,h?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),h.mode!=null&&(h.mode=mt.includes(h.mode)?h.mode:"default-floor"),h.autoAdjustFacadeHeights!=null&&(o(this,u).autoAdjustFacadeHeights=h.autoAdjustFacadeHeights),h.dynamicBuildingInteriors!=null&&h.dynamicBuildingInteriors!==o(this,u).dynamicBuildingInteriors&&(e=!0),h.isolateBelowGroundView!=null&&h.isolateBelowGroundView!==o(this,u).isolateBelowGroundView&&(e=!0),h.forceInteriorsVisible!=null&&h.forceInteriorsVisible!==o(this,u).forceInteriorsVisible&&(e=!0),h.showLabelsAndMarkersOnAllVisibleFloors!=null&&h.showLabelsAndMarkersOnAllVisibleFloors!==o(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),f&&h.autoZoomThresholds!==void 0&&(F(this,p,ot).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,p,et).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,T)<0;n&&!g?(d(this,L,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||o(this,I).call(this)):o(this,I).call(this)}F(this,p,tt).call(this,i,s)}destroy(){this.disable(),F(this,p,Xo).call(this),o(this,l).off("facades-in-view-change",o(this,fo)),o(this,l).off("floor-change-start",o(this,po)),o(this,l).off("camera-change",o(this,oo)),o(this,l).off("user-interaction-start",o(this,go)),o(this,l).off("user-interaction-end",o(this,Fo)),o(this,l).off("global-state-change",o(this,bo)),o(this,S).forEach(t=>t.destroy()),o(this,x).destroy(),o(this,v).destroy(),d(this,P,[])}async focus(t=o(this,u).setFloorOnFocus){if(t)if(ht(o(this,J),o(this,l).Camera.elevation,o(this,$)))d(this,J,o(this,l).Camera.elevation),d(this,L,!0);else{let e=ut(o(this,j),o(this,x),o(this,M)),i=e?Oo(e,o(this,u).mode,o(this,T)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,I).call(this),o(this,v).publish("focus",{facades:this.focusedFacades})}preloadFloors(){F(this,p,et).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!zo(e,t))return;let i=o(this,S).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,S).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!zo(e,t))return;let i=o(this,S).get(t.id);i&&(i.activeFloor=e,o(this,I).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,S).get(i.id);s&&(s.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,S).get(i.id);s&&(s.excluded=!1)}}getCurrentFloorForStack(t){return o(this,S).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};v=new WeakMap,l=new WeakMap,C=new WeakMap,u=new WeakMap,j=new WeakMap,z=new WeakMap,S=new WeakMap,x=new WeakMap,$=new WeakMap,L=new WeakMap,T=new WeakMap,J=new WeakMap,co=new WeakMap,ho=new WeakMap,mo=new WeakMap,M=new WeakMap,G=new WeakMap,X=new WeakMap,_=new WeakMap,P=new WeakMap,R=new WeakMap,p=new WeakSet,Jo=a(function(){o(this,u).autoFocus&&(o(this,$)?this.focus():d(this,L,!0)),o(this,v).publish("state-change")},"#handleViewStateChange"),Ft=a(function(){d(this,P,[]);for(let t of o(this,u).dynamicLayers){let e=new Do([t],!0,o(this,l));e.processLayerGroup(o(this,mo),()=>o(this,u)),o(this,P).push(e)}Ko(o(this,P),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),Xo=a(function(){o(this,R)&&(o(this,l).off("camera-screen-offsets-change",o(this,R)),d(this,R,null))},"#unsubscribeScreenOffsets"),ot=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:s}=Bo(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=s,(e.expandMinZoom??!0)&&s<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(s-no)},"#recalcThresholds"),tt=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,v).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),bt=a(function(){let t=o(this,C).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(s=>{e[s.name]||(e[s.name]=[]),e[s.name].push(...s.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of s.spaces)i[n]==null&&(i[n]=[]),i[n].push(s.name)}),d(this,co,t.map(({name:s})=>s)),d(this,ho,i),d(this,mo,e)},"#setupLayers"),et=a(function(t){o(this,l).preloadFloors(o(this,C).getByType("facade").map(e=>Oo(o(this,S).get(e.floorStack.id),t,o(this,T))).filter(e=>e!=null&&Zo.Floor.is(e)))},"#preloadFloors"),fo=new WeakMap,po=new WeakMap,go=new WeakMap,Fo=new WeakMap,bo=new WeakMap,oo=new WeakMap,ko=a(function(t,e,i,s=!1){t.forEach(n=>{if(n.floor)if(e){let f=i!==void 0&&!s?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,f)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),yt=a(async function(t,e,i,s){return F(this,p,ko).call(this,e.floorStates,!0,s,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),St=a(async function(t,e,i,s,n){let m=n;m&&F(this,p,ko).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let f=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return f.result==="completed"&&!m&&F(this,p,ko).call(this,e.floorStates,Ro({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,M)==="in-range",inFocus:o(this,z).has(t.id),mode:o(this,u).mode,elevation:o(this,T),inNavigation:s.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),f},"#animateOutdoorSequence"),I=new WeakMap,a(it,"DynamicFocus");var Mo=it;return kt(zt);})();
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 j}l(S,"getRegistrationScript");function m(){N({extensionName:"dynamic-focus",getRegistrationScript:S,logger:F})}l(m,"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=L(Z),{extensions:s,mapData:t}=o;if(!t)throw new Error("Map data is not available");m();const f=(s?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",r=W(d=>{try{let u=d;e==="focus"&&d.facades&&(u={...d,facades:v(t,d.facades)}),i(u)}catch(u){F.error(`Error in dynamic focus event callback for ${String(e)}:`,u)}},[e,t,i]);G({eventKey:`dynamic-focus:${String(e)}`,callback:r,setupScript:l(()=>R({extensionName:"dynamic-focus",eventName:String(e)}),"setupScript"),cleanupScript:l(()=>$({extensionName:"dynamic-focus",eventName:String(e)}),"cleanupScript"),shouldInject:f})}l(b,"useDynamicFocusEvent");function k(){const e=T(C),{bridge:i,extensions:o,updateExtensionState:s}=e;m();const t=o["dynamic-focus"],h=t?.registrationState||"unregistered",f=h==="registered",r=t?.isEnabled||!1,[d,u]=x(t?.focusedFacades||[]),w=A(o);w.current=o,b("focus",c(n=>{const p=n.facades;u(p),s("dynamic-focus",y=>({...y,registrationState:h,focusedFacades:p}))},[h,s]));const a=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=>{w.current?.["dynamic-focus"]?.isEnabled||(await a("enable",[n]),s("dynamic-focus",B=>({...B,isEnabled:!0})))},[a,s]),M=c(async n=>await a("updateState",[n]),[a]),O=c(async()=>await a("getState"),[a]),I=c(async n=>await a("focus",[n]),[a]),V=c(async()=>{await a("disable"),u([]),s("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[a,u,s]);return{isReady:f,isEnabled:r,focusedFacades:d,updateState:M,getState:O,focus:I,disable:V,enable:E}}l(k,"useDynamicFocus");export{k as useDynamicFocus,b as useDynamicFocusEvent};
25
+ }`;function S(){return j}l(S,"getRegistrationScript");function g(){R({extensionName:"dynamic-focus",getRegistrationScript:S,logger:F})}l(g,"useDynamicFocusRegistration");function b(o,i){if(typeof o!="string"||o.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 e=W(_),{extensions:s,mapData:t}=e;if(!t)throw new Error("Map data is not available");g();const f=(s?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",a=A(c=>{try{let h=c;o==="focus"&&c.facades&&(h={...c,facades:v(t,c.facades)}),i(h)}catch(h){F.error(`Error in dynamic focus event callback for ${String(o)}:`,h)}},[o,t,i]);G({eventKey:`dynamic-focus:${String(o)}`,callback:a,setupScript:l(()=>N({extensionName:"dynamic-focus",eventName:String(o)}),"setupScript"),cleanupScript:l(()=>$({extensionName:"dynamic-focus",eventName:String(o)}),"cleanupScript"),shouldInject:f})}l(b,"useDynamicFocusEvent");function k(){const o=x(D),{bridge:i,extensions:e,updateExtensionState:s}=o;g();const t=e["dynamic-focus"],d=t?.registrationState||"unregistered",f=d==="registered",a=t?.isEnabled||!1,[c,h]=B(t?.focusedFacades||[]),w=C(e);w.current=e,b("focus",u(n=>{const m=n.facades;h(m),s("dynamic-focus",y=>({...y,registrationState:d,focusedFacades:m}))},[d,s]));const r=u(async(n,m=[])=>{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:m}})},[i]),E=u(async n=>{w.current?.["dynamic-focus"]?.isEnabled||(await r("enable",[n]),s("dynamic-focus",V=>({...V,isEnabled:!0})))},[r,s]),T=u(async n=>await r("updateState",[n]),[r]),M=u(async()=>await r("getState"),[r]),O=u(async n=>await r("focus",[n]),[r]),Z=u(async()=>{await r("disable"),h([]),s("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[r,h,s]);return{isReady:f,isEnabled:a,focusedFacades:c,updateState:T,getState:M,focus:O,disable:Z,enable:E}}l(k,"useDynamicFocus");export{k as useDynamicFocus,b as useDynamicFocusEvent};
package/lib/rn/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Facade, Floor, FootprintConfig, TFacadeState, TFloorAltitudeData, VisibilityState as BuildingFloorStackState } from '@mappedin/mappedin-js';
2
2
  import { Building } from './building';
3
+ import type { CalculateZoomThresholdsOptions } from './zoom-thresholds';
3
4
  export type MultiFloorVisibilityState = (floors: Floor[], currentFloor: Floor, floorIdsInNavigation: Floor['id'][], floorsVisualHeightMap: Map<number, TFloorAltitudeData>, footprintConfig?: Partial<FootprintConfig>) => BuildingFloorStackState;
4
5
  export type DynamicFocusAnimationOptions = {
5
6
  /**
@@ -39,7 +40,7 @@ export type DynamicFocusState = {
39
40
  * The zoom level at which the camera will fade in the facades and fade out the indoor floors.
40
41
  * @default 17
41
42
  */
42
- outdoorZoomThreshold?: number;
43
+ outdoorZoomThreshold: number;
43
44
  /**
44
45
  * Whether to set the floor to the outdoors when the camera moves in range.
45
46
  * @default true
@@ -106,6 +107,22 @@ export type DynamicFocusState = {
106
107
  * @default false
107
108
  */
108
109
  showLabelsAndMarkersOnAllVisibleFloors: boolean;
110
+ /**
111
+ * Automatically calculates zoom thresholds using {@link calculateZoomThresholds} and
112
+ * recalculates whenever screen offsets change. When enabled, manual `indoorZoomThreshold`
113
+ * and `outdoorZoomThreshold` values are ignored with a console warning.
114
+ *
115
+ * When enabled, `Camera.minZoomLevel` is automatically lowered if it would prevent
116
+ * the camera from reaching the outdoor zoom threshold (see {@link CalculateZoomThresholdsOptions.expandMinZoom | expandMinZoom},
117
+ * defaults to `true`). Pass `{ expandMinZoom: false }` to opt out.
118
+ *
119
+ * - `true` — enable with default options
120
+ * - `CalculateZoomThresholdsOptions` — enable with custom options (e.g. `{ debug: true }`)
121
+ * - `false` — disable (default)
122
+ *
123
+ * @default false
124
+ */
125
+ autoZoomThresholds: boolean | CalculateZoomThresholdsOptions;
109
126
  };
110
127
  /**
111
128
  * Internal events emitted for updating React state.
@@ -123,6 +140,13 @@ export type DynamicFocusEvents = {
123
140
  focus: {
124
141
  facades: Facade[];
125
142
  };
143
+ /**
144
+ * Emitted when zoom thresholds change, either from manual `updateState()` calls or automatic recalculation via `autoZoomThresholds`.
145
+ */
146
+ 'zoom-threshold-change': {
147
+ indoorZoomThreshold: number;
148
+ outdoorZoomThreshold: number;
149
+ };
126
150
  };
127
151
  export type DynamicFocusEventPayload<EventName extends keyof DynamicFocusEvents> = DynamicFocusEvents[EventName] extends {
128
152
  data: null;
@@ -0,0 +1,59 @@
1
+ import { MapView } from '@mappedin/mappedin-js';
2
+ /**
3
+ * Options for {@link calculateZoomThresholds}.
4
+ */
5
+ export type CalculateZoomThresholdsOptions = {
6
+ /**
7
+ * Determines which view is considered the starting point when computing thresholds.
8
+ * - 'indoor-first' (default): thresholds are placed slightly BELOW the base zoom level so that
9
+ * zooming out reveals outdoor content after passing the offsets.
10
+ * - 'outdoor-first': thresholds are placed slightly ABOVE the base zoom level
11
+ * so that zooming in reveals indoor content after passing the offsets.
12
+ */
13
+ initialVisibility?: 'indoor-first' | 'outdoor-first';
14
+ /**
15
+ * When true, visualizes the winning zoom threshold target via `getFocusOnTransform`
16
+ * debug overlays (point cloud + camera-space OBB). Only the winning target is
17
+ * visualized to avoid cluttering the debug view.
18
+ */
19
+ debug?: boolean;
20
+ /**
21
+ * When true, automatically lowers `Camera.minZoomLevel` if it would prevent
22
+ * the camera from reaching the outdoor zoom threshold.
23
+ * A buffer of {@link OUTDOOR_ZOOM_OFFSET} is applied below the threshold.
24
+ * @default true
25
+ */
26
+ expandMinZoom?: boolean;
27
+ };
28
+ /**
29
+ * Computes indoor and outdoor zoom thresholds for transitioning between map views.
30
+ *
31
+ * The base zoom level is determined by the minimum zoom across all indoor building floor-stacks
32
+ * (altitude-aware, accounting for the full 3D volume of each building). If no indoor floor stacks
33
+ * exist, hardcoded defaults (18/17) are returned with a logged error.
34
+ *
35
+ * Fixed offsets are then applied above or below this base depending on
36
+ * {@link CalculateZoomThresholdsOptions.initialVisibility | initialVisibility}.
37
+ *
38
+ * @param mapView - The active MapView instance.
39
+ * @param userOptions - Optional threshold configuration.
40
+ * @returns `{ indoorZoomThreshold, outdoorZoomThreshold }` — zoom levels at which
41
+ * the scene should transition between indoor and outdoor presentation.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const { indoorZoomThreshold, outdoorZoomThreshold } = calculateZoomThresholds(mapView);
46
+ *
47
+ * const dynamicFocus = new DynamicFocus(mapView, {
48
+ * indoorZoomThreshold,
49
+ * outdoorZoomThreshold,
50
+ * });
51
+ * ```
52
+ *
53
+ * @see {@link CalculateZoomThresholdsOptions} for all configuration options.
54
+ * @deprecated Use the {@link DynamicFocusState.autoZoomThresholds | autoZoomThresholds} option in DynamicFocus state instead.
55
+ */
56
+ export declare const calculateZoomThresholds: (mapView: MapView, userOptions?: CalculateZoomThresholdsOptions) => {
57
+ indoorZoomThreshold: number;
58
+ outdoorZoomThreshold: number;
59
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappedin/dynamic-focus",
3
- "version": "6.17.1-beta.0",
3
+ "version": "6.19.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.17.1",
41
- "@mappedin/react-sdk": "^6.17.1",
42
- "@mappedin/react-native-sdk": "^6.17.1"
40
+ "@mappedin/react-native-sdk": "^6.19.0",
41
+ "@mappedin/react-sdk": "^6.19.0",
42
+ "@mappedin/mappedin-js": "^6.19.0"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@mappedin/react-sdk": {
@@ -63,10 +63,10 @@
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
  "types": "tsc -b",
66
- "test": "pnpm -w test dynamic-focus",
67
- "test:cov": "NODE_ENV=test jest --coverage",
66
+ "test": "jest --config jest.config.js",
67
+ "test:cov": "pnpm test --coverage",
68
68
  "version:ci": "pnpm version --no-commit-hooks --no-git-tag-version",
69
- "clean": "rm -rf lib/** && rm -rf examples/dist/**",
69
+ "clean": "rm -rf lib/** && rm -rf examples/dist/** && rm -f ../.cache/dynamic-focus-cache",
70
70
  "docs": "RN_BUILD=true npx turbo build --filter=@mappedin/dynamic-focus --ui stream && pnpm docs:build",
71
71
  "docs:build": "typedoc"
72
72
  }
@@ -1 +0,0 @@
1
- var Qt=Object.defineProperty,ye=Object.defineProperties;var Se=Object.getOwnPropertyDescriptors;var Kt=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var Jt=s=>{throw TypeError(s)};var xt=(s,t,o)=>t in s?Qt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[t]=o,T=(s,t)=>{for(var o in t||(t={}))Ee.call(t,o)&&xt(s,o,t[o]);if(Kt)for(var o of Kt(t))ve.call(t,o)&&xt(s,o,t[o]);return s},rt=(s,t)=>ye(s,Se(t)),a=(s,t)=>Qt(s,"name",{value:t,configurable:!0});var p=(s,t,o)=>xt(s,typeof t!="symbol"?t+"":t,o),Lt=(s,t,o)=>t.has(s)||Jt("Cannot "+o);var e=(s,t,o)=>(Lt(s,t,"read from private field"),o?o.call(s):t.get(s)),d=(s,t,o)=>t.has(s)?Jt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,o),c=(s,t,o,i)=>(Lt(s,t,"write to private field"),i?i.call(s,o):t.set(s,o),o),E=(s,t,o)=>(Lt(s,t,"access private method"),o);var S={env:{NODE_ENV:"production",npm_package_version:"6.17.1-beta.0"}};import{Floor as Pe,getMultiFloorState as Re}from"@mappedin/mappedin-js";function Xt(s,t){if(s==null||t==null)return s===t;if(s.length!==t.length)return!1;for(let o=0;o<s.length;o++)if(s[o]!==t[o])return!1;return!0}a(Xt,"arraysEqual");var _t=class _t{constructor(){p(this,"_subscribers",{});p(this,"_abortController",new AbortController);p(this,"_cleanupFunctions",[])}get signal(){return this._abortController.signal}publish(t,o){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(o)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,o,i){let r=i==null?void 0:i.signal;if(r!=null&&r.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(o);let n=a(()=>this.off(t,o),"cleanup");return r&&r.addEventListener("abort",n,{once:!0}),this._cleanupFunctions.push(n),n}off(t,o){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(o);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(_t,"PubSub");var wt=_t;import{Facade as Be,Floor as Oe,FloorStack as Ie}from"@mappedin/mappedin-js";var A,at,Z,B,v,k,K,Q,Nt=class Nt{constructor(t,o){p(this,"__type","building");d(this,A);d(this,at,new Map);d(this,Z,new Map);d(this,B,[]);d(this,v);d(this,k);p(this,"defaultFloor");p(this,"activeFloor");p(this,"excluded",!1);p(this,"floorsAltitudesMap",new Map);p(this,"aboveGroundFloors",[]);d(this,K);d(this,Q);var r;c(this,A,t),c(this,at,new Map(t.floors.map(n=>[n.id,n]))),c(this,Z,new Map(t.floors.map(n=>[n.elevation,n]))),c(this,B,Array.from(e(this,Z).values()).sort((n,u)=>n.elevation-u.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,c(this,v,o),this.aboveGroundFloors=e(this,B).filter(n=>n.elevation>=0);let i=(r=t.facade)==null?void 0:r.spaces.map(n=>e(this,v).getState(n)).sort((n,u)=>n.altitude-u.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let n in this.aboveGroundFloors){let u=this.aboveGroundFloors[n],f=i[n];this.floorsAltitudesMap.set(u.elevation,{altitude:f.altitude,visualHeight:f.height})}}get id(){return e(this,A).id}get name(){return e(this,A).name}get floors(){return e(this,A).floors}get floorStack(){return e(this,A)}get facade(){return e(this,A).facade}get isCurrentFloorStack(){return this.id===e(this,v).currentFloorStack.id}get isIndoor(){let t=e(this,v).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 e(this,K)==null&&c(this,K,Math.max(...e(this,Z).keys())),e(this,K)}get minElevation(){return e(this,Q)==null&&c(this,Q,Math.min(...e(this,Z).keys())),e(this,Q)}has(t){return Oe.is(t)?e(this,at).has(t.id):Ie.is(t)?t.id===e(this,A).id:Be.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return e(this,Z).get(t)}getNearestFloorByElevation(t){let o=this.getFloorByElevation(t);if(o)return o;if(t>=0){if(t>this.maxElevation)return e(this,B)[e(this,B).length-1];for(let i=e(this,B).length-1;i>=0;i--){let r=e(this,B)[i];if(r.elevation<=t)return r}}else{if(t<this.minElevation)return e(this,B)[0];for(let i of e(this,B))if(i.elevation>=t)return i}}getHighestFloor(){return e(this,B)[e(this,B).length-1]}cancelAnimation(){e(this,k)&&(e(this,k).animation.cancel(),c(this,k,void 0))}async animateFacade(t,o={duration:150}){var u;let i=((u=e(this,k))==null?void 0:u.state)||e(this,v).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:n}=t;if(e(this,v).updateState(this.facade,{visible:!0}),r!==void 0){c(this,k,{animation:e(this,v).animateState(this.facade,{opacity:r},{duration:o.duration}),state:t});let f=await e(this,k).animation;if(c(this,k,void 0),f.result==="cancelled")return f}return n===!1&&e(this,v).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),e(this,A).floors.forEach(t=>{e(this,v).updateState(t,{visible:t.id===e(this,v).currentFloor.id})}),this.has(e(this,v).currentFloor)||e(this,v).updateState(this.facade,{visible:!0,opacity:1})}};A=new WeakMap,at=new WeakMap,Z=new WeakMap,B=new WeakMap,v=new WeakMap,k=new WeakMap,K=new WeakMap,Q=new WeakMap,a(Nt,"Building");var Bt=Nt;function te(s,t,o){return s>=t?"in-range":s<=o?"out-of-range":"transition"}a(te,"getZoomState");function Ot(s,t,o){if(s.__type==="outdoors"&&"floor"in s)return s.floor;let i=s;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(o);case"nearest-elevation":return i.getNearestFloorByElevation(o);default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Ot,"getFloorToShow");function Ae(s,t,o,i){return i?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:o?{facade:s,state:{type:"facade",visible:!0,opacity:.2}}:{facade:s,state:{type:"facade",visible:!0,opacity:1}}}a(Ae,"getFacadeState");function Ve(s,t,o){return{outdoorOpacity:"initial",floorStates:s.floors.map(i=>{let n=i.id===t.id&&o;return{floor:i,state:{type:"floor",visible:n,geometry:{visible:n},labels:{enabled:n},markers:{enabled:n},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}a(Ve,"getSingleBuildingState");function ee(s,t){if(!t.includes("lock-elevation"))return"initial";for(let o of s)if(typeof o.outdoorOpacity=="number"&&o.outdoorOpacity>=0&&o.outdoorOpacity<=1)return o.outdoorOpacity;return"initial"}a(ee,"getOutdoorOpacity");function oe(s,t,o){var i;switch(o){case"in-range":return(i=s[0])!=null&&i.canSetFloor?s[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(oe,"getSetFloorTargetFromZoomState");function ie(s){var z;let{buildings:t,inViewSet:o,currentFloor:i,zoomState:r,mode:n,elevation:u,floorIdsInNavigation:f,floorStackIdsInNavigation:g,multiFloorView:m,getMultiFloorState:$,dynamicBuildingInteriors:V,isolateBelowGroundView:st,currentElevation:nt,forceInteriorsVisible:St,getFloorStackAltitudeData:I}=s,_=new Map,kt=st&&nt<0&&r==="in-range";for(let b of t){let Et=o.has(b.id),H=kt&&b.minElevation>=0,vt=H?!1:Et,Dt=H?!1:Ct({building:b,currentFloor:i,inRange:r==="in-range",inFocus:Et,mode:n,elevation:u,inNavigation:g.includes(b.id),dynamicBuildingInteriors:V,forceInteriorsVisible:St}),Mt=i.floorStack.id===b.id?b.activeFloor:Ot(b,n,u),ge=m!=null&&m.enabled?$(b.floors,Mt||b.activeFloor,f,(z=I==null?void 0:I(b.id))!=null?z:b.floorsAltitudesMap,{color:m==null?void 0:m.footprintColor,spacesOpenToBelowEnabled:m==null?void 0:m.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:m==null?void 0:m.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:m==null?void 0:m.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:m==null?void 0:m.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:m==null?void 0:m.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:m==null?void 0:m.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:m==null?void 0:m.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:m==null?void 0:m.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:m==null?void 0:m.footprintOpacity,outline:m==null?void 0:m.footprintOutline}):Ve(b.floorStack,Mt||b.activeFloor,Dt),Fe=st&&nt<0&&r==="in-range",be=Ae(b.facade,Dt,Fe,H);_.set(b.id,{building:b,showIndoor:Dt,floorStackState:ge,facadeState:be,inFocus:vt,floorToShow:Mt,isAboveGroundInIsolation:H})}return _}a(ie,"getBuildingStates");function se(s,t){return s.excluded?"none":t?"indoor":"outdoor"}a(se,"getBuildingAnimationType");function Ct(s){let{building:t,currentFloor:o,inRange:i,inFocus:r,mode:n,elevation:u,inNavigation:f,dynamicBuildingInteriors:g,forceInteriorsVisible:m}=s;if(t.id===o.floorStack.id)return!0;if(t.excluded)return!1;if(m===!0||f===!0)return!0;if(!g)return o.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(u)!=null;default:break}return!0}a(Ct,"shouldShowIndoor");function ne(s,t,o){return s!==t&&!o}a(ne,"shouldDeferSetFloor");var re=["default-floor","lock-elevation","nearest-elevation"];import{Floor as ke,FloorStack as De}from"@mappedin/mappedin-js";var Gt="[MappedinJS]";function Zt(s="",{prefix:t=Gt}={}){let o="".concat(t).concat(s?"-".concat(s):""),i=a((r,n)=>{if(typeof window<"u"&&window.rnDebug){let u=n.map(f=>f instanceof Error&&f.stack?"".concat(f.message,"\n").concat(f.stack):f);window.rnDebug("".concat(s," ").concat(r,": ").concat(u.join(" ")))}},"rnDebug");return{logState:S.env.NODE_ENV==="test"?3:0,log(...r){this.logState<=0&&(console.log(o,...r),i("log",r))},warn(...r){this.logState<=1&&(console.warn(o,...r),i("warn",r))},error(...r){this.logState<=2&&(console.error(o,...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(Zt,"createLogger");var Te=Zt();var J=Te;function ae(s,t,o,i){return(s<t||s>o)&&J.warn(i),Math.min(o,Math.max(t,s))}a(ae,"clampWithWarning");function Pt(s,t){return!ke.is(s)||(s==null?void 0:s.floorStack)==null||!De.is(t)?!1:s.floorStack.id!==t.id?(J.warn("Floor (".concat(s.id,") does not belong to floor stack (").concat(t.id,").")),!1):!0}a(Pt,"validateFloorForStack");function Rt(s,t,o,i){return ae(s,t,o,"".concat(i," must be between ").concat(t," and ").concat(o,"."))}a(Rt,"validateZoomThreshold");var X=Zt("",{prefix:"[DynamicFocus]"});var D,tt,lt,Ut,jt=class jt{constructor(t,o){d(this,lt);p(this,"__type","outdoors");d(this,D);d(this,tt);c(this,D,t),c(this,tt,o)}get id(){return e(this,D).id}get floorStack(){return e(this,D)}get floor(){return e(this,D).defaultFloor}matchesFloorStack(t){return t===e(this,D)||t===e(this,D).id}show(){E(this,lt,Ut).call(this,!0)}hide(){E(this,lt,Ut).call(this,!1)}destroy(){this.matchesFloorStack(e(this,tt).currentFloorStack)||this.hide()}};D=new WeakMap,tt=new WeakMap,lt=new WeakSet,Ut=a(function(t){for(let o of e(this,D).floors)e(this,tt).updateState(o,{visible:t})},"#setVisible"),a(jt,"Outdoors");var It=jt;function le(s,t){let o=s.getByType("floor-stack"),i=o.find(n=>{var u;return((u=n.type)==null?void 0:u.toLowerCase())==="outdoor"});if(i)return i;let r=o.find(n=>n.facade==null&&!t.has(n.id));return r||(X.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),o[0])}a(le,"getOutdoorFloorStack");var ue={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1},Io=.2,Ao=.4;function Me(s,t){return"".concat(t," ").concat(s)}a(Me,"formatMessage");var $t=class $t extends Error{constructor(t,o=Gt){super(Me(t,o)),this.name="MappedinError"}};a($t,"MappedinError");var At=$t;var xe=a(s=>s,"linearEase"),Le=a(s=>s*s,"quadEaseIn"),_e=a(s=>1-Math.cos(s*Math.PI/2),"easeIn"),Ne=a(s=>1-(1-s)*(1-s),"quadEaseOut"),Ce=a(s=>1-Math.pow(1-s,3),"cubicEaseOut"),Ge={linear:xe,"ease-in":Le,"ease-out":Ne,"ease-in-out":_e,"ease-out-cubic":Ce};function Ze(s,t){let o=0;if(t.length<2)return o;let r=t[0]<t[1]?(n,u)=>n>u:(n,u)=>n<u;for(;o<t.length-1&&r(s,t[o+1]);)o++;return o>t.length-2?Math.max(0,t.length-2):o}a(Ze,"getInterpolationBreakpoint");function ce(s,t,o,i="ease-in"){if(t.length!==o.length)throw new At("Input and output ranges must have the same number of values.");s=Math.max(t[0],Math.min(s,t[t.length-1]));let r=Ze(s,t),n=(s-t[r])/(t[r+1]-t[r]),u=typeof i=="function"?i(n):Ge[i](n);return o[r]+u*(o[r+1]-o[r])}a(ce,"interpolateMulti");var M,ut,ct,N,dt,qt=class qt{constructor(t,o,i){p(this,"layers");p(this,"visible");d(this,M);d(this,ut,[]);d(this,ct,!1);d(this,N,new Map);p(this,"interpolationFn");d(this,dt,1);this.layers=t,this.visible=o,c(this,M,i)}processLayerGroup(t,o,i){if(!e(this,ct)&&(this.layers.forEach(r=>{let n=t[r];n&&e(this,ut).push(...n)}),c(this,ct,!0),this.visible)){let r=[o,i],n=[1,0];this.interpolationFn=u=>ce(u,r,n)}}setOpacity(t){var o,i,r;c(this,dt,t);for(let n of e(this,ut))if(n.startsWith("img_")){let u=e(this,M).Image3D.getById(n);if(u){let f=e(this,M).getState(u.image);e(this,N).has(n)||e(this,N).set(n,(o=f==null?void 0:f.opacity)!=null?o:1);let g=Math.min(e(this,N).get(n),t);e(this,M).updateState(u.image,{opacity:g})}}else{let u=(i=e(this,M).getMapData())==null?void 0:i.getById("space",n);if(!u)continue;let f=e(this,M).getState(u);e(this,N).has(n)||e(this,N).set(n,(r=f==null?void 0:f.opacity)!=null?r:1);let g=Math.min(e(this,N).get(n),t);e(this,M).updateState(u,{opacity:g,visible:g>0})}}get opacity(){return e(this,dt)}};M=new WeakMap,ut=new WeakMap,ct=new WeakMap,N=new WeakMap,dt=new WeakMap,a(qt,"LayerGroup");var Vt=qt;function Yt(s,t){s.forEach(o=>{if(o.interpolationFn!=null){let i=o.interpolationFn(t);i!=null&&(o.setOpacity(i),o.visible=i===1)}})}a(Yt,"runLayerGroupInterpolations");var O,l,P,h,Y,q,y,C,W,G,w,et,ht,ft,mt,x,R,ot,U,j,F,Wt,he,fe,zt,pt,gt,Ft,bt,yt,it,Tt,me,pe,L,Ht=class Ht{constructor(t){d(this,F);d(this,O);d(this,l);d(this,P);d(this,h,ue);d(this,Y,[]);d(this,q,new Set);d(this,y,new Map);d(this,C);d(this,W,!1);d(this,G,!1);d(this,w,0);d(this,et,0);d(this,ht,[]);d(this,ft,{});d(this,mt,{});d(this,x,"transition");d(this,R,"outdoor");d(this,ot,[]);d(this,U,!1);d(this,j,[]);p(this,"sceneUpdateQueue",Promise.resolve());p(this,"on",a((t,o)=>{e(this,O).on(t,o)},"on"));p(this,"off",a((t,o)=>{e(this,O).off(t,o)},"off"));d(this,pt,a(t=>{if(!this.isEnabled)return;let{facades:o}=t;if(Xt(o,this.focusedFacades)&&e(this,R)==="transition"&&!e(this,G))return;c(this,G,!1),c(this,Y,[]),e(this,q).clear();let i=e(this,h).isolateBelowGroundView&&e(this,w)<0;if(o.length>0)for(let r of o){let n=e(this,y).get(r.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;e(this,q).add(n.id),e(this,Y).push(n)}}e(this,h).autoFocus&&this.focus()},"#handleFacadesInViewChange"));d(this,gt,a(async t=>{var f,g,m,$;if(!this.isEnabled)return;let{floor:o}=t,i=e(this,y).get(o.floorStack.id);i&&(i.activeFloor=o);let r=e(this,h).isolateBelowGroundView&&e(this,w)<0;(i==null?void 0:i.excluded)===!1&&!e(this,C).matchesFloorStack(o.floorStack)&&c(this,w,o.elevation);let n=e(this,h).isolateBelowGroundView&&e(this,w)<0,u=r&&!n;if(e(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(u?(c(this,G,!0),e(this,l).Camera.updateFacadesInView(),e(this,h).autoFocus||(await e(this,L).call(this,o),e(this,O).publish("focus",{facades:this.focusedFacades}))):(await e(this,L).call(this,o),e(this,O).publish("focus",{facades:this.focusedFacades})));let V=(g=(f=i==null?void 0:i.floorsAltitudesMap.get(o.elevation))==null?void 0:f.altitude)!=null?g:0;e(this,l).options.multiFloorView!=null&&((m=e(this,l).options.multiFloorView)!=null&&m.enabled)&&(($=e(this,l).options.multiFloorView)!=null&&$.updateCameraElevationOnFloorChange)&&e(this,l).Camera.elevation!==V&&e(this,l).Camera.animateElevation(V,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));d(this,Ft,a(()=>{c(this,W,!0)},"#handleUserInteractionStart"));d(this,bt,a(()=>{c(this,W,!1)},"#handleUserInteractionEnd"));d(this,yt,a(()=>{e(this,L).call(this)},"#handleGlobalStateChange"));d(this,it,a(t=>{if(!this.isEnabled)return;let{zoomLevel:o}=t,i=te(o,e(this,h).indoorZoomThreshold,e(this,h).outdoorZoomThreshold);e(this,x)!==i&&(c(this,x,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Yt(e(this,j),o)},"#handleCameraChange"));d(this,L,a(async t=>{var g,m,$;if(e(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let o=t||e(this,l).currentFloor,i=e(this,l).getGlobalState().multiFloorView,r=e(this,l).options.multiFloorView?T(T({},e(this,l).options.multiFloorView),i):e(this,l).options.multiFloorView,n=((m=(g=e(this,l).Navigation)==null?void 0:g.floors)==null?void 0:m.map(V=>V.id))||[],u=(($=e(this,l).Navigation)==null?void 0:$.floorStacks.map(V=>V.id))||[],f=new Promise(async V=>{var St;await this.sceneUpdateQueue;let st=ie({buildings:Array.from(e(this,y).values()),inViewSet:e(this,q),currentFloor:o,zoomState:e(this,x),mode:e(this,h).mode,elevation:e(this,w),floorIdsInNavigation:n,floorStackIdsInNavigation:u,multiFloorView:r,getMultiFloorState:(St=e(this,h).customMultiFloorVisibilityState)!=null?St:Re,dynamicBuildingInteriors:e(this,h).dynamicBuildingInteriors,isolateBelowGroundView:e(this,h).isolateBelowGroundView,currentElevation:e(this,w),forceInteriorsVisible:e(this,h).forceInteriorsVisible,getFloorStackAltitudeData:a(I=>e(this,l).getFloorStackAltitudeData(I),"getFloorStackAltitudeData")}),nt=[];await Promise.all(Array.from(st.values()).map(async I=>{let{building:_,showIndoor:kt,floorStackState:z,facadeState:b,inFocus:Et,isAboveGroundInIsolation:H}=I;nt.push(z);let vt=se(_,kt);if(vt==="indoor")return E(this,F,me).call(this,_,z,b,Et);if(vt==="outdoor")return E(this,F,pe).call(this,_,z,b,u,H)})),e(this,l).Outdoor.setOpacity(ee(nt,e(this,h).mode)),c(this,ot,e(this,Y).filter(I=>{var _;return((_=st.get(I.id))==null?void 0:_.showIndoor)===!0}).map(I=>I.facade)),e(this,O).publish("focus",{facades:e(this,ot)}),V()});return this.sceneUpdateQueue=f,f},"#applyBuildingStates"));c(this,O,new wt),c(this,l,t),X.setLevel(J.logState),c(this,P,e(this,l).getMapData()),c(this,w,e(this,l).currentFloor.elevation),c(this,et,e(this,l).Camera.elevation);for(let o of e(this,P).getByType("facade"))e(this,y).set(o.floorStack.id,new Bt(o.floorStack,e(this,l)));E(this,F,fe).call(this),c(this,C,new It(le(e(this,P),e(this,y)),e(this,l))),e(this,l).on("floor-change-start",e(this,gt)),e(this,l).on("camera-change",e(this,it)),e(this,l).on("facades-in-view-change",e(this,pt)),e(this,l).on("user-interaction-start",e(this,Ft)),e(this,l).on("user-interaction-end",e(this,bt)),e(this,l).on("global-state-change",e(this,yt))}enable(t){if(e(this,U)){X.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,U,!0),e(this,l).manualFloorVisibility=!0,e(this,C).show(),this.updateState(T(T({},e(this,h)),t)),E(this,F,he).call(this),e(this,it).call(this,{zoomLevel:e(this,l).Camera.zoomLevel,center:e(this,l).Camera.center,bearing:e(this,l).Camera.bearing,pitch:e(this,l).Camera.pitch}),e(this,l).Camera.updateFacadesInView()}disable(){if(!e(this,U)){X.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,U,!1),e(this,l).manualFloorVisibility=!1}get isEnabled(){return e(this,U)}get isIndoor(){return e(this,R)==="indoor"}get isOutdoor(){return e(this,R)==="outdoor"}get outdoorsFloorStack(){return e(this,C).floorStack}get layers(){return e(this,ht)}get layersBySpaceId(){return e(this,ft)}setIndoor(){c(this,R,"indoor"),c(this,x,"in-range"),E(this,F,Wt).call(this)}setOutdoor(){c(this,R,"outdoor"),c(this,x,"out-of-range"),E(this,F,Wt).call(this)}get focusedFacades(){return[...e(this,ot)]}getState(){return T({},e(this,h))}updateState(t){var r,n;let o=!1,i=e(this,h).isolateBelowGroundView&&e(this,w)<0;if(t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=Rt(t.indoorZoomThreshold,(r=t==null?void 0:t.outdoorZoomThreshold)!=null?r:e(this,h).outdoorZoomThreshold,e(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),o=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=Rt(t.outdoorZoomThreshold,e(this,l).Camera.minZoomLevel,(n=t==null?void 0:t.indoorZoomThreshold)!=null?n:e(this,h).indoorZoomThreshold,"outdoorZoomThreshold"),o=!0),t.mode!=null&&(t.mode=re.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(e(this,h).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==e(this,h).dynamicBuildingInteriors&&(o=!0),t.isolateBelowGroundView!=null&&t.isolateBelowGroundView!==e(this,h).isolateBelowGroundView&&(o=!0),t.forceInteriorsVisible!=null&&t.forceInteriorsVisible!==e(this,h).forceInteriorsVisible&&(o=!0),t.showLabelsAndMarkersOnAllVisibleFloors!=null&&t.showLabelsAndMarkersOnAllVisibleFloors!==e(this,h).showLabelsAndMarkersOnAllVisibleFloors&&(o=!0),c(this,h,Object.assign({},e(this,h),Object.fromEntries(Object.entries(t).filter(([,u])=>u!=null)))),t.mode!=null&&t.preloadFloors&&E(this,F,zt).call(this,t.mode),o){let u=e(this,h).isolateBelowGroundView&&e(this,w)<0;i&&!u?(c(this,G,!0),e(this,l).Camera.updateFacadesInView(),e(this,h).autoFocus||e(this,L).call(this)):e(this,L).call(this)}}destroy(){this.disable(),e(this,l).off("facades-in-view-change",e(this,pt)),e(this,l).off("floor-change-start",e(this,gt)),e(this,l).off("camera-change",e(this,it)),e(this,l).off("user-interaction-start",e(this,Ft)),e(this,l).off("user-interaction-end",e(this,bt)),e(this,l).off("global-state-change",e(this,yt)),e(this,y).forEach(t=>t.destroy()),e(this,C).destroy(),e(this,O).destroy(),c(this,j,[])}async focus(t=e(this,h).setFloorOnFocus){if(t)if(ne(e(this,et),e(this,l).Camera.elevation,e(this,W)))c(this,et,e(this,l).Camera.elevation),c(this,G,!0);else{let o=oe(e(this,Y),e(this,C),e(this,x)),i=o?Ot(o,e(this,h).mode,e(this,w)):void 0;i&&i.id!==e(this,l).currentFloor.id&&e(this,l).setFloor(i,{context:"dynamic-focus"})}await e(this,L).call(this),e(this,O).publish("focus",{facades:this.focusedFacades})}preloadFloors(){E(this,F,zt).call(this,e(this,h).mode)}setDefaultFloorForStack(t,o){if(!Pt(o,t))return;let i=e(this,y).get(t.id);i&&(i.defaultFloor=o)}resetDefaultFloorForStack(t){let o=e(this,y).get(t.id);o&&(o.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){var o;return((o=e(this,y).get(t.id))==null?void 0:o.defaultFloor)||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,o){if(!Pt(o,t))return;let i=e(this,y).get(t.id);i&&(i.activeFloor=o,e(this,L).call(this))}exclude(t){let o=Array.isArray(t)?t:[t];for(let i of o){let r=e(this,y).get(i.id);r&&(r.excluded=!0)}}include(t){let o=Array.isArray(t)?t:[t];for(let i of o){let r=e(this,y).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){var o;return((o=e(this,y).get(t.id))==null?void 0:o.activeFloor)||this.getDefaultFloorForStack(t)}};O=new WeakMap,l=new WeakMap,P=new WeakMap,h=new WeakMap,Y=new WeakMap,q=new WeakMap,y=new WeakMap,C=new WeakMap,W=new WeakMap,G=new WeakMap,w=new WeakMap,et=new WeakMap,ht=new WeakMap,ft=new WeakMap,mt=new WeakMap,x=new WeakMap,R=new WeakMap,ot=new WeakMap,U=new WeakMap,j=new WeakMap,F=new WeakSet,Wt=a(function(){e(this,h).autoFocus&&(e(this,W)?this.focus():c(this,G,!0)),e(this,O).publish("state-change")},"#handleViewStateChange"),he=a(function(){c(this,j,[]);for(let t of e(this,h).dynamicLayers){let o=new Vt([t],!0,e(this,l));o.processLayerGroup(e(this,mt),e(this,h).outdoorZoomThreshold,e(this,h).indoorZoomThreshold),e(this,j).push(o)}Yt(e(this,j),e(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),fe=a(function(){var r,n,u;let t=(u=(n=(r=e(this,P).internal.mvf)==null?void 0:r.enterprise)==null?void 0:n.layers)!=null?u:[],o={},i={};t.forEach(f=>{o[f.name]||(o[f.name]=[]),o[f.name].push(...f.spaces.map(({spaceId:g})=>g));for(let{spaceId:g}of f.spaces)i[g]==null&&(i[g]=[]),i[g].push(f.name)}),c(this,ht,t.map(({name:f})=>f)),c(this,ft,i),c(this,mt,o)},"#setupLayers"),zt=a(function(t){e(this,l).preloadFloors(e(this,P).getByType("facade").map(o=>Ot(e(this,y).get(o.floorStack.id),t,e(this,w))).filter(o=>o!=null&&Pe.is(o)))},"#preloadFloors"),pt=new WeakMap,gt=new WeakMap,Ft=new WeakMap,bt=new WeakMap,yt=new WeakMap,it=new WeakMap,Tt=a(function(t,o,i,r=!1){t.forEach(n=>{if(n.floor)if(o){let f=i!==void 0&&!r?rt(T({},n.state),{labels:rt(T({},n.state.labels),{enabled:n.state.labels.enabled&&i}),markers:rt(T({},n.state.markers),{enabled:n.state.markers.enabled&&i}),occlusion:rt(T({},n.state.occlusion),{enabled:n.state.occlusion.enabled&&i})}):n.state;e(this,l).updateState(n.floor,f)}else e(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),me=a(async function(t,o,i,r){return E(this,F,Tt).call(this,o.floorStates,!0,r,e(this,h).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,e(this,h).indoorAnimationOptions)},"#animateIndoorSequence"),pe=a(async function(t,o,i,r,n){let u=n;u&&E(this,F,Tt).call(this,o.floorStates,!1,void 0,e(this,h).showLabelsAndMarkersOnAllVisibleFloors);let f=await t.animateFacade(i.state,e(this,h).outdoorAnimationOptions);return f.result==="completed"&&!u&&E(this,F,Tt).call(this,o.floorStates,Ct({building:t,currentFloor:e(this,l).currentFloor,inRange:e(this,x)==="in-range",inFocus:e(this,q).has(t.id),mode:e(this,h).mode,elevation:e(this,w),inNavigation:r.includes(t.floorStack.id),dynamicBuildingInteriors:e(this,h).dynamicBuildingInteriors,forceInteriorsVisible:e(this,h).forceInteriorsVisible}),void 0,e(this,h).showLabelsAndMarkersOnAllVisibleFloors),f},"#animateOutdoorSequence"),L=new WeakMap,a(Ht,"DynamicFocus");var de=Ht;export{a,Io as b,Ao as c,de as d};