mobility-toolbox-js 3.0.0-beta.18 → 3.0.0-beta.19
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/mbt.js +7 -7
- package/mbt.js.map +2 -2
- package/mbt.min.js +1 -1
- package/mbt.min.js.map +3 -3
- package/ol/layers/MaplibreLayer.js +3 -1
- package/ol/renderers/MaplibreStyleLayerRenderer.js +6 -6
- package/package.json +1 -1
package/mbt.min.js
CHANGED
|
@@ -585,7 +585,7 @@ uniform ${O} ${D} u_${G};
|
|
|
585
585
|
`||A===S){o=Math.max(o,m),l.push(m),m=0,g+=b,b=0;continue}let R=e[A+1]||s.font,j=ng(R,M);t.push(j),m+=j;let W=xz(R);a.push(W),b=Math.max(b,W)}return{width:o,height:g,widths:t,heights:a,lineWidths:l}}function hI(s,e,t,a,l,o,m,g,b,A,S){s.save(),t!==1&&(s.globalAlpha===void 0?s.globalAlpha=M=>M.globalAlpha*=t:s.globalAlpha*=t),e&&s.transform.apply(s,e),a.contextInstructions?(s.translate(b,A),s.scale(S[0],S[1]),bz(a,s)):S[0]<0||S[1]<0?(s.translate(b,A),s.scale(S[0],S[1]),s.drawImage(a,l,o,m,g,0,0,m,g)):s.drawImage(a,l,o,m,g,b,A,m*S[0],g*S[1]),s.restore()}function bz(s,e){let t=s.contextInstructions;for(let a=0,l=t.length;a<l;a+=2)Array.isArray(t[a+1])?e[t[a]].apply(e,t[a+1]):e[t[a]]=t[a+1]}var Ux=class s extends ig{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()?Rt.LOADING:Rt.LOADED,this.imageState_===Rt.LOADING&&this.ready().then(()=>this.imageState_=Rt.LOADED),this.render()}clone(){let e=this.getScale(),t=new s({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 t.setOpacity(this.getOpacity()),t}getAnchor(){let e=this.size_,t=this.getDisplacement(),a=this.getScaleArray();return[e[0]/2-t[0]/a[0],e[1]/2+t[1]/a[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 t=this.canvases_[e];if(!t){let a=this.renderOptions_,l=Yr(a.size*e,a.size*e);this.draw_(a,l,e),t=l.canvas,this.canvases_[e]=t}return t}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,t,a){if(t===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return t;let l=this.radius_,o=this.radius2_===void 0?l:this.radius2_;if(l<o){let xe=l;l=o,o=xe}let m=this.radius2_===void 0?this.points_:this.points_*2,g=2*Math.PI/m,b=o*Math.sin(g),A=Math.sqrt(o*o-b*b),S=l-A,M=Math.sqrt(b*b+S*S),R=M/b;if(e==="miter"&&R<=a)return R*t;let j=t/2/R,W=t/2*(S/M),$=Math.sqrt((l+j)*(l+j)+W*W)-l;if(this.radius2_===void 0||e==="bevel")return $*2;let X=l*Math.sin(g),se=Math.sqrt(l*l-X*X),me=o-se,pe=Math.sqrt(X*X+me*me)/X;if(pe<=a){let xe=pe*t/2-o-l;return 2*Math.max($,xe)}return $*2}createRenderOptions(){let e=ms,t=gs,a=0,l=null,o=0,m,g=0;this.stroke_&&(m=Nn(this.stroke_.getColor()??ia),g=this.stroke_.getWidth()??oa,l=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset()??0,t=this.stroke_.getLineJoin()??gs,e=this.stroke_.getLineCap()??ms,a=this.stroke_.getMiterLimit()??ra);let b=this.calculateLineJoinSize_(t,g,a),A=Math.max(this.radius_,this.radius2_||0),S=Math.ceil(2*A+b);return{strokeStyle:m,strokeWidth:g,size:S,lineCap:e,lineDash:l,lineDashOffset:o,lineJoin:t,miterLimit:a}}render(){this.renderOptions_=this.createRenderOptions();let e=this.renderOptions_.size;this.canvases_={},this.hitDetectionCanvas_=null,this.size_=[e,e]}draw_(e,t,a){if(t.scale(a,a),t.translate(e.size/2,e.size/2),this.createPath_(t),this.fill_){let l=this.fill_.getColor();l===null&&(l=di),t.fillStyle=Nn(l),t.fill()}e.strokeStyle&&(t.strokeStyle=e.strokeStyle,t.lineWidth=e.strokeWidth,e.lineDash&&(t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset),t.lineCap=e.lineCap,t.lineJoin=e.lineJoin,t.miterLimit=e.miterLimit,t.stroke())}createHitDetectionCanvas_(e){let t;if(this.fill_){let a=this.fill_.getColor(),l=0;typeof a=="string"&&(a=ta(a)),a===null?l=1:Array.isArray(a)&&(l=a.length===4?a[3]:1),l===0&&(t=Yr(e.size,e.size),this.drawHitDetectionCanvas_(e,t))}return t?t.canvas:this.getImage(1)}createPath_(e){let t=this.points_,a=this.radius_;if(t===1/0)e.arc(0,0,a,0,2*Math.PI);else{let l=this.radius2_===void 0?a:this.radius2_;this.radius2_!==void 0&&(t*=2);let o=this.angle_-Math.PI/2,m=2*Math.PI/t;for(let g=0;g<t;g++){let b=o+g*m,A=g%2===0?a:l;e.lineTo(A*Math.cos(b),A*Math.sin(b))}e.closePath()}}drawHitDetectionCanvas_(e,t){t.translate(e.size/2,e.size/2),this.createPath_(t),t.fillStyle=di,t.fill(),e.strokeStyle&&(t.strokeStyle=e.strokeStyle,t.lineWidth=e.strokeWidth,e.lineDash&&(t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset),t.lineJoin=e.lineJoin,t.miterLimit=e.miterLimit,t.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}},sg=Ux;var Gx=class s extends sg{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(),t=new s({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 t.setOpacity(this.getOpacity()),t}setRadius(e){this.radius_=e,this.render()}},Vn=Gx;var Xa=class s{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=pI,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 s({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(t){return t.get(e)}:e?e!==void 0&&(this.geometryFunction_=function(){return e}):this.geometryFunction_=pI,this.geometry_=e}setZIndex(e){this.zIndex_=e}};function dI(s){let e;if(typeof s=="function")e=s;else{let t;Array.isArray(s)?t=s:(xr(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),t=[s]),e=function(){return t}}return e}var Vx=null;function qx(s,e){if(!Vx){let t=new Gi({color:"rgba(255,255,255,0.4)"}),a=new pi({color:"#3399CC",width:1.25});Vx=[new Xa({image:new Vn({fill:t,stroke:a,radius:5}),fill:t,stroke:a})]}return Vx}function fI(){let s={},e=[255,255,255,1],t=[0,153,255,1],a=3;return s.Polygon=[new Xa({fill:new Gi({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new Xa({stroke:new pi({color:e,width:a+2})}),new Xa({stroke:new pi({color:t,width:a})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new Xa({image:new Vn({radius:a*2,fill:new Gi({color:t}),stroke:new pi({color:e,width:a/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function pI(s){return s.getGeometry()}var Vi=Xa;var wz="#333",$x=class s{constructor(e){e=e||{},this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.scale_=e.scale,this.scaleArray_=Wa(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 Gi({color:wz}),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 s({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_=Wa(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}},mI=$x;var TI=Lo(Hx(),1);function gI(s,e,t,a){return t!==void 0&&a!==void 0?[t/s,a/e]:t!==void 0?t/s:a!==void 0?a/e:1}var Xx=class s extends ig{constructor(e){e=e||{};let t=e.opacity!==void 0?e.opacity:1,a=e.rotation!==void 0?e.rotation:0,l=e.scale!==void 0?e.scale:1,o=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:t,rotation:a,scale:l,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 m=e.img!==void 0?e.img:null,g=e.src;xr(!(g!==void 0&&m),"`image` and `src` cannot be provided at the same time"),(g===void 0||g.length===0)&&m&&(g=m.src||Nt(m)),xr(g!==void 0&&g.length>0,"A defined and non-empty `src` or `image` must be provided"),xr(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let b;if(e.src!==void 0?b=Rt.IDLE:m!==void 0&&("complete"in m?m.complete?b=m.src?Rt.LOADED:Rt.IDLE:b=Rt.LOADING:b=Rt.LOADED),this.color_=e.color!==void 0?ta(e.color):null,this.iconImage_=Mu(m,g,this.crossOrigin_,b,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,e.width!==void 0||e.height!==void 0){let A,S;if(e.size)[A,S]=e.size;else{let M=this.getImage(1);if(M.width&&M.height)A=M.width,S=M.height;else if(M instanceof HTMLImageElement){this.initialOptions_=e;let R=()=>{if(this.unlistenImageChange(R),!this.initialOptions_)return;let j=this.iconImage_.getSize();this.setScale(gI(j[0],j[1],e.width,e.height))};this.listenImageChange(R);return}}A!==void 0&&this.setScale(gI(A,S,e.width,e.height))}}clone(){let e,t,a;return this.initialOptions_?(t=this.initialOptions_.width,a=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new s({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:t,height:a,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 l=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!l)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=l[0]),this.anchorYUnits_=="fraction"&&(e[1]*=l[1])}if(this.anchorOrigin_!="top-left"){if(!l)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+l[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+l[1])}this.normalizedAnchor_=e}let t=this.getDisplacement(),a=this.getScaleArray();return[e[0]-t[0]/a[0],e[1]+t[1]/a[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 t=this.getSize(),a=this.iconImage_.getSize();if(!t||!a)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=a[0]-t[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=a[1]-t[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()==Rt.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()==Rt.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(Er.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(Er.CHANGE,e)}ready(){return this.iconImage_.ready()}},Pd=Xx;var Zl=0,ku=0,Br=1<<Zl++,mt=1<<Zl++,qn=1<<Zl++,si=1<<Zl++,Wo=1<<Zl++,Cd=1<<Zl++,hn=Math.pow(2,Zl)-1,_I={[Br]:"boolean",[mt]:"number",[qn]:"string",[si]:"color",[Wo]:"number[]",[Cd]:"size"},Sz=Object.keys(_I).map(Number).sort(Oo);function qi(s){let e=[];for(let t of Sz)Az(s,t)&&e.push(_I[t]);return e.length===0?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function Az(s,e){return(s&e)===e}function Zo(s,e){return!!(s&e)}function ag(s,e){return s===e}var $o=class{constructor(e,t){this.type=e,this.value=t}},Yx=class{constructor(e,t,...a){this.type=e,this.operator=t,this.args=a}};function Kx(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,style:{}}}function Ez(s){switch(s){case"string":return qn;case"color":return si;case"number":return mt;case"boolean":return Br;case"number[]":return Wo;default:throw new Error(`Unrecognized type hint: ${s}`)}}function cr(s,e,t){switch(typeof s){case"boolean":return new $o(Br,s);case"number":return new $o(t===Cd?Cd:mt,s);case"string":{let l=qn;return oI(s)&&(l|=si),ag(l&t,ku)||(l&=t),new $o(l,s)}default:}if(!Array.isArray(s))throw new Error("Expression must be an array or a primitive value");if(s.length===0)throw new Error("Empty expression");if(typeof s[0]=="string")return zz(s,e,t);for(let l of s)if(typeof l!="number")throw new Error("Expected an array of numbers");let a=Wo;return s.length===2?a|=Cd:(s.length===3||s.length===4)&&(a|=si),t&&(a&=t),new $o(a,s)}var Le={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",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"},Iz={[Le.Get]:Dt(([s,e])=>e!==void 0?Ez(e.value):hn,Bt(1,2),Pz),[Le.Var]:Dt(([s])=>s.type,Bt(1,1),Tz),[Le.Id]:Dt(mt|qn,Td,Cz),[Le.Concat]:Dt(qn,Bt(2,1/0),ir(hn)),[Le.GeometryType]:Dt(qn,Td,Mz),[Le.Resolution]:Dt(mt,Td),[Le.Zoom]:Dt(mt,Td),[Le.Time]:Dt(mt,Td),[Le.Any]:Dt(Br,Bt(2,1/0),ir(Br)),[Le.All]:Dt(Br,Bt(2,1/0),ir(Br)),[Le.Not]:Dt(Br,Bt(1,1),ir(Br)),[Le.Equal]:Dt(Br,Bt(2,2),ir(hn),Ya),[Le.NotEqual]:Dt(Br,Bt(2,2),ir(hn),Ya),[Le.GreaterThan]:Dt(Br,Bt(2,2),ir(hn),Ya),[Le.GreaterThanOrEqualTo]:Dt(Br,Bt(2,2),ir(hn),Ya),[Le.LessThan]:Dt(Br,Bt(2,2),ir(hn),Ya),[Le.LessThanOrEqualTo]:Dt(Br,Bt(2,2),ir(hn),Ya),[Le.Multiply]:Dt(s=>{let e=mt|si;for(let t=0;t<s.length;t++)e&=s[t].type;return e},Bt(2,1/0),ir(mt|si),Ya),[Le.Coalesce]:Dt(s=>{let e=hn;for(let t=1;t<s.length;t+=2)e&=s[t].type;return e&=s[s.length-1].type,e},Bt(2,1/0),ir(hn),Ya),[Le.Divide]:Dt(mt,Bt(2,2),ir(mt)),[Le.Add]:Dt(mt,Bt(2,1/0),ir(mt)),[Le.Subtract]:Dt(mt,Bt(2,2),ir(mt)),[Le.Clamp]:Dt(mt,Bt(3,3),ir(mt)),[Le.Mod]:Dt(mt,Bt(2,2),ir(mt)),[Le.Pow]:Dt(mt,Bt(2,2),ir(mt)),[Le.Abs]:Dt(mt,Bt(1,1),ir(mt)),[Le.Floor]:Dt(mt,Bt(1,1),ir(mt)),[Le.Ceil]:Dt(mt,Bt(1,1),ir(mt)),[Le.Round]:Dt(mt,Bt(1,1),ir(mt)),[Le.Sin]:Dt(mt,Bt(1,1),ir(mt)),[Le.Cos]:Dt(mt,Bt(1,1),ir(mt)),[Le.Atan]:Dt(mt,Bt(1,2),ir(mt)),[Le.Sqrt]:Dt(mt,Bt(1,1),ir(mt)),[Le.Match]:Dt(s=>{let e=hn;for(let t=2;t<s.length;t+=2)e&=s[t].type;return e&=s[s.length-1].type,e},Bt(4,1/0),yI,kz),[Le.Between]:Dt(Br,Bt(3,3),ir(mt)),[Le.Interpolate]:Dt(s=>{let e=si|mt;for(let t=3;t<s.length;t+=2)e&=s[t].type;return e},Bt(6,1/0),yI,Fz),[Le.Case]:Dt(s=>{let e=hn;for(let t=1;t<s.length;t+=2)e&=s[t].type;return e&=s[s.length-1].type,e},Bt(3,1/0),Rz,Lz),[Le.In]:Dt(Br,Bt(2,2),Dz),[Le.Number]:Dt(mt,Bt(1,1/0),ir(hn)),[Le.String]:Dt(qn,Bt(1,1/0),ir(hn)),[Le.Array]:Dt(s=>s.length===2?Wo|Cd:s.length===3||s.length===4?Wo|si:Wo,Bt(1,1/0),ir(mt)),[Le.Color]:Dt(si,Bt(1,4),ir(mt)),[Le.Band]:Dt(mt,Bt(1,3),ir(mt)),[Le.Palette]:Dt(si,Bt(2,2),Oz),[Le.ToString]:Dt(qn,Bt(1,1),ir(Br|mt|qn|si))};function Pz(s,e){let t=cr(s[1],e);if(!(t instanceof $o))throw new Error("Expected a literal argument for get operation");if(typeof t.value!="string")throw new Error("Expected a string argument for get operation");if(e.properties.add(t.value),s.length===3){let a=cr(s[2],e);return[t,a]}return[t]}function Tz(s,e,t,a){let l=s[1];if(typeof l!="string")throw new Error("Expected a string argument for var operation");if(e.variables.add(l),!("variables"in e.style)||e.style.variables[l]===void 0)return[new $o(hn,l)];let o=e.style.variables[l],m=cr(o,e);if(m.value=l,a&&!Zo(a,m.type))throw new Error(`The variable ${l} has type ${qi(m.type)} but the following type was expected: ${qi(a)}`);return[m]}function Cz(s,e){e.featureId=!0}function Mz(s,e){e.geometryType=!0}function Td(s,e){let t=s[0];if(s.length!==1)throw new Error(`Expected no arguments for ${t} operation`);return[]}function Bt(s,e){return function(t,a){let l=t[0],o=t.length-1;if(s===e){if(o!==s){let m=s===1?"":"s";throw new Error(`Expected ${s} argument${m} for ${l}, got ${o}`)}}else if(o<s||o>e){let m=e===1/0?`${s} or more`:`${s} to ${e}`;throw new Error(`Expected ${m} arguments for ${l}, got ${o}`)}}}function ir(s){return function(e,t){let a=e[0],l=e.length-1,o=new Array(l);for(let m=0;m<l;++m){let g=cr(e[m+1],t);if(!Zo(s,g.type)){let b=qi(s),A=qi(g.type);throw new Error(`Unexpected type for argument ${m} of ${a} operation, got ${b} but expected ${A}`)}g.type&=s,o[m]=g}return o}}function Ya(s,e,t){let a=s[0],l=s.length-1,o=hn;for(let g=0;g<t.length;++g)o&=t[g].type;if(o===ku)throw new Error(`No common type could be found for arguments of ${a} operation`);let m=new Array(l);for(let g=0;g<l;++g)m[g]=cr(s[g+1],e,o);return m}function Rz(s,e){let t=s[0],a=s.length-1;if(a%2===0)throw new Error(`An odd amount of arguments was expected for operation ${t}, got ${JSON.stringify(a)} instead`)}function yI(s,e){let t=s[0],a=s.length-1;if(a%2===1)throw new Error(`An even amount of arguments was expected for operation ${t}, got ${JSON.stringify(a)} instead`)}function kz(s,e,t,a){let l=s.length-1,m=cr(s[1],e).type,g=cr(s[s.length-1],e),b=a!==void 0?a&g.type:g.type,A=new Array(l-2);for(let M=0;M<l-2;M+=2){let R=cr(s[M+2],e),j=cr(s[M+3],e);m&=R.type,b&=j.type,A[M]=R,A[M+1]=j}let S=qn|mt|Br;if(!Zo(S,m))throw new Error(`Expected an input of type ${qi(S)} for the interpolate operation, got ${qi(m)} instead`);if(m&=S,ag(b,ku))throw new Error("Could not find a common output type for the following match operation: "+JSON.stringify(s));for(let M=0;M<l-2;M+=2){let R=cr(s[M+2],e,m),j=cr(s[M+3],e,b);A[M]=R,A[M+1]=j}return[cr(s[1],e,m),...A,cr(s[s.length-1],e,b)]}function Fz(s,e,t,a){let l=s[1],o;switch(l[0]){case"linear":o=1;break;case"exponential":if(o=l[1],typeof o!="number")throw new Error(`Expected a number base for exponential interpolation, got ${JSON.stringify(o)} instead`);break;default:o=null}if(!o)throw new Error(`Invalid interpolation type: ${JSON.stringify(l)}`);o=cr(o,e);let m=cr(s[2],e);if(!Zo(mt,m.type))throw new Error(`Expected an input of type number for the interpolate operation, got ${qi(m.type)} instead`);m=cr(s[2],e,mt);let g=new Array(s.length-3);for(let b=0;b<g.length;b+=2){let A=cr(s[b+3],e);if(!Zo(mt,A.type))throw new Error(`Expected all stop input values in the interpolate operation to be of type number, got ${qi(A.type)} at position ${b+2} instead`);let S=cr(s[b+4],e);if(!Zo(mt|si,S.type))throw new Error(`Expected all stop output values in the interpolate operation to be a number or color, got ${qi(S.type)} at position ${b+3} instead`);A=cr(s[b+3],e,mt),S=cr(s[b+4],e,mt|si),g[b]=A,g[b+1]=S}return[o,m,...g]}function Lz(s,e,t,a){let l=cr(s[s.length-1],e,a),o=a!==void 0?a&l.type:l.type,m=new Array(s.length-1);for(let g=0;g<m.length-1;g+=2){let b=cr(s[g+1],e),A=cr(s[g+2],e,a);if(!Zo(Br,b.type))throw new Error(`Expected all conditions in the case operation to be of type boolean, got ${qi(b.type)} at position ${g} instead`);o&=A.type,m[g]=b,m[g+1]=A}if(ag(o,ku))throw new Error("Could not find a common output type for the following case operation: "+JSON.stringify(s));for(let g=0;g<m.length-1;g+=2)m[g+1]=cr(s[g+2],e,o);return m[m.length-1]=cr(s[s.length-1],e,o),m}function Dz(s,e){let t=s[2];if(!Array.isArray(t))throw new Error('The "in" operator was provided a literal value which was not an array as second argument.');if(typeof t[0]=="string"){if(t[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(t[1]))throw new Error('The "in" operator was provided a literal value which was not an array as second argument.');t=t[1]}let a=qn|mt,l=new Array(t.length);for(let m=0;m<l.length;m++){let g=cr(t[m],e);a&=g.type,l[m]=g}if(ag(a,ku))throw new Error("Could not find a common type for the following in operation: "+JSON.stringify(s));return[cr(s[1],e,a),...l]}function Oz(s,e){let t=cr(s[1],e,mt);if(t.type!==mt)throw new Error(`The first argument of palette must be an number, got ${qi(t.type)} instead`);let a=s[2];if(!Array.isArray(a))throw new Error("The second argument of palette must be an array");let l=new Array(a.length);for(let o=0;o<l.length;o++){let m=cr(a[o],e,si);if(!(m instanceof $o))throw new Error(`The palette color at index ${o} must be a literal value`);if(!Zo(m.type,si))throw new Error(`The palette color at index ${o} should be of type color, got ${qi(m.type)} instead`);l[o]=m}return[t,...l]}function Dt(s,...e){return function(t,a,l){let o=t[0],m=[];for(let b=0;b<e.length;b++)m=e[b](t,a,m,l)||m;let g=typeof s=="function"?s(m):s;if(l!==void 0){if(!Zo(g,l))throw new Error(`The following expression was expected to return ${qi(l)}, but returns ${qi(g)} instead: ${JSON.stringify(t)}`);g&=l}if(g===ku)throw new Error(`No matching type was found for the following expression: ${JSON.stringify(t)}`);return new Yx(g,o,...m)}}function zz(s,e,t){let a=s[0],l=Iz[a];if(!l)throw new Error(`Unknown operator: ${a}`);return l(s,e,t)}function Jx(s){if(!s)return"";let e=s.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 Jx(s.getGeometries()[0]);default:return""}}function Qx(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function ys(s,e,t){let a=cr(s,t);if(!Zo(e,a.type)){let l=qi(e),o=qi(a.type);throw new Error(`Expected expression to be of type ${l}, got ${o}`)}return Ho(a,t)}function Ho(s,e){if(s instanceof $o){if(s.type===si&&typeof s.value=="string"){let a=rg(s.value);return function(){return a}}return function(){return s.value}}let t=s.operator;switch(t){case Le.Number:case Le.String:case Le.Coalesce:return Bz(s,e);case Le.Get:case Le.Var:return jz(s,e);case Le.Id:return a=>a.featureId;case Le.GeometryType:return a=>a.geometryType;case Le.Concat:{let a=s.args.map(l=>Ho(l,e));return l=>"".concat(...a.map(o=>o(l).toString()))}case Le.Resolution:return a=>a.resolution;case Le.Any:case Le.All:case Le.Between:case Le.In:case Le.Not:return Uz(s,e);case Le.Equal:case Le.NotEqual:case Le.LessThan:case Le.LessThanOrEqualTo:case Le.GreaterThan:case Le.GreaterThanOrEqualTo:return Nz(s,e);case Le.Multiply:case Le.Divide:case Le.Add:case Le.Subtract:case Le.Clamp:case Le.Mod:case Le.Pow:case Le.Abs:case Le.Floor:case Le.Ceil:case Le.Round:case Le.Sin:case Le.Cos:case Le.Atan:case Le.Sqrt:return Gz(s,e);case Le.Case:return Vz(s,e);case Le.Match:return qz(s,e);case Le.Interpolate:return $z(s,e);case Le.ToString:return Wz(s,e);default:throw new Error(`Unsupported operator ${t}`)}}function Bz(s,e){let t=s.operator,a=s.args.length,l=new Array(a);for(let o=0;o<a;++o)l[o]=Ho(s.args[o],e);switch(t){case Le.Coalesce:return o=>{for(let m=0;m<a;++m){let g=l[m](o);if(typeof g<"u"&&g!==null)return g}throw new Error("Expected one of the values to be non-null")};case Le.Number:case Le.String:return o=>{for(let m=0;m<a;++m){let g=l[m](o);if(typeof g===t)return g}throw new Error(`Expected one of the values to be a ${t}`)};default:throw new Error(`Unsupported assertion operator ${t}`)}}function jz(s,e){let a=s.args[0].value;switch(s.operator){case Le.Get:return l=>l.properties[a];case Le.Var:return l=>l.variables[a];default:throw new Error(`Unsupported accessor operator ${s.operator}`)}}function Nz(s,e){let t=s.operator,a=Ho(s.args[0],e),l=Ho(s.args[1],e);switch(t){case Le.Equal:return o=>a(o)===l(o);case Le.NotEqual:return o=>a(o)!==l(o);case Le.LessThan:return o=>a(o)<l(o);case Le.LessThanOrEqualTo:return o=>a(o)<=l(o);case Le.GreaterThan:return o=>a(o)>l(o);case Le.GreaterThanOrEqualTo:return o=>a(o)>=l(o);default:throw new Error(`Unsupported comparison operator ${t}`)}}function Uz(s,e){let t=s.operator,a=s.args.length,l=new Array(a);for(let o=0;o<a;++o)l[o]=Ho(s.args[o],e);switch(t){case Le.Any:return o=>{for(let m=0;m<a;++m)if(l[m](o))return!0;return!1};case Le.All:return o=>{for(let m=0;m<a;++m)if(!l[m](o))return!1;return!0};case Le.Between:return o=>{let m=l[0](o),g=l[1](o),b=l[2](o);return m>=g&&m<=b};case Le.In:return o=>{let m=l[0](o);for(let g=1;g<a;++g)if(m===l[g](o))return!0;return!1};case Le.Not:return o=>!l[0](o);default:throw new Error(`Unsupported logical operator ${t}`)}}function Gz(s,e){let t=s.operator,a=s.args.length,l=new Array(a);for(let o=0;o<a;++o)l[o]=Ho(s.args[o],e);switch(t){case Le.Multiply:return o=>{let m=1;for(let g=0;g<a;++g)m*=l[g](o);return m};case Le.Divide:return o=>l[0](o)/l[1](o);case Le.Add:return o=>{let m=0;for(let g=0;g<a;++g)m+=l[g](o);return m};case Le.Subtract:return o=>l[0](o)-l[1](o);case Le.Clamp:return o=>{let m=l[0](o),g=l[1](o);if(m<g)return g;let b=l[2](o);return m>b?b:m};case Le.Mod:return o=>l[0](o)%l[1](o);case Le.Pow:return o=>Math.pow(l[0](o),l[1](o));case Le.Abs:return o=>Math.abs(l[0](o));case Le.Floor:return o=>Math.floor(l[0](o));case Le.Ceil:return o=>Math.ceil(l[0](o));case Le.Round:return o=>Math.round(l[0](o));case Le.Sin:return o=>Math.sin(l[0](o));case Le.Cos:return o=>Math.cos(l[0](o));case Le.Atan:return a===2?o=>Math.atan2(l[0](o),l[1](o)):o=>Math.atan(l[0](o));case Le.Sqrt:return o=>Math.sqrt(l[0](o));default:throw new Error(`Unsupported numeric operator ${t}`)}}function Vz(s,e){let t=s.args.length,a=new Array(t);for(let l=0;l<t;++l)a[l]=Ho(s.args[l],e);return l=>{for(let o=0;o<t-1;o+=2)if(a[o](l))return a[o+1](l);return a[t-1](l)}}function qz(s,e){let t=s.args.length,a=new Array(t);for(let l=0;l<t;++l)a[l]=Ho(s.args[l],e);return l=>{let o=a[0](l);for(let m=1;m<t;m+=2)if(o===a[m](l))return a[m+1](l);return a[t-1](l)}}function $z(s,e){let t=s.args.length,a=new Array(t);for(let l=0;l<t;++l)a[l]=Ho(s.args[l],e);return l=>{let o=a[0](l),m=a[1](l),g,b;for(let A=2;A<t;A+=2){let S=a[A](l),M=a[A+1](l),R=Array.isArray(M);if(R&&(M=iI(M)),S>=m)return A===2?M:R?Zz(o,m,g,b,S,M):Md(o,m,g,b,S,M);g=S,b=M}return b}}function Wz(s,e){let t=s.operator,a=s.args.length,l=new Array(a);for(let o=0;o<a;++o)l[o]=Ho(s.args[o],e);switch(t){case Le.ToString:return o=>{let m=l[0](o);return s.args[0].type===si?Ed(m):m.toString()};default:throw new Error(`Unsupported convert operator ${t}`)}}function Md(s,e,t,a,l,o){let m=l-t;if(m===0)return a;let g=e-t,b=s===1?g/m:(Math.pow(s,g)-1)/(Math.pow(s,m)-1);return a+b*(o-a)}function Zz(s,e,t,a,l,o){if(l-t===0)return a;let g=Cx(a),b=Cx(o),A=b[2]-g[2];A>180?A-=360:A<-180&&(A+=360);let S=[Md(s,e,t,g[0],l,b[0]),Md(s,e,t,g[1],l,b[1]),g[2]+Md(s,e,t,0,l,A),Md(s,e,t,a[3],l,o[3])];return Mx(nI(S))}function Hz(s){return!0}function wI(s){let e=Kx(),t=Xz(s,e),a=Qx();return function(l,o){if(a.properties=l.getPropertiesInternal(),a.resolution=o,e.featureId){let m=l.getId();m!==void 0?a.featureId=m:a.featureId=null}return e.geometryType&&(a.geometryType=Jx(l.getGeometry())),t(a)}}function r0(s){let e=Kx(),t=s.length,a=new Array(t);for(let m=0;m<t;++m)a[m]=e0(s[m],e);let l=Qx(),o=new Array(t);return function(m,g){if(l.properties=m.getPropertiesInternal(),l.resolution=g,e.featureId){let A=m.getId();A!==void 0?l.featureId=A:l.featureId=null}let b=0;for(let A=0;A<t;++A){let S=a[A](l);S&&(o[b]=S,b+=1)}return o.length=b,o}}function Xz(s,e){let t=s.length,a=new Array(t);for(let l=0;l<t;++l){let o=s[l],m="filter"in o?ys(o.filter,Br,e):Hz,g;if(Array.isArray(o.style)){let b=o.style.length;g=new Array(b);for(let A=0;A<b;++A)g[A]=e0(o.style[A],e)}else g=[e0(o.style,e)];a[l]={filter:m,styles:g}}return function(l){let o=[],m=!1;for(let g=0;g<t;++g){let b=a[g].filter;if(b(l)&&!(s[g].else&&m)){m=!0;for(let A of a[g].styles){let S=A(l);S&&o.push(S)}}}return o}}function e0(s,e){let t=Rd(s,"",e),a=kd(s,"",e),l=Yz(s,e),o=Kz(s,e),m=$n(s,"z-index",e);if(!t&&!a&&!l&&!o&&!oo(s))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(s));let g=new Vi;return function(b){let A=!0;if(t){let S=t(b);S&&(A=!1),g.setFill(S)}if(a){let S=a(b);S&&(A=!1),g.setStroke(S)}if(l){let S=l(b);S&&(A=!1),g.setText(S)}if(o){let S=o(b);S&&(A=!1),g.setImage(S)}return m&&g.setZIndex(m(b)),A?null:g}}function Rd(s,e,t){let a;if(e+"fill-pattern-src"in s?a=tB(s,e+"fill-",t):a=i0(s,e+"fill-color",t),!a)return null;let l=new Gi;return function(o){let m=a(o);return m==="none"?null:(l.setColor(m),l)}}function kd(s,e,t){let a=$n(s,e+"stroke-width",t),l=i0(s,e+"stroke-color",t);if(!a&&!l)return null;let o=sa(s,e+"stroke-line-cap",t),m=sa(s,e+"stroke-line-join",t),g=SI(s,e+"stroke-line-dash",t),b=$n(s,e+"stroke-line-dash-offset",t),A=$n(s,e+"stroke-miter-limit",t),S=new pi;return function(M){if(l){let R=l(M);if(R==="none")return null;S.setColor(R)}if(a&&S.setWidth(a(M)),o){let R=o(M);if(R!=="butt"&&R!=="round"&&R!=="square")throw new Error("Expected butt, round, or square line cap");S.setLineCap(R)}if(m){let R=m(M);if(R!=="bevel"&&R!=="round"&&R!=="miter")throw new Error("Expected bevel, round, or miter line join");S.setLineJoin(R)}return g&&S.setLineDash(g(M)),b&&S.setLineDashOffset(b(M)),A&&S.setMiterLimit(A(M)),S}}function Yz(s,e){let t="text-",a=sa(s,t+"value",e);if(!a)return null;let l=Rd(s,t,e),o=Rd(s,t+"background-",e),m=kd(s,t,e),g=kd(s,t+"background-",e),b=sa(s,t+"font",e),A=$n(s,t+"max-angle",e),S=$n(s,t+"offset-x",e),M=$n(s,t+"offset-y",e),R=Fd(s,t+"overflow",e),j=sa(s,t+"placement",e),W=$n(s,t+"repeat",e),re=ug(s,t+"scale",e),$=Fd(s,t+"rotate-with-view",e),X=$n(s,t+"rotation",e),se=sa(s,t+"align",e),me=sa(s,t+"justify",e),_e=sa(s,t+"baseline",e),pe=SI(s,t+"padding",e),xe=hg(s,t+"declutter-mode"),Ee=new mI({declutterMode:xe});return function(Me){if(Ee.setText(a(Me)),l&&Ee.setFill(l(Me)),o&&Ee.setBackgroundFill(o(Me)),m&&Ee.setStroke(m(Me)),g&&Ee.setBackgroundStroke(g(Me)),b&&Ee.setFont(b(Me)),A&&Ee.setMaxAngle(A(Me)),S&&Ee.setOffsetX(S(Me)),M&&Ee.setOffsetY(M(Me)),R&&Ee.setOverflow(R(Me)),j){let Se=j(Me);if(Se!=="point"&&Se!=="line")throw new Error("Expected point or line for text-placement");Ee.setPlacement(Se)}if(W&&Ee.setRepeat(W(Me)),re&&Ee.setScale(re(Me)),$&&Ee.setRotateWithView($(Me)),X&&Ee.setRotation(X(Me)),se){let Se=se(Me);if(Se!=="left"&&Se!=="center"&&Se!=="right"&&Se!=="end"&&Se!=="start")throw new Error("Expected left, right, center, start, or end for text-align");Ee.setTextAlign(Se)}if(me){let Se=me(Me);if(Se!=="left"&&Se!=="right"&&Se!=="center")throw new Error("Expected left, right, or center for text-justify");Ee.setJustify(Se)}if(_e){let Se=_e(Me);if(Se!=="bottom"&&Se!=="top"&&Se!=="middle"&&Se!=="alphabetic"&&Se!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");Ee.setTextBaseline(Se)}return pe&&Ee.setPadding(pe(Me)),Ee}}function Kz(s,e){return"icon-src"in s?Jz(s,e):"shape-points"in s?Qz(s,e):"circle-radius"in s?eB(s,e):null}function Jz(s,e){let t="icon-",a=t+"src",l=AI(s[a],a),o=lg(s,t+"anchor",e),m=ug(s,t+"scale",e),g=$n(s,t+"opacity",e),b=lg(s,t+"displacement",e),A=$n(s,t+"rotation",e),S=Fd(s,t+"rotate-with-view",e),M=xI(s,t+"anchor-origin"),R=bI(s,t+"anchor-x-units"),j=bI(s,t+"anchor-y-units"),W=oB(s,t+"color"),re=iB(s,t+"cross-origin"),$=nB(s,t+"offset"),X=xI(s,t+"offset-origin"),se=cg(s,t+"width"),me=cg(s,t+"height"),_e=rB(s,t+"size"),pe=hg(s,t+"declutter-mode"),xe=new Pd({src:l,anchorOrigin:M,anchorXUnits:R,anchorYUnits:j,color:W,crossOrigin:re,offset:$,offsetOrigin:X,height:me,width:se,size:_e,declutterMode:pe});return function(Ee){return g&&xe.setOpacity(g(Ee)),b&&xe.setDisplacement(b(Ee)),A&&xe.setRotation(A(Ee)),S&&xe.setRotateWithView(S(Ee)),m&&xe.setScale(m(Ee)),o&&xe.setAnchor(o(Ee)),xe}}function Qz(s,e){let t="shape-",a=t+"points",l=t+"radius",o=t0(s[a],a),m=t0(s[l],l),g=Rd(s,t,e),b=kd(s,t,e),A=ug(s,t+"scale",e),S=lg(s,t+"displacement",e),M=$n(s,t+"rotation",e),R=Fd(s,t+"rotate-with-view",e),j=cg(s,t+"radius2"),W=cg(s,t+"angle"),re=hg(s,t+"declutter-mode"),$=new sg({points:o,radius:m,radius2:j,angle:W,declutterMode:re});return function(X){return g&&$.setFill(g(X)),b&&$.setStroke(b(X)),S&&$.setDisplacement(S(X)),M&&$.setRotation(M(X)),R&&$.setRotateWithView(R(X)),A&&$.setScale(A(X)),$}}function eB(s,e){let t="circle-",a=Rd(s,t,e),l=kd(s,t,e),o=$n(s,t+"radius",e),m=ug(s,t+"scale",e),g=lg(s,t+"displacement",e),b=$n(s,t+"rotation",e),A=Fd(s,t+"rotate-with-view",e),S=hg(s,t+"declutter-mode"),M=new Vn({radius:5,declutterMode:S});return function(R){return o&&M.setRadius(o(R)),a&&M.setFill(a(R)),l&&M.setStroke(l(R)),g&&M.setDisplacement(g(R)),b&&M.setRotation(b(R)),A&&M.setRotateWithView(A(R)),m&&M.setScale(m(R)),M}}function $n(s,e,t){if(!(e in s))return;let a=ys(s[e],mt,t);return function(l){return t0(a(l),e)}}function sa(s,e,t){if(!(e in s))return null;let a=ys(s[e],qn,t);return function(l){return AI(a(l),e)}}function tB(s,e,t){let a=sa(s,e+"pattern-src",t),l=vI(s,e+"pattern-offset",t),o=vI(s,e+"pattern-size",t),m=i0(s,e+"color",t);return function(g){return{src:a(g),offset:l&&l(g),size:o&&o(g),color:m&&m(g)}}}function Fd(s,e,t){if(!(e in s))return null;let a=ys(s[e],Br,t);return function(l){let o=a(l);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${e}`);return o}}function i0(s,e,t){if(!(e in s))return null;let a=ys(s[e],si|qn,t);return function(l){return EI(a(l),e)}}function SI(s,e,t){if(!(e in s))return null;let a=ys(s[e],Wo,t);return function(l){return Ld(a(l),e)}}function lg(s,e,t){if(!(e in s))return null;let a=ys(s[e],Wo,t);return function(l){let o=Ld(a(l),e);if(o.length!==2)throw new Error(`Expected two numbers for ${e}`);return o}}function vI(s,e,t){if(!(e in s))return null;let a=ys(s[e],Wo,t);return function(l){return II(a(l),e)}}function ug(s,e,t){if(!(e in s))return null;let a=ys(s[e],Wo|mt,t);return function(l){return sB(a(l),e)}}function cg(s,e){let t=s[e];if(t!==void 0){if(typeof t!="number")throw new Error(`Expected a number for ${e}`);return t}}function rB(s,e){let t=s[e];if(t!==void 0){if(typeof t=="number")return Wa(t);if(!Array.isArray(t))throw new Error(`Expected a number or size array for ${e}`);if(t.length!==2||typeof t[0]!="number"||typeof t[1]!="number")throw new Error(`Expected a number or size array for ${e}`);return t}}function iB(s,e){let t=s[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);return t}}function xI(s,e){let t=s[e];if(t!==void 0){if(t!=="bottom-left"&&t!=="bottom-right"&&t!=="top-left"&&t!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return t}}function bI(s,e){let t=s[e];if(t!==void 0){if(t!=="pixels"&&t!=="fraction")throw new Error(`Expected pixels or fraction for ${e}`);return t}}function nB(s,e){let t=s[e];if(t!==void 0)return Ld(t,e)}function hg(s,e){let t=s[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);if(t!=="declutter"&&t!=="obstacle"&&t!=="none")throw new Error(`Expected declutter, obstacle, or none for ${e}`);return t}}function oB(s,e){let t=s[e];if(t!==void 0)return EI(t,e)}function Ld(s,e){if(!Array.isArray(s))throw new Error(`Expected an array for ${e}`);let t=s.length;for(let a=0;a<t;++a)if(typeof s[a]!="number")throw new Error(`Expected an array of numbers for ${e}`);return s}function AI(s,e){if(typeof s!="string")throw new Error(`Expected a string for ${e}`);return s}function t0(s,e){if(typeof s!="number")throw new Error(`Expected a number for ${e}`);return s}function EI(s,e){if(typeof s=="string")return s;let t=Ld(s,e),a=t.length;if(a<3||a>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return t}function II(s,e){let t=Ld(s,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function sB(s,e){return typeof s=="number"?s:II(s,e)}var PI={RENDER_ORDER:"renderOrder"},n0=class extends Vo{constructor(e){e=e||{};let t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),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(PI.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){let a=this.getDeclutter();a in e.declutter||(e.declutter[a]=new TI.default(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(PI.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?qx:e;let t=aB(e);this.styleFunction_=e===null?void 0:dI(t),this.changed()}};function aB(s){if(s===void 0)return qx;if(!s)return null;if(typeof s=="function"||s instanceof Vi)return s;if(!Array.isArray(s))return r0([s]);if(s.length===0)return[];let e=s.length,t=s[0];if(t instanceof Vi){let l=new Array(e);for(let o=0;o<e;++o){let m=s[o];if(!(m instanceof Vi))throw new Error("Expected a list of style instances");l[o]=m}return l}if("style"in t){let l=new Array(e);for(let o=0;o<e;++o){let m=s[o];if(!("style"in m))throw new Error("Expected a list of rules with a style property");l[o]=m}return wI(l)}return r0(s)}var CI=n0;var Dd={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},Od=[Dd.FILL],_s=[Dd.STROKE],aa=[Dd.BEGIN_PATH],o0=[Dd.CLOSE_PATH],xt=Dd;var s0=class{drawCustom(e,t,a,l,o){}drawGeometry(e){}setStyle(e){}drawCircle(e,t,a){}drawFeature(e,t,a){}drawGeometryCollection(e,t,a){}drawLineString(e,t,a){}drawMultiLineString(e,t,a){}drawMultiPoint(e,t,a){}drawMultiPolygon(e,t,a){}drawPoint(e,t,a){}drawPolygon(e,t,a){}drawText(e,t,a){}setFillStrokeStyle(e,t){}setImageStyle(e,t){}setTextStyle(e,t){}},pg=s0;var a0=class extends pg{constructor(e,t,a,l){super(),this.tolerance=e,this.maxExtent=t,this.pixelRatio=l,this.maxLineWidth=0,this.resolution=a,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){let t=this.pixelRatio;return t==1?e:e.map(function(a){return a*t})}appendFlatPointCoordinates(e,t){let a=this.getBufferedMaxExtent(),l=this.tmpCoordinate_,o=this.coordinates,m=o.length;for(let g=0,b=e.length;g<b;g+=t)l[0]=e[g],l[1]=e[g+1],Ys(a,l)&&(o[m++]=l[0],o[m++]=l[1]);return m}appendFlatLineCoordinates(e,t,a,l,o,m){let g=this.coordinates,b=g.length,A=this.getBufferedMaxExtent();m&&(t+=l);let S=e[t],M=e[t+1],R=this.tmpCoordinate_,j=!0,W,re,$;for(W=t+l;W<a;W+=l)R[0]=e[W],R[1]=e[W+1],$=Fm(A,R),$!==re?(j&&(g[b++]=S,g[b++]=M,j=!1),g[b++]=R[0],g[b++]=R[1]):$===ii.INTERSECTING?(g[b++]=R[0],g[b++]=R[1],j=!1):j=!0,S=R[0],M=R[1],re=$;return(o&&j||W===t+l)&&(g[b++]=S,g[b++]=M),b}drawCustomCoordinates_(e,t,a,l,o){for(let m=0,g=a.length;m<g;++m){let b=a[m],A=this.appendFlatLineCoordinates(e,t,b,l,!1,!1);o.push(A),t=b}return t}drawCustom(e,t,a,l,o){this.beginGeometry(e,t,o);let m=e.getType(),g=e.getStride(),b=this.coordinates.length,A,S,M,R,j;switch(m){case"MultiPolygon":A=e.getOrientedFlatCoordinates(),R=[];let W=e.getEndss();j=0;for(let re=0,$=W.length;re<$;++re){let X=[];j=this.drawCustomCoordinates_(A,j,W[re],g,X),R.push(X)}this.instructions.push([xt.CUSTOM,b,R,e,a,hd,o]),this.hitDetectionInstructions.push([xt.CUSTOM,b,R,e,l||a,hd,o]);break;case"Polygon":case"MultiLineString":M=[],A=m=="Polygon"?e.getOrientedFlatCoordinates():e.getFlatCoordinates(),j=this.drawCustomCoordinates_(A,0,e.getEnds(),g,M),this.instructions.push([xt.CUSTOM,b,M,e,a,Va,o]),this.hitDetectionInstructions.push([xt.CUSTOM,b,M,e,l||a,Va,o]);break;case"LineString":case"Circle":A=e.getFlatCoordinates(),S=this.appendFlatLineCoordinates(A,0,A.length,g,!1,!1),this.instructions.push([xt.CUSTOM,b,S,e,a,vo,o]),this.hitDetectionInstructions.push([xt.CUSTOM,b,S,e,l||a,vo,o]);break;case"MultiPoint":A=e.getFlatCoordinates(),S=this.appendFlatPointCoordinates(A,g),S>b&&(this.instructions.push([xt.CUSTOM,b,S,e,a,vo,o]),this.hitDetectionInstructions.push([xt.CUSTOM,b,S,e,l||a,vo,o]));break;case"Point":A=e.getFlatCoordinates(),this.coordinates.push(A[0],A[1]),S=this.coordinates.length,this.instructions.push([xt.CUSTOM,b,S,e,a,void 0,o]),this.hitDetectionInstructions.push([xt.CUSTOM,b,S,e,l||a,void 0,o]);break;default:}this.endGeometry(t)}beginGeometry(e,t,a){this.beginGeometryInstruction1_=[xt.BEGIN_GEOMETRY,t,0,e,a],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[xt.BEGIN_GEOMETRY,t,0,e,a],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let e=this.hitDetectionInstructions;e.reverse();let t,a=e.length,l,o,m=-1;for(t=0;t<a;++t)l=e[t],o=l[0],o==xt.END_GEOMETRY?m=t:o==xt.BEGIN_GEOMETRY&&(l[2]=t,jA(this.hitDetectionInstructions,m,t),m=-1)}setFillStrokeStyle(e,t){let a=this.state;if(e){let l=e.getColor();a.fillPatternScale=l&&typeof l=="object"&&"src"in l?this.pixelRatio:1,a.fillStyle=Nn(l||di)}else a.fillStyle=void 0;if(t){let l=t.getColor();a.strokeStyle=Nn(l||ia);let o=t.getLineCap();a.lineCap=o!==void 0?o:ms;let m=t.getLineDash();a.lineDash=m?m.slice():Un;let g=t.getLineDashOffset();a.lineDashOffset=g||Gn;let b=t.getLineJoin();a.lineJoin=b!==void 0?b:gs;let A=t.getWidth();a.lineWidth=A!==void 0?A:oa;let S=t.getMiterLimit();a.miterLimit=S!==void 0?S:ra,a.lineWidth>this.maxLineWidth&&(this.maxLineWidth=a.lineWidth,this.bufferedMaxExtent_=null)}else a.strokeStyle=void 0,a.lineCap=void 0,a.lineDash=null,a.lineDashOffset=void 0,a.lineJoin=void 0,a.lineWidth=void 0,a.miterLimit=void 0}createFill(e){let t=e.fillStyle,a=[xt.SET_FILL_STYLE,t];return typeof t!="string"&&a.push(e.fillPatternScale),a}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[xt.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,t){let a=e.fillStyle;(typeof a!="string"||e.currentFillStyle!=a)&&(a!==void 0&&this.instructions.push(t.call(this,e)),e.currentFillStyle=a)}updateStrokeStyle(e,t){let a=e.strokeStyle,l=e.lineCap,o=e.lineDash,m=e.lineDashOffset,g=e.lineJoin,b=e.lineWidth,A=e.miterLimit;(e.currentStrokeStyle!=a||e.currentLineCap!=l||o!=e.currentLineDash&&!Fn(e.currentLineDash,o)||e.currentLineDashOffset!=m||e.currentLineJoin!=g||e.currentLineWidth!=b||e.currentMiterLimit!=A)&&(a!==void 0&&t.call(this,e),e.currentStrokeStyle=a,e.currentLineCap=l,e.currentLineDash=o,e.currentLineDashOffset=m,e.currentLineJoin=g,e.currentLineWidth=b,e.currentMiterLimit=A)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let t=[xt.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=NA(this.maxExtent),this.maxLineWidth>0)){let e=this.resolution*(this.maxLineWidth+1)/2;Ln(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},vs=a0;var l0=class extends vs{constructor(e,t,a,l){super(e,t,a,l),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,t,a){if(!this.image_||this.maxExtent&&!Ys(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,a);let l=e.getFlatCoordinates(),o=e.getStride(),m=this.coordinates.length,g=this.appendFlatPointCoordinates(l,o);this.instructions.push([xt.DRAW_IMAGE,m,g,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([xt.DRAW_IMAGE,m,g,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(t)}drawMultiPoint(e,t,a){if(!this.image_)return;this.beginGeometry(e,t,a);let l=e.getFlatCoordinates(),o=[];for(let b=0,A=l.length;b<A;b+=e.getStride())(!this.maxExtent||Ys(this.maxExtent,l.slice(b,b+2)))&&o.push(l[b],l[b+1]);let m=this.coordinates.length,g=this.appendFlatPointCoordinates(o,2);this.instructions.push([xt.DRAW_IMAGE,m,g,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([xt.DRAW_IMAGE,m,g,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(t)}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,t){let a=e.getAnchor(),l=e.getSize(),o=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=a[0],this.anchorY_=a[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=l[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_=l[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}},MI=l0;var c0=class extends vs{constructor(e,t,a,l){super(e,t,a,l)}drawFlatCoordinates_(e,t,a,l){let o=this.coordinates.length,m=this.appendFlatLineCoordinates(e,t,a,l,!1,!1),g=[xt.MOVE_TO_LINE_TO,o,m];return this.instructions.push(g),this.hitDetectionInstructions.push(g),a}drawLineString(e,t,a){let l=this.state,o=l.strokeStyle,m=l.lineWidth;if(o===void 0||m===void 0)return;this.updateStrokeStyle(l,this.applyStroke),this.beginGeometry(e,t,a),this.hitDetectionInstructions.push([xt.SET_STROKE_STYLE,l.strokeStyle,l.lineWidth,l.lineCap,l.lineJoin,l.miterLimit,Un,Gn],aa);let g=e.getFlatCoordinates(),b=e.getStride();this.drawFlatCoordinates_(g,0,g.length,b),this.hitDetectionInstructions.push(_s),this.endGeometry(t)}drawMultiLineString(e,t,a){let l=this.state,o=l.strokeStyle,m=l.lineWidth;if(o===void 0||m===void 0)return;this.updateStrokeStyle(l,this.applyStroke),this.beginGeometry(e,t,a),this.hitDetectionInstructions.push([xt.SET_STROKE_STYLE,l.strokeStyle,l.lineWidth,l.lineCap,l.lineJoin,l.miterLimit,Un,Gn],aa);let g=e.getEnds(),b=e.getFlatCoordinates(),A=e.getStride(),S=0;for(let M=0,R=g.length;M<R;++M)S=this.drawFlatCoordinates_(b,S,g[M],A);this.hitDetectionInstructions.push(_s),this.endGeometry(t)}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(aa)}},RI=c0;var u0=class extends vs{constructor(e,t,a,l){super(e,t,a,l)}drawFlatCoordinatess_(e,t,a,l){let o=this.state,m=o.fillStyle!==void 0,g=o.strokeStyle!==void 0,b=a.length;this.instructions.push(aa),this.hitDetectionInstructions.push(aa);for(let A=0;A<b;++A){let S=a[A],M=this.coordinates.length,R=this.appendFlatLineCoordinates(e,t,S,l,!0,!g),j=[xt.MOVE_TO_LINE_TO,M,R];this.instructions.push(j),this.hitDetectionInstructions.push(j),g&&(this.instructions.push(o0),this.hitDetectionInstructions.push(o0)),t=S}return m&&(this.instructions.push(Od),this.hitDetectionInstructions.push(Od)),g&&(this.instructions.push(_s),this.hitDetectionInstructions.push(_s)),t}drawCircle(e,t,a){let l=this.state,o=l.fillStyle,m=l.strokeStyle;if(o===void 0&&m===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,a),l.fillStyle!==void 0&&this.hitDetectionInstructions.push([xt.SET_FILL_STYLE,di]),l.strokeStyle!==void 0&&this.hitDetectionInstructions.push([xt.SET_STROKE_STYLE,l.strokeStyle,l.lineWidth,l.lineCap,l.lineJoin,l.miterLimit,Un,Gn]);let g=e.getFlatCoordinates(),b=e.getStride(),A=this.coordinates.length;this.appendFlatLineCoordinates(g,0,g.length,b,!1,!1);let S=[xt.CIRCLE,A];this.instructions.push(aa,S),this.hitDetectionInstructions.push(aa,S),l.fillStyle!==void 0&&(this.instructions.push(Od),this.hitDetectionInstructions.push(Od)),l.strokeStyle!==void 0&&(this.instructions.push(_s),this.hitDetectionInstructions.push(_s)),this.endGeometry(t)}drawPolygon(e,t,a){let l=this.state,o=l.fillStyle,m=l.strokeStyle;if(o===void 0&&m===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,a),l.fillStyle!==void 0&&this.hitDetectionInstructions.push([xt.SET_FILL_STYLE,di]),l.strokeStyle!==void 0&&this.hitDetectionInstructions.push([xt.SET_STROKE_STYLE,l.strokeStyle,l.lineWidth,l.lineCap,l.lineJoin,l.miterLimit,Un,Gn]);let g=e.getEnds(),b=e.getOrientedFlatCoordinates(),A=e.getStride();this.drawFlatCoordinatess_(b,0,g,A),this.endGeometry(t)}drawMultiPolygon(e,t,a){let l=this.state,o=l.fillStyle,m=l.strokeStyle;if(o===void 0&&m===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,a),l.fillStyle!==void 0&&this.hitDetectionInstructions.push([xt.SET_FILL_STYLE,di]),l.strokeStyle!==void 0&&this.hitDetectionInstructions.push([xt.SET_STROKE_STYLE,l.strokeStyle,l.lineWidth,l.lineCap,l.lineJoin,l.miterLimit,Un,Gn]);let g=e.getEndss(),b=e.getOrientedFlatCoordinates(),A=e.getStride(),S=0;for(let M=0,R=g.length;M<R;++M)S=this.drawFlatCoordinatess_(b,S,g[M],A);this.endGeometry(t)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let e=this.tolerance;if(e!==0){let t=this.coordinates;for(let a=0,l=t.length;a<l;++a)t[a]=Ga(t[a],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)}},h0=u0;function kI(s,e,t,a,l){let o=[],m=t,g=0,b=e.slice(t,2);for(;g<s&&m+l<a;){let[A,S]=b.slice(-2),M=e[m+l],R=e[m+l+1],j=Math.sqrt((M-A)*(M-A)+(R-S)*(R-S));if(g+=j,g>=s){let W=(s-g+j)/j,re=Ni(A,M,W),$=Ni(S,R,W);b.push(re,$),o.push(b),b=[re,$],g==s&&(m+=l),g=0}else if(g<s)b.push(e[m+l],e[m+l+1]),m+=l;else{let W=j-g,re=Ni(A,M,W/j),$=Ni(S,R,W/j);b.push(re,$),o.push(b),b=[re,$],g=0,m+=l}}return g>0&&o.push(b),o}function FI(s,e,t,a,l){let o=t,m=t,g=0,b=0,A=t,S,M,R,j,W,re,$,X,se,me;for(M=t;M<a;M+=l){let _e=e[M],pe=e[M+1];W!==void 0&&(se=_e-W,me=pe-re,j=Math.sqrt(se*se+me*me),$!==void 0&&(b+=R,S=Math.acos(($*se+X*me)/(R*j)),S>s&&(b>g&&(g=b,o=A,m=M),b=0,A=M-l)),R=j,$=se,X=me),W=_e,re=pe}return b+=j,b>g?[A,M]:[o,m]}var zd={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},p0=class extends vs{constructor(e,t,a,l){super(e,t,a,l),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[di]={fillStyle:di},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,t,a){let l=this.textFillState_,o=this.textStrokeState_,m=this.textState_;if(this.text_===""||!m||!l&&!o)return;let g=this.coordinates,b=g.length,A=e.getType(),S=null,M=e.getStride();if(m.placement==="line"&&(A=="LineString"||A=="MultiLineString"||A=="Polygon"||A=="MultiPolygon")){if(!ni(this.maxExtent,e.getExtent()))return;let R;if(S=e.getFlatCoordinates(),A=="LineString")R=[S.length];else if(A=="MultiLineString")R=e.getEnds();else if(A=="Polygon")R=e.getEnds().slice(0,1);else if(A=="MultiPolygon"){let $=e.getEndss();R=[];for(let X=0,se=$.length;X<se;++X)R.push($[X][0])}this.beginGeometry(e,t,a);let j=m.repeat,W=j?void 0:m.textAlign,re=0;for(let $=0,X=R.length;$<X;++$){let se;j?se=kI(j*this.resolution,S,re,R[$],M):se=[S.slice(re,R[$])];for(let me=0,_e=se.length;me<_e;++me){let pe=se[me],xe=0,Ee=pe.length;if(W==null){let Se=FI(m.maxAngle,pe,0,pe.length,2);xe=Se[0],Ee=Se[1]}for(let Se=xe;Se<Ee;Se+=M)g.push(pe[Se],pe[Se+1]);let Me=g.length;re=R[$],this.drawChars_(b,Me),b=Me}}this.endGeometry(t)}else{let R=m.overflow?null:[];switch(A){case"Point":case"MultiPoint":S=e.getFlatCoordinates();break;case"LineString":S=e.getFlatMidpoint();break;case"Circle":S=e.getCenter();break;case"MultiLineString":S=e.getFlatMidpoints(),M=2;break;case"Polygon":S=e.getFlatInteriorPoint(),m.overflow||R.push(S[2]/this.resolution),M=3;break;case"MultiPolygon":let se=e.getFlatInteriorPoints();S=[];for(let me=0,_e=se.length;me<_e;me+=3)m.overflow||R.push(se[me+2]/this.resolution),S.push(se[me],se[me+1]);if(S.length===0)return;M=2;break;default:}let j=this.appendFlatPointCoordinates(S,M);if(j===b)return;if(R&&(j-b)/2!==S.length/M){let se=b/2;R=R.filter((me,_e)=>{let pe=g[(se+_e)*2]===S[_e*M]&&g[(se+_e)*2+1]===S[_e*M+1];return pe||--se,pe})}this.saveTextStates_(),(m.backgroundFill||m.backgroundStroke)&&(this.setFillStrokeStyle(m.backgroundFill,m.backgroundStroke),m.backgroundFill&&this.updateFillStyle(this.state,this.createFill),m.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(e,t,a);let W=m.padding;if(W!=na&&(m.scale[0]<0||m.scale[1]<0)){let se=m.padding[0],me=m.padding[1],_e=m.padding[2],pe=m.padding[3];m.scale[0]<0&&(me=-me,pe=-pe),m.scale[1]<0&&(se=-se,_e=-_e),W=[se,me,_e,pe]}let re=this.pixelRatio;this.instructions.push([xt.DRAW_IMAGE,b,j,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,W==na?na:W.map(function(se){return se*re}),!!m.backgroundFill,!!m.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,R]);let $=1/re,X=this.state.fillStyle;m.backgroundFill&&(this.state.fillStyle=di,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([xt.DRAW_IMAGE,b,j,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[$,$],NaN,this.declutterMode_,this.declutterImageWithText_,W,!!m.backgroundFill,!!m.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?di:this.fillKey_,this.textOffsetX_,this.textOffsetY_,R]),m.backgroundFill&&(this.state.fillStyle=X,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(t)}}saveTextStates_(){let e=this.textStrokeState_,t=this.textState_,a=this.textFillState_,l=this.strokeKey_;e&&(l in this.strokeStates||(this.strokeStates[l]={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:t.font,textAlign:t.textAlign||Ha,justify:t.justify,textBaseline:t.textBaseline||Wl,scale:t.scale});let m=this.fillKey_;a&&(m in this.fillStates||(this.fillStates[m]={fillStyle:a.fillStyle}))}drawChars_(e,t){let a=this.textStrokeState_,l=this.textState_,o=this.strokeKey_,m=this.textKey_,g=this.fillKey_;this.saveTextStates_();let b=this.pixelRatio,A=zd[l.textBaseline],S=this.textOffsetY_*b,M=this.text_,R=a?a.lineWidth*Math.abs(l.scale[0])/2:0;this.instructions.push([xt.DRAW_CHARS,e,t,A,l.overflow,g,l.maxAngle,b,S,o,R*b,M,m,1,this.declutterMode_]),this.hitDetectionInstructions.push([xt.DRAW_CHARS,e,t,A,l.overflow,g&&di,l.maxAngle,b,S,o,R*b,M,m,1/b,this.declutterMode_])}setTextStyle(e,t){let a,l,o;if(!e)this.text_="";else{let m=e.getFill();m?(l=this.textFillState_,l||(l={},this.textFillState_=l),l.fillStyle=Nn(m.getColor()||di)):(l=null,this.textFillState_=l);let g=e.getStroke();if(!g)o=null,this.textStrokeState_=o;else{o=this.textStrokeState_,o||(o={},this.textStrokeState_=o);let W=g.getLineDash(),re=g.getLineDashOffset(),$=g.getWidth(),X=g.getMiterLimit();o.lineCap=g.getLineCap()||ms,o.lineDash=W?W.slice():Un,o.lineDashOffset=re===void 0?Gn:re,o.lineJoin=g.getLineJoin()||gs,o.lineWidth=$===void 0?oa:$,o.miterLimit=X===void 0?ra:X,o.strokeStyle=Nn(g.getColor()||ia)}a=this.textState_;let b=e.getFont()||og;lI(b);let A=e.getScaleArray();a.overflow=e.getOverflow(),a.font=b,a.maxAngle=e.getMaxAngle(),a.placement=e.getPlacement(),a.textAlign=e.getTextAlign(),a.repeat=e.getRepeat(),a.justify=e.getJustify(),a.textBaseline=e.getTextBaseline()||Wl,a.backgroundFill=e.getBackgroundFill(),a.backgroundStroke=e.getBackgroundStroke(),a.padding=e.getPadding()||na,a.scale=A===void 0?[1,1]:A;let S=e.getOffsetX(),M=e.getOffsetY(),R=e.getRotateWithView(),j=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=S===void 0?0:S,this.textOffsetY_=M===void 0?0:M,this.textRotateWithView_=R===void 0?!1:R,this.textRotation_=j===void 0?0:j,this.strokeKey_=o?(typeof o.strokeStyle=="string"?o.strokeStyle:Nt(o.strokeStyle))+o.lineCap+o.lineDashOffset+"|"+o.lineWidth+o.lineJoin+o.miterLimit+"["+o.lineDash.join()+"]":"",this.textKey_=a.font+a.scale+(a.textAlign||"?")+(a.repeat||"?")+(a.justify||"?")+(a.textBaseline||"?"),this.fillKey_=l&&l.fillStyle?typeof l.fillStyle=="string"?l.fillStyle:"|"+Nt(l.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}},LI=p0;var lB={Circle:h0,Default:vs,Image:MI,LineString:RI,Polygon:h0,Text:LI},d0=class{constructor(e,t,a,l){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=l,this.resolution_=a,this.buildersByZIndex_={}}finish(){let e={};for(let t in this.buildersByZIndex_){e[t]=e[t]||{};let a=this.buildersByZIndex_[t];for(let l in a){let o=a[l].finish();e[t][l]=o}}return e}getBuilder(e,t){let a=e!==void 0?e.toString():"0",l=this.buildersByZIndex_[a];l===void 0&&(l={},this.buildersByZIndex_[a]=l);let o=l[t];if(o===void 0){let m=lB[t];o=new m(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),l[t]=o}return o}},DI=d0;var f0=class extends Rm{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e}getFeatures(e){return It()}getData(e){return null}prepareFrame(e){return It()}renderFrame(e,t){return It()}loadedTileCallback(e,t,a){e[t]||(e[t]={}),e[t][a.tileCoord.toString()]=a}createLoadedTileFinder(e,t,a){return(l,o)=>{let m=this.loadedTileCallback.bind(this,a,l);return e.forEachLoadedTile(t,l,o,m)}}forEachFeatureAtCoordinate(e,t,a,l,o){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){let t=e.target;(t.getState()===Rt.LOADED||t.getState()===Rt.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=Rt.LOADED&&t!=Rt.ERROR&&e.addEventListener(Er.CHANGE,this.boundHandleImageChange_),t==Rt.IDLE&&(e.load(),t=e.getState()),t==Rt.LOADED}renderIfReadyAndVisible(){let e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}},Fu=f0;var m0=class extends Or{constructor(e,t,a,l){super(e),this.inversePixelTransform=t,this.frameState=a,this.context=l}},OI=m0;var g0=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Pu(),{get:(e,t)=>{if(typeof Pu()[t]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(t),this.pushMethodArgs_},set:(e,t,a)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(t,a),!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(t=>{for(let a=0,l=t.length;a<l;++a){let o=t[a];if(typeof o=="function"){o(e);continue}let m=t[++a];if(typeof e[o]=="function")e[o](...m);else{if(typeof m=="function"){e[o]=m(e);continue}e[o]=m}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},dg=g0;var _0=[],Lu=null;function cB(){Lu=Yr(1,1,void 0,{willReadFrequently:!0})}var y0=class extends Fu{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=Ai(),this.pixelTransform=Ai(),this.inversePixelTransform=Ai(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.pixelContext_=null,this.frameState=null}getImageData(e,t,a){Lu||cB(),Lu.clearRect(0,0,1,1);let l;try{Lu.drawImage(e,t,a,1,1,0,0,1,1),l=Lu.getImageData(0,0,1,1).data}catch{return Lu=null,null}return l}getBackground(e){let a=this.getLayer().getBackground();return typeof a=="function"&&(a=a(e.viewState.resolution)),a||void 0}useContainer(e,t,a){let l=this.getLayer().getClassName(),o,m;if(e&&e.className===l&&(!a||e&&e.style.backgroundColor&&Fn(ta(e.style.backgroundColor),ta(a)))){let g=e.firstElementChild;g instanceof HTMLCanvasElement&&(m=g.getContext("2d"))}if(m&&m.canvas.style.transform===t?(this.container=e,this.context=m,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=l;let g=o.style;g.position="absolute",g.width="100%",g.height="100%",m=Yr();let b=m.canvas;o.appendChild(b),g=b.style,g.position="absolute",g.left="0",g.transformOrigin="top left",this.container=o,this.context=m}!this.containerReused&&a&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=a)}clipUnrotated(e,t,a){let l=_v(a),o=vv(a),m=yv(a),g=gv(a);zi(t.coordinateToPixelTransform,l),zi(t.coordinateToPixelTransform,o),zi(t.coordinateToPixelTransform,m),zi(t.coordinateToPixelTransform,g);let b=this.inversePixelTransform;zi(b,l),zi(b,o),zi(b,m),zi(b,g),e.save(),e.beginPath(),e.moveTo(Math.round(l[0]),Math.round(l[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(m[0]),Math.round(m[1])),e.lineTo(Math.round(g[0]),Math.round(g[1])),e.clip()}prepareContainer(e,t){let a=e.extent,l=e.viewState.resolution,o=e.viewState.rotation,m=e.pixelRatio,g=Math.round(Fr(a)/l*m),b=Math.round(hi(a)/l*m);cn(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/m,1/m,o,-g/2,-b/2),OA(this.inversePixelTransform,this.pixelTransform);let A=lv(this.pixelTransform);if(this.useContainer(t,A,this.getBackground(e)),!this.containerReused){let S=this.context.canvas;S.width!=g||S.height!=b?(S.width=g,S.height=b):this.context.clearRect(0,0,g,b),A!==S.style.transform&&(S.style.transform=A)}}dispatchRenderEvent_(e,t,a){let l=this.getLayer();if(l.hasListener(e)){let o=new OI(e,this.inversePixelTransform,a,t);l.dispatchEvent(o)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(ds.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(ds.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new dg),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(ds.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(ds.POSTRENDER,this.context,e))}getRenderTransform(e,t,a,l,o,m,g){let b=o/2,A=m/2,S=l/t,M=-S,R=-e[0]+g,j=-e[1];return cn(this.tempTransform,b,A,S,M,-a,R,j)}disposeInternal(){delete this.frameState,super.disposeInternal()}},fg=y0;function zI(s,e,t,a,l,o,m,g,b,A,S,M){let R=s[e],j=s[e+1],W=0,re=0,$=0,X=0;function se(){W=R,re=j,e+=a,R=s[e],j=s[e+1],X+=$,$=Math.sqrt((R-W)*(R-W)+(j-re)*(j-re))}do se();while(e<t-a&&X+$<o);let me=$===0?0:(o-X)/$,_e=Ni(W,R,me),pe=Ni(re,j,me),xe=e-a,Ee=X,Me=o+g*b(A,l,S);for(;e<t-a&&X+$<Me;)se();me=$===0?0:(Me-X)/$;let Se=Ni(W,R,me),ut=Ni(re,j,me),Ue;if(M){let ot=[_e,pe,Se,ut];jm(ot,0,4,2,M,ot,ot),Ue=ot[0]>ot[2]}else Ue=_e>Se;let $e=Math.PI,pt=[],Pt=xe+a===e;e=xe,$=0,X=Ee,R=s[e],j=s[e+1];let et;if(Pt){se(),et=Math.atan2(j-re,R-W),Ue&&(et+=et>0?-$e:$e);let ot=(Se+_e)/2,gt=(ut+pe)/2;return pt[0]=[ot,gt,(Me-o)/2,et,l],pt}l=l.replace(/\n/g," ");for(let ot=0,gt=l.length;ot<gt;){se();let dt=Math.atan2(j-re,R-W);if(Ue&&(dt+=dt>0?-$e:$e),et!==void 0){let Ge=dt-et;if(Ge+=Ge>$e?-2*$e:Ge<-$e?2*$e:0,Math.abs(Ge)>m)return null}et=dt;let kt=ot,yt=0;for(;ot<gt;++ot){let Ge=Ue?gt-ot-1:ot,Gr=g*b(A,l[Ge],S);if(e+a<t&&X+$<o+yt+Gr/2)break;yt+=Gr}if(ot===kt)continue;let Ot=Ue?l.substring(gt-kt,gt-ot):l.substring(kt,ot);me=$===0?0:(o+yt/2-X)/$;let Qt=Ni(W,R,me),Tr=Ni(re,j,me);pt.push([Qt,Tr,yt/2,dt,Ot]),o+=yt}return pt}var Du=On(),Ka=[],la=[],ca=[],Ja=[];function BI(s){return s[3].declutterBox}var jI=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function v0(s,e){return e==="start"?e=jI.test(s)?"right":"left":e==="end"&&(e=jI.test(s)?"left":"right"),zd[e]}function uB(s,e,t){return t>0&&s.push(`
|
|
586
586
|
`,""),s.push(e,""),s}var x0=class{constructor(e,t,a,l,o){this.overlaps=a,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=l.instructions,this.coordinates=l.coordinates,this.coordinateCache_={},this.renderedTransform_=Ai(),this.hitDetectionInstructions=l.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=l.fillStates||{},this.strokeStates=l.strokeStates||{},this.textStates=l.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=o?new dg:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,a,l){let o=e+t+a+l;if(this.labels_[o])return this.labels_[o];let m=l?this.strokeStates[l]:null,g=a?this.fillStates[a]:null,b=this.textStates[t],A=this.pixelRatio,S=[b.scale[0]*A,b.scale[1]*A],M=Array.isArray(e),R=b.justify?zd[b.justify]:v0(Array.isArray(e)?e[0]:e,b.textAlign||Ha),j=l&&m.lineWidth?m.lineWidth:0,W=M?e:e.split(`
|
|
587
587
|
`).reduce(uB,[]),{width:re,height:$,widths:X,heights:se,lineWidths:me}=uI(b,W),_e=re+j,pe=[],xe=(_e+2)*S[0],Ee=($+j)*S[1],Me={width:xe<0?Math.floor(xe):Math.ceil(xe),height:Ee<0?Math.floor(Ee):Math.ceil(Ee),contextInstructions:pe};(S[0]!=1||S[1]!=1)&&pe.push("scale",S),l&&(pe.push("strokeStyle",m.strokeStyle),pe.push("lineWidth",j),pe.push("lineCap",m.lineCap),pe.push("lineJoin",m.lineJoin),pe.push("miterLimit",m.miterLimit),pe.push("setLineDash",[m.lineDash]),pe.push("lineDashOffset",m.lineDashOffset)),a&&pe.push("fillStyle",g.fillStyle),pe.push("textBaseline","middle"),pe.push("textAlign","center");let Se=.5-R,ut=R*_e+Se*j,Ue=[],$e=[],pt=0,Pt=0,et=0,ot=0,gt;for(let dt=0,kt=W.length;dt<kt;dt+=2){let yt=W[dt];if(yt===`
|
|
588
|
-
`){Pt+=pt,pt=0,ut=R*_e+Se*j,++ot;continue}let Ot=W[dt+1]||b.font;Ot!==gt&&(l&&Ue.push("font",Ot),a&&$e.push("font",Ot),gt=Ot),pt=Math.max(pt,se[et]);let Qt=[yt,ut+Se*X[et]+R*(X[et]-me[ot]),.5*(j+pt)+Pt];ut+=X[et],l&&Ue.push("strokeText",Qt),a&&$e.push("fillText",Qt),++et}return Array.prototype.push.apply(pe,Ue),Array.prototype.push.apply(pe,$e),this.labels_[o]=Me,Me}replayTextBackground_(e,t,a,l,o,m,g){e.beginPath(),e.moveTo.apply(e,t),e.lineTo.apply(e,a),e.lineTo.apply(e,l),e.lineTo.apply(e,o),e.lineTo.apply(e,t),m&&(this.alignAndScaleFill_=m[2],this.fill_(e)),g&&(this.setStrokeStyle_(e,g),e.stroke())}calculateImageOrLabelDimensions_(e,t,a,l,o,m,g,b,A,S,M,R,j,W,re,$){g*=R[0],b*=R[1];let X=a-g,se=l-b,me=o+A>e?e-A:o,_e=m+S>t?t-S:m,pe=W[3]+me*R[0]+W[1],xe=W[0]+_e*R[1]+W[2],Ee=X-W[3],Me=se-W[0];(re||M!==0)&&(Ka[0]=Ee,Ja[0]=Ee,Ka[1]=Me,la[1]=Me,la[0]=Ee+pe,ca[0]=la[0],ca[1]=Me+xe,Ja[1]=ca[1]);let Se;return M!==0?(Se=cn(Ai(),a,l,1,1,M,-a,-l),zi(Se,Ka),zi(Se,la),zi(Se,ca),zi(Se,Ja),Js(Math.min(Ka[0],la[0],ca[0],Ja[0]),Math.min(Ka[1],la[1],ca[1],Ja[1]),Math.max(Ka[0],la[0],ca[0],Ja[0]),Math.max(Ka[1],la[1],ca[1],Ja[1]),Du)):Js(Math.min(Ee,Ee+pe),Math.min(Me,Me+xe),Math.max(Ee,Ee+pe),Math.max(Me,Me+xe),Du),j&&(X=Math.round(X),se=Math.round(se)),{drawImageX:X,drawImageY:se,drawImageW:me,drawImageH:_e,originX:A,originY:S,declutterBox:{minX:Du[0],minY:Du[1],maxX:Du[2],maxY:Du[3],value:$},canvasTransform:Se,scale:R}}replayImageOrLabel_(e,t,a,l,o,m,g){let b=!!(m||g),A=l.declutterBox,S=g?g[2]*l.scale[0]/2:0;return A.minX-S<=t[0]&&A.maxX+S>=0&&A.minY-S<=t[1]&&A.maxY+S>=0&&(b&&this.replayTextBackground_(e,Ka,la,ca,Ja,m,g),hI(e,l.canvasTransform,o,a,l.originX,l.originY,l.drawImageW,l.drawImageH,l.drawImageX,l.drawImageY,l.scale)),!0}fill_(e){let t=this.alignAndScaleFill_;if(t){let a=zi(this.renderedTransform_,[0,0]),l=512*this.pixelRatio;e.save(),e.translate(a[0]%l,a[1]%l),t!==1&&e.scale(t,t),e.rotate(this.viewRotation_)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6])}drawLabelWithPointPlacement_(e,t,a,l){let o=this.textStates[t],m=this.createLabel(e,t,l,a),g=this.strokeStates[a],b=this.pixelRatio,A=v0(Array.isArray(e)?e[0]:e,o.textAlign||Ha),S=zd[o.textBaseline||Wl],M=g&&g.lineWidth?g.lineWidth:0,R=m.width/b-2*o.scale[0],j=A*R+2*(.5-A)*M,W=S*m.height/b+2*(.5-S)*M;return{label:m,anchorX:j,anchorY:W}}execute_(e,t,a,l,o,m,g,b){let A=this.zIndexContext_,S;this.pixelCoordinates_&&Fn(a,this.renderedTransform_)?S=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),S=zn(this.coordinates,0,this.coordinates.length,2,a,this.pixelCoordinates_),LA(this.renderedTransform_,a));let M=0,R=l.length,j=0,W,re,$,X,se,me,_e,pe,xe,Ee,Me,Se,ut,Ue=0,$e=0,pt=null,Pt=null,et=this.coordinateCache_,ot=this.viewRotation_,gt=Math.round(Math.atan2(-a[1],a[0])*1e12)/1e12,dt={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:ot},kt=this.instructions!=l||this.overlaps?0:200,yt,Ot,Qt,Tr;for(;M<R;){let Ge=l[M];switch(Ge[0]){case xt.BEGIN_GEOMETRY:yt=Ge[1],Tr=Ge[3],yt.getGeometry()?g!==void 0&&!ni(g,Tr.getExtent())?M=Ge[2]+1:++M:M=Ge[2],A&&(A.zIndex=Ge[4]);break;case xt.BEGIN_PATH:Ue>kt&&(this.fill_(e),Ue=0),$e>kt&&(e.stroke(),$e=0),!Ue&&!$e&&(e.beginPath(),se=NaN,me=NaN),++M;break;case xt.CIRCLE:j=Ge[1];let Vr=S[j],Yi=S[j+1],Ki=S[j+2],Wn=S[j+3],Kr=Ki-Vr,An=Wn-Yi,br=Math.sqrt(Kr*Kr+An*An);e.moveTo(Vr+br,Yi),e.arc(Vr,Yi,br,0,2*Math.PI,!0),++M;break;case xt.CLOSE_PATH:e.closePath(),++M;break;case xt.CUSTOM:j=Ge[1],W=Ge[2];let Zn=Ge[3],Te=Ge[4],En=Ge[5];dt.geometry=Zn,dt.feature=yt,M in et||(et[M]=[]);let Ri=et[M];En?En(S,j,W,2,Ri):(Ri[0]=S[j],Ri[1]=S[j+1],Ri.length=2),A&&(A.zIndex=Ge[6]),Te(Ri,dt),++M;break;case xt.DRAW_IMAGE:j=Ge[1],W=Ge[2],xe=Ge[3],re=Ge[4],$=Ge[5];let Tt=Ge[6],er=Ge[7],ki=Ge[8],co=Ge[9],uo=Ge[10],In=Ge[11],Pn=Ge[12],Hn=Ge[13];X=Ge[14]||"declutter";let ho=Ge[15];if(!xe&&Ge.length>=20){Ee=Ge[19],Me=Ge[20],Se=Ge[21],ut=Ge[22];let ue=this.drawLabelWithPointPlacement_(Ee,Me,Se,ut);xe=ue.label,Ge[3]=xe;let de=Ge[23];re=(ue.anchorX-de)*this.pixelRatio,Ge[4]=re;let oe=Ge[24];$=(ue.anchorY-oe)*this.pixelRatio,Ge[5]=$,Tt=xe.height,Ge[6]=Tt,Hn=xe.width,Ge[13]=Hn}let je;Ge.length>25&&(je=Ge[25]);let Jr,qr,Xn;Ge.length>17?(Jr=Ge[16],qr=Ge[17],Xn=Ge[18]):(Jr=na,qr=!1,Xn=!1),uo&>?In+=ot:!uo&&!gt&&(In-=ot);let Eo=0;for(;j<W;j+=2){if(je&&je[Eo++]<Hn/this.pixelRatio)continue;let ue=this.calculateImageOrLabelDimensions_(xe.width,xe.height,S[j],S[j+1],Hn,Tt,re,$,ki,co,In,Pn,o,Jr,qr||Xn,yt),de=[e,t,xe,ue,er,qr?pt:null,Xn?Pt:null];if(b){let oe,ve,Ce;if(ho){let We=W-j;if(!ho[We]){ho[We]={args:de,declutterMode:X};continue}let Je=ho[We];oe=Je.args,ve=Je.declutterMode,delete ho[We],Ce=BI(oe)}let Pe,Ie;if(oe&&(ve!=="declutter"||!b.collides(Ce))&&(Pe=!0),(X!=="declutter"||!b.collides(ue.declutterBox))&&(Ie=!0),ve==="declutter"&&X==="declutter"){let We=Pe&&Ie;Pe=We,Ie=We}Pe&&(ve!=="none"&&b.insert(Ce),this.replayImageOrLabel_.apply(this,oe)),Ie&&(X!=="none"&&b.insert(ue.declutterBox),this.replayImageOrLabel_.apply(this,de))}else this.replayImageOrLabel_.apply(this,de)}++M;break;case xt.DRAW_CHARS:let Be=Ge[1],Ct=Ge[2],bt=Ge[3],ai=Ge[4];ut=Ge[5];let li=Ge[6],Et=Ge[7],Tn=Ge[8];Se=Ge[9];let fn=Ge[10];Ee=Ge[11],Me=Ge[12];let Lr=[Ge[13],Ge[13]];X=Ge[14]||"declutter";let J=this.textStates[Me],B=J.font,N=[J.scale[0]*Et,J.scale[1]*Et],V;B in this.widths_?V=this.widths_[B]:(V={},this.widths_[B]=V);let ee=$m(S,Be,Ct,2),le=Math.abs(N[0])*Nx(B,Ee,V);if(ai||le<=ee){let ue=this.textStates[Me].textAlign,de=(ee-le)*v0(Ee,ue),oe=zI(S,Be,Ct,2,Ee,de,li,Math.abs(N[0]),Nx,B,V,gt?0:this.viewRotation_);e:if(oe){let ve=[],Ce,Pe,Ie,We,Je;if(Se)for(Ce=0,Pe=oe.length;Ce<Pe;++Ce){Je=oe[Ce],Ie=Je[4],We=this.createLabel(Ie,Me,"",Se),re=Je[2]+(N[0]<0?-fn:fn),$=bt*We.height+(.5-bt)*2*fn*N[1]/N[0]-Tn;let At=this.calculateImageOrLabelDimensions_(We.width,We.height,Je[0],Je[1],We.width,We.height,re,$,0,0,Je[3],Lr,!1,na,!1,yt);if(b&&X==="declutter"&&b.collides(At.declutterBox))break e;ve.push([e,t,We,At,1,null,null])}if(ut)for(Ce=0,Pe=oe.length;Ce<Pe;++Ce){Je=oe[Ce],Ie=Je[4],We=this.createLabel(Ie,Me,ut,""),re=Je[2],$=bt*We.height-Tn;let At=this.calculateImageOrLabelDimensions_(We.width,We.height,Je[0],Je[1],We.width,We.height,re,$,0,0,Je[3],Lr,!1,na,!1,yt);if(b&&X==="declutter"&&b.collides(At.declutterBox))break e;ve.push([e,t,We,At,1,null,null])}b&&X!=="none"&&b.load(ve.map(BI));for(let At=0,_t=ve.length;At<_t;++At)this.replayImageOrLabel_.apply(this,ve[At])}}++M;break;case xt.END_GEOMETRY:if(m!==void 0){yt=Ge[1];let ue=m(yt,Tr,X);if(ue)return ue}++M;break;case xt.FILL:kt?Ue++:this.fill_(e),++M;break;case xt.MOVE_TO_LINE_TO:for(j=Ge[1],W=Ge[2],Ot=S[j],Qt=S[j+1],e.moveTo(Ot,Qt),se=Ot+.5|0,me=Qt+.5|0,j+=2;j<W;j+=2)Ot=S[j],Qt=S[j+1],_e=Ot+.5|0,pe=Qt+.5|0,(j==W-2||_e!==se||pe!==me)&&(e.lineTo(Ot,Qt),se=_e,me=pe);++M;break;case xt.SET_FILL_STYLE:pt=Ge,this.alignAndScaleFill_=Ge[2],Ue&&(this.fill_(e),Ue=0,$e&&(e.stroke(),$e=0)),e.fillStyle=Ge[1],++M;break;case xt.SET_STROKE_STYLE:Pt=Ge,$e&&(e.stroke(),$e=0),this.setStrokeStyle_(e,Ge),++M;break;case xt.STROKE:kt?$e++:e.stroke(),++M;break;default:++M;break}}Ue&&this.fill_(e),$e&&e.stroke()}execute(e,t,a,l,o,m){this.viewRotation_=l,this.execute_(e,t,a,this.instructions,o,void 0,void 0,m)}executeHitDetection(e,t,a,l,o){return this.viewRotation_=a,this.execute_(e,[e.canvas.width,e.canvas.height],t,this.hitDetectionInstructions,!0,l,o)}},NI=x0;var Hl=["Polygon","Circle","LineString","Image","Text","Default"],S0=["Image","Text"],UI=Hl.filter(s=>!S0.includes(s)),w0=class{constructor(e,t,a,l,o,m,g){this.maxExtent_=e,this.overlaps_=l,this.pixelRatio_=a,this.resolution_=t,this.renderBuffer_=m,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Ai(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(o,g)}clip(e,t){let a=this.getClipCoords(t);e.beginPath(),e.moveTo(a[0],a[1]),e.lineTo(a[2],a[3]),e.lineTo(a[4],a[5]),e.lineTo(a[6],a[7]),e.clip()}createExecutors_(e,t){for(let a in e){let l=this.executorsByZIndex_[a];l===void 0&&(l={},this.executorsByZIndex_[a]=l);let o=e[a];for(let m in o){let g=o[m];l[m]=new NI(this.resolution_,this.pixelRatio_,this.overlaps_,g,t)}}}hasExecutors(e){for(let t in this.executorsByZIndex_){let a=this.executorsByZIndex_[t];for(let l=0,o=e.length;l<o;++l)if(e[l]in a)return!0}return!1}forEachFeatureAtCoordinate(e,t,a,l,o,m){l=Math.round(l);let g=l*2+1,b=cn(this.hitDetectionTransform_,l+.5,l+.5,1/t,-1/t,-a,-e[0],-e[1]),A=!this.hitDetectionContext_;A&&(this.hitDetectionContext_=Yr(g,g,void 0,{willReadFrequently:!0}));let S=this.hitDetectionContext_;S.canvas.width!==g||S.canvas.height!==g?(S.canvas.width=g,S.canvas.height=g):A||S.clearRect(0,0,g,g);let M;this.renderBuffer_!==void 0&&(M=On(),fv(M,e),Ln(M,t*(this.renderBuffer_+l),M));let R=hB(l),j;function W(pe,xe,Ee){let Me=S.getImageData(0,0,g,g).data;for(let Se=0,ut=R.length;Se<ut;Se++)if(Me[R[Se]]>0){if(!m||Ee==="none"||j!=="Image"&&j!=="Text"||m.includes(pe)){let Ue=(R[Se]-3)/4,$e=l-Ue%g,pt=l-(Ue/g|0),Pt=o(pe,xe,$e*$e+pt*pt);if(Pt)return Pt}S.clearRect(0,0,g,g);break}}let re=Object.keys(this.executorsByZIndex_).map(Number);re.sort(Oo);let $,X,se,me,_e;for($=re.length-1;$>=0;--$){let pe=re[$].toString();for(se=this.executorsByZIndex_[pe],X=Hl.length-1;X>=0;--X)if(j=Hl[X],me=se[j],me!==void 0&&(_e=me.executeHitDetection(S,b,a,W,M),_e))return _e}}getClipCoords(e){let t=this.maxExtent_;if(!t)return null;let a=t[0],l=t[1],o=t[2],m=t[3],g=[a,l,a,m,o,m,o,l];return zn(g,0,8,2,e,g),g}isEmpty(){return oo(this.executorsByZIndex_)}execute(e,t,a,l,o,m,g){let b=Object.keys(this.executorsByZIndex_).map(Number);b.sort(Oo),m=m||Hl;let A=Hl.length,S,M,R,j,W;for(g&&b.reverse(),S=0,M=b.length;S<M;++S){let re=b[S].toString();for(W=this.executorsByZIndex_[re],R=0,j=m.length;R<j;++R){let $=m[R],X=W[$];if(X!==void 0){let se=g===null?void 0:X.getZIndexContext(),me=se?se.getContext():e,_e=this.maxExtent_&&$!=="Image"&&$!=="Text";if(_e&&(me.save(),this.clip(me,a)),!se||$==="Text"||$==="Image"?X.execute(me,t,a,l,o,g):se.pushFunction(pe=>X.execute(pe,t,a,l,o,g)),_e&&me.restore(),se){se.offset();let pe=b[S]*A+R;this.deferredZIndexContexts_[pe]||(this.deferredZIndexContexts_[pe]=[]),this.deferredZIndexContexts_[pe].push(se)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(Oo);for(let a=0,l=t.length;a<l;++a)e[t[a]].forEach(o=>{o.draw(this.renderedContext_),o.clear()}),e[t[a]].length=0}},b0={};function hB(s){if(b0[s]!==void 0)return b0[s];let e=s*2+1,t=s*s,a=new Array(t+1);for(let o=0;o<=s;++o)for(let m=0;m<=s;++m){let g=o*o+m*m;if(g>t)break;let b=a[g];b||(b=[],a[g]=b),b.push(((s+o)*e+(s+m))*4+3),o>0&&b.push(((s-o)*e+(s+m))*4+3),m>0&&(b.push(((s+o)*e+(s-m))*4+3),o>0&&b.push(((s-o)*e+(s-m))*4+3))}let l=[];for(let o=0,m=a.length;o<m;++o)a[o]&&l.push(...a[o]);return b0[s]=l,l}var GI=w0;var A0=class extends pg{constructor(e,t,a,l,o,m,g){super(),this.context_=e,this.pixelRatio_=t,this.extent_=a,this.transform_=l,this.transformRotation_=l?iE(Math.atan2(l[1],l[0]),10):0,this.viewRotation_=o,this.squaredTolerance_=m,this.userTransform_=g,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_=Ai()}drawImages_(e,t,a,l){if(!this.image_)return;let o=zn(e,t,a,l,this.transform_,this.pixelCoordinates_),m=this.context_,g=this.tmpLocalTransform_,b=m.globalAlpha;this.imageOpacity_!=1&&(m.globalAlpha=b*this.imageOpacity_);let A=this.imageRotation_;this.transformRotation_===0&&(A-=this.viewRotation_),this.imageRotateWithView_&&(A+=this.viewRotation_);for(let S=0,M=o.length;S<M;S+=2){let R=o[S]-this.imageAnchorX_,j=o[S+1]-this.imageAnchorY_;if(A!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let W=R+this.imageAnchorX_,re=j+this.imageAnchorY_;cn(g,W,re,1,1,A,-W,-re),m.save(),m.transform.apply(m,g),m.translate(W,re),m.scale(this.imageScale_[0],this.imageScale_[1]),m.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),m.restore()}else m.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,R,j,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(m.globalAlpha=b)}drawText_(e,t,a,l){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let o=zn(e,t,a,l,this.transform_,this.pixelCoordinates_),m=this.context_,g=this.textRotation_;for(this.transformRotation_===0&&(g-=this.viewRotation_),this.textRotateWithView_&&(g+=this.viewRotation_);t<a;t+=l){let b=o[t]+this.textOffsetX_,A=o[t+1]+this.textOffsetY_;g!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(m.save(),m.translate(b-this.textOffsetX_,A-this.textOffsetY_),m.rotate(g),m.translate(this.textOffsetX_,this.textOffsetY_),m.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&m.strokeText(this.text_,0,0),this.textFillState_&&m.fillText(this.text_,0,0),m.restore()):(this.textStrokeState_&&m.strokeText(this.text_,b,A),this.textFillState_&&m.fillText(this.text_,b,A))}}moveToLineTo_(e,t,a,l,o){let m=this.context_,g=zn(e,t,a,l,this.transform_,this.pixelCoordinates_);m.moveTo(g[0],g[1]);let b=g.length;o&&(b-=2);for(let A=2;A<b;A+=2)m.lineTo(g[A],g[A+1]);return o&&m.closePath(),a}drawRings_(e,t,a,l){for(let o=0,m=a.length;o<m;++o)t=this.moveToLineTo_(e,t,a[o],l,!0);return t}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ni(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=_E(e,this.transform_,this.pixelCoordinates_),a=t[2]-t[0],l=t[3]-t[1],o=Math.sqrt(a*a+l*l),m=this.context_;m.beginPath(),m.arc(t[0],t[1],o,0,2*Math.PI),this.fillState_&&m.fill(),this.strokeState_&&m.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,t){let a=t.getGeometryFunction()(e);a&&(this.setStyle(t),this.drawGeometry(a))}drawGeometryCollection(e){let t=e.getGeometriesArray();for(let a=0,l=t.length;a<l;++a)this.drawGeometry(t[a])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getFlatCoordinates(),a=e.getStride();this.image_&&this.drawImages_(t,0,t.length,a),this.text_!==""&&this.drawText_(t,0,t.length,a)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getFlatCoordinates(),a=e.getStride();this.image_&&this.drawImages_(t,0,t.length,a),this.text_!==""&&this.drawText_(t,0,t.length,a)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ni(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let t=this.context_,a=e.getFlatCoordinates();t.beginPath(),this.moveToLineTo_(a,0,a.length,e.getStride(),!1),t.stroke()}if(this.text_!==""){let t=e.getFlatMidpoint();this.drawText_(t,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getExtent();if(ni(this.extent_,t)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let a=this.context_,l=e.getFlatCoordinates(),o=0,m=e.getEnds(),g=e.getStride();a.beginPath();for(let b=0,A=m.length;b<A;++b)o=this.moveToLineTo_(l,o,m[b],g,!1);a.stroke()}if(this.text_!==""){let a=e.getFlatMidpoints();this.drawText_(a,0,a.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ni(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=this.context_;t.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){let t=e.getFlatInteriorPoint();this.drawText_(t,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ni(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=this.context_,a=e.getOrientedFlatCoordinates(),l=0,o=e.getEndss(),m=e.getStride();t.beginPath();for(let g=0,b=o.length;g<b;++g){let A=o[g];l=this.drawRings_(a,l,A,m)}this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){let t=e.getFlatInteriorPoints();this.drawText_(t,0,t.length,2)}}}setContextFillState_(e){let t=this.context_,a=this.contextFillState_;a?a.fillStyle!=e.fillStyle&&(a.fillStyle=e.fillStyle,t.fillStyle=e.fillStyle):(t.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let t=this.context_,a=this.contextStrokeState_;a?(a.lineCap!=e.lineCap&&(a.lineCap=e.lineCap,t.lineCap=e.lineCap),Fn(a.lineDash,e.lineDash)||t.setLineDash(a.lineDash=e.lineDash),a.lineDashOffset!=e.lineDashOffset&&(a.lineDashOffset=e.lineDashOffset,t.lineDashOffset=e.lineDashOffset),a.lineJoin!=e.lineJoin&&(a.lineJoin=e.lineJoin,t.lineJoin=e.lineJoin),a.lineWidth!=e.lineWidth&&(a.lineWidth=e.lineWidth,t.lineWidth=e.lineWidth),a.miterLimit!=e.miterLimit&&(a.miterLimit=e.miterLimit,t.miterLimit=e.miterLimit),a.strokeStyle!=e.strokeStyle&&(a.strokeStyle=e.strokeStyle,t.strokeStyle=e.strokeStyle)):(t.lineCap=e.lineCap,t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset,t.lineJoin=e.lineJoin,t.lineWidth=e.lineWidth,t.miterLimit=e.miterLimit,t.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 t=this.context_,a=this.contextTextState_,l=e.textAlign?e.textAlign:Ha;a?(a.font!=e.font&&(a.font=e.font,t.font=e.font),a.textAlign!=l&&(a.textAlign=l,t.textAlign=l),a.textBaseline!=e.textBaseline&&(a.textBaseline=e.textBaseline,t.textBaseline=e.textBaseline)):(t.font=e.font,t.textAlign=l,t.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:l,textBaseline:e.textBaseline})}setFillStrokeStyle(e,t){if(!e)this.fillState_=null;else{let a=e.getColor();this.fillState_={fillStyle:Nn(a||di)}}if(!t)this.strokeState_=null;else{let a=t.getColor(),l=t.getLineCap(),o=t.getLineDash(),m=t.getLineDashOffset(),g=t.getLineJoin(),b=t.getWidth(),A=t.getMiterLimit(),S=o||Un;this.strokeState_={lineCap:l!==void 0?l:ms,lineDash:this.pixelRatio_===1?S:S.map(M=>M*this.pixelRatio_),lineDashOffset:(m||Gn)*this.pixelRatio_,lineJoin:g!==void 0?g:gs,lineWidth:(b!==void 0?b:oa)*this.pixelRatio_,miterLimit:A!==void 0?A:ra,strokeStyle:Nn(a||ia)}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}let a=e.getPixelRatio(this.pixelRatio_),l=e.getAnchor(),o=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=l[0]*a,this.imageAnchorY_=l[1]*a,this.imageHeight_=t[1]*a,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=o[0],this.imageOriginY_=o[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let m=e.getScaleArray();this.imageScale_=[m[0]*this.pixelRatio_/a,m[1]*this.pixelRatio_/a],this.imageWidth_=t[0]*a}setTextStyle(e){if(!e)this.text_="";else{let t=e.getFill();if(!t)this.textFillState_=null;else{let j=t.getColor();this.textFillState_={fillStyle:Nn(j||di)}}let a=e.getStroke();if(!a)this.textStrokeState_=null;else{let j=a.getColor(),W=a.getLineCap(),re=a.getLineDash(),$=a.getLineDashOffset(),X=a.getLineJoin(),se=a.getWidth(),me=a.getMiterLimit();this.textStrokeState_={lineCap:W!==void 0?W:ms,lineDash:re||Un,lineDashOffset:$||Gn,lineJoin:X!==void 0?X:gs,lineWidth:se!==void 0?se:oa,miterLimit:me!==void 0?me:ra,strokeStyle:Nn(j||ia)}}let l=e.getFont(),o=e.getOffsetX(),m=e.getOffsetY(),g=e.getRotateWithView(),b=e.getRotation(),A=e.getScaleArray(),S=e.getText(),M=e.getTextAlign(),R=e.getTextBaseline();this.textState_={font:l!==void 0?l:og,textAlign:M!==void 0?M:Ha,textBaseline:R!==void 0?R:Wl},this.text_=S!==void 0?Array.isArray(S)?S.reduce((j,W,re)=>j+=re%2?" ":W,""):S:"",this.textOffsetX_=o!==void 0?this.pixelRatio_*o:0,this.textOffsetY_=m!==void 0?this.pixelRatio_*m:0,this.textRotateWithView_=g!==void 0?g:!1,this.textRotation_=b!==void 0?b:0,this.textScale_=[this.pixelRatio_*A[0],this.pixelRatio_*A[1]]}}},VI=A0;var Xo=.5;function qI(s,e,t,a,l,o,m,g,b){let A=b?hs(l,b):l,S=s[0]*Xo,M=s[1]*Xo,R=Yr(S,M);R.imageSmoothingEnabled=!1;let j=R.canvas,W=new VI(R,Xo,l,null,m,g,b?wu(so(),b):null),re=t.length,$=Math.floor((256*256*256-1)/re),X={};for(let me=1;me<=re;++me){let _e=t[me-1],pe=_e.getStyleFunction()||a;if(!pe)continue;let xe=pe(_e,o);if(!xe)continue;Array.isArray(xe)||(xe=[xe]);let Me=(me*$).toString(16).padStart(7,"#00000");for(let Se=0,ut=xe.length;Se<ut;++Se){let Ue=xe[Se],$e=Ue.getGeometryFunction()(_e);if(!$e||!ni(A,$e.getExtent()))continue;let pt=Ue.clone(),Pt=pt.getFill();Pt&&Pt.setColor(Me);let et=pt.getStroke();et&&(et.setColor(Me),et.setLineDash(null)),pt.setText(void 0);let ot=Ue.getImage();if(ot){let yt=ot.getImageSize();if(!yt)continue;let Ot=Yr(yt[0],yt[1],void 0,{alpha:!1}),Qt=Ot.canvas;Ot.fillStyle=Me,Ot.fillRect(0,0,Qt.width,Qt.height),pt.setImage(new Pd({img:Qt,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 gt=pt.getZIndex()||0,dt=X[gt];dt||(dt={},X[gt]=dt,dt.Polygon=[],dt.Circle=[],dt.LineString=[],dt.Point=[]);let kt=$e.getType();if(kt==="GeometryCollection"){let yt=$e.getGeometriesArrayRecursive();for(let Ot=0,Qt=yt.length;Ot<Qt;++Ot){let Tr=yt[Ot];dt[Tr.getType().replace("Multi","")].push(Tr,pt)}}else dt[kt.replace("Multi","")].push($e,pt)}}let se=Object.keys(X).map(Number).sort(Oo);for(let me=0,_e=se.length;me<_e;++me){let pe=X[se[me]];for(let xe in pe){let Ee=pe[xe];for(let Me=0,Se=Ee.length;Me<Se;Me+=2){W.setStyle(Ee[Me+1]);for(let ut=0,Ue=e.length;ut<Ue;++ut)W.setTransform(e[ut]),W.drawGeometry(Ee[Me])}}}return R.getImageData(0,0,j.width,j.height)}function $I(s,e,t){let a=[];if(t){let l=Math.floor(Math.round(s[0])*Xo),o=Math.floor(Math.round(s[1])*Xo),m=(zr(l,0,t.width-1)+zr(o,0,t.height-1)*t.width)*4,g=t.data[m],b=t.data[m+1],S=t.data[m+2]+256*(b+256*g),M=Math.floor((256*256*256-1)/e.length);S&&S%M===0&&a.push(e[S/M-1])}return a}var pB=.5,WI={Point:vB,LineString:gB,Polygon:bB,MultiPoint:xB,MultiLineString:yB,MultiPolygon:_B,GeometryCollection:mB,Circle:dB};function ZI(s,e){return parseInt(Nt(s),10)-parseInt(Nt(e),10)}function E0(s,e){let t=I0(s,e);return t*t}function I0(s,e){return pB*s/e}function dB(s,e,t,a,l){let o=t.getFill(),m=t.getStroke();if(o||m){let b=s.getBuilder(t.getZIndex(),"Circle");b.setFillStrokeStyle(o,m),b.drawCircle(e,a,l)}let g=t.getText();if(g&&g.getText()){let b=s.getBuilder(t.getZIndex(),"Text");b.setTextStyle(g),b.drawText(e,a)}}function P0(s,e,t,a,l,o,m,g){let b=[],A=t.getImage();if(A){let R=!0,j=A.getImageState();j==Rt.LOADED||j==Rt.ERROR?R=!1:j==Rt.IDLE&&A.load(),R&&b.push(A.ready())}let S=t.getFill();S&&S.loading()&&b.push(S.ready());let M=b.length>0;return M&&Promise.all(b).then(()=>l(null)),fB(s,e,t,a,o,m,g),M}function fB(s,e,t,a,l,o,m){let g=t.getGeometryFunction()(e);if(!g)return;let b=g.simplifyTransformed(a,l);if(t.getRenderer())HI(s,b,t,e,m);else{let S=WI[b.getType()];S(s,b,t,e,m,o)}}function HI(s,e,t,a,l){if(e.getType()=="GeometryCollection"){let m=e.getGeometries();for(let g=0,b=m.length;g<b;++g)HI(s,m[g],t,a,l);return}s.getBuilder(t.getZIndex(),"Default").drawCustom(e,a,t.getRenderer(),t.getHitDetectionRenderer(),l)}function mB(s,e,t,a,l,o){let m=e.getGeometriesArray(),g,b;for(g=0,b=m.length;g<b;++g){let A=WI[m[g].getType()];A(s,m[g],t,a,l,o)}}function gB(s,e,t,a,l){let o=t.getStroke();if(o){let g=s.getBuilder(t.getZIndex(),"LineString");g.setFillStrokeStyle(null,o),g.drawLineString(e,a,l)}let m=t.getText();if(m&&m.getText()){let g=s.getBuilder(t.getZIndex(),"Text");g.setTextStyle(m),g.drawText(e,a,l)}}function yB(s,e,t,a,l){let o=t.getStroke();if(o){let g=s.getBuilder(t.getZIndex(),"LineString");g.setFillStrokeStyle(null,o),g.drawMultiLineString(e,a,l)}let m=t.getText();if(m&&m.getText()){let g=s.getBuilder(t.getZIndex(),"Text");g.setTextStyle(m),g.drawText(e,a,l)}}function _B(s,e,t,a,l){let o=t.getFill(),m=t.getStroke();if(m||o){let b=s.getBuilder(t.getZIndex(),"Polygon");b.setFillStrokeStyle(o,m),b.drawMultiPolygon(e,a,l)}let g=t.getText();if(g&&g.getText()){let b=s.getBuilder(t.getZIndex(),"Text");b.setTextStyle(g),b.drawText(e,a,l)}}function vB(s,e,t,a,l,o){let m=t.getImage(),g=t.getText(),b=g&&g.getText(),A=o&&m&&b?{}:void 0;if(m){if(m.getImageState()!=Rt.LOADED)return;let S=s.getBuilder(t.getZIndex(),"Image");S.setImageStyle(m,A),S.drawPoint(e,a,l)}if(b){let S=s.getBuilder(t.getZIndex(),"Text");S.setTextStyle(g,A),S.drawText(e,a,l)}}function xB(s,e,t,a,l,o){let m=t.getImage(),g=m&&m.getOpacity()!==0,b=t.getText(),A=b&&b.getText(),S=o&&g&&A?{}:void 0;if(g){if(m.getImageState()!=Rt.LOADED)return;let M=s.getBuilder(t.getZIndex(),"Image");M.setImageStyle(m,S),M.drawMultiPoint(e,a,l)}if(A){let M=s.getBuilder(t.getZIndex(),"Text");M.setTextStyle(b,S),M.drawText(e,a,l)}}function bB(s,e,t,a,l){let o=t.getFill(),m=t.getStroke();if(o||m){let b=s.getBuilder(t.getZIndex(),"Polygon");b.setFillStrokeStyle(o,m),b.drawPolygon(e,a,l)}let g=t.getText();if(g&&g.getText()){let b=s.getBuilder(t.getZIndex(),"Text");b.setTextStyle(g),b.drawText(e,a,l)}}var T0=class extends fg{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_=On(),this.wrappedRenderedExtent_=On(),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,t,a){let l=t.extent,o=t.viewState,m=o.center,g=o.resolution,b=o.projection,A=o.rotation,S=b.getExtent(),M=this.getLayer().getSource(),R=this.getLayer().getDeclutter(),j=t.pixelRatio,W=t.viewHints,re=!(W[Bn.ANIMATING]||W[Bn.INTERACTING]),$=this.context,X=Math.round(Fr(l)/g*j),se=Math.round(hi(l)/g*j),me=M.getWrapX()&&b.canWrapX(),_e=me?Fr(S):null,pe=me?Math.ceil((l[2]-S[2])/_e)+1:1,xe=me?Math.floor((l[0]-S[0])/_e):0;do{let Ee=this.getRenderTransform(m,g,0,j,X,se,xe*_e);t.declutter&&(Ee=Ee.slice(0)),e.execute($,[$.canvas.width,$.canvas.height],Ee,A,re,a===void 0?Hl:a?S0:UI,a?R&&t.declutter[R]:void 0)}while(++xe<pe)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Yr(this.context.canvas.width,this.context.canvas.height,_0))}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,WE(this.context),_0.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,t){let a=e.layerStatesArray[e.layerIndex];this.opacity_=a.opacity;let l=e.viewState;this.prepareContainer(e,t);let o=this.context,m=this.replayGroup_,g=m&&!m.isEmpty();if(!g&&!(this.getLayer().hasListener(ds.PRERENDER)||this.getLayer().hasListener(ds.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(o,e);let b=l.projection;if(this.clipped_=!1,g&&a.extent&&this.clipping){let A=ps(a.extent,b);g=ni(A,e.extent),this.clipped_=g&&!Ks(A,e.extent),this.clipped_&&this.clipUnrotated(o,e,A)}return g&&this.renderWorlds(m,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&o.restore(),this.postRender(o,e),this.renderedRotation_!==l.rotation&&(this.renderedRotation_=l.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(t=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let a=this.frameState.size.slice(),l=this.renderedCenter_,o=this.renderedResolution_,m=this.renderedRotation_,g=this.renderedProjection_,b=this.wrappedRenderedExtent_,A=this.getLayer(),S=[],M=a[0]*Xo,R=a[1]*Xo;S.push(this.getRenderTransform(l,o,m,Xo,M,R,0).slice());let j=A.getSource(),W=g.getExtent();if(j.getWrapX()&&g.canWrapX()&&!Ks(W,b)){let $=b[0],X=Fr(W),se=0,me;for(;$<W[0];)--se,me=X*se,S.push(this.getRenderTransform(l,o,m,Xo,M,R,me).slice()),$+=X;for(se=0,$=b[2];$>W[2];)++se,me=X*se,S.push(this.getRenderTransform(l,o,m,Xo,M,R,me).slice()),$-=X}let re=so();this.hitDetectionImageData_=qI(a,S,this.renderedFeatures_,A.getStyleFunction(),b,o,m,E0(o,this.renderedPixelRatio_),re?g:null)}t($I(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,a,l,o){if(!this.replayGroup_)return;let m=t.viewState.resolution,g=t.viewState.rotation,b=this.getLayer(),A={},S=function(W,re,$){let X=Nt(W),se=A[X];if(se){if(se!==!0&&$<se.distanceSq){if($===0)return A[X]=!0,o.splice(o.lastIndexOf(se),1),l(W,b,re);se.geometry=re,se.distanceSq=$}}else{if($===0)return A[X]=!0,l(W,b,re);o.push(A[X]={feature:W,layer:b,geometry:re,distanceSq:$,callback:l})}},M,R=[this.replayGroup_],j=this.getLayer().getDeclutter();return R.some(W=>M=W.forEachFeatureAtCoordinate(e,m,g,a,S,j&&t.declutter[j]?t.declutter[j].all().map(re=>re.value):null)),M}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let t=this.getLayer(),a=t.getSource();if(!a)return!1;let l=e.viewHints[Bn.ANIMATING],o=e.viewHints[Bn.INTERACTING],m=t.getUpdateWhileAnimating(),g=t.getUpdateWhileInteracting();if(this.ready&&!m&&l||!g&&o)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let b=e.extent,A=e.viewState,S=A.projection,M=A.resolution,R=e.pixelRatio,j=t.getRevision(),W=t.getRenderBuffer(),re=t.getRenderOrder();re===void 0&&(re=ZI);let $=A.center.slice(),X=Ln(b,W*M),se=X.slice(),me=[X.slice()],_e=S.getExtent();if(a.getWrapX()&&S.canWrapX()&&!Ks(_e,e.extent)){let et=Fr(_e),ot=Math.max(Fr(X)/2,et);X[0]=_e[0]-ot,X[2]=_e[2]+ot,aE($,S);let gt=xv(me[0],S);gt[0]<_e[0]&>[2]<_e[2]?me.push([gt[0]+et,gt[1],gt[2]+et,gt[3]]):gt[0]>_e[0]&>[2]>_e[2]&&me.push([gt[0]-et,gt[1],gt[2]-et,gt[3]])}if(this.ready&&this.renderedResolution_==M&&this.renderedRevision_==j&&this.renderedRenderOrder_==re&&this.renderedFrameDeclutter_===!!e.declutter&&Ks(this.wrappedRenderedExtent_,X))return Fn(this.renderedExtent_,se)||(this.hitDetectionImageData_=null,this.renderedExtent_=se),this.renderedCenter_=$,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let pe=new DI(I0(M,R),X,M,R),xe=so(),Ee;if(xe){for(let et=0,ot=me.length;et<ot;++et){let gt=me[et],dt=hs(gt,S);a.loadFeatures(dt,dE(M,S),xe)}Ee=wu(xe,S)}else for(let et=0,ot=me.length;et<ot;++et)a.loadFeatures(me[et],M,S);let Me=E0(M,R),Se=!0,ut=(et,ot)=>{let gt,dt=et.getStyleFunction()||t.getStyleFunction();if(dt&&(gt=dt(et,M)),gt){let kt=this.renderFeature(et,Me,gt,pe,Ee,this.getLayer().getDeclutter(),ot);Se=Se&&!kt}},Ue=hs(X,S),$e=a.getFeaturesInExtent(Ue);re&&$e.sort(re);for(let et=0,ot=$e.length;et<ot;++et)ut($e[et],et);this.renderedFeatures_=$e,this.ready=Se;let pt=pe.finish(),Pt=new GI(X,M,R,a.getOverlaps(),pt,t.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=M,this.renderedRevision_=j,this.renderedRenderOrder_=re,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=se,this.wrappedRenderedExtent_=X,this.renderedCenter_=$,this.renderedProjection_=S,this.renderedPixelRatio_=R,this.replayGroup_=Pt,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,t,a,l,o,m,g){if(!a)return!1;let b=!1;if(Array.isArray(a))for(let A=0,S=a.length;A<S;++A)b=P0(l,e,a[A],t,this.boundHandleStyleImageChange_,o,m,g)||b;else b=P0(l,e,a,t,this.boundHandleStyleImageChange_,o,m,g);return b}},XI=T0;var C0=class extends CI{constructor(e){super(e)}createRenderer(){return new XI(this)}},Xl=C0;var YI=Lo(Hx(),1);var M0=class{constructor(e){this.rbush_=new YI.default(e),this.items_={}}insert(e,t){let a={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:t};this.rbush_.insert(a),this.items_[Nt(t)]=a}load(e,t){let a=new Array(t.length);for(let l=0,o=t.length;l<o;l++){let m=e[l],g=t[l],b={minX:m[0],minY:m[1],maxX:m[2],maxY:m[3],value:g};a[l]=b,this.items_[Nt(g)]=b}this.rbush_.load(a)}remove(e){let t=Nt(e),a=this.items_[t];return delete this.items_[t],this.rbush_.remove(a)!==null}update(e,t){let a=this.items_[Nt(t)],l=[a.minX,a.minY,a.maxX,a.maxY];Lm(l,e)||(this.remove(t),this.insert(e,t))}getAll(){return this.rbush_.all().map(function(t){return t.value})}getInExtent(e){let t={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(t).map(function(l){return l.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,t){return this.forEach_(this.getInExtent(e),t)}forEach_(e,t){let a;for(let l=0,o=e.length;l<o;l++)if(a=t(e[l]),a)return a;return a}isEmpty(){return oo(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let t=this.rbush_.toJSON();return Js(t.minX,t.minY,t.maxX,t.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(let t in e.items_)this.items_[t]=e.items_[t]}},Bd=M0;var KI=Ai(),jd=class s{constructor(e,t,a,l,o,m){this.styleFunction,this.extent_,this.id_=m,this.type_=e,this.flatCoordinates_=t,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=a||null,this.properties_=o,this.squaredTolerance_,this.stride_=l,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Ba(this.flatCoordinates_):_u(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=_o(this.getExtent());this.flatInteriorPoints_=md(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=RE(this.flatCoordinates_,this.ends_),t=Hm(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Wm(this.flatCoordinates_,0,e,2,t)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Vl(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let e=this.flatCoordinates_,t=0,a=this.ends_;for(let l=0,o=a.length;l<o;++l){let m=a[l],g=Vl(e,t,m,2,.5);Bi(this.flatMidpoints_,g),t=m}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,t){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=Xr(e);let t=e.getExtent(),a=e.getWorldExtent();if(t&&a){let l=hi(a)/hi(t);cn(KI,a[0],a[3],l,-l,0,0,0),zn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,KI,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new s(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Cm((e,t)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),t&&this.simplifiedGeometry_.applyTransform(t);let a=this.simplifiedGeometry_.getFlatCoordinates(),l;switch(this.type_){case"LineString":a.length=Gl(a,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,a,0),l=[a.length];break;case"MultiLineString":l=[],a.length=Gm(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,a,0,l);break;case"Polygon":l=[],a.length=ud(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),a,0,l);break;default:}return l&&(this.simplifiedGeometry_=new s(this.type_,a,l,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};jd.prototype.getFlatCoordinates=jd.prototype.getOrientedFlatCoordinates;var wo=jd;var R0=class extends Ei{constructor(e){super(),this.projection=Xr(e.projection),this.attributions_=JI(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible!==void 0?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 t=this;this.viewPromise_=new Promise(function(a,l){t.viewResolver=a,t.viewRejector=l})}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_=JI(e),this.changed()}setState(e){this.state_=e,this.changed()}};function JI(s){return s?Array.isArray(s)?function(e){return s}:typeof s=="function"?s:function(e){return[s]}:null}var ua=R0;var pn={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function QI(s,e){return[[-1/0,-1/0,1/0,1/0]]}var wB=!1;function SB(s,e,t,a,l,o,m){let g=new XMLHttpRequest;g.open("GET",typeof s=="function"?s(t,a,l):s,!0),e.getType()=="arraybuffer"&&(g.responseType="arraybuffer"),g.withCredentials=wB,g.onload=function(b){if(!g.status||g.status>=200&&g.status<300){let A=e.getType();try{let S;A=="text"||A=="json"?S=g.responseText:A=="xml"?S=g.responseXML||g.responseText:A=="arraybuffer"&&(S=g.response),S?o(e.readFeatures(S,{extent:t,featureProjection:l}),e.readProjection(S)):m()}catch{m()}}else m()},g.onerror=m,g.send()}function k0(s,e){return function(t,a,l,o,m){let g=this;SB(s,e,t,a,l,function(b,A){g.addFeatures(b),o!==void 0&&o(b)},m||zo)}}var xs=class extends Or{constructor(e,t,a){super(e),this.feature=t,this.features=a}},F0=class extends ua{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_=zo,this.format_=e.format,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&&(xr(this.format_,"`format` must be set when `url` is set"),this.loader_=k0(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:QI;let t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Bd:null,this.loadedExtentsRtree_=new Bd,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let a,l;Array.isArray(e.features)?l=e.features:e.features&&(a=e.features,l=a.getArray()),!t&&a===void 0&&(a=new Sd(l)),l!==void 0&&this.addFeaturesInternal(l),a!==void 0&&this.bindFeaturesCollection_(a)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let t=Nt(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);let a=e.getGeometry();if(a){let l=a.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(l,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new xs(pn.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof wo||(this.featureChangeKeys_[e]=[ji(t,Er.CHANGE,this.handleFeatureChange_,this),ji(t,Im.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let a=!0;if(t.getId()!==void 0){let l=String(t.getId());if(!(l in this.idIndex_))this.idIndex_[l]=t;else if(t instanceof wo){let o=this.idIndex_[l];o instanceof wo?Array.isArray(o)?o.push(t):this.idIndex_[l]=[o,t]:a=!1}else a=!1}return a&&(xr(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),a}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let t=[],a=[],l=[];for(let o=0,m=e.length;o<m;o++){let g=e[o],b=Nt(g);this.addToIndex_(b,g)&&a.push(g)}for(let o=0,m=a.length;o<m;o++){let g=a[o],b=Nt(g);this.setupChangeEvents_(b,g);let A=g.getGeometry();if(A){let S=A.getExtent();t.push(S),l.push(g)}else this.nullGeometryFeatures_[b]=g}if(this.featuresRtree_&&this.featuresRtree_.load(t,l),this.hasListener(pn.ADDFEATURE))for(let o=0,m=a.length;o<m;o++)this.dispatchEvent(new xs(pn.ADDFEATURE,a[o]))}bindFeaturesCollection_(e){let t=!1;this.addEventListener(pn.ADDFEATURE,function(a){t||(t=!0,e.push(a.feature),t=!1)}),this.addEventListener(pn.REMOVEFEATURE,function(a){t||(t=!0,e.remove(a.feature),t=!1)}),e.addEventListener(qo.ADD,a=>{t||(t=!0,this.addFeature(a.element),t=!1)}),e.addEventListener(qo.REMOVE,a=>{t||(t=!0,this.removeFeature(a.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(let a in this.featureChangeKeys_)this.featureChangeKeys_[a].forEach(un);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){let a=l=>{this.removeFeatureInternal(l)};this.featuresRtree_.forEach(a);for(let l in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[l])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let t=new xs(pn.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){let a=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(a,function(l){let o=l.getGeometry();if(o instanceof wo||o.intersectsCoordinate(e))return t(l)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(a){let l=a.getGeometry();if(l instanceof wo||l.intersectsExtent(e)){let o=t(a);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(),oo(this.nullGeometryFeatures_)||Bi(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let t=[];return this.forEachFeatureAtCoordinateDirect(e,function(a){t.push(a)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let l=ZA(e,t);return[].concat(...l.map(o=>this.featuresRtree_.getInExtent(o)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){let a=e[0],l=e[1],o=null,m=[NaN,NaN],g=1/0,b=[-1/0,-1/0,1/0,1/0];return t=t||Tm,this.featuresRtree_.forEachInExtent(b,function(A){if(t(A)){let S=A.getGeometry(),M=g;if(g=S instanceof wo?0:S.closestPointXY(a,l,m,g),g<M){o=A;let R=Math.sqrt(g);b[0]=a-R,b[1]=l-R,b[2]=a+R,b[3]=l+R}}}),o}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){let t=this.idIndex_[e.toString()];return t!==void 0?t:null}getFeatureByUid(e){let t=this.uidIndex_[e];return t!==void 0?t:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){let t=e.target,a=Nt(t),l=t.getGeometry();if(!l)a in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(t),this.nullGeometryFeatures_[a]=t);else{let m=l.getExtent();a in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[a],this.featuresRtree_&&this.featuresRtree_.insert(m,t)):this.featuresRtree_&&this.featuresRtree_.update(m,t)}let o=t.getId();if(o!==void 0){let m=o.toString();this.idIndex_[m]!==t&&(this.removeFromIdIndex_(t),this.idIndex_[m]=t)}else this.removeFromIdIndex_(t),this.uidIndex_[a]=t;this.changed(),this.dispatchEvent(new xs(pn.CHANGEFEATURE,t))}hasFeature(e){let t=e.getId();return t!==void 0?t in this.idIndex_:Nt(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&oo(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,t,a){let l=this.loadedExtentsRtree_,o=this.strategy_(e,t,a);for(let m=0,g=o.length;m<g;++m){let b=o[m];l.forEachInExtent(b,function(S){return Ks(S.extent,b)})||(++this.loadingExtentsCount_,this.dispatchEvent(new xs(pn.FEATURESLOADSTART)),this.loader_.call(this,b,t,a,S=>{--this.loadingExtentsCount_,this.dispatchEvent(new xs(pn.FEATURESLOADEND,void 0,S))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new xs(pn.FEATURESLOADERROR))}),l.insert(b,{extent:b.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){let t=this.loadedExtentsRtree_,a;t.forEachInExtent(e,function(l){if(Lm(l.extent,e))return a=l,!0}),a&&t.remove(a)}removeFeatures(e){let t=[];for(let a=0,l=e.length;a<l;++a){let o=e[a],m=this.removeFeatureInternal(o);m&&t.push(m)}t.length>0&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){let t=Nt(e);if(!(t in this.uidIndex_))return;t in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[t]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[t]?.forEach(un),delete this.featureChangeKeys_[t];let l=e.getId();if(l!==void 0){let o=l.toString(),m=this.idIndex_[o];m===e?delete this.idIndex_[o]:Array.isArray(m)&&(m.splice(m.indexOf(e),1),m.length===1&&(this.idIndex_[o]=m[0]))}return delete this.uidIndex_[t],this.hasListener(pn.REMOVEFEATURE)&&this.dispatchEvent(new xs(pn.REMOVEFEATURE,e)),e}removeFromIdIndex_(e){let t=!1;for(let a in this.idIndex_){let l=this.idIndex_[a];if(e instanceof wo&&Array.isArray(l)&&l.includes(e))l.splice(l.indexOf(e),1);else if(this.idIndex_[a]===e){delete this.idIndex_[a],t=!0;break}}return t}setLoader(e){this.loader_=e}setUrl(e){xr(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(k0(e,this.format_))}},Yl=F0;var ao={SINGLECLICK:"singleclick",CLICK:Er.CLICK,DBLCLICK:Er.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var L0={ACTIVE:"active"};var D0=class extends Ei{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(L0.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(L0.ACTIVE,e)}setMap(e){this.map_=e}};var e2=D0;var O0=class extends e2{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 t=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==ao.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==ao.POINTERUP){let a=this.handleUpEvent(e);this.handlingDownUpSequence=a&&this.targetPointers.length>0}}else if(e.type==ao.POINTERDOWN){let a=this.handleDownEvent(e);this.handlingDownUpSequence=a,t=this.stopDown(a)}else e.type==ao.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};var t2=O0;var r2=function(s){let e=s.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var i2=Tm,n2=function(s){return s.type==ao.CLICK};var o2=function(s){return s.type==ao.SINGLECLICK};var s2=function(s){let e=s.originalEvent;return xr(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var a2=0,Nd=1,l2=[0,0,0,0],Ou=[],z0={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},Ud=class extends Or{constructor(e,t,a){super(e),this.features=t,this.mapBrowserEvent=a}},B0=class extends t2{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:s2,this.defaultDeleteCondition_=function(a){return r2(a)&&o2(a)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:i2,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Bd,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Xl({source:new Yl({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:EB(),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 t;if(e.features?t=e.features:e.source&&(this.source_=e.source,t=new Sd(this.source_.getFeatures()),this.source_.addEventListener(pn.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(pn.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!t)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=t,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(qo.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(qo.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 t=e.getGeometry();if(t){let l=this.SEGMENT_WRITERS_[t.getType()];l&&l(e,t)}let a=this.getMap();a&&a.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastPixel_,a),e.addEventListener(Er.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Sd;let a=this.featuresBeingModified_.getArray();for(let l=0,o=t.length;l<o;++l){let m=t[l];for(let g=0,b=m.length;g<b;++g){let A=m[g].feature;A&&!a.includes(A)&&this.featuresBeingModified_.push(A)}}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new Ud(z0.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(Er.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){let t=this.rBush_,a=[];t.forEach(function(l){e===l.feature&&a.push(l)});for(let l=a.length-1;l>=0;--l){let o=a[l];for(let m=this.dragSegments_.length-1;m>=0;--m)this.dragSegments_[m][0]===o&&this.dragSegments_.splice(m,1);t.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 t=e.target;this.removeFeature_(t),this.addFeature_(t)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,t){let a=t.getCoordinates(),l={feature:e,geometry:t,segment:[a,a]};this.rBush_.insert(t.getExtent(),l)}writeMultiPointGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length;l<o;++l){let m=a[l],g={feature:e,geometry:t,depth:[l],index:l,segment:[m,m]};this.rBush_.insert(t.getExtent(),g)}}writeLineStringGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length-1;l<o;++l){let m=a.slice(l,l+2),g={feature:e,geometry:t,index:l,segment:m};this.rBush_.insert(us(m),g)}}writeMultiLineStringGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length;l<o;++l){let m=a[l];for(let g=0,b=m.length-1;g<b;++g){let A=m.slice(g,g+2),S={feature:e,geometry:t,depth:[l],index:g,segment:A};this.rBush_.insert(us(A),S)}}}writePolygonGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length;l<o;++l){let m=a[l];for(let g=0,b=m.length-1;g<b;++g){let A=m.slice(g,g+2),S={feature:e,geometry:t,depth:[l],index:g,segment:A};this.rBush_.insert(us(A),S)}}}writeMultiPolygonGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length;l<o;++l){let m=a[l];for(let g=0,b=m.length;g<b;++g){let A=m[g];for(let S=0,M=A.length-1;S<M;++S){let R=A.slice(S,S+2),j={feature:e,geometry:t,depth:[g,l],index:S,segment:R};this.rBush_.insert(us(R),j)}}}}writeCircleGeometry_(e,t){let a=t.getCenter(),l={feature:e,geometry:t,index:a2,segment:[a,a]},o={feature:e,geometry:t,index:Nd,segment:[a,a]},m=[l,o];l.featureSegments=m,o.featureSegments=m,this.rBush_.insert(Ba(a),l);let g=t,b=so();if(b&&this.getMap()){let A=this.getMap().getView().getProjection();g=g.clone().transform(b,A),g=Zv(g).transform(A,b)}this.rBush_.insert(g.getExtent(),o)}writeGeometryCollectionGeometry_(e,t){let a=t.getGeometriesArray();for(let l=0;l<a.length;++l){let o=a[l],m=this.SEGMENT_WRITERS_[o.getType()];m(e,o)}}createOrUpdateVertexFeature_(e,t,a){let l=this.vertexFeature_;return l?l.getGeometry().setCoordinates(e):(l=new bo(new Pi(e)),this.vertexFeature_=l,this.overlay_.getSource().addFeature(l)),l.set("features",t),l.set("geometries",a),l}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let t;return!e.map.getView().getInteracting()&&e.type==ao.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=ao.SINGLECLICK||!this.ignoreNextSingleClick_?t=this.removePoint():t=!0),e.type==ao.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!t}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_);let t=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],a=[],l=[];for(let o=0,m=this.dragSegments_.length;o<m;++o){let g=this.dragSegments_[o],b=g[0],A=b.feature;a.includes(A)||a.push(A);let S=b.geometry;l.includes(S)||l.push(S);let M=b.depth,R,j=b.segment,W=g[1];for(;t.length<S.getStride();)t.push(j[W][t.length]);switch(S.getType()){case"Point":R=t,j[0]=t,j[1]=t;break;case"MultiPoint":R=S.getCoordinates(),R[b.index]=t,j[0]=t,j[1]=t;break;case"LineString":R=S.getCoordinates(),R[b.index+W]=t,j[W]=t;break;case"MultiLineString":R=S.getCoordinates(),R[M[0]][b.index+W]=t,j[W]=t;break;case"Polygon":R=S.getCoordinates(),R[M[0]][b.index+W]=t,j[W]=t;break;case"MultiPolygon":R=S.getCoordinates(),R[M[1]][M[0]][b.index+W]=t,j[W]=t;break;case"Circle":if(j[0]=t,j[1]=t,b.index===a2)this.changingFeature_=!0,S.setCenter(t),this.changingFeature_=!1;else{this.changingFeature_=!0;let re=e.map.getView().getProjection(),$=Iv(oi(S.getCenter(),re),oi(t,re)),X=so();if(X){let se=S.clone().transform(X,re);se.setRadius($),$=se.transform(re,X).getRadius()}S.setRadius($),this.changingFeature_=!1}break;default:}R&&this.setGeometryCoordinates_(S,R)}this.createOrUpdateVertexFeature_(t,a,l)}handleDownEvent(e){if(!this.condition_(e))return!1;let t=e.coordinate;this.handlePointerAtPixel_(e.pixel,e.map,t),this.dragSegments_.length=0,this.featuresBeingModified_=null;let a=this.vertexFeature_;if(a){let l=e.map.getView().getProjection(),o=[],m=a.getGeometry().getCoordinates(),g=us([m]),b=this.rBush_.getInExtent(g),A={};b.sort(AB);for(let S=0,M=b.length;S<M;++S){let R=b[S],j=R.segment,W=Nt(R.geometry),re=R.depth;if(re&&(W+="-"+re.join("-")),A[W]||(A[W]=new Array(2)),R.geometry.getType()==="Circle"&&R.index===Nd){let $=u2(t,R,l);Sn($,m)&&!A[W][0]&&(this.dragSegments_.push([R,0]),A[W][0]=R);continue}if(Sn(j[0],m)&&!A[W][0]){this.dragSegments_.push([R,0]),A[W][0]=R;continue}if(Sn(j[1],m)&&!A[W][1]){if(A[W][0]&&A[W][0].index===0){let $=R.geometry.getCoordinates();switch(R.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":$=$[re[1]];case"Polygon":if(R.index!==$[re[0]].length-2)continue;break;default:}}this.dragSegments_.push([R,1]),A[W][1]=R;continue}Nt(j)in this.vertexSegments_&&!A[W][0]&&!A[W][1]&&this.insertVertexCondition_(e)&&o.push(R)}o.length&&this.willModifyFeatures_(e,[o]);for(let S=o.length-1;S>=0;--S)this.insertVertex_(o[S],m)}return!!this.vertexFeature_}handleUpEvent(e){for(let t=this.dragSegments_.length-1;t>=0;--t){let a=this.dragSegments_[t][0],l=a.geometry;if(l.getType()==="Circle"){let o=l.getCenter(),m=a.featureSegments[0],g=a.featureSegments[1];m.segment[0]=o,m.segment[1]=o,g.segment[0]=o,g.segment[1]=o,this.rBush_.update(Ba(o),m);let b=l,A=so();if(A){let S=e.map.getView().getProjection();b=b.clone().transform(A,S),b=Zv(b).transform(S,A)}this.rBush_.update(b.getExtent(),g)}else this.rBush_.update(us(a.segment),a)}return this.featuresBeingModified_&&(this.dispatchEvent(new Ud(z0.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastPixel_=e.pixel,this.handlePointerAtPixel_(e.pixel,e.map,e.coordinate)}handlePointerAtPixel_(e,t,a){let l=a||t.getCoordinateFromPixel(e),o=t.getView().getProjection(),m=function(A,S){return c2(l,A,o)-c2(l,S,o)},g,b;if(this.hitDetection_){let A=typeof this.hitDetection_=="object"?S=>S===this.hitDetection_:void 0;t.forEachFeatureAtPixel(e,(S,M,R)=>{R&&R.getType()==="Point"&&(R=new Pi(Nl(R.getCoordinates(),o)));let j=R||S.getGeometry();if(S instanceof bo&&this.features_.getArray().includes(S)){b=j;let W=S.getGeometry().getFlatCoordinates().slice(0,2);g=[{feature:S,geometry:b,segment:[W,W]}]}return!0},{layerFilter:A})}if(!g){let A=ps(Ba(l,l2),o),S=t.getView().getResolution()*this.pixelTolerance_,M=hs(Ln(A,S,l2),o);g=this.rBush_.getInExtent(M)}if(g&&g.length>0){let A=g.sort(m)[0],S=A.segment,M=u2(l,A,o),R=t.getPixelFromCoordinate(M),j=Iv(e,R);if(b||j<=this.pixelTolerance_){let W={};if(W[Nt(S)]=!0,this.snapToPointer_||(this.delta_[0]=M[0]-l[0],this.delta_[1]=M[1]-l[1]),A.geometry.getType()==="Circle"&&A.index===Nd)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(M,[A.feature],[A.geometry]);else{let re=t.getPixelFromCoordinate(S[0]),$=t.getPixelFromCoordinate(S[1]),X=bu(R,re),se=bu(R,$);j=Math.sqrt(Math.min(X,se)),this.snappedToVertex_=j<=this.pixelTolerance_,this.snappedToVertex_&&(M=X>se?S[1]:S[0]),this.createOrUpdateVertexFeature_(M,[A.feature],[A.geometry]);let me={};me[Nt(A.geometry)]=!0;for(let _e=1,pe=g.length;_e<pe;++_e){let xe=g[_e].segment;if(Sn(S[0],xe[0])&&Sn(S[1],xe[1])||Sn(S[0],xe[1])&&Sn(S[1],xe[0])){let Ee=Nt(g[_e].geometry);Ee in me||(me[Ee]=!0,W[Nt(xe)]=!0)}else break}}this.vertexSegments_=W;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,t){let a=e.segment,l=e.feature,o=e.geometry,m=e.depth,g=e.index,b;for(;t.length<o.getStride();)t.push(0);switch(o.getType()){case"MultiLineString":b=o.getCoordinates(),b[m[0]].splice(g+1,0,t);break;case"Polygon":b=o.getCoordinates(),b[m[0]].splice(g+1,0,t);break;case"MultiPolygon":b=o.getCoordinates(),b[m[1]][m[0]].splice(g+1,0,t);break;case"LineString":b=o.getCoordinates(),b.splice(g+1,0,t);break;default:return}this.setGeometryCoordinates_(o,b);let A=this.rBush_;A.remove(e),this.updateSegmentIndices_(o,g,m,1);let S={segment:[a[0],t],feature:l,geometry:o,depth:m,index:g};A.insert(us(S.segment),S),this.dragSegments_.push([S,1]);let M={segment:[t,a[1]],feature:l,geometry:o,depth:m,index:g+1};A.insert(us(M.segment),M),this.dragSegments_.push([M,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=ao.POINTERDRAG){let e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_);let t=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Ud(z0.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null,t}return!1}removeVertex_(){let e=this.dragSegments_,t={},a=!1,l,o,m,g,b,A,S,M,R,j,W;for(b=e.length-1;b>=0;--b)m=e[b],j=m[0],W=Nt(j.feature),j.depth&&(W+="-"+j.depth.join("-")),W in t||(t[W]={}),m[1]===0?(t[W].right=j,t[W].index=j.index):m[1]==1&&(t[W].left=j,t[W].index=j.index+1);for(W in t){switch(R=t[W].right,S=t[W].left,A=t[W].index,M=A-1,S!==void 0?j=S:j=R,M<0&&(M=0),g=j.geometry,o=g.getCoordinates(),l=o,a=!1,g.getType()){case"MultiLineString":o[j.depth[0]].length>2&&(o[j.depth[0]].splice(A,1),a=!0);break;case"LineString":o.length>2&&(o.splice(A,1),a=!0);break;case"MultiPolygon":l=l[j.depth[1]];case"Polygon":l=l[j.depth[0]],l.length>4&&(A==l.length-1&&(A=0),l.splice(A,1),a=!0,A===0&&(l.pop(),l.push(l[0]),M=l.length-1));break;default:}if(a){this.setGeometryCoordinates_(g,o);let re=[];if(S!==void 0&&(this.rBush_.remove(S),re.push(S.segment[0])),R!==void 0&&(this.rBush_.remove(R),re.push(R.segment[1])),S!==void 0&&R!==void 0){let $={depth:j.depth,feature:j.feature,geometry:j.geometry,index:M,segment:re};this.rBush_.insert(us($.segment),$)}this.updateSegmentIndices_(g,A,j.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return a}setGeometryCoordinates_(e,t){this.changingFeature_=!0,e.setCoordinates(t),this.changingFeature_=!1}updateSegmentIndices_(e,t,a,l){this.rBush_.forEachInExtent(e.getExtent(),function(o){o.geometry===e&&(a===void 0||o.depth===void 0||Fn(o.depth,a))&&o.index>t&&(o.index+=l)})}};function AB(s,e){return s.index-e.index}function c2(s,e,t){let a=e.geometry;if(a.getType()==="Circle"){let o=a;if(e.index===Nd){let m=so();m&&(o=o.clone().transform(m,t));let g=bu(o.getCenter(),oi(s,t)),b=Math.sqrt(g)-o.getRadius();return b*b}}let l=oi(s,t);return Ou[0]=oi(e.segment[0],t),Ou[1]=oi(e.segment[1],t),sE(l,Ou)}function u2(s,e,t){let a=e.geometry;if(a.getType()==="Circle"&&e.index===Nd){let o=a,m=so();return m&&(o=o.clone().transform(m,t)),Nl(o.getClosestPoint(oi(s,t)),t)}let l=oi(s,t);return Ou[0]=oi(e.segment[0],t),Ou[1]=oi(e.segment[1],t),Nl(Ev(l,Ou),t)}function EB(){let s=fI();return function(e,t){return s.Point}}var j0=B0;var N0=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=bo,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let a=t.dataProjection?Xr(t.dataProjection):this.readProjection(e);t.extent&&a&&a.getUnits()==="tile-pixels"&&(a=Xr(a),a.setWorldExtent(t.extent)),t={dataProjection:a,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return It()}readFeature(e,t){return It()}readFeatures(e,t){return It()}readGeometry(e,t){return It()}readProjection(e){return It()}writeFeature(e,t){return It()}writeFeatures(e,t){return It()}writeGeometry(e,t){return It()}},h2=N0;function mg(s,e,t){let a=t?Xr(t.featureProjection):null,l=t?Xr(t.dataProjection):null,o=s;if(a&&l&&!pE(a,l)){e&&(o=s.clone());let m=e?a:l,g=e?l:a;m.getUnits()==="tile-pixels"?o.transform(m,g):o.applyTransform(jl(m,g))}if(e&&t&&t.decimals!==void 0){let m=Math.pow(10,t.decimals),g=function(b){for(let A=0,S=b.length;A<S;++A)b[A]=Math.round(b[A]*m)/m;return b};o===s&&(o=s.clone()),o.applyTransform(g)}return o}var IB={Point:Pi,LineString:No,Polygon:Au,MultiPoint:fd,MultiLineString:Gv,MultiPolygon:Xv};function PB(s,e,t){return Array.isArray(e[0])?(Zm(s,0,e,t)||(s=s.slice(),yd(s,0,e,t)),s):(gd(s,0,e,t)||(s=s.slice(),Su(s,0,e,t)),s)}function U0(s,e){let t=s.geometry;if(!t)return[];if(Array.isArray(t))return t.map(o=>U0({...s,geometry:o})).flat();let a=t.type==="MultiPolygon"?"Polygon":t.type;if(a==="GeometryCollection"||a==="Circle")throw new Error("Unsupported geometry type: "+a);let l=t.layout.length;return mg(new wo(a,a==="Polygon"?PB(t.flatCoordinates,t.ends,l):t.flatCoordinates,t.ends?.flat(),l,s.properties||{},s.id).enableSimplifyTransformed(),!1,e)}function gg(s,e){if(!s)return null;if(Array.isArray(s)){let a=s.map(l=>gg(l,e));return new Lv(a)}let t=IB[s.type];return mg(new t(s.flatCoordinates,s.layout,s.ends),!1,e)}var G0=class extends h2{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(yg(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(yg(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return It()}readFeaturesFromObject(e,t){return It()}readGeometry(e,t){return this.readGeometryFromObject(yg(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return It()}readProjection(e){return this.readProjectionFromObject(yg(e))}readProjectionFromObject(e){return It()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return It()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return It()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return It()}};function yg(s){if(typeof s=="string"){let e=JSON.parse(s);return e||null}return s!==null?s:null}var p2=G0;var V0=class extends p2{constructor(e){e=e||{},super(),this.dataProjection=Xr(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=Xr(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,t){let a=null;e.type==="Feature"?a=e:a={type:"Feature",geometry:e,properties:null};let l=$0(a.geometry,t);if(this.featureClass===wo)return U0({geometry:l,id:a.id,properties:a.properties},t);let o=new bo;return this.geometryName_?o.setGeometryName(this.geometryName_):this.extractGeometryName_&&a.geometry_name&&o.setGeometryName(a.geometry_name),o.setGeometry(gg(l,t)),"id"in a&&o.setId(a.id),a.properties&&o.setProperties(a.properties,!0),o}readFeaturesFromObject(e,t){let a=e,l=null;if(a.type==="FeatureCollection"){let o=e;l=[];let m=o.features;for(let g=0,b=m.length;g<b;++g){let A=this.readFeatureFromObject(m[g],t);A&&l.push(A)}}else l=[this.readFeatureFromObject(e,t)];return l.flat()}readGeometryFromObject(e,t){return TB(e,t)}readProjectionFromObject(e){let t=e.crs,a;if(t)if(t.type=="name")a=Xr(t.properties.name);else if(t.type==="EPSG")a=Xr("EPSG:"+t.properties.code);else throw new Error("Unknown SRS type");else a=this.dataProjection;return a}writeFeatureObject(e,t){t=this.adaptOptions(t);let a={type:"Feature",geometry:null,properties:null},l=e.getId();if(l!==void 0&&(a.id=l),!e.hasProperties())return a;let o=e.getProperties(),m=e.getGeometry();return m&&(a.geometry=q0(m,t),delete o[e.getGeometryName()]),oo(o)||(a.properties=o),a}writeFeaturesObject(e,t){t=this.adaptOptions(t);let a=[];for(let l=0,o=e.length;l<o;++l)a.push(this.writeFeatureObject(e[l],t));return{type:"FeatureCollection",features:a}}writeGeometryObject(e,t){return q0(e,this.adaptOptions(t))}};function $0(s,e){if(!s)return null;let t;switch(s.type){case"Point":{t=MB(s);break}case"LineString":{t=RB(s);break}case"Polygon":{t=DB(s);break}case"MultiPoint":{t=FB(s);break}case"MultiLineString":{t=kB(s);break}case"MultiPolygon":{t=LB(s);break}case"GeometryCollection":{t=CB(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return t}function TB(s,e){let t=$0(s,e);return gg(t,e)}function CB(s,e){return s.geometries.map(function(a){return $0(a,e)})}function MB(s){let e=s.coordinates;return{type:"Point",flatCoordinates:e,layout:Na(e.length)}}function RB(s){let e=s.coordinates,t=e.flat();return{type:"LineString",flatCoordinates:t,ends:[t.length],layout:Na(e[0]?.length||2)}}function kB(s){let e=s.coordinates,t=e[0]?.[0]?.length||2,a=[],l=Ua(a,0,e,t);return{type:"MultiLineString",flatCoordinates:a,ends:l,layout:Na(t)}}function FB(s){let e=s.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:Na(e[0]?.length||2)}}function LB(s){let e=s.coordinates,t=[],a=e[0]?.[0]?.[0].length||2,l=Um(t,0,e,a);return{type:"MultiPolygon",flatCoordinates:t,ends:l,layout:Na(a)}}function DB(s){let e=s.coordinates,t=[],a=e[0]?.[0]?.length,l=Ua(t,0,e,a);return{type:"Polygon",flatCoordinates:t,ends:l,layout:Na(a)}}function q0(s,e){s=mg(s,!0,e);let t=s.getType(),a;switch(t){case"Point":{a=UB(s,e);break}case"LineString":{a=zB(s,e);break}case"Polygon":{a=GB(s,e);break}case"MultiPoint":{a=jB(s,e);break}case"MultiLineString":{a=BB(s,e);break}case"MultiPolygon":{a=NB(s,e);break}case"GeometryCollection":{a=OB(s,e);break}case"Circle":{a={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+t)}return a}function OB(s,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(a){return q0(a,e)})}}function zB(s,e){return{type:"LineString",coordinates:s.getCoordinates()}}function BB(s,e){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function jB(s,e){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function NB(s,e){let t;return e&&(t=e.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(t)}}function UB(s,e){return{type:"Point",coordinates:s.getCoordinates()}}function GB(s,e){let t;return e&&(t=e.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(t)}}var Ti=V0;var VB=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,d2=/^([\d.]+),([\d.]+)$/,f2=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,_g="stop-fetch",m2=s=>{let e=[];return s.forEach(t=>{let a=t.getGeometry()?.getCoordinates();a?.length&&e.push(...a)}),e},W0=class s extends Tu{constructor(t={}){super(t);this.viaPoints=[];this.graphs=[];this.useRawViaPoints=!1;this.snapToClosestStation=!1;this.cacheStationData={};this.abortControllers={};this.segments=[];this.format=new Ti({featureProjection:"EPSG:3857"});this.initialRouteDrag={};this.element||this.createDefaultElement(),this.loading=!1,this.active=t.active||!0,this.graphs=t.graphs||[["osm",0,99]],this.mot=t.mot||"bus",this.modify=t.modify!==!1,this.routingApiParams=t.routingApiParams,this.useRawViaPoints=t.useRawViaPoints||!1,this.snapToClosestStation=t.snapToClosestStation||!1,this.apiKey=t.apiKey,this.stopsApiKey=t.stopsApiKey||this.apiKey,this.stopsApiUrl=t.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new Xp({...t}),this.routingLayer=t.routingLayer||new Xl({source:new Yl,style:t.style}),this.onRouteError=t.onRouteError||(a=>{this.dispatchEvent(new Or("change:route")),this.reset(),console.error(a)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",a=>{a.key==="active"&&this.onActiveChange(),a.key==="mot"&&this.viaPoints&&this.drawRoute()})}get active(){return this.get("active")}set active(t){this.set("active",t)}get loading(){return this.get("loading")}set loading(t){this.set("loading",t)}get modify(){return this.get("modify")}set modify(t){this.set("modify",t)}get mot(){return this.get("mot")}set mot(t){this.set("mot",t)}static getGraphsResolutions(t,a){let l=a.getView();return t.map(([,o,m])=>[l.getResolutionForZoom(o),l.getResolutionForZoom(m||o+1)])}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}addViaPoint(t,a=-1,l=0){this.viaPoints.splice(a===-1?this.viaPoints.length:a,l,t),this.drawRoute(),this.dispatchEvent(new Or("change:route"))}removeViaPoint(t=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[t]&&this.viaPoints.splice(t,1),this.drawRoute(),this.dispatchEvent(new Or("change:route"))}setViaPoints(t){this.viaPoints=[...t],this.drawRoute(),this.dispatchEvent(new Or("change:route"))}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new Or("change:route"))}abortRequests(){this.graphs.forEach(t=>{let a=t[0];this.abortControllers[a]&&this.abortControllers[a].abort(),this.abortControllers[a]=new AbortController}),this.abortControllers[_g]?.abort(),this.abortControllers[_g]=new AbortController,this.loading=!1}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[_g]);let t=this.viaPoints.map(a=>{if(Array.isArray(a)){let l=this.getMap()?.getView().getProjection(),[o,m]=Bl(a,l);return this.snapToClosestStation?[`@${m}`,o]:[m,o]}return this.useRawViaPoints?a:`!${a}`});return this.loading=!0,this.viaPoints.forEach((a,l)=>this.drawViaPoint(a,l,this.abortControllers[_g])),Promise.all(this.graphs.map(([a],l)=>{let{signal:o}=this.abortControllers[a];return this.api?this.api.route({graph:a,via:`${t.join("|")}`,mot:this.mot,"resolve-hops":!1,elevation:!1,"coord-radius":100,"coord-punish":1e3,...this.routingApiParams||{}},{signal:o}).then(m=>{if(this.segments=this.format.readFeatures(m),this.mot==="foot"){let A=this.segments.reduce((S,M)=>{let R=M.get("trg");return S.find(j=>j[0]===R[0]&&j[1]===R[1])?S:[...S,R]},[]);this.segments=A.map(S=>{let M=this.segments.filter(j=>{let W=j.get("trg");return W[0]===S[0]&&W[1]===S[1]}),R=m2(M);return new bo({geometry:new No(R)})})}let g=m2(this.segments),b=new bo({geometry:new No(g)});b.set("graph",a),b.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[l]?.length>=2&&(b.set("minResolution",this.graphsResolutions[l][0]),b.set("maxResolution",this.graphsResolutions[l][1])),this.routingLayer?.getSource()?.addFeature(b),this.loading=!1}).catch(m=>{/AbortError/.test(m.message)||(this.segments=[],this.dispatchEvent(new Or("error")),this.onRouteError(m,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(t,a,l){let o=new bo;if(o.set("viaPointIdx",a),Array.isArray(t))return o.setGeometry(new Pi(t)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o);if(!this.useRawViaPoints||f2.test(t)){let S,M;return this.useRawViaPoints?[,S,,M]=f2.exec(t)||[]:[S,M]=t.split("$"),fetch(`${this.stopsApiUrl}lookup/${S}?key=${this.stopsApiKey}`,{signal:l.signal}).then(R=>R.json()).then(R=>{let{coordinates:j}=R.features[0].geometry;return this.cacheStationData[t]=Ii(j),o.set("viaPointTrack",M),o.setGeometry(new Pi(Ii(j))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(R=>{/AbortError/.test(R.message)||(this.dispatchEvent(new Or("error")),this.onRouteError(R,this),this.loading=!1)})}if(this.useRawViaPoints&&d2.test(t)){let[S,M]=d2.exec(t)||[];if(M&&S){let R=parseFloat(M),j=parseFloat(S),W=Ii([R,j],this.getMap()?.getView().getProjection());return o.setGeometry(new Pi(W)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}}let[,m,,g,b,,A]=VB.exec(t)||[];if(b&&g){let S=Ii([parseFloat(b),parseFloat(g)],this.getMap()?.getView().getProjection());return o.set("viaPointTrack",A),o.setGeometry(new Pi(S)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}return m?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${m}&limit=1`,{signal:l.signal}).then(S=>S.json()).then(S=>{let{coordinates:M}=S.features[0].geometry;return this.cacheStationData[t]=Ii(M),o.set("viaPointTrack",A),o.setGeometry(new Pi(Ii(M))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(S=>(this.dispatchEvent(new Or("error")),this.onRouteError(S,this),this.loading=!1,null)):Promise.resolve(null)}onMapClick(t){let l=t.target.getFeaturesAtPixel(t.pixel,{layerFilter:o=>o===this.routingLayer,hitTolerance:5}).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("viaPointIdx")!==void 0);if(l){this.removeViaPoint(l.get("viaPointIdx"));return}this.addViaPoint(t.coordinate)}onModifyStart(t){let a=-1,l=t.features.getArray().find(m=>m.getGeometry()?.getType()==="LineString");if(l&&l.getGeometry()&&t.mapBrowserEvent.coordinate){let m=Ln(new Pi(l.getGeometry()?.getClosestPoint(t.mapBrowserEvent.coordinate)).getExtent(),.001);a=this.segments.findIndex(g=>g.getGeometry()?.intersectsExtent(m))}let o=(t.features.getArray().filter(m=>m.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={viaPoint:o,oldRoute:l&&l.clone(),segmentIndex:a}}onModifyEnd(t){let a=t.mapBrowserEvent.coordinate,{oldRoute:l,viaPoint:o,segmentIndex:m}=this.initialRouteDrag||{};return o?this.addViaPoint(a,o.get("viaPointIdx"),1):l?m===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(a,(m||0)+1):this.addViaPoint(a,0,1)}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 j0({source:this.routingLayer?.getSource()||void 0,pixelTolerance:6,deleteCondition:t=>{let l=(t.target?.getFeaturesAtPixel(t.pixel,{hitTolerance:5})).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("index"));return n2(t)&&l?(this.removeViaPoint(l.get("index")),!0):!1}}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}removeListeners(){this.onMapClickKey&&Ol(this.onMapClickKey)}setMap(t){super.setMap(t),t&&this.active?this.activate():t||(this.active=!1)}activate(){let t=this.getMap();t&&(this.format=new Ti({featureProjection:t.getView().getProjection()}),this.graphsResolutions=s.getGraphsResolutions(this.graphs,t),this.modifyInteraction&&t.removeInteraction(this.modifyInteraction),this.modifyInteraction&&t.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}deactivate(){let t=this.getMap();t&&(this.modifyInteraction&&t.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}render(){}},g2=W0;var Z0=class{constructor(e){let{apiParams:t,apiKey:a,url:l,placeholder:o}=e||{};this.apiParams={limit:20,...t||{}},this.placeholder=o||"Search for a stop...";let m={apiKey:a};l&&(m.url=l),this.api=new Yp(m),this.abortController=new AbortController,this.createElement(e),this.options=e}render(e){let t=e?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=t.length?"block":"none",this.suggestionsElt.innerHTML="",t.forEach(a=>{let l=document.createElement("div");l.innerHTML=a?.properties?.name,l.onclick=o=>{this.options?.onSuggestionClick?.(a,o)},Object.assign(l.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(l)}))}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=t=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(t.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",overflowY:"auto",cursor:"pointer"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{display:"none",position:"absolute",right:"0",padding:"0 10px",fontSize:"200%",cursor:"pointer"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}search(e,t){return(e!==void 0||e!==null)&&(this.apiParams.q=e),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,t&&{signal:t.signal}).then(a=>{this.render(a)}).catch(()=>{this.render()})}},y2=Z0;var qB=()=>{let s=document.createElement("div");return Object.assign(s.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),s},_2=qB;var H0=class extends Tu{constructor(e){let t=_2();t.className=e?.className||"mbt-stop-finder";let a={element:t,...e||{}};super(a),this.controller=new y2({onSuggestionClick:this.onSuggestionClick.bind(this),...a})}onSuggestionClick(e){let t=Ii(e.geometry.coordinates);this.getMap()?.getView().setCenter(t)}search(e,t){return this.controller.search(e,t)}},v2=H0;var T2=Lo(Gd());var A2=Lo(Q0(),1);var l3="vectorTileFeature",eb={"EPSG:3857":new Ti({featureProjection:"EPSG:3857"})},zu=class extends Fu{getFeaturesAtCoordinate(e,t=5){let a=this.getMapLibrePixels(e,t);if(!a)return[];let l=this.getLayer().get("queryRenderedFeaturesOptions")||{};return this.getLayer().mapLibreMap?.queryRenderedFeatures(a,l).map(m=>this.toOlFeature(m))||[]}prepareFrame(){return!0}renderFrame(e){let t=this.getLayer(),{mapLibreMap:a}=t,l=t.getMapInternal();if(!t||!l||!a)return null;let o=a.getCanvas(),{viewState:m}=e;a.jumpTo({center:Bl(m.center),zoom:m.zoom-1,bearing:tE(-m.rotation)});let g=t.getOpacity().toString();return o&&g!==o.style.opacity&&(o.style.opacity=g),o.isConnected?c3(o,e)||a.resize():l.render(),a.redraw(),a.getContainer()}getFeatures(e){let t=this.getLayer().getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(t))}forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{let g=m.getGeometry();g instanceof Ui&&l(m,this.layer_,g)}),o?.[0]}getMapLibrePixels(e,t){if(!e)return;let a=this.getLayer().mapLibreMap?.project(Bl(e));if(a?.x===void 0||a?.y===void 0)return;let l=[a.x,a.y];if(t){let[o,m]=l;l=[[o-t,m-t],[o+t,m+t]]}return l}toOlFeature(e){let l=this.getLayer().getMapInternal()?.getView()?.getProjection()?.getCode()||"EPSG:3857";eb[l]||(eb[l]=new Ti({featureProjection:l}));let o=eb[l].readFeature(e);return o&&o.set(l3,e,!0),o}};function c3(s,e){return s.width===Math.floor(e.size[0]*e.pixelRatio)&&s.height===Math.floor(e.size[1]*e.pixelRatio)}var u3=s=>{if(!s)return[];let{style:e}=s;if(!e)return[];let{sourceCaches:t}=e,a=[];return Object.values(t).forEach(l=>{if(l.used){let{attribution:o}=l.getSource();o&&(a=a.concat(o.replace(/©/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),h3(a)},h3=s=>{let e=s.filter(l=>l!=null&&l.trim&&l.trim()),t=e.map(l=>l.toLowerCase());return[...new Set(t)].map(l=>e.find(o=>o.toLowerCase()===l))},tb=u3;var Bu=class extends Vo{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(e){super({source:new ua({attributions:()=>tb(this.mapLibreMap)}),...e})}disposeInternal(){Ol(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 t=document.createElement("div");t.style.position="absolute",t.style.width="100%",t.style.height="100%";let a=this.get("mapLibreOptions");this.mapLibreMap=new A2.Map(Object.assign({},a,{container:t,attributionControl:!1,interactive:!1,trackResize:!1})),this.mapLibreMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mapLibreMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new Or("load"))})}createRenderer(){return new zu(this)}};var E2=Lo(Gd());var $i=(0,E2.default)(s=>{console.warn(s)},1e3);function p3(s){return class extends s{constructor(...a){let l=a[0];super(l);this.options={};this.olEventsKeys=[];l.properties&&($i("Deprecated. Don't use properties options. Pass the values directly in options object."),this.setProperties(l.properties)),this.olEventsKeys?.push(this.on("propertychange",o=>{o.key==="children"&&this.onChildrenChange(o.oldValue)})),this.options=l,this.set("children",l.children||[])}get children(){return $i("Layer.children is deprecated. Use the Layer.get('children') method instead."),this.get("children")||[]}set children(a){$i("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),this.set("children",a||[])}get copyrights(){return $i("Layer.copyrights is deprecated. Get the attributions from the source object"),this.get("copyrights")}set copyrights(a){$i("Layer.copyrights is deprecated. Set the attributions to the source object.");let l=a&&!Array.isArray(a)?[a]:a;this.set("copyrights",l||[])}get disabled(){return $i("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),this.get("disabled")}set disabled(a){$i("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),this.set("disabled",a)}get group(){return $i("Layer.group is deprecated. Use the Layer.get('group') method instead."),this.get("group")}get hitTolerance(){return $i("Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."),this.get("hitTolerance")||5}get key(){return this.get("key")||this.get("name")||Nt(this)}get map(){return this.getMapInternal()}get name(){return $i("Layer.name is deprecated. Use the Layer.get('name') method instead."),this.get("name")}get olLayer(){return $i("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(a){$i("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.")}get parent(){return $i("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),this.get("parent")}set parent(a){$i("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),this.set("parent",a)}get visible(){return $i("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),this.getVisible()}set visible(a){$i("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),this.setVisible(a)}setMapInternal(a){super.setMapInternal(a),a?this.attachToMap(a):this.detachFromMap()}onChildrenChange(a){(a||[]).forEach(l=>{l.set("parent",void 0)}),(this.get("children")||[]).forEach(l=>{l.set("parent",this)})}attachToMap(a){(super.attachToMap||(()=>{}))(a),(this.get("children")||[]).forEach(l=>{a.addLayer(l)})}detachFromMap(){(this.get("children")||[]).forEach(a=>{this.map.removeLayer(a)}),(super.detachFromMap||(()=>{}))()}flat(){return $i("Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead."),Dl(this)}}}var I2=p3;function d3(s){return class extends I2(s){}}var bs=d3;var P2=(s,e,t,a)=>Fl(`${s}/styles/${e}/style.json`,{[a]:t}).toString(),rb=class s extends bs(Bu){get mbMap(){return console.warn("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get maplibreMap(){return console.warn("MaplibreLayer.maplibreMap 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)}constructor(e){let t={apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...e||{},mapLibreOptions:{...e.mapLibreOptions||{}}};!t.mapLibreOptions.style&&t.apiKey&&(t.mapLibreOptions.style=P2(t.url,t.style,t.apiKey,t.apiKeyName)),super(t)}attachToMap(e){super.attachToMap(e),this.updateMaplibreMap();let t=(0,T2.default)(this.updateMaplibreMap.bind(this),150);this.olEventsKeys.push(this.on("propertychange",a=>{/(url|style)/.test(a.key)&&t()}))}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:P2(this.url,this.style,this.get("apiKey"),this.get("apiKeyName"))}updateMaplibreMap(){this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}clone(e){return new s({...this.options||{},...e||{}})}},C2=rb;var ib={"EPSG:3857":new Ti({featureProjection:"EPSG:3857"})},Vd=class extends Fu{getFeaturesAtCoordinate(e,t=5){if(!e)return[];let a=this.getLayer(),l=a.getMapInternal(),{maplibreMap:o}=a.maplibreLayer,m=l?.getView()?.getProjection()?.getCode()||"EPSG:3857",g=[];if(ib[m]||(ib[m]=new Ti({featureProjection:m})),o?.isStyleLoaded()){let b=e&&o.project(Bl(e));if(b?.x&&b?.y){let A=[b.x,b.y];if(t){let[M,R]=A;A=[[M-t,R-t],[M+t,R+t]]}let S=a.layers||[];a.layersFilter&&(S=o.getStyle().layers.filter(a.layersFilter)),a.queryRenderedLayersFilter&&(S=o.getStyle().layers.filter(a.queryRenderedLayersFilter)),g=o.queryRenderedFeatures(A,{layers:S.map(M=>M.id),validate:!1}).map(M=>{let R=ib[m].readFeature(M);return R&&R.set(Iu,M),R})}}return g}prepareFrame(){return!0}renderFrame(){return null}getFeatures(e){let t=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(t))}forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{l(m,this.layer_,m.getGeometry())}),o?.[0]}};var nb=class s extends bs(Vo){constructor(t={mapLibreOptions:{style:{version:8,sources:{},layers:[]}}}){t.mapboxLayer&&(console.warn("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),t.maplibreLayer=t.mapboxLayer,delete t.mapboxLayer);super({source:new ua({}),...t});this.highlightedFeatures=[];this.selectedFeatures=[];this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=a=>!!this.layers.find(l=>a.id===l.id))}get beforeId(){return this.get("beforeId")}set beforeId(t){this.set("beforeId",t)}get layers(){return this.get("layers")}set layers(t){this.set("layers",t)}get layersFilter(){return this.get("layersFilter")}set layersFilter(t){this.set("layersFilter",t)}get mapboxLayer(){return console.warn("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(t){this.set("maplibreLayer",t)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(t){this.set("queryRenderedLayersFilter",t)}get sources(){return this.get("sources")}set sources(t){this.set("sources",t)}get styleLayer(){return console.warn("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(t){console.warn("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[t]}get styleLayers(){return console.warn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(t){console.warn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=t}createRenderer(){return new Vd(this)}attachToMap(t){if(this.maplibreLayer&&!this.maplibreLayer.map&&t.addLayer(this.maplibreLayer),super.attachToMap(t),!this.map||!this.maplibreLayer)return;if(!this.map.getTargetElement()){this.olEventsKeys.push(this.map.on("change:target",()=>{this.attachToMap(t)}));return}let{mapLibreMap:a}=this.maplibreLayer;a&&(a.loaded()?this.onLoad():a.once("load",this.onLoad)),this.olEventsKeys.push(this.maplibreLayer.on("load",this.onLoad.bind(this)),this.on("change:visible",l=>{this.applyLayoutVisibility(l)}),this.on("propertychange",l=>{/(sources|layers|layersFilter|maplibreLayer|beforeId)/.test(l.key)&&(this.detachFromMap(),this.attachToMap(t))}))}detachFromMap(){this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources()),super.detachFromMap()}addSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:t}=this.maplibreLayer;t&&Object.entries(this.sources).forEach(([a,l])=>{t.getSource(a)||t.addSource(a,l)})}removeSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:t}=this.maplibreLayer;t&&Object.keys(this.sources).forEach(a=>{t.getSource(a)&&t.removeSource(a)})}addLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:t}=this.maplibreLayer;t&&(this.layers.forEach(a=>{let{id:l,source:o}=a;(!o||o&&t.getSource(o))&&l&&!t.getLayer(l)&&t.addLayer(a,this.beforeId)}),this.applyLayoutVisibility())}removeLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:t}=this.maplibreLayer;t&&this.layers.forEach(a=>{let{id:l}=a;l&&t.getLayer(l)&&t.removeLayer(l)})}onLoad(){if(!this.maplibreLayer?.mapLibreMap)return;this.addSources(),this.addLayers();let{mapLibreMap:t}=this.maplibreLayer,a=t.getStyle();if(a?.layers&&this.layersFilter){let l=a.layers.filter(this.layersFilter);this.set("disabled",!l.length)}this.applyLayoutVisibility()}setFeatureState(t,a){if(!this.maplibreLayer?.mapLibreMap||!t.length)return;let{mapLibreMap:l}=this.maplibreLayer;t.forEach(o=>{let{source:m,sourceLayer:g}=o.get(Iu)||{};if(!m&&!g||!o.getId()){o.getId()||console.warn("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.getId(),o.getProperties());return}l.setFeatureState({id:o.getId(),source:m,sourceLayer:g},a)})}getFeatureInfoAtCoordinate(t){if(console.warn("Deprecated. getFeatureInfoAtCoordinate([layer], coordinate) from ol package instead."),!this.maplibreLayer?.mapLibreMap)return Promise.resolve({coordinate:t,features:[],layer:this});let{mapLibreMap:a}=this.maplibreLayer;if(!a.isStyleLoaded())return Promise.resolve({coordinate:t,features:[],layer:this});let l=this.layers||[];return this.layersFilter&&(l=a.getStyle().layers.filter(this.layersFilter)),this.queryRenderedLayersFilter&&(l=a.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({features:[],layer:this,coordinate:t})}setHoverState(t,a){console.warn(`Deprecated. Use layer.setFeatureState(features, {hover: ${a}}) instead.`),this.setFeatureState(t,{hover:a})}select(t=[]){console.warn("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=t,this.setHoverState(this.selectedFeatures||[],!0)}highlight(t=[]){console.warn("Deprecated. Use layer.setFeatureState(features, {highlighted: true}) instead.");let a=this.highlightedFeatures?.filter(l=>!(this.selectedFeatures||[]).map(o=>o.getId()).includes(l.getId()))||[];this.setHoverState(a,!1),this.highlightedFeatures=t,this.setHoverState(this.highlightedFeatures,!0)}applyLayoutVisibility(t){if(!this.maplibreLayer?.mapLibreMap?.getStyle()||!this.layersFilter)return;let{mapLibreMap:a}=this.maplibreLayer,l=a.getStyle(),o=this.getVisible()?"visible":"none",m=l.layers||[];for(let g=0;g<m.length;g+=1){let b=m[g];if(this.layersFilter(b)){let{id:A}=b;a.getLayer(A)&&(a.setLayoutProperty(A,"visibility",o),(this.getMinZoom()||this.getMaxZoom())&&a.setLayerZoomRange(A,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}clone(t){return new s({...this.options,...t})}},M2=nb;var lb=Lo(Gd());var sb=Lo(Gd()),ab=Lo(D2());function R3(s){return class extends s{constructor(t){super({hitTolerance:10,...t}),this.defineProperties(t),this.debug=t.debug||!1,this.mode=t.mode||ri.TOPOGRAPHIC,this.api=t.api||new Jp(t),this.tenant=t.tenant||"",this.minZoomInterpolation=t.minZoomInterpolation||8,this.format=new Ti,this.onStart=t.onStart,this.onStop=t.onStop,this.motsByZoom=t.motsByZoom||[Go,Go,Go,Go,Go,Go,Go,Go,Go,Xm,Xm],this.getMotsByZoom=a=>t.getMotsByZoom?t.getMotsByZoom(a,this.motsByZoom):this.motsByZoom[a],this.generalizationLevelByZoom=t.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=a=>t.getGeneralizationLevelByZoom?t.getGeneralizationLevelByZoom(a,this.generalizationLevelByZoom):this.generalizationLevelByZoom[a],this.renderTimeIntervalByZoom=t.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=a=>t.getRenderTimeIntervalByZoom?t.getRenderTimeIntervalByZoom(a,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[a],this.isUpdateBboxOnMoveEnd=t.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,ab.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,sb.default)(this.renderTrajectoriesInternal,50,{leading:!0,trailing:!0,maxWait:5e3}),this.renderTrajectoriesInternal=this.renderTrajectoriesInternal.bind(this),this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}defineProperties(t){(super.defineProperties||(()=>{}))(t);let{style:a,speed:l,pixelRatio:o,hoverVehicleId:m,selectedVehicleId:g,filter:b,sort:A,time:S,live:M,canvas:R,styleOptions:j,mode:W,bboxParameters:re}=t,$=R,X=l||1,se=S||new Date,me=W||ri.TOPOGRAPHIC,_e=a||ql;Object.defineProperties(this,{isTrackerLayer:{value:!0},canvas:{get:()=>($||($=document.createElement("canvas")),$),set:pe=>{$=pe}},mode:{get:()=>me,set:pe=>{pe!==me&&(me=pe,this.api?.wsApi?.open&&(this.stop(),this.start()))}},style:{get:()=>_e,set:pe=>{_e=pe,this.renderTrajectories()}},styleOptions:{value:{...Eu,...j||{}}},speed:{get:()=>X,set:pe=>{X=pe,this.start()}},bboxParameters:{value:re,writable:!0},filter:{value:b,writable:!0},sort:{value:A,writable:!0},live:{value:M===!1?M:!0,writable:!0},time:{get:()=>se,set:pe=>{se=pe&&pe.getTime?pe:new Date(pe),this.renderTrajectories()}},trajectories:{value:{},writable:!0},hoverVehicleId:{value:m,writable:!0},selectedVehicleId:{value:g,writable:!0},pixelRatio:{value:o||(typeof window<"u"?window.devicePixelRatio:1),writable:!0},useRequestAnimationFrame:{value:t.useRequestAnimationFrame||!1,writable:!0},useThrottle:{value:t.useThrottle!==!1,writable:!0},useDebounce:{value:t.useDebounce||!1,writable:!0}})}attachToMap(t){super.attachToMap(t),document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),Ol(this.visibilityRef),this.canvas){let t=this.canvas.getContext("2d");t&&t.clearRect(0,0,this.canvas.width,this.canvas.height),super.detachFromMap()}}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)}renderTrajectoriesInternal(t,a=!1){if(!this.map||!this.trajectories)return!1;let l=this.live?Date.now():this.time?.getTime(),o=Object.values(this.trajectories);return this.sort&&o.sort(this.sort),!this.canvas||!this.style||(this.renderState=xd(this.canvas,o,this.style,{...t,pixelRatio:this.pixelRatio||1,time:l},{filter:this.filter,noInterpolate:(t.zoom||0)<this.minZoomInterpolation?!0:a,hoverVehicleId:this.hoverVehicleId,selectedVehicleId:this.selectedVehicleId,...this.styleOptions})),!0}renderTrajectories(t,a){this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),t&&(!a&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(t,a)}):!a&&this.useDebounce?this.debounceRenderTrajectories(t,a):!a&&this.useThrottle?this.throttleRenderTrajectories(t,a):this.renderTrajectoriesInternal(t,a))}setBbox(t,a){if(this.trajectories&&t&&a){let S=Object.keys(this.trajectories);for(let M=S.length-1;M>=0;M-=1)this.purgeTrajectory(this.trajectories[S[M]],t,a)}let l=Math.floor(a);if(!t||Number.isNaN(l))return;let[o,m,g,b]=t,A=[Math.floor(o),Math.floor(m),Math.ceil(g),Math.ceil(b),l];this.generalizationLevel=this.getGeneralizationLevelByZoom(l),this.generalizationLevel&&A.push(`gen=${this.generalizationLevel}`),this.mots=this.getMotsByZoom(l),this.mots&&A.push(`mots=${this.mots}`),this.tenant&&A.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&A.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([S,M])=>{A.push(`${S}=${M}`)}),this.api.bbox=A}getRefreshTimeInMs(t=0){let a=t!==void 0?Math.round(t):-1,l=this.getRenderTimeIntervalByZoom(a)||25,o=Math.max(25,l/(this.speed||1)),m=Math.min(o,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,ab.default)(this.renderTrajectoriesInternal,m,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,sb.default)(this.renderTrajectoriesInternal,m,{leading:!0,trailing:!0,maxWait:5e3})),this.api?.buffer){let[,g]=this.api.buffer;this.api.buffer=[m,g]}return o}getVehicle(t){return this.trajectories&&Object.values(this.trajectories).filter(t)||[]}getFeatureInfoAtCoordinate(t,a){let{resolution:l,nb:o}=a,m=Ln([...t,...t],this.hitTolerance*l),g=Object.values(this.trajectories||{});this.sort&&(g=g.sort(this.sort));let b=[];for(let A=0;A<g.length;A+=1){let{coordinate:S}=g[A].properties;if(S&&Ys(m,S)&&b.push(g[A]),b.length===o)break}return Promise.resolve({layer:this,features:b.map(A=>this.format.readFeature(A)),coordinate:t})}getTrajectoryInfos(t){let a=[this.api.getStopSequence(t),this.api.getFullTrajectory(t,this.mode,this.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0)))];return Promise.all(a).then(([l,o])=>({stopSequence:l,fullTrajectory:o}))}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([t,a])=>{let l=a?.properties?.time_intervals;this.time&&l?.length&&l[l.length-1][0]<this.time.getTime()&&this.removeTrajectory(t)})}purgeTrajectory(t,a,l){let{type:o,bounds:m}=t.properties;return this.isUpdateBboxOnMoveEnd&&!ni(a,m)||this.mots&&!this.mots.includes(o)?(this.removeTrajectory(t),!0):!1}addTrajectory(t){this.trajectories||(this.trajectories={});let a=t.properties.train_id;a!==void 0&&(this.trajectories[a]=t),this.renderTrajectories()}removeTrajectory(t){let a;typeof t!="string"?a=t?.properties?.train_id:a=t,a!==void 0&&this.trajectories&&delete this.trajectories[a]}onZoomEnd(){this.startUpdateTime()}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(this.visible===!1)return;this.start()}}onTrajectoryMessage(t){if(!t.content)return;let a=t.content,{geometry:l,properties:{train_id:o,time_since_update:m,raw_coordinates:g}}=a;m<0||this.purgeTrajectory(a)||(this.debug&&this.mode===ri.TOPOGRAPHIC&&g?a.properties.olGeometry=this.format.readGeometry({type:"Point",coordinates:Ii(g,this.map.getView().getProjection())}):a.properties.olGeometry=this.format.readGeometry(l),a.properties.timeOffset=Date.now()-t.timestamp,this.addTrajectory(a))}onDeleteTrajectoryMessage(t){t.content&&this.removeTrajectory(t.content)}highlightVehicle(t){this.hoverVehicleId!==t&&(this.hoverVehicleId=t,this.renderTrajectories(!0))}selectVehicle(t){this.selectedVehicleId!==t&&(this.selectedVehicleId=t,this.renderTrajectories(!0))}}}var xg=R3;var k3=new Vi({zIndex:2,image:new Vn({radius:5,fill:new Gi({color:"#000000"})}),stroke:new pi({color:"#000000",width:6})}),F3=(s,e,t)=>{let a="#ffffff",l=s.get("type"),o=s.get("stroke");return o&&o[0]!=="#"&&(o=`#${o}`),a=o||t?.getBgColor(l),a=/#ffffff/i.test(a)?"#ff0000":a,[k3,new Vi({zIndex:3,image:new Vn({radius:4,fill:new Gi({color:a})}),stroke:new pi({color:a,width:4})})]},bg=F3;var L3=new Vi({zIndex:2,image:new Vn({radius:5,fill:new Gi({color:"#000000"})}),stroke:new pi({color:"#000000",width:6})}),D3=new Vi({zIndex:3,image:new Vn({radius:4,fill:new Gi({color:"#a0a0a0"})}),stroke:new pi({color:"#a0a0a0",width:4})}),O3=()=>[L3,D3],O2=O3;var z2=new Vn({radius:6,fill:new Gi({color:[255,0,0,1]}),stroke:new pi({color:[0,0,0,1],width:1})}),z3=new Vi({stroke:new pi({color:[0,0,0,1],width:5})}),B3=new Vi({image:z2,stroke:new pi({color:[255,0,0,1],width:3})}),j3=new Vi({image:z2,stroke:new pi({color:[255,0,0,1],width:3,lineDash:[1,10]})}),N3=(s,e)=>{let t=s.get("minResolution"),a=s.get("maxResolution"),l=e<=t&&e>a;return t&&a&&!l?[]:s.get("mot")!=="foot"?[z3,B3]:[j3]},B2=N3;var U3=new Ti,qd=class extends fg{prepareFrame(){return!0}renderFrame(e){let{canvas:t,renderedViewState:a}=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%",t instanceof HTMLCanvasElement&&(t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.transformOrigin="top left",this.container.appendChild(t))),a){let{center:l,resolution:o,rotation:m}=e.viewState,{center:g,resolution:b,rotation:A}=a;if(b/o>=3)t?.getContext("2d")?.clearRect(0,0,t?.width,t?.height);else{let S=this.getLayer().getMapInternal(),M=S?.getPixelFromCoordinate(g),R=S?.getPixelFromCoordinate(l);M&&R&&(this.container.style.transform=DA(M[0]-R[0],M[1]-R[1],b/o,b/o,m-A,0,0))}}return this.container}getData(e){let t;try{let{pixelRatio:a}=this.getLayer();return t=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(e[0]*(a||1),e[1]*(a||1),1,1).data||null,t}catch(a){console.error("error getting data",a)}return null}getFeatures(e){let t=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(t))}forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{l(m,this.layer_,m.getGeometry())}),o?.[0]}getFeaturesAtCoordinate(e,t=5){if(!e)return[];let a=this.getLayer(),o=a.getMapInternal()?.getView()?.getResolution()||1,m=10,g=Ln([...e,...e],t*o),b=[],A=Object.values(a.trajectories||{});a.sort&&(A=A.sort(this.sort));let S=[];for(let M=0;M<A.length;M+=1){let R=A[M];if(R.properties.coordinate&&Ys(g,R.properties.coordinate)&&S.push(A[M]),S.length===m)break}return b=S.map(M=>U3.readFeature(M)),b}};var G3=new Ti,cb=class s extends xg(bs(Vo)){constructor(t){super({source:new ua({}),...t});this.allowRenderWhenAnimating=!1;this.allowRenderWhenAnimating=!!t.allowRenderWhenAnimating,this.vectorLayer=new Xl({updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0,source:new Yl({features:[]}),style:(a,l)=>(t.fullTrajectoryStyle||bg)(a,l,this.styleOptions)}),this.renderState={center:[0,0],zoom:void 0,rotation:0},this.onZoomEndDebounced=(0,lb.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,lb.default)(this.onMoveEnd,100)}createRenderer(){return new qd(this)}attachToMap(t){if(super.attachToMap(t),this.map){this.visible&&this.start();let a=this.map.getLayers().getArray().indexOf(this);this.map.getLayers().insertAt(a,this.vectorLayer),this.olEventsKeys.push(...this.map.on(["moveend","change:target"],l=>{let o=(l.map||l.target).getView();if(o.getAnimating()||o.getInteracting())return;let m=o.getZoom();this.currentZoom!==m&&this.onZoomEndDebounced(l),this.currentZoom=m,this.onMoveEndDebounced(l)}),this.on("change:visible",l=>{l.target.visible?this.start():this.stop()}),this.on("propertychange",l=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(l.key)&&this.vectorLayer.set(l.key,l.target.get(l.key))}))}}detachFromMap(){this.map?.removeLayer(this.vectorLayer),super.detachFromMap()}renderTrajectories(t){if(!this.map)return;let a=this.map.getView();a.getCenter()&&super.renderTrajectories({size:this.map.getSize(),center:a.getCenter(),extent:a.calculateExtent(),resolution:a.getResolution(),rotation:a.getRotation(),zoom:a.getZoom(),pixelRatio:this.pixelRatio},t)}renderTrajectoriesInternal(t,a){if(!this.map)return!1;let l=!1;if(l=(this.allowRenderWhenAnimating?!1:this.map.getView().getAnimating()||this.map.getView().getInteracting())?!1:super.renderTrajectoriesInternal(t,a),l){this.renderedViewState={...t};let{container:m}=this.getRenderer();m&&(m.style.transform="")}return l}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getView().getZoom())}onMoveEnd(t){!this.isUpdateBboxOnMoveEnd||!this.visible||this.setBbox()}onZoomEnd(){super.onZoomEnd(),!(!this.isUpdateBboxOnMoveEnd||!this.visible)&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}highlight(t){this.highlightVehicle(t?.get("train_id"))}select(t){this.selectVehicle(t?.get("train_id")),this.highlightTrajectory(t?.get("train_id"))}purgeTrajectory(t,a,l){let o=this.map.getView().getCenter();return!a&&!o?!1:super.purgeTrajectory(t,a||this.map.getView().calculateExtent(),l||this.map.getView().getZoom()||0)}setBbox(t,a){super.setBbox(t||this.map.getView().calculateExtent(),a||this.map.getView().getZoom()||0)}highlightTrajectory(t){return t?this.api.getFullTrajectory(t,this.mode,this.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0))).then(a=>{let l=a.content;if(!l?.features?.length)return[];let o=G3.readFeatures(l);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([]))}clone(t){return new s({...this.options,...t})}},j2=cb;var ub=class s extends bs(Vo){constructor(e){super(e),console.warn("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(e){return new s({...this.options||{},...e||{}})}},wg=ub;var hb=class s extends wg{getFeatureInfoAtCoordinate(e){let t=[];if(this.map){let a=this.map.getPixelFromCoordinate(e);t=this.map.getFeaturesAtPixel(a,{layerFilter:l=>l===this.olLayer,hitTolerance:this.hitTolerance||5})}return Promise.resolve({features:t,layer:this,coordinate:e})}clone(e){return new s({...this.options,...e})}},N2=hb;var V3=new Ti,q3=(s,e,t)=>{let a,{coordinate:l,resolution:o,projection:m,params:g}=e;return s&&o&&m&&(a=s.getFeatureInfoUrl(l,o,m,{info_format:"application/json",query_layers:s.getParams().layers,...g})),fetch(a,{signal:t.signal}).then(b=>b.json()).then(b=>V3.readFeatures(b)).catch(()=>[])},$d={},$3=async(s,e,t=5)=>{Object.values($d).forEach(o=>{o?.abort()}),$d={};let l=Dl(e).map(o=>{let m=o.getMapInternal(),g=m?.getView()?.getProjection()?.getCode(),b={features:[],layer:o,coordinate:s};if(!g)return Promise.resolve(b);if(o.getFeatureInfoAtCoordinate)return o.getFeatureInfoAtCoordinate(s);let A=o?.getSource();if(A?.getFeatureInfoUrl){let R=Nt(o);$d[R]?.abort(),$d[R]=new AbortController;let j=m?.getView()?.getResolution();return q3(A,{coordinate:s,resolution:j,projection:g,params:{info_format:"application/json",query_layers:A.getParams().layers}},$d[R]).then(W=>({features:W,layer:o,coordinate:s})).catch(()=>({features:[],layer:o,coordinate:s}))}let S=m?.getPixelFromCoordinate(s);if(!S)return Promise.resolve(b);let M=m?.getFeaturesAtPixel(S,{layerFilter:R=>R===o,hitTolerance:o.get("hitTolerance")||t||5});return Promise.resolve({features:M,layer:o,coordinate:s})});return Promise.all(l)},U2=$3;var Uy={};ev(Uy,{CopyrightControl:()=>G2,Layer:()=>Ig,RealtimeAPI:()=>Jp,RealtimeLayer:()=>_L,RealtimeModes:()=>ri,RoutingAPI:()=>Xp,StopsAPI:()=>Yp,VECTOR_TILE_FEATURE_PROPERTY:()=>Iu,compareDepartures:()=>bd,createCanvas:()=>Uo,createRealtimeFilters:()=>sv,debounceDeparturesMessages:()=>Yv,debounceWebsocketMessages:()=>Kp,getCircleCanvas:()=>nx,getDelayBgCanvas:()=>rx,getDelayTextCanvas:()=>ix,getHoursAndMinutes:()=>kA,getLayersAsFlatArray:()=>Dl,getMapGlCopyrights:()=>Qp,getMercatorResolution:()=>yL,getSourceCoordinates:()=>Ny,getTextCanvas:()=>ox,getUTCDateString:()=>MA,getUTCTimeString:()=>RA,getUrlWithParams:()=>Fl,getVehiclePosition:()=>vd,pad:()=>Em,realtimeConfig:()=>Eu,realtimeDefaultStyle:()=>ql,realtimeDelayStyle:()=>sx,realtimeSimpleStyle:()=>ax,removeDuplicate:()=>Ll,renderTrajectories:()=>xd,sortAndFilterDepartures:()=>wd,sortByDelay:()=>av});var W3=" | ",pb=class{constructor(e={}){this.options=e}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}getDefaultPosition(){return"bottom-right"}render(){if(this.map&&this.container){let e=this.options?.separator||W3,t=this.options?.customAttribution||Qp(this.map),a=(Array.isArray(t)?t:[t]).join(e);this.container.innerHTML!==a&&(this.content=a,this.container.innerHTML=this.content)}}},G2=pb;var Wi=[];for(Ag=0;Ag<256;++Ag)Wi.push((Ag+256).toString(16).slice(1));var Ag;function V2(s,e=0){return(Wi[s[e+0]]+Wi[s[e+1]]+Wi[s[e+2]]+Wi[s[e+3]]+"-"+Wi[s[e+4]]+Wi[s[e+5]]+"-"+Wi[s[e+6]]+Wi[s[e+7]]+"-"+Wi[s[e+8]]+Wi[s[e+9]]+"-"+Wi[s[e+10]]+Wi[s[e+11]]+Wi[s[e+12]]+Wi[s[e+13]]+Wi[s[e+14]]+Wi[s[e+15]]).toLowerCase()}var Eg,Z3=new Uint8Array(16);function db(){if(!Eg&&(Eg=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Eg))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Eg(Z3)}var H3=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),fb={randomUUID:H3};function X3(s,e,t){if(fb.randomUUID&&!e&&!s)return fb.randomUUID();s=s||{};var a=s.random||(s.rng||db)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,e){t=t||0;for(var l=0;l<16;++l)e[t+l]=a[l];return e}return V2(a)}var mb=X3;var q2=Lo(Q0()),gb=class extends q2.Evented{constructor(t={}){super();this.options={};this.type="custom";this.options=t,this.id=t.id||mb(),this.type="custom"}onAdd(t,a){this.map=t}onRemove(t,a){this.map=void 0}render(t){}},Ig=gb;var QF=Lo(KF(),1),zG=Object.defineProperty,dr=(s,e)=>zG(s,"name",{value:e,configurable:!0}),BG=class{constructor(e){this.direction=!1,this.compareProperties=!0;var t,a,l;this.precision=10**-((t=e?.precision)!=null?t:17),this.direction=(a=e?.direction)!=null?a:!1,this.compareProperties=(l=e?.compareProperties)!=null?l:!0}compare(e,t){if(e.type!==t.type||!ff(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates);case"Polygon":return this.comparePolygon(e,t);case"GeometryCollection":return this.compareGeometryCollection(e,t);case"Feature":return this.compareFeature(e,t);case"FeatureCollection":return this.compareFeatureCollection(e,t);default:if(e.type.startsWith("Multi")){let a=Iw(e),l=Iw(t);return a.every(o=>l.some(m=>this.compare(o,m)))}}return!1}compareCoord(e,t){return e.length===t.length&&e.every((a,l)=>Math.abs(a-t[l])<this.precision)}compareLine(e,t,a=0,l=!1){if(!ff(e,t))return!1;let o=e,m=t;if(l&&!this.compareCoord(o[0],m[0])){let b=this.fixStartIndex(m,o);if(b)m=b;else return!1}let g=this.compareCoord(o[a],m[a]);return this.direction||g?this.comparePath(o,m):this.compareCoord(o[a],m[m.length-(1+a)])?this.comparePath(o.slice().reverse(),m):!1}fixStartIndex(e,t){let a,l=-1;for(let o=0;o<e.length;o++)if(this.compareCoord(e[o],t[0])){l=o;break}return l>=0&&(a=[].concat(e.slice(l,e.length),e.slice(1,l+1))),a}comparePath(e,t){return e.every((a,l)=>this.compareCoord(a,t[l]))}comparePolygon(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){let a=e.coordinates.slice(1,e.coordinates.length),l=t.coordinates.slice(1,t.coordinates.length);return a.every(o=>l.some(m=>this.compareLine(o,m,1,!0)))}return!1}compareGeometryCollection(e,t){return ff(e.geometries,t.geometries)&&this.compareBBox(e,t)&&e.geometries.every((a,l)=>this.compare(a,t.geometries[l]))}compareFeature(e,t){return e.id===t.id&&(this.compareProperties?(0,QF.default)(e.properties,t.properties):!0)&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return ff(e.features,t.features)&&this.compareBBox(e,t)&&e.features.every((a,l)=>this.compare(a,t.features[l]))}compareBBox(e,t){return!e.bbox&&!t.bbox||(e.bbox&&t.bbox?this.compareCoord(e.bbox,t.bbox):!1)}};dr(BG,"GeojsonEquality");function ff(s,e){return s.coordinates?s.coordinates.length===e.coordinates.length:s.length===e.length}dr(ff,"sameLength");function Iw(s){return s.coordinates.map(e=>({type:s.type.replace("Multi",""),coordinates:e}))}dr(Iw,"explode");var Zi=63710088e-1,eL={centimeters:Zi*100,centimetres:Zi*100,degrees:360/(2*Math.PI),feet:Zi*3.28084,inches:Zi*39.37,kilometers:Zi/1e3,kilometres:Zi/1e3,meters:Zi,metres:Zi,miles:Zi/1609.344,millimeters:Zi*1e3,millimetres:Zi*1e3,nauticalmiles:Zi/1852,radians:1,yards:Zi*1.0936},JF={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:29155334959812285e-23,millimeters:1e6,millimetres:1e6,yards:1.195990046};function Ko(s,e,t={}){let a={type:"Feature"};return(t.id===0||t.id)&&(a.id=t.id),t.bbox&&(a.bbox=t.bbox),a.properties=e||{},a.geometry=s,a}dr(Ko,"feature");function jG(s,e,t={}){switch(s){case"Point":return Hi(e).geometry;case"LineString":return Fs(e).geometry;case"Polygon":return Pw(e).geometry;case"MultiPoint":return rL(e).geometry;case"MultiLineString":return tL(e).geometry;case"MultiPolygon":return iL(e).geometry;default:throw new Error(s+" is invalid")}}dr(jG,"geometry");function Hi(s,e,t={}){if(!s)throw new Error("coordinates is required");if(!Array.isArray(s))throw new Error("coordinates must be an Array");if(s.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!vc(s[0])||!vc(s[1]))throw new Error("coordinates must contain numbers");return Ko({type:"Point",coordinates:s},e,t)}dr(Hi,"point");function NG(s,e,t={}){return Oy(s.map(a=>Hi(a,e)),t)}dr(NG,"points");function Pw(s,e,t={}){for(let l of s){if(l.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(l[l.length-1].length!==l[0].length)throw new Error("First and last Position are not equivalent.");for(let o=0;o<l[l.length-1].length;o++)if(l[l.length-1][o]!==l[0][o])throw new Error("First and last Position are not equivalent.")}return Ko({type:"Polygon",coordinates:s},e,t)}dr(Pw,"polygon");function UG(s,e,t={}){return Oy(s.map(a=>Pw(a,e)),t)}dr(UG,"polygons");function Fs(s,e,t={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return Ko({type:"LineString",coordinates:s},e,t)}dr(Fs,"lineString");function GG(s,e,t={}){return Oy(s.map(a=>Fs(a,e)),t)}dr(GG,"lineStrings");function Oy(s,e={}){let t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=s,t}dr(Oy,"featureCollection");function tL(s,e,t={}){return Ko({type:"MultiLineString",coordinates:s},e,t)}dr(tL,"multiLineString");function rL(s,e,t={}){return Ko({type:"MultiPoint",coordinates:s},e,t)}dr(rL,"multiPoint");function iL(s,e,t={}){return Ko({type:"MultiPolygon",coordinates:s},e,t)}dr(iL,"multiPolygon");function VG(s,e,t={}){return Ko({type:"GeometryCollection",geometries:s},e,t)}dr(VG,"geometryCollection");function qG(s,e=0){if(e&&!(e>=0))throw new Error("precision must be a positive number");let t=Math.pow(10,e||0);return Math.round(s*t)/t}dr(qG,"round");function nL(s,e="kilometers"){let t=eL[e];if(!t)throw new Error(e+" units is invalid");return s*t}dr(nL,"radiansToLength");function Tw(s,e="kilometers"){let t=eL[e];if(!t)throw new Error(e+" units is invalid");return s/t}dr(Tw,"lengthToRadians");function $G(s,e){return zy(Tw(s,e))}dr($G,"lengthToDegrees");function WG(s){let e=s%360;return e<0&&(e+=360),e}dr(WG,"bearingToAzimuth");function zy(s){return s%(2*Math.PI)*180/Math.PI}dr(zy,"radiansToDegrees");function nl(s){return s%360*Math.PI/180}dr(nl,"degreesToRadians");function mf(s,e="kilometers",t="kilometers"){if(!(s>=0))throw new Error("length must be a positive number");return nL(Tw(s,e),t)}dr(mf,"convertLength");function ZG(s,e="meters",t="kilometers"){if(!(s>=0))throw new Error("area must be a positive number");let a=JF[e];if(!a)throw new Error("invalid original units");let l=JF[t];if(!l)throw new Error("invalid final units");return s/a*l}dr(ZG,"convertArea");function vc(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}dr(vc,"isNumber");function Bh(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}dr(Bh,"isObject");function HG(s){if(!s)throw new Error("bbox is required");if(!Array.isArray(s))throw new Error("bbox must be an Array");if(s.length!==4&&s.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");s.forEach(e=>{if(!vc(e))throw new Error("bbox must only contain numbers")})}dr(HG,"validateBBox");function XG(s){if(!s)throw new Error("id is required");if(["string","number"].indexOf(typeof s)===-1)throw new Error("id must be a number or a string")}dr(XG,"validateId");var YG=Object.defineProperty,Xi=(s,e)=>YG(s,"name",{value:e,configurable:!0});function da(s,e,t){if(s!==null)for(var a,l,o,m,g,b,A,S=0,M=0,R,j=s.type,W=j==="FeatureCollection",re=j==="Feature",$=W?s.features.length:1,X=0;X<$;X++){A=W?s.features[X].geometry:re?s.geometry:s,R=A?A.type==="GeometryCollection":!1,g=R?A.geometries.length:1;for(var se=0;se<g;se++){var me=0,_e=0;if(m=R?A.geometries[se]:A,m!==null){b=m.coordinates;var pe=m.type;switch(S=t&&(pe==="Polygon"||pe==="MultiPolygon")?1:0,pe){case null:break;case"Point":if(e(b,M,X,me,_e)===!1)return!1;M++,me++;break;case"LineString":case"MultiPoint":for(a=0;a<b.length;a++){if(e(b[a],M,X,me,_e)===!1)return!1;M++,pe==="MultiPoint"&&me++}pe==="LineString"&&me++;break;case"Polygon":case"MultiLineString":for(a=0;a<b.length;a++){for(l=0;l<b[a].length-S;l++){if(e(b[a][l],M,X,me,_e)===!1)return!1;M++}pe==="MultiLineString"&&me++,pe==="Polygon"&&_e++}pe==="Polygon"&&me++;break;case"MultiPolygon":for(a=0;a<b.length;a++){for(_e=0,l=0;l<b[a].length;l++){for(o=0;o<b[a][l].length-S;o++){if(e(b[a][l][o],M,X,me,_e)===!1)return!1;M++}_e++}me++}break;case"GeometryCollection":for(a=0;a<m.geometries.length;a++)if(da(m.geometries[a],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}Xi(da,"coordEach");function KG(s,e,t,a){var l=t;return da(s,function(o,m,g,b,A){m===0&&t===void 0?l=o:l=e(l,o,m,g,b,A)},a),l}Xi(KG,"coordReduce");function oL(s,e){var t;switch(s.type){case"FeatureCollection":for(t=0;t<s.features.length&&e(s.features[t].properties,t)!==!1;t++);break;case"Feature":e(s.properties,0);break}}Xi(oL,"propEach");function JG(s,e,t){var a=t;return oL(s,function(l,o){o===0&&t===void 0?a=l:a=e(a,l,o)}),a}Xi(JG,"propReduce");function sL(s,e){if(s.type==="Feature")e(s,0);else if(s.type==="FeatureCollection")for(var t=0;t<s.features.length&&e(s.features[t],t)!==!1;t++);}Xi(sL,"featureEach");function QG(s,e,t){var a=t;return sL(s,function(l,o){o===0&&t===void 0?a=l:a=e(a,l,o)}),a}Xi(QG,"featureReduce");function eV(s){var e=[];return da(s,function(t){e.push(t)}),e}Xi(eV,"coordAll");function Cw(s,e){var t,a,l,o,m,g,b,A,S,M,R=0,j=s.type==="FeatureCollection",W=s.type==="Feature",re=j?s.features.length:1;for(t=0;t<re;t++){for(g=j?s.features[t].geometry:W?s.geometry:s,A=j?s.features[t].properties:W?s.properties:{},S=j?s.features[t].bbox:W?s.bbox:void 0,M=j?s.features[t].id:W?s.id:void 0,b=g?g.type==="GeometryCollection":!1,m=b?g.geometries.length:1,l=0;l<m;l++){if(o=b?g.geometries[l]:g,o===null){if(e(null,R,A,S,M)===!1)return!1;continue}switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(o,R,A,S,M)===!1)return!1;break}case"GeometryCollection":{for(a=0;a<o.geometries.length;a++)if(e(o.geometries[a],R,A,S,M)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}R++}}Xi(Cw,"geomEach");function tV(s,e,t){var a=t;return Cw(s,function(l,o,m,g,b){o===0&&t===void 0?a=l:a=e(a,l,o,m,g,b)}),a}Xi(tV,"geomReduce");function By(s,e){Cw(s,function(t,a,l,o,m){var g=t===null?null:t.type;switch(g){case null:case"Point":case"LineString":case"Polygon":return e(Ko(t,l,{bbox:o,id:m}),a,0)===!1?!1:void 0}var b;switch(g){case"MultiPoint":b="Point";break;case"MultiLineString":b="LineString";break;case"MultiPolygon":b="Polygon";break}for(var A=0;A<t.coordinates.length;A++){var S=t.coordinates[A],M={type:b,coordinates:S};if(e(Ko(M,l),a,A)===!1)return!1}})}Xi(By,"flattenEach");function rV(s,e,t){var a=t;return By(s,function(l,o,m){o===0&&m===0&&t===void 0?a=l:a=e(a,l,o,m)}),a}Xi(rV,"flattenReduce");function aL(s,e){By(s,function(t,a,l){var o=0;if(t.geometry){var m=t.geometry.type;if(!(m==="Point"||m==="MultiPoint")){var g,b=0,A=0,S=0;if(da(t,function(M,R,j,W,re){if(g===void 0||a>b||W>A||re>S){g=M,b=a,A=W,S=re,o=0;return}var $=Fs([g,M],t.properties);if(e($,a,l,re,o)===!1)return!1;o++,g=M})===!1)return!1}}})}Xi(aL,"segmentEach");function iV(s,e,t){var a=t,l=!1;return aL(s,function(o,m,g,b,A){l===!1&&t===void 0?a=o:a=e(a,o,m,g,b,A),l=!0}),a}Xi(iV,"segmentReduce");function lL(s,e){if(!s)throw new Error("geojson is required");By(s,function(t,a,l){if(t.geometry!==null){var o=t.geometry.type,m=t.geometry.coordinates;switch(o){case"LineString":if(e(t,a,l,0,0)===!1)return!1;break;case"Polygon":for(var g=0;g<m.length;g++)if(e(Fs(m[g],t.properties),a,l,g)===!1)return!1;break}}})}Xi(lL,"lineEach");function nV(s,e,t){var a=t;return lL(s,function(l,o,m,g){o===0&&t===void 0?a=l:a=e(a,l,o,m,g)}),a}Xi(nV,"lineReduce");function oV(s,e){if(e=e||{},!Bh(e))throw new Error("options is invalid");var t=e.featureIndex||0,a=e.multiFeatureIndex||0,l=e.geometryIndex||0,o=e.segmentIndex||0,m=e.properties,g;switch(s.type){case"FeatureCollection":t<0&&(t=s.features.length+t),m=m||s.features[t].properties,g=s.features[t].geometry;break;case"Feature":m=m||s.properties,g=s.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":g=s;break;default:throw new Error("geojson is invalid")}if(g===null)return null;var b=g.coordinates;switch(g.type){case"Point":case"MultiPoint":return null;case"LineString":return o<0&&(o=b.length+o-1),Fs([b[o],b[o+1]],m,e);case"Polygon":return l<0&&(l=b.length+l),o<0&&(o=b[l].length+o-1),Fs([b[l][o],b[l][o+1]],m,e);case"MultiLineString":return a<0&&(a=b.length+a),o<0&&(o=b[a].length+o-1),Fs([b[a][o],b[a][o+1]],m,e);case"MultiPolygon":return a<0&&(a=b.length+a),l<0&&(l=b[a].length+l),o<0&&(o=b[a][l].length-o-1),Fs([b[a][l][o],b[a][l][o+1]],m,e)}throw new Error("geojson is invalid")}Xi(oV,"findSegment");function sV(s,e){if(e=e||{},!Bh(e))throw new Error("options is invalid");var t=e.featureIndex||0,a=e.multiFeatureIndex||0,l=e.geometryIndex||0,o=e.coordIndex||0,m=e.properties,g;switch(s.type){case"FeatureCollection":t<0&&(t=s.features.length+t),m=m||s.features[t].properties,g=s.features[t].geometry;break;case"Feature":m=m||s.properties,g=s.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":g=s;break;default:throw new Error("geojson is invalid")}if(g===null)return null;var b=g.coordinates;switch(g.type){case"Point":return Hi(b,m,e);case"MultiPoint":return a<0&&(a=b.length+a),Hi(b[a],m,e);case"LineString":return o<0&&(o=b.length+o),Hi(b[o],m,e);case"Polygon":return l<0&&(l=b.length+l),o<0&&(o=b[l].length+o),Hi(b[l][o],m,e);case"MultiLineString":return a<0&&(a=b.length+a),o<0&&(o=b[a].length+o),Hi(b[a][o],m,e);case"MultiPolygon":return a<0&&(a=b.length+a),l<0&&(l=b[a].length+l),o<0&&(o=b[a][l].length-o),Hi(b[a][l][o],m,e)}throw new Error("geojson is invalid")}Xi(sV,"findPoint");var aV=Object.defineProperty,lV=(s,e)=>aV(s,"name",{value:e,configurable:!0});function Mw(s,e={}){let t=0,a=0,l=0;return da(s,function(o){t+=o[0],a+=o[1],l++},!0),Hi([t/l,a/l],e.properties)}lV(Mw,"centroid");var cV=Object.defineProperty,ol=(s,e)=>cV(s,"name",{value:e,configurable:!0});function Jo(s){if(!s)throw new Error("coord is required");if(!Array.isArray(s)){if(s.type==="Feature"&&s.geometry!==null&&s.geometry.type==="Point")return[...s.geometry.coordinates];if(s.type==="Point")return[...s.coordinates]}if(Array.isArray(s)&&s.length>=2&&!Array.isArray(s[0])&&!Array.isArray(s[1]))return[...s];throw new Error("coord must be GeoJSON Point or an Array of numbers")}ol(Jo,"getCoord");function Rw(s){if(Array.isArray(s))return s;if(s.type==="Feature"){if(s.geometry!==null)return s.geometry.coordinates}else if(s.coordinates)return s.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}ol(Rw,"getCoords");function cL(s){if(s.length>1&&vc(s[0])&&vc(s[1]))return!0;if(Array.isArray(s[0])&&s[0].length)return cL(s[0]);throw new Error("coordinates must only contain numbers")}ol(cL,"containsNumber");function uV(s,e,t){if(!e||!t)throw new Error("type and name required");if(!s||s.type!==e)throw new Error("Invalid input to "+t+": must be a "+e+", given "+s.type)}ol(uV,"geojsonType");function hV(s,e,t){if(!s)throw new Error("No feature passed");if(!t)throw new Error(".featureOf() requires a name");if(!s||s.type!=="Feature"||!s.geometry)throw new Error("Invalid input to "+t+", Feature with geometry required");if(!s.geometry||s.geometry.type!==e)throw new Error("Invalid input to "+t+": must be a "+e+", given "+s.geometry.type)}ol(hV,"featureOf");function pV(s,e,t){if(!s)throw new Error("No featureCollection passed");if(!t)throw new Error(".collectionOf() requires a name");if(!s||s.type!=="FeatureCollection")throw new Error("Invalid input to "+t+", FeatureCollection required");for(let a of s.features){if(!a||a.type!=="Feature"||!a.geometry)throw new Error("Invalid input to "+t+", Feature with geometry required");if(!a.geometry||a.geometry.type!==e)throw new Error("Invalid input to "+t+": must be a "+e+", given "+a.geometry.type)}}ol(pV,"collectionOf");function dV(s){return s.type==="Feature"?s.geometry:s}ol(dV,"getGeom");function fV(s,e){return s.type==="FeatureCollection"?"FeatureCollection":s.type==="GeometryCollection"?"GeometryCollection":s.type==="Feature"&&s.geometry!==null?s.geometry.type:s.type}ol(fV,"getType");var mV=Object.defineProperty,uL=(s,e)=>mV(s,"name",{value:e,configurable:!0});function Fw(s,e,t={}){let a;return t.final?a=kw(Jo(e),Jo(s)):a=kw(Jo(s),Jo(e)),a>180?-(360-a):a}uL(Fw,"rhumbBearing");function kw(s,e){let t=nl(s[1]),a=nl(e[1]),l=nl(e[0]-s[0]);l>Math.PI&&(l-=2*Math.PI),l<-Math.PI&&(l+=2*Math.PI);let o=Math.log(Math.tan(a/2+Math.PI/4)/Math.tan(t/2+Math.PI/4)),m=Math.atan2(l,o);return(zy(m)+360)%360}uL(kw,"calculateRhumbBearing");var gV=Object.defineProperty,hL=(s,e)=>gV(s,"name",{value:e,configurable:!0});function Lw(s,e,t={}){let a=Jo(s),l=Jo(e);l[0]+=l[0]-a[0]>180?-360:a[0]-l[0]>180?360:0;let o=pL(a,l);return mf(o,"meters",t.units)}hL(Lw,"rhumbDistance");function pL(s,e,t){t=t===void 0?Zi:Number(t);let a=t,l=s[1]*Math.PI/180,o=e[1]*Math.PI/180,m=o-l,g=Math.abs(e[0]-s[0])*Math.PI/180;g>Math.PI&&(g-=2*Math.PI);let b=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(l/2+Math.PI/4)),A=Math.abs(b)>1e-11?m/b:Math.cos(l);return Math.sqrt(m*m+A*A*g*g)*a}hL(pL,"calculateRhumbDistance");var yV=Object.defineProperty,dL=(s,e)=>yV(s,"name",{value:e,configurable:!0});function Dw(s,e,t,a={}){let l=e<0,o=mf(Math.abs(e),a.units,"meters");l&&(o=-Math.abs(o));let m=Jo(s),g=fL(m,o,t);return g[0]+=g[0]-m[0]>180?-360:m[0]-g[0]>180?360:0,Hi(g,a.properties)}dL(Dw,"rhumbDestination");function fL(s,e,t,a){a=a===void 0?Zi:Number(a);let l=e/a,o=s[0]*Math.PI/180,m=nl(s[1]),g=nl(t),b=l*Math.cos(g),A=m+b;Math.abs(A)>Math.PI/2&&(A=A>0?Math.PI-A:-Math.PI-A);let S=Math.log(Math.tan(A/2+Math.PI/4)/Math.tan(m/2+Math.PI/4)),M=Math.abs(S)>1e-11?b/S:Math.cos(m),R=l*Math.sin(g)/M;return[((o+R)*180/Math.PI+540)%360-180,A*180/Math.PI]}dL(fL,"calculateRhumbDestination");var _V=Object.defineProperty,jh=(s,e)=>_V(s,"name",{value:e,configurable:!0});function Ow(s){if(!s)throw new Error("geojson is required");switch(s.type){case"Feature":return zw(s);case"FeatureCollection":return mL(s);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return jy(s);default:throw new Error("unknown GeoJSON type")}}jh(Ow,"clone");function zw(s){let e={type:"Feature"};return Object.keys(s).forEach(t=>{switch(t){case"type":case"properties":case"geometry":return;default:e[t]=s[t]}}),e.properties=Bw(s.properties),s.geometry==null?e.geometry=null:e.geometry=jy(s.geometry),e}jh(zw,"cloneFeature");function Bw(s){let e={};return s&&Object.keys(s).forEach(t=>{let a=s[t];typeof a=="object"?a===null?e[t]=null:Array.isArray(a)?e[t]=a.map(l=>l):e[t]=Bw(a):e[t]=a}),e}jh(Bw,"cloneProperties");function mL(s){let e={type:"FeatureCollection"};return Object.keys(s).forEach(t=>{switch(t){case"type":case"features":return;default:e[t]=s[t]}}),e.features=s.features.map(t=>zw(t)),e}jh(mL,"cloneFeatureCollection");function jy(s){let e={type:s.type};return s.bbox&&(e.bbox=s.bbox),s.type==="GeometryCollection"?(e.geometries=s.geometries.map(t=>jy(t)),e):(e.coordinates=jw(s.coordinates),e)}jh(jy,"cloneGeometry");function jw(s){let e=s;return typeof e[0]!="object"?e.slice():e.map(t=>jw(t))}jh(jw,"deepSlice");var vV=Object.defineProperty,xV=(s,e)=>vV(s,"name",{value:e,configurable:!0});function gL(s,e,t){if(t=t||{},!Bh(t))throw new Error("options is invalid");var a=t.pivot,l=t.mutate;if(!s)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");return e===0||(a||(a=Mw(s)),(l===!1||l===void 0)&&(s=Ow(s)),da(s,function(o){var m=Fw(a,o),g=m+e,b=Lw(a,o),A=Rw(Dw(a,b,g));o[0]=A[0],o[1]=A[1]})),s}xV(gL,"transformRotate");var Nw=gL;var bV=(s,e=1)=>{let{width:t,height:a}=s.getCanvas(),l=s.unproject({x:0,y:0}),o=s.unproject({x:0,y:a/e}),m=s.unproject({x:t/e,y:a/e}),g=s.unproject({x:t/e,y:0});return[[l.lng,l.lat],[g.lng,g.lat],[m.lng,m.lat],[o.lng,o.lat]]},Ny=bV;var wV=s=>{let e=s.getBounds().toArray(),t=Ii(e[0]),a=Ii(e[1]),l=[...t,...a],{width:o,height:m}=s.getCanvas(),g=Fr(l)/o,b=hi(l)/m;return Math.max(g,b)},yL=wV;var SV=s=>od(s.toArray().flat(),"EPSG:4326","EPSG:3857"),Uw=SV;var Gw=class extends xg(Ig){constructor(e={}){let t=document.createElement("canvas");super({canvas:t,id:"realtime",...e}),this.source={id:this.id,type:"canvas",canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],animate:!0,attribution:e.attribution?.join(", "),loaded:!0},this.layer={id:`${this.id}-raster`,type:"raster",source:this.id,layout:{visibility:"visible"},paint:{"raster-opacity":1,"raster-fade-duration":0,"raster-resampling":"nearest"}},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}onAdd(e,t){super.onAdd(e,t),e.isStyleLoaded()&&this.onLoad(),e.on("load",this.onLoad)}onRemove(e,t){e.off("load",this.onLoad),e.getLayer(this.layer.id)&&e.removeLayer(this.layer.id),e.getSource(this.id)&&e.removeSource(this.id),super.onRemove(e,t)}onLoad(){this.map.getSource(this.id)||this.map.addSource(this.id,this.source),this.map.getLayer(this.layer.id)||this.map.addLayer(this.layer,this.id),this.start()}start(){super.start(),this.map.on("move",this.onMove),this.map.on("moveend",this.onMoveEnd),this.map.on("zoomend",this.onZoomEnd)}stop(){super.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}renderTrajectories(e=!1){if(!this.map)return;this.pixelRatio||(this.pixelRatio=1);let{width:t,height:a}=this.map.getCanvas(),l=this.map.getCenter(),o=this.map.unproject({x:0,y:a/this.pixelRatio}),m=this.map.unproject({x:t/this.pixelRatio,y:0}),g=Nw(Hi([o.lng,o.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,b=Nw(Hi([m.lng,m.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,A=[...Ii(g),...Ii(b)],S=Fr(A)/(t/this.pixelRatio),M=hi(A)/(a/this.pixelRatio),R=Math.max(S,M),j={size:[t/this.pixelRatio,a/this.pixelRatio],center:Ii([l.lng,l.lat]),extent:A,resolution:R,zoom:this.map.getZoom()-1,rotation:-(this.map.getBearing()*Math.PI)/180,pixelRatio:this.pixelRatio};super.renderTrajectories(j,e)}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getZoom())}purgeTrajectory(e,t,a){return super.purgeTrajectory(e,t||Uw(this.map.getBounds()),a||Math.floor(this.map.getZoom()-1))}setBbox(e,t){super.setBbox(e||Uw(this.map.getBounds()),t||this.map.getZoom()-1)}renderTrajectoriesInternal(e,t=!1){let a=super.renderTrajectoriesInternal(e,t);if(a&&this.map.style){let l=Ny(this.map,this.pixelRatio),o=this.map.getSource(this.id);o&&o.setCoordinates(l)}return a}onMove(){this.renderTrajectories()}onMoveEnd(){this.renderTrajectories(),this.isUpdateBboxOnMoveEnd&&this.setBbox()}},_L=Gw;var Vw={ol:Sg,maplibre:Uy};typeof window<"u"&&(window.mbt=Vw);var Toe=Vw;})();
|
|
588
|
+
`){Pt+=pt,pt=0,ut=R*_e+Se*j,++ot;continue}let Ot=W[dt+1]||b.font;Ot!==gt&&(l&&Ue.push("font",Ot),a&&$e.push("font",Ot),gt=Ot),pt=Math.max(pt,se[et]);let Qt=[yt,ut+Se*X[et]+R*(X[et]-me[ot]),.5*(j+pt)+Pt];ut+=X[et],l&&Ue.push("strokeText",Qt),a&&$e.push("fillText",Qt),++et}return Array.prototype.push.apply(pe,Ue),Array.prototype.push.apply(pe,$e),this.labels_[o]=Me,Me}replayTextBackground_(e,t,a,l,o,m,g){e.beginPath(),e.moveTo.apply(e,t),e.lineTo.apply(e,a),e.lineTo.apply(e,l),e.lineTo.apply(e,o),e.lineTo.apply(e,t),m&&(this.alignAndScaleFill_=m[2],this.fill_(e)),g&&(this.setStrokeStyle_(e,g),e.stroke())}calculateImageOrLabelDimensions_(e,t,a,l,o,m,g,b,A,S,M,R,j,W,re,$){g*=R[0],b*=R[1];let X=a-g,se=l-b,me=o+A>e?e-A:o,_e=m+S>t?t-S:m,pe=W[3]+me*R[0]+W[1],xe=W[0]+_e*R[1]+W[2],Ee=X-W[3],Me=se-W[0];(re||M!==0)&&(Ka[0]=Ee,Ja[0]=Ee,Ka[1]=Me,la[1]=Me,la[0]=Ee+pe,ca[0]=la[0],ca[1]=Me+xe,Ja[1]=ca[1]);let Se;return M!==0?(Se=cn(Ai(),a,l,1,1,M,-a,-l),zi(Se,Ka),zi(Se,la),zi(Se,ca),zi(Se,Ja),Js(Math.min(Ka[0],la[0],ca[0],Ja[0]),Math.min(Ka[1],la[1],ca[1],Ja[1]),Math.max(Ka[0],la[0],ca[0],Ja[0]),Math.max(Ka[1],la[1],ca[1],Ja[1]),Du)):Js(Math.min(Ee,Ee+pe),Math.min(Me,Me+xe),Math.max(Ee,Ee+pe),Math.max(Me,Me+xe),Du),j&&(X=Math.round(X),se=Math.round(se)),{drawImageX:X,drawImageY:se,drawImageW:me,drawImageH:_e,originX:A,originY:S,declutterBox:{minX:Du[0],minY:Du[1],maxX:Du[2],maxY:Du[3],value:$},canvasTransform:Se,scale:R}}replayImageOrLabel_(e,t,a,l,o,m,g){let b=!!(m||g),A=l.declutterBox,S=g?g[2]*l.scale[0]/2:0;return A.minX-S<=t[0]&&A.maxX+S>=0&&A.minY-S<=t[1]&&A.maxY+S>=0&&(b&&this.replayTextBackground_(e,Ka,la,ca,Ja,m,g),hI(e,l.canvasTransform,o,a,l.originX,l.originY,l.drawImageW,l.drawImageH,l.drawImageX,l.drawImageY,l.scale)),!0}fill_(e){let t=this.alignAndScaleFill_;if(t){let a=zi(this.renderedTransform_,[0,0]),l=512*this.pixelRatio;e.save(),e.translate(a[0]%l,a[1]%l),t!==1&&e.scale(t,t),e.rotate(this.viewRotation_)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6])}drawLabelWithPointPlacement_(e,t,a,l){let o=this.textStates[t],m=this.createLabel(e,t,l,a),g=this.strokeStates[a],b=this.pixelRatio,A=v0(Array.isArray(e)?e[0]:e,o.textAlign||Ha),S=zd[o.textBaseline||Wl],M=g&&g.lineWidth?g.lineWidth:0,R=m.width/b-2*o.scale[0],j=A*R+2*(.5-A)*M,W=S*m.height/b+2*(.5-S)*M;return{label:m,anchorX:j,anchorY:W}}execute_(e,t,a,l,o,m,g,b){let A=this.zIndexContext_,S;this.pixelCoordinates_&&Fn(a,this.renderedTransform_)?S=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),S=zn(this.coordinates,0,this.coordinates.length,2,a,this.pixelCoordinates_),LA(this.renderedTransform_,a));let M=0,R=l.length,j=0,W,re,$,X,se,me,_e,pe,xe,Ee,Me,Se,ut,Ue=0,$e=0,pt=null,Pt=null,et=this.coordinateCache_,ot=this.viewRotation_,gt=Math.round(Math.atan2(-a[1],a[0])*1e12)/1e12,dt={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:ot},kt=this.instructions!=l||this.overlaps?0:200,yt,Ot,Qt,Tr;for(;M<R;){let Ge=l[M];switch(Ge[0]){case xt.BEGIN_GEOMETRY:yt=Ge[1],Tr=Ge[3],yt.getGeometry()?g!==void 0&&!ni(g,Tr.getExtent())?M=Ge[2]+1:++M:M=Ge[2],A&&(A.zIndex=Ge[4]);break;case xt.BEGIN_PATH:Ue>kt&&(this.fill_(e),Ue=0),$e>kt&&(e.stroke(),$e=0),!Ue&&!$e&&(e.beginPath(),se=NaN,me=NaN),++M;break;case xt.CIRCLE:j=Ge[1];let Vr=S[j],Yi=S[j+1],Ki=S[j+2],Wn=S[j+3],Kr=Ki-Vr,An=Wn-Yi,br=Math.sqrt(Kr*Kr+An*An);e.moveTo(Vr+br,Yi),e.arc(Vr,Yi,br,0,2*Math.PI,!0),++M;break;case xt.CLOSE_PATH:e.closePath(),++M;break;case xt.CUSTOM:j=Ge[1],W=Ge[2];let Zn=Ge[3],Te=Ge[4],En=Ge[5];dt.geometry=Zn,dt.feature=yt,M in et||(et[M]=[]);let Ri=et[M];En?En(S,j,W,2,Ri):(Ri[0]=S[j],Ri[1]=S[j+1],Ri.length=2),A&&(A.zIndex=Ge[6]),Te(Ri,dt),++M;break;case xt.DRAW_IMAGE:j=Ge[1],W=Ge[2],xe=Ge[3],re=Ge[4],$=Ge[5];let Tt=Ge[6],er=Ge[7],ki=Ge[8],co=Ge[9],uo=Ge[10],In=Ge[11],Pn=Ge[12],Hn=Ge[13];X=Ge[14]||"declutter";let ho=Ge[15];if(!xe&&Ge.length>=20){Ee=Ge[19],Me=Ge[20],Se=Ge[21],ut=Ge[22];let ue=this.drawLabelWithPointPlacement_(Ee,Me,Se,ut);xe=ue.label,Ge[3]=xe;let de=Ge[23];re=(ue.anchorX-de)*this.pixelRatio,Ge[4]=re;let oe=Ge[24];$=(ue.anchorY-oe)*this.pixelRatio,Ge[5]=$,Tt=xe.height,Ge[6]=Tt,Hn=xe.width,Ge[13]=Hn}let je;Ge.length>25&&(je=Ge[25]);let Jr,qr,Xn;Ge.length>17?(Jr=Ge[16],qr=Ge[17],Xn=Ge[18]):(Jr=na,qr=!1,Xn=!1),uo&>?In+=ot:!uo&&!gt&&(In-=ot);let Eo=0;for(;j<W;j+=2){if(je&&je[Eo++]<Hn/this.pixelRatio)continue;let ue=this.calculateImageOrLabelDimensions_(xe.width,xe.height,S[j],S[j+1],Hn,Tt,re,$,ki,co,In,Pn,o,Jr,qr||Xn,yt),de=[e,t,xe,ue,er,qr?pt:null,Xn?Pt:null];if(b){let oe,ve,Ce;if(ho){let We=W-j;if(!ho[We]){ho[We]={args:de,declutterMode:X};continue}let Je=ho[We];oe=Je.args,ve=Je.declutterMode,delete ho[We],Ce=BI(oe)}let Pe,Ie;if(oe&&(ve!=="declutter"||!b.collides(Ce))&&(Pe=!0),(X!=="declutter"||!b.collides(ue.declutterBox))&&(Ie=!0),ve==="declutter"&&X==="declutter"){let We=Pe&&Ie;Pe=We,Ie=We}Pe&&(ve!=="none"&&b.insert(Ce),this.replayImageOrLabel_.apply(this,oe)),Ie&&(X!=="none"&&b.insert(ue.declutterBox),this.replayImageOrLabel_.apply(this,de))}else this.replayImageOrLabel_.apply(this,de)}++M;break;case xt.DRAW_CHARS:let Be=Ge[1],Ct=Ge[2],bt=Ge[3],ai=Ge[4];ut=Ge[5];let li=Ge[6],Et=Ge[7],Tn=Ge[8];Se=Ge[9];let fn=Ge[10];Ee=Ge[11],Me=Ge[12];let Lr=[Ge[13],Ge[13]];X=Ge[14]||"declutter";let J=this.textStates[Me],B=J.font,N=[J.scale[0]*Et,J.scale[1]*Et],V;B in this.widths_?V=this.widths_[B]:(V={},this.widths_[B]=V);let ee=$m(S,Be,Ct,2),le=Math.abs(N[0])*Nx(B,Ee,V);if(ai||le<=ee){let ue=this.textStates[Me].textAlign,de=(ee-le)*v0(Ee,ue),oe=zI(S,Be,Ct,2,Ee,de,li,Math.abs(N[0]),Nx,B,V,gt?0:this.viewRotation_);e:if(oe){let ve=[],Ce,Pe,Ie,We,Je;if(Se)for(Ce=0,Pe=oe.length;Ce<Pe;++Ce){Je=oe[Ce],Ie=Je[4],We=this.createLabel(Ie,Me,"",Se),re=Je[2]+(N[0]<0?-fn:fn),$=bt*We.height+(.5-bt)*2*fn*N[1]/N[0]-Tn;let At=this.calculateImageOrLabelDimensions_(We.width,We.height,Je[0],Je[1],We.width,We.height,re,$,0,0,Je[3],Lr,!1,na,!1,yt);if(b&&X==="declutter"&&b.collides(At.declutterBox))break e;ve.push([e,t,We,At,1,null,null])}if(ut)for(Ce=0,Pe=oe.length;Ce<Pe;++Ce){Je=oe[Ce],Ie=Je[4],We=this.createLabel(Ie,Me,ut,""),re=Je[2],$=bt*We.height-Tn;let At=this.calculateImageOrLabelDimensions_(We.width,We.height,Je[0],Je[1],We.width,We.height,re,$,0,0,Je[3],Lr,!1,na,!1,yt);if(b&&X==="declutter"&&b.collides(At.declutterBox))break e;ve.push([e,t,We,At,1,null,null])}b&&X!=="none"&&b.load(ve.map(BI));for(let At=0,_t=ve.length;At<_t;++At)this.replayImageOrLabel_.apply(this,ve[At])}}++M;break;case xt.END_GEOMETRY:if(m!==void 0){yt=Ge[1];let ue=m(yt,Tr,X);if(ue)return ue}++M;break;case xt.FILL:kt?Ue++:this.fill_(e),++M;break;case xt.MOVE_TO_LINE_TO:for(j=Ge[1],W=Ge[2],Ot=S[j],Qt=S[j+1],e.moveTo(Ot,Qt),se=Ot+.5|0,me=Qt+.5|0,j+=2;j<W;j+=2)Ot=S[j],Qt=S[j+1],_e=Ot+.5|0,pe=Qt+.5|0,(j==W-2||_e!==se||pe!==me)&&(e.lineTo(Ot,Qt),se=_e,me=pe);++M;break;case xt.SET_FILL_STYLE:pt=Ge,this.alignAndScaleFill_=Ge[2],Ue&&(this.fill_(e),Ue=0,$e&&(e.stroke(),$e=0)),e.fillStyle=Ge[1],++M;break;case xt.SET_STROKE_STYLE:Pt=Ge,$e&&(e.stroke(),$e=0),this.setStrokeStyle_(e,Ge),++M;break;case xt.STROKE:kt?$e++:e.stroke(),++M;break;default:++M;break}}Ue&&this.fill_(e),$e&&e.stroke()}execute(e,t,a,l,o,m){this.viewRotation_=l,this.execute_(e,t,a,this.instructions,o,void 0,void 0,m)}executeHitDetection(e,t,a,l,o){return this.viewRotation_=a,this.execute_(e,[e.canvas.width,e.canvas.height],t,this.hitDetectionInstructions,!0,l,o)}},NI=x0;var Hl=["Polygon","Circle","LineString","Image","Text","Default"],S0=["Image","Text"],UI=Hl.filter(s=>!S0.includes(s)),w0=class{constructor(e,t,a,l,o,m,g){this.maxExtent_=e,this.overlaps_=l,this.pixelRatio_=a,this.resolution_=t,this.renderBuffer_=m,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Ai(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(o,g)}clip(e,t){let a=this.getClipCoords(t);e.beginPath(),e.moveTo(a[0],a[1]),e.lineTo(a[2],a[3]),e.lineTo(a[4],a[5]),e.lineTo(a[6],a[7]),e.clip()}createExecutors_(e,t){for(let a in e){let l=this.executorsByZIndex_[a];l===void 0&&(l={},this.executorsByZIndex_[a]=l);let o=e[a];for(let m in o){let g=o[m];l[m]=new NI(this.resolution_,this.pixelRatio_,this.overlaps_,g,t)}}}hasExecutors(e){for(let t in this.executorsByZIndex_){let a=this.executorsByZIndex_[t];for(let l=0,o=e.length;l<o;++l)if(e[l]in a)return!0}return!1}forEachFeatureAtCoordinate(e,t,a,l,o,m){l=Math.round(l);let g=l*2+1,b=cn(this.hitDetectionTransform_,l+.5,l+.5,1/t,-1/t,-a,-e[0],-e[1]),A=!this.hitDetectionContext_;A&&(this.hitDetectionContext_=Yr(g,g,void 0,{willReadFrequently:!0}));let S=this.hitDetectionContext_;S.canvas.width!==g||S.canvas.height!==g?(S.canvas.width=g,S.canvas.height=g):A||S.clearRect(0,0,g,g);let M;this.renderBuffer_!==void 0&&(M=On(),fv(M,e),Ln(M,t*(this.renderBuffer_+l),M));let R=hB(l),j;function W(pe,xe,Ee){let Me=S.getImageData(0,0,g,g).data;for(let Se=0,ut=R.length;Se<ut;Se++)if(Me[R[Se]]>0){if(!m||Ee==="none"||j!=="Image"&&j!=="Text"||m.includes(pe)){let Ue=(R[Se]-3)/4,$e=l-Ue%g,pt=l-(Ue/g|0),Pt=o(pe,xe,$e*$e+pt*pt);if(Pt)return Pt}S.clearRect(0,0,g,g);break}}let re=Object.keys(this.executorsByZIndex_).map(Number);re.sort(Oo);let $,X,se,me,_e;for($=re.length-1;$>=0;--$){let pe=re[$].toString();for(se=this.executorsByZIndex_[pe],X=Hl.length-1;X>=0;--X)if(j=Hl[X],me=se[j],me!==void 0&&(_e=me.executeHitDetection(S,b,a,W,M),_e))return _e}}getClipCoords(e){let t=this.maxExtent_;if(!t)return null;let a=t[0],l=t[1],o=t[2],m=t[3],g=[a,l,a,m,o,m,o,l];return zn(g,0,8,2,e,g),g}isEmpty(){return oo(this.executorsByZIndex_)}execute(e,t,a,l,o,m,g){let b=Object.keys(this.executorsByZIndex_).map(Number);b.sort(Oo),m=m||Hl;let A=Hl.length,S,M,R,j,W;for(g&&b.reverse(),S=0,M=b.length;S<M;++S){let re=b[S].toString();for(W=this.executorsByZIndex_[re],R=0,j=m.length;R<j;++R){let $=m[R],X=W[$];if(X!==void 0){let se=g===null?void 0:X.getZIndexContext(),me=se?se.getContext():e,_e=this.maxExtent_&&$!=="Image"&&$!=="Text";if(_e&&(me.save(),this.clip(me,a)),!se||$==="Text"||$==="Image"?X.execute(me,t,a,l,o,g):se.pushFunction(pe=>X.execute(pe,t,a,l,o,g)),_e&&me.restore(),se){se.offset();let pe=b[S]*A+R;this.deferredZIndexContexts_[pe]||(this.deferredZIndexContexts_[pe]=[]),this.deferredZIndexContexts_[pe].push(se)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(Oo);for(let a=0,l=t.length;a<l;++a)e[t[a]].forEach(o=>{o.draw(this.renderedContext_),o.clear()}),e[t[a]].length=0}},b0={};function hB(s){if(b0[s]!==void 0)return b0[s];let e=s*2+1,t=s*s,a=new Array(t+1);for(let o=0;o<=s;++o)for(let m=0;m<=s;++m){let g=o*o+m*m;if(g>t)break;let b=a[g];b||(b=[],a[g]=b),b.push(((s+o)*e+(s+m))*4+3),o>0&&b.push(((s-o)*e+(s+m))*4+3),m>0&&(b.push(((s+o)*e+(s-m))*4+3),o>0&&b.push(((s-o)*e+(s-m))*4+3))}let l=[];for(let o=0,m=a.length;o<m;++o)a[o]&&l.push(...a[o]);return b0[s]=l,l}var GI=w0;var A0=class extends pg{constructor(e,t,a,l,o,m,g){super(),this.context_=e,this.pixelRatio_=t,this.extent_=a,this.transform_=l,this.transformRotation_=l?iE(Math.atan2(l[1],l[0]),10):0,this.viewRotation_=o,this.squaredTolerance_=m,this.userTransform_=g,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_=Ai()}drawImages_(e,t,a,l){if(!this.image_)return;let o=zn(e,t,a,l,this.transform_,this.pixelCoordinates_),m=this.context_,g=this.tmpLocalTransform_,b=m.globalAlpha;this.imageOpacity_!=1&&(m.globalAlpha=b*this.imageOpacity_);let A=this.imageRotation_;this.transformRotation_===0&&(A-=this.viewRotation_),this.imageRotateWithView_&&(A+=this.viewRotation_);for(let S=0,M=o.length;S<M;S+=2){let R=o[S]-this.imageAnchorX_,j=o[S+1]-this.imageAnchorY_;if(A!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let W=R+this.imageAnchorX_,re=j+this.imageAnchorY_;cn(g,W,re,1,1,A,-W,-re),m.save(),m.transform.apply(m,g),m.translate(W,re),m.scale(this.imageScale_[0],this.imageScale_[1]),m.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),m.restore()}else m.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,R,j,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(m.globalAlpha=b)}drawText_(e,t,a,l){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let o=zn(e,t,a,l,this.transform_,this.pixelCoordinates_),m=this.context_,g=this.textRotation_;for(this.transformRotation_===0&&(g-=this.viewRotation_),this.textRotateWithView_&&(g+=this.viewRotation_);t<a;t+=l){let b=o[t]+this.textOffsetX_,A=o[t+1]+this.textOffsetY_;g!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(m.save(),m.translate(b-this.textOffsetX_,A-this.textOffsetY_),m.rotate(g),m.translate(this.textOffsetX_,this.textOffsetY_),m.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&m.strokeText(this.text_,0,0),this.textFillState_&&m.fillText(this.text_,0,0),m.restore()):(this.textStrokeState_&&m.strokeText(this.text_,b,A),this.textFillState_&&m.fillText(this.text_,b,A))}}moveToLineTo_(e,t,a,l,o){let m=this.context_,g=zn(e,t,a,l,this.transform_,this.pixelCoordinates_);m.moveTo(g[0],g[1]);let b=g.length;o&&(b-=2);for(let A=2;A<b;A+=2)m.lineTo(g[A],g[A+1]);return o&&m.closePath(),a}drawRings_(e,t,a,l){for(let o=0,m=a.length;o<m;++o)t=this.moveToLineTo_(e,t,a[o],l,!0);return t}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ni(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=_E(e,this.transform_,this.pixelCoordinates_),a=t[2]-t[0],l=t[3]-t[1],o=Math.sqrt(a*a+l*l),m=this.context_;m.beginPath(),m.arc(t[0],t[1],o,0,2*Math.PI),this.fillState_&&m.fill(),this.strokeState_&&m.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,t){let a=t.getGeometryFunction()(e);a&&(this.setStyle(t),this.drawGeometry(a))}drawGeometryCollection(e){let t=e.getGeometriesArray();for(let a=0,l=t.length;a<l;++a)this.drawGeometry(t[a])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getFlatCoordinates(),a=e.getStride();this.image_&&this.drawImages_(t,0,t.length,a),this.text_!==""&&this.drawText_(t,0,t.length,a)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getFlatCoordinates(),a=e.getStride();this.image_&&this.drawImages_(t,0,t.length,a),this.text_!==""&&this.drawText_(t,0,t.length,a)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ni(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let t=this.context_,a=e.getFlatCoordinates();t.beginPath(),this.moveToLineTo_(a,0,a.length,e.getStride(),!1),t.stroke()}if(this.text_!==""){let t=e.getFlatMidpoint();this.drawText_(t,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getExtent();if(ni(this.extent_,t)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let a=this.context_,l=e.getFlatCoordinates(),o=0,m=e.getEnds(),g=e.getStride();a.beginPath();for(let b=0,A=m.length;b<A;++b)o=this.moveToLineTo_(l,o,m[b],g,!1);a.stroke()}if(this.text_!==""){let a=e.getFlatMidpoints();this.drawText_(a,0,a.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ni(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=this.context_;t.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){let t=e.getFlatInteriorPoint();this.drawText_(t,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ni(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=this.context_,a=e.getOrientedFlatCoordinates(),l=0,o=e.getEndss(),m=e.getStride();t.beginPath();for(let g=0,b=o.length;g<b;++g){let A=o[g];l=this.drawRings_(a,l,A,m)}this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){let t=e.getFlatInteriorPoints();this.drawText_(t,0,t.length,2)}}}setContextFillState_(e){let t=this.context_,a=this.contextFillState_;a?a.fillStyle!=e.fillStyle&&(a.fillStyle=e.fillStyle,t.fillStyle=e.fillStyle):(t.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let t=this.context_,a=this.contextStrokeState_;a?(a.lineCap!=e.lineCap&&(a.lineCap=e.lineCap,t.lineCap=e.lineCap),Fn(a.lineDash,e.lineDash)||t.setLineDash(a.lineDash=e.lineDash),a.lineDashOffset!=e.lineDashOffset&&(a.lineDashOffset=e.lineDashOffset,t.lineDashOffset=e.lineDashOffset),a.lineJoin!=e.lineJoin&&(a.lineJoin=e.lineJoin,t.lineJoin=e.lineJoin),a.lineWidth!=e.lineWidth&&(a.lineWidth=e.lineWidth,t.lineWidth=e.lineWidth),a.miterLimit!=e.miterLimit&&(a.miterLimit=e.miterLimit,t.miterLimit=e.miterLimit),a.strokeStyle!=e.strokeStyle&&(a.strokeStyle=e.strokeStyle,t.strokeStyle=e.strokeStyle)):(t.lineCap=e.lineCap,t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset,t.lineJoin=e.lineJoin,t.lineWidth=e.lineWidth,t.miterLimit=e.miterLimit,t.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 t=this.context_,a=this.contextTextState_,l=e.textAlign?e.textAlign:Ha;a?(a.font!=e.font&&(a.font=e.font,t.font=e.font),a.textAlign!=l&&(a.textAlign=l,t.textAlign=l),a.textBaseline!=e.textBaseline&&(a.textBaseline=e.textBaseline,t.textBaseline=e.textBaseline)):(t.font=e.font,t.textAlign=l,t.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:l,textBaseline:e.textBaseline})}setFillStrokeStyle(e,t){if(!e)this.fillState_=null;else{let a=e.getColor();this.fillState_={fillStyle:Nn(a||di)}}if(!t)this.strokeState_=null;else{let a=t.getColor(),l=t.getLineCap(),o=t.getLineDash(),m=t.getLineDashOffset(),g=t.getLineJoin(),b=t.getWidth(),A=t.getMiterLimit(),S=o||Un;this.strokeState_={lineCap:l!==void 0?l:ms,lineDash:this.pixelRatio_===1?S:S.map(M=>M*this.pixelRatio_),lineDashOffset:(m||Gn)*this.pixelRatio_,lineJoin:g!==void 0?g:gs,lineWidth:(b!==void 0?b:oa)*this.pixelRatio_,miterLimit:A!==void 0?A:ra,strokeStyle:Nn(a||ia)}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}let a=e.getPixelRatio(this.pixelRatio_),l=e.getAnchor(),o=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=l[0]*a,this.imageAnchorY_=l[1]*a,this.imageHeight_=t[1]*a,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=o[0],this.imageOriginY_=o[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let m=e.getScaleArray();this.imageScale_=[m[0]*this.pixelRatio_/a,m[1]*this.pixelRatio_/a],this.imageWidth_=t[0]*a}setTextStyle(e){if(!e)this.text_="";else{let t=e.getFill();if(!t)this.textFillState_=null;else{let j=t.getColor();this.textFillState_={fillStyle:Nn(j||di)}}let a=e.getStroke();if(!a)this.textStrokeState_=null;else{let j=a.getColor(),W=a.getLineCap(),re=a.getLineDash(),$=a.getLineDashOffset(),X=a.getLineJoin(),se=a.getWidth(),me=a.getMiterLimit();this.textStrokeState_={lineCap:W!==void 0?W:ms,lineDash:re||Un,lineDashOffset:$||Gn,lineJoin:X!==void 0?X:gs,lineWidth:se!==void 0?se:oa,miterLimit:me!==void 0?me:ra,strokeStyle:Nn(j||ia)}}let l=e.getFont(),o=e.getOffsetX(),m=e.getOffsetY(),g=e.getRotateWithView(),b=e.getRotation(),A=e.getScaleArray(),S=e.getText(),M=e.getTextAlign(),R=e.getTextBaseline();this.textState_={font:l!==void 0?l:og,textAlign:M!==void 0?M:Ha,textBaseline:R!==void 0?R:Wl},this.text_=S!==void 0?Array.isArray(S)?S.reduce((j,W,re)=>j+=re%2?" ":W,""):S:"",this.textOffsetX_=o!==void 0?this.pixelRatio_*o:0,this.textOffsetY_=m!==void 0?this.pixelRatio_*m:0,this.textRotateWithView_=g!==void 0?g:!1,this.textRotation_=b!==void 0?b:0,this.textScale_=[this.pixelRatio_*A[0],this.pixelRatio_*A[1]]}}},VI=A0;var Xo=.5;function qI(s,e,t,a,l,o,m,g,b){let A=b?hs(l,b):l,S=s[0]*Xo,M=s[1]*Xo,R=Yr(S,M);R.imageSmoothingEnabled=!1;let j=R.canvas,W=new VI(R,Xo,l,null,m,g,b?wu(so(),b):null),re=t.length,$=Math.floor((256*256*256-1)/re),X={};for(let me=1;me<=re;++me){let _e=t[me-1],pe=_e.getStyleFunction()||a;if(!pe)continue;let xe=pe(_e,o);if(!xe)continue;Array.isArray(xe)||(xe=[xe]);let Me=(me*$).toString(16).padStart(7,"#00000");for(let Se=0,ut=xe.length;Se<ut;++Se){let Ue=xe[Se],$e=Ue.getGeometryFunction()(_e);if(!$e||!ni(A,$e.getExtent()))continue;let pt=Ue.clone(),Pt=pt.getFill();Pt&&Pt.setColor(Me);let et=pt.getStroke();et&&(et.setColor(Me),et.setLineDash(null)),pt.setText(void 0);let ot=Ue.getImage();if(ot){let yt=ot.getImageSize();if(!yt)continue;let Ot=Yr(yt[0],yt[1],void 0,{alpha:!1}),Qt=Ot.canvas;Ot.fillStyle=Me,Ot.fillRect(0,0,Qt.width,Qt.height),pt.setImage(new Pd({img:Qt,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 gt=pt.getZIndex()||0,dt=X[gt];dt||(dt={},X[gt]=dt,dt.Polygon=[],dt.Circle=[],dt.LineString=[],dt.Point=[]);let kt=$e.getType();if(kt==="GeometryCollection"){let yt=$e.getGeometriesArrayRecursive();for(let Ot=0,Qt=yt.length;Ot<Qt;++Ot){let Tr=yt[Ot];dt[Tr.getType().replace("Multi","")].push(Tr,pt)}}else dt[kt.replace("Multi","")].push($e,pt)}}let se=Object.keys(X).map(Number).sort(Oo);for(let me=0,_e=se.length;me<_e;++me){let pe=X[se[me]];for(let xe in pe){let Ee=pe[xe];for(let Me=0,Se=Ee.length;Me<Se;Me+=2){W.setStyle(Ee[Me+1]);for(let ut=0,Ue=e.length;ut<Ue;++ut)W.setTransform(e[ut]),W.drawGeometry(Ee[Me])}}}return R.getImageData(0,0,j.width,j.height)}function $I(s,e,t){let a=[];if(t){let l=Math.floor(Math.round(s[0])*Xo),o=Math.floor(Math.round(s[1])*Xo),m=(zr(l,0,t.width-1)+zr(o,0,t.height-1)*t.width)*4,g=t.data[m],b=t.data[m+1],S=t.data[m+2]+256*(b+256*g),M=Math.floor((256*256*256-1)/e.length);S&&S%M===0&&a.push(e[S/M-1])}return a}var pB=.5,WI={Point:vB,LineString:gB,Polygon:bB,MultiPoint:xB,MultiLineString:yB,MultiPolygon:_B,GeometryCollection:mB,Circle:dB};function ZI(s,e){return parseInt(Nt(s),10)-parseInt(Nt(e),10)}function E0(s,e){let t=I0(s,e);return t*t}function I0(s,e){return pB*s/e}function dB(s,e,t,a,l){let o=t.getFill(),m=t.getStroke();if(o||m){let b=s.getBuilder(t.getZIndex(),"Circle");b.setFillStrokeStyle(o,m),b.drawCircle(e,a,l)}let g=t.getText();if(g&&g.getText()){let b=s.getBuilder(t.getZIndex(),"Text");b.setTextStyle(g),b.drawText(e,a)}}function P0(s,e,t,a,l,o,m,g){let b=[],A=t.getImage();if(A){let R=!0,j=A.getImageState();j==Rt.LOADED||j==Rt.ERROR?R=!1:j==Rt.IDLE&&A.load(),R&&b.push(A.ready())}let S=t.getFill();S&&S.loading()&&b.push(S.ready());let M=b.length>0;return M&&Promise.all(b).then(()=>l(null)),fB(s,e,t,a,o,m,g),M}function fB(s,e,t,a,l,o,m){let g=t.getGeometryFunction()(e);if(!g)return;let b=g.simplifyTransformed(a,l);if(t.getRenderer())HI(s,b,t,e,m);else{let S=WI[b.getType()];S(s,b,t,e,m,o)}}function HI(s,e,t,a,l){if(e.getType()=="GeometryCollection"){let m=e.getGeometries();for(let g=0,b=m.length;g<b;++g)HI(s,m[g],t,a,l);return}s.getBuilder(t.getZIndex(),"Default").drawCustom(e,a,t.getRenderer(),t.getHitDetectionRenderer(),l)}function mB(s,e,t,a,l,o){let m=e.getGeometriesArray(),g,b;for(g=0,b=m.length;g<b;++g){let A=WI[m[g].getType()];A(s,m[g],t,a,l,o)}}function gB(s,e,t,a,l){let o=t.getStroke();if(o){let g=s.getBuilder(t.getZIndex(),"LineString");g.setFillStrokeStyle(null,o),g.drawLineString(e,a,l)}let m=t.getText();if(m&&m.getText()){let g=s.getBuilder(t.getZIndex(),"Text");g.setTextStyle(m),g.drawText(e,a,l)}}function yB(s,e,t,a,l){let o=t.getStroke();if(o){let g=s.getBuilder(t.getZIndex(),"LineString");g.setFillStrokeStyle(null,o),g.drawMultiLineString(e,a,l)}let m=t.getText();if(m&&m.getText()){let g=s.getBuilder(t.getZIndex(),"Text");g.setTextStyle(m),g.drawText(e,a,l)}}function _B(s,e,t,a,l){let o=t.getFill(),m=t.getStroke();if(m||o){let b=s.getBuilder(t.getZIndex(),"Polygon");b.setFillStrokeStyle(o,m),b.drawMultiPolygon(e,a,l)}let g=t.getText();if(g&&g.getText()){let b=s.getBuilder(t.getZIndex(),"Text");b.setTextStyle(g),b.drawText(e,a,l)}}function vB(s,e,t,a,l,o){let m=t.getImage(),g=t.getText(),b=g&&g.getText(),A=o&&m&&b?{}:void 0;if(m){if(m.getImageState()!=Rt.LOADED)return;let S=s.getBuilder(t.getZIndex(),"Image");S.setImageStyle(m,A),S.drawPoint(e,a,l)}if(b){let S=s.getBuilder(t.getZIndex(),"Text");S.setTextStyle(g,A),S.drawText(e,a,l)}}function xB(s,e,t,a,l,o){let m=t.getImage(),g=m&&m.getOpacity()!==0,b=t.getText(),A=b&&b.getText(),S=o&&g&&A?{}:void 0;if(g){if(m.getImageState()!=Rt.LOADED)return;let M=s.getBuilder(t.getZIndex(),"Image");M.setImageStyle(m,S),M.drawMultiPoint(e,a,l)}if(A){let M=s.getBuilder(t.getZIndex(),"Text");M.setTextStyle(b,S),M.drawText(e,a,l)}}function bB(s,e,t,a,l){let o=t.getFill(),m=t.getStroke();if(o||m){let b=s.getBuilder(t.getZIndex(),"Polygon");b.setFillStrokeStyle(o,m),b.drawPolygon(e,a,l)}let g=t.getText();if(g&&g.getText()){let b=s.getBuilder(t.getZIndex(),"Text");b.setTextStyle(g),b.drawText(e,a,l)}}var T0=class extends fg{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_=On(),this.wrappedRenderedExtent_=On(),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,t,a){let l=t.extent,o=t.viewState,m=o.center,g=o.resolution,b=o.projection,A=o.rotation,S=b.getExtent(),M=this.getLayer().getSource(),R=this.getLayer().getDeclutter(),j=t.pixelRatio,W=t.viewHints,re=!(W[Bn.ANIMATING]||W[Bn.INTERACTING]),$=this.context,X=Math.round(Fr(l)/g*j),se=Math.round(hi(l)/g*j),me=M.getWrapX()&&b.canWrapX(),_e=me?Fr(S):null,pe=me?Math.ceil((l[2]-S[2])/_e)+1:1,xe=me?Math.floor((l[0]-S[0])/_e):0;do{let Ee=this.getRenderTransform(m,g,0,j,X,se,xe*_e);t.declutter&&(Ee=Ee.slice(0)),e.execute($,[$.canvas.width,$.canvas.height],Ee,A,re,a===void 0?Hl:a?S0:UI,a?R&&t.declutter[R]:void 0)}while(++xe<pe)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Yr(this.context.canvas.width,this.context.canvas.height,_0))}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,WE(this.context),_0.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,t){let a=e.layerStatesArray[e.layerIndex];this.opacity_=a.opacity;let l=e.viewState;this.prepareContainer(e,t);let o=this.context,m=this.replayGroup_,g=m&&!m.isEmpty();if(!g&&!(this.getLayer().hasListener(ds.PRERENDER)||this.getLayer().hasListener(ds.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(o,e);let b=l.projection;if(this.clipped_=!1,g&&a.extent&&this.clipping){let A=ps(a.extent,b);g=ni(A,e.extent),this.clipped_=g&&!Ks(A,e.extent),this.clipped_&&this.clipUnrotated(o,e,A)}return g&&this.renderWorlds(m,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&o.restore(),this.postRender(o,e),this.renderedRotation_!==l.rotation&&(this.renderedRotation_=l.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(t=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let a=this.frameState.size.slice(),l=this.renderedCenter_,o=this.renderedResolution_,m=this.renderedRotation_,g=this.renderedProjection_,b=this.wrappedRenderedExtent_,A=this.getLayer(),S=[],M=a[0]*Xo,R=a[1]*Xo;S.push(this.getRenderTransform(l,o,m,Xo,M,R,0).slice());let j=A.getSource(),W=g.getExtent();if(j.getWrapX()&&g.canWrapX()&&!Ks(W,b)){let $=b[0],X=Fr(W),se=0,me;for(;$<W[0];)--se,me=X*se,S.push(this.getRenderTransform(l,o,m,Xo,M,R,me).slice()),$+=X;for(se=0,$=b[2];$>W[2];)++se,me=X*se,S.push(this.getRenderTransform(l,o,m,Xo,M,R,me).slice()),$-=X}let re=so();this.hitDetectionImageData_=qI(a,S,this.renderedFeatures_,A.getStyleFunction(),b,o,m,E0(o,this.renderedPixelRatio_),re?g:null)}t($I(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,a,l,o){if(!this.replayGroup_)return;let m=t.viewState.resolution,g=t.viewState.rotation,b=this.getLayer(),A={},S=function(W,re,$){let X=Nt(W),se=A[X];if(se){if(se!==!0&&$<se.distanceSq){if($===0)return A[X]=!0,o.splice(o.lastIndexOf(se),1),l(W,b,re);se.geometry=re,se.distanceSq=$}}else{if($===0)return A[X]=!0,l(W,b,re);o.push(A[X]={feature:W,layer:b,geometry:re,distanceSq:$,callback:l})}},M,R=[this.replayGroup_],j=this.getLayer().getDeclutter();return R.some(W=>M=W.forEachFeatureAtCoordinate(e,m,g,a,S,j&&t.declutter[j]?t.declutter[j].all().map(re=>re.value):null)),M}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let t=this.getLayer(),a=t.getSource();if(!a)return!1;let l=e.viewHints[Bn.ANIMATING],o=e.viewHints[Bn.INTERACTING],m=t.getUpdateWhileAnimating(),g=t.getUpdateWhileInteracting();if(this.ready&&!m&&l||!g&&o)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let b=e.extent,A=e.viewState,S=A.projection,M=A.resolution,R=e.pixelRatio,j=t.getRevision(),W=t.getRenderBuffer(),re=t.getRenderOrder();re===void 0&&(re=ZI);let $=A.center.slice(),X=Ln(b,W*M),se=X.slice(),me=[X.slice()],_e=S.getExtent();if(a.getWrapX()&&S.canWrapX()&&!Ks(_e,e.extent)){let et=Fr(_e),ot=Math.max(Fr(X)/2,et);X[0]=_e[0]-ot,X[2]=_e[2]+ot,aE($,S);let gt=xv(me[0],S);gt[0]<_e[0]&>[2]<_e[2]?me.push([gt[0]+et,gt[1],gt[2]+et,gt[3]]):gt[0]>_e[0]&>[2]>_e[2]&&me.push([gt[0]-et,gt[1],gt[2]-et,gt[3]])}if(this.ready&&this.renderedResolution_==M&&this.renderedRevision_==j&&this.renderedRenderOrder_==re&&this.renderedFrameDeclutter_===!!e.declutter&&Ks(this.wrappedRenderedExtent_,X))return Fn(this.renderedExtent_,se)||(this.hitDetectionImageData_=null,this.renderedExtent_=se),this.renderedCenter_=$,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let pe=new DI(I0(M,R),X,M,R),xe=so(),Ee;if(xe){for(let et=0,ot=me.length;et<ot;++et){let gt=me[et],dt=hs(gt,S);a.loadFeatures(dt,dE(M,S),xe)}Ee=wu(xe,S)}else for(let et=0,ot=me.length;et<ot;++et)a.loadFeatures(me[et],M,S);let Me=E0(M,R),Se=!0,ut=(et,ot)=>{let gt,dt=et.getStyleFunction()||t.getStyleFunction();if(dt&&(gt=dt(et,M)),gt){let kt=this.renderFeature(et,Me,gt,pe,Ee,this.getLayer().getDeclutter(),ot);Se=Se&&!kt}},Ue=hs(X,S),$e=a.getFeaturesInExtent(Ue);re&&$e.sort(re);for(let et=0,ot=$e.length;et<ot;++et)ut($e[et],et);this.renderedFeatures_=$e,this.ready=Se;let pt=pe.finish(),Pt=new GI(X,M,R,a.getOverlaps(),pt,t.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=M,this.renderedRevision_=j,this.renderedRenderOrder_=re,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=se,this.wrappedRenderedExtent_=X,this.renderedCenter_=$,this.renderedProjection_=S,this.renderedPixelRatio_=R,this.replayGroup_=Pt,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,t,a,l,o,m,g){if(!a)return!1;let b=!1;if(Array.isArray(a))for(let A=0,S=a.length;A<S;++A)b=P0(l,e,a[A],t,this.boundHandleStyleImageChange_,o,m,g)||b;else b=P0(l,e,a,t,this.boundHandleStyleImageChange_,o,m,g);return b}},XI=T0;var C0=class extends CI{constructor(e){super(e)}createRenderer(){return new XI(this)}},Xl=C0;var YI=Lo(Hx(),1);var M0=class{constructor(e){this.rbush_=new YI.default(e),this.items_={}}insert(e,t){let a={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:t};this.rbush_.insert(a),this.items_[Nt(t)]=a}load(e,t){let a=new Array(t.length);for(let l=0,o=t.length;l<o;l++){let m=e[l],g=t[l],b={minX:m[0],minY:m[1],maxX:m[2],maxY:m[3],value:g};a[l]=b,this.items_[Nt(g)]=b}this.rbush_.load(a)}remove(e){let t=Nt(e),a=this.items_[t];return delete this.items_[t],this.rbush_.remove(a)!==null}update(e,t){let a=this.items_[Nt(t)],l=[a.minX,a.minY,a.maxX,a.maxY];Lm(l,e)||(this.remove(t),this.insert(e,t))}getAll(){return this.rbush_.all().map(function(t){return t.value})}getInExtent(e){let t={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(t).map(function(l){return l.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,t){return this.forEach_(this.getInExtent(e),t)}forEach_(e,t){let a;for(let l=0,o=e.length;l<o;l++)if(a=t(e[l]),a)return a;return a}isEmpty(){return oo(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let t=this.rbush_.toJSON();return Js(t.minX,t.minY,t.maxX,t.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(let t in e.items_)this.items_[t]=e.items_[t]}},Bd=M0;var KI=Ai(),jd=class s{constructor(e,t,a,l,o,m){this.styleFunction,this.extent_,this.id_=m,this.type_=e,this.flatCoordinates_=t,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=a||null,this.properties_=o,this.squaredTolerance_,this.stride_=l,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Ba(this.flatCoordinates_):_u(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=_o(this.getExtent());this.flatInteriorPoints_=md(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=RE(this.flatCoordinates_,this.ends_),t=Hm(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Wm(this.flatCoordinates_,0,e,2,t)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Vl(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let e=this.flatCoordinates_,t=0,a=this.ends_;for(let l=0,o=a.length;l<o;++l){let m=a[l],g=Vl(e,t,m,2,.5);Bi(this.flatMidpoints_,g),t=m}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,t){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=Xr(e);let t=e.getExtent(),a=e.getWorldExtent();if(t&&a){let l=hi(a)/hi(t);cn(KI,a[0],a[3],l,-l,0,0,0),zn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,KI,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new s(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Cm((e,t)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),t&&this.simplifiedGeometry_.applyTransform(t);let a=this.simplifiedGeometry_.getFlatCoordinates(),l;switch(this.type_){case"LineString":a.length=Gl(a,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,a,0),l=[a.length];break;case"MultiLineString":l=[],a.length=Gm(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,a,0,l);break;case"Polygon":l=[],a.length=ud(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),a,0,l);break;default:}return l&&(this.simplifiedGeometry_=new s(this.type_,a,l,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};jd.prototype.getFlatCoordinates=jd.prototype.getOrientedFlatCoordinates;var wo=jd;var R0=class extends Ei{constructor(e){super(),this.projection=Xr(e.projection),this.attributions_=JI(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible!==void 0?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 t=this;this.viewPromise_=new Promise(function(a,l){t.viewResolver=a,t.viewRejector=l})}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_=JI(e),this.changed()}setState(e){this.state_=e,this.changed()}};function JI(s){return s?Array.isArray(s)?function(e){return s}:typeof s=="function"?s:function(e){return[s]}:null}var ua=R0;var pn={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function QI(s,e){return[[-1/0,-1/0,1/0,1/0]]}var wB=!1;function SB(s,e,t,a,l,o,m){let g=new XMLHttpRequest;g.open("GET",typeof s=="function"?s(t,a,l):s,!0),e.getType()=="arraybuffer"&&(g.responseType="arraybuffer"),g.withCredentials=wB,g.onload=function(b){if(!g.status||g.status>=200&&g.status<300){let A=e.getType();try{let S;A=="text"||A=="json"?S=g.responseText:A=="xml"?S=g.responseXML||g.responseText:A=="arraybuffer"&&(S=g.response),S?o(e.readFeatures(S,{extent:t,featureProjection:l}),e.readProjection(S)):m()}catch{m()}}else m()},g.onerror=m,g.send()}function k0(s,e){return function(t,a,l,o,m){let g=this;SB(s,e,t,a,l,function(b,A){g.addFeatures(b),o!==void 0&&o(b)},m||zo)}}var xs=class extends Or{constructor(e,t,a){super(e),this.feature=t,this.features=a}},F0=class extends ua{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_=zo,this.format_=e.format,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&&(xr(this.format_,"`format` must be set when `url` is set"),this.loader_=k0(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:QI;let t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Bd:null,this.loadedExtentsRtree_=new Bd,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let a,l;Array.isArray(e.features)?l=e.features:e.features&&(a=e.features,l=a.getArray()),!t&&a===void 0&&(a=new Sd(l)),l!==void 0&&this.addFeaturesInternal(l),a!==void 0&&this.bindFeaturesCollection_(a)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let t=Nt(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);let a=e.getGeometry();if(a){let l=a.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(l,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new xs(pn.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof wo||(this.featureChangeKeys_[e]=[ji(t,Er.CHANGE,this.handleFeatureChange_,this),ji(t,Im.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let a=!0;if(t.getId()!==void 0){let l=String(t.getId());if(!(l in this.idIndex_))this.idIndex_[l]=t;else if(t instanceof wo){let o=this.idIndex_[l];o instanceof wo?Array.isArray(o)?o.push(t):this.idIndex_[l]=[o,t]:a=!1}else a=!1}return a&&(xr(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),a}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let t=[],a=[],l=[];for(let o=0,m=e.length;o<m;o++){let g=e[o],b=Nt(g);this.addToIndex_(b,g)&&a.push(g)}for(let o=0,m=a.length;o<m;o++){let g=a[o],b=Nt(g);this.setupChangeEvents_(b,g);let A=g.getGeometry();if(A){let S=A.getExtent();t.push(S),l.push(g)}else this.nullGeometryFeatures_[b]=g}if(this.featuresRtree_&&this.featuresRtree_.load(t,l),this.hasListener(pn.ADDFEATURE))for(let o=0,m=a.length;o<m;o++)this.dispatchEvent(new xs(pn.ADDFEATURE,a[o]))}bindFeaturesCollection_(e){let t=!1;this.addEventListener(pn.ADDFEATURE,function(a){t||(t=!0,e.push(a.feature),t=!1)}),this.addEventListener(pn.REMOVEFEATURE,function(a){t||(t=!0,e.remove(a.feature),t=!1)}),e.addEventListener(qo.ADD,a=>{t||(t=!0,this.addFeature(a.element),t=!1)}),e.addEventListener(qo.REMOVE,a=>{t||(t=!0,this.removeFeature(a.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(let a in this.featureChangeKeys_)this.featureChangeKeys_[a].forEach(un);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){let a=l=>{this.removeFeatureInternal(l)};this.featuresRtree_.forEach(a);for(let l in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[l])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let t=new xs(pn.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){let a=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(a,function(l){let o=l.getGeometry();if(o instanceof wo||o.intersectsCoordinate(e))return t(l)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(a){let l=a.getGeometry();if(l instanceof wo||l.intersectsExtent(e)){let o=t(a);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(),oo(this.nullGeometryFeatures_)||Bi(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let t=[];return this.forEachFeatureAtCoordinateDirect(e,function(a){t.push(a)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let l=ZA(e,t);return[].concat(...l.map(o=>this.featuresRtree_.getInExtent(o)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){let a=e[0],l=e[1],o=null,m=[NaN,NaN],g=1/0,b=[-1/0,-1/0,1/0,1/0];return t=t||Tm,this.featuresRtree_.forEachInExtent(b,function(A){if(t(A)){let S=A.getGeometry(),M=g;if(g=S instanceof wo?0:S.closestPointXY(a,l,m,g),g<M){o=A;let R=Math.sqrt(g);b[0]=a-R,b[1]=l-R,b[2]=a+R,b[3]=l+R}}}),o}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){let t=this.idIndex_[e.toString()];return t!==void 0?t:null}getFeatureByUid(e){let t=this.uidIndex_[e];return t!==void 0?t:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){let t=e.target,a=Nt(t),l=t.getGeometry();if(!l)a in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(t),this.nullGeometryFeatures_[a]=t);else{let m=l.getExtent();a in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[a],this.featuresRtree_&&this.featuresRtree_.insert(m,t)):this.featuresRtree_&&this.featuresRtree_.update(m,t)}let o=t.getId();if(o!==void 0){let m=o.toString();this.idIndex_[m]!==t&&(this.removeFromIdIndex_(t),this.idIndex_[m]=t)}else this.removeFromIdIndex_(t),this.uidIndex_[a]=t;this.changed(),this.dispatchEvent(new xs(pn.CHANGEFEATURE,t))}hasFeature(e){let t=e.getId();return t!==void 0?t in this.idIndex_:Nt(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&oo(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,t,a){let l=this.loadedExtentsRtree_,o=this.strategy_(e,t,a);for(let m=0,g=o.length;m<g;++m){let b=o[m];l.forEachInExtent(b,function(S){return Ks(S.extent,b)})||(++this.loadingExtentsCount_,this.dispatchEvent(new xs(pn.FEATURESLOADSTART)),this.loader_.call(this,b,t,a,S=>{--this.loadingExtentsCount_,this.dispatchEvent(new xs(pn.FEATURESLOADEND,void 0,S))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new xs(pn.FEATURESLOADERROR))}),l.insert(b,{extent:b.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){let t=this.loadedExtentsRtree_,a;t.forEachInExtent(e,function(l){if(Lm(l.extent,e))return a=l,!0}),a&&t.remove(a)}removeFeatures(e){let t=[];for(let a=0,l=e.length;a<l;++a){let o=e[a],m=this.removeFeatureInternal(o);m&&t.push(m)}t.length>0&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){let t=Nt(e);if(!(t in this.uidIndex_))return;t in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[t]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[t]?.forEach(un),delete this.featureChangeKeys_[t];let l=e.getId();if(l!==void 0){let o=l.toString(),m=this.idIndex_[o];m===e?delete this.idIndex_[o]:Array.isArray(m)&&(m.splice(m.indexOf(e),1),m.length===1&&(this.idIndex_[o]=m[0]))}return delete this.uidIndex_[t],this.hasListener(pn.REMOVEFEATURE)&&this.dispatchEvent(new xs(pn.REMOVEFEATURE,e)),e}removeFromIdIndex_(e){let t=!1;for(let a in this.idIndex_){let l=this.idIndex_[a];if(e instanceof wo&&Array.isArray(l)&&l.includes(e))l.splice(l.indexOf(e),1);else if(this.idIndex_[a]===e){delete this.idIndex_[a],t=!0;break}}return t}setLoader(e){this.loader_=e}setUrl(e){xr(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(k0(e,this.format_))}},Yl=F0;var ao={SINGLECLICK:"singleclick",CLICK:Er.CLICK,DBLCLICK:Er.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var L0={ACTIVE:"active"};var D0=class extends Ei{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(L0.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(L0.ACTIVE,e)}setMap(e){this.map_=e}};var e2=D0;var O0=class extends e2{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 t=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==ao.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==ao.POINTERUP){let a=this.handleUpEvent(e);this.handlingDownUpSequence=a&&this.targetPointers.length>0}}else if(e.type==ao.POINTERDOWN){let a=this.handleDownEvent(e);this.handlingDownUpSequence=a,t=this.stopDown(a)}else e.type==ao.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};var t2=O0;var r2=function(s){let e=s.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var i2=Tm,n2=function(s){return s.type==ao.CLICK};var o2=function(s){return s.type==ao.SINGLECLICK};var s2=function(s){let e=s.originalEvent;return xr(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var a2=0,Nd=1,l2=[0,0,0,0],Ou=[],z0={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},Ud=class extends Or{constructor(e,t,a){super(e),this.features=t,this.mapBrowserEvent=a}},B0=class extends t2{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:s2,this.defaultDeleteCondition_=function(a){return r2(a)&&o2(a)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:i2,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Bd,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Xl({source:new Yl({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:EB(),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 t;if(e.features?t=e.features:e.source&&(this.source_=e.source,t=new Sd(this.source_.getFeatures()),this.source_.addEventListener(pn.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(pn.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!t)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=t,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(qo.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(qo.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 t=e.getGeometry();if(t){let l=this.SEGMENT_WRITERS_[t.getType()];l&&l(e,t)}let a=this.getMap();a&&a.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastPixel_,a),e.addEventListener(Er.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Sd;let a=this.featuresBeingModified_.getArray();for(let l=0,o=t.length;l<o;++l){let m=t[l];for(let g=0,b=m.length;g<b;++g){let A=m[g].feature;A&&!a.includes(A)&&this.featuresBeingModified_.push(A)}}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new Ud(z0.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(Er.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){let t=this.rBush_,a=[];t.forEach(function(l){e===l.feature&&a.push(l)});for(let l=a.length-1;l>=0;--l){let o=a[l];for(let m=this.dragSegments_.length-1;m>=0;--m)this.dragSegments_[m][0]===o&&this.dragSegments_.splice(m,1);t.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 t=e.target;this.removeFeature_(t),this.addFeature_(t)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,t){let a=t.getCoordinates(),l={feature:e,geometry:t,segment:[a,a]};this.rBush_.insert(t.getExtent(),l)}writeMultiPointGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length;l<o;++l){let m=a[l],g={feature:e,geometry:t,depth:[l],index:l,segment:[m,m]};this.rBush_.insert(t.getExtent(),g)}}writeLineStringGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length-1;l<o;++l){let m=a.slice(l,l+2),g={feature:e,geometry:t,index:l,segment:m};this.rBush_.insert(us(m),g)}}writeMultiLineStringGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length;l<o;++l){let m=a[l];for(let g=0,b=m.length-1;g<b;++g){let A=m.slice(g,g+2),S={feature:e,geometry:t,depth:[l],index:g,segment:A};this.rBush_.insert(us(A),S)}}}writePolygonGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length;l<o;++l){let m=a[l];for(let g=0,b=m.length-1;g<b;++g){let A=m.slice(g,g+2),S={feature:e,geometry:t,depth:[l],index:g,segment:A};this.rBush_.insert(us(A),S)}}}writeMultiPolygonGeometry_(e,t){let a=t.getCoordinates();for(let l=0,o=a.length;l<o;++l){let m=a[l];for(let g=0,b=m.length;g<b;++g){let A=m[g];for(let S=0,M=A.length-1;S<M;++S){let R=A.slice(S,S+2),j={feature:e,geometry:t,depth:[g,l],index:S,segment:R};this.rBush_.insert(us(R),j)}}}}writeCircleGeometry_(e,t){let a=t.getCenter(),l={feature:e,geometry:t,index:a2,segment:[a,a]},o={feature:e,geometry:t,index:Nd,segment:[a,a]},m=[l,o];l.featureSegments=m,o.featureSegments=m,this.rBush_.insert(Ba(a),l);let g=t,b=so();if(b&&this.getMap()){let A=this.getMap().getView().getProjection();g=g.clone().transform(b,A),g=Zv(g).transform(A,b)}this.rBush_.insert(g.getExtent(),o)}writeGeometryCollectionGeometry_(e,t){let a=t.getGeometriesArray();for(let l=0;l<a.length;++l){let o=a[l],m=this.SEGMENT_WRITERS_[o.getType()];m(e,o)}}createOrUpdateVertexFeature_(e,t,a){let l=this.vertexFeature_;return l?l.getGeometry().setCoordinates(e):(l=new bo(new Pi(e)),this.vertexFeature_=l,this.overlay_.getSource().addFeature(l)),l.set("features",t),l.set("geometries",a),l}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let t;return!e.map.getView().getInteracting()&&e.type==ao.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=ao.SINGLECLICK||!this.ignoreNextSingleClick_?t=this.removePoint():t=!0),e.type==ao.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!t}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_);let t=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],a=[],l=[];for(let o=0,m=this.dragSegments_.length;o<m;++o){let g=this.dragSegments_[o],b=g[0],A=b.feature;a.includes(A)||a.push(A);let S=b.geometry;l.includes(S)||l.push(S);let M=b.depth,R,j=b.segment,W=g[1];for(;t.length<S.getStride();)t.push(j[W][t.length]);switch(S.getType()){case"Point":R=t,j[0]=t,j[1]=t;break;case"MultiPoint":R=S.getCoordinates(),R[b.index]=t,j[0]=t,j[1]=t;break;case"LineString":R=S.getCoordinates(),R[b.index+W]=t,j[W]=t;break;case"MultiLineString":R=S.getCoordinates(),R[M[0]][b.index+W]=t,j[W]=t;break;case"Polygon":R=S.getCoordinates(),R[M[0]][b.index+W]=t,j[W]=t;break;case"MultiPolygon":R=S.getCoordinates(),R[M[1]][M[0]][b.index+W]=t,j[W]=t;break;case"Circle":if(j[0]=t,j[1]=t,b.index===a2)this.changingFeature_=!0,S.setCenter(t),this.changingFeature_=!1;else{this.changingFeature_=!0;let re=e.map.getView().getProjection(),$=Iv(oi(S.getCenter(),re),oi(t,re)),X=so();if(X){let se=S.clone().transform(X,re);se.setRadius($),$=se.transform(re,X).getRadius()}S.setRadius($),this.changingFeature_=!1}break;default:}R&&this.setGeometryCoordinates_(S,R)}this.createOrUpdateVertexFeature_(t,a,l)}handleDownEvent(e){if(!this.condition_(e))return!1;let t=e.coordinate;this.handlePointerAtPixel_(e.pixel,e.map,t),this.dragSegments_.length=0,this.featuresBeingModified_=null;let a=this.vertexFeature_;if(a){let l=e.map.getView().getProjection(),o=[],m=a.getGeometry().getCoordinates(),g=us([m]),b=this.rBush_.getInExtent(g),A={};b.sort(AB);for(let S=0,M=b.length;S<M;++S){let R=b[S],j=R.segment,W=Nt(R.geometry),re=R.depth;if(re&&(W+="-"+re.join("-")),A[W]||(A[W]=new Array(2)),R.geometry.getType()==="Circle"&&R.index===Nd){let $=u2(t,R,l);Sn($,m)&&!A[W][0]&&(this.dragSegments_.push([R,0]),A[W][0]=R);continue}if(Sn(j[0],m)&&!A[W][0]){this.dragSegments_.push([R,0]),A[W][0]=R;continue}if(Sn(j[1],m)&&!A[W][1]){if(A[W][0]&&A[W][0].index===0){let $=R.geometry.getCoordinates();switch(R.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":$=$[re[1]];case"Polygon":if(R.index!==$[re[0]].length-2)continue;break;default:}}this.dragSegments_.push([R,1]),A[W][1]=R;continue}Nt(j)in this.vertexSegments_&&!A[W][0]&&!A[W][1]&&this.insertVertexCondition_(e)&&o.push(R)}o.length&&this.willModifyFeatures_(e,[o]);for(let S=o.length-1;S>=0;--S)this.insertVertex_(o[S],m)}return!!this.vertexFeature_}handleUpEvent(e){for(let t=this.dragSegments_.length-1;t>=0;--t){let a=this.dragSegments_[t][0],l=a.geometry;if(l.getType()==="Circle"){let o=l.getCenter(),m=a.featureSegments[0],g=a.featureSegments[1];m.segment[0]=o,m.segment[1]=o,g.segment[0]=o,g.segment[1]=o,this.rBush_.update(Ba(o),m);let b=l,A=so();if(A){let S=e.map.getView().getProjection();b=b.clone().transform(A,S),b=Zv(b).transform(S,A)}this.rBush_.update(b.getExtent(),g)}else this.rBush_.update(us(a.segment),a)}return this.featuresBeingModified_&&(this.dispatchEvent(new Ud(z0.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastPixel_=e.pixel,this.handlePointerAtPixel_(e.pixel,e.map,e.coordinate)}handlePointerAtPixel_(e,t,a){let l=a||t.getCoordinateFromPixel(e),o=t.getView().getProjection(),m=function(A,S){return c2(l,A,o)-c2(l,S,o)},g,b;if(this.hitDetection_){let A=typeof this.hitDetection_=="object"?S=>S===this.hitDetection_:void 0;t.forEachFeatureAtPixel(e,(S,M,R)=>{R&&R.getType()==="Point"&&(R=new Pi(Nl(R.getCoordinates(),o)));let j=R||S.getGeometry();if(S instanceof bo&&this.features_.getArray().includes(S)){b=j;let W=S.getGeometry().getFlatCoordinates().slice(0,2);g=[{feature:S,geometry:b,segment:[W,W]}]}return!0},{layerFilter:A})}if(!g){let A=ps(Ba(l,l2),o),S=t.getView().getResolution()*this.pixelTolerance_,M=hs(Ln(A,S,l2),o);g=this.rBush_.getInExtent(M)}if(g&&g.length>0){let A=g.sort(m)[0],S=A.segment,M=u2(l,A,o),R=t.getPixelFromCoordinate(M),j=Iv(e,R);if(b||j<=this.pixelTolerance_){let W={};if(W[Nt(S)]=!0,this.snapToPointer_||(this.delta_[0]=M[0]-l[0],this.delta_[1]=M[1]-l[1]),A.geometry.getType()==="Circle"&&A.index===Nd)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(M,[A.feature],[A.geometry]);else{let re=t.getPixelFromCoordinate(S[0]),$=t.getPixelFromCoordinate(S[1]),X=bu(R,re),se=bu(R,$);j=Math.sqrt(Math.min(X,se)),this.snappedToVertex_=j<=this.pixelTolerance_,this.snappedToVertex_&&(M=X>se?S[1]:S[0]),this.createOrUpdateVertexFeature_(M,[A.feature],[A.geometry]);let me={};me[Nt(A.geometry)]=!0;for(let _e=1,pe=g.length;_e<pe;++_e){let xe=g[_e].segment;if(Sn(S[0],xe[0])&&Sn(S[1],xe[1])||Sn(S[0],xe[1])&&Sn(S[1],xe[0])){let Ee=Nt(g[_e].geometry);Ee in me||(me[Ee]=!0,W[Nt(xe)]=!0)}else break}}this.vertexSegments_=W;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,t){let a=e.segment,l=e.feature,o=e.geometry,m=e.depth,g=e.index,b;for(;t.length<o.getStride();)t.push(0);switch(o.getType()){case"MultiLineString":b=o.getCoordinates(),b[m[0]].splice(g+1,0,t);break;case"Polygon":b=o.getCoordinates(),b[m[0]].splice(g+1,0,t);break;case"MultiPolygon":b=o.getCoordinates(),b[m[1]][m[0]].splice(g+1,0,t);break;case"LineString":b=o.getCoordinates(),b.splice(g+1,0,t);break;default:return}this.setGeometryCoordinates_(o,b);let A=this.rBush_;A.remove(e),this.updateSegmentIndices_(o,g,m,1);let S={segment:[a[0],t],feature:l,geometry:o,depth:m,index:g};A.insert(us(S.segment),S),this.dragSegments_.push([S,1]);let M={segment:[t,a[1]],feature:l,geometry:o,depth:m,index:g+1};A.insert(us(M.segment),M),this.dragSegments_.push([M,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=ao.POINTERDRAG){let e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_);let t=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Ud(z0.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null,t}return!1}removeVertex_(){let e=this.dragSegments_,t={},a=!1,l,o,m,g,b,A,S,M,R,j,W;for(b=e.length-1;b>=0;--b)m=e[b],j=m[0],W=Nt(j.feature),j.depth&&(W+="-"+j.depth.join("-")),W in t||(t[W]={}),m[1]===0?(t[W].right=j,t[W].index=j.index):m[1]==1&&(t[W].left=j,t[W].index=j.index+1);for(W in t){switch(R=t[W].right,S=t[W].left,A=t[W].index,M=A-1,S!==void 0?j=S:j=R,M<0&&(M=0),g=j.geometry,o=g.getCoordinates(),l=o,a=!1,g.getType()){case"MultiLineString":o[j.depth[0]].length>2&&(o[j.depth[0]].splice(A,1),a=!0);break;case"LineString":o.length>2&&(o.splice(A,1),a=!0);break;case"MultiPolygon":l=l[j.depth[1]];case"Polygon":l=l[j.depth[0]],l.length>4&&(A==l.length-1&&(A=0),l.splice(A,1),a=!0,A===0&&(l.pop(),l.push(l[0]),M=l.length-1));break;default:}if(a){this.setGeometryCoordinates_(g,o);let re=[];if(S!==void 0&&(this.rBush_.remove(S),re.push(S.segment[0])),R!==void 0&&(this.rBush_.remove(R),re.push(R.segment[1])),S!==void 0&&R!==void 0){let $={depth:j.depth,feature:j.feature,geometry:j.geometry,index:M,segment:re};this.rBush_.insert(us($.segment),$)}this.updateSegmentIndices_(g,A,j.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return a}setGeometryCoordinates_(e,t){this.changingFeature_=!0,e.setCoordinates(t),this.changingFeature_=!1}updateSegmentIndices_(e,t,a,l){this.rBush_.forEachInExtent(e.getExtent(),function(o){o.geometry===e&&(a===void 0||o.depth===void 0||Fn(o.depth,a))&&o.index>t&&(o.index+=l)})}};function AB(s,e){return s.index-e.index}function c2(s,e,t){let a=e.geometry;if(a.getType()==="Circle"){let o=a;if(e.index===Nd){let m=so();m&&(o=o.clone().transform(m,t));let g=bu(o.getCenter(),oi(s,t)),b=Math.sqrt(g)-o.getRadius();return b*b}}let l=oi(s,t);return Ou[0]=oi(e.segment[0],t),Ou[1]=oi(e.segment[1],t),sE(l,Ou)}function u2(s,e,t){let a=e.geometry;if(a.getType()==="Circle"&&e.index===Nd){let o=a,m=so();return m&&(o=o.clone().transform(m,t)),Nl(o.getClosestPoint(oi(s,t)),t)}let l=oi(s,t);return Ou[0]=oi(e.segment[0],t),Ou[1]=oi(e.segment[1],t),Nl(Ev(l,Ou),t)}function EB(){let s=fI();return function(e,t){return s.Point}}var j0=B0;var N0=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=bo,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let a=t.dataProjection?Xr(t.dataProjection):this.readProjection(e);t.extent&&a&&a.getUnits()==="tile-pixels"&&(a=Xr(a),a.setWorldExtent(t.extent)),t={dataProjection:a,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return It()}readFeature(e,t){return It()}readFeatures(e,t){return It()}readGeometry(e,t){return It()}readProjection(e){return It()}writeFeature(e,t){return It()}writeFeatures(e,t){return It()}writeGeometry(e,t){return It()}},h2=N0;function mg(s,e,t){let a=t?Xr(t.featureProjection):null,l=t?Xr(t.dataProjection):null,o=s;if(a&&l&&!pE(a,l)){e&&(o=s.clone());let m=e?a:l,g=e?l:a;m.getUnits()==="tile-pixels"?o.transform(m,g):o.applyTransform(jl(m,g))}if(e&&t&&t.decimals!==void 0){let m=Math.pow(10,t.decimals),g=function(b){for(let A=0,S=b.length;A<S;++A)b[A]=Math.round(b[A]*m)/m;return b};o===s&&(o=s.clone()),o.applyTransform(g)}return o}var IB={Point:Pi,LineString:No,Polygon:Au,MultiPoint:fd,MultiLineString:Gv,MultiPolygon:Xv};function PB(s,e,t){return Array.isArray(e[0])?(Zm(s,0,e,t)||(s=s.slice(),yd(s,0,e,t)),s):(gd(s,0,e,t)||(s=s.slice(),Su(s,0,e,t)),s)}function U0(s,e){let t=s.geometry;if(!t)return[];if(Array.isArray(t))return t.map(o=>U0({...s,geometry:o})).flat();let a=t.type==="MultiPolygon"?"Polygon":t.type;if(a==="GeometryCollection"||a==="Circle")throw new Error("Unsupported geometry type: "+a);let l=t.layout.length;return mg(new wo(a,a==="Polygon"?PB(t.flatCoordinates,t.ends,l):t.flatCoordinates,t.ends?.flat(),l,s.properties||{},s.id).enableSimplifyTransformed(),!1,e)}function gg(s,e){if(!s)return null;if(Array.isArray(s)){let a=s.map(l=>gg(l,e));return new Lv(a)}let t=IB[s.type];return mg(new t(s.flatCoordinates,s.layout,s.ends),!1,e)}var G0=class extends h2{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(yg(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(yg(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return It()}readFeaturesFromObject(e,t){return It()}readGeometry(e,t){return this.readGeometryFromObject(yg(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return It()}readProjection(e){return this.readProjectionFromObject(yg(e))}readProjectionFromObject(e){return It()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return It()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return It()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return It()}};function yg(s){if(typeof s=="string"){let e=JSON.parse(s);return e||null}return s!==null?s:null}var p2=G0;var V0=class extends p2{constructor(e){e=e||{},super(),this.dataProjection=Xr(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=Xr(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,t){let a=null;e.type==="Feature"?a=e:a={type:"Feature",geometry:e,properties:null};let l=$0(a.geometry,t);if(this.featureClass===wo)return U0({geometry:l,id:a.id,properties:a.properties},t);let o=new bo;return this.geometryName_?o.setGeometryName(this.geometryName_):this.extractGeometryName_&&a.geometry_name&&o.setGeometryName(a.geometry_name),o.setGeometry(gg(l,t)),"id"in a&&o.setId(a.id),a.properties&&o.setProperties(a.properties,!0),o}readFeaturesFromObject(e,t){let a=e,l=null;if(a.type==="FeatureCollection"){let o=e;l=[];let m=o.features;for(let g=0,b=m.length;g<b;++g){let A=this.readFeatureFromObject(m[g],t);A&&l.push(A)}}else l=[this.readFeatureFromObject(e,t)];return l.flat()}readGeometryFromObject(e,t){return TB(e,t)}readProjectionFromObject(e){let t=e.crs,a;if(t)if(t.type=="name")a=Xr(t.properties.name);else if(t.type==="EPSG")a=Xr("EPSG:"+t.properties.code);else throw new Error("Unknown SRS type");else a=this.dataProjection;return a}writeFeatureObject(e,t){t=this.adaptOptions(t);let a={type:"Feature",geometry:null,properties:null},l=e.getId();if(l!==void 0&&(a.id=l),!e.hasProperties())return a;let o=e.getProperties(),m=e.getGeometry();return m&&(a.geometry=q0(m,t),delete o[e.getGeometryName()]),oo(o)||(a.properties=o),a}writeFeaturesObject(e,t){t=this.adaptOptions(t);let a=[];for(let l=0,o=e.length;l<o;++l)a.push(this.writeFeatureObject(e[l],t));return{type:"FeatureCollection",features:a}}writeGeometryObject(e,t){return q0(e,this.adaptOptions(t))}};function $0(s,e){if(!s)return null;let t;switch(s.type){case"Point":{t=MB(s);break}case"LineString":{t=RB(s);break}case"Polygon":{t=DB(s);break}case"MultiPoint":{t=FB(s);break}case"MultiLineString":{t=kB(s);break}case"MultiPolygon":{t=LB(s);break}case"GeometryCollection":{t=CB(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return t}function TB(s,e){let t=$0(s,e);return gg(t,e)}function CB(s,e){return s.geometries.map(function(a){return $0(a,e)})}function MB(s){let e=s.coordinates;return{type:"Point",flatCoordinates:e,layout:Na(e.length)}}function RB(s){let e=s.coordinates,t=e.flat();return{type:"LineString",flatCoordinates:t,ends:[t.length],layout:Na(e[0]?.length||2)}}function kB(s){let e=s.coordinates,t=e[0]?.[0]?.length||2,a=[],l=Ua(a,0,e,t);return{type:"MultiLineString",flatCoordinates:a,ends:l,layout:Na(t)}}function FB(s){let e=s.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:Na(e[0]?.length||2)}}function LB(s){let e=s.coordinates,t=[],a=e[0]?.[0]?.[0].length||2,l=Um(t,0,e,a);return{type:"MultiPolygon",flatCoordinates:t,ends:l,layout:Na(a)}}function DB(s){let e=s.coordinates,t=[],a=e[0]?.[0]?.length,l=Ua(t,0,e,a);return{type:"Polygon",flatCoordinates:t,ends:l,layout:Na(a)}}function q0(s,e){s=mg(s,!0,e);let t=s.getType(),a;switch(t){case"Point":{a=UB(s,e);break}case"LineString":{a=zB(s,e);break}case"Polygon":{a=GB(s,e);break}case"MultiPoint":{a=jB(s,e);break}case"MultiLineString":{a=BB(s,e);break}case"MultiPolygon":{a=NB(s,e);break}case"GeometryCollection":{a=OB(s,e);break}case"Circle":{a={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+t)}return a}function OB(s,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(a){return q0(a,e)})}}function zB(s,e){return{type:"LineString",coordinates:s.getCoordinates()}}function BB(s,e){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function jB(s,e){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function NB(s,e){let t;return e&&(t=e.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(t)}}function UB(s,e){return{type:"Point",coordinates:s.getCoordinates()}}function GB(s,e){let t;return e&&(t=e.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(t)}}var Ti=V0;var VB=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,d2=/^([\d.]+),([\d.]+)$/,f2=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,_g="stop-fetch",m2=s=>{let e=[];return s.forEach(t=>{let a=t.getGeometry()?.getCoordinates();a?.length&&e.push(...a)}),e},W0=class s extends Tu{constructor(t={}){super(t);this.viaPoints=[];this.graphs=[];this.useRawViaPoints=!1;this.snapToClosestStation=!1;this.cacheStationData={};this.abortControllers={};this.segments=[];this.format=new Ti({featureProjection:"EPSG:3857"});this.initialRouteDrag={};this.element||this.createDefaultElement(),this.loading=!1,this.active=t.active||!0,this.graphs=t.graphs||[["osm",0,99]],this.mot=t.mot||"bus",this.modify=t.modify!==!1,this.routingApiParams=t.routingApiParams,this.useRawViaPoints=t.useRawViaPoints||!1,this.snapToClosestStation=t.snapToClosestStation||!1,this.apiKey=t.apiKey,this.stopsApiKey=t.stopsApiKey||this.apiKey,this.stopsApiUrl=t.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new Xp({...t}),this.routingLayer=t.routingLayer||new Xl({source:new Yl,style:t.style}),this.onRouteError=t.onRouteError||(a=>{this.dispatchEvent(new Or("change:route")),this.reset(),console.error(a)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",a=>{a.key==="active"&&this.onActiveChange(),a.key==="mot"&&this.viaPoints&&this.drawRoute()})}get active(){return this.get("active")}set active(t){this.set("active",t)}get loading(){return this.get("loading")}set loading(t){this.set("loading",t)}get modify(){return this.get("modify")}set modify(t){this.set("modify",t)}get mot(){return this.get("mot")}set mot(t){this.set("mot",t)}static getGraphsResolutions(t,a){let l=a.getView();return t.map(([,o,m])=>[l.getResolutionForZoom(o),l.getResolutionForZoom(m||o+1)])}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}addViaPoint(t,a=-1,l=0){this.viaPoints.splice(a===-1?this.viaPoints.length:a,l,t),this.drawRoute(),this.dispatchEvent(new Or("change:route"))}removeViaPoint(t=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[t]&&this.viaPoints.splice(t,1),this.drawRoute(),this.dispatchEvent(new Or("change:route"))}setViaPoints(t){this.viaPoints=[...t],this.drawRoute(),this.dispatchEvent(new Or("change:route"))}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new Or("change:route"))}abortRequests(){this.graphs.forEach(t=>{let a=t[0];this.abortControllers[a]&&this.abortControllers[a].abort(),this.abortControllers[a]=new AbortController}),this.abortControllers[_g]?.abort(),this.abortControllers[_g]=new AbortController,this.loading=!1}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[_g]);let t=this.viaPoints.map(a=>{if(Array.isArray(a)){let l=this.getMap()?.getView().getProjection(),[o,m]=Bl(a,l);return this.snapToClosestStation?[`@${m}`,o]:[m,o]}return this.useRawViaPoints?a:`!${a}`});return this.loading=!0,this.viaPoints.forEach((a,l)=>this.drawViaPoint(a,l,this.abortControllers[_g])),Promise.all(this.graphs.map(([a],l)=>{let{signal:o}=this.abortControllers[a];return this.api?this.api.route({graph:a,via:`${t.join("|")}`,mot:this.mot,"resolve-hops":!1,elevation:!1,"coord-radius":100,"coord-punish":1e3,...this.routingApiParams||{}},{signal:o}).then(m=>{if(this.segments=this.format.readFeatures(m),this.mot==="foot"){let A=this.segments.reduce((S,M)=>{let R=M.get("trg");return S.find(j=>j[0]===R[0]&&j[1]===R[1])?S:[...S,R]},[]);this.segments=A.map(S=>{let M=this.segments.filter(j=>{let W=j.get("trg");return W[0]===S[0]&&W[1]===S[1]}),R=m2(M);return new bo({geometry:new No(R)})})}let g=m2(this.segments),b=new bo({geometry:new No(g)});b.set("graph",a),b.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[l]?.length>=2&&(b.set("minResolution",this.graphsResolutions[l][0]),b.set("maxResolution",this.graphsResolutions[l][1])),this.routingLayer?.getSource()?.addFeature(b),this.loading=!1}).catch(m=>{/AbortError/.test(m.message)||(this.segments=[],this.dispatchEvent(new Or("error")),this.onRouteError(m,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(t,a,l){let o=new bo;if(o.set("viaPointIdx",a),Array.isArray(t))return o.setGeometry(new Pi(t)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o);if(!this.useRawViaPoints||f2.test(t)){let S,M;return this.useRawViaPoints?[,S,,M]=f2.exec(t)||[]:[S,M]=t.split("$"),fetch(`${this.stopsApiUrl}lookup/${S}?key=${this.stopsApiKey}`,{signal:l.signal}).then(R=>R.json()).then(R=>{let{coordinates:j}=R.features[0].geometry;return this.cacheStationData[t]=Ii(j),o.set("viaPointTrack",M),o.setGeometry(new Pi(Ii(j))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(R=>{/AbortError/.test(R.message)||(this.dispatchEvent(new Or("error")),this.onRouteError(R,this),this.loading=!1)})}if(this.useRawViaPoints&&d2.test(t)){let[S,M]=d2.exec(t)||[];if(M&&S){let R=parseFloat(M),j=parseFloat(S),W=Ii([R,j],this.getMap()?.getView().getProjection());return o.setGeometry(new Pi(W)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}}let[,m,,g,b,,A]=VB.exec(t)||[];if(b&&g){let S=Ii([parseFloat(b),parseFloat(g)],this.getMap()?.getView().getProjection());return o.set("viaPointTrack",A),o.setGeometry(new Pi(S)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}return m?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${m}&limit=1`,{signal:l.signal}).then(S=>S.json()).then(S=>{let{coordinates:M}=S.features[0].geometry;return this.cacheStationData[t]=Ii(M),o.set("viaPointTrack",A),o.setGeometry(new Pi(Ii(M))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(S=>(this.dispatchEvent(new Or("error")),this.onRouteError(S,this),this.loading=!1,null)):Promise.resolve(null)}onMapClick(t){let l=t.target.getFeaturesAtPixel(t.pixel,{layerFilter:o=>o===this.routingLayer,hitTolerance:5}).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("viaPointIdx")!==void 0);if(l){this.removeViaPoint(l.get("viaPointIdx"));return}this.addViaPoint(t.coordinate)}onModifyStart(t){let a=-1,l=t.features.getArray().find(m=>m.getGeometry()?.getType()==="LineString");if(l&&l.getGeometry()&&t.mapBrowserEvent.coordinate){let m=Ln(new Pi(l.getGeometry()?.getClosestPoint(t.mapBrowserEvent.coordinate)).getExtent(),.001);a=this.segments.findIndex(g=>g.getGeometry()?.intersectsExtent(m))}let o=(t.features.getArray().filter(m=>m.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={viaPoint:o,oldRoute:l&&l.clone(),segmentIndex:a}}onModifyEnd(t){let a=t.mapBrowserEvent.coordinate,{oldRoute:l,viaPoint:o,segmentIndex:m}=this.initialRouteDrag||{};return o?this.addViaPoint(a,o.get("viaPointIdx"),1):l?m===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(a,(m||0)+1):this.addViaPoint(a,0,1)}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 j0({source:this.routingLayer?.getSource()||void 0,pixelTolerance:6,deleteCondition:t=>{let l=(t.target?.getFeaturesAtPixel(t.pixel,{hitTolerance:5})).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("index"));return n2(t)&&l?(this.removeViaPoint(l.get("index")),!0):!1}}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}removeListeners(){this.onMapClickKey&&Ol(this.onMapClickKey)}setMap(t){super.setMap(t),t&&this.active?this.activate():t||(this.active=!1)}activate(){let t=this.getMap();t&&(this.format=new Ti({featureProjection:t.getView().getProjection()}),this.graphsResolutions=s.getGraphsResolutions(this.graphs,t),this.modifyInteraction&&t.removeInteraction(this.modifyInteraction),this.modifyInteraction&&t.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}deactivate(){let t=this.getMap();t&&(this.modifyInteraction&&t.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}render(){}},g2=W0;var Z0=class{constructor(e){let{apiParams:t,apiKey:a,url:l,placeholder:o}=e||{};this.apiParams={limit:20,...t||{}},this.placeholder=o||"Search for a stop...";let m={apiKey:a};l&&(m.url=l),this.api=new Yp(m),this.abortController=new AbortController,this.createElement(e),this.options=e}render(e){let t=e?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=t.length?"block":"none",this.suggestionsElt.innerHTML="",t.forEach(a=>{let l=document.createElement("div");l.innerHTML=a?.properties?.name,l.onclick=o=>{this.options?.onSuggestionClick?.(a,o)},Object.assign(l.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(l)}))}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=t=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(t.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",overflowY:"auto",cursor:"pointer"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{display:"none",position:"absolute",right:"0",padding:"0 10px",fontSize:"200%",cursor:"pointer"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}search(e,t){return(e!==void 0||e!==null)&&(this.apiParams.q=e),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,t&&{signal:t.signal}).then(a=>{this.render(a)}).catch(()=>{this.render()})}},y2=Z0;var qB=()=>{let s=document.createElement("div");return Object.assign(s.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),s},_2=qB;var H0=class extends Tu{constructor(e){let t=_2();t.className=e?.className||"mbt-stop-finder";let a={element:t,...e||{}};super(a),this.controller=new y2({onSuggestionClick:this.onSuggestionClick.bind(this),...a})}onSuggestionClick(e){let t=Ii(e.geometry.coordinates);this.getMap()?.getView().setCenter(t)}search(e,t){return this.controller.search(e,t)}},v2=H0;var T2=Lo(Gd());var A2=Lo(Q0(),1);var l3="vectorTileFeature",eb={"EPSG:3857":new Ti({featureProjection:"EPSG:3857"})},zu=class extends Fu{getFeaturesAtCoordinate(e,t=5){let a=this.getMapLibrePixels(e,t);if(!a)return[];let l=this.getLayer().get("queryRenderedFeaturesOptions")||{};return this.getLayer().mapLibreMap?.queryRenderedFeatures(a,l).map(m=>this.toOlFeature(m))||[]}prepareFrame(){return!0}renderFrame(e){let t=this.getLayer(),{mapLibreMap:a}=t,l=t.getMapInternal();if(!t||!l||!a)return null;let o=a.getCanvas(),{viewState:m}=e;a.jumpTo({center:Bl(m.center),zoom:m.zoom-1,bearing:tE(-m.rotation)});let g=t.getOpacity().toString();return o&&g!==o.style.opacity&&(o.style.opacity=g),o.isConnected?c3(o,e)||a.resize():l.render(),a.redraw(),a.getContainer()}getFeatures(e){let t=this.getLayer().getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(t))}forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{let g=m.getGeometry();g instanceof Ui&&l(m,this.layer_,g)}),o?.[0]}getMapLibrePixels(e,t){if(!e)return;let a=this.getLayer().mapLibreMap?.project(Bl(e));if(a?.x===void 0||a?.y===void 0)return;let l=[a.x,a.y];if(t){let[o,m]=l;l=[[o-t,m-t],[o+t,m+t]]}return l}toOlFeature(e){let l=this.getLayer().getMapInternal()?.getView()?.getProjection()?.getCode()||"EPSG:3857";eb[l]||(eb[l]=new Ti({featureProjection:l}));let o=eb[l].readFeature(e);return o&&o.set(l3,e,!0),o}};function c3(s,e){return s.width===Math.floor(e.size[0]*e.pixelRatio)&&s.height===Math.floor(e.size[1]*e.pixelRatio)}var u3=s=>{if(!s)return[];let{style:e}=s;if(!e)return[];let{sourceCaches:t}=e,a=[];return Object.values(t).forEach(l=>{if(l.used){let{attribution:o}=l.getSource();o&&(a=a.concat(o.replace(/©/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),h3(a)},h3=s=>{let e=s.filter(l=>l!=null&&l.trim&&l.trim()),t=e.map(l=>l.toLowerCase());return[...new Set(t)].map(l=>e.find(o=>o.toLowerCase()===l))},tb=u3;var Bu=class extends Vo{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(e){super({source:new ua({attributions:()=>tb(this.mapLibreMap)}),...e})}disposeInternal(){Ol(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 t=document.createElement("div");t.style.position="absolute",t.style.width="100%",t.style.height="100%";let a=this.get("mapLibreOptions");this.mapLibreMap=new A2.Map(Object.assign({},a,{container:t,attributionControl:!1,interactive:!1,trackResize:!1})),this.mapLibreMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mapLibreMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new Or("load"))})}createRenderer(){return new zu(this)}};var E2=Lo(Gd());var $i=(0,E2.default)(s=>{console.warn(s)},1e3);function p3(s){return class extends s{constructor(...a){let l=a[0];super(l);this.options={};this.olEventsKeys=[];l.properties&&($i("Deprecated. Don't use properties options. Pass the values directly in options object."),this.setProperties(l.properties)),this.olEventsKeys?.push(this.on("propertychange",o=>{o.key==="children"&&this.onChildrenChange(o.oldValue)})),this.options=l,this.set("children",l.children||[])}get children(){return $i("Layer.children is deprecated. Use the Layer.get('children') method instead."),this.get("children")||[]}set children(a){$i("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),this.set("children",a||[])}get copyrights(){return $i("Layer.copyrights is deprecated. Get the attributions from the source object"),this.get("copyrights")}set copyrights(a){$i("Layer.copyrights is deprecated. Set the attributions to the source object.");let l=a&&!Array.isArray(a)?[a]:a;this.set("copyrights",l||[])}get disabled(){return $i("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),this.get("disabled")}set disabled(a){$i("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),this.set("disabled",a)}get group(){return $i("Layer.group is deprecated. Use the Layer.get('group') method instead."),this.get("group")}get hitTolerance(){return $i("Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."),this.get("hitTolerance")||5}get key(){return this.get("key")||this.get("name")||Nt(this)}get map(){return this.getMapInternal()}get name(){return $i("Layer.name is deprecated. Use the Layer.get('name') method instead."),this.get("name")}get olLayer(){return $i("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(a){$i("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.")}get parent(){return $i("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),this.get("parent")}set parent(a){$i("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),this.set("parent",a)}get visible(){return $i("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),this.getVisible()}set visible(a){$i("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),this.setVisible(a)}setMapInternal(a){super.setMapInternal(a),a?this.attachToMap(a):this.detachFromMap()}onChildrenChange(a){(a||[]).forEach(l=>{l.set("parent",void 0)}),(this.get("children")||[]).forEach(l=>{l.set("parent",this)})}attachToMap(a){(super.attachToMap||(()=>{}))(a),(this.get("children")||[]).forEach(l=>{a.addLayer(l)})}detachFromMap(){(this.get("children")||[]).forEach(a=>{this.map.removeLayer(a)}),(super.detachFromMap||(()=>{}))()}flat(){return $i("Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead."),Dl(this)}}}var I2=p3;function d3(s){return class extends I2(s){}}var bs=d3;var P2=(s,e,t,a)=>Fl(`${s}/styles/${e}/style.json`,{[a]:t}).toString(),rb=class s extends bs(Bu){get mbMap(){return console.warn("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get maplibreMap(){return console.warn("MaplibreLayer.maplibreMap 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)}constructor(e){let t={apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...e||{},mapLibreOptions:{...e.mapLibreOptions||{}}};!t.mapLibreOptions.style&&t.apiKey&&t.style&&(t.mapLibreOptions.style=P2(t.url,t.style,t.apiKey,t.apiKeyName)),super(t)}attachToMap(e){super.attachToMap(e),this.updateMaplibreMap();let t=(0,T2.default)(this.updateMaplibreMap.bind(this),150);this.olEventsKeys.push(this.on("propertychange",a=>{/(url|style)/.test(a.key)&&t()}))}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:P2(this.url,this.style,this.get("apiKey"),this.get("apiKeyName"))}updateMaplibreMap(){this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}clone(e){return new s({...this.options||{},...e||{}})}},C2=rb;var ib={"EPSG:3857":new Ti({featureProjection:"EPSG:3857"})},Vd=class extends Fu{getFeaturesAtCoordinate(e,t=5){if(!e)return[];let a=this.getLayer(),l=a.getMapInternal(),{mapLibreMap:o}=a.maplibreLayer,m=l?.getView()?.getProjection()?.getCode()||"EPSG:3857",g=[];if(ib[m]||(ib[m]=new Ti({featureProjection:m})),o?.isStyleLoaded()){let b=e&&o.project(Bl(e));if(b?.x&&b?.y){let A=[b.x,b.y];if(t){let[M,R]=A;A=[[M-t,R-t],[M+t,R+t]]}let S=a.layers||[];a.layersFilter&&(S=o.getStyle().layers.filter(a.layersFilter)),a.queryRenderedLayersFilter&&(S=o.getStyle().layers.filter(a.queryRenderedLayersFilter)),g=o.queryRenderedFeatures(A,{layers:S.map(M=>M.id),validate:!1}).map(M=>{let R=ib[m].readFeature(M);return R&&R.set(Iu,M),R})}}return g}prepareFrame(){return!0}renderFrame(){return null}getFeatures(e){let t=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(t))}forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{l(m,this.layer_,m.getGeometry())}),o?.[0]}};var nb=class s extends bs(Vo){constructor(t={mapLibreOptions:{style:{version:8,sources:{},layers:[]}}}){t.mapboxLayer&&(console.warn("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),t.maplibreLayer=t.mapboxLayer,delete t.mapboxLayer);super({source:new ua({}),...t});this.highlightedFeatures=[];this.selectedFeatures=[];this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=a=>!!this.layers.find(l=>a.id===l.id))}get beforeId(){return this.get("beforeId")}set beforeId(t){this.set("beforeId",t)}get layers(){return this.get("layers")}set layers(t){this.set("layers",t)}get layersFilter(){return this.get("layersFilter")}set layersFilter(t){this.set("layersFilter",t)}get mapboxLayer(){return console.warn("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(t){this.set("maplibreLayer",t)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(t){this.set("queryRenderedLayersFilter",t)}get sources(){return this.get("sources")}set sources(t){this.set("sources",t)}get styleLayer(){return console.warn("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(t){console.warn("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[t]}get styleLayers(){return console.warn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(t){console.warn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=t}createRenderer(){return new Vd(this)}attachToMap(t){if(this.maplibreLayer&&!this.maplibreLayer.map&&t.addLayer(this.maplibreLayer),super.attachToMap(t),!this.map||!this.maplibreLayer)return;if(!this.map.getTargetElement()){this.olEventsKeys.push(this.map.on("change:target",()=>{this.attachToMap(t)}));return}let{mapLibreMap:a}=this.maplibreLayer;a&&(a.loaded()?this.onLoad():a.once("load",this.onLoad)),this.olEventsKeys.push(this.maplibreLayer.on("load",this.onLoad.bind(this)),this.on("change:visible",l=>{this.applyLayoutVisibility(l)}),this.on("propertychange",l=>{/(sources|layers|layersFilter|maplibreLayer|beforeId)/.test(l.key)&&(this.detachFromMap(),this.attachToMap(t))}))}detachFromMap(){this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources()),super.detachFromMap()}addSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:t}=this.maplibreLayer;t&&Object.entries(this.sources).forEach(([a,l])=>{t.getSource(a)||t.addSource(a,l)})}removeSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:t}=this.maplibreLayer;t&&Object.keys(this.sources).forEach(a=>{t.getSource(a)&&t.removeSource(a)})}addLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:t}=this.maplibreLayer;t&&(this.layers.forEach(a=>{let{id:l,source:o}=a;(!o||o&&t.getSource(o))&&l&&!t.getLayer(l)&&t.addLayer(a,this.beforeId)}),this.applyLayoutVisibility())}removeLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:t}=this.maplibreLayer;t&&this.layers.forEach(a=>{let{id:l}=a;l&&t.getLayer(l)&&t.removeLayer(l)})}onLoad(){if(!this.maplibreLayer?.mapLibreMap)return;this.addSources(),this.addLayers();let{mapLibreMap:t}=this.maplibreLayer,a=t.getStyle();if(a?.layers&&this.layersFilter){let l=a.layers.filter(this.layersFilter);this.set("disabled",!l.length)}this.applyLayoutVisibility()}setFeatureState(t,a){if(!this.maplibreLayer?.mapLibreMap||!t.length)return;let{mapLibreMap:l}=this.maplibreLayer;t.forEach(o=>{let{source:m,sourceLayer:g}=o.get(Iu)||{};if(!m&&!g||!o.getId()){o.getId()||console.warn("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.getId(),o.getProperties());return}l.setFeatureState({id:o.getId(),source:m,sourceLayer:g},a)})}getFeatureInfoAtCoordinate(t){if(console.warn("Deprecated. getFeatureInfoAtCoordinate([layer], coordinate) from ol package instead."),!this.maplibreLayer?.mapLibreMap)return Promise.resolve({coordinate:t,features:[],layer:this});let{mapLibreMap:a}=this.maplibreLayer;if(!a.isStyleLoaded())return Promise.resolve({coordinate:t,features:[],layer:this});let l=this.layers||[];return this.layersFilter&&(l=a.getStyle().layers.filter(this.layersFilter)),this.queryRenderedLayersFilter&&(l=a.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({features:[],layer:this,coordinate:t})}setHoverState(t,a){console.warn(`Deprecated. Use layer.setFeatureState(features, {hover: ${a}}) instead.`),this.setFeatureState(t,{hover:a})}select(t=[]){console.warn("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=t,this.setHoverState(this.selectedFeatures||[],!0)}highlight(t=[]){console.warn("Deprecated. Use layer.setFeatureState(features, {highlighted: true}) instead.");let a=this.highlightedFeatures?.filter(l=>!(this.selectedFeatures||[]).map(o=>o.getId()).includes(l.getId()))||[];this.setHoverState(a,!1),this.highlightedFeatures=t,this.setHoverState(this.highlightedFeatures,!0)}applyLayoutVisibility(t){if(!this.maplibreLayer?.mapLibreMap?.getStyle()||!this.layersFilter)return;let{mapLibreMap:a}=this.maplibreLayer,l=a.getStyle(),o=this.getVisible()?"visible":"none",m=l.layers||[];for(let g=0;g<m.length;g+=1){let b=m[g];if(this.layersFilter(b)){let{id:A}=b;a.getLayer(A)&&(a.setLayoutProperty(A,"visibility",o),(this.getMinZoom()||this.getMaxZoom())&&a.setLayerZoomRange(A,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}clone(t){return new s({...this.options,...t})}},M2=nb;var lb=Lo(Gd());var sb=Lo(Gd()),ab=Lo(D2());function R3(s){return class extends s{constructor(t){super({hitTolerance:10,...t}),this.defineProperties(t),this.debug=t.debug||!1,this.mode=t.mode||ri.TOPOGRAPHIC,this.api=t.api||new Jp(t),this.tenant=t.tenant||"",this.minZoomInterpolation=t.minZoomInterpolation||8,this.format=new Ti,this.onStart=t.onStart,this.onStop=t.onStop,this.motsByZoom=t.motsByZoom||[Go,Go,Go,Go,Go,Go,Go,Go,Go,Xm,Xm],this.getMotsByZoom=a=>t.getMotsByZoom?t.getMotsByZoom(a,this.motsByZoom):this.motsByZoom[a],this.generalizationLevelByZoom=t.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=a=>t.getGeneralizationLevelByZoom?t.getGeneralizationLevelByZoom(a,this.generalizationLevelByZoom):this.generalizationLevelByZoom[a],this.renderTimeIntervalByZoom=t.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=a=>t.getRenderTimeIntervalByZoom?t.getRenderTimeIntervalByZoom(a,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[a],this.isUpdateBboxOnMoveEnd=t.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,ab.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,sb.default)(this.renderTrajectoriesInternal,50,{leading:!0,trailing:!0,maxWait:5e3}),this.renderTrajectoriesInternal=this.renderTrajectoriesInternal.bind(this),this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}defineProperties(t){(super.defineProperties||(()=>{}))(t);let{style:a,speed:l,pixelRatio:o,hoverVehicleId:m,selectedVehicleId:g,filter:b,sort:A,time:S,live:M,canvas:R,styleOptions:j,mode:W,bboxParameters:re}=t,$=R,X=l||1,se=S||new Date,me=W||ri.TOPOGRAPHIC,_e=a||ql;Object.defineProperties(this,{isTrackerLayer:{value:!0},canvas:{get:()=>($||($=document.createElement("canvas")),$),set:pe=>{$=pe}},mode:{get:()=>me,set:pe=>{pe!==me&&(me=pe,this.api?.wsApi?.open&&(this.stop(),this.start()))}},style:{get:()=>_e,set:pe=>{_e=pe,this.renderTrajectories()}},styleOptions:{value:{...Eu,...j||{}}},speed:{get:()=>X,set:pe=>{X=pe,this.start()}},bboxParameters:{value:re,writable:!0},filter:{value:b,writable:!0},sort:{value:A,writable:!0},live:{value:M===!1?M:!0,writable:!0},time:{get:()=>se,set:pe=>{se=pe&&pe.getTime?pe:new Date(pe),this.renderTrajectories()}},trajectories:{value:{},writable:!0},hoverVehicleId:{value:m,writable:!0},selectedVehicleId:{value:g,writable:!0},pixelRatio:{value:o||(typeof window<"u"?window.devicePixelRatio:1),writable:!0},useRequestAnimationFrame:{value:t.useRequestAnimationFrame||!1,writable:!0},useThrottle:{value:t.useThrottle!==!1,writable:!0},useDebounce:{value:t.useDebounce||!1,writable:!0}})}attachToMap(t){super.attachToMap(t),document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),Ol(this.visibilityRef),this.canvas){let t=this.canvas.getContext("2d");t&&t.clearRect(0,0,this.canvas.width,this.canvas.height),super.detachFromMap()}}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)}renderTrajectoriesInternal(t,a=!1){if(!this.map||!this.trajectories)return!1;let l=this.live?Date.now():this.time?.getTime(),o=Object.values(this.trajectories);return this.sort&&o.sort(this.sort),!this.canvas||!this.style||(this.renderState=xd(this.canvas,o,this.style,{...t,pixelRatio:this.pixelRatio||1,time:l},{filter:this.filter,noInterpolate:(t.zoom||0)<this.minZoomInterpolation?!0:a,hoverVehicleId:this.hoverVehicleId,selectedVehicleId:this.selectedVehicleId,...this.styleOptions})),!0}renderTrajectories(t,a){this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),t&&(!a&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(t,a)}):!a&&this.useDebounce?this.debounceRenderTrajectories(t,a):!a&&this.useThrottle?this.throttleRenderTrajectories(t,a):this.renderTrajectoriesInternal(t,a))}setBbox(t,a){if(this.trajectories&&t&&a){let S=Object.keys(this.trajectories);for(let M=S.length-1;M>=0;M-=1)this.purgeTrajectory(this.trajectories[S[M]],t,a)}let l=Math.floor(a);if(!t||Number.isNaN(l))return;let[o,m,g,b]=t,A=[Math.floor(o),Math.floor(m),Math.ceil(g),Math.ceil(b),l];this.generalizationLevel=this.getGeneralizationLevelByZoom(l),this.generalizationLevel&&A.push(`gen=${this.generalizationLevel}`),this.mots=this.getMotsByZoom(l),this.mots&&A.push(`mots=${this.mots}`),this.tenant&&A.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&A.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([S,M])=>{A.push(`${S}=${M}`)}),this.api.bbox=A}getRefreshTimeInMs(t=0){let a=t!==void 0?Math.round(t):-1,l=this.getRenderTimeIntervalByZoom(a)||25,o=Math.max(25,l/(this.speed||1)),m=Math.min(o,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,ab.default)(this.renderTrajectoriesInternal,m,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,sb.default)(this.renderTrajectoriesInternal,m,{leading:!0,trailing:!0,maxWait:5e3})),this.api?.buffer){let[,g]=this.api.buffer;this.api.buffer=[m,g]}return o}getVehicle(t){return this.trajectories&&Object.values(this.trajectories).filter(t)||[]}getFeatureInfoAtCoordinate(t,a){let{resolution:l,nb:o}=a,m=Ln([...t,...t],this.hitTolerance*l),g=Object.values(this.trajectories||{});this.sort&&(g=g.sort(this.sort));let b=[];for(let A=0;A<g.length;A+=1){let{coordinate:S}=g[A].properties;if(S&&Ys(m,S)&&b.push(g[A]),b.length===o)break}return Promise.resolve({layer:this,features:b.map(A=>this.format.readFeature(A)),coordinate:t})}getTrajectoryInfos(t){let a=[this.api.getStopSequence(t),this.api.getFullTrajectory(t,this.mode,this.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0)))];return Promise.all(a).then(([l,o])=>({stopSequence:l,fullTrajectory:o}))}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([t,a])=>{let l=a?.properties?.time_intervals;this.time&&l?.length&&l[l.length-1][0]<this.time.getTime()&&this.removeTrajectory(t)})}purgeTrajectory(t,a,l){let{type:o,bounds:m}=t.properties;return this.isUpdateBboxOnMoveEnd&&!ni(a,m)||this.mots&&!this.mots.includes(o)?(this.removeTrajectory(t),!0):!1}addTrajectory(t){this.trajectories||(this.trajectories={});let a=t.properties.train_id;a!==void 0&&(this.trajectories[a]=t),this.renderTrajectories()}removeTrajectory(t){let a;typeof t!="string"?a=t?.properties?.train_id:a=t,a!==void 0&&this.trajectories&&delete this.trajectories[a]}onZoomEnd(){this.startUpdateTime()}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(this.visible===!1)return;this.start()}}onTrajectoryMessage(t){if(!t.content)return;let a=t.content,{geometry:l,properties:{train_id:o,time_since_update:m,raw_coordinates:g}}=a;m<0||this.purgeTrajectory(a)||(this.debug&&this.mode===ri.TOPOGRAPHIC&&g?a.properties.olGeometry=this.format.readGeometry({type:"Point",coordinates:Ii(g,this.map.getView().getProjection())}):a.properties.olGeometry=this.format.readGeometry(l),a.properties.timeOffset=Date.now()-t.timestamp,this.addTrajectory(a))}onDeleteTrajectoryMessage(t){t.content&&this.removeTrajectory(t.content)}highlightVehicle(t){this.hoverVehicleId!==t&&(this.hoverVehicleId=t,this.renderTrajectories(!0))}selectVehicle(t){this.selectedVehicleId!==t&&(this.selectedVehicleId=t,this.renderTrajectories(!0))}}}var xg=R3;var k3=new Vi({zIndex:2,image:new Vn({radius:5,fill:new Gi({color:"#000000"})}),stroke:new pi({color:"#000000",width:6})}),F3=(s,e,t)=>{let a="#ffffff",l=s.get("type"),o=s.get("stroke");return o&&o[0]!=="#"&&(o=`#${o}`),a=o||t?.getBgColor(l),a=/#ffffff/i.test(a)?"#ff0000":a,[k3,new Vi({zIndex:3,image:new Vn({radius:4,fill:new Gi({color:a})}),stroke:new pi({color:a,width:4})})]},bg=F3;var L3=new Vi({zIndex:2,image:new Vn({radius:5,fill:new Gi({color:"#000000"})}),stroke:new pi({color:"#000000",width:6})}),D3=new Vi({zIndex:3,image:new Vn({radius:4,fill:new Gi({color:"#a0a0a0"})}),stroke:new pi({color:"#a0a0a0",width:4})}),O3=()=>[L3,D3],O2=O3;var z2=new Vn({radius:6,fill:new Gi({color:[255,0,0,1]}),stroke:new pi({color:[0,0,0,1],width:1})}),z3=new Vi({stroke:new pi({color:[0,0,0,1],width:5})}),B3=new Vi({image:z2,stroke:new pi({color:[255,0,0,1],width:3})}),j3=new Vi({image:z2,stroke:new pi({color:[255,0,0,1],width:3,lineDash:[1,10]})}),N3=(s,e)=>{let t=s.get("minResolution"),a=s.get("maxResolution"),l=e<=t&&e>a;return t&&a&&!l?[]:s.get("mot")!=="foot"?[z3,B3]:[j3]},B2=N3;var U3=new Ti,qd=class extends fg{prepareFrame(){return!0}renderFrame(e){let{canvas:t,renderedViewState:a}=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%",t instanceof HTMLCanvasElement&&(t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.transformOrigin="top left",this.container.appendChild(t))),a){let{center:l,resolution:o,rotation:m}=e.viewState,{center:g,resolution:b,rotation:A}=a;if(b/o>=3)t?.getContext("2d")?.clearRect(0,0,t?.width,t?.height);else{let S=this.getLayer().getMapInternal(),M=S?.getPixelFromCoordinate(g),R=S?.getPixelFromCoordinate(l);M&&R&&(this.container.style.transform=DA(M[0]-R[0],M[1]-R[1],b/o,b/o,m-A,0,0))}}return this.container}getData(e){let t;try{let{pixelRatio:a}=this.getLayer();return t=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(e[0]*(a||1),e[1]*(a||1),1,1).data||null,t}catch(a){console.error("error getting data",a)}return null}getFeatures(e){let t=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(t))}forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{l(m,this.layer_,m.getGeometry())}),o?.[0]}getFeaturesAtCoordinate(e,t=5){if(!e)return[];let a=this.getLayer(),o=a.getMapInternal()?.getView()?.getResolution()||1,m=10,g=Ln([...e,...e],t*o),b=[],A=Object.values(a.trajectories||{});a.sort&&(A=A.sort(this.sort));let S=[];for(let M=0;M<A.length;M+=1){let R=A[M];if(R.properties.coordinate&&Ys(g,R.properties.coordinate)&&S.push(A[M]),S.length===m)break}return b=S.map(M=>U3.readFeature(M)),b}};var G3=new Ti,cb=class s extends xg(bs(Vo)){constructor(t){super({source:new ua({}),...t});this.allowRenderWhenAnimating=!1;this.allowRenderWhenAnimating=!!t.allowRenderWhenAnimating,this.vectorLayer=new Xl({updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0,source:new Yl({features:[]}),style:(a,l)=>(t.fullTrajectoryStyle||bg)(a,l,this.styleOptions)}),this.renderState={center:[0,0],zoom:void 0,rotation:0},this.onZoomEndDebounced=(0,lb.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,lb.default)(this.onMoveEnd,100)}createRenderer(){return new qd(this)}attachToMap(t){if(super.attachToMap(t),this.map){this.visible&&this.start();let a=this.map.getLayers().getArray().indexOf(this);this.map.getLayers().insertAt(a,this.vectorLayer),this.olEventsKeys.push(...this.map.on(["moveend","change:target"],l=>{let o=(l.map||l.target).getView();if(o.getAnimating()||o.getInteracting())return;let m=o.getZoom();this.currentZoom!==m&&this.onZoomEndDebounced(l),this.currentZoom=m,this.onMoveEndDebounced(l)}),this.on("change:visible",l=>{l.target.visible?this.start():this.stop()}),this.on("propertychange",l=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(l.key)&&this.vectorLayer.set(l.key,l.target.get(l.key))}))}}detachFromMap(){this.map?.removeLayer(this.vectorLayer),super.detachFromMap()}renderTrajectories(t){if(!this.map)return;let a=this.map.getView();a.getCenter()&&super.renderTrajectories({size:this.map.getSize(),center:a.getCenter(),extent:a.calculateExtent(),resolution:a.getResolution(),rotation:a.getRotation(),zoom:a.getZoom(),pixelRatio:this.pixelRatio},t)}renderTrajectoriesInternal(t,a){if(!this.map)return!1;let l=!1;if(l=(this.allowRenderWhenAnimating?!1:this.map.getView().getAnimating()||this.map.getView().getInteracting())?!1:super.renderTrajectoriesInternal(t,a),l){this.renderedViewState={...t};let{container:m}=this.getRenderer();m&&(m.style.transform="")}return l}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getView().getZoom())}onMoveEnd(t){!this.isUpdateBboxOnMoveEnd||!this.visible||this.setBbox()}onZoomEnd(){super.onZoomEnd(),!(!this.isUpdateBboxOnMoveEnd||!this.visible)&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}highlight(t){this.highlightVehicle(t?.get("train_id"))}select(t){this.selectVehicle(t?.get("train_id")),this.highlightTrajectory(t?.get("train_id"))}purgeTrajectory(t,a,l){let o=this.map.getView().getCenter();return!a&&!o?!1:super.purgeTrajectory(t,a||this.map.getView().calculateExtent(),l||this.map.getView().getZoom()||0)}setBbox(t,a){super.setBbox(t||this.map.getView().calculateExtent(),a||this.map.getView().getZoom()||0)}highlightTrajectory(t){return t?this.api.getFullTrajectory(t,this.mode,this.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0))).then(a=>{let l=a.content;if(!l?.features?.length)return[];let o=G3.readFeatures(l);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([]))}clone(t){return new s({...this.options,...t})}},j2=cb;var ub=class s extends bs(Vo){constructor(e){super(e),console.warn("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(e){return new s({...this.options||{},...e||{}})}},wg=ub;var hb=class s extends wg{getFeatureInfoAtCoordinate(e){let t=[];if(this.map){let a=this.map.getPixelFromCoordinate(e);t=this.map.getFeaturesAtPixel(a,{layerFilter:l=>l===this.olLayer,hitTolerance:this.hitTolerance||5})}return Promise.resolve({features:t,layer:this,coordinate:e})}clone(e){return new s({...this.options,...e})}},N2=hb;var V3=new Ti,q3=(s,e,t)=>{let a,{coordinate:l,resolution:o,projection:m,params:g}=e;return s&&o&&m&&(a=s.getFeatureInfoUrl(l,o,m,{info_format:"application/json",query_layers:s.getParams().layers,...g})),fetch(a,{signal:t.signal}).then(b=>b.json()).then(b=>V3.readFeatures(b)).catch(()=>[])},$d={},$3=async(s,e,t=5)=>{Object.values($d).forEach(o=>{o?.abort()}),$d={};let l=Dl(e).map(o=>{let m=o.getMapInternal(),g=m?.getView()?.getProjection()?.getCode(),b={features:[],layer:o,coordinate:s};if(!g)return Promise.resolve(b);if(o.getFeatureInfoAtCoordinate)return o.getFeatureInfoAtCoordinate(s);let A=o?.getSource();if(A?.getFeatureInfoUrl){let R=Nt(o);$d[R]?.abort(),$d[R]=new AbortController;let j=m?.getView()?.getResolution();return q3(A,{coordinate:s,resolution:j,projection:g,params:{info_format:"application/json",query_layers:A.getParams().layers}},$d[R]).then(W=>({features:W,layer:o,coordinate:s})).catch(()=>({features:[],layer:o,coordinate:s}))}let S=m?.getPixelFromCoordinate(s);if(!S)return Promise.resolve(b);let M=m?.getFeaturesAtPixel(S,{layerFilter:R=>R===o,hitTolerance:o.get("hitTolerance")||t||5});return Promise.resolve({features:M,layer:o,coordinate:s})});return Promise.all(l)},U2=$3;var Uy={};ev(Uy,{CopyrightControl:()=>G2,Layer:()=>Ig,RealtimeAPI:()=>Jp,RealtimeLayer:()=>_L,RealtimeModes:()=>ri,RoutingAPI:()=>Xp,StopsAPI:()=>Yp,VECTOR_TILE_FEATURE_PROPERTY:()=>Iu,compareDepartures:()=>bd,createCanvas:()=>Uo,createRealtimeFilters:()=>sv,debounceDeparturesMessages:()=>Yv,debounceWebsocketMessages:()=>Kp,getCircleCanvas:()=>nx,getDelayBgCanvas:()=>rx,getDelayTextCanvas:()=>ix,getHoursAndMinutes:()=>kA,getLayersAsFlatArray:()=>Dl,getMapGlCopyrights:()=>Qp,getMercatorResolution:()=>yL,getSourceCoordinates:()=>Ny,getTextCanvas:()=>ox,getUTCDateString:()=>MA,getUTCTimeString:()=>RA,getUrlWithParams:()=>Fl,getVehiclePosition:()=>vd,pad:()=>Em,realtimeConfig:()=>Eu,realtimeDefaultStyle:()=>ql,realtimeDelayStyle:()=>sx,realtimeSimpleStyle:()=>ax,removeDuplicate:()=>Ll,renderTrajectories:()=>xd,sortAndFilterDepartures:()=>wd,sortByDelay:()=>av});var W3=" | ",pb=class{constructor(e={}){this.options=e}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}getDefaultPosition(){return"bottom-right"}render(){if(this.map&&this.container){let e=this.options?.separator||W3,t=this.options?.customAttribution||Qp(this.map),a=(Array.isArray(t)?t:[t]).join(e);this.container.innerHTML!==a&&(this.content=a,this.container.innerHTML=this.content)}}},G2=pb;var Wi=[];for(Ag=0;Ag<256;++Ag)Wi.push((Ag+256).toString(16).slice(1));var Ag;function V2(s,e=0){return(Wi[s[e+0]]+Wi[s[e+1]]+Wi[s[e+2]]+Wi[s[e+3]]+"-"+Wi[s[e+4]]+Wi[s[e+5]]+"-"+Wi[s[e+6]]+Wi[s[e+7]]+"-"+Wi[s[e+8]]+Wi[s[e+9]]+"-"+Wi[s[e+10]]+Wi[s[e+11]]+Wi[s[e+12]]+Wi[s[e+13]]+Wi[s[e+14]]+Wi[s[e+15]]).toLowerCase()}var Eg,Z3=new Uint8Array(16);function db(){if(!Eg&&(Eg=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Eg))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Eg(Z3)}var H3=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),fb={randomUUID:H3};function X3(s,e,t){if(fb.randomUUID&&!e&&!s)return fb.randomUUID();s=s||{};var a=s.random||(s.rng||db)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,e){t=t||0;for(var l=0;l<16;++l)e[t+l]=a[l];return e}return V2(a)}var mb=X3;var q2=Lo(Q0()),gb=class extends q2.Evented{constructor(t={}){super();this.options={};this.type="custom";this.options=t,this.id=t.id||mb(),this.type="custom"}onAdd(t,a){this.map=t}onRemove(t,a){this.map=void 0}render(t){}},Ig=gb;var QF=Lo(KF(),1),zG=Object.defineProperty,dr=(s,e)=>zG(s,"name",{value:e,configurable:!0}),BG=class{constructor(e){this.direction=!1,this.compareProperties=!0;var t,a,l;this.precision=10**-((t=e?.precision)!=null?t:17),this.direction=(a=e?.direction)!=null?a:!1,this.compareProperties=(l=e?.compareProperties)!=null?l:!0}compare(e,t){if(e.type!==t.type||!ff(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates);case"Polygon":return this.comparePolygon(e,t);case"GeometryCollection":return this.compareGeometryCollection(e,t);case"Feature":return this.compareFeature(e,t);case"FeatureCollection":return this.compareFeatureCollection(e,t);default:if(e.type.startsWith("Multi")){let a=Iw(e),l=Iw(t);return a.every(o=>l.some(m=>this.compare(o,m)))}}return!1}compareCoord(e,t){return e.length===t.length&&e.every((a,l)=>Math.abs(a-t[l])<this.precision)}compareLine(e,t,a=0,l=!1){if(!ff(e,t))return!1;let o=e,m=t;if(l&&!this.compareCoord(o[0],m[0])){let b=this.fixStartIndex(m,o);if(b)m=b;else return!1}let g=this.compareCoord(o[a],m[a]);return this.direction||g?this.comparePath(o,m):this.compareCoord(o[a],m[m.length-(1+a)])?this.comparePath(o.slice().reverse(),m):!1}fixStartIndex(e,t){let a,l=-1;for(let o=0;o<e.length;o++)if(this.compareCoord(e[o],t[0])){l=o;break}return l>=0&&(a=[].concat(e.slice(l,e.length),e.slice(1,l+1))),a}comparePath(e,t){return e.every((a,l)=>this.compareCoord(a,t[l]))}comparePolygon(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){let a=e.coordinates.slice(1,e.coordinates.length),l=t.coordinates.slice(1,t.coordinates.length);return a.every(o=>l.some(m=>this.compareLine(o,m,1,!0)))}return!1}compareGeometryCollection(e,t){return ff(e.geometries,t.geometries)&&this.compareBBox(e,t)&&e.geometries.every((a,l)=>this.compare(a,t.geometries[l]))}compareFeature(e,t){return e.id===t.id&&(this.compareProperties?(0,QF.default)(e.properties,t.properties):!0)&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return ff(e.features,t.features)&&this.compareBBox(e,t)&&e.features.every((a,l)=>this.compare(a,t.features[l]))}compareBBox(e,t){return!e.bbox&&!t.bbox||(e.bbox&&t.bbox?this.compareCoord(e.bbox,t.bbox):!1)}};dr(BG,"GeojsonEquality");function ff(s,e){return s.coordinates?s.coordinates.length===e.coordinates.length:s.length===e.length}dr(ff,"sameLength");function Iw(s){return s.coordinates.map(e=>({type:s.type.replace("Multi",""),coordinates:e}))}dr(Iw,"explode");var Zi=63710088e-1,eL={centimeters:Zi*100,centimetres:Zi*100,degrees:360/(2*Math.PI),feet:Zi*3.28084,inches:Zi*39.37,kilometers:Zi/1e3,kilometres:Zi/1e3,meters:Zi,metres:Zi,miles:Zi/1609.344,millimeters:Zi*1e3,millimetres:Zi*1e3,nauticalmiles:Zi/1852,radians:1,yards:Zi*1.0936},JF={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:29155334959812285e-23,millimeters:1e6,millimetres:1e6,yards:1.195990046};function Ko(s,e,t={}){let a={type:"Feature"};return(t.id===0||t.id)&&(a.id=t.id),t.bbox&&(a.bbox=t.bbox),a.properties=e||{},a.geometry=s,a}dr(Ko,"feature");function jG(s,e,t={}){switch(s){case"Point":return Hi(e).geometry;case"LineString":return Fs(e).geometry;case"Polygon":return Pw(e).geometry;case"MultiPoint":return rL(e).geometry;case"MultiLineString":return tL(e).geometry;case"MultiPolygon":return iL(e).geometry;default:throw new Error(s+" is invalid")}}dr(jG,"geometry");function Hi(s,e,t={}){if(!s)throw new Error("coordinates is required");if(!Array.isArray(s))throw new Error("coordinates must be an Array");if(s.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!vc(s[0])||!vc(s[1]))throw new Error("coordinates must contain numbers");return Ko({type:"Point",coordinates:s},e,t)}dr(Hi,"point");function NG(s,e,t={}){return Oy(s.map(a=>Hi(a,e)),t)}dr(NG,"points");function Pw(s,e,t={}){for(let l of s){if(l.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(l[l.length-1].length!==l[0].length)throw new Error("First and last Position are not equivalent.");for(let o=0;o<l[l.length-1].length;o++)if(l[l.length-1][o]!==l[0][o])throw new Error("First and last Position are not equivalent.")}return Ko({type:"Polygon",coordinates:s},e,t)}dr(Pw,"polygon");function UG(s,e,t={}){return Oy(s.map(a=>Pw(a,e)),t)}dr(UG,"polygons");function Fs(s,e,t={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return Ko({type:"LineString",coordinates:s},e,t)}dr(Fs,"lineString");function GG(s,e,t={}){return Oy(s.map(a=>Fs(a,e)),t)}dr(GG,"lineStrings");function Oy(s,e={}){let t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=s,t}dr(Oy,"featureCollection");function tL(s,e,t={}){return Ko({type:"MultiLineString",coordinates:s},e,t)}dr(tL,"multiLineString");function rL(s,e,t={}){return Ko({type:"MultiPoint",coordinates:s},e,t)}dr(rL,"multiPoint");function iL(s,e,t={}){return Ko({type:"MultiPolygon",coordinates:s},e,t)}dr(iL,"multiPolygon");function VG(s,e,t={}){return Ko({type:"GeometryCollection",geometries:s},e,t)}dr(VG,"geometryCollection");function qG(s,e=0){if(e&&!(e>=0))throw new Error("precision must be a positive number");let t=Math.pow(10,e||0);return Math.round(s*t)/t}dr(qG,"round");function nL(s,e="kilometers"){let t=eL[e];if(!t)throw new Error(e+" units is invalid");return s*t}dr(nL,"radiansToLength");function Tw(s,e="kilometers"){let t=eL[e];if(!t)throw new Error(e+" units is invalid");return s/t}dr(Tw,"lengthToRadians");function $G(s,e){return zy(Tw(s,e))}dr($G,"lengthToDegrees");function WG(s){let e=s%360;return e<0&&(e+=360),e}dr(WG,"bearingToAzimuth");function zy(s){return s%(2*Math.PI)*180/Math.PI}dr(zy,"radiansToDegrees");function nl(s){return s%360*Math.PI/180}dr(nl,"degreesToRadians");function mf(s,e="kilometers",t="kilometers"){if(!(s>=0))throw new Error("length must be a positive number");return nL(Tw(s,e),t)}dr(mf,"convertLength");function ZG(s,e="meters",t="kilometers"){if(!(s>=0))throw new Error("area must be a positive number");let a=JF[e];if(!a)throw new Error("invalid original units");let l=JF[t];if(!l)throw new Error("invalid final units");return s/a*l}dr(ZG,"convertArea");function vc(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}dr(vc,"isNumber");function Bh(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}dr(Bh,"isObject");function HG(s){if(!s)throw new Error("bbox is required");if(!Array.isArray(s))throw new Error("bbox must be an Array");if(s.length!==4&&s.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");s.forEach(e=>{if(!vc(e))throw new Error("bbox must only contain numbers")})}dr(HG,"validateBBox");function XG(s){if(!s)throw new Error("id is required");if(["string","number"].indexOf(typeof s)===-1)throw new Error("id must be a number or a string")}dr(XG,"validateId");var YG=Object.defineProperty,Xi=(s,e)=>YG(s,"name",{value:e,configurable:!0});function da(s,e,t){if(s!==null)for(var a,l,o,m,g,b,A,S=0,M=0,R,j=s.type,W=j==="FeatureCollection",re=j==="Feature",$=W?s.features.length:1,X=0;X<$;X++){A=W?s.features[X].geometry:re?s.geometry:s,R=A?A.type==="GeometryCollection":!1,g=R?A.geometries.length:1;for(var se=0;se<g;se++){var me=0,_e=0;if(m=R?A.geometries[se]:A,m!==null){b=m.coordinates;var pe=m.type;switch(S=t&&(pe==="Polygon"||pe==="MultiPolygon")?1:0,pe){case null:break;case"Point":if(e(b,M,X,me,_e)===!1)return!1;M++,me++;break;case"LineString":case"MultiPoint":for(a=0;a<b.length;a++){if(e(b[a],M,X,me,_e)===!1)return!1;M++,pe==="MultiPoint"&&me++}pe==="LineString"&&me++;break;case"Polygon":case"MultiLineString":for(a=0;a<b.length;a++){for(l=0;l<b[a].length-S;l++){if(e(b[a][l],M,X,me,_e)===!1)return!1;M++}pe==="MultiLineString"&&me++,pe==="Polygon"&&_e++}pe==="Polygon"&&me++;break;case"MultiPolygon":for(a=0;a<b.length;a++){for(_e=0,l=0;l<b[a].length;l++){for(o=0;o<b[a][l].length-S;o++){if(e(b[a][l][o],M,X,me,_e)===!1)return!1;M++}_e++}me++}break;case"GeometryCollection":for(a=0;a<m.geometries.length;a++)if(da(m.geometries[a],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}Xi(da,"coordEach");function KG(s,e,t,a){var l=t;return da(s,function(o,m,g,b,A){m===0&&t===void 0?l=o:l=e(l,o,m,g,b,A)},a),l}Xi(KG,"coordReduce");function oL(s,e){var t;switch(s.type){case"FeatureCollection":for(t=0;t<s.features.length&&e(s.features[t].properties,t)!==!1;t++);break;case"Feature":e(s.properties,0);break}}Xi(oL,"propEach");function JG(s,e,t){var a=t;return oL(s,function(l,o){o===0&&t===void 0?a=l:a=e(a,l,o)}),a}Xi(JG,"propReduce");function sL(s,e){if(s.type==="Feature")e(s,0);else if(s.type==="FeatureCollection")for(var t=0;t<s.features.length&&e(s.features[t],t)!==!1;t++);}Xi(sL,"featureEach");function QG(s,e,t){var a=t;return sL(s,function(l,o){o===0&&t===void 0?a=l:a=e(a,l,o)}),a}Xi(QG,"featureReduce");function eV(s){var e=[];return da(s,function(t){e.push(t)}),e}Xi(eV,"coordAll");function Cw(s,e){var t,a,l,o,m,g,b,A,S,M,R=0,j=s.type==="FeatureCollection",W=s.type==="Feature",re=j?s.features.length:1;for(t=0;t<re;t++){for(g=j?s.features[t].geometry:W?s.geometry:s,A=j?s.features[t].properties:W?s.properties:{},S=j?s.features[t].bbox:W?s.bbox:void 0,M=j?s.features[t].id:W?s.id:void 0,b=g?g.type==="GeometryCollection":!1,m=b?g.geometries.length:1,l=0;l<m;l++){if(o=b?g.geometries[l]:g,o===null){if(e(null,R,A,S,M)===!1)return!1;continue}switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(o,R,A,S,M)===!1)return!1;break}case"GeometryCollection":{for(a=0;a<o.geometries.length;a++)if(e(o.geometries[a],R,A,S,M)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}R++}}Xi(Cw,"geomEach");function tV(s,e,t){var a=t;return Cw(s,function(l,o,m,g,b){o===0&&t===void 0?a=l:a=e(a,l,o,m,g,b)}),a}Xi(tV,"geomReduce");function By(s,e){Cw(s,function(t,a,l,o,m){var g=t===null?null:t.type;switch(g){case null:case"Point":case"LineString":case"Polygon":return e(Ko(t,l,{bbox:o,id:m}),a,0)===!1?!1:void 0}var b;switch(g){case"MultiPoint":b="Point";break;case"MultiLineString":b="LineString";break;case"MultiPolygon":b="Polygon";break}for(var A=0;A<t.coordinates.length;A++){var S=t.coordinates[A],M={type:b,coordinates:S};if(e(Ko(M,l),a,A)===!1)return!1}})}Xi(By,"flattenEach");function rV(s,e,t){var a=t;return By(s,function(l,o,m){o===0&&m===0&&t===void 0?a=l:a=e(a,l,o,m)}),a}Xi(rV,"flattenReduce");function aL(s,e){By(s,function(t,a,l){var o=0;if(t.geometry){var m=t.geometry.type;if(!(m==="Point"||m==="MultiPoint")){var g,b=0,A=0,S=0;if(da(t,function(M,R,j,W,re){if(g===void 0||a>b||W>A||re>S){g=M,b=a,A=W,S=re,o=0;return}var $=Fs([g,M],t.properties);if(e($,a,l,re,o)===!1)return!1;o++,g=M})===!1)return!1}}})}Xi(aL,"segmentEach");function iV(s,e,t){var a=t,l=!1;return aL(s,function(o,m,g,b,A){l===!1&&t===void 0?a=o:a=e(a,o,m,g,b,A),l=!0}),a}Xi(iV,"segmentReduce");function lL(s,e){if(!s)throw new Error("geojson is required");By(s,function(t,a,l){if(t.geometry!==null){var o=t.geometry.type,m=t.geometry.coordinates;switch(o){case"LineString":if(e(t,a,l,0,0)===!1)return!1;break;case"Polygon":for(var g=0;g<m.length;g++)if(e(Fs(m[g],t.properties),a,l,g)===!1)return!1;break}}})}Xi(lL,"lineEach");function nV(s,e,t){var a=t;return lL(s,function(l,o,m,g){o===0&&t===void 0?a=l:a=e(a,l,o,m,g)}),a}Xi(nV,"lineReduce");function oV(s,e){if(e=e||{},!Bh(e))throw new Error("options is invalid");var t=e.featureIndex||0,a=e.multiFeatureIndex||0,l=e.geometryIndex||0,o=e.segmentIndex||0,m=e.properties,g;switch(s.type){case"FeatureCollection":t<0&&(t=s.features.length+t),m=m||s.features[t].properties,g=s.features[t].geometry;break;case"Feature":m=m||s.properties,g=s.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":g=s;break;default:throw new Error("geojson is invalid")}if(g===null)return null;var b=g.coordinates;switch(g.type){case"Point":case"MultiPoint":return null;case"LineString":return o<0&&(o=b.length+o-1),Fs([b[o],b[o+1]],m,e);case"Polygon":return l<0&&(l=b.length+l),o<0&&(o=b[l].length+o-1),Fs([b[l][o],b[l][o+1]],m,e);case"MultiLineString":return a<0&&(a=b.length+a),o<0&&(o=b[a].length+o-1),Fs([b[a][o],b[a][o+1]],m,e);case"MultiPolygon":return a<0&&(a=b.length+a),l<0&&(l=b[a].length+l),o<0&&(o=b[a][l].length-o-1),Fs([b[a][l][o],b[a][l][o+1]],m,e)}throw new Error("geojson is invalid")}Xi(oV,"findSegment");function sV(s,e){if(e=e||{},!Bh(e))throw new Error("options is invalid");var t=e.featureIndex||0,a=e.multiFeatureIndex||0,l=e.geometryIndex||0,o=e.coordIndex||0,m=e.properties,g;switch(s.type){case"FeatureCollection":t<0&&(t=s.features.length+t),m=m||s.features[t].properties,g=s.features[t].geometry;break;case"Feature":m=m||s.properties,g=s.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":g=s;break;default:throw new Error("geojson is invalid")}if(g===null)return null;var b=g.coordinates;switch(g.type){case"Point":return Hi(b,m,e);case"MultiPoint":return a<0&&(a=b.length+a),Hi(b[a],m,e);case"LineString":return o<0&&(o=b.length+o),Hi(b[o],m,e);case"Polygon":return l<0&&(l=b.length+l),o<0&&(o=b[l].length+o),Hi(b[l][o],m,e);case"MultiLineString":return a<0&&(a=b.length+a),o<0&&(o=b[a].length+o),Hi(b[a][o],m,e);case"MultiPolygon":return a<0&&(a=b.length+a),l<0&&(l=b[a].length+l),o<0&&(o=b[a][l].length-o),Hi(b[a][l][o],m,e)}throw new Error("geojson is invalid")}Xi(sV,"findPoint");var aV=Object.defineProperty,lV=(s,e)=>aV(s,"name",{value:e,configurable:!0});function Mw(s,e={}){let t=0,a=0,l=0;return da(s,function(o){t+=o[0],a+=o[1],l++},!0),Hi([t/l,a/l],e.properties)}lV(Mw,"centroid");var cV=Object.defineProperty,ol=(s,e)=>cV(s,"name",{value:e,configurable:!0});function Jo(s){if(!s)throw new Error("coord is required");if(!Array.isArray(s)){if(s.type==="Feature"&&s.geometry!==null&&s.geometry.type==="Point")return[...s.geometry.coordinates];if(s.type==="Point")return[...s.coordinates]}if(Array.isArray(s)&&s.length>=2&&!Array.isArray(s[0])&&!Array.isArray(s[1]))return[...s];throw new Error("coord must be GeoJSON Point or an Array of numbers")}ol(Jo,"getCoord");function Rw(s){if(Array.isArray(s))return s;if(s.type==="Feature"){if(s.geometry!==null)return s.geometry.coordinates}else if(s.coordinates)return s.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}ol(Rw,"getCoords");function cL(s){if(s.length>1&&vc(s[0])&&vc(s[1]))return!0;if(Array.isArray(s[0])&&s[0].length)return cL(s[0]);throw new Error("coordinates must only contain numbers")}ol(cL,"containsNumber");function uV(s,e,t){if(!e||!t)throw new Error("type and name required");if(!s||s.type!==e)throw new Error("Invalid input to "+t+": must be a "+e+", given "+s.type)}ol(uV,"geojsonType");function hV(s,e,t){if(!s)throw new Error("No feature passed");if(!t)throw new Error(".featureOf() requires a name");if(!s||s.type!=="Feature"||!s.geometry)throw new Error("Invalid input to "+t+", Feature with geometry required");if(!s.geometry||s.geometry.type!==e)throw new Error("Invalid input to "+t+": must be a "+e+", given "+s.geometry.type)}ol(hV,"featureOf");function pV(s,e,t){if(!s)throw new Error("No featureCollection passed");if(!t)throw new Error(".collectionOf() requires a name");if(!s||s.type!=="FeatureCollection")throw new Error("Invalid input to "+t+", FeatureCollection required");for(let a of s.features){if(!a||a.type!=="Feature"||!a.geometry)throw new Error("Invalid input to "+t+", Feature with geometry required");if(!a.geometry||a.geometry.type!==e)throw new Error("Invalid input to "+t+": must be a "+e+", given "+a.geometry.type)}}ol(pV,"collectionOf");function dV(s){return s.type==="Feature"?s.geometry:s}ol(dV,"getGeom");function fV(s,e){return s.type==="FeatureCollection"?"FeatureCollection":s.type==="GeometryCollection"?"GeometryCollection":s.type==="Feature"&&s.geometry!==null?s.geometry.type:s.type}ol(fV,"getType");var mV=Object.defineProperty,uL=(s,e)=>mV(s,"name",{value:e,configurable:!0});function Fw(s,e,t={}){let a;return t.final?a=kw(Jo(e),Jo(s)):a=kw(Jo(s),Jo(e)),a>180?-(360-a):a}uL(Fw,"rhumbBearing");function kw(s,e){let t=nl(s[1]),a=nl(e[1]),l=nl(e[0]-s[0]);l>Math.PI&&(l-=2*Math.PI),l<-Math.PI&&(l+=2*Math.PI);let o=Math.log(Math.tan(a/2+Math.PI/4)/Math.tan(t/2+Math.PI/4)),m=Math.atan2(l,o);return(zy(m)+360)%360}uL(kw,"calculateRhumbBearing");var gV=Object.defineProperty,hL=(s,e)=>gV(s,"name",{value:e,configurable:!0});function Lw(s,e,t={}){let a=Jo(s),l=Jo(e);l[0]+=l[0]-a[0]>180?-360:a[0]-l[0]>180?360:0;let o=pL(a,l);return mf(o,"meters",t.units)}hL(Lw,"rhumbDistance");function pL(s,e,t){t=t===void 0?Zi:Number(t);let a=t,l=s[1]*Math.PI/180,o=e[1]*Math.PI/180,m=o-l,g=Math.abs(e[0]-s[0])*Math.PI/180;g>Math.PI&&(g-=2*Math.PI);let b=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(l/2+Math.PI/4)),A=Math.abs(b)>1e-11?m/b:Math.cos(l);return Math.sqrt(m*m+A*A*g*g)*a}hL(pL,"calculateRhumbDistance");var yV=Object.defineProperty,dL=(s,e)=>yV(s,"name",{value:e,configurable:!0});function Dw(s,e,t,a={}){let l=e<0,o=mf(Math.abs(e),a.units,"meters");l&&(o=-Math.abs(o));let m=Jo(s),g=fL(m,o,t);return g[0]+=g[0]-m[0]>180?-360:m[0]-g[0]>180?360:0,Hi(g,a.properties)}dL(Dw,"rhumbDestination");function fL(s,e,t,a){a=a===void 0?Zi:Number(a);let l=e/a,o=s[0]*Math.PI/180,m=nl(s[1]),g=nl(t),b=l*Math.cos(g),A=m+b;Math.abs(A)>Math.PI/2&&(A=A>0?Math.PI-A:-Math.PI-A);let S=Math.log(Math.tan(A/2+Math.PI/4)/Math.tan(m/2+Math.PI/4)),M=Math.abs(S)>1e-11?b/S:Math.cos(m),R=l*Math.sin(g)/M;return[((o+R)*180/Math.PI+540)%360-180,A*180/Math.PI]}dL(fL,"calculateRhumbDestination");var _V=Object.defineProperty,jh=(s,e)=>_V(s,"name",{value:e,configurable:!0});function Ow(s){if(!s)throw new Error("geojson is required");switch(s.type){case"Feature":return zw(s);case"FeatureCollection":return mL(s);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return jy(s);default:throw new Error("unknown GeoJSON type")}}jh(Ow,"clone");function zw(s){let e={type:"Feature"};return Object.keys(s).forEach(t=>{switch(t){case"type":case"properties":case"geometry":return;default:e[t]=s[t]}}),e.properties=Bw(s.properties),s.geometry==null?e.geometry=null:e.geometry=jy(s.geometry),e}jh(zw,"cloneFeature");function Bw(s){let e={};return s&&Object.keys(s).forEach(t=>{let a=s[t];typeof a=="object"?a===null?e[t]=null:Array.isArray(a)?e[t]=a.map(l=>l):e[t]=Bw(a):e[t]=a}),e}jh(Bw,"cloneProperties");function mL(s){let e={type:"FeatureCollection"};return Object.keys(s).forEach(t=>{switch(t){case"type":case"features":return;default:e[t]=s[t]}}),e.features=s.features.map(t=>zw(t)),e}jh(mL,"cloneFeatureCollection");function jy(s){let e={type:s.type};return s.bbox&&(e.bbox=s.bbox),s.type==="GeometryCollection"?(e.geometries=s.geometries.map(t=>jy(t)),e):(e.coordinates=jw(s.coordinates),e)}jh(jy,"cloneGeometry");function jw(s){let e=s;return typeof e[0]!="object"?e.slice():e.map(t=>jw(t))}jh(jw,"deepSlice");var vV=Object.defineProperty,xV=(s,e)=>vV(s,"name",{value:e,configurable:!0});function gL(s,e,t){if(t=t||{},!Bh(t))throw new Error("options is invalid");var a=t.pivot,l=t.mutate;if(!s)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");return e===0||(a||(a=Mw(s)),(l===!1||l===void 0)&&(s=Ow(s)),da(s,function(o){var m=Fw(a,o),g=m+e,b=Lw(a,o),A=Rw(Dw(a,b,g));o[0]=A[0],o[1]=A[1]})),s}xV(gL,"transformRotate");var Nw=gL;var bV=(s,e=1)=>{let{width:t,height:a}=s.getCanvas(),l=s.unproject({x:0,y:0}),o=s.unproject({x:0,y:a/e}),m=s.unproject({x:t/e,y:a/e}),g=s.unproject({x:t/e,y:0});return[[l.lng,l.lat],[g.lng,g.lat],[m.lng,m.lat],[o.lng,o.lat]]},Ny=bV;var wV=s=>{let e=s.getBounds().toArray(),t=Ii(e[0]),a=Ii(e[1]),l=[...t,...a],{width:o,height:m}=s.getCanvas(),g=Fr(l)/o,b=hi(l)/m;return Math.max(g,b)},yL=wV;var SV=s=>od(s.toArray().flat(),"EPSG:4326","EPSG:3857"),Uw=SV;var Gw=class extends xg(Ig){constructor(e={}){let t=document.createElement("canvas");super({canvas:t,id:"realtime",...e}),this.source={id:this.id,type:"canvas",canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],animate:!0,attribution:e.attribution?.join(", "),loaded:!0},this.layer={id:`${this.id}-raster`,type:"raster",source:this.id,layout:{visibility:"visible"},paint:{"raster-opacity":1,"raster-fade-duration":0,"raster-resampling":"nearest"}},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}onAdd(e,t){super.onAdd(e,t),e.isStyleLoaded()&&this.onLoad(),e.on("load",this.onLoad)}onRemove(e,t){e.off("load",this.onLoad),e.getLayer(this.layer.id)&&e.removeLayer(this.layer.id),e.getSource(this.id)&&e.removeSource(this.id),super.onRemove(e,t)}onLoad(){this.map.getSource(this.id)||this.map.addSource(this.id,this.source),this.map.getLayer(this.layer.id)||this.map.addLayer(this.layer,this.id),this.start()}start(){super.start(),this.map.on("move",this.onMove),this.map.on("moveend",this.onMoveEnd),this.map.on("zoomend",this.onZoomEnd)}stop(){super.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}renderTrajectories(e=!1){if(!this.map)return;this.pixelRatio||(this.pixelRatio=1);let{width:t,height:a}=this.map.getCanvas(),l=this.map.getCenter(),o=this.map.unproject({x:0,y:a/this.pixelRatio}),m=this.map.unproject({x:t/this.pixelRatio,y:0}),g=Nw(Hi([o.lng,o.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,b=Nw(Hi([m.lng,m.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,A=[...Ii(g),...Ii(b)],S=Fr(A)/(t/this.pixelRatio),M=hi(A)/(a/this.pixelRatio),R=Math.max(S,M),j={size:[t/this.pixelRatio,a/this.pixelRatio],center:Ii([l.lng,l.lat]),extent:A,resolution:R,zoom:this.map.getZoom()-1,rotation:-(this.map.getBearing()*Math.PI)/180,pixelRatio:this.pixelRatio};super.renderTrajectories(j,e)}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getZoom())}purgeTrajectory(e,t,a){return super.purgeTrajectory(e,t||Uw(this.map.getBounds()),a||Math.floor(this.map.getZoom()-1))}setBbox(e,t){super.setBbox(e||Uw(this.map.getBounds()),t||this.map.getZoom()-1)}renderTrajectoriesInternal(e,t=!1){let a=super.renderTrajectoriesInternal(e,t);if(a&&this.map.style){let l=Ny(this.map,this.pixelRatio),o=this.map.getSource(this.id);o&&o.setCoordinates(l)}return a}onMove(){this.renderTrajectories()}onMoveEnd(){this.renderTrajectories(),this.isUpdateBboxOnMoveEnd&&this.setBbox()}},_L=Gw;var Vw={ol:Sg,maplibre:Uy};typeof window<"u"&&(window.mbt=Vw);var Toe=Vw;})();
|
|
589
589
|
/*! Bundled license information:
|
|
590
590
|
|
|
591
591
|
maplibre-gl/dist/maplibre-gl.js:
|