mobility-toolbox-js 3.0.0-beta.34 → 3.0.0-beta.35
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/common/utils/RealtimeEngine.d.ts +1 -1
- package/common/utils/RealtimeEngine.js +1 -1
- package/mbt.js +19 -4
- package/mbt.js.map +2 -2
- package/mbt.min.js +1 -1
- package/mbt.min.js.map +3 -3
- package/ol/controls/RoutingControl.js +9 -6
- package/ol/layers/RealtimeLayer.d.ts +6 -2
- package/ol/layers/RealtimeLayer.js +9 -0
- package/package.json +1 -1
package/mbt.min.js
CHANGED
|
@@ -582,7 +582,7 @@ uniform ${D} ${F} u_${j};
|
|
|
582
582
|
`||T===I){o=Math.max(o,_),c.push(_),_=0,v+=w,w=0;continue}let O=e[T+1]||h.font,U=Pp(O,L);r.push(U),_+=U;let J=cI(O);l.push(J),w=Math.max(w,J)}return{width:o,height:v,widths:r,heights:l,lineWidths:c}}function ub(h,e,r,l,c,o,_,v,w,T,I){h.save(),r!==1&&(h.globalAlpha===void 0?h.globalAlpha=L=>L.globalAlpha*=r:h.globalAlpha*=r),e&&h.transform.apply(h,e),l.contextInstructions?(h.translate(w,T),h.scale(I[0],I[1]),hI(l,h)):I[0]<0||I[1]<0?(h.translate(w,T),h.scale(I[0],I[1]),h.drawImage(l,c,o,_,v,0,0,_,v)):h.drawImage(l,c,o,_,v,w,T,_*I[0],v*I[1]),h.restore()}function hI(h,e){let r=h.contextInstructions;for(let l=0,c=r.length;l<c;l+=2)Array.isArray(r[l+1])?e[r[l]].apply(e,r[l+1]):e[r[l]]=r[l+1]}var ay=class h extends Ap{constructor(e){super({opacity:1,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,rotation:e.rotation!==void 0?e.rotation:0,scale:e.scale!==void 0?e.scale:1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode}),this.canvases_,this.hitDetectionCanvas_=null,this.fill_=e.fill!==void 0?e.fill:null,this.origin_=[0,0],this.points_=e.points,this.radius=e.radius,this.radius2_=e.radius2,this.angle_=e.angle!==void 0?e.angle:0,this.stroke_=e.stroke!==void 0?e.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?St.LOADING:St.LOADED,this.imageState_===St.LOADING&&this.ready().then(()=>this.imageState_=St.LOADED),this.render()}clone(){let e=this.getScale(),r=new h({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return r.setOpacity(this.getOpacity()),r}getAnchor(){let e=this.size_,r=this.getDisplacement(),l=this.getScaleArray();return[e[0]/2-r[0]/l[0],e[1]/2+r[1]/l[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(e){let r=this.canvases_[e];if(!r){let l=this.renderOptions_,c=Ai(l.size*e,l.size*e);this.draw_(l,c,e),r=c.canvas,this.canvases_[e]=r}return r}getPixelRatio(e){return e}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,r,l){if(r===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return r;let c=this.radius,o=this.radius2_===void 0?c:this.radius2_;if(c<o){let Ce=c;c=o,o=Ce}let _=this.radius2_===void 0?this.points_:this.points_*2,v=2*Math.PI/_,w=o*Math.sin(v),T=Math.sqrt(o*o-w*w),I=c-T,L=Math.sqrt(w*w+I*I),O=L/w;if(e==="miter"&&O<=l)return O*r;let U=r/2/O,J=r/2*(I/L),he=Math.sqrt((c+U)*(c+U)+J*J)-c;if(this.radius2_===void 0||e==="bevel")return he*2;let me=c*Math.sin(v),ve=Math.sqrt(c*c-me*me),we=o-ve,Re=Math.sqrt(me*me+we*we)/me;if(Re<=l){let Ce=Re*r/2-o-c;return 2*Math.max(he,Ce)}return he*2}createRenderOptions(){let e=Gs,r=Us,l=0,c=null,o=0,_,v=0;this.stroke_&&(_=Sn(this.stroke_.getColor()??vo),v=this.stroke_.getWidth()??wo,c=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset()??0,r=this.stroke_.getLineJoin()??Us,e=this.stroke_.getLineCap()??Gs,l=this.stroke_.getMiterLimit()??xo);let w=this.calculateLineJoinSize_(r,v,l),T=Math.max(this.radius,this.radius2_||0),I=Math.ceil(2*T+w);return{strokeStyle:_,strokeWidth:v,size:I,lineCap:e,lineDash:c,lineDashOffset:o,lineJoin:r,miterLimit:l}}render(){this.renderOptions_=this.createRenderOptions();let e=this.renderOptions_.size;this.canvases_={},this.hitDetectionCanvas_=null,this.size_=[e,e]}draw_(e,r,l){if(r.scale(l,l),r.translate(e.size/2,e.size/2),this.createPath_(r),this.fill_){let c=this.fill_.getColor();c===null&&(c=Zi),r.fillStyle=Sn(c),r.fill()}e.strokeStyle&&(r.strokeStyle=e.strokeStyle,r.lineWidth=e.strokeWidth,e.lineDash&&(r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset),r.lineCap=e.lineCap,r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit,r.stroke())}createHitDetectionCanvas_(e){let r;if(this.fill_){let l=this.fill_.getColor(),c=0;typeof l=="string"&&(l=_o(l)),l===null?c=1:Array.isArray(l)&&(c=l.length===4?l[3]:1),c===0&&(r=Ai(e.size,e.size),this.drawHitDetectionCanvas_(e,r))}return r?r.canvas:this.getImage(1)}createPath_(e){let r=this.points_,l=this.radius;if(r===1/0)e.arc(0,0,l,0,2*Math.PI);else{let c=this.radius2_===void 0?l:this.radius2_;this.radius2_!==void 0&&(r*=2);let o=this.angle_-Math.PI/2,_=2*Math.PI/r;for(let v=0;v<r;v++){let w=o+v*_,T=v%2===0?l:c;e.lineTo(T*Math.cos(w),T*Math.sin(w))}e.closePath()}}drawHitDetectionCanvas_(e,r){r.translate(e.size/2,e.size/2),this.createPath_(r),r.fillStyle=Zi,r.fill(),e.strokeStyle&&(r.strokeStyle=e.strokeStyle,r.lineWidth=e.strokeWidth,e.lineDash&&(r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset),r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit,r.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}},kp=ay;var ly=class h extends kp{constructor(e){e=e||{radius:5},super({points:1/0,fill:e.fill,radius:e.radius,stroke:e.stroke,scale:e.scale!==void 0?e.scale:1,rotation:e.rotation!==void 0?e.rotation:0,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode})}clone(){let e=this.getScale(),r=new h({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return r.setOpacity(this.getOpacity()),r}setRadius(e){this.radius=e,this.render()}},En=ly;var _a=class h{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=db,e.geometry!==void 0&&this.setGeometry(e.geometry),this.fill_=e.fill!==void 0?e.fill:null,this.image_=e.image!==void 0?e.image:null,this.renderer_=e.renderer!==void 0?e.renderer:null,this.hitDetectionRenderer_=e.hitDetectionRenderer!==void 0?e.hitDetectionRenderer:null,this.stroke_=e.stroke!==void 0?e.stroke:null,this.text_=e.text!==void 0?e.text:null,this.zIndex_=e.zIndex}clone(){let e=this.getGeometry();return e&&typeof e=="object"&&(e=e.clone()),new h({geometry:e??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(e){this.renderer_=e}setHitDetectionRenderer(e){this.hitDetectionRenderer_=e}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(e){this.fill_=e}getImage(){return this.image_}setImage(e){this.image_=e}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e}getText(){return this.text_}setText(e){this.text_=e}getZIndex(){return this.zIndex_}setGeometry(e){typeof e=="function"?this.geometryFunction_=e:typeof e=="string"?this.geometryFunction_=function(r){return r.get(e)}:e?e!==void 0&&(this.geometryFunction_=function(){return e}):this.geometryFunction_=db,this.geometry_=e}setZIndex(e){this.zIndex_=e}};function pb(h){let e;if(typeof h=="function")e=h;else{let r;Array.isArray(h)?r=h:(hi(typeof h.getZIndex=="function","Expected an `Style` or an array of `Style`"),r=[h]),e=function(){return r}}return e}var cy=null;function hy(h,e){if(!cy){let r=new Cr({color:"rgba(255,255,255,0.4)"}),l=new Wi({color:"#3399CC",width:1.25});cy=[new _a({image:new En({fill:r,stroke:l,radius:5}),fill:r,stroke:l})]}return cy}function fb(){let h={},e=[255,255,255,1],r=[0,153,255,1],l=3;return h.Polygon=[new _a({fill:new Cr({color:[255,255,255,.5]})})],h.MultiPolygon=h.Polygon,h.LineString=[new _a({stroke:new Wi({color:e,width:l+2})}),new _a({stroke:new Wi({color:r,width:l})})],h.MultiLineString=h.LineString,h.Circle=h.Polygon.concat(h.LineString),h.Point=[new _a({image:new En({radius:l*2,fill:new Cr({color:r}),stroke:new Wi({color:e,width:l/2})}),zIndex:1/0})],h.MultiPoint=h.Point,h.GeometryCollection=h.Polygon.concat(h.LineString,h.Point),h}function db(h){return h.getGeometry()}var Er=_a;var uI="#333",uy=class h{constructor(e){e=e||{},this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.scale_=e.scale,this.scaleArray_=js(e.scale!==void 0?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.justify_=e.justify,this.repeat_=e.repeat,this.textBaseline_=e.textBaseline,this.fill_=e.fill!==void 0?e.fill:new Cr({color:uI}),this.maxAngle_=e.maxAngle!==void 0?e.maxAngle:Math.PI/4,this.placement_=e.placement!==void 0?e.placement:"point",this.overflow_=!!e.overflow,this.stroke_=e.stroke!==void 0?e.stroke:null,this.offsetX_=e.offsetX!==void 0?e.offsetX:0,this.offsetY_=e.offsetY!==void 0?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=e.padding===void 0?null:e.padding,this.declutterMode_=e.declutterMode}clone(){let e=this.getScale();return new h({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(e){this.overflow_=e}setFont(e){this.font_=e}setMaxAngle(e){this.maxAngle_=e}setOffsetX(e){this.offsetX_=e}setOffsetY(e){this.offsetY_=e}setPlacement(e){this.placement_=e}setRepeat(e){this.repeat_=e}setRotateWithView(e){this.rotateWithView_=e}setFill(e){this.fill_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=js(e!==void 0?e:1)}setStroke(e){this.stroke_=e}setText(e){this.text_=e}setTextAlign(e){this.textAlign_=e}setJustify(e){this.justify_=e}setTextBaseline(e){this.textBaseline_=e}setBackgroundFill(e){this.backgroundFill_=e}setBackgroundStroke(e){this.backgroundStroke_=e}setPadding(e){this.padding_=e}},mb=uy;function Lp(h,e,r=0,l=h.length-1,c=dI){for(;l>r;){if(l-r>600){let w=l-r+1,T=e-r+1,I=Math.log(w),L=.5*Math.exp(2*I/3),O=.5*Math.sqrt(I*L*(w-L)/w)*(T-w/2<0?-1:1),U=Math.max(r,Math.floor(e-T*L/w+O)),J=Math.min(l,Math.floor(e+(w-T)*L/w+O));Lp(h,e,U,J,c)}let o=h[e],_=r,v=l;for(Iu(h,r,e),c(h[l],o)>0&&Iu(h,r,l);_<v;){for(Iu(h,_,v),_++,v--;c(h[_],o)<0;)_++;for(;c(h[v],o)>0;)v--}c(h[r],o)===0?Iu(h,r,v):(v++,Iu(h,v,l)),v<=e&&(r=v+1),e<=v&&(l=v-1)}}function Iu(h,e,r){let l=h[e];h[e]=h[r],h[r]=l}function dI(h,e){return h<e?-1:h>e?1:0}var ul=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let r=this.data,l=[];if(!Fp(e,r))return l;let c=this.toBBox,o=[];for(;r;){for(let _=0;_<r.children.length;_++){let v=r.children[_],w=r.leaf?c(v):v;Fp(e,w)&&(r.leaf?l.push(v):py(e,w)?this._all(v,l):o.push(v))}r=o.pop()}return l}collides(e){let r=this.data;if(!Fp(e,r))return!1;let l=[];for(;r;){for(let c=0;c<r.children.length;c++){let o=r.children[c],_=r.leaf?this.toBBox(o):o;if(Fp(e,_)){if(r.leaf||py(e,_))return!0;l.push(o)}}r=l.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let l=0;l<e.length;l++)this.insert(e[l]);return this}let r=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=r;else if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){let l=this.data;this.data=r,r=l}this._insert(r,this.data.height-r.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Rc([]),this}remove(e,r){if(!e)return this;let l=this.data,c=this.toBBox(e),o=[],_=[],v,w,T;for(;l||o.length;){if(l||(l=o.pop(),w=o[o.length-1],v=_.pop(),T=!0),l.leaf){let I=pI(e,l.children,r);if(I!==-1)return l.children.splice(I,1),o.push(l),this._condense(o),this}!T&&!l.leaf&&py(l,c)?(o.push(l),_.push(v),v=0,w=l,l=l.children[0]):w?(v++,l=w.children[v],T=!1):l=null}return this}toBBox(e){return e}compareMinX(e,r){return e.minX-r.minX}compareMinY(e,r){return e.minY-r.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,r){let l=[];for(;e;)e.leaf?r.push(...e.children):l.push(...e.children),e=l.pop();return r}_build(e,r,l,c){let o=l-r+1,_=this._maxEntries,v;if(o<=_)return v=Rc(e.slice(r,l+1)),Pc(v,this.toBBox),v;c||(c=Math.ceil(Math.log(o)/Math.log(_)),_=Math.ceil(o/Math.pow(_,c-1))),v=Rc([]),v.leaf=!1,v.height=c;let w=Math.ceil(o/_),T=w*Math.ceil(Math.sqrt(_));gb(e,r,l,T,this.compareMinX);for(let I=r;I<=l;I+=T){let L=Math.min(I+T-1,l);gb(e,I,L,w,this.compareMinY);for(let O=I;O<=L;O+=w){let U=Math.min(O+w-1,L);v.children.push(this._build(e,O,U,c-1))}}return Pc(v,this.toBBox),v}_chooseSubtree(e,r,l,c){for(;c.push(r),!(r.leaf||c.length-1===l);){let o=1/0,_=1/0,v;for(let w=0;w<r.children.length;w++){let T=r.children[w],I=dy(T),L=gI(e,T)-I;L<_?(_=L,o=I<o?I:o,v=T):L===_&&I<o&&(o=I,v=T)}r=v||r.children[0]}return r}_insert(e,r,l){let c=l?e:this.toBBox(e),o=[],_=this._chooseSubtree(c,this.data,r,o);for(_.children.push(e),Eu(_,c);r>=0&&o[r].children.length>this._maxEntries;)this._split(o,r),r--;this._adjustParentBBoxes(c,o,r)}_split(e,r){let l=e[r],c=l.children.length,o=this._minEntries;this._chooseSplitAxis(l,o,c);let _=this._chooseSplitIndex(l,o,c),v=Rc(l.children.splice(_,l.children.length-_));v.height=l.height,v.leaf=l.leaf,Pc(l,this.toBBox),Pc(v,this.toBBox),r?e[r-1].children.push(v):this._splitRoot(l,v)}_splitRoot(e,r){this.data=Rc([e,r]),this.data.height=e.height+1,this.data.leaf=!1,Pc(this.data,this.toBBox)}_chooseSplitIndex(e,r,l){let c,o=1/0,_=1/0;for(let v=r;v<=l-r;v++){let w=Cu(e,0,v,this.toBBox),T=Cu(e,v,l,this.toBBox),I=yI(w,T),L=dy(w)+dy(T);I<o?(o=I,c=v,_=L<_?L:_):I===o&&L<_&&(_=L,c=v)}return c||l-r}_chooseSplitAxis(e,r,l){let c=e.leaf?this.compareMinX:fI,o=e.leaf?this.compareMinY:mI,_=this._allDistMargin(e,r,l,c),v=this._allDistMargin(e,r,l,o);_<v&&e.children.sort(c)}_allDistMargin(e,r,l,c){e.children.sort(c);let o=this.toBBox,_=Cu(e,0,r,o),v=Cu(e,l-r,l,o),w=Dp(_)+Dp(v);for(let T=r;T<l-r;T++){let I=e.children[T];Eu(_,e.leaf?o(I):I),w+=Dp(_)}for(let T=l-r-1;T>=r;T--){let I=e.children[T];Eu(v,e.leaf?o(I):I),w+=Dp(v)}return w}_adjustParentBBoxes(e,r,l){for(let c=l;c>=0;c--)Eu(r[c],e)}_condense(e){for(let r=e.length-1,l;r>=0;r--)e[r].children.length===0?r>0?(l=e[r-1].children,l.splice(l.indexOf(e[r]),1)):this.clear():Pc(e[r],this.toBBox)}};function pI(h,e,r){if(!r)return e.indexOf(h);for(let l=0;l<e.length;l++)if(r(h,e[l]))return l;return-1}function Pc(h,e){Cu(h,0,h.children.length,e,h)}function Cu(h,e,r,l,c){c||(c=Rc(null)),c.minX=1/0,c.minY=1/0,c.maxX=-1/0,c.maxY=-1/0;for(let o=e;o<r;o++){let _=h.children[o];Eu(c,h.leaf?l(_):_)}return c}function Eu(h,e){return h.minX=Math.min(h.minX,e.minX),h.minY=Math.min(h.minY,e.minY),h.maxX=Math.max(h.maxX,e.maxX),h.maxY=Math.max(h.maxY,e.maxY),h}function fI(h,e){return h.minX-e.minX}function mI(h,e){return h.minY-e.minY}function dy(h){return(h.maxX-h.minX)*(h.maxY-h.minY)}function Dp(h){return h.maxX-h.minX+(h.maxY-h.minY)}function gI(h,e){return(Math.max(e.maxX,h.maxX)-Math.min(e.minX,h.minX))*(Math.max(e.maxY,h.maxY)-Math.min(e.minY,h.minY))}function yI(h,e){let r=Math.max(h.minX,e.minX),l=Math.max(h.minY,e.minY),c=Math.min(h.maxX,e.maxX),o=Math.min(h.maxY,e.maxY);return Math.max(0,c-r)*Math.max(0,o-l)}function py(h,e){return h.minX<=e.minX&&h.minY<=e.minY&&e.maxX<=h.maxX&&e.maxY<=h.maxY}function Fp(h,e){return e.minX<=h.maxX&&e.minY<=h.maxY&&e.maxX>=h.minX&&e.maxY>=h.minY}function Rc(h){return{children:h,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function gb(h,e,r,l,c){let o=[e,r];for(;o.length;){if(r=o.pop(),e=o.pop(),r-e<=l)continue;let _=e+Math.ceil((r-e)/l/2)*l;Lp(h,_,e,r,c),o.push(e,_,_,r)}}function yb(h,e,r,l){return r!==void 0&&l!==void 0?[r/h,l/e]:r!==void 0?r/h:l!==void 0?l/e:1}var fy=class h extends Ap{constructor(e){e=e||{};let r=e.opacity!==void 0?e.opacity:1,l=e.rotation!==void 0?e.rotation:0,c=e.scale!==void 0?e.scale:1,o=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:r,rotation:l,scale:c,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:o,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;let _=e.img!==void 0?e.img:null,v=e.src;hi(!(v!==void 0&&_),"`image` and `src` cannot be provided at the same time"),(v===void 0||v.length===0)&&_&&(v=_.src||Vt(_)),hi(v!==void 0&&v.length>0,"A defined and non-empty `src` or `image` must be provided"),hi(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let w;if(e.src!==void 0?w=St.IDLE:_!==void 0&&("complete"in _?_.complete?w=_.src?St.LOADED:St.IDLE:w=St.LOADING:w=St.LOADED),this.color_=e.color!==void 0?_o(e.color):null,this.iconImage_=Mc(_,v,this.crossOrigin_,w,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,this.initialOptions_,e.width!==void 0||e.height!==void 0){let T,I;if(e.size)[T,I]=e.size;else{let L=this.getImage(1);if(L.width&&L.height)T=L.width,I=L.height;else if(L instanceof HTMLImageElement){this.initialOptions_=e;let O=()=>{if(this.unlistenImageChange(O),!this.initialOptions_)return;let U=this.iconImage_.getSize();this.setScale(yb(U[0],U[1],e.width,e.height))};this.listenImageChange(O);return}}T!==void 0&&this.setScale(yb(T,I,e.width,e.height))}}clone(){let e,r,l;return this.initialOptions_?(r=this.initialOptions_.width,l=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new h({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:r,height:l,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;let c=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!c)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=c[0]),this.anchorYUnits_=="fraction"&&(e[1]*=c[1])}if(this.anchorOrigin_!="top-left"){if(!c)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+c[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+c[1])}this.normalizedAnchor_=e}let r=this.getDisplacement(),l=this.getScaleArray();return[e[0]-r[0]/l[0],e[1]+r[1]/l[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){let r=this.getSize(),l=this.iconImage_.getSize();if(!r||!l)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=l[0]-r[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=l[1]-r[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==St.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){let e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==St.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(ui.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(ui.CHANGE,e)}ready(){return this.iconImage_.ready()}},Tu=fy;var dl=0;var Gr=1<<dl++,Ut=1<<dl++,rn=1<<dl++,Xn=1<<dl++,va=1<<dl++,Mu=1<<dl++,zp=Math.pow(2,dl)-1,gy={[Gr]:"boolean",[Ut]:"number",[rn]:"string",[Xn]:"color",[va]:"number[]",[Mu]:"size"},_I=Object.keys(gy).map(Number).sort(gs);function xI(h){return h in gy}function Au(h){let e=[];for(let r of _I)Pu(h,r)&&e.push(gy[r]);return e.length===0?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function Pu(h,e){return(h&e)===e}function xa(h,e){return h===e}var Pi=class{constructor(e,r){if(!xI(e))throw new Error(`literal expressions must have a specific type, got ${Au(e)}`);this.type=e,this.value=r}},my=class{constructor(e,r,...l){this.type=e,this.operator=r,this.args=l}};function yy(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1}}function lr(h,e,r){switch(typeof h){case"boolean":{if(xa(e,rn))return new Pi(rn,h?"true":"false");if(!Pu(e,Gr))throw new Error(`got a boolean, but expected ${Au(e)}`);return new Pi(Gr,h)}case"number":{if(xa(e,Mu))return new Pi(Mu,js(h));if(xa(e,Gr))return new Pi(Gr,!!h);if(xa(e,rn))return new Pi(rn,h.toString());if(!Pu(e,Ut))throw new Error(`got a number, but expected ${Au(e)}`);return new Pi(Ut,h)}case"string":{if(xa(e,Xn))return new Pi(Xn,bu(h));if(xa(e,Gr))return new Pi(Gr,!!h);if(!Pu(e,rn))throw new Error(`got a string, but expected ${Au(e)}`);return new Pi(rn,h)}default:}if(!Array.isArray(h))throw new Error("expression must be an array or a primitive value");if(h.length===0)throw new Error("empty expression");if(typeof h[0]=="string")return PI(h,e,r);for(let l of h)if(typeof l!="number")throw new Error("expected an array of numbers");if(xa(e,Mu)){if(h.length!==2)throw new Error(`expected an array of two values for a size, got ${h.length}`);return new Pi(Mu,h)}if(xa(e,Xn)){if(h.length===3)return new Pi(Xn,[...h,1]);if(h.length===4)return new Pi(Xn,h);throw new Error(`expected an array of 3 or 4 values for a color, got ${h.length}`)}if(!Pu(e,va))throw new Error(`got an array of numbers, but expected ${Au(e)}`);return new Pi(va,h)}var Te={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},vI={[Te.Get]:It(kt(1,1/0),_b),[Te.Var]:It(kt(1,1),bI),[Te.Has]:It(kt(1,1/0),_b),[Te.Id]:It(wI,kc),[Te.Concat]:It(kt(2,1/0),ei(rn)),[Te.GeometryType]:It(SI,kc),[Te.LineMetric]:It(kc),[Te.Resolution]:It(kc),[Te.Zoom]:It(kc),[Te.Time]:It(kc),[Te.Any]:It(kt(2,1/0),ei(Gr)),[Te.All]:It(kt(2,1/0),ei(Gr)),[Te.Not]:It(kt(1,1),ei(Gr)),[Te.Equal]:It(kt(2,2),ei(zp)),[Te.NotEqual]:It(kt(2,2),ei(zp)),[Te.GreaterThan]:It(kt(2,2),ei(Ut)),[Te.GreaterThanOrEqualTo]:It(kt(2,2),ei(Ut)),[Te.LessThan]:It(kt(2,2),ei(Ut)),[Te.LessThanOrEqualTo]:It(kt(2,2),ei(Ut)),[Te.Multiply]:It(kt(2,1/0),xb),[Te.Coalesce]:It(kt(2,1/0),xb),[Te.Divide]:It(kt(2,2),ei(Ut)),[Te.Add]:It(kt(2,1/0),ei(Ut)),[Te.Subtract]:It(kt(2,2),ei(Ut)),[Te.Clamp]:It(kt(3,3),ei(Ut)),[Te.Mod]:It(kt(2,2),ei(Ut)),[Te.Pow]:It(kt(2,2),ei(Ut)),[Te.Abs]:It(kt(1,1),ei(Ut)),[Te.Floor]:It(kt(1,1),ei(Ut)),[Te.Ceil]:It(kt(1,1),ei(Ut)),[Te.Round]:It(kt(1,1),ei(Ut)),[Te.Sin]:It(kt(1,1),ei(Ut)),[Te.Cos]:It(kt(1,1),ei(Ut)),[Te.Atan]:It(kt(1,2),ei(Ut)),[Te.Sqrt]:It(kt(1,1),ei(Ut)),[Te.Match]:It(kt(4,1/0),vb,CI),[Te.Between]:It(kt(3,3),ei(Ut)),[Te.Interpolate]:It(kt(6,1/0),vb,EI),[Te.Case]:It(kt(3,1/0),II,TI),[Te.In]:It(kt(2,2),MI),[Te.Number]:It(kt(1,1/0),ei(zp)),[Te.String]:It(kt(1,1/0),ei(zp)),[Te.Array]:It(kt(1,1/0),ei(Ut)),[Te.Color]:It(kt(1,4),ei(Ut)),[Te.Band]:It(kt(1,3),ei(Ut)),[Te.Palette]:It(kt(2,2),AI),[Te.ToString]:It(kt(1,1),ei(Gr|Ut|rn|Xn))};function _b(h,e,r){let l=h.length-1,c=new Array(l);for(let o=0;o<l;++o){let _=h[o+1];switch(typeof _){case"number":{c[o]=new Pi(Ut,_);break}case"string":{c[o]=new Pi(rn,_);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${_}`)}o===0&&r.properties.add(String(_))}return c}function bI(h,e,r){let l=h[1];if(typeof l!="string")throw new Error("expected a string argument for var operation");return r.variables.add(l),[new Pi(rn,l)]}function wI(h,e,r){r.featureId=!0}function SI(h,e,r){r.geometryType=!0}function kc(h,e,r){let l=h[0];if(h.length!==1)throw new Error(`expected no arguments for ${l} operation`);return[]}function kt(h,e){return function(r,l,c){let o=r[0],_=r.length-1;if(h===e){if(_!==h){let v=h===1?"":"s";throw new Error(`expected ${h} argument${v} for ${o}, got ${_}`)}}else if(_<h||_>e){let v=e===1/0?`${h} or more`:`${h} to ${e}`;throw new Error(`expected ${v} arguments for ${o}, got ${_}`)}}}function xb(h,e,r){let l=h.length-1,c=new Array(l);for(let o=0;o<l;++o){let _=lr(h[o+1],e,r);c[o]=_}return c}function ei(h){return function(e,r,l){let c=e.length-1,o=new Array(c);for(let _=0;_<c;++_){let v=lr(e[_+1],h,l);o[_]=v}return o}}function II(h,e,r){let l=h[0],c=h.length-1;if(c%2===0)throw new Error(`expected an odd number of arguments for ${l}, got ${c} instead`)}function vb(h,e,r){let l=h[0],c=h.length-1;if(c%2===1)throw new Error(`expected an even number of arguments for operation ${l}, got ${c} instead`)}function CI(h,e,r){let l=h.length-1,c=rn|Ut|Gr,o=lr(h[1],c,r),_=lr(h[h.length-1],e,r),v=new Array(l-2);for(let w=0;w<l-2;w+=2){try{let T=lr(h[w+2],o.type,r);v[w]=T}catch(T){throw new Error(`failed to parse argument ${w+1} of match expression: ${T.message}`)}try{let T=lr(h[w+3],_.type,r);v[w+1]=T}catch(T){throw new Error(`failed to parse argument ${w+2} of match expression: ${T.message}`)}}return[o,...v,_]}function EI(h,e,r){let l=h[1],c;switch(l[0]){case"linear":c=1;break;case"exponential":let w=l[1];if(typeof w!="number"||w<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(w)} instead`);c=w;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(l)}`)}let o=new Pi(Ut,c),_;try{_=lr(h[2],Ut,r)}catch(w){throw new Error(`failed to parse argument 1 in interpolate expression: ${w.message}`)}let v=new Array(h.length-3);for(let w=0;w<v.length;w+=2){try{let T=lr(h[w+3],Ut,r);v[w]=T}catch(T){throw new Error(`failed to parse argument ${w+2} for interpolate expression: ${T.message}`)}try{let T=lr(h[w+4],e,r);v[w+1]=T}catch(T){throw new Error(`failed to parse argument ${w+3} for interpolate expression: ${T.message}`)}}return[o,_,...v]}function TI(h,e,r){let l=lr(h[h.length-1],e,r),c=new Array(h.length-1);for(let o=0;o<c.length-1;o+=2){try{let _=lr(h[o+1],Gr,r);c[o]=_}catch(_){throw new Error(`failed to parse argument ${o} of case expression: ${_.message}`)}try{let _=lr(h[o+2],l.type,r);c[o+1]=_}catch(_){throw new Error(`failed to parse argument ${o+1} of case expression: ${_.message}`)}}return c[c.length-1]=l,c}function MI(h,e,r){let l=h[2];if(!Array.isArray(l))throw new Error('the second argument for the "in" operator must be an array');let c;if(typeof l[0]=="string"){if(l[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(l[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');l=l[1],c=rn}else c=Ut;let o=new Array(l.length);for(let v=0;v<o.length;v++)try{let w=lr(l[v],c,r);o[v]=w}catch(w){throw new Error(`failed to parse haystack item ${v} for "in" expression: ${w.message}`)}return[lr(h[1],c,r),...o]}function AI(h,e,r){let l;try{l=lr(h[1],Ut,r)}catch(_){throw new Error(`failed to parse first argument in palette expression: ${_.message}`)}let c=h[2];if(!Array.isArray(c))throw new Error("the second argument of palette must be an array");let o=new Array(c.length);for(let _=0;_<o.length;_++){let v;try{v=lr(c[_],Xn,r)}catch(w){throw new Error(`failed to parse color at index ${_} in palette expression: ${w.message}`)}if(!(v instanceof Pi))throw new Error(`the palette color at index ${_} must be a literal value`);o[_]=v}return[l,...o]}function It(...h){return function(e,r,l){let c=e[0],o;for(let _=0;_<h.length;_++){let v=h[_](e,r,l);if(_==h.length-1){if(!v)throw new Error("expected last argument validator to return the parsed args");o=v}}return new my(r,c,...o)}}function PI(h,e,r){let l=h[0],c=vI[l];if(!c)throw new Error(`unknown operator: ${l}`);return c(h,e,r)}function _y(h){if(!h)return"";let e=h.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return _y(h.getGeometries()[0]);default:return""}}function xy(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function qs(h,e,r){let l=lr(h,e,r);return Is(l,r)}function Is(h,e){if(h instanceof Pi){if(h.type===Xn&&typeof h.value=="string"){let l=bu(h.value);return function(){return l}}return function(){return h.value}}let r=h.operator;switch(r){case Te.Number:case Te.String:case Te.Coalesce:return RI(h,e);case Te.Get:case Te.Var:case Te.Has:return kI(h,e);case Te.Id:return l=>l.featureId;case Te.GeometryType:return l=>l.geometryType;case Te.Concat:{let l=h.args.map(c=>Is(c,e));return c=>"".concat(...l.map(o=>o(c).toString()))}case Te.Resolution:return l=>l.resolution;case Te.Any:case Te.All:case Te.Between:case Te.In:case Te.Not:return DI(h,e);case Te.Equal:case Te.NotEqual:case Te.LessThan:case Te.LessThanOrEqualTo:case Te.GreaterThan:case Te.GreaterThanOrEqualTo:return LI(h,e);case Te.Multiply:case Te.Divide:case Te.Add:case Te.Subtract:case Te.Clamp:case Te.Mod:case Te.Pow:case Te.Abs:case Te.Floor:case Te.Ceil:case Te.Round:case Te.Sin:case Te.Cos:case Te.Atan:case Te.Sqrt:return FI(h,e);case Te.Case:return zI(h,e);case Te.Match:return OI(h,e);case Te.Interpolate:return BI(h,e);case Te.ToString:return NI(h,e);default:throw new Error(`Unsupported operator ${r}`)}}function RI(h,e){let r=h.operator,l=h.args.length,c=new Array(l);for(let o=0;o<l;++o)c[o]=Is(h.args[o],e);switch(r){case Te.Coalesce:return o=>{for(let _=0;_<l;++_){let v=c[_](o);if(typeof v<"u"&&v!==null)return v}throw new Error("Expected one of the values to be non-null")};case Te.Number:case Te.String:return o=>{for(let _=0;_<l;++_){let v=c[_](o);if(typeof v===r)return v}throw new Error(`Expected one of the values to be a ${r}`)};default:throw new Error(`Unsupported assertion operator ${r}`)}}function kI(h,e){let l=h.args[0].value;switch(h.operator){case Te.Get:return c=>{let o=h.args,_=c.properties[l];for(let v=1,w=o.length;v<w;++v){let I=o[v].value;_=_[I]}return _};case Te.Var:return c=>c.variables[l];case Te.Has:return c=>{let o=h.args;if(!(l in c.properties))return!1;let _=c.properties[l];for(let v=1,w=o.length;v<w;++v){let I=o[v].value;if(!_||!Object.hasOwn(_,I))return!1;_=_[I]}return!0};default:throw new Error(`Unsupported accessor operator ${h.operator}`)}}function LI(h,e){let r=h.operator,l=Is(h.args[0],e),c=Is(h.args[1],e);switch(r){case Te.Equal:return o=>l(o)===c(o);case Te.NotEqual:return o=>l(o)!==c(o);case Te.LessThan:return o=>l(o)<c(o);case Te.LessThanOrEqualTo:return o=>l(o)<=c(o);case Te.GreaterThan:return o=>l(o)>c(o);case Te.GreaterThanOrEqualTo:return o=>l(o)>=c(o);default:throw new Error(`Unsupported comparison operator ${r}`)}}function DI(h,e){let r=h.operator,l=h.args.length,c=new Array(l);for(let o=0;o<l;++o)c[o]=Is(h.args[o],e);switch(r){case Te.Any:return o=>{for(let _=0;_<l;++_)if(c[_](o))return!0;return!1};case Te.All:return o=>{for(let _=0;_<l;++_)if(!c[_](o))return!1;return!0};case Te.Between:return o=>{let _=c[0](o),v=c[1](o),w=c[2](o);return _>=v&&_<=w};case Te.In:return o=>{let _=c[0](o);for(let v=1;v<l;++v)if(_===c[v](o))return!0;return!1};case Te.Not:return o=>!c[0](o);default:throw new Error(`Unsupported logical operator ${r}`)}}function FI(h,e){let r=h.operator,l=h.args.length,c=new Array(l);for(let o=0;o<l;++o)c[o]=Is(h.args[o],e);switch(r){case Te.Multiply:return o=>{let _=1;for(let v=0;v<l;++v)_*=c[v](o);return _};case Te.Divide:return o=>c[0](o)/c[1](o);case Te.Add:return o=>{let _=0;for(let v=0;v<l;++v)_+=c[v](o);return _};case Te.Subtract:return o=>c[0](o)-c[1](o);case Te.Clamp:return o=>{let _=c[0](o),v=c[1](o);if(_<v)return v;let w=c[2](o);return _>w?w:_};case Te.Mod:return o=>c[0](o)%c[1](o);case Te.Pow:return o=>Math.pow(c[0](o),c[1](o));case Te.Abs:return o=>Math.abs(c[0](o));case Te.Floor:return o=>Math.floor(c[0](o));case Te.Ceil:return o=>Math.ceil(c[0](o));case Te.Round:return o=>Math.round(c[0](o));case Te.Sin:return o=>Math.sin(c[0](o));case Te.Cos:return o=>Math.cos(c[0](o));case Te.Atan:return l===2?o=>Math.atan2(c[0](o),c[1](o)):o=>Math.atan(c[0](o));case Te.Sqrt:return o=>Math.sqrt(c[0](o));default:throw new Error(`Unsupported numeric operator ${r}`)}}function zI(h,e){let r=h.args.length,l=new Array(r);for(let c=0;c<r;++c)l[c]=Is(h.args[c],e);return c=>{for(let o=0;o<r-1;o+=2)if(l[o](c))return l[o+1](c);return l[r-1](c)}}function OI(h,e){let r=h.args.length,l=new Array(r);for(let c=0;c<r;++c)l[c]=Is(h.args[c],e);return c=>{let o=l[0](c);for(let _=1;_<r;_+=2)if(o===l[_](c))return l[_+1](c);return l[r-1](c)}}function BI(h,e){let r=h.args.length,l=new Array(r);for(let c=0;c<r;++c)l[c]=Is(h.args[c],e);return c=>{let o=l[0](c),_=l[1](c),v,w;for(let T=2;T<r;T+=2){let I=l[T](c),L=l[T+1](c),O=Array.isArray(L);if(O&&(L=ib(L)),I>=_)return T===2?L:O?VI(o,_,v,w,I,L):Ru(o,_,v,w,I,L);v=I,w=L}return w}}function NI(h,e){let r=h.operator,l=h.args.length,c=new Array(l);for(let o=0;o<l;++o)c[o]=Is(h.args[o],e);switch(r){case Te.ToString:return o=>{let _=c[0](o);return h.args[0].type===Xn?wu(_):_.toString()};default:throw new Error(`Unsupported convert operator ${r}`)}}function Ru(h,e,r,l,c,o){let _=c-r;if(_===0)return l;let v=e-r,w=h===1?v/_:(Math.pow(h,v)-1)/(Math.pow(h,_)-1);return l+w*(o-l)}function VI(h,e,r,l,c,o){if(c-r===0)return l;let v=Xg(l),w=Xg(o),T=w[2]-v[2];T>180?T-=360:T<-180&&(T+=360);let I=[Ru(h,e,r,v[0],c,w[0]),Ru(h,e,r,v[1],c,w[1]),v[2]+Ru(h,e,r,0,c,T),Ru(h,e,r,l[3],c,o[3])];return Hg(rb(I))}function jI(h){return!0}function Ib(h){let e=yy(),r=GI(h,e),l=xy();return function(c,o){if(l.properties=c.getPropertiesInternal(),l.resolution=o,e.featureId){let _=c.getId();_!==void 0?l.featureId=_:l.featureId=null}return e.geometryType&&(l.geometryType=_y(c.getGeometry())),r(l)}}function wy(h){let e=yy(),r=h.length,l=new Array(r);for(let _=0;_<r;++_)l[_]=vy(h[_],e);let c=xy(),o=new Array(r);return function(_,v){if(c.properties=_.getPropertiesInternal(),c.resolution=v,e.featureId){let T=_.getId();T!==void 0?c.featureId=T:c.featureId=null}let w=0;for(let T=0;T<r;++T){let I=l[T](c);I&&(o[w]=I,w+=1)}return o.length=w,o}}function GI(h,e){let r=h.length,l=new Array(r);for(let c=0;c<r;++c){let o=h[c],_="filter"in o?qs(o.filter,Gr,e):jI,v;if(Array.isArray(o.style)){let w=o.style.length;v=new Array(w);for(let T=0;T<w;++T)v[T]=vy(o.style[T],e)}else v=[vy(o.style,e)];l[c]={filter:_,styles:v}}return function(c){let o=[],_=!1;for(let v=0;v<r;++v){let w=l[v].filter;if(w(c)&&!(h[v].else&&_)){_=!0;for(let T of l[v].styles){let I=T(c);I&&o.push(I)}}}return o}}function vy(h,e){let r=ku(h,"",e),l=Lu(h,"",e),c=UI(h,e),o=qI(h,e),_=Tn(h,"z-index",e);if(!r&&!l&&!c&&!o&&!Wn(h))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(h));let v=new Er;return function(w){let T=!0;if(r){let I=r(w);I&&(T=!1),v.setFill(I)}if(l){let I=l(w);I&&(T=!1),v.setStroke(I)}if(c){let I=c(w);I&&(T=!1),v.setText(I)}if(o){let I=o(w);I&&(T=!1),v.setImage(I)}return _&&v.setZIndex(_(w)),T?null:v}}function ku(h,e,r){let l;if(e+"fill-pattern-src"in h)l=XI(h,e+"fill-",r);else{if(h[e+"fill-color"]==="none")return o=>null;l=Sy(h,e+"fill-color",r)}if(!l)return null;let c=new Cr;return function(o){let _=l(o);return _===Tp?null:(c.setColor(_),c)}}function Lu(h,e,r){let l=Tn(h,e+"stroke-width",r),c=Sy(h,e+"stroke-color",r);if(!l&&!c)return null;let o=So(h,e+"stroke-line-cap",r),_=So(h,e+"stroke-line-join",r),v=Cb(h,e+"stroke-line-dash",r),w=Tn(h,e+"stroke-line-dash-offset",r),T=Tn(h,e+"stroke-miter-limit",r),I=new Wi;return function(L){if(c){let O=c(L);if(O===Tp)return null;I.setColor(O)}if(l&&I.setWidth(l(L)),o){let O=o(L);if(O!=="butt"&&O!=="round"&&O!=="square")throw new Error("Expected butt, round, or square line cap");I.setLineCap(O)}if(_){let O=_(L);if(O!=="bevel"&&O!=="round"&&O!=="miter")throw new Error("Expected bevel, round, or miter line join");I.setLineJoin(O)}return v&&I.setLineDash(v(L)),w&&I.setLineDashOffset(w(L)),T&&I.setMiterLimit(T(L)),I}}function UI(h,e){let r="text-",l=So(h,r+"value",e);if(!l)return null;let c=ku(h,r,e),o=ku(h,r+"background-",e),_=Lu(h,r,e),v=Lu(h,r+"background-",e),w=So(h,r+"font",e),T=Tn(h,r+"max-angle",e),I=Tn(h,r+"offset-x",e),L=Tn(h,r+"offset-y",e),O=Du(h,r+"overflow",e),U=So(h,r+"placement",e),J=Tn(h,r+"repeat",e),ce=Np(h,r+"scale",e),he=Du(h,r+"rotate-with-view",e),me=Tn(h,r+"rotation",e),ve=So(h,r+"align",e),we=So(h,r+"justify",e),Me=So(h,r+"baseline",e),Re=Cb(h,r+"padding",e),Ce=Vp(h,r+"declutter-mode"),Le=new mb({declutterMode:Ce});return function(Ue){if(Le.setText(l(Ue)),c&&Le.setFill(c(Ue)),o&&Le.setBackgroundFill(o(Ue)),_&&Le.setStroke(_(Ue)),v&&Le.setBackgroundStroke(v(Ue)),w&&Le.setFont(w(Ue)),T&&Le.setMaxAngle(T(Ue)),I&&Le.setOffsetX(I(Ue)),L&&Le.setOffsetY(L(Ue)),O&&Le.setOverflow(O(Ue)),U){let Ae=U(Ue);if(Ae!=="point"&&Ae!=="line")throw new Error("Expected point or line for text-placement");Le.setPlacement(Ae)}if(J&&Le.setRepeat(J(Ue)),ce&&Le.setScale(ce(Ue)),he&&Le.setRotateWithView(he(Ue)),me&&Le.setRotation(me(Ue)),ve){let Ae=ve(Ue);if(Ae!=="left"&&Ae!=="center"&&Ae!=="right"&&Ae!=="end"&&Ae!=="start")throw new Error("Expected left, right, center, start, or end for text-align");Le.setTextAlign(Ae)}if(we){let Ae=we(Ue);if(Ae!=="left"&&Ae!=="right"&&Ae!=="center")throw new Error("Expected left, right, or center for text-justify");Le.setJustify(Ae)}if(Me){let Ae=Me(Ue);if(Ae!=="bottom"&&Ae!=="top"&&Ae!=="middle"&&Ae!=="alphabetic"&&Ae!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");Le.setTextBaseline(Ae)}return Re&&Le.setPadding(Re(Ue)),Le}}function qI(h,e){return"icon-src"in h?$I(h,e):"shape-points"in h?WI(h,e):"circle-radius"in h?ZI(h,e):null}function $I(h,e){let r="icon-",l=r+"src",c=Eb(h[l],l),o=Op(h,r+"anchor",e),_=Np(h,r+"scale",e),v=Tn(h,r+"opacity",e),w=Op(h,r+"displacement",e),T=Tn(h,r+"rotation",e),I=Du(h,r+"rotate-with-view",e),L=wb(h,r+"anchor-origin"),O=Sb(h,r+"anchor-x-units"),U=Sb(h,r+"anchor-y-units"),J=JI(h,r+"color"),ce=YI(h,r+"cross-origin"),he=KI(h,r+"offset"),me=wb(h,r+"offset-origin"),ve=Bp(h,r+"width"),we=Bp(h,r+"height"),Me=HI(h,r+"size"),Re=Vp(h,r+"declutter-mode"),Ce=new Tu({src:c,anchorOrigin:L,anchorXUnits:O,anchorYUnits:U,color:J,crossOrigin:ce,offset:he,offsetOrigin:me,height:we,width:ve,size:Me,declutterMode:Re});return function(Le){return v&&Ce.setOpacity(v(Le)),w&&Ce.setDisplacement(w(Le)),T&&Ce.setRotation(T(Le)),I&&Ce.setRotateWithView(I(Le)),_&&Ce.setScale(_(Le)),o&&Ce.setAnchor(o(Le)),Ce}}function WI(h,e){let r="shape-",l=r+"points",c=r+"radius",o=by(h[l],l),_=by(h[c],c),v=ku(h,r,e),w=Lu(h,r,e),T=Np(h,r+"scale",e),I=Op(h,r+"displacement",e),L=Tn(h,r+"rotation",e),O=Du(h,r+"rotate-with-view",e),U=Bp(h,r+"radius2"),J=Bp(h,r+"angle"),ce=Vp(h,r+"declutter-mode"),he=new kp({points:o,radius:_,radius2:U,angle:J,declutterMode:ce});return function(me){return v&&he.setFill(v(me)),w&&he.setStroke(w(me)),I&&he.setDisplacement(I(me)),L&&he.setRotation(L(me)),O&&he.setRotateWithView(O(me)),T&&he.setScale(T(me)),he}}function ZI(h,e){let r="circle-",l=ku(h,r,e),c=Lu(h,r,e),o=Tn(h,r+"radius",e),_=Np(h,r+"scale",e),v=Op(h,r+"displacement",e),w=Tn(h,r+"rotation",e),T=Du(h,r+"rotate-with-view",e),I=Vp(h,r+"declutter-mode"),L=new En({radius:5,declutterMode:I});return function(O){return o&&L.setRadius(o(O)),l&&L.setFill(l(O)),c&&L.setStroke(c(O)),v&&L.setDisplacement(v(O)),w&&L.setRotation(w(O)),T&&L.setRotateWithView(T(O)),_&&L.setScale(_(O)),L}}function Tn(h,e,r){if(!(e in h))return;let l=qs(h[e],Ut,r);return function(c){return by(l(c),e)}}function So(h,e,r){if(!(e in h))return null;let l=qs(h[e],rn,r);return function(c){return Eb(l(c),e)}}function XI(h,e,r){let l=So(h,e+"pattern-src",r),c=bb(h,e+"pattern-offset",r),o=bb(h,e+"pattern-size",r),_=Sy(h,e+"color",r);return function(v){return{src:l(v),offset:c&&c(v),size:o&&o(v),color:_&&_(v)}}}function Du(h,e,r){if(!(e in h))return null;let l=qs(h[e],Gr,r);return function(c){let o=l(c);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${e}`);return o}}function Sy(h,e,r){if(!(e in h))return null;let l=qs(h[e],Xn,r);return function(c){return Tb(l(c),e)}}function Cb(h,e,r){if(!(e in h))return null;let l=qs(h[e],va,r);return function(c){return Fu(l(c),e)}}function Op(h,e,r){if(!(e in h))return null;let l=qs(h[e],va,r);return function(c){let o=Fu(l(c),e);if(o.length!==2)throw new Error(`Expected two numbers for ${e}`);return o}}function bb(h,e,r){if(!(e in h))return null;let l=qs(h[e],va,r);return function(c){return Mb(l(c),e)}}function Np(h,e,r){if(!(e in h))return null;let l=qs(h[e],va|Ut,r);return function(c){return QI(l(c),e)}}function Bp(h,e){let r=h[e];if(r!==void 0){if(typeof r!="number")throw new Error(`Expected a number for ${e}`);return r}}function HI(h,e){let r=h[e];if(r!==void 0){if(typeof r=="number")return js(r);if(!Array.isArray(r))throw new Error(`Expected a number or size array for ${e}`);if(r.length!==2||typeof r[0]!="number"||typeof r[1]!="number")throw new Error(`Expected a number or size array for ${e}`);return r}}function YI(h,e){let r=h[e];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${e}`);return r}}function wb(h,e){let r=h[e];if(r!==void 0){if(r!=="bottom-left"&&r!=="bottom-right"&&r!=="top-left"&&r!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return r}}function Sb(h,e){let r=h[e];if(r!==void 0){if(r!=="pixels"&&r!=="fraction")throw new Error(`Expected pixels or fraction for ${e}`);return r}}function KI(h,e){let r=h[e];if(r!==void 0)return Fu(r,e)}function Vp(h,e){let r=h[e];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${e}`);if(r!=="declutter"&&r!=="obstacle"&&r!=="none")throw new Error(`Expected declutter, obstacle, or none for ${e}`);return r}}function JI(h,e){let r=h[e];if(r!==void 0)return Tb(r,e)}function Fu(h,e){if(!Array.isArray(h))throw new Error(`Expected an array for ${e}`);let r=h.length;for(let l=0;l<r;++l)if(typeof h[l]!="number")throw new Error(`Expected an array of numbers for ${e}`);return h}function Eb(h,e){if(typeof h!="string")throw new Error(`Expected a string for ${e}`);return h}function by(h,e){if(typeof h!="number")throw new Error(`Expected a number for ${e}`);return h}function Tb(h,e){if(typeof h=="string")return h;let r=Fu(h,e),l=r.length;if(l<3||l>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return r}function Mb(h,e){let r=Fu(h,e);if(r.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return r}function QI(h,e){return typeof h=="number"?h:Mb(h,e)}var Ab={RENDER_ORDER:"renderOrder"},Iy=class extends ws{constructor(e){e=e||{};let r=Object.assign({},e);delete r.style,delete r.renderBuffer,delete r.updateWhileAnimating,delete r.updateWhileInteracting,super(r),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Ab.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,r){let l=this.getDeclutter();l in e.declutter||(e.declutter[l]=new ul(9)),this.getRenderer().renderDeclutter(e,r)}setRenderOrder(e){this.set(Ab.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?hy:e;let r=eC(e);this.styleFunction_=e===null?void 0:pb(r),this.changed()}};function eC(h){if(h===void 0)return hy;if(!h)return null;if(typeof h=="function"||h instanceof Er)return h;if(!Array.isArray(h))return wy([h]);if(h.length===0)return[];let e=h.length,r=h[0];if(r instanceof Er){let c=new Array(e);for(let o=0;o<e;++o){let _=h[o];if(!(_ instanceof Er))throw new Error("Expected a list of style instances");c[o]=_}return c}if("style"in r){let c=new Array(e);for(let o=0;o<e;++o){let _=h[o];if(!("style"in _))throw new Error("Expected a list of rules with a style property");c[o]=_}return Ib(c)}return wy(h)}var Pb=Iy;var zu={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Ou=[zu.FILL],$s=[zu.STROKE],Io=[zu.BEGIN_PATH],Cy=[zu.CLOSE_PATH],dt=zu;var Ey=class{drawCustom(e,r,l,c,o){}drawGeometry(e){}setStyle(e){}drawCircle(e,r,l){}drawFeature(e,r,l){}drawGeometryCollection(e,r,l){}drawLineString(e,r,l){}drawMultiLineString(e,r,l){}drawMultiPoint(e,r,l){}drawMultiPolygon(e,r,l){}drawPoint(e,r,l){}drawPolygon(e,r,l){}drawText(e,r,l){}setFillStrokeStyle(e,r){}setImageStyle(e,r){}setTextStyle(e,r){}},jp=Ey;var Ty=class extends jp{constructor(e,r,l,c){super(),this.tolerance=e,this.maxExtent=r,this.pixelRatio=c,this.maxLineWidth=0,this.resolution=l,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){let r=this.pixelRatio;return r==1?e:e.map(function(l){return l*r})}appendFlatPointCoordinates(e,r){let l=this.getBufferedMaxExtent(),c=this.tmpCoordinate_,o=this.coordinates,_=o.length;for(let v=0,w=e.length;v<w;v+=r)c[0]=e[v],c[1]=e[v+1],tl(l,c)&&(o[_++]=c[0],o[_++]=c[1]);return _}appendFlatLineCoordinates(e,r,l,c,o,_){let v=this.coordinates,w=v.length,T=this.getBufferedMaxExtent();_&&(r+=c);let I=e[r],L=e[r+1],O=this.tmpCoordinate_,U=!0,J,ce,he;for(J=r+c;J<l;J+=c)O[0]=e[J],O[1]=e[J+1],he=op(T,O),he!==ce?(U&&(v[w++]=I,v[w++]=L,U=!1),v[w++]=O[0],v[w++]=O[1]):he===Oi.INTERSECTING?(v[w++]=O[0],v[w++]=O[1],U=!1):U=!0,I=O[0],L=O[1],ce=he;return(o&&U||J===r+c)&&(v[w++]=I,v[w++]=L),w}drawCustomCoordinates_(e,r,l,c,o){for(let _=0,v=l.length;_<v;++_){let w=l[_],T=this.appendFlatLineCoordinates(e,r,w,c,!1,!1);o.push(T),r=w}return r}drawCustom(e,r,l,c,o){this.beginGeometry(e,r,o);let _=e.getType(),v=e.getStride(),w=this.coordinates.length,T,I,L,O,U;switch(_){case"MultiPolygon":T=e.getOrientedFlatCoordinates(),O=[];let J=e.getEndss();U=0;for(let ce=0,he=J.length;ce<he;++ce){let me=[];U=this.drawCustomCoordinates_(T,U,J[ce],v,me),O.push(me)}this.instructions.push([dt.CUSTOM,w,O,e,l,au,o]),this.hitDetectionInstructions.push([dt.CUSTOM,w,O,e,c||l,au,o]);break;case"Polygon":case"MultiLineString":L=[],T=_=="Polygon"?e.getOrientedFlatCoordinates():e.getFlatCoordinates(),U=this.drawCustomCoordinates_(T,0,e.getEnds(),v,L),this.instructions.push([dt.CUSTOM,w,L,e,l,pa,o]),this.hitDetectionInstructions.push([dt.CUSTOM,w,L,e,c||l,pa,o]);break;case"LineString":case"Circle":T=e.getFlatCoordinates(),I=this.appendFlatLineCoordinates(T,0,T.length,v,!1,!1),this.instructions.push([dt.CUSTOM,w,I,e,l,os,o]),this.hitDetectionInstructions.push([dt.CUSTOM,w,I,e,c||l,os,o]);break;case"MultiPoint":T=e.getFlatCoordinates(),I=this.appendFlatPointCoordinates(T,v),I>w&&(this.instructions.push([dt.CUSTOM,w,I,e,l,os,o]),this.hitDetectionInstructions.push([dt.CUSTOM,w,I,e,c||l,os,o]));break;case"Point":T=e.getFlatCoordinates(),this.coordinates.push(T[0],T[1]),I=this.coordinates.length,this.instructions.push([dt.CUSTOM,w,I,e,l,void 0,o]),this.hitDetectionInstructions.push([dt.CUSTOM,w,I,e,c||l,void 0,o]);break;default:}this.endGeometry(r)}beginGeometry(e,r,l){this.beginGeometryInstruction1_=[dt.BEGIN_GEOMETRY,r,0,e,l],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[dt.BEGIN_GEOMETRY,r,0,e,l],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let e=this.hitDetectionInstructions;e.reverse();let r,l=e.length,c,o,_=-1;for(r=0;r<l;++r)c=e[r],o=c[0],o==dt.END_GEOMETRY?_=r:o==dt.BEGIN_GEOMETRY&&(c[2]=r,Vx(this.hitDetectionInstructions,_,r),_=-1)}setFillStrokeStyle(e,r){let l=this.state;if(e){let c=e.getColor();l.fillPatternScale=c&&typeof c=="object"&&"src"in c?this.pixelRatio:1,l.fillStyle=Sn(c||Zi)}else l.fillStyle=void 0;if(r){let c=r.getColor();l.strokeStyle=Sn(c||vo);let o=r.getLineCap();l.lineCap=o!==void 0?o:Gs;let _=r.getLineDash();l.lineDash=_?_.slice():In;let v=r.getLineDashOffset();l.lineDashOffset=v||Cn;let w=r.getLineJoin();l.lineJoin=w!==void 0?w:Us;let T=r.getWidth();l.lineWidth=T!==void 0?T:wo;let I=r.getMiterLimit();l.miterLimit=I!==void 0?I:xo,l.lineWidth>this.maxLineWidth&&(this.maxLineWidth=l.lineWidth,this.bufferedMaxExtent_=null)}else l.strokeStyle=void 0,l.lineCap=void 0,l.lineDash=null,l.lineDashOffset=void 0,l.lineJoin=void 0,l.lineWidth=void 0,l.miterLimit=void 0}createFill(e){let r=e.fillStyle,l=[dt.SET_FILL_STYLE,r];return typeof r!="string"&&l.push(e.fillPatternScale),l}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[dt.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,this.applyPixelRatio(e.lineDash),e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,r){let l=e.fillStyle;(typeof l!="string"||e.currentFillStyle!=l)&&(l!==void 0&&this.instructions.push(r.call(this,e)),e.currentFillStyle=l)}updateStrokeStyle(e,r){let l=e.strokeStyle,c=e.lineCap,o=e.lineDash,_=e.lineDashOffset,v=e.lineJoin,w=e.lineWidth,T=e.miterLimit;(e.currentStrokeStyle!=l||e.currentLineCap!=c||o!=e.currentLineDash&&!yn(e.currentLineDash,o)||e.currentLineDashOffset!=_||e.currentLineJoin!=v||e.currentLineWidth!=w||e.currentMiterLimit!=T)&&(l!==void 0&&r.call(this,e),e.currentStrokeStyle=l,e.currentLineCap=c,e.currentLineDash=o,e.currentLineDashOffset=_,e.currentLineJoin=v,e.currentLineWidth=w,e.currentMiterLimit=T)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let r=[dt.END_GEOMETRY,e];this.instructions.push(r),this.hitDetectionInstructions.push(r)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=jx(this.maxExtent),this.maxLineWidth>0)){let e=this.resolution*(this.maxLineWidth+1)/2;ns(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},Ws=Ty;var My=class extends Ws{constructor(e,r,l,c){super(e,r,l,c),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,r,l){if(!this.image_||this.maxExtent&&!tl(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,r,l);let c=e.getFlatCoordinates(),o=e.getStride(),_=this.coordinates.length,v=this.appendFlatPointCoordinates(c,o);this.instructions.push([dt.DRAW_IMAGE,_,v,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([dt.DRAW_IMAGE,_,v,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(r)}drawMultiPoint(e,r,l){if(!this.image_)return;this.beginGeometry(e,r,l);let c=e.getFlatCoordinates(),o=[];for(let w=0,T=c.length;w<T;w+=e.getStride())(!this.maxExtent||tl(this.maxExtent,c.slice(w,w+2)))&&o.push(c[w],c[w+1]);let _=this.coordinates.length,v=this.appendFlatPointCoordinates(o,2);this.instructions.push([dt.DRAW_IMAGE,_,v,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([dt.DRAW_IMAGE,_,v,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(r)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(e,r){let l=e.getAnchor(),c=e.getSize(),o=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=l[0],this.anchorY_=l[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=c[1],this.opacity_=e.getOpacity(),this.originX_=o[0],this.originY_=o[1],this.rotateWithView_=e.getRotateWithView(),this.rotation_=e.getRotation(),this.scale_=e.getScaleArray(),this.width_=c[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=r}},Rb=My;var Ay=class extends Ws{constructor(e,r,l,c){super(e,r,l,c)}drawFlatCoordinates_(e,r,l,c){let o=this.coordinates.length,_=this.appendFlatLineCoordinates(e,r,l,c,!1,!1),v=[dt.MOVE_TO_LINE_TO,o,_];return this.instructions.push(v),this.hitDetectionInstructions.push(v),l}drawLineString(e,r,l){let c=this.state,o=c.strokeStyle,_=c.lineWidth;if(o===void 0||_===void 0)return;this.updateStrokeStyle(c,this.applyStroke),this.beginGeometry(e,r,l),this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn],Io);let v=e.getFlatCoordinates(),w=e.getStride();this.drawFlatCoordinates_(v,0,v.length,w),this.hitDetectionInstructions.push($s),this.endGeometry(r)}drawMultiLineString(e,r,l){let c=this.state,o=c.strokeStyle,_=c.lineWidth;if(o===void 0||_===void 0)return;this.updateStrokeStyle(c,this.applyStroke),this.beginGeometry(e,r,l),this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn],Io);let v=e.getEnds(),w=e.getFlatCoordinates(),T=e.getStride(),I=0;for(let L=0,O=v.length;L<O;++L)I=this.drawFlatCoordinates_(w,I,v[L],T);this.hitDetectionInstructions.push($s),this.endGeometry(r)}finish(){let e=this.state;return e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&this.instructions.push($s),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(e){e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&(this.instructions.push($s),e.lastStroke=this.coordinates.length),e.lastStroke=0,super.applyStroke(e),this.instructions.push(Io)}},kb=Ay;var Py=class extends Ws{constructor(e,r,l,c){super(e,r,l,c)}drawFlatCoordinatess_(e,r,l,c){let o=this.state,_=o.fillStyle!==void 0,v=o.strokeStyle!==void 0,w=l.length;this.instructions.push(Io),this.hitDetectionInstructions.push(Io);for(let T=0;T<w;++T){let I=l[T],L=this.coordinates.length,O=this.appendFlatLineCoordinates(e,r,I,c,!0,!v),U=[dt.MOVE_TO_LINE_TO,L,O];this.instructions.push(U),this.hitDetectionInstructions.push(U),v&&(this.instructions.push(Cy),this.hitDetectionInstructions.push(Cy)),r=I}return _&&(this.instructions.push(Ou),this.hitDetectionInstructions.push(Ou)),v&&(this.instructions.push($s),this.hitDetectionInstructions.push($s)),r}drawCircle(e,r,l){let c=this.state,o=c.fillStyle,_=c.strokeStyle;if(o===void 0&&_===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,r,l),c.fillStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_FILL_STYLE,Zi]),c.strokeStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn]);let v=e.getFlatCoordinates(),w=e.getStride(),T=this.coordinates.length;this.appendFlatLineCoordinates(v,0,v.length,w,!1,!1);let I=[dt.CIRCLE,T];this.instructions.push(Io,I),this.hitDetectionInstructions.push(Io,I),c.fillStyle!==void 0&&(this.instructions.push(Ou),this.hitDetectionInstructions.push(Ou)),c.strokeStyle!==void 0&&(this.instructions.push($s),this.hitDetectionInstructions.push($s)),this.endGeometry(r)}drawPolygon(e,r,l){let c=this.state,o=c.fillStyle,_=c.strokeStyle;if(o===void 0&&_===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,r,l),c.fillStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_FILL_STYLE,Zi]),c.strokeStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn]);let v=e.getEnds(),w=e.getOrientedFlatCoordinates(),T=e.getStride();this.drawFlatCoordinatess_(w,0,v,T),this.endGeometry(r)}drawMultiPolygon(e,r,l){let c=this.state,o=c.fillStyle,_=c.strokeStyle;if(o===void 0&&_===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,r,l),c.fillStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_FILL_STYLE,Zi]),c.strokeStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn]);let v=e.getEndss(),w=e.getOrientedFlatCoordinates(),T=e.getStride(),I=0;for(let L=0,O=v.length;L<O;++L)I=this.drawFlatCoordinatess_(w,I,v[L],T);this.endGeometry(r)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let e=this.tolerance;if(e!==0){let r=this.coordinates;for(let l=0,c=r.length;l<c;++l)r[l]=da(r[l],e)}return super.finish()}setFillStrokeStyles_(){let e=this.state;e.fillStyle!==void 0&&this.updateFillStyle(e,this.createFill),e.strokeStyle!==void 0&&this.updateStrokeStyle(e,this.applyStroke)}},Ry=Py;function Lb(h,e,r,l,c){let o=[],_=r,v=0,w=e.slice(r,2);for(;v<h&&_+c<l;){let[T,I]=w.slice(-2),L=e[_+c],O=e[_+c+1],U=Math.sqrt((L-T)*(L-T)+(O-I)*(O-I));if(v+=U,v>=h){let J=(h-v+U)/U,ce=Sr(T,L,J),he=Sr(I,O,J);w.push(ce,he),o.push(w),w=[ce,he],v==h&&(_+=c),v=0}else if(v<h)w.push(e[_+c],e[_+c+1]),_+=c;else{let J=U-v,ce=Sr(T,L,J/U),he=Sr(I,O,J/U);w.push(ce,he),o.push(w),w=[ce,he],v=0,_+=c}}return v>0&&o.push(w),o}function Db(h,e,r,l,c){let o=r,_=r,v=0,w=0,T=r,I,L,O,U,J,ce,he,me,ve,we;for(L=r;L<l;L+=c){let Me=e[L],Re=e[L+1];J!==void 0&&(ve=Me-J,we=Re-ce,U=Math.sqrt(ve*ve+we*we),he!==void 0&&(w+=O,I=Math.acos((he*ve+me*we)/(O*U)),I>h&&(w>v&&(v=w,o=T,_=L),w=0,T=L-c)),O=U,he=ve,me=we),J=Me,ce=Re}return w+=U,w>v?[T,L]:[o,_]}var Bu={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},ky=class extends Ws{constructor(e,r,l,c){super(e,r,l,c),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Zi]={fillStyle:Zi},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){let e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,r,l){let c=this.textFillState_,o=this.textStrokeState_,_=this.textState_;if(this.text_===""||!_||!c&&!o)return;let v=this.coordinates,w=v.length,T=e.getType(),I=null,L=e.getStride();if(_.placement==="line"&&(T=="LineString"||T=="MultiLineString"||T=="Polygon"||T=="MultiPolygon")){if(!Bi(this.maxExtent,e.getExtent()))return;let O;if(I=e.getFlatCoordinates(),T=="LineString")O=[I.length];else if(T=="MultiLineString")O=e.getEnds();else if(T=="Polygon")O=e.getEnds().slice(0,1);else if(T=="MultiPolygon"){let he=e.getEndss();O=[];for(let me=0,ve=he.length;me<ve;++me)O.push(he[me][0])}this.beginGeometry(e,r,l);let U=_.repeat,J=U?void 0:_.textAlign,ce=0;for(let he=0,me=O.length;he<me;++he){let ve;U?ve=Lb(U*this.resolution,I,ce,O[he],L):ve=[I.slice(ce,O[he])];for(let we=0,Me=ve.length;we<Me;++we){let Re=ve[we],Ce=0,Le=Re.length;if(J==null){let Ae=Db(_.maxAngle,Re,0,Re.length,2);Ce=Ae[0],Le=Ae[1]}for(let Ae=Ce;Ae<Le;Ae+=L)v.push(Re[Ae],Re[Ae+1]);let Ue=v.length;ce=O[he],this.drawChars_(w,Ue),w=Ue}}this.endGeometry(r)}else{let O=_.overflow?null:[];switch(T){case"Point":case"MultiPoint":I=e.getFlatCoordinates();break;case"LineString":I=e.getFlatMidpoint();break;case"Circle":I=e.getCenter();break;case"MultiLineString":I=e.getFlatMidpoints(),L=2;break;case"Polygon":I=e.getFlatInteriorPoint(),_.overflow||O.push(I[2]/this.resolution),L=3;break;case"MultiPolygon":let ve=e.getFlatInteriorPoints();I=[];for(let we=0,Me=ve.length;we<Me;we+=3)_.overflow||O.push(ve[we+2]/this.resolution),I.push(ve[we],ve[we+1]);if(I.length===0)return;L=2;break;default:}let U=this.appendFlatPointCoordinates(I,L);if(U===w)return;if(O&&(U-w)/2!==I.length/L){let ve=w/2;O=O.filter((we,Me)=>{let Re=v[(ve+Me)*2]===I[Me*L]&&v[(ve+Me)*2+1]===I[Me*L+1];return Re||--ve,Re})}this.saveTextStates_(),(_.backgroundFill||_.backgroundStroke)&&(this.setFillStrokeStyle(_.backgroundFill,_.backgroundStroke),_.backgroundFill&&this.updateFillStyle(this.state,this.createFill),_.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(e,r,l);let J=_.padding;if(J!=bo&&(_.scale[0]<0||_.scale[1]<0)){let ve=_.padding[0],we=_.padding[1],Me=_.padding[2],Re=_.padding[3];_.scale[0]<0&&(we=-we,Re=-Re),_.scale[1]<0&&(ve=-ve,Me=-Me),J=[ve,we,Me,Re]}let ce=this.pixelRatio;this.instructions.push([dt.DRAW_IMAGE,w,U,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,J==bo?bo:J.map(function(ve){return ve*ce}),!!_.backgroundFill,!!_.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,O]);let he=1/ce,me=this.state.fillStyle;_.backgroundFill&&(this.state.fillStyle=Zi,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([dt.DRAW_IMAGE,w,U,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[he,he],NaN,this.declutterMode_,this.declutterImageWithText_,J,!!_.backgroundFill,!!_.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Zi:this.fillKey_,this.textOffsetX_,this.textOffsetY_,O]),_.backgroundFill&&(this.state.fillStyle=me,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(r)}}saveTextStates_(){let e=this.textStrokeState_,r=this.textState_,l=this.textFillState_,c=this.strokeKey_;e&&(c in this.strokeStates||(this.strokeStates[c]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));let o=this.textKey_;o in this.textStates||(this.textStates[o]={font:r.font,textAlign:r.textAlign||ya,justify:r.justify,textBaseline:r.textBaseline||hl,scale:r.scale});let _=this.fillKey_;l&&(_ in this.fillStates||(this.fillStates[_]={fillStyle:l.fillStyle}))}drawChars_(e,r){let l=this.textStrokeState_,c=this.textState_,o=this.strokeKey_,_=this.textKey_,v=this.fillKey_;this.saveTextStates_();let w=this.pixelRatio,T=Bu[c.textBaseline],I=this.textOffsetY_*w,L=this.text_,O=l?l.lineWidth*Math.abs(c.scale[0])/2:0;this.instructions.push([dt.DRAW_CHARS,e,r,T,c.overflow,v,c.maxAngle,w,I,o,O*w,L,_,1,this.declutterMode_]),this.hitDetectionInstructions.push([dt.DRAW_CHARS,e,r,T,c.overflow,v&&Zi,c.maxAngle,w,I,o,O*w,L,_,1/w,this.declutterMode_])}setTextStyle(e,r){let l,c,o;if(!e)this.text_="";else{let _=e.getFill();_?(c=this.textFillState_,c||(c={},this.textFillState_=c),c.fillStyle=Sn(_.getColor()||Zi)):(c=null,this.textFillState_=c);let v=e.getStroke();if(!v)o=null,this.textStrokeState_=o;else{o=this.textStrokeState_,o||(o={},this.textStrokeState_=o);let J=v.getLineDash(),ce=v.getLineDashOffset(),he=v.getWidth(),me=v.getMiterLimit();o.lineCap=v.getLineCap()||Gs,o.lineDash=J?J.slice():In,o.lineDashOffset=ce===void 0?Cn:ce,o.lineJoin=v.getLineJoin()||Us,o.lineWidth=he===void 0?wo:he,o.miterLimit=me===void 0?xo:me,o.strokeStyle=Sn(v.getColor()||vo)}l=this.textState_;let w=e.getFont()||Rp;lb(w);let T=e.getScaleArray();l.overflow=e.getOverflow(),l.font=w,l.maxAngle=e.getMaxAngle(),l.placement=e.getPlacement(),l.textAlign=e.getTextAlign(),l.repeat=e.getRepeat(),l.justify=e.getJustify(),l.textBaseline=e.getTextBaseline()||hl,l.backgroundFill=e.getBackgroundFill(),l.backgroundStroke=e.getBackgroundStroke(),l.padding=e.getPadding()||bo,l.scale=T===void 0?[1,1]:T;let I=e.getOffsetX(),L=e.getOffsetY(),O=e.getRotateWithView(),U=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=I===void 0?0:I,this.textOffsetY_=L===void 0?0:L,this.textRotateWithView_=O===void 0?!1:O,this.textRotation_=U===void 0?0:U,this.strokeKey_=o?(typeof o.strokeStyle=="string"?o.strokeStyle:Vt(o.strokeStyle))+o.lineCap+o.lineDashOffset+"|"+o.lineWidth+o.lineJoin+o.miterLimit+"["+o.lineDash.join()+"]":"",this.textKey_=l.font+l.scale+(l.textAlign||"?")+(l.repeat||"?")+(l.justify||"?")+(l.textBaseline||"?"),this.fillKey_=c&&c.fillStyle?typeof c.fillStyle=="string"?c.fillStyle:"|"+Vt(c.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=r}},Fb=ky;var tC={Circle:Ry,Default:Ws,Image:Rb,LineString:kb,Polygon:Ry,Text:Fb},Ly=class{constructor(e,r,l,c){this.tolerance_=e,this.maxExtent_=r,this.pixelRatio_=c,this.resolution_=l,this.buildersByZIndex_={}}finish(){let e={};for(let r in this.buildersByZIndex_){e[r]=e[r]||{};let l=this.buildersByZIndex_[r];for(let c in l){let o=l[c].finish();e[r][c]=o}}return e}getBuilder(e,r){let l=e!==void 0?e.toString():"0",c=this.buildersByZIndex_[l];c===void 0&&(c={},this.buildersByZIndex_[l]=c);let o=c[r];if(o===void 0){let _=tC[r];o=new _(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),c[r]=o}return o}},zb=Ly;var iC=5,Dy=class extends np{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.staleKeys_=new Array,this.maxStaleKeys=iC}getStaleKeys(){return this.staleKeys_}prependStaleKey(e){this.staleKeys_.unshift(e),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return xt()}getData(e){return null}prepareFrame(e){return xt()}renderFrame(e,r){return xt()}forEachFeatureAtCoordinate(e,r,l,c,o){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){let r=e.target;(r.getState()===St.LOADED||r.getState()===St.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let r=e.getState();return r!=St.LOADED&&r!=St.ERROR&&e.addEventListener(ui.CHANGE,this.boundHandleImageChange_),r==St.IDLE&&(e.load(),r=e.getState()),r==St.LOADED}renderIfReadyAndVisible(){let e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}},ba=Dy;var Fy=class extends Si{constructor(e,r,l,c){super(e),this.inversePixelTransform=r,this.frameState=l,this.context=c}},Ob=Fy;var zy=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Tc(),{get:(e,r)=>{if(typeof Tc()[r]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(r),this.pushMethodArgs_},set:(e,r,l)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(r,l),!0)})}pushMethodArgs_=(...e)=>(this.instructions_[this.zIndex+this.offset_].push(e),this);pushFunction(e){this.instructions_[this.zIndex+this.offset_].push(e)}getContext(){return this.context_}draw(e){this.instructions_.forEach(r=>{for(let l=0,c=r.length;l<c;++l){let o=r[l];if(typeof o=="function"){o(e);continue}let _=r[++l];if(typeof e[o]=="function")e[o](..._);else{if(typeof _=="function"){e[o]=_(e);continue}e[o]=_}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},Gp=zy;var By=[],Lc=null;function rC(){Lc=Ai(1,1,void 0,{willReadFrequently:!0})}var Oy=class extends ba{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=nr(),this.pixelTransform=nr(),this.inversePixelTransform=nr(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,r,l){Lc||rC(),Lc.clearRect(0,0,1,1);let c;try{Lc.drawImage(e,r,l,1,1,0,0,1,1),c=Lc.getImageData(0,0,1,1).data}catch{return Lc=null,null}return c}getBackground(e){let l=this.getLayer().getBackground();return typeof l=="function"&&(l=l(e.viewState.resolution)),l||void 0}useContainer(e,r,l){let c=this.getLayer().getClassName(),o,_;if(e&&e.className===c&&(!l||e&&e.style.backgroundColor&&yn(_o(e.style.backgroundColor),_o(l)))){let v=e.firstElementChild;v instanceof HTMLCanvasElement&&(_=v.getContext("2d"))}if(_&&_.canvas.style.transform===r?(this.container=e,this.context=_,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){o=document.createElement("div"),o.className=c;let v=o.style;v.position="absolute",v.width="100%",v.height="100%",_=Ai();let w=_.canvas;o.appendChild(w),v=w.style,v.position="absolute",v.left="0",v.transformOrigin="top left",this.container=o,this.context=_}!this.containerReused&&l&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=l)}clipUnrotated(e,r,l){let c=Hm(l),o=Ym(l),_=Xm(l),v=Zm(l);vr(r.coordinateToPixelTransform,c),vr(r.coordinateToPixelTransform,o),vr(r.coordinateToPixelTransform,_),vr(r.coordinateToPixelTransform,v);let w=this.inversePixelTransform;vr(w,c),vr(w,o),vr(w,_),vr(w,v),e.save(),e.beginPath(),e.moveTo(Math.round(c[0]),Math.round(c[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(_[0]),Math.round(_[1])),e.lineTo(Math.round(v[0]),Math.round(v[1])),e.clip()}prepareContainer(e,r){let l=e.extent,c=e.viewState.resolution,o=e.viewState.rotation,_=e.pixelRatio,v=Math.round(_i(l)/c*_),w=Math.round($i(l)/c*_);Vr(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/_,1/_,o,-v/2,-w/2),Ox(this.inversePixelTransform,this.pixelTransform);let T=Nm(this.pixelTransform);if(this.useContainer(r,T,this.getBackground(e)),!this.containerReused){let I=this.context.canvas;I.width!=v||I.height!=w?(I.width=v,I.height=w):this.context.clearRect(0,0,v,w),T!==I.style.transform&&(I.style.transform=T)}}dispatchRenderEvent_(e,r,l){let c=this.getLayer();if(c.hasListener(e)){let o=new Ob(e,this.inversePixelTransform,l,r);c.dispatchEvent(o)}}preRender(e,r){this.frameState=r,!r.declutter&&this.dispatchRenderEvent_(Ns.PRERENDER,e,r)}postRender(e,r){r.declutter||this.dispatchRenderEvent_(Ns.POSTRENDER,e,r)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new Gp),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(Ns.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(Ns.POSTRENDER,this.context,e))}getRenderTransform(e,r,l,c,o,_,v){let w=o/2,T=_/2,I=c/r,L=-I,O=-e[0]+v,U=-e[1];return Vr(this.tempTransform,w,T,I,L,-l,O,U)}disposeInternal(){delete this.frameState,super.disposeInternal()}},Up=Oy;function Bb(h,e,r,l,c,o,_,v,w,T,I,L){let O=h[e],U=h[e+1],J=0,ce=0,he=0,me=0;function ve(){J=O,ce=U,e+=l,O=h[e],U=h[e+1],me+=he,he=Math.sqrt((O-J)*(O-J)+(U-ce)*(U-ce))}do ve();while(e<r-l&&me+he<o);let we=he===0?0:(o-me)/he,Me=Sr(J,O,we),Re=Sr(ce,U,we),Ce=e-l,Le=me,Ue=o+v*w(T,c,I);for(;e<r-l&&me+he<Ue;)ve();we=he===0?0:(Ue-me)/he;let Ae=Sr(J,O,we),Lt=Sr(ce,U,we),lt;if(L){let ot=[Me,Re,Ae,Lt];dp(ot,0,4,2,L,ot,ot),lt=ot[0]>ot[2]}else lt=Me>Ae;let it=Math.PI,wt=[],zt=Ce+l===e;e=Ce,he=0,me=Le,O=h[e],U=h[e+1];let nt;if(zt){ve(),nt=Math.atan2(U-ce,O-J),lt&&(nt+=nt>0?-it:it);let ot=(Ae+Me)/2,ut=(Lt+Re)/2;return wt[0]=[ot,ut,(Ue-o)/2,nt,c],wt}c=c.replace(/\n/g," ");for(let ot=0,ut=c.length;ot<ut;){ve();let yt=Math.atan2(U-ce,O-J);if(lt&&(yt+=yt>0?-it:it),nt!==void 0){let je=yt-nt;if(je+=je>it?-2*it:je<-it?2*it:0,Math.abs(je)>_)return null}nt=yt;let At=ot,Tt=0;for(;ot<ut;++ot){let je=lt?ut-ot-1:ot,xi=v*w(T,c[je],I);if(e+l<r&&me+he<o+Tt+xi/2)break;Tt+=xi}if(ot===At)continue;let Bt=lt?c.substring(ut-At,ut-ot):c.substring(At,ot);we=he===0?0:(o+Tt/2-me)/he;let $t=Sr(J,O,we),di=Sr(ce,U,we);wt.push([$t,di,Tt/2,yt,Bt]),o+=Tt}return wt}var Dc=xn(),wa=[],Co=[],Eo=[],Sa=[];function Nb(h){return h[3].declutterBox}var Vb=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function Ny(h,e){return e==="start"?e=Vb.test(h)?"right":"left":e==="end"&&(e=Vb.test(h)?"left":"right"),Bu[e]}function nC(h,e,r){return r>0&&h.push(`
|
|
583
583
|
`,""),h.push(e,""),h}var Vy=class{constructor(e,r,l,c,o){this.overlaps=l,this.pixelRatio=r,this.resolution=e,this.alignAndScaleFill_,this.instructions=c.instructions,this.coordinates=c.coordinates,this.coordinateCache_={},this.renderedTransform_=nr(),this.hitDetectionInstructions=c.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=c.fillStates||{},this.strokeStates=c.strokeStates||{},this.textStates=c.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=o?new Gp:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,r,l,c){let o=e+r+l+c;if(this.labels_[o])return this.labels_[o];let _=c?this.strokeStates[c]:null,v=l?this.fillStates[l]:null,w=this.textStates[r],T=this.pixelRatio,I=[w.scale[0]*T,w.scale[1]*T],L=w.justify?Bu[w.justify]:Ny(Array.isArray(e)?e[0]:e,w.textAlign||ya),O=c&&_.lineWidth?_.lineWidth:0,U=Array.isArray(e)?e:String(e).split(`
|
|
584
584
|
`).reduce(nC,[]),{width:J,height:ce,widths:he,heights:me,lineWidths:ve}=hb(w,U),we=J+O,Me=[],Re=(we+2)*I[0],Ce=(ce+O)*I[1],Le={width:Re<0?Math.floor(Re):Math.ceil(Re),height:Ce<0?Math.floor(Ce):Math.ceil(Ce),contextInstructions:Me};(I[0]!=1||I[1]!=1)&&Me.push("scale",I),c&&(Me.push("strokeStyle",_.strokeStyle),Me.push("lineWidth",O),Me.push("lineCap",_.lineCap),Me.push("lineJoin",_.lineJoin),Me.push("miterLimit",_.miterLimit),Me.push("setLineDash",[_.lineDash]),Me.push("lineDashOffset",_.lineDashOffset)),l&&Me.push("fillStyle",v.fillStyle),Me.push("textBaseline","middle"),Me.push("textAlign","center");let Ue=.5-L,Ae=L*we+Ue*O,Lt=[],lt=[],it=0,wt=0,zt=0,nt=0,ot;for(let ut=0,yt=U.length;ut<yt;ut+=2){let At=U[ut];if(At===`
|
|
585
|
-
`){wt+=it,it=0,Ae=L*we+Ue*O,++nt;continue}let Tt=U[ut+1]||w.font;Tt!==ot&&(c&&Lt.push("font",Tt),l&<.push("font",Tt),ot=Tt),it=Math.max(it,me[zt]);let Bt=[At,Ae+Ue*he[zt]+L*(he[zt]-ve[nt]),.5*(O+it)+wt];Ae+=he[zt],c&&Lt.push("strokeText",Bt),l&<.push("fillText",Bt),++zt}return Array.prototype.push.apply(Me,Lt),Array.prototype.push.apply(Me,lt),this.labels_[o]=Le,Le}replayTextBackground_(e,r,l,c,o,_,v){e.beginPath(),e.moveTo.apply(e,r),e.lineTo.apply(e,l),e.lineTo.apply(e,c),e.lineTo.apply(e,o),e.lineTo.apply(e,r),_&&(this.alignAndScaleFill_=_[2],this.fill_(e)),v&&(this.setStrokeStyle_(e,v),e.stroke())}calculateImageOrLabelDimensions_(e,r,l,c,o,_,v,w,T,I,L,O,U,J,ce,he){v*=O[0],w*=O[1];let me=l-v,ve=c-w,we=o+T>e?e-T:o,Me=_+I>r?r-I:_,Re=J[3]+we*O[0]+J[1],Ce=J[0]+Me*O[1]+J[2],Le=me-J[3],Ue=ve-J[0];(ce||L!==0)&&(wa[0]=Le,Sa[0]=Le,wa[1]=Ue,Co[1]=Ue,Co[0]=Le+Re,Eo[0]=Co[0],Eo[1]=Ue+Ce,Sa[1]=Eo[1]);let Ae;return L!==0?(Ae=Vr(nr(),l,c,1,1,L,-l,-c),vr(Ae,wa),vr(Ae,Co),vr(Ae,Eo),vr(Ae,Sa),mo(Math.min(wa[0],Co[0],Eo[0],Sa[0]),Math.min(wa[1],Co[1],Eo[1],Sa[1]),Math.max(wa[0],Co[0],Eo[0],Sa[0]),Math.max(wa[1],Co[1],Eo[1],Sa[1]),Dc)):mo(Math.min(Le,Le+Re),Math.min(Ue,Ue+Ce),Math.max(Le,Le+Re),Math.max(Ue,Ue+Ce),Dc),U&&(me=Math.round(me),ve=Math.round(ve)),{drawImageX:me,drawImageY:ve,drawImageW:we,drawImageH:Me,originX:T,originY:I,declutterBox:{minX:Dc[0],minY:Dc[1],maxX:Dc[2],maxY:Dc[3],value:he},canvasTransform:Ae,scale:O}}replayImageOrLabel_(e,r,l,c,o,_,v){let w=!!(_||v),T=c.declutterBox,I=v?v[2]*c.scale[0]/2:0;return T.minX-I<=r[0]&&T.maxX+I>=0&&T.minY-I<=r[1]&&T.maxY+I>=0&&(w&&this.replayTextBackground_(e,wa,Co,Eo,Sa,_,v),ub(e,c.canvasTransform,o,l,c.originX,c.originY,c.drawImageW,c.drawImageH,c.drawImageX,c.drawImageY,c.scale)),!0}fill_(e){let r=this.alignAndScaleFill_;if(r){let l=vr(this.renderedTransform_,[0,0]),c=512*this.pixelRatio;e.save(),e.translate(l[0]%c,l[1]%c),r!==1&&e.scale(r,r),e.rotate(this.viewRotation_)}e.fill(),r&&e.restore()}setStrokeStyle_(e,r){e.strokeStyle=r[1],e.lineWidth=r[2],e.lineCap=r[3],e.lineJoin=r[4],e.miterLimit=r[5],e.lineDashOffset=r[7],e.setLineDash(r[6])}drawLabelWithPointPlacement_(e,r,l,c){let o=this.textStates[r],_=this.createLabel(e,r,c,l),v=this.strokeStates[l],w=this.pixelRatio,T=Ny(Array.isArray(e)?e[0]:e,o.textAlign||ya),I=Bu[o.textBaseline||hl],L=v&&v.lineWidth?v.lineWidth:0,O=_.width/w-2*o.scale[0],U=T*O+2*(.5-T)*L,J=I*_.height/w+2*(.5-I)*L;return{label:_,anchorX:U,anchorY:J}}execute_(e,r,l,c,o,_,v,w){let T=this.zIndexContext_,I;this.pixelCoordinates_&&yn(l,this.renderedTransform_)?I=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),I=vn(this.coordinates,0,this.coordinates.length,2,l,this.pixelCoordinates_),Fx(this.renderedTransform_,l));let L=0,O=c.length,U=0,J,ce,he,me,ve,we,Me,Re,Ce,Le,Ue,Ae,Lt,lt=0,it=0,wt=null,zt=null,nt=this.coordinateCache_,ot=this.viewRotation_,ut=Math.round(Math.atan2(-l[1],l[0])*1e12)/1e12,yt={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:ot},At=this.instructions!=c||this.overlaps?0:200,Tt,Bt,$t,di;for(;L<O;){let je=c[L];switch(je[0]){case dt.BEGIN_GEOMETRY:Tt=je[1],di=je[3],Tt.getGeometry()?v!==void 0&&!Bi(v,di.getExtent())?L=je[2]+1:++L:L=je[2],T&&(T.zIndex=je[4]);break;case dt.BEGIN_PATH:lt>At&&(this.fill_(e),lt=0),it>At&&(e.stroke(),it=0),!lt&&!it&&(e.beginPath(),ve=NaN,we=NaN),++L;break;case dt.CIRCLE:U=je[1];let vi=I[U],hr=I[U+1],ur=I[U+2],nn=I[U+3],Vi=ur-vi,sn=nn-hr,on=Math.sqrt(Vi*Vi+sn*sn);e.moveTo(vi+on,hr),e.arc(vi,hr,on,0,2*Math.PI,!0),++L;break;case dt.CLOSE_PATH:e.closePath(),++L;break;case dt.CUSTOM:U=je[1],J=je[2];let An=je[3],xe=je[4],Pn=je[5];yt.geometry=An,yt.feature=Tt,L in nt||(nt[L]=[]);let dr=nt[L];Pn?Pn(I,U,J,2,dr):(dr[0]=I[U],dr[1]=I[U+1],dr.length=2),T&&(T.zIndex=je[6]),xe(dr,yt),++L;break;case dt.DRAW_IMAGE:U=je[1],J=je[2],Ce=je[3],ce=je[4],he=je[5];let _t=je[6],Zt=je[7],Rn=je[8],an=je[9],Ar=je[10],ln=je[11],pr=je[12],Yn=je[13];me=je[14]||"declutter";let kn=je[15];if(!Ce&&je.length>=20){Le=je[19],Ue=je[20],Ae=je[21],Lt=je[22];let ne=this.drawLabelWithPointPlacement_(Le,Ue,Ae,Lt);Ce=ne.label,je[3]=Ce;let ae=je[23];ce=(ne.anchorX-ae)*this.pixelRatio,je[4]=ce;let ue=je[24];he=(ne.anchorY-ue)*this.pixelRatio,je[5]=he,_t=Ce.height,je[6]=_t,Yn=Ce.width,je[13]=Yn}let Fe;je.length>25&&(Fe=je[25]);let Pr,Ci,fr;je.length>17?(Pr=je[16],Ci=je[17],fr=je[18]):(Pr=bo,Ci=!1,fr=!1),Ar&&ut?ln+=ot:!Ar&&!ut&&(ln-=ot);let Kn=0;for(;U<J;U+=2){if(Fe&&Fe[Kn++]<Yn/this.pixelRatio)continue;let ne=this.calculateImageOrLabelDimensions_(Ce.width,Ce.height,I[U],I[U+1],Yn,_t,ce,he,Rn,an,ln,pr,o,Pr,Ci||fr,Tt),ae=[e,r,Ce,ne,Zt,Ci?wt:null,fr?zt:null];if(w){let ue,ie,_e;if(kn){let Pe=J-U;if(!kn[Pe]){kn[Pe]={args:ae,declutterMode:me};continue}let We=kn[Pe];ue=We.args,ie=We.declutterMode,delete kn[Pe],_e=Nb(ue)}let Ie,ye;if(ue&&(ie!=="declutter"||!w.collides(_e))&&(Ie=!0),(me!=="declutter"||!w.collides(ne.declutterBox))&&(ye=!0),ie==="declutter"&&me==="declutter"){let Pe=Ie&&ye;Ie=Pe,ye=Pe}Ie&&(ie!=="none"&&w.insert(_e),this.replayImageOrLabel_.apply(this,ue)),ye&&(me!=="none"&&w.insert(ne.declutterBox),this.replayImageOrLabel_.apply(this,ae))}else this.replayImageOrLabel_.apply(this,ae)}++L;break;case dt.DRAW_CHARS:let ze=je[1],bt=je[2],ct=je[3],Hi=je[4];Lt=je[5];let qr=je[6],mt=je[7],$r=je[8];Ae=je[9];let Wr=je[10];Le=je[11],Ue=je[12];let Ln=[je[13],je[13]];me=je[14]||"declutter";let Rr=this.textStates[Ue],Q=Rr.font,N=[Rr.scale[0]*mt,Rr.scale[1]*mt],B;Q in this.widths_?B=this.widths_[Q]:(B={},this.widths_[Q]=B);let q=_p(I,ze,bt,2),X=Math.abs(N[0])*oy(Q,Le,B);if(Hi||X<=q){let ne=this.textStates[Ue].textAlign,ae=(q-X)*Ny(Le,ne),ue=Bb(I,ze,bt,2,Le,ae,qr,Math.abs(N[0]),oy,Q,B,ut?0:this.viewRotation_);e:if(ue){let ie=[],_e,Ie,ye,Pe,We;if(Ae)for(_e=0,Ie=ue.length;_e<Ie;++_e){We=ue[_e],ye=We[4],Pe=this.createLabel(ye,Ue,"",Ae),ce=We[2]+(N[0]<0?-Wr:Wr),he=ct*Pe.height+(.5-ct)*2*Wr*N[1]/N[0]-$r;let Je=this.calculateImageOrLabelDimensions_(Pe.width,Pe.height,We[0],We[1],Pe.width,Pe.height,ce,he,0,0,We[3],Ln,!1,bo,!1,Tt);if(w&&me==="declutter"&&w.collides(Je.declutterBox))break e;ie.push([e,r,Pe,Je,1,null,null])}if(Lt)for(_e=0,Ie=ue.length;_e<Ie;++_e){We=ue[_e],ye=We[4],Pe=this.createLabel(ye,Ue,Lt,""),ce=We[2],he=ct*Pe.height-$r;let Je=this.calculateImageOrLabelDimensions_(Pe.width,Pe.height,We[0],We[1],Pe.width,Pe.height,ce,he,0,0,We[3],Ln,!1,bo,!1,Tt);if(w&&me==="declutter"&&w.collides(Je.declutterBox))break e;ie.push([e,r,Pe,Je,1,null,null])}w&&me!=="none"&&w.load(ie.map(Nb));for(let Je=0,Ot=ie.length;Je<Ot;++Je)this.replayImageOrLabel_.apply(this,ie[Je])}}++L;break;case dt.END_GEOMETRY:if(_!==void 0){Tt=je[1];let ne=_(Tt,di,me);if(ne)return ne}++L;break;case dt.FILL:At?lt++:this.fill_(e),++L;break;case dt.MOVE_TO_LINE_TO:for(U=je[1],J=je[2],Bt=I[U],$t=I[U+1],e.moveTo(Bt,$t),ve=Bt+.5|0,we=$t+.5|0,U+=2;U<J;U+=2)Bt=I[U],$t=I[U+1],Me=Bt+.5|0,Re=$t+.5|0,(U==J-2||Me!==ve||Re!==we)&&(e.lineTo(Bt,$t),ve=Me,we=Re);++L;break;case dt.SET_FILL_STYLE:wt=je,this.alignAndScaleFill_=je[2],lt&&(this.fill_(e),lt=0,it&&(e.stroke(),it=0)),e.fillStyle=je[1],++L;break;case dt.SET_STROKE_STYLE:zt=je,it&&(e.stroke(),it=0),this.setStrokeStyle_(e,je),++L;break;case dt.STROKE:At?it++:e.stroke(),++L;break;default:++L;break}}lt&&this.fill_(e),it&&e.stroke()}execute(e,r,l,c,o,_){this.viewRotation_=c,this.execute_(e,r,l,this.instructions,o,void 0,void 0,_)}executeHitDetection(e,r,l,c,o){return this.viewRotation_=l,this.execute_(e,[e.canvas.width,e.canvas.height],r,this.hitDetectionInstructions,!0,c,o)}},jb=Vy;var pl=["Polygon","Circle","LineString","Image","Text","Default"],Uy=["Image","Text"],Gb=pl.filter(h=>!Uy.includes(h)),Gy=class{constructor(e,r,l,c,o,_,v){this.maxExtent_=e,this.overlaps_=c,this.pixelRatio_=l,this.resolution_=r,this.renderBuffer_=_,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=nr(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(o,v)}clip(e,r){let l=this.getClipCoords(r);e.beginPath(),e.moveTo(l[0],l[1]),e.lineTo(l[2],l[3]),e.lineTo(l[4],l[5]),e.lineTo(l[6],l[7]),e.clip()}createExecutors_(e,r){for(let l in e){let c=this.executorsByZIndex_[l];c===void 0&&(c={},this.executorsByZIndex_[l]=c);let o=e[l];for(let _ in o){let v=o[_];c[_]=new jb(this.resolution_,this.pixelRatio_,this.overlaps_,v,r)}}}hasExecutors(e){for(let r in this.executorsByZIndex_){let l=this.executorsByZIndex_[r];for(let c=0,o=e.length;c<o;++c)if(e[c]in l)return!0}return!1}forEachFeatureAtCoordinate(e,r,l,c,o,_){c=Math.round(c);let v=c*2+1,w=Vr(this.hitDetectionTransform_,c+.5,c+.5,1/r,-1/r,-l,-e[0],-e[1]),T=!this.hitDetectionContext_;T&&(this.hitDetectionContext_=Ai(v,v,void 0,{willReadFrequently:!0}));let I=this.hitDetectionContext_;I.canvas.width!==v||I.canvas.height!==v?(I.canvas.width=v,I.canvas.height=v):T||I.clearRect(0,0,v,v);let L;this.renderBuffer_!==void 0&&(L=xn(),$m(L,e),ns(L,r*(this.renderBuffer_+c),L));let O=sC(c),U;function J(Re,Ce,Le){let Ue=I.getImageData(0,0,v,v).data;for(let Ae=0,Lt=O.length;Ae<Lt;Ae++)if(Ue[O[Ae]]>0){if(!_||Le==="none"||U!=="Image"&&U!=="Text"||_.includes(Re)){let lt=(O[Ae]-3)/4,it=c-lt%v,wt=c-(lt/v|0),zt=o(Re,Ce,it*it+wt*wt);if(zt)return zt}I.clearRect(0,0,v,v);break}}let ce=Object.keys(this.executorsByZIndex_).map(Number);ce.sort(gs);let he,me,ve,we,Me;for(he=ce.length-1;he>=0;--he){let Re=ce[he].toString();for(ve=this.executorsByZIndex_[Re],me=pl.length-1;me>=0;--me)if(U=pl[me],we=ve[U],we!==void 0&&(Me=we.executeHitDetection(I,w,l,J,L),Me))return Me}}getClipCoords(e){let r=this.maxExtent_;if(!r)return null;let l=r[0],c=r[1],o=r[2],_=r[3],v=[l,c,l,_,o,_,o,c];return vn(v,0,8,2,e,v),v}isEmpty(){return Wn(this.executorsByZIndex_)}execute(e,r,l,c,o,_,v){let w=Object.keys(this.executorsByZIndex_).map(Number);w.sort(gs),_=_||pl;let T=pl.length,I,L,O,U,J;for(v&&w.reverse(),I=0,L=w.length;I<L;++I){let ce=w[I].toString();for(J=this.executorsByZIndex_[ce],O=0,U=_.length;O<U;++O){let he=_[O],me=J[he];if(me!==void 0){let ve=v===null?void 0:me.getZIndexContext(),we=ve?ve.getContext():e,Me=this.maxExtent_&&he!=="Image"&&he!=="Text";if(Me&&(we.save(),this.clip(we,l)),!ve||he==="Text"||he==="Image"?me.execute(we,r,l,c,o,v):ve.pushFunction(Re=>me.execute(Re,r,l,c,o,v)),Me&&we.restore(),ve){ve.offset();let Re=w[I]*T+O;this.deferredZIndexContexts_[Re]||(this.deferredZIndexContexts_[Re]=[]),this.deferredZIndexContexts_[Re].push(ve)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,r=Object.keys(e).map(Number).sort(gs);for(let l=0,c=r.length;l<c;++l)e[r[l]].forEach(o=>{o.draw(this.renderedContext_),o.clear()}),e[r[l]].length=0}},jy={};function sC(h){if(jy[h]!==void 0)return jy[h];let e=h*2+1,r=h*h,l=new Array(r+1);for(let o=0;o<=h;++o)for(let _=0;_<=h;++_){let v=o*o+_*_;if(v>r)break;let w=l[v];w||(w=[],l[v]=w),w.push(((h+o)*e+(h+_))*4+3),o>0&&w.push(((h-o)*e+(h+_))*4+3),_>0&&(w.push(((h+o)*e+(h-_))*4+3),o>0&&w.push(((h-o)*e+(h-_))*4+3))}let c=[];for(let o=0,_=l.length;o<_;++o)l[o]&&c.push(...l[o]);return jy[h]=c,c}var Ub=Gy;var qy=class extends jp{constructor(e,r,l,c,o,_,v){super(),this.context_=e,this.pixelRatio_=r,this.extent_=l,this.transform_=c,this.transformRotation_=c?nv(Math.atan2(c[1],c[0]),10):0,this.viewRotation_=o,this.squaredTolerance_=_,this.userTransform_=v,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=nr()}drawImages_(e,r,l,c){if(!this.image_)return;let o=vn(e,r,l,c,this.transform_,this.pixelCoordinates_),_=this.context_,v=this.tmpLocalTransform_,w=_.globalAlpha;this.imageOpacity_!=1&&(_.globalAlpha=w*this.imageOpacity_);let T=this.imageRotation_;this.transformRotation_===0&&(T-=this.viewRotation_),this.imageRotateWithView_&&(T+=this.viewRotation_);for(let I=0,L=o.length;I<L;I+=2){let O=o[I]-this.imageAnchorX_,U=o[I+1]-this.imageAnchorY_;if(T!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let J=O+this.imageAnchorX_,ce=U+this.imageAnchorY_;Vr(v,J,ce,1,1,T,-J,-ce),_.save(),_.transform.apply(_,v),_.translate(J,ce),_.scale(this.imageScale_[0],this.imageScale_[1]),_.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),_.restore()}else _.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,O,U,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(_.globalAlpha=w)}drawText_(e,r,l,c){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let o=vn(e,r,l,c,this.transform_,this.pixelCoordinates_),_=this.context_,v=this.textRotation_;for(this.transformRotation_===0&&(v-=this.viewRotation_),this.textRotateWithView_&&(v+=this.viewRotation_);r<l;r+=c){let w=o[r]+this.textOffsetX_,T=o[r+1]+this.textOffsetY_;v!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(_.save(),_.translate(w-this.textOffsetX_,T-this.textOffsetY_),_.rotate(v),_.translate(this.textOffsetX_,this.textOffsetY_),_.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&_.strokeText(this.text_,0,0),this.textFillState_&&_.fillText(this.text_,0,0),_.restore()):(this.textStrokeState_&&_.strokeText(this.text_,w,T),this.textFillState_&&_.fillText(this.text_,w,T))}}moveToLineTo_(e,r,l,c,o){let _=this.context_,v=vn(e,r,l,c,this.transform_,this.pixelCoordinates_);_.moveTo(v[0],v[1]);let w=v.length;o&&(w-=2);for(let T=2;T<w;T+=2)_.lineTo(v[T],v[T+1]);return o&&_.closePath(),l}drawRings_(e,r,l,c){for(let o=0,_=l.length;o<_;++o)r=this.moveToLineTo_(e,r,l[o],c,!0);return r}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Bi(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=xv(e,this.transform_,this.pixelCoordinates_),l=r[2]-r[0],c=r[3]-r[1],o=Math.sqrt(l*l+c*c),_=this.context_;_.beginPath(),_.arc(r[0],r[1],o,0,2*Math.PI),this.fillState_&&_.fill(),this.strokeState_&&_.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break;default:}}drawFeature(e,r){let l=r.getGeometryFunction()(e);l&&(this.setStyle(r),this.drawGeometry(l))}drawGeometryCollection(e){let r=e.getGeometriesArray();for(let l=0,c=r.length;l<c;++l)this.drawGeometry(r[l])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),l=e.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),l=e.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Bi(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=e.getFlatCoordinates();r.beginPath(),this.moveToLineTo_(l,0,l.length,e.getStride(),!1),r.stroke()}if(this.text_!==""){let r=e.getFlatMidpoint();this.drawText_(r,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getExtent();if(Bi(this.extent_,r)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let l=this.context_,c=e.getFlatCoordinates(),o=0,_=e.getEnds(),v=e.getStride();l.beginPath();for(let w=0,T=_.length;w<T;++w)o=this.moveToLineTo_(c,o,_[w],v,!1);l.stroke()}if(this.text_!==""){let l=e.getFlatMidpoints();this.drawText_(l,0,l.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Bi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_;r.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoint();this.drawText_(r,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Bi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=e.getOrientedFlatCoordinates(),c=0,o=e.getEndss(),_=e.getStride();r.beginPath();for(let v=0,w=o.length;v<w;++v){let T=o[v];c=this.drawRings_(l,c,T,_)}this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoints();this.drawText_(r,0,r.length,2)}}}setContextFillState_(e){let r=this.context_,l=this.contextFillState_;l?l.fillStyle!=e.fillStyle&&(l.fillStyle=e.fillStyle,r.fillStyle=e.fillStyle):(r.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let r=this.context_,l=this.contextStrokeState_;l?(l.lineCap!=e.lineCap&&(l.lineCap=e.lineCap,r.lineCap=e.lineCap),yn(l.lineDash,e.lineDash)||r.setLineDash(l.lineDash=e.lineDash),l.lineDashOffset!=e.lineDashOffset&&(l.lineDashOffset=e.lineDashOffset,r.lineDashOffset=e.lineDashOffset),l.lineJoin!=e.lineJoin&&(l.lineJoin=e.lineJoin,r.lineJoin=e.lineJoin),l.lineWidth!=e.lineWidth&&(l.lineWidth=e.lineWidth,r.lineWidth=e.lineWidth),l.miterLimit!=e.miterLimit&&(l.miterLimit=e.miterLimit,r.miterLimit=e.miterLimit),l.strokeStyle!=e.strokeStyle&&(l.strokeStyle=e.strokeStyle,r.strokeStyle=e.strokeStyle)):(r.lineCap=e.lineCap,r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset,r.lineJoin=e.lineJoin,r.lineWidth=e.lineWidth,r.miterLimit=e.miterLimit,r.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){let r=this.context_,l=this.contextTextState_,c=e.textAlign?e.textAlign:ya;l?(l.font!=e.font&&(l.font=e.font,r.font=e.font),l.textAlign!=c&&(l.textAlign=c,r.textAlign=c),l.textBaseline!=e.textBaseline&&(l.textBaseline=e.textBaseline,r.textBaseline=e.textBaseline)):(r.font=e.font,r.textAlign=c,r.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:c,textBaseline:e.textBaseline})}setFillStrokeStyle(e,r){if(!e)this.fillState_=null;else{let l=e.getColor();this.fillState_={fillStyle:Sn(l||Zi)}}if(!r)this.strokeState_=null;else{let l=r.getColor(),c=r.getLineCap(),o=r.getLineDash(),_=r.getLineDashOffset(),v=r.getLineJoin(),w=r.getWidth(),T=r.getMiterLimit(),I=o||In;this.strokeState_={lineCap:c!==void 0?c:Gs,lineDash:this.pixelRatio_===1?I:I.map(L=>L*this.pixelRatio_),lineDashOffset:(_||Cn)*this.pixelRatio_,lineJoin:v!==void 0?v:Us,lineWidth:(w!==void 0?w:wo)*this.pixelRatio_,miterLimit:T!==void 0?T:xo,strokeStyle:Sn(l||vo)}}}setImageStyle(e){let r;if(!e||!(r=e.getSize())){this.image_=null;return}let l=e.getPixelRatio(this.pixelRatio_),c=e.getAnchor(),o=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=c[0]*l,this.imageAnchorY_=c[1]*l,this.imageHeight_=r[1]*l,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=o[0],this.imageOriginY_=o[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let _=e.getScaleArray();this.imageScale_=[_[0]*this.pixelRatio_/l,_[1]*this.pixelRatio_/l],this.imageWidth_=r[0]*l}setTextStyle(e){if(!e)this.text_="";else{let r=e.getFill();if(!r)this.textFillState_=null;else{let U=r.getColor();this.textFillState_={fillStyle:Sn(U||Zi)}}let l=e.getStroke();if(!l)this.textStrokeState_=null;else{let U=l.getColor(),J=l.getLineCap(),ce=l.getLineDash(),he=l.getLineDashOffset(),me=l.getLineJoin(),ve=l.getWidth(),we=l.getMiterLimit();this.textStrokeState_={lineCap:J!==void 0?J:Gs,lineDash:ce||In,lineDashOffset:he||Cn,lineJoin:me!==void 0?me:Us,lineWidth:ve!==void 0?ve:wo,miterLimit:we!==void 0?we:xo,strokeStyle:Sn(U||vo)}}let c=e.getFont(),o=e.getOffsetX(),_=e.getOffsetY(),v=e.getRotateWithView(),w=e.getRotation(),T=e.getScaleArray(),I=e.getText(),L=e.getTextAlign(),O=e.getTextBaseline();this.textState_={font:c!==void 0?c:Rp,textAlign:L!==void 0?L:ya,textBaseline:O!==void 0?O:hl},this.text_=I!==void 0?Array.isArray(I)?I.reduce((U,J,ce)=>U+=ce%2?" ":J,""):I:"",this.textOffsetX_=o!==void 0?this.pixelRatio_*o:0,this.textOffsetY_=_!==void 0?this.pixelRatio_*_:0,this.textRotateWithView_=v!==void 0?v:!1,this.textRotation_=w!==void 0?w:0,this.textScale_=[this.pixelRatio_*T[0],this.pixelRatio_*T[1]]}}},qb=qy;var Cs=.5;function $b(h,e,r,l,c,o,_,v,w){let T=w?Os(c,w):c,I=h[0]*Cs,L=h[1]*Cs,O=Ai(I,L);O.imageSmoothingEnabled=!1;let U=O.canvas,J=new qb(O,Cs,c,null,_,v,w?vc(Zn(),w):null),ce=r.length,he=Math.floor((256*256*256-1)/ce),me={};for(let we=1;we<=ce;++we){let Me=r[we-1],Re=Me.getStyleFunction()||l;if(!Re)continue;let Ce=Re(Me,o);if(!Ce)continue;Array.isArray(Ce)||(Ce=[Ce]);let Ue=(we*he).toString(16).padStart(7,"#00000");for(let Ae=0,Lt=Ce.length;Ae<Lt;++Ae){let lt=Ce[Ae],it=lt.getGeometryFunction()(Me);if(!it||!Bi(T,it.getExtent()))continue;let wt=lt.clone(),zt=wt.getFill();zt&&zt.setColor(Ue);let nt=wt.getStroke();nt&&(nt.setColor(Ue),nt.setLineDash(null)),wt.setText(void 0);let ot=lt.getImage();if(ot){let Tt=ot.getImageSize();if(!Tt)continue;let Bt=Ai(Tt[0],Tt[1],void 0,{alpha:!1}),$t=Bt.canvas;Bt.fillStyle=Ue,Bt.fillRect(0,0,$t.width,$t.height),wt.setImage(new Tu({img:$t,anchor:ot.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:ot.getOrigin(),opacity:1,size:ot.getSize(),scale:ot.getScale(),rotation:ot.getRotation(),rotateWithView:ot.getRotateWithView()}))}let ut=wt.getZIndex()||0,yt=me[ut];yt||(yt={},me[ut]=yt,yt.Polygon=[],yt.Circle=[],yt.LineString=[],yt.Point=[]);let At=it.getType();if(At==="GeometryCollection"){let Tt=it.getGeometriesArrayRecursive();for(let Bt=0,$t=Tt.length;Bt<$t;++Bt){let di=Tt[Bt];yt[di.getType().replace("Multi","")].push(di,wt)}}else yt[At.replace("Multi","")].push(it,wt)}}let ve=Object.keys(me).map(Number).sort(gs);for(let we=0,Me=ve.length;we<Me;++we){let Re=me[ve[we]];for(let Ce in Re){let Le=Re[Ce];for(let Ue=0,Ae=Le.length;Ue<Ae;Ue+=2){J.setStyle(Le[Ue+1]);for(let Lt=0,lt=e.length;Lt<lt;++Lt)J.setTransform(e[Lt]),J.drawGeometry(Le[Ue])}}}return O.getImageData(0,0,U.width,U.height)}function Wb(h,e,r){let l=[];if(r){let c=Math.floor(Math.round(h[0])*Cs),o=Math.floor(Math.round(h[1])*Cs),_=(Ii(c,0,r.width-1)+Ii(o,0,r.height-1)*r.width)*4,v=r.data[_],w=r.data[_+1],I=r.data[_+2]+256*(w+256*v),L=Math.floor((256*256*256-1)/e.length);I&&I%L===0&&l.push(e[I/L-1])}return l}var oC=.5,Zb={Point:pC,LineString:hC,Polygon:mC,MultiPoint:fC,MultiLineString:uC,MultiPolygon:dC,GeometryCollection:cC,Circle:aC};function Xb(h,e){return parseInt(Vt(h),10)-parseInt(Vt(e),10)}function $y(h,e){let r=Wy(h,e);return r*r}function Wy(h,e){return oC*h/e}function aC(h,e,r,l,c){let o=r.getFill(),_=r.getStroke();if(o||_){let w=h.getBuilder(r.getZIndex(),"Circle");w.setFillStrokeStyle(o,_),w.drawCircle(e,l,c)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l)}}function Zy(h,e,r,l,c,o,_,v){let w=[],T=r.getImage();if(T){let O=!0,U=T.getImageState();U==St.LOADED||U==St.ERROR?O=!1:U==St.IDLE&&T.load(),O&&w.push(T.ready())}let I=r.getFill();I&&I.loading()&&w.push(I.ready());let L=w.length>0;return L&&Promise.all(w).then(()=>c(null)),lC(h,e,r,l,o,_,v),L}function lC(h,e,r,l,c,o,_){let v=r.getGeometryFunction()(e);if(!v)return;let w=v.simplifyTransformed(l,c);if(r.getRenderer())Hb(h,w,r,e,_);else{let I=Zb[w.getType()];I(h,w,r,e,_,o)}}function Hb(h,e,r,l,c){if(e.getType()=="GeometryCollection"){let _=e.getGeometries();for(let v=0,w=_.length;v<w;++v)Hb(h,_[v],r,l,c);return}h.getBuilder(r.getZIndex(),"Default").drawCustom(e,l,r.getRenderer(),r.getHitDetectionRenderer(),c)}function cC(h,e,r,l,c,o){let _=e.getGeometriesArray(),v,w;for(v=0,w=_.length;v<w;++v){let T=Zb[_[v].getType()];T(h,_[v],r,l,c,o)}}function hC(h,e,r,l,c){let o=r.getStroke();if(o){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,o),v.drawLineString(e,l,c)}let _=r.getText();if(_&&_.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(_),v.drawText(e,l,c)}}function uC(h,e,r,l,c){let o=r.getStroke();if(o){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,o),v.drawMultiLineString(e,l,c)}let _=r.getText();if(_&&_.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(_),v.drawText(e,l,c)}}function dC(h,e,r,l,c){let o=r.getFill(),_=r.getStroke();if(_||o){let w=h.getBuilder(r.getZIndex(),"Polygon");w.setFillStrokeStyle(o,_),w.drawMultiPolygon(e,l,c)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l,c)}}function pC(h,e,r,l,c,o){let _=r.getImage(),v=r.getText(),w=v&&v.getText(),T=o&&_&&w?{}:void 0;if(_){if(_.getImageState()!=St.LOADED)return;let I=h.getBuilder(r.getZIndex(),"Image");I.setImageStyle(_,T),I.drawPoint(e,l,c)}if(w){let I=h.getBuilder(r.getZIndex(),"Text");I.setTextStyle(v,T),I.drawText(e,l,c)}}function fC(h,e,r,l,c,o){let _=r.getImage(),v=_&&_.getOpacity()!==0,w=r.getText(),T=w&&w.getText(),I=o&&v&&T?{}:void 0;if(v){if(_.getImageState()!=St.LOADED)return;let L=h.getBuilder(r.getZIndex(),"Image");L.setImageStyle(_,I),L.drawMultiPoint(e,l,c)}if(T){let L=h.getBuilder(r.getZIndex(),"Text");L.setTextStyle(w,I),L.drawText(e,l,c)}}function mC(h,e,r,l,c){let o=r.getFill(),_=r.getStroke();if(o||_){let w=h.getBuilder(r.getZIndex(),"Polygon");w.setFillStrokeStyle(o,_),w.drawPolygon(e,l,c)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l,c)}}var Xy=class extends Up{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=xn(),this.wrappedRenderedExtent_=xn(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(e,r,l){let c=r.extent,o=r.viewState,_=o.center,v=o.resolution,w=o.projection,T=o.rotation,I=w.getExtent(),L=this.getLayer().getSource(),O=this.getLayer().getDeclutter(),U=r.pixelRatio,J=r.viewHints,ce=!(J[bn.ANIMATING]||J[bn.INTERACTING]),he=this.context,me=Math.round(_i(c)/v*U),ve=Math.round($i(c)/v*U),we=L.getWrapX()&&w.canWrapX(),Me=we?_i(I):null,Re=we?Math.ceil((c[2]-I[2])/Me)+1:1,Ce=we?Math.floor((c[0]-I[0])/Me):0;do{let Le=this.getRenderTransform(_,v,0,U,me,ve,Ce*Me);r.declutter&&(Le=Le.slice(0)),e.execute(he,[he.canvas.width,he.canvas.height],Le,T,ce,l===void 0?pl:l?Uy:Gb,l?O&&r.declutter[O]:void 0)}while(++Ce<Re)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Ai(this.context.canvas.width,this.context.canvas.height,By))}resetDrawContext_(){if(this.opacity_!==1){let e=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=e,sb(this.context),By.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(e){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,e,!0)}renderDeferredInternal(e){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(e,r){let l=e.layerStatesArray[e.layerIndex];this.opacity_=l.opacity;let c=e.viewState;this.prepareContainer(e,r);let o=this.context,_=this.replayGroup_,v=_&&!_.isEmpty();if(!v&&!(this.getLayer().hasListener(Ns.PRERENDER)||this.getLayer().hasListener(Ns.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(o,e);let w=c.projection;if(this.clipped_=!1,v&&l.extent&&this.clipping){let T=Bs(l.extent,w);v=Bi(T,e.extent),this.clipped_=v&&!fo(T,e.extent),this.clipped_&&this.clipUnrotated(o,e,T)}return v&&this.renderWorlds(_,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&o.restore(),this.postRender(o,e),this.renderedRotation_!==c.rotation&&(this.renderedRotation_=c.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(r=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let l=this.frameState.size.slice(),c=this.renderedCenter_,o=this.renderedResolution_,_=this.renderedRotation_,v=this.renderedProjection_,w=this.wrappedRenderedExtent_,T=this.getLayer(),I=[],L=l[0]*Cs,O=l[1]*Cs;I.push(this.getRenderTransform(c,o,_,Cs,L,O,0).slice());let U=T.getSource(),J=v.getExtent();if(U.getWrapX()&&v.canWrapX()&&!fo(J,w)){let he=w[0],me=_i(J),ve=0,we;for(;he<J[0];)--ve,we=me*ve,I.push(this.getRenderTransform(c,o,_,Cs,L,O,we).slice()),he+=me;for(ve=0,he=w[2];he>J[2];)++ve,we=me*ve,I.push(this.getRenderTransform(c,o,_,Cs,L,O,we).slice()),he-=me}let ce=Zn();this.hitDetectionImageData_=$b(l,I,this.renderedFeatures_,T.getStyleFunction(),w,o,_,$y(o,this.renderedPixelRatio_),ce?v:null)}r(Wb(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,r,l,c,o){if(!this.replayGroup_)return;let _=r.viewState.resolution,v=r.viewState.rotation,w=this.getLayer(),T={},I=function(J,ce,he){let me=Vt(J),ve=T[me];if(ve){if(ve!==!0&&he<ve.distanceSq){if(he===0)return T[me]=!0,o.splice(o.lastIndexOf(ve),1),c(J,w,ce);ve.geometry=ce,ve.distanceSq=he}}else{if(he===0)return T[me]=!0,c(J,w,ce);o.push(T[me]={feature:J,layer:w,geometry:ce,distanceSq:he,callback:c})}},L,O=[this.replayGroup_],U=this.getLayer().getDeclutter();return O.some(J=>L=J.forEachFeatureAtCoordinate(e,_,v,l,I,U&&r.declutter[U]?r.declutter[U].all().map(ce=>ce.value):null)),L}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let r=this.getLayer(),l=r.getSource();if(!l)return!1;let c=e.viewHints[bn.ANIMATING],o=e.viewHints[bn.INTERACTING],_=r.getUpdateWhileAnimating(),v=r.getUpdateWhileInteracting();if(this.ready&&!_&&c||!v&&o)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let w=e.extent,T=e.viewState,I=T.projection,L=T.resolution,O=e.pixelRatio,U=r.getRevision(),J=r.getRenderBuffer(),ce=r.getRenderOrder();ce===void 0&&(ce=Xb);let he=T.center.slice(),me=ns(w,J*L),ve=me.slice(),we=[me.slice()],Me=I.getExtent();if(l.getWrapX()&&I.canWrapX()&&!fo(Me,e.extent)){let nt=_i(Me),ot=Math.max(_i(me)/2,nt);me[0]=Me[0]-ot,me[2]=Me[2]+ot,lv(he,I);let ut=Km(we[0],I);ut[0]<Me[0]&&ut[2]<Me[2]?we.push([ut[0]+nt,ut[1],ut[2]+nt,ut[3]]):ut[0]>Me[0]&&ut[2]>Me[2]&&we.push([ut[0]-nt,ut[1],ut[2]-nt,ut[3]])}if(this.ready&&this.renderedResolution_==L&&this.renderedRevision_==U&&this.renderedRenderOrder_==ce&&this.renderedFrameDeclutter_===!!e.declutter&&fo(this.wrappedRenderedExtent_,me))return yn(this.renderedExtent_,ve)||(this.hitDetectionImageData_=null,this.renderedExtent_=ve),this.renderedCenter_=he,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let Re=new zb(Wy(L,O),me,L,O),Ce=Zn(),Le;if(Ce){for(let nt=0,ot=we.length;nt<ot;++nt){let ut=we[nt],yt=Os(ut,I);l.loadFeatures(yt,fv(L,I),Ce)}Le=vc(Ce,I)}else for(let nt=0,ot=we.length;nt<ot;++nt)l.loadFeatures(we[nt],L,I);let Ue=$y(L,O),Ae=!0,Lt=(nt,ot)=>{let ut,yt=nt.getStyleFunction()||r.getStyleFunction();if(yt&&(ut=yt(nt,L)),ut){let At=this.renderFeature(nt,Ue,ut,Re,Le,this.getLayer().getDeclutter(),ot);Ae=Ae&&!At}},lt=Os(me,I),it=l.getFeaturesInExtent(lt);ce&&it.sort(ce);for(let nt=0,ot=it.length;nt<ot;++nt)Lt(it[nt],nt);this.renderedFeatures_=it,this.ready=Ae;let wt=Re.finish(),zt=new Ub(me,L,O,l.getOverlaps(),wt,r.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=L,this.renderedRevision_=U,this.renderedRenderOrder_=ce,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=ve,this.wrappedRenderedExtent_=me,this.renderedCenter_=he,this.renderedProjection_=I,this.renderedPixelRatio_=O,this.replayGroup_=zt,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,r,l,c,o,_,v){if(!l)return!1;let w=!1;if(Array.isArray(l))for(let T=0,I=l.length;T<I;++T)w=Zy(c,e,l[T],r,this.boundHandleStyleImageChange_,o,_,v)||w;else w=Zy(c,e,l,r,this.boundHandleStyleImageChange_,o,_,v);return w}},Yb=Xy;var Hy=class extends Pb{constructor(e){super(e)}createRenderer(){return new Yb(this)}},fl=Hy;var Yy=class{constructor(e){this.rbush_=new ul(e),this.items_={}}insert(e,r){let l={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:r};this.rbush_.insert(l),this.items_[Vt(r)]=l}load(e,r){let l=new Array(r.length);for(let c=0,o=r.length;c<o;c++){let _=e[c],v=r[c],w={minX:_[0],minY:_[1],maxX:_[2],maxY:_[3],value:v};l[c]=w,this.items_[Vt(v)]=w}this.rbush_.load(l)}remove(e){let r=Vt(e),l=this.items_[r];return delete this.items_[r],this.rbush_.remove(l)!==null}update(e,r){let l=this.items_[Vt(r)],c=[l.minX,l.minY,l.maxX,l.maxY];ap(c,e)||(this.remove(r),this.insert(e,r))}getAll(){return this.rbush_.all().map(function(r){return r.value})}getInExtent(e){let r={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(r).map(function(c){return c.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,r){return this.forEach_(this.getInExtent(e),r)}forEach_(e,r){let l;for(let c=0,o=e.length;c<o;c++)if(l=r(e[c]),l)return l;return l}isEmpty(){return Wn(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let r=this.rbush_.toJSON();return mo(r.minX,r.minY,r.maxX,r.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(let r in e.items_)this.items_[r]=e.items_[r]}},Nu=Yy;var Kb=nr(),Vu=class h{constructor(e,r,l,c,o,_){this.styleFunction,this.extent_,this.id_=_,this.type_=e,this.flatCoordinates_=r,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=l||null,this.properties_=o,this.squaredTolerance_,this.stride_=c,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?la(this.flatCoordinates_):gc(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=ss(this.getExtent());this.flatInteriorPoints_=uu(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=kv(this.flatCoordinates_,this.ends_),r=bp(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=xp(this.flatCoordinates_,0,e,2,r)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=ll(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let e=this.flatCoordinates_,r=0,l=this.ends_;for(let c=0,o=l.length;c<o;++c){let _=l[c],v=ll(e,r,_,2,.5);br(this.flatMidpoints_,v),r=_}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,r){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(e){e=ki(e);let r=e.getExtent(),l=e.getWorldExtent();if(r&&l){let c=$i(l)/$i(r);Vr(Kb,l[0],l[3],c,-c,0,0,0),vn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,Kb,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new h(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=ip((e,r)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),r&&this.simplifiedGeometry_.applyTransform(r);let l=this.simplifiedGeometry_.getFlatCoordinates(),c;switch(this.type_){case"LineString":l.length=al(l,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,l,0),c=[l.length];break;case"MultiLineString":c=[],l.length=mp(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,l,0,c);break;case"Polygon":c=[],l.length=ou(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),l,0,c);break;default:}return c&&(this.simplifiedGeometry_=new h(this.type_,l,c,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};Vu.prototype.getFlatCoordinates=Vu.prototype.getOrientedFlatCoordinates;var Es=Vu;var Ky=class extends sr{constructor(e){super(),this.projection=ki(e.projection),this.attributions_=Jb(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible??!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;let r=this;this.viewPromise_=new Promise(function(l,c){r.viewResolver=l,r.viewRejector=c})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=Jb(e),this.changed()}setState(e){this.state_=e,this.changed()}};function Jb(h){return h?typeof h=="function"?h:(Array.isArray(h)||(h=[h]),e=>h):null}var To=Ky;var Ur={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function Qb(h,e){return[[-1/0,-1/0,1/0,1/0]]}var gC=!1;function yC(h,e,r,l,c,o,_){let v=new XMLHttpRequest;v.open("GET",typeof h=="function"?h(r,l,c):h,!0),e.getType()=="arraybuffer"&&(v.responseType="arraybuffer"),v.withCredentials=gC,v.onload=function(w){if(!v.status||v.status>=200&&v.status<300){let T=e.getType();try{let I;T=="text"||T=="json"?I=v.responseText:T=="xml"?I=v.responseXML||v.responseText:T=="arraybuffer"&&(I=v.response),I?o(e.readFeatures(I,{extent:r,featureProjection:c}),e.readProjection(I)):_()}catch{_()}}else _()},v.onerror=_,v.send()}function Jy(h,e){return function(r,l,c,o,_){let v=this;yC(h,e,r,l,c,function(w,T){v.addFeatures(w),o!==void 0&&o(w)},_||ys)}}var Zs=class extends Si{constructor(e,r,l){super(e),this.feature=r,this.features=l}},Qy=class extends To{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=ys,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(hi(this.format_,"`format` must be set when `url` is set"),this.loader_=Jy(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:Qb;let r=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=r?new Nu:null,this.loadedExtentsRtree_=new Nu,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let l,c;Array.isArray(e.features)?c=e.features:e.features&&(l=e.features,c=l.getArray()),!r&&l===void 0&&(l=new xu(c)),c!==void 0&&this.addFeaturesInternal(c),l!==void 0&&this.bindFeaturesCollection_(l)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let r=Vt(e);if(!this.addToIndex_(r,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(r,e);let l=e.getGeometry();if(l){let c=l.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(c,e)}else this.nullGeometryFeatures_[r]=e;this.dispatchEvent(new Zs(Ur.ADDFEATURE,e))}setupChangeEvents_(e,r){r instanceof Es||(this.featureChangeKeys_[e]=[wr(r,ui.CHANGE,this.handleFeatureChange_,this),wr(r,Qd.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,r){let l=!0;if(r.getId()!==void 0){let c=String(r.getId());if(!(c in this.idIndex_))this.idIndex_[c]=r;else if(r instanceof Es){let o=this.idIndex_[c];o instanceof Es?Array.isArray(o)?o.push(r):this.idIndex_[c]=[o,r]:l=!1}else l=!1}return l&&(hi(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=r),l}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let r=[],l=[],c=[];for(let o=0,_=e.length;o<_;o++){let v=e[o],w=Vt(v);this.addToIndex_(w,v)&&l.push(v)}for(let o=0,_=l.length;o<_;o++){let v=l[o],w=Vt(v);this.setupChangeEvents_(w,v);let T=v.getGeometry();if(T){let I=T.getExtent();r.push(I),c.push(v)}else this.nullGeometryFeatures_[w]=v}if(this.featuresRtree_&&this.featuresRtree_.load(r,c),this.hasListener(Ur.ADDFEATURE))for(let o=0,_=l.length;o<_;o++)this.dispatchEvent(new Zs(Ur.ADDFEATURE,l[o]))}bindFeaturesCollection_(e){let r=!1;this.addEventListener(Ur.ADDFEATURE,function(l){r||(r=!0,e.push(l.feature),r=!1)}),this.addEventListener(Ur.REMOVEFEATURE,function(l){r||(r=!0,e.remove(l.feature),r=!1)}),e.addEventListener(Ss.ADD,l=>{r||(r=!0,this.addFeature(l.element),r=!1)}),e.addEventListener(Ss.REMOVE,l=>{r||(r=!0,this.removeFeature(l.element),r=!1)}),this.featuresCollection_=e}clear(e){if(e){for(let l in this.featureChangeKeys_)this.featureChangeKeys_[l].forEach(jr);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){let l=c=>{this.removeFeatureInternal(c)};this.featuresRtree_.forEach(l);for(let c in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[c])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let r=new Zs(Ur.CLEAR);this.dispatchEvent(r),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,r){let l=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(l,function(c){let o=c.getGeometry();if(o instanceof Es||o.intersectsCoordinate(e))return r(c)})}forEachFeatureInExtent(e,r){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,r);this.featuresCollection_&&this.featuresCollection_.forEach(r)}forEachFeatureIntersectingExtent(e,r){return this.forEachFeatureInExtent(e,function(l){let c=l.getGeometry();if(c instanceof Es||c.intersectsExtent(e)){let o=r(l);if(o)return o}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),Wn(this.nullGeometryFeatures_)||br(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let r=[];return this.forEachFeatureAtCoordinateDirect(e,function(l){r.push(l)}),r}getFeaturesInExtent(e,r){if(this.featuresRtree_){if(!(r&&r.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let c=Xx(e,r);return[].concat(...c.map(o=>this.featuresRtree_.getInExtent(o)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,r){let l=e[0],c=e[1],o=null,_=[NaN,NaN],v=1/0,w=[-1/0,-1/0,1/0,1/0];return r=r||tp,this.featuresRtree_.forEachInExtent(w,function(T){if(r(T)){let I=T.getGeometry(),L=v;if(v=I instanceof Es?0:I.closestPointXY(l,c,_,v),v<L){o=T;let O=Math.sqrt(v);w[0]=l-O,w[1]=c-O,w[2]=l+O,w[3]=c+O}}}),o}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){let r=this.idIndex_[e.toString()];return r!==void 0?r:null}getFeatureByUid(e){let r=this.uidIndex_[e];return r!==void 0?r:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){let r=e.target,l=Vt(r),c=r.getGeometry();if(!c)l in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(r),this.nullGeometryFeatures_[l]=r);else{let _=c.getExtent();l in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[l],this.featuresRtree_&&this.featuresRtree_.insert(_,r)):this.featuresRtree_&&this.featuresRtree_.update(_,r)}let o=r.getId();if(o!==void 0){let _=o.toString();this.idIndex_[_]!==r&&(this.removeFromIdIndex_(r),this.idIndex_[_]=r)}else this.removeFromIdIndex_(r),this.uidIndex_[l]=r;this.changed(),this.dispatchEvent(new Zs(Ur.CHANGEFEATURE,r))}hasFeature(e){let r=e.getId();return r!==void 0?r in this.idIndex_:Vt(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Wn(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,r,l){let c=this.loadedExtentsRtree_,o=this.strategy_(e,r,l);for(let _=0,v=o.length;_<v;++_){let w=o[_];c.forEachInExtent(w,function(I){return fo(I.extent,w)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Zs(Ur.FEATURESLOADSTART)),this.loader_.call(this,w,r,l,I=>{--this.loadingExtentsCount_,this.dispatchEvent(new Zs(Ur.FEATURESLOADEND,void 0,I))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Zs(Ur.FEATURESLOADERROR))}),c.insert(w,{extent:w.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){let r=this.loadedExtentsRtree_,l;r.forEachInExtent(e,function(c){if(ap(c.extent,e))return l=c,!0}),l&&r.remove(l)}removeFeatures(e){let r=!1;for(let l=0,c=e.length;l<c;++l)r=this.removeFeatureInternal(e[l])||r;r&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){let r=Vt(e);if(!(r in this.uidIndex_))return!1;r in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[r]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[r]?.forEach(jr),delete this.featureChangeKeys_[r];let c=e.getId();if(c!==void 0){let o=c.toString(),_=this.idIndex_[o];_===e?delete this.idIndex_[o]:Array.isArray(_)&&(_.splice(_.indexOf(e),1),_.length===1&&(this.idIndex_[o]=_[0]))}return delete this.uidIndex_[r],this.hasListener(Ur.REMOVEFEATURE)&&this.dispatchEvent(new Zs(Ur.REMOVEFEATURE,e)),!0}removeFromIdIndex_(e){for(let r in this.idIndex_)if(this.idIndex_[r]===e){delete this.idIndex_[r];break}}setLoader(e){this.loader_=e}setUrl(e){hi(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(Jy(e,this.format_))}},ml=Qy;var Hn={SINGLECLICK:"singleclick",CLICK:ui.CLICK,DBLCLICK:ui.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var e_={ACTIVE:"active"};var t_=class extends sr{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(e_.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(e_.ACTIVE,e)}setMap(e){this.map_=e}};var e1=t_;var i_=class extends e1{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let r=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==Hn.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==Hn.POINTERUP){let l=this.handleUpEvent(e);this.handlingDownUpSequence=l&&this.targetPointers.length>0}}else if(e.type==Hn.POINTERDOWN){let l=this.handleDownEvent(e);this.handlingDownUpSequence=l,r=this.stopDown(l)}else e.type==Hn.POINTERMOVE&&this.handleMoveEvent(e);return!r}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};var t1=i_;var i1=function(h){let e=h.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var r1=tp,n1=function(h){return h.type==Hn.CLICK};var s1=function(h){return h.type==Hn.SINGLECLICK};var o1=function(h){let e=h.originalEvent;return hi(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var r_=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=ls,this.supportedMediaTypes=null}getReadOptions(e,r){if(r){let l=r.dataProjection?ki(r.dataProjection):this.readProjection(e);r.extent&&l&&l.getUnits()==="tile-pixels"&&(l=ki(l),l.setWorldExtent(r.extent)),r={dataProjection:l,featureProjection:r.featureProjection}}return this.adaptOptions(r)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return xt()}readFeature(e,r){return xt()}readFeatures(e,r){return xt()}readGeometry(e,r){return xt()}readProjection(e){return xt()}writeFeature(e,r){return xt()}writeFeatures(e,r){return xt()}writeGeometry(e,r){return xt()}},a1=r_;function qp(h,e,r){let l=r?ki(r.featureProjection):null,c=r?ki(r.dataProjection):null,o=h;if(l&&c&&!pv(l,c)){e&&(o=h.clone());let _=e?l:c,v=e?c:l;_.getUnits()==="tile-pixels"?o.transform(_,v):o.applyTransform(nl(_,v))}if(e&&r&&r.decimals!==void 0){let _=Math.pow(10,r.decimals),v=function(w){for(let T=0,I=w.length;T<I;++T)w[T]=Math.round(w[T]*_)/_;return w};o===h&&(o=h.clone()),o.applyTransform(v)}return o}var _C={Point:ar,LineString:vs,Polygon:wc,MultiPoint:hu,MultiLineString:vg,MultiPolygon:Tg};function xC(h,e,r){return Array.isArray(e[0])?(vp(h,0,e,r)||(h=h.slice(),pu(h,0,e,r)),h):(du(h,0,e,r)||(h=h.slice(),bc(h,0,e,r)),h)}function n_(h,e){let r=h.geometry;if(!r)return[];if(Array.isArray(r))return r.map(o=>n_({...h,geometry:o})).flat();let l=r.type==="MultiPolygon"?"Polygon":r.type;if(l==="GeometryCollection"||l==="Circle")throw new Error("Unsupported geometry type: "+l);let c=r.layout.length;return qp(new Es(l,l==="Polygon"?xC(r.flatCoordinates,r.ends,c):r.flatCoordinates,r.ends?.flat(),c,h.properties||{},h.id).enableSimplifyTransformed(),!1,e)}function $p(h,e){if(!h)return null;if(Array.isArray(h)){let l=h.map(c=>$p(c,e));return new dg(l)}let r=_C[h.type];return qp(new r(h.flatCoordinates,h.layout,h.ends),!1,e)}var s_=class extends a1{constructor(){super()}getType(){return"json"}readFeature(e,r){return this.readFeatureFromObject(Wp(e),this.getReadOptions(e,r))}readFeatures(e,r){return this.readFeaturesFromObject(Wp(e),this.getReadOptions(e,r))}readFeatureFromObject(e,r){return xt()}readFeaturesFromObject(e,r){return xt()}readGeometry(e,r){return this.readGeometryFromObject(Wp(e),this.getReadOptions(e,r))}readGeometryFromObject(e,r){return xt()}readProjection(e){return this.readProjectionFromObject(Wp(e))}readProjectionFromObject(e){return xt()}writeFeature(e,r){return JSON.stringify(this.writeFeatureObject(e,r))}writeFeatureObject(e,r){return xt()}writeFeatures(e,r){return JSON.stringify(this.writeFeaturesObject(e,r))}writeFeaturesObject(e,r){return xt()}writeGeometry(e,r){return JSON.stringify(this.writeGeometryObject(e,r))}writeGeometryObject(e,r){return xt()}};function Wp(h){if(typeof h=="string"){let e=JSON.parse(h);return e||null}return h!==null?h:null}var l1=s_;var o_=class extends l1{constructor(e){e=e||{},super(),this.dataProjection=ki(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=ki(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,r){let l=null;e.type==="Feature"?l=e:l={type:"Feature",geometry:e,properties:null};let c=l_(l.geometry,r);if(this.featureClass===Es)return n_({geometry:c,id:l.id,properties:l.properties},r);let o=new ls;return this.geometryName_?o.setGeometryName(this.geometryName_):this.extractGeometryName_&&l.geometry_name&&o.setGeometryName(l.geometry_name),o.setGeometry($p(c,r)),"id"in l&&o.setId(l.id),l.properties&&o.setProperties(l.properties,!0),o}readFeaturesFromObject(e,r){let l=e,c=null;if(l.type==="FeatureCollection"){let o=e;c=[];let _=o.features;for(let v=0,w=_.length;v<w;++v){let T=this.readFeatureFromObject(_[v],r);T&&c.push(T)}}else c=[this.readFeatureFromObject(e,r)];return c.flat()}readGeometryFromObject(e,r){return vC(e,r)}readProjectionFromObject(e){let r=e.crs,l;if(r)if(r.type=="name")l=ki(r.properties.name);else if(r.type==="EPSG")l=ki("EPSG:"+r.properties.code);else throw new Error("Unknown SRS type");else l=this.dataProjection;return l}writeFeatureObject(e,r){r=this.adaptOptions(r);let l={type:"Feature",geometry:null,properties:null},c=e.getId();if(c!==void 0&&(l.id=c),!e.hasProperties())return l;let o=e.getProperties(),_=e.getGeometry();return _&&(l.geometry=a_(_,r),delete o[e.getGeometryName()]),Wn(o)||(l.properties=o),l}writeFeaturesObject(e,r){r=this.adaptOptions(r);let l=[];for(let c=0,o=e.length;c<o;++c)l.push(this.writeFeatureObject(e[c],r));return{type:"FeatureCollection",features:l}}writeGeometryObject(e,r){return a_(e,this.adaptOptions(r))}};function l_(h,e){if(!h)return null;let r;switch(h.type){case"Point":{r=wC(h);break}case"LineString":{r=SC(h);break}case"Polygon":{r=TC(h);break}case"MultiPoint":{r=CC(h);break}case"MultiLineString":{r=IC(h);break}case"MultiPolygon":{r=EC(h);break}case"GeometryCollection":{r=bC(h);break}default:throw new Error("Unsupported GeoJSON type: "+h.type)}return r}function vC(h,e){let r=l_(h,e);return $p(r,e)}function bC(h,e){return h.geometries.map(function(l){return l_(l,e)})}function wC(h){let e=h.coordinates;return{type:"Point",flatCoordinates:e,layout:ha(e.length)}}function SC(h){let e=h.coordinates,r=e.flat();return{type:"LineString",flatCoordinates:r,ends:[r.length],layout:ha(e[0]?.length||2)}}function IC(h){let e=h.coordinates,r=e[0]?.[0]?.length||2,l=[],c=ua(l,0,e,r);return{type:"MultiLineString",flatCoordinates:l,ends:c,layout:ha(r)}}function CC(h){let e=h.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:ha(e[0]?.length||2)}}function EC(h){let e=h.coordinates,r=[],l=e[0]?.[0]?.[0].length||2,c=fp(r,0,e,l);return{type:"MultiPolygon",flatCoordinates:r,ends:c,layout:ha(l)}}function TC(h){let e=h.coordinates,r=[],l=e[0]?.[0]?.length,c=ua(r,0,e,l);return{type:"Polygon",flatCoordinates:r,ends:c,layout:ha(l)}}function a_(h,e){h=qp(h,!0,e);let r=h.getType(),l;switch(r){case"Point":{l=LC(h,e);break}case"LineString":{l=AC(h,e);break}case"Polygon":{l=DC(h,e);break}case"MultiPoint":{l=RC(h,e);break}case"MultiLineString":{l=PC(h,e);break}case"MultiPolygon":{l=kC(h,e);break}case"GeometryCollection":{l=MC(h,e);break}case"Circle":{l={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+r)}return l}function MC(h,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:h.getGeometriesArray().map(function(l){return a_(l,e)})}}function AC(h,e){return{type:"LineString",coordinates:h.getCoordinates()}}function PC(h,e){return{type:"MultiLineString",coordinates:h.getCoordinates()}}function RC(h,e){return{type:"MultiPoint",coordinates:h.getCoordinates()}}function kC(h,e){let r;return e&&(r=e.rightHanded),{type:"MultiPolygon",coordinates:h.getCoordinates(r)}}function LC(h,e){return{type:"Point",coordinates:h.getCoordinates()}}function DC(h,e){let r;return e&&(r=e.rightHanded),{type:"Polygon",coordinates:h.getCoordinates(r)}}var cr=o_;var c1=0,ju=1,h1=[0,0,0,0],Fc=[],c_={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},Gu=class extends Si{constructor(e,r,l){super(e),this.features=r,this.mapBrowserEvent=l}},h_=class extends t1{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:o1,this.defaultDeleteCondition_=function(l){return i1(l)&&s1(l)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:r1,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Nu,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new fl({source:new ml({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:zC(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let r;if(e.features?r=e.features:e.source&&(this.source_=e.source,r=new xu(this.source_.getFeatures()),this.source_.addEventListener(Ur.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Ur.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!r)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=r,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Ss.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Ss.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}addFeature_(e){let r=e.getGeometry();if(r){let c=this.SEGMENT_WRITERS_[r.getType()];c&&c(e,r)}let l=this.getMap();l&&l.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastPixel_,l),e.addEventListener(ui.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,r){if(!this.featuresBeingModified_){this.featuresBeingModified_=new xu;let l=this.featuresBeingModified_.getArray();for(let c=0,o=r.length;c<o;++c){let _=r[c];for(let v=0,w=_.length;v<w;++v){let T=_[v].feature;T&&!l.includes(T)&&this.featuresBeingModified_.push(T)}}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new Gu(c_.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(ui.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){let r=this.rBush_,l=[];r.forEach(function(c){e===c.feature&&l.push(c)});for(let c=l.length-1;c>=0;--c){let o=l[c];for(let _=this.dragSegments_.length-1;_>=0;--_)this.dragSegments_[_][0]===o&&this.dragSegments_.splice(_,1);r.remove(o)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){let r=e.target;this.removeFeature_(r),this.addFeature_(r)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,r){let l=r.getCoordinates(),c={feature:e,geometry:r,segment:[l,l]};this.rBush_.insert(r.getExtent(),c)}writeMultiPointGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length;c<o;++c){let _=l[c],v={feature:e,geometry:r,depth:[c],index:c,segment:[_,_]};this.rBush_.insert(r.getExtent(),v)}}writeLineStringGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length-1;c<o;++c){let _=l.slice(c,c+2),v={feature:e,geometry:r,index:c,segment:_};this.rBush_.insert(zs(_),v)}}writeMultiLineStringGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length;c<o;++c){let _=l[c];for(let v=0,w=_.length-1;v<w;++v){let T=_.slice(v,v+2),I={feature:e,geometry:r,depth:[c],index:v,segment:T};this.rBush_.insert(zs(T),I)}}}writePolygonGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length;c<o;++c){let _=l[c];for(let v=0,w=_.length-1;v<w;++v){let T=_.slice(v,v+2),I={feature:e,geometry:r,depth:[c],index:v,segment:T};this.rBush_.insert(zs(T),I)}}}writeMultiPolygonGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length;c<o;++c){let _=l[c];for(let v=0,w=_.length;v<w;++v){let T=_[v];for(let I=0,L=T.length-1;I<L;++I){let O=T.slice(I,I+2),U={feature:e,geometry:r,depth:[v,c],index:I,segment:O};this.rBush_.insert(zs(O),U)}}}}writeCircleGeometry_(e,r){let l=r.getCenter(),c={feature:e,geometry:r,index:c1,segment:[l,l]},o={feature:e,geometry:r,index:ju,segment:[l,l]},_=[c,o];c.featureSegments=_,o.featureSegments=_,this.rBush_.insert(la(l),c);let v=r,w=Zn();if(w&&this.getMap()){let T=this.getMap().getView().getProjection();v=v.clone().transform(w,T),v=Cg(v).transform(T,w)}this.rBush_.insert(v.getExtent(),o)}writeGeometryCollectionGeometry_(e,r){let l=r.getGeometriesArray();for(let c=0;c<l.length;++c){let o=l[c],_=this.SEGMENT_WRITERS_[o.getType()];_(e,o)}}createOrUpdateVertexFeature_(e,r,l){let c=this.vertexFeature_;return c?c.getGeometry().setCoordinates(e):(c=new ls(new ar(e)),this.vertexFeature_=c,this.overlay_.getSource().addFeature(c)),c.set("features",r),c.set("geometries",l),c}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let r;return!e.map.getView().getInteracting()&&e.type==Hn.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=Hn.SINGLECLICK||!this.ignoreNextSingleClick_?r=this.removePoint():r=!0),e.type==Hn.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!r}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_);let r=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],l=[],c=[];for(let o=0,_=this.dragSegments_.length;o<_;++o){let v=this.dragSegments_[o],w=v[0],T=w.feature;l.includes(T)||l.push(T);let I=w.geometry;c.includes(I)||c.push(I);let L=w.depth,O,U=w.segment,J=v[1];for(;r.length<I.getStride();)r.push(U[J][r.length]);switch(I.getType()){case"Point":O=r,U[0]=r,U[1]=r;break;case"MultiPoint":O=I.getCoordinates(),O[w.index]=r,U[0]=r,U[1]=r;break;case"LineString":O=I.getCoordinates(),O[w.index+J]=r,U[J]=r;break;case"MultiLineString":O=I.getCoordinates(),O[L[0]][w.index+J]=r,U[J]=r;break;case"Polygon":O=I.getCoordinates(),O[L[0]][w.index+J]=r,U[J]=r;break;case"MultiPolygon":O=I.getCoordinates(),O[L[1]][L[0]][w.index+J]=r,U[J]=r;break;case"Circle":if(U[0]=r,U[1]=r,w.index===c1)this.changingFeature_=!0,I.setCenter(r),this.changingFeature_=!1;else{this.changingFeature_=!0;let ce=e.map.getView().getProjection(),he=rg(Ni(I.getCenter(),ce),Ni(r,ce)),me=Zn();if(me){let ve=I.clone().transform(me,ce);ve.setRadius(he),he=ve.transform(ce,me).getRadius()}I.setRadius(he),this.changingFeature_=!1}break;default:}O&&this.setGeometryCoordinates_(I,O)}this.createOrUpdateVertexFeature_(r,l,c)}handleDownEvent(e){if(!this.condition_(e))return!1;let r=e.coordinate;this.handlePointerAtPixel_(e.pixel,e.map,r),this.dragSegments_.length=0,this.featuresBeingModified_=null;let l=this.vertexFeature_;if(l){let c=e.map.getView().getProjection(),o=[],_=l.getGeometry().getCoordinates(),v=zs([_]),w=this.rBush_.getInExtent(v),T={};w.sort(FC);for(let I=0,L=w.length;I<L;++I){let O=w[I],U=O.segment,J=Vt(O.geometry),ce=O.depth;if(ce&&(J+="-"+ce.join("-")),T[J]||(T[J]=new Array(2)),O.geometry.getType()==="Circle"&&O.index===ju){let he=d1(r,O,c);tn(he,_)&&!T[J][0]&&(this.dragSegments_.push([O,0]),T[J][0]=O);continue}if(tn(U[0],_)&&!T[J][0]){this.dragSegments_.push([O,0]),T[J][0]=O;continue}if(tn(U[1],_)&&!T[J][1]){if(T[J][0]&&T[J][0].index===0){let he=O.geometry.getCoordinates();switch(O.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":he=he[ce[1]];case"Polygon":if(O.index!==he[ce[0]].length-2)continue;break;default:}}this.dragSegments_.push([O,1]),T[J][1]=O;continue}Vt(U)in this.vertexSegments_&&!T[J][0]&&!T[J][1]&&this.insertVertexCondition_(e)&&o.push(O)}o.length&&this.willModifyFeatures_(e,[o]);for(let I=o.length-1;I>=0;--I)this.insertVertex_(o[I],_)}return!!this.vertexFeature_}handleUpEvent(e){for(let r=this.dragSegments_.length-1;r>=0;--r){let l=this.dragSegments_[r][0],c=l.geometry;if(c.getType()==="Circle"){let o=c.getCenter(),_=l.featureSegments[0],v=l.featureSegments[1];_.segment[0]=o,_.segment[1]=o,v.segment[0]=o,v.segment[1]=o,this.rBush_.update(la(o),_);let w=c,T=Zn();if(T){let I=e.map.getView().getProjection();w=w.clone().transform(T,I),w=Cg(w).transform(I,T)}this.rBush_.update(w.getExtent(),v)}else this.rBush_.update(zs(l.segment),l)}return this.featuresBeingModified_&&(this.dispatchEvent(new Gu(c_.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastPixel_=e.pixel,this.handlePointerAtPixel_(e.pixel,e.map,e.coordinate)}handlePointerAtPixel_(e,r,l){let c=l||r.getCoordinateFromPixel(e),o=r.getView().getProjection(),_=function(T,I){return u1(c,T,o)-u1(c,I,o)},v,w;if(this.hitDetection_){let T=typeof this.hitDetection_=="object"?I=>I===this.hitDetection_:void 0;r.forEachFeatureAtPixel(e,(I,L,O)=>{O&&O.getType()==="Point"&&(O=new ar(sl(O.getCoordinates(),o)));let U=O||I.getGeometry();if(I instanceof ls&&this.features_.getArray().includes(I)){w=U;let J=I.getGeometry().getFlatCoordinates().slice(0,2);v=[{feature:I,geometry:w,segment:[J,J]}]}return!0},{layerFilter:T})}if(!v){let T=Bs(la(c,h1),o),I=r.getView().getResolution()*this.pixelTolerance_,L=Os(ns(T,I,h1),o);v=this.rBush_.getInExtent(L)}if(v&&v.length>0){let T=v.sort(_)[0],I=T.segment,L=d1(c,T,o),O=r.getPixelFromCoordinate(L),U=rg(e,O);if(w||U<=this.pixelTolerance_){let J={};if(J[Vt(I)]=!0,this.snapToPointer_||(this.delta_[0]=L[0]-c[0],this.delta_[1]=L[1]-c[1]),T.geometry.getType()==="Circle"&&T.index===ju)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(L,[T.feature],[T.geometry]);else{let ce=r.getPixelFromCoordinate(I[0]),he=r.getPixelFromCoordinate(I[1]),me=xc(O,ce),ve=xc(O,he);U=Math.sqrt(Math.min(me,ve)),this.snappedToVertex_=U<=this.pixelTolerance_,this.snappedToVertex_&&(L=me>ve?I[1]:I[0]),this.createOrUpdateVertexFeature_(L,[T.feature],[T.geometry]);let we={};we[Vt(T.geometry)]=!0;for(let Me=1,Re=v.length;Me<Re;++Me){let Ce=v[Me].segment;if(tn(I[0],Ce[0])&&tn(I[1],Ce[1])||tn(I[0],Ce[1])&&tn(I[1],Ce[0])){let Le=Vt(v[Me].geometry);Le in we||(we[Le]=!0,J[Vt(Ce)]=!0)}else break}}this.vertexSegments_=J;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,r){let l=e.segment,c=e.feature,o=e.geometry,_=e.depth,v=e.index,w;for(;r.length<o.getStride();)r.push(0);switch(o.getType()){case"MultiLineString":w=o.getCoordinates(),w[_[0]].splice(v+1,0,r);break;case"Polygon":w=o.getCoordinates(),w[_[0]].splice(v+1,0,r);break;case"MultiPolygon":w=o.getCoordinates(),w[_[1]][_[0]].splice(v+1,0,r);break;case"LineString":w=o.getCoordinates(),w.splice(v+1,0,r);break;default:return}this.setGeometryCoordinates_(o,w);let T=this.rBush_;T.remove(e),this.updateSegmentIndices_(o,v,_,1);let I={segment:[l[0],r],feature:c,geometry:o,depth:_,index:v};T.insert(zs(I.segment),I),this.dragSegments_.push([I,1]);let L={segment:[r,l[1]],feature:c,geometry:o,depth:_,index:v+1};T.insert(zs(L.segment),L),this.dragSegments_.push([L,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=Hn.POINTERDRAG){let e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_);let r=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Gu(c_.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null,r}return!1}removeVertex_(){let e=this.dragSegments_,r={},l=!1,c,o,_,v,w,T,I,L,O,U,J;for(w=e.length-1;w>=0;--w)_=e[w],U=_[0],J=Vt(U.feature),U.depth&&(J+="-"+U.depth.join("-")),J in r||(r[J]={}),_[1]===0?(r[J].right=U,r[J].index=U.index):_[1]==1&&(r[J].left=U,r[J].index=U.index+1);for(J in r){switch(O=r[J].right,I=r[J].left,T=r[J].index,L=T-1,I!==void 0?U=I:U=O,L<0&&(L=0),v=U.geometry,o=v.getCoordinates(),c=o,l=!1,v.getType()){case"MultiLineString":o[U.depth[0]].length>2&&(o[U.depth[0]].splice(T,1),l=!0);break;case"LineString":o.length>2&&(o.splice(T,1),l=!0);break;case"MultiPolygon":c=c[U.depth[1]];case"Polygon":c=c[U.depth[0]],c.length>4&&(T==c.length-1&&(T=0),c.splice(T,1),l=!0,T===0&&(c.pop(),c.push(c[0]),L=c.length-1));break;default:}if(l){this.setGeometryCoordinates_(v,o);let ce=[];if(I!==void 0&&(this.rBush_.remove(I),ce.push(I.segment[0])),O!==void 0&&(this.rBush_.remove(O),ce.push(O.segment[1])),I!==void 0&&O!==void 0){let he={depth:U.depth,feature:U.feature,geometry:U.geometry,index:L,segment:ce};this.rBush_.insert(zs(he.segment),he)}this.updateSegmentIndices_(v,T,U.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return l}setGeometryCoordinates_(e,r){this.changingFeature_=!0,e.setCoordinates(r),this.changingFeature_=!1}updateSegmentIndices_(e,r,l,c){this.rBush_.forEachInExtent(e.getExtent(),function(o){o.geometry===e&&(l===void 0||o.depth===void 0||yn(o.depth,l))&&o.index>r&&(o.index+=c)})}};function FC(h,e){return h.index-e.index}function u1(h,e,r){let l=e.geometry;if(l.getType()==="Circle"){let o=l;if(e.index===ju){let _=Zn();_&&(o=o.clone().transform(_,r));let v=xc(o.getCenter(),Ni(h,r)),w=Math.sqrt(v)-o.getRadius();return w*w}}let c=Ni(h,r);return Fc[0]=Ni(e.segment[0],r),Fc[1]=Ni(e.segment[1],r),av(c,Fc)}function d1(h,e,r){let l=e.geometry;if(l.getType()==="Circle"&&e.index===ju){let o=l,_=Zn();return _&&(o=o.clone().transform(_,r)),sl(o.getClosestPoint(Ni(h,r)),r)}let c=Ni(h,r);return Fc[0]=Ni(e.segment[0],r),Fc[1]=Ni(e.segment[1],r),sl(ig(c,Fc),r)}function zC(){let h=fb();return function(e,r){return h.Point}}var u_=h_;var OC=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,p1=/^([\d.]+),([\d.]+)$/,f1=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,Zp="stop-fetch",m1=h=>{let e=[];return h.forEach(r=>{let l=r.getGeometry()?.getCoordinates();l?.length&&e.push(...l)}),e},d_=class h extends Cc{constructor(r={}){super(r);this.abortControllers={};this.cacheStationData={};this.format=new cr({featureProjection:"EPSG:3857"});this.graphs=[];this.initialRouteDrag={};this.segments=[];this.snapToClosestStation=!1;this.useRawViaPoints=!1;this.viaPoints=[];this.element||this.createDefaultElement(),this.loading=!1,this.active=r.active||!0,this.graphs=r.graphs||[["osm",0,99]],this.mot=r.mot||"bus",this.modify=r.modify!==!1,this.apiParams=r.apiParams,this.useRawViaPoints=r.useRawViaPoints||!1,this.snapToClosestStation=r.snapToClosestStation||!1,this.apiKey=r.apiKey,this.stopsApiKey=r.stopsApiKey||this.apiKey,this.stopsApiUrl=r.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new Xh({...r}),this.routingLayer=r.routingLayer||new fl({source:new ml,style:r.style}),this.onRouteError=r.onRouteError||(l=>{this.dispatchEvent(new Si("change:route")),this.reset(),console.error(l)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",l=>{l.key==="active"&&this.onActiveChange(),l.key==="mot"&&this.viaPoints&&this.drawRoute()})}static getGraphsResolutions(r,l){let c=l.getView();return r.map(([,o,_])=>[c.getResolutionForZoom(o),c.getResolutionForZoom(_||o+1)])}abortRequests(){this.graphs.forEach(r=>{let l=r[0];this.abortControllers[l]&&this.abortControllers[l].abort(),this.abortControllers[l]=new AbortController}),this.abortControllers[Zp]?.abort(),this.abortControllers[Zp]=new AbortController,this.loading=!1}activate(){let r=this.getMap();r&&(this.format=new cr({featureProjection:r.getView().getProjection()}),this.graphsResolutions=h.getGraphsResolutions(this.graphs,r),this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.modifyInteraction&&r.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}addViaPoint(r,l=-1,c=0){this.viaPoints.splice(l===-1?this.viaPoints.length:l,c,r),this.drawRoute(),this.dispatchEvent(new Si("change:route"))}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new u_({deleteCondition:r=>{let c=(r.target?.getFeaturesAtPixel(r.pixel,{hitTolerance:5})||[]).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("index"));return n1(r)&&c?(this.removeViaPoint(c.get("index")),!0):!1},pixelTolerance:6,source:this.routingLayer?.getSource()||void 0}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}deactivate(){let r=this.getMap();r&&(this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(!0),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[Zp]);let r=this.viaPoints.map(l=>{if(Array.isArray(l)){let c=this.getMap()?.getView().getProjection(),[o,_]=rl(l,c);return this.snapToClosestStation?[`@${_}`,o]:[_,o]}return this.useRawViaPoints?l:`!${l}`});return this.loading=!0,this.viaPoints.forEach((l,c)=>{this.drawViaPoint(l,c,this.abortControllers[Zp])}),Promise.all(this.graphs.map(([l],c)=>{let{signal:o}=this.abortControllers[l];return this.api?this.api.route({"coord-punish":1e3,"coord-radius":100,elevation:!1,graph:l,mot:this.mot,"resolve-hops":!1,via:`${r.join("|")}`,...this.apiParams||{}},{signal:o}).then(_=>{if(this.segments=this.format.readFeatures(_),this.mot==="foot"){let T=this.segments.reduce((I,L)=>{let O=L.get("trg");return I.find(U=>U[0]===O[0]&&U[1]===O[1])?I:[...I,O]},[]);this.segments=T.map(I=>{let L=this.segments.filter(U=>{let J=U.get("trg");return J[0]===I[0]&&J[1]===I[1]}),O=m1(L);return new ls({geometry:new vs(O)})})}let v=m1(this.segments),w=new ls({geometry:new vs(v)});w.set("graph",l),w.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[c]?.length>=2&&(w.set("minResolution",this.graphsResolutions[c][0]),w.set("maxResolution",this.graphsResolutions[c][1])),this.routingLayer?.getSource()?.addFeature(w),this.loading=!1}).catch(_=>{/AbortError/.test(_.message)||(this.segments=[],this.dispatchEvent(new Si("error")),this.onRouteError(_,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(r,l,c){let o=new ls;if(o.set("viaPointIdx",l),Array.isArray(r))return o.setGeometry(new ar(r)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o);if(!this.useRawViaPoints||f1.test(r)){let I,L;return this.useRawViaPoints?[,I,,L]=f1.exec(r)||[]:[I,L]=r.split("$"),fetch(`${this.stopsApiUrl}lookup/${I}?key=${this.stopsApiKey}`,{signal:c.signal}).then(O=>O.json()).then(O=>{let{coordinates:U}=O.features[0].geometry;return this.cacheStationData[r]=or(U),o.set("viaPointTrack",L),o.setGeometry(new ar(or(U))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(O=>{/AbortError/.test(O.message)||(this.dispatchEvent(new Si("error")),this.onRouteError(O,this),this.loading=!1)})}if(this.useRawViaPoints&&p1.test(r)){let[I,L]=p1.exec(r)||[];if(L&&I){let O=parseFloat(L),U=parseFloat(I),J=or([O,U],this.getMap()?.getView().getProjection());return o.setGeometry(new ar(J)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}}let[,_,,v,w,,T]=OC.exec(r)||[];if(w&&v){let I=or([parseFloat(w),parseFloat(v)],this.getMap()?.getView().getProjection());return o.set("viaPointTrack",T),o.setGeometry(new ar(I)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}return _?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${_}&limit=1`,{signal:c.signal}).then(I=>I.json()).then(I=>{let{coordinates:L}=I.features[0].geometry;return this.cacheStationData[r]=or(L),o.set("viaPointTrack",T),o.setGeometry(new ar(or(L))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(I=>(this.dispatchEvent(new Si("error")),this.onRouteError(I,this),this.loading=!1,null)):Promise.resolve(null)}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}onMapClick(r){let c=r.target.getFeaturesAtPixel(r.pixel,{hitTolerance:5,layerFilter:o=>o===this.routingLayer}).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("viaPointIdx")!==void 0);if(c){this.removeViaPoint(c.get("viaPointIdx"));return}this.addViaPoint(r.coordinate)}onModifyEnd(r){let l=r.mapBrowserEvent.coordinate,{oldRoute:c,segmentIndex:o,viaPoint:_}=this.initialRouteDrag||{};return _?this.addViaPoint(l,_.get("viaPointIdx"),1):c?o===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(l,(o||0)+1):this.addViaPoint(l,0,1)}onModifyStart(r){let l=-1,c=r.features.getArray().find(_=>_.getGeometry()?.getType()==="LineString");if(c?.getGeometry()&&r.mapBrowserEvent.coordinate){let _=ns(new ar(c.getGeometry()?.getClosestPoint(r.mapBrowserEvent.coordinate)).getExtent(),.001);l=this.segments.findIndex(v=>v.getGeometry()?.intersectsExtent(_))}let o=(r.features.getArray().filter(_=>_.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={oldRoute:c?.clone(),segmentIndex:l,viaPoint:o}}removeListeners(){this.onMapClickKey&&el(this.onMapClickKey)}removeViaPoint(r=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[r]&&this.viaPoints.splice(r,1),this.drawRoute(),this.dispatchEvent(new Si("change:route"))}render(){}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new Si("change:route"))}setMap(r){super.setMap(r),r&&this.active?this.activate():r||(this.active=!1)}setViaPoints(r){this.viaPoints=[...r],this.drawRoute(),this.dispatchEvent(new Si("change:route"))}get active(){return this.get("active")}set active(r){this.set("active",r)}get loading(){return this.get("loading")}set loading(r){this.set("loading",r)}get modify(){return this.get("modify")}set modify(r){this.set("modify",r)}get mot(){return this.get("mot")}set mot(r){this.set("mot",r)}},g1=d_;var p_=class{constructor(e){let{apiKey:r,apiParams:l,placeholder:c,url:o}=e||{};this.apiParams={limit:20,...l||{}},this.placeholder=c||"Search for a stop...";let _={apiKey:r};o&&(_.url=o),this.api=new Hh(_),this.abortController=new AbortController,this.createElement(e),this.options=e}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=r=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(r.target.value,this.abortController)},Object.assign(this.inputElt.style,{padding:"10px 30px 10px 10px"}),e.appendChild(this.inputElt),this.suggestionsElt=document.createElement("div"),Object.assign(this.suggestionsElt.style,{backgroundColor:"white",cursor:"pointer",overflowY:"auto"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{cursor:"pointer",display:"none",fontSize:"200%",padding:"0 10px",position:"absolute",right:"0"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}render(e){let r=e?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=r.length?"block":"none",this.suggestionsElt.innerHTML="",r.forEach(l=>{let c=document.createElement("div");c.innerHTML=l?.properties?.name,c.onclick=o=>{this.options?.onSuggestionClick?.(l,o)},Object.assign(c.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(c)}))}search(e,r){return(e!==void 0||e!==null)&&(this.apiParams.q=e),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,r&&{signal:r.signal}).then(l=>{this.render(l)}).catch(()=>{this.render()})}},y1=p_;var BC=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),h},_1=BC;var f_=class extends Cc{constructor(e){let r=_1();r.className=e?.className||"mbt-stop-finder";let l={element:r,...e||{}};super(l),this.controller=new y1({onSuggestionClick:this.onSuggestionClick.bind(this),...l})}onSuggestionClick(e){let r=or(e.geometry.coordinates);this.getMap()?.getView().setCenter(r)}search(e,r){return this.controller.search(e,r)}},x1=f_;var b1=Fs(y_(),1);var NC="vectorTileFeature",__={"EPSG:3857":new cr({featureProjection:"EPSG:3857"})},zc=class extends ba{getFeaturesAtCoordinate(e,r=5){let l=this.getMapLibrePixels(e,r);if(!l)return[];let c=this.getLayer().get("queryRenderedFeaturesOptions")||{};return this.getLayer().mapLibreMap?.queryRenderedFeatures(l,c).map(_=>this.toOlFeature(_))||[]}prepareFrame(){return!0}renderFrame(e){let r=this.getLayer(),{mapLibreMap:l}=r,c=r.getMapInternal();if(!r||!c||!l)return null;let o=l.getCanvas(),{viewState:_}=e;l.jumpTo({center:rl(_.center),zoom:_.zoom-1,bearing:iv(-_.rotation)});let v=r.getOpacity().toString();return o&&v!==o.style.opacity&&(o.style.opacity=v),o.isConnected?VC(o,e)||l.resize():c.render(),l.redraw(),l.getContainer()}getFeatures(e){let r=this.getLayer().getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,l,c){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(_=>{let v=_.getGeometry();v instanceof Ir&&c(_,this.getLayer(),v)}),o?.[0]}getMapLibrePixels(e,r){if(!e)return;let l=this.getLayer().mapLibreMap?.project(rl(e));if(l?.x===void 0||l?.y===void 0)return;let c=[l.x,l.y];if(r){let[o,_]=c;c=[[o-r,_-r],[o+r,_+r]]}return c}toOlFeature(e){let c=this.getLayer().getMapInternal()?.getView()?.getProjection()?.getCode()||"EPSG:3857";__[c]||(__[c]=new cr({featureProjection:c}));let o=__[c].readFeature(e);return o&&o.set(NC,e,!0),o}};function VC(h,e){return h.width===Math.floor(e.size[0]*e.pixelRatio)&&h.height===Math.floor(e.size[1]*e.pixelRatio)}var jC=h=>{if(!h)return[];let{style:e}=h;if(!e)return[];let{sourceCaches:r}=e,l=[];return Object.values(r).forEach(c=>{if(c.used){let{attribution:o}=c.getSource();o&&(l=l.concat(o.replace(/©/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),GC(l)},GC=h=>{let e=h.filter(c=>c!=null&&c.trim&&c.trim()),r=e.map(c=>c.toLowerCase());return[...new Set(r)].map(c=>e.find(o=>o.toLowerCase()===c))},x_=jC;var Oc=class extends ws{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(e){super({source:new To({attributions:()=>x_(this.mapLibreMap)}),...e})}disposeInternal(){el(this.olListenersKeys),this.loaded=!1,this.mapLibreMap&&(this.mapLibreMap.triggerRepaint=()=>{},this.mapLibreMap.remove()),super.disposeInternal()}setMapInternal(e){super.setMapInternal(e),e?this.loadMapLibreMap():this.dispose()}loadMapLibreMap(){this.loaded=!1;let e=this.getMapInternal();if(e&&this.olListenersKeys.push(e.on("change:target",this.loadMapLibreMap.bind(this))),!e?.getTargetElement())return;if(!this.getVisible()){this.olListenersKeys.push(this.once("change:visible",this.loadMapLibreMap.bind(this)));return}let r=document.createElement("div");r.style.position="absolute",r.style.width="100%",r.style.height="100%";let l=this.get("mapLibreOptions");this.mapLibreMap=new b1.Map(Object.assign({},l,{container:r,attributionControl:!1,interactive:!1,trackResize:!1})),this.mapLibreMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mapLibreMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new Si("load"))})}createRenderer(){return new zc(this)}};var I_=Fs(gl());var C1=Fs(gl());var Xi=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Xi=(0,C1.default)(h=>{console.warn(h)},1e3));function oE(h){return class extends h{constructor(...l){let c=l[0];super(c);this.olEventsKeys=[];this.options={};c.properties&&(Xi("Deprecated. Don't use properties options. Pass the values directly in options object."),this.setProperties(c.properties)),this.on("propertychange",o=>{o.key==="children"&&this.onChildrenChange(o.oldValue)}),this.options=c,this.set("children",c.children||[])}attachToMap(l){(super.attachToMap||(()=>{}))(l),(this.get("children")||[]).forEach(c=>{l.addLayer(c)})}detachFromMap(){el(this.olEventsKeys),(this.get("children")||[]).forEach(l=>{this.map.removeLayer(l)}),(super.detachFromMap||(()=>{}))()}flat(){return Xi("Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead."),Qa(this)}onChildrenChange(l){(l||[]).forEach(c=>{c.set("parent",void 0)}),(this.get("children")||[]).forEach(c=>{c.set("parent",this)})}setMapInternal(l){l?(super.setMapInternal(l),this.attachToMap(l)):(this.detachFromMap(),super.setMapInternal(l))}get children(){return Xi("Layer.children is deprecated. Use the Layer.get('children') method instead."),this.get("children")||[]}set children(l){Xi("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),this.set("children",l||[])}get copyrights(){return Xi("Layer.copyrights is deprecated. Get the attributions from the source object"),this.get("copyrights")}set copyrights(l){Xi("Layer.copyrights is deprecated. Set the attributions to the source object.");let c=l&&!Array.isArray(l)?[l]:l;this.set("copyrights",c||[])}get disabled(){return Xi("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),this.get("disabled")}set disabled(l){Xi("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),this.set("disabled",l)}get group(){return Xi("Layer.group is deprecated. Use the Layer.get('group') method instead."),this.get("group")}get hitTolerance(){return Xi("Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."),this.get("hitTolerance")||5}set hitTolerance(l){Xi("Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."),this.set("hitTolerance",l)}get key(){return this.get("key")||this.get("name")||Vt(this)}get map(){return this.getMapInternal()}get name(){return Xi("Layer.name is deprecated. Use the Layer.get('name') method instead."),this.get("name")}get olLayer(){return Xi("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object."),this}set olLayer(l){Xi("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.")}get parent(){return Xi("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),this.get("parent")}set parent(l){Xi("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),this.set("parent",l)}get visible(){return Xi("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),this.getVisible()}set visible(l){Xi("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),this.setVisible(l)}}}var E1=oE;function aE(h){return class extends E1(h){}}var Xs=aE;var T1=(h,e,r,l)=>Ya(`${h}/styles/${e}/style.json`,{[l]:r}).toString(),w_=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(w_=(0,I_.default)(h=>{console.warn(h)},1e3));var S_=class h extends Xs(Oc){constructor(e){let r={apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...e||{},mapLibreOptions:{...e.mapLibreOptions||{}}};!r.mapLibreOptions.style&&r.url?.includes("style.json")?r.mapLibreOptions.style=r.url:!r.mapLibreOptions.style&&r.apiKey&&r.style&&typeof r.style=="string"&&(r.mapLibreOptions.style=T1(r.url,r.style,r.apiKey,r.apiKeyName)),super(r)}attachToMap(e){super.attachToMap(e);let r=(0,I_.default)(this.updateMaplibreMap.bind(this),150);r(),this.olEventsKeys.push(this.on("propertychange",l=>{/(url|style|apiKey|apiKeyName)/.test(l.key)&&r()}))}clone(e){return new h({...this.options||{},...e||{}})}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:T1(this.url,this.style,this.apiKey,this.apiKeyName)}updateMaplibreMap(){try{this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}catch(e){console.error("Error while updating MaplibreMap",e)}}set apiKey(e){this.set("apiKey",e)}get apiKey(){return this.get("apiKey")}set apiKeyName(e){this.set("apiKeyName",e)}get apiKeyName(){return this.get("apiKeyName")}get maplibreMap(){return w_("MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap."),this.mapLibreMap}get mbMap(){return w_("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get style(){return this.get("style")}set style(e){this.set("style",e)}get url(){return this.get("url")}set url(e){this.set("url",e)}},M1=S_;var A1=Fs(gl());var C_={"EPSG:3857":new cr({featureProjection:"EPSG:3857"})},Uu=class extends ba{forEachFeatureAtCoordinate(e,r,l,c){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(_=>{c(_,this.layer_,_.getGeometry())}),o?.[0]}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),c=l.getMapInternal(),{mapLibreMap:o}=l.maplibreLayer,_=c?.getView()?.getProjection()?.getCode()||"EPSG:3857",v=[];if(C_[_]||(C_[_]=new cr({featureProjection:_})),o?.isStyleLoaded()){let w=e&&o.project(rl(e));if(w?.x&&w?.y){let T=[w.x,w.y];if(r){let[L,O]=T;T=[[L-r,O-r],[L+r,O+r]]}let I=l.layers||[];l.layersFilter&&(I=o.getStyle().layers.filter(l.layersFilter)),l.queryRenderedLayersFilter&&(I=o.getStyle().layers.filter(l.queryRenderedLayersFilter)),v=o.queryRenderedFeatures(T,{layers:I.map(L=>L.id),validate:!1}).map(L=>{let O=C_[_].readFeature(L);return O&&O.set(Ic,L),O})}}return v}prepareFrame(){return!0}renderFrame(){return null}};var Mn=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Mn=(0,A1.default)((...h)=>{console.warn(...h)},1e3));var E_=class h extends Xs(ws){constructor(r={mapLibreOptions:{style:{layers:[],sources:{},version:8}}}){r.mapboxLayer&&(Mn("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),r.maplibreLayer=r.mapboxLayer,delete r.mapboxLayer),r.styleLayers&&(Mn("options.styleLayers is deprecated. Use options.layers instead."),r.layers=r.styleLayers,delete r.styleLayers),r.styleLayersFilter&&(Mn("options.styleLayersFilter is deprecated. Use options.layersFilter instead."),r.layersFilter=r.styleLayersFilter,delete r.styleLayersFilter);super({source:new To({}),...r});this.highlightedFeatures=[];this.selectedFeatures=[];this.beforeId=r.beforeId,this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=l=>!!this.layers.find(c=>l.id===c.id))}addLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&(this.layers.forEach(l=>{let{id:c,source:o}=l;(!o||o&&r.getSource(o))&&c&&!r.getLayer(c)&&r.addLayer(l,this.beforeId)}),this.applyLayoutVisibility())}addSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.entries(this.sources).forEach(([l,c])=>{r.getSource(l)||r.addSource(l,c)})}applyLayoutVisibility(r){if(!this.maplibreLayer?.mapLibreMap?.getStyle()||!this.layersFilter)return;let{mapLibreMap:l}=this.maplibreLayer,c=l.getStyle(),o=this.getVisible()?"visible":"none",_=c.layers||[];for(let v=0;v<_.length;v+=1){let w=_[v];if(this.layersFilter(w)){let{id:T}=w;l.getLayer(T)&&(l.setLayoutProperty(T,"visibility",o),(this.getMinZoom()||this.getMaxZoom())&&l.setLayerZoomRange(T,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}attachToMap(r){if(this.maplibreLayer&&!this.maplibreLayer.map&&r.addLayer(this.maplibreLayer),super.attachToMap(r),!this.map||!this.maplibreLayer)return;if(!this.map.getTargetElement()){this.olEventsKeys.push(this.map.on("change:target",()=>{this.attachToMap(r)}));return}let{mapLibreMap:l}=this.maplibreLayer;l&&(l.loaded()?this.onLoad():l.once("load",this.onLoad)),this.olEventsKeys.push(this.maplibreLayer.on("load",this.onLoad.bind(this)),this.on("change:visible",c=>{this.applyLayoutVisibility(c)}),this.on("propertychange",c=>{/(sources|layers|layersFilter|maplibreLayer|beforeId)/.test(c.key)&&(this.detachFromMap(),this.attachToMap(r))}),this.maplibreLayer.on("propertychange",c=>{c.key==="style"&&c.target.maplibreMap.once("styledata",()=>{c.target.maplibreMap.once("idle",()=>{this.onLoad()})})}))}clone(r){return new h({...this.options,...r})}createRenderer(){return new Uu(this)}detachFromMap(){this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources()),super.detachFromMap()}getFeatureInfoAtCoordinate(r){if(Mn("Deprecated. getFeatureInfoAtCoordinate([layer], coordinate) from ol package instead."),!this.maplibreLayer?.mapLibreMap)return Promise.resolve({coordinate:r,features:[],layer:this});let{mapLibreMap:l}=this.maplibreLayer;if(!l.isStyleLoaded())return Promise.resolve({coordinate:r,features:[],layer:this});let c=this.layers||[];return this.layersFilter&&(c=l.getStyle().layers.filter(this.layersFilter),console.log(c)),this.queryRenderedLayersFilter&&(c=l.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({coordinate:r,features:[],layer:this})}highlight(r=[]){Mn("Deprecated. Use layer.setFeatureState(features, {hover: true}) instead.");let l=this.highlightedFeatures?.filter(c=>!(this.selectedFeatures||[]).map(o=>o.getId()).includes(c.getId()))||[];this.setHoverState(l,!1),this.highlightedFeatures=r,this.setHoverState(this.highlightedFeatures,!0)}onLoad(){if(!this.maplibreLayer?.mapLibreMap)return;this.addSources(),this.addLayers();let{mapLibreMap:r}=this.maplibreLayer,l=r.getStyle();if(l?.layers&&this.layersFilter){let c=l.layers.filter(this.layersFilter);this.set("disabled",!c.length)}this.applyLayoutVisibility()}removeLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&this.layers.forEach(l=>{let{id:c}=l;c&&r.getLayer(c)&&r.removeLayer(c)})}removeSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.keys(this.sources).forEach(l=>{r.getSource(l)&&r.removeSource(l)})}select(r=[]){Mn("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=r,this.setHoverState(this.selectedFeatures||[],!0)}setFeatureState(r,l){if(!this.maplibreLayer?.mapLibreMap||!r.length)return;let{mapLibreMap:c}=this.maplibreLayer;r.forEach(o=>{let{source:_,sourceLayer:v}=o.get(Ic)||{};if(!_&&!v||!o.getId()){o.getId()||Mn("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",o.getProperties());return}c.setFeatureState({id:o.getId(),source:_,sourceLayer:v},l)})}setHoverState(r,l){Mn(`Deprecated. Use layer.setFeatureState(features, {hover: ${l}}) instead.`),this.setFeatureState(r,{hover:l})}get beforeId(){return this.get("beforeId")}set beforeId(r){this.set("beforeId",r)}get layers(){return this.get("layers")}set layers(r){this.set("layers",r)}get layersFilter(){return this.get("layersFilter")}set layersFilter(r){this.set("layersFilter",r)}get mapboxLayer(){return Mn("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(r){this.set("maplibreLayer",r)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(r){this.set("queryRenderedLayersFilter",r)}get sources(){return this.get("sources")}set sources(r){this.set("sources",r)}get styleLayer(){return Mn("Deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(r){Mn("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[r]}get styleLayers(){return Mn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(r){Mn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=r}},P1=E_;var R_=Fs(gl());var M_=Fs(gl()),A_=Fs(F1());var P_=class{constructor(e){this.getViewState=()=>({});this.shouldRender=()=>!0;this._mode=e.mode||qi.TOPOGRAPHIC,this._speed=e.speed||1,this._style=e.style||Ka,this._time=e.time||new Date,this.api=e.api||new Zh(e),this.bboxParameters=e.bboxParameters,this.canvas=e.canvas||document.createElement("canvas"),this.debug=e.debug||!1,this.filter=e.filter,this.hoverVehicleId=e.hoverVehicleId,this.live=e.live!==!1,this.minZoomInterpolation=e.minZoomInterpolation||8,this.pixelRatio=e.pixelRatio||(typeof window<"u"?window.devicePixelRatio:1),this.selectedVehicleId=e.selectedVehicleId,this.sort=e.sort,this.styleOptions={...Sc,...e.styleOptions||{}},this.tenant=e.tenant||"",this.trajectories={},this.useDebounce=e.useDebounce||!1,this.useRequestAnimationFrame=e.useRequestAnimationFrame||!1,this.useThrottle=e.useThrottle!==!1,this.getViewState=e.getViewState||(()=>({})),this.shouldRender=e.shouldRender||(()=>!0),this.onRender=e.onRender,this.onStart=e.onStart,this.onStop=e.onStop,this.format=new cr,this.motsByZoom=e.motsByZoom||[bs,bs,bs,bs,bs,bs,bs,bs,bs,wp,wp],this.getMotsByZoom=r=>e.getMotsByZoom?e.getMotsByZoom(r,this.motsByZoom):this.motsByZoom[r],this.generalizationLevelByZoom=e.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=r=>e.getGeneralizationLevelByZoom?e.getGeneralizationLevelByZoom(r,this.generalizationLevelByZoom):this.generalizationLevelByZoom[r],this.renderTimeIntervalByZoom=e.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=r=>e.getRenderTimeIntervalByZoom?e.getRenderTimeIntervalByZoom(r,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[r],this.isUpdateBboxOnMoveEnd=e.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,A_.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,M_.default)(this.renderTrajectoriesInternal,50,{leading:!0,maxWait:5e3,trailing:!0}),this.renderState={center:[0,0],rotation:0,zoom:void 0},this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}addTrajectory(e){this.trajectories||(this.trajectories={});let r=e.properties.train_id;r!==void 0&&(this.trajectories[r]=e),this.renderTrajectories()}attachToMap(){document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),this.canvas){let e=this.canvas.getContext("2d");e&&e.clearRect(0,0,this.canvas.width,this.canvas.height)}}getRefreshTimeInMs(){let r=this.getViewState().zoom||0,l=r!==void 0?Math.round(r):-1,c=this.getRenderTimeIntervalByZoom(l)||25,o=Math.max(25,c/(this.speed||1)),_=Math.min(o,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,A_.default)(this.renderTrajectoriesInternal,_,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,M_.default)(this.renderTrajectoriesInternal,_,{leading:!0,maxWait:5e3,trailing:!0})),this.api?.buffer){let[,v]=this.api.buffer;this.api.buffer=[_,v]}return o}getVehicle(e){return this.trajectories&&Object.values(this.trajectories).filter(e)||[]}getVehiclesAtCoordinate(e,r){let{resolution:l}=this.getViewState(),{hitTolerance:c,nb:o}=r||{},_=ns([...e,...e],(c||5)*(l||1)),v=Object.values(this.trajectories||{});this.sort&&(v=v.sort(this.sort));let w=[];for(let T=0;T<v.length;T+=1){let{coordinate:I}=v[T].properties;if(I&&tl(_,I)&&w.push(v[T]),w.length===o)break}return{features:w,type:"FeatureCollection"}}onDeleteTrajectoryMessage(e){e.content&&this.removeTrajectory(e.content)}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(!this.getViewState().visible)return;this.start()}}onTrajectoryMessage(e){if(!e.content)return;let r=e.content,{geometry:l,properties:{raw_coordinates:c,time_since_update:o}}=r;o<0||this.purgeTrajectory(r)||(this.debug&&this.mode===qi.TOPOGRAPHIC&&c?r.properties.olGeometry=this.format.readGeometry({coordinates:or(c),type:"Point"}):r.properties.olGeometry=this.format.readGeometry(l),r.properties.timeOffset=Date.now()-e.timestamp,this.addTrajectory(r))}onZoomEnd(){this.startUpdateTime()}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([e,r])=>{let l=r?.properties?.time_intervals;this.time&&l?.length&&l[l.length-1][0]<this.time.getTime()&&this.removeTrajectory(e)})}purgeTrajectory(e){let l=this.getViewState().extent,{bounds:c,type:o}=e.properties;return this.isUpdateBboxOnMoveEnd&&l&&!Bi(l,c)||this.mots&&!this.mots.includes(o)?(this.removeTrajectory(e),!0):!1}removeTrajectory(e){let r;typeof e!="string"?r=e?.properties?.train_id:r=e,r!==void 0&&this.trajectories&&delete this.trajectories[r]}renderTrajectories(e){let r=this.getViewState();this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),!(!r?.center||!r?.extent||!r?.size)&&(!e&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(r,e)}):!e&&this.useDebounce?this.debounceRenderTrajectories(r,e):!e&&this.useThrottle?this.throttleRenderTrajectories(r,e):this.renderTrajectoriesInternal(r,e))}renderTrajectoriesInternal(e,r=!1){if(!this.trajectories||!this.shouldRender())return!1;let l=this.live?Date.now():this.time?.getTime(),c=Object.values(this.trajectories);return this.sort&&c.sort(this.sort),!this.canvas||!this.style||(this.renderState=gu(this.canvas,c,this.style,{...e,pixelRatio:this.pixelRatio||1,time:l},{filter:this.filter,hoverVehicleId:this.hoverVehicleId,noInterpolate:(e.zoom||0)<this.minZoomInterpolation?!0:r,selectedVehicleId:this.selectedVehicleId,...this.styleOptions}),this.onRender?.(this.renderState,e)),!0}setBbox(){let e=this.getViewState(),r=e.extent,l=e.zoom||0;if(!r||Number.isNaN(l))return;if(this.trajectories&&r&&l){let I=Object.keys(this.trajectories);for(let L=I.length-1;L>=0;L-=1)this.purgeTrajectory(this.trajectories[I[L]])}let c=Math.floor(l);if(!r||Number.isNaN(c))return;let[o,_,v,w]=r,T=[Math.floor(o),Math.floor(_),Math.ceil(v),Math.ceil(w),c];this.generalizationLevel=this.getGeneralizationLevelByZoom(c),this.generalizationLevel&&T.push(`gen=${this.generalizationLevel}`),this.mots=this.getMotsByZoom(c),this.mots&&T.push(`mots=${this.mots}`),this.tenant&&T.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&T.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([I,L])=>{T.push(`${I}=${L}`)}),this.api.bbox=T}start(){this.stop(),this.purgeOutOfDateTrajectories(),this.renderTrajectories(),this.startUpdateTime(),this.api.open(),this.api.subscribeTrajectory(this.mode,this.onTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.api.subscribeDeletedVehicles(this.mode,this.onDeleteTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.isUpdateBboxOnMoveEnd&&this.setBbox(),this.onStart&&this.onStart(this)}startUpdateTime(){this.stopUpdateTime(),this.updateTimeDelay=this.getRefreshTimeInMs()||0,this.updateTimeInterval=window.setInterval(()=>{this.live?this.time=new Date:this.time&&this.updateTimeDelay&&this.speed&&(this.time=new Date(this.time.getTime()+this.updateTimeDelay*this.speed))},this.updateTimeDelay)}stop(){this.api.unsubscribeTrajectory(this.onTrajectoryMessage),this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage),this.api.close(),this.onStop&&this.onStop(this)}stopUpdateTime(){this.updateTimeInterval&&(clearInterval(this.updateTimeInterval),this.updateTimeInterval=void 0)}get mode(){return this._mode}set mode(e){e!==this._mode&&(this._mode=e,this.api?.wsApi?.open&&(this.stop(),this.start()))}get speed(){return this._speed}set speed(e){this._speed=e,this.start()}get style(){return this._style}set style(e){this._style=e,this.renderTrajectories()}get time(){return this._time}set time(e){this._time=e?.getTime?e:new Date(e),this.renderTrajectories()}},Hp=P_;var CE=new cr,qu=class extends Up{forEachFeatureAtCoordinate(e,r,l,c){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(_=>{c(_,this.layer_,_.getGeometry())}),o?.[0]}getData(e){let r;try{let{pixelRatio:l}=this.getLayer();return r=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(e[0]*(l||1),e[1]*(l||1),1,1).data||null,r}catch(l){console.error("error getting data",l)}return null}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),c=l.engine.getVehiclesAtCoordinate(e,{hitTolerance:r,nb:l.maxNbFeaturesRequested});return CE.readFeatures(c)}prepareFrame(){return!0}renderFrame(e){let{canvas:r,renderedViewState:l}=this.getLayer();if(this.container||(this.container=document.createElement("div"),this.container.className=this.getLayer().getClassName(),this.container.style.position="absolute",this.container.style.width="100%",this.container.style.height="100%",r instanceof HTMLCanvasElement&&(r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.transformOrigin="top left",this.container.appendChild(r))),l){let{center:c,resolution:o,rotation:_}=e.viewState,{center:v,resolution:w,rotation:T}=l;if(w/o>=3){let I=r?.getContext("2d");r?.width&&r?.height&&I?.clearRect(0,0,r.width,r.height)}else{let I=this.getLayer().getMapInternal(),L=I?.getPixelFromCoordinate(v),O=I?.getPixelFromCoordinate(c);L&&O&&(this.container.style.transform=zx(L[0]-O[0],L[1]-O[1],w/o,w/o,_-T,0,0))}}return this.container}};var EE=new Er({image:new En({fill:new Cr({color:"#000000"}),radius:5}),stroke:new Wi({color:"#000000",width:6}),zIndex:2}),TE=(h,e,r)=>{let l="#ffffff",c=h.get("type"),o=h.get("stroke");return o&&o[0]!=="#"&&(o=`#${o}`),l=o||r?.getBgColor(c),l=/#ffffff/i.test(l)?"#ff0000":l,[EE,new Er({image:new En({fill:new Cr({color:l}),radius:4}),stroke:new Wi({color:l,width:4}),zIndex:3})]},Yp=TE;var ME=new Er({image:new En({fill:new Cr({color:"#000000"}),radius:5}),stroke:new Wi({color:"#000000",width:6}),zIndex:2}),AE=new Er({image:new En({fill:new Cr({color:"#a0a0a0"}),radius:4}),stroke:new Wi({color:"#a0a0a0",width:4}),zIndex:3}),PE=()=>[ME,AE],z1=PE;var O1=new En({fill:new Cr({color:[255,0,0,1]}),radius:6,stroke:new Wi({color:[0,0,0,1],width:1})}),RE=new Er({stroke:new Wi({color:[0,0,0,1],width:5})}),kE=new Er({image:O1,stroke:new Wi({color:[255,0,0,1],width:3})}),LE=new Er({image:O1,stroke:new Wi({color:[255,0,0,1],lineDash:[1,10],width:3})}),DE=(h,e)=>{let r=h.get("minResolution"),l=h.get("maxResolution"),c=e<=r&&e>l;return r&&l&&!c?[]:h.get("mot")!=="foot"?[RE,kE]:[LE]},B1=DE;var FE=new cr,k_=class h extends Xs(ws){constructor(r){super({source:new To({}),...r});this.allowRenderWhenAnimating=!1;this.maxNbFeaturesRequested=100;this.engine=new Hp({getViewState:this.getViewState.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...r}),this.allowRenderWhenAnimating=!!r.allowRenderWhenAnimating,this.vectorLayer=new fl({source:new ml({features:[]}),style:(l,c)=>(r.fullTrajectoryStyle||Yp)(l,c,this.engine.styleOptions),updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0}),this.onZoomEndDebounced=(0,R_.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,R_.default)(this.onMoveEnd,100)}attachToMap(r){if(super.attachToMap(r),this.engine.attachToMap(),this.map){this.getVisible()&&this.engine.start();let l=this.map.getLayers().getArray().indexOf(this);this.map.getLayers().insertAt(l,this.vectorLayer),this.olEventsKeys.push(...this.map.on(["moveend","change:target"],c=>{let o=(c.map||c.target).getView();if(!o||o?.getAnimating()||o?.getInteracting())return;let _=o.getZoom();this.currentZoom!==_&&this.onZoomEndDebounced(c),this.currentZoom=_,this.onMoveEndDebounced(c)}),this.on("change:visible",c=>{c.target.getVisible()?this.engine.start():this.engine.stop()}),this.on("propertychange",c=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(c.key)&&this.vectorLayer.set(c.key,c.target.get(c.key))}))}}clone(r){return new h({...this.options,...r})}createRenderer(){return new qu(this)}detachFromMap(){this.map?.removeLayer(this.vectorLayer),this.engine.detachFromMap(),super.detachFromMap()}getTrajectoryInfos(r){let l=[this.engine.api.getStopSequence(r),this.engine.api.getFullTrajectory(r,this.engine.mode,this.engine.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0)))];return Promise.all(l).then(([c,o])=>({fullTrajectory:o,stopSequence:c}))}getViewState(){if(!this.map?.getView())return{};let r=this.map.getView();return{center:r.getCenter(),extent:r.calculateExtent(),pixelRatio:this.engine.pixelRatio,resolution:r.getResolution(),rotation:r.getRotation(),size:this.map.getSize(),visible:this.getVisible(),zoom:r.getZoom()}}highlight(r){let l=r?.get("train_id");this.hoverVehicleId!==l&&(this.hoverVehicleId=l,this.engine.renderTrajectories(!0))}highlightTrajectory(r){return r?this.engine.api.getFullTrajectory(r,this.engine.mode,this.engine.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0))).then(l=>{let c=l.content;if(!c?.features?.length)return[];let o=FE.readFeatures(c);return this.vectorLayer?.getSource()?.clear(!0),o.length&&this.vectorLayer?.getSource()?.addFeatures(o),o}).catch(()=>(this.vectorLayer?.getSource()?.clear(!0),[])):(this.vectorLayer?.getSource()?.clear(!0),Promise.resolve([]))}onMoveEnd(){!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible()||this.engine.setBbox()}onRealtimeEngineRender(r,l){this.renderedViewState={...l};let{container:c}=this.getRenderer();c&&(c.style.transform="")}onZoomEnd(){this.engine.onZoomEnd(),!(!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible())&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}select(r){let l=r?.get("train_id");this.selectedVehicleId!==l&&(this.selectedVehicleId=l,this.engine.renderTrajectories(!0)),this.highlightTrajectory(l)}shouldRender(){return this.allowRenderWhenAnimating?!1:this.map.getView().getAnimating()||this.map.getView().getInteracting()}start(){this.engine.start()}stop(){this.engine.stop()}get api(){return this.engine.api}set api(r){this.engine.api=r}get canvas(){return this.engine.canvas}get filter(){return this.engine.filter}get hoverVehicleId(){return this.engine.hoverVehicleId}set hoverVehicleId(r){this.engine.hoverVehicleId=r}get mode(){return this.engine.mode}set mode(r){this.engine.mode=r}get pixelRatio(){return this.engine.pixelRatio}get selectedVehicleId(){return this.engine.selectedVehicleId}set selectedVehicleId(r){this.engine.selectedVehicleId=r}get sort(){return this.engine.sort}get trajectories(){return this.engine.trajectories}},N1=k_;var V1=Fs(gl());var j1=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(j1=(0,V1.default)(h=>{console.warn(h)},1e3));var L_=class extends ba{prepareFrame(){return!0}renderFrame(){return null}},D_=class h extends Xs(ws){constructor(e){super(e),j1("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(e){return new h({...this.options||{},...e||{}})}createRenderer(){return new L_(this)}},Kp=D_;var F_=class h extends Kp{clone(e){return new h({...this.options,...e})}getFeatureInfoAtCoordinate(e){let r=[];if(this.map){let l=this.map.getPixelFromCoordinate(e);r=this.map.getFeaturesAtPixel(l,{hitTolerance:this.hitTolerance||5,layerFilter:c=>c===this.olLayer})||[]}return Promise.resolve({coordinate:e,features:r,layer:this})}},G1=F_;var zE=new cr,OE=(h,e,r)=>{let l,{coordinate:c,params:o,projection:_,resolution:v}=e;return h&&v&&_&&(l=h.getFeatureInfoUrl(c,v,_,{info_format:"application/json",query_layers:h.getParams().layers,...o})),fetch(l,{signal:r.signal}).then(w=>w.json()).then(w=>zE.readFeatures(w)).catch(()=>[])},$u={},BE=async(h,e,r=5)=>{Object.values($u).forEach(o=>{o?.abort()}),$u={};let c=Qa(e).map(o=>{let _=o.getMapInternal(),v=_?.getView()?.getProjection()?.getCode(),w={coordinate:h,features:[],layer:o};if(!v)return Promise.resolve(w);if(o.getFeatureInfoAtCoordinate)return o.getFeatureInfoAtCoordinate(h);let T=o?.getSource();if(T?.getFeatureInfoUrl){let O=Vt(o);$u[O]?.abort(),$u[O]=new AbortController;let U=_?.getView()?.getResolution();return OE(T,{coordinate:h,params:{info_format:"application/json",query_layers:T.getParams().layers},projection:v,resolution:U},$u[O]).then(J=>({coordinate:h,features:J,layer:o})).catch(()=>({coordinate:h,features:[],layer:o}))}let I=_?.getPixelFromCoordinate(h);if(!I)return Promise.resolve(w);let L=_?.getFeaturesAtPixel(I,{hitTolerance:o.get("hitTolerance")||r||5,layerFilter:O=>O===o});return Promise.resolve({coordinate:h,features:L,layer:o})});return Promise.all(c)},U1=BE;var rf={};vm(rf,{CopyrightControl:()=>q1,Layer:()=>Qp,RealtimeAPI:()=>Zh,RealtimeLayer:()=>lw,RealtimeModes:()=>qi,RoutingAPI:()=>Xh,StopsAPI:()=>Hh,VECTOR_TILE_FEATURE_PROPERTY:()=>Ic,compareDepartures:()=>yu,createCanvas:()=>ms,createRealtimeFilters:()=>Om,debounceDeparturesMessages:()=>Mg,debounceWebsocketMessages:()=>Wh,getCircleCanvas:()=>Lm,getDelayBgCanvas:()=>Rm,getDelayTextCanvas:()=>km,getHoursAndMinutes:()=>Lx,getLayersAsFlatArray:()=>Qa,getMapGlCopyrights:()=>Yh,getMercatorResolution:()=>aw,getSourceCoordinates:()=>tf,getTextCanvas:()=>Dm,getUTCDateString:()=>Rx,getUTCTimeString:()=>kx,getUrlWithParams:()=>Ya,getVehiclePosition:()=>mu,pad:()=>Jd,realtimeConfig:()=>Sc,realtimeDefaultStyle:()=>Ka,realtimeDelayStyle:()=>Fm,realtimeSimpleStyle:()=>zm,removeDuplicate:()=>Ja,renderTrajectories:()=>gu,sortAndFilterDepartures:()=>_u,sortByDelay:()=>Bm});var NE=" | ",z_=class{constructor(e={}){this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this.map=e,this.container||(this.container=document.createElement("div")),this.render=this.render.bind(this),this.map.on("idle",this.render),this.map.on("sourcedata",this.render),this.map.on("styledata",this.render),this.render(),this.container}onRemove(){return this.container?.parentElement&&this.container.parentElement?.removeChild(this.container),this.map&&(this.map.off("sourcedata",this.render),this.map.off("styledata",this.render),this.map.off("idle",this.render)),this.map=void 0,this.container}render(){if(this.map&&this.container){let e=this.options?.separator||NE,r=this.options?.customAttribution||Yh(this.map),l=(Array.isArray(r)?r:[r]).join(e);this.container.innerHTML!==l&&(this.content=l,this.container.innerHTML=this.content)}}},q1=z_;var W1=Fs(y_());var Tr=[];for(let h=0;h<256;++h)Tr.push((h+256).toString(16).slice(1));function $1(h,e=0){return(Tr[h[e+0]]+Tr[h[e+1]]+Tr[h[e+2]]+Tr[h[e+3]]+"-"+Tr[h[e+4]]+Tr[h[e+5]]+"-"+Tr[h[e+6]]+Tr[h[e+7]]+"-"+Tr[h[e+8]]+Tr[h[e+9]]+"-"+Tr[h[e+10]]+Tr[h[e+11]]+Tr[h[e+12]]+Tr[h[e+13]]+Tr[h[e+14]]+Tr[h[e+15]]).toLowerCase()}var O_,VE=new Uint8Array(16);function B_(){if(!O_){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");O_=crypto.getRandomValues.bind(crypto)}return O_(VE)}var jE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),N_={randomUUID:jE};function GE(h,e,r){if(N_.randomUUID&&!e&&!h)return N_.randomUUID();h=h||{};let l=h.random||(h.rng||B_)();if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,e){r=r||0;for(let c=0;c<16;++c)e[r+c]=l[c];return e}return $1(l)}var V_=GE;var j_=class extends W1.Evented{constructor(r={}){super();this.options={};this.type="custom";this.options=r,this.id=r.id||V_()}onAdd(r,l){this.map=r}onRemove(r,l){this.map=void 0}render(r){}},Qp=j_;var Mr=63710088e-1,X1={centimeters:Mr*100,centimetres:Mr*100,degrees:360/(2*Math.PI),feet:Mr*3.28084,inches:Mr*39.37,kilometers:Mr/1e3,kilometres:Mr/1e3,meters:Mr,metres:Mr,miles:Mr/1609.344,millimeters:Mr*1e3,millimetres:Mr*1e3,nauticalmiles:Mr/1852,radians:1,yards:Mr*1.0936};function UE(h,e,r={}){let l={type:"Feature"};return(r.id===0||r.id)&&(l.id=r.id),r.bbox&&(l.bbox=r.bbox),l.properties=e||{},l.geometry=h,l}function yl(h,e,r={}){if(!h)throw new Error("coordinates is required");if(!Array.isArray(h))throw new Error("coordinates must be an Array");if(h.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Z1(h[0])||!Z1(h[1]))throw new Error("coordinates must contain numbers");return UE({type:"Point",coordinates:h},e,r)}function qE(h,e="kilometers"){let r=X1[e];if(!r)throw new Error(e+" units is invalid");return h*r}function $E(h,e="kilometers"){let r=X1[e];if(!r)throw new Error(e+" units is invalid");return h/r}function H1(h){return h%(2*Math.PI)*180/Math.PI}function _l(h){return h%360*Math.PI/180}function ef(h,e="kilometers",r="kilometers"){if(!(h>=0))throw new Error("length must be a positive number");return qE($E(h,e),r)}function Z1(h){return!isNaN(h)&&h!==null&&!Array.isArray(h)}function Y1(h){return h!==null&&typeof h=="object"&&!Array.isArray(h)}function Wu(h,e,r){if(h!==null)for(var l,c,o,_,v,w,T,I=0,L=0,O,U=h.type,J=U==="FeatureCollection",ce=U==="Feature",he=J?h.features.length:1,me=0;me<he;me++){T=J?h.features[me].geometry:ce?h.geometry:h,O=T?T.type==="GeometryCollection":!1,v=O?T.geometries.length:1;for(var ve=0;ve<v;ve++){var we=0,Me=0;if(_=O?T.geometries[ve]:T,_!==null){w=_.coordinates;var Re=_.type;switch(I=r&&(Re==="Polygon"||Re==="MultiPolygon")?1:0,Re){case null:break;case"Point":if(e(w,L,me,we,Me)===!1)return!1;L++,we++;break;case"LineString":case"MultiPoint":for(l=0;l<w.length;l++){if(e(w[l],L,me,we,Me)===!1)return!1;L++,Re==="MultiPoint"&&we++}Re==="LineString"&&we++;break;case"Polygon":case"MultiLineString":for(l=0;l<w.length;l++){for(c=0;c<w[l].length-I;c++){if(e(w[l][c],L,me,we,Me)===!1)return!1;L++}Re==="MultiLineString"&&we++,Re==="Polygon"&&Me++}Re==="Polygon"&&we++;break;case"MultiPolygon":for(l=0;l<w.length;l++){for(Me=0,c=0;c<w[l].length;c++){for(o=0;o<w[l][c].length-I;o++){if(e(w[l][c][o],L,me,we,Me)===!1)return!1;L++}Me++}we++}break;case"GeometryCollection":for(l=0;l<_.geometries.length;l++)if(Wu(_.geometries[l],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function K1(h,e={}){let r=0,l=0,c=0;return Wu(h,function(o){r+=o[0],l+=o[1],c++},!0),yl([r/c,l/c],e.properties)}function Hs(h){if(!h)throw new Error("coord is required");if(!Array.isArray(h)){if(h.type==="Feature"&&h.geometry!==null&&h.geometry.type==="Point")return[...h.geometry.coordinates];if(h.type==="Point")return[...h.coordinates]}if(Array.isArray(h)&&h.length>=2&&!Array.isArray(h[0])&&!Array.isArray(h[1]))return[...h];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function J1(h){if(Array.isArray(h))return h;if(h.type==="Feature"){if(h.geometry!==null)return h.geometry.coordinates}else if(h.coordinates)return h.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function ew(h,e,r={}){let l;return r.final?l=Q1(Hs(e),Hs(h)):l=Q1(Hs(h),Hs(e)),l>180?-(360-l):l}function Q1(h,e){let r=_l(h[1]),l=_l(e[1]),c=_l(e[0]-h[0]);c>Math.PI&&(c-=2*Math.PI),c<-Math.PI&&(c+=2*Math.PI);let o=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),_=Math.atan2(c,o);return(H1(_)+360)%360}function tw(h,e,r={}){let l=Hs(h),c=Hs(e);c[0]+=c[0]-l[0]>180?-360:l[0]-c[0]>180?360:0;let o=WE(l,c);return ef(o,"meters",r.units)}function WE(h,e,r){r=r===void 0?Mr:Number(r);let l=r,c=h[1]*Math.PI/180,o=e[1]*Math.PI/180,_=o-c,v=Math.abs(e[0]-h[0])*Math.PI/180;v>Math.PI&&(v-=2*Math.PI);let w=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(c/2+Math.PI/4)),T=Math.abs(w)>1e-11?_/w:Math.cos(c);return Math.sqrt(_*_+T*T*v*v)*l}function iw(h,e,r,l={}){let c=e<0,o=ef(Math.abs(e),l.units,"meters");c&&(o=-Math.abs(o));let _=Hs(h),v=ZE(_,o,r);return v[0]+=v[0]-_[0]>180?-360:_[0]-v[0]>180?360:0,yl(v,l.properties)}function ZE(h,e,r,l){l=l===void 0?Mr:Number(l);let c=e/l,o=h[0]*Math.PI/180,_=_l(h[1]),v=_l(r),w=c*Math.cos(v),T=_+w;Math.abs(T)>Math.PI/2&&(T=T>0?Math.PI-T:-Math.PI-T);let I=Math.log(Math.tan(T/2+Math.PI/4)/Math.tan(_/2+Math.PI/4)),L=Math.abs(I)>1e-11?w/I:Math.cos(_),O=c*Math.sin(v)/L;return[((o+O)*180/Math.PI+540)%360-180,T*180/Math.PI]}function rw(h){if(!h)throw new Error("geojson is required");switch(h.type){case"Feature":return nw(h);case"FeatureCollection":return XE(h);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return G_(h);default:throw new Error("unknown GeoJSON type")}}function nw(h){let e={type:"Feature"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:e[r]=h[r]}}),e.properties=sw(h.properties),h.geometry==null?e.geometry=null:e.geometry=G_(h.geometry),e}function sw(h){let e={};return h&&Object.keys(h).forEach(r=>{let l=h[r];typeof l=="object"?l===null?e[r]=null:Array.isArray(l)?e[r]=l.map(c=>c):e[r]=sw(l):e[r]=l}),e}function XE(h){let e={type:"FeatureCollection"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"features":return;default:e[r]=h[r]}}),e.features=h.features.map(r=>nw(r)),e}function G_(h){let e={type:h.type};return h.bbox&&(e.bbox=h.bbox),h.type==="GeometryCollection"?(e.geometries=h.geometries.map(r=>G_(r)),e):(e.coordinates=ow(h.coordinates),e)}function ow(h){let e=h;return typeof e[0]!="object"?e.slice():e.map(r=>ow(r))}function HE(h,e,r){if(r=r||{},!Y1(r))throw new Error("options is invalid");let l=r.pivot,c=r.mutate;if(!h)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");if(e===0)return h;let o=l??K1(h);return(c===!1||c===void 0)&&(h=rw(h)),Wu(h,function(_){let w=ew(o,_)+e,T=tw(o,_),I=J1(iw(o,T,w));_[0]=I[0],_[1]=I[1]}),h}var U_=HE;var YE=(h,e=1)=>{let{height:r,width:l}=h.getCanvas(),c=h.unproject({x:0,y:0}),o=h.unproject({x:0,y:r/e}),_=h.unproject({x:l/e,y:r/e}),v=h.unproject({x:l/e,y:0});return[[c.lng,c.lat],[v.lng,v.lat],[_.lng,_.lat],[o.lng,o.lat]]},tf=YE;var KE=h=>{let e=h.getBounds().toArray(),r=or(e[0]),l=or(e[1]),c=[...r,...l],{width:o,height:_}=h.getCanvas(),v=_i(c)/o,w=$i(c)/_;return Math.max(v,w)},aw=KE;var q_=class extends Qp{#e;constructor(e={}){let r=e?.id||"realtime";super({...e,id:"realtime-custom-"+r}),this.#e=r,this.engine=new Hp({getViewState:this.getViewState.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...e}),this.sourceId=this.#e,this.source={animate:!0,attribution:e.attribution?.join(", "),canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],loaded:!0,type:"canvas"},this.layer={id:this.#e,layout:{visibility:"visible"},paint:{"raster-fade-duration":0,"raster-opacity":1,"raster-resampling":"nearest"},source:this.sourceId,type:"raster"},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}getViewState(){if(!this.map)return{};this.pixelRatio||(this.pixelRatio=1);let{height:e,width:r}=this.map.getCanvas(),l=this.map.getCenter(),c=this.map.unproject({x:0,y:e/this.pixelRatio}),o=this.map.unproject({x:r/this.pixelRatio,y:0}),_=U_(yl([c.lng,c.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,v=U_(yl([o.lng,o.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,w=[...or(_),...or(v)],T=_i(w)/(r/this.pixelRatio),I=$i(w)/(e/this.pixelRatio),L=Math.max(T,I);return{center:or([l.lng,l.lat]),extent:w,pixelRatio:this.pixelRatio,resolution:L,rotation:-(this.map.getBearing()*Math.PI)/180,size:[r/this.pixelRatio,e/this.pixelRatio],visible:!0,zoom:this.map.getZoom()-1}}onAdd(e,r){super.onAdd(e,r),this.engine.attachToMap(),e.isStyleLoaded()&&this.onLoad(),e.on("load",this.onLoad)}onLoad(){this.map?.getSource(this.sourceId)||this.map?.addSource(this.sourceId,this.source),this.map?.getLayer(this.layer.id)||this.map?.addLayer(this.layer,this.id),this.start()}onMove(){this.engine.renderTrajectories()}onMoveEnd(){this.engine.renderTrajectories(),this.engine.isUpdateBboxOnMoveEnd&&this.engine.setBbox()}onRealtimeEngineRender(){if(this.map?.style){let e=tf(this.map,this.pixelRatio),r=this.map.getSource(this.sourceId);r&&r.setCoordinates(e)}}onRemove(e,r){this.engine.detachFromMap(),this.stop(),e.off("load",this.onLoad),e.getLayer(this.layer.id)&&e.removeLayer(this.layer.id),e.getSource(this.sourceId)&&e.removeSource(this.sourceId),super.onRemove(e,r)}onZoomEnd(){this.engine.onZoomEnd()}start(){this.engine.start(),this.map?.on("move",this.onMove),this.map?.on("moveend",this.onMoveEnd),this.map?.on("zoomend",this.onZoomEnd)}stop(){this.engine.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}get canvas(){return this.engine.canvas}get pixelRatio(){return this.engine.pixelRatio||1}set pixelRatio(e){this.engine.pixelRatio=e||1}},lw=q_;var $_={ol:Jp,maplibre:rf};typeof window<"u"&&(window.mbt=$_);var Z6=$_;})();
|
|
585
|
+
`){wt+=it,it=0,Ae=L*we+Ue*O,++nt;continue}let Tt=U[ut+1]||w.font;Tt!==ot&&(c&&Lt.push("font",Tt),l&<.push("font",Tt),ot=Tt),it=Math.max(it,me[zt]);let Bt=[At,Ae+Ue*he[zt]+L*(he[zt]-ve[nt]),.5*(O+it)+wt];Ae+=he[zt],c&&Lt.push("strokeText",Bt),l&<.push("fillText",Bt),++zt}return Array.prototype.push.apply(Me,Lt),Array.prototype.push.apply(Me,lt),this.labels_[o]=Le,Le}replayTextBackground_(e,r,l,c,o,_,v){e.beginPath(),e.moveTo.apply(e,r),e.lineTo.apply(e,l),e.lineTo.apply(e,c),e.lineTo.apply(e,o),e.lineTo.apply(e,r),_&&(this.alignAndScaleFill_=_[2],this.fill_(e)),v&&(this.setStrokeStyle_(e,v),e.stroke())}calculateImageOrLabelDimensions_(e,r,l,c,o,_,v,w,T,I,L,O,U,J,ce,he){v*=O[0],w*=O[1];let me=l-v,ve=c-w,we=o+T>e?e-T:o,Me=_+I>r?r-I:_,Re=J[3]+we*O[0]+J[1],Ce=J[0]+Me*O[1]+J[2],Le=me-J[3],Ue=ve-J[0];(ce||L!==0)&&(wa[0]=Le,Sa[0]=Le,wa[1]=Ue,Co[1]=Ue,Co[0]=Le+Re,Eo[0]=Co[0],Eo[1]=Ue+Ce,Sa[1]=Eo[1]);let Ae;return L!==0?(Ae=Vr(nr(),l,c,1,1,L,-l,-c),vr(Ae,wa),vr(Ae,Co),vr(Ae,Eo),vr(Ae,Sa),mo(Math.min(wa[0],Co[0],Eo[0],Sa[0]),Math.min(wa[1],Co[1],Eo[1],Sa[1]),Math.max(wa[0],Co[0],Eo[0],Sa[0]),Math.max(wa[1],Co[1],Eo[1],Sa[1]),Dc)):mo(Math.min(Le,Le+Re),Math.min(Ue,Ue+Ce),Math.max(Le,Le+Re),Math.max(Ue,Ue+Ce),Dc),U&&(me=Math.round(me),ve=Math.round(ve)),{drawImageX:me,drawImageY:ve,drawImageW:we,drawImageH:Me,originX:T,originY:I,declutterBox:{minX:Dc[0],minY:Dc[1],maxX:Dc[2],maxY:Dc[3],value:he},canvasTransform:Ae,scale:O}}replayImageOrLabel_(e,r,l,c,o,_,v){let w=!!(_||v),T=c.declutterBox,I=v?v[2]*c.scale[0]/2:0;return T.minX-I<=r[0]&&T.maxX+I>=0&&T.minY-I<=r[1]&&T.maxY+I>=0&&(w&&this.replayTextBackground_(e,wa,Co,Eo,Sa,_,v),ub(e,c.canvasTransform,o,l,c.originX,c.originY,c.drawImageW,c.drawImageH,c.drawImageX,c.drawImageY,c.scale)),!0}fill_(e){let r=this.alignAndScaleFill_;if(r){let l=vr(this.renderedTransform_,[0,0]),c=512*this.pixelRatio;e.save(),e.translate(l[0]%c,l[1]%c),r!==1&&e.scale(r,r),e.rotate(this.viewRotation_)}e.fill(),r&&e.restore()}setStrokeStyle_(e,r){e.strokeStyle=r[1],e.lineWidth=r[2],e.lineCap=r[3],e.lineJoin=r[4],e.miterLimit=r[5],e.lineDashOffset=r[7],e.setLineDash(r[6])}drawLabelWithPointPlacement_(e,r,l,c){let o=this.textStates[r],_=this.createLabel(e,r,c,l),v=this.strokeStates[l],w=this.pixelRatio,T=Ny(Array.isArray(e)?e[0]:e,o.textAlign||ya),I=Bu[o.textBaseline||hl],L=v&&v.lineWidth?v.lineWidth:0,O=_.width/w-2*o.scale[0],U=T*O+2*(.5-T)*L,J=I*_.height/w+2*(.5-I)*L;return{label:_,anchorX:U,anchorY:J}}execute_(e,r,l,c,o,_,v,w){let T=this.zIndexContext_,I;this.pixelCoordinates_&&yn(l,this.renderedTransform_)?I=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),I=vn(this.coordinates,0,this.coordinates.length,2,l,this.pixelCoordinates_),Fx(this.renderedTransform_,l));let L=0,O=c.length,U=0,J,ce,he,me,ve,we,Me,Re,Ce,Le,Ue,Ae,Lt,lt=0,it=0,wt=null,zt=null,nt=this.coordinateCache_,ot=this.viewRotation_,ut=Math.round(Math.atan2(-l[1],l[0])*1e12)/1e12,yt={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:ot},At=this.instructions!=c||this.overlaps?0:200,Tt,Bt,$t,di;for(;L<O;){let je=c[L];switch(je[0]){case dt.BEGIN_GEOMETRY:Tt=je[1],di=je[3],Tt.getGeometry()?v!==void 0&&!Bi(v,di.getExtent())?L=je[2]+1:++L:L=je[2],T&&(T.zIndex=je[4]);break;case dt.BEGIN_PATH:lt>At&&(this.fill_(e),lt=0),it>At&&(e.stroke(),it=0),!lt&&!it&&(e.beginPath(),ve=NaN,we=NaN),++L;break;case dt.CIRCLE:U=je[1];let vi=I[U],hr=I[U+1],ur=I[U+2],nn=I[U+3],Vi=ur-vi,sn=nn-hr,on=Math.sqrt(Vi*Vi+sn*sn);e.moveTo(vi+on,hr),e.arc(vi,hr,on,0,2*Math.PI,!0),++L;break;case dt.CLOSE_PATH:e.closePath(),++L;break;case dt.CUSTOM:U=je[1],J=je[2];let An=je[3],xe=je[4],Pn=je[5];yt.geometry=An,yt.feature=Tt,L in nt||(nt[L]=[]);let dr=nt[L];Pn?Pn(I,U,J,2,dr):(dr[0]=I[U],dr[1]=I[U+1],dr.length=2),T&&(T.zIndex=je[6]),xe(dr,yt),++L;break;case dt.DRAW_IMAGE:U=je[1],J=je[2],Ce=je[3],ce=je[4],he=je[5];let _t=je[6],Zt=je[7],Rn=je[8],an=je[9],Ar=je[10],ln=je[11],pr=je[12],Yn=je[13];me=je[14]||"declutter";let kn=je[15];if(!Ce&&je.length>=20){Le=je[19],Ue=je[20],Ae=je[21],Lt=je[22];let ne=this.drawLabelWithPointPlacement_(Le,Ue,Ae,Lt);Ce=ne.label,je[3]=Ce;let ae=je[23];ce=(ne.anchorX-ae)*this.pixelRatio,je[4]=ce;let ue=je[24];he=(ne.anchorY-ue)*this.pixelRatio,je[5]=he,_t=Ce.height,je[6]=_t,Yn=Ce.width,je[13]=Yn}let Fe;je.length>25&&(Fe=je[25]);let Pr,Ci,fr;je.length>17?(Pr=je[16],Ci=je[17],fr=je[18]):(Pr=bo,Ci=!1,fr=!1),Ar&&ut?ln+=ot:!Ar&&!ut&&(ln-=ot);let Kn=0;for(;U<J;U+=2){if(Fe&&Fe[Kn++]<Yn/this.pixelRatio)continue;let ne=this.calculateImageOrLabelDimensions_(Ce.width,Ce.height,I[U],I[U+1],Yn,_t,ce,he,Rn,an,ln,pr,o,Pr,Ci||fr,Tt),ae=[e,r,Ce,ne,Zt,Ci?wt:null,fr?zt:null];if(w){let ue,ie,_e;if(kn){let Pe=J-U;if(!kn[Pe]){kn[Pe]={args:ae,declutterMode:me};continue}let We=kn[Pe];ue=We.args,ie=We.declutterMode,delete kn[Pe],_e=Nb(ue)}let Ie,ye;if(ue&&(ie!=="declutter"||!w.collides(_e))&&(Ie=!0),(me!=="declutter"||!w.collides(ne.declutterBox))&&(ye=!0),ie==="declutter"&&me==="declutter"){let Pe=Ie&&ye;Ie=Pe,ye=Pe}Ie&&(ie!=="none"&&w.insert(_e),this.replayImageOrLabel_.apply(this,ue)),ye&&(me!=="none"&&w.insert(ne.declutterBox),this.replayImageOrLabel_.apply(this,ae))}else this.replayImageOrLabel_.apply(this,ae)}++L;break;case dt.DRAW_CHARS:let ze=je[1],bt=je[2],ct=je[3],Hi=je[4];Lt=je[5];let qr=je[6],mt=je[7],$r=je[8];Ae=je[9];let Wr=je[10];Le=je[11],Ue=je[12];let Ln=[je[13],je[13]];me=je[14]||"declutter";let Rr=this.textStates[Ue],Q=Rr.font,N=[Rr.scale[0]*mt,Rr.scale[1]*mt],B;Q in this.widths_?B=this.widths_[Q]:(B={},this.widths_[Q]=B);let q=_p(I,ze,bt,2),X=Math.abs(N[0])*oy(Q,Le,B);if(Hi||X<=q){let ne=this.textStates[Ue].textAlign,ae=(q-X)*Ny(Le,ne),ue=Bb(I,ze,bt,2,Le,ae,qr,Math.abs(N[0]),oy,Q,B,ut?0:this.viewRotation_);e:if(ue){let ie=[],_e,Ie,ye,Pe,We;if(Ae)for(_e=0,Ie=ue.length;_e<Ie;++_e){We=ue[_e],ye=We[4],Pe=this.createLabel(ye,Ue,"",Ae),ce=We[2]+(N[0]<0?-Wr:Wr),he=ct*Pe.height+(.5-ct)*2*Wr*N[1]/N[0]-$r;let Je=this.calculateImageOrLabelDimensions_(Pe.width,Pe.height,We[0],We[1],Pe.width,Pe.height,ce,he,0,0,We[3],Ln,!1,bo,!1,Tt);if(w&&me==="declutter"&&w.collides(Je.declutterBox))break e;ie.push([e,r,Pe,Je,1,null,null])}if(Lt)for(_e=0,Ie=ue.length;_e<Ie;++_e){We=ue[_e],ye=We[4],Pe=this.createLabel(ye,Ue,Lt,""),ce=We[2],he=ct*Pe.height-$r;let Je=this.calculateImageOrLabelDimensions_(Pe.width,Pe.height,We[0],We[1],Pe.width,Pe.height,ce,he,0,0,We[3],Ln,!1,bo,!1,Tt);if(w&&me==="declutter"&&w.collides(Je.declutterBox))break e;ie.push([e,r,Pe,Je,1,null,null])}w&&me!=="none"&&w.load(ie.map(Nb));for(let Je=0,Ot=ie.length;Je<Ot;++Je)this.replayImageOrLabel_.apply(this,ie[Je])}}++L;break;case dt.END_GEOMETRY:if(_!==void 0){Tt=je[1];let ne=_(Tt,di,me);if(ne)return ne}++L;break;case dt.FILL:At?lt++:this.fill_(e),++L;break;case dt.MOVE_TO_LINE_TO:for(U=je[1],J=je[2],Bt=I[U],$t=I[U+1],e.moveTo(Bt,$t),ve=Bt+.5|0,we=$t+.5|0,U+=2;U<J;U+=2)Bt=I[U],$t=I[U+1],Me=Bt+.5|0,Re=$t+.5|0,(U==J-2||Me!==ve||Re!==we)&&(e.lineTo(Bt,$t),ve=Me,we=Re);++L;break;case dt.SET_FILL_STYLE:wt=je,this.alignAndScaleFill_=je[2],lt&&(this.fill_(e),lt=0,it&&(e.stroke(),it=0)),e.fillStyle=je[1],++L;break;case dt.SET_STROKE_STYLE:zt=je,it&&(e.stroke(),it=0),this.setStrokeStyle_(e,je),++L;break;case dt.STROKE:At?it++:e.stroke(),++L;break;default:++L;break}}lt&&this.fill_(e),it&&e.stroke()}execute(e,r,l,c,o,_){this.viewRotation_=c,this.execute_(e,r,l,this.instructions,o,void 0,void 0,_)}executeHitDetection(e,r,l,c,o){return this.viewRotation_=l,this.execute_(e,[e.canvas.width,e.canvas.height],r,this.hitDetectionInstructions,!0,c,o)}},jb=Vy;var pl=["Polygon","Circle","LineString","Image","Text","Default"],Uy=["Image","Text"],Gb=pl.filter(h=>!Uy.includes(h)),Gy=class{constructor(e,r,l,c,o,_,v){this.maxExtent_=e,this.overlaps_=c,this.pixelRatio_=l,this.resolution_=r,this.renderBuffer_=_,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=nr(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(o,v)}clip(e,r){let l=this.getClipCoords(r);e.beginPath(),e.moveTo(l[0],l[1]),e.lineTo(l[2],l[3]),e.lineTo(l[4],l[5]),e.lineTo(l[6],l[7]),e.clip()}createExecutors_(e,r){for(let l in e){let c=this.executorsByZIndex_[l];c===void 0&&(c={},this.executorsByZIndex_[l]=c);let o=e[l];for(let _ in o){let v=o[_];c[_]=new jb(this.resolution_,this.pixelRatio_,this.overlaps_,v,r)}}}hasExecutors(e){for(let r in this.executorsByZIndex_){let l=this.executorsByZIndex_[r];for(let c=0,o=e.length;c<o;++c)if(e[c]in l)return!0}return!1}forEachFeatureAtCoordinate(e,r,l,c,o,_){c=Math.round(c);let v=c*2+1,w=Vr(this.hitDetectionTransform_,c+.5,c+.5,1/r,-1/r,-l,-e[0],-e[1]),T=!this.hitDetectionContext_;T&&(this.hitDetectionContext_=Ai(v,v,void 0,{willReadFrequently:!0}));let I=this.hitDetectionContext_;I.canvas.width!==v||I.canvas.height!==v?(I.canvas.width=v,I.canvas.height=v):T||I.clearRect(0,0,v,v);let L;this.renderBuffer_!==void 0&&(L=xn(),$m(L,e),ns(L,r*(this.renderBuffer_+c),L));let O=sC(c),U;function J(Re,Ce,Le){let Ue=I.getImageData(0,0,v,v).data;for(let Ae=0,Lt=O.length;Ae<Lt;Ae++)if(Ue[O[Ae]]>0){if(!_||Le==="none"||U!=="Image"&&U!=="Text"||_.includes(Re)){let lt=(O[Ae]-3)/4,it=c-lt%v,wt=c-(lt/v|0),zt=o(Re,Ce,it*it+wt*wt);if(zt)return zt}I.clearRect(0,0,v,v);break}}let ce=Object.keys(this.executorsByZIndex_).map(Number);ce.sort(gs);let he,me,ve,we,Me;for(he=ce.length-1;he>=0;--he){let Re=ce[he].toString();for(ve=this.executorsByZIndex_[Re],me=pl.length-1;me>=0;--me)if(U=pl[me],we=ve[U],we!==void 0&&(Me=we.executeHitDetection(I,w,l,J,L),Me))return Me}}getClipCoords(e){let r=this.maxExtent_;if(!r)return null;let l=r[0],c=r[1],o=r[2],_=r[3],v=[l,c,l,_,o,_,o,c];return vn(v,0,8,2,e,v),v}isEmpty(){return Wn(this.executorsByZIndex_)}execute(e,r,l,c,o,_,v){let w=Object.keys(this.executorsByZIndex_).map(Number);w.sort(gs),_=_||pl;let T=pl.length,I,L,O,U,J;for(v&&w.reverse(),I=0,L=w.length;I<L;++I){let ce=w[I].toString();for(J=this.executorsByZIndex_[ce],O=0,U=_.length;O<U;++O){let he=_[O],me=J[he];if(me!==void 0){let ve=v===null?void 0:me.getZIndexContext(),we=ve?ve.getContext():e,Me=this.maxExtent_&&he!=="Image"&&he!=="Text";if(Me&&(we.save(),this.clip(we,l)),!ve||he==="Text"||he==="Image"?me.execute(we,r,l,c,o,v):ve.pushFunction(Re=>me.execute(Re,r,l,c,o,v)),Me&&we.restore(),ve){ve.offset();let Re=w[I]*T+O;this.deferredZIndexContexts_[Re]||(this.deferredZIndexContexts_[Re]=[]),this.deferredZIndexContexts_[Re].push(ve)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,r=Object.keys(e).map(Number).sort(gs);for(let l=0,c=r.length;l<c;++l)e[r[l]].forEach(o=>{o.draw(this.renderedContext_),o.clear()}),e[r[l]].length=0}},jy={};function sC(h){if(jy[h]!==void 0)return jy[h];let e=h*2+1,r=h*h,l=new Array(r+1);for(let o=0;o<=h;++o)for(let _=0;_<=h;++_){let v=o*o+_*_;if(v>r)break;let w=l[v];w||(w=[],l[v]=w),w.push(((h+o)*e+(h+_))*4+3),o>0&&w.push(((h-o)*e+(h+_))*4+3),_>0&&(w.push(((h+o)*e+(h-_))*4+3),o>0&&w.push(((h-o)*e+(h-_))*4+3))}let c=[];for(let o=0,_=l.length;o<_;++o)l[o]&&c.push(...l[o]);return jy[h]=c,c}var Ub=Gy;var qy=class extends jp{constructor(e,r,l,c,o,_,v){super(),this.context_=e,this.pixelRatio_=r,this.extent_=l,this.transform_=c,this.transformRotation_=c?nv(Math.atan2(c[1],c[0]),10):0,this.viewRotation_=o,this.squaredTolerance_=_,this.userTransform_=v,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=nr()}drawImages_(e,r,l,c){if(!this.image_)return;let o=vn(e,r,l,c,this.transform_,this.pixelCoordinates_),_=this.context_,v=this.tmpLocalTransform_,w=_.globalAlpha;this.imageOpacity_!=1&&(_.globalAlpha=w*this.imageOpacity_);let T=this.imageRotation_;this.transformRotation_===0&&(T-=this.viewRotation_),this.imageRotateWithView_&&(T+=this.viewRotation_);for(let I=0,L=o.length;I<L;I+=2){let O=o[I]-this.imageAnchorX_,U=o[I+1]-this.imageAnchorY_;if(T!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let J=O+this.imageAnchorX_,ce=U+this.imageAnchorY_;Vr(v,J,ce,1,1,T,-J,-ce),_.save(),_.transform.apply(_,v),_.translate(J,ce),_.scale(this.imageScale_[0],this.imageScale_[1]),_.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),_.restore()}else _.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,O,U,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(_.globalAlpha=w)}drawText_(e,r,l,c){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let o=vn(e,r,l,c,this.transform_,this.pixelCoordinates_),_=this.context_,v=this.textRotation_;for(this.transformRotation_===0&&(v-=this.viewRotation_),this.textRotateWithView_&&(v+=this.viewRotation_);r<l;r+=c){let w=o[r]+this.textOffsetX_,T=o[r+1]+this.textOffsetY_;v!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(_.save(),_.translate(w-this.textOffsetX_,T-this.textOffsetY_),_.rotate(v),_.translate(this.textOffsetX_,this.textOffsetY_),_.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&_.strokeText(this.text_,0,0),this.textFillState_&&_.fillText(this.text_,0,0),_.restore()):(this.textStrokeState_&&_.strokeText(this.text_,w,T),this.textFillState_&&_.fillText(this.text_,w,T))}}moveToLineTo_(e,r,l,c,o){let _=this.context_,v=vn(e,r,l,c,this.transform_,this.pixelCoordinates_);_.moveTo(v[0],v[1]);let w=v.length;o&&(w-=2);for(let T=2;T<w;T+=2)_.lineTo(v[T],v[T+1]);return o&&_.closePath(),l}drawRings_(e,r,l,c){for(let o=0,_=l.length;o<_;++o)r=this.moveToLineTo_(e,r,l[o],c,!0);return r}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Bi(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=xv(e,this.transform_,this.pixelCoordinates_),l=r[2]-r[0],c=r[3]-r[1],o=Math.sqrt(l*l+c*c),_=this.context_;_.beginPath(),_.arc(r[0],r[1],o,0,2*Math.PI),this.fillState_&&_.fill(),this.strokeState_&&_.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break;default:}}drawFeature(e,r){let l=r.getGeometryFunction()(e);l&&(this.setStyle(r),this.drawGeometry(l))}drawGeometryCollection(e){let r=e.getGeometriesArray();for(let l=0,c=r.length;l<c;++l)this.drawGeometry(r[l])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),l=e.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),l=e.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Bi(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=e.getFlatCoordinates();r.beginPath(),this.moveToLineTo_(l,0,l.length,e.getStride(),!1),r.stroke()}if(this.text_!==""){let r=e.getFlatMidpoint();this.drawText_(r,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getExtent();if(Bi(this.extent_,r)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let l=this.context_,c=e.getFlatCoordinates(),o=0,_=e.getEnds(),v=e.getStride();l.beginPath();for(let w=0,T=_.length;w<T;++w)o=this.moveToLineTo_(c,o,_[w],v,!1);l.stroke()}if(this.text_!==""){let l=e.getFlatMidpoints();this.drawText_(l,0,l.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Bi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_;r.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoint();this.drawText_(r,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Bi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=e.getOrientedFlatCoordinates(),c=0,o=e.getEndss(),_=e.getStride();r.beginPath();for(let v=0,w=o.length;v<w;++v){let T=o[v];c=this.drawRings_(l,c,T,_)}this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoints();this.drawText_(r,0,r.length,2)}}}setContextFillState_(e){let r=this.context_,l=this.contextFillState_;l?l.fillStyle!=e.fillStyle&&(l.fillStyle=e.fillStyle,r.fillStyle=e.fillStyle):(r.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let r=this.context_,l=this.contextStrokeState_;l?(l.lineCap!=e.lineCap&&(l.lineCap=e.lineCap,r.lineCap=e.lineCap),yn(l.lineDash,e.lineDash)||r.setLineDash(l.lineDash=e.lineDash),l.lineDashOffset!=e.lineDashOffset&&(l.lineDashOffset=e.lineDashOffset,r.lineDashOffset=e.lineDashOffset),l.lineJoin!=e.lineJoin&&(l.lineJoin=e.lineJoin,r.lineJoin=e.lineJoin),l.lineWidth!=e.lineWidth&&(l.lineWidth=e.lineWidth,r.lineWidth=e.lineWidth),l.miterLimit!=e.miterLimit&&(l.miterLimit=e.miterLimit,r.miterLimit=e.miterLimit),l.strokeStyle!=e.strokeStyle&&(l.strokeStyle=e.strokeStyle,r.strokeStyle=e.strokeStyle)):(r.lineCap=e.lineCap,r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset,r.lineJoin=e.lineJoin,r.lineWidth=e.lineWidth,r.miterLimit=e.miterLimit,r.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){let r=this.context_,l=this.contextTextState_,c=e.textAlign?e.textAlign:ya;l?(l.font!=e.font&&(l.font=e.font,r.font=e.font),l.textAlign!=c&&(l.textAlign=c,r.textAlign=c),l.textBaseline!=e.textBaseline&&(l.textBaseline=e.textBaseline,r.textBaseline=e.textBaseline)):(r.font=e.font,r.textAlign=c,r.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:c,textBaseline:e.textBaseline})}setFillStrokeStyle(e,r){if(!e)this.fillState_=null;else{let l=e.getColor();this.fillState_={fillStyle:Sn(l||Zi)}}if(!r)this.strokeState_=null;else{let l=r.getColor(),c=r.getLineCap(),o=r.getLineDash(),_=r.getLineDashOffset(),v=r.getLineJoin(),w=r.getWidth(),T=r.getMiterLimit(),I=o||In;this.strokeState_={lineCap:c!==void 0?c:Gs,lineDash:this.pixelRatio_===1?I:I.map(L=>L*this.pixelRatio_),lineDashOffset:(_||Cn)*this.pixelRatio_,lineJoin:v!==void 0?v:Us,lineWidth:(w!==void 0?w:wo)*this.pixelRatio_,miterLimit:T!==void 0?T:xo,strokeStyle:Sn(l||vo)}}}setImageStyle(e){let r;if(!e||!(r=e.getSize())){this.image_=null;return}let l=e.getPixelRatio(this.pixelRatio_),c=e.getAnchor(),o=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=c[0]*l,this.imageAnchorY_=c[1]*l,this.imageHeight_=r[1]*l,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=o[0],this.imageOriginY_=o[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let _=e.getScaleArray();this.imageScale_=[_[0]*this.pixelRatio_/l,_[1]*this.pixelRatio_/l],this.imageWidth_=r[0]*l}setTextStyle(e){if(!e)this.text_="";else{let r=e.getFill();if(!r)this.textFillState_=null;else{let U=r.getColor();this.textFillState_={fillStyle:Sn(U||Zi)}}let l=e.getStroke();if(!l)this.textStrokeState_=null;else{let U=l.getColor(),J=l.getLineCap(),ce=l.getLineDash(),he=l.getLineDashOffset(),me=l.getLineJoin(),ve=l.getWidth(),we=l.getMiterLimit();this.textStrokeState_={lineCap:J!==void 0?J:Gs,lineDash:ce||In,lineDashOffset:he||Cn,lineJoin:me!==void 0?me:Us,lineWidth:ve!==void 0?ve:wo,miterLimit:we!==void 0?we:xo,strokeStyle:Sn(U||vo)}}let c=e.getFont(),o=e.getOffsetX(),_=e.getOffsetY(),v=e.getRotateWithView(),w=e.getRotation(),T=e.getScaleArray(),I=e.getText(),L=e.getTextAlign(),O=e.getTextBaseline();this.textState_={font:c!==void 0?c:Rp,textAlign:L!==void 0?L:ya,textBaseline:O!==void 0?O:hl},this.text_=I!==void 0?Array.isArray(I)?I.reduce((U,J,ce)=>U+=ce%2?" ":J,""):I:"",this.textOffsetX_=o!==void 0?this.pixelRatio_*o:0,this.textOffsetY_=_!==void 0?this.pixelRatio_*_:0,this.textRotateWithView_=v!==void 0?v:!1,this.textRotation_=w!==void 0?w:0,this.textScale_=[this.pixelRatio_*T[0],this.pixelRatio_*T[1]]}}},qb=qy;var Cs=.5;function $b(h,e,r,l,c,o,_,v,w){let T=w?Os(c,w):c,I=h[0]*Cs,L=h[1]*Cs,O=Ai(I,L);O.imageSmoothingEnabled=!1;let U=O.canvas,J=new qb(O,Cs,c,null,_,v,w?vc(Zn(),w):null),ce=r.length,he=Math.floor((256*256*256-1)/ce),me={};for(let we=1;we<=ce;++we){let Me=r[we-1],Re=Me.getStyleFunction()||l;if(!Re)continue;let Ce=Re(Me,o);if(!Ce)continue;Array.isArray(Ce)||(Ce=[Ce]);let Ue=(we*he).toString(16).padStart(7,"#00000");for(let Ae=0,Lt=Ce.length;Ae<Lt;++Ae){let lt=Ce[Ae],it=lt.getGeometryFunction()(Me);if(!it||!Bi(T,it.getExtent()))continue;let wt=lt.clone(),zt=wt.getFill();zt&&zt.setColor(Ue);let nt=wt.getStroke();nt&&(nt.setColor(Ue),nt.setLineDash(null)),wt.setText(void 0);let ot=lt.getImage();if(ot){let Tt=ot.getImageSize();if(!Tt)continue;let Bt=Ai(Tt[0],Tt[1],void 0,{alpha:!1}),$t=Bt.canvas;Bt.fillStyle=Ue,Bt.fillRect(0,0,$t.width,$t.height),wt.setImage(new Tu({img:$t,anchor:ot.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:ot.getOrigin(),opacity:1,size:ot.getSize(),scale:ot.getScale(),rotation:ot.getRotation(),rotateWithView:ot.getRotateWithView()}))}let ut=wt.getZIndex()||0,yt=me[ut];yt||(yt={},me[ut]=yt,yt.Polygon=[],yt.Circle=[],yt.LineString=[],yt.Point=[]);let At=it.getType();if(At==="GeometryCollection"){let Tt=it.getGeometriesArrayRecursive();for(let Bt=0,$t=Tt.length;Bt<$t;++Bt){let di=Tt[Bt];yt[di.getType().replace("Multi","")].push(di,wt)}}else yt[At.replace("Multi","")].push(it,wt)}}let ve=Object.keys(me).map(Number).sort(gs);for(let we=0,Me=ve.length;we<Me;++we){let Re=me[ve[we]];for(let Ce in Re){let Le=Re[Ce];for(let Ue=0,Ae=Le.length;Ue<Ae;Ue+=2){J.setStyle(Le[Ue+1]);for(let Lt=0,lt=e.length;Lt<lt;++Lt)J.setTransform(e[Lt]),J.drawGeometry(Le[Ue])}}}return O.getImageData(0,0,U.width,U.height)}function Wb(h,e,r){let l=[];if(r){let c=Math.floor(Math.round(h[0])*Cs),o=Math.floor(Math.round(h[1])*Cs),_=(Ii(c,0,r.width-1)+Ii(o,0,r.height-1)*r.width)*4,v=r.data[_],w=r.data[_+1],I=r.data[_+2]+256*(w+256*v),L=Math.floor((256*256*256-1)/e.length);I&&I%L===0&&l.push(e[I/L-1])}return l}var oC=.5,Zb={Point:pC,LineString:hC,Polygon:mC,MultiPoint:fC,MultiLineString:uC,MultiPolygon:dC,GeometryCollection:cC,Circle:aC};function Xb(h,e){return parseInt(Vt(h),10)-parseInt(Vt(e),10)}function $y(h,e){let r=Wy(h,e);return r*r}function Wy(h,e){return oC*h/e}function aC(h,e,r,l,c){let o=r.getFill(),_=r.getStroke();if(o||_){let w=h.getBuilder(r.getZIndex(),"Circle");w.setFillStrokeStyle(o,_),w.drawCircle(e,l,c)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l)}}function Zy(h,e,r,l,c,o,_,v){let w=[],T=r.getImage();if(T){let O=!0,U=T.getImageState();U==St.LOADED||U==St.ERROR?O=!1:U==St.IDLE&&T.load(),O&&w.push(T.ready())}let I=r.getFill();I&&I.loading()&&w.push(I.ready());let L=w.length>0;return L&&Promise.all(w).then(()=>c(null)),lC(h,e,r,l,o,_,v),L}function lC(h,e,r,l,c,o,_){let v=r.getGeometryFunction()(e);if(!v)return;let w=v.simplifyTransformed(l,c);if(r.getRenderer())Hb(h,w,r,e,_);else{let I=Zb[w.getType()];I(h,w,r,e,_,o)}}function Hb(h,e,r,l,c){if(e.getType()=="GeometryCollection"){let _=e.getGeometries();for(let v=0,w=_.length;v<w;++v)Hb(h,_[v],r,l,c);return}h.getBuilder(r.getZIndex(),"Default").drawCustom(e,l,r.getRenderer(),r.getHitDetectionRenderer(),c)}function cC(h,e,r,l,c,o){let _=e.getGeometriesArray(),v,w;for(v=0,w=_.length;v<w;++v){let T=Zb[_[v].getType()];T(h,_[v],r,l,c,o)}}function hC(h,e,r,l,c){let o=r.getStroke();if(o){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,o),v.drawLineString(e,l,c)}let _=r.getText();if(_&&_.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(_),v.drawText(e,l,c)}}function uC(h,e,r,l,c){let o=r.getStroke();if(o){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,o),v.drawMultiLineString(e,l,c)}let _=r.getText();if(_&&_.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(_),v.drawText(e,l,c)}}function dC(h,e,r,l,c){let o=r.getFill(),_=r.getStroke();if(_||o){let w=h.getBuilder(r.getZIndex(),"Polygon");w.setFillStrokeStyle(o,_),w.drawMultiPolygon(e,l,c)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l,c)}}function pC(h,e,r,l,c,o){let _=r.getImage(),v=r.getText(),w=v&&v.getText(),T=o&&_&&w?{}:void 0;if(_){if(_.getImageState()!=St.LOADED)return;let I=h.getBuilder(r.getZIndex(),"Image");I.setImageStyle(_,T),I.drawPoint(e,l,c)}if(w){let I=h.getBuilder(r.getZIndex(),"Text");I.setTextStyle(v,T),I.drawText(e,l,c)}}function fC(h,e,r,l,c,o){let _=r.getImage(),v=_&&_.getOpacity()!==0,w=r.getText(),T=w&&w.getText(),I=o&&v&&T?{}:void 0;if(v){if(_.getImageState()!=St.LOADED)return;let L=h.getBuilder(r.getZIndex(),"Image");L.setImageStyle(_,I),L.drawMultiPoint(e,l,c)}if(T){let L=h.getBuilder(r.getZIndex(),"Text");L.setTextStyle(w,I),L.drawText(e,l,c)}}function mC(h,e,r,l,c){let o=r.getFill(),_=r.getStroke();if(o||_){let w=h.getBuilder(r.getZIndex(),"Polygon");w.setFillStrokeStyle(o,_),w.drawPolygon(e,l,c)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l,c)}}var Xy=class extends Up{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=xn(),this.wrappedRenderedExtent_=xn(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(e,r,l){let c=r.extent,o=r.viewState,_=o.center,v=o.resolution,w=o.projection,T=o.rotation,I=w.getExtent(),L=this.getLayer().getSource(),O=this.getLayer().getDeclutter(),U=r.pixelRatio,J=r.viewHints,ce=!(J[bn.ANIMATING]||J[bn.INTERACTING]),he=this.context,me=Math.round(_i(c)/v*U),ve=Math.round($i(c)/v*U),we=L.getWrapX()&&w.canWrapX(),Me=we?_i(I):null,Re=we?Math.ceil((c[2]-I[2])/Me)+1:1,Ce=we?Math.floor((c[0]-I[0])/Me):0;do{let Le=this.getRenderTransform(_,v,0,U,me,ve,Ce*Me);r.declutter&&(Le=Le.slice(0)),e.execute(he,[he.canvas.width,he.canvas.height],Le,T,ce,l===void 0?pl:l?Uy:Gb,l?O&&r.declutter[O]:void 0)}while(++Ce<Re)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Ai(this.context.canvas.width,this.context.canvas.height,By))}resetDrawContext_(){if(this.opacity_!==1){let e=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=e,sb(this.context),By.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(e){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,e,!0)}renderDeferredInternal(e){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(e,r){let l=e.layerStatesArray[e.layerIndex];this.opacity_=l.opacity;let c=e.viewState;this.prepareContainer(e,r);let o=this.context,_=this.replayGroup_,v=_&&!_.isEmpty();if(!v&&!(this.getLayer().hasListener(Ns.PRERENDER)||this.getLayer().hasListener(Ns.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(o,e);let w=c.projection;if(this.clipped_=!1,v&&l.extent&&this.clipping){let T=Bs(l.extent,w);v=Bi(T,e.extent),this.clipped_=v&&!fo(T,e.extent),this.clipped_&&this.clipUnrotated(o,e,T)}return v&&this.renderWorlds(_,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&o.restore(),this.postRender(o,e),this.renderedRotation_!==c.rotation&&(this.renderedRotation_=c.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(r=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let l=this.frameState.size.slice(),c=this.renderedCenter_,o=this.renderedResolution_,_=this.renderedRotation_,v=this.renderedProjection_,w=this.wrappedRenderedExtent_,T=this.getLayer(),I=[],L=l[0]*Cs,O=l[1]*Cs;I.push(this.getRenderTransform(c,o,_,Cs,L,O,0).slice());let U=T.getSource(),J=v.getExtent();if(U.getWrapX()&&v.canWrapX()&&!fo(J,w)){let he=w[0],me=_i(J),ve=0,we;for(;he<J[0];)--ve,we=me*ve,I.push(this.getRenderTransform(c,o,_,Cs,L,O,we).slice()),he+=me;for(ve=0,he=w[2];he>J[2];)++ve,we=me*ve,I.push(this.getRenderTransform(c,o,_,Cs,L,O,we).slice()),he-=me}let ce=Zn();this.hitDetectionImageData_=$b(l,I,this.renderedFeatures_,T.getStyleFunction(),w,o,_,$y(o,this.renderedPixelRatio_),ce?v:null)}r(Wb(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,r,l,c,o){if(!this.replayGroup_)return;let _=r.viewState.resolution,v=r.viewState.rotation,w=this.getLayer(),T={},I=function(J,ce,he){let me=Vt(J),ve=T[me];if(ve){if(ve!==!0&&he<ve.distanceSq){if(he===0)return T[me]=!0,o.splice(o.lastIndexOf(ve),1),c(J,w,ce);ve.geometry=ce,ve.distanceSq=he}}else{if(he===0)return T[me]=!0,c(J,w,ce);o.push(T[me]={feature:J,layer:w,geometry:ce,distanceSq:he,callback:c})}},L,O=[this.replayGroup_],U=this.getLayer().getDeclutter();return O.some(J=>L=J.forEachFeatureAtCoordinate(e,_,v,l,I,U&&r.declutter[U]?r.declutter[U].all().map(ce=>ce.value):null)),L}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let r=this.getLayer(),l=r.getSource();if(!l)return!1;let c=e.viewHints[bn.ANIMATING],o=e.viewHints[bn.INTERACTING],_=r.getUpdateWhileAnimating(),v=r.getUpdateWhileInteracting();if(this.ready&&!_&&c||!v&&o)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let w=e.extent,T=e.viewState,I=T.projection,L=T.resolution,O=e.pixelRatio,U=r.getRevision(),J=r.getRenderBuffer(),ce=r.getRenderOrder();ce===void 0&&(ce=Xb);let he=T.center.slice(),me=ns(w,J*L),ve=me.slice(),we=[me.slice()],Me=I.getExtent();if(l.getWrapX()&&I.canWrapX()&&!fo(Me,e.extent)){let nt=_i(Me),ot=Math.max(_i(me)/2,nt);me[0]=Me[0]-ot,me[2]=Me[2]+ot,lv(he,I);let ut=Km(we[0],I);ut[0]<Me[0]&&ut[2]<Me[2]?we.push([ut[0]+nt,ut[1],ut[2]+nt,ut[3]]):ut[0]>Me[0]&&ut[2]>Me[2]&&we.push([ut[0]-nt,ut[1],ut[2]-nt,ut[3]])}if(this.ready&&this.renderedResolution_==L&&this.renderedRevision_==U&&this.renderedRenderOrder_==ce&&this.renderedFrameDeclutter_===!!e.declutter&&fo(this.wrappedRenderedExtent_,me))return yn(this.renderedExtent_,ve)||(this.hitDetectionImageData_=null,this.renderedExtent_=ve),this.renderedCenter_=he,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let Re=new zb(Wy(L,O),me,L,O),Ce=Zn(),Le;if(Ce){for(let nt=0,ot=we.length;nt<ot;++nt){let ut=we[nt],yt=Os(ut,I);l.loadFeatures(yt,fv(L,I),Ce)}Le=vc(Ce,I)}else for(let nt=0,ot=we.length;nt<ot;++nt)l.loadFeatures(we[nt],L,I);let Ue=$y(L,O),Ae=!0,Lt=(nt,ot)=>{let ut,yt=nt.getStyleFunction()||r.getStyleFunction();if(yt&&(ut=yt(nt,L)),ut){let At=this.renderFeature(nt,Ue,ut,Re,Le,this.getLayer().getDeclutter(),ot);Ae=Ae&&!At}},lt=Os(me,I),it=l.getFeaturesInExtent(lt);ce&&it.sort(ce);for(let nt=0,ot=it.length;nt<ot;++nt)Lt(it[nt],nt);this.renderedFeatures_=it,this.ready=Ae;let wt=Re.finish(),zt=new Ub(me,L,O,l.getOverlaps(),wt,r.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=L,this.renderedRevision_=U,this.renderedRenderOrder_=ce,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=ve,this.wrappedRenderedExtent_=me,this.renderedCenter_=he,this.renderedProjection_=I,this.renderedPixelRatio_=O,this.replayGroup_=zt,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,r,l,c,o,_,v){if(!l)return!1;let w=!1;if(Array.isArray(l))for(let T=0,I=l.length;T<I;++T)w=Zy(c,e,l[T],r,this.boundHandleStyleImageChange_,o,_,v)||w;else w=Zy(c,e,l,r,this.boundHandleStyleImageChange_,o,_,v);return w}},Yb=Xy;var Hy=class extends Pb{constructor(e){super(e)}createRenderer(){return new Yb(this)}},fl=Hy;var Yy=class{constructor(e){this.rbush_=new ul(e),this.items_={}}insert(e,r){let l={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:r};this.rbush_.insert(l),this.items_[Vt(r)]=l}load(e,r){let l=new Array(r.length);for(let c=0,o=r.length;c<o;c++){let _=e[c],v=r[c],w={minX:_[0],minY:_[1],maxX:_[2],maxY:_[3],value:v};l[c]=w,this.items_[Vt(v)]=w}this.rbush_.load(l)}remove(e){let r=Vt(e),l=this.items_[r];return delete this.items_[r],this.rbush_.remove(l)!==null}update(e,r){let l=this.items_[Vt(r)],c=[l.minX,l.minY,l.maxX,l.maxY];ap(c,e)||(this.remove(r),this.insert(e,r))}getAll(){return this.rbush_.all().map(function(r){return r.value})}getInExtent(e){let r={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(r).map(function(c){return c.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,r){return this.forEach_(this.getInExtent(e),r)}forEach_(e,r){let l;for(let c=0,o=e.length;c<o;c++)if(l=r(e[c]),l)return l;return l}isEmpty(){return Wn(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let r=this.rbush_.toJSON();return mo(r.minX,r.minY,r.maxX,r.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(let r in e.items_)this.items_[r]=e.items_[r]}},Nu=Yy;var Kb=nr(),Vu=class h{constructor(e,r,l,c,o,_){this.styleFunction,this.extent_,this.id_=_,this.type_=e,this.flatCoordinates_=r,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=l||null,this.properties_=o,this.squaredTolerance_,this.stride_=c,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?la(this.flatCoordinates_):gc(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=ss(this.getExtent());this.flatInteriorPoints_=uu(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=kv(this.flatCoordinates_,this.ends_),r=bp(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=xp(this.flatCoordinates_,0,e,2,r)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=ll(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let e=this.flatCoordinates_,r=0,l=this.ends_;for(let c=0,o=l.length;c<o;++c){let _=l[c],v=ll(e,r,_,2,.5);br(this.flatMidpoints_,v),r=_}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,r){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(e){e=ki(e);let r=e.getExtent(),l=e.getWorldExtent();if(r&&l){let c=$i(l)/$i(r);Vr(Kb,l[0],l[3],c,-c,0,0,0),vn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,Kb,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new h(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=ip((e,r)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),r&&this.simplifiedGeometry_.applyTransform(r);let l=this.simplifiedGeometry_.getFlatCoordinates(),c;switch(this.type_){case"LineString":l.length=al(l,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,l,0),c=[l.length];break;case"MultiLineString":c=[],l.length=mp(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,l,0,c);break;case"Polygon":c=[],l.length=ou(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),l,0,c);break;default:}return c&&(this.simplifiedGeometry_=new h(this.type_,l,c,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};Vu.prototype.getFlatCoordinates=Vu.prototype.getOrientedFlatCoordinates;var Es=Vu;var Ky=class extends sr{constructor(e){super(),this.projection=ki(e.projection),this.attributions_=Jb(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible??!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;let r=this;this.viewPromise_=new Promise(function(l,c){r.viewResolver=l,r.viewRejector=c})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=Jb(e),this.changed()}setState(e){this.state_=e,this.changed()}};function Jb(h){return h?typeof h=="function"?h:(Array.isArray(h)||(h=[h]),e=>h):null}var To=Ky;var Ur={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function Qb(h,e){return[[-1/0,-1/0,1/0,1/0]]}var gC=!1;function yC(h,e,r,l,c,o,_){let v=new XMLHttpRequest;v.open("GET",typeof h=="function"?h(r,l,c):h,!0),e.getType()=="arraybuffer"&&(v.responseType="arraybuffer"),v.withCredentials=gC,v.onload=function(w){if(!v.status||v.status>=200&&v.status<300){let T=e.getType();try{let I;T=="text"||T=="json"?I=v.responseText:T=="xml"?I=v.responseXML||v.responseText:T=="arraybuffer"&&(I=v.response),I?o(e.readFeatures(I,{extent:r,featureProjection:c}),e.readProjection(I)):_()}catch{_()}}else _()},v.onerror=_,v.send()}function Jy(h,e){return function(r,l,c,o,_){let v=this;yC(h,e,r,l,c,function(w,T){v.addFeatures(w),o!==void 0&&o(w)},_||ys)}}var Zs=class extends Si{constructor(e,r,l){super(e),this.feature=r,this.features=l}},Qy=class extends To{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=ys,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(hi(this.format_,"`format` must be set when `url` is set"),this.loader_=Jy(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:Qb;let r=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=r?new Nu:null,this.loadedExtentsRtree_=new Nu,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let l,c;Array.isArray(e.features)?c=e.features:e.features&&(l=e.features,c=l.getArray()),!r&&l===void 0&&(l=new xu(c)),c!==void 0&&this.addFeaturesInternal(c),l!==void 0&&this.bindFeaturesCollection_(l)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let r=Vt(e);if(!this.addToIndex_(r,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(r,e);let l=e.getGeometry();if(l){let c=l.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(c,e)}else this.nullGeometryFeatures_[r]=e;this.dispatchEvent(new Zs(Ur.ADDFEATURE,e))}setupChangeEvents_(e,r){r instanceof Es||(this.featureChangeKeys_[e]=[wr(r,ui.CHANGE,this.handleFeatureChange_,this),wr(r,Qd.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,r){let l=!0;if(r.getId()!==void 0){let c=String(r.getId());if(!(c in this.idIndex_))this.idIndex_[c]=r;else if(r instanceof Es){let o=this.idIndex_[c];o instanceof Es?Array.isArray(o)?o.push(r):this.idIndex_[c]=[o,r]:l=!1}else l=!1}return l&&(hi(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=r),l}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let r=[],l=[],c=[];for(let o=0,_=e.length;o<_;o++){let v=e[o],w=Vt(v);this.addToIndex_(w,v)&&l.push(v)}for(let o=0,_=l.length;o<_;o++){let v=l[o],w=Vt(v);this.setupChangeEvents_(w,v);let T=v.getGeometry();if(T){let I=T.getExtent();r.push(I),c.push(v)}else this.nullGeometryFeatures_[w]=v}if(this.featuresRtree_&&this.featuresRtree_.load(r,c),this.hasListener(Ur.ADDFEATURE))for(let o=0,_=l.length;o<_;o++)this.dispatchEvent(new Zs(Ur.ADDFEATURE,l[o]))}bindFeaturesCollection_(e){let r=!1;this.addEventListener(Ur.ADDFEATURE,function(l){r||(r=!0,e.push(l.feature),r=!1)}),this.addEventListener(Ur.REMOVEFEATURE,function(l){r||(r=!0,e.remove(l.feature),r=!1)}),e.addEventListener(Ss.ADD,l=>{r||(r=!0,this.addFeature(l.element),r=!1)}),e.addEventListener(Ss.REMOVE,l=>{r||(r=!0,this.removeFeature(l.element),r=!1)}),this.featuresCollection_=e}clear(e){if(e){for(let l in this.featureChangeKeys_)this.featureChangeKeys_[l].forEach(jr);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){let l=c=>{this.removeFeatureInternal(c)};this.featuresRtree_.forEach(l);for(let c in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[c])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let r=new Zs(Ur.CLEAR);this.dispatchEvent(r),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,r){let l=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(l,function(c){let o=c.getGeometry();if(o instanceof Es||o.intersectsCoordinate(e))return r(c)})}forEachFeatureInExtent(e,r){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,r);this.featuresCollection_&&this.featuresCollection_.forEach(r)}forEachFeatureIntersectingExtent(e,r){return this.forEachFeatureInExtent(e,function(l){let c=l.getGeometry();if(c instanceof Es||c.intersectsExtent(e)){let o=r(l);if(o)return o}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),Wn(this.nullGeometryFeatures_)||br(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let r=[];return this.forEachFeatureAtCoordinateDirect(e,function(l){r.push(l)}),r}getFeaturesInExtent(e,r){if(this.featuresRtree_){if(!(r&&r.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let c=Xx(e,r);return[].concat(...c.map(o=>this.featuresRtree_.getInExtent(o)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,r){let l=e[0],c=e[1],o=null,_=[NaN,NaN],v=1/0,w=[-1/0,-1/0,1/0,1/0];return r=r||tp,this.featuresRtree_.forEachInExtent(w,function(T){if(r(T)){let I=T.getGeometry(),L=v;if(v=I instanceof Es?0:I.closestPointXY(l,c,_,v),v<L){o=T;let O=Math.sqrt(v);w[0]=l-O,w[1]=c-O,w[2]=l+O,w[3]=c+O}}}),o}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){let r=this.idIndex_[e.toString()];return r!==void 0?r:null}getFeatureByUid(e){let r=this.uidIndex_[e];return r!==void 0?r:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){let r=e.target,l=Vt(r),c=r.getGeometry();if(!c)l in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(r),this.nullGeometryFeatures_[l]=r);else{let _=c.getExtent();l in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[l],this.featuresRtree_&&this.featuresRtree_.insert(_,r)):this.featuresRtree_&&this.featuresRtree_.update(_,r)}let o=r.getId();if(o!==void 0){let _=o.toString();this.idIndex_[_]!==r&&(this.removeFromIdIndex_(r),this.idIndex_[_]=r)}else this.removeFromIdIndex_(r),this.uidIndex_[l]=r;this.changed(),this.dispatchEvent(new Zs(Ur.CHANGEFEATURE,r))}hasFeature(e){let r=e.getId();return r!==void 0?r in this.idIndex_:Vt(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Wn(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,r,l){let c=this.loadedExtentsRtree_,o=this.strategy_(e,r,l);for(let _=0,v=o.length;_<v;++_){let w=o[_];c.forEachInExtent(w,function(I){return fo(I.extent,w)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Zs(Ur.FEATURESLOADSTART)),this.loader_.call(this,w,r,l,I=>{--this.loadingExtentsCount_,this.dispatchEvent(new Zs(Ur.FEATURESLOADEND,void 0,I))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Zs(Ur.FEATURESLOADERROR))}),c.insert(w,{extent:w.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){let r=this.loadedExtentsRtree_,l;r.forEachInExtent(e,function(c){if(ap(c.extent,e))return l=c,!0}),l&&r.remove(l)}removeFeatures(e){let r=!1;for(let l=0,c=e.length;l<c;++l)r=this.removeFeatureInternal(e[l])||r;r&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){let r=Vt(e);if(!(r in this.uidIndex_))return!1;r in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[r]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[r]?.forEach(jr),delete this.featureChangeKeys_[r];let c=e.getId();if(c!==void 0){let o=c.toString(),_=this.idIndex_[o];_===e?delete this.idIndex_[o]:Array.isArray(_)&&(_.splice(_.indexOf(e),1),_.length===1&&(this.idIndex_[o]=_[0]))}return delete this.uidIndex_[r],this.hasListener(Ur.REMOVEFEATURE)&&this.dispatchEvent(new Zs(Ur.REMOVEFEATURE,e)),!0}removeFromIdIndex_(e){for(let r in this.idIndex_)if(this.idIndex_[r]===e){delete this.idIndex_[r];break}}setLoader(e){this.loader_=e}setUrl(e){hi(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(Jy(e,this.format_))}},ml=Qy;var Hn={SINGLECLICK:"singleclick",CLICK:ui.CLICK,DBLCLICK:ui.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var e_={ACTIVE:"active"};var t_=class extends sr{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(e_.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(e_.ACTIVE,e)}setMap(e){this.map_=e}};var e1=t_;var i_=class extends e1{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let r=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==Hn.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==Hn.POINTERUP){let l=this.handleUpEvent(e);this.handlingDownUpSequence=l&&this.targetPointers.length>0}}else if(e.type==Hn.POINTERDOWN){let l=this.handleDownEvent(e);this.handlingDownUpSequence=l,r=this.stopDown(l)}else e.type==Hn.POINTERMOVE&&this.handleMoveEvent(e);return!r}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};var t1=i_;var i1=function(h){let e=h.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var r1=tp,n1=function(h){return h.type==Hn.CLICK};var s1=function(h){return h.type==Hn.SINGLECLICK};var o1=function(h){let e=h.originalEvent;return hi(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var r_=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=ls,this.supportedMediaTypes=null}getReadOptions(e,r){if(r){let l=r.dataProjection?ki(r.dataProjection):this.readProjection(e);r.extent&&l&&l.getUnits()==="tile-pixels"&&(l=ki(l),l.setWorldExtent(r.extent)),r={dataProjection:l,featureProjection:r.featureProjection}}return this.adaptOptions(r)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return xt()}readFeature(e,r){return xt()}readFeatures(e,r){return xt()}readGeometry(e,r){return xt()}readProjection(e){return xt()}writeFeature(e,r){return xt()}writeFeatures(e,r){return xt()}writeGeometry(e,r){return xt()}},a1=r_;function qp(h,e,r){let l=r?ki(r.featureProjection):null,c=r?ki(r.dataProjection):null,o=h;if(l&&c&&!pv(l,c)){e&&(o=h.clone());let _=e?l:c,v=e?c:l;_.getUnits()==="tile-pixels"?o.transform(_,v):o.applyTransform(nl(_,v))}if(e&&r&&r.decimals!==void 0){let _=Math.pow(10,r.decimals),v=function(w){for(let T=0,I=w.length;T<I;++T)w[T]=Math.round(w[T]*_)/_;return w};o===h&&(o=h.clone()),o.applyTransform(v)}return o}var _C={Point:ar,LineString:vs,Polygon:wc,MultiPoint:hu,MultiLineString:vg,MultiPolygon:Tg};function xC(h,e,r){return Array.isArray(e[0])?(vp(h,0,e,r)||(h=h.slice(),pu(h,0,e,r)),h):(du(h,0,e,r)||(h=h.slice(),bc(h,0,e,r)),h)}function n_(h,e){let r=h.geometry;if(!r)return[];if(Array.isArray(r))return r.map(o=>n_({...h,geometry:o})).flat();let l=r.type==="MultiPolygon"?"Polygon":r.type;if(l==="GeometryCollection"||l==="Circle")throw new Error("Unsupported geometry type: "+l);let c=r.layout.length;return qp(new Es(l,l==="Polygon"?xC(r.flatCoordinates,r.ends,c):r.flatCoordinates,r.ends?.flat(),c,h.properties||{},h.id).enableSimplifyTransformed(),!1,e)}function $p(h,e){if(!h)return null;if(Array.isArray(h)){let l=h.map(c=>$p(c,e));return new dg(l)}let r=_C[h.type];return qp(new r(h.flatCoordinates,h.layout,h.ends),!1,e)}var s_=class extends a1{constructor(){super()}getType(){return"json"}readFeature(e,r){return this.readFeatureFromObject(Wp(e),this.getReadOptions(e,r))}readFeatures(e,r){return this.readFeaturesFromObject(Wp(e),this.getReadOptions(e,r))}readFeatureFromObject(e,r){return xt()}readFeaturesFromObject(e,r){return xt()}readGeometry(e,r){return this.readGeometryFromObject(Wp(e),this.getReadOptions(e,r))}readGeometryFromObject(e,r){return xt()}readProjection(e){return this.readProjectionFromObject(Wp(e))}readProjectionFromObject(e){return xt()}writeFeature(e,r){return JSON.stringify(this.writeFeatureObject(e,r))}writeFeatureObject(e,r){return xt()}writeFeatures(e,r){return JSON.stringify(this.writeFeaturesObject(e,r))}writeFeaturesObject(e,r){return xt()}writeGeometry(e,r){return JSON.stringify(this.writeGeometryObject(e,r))}writeGeometryObject(e,r){return xt()}};function Wp(h){if(typeof h=="string"){let e=JSON.parse(h);return e||null}return h!==null?h:null}var l1=s_;var o_=class extends l1{constructor(e){e=e||{},super(),this.dataProjection=ki(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=ki(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,r){let l=null;e.type==="Feature"?l=e:l={type:"Feature",geometry:e,properties:null};let c=l_(l.geometry,r);if(this.featureClass===Es)return n_({geometry:c,id:l.id,properties:l.properties},r);let o=new ls;return this.geometryName_?o.setGeometryName(this.geometryName_):this.extractGeometryName_&&l.geometry_name&&o.setGeometryName(l.geometry_name),o.setGeometry($p(c,r)),"id"in l&&o.setId(l.id),l.properties&&o.setProperties(l.properties,!0),o}readFeaturesFromObject(e,r){let l=e,c=null;if(l.type==="FeatureCollection"){let o=e;c=[];let _=o.features;for(let v=0,w=_.length;v<w;++v){let T=this.readFeatureFromObject(_[v],r);T&&c.push(T)}}else c=[this.readFeatureFromObject(e,r)];return c.flat()}readGeometryFromObject(e,r){return vC(e,r)}readProjectionFromObject(e){let r=e.crs,l;if(r)if(r.type=="name")l=ki(r.properties.name);else if(r.type==="EPSG")l=ki("EPSG:"+r.properties.code);else throw new Error("Unknown SRS type");else l=this.dataProjection;return l}writeFeatureObject(e,r){r=this.adaptOptions(r);let l={type:"Feature",geometry:null,properties:null},c=e.getId();if(c!==void 0&&(l.id=c),!e.hasProperties())return l;let o=e.getProperties(),_=e.getGeometry();return _&&(l.geometry=a_(_,r),delete o[e.getGeometryName()]),Wn(o)||(l.properties=o),l}writeFeaturesObject(e,r){r=this.adaptOptions(r);let l=[];for(let c=0,o=e.length;c<o;++c)l.push(this.writeFeatureObject(e[c],r));return{type:"FeatureCollection",features:l}}writeGeometryObject(e,r){return a_(e,this.adaptOptions(r))}};function l_(h,e){if(!h)return null;let r;switch(h.type){case"Point":{r=wC(h);break}case"LineString":{r=SC(h);break}case"Polygon":{r=TC(h);break}case"MultiPoint":{r=CC(h);break}case"MultiLineString":{r=IC(h);break}case"MultiPolygon":{r=EC(h);break}case"GeometryCollection":{r=bC(h);break}default:throw new Error("Unsupported GeoJSON type: "+h.type)}return r}function vC(h,e){let r=l_(h,e);return $p(r,e)}function bC(h,e){return h.geometries.map(function(l){return l_(l,e)})}function wC(h){let e=h.coordinates;return{type:"Point",flatCoordinates:e,layout:ha(e.length)}}function SC(h){let e=h.coordinates,r=e.flat();return{type:"LineString",flatCoordinates:r,ends:[r.length],layout:ha(e[0]?.length||2)}}function IC(h){let e=h.coordinates,r=e[0]?.[0]?.length||2,l=[],c=ua(l,0,e,r);return{type:"MultiLineString",flatCoordinates:l,ends:c,layout:ha(r)}}function CC(h){let e=h.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:ha(e[0]?.length||2)}}function EC(h){let e=h.coordinates,r=[],l=e[0]?.[0]?.[0].length||2,c=fp(r,0,e,l);return{type:"MultiPolygon",flatCoordinates:r,ends:c,layout:ha(l)}}function TC(h){let e=h.coordinates,r=[],l=e[0]?.[0]?.length,c=ua(r,0,e,l);return{type:"Polygon",flatCoordinates:r,ends:c,layout:ha(l)}}function a_(h,e){h=qp(h,!0,e);let r=h.getType(),l;switch(r){case"Point":{l=LC(h,e);break}case"LineString":{l=AC(h,e);break}case"Polygon":{l=DC(h,e);break}case"MultiPoint":{l=RC(h,e);break}case"MultiLineString":{l=PC(h,e);break}case"MultiPolygon":{l=kC(h,e);break}case"GeometryCollection":{l=MC(h,e);break}case"Circle":{l={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+r)}return l}function MC(h,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:h.getGeometriesArray().map(function(l){return a_(l,e)})}}function AC(h,e){return{type:"LineString",coordinates:h.getCoordinates()}}function PC(h,e){return{type:"MultiLineString",coordinates:h.getCoordinates()}}function RC(h,e){return{type:"MultiPoint",coordinates:h.getCoordinates()}}function kC(h,e){let r;return e&&(r=e.rightHanded),{type:"MultiPolygon",coordinates:h.getCoordinates(r)}}function LC(h,e){return{type:"Point",coordinates:h.getCoordinates()}}function DC(h,e){let r;return e&&(r=e.rightHanded),{type:"Polygon",coordinates:h.getCoordinates(r)}}var cr=o_;var c1=0,ju=1,h1=[0,0,0,0],Fc=[],c_={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},Gu=class extends Si{constructor(e,r,l){super(e),this.features=r,this.mapBrowserEvent=l}},h_=class extends t1{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:o1,this.defaultDeleteCondition_=function(l){return i1(l)&&s1(l)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:r1,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Nu,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new fl({source:new ml({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:zC(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let r;if(e.features?r=e.features:e.source&&(this.source_=e.source,r=new xu(this.source_.getFeatures()),this.source_.addEventListener(Ur.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Ur.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!r)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=r,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Ss.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Ss.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}addFeature_(e){let r=e.getGeometry();if(r){let c=this.SEGMENT_WRITERS_[r.getType()];c&&c(e,r)}let l=this.getMap();l&&l.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastPixel_,l),e.addEventListener(ui.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,r){if(!this.featuresBeingModified_){this.featuresBeingModified_=new xu;let l=this.featuresBeingModified_.getArray();for(let c=0,o=r.length;c<o;++c){let _=r[c];for(let v=0,w=_.length;v<w;++v){let T=_[v].feature;T&&!l.includes(T)&&this.featuresBeingModified_.push(T)}}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new Gu(c_.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(ui.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){let r=this.rBush_,l=[];r.forEach(function(c){e===c.feature&&l.push(c)});for(let c=l.length-1;c>=0;--c){let o=l[c];for(let _=this.dragSegments_.length-1;_>=0;--_)this.dragSegments_[_][0]===o&&this.dragSegments_.splice(_,1);r.remove(o)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){let r=e.target;this.removeFeature_(r),this.addFeature_(r)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,r){let l=r.getCoordinates(),c={feature:e,geometry:r,segment:[l,l]};this.rBush_.insert(r.getExtent(),c)}writeMultiPointGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length;c<o;++c){let _=l[c],v={feature:e,geometry:r,depth:[c],index:c,segment:[_,_]};this.rBush_.insert(r.getExtent(),v)}}writeLineStringGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length-1;c<o;++c){let _=l.slice(c,c+2),v={feature:e,geometry:r,index:c,segment:_};this.rBush_.insert(zs(_),v)}}writeMultiLineStringGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length;c<o;++c){let _=l[c];for(let v=0,w=_.length-1;v<w;++v){let T=_.slice(v,v+2),I={feature:e,geometry:r,depth:[c],index:v,segment:T};this.rBush_.insert(zs(T),I)}}}writePolygonGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length;c<o;++c){let _=l[c];for(let v=0,w=_.length-1;v<w;++v){let T=_.slice(v,v+2),I={feature:e,geometry:r,depth:[c],index:v,segment:T};this.rBush_.insert(zs(T),I)}}}writeMultiPolygonGeometry_(e,r){let l=r.getCoordinates();for(let c=0,o=l.length;c<o;++c){let _=l[c];for(let v=0,w=_.length;v<w;++v){let T=_[v];for(let I=0,L=T.length-1;I<L;++I){let O=T.slice(I,I+2),U={feature:e,geometry:r,depth:[v,c],index:I,segment:O};this.rBush_.insert(zs(O),U)}}}}writeCircleGeometry_(e,r){let l=r.getCenter(),c={feature:e,geometry:r,index:c1,segment:[l,l]},o={feature:e,geometry:r,index:ju,segment:[l,l]},_=[c,o];c.featureSegments=_,o.featureSegments=_,this.rBush_.insert(la(l),c);let v=r,w=Zn();if(w&&this.getMap()){let T=this.getMap().getView().getProjection();v=v.clone().transform(w,T),v=Cg(v).transform(T,w)}this.rBush_.insert(v.getExtent(),o)}writeGeometryCollectionGeometry_(e,r){let l=r.getGeometriesArray();for(let c=0;c<l.length;++c){let o=l[c],_=this.SEGMENT_WRITERS_[o.getType()];_(e,o)}}createOrUpdateVertexFeature_(e,r,l){let c=this.vertexFeature_;return c?c.getGeometry().setCoordinates(e):(c=new ls(new ar(e)),this.vertexFeature_=c,this.overlay_.getSource().addFeature(c)),c.set("features",r),c.set("geometries",l),c}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let r;return!e.map.getView().getInteracting()&&e.type==Hn.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=Hn.SINGLECLICK||!this.ignoreNextSingleClick_?r=this.removePoint():r=!0),e.type==Hn.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!r}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_);let r=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],l=[],c=[];for(let o=0,_=this.dragSegments_.length;o<_;++o){let v=this.dragSegments_[o],w=v[0],T=w.feature;l.includes(T)||l.push(T);let I=w.geometry;c.includes(I)||c.push(I);let L=w.depth,O,U=w.segment,J=v[1];for(;r.length<I.getStride();)r.push(U[J][r.length]);switch(I.getType()){case"Point":O=r,U[0]=r,U[1]=r;break;case"MultiPoint":O=I.getCoordinates(),O[w.index]=r,U[0]=r,U[1]=r;break;case"LineString":O=I.getCoordinates(),O[w.index+J]=r,U[J]=r;break;case"MultiLineString":O=I.getCoordinates(),O[L[0]][w.index+J]=r,U[J]=r;break;case"Polygon":O=I.getCoordinates(),O[L[0]][w.index+J]=r,U[J]=r;break;case"MultiPolygon":O=I.getCoordinates(),O[L[1]][L[0]][w.index+J]=r,U[J]=r;break;case"Circle":if(U[0]=r,U[1]=r,w.index===c1)this.changingFeature_=!0,I.setCenter(r),this.changingFeature_=!1;else{this.changingFeature_=!0;let ce=e.map.getView().getProjection(),he=rg(Ni(I.getCenter(),ce),Ni(r,ce)),me=Zn();if(me){let ve=I.clone().transform(me,ce);ve.setRadius(he),he=ve.transform(ce,me).getRadius()}I.setRadius(he),this.changingFeature_=!1}break;default:}O&&this.setGeometryCoordinates_(I,O)}this.createOrUpdateVertexFeature_(r,l,c)}handleDownEvent(e){if(!this.condition_(e))return!1;let r=e.coordinate;this.handlePointerAtPixel_(e.pixel,e.map,r),this.dragSegments_.length=0,this.featuresBeingModified_=null;let l=this.vertexFeature_;if(l){let c=e.map.getView().getProjection(),o=[],_=l.getGeometry().getCoordinates(),v=zs([_]),w=this.rBush_.getInExtent(v),T={};w.sort(FC);for(let I=0,L=w.length;I<L;++I){let O=w[I],U=O.segment,J=Vt(O.geometry),ce=O.depth;if(ce&&(J+="-"+ce.join("-")),T[J]||(T[J]=new Array(2)),O.geometry.getType()==="Circle"&&O.index===ju){let he=d1(r,O,c);tn(he,_)&&!T[J][0]&&(this.dragSegments_.push([O,0]),T[J][0]=O);continue}if(tn(U[0],_)&&!T[J][0]){this.dragSegments_.push([O,0]),T[J][0]=O;continue}if(tn(U[1],_)&&!T[J][1]){if(T[J][0]&&T[J][0].index===0){let he=O.geometry.getCoordinates();switch(O.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":he=he[ce[1]];case"Polygon":if(O.index!==he[ce[0]].length-2)continue;break;default:}}this.dragSegments_.push([O,1]),T[J][1]=O;continue}Vt(U)in this.vertexSegments_&&!T[J][0]&&!T[J][1]&&this.insertVertexCondition_(e)&&o.push(O)}o.length&&this.willModifyFeatures_(e,[o]);for(let I=o.length-1;I>=0;--I)this.insertVertex_(o[I],_)}return!!this.vertexFeature_}handleUpEvent(e){for(let r=this.dragSegments_.length-1;r>=0;--r){let l=this.dragSegments_[r][0],c=l.geometry;if(c.getType()==="Circle"){let o=c.getCenter(),_=l.featureSegments[0],v=l.featureSegments[1];_.segment[0]=o,_.segment[1]=o,v.segment[0]=o,v.segment[1]=o,this.rBush_.update(la(o),_);let w=c,T=Zn();if(T){let I=e.map.getView().getProjection();w=w.clone().transform(T,I),w=Cg(w).transform(I,T)}this.rBush_.update(w.getExtent(),v)}else this.rBush_.update(zs(l.segment),l)}return this.featuresBeingModified_&&(this.dispatchEvent(new Gu(c_.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastPixel_=e.pixel,this.handlePointerAtPixel_(e.pixel,e.map,e.coordinate)}handlePointerAtPixel_(e,r,l){let c=l||r.getCoordinateFromPixel(e),o=r.getView().getProjection(),_=function(T,I){return u1(c,T,o)-u1(c,I,o)},v,w;if(this.hitDetection_){let T=typeof this.hitDetection_=="object"?I=>I===this.hitDetection_:void 0;r.forEachFeatureAtPixel(e,(I,L,O)=>{O&&O.getType()==="Point"&&(O=new ar(sl(O.getCoordinates(),o)));let U=O||I.getGeometry();if(I instanceof ls&&this.features_.getArray().includes(I)){w=U;let J=I.getGeometry().getFlatCoordinates().slice(0,2);v=[{feature:I,geometry:w,segment:[J,J]}]}return!0},{layerFilter:T})}if(!v){let T=Bs(la(c,h1),o),I=r.getView().getResolution()*this.pixelTolerance_,L=Os(ns(T,I,h1),o);v=this.rBush_.getInExtent(L)}if(v&&v.length>0){let T=v.sort(_)[0],I=T.segment,L=d1(c,T,o),O=r.getPixelFromCoordinate(L),U=rg(e,O);if(w||U<=this.pixelTolerance_){let J={};if(J[Vt(I)]=!0,this.snapToPointer_||(this.delta_[0]=L[0]-c[0],this.delta_[1]=L[1]-c[1]),T.geometry.getType()==="Circle"&&T.index===ju)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(L,[T.feature],[T.geometry]);else{let ce=r.getPixelFromCoordinate(I[0]),he=r.getPixelFromCoordinate(I[1]),me=xc(O,ce),ve=xc(O,he);U=Math.sqrt(Math.min(me,ve)),this.snappedToVertex_=U<=this.pixelTolerance_,this.snappedToVertex_&&(L=me>ve?I[1]:I[0]),this.createOrUpdateVertexFeature_(L,[T.feature],[T.geometry]);let we={};we[Vt(T.geometry)]=!0;for(let Me=1,Re=v.length;Me<Re;++Me){let Ce=v[Me].segment;if(tn(I[0],Ce[0])&&tn(I[1],Ce[1])||tn(I[0],Ce[1])&&tn(I[1],Ce[0])){let Le=Vt(v[Me].geometry);Le in we||(we[Le]=!0,J[Vt(Ce)]=!0)}else break}}this.vertexSegments_=J;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,r){let l=e.segment,c=e.feature,o=e.geometry,_=e.depth,v=e.index,w;for(;r.length<o.getStride();)r.push(0);switch(o.getType()){case"MultiLineString":w=o.getCoordinates(),w[_[0]].splice(v+1,0,r);break;case"Polygon":w=o.getCoordinates(),w[_[0]].splice(v+1,0,r);break;case"MultiPolygon":w=o.getCoordinates(),w[_[1]][_[0]].splice(v+1,0,r);break;case"LineString":w=o.getCoordinates(),w.splice(v+1,0,r);break;default:return}this.setGeometryCoordinates_(o,w);let T=this.rBush_;T.remove(e),this.updateSegmentIndices_(o,v,_,1);let I={segment:[l[0],r],feature:c,geometry:o,depth:_,index:v};T.insert(zs(I.segment),I),this.dragSegments_.push([I,1]);let L={segment:[r,l[1]],feature:c,geometry:o,depth:_,index:v+1};T.insert(zs(L.segment),L),this.dragSegments_.push([L,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=Hn.POINTERDRAG){let e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_);let r=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Gu(c_.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null,r}return!1}removeVertex_(){let e=this.dragSegments_,r={},l=!1,c,o,_,v,w,T,I,L,O,U,J;for(w=e.length-1;w>=0;--w)_=e[w],U=_[0],J=Vt(U.feature),U.depth&&(J+="-"+U.depth.join("-")),J in r||(r[J]={}),_[1]===0?(r[J].right=U,r[J].index=U.index):_[1]==1&&(r[J].left=U,r[J].index=U.index+1);for(J in r){switch(O=r[J].right,I=r[J].left,T=r[J].index,L=T-1,I!==void 0?U=I:U=O,L<0&&(L=0),v=U.geometry,o=v.getCoordinates(),c=o,l=!1,v.getType()){case"MultiLineString":o[U.depth[0]].length>2&&(o[U.depth[0]].splice(T,1),l=!0);break;case"LineString":o.length>2&&(o.splice(T,1),l=!0);break;case"MultiPolygon":c=c[U.depth[1]];case"Polygon":c=c[U.depth[0]],c.length>4&&(T==c.length-1&&(T=0),c.splice(T,1),l=!0,T===0&&(c.pop(),c.push(c[0]),L=c.length-1));break;default:}if(l){this.setGeometryCoordinates_(v,o);let ce=[];if(I!==void 0&&(this.rBush_.remove(I),ce.push(I.segment[0])),O!==void 0&&(this.rBush_.remove(O),ce.push(O.segment[1])),I!==void 0&&O!==void 0){let he={depth:U.depth,feature:U.feature,geometry:U.geometry,index:L,segment:ce};this.rBush_.insert(zs(he.segment),he)}this.updateSegmentIndices_(v,T,U.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return l}setGeometryCoordinates_(e,r){this.changingFeature_=!0,e.setCoordinates(r),this.changingFeature_=!1}updateSegmentIndices_(e,r,l,c){this.rBush_.forEachInExtent(e.getExtent(),function(o){o.geometry===e&&(l===void 0||o.depth===void 0||yn(o.depth,l))&&o.index>r&&(o.index+=c)})}};function FC(h,e){return h.index-e.index}function u1(h,e,r){let l=e.geometry;if(l.getType()==="Circle"){let o=l;if(e.index===ju){let _=Zn();_&&(o=o.clone().transform(_,r));let v=xc(o.getCenter(),Ni(h,r)),w=Math.sqrt(v)-o.getRadius();return w*w}}let c=Ni(h,r);return Fc[0]=Ni(e.segment[0],r),Fc[1]=Ni(e.segment[1],r),av(c,Fc)}function d1(h,e,r){let l=e.geometry;if(l.getType()==="Circle"&&e.index===ju){let o=l,_=Zn();return _&&(o=o.clone().transform(_,r)),sl(o.getClosestPoint(Ni(h,r)),r)}let c=Ni(h,r);return Fc[0]=Ni(e.segment[0],r),Fc[1]=Ni(e.segment[1],r),sl(ig(c,Fc),r)}function zC(){let h=fb();return function(e,r){return h.Point}}var u_=h_;var OC=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,p1=/^([\d.]+),([\d.]+)$/,f1=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,Zp="stop-fetch",m1=h=>{let e=[];return h.forEach(r=>{let l=r.getGeometry()?.getCoordinates();l?.length&&e.push(...l)}),e},d_=class h extends Cc{constructor(r={}){super(r);this.abortControllers={};this.cacheStationData={};this.format=new cr({featureProjection:"EPSG:3857"});this.graphs=[];this.initialRouteDrag={};this.segments=[];this.snapToClosestStation=!1;this.useRawViaPoints=!1;this.viaPoints=[];this.element||this.createDefaultElement(),this.loading=!1,this.active=r.active||!0,this.graphs=r.graphs||[["osm",0,99]],this.mot=r.mot||"bus",this.modify=r.modify!==!1,this.apiParams=r.apiParams,this.useRawViaPoints=r.useRawViaPoints||!1,this.snapToClosestStation=r.snapToClosestStation||!1,this.apiKey=r.apiKey,this.stopsApiKey=r.stopsApiKey||this.apiKey,this.stopsApiUrl=r.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new Xh({...r}),this.routingLayer=r.routingLayer||new fl({source:new ml,style:r.style}),this.onRouteError=r.onRouteError||(l=>{this.dispatchEvent(new Si("change:route")),this.reset(),console.error(l)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",l=>{l.key==="active"&&this.onActiveChange(),l.key==="mot"&&this.viaPoints&&this.drawRoute()})}static getGraphsResolutions(r,l){let c=l.getView();return r.map(([,o,_])=>[c.getResolutionForZoom(o),c.getResolutionForZoom(_||o+1)])}abortRequests(){this.graphs.forEach(r=>{let l=r[0];this.abortControllers[l]&&this.abortControllers[l].abort(),this.abortControllers[l]=new AbortController}),this.abortControllers[Zp]?.abort(),this.abortControllers[Zp]=new AbortController,this.loading=!1}activate(){let r=this.getMap();r&&(this.format=new cr({featureProjection:r.getView().getProjection()}),this.graphsResolutions=h.getGraphsResolutions(this.graphs,r),this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.modifyInteraction&&r.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}addViaPoint(r,l=-1,c=0){this.viaPoints.splice(l===-1?this.viaPoints.length:l,c,r),this.drawRoute(),this.dispatchEvent(new Si("change:route"))}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new u_({deleteCondition:r=>{let c=(r.target?.getFeaturesAtPixel(r.pixel,{hitTolerance:5})||[]).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("index"));return n1(r)&&c?(this.removeViaPoint(c.get("index")),!0):!1},pixelTolerance:6,source:this.routingLayer?.getSource()||void 0}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}deactivate(){let r=this.getMap();r&&(this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(!0),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[Zp]);let r=this.viaPoints.map(l=>{if(Array.isArray(l)){let c=this.getMap()?.getView().getProjection(),[o,_]=rl(l,c);return this.snapToClosestStation?[`@${_}`,o]:[_,o]}return this.useRawViaPoints?l:`!${l}`});return this.loading=!0,this.viaPoints.forEach((l,c)=>{this.drawViaPoint(l,c,this.abortControllers[Zp])}),Promise.all(this.graphs.map(([l],c)=>{let{signal:o}=this.abortControllers[l];return this.api?this.api.route({"coord-punish":1e3,"coord-radius":100,elevation:!1,graph:l,mot:this.mot,"resolve-hops":!1,via:`${r.join("|")}`,...this.apiParams||{}},{signal:o}).then(_=>{if(this.segments=this.format.readFeatures(_),this.mot==="foot"){let T=this.segments.reduce((I,L)=>{let O=L.get("trg");return I.find(U=>U[0]===O[0]&&U[1]===O[1])?I:[...I,O]},[]);this.segments=T.map(I=>{let L=this.segments.filter(U=>{let J=U.get("trg");return J[0]===I[0]&&J[1]===I[1]}),O=m1(L);return new ls({geometry:new vs(O)})})}let v=m1(this.segments),w=new ls({geometry:new vs(v)});w.set("graph",l),w.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[c]?.length>=2&&(w.set("minResolution",this.graphsResolutions[c][0]),w.set("maxResolution",this.graphsResolutions[c][1])),this.routingLayer?.getSource()?.addFeature(w),this.loading=!1}).catch(_=>{/AbortError/.test(_.name)||(this.segments=[],this.dispatchEvent(new Si("error")),this.onRouteError(_,this),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(r,l,c){let o=new ls;if(o.set("viaPointIdx",l),Array.isArray(r))return o.setGeometry(new ar(r)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o);if(!this.useRawViaPoints||f1.test(r)){let I,L;return this.useRawViaPoints?[,I,,L]=f1.exec(r)||[]:[I,L]=r.split("$"),fetch(`${this.stopsApiUrl}lookup/${I}?key=${this.stopsApiKey}`,{signal:c.signal}).then(O=>O.json()).then(O=>{let{coordinates:U}=O?.features?.[0]?.geometry||{};return U||console.log("No coordinates found for station "+I,O),this.cacheStationData[r]=or(U),o.set("viaPointTrack",L),o.setGeometry(new ar(or(U))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(O=>{/AbortError/.test(O.message)||(this.dispatchEvent(new Si("error")),this.onRouteError(O,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)})}if(this.useRawViaPoints&&p1.test(r)){let[I,L]=p1.exec(r)||[];if(L&&I){let O=parseFloat(L),U=parseFloat(I),J=or([O,U],this.getMap()?.getView().getProjection());return o.setGeometry(new ar(J)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}}let[,_,,v,w,,T]=OC.exec(r)||[];if(w&&v){let I=or([parseFloat(w),parseFloat(v)],this.getMap()?.getView().getProjection());return o.set("viaPointTrack",T),o.setGeometry(new ar(I)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}return _?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${_}&limit=1`,{signal:c.signal}).then(I=>I.json()).then(I=>{let{coordinates:L}=I.features[0].geometry;return this.cacheStationData[r]=or(L),o.set("viaPointTrack",T),o.setGeometry(new ar(or(L))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(I=>(this.dispatchEvent(new Si("error")),this.onRouteError(I,this),this.loading=!1,null)):Promise.resolve(null)}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}onMapClick(r){let c=r.target.getFeaturesAtPixel(r.pixel,{hitTolerance:5,layerFilter:o=>o===this.routingLayer}).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("viaPointIdx")!==void 0);if(c){this.removeViaPoint(c.get("viaPointIdx"));return}this.addViaPoint(r.coordinate)}onModifyEnd(r){let l=r.mapBrowserEvent.coordinate,{oldRoute:c,segmentIndex:o,viaPoint:_}=this.initialRouteDrag||{};return _?this.addViaPoint(l,_.get("viaPointIdx"),1):c?o===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(l,(o||0)+1):this.addViaPoint(l,0,1)}onModifyStart(r){let l=-1,c=r.features.getArray().find(_=>_.getGeometry()?.getType()==="LineString");if(c?.getGeometry()&&r.mapBrowserEvent.coordinate){let _=ns(new ar(c.getGeometry()?.getClosestPoint(r.mapBrowserEvent.coordinate)).getExtent(),.001);l=this.segments.findIndex(v=>v.getGeometry()?.intersectsExtent(_))}let o=(r.features.getArray().filter(_=>_.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={oldRoute:c?.clone(),segmentIndex:l,viaPoint:o}}removeListeners(){this.onMapClickKey&&el(this.onMapClickKey)}removeViaPoint(r=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[r]&&this.viaPoints.splice(r,1),this.drawRoute(),this.dispatchEvent(new Si("change:route"))}render(){}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new Si("change:route"))}setMap(r){super.setMap(r),r&&this.active?this.activate():r||(this.active=!1)}setViaPoints(r){this.viaPoints=[...r],this.drawRoute(),this.dispatchEvent(new Si("change:route"))}get active(){return this.get("active")}set active(r){this.set("active",r)}get loading(){return this.get("loading")}set loading(r){this.set("loading",r)}get modify(){return this.get("modify")}set modify(r){this.set("modify",r)}get mot(){return this.get("mot")}set mot(r){this.set("mot",r)}},g1=d_;var p_=class{constructor(e){let{apiKey:r,apiParams:l,placeholder:c,url:o}=e||{};this.apiParams={limit:20,...l||{}},this.placeholder=c||"Search for a stop...";let _={apiKey:r};o&&(_.url=o),this.api=new Hh(_),this.abortController=new AbortController,this.createElement(e),this.options=e}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=r=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(r.target.value,this.abortController)},Object.assign(this.inputElt.style,{padding:"10px 30px 10px 10px"}),e.appendChild(this.inputElt),this.suggestionsElt=document.createElement("div"),Object.assign(this.suggestionsElt.style,{backgroundColor:"white",cursor:"pointer",overflowY:"auto"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{cursor:"pointer",display:"none",fontSize:"200%",padding:"0 10px",position:"absolute",right:"0"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}render(e){let r=e?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=r.length?"block":"none",this.suggestionsElt.innerHTML="",r.forEach(l=>{let c=document.createElement("div");c.innerHTML=l?.properties?.name,c.onclick=o=>{this.options?.onSuggestionClick?.(l,o)},Object.assign(c.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(c)}))}search(e,r){return(e!==void 0||e!==null)&&(this.apiParams.q=e),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,r&&{signal:r.signal}).then(l=>{this.render(l)}).catch(()=>{this.render()})}},y1=p_;var BC=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),h},_1=BC;var f_=class extends Cc{constructor(e){let r=_1();r.className=e?.className||"mbt-stop-finder";let l={element:r,...e||{}};super(l),this.controller=new y1({onSuggestionClick:this.onSuggestionClick.bind(this),...l})}onSuggestionClick(e){let r=or(e.geometry.coordinates);this.getMap()?.getView().setCenter(r)}search(e,r){return this.controller.search(e,r)}},x1=f_;var b1=Fs(y_(),1);var NC="vectorTileFeature",__={"EPSG:3857":new cr({featureProjection:"EPSG:3857"})},zc=class extends ba{getFeaturesAtCoordinate(e,r=5){let l=this.getMapLibrePixels(e,r);if(!l)return[];let c=this.getLayer().get("queryRenderedFeaturesOptions")||{};return this.getLayer().mapLibreMap?.queryRenderedFeatures(l,c).map(_=>this.toOlFeature(_))||[]}prepareFrame(){return!0}renderFrame(e){let r=this.getLayer(),{mapLibreMap:l}=r,c=r.getMapInternal();if(!r||!c||!l)return null;let o=l.getCanvas(),{viewState:_}=e;l.jumpTo({center:rl(_.center),zoom:_.zoom-1,bearing:iv(-_.rotation)});let v=r.getOpacity().toString();return o&&v!==o.style.opacity&&(o.style.opacity=v),o.isConnected?VC(o,e)||l.resize():c.render(),l.redraw(),l.getContainer()}getFeatures(e){let r=this.getLayer().getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,l,c){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(_=>{let v=_.getGeometry();v instanceof Ir&&c(_,this.getLayer(),v)}),o?.[0]}getMapLibrePixels(e,r){if(!e)return;let l=this.getLayer().mapLibreMap?.project(rl(e));if(l?.x===void 0||l?.y===void 0)return;let c=[l.x,l.y];if(r){let[o,_]=c;c=[[o-r,_-r],[o+r,_+r]]}return c}toOlFeature(e){let c=this.getLayer().getMapInternal()?.getView()?.getProjection()?.getCode()||"EPSG:3857";__[c]||(__[c]=new cr({featureProjection:c}));let o=__[c].readFeature(e);return o&&o.set(NC,e,!0),o}};function VC(h,e){return h.width===Math.floor(e.size[0]*e.pixelRatio)&&h.height===Math.floor(e.size[1]*e.pixelRatio)}var jC=h=>{if(!h)return[];let{style:e}=h;if(!e)return[];let{sourceCaches:r}=e,l=[];return Object.values(r).forEach(c=>{if(c.used){let{attribution:o}=c.getSource();o&&(l=l.concat(o.replace(/©/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),GC(l)},GC=h=>{let e=h.filter(c=>c!=null&&c.trim&&c.trim()),r=e.map(c=>c.toLowerCase());return[...new Set(r)].map(c=>e.find(o=>o.toLowerCase()===c))},x_=jC;var Oc=class extends ws{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(e){super({source:new To({attributions:()=>x_(this.mapLibreMap)}),...e})}disposeInternal(){el(this.olListenersKeys),this.loaded=!1,this.mapLibreMap&&(this.mapLibreMap.triggerRepaint=()=>{},this.mapLibreMap.remove()),super.disposeInternal()}setMapInternal(e){super.setMapInternal(e),e?this.loadMapLibreMap():this.dispose()}loadMapLibreMap(){this.loaded=!1;let e=this.getMapInternal();if(e&&this.olListenersKeys.push(e.on("change:target",this.loadMapLibreMap.bind(this))),!e?.getTargetElement())return;if(!this.getVisible()){this.olListenersKeys.push(this.once("change:visible",this.loadMapLibreMap.bind(this)));return}let r=document.createElement("div");r.style.position="absolute",r.style.width="100%",r.style.height="100%";let l=this.get("mapLibreOptions");this.mapLibreMap=new b1.Map(Object.assign({},l,{container:r,attributionControl:!1,interactive:!1,trackResize:!1})),this.mapLibreMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mapLibreMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new Si("load"))})}createRenderer(){return new zc(this)}};var I_=Fs(gl());var C1=Fs(gl());var Xi=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Xi=(0,C1.default)(h=>{console.warn(h)},1e3));function oE(h){return class extends h{constructor(...l){let c=l[0];super(c);this.olEventsKeys=[];this.options={};c.properties&&(Xi("Deprecated. Don't use properties options. Pass the values directly in options object."),this.setProperties(c.properties)),this.on("propertychange",o=>{o.key==="children"&&this.onChildrenChange(o.oldValue)}),this.options=c,this.set("children",c.children||[])}attachToMap(l){(super.attachToMap||(()=>{}))(l),(this.get("children")||[]).forEach(c=>{l.addLayer(c)})}detachFromMap(){el(this.olEventsKeys),(this.get("children")||[]).forEach(l=>{this.map.removeLayer(l)}),(super.detachFromMap||(()=>{}))()}flat(){return Xi("Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead."),Qa(this)}onChildrenChange(l){(l||[]).forEach(c=>{c.set("parent",void 0)}),(this.get("children")||[]).forEach(c=>{c.set("parent",this)})}setMapInternal(l){l?(super.setMapInternal(l),this.attachToMap(l)):(this.detachFromMap(),super.setMapInternal(l))}get children(){return Xi("Layer.children is deprecated. Use the Layer.get('children') method instead."),this.get("children")||[]}set children(l){Xi("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),this.set("children",l||[])}get copyrights(){return Xi("Layer.copyrights is deprecated. Get the attributions from the source object"),this.get("copyrights")}set copyrights(l){Xi("Layer.copyrights is deprecated. Set the attributions to the source object.");let c=l&&!Array.isArray(l)?[l]:l;this.set("copyrights",c||[])}get disabled(){return Xi("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),this.get("disabled")}set disabled(l){Xi("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),this.set("disabled",l)}get group(){return Xi("Layer.group is deprecated. Use the Layer.get('group') method instead."),this.get("group")}get hitTolerance(){return Xi("Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."),this.get("hitTolerance")||5}set hitTolerance(l){Xi("Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."),this.set("hitTolerance",l)}get key(){return this.get("key")||this.get("name")||Vt(this)}get map(){return this.getMapInternal()}get name(){return Xi("Layer.name is deprecated. Use the Layer.get('name') method instead."),this.get("name")}get olLayer(){return Xi("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object."),this}set olLayer(l){Xi("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.")}get parent(){return Xi("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),this.get("parent")}set parent(l){Xi("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),this.set("parent",l)}get visible(){return Xi("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),this.getVisible()}set visible(l){Xi("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),this.setVisible(l)}}}var E1=oE;function aE(h){return class extends E1(h){}}var Xs=aE;var T1=(h,e,r,l)=>Ya(`${h}/styles/${e}/style.json`,{[l]:r}).toString(),w_=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(w_=(0,I_.default)(h=>{console.warn(h)},1e3));var S_=class h extends Xs(Oc){constructor(e){let r={apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...e||{},mapLibreOptions:{...e.mapLibreOptions||{}}};!r.mapLibreOptions.style&&r.url?.includes("style.json")?r.mapLibreOptions.style=r.url:!r.mapLibreOptions.style&&r.apiKey&&r.style&&typeof r.style=="string"&&(r.mapLibreOptions.style=T1(r.url,r.style,r.apiKey,r.apiKeyName)),super(r)}attachToMap(e){super.attachToMap(e);let r=(0,I_.default)(this.updateMaplibreMap.bind(this),150);r(),this.olEventsKeys.push(this.on("propertychange",l=>{/(url|style|apiKey|apiKeyName)/.test(l.key)&&r()}))}clone(e){return new h({...this.options||{},...e||{}})}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:T1(this.url,this.style,this.apiKey,this.apiKeyName)}updateMaplibreMap(){try{this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}catch(e){console.error("Error while updating MaplibreMap",e)}}set apiKey(e){this.set("apiKey",e)}get apiKey(){return this.get("apiKey")}set apiKeyName(e){this.set("apiKeyName",e)}get apiKeyName(){return this.get("apiKeyName")}get maplibreMap(){return w_("MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap."),this.mapLibreMap}get mbMap(){return w_("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get style(){return this.get("style")}set style(e){this.set("style",e)}get url(){return this.get("url")}set url(e){this.set("url",e)}},M1=S_;var A1=Fs(gl());var C_={"EPSG:3857":new cr({featureProjection:"EPSG:3857"})},Uu=class extends ba{forEachFeatureAtCoordinate(e,r,l,c){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(_=>{c(_,this.layer_,_.getGeometry())}),o?.[0]}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),c=l.getMapInternal(),{mapLibreMap:o}=l.maplibreLayer,_=c?.getView()?.getProjection()?.getCode()||"EPSG:3857",v=[];if(C_[_]||(C_[_]=new cr({featureProjection:_})),o?.isStyleLoaded()){let w=e&&o.project(rl(e));if(w?.x&&w?.y){let T=[w.x,w.y];if(r){let[L,O]=T;T=[[L-r,O-r],[L+r,O+r]]}let I=l.layers||[];l.layersFilter&&(I=o.getStyle().layers.filter(l.layersFilter)),l.queryRenderedLayersFilter&&(I=o.getStyle().layers.filter(l.queryRenderedLayersFilter)),v=o.queryRenderedFeatures(T,{layers:I.map(L=>L.id),validate:!1}).map(L=>{let O=C_[_].readFeature(L);return O&&O.set(Ic,L),O})}}return v}prepareFrame(){return!0}renderFrame(){return null}};var Mn=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Mn=(0,A1.default)((...h)=>{console.warn(...h)},1e3));var E_=class h extends Xs(ws){constructor(r={mapLibreOptions:{style:{layers:[],sources:{},version:8}}}){r.mapboxLayer&&(Mn("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),r.maplibreLayer=r.mapboxLayer,delete r.mapboxLayer),r.styleLayers&&(Mn("options.styleLayers is deprecated. Use options.layers instead."),r.layers=r.styleLayers,delete r.styleLayers),r.styleLayersFilter&&(Mn("options.styleLayersFilter is deprecated. Use options.layersFilter instead."),r.layersFilter=r.styleLayersFilter,delete r.styleLayersFilter);super({source:new To({}),...r});this.highlightedFeatures=[];this.selectedFeatures=[];this.beforeId=r.beforeId,this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=l=>!!this.layers.find(c=>l.id===c.id))}addLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&(this.layers.forEach(l=>{let{id:c,source:o}=l;(!o||o&&r.getSource(o))&&c&&!r.getLayer(c)&&r.addLayer(l,this.beforeId)}),this.applyLayoutVisibility())}addSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.entries(this.sources).forEach(([l,c])=>{r.getSource(l)||r.addSource(l,c)})}applyLayoutVisibility(r){if(!this.maplibreLayer?.mapLibreMap?.getStyle()||!this.layersFilter)return;let{mapLibreMap:l}=this.maplibreLayer,c=l.getStyle(),o=this.getVisible()?"visible":"none",_=c.layers||[];for(let v=0;v<_.length;v+=1){let w=_[v];if(this.layersFilter(w)){let{id:T}=w;l.getLayer(T)&&(l.setLayoutProperty(T,"visibility",o),(this.getMinZoom()||this.getMaxZoom())&&l.setLayerZoomRange(T,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}attachToMap(r){if(this.maplibreLayer&&!this.maplibreLayer.map&&r.addLayer(this.maplibreLayer),super.attachToMap(r),!this.map||!this.maplibreLayer)return;if(!this.map.getTargetElement()){this.olEventsKeys.push(this.map.on("change:target",()=>{this.attachToMap(r)}));return}let{mapLibreMap:l}=this.maplibreLayer;l&&(l.loaded()?this.onLoad():l.once("load",this.onLoad)),this.olEventsKeys.push(this.maplibreLayer.on("load",this.onLoad.bind(this)),this.on("change:visible",c=>{this.applyLayoutVisibility(c)}),this.on("propertychange",c=>{/(sources|layers|layersFilter|maplibreLayer|beforeId)/.test(c.key)&&(this.detachFromMap(),this.attachToMap(r))}),this.maplibreLayer.on("propertychange",c=>{c.key==="style"&&c.target.maplibreMap.once("styledata",()=>{c.target.maplibreMap.once("idle",()=>{this.onLoad()})})}))}clone(r){return new h({...this.options,...r})}createRenderer(){return new Uu(this)}detachFromMap(){this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources()),super.detachFromMap()}getFeatureInfoAtCoordinate(r){if(Mn("Deprecated. getFeatureInfoAtCoordinate([layer], coordinate) from ol package instead."),!this.maplibreLayer?.mapLibreMap)return Promise.resolve({coordinate:r,features:[],layer:this});let{mapLibreMap:l}=this.maplibreLayer;if(!l.isStyleLoaded())return Promise.resolve({coordinate:r,features:[],layer:this});let c=this.layers||[];return this.layersFilter&&(c=l.getStyle().layers.filter(this.layersFilter),console.log(c)),this.queryRenderedLayersFilter&&(c=l.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({coordinate:r,features:[],layer:this})}highlight(r=[]){Mn("Deprecated. Use layer.setFeatureState(features, {hover: true}) instead.");let l=this.highlightedFeatures?.filter(c=>!(this.selectedFeatures||[]).map(o=>o.getId()).includes(c.getId()))||[];this.setHoverState(l,!1),this.highlightedFeatures=r,this.setHoverState(this.highlightedFeatures,!0)}onLoad(){if(!this.maplibreLayer?.mapLibreMap)return;this.addSources(),this.addLayers();let{mapLibreMap:r}=this.maplibreLayer,l=r.getStyle();if(l?.layers&&this.layersFilter){let c=l.layers.filter(this.layersFilter);this.set("disabled",!c.length)}this.applyLayoutVisibility()}removeLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&this.layers.forEach(l=>{let{id:c}=l;c&&r.getLayer(c)&&r.removeLayer(c)})}removeSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.keys(this.sources).forEach(l=>{r.getSource(l)&&r.removeSource(l)})}select(r=[]){Mn("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=r,this.setHoverState(this.selectedFeatures||[],!0)}setFeatureState(r,l){if(!this.maplibreLayer?.mapLibreMap||!r.length)return;let{mapLibreMap:c}=this.maplibreLayer;r.forEach(o=>{let{source:_,sourceLayer:v}=o.get(Ic)||{};if(!_&&!v||!o.getId()){o.getId()||Mn("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",o.getProperties());return}c.setFeatureState({id:o.getId(),source:_,sourceLayer:v},l)})}setHoverState(r,l){Mn(`Deprecated. Use layer.setFeatureState(features, {hover: ${l}}) instead.`),this.setFeatureState(r,{hover:l})}get beforeId(){return this.get("beforeId")}set beforeId(r){this.set("beforeId",r)}get layers(){return this.get("layers")}set layers(r){this.set("layers",r)}get layersFilter(){return this.get("layersFilter")}set layersFilter(r){this.set("layersFilter",r)}get mapboxLayer(){return Mn("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(r){this.set("maplibreLayer",r)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(r){this.set("queryRenderedLayersFilter",r)}get sources(){return this.get("sources")}set sources(r){this.set("sources",r)}get styleLayer(){return Mn("Deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(r){Mn("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[r]}get styleLayers(){return Mn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(r){Mn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=r}},P1=E_;var R_=Fs(gl());var M_=Fs(gl()),A_=Fs(F1());var P_=class{constructor(e){this.getViewState=()=>({});this.shouldRender=()=>!0;this._mode=e.mode||qi.TOPOGRAPHIC,this._speed=e.speed||1,this._style=e.style||Ka,this._time=e.time||new Date,this.api=e.api||new Zh(e),this.bboxParameters=e.bboxParameters,this.canvas=e.canvas||document.createElement("canvas"),this.debug=e.debug||!1,this.filter=e.filter,this.hoverVehicleId=e.hoverVehicleId,this.live=e.live!==!1,this.minZoomInterpolation=e.minZoomInterpolation||8,this.pixelRatio=e.pixelRatio||(typeof window<"u"?window.devicePixelRatio:1),this.selectedVehicleId=e.selectedVehicleId,this.sort=e.sort,this.styleOptions={...Sc,...e.styleOptions||{}},this.tenant=e.tenant||"",this.trajectories={},this.useDebounce=e.useDebounce||!1,this.useRequestAnimationFrame=e.useRequestAnimationFrame||!1,this.useThrottle=e.useThrottle!==!1,this.getViewState=e.getViewState||(()=>({})),this.shouldRender=e.shouldRender||(()=>!0),this.onRender=e.onRender,this.onStart=e.onStart,this.onStop=e.onStop,this.format=new cr,this.motsByZoom=e.motsByZoom||[bs,bs,bs,bs,bs,bs,bs,bs,bs,wp,wp],this.getMotsByZoom=r=>e.getMotsByZoom?e.getMotsByZoom(r,this.motsByZoom):this.motsByZoom[r],this.generalizationLevelByZoom=e.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=r=>e.getGeneralizationLevelByZoom?e.getGeneralizationLevelByZoom(r,this.generalizationLevelByZoom):this.generalizationLevelByZoom[r],this.renderTimeIntervalByZoom=e.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=r=>e.getRenderTimeIntervalByZoom?e.getRenderTimeIntervalByZoom(r,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[r],this.isUpdateBboxOnMoveEnd=e.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,A_.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,M_.default)(this.renderTrajectoriesInternal,50,{leading:!0,maxWait:5e3,trailing:!0}),this.renderState={center:[0,0],rotation:0,zoom:void 0},this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}addTrajectory(e){this.trajectories||(this.trajectories={});let r=e.properties.train_id;r!==void 0&&(this.trajectories[r]=e),this.renderTrajectories()}attachToMap(){document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),this.canvas){let e=this.canvas.getContext("2d");e&&e.clearRect(0,0,this.canvas.width,this.canvas.height)}}getRefreshTimeInMs(){let r=this.getViewState().zoom||0,l=r!==void 0?Math.round(r):-1,c=this.getRenderTimeIntervalByZoom(l)||25,o=Math.max(25,c/(this.speed||1)),_=Math.min(o,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,A_.default)(this.renderTrajectoriesInternal,_,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,M_.default)(this.renderTrajectoriesInternal,_,{leading:!0,maxWait:5e3,trailing:!0})),this.api?.buffer){let[,v]=this.api.buffer;this.api.buffer=[_,v]}return o}getVehicles(e){return this.trajectories&&Object.values(this.trajectories).filter(e)||[]}getVehiclesAtCoordinate(e,r){let{resolution:l}=this.getViewState(),{hitTolerance:c,nb:o}=r||{},_=ns([...e,...e],(c||5)*(l||1)),v=Object.values(this.trajectories||{});this.sort&&(v=v.sort(this.sort));let w=[];for(let T=0;T<v.length;T+=1){let{coordinate:I}=v[T].properties;if(I&&tl(_,I)&&w.push(v[T]),w.length===o)break}return{features:w,type:"FeatureCollection"}}onDeleteTrajectoryMessage(e){e.content&&this.removeTrajectory(e.content)}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(!this.getViewState().visible)return;this.start()}}onTrajectoryMessage(e){if(!e.content)return;let r=e.content,{geometry:l,properties:{raw_coordinates:c,time_since_update:o}}=r;o<0||this.purgeTrajectory(r)||(this.debug&&this.mode===qi.TOPOGRAPHIC&&c?r.properties.olGeometry=this.format.readGeometry({coordinates:or(c),type:"Point"}):r.properties.olGeometry=this.format.readGeometry(l),r.properties.timeOffset=Date.now()-e.timestamp,this.addTrajectory(r))}onZoomEnd(){this.startUpdateTime()}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([e,r])=>{let l=r?.properties?.time_intervals;this.time&&l?.length&&l[l.length-1][0]<this.time.getTime()&&this.removeTrajectory(e)})}purgeTrajectory(e){let l=this.getViewState().extent,{bounds:c,type:o}=e.properties;return this.isUpdateBboxOnMoveEnd&&l&&!Bi(l,c)||this.mots&&!this.mots.includes(o)?(this.removeTrajectory(e),!0):!1}removeTrajectory(e){let r;typeof e!="string"?r=e?.properties?.train_id:r=e,r!==void 0&&this.trajectories&&delete this.trajectories[r]}renderTrajectories(e){let r=this.getViewState();this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),!(!r?.center||!r?.extent||!r?.size)&&(!e&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(r,e)}):!e&&this.useDebounce?this.debounceRenderTrajectories(r,e):!e&&this.useThrottle?this.throttleRenderTrajectories(r,e):this.renderTrajectoriesInternal(r,e))}renderTrajectoriesInternal(e,r=!1){if(!this.trajectories||!this.shouldRender())return!1;let l=this.live?Date.now():this.time?.getTime(),c=Object.values(this.trajectories);return this.sort&&c.sort(this.sort),!this.canvas||!this.style||(this.renderState=gu(this.canvas,c,this.style,{...e,pixelRatio:this.pixelRatio||1,time:l},{filter:this.filter,hoverVehicleId:this.hoverVehicleId,noInterpolate:(e.zoom||0)<this.minZoomInterpolation?!0:r,selectedVehicleId:this.selectedVehicleId,...this.styleOptions}),this.onRender?.(this.renderState,e)),!0}setBbox(){let e=this.getViewState(),r=e.extent,l=e.zoom||0;if(!r||Number.isNaN(l))return;if(this.trajectories&&r&&l){let I=Object.keys(this.trajectories);for(let L=I.length-1;L>=0;L-=1)this.purgeTrajectory(this.trajectories[I[L]])}let c=Math.floor(l);if(!r||Number.isNaN(c))return;let[o,_,v,w]=r,T=[Math.floor(o),Math.floor(_),Math.ceil(v),Math.ceil(w),c];this.generalizationLevel=this.getGeneralizationLevelByZoom(c),this.generalizationLevel&&T.push(`gen=${this.generalizationLevel}`),this.mots=this.getMotsByZoom(c),this.mots&&T.push(`mots=${this.mots}`),this.tenant&&T.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&T.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([I,L])=>{T.push(`${I}=${L}`)}),this.api.bbox=T}start(){this.stop(),this.purgeOutOfDateTrajectories(),this.renderTrajectories(),this.startUpdateTime(),this.api.open(),this.api.subscribeTrajectory(this.mode,this.onTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.api.subscribeDeletedVehicles(this.mode,this.onDeleteTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.isUpdateBboxOnMoveEnd&&this.setBbox(),this.onStart&&this.onStart(this)}startUpdateTime(){this.stopUpdateTime(),this.updateTimeDelay=this.getRefreshTimeInMs()||0,this.updateTimeInterval=window.setInterval(()=>{this.live?this.time=new Date:this.time&&this.updateTimeDelay&&this.speed&&(this.time=new Date(this.time.getTime()+this.updateTimeDelay*this.speed))},this.updateTimeDelay)}stop(){this.api.unsubscribeTrajectory(this.onTrajectoryMessage),this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage),this.api.close(),this.onStop&&this.onStop(this)}stopUpdateTime(){this.updateTimeInterval&&(clearInterval(this.updateTimeInterval),this.updateTimeInterval=void 0)}get mode(){return this._mode}set mode(e){e!==this._mode&&(this._mode=e,this.api?.wsApi?.open&&(this.stop(),this.start()))}get speed(){return this._speed}set speed(e){this._speed=e,this.start()}get style(){return this._style}set style(e){this._style=e,this.renderTrajectories()}get time(){return this._time}set time(e){this._time=e?.getTime?e:new Date(e),this.renderTrajectories()}},Hp=P_;var CE=new cr,qu=class extends Up{forEachFeatureAtCoordinate(e,r,l,c){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(_=>{c(_,this.layer_,_.getGeometry())}),o?.[0]}getData(e){let r;try{let{pixelRatio:l}=this.getLayer();return r=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(e[0]*(l||1),e[1]*(l||1),1,1).data||null,r}catch(l){console.error("error getting data",l)}return null}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),c=l.engine.getVehiclesAtCoordinate(e,{hitTolerance:r,nb:l.maxNbFeaturesRequested});return CE.readFeatures(c)}prepareFrame(){return!0}renderFrame(e){let{canvas:r,renderedViewState:l}=this.getLayer();if(this.container||(this.container=document.createElement("div"),this.container.className=this.getLayer().getClassName(),this.container.style.position="absolute",this.container.style.width="100%",this.container.style.height="100%",r instanceof HTMLCanvasElement&&(r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.transformOrigin="top left",this.container.appendChild(r))),l){let{center:c,resolution:o,rotation:_}=e.viewState,{center:v,resolution:w,rotation:T}=l;if(w/o>=3){let I=r?.getContext("2d");r?.width&&r?.height&&I?.clearRect(0,0,r.width,r.height)}else{let I=this.getLayer().getMapInternal(),L=I?.getPixelFromCoordinate(v),O=I?.getPixelFromCoordinate(c);L&&O&&(this.container.style.transform=zx(L[0]-O[0],L[1]-O[1],w/o,w/o,_-T,0,0))}}return this.container}};var EE=new Er({image:new En({fill:new Cr({color:"#000000"}),radius:5}),stroke:new Wi({color:"#000000",width:6}),zIndex:2}),TE=(h,e,r)=>{let l="#ffffff",c=h.get("type"),o=h.get("stroke");return o&&o[0]!=="#"&&(o=`#${o}`),l=o||r?.getBgColor(c),l=/#ffffff/i.test(l)?"#ff0000":l,[EE,new Er({image:new En({fill:new Cr({color:l}),radius:4}),stroke:new Wi({color:l,width:4}),zIndex:3})]},Yp=TE;var ME=new Er({image:new En({fill:new Cr({color:"#000000"}),radius:5}),stroke:new Wi({color:"#000000",width:6}),zIndex:2}),AE=new Er({image:new En({fill:new Cr({color:"#a0a0a0"}),radius:4}),stroke:new Wi({color:"#a0a0a0",width:4}),zIndex:3}),PE=()=>[ME,AE],z1=PE;var O1=new En({fill:new Cr({color:[255,0,0,1]}),radius:6,stroke:new Wi({color:[0,0,0,1],width:1})}),RE=new Er({stroke:new Wi({color:[0,0,0,1],width:5})}),kE=new Er({image:O1,stroke:new Wi({color:[255,0,0,1],width:3})}),LE=new Er({image:O1,stroke:new Wi({color:[255,0,0,1],lineDash:[1,10],width:3})}),DE=(h,e)=>{let r=h.get("minResolution"),l=h.get("maxResolution"),c=e<=r&&e>l;return r&&l&&!c?[]:h.get("mot")!=="foot"?[RE,kE]:[LE]},B1=DE;var FE=new cr,k_=class h extends Xs(ws){constructor(r){super({source:new To({}),...r});this.allowRenderWhenAnimating=!1;this.maxNbFeaturesRequested=100;this.engine=new Hp({getViewState:this.getViewState.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...r}),this.allowRenderWhenAnimating=!!r.allowRenderWhenAnimating,this.vectorLayer=new fl({source:new ml({features:[]}),style:(l,c)=>(r.fullTrajectoryStyle||Yp)(l,c,this.engine.styleOptions),updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0}),this.onZoomEndDebounced=(0,R_.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,R_.default)(this.onMoveEnd,100)}attachToMap(r){if(super.attachToMap(r),this.engine.attachToMap(),this.map){this.getVisible()&&this.engine.start();let l=this.map.getLayers().getArray().indexOf(this);this.map.getLayers().insertAt(l,this.vectorLayer),this.olEventsKeys.push(...this.map.on(["moveend","change:target"],c=>{let o=(c.map||c.target).getView();if(!o||o?.getAnimating()||o?.getInteracting())return;let _=o.getZoom();this.currentZoom!==_&&this.onZoomEndDebounced(c),this.currentZoom=_,this.onMoveEndDebounced(c)}),this.on("change:visible",c=>{c.target.getVisible()?this.engine.start():this.engine.stop()}),this.on("propertychange",c=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(c.key)&&this.vectorLayer.set(c.key,c.target.get(c.key))}))}}clone(r){return new h({...this.options,...r})}createRenderer(){return new qu(this)}detachFromMap(){this.map?.removeLayer(this.vectorLayer),this.engine.detachFromMap(),super.detachFromMap()}getTrajectoryInfos(r){let l=[this.engine.api.getStopSequence(r),this.engine.api.getFullTrajectory(r,this.engine.mode,this.engine.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0)))];return Promise.all(l).then(([c,o])=>({fullTrajectory:o,stopSequence:c}))}getVehicles(r){return this.engine.getVehicles(r)}getViewState(){if(!this.map?.getView())return{};let r=this.map.getView();return{center:r.getCenter(),extent:r.calculateExtent(),pixelRatio:this.engine.pixelRatio,resolution:r.getResolution(),rotation:r.getRotation(),size:this.map.getSize(),visible:this.getVisible(),zoom:r.getZoom()}}highlight(r){let l=r?.get("train_id");this.hoverVehicleId!==l&&(this.hoverVehicleId=l,this.engine.renderTrajectories(!0))}highlightTrajectory(r){return r?this.engine.api.getFullTrajectory(r,this.engine.mode,this.engine.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0))).then(l=>{let c=l.content;if(!c?.features?.length)return[];let o=FE.readFeatures(c);return this.vectorLayer?.getSource()?.clear(!0),o.length&&this.vectorLayer?.getSource()?.addFeatures(o),o}).catch(()=>(this.vectorLayer?.getSource()?.clear(!0),[])):(this.vectorLayer?.getSource()?.clear(!0),Promise.resolve([]))}onMoveEnd(){!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible()||this.engine.setBbox()}onRealtimeEngineRender(r,l){this.renderedViewState={...l};let{container:c}=this.getRenderer();c&&(c.style.transform="")}onZoomEnd(){this.engine.onZoomEnd(),!(!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible())&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}select(r){let l=r?.get("train_id");this.selectedVehicleId!==l&&(this.selectedVehicleId=l,this.engine.renderTrajectories(!0)),this.highlightTrajectory(l)}shouldRender(){return this.allowRenderWhenAnimating?!1:this.map.getView().getAnimating()||this.map.getView().getInteracting()}start(){this.engine.start()}stop(){this.engine.stop()}get api(){return this.engine.api}set api(r){this.engine.api=r}get canvas(){return this.engine.canvas}get filter(){return this.engine.filter}set filter(r){this.engine.filter=r}get hoverVehicleId(){return this.engine.hoverVehicleId}set hoverVehicleId(r){this.engine.hoverVehicleId=r}get mode(){return this.engine.mode}set mode(r){this.engine.mode=r}get pixelRatio(){return this.engine.pixelRatio}get selectedVehicleId(){return this.engine.selectedVehicleId}set selectedVehicleId(r){this.engine.selectedVehicleId=r}get sort(){return this.engine.sort}set sort(r){this.engine.sort=r}get trajectories(){return this.engine.trajectories}},N1=k_;var V1=Fs(gl());var j1=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(j1=(0,V1.default)(h=>{console.warn(h)},1e3));var L_=class extends ba{prepareFrame(){return!0}renderFrame(){return null}},D_=class h extends Xs(ws){constructor(e){super(e),j1("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(e){return new h({...this.options||{},...e||{}})}createRenderer(){return new L_(this)}},Kp=D_;var F_=class h extends Kp{clone(e){return new h({...this.options,...e})}getFeatureInfoAtCoordinate(e){let r=[];if(this.map){let l=this.map.getPixelFromCoordinate(e);r=this.map.getFeaturesAtPixel(l,{hitTolerance:this.hitTolerance||5,layerFilter:c=>c===this.olLayer})||[]}return Promise.resolve({coordinate:e,features:r,layer:this})}},G1=F_;var zE=new cr,OE=(h,e,r)=>{let l,{coordinate:c,params:o,projection:_,resolution:v}=e;return h&&v&&_&&(l=h.getFeatureInfoUrl(c,v,_,{info_format:"application/json",query_layers:h.getParams().layers,...o})),fetch(l,{signal:r.signal}).then(w=>w.json()).then(w=>zE.readFeatures(w)).catch(()=>[])},$u={},BE=async(h,e,r=5)=>{Object.values($u).forEach(o=>{o?.abort()}),$u={};let c=Qa(e).map(o=>{let _=o.getMapInternal(),v=_?.getView()?.getProjection()?.getCode(),w={coordinate:h,features:[],layer:o};if(!v)return Promise.resolve(w);if(o.getFeatureInfoAtCoordinate)return o.getFeatureInfoAtCoordinate(h);let T=o?.getSource();if(T?.getFeatureInfoUrl){let O=Vt(o);$u[O]?.abort(),$u[O]=new AbortController;let U=_?.getView()?.getResolution();return OE(T,{coordinate:h,params:{info_format:"application/json",query_layers:T.getParams().layers},projection:v,resolution:U},$u[O]).then(J=>({coordinate:h,features:J,layer:o})).catch(()=>({coordinate:h,features:[],layer:o}))}let I=_?.getPixelFromCoordinate(h);if(!I)return Promise.resolve(w);let L=_?.getFeaturesAtPixel(I,{hitTolerance:o.get("hitTolerance")||r||5,layerFilter:O=>O===o});return Promise.resolve({coordinate:h,features:L,layer:o})});return Promise.all(c)},U1=BE;var rf={};vm(rf,{CopyrightControl:()=>q1,Layer:()=>Qp,RealtimeAPI:()=>Zh,RealtimeLayer:()=>lw,RealtimeModes:()=>qi,RoutingAPI:()=>Xh,StopsAPI:()=>Hh,VECTOR_TILE_FEATURE_PROPERTY:()=>Ic,compareDepartures:()=>yu,createCanvas:()=>ms,createRealtimeFilters:()=>Om,debounceDeparturesMessages:()=>Mg,debounceWebsocketMessages:()=>Wh,getCircleCanvas:()=>Lm,getDelayBgCanvas:()=>Rm,getDelayTextCanvas:()=>km,getHoursAndMinutes:()=>Lx,getLayersAsFlatArray:()=>Qa,getMapGlCopyrights:()=>Yh,getMercatorResolution:()=>aw,getSourceCoordinates:()=>tf,getTextCanvas:()=>Dm,getUTCDateString:()=>Rx,getUTCTimeString:()=>kx,getUrlWithParams:()=>Ya,getVehiclePosition:()=>mu,pad:()=>Jd,realtimeConfig:()=>Sc,realtimeDefaultStyle:()=>Ka,realtimeDelayStyle:()=>Fm,realtimeSimpleStyle:()=>zm,removeDuplicate:()=>Ja,renderTrajectories:()=>gu,sortAndFilterDepartures:()=>_u,sortByDelay:()=>Bm});var NE=" | ",z_=class{constructor(e={}){this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this.map=e,this.container||(this.container=document.createElement("div")),this.render=this.render.bind(this),this.map.on("idle",this.render),this.map.on("sourcedata",this.render),this.map.on("styledata",this.render),this.render(),this.container}onRemove(){return this.container?.parentElement&&this.container.parentElement?.removeChild(this.container),this.map&&(this.map.off("sourcedata",this.render),this.map.off("styledata",this.render),this.map.off("idle",this.render)),this.map=void 0,this.container}render(){if(this.map&&this.container){let e=this.options?.separator||NE,r=this.options?.customAttribution||Yh(this.map),l=(Array.isArray(r)?r:[r]).join(e);this.container.innerHTML!==l&&(this.content=l,this.container.innerHTML=this.content)}}},q1=z_;var W1=Fs(y_());var Tr=[];for(let h=0;h<256;++h)Tr.push((h+256).toString(16).slice(1));function $1(h,e=0){return(Tr[h[e+0]]+Tr[h[e+1]]+Tr[h[e+2]]+Tr[h[e+3]]+"-"+Tr[h[e+4]]+Tr[h[e+5]]+"-"+Tr[h[e+6]]+Tr[h[e+7]]+"-"+Tr[h[e+8]]+Tr[h[e+9]]+"-"+Tr[h[e+10]]+Tr[h[e+11]]+Tr[h[e+12]]+Tr[h[e+13]]+Tr[h[e+14]]+Tr[h[e+15]]).toLowerCase()}var O_,VE=new Uint8Array(16);function B_(){if(!O_){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");O_=crypto.getRandomValues.bind(crypto)}return O_(VE)}var jE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),N_={randomUUID:jE};function GE(h,e,r){if(N_.randomUUID&&!e&&!h)return N_.randomUUID();h=h||{};let l=h.random||(h.rng||B_)();if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,e){r=r||0;for(let c=0;c<16;++c)e[r+c]=l[c];return e}return $1(l)}var V_=GE;var j_=class extends W1.Evented{constructor(r={}){super();this.options={};this.type="custom";this.options=r,this.id=r.id||V_()}onAdd(r,l){this.map=r}onRemove(r,l){this.map=void 0}render(r){}},Qp=j_;var Mr=63710088e-1,X1={centimeters:Mr*100,centimetres:Mr*100,degrees:360/(2*Math.PI),feet:Mr*3.28084,inches:Mr*39.37,kilometers:Mr/1e3,kilometres:Mr/1e3,meters:Mr,metres:Mr,miles:Mr/1609.344,millimeters:Mr*1e3,millimetres:Mr*1e3,nauticalmiles:Mr/1852,radians:1,yards:Mr*1.0936};function UE(h,e,r={}){let l={type:"Feature"};return(r.id===0||r.id)&&(l.id=r.id),r.bbox&&(l.bbox=r.bbox),l.properties=e||{},l.geometry=h,l}function yl(h,e,r={}){if(!h)throw new Error("coordinates is required");if(!Array.isArray(h))throw new Error("coordinates must be an Array");if(h.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Z1(h[0])||!Z1(h[1]))throw new Error("coordinates must contain numbers");return UE({type:"Point",coordinates:h},e,r)}function qE(h,e="kilometers"){let r=X1[e];if(!r)throw new Error(e+" units is invalid");return h*r}function $E(h,e="kilometers"){let r=X1[e];if(!r)throw new Error(e+" units is invalid");return h/r}function H1(h){return h%(2*Math.PI)*180/Math.PI}function _l(h){return h%360*Math.PI/180}function ef(h,e="kilometers",r="kilometers"){if(!(h>=0))throw new Error("length must be a positive number");return qE($E(h,e),r)}function Z1(h){return!isNaN(h)&&h!==null&&!Array.isArray(h)}function Y1(h){return h!==null&&typeof h=="object"&&!Array.isArray(h)}function Wu(h,e,r){if(h!==null)for(var l,c,o,_,v,w,T,I=0,L=0,O,U=h.type,J=U==="FeatureCollection",ce=U==="Feature",he=J?h.features.length:1,me=0;me<he;me++){T=J?h.features[me].geometry:ce?h.geometry:h,O=T?T.type==="GeometryCollection":!1,v=O?T.geometries.length:1;for(var ve=0;ve<v;ve++){var we=0,Me=0;if(_=O?T.geometries[ve]:T,_!==null){w=_.coordinates;var Re=_.type;switch(I=r&&(Re==="Polygon"||Re==="MultiPolygon")?1:0,Re){case null:break;case"Point":if(e(w,L,me,we,Me)===!1)return!1;L++,we++;break;case"LineString":case"MultiPoint":for(l=0;l<w.length;l++){if(e(w[l],L,me,we,Me)===!1)return!1;L++,Re==="MultiPoint"&&we++}Re==="LineString"&&we++;break;case"Polygon":case"MultiLineString":for(l=0;l<w.length;l++){for(c=0;c<w[l].length-I;c++){if(e(w[l][c],L,me,we,Me)===!1)return!1;L++}Re==="MultiLineString"&&we++,Re==="Polygon"&&Me++}Re==="Polygon"&&we++;break;case"MultiPolygon":for(l=0;l<w.length;l++){for(Me=0,c=0;c<w[l].length;c++){for(o=0;o<w[l][c].length-I;o++){if(e(w[l][c][o],L,me,we,Me)===!1)return!1;L++}Me++}we++}break;case"GeometryCollection":for(l=0;l<_.geometries.length;l++)if(Wu(_.geometries[l],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function K1(h,e={}){let r=0,l=0,c=0;return Wu(h,function(o){r+=o[0],l+=o[1],c++},!0),yl([r/c,l/c],e.properties)}function Hs(h){if(!h)throw new Error("coord is required");if(!Array.isArray(h)){if(h.type==="Feature"&&h.geometry!==null&&h.geometry.type==="Point")return[...h.geometry.coordinates];if(h.type==="Point")return[...h.coordinates]}if(Array.isArray(h)&&h.length>=2&&!Array.isArray(h[0])&&!Array.isArray(h[1]))return[...h];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function J1(h){if(Array.isArray(h))return h;if(h.type==="Feature"){if(h.geometry!==null)return h.geometry.coordinates}else if(h.coordinates)return h.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function ew(h,e,r={}){let l;return r.final?l=Q1(Hs(e),Hs(h)):l=Q1(Hs(h),Hs(e)),l>180?-(360-l):l}function Q1(h,e){let r=_l(h[1]),l=_l(e[1]),c=_l(e[0]-h[0]);c>Math.PI&&(c-=2*Math.PI),c<-Math.PI&&(c+=2*Math.PI);let o=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),_=Math.atan2(c,o);return(H1(_)+360)%360}function tw(h,e,r={}){let l=Hs(h),c=Hs(e);c[0]+=c[0]-l[0]>180?-360:l[0]-c[0]>180?360:0;let o=WE(l,c);return ef(o,"meters",r.units)}function WE(h,e,r){r=r===void 0?Mr:Number(r);let l=r,c=h[1]*Math.PI/180,o=e[1]*Math.PI/180,_=o-c,v=Math.abs(e[0]-h[0])*Math.PI/180;v>Math.PI&&(v-=2*Math.PI);let w=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(c/2+Math.PI/4)),T=Math.abs(w)>1e-11?_/w:Math.cos(c);return Math.sqrt(_*_+T*T*v*v)*l}function iw(h,e,r,l={}){let c=e<0,o=ef(Math.abs(e),l.units,"meters");c&&(o=-Math.abs(o));let _=Hs(h),v=ZE(_,o,r);return v[0]+=v[0]-_[0]>180?-360:_[0]-v[0]>180?360:0,yl(v,l.properties)}function ZE(h,e,r,l){l=l===void 0?Mr:Number(l);let c=e/l,o=h[0]*Math.PI/180,_=_l(h[1]),v=_l(r),w=c*Math.cos(v),T=_+w;Math.abs(T)>Math.PI/2&&(T=T>0?Math.PI-T:-Math.PI-T);let I=Math.log(Math.tan(T/2+Math.PI/4)/Math.tan(_/2+Math.PI/4)),L=Math.abs(I)>1e-11?w/I:Math.cos(_),O=c*Math.sin(v)/L;return[((o+O)*180/Math.PI+540)%360-180,T*180/Math.PI]}function rw(h){if(!h)throw new Error("geojson is required");switch(h.type){case"Feature":return nw(h);case"FeatureCollection":return XE(h);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return G_(h);default:throw new Error("unknown GeoJSON type")}}function nw(h){let e={type:"Feature"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:e[r]=h[r]}}),e.properties=sw(h.properties),h.geometry==null?e.geometry=null:e.geometry=G_(h.geometry),e}function sw(h){let e={};return h&&Object.keys(h).forEach(r=>{let l=h[r];typeof l=="object"?l===null?e[r]=null:Array.isArray(l)?e[r]=l.map(c=>c):e[r]=sw(l):e[r]=l}),e}function XE(h){let e={type:"FeatureCollection"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"features":return;default:e[r]=h[r]}}),e.features=h.features.map(r=>nw(r)),e}function G_(h){let e={type:h.type};return h.bbox&&(e.bbox=h.bbox),h.type==="GeometryCollection"?(e.geometries=h.geometries.map(r=>G_(r)),e):(e.coordinates=ow(h.coordinates),e)}function ow(h){let e=h;return typeof e[0]!="object"?e.slice():e.map(r=>ow(r))}function HE(h,e,r){if(r=r||{},!Y1(r))throw new Error("options is invalid");let l=r.pivot,c=r.mutate;if(!h)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");if(e===0)return h;let o=l??K1(h);return(c===!1||c===void 0)&&(h=rw(h)),Wu(h,function(_){let w=ew(o,_)+e,T=tw(o,_),I=J1(iw(o,T,w));_[0]=I[0],_[1]=I[1]}),h}var U_=HE;var YE=(h,e=1)=>{let{height:r,width:l}=h.getCanvas(),c=h.unproject({x:0,y:0}),o=h.unproject({x:0,y:r/e}),_=h.unproject({x:l/e,y:r/e}),v=h.unproject({x:l/e,y:0});return[[c.lng,c.lat],[v.lng,v.lat],[_.lng,_.lat],[o.lng,o.lat]]},tf=YE;var KE=h=>{let e=h.getBounds().toArray(),r=or(e[0]),l=or(e[1]),c=[...r,...l],{width:o,height:_}=h.getCanvas(),v=_i(c)/o,w=$i(c)/_;return Math.max(v,w)},aw=KE;var q_=class extends Qp{#e;constructor(e={}){let r=e?.id||"realtime";super({...e,id:"realtime-custom-"+r}),this.#e=r,this.engine=new Hp({getViewState:this.getViewState.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...e}),this.sourceId=this.#e,this.source={animate:!0,attribution:e.attribution?.join(", "),canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],loaded:!0,type:"canvas"},this.layer={id:this.#e,layout:{visibility:"visible"},paint:{"raster-fade-duration":0,"raster-opacity":1,"raster-resampling":"nearest"},source:this.sourceId,type:"raster"},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}getViewState(){if(!this.map)return{};this.pixelRatio||(this.pixelRatio=1);let{height:e,width:r}=this.map.getCanvas(),l=this.map.getCenter(),c=this.map.unproject({x:0,y:e/this.pixelRatio}),o=this.map.unproject({x:r/this.pixelRatio,y:0}),_=U_(yl([c.lng,c.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,v=U_(yl([o.lng,o.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,w=[...or(_),...or(v)],T=_i(w)/(r/this.pixelRatio),I=$i(w)/(e/this.pixelRatio),L=Math.max(T,I);return{center:or([l.lng,l.lat]),extent:w,pixelRatio:this.pixelRatio,resolution:L,rotation:-(this.map.getBearing()*Math.PI)/180,size:[r/this.pixelRatio,e/this.pixelRatio],visible:!0,zoom:this.map.getZoom()-1}}onAdd(e,r){super.onAdd(e,r),this.engine.attachToMap(),e.isStyleLoaded()&&this.onLoad(),e.on("load",this.onLoad)}onLoad(){this.map?.getSource(this.sourceId)||this.map?.addSource(this.sourceId,this.source),this.map?.getLayer(this.layer.id)||this.map?.addLayer(this.layer,this.id),this.start()}onMove(){this.engine.renderTrajectories()}onMoveEnd(){this.engine.renderTrajectories(),this.engine.isUpdateBboxOnMoveEnd&&this.engine.setBbox()}onRealtimeEngineRender(){if(this.map?.style){let e=tf(this.map,this.pixelRatio),r=this.map.getSource(this.sourceId);r&&r.setCoordinates(e)}}onRemove(e,r){this.engine.detachFromMap(),this.stop(),e.off("load",this.onLoad),e.getLayer(this.layer.id)&&e.removeLayer(this.layer.id),e.getSource(this.sourceId)&&e.removeSource(this.sourceId),super.onRemove(e,r)}onZoomEnd(){this.engine.onZoomEnd()}start(){this.engine.start(),this.map?.on("move",this.onMove),this.map?.on("moveend",this.onMoveEnd),this.map?.on("zoomend",this.onZoomEnd)}stop(){this.engine.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}get canvas(){return this.engine.canvas}get pixelRatio(){return this.engine.pixelRatio||1}set pixelRatio(e){this.engine.pixelRatio=e||1}},lw=q_;var $_={ol:Jp,maplibre:rf};typeof window<"u"&&(window.mbt=$_);var Z6=$_;})();
|
|
586
586
|
/*! Bundled license information:
|
|
587
587
|
|
|
588
588
|
maplibre-gl/dist/maplibre-gl.js:
|