@mapxus/mapxus-map-jp 10.0.0 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(p,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("@mapxus/mapxus-auth-jp"),require("maplibre-gl")):typeof define=="function"&&define.amd?define(["exports","@mapxus/mapxus-auth-jp","maplibre-gl"],T):(p=typeof globalThis<"u"?globalThis:p||self,T(p.MapxusMap={},p.MapxusAuth,p.maplibregl))})(this,(function(p,T,kt){"use strict";var mr={value:()=>{}};function ye(){for(var t=0,e=arguments.length,i={},r;t<e;++t){if(!(r=arguments[t]+"")||r in i||/[\s.]/.test(r))throw new Error("illegal type: "+r);i[r]=[]}return new Ae(i)}function Ae(t){this._=t}function br(t,e){return t.trim().split(/^|\s+/).map(function(i){var r="",n=i.indexOf(".");if(n>=0&&(r=i.slice(n+1),i=i.slice(0,n)),i&&!e.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:r}})}Ae.prototype=ye.prototype={constructor:Ae,on:function(t,e){var i=this._,r=br(t+"",i),n,s=-1,o=r.length;if(arguments.length<2){for(;++s<o;)if((n=(t=r[s]).type)&&(n=Sr(i[n],t.name)))return n;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(n=(t=r[s]).type)i[n]=Dt(i[n],t.name,e);else if(e==null)for(n in i)i[n]=Dt(i[n],t.name,null);return this},copy:function(){var t={},e=this._;for(var i in e)t[i]=e[i].slice();return new Ae(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var i=new Array(n),r=0,n,s;r<n;++r)i[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],r=0,n=s.length;r<n;++r)s[r].value.apply(e,i)},apply:function(t,e,i){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],n=0,s=r.length;n<s;++n)r[n].value.apply(e,i)}};function Sr(t,e){for(var i=0,r=t.length,n;i<r;++i)if((n=t[i]).name===e)return n.value}function Dt(t,e,i){for(var r=0,n=t.length;r<n;++r)if(t[r].name===e){t[r]=mr,t=t.slice(0,r).concat(t.slice(r+1));break}return i!=null&&t.push({name:e,value:i}),t}const Je={version:"10.0.0"}.version,Ht="https://map-api.mapxus.co.jp/bms",R=10,k=1;class D{static instance;_globalDispatcher;_httpSession;_theme=null;_isSDKInitialized=!1;constructor(){}static getInstance(){return D.instance||(D.instance=new D),D.instance}setGlobalDispatcher(e){this._globalDispatcher=e}getGlobalDispatcher(){return this._globalDispatcher}async getHttpSession(){return this._httpSession||(this.registerSDK(),this._httpSession=await T.HTTPSession.create(T.SDKName.MapSDK,T.base64Encode(`version-${Je}`)),this._httpSession.setBaseURL(Ht),this._httpSession.setRetryConfig(3)),this._httpSession}registerSDK(){this._isSDKInitialized||(this._isSDKInitialized=!0,T.reportLog(`${T.SDKName.MapSDK} initialized`))}get theme(){return this._theme}setTheme(e){this._theme=e}clear(){this._httpSession.destroy(),this._globalDispatcher=null,D.instance=null}}const Nt=["unauthorized","initError"],et=globalThis,tt=ye(...Nt);D.getInstance().setGlobalDispatcher(tt),et.MapxusMapEvents=et.MapxusMapEvents||{},et.MapxusMapEvents.on=function(t,e){return tt.on(t,e),{off:()=>tt.on(t,null)}};var Me={exports:{}},Ut;function vr(){if(Ut)return Me.exports;Ut=1;function t(){}return t.prototype={on:function(e,i,r){var n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:i,ctx:r}),this},once:function(e,i,r){var n=this;function s(){n.off(e,s),i.apply(r,arguments)}return s._=i,this.on(e,s,r)},emit:function(e){var i=[].slice.call(arguments,1),r=((this.e||(this.e={}))[e]||[]).slice(),n=0,s=r.length;for(n;n<s;n++)r[n].fn.apply(r[n].ctx,i);return this},off:function(e,i){var r=this.e||(this.e={}),n=r[e],s=[];if(n&&i)for(var o=0,a=n.length;o<a;o++)n[o].fn!==i&&n[o].fn._!==i&&s.push(n[o]);return s.length?r[e]=s:delete r[e],this}},Me.exports=t,Me.exports.TinyEmitter=t,Me.exports}var Ir=vr(),xe=(t=>(t[t.VENUE=0]="VENUE",t[t.GLOBAL=1]="GLOBAL",t))(xe||{});function Lr(t){return t.layers.filter(e=>!rt(e.source))}function it(t){return t.layers.filter(e=>rt(e.source))}function rt(t){return typeof t!="string"?!1:t.startsWith("indoor-")}function nt(t){const{buildingId:e,labelCenter:{lat:i,lon:r},floors:n,name:s,venueId:o,defaultFloor:a}=t,l=Object.entries(s).reduce((c,[f,g])=>{const _=f==="default"?"name":`name:${f}`;return Object.assign(c,{[_]:g})},{}),{codes:d,ids:u,ordinals:h}=n.reduce((c,f)=>{const{id:g,code:_,ordinal:y}=f;return{codes:c.codes?`${c.codes},${_}`:_,ids:c.ids?`${c.ids},${g}`:g,ordinals:`${c.ordinals}`?`${c.ordinals},${y}`:`${y}`}},{codes:"",ids:"",ordinals:""});return{layer:{id:"mapxus-building-line"},properties:{building:"yes",id:e,label_center:`${r},${i}`,level_ids:u,level_names:d,ordinals:h,"ref:venue":o,...l,...a?{default_displayed_floor:a}:{}},source:"indoor-planet",sourceLayer:"mapxus_building"}}function Te(t){const{address:e,buildings:i,id:r,name:n,type:s,labelCenter:{lon:o,lat:a},defaultBuilding:l,sharedFloors:d}=t,u=Object.entries(e).reduce((_,[y,m])=>Object.assign(_,y==="default"?{"addr:street":m.street,"addr:housenumber":m.housenumber}:{[`addr:street:${y}`]:m.street}),{}),h=Object.entries(n).reduce((_,[y,m])=>{const S=y==="default"?"name":`name:${y}`;return Object.assign(_,{[S]:m})},{}),c=l?i.find(_=>_.id===l)?.defaultFloor:null,f=l?{default_displayed_building:l,...c?{default_displayed_ordinal:c}:{}}:{},g=d?.length?{shared_level_ids:d.map(({id:_})=>_).join(","),shared_level_ordinals:d.map(({ordinal:_})=>_).join(",")}:{};return{layer:{id:"mapxus-venue-fill"},properties:{...u,...h,id:r,venue:s,label_center:`${o},${a}`,building_ids:i.map(({id:_})=>_).join(),...f,...g},source:"indoor-planet",sourceLayer:"mapxus_venue"}}function w(t,e=","){return typeof t!="string"||!t.trim()?[]:t.split(e)}const me="reserve_mapxus-level-fill",x="reserve_mapxus-shared-level-fill",be="reserve_mapxus-building-fill";var M=(t=>(t.ENGLISH="en",t.CHINESE_SIMPLIFIED="zh-Hans",t.CHINESE_TRADITIONAL="zh-Hant",t.CHINESE_TRADITIONAL_TW="zh-Hant-TW",t.JAPANESE="ja",t.KOREAN="ko",t.FILIPINO="fil",t.INDONESIAN="id",t.PORTUGUESE="pt",t.THAI="th",t.VIETNAMESE="vi",t.ARABIC="ar",t))(M||{});function jt(t){let e=null;return wr(t)?e=M.ENGLISH:Br(t)?e=M.CHINESE_SIMPLIFIED:Er(t)?e=M.CHINESE_TRADITIONAL:Pr(t)?e=M.CHINESE_TRADITIONAL_TW:Fr(t)?e=M.JAPANESE:Cr(t)?e=M.KOREAN:Or(t)?e=M.FILIPINO:$r(t)?e=M.INDONESIAN:Ar(t)?e=M.PORTUGUESE:Mr(t)?e=M.THAI:xr(t)?e=M.VIETNAMESE:Tr(t)&&(e=M.ARABIC),e}function wr(t){return/^en(-(US|GB|AU))?$/.test(t)}function Br(t){return/^zh(-(Hans|CN))?$/.test(t)}function Er(t){return/^zh-(Hant|HK|MO)$/.test(t)}function Pr(t){return t==="zh-TW"}function Fr(t){return/^ja(-JP)?$/.test(t)}function Cr(t){return/^ko(-KR)?$/.test(t)}function Or(t){return/^(fil|tl)(-PH)?$/.test(t)}function $r(t){return/^id(-ID)?$/.test(t)}function Ar(t){return/^pt(-(BR|PT))?$/.test(t)}function Mr(t){return/^th(-TH)?$/.test(t)}function xr(t){return/^vi(-VN)?$/.test(t)}function Tr(t){return/^ar(-(DZ|BH|EG|IQ|JO|KW|LB|LY|MA|OM|QA|SA|SY|TN|AE|YE))?$/.test(t)}const Re={lineWidth:3,lineColor:"#A5E3FF",lineOpacity:1,lineOffset:-1.5},Vt={fontColor:"#8c8c8c",activeFontColor:"#fff",backgroundColor:"#fff",activeBackgroundColor:"#074769",itemSize:50,itemCount:4,defaultFolded:!1},Rr=jt(window.navigator.language)??M.ENGLISH;let zt=class extends Error{status;constructor(e,i){super(e);const{status:r,name:n}=i;r!==void 0&&(this.status=r),n!==void 0&&(this.name=n)}};function kr(t,e=30){let i,r=null;return{promise:new Promise((o,a)=>{r=a;const l=performance.now(),d=()=>{t()?(clearInterval(i),o(!0)):(performance.now()-l)/1e3>e&&(a(new zt("Timeouts or Feature is not found in the map at current zoom level.",{status:404,name:"NetworkError"})),clearInterval(i))};d(),i=setInterval(d,100)}),abort:()=>{i&&(clearInterval(i),i=null),r&&(r(new zt("Query was aborted by the user.",{status:400,name:"AbortError"})),r=null)}}}function N(t){if(!t)return null;const i=(Array.isArray(t)?t:[t]).filter(v).map(r=>r.trim());return i.length>0?i.join(","):null}function v(t){return typeof t=="string"&&t.trim().length>0}function Z(t){return Array.isArray(t)&&t.length===2&&t.every(e=>typeof e=="number")}function Se(t){return Array.isArray(t)&&t.length===2&&t.every(e=>Z(e))}function se(t){return typeof t=="number"&&t>0}function ke(t,e){const i={...t};return e.forEach(r=>{delete i[r]}),i}var qt=(t=>(t.POINT="Point",t.POLYGON="Polygon",t))(qt||{}),st=(t=>(t.POINT="Point",t.POLYGON="Polygon",t.GATE="Gate",t))(st||{}),Gt=(t=>(t.DEFAULT_NAME="DefaultName",t))(Gt||{}),Kt=(t=>(t.ABSOLUTE_DISTANCE="AbsoluteDistance",t.ACTUAL_DISTANCE="ActualDistance",t))(Kt||{});const ot=["specialHours","businessStatus","serviceHours","keywords","siteCode","refPhotoId","totalPhotoCount","photos","icon"],at=D.getInstance();class Wt{_poisApi="api/v5/pois";_categoriesGroupApi="api/v5/categories/group";constructor(){}searchByIds(e){const i=N(e);if(!i)throw new Error("Invalid ids parameter. Expected a non-empty string or an array of strings.");const r=`${this._poisApi}/${i}`;return this._filterPoiProperties(r,W)}searchByDistance(e){const{center:i,distance:r,keywords:n="",offset:s=R,page:o=k}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",i.join(",")),a.set("distance",String(Math.round(r))),a.set("offset",String(s)),a.set("page",String(o)),v(n)&&a.set("keywords",n);const l=`${this._poisApi}?${a.toString()}`;return this._filterPoiProperties(l,W)}searchByBounds(e){const{bounds:i,offset:r=R,page:n=k,keywords:s,orderBy:o}=e;if(!Se(i))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const a=new URLSearchParams;a.set("bbox",i.flat().join()),a.set("offset",String(r)),a.set("page",String(n)),v(s)&&a.set("keywords",s),o&&a.set("orderBy",o);const l=`${this._poisApi}?${a.toString()}`;return this._filterPoiProperties(l,W)}searchByBuilding(e){const{buildingId:i,offset:r=R,page:n=k,keywords:s,orderBy:o}=e;if(!v(i))throw new Error("'buildingId' must be a non-empty string.");const a=new URLSearchParams;a.set("buildingId",i),a.set("offset",String(r)),a.set("page",String(n)),v(s)&&a.set("keywords",s),o&&a.set("orderBy",o);const l=`${this._poisApi}?${a.toString()}`;return this._filterPoiProperties(l,d=>W(d))}searchByVenue(e){const{venueId:i,offset:r=R,page:n=k,keywords:s,orderBy:o}=e;if(!v(i))throw new Error("'venueId' must be a non-empty string.");const a=new URLSearchParams;a.set("venueId",i),a.set("offset",String(r)),a.set("page",String(n)),v(s)&&a.set("keywords",s),o&&a.set("orderBy",o);const l=`${this._poisApi}?${a.toString()}`;return this._filterPoiProperties(l,W)}searchByFloors(e){let i=null,r=null;const n="floorIds"in e?N(e.floorIds):null,s="sharedFloorIds"in e?N(e.sharedFloorIds):null;if(n?(i="floorId",r=n):s&&(i="sharedFloorId",r=s),!i||!r)throw new Error("Either 'floorIds' or 'sharedFloorIds' must be a non-empty array.");const{offset:o=R,page:a=k,keywords:l,orderBy:d}=e,u=new URLSearchParams;u.set("offset",String(o)),u.set("page",String(a)),u.set(i,r),v(l)&&u.set("keywords",l),d&&u.set("orderBy",d);const h=`${this._poisApi}?${u.toString()}`;return this._filterPoiProperties(h,W)}async searchByOrientation(e){const{center:i,angle:r,distance:n,distanceSearchType:s=st.POINT}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(n)||n>100)throw new Error("Invalid distance parameter. Expected a positive number and no more than 100.");if(!se(r))throw new Error("Invalid angle parameter. Expected a positive number.");const o=new URLSearchParams;if("ordinal"in e){if(!v(e.ordinal))throw new Error("'ordinal' must be a non-empty string.");o.set("ordinal",e.ordinal)}else if("floorId"in e){if(!v(e.floorId))throw new Error("'floorId' must be a non-empty string.");o.set("floorId",e.floorId)}else if("buildingId"in e){if(!v(e.buildingId))throw new Error("'buildingId' must be a non-empty string.");o.set("buildingId",e.buildingId)}else throw new Error("Either 'ordinal', 'floorId', or 'buildingId' must be provided.");o.set("center",i.join()),o.set("angle",String(Math.round(r))),o.set("distance",String(n)),o.set("distanceSearchType",s);const a=`${this._poisApi}/orientation?${o.toString()}`;return(await at.getHttpSession()).request(a)}searchByCategory(e){const{center:i,distance:r,page:n=k,offset:s=R}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000");const o=new URLSearchParams;if("category"in e&&v(e.category))o.set("category",String(e.category));else if("excludedCategories"in e&&N(e.excludedCategories))o.set("excludeCategories",N(e.excludedCategories));else throw new Error("Either 'category' or 'excludedCategories' must be provided.");o.set("center",i.join(",")),o.set("distance",String(r)),o.set("page",String(n)),o.set("offset",String(s));const a=`${this._poisApi}?${o.toString()}`;return this._filterPoiProperties(a,W)}async searchCategories(e){const i=new URLSearchParams;if("floorId"in e&&v(e.floorId)?i.set("floorId",e.floorId):"buildingId"in e&&v(e.buildingId)?i.set("buildingId",e.buildingId):"sharedFloorId"in e&&v(e.sharedFloorId)?i.set("sharedFloorId",e.sharedFloorId):"venueId"in e&&v(e.venueId)&&i.set("venueId",e.venueId),"bounds"in e&&Se(e.bounds)&&(i.set("bbox",e.bounds.flat().join()),v(e.keywords)&&i.set("keywords",e.keywords)),i.toString().length===0)throw new Error("At least one of 'floorId', 'buildingId', 'sharedFloorId', 'venueId', or 'bounds' must be provided.");const r=`${this._categoriesGroupApi}?${i.toString()}`;return(await at.getHttpSession()).request(r)}search(e){const i=new URLSearchParams;Object.entries(e).forEach(([n,s])=>{switch(n){case"bounds":Se(s)&&i.set("bbox",s.flat().join());break;case"center":Z(s)&&i.set("center",s.join());break;case"excludedCategories":const o=N(s);o&&i.set("excludeCategories",o);break;case"floorIds":const a=N(s);a&&i.set("floorId",a);break;case"sharedFloorIds":const l=N(s);l&&i.set("sharedFloorId",l);break;default:i.set(n,String(s))}});const r=`${this._poisApi}?${i.toString()}`;return this._filterPoiProperties(r,W)}async _filterPoiProperties(e,i){const n=await(await at.getHttpSession()).request(e),s=n.result.pois.map(i);return{...n,result:{...n.result,pois:s}}}}function W(t){return"sharedFloorId"in t,ke(t,ot)}const Yt=["opening_hours","description","phone","website","email","appURL","icon"],Dr=D.getInstance();class Xt{_api="api/v5/venues";constructor(){}searchByIds(e){const i=N(e);if(!i)throw new Error("Please input venue id at least one.");const r=`${this._api}/${i}`;return this._filterVenueProperties(r,oe)}searchByDistance(e){const{center:i,distance:r,keywords:n="",offset:s=R,page:o=k}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",i.join(",")),a.set("distance",String(r)),a.set("offset",String(s)),a.set("page",String(o)),v(n)&&a.set("keywords",n);const l=`${this._api}?${a.toString()}`;return this._filterVenueProperties(l,oe)}searchByBounds(e){const{keywords:i,bounds:r,offset:n=R,page:s=k}=e;if(!Se(r))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const o=new URLSearchParams;o.set("bbox",r.flat().join()),o.set("offset",String(n)),o.set("page",String(s)),v(i)&&o.set("keywords",i);const a=`${this._api}?${o.toString()}`;return this._filterVenueProperties(a,oe)}searchByGlobal(e){const{keywords:i,offset:r=R,page:n=k}=e,s=new URLSearchParams;s.set("offset",String(r)),s.set("page",String(n)),v(i)&&s.set("keywords",i);const o=`${this._api}?${s.toString()}`;return this._filterVenueProperties(o,oe)}searchBySharedFloorId(e){if(!v(e))throw new Error("Please input correct sharedFloorId.");const i=`${this._api}/shared_floors/${e}`;return this._filterVenueProperties(i,oe)}search(e){const i=new URLSearchParams;Object.entries(e).forEach(([n,s])=>{n==="bounds"?i.set("bbox",s.flat().join()):n==="center"?i.set("center",s.join()):i.set(n,String(s))});const r=`${this._api}?${i.toString()}`;return this._filterVenueProperties(r,oe)}async _filterVenueProperties(e,i){const n=await(await Dr.getHttpSession()).request(e),s=n.result.venues.map(i);return{...n,result:{...n.result,venues:s}}}}function oe(t){return ke(t,Yt)}const Qt=["specialHours","businessStatus","serviceHours","keywords","siteCode","refPhotoId","totalPhotoCount","photos","description"],Hr=D.getInstance();class Zt{_api="api/v5/buildings";constructor(){}searchByIds(e){const i=N(e);if(!i)throw new Error("Please input building id at least one.");const r=`${this._api}/${i}`;return this._filterBuildingProperties(r,ae)}searchByDistance(e){const{center:i,distance:r,keywords:n="",offset:s=R,page:o=k}=e;if(!Z(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!se(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",i.join(",")),a.set("distance",String(r)),a.set("offset",String(s)),a.set("page",String(o)),v(n)&&a.set("keywords",n);const l=`${this._api}?${a.toString()}`;return this._filterBuildingProperties(l,ae)}searchByBounds(e){const{bounds:i,offset:r=R,page:n=k,keywords:s}=e;if(!Se(i))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const o=new URLSearchParams;o.set("bbox",i.flat().join()),o.set("offset",String(r)),o.set("page",String(n)),v(s)&&o.set("keywords",s);const a=`${this._api}?${o.toString()}`;return this._filterBuildingProperties(a,ae)}searchByGlobal(e){const{keywords:i,offset:r=R,page:n=k}=e,s=new URLSearchParams;s.set("searchGlobal",String(!0)),s.set("offset",String(r)),s.set("page",String(n)),v(i)&&s.set("keywords",i);const o=`${this._api}?${s.toString()}`;return this._filterBuildingProperties(o,ae)}searchByFloorId(e){if(!v(e))throw new Error("'floorId' cannot be empty.");const i=`${this._api}/floors/${e}`;return this._filterBuildingProperties(i,ae)}search(e){const i=new URLSearchParams;Object.entries(e).forEach(([n,s])=>{n==="bounds"?i.set("bbox",s.flat().join()):n==="center"?i.set("center",s.join()):i.set(n,String(s))});const r=`${this._api}?${i.toString()}`;return this._filterBuildingProperties(r,ae)}async _filterBuildingProperties(e,i){const n=await(await Hr.getHttpSession()).request(e),s=n.result.buildings.map(i);return{...n,result:{...n.result,buildings:s}}}}function ae(t){return ke(t,Qt)}const Jt=new Zt,ei=new Xt,Nr=new Wt;async function De(t){return(await Jt.searchByIds(t)).result.buildings[0]}async function Ur(t){const i=(await Jt.searchByFloorId(t)).result.buildings[0].buildingId;return await De(i)}async function He(t){return(await ei.searchByIds(t)).result.venues[0]}async function ti(t){return(await ei.searchBySharedFloorId(t)).result.venues[0]}async function jr(t){return(await Nr.searchByIds([t])).result.pois[0]}class Y{static instance;_visitedBuildingUnits;_historyBuildingUnit;_historyOrdinal;constructor(){this._visitedBuildingUnits=[],this._historyBuildingUnit=new Map,this._historyOrdinal=new Map}static getInstance(){return Y.instance||(Y.instance=new Y),Y.instance}getHistoryBuildingUnit(e){return this._historyBuildingUnit.get(e)}setHistoryBuildingUnit(e,i){this._historyBuildingUnit.set(e,i)}getHistoryOrdinal(e){return this._historyOrdinal.get(e)}setHistoryOrdinal(e,i){this._historyOrdinal.set(e,i)}getVisitedBuildingUnits(){return this._visitedBuildingUnits}addVisitedBuildingUnit(e){this._visitedBuildingUnits.push(e),this._visitedBuildingUnits.length>100&&(this._visitedBuildingUnits=this._visitedBuildingUnits.slice(this._visitedBuildingUnits.length-100))}}var ii=typeof global=="object"&&global&&global.Object===Object&&global,Vr=typeof self=="object"&&self&&self.Object===Object&&self,U=ii||Vr||Function("return this")(),X=U.Symbol,ri=Object.prototype,zr=ri.hasOwnProperty,qr=ri.toString,ve=X?X.toStringTag:void 0;function Gr(t){var e=zr.call(t,ve),i=t[ve];try{t[ve]=void 0;var r=!0}catch{}var n=qr.call(t);return r&&(e?t[ve]=i:delete t[ve]),n}var Kr=Object.prototype,Wr=Kr.toString;function Yr(t){return Wr.call(t)}var Xr="[object Null]",Qr="[object Undefined]",ni=X?X.toStringTag:void 0;function le(t){return t==null?t===void 0?Qr:Xr:ni&&ni in Object(t)?Gr(t):Yr(t)}function de(t){return t!=null&&typeof t=="object"}var Zr="[object Symbol]";function Ie(t){return typeof t=="symbol"||de(t)&&le(t)==Zr}function Jr(t,e,i){for(var r=-1,n=t.length;++r<n;){var s=t[r],o=e(s);if(o!=null&&(a===void 0?o===o&&!Ie(o):i(o,a)))var a=o,l=s}return l}function en(){this.__data__=[],this.size=0}function si(t,e){return t===e||t!==t&&e!==e}function Ne(t,e){for(var i=t.length;i--;)if(si(t[i][0],e))return i;return-1}var tn=Array.prototype,rn=tn.splice;function nn(t){var e=this.__data__,i=Ne(e,t);if(i<0)return!1;var r=e.length-1;return i==r?e.pop():rn.call(e,i,1),--this.size,!0}function sn(t){var e=this.__data__,i=Ne(e,t);return i<0?void 0:e[i][1]}function on(t){return Ne(this.__data__,t)>-1}function an(t,e){var i=this.__data__,r=Ne(i,t);return r<0?(++this.size,i.push([t,e])):i[r][1]=e,this}function j(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}j.prototype.clear=en,j.prototype.delete=nn,j.prototype.get=sn,j.prototype.has=on,j.prototype.set=an;function ln(){this.__data__=new j,this.size=0}function dn(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i}function un(t){return this.__data__.get(t)}function cn(t){return this.__data__.has(t)}function ue(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var hn="[object AsyncFunction]",_n="[object Function]",fn="[object GeneratorFunction]",pn="[object Proxy]";function oi(t){if(!ue(t))return!1;var e=le(t);return e==_n||e==fn||e==hn||e==pn}var lt=U["__core-js_shared__"],ai=(function(){var t=/[^.]+$/.exec(lt&&lt.keys&&lt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function gn(t){return!!ai&&ai in t}var yn=Function.prototype,mn=yn.toString;function J(t){if(t!=null){try{return mn.call(t)}catch{}try{return t+""}catch{}}return""}var bn=/[\\^$.*+?()[\]{}|]/g,Sn=/^\[object .+?Constructor\]$/,vn=Function.prototype,In=Object.prototype,Ln=vn.toString,wn=In.hasOwnProperty,Bn=RegExp("^"+Ln.call(wn).replace(bn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function En(t){if(!ue(t)||gn(t))return!1;var e=oi(t)?Bn:Sn;return e.test(J(t))}function Pn(t,e){return t?.[e]}function ce(t,e){var i=Pn(t,e);return En(i)?i:void 0}var Le=ce(U,"Map"),we=ce(Object,"create");function Fn(){this.__data__=we?we(null):{},this.size=0}function Cn(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var On="__lodash_hash_undefined__",$n=Object.prototype,An=$n.hasOwnProperty;function Mn(t){var e=this.__data__;if(we){var i=e[t];return i===On?void 0:i}return An.call(e,t)?e[t]:void 0}var xn=Object.prototype,Tn=xn.hasOwnProperty;function Rn(t){var e=this.__data__;return we?e[t]!==void 0:Tn.call(e,t)}var kn="__lodash_hash_undefined__";function Dn(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=we&&e===void 0?kn:e,this}function ee(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}ee.prototype.clear=Fn,ee.prototype.delete=Cn,ee.prototype.get=Mn,ee.prototype.has=Rn,ee.prototype.set=Dn;function Hn(){this.size=0,this.__data__={hash:new ee,map:new(Le||j),string:new ee}}function Nn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Ue(t,e){var i=t.__data__;return Nn(e)?i[typeof e=="string"?"string":"hash"]:i.map}function Un(t){var e=Ue(this,t).delete(t);return this.size-=e?1:0,e}function jn(t){return Ue(this,t).get(t)}function Vn(t){return Ue(this,t).has(t)}function zn(t,e){var i=Ue(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this}function V(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}V.prototype.clear=Hn,V.prototype.delete=Un,V.prototype.get=jn,V.prototype.has=Vn,V.prototype.set=zn;var qn=200;function Gn(t,e){var i=this.__data__;if(i instanceof j){var r=i.__data__;if(!Le||r.length<qn-1)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new V(r)}return i.set(t,e),this.size=i.size,this}function z(t){var e=this.__data__=new j(t);this.size=e.size}z.prototype.clear=ln,z.prototype.delete=dn,z.prototype.get=un,z.prototype.has=cn,z.prototype.set=Gn;var Kn="__lodash_hash_undefined__";function Wn(t){return this.__data__.set(t,Kn),this}function Yn(t){return this.__data__.has(t)}function Be(t){var e=-1,i=t==null?0:t.length;for(this.__data__=new V;++e<i;)this.add(t[e])}Be.prototype.add=Be.prototype.push=Wn,Be.prototype.has=Yn;function Xn(t,e){for(var i=-1,r=t==null?0:t.length;++i<r;)if(e(t[i],i,t))return!0;return!1}function li(t,e){return t.has(e)}var Qn=1,Zn=2;function di(t,e,i,r,n,s){var o=i&Qn,a=t.length,l=e.length;if(a!=l&&!(o&&l>a))return!1;var d=s.get(t),u=s.get(e);if(d&&u)return d==e&&u==t;var h=-1,c=!0,f=i&Zn?new Be:void 0;for(s.set(t,e),s.set(e,t);++h<a;){var g=t[h],_=e[h];if(r)var y=o?r(_,g,h,e,t,s):r(g,_,h,t,e,s);if(y!==void 0){if(y)continue;c=!1;break}if(f){if(!Xn(e,function(m,S){if(!li(f,S)&&(g===m||n(g,m,i,r,s)))return f.push(S)})){c=!1;break}}else if(!(g===_||n(g,_,i,r,s))){c=!1;break}}return s.delete(t),s.delete(e),c}var ui=U.Uint8Array;function Jn(t){var e=-1,i=Array(t.size);return t.forEach(function(r,n){i[++e]=[n,r]}),i}function dt(t){var e=-1,i=Array(t.size);return t.forEach(function(r){i[++e]=r}),i}var es=1,ts=2,is="[object Boolean]",rs="[object Date]",ns="[object Error]",ss="[object Map]",os="[object Number]",as="[object RegExp]",ls="[object Set]",ds="[object String]",us="[object Symbol]",cs="[object ArrayBuffer]",hs="[object DataView]",ci=X?X.prototype:void 0,ut=ci?ci.valueOf:void 0;function _s(t,e,i,r,n,s,o){switch(i){case hs:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case cs:return!(t.byteLength!=e.byteLength||!s(new ui(t),new ui(e)));case is:case rs:case os:return si(+t,+e);case ns:return t.name==e.name&&t.message==e.message;case as:case ds:return t==e+"";case ss:var a=Jn;case ls:var l=r&es;if(a||(a=dt),t.size!=e.size&&!l)return!1;var d=o.get(t);if(d)return d==e;r|=ts,o.set(t,e);var u=di(a(t),a(e),r,n,s,o);return o.delete(t),u;case us:if(ut)return ut.call(t)==ut.call(e)}return!1}function fs(t,e){for(var i=-1,r=e.length,n=t.length;++i<r;)t[n+i]=e[i];return t}var q=Array.isArray;function ps(t,e,i){var r=e(t);return q(t)?r:fs(r,i(t))}function gs(t,e){for(var i=-1,r=t==null?0:t.length,n=0,s=[];++i<r;){var o=t[i];e(o,i,t)&&(s[n++]=o)}return s}function ys(){return[]}var ms=Object.prototype,bs=ms.propertyIsEnumerable,hi=Object.getOwnPropertySymbols,Ss=hi?function(t){return t==null?[]:(t=Object(t),gs(hi(t),function(e){return bs.call(t,e)}))}:ys;function vs(t,e){for(var i=-1,r=Array(t);++i<t;)r[i]=e(i);return r}var Is="[object Arguments]";function _i(t){return de(t)&&le(t)==Is}var fi=Object.prototype,Ls=fi.hasOwnProperty,ws=fi.propertyIsEnumerable,pi=_i((function(){return arguments})())?_i:function(t){return de(t)&&Ls.call(t,"callee")&&!ws.call(t,"callee")};function Bs(){return!1}var gi=typeof p=="object"&&p&&!p.nodeType&&p,yi=gi&&typeof module=="object"&&module&&!module.nodeType&&module,Es=yi&&yi.exports===gi,mi=Es?U.Buffer:void 0,Ps=mi?mi.isBuffer:void 0,ct=Ps||Bs,Fs=9007199254740991,Cs=/^(?:0|[1-9]\d*)$/;function bi(t,e){var i=typeof t;return e=e??Fs,!!e&&(i=="number"||i!="symbol"&&Cs.test(t))&&t>-1&&t%1==0&&t<e}var Os=9007199254740991;function ht(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Os}var $s="[object Arguments]",As="[object Array]",Ms="[object Boolean]",xs="[object Date]",Ts="[object Error]",Rs="[object Function]",ks="[object Map]",Ds="[object Number]",Hs="[object Object]",Ns="[object RegExp]",Us="[object Set]",js="[object String]",Vs="[object WeakMap]",zs="[object ArrayBuffer]",qs="[object DataView]",Gs="[object Float32Array]",Ks="[object Float64Array]",Ws="[object Int8Array]",Ys="[object Int16Array]",Xs="[object Int32Array]",Qs="[object Uint8Array]",Zs="[object Uint8ClampedArray]",Js="[object Uint16Array]",eo="[object Uint32Array]",I={};I[Gs]=I[Ks]=I[Ws]=I[Ys]=I[Xs]=I[Qs]=I[Zs]=I[Js]=I[eo]=!0,I[$s]=I[As]=I[zs]=I[Ms]=I[qs]=I[xs]=I[Ts]=I[Rs]=I[ks]=I[Ds]=I[Hs]=I[Ns]=I[Us]=I[js]=I[Vs]=!1;function to(t){return de(t)&&ht(t.length)&&!!I[le(t)]}function io(t){return function(e){return t(e)}}var Si=typeof p=="object"&&p&&!p.nodeType&&p,Ee=Si&&typeof module=="object"&&module&&!module.nodeType&&module,ro=Ee&&Ee.exports===Si,_t=ro&&ii.process,vi=(function(){try{var t=Ee&&Ee.require&&Ee.require("util").types;return t||_t&&_t.binding&&_t.binding("util")}catch{}})(),Ii=vi&&vi.isTypedArray,Li=Ii?io(Ii):to,no=Object.prototype,so=no.hasOwnProperty;function oo(t,e){var i=q(t),r=!i&&pi(t),n=!i&&!r&&ct(t),s=!i&&!r&&!n&&Li(t),o=i||r||n||s,a=o?vs(t.length,String):[],l=a.length;for(var d in t)so.call(t,d)&&!(o&&(d=="length"||n&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||bi(d,l)))&&a.push(d);return a}var ao=Object.prototype;function lo(t){var e=t&&t.constructor,i=typeof e=="function"&&e.prototype||ao;return t===i}function uo(t,e){return function(i){return t(e(i))}}var co=uo(Object.keys,Object),ho=Object.prototype,_o=ho.hasOwnProperty;function fo(t){if(!lo(t))return co(t);var e=[];for(var i in Object(t))_o.call(t,i)&&i!="constructor"&&e.push(i);return e}function po(t){return t!=null&&ht(t.length)&&!oi(t)}function wi(t){return po(t)?oo(t):fo(t)}function Bi(t){return ps(t,wi,Ss)}var go=1,yo=Object.prototype,mo=yo.hasOwnProperty;function bo(t,e,i,r,n,s){var o=i&go,a=Bi(t),l=a.length,d=Bi(e),u=d.length;if(l!=u&&!o)return!1;for(var h=l;h--;){var c=a[h];if(!(o?c in e:mo.call(e,c)))return!1}var f=s.get(t),g=s.get(e);if(f&&g)return f==e&&g==t;var _=!0;s.set(t,e),s.set(e,t);for(var y=o;++h<l;){c=a[h];var m=t[c],S=e[c];if(r)var E=o?r(S,m,c,e,t,s):r(m,S,c,t,e,s);if(!(E===void 0?m===S||n(m,S,i,r,s):E)){_=!1;break}y||(y=c=="constructor")}if(_&&!y){var C=t.constructor,B=e.constructor;C!=B&&"constructor"in t&&"constructor"in e&&!(typeof C=="function"&&C instanceof C&&typeof B=="function"&&B instanceof B)&&(_=!1)}return s.delete(t),s.delete(e),_}var ft=ce(U,"DataView"),pt=ce(U,"Promise"),he=ce(U,"Set"),gt=ce(U,"WeakMap"),Ei="[object Map]",So="[object Object]",Pi="[object Promise]",Fi="[object Set]",Ci="[object WeakMap]",Oi="[object DataView]",vo=J(ft),Io=J(Le),Lo=J(pt),wo=J(he),Bo=J(gt),Q=le;(ft&&Q(new ft(new ArrayBuffer(1)))!=Oi||Le&&Q(new Le)!=Ei||pt&&Q(pt.resolve())!=Pi||he&&Q(new he)!=Fi||gt&&Q(new gt)!=Ci)&&(Q=function(t){var e=le(t),i=e==So?t.constructor:void 0,r=i?J(i):"";if(r)switch(r){case vo:return Oi;case Io:return Ei;case Lo:return Pi;case wo:return Fi;case Bo:return Ci}return e});var Eo=1,$i="[object Arguments]",Ai="[object Array]",je="[object Object]",Po=Object.prototype,Mi=Po.hasOwnProperty;function Fo(t,e,i,r,n,s){var o=q(t),a=q(e),l=o?Ai:Q(t),d=a?Ai:Q(e);l=l==$i?je:l,d=d==$i?je:d;var u=l==je,h=d==je,c=l==d;if(c&&ct(t)){if(!ct(e))return!1;o=!0,u=!1}if(c&&!u)return s||(s=new z),o||Li(t)?di(t,e,i,r,n,s):_s(t,e,l,i,r,n,s);if(!(i&Eo)){var f=u&&Mi.call(t,"__wrapped__"),g=h&&Mi.call(e,"__wrapped__");if(f||g){var _=f?t.value():t,y=g?e.value():e;return s||(s=new z),n(_,y,i,r,s)}}return c?(s||(s=new z),bo(t,e,i,r,n,s)):!1}function yt(t,e,i,r,n){return t===e?!0:t==null||e==null||!de(t)&&!de(e)?t!==t&&e!==e:Fo(t,e,i,r,yt,n)}var Co=1,Oo=2;function $o(t,e,i,r){var n=i.length,s=n;if(t==null)return!s;for(t=Object(t);n--;){var o=i[n];if(o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++n<s;){o=i[n];var a=o[0],l=t[a],d=o[1];if(o[2]){if(l===void 0&&!(a in t))return!1}else{var u=new z,h;if(!(h===void 0?yt(d,l,Co|Oo,r,u):h))return!1}}return!0}function xi(t){return t===t&&!ue(t)}function Ao(t){for(var e=wi(t),i=e.length;i--;){var r=e[i],n=t[r];e[i]=[r,n,xi(n)]}return e}function Ti(t,e){return function(i){return i==null?!1:i[t]===e&&(e!==void 0||t in Object(i))}}function Mo(t){var e=Ao(t);return e.length==1&&e[0][2]?Ti(e[0][0],e[0][1]):function(i){return i===t||$o(i,t,e)}}var xo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,To=/^\w*$/;function mt(t,e){if(q(t))return!1;var i=typeof t;return i=="number"||i=="symbol"||i=="boolean"||t==null||Ie(t)?!0:To.test(t)||!xo.test(t)||e!=null&&t in Object(e)}var Ro="Expected a function";function bt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Ro);var i=function(){var r=arguments,n=e?e.apply(this,r):r[0],s=i.cache;if(s.has(n))return s.get(n);var o=t.apply(this,r);return i.cache=s.set(n,o)||s,o};return i.cache=new(bt.Cache||V),i}bt.Cache=V;var ko=500;function Do(t){var e=bt(t,function(r){return i.size===ko&&i.clear(),r}),i=e.cache;return e}var Ho=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,No=/\\(\\)?/g,Uo=Do(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Ho,function(i,r,n,s){e.push(n?s.replace(No,"$1"):r||i)}),e});function jo(t,e){for(var i=-1,r=t==null?0:t.length,n=Array(r);++i<r;)n[i]=e(t[i],i,t);return n}var Ri=X?X.prototype:void 0,ki=Ri?Ri.toString:void 0;function Di(t){if(typeof t=="string")return t;if(q(t))return jo(t,Di)+"";if(Ie(t))return ki?ki.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Hi(t){return t==null?"":Di(t)}function Ni(t,e){return q(t)?t:mt(t,e)?[t]:Uo(Hi(t))}function Ve(t){if(typeof t=="string"||Ie(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Ui(t,e){e=Ni(e,t);for(var i=0,r=e.length;t!=null&&i<r;)t=t[Ve(e[i++])];return i&&i==r?t:void 0}function Vo(t,e,i){var r=t==null?void 0:Ui(t,e);return r===void 0?i:r}function zo(t,e){return t!=null&&e in Object(t)}function qo(t,e,i){e=Ni(e,t);for(var r=-1,n=e.length,s=!1;++r<n;){var o=Ve(e[r]);if(!(s=t!=null&&i(t,o)))break;t=t[o]}return s||++r!=n?s:(n=t==null?0:t.length,!!n&&ht(n)&&bi(o,n)&&(q(t)||pi(t)))}function Go(t,e){return t!=null&&qo(t,e,zo)}var Ko=1,Wo=2;function Yo(t,e){return mt(t)&&xi(e)?Ti(Ve(t),e):function(i){var r=Vo(i,t);return r===void 0&&r===e?Go(i,t):yt(e,r,Ko|Wo)}}function Xo(t){return t}function Qo(t){return function(e){return e?.[t]}}function Zo(t){return function(e){return Ui(e,t)}}function Jo(t){return mt(t)?Qo(Ve(t)):Zo(t)}function ji(t){return typeof t=="function"?t:t==null?Xo:typeof t=="object"?q(t)?Yo(t[0],t[1]):Mo(t):Jo(t)}function ea(t,e){return t<e}function ta(t,e){return t&&t.length?Jr(t,ji(e),ea):void 0}class ia{_isMaskMode;_hiddenBuildings;_history;constructor(e){this._isMaskMode=e,this._hiddenBuildings=[],this._history=Y.getInstance()}getLayeredData(e){const{selectedVenueId:i,venueMap:r,buildingMap:n,sharedFloorMap:s}=e,o=[],a=[],l=[],d=[],u=[],h=[],c=[...r.values()],f=i?[r.get(i),...c.filter(g=>g.properties.id!==i)]:c;for(const g of f){if(!g||!g.properties)continue;const{id:_,overlap:y,building_ids:m,shared_level_ids:S,default_displayed_ordinal:E,default_displayed_building:C}=g.properties,B=_===i,b=sa(y),O=w(m),$=this._history.getHistoryOrdinal(_);let P=$??E;if(P)$||(this._history.setHistoryOrdinal(_,P),this._history.setHistoryBuildingUnit(_,{id:C,type:"building"}));else{const{ordinal:L,buildingId:H}=ra(O,n);if(!L)continue;P=L,this._history.setHistoryOrdinal(_,P),this._history.setHistoryBuildingUnit(_,{id:H,type:"building"})}O.forEach(L=>{const H=n.get(L),A=na(H,P);A?this._isMaskMode?B?(a.push(A),o.push({level:A,overlap:b.get(A)??null,venueId:_})):u.push(L):(o.push({level:A,overlap:b.get(A)??null,venueId:_}),B&&a.push(A)):d.push(L)}),w(S).forEach(L=>{const H=s.get(L),{ordinal:A,persistence:K}=H?.properties||{},ne=K==="true"&&0<=A&&A<=P,ge=A===P,Ze=ne||ge,$e={level:L,overlap:b.get(L)??null,venueId:_};Ze?this._isMaskMode?B?(o.push($e),ne&&l.push(L),ge&&a.push(L)):h.push(L):(o.push($e),B&&ge&&a.push(L),ne&&l.push(L)):d.push(L)})}return this._hiddenBuildings=d,{displayedLevels:o,selectedLevelIds:a,alwaysDisplayedSharedLevelIds:l,maskBuildingIds:u,maskSharedFloorIds:h}}getHiddenBuildings(){return this._hiddenBuildings}}function ra(t,e){const i=t.find(s=>e.has(s))??t[0]??null,r=i?e.get(i):null;return{ordinal:r?Vi(r):null,buildingId:i}}function Vi(t){if(!t||!t.properties)return null;const{level_ids:e,ordinals:i,default_displayed_floor:r}=t.properties,n=w(i);let s=null;if(r){const o=w(e).findIndex(a=>a===r);s=n[o]??null}return s||(s=ta(n,o=>Math.abs(Number(o)-.1))),s}function na(t,e){if(!t||!t.properties)return null;const{level_ids:i,ordinals:r}=t.properties,n=w(r).findIndex(s=>s===e);return w(i)[n]??null}function sa(t){const e=new Map;if(!t)return e;for(const i of w(t,"/")){const[r,n]=w(i,":");e.set(r,w(n))}return e}class oa{_maplibre;_isAnimated=!0;_bounds=null;_boundsPadding;_center=null;_fitBoundsTimer=null;constructor(e,i){this._maplibre=e,this._boundsPadding=i}setAnimated(e){this._isAnimated=e}setBounds(e){this._bounds=e}getBounds(){return this._bounds}setCenter(e){this._center=e}async fitBounds(){if(!this._bounds)return;this._fitBoundsTimer&&(clearTimeout(this._fitBoundsTimer),this._fitBoundsTimer=null);const e=this._isAnimated?{animate:!0,duration:500}:{animate:!1},i=this._isAnimated?500:0;return new Promise(r=>{const n=()=>{this._maplibre.off("idle",n),r(!0)};this._maplibre.on("idle",n),this._maplibre.fitBounds(this._bounds,{...e,padding:this._boundsPadding,bearing:this._maplibre.getBearing()}),this._fitBoundsTimer=setTimeout(()=>{this._maplibre.off("idle",n),this._fitBoundsTimer=null,r(!0)},i+200)})}panToCenter(){this._center&&this._maplibre.panTo(this._center,{animate:this._isAnimated})}}var St=function(){return U.Date.now()},aa=/\s/;function la(t){for(var e=t.length;e--&&aa.test(t.charAt(e)););return e}var da=/^\s+/;function ua(t){return t&&t.slice(0,la(t)+1).replace(da,"")}var zi=NaN,ca=/^[-+]0x[0-9a-f]+$/i,ha=/^0b[01]+$/i,_a=/^0o[0-7]+$/i,fa=parseInt;function ze(t){if(typeof t=="number")return t;if(Ie(t))return zi;if(ue(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=ue(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=ua(t);var i=ha.test(t);return i||_a.test(t)?fa(t.slice(2),i?2:8):ca.test(t)?zi:+t}var pa="Expected a function",ga=Math.max,ya=Math.min;function vt(t,e,i){var r,n,s,o,a,l,d=0,u=!1,h=!1,c=!0;if(typeof t!="function")throw new TypeError(pa);e=ze(e)||0,ue(i)&&(u=!!i.leading,h="maxWait"in i,s=h?ga(ze(i.maxWait)||0,e):s,c="trailing"in i?!!i.trailing:c);function f(b){var O=r,$=n;return r=n=void 0,d=b,o=t.apply($,O),o}function g(b){return d=b,a=setTimeout(m,e),u?f(b):o}function _(b){var O=b-l,$=b-d,P=e-O;return h?ya(P,s-$):P}function y(b){var O=b-l,$=b-d;return l===void 0||O>=e||O<0||h&&$>=s}function m(){var b=St();if(y(b))return S(b);a=setTimeout(m,_(b))}function S(b){return a=void 0,c&&r?f(b):(r=n=void 0,o)}function E(){a!==void 0&&clearTimeout(a),d=0,r=l=n=a=void 0}function C(){return a===void 0?o:S(St())}function B(){var b=St(),O=y(b);if(r=arguments,n=this,l=b,O){if(a===void 0)return g(l);if(h)return clearTimeout(a),a=setTimeout(m,e),f(l)}return a===void 0&&(a=setTimeout(m,e)),o}return B.cancel=E,B.flush=C,B}function ma(t,e,i,r){for(var n=t.length,s=i+-1;++s<n;)if(e(t[s],s,t))return s;return-1}function ba(t){return t!==t}function Sa(t,e,i){for(var r=i-1,n=t.length;++r<n;)if(t[r]===e)return r;return-1}function va(t,e,i){return e===e?Sa(t,e,i):ma(t,ba,i)}function Ia(t,e){var i=t==null?0:t.length;return!!i&&va(t,e,0)>-1}function La(){}var wa=1/0,Ba=he&&1/dt(new he([,-0]))[1]==wa?function(t){return new he(t)}:La,Ea=200;function Pa(t,e,i){var r=-1,n=Ia,s=t.length,o=!0,a=[],l=a;if(s>=Ea){var d=e?null:Ba(t);if(d)return dt(d);o=!1,n=li,l=new Be}else l=e?[]:a;e:for(;++r<s;){var u=t[r],h=e?e(u):u;if(u=u!==0?u:0,o&&h===h){for(var c=l.length;c--;)if(l[c]===h)continue e;e&&l.push(h),a.push(u)}else n(l,h,i)||(l!==a&&l.push(h),a.push(u))}return a}function qi(t,e){return t&&t.length?Pa(t,ji(e)):[]}var Fa=0;function te(t){var e=++Fa;return Hi(t)+e}const Pe="Indoor_selectedFloorChanged",qe="Indoor_selectedBuildingChanged",It="Indoor_mapxusMapLoaded",Gi="Indoor_maplibreMapLoaded",Ge="mapxus-venue-fill",ie="mapxus-building-line",Ki="mapxus-level-fill",Lt="mapxus-shared-level-fill",wt="highlight-mapxus_level",Bt="highlight-mapxus_shared_level";class Wi extends Ir.TinyEmitter{_map;_features=[];_allVenuesMap=new Map;_allBuildingsMap=new Map;_allSharedLevelsMap=new Map;_curBuildingId=null;_curBuildingFeature=null;_curSharedLevelId=null;_floor={code:null,id:null,ordinal:null};_sharedFloor={id:null,ordinal:null,name:null};_outdoorMapShown;_originIndoorLayers=[];_outdoorLayers=[];_curVenueId=null;_curVenueFeature=null;_selectedHighlightStyle;_upperLayers=[];_commonPoiLayers=[];_sectionFillLineLayers=[];_sectionSymbolLayers=[];_middleLayers=[];_lowerLayers=[];_excludedPoisInMiddle=[];_dispatch=ye(Pe);_startWithIndoorView;_indoorMapLoaded=!1;_isSelectSharedFloor=!1;_isMaskMode;_upperLevels=new Set;_middleLevels=new Set;_lowerLevels=new Set;_featureIncomplete=!1;_fitBounds;_dragPan;_history=Y.getInstance();_maskBuildings=new Set;_maskSharedFloors=new Set;_enableIndoorClickSelection;_enableOutdoorClickSelection;_zIndexHistory=new Map;_floorSwitchScope;_isDestroyed=!1;_abortQueryFeature;_debounceRendering;layeredHandler;dragPanHandler;constructor(e){super();const{map:i,startWithIndoorView:r,outdoorMapShown:n,selectedHighlightStyle:s,fitBounds:o,boundsPadding:a,maskNonSelectedAreas:l,enableIndoorClickSelection:d,enableOutdoorClickSelection:u,floorSwitchScope:h}=e;this.layeredHandler=new ia(l),this.dragPanHandler=new oa(i,a),this._map=i,this._enableIndoorClickSelection=d,this._enableOutdoorClickSelection=u,this._startWithIndoorView=r,this._outdoorMapShown=n,this._isMaskMode=l,this._fitBounds=o,this._floorSwitchScope=h,this._selectedHighlightStyle=s?Object.assign({},Re,s):Re,this._bindMaplibreEventListeners()}destroy(){this._isDestroyed||(this._isDestroyed=!0,this._dispatch.on(`.${Pe}`,null),this.off(qe),this.off(Gi),this.off(It),this._debounceRendering?.cancel(),this._abortQueryFeature&&(this._abortQueryFeature(),this._abortQueryFeature=null))}setAllowOutdoorSwitch(e){return this._enableOutdoorClickSelection=e,this}setAllowBuildingSwitch(e){return this._enableIndoorClickSelection=e,this}setAllowIndoorClickSelect(e){this._enableIndoorClickSelection=e}setAllowOutdoorClickSelect(e){this._enableOutdoorClickSelection=e}setFloorSwitchScope(e){this._floorSwitchScope=e}get floor(){return this._isSelectSharedFloor?this._sharedFloor:this._curBuildingId?this._floor:null}get building(){return this._curBuildingFeature}get venue(){return this._curVenueFeature}get features(){return this._features}getFeaturesById(e,i){const{layerIds:r,filter:n}=i||{},s=this._queryRenderedFeatures(r);if(!s.length)return[];const o=n?a=>a.properties.id===e&&n(a):a=>a.properties.id===e;return s.filter(o)}async switchFloorByOrdinal(e){this._updateFloorState(e),this._dispatch.call(Pe,null,{venue:this.venue,building:this.building,floor:this.floor}),this.venue&&e&&(this._floorSwitchScope===xe.GLOBAL&&this._changeOtherVenuesHistory(e),this._dragPan===!0&&(this._fitBounds?await this.dragPanHandler.fitBounds():await this.panToBuildingCenter()),this._dragPan==="restrict"&&await this._checkAndPanToBuilding()),this.updateRendering()}setOutdoorMapShown(e){this._outdoorMapShown=e,this._setOutdoorVisibility(e)}setSelectedHighlightStyle(e){this._selectedHighlightStyle=Object.assign({},this._selectedHighlightStyle,e??{"line-opacity":0});for(const i of[wt,Bt])if(this._map.getLayer(i))if(e){const{lineColor:r,lineOpacity:n,lineWidth:s,lineOffset:o}=this._selectedHighlightStyle,a=Yi(s,o);this._map.setPaintProperty(i,"line-color",r),this._map.setPaintProperty(i,"line-opacity",n),this._map.setPaintProperty(i,"line-width",s),this._map.setPaintProperty(i,"line-offset",a)}else this._map.setPaintProperty(i,"line-opacity",0)}onMapChange(e){const i=te(`${Pe}.`);return this._dispatch.on(i,e),{unsubscribe:()=>this._dispatch.on(i,null)}}async selectBuilding(e,i){if(this._isCurrentFeature(e))return;this._isSelectSharedFloor=!1,this._curSharedLevelId=null;let r=null;if(!e||!e.properties)this.dragPanHandler.setCenter(null),this._clear();else{const{floorId:n,featureIncomplete:s}=i||{};this._featureIncomplete=s??this._featureIncomplete;const{id:o,"ref:venue":a,label_center:l}=e.properties,d=w(l).map(u=>parseFloat(u));this._curBuildingFeature=e,this._curBuildingId=o,this._history.addVisitedBuildingUnit({id:o,type:"building"}),this.dragPanHandler.setCenter(d),this._curVenueId!==a&&(this._curVenueId=a,this._curVenueFeature=await this._queryVenueFeature(a)),r=this._getBuildingDisplayedOrdinal(e,n)}await this.switchFloorByOrdinal(r),this.emit(qe,e?{building:e,ordinal:r,dragPan:this._dragPan}:null),this._dispatchIndoorMapLoaded()}async selectSharedFloor(e,i,r){if(e.id===this._curSharedLevelId)return;const{id:n,ordinal:s}=e;this._isSelectSharedFloor=!0,this._curBuildingId=null,this._curBuildingFeature=null,this._sharedFloor=e,this._curSharedLevelId=n,this._featureIncomplete=r?.featureIncomplete??this._featureIncomplete;const{label_center:o,id:a}=i.properties,l=w(o).map(d=>parseFloat(d));this._curVenueId=a,this._curVenueFeature=i,this.dragPanHandler.setCenter(l),this._history.addVisitedBuildingUnit({id:n,type:"sharedFloor"}),this._history.setHistoryOrdinal(a,s),this._history.setHistoryBuildingUnit(a,{id:n,type:"sharedFloor"}),this._dragPan===!0&&(this._fitBounds?await this.dragPanHandler.fitBounds():await this.panToVenueCenter()),this._dispatch.call(Pe,null,{venue:this.venue,building:this.building,floor:this.floor}),this.emit(qe,{...e,dragPan:this._dragPan}),this._dispatchIndoorMapLoaded(),this.updateRendering()}updateCustomLayers(){const e=this._map.getStyle();this._originIndoorLayers=it(e),this._outdoorLayers=Lr(e),this._copyOverlapLayers(),this._copySharedFloorBackgroundLayers(),this._addSelectedHighlightLayers(),this._addReserveFloorLayers(),this._isMaskMode&&this._addBuildingMaskLayer(),this._outdoorMapShown||this._setOutdoorVisibility(!1)}updateRendering(){this._updateFeatures(),this._updateSelectedFeatures(),this._layerFloors(),this._calExcludedPoisInMiddle(),this._filterLayers(),this._filterSelectedHighlight(),this._updateUnselectedMask()}async panToBuildingCenter(){if(this.dragPanHandler.panToCenter(),this._featureIncomplete){const e=()=>this.getFeaturesById(this._curBuildingId,{layerIds:[ie]})[0];await this._waitForFeatureLoaded(e)}}async panToVenueCenter(){if(this.dragPanHandler.panToCenter(),this._featureIncomplete){const e=()=>this.getFeaturesById(this._curVenueId,{layerIds:[Ge]})[0];await this._waitForFeatureLoaded(e)}}async _waitForFeatureLoaded(e){const i=()=>this._isDestroyed?(this._abortQueryFeature?.(),!0):!!e(),{promise:r,abort:n}=kr(i);this._abortQueryFeature=n;try{await Promise.race([r,new Promise((s,o)=>{this._abortQueryFeature=()=>{o(new Error("Aborted")),this._abortQueryFeature=null}})])}catch(s){console.warn(s);return}}setDragPan(e){this._dragPan=e}setFitBounds(e){this._fitBounds=e}async queryIndoorFeaturesByClickPoint(e){const i=this._queryVisibleFeature(e);if(!i)return null;const r=async s=>{let o=this.getFeaturesById(s,{layerIds:[Ge]})[0];if(!o){const a=await He(s);o=Te(a),this._featureIncomplete=!0}return o??null},n=async s=>{let o=this.getFeaturesById(s,{layerIds:[ie]})[0];if(!o){const a=await De(s);o=nt(a),this._featureIncomplete=!0}return o??null};if(Ke(i.sourceLayer,i.layer.type)){const{id:s,"ref:building":o,name:a,ordinal:l}=i.properties,d=await n(o);if(d){const u=d.properties["ref:venue"];return{venue:await r(u),building:d,floor:{id:s,code:a,ordinal:l}}}}else if(Qi(i.sourceLayer,i.layer.type)){const{id:s,ordinal:o,name:a,"ref:venue":l}=i.properties;return{sharedFloor:{id:s,ordinal:o,name:typeof a=="string"?{default:a}:a},venue:await r(l)}}else{const s=i?.properties?.["ref:venue"];return i?{building:i,venue:await r(s)}:null}}async selectByClickMap(e){!this._enableIndoorClickSelection&&!this._enableOutdoorClickSelection||(this.setDragPan(!1),this.dragPanHandler.setBounds(null),this._featureIncomplete=!1,e?this._enableIndoorClickSelection&&("building"in e?await this.selectBuilding(e.building,{floorId:e?.floor?.id}):"sharedFloor"in e&&await this.selectSharedFloor(e.sharedFloor,e.venue)):this._enableOutdoorClickSelection&&await this.selectBuilding(null))}_bindMaplibreEventListeners(){this._map.once("styledata",()=>this.updateCustomLayers()),this._map.once("idle",()=>{this.emit(Gi),(!this._startWithIndoorView||this._map.getZoom()<14)&&this._dispatchIndoorMapLoaded()}),this._map.on("sourcedata",this._debounceRendering=vt(()=>this.updateRendering(),300))}_clear(){this._curBuildingFeature=null,this._curBuildingId=null,this._floor={code:null,id:null,ordinal:null},this._curVenueId=null,this._curVenueFeature=null,this._curSharedLevelId=null}_getIndoorFeatures(){return this._queryRenderedFeatures().filter(e=>rt(e.source))}_getBuildingFloorByOrdinal(e,i){let r=null,n=null;if(e?.properties){const{ordinals:s,level_names:o,level_ids:a}=e.properties,l=w(s).findIndex(d=>d===i);r=w(o)[l]??null,n=w(a)[l]??null}return{code:r,id:n,ordinal:i}}_isCurrentFeature(e){const i=e?.properties?.id??null,r=this._isSelectSharedFloor?this._curSharedLevelId:this._curBuildingId;return i===r}_setOutdoorVisibility(e){for(const{id:i}of this._outdoorLayers)this._map.getLayer(i)&&this._map.setLayoutProperty(i,"visibility",e?"visible":"none")}_addReserveFloorLayers(){for(const e of[me,x]){if(this._map.getLayer(e))continue;const i=e.split("_")[1],r=this._map.getLayer(i);if(!r)continue;const{source:n,sourceLayer:s}=r,o=e===me?this._middleLayers[0]:this._lowerLayers[0];let a={"fill-opacity":0};if(this._isMaskMode&&e===x){const l=this._originIndoorLayers.find(({id:d})=>d===ie);l&&(a=Object.assign({},l.paint??{},a))}this._map.addLayer({id:e,source:n,"source-layer":s,type:"fill",paint:a},o.id)}}_addBuildingMaskLayer(){if(this._map.getLayer(be))return;const e=this._originIndoorLayers.find(({id:i})=>i===ie);if(e){const i=Object.assign({},e,{id:be,layout:Object.assign({},e.layout??{},{visibility:"visible"}),paint:Object.assign({},e.paint??{},{"fill-opacity":0})});this._map.addLayer(i,ie)}}_updateUnselectedMask(){if(!this._isMaskMode)return;const e=[...this._maskBuildings],i=[...this._maskSharedFloors];this._map.getLayer(be)&&this._map.setPaintProperty(be,"fill-opacity",["case",["in",["get","id"],["literal",e]],1,0]),this._map.getLayer(x)&&this._map.setPaintProperty(x,"fill-opacity",["case",["in",["get","id"],["literal",i]],1,0])}_addSelectedHighlightLayers(){const e=[{layerId:wt,sourceLayer:"mapxus_level"},{layerId:Bt,sourceLayer:"mapxus_shared_level"}];let i=this._originIndoorLayers.find(({type:r})=>Pt(r));if(!i){const r=this._originIndoorLayers.findIndex(({id:n})=>n===this._upperLayers[this._upperLayers.length-1].id);i=this._originIndoorLayers[r+1]}for(const{layerId:r,sourceLayer:n}of e){if(this._map.getLayer(r))continue;const{lineWidth:s,lineOpacity:o,lineColor:a,lineOffset:l}=this._selectedHighlightStyle,d=Yi(s,l);this._map.addLayer({id:r,source:"indoor-planet","source-layer":n,type:"line",filter:["==","id",""],paint:{"line-offset":d,"line-width":s,"line-color":a,"line-opacity":o}},i?.id)}}_filterSelectedHighlight(){for(const e of[wt,Bt])this._map.getLayer(e)&&this._map.setFilter(e,["==","id",this._isSelectSharedFloor?this._curSharedLevelId:this._floor.id??""])}_copyOverlapLayers(){const e=this._originIndoorLayers.findIndex(({type:a,"source-layer":l})=>Xi(l,a)),i=this._originIndoorLayers.findIndex(({type:a,"source-layer":l})=>Et(l,a)),r=this._originIndoorLayers.slice(e,i);this._upperLayers=r.filter(({type:a})=>Oa(a));const n=this._originIndoorLayers.slice(i),s=n.findIndex(({type:a,"source-layer":l})=>!Et(l,a));if(s>-1){this._commonPoiLayers=n.slice(0,s);const a=n.slice(s).filter(({"source-layer":l})=>l==="mapxus_section");this._sectionFillLineLayers=a.filter(({type:l})=>l!=="symbol"),this._sectionSymbolLayers=a.filter(({type:l})=>l==="symbol")}else this._commonPoiLayers=[...n],this._sectionSymbolLayers=r.filter(({type:a,"source-layer":l})=>l==="mapxus_section"&&a==="symbol");const o=this._upperLayers[0];this._middleLayers=this._upperLayers.filter(({type:a})=>!Pt(a)).map(a=>{const l=`${a.id}-overlap-copy`;let d=this._map.getLayer(l);return d||(d=Object.assign({},a,{id:l}),this._map.addLayer(d,o.id)),d})}_copySharedFloorBackgroundLayers(){if(!!!this._upperLayers.find(n=>n.id===x.split("_")[1]))return;const i=this._upperLayers.filter(({"source-layer":n,type:s})=>!Ke(n,s)&&!Pt(s)),r=this._middleLayers[0]||this._upperLayers[0];this._lowerLayers=[...i,...this._commonPoiLayers].map(n=>{const s=`${n.id}-shared-bg`;let o=this._map.getLayer(s);return o||(o=Object.assign({},n,{id:s}),this._map.addLayer(o,r.id)),o})}_updateFeatures(){this._features=this._getIndoorFeatures();const e=qi(this._features,s=>s.layer.id+":"+s.properties.id),i=[],r=[],n=[];for(const s of e){const o=s.layer.id;o===Ge?i.push(s):o===ie?r.push(s):o===x&&n.push(s)}this._allVenuesMap=new Map(i.map(s=>[s.properties.id,s])),this._allBuildingsMap=new Map(r.map(s=>[s.properties.id,s])),this._allSharedLevelsMap=new Map(n.map(s=>[s.properties.id,s]))}_calExcludedPoisInMiddle(){const e=this._map.querySourceFeatures("indoor-planet",{sourceLayer:"mapxus_place"}),i=n=>n?w(n).some(o=>this._upperLevels.has(o)):!1,r=e.filter(n=>{const s=n.properties["ref:level"]||n.properties["ref:shared_level"];return this._middleLevels.has(s)?i(n.properties.overlap):!1});this._excludedPoisInMiddle=r.map(n=>n.properties["osm:ref"])}_updateSelectedFeatures(){if(this._featureIncomplete){if(this._isSelectSharedFloor){const e=this._features.find(i=>i.properties.id===this._curVenueId);if(!e)return;this._curVenueFeature=e}else{const e=this._allBuildingsMap.get(this._curBuildingId);if(!e)return;this._curBuildingFeature=e}this._featureIncomplete=!1}}_layerFloors(){const{displayedLevels:e,selectedLevelIds:i,alwaysDisplayedSharedLevelIds:r,maskBuildingIds:n,maskSharedFloorIds:s}=this.layeredHandler.getLayeredData({selectedVenueId:this._curVenueId,venueMap:this._allVenuesMap,buildingMap:this._allBuildingsMap,sharedFloorMap:this._allSharedLevelsMap});this._upperLevels.clear(),this._middleLevels.clear(),this._lowerLevels.clear(),this._layerSelectedLevels(e,i),this._layerUnselectedLevels(e,i,r),this._isMaskMode&&(this._maskBuildings.clear(),this._maskSharedFloors.clear(),n.forEach(o=>{this._maskBuildings.add(o)}),s.forEach(o=>{this._maskSharedFloors.add(o)}))}_layerSelectedLevels(e,i){for(const r of i){this._upperLevels.add(r),this._zIndexHistory.set(r,!0);const n=e.find(({level:s,overlap:o})=>s===r&&!!o);if(n)for(const s of n.overlap)this._zIndexHistory.get(s)&&this._zIndexHistory.delete(s)}}_layerUnselectedLevels(e,i,r){for(const n of e){if(i.includes(n.level))continue;const{level:s,overlap:o,venueId:a}=n,l=this._zIndexHistory.get(s),d=!o||!o.some(h=>this._upperLevels.has(h)),u=r.includes(s);if(a===this._curVenueId&&u){this._lowerLevels.add(s),this._zIndexHistory.delete(s);continue}l?this._upperLevels.add(s):l===!1?this._middleLevels.add(s):u?this._lowerLevels.add(s):d?(this._upperLevels.add(s),this._zIndexHistory.set(s,!0)):(this._middleLevels.add(s),this._zIndexHistory.set(s,!1))}}_filterLayers(){this._filterIndoorLayers([...this._upperLevels,...this._middleLevels],this._commonPoiLayers),this._filterIndoorLayers([...this._upperLevels],this._upperLayers),this._filterIndoorLayers([...this._middleLevels],this._middleLayers),this._filterIndoorLayers([...this._lowerLevels],this._lowerLayers),this._sectionSymbolLayers.length!==0&&(this._sectionFillLineLayers.length?(this._filterIndoorLayers([...this._upperLevels],this._sectionFillLineLayers),this._filterIndoorLayers([...this._upperLevels],this._sectionSymbolLayers)):this._filterIndoorLayers([...this._upperLevels,...this._middleLevels,...this._lowerLevels],this._sectionSymbolLayers))}_filterIndoorLayers(e,i){let r;for(const n of i){const{id:s,filter:o,type:a,"source-layer":l}=n,d=o?[o]:[],u=s.includes("-shared-bg"),h=[...this._maskBuildings],c=[...this._maskSharedFloors];Xi(l,a)?r=["all",Ke(l,a)?["!in","ref:building",...h]:["!in","id",...c],["in","id",...e],...d]:u?r=["all",["!in","ref:shared_level",...c],["in","ref:shared_level",...e],...d]:(r=["all",["any",["all",["!in","ref:building",...h],["in","ref:level",...e]],["all",["!in","ref:shared_level",...c],["in","ref:shared_level",...e]]],...d],Et(l,a)&&r.splice(1,0,["any",["!has","overlap"],["any",["in","ref:level",...this._upperLevels],["in","ref:shared_level",...this._upperLevels],["!in","osm:ref",...this._excludedPoisInMiddle]]])),this._map.setFilter(s,r)}}async _queryVenueFeature(e){let i=this.getFeaturesById(e,{layerIds:[Ge]})[0]??null;if(!i)try{const r=await He(e);i=Te(r)}catch(r){console.error(r)}return i}_getBuildingDisplayedOrdinal(e,i){if(!e||!e.properties)return null;const{"ref:venue":r,level_ids:n,ordinals:s}=e.properties,o=w(n),a=w(s);if(i){const d=o.findIndex(u=>u===i);return a[d]??null}const l=this._history.getHistoryOrdinal(r);return l&&a.includes(l)?l:Vi(e)}_updateFloorState(e){if(!e){this._floor={code:null,id:null,ordinal:null};return}const{code:i,id:r}=this._getBuildingFloorByOrdinal(this._curBuildingFeature,e);(!i||!r)&&console.error(`Floor with ordinal "${e}" not found in building "${this._curBuildingId}".`),this._floor={code:i,id:r,ordinal:e},this._history.setHistoryOrdinal(this._curVenueId,e),this._history.setHistoryBuildingUnit(this._curVenueId,{id:this._curBuildingId,type:"building"})}async _checkAndPanToBuilding(){this.getFeaturesById(this._curBuildingId,{layerIds:[ie]})[0]||(this._fitBounds?this.dragPanHandler.fitBounds():this.dragPanHandler.panToCenter())}_queryVisibleFeature(e){const r=[Ki,Lt,`${Ki}-overlap-copy`,`${Lt}-overlap-copy`,`${Lt}-shared-bg`,...this._isMaskMode?[x,be]:[]].filter(o=>!!this._map.getLayer(o)),n=this._map.queryRenderedFeatures(e,{layers:r});let s=null;for(const o of r){const a=n.find(l=>l.layer.id===o);if(a){s=a;break}}return s&&Ca(s.sourceLayer,s.layer.type)&&(this._maskBuildings.has(s.properties?.id)||(s=null)),s}_queryRenderedFeatures(e){const i=(e||[]).filter(s=>this._map.getLayer(s));if(e&&e.length>0&&i.length===0)return[];const r=i.length?{layers:i}:{},n=this._map.getCanvas().getBoundingClientRect();return this._map.queryRenderedFeatures([[0,0],[n.width,n.height]],r)}_dispatchIndoorMapLoaded(){this._indoorMapLoaded||(this._indoorMapLoaded=!0,this.emit(It))}_changeOtherVenuesHistory(e){const i=[...this._allVenuesMap.values()];for(const r of i){const n=r.properties.id;n!==this._curVenueId&&this._history.setHistoryOrdinal(n,e)}}}function Yi(t,e){const i=typeof t=="number"&&t===Re.lineWidth,r=typeof e=="number"&&e===Re.lineOffset;if(!r)return e;if(i&&r)return["interpolate",["linear"],["zoom"],18,-1.5,20.2,-3.75,20.4,-3.8,21.5,-7.5,22,-9.55];if(!i&&r)return typeof t=="number"?-(t/2):e}function Ca(t,e){return t==="mapxus_building"&&(e==="fill"||e==="line"||e==="symbol")}function Xi(t,e){return Ke(t,e)||Qi(t,e)}function Ke(t,e){return t==="mapxus_level"&&(e==="fill"||e==="line")}function Qi(t,e){return t==="mapxus_shared_level"&&(e==="fill"||e==="line")}function Et(t,e){return t==="mapxus_place"&&e==="symbol"}function Pt(t){return t==="fill-extrusion"}function Oa(t){return t==="line"||t==="fill"||t==="fill-extrusion"}const We="Poi_poiClick";class Zi{_map;_currentStyle=null;_styleLayersLength=0;_layerIds=[];_dispatch=ye(We);_listeners=[];constructor(e){this._map=e,this._bindPoiClickEvent()}destroy(){this._dispatch.on(`.${We}`,null),this._currentStyle=null,this._map=null,this._dispatch=null,this._listeners=[],this._layerIds=[]}onPoiClick(e){const i=te(`${We}.`);return this._dispatch.on(i,e),this._listeners.push(i),{unsubscribe:()=>this._dispatch.on(i,null)}}_queryPoiLayers(){const e=this._map.getStyle();if(e.name===this._currentStyle&&e.layers.length===this._styleLayersLength)return;const i=it(e).filter(r=>r["source-layer"]==="mapxus_place"&&r.type==="symbol");this._layerIds=i.map(({id:r})=>r),this._currentStyle=e.name,this._styleLayersLength=e.layers.length}_bindPoiClickEvent(){this._map.on("click",e=>{if(this._listeners.length===0)return;this._queryPoiLayers();const i=this._map.queryRenderedFeatures(e.point,{layers:this._layerIds});if(i.length===0)return;const r=i[0],n=w(r.properties["ref:sections"]),s=!!r.properties["ref:shared_level"],o={coordinate:e.lngLat,poi:r};if(n.length>0){const a=this._map.querySourceFeatures("indoor-planet",{sourceLayer:"mapxus_section"});o.sections=n.map(l=>{const d=a.find(g=>g.properties.id===l),{id:u,section:h="",correlation_id:c}=d?.properties||{},f=Ji(d?.properties);return{id:u,category:h,sectionName:f,...c&&{correlationId:c}}})}if(s){const a=r.properties["ref:shared_level"],{floor:l,venue:d}=this._queryIndoorFeaturesBySharedFloor(a);o.floor=l,o.venue=d}else{const a=r.properties["ref:level"],{floor:l,building:d,venue:u}=this._queryIndoorFeaturesByFloor(a);o.floor=l,o.building=d,o.venue=u}this._dispatch.call(We,null,o)})}_queryIndoorFeaturesBySharedFloor(e){const i=this._map.queryRenderedFeatures({layers:[x,"mapxus-venue-fill"]}),r=i.find(d=>d.sourceLayer==="mapxus_shared_level"&&d.properties.id===e);if(!r)return{floor:null,venue:null};const n=r.properties["ref:venue"],s=i.find(d=>d.layer.id==="mapxus-venue-fill"&&d.properties.id===n)??null,{id:o,ordinal:a}=r.properties,l=Ji(r.properties);return{floor:{id:o,ordinal:a,name:l},venue:s}}_queryIndoorFeaturesByFloor(e){const i=this._map.queryRenderedFeatures({layers:[me,"mapxus-building-line","mapxus-venue-fill"]}),r=i.find(u=>u.sourceLayer==="mapxus_level"&&u.properties.id===e);if(!r)return{floor:null,building:null,venue:null};const{id:n,ordinal:s,name:o,"ref:building":a}=r.properties||{},l=i.find(u=>u.layer.id==="mapxus-building-line"&&u.properties.id===a)??null,d=i.find(u=>u.layer.id==="mapxus-venue-fill"&&u.properties.id===l?.properties?.["ref:venue"])??null;return{floor:{id:n,ordinal:s,code:o},building:l,venue:d}}}function Ji(t){return t?Object.keys(t).filter(i=>i.includes("name")).reduce((i,r)=>{const[,n]=w(r,":");return n?i[n]=t[r]:i.default=t[r],i},{}):{default:""}}function Fe(t){t.parentNode&&t.parentNode.removeChild(t)}function F(t,e,i){const r=document.createElement(t);return e&&(r.className=e),i&&i.appendChild(r),r}class er{_map;_maplibre;_buildingId;_features;_$container;_$listContainer;_$buildingList;_listHeight;_language;_visible;_position="top-right";_isMobileMode;_isListShown=!1;constructor(e,i){this._map=e,this._language=e.getLanguage(),this._visible=i??!0,this._detectDeviceMode()}onAdd(e){return this._maplibre=e,this._$container=F("div",`maplibregl-ctrl maplibregl-ctrl-building-filter ${this._visible?"":"hide"}`,this._maplibre.getContainer()),this._$container.appendChild(this._buildingFilterIconCreate("div")),this._$container.appendChild(this._buildingNameListCreate("div")),this._bindEvents(),this._$container}onRemove(){Fe(this._$container)}get position(){return this._position}get enabled(){return this._visible}getDefaultPosition(){return"top-right"}setVisibility(e){this._visible=e,e?this._$showLayout():this._$hideLayout()}changePosition(e,i,r){const n=document.querySelector(`.maplibregl-ctrl-${e}`),s=n.querySelector(".maplibregl-ctrl-building-filter");if(e!==i){this._position=i;const o=document.querySelector(`.maplibregl-ctrl-${i}`);s&&(n.removeChild(s),Number.isFinite(r)?o.insertBefore(s,o.children[r]):o.append(s),this._updateBuildingListLayout(i))}else Number.isFinite(r)&&n.children[r]!==s&&(n.removeChild(s),n.insertBefore(s,n.children[r]))}_bindEvents(){this._maplibre.on("moveend",()=>this._refresh()),this._map.onMapChangeListener(e=>{const i=e.building?.properties?.id??"";this._buildingId!==i&&(this._buildingId=i,this._refresh())}),this._map.renderComplete(()=>this._init())}_init(){this._load()}_refresh(){this._load()}_load(){this._buildingNameListClean(),this._buildingNameListUpdate()}_buildingFilterIconCreate(e){const i=F(e,"mapxus-building-filter-icon");return this._bindMouseOnEvents(i,!1),this._bindMobileTouchEvents(i),i}_buildingNameListCreate(e){return this._$listContainer=F(e,"mapxus-building-name-layout"),this._$listContainer.style.display="none",this._$listContainer.style.top="20px",this._$buildingList=F(e,"mapxus-building-name-list",this._$listContainer),this._bindMouseOnEvents(this._$listContainer,!0),this._$listContainer}_buildingNameListUpdate(){this._features=[];const e=this._map.getMaplibre(),i=e?e.queryRenderedFeatures({layers:["mapxus-building-line"]}):[];for(const r of i){const{properties:n}=r,{id:s,name:o}=n,a=n?.[`name:${this._language}`]??o;this._features.find(l=>l.properties.id===s)||(this._features.push(r),this._$buildingList.appendChild(this._buildingNameCreate("p",a,s,s===this._map.building?.properties?.id)))}this._setBuildingListHeight(this._features),this._updateBuildingListLayout(this._position)}_buildingNameListClean(){this._$buildingList.replaceChildren()}_setBuildingListHeight(e){const n=e.map(s=>{const o=s?.properties?.[`name:${this._language}`]??s?.properties?.name;return o?Math.ceil(o.length*8/107):0}).reduce((s,o)=>s+o,0);this._listHeight=n*26+e.length*8,this._$buildingList.style.height=this._$listContainer.style.height=`${this._listHeight>=208?208:this._listHeight}px`}_buildingNameCreate(e,i,r,n){const s=F(e,`mapxus-building-name${n?" active":""}`);return s.dataset.id=r,s.innerText=i,this._buildingNameClickEvent(s),s}_toggleList(e){this._isListShown=e,this._$listContainer.style.display=e?"block":"none"}_buildingNameClickEvent(e){e.onclick||(e.onclick=async i=>{const r=i.target;await this._map.selectBuildingById(r.dataset.id)})}_bindMouseOnEvents(e,i){e.onmouseenter=()=>{this._isMobileMode||this._toggleList(!0)},i&&(e.onmouseleave=()=>this._toggleList(!1))}_bindMobileTouchEvents(e){window.addEventListener("resize",()=>this._detectDeviceMode()),e.ontouchend=()=>this._toggleList(!this._isListShown)}_$showLayout(){this._$container.classList.remove("hide")}_$hideLayout(){this._$container.classList.add("hide")}_updateBuildingListLayout(e){e.indexOf("left")>-1?(this._$listContainer.style.right=null,this._$listContainer.style.left="55px"):(this._$listContainer.style.left=null,this._$listContainer.style.right="55px");const i=this._$container.offsetParent?this._$container.offsetParent.clientHeight-(this._$container.offsetTop+this._$container.clientHeight)-25:0;e.includes("bottom")&&this._listHeight-20>i?(this._$listContainer.style.top=null,this._$listContainer.style.bottom="15px"):(this._$listContainer.style.bottom=null,this._$listContainer.style.top="20px")}_detectDeviceMode(){this._isMobileMode=window.matchMedia("(pointer: coarse) and (max-width: 768px)").matches}}var $a=Math.max,Aa=Math.min;function Ma(t,e,i){return t>=Aa(e,i)&&t<$a(e,i)}var tr=1/0,xa=17976931348623157e292;function ir(t){if(!t)return t===0?t:0;if(t=ze(t),t===tr||t===-tr){var e=t<0?-1:1;return e*xa}return t===t?t:0}function rr(t,e,i){return e=ir(e),i===void 0?(i=e,e=0):i=ir(i),t=ze(t),Ma(t,e,i)}class nr{_container;_indoor;_maplibre;_position="top-right";_buildingId;_floorNames;_ordinals;_ordinal;_style;_$innerFloors;_$activeFloor;_centerSelectorIdx;_lastNormalScrollableIdx;_$arrowBtnUp;_$arrowBtnDown;_maxScrollTop;_$selectorExpanded;_$selectorFolded;_componentDidMount=!1;_visible=!1;_isEnabled;_dragPan;_language;_debounceScroll;_clearScrollEventListener;constructor(e,i){const{style:r,enabled:n=!0,language:s}=i;this._indoor=e,this._language=s,this._style=r?Object.assign({},Vt,r):Vt,this._isEnabled=n,this._addIndoorEventListeners()}onAdd(e){return this._maplibre=e,this._addMapMoveEventListener(),this._container=F("div","maplibregl-ctrl mapxus-ctrl-floors hidden"),this._container}onRemove(){this._debounceScroll&&this._debounceScroll.cancel(),this._clearScrollEventListener&&this._clearScrollEventListener(),Fe(this._container)}get position(){return this._position}get enabled(){return this._isEnabled}setEnabled(e){this._isEnabled=e,e&&!this._visible&&this._setVisibility(!0),!e&&this._visible&&this._setVisibility(!1)}getDefaultPosition(){return"top-right"}async switchByOrdinal(e,i){this._ordinal=e,this._dragPan=i??!0,await this._indoor.switchFloorByOrdinal(e),this._updateSelectorStatus(e),this._scrollCenterActiveFloor()}changePosition(e,i,r){const n=document.querySelector(`.maplibregl-ctrl-${e}`),s=n.querySelector(".mapxus-ctrl-floors");if(e!==i){this._position=i;const o=document.querySelector(`.maplibregl-ctrl-${i}`);s&&(n.removeChild(s),Number.isFinite(r)?o.insertBefore(s,o.children[r]):o.append(s),this._show(),this._scrollCenterActiveFloor())}else Number.isFinite(r)&&n.children[r]!==s&&(n.removeChild(s),n.insertBefore(s,n.children[r]),this._show(),this._scrollCenterActiveFloor())}setStyle(e){this._style=Object.assign({},this._style,e),this._componentDidMount&&(this._clearFloors(),this._calcSelectorLayout(),this._render(),this._scrollCenterActiveFloor())}_setVisibility(e){this._componentDidMount?e?(this._show(),this._scrollCenterActiveFloor()):this._hide():(this._visible=e,this._indoor.building&&e&&(this._render(),this._show(),this._scrollCenterActiveFloor()))}_addIndoorEventListeners(){this._indoor.on(qe,e=>{if(this._updatePrepared(),!e)return;const{ordinal:i,dragPan:r}=e;this._dragPan=r,"building"in e?this._renderBuildingFloors(e.building,i):this._renderSharedLevelFloor(e)})}_updatePrepared(){this._clearState(),this._visible&&this._hide(),this._componentDidMount&&this._clearFloors()}_renderBuildingFloors(e,i){const{level_names:r,ordinals:n,id:s}=e.properties;this._buildingId=s,this._floorNames=r.split(",").reverse(),this._ordinals=n.split(",").reverse(),this._ordinal=i,this._calcSelectorLayout(),this._render();const o=this._indoor.getFeaturesById(s,{filter:a=>a.layer.id==="mapxus-building-line"})[0];this._checkIfShowFloorSelector(o)}_renderSharedLevelFloor(e){const{name:i,ordinal:r,id:n}=e;this._floorNames=[i[this._language]||i.default],this._ordinals=[r],this._ordinal=r,this._calcSelectorLayout(),this._render();const s=this._indoor.getFeaturesById(n,{layerIds:[x]})[0];this._checkIfShowFloorSelector(s)}_checkIfShowFloorSelector(e){this.enabled&&(this._dragPan!==!1||this._dragPan===!1&&e)&&(this._show(),this._scrollCenterActiveFloor())}_addMapMoveEventListener(){this._maplibre.on("moveend",()=>{this.enabled&&this._dragPan===!1&&this._buildingId&&(this._indoor.getFeaturesById(this._buildingId,{layerIds:["mapxus-building-line"]})[0]?this._componentDidMount?this._visible||(this._show(),this._scrollCenterActiveFloor()):(this._render(),this._show(),this._scrollCenterActiveFloor()):this._componentDidMount&&this._visible&&this._hide())})}_clearState(){this._buildingId=null,this._floorNames=[],this._ordinals=[],this._ordinal=null}_calcSelectorLayout(){const{itemCount:e,itemSize:i}=this._style;this._centerSelectorIdx=Math.ceil(e/2)-1,this._maxScrollTop=(this._floorNames.length-e)*i,this._lastNormalScrollableIdx=this._floorNames.length-(e-this._centerSelectorIdx-1)-1}_render(){this._createFloors(),this._componentDidMount=!0}_hide(){this._container.classList.add("hidden"),this._visible=!1}_show(){this._container.classList.remove("hidden"),this._visible=!0}_createFloors(){this._$selectorFolded=this._$foldedSelector(this._container,()=>{this._expandSelector(!0),this._scrollCenterActiveFloor()}),this._$selectorExpanded=this._$expandedSelector(this._container,()=>this._expandSelector(!1))}_$expandedSelector(e,i){const{itemSize:r,itemCount:n,defaultFolded:s,backgroundColor:o}=this._style,a=F("div",`mapxus-ctrl-floors-expanded ${s?"hidden":""}`,e);if(this._floorNames.length>1){const d=F("div","mapxus-ctrl-floors-close",a);d.onclick=i}const l=F("div","mapxus-ctrl-floors-wrapper",a);return l.style.backgroundColor=o,this._floorNames.length>n&&(this._$arrowBtnUp=this._$createScrollButton(l,"up"),this._$arrowBtnUp.onclick=()=>this._handleScroll("up")),this._$innerFloors=F("div","mapxus-ctrl-floors-inner",l),Object.assign(this._$innerFloors.style,{maxHeight:`${r*n}px`,width:`${r}px`}),this._$createFloors(this._$innerFloors),this._floorNames.length>n&&(this._$arrowBtnDown=this._$createScrollButton(l,"down"),this._$arrowBtnDown.onclick=()=>this._handleScroll("down"),this._$innerFloors.addEventListener("scroll",this._debounceScroll=vt(d=>{d.stopPropagation(),this._resetArrowBtnStatus(this._$innerFloors.scrollTop)},100)),this._clearScrollEventListener=()=>this._$innerFloors.removeEventListener("scroll",this._debounceScroll)),a}_$foldedSelector(e,i){const{itemSize:r,activeFontColor:n,activeBackgroundColor:s,defaultFolded:o}=this._style,a=F("div",`mapxus-ctrl-floors-folded mapxus-ctrl-floors-floor ${o?"":"hidden"}`,e);return a.onclick=i,Object.assign(a.style,{width:`${r}px`,height:`${r}px`,lineHeight:`${r}px`,color:n,backgroundColor:s}),a}_clearFloors(){this._container.replaceChildren(),this._componentDidMount=!1}_$createScrollButton(e,i){return F("div",`mapxus-ctrl-floors-arrow mapxus-ctrl-floors-floor ${i}`,e)}_$createFloors(e){const{fontColor:i,itemSize:r}=this._style;let n;this._floorNames.forEach((s,o)=>{n=F("div","mapxus-ctrl-floors-floor",e),n.dataset.floor=s,n.dataset.ordinal=this._ordinals[o],n.innerText=s,Object.assign(n.style,{color:i,height:`${r}px`,lineHeight:`${r}px`}),n.dataset.ordinal===this._ordinal&&(this._$activeFloor=n,this._resetActiveFloor(!0),this._$selectorFolded.innerText=s),n.onclick=async a=>{this._indoor.setDragPan("restrict"),this._indoor.dragPanHandler.setAnimated(!0),await this.switchByOrdinal(a.target.dataset.ordinal)}})}_updateSelectorStatus(e){const i=this._floorNames[this._ordinals.indexOf(e)];this._$activeFloor&&this._resetActiveFloor(!1);for(const r of this._$innerFloors.children){const n=r;n.dataset.ordinal===e&&(this._$activeFloor=n,this._resetActiveFloor(!0))}this._$selectorFolded.innerText=i}_resetArrowBtnStatus(e){e===0?this._$arrowBtnUp?.classList?.add("hidden"):this._$arrowBtnUp?.classList?.remove("hidden"),e===this._maxScrollTop?this._$arrowBtnDown?.classList?.add("hidden"):this._$arrowBtnDown?.classList?.remove("hidden")}_resetActiveFloor(e){const{activeBackgroundColor:i,backgroundColor:r,activeFontColor:n,fontColor:s}=this._style;Object.assign(this._$activeFloor.style,{color:e?n:s,backgroundColor:e?i:r,fontWeight:e?"bold":"normal",cursor:e?"auto":"pointer"}),this._$activeFloor.disabled=e}_scrollCenterActiveFloor(){if(this._ordinal){const e=this._ordinals.indexOf(this._ordinal);e>-1&&(this._$innerFloors.scrollTop=this._getScrollTop(e),this._$innerFloors.scrollTop||this._resetArrowBtnStatus(0))}}_getScrollTop(e){return rr(this._centerSelectorIdx,this._lastNormalScrollableIdx+1)?(e-this._centerSelectorIdx)*this._style.itemSize:e>this._lastNormalScrollableIdx?this._maxScrollTop:0}_handleScroll(e){const i=this._$innerFloors.scrollTop,{itemSize:r}=this._style;if(e==="up"){const n=i-r*2;this._$innerFloors.scrollTop=n<0?0:n}else if(e==="down"){const n=i+r*2;this._$innerFloors.scrollTop=n>this._maxScrollTop?this._maxScrollTop:n}}_expandSelector(e){e?(this._$selectorExpanded.classList.remove("hidden"),this._$selectorFolded.classList.add("hidden")):(this._$selectorExpanded.classList.add("hidden"),this._$selectorFolded.classList.remove("hidden"))}}class Ta{_container;_isEnabled;constructor(e){this._isEnabled=e?.enabled??!0}onAdd(e){if(this._container=F("div","maplibregl-ctrl mapxus-ctrl-logo",e.getContainer()),this._isEnabled){const i=F("a","mapxus-logo",this._container);i.target="_blank",i.href="https://www.khi.co.jp/groupvision2030/mapxus.html",i.setAttribute("aria-label","Mapxus logo"),i.setAttribute("rel","noopener"),this._container.appendChild(i)}return this._container}onRemove(){Fe(this._container)}getDefaultPosition(){return"bottom-left"}}class Ra{_container;_anchor;_theme;constructor(e){this._theme=e.theme?e.theme:"default"}onAdd(e){return this._container=F("div","maplibregl-ctrl mapxus-ctrl-attribution",e.getContainer()),this._anchor=F("a","mapxus-attribution",this._container),this._anchor.target="_blank",this._setCopyrightInfo(this._theme),this._anchor.setAttribute("aria-label","Mapxus attribution"),this._anchor.setAttribute("rel","noopener"),this._container.appendChild(this._anchor),this._container}onRemove(){Fe(this._container)}getDefaultPosition(){return"bottom-right"}changeTheme(e){this._setCopyrightInfo(e)}_setCopyrightInfo(e){this._anchor.innerText=e==="landsD"?"© The Government of the Hong Kong SAR":"©Mapxus driven by Kawasaki ©OpenStreetMap contributors",e==="landsD"&&(this._anchor.href="https://www.map.gov.hk/gm/")}}class ka{_container;_$icon;_removeClickEventListener;onAdd(e){return this._container=F("div","maplibregl-ctrl mapxus-ctrl-collapsed-copyright",e.getContainer()),this._container.innerHTML=Da(),this._bindEvents(),this._container}onRemove(){this._removeClickEventListener(),Fe(this._container)}getDefaultPosition(){return"bottom-right"}_bindEvents(){const e=this._container.querySelector(".mapxus-collapsed-copyright-menu");this._$icon=this._container.querySelector(".mapxus-collapsed-copyright-btn");let i=!1;this._$icon.addEventListener("click",r),this._removeClickEventListener=()=>this._$icon.removeEventListener("click",r);function r(){i=!i,n()}function n(){i?e.classList.remove("hidden"):e.classList.add("hidden")}}}function Da(){return`
1
+ (function(p,$){typeof exports=="object"&&typeof module<"u"?$(exports,require("@mapxus/mapxus-auth-jp"),require("maplibre-gl")):typeof define=="function"&&define.amd?define(["exports","@mapxus/mapxus-auth-jp","maplibre-gl"],$):(p=typeof globalThis<"u"?globalThis:p||self,$(p.MapxusMap={},p.MapxusAuth,p.maplibregl))})(this,(function(p,$,Ut){"use strict";var vr={value:()=>{}};function Se(){for(var t=0,e=arguments.length,i={},r;t<e;++t){if(!(r=arguments[t]+"")||r in i||/[\s.]/.test(r))throw new Error("illegal type: "+r);i[r]=[]}return new Te(i)}function Te(t){this._=t}function Ir(t,e){return t.trim().split(/^|\s+/).map(function(i){var r="",n=i.indexOf(".");if(n>=0&&(r=i.slice(n+1),i=i.slice(0,n)),i&&!e.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:r}})}Te.prototype=Se.prototype={constructor:Te,on:function(t,e){var i=this._,r=Ir(t+"",i),n,s=-1,o=r.length;if(arguments.length<2){for(;++s<o;)if((n=(t=r[s]).type)&&(n=Lr(i[n],t.name)))return n;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<o;)if(n=(t=r[s]).type)i[n]=jt(i[n],t.name,e);else if(e==null)for(n in i)i[n]=jt(i[n],t.name,null);return this},copy:function(){var t={},e=this._;for(var i in e)t[i]=e[i].slice();return new Te(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var i=new Array(n),r=0,n,s;r<n;++r)i[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(s=this._[t],r=0,n=s.length;r<n;++r)s[r].value.apply(e,i)},apply:function(t,e,i){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],n=0,s=r.length;n<s;++n)r[n].value.apply(e,i)}};function Lr(t,e){for(var i=0,r=t.length,n;i<r;++i)if((n=t[i]).name===e)return n.value}function jt(t,e,i){for(var r=0,n=t.length;r<n;++r)if(t[r].name===e){t[r]=vr,t=t.slice(0,r).concat(t.slice(r+1));break}return i!=null&&t.push({name:e,value:i}),t}const rt={version:"10.0.1"}.version,Re="https://map-api.mapxus.co.jp/bms",R=10,k=1,ae="api/v5/venues",le="api/v5/buildings",j="api/v5/pois",wr="api/v5/categories/group",Br="api/v4/route/query",Er="api/v3/tiles/styles";class D{static instance;_globalDispatcher;_httpSession;_theme=null;_isSDKInitialized=!1;constructor(){}static getInstance(){return D.instance||(D.instance=new D),D.instance}setGlobalDispatcher(e){this._globalDispatcher=e}getGlobalDispatcher(){return this._globalDispatcher}async getHttpSession(){return this._httpSession||(this.registerSDK(),this._httpSession=await $.HTTPSession.create($.SDKName.MapSDK,$.base64Encode(`version-${rt}`)),this._httpSession.setBaseURL(Re),this._httpSession.setRetryConfig(3)),this._httpSession}registerSDK(){this._isSDKInitialized||(this._isSDKInitialized=!0,$.reportLog(`${$.SDKName.MapSDK} initialized`))}get theme(){return this._theme}setTheme(e){this._theme=e}clear(){this._httpSession.destroy(),this._globalDispatcher=null,D.instance=null}}const Vt=["unauthorized","initError"],nt=globalThis,st=Se(...Vt);D.getInstance().setGlobalDispatcher(st),nt.MapxusMapEvents=nt.MapxusMapEvents||{},nt.MapxusMapEvents.on=function(t,e){return st.on(t,e),{off:()=>st.on(t,null)}};var ke={exports:{}},zt;function Pr(){if(zt)return ke.exports;zt=1;function t(){}return t.prototype={on:function(e,i,r){var n=this.e||(this.e={});return(n[e]||(n[e]=[])).push({fn:i,ctx:r}),this},once:function(e,i,r){var n=this;function s(){n.off(e,s),i.apply(r,arguments)}return s._=i,this.on(e,s,r)},emit:function(e){var i=[].slice.call(arguments,1),r=((this.e||(this.e={}))[e]||[]).slice(),n=0,s=r.length;for(n;n<s;n++)r[n].fn.apply(r[n].ctx,i);return this},off:function(e,i){var r=this.e||(this.e={}),n=r[e],s=[];if(n&&i)for(var o=0,a=n.length;o<a;o++)n[o].fn!==i&&n[o].fn._!==i&&s.push(n[o]);return s.length?r[e]=s:delete r[e],this}},ke.exports=t,ke.exports.TinyEmitter=t,ke.exports}var Fr=Pr(),De=(t=>(t[t.VENUE=0]="VENUE",t[t.GLOBAL=1]="GLOBAL",t))(De||{});function Cr(t){return t.layers.filter(e=>!at(e.source))}function ot(t){return t.layers.filter(e=>at(e.source))}function at(t){return typeof t!="string"?!1:t.startsWith("indoor-")}function lt(t){const{buildingId:e,labelCenter:{lat:i,lon:r},floors:n,name:s,venueId:o,defaultFloor:a}=t,l=Object.entries(s).reduce((h,[f,g])=>{const _=f==="default"?"name":`name:${f}`;return Object.assign(h,{[_]:g})},{}),{codes:d,ids:u,ordinals:c}=n.reduce((h,f)=>{const{id:g,code:_,ordinal:y}=f;return{codes:h.codes?`${h.codes},${_}`:_,ids:h.ids?`${h.ids},${g}`:g,ordinals:`${h.ordinals}`?`${h.ordinals},${y}`:`${y}`}},{codes:"",ids:"",ordinals:""});return{layer:{id:"mapxus-building-line"},properties:{building:"yes",id:e,label_center:`${r},${i}`,level_ids:u,level_names:d,ordinals:c,"ref:venue":o,...l,...a?{default_displayed_floor:a}:{}},source:"indoor-planet",sourceLayer:"mapxus_building"}}function He(t){const{address:e,buildings:i,id:r,name:n,type:s,labelCenter:{lon:o,lat:a},defaultBuilding:l,sharedFloors:d}=t,u=Object.entries(e).reduce((_,[y,m])=>Object.assign(_,y==="default"?{"addr:street":m.street,"addr:housenumber":m.housenumber}:{[`addr:street:${y}`]:m.street}),{}),c=Object.entries(n).reduce((_,[y,m])=>{const S=y==="default"?"name":`name:${y}`;return Object.assign(_,{[S]:m})},{}),h=l?i.find(_=>_.id===l)?.defaultFloor:null,f=l?{default_displayed_building:l,...h?{default_displayed_ordinal:h}:{}}:{},g=d?.length?{shared_level_ids:d.map(({id:_})=>_).join(","),shared_level_ordinals:d.map(({ordinal:_})=>_).join(",")}:{};return{layer:{id:"mapxus-venue-fill"},properties:{...u,...c,id:r,venue:s,label_center:`${o},${a}`,building_ids:i.map(({id:_})=>_).join(),...f,...g},source:"indoor-planet",sourceLayer:"mapxus_venue"}}function w(t,e=","){return typeof t!="string"||!t.trim()?[]:t.split(e)}const ve="reserve_mapxus-level-fill",T="reserve_mapxus-shared-level-fill",Ie="reserve_mapxus-building-fill";var x=(t=>(t.ENGLISH="en",t.CHINESE_SIMPLIFIED="zh-Hans",t.CHINESE_TRADITIONAL="zh-Hant",t.CHINESE_TRADITIONAL_TW="zh-Hant-TW",t.JAPANESE="ja",t.KOREAN="ko",t.FILIPINO="fil",t.INDONESIAN="id",t.PORTUGUESE="pt",t.THAI="th",t.VIETNAMESE="vi",t.ARABIC="ar",t))(x||{});function qt(t){let e=null;return Or(t)?e=x.ENGLISH:$r(t)?e=x.CHINESE_SIMPLIFIED:Mr(t)?e=x.CHINESE_TRADITIONAL:Ar(t)?e=x.CHINESE_TRADITIONAL_TW:xr(t)?e=x.JAPANESE:Tr(t)?e=x.KOREAN:Rr(t)?e=x.FILIPINO:kr(t)?e=x.INDONESIAN:Dr(t)?e=x.PORTUGUESE:Hr(t)?e=x.THAI:Nr(t)?e=x.VIETNAMESE:Ur(t)&&(e=x.ARABIC),e}function Or(t){return/^en(-(US|GB|AU))?$/.test(t)}function $r(t){return/^zh(-(Hans|CN))?$/.test(t)}function Mr(t){return/^zh-(Hant|HK|MO)$/.test(t)}function Ar(t){return t==="zh-TW"}function xr(t){return/^ja(-JP)?$/.test(t)}function Tr(t){return/^ko(-KR)?$/.test(t)}function Rr(t){return/^(fil|tl)(-PH)?$/.test(t)}function kr(t){return/^id(-ID)?$/.test(t)}function Dr(t){return/^pt(-(BR|PT))?$/.test(t)}function Hr(t){return/^th(-TH)?$/.test(t)}function Nr(t){return/^vi(-VN)?$/.test(t)}function Ur(t){return/^ar(-(DZ|BH|EG|IQ|JO|KW|LB|LY|MA|OM|QA|SA|SY|TN|AE|YE))?$/.test(t)}const Ne={lineWidth:3,lineColor:"#A5E3FF",lineOpacity:1,lineOffset:-1.5},Gt={fontColor:"#8c8c8c",activeFontColor:"#fff",backgroundColor:"#fff",activeBackgroundColor:"#074769",itemSize:50,itemCount:4,defaultFolded:!1},jr=qt(window.navigator.language)??x.ENGLISH;class Kt extends Error{status;constructor(e,i){super(e);const{status:r,name:n}=i;r!==void 0&&(this.status=r),n!==void 0&&(this.name=n)}}function Vr(t,e=30){let i,r=null;return{promise:new Promise((o,a)=>{r=a;const l=performance.now(),d=()=>{t()?(clearInterval(i),o(!0)):(performance.now()-l)/1e3>e&&(a(new Kt("Timeouts or Feature is not found in the map at current zoom level.",{status:404,name:"NetworkError"})),clearInterval(i))};d(),i=setInterval(d,100)}),abort:()=>{i&&(clearInterval(i),i=null),r&&(r(new Kt("Query was aborted by the user.",{status:400,name:"AbortError"})),r=null)}}}function N(t){if(!t)return null;const i=(Array.isArray(t)?t:[t]).filter(v).map(r=>r.trim());return i.length>0?i.join(","):null}function v(t){return typeof t=="string"&&t.trim().length>0}function J(t){return Array.isArray(t)&&t.length===2&&t.every(e=>typeof e=="number")}function Le(t){return Array.isArray(t)&&t.length===2&&t.every(e=>J(e))}function de(t){return typeof t=="number"&&t>0}function Ue(t,e){const i={...t};return e.forEach(r=>{delete i[r]}),i}var Wt=(t=>(t.POINT="Point",t.POLYGON="Polygon",t))(Wt||{}),dt=(t=>(t.POINT="Point",t.POLYGON="Polygon",t.GATE="Gate",t))(dt||{}),Yt=(t=>(t.DEFAULT_NAME="DefaultName",t))(Yt||{}),Xt=(t=>(t.ABSOLUTE_DISTANCE="AbsoluteDistance",t.ACTUAL_DISTANCE="ActualDistance",t))(Xt||{});const ut=["specialHours","businessStatus","serviceHours","keywords","siteCode","refPhotoId","totalPhotoCount","photos","icon"],ct=D.getInstance();class Qt{constructor(){}searchByIds(e){const i=N(e);if(!i)throw new Error("Invalid ids parameter. Expected a non-empty string or an array of strings.");const r=`${j}/${i}`;return this._filterPoiProperties(r,Y)}searchByDistance(e){const{center:i,distance:r,keywords:n="",offset:s=R,page:o=k}=e;if(!J(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!de(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",i.join(",")),a.set("distance",String(Math.round(r))),a.set("offset",String(s)),a.set("page",String(o)),v(n)&&a.set("keywords",n);const l=`${j}?${a.toString()}`;return this._filterPoiProperties(l,Y)}searchByBounds(e){const{bounds:i,offset:r=R,page:n=k,keywords:s,orderBy:o}=e;if(!Le(i))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const a=new URLSearchParams;a.set("bbox",i.flat().join()),a.set("offset",String(r)),a.set("page",String(n)),v(s)&&a.set("keywords",s),o&&a.set("orderBy",o);const l=`${j}?${a.toString()}`;return this._filterPoiProperties(l,Y)}searchByBuilding(e){const{buildingId:i,offset:r=R,page:n=k,keywords:s,orderBy:o}=e;if(!v(i))throw new Error("'buildingId' must be a non-empty string.");const a=new URLSearchParams;a.set("buildingId",i),a.set("offset",String(r)),a.set("page",String(n)),v(s)&&a.set("keywords",s),o&&a.set("orderBy",o);const l=`${j}?${a.toString()}`;return this._filterPoiProperties(l,d=>Y(d))}searchByVenue(e){const{venueId:i,offset:r=R,page:n=k,keywords:s,orderBy:o}=e;if(!v(i))throw new Error("'venueId' must be a non-empty string.");const a=new URLSearchParams;a.set("venueId",i),a.set("offset",String(r)),a.set("page",String(n)),v(s)&&a.set("keywords",s),o&&a.set("orderBy",o);const l=`${j}?${a.toString()}`;return this._filterPoiProperties(l,Y)}searchByFloors(e){let i=null,r=null;const n="floorIds"in e?N(e.floorIds):null,s="sharedFloorIds"in e?N(e.sharedFloorIds):null;if(n?(i="floorId",r=n):s&&(i="sharedFloorId",r=s),!i||!r)throw new Error("Either 'floorIds' or 'sharedFloorIds' must be a non-empty array.");const{offset:o=R,page:a=k,keywords:l,orderBy:d}=e,u=new URLSearchParams;u.set("offset",String(o)),u.set("page",String(a)),u.set(i,r),v(l)&&u.set("keywords",l),d&&u.set("orderBy",d);const c=`${j}?${u.toString()}`;return this._filterPoiProperties(c,Y)}async searchByOrientation(e){const{center:i,angle:r,distance:n,distanceSearchType:s=dt.POINT}=e;if(!J(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!de(n)||n>100)throw new Error("Invalid distance parameter. Expected a positive number and cannot exceed 100.");if(!de(r))throw new Error("Invalid angle parameter. Expected a positive number.");const o=new URLSearchParams;if("ordinal"in e){if(!v(e.ordinal))throw new Error("'ordinal' must be a non-empty string.");o.set("ordinal",e.ordinal)}else if("floorId"in e){if(!v(e.floorId))throw new Error("'floorId' must be a non-empty string.");o.set("floorId",e.floorId)}else if("buildingId"in e){if(!v(e.buildingId))throw new Error("'buildingId' must be a non-empty string.");o.set("buildingId",e.buildingId)}else throw new Error("Either 'ordinal', 'floorId', or 'buildingId' must be provided.");o.set("center",i.join()),o.set("angle",String(Math.round(r))),o.set("distance",String(n)),o.set("distanceSearchType",s);const a=`${j}/orientation?${o.toString()}`;return(await ct.getHttpSession()).request(a)}searchByCategory(e){const{center:i,distance:r,page:n=k,offset:s=R}=e;if(!J(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!de(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000");const o=new URLSearchParams;if("category"in e&&v(e.category))o.set("category",String(e.category));else if("excludedCategories"in e&&N(e.excludedCategories))o.set("excludeCategories",N(e.excludedCategories));else throw new Error("Either 'category' or 'excludedCategories' must be provided.");o.set("center",i.join(",")),o.set("distance",String(r)),o.set("page",String(n)),o.set("offset",String(s));const a=`${j}?${o.toString()}`;return this._filterPoiProperties(a,Y)}async searchCategories(e){const i=new URLSearchParams;if("floorId"in e&&v(e.floorId)?i.set("floorId",e.floorId):"buildingId"in e&&v(e.buildingId)?i.set("buildingId",e.buildingId):"sharedFloorId"in e&&v(e.sharedFloorId)?i.set("sharedFloorId",e.sharedFloorId):"venueId"in e&&v(e.venueId)&&i.set("venueId",e.venueId),"bounds"in e&&Le(e.bounds)&&(i.set("bbox",e.bounds.flat().join()),v(e.keywords)&&i.set("keywords",e.keywords)),i.toString().length===0)throw new Error("At least one of 'floorId', 'buildingId', 'sharedFloorId', 'venueId', or 'bounds' must be provided.");const r=`${wr}?${i.toString()}`;return(await ct.getHttpSession()).request(r)}search(e){const i=new URLSearchParams;Object.entries(e).forEach(([n,s])=>{switch(n){case"bounds":Le(s)&&i.set("bbox",s.flat().join());break;case"center":J(s)&&i.set("center",s.join());break;case"excludedCategories":const o=N(s);o&&i.set("excludeCategories",o);break;case"floorIds":const a=N(s);a&&i.set("floorId",a);break;case"sharedFloorIds":const l=N(s);l&&i.set("sharedFloorId",l);break;default:i.set(n,String(s))}});const r=`${j}?${i.toString()}`;return this._filterPoiProperties(r,Y)}async _filterPoiProperties(e,i){const n=await(await ct.getHttpSession()).request(e),s=n.result.pois.map(i);return{...n,result:{...n.result,pois:s}}}}function Y(t){return"sharedFloorId"in t,Ue(t,ut)}const Zt=["opening_hours","description","phone","website","email","appURL","icon"],zr=D.getInstance();class Jt{constructor(){}searchByIds(e){const i=N(e);if(!i)throw new Error("Please input venue id at least one.");const r=`${ae}/${i}`;return this._filterVenueProperties(r,ue)}searchByDistance(e){const{center:i,distance:r,keywords:n="",offset:s=R,page:o=k}=e;if(!J(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!de(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",i.join(",")),a.set("distance",String(r)),a.set("offset",String(s)),a.set("page",String(o)),v(n)&&a.set("keywords",n);const l=`${ae}?${a.toString()}`;return this._filterVenueProperties(l,ue)}searchByBounds(e){const{keywords:i,bounds:r,offset:n=R,page:s=k}=e;if(!Le(r))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const o=new URLSearchParams;o.set("bbox",r.flat().join()),o.set("offset",String(n)),o.set("page",String(s)),v(i)&&o.set("keywords",i);const a=`${ae}?${o.toString()}`;return this._filterVenueProperties(a,ue)}searchByGlobal(e){const{keywords:i,offset:r=R,page:n=k}=e,s=new URLSearchParams;s.set("offset",String(r)),s.set("page",String(n)),v(i)&&s.set("keywords",i);const o=`${ae}?${s.toString()}`;return this._filterVenueProperties(o,ue)}searchBySharedFloorId(e){if(!v(e))throw new Error("Please input correct sharedFloorId.");const i=`${ae}/shared_floors/${e}`;return this._filterVenueProperties(i,ue)}search(e){const i=new URLSearchParams;Object.entries(e).forEach(([n,s])=>{n==="bounds"?i.set("bbox",s.flat().join()):n==="center"?i.set("center",s.join()):i.set(n,String(s))});const r=`${ae}?${i.toString()}`;return this._filterVenueProperties(r,ue)}async _filterVenueProperties(e,i){const n=await(await zr.getHttpSession()).request(e),s=n.result.venues.map(i);return{...n,result:{...n.result,venues:s}}}}function ue(t){return Ue(t,Zt)}const ei=["specialHours","businessStatus","serviceHours","keywords","siteCode","refPhotoId","totalPhotoCount","photos","description"],qr=D.getInstance();class ti{constructor(){}searchByIds(e){const i=N(e);if(!i)throw new Error("Please input building id at least one.");const r=`${le}/${i}`;return this._filterBuildingProperties(r,ce)}searchByDistance(e){const{center:i,distance:r,keywords:n="",offset:s=R,page:o=k}=e;if(!J(i))throw new Error("Invalid center parameter. Expected an array of two numbers.");if(!de(r)||r>1e4)throw new Error("Invalid distance parameter. Expected a positive number and no more than 10000.");const a=new URLSearchParams;a.set("center",i.join(",")),a.set("distance",String(r)),a.set("offset",String(s)),a.set("page",String(o)),v(n)&&a.set("keywords",n);const l=`${le}?${a.toString()}`;return this._filterBuildingProperties(l,ce)}searchByBounds(e){const{bounds:i,offset:r=R,page:n=k,keywords:s}=e;if(!Le(i))throw new Error("'bounds' must be an array of two arrays, each containing two numbers.");const o=new URLSearchParams;o.set("bbox",i.flat().join()),o.set("offset",String(r)),o.set("page",String(n)),v(s)&&o.set("keywords",s);const a=`${le}?${o.toString()}`;return this._filterBuildingProperties(a,ce)}searchByGlobal(e){const{keywords:i,offset:r=R,page:n=k}=e,s=new URLSearchParams;s.set("searchGlobal",String(!0)),s.set("offset",String(r)),s.set("page",String(n)),v(i)&&s.set("keywords",i);const o=`${le}?${s.toString()}`;return this._filterBuildingProperties(o,ce)}searchByFloorId(e){if(!v(e))throw new Error("'floorId' cannot be empty.");const i=`${le}/floors/${e}`;return this._filterBuildingProperties(i,ce)}search(e){const i=new URLSearchParams;Object.entries(e).forEach(([n,s])=>{n==="bounds"?i.set("bbox",s.flat().join()):n==="center"?i.set("center",s.join()):i.set(n,String(s))});const r=`${le}?${i.toString()}`;return this._filterBuildingProperties(r,ce)}async _filterBuildingProperties(e,i){const n=await(await qr.getHttpSession()).request(e),s=n.result.buildings.map(i);return{...n,result:{...n.result,buildings:s}}}}function ce(t){return Ue(t,ei)}const ii=new ti,ri=new Jt,Gr=new Qt;async function je(t){return(await ii.searchByIds(t)).result.buildings[0]}async function Kr(t){const i=(await ii.searchByFloorId(t)).result.buildings[0].buildingId;return await je(i)}async function Ve(t){return(await ri.searchByIds(t)).result.venues[0]}async function ni(t){return(await ri.searchBySharedFloorId(t)).result.venues[0]}async function Wr(t){return(await Gr.searchByIds([t])).result.pois[0]}class X{static instance;_visitedBuildingUnits;_historyBuildingUnit;_historyOrdinal;constructor(){this._visitedBuildingUnits=[],this._historyBuildingUnit=new Map,this._historyOrdinal=new Map}static getInstance(){return X.instance||(X.instance=new X),X.instance}getHistoryBuildingUnit(e){return this._historyBuildingUnit.get(e)}setHistoryBuildingUnit(e,i){this._historyBuildingUnit.set(e,i)}getHistoryOrdinal(e){return this._historyOrdinal.get(e)}setHistoryOrdinal(e,i){this._historyOrdinal.set(e,i)}getVisitedBuildingUnits(){return this._visitedBuildingUnits}addVisitedBuildingUnit(e){this._visitedBuildingUnits.push(e),this._visitedBuildingUnits.length>100&&(this._visitedBuildingUnits=this._visitedBuildingUnits.slice(this._visitedBuildingUnits.length-100))}}var si=typeof global=="object"&&global&&global.Object===Object&&global,Yr=typeof self=="object"&&self&&self.Object===Object&&self,U=si||Yr||Function("return this")(),Q=U.Symbol,oi=Object.prototype,Xr=oi.hasOwnProperty,Qr=oi.toString,we=Q?Q.toStringTag:void 0;function Zr(t){var e=Xr.call(t,we),i=t[we];try{t[we]=void 0;var r=!0}catch{}var n=Qr.call(t);return r&&(e?t[we]=i:delete t[we]),n}var Jr=Object.prototype,en=Jr.toString;function tn(t){return en.call(t)}var rn="[object Null]",nn="[object Undefined]",ai=Q?Q.toStringTag:void 0;function he(t){return t==null?t===void 0?nn:rn:ai&&ai in Object(t)?Zr(t):tn(t)}function _e(t){return t!=null&&typeof t=="object"}var sn="[object Symbol]";function Be(t){return typeof t=="symbol"||_e(t)&&he(t)==sn}function on(t,e,i){for(var r=-1,n=t.length;++r<n;){var s=t[r],o=e(s);if(o!=null&&(a===void 0?o===o&&!Be(o):i(o,a)))var a=o,l=s}return l}function an(){this.__data__=[],this.size=0}function li(t,e){return t===e||t!==t&&e!==e}function ze(t,e){for(var i=t.length;i--;)if(li(t[i][0],e))return i;return-1}var ln=Array.prototype,dn=ln.splice;function un(t){var e=this.__data__,i=ze(e,t);if(i<0)return!1;var r=e.length-1;return i==r?e.pop():dn.call(e,i,1),--this.size,!0}function cn(t){var e=this.__data__,i=ze(e,t);return i<0?void 0:e[i][1]}function hn(t){return ze(this.__data__,t)>-1}function _n(t,e){var i=this.__data__,r=ze(i,t);return r<0?(++this.size,i.push([t,e])):i[r][1]=e,this}function V(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}V.prototype.clear=an,V.prototype.delete=un,V.prototype.get=cn,V.prototype.has=hn,V.prototype.set=_n;function fn(){this.__data__=new V,this.size=0}function pn(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i}function gn(t){return this.__data__.get(t)}function yn(t){return this.__data__.has(t)}function fe(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var mn="[object AsyncFunction]",bn="[object Function]",Sn="[object GeneratorFunction]",vn="[object Proxy]";function di(t){if(!fe(t))return!1;var e=he(t);return e==bn||e==Sn||e==mn||e==vn}var ht=U["__core-js_shared__"],ui=(function(){var t=/[^.]+$/.exec(ht&&ht.keys&&ht.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function In(t){return!!ui&&ui in t}var Ln=Function.prototype,wn=Ln.toString;function ee(t){if(t!=null){try{return wn.call(t)}catch{}try{return t+""}catch{}}return""}var Bn=/[\\^$.*+?()[\]{}|]/g,En=/^\[object .+?Constructor\]$/,Pn=Function.prototype,Fn=Object.prototype,Cn=Pn.toString,On=Fn.hasOwnProperty,$n=RegExp("^"+Cn.call(On).replace(Bn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Mn(t){if(!fe(t)||In(t))return!1;var e=di(t)?$n:En;return e.test(ee(t))}function An(t,e){return t?.[e]}function pe(t,e){var i=An(t,e);return Mn(i)?i:void 0}var Ee=pe(U,"Map"),Pe=pe(Object,"create");function xn(){this.__data__=Pe?Pe(null):{},this.size=0}function Tn(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Rn="__lodash_hash_undefined__",kn=Object.prototype,Dn=kn.hasOwnProperty;function Hn(t){var e=this.__data__;if(Pe){var i=e[t];return i===Rn?void 0:i}return Dn.call(e,t)?e[t]:void 0}var Nn=Object.prototype,Un=Nn.hasOwnProperty;function jn(t){var e=this.__data__;return Pe?e[t]!==void 0:Un.call(e,t)}var Vn="__lodash_hash_undefined__";function zn(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Pe&&e===void 0?Vn:e,this}function te(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}te.prototype.clear=xn,te.prototype.delete=Tn,te.prototype.get=Hn,te.prototype.has=jn,te.prototype.set=zn;function qn(){this.size=0,this.__data__={hash:new te,map:new(Ee||V),string:new te}}function Gn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function qe(t,e){var i=t.__data__;return Gn(e)?i[typeof e=="string"?"string":"hash"]:i.map}function Kn(t){var e=qe(this,t).delete(t);return this.size-=e?1:0,e}function Wn(t){return qe(this,t).get(t)}function Yn(t){return qe(this,t).has(t)}function Xn(t,e){var i=qe(this,t),r=i.size;return i.set(t,e),this.size+=i.size==r?0:1,this}function z(t){var e=-1,i=t==null?0:t.length;for(this.clear();++e<i;){var r=t[e];this.set(r[0],r[1])}}z.prototype.clear=qn,z.prototype.delete=Kn,z.prototype.get=Wn,z.prototype.has=Yn,z.prototype.set=Xn;var Qn=200;function Zn(t,e){var i=this.__data__;if(i instanceof V){var r=i.__data__;if(!Ee||r.length<Qn-1)return r.push([t,e]),this.size=++i.size,this;i=this.__data__=new z(r)}return i.set(t,e),this.size=i.size,this}function q(t){var e=this.__data__=new V(t);this.size=e.size}q.prototype.clear=fn,q.prototype.delete=pn,q.prototype.get=gn,q.prototype.has=yn,q.prototype.set=Zn;var Jn="__lodash_hash_undefined__";function es(t){return this.__data__.set(t,Jn),this}function ts(t){return this.__data__.has(t)}function Fe(t){var e=-1,i=t==null?0:t.length;for(this.__data__=new z;++e<i;)this.add(t[e])}Fe.prototype.add=Fe.prototype.push=es,Fe.prototype.has=ts;function is(t,e){for(var i=-1,r=t==null?0:t.length;++i<r;)if(e(t[i],i,t))return!0;return!1}function ci(t,e){return t.has(e)}var rs=1,ns=2;function hi(t,e,i,r,n,s){var o=i&rs,a=t.length,l=e.length;if(a!=l&&!(o&&l>a))return!1;var d=s.get(t),u=s.get(e);if(d&&u)return d==e&&u==t;var c=-1,h=!0,f=i&ns?new Fe:void 0;for(s.set(t,e),s.set(e,t);++c<a;){var g=t[c],_=e[c];if(r)var y=o?r(_,g,c,e,t,s):r(g,_,c,t,e,s);if(y!==void 0){if(y)continue;h=!1;break}if(f){if(!is(e,function(m,S){if(!ci(f,S)&&(g===m||n(g,m,i,r,s)))return f.push(S)})){h=!1;break}}else if(!(g===_||n(g,_,i,r,s))){h=!1;break}}return s.delete(t),s.delete(e),h}var _i=U.Uint8Array;function ss(t){var e=-1,i=Array(t.size);return t.forEach(function(r,n){i[++e]=[n,r]}),i}function _t(t){var e=-1,i=Array(t.size);return t.forEach(function(r){i[++e]=r}),i}var os=1,as=2,ls="[object Boolean]",ds="[object Date]",us="[object Error]",cs="[object Map]",hs="[object Number]",_s="[object RegExp]",fs="[object Set]",ps="[object String]",gs="[object Symbol]",ys="[object ArrayBuffer]",ms="[object DataView]",fi=Q?Q.prototype:void 0,ft=fi?fi.valueOf:void 0;function bs(t,e,i,r,n,s,o){switch(i){case ms:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case ys:return!(t.byteLength!=e.byteLength||!s(new _i(t),new _i(e)));case ls:case ds:case hs:return li(+t,+e);case us:return t.name==e.name&&t.message==e.message;case _s:case ps:return t==e+"";case cs:var a=ss;case fs:var l=r&os;if(a||(a=_t),t.size!=e.size&&!l)return!1;var d=o.get(t);if(d)return d==e;r|=as,o.set(t,e);var u=hi(a(t),a(e),r,n,s,o);return o.delete(t),u;case gs:if(ft)return ft.call(t)==ft.call(e)}return!1}function Ss(t,e){for(var i=-1,r=e.length,n=t.length;++i<r;)t[n+i]=e[i];return t}var G=Array.isArray;function vs(t,e,i){var r=e(t);return G(t)?r:Ss(r,i(t))}function Is(t,e){for(var i=-1,r=t==null?0:t.length,n=0,s=[];++i<r;){var o=t[i];e(o,i,t)&&(s[n++]=o)}return s}function Ls(){return[]}var ws=Object.prototype,Bs=ws.propertyIsEnumerable,pi=Object.getOwnPropertySymbols,Es=pi?function(t){return t==null?[]:(t=Object(t),Is(pi(t),function(e){return Bs.call(t,e)}))}:Ls;function Ps(t,e){for(var i=-1,r=Array(t);++i<t;)r[i]=e(i);return r}var Fs="[object Arguments]";function gi(t){return _e(t)&&he(t)==Fs}var yi=Object.prototype,Cs=yi.hasOwnProperty,Os=yi.propertyIsEnumerable,mi=gi((function(){return arguments})())?gi:function(t){return _e(t)&&Cs.call(t,"callee")&&!Os.call(t,"callee")};function $s(){return!1}var bi=typeof p=="object"&&p&&!p.nodeType&&p,Si=bi&&typeof module=="object"&&module&&!module.nodeType&&module,Ms=Si&&Si.exports===bi,vi=Ms?U.Buffer:void 0,As=vi?vi.isBuffer:void 0,pt=As||$s,xs=9007199254740991,Ts=/^(?:0|[1-9]\d*)$/;function Ii(t,e){var i=typeof t;return e=e??xs,!!e&&(i=="number"||i!="symbol"&&Ts.test(t))&&t>-1&&t%1==0&&t<e}var Rs=9007199254740991;function gt(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Rs}var ks="[object Arguments]",Ds="[object Array]",Hs="[object Boolean]",Ns="[object Date]",Us="[object Error]",js="[object Function]",Vs="[object Map]",zs="[object Number]",qs="[object Object]",Gs="[object RegExp]",Ks="[object Set]",Ws="[object String]",Ys="[object WeakMap]",Xs="[object ArrayBuffer]",Qs="[object DataView]",Zs="[object Float32Array]",Js="[object Float64Array]",eo="[object Int8Array]",to="[object Int16Array]",io="[object Int32Array]",ro="[object Uint8Array]",no="[object Uint8ClampedArray]",so="[object Uint16Array]",oo="[object Uint32Array]",I={};I[Zs]=I[Js]=I[eo]=I[to]=I[io]=I[ro]=I[no]=I[so]=I[oo]=!0,I[ks]=I[Ds]=I[Xs]=I[Hs]=I[Qs]=I[Ns]=I[Us]=I[js]=I[Vs]=I[zs]=I[qs]=I[Gs]=I[Ks]=I[Ws]=I[Ys]=!1;function ao(t){return _e(t)&&gt(t.length)&&!!I[he(t)]}function lo(t){return function(e){return t(e)}}var Li=typeof p=="object"&&p&&!p.nodeType&&p,Ce=Li&&typeof module=="object"&&module&&!module.nodeType&&module,uo=Ce&&Ce.exports===Li,yt=uo&&si.process,wi=(function(){try{var t=Ce&&Ce.require&&Ce.require("util").types;return t||yt&&yt.binding&&yt.binding("util")}catch{}})(),Bi=wi&&wi.isTypedArray,Ei=Bi?lo(Bi):ao,co=Object.prototype,ho=co.hasOwnProperty;function _o(t,e){var i=G(t),r=!i&&mi(t),n=!i&&!r&&pt(t),s=!i&&!r&&!n&&Ei(t),o=i||r||n||s,a=o?Ps(t.length,String):[],l=a.length;for(var d in t)ho.call(t,d)&&!(o&&(d=="length"||n&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||Ii(d,l)))&&a.push(d);return a}var fo=Object.prototype;function po(t){var e=t&&t.constructor,i=typeof e=="function"&&e.prototype||fo;return t===i}function go(t,e){return function(i){return t(e(i))}}var yo=go(Object.keys,Object),mo=Object.prototype,bo=mo.hasOwnProperty;function So(t){if(!po(t))return yo(t);var e=[];for(var i in Object(t))bo.call(t,i)&&i!="constructor"&&e.push(i);return e}function vo(t){return t!=null&&gt(t.length)&&!di(t)}function Pi(t){return vo(t)?_o(t):So(t)}function Fi(t){return vs(t,Pi,Es)}var Io=1,Lo=Object.prototype,wo=Lo.hasOwnProperty;function Bo(t,e,i,r,n,s){var o=i&Io,a=Fi(t),l=a.length,d=Fi(e),u=d.length;if(l!=u&&!o)return!1;for(var c=l;c--;){var h=a[c];if(!(o?h in e:wo.call(e,h)))return!1}var f=s.get(t),g=s.get(e);if(f&&g)return f==e&&g==t;var _=!0;s.set(t,e),s.set(e,t);for(var y=o;++c<l;){h=a[c];var m=t[h],S=e[h];if(r)var E=o?r(S,m,h,e,t,s):r(m,S,h,t,e,s);if(!(E===void 0?m===S||n(m,S,i,r,s):E)){_=!1;break}y||(y=h=="constructor")}if(_&&!y){var C=t.constructor,B=e.constructor;C!=B&&"constructor"in t&&"constructor"in e&&!(typeof C=="function"&&C instanceof C&&typeof B=="function"&&B instanceof B)&&(_=!1)}return s.delete(t),s.delete(e),_}var mt=pe(U,"DataView"),bt=pe(U,"Promise"),ge=pe(U,"Set"),St=pe(U,"WeakMap"),Ci="[object Map]",Eo="[object Object]",Oi="[object Promise]",$i="[object Set]",Mi="[object WeakMap]",Ai="[object DataView]",Po=ee(mt),Fo=ee(Ee),Co=ee(bt),Oo=ee(ge),$o=ee(St),Z=he;(mt&&Z(new mt(new ArrayBuffer(1)))!=Ai||Ee&&Z(new Ee)!=Ci||bt&&Z(bt.resolve())!=Oi||ge&&Z(new ge)!=$i||St&&Z(new St)!=Mi)&&(Z=function(t){var e=he(t),i=e==Eo?t.constructor:void 0,r=i?ee(i):"";if(r)switch(r){case Po:return Ai;case Fo:return Ci;case Co:return Oi;case Oo:return $i;case $o:return Mi}return e});var Mo=1,xi="[object Arguments]",Ti="[object Array]",Ge="[object Object]",Ao=Object.prototype,Ri=Ao.hasOwnProperty;function xo(t,e,i,r,n,s){var o=G(t),a=G(e),l=o?Ti:Z(t),d=a?Ti:Z(e);l=l==xi?Ge:l,d=d==xi?Ge:d;var u=l==Ge,c=d==Ge,h=l==d;if(h&&pt(t)){if(!pt(e))return!1;o=!0,u=!1}if(h&&!u)return s||(s=new q),o||Ei(t)?hi(t,e,i,r,n,s):bs(t,e,l,i,r,n,s);if(!(i&Mo)){var f=u&&Ri.call(t,"__wrapped__"),g=c&&Ri.call(e,"__wrapped__");if(f||g){var _=f?t.value():t,y=g?e.value():e;return s||(s=new q),n(_,y,i,r,s)}}return h?(s||(s=new q),Bo(t,e,i,r,n,s)):!1}function vt(t,e,i,r,n){return t===e?!0:t==null||e==null||!_e(t)&&!_e(e)?t!==t&&e!==e:xo(t,e,i,r,vt,n)}var To=1,Ro=2;function ko(t,e,i,r){var n=i.length,s=n;if(t==null)return!s;for(t=Object(t);n--;){var o=i[n];if(o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++n<s;){o=i[n];var a=o[0],l=t[a],d=o[1];if(o[2]){if(l===void 0&&!(a in t))return!1}else{var u=new q,c;if(!(c===void 0?vt(d,l,To|Ro,r,u):c))return!1}}return!0}function ki(t){return t===t&&!fe(t)}function Do(t){for(var e=Pi(t),i=e.length;i--;){var r=e[i],n=t[r];e[i]=[r,n,ki(n)]}return e}function Di(t,e){return function(i){return i==null?!1:i[t]===e&&(e!==void 0||t in Object(i))}}function Ho(t){var e=Do(t);return e.length==1&&e[0][2]?Di(e[0][0],e[0][1]):function(i){return i===t||ko(i,t,e)}}var No=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Uo=/^\w*$/;function It(t,e){if(G(t))return!1;var i=typeof t;return i=="number"||i=="symbol"||i=="boolean"||t==null||Be(t)?!0:Uo.test(t)||!No.test(t)||e!=null&&t in Object(e)}var jo="Expected a function";function Lt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(jo);var i=function(){var r=arguments,n=e?e.apply(this,r):r[0],s=i.cache;if(s.has(n))return s.get(n);var o=t.apply(this,r);return i.cache=s.set(n,o)||s,o};return i.cache=new(Lt.Cache||z),i}Lt.Cache=z;var Vo=500;function zo(t){var e=Lt(t,function(r){return i.size===Vo&&i.clear(),r}),i=e.cache;return e}var qo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Go=/\\(\\)?/g,Ko=zo(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(qo,function(i,r,n,s){e.push(n?s.replace(Go,"$1"):r||i)}),e});function Wo(t,e){for(var i=-1,r=t==null?0:t.length,n=Array(r);++i<r;)n[i]=e(t[i],i,t);return n}var Hi=Q?Q.prototype:void 0,Ni=Hi?Hi.toString:void 0;function Ui(t){if(typeof t=="string")return t;if(G(t))return Wo(t,Ui)+"";if(Be(t))return Ni?Ni.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function ji(t){return t==null?"":Ui(t)}function Vi(t,e){return G(t)?t:It(t,e)?[t]:Ko(ji(t))}function Ke(t){if(typeof t=="string"||Be(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function zi(t,e){e=Vi(e,t);for(var i=0,r=e.length;t!=null&&i<r;)t=t[Ke(e[i++])];return i&&i==r?t:void 0}function Yo(t,e,i){var r=t==null?void 0:zi(t,e);return r===void 0?i:r}function Xo(t,e){return t!=null&&e in Object(t)}function Qo(t,e,i){e=Vi(e,t);for(var r=-1,n=e.length,s=!1;++r<n;){var o=Ke(e[r]);if(!(s=t!=null&&i(t,o)))break;t=t[o]}return s||++r!=n?s:(n=t==null?0:t.length,!!n&&gt(n)&&Ii(o,n)&&(G(t)||mi(t)))}function Zo(t,e){return t!=null&&Qo(t,e,Xo)}var Jo=1,ea=2;function ta(t,e){return It(t)&&ki(e)?Di(Ke(t),e):function(i){var r=Yo(i,t);return r===void 0&&r===e?Zo(i,t):vt(e,r,Jo|ea)}}function ia(t){return t}function ra(t){return function(e){return e?.[t]}}function na(t){return function(e){return zi(e,t)}}function sa(t){return It(t)?ra(Ke(t)):na(t)}function qi(t){return typeof t=="function"?t:t==null?ia:typeof t=="object"?G(t)?ta(t[0],t[1]):Ho(t):sa(t)}function oa(t,e){return t<e}function aa(t,e){return t&&t.length?on(t,qi(e),oa):void 0}class la{_isMaskMode;_hiddenBuildings;_history;constructor(e){this._isMaskMode=e,this._hiddenBuildings=[],this._history=X.getInstance()}getLayeredData(e){const{selectedVenueId:i,venueMap:r,buildingMap:n,sharedFloorMap:s}=e,o=[],a=[],l=[],d=[],u=[],c=[],h=[...r.values()],f=i?[r.get(i),...h.filter(g=>g.properties.id!==i)]:h;for(const g of f){if(!g||!g.properties)continue;const{id:_,overlap:y,building_ids:m,shared_level_ids:S,default_displayed_ordinal:E,default_displayed_building:C}=g.properties,B=_===i,b=ca(y),O=w(m),M=this._history.getHistoryOrdinal(_);let P=M??E;if(P)M||(this._history.setHistoryOrdinal(_,P),this._history.setHistoryBuildingUnit(_,{id:C,type:"building"}));else{const{ordinal:L,buildingId:H}=da(O,n);if(!L)continue;P=L,this._history.setHistoryOrdinal(_,P),this._history.setHistoryBuildingUnit(_,{id:H,type:"building"})}O.forEach(L=>{const H=n.get(L),A=ua(H,P);A?this._isMaskMode?B?(a.push(A),o.push({level:A,overlap:b.get(A)??null,venueId:_})):u.push(L):(o.push({level:A,overlap:b.get(A)??null,venueId:_}),B&&a.push(A)):d.push(L)}),w(S).forEach(L=>{const H=s.get(L),{ordinal:A,persistence:W}=H?.properties||{},oe=W==="true"&&0<=A&&A<=P,be=A===P,it=oe||be,xe={level:L,overlap:b.get(L)??null,venueId:_};it?this._isMaskMode?B?(o.push(xe),oe&&l.push(L),be&&a.push(L)):c.push(L):(o.push(xe),B&&be&&a.push(L),oe&&l.push(L)):d.push(L)})}return this._hiddenBuildings=d,{displayedLevels:o,selectedLevelIds:a,alwaysDisplayedSharedLevelIds:l,maskBuildingIds:u,maskSharedFloorIds:c}}getHiddenBuildings(){return this._hiddenBuildings}}function da(t,e){const i=t.find(s=>e.has(s))??t[0]??null,r=i?e.get(i):null;return{ordinal:r?Gi(r):null,buildingId:i}}function Gi(t){if(!t||!t.properties)return null;const{level_ids:e,ordinals:i,default_displayed_floor:r}=t.properties,n=w(i);let s=null;if(r){const o=w(e).findIndex(a=>a===r);s=n[o]??null}return s||(s=aa(n,o=>Math.abs(Number(o)-.1))),s}function ua(t,e){if(!t||!t.properties)return null;const{level_ids:i,ordinals:r}=t.properties,n=w(r).findIndex(s=>s===e);return w(i)[n]??null}function ca(t){const e=new Map;if(!t)return e;for(const i of w(t,"/")){const[r,n]=w(i,":");e.set(r,w(n))}return e}class ha{_maplibre;_isAnimated=!0;_bounds=null;_boundsPadding;_center=null;_fitBoundsTimer=null;constructor(e,i){this._maplibre=e,this._boundsPadding=i}setAnimated(e){this._isAnimated=e}setBounds(e){this._bounds=e}getBounds(){return this._bounds}setCenter(e){this._center=e}async fitBounds(){if(!this._bounds)return;this._fitBoundsTimer&&(clearTimeout(this._fitBoundsTimer),this._fitBoundsTimer=null);const e=this._isAnimated?{animate:!0,duration:500}:{animate:!1},i=this._isAnimated?500:0;return new Promise(r=>{const n=()=>{this._maplibre.off("idle",n),r(!0)};this._maplibre.on("idle",n),this._maplibre.fitBounds(this._bounds,{...e,padding:this._boundsPadding,bearing:this._maplibre.getBearing()}),this._fitBoundsTimer=setTimeout(()=>{this._maplibre.off("idle",n),this._fitBoundsTimer=null,r(!0)},i+200)})}panToCenter(){this._center&&this._maplibre.panTo(this._center,{animate:this._isAnimated})}}var wt=function(){return U.Date.now()},_a=/\s/;function fa(t){for(var e=t.length;e--&&_a.test(t.charAt(e)););return e}var pa=/^\s+/;function ga(t){return t&&t.slice(0,fa(t)+1).replace(pa,"")}var Ki=NaN,ya=/^[-+]0x[0-9a-f]+$/i,ma=/^0b[01]+$/i,ba=/^0o[0-7]+$/i,Sa=parseInt;function We(t){if(typeof t=="number")return t;if(Be(t))return Ki;if(fe(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=fe(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=ga(t);var i=ma.test(t);return i||ba.test(t)?Sa(t.slice(2),i?2:8):ya.test(t)?Ki:+t}var va="Expected a function",Ia=Math.max,La=Math.min;function Wi(t,e,i){var r,n,s,o,a,l,d=0,u=!1,c=!1,h=!0;if(typeof t!="function")throw new TypeError(va);e=We(e)||0,fe(i)&&(u=!!i.leading,c="maxWait"in i,s=c?Ia(We(i.maxWait)||0,e):s,h="trailing"in i?!!i.trailing:h);function f(b){var O=r,M=n;return r=n=void 0,d=b,o=t.apply(M,O),o}function g(b){return d=b,a=setTimeout(m,e),u?f(b):o}function _(b){var O=b-l,M=b-d,P=e-O;return c?La(P,s-M):P}function y(b){var O=b-l,M=b-d;return l===void 0||O>=e||O<0||c&&M>=s}function m(){var b=wt();if(y(b))return S(b);a=setTimeout(m,_(b))}function S(b){return a=void 0,h&&r?f(b):(r=n=void 0,o)}function E(){a!==void 0&&clearTimeout(a),d=0,r=l=n=a=void 0}function C(){return a===void 0?o:S(wt())}function B(){var b=wt(),O=y(b);if(r=arguments,n=this,l=b,O){if(a===void 0)return g(l);if(c)return clearTimeout(a),a=setTimeout(m,e),f(l)}return a===void 0&&(a=setTimeout(m,e)),o}return B.cancel=E,B.flush=C,B}function wa(t,e,i,r){for(var n=t.length,s=i+-1;++s<n;)if(e(t[s],s,t))return s;return-1}function Ba(t){return t!==t}function Ea(t,e,i){for(var r=i-1,n=t.length;++r<n;)if(t[r]===e)return r;return-1}function Pa(t,e,i){return e===e?Ea(t,e,i):wa(t,Ba,i)}function Fa(t,e){var i=t==null?0:t.length;return!!i&&Pa(t,e,0)>-1}function Ca(){}var Oa=1/0,$a=ge&&1/_t(new ge([,-0]))[1]==Oa?function(t){return new ge(t)}:Ca,Ma=200;function Aa(t,e,i){var r=-1,n=Fa,s=t.length,o=!0,a=[],l=a;if(s>=Ma){var d=e?null:$a(t);if(d)return _t(d);o=!1,n=ci,l=new Fe}else l=e?[]:a;e:for(;++r<s;){var u=t[r],c=e?e(u):u;if(u=u!==0?u:0,o&&c===c){for(var h=l.length;h--;)if(l[h]===c)continue e;e&&l.push(c),a.push(u)}else n(l,c,i)||(l!==a&&l.push(c),a.push(u))}return a}function Yi(t,e){return t&&t.length?Aa(t,qi(e)):[]}var xa=0;function ie(t){var e=++xa;return ji(t)+e}const Oe="Indoor_selectedFloorChanged",Ye="Indoor_selectedBuildingChanged",Bt="Indoor_mapxusMapLoaded",Xi="Indoor_maplibreMapLoaded",Xe="mapxus-venue-fill",re="mapxus-building-line",Qi="mapxus-level-fill",Et="mapxus-shared-level-fill",Pt="highlight-mapxus_level",Ft="highlight-mapxus_shared_level";class Zi extends Fr.TinyEmitter{_map;_features=[];_allVenuesMap=new Map;_allBuildingsMap=new Map;_allSharedLevelsMap=new Map;_curBuildingId=null;_curBuildingFeature=null;_curSharedLevelId=null;_floor={code:null,id:null,ordinal:null};_sharedFloor={id:null,ordinal:null,name:null};_outdoorMapShown;_originIndoorLayers=[];_outdoorLayers=[];_curVenueId=null;_curVenueFeature=null;_selectedHighlightStyle;_upperLayers=[];_commonPoiLayers=[];_sectionFillLineLayers=[];_sectionSymbolLayers=[];_middleLayers=[];_lowerLayers=[];_excludedPoisInMiddle=[];_dispatch=Se(Oe);_startWithIndoorView;_indoorMapLoaded=!1;_isSelectSharedFloor=!1;_isMaskMode;_upperLevels=new Set;_middleLevels=new Set;_lowerLevels=new Set;_featureIncomplete=!1;_fitBounds;_dragPan;_history=X.getInstance();_maskBuildings=new Set;_maskSharedFloors=new Set;_enableIndoorClickSelection;_enableOutdoorClickSelection;_zIndexHistory=new Map;_floorSwitchScope;_isDestroyed=!1;_abortQueryFeature;_debounceRendering;layeredHandler;dragPanHandler;constructor(e){super();const{map:i,startWithIndoorView:r,outdoorMapShown:n,selectedHighlightStyle:s,fitBounds:o,boundsPadding:a,maskNonSelectedAreas:l,enableIndoorClickSelection:d,enableOutdoorClickSelection:u,floorSwitchScope:c}=e;this.layeredHandler=new la(l),this.dragPanHandler=new ha(i,a),this._map=i,this._enableIndoorClickSelection=d,this._enableOutdoorClickSelection=u,this._startWithIndoorView=r,this._outdoorMapShown=n,this._isMaskMode=l,this._fitBounds=o,this._floorSwitchScope=c,this._selectedHighlightStyle=s?Object.assign({},Ne,s):Ne,this._bindMaplibreEventListeners()}destroy(){this._isDestroyed||(this._isDestroyed=!0,this._dispatch.on(`.${Oe}`,null),this.off(Ye),this.off(Xi),this.off(Bt),this._debounceRendering?.cancel(),this._abortQueryFeature&&(this._abortQueryFeature(),this._abortQueryFeature=null))}setAllowOutdoorSwitch(e){return this._enableOutdoorClickSelection=e,this}setAllowBuildingSwitch(e){return this._enableIndoorClickSelection=e,this}setAllowIndoorClickSelect(e){this._enableIndoorClickSelection=e}setAllowOutdoorClickSelect(e){this._enableOutdoorClickSelection=e}setFloorSwitchScope(e){this._floorSwitchScope=e}get floor(){return this._isSelectSharedFloor?this._sharedFloor:this._curBuildingId?this._floor:null}get building(){return this._curBuildingFeature}get venue(){return this._curVenueFeature}get features(){return this._features}getFeaturesById(e,i){const{layerIds:r,filter:n}=i||{},s=this._queryRenderedFeatures(r);if(!s.length)return[];const o=n?a=>a.properties.id===e&&n(a):a=>a.properties.id===e;return s.filter(o)}async switchFloorByOrdinal(e){this._updateFloorState(e),this._dispatch.call(Oe,null,{venue:this.venue,building:this.building,floor:this.floor}),this.venue&&e&&(this._floorSwitchScope===De.GLOBAL&&this._changeOtherVenuesHistory(e),this._dragPan===!0&&(this._fitBounds?await this.dragPanHandler.fitBounds():await this.panToBuildingCenter()),this._dragPan==="restrict"&&await this._checkAndPanToBuilding()),this.updateRendering()}setOutdoorMapShown(e){this._outdoorMapShown=e,this._setOutdoorVisibility(e)}setSelectedHighlightStyle(e){this._selectedHighlightStyle=Object.assign({},this._selectedHighlightStyle,e??{"line-opacity":0});for(const i of[Pt,Ft])if(this._map.getLayer(i))if(e){const{lineColor:r,lineOpacity:n,lineWidth:s,lineOffset:o}=this._selectedHighlightStyle,a=Ji(s,o);this._map.setPaintProperty(i,"line-color",r),this._map.setPaintProperty(i,"line-opacity",n),this._map.setPaintProperty(i,"line-width",s),this._map.setPaintProperty(i,"line-offset",a)}else this._map.setPaintProperty(i,"line-opacity",0)}onMapChange(e){const i=ie(`${Oe}.`);return this._dispatch.on(i,e),{unsubscribe:()=>this._dispatch.on(i,null)}}async selectBuilding(e,i){if(this._isCurrentFeature(e))return;this._isSelectSharedFloor=!1,this._curSharedLevelId=null;let r=null;if(!e||!e.properties)this.dragPanHandler.setCenter(null),this._clear();else{const{floorId:n,featureIncomplete:s}=i||{};this._featureIncomplete=s??this._featureIncomplete;const{id:o,"ref:venue":a,label_center:l}=e.properties,d=w(l).map(u=>parseFloat(u));this._curBuildingFeature=e,this._curBuildingId=o,this._history.addVisitedBuildingUnit({id:o,type:"building"}),this.dragPanHandler.setCenter(d),this._curVenueId!==a&&(this._curVenueId=a,this._curVenueFeature=await this._queryVenueFeature(a)),r=this._getBuildingDisplayedOrdinal(e,n)}await this.switchFloorByOrdinal(r),this.emit(Ye,e?{building:e,ordinal:r,dragPan:this._dragPan}:null),this._dispatchIndoorMapLoaded()}async selectSharedFloor(e,i,r){if(e.id===this._curSharedLevelId)return;const{id:n,ordinal:s}=e;this._isSelectSharedFloor=!0,this._curBuildingId=null,this._curBuildingFeature=null,this._sharedFloor=e,this._curSharedLevelId=n,this._featureIncomplete=r?.featureIncomplete??this._featureIncomplete;const{label_center:o,id:a}=i.properties,l=w(o).map(d=>parseFloat(d));this._curVenueId=a,this._curVenueFeature=i,this.dragPanHandler.setCenter(l),this._history.addVisitedBuildingUnit({id:n,type:"sharedFloor"}),this._history.setHistoryOrdinal(a,s),this._history.setHistoryBuildingUnit(a,{id:n,type:"sharedFloor"}),this._dragPan===!0&&(this._fitBounds?await this.dragPanHandler.fitBounds():await this.panToVenueCenter()),this._dispatch.call(Oe,null,{venue:this.venue,building:this.building,floor:this.floor}),this.emit(Ye,{...e,dragPan:this._dragPan}),this._dispatchIndoorMapLoaded(),this.updateRendering()}updateCustomLayers(){const e=this._map.getStyle();this._originIndoorLayers=ot(e),this._outdoorLayers=Cr(e),this._copyOverlapLayers(),this._copySharedFloorBackgroundLayers(),this._addSelectedHighlightLayers(),this._addReserveFloorLayers(),this._isMaskMode&&this._addBuildingMaskLayer(),this._outdoorMapShown||this._setOutdoorVisibility(!1)}updateRendering(){this._updateFeatures(),this._updateSelectedFeatures(),this._layerFloors(),this._calExcludedPoisInMiddle(),this._filterLayers(),this._filterSelectedHighlight(),this._updateUnselectedMask()}async panToBuildingCenter(){if(this.dragPanHandler.panToCenter(),this._featureIncomplete){const e=()=>this.getFeaturesById(this._curBuildingId,{layerIds:[re]})[0];await this._waitForFeatureLoaded(e)}}async panToVenueCenter(){if(this.dragPanHandler.panToCenter(),this._featureIncomplete){const e=()=>this.getFeaturesById(this._curVenueId,{layerIds:[Xe]})[0];await this._waitForFeatureLoaded(e)}}async _waitForFeatureLoaded(e){const i=()=>this._isDestroyed?(this._abortQueryFeature?.(),!0):!!e(),{promise:r,abort:n}=Vr(i);this._abortQueryFeature=n;try{await Promise.race([r,new Promise((s,o)=>{this._abortQueryFeature=()=>{o(new Error("Aborted")),this._abortQueryFeature=null}})])}catch(s){console.warn(s);return}}setDragPan(e){this._dragPan=e}setFitBounds(e){this._fitBounds=e}async queryIndoorFeaturesByClickPoint(e){const i=this._queryVisibleFeature(e);if(!i)return null;const r=async s=>{let o=this.getFeaturesById(s,{layerIds:[Xe]})[0];if(!o){const a=await Ve(s);o=He(a),this._featureIncomplete=!0}return o??null},n=async s=>{let o=this.getFeaturesById(s,{layerIds:[re]})[0];if(!o){const a=await je(s);o=lt(a),this._featureIncomplete=!0}return o??null};if(Qe(i.sourceLayer,i.layer.type)){const{id:s,"ref:building":o,name:a,ordinal:l}=i.properties,d=await n(o);if(d){const u=d.properties["ref:venue"];return{venue:await r(u),building:d,floor:{id:s,code:a,ordinal:l}}}}else if(tr(i.sourceLayer,i.layer.type)){const{id:s,ordinal:o,name:a,"ref:venue":l}=i.properties;return{sharedFloor:{id:s,ordinal:o,name:typeof a=="string"?{default:a}:a},venue:await r(l)}}else{const s=i?.properties?.["ref:venue"];return i?{building:i,venue:await r(s)}:null}}async selectByClickMap(e){!this._enableIndoorClickSelection&&!this._enableOutdoorClickSelection||(this.setDragPan(!1),this.dragPanHandler.setBounds(null),this._featureIncomplete=!1,e?this._enableIndoorClickSelection&&("building"in e?await this.selectBuilding(e.building,{floorId:e?.floor?.id}):"sharedFloor"in e&&await this.selectSharedFloor(e.sharedFloor,e.venue)):this._enableOutdoorClickSelection&&await this.selectBuilding(null))}_bindMaplibreEventListeners(){this._map.once("styledata",()=>this.updateCustomLayers()),this._map.once("idle",()=>{this.emit(Xi),(!this._startWithIndoorView||this._map.getZoom()<14)&&this._dispatchIndoorMapLoaded()}),this._map.on("sourcedata",this._debounceRendering=Wi(()=>this.updateRendering(),300))}_clear(){this._curBuildingFeature=null,this._curBuildingId=null,this._floor={code:null,id:null,ordinal:null},this._curVenueId=null,this._curVenueFeature=null,this._curSharedLevelId=null}_getIndoorFeatures(){return this._queryRenderedFeatures().filter(e=>at(e.source))}_getBuildingFloorByOrdinal(e,i){let r=null,n=null;if(e?.properties){const{ordinals:s,level_names:o,level_ids:a}=e.properties,l=w(s).findIndex(d=>d===i);r=w(o)[l]??null,n=w(a)[l]??null}return{code:r,id:n,ordinal:i}}_isCurrentFeature(e){const i=e?.properties?.id??null,r=this._isSelectSharedFloor?this._curSharedLevelId:this._curBuildingId;return i===r}_setOutdoorVisibility(e){for(const{id:i}of this._outdoorLayers)this._map.getLayer(i)&&this._map.setLayoutProperty(i,"visibility",e?"visible":"none")}_addReserveFloorLayers(){for(const e of[ve,T]){if(this._map.getLayer(e))continue;const i=e.split("_")[1],r=this._map.getLayer(i);if(!r)continue;const{source:n,sourceLayer:s}=r,o=e===ve?this._middleLayers[0]:this._lowerLayers[0];let a={"fill-opacity":0};if(this._isMaskMode&&e===T){const l=this._originIndoorLayers.find(({id:d})=>d===re);l&&(a=Object.assign({},l.paint??{},a))}this._map.addLayer({id:e,source:n,"source-layer":s,type:"fill",paint:a},o.id)}}_addBuildingMaskLayer(){if(this._map.getLayer(Ie))return;const e=this._originIndoorLayers.find(({id:i})=>i===re);if(e){const i=Object.assign({},e,{id:Ie,layout:Object.assign({},e.layout??{},{visibility:"visible"}),paint:Object.assign({},e.paint??{},{"fill-opacity":0})});this._map.addLayer(i,re)}}_updateUnselectedMask(){if(!this._isMaskMode)return;const e=[...this._maskBuildings],i=[...this._maskSharedFloors];this._map.getLayer(Ie)&&this._map.setPaintProperty(Ie,"fill-opacity",["case",["in",["get","id"],["literal",e]],1,0]),this._map.getLayer(T)&&this._map.setPaintProperty(T,"fill-opacity",["case",["in",["get","id"],["literal",i]],1,0])}_addSelectedHighlightLayers(){const e=[{layerId:Pt,sourceLayer:"mapxus_level"},{layerId:Ft,sourceLayer:"mapxus_shared_level"}];let i=this._originIndoorLayers.find(({type:r})=>Ot(r));if(!i){const r=this._originIndoorLayers.findIndex(({id:n})=>n===this._upperLayers[this._upperLayers.length-1].id);i=this._originIndoorLayers[r+1]}for(const{layerId:r,sourceLayer:n}of e){if(this._map.getLayer(r))continue;const{lineWidth:s,lineOpacity:o,lineColor:a,lineOffset:l}=this._selectedHighlightStyle,d=Ji(s,l);this._map.addLayer({id:r,source:"indoor-planet","source-layer":n,type:"line",filter:["==","id",""],paint:{"line-offset":d,"line-width":s,"line-color":a,"line-opacity":o}},i?.id)}}_filterSelectedHighlight(){for(const e of[Pt,Ft])this._map.getLayer(e)&&this._map.setFilter(e,["==","id",this._isSelectSharedFloor?this._curSharedLevelId:this._floor.id??""])}_copyOverlapLayers(){const e=this._originIndoorLayers.findIndex(({type:a,"source-layer":l})=>er(l,a)),i=this._originIndoorLayers.findIndex(({type:a,"source-layer":l})=>Ct(l,a)),r=this._originIndoorLayers.slice(e,i);this._upperLayers=r.filter(({type:a})=>Ra(a));const n=this._originIndoorLayers.slice(i),s=n.findIndex(({type:a,"source-layer":l})=>!Ct(l,a));if(s>-1){this._commonPoiLayers=n.slice(0,s);const a=n.slice(s).filter(({"source-layer":l})=>l==="mapxus_section");this._sectionFillLineLayers=a.filter(({type:l})=>l!=="symbol"),this._sectionSymbolLayers=a.filter(({type:l})=>l==="symbol")}else this._commonPoiLayers=[...n],this._sectionSymbolLayers=r.filter(({type:a,"source-layer":l})=>l==="mapxus_section"&&a==="symbol");const o=this._upperLayers[0];this._middleLayers=this._upperLayers.filter(({type:a})=>!Ot(a)).map(a=>{const l=`${a.id}-overlap-copy`;let d=this._map.getLayer(l);return d||(d=Object.assign({},a,{id:l}),this._map.addLayer(d,o.id)),d})}_copySharedFloorBackgroundLayers(){if(!!!this._upperLayers.find(n=>n.id===T.split("_")[1]))return;const i=this._upperLayers.filter(({"source-layer":n,type:s})=>!Qe(n,s)&&!Ot(s)),r=this._middleLayers[0]||this._upperLayers[0];this._lowerLayers=[...i,...this._commonPoiLayers].map(n=>{const s=`${n.id}-shared-bg`;let o=this._map.getLayer(s);return o||(o=Object.assign({},n,{id:s}),this._map.addLayer(o,r.id)),o})}_updateFeatures(){this._features=this._getIndoorFeatures();const e=Yi(this._features,s=>s.layer.id+":"+s.properties.id),i=[],r=[],n=[];for(const s of e){const o=s.layer.id;o===Xe?i.push(s):o===re?r.push(s):o===T&&n.push(s)}this._allVenuesMap=new Map(i.map(s=>[s.properties.id,s])),this._allBuildingsMap=new Map(r.map(s=>[s.properties.id,s])),this._allSharedLevelsMap=new Map(n.map(s=>[s.properties.id,s]))}_calExcludedPoisInMiddle(){const e=this._map.querySourceFeatures("indoor-planet",{sourceLayer:"mapxus_place"}),i=n=>n?w(n).some(o=>this._upperLevels.has(o)):!1,r=e.filter(n=>{const s=n.properties["ref:level"]||n.properties["ref:shared_level"];return this._middleLevels.has(s)?i(n.properties.overlap):!1});this._excludedPoisInMiddle=r.map(n=>n.properties["osm:ref"])}_updateSelectedFeatures(){if(this._featureIncomplete){if(this._isSelectSharedFloor){const e=this._features.find(i=>i.properties.id===this._curVenueId);if(!e)return;this._curVenueFeature=e}else{const e=this._allBuildingsMap.get(this._curBuildingId);if(!e)return;this._curBuildingFeature=e}this._featureIncomplete=!1}}_layerFloors(){const{displayedLevels:e,selectedLevelIds:i,alwaysDisplayedSharedLevelIds:r,maskBuildingIds:n,maskSharedFloorIds:s}=this.layeredHandler.getLayeredData({selectedVenueId:this._curVenueId,venueMap:this._allVenuesMap,buildingMap:this._allBuildingsMap,sharedFloorMap:this._allSharedLevelsMap});this._upperLevels.clear(),this._middleLevels.clear(),this._lowerLevels.clear(),this._layerSelectedLevels(e,i),this._layerUnselectedLevels(e,i,r),this._isMaskMode&&(this._maskBuildings.clear(),this._maskSharedFloors.clear(),n.forEach(o=>{this._maskBuildings.add(o)}),s.forEach(o=>{this._maskSharedFloors.add(o)}))}_layerSelectedLevels(e,i){for(const r of i){this._upperLevels.add(r),this._zIndexHistory.set(r,!0);const n=e.find(({level:s,overlap:o})=>s===r&&!!o);if(n)for(const s of n.overlap)this._zIndexHistory.get(s)&&this._zIndexHistory.delete(s)}}_layerUnselectedLevels(e,i,r){for(const n of e){if(i.includes(n.level))continue;const{level:s,overlap:o,venueId:a}=n,l=this._zIndexHistory.get(s),d=!o||!o.some(c=>this._upperLevels.has(c)),u=r.includes(s);if(a===this._curVenueId&&u){this._lowerLevels.add(s),this._zIndexHistory.delete(s);continue}l?this._upperLevels.add(s):l===!1?this._middleLevels.add(s):u?this._lowerLevels.add(s):d?(this._upperLevels.add(s),this._zIndexHistory.set(s,!0)):(this._middleLevels.add(s),this._zIndexHistory.set(s,!1))}}_filterLayers(){this._filterIndoorLayers([...this._upperLevels,...this._middleLevels],this._commonPoiLayers),this._filterIndoorLayers([...this._upperLevels],this._upperLayers),this._filterIndoorLayers([...this._middleLevels],this._middleLayers),this._filterIndoorLayers([...this._lowerLevels],this._lowerLayers),this._sectionSymbolLayers.length!==0&&(this._sectionFillLineLayers.length?(this._filterIndoorLayers([...this._upperLevels],this._sectionFillLineLayers),this._filterIndoorLayers([...this._upperLevels],this._sectionSymbolLayers)):this._filterIndoorLayers([...this._upperLevels,...this._middleLevels,...this._lowerLevels],this._sectionSymbolLayers))}_filterIndoorLayers(e,i){let r;for(const n of i){const{id:s,filter:o,type:a,"source-layer":l}=n,d=o?[o]:[],u=s.includes("-shared-bg"),c=[...this._maskBuildings],h=[...this._maskSharedFloors];er(l,a)?r=["all",Qe(l,a)?["!in","ref:building",...c]:["!in","id",...h],["in","id",...e],...d]:u?r=["all",["!in","ref:shared_level",...h],["in","ref:shared_level",...e],...d]:(r=["all",["any",["all",["!in","ref:building",...c],["in","ref:level",...e]],["all",["!in","ref:shared_level",...h],["in","ref:shared_level",...e]]],...d],Ct(l,a)&&r.splice(1,0,["any",["!has","overlap"],["any",["in","ref:level",...this._upperLevels],["in","ref:shared_level",...this._upperLevels],["!in","osm:ref",...this._excludedPoisInMiddle]]])),this._map.setFilter(s,r)}}async _queryVenueFeature(e){let i=this.getFeaturesById(e,{layerIds:[Xe]})[0]??null;if(!i)try{const r=await Ve(e);i=He(r)}catch(r){console.error(r)}return i}_getBuildingDisplayedOrdinal(e,i){if(!e||!e.properties)return null;const{"ref:venue":r,level_ids:n,ordinals:s}=e.properties,o=w(n),a=w(s);if(i){const d=o.findIndex(u=>u===i);return a[d]??null}const l=this._history.getHistoryOrdinal(r);return l&&a.includes(l)?l:Gi(e)}_updateFloorState(e){if(!e){this._floor={code:null,id:null,ordinal:null};return}const{code:i,id:r}=this._getBuildingFloorByOrdinal(this._curBuildingFeature,e);(!i||!r)&&console.error(`Floor with ordinal "${e}" not found in building "${this._curBuildingId}".`),this._floor={code:i,id:r,ordinal:e},this._history.setHistoryOrdinal(this._curVenueId,e),this._history.setHistoryBuildingUnit(this._curVenueId,{id:this._curBuildingId,type:"building"})}async _checkAndPanToBuilding(){this.getFeaturesById(this._curBuildingId,{layerIds:[re]})[0]||(this._fitBounds?this.dragPanHandler.fitBounds():this.dragPanHandler.panToCenter())}_queryVisibleFeature(e){const r=[Qi,Et,`${Qi}-overlap-copy`,`${Et}-overlap-copy`,`${Et}-shared-bg`,...this._isMaskMode?[T,Ie]:[]].filter(o=>!!this._map.getLayer(o)),n=this._map.queryRenderedFeatures(e,{layers:r});let s=null;for(const o of r){const a=n.find(l=>l.layer.id===o);if(a){s=a;break}}return s&&Ta(s.sourceLayer,s.layer.type)&&(this._maskBuildings.has(s.properties?.id)||(s=null)),s}_queryRenderedFeatures(e){const i=(e||[]).filter(s=>this._map.getLayer(s));if(e&&e.length>0&&i.length===0)return[];const r=i.length?{layers:i}:{},n=this._map.getCanvas().getBoundingClientRect();return this._map.queryRenderedFeatures([[0,0],[n.width,n.height]],r)}_dispatchIndoorMapLoaded(){this._indoorMapLoaded||(this._indoorMapLoaded=!0,this.emit(Bt))}_changeOtherVenuesHistory(e){const i=[...this._allVenuesMap.values()];for(const r of i){const n=r.properties.id;n!==this._curVenueId&&this._history.setHistoryOrdinal(n,e)}}}function Ji(t,e){const i=typeof t=="number"&&t===Ne.lineWidth,r=typeof e=="number"&&e===Ne.lineOffset;if(!r)return e;if(i&&r)return["interpolate",["linear"],["zoom"],18,-1.5,20.2,-3.75,20.4,-3.8,21.5,-7.5,22,-9.55];if(!i&&r)return typeof t=="number"?-(t/2):e}function Ta(t,e){return t==="mapxus_building"&&(e==="fill"||e==="line"||e==="symbol")}function er(t,e){return Qe(t,e)||tr(t,e)}function Qe(t,e){return t==="mapxus_level"&&(e==="fill"||e==="line")}function tr(t,e){return t==="mapxus_shared_level"&&(e==="fill"||e==="line")}function Ct(t,e){return t==="mapxus_place"&&e==="symbol"}function Ot(t){return t==="fill-extrusion"}function Ra(t){return t==="line"||t==="fill"||t==="fill-extrusion"}const Ze="Poi_poiClick";class ir{_map;_currentStyle=null;_styleLayersLength=0;_layerIds=[];_dispatch=Se(Ze);_listeners=[];constructor(e){this._map=e,this._bindPoiClickEvent()}destroy(){this._dispatch.on(`.${Ze}`,null),this._currentStyle=null,this._map=null,this._dispatch=null,this._listeners=[],this._layerIds=[]}onPoiClick(e){const i=ie(`${Ze}.`);return this._dispatch.on(i,e),this._listeners.push(i),{unsubscribe:()=>this._dispatch.on(i,null)}}_queryPoiLayers(){const e=this._map.getStyle();if(e.name===this._currentStyle&&e.layers.length===this._styleLayersLength)return;const i=ot(e).filter(r=>r["source-layer"]==="mapxus_place"&&r.type==="symbol");this._layerIds=i.map(({id:r})=>r),this._currentStyle=e.name,this._styleLayersLength=e.layers.length}_bindPoiClickEvent(){this._map.on("click",e=>{if(this._listeners.length===0)return;this._queryPoiLayers();const i=this._map.queryRenderedFeatures(e.point,{layers:this._layerIds});if(i.length===0)return;const r=i[0],n=w(r.properties["ref:sections"]),s=!!r.properties["ref:shared_level"],o={coordinate:e.lngLat,poi:r};if(n.length>0){const a=this._map.querySourceFeatures("indoor-planet",{sourceLayer:"mapxus_section"});o.sections=n.map(l=>{const d=a.find(g=>g.properties.id===l),{id:u,section:c="",correlation_id:h}=d?.properties||{},f=rr(d?.properties);return{id:u,category:c,sectionName:f,...h&&{correlationId:h}}})}if(s){const a=r.properties["ref:shared_level"],{floor:l,venue:d}=this._queryIndoorFeaturesBySharedFloor(a);o.floor=l,o.venue=d}else{const a=r.properties["ref:level"],{floor:l,building:d,venue:u}=this._queryIndoorFeaturesByFloor(a);o.floor=l,o.building=d,o.venue=u}this._dispatch.call(Ze,null,o)})}_queryIndoorFeaturesBySharedFloor(e){const i=this._map.queryRenderedFeatures({layers:[T,"mapxus-venue-fill"]}),r=i.find(d=>d.sourceLayer==="mapxus_shared_level"&&d.properties.id===e);if(!r)return{floor:null,venue:null};const n=r.properties["ref:venue"],s=i.find(d=>d.layer.id==="mapxus-venue-fill"&&d.properties.id===n)??null,{id:o,ordinal:a}=r.properties,l=rr(r.properties);return{floor:{id:o,ordinal:a,name:l},venue:s}}_queryIndoorFeaturesByFloor(e){const i=this._map.queryRenderedFeatures({layers:[ve,"mapxus-building-line","mapxus-venue-fill"]}),r=i.find(u=>u.sourceLayer==="mapxus_level"&&u.properties.id===e);if(!r)return{floor:null,building:null,venue:null};const{id:n,ordinal:s,name:o,"ref:building":a}=r.properties||{},l=i.find(u=>u.layer.id==="mapxus-building-line"&&u.properties.id===a)??null,d=i.find(u=>u.layer.id==="mapxus-venue-fill"&&u.properties.id===l?.properties?.["ref:venue"])??null;return{floor:{id:n,ordinal:s,code:o},building:l,venue:d}}}function rr(t){return t?Object.keys(t).filter(i=>i.includes("name")).reduce((i,r)=>{const[,n]=w(r,":");return n?i[n]=t[r]:i.default=t[r],i},{}):{default:""}}function $e(t){t.parentNode&&t.parentNode.removeChild(t)}function F(t,e,i){const r=document.createElement(t);return e&&(r.className=e),i&&i.appendChild(r),r}class nr{_map;_maplibre;_buildingId;_features;_$container;_$listContainer;_$buildingList;_listHeight;_language;_visible;_position="top-right";_isMobileMode;_isListShown=!1;constructor(e,i){this._map=e,this._language=e.getLanguage(),this._visible=i??!0,this._detectDeviceMode()}onAdd(e){return this._maplibre=e,this._$container=F("div",`maplibregl-ctrl maplibregl-ctrl-building-filter ${this._visible?"":"hide"}`,this._maplibre.getContainer()),this._$container.appendChild(this._buildingFilterIconCreate("div")),this._$container.appendChild(this._buildingNameListCreate("div")),this._bindEvents(),this._$container}onRemove(){$e(this._$container)}get position(){return this._position}get enabled(){return this._visible}getDefaultPosition(){return"top-right"}setVisibility(e){this._visible=e,e?this._$showLayout():this._$hideLayout()}changePosition(e,i,r){const n=document.querySelector(`.maplibregl-ctrl-${e}`),s=n.querySelector(".maplibregl-ctrl-building-filter");if(e!==i){this._position=i;const o=document.querySelector(`.maplibregl-ctrl-${i}`);s&&(n.removeChild(s),Number.isFinite(r)?o.insertBefore(s,o.children[r]):o.append(s),this._updateBuildingListLayout(i))}else Number.isFinite(r)&&n.children[r]!==s&&(n.removeChild(s),n.insertBefore(s,n.children[r]))}_bindEvents(){this._maplibre.on("moveend",()=>this._refresh()),this._map.onMapChangeListener(e=>{const i=e.building?.properties?.id??"";this._buildingId!==i&&(this._buildingId=i,this._refresh())}),this._map.renderComplete(()=>this._init())}_init(){this._load()}_refresh(){this._load()}_load(){this._buildingNameListClean(),this._buildingNameListUpdate()}_buildingFilterIconCreate(e){const i=F(e,"mapxus-building-filter-icon");return this._bindMouseOnEvents(i,!1),this._bindMobileTouchEvents(i),i}_buildingNameListCreate(e){return this._$listContainer=F(e,"mapxus-building-name-layout"),this._$listContainer.style.display="none",this._$listContainer.style.top="20px",this._$buildingList=F(e,"mapxus-building-name-list",this._$listContainer),this._bindMouseOnEvents(this._$listContainer,!0),this._$listContainer}_buildingNameListUpdate(){this._features=[];const e=this._map.getMaplibre(),i=e?e.queryRenderedFeatures({layers:["mapxus-building-line"]}):[];for(const r of i){const{properties:n}=r,{id:s,name:o}=n,a=n?.[`name:${this._language}`]??o;this._features.find(l=>l.properties.id===s)||(this._features.push(r),this._$buildingList.appendChild(this._buildingNameCreate("p",a,s,s===this._map.building?.properties?.id)))}this._setBuildingListHeight(this._features),this._updateBuildingListLayout(this._position)}_buildingNameListClean(){this._$buildingList.replaceChildren()}_setBuildingListHeight(e){const n=e.map(s=>{const o=s?.properties?.[`name:${this._language}`]??s?.properties?.name;return o?Math.ceil(o.length*8/107):0}).reduce((s,o)=>s+o,0);this._listHeight=n*26+e.length*8,this._$buildingList.style.height=this._$listContainer.style.height=`${this._listHeight>=208?208:this._listHeight}px`}_buildingNameCreate(e,i,r,n){const s=F(e,`mapxus-building-name${n?" active":""}`);return s.dataset.id=r,s.innerText=i,this._buildingNameClickEvent(s),s}_toggleList(e){this._isListShown=e,this._$listContainer.style.display=e?"block":"none"}_buildingNameClickEvent(e){e.onclick||(e.onclick=async i=>{const r=i.target;await this._map.selectBuildingById(r.dataset.id)})}_bindMouseOnEvents(e,i){e.onmouseenter=()=>{this._isMobileMode||this._toggleList(!0)},i&&(e.onmouseleave=()=>this._toggleList(!1))}_bindMobileTouchEvents(e){window.addEventListener("resize",()=>this._detectDeviceMode()),e.ontouchend=()=>this._toggleList(!this._isListShown)}_$showLayout(){this._$container.classList.remove("hide")}_$hideLayout(){this._$container.classList.add("hide")}_updateBuildingListLayout(e){e.indexOf("left")>-1?(this._$listContainer.style.right=null,this._$listContainer.style.left="55px"):(this._$listContainer.style.left=null,this._$listContainer.style.right="55px");const i=this._$container.offsetParent?this._$container.offsetParent.clientHeight-(this._$container.offsetTop+this._$container.clientHeight)-25:0;e.includes("bottom")&&this._listHeight-20>i?(this._$listContainer.style.top=null,this._$listContainer.style.bottom="15px"):(this._$listContainer.style.bottom=null,this._$listContainer.style.top="20px")}_detectDeviceMode(){this._isMobileMode=window.matchMedia("(pointer: coarse) and (max-width: 768px)").matches}}var ka=Math.max,Da=Math.min;function Ha(t,e,i){return t>=Da(e,i)&&t<ka(e,i)}var sr=1/0,Na=17976931348623157e292;function or(t){if(!t)return t===0?t:0;if(t=We(t),t===sr||t===-sr){var e=t<0?-1:1;return e*Na}return t===t?t:0}function ar(t,e,i){return e=or(e),i===void 0?(i=e,e=0):i=or(i),t=We(t),Ha(t,e,i)}class lr{_container;_indoor;_maplibre;_position="top-right";_buildingId;_floorNames;_ordinals;_ordinal;_style;_$innerFloors;_$activeFloor;_centerSelectorIdx;_lastNormalScrollableIdx;_$arrowBtnUp;_$arrowBtnDown;_maxScrollTop;_$selectorExpanded;_$selectorFolded;_componentDidMount=!1;_visible=!1;_isEnabled;_dragPan;_language;_debounceScroll;_clearScrollEventListener;constructor(e,i){const{style:r,enabled:n=!0,language:s}=i;this._indoor=e,this._language=s,this._style=r?Object.assign({},Gt,r):Gt,this._isEnabled=n,this._addIndoorEventListeners()}onAdd(e){return this._maplibre=e,this._addMapMoveEventListener(),this._container=F("div","maplibregl-ctrl mapxus-ctrl-floors hidden"),this._container}onRemove(){this._debounceScroll&&this._debounceScroll.cancel(),this._clearScrollEventListener&&this._clearScrollEventListener(),$e(this._container)}get position(){return this._position}get enabled(){return this._isEnabled}setEnabled(e){this._isEnabled=e,e&&!this._visible&&this._setVisibility(!0),!e&&this._visible&&this._setVisibility(!1)}getDefaultPosition(){return"top-right"}async switchByOrdinal(e,i){this._ordinal=e,this._dragPan=i??!0,await this._indoor.switchFloorByOrdinal(e),this._updateSelectorStatus(e),this._scrollCenterActiveFloor()}changePosition(e,i,r){const n=document.querySelector(`.maplibregl-ctrl-${e}`),s=n.querySelector(".mapxus-ctrl-floors");if(e!==i){this._position=i;const o=document.querySelector(`.maplibregl-ctrl-${i}`);s&&(n.removeChild(s),Number.isFinite(r)?o.insertBefore(s,o.children[r]):o.append(s),this._show(),this._scrollCenterActiveFloor())}else Number.isFinite(r)&&n.children[r]!==s&&(n.removeChild(s),n.insertBefore(s,n.children[r]),this._show(),this._scrollCenterActiveFloor())}setStyle(e){this._style=Object.assign({},this._style,e),this._componentDidMount&&(this._clearFloors(),this._calcSelectorLayout(),this._render(),this._scrollCenterActiveFloor())}_setVisibility(e){this._componentDidMount?e?(this._show(),this._scrollCenterActiveFloor()):this._hide():(this._visible=e,this._indoor.building&&e&&(this._render(),this._show(),this._scrollCenterActiveFloor()))}_addIndoorEventListeners(){this._indoor.on(Ye,e=>{if(this._updatePrepared(),!e)return;const{ordinal:i,dragPan:r}=e;this._dragPan=r,"building"in e?this._renderBuildingFloors(e.building,i):this._renderSharedLevelFloor(e)})}_updatePrepared(){this._clearState(),this._visible&&this._hide(),this._componentDidMount&&this._clearFloors()}_renderBuildingFloors(e,i){const{level_names:r,ordinals:n,id:s}=e.properties;this._buildingId=s,this._floorNames=r.split(",").reverse(),this._ordinals=n.split(",").reverse(),this._ordinal=i,this._calcSelectorLayout(),this._render();const o=this._indoor.getFeaturesById(s,{filter:a=>a.layer.id==="mapxus-building-line"})[0];this._checkIfShowFloorSelector(o)}_renderSharedLevelFloor(e){const{name:i,ordinal:r,id:n}=e;this._floorNames=[i[this._language]||i.default],this._ordinals=[r],this._ordinal=r,this._calcSelectorLayout(),this._render();const s=this._indoor.getFeaturesById(n,{layerIds:[T]})[0];this._checkIfShowFloorSelector(s)}_checkIfShowFloorSelector(e){this.enabled&&(this._dragPan!==!1||this._dragPan===!1&&e)&&(this._show(),this._scrollCenterActiveFloor())}_addMapMoveEventListener(){this._maplibre.on("moveend",()=>{this.enabled&&this._dragPan===!1&&this._buildingId&&(this._indoor.getFeaturesById(this._buildingId,{layerIds:["mapxus-building-line"]})[0]?this._componentDidMount?this._visible||(this._show(),this._scrollCenterActiveFloor()):(this._render(),this._show(),this._scrollCenterActiveFloor()):this._componentDidMount&&this._visible&&this._hide())})}_clearState(){this._buildingId=null,this._floorNames=[],this._ordinals=[],this._ordinal=null}_calcSelectorLayout(){const{itemCount:e,itemSize:i}=this._style;this._centerSelectorIdx=Math.ceil(e/2)-1,this._maxScrollTop=(this._floorNames.length-e)*i,this._lastNormalScrollableIdx=this._floorNames.length-(e-this._centerSelectorIdx-1)-1}_render(){this._createFloors(),this._componentDidMount=!0}_hide(){this._container.classList.add("hidden"),this._visible=!1}_show(){this._container.classList.remove("hidden"),this._visible=!0}_createFloors(){this._$selectorFolded=this._$foldedSelector(this._container,()=>{this._expandSelector(!0),this._scrollCenterActiveFloor()}),this._$selectorExpanded=this._$expandedSelector(this._container,()=>this._expandSelector(!1))}_$expandedSelector(e,i){const{itemSize:r,itemCount:n,defaultFolded:s,backgroundColor:o}=this._style,a=F("div",`mapxus-ctrl-floors-expanded ${s?"hidden":""}`,e);if(this._floorNames.length>1){const d=F("div","mapxus-ctrl-floors-close",a);d.onclick=i}const l=F("div","mapxus-ctrl-floors-wrapper",a);return l.style.backgroundColor=o,this._floorNames.length>n&&(this._$arrowBtnUp=this._$createScrollButton(l,"up"),this._$arrowBtnUp.onclick=()=>this._handleScroll("up")),this._$innerFloors=F("div","mapxus-ctrl-floors-inner",l),Object.assign(this._$innerFloors.style,{maxHeight:`${r*n}px`,width:`${r}px`}),this._$createFloors(this._$innerFloors),this._floorNames.length>n&&(this._$arrowBtnDown=this._$createScrollButton(l,"down"),this._$arrowBtnDown.onclick=()=>this._handleScroll("down"),this._$innerFloors.addEventListener("scroll",this._debounceScroll=Wi(d=>{d.stopPropagation(),this._resetArrowBtnStatus(this._$innerFloors.scrollTop)},100)),this._clearScrollEventListener=()=>this._$innerFloors.removeEventListener("scroll",this._debounceScroll)),a}_$foldedSelector(e,i){const{itemSize:r,activeFontColor:n,activeBackgroundColor:s,defaultFolded:o}=this._style,a=F("div",`mapxus-ctrl-floors-folded mapxus-ctrl-floors-floor ${o?"":"hidden"}`,e);return a.onclick=i,Object.assign(a.style,{width:`${r}px`,height:`${r}px`,lineHeight:`${r}px`,color:n,backgroundColor:s}),a}_clearFloors(){this._container.replaceChildren(),this._componentDidMount=!1}_$createScrollButton(e,i){return F("div",`mapxus-ctrl-floors-arrow mapxus-ctrl-floors-floor ${i}`,e)}_$createFloors(e){const{fontColor:i,itemSize:r}=this._style;let n;this._floorNames.forEach((s,o)=>{n=F("div","mapxus-ctrl-floors-floor",e),n.dataset.floor=s,n.dataset.ordinal=this._ordinals[o],n.innerText=s,Object.assign(n.style,{color:i,height:`${r}px`,lineHeight:`${r}px`}),n.dataset.ordinal===this._ordinal&&(this._$activeFloor=n,this._resetActiveFloor(!0),this._$selectorFolded.innerText=s),n.onclick=async a=>{this._indoor.setDragPan("restrict"),this._indoor.dragPanHandler.setAnimated(!0),await this.switchByOrdinal(a.target.dataset.ordinal)}})}_updateSelectorStatus(e){const i=this._floorNames[this._ordinals.indexOf(e)];this._$activeFloor&&this._resetActiveFloor(!1);for(const r of this._$innerFloors.children){const n=r;n.dataset.ordinal===e&&(this._$activeFloor=n,this._resetActiveFloor(!0))}this._$selectorFolded.innerText=i}_resetArrowBtnStatus(e){e===0?this._$arrowBtnUp?.classList?.add("hidden"):this._$arrowBtnUp?.classList?.remove("hidden"),e===this._maxScrollTop?this._$arrowBtnDown?.classList?.add("hidden"):this._$arrowBtnDown?.classList?.remove("hidden")}_resetActiveFloor(e){const{activeBackgroundColor:i,backgroundColor:r,activeFontColor:n,fontColor:s}=this._style;Object.assign(this._$activeFloor.style,{color:e?n:s,backgroundColor:e?i:r,fontWeight:e?"bold":"normal",cursor:e?"auto":"pointer"}),this._$activeFloor.disabled=e}_scrollCenterActiveFloor(){if(this._ordinal){const e=this._ordinals.indexOf(this._ordinal);e>-1&&(this._$innerFloors.scrollTop=this._getScrollTop(e),this._$innerFloors.scrollTop||this._resetArrowBtnStatus(0))}}_getScrollTop(e){return ar(this._centerSelectorIdx,this._lastNormalScrollableIdx+1)?(e-this._centerSelectorIdx)*this._style.itemSize:e>this._lastNormalScrollableIdx?this._maxScrollTop:0}_handleScroll(e){const i=this._$innerFloors.scrollTop,{itemSize:r}=this._style;if(e==="up"){const n=i-r*2;this._$innerFloors.scrollTop=n<0?0:n}else if(e==="down"){const n=i+r*2;this._$innerFloors.scrollTop=n>this._maxScrollTop?this._maxScrollTop:n}}_expandSelector(e){e?(this._$selectorExpanded.classList.remove("hidden"),this._$selectorFolded.classList.add("hidden")):(this._$selectorExpanded.classList.add("hidden"),this._$selectorFolded.classList.remove("hidden"))}}const dr=Re.includes("co.jp"),Ua=dr?"kawasaki-logo":"mapxus-logo",ja=dr?"https://www.khi.co.jp/groupvision2030/mapxus.html":"https://www.mapxus.com/";class Va{_container;_isEnabled;constructor(e){this._isEnabled=e?.enabled??!0}onAdd(e){if(this._container=F("div","maplibregl-ctrl mapxus-ctrl-logo",e.getContainer()),this._isEnabled){const i=F("a",Ua,this._container);i.target="_blank",i.href=ja,i.setAttribute("aria-label","Mapxus logo"),i.setAttribute("rel","noopener"),this._container.appendChild(i)}return this._container}onRemove(){$e(this._container)}getDefaultPosition(){return"bottom-left"}}const za=Re.includes("co.jp");class qa{_container;_anchor;_theme;constructor(e){this._theme=e.theme?e.theme:"default"}onAdd(e){return this._container=F("div","maplibregl-ctrl mapxus-ctrl-attribution",e.getContainer()),this._anchor=F("a","mapxus-attribution",this._container),this._anchor.target="_blank",this._setCopyrightInfo(this._theme),this._anchor.setAttribute("aria-label","Mapxus attribution"),this._anchor.setAttribute("rel","noopener"),this._container.appendChild(this._anchor),this._container}onRemove(){$e(this._container)}getDefaultPosition(){return"bottom-right"}changeTheme(e){this._setCopyrightInfo(e)}_setCopyrightInfo(e){this._anchor.innerText=e==="landsD"?"© The Government of the Hong Kong SAR":za?"©Mapxus driven by Kawasaki ©OpenStreetMap contributors":"©Mapxus ©OpenStreetMap contributors",e==="landsD"&&(this._anchor.href="https://www.map.gov.hk/gm/")}}class Ga{_container;_$icon;_removeClickEventListener;onAdd(e){return this._container=F("div","maplibregl-ctrl mapxus-ctrl-collapsed-copyright",e.getContainer()),this._container.innerHTML=Ka(),this._bindEvents(),this._container}onRemove(){this._removeClickEventListener(),$e(this._container)}getDefaultPosition(){return"bottom-right"}_bindEvents(){const e=this._container.querySelector(".mapxus-collapsed-copyright-menu");this._$icon=this._container.querySelector(".mapxus-collapsed-copyright-btn");let i=!1;this._$icon.addEventListener("click",r),this._removeClickEventListener=()=>this._$icon.removeEventListener("click",r);function r(){i=!i,n()}function n(){i?e.classList.remove("hidden"):e.classList.add("hidden")}}}function Ka(){return`
2
2
  <div class="mapxus-collapsed-copyright-content">
3
3
  <div class="mapxus-collapsed-copyright-menu hidden">
4
4
  <div class="mapxus-collapsed-copyright-logo" onclick="window.open('https://www.khi.co.jp/groupvision2030/mapxus.html')"></div>
@@ -7,4 +7,4 @@
7
7
  </div>
8
8
  <div class="mapxus-collapsed-copyright-btn"></div>
9
9
  </div>
10
- `}function sr(t){return`${Ht}/api/v3/tiles/styles/${t}`}class or extends Error{_status;constructor(e,i){super(e);const{cause:r,status:n,type:s}=i??{};this.name=typeof s=="string"?s:"CustomError",r!==void 0&&(this.cause=r),n!==void 0&&(this._status=n)}get status(){return this._status}}var Ft=(t=>(t.CHRISTMAS="christmas_mims2_v1",t.HALLOWEEN="halloween_mims2_v1",t.MAPPY_BEE="mappybee_mims2_v2",t.MAPXUS="mapxus_mims2_v1",t.LANDS_D="lands_d_mims2_v1",t.COMMON="common_mims2_v1",t.MAPXUS_V2="mapxus_v2",t.MAPXUS_DEFAULT="mapxus_v8",t.ROSE_TEA="rose_tea",t.PEAR_SORBET="pear_sorbet",t.CITY_WALK="city_walk",t.MOCHA_MOUSSE="mocha_mousse",t.SECTION_DISPLAY_BY_COLOR="mapxus_v7_with_section_v2",t.SECTION_DISPLAY_BY_CATEGORY="mapxus_v7_with_section_v3",t))(Ft||{});class ar{_buildingSelector;_isEnabled=!0;_position;constructor(e){this._buildingSelector=e}enable(){this._isEnabled=!0,this._buildingSelector.enabled||this._buildingSelector.setVisibility(!0)}disable(){this._isEnabled=!1,this._buildingSelector.enabled&&this._buildingSelector.setVisibility(!1)}setPosition(e,i){this._position=e,this._buildingSelector.changePosition(this._buildingSelector.position,e,i)}get isEnabled(){return this._isEnabled}get position(){return this._position}}class lr{_floorSelector;_isEnabled;_position;constructor(e){this._floorSelector=e,this._position=e.position,this._isEnabled=this._floorSelector.enabled}enable(){this._isEnabled=!0,this._floorSelector.setEnabled(!0)}disable(){this._isEnabled=!1,this._floorSelector.setEnabled(!1)}setPosition(e,i){this._position=e,this._floorSelector.changePosition(this._floorSelector.position,e,i)}setStyle(e){this._floorSelector.setStyle(e)}get isEnabled(){return this._isEnabled}get position(){return this._position}}class dr{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowBuildingSwitch(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowBuildingSwitch(!1)}get isEnabled(){return this._isEnabled}}class ur{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowOutdoorSwitch(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowOutdoorSwitch(!1)}get isEnabled(){return this._isEnabled}}class cr{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowIndoorClickSelect(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowIndoorClickSelect(!1)}get isEnabled(){return this._isEnabled}}class hr{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowOutdoorClickSelect(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowOutdoorClickSelect(!1)}get isEnabled(){return this._isEnabled}}const Ct="Map_mapClick",Ot="Map_pointClick",$t="Map_isRenderComplete",Ce="Map_isDestroyed",_e=D.getInstance();let Ha=class{_map;_indoor;_poi;_floorsControl;_buildingFilterControl;_attributionControl;_language;_dispatch=ye(Ct,Ot,$t,Ce);_fitBounds;_history=Y.getInstance();_debounceHTTPErrorHandler;_transformRequestHandler;_tokenRefreshingPromise=null;_cancelTokenChangedListener;isDestroyed=!1;switchOutdoor;outdoorClickSelection;switchBuilding;indoorClickSelection;buildingSelector;floorSelector;constructor(e){if(!e.map)throw new or("Parameter 'Map' is required!",{type:"TypeError"});_e.registerSDK(),this._permissionCheck().then(()=>{this._setup(e)}).catch(i=>{const r=i.cause?i.message+" "+i.cause.message:i.message;console.error(r)})}renderComplete(e){const i=te(`${$t}.`);this._dispatch.on(i,e)}destroyed(e){const i=te(`${Ce}.`);this._dispatch.on(i,()=>{e(),this._dispatch.on(i,null),this._dispatch._[Ce].length===0&&(delete this._dispatch,Object.freeze(this))})}setTransformRequest(e){this._transformRequestHandler=e}getIndoor(){return this._indoor}getMaplibre(){return this._map}get floor(){return this._indoor?.floor??null}get building(){return this._indoor?.building??null}get venue(){return this._indoor?.venue??null}setLanguage(e){this._language!==e&&(this._language=e);const n=(this._map?.getStyle()?.layers||[]).filter(({type:s})=>s==="symbol");for(const{id:s}of n){const o=this._map.getLayer(s),a=typeof this._map.getLayoutProperty(s,"text-field")=="string";o&&!a&&this._map.setLayoutProperty(s,"text-field",["coalesce",["get",`name:${e}`],["get","name"]])}}getLanguage(){return this._language}setOutdoorMapShown(e){this._indoor?.setOutdoorMapShown(e)}queryIndoorFeaturesByPoint(e){const{x:i,y:r}=e,n=this._map.queryRenderedFeatures([i,r],{layers:["mapxus-venue-fill","mapxus-building-line",me,x]}),s=n.find(l=>l.layer.id==="mapxus-venue-fill");if(!s)return null;const o=this._history.getHistoryOrdinal(s.properties.id),a=n.find(l=>l.properties?.ordinal===o);if(a){if(a.sourceLayer==="mapxus_shared_level")return{venue:s,sharedLevel:a};const l=n.find(d=>d.properties.id===a.properties["ref:building"]);return{venue:s,building:l,level:a}}}getIndoorFeaturesByCoordinates(e,i){const r=this._map.project(e),n=this._map.queryRenderedFeatures(r,{layers:["mapxus-venue-fill","mapxus-building-line","mapxus-level-fill","mapxus-level-fill-overlap-copy"]});if(n.length===0)return{venue:null,building:null,level:null};const o=n.filter(d=>d.layer.id.includes("mapxus-level-fill")).find(d=>Number.isFinite(i)?d.properties.ordinal===i+"":d.layer.id.startsWith("mapxus-level-fill"));if(!o)return{venue:null,building:null,level:null};const a=n.find(d=>d.properties.id===o.properties["ref:building"]);return{venue:n.find(d=>d.properties.id===a.properties["ref:venue"]),building:a,level:o}}getFeaturesById(e,i){return this._indoor?.getFeaturesById(e,i)||[]}async switchFloorByOrdinal(e){await this._indoor?.switchFloorByOrdinal(e)}async selectFloorById(e,i){const{dragPan:r=!0,animate:n=!0,fitBounds:s}=i||{},o=s??this._fitBounds,a=async()=>{const l=await _r(e),{maxLat:d,maxLon:u,minLat:h,minLon:c}=l?.bbox||{};this._indoor.dragPanHandler.setBounds([c,h,u,d])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(o),this._indoor.dragPanHandler.setAnimated(n),e===this.floor?.id){if(!r)return;o?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let l=!1,d=(this._map.getLayer("mapxus-building-line")?this._map.queryRenderedFeatures({layers:["mapxus-building-line"]}):[]).find(h=>h.properties?.level_ids?.includes(e))??null;if(d&&d.properties?.id===this.building?.properties?.id){o&&!this._indoor.dragPanHandler.getBounds()&&await a();const{level_ids:h,ordinals:c}=d.properties,f=w(h).indexOf(e),g=w(c)[f]??null;await this._floorsControl.switchByOrdinal(g,r)}else{if(d)o&&await a();else{const h=await _r(e),{maxLat:c,maxLon:f,minLat:g,minLon:_}=h.bbox;l=!0,d=h.feature,this._indoor.dragPanHandler.setBounds([_,g,f,c])}await this._indoor.selectBuilding(d??null,{floorId:e,featureIncomplete:l})}}}async selectSharedFloorById(e,i){const{dragPan:r=!0,animate:n=!0,fitBounds:s}=i||{},o=s??this._fitBounds,a=async()=>{const l=await Na(e),{maxLat:d,maxLon:u,minLat:h,minLon:c}=l?.bbox||{};this._indoor.dragPanHandler.setBounds([c,h,u,d])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(o),this._indoor.dragPanHandler.setAnimated(n),e===this.floor?.id){if(!r)return;o?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let l=!1,d,u;const h=(this._map.getLayer(x)?this._map.queryRenderedFeatures({layers:[x]}):[]).find(c=>c.properties?.id===e)??null;if(h)o&&await a();else{const c=await ti(e);u=Te(c),l=!0;const{maxLat:f,maxLon:g,minLat:_,minLon:y}=c?.bbox||{};this._indoor.dragPanHandler.setBounds([y,_,g,f]);const m=c.sharedFloors.find(({id:B})=>B===e),{id:S,name:E,ordinal:C}=m;d={id:S,name:E,ordinal:C+""}}if(!l){const{id:c,name:f,ordinal:g,"ref:venue":_}=h.properties||{};d={id:c,name:typeof f=="string"?{default:f}:f,ordinal:g},u=(this._map.getLayer("mapxus-venue-fill")?this._map.queryRenderedFeatures({layers:["mapxus-venue-fill"]}):[]).find(y=>y.properties?.id===_)??null}d&&u&&await this._indoor?.selectSharedFloor(d,u,{featureIncomplete:l})}}async selectBuildingById(e,i){const{dragPan:r=!0,animate:n=!0,fitBounds:s}=i||{},o=s??this._fitBounds,a=async()=>{const l=await De(e),{maxLat:d,maxLon:u,minLat:h,minLon:c}=l?.bbox||{};this._indoor.dragPanHandler.setBounds([c,h,u,d])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(o),this._indoor.dragPanHandler.setAnimated(n),e===this.building?.properties?.id){if(!r)return;o?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let l=!1,d=(this._map.getLayer("mapxus-building-line")?this._map.queryRenderedFeatures({layers:["mapxus-building-line"]}):[]).find(u=>u.properties?.id===e)??null;if(d)o&&await a();else{const u=await De(e),{maxLat:h,maxLon:c,minLat:f,minLon:g}=u?.bbox||{};d=nt(u),l=!0,this._indoor.dragPanHandler.setBounds([g,f,c,h])}await this._indoor?.selectBuilding(d,{featureIncomplete:l})}}async selectVenueById(e,i){if(typeof e=="string"&&e.trim()===""||e===null){await this._indoor?.selectBuilding(null);return}const{dragPan:n=!0,animate:s=!0,fitBounds:o}=i||{},a=o??this._fitBounds,l=async()=>{const d=await He(e),{maxLat:u,maxLon:h,minLat:c,minLon:f}=d?.bbox||{};this._indoor.dragPanHandler.setBounds([f,c,h,u])};if(this._indoor.setDragPan(n),this._indoor.setFitBounds(a),this._indoor.dragPanHandler.setAnimated(s),e===this.venue?.properties?.id){if(!n)return;a?(this._indoor.dragPanHandler.getBounds()||await l(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{const d=this._history.getHistoryBuildingUnit(e);if(d){const{id:u,type:h}=d;h==="building"?await this.selectBuildingById(u,i):await this.selectSharedFloorById(u,i)}else{const u=(this._map.getLayer("mapxus-venue-fill")?this._map.queryRenderedFeatures({layers:["mapxus-venue-fill"]}):[]).find(c=>c.properties?.id===e)??null;let h;if(u){const{default_displayed_building:c,building_ids:f}=u.properties;h=c||w(f)[0]}else{const c=await He(e);h=c.defaultBuilding||c.buildings[0]?.id}await this.selectBuildingById(h,i)}}}onMapClickListener(e){const i=te(`${Ct}.`);return this._dispatch.on(i,e),{unsubscribe:()=>this._dispatch.on(i,null)}}onPoiClickListener(e){return this._poi?.onPoiClick(e)}onPointClickListener(e){const i=te(`${Ot}.`);return this._dispatch.on(i,e),{unsubscribe:()=>this._dispatch.on(i,null)}}onMapChangeListener(e){return this._indoor?.onMapChange(e)}switchTheme(e){this.setTheme(e)}setTheme(e){e!==_e.theme&&(this._setStyle(sr(e),{diff:!1}),_e.setTheme(e),this._map?.once("styledata",()=>{this._indoor.updateCustomLayers(),this._indoor.updateRendering()}),"changeTheme"in this._attributionControl&&this._attributionControl.changeTheme(e))}setSelectedBuildingBorderStyle(e){return this._indoor?.setSelectedHighlightStyle(e),this}setSelectedHighlightStyle(e){return this._indoor?.setSelectedHighlightStyle(e),this}setFloorSwitchScope(e){this._indoor?.setFloorSwitchScope(e)}async _setup(e){const{map:i,poiId:r,sharedFloorId:n,floorId:s,buildingId:o,venueId:a,theme:l=Ft.MAPXUS_DEFAULT,floorSelectorEnabled:d,buildingSelectorEnabled:u,outdoorMapShown:h=!0,collapseCopyright:c=!1,maskNonSelectedAreas:f=!1,fitBuildingBounds:g,fitBounds:_,boundsPadding:y=30,selectedHighlightStyle:m,floorSelectorStyle:S,language:E=Rr,autoSelectBuilding:C=!1,transformRequest:B=null,mapxusLogoEnabled:b=!0,enableIndoorClickSelection:O=!0,enableOutdoorClickSelection:$=!0,floorSwitchScope:P=xe.VENUE}=e;this._map=i,this._language=E,this._fitBounds=_??g??!1,this._indoor=new Wi({map:this._map,startWithIndoorView:!!(a||o||s||r||n),outdoorMapShown:h,fitBounds:this._fitBounds,boundsPadding:y,maskNonSelectedAreas:f,selectedHighlightStyle:m,enableIndoorClickSelection:O,enableOutdoorClickSelection:$,floorSwitchScope:P}),this._poi=new Zi(this._map),this._transformRequestHandler=B,await this._resourceRequestTransform(),this._installRtlTextPlugin(),this._setStyle(sr(l)),_e.setTheme(l),this._checkMapZoom(),c?this._attributionControl=new ka:(this._attributionControl=new Ra({theme:l}),this._addControl(new Ta({enabled:b}))),this._addControl(this._attributionControl),this._addControl(this._buildingFilterControl=new er(this,u)),this._addControl(this._floorsControl=new nr(this._indoor,{language:E,style:S,enabled:d})),r?this._selectPoiById(r):s?this.selectFloorById(s,{animate:!1}):o?this.selectBuildingById(o,{animate:!1}):a?this.selectVenueById(a,{animate:!1}):n&&this.selectSharedFloorById(n,{animate:!1}),this.switchOutdoor=new ur(this._indoor),this.switchBuilding=new dr(this._indoor),this.outdoorClickSelection=new hr(this._indoor),this.indoorClickSelection=new cr(this._indoor),this.buildingSelector=new ar(this._buildingFilterControl),this.floorSelector=new lr(this._floorsControl),this._map.once("styledata",()=>this.setLanguage(this._language)),this._map.on("remove",()=>this._destroy()),this._map.on("error",this._debounceHTTPErrorHandler=vt(L=>this._updatePermission(L),300)),this._indoor.once(It,()=>{C&&this._map.on("moveend",()=>this._selectCenterBuilding()),this._bindMapClickListener(),this._dispatch.call($t)})}_setStyle(e,i){this._map?.setStyle(e,{localIdeographFontFamily:!1,...i??{}})}_addControl(e,i){this._map.addControl(e,i)}async _selectPoiById(e){try{const i=await jr(e),{lon:r,lat:n}=i.location;"floorId"in i?await this.selectFloorById(i.floorId,{animate:!1}):"sharedFloorId"in i&&await this.selectSharedFloorById(i.sharedFloorId,{animate:!1}),this._map.panTo([r,n],{animate:!1})}catch(i){this._dispatchErrorGlobal("initError",i)}}async _resourceRequestTransform(){const e={"Content-Type":"application/json",sdkVersion:Je,identifier:await T.getIdentifier(),token:await T.getToken()};this._map.setTransformRequest((i,r)=>{const{host:n}=new URL(i);return n.includes("map-api")&&n.includes("mapxus")?{url:i,headers:e}:this._transformRequestHandler?this._transformRequestHandler(i,r):{url:i}})}_checkMapZoom(){const e=this._map.getZoom();(e<8||e>22)&&e>1&&console.warn("Indoor maps perform better at zoom levels [8, 22].")}async _updatePermission(e){if(e.error?.status===401)return this._tokenRefreshingPromise?this._tokenRefreshingPromise:(this._tokenRefreshingPromise=this._resourceRequestTransform().finally(()=>this._tokenRefreshingPromise=null),this._tokenRefreshingPromise)}_selectCenterBuilding(){const e=this._getCenterBuildingUnitsMap();if(!e.size)return;let i=e.entries().next().value[1];const r=this._history.getVisitedBuildingUnits().reverse();for(const n of r){const{id:s}=n;if(e.get(s)){i=n;break}}i.type==="building"?this.selectBuildingById(i.id,{dragPan:!1}):this.selectSharedFloorById(i.id,{dragPan:!1})}_getCenterBuildingUnitsMap(){const e=this._map.getCanvas().getBoundingClientRect(),i=e.width/4,r=e.height/4,n=[i,r],s=[e.width-i,e.height-r],o=["mapxus-building-line",x].filter(u=>this._map.getLayer(u)),a=this._map.queryRenderedFeatures([n,s],{layers:o}),d=qi(a,"properties.id").filter(u=>!this._indoor.layeredHandler.getHiddenBuildings().includes(u.properties.id));return new globalThis.Map(d.map(({properties:u})=>[`${u.id}`,{id:u.id,type:u.building?"building":"sharedFloor"}]))}_bindMapClickListener(){this._map.on("click",async e=>{const{point:i,lngLat:r}=e,n=await this._indoor.queryIndoorFeaturesByClickPoint(i);await this._indoor.selectByClickMap(n),this._dispatch.call(Ot,null,{point:i,coordinate:r}),this._dispatch.call(Ct,null,{coordinate:r,venue:n?.venue??null,building:n&&"building"in n?n.building:null,floor:n?"sharedFloor"in n?n.sharedFloor:n.floor??null:null})})}_dispatchErrorGlobal(e,i){const r=_e.getGlobalDispatcher();if(!r)return;const n=i.response?.status||i.status||"unknown",s=i.response?.data?.message||i.message||"unknown";r.call(e,null,{status:n,message:s})}_installRtlTextPlugin(){kt.getRTLTextPluginStatus()==="unavailable"&&kt.setRTLTextPlugin("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js",!0)}async _permissionCheck(){try{if(!(await T.md5(T.SDKName.MapSDK)==="true"))throw new or("Permission invalid!",{status:403,type:"PermissionError"});return Promise.resolve()}catch(e){return this._dispatchErrorGlobal("unauthorized",e),this._dispatchErrorGlobal("initError",e),Promise.reject(e)}}_destroy(){if(this.isDestroyed)return;this.isDestroyed=!0,this._debounceHTTPErrorHandler?.cancel();const e=this._dispatch._;for(const i in e)i!==Ce&&e.hasOwnProperty(i)&&e[i].forEach(({name:r})=>{this._dispatch.on(`${i}.${r}`,null)});this._indoor.destroy(),this._poi.destroy(),_e.clear(),Object.keys(this).forEach(i=>{i!=="isDestroyed"&&i!=="_dispatch"&&delete this[i]}),this._cancelTokenChangedListener&&this._cancelTokenChangedListener(),this._dispatch.call(Ce)}};async function _r(t){const e=await Ur(t);return{feature:nt(e),bbox:e.bbox}}async function Na(t){const e=await ti(t);return{feature:Te(e),bbox:e.bbox}}async function Oe(t,e){if(!t.hasImage(e))try{const i=await t.loadImage(e);t.addImage(e,i.data)}catch(i){throw new Error(i)}}class Ua{_maplibreMap;_layerId;_sourceId;_imageName="poi-01";_imageSize=.75;_iconAnchor="bottom";constructor(e){this._maplibreMap=e;const i=te();this._layerId=`MXMap_preset_marker_layer_${i}`,this._sourceId=`MXMap_preset_marker_source_${i}`}async setIcon(e){if(typeof e!="string"||!e.trim())throw new Error("Icon must be a non-empty string.");await Oe(this._maplibreMap,e.trim()),this._imageName=e}setIconSize(e){this._imageSize=e}setIconAnchor(e){this._iconAnchor=e}get layerId(){return this._layerId}get sourceId(){return this._sourceId}create(e){if(!(Array.isArray(e)&&e.length))return;const i=e.map(r=>this._createIconFeature(r));this._addIconSource(i),this._addIconLayer()}updateData(e){const i=!!(e.remove&&e.remove.length),r=!!(e.add&&e.add.length),n=!!(e.update&&e.update.length),s=this._maplibreMap.getSource(this._sourceId);if(!i&&!r&&!n||!s)return;const o={};i&&(o.remove=e.remove),r&&(o.add=e.add.map(a=>this._createIconFeature(a))),n&&(o.update=e.update.map(a=>{const l=this._createIconFeature(a),{id:d,geometry:u,properties:h}=l;return{id:d,...u&&{newGeometry:u},...h&&{addOrUpdateProperties:Object.entries(h).map(([c,f])=>({key:c,value:f}))},...!u&&!h&&{removeAllProperties:!0}}})),s.updateData(o)}remove(){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.removeLayer(this._layerId),this._maplibreMap.getSource(this._sourceId)&&this._maplibreMap.removeSource(this._sourceId)}on(e,i){const r=s=>this._handleEventListener(s,i),{unsubscribe:n}=this._maplibreMap.on(e,this._layerId,r);return{off:n}}setFilter(e){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,e)}setFilterByVenue(e,i){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,["any",["all",["==",["get","venueId"],e??""],["==",["get","ordinal"],i??""]],["all",["==",["get","venueId"],""],["==",["get","ordinal"],""]]])}setFilterByBuilding(e,i){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,["any",["all",["==",["get","buildingId"],e??""],["==",["get","ordinal"],i??""]],["all",["==",["get","buildingId"],""],["==",["get","ordinal"],""]]])}setOpacity(e){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",e)}setOpacityByVenue(e,i,r){if(this._maplibreMap.getLayer(this._layerId)){const n=["case",["all",["==",["get","venueId"],e??""],["==",["get","ordinal"],i??""]],1,["all",["==",["get","venueId"],""],["==",["get","ordinal"],""]],1,r??.5];this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",n)}}setOpacityByBuilding(e,i,r){if(this._maplibreMap.getLayer(this._layerId)){const n=["case",["all",["==",["get","buildingId"],e??""],["==",["get","ordinal"],i??""]],1,["all",["==",["get","buildingId"],""],["==",["get","ordinal"],""]],1,r??.5];this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",n)}}_createIconFeature(e){const{lngLat:i,properties:r}=e;return{id:"featureId"in e?e.featureId:void 0,type:"Feature",...i&&{geometry:{type:"Point",coordinates:i}},...r&&{properties:r}}}_addIconSource(e){const i={type:"geojson",data:{type:"FeatureCollection",features:e}};this._maplibreMap.addSource(this._sourceId,i)}_addIconLayer(){this._maplibreMap.addLayer({id:this._layerId,type:"symbol",source:this._sourceId,layout:{"icon-image":this._imageName,"icon-size":this._imageSize,"icon-anchor":this._iconAnchor,"icon-allow-overlap":!0,"icon-ignore-placement":!0}})}_handleEventListener(e,i){const{point:r}=e,n=this._maplibreMap.queryRenderedFeatures(r,{layers:[this._layerId]});i(n[0])}}function Ye(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}const At={indoorLineColor:"#45b1cc",outdoorLineColor:"#8183ba",dashedLineColor:"#969696",shuttleBusLineColor:"#fb923c",lineWidth:4,dashedLineWidth:4,disableDashedLine:!1,inactiveRouteOpacity:.5,outdoorLineOpacity:1,markerIconSize:.75,markers:{from:"poi-02",to:"poi-01",stops:["waypoint-01"]},lineSymbol:{image:"east-blue-arrow-01",size:.25,spacing:1}},Xe="mmws-source-line-solid",fe="mmws-layer-line-solid",pe="mmws-layer-icon-line-symbol",Mt="mmws-source-line-dashed",re="mmws-layer-line-dashed",xt="mmws-source-icon-connector",fr="mmws-layer-icon-connector",Qe="mmws-source-icon-marker",Tt="mmws-layer-icon-marker",pr=[fe,pe,re,fr,Tt],ja=[Xe,Mt,xt,Qe];class Va{_maplibreMap;_routeStyle=At;_styleDiffs={};_filterBy="venue";_curVenue=null;_curBuilding=null;_curOrdinal=null;_renderBoundaryLayer;constructor(e,i){this._maplibreMap=e,i&&(this._updateStyleProperties(i),e.on("load",()=>this._loadMarkerIcons()))}async setStyle(e){this._updateStyleProperties(e),await this._loadMarkerIcons(),await this._updateLayers()}async setMarkerIcons(e){if(Array.isArray(e)&&e.length){const i=e.slice(1,e.length-1);this._routeStyle.markers={from:e[0],to:Ye(e),stops:i.length?i:[e[0]]},this._styleDiffs={markers:this._routeStyle.markers}}else"from"in e&&(this._routeStyle.markers.from=e.from,this._styleDiffs.markers.from=e.from),"to"in e&&(this._routeStyle.markers.to=e.to,this._styleDiffs.markers.to=e.to),"stops"in e&&(this._routeStyle.markers.stops=e.stops??[null],this._styleDiffs.markers.stops=e.stops??[null]);await this._loadMarkerIcons()}setMarkerIconSize(e){return this._routeStyle.markerIconSize=e,this}setIndoorLineColor(e){return this._routeStyle.indoorLineColor=e,this}setOutdoorLineColor(e){return this._routeStyle.outdoorLineColor=e,this}setDashedLineColor(e){return this._routeStyle.dashedLineColor=e,this}setBusLineColor(e){return this._routeStyle.shuttleBusLineColor=e,this}render(e,i){if(!this._renderBoundaryLayer){const d=this._maplibreMap.getStyle(),u=it(d);let h=u.find(({type:c,id:f})=>!f.includes("-overlap-copy")&&c==="fill-extrusion");h||(h=u.find(c=>c.type==="symbol"&&c?.["source-layer"]==="mapxus_place")),this._renderBoundaryLayer=h?.id}const{instructions:r,points:{coordinates:n}}=e,{lineFeatures:s,connectorFeatures:o,dashedLineFeatures:a,markerFeatures:l}=this._classifyFeatures(r,n,i);this._renderSolidLines(s),this._renderLineSymbols(Xe,pe),this._routeStyle.disableDashedLine!==!0&&this._renderDashedLines(a),this._renderConnectors(o),this._renderMarkers(l)}remove(){pr.forEach(e=>{this._maplibreMap.getLayer(e)&&this._maplibreMap.removeLayer(e)}),ja.forEach(e=>{this._maplibreMap.getSource(e)&&this._maplibreMap.removeSource(e)})}setFilterByVenue(e,i){this._filterBy="venue",this._curVenue=e??null,this._curOrdinal=i??null,this._filterRouteOpacity()}setFilterByBuilding(e,i){this._filterBy="building",this._curBuilding=e??null,this._curOrdinal=i??null,this._filterRouteOpacity()}_classifyFeatures(e,i,r){const n=[],s=[],o=[],a=[],l=[];e.forEach(($,P)=>{const{venue_id:L,building_id:H,floor_id:A,ordinal:K,sign:ne,type:ge,interval:[Ze,$e]}=$;if(qa(ne))l.push($);else if(za(ne)){P!==0&&P!==e.length-1&&s.push(this._createIconFeature(`connector-${s.length}`,i[Ze],{...G({venue_id:L,building_id:H,floor_id:A,ordinal:K}),icon:ge}));const yr=e[P+1];if(yr){const{venue_id:Xa,building_id:Qa,floor_id:Za,ordinal:Ja}=yr;s.push(this._createIconFeature(`connector-${s.length}`,i[$e],{...G({venue_id:Xa,building_id:Qa,floor_id:Za,ordinal:Ja}),icon:ge}))}}else n.push(this._createLineFeature(`solid-line-${n.length}`,i.slice(Ze,$e+1),G({venue_id:L,building_id:H,floor_id:A,ordinal:K,isShuttleBus:Ga(ne)?1:0})))});const d=e[0],{venue_id:u,building_id:h,floor_id:c,ordinal:f}=d,g=e[e.length-1],{venue_id:_,building_id:y,floor_id:m,ordinal:S}=g,E=i[0],C=i[i.length-1],B=r[0],b=r[r.length-1],O=r.slice(1,r.length-1);return B&&o.push(this._createLineFeature(`dashed-line-${o.length}`,[B,E],G({venue_id:u,building_id:h,floor_id:c,ordinal:f}))),b&&o.push(this._createLineFeature(`dashed-line-${o.length}`,[C,b],G({venue_id:_,building_id:y,floor_id:m,ordinal:S}))),l.length&&O.length&&l.forEach(({venue_id:$,building_id:P,floor_id:L,ordinal:H,interval:[A]},K)=>{o.push(this._createLineFeature(`dashed-line-${o.length}`,[i[A],O[K]],G({venue_id:$,building_id:P,floor_id:L,ordinal:H}))),a.push(this._createIconFeature(`marker-${a.length}`,O[K],{...G({venue_id:$,building_id:P,floor_id:L,ordinal:H,markerType:`stops_${K}`}),icon:this._routeStyle.markers.stops[K]??Ye(this._routeStyle.markers.stops),iconSize:this._routeStyle.markerIconSize}))}),a.push(this._createIconFeature(`marker-${a.length}`,B??E,{...G({venue_id:u,building_id:h,floor_id:c,ordinal:f,markerType:"from"}),icon:this._routeStyle.markers.from,iconSize:this._routeStyle.markerIconSize})),a.push(this._createIconFeature(`marker-${a.length}`,b??C,{...G({venue_id:_,building_id:y,floor_id:m,ordinal:S,markerType:"to"}),icon:this._routeStyle.markers.to,iconSize:this._routeStyle.markerIconSize})),{lineFeatures:n,connectorFeatures:s,dashedLineFeatures:o,markerFeatures:a}}_createLineFeature(e,i,r){return{id:e,type:"Feature",geometry:{type:"LineString",coordinates:i},properties:r}}_createIconFeature(e,i,r){return{id:e,type:"Feature",geometry:{type:"Point",coordinates:i},properties:r}}_renderSolidLines(e){this._addCollectionSource(Xe,e),this._addLineLayer(Xe,fe,{"line-color":["case",["==",["get","isShuttleBus"],"1"],this._routeStyle.shuttleBusLineColor,["==",["get","floor_id"],null],this._routeStyle.outdoorLineColor,this._routeStyle.indoorLineColor],"line-opacity":["case",["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,1],"line-width":this._routeStyle.lineWidth})}_renderDashedLines(e){this._addCollectionSource(Mt,e),this._addLineLayer(Mt,re,{"line-color":this._routeStyle.dashedLineColor,"line-width":this._routeStyle.dashedLineWidth,"line-dasharray":[.1,1.8]})}_renderConnectors(e){this._addCollectionSource(xt,e),this._addIconLayer(xt,fr)}_renderMarkers(e){this._addCollectionSource(Qe,e),this._addIconLayer(Qe,Tt,{"icon-anchor":"bottom","icon-allow-overlap":!0,"icon-ignore-placement":!0})}_addCollectionSource(e,i){this._maplibreMap.addSource(e,{type:"geojson",data:{type:"FeatureCollection",features:i}})}_addLineLayer(e,i,r){this._maplibreMap.addLayer({id:i,type:"line",source:e,layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":4,...r||{}}},this._renderBoundaryLayer)}_renderLineSymbols(e,i){this._maplibreMap.addLayer({id:i,type:"symbol",source:e,layout:{"symbol-placement":"line","symbol-spacing":this._routeStyle.lineSymbol.spacing,"icon-size":this._routeStyle.lineSymbol.size,"icon-image":this._routeStyle.lineSymbol.image},paint:{"icon-opacity":["case",["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,1]}},this._renderBoundaryLayer)}_addIconLayer(e,i,r){this._maplibreMap.addLayer({id:i,type:"symbol",source:e,layout:{"icon-image":["get","icon"],"icon-size":["case",["has","iconSize"],["get","iconSize"],1],...r||{}}})}_updateStyleProperties(e){if(this._styleDiffs=gr(this._routeStyle,e??At),!e)this._routeStyle=At;else if(Object.keys(this._styleDiffs).length){const i={...this._routeStyle.lineSymbol,...this._styleDiffs.lineSymbol??{}},r=this._styleDiffs.markers;let n=this._routeStyle.markers;const s={outdoorLineOpacity:(this._styleDiffs.outdoorLineOpacity>1?1:this._styleDiffs.outdoorLineOpacity<0?0:this._styleDiffs.outdoorLineOpacity)??this._routeStyle.outdoorLineOpacity},o={inactiveRouteOpacity:(this._styleDiffs.inactiveRouteOpacity>1?1:this._styleDiffs.inactiveRouteOpacity<0?0:this._styleDiffs.inactiveRouteOpacity)??this._routeStyle.inactiveRouteOpacity};r&&Object.keys(r).length&&(n={...n,...r}),this._routeStyle={...this._routeStyle,...this._styleDiffs,...s,...o,markers:n,lineSymbol:i}}}async _loadMarkerIcons(){const{markers:e,lineSymbol:i}=this._styleDiffs;if(i?.image&&await Oe(this._maplibreMap,i.image),e&&Object.keys(e).length){const{from:r,to:n,stops:s}=e;if(r&&await Oe(this._maplibreMap,r),n&&await Oe(this._maplibreMap,n),s&&s.length){const o=s.filter(a=>!!a);o.length&&await Promise.all(o.map(a=>Oe(this._maplibreMap,a)))}}}async _updateLayers(){if(!this._maplibreMap.getLayer(fe))return;const{indoorLineColor:e,outdoorLineColor:i,dashedLineColor:r,shuttleBusLineColor:n,lineWidth:s,dashedLineWidth:o,disableDashedLine:a,inactiveRouteOpacity:l,outdoorLineOpacity:d,markerIconSize:u,markers:h,lineSymbol:c}=this._styleDiffs;if((e||i||n)&&this._maplibreMap.setPaintProperty(fe,"line-color",["case",["==",["get","isShuttleBus"],"1"],this._routeStyle.shuttleBusLineColor,["==",["get","floor_id"],null],this._routeStyle.outdoorLineColor,this._routeStyle.indoorLineColor]),s!==void 0&&s+""&&this._maplibreMap.setPaintProperty(fe,"line-width",s),typeof a=="boolean"?a?this._maplibreMap.setPaintProperty(re,"line-color","transparent"):(this._maplibreMap.setPaintProperty(re,"line-color",this._routeStyle.dashedLineColor),this._maplibreMap.setPaintProperty(re,"line-width",this._routeStyle.dashedLineWidth)):this._routeStyle.disableDashedLine!==!0&&(r&&this._maplibreMap.setPaintProperty(re,"line-color",r),o!==void 0&&o+""&&this._maplibreMap.setPaintProperty(re,"line-width",o)),l!==void 0&&l+""&&this._filterRouteOpacity(),u!==void 0&&u+""&&this._maplibreMap.setLayoutProperty(Tt,"icon-size",u),h&&Object.keys(h).length){const{from:f,to:g,stops:_}=h,y=this._maplibreMap.getSource(Qe),m=await y.getData();m.features=m.features.map(S=>{const{markerType:E}=S.properties;if(f!==void 0&&E==="from"&&(S.properties.icon=f),g!==void 0&&E==="to"&&(S.properties.icon=g),_&&E.includes("stops")){const C=parseInt(E.split("_")[1]);S.properties.icon=_[C]??Ye(_)}return S}),y.setData(m)}if(c){const{image:f,size:g,spacing:_}=c;f!==void 0&&this._maplibreMap.setLayoutProperty(pe,"icon-image",f),g!==void 0&&g+""&&this._maplibreMap.setLayoutProperty(pe,"icon-size",g),_!==void 0&&_+""&&this._maplibreMap.setLayoutProperty(pe,"symbol-spacing",_)}d!==void 0&&d+""&&(this._maplibreMap.setPaintProperty(fe,"line-opacity",["case",["==",["get","floor_id"],null],d,1]),this._maplibreMap.setPaintProperty(pe,"icon-opacity",["case",["==",["get","floor_id"],null],d,1]),this._filterRouteOpacity())}_filterRouteOpacity(){let e;switch(this._filterBy){case"venue":e=["case",["all",["==",["get","ordinal"],this._curOrdinal??""],["==",["get","venue_id"],this._curVenue??""]],1,["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,this._routeStyle.inactiveRouteOpacity];break;case"building":e=["case",["all",["==",["get","ordinal"],this._curOrdinal??""],["==",["get","building_id"],this._curBuilding??""]],1,["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,this._routeStyle.inactiveRouteOpacity];break}pr.forEach(i=>{this._maplibreMap.getLayer(i)&&this._maplibreMap.setPaintProperty(i,i.includes("layer-line")?"line-opacity":"icon-opacity",e)})}}function G(t){return Object.fromEntries(Object.entries(t).map(([e,i])=>[e,Number.isFinite(i)?i+"":i]))}function za(t){return t===100||t===-100}function qa(t){return t===5}function Ga(t){return rr(t,104,108)}function gr(t,e){const i={};for(const r in e){const n=t[r],s=e[r];if(r==="markers"||r==="lineSymbol")if(Array.isArray(s)){const o=s.slice(1,s.length-1);i[r]={from:s[0],to:Ye(s),stops:o.length?o:[s[0]]}}else{const o=gr(n,s);Object.keys(o).length&&(i[r]=o)}else s+""!=n+""&&(i[r]=r==="stops"?s??[null]:s)}return i}var Rt=(t=>(t.FOOT="foot",t.WHEELCHAIR="wheelchair",t.ESCALATOR="escalator",t.EMERGENCY="emergency",t))(Rt||{});const Ka=D.getInstance();class Wa{_api="api/v4/route/query";constructor(){}async search(e){const{points:i,vehicle:r=Rt.FOOT,locale:n="en"}=e;if(!(i&&i.length>1&&i.length<6))throw new Error("Parameter error. It must be 1 < {points.length} < 6");if(Ya(i))throw new Error("Parameter error. Points must have lat and lon.");return(await Ka.getHttpSession()).request(this._api,{method:"POST",body:JSON.stringify({points:i,vehicle:r,locale:n})})}}function Ya(t){return t.some(e=>!e||typeof e.lat!="number"||typeof e.lon!="number")}p.ASSISTANT_LAYER_INDOOR_FLOORS=me,p.ASSISTANT_LAYER_SHARED_FLOORS=x,p.BuildingFilterControl=er,p.BuildingSelectorHandler=ar,p.BuildingsService=Zt,p.DistanceSearchType=qt,p.ERRORS=Nt,p.FloorSelectorHandler=lr,p.FloorSwitchScope=xe,p.FloorsControl=nr,p.Indoor=Wi,p.IndoorClickSelection=cr,p.Map=Ha,p.Marker=Ua,p.OFFSET=R,p.OrientationDistanceSearchType=st,p.OutdoorClickSelection=hr,p.PAGE=k,p.Poi=Zi,p.PoisOrderBy=Gt,p.PoisService=Wt,p.PoisSortBy=Kt,p.PresetLanguage=M,p.RoutePainter=Va,p.RouteService=Wa,p.SwitchBuildingHandler=dr,p.SwitchOutdoorHandler=ur,p.ThemeType=Ft,p.VERSION=Je,p.VehicleType=Rt,p.VenuesService=Xt,p.convertBrowserLangToPresetLang=jt,p.omittedBuildingProps=Qt,p.omittedPoiProps=ot,p.omittedVenueKeys=Yt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
10
+ `}function $t(t){return`${Re}/${Er}/${t}`}var Mt=(t=>(t.CHRISTMAS="christmas_mims2_v1",t.HALLOWEEN="halloween_mims2_v1",t.MAPPY_BEE="mappybee_mims2_v2",t.MAPXUS="mapxus_mims2_v1",t.LANDS_D="lands_d_mims2_v1",t.COMMON="common_mims2_v1",t.MAPXUS_V2="mapxus_v2",t.MAPXUS_DEFAULT="mapxus_v8",t.ROSE_TEA="rose_tea",t.PEAR_SORBET="pear_sorbet",t.CITY_WALK="city_walk",t.MOCHA_MOUSSE="mocha_mousse",t.SECTION_DISPLAY_BY_COLOR="mapxus_v7_with_section_v2",t.SECTION_DISPLAY_BY_CATEGORY="mapxus_v7_with_section_v3",t))(Mt||{});class ur{_buildingSelector;_isEnabled=!0;_position;constructor(e){this._buildingSelector=e}enable(){this._isEnabled=!0,this._buildingSelector.enabled||this._buildingSelector.setVisibility(!0)}disable(){this._isEnabled=!1,this._buildingSelector.enabled&&this._buildingSelector.setVisibility(!1)}setPosition(e,i){this._position=e,this._buildingSelector.changePosition(this._buildingSelector.position,e,i)}get isEnabled(){return this._isEnabled}get position(){return this._position}}class cr{_floorSelector;_isEnabled;_position;constructor(e){this._floorSelector=e,this._position=e.position,this._isEnabled=this._floorSelector.enabled}enable(){this._isEnabled=!0,this._floorSelector.setEnabled(!0)}disable(){this._isEnabled=!1,this._floorSelector.setEnabled(!1)}setPosition(e,i){this._position=e,this._floorSelector.changePosition(this._floorSelector.position,e,i)}setStyle(e){this._floorSelector.setStyle(e)}get isEnabled(){return this._isEnabled}get position(){return this._position}}class hr{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowBuildingSwitch(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowBuildingSwitch(!1)}get isEnabled(){return this._isEnabled}}class _r{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowOutdoorSwitch(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowOutdoorSwitch(!1)}get isEnabled(){return this._isEnabled}}class fr{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowIndoorClickSelect(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowIndoorClickSelect(!1)}get isEnabled(){return this._isEnabled}}class pr{_indoor;_isEnabled=!0;constructor(e){this._indoor=e}enable(){this._isEnabled=!0,this._indoor.setAllowOutdoorClickSelect(!0)}disable(){this._isEnabled=!1,this._indoor.setAllowOutdoorClickSelect(!1)}get isEnabled(){return this._isEnabled}}const At="Map_mapClick",xt="Map_pointClick",Tt="Map_isRenderComplete",Me="Map_isDestroyed",ne=D.getInstance();let Wa=class{_map;_indoor;_poi;_floorsControl;_buildingFilterControl;_attributionControl;_language;_dispatch=Se(At,xt,Tt,Me);_fitBounds;_history=X.getInstance();_transformRequestHandler;isDestroyed=!1;switchOutdoor;outdoorClickSelection;switchBuilding;indoorClickSelection;buildingSelector;floorSelector;constructor(e){if(!e.map)throw new $.AuthSdkError("Parameter 'Map' is required!",{type:"ValidationError"});ne.registerSDK(),this._permissionCheck().then(()=>this._setup(e)).catch(i=>{const r=i.cause?i.message+" "+i.cause.message:i.message;console.error(r)})}renderComplete(e){const i=ie(`${Tt}.`);this._dispatch.on(i,e)}destroyed(e){const i=ie(`${Me}.`);this._dispatch.on(i,()=>{e(),this._dispatch.on(i,null),this._dispatch._[Me].length===0&&(delete this._dispatch,Object.freeze(this))})}setTransformRequest(e){this._transformRequestHandler=e,this._resourceRequestTransform()}getIndoor(){return this._indoor}getMaplibre(){return this._map}get floor(){return this._indoor?.floor??null}get building(){return this._indoor?.building??null}get venue(){return this._indoor?.venue??null}setLanguage(e){if(this._language===e)return;this._language=e;const i=this._map?.getStyle()?.layers||[];for(const{id:r,type:n}of i){if(!this._map.getLayer(r)||n!=="symbol")continue;const s=this._map.getLayoutProperty(r,"text-field");!s||typeof s=="string"||this._map.setLayoutProperty(r,"text-field",["coalesce",["get",`name:${e}`],["get","name"],""])}}getLanguage(){return this._language}setOutdoorMapShown(e){this._indoor?.setOutdoorMapShown(e)}queryIndoorFeaturesByPoint(e){const{x:i,y:r}=e,n=this._map.queryRenderedFeatures([i,r],{layers:["mapxus-venue-fill","mapxus-building-line",ve,T]}),s=n.find(o=>o.layer.id==="mapxus-venue-fill");if(s){const o=this._history.getHistoryOrdinal(s.properties.id),a=n.find(l=>l.properties?.ordinal===o);if(a){if(a.sourceLayer==="mapxus_shared_level")return{venue:s,sharedLevel:a};const l=n.find(d=>d.properties.id===a.properties["ref:building"]);return{venue:s,building:l,level:a}}}return null}getIndoorFeaturesByCoordinates(e,i){const r=this._map.project(e),n=this._map.queryRenderedFeatures(r,{layers:["mapxus-venue-fill","mapxus-building-line","mapxus-level-fill","mapxus-level-fill-overlap-copy"]});if(n.length===0)return{venue:null,building:null,level:null};const o=n.filter(d=>d.layer.id.includes("mapxus-level-fill")).find(d=>Number.isFinite(i)?d.properties.ordinal===i+"":d.layer.id.startsWith("mapxus-level-fill"));if(!o)return{venue:null,building:null,level:null};const a=n.find(d=>d.properties.id===o.properties["ref:building"]);return{venue:n.find(d=>d.properties.id===a.properties["ref:venue"]),building:a,level:o}}getFeaturesById(e,i){return this._indoor?.getFeaturesById(e,i)||[]}async switchFloorByOrdinal(e){await this._indoor?.switchFloorByOrdinal(e)}async selectFloorById(e,i){const{dragPan:r=!0,animate:n=!0,fitBounds:s}=i||{},o=s??this._fitBounds,a=async()=>{const l=await gr(e),{maxLat:d,maxLon:u,minLat:c,minLon:h}=l?.bbox||{};this._indoor.dragPanHandler.setBounds([h,c,u,d])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(o),this._indoor.dragPanHandler.setAnimated(n),e===this.floor?.id){if(!r)return;o?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let l=!1,d=(this._map.getLayer("mapxus-building-line")?this._map.queryRenderedFeatures({layers:["mapxus-building-line"]}):[]).find(c=>c.properties?.level_ids?.includes(e))??null;if(d&&d.properties?.id===this.building?.properties?.id){o&&!this._indoor.dragPanHandler.getBounds()&&await a();const{level_ids:c,ordinals:h}=d.properties,f=w(c).indexOf(e),g=w(h)[f]??null;await this._floorsControl.switchByOrdinal(g,r)}else{if(d)o&&await a();else{const c=await gr(e),{maxLat:h,maxLon:f,minLat:g,minLon:_}=c.bbox;l=!0,d=c.feature,this._indoor.dragPanHandler.setBounds([_,g,f,h])}await this._indoor.selectBuilding(d??null,{floorId:e,featureIncomplete:l})}}}async selectSharedFloorById(e,i){const{dragPan:r=!0,animate:n=!0,fitBounds:s}=i||{},o=s??this._fitBounds,a=async()=>{const l=await Ya(e),{maxLat:d,maxLon:u,minLat:c,minLon:h}=l?.bbox||{};this._indoor.dragPanHandler.setBounds([h,c,u,d])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(o),this._indoor.dragPanHandler.setAnimated(n),e===this.floor?.id){if(!r)return;o?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let l=!1,d,u;const c=(this._map.getLayer(T)?this._map.queryRenderedFeatures({layers:[T]}):[]).find(h=>h.properties?.id===e)??null;if(c)o&&await a();else{const h=await ni(e);u=He(h),l=!0;const{maxLat:f,maxLon:g,minLat:_,minLon:y}=h?.bbox||{};this._indoor.dragPanHandler.setBounds([y,_,g,f]);const m=h.sharedFloors.find(({id:B})=>B===e),{id:S,name:E,ordinal:C}=m;d={id:S,name:E,ordinal:C+""}}if(!l){const{id:h,name:f,ordinal:g,"ref:venue":_}=c.properties||{};d={id:h,name:typeof f=="string"?{default:f}:f,ordinal:g},u=(this._map.getLayer("mapxus-venue-fill")?this._map.queryRenderedFeatures({layers:["mapxus-venue-fill"]}):[]).find(y=>y.properties?.id===_)??null}d&&u&&await this._indoor?.selectSharedFloor(d,u,{featureIncomplete:l})}}async selectBuildingById(e,i){const{dragPan:r=!0,animate:n=!0,fitBounds:s}=i||{},o=s??this._fitBounds,a=async()=>{const l=await je(e),{maxLat:d,maxLon:u,minLat:c,minLon:h}=l?.bbox||{};this._indoor.dragPanHandler.setBounds([h,c,u,d])};if(this._indoor.setDragPan(r),this._indoor.setFitBounds(o),this._indoor.dragPanHandler.setAnimated(n),e===this.building?.properties?.id){if(!r)return;o?(this._indoor.dragPanHandler.getBounds()||await a(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{let l=!1,d=(this._map.getLayer("mapxus-building-line")?this._map.queryRenderedFeatures({layers:["mapxus-building-line"]}):[]).find(u=>u.properties?.id===e)??null;if(d)o&&await a();else{const u=await je(e),{maxLat:c,maxLon:h,minLat:f,minLon:g}=u?.bbox||{};d=lt(u),l=!0,this._indoor.dragPanHandler.setBounds([g,f,h,c])}await this._indoor?.selectBuilding(d,{featureIncomplete:l})}}async selectVenueById(e,i){if(typeof e=="string"&&e.trim()===""||e===null){await this._indoor?.selectBuilding(null);return}const{dragPan:n=!0,animate:s=!0,fitBounds:o}=i||{},a=o??this._fitBounds,l=async()=>{const d=await Ve(e),{maxLat:u,maxLon:c,minLat:h,minLon:f}=d?.bbox||{};this._indoor.dragPanHandler.setBounds([f,h,c,u])};if(this._indoor.setDragPan(n),this._indoor.setFitBounds(a),this._indoor.dragPanHandler.setAnimated(s),e===this.venue?.properties?.id){if(!n)return;a?(this._indoor.dragPanHandler.getBounds()||await l(),await this._indoor.dragPanHandler.fitBounds()):this._indoor.dragPanHandler.panToCenter()}else{const d=this._history.getHistoryBuildingUnit(e);if(d){const{id:u,type:c}=d;c==="building"?await this.selectBuildingById(u,i):await this.selectSharedFloorById(u,i)}else{const u=(this._map.getLayer("mapxus-venue-fill")?this._map.queryRenderedFeatures({layers:["mapxus-venue-fill"]}):[]).find(h=>h.properties?.id===e)??null;let c;if(u){const{default_displayed_building:h,building_ids:f}=u.properties;c=h||w(f)[0]}else{const h=await Ve(e);c=h.defaultBuilding||h.buildings[0]?.id}await this.selectBuildingById(c,i)}}}onMapClickListener(e){const i=ie(`${At}.`);return this._dispatch.on(i,e),{unsubscribe:()=>this._dispatch.on(i,null)}}onPoiClickListener(e){return this._poi?.onPoiClick(e)}onPointClickListener(e){const i=ie(`${xt}.`);return this._dispatch.on(i,e),{unsubscribe:()=>this._dispatch.on(i,null)}}onMapChangeListener(e){return this._indoor?.onMapChange(e)}switchTheme(e){this.setTheme(e)}setTheme(e){e!==ne.theme&&(this._setStyle($t(e),{diff:!1}),ne.setTheme(e),this._map?.once("styledata",()=>{this._indoor.updateCustomLayers(),this._indoor.updateRendering()}),"changeTheme"in this._attributionControl&&this._attributionControl.changeTheme(e))}setSelectedBuildingBorderStyle(e){return this._indoor?.setSelectedHighlightStyle(e),this}setSelectedHighlightStyle(e){return this._indoor?.setSelectedHighlightStyle(e),this}setFloorSwitchScope(e){this._indoor?.setFloorSwitchScope(e)}async _setup(e){const{map:i,poiId:r,sharedFloorId:n,floorId:s,buildingId:o,venueId:a,theme:l=Mt.MAPXUS_DEFAULT,floorSelectorEnabled:d,buildingSelectorEnabled:u,outdoorMapShown:c=!0,collapseCopyright:h=!1,maskNonSelectedAreas:f=!1,fitBuildingBounds:g,fitBounds:_,boundsPadding:y=30,selectedHighlightStyle:m,floorSelectorStyle:S,language:E=jr,autoSelectBuilding:C=!1,transformRequest:B=null,mapxusLogoEnabled:b=!0,enableIndoorClickSelection:O=!0,enableOutdoorClickSelection:M=!0,floorSwitchScope:P=De.VENUE}=e;this._map=i,this._language=E,this._fitBounds=_??g??!1,this._indoor=new Zi({map:this._map,startWithIndoorView:!!(a||o||s||r||n),outdoorMapShown:c,fitBounds:this._fitBounds,boundsPadding:y,maskNonSelectedAreas:f,selectedHighlightStyle:m,enableIndoorClickSelection:O,enableOutdoorClickSelection:M,floorSwitchScope:P}),this._poi=new ir(this._map),this._transformRequestHandler=B,this._resourceRequestTransform(),this._installRtlTextPlugin(),this._setStyle($t(l)),ne.setTheme(l),this._checkMapZoom(),h?this._attributionControl=new Ga:(this._attributionControl=new qa({theme:l}),this._addControl(new Va({enabled:b}))),this._addControl(this._attributionControl),this._addControl(this._buildingFilterControl=new nr(this,u)),this._addControl(this._floorsControl=new lr(this._indoor,{language:E,style:S,enabled:d})),r?this._selectPoiById(r):s?this.selectFloorById(s,{animate:!1}):o?this.selectBuildingById(o,{animate:!1}):a?this.selectVenueById(a,{animate:!1}):n&&this.selectSharedFloorById(n,{animate:!1}),this.switchOutdoor=new _r(this._indoor),this.switchBuilding=new hr(this._indoor),this.outdoorClickSelection=new pr(this._indoor),this.indoorClickSelection=new fr(this._indoor),this.buildingSelector=new ur(this._buildingFilterControl),this.floorSelector=new cr(this._floorsControl),this._map.once("styledata",()=>this.setLanguage(this._language)),this._map.on("remove",()=>this._destroy()),this._map.on("error",L=>this._updatePermission(L)),this._indoor.once(Bt,()=>{C&&this._map.on("moveend",()=>this._selectCenterBuilding()),this._bindMapClickListener(),this._dispatch.call(Tt)})}_setStyle(e,i){this._map?.setStyle(e,{localIdeographFontFamily:!1,...i??{}})}_addControl(e,i){this._map.addControl(e,i)}async _selectPoiById(e){try{const i=await Wr(e),{lon:r,lat:n}=i.location;"floorId"in i?await this.selectFloorById(i.floorId,{animate:!1}):"sharedFloorId"in i&&await this.selectSharedFloorById(i.sharedFloorId,{animate:!1}),this._map.panTo([r,n],{animate:!1})}catch(i){this._dispatchErrorGlobal("initError",i)}}_resourceRequestTransform(){this._map.setTransformRequest((e,i)=>{const{host:r}=new URL(e),n=r.includes("map-api")&&r.includes("mapxus"),s=$.getLatestCredentials();return n?{url:e,headers:{"Content-Type":"application/json",sdkVersion:`web-${$.SDKName.MapSDK}/${rt}`,identifier:s.identifier,token:s.token}}:this._transformRequestHandler?this._transformRequestHandler(e,i):{url:e}})}_checkMapZoom(){const e=this._map.getZoom();(e<8||e>22)&&e>1&&console.warn("Indoor maps perform better at zoom levels [8, 22].")}async _updatePermission(e){if(e.error?.status!==401)return;await $.getToken(),this._resourceRequestTransform();const i=e.error.url;/^https:\/\/[^/]+\/bms\/api\/v\d+\/tiles\/styles\//.test(i)&&ne.theme&&this._setStyle($t(ne.theme))}_selectCenterBuilding(){const e=this._getCenterBuildingUnitsMap();if(!e.size)return;let i=e.entries().next().value[1];const r=this._history.getVisitedBuildingUnits().reverse();for(const n of r){const{id:s}=n;if(e.get(s)){i=n;break}}i.type==="building"?this.selectBuildingById(i.id,{dragPan:!1}):this.selectSharedFloorById(i.id,{dragPan:!1})}_getCenterBuildingUnitsMap(){const e=this._map.getCanvas().getBoundingClientRect(),i=e.width/4,r=e.height/4,n=[i,r],s=[e.width-i,e.height-r],o=["mapxus-building-line",T].filter(u=>this._map.getLayer(u)),a=this._map.queryRenderedFeatures([n,s],{layers:o}),d=Yi(a,"properties.id").filter(u=>!this._indoor.layeredHandler.getHiddenBuildings().includes(u.properties.id));return new globalThis.Map(d.map(u=>{const{properties:c}=u;return[`${c.id}`,{id:c.id,type:c.building?"building":"sharedFloor"}]}))}_bindMapClickListener(){this._map.on("click",async e=>{const{point:i,lngLat:r}=e,n=await this._indoor.queryIndoorFeaturesByClickPoint(i);await this._indoor.selectByClickMap(n),this._dispatch.call(xt,null,{point:i,coordinate:r}),this._dispatch.call(At,null,{coordinate:r,venue:n?.venue??null,building:n&&"building"in n?n.building:null,floor:n?"sharedFloor"in n?n.sharedFloor:n.floor??null:null})})}_dispatchErrorGlobal(e,i){const r=ne.getGlobalDispatcher();if(!r)return;const n=i.response?.status||i.status||"unknown",s=i.response?.data?.message||i.message||"unknown";r.call(e,null,{status:n,message:s})}_installRtlTextPlugin(){Ut.getRTLTextPluginStatus()==="unavailable"&&Ut.setRTLTextPlugin("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js",!0)}async _permissionCheck(){try{if(!(await $.md5($.SDKName.MapSDK)==="true"))throw new $.AuthSdkError("Permission invalid!",{status:403,type:"PermissionError"});return Promise.resolve()}catch(e){return this._dispatchErrorGlobal("unauthorized",e),this._dispatchErrorGlobal("initError",e),Promise.reject(e)}}_destroy(){if(this.isDestroyed)return;this.isDestroyed=!0;const e=this._dispatch._;for(const i in e)i!==Me&&e.hasOwnProperty(i)&&e[i].forEach(({name:r})=>{this._dispatch.on(`${i}.${r}`,null)});this._indoor.destroy(),this._poi.destroy(),Object.keys(this).forEach(i=>{i!=="isDestroyed"&&i!=="_dispatch"&&delete this[i]}),this._dispatch.call(Me)}};async function gr(t){const e=await Kr(t);return{feature:lt(e),bbox:e.bbox}}async function Ya(t){const e=await ni(t);return{feature:He(e),bbox:e.bbox}}async function Ae(t,e){if(!t.hasImage(e))try{const i=await t.loadImage(e);t.addImage(e,i.data)}catch(i){throw new Error(i)}}class Xa{_maplibreMap;_layerId;_sourceId;_imageName="poi-01";_imageSize=.75;_iconAnchor="bottom";constructor(e){this._maplibreMap=e;const i=ie();this._layerId=`MXMap_preset_marker_layer_${i}`,this._sourceId=`MXMap_preset_marker_source_${i}`}async setIcon(e){if(typeof e!="string"||!e.trim())throw new Error("Icon must be a non-empty string.");await Ae(this._maplibreMap,e.trim()),this._imageName=e}setIconSize(e){this._imageSize=e}setIconAnchor(e){this._iconAnchor=e}get layerId(){return this._layerId}get sourceId(){return this._sourceId}create(e){if(!(Array.isArray(e)&&e.length))return;const i=e.map(r=>this._createIconFeature(r));this._addIconSource(i),this._addIconLayer()}updateData(e){const i=!!(e.remove&&e.remove.length),r=!!(e.add&&e.add.length),n=!!(e.update&&e.update.length),s=this._maplibreMap.getSource(this._sourceId);if(!i&&!r&&!n||!s)return;const o={};i&&(o.remove=e.remove),r&&(o.add=e.add.map(a=>this._createIconFeature(a))),n&&(o.update=e.update.map(a=>{const l=this._createIconFeature(a),{id:d,geometry:u,properties:c}=l;return{id:d,...u&&{newGeometry:u},...c&&{addOrUpdateProperties:Object.entries(c).map(([h,f])=>({key:h,value:f}))},...!u&&!c&&{removeAllProperties:!0}}})),s.updateData(o)}remove(){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.removeLayer(this._layerId),this._maplibreMap.getSource(this._sourceId)&&this._maplibreMap.removeSource(this._sourceId)}on(e,i){const r=s=>this._handleEventListener(s,i),{unsubscribe:n}=this._maplibreMap.on(e,this._layerId,r);return{off:n}}setFilter(e){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,e)}setFilterByVenue(e,i){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,["any",["all",["==",["get","venueId"],e??""],["==",["get","ordinal"],i??""]],["all",["==",["get","venueId"],""],["==",["get","ordinal"],""]]])}setFilterByBuilding(e,i){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setFilter(this._layerId,["any",["all",["==",["get","buildingId"],e??""],["==",["get","ordinal"],i??""]],["all",["==",["get","buildingId"],""],["==",["get","ordinal"],""]]])}setOpacity(e){this._maplibreMap.getLayer(this._layerId)&&this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",e)}setOpacityByVenue(e,i,r){if(this._maplibreMap.getLayer(this._layerId)){const n=["case",["all",["==",["get","venueId"],e??""],["==",["get","ordinal"],i??""]],1,["all",["==",["get","venueId"],""],["==",["get","ordinal"],""]],1,r??.5];this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",n)}}setOpacityByBuilding(e,i,r){if(this._maplibreMap.getLayer(this._layerId)){const n=["case",["all",["==",["get","buildingId"],e??""],["==",["get","ordinal"],i??""]],1,["all",["==",["get","buildingId"],""],["==",["get","ordinal"],""]],1,r??.5];this._maplibreMap.setPaintProperty(this._layerId,"icon-opacity",n)}}_createIconFeature(e){const{lngLat:i,properties:r}=e;return{id:"featureId"in e?e.featureId:void 0,type:"Feature",...i&&{geometry:{type:"Point",coordinates:i}},...r&&{properties:r}}}_addIconSource(e){const i={type:"geojson",data:{type:"FeatureCollection",features:e}};this._maplibreMap.addSource(this._sourceId,i)}_addIconLayer(){this._maplibreMap.addLayer({id:this._layerId,type:"symbol",source:this._sourceId,layout:{"icon-image":this._imageName,"icon-size":this._imageSize,"icon-anchor":this._iconAnchor,"icon-allow-overlap":!0,"icon-ignore-placement":!0}})}_handleEventListener(e,i){const{point:r}=e,n=this._maplibreMap.queryRenderedFeatures(r,{layers:[this._layerId]});i(n[0])}}function Je(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}const Rt={indoorLineColor:"#45b1cc",outdoorLineColor:"#8183ba",dashedLineColor:"#969696",shuttleBusLineColor:"#fb923c",lineWidth:4,dashedLineWidth:4,disableDashedLine:!1,inactiveRouteOpacity:.5,outdoorLineOpacity:1,markerIconSize:.75,markers:{from:"poi-02",to:"poi-01",stops:["waypoint-01"]},lineSymbol:{image:"east-blue-arrow-01",size:.25,spacing:1}},et="mmws-source-line-solid",ye="mmws-layer-line-solid",me="mmws-layer-icon-line-symbol",kt="mmws-source-line-dashed",se="mmws-layer-line-dashed",Dt="mmws-source-icon-connector",yr="mmws-layer-icon-connector",tt="mmws-source-icon-marker",Ht="mmws-layer-icon-marker",mr=[ye,me,se,yr,Ht],Qa=[et,kt,Dt,tt];class Za{_maplibreMap;_routeStyle=Rt;_styleDiffs={};_filterBy="venue";_curVenue=null;_curBuilding=null;_curOrdinal=null;_renderBoundaryLayer;constructor(e,i){this._maplibreMap=e,i&&(this._updateStyleProperties(i),e.on("load",()=>this._loadMarkerIcons()))}async setStyle(e){this._updateStyleProperties(e),await this._loadMarkerIcons(),await this._updateLayers()}async setMarkerIcons(e){if(Array.isArray(e)&&e.length){const i=e.slice(1,e.length-1);this._routeStyle.markers={from:e[0],to:Je(e),stops:i.length?i:[e[0]]},this._styleDiffs={markers:this._routeStyle.markers}}else"from"in e&&(this._routeStyle.markers.from=e.from,this._styleDiffs.markers.from=e.from),"to"in e&&(this._routeStyle.markers.to=e.to,this._styleDiffs.markers.to=e.to),"stops"in e&&(this._routeStyle.markers.stops=e.stops??[null],this._styleDiffs.markers.stops=e.stops??[null]);await this._loadMarkerIcons()}setMarkerIconSize(e){return this._routeStyle.markerIconSize=e,this}setIndoorLineColor(e){return this._routeStyle.indoorLineColor=e,this}setOutdoorLineColor(e){return this._routeStyle.outdoorLineColor=e,this}setDashedLineColor(e){return this._routeStyle.dashedLineColor=e,this}setBusLineColor(e){return this._routeStyle.shuttleBusLineColor=e,this}render(e,i){if(!this._renderBoundaryLayer){const d=this._maplibreMap.getStyle(),u=ot(d);let c=u.find(({type:h,id:f})=>!f.includes("-overlap-copy")&&h==="fill-extrusion");c||(c=u.find(h=>h.type==="symbol"&&h?.["source-layer"]==="mapxus_place")),this._renderBoundaryLayer=c?.id}const{instructions:r,points:{coordinates:n}}=e,{lineFeatures:s,connectorFeatures:o,dashedLineFeatures:a,markerFeatures:l}=this._classifyFeatures(r,n,i);this._renderSolidLines(s),this._renderLineSymbols(et,me),this._routeStyle.disableDashedLine!==!0&&this._renderDashedLines(a),this._renderConnectors(o),this._renderMarkers(l)}remove(){mr.forEach(e=>{this._maplibreMap.getLayer(e)&&this._maplibreMap.removeLayer(e)}),Qa.forEach(e=>{this._maplibreMap.getSource(e)&&this._maplibreMap.removeSource(e)})}setFilterByVenue(e,i){this._filterBy="venue",this._curVenue=e??null,this._curOrdinal=i??null,this._filterRouteOpacity()}setFilterByBuilding(e,i){this._filterBy="building",this._curBuilding=e??null,this._curOrdinal=i??null,this._filterRouteOpacity()}_classifyFeatures(e,i,r){const n=[],s=[],o=[],a=[],l=[];e.forEach((M,P)=>{const{venue_id:L,building_id:H,floor_id:A,ordinal:W,sign:oe,type:be,interval:[it,xe]}=M;if(el(oe))l.push(M);else if(Ja(oe)){P!==0&&P!==e.length-1&&s.push(this._createIconFeature(`connector-${s.length}`,i[it],{...K({venue_id:L,building_id:H,floor_id:A,ordinal:W}),icon:be}));const Sr=e[P+1];if(Sr){const{venue_id:sl,building_id:ol,floor_id:al,ordinal:ll}=Sr;s.push(this._createIconFeature(`connector-${s.length}`,i[xe],{...K({venue_id:sl,building_id:ol,floor_id:al,ordinal:ll}),icon:be}))}}else n.push(this._createLineFeature(`solid-line-${n.length}`,i.slice(it,xe+1),K({venue_id:L,building_id:H,floor_id:A,ordinal:W,isShuttleBus:tl(oe)?1:0})))});const d=e[0],{venue_id:u,building_id:c,floor_id:h,ordinal:f}=d,g=e[e.length-1],{venue_id:_,building_id:y,floor_id:m,ordinal:S}=g,E=i[0],C=i[i.length-1],B=r[0],b=r[r.length-1],O=r.slice(1,r.length-1);return B&&o.push(this._createLineFeature(`dashed-line-${o.length}`,[B,E],K({venue_id:u,building_id:c,floor_id:h,ordinal:f}))),b&&o.push(this._createLineFeature(`dashed-line-${o.length}`,[C,b],K({venue_id:_,building_id:y,floor_id:m,ordinal:S}))),l.length&&O.length&&l.forEach(({venue_id:M,building_id:P,floor_id:L,ordinal:H,interval:[A]},W)=>{o.push(this._createLineFeature(`dashed-line-${o.length}`,[i[A],O[W]],K({venue_id:M,building_id:P,floor_id:L,ordinal:H}))),a.push(this._createIconFeature(`marker-${a.length}`,O[W],{...K({venue_id:M,building_id:P,floor_id:L,ordinal:H,markerType:`stops_${W}`}),icon:this._routeStyle.markers.stops[W]??Je(this._routeStyle.markers.stops),iconSize:this._routeStyle.markerIconSize}))}),a.push(this._createIconFeature(`marker-${a.length}`,B??E,{...K({venue_id:u,building_id:c,floor_id:h,ordinal:f,markerType:"from"}),icon:this._routeStyle.markers.from,iconSize:this._routeStyle.markerIconSize})),a.push(this._createIconFeature(`marker-${a.length}`,b??C,{...K({venue_id:_,building_id:y,floor_id:m,ordinal:S,markerType:"to"}),icon:this._routeStyle.markers.to,iconSize:this._routeStyle.markerIconSize})),{lineFeatures:n,connectorFeatures:s,dashedLineFeatures:o,markerFeatures:a}}_createLineFeature(e,i,r){return{id:e,type:"Feature",geometry:{type:"LineString",coordinates:i},properties:r}}_createIconFeature(e,i,r){return{id:e,type:"Feature",geometry:{type:"Point",coordinates:i},properties:r}}_renderSolidLines(e){this._addCollectionSource(et,e),this._addLineLayer(et,ye,{"line-color":["case",["==",["get","isShuttleBus"],"1"],this._routeStyle.shuttleBusLineColor,["==",["get","floor_id"],null],this._routeStyle.outdoorLineColor,this._routeStyle.indoorLineColor],"line-opacity":["case",["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,1],"line-width":this._routeStyle.lineWidth})}_renderDashedLines(e){this._addCollectionSource(kt,e),this._addLineLayer(kt,se,{"line-color":this._routeStyle.dashedLineColor,"line-width":this._routeStyle.dashedLineWidth,"line-dasharray":[.1,1.8]})}_renderConnectors(e){this._addCollectionSource(Dt,e),this._addIconLayer(Dt,yr)}_renderMarkers(e){this._addCollectionSource(tt,e),this._addIconLayer(tt,Ht,{"icon-anchor":"bottom","icon-allow-overlap":!0,"icon-ignore-placement":!0})}_addCollectionSource(e,i){this._maplibreMap.addSource(e,{type:"geojson",data:{type:"FeatureCollection",features:i}})}_addLineLayer(e,i,r){this._maplibreMap.addLayer({id:i,type:"line",source:e,layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":4,...r||{}}},this._renderBoundaryLayer)}_renderLineSymbols(e,i){this._maplibreMap.addLayer({id:i,type:"symbol",source:e,layout:{"symbol-placement":"line","symbol-spacing":this._routeStyle.lineSymbol.spacing,"icon-size":this._routeStyle.lineSymbol.size,"icon-image":this._routeStyle.lineSymbol.image},paint:{"icon-opacity":["case",["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,1]}},this._renderBoundaryLayer)}_addIconLayer(e,i,r){this._maplibreMap.addLayer({id:i,type:"symbol",source:e,layout:{"icon-image":["get","icon"],"icon-size":["case",["has","iconSize"],["get","iconSize"],1],...r||{}}})}_updateStyleProperties(e){if(this._styleDiffs=br(this._routeStyle,e??Rt),!e)this._routeStyle=Rt;else if(Object.keys(this._styleDiffs).length){const i={...this._routeStyle.lineSymbol,...this._styleDiffs.lineSymbol??{}},r=this._styleDiffs.markers;let n=this._routeStyle.markers;const s={outdoorLineOpacity:(this._styleDiffs.outdoorLineOpacity>1?1:this._styleDiffs.outdoorLineOpacity<0?0:this._styleDiffs.outdoorLineOpacity)??this._routeStyle.outdoorLineOpacity},o={inactiveRouteOpacity:(this._styleDiffs.inactiveRouteOpacity>1?1:this._styleDiffs.inactiveRouteOpacity<0?0:this._styleDiffs.inactiveRouteOpacity)??this._routeStyle.inactiveRouteOpacity};r&&Object.keys(r).length&&(n={...n,...r}),this._routeStyle={...this._routeStyle,...this._styleDiffs,...s,...o,markers:n,lineSymbol:i}}}async _loadMarkerIcons(){const{markers:e,lineSymbol:i}=this._styleDiffs;if(i?.image&&await Ae(this._maplibreMap,i.image),e&&Object.keys(e).length){const{from:r,to:n,stops:s}=e;if(r&&await Ae(this._maplibreMap,r),n&&await Ae(this._maplibreMap,n),s&&s.length){const o=s.filter(a=>!!a);o.length&&await Promise.all(o.map(a=>Ae(this._maplibreMap,a)))}}}async _updateLayers(){if(!this._maplibreMap.getLayer(ye))return;const{indoorLineColor:e,outdoorLineColor:i,dashedLineColor:r,shuttleBusLineColor:n,lineWidth:s,dashedLineWidth:o,disableDashedLine:a,inactiveRouteOpacity:l,outdoorLineOpacity:d,markerIconSize:u,markers:c,lineSymbol:h}=this._styleDiffs;if((e||i||n)&&this._maplibreMap.setPaintProperty(ye,"line-color",["case",["==",["get","isShuttleBus"],"1"],this._routeStyle.shuttleBusLineColor,["==",["get","floor_id"],null],this._routeStyle.outdoorLineColor,this._routeStyle.indoorLineColor]),s!==void 0&&s+""&&this._maplibreMap.setPaintProperty(ye,"line-width",s),typeof a=="boolean"?a?this._maplibreMap.setPaintProperty(se,"line-color","transparent"):(this._maplibreMap.setPaintProperty(se,"line-color",this._routeStyle.dashedLineColor),this._maplibreMap.setPaintProperty(se,"line-width",this._routeStyle.dashedLineWidth)):this._routeStyle.disableDashedLine!==!0&&(r&&this._maplibreMap.setPaintProperty(se,"line-color",r),o!==void 0&&o+""&&this._maplibreMap.setPaintProperty(se,"line-width",o)),l!==void 0&&l+""&&this._filterRouteOpacity(),u!==void 0&&u+""&&this._maplibreMap.setLayoutProperty(Ht,"icon-size",u),c&&Object.keys(c).length){const{from:f,to:g,stops:_}=c,y=this._maplibreMap.getSource(tt),m=await y.getData();m.features=m.features.map(S=>{const{markerType:E}=S.properties;if(f!==void 0&&E==="from"&&(S.properties.icon=f),g!==void 0&&E==="to"&&(S.properties.icon=g),_&&E.includes("stops")){const C=parseInt(E.split("_")[1]);S.properties.icon=_[C]??Je(_)}return S}),y.setData(m)}if(h){const{image:f,size:g,spacing:_}=h;f!==void 0&&this._maplibreMap.setLayoutProperty(me,"icon-image",f),g!==void 0&&g+""&&this._maplibreMap.setLayoutProperty(me,"icon-size",g),_!==void 0&&_+""&&this._maplibreMap.setLayoutProperty(me,"symbol-spacing",_)}d!==void 0&&d+""&&(this._maplibreMap.setPaintProperty(ye,"line-opacity",["case",["==",["get","floor_id"],null],d,1]),this._maplibreMap.setPaintProperty(me,"icon-opacity",["case",["==",["get","floor_id"],null],d,1]),this._filterRouteOpacity())}_filterRouteOpacity(){let e;switch(this._filterBy){case"venue":e=["case",["all",["==",["get","ordinal"],this._curOrdinal??""],["==",["get","venue_id"],this._curVenue??""]],1,["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,this._routeStyle.inactiveRouteOpacity];break;case"building":e=["case",["all",["==",["get","ordinal"],this._curOrdinal??""],["==",["get","building_id"],this._curBuilding??""]],1,["==",["get","floor_id"],null],this._routeStyle.outdoorLineOpacity,this._routeStyle.inactiveRouteOpacity];break}mr.forEach(i=>{this._maplibreMap.getLayer(i)&&this._maplibreMap.setPaintProperty(i,i.includes("layer-line")?"line-opacity":"icon-opacity",e)})}}function K(t){return Object.fromEntries(Object.entries(t).map(([e,i])=>[e,Number.isFinite(i)?i+"":i]))}function Ja(t){return t===100||t===-100}function el(t){return t===5}function tl(t){return ar(t,104,108)}function br(t,e){const i={};for(const r in e){const n=t[r],s=e[r];if(r==="markers"||r==="lineSymbol")if(Array.isArray(s)){const o=s.slice(1,s.length-1);i[r]={from:s[0],to:Je(s),stops:o.length?o:[s[0]]}}else{const o=br(n,s);Object.keys(o).length&&(i[r]=o)}else s+""!=n+""&&(i[r]=r==="stops"?s??[null]:s)}return i}var Nt=(t=>(t.FOOT="foot",t.WHEELCHAIR="wheelchair",t.ESCALATOR="escalator",t.EMERGENCY="emergency",t))(Nt||{});const il=D.getInstance();class rl{constructor(){}async search(e){const{points:i,vehicle:r=Nt.FOOT,locale:n="en"}=e;if(!(i&&i.length>1&&i.length<6))throw new Error("Parameter error. It must be 1 < {points.length} < 6");if(nl(i))throw new Error("Parameter error. Points must have lat and lon.");return(await il.getHttpSession()).request(Br,{method:"POST",body:JSON.stringify({points:i,vehicle:r,locale:n})})}}function nl(t){return t.some(e=>!e||typeof e.lat!="number"||typeof e.lon!="number")}p.ASSISTANT_LAYER_INDOOR_FLOORS=ve,p.ASSISTANT_LAYER_SHARED_FLOORS=T,p.BuildingFilterControl=nr,p.BuildingSelectorHandler=ur,p.BuildingsService=ti,p.DistanceSearchType=Wt,p.ERRORS=Vt,p.FloorSelectorHandler=cr,p.FloorSwitchScope=De,p.FloorsControl=lr,p.Indoor=Zi,p.IndoorClickSelection=fr,p.Map=Wa,p.Marker=Xa,p.OFFSET=R,p.OrientationDistanceSearchType=dt,p.OutdoorClickSelection=pr,p.PAGE=k,p.Poi=ir,p.PoisOrderBy=Yt,p.PoisService=Qt,p.PoisSortBy=Xt,p.PresetLanguage=x,p.RoutePainter=Za,p.RouteService=rl,p.SwitchBuildingHandler=hr,p.SwitchOutdoorHandler=_r,p.ThemeType=Mt,p.VERSION=rt,p.VehicleType=Nt,p.VenuesService=Jt,p.convertBrowserLangToPresetLang=qt,p.omittedBuildingProps=ei,p.omittedPoiProps=ut,p.omittedVenueKeys=Zt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
Binary file
Binary file