@mappedin/dynamic-focus 6.28.0-beta.0 → 6.30.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 rt=Object.defineProperty;var st=s=>{throw TypeError(s)};var It=(s,t,e)=>t in s?rt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t)=>rt(s,"name",{value:t,configurable:!0});var E=(s,t,e)=>It(s,typeof t!="symbol"?t+"":t,e),xo=(s,t,e)=>t.has(s)||st("Cannot "+e);var o=(s,t,e)=>(xo(s,t,"read from private field"),e?e.call(s):t.get(s)),d=(s,t,e)=>t.has(s)?st("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),c=(s,t,e,i)=>(xo(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e),F=(s,t,e)=>(xo(s,t,"access private method"),e);var y={env:{NODE_ENV:"production",npm_package_version:"6.30.0-beta.0"}};var ro={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!0,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},cameraLiftAnimationOptions:{duration:500,easing:"ease-in-out",interruptible:!0},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},so=.2,Co=.4;var Go="[MappedinJS]";var Bt={log:0,debug:0,info:1,warn:2,error:3,silent:4};function Dt(s){return Bt[s.toLowerCase()]}a(Dt,"parseLogLevel");function Ro(s="",{prefix:t=Go}={}){let e=`${t}${s?`-${s}`:""}`,i=a((r,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(p=>p instanceof Error&&p.stack?`${p.message}
|
|
2
|
+
${p.stack}`:p);window.rnDebug(`${s} ${r}: ${f.join(" ")}`)}},"rnDebug");return{logState:y.env.NODE_ENV==="test"?4:1,debug(...r){this.logState<=0&&(console.debug(e,...r),i("debug",r))},log(...r){this.debug(...r)},info(...r){this.logState<=1&&(console.info(e,...r),i("info",r))},warn(...r){this.logState<=2&&(console.warn(e,...r),i("warn",r))},error(...r){this.logState<=3&&(console.error(e,...r),i("error",r))},assert(...r){console.assert(...r)},time(r){console.time(r)},timeEnd(r){console.timeEnd(r)},setLevel(r){let n=typeof r=="string"?Dt(r):r;if(n===void 0||!(n>=0&&n<=4)){console.warn(e,`setLevel: unknown log level "${r}"`);return}this.logState=n}}}a(Ro,"createLogger");var Lt=Ro();var K=Lt;var V=Ro("",{prefix:"[DynamicFocus]"});var nt=a((s,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Mt(s,e);if(i===void 0)return V.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:ro.indoorZoomThreshold,outdoorZoomThreshold:ro.outdoorZoomThreshold};let r=i+Co,n=i+so;return e.initialVisibility==="indoor-first"&&(r=i-so,n=i-Co),{indoorZoomThreshold:r,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Mt(s,t){let i=s.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),r=1/0,n;for(let f of i){let p=s.Camera.getFocusOnTransform(f).zoomLevel??1/0;p<r&&(r=p,n=f)}if(r!==1/0)return t.debug&&n&&s.Camera.getFocusOnTransform(n,{debugColor:"blue"}),r}a(Mt,"getDefaultZoomLevel");import{Floor as Ht,getMultiFloorState as Kt}from"@mappedin/mappedin-js";function at(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(at,"arraysEqual");var Po=class Po{_subscribers={};_abortController=new AbortController;get signal(){return this._abortController.signal}getSubscribers(t){if(!(!this._subscribers||!this._subscribers[t]||this.signal.aborted))return this._subscribers[t]}publish(t,e){let i=this.getSubscribers(t);i&&i.forEach(function(r){typeof r=="function"&&r(e)})}hasSubscribers(t){return!!this.getSubscribers(t)?.length}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}),n}off(t,e){let i=this.getSubscribers(t);if(!i)return;let r=i.indexOf(e);r!==-1&&i.splice(r,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(Po,"PubSub");var wo=Po;import{Facade as Nt,Floor as Zt,FloorStack as _t}from"@mappedin/mappedin-js";var I,no,G,O,w,k,Q,J,Uo=class Uo{constructor(t,e){E(this,"__type","building");d(this,I);d(this,no,new Map);d(this,G,new Map);d(this,O,[]);d(this,w);d(this,k);E(this,"defaultFloor");E(this,"activeFloor");E(this,"excluded",!1);E(this,"aboveGroundFloors",[]);d(this,Q);d(this,J);c(this,I,t),c(this,no,new Map(t.floors.map(r=>[r.id,r]))),c(this,G,new Map(t.floors.map(r=>[r.elevation,r]))),c(this,O,Array.from(o(this,G).values()).sort((r,n)=>r.elevation-n.elevation));let i=t.defaultFloor;if(!i)throw new Error(`Building created for floor stack "${t.id}" with no resolvable default floor`);this.defaultFloor=i,this.activeFloor=this.defaultFloor,c(this,w,e),this.aboveGroundFloors=o(this,O).filter(r=>r.elevation>=0)}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,w).currentFloorStack.id}get isIndoor(){let t=o(this,w).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&&c(this,Q,Math.max(...o(this,G).keys())),o(this,Q)}get minElevation(){return o(this,J)==null&&c(this,J,Math.min(...o(this,G).keys())),o(this,J)}has(t){return Zt.is(t)?o(this,no).has(t.id):_t.is(t)?t.id===o(this,I).id:Nt.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,G).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,O)[o(this,O).length-1];for(let i=o(this,O).length-1;i>=0;i--){let r=o(this,O)[i];if(r.elevation<=t)return r}}else{if(t<this.minElevation)return o(this,O)[0];for(let i of o(this,O))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,O)[o(this,O).length-1]}cancelAnimation(){o(this,k)&&(o(this,k).animation.cancel(),c(this,k,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,k)?.state||o(this,w).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,w).updateState(this.facade,{visible:!0}),r!==void 0){c(this,k,{animation:o(this,w).animateState(this.facade,{opacity:r},{duration:e.duration}),state:t});let f=await o(this,k).animation;if(c(this,k,void 0),f.result==="cancelled")return f}return n===!1&&o(this,w).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,I).floors.forEach(t=>{o(this,w).updateState(t,{visible:t.id===o(this,w).currentFloor.id})}),this.has(o(this,w).currentFloor)||o(this,w).updateState(this.facade,{visible:!0,opacity:1})}};I=new WeakMap,no=new WeakMap,G=new WeakMap,O=new WeakMap,w=new WeakMap,k=new WeakMap,Q=new WeakMap,J=new WeakMap,a(Uo,"Building");var Oo=Uo;function lt(s,t,e){return s>=t?"in-range":s<=e?"out-of-range":"transition"}a(lt,"getZoomState");function Vo(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);case"active-floor":return i.activeFloor;default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Vo,"getFloorToShow");function xt(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(xt,"getFacadeState");function Ct(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(Ct,"getSingleBuildingState");function ut(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(ut,"getOutdoorOpacity");function dt(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(dt,"getSetFloorTargetFromZoomState");function ct(s){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:r,mode:n,elevation:f,floorIdsInNavigation:p,floorStackIdsInNavigation:T,showAllFloorsIncludedInNavigation:h,multiFloorView:g,getMultiFloorState:j,dynamicBuildingInteriors:A,isolateBelowGroundView:H,currentElevation:So,forceInteriorsVisible:io,getFloorStackAltitudeData:Eo}=s,vo=new Map,No=H&&So<0&&r==="in-range";for(let b of t){let it=e.has(b.id),To=No&&b.minElevation>=0,wt=To?!1:it,Zo=To?!1:$o({building:b,currentFloor:i,inRange:r==="in-range",inFocus:it,mode:n,elevation:f,inNavigation:T.includes(b.id),dynamicBuildingInteriors:A,forceInteriorsVisible:io}),_o=i.floorStack.id===b.id?b.activeFloor:Vo(b,n,f),Ot=g?.enabled?j(b.floors,_o||b.activeFloor,p,Eo(b.id),{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},h):Ct(b.floorStack,_o||b.activeFloor,Zo),Vt=H&&So<0&&r==="in-range",At=xt(b.facade,Zo,Vt,To);vo.set(b.id,{building:b,showIndoor:Zo,floorStackState:Ot,facadeState:At,inFocus:wt,floorToShow:_o,isAboveGroundInIsolation:To})}return vo}a(ct,"getBuildingStates");function ht(s,t){return s.excluded?"none":t?"indoor":"outdoor"}a(ht,"getBuildingAnimationType");function $o(s){let{building:t,currentFloor:e,inRange:i,inFocus:r,mode:n,elevation:f,inNavigation:p,dynamicBuildingInteriors:T,forceInteriorsVisible:h}=s;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(h===!0||p===!0)return!0;if(!T)return e.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(f)!=null;default:break}return!0}a($o,"shouldShowIndoor");function ft(s,t,e){return s!==t&&!e}a(ft,"shouldDeferSetFloor");var mt=["default-floor","active-floor","lock-elevation","nearest-elevation"];import{Floor as Gt,FloorStack as Rt}from"@mappedin/mappedin-js";function pt(s,t,e,i){return(s<t||s>e)&&K.warn(i),Math.min(e,Math.max(t,s))}a(pt,"clampWithWarning");function jo(s,t){return!Gt.is(s)||s?.floorStack==null||!Rt.is(t)?!1:s.floorStack.id!==t.id?(K.warn(`Floor (${s.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(jo,"validateFloorForStack");function zo(s,t,e,i){return pt(s,t,e,`${i} must be between ${t} and ${e}.`)}a(zo,"validateZoomThreshold");var B,X,ao,Yo,Wo=class Wo{constructor(t,e){d(this,ao);E(this,"__type","outdoors");d(this,B);d(this,X);c(this,B,t),c(this,X,e)}get id(){return o(this,B).id}get floorStack(){return o(this,B)}get floor(){return o(this,B).defaultFloor}matchesFloorStack(t){return t===o(this,B)||t===o(this,B).id}show(){F(this,ao,Yo).call(this,!0)}hide(){F(this,ao,Yo).call(this,!1)}destroy(){this.matchesFloorStack(o(this,X).currentFloorStack)||this.hide()}};B=new WeakMap,X=new WeakMap,ao=new WeakSet,Yo=a(function(t){for(let e of o(this,B).floors)o(this,X).updateState(e,{visible:t})},"#setVisible"),a(Wo,"Outdoors");var Ao=Wo;function gt(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||(V.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(gt,"getOutdoorFloorStack");function Pt(s,t){return`${t} ${s}`}a(Pt,"formatMessage");var qo=class qo extends Error{constructor(t,e=Go){super(Pt(t,e)),this.name="MappedinError"}};a(qo,"MappedinError");var Io=qo;var Ut=a(s=>s,"linearEase"),$t=a(s=>s*s,"quadEaseIn"),jt=a(s=>1-Math.cos(s*Math.PI/2),"easeIn"),zt=a(s=>1-(1-s)*(1-s),"quadEaseOut"),Yt=a(s=>1-Math.pow(1-s,3),"cubicEaseOut"),Wt={linear:Ut,"ease-in":$t,"ease-out":zt,"ease-in-out":jt,"ease-out-cubic":Yt};function qt(s,t){let e=0;if(t.length<2)return e;let r=t[0]<t[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<t.length-1&&r(s,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(qt,"getInterpolationBreakpoint");function Ft(s,t,e,i="ease-in"){if(t.length!==e.length)throw new Io("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=qt(s,t),n=(s-t[r])/(t[r+1]-t[r]),f=typeof i=="function"?i(n):Wt[i](n);return e[r]+f*(e[r+1]-e[r])}a(Ft,"interpolateMulti");var D,lo,uo,_,co,Ko=class Ko{constructor(t,e,i){E(this,"layers");E(this,"visible");d(this,D);d(this,lo,[]);d(this,uo,!1);d(this,_,new Map);E(this,"interpolationFn");d(this,co,1);this.layers=t,this.visible=e,c(this,D,i)}processLayerGroup(t,e){o(this,uo)||(this.layers.forEach(i=>{let r=t[i];r&&o(this,lo).push(...r)}),c(this,uo,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:r,indoorZoomThreshold:n}=e();return Ft(i,[r,n],[1,0])}))}setOpacity(t){c(this,co,t);for(let e of o(this,lo))if(e.startsWith("img_")){let i=o(this,D).Image3D.getById(e);if(i){if(!o(this,_).has(e)){let n=o(this,D).getState(i.image);o(this,_).set(e,n?.opacity??1)}let r=Math.min(o(this,_).get(e),t);o(this,D).updateState(i.image,{opacity:r})}}else{let i=o(this,D).getMapData()?.getById("space",e);if(!i)continue;if(!o(this,_).has(e)){let n=o(this,D).getState(i);o(this,_).set(e,n?.opacity??1)}let r=Math.min(o(this,_).get(e),t);o(this,D).updateState(i,{opacity:r,visible:r>0})}}get opacity(){return o(this,co)}};D=new WeakMap,lo=new WeakMap,uo=new WeakMap,_=new WeakMap,co=new WeakMap,a(Ko,"LayerGroup");var ko=Ko;function Ho(s,t,e){s.forEach(i=>{if(e?.forceOpacity!==void 0){i.setOpacity(e.forceOpacity),i.visible=e.forceOpacity===1;return}if(i.interpolationFn!=null){let r=i.interpolationFn(t);r!=null&&(i.setOpacity(r),i.visible=r===1)}})}a(Ho,"runLayerGroupInterpolations");var L,l,R,u,z,Y,S,M,W,x,v,q,ho,fo,mo,N,P,oo,po,Z,U,$,m,Qo,yt,Jo,Xo,ot,St,tt,to,go,Et,Do,Lo,Mo,Fo,bo,yo,eo,Bo,vt,Tt,C,et=class et{constructor(t){d(this,m);d(this,L);d(this,l);d(this,R);d(this,u,ro);d(this,z,[]);d(this,Y,new Set);d(this,S,new Map);d(this,M);d(this,W,!1);d(this,x,!1);d(this,v,0);d(this,q,0);d(this,ho,[]);d(this,fo,{});d(this,mo,{});d(this,N,"transition");d(this,P,"outdoor");d(this,oo,[]);d(this,po,[]);d(this,Z,!1);d(this,U,[]);d(this,$,null);E(this,"sceneUpdateQueue",Promise.resolve());E(this,"on",a((t,e)=>{o(this,L).on(t,e)},"on"));E(this,"off",a((t,e)=>{o(this,L).off(t,e)},"off"));d(this,to,a(()=>{c(this,z,[]),o(this,Y).clear();let t=o(this,u).isolateBelowGroundView&&o(this,v)<0;for(let e of o(this,po)){let i=o(this,S).get(e.floorStack.id);i&&(t&&i.minElevation>=0||(o(this,Y).add(i.id),o(this,z).push(i)))}},"#updateBuildingsInView"));d(this,go,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;at(e,this.focusedFacades)&&o(this,P)==="transition"&&!o(this,x)||(c(this,x,!1),c(this,po,e),o(this,to).call(this),o(this,u).autoFocus&&this.focus())},"#handleFacadesInViewChange"));d(this,Do,a((t,e)=>{if(!this.isEnabled)return;let i=o(this,S).get(t.floorStack.id);i&&(e.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=t));let r=o(this,u).isolateBelowGroundView&&o(this,v)<0;i?.excluded===!1&&!o(this,M).matchesFloorStack(t.floorStack)&&c(this,v,t.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,v)<0,f=r&&!n;if(e.reason==="dynamic-focus")return;let p=F(this,m,Et).call(this),T=o(this,Lo).call(this,t,e,f,p);if(p)return T;T.catch(h=>{V.error("setFloor override work failed after sync floor-change commit",h)})},"#setFloorHandler"));d(this,Lo,a(async(t,e,i,r)=>{i&&(c(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,to).call(this)),await o(this,C).call(this,t),!(!this.isEnabled||e.signal.aborted)&&r&&this.isEnabled&&!e.signal.aborted&&await o(this,Mo).call(this,t)},"#runFloorChangeWork"));d(this,Mo,a(t=>{let e=o(this,l).getFloorStackAltitudeData(t.floorStack).get(t.elevation)?.altitude;if(typeof e=="number"&&o(this,l).Camera.elevation!==e)return o(this,l).Camera.animateElevation(e,o(this,u).cameraLiftAnimationOptions)},"#liftCameraToFloorAltitude"));d(this,Fo,a(()=>{c(this,W,!0)},"#handleUserInteractionStart"));d(this,bo,a(()=>{c(this,W,!1)},"#handleUserInteractionEnd"));d(this,yo,a(()=>{o(this,C).call(this)},"#handleGlobalStateChange"));d(this,eo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=lt(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,N)!==i&&(c(this,N,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let r=(o(this,l).Navigation?.floors?.length??0)>0;Ho(o(this,U),e,r?{forceOpacity:0}:void 0)},"#handleCameraChange"));d(this,C,a(async t=>{if(!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(h=>h.id)||[],f=o(this,l).Navigation?.floorStacks.map(h=>h.id)||[],p=r?.showAllFloorsIncludedInNavigation??!1,T=new Promise(async h=>{await this.sceneUpdateQueue;let g=ct({buildings:Array.from(o(this,S).values()),inViewSet:o(this,Y),currentFloor:e,zoomState:o(this,N),mode:o(this,u).mode,elevation:o(this,v),floorIdsInNavigation:n,floorStackIdsInNavigation:f,showAllFloorsIncludedInNavigation:p,multiFloorView:r,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Kt,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,v),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(A=>o(this,l).getFloorStackAltitudeData(A),"getFloorStackAltitudeData")}),j=[];await Promise.all(Array.from(g.values()).map(async A=>{let{building:H,showIndoor:So,floorStackState:io,facadeState:Eo,inFocus:vo,isAboveGroundInIsolation:No}=A;j.push(io);let b=ht(H,So);if(b==="indoor")return F(this,m,vt).call(this,H,io,Eo,vo);if(b==="outdoor")return F(this,m,Tt).call(this,H,io,Eo,f,No)})),o(this,l).Outdoor.setOpacity(ut(j,o(this,u).mode)),c(this,oo,o(this,z).filter(A=>g.get(A.id)?.showIndoor===!0).map(A=>A.facade)),o(this,L).publish("focus",{facades:o(this,oo)}),h()});return this.sceneUpdateQueue=T,T},"#applyBuildingStates"));c(this,L,new wo),c(this,l,t),V.setLevel(K.logState),c(this,R,o(this,l).getMapData()),c(this,v,o(this,l).currentFloor.elevation),c(this,q,o(this,l).Camera.elevation);for(let e of o(this,R).getByType("facade")){let{floorStack:i}=e;if(i.floors.length===0||i.defaultFloor==null){V.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,S).set(i.id,new Oo(i,o(this,l)))}F(this,m,St).call(this),c(this,M,new Ao(gt(o(this,R),o(this,S)),o(this,l))),o(this,l).on("camera-change",o(this,eo)),o(this,l).on("facades-in-view-change",o(this,go)),o(this,l).on("user-interaction-start",o(this,Fo)),o(this,l).on("user-interaction-end",o(this,bo)),o(this,l).on("global-state-change",o(this,yo))}enable(t){if(o(this,Z)){V.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,Z,!0),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(o(this,Do)),o(this,M).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,m,yt).call(this),o(this,eo).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)){V.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,Z,!1),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(void 0)}get isEnabled(){return o(this,Z)}get isIndoor(){return o(this,P)==="indoor"}get isOutdoor(){return o(this,P)==="outdoor"}get outdoorsFloorStack(){return o(this,M).floorStack}get layers(){return o(this,ho)}get layersBySpaceId(){return o(this,fo)}setIndoor(){c(this,P,"indoor"),c(this,N,"in-range"),F(this,m,Qo).call(this)}setOutdoor(){c(this,P,"outdoor"),c(this,N,"out-of-range"),F(this,m,Qo).call(this)}get focusedFacades(){return[...o(this,oo)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,r=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,v)<0,f=o(this,u).autoFocus,p=!!o(this,u).autoZoomThresholds,T=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:p,h=t;if(T&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:j,...A}=h;h=A}if(!p&&T?(c(this,$,()=>{if(!o(this,Z))return;let g=o(this,u).indoorZoomThreshold,j=o(this,u).outdoorZoomThreshold;F(this,m,Xo).call(this),F(this,m,ot).call(this,g,j),o(this,C).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,$))):p&&!T&&F(this,m,Jo).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=zo(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=zo(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),h.cameraLiftAnimationOptions!=null&&(h={...h,cameraLiftAnimationOptions:{...o(this,u).cameraLiftAnimationOptions,...h.cameraLiftAnimationOptions}}),c(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),T&&h.autoZoomThresholds!==void 0&&(F(this,m,Xo).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,m,tt).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,v)<0;n&&!g&&(c(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,to).call(this)),o(this,C).call(this)}F(this,m,ot).call(this,i,r),o(this,Z)&&!f&&o(this,u).autoFocus&&(c(this,q,o(this,l).Camera.elevation),this.focus(o(this,u).setFloorOnFocus&&o(this,M).matchesFloorStack(o(this,l).currentFloor.floorStack)))}destroy(){this.disable(),F(this,m,Jo).call(this),o(this,l).off("facades-in-view-change",o(this,go)),o(this,l).off("camera-change",o(this,eo)),o(this,l).off("user-interaction-start",o(this,Fo)),o(this,l).off("user-interaction-end",o(this,bo)),o(this,l).off("global-state-change",o(this,yo)),o(this,S).forEach(t=>t.destroy()),o(this,M).destroy(),o(this,L).destroy(),c(this,U,[])}async focus(t=o(this,u).setFloorOnFocus){let e;if(t)if(ft(o(this,q),o(this,l).Camera.elevation,o(this,W)))c(this,q,o(this,l).Camera.elevation),c(this,x,!0);else{let i=dt(o(this,z),o(this,M),o(this,N)),r=i?Vo(i,o(this,u).mode,o(this,v)):void 0;r&&r.id!==o(this,l).currentFloor.id&&(e=r,o(this,l).setFloor(r,{context:"dynamic-focus"}))}await o(this,C).call(this,e)}preloadFloors(){F(this,m,tt).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!jo(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),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!jo(e,t))return;let i=o(this,S).get(t.id);i&&(i.activeFloor=e,o(this,C).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,S).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,S).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){return o(this,S).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};L=new WeakMap,l=new WeakMap,R=new WeakMap,u=new WeakMap,z=new WeakMap,Y=new WeakMap,S=new WeakMap,M=new WeakMap,W=new WeakMap,x=new WeakMap,v=new WeakMap,q=new WeakMap,ho=new WeakMap,fo=new WeakMap,mo=new WeakMap,N=new WeakMap,P=new WeakMap,oo=new WeakMap,po=new WeakMap,Z=new WeakMap,U=new WeakMap,$=new WeakMap,m=new WeakSet,Qo=a(function(){o(this,u).autoFocus&&(o(this,W)?this.focus():c(this,x,!0)),o(this,L).publish("state-change")},"#handleViewStateChange"),yt=a(function(){c(this,U,[]);for(let e of o(this,u).dynamicLayers){let i=new ko([e],!0,o(this,l));i.processLayerGroup(o(this,mo),()=>o(this,u)),o(this,U).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;Ho(o(this,U),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),Jo=a(function(){o(this,$)&&(o(this,l).off("camera-screen-offsets-change",o(this,$)),c(this,$,null))},"#unsubscribeScreenOffsets"),Xo=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:r}=nt(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=r,(e.expandMinZoom??!0)&&r<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(r-so)},"#recalcThresholds"),ot=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,L).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),St=a(function(){let t=o(this,R).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)}),c(this,ho,t.map(({name:r})=>r)),c(this,fo,i),c(this,mo,e)},"#setupLayers"),tt=a(function(t){let e=[];for(let i of o(this,R).getByType("facade")){let r=o(this,S).get(i.floorStack.id);if(!r)continue;let n=Vo(r,t,o(this,v));n!=null&&Ht.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),to=new WeakMap,go=new WeakMap,Et=a(function(){let{multiFloorView:t}=o(this,l).options;return!!t?.enabled&&!!t?.updateCameraElevationOnFloorChange},"#shouldAwaitFloorChangeCommit"),Do=new WeakMap,Lo=new WeakMap,Mo=new WeakMap,Fo=new WeakMap,bo=new WeakMap,yo=new WeakMap,eo=new WeakMap,Bo=a(function(t,e,i,r=!1){t.forEach(n=>{if(n.floor)if(e){let p=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,p)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),vt=a(async function(t,e,i,r){return F(this,m,Bo).call(this,e.floorStates,!0,r,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Tt=a(async function(t,e,i,r,n){let f=n;f&&F(this,m,Bo).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let p=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return p.result==="completed"&&!f&&F(this,m,Bo).call(this,e.floorStates,$o({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,N)==="in-range",inFocus:o(this,Y).has(t.id),mode:o(this,u).mode,elevation:o(this,v),inNavigation:r.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),p},"#animateOutdoorSequence"),C=new WeakMap,a(et,"DynamicFocus");var bt=et;export{a,nt as b,bt as c};
|
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as t}from"./chunk-
|
|
1
|
+
import{b as o,c as t}from"./chunk-ZDOX35PS.js";export{t as DynamicFocus,o as calculateZoomThresholds};
|
package/lib/esm/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,c as a}from"../chunk-
|
|
1
|
+
import{a as t,c as a}from"../chunk-ZDOX35PS.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};
|
package/lib/rn/index-rn.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var A=Object.defineProperty,n=(o,s)=>A(o,"name",{value:s,configurable:!0});import{useState as B,useCallback as c,useContext as C,useRef as L}from"react";import{MappedinContext as D}from"@mappedin/react-native-sdk";import{useCallback as x,useContext as W}from"react";var _="[MappedinJS]",N={log:0,debug:0,info:1,warn:2,error:3,silent:4};function v(o){return N[o.toLowerCase()]}n(v,"parseLogLevel");function m(o="",{prefix:s=_}={}){const e=`${s}${o?`-${o}`:""}`,i=n((t,r)=>{if(typeof window<"u"&&window.rnDebug){const f=r.map(l=>l instanceof Error&&l.stack?`${l.message}
|
|
2
|
-
${l.stack}`:l);window.rnDebug(`${o} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:1,debug(...t){this.logState<=0&&(console.debug(e,...t),i("debug",t))},log(...t){this.debug(...t)},info(...t){this.logState<=1&&(console.info(e,...t),i("info",t))},warn(...t){this.logState<=2&&(console.warn(e,...t),i("warn",t))},error(...t){this.logState<=3&&(console.error(e,...t),i("error",t))},assert(...t){console.assert(...t)},time(t){console.time(t)},timeEnd(t){console.timeEnd(t)},setLevel(t){const r=typeof t=="string"?v(t):t;if(r===void 0||!(r>=0&&r<=4)){console.warn(e,`setLevel: unknown log level "${t}"`);return}this.logState=r}}}n(m,"createLogger");var Q=m(),F=m("",{prefix:"[DynamicFocus]"});import{MappedinContext as $,useEventCallback as G,createEventSetupScript as R,createEventCleanupScript as j}from"@mappedin/react-native-sdk";function S(o,s){return s.map(e=>e&&e.id&&o.getById("facade",e.id)||e)}n(S,"hydrateFacades");import{useRegisterExtension as P}from"@mappedin/react-native-sdk";var q='\n // Define require function that uses bridge.modules for external dependencies\n globalThis.require = globalThis.require || ((id) => {\n if (window.bridge?.modules?.[id]) {\n return window.bridge.modules[id];\n }\n throw new Error(\'Module not found: \' + id);\n });\n \n"use strict";var DynamicFocus=(()=>{var so=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var Mt=Object.prototype.hasOwnProperty;var dt=r=>{throw TypeError(r)};var Zt=(r,t,e)=>t in r?so(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>so(r,"name",{value:t,configurable:!0}),Uo=(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 _t=(r,t)=>{for(var e in t)so(r,e,{get:t[e],enumerable:!0})},Nt=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Lt(t))!Mt.call(r,s)&&s!==e&&so(r,s,{get:()=>t[s],enumerable:!(i=Bt(t,s))||i.enumerable});return r};var xt=r=>Nt(so({},"__esModule",{value:!0}),r);var b=(r,t,e)=>Zt(r,typeof t!="symbol"?t+"":t,e),$o=(r,t,e)=>t.has(r)||dt("Cannot "+e);var o=(r,t,e)=>($o(r,t,"read from private field"),e?e.call(r):t.get(r)),d=(r,t,e)=>t.has(r)?dt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,i)=>($o(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>($o(r,t,"access private method"),e);var Jt={};_t(Jt,{DynamicFocus:()=>Zo,calculateZoomThresholds:()=>Do});var Co=Uo("@mappedin/mappedin-js");function ct(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(ct,"arraysEqual");var jo=class jo{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(jo,"PubSub");var Oo=jo;var Q=Uo("@mappedin/mappedin-js");var I,ro,C,w,T,A,H,K,zo=class zo{constructor(t,e){b(this,"__type","building");d(this,I);d(this,ro,new Map);d(this,C,new Map);d(this,w,[]);d(this,T);d(this,A);b(this,"defaultFloor");b(this,"activeFloor");b(this,"excluded",!1);b(this,"aboveGroundFloors",[]);d(this,H);d(this,K);c(this,I,t),c(this,ro,new Map(t.floors.map(s=>[s.id,s]))),c(this,C,new Map(t.floors.map(s=>[s.elevation,s]))),c(this,w,Array.from(o(this,C).values()).sort((s,n)=>s.elevation-n.elevation));let i=t.defaultFloor;if(!i)throw new Error(`Building created for floor stack "${t.id}" with no resolvable default floor`);this.defaultFloor=i,this.activeFloor=this.defaultFloor,c(this,T,e),this.aboveGroundFloors=o(this,w).filter(s=>s.elevation>=0)}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&&c(this,H,Math.max(...o(this,C).keys())),o(this,H)}get minElevation(){return o(this,K)==null&&c(this,K,Math.min(...o(this,C).keys())),o(this,K)}has(t){return Q.Floor.is(t)?o(this,ro).has(t.id):Q.FloorStack.is(t)?t.id===o(this,I).id:Q.Facade.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,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,A)&&(o(this,A).animation.cancel(),c(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){c(this,A,{animation:o(this,T).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let f=await o(this,A).animation;if(c(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,ro=new WeakMap,C=new WeakMap,w=new WeakMap,T=new WeakMap,A=new WeakMap,H=new WeakMap,K=new WeakMap,a(zo,"Building");var Vo=zo;function ht(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(ht,"getZoomState");function Io(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);case"active-floor":return i.activeFloor;default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Io,"getFloorToShow");function Ct(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(Ct,"getFacadeState");function Gt(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(Gt,"getSingleBuildingState");function ft(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(ft,"getOutdoorOpacity");function mt(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(mt,"getSetFloorTargetFromZoomState");function pt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:f,floorIdsInNavigation:p,floorStackIdsInNavigation:v,showAllFloorsIncludedInNavigation:h,multiFloorView:g,getMultiFloorState:$,dynamicBuildingInteriors:V,isolateBelowGroundView:q,currentElevation:Eo,forceInteriorsVisible:io,getFloorStackAltitudeData:vo}=r,To=new Map,Go=q&&Eo<0&&s==="in-range";for(let y of t){let ut=e.has(y.id),wo=Go&&y.minElevation>=0,It=wo?!1:ut,Ro=wo?!1:Yo({building:y,currentFloor:i,inRange:s==="in-range",inFocus:ut,mode:n,elevation:f,inNavigation:v.includes(y.id),dynamicBuildingInteriors:V,forceInteriorsVisible:io}),Po=i.floorStack.id===y.id?y.activeFloor:Io(y,n,f),At=g?.enabled?$(y.floors,Po||y.activeFloor,p,vo(y.id),{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},h):Gt(y.floorStack,Po||y.activeFloor,Ro),kt=q&&Eo<0&&s==="in-range",Dt=Ct(y.facade,Ro,kt,wo);To.set(y.id,{building:y,showIndoor:Ro,floorStackState:At,facadeState:Dt,inFocus:It,floorToShow:Po,isAboveGroundInIsolation:wo})}return To}a(pt,"getBuildingStates");function gt(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(gt,"getBuildingAnimationType");function Yo(r){let{building:t,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:f,inNavigation:p,dynamicBuildingInteriors:v,forceInteriorsVisible:h}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(h===!0||p===!0)return!0;if(!v)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(Yo,"shouldShowIndoor");function Ft(r,t,e){return r!==t&&!e}a(Ft,"shouldDeferSetFloor");var bt=["default-floor","active-floor","lock-elevation","nearest-elevation"];var Ao=Uo("@mappedin/mappedin-js");var Wo="[MappedinJS]";var Rt={log:0,debug:0,info:1,warn:2,error:3,silent:4};function Pt(r){return Rt[r.toLowerCase()]}a(Pt,"parseLogLevel");function qo(r="",{prefix:t=Wo}={}){let e=`${t}${r?`-${r}`:""}`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(p=>p instanceof Error&&p.stack?`${p.message}\n${p.stack}`:p);window.rnDebug(`${r} ${s}: ${f.join(" ")}`)}},"rnDebug");return{logState:1,debug(...s){this.logState<=0&&(console.debug(e,...s),i("debug",s))},log(...s){this.debug(...s)},info(...s){this.logState<=1&&(console.info(e,...s),i("info",s))},warn(...s){this.logState<=2&&(console.warn(e,...s),i("warn",s))},error(...s){this.logState<=3&&(console.error(e,...s),i("error",s))},assert(...s){console.assert(...s)},time(s){console.time(s)},timeEnd(s){console.timeEnd(s)},setLevel(s){let n=typeof s=="string"?Pt(s):s;if(n===void 0||!(n>=0&&n<=4)){console.warn(e,`setLevel: unknown log level "${s}"`);return}this.logState=n}}}a(qo,"createLogger");var Ut=qo();var J=Ut;function yt(r,t,e,i){return(r<t||r>e)&&J.warn(i),Math.min(e,Math.max(t,r))}a(yt,"clampWithWarning");function Ho(r,t){return!Ao.Floor.is(r)||r?.floorStack==null||!Ao.FloorStack.is(t)?!1:r.floorStack.id!==t.id?(J.warn(`Floor (${r.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(Ho,"validateFloorForStack");function Ko(r,t,e,i){return yt(r,t,e,`${i} must be between ${t} and ${e}.`)}a(Ko,"validateZoomThreshold");var O=qo("",{prefix:"[DynamicFocus]"});var k,X,no,Qo,Jo=class Jo{constructor(t,e){d(this,no);b(this,"__type","outdoors");d(this,k);d(this,X);c(this,k,t),c(this,X,e)}get id(){return o(this,k).id}get floorStack(){return o(this,k)}get floor(){return o(this,k).defaultFloor}matchesFloorStack(t){return t===o(this,k)||t===o(this,k).id}show(){F(this,no,Qo).call(this,!0)}hide(){F(this,no,Qo).call(this,!1)}destroy(){this.matchesFloorStack(o(this,X).currentFloorStack)||this.hide()}};k=new WeakMap,X=new WeakMap,no=new WeakSet,Qo=a(function(t){for(let e of o(this,k).floors)o(this,X).updateState(e,{visible:t})},"#setVisible"),a(Jo,"Outdoors");var ko=Jo;function St(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||(O.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(St,"getOutdoorFloorStack");var ao={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!0,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},cameraLiftAnimationOptions:{duration:500,easing:"ease-in-out",interruptible:!0},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},lo=.2,Xo=.4;var Do=a((r,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=$t(r,e);if(i===void 0)return O.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:ao.indoorZoomThreshold,outdoorZoomThreshold:ao.outdoorZoomThreshold};let s=i+Xo,n=i+lo;return e.initialVisibility==="indoor-first"&&(s=i-lo,n=i-Xo),{indoorZoomThreshold:s,outdoorZoomThreshold:n}},"calculateZoomThresholds");function $t(r,t){let i=r.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),s=1/0,n;for(let f of i){let p=r.Camera.getFocusOnTransform(f).zoomLevel??1/0;p<s&&(s=p,n=f)}if(s!==1/0)return t.debug&&n&&r.Camera.getFocusOnTransform(n,{debugColor:"blue"}),s}a($t,"getDefaultZoomLevel");function jt(r,t){return`${t} ${r}`}a(jt,"formatMessage");var ot=class ot extends Error{constructor(t,e=Wo){super(jt(t,e)),this.name="MappedinError"}};a(ot,"MappedinError");var Bo=ot;var zt=a(r=>r,"linearEase"),Yt=a(r=>r*r,"quadEaseIn"),Wt=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),qt=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Ht=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),Kt={linear:zt,"ease-in":Yt,"ease-out":qt,"ease-in-out":Wt,"ease-out-cubic":Ht};function Qt(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(Qt,"getInterpolationBreakpoint");function Et(r,t,e,i="ease-in"){if(t.length!==e.length)throw new Bo("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=Qt(r,t),n=(r-t[s])/(t[s+1]-t[s]),f=typeof i=="function"?i(n):Kt[i](n);return e[s]+f*(e[s+1]-e[s])}a(Et,"interpolateMulti");var D,uo,co,_,ho,et=class et{constructor(t,e,i){b(this,"layers");b(this,"visible");d(this,D);d(this,uo,[]);d(this,co,!1);d(this,_,new Map);b(this,"interpolationFn");d(this,ho,1);this.layers=t,this.visible=e,c(this,D,i)}processLayerGroup(t,e){o(this,co)||(this.layers.forEach(i=>{let s=t[i];s&&o(this,uo).push(...s)}),c(this,co,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:s,indoorZoomThreshold:n}=e();return Et(i,[s,n],[1,0])}))}setOpacity(t){c(this,ho,t);for(let e of o(this,uo))if(e.startsWith("img_")){let i=o(this,D).Image3D.getById(e);if(i){if(!o(this,_).has(e)){let n=o(this,D).getState(i.image);o(this,_).set(e,n?.opacity??1)}let s=Math.min(o(this,_).get(e),t);o(this,D).updateState(i.image,{opacity:s})}}else{let i=o(this,D).getMapData()?.getById("space",e);if(!i)continue;if(!o(this,_).has(e)){let n=o(this,D).getState(i);o(this,_).set(e,n?.opacity??1)}let s=Math.min(o(this,_).get(e),t);o(this,D).updateState(i,{opacity:s,visible:s>0})}}get opacity(){return o(this,ho)}};D=new WeakMap,uo=new WeakMap,co=new WeakMap,_=new WeakMap,ho=new WeakMap,a(et,"LayerGroup");var Lo=et;function tt(r,t,e){r.forEach(i=>{if(e?.forceOpacity!==void 0){i.setOpacity(e.forceOpacity),i.visible=e.forceOpacity===1;return}if(i.interpolationFn!=null){let s=i.interpolationFn(t);s!=null&&(i.setOpacity(s),i.visible=s===1)}})}a(tt,"runLayerGroupInterpolations");var B,l,G,u,j,z,S,L,Y,N,E,W,fo,mo,po,M,R,oo,go,Z,P,U,m,it,vt,st,rt,nt,Tt,at,to,Fo,wt,_o,No,xo,bo,yo,So,eo,Mo,Ot,Vt,x,lt=class lt{constructor(t){d(this,m);d(this,B);d(this,l);d(this,G);d(this,u,ao);d(this,j,[]);d(this,z,new Set);d(this,S,new Map);d(this,L);d(this,Y,!1);d(this,N,!1);d(this,E,0);d(this,W,0);d(this,fo,[]);d(this,mo,{});d(this,po,{});d(this,M,"transition");d(this,R,"outdoor");d(this,oo,[]);d(this,go,[]);d(this,Z,!1);d(this,P,[]);d(this,U,null);b(this,"sceneUpdateQueue",Promise.resolve());b(this,"on",a((t,e)=>{o(this,B).on(t,e)},"on"));b(this,"off",a((t,e)=>{o(this,B).off(t,e)},"off"));d(this,to,a(()=>{c(this,j,[]),o(this,z).clear();let t=o(this,u).isolateBelowGroundView&&o(this,E)<0;for(let e of o(this,go)){let i=o(this,S).get(e.floorStack.id);i&&(t&&i.minElevation>=0||(o(this,z).add(i.id),o(this,j).push(i)))}},"#updateBuildingsInView"));d(this,Fo,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;ct(e,this.focusedFacades)&&o(this,R)==="transition"&&!o(this,N)||(c(this,N,!1),c(this,go,e),o(this,to).call(this),o(this,u).autoFocus&&this.focus())},"#handleFacadesInViewChange"));d(this,_o,a((t,e)=>{if(!this.isEnabled)return;let i=o(this,S).get(t.floorStack.id);i&&(e.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=t));let s=o(this,u).isolateBelowGroundView&&o(this,E)<0;i?.excluded===!1&&!o(this,L).matchesFloorStack(t.floorStack)&&c(this,E,t.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,E)<0,f=s&&!n;if(e.reason==="dynamic-focus")return;let p=F(this,m,wt).call(this),v=o(this,No).call(this,t,e,f,p);if(p)return v;v.catch(h=>{O.error("setFloor override work failed after sync floor-change commit",h)})},"#setFloorHandler"));d(this,No,a(async(t,e,i,s)=>{i&&(c(this,N,!0),o(this,l).Camera.updateFacadesInView(),o(this,to).call(this)),await o(this,x).call(this,t),!(!this.isEnabled||e.signal.aborted)&&s&&this.isEnabled&&!e.signal.aborted&&await o(this,xo).call(this,t)},"#runFloorChangeWork"));d(this,xo,a(t=>{let e=o(this,l).getFloorStackAltitudeData(t.floorStack).get(t.elevation)?.altitude;if(typeof e=="number"&&o(this,l).Camera.elevation!==e)return o(this,l).Camera.animateElevation(e,o(this,u).cameraLiftAnimationOptions)},"#liftCameraToFloorAltitude"));d(this,bo,a(()=>{c(this,Y,!0)},"#handleUserInteractionStart"));d(this,yo,a(()=>{c(this,Y,!1)},"#handleUserInteractionEnd"));d(this,So,a(()=>{o(this,x).call(this)},"#handleGlobalStateChange"));d(this,eo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=ht(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,M)!==i&&(c(this,M,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let s=(o(this,l).Navigation?.floors?.length??0)>0;tt(o(this,P),e,s?{forceOpacity:0}:void 0)},"#handleCameraChange"));d(this,x,a(async t=>{if(!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)||[],p=s?.showAllFloorsIncludedInNavigation??!1,v=new Promise(async h=>{await this.sceneUpdateQueue;let g=pt({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,E),floorIdsInNavigation:n,floorStackIdsInNavigation:f,showAllFloorsIncludedInNavigation:p,multiFloorView:s,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Co.getMultiFloorState,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,E),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(V=>o(this,l).getFloorStackAltitudeData(V),"getFloorStackAltitudeData")}),$=[];await Promise.all(Array.from(g.values()).map(async V=>{let{building:q,showIndoor:Eo,floorStackState:io,facadeState:vo,inFocus:To,isAboveGroundInIsolation:Go}=V;$.push(io);let y=gt(q,Eo);if(y==="indoor")return F(this,m,Ot).call(this,q,io,vo,To);if(y==="outdoor")return F(this,m,Vt).call(this,q,io,vo,f,Go)})),o(this,l).Outdoor.setOpacity(ft($,o(this,u).mode)),c(this,oo,o(this,j).filter(V=>g.get(V.id)?.showIndoor===!0).map(V=>V.facade)),o(this,B).publish("focus",{facades:o(this,oo)}),h()});return this.sceneUpdateQueue=v,v},"#applyBuildingStates"));c(this,B,new Oo),c(this,l,t),O.setLevel(J.logState),c(this,G,o(this,l).getMapData()),c(this,E,o(this,l).currentFloor.elevation),c(this,W,o(this,l).Camera.elevation);for(let e of o(this,G).getByType("facade")){let{floorStack:i}=e;if(i.floors.length===0||i.defaultFloor==null){O.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,S).set(i.id,new Vo(i,o(this,l)))}F(this,m,Tt).call(this),c(this,L,new ko(St(o(this,G),o(this,S)),o(this,l))),o(this,l).on("camera-change",o(this,eo)),o(this,l).on("facades-in-view-change",o(this,Fo)),o(this,l).on("user-interaction-start",o(this,bo)),o(this,l).on("user-interaction-end",o(this,yo)),o(this,l).on("global-state-change",o(this,So))}enable(t){if(o(this,Z)){O.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,Z,!0),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(o(this,_o)),o(this,L).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&O.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,m,vt).call(this),o(this,eo).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)){O.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,Z,!1),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(void 0)}get isEnabled(){return o(this,Z)}get isIndoor(){return o(this,R)==="indoor"}get isOutdoor(){return o(this,R)==="outdoor"}get outdoorsFloorStack(){return o(this,L).floorStack}get layers(){return o(this,fo)}get layersBySpaceId(){return o(this,mo)}setIndoor(){c(this,R,"indoor"),c(this,M,"in-range"),F(this,m,it).call(this)}setOutdoor(){c(this,R,"outdoor"),c(this,M,"out-of-range"),F(this,m,it).call(this)}get focusedFacades(){return[...o(this,oo)]}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,E)<0,f=o(this,u).autoFocus,p=!!o(this,u).autoZoomThresholds,v=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:p,h=t;if(v&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){O.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:$,...V}=h;h=V}if(!p&&v?(c(this,U,()=>{if(!o(this,Z))return;let g=o(this,u).indoorZoomThreshold,$=o(this,u).outdoorZoomThreshold;F(this,m,rt).call(this),F(this,m,nt).call(this,g,$),o(this,x).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,U))):p&&!v&&F(this,m,st).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=Ko(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=Ko(h.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,h?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),h.mode!=null&&(h.mode=bt.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),h.cameraLiftAnimationOptions!=null&&(h={...h,cameraLiftAnimationOptions:{...o(this,u).cameraLiftAnimationOptions,...h.cameraLiftAnimationOptions}}),c(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),v&&h.autoZoomThresholds!==void 0&&(F(this,m,rt).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,m,at).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,E)<0;n&&!g&&(c(this,N,!0),o(this,l).Camera.updateFacadesInView(),o(this,to).call(this)),o(this,x).call(this)}F(this,m,nt).call(this,i,s),o(this,Z)&&!f&&o(this,u).autoFocus&&(c(this,W,o(this,l).Camera.elevation),this.focus(o(this,u).setFloorOnFocus&&o(this,L).matchesFloorStack(o(this,l).currentFloor.floorStack)))}destroy(){this.disable(),F(this,m,st).call(this),o(this,l).off("facades-in-view-change",o(this,Fo)),o(this,l).off("camera-change",o(this,eo)),o(this,l).off("user-interaction-start",o(this,bo)),o(this,l).off("user-interaction-end",o(this,yo)),o(this,l).off("global-state-change",o(this,So)),o(this,S).forEach(t=>t.destroy()),o(this,L).destroy(),o(this,B).destroy(),c(this,P,[])}async focus(t=o(this,u).setFloorOnFocus){let e;if(t)if(Ft(o(this,W),o(this,l).Camera.elevation,o(this,Y)))c(this,W,o(this,l).Camera.elevation),c(this,N,!0);else{let i=mt(o(this,j),o(this,L),o(this,M)),s=i?Io(i,o(this,u).mode,o(this,E)):void 0;s&&s.id!==o(this,l).currentFloor.id&&(e=s,o(this,l).setFloor(s,{context:"dynamic-focus"}))}await o(this,x).call(this,e)}preloadFloors(){F(this,m,at).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!Ho(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),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Ho(e,t))return;let i=o(this,S).get(t.id);i&&(i.activeFloor=e,o(this,x).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)}};B=new WeakMap,l=new WeakMap,G=new WeakMap,u=new WeakMap,j=new WeakMap,z=new WeakMap,S=new WeakMap,L=new WeakMap,Y=new WeakMap,N=new WeakMap,E=new WeakMap,W=new WeakMap,fo=new WeakMap,mo=new WeakMap,po=new WeakMap,M=new WeakMap,R=new WeakMap,oo=new WeakMap,go=new WeakMap,Z=new WeakMap,P=new WeakMap,U=new WeakMap,m=new WeakSet,it=a(function(){o(this,u).autoFocus&&(o(this,Y)?this.focus():c(this,N,!0)),o(this,B).publish("state-change")},"#handleViewStateChange"),vt=a(function(){c(this,P,[]);for(let e of o(this,u).dynamicLayers){let i=new Lo([e],!0,o(this,l));i.processLayerGroup(o(this,po),()=>o(this,u)),o(this,P).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;tt(o(this,P),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),st=a(function(){o(this,U)&&(o(this,l).off("camera-screen-offsets-change",o(this,U)),c(this,U,null))},"#unsubscribeScreenOffsets"),rt=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:s}=Do(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-lo)},"#recalcThresholds"),nt=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,B).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),Tt=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)}),c(this,fo,t.map(({name:s})=>s)),c(this,mo,i),c(this,po,e)},"#setupLayers"),at=a(function(t){let e=[];for(let i of o(this,G).getByType("facade")){let s=o(this,S).get(i.floorStack.id);if(!s)continue;let n=Io(s,t,o(this,E));n!=null&&Co.Floor.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),to=new WeakMap,Fo=new WeakMap,wt=a(function(){let{multiFloorView:t}=o(this,l).options;return!!t?.enabled&&!!t?.updateCameraElevationOnFloorChange},"#shouldAwaitFloorChangeCommit"),_o=new WeakMap,No=new WeakMap,xo=new WeakMap,bo=new WeakMap,yo=new WeakMap,So=new WeakMap,eo=new WeakMap,Mo=a(function(t,e,i,s=!1){t.forEach(n=>{if(n.floor)if(e){let p=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,p)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),Ot=a(async function(t,e,i,s){return F(this,m,Mo).call(this,e.floorStates,!0,s,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Vt=a(async function(t,e,i,s,n){let f=n;f&&F(this,m,Mo).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let p=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return p.result==="completed"&&!f&&F(this,m,Mo).call(this,e.floorStates,Yo({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,E),inNavigation:s.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),p},"#animateOutdoorSequence"),x=new WeakMap,a(lt,"DynamicFocus");var Zo=lt;return xt(Jt);})();\n\n\n// Register the extension\nif (window.bridge && window.bridge.extensions) {\n try {\n window.bridge.extensions.register({ name: \'dynamic-focus\', package: { Extension: DynamicFocus.DynamicFocus } });\n if (window.rnDebug) window.rnDebug(\'Extension: dynamic-focus registered\');\n } catch(e) {\n if (window.rnDebug) window.rnDebug(\'Failed to register dynamic-focus extension: \' + e.message);\n }\n} else {\n if (window.rnDebug) window.rnDebug(\'Bridge or extensions not available for registration\');\n}';function k(){return q}n(k,"getRegistrationScript");function g(){P({extensionName:"dynamic-focus",getRegistrationScript:k,logger:F})}n(g,"useDynamicFocusRegistration");function b(o,s){if(typeof o!="string"||o.length===0)throw new Error("Event parameter must be a non-empty string");if(typeof s!="function")throw new Error("Callback parameter must be a function");const e=W($),{extensions:i,mapData:t}=e;if(!t)throw new Error("Map data is not available");g();const f=(i?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",l=x(d=>{try{let u=d;o==="focus"&&d.facades&&(u={...d,facades:S(t,d.facades)}),s(u)}catch(u){F.error(`Error in dynamic focus event callback for ${String(o)}:`,u)}},[o,t,s]);G({eventKey:`dynamic-focus:${String(o)}`,callback:l,setupScript:n(()=>R({extensionName:"dynamic-focus",eventName:String(o)}),"setupScript"),cleanupScript:n(()=>j({extensionName:"dynamic-focus",eventName:String(o)}),"cleanupScript"),shouldInject:f})}n(b,"useDynamicFocusEvent");function E(){const o=C(D),{bridge:s,extensions:e,updateExtensionState:i}=o;g();const t=e["dynamic-focus"],r=t?.registrationState||"unregistered",f=r==="registered",l=t?.isEnabled||!1,[d,u]=B(t?.focusedFacades||[]),w=L(e);w.current=e,b("focus",c(h=>{const p=h.facades;u(p),i("dynamic-focus",y=>({...y,registrationState:r,focusedFacades:p}))},[r,i]));const a=c(async(h,p=[])=>{if(!s?.isReady)throw new Error("Bridge is not ready. Ensure the WebView is loaded.");return await s.instruct({type:"extension",payload:{name:"dynamic-focus",method:h,args:p}})},[s]),T=c(async h=>{w.current?.["dynamic-focus"]?.isEnabled||(await a("enable",[h]),i("dynamic-focus",V=>({...V,isEnabled:!0})))},[a,i]),M=c(async h=>await a("updateState",[h]),[a]),O=c(async()=>await a("getState"),[a]),I=c(async h=>await a("focus",[h]),[a]),Z=c(async()=>{await a("disable"),u([]),i("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[a,u,i]);return{isReady:f,isEnabled:l,focusedFacades:d,updateState:M,getState:O,focus:I,disable:Z,enable:T}}n(E,"useDynamicFocus");export{E as useDynamicFocus,b as useDynamicFocusEvent};
|
|
2
|
+
${l.stack}`:l);window.rnDebug(`${o} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:1,debug(...t){this.logState<=0&&(console.debug(e,...t),i("debug",t))},log(...t){this.debug(...t)},info(...t){this.logState<=1&&(console.info(e,...t),i("info",t))},warn(...t){this.logState<=2&&(console.warn(e,...t),i("warn",t))},error(...t){this.logState<=3&&(console.error(e,...t),i("error",t))},assert(...t){console.assert(...t)},time(t){console.time(t)},timeEnd(t){console.timeEnd(t)},setLevel(t){const r=typeof t=="string"?v(t):t;if(r===void 0||!(r>=0&&r<=4)){console.warn(e,`setLevel: unknown log level "${t}"`);return}this.logState=r}}}n(m,"createLogger");var Q=m(),F=m("",{prefix:"[DynamicFocus]"});import{MappedinContext as $,useEventCallback as G,createEventSetupScript as R,createEventCleanupScript as j}from"@mappedin/react-native-sdk";function S(o,s){return s.map(e=>e&&e.id&&o.getById("facade",e.id)||e)}n(S,"hydrateFacades");import{useRegisterExtension as P}from"@mappedin/react-native-sdk";var q='\n // Define require function that uses bridge.modules for external dependencies\n globalThis.require = globalThis.require || ((id) => {\n if (window.bridge?.modules?.[id]) {\n return window.bridge.modules[id];\n }\n throw new Error(\'Module not found: \' + id);\n });\n \n"use strict";var DynamicFocus=(()=>{var so=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var Lt=Object.prototype.hasOwnProperty;var dt=r=>{throw TypeError(r)};var Nt=(r,t,e)=>t in r?so(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>so(r,"name",{value:t,configurable:!0}),Uo=(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 Zt=(r,t)=>{for(var e in t)so(r,e,{get:t[e],enumerable:!0})},_t=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Mt(t))!Lt.call(r,s)&&s!==e&&so(r,s,{get:()=>t[s],enumerable:!(i=Bt(t,s))||i.enumerable});return r};var xt=r=>_t(so({},"__esModule",{value:!0}),r);var b=(r,t,e)=>Nt(r,typeof t!="symbol"?t+"":t,e),$o=(r,t,e)=>t.has(r)||dt("Cannot "+e);var o=(r,t,e)=>($o(r,t,"read from private field"),e?e.call(r):t.get(r)),d=(r,t,e)=>t.has(r)?dt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,i)=>($o(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>($o(r,t,"access private method"),e);var Jt={};Zt(Jt,{DynamicFocus:()=>No,calculateZoomThresholds:()=>Do});var Co=Uo("@mappedin/mappedin-js");function ct(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(ct,"arraysEqual");var jo=class jo{constructor(){b(this,"_subscribers",{});b(this,"_abortController",new AbortController)}get signal(){return this._abortController.signal}getSubscribers(t){if(!(!this._subscribers||!this._subscribers[t]||this.signal.aborted))return this._subscribers[t]}publish(t,e){let i=this.getSubscribers(t);i&&i.forEach(function(s){typeof s=="function"&&s(e)})}hasSubscribers(t){return!!this.getSubscribers(t)?.length}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){let i=this.getSubscribers(t);if(!i)return;let s=i.indexOf(e);s!==-1&&i.splice(s,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(jo,"PubSub");var Oo=jo;var Q=Uo("@mappedin/mappedin-js");var A,ro,C,w,T,I,H,K,zo=class zo{constructor(t,e){b(this,"__type","building");d(this,A);d(this,ro,new Map);d(this,C,new Map);d(this,w,[]);d(this,T);d(this,I);b(this,"defaultFloor");b(this,"activeFloor");b(this,"excluded",!1);b(this,"aboveGroundFloors",[]);d(this,H);d(this,K);c(this,A,t),c(this,ro,new Map(t.floors.map(s=>[s.id,s]))),c(this,C,new Map(t.floors.map(s=>[s.elevation,s]))),c(this,w,Array.from(o(this,C).values()).sort((s,n)=>s.elevation-n.elevation));let i=t.defaultFloor;if(!i)throw new Error(`Building created for floor stack "${t.id}" with no resolvable default floor`);this.defaultFloor=i,this.activeFloor=this.defaultFloor,c(this,T,e),this.aboveGroundFloors=o(this,w).filter(s=>s.elevation>=0)}get id(){return o(this,A).id}get name(){return o(this,A).name}get floors(){return o(this,A).floors}get floorStack(){return o(this,A)}get facade(){return o(this,A).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&&c(this,H,Math.max(...o(this,C).keys())),o(this,H)}get minElevation(){return o(this,K)==null&&c(this,K,Math.min(...o(this,C).keys())),o(this,K)}has(t){return Q.Floor.is(t)?o(this,ro).has(t.id):Q.FloorStack.is(t)?t.id===o(this,A).id:Q.Facade.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,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,I)&&(o(this,I).animation.cancel(),c(this,I,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,I)?.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){c(this,I,{animation:o(this,T).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let f=await o(this,I).animation;if(c(this,I,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,A).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})}};A=new WeakMap,ro=new WeakMap,C=new WeakMap,w=new WeakMap,T=new WeakMap,I=new WeakMap,H=new WeakMap,K=new WeakMap,a(zo,"Building");var Vo=zo;function ht(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(ht,"getZoomState");function Ao(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);case"active-floor":return i.activeFloor;default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Ao,"getFloorToShow");function Ct(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(Ct,"getFacadeState");function Gt(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(Gt,"getSingleBuildingState");function ft(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(ft,"getOutdoorOpacity");function mt(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(mt,"getSetFloorTargetFromZoomState");function pt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:f,floorIdsInNavigation:p,floorStackIdsInNavigation:v,showAllFloorsIncludedInNavigation:h,multiFloorView:g,getMultiFloorState:$,dynamicBuildingInteriors:V,isolateBelowGroundView:q,currentElevation:Eo,forceInteriorsVisible:io,getFloorStackAltitudeData:vo}=r,To=new Map,Go=q&&Eo<0&&s==="in-range";for(let y of t){let ut=e.has(y.id),wo=Go&&y.minElevation>=0,At=wo?!1:ut,Ro=wo?!1:Yo({building:y,currentFloor:i,inRange:s==="in-range",inFocus:ut,mode:n,elevation:f,inNavigation:v.includes(y.id),dynamicBuildingInteriors:V,forceInteriorsVisible:io}),Po=i.floorStack.id===y.id?y.activeFloor:Ao(y,n,f),It=g?.enabled?$(y.floors,Po||y.activeFloor,p,vo(y.id),{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},h):Gt(y.floorStack,Po||y.activeFloor,Ro),kt=q&&Eo<0&&s==="in-range",Dt=Ct(y.facade,Ro,kt,wo);To.set(y.id,{building:y,showIndoor:Ro,floorStackState:It,facadeState:Dt,inFocus:At,floorToShow:Po,isAboveGroundInIsolation:wo})}return To}a(pt,"getBuildingStates");function gt(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(gt,"getBuildingAnimationType");function Yo(r){let{building:t,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:f,inNavigation:p,dynamicBuildingInteriors:v,forceInteriorsVisible:h}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(h===!0||p===!0)return!0;if(!v)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(Yo,"shouldShowIndoor");function Ft(r,t,e){return r!==t&&!e}a(Ft,"shouldDeferSetFloor");var bt=["default-floor","active-floor","lock-elevation","nearest-elevation"];var Io=Uo("@mappedin/mappedin-js");var Wo="[MappedinJS]";var Rt={log:0,debug:0,info:1,warn:2,error:3,silent:4};function Pt(r){return Rt[r.toLowerCase()]}a(Pt,"parseLogLevel");function qo(r="",{prefix:t=Wo}={}){let e=`${t}${r?`-${r}`:""}`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(p=>p instanceof Error&&p.stack?`${p.message}\n${p.stack}`:p);window.rnDebug(`${r} ${s}: ${f.join(" ")}`)}},"rnDebug");return{logState:1,debug(...s){this.logState<=0&&(console.debug(e,...s),i("debug",s))},log(...s){this.debug(...s)},info(...s){this.logState<=1&&(console.info(e,...s),i("info",s))},warn(...s){this.logState<=2&&(console.warn(e,...s),i("warn",s))},error(...s){this.logState<=3&&(console.error(e,...s),i("error",s))},assert(...s){console.assert(...s)},time(s){console.time(s)},timeEnd(s){console.timeEnd(s)},setLevel(s){let n=typeof s=="string"?Pt(s):s;if(n===void 0||!(n>=0&&n<=4)){console.warn(e,`setLevel: unknown log level "${s}"`);return}this.logState=n}}}a(qo,"createLogger");var Ut=qo();var J=Ut;function yt(r,t,e,i){return(r<t||r>e)&&J.warn(i),Math.min(e,Math.max(t,r))}a(yt,"clampWithWarning");function Ho(r,t){return!Io.Floor.is(r)||r?.floorStack==null||!Io.FloorStack.is(t)?!1:r.floorStack.id!==t.id?(J.warn(`Floor (${r.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(Ho,"validateFloorForStack");function Ko(r,t,e,i){return yt(r,t,e,`${i} must be between ${t} and ${e}.`)}a(Ko,"validateZoomThreshold");var O=qo("",{prefix:"[DynamicFocus]"});var k,X,no,Qo,Jo=class Jo{constructor(t,e){d(this,no);b(this,"__type","outdoors");d(this,k);d(this,X);c(this,k,t),c(this,X,e)}get id(){return o(this,k).id}get floorStack(){return o(this,k)}get floor(){return o(this,k).defaultFloor}matchesFloorStack(t){return t===o(this,k)||t===o(this,k).id}show(){F(this,no,Qo).call(this,!0)}hide(){F(this,no,Qo).call(this,!1)}destroy(){this.matchesFloorStack(o(this,X).currentFloorStack)||this.hide()}};k=new WeakMap,X=new WeakMap,no=new WeakSet,Qo=a(function(t){for(let e of o(this,k).floors)o(this,X).updateState(e,{visible:t})},"#setVisible"),a(Jo,"Outdoors");var ko=Jo;function St(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||(O.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(St,"getOutdoorFloorStack");var ao={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!0,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},cameraLiftAnimationOptions:{duration:500,easing:"ease-in-out",interruptible:!0},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},lo=.2,Xo=.4;var Do=a((r,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=$t(r,e);if(i===void 0)return O.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:ao.indoorZoomThreshold,outdoorZoomThreshold:ao.outdoorZoomThreshold};let s=i+Xo,n=i+lo;return e.initialVisibility==="indoor-first"&&(s=i-lo,n=i-Xo),{indoorZoomThreshold:s,outdoorZoomThreshold:n}},"calculateZoomThresholds");function $t(r,t){let i=r.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),s=1/0,n;for(let f of i){let p=r.Camera.getFocusOnTransform(f).zoomLevel??1/0;p<s&&(s=p,n=f)}if(s!==1/0)return t.debug&&n&&r.Camera.getFocusOnTransform(n,{debugColor:"blue"}),s}a($t,"getDefaultZoomLevel");function jt(r,t){return`${t} ${r}`}a(jt,"formatMessage");var ot=class ot extends Error{constructor(t,e=Wo){super(jt(t,e)),this.name="MappedinError"}};a(ot,"MappedinError");var Bo=ot;var zt=a(r=>r,"linearEase"),Yt=a(r=>r*r,"quadEaseIn"),Wt=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),qt=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Ht=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),Kt={linear:zt,"ease-in":Yt,"ease-out":qt,"ease-in-out":Wt,"ease-out-cubic":Ht};function Qt(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(Qt,"getInterpolationBreakpoint");function Et(r,t,e,i="ease-in"){if(t.length!==e.length)throw new Bo("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=Qt(r,t),n=(r-t[s])/(t[s+1]-t[s]),f=typeof i=="function"?i(n):Kt[i](n);return e[s]+f*(e[s+1]-e[s])}a(Et,"interpolateMulti");var D,uo,co,Z,ho,et=class et{constructor(t,e,i){b(this,"layers");b(this,"visible");d(this,D);d(this,uo,[]);d(this,co,!1);d(this,Z,new Map);b(this,"interpolationFn");d(this,ho,1);this.layers=t,this.visible=e,c(this,D,i)}processLayerGroup(t,e){o(this,co)||(this.layers.forEach(i=>{let s=t[i];s&&o(this,uo).push(...s)}),c(this,co,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:s,indoorZoomThreshold:n}=e();return Et(i,[s,n],[1,0])}))}setOpacity(t){c(this,ho,t);for(let e of o(this,uo))if(e.startsWith("img_")){let i=o(this,D).Image3D.getById(e);if(i){if(!o(this,Z).has(e)){let n=o(this,D).getState(i.image);o(this,Z).set(e,n?.opacity??1)}let s=Math.min(o(this,Z).get(e),t);o(this,D).updateState(i.image,{opacity:s})}}else{let i=o(this,D).getMapData()?.getById("space",e);if(!i)continue;if(!o(this,Z).has(e)){let n=o(this,D).getState(i);o(this,Z).set(e,n?.opacity??1)}let s=Math.min(o(this,Z).get(e),t);o(this,D).updateState(i,{opacity:s,visible:s>0})}}get opacity(){return o(this,ho)}};D=new WeakMap,uo=new WeakMap,co=new WeakMap,Z=new WeakMap,ho=new WeakMap,a(et,"LayerGroup");var Mo=et;function tt(r,t,e){r.forEach(i=>{if(e?.forceOpacity!==void 0){i.setOpacity(e.forceOpacity),i.visible=e.forceOpacity===1;return}if(i.interpolationFn!=null){let s=i.interpolationFn(t);s!=null&&(i.setOpacity(s),i.visible=s===1)}})}a(tt,"runLayerGroupInterpolations");var B,l,G,u,j,z,S,M,Y,_,E,W,fo,mo,po,L,R,oo,go,N,P,U,m,it,vt,st,rt,nt,Tt,at,to,Fo,wt,Zo,_o,xo,bo,yo,So,eo,Lo,Ot,Vt,x,lt=class lt{constructor(t){d(this,m);d(this,B);d(this,l);d(this,G);d(this,u,ao);d(this,j,[]);d(this,z,new Set);d(this,S,new Map);d(this,M);d(this,Y,!1);d(this,_,!1);d(this,E,0);d(this,W,0);d(this,fo,[]);d(this,mo,{});d(this,po,{});d(this,L,"transition");d(this,R,"outdoor");d(this,oo,[]);d(this,go,[]);d(this,N,!1);d(this,P,[]);d(this,U,null);b(this,"sceneUpdateQueue",Promise.resolve());b(this,"on",a((t,e)=>{o(this,B).on(t,e)},"on"));b(this,"off",a((t,e)=>{o(this,B).off(t,e)},"off"));d(this,to,a(()=>{c(this,j,[]),o(this,z).clear();let t=o(this,u).isolateBelowGroundView&&o(this,E)<0;for(let e of o(this,go)){let i=o(this,S).get(e.floorStack.id);i&&(t&&i.minElevation>=0||(o(this,z).add(i.id),o(this,j).push(i)))}},"#updateBuildingsInView"));d(this,Fo,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;ct(e,this.focusedFacades)&&o(this,R)==="transition"&&!o(this,_)||(c(this,_,!1),c(this,go,e),o(this,to).call(this),o(this,u).autoFocus&&this.focus())},"#handleFacadesInViewChange"));d(this,Zo,a((t,e)=>{if(!this.isEnabled)return;let i=o(this,S).get(t.floorStack.id);i&&(e.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=t));let s=o(this,u).isolateBelowGroundView&&o(this,E)<0;i?.excluded===!1&&!o(this,M).matchesFloorStack(t.floorStack)&&c(this,E,t.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,E)<0,f=s&&!n;if(e.reason==="dynamic-focus")return;let p=F(this,m,wt).call(this),v=o(this,_o).call(this,t,e,f,p);if(p)return v;v.catch(h=>{O.error("setFloor override work failed after sync floor-change commit",h)})},"#setFloorHandler"));d(this,_o,a(async(t,e,i,s)=>{i&&(c(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,to).call(this)),await o(this,x).call(this,t),!(!this.isEnabled||e.signal.aborted)&&s&&this.isEnabled&&!e.signal.aborted&&await o(this,xo).call(this,t)},"#runFloorChangeWork"));d(this,xo,a(t=>{let e=o(this,l).getFloorStackAltitudeData(t.floorStack).get(t.elevation)?.altitude;if(typeof e=="number"&&o(this,l).Camera.elevation!==e)return o(this,l).Camera.animateElevation(e,o(this,u).cameraLiftAnimationOptions)},"#liftCameraToFloorAltitude"));d(this,bo,a(()=>{c(this,Y,!0)},"#handleUserInteractionStart"));d(this,yo,a(()=>{c(this,Y,!1)},"#handleUserInteractionEnd"));d(this,So,a(()=>{o(this,x).call(this)},"#handleGlobalStateChange"));d(this,eo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=ht(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,L)!==i&&(c(this,L,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let s=(o(this,l).Navigation?.floors?.length??0)>0;tt(o(this,P),e,s?{forceOpacity:0}:void 0)},"#handleCameraChange"));d(this,x,a(async t=>{if(!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)||[],p=s?.showAllFloorsIncludedInNavigation??!1,v=new Promise(async h=>{await this.sceneUpdateQueue;let g=pt({buildings:Array.from(o(this,S).values()),inViewSet:o(this,z),currentFloor:e,zoomState:o(this,L),mode:o(this,u).mode,elevation:o(this,E),floorIdsInNavigation:n,floorStackIdsInNavigation:f,showAllFloorsIncludedInNavigation:p,multiFloorView:s,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Co.getMultiFloorState,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,E),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(V=>o(this,l).getFloorStackAltitudeData(V),"getFloorStackAltitudeData")}),$=[];await Promise.all(Array.from(g.values()).map(async V=>{let{building:q,showIndoor:Eo,floorStackState:io,facadeState:vo,inFocus:To,isAboveGroundInIsolation:Go}=V;$.push(io);let y=gt(q,Eo);if(y==="indoor")return F(this,m,Ot).call(this,q,io,vo,To);if(y==="outdoor")return F(this,m,Vt).call(this,q,io,vo,f,Go)})),o(this,l).Outdoor.setOpacity(ft($,o(this,u).mode)),c(this,oo,o(this,j).filter(V=>g.get(V.id)?.showIndoor===!0).map(V=>V.facade)),o(this,B).publish("focus",{facades:o(this,oo)}),h()});return this.sceneUpdateQueue=v,v},"#applyBuildingStates"));c(this,B,new Oo),c(this,l,t),O.setLevel(J.logState),c(this,G,o(this,l).getMapData()),c(this,E,o(this,l).currentFloor.elevation),c(this,W,o(this,l).Camera.elevation);for(let e of o(this,G).getByType("facade")){let{floorStack:i}=e;if(i.floors.length===0||i.defaultFloor==null){O.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,S).set(i.id,new Vo(i,o(this,l)))}F(this,m,Tt).call(this),c(this,M,new ko(St(o(this,G),o(this,S)),o(this,l))),o(this,l).on("camera-change",o(this,eo)),o(this,l).on("facades-in-view-change",o(this,Fo)),o(this,l).on("user-interaction-start",o(this,bo)),o(this,l).on("user-interaction-end",o(this,yo)),o(this,l).on("global-state-change",o(this,So))}enable(t){if(o(this,N)){O.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,N,!0),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(o(this,Zo)),o(this,M).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&O.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,m,vt).call(this),o(this,eo).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)){O.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,N,!1),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(void 0)}get isEnabled(){return o(this,N)}get isIndoor(){return o(this,R)==="indoor"}get isOutdoor(){return o(this,R)==="outdoor"}get outdoorsFloorStack(){return o(this,M).floorStack}get layers(){return o(this,fo)}get layersBySpaceId(){return o(this,mo)}setIndoor(){c(this,R,"indoor"),c(this,L,"in-range"),F(this,m,it).call(this)}setOutdoor(){c(this,R,"outdoor"),c(this,L,"out-of-range"),F(this,m,it).call(this)}get focusedFacades(){return[...o(this,oo)]}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,E)<0,f=o(this,u).autoFocus,p=!!o(this,u).autoZoomThresholds,v=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:p,h=t;if(v&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){O.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:$,...V}=h;h=V}if(!p&&v?(c(this,U,()=>{if(!o(this,N))return;let g=o(this,u).indoorZoomThreshold,$=o(this,u).outdoorZoomThreshold;F(this,m,rt).call(this),F(this,m,nt).call(this,g,$),o(this,x).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,U))):p&&!v&&F(this,m,st).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=Ko(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=Ko(h.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,h?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),h.mode!=null&&(h.mode=bt.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),h.cameraLiftAnimationOptions!=null&&(h={...h,cameraLiftAnimationOptions:{...o(this,u).cameraLiftAnimationOptions,...h.cameraLiftAnimationOptions}}),c(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),v&&h.autoZoomThresholds!==void 0&&(F(this,m,rt).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,m,at).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,E)<0;n&&!g&&(c(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,to).call(this)),o(this,x).call(this)}F(this,m,nt).call(this,i,s),o(this,N)&&!f&&o(this,u).autoFocus&&(c(this,W,o(this,l).Camera.elevation),this.focus(o(this,u).setFloorOnFocus&&o(this,M).matchesFloorStack(o(this,l).currentFloor.floorStack)))}destroy(){this.disable(),F(this,m,st).call(this),o(this,l).off("facades-in-view-change",o(this,Fo)),o(this,l).off("camera-change",o(this,eo)),o(this,l).off("user-interaction-start",o(this,bo)),o(this,l).off("user-interaction-end",o(this,yo)),o(this,l).off("global-state-change",o(this,So)),o(this,S).forEach(t=>t.destroy()),o(this,M).destroy(),o(this,B).destroy(),c(this,P,[])}async focus(t=o(this,u).setFloorOnFocus){let e;if(t)if(Ft(o(this,W),o(this,l).Camera.elevation,o(this,Y)))c(this,W,o(this,l).Camera.elevation),c(this,_,!0);else{let i=mt(o(this,j),o(this,M),o(this,L)),s=i?Ao(i,o(this,u).mode,o(this,E)):void 0;s&&s.id!==o(this,l).currentFloor.id&&(e=s,o(this,l).setFloor(s,{context:"dynamic-focus"}))}await o(this,x).call(this,e)}preloadFloors(){F(this,m,at).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!Ho(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),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Ho(e,t))return;let i=o(this,S).get(t.id);i&&(i.activeFloor=e,o(this,x).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)}};B=new WeakMap,l=new WeakMap,G=new WeakMap,u=new WeakMap,j=new WeakMap,z=new WeakMap,S=new WeakMap,M=new WeakMap,Y=new WeakMap,_=new WeakMap,E=new WeakMap,W=new WeakMap,fo=new WeakMap,mo=new WeakMap,po=new WeakMap,L=new WeakMap,R=new WeakMap,oo=new WeakMap,go=new WeakMap,N=new WeakMap,P=new WeakMap,U=new WeakMap,m=new WeakSet,it=a(function(){o(this,u).autoFocus&&(o(this,Y)?this.focus():c(this,_,!0)),o(this,B).publish("state-change")},"#handleViewStateChange"),vt=a(function(){c(this,P,[]);for(let e of o(this,u).dynamicLayers){let i=new Mo([e],!0,o(this,l));i.processLayerGroup(o(this,po),()=>o(this,u)),o(this,P).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;tt(o(this,P),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),st=a(function(){o(this,U)&&(o(this,l).off("camera-screen-offsets-change",o(this,U)),c(this,U,null))},"#unsubscribeScreenOffsets"),rt=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:s}=Do(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-lo)},"#recalcThresholds"),nt=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,B).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),Tt=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)}),c(this,fo,t.map(({name:s})=>s)),c(this,mo,i),c(this,po,e)},"#setupLayers"),at=a(function(t){let e=[];for(let i of o(this,G).getByType("facade")){let s=o(this,S).get(i.floorStack.id);if(!s)continue;let n=Ao(s,t,o(this,E));n!=null&&Co.Floor.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),to=new WeakMap,Fo=new WeakMap,wt=a(function(){let{multiFloorView:t}=o(this,l).options;return!!t?.enabled&&!!t?.updateCameraElevationOnFloorChange},"#shouldAwaitFloorChangeCommit"),Zo=new WeakMap,_o=new WeakMap,xo=new WeakMap,bo=new WeakMap,yo=new WeakMap,So=new WeakMap,eo=new WeakMap,Lo=a(function(t,e,i,s=!1){t.forEach(n=>{if(n.floor)if(e){let p=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,p)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),Ot=a(async function(t,e,i,s){return F(this,m,Lo).call(this,e.floorStates,!0,s,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Vt=a(async function(t,e,i,s,n){let f=n;f&&F(this,m,Lo).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let p=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return p.result==="completed"&&!f&&F(this,m,Lo).call(this,e.floorStates,Yo({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,L)==="in-range",inFocus:o(this,z).has(t.id),mode:o(this,u).mode,elevation:o(this,E),inNavigation:s.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),p},"#animateOutdoorSequence"),x=new WeakMap,a(lt,"DynamicFocus");var No=lt;return xt(Jt);})();\n\n\n// Register the extension\nif (window.bridge && window.bridge.extensions) {\n try {\n window.bridge.extensions.register({ name: \'dynamic-focus\', package: { Extension: DynamicFocus.DynamicFocus } });\n if (window.rnDebug) window.rnDebug(\'Extension: dynamic-focus registered\');\n } catch(e) {\n if (window.rnDebug) window.rnDebug(\'Failed to register dynamic-focus extension: \' + e.message);\n }\n} else {\n if (window.rnDebug) window.rnDebug(\'Bridge or extensions not available for registration\');\n}';function k(){return q}n(k,"getRegistrationScript");function g(){P({extensionName:"dynamic-focus",getRegistrationScript:k,logger:F})}n(g,"useDynamicFocusRegistration");function b(o,s){if(typeof o!="string"||o.length===0)throw new Error("Event parameter must be a non-empty string");if(typeof s!="function")throw new Error("Callback parameter must be a function");const e=W($),{extensions:i,mapData:t}=e;if(!t)throw new Error("Map data is not available");g();const f=(i?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",l=x(d=>{try{let u=d;o==="focus"&&d.facades&&(u={...d,facades:S(t,d.facades)}),s(u)}catch(u){F.error(`Error in dynamic focus event callback for ${String(o)}:`,u)}},[o,t,s]);G({eventKey:`dynamic-focus:${String(o)}`,callback:l,setupScript:n(()=>R({extensionName:"dynamic-focus",eventName:String(o)}),"setupScript"),cleanupScript:n(()=>j({extensionName:"dynamic-focus",eventName:String(o)}),"cleanupScript"),shouldInject:f})}n(b,"useDynamicFocusEvent");function E(){const o=C(D),{bridge:s,extensions:e,updateExtensionState:i}=o;g();const t=e["dynamic-focus"],r=t?.registrationState||"unregistered",f=r==="registered",l=t?.isEnabled||!1,[d,u]=B(t?.focusedFacades||[]),w=L(e);w.current=e,b("focus",c(h=>{const p=h.facades;u(p),i("dynamic-focus",y=>({...y,registrationState:r,focusedFacades:p}))},[r,i]));const a=c(async(h,p=[])=>{if(!s?.isReady)throw new Error("Bridge is not ready. Ensure the WebView is loaded.");return await s.instruct({type:"extension",payload:{name:"dynamic-focus",method:h,args:p}})},[s]),T=c(async h=>{w.current?.["dynamic-focus"]?.isEnabled||(await a("enable",[h]),i("dynamic-focus",V=>({...V,isEnabled:!0})))},[a,i]),M=c(async h=>await a("updateState",[h]),[a]),O=c(async()=>await a("getState"),[a]),I=c(async h=>await a("focus",[h]),[a]),Z=c(async()=>{await a("disable"),u([]),i("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[a,u,i]);return{isReady:f,isEnabled:l,focusedFacades:d,updateState:M,getState:O,focus:I,disable:Z,enable:T}}n(E,"useDynamicFocus");export{E as useDynamicFocus,b as useDynamicFocusEvent};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mappedin/dynamic-focus",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.30.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/
|
|
41
|
-
"@mappedin/
|
|
42
|
-
"@mappedin/react-sdk": "^6.
|
|
40
|
+
"@mappedin/mappedin-js": "^6.30.0",
|
|
41
|
+
"@mappedin/react-sdk": "^6.30.0",
|
|
42
|
+
"@mappedin/react-native-sdk": "^6.30.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@mappedin/react-sdk": {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var rt=Object.defineProperty;var st=s=>{throw TypeError(s)};var At=(s,t,e)=>t in s?rt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t)=>rt(s,"name",{value:t,configurable:!0});var E=(s,t,e)=>At(s,typeof t!="symbol"?t+"":t,e),xo=(s,t,e)=>t.has(s)||st("Cannot "+e);var o=(s,t,e)=>(xo(s,t,"read from private field"),e?e.call(s):t.get(s)),d=(s,t,e)=>t.has(s)?st("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),c=(s,t,e,i)=>(xo(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e),F=(s,t,e)=>(xo(s,t,"access private method"),e);var y={env:{NODE_ENV:"production",npm_package_version:"6.28.0-beta.0"}};var ro={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!0,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},cameraLiftAnimationOptions:{duration:500,easing:"ease-in-out",interruptible:!0},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},so=.2,Co=.4;var Go="[MappedinJS]";var Bt={log:0,debug:0,info:1,warn:2,error:3,silent:4};function Dt(s){return Bt[s.toLowerCase()]}a(Dt,"parseLogLevel");function Ro(s="",{prefix:t=Go}={}){let e=`${t}${s?`-${s}`:""}`,i=a((r,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(p=>p instanceof Error&&p.stack?`${p.message}
|
|
2
|
-
${p.stack}`:p);window.rnDebug(`${s} ${r}: ${f.join(" ")}`)}},"rnDebug");return{logState:y.env.NODE_ENV==="test"?4:1,debug(...r){this.logState<=0&&(console.debug(e,...r),i("debug",r))},log(...r){this.debug(...r)},info(...r){this.logState<=1&&(console.info(e,...r),i("info",r))},warn(...r){this.logState<=2&&(console.warn(e,...r),i("warn",r))},error(...r){this.logState<=3&&(console.error(e,...r),i("error",r))},assert(...r){console.assert(...r)},time(r){console.time(r)},timeEnd(r){console.timeEnd(r)},setLevel(r){let n=typeof r=="string"?Dt(r):r;if(n===void 0||!(n>=0&&n<=4)){console.warn(e,`setLevel: unknown log level "${r}"`);return}this.logState=n}}}a(Ro,"createLogger");var Lt=Ro();var K=Lt;var V=Ro("",{prefix:"[DynamicFocus]"});var nt=a((s,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Mt(s,e);if(i===void 0)return V.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:ro.indoorZoomThreshold,outdoorZoomThreshold:ro.outdoorZoomThreshold};let r=i+Co,n=i+so;return e.initialVisibility==="indoor-first"&&(r=i-so,n=i-Co),{indoorZoomThreshold:r,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Mt(s,t){let i=s.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),r=1/0,n;for(let f of i){let p=s.Camera.getFocusOnTransform(f).zoomLevel??1/0;p<r&&(r=p,n=f)}if(r!==1/0)return t.debug&&n&&s.Camera.getFocusOnTransform(n,{debugColor:"blue"}),r}a(Mt,"getDefaultZoomLevel");import{Floor as Ht,getMultiFloorState as Kt}from"@mappedin/mappedin-js";function at(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(at,"arraysEqual");var Po=class Po{_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 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}),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(Po,"PubSub");var wo=Po;import{Facade as Zt,Floor as _t,FloorStack as Nt}from"@mappedin/mappedin-js";var A,no,G,O,w,k,Q,J,Uo=class Uo{constructor(t,e){E(this,"__type","building");d(this,A);d(this,no,new Map);d(this,G,new Map);d(this,O,[]);d(this,w);d(this,k);E(this,"defaultFloor");E(this,"activeFloor");E(this,"excluded",!1);E(this,"aboveGroundFloors",[]);d(this,Q);d(this,J);c(this,A,t),c(this,no,new Map(t.floors.map(r=>[r.id,r]))),c(this,G,new Map(t.floors.map(r=>[r.elevation,r]))),c(this,O,Array.from(o(this,G).values()).sort((r,n)=>r.elevation-n.elevation));let i=t.defaultFloor;if(!i)throw new Error(`Building created for floor stack "${t.id}" with no resolvable default floor`);this.defaultFloor=i,this.activeFloor=this.defaultFloor,c(this,w,e),this.aboveGroundFloors=o(this,O).filter(r=>r.elevation>=0)}get id(){return o(this,A).id}get name(){return o(this,A).name}get floors(){return o(this,A).floors}get floorStack(){return o(this,A)}get facade(){return o(this,A).facade}get isCurrentFloorStack(){return this.id===o(this,w).currentFloorStack.id}get isIndoor(){let t=o(this,w).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&&c(this,Q,Math.max(...o(this,G).keys())),o(this,Q)}get minElevation(){return o(this,J)==null&&c(this,J,Math.min(...o(this,G).keys())),o(this,J)}has(t){return _t.is(t)?o(this,no).has(t.id):Nt.is(t)?t.id===o(this,A).id:Zt.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,G).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,O)[o(this,O).length-1];for(let i=o(this,O).length-1;i>=0;i--){let r=o(this,O)[i];if(r.elevation<=t)return r}}else{if(t<this.minElevation)return o(this,O)[0];for(let i of o(this,O))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,O)[o(this,O).length-1]}cancelAnimation(){o(this,k)&&(o(this,k).animation.cancel(),c(this,k,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,k)?.state||o(this,w).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,w).updateState(this.facade,{visible:!0}),r!==void 0){c(this,k,{animation:o(this,w).animateState(this.facade,{opacity:r},{duration:e.duration}),state:t});let f=await o(this,k).animation;if(c(this,k,void 0),f.result==="cancelled")return f}return n===!1&&o(this,w).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,A).floors.forEach(t=>{o(this,w).updateState(t,{visible:t.id===o(this,w).currentFloor.id})}),this.has(o(this,w).currentFloor)||o(this,w).updateState(this.facade,{visible:!0,opacity:1})}};A=new WeakMap,no=new WeakMap,G=new WeakMap,O=new WeakMap,w=new WeakMap,k=new WeakMap,Q=new WeakMap,J=new WeakMap,a(Uo,"Building");var Oo=Uo;function lt(s,t,e){return s>=t?"in-range":s<=e?"out-of-range":"transition"}a(lt,"getZoomState");function Vo(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);case"active-floor":return i.activeFloor;default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Vo,"getFloorToShow");function xt(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(xt,"getFacadeState");function Ct(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(Ct,"getSingleBuildingState");function ut(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(ut,"getOutdoorOpacity");function dt(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(dt,"getSetFloorTargetFromZoomState");function ct(s){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:r,mode:n,elevation:f,floorIdsInNavigation:p,floorStackIdsInNavigation:T,showAllFloorsIncludedInNavigation:h,multiFloorView:g,getMultiFloorState:j,dynamicBuildingInteriors:I,isolateBelowGroundView:H,currentElevation:So,forceInteriorsVisible:io,getFloorStackAltitudeData:Eo}=s,vo=new Map,Zo=H&&So<0&&r==="in-range";for(let b of t){let it=e.has(b.id),To=Zo&&b.minElevation>=0,wt=To?!1:it,_o=To?!1:$o({building:b,currentFloor:i,inRange:r==="in-range",inFocus:it,mode:n,elevation:f,inNavigation:T.includes(b.id),dynamicBuildingInteriors:I,forceInteriorsVisible:io}),No=i.floorStack.id===b.id?b.activeFloor:Vo(b,n,f),Ot=g?.enabled?j(b.floors,No||b.activeFloor,p,Eo(b.id),{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},h):Ct(b.floorStack,No||b.activeFloor,_o),Vt=H&&So<0&&r==="in-range",It=xt(b.facade,_o,Vt,To);vo.set(b.id,{building:b,showIndoor:_o,floorStackState:Ot,facadeState:It,inFocus:wt,floorToShow:No,isAboveGroundInIsolation:To})}return vo}a(ct,"getBuildingStates");function ht(s,t){return s.excluded?"none":t?"indoor":"outdoor"}a(ht,"getBuildingAnimationType");function $o(s){let{building:t,currentFloor:e,inRange:i,inFocus:r,mode:n,elevation:f,inNavigation:p,dynamicBuildingInteriors:T,forceInteriorsVisible:h}=s;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(h===!0||p===!0)return!0;if(!T)return e.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(f)!=null;default:break}return!0}a($o,"shouldShowIndoor");function ft(s,t,e){return s!==t&&!e}a(ft,"shouldDeferSetFloor");var mt=["default-floor","active-floor","lock-elevation","nearest-elevation"];import{Floor as Gt,FloorStack as Rt}from"@mappedin/mappedin-js";function pt(s,t,e,i){return(s<t||s>e)&&K.warn(i),Math.min(e,Math.max(t,s))}a(pt,"clampWithWarning");function jo(s,t){return!Gt.is(s)||s?.floorStack==null||!Rt.is(t)?!1:s.floorStack.id!==t.id?(K.warn(`Floor (${s.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(jo,"validateFloorForStack");function zo(s,t,e,i){return pt(s,t,e,`${i} must be between ${t} and ${e}.`)}a(zo,"validateZoomThreshold");var B,X,ao,Yo,Wo=class Wo{constructor(t,e){d(this,ao);E(this,"__type","outdoors");d(this,B);d(this,X);c(this,B,t),c(this,X,e)}get id(){return o(this,B).id}get floorStack(){return o(this,B)}get floor(){return o(this,B).defaultFloor}matchesFloorStack(t){return t===o(this,B)||t===o(this,B).id}show(){F(this,ao,Yo).call(this,!0)}hide(){F(this,ao,Yo).call(this,!1)}destroy(){this.matchesFloorStack(o(this,X).currentFloorStack)||this.hide()}};B=new WeakMap,X=new WeakMap,ao=new WeakSet,Yo=a(function(t){for(let e of o(this,B).floors)o(this,X).updateState(e,{visible:t})},"#setVisible"),a(Wo,"Outdoors");var Io=Wo;function gt(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||(V.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(gt,"getOutdoorFloorStack");function Pt(s,t){return`${t} ${s}`}a(Pt,"formatMessage");var qo=class qo extends Error{constructor(t,e=Go){super(Pt(t,e)),this.name="MappedinError"}};a(qo,"MappedinError");var Ao=qo;var Ut=a(s=>s,"linearEase"),$t=a(s=>s*s,"quadEaseIn"),jt=a(s=>1-Math.cos(s*Math.PI/2),"easeIn"),zt=a(s=>1-(1-s)*(1-s),"quadEaseOut"),Yt=a(s=>1-Math.pow(1-s,3),"cubicEaseOut"),Wt={linear:Ut,"ease-in":$t,"ease-out":zt,"ease-in-out":jt,"ease-out-cubic":Yt};function qt(s,t){let e=0;if(t.length<2)return e;let r=t[0]<t[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<t.length-1&&r(s,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(qt,"getInterpolationBreakpoint");function Ft(s,t,e,i="ease-in"){if(t.length!==e.length)throw new Ao("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=qt(s,t),n=(s-t[r])/(t[r+1]-t[r]),f=typeof i=="function"?i(n):Wt[i](n);return e[r]+f*(e[r+1]-e[r])}a(Ft,"interpolateMulti");var D,lo,uo,N,co,Ko=class Ko{constructor(t,e,i){E(this,"layers");E(this,"visible");d(this,D);d(this,lo,[]);d(this,uo,!1);d(this,N,new Map);E(this,"interpolationFn");d(this,co,1);this.layers=t,this.visible=e,c(this,D,i)}processLayerGroup(t,e){o(this,uo)||(this.layers.forEach(i=>{let r=t[i];r&&o(this,lo).push(...r)}),c(this,uo,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:r,indoorZoomThreshold:n}=e();return Ft(i,[r,n],[1,0])}))}setOpacity(t){c(this,co,t);for(let e of o(this,lo))if(e.startsWith("img_")){let i=o(this,D).Image3D.getById(e);if(i){if(!o(this,N).has(e)){let n=o(this,D).getState(i.image);o(this,N).set(e,n?.opacity??1)}let r=Math.min(o(this,N).get(e),t);o(this,D).updateState(i.image,{opacity:r})}}else{let i=o(this,D).getMapData()?.getById("space",e);if(!i)continue;if(!o(this,N).has(e)){let n=o(this,D).getState(i);o(this,N).set(e,n?.opacity??1)}let r=Math.min(o(this,N).get(e),t);o(this,D).updateState(i,{opacity:r,visible:r>0})}}get opacity(){return o(this,co)}};D=new WeakMap,lo=new WeakMap,uo=new WeakMap,N=new WeakMap,co=new WeakMap,a(Ko,"LayerGroup");var ko=Ko;function Ho(s,t,e){s.forEach(i=>{if(e?.forceOpacity!==void 0){i.setOpacity(e.forceOpacity),i.visible=e.forceOpacity===1;return}if(i.interpolationFn!=null){let r=i.interpolationFn(t);r!=null&&(i.setOpacity(r),i.visible=r===1)}})}a(Ho,"runLayerGroupInterpolations");var L,l,R,u,z,Y,S,M,W,x,v,q,ho,fo,mo,Z,P,oo,po,_,U,$,m,Qo,yt,Jo,Xo,ot,St,tt,to,go,Et,Do,Lo,Mo,Fo,bo,yo,eo,Bo,vt,Tt,C,et=class et{constructor(t){d(this,m);d(this,L);d(this,l);d(this,R);d(this,u,ro);d(this,z,[]);d(this,Y,new Set);d(this,S,new Map);d(this,M);d(this,W,!1);d(this,x,!1);d(this,v,0);d(this,q,0);d(this,ho,[]);d(this,fo,{});d(this,mo,{});d(this,Z,"transition");d(this,P,"outdoor");d(this,oo,[]);d(this,po,[]);d(this,_,!1);d(this,U,[]);d(this,$,null);E(this,"sceneUpdateQueue",Promise.resolve());E(this,"on",a((t,e)=>{o(this,L).on(t,e)},"on"));E(this,"off",a((t,e)=>{o(this,L).off(t,e)},"off"));d(this,to,a(()=>{c(this,z,[]),o(this,Y).clear();let t=o(this,u).isolateBelowGroundView&&o(this,v)<0;for(let e of o(this,po)){let i=o(this,S).get(e.floorStack.id);i&&(t&&i.minElevation>=0||(o(this,Y).add(i.id),o(this,z).push(i)))}},"#updateBuildingsInView"));d(this,go,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;at(e,this.focusedFacades)&&o(this,P)==="transition"&&!o(this,x)||(c(this,x,!1),c(this,po,e),o(this,to).call(this),o(this,u).autoFocus&&this.focus())},"#handleFacadesInViewChange"));d(this,Do,a((t,e)=>{if(!this.isEnabled)return;let i=o(this,S).get(t.floorStack.id);i&&(e.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=t));let r=o(this,u).isolateBelowGroundView&&o(this,v)<0;i?.excluded===!1&&!o(this,M).matchesFloorStack(t.floorStack)&&c(this,v,t.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,v)<0,f=r&&!n;if(e.reason==="dynamic-focus")return;let p=F(this,m,Et).call(this),T=o(this,Lo).call(this,t,e,f,p);if(p)return T;T.catch(h=>{V.error("setFloor override work failed after sync floor-change commit",h)})},"#setFloorHandler"));d(this,Lo,a(async(t,e,i,r)=>{i&&(c(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,to).call(this)),await o(this,C).call(this,t),!(!this.isEnabled||e.signal.aborted)&&r&&this.isEnabled&&!e.signal.aborted&&await o(this,Mo).call(this,t)},"#runFloorChangeWork"));d(this,Mo,a(t=>{let e=o(this,l).getFloorStackAltitudeData(t.floorStack).get(t.elevation)?.altitude;if(typeof e=="number"&&o(this,l).Camera.elevation!==e)return o(this,l).Camera.animateElevation(e,o(this,u).cameraLiftAnimationOptions)},"#liftCameraToFloorAltitude"));d(this,Fo,a(()=>{c(this,W,!0)},"#handleUserInteractionStart"));d(this,bo,a(()=>{c(this,W,!1)},"#handleUserInteractionEnd"));d(this,yo,a(()=>{o(this,C).call(this)},"#handleGlobalStateChange"));d(this,eo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=lt(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,Z)!==i&&(c(this,Z,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let r=(o(this,l).Navigation?.floors?.length??0)>0;Ho(o(this,U),e,r?{forceOpacity:0}:void 0)},"#handleCameraChange"));d(this,C,a(async t=>{if(!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(h=>h.id)||[],f=o(this,l).Navigation?.floorStacks.map(h=>h.id)||[],p=r?.showAllFloorsIncludedInNavigation??!1,T=new Promise(async h=>{await this.sceneUpdateQueue;let g=ct({buildings:Array.from(o(this,S).values()),inViewSet:o(this,Y),currentFloor:e,zoomState:o(this,Z),mode:o(this,u).mode,elevation:o(this,v),floorIdsInNavigation:n,floorStackIdsInNavigation:f,showAllFloorsIncludedInNavigation:p,multiFloorView:r,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Kt,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,v),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(I=>o(this,l).getFloorStackAltitudeData(I),"getFloorStackAltitudeData")}),j=[];await Promise.all(Array.from(g.values()).map(async I=>{let{building:H,showIndoor:So,floorStackState:io,facadeState:Eo,inFocus:vo,isAboveGroundInIsolation:Zo}=I;j.push(io);let b=ht(H,So);if(b==="indoor")return F(this,m,vt).call(this,H,io,Eo,vo);if(b==="outdoor")return F(this,m,Tt).call(this,H,io,Eo,f,Zo)})),o(this,l).Outdoor.setOpacity(ut(j,o(this,u).mode)),c(this,oo,o(this,z).filter(I=>g.get(I.id)?.showIndoor===!0).map(I=>I.facade)),o(this,L).publish("focus",{facades:o(this,oo)}),h()});return this.sceneUpdateQueue=T,T},"#applyBuildingStates"));c(this,L,new wo),c(this,l,t),V.setLevel(K.logState),c(this,R,o(this,l).getMapData()),c(this,v,o(this,l).currentFloor.elevation),c(this,q,o(this,l).Camera.elevation);for(let e of o(this,R).getByType("facade")){let{floorStack:i}=e;if(i.floors.length===0||i.defaultFloor==null){V.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,S).set(i.id,new Oo(i,o(this,l)))}F(this,m,St).call(this),c(this,M,new Io(gt(o(this,R),o(this,S)),o(this,l))),o(this,l).on("camera-change",o(this,eo)),o(this,l).on("facades-in-view-change",o(this,go)),o(this,l).on("user-interaction-start",o(this,Fo)),o(this,l).on("user-interaction-end",o(this,bo)),o(this,l).on("global-state-change",o(this,yo))}enable(t){if(o(this,_)){V.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,_,!0),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(o(this,Do)),o(this,M).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,m,yt).call(this),o(this,eo).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,_)){V.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,_,!1),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(void 0)}get isEnabled(){return o(this,_)}get isIndoor(){return o(this,P)==="indoor"}get isOutdoor(){return o(this,P)==="outdoor"}get outdoorsFloorStack(){return o(this,M).floorStack}get layers(){return o(this,ho)}get layersBySpaceId(){return o(this,fo)}setIndoor(){c(this,P,"indoor"),c(this,Z,"in-range"),F(this,m,Qo).call(this)}setOutdoor(){c(this,P,"outdoor"),c(this,Z,"out-of-range"),F(this,m,Qo).call(this)}get focusedFacades(){return[...o(this,oo)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,r=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,v)<0,f=o(this,u).autoFocus,p=!!o(this,u).autoZoomThresholds,T=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:p,h=t;if(T&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:j,...I}=h;h=I}if(!p&&T?(c(this,$,()=>{if(!o(this,_))return;let g=o(this,u).indoorZoomThreshold,j=o(this,u).outdoorZoomThreshold;F(this,m,Xo).call(this),F(this,m,ot).call(this,g,j),o(this,C).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,$))):p&&!T&&F(this,m,Jo).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=zo(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=zo(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),h.cameraLiftAnimationOptions!=null&&(h={...h,cameraLiftAnimationOptions:{...o(this,u).cameraLiftAnimationOptions,...h.cameraLiftAnimationOptions}}),c(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),T&&h.autoZoomThresholds!==void 0&&(F(this,m,Xo).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,m,tt).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,v)<0;n&&!g&&(c(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,to).call(this)),o(this,C).call(this)}F(this,m,ot).call(this,i,r),o(this,_)&&!f&&o(this,u).autoFocus&&(c(this,q,o(this,l).Camera.elevation),this.focus(o(this,u).setFloorOnFocus&&o(this,M).matchesFloorStack(o(this,l).currentFloor.floorStack)))}destroy(){this.disable(),F(this,m,Jo).call(this),o(this,l).off("facades-in-view-change",o(this,go)),o(this,l).off("camera-change",o(this,eo)),o(this,l).off("user-interaction-start",o(this,Fo)),o(this,l).off("user-interaction-end",o(this,bo)),o(this,l).off("global-state-change",o(this,yo)),o(this,S).forEach(t=>t.destroy()),o(this,M).destroy(),o(this,L).destroy(),c(this,U,[])}async focus(t=o(this,u).setFloorOnFocus){let e;if(t)if(ft(o(this,q),o(this,l).Camera.elevation,o(this,W)))c(this,q,o(this,l).Camera.elevation),c(this,x,!0);else{let i=dt(o(this,z),o(this,M),o(this,Z)),r=i?Vo(i,o(this,u).mode,o(this,v)):void 0;r&&r.id!==o(this,l).currentFloor.id&&(e=r,o(this,l).setFloor(r,{context:"dynamic-focus"}))}await o(this,C).call(this,e)}preloadFloors(){F(this,m,tt).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!jo(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),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!jo(e,t))return;let i=o(this,S).get(t.id);i&&(i.activeFloor=e,o(this,C).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,S).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,S).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){return o(this,S).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};L=new WeakMap,l=new WeakMap,R=new WeakMap,u=new WeakMap,z=new WeakMap,Y=new WeakMap,S=new WeakMap,M=new WeakMap,W=new WeakMap,x=new WeakMap,v=new WeakMap,q=new WeakMap,ho=new WeakMap,fo=new WeakMap,mo=new WeakMap,Z=new WeakMap,P=new WeakMap,oo=new WeakMap,po=new WeakMap,_=new WeakMap,U=new WeakMap,$=new WeakMap,m=new WeakSet,Qo=a(function(){o(this,u).autoFocus&&(o(this,W)?this.focus():c(this,x,!0)),o(this,L).publish("state-change")},"#handleViewStateChange"),yt=a(function(){c(this,U,[]);for(let e of o(this,u).dynamicLayers){let i=new ko([e],!0,o(this,l));i.processLayerGroup(o(this,mo),()=>o(this,u)),o(this,U).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;Ho(o(this,U),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),Jo=a(function(){o(this,$)&&(o(this,l).off("camera-screen-offsets-change",o(this,$)),c(this,$,null))},"#unsubscribeScreenOffsets"),Xo=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:r}=nt(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=r,(e.expandMinZoom??!0)&&r<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(r-so)},"#recalcThresholds"),ot=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,L).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),St=a(function(){let t=o(this,R).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)}),c(this,ho,t.map(({name:r})=>r)),c(this,fo,i),c(this,mo,e)},"#setupLayers"),tt=a(function(t){let e=[];for(let i of o(this,R).getByType("facade")){let r=o(this,S).get(i.floorStack.id);if(!r)continue;let n=Vo(r,t,o(this,v));n!=null&&Ht.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),to=new WeakMap,go=new WeakMap,Et=a(function(){let{multiFloorView:t}=o(this,l).options;return!!t?.enabled&&!!t?.updateCameraElevationOnFloorChange},"#shouldAwaitFloorChangeCommit"),Do=new WeakMap,Lo=new WeakMap,Mo=new WeakMap,Fo=new WeakMap,bo=new WeakMap,yo=new WeakMap,eo=new WeakMap,Bo=a(function(t,e,i,r=!1){t.forEach(n=>{if(n.floor)if(e){let p=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,p)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),vt=a(async function(t,e,i,r){return F(this,m,Bo).call(this,e.floorStates,!0,r,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Tt=a(async function(t,e,i,r,n){let f=n;f&&F(this,m,Bo).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let p=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return p.result==="completed"&&!f&&F(this,m,Bo).call(this,e.floorStates,$o({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,Z)==="in-range",inFocus:o(this,Y).has(t.id),mode:o(this,u).mode,elevation:o(this,v),inNavigation:r.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),p},"#animateOutdoorSequence"),C=new WeakMap,a(et,"DynamicFocus");var bt=et;export{a,nt as b,bt as c};
|