r.bing.com
Open in
urlscan Pro
2a02:26f0:3500:1b::1724:a392
Public Scan
URL:
https://r.bing.com/rp/Tuynh8AGDktN6S4GYnjjdLWpWf0.br.js
Submission Tags: falconsandbox
Submission: On November 21 via api from US — Scanned from DE
Submission Tags: falconsandbox
Submission: On November 21 via api from US — Scanned from DE
Form analysis
0 forms found in the DOMText Content
(function(){var vt,ft,n;try{var i=window.$MicrosoftMaps8,t=i.Internal,ai=i.Anchor,ot=Microsoft.Maps.Internal._BaseMapDataSource,o=t._BaseMapTemplateSelector,y=t.CanvasDrawingContext,c=i.CoordinateProjection,u=t._Debug,e=t._EntityHelper,vi=i.G,p=i.GlobalConfig,w=t._Gimme,f=t._Helper,kt=t.HitTestIndex,s=t._JSEvent,g=p.features.labels,nt=t._LatLonCrs,dt=t._LayerDataSource,yi=i.LocationRect,st=t._MapFrameData,ht=i.Location,b=i.Matrix2D,pi=t.MapHelper,gt=i.MapMath,wi=i.MapTypeId,ni=i.MercatorCubeCrs,ti=t._Observable,ii=t._ObservableObject,r=i.Point,h=i.Rectangle,ct=t.RegionIndex,ri=i.SimpleLinePrimitive,bi=i.SimplePointPrimitive,tt=i.Size,ui=i.Viewport,it=i.ZoomLevel,ki=t.Iterator,di=t._Network,nt=t._LatLonCrs,lt=t._NAARectangle,fi=i.VectorImageTemplate,ei=i.VectorMapLayer,rt=t._VectorMath,gi=t._WorkDispatcher,nr=t._LayerRendererManager,l=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}if(typeof i!="function"&&i!==null)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),a=function(){function t(n){this.data=n;this._padding=t._defaultPadding;this.id=n.labelId;this.lastUsedRegions=[];this.reset()}return t.prototype.reset=function(){this.placedRegions=[];this.placementPriority=Number.MAX_VALUE;this.shouldBeRendered=!0;this.regions=[];this.positionInitialized=!1},t.getIconBounds=function(n,t){var r=h.empty(),i,u;if(n)for(i=0,u=n.length;i<u;i++)n[i]&&r.union(n[i].getBounds(t));return r},t.prototype.lastUsedRegion=function(n){for(var r,i=0,u=this.lastUsedRegions.length;i<u;i++)if(r=this.lastUsedRegions[i],t._regionsMatch(r,n))return r;return n},t._regionsMatch=function(n,t){var i=n.bounds.getBoundingBoxRelativeTo(n.anchor),r=t.bounds.getBoundingBoxRelativeTo(t.anchor);return i.equals(r,.5)},t.prototype.initializePosition=function(n,t){var i,r;this.positionInitialized||(this._initializeLabelRegions(n,t),i=this.data.style&&this.data.style.styleStatic.strataStyle,i&&i.alpha&&i.alpha<v.collisionAlphaThreshold&&this.regions.length&&(r=this.regions[0],r.isFixed=!0),this._initBounds(n),this.positionInitialized=!0)},t.prototype._computeFontSize=function(n,t,i,r,u){var f=n/t,e=i/f;return gt.roundToInterval(Math.min(r,e)/u,.1)},t.getLabelOrigin=function(t,i,u,f){var e,o;f=f||n.topRight;u=u||{x:0,y:0};switch(f&n.horizontalMask){case n.left:e=-t;break;case n.center:e=-t/2;break;default:case n.right:e=0}switch(f&n.verticalMask){default:case n.top:o=-i;break;case n.middle:o=-i/2;break;case n.bottom:o=0}return new r(e+u.x,o+u.y)},t.prototype._initRegionBounds=function(n,i,u){var f=i.size;f||(u||(u=this._measureLabel()),f=u);var o=f.height,s=f.width,a=i.anchor,e=t.getLabelOrigin(s,o,i.anchorOffset,i.placement),v=new r(e.x+s,e.y+o),c=new h(e,v),l=Math.max(this.data.lowImportanceCollisionPadding/4,this._padding)||this._padding;return c.buffer(l,l),i.bounds=new ft(i.anchor,new lt(c,i.orientation,a)),u},t.prototype._initBounds=function(n){for(var t,r,i=0,u=this.regions.length;i<u;i++)(t=this.regions[i],n.normalize(t.anchor),t.anchorTransform=b.identity,t.bounds===undefined)&&(r=this._initRegionBounds(n,t,r))},t.prototype.getRegions=function(){if(!this.positionInitialized)throw new Error("Invalid operation: initializePosition must be called before getRegions");return this.regions},t.prototype._measureLabel=function(){this.lineWidths=[];var n=this.data;return k.getTextSize(n.text,n.secondaryText,n.style,n.fontSize,n.secondaryFontSize,this.lineWidths)},t.prototype._hasBackground=function(){var n=this.data.style.styleStatic;return n.showBackground&&!!(n.backgroundColor||n.backgroundOutlineColor&&n.backgroundOutlineWidth)},t.prototype._initializeLabelRegions=function(){},t.prototype._getRegionsFromHints=function(i,u,f,e,o,s){for(var rt,v,w,k,ct,g,h,nt,ft,et,p,lt,tt,ot,st=[],ht={},a=null,it=0,at=this.data.primitives.length;it<at;it++)if(rt=this.data.primitives[it],v=rt.entity.labelHint,v&&v.lbl&&st.indexOf(v)===-1){for(w=null,a||(a=[]),k=0,ct=v.lbl.length;k<ct;k++){var ut=v.lbl[k],d=[],vt=ut.tps&&ut.tps.length,y=f,l=null;for(g=0;g<vt;g++)(h=ut.tps[g],!!h.n!=!!e)&&(typeof s!="number"||typeof h.esi!="number"||s===h.esi-1)&&(l||(nt=new c(rt.crs,i),nt.project(h.x||0,h.y||0),l=new r(nt.lastProjectedX,nt.lastProjectedY),i.normalize(l),y||(ft=l.x,et=l.y,h.n&&(p=new r(h.w/2,h.h/2),h.a&&(lt=b.identity.rotate(h.a),p=lt.transform(p)),ft+=p.x,et+=p.y),y=new r(ft,et))),d.push(h));d.length&&(tt=d[0],ot=(tt.n||"")+y.x.toFixed(2)+","+y.y.toFixed(2),ht[ot]||(ht[ot]=!0,w={label:this,text:this.data.text,anchor:y.clone(),anchorOffset:new r(l.x-y.x,l.y-y.y),parentRegion:o,textSpans:d,placement:tt.n?undefined:n.middleCenter},f&&l.x+tt.w<f.x&&(w.horizontalAlignment=2),a.push(w)))}st.push(v)}return a&&a.length&&(this._setReplicaProximityForLabelHints(),t._computeRegionBoundsBasedOnLabelHints(a)),a},t.prototype._setReplicaProximityForLabelHints=function(){this.replicaProximity=1},t._computeRegionBoundsBasedOnLabelHints=function(n){for(var t,f,c,i,o,l,u=0,s=n.length;u<s;u++)if(t=n[u],t.textSpans){var e=new ft(t.anchor),a=t.textSpans[0].x,v=t.textSpans[0].y;for(f=0,c=t.textSpans.length;f<c;f++)i=t.textSpans[f],i.n&&(o=new tt(i.w,i.h),l=new r(t.anchor.x+t.anchorOffset.x+(i.x-a),t.anchor.y+t.anchorOffset.y+(i.y-v)),e.add(new lt(new h(new r(0,0),new r(o.width,o.height)),i.a,l)));e.bbox.isEmpty()||(t.bounds=e)}},t._defaultPadding=2,t}(),at=function(t){function u(n){return t.call(this,n)||this}return l(u,t),u.prototype._largestAreaPrimitiveItem=function(n){for(var r=-1,u=0,t=0,e=n.length;t<e;t++){var i=n[t].geometry,o=Math.abs(i.bounds[1]-i.bounds[3]),s=Math.abs(i.bounds[2]-i.bounds[0]),f=o*s;f>r&&(r=f,u=t)}return u},u.prototype._initializeRegionsAtCentroid=function(t,u,f,e){function g(n){return typeof n.length=="undefined"}var w=i.SpatialMath,a=w&&w.Geometry,o,h,k,s,d;if(a){o=void 0;try{o=a.centroid(u)}catch(rt){}if(o){var b=u.crs,tt=new ri([new ht(o.latitude,b.toLongitude(e.bounds[3],e.bounds[2])),new ht(o.latitude,b.toLongitude(e.bounds[1],e.bounds[0]))],null,null,!1),y=a.intersection(u,tt);if(y&&g(y)){h=void 0;f.project(e.bounds[3],e.bounds[2]);k=f.lastProjectedY;u.crs!==nt.instance&&(f=new c(nt.instance,t));f.project(o.longitude,o.latitude);h=new r(f.lastProjectedX,f.lastProjectedY);s=y.geometry.bounds;f.project(s[3],s[2]);d=f.lastProjectedX;f.project(s[1],s[0]);var it=f.lastProjectedX,p=it-d,l=this._measureLabel();l.width/p>1.1&&(this.data.text=v.wrapTextToFit(this.data.text,l,{width:p,height:0},3),this.data.text.indexOf("\n")>0&&(l=this._measureLabel()));l.width/p<=1.2&&this.regions.push({label:this,text:this.data.text,anchor:h,horizontalAlignment:0,placement:n.middleCenter,orientation:0});this.regions.push({label:this,text:this.data.text,anchor:new r(h.x,k),anchorOffset:new r(0,8),horizontalAlignment:0,placement:n.bottomCenter,orientation:0})}}}},u.prototype._initializeRegionsWithBounds=function(t,i,u){var o,s,a;i.project(u.bounds[3],u.bounds[2]);o=i.lastProjectedX;s=i.lastProjectedY;i.project(u.bounds[1],u.bounds[0]);var c=i.lastProjectedX,l=i.lastProjectedY,e=c-o,h=s-l,f=this._measureLabel();f.width/e>=1.3&&(this.data.text=v.wrapTextToFit(this.data.text,f,{width:e,height:h},3),this.data.text.indexOf("\n")>0&&(f=this._measureLabel()));f.width/e>=1.3||f.height/h>=1.3||f.width*f.height/(e*h)>=1.3?this.shouldBeRendered=!1:(a=new r((o+c)/2,(s+l)/2),this.regions.push({label:this,text:this.data.text,anchor:a,horizontalAlignment:0,placement:n.middleCenter,orientation:0}))},u.prototype._getRegionsFromVenueRects=function(t,i){for(var f,l,a,e,it,ut,v=i.labelRects,y=this._measureLabel(),h=ni.instance,u=new c(h,t),p=[],o=0,w=v.length;o<w;o++)if(f=v[o],f){var s=f.xy,ft=h.projectToX(s[1],s[0]),et=h.projectToY(s[1],s[0]),b=f.width||0,k=f.height||0,d=et+k/2,g=ft-b/2;u.project(g,d);l=u.lastProjectedY;a=u.lastProjectedX;u.project(g+b,d-k);var nt=u.lastProjectedY,tt=u.lastProjectedX,ot=Math.abs(tt-a),st=Math.abs(l-nt);if((!(o<w-1)||!(st<y.height||ot<y.width))&&(e=(f.angle||0)%360,e<0&&(e+=360),!(e>60)||!(e<270))){it=rt.degreesToRadians(-e);ut={label:this,text:this.data.text,anchor:new r((a+tt)/2,(l+nt)/2),orientation:it,placement:n.middleCenter,horizontalAlignment:0};p.push(ut);this._padding=.5;break}}return p},u.prototype._initializeLabelRegions=function(n,t){var u=this.data.primitives&&this.data.primitives[0],f=u&&u.entity,e,i;if((this.regions=f.labelRects?this._getRegionsFromVenueRects(n,f,u):this._getRegionsFromHints(n,t),!this.regions)&&(this.regions=[],!f.labelRects)){e=0;i=this.data.primitives;i.length>1&&(e=this._largestAreaPrimitiveItem(i));var r=i[e],o=new c(r.crs,n),s=r.geometry;this._initializeRegionsAtCentroid(n,r,o,s);this.regions.length||this._initializeRegionsWithBounds(r,o,s)}},u}(a),ut=function(){function t(){this.labelRenderingComplete=new s}return t.prototype.beginDraw=function(){},t.prototype.endDraw=function(){},t.prototype.clear=function(){},t.prototype.cancelRender=function(){},t.prototype.draw=function(){return!1},t.prototype.remove=function(){return!1},t.prototype.update=function(){return!1},t.prototype.transformContainer=function(){return!1},t.prototype.invalidateHitTestingData=function(){},t.prototype.performHitTesting=function(){return!1},t.prototype.dispose=function(){f._disposeEvents(this)},t._getTextAnchorOffset=function(i,u){var c=u.width,s=u.height,f=i.region,h=f.placement,l=h&n.horizontalMask||n.right,a=t._horizontalTextAnchorFactor[n[l]],v=c*(a[f.horizontalAlignment]||0),o=0,e;switch(h&n.verticalMask){default:case n.top:o=-s;break;case n.middle:o=-s/2;break;case n.bottom:}return e=new r(v,o),f.anchorOffset&&(e=e.add(f.anchorOffset)),e},t._horizontalTextAnchorFactor={left:[-.5,-1,0],center:[0,-.5,.5],right:[.5,0,1]},t}(),k=function(i){function o(n,t,r,u,f){var e=i.call(this)||this;return e._mapEvents=[],e._taintedTemplatesExists=!1,e._map=n,e._dpiScale=t,e._canvasId=r?r:"labelCanvasId",e._canvasZIndex=u,e._renderEntityTypes=f,e._addCanvas(),e._positionCanvas(!1),e._hitTestIndex=new kt,e._labelOptions=n.getMapOptions().labelOptions,e._orderedLabels={},e}return l(o,i),o.init=function(){if(typeof p!="undefined"){var t=p.dynamicProperties&&p.dynamicProperties.uiLanguage||"",n=t.split("-")[0].toLowerCase(),i=g.nonItalicLabelLanguages||"",r=i.toLowerCase().split(",");n&&r.indexOf(n)>=0&&(o._nonItalicMarket=!0)}},o.prototype.transformContainer=function(n){if(this._validate2DCanvas()){var t=this._lastAnchorPointOfLabelCanvas=n.transform(new r(0,0)),i="translate("+t.x+"px,"+t.y+"px)";this._canvas.set_style({"-webkit-transform":i,transform:i})}return!0},o.prototype.dispose=function(){this._map=null;this._canvas&&this._canvas.clear();this._canvas=null;this._drawingContext&&(this._drawingContext.dispose(),this._drawingContext=null);this._hitTestIndex=null;this._context=null;this._orderedLabels=null;this._mapEvents.forEach(function(n){n.dispose()});i.prototype.dispose.call(this)},o.prototype.beginDraw=function(n,t){if(this._currentLabelRenderingContext=n,!f._renderAllPoiAndLabelsGL()){var i=this._drawingContext;i?(this._positionCanvas(t),i.save()):u.log(null,"Canvas context hasn't been created")}},o.prototype.copyCanvas=function(n){var t=this._drawingContext,i;t&&this._validate2DCanvas()&&(this._lastAnchorPointOfLabelCanvas=this._lastAnchorPointOfLabelCanvas||new r(0,0),i=t.getSize(),n.drawImage(t.getRootElement()[0],this._lastAnchorPointOfLabelCanvas.x-this._widthPadding,this._lastAnchorPointOfLabelCanvas.y-this._heightPadding,i.width,i.height),this._lastAnchorPointOfLabelCanvas=null)},o.prototype.endDraw=function(n,t){var u=this,i,r;n&&(i=this._validate2DCanvas(),r=this._drawingContext,r||!i)&&(this._drawLabels(!1,t,n.frame),Microsoft.Maps.setAsync(function(){u.labelRenderingComplete&&u.labelRenderingComplete.invoke({labelRenderingContext:n,delayedRenderingTime:0})}),i&&r.restore())},o.prototype._drawLabels=function(n,t,i){var f=this._orderedLabels,r,l,e,s,h,a;if(f){var c=o._getSortedPriorityKeys(Object.keys(f)),w=this._drawingContext,b=this._dpiScale;for(u.clearTestHooksLog(u.LabelDrawOrderTag),r=0,l=c.length;r<l;r++){if(e=f[c[r]],s=Object.keys(e),!s.length){delete f[c[r]];continue}for(h=0,a=s.length;h<a;h++){var v=s[h],y=e[v],p=Object.keys(y);p.length?this._drawLabelsInLayer(y,p,n,t,w,b,i):delete e[v]}}}},o.prototype._renderHitTesting=function(n,t,i,r){var c=n[0].getHitTestShape(),o={primitive:t,target:i.independentHotRegions?1:0},s=r.bounds.getBoundingBoxRelativeTo(r.anchor),h=s.getSize(),u=s.minPoint,f=h.width,e=h.height;switch(c){case 2:this._hitTestIndex.addRectangle(o,u.x,u.y,f,e);break;case 1:this._hitTestIndex.addEllipse(o,u.x+f/2,u.y+e/2,f,e)}},o.prototype._drawLabelsInLayer=function(n,t,i,r,f,o){for(var h,a,w,p,b,l,v=t.length-1;v>=0;v--){h=n[t[v]];u.logLabelDrawOrder(h.text);var y=h.region,s=y.label.data.primitives[0],c=h.iconTemplates;if(!i||(l=c&&c[0],a=!1,s&&(a=e.getClickable(s.entity)||s.isTapEnabled&&s.isTapEnabled()),a||(a=l&&l.getIsHitTestable()),a&&s&&s.layer))if(y.type===1){if(w=y.anchor,!c||!c.length)continue;if(i)this._renderHitTesting(c,s,h,y);else{for(u.logPoiLayerStyleStart(),p=0,b=c.length;p<b;p++)l=c[p],l.renderCanvas(f,{id:null,name:h.text},w.x*o,w.y*o,o,u.UserLogTag,s);u.logPoiLayerStyleEnd(u.UserLogTag);u.logPushpinPrimitive(u.UserLogTag,s)}}else h.style&&this._drawTextLabel(h,i,r)}},o.prototype.cancelRender=function(){this._currentLabelRenderingContext=null},o.prototype.draw=function(n){var u=this._acceptRenderable(n),r,t,i;return u&&this._orderedLabels&&(n.drawPriority=Math.round((n.fontSize||0)*1e3),r=o._labelKey(n),t=this._orderedLabels[r],t||(t={},this._orderedLabels[r]=t),i=t[n.labelZIndex],i||(i={},t[n.labelZIndex]=i),i[n.id]=n,n.oldLabelZIndex=n.labelZIndex),u},o.prototype.remove=function(n){var r=this._acceptRenderable(n),t,i;return r&&this._orderedLabels&&(t=this._orderedLabels[o._labelKey(n)],i=t&&t[n.oldLabelZIndex],i&&delete i[n.id]),r},o.prototype.update=function(n){var u=this._acceptRenderable(n),t,i,r;return u&&this._orderedLabels&&(i=this._orderedLabels[o._labelKey(n)],r=i&&i[n.oldLabelZIndex],r&&(t=r[n.id]),t&&(this.remove(t),this.draw(n))),u},o._size=function(n){var t=n.size,i;if(!t){i=n.region&&n.region.type||0;switch(i){case 1:t=a.getIconBounds(n.iconTemplates,n.text).getSize();break;default:t=o.getTextSize(n.text,n.secondaryText,n.style,n.fontSize,n.secondaryFontSize,n.lineWidths)}t&&t.width&&t.height&&(n.size=t)}return t},o._labelKey=function(n){return(n.layerZIndex||0)*1e6+n.drawPriority},o._getSortedPriorityKeys=function(n){for(var u,e=0,o=!0,i,t=0,r=n.length;t<r;t++){if(i=parseInt(n[t]),i<e){o=!1;break}e=i}if(o)return n;for(u=[],t=0,r=n.length;t<r;t++)f._orderedInsert(u,n[t],null,function(n){return parseInt(n)});return u},o.getTextSize=function(n,t,i,r,u,f){function l(n,t){var u,l,r,p,v;if(n)for(u=o.createFont(t,i),s=s||y.getLineHeight(u),l=n.split("\n"),h.setFont(u),r=0,p=l.length;r<p;r++)v=a.measureText(l[r]).width,f&&f.push(v),e=Math.max(e,v),c+=s}var h=o._scratchContext,a=h.getRawContext(),e=0,c=0,s=0;return f&&(f.length=0),l(n,r),l(t,u),new tt(e,c)},o.prototype.invalidateHitTestingData=function(){this._hitTestIndexValid=!1},o.prototype.performHitTesting=function(n,t){if(!this._hitTestIndex)return!1;this._hitTestIndexValid||this._renderHitTestData();var i=this._hitTestIndex.hitTest(t),r=!1;return i&&i.primitive&&(n.primitive=i.primitive,n.hitTarget=i.target,n.layer=i.primitive.layer,r=!0),r},o.prototype._addCanvas=function(){var n,t;this._require2DCanvas()&&!this._drawingContext&&(this._drawingContext=new y,n=this._canvas=this._drawingContext.getRootElement(),n.set_attr("id",this._canvasId==="labelCanvasId"?this._canvasId:this._canvasId+"2d"),n.set_attr("class","labelCanvas"),n.set_style({outline:"none",position:"absolute",zIndex:this._canvasZIndex}),t=this._map.getMode().getRootElement(),t.append(n),this._context=this._drawingContext.getRawContext())},o.prototype._positionCanvas=function(n){var t=this._map.getActualSize(),u,i;if(this._require2DCanvas()){u=this._map.getMapOptions();i=300;u.isPrintMode?i=0:(u.liteMode||f._getDpr()>1)&&(i=100);var e=this._widthPadding=Math.min(i,Math.ceil(.75*t.width)),o=this._heightPadding=Math.min(i,Math.ceil(.75*t.height)),r=this._dpiScale,s=t.width+2*e,h=t.height+2*o;this._drawingContext.setSize(r*s,r*h);n||this._canvas.set_style({top:-o+"px",left:-e+"px","-webkit-transform":"translate(0px, 0px)",transform:"translate(0px, 0px)",display:"block"});this._context.translate(r*e,r*o)}else this._canvas&&this._canvas.set_style({display:"none"});return t},o.prototype._renderHitTestData=function(){var n,t,i;this._validate2DCanvas()?(t=this._drawingContext,n=t.getSize(),i=this._dpiScale,this._hitTestIndex.reset(n.width/i,n.height/i),t.save(),this._drawLabels(!0),t.restore()):(n=this._map.getActualSize(),this._hitTestIndex.reset(n.width,n.height),this._drawLabels(!0));this._hitTestIndexValid=!0},o.prototype._renderTextLabel=function(n,t,i,r,u){var f=n.region,e=this._drawingContext,p=!u&&e.getRawContext(),s=n.style,h=r,a,c,y=!1,v={labels:[]},l,w;c=f.textSpans&&f.textSpans.length>0?o.createFont(f.textSpans[0].f*h,s):o.createFont(n.fontSize*h,s);u||e.setFont(c);l=f.horizontalAlignment;switch(l){default:case 1:a="left";break;case 0:a="center";break;case 2:a="right"}return u||(p.textAlign=a),f.textSpans?this._drawTextWithHints(p,n,c,h,l,s,t,i,u,v):u?this._drawTextWithoutHints(e,n,f,c,h,l,s,t,i,u,v):(e.save(),w=this._drawTextWithoutHints(e,n,f,c,h,l,s,t,i,u,v),y=y||w,e.restore(y)),v},o.prototype._getTextLabelData=function(n,t,i,r){return this._renderTextLabel(n,t,i,r,!0)},o.prototype._drawTextLabel=function(n,t,i){this._renderTextLabel(n,t,i,this._dpiScale,!1)},o.prototype._drawTextWithHints=function(t,i,r,u,f,e,s,h,c,l){var it=i.region,y=it.textSpans,st=y[0].x,ht=y[0].y,rt=e.styleStatic,ct=e.styleDynamic,b,k,lt=!c&&t.font,ut=!1,g=y[0].f,ft=r,p,et,v,d,a,nt,ot,w,tt;for(rt.fontOutlined&&(b=ct.outlineColor,k=rt.outlineWidth*u),p=0,et=y.length;p<et;p++)v=y[p],d=!1,v.n&&(a=o._prepareTextRenderingResult(f,e,i,p,v,st,ht,b,k,u),s?(nt=it.label.data,ot={primitive:nt.primitives[0],target:nt.independentHotRegions?2:0},this._hitTestIndex.addRectangle(ot,a.x,a.y,a.w,a.h)):(a.x*=u,a.y*=u,a.relativePlacement=n.bottom,d=v.f&&v.f!==g,d&&(g=v.f,ft=o.createFont(g*u,e)),a.font=ft,c||(w=a.x,tt=a.y,f===0?w+=u*(a.w/2):f===2&&(w+=u*(a.w-3)),t.textBaseline=a.textBaseline,d&&(ut=!0,t.font=a.font),a.rotation!==0?(t.save(),t.translate(w,tt),t.rotate(a.rotation),o._strokeAndFillText(t,e,v.n,0,0,h,null,null,b,k),t.restore()):o._strokeAndFillText(t,e,v.n,w,tt,h,null,null,b,k)),l.labels.push(a)));!c&&ut&&(t.font=lt)},o.prototype._drawTextWithoutHints=function(t,i,r,u,f,e,s,h,c,l,a){function kt(t,u,y){for(var g,d,ut,ft,gt,kt,vt,dt=t?t.split("\n"):[],wt=0,ti=dt.length;wt<ti;wt++,at++){if(g=dt[wt],(h||l)&&(d=bt[at]||o.getTextSize(g,"",s,i.fontSize,0).width),h){bt[at]=d;ut=0;ft=-2;switch(r.horizontalAlignment){case 0:ut=-d/2;break;case 2:ut=-d}switch(rt){case n.middle:ft=-p/2;break;case n.top:ft=-p+2}gt={primitive:r.label.data.primitives[0],target:u};ni.addRectangle(gt,ut+w.x+b.x,ft+w.y+b.y+lt,d,p)}else kt=f*lt,l||o._strokeAndFillText(v,s,g,0,kt,c,nt,et,k,tt),vt=ot,e===0?vt-=f*d/2:e===2&&(vt-=f*d),a.labels.push({style:s,text:g,anchorOffetX:ht,anchorOffetY:ct+kt,x:vt,y:st,w:d,h:p,rotation:r.orientation,relativePlacement:rt,font:y,outlineColor:k,outlineSize:tt,glowColor:nt,glowSize:et,background:pt,horizontalAlignment:e,resetFont:it,textBaseline:yt});lt+=p}}var v=!l&&t.getRawContext(),dt=o._size(i),p=y.getLineHeight(u)/f,w=r.anchor,b=ut._getTextAnchorOffset(i,dt),it=!1,rt=r.placement&n.verticalMask,vt=o._getVerticalAdjustment(rt),yt=vt.textBaseline,wt,ot,st,ht,ct;b.y+=p*vt.verticalAdjustmentRatio;l||(v.textBaseline=yt);var d=s.styleStatic,gt=s.styleDynamic,ft=d.showBackground,g=this._labelOptions,nt,et,k,tt,pt=null;this._labelOptions.testRenderStyles&&ft?(nt=g.glowColor,et=nt&&g.glowSize,k=g.outlineColor,tt=k&&g.outlineSize*f,ft=!1):d.fontOutlined&&(k=gt.outlineColor,tt=(d.outlineWidth||1)*f);!h&&ft&&(wt=r.bounds.getBoundingBoxRelativeTo(w),pt=o._renderTextBackground(v,f,d,wt,l));ot=f*w.x;st=f*w.y;l||v.translate(ot,st);!l&&r.orientation&&v.rotate(r.orientation);ht=f*b.x;ct=f*b.y;l||v.translate(ht,ct);var lt=0,bt=i.lineWidths=i.lineWidths||[],at=0,ni=this._hitTestIndex;return kt(i.text,i.independentHotRegions?2:0,u),i.secondaryText&&(u=o.createFont(i.secondaryFontSize*f,s),l||t.setFont(u),it=!0,kt(i.secondaryText,i.independentHotRegions?3:0,u)),it},o.prototype._require2DCanvas=function(){return this._renderEntityTypes.indexOf(1)>-1&&(!f._renderAllPoiAndLabelsGL()||this._taintedTemplatesExists)},o.prototype._validate2DCanvas=function(){var n=this._require2DCanvas();return n&&!this._canvas&&(this._addCanvas(),this._positionCanvas(!1)),n},o.prototype._acceptRenderable=function(n){function u(){return r.type===1||!!n.style}var i,r=n.region;try{i=this._renderEntityTypes.indexOf(2)>-1?t._MicroPoiEntity&&r.label.data.primitives[0].entity instanceof t._MicroPoiEntity:u()}catch(f){i=u()}return i},o._strokeAndFillText=function(n,t,i,r,u,f,e,o,s,h){i=t.styleDynamic.fontCaps===1&&i.toLocaleUpperCase?i.toLocaleUpperCase():i;var c=n.lineWidth,l=n.strokeStyle;f||(e&&o&&(n.shadowColor=e,n.shadowBlur=o),s&&h&&(n.strokeStyle=s,n.lineWidth=h,n.strokeText(i,r,u)));n.fillStyle=t.styleDynamic.fontColor;t.styleStatic.strataStyle&&t.styleStatic.strataStyle.alpha&&t.styleStatic.strataStyle.alpha<1&&(n.globalAlpha=t.styleStatic.strataStyle.alpha);n.fillText(i,r,u);n.globalAlpha=1;n.lineWidth=c;n.strokeStyle=l;n.shadowBlur=0},o.createFont=function(n,t){var i=t.styleDynamic,s=i.fontStyle===1&&!o._nonItalicMarket?"italic":"",h=i.fontCaps===2?"small-caps":"",r="",u=i.font,f,e;if(i.fontWeight)switch(i.fontWeight){case 4:r="bold";break;case 1:r="lighter";break;case 3:u.toLowerCase()!=="segoebing"&&(r="600")}return f=n+"pt",e=fi.getDefaultFontFamily(u),[s,h,r,f,e].join(" ")},o._prepareTextRenderingResult=function(n,t,i,r,u,e,s,h,c,l){var v=i.region,p=v.anchor.x+v.anchorOffset.x+(u.x-e),rt=v.anchor.y+v.anchorOffset.y+(u.y-s),b=i.lineWidths||[],y=parseFloat(u.w),a=y,nt,k,tt,d,it;if(g.useSegoeFontStack||(b[r]||(nt=t.styleDynamic.fontCaps===1&&u.n.toLocaleUpperCase?u.n.toLocaleUpperCase():u.n,k=o.getTextSize(nt,"",t,u.f,0).width,k+=w.Browser.is_safari&&l>1?10:0,b[r]=Math.max(a,k)),a=b[r]),a!==y)switch(n){case 2:p-=a-y;break;case 0:p-=(a-y)/2}return tt=(w.Browser.is_edge||w.Browser.is_ie||w.Browser.is_safari)&&f._renderAllPoiAndLabelsGL()?o._size(i).height:parseFloat(u.h),d=parseFloat(u.a),it=isNaN(d)?0:d,{style:t,text:u.n,x:p,y:rt,anchorOffetX:0,anchorOffetY:0,w:a,h:tt,rotation:it,outlineColor:h,outlineSize:c,font:null,horizontalAlignment:n,resetFont:!1,textBaseline:"top"}},o._renderTextBackground=function(n,t,i,r,u){var h=i.backgroundColor,c=i.backgroundOutlineColor,l=i.backgroundOutlineWidth*t,f=Math.floor(r.minPoint.x),e=Math.floor(r.minPoint.y)+2,o=Math.ceil(r.maxPoint.x-f),s=Math.ceil(r.maxPoint.y-e);return f*=t,e*=t,o*=t,s*=t,u||(h&&(n.fillStyle=h,n.fillRect(f,e,o,s)),c&&l&&(n.strokeStyle=c,n.lineWidth=l,n.strokeRect(f,e,o,s))),{bound:r,scale:t,styleStatic:i}},o._getVerticalAdjustment=function(t){var i,r;switch(t){default:case n.bottom:i="top";r=0;break;case n.middle:i="middle";r=.5;break;case n.top:i="bottom";r=1}return{textBaseline:i,verticalAdjustmentRatio:r}},o._scratchContext=new y,o}(ut);k.init();vt=function(){function n(){this._index=new ct;this._occludedIndex=new ct}return n.prototype.reset=function(n,t){this._index.reset(n,t);this._occludedIndex.reset(n,t)},n.prototype.addLabels=function(t){for(var r,e,f,c,i,o,s,l,u=0,h=t.length;u<h;u++)if(r=t[u],r.shouldBeRendered)for(e=r.getRegions(),f=0,c=e.length;f<c;f++)(i=e[f],i.id=i.id||n._regionId++,!i.isFixed||(o=!0,i.type===1&&(s=r.data.primitives[0].layer,o=s&&ti.getValue(s,"renderTarget")!==0),o&&r.placedRegions.push(i),i.occludesOthers))&&(l=i.occludesOthers?this._occludedIndex:this._index,l.add(i,i.bounds.bbox))},n.prototype.addRenderables=function(n){for(var i,t=0,r=n.length;t<r;t++)i=n[t].region,this._index.add(i,i.rect)},n.prototype.getOverlappingRegions=function(n){return this._getOverlappingRegions(n,this._index)},n.prototype.getOverlappingOccludedRegions=function(n){return this._getOverlappingRegions(n,this._occludedIndex)},n.prototype._getOverlappingRegions=function(n,t){for(var i,f,r=n.rect,e=t.getOverlappingRegions(r||n.bounds.bbox),o=[],s={},u=0,h=e.length;u<h;u++)i=e[u],s[i.id]||(f=!1,i.isRejected||i.label.id===n.label.id||(f=r?r.intersects(i.rect):n.bounds.intersects(i.bounds)),f&&o.push(i),s[i.id]=!0);return o},n.prototype.getRegions=function(n,t){return this._index.getRegions(n,t)},n.prototype.getHeight=function(){return this._index.getHeight()},n.prototype.getWidth=function(){return this._index.getWidth()},n._regionId=0,n}();ft=function(){function n(n,t){this.bbox=h.empty();this.setAnchor(n);this.bounds=[];t&&this.add(t)}return n.prototype.add=function(n){this.bounds.push(n);this.bbox.union(n.bbox);this._refreshArbb()},n.prototype.getBoundingBoxRelativeTo=function(n){var t=this.anchorRelativeBoundingBox;return n&&!t.isEmpty()&&(t=new h(t.minPoint.add(n),t.maxPoint.add(n))),t},n.prototype.setAnchor=function(n){this.anchor=n&&n.clone();this._refreshArbb()},n.prototype._refreshArbb=function(){var n=this.anchor;this.anchorRelativeBoundingBox=n&&!this.bbox.isEmpty()?new h(this.bbox.minPoint.subtract(n),this.bbox.maxPoint.subtract(n)):h.empty()},n.prototype.intersects=function(n){var t,r,u,i,f,e;if(!this.bbox.intersects(n.bbox))return!1;for(t=0,r=this.bounds.length;t<r;t++)for(u=this.bounds[t],i=0,f=n.bounds.length;i<f;i++)if(e=n.bounds[i],u.intersects(e))return!0;return!1},n}(),function(n){n[n.none=0]="none";n[n.top=1]="top";n[n.middle=2]="middle";n[n.bottom=4]="bottom";n[n.verticalMask=15]="verticalMask";n[n.left=16]="left";n[n.center=32]="center";n[n.right=64]="right";n[n.horizontalMask=240]="horizontalMask";n[n.topLeft=17]="topLeft";n[n.topCenter=33]="topCenter";n[n.topRight=65]="topRight";n[n.middleLeft=18]="middleLeft";n[n.middleCenter=34]="middleCenter";n[n.middleRight=66]="middleRight";n[n.bottomLeft=20]="bottomLeft";n[n.bottomCenter=36]="bottomCenter";n[n.bottomRight=68]="bottomRight"}(n||(n={}));var oi=function(){function n(){this._index=new vt;this._landmarksCount=0;this._landmarkDealsCount=0}return n.prototype.computeRenderables=function(t,i,r){var e={},o=[],s=0,c=0,v=r.pixelWidth,y=r.pixelHeight,nt=h.fromSides(0,v,0,y),tt=h.fromSides(-v/2,v*1.5,-y/2,y*1.5),w=0,b,p,f,l,a,k,d,g;n._addLabelsToCache(e,t);b=Date.now();for(p in e)if(e.hasOwnProperty(p)){if(f=e[p],f.data.dirty&&f.data.primitives.length===0)delete e[f.id];else{if(f.reset(),!f.data.style)continue;f.initializePosition(r,i);n._isInDisplay(f,nt,tt)&&(o.push(f),c++)}s++}return w=Date.now()-b,s!==c&&u.log(null,"CollisionManager: received {0} labels out of which {1} in display, {2} outside display",s,c,s-c),l=Date.now(),this._sortByXsrPriority(o),l=Date.now()-l,this._index.reset(r.pixelWidth,r.pixelHeight),this._index.addLabels(o),a=Date.now(),this._doFirstPlacementPass(o),a=Date.now()-a,k={sortTime:l,collisionTime:a,initializePositionTime:w},this._index.reset(0,0),d=this._createRenderables(o),g={renderables:d,diagnosticArgs:k,landmarksCount:this._landmarksCount,landmarkDealsCount:this._landmarkDealsCount},g},n._addLabelsToCache=function(n,t){for(var i,r=0,u=t.length;r<u;r++)(i=t[r],i.data&&i.data.primitives&&i.data.primitives[0]&&!i.data.primitives[0].isDisposed)&&(n[i.id]=i)},n.prototype._sortByXsrPriority=function(n){n.sort(function(n,t){var i=n.data,r=t.data,h=i.drawOrder||0,c=r.drawOrder||0,w=i.priorityGroup===o.poiStylePriorityGroup,b=r.priorityGroup===o.poiStylePriorityGroup,l=0,y,p,e,s,u,f;if(w&&b)return i.priority-r.priority||h-c;if(w)return-1;if(b)return 1;var a=i.style.styleStatic.strataStyle,v=r.style.styleStatic.strataStyle,k=a&&a.alpha&&a.alpha<1,d=v&&v.alpha&&v.alpha<1;if(k&&!d)return-1;if(d&&!k)return 1;if(y=parseInt(i.entityId),p=parseInt(r.entityId),i.priorityGroup!==0&&r.priorityGroup!==0&&i.priorityGroup===r.priorityGroup)return h-c||y-p;if(i.priority===r.priority){if(e=i.lowImportanceCollisionPadding,s=r.lowImportanceCollisionPadding,e===0&&s!==0)return-1;if(e!==0&&s===0)return 1;if(u=i.labelImportance,f=r.labelImportance,u!==-1&&f===-1)return-1;if(u===-1&&f!==-1)return 1;if(u!==-1&&f!==-1)if(u===f){if(l=e-s,l!==0)return l}else return u-f;return h-c||y-p}return i.priority-r.priority});for(var t=0;t<n.length;t++)n[t].placementPriority=t},n.prototype._doFirstPlacementPass=function(n){for(var e,l,t,o,y,nt,r,u,h=0,v=n.length;h<v;h++){var s=n[h],f=s.getRegions(),i=null,c=!1;if(g.debugLabels&&f.length){Array.prototype.push.apply(s.placedRegions,f);continue}for(e=0,l=f.length;e<l;e++)if((t=f[e],o=t.parentRegion,!t.isRejected&&!t.isFixed&&(!o||!o.isRejected))&&(t.type!==1||s.data.iconTemplates)){if(o?i===o&&(c=!0):(i&&!i.isFixed&&c&&(i.isRejected=!0),i=t,c=!1),y=this._index.getOverlappingOccludedRegions(t),y.length>0){t.isRejected=!0;continue}for(var p=this._index.getOverlappingRegions(t),w=p.length,a=!1;w--;){for(var b=p[w],k=b.label.placedRegions,d=k.length;d--;)if(nt=k[d],nt===b){a=!0;break}if(a)break}if(a){t.isRejected=!0;continue}if(s.placedRegions.push(t),o){for(r=e+1;r<l;r++)u=f[r],u.isFixed||u.parentRegion!==o||(u.isRejected=!0);i=null}else if(s.replicaProximity)this._filterReplicas(t,e,s.replicaProximity,f);else for(r=e+1;r<l;r++)u=f[r],u.isFixed||u.parentRegion===t||(u.isRejected=!0)}i&&!i.isFixed&&c&&(i.isRejected=!0)}},n.prototype._filterReplicas=function(n,t,i,r){var e=n.bounds.bbox.clone(),f,o,u;for(e.buffer(i,i),f=t+1,o=r.length;f<o;f++)u=r[f],u.isFixed||u.isRejected||u.parentRegion||!e.intersects(u.bounds.bbox)||(u.isRejected=!0)},n.prototype._createRenderables=function(n){for(var r,s,t,f,c=[],l=0,a=0,h=0,y=n.length;h<y;h++){var i=n[h],u=i.data,o=i.placedRegions,v=[];for(r=0,s=o.length;r<s;r++)t=o[r],t&&!t.isRejected&&(t=i.lastUsedRegion(t),f=u.primitives[0],e.isLandmarkEntity(f.entity)&&t.type&&t.type===1&&(l++,f.entity.landmarksDealFlag&&a++),c.push({id:t.id.toString(),type:u.type,text:t.text,secondaryText:t.secondaryText,independentHotRegions:u.independentHotRegions,lineWidths:i.lineWidths,labelId:i.id,region:t,geometryType:f.geometryType,iconTemplates:u.iconTemplates,style:u.style,fontSize:u.fontSize,secondaryFontSize:u.secondaryFontSize,layerZIndex:f.layer&&parseInt(f.layer.getZIndex()),labelZIndex:f.zIndex||0}),v.push(t));for(i.lastUsedRegions=v,o=i.regions,r=0,s=o.length;r<s;r++)t=o[r],t.bounds.bounds=[];i.regions=[]}return this._landmarksCount=l,this._landmarkDealsCount=a,c},n._isInDisplay=function(n,t,i){for(var e,o=n.getRegions(),s=!1,u=n.data,r=u&&u.primitives&&u.primitives[0],h=r&&r.hasVectorIcon&&r.hasVectorIcon()&&r.entity.collisionBehavior===1,c=h?i:t,f=0,l=o.length;f<l;f++)e=o[f],c.intersects(e.bounds.bbox)?s=!0:e.isRejected=!0;return s},n}(),d=function(t){function i(n){return t.call(this,n)||this}return l(i,t),i.prototype.initializePosition=function(n,i){var r=this.data,u=r.style;u.styleStatic.wrapDisplayName&&r.text&&(r.text=v.wrapText(r.text));t.prototype.initializePosition.call(this,n,i)},i.prototype._initializeLabelRegions=function(n){var s=this.data,t=new c(s.crs,n),f=s.primitives[0],h=f.entity&&f.entity.labelHint,i,r,e,u,o;if(h)i=h.lbl,r=i[0],i&&i.length>0&&r.tps&&r.tps.length>0&&(e=r.tps[0],t.project(e.x||0,e.y||0));else{if(u=f.geometry,!u)return;t.project(u.x,u.y)}o=this._getIconRegion(t.lastProjectedX,t.lastProjectedY);o&&this.regions.push(o)},i.prototype._getIconRegion=function(t,u){var o,h=this.data.iconTemplates,f=this.data.imageWidth,e=this.data.imageHeight,y,s,c,l,v;return(!f||!e)&&h&&h[0]&&(s=a.getIconBounds(h,this.data.iconText),c=s.getSize(),f=c.width,e=c.height,y=new r(s.maxPoint.x-f/2,s.maxPoint.y-e/2)),f&&e&&(o={type:1,label:this,text:this.data.iconText,anchor:new r(t,u),anchorOffset:y,size:new tt(f,e),placement:n.middleCenter},l=this.data.primitives[0].entity,v=l&&l.collisionBehavior||0,v!==0&&(o.isFixed=!0),v===2&&(o.occludesOthers=!0),this.data.offsetX||(this.data.offsetX=f/2+i._defaultIconLabelOffset),this.data.offsetY||(this.data.offsetY=e/2+i._defaultIconLabelOffset)),o},i._defaultIconLabelOffset=2,i}(a),si=function(){function n(){this._collisionMapScale=.01;this._bufferSizeAroundRenderables=5;this._collisionMap=[]}return n.prototype.collide=function(n,t){for(var i,e,u=[],f=Object.keys(n),r=0,o=f.length;r<o;r++)i=n[f[r]].region,i.rect=i.bounds.getBoundingBoxRelativeTo(i.anchor),i.isRejected=!1,u.push(n[f[r]]);this._scaledViewportWidth=t*this._collisionMapScale;e=Math.ceil(t/32*this._collisionMapScale);this._sort(u);this._collide(u,e)},n.prototype._collide=function(n,t){this._collideGroup(n,t,!0);this._collideGroup(n,t,!1);this._collisionMap=[]},n.prototype._collideGroup=function(n,t,i){for(var s=this._collisionMapScale,u,f,e,c,o,r,h=0,l=n.length;h<l;h++){if(r=n[h].region,o=r.rect,u=Math.ceil((o.minPoint.x-this._bufferSizeAroundRenderables)*s),f=Math.floor((o.maxPoint.x+this._bufferSizeAroundRenderables)*s),e=Math.ceil((o.minPoint.y-this._bufferSizeAroundRenderables)*s),c=Math.floor((o.maxPoint.y+this._bufferSizeAroundRenderables)*s),u=Math.min(u,f),e=Math.min(e,c),u<0||f>this._scaledViewportWidth){r.isRejected=!0;continue}!!r.occludesOthers!==i||r.isRejected||(r.occludesOthers||!this._isOverlappingRegion(u,f,e,c,t)?this._updateCollisionMap(u,f,e,c,t):r.isRejected=!0)}},n.prototype._updateCollisionMap=function(n,t,i,r,u){this._isOverlappingRegionOrUpdateCollisionMap(n,t,i,r,u,!0)},n.prototype._isOverlappingRegion=function(n,t,i,r,u){return this._isOverlappingRegionOrUpdateCollisionMap(n,t,i,r,u,!1)},n.prototype._isOverlappingRegionOrUpdateCollisionMap=function(n,t,i,r,u,f){for(var h,c=n/32>>0,l=t/32>>0,p=n%32,k=t%32,a,v=-1<<p>>>p,y=-2147483648>>k,w=v&y,o=!1,e,b=this._collisionMap,s=c;s<=l;s++)for(h=i;h<=r;h++)if(a=u*h+s,e=b[a]||0,c===l?f?e|=w:o=(e&w)!=0:s===c?f?e|=v:o=(e&v)!=0:s===l?f?e|=y:o=(e&y)!=0:f?e=-1:o=!!e,f)b[a]=e;else if(o)return!0;return o},n.prototype._sort=function(n){n.sort(function(n,t){return t.drawPriority-n.drawPriority})},n}(),yt=function(n){function t(t,r,u,f){var e=this,o={};return e=n.call(this,o)||this,e._isShutDown=!0,e._spatialMathRequested=!!(i&&i.SpatialMath),o.defineProperty("isLabelsEnabled",function(n,t){e._onIsLabelsEnabledChanged(n,t);e.labelsEnabledChanged.invoke(t)}),o.defineProperty("isUserLabelsEnabled",function(n,t){e._onIsUserLabelsEnabledChanged(n,t)}),e.instrumentLabelingPass=new s,e.labelsEnabledChanged=new s,e.onLabelsProcessed=new s,e._onTemplateReady=new s,e._frameMangerEventHandlers=[],e._labelingDiagnostics={},e._disposables=[],e._mapEvents=[],e._coreConfig=t,e._hitTestController=r,e._workDispatcher=u,e._customMapStyleManager=f,e.hitTestPriority=1,e}return l(t,n),t.prototype.attach=function(n){var t=this;this._map=n;this._labelUserMapLayers=this.getIsLabelsSupported();this._mapEvents.push(this._map.changed.add(function(n){n.name==="mode"&&t._onMapModeChanged(n.newValue)}));this._mapEvents.push(this._map.mapTypeChangeStarted.add(function(n){t._onMapTypeChangeStarted(n)}))},t.prototype.getIsLabelsSupported=function(){return this._map.getMode()?this._isSupportedMapTypeForLabels(this._map.getMapType().id)&&this._isSupportedMapModeForLabels(this._map.getMode().mapModeType):!0},t.prototype.getBaseTemplateName=function(){return this._templateName},t.prototype.SetAnimationState=function(n){this._isInAnimation=n},t.prototype.dispose=function(){this._shutDown();n.prototype.dispose.call(this);this._hitTestController=null;clearTimeout(this._invalidatedTimerId);f._clearDisposables(this._mapEvents);f._clearDisposables(this._frameMangerEventHandlers);f._disposeEvents(this)},t.prototype._onFrameSet=function(n){var t,i;this._isInAnimation||(t=n.frame,this._currentLabelRenderingContext&&this._currentLabelRenderingContext.frame&&(i=this._labeler&&this._labeler.cancelProcessingForFrame(this._currentLabelRenderingContext.frame),this._vectorLabels&&this._vectorLabels.cancelRender(this._currentLabelRenderingContext),i&&this._previousFrameData&&this._previousFrameData.frame.frameNumber===this._currentLabelRenderingContext.frame.frameNumber&&(this._previousFrameData=null)),this._finalVectorLabelRenderCompleteHandler&&this._finalVectorLabelRenderCompleteHandler.dispose(),this._finalVectorLabelRenderCompleteHandler=null,this._currentLabelRenderingContext={frame:t,paintId:0},this._isFinalPaintInitiated=!1)},t.prototype.performHitTesting=function(n,t){this._vectorLabels&&!this._isShutDown&&this._vectorLabels.performHitTesting(n,t)},t.prototype._constructVectorLabel=function(){return new wt(this._map)},t.prototype._initLabelRenderer=function(){this._vectorLabels&&this._vectorLabels.dispose();this._vectorLabels=this._constructVectorLabel()},t.prototype._bootStrap=function(){var n=this;this._isShutDown&&(this._isShutDown=!1,this._hitTestController&&this._hitTestController.addComponent(this));this._isTemplateReady=!1;this._subscribeToFrameManagerEvents();this._map.getTemplateSelector().then(function(t){return n._templateSelector=t,n._templateName=(t.getName()||"").toUpperCase(),t.selectorReady()}).then(function(t){!n._isShutDown&&t&&n._templateSelector&&t.getName()===n._templateSelector.getName()&&(n._isTemplateReady=!0,n._onTemplateReady.invoke(),n._onTemplateSelectorReady())})},t.prototype._onTemplateSelectorReady=function(){this._isShutDown||(u.log(null,"Hooking up LabelController to FrameManager and CompositeMode events"),this._createLabeler(),this._initLabelRenderer())},t.prototype._shutDown=function(){this._isShutDown||(f._clearDisposables(this._disposables),f._clearDisposables(this._frameMangerEventHandlers),this._templateSelector=null,this._isInitialLoadingComplete=!1,this._labeler=null,this._vectorLabels&&(this._vectorLabels.dispose(),this._vectorLabels=null),this._hitTestController&&this._hitTestController.removeComponent(this),this._isShutDown=!0)},t.prototype.getViewport=function(){var n=this._map.getMode();return n.getCurrentCrsViewport()},t.prototype.copyCanvas=function(n){this._vectorLabels&&this._vectorLabels.copyCanvas(n)},t.prototype.renderLabels=function(n,t){var i=this;this._currentLabelRenderingContext&&this._currentLabelRenderingContext.frame&&((this._isFinalPaintInitiated||this._labelInvalidated)&&u.clearTestHooksLog(u.UserLogTag),this._currentLabelRenderingContext={frame:this._currentLabelRenderingContext.frame,paintId:this._currentLabelRenderingContext.paintId++},this._vectorLabels||this._initLabelRenderer(),this._isFinalPaintInitiated&&(this._labelingDiagnostics.renderingTime=Date.now(),this._finalVectorLabelRenderCompleteHandler=this._vectorLabels.renderingComplete.add(function(n){n.labelRenderingContext&&n.labelRenderingContext.frame&&i._currentLabelRenderingContext&&i._currentLabelRenderingContext.frame&&n.labelRenderingContext.frame.frameNumber===i._currentLabelRenderingContext.frame.frameNumber&&n.labelRenderingContext.paintId===i._currentLabelRenderingContext.paintId&&(i._labelingDiagnostics.totalLabelingTime+=n.delayedRenderingTime,i._labelingDiagnostics.delayedRenderingTime=n.delayedRenderingTime,i._finalVectorLabelRenderCompleteHandler&&i._finalVectorLabelRenderCompleteHandler.dispose(),i._finalVectorLabelRenderCompleteHandler=null,i._completeLabelRenderingPhase())})),this._vectorLabels.render(n,this._currentLabelRenderingContext,this._labelingDiagnostics,t,this._labelInvalidated),this._labelInvalidated=!1,this._isFinalPaintInitiated&&(this._labelingDiagnostics.renderingTime=Date.now()-this._labelingDiagnostics.renderingTime,this._labelingDiagnostics.totalLabelingTime=Date.now()-this._labelingDiagnostics.totalLabelingTime,this._isFinalPaintInitiated=!1))},t.prototype._subscribeToFrameManagerEvents=function(){var t=this,n=this._map.getFrameManager();this._frameMangerEventHandlers.length===0&&(this._isInitialLoadingComplete||(this._isInitialLoadingComplete=!0,n.frameSet.isPreviouslyInvoked&&this._onFrameSet(n.frameSet.lastInvokedArgs),n.dataLoaded.isPreviouslyInvoked&&this._showLabelsForFrameOnTemplateReady(n.dataLoaded.lastInvokedArgs.frame)),this._frameMangerEventHandlers.push(n.frameSet.add(function(n){t._onFrameSet(n)})),this._frameMangerEventHandlers.push(n.dataLoaded.add(function(n){t._showLabelsForFrameOnTemplateReady(n.frame)})))},t.prototype._showLabelsForFrameOnTemplateReady=function(n){var t=this;this._isInAnimation||(this._isTemplateReady?this._showLabelsForFrame(n):this._onTemplateReady.addOne(function(){t._showLabelsForFrame(n)}))},t.prototype._createLabeler=function(){var n=this;this._labeler||(this._disposables.push(this._labeler=new v(this,this._workDispatcher)),this._disposables.push(this._labeler.primitiveProcessingComplete.add(function(t){return n._primitiveProcessingComplete(t)})),this._disposables.push(this._labeler.labelsProcessed.add(function(t){return n._showLabels(t)})))},t.prototype._isSupportedMapTypeForLabels=function(){return!0},t.prototype._isSupportedMapModeForLabels=function(n){return n===0},t.prototype._showLabelsForFrame=function(n){var i=this,f,o,s;this._labelingDiagnostics={frameNumber:n.frameNumber};f=Date.now();this._labelingDiagnostics.totalLabelingTime=f;var l=this._map.getFrameManager(),r=this._getMapFrameData(),u=r&&r.getPrimitives(1,!0);if(u){var h=this._map.getMapOptions().liteMode||t._isNullDataRegionFrame(r),e={},c=r.getLayerFrameData();c.forEach(function(n){var t=n.layer,r=t&&t.getIconOnlyLimit(),i;r>0&&(i=n.getPrimitives(1,!0),i&&i.length>=r&&(e[t.getId()]=!0))});this._labelingDiagnostics.primitiveCount=u.length;this._labelingDiagnostics.timeToAddStyles=Date.now();o=this._fetchPrerequisites(u);this._previousFrameData=r;s=function(){if(i._previousFrameData===r&&i._labeler&&!i._isInAnimation){var t=i._map.getMode(),f=t.getCurrentCrsViewport();i.addStyle(u);i._labelingDiagnostics.timeToAddStyles=Date.now()-i._labelingDiagnostics.timeToAddStyles;i._labelingDiagnostics.labelDataProcessingTime=Date.now();i._labeler.processData(n,u,e,f,i._map.getMercatorZoomLevel(),h);i._labelingDiagnostics.labelDataProcessingTime=Date.now()-i._labelingDiagnostics.labelDataProcessingTime}};Promise.all(o).then(s)}},t.isIconStyle=function(n){return n===t._iconStyle},t.prototype.addStyle=function(n){var f,i,r,s;if(n)for(f=this._map.getMercatorZoomLevel(),i=it.toScale(null,f,!0),r=n.length-1;r>=0;r--){var t=n[r],u=t.layer,o=u&&u.getTemplateSelector()||this._templateSelector;t.style=o.getMarkupStyle?o.getMarkupStyle(t,i):this._templateSelector.getMarkupStyle(t,i);e.isLandmarkEntity(t.entity)&&t.style&&(s=t.style.styleStatic,s.wrapDisplayName=!0);t.geometryType===1?(!u||u.getRenderTarget()!==0||t.entity&&t.entity.collisionBehavior===2)&&this._setMarkupStyle(t,o,i):t.iconTemplates=this._templateSelector.getFetchedShields(f,t.bucket,e.getShieldIndices(t.entity))}},t.prototype._fetchPrerequisites=function(n){for(var h,a,y,u,p,w,b,k,d=this,g={},f={},nt={},c=[],r=Array(),l=0,ut=n.length;l<ut;l++){var t=n[l],s=t.layer,tt=s&&s.getTemplateSelector();if(t.geometryType!==1&&(h=e.getShieldIndices(t.entity),h&&h.length>0&&c.push({bucketId:t.bucket,indexes:h}),!this._spatialMathRequested&&t.geometryType===3&&t.bucket&&t.entity&&!t.entity.labelHint&&e.getDisplayName(t.entity)&&(this._spatialMathRequested=!0,r.push(new Promise(function(n,t){d._map?d._map.getContainer().instanceAsync("SpatialMath",function(){n()}):t()})))),tt&&(s.getRenderTarget()!==0||t.entity&&t.entity.collisionBehavior===2)){a=s.getId();g[a]||(g[a]=!0,r.push(tt.selectorReady()));var it=t.bucket,i=t.entity,v=i,rt=i&&i.oid;rt?nt[rt]=!0:it&&(f[it]=!0);(t.catId||i&&i.getSelectedCategoryForIcon)&&(y=t.catId||i.getSelectedCategoryForIcon()||o.extractCategoryId(i.getPrimaryCategoryPath(),!0),y&&(u=o.getBucketForCategory(y),u&&(f[u]=!0),p=v&&v.getSearchCategory&&v.getSearchCategory(),u=p&&o.getBucketForCategory(p),u&&(f[u]=!0)));t.stylesheetEntry&&(w=this._customMapStyleManager.getElementBucket(t.stylesheetEntry,t.geometryType),w&&(f[w.toString()]=!0))}}return b=Object.keys(f),b.length>0&&r.push(this._templateSelector.prefetchImages(b)),k=Object.keys(nt),k.length>0&&r.push(this._templateSelector.prefetchOrganizationImagesByOrgId(k)),c.length>0&&r.push(this._templateSelector.prefetchShields(c)),r},t.prototype.invalidateLabels=function(){var n=this,t=function(){n._labelInvalidated=!0;n.onLabelsProcessed.invoke(n._currentLabelRenderingContext.frame)};clearTimeout(this._invalidatedTimerId);this._invalidatedTimerId=Microsoft.Maps.setTimeout(t,0)},t.prototype._setMarkupStyle=function(n,i,r){var u=n.iconTemplates=i.getTemplates(n,r);u&&u.length&&!n.style&&(n.style=t._iconStyle)},t.prototype._showLabels=function(n){var t=it.toScale(null,this._map.getMercatorZoomLevel(),!0),i=it.toScale(null,n.zoom,!0);i===t&&(this._vectorLabels||this._initLabelRenderer(),this._vectorLabels.showLabels(n.labels,n.region),this._isFinalPaintInitiated=!0,this.invalidateLabels(),this._zoomLevelForLabelingPhase=this._map.getMercatorZoomLevel())},t.prototype._getMapFrameData=function(){var u=this._map.getFrameManager(),n=u.getFrameData(),i,r,s,h;if(this._labelBaseMapLayers||this._labelUserMapLayers){if(!this._labelBaseMapLayers||!this._labelUserMapLayers){var f=[],e=[],o=n.getLayerFrameData();for(i=0;i<o.length;++i)r=o[i],s=r.layer,t._isBaseMapLayer(s)?e.push(r):f.push(r);h=this._labelBaseMapLayers?e:f;n=new st(u.getFrame(),h)}}else n=new st(u.getFrame(),[]);return n},t._isBaseMapLayer=function(n){var i=!1,t=n.getDataSource&&n.getDataSource();return t&&t instanceof dt&&(t=t.getParentDataSource()),t&&t instanceof ot&&(i=!0),i},t.prototype._primitiveProcessingComplete=function(n){this._labelingDiagnostics.collisionSortTime=n.sortTime;this._labelingDiagnostics.collisionTime=n.collisionTime;this._labelingDiagnostics.primitiveChangeProcessingTime=n.primitiveChangeProcessingTime;this._labelingDiagnostics.computeRenderablesTime=n.computeRenderablesTime;this._labelingDiagnostics.initializePositionTime=n.initializePositionTime;this._labelingDiagnostics.landmarksCount=n.landmarksCount;this._labelingDiagnostics.landmarkDealsCount=n.landmarkDealsCount},t.prototype._completeLabelRenderingPhase=function(){this.instrumentLabelingPass.invoke(this._labelingDiagnostics);this._labelingDiagnostics={};var n=this._map.getFrameManager();n.completeLabelRenderingPhase(this._currentLabelRenderingContext.frame)},t.prototype._onMapTypeChangeStarted=function(n){this.getIsLabelsEnabled()&&n.newMapTypeId!==n.oldMapTypeId&&(this._isSupportedMapTypeForLabels(n.newMapTypeId)?(this._templateSelector=null,this._bootStrap()):this._shutDown())},t.prototype._onMapModeChanged=function(n){this.getIsLabelsEnabled()&&(this._isSupportedMapTypeForLabels(this._map.getMapType().id)&&this._isSupportedMapModeForLabels(n.mapModeType)?this._bootStrap():this._shutDown())},t.prototype._onIsLabelsEnabledChanged=function(n,t){var r,i,u;if(this.getIsLabelsSupported())for(this._labelBaseMapLayers=t,this._bootStrap(),r=this._map.getBaseLayers(),i=0;i<r.length;i++)u=r[i],u instanceof ei&&u.dataVersion++},t.prototype._onIsUserLabelsEnabledChanged=function(n,t){n!==t&&this.getIsLabelsSupported()&&(this._labelUserMapLayers=t,this._bootStrap())},t._isNullDataRegionFrame=function(n){for(var e,s,i,r=!1,u=0,o=n.getLayerFrameData(),f=0;f<o.length;++f)if(e=o[f],s=e.layer,t._isBaseMapLayer(s)&&(i=e.getPrimitives(2,!0),i.length>0))if(i[0].isNullDataRegionMarker){if(r=!0,u>0&&i.length!==u){r=!1;break}u=i.length}else r=!1;return r},t._iconStyle={styleDynamic:{densityDistance:0,densityImportance:0,densityLodDelta:0,globalOrder:20,priority:0,font:"x",fontSize:1,fontColor:"x",visible:!0},styleStatic:{}},t}(ii),v=function(){function n(n,t){var i=this;this._disposables=[];this.message=new s;this.primitiveProcessingComplete=new s;this._workDispatcher=t;this._controller=n;this._worker=new hi(this,n.getBaseTemplateName(),t);this._labelDataByLabelId={};this._changedHandlersByLabelId={};this._alwaysRaiseEvents=!1;this._disposables.push(this._worker.message.add(function(n){if(i._currentFrame&&n.frame.frameNumber===i._currentFrame.frameNumber){var t=i._getWorkDispatcherKeyForFrame(n.frame),r=function(){i._processWorkerMessage(n)};i._workDispatcher&&i._workDispatcher.dispatch(r,t,4)}}));this.labelsProcessed=new s}return n.prototype.processData=function(n,t,i,r,u,f){var o,e,s;if(t&&r){for(this._showLabelBackground=f,this._labelDataByLabelId={},this._disposeAllChangedHandlers(),this._currentFrame=n,o={type:0,frame:this._currentFrame,viewport:r,zoom:u,labels:[]},this._labelDrawOrder={},e=0,s=t.length;e<s;e++)this._associateLabelsWithPrimitive(t[e],i,o);this._postMessage(o)}},n.prototype.cancelProcessingForFrame=function(n){var t=!!this._currentFrame,i={type:2,frame:n};return this._postMessage(i),this._workDispatcher&&this._workDispatcher.cancelDispatchWithKey(this._getWorkDispatcherKeyForFrame(n),4),this._currentFrame=null,t},n.prototype._getWorkDispatcherKeyForFrame=function(t){return n._dispatchKey+t.frameNumber},n.prototype._associateLabelsWithPrimitive=function(n,t,i){var u=n.layer&&n.layer.getId(),v=n.entity&&n.entity.alwaysShowLabel,y=!v&&u&&t[u],s=this._createLabelData(n,y),e,l,o,h,r,a,c;if(s&&s.length)for(n.labelIds=[],e=0,l=s.length;e<l;e++){for(o=s[e],n.labelIds[e]=o.labelId,h=et.getKey(n,o),r=this._labelDataByLabelId[h],r?r.dirty=!0:(r=o,i.labels.push(o),this._labelDataByLabelId[h]=o),u=n.layer&&n.layer.getId(),u&&(r.drawOrder=this._labelDrawOrder[u]||0,this._labelDrawOrder[u]=r.drawOrder+1),n.labelIds[e]=r.labelId,c=r.primitives.length;c--;)if(f._arePrimitivesEqual(r.primitives[c],n)){a=!0;break}a||r.primitives.push(n)}},n.prototype.dispose=function(){f._clearDisposables(this._disposables);this._disposeAllChangedHandlers();this._labelDataByLabelId={};this._worker=null;this._controller=null},n.prototype._disposeAllChangedHandlers=function(){var n=this,t=Object.keys(this._changedHandlersByLabelId);t.forEach(function(t){return f._clearDisposables(n._changedHandlersByLabelId[t])});this._changedHandlersByLabelId={}},n.prototype._disposeChangedHandlers=function(n){f._clearDisposables(this._changedHandlersByLabelId[n]);delete this._changedHandlersByLabelId[n]},n.prototype._processWorkerMessage=function(n){var l,r,s,t,v;switch(n.type){case 1:var u=n,f={},c=u.renderables;for(t=0,l=c.length;t<l;t++){var a=c[t],i=a.labelId,e=this._labelDataByLabelId[i];e&&e.primitives&&e.primitives[0]&&!e.primitives[0].isDisposed&&(r=f[i],r||(r=[],f[i]=r),r.push(a))}for(s=Object.keys(f),t=0,v=s.length;t<v;t++){i=s[t];var r=f[i],y=this._labelDataByLabelId[i],h=y.primitives[0],p=h.entity,w=this._updateExistingLabel.bind(this,r,y),o=[];p.changed&&o.push(p.changed.add(w));h.changing&&o.push(h.changing.add(w));this._disposeChangedHandlers(i);o.length&&(this._changedHandlersByLabelId[i]=o)}this._currentFrame=null;this.primitiveProcessingComplete.invoke(u.labelWorkerDiagnosticArgs);this._raiseLabelsProcessedEvent(u.region,u.renderables,u.zoom);break;default:throw new Error("Unknown MessageType: "+n.type);}},n.prototype._updateExistingLabel=function(n,t,i){if(this._controller){var r=t.primitives[0],u=!1;r&&(i&&i.sender===r?i.name==="location"&&(this._updateLocation(n,t,i.newValue),u=!0):(this._updateStyle(n,t,r),this._updateZIndex(n,r),u=!0));u&&this._controller.invalidateLabels()}},n.prototype._updateLocation=function(n,t,i){var s=this._controller.getViewport(),f,h,l,e,a,u,o;if(s)for(f=new c(nt.instance,s),f.project(i.longitude,i.latitude),h=f.lastProjectedX,l=f.lastProjectedY,e=0,a=n.length;e<a;e++)u=n[e].region,u&&(o=new r(h,l),u.anchor=o,u.bounds&&u.bounds.setAnchor(o))},n.prototype._updateStyle=function(n,t,i){var u,f,r;for(this._controller.addStyle(t.primitives),t.style=i.style,u=0,f=n.length;u<f;u++)r=n[u],r.style=t.style,r.lineWidths=[],r.size=null,r.iconTemplates=t.iconTemplates=i.iconTemplates&&i.iconTemplates.length?i.iconTemplates:null},n.prototype._updateZIndex=function(n,t){for(var r=t.zIndex||0,i=0,u=n.length;i<u;i++)n[i].labelZIndex=r},n.prototype._createLabelData=function(t,i){var u=t.entity,r,ut,c,l,a,tt,st;if(!t.entity||(r=t.style,ut=n._isValidStyle(r),!ut))return null;if(!t.entity.labelHint){var ft=e.getLabelImportance(u),y=0;if((r.styleDynamic.visible&&r.styleDynamic.densityLodDelta&&r.styleDynamic.densityLodDelta!==rt.markupVisible&&r.styleDynamic.densityLodDelta!==rt.markupInvisible&&(r.styleDynamic.visible=ft>=0?ft<=255-r.styleDynamic.densityLodDelta*r.styleDynamic.densityImportance:r.styleDynamic.densityLodDelta<=(255-r.styleDynamic.densityImportance)/50+1,r.styleDynamic.visible&&(y=r.styleDynamic.densityLodDelta*r.styleDynamic.densityDistance+.5)),!r.styleDynamic.visible)||t.geometryType===2&&t.geometry.x.length<2)return null}var p=e.getShieldIndices(u),w=p&&p.length&&e.getShieldNames(u),o=t.iconTemplates,b=w&&w.length&&o,ht=e.isLandmarkEntity(u),s=!!(b&&b.length),k=o&&!!o[0],f=e.getDisplayName(u),h=f&&e.getSecondaryDisplayName(u),ct=h&&e.independentHotRegions(u),v=e.getIconText(u),ot=!1;if(s){var d=t.entity.labelHint,g=d&&d.lbl&&d.lbl[0],nt=g&&g.tps&&g.tps[0];nt&&nt.n&&(ot=!0,f=nt.n)}if((c=k&&!s&&(i||!f||o[0].hasText&&!v||yt.isIconStyle(r)),r.styleStatic.showBackground=this._showLabelBackground,!s&&r.styleStatic.shieldLabelVisibility===1)||!f&&!s&&!c)return null;if(l=[],s&&(l=n._createShieldLabelData(t,u,r,y,p,w,b),!ot))return l;r.styleDynamic.fontCaps===1&&(f=f.toUpperCase(),h=h.toUpperCase());a=1;tt=0;switch(t.geometryType){case 1:a=c?0:1;tt=r.styleDynamic.priority;st=!c&&n._getPointLabelType(ht,k,t.bucket);break;case 3:a=3;break;case 2:a=2}c&&(v=v||f,f=null,h=null);var lt=r.styleDynamic.fontSize,at=r.styleDynamic.secondaryFontSize,it={labelId:null,entityId:u.id,bucket:t.bucket,primitives:[],crs:t.crs,lowImportanceCollisionPadding:y,labelImportance:e.getLabelImportance(u),fontSize:lt,secondaryFontSize:at,priority:r.styleDynamic.globalOrder,text:f,secondaryText:h,independentHotRegions:ct,iconText:v,type:a,pointType:st,priorityGroup:tt,offsetX:r.styleStatic.offsetX,offsetY:r.styleStatic.offsetY,imageWidth:r.styleStatic.imageWidth,imageHeight:r.styleStatic.imageHeight,style:r,iconTemplates:k?o:null};return it.labelId=et.getKey(t,it),l.push(it),l},n._createShieldLabelData=function(n,t,i,r,f,o,s){var v=[],l,h,y,c,p,a;for(u.assert(!!(f&&f.length),"No shield indices"),u.assert(!!(o&&o.length),"No shield names"),u.assert(!!(s&&s.length),"No shield templates"),l=0,h=0;h<s.length;h++)s[h]&&l++;for(u.assert(f.length===o.length&&o.length===l,"Shield indices, names and templates don't match"),h=0,y=o.length;h<y;h++)c=e.getShieldDisplayData(o[h]),p=s[h],c&&c.text&&p&&(a={labelId:null,entityId:t.id,bucket:n.bucket,primitives:[],crs:n.crs,lowImportanceCollisionPadding:r,labelImportance:e.getLabelImportance(t),fontSize:i.styleDynamic.fontSize,priority:i.styleDynamic.globalOrder,text:c.modifier,iconText:c.text,type:4,priorityGroup:0,offsetX:i.styleStatic.offsetX,offsetY:i.styleStatic.offsetY,imageWidth:i.styleStatic.imageWidth,imageHeight:i.styleStatic.imageHeight,style:i,iconTemplates:[s[h]],shieldIndex:f[h],shieldCount:l,shieldInstance:h},a.labelId=et.getKey(n,a),v.push(a));return v},n._getPointLabelType=function(n,t,i){switch(i){case o.pricePoiBucketId:case o.bucketIdForPoi:case o.bucketIdForDirectionsPins:case o.bucketIdForSelectedPoi:return 1;case o.bucketIdForTransientLensTop:return 2;case o.bucketIdForTransientLensBottom:return 3;case o.bucketIdForTransientLensLeft:return 4;case o.bucketIdForTransientLensRight:return 5;default:return t?1:0}},n.wrapText=function(t,i){var r;if(i=i||n._minWrapLength,t&&t.length>=i&&(r=t.split(/\s+/),r.length>1)){for(var e=t.length/2,u="",f="";r.length;){while(r.length&&u.length<=f.length)u=u+" "+r.shift();while(r.length&&f.length<=u.length)f=r.pop()+" "+f}Math.abs(u.length-f.length)<e*2/3&&(t=(u+"\n"+f).trim())}return t},n.wrapTextToFit=function(t,i,r,u){var c,h,v;if(i.width>r.width)if(c=f._clamp(Math.round(i.width/r.width),2,u),c===2)t=n.wrapText(t,0);else{var w=Math.ceil(t.length/c),a=t.split(/\s+/),s=[],e="",o=!1;for(h=0,v=a.length;h<v;h++){var l=a[h],y=l.length,b=e.length+y+(o?1:0),p=b-w;p<=y/2?(e=e+(o?" ":"")+l,o=!0,p>=0&&(s.push(e),e="",o=!1)):(s.push(e),e=l,o=!0)}e&&s.push(e);t=s.join("\n").trim()}return t},n.prototype._raiseLabelsProcessedEvent=function(n,t,i){var r={region:n,labels:t,zoom:i};this.labelsProcessed.invoke(r)},n.prototype._postMessage=function(n){this.message.invoke(n)},n._isValidStyle=function(n){return!!(n&&n.styleStatic&&n.styleDynamic.fontColor&&n.styleDynamic.fontSize&&n.styleDynamic.font)},n.collisionAlphaThreshold=.58,n._minWrapLength=20,n._dispatchKey="Labeler:",n}(),hi=function(){function n(n,t,i){var r=this;this._workDispatcher=i;this._templateName=t;this._collisionManager=new oi;this._messageQueue=[];this.message=new s;this._mainThreadMessageSubscription=n.message.add(function(n){return r._queueMessage(n)})}return n.prototype.dispose=function(){this._mainThreadMessageSubscription&&(this._mainThreadMessageSubscription.dispose(),this._mainThreadMessageSubscription=null)},n.prototype._queueMessage=function(n){var r=this,t=this._getWorkDispatcherKeyForFrame(n.frame),i;n.type===2?this._workDispatcher.cancelDispatchWithKey(t,4):(this._messageQueue.push(n),i=function(){r._processMessage()},this._workDispatcher.dispatch(i,t,4))},n.prototype._getWorkDispatcherKeyForFrame=function(t){return n._dispatchKey+t.frameNumber},n.prototype._processMessage=function(){var r=this,n,t,i;if(this._messageQueue.length!==0){n=this._messageQueue.shift();switch(n.type){case 0:this._processPrimitivesChangedMessage(n);break;default:throw new Error("Unknown MessageType: "+n.type);}this._messageQueue.length>0&&(t=this._getWorkDispatcherKeyForFrame(this._messageQueue[0].frame),i=function(){r._processMessage()},this._workDispatcher.dispatch(i,t,4))}},n.prototype._processPrimitivesChangedMessage=function(n){for(var i,r,o,u,t,f=Date.now(),s=[],e=0,h=n.labels.length;e<h;e++){i=n.labels[e];o=i.type;switch(o){case 0:r=new d(i);break;case 1:r=new pt(i);break;case 2:r=new ci(i);break;case 3:r=new at(i);break;case 4:r=new li(i,this._templateName);break;default:throw new Error("Unknown LabelType: "+o);}s.push(r)}u=Date.now();t=this._collisionManager.computeRenderables(s,n.zoom,n.viewport);u=Date.now()-u;f=Date.now()-f;t.diagnosticArgs.computeRenderablesTime=u;t.diagnosticArgs.primitiveChangeProcessingTime=f;t.diagnosticArgs.landmarksCount=t.landmarksCount;t.diagnosticArgs.landmarkDealsCount=t.landmarkDealsCount;this._postMessage({type:1,frame:n.frame,region:n.viewport,renderables:t.renderables,labelWorkerDiagnosticArgs:t.diagnosticArgs,zoom:n.zoom})},n.prototype._postMessage=function(n){this.message.invoke(n)},n._dispatchKey="LabelerWorker:",n}(),et=function(){function n(){}return n.getKey=function(n,t){var i=n.geometryType,f="b:"+(t.bucket||"-1"),e="r:"+(n.revision||0),o="l:"+(n.layer&&n.layer.getId()||"0"),r="g:"+i+"#"+f+"#"+e+"#"+o,u=(t.iconText||"")+(t.text||"");return t.type===4?"#S#".concat(t.shieldIndex,"#").concat(t.shieldInstance,"#").concat(t.shieldCount,"#").concat(u):i===2?r+"#"+u:r+"#"+t.entityId},n}(),ci=function(t){function i(n){return t.call(this,n)||this}return l(i,t),i.prototype._initializeLabelRegions=function(n,t){var e,f,a;if(this.regions=this._getRegionsFromHints(n,t),!this.regions)for(this.regions=[],e=i.getLongestSegments(this.data.primitives,i._MAX_ALTERNATES),f=0,a=e.length;f<a;f++){var u=e[f],o=u.x0,s=u.y0,h=u.x1,l=u.y1,r=new c(u.crs,n);r.project(o,s);o=r.lastProjectedX;s=r.lastProjectedY;r.project(h,l);h=r.lastProjectedX;l=r.lastProjectedY;this._addLinearLabelRegion(o,s,h,l)}},i.prototype._addLinearLabelRegion=function(t,u,f,e){var o,s,h;t>f&&(o=t,t=f,f=o,o=u,u=e,e=o);s=Math.atan2(e-u,f-t);Math.abs(s-Math.PI/2)<=i._VERTICAL_LABEL_TOLERANCE&&(s+=Math.PI,h=t,t=f,f=h,h=u,u=e,e=h);this.regions.push({label:this,text:this.data.text,anchor:new r((t+f)/2,(u+e)/2),placement:n.middleCenter,horizontalAlignment:0,orientation:s})},i.getLongestSegments=function(n,t){for(var e,r,i,o,u=[],f=0,a=n.length;f<a;f++)for(e=n[f],r=e.geometry,i=0,o=r.x.length-1;i<o;i++){var s=r.x[i],h=r.y[i],c=r.x[i+1],l=r.y[i+1];u[f]={x0:s,y0:h,x1:c,y1:l,crs:e.crs,weight:Math.abs(s-c)+Math.abs(h-l)}}return u.sort(function(n,t){return t.weight-n.weight}),u.length=Math.min(u.length,t),u},i._MAX_ALTERNATES=3,i._VERTICAL_LABEL_TOLERANCE=Math.PI/60,i}(a),pt=function(t){function i(n){var i=t.call(this,n)||this;return i._calculatePlacements(),i}return l(i,t),i.prototype._calculatePlacements=function(){this._placement=n.none;switch(this.data.pointType){default:this._possiblePlacements=i._defaultLabelPlacements;break;case 1:case 5:this._possiblePlacements=i._poiLabelPlacements;this._hasBackground()||(this._padding=0);break;case 2:this._possiblePlacements=i._transientLensLabelTopPlacements;break;case 3:this._possiblePlacements=i._transientLensLabelBottomPlacements;break;case 4:this._possiblePlacements=i._transientLensLabelLeftPlacements;break;case 5:this._possiblePlacements=i._transientLensLabelRightPlacements}},i.prototype._getIconLocationFromHint=function(n){var i=n.entity&&n.entity.labelHint,t=i&&ot.getAnchorTextSpan(i);return t&&!t.n?new r(t.x,t.y):null},i.prototype._initializeLabelRegions=function(n,t){var h=this.data.primitives[0],f=this._getIconLocationFromHint(h),l=h.geometry,e=new c(this.data.crs,n),u,i,o,s;e.project(f?f.x:l.x,f?f.y:l.y);u=new r(e.lastProjectedX,e.lastProjectedY);n.normalize(u);i=this._getIconRegion(u.x,u.y);i&&this.regions.push(i);o=this._getRegionsFromHints(n,t,u,!1,i);o?(this._padding=0,Array.prototype.push.apply(this.regions,o)):(s=this._measureLabel(),i&&this._initRegionBounds(n,i,s),Array.prototype.push.apply(this.regions,this._getTextRegions(u,s,i)))},i.prototype._getTextRegions=function(n,t,i){for(var u,f=[],o=this.data.offsetX||0,s=this.data.offsetY||0,r=0,e=this._possiblePlacements.length;r<e;r++)u=this._getRegionForPosition(this._possiblePlacements[r],n,t,i),u&&f.push(u);return f},i.prototype._getRegionForPosition=function(t,u,f,e){var a,y,v,p,o,s,w,c=u.x,l=u.y,b=f.width,k=f.height,d=e?e.bounds.getBoundingBoxRelativeTo(u):h.fromPoints(u),nt=d.minPoint.x,tt=d.minPoint.y,it=d.maxPoint.x,rt=d.maxPoint.y,g=i._iconMargin;t=t||n.middleCenter;switch(t&n.horizontalMask){default:case n.center:o=0;a=c-b/2;y=a+b;w=0;break;case n.left:o=nt-c-g.left;y=c+o;a=y-b;w=2;break;case n.right:o=it-c+g.right;a=c+o;y=a+b;w=1}switch(t&n.verticalMask){default:case n.middle:s=0;v=l-k/2;p=v+k;break;case n.top:s=tt-l-g.top;p=l+s;v=p-k;break;case n.bottom:s=rt-l+g.bottom;v=l+s;p=v+k}return{label:this,text:this.data.text,secondaryText:this.data.secondaryText,anchor:new r(c,l),anchorOffset:new r(o,s),placement:t,parentRegion:e,orientation:0,horizontalAlignment:w}},i._poiLabelPlacements=[n.bottomCenter,n.topCenter,n.middleLeft,n.middleRight],i._basemapIconLabelPlacements=[n.topLeft,n.topRight,n.bottomLeft,n.bottomRight,n.bottomCenter],i._transientLensLabelTopPlacements=[n.topCenter],i._transientLensLabelBottomPlacements=[n.bottomCenter],i._transientLensLabelLeftPlacements=[n.middleLeft],i._transientLensLabelRightPlacements=[n.middleRight],i._defaultLabelPlacements=[n.middleCenter],i._iconMargin={left:4,top:1,right:4,bottom:1},i}(d),li=function(t){function i(n,r){var u=t.call(this,n)||this,f=i._roadShieldModifierStyle;switch(r){case"7443EAC9-CD76-4236-B027-22DBC504BF06":f=i._aerialShieldModifierStyle}return u.data.style=f,u.data.fontSize=f.styleDynamic.fontSize,u._possiblePlacements=i._roadShieldPlacements,u.replicaProximity=200,u}return l(i,t),i.prototype._initializeLabelRegions=function(n,t){var i=this.data,e=this._getRegionsFromHints(n,t,null,!0,null,i.shieldInstance),o,u,f,s,r;if(e)for(o=this._measureLabel(),u=a.getIconBounds(i.iconTemplates,i.iconText).getSize(),i.offsetX||(i.offsetX=u.width/2+d._defaultIconLabelOffset),i.offsetY||(i.offsetY=u.height/2+d._defaultIconLabelOffset),f=0,s=e.length;f<s;f++)r=e[f],r.text=i.iconText,r.type=1,r.size=u,this.regions.push(r),i.text&&(this._initRegionBounds(n,r,o),Array.prototype.push.apply(this.regions,this._getTextRegions(r.anchor,o,r)))},i._roadShieldPlacements=[n.topCenter],i._roadShieldModifierStyle={styleStatic:{fontOutlined:!0,outlineWidth:1,horizontalAlignment:0},styleDynamic:{font:"SegoeBing",fontSize:7.5,fontWeight:4,fontColor:"#000",outlineColor:"#fff",globalOrder:726,visible:!0,priority:0}},i._aerialShieldModifierStyle={styleStatic:{fontOutlined:!0,outlineWidth:1,horizontalAlignment:0},styleDynamic:{font:"SegoeBing",fontSize:7.5,fontWeight:4,globalOrder:726,visible:!0,fontColor:"#fff",outlineColor:"#555",priority:0}},i}(pt),wt=function(){function n(n){this._disposables=[];this._renderers=[];this._labels={};this._labelCollider=new si;this._disposables.push(this.renderingComplete=new s);var t=n.getLabelDpiScale();this._createRenderer(n,t)}return n.prototype._constructRenderers=function(n,t){return[new k(n,t,"labelCanvasId",2e4,[1])]},n.prototype._createRenderer=function(n,t){for(var u,f,e=this,i=this._constructRenderers(n,t),r=0,o=i.length;r<o;r++)this._disposables.push(i[r].labelRenderingComplete.add(function(n){Microsoft.Maps.setAsync(function(){e.renderingComplete.invoke(n)})}));(u=this._disposables).push.apply(u,i);(f=this._renderers).push.apply(f,i)},n.prototype.performHitTesting=function(n,t){for(var r=this._renderers,u=r.length,i=u-1;i>=0;i--)if(r[i]&&r[i].performHitTesting(n,t))break},n.prototype.showLabels=function(n,t){u.log(null,"renderLabels called with {0} labels",n.length);this._renderArgs={labels:n,viewport:t}},n.prototype._showLabels=function(n,t,i){for(var l,o,w,a=t.transform(i),s=this._labels,v=Object.keys(s),h={},u,y=this._renderers.length,r,c=n.length-1;c>=0;c--){var f=n[c],e=f.region,p=a.transform(e.anchor);for(e.anchor.x=p.x,e.anchor.y=p.y,e.anchorTransform=a.multiply(e.anchorTransform),u=f.id,h[u]=f,r=0;r<y;r++)if(l=this._renderers[r],s[u]){if(l.update(f))break}else if(l.draw(f))break}for(o=0,w=v.length;o<w;o++)if(u=v[o],!h[u])for(r=0;r<y;r++)if(this._renderers[r].remove(s[u]))break;this._labels=h},n.prototype.dispose=function(){f._clearDisposables(this._disposables);this._renderers=[]},n.prototype.copyCanvas=function(n){for(var t=0,i=this._renderers.length;t<i;t++)this._renderers[t].copyCanvas(n)},n.prototype.render=function(n,t,i,r,f){var o=null,e,s=this._renderers,h=s.length,c,l,a,v;if(o=this._viewport?this._viewport.transform(n):b.identity,c=o.getZoomDirection(),l=!o.nearlyEquals(b.identity,1e-6),l||this._renderArgs)for(e=0;e<h;e++)s[e].invalidateHitTestingData();if(c||this._renderArgs||f){for(e=0;e<h;e++)s[e].beginDraw(t,r);for(a=Date.now(),this._fullRender(n,o,c,t,r),v=Date.now(),i.fullRenderTime=v-a,i.labelCount=Object.keys(this._labels).length,e=0;e<h;e++)s[e].endDraw(t,r)}else if(l)for(e=0;e<h;e++)s[e].transformContainer(o);u.logLabelData(this._labels)},n.prototype.cancelRender=function(n){this._renderers.forEach(function(t){t.cancelRender(n)})},n.prototype._fullRender=function(n,t,i,r,u){var c=this._labels,h,e,y=this._renderArgs,b=this._renderers.length,o,k=!1,a,l,s,v,d,p,w;if(r&&(a=r.frame,k=f._renderAllPoiAndLabelsGL()&&(u||a.cause===7||a.cause===3||a.cause===1)),y)this._showLabels(y.labels,ui.fromIProjectedRegionId(y.viewport),n),this._renderArgs=null;else{for(l=Object.keys(c),s=0,v=l.length;s<v;s++)if(h=c[l[s]],e=h.region,d=e.label&&e.label.data&&e.label.data.primitives&&e.label.data.primitives[0],e.type!==1||!k||d.taintedTemplate||!f._renderAllPoiAndLabelsGL())for(p=t.transform(e.anchor),e.anchor.x=p.x,e.anchor.y=p.y,e.anchorTransform=t.multiply(e.anchorTransform),o=0;o<b;o++)if(this._renderers[o].update(h))break;if(i===-1&&this._labelCollider.collide(c,n.pixelWidth),i===-1||i===1)for(s=0,v=l.length;s<v;s++)if(w=l[s],h=c[w],e=h.region,e.isRejected||e.anchor.x<0||e.anchor.x>=n.pixelWidth||e.anchor.y<0||e.anchor.y>=n.pixelHeight){for(o=0;o<b;o++)this._renderers[o].remove(h);delete c[w]}}this._viewport=n},n}();t._CanvasLabelRenderer=k;t.AreaLabel=at;t.Labeler=v;t.LabelRenderer=ut;t.LabelController=yt;t.RelativePlacement=n;t.VectorLabels=wt}catch(bt){if(i.logger)i.logger.logCriticalError(bt);else throw bt;}}).call(window)