mobility-toolbox-js 3.0.0-beta.22 → 3.0.0-beta.24

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.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 k=e[A+1]||s.font,j=cg(k,M);t.push(j),m+=j;let Z=Tz(k);a.push(Z),b=Math.max(b,Z)}return{width:o,height:g,widths:t,heights:a,lineWidths:l}}function yI(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]),Cz(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 Cz(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 $0=class s extends lg{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()?Mt.LOADING:Mt.LOADED,this.imageState_===Mt.LOADING&&this.ready().then(()=>this.imageState_=Mt.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=Xr(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 _e=l;l=o,o=_e}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),k=M/b;if(e==="miter"&&k<=a)return k*t;let j=t/2/k,Z=t/2*(S/M),q=Math.sqrt((l+j)*(l+j)+Z*Z)-l;if(this.radius2_===void 0||e==="bevel")return q*2;let H=l*Math.sin(g),ae=Math.sqrt(l*l-H*H),pe=o-ae,de=Math.sqrt(H*H+pe*pe)/H;if(de<=a){let _e=de*t/2-o-l;return 2*Math.max(q,_e)}return q*2}createRenderOptions(){let e=ys,t=_s,a=0,l=null,o=0,m,g=0;this.stroke_&&(m=jn(this.stroke_.getColor()??oa),g=this.stroke_.getWidth()??aa,l=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset()??0,t=this.stroke_.getLineJoin()??_s,e=this.stroke_.getLineCap()??ys,a=this.stroke_.getMiterLimit()??na);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=li),t.fillStyle=jn(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=ia(a)),a===null?l=1:Array.isArray(a)&&(l=a.length===4?a[3]:1),l===0&&(t=Xr(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=li,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()}},hg=$0;var W0=class s extends hg{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=W0;var Ha=class s{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=_I,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_=_I,this.geometry_=e}setZIndex(e){this.zIndex_=e}};function xI(s){let e;if(typeof s=="function")e=s;else{let t;Array.isArray(s)?t=s:(Ar(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),t=[s]),e=function(){return t}}return e}var Z0=null;function X0(s,e){if(!Z0){let t=new qi({color:"rgba(255,255,255,0.4)"}),a=new ai({color:"#3399CC",width:1.25});Z0=[new Ha({image:new Vn({fill:t,stroke:a,radius:5}),fill:t,stroke:a})]}return Z0}function vI(){let s={},e=[255,255,255,1],t=[0,153,255,1],a=3;return s.Polygon=[new Ha({fill:new qi({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new Ha({stroke:new ai({color:e,width:a+2})}),new Ha({stroke:new ai({color:t,width:a})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new Ha({image:new Vn({radius:a*2,fill:new qi({color:t}),stroke:new ai({color:e,width:a/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function _I(s){return s.getGeometry()}var $i=Ha;var Mz="#333",H0=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 qi({color:Mz}),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}},bI=H0;var LI=ao(J0(),1);function wI(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 Q0=class s extends lg{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;Ar(!(g!==void 0&&m),"`image` and `src` cannot be provided at the same time"),(g===void 0||g.length===0)&&m&&(g=m.src||Ut(m)),Ar(g!==void 0&&g.length>0,"A defined and non-empty `src` or `image` must be provided"),Ar(!((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=Mt.IDLE:m!==void 0&&("complete"in m?m.complete?b=m.src?Mt.LOADED:Mt.IDLE:b=Mt.LOADING:b=Mt.LOADED),this.color_=e.color!==void 0?ia(e.color):null,this.iconImage_=ku(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 k=()=>{if(this.unlistenImageChange(k),!this.initialOptions_)return;let j=this.iconImage_.getSize();this.setScale(wI(j[0],j[1],e.width,e.height))};this.listenImageChange(k);return}}A!==void 0&&this.setScale(wI(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()==Mt.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()==Mt.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(Ir.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(Ir.CHANGE,e)}ready(){return this.iconImage_.ready()}},Dd=Q0;var Kl=0,Lu=0,Nr=1<<Kl++,gt=1<<Kl++,qn=1<<Kl++,ri=1<<Kl++,Zo=1<<Kl++,zd=1<<Kl++,un=Math.pow(2,Kl)-1,AI={[Nr]:"boolean",[gt]:"number",[qn]:"string",[ri]:"color",[Zo]:"number[]",[zd]:"size"},Rz=Object.keys(AI).map(Number).sort(Bo);function Wi(s){let e=[];for(let t of Rz)kz(s,t)&&e.push(AI[t]);return e.length===0?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function kz(s,e){return(s&e)===e}function Xo(s,e){return!!(s&e)}function pg(s,e){return s===e}var Wo=class{constructor(e,t){this.type=e,this.value=t}},ev=class{constructor(e,t,...a){this.type=e,this.operator=t,this.args=a}};function tv(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,style:{}}}function Fz(s){switch(s){case"string":return qn;case"color":return ri;case"number":return gt;case"boolean":return Nr;case"number[]":return Zo;default:throw new Error(`Unrecognized type hint: ${s}`)}}function cr(s,e,t){switch(typeof s){case"boolean":return new Wo(Nr,s);case"number":return new Wo(t===zd?zd:gt,s);case"string":{let l=qn;return hI(s)&&(l|=ri),pg(l&t,Lu)||(l&=t),new Wo(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 $z(s,e,t);for(let l of s)if(typeof l!="number")throw new Error("Expected an array of numbers");let a=Zo;return s.length===2?a|=zd:(s.length===3||s.length===4)&&(a|=ri),t&&(a&=t),new Wo(a,s)}var Fe={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"},Lz={[Fe.Get]:Ft(([s,e])=>e!==void 0?Fz(e.value):un,zt(1,2),Dz),[Fe.Var]:Ft(([s])=>s.type,zt(1,1),Oz),[Fe.Id]:Ft(gt|qn,Od,zz),[Fe.Concat]:Ft(qn,zt(2,1/0),rr(un)),[Fe.GeometryType]:Ft(qn,Od,Bz),[Fe.Resolution]:Ft(gt,Od),[Fe.Zoom]:Ft(gt,Od),[Fe.Time]:Ft(gt,Od),[Fe.Any]:Ft(Nr,zt(2,1/0),rr(Nr)),[Fe.All]:Ft(Nr,zt(2,1/0),rr(Nr)),[Fe.Not]:Ft(Nr,zt(1,1),rr(Nr)),[Fe.Equal]:Ft(Nr,zt(2,2),rr(un),Ka),[Fe.NotEqual]:Ft(Nr,zt(2,2),rr(un),Ka),[Fe.GreaterThan]:Ft(Nr,zt(2,2),rr(un),Ka),[Fe.GreaterThanOrEqualTo]:Ft(Nr,zt(2,2),rr(un),Ka),[Fe.LessThan]:Ft(Nr,zt(2,2),rr(un),Ka),[Fe.LessThanOrEqualTo]:Ft(Nr,zt(2,2),rr(un),Ka),[Fe.Multiply]:Ft(s=>{let e=gt|ri;for(let t=0;t<s.length;t++)e&=s[t].type;return e},zt(2,1/0),rr(gt|ri),Ka),[Fe.Coalesce]:Ft(s=>{let e=un;for(let t=1;t<s.length;t+=2)e&=s[t].type;return e&=s[s.length-1].type,e},zt(2,1/0),rr(un),Ka),[Fe.Divide]:Ft(gt,zt(2,2),rr(gt)),[Fe.Add]:Ft(gt,zt(2,1/0),rr(gt)),[Fe.Subtract]:Ft(gt,zt(2,2),rr(gt)),[Fe.Clamp]:Ft(gt,zt(3,3),rr(gt)),[Fe.Mod]:Ft(gt,zt(2,2),rr(gt)),[Fe.Pow]:Ft(gt,zt(2,2),rr(gt)),[Fe.Abs]:Ft(gt,zt(1,1),rr(gt)),[Fe.Floor]:Ft(gt,zt(1,1),rr(gt)),[Fe.Ceil]:Ft(gt,zt(1,1),rr(gt)),[Fe.Round]:Ft(gt,zt(1,1),rr(gt)),[Fe.Sin]:Ft(gt,zt(1,1),rr(gt)),[Fe.Cos]:Ft(gt,zt(1,1),rr(gt)),[Fe.Atan]:Ft(gt,zt(1,2),rr(gt)),[Fe.Sqrt]:Ft(gt,zt(1,1),rr(gt)),[Fe.Match]:Ft(s=>{let e=un;for(let t=2;t<s.length;t+=2)e&=s[t].type;return e&=s[s.length-1].type,e},zt(4,1/0),SI,jz),[Fe.Between]:Ft(Nr,zt(3,3),rr(gt)),[Fe.Interpolate]:Ft(s=>{let e=ri|gt;for(let t=3;t<s.length;t+=2)e&=s[t].type;return e},zt(6,1/0),SI,Uz),[Fe.Case]:Ft(s=>{let e=un;for(let t=1;t<s.length;t+=2)e&=s[t].type;return e&=s[s.length-1].type,e},zt(3,1/0),Nz,Gz),[Fe.In]:Ft(Nr,zt(2,2),Vz),[Fe.Number]:Ft(gt,zt(1,1/0),rr(un)),[Fe.String]:Ft(qn,zt(1,1/0),rr(un)),[Fe.Array]:Ft(s=>s.length===2?Zo|zd:s.length===3||s.length===4?Zo|ri:Zo,zt(1,1/0),rr(gt)),[Fe.Color]:Ft(ri,zt(1,4),rr(gt)),[Fe.Band]:Ft(gt,zt(1,3),rr(gt)),[Fe.Palette]:Ft(ri,zt(2,2),qz),[Fe.ToString]:Ft(qn,zt(1,1),rr(Nr|gt|qn|ri))};function Dz(s,e){let t=cr(s[1],e);if(!(t instanceof Wo))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 Oz(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 Wo(un,l)];let o=e.style.variables[l],m=cr(o,e);if(m.value=l,a&&!Xo(a,m.type))throw new Error(`The variable ${l} has type ${Wi(m.type)} but the following type was expected: ${Wi(a)}`);return[m]}function zz(s,e){e.featureId=!0}function Bz(s,e){e.geometryType=!0}function Od(s,e){let t=s[0];if(s.length!==1)throw new Error(`Expected no arguments for ${t} operation`);return[]}function zt(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 rr(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(!Xo(s,g.type)){let b=Wi(s),A=Wi(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 Ka(s,e,t){let a=s[0],l=s.length-1,o=un;for(let g=0;g<t.length;++g)o&=t[g].type;if(o===Lu)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 Nz(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 SI(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 jz(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 k=cr(s[M+2],e),j=cr(s[M+3],e);m&=k.type,b&=j.type,A[M]=k,A[M+1]=j}let S=qn|gt|Nr;if(!Xo(S,m))throw new Error(`Expected an input of type ${Wi(S)} for the interpolate operation, got ${Wi(m)} instead`);if(m&=S,pg(b,Lu))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 k=cr(s[M+2],e,m),j=cr(s[M+3],e,b);A[M]=k,A[M+1]=j}return[cr(s[1],e,m),...A,cr(s[s.length-1],e,b)]}function Uz(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(!Xo(gt,m.type))throw new Error(`Expected an input of type number for the interpolate operation, got ${Wi(m.type)} instead`);m=cr(s[2],e,gt);let g=new Array(s.length-3);for(let b=0;b<g.length;b+=2){let A=cr(s[b+3],e);if(!Xo(gt,A.type))throw new Error(`Expected all stop input values in the interpolate operation to be of type number, got ${Wi(A.type)} at position ${b+2} instead`);let S=cr(s[b+4],e);if(!Xo(gt|ri,S.type))throw new Error(`Expected all stop output values in the interpolate operation to be a number or color, got ${Wi(S.type)} at position ${b+3} instead`);A=cr(s[b+3],e,gt),S=cr(s[b+4],e,gt|ri),g[b]=A,g[b+1]=S}return[o,m,...g]}function Gz(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(!Xo(Nr,b.type))throw new Error(`Expected all conditions in the case operation to be of type boolean, got ${Wi(b.type)} at position ${g} instead`);o&=A.type,m[g]=b,m[g+1]=A}if(pg(o,Lu))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 Vz(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|gt,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(pg(a,Lu))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 qz(s,e){let t=cr(s[1],e,gt);if(t.type!==gt)throw new Error(`The first argument of palette must be an number, got ${Wi(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,ri);if(!(m instanceof Wo))throw new Error(`The palette color at index ${o} must be a literal value`);if(!Xo(m.type,ri))throw new Error(`The palette color at index ${o} should be of type color, got ${Wi(m.type)} instead`);l[o]=m}return[t,...l]}function Ft(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(!Xo(g,l))throw new Error(`The following expression was expected to return ${Wi(l)}, but returns ${Wi(g)} instead: ${JSON.stringify(t)}`);g&=l}if(g===Lu)throw new Error(`No matching type was found for the following expression: ${JSON.stringify(t)}`);return new ev(g,o,...m)}}function $z(s,e,t){let a=s[0],l=Lz[a];if(!l)throw new Error(`Unknown operator: ${a}`);return l(s,e,t)}function rv(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 rv(s.getGeometries()[0]);default:return""}}function iv(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function xs(s,e,t){let a=cr(s,t);if(!Xo(e,a.type)){let l=Wi(e),o=Wi(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 Wo){if(s.type===ri&&typeof s.value=="string"){let a=ag(s.value);return function(){return a}}return function(){return s.value}}let t=s.operator;switch(t){case Fe.Number:case Fe.String:case Fe.Coalesce:return Wz(s,e);case Fe.Get:case Fe.Var:return Zz(s,e);case Fe.Id:return a=>a.featureId;case Fe.GeometryType:return a=>a.geometryType;case Fe.Concat:{let a=s.args.map(l=>Ho(l,e));return l=>"".concat(...a.map(o=>o(l).toString()))}case Fe.Resolution:return a=>a.resolution;case Fe.Any:case Fe.All:case Fe.Between:case Fe.In:case Fe.Not:return Hz(s,e);case Fe.Equal:case Fe.NotEqual:case Fe.LessThan:case Fe.LessThanOrEqualTo:case Fe.GreaterThan:case Fe.GreaterThanOrEqualTo:return Xz(s,e);case Fe.Multiply:case Fe.Divide:case Fe.Add:case Fe.Subtract:case Fe.Clamp:case Fe.Mod:case Fe.Pow:case Fe.Abs:case Fe.Floor:case Fe.Ceil:case Fe.Round:case Fe.Sin:case Fe.Cos:case Fe.Atan:case Fe.Sqrt:return Kz(s,e);case Fe.Case:return Yz(s,e);case Fe.Match:return Jz(s,e);case Fe.Interpolate:return Qz(s,e);case Fe.ToString:return eB(s,e);default:throw new Error(`Unsupported operator ${t}`)}}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 Fe.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 Fe.Number:case Fe.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 Zz(s,e){let a=s.args[0].value;switch(s.operator){case Fe.Get:return l=>l.properties[a];case Fe.Var:return l=>l.variables[a];default:throw new Error(`Unsupported accessor operator ${s.operator}`)}}function Xz(s,e){let t=s.operator,a=Ho(s.args[0],e),l=Ho(s.args[1],e);switch(t){case Fe.Equal:return o=>a(o)===l(o);case Fe.NotEqual:return o=>a(o)!==l(o);case Fe.LessThan:return o=>a(o)<l(o);case Fe.LessThanOrEqualTo:return o=>a(o)<=l(o);case Fe.GreaterThan:return o=>a(o)>l(o);case Fe.GreaterThanOrEqualTo:return o=>a(o)>=l(o);default:throw new Error(`Unsupported comparison operator ${t}`)}}function Hz(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 Fe.Any:return o=>{for(let m=0;m<a;++m)if(l[m](o))return!0;return!1};case Fe.All:return o=>{for(let m=0;m<a;++m)if(!l[m](o))return!1;return!0};case Fe.Between:return o=>{let m=l[0](o),g=l[1](o),b=l[2](o);return m>=g&&m<=b};case Fe.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 Fe.Not:return o=>!l[0](o);default:throw new Error(`Unsupported logical operator ${t}`)}}function Kz(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 Fe.Multiply:return o=>{let m=1;for(let g=0;g<a;++g)m*=l[g](o);return m};case Fe.Divide:return o=>l[0](o)/l[1](o);case Fe.Add:return o=>{let m=0;for(let g=0;g<a;++g)m+=l[g](o);return m};case Fe.Subtract:return o=>l[0](o)-l[1](o);case Fe.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 Fe.Mod:return o=>l[0](o)%l[1](o);case Fe.Pow:return o=>Math.pow(l[0](o),l[1](o));case Fe.Abs:return o=>Math.abs(l[0](o));case Fe.Floor:return o=>Math.floor(l[0](o));case Fe.Ceil:return o=>Math.ceil(l[0](o));case Fe.Round:return o=>Math.round(l[0](o));case Fe.Sin:return o=>Math.sin(l[0](o));case Fe.Cos:return o=>Math.cos(l[0](o));case Fe.Atan:return a===2?o=>Math.atan2(l[0](o),l[1](o)):o=>Math.atan(l[0](o));case Fe.Sqrt:return o=>Math.sqrt(l[0](o));default:throw new Error(`Unsupported numeric operator ${t}`)}}function Yz(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 Jz(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 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),m=a[1](l),g,b;for(let A=2;A<t;A+=2){let S=a[A](l),M=a[A+1](l),k=Array.isArray(M);if(k&&(M=cI(M)),S>=m)return A===2?M:k?tB(o,m,g,b,S,M):Bd(o,m,g,b,S,M);g=S,b=M}return b}}function eB(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 Fe.ToString:return o=>{let m=l[0](o);return s.args[0].type===ri?Fd(m):m.toString()};default:throw new Error(`Unsupported convert operator ${t}`)}}function Bd(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 tB(s,e,t,a,l,o){if(l-t===0)return a;let g=F0(a),b=F0(o),A=b[2]-g[2];A>180?A-=360:A<-180&&(A+=360);let S=[Bd(s,e,t,g[0],l,b[0]),Bd(s,e,t,g[1],l,b[1]),g[2]+Bd(s,e,t,0,l,A),Bd(s,e,t,a[3],l,o[3])];return L0(uI(S))}function rB(s){return!0}function TI(s){let e=tv(),t=iB(s,e),a=iv();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=rv(l.getGeometry())),t(a)}}function sv(s){let e=tv(),t=s.length,a=new Array(t);for(let m=0;m<t;++m)a[m]=nv(s[m],e);let l=iv(),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 iB(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?xs(o.filter,Nr,e):rB,g;if(Array.isArray(o.style)){let b=o.style.length;g=new Array(b);for(let A=0;A<b;++A)g[A]=nv(o.style[A],e)}else g=[nv(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 nv(s,e){let t=Nd(s,"",e),a=jd(s,"",e),l=nB(s,e),o=oB(s,e),m=$n(s,"z-index",e);if(!t&&!a&&!l&&!o&&!lo(s))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(s));let g=new $i;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 Nd(s,e,t){let a;if(e+"fill-pattern-src"in s?a=cB(s,e+"fill-",t):a=av(s,e+"fill-color",t),!a)return null;let l=new qi;return function(o){let m=a(o);return m==="none"?null:(l.setColor(m),l)}}function jd(s,e,t){let a=$n(s,e+"stroke-width",t),l=av(s,e+"stroke-color",t);if(!a&&!l)return null;let o=la(s,e+"stroke-line-cap",t),m=la(s,e+"stroke-line-join",t),g=CI(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 ai;return function(M){if(l){let k=l(M);if(k==="none")return null;S.setColor(k)}if(a&&S.setWidth(a(M)),o){let k=o(M);if(k!=="butt"&&k!=="round"&&k!=="square")throw new Error("Expected butt, round, or square line cap");S.setLineCap(k)}if(m){let k=m(M);if(k!=="bevel"&&k!=="round"&&k!=="miter")throw new Error("Expected bevel, round, or miter line join");S.setLineJoin(k)}return g&&S.setLineDash(g(M)),b&&S.setLineDashOffset(b(M)),A&&S.setMiterLimit(A(M)),S}}function nB(s,e){let t="text-",a=la(s,t+"value",e);if(!a)return null;let l=Nd(s,t,e),o=Nd(s,t+"background-",e),m=jd(s,t,e),g=jd(s,t+"background-",e),b=la(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),k=Ud(s,t+"overflow",e),j=la(s,t+"placement",e),Z=$n(s,t+"repeat",e),te=mg(s,t+"scale",e),q=Ud(s,t+"rotate-with-view",e),H=$n(s,t+"rotation",e),ae=la(s,t+"align",e),pe=la(s,t+"justify",e),ve=la(s,t+"baseline",e),de=CI(s,t+"padding",e),_e=gg(s,t+"declutter-mode"),Pe=new bI({declutterMode:_e});return function(Re){if(Pe.setText(a(Re)),l&&Pe.setFill(l(Re)),o&&Pe.setBackgroundFill(o(Re)),m&&Pe.setStroke(m(Re)),g&&Pe.setBackgroundStroke(g(Re)),b&&Pe.setFont(b(Re)),A&&Pe.setMaxAngle(A(Re)),S&&Pe.setOffsetX(S(Re)),M&&Pe.setOffsetY(M(Re)),k&&Pe.setOverflow(k(Re)),j){let Ae=j(Re);if(Ae!=="point"&&Ae!=="line")throw new Error("Expected point or line for text-placement");Pe.setPlacement(Ae)}if(Z&&Pe.setRepeat(Z(Re)),te&&Pe.setScale(te(Re)),q&&Pe.setRotateWithView(q(Re)),H&&Pe.setRotation(H(Re)),ae){let Ae=ae(Re);if(Ae!=="left"&&Ae!=="center"&&Ae!=="right"&&Ae!=="end"&&Ae!=="start")throw new Error("Expected left, right, center, start, or end for text-align");Pe.setTextAlign(Ae)}if(pe){let Ae=pe(Re);if(Ae!=="left"&&Ae!=="right"&&Ae!=="center")throw new Error("Expected left, right, or center for text-justify");Pe.setJustify(Ae)}if(ve){let Ae=ve(Re);if(Ae!=="bottom"&&Ae!=="top"&&Ae!=="middle"&&Ae!=="alphabetic"&&Ae!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");Pe.setTextBaseline(Ae)}return de&&Pe.setPadding(de(Re)),Pe}}function oB(s,e){return"icon-src"in s?sB(s,e):"shape-points"in s?aB(s,e):"circle-radius"in s?lB(s,e):null}function sB(s,e){let t="icon-",a=t+"src",l=MI(s[a],a),o=dg(s,t+"anchor",e),m=mg(s,t+"scale",e),g=$n(s,t+"opacity",e),b=dg(s,t+"displacement",e),A=$n(s,t+"rotation",e),S=Ud(s,t+"rotate-with-view",e),M=II(s,t+"anchor-origin"),k=PI(s,t+"anchor-x-units"),j=PI(s,t+"anchor-y-units"),Z=dB(s,t+"color"),te=hB(s,t+"cross-origin"),q=pB(s,t+"offset"),H=II(s,t+"offset-origin"),ae=fg(s,t+"width"),pe=fg(s,t+"height"),ve=uB(s,t+"size"),de=gg(s,t+"declutter-mode"),_e=new Dd({src:l,anchorOrigin:M,anchorXUnits:k,anchorYUnits:j,color:Z,crossOrigin:te,offset:q,offsetOrigin:H,height:pe,width:ae,size:ve,declutterMode:de});return function(Pe){return g&&_e.setOpacity(g(Pe)),b&&_e.setDisplacement(b(Pe)),A&&_e.setRotation(A(Pe)),S&&_e.setRotateWithView(S(Pe)),m&&_e.setScale(m(Pe)),o&&_e.setAnchor(o(Pe)),_e}}function aB(s,e){let t="shape-",a=t+"points",l=t+"radius",o=ov(s[a],a),m=ov(s[l],l),g=Nd(s,t,e),b=jd(s,t,e),A=mg(s,t+"scale",e),S=dg(s,t+"displacement",e),M=$n(s,t+"rotation",e),k=Ud(s,t+"rotate-with-view",e),j=fg(s,t+"radius2"),Z=fg(s,t+"angle"),te=gg(s,t+"declutter-mode"),q=new hg({points:o,radius:m,radius2:j,angle:Z,declutterMode:te});return function(H){return g&&q.setFill(g(H)),b&&q.setStroke(b(H)),S&&q.setDisplacement(S(H)),M&&q.setRotation(M(H)),k&&q.setRotateWithView(k(H)),A&&q.setScale(A(H)),q}}function lB(s,e){let t="circle-",a=Nd(s,t,e),l=jd(s,t,e),o=$n(s,t+"radius",e),m=mg(s,t+"scale",e),g=dg(s,t+"displacement",e),b=$n(s,t+"rotation",e),A=Ud(s,t+"rotate-with-view",e),S=gg(s,t+"declutter-mode"),M=new Vn({radius:5,declutterMode:S});return function(k){return o&&M.setRadius(o(k)),a&&M.setFill(a(k)),l&&M.setStroke(l(k)),g&&M.setDisplacement(g(k)),b&&M.setRotation(b(k)),A&&M.setRotateWithView(A(k)),m&&M.setScale(m(k)),M}}function $n(s,e,t){if(!(e in s))return;let a=xs(s[e],gt,t);return function(l){return ov(a(l),e)}}function la(s,e,t){if(!(e in s))return null;let a=xs(s[e],qn,t);return function(l){return MI(a(l),e)}}function cB(s,e,t){let a=la(s,e+"pattern-src",t),l=EI(s,e+"pattern-offset",t),o=EI(s,e+"pattern-size",t),m=av(s,e+"color",t);return function(g){return{src:a(g),offset:l&&l(g),size:o&&o(g),color:m&&m(g)}}}function Ud(s,e,t){if(!(e in s))return null;let a=xs(s[e],Nr,t);return function(l){let o=a(l);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${e}`);return o}}function av(s,e,t){if(!(e in s))return null;let a=xs(s[e],ri|qn,t);return function(l){return RI(a(l),e)}}function CI(s,e,t){if(!(e in s))return null;let a=xs(s[e],Zo,t);return function(l){return Gd(a(l),e)}}function dg(s,e,t){if(!(e in s))return null;let a=xs(s[e],Zo,t);return function(l){let o=Gd(a(l),e);if(o.length!==2)throw new Error(`Expected two numbers for ${e}`);return o}}function EI(s,e,t){if(!(e in s))return null;let a=xs(s[e],Zo,t);return function(l){return kI(a(l),e)}}function mg(s,e,t){if(!(e in s))return null;let a=xs(s[e],Zo|gt,t);return function(l){return fB(a(l),e)}}function fg(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 uB(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 hB(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 II(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 PI(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 pB(s,e){let t=s[e];if(t!==void 0)return Gd(t,e)}function gg(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 dB(s,e){let t=s[e];if(t!==void 0)return RI(t,e)}function Gd(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 MI(s,e){if(typeof s!="string")throw new Error(`Expected a string for ${e}`);return s}function ov(s,e){if(typeof s!="number")throw new Error(`Expected a number for ${e}`);return s}function RI(s,e){if(typeof s=="string")return s;let t=Gd(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 kI(s,e){let t=Gd(s,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function fB(s,e){return typeof s=="number"?s:kI(s,e)}var FI={RENDER_ORDER:"renderOrder"},lv=class extends qo{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(FI.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 LI.default(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(FI.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?X0:e;let t=mB(e);this.styleFunction_=e===null?void 0:xI(t),this.changed()}};function mB(s){if(s===void 0)return X0;if(!s)return null;if(typeof s=="function"||s instanceof $i)return s;if(!Array.isArray(s))return sv([s]);if(s.length===0)return[];let e=s.length,t=s[0];if(t instanceof $i){let l=new Array(e);for(let o=0;o<e;++o){let m=s[o];if(!(m instanceof $i))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 TI(l)}return sv(s)}var DI=lv;var Vd={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},qd=[Vd.FILL],vs=[Vd.STROKE],ca=[Vd.BEGIN_PATH],cv=[Vd.CLOSE_PATH],xt=Vd;var uv=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){}},yg=uv;var hv=class extends yg{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],Js(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],k=this.tmpCoordinate_,j=!0,Z,te,q;for(Z=t+l;Z<a;Z+=l)k[0]=e[Z],k[1]=e[Z+1],q=Nm(A,k),q!==te?(j&&(g[b++]=S,g[b++]=M,j=!1),g[b++]=k[0],g[b++]=k[1]):q===Qr.INTERSECTING?(g[b++]=k[0],g[b++]=k[1],j=!1):j=!0,S=k[0],M=k[1],te=q;return(o&&j||Z===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,k,j;switch(m){case"MultiPolygon":A=e.getOrientedFlatCoordinates(),k=[];let Z=e.getEndss();j=0;for(let te=0,q=Z.length;te<q;++te){let H=[];j=this.drawCustomCoordinates_(A,j,Z[te],g,H),k.push(H)}this.instructions.push([xt.CUSTOM,b,k,e,a,xd,o]),this.hitDetectionInstructions.push([xt.CUSTOM,b,k,e,l||a,xd,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,wo,o]),this.hitDetectionInstructions.push([xt.CUSTOM,b,S,e,l||a,wo,o]);break;case"MultiPoint":A=e.getFlatCoordinates(),S=this.appendFlatPointCoordinates(A,g),S>b&&(this.instructions.push([xt.CUSTOM,b,S,e,a,wo,o]),this.hitDetectionInstructions.push([xt.CUSTOM,b,S,e,l||a,wo,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,$A(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=jn(l||li)}else a.fillStyle=void 0;if(t){let l=t.getColor();a.strokeStyle=jn(l||oa);let o=t.getLineCap();a.lineCap=o!==void 0?o:ys;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:_s;let A=t.getWidth();a.lineWidth=A!==void 0?A:aa;let S=t.getMiterLimit();a.miterLimit=S!==void 0?S:na,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_=WA(this.maxExtent),this.maxLineWidth>0)){let e=this.resolution*(this.maxLineWidth+1)/2;Ln(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},bs=hv;var pv=class extends bs{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&&!Js(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||Js(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}},OI=pv;var dv=class extends bs{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],ca);let g=e.getFlatCoordinates(),b=e.getStride();this.drawFlatCoordinates_(g,0,g.length,b),this.hitDetectionInstructions.push(vs),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],ca);let g=e.getEnds(),b=e.getFlatCoordinates(),A=e.getStride(),S=0;for(let M=0,k=g.length;M<k;++M)S=this.drawFlatCoordinates_(b,S,g[M],A);this.hitDetectionInstructions.push(vs),this.endGeometry(t)}finish(){let e=this.state;return e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&this.instructions.push(vs),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(e){e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&(this.instructions.push(vs),e.lastStroke=this.coordinates.length),e.lastStroke=0,super.applyStroke(e),this.instructions.push(ca)}},zI=dv;var fv=class extends bs{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(ca),this.hitDetectionInstructions.push(ca);for(let A=0;A<b;++A){let S=a[A],M=this.coordinates.length,k=this.appendFlatLineCoordinates(e,t,S,l,!0,!g),j=[xt.MOVE_TO_LINE_TO,M,k];this.instructions.push(j),this.hitDetectionInstructions.push(j),g&&(this.instructions.push(cv),this.hitDetectionInstructions.push(cv)),t=S}return m&&(this.instructions.push(qd),this.hitDetectionInstructions.push(qd)),g&&(this.instructions.push(vs),this.hitDetectionInstructions.push(vs)),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,li]),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(ca,S),this.hitDetectionInstructions.push(ca,S),l.fillStyle!==void 0&&(this.instructions.push(qd),this.hitDetectionInstructions.push(qd)),l.strokeStyle!==void 0&&(this.instructions.push(vs),this.hitDetectionInstructions.push(vs)),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,li]),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,li]),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,k=g.length;M<k;++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)}},mv=fv;function BI(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],k=e[m+l+1],j=Math.sqrt((M-A)*(M-A)+(k-S)*(k-S));if(g+=j,g>=s){let Z=(s-g+j)/j,te=Gi(A,M,Z),q=Gi(S,k,Z);b.push(te,q),o.push(b),b=[te,q],g==s&&(m+=l),g=0}else if(g<s)b.push(e[m+l],e[m+l+1]),m+=l;else{let Z=j-g,te=Gi(A,M,Z/j),q=Gi(S,k,Z/j);b.push(te,q),o.push(b),b=[te,q],g=0,m+=l}}return g>0&&o.push(b),o}function NI(s,e,t,a,l){let o=t,m=t,g=0,b=0,A=t,S,M,k,j,Z,te,q,H,ae,pe;for(M=t;M<a;M+=l){let ve=e[M],de=e[M+1];Z!==void 0&&(ae=ve-Z,pe=de-te,j=Math.sqrt(ae*ae+pe*pe),q!==void 0&&(b+=k,S=Math.acos((q*ae+H*pe)/(k*j)),S>s&&(b>g&&(g=b,o=A,m=M),b=0,A=M-l)),k=j,q=ae,H=pe),Z=ve,te=de}return b+=j,b>g?[A,M]:[o,m]}var $d={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},gv=class extends bs{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[li]={fillStyle:li},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(!ei(this.maxExtent,e.getExtent()))return;let k;if(S=e.getFlatCoordinates(),A=="LineString")k=[S.length];else if(A=="MultiLineString")k=e.getEnds();else if(A=="Polygon")k=e.getEnds().slice(0,1);else if(A=="MultiPolygon"){let q=e.getEndss();k=[];for(let H=0,ae=q.length;H<ae;++H)k.push(q[H][0])}this.beginGeometry(e,t,a);let j=m.repeat,Z=j?void 0:m.textAlign,te=0;for(let q=0,H=k.length;q<H;++q){let ae;j?ae=BI(j*this.resolution,S,te,k[q],M):ae=[S.slice(te,k[q])];for(let pe=0,ve=ae.length;pe<ve;++pe){let de=ae[pe],_e=0,Pe=de.length;if(Z==null){let Ae=NI(m.maxAngle,de,0,de.length,2);_e=Ae[0],Pe=Ae[1]}for(let Ae=_e;Ae<Pe;Ae+=M)g.push(de[Ae],de[Ae+1]);let Re=g.length;te=k[q],this.drawChars_(b,Re),b=Re}}this.endGeometry(t)}else{let k=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||k.push(S[2]/this.resolution),M=3;break;case"MultiPolygon":let ae=e.getFlatInteriorPoints();S=[];for(let pe=0,ve=ae.length;pe<ve;pe+=3)m.overflow||k.push(ae[pe+2]/this.resolution),S.push(ae[pe],ae[pe+1]);if(S.length===0)return;M=2;break;default:}let j=this.appendFlatPointCoordinates(S,M);if(j===b)return;if(k&&(j-b)/2!==S.length/M){let ae=b/2;k=k.filter((pe,ve)=>{let de=g[(ae+ve)*2]===S[ve*M]&&g[(ae+ve)*2+1]===S[ve*M+1];return de||--ae,de})}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 Z=m.padding;if(Z!=sa&&(m.scale[0]<0||m.scale[1]<0)){let ae=m.padding[0],pe=m.padding[1],ve=m.padding[2],de=m.padding[3];m.scale[0]<0&&(pe=-pe,de=-de),m.scale[1]<0&&(ae=-ae,ve=-ve),Z=[ae,pe,ve,de]}let te=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_,Z==sa?sa:Z.map(function(ae){return ae*te}),!!m.backgroundFill,!!m.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,k]);let q=1/te,H=this.state.fillStyle;m.backgroundFill&&(this.state.fillStyle=li,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_,[q,q],NaN,this.declutterMode_,this.declutterImageWithText_,Z,!!m.backgroundFill,!!m.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?li:this.fillKey_,this.textOffsetX_,this.textOffsetY_,k]),m.backgroundFill&&(this.state.fillStyle=H,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||Xa,justify:t.justify,textBaseline:t.textBaseline||Hl,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=$d[l.textBaseline],S=this.textOffsetY_*b,M=this.text_,k=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,k*b,M,m,1,this.declutterMode_]),this.hitDetectionInstructions.push([xt.DRAW_CHARS,e,t,A,l.overflow,g&&li,l.maxAngle,b,S,o,k*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=jn(m.getColor()||li)):(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 Z=g.getLineDash(),te=g.getLineDashOffset(),q=g.getWidth(),H=g.getMiterLimit();o.lineCap=g.getLineCap()||ys,o.lineDash=Z?Z.slice():Un,o.lineDashOffset=te===void 0?Gn:te,o.lineJoin=g.getLineJoin()||_s,o.lineWidth=q===void 0?aa:q,o.miterLimit=H===void 0?na:H,o.strokeStyle=jn(g.getColor()||oa)}a=this.textState_;let b=e.getFont()||ug;fI(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()||Hl,a.backgroundFill=e.getBackgroundFill(),a.backgroundStroke=e.getBackgroundStroke(),a.padding=e.getPadding()||sa,a.scale=A===void 0?[1,1]:A;let S=e.getOffsetX(),M=e.getOffsetY(),k=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_=k===void 0?!1:k,this.textRotation_=j===void 0?0:j,this.strokeKey_=o?(typeof o.strokeStyle=="string"?o.strokeStyle:Ut(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:"|"+Ut(l.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}},jI=gv;var gB={Circle:mv,Default:bs,Image:OI,LineString:zI,Polygon:mv,Text:jI},yv=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=gB[t];o=new m(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),l[t]=o}return o}},UI=yv;var _v=class extends zm{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e}getFeatures(e){return Pt()}getData(e){return null}prepareFrame(e){return Pt()}renderFrame(e,t){return Pt()}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()===Mt.LOADED||t.getState()===Mt.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=Mt.LOADED&&t!=Mt.ERROR&&e.addEventListener(Ir.CHANGE,this.boundHandleImageChange_),t==Mt.IDLE&&(e.load(),t=e.getState()),t==Mt.LOADED}renderIfReadyAndVisible(){let e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}},Du=_v;var xv=class extends zr{constructor(e,t,a,l){super(e),this.inversePixelTransform=t,this.frameState=a,this.context=l}},GI=xv;var vv=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Cu(),{get:(e,t)=>{if(typeof Cu()[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}},_g=vv;var wv=[],Ou=null;function yB(){Ou=Xr(1,1,void 0,{willReadFrequently:!0})}var bv=class extends Du{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=wi(),this.pixelTransform=wi(),this.inversePixelTransform=wi(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.pixelContext_=null,this.frameState=null}getImageData(e,t,a){Ou||yB(),Ou.clearRect(0,0,1,1);let l;try{Ou.drawImage(e,t,a,1,1,0,0,1,1),l=Ou.getImageData(0,0,1,1).data}catch{return Ou=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(ia(e.style.backgroundColor),ia(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=Xr();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=Fx(a),o=Lx(a),m=kx(a),g=Rx(a);Ni(t.coordinateToPixelTransform,l),Ni(t.coordinateToPixelTransform,o),Ni(t.coordinateToPixelTransform,m),Ni(t.coordinateToPixelTransform,g);let b=this.inversePixelTransform;Ni(b,l),Ni(b,o),Ni(b,m),Ni(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(kr(a)/l*m),b=Math.round(si(a)/l*m);ln(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/m,1/m,o,-g/2,-b/2),GA(this.inversePixelTransform,this.pixelTransform);let A=Sx(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 GI(e,this.inversePixelTransform,a,t);l.dispatchEvent(o)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(ms.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(ms.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new _g),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(ms.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(ms.POSTRENDER,this.context,e))}getRenderTransform(e,t,a,l,o,m,g){let b=o/2,A=m/2,S=l/t,M=-S,k=-e[0]+g,j=-e[1];return ln(this.tempTransform,b,A,S,M,-a,k,j)}disposeInternal(){delete this.frameState,super.disposeInternal()}},xg=bv;function VI(s,e,t,a,l,o,m,g,b,A,S,M){let k=s[e],j=s[e+1],Z=0,te=0,q=0,H=0;function ae(){Z=k,te=j,e+=a,k=s[e],j=s[e+1],H+=q,q=Math.sqrt((k-Z)*(k-Z)+(j-te)*(j-te))}do ae();while(e<t-a&&H+q<o);let pe=q===0?0:(o-H)/q,ve=Gi(Z,k,pe),de=Gi(te,j,pe),_e=e-a,Pe=H,Re=o+g*b(A,l,S);for(;e<t-a&&H+q<Re;)ae();pe=q===0?0:(Re-H)/q;let Ae=Gi(Z,k,pe),ut=Gi(te,j,pe),Ve;if(M){let nt=[ve,de,Ae,ut];$m(nt,0,4,2,M,nt,nt),Ve=nt[0]>nt[2]}else Ve=ve>Ae;let Ue=Math.PI,pt=[],Tt=_e+a===e;e=_e,q=0,H=Pe,k=s[e],j=s[e+1];let Qe;if(Tt){ae(),Qe=Math.atan2(j-te,k-Z),Ve&&(Qe+=Qe>0?-Ue:Ue);let nt=(Ae+ve)/2,yt=(ut+de)/2;return pt[0]=[nt,yt,(Re-o)/2,Qe,l],pt}l=l.replace(/\n/g," ");for(let nt=0,yt=l.length;nt<yt;){ae();let dt=Math.atan2(j-te,k-Z);if(Ve&&(dt+=dt>0?-Ue:Ue),Qe!==void 0){let $e=dt-Qe;if($e+=$e>Ue?-2*Ue:$e<-Ue?2*Ue:0,Math.abs($e)>m)return null}Qe=dt;let Rt=nt,bt=0;for(;nt<yt;++nt){let $e=Ve?yt-nt-1:nt,Fr=g*b(A,l[$e],S);if(e+a<t&&H+q<o+bt+Fr/2)break;bt+=Fr}if(nt===Rt)continue;let Bt=Ve?l.substring(yt-Rt,yt-nt):l.substring(Rt,nt);pe=q===0?0:(o+bt/2-H)/q;let jt=Gi(Z,k,pe),Pr=Gi(te,j,pe);pt.push([jt,Pr,bt/2,dt,Bt]),o+=bt}return pt}var zu=On(),Ya=[],ua=[],ha=[],Ja=[];function qI(s){return s[3].declutterBox}var $I=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function Sv(s,e){return e==="start"?e=$I.test(s)?"right":"left":e==="end"&&(e=$I.test(s)?"left":"right"),$d[e]}function _B(s,e,t){return t>0&&s.push(`
586
586
  `,""),s.push(e,""),s}var Av=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_=wi(),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 _g: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),k=b.justify?$d[b.justify]:Sv(Array.isArray(e)?e[0]:e,b.textAlign||Xa),j=l&&m.lineWidth?m.lineWidth:0,Z=M?e:e.split(`
587
587
  `).reduce(_B,[]),{width:te,height:q,widths:H,heights:ae,lineWidths:pe}=gI(b,Z),ve=te+j,de=[],_e=(ve+2)*S[0],Pe=(q+j)*S[1],Re={width:_e<0?Math.floor(_e):Math.ceil(_e),height:Pe<0?Math.floor(Pe):Math.ceil(Pe),contextInstructions:de};(S[0]!=1||S[1]!=1)&&de.push("scale",S),l&&(de.push("strokeStyle",m.strokeStyle),de.push("lineWidth",j),de.push("lineCap",m.lineCap),de.push("lineJoin",m.lineJoin),de.push("miterLimit",m.miterLimit),de.push("setLineDash",[m.lineDash]),de.push("lineDashOffset",m.lineDashOffset)),a&&de.push("fillStyle",g.fillStyle),de.push("textBaseline","middle"),de.push("textAlign","center");let Ae=.5-k,ut=k*ve+Ae*j,Ve=[],Ue=[],pt=0,Tt=0,Qe=0,nt=0,yt;for(let dt=0,Rt=Z.length;dt<Rt;dt+=2){let bt=Z[dt];if(bt===`
588
- `){Tt+=pt,pt=0,ut=k*ve+Ae*j,++nt;continue}let Bt=Z[dt+1]||b.font;Bt!==yt&&(l&&Ve.push("font",Bt),a&&Ue.push("font",Bt),yt=Bt),pt=Math.max(pt,ae[Qe]);let jt=[bt,ut+Ae*H[Qe]+k*(H[Qe]-pe[nt]),.5*(j+pt)+Tt];ut+=H[Qe],l&&Ve.push("strokeText",jt),a&&Ue.push("fillText",jt),++Qe}return Array.prototype.push.apply(de,Ve),Array.prototype.push.apply(de,Ue),this.labels_[o]=Re,Re}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,k,j,Z,te,q){g*=k[0],b*=k[1];let H=a-g,ae=l-b,pe=o+A>e?e-A:o,ve=m+S>t?t-S:m,de=Z[3]+pe*k[0]+Z[1],_e=Z[0]+ve*k[1]+Z[2],Pe=H-Z[3],Re=ae-Z[0];(te||M!==0)&&(Ya[0]=Pe,Ja[0]=Pe,Ya[1]=Re,ua[1]=Re,ua[0]=Pe+de,ha[0]=ua[0],ha[1]=Re+_e,Ja[1]=ha[1]);let Ae;return M!==0?(Ae=ln(wi(),a,l,1,1,M,-a,-l),Ni(Ae,Ya),Ni(Ae,ua),Ni(Ae,ha),Ni(Ae,Ja),ea(Math.min(Ya[0],ua[0],ha[0],Ja[0]),Math.min(Ya[1],ua[1],ha[1],Ja[1]),Math.max(Ya[0],ua[0],ha[0],Ja[0]),Math.max(Ya[1],ua[1],ha[1],Ja[1]),zu)):ea(Math.min(Pe,Pe+de),Math.min(Re,Re+_e),Math.max(Pe,Pe+de),Math.max(Re,Re+_e),zu),j&&(H=Math.round(H),ae=Math.round(ae)),{drawImageX:H,drawImageY:ae,drawImageW:pe,drawImageH:ve,originX:A,originY:S,declutterBox:{minX:zu[0],minY:zu[1],maxX:zu[2],maxY:zu[3],value:q},canvasTransform:Ae,scale:k}}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,Ya,ua,ha,Ja,m,g),yI(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=Ni(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=Sv(Array.isArray(e)?e[0]:e,o.textAlign||Xa),S=$d[o.textBaseline||Hl],M=g&&g.lineWidth?g.lineWidth:0,k=m.width/b-2*o.scale[0],j=A*k+2*(.5-A)*M,Z=S*m.height/b+2*(.5-S)*M;return{label:m,anchorX:j,anchorY:Z}}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_),jA(this.renderedTransform_,a));let M=0,k=l.length,j=0,Z,te,q,H,ae,pe,ve,de,_e,Pe,Re,Ae,ut,Ve=0,Ue=0,pt=null,Tt=null,Qe=this.coordinateCache_,nt=this.viewRotation_,yt=Math.round(Math.atan2(-a[1],a[0])*1e12)/1e12,dt={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:nt},Rt=this.instructions!=l||this.overlaps?0:200,bt,Bt,jt,Pr;for(;M<k;){let $e=l[M];switch($e[0]){case xt.BEGIN_GEOMETRY:bt=$e[1],Pr=$e[3],bt.getGeometry()?g!==void 0&&!ei(g,Pr.getExtent())?M=$e[2]+1:++M:M=$e[2],A&&(A.zIndex=$e[4]);break;case xt.BEGIN_PATH:Ve>Rt&&(this.fill_(e),Ve=0),Ue>Rt&&(e.stroke(),Ue=0),!Ve&&!Ue&&(e.beginPath(),ae=NaN,pe=NaN),++M;break;case xt.CIRCLE:j=$e[1];let Lr=S[j],Mi=S[j+1],Ri=S[j+2],En=S[j+3],ii=Ri-Lr,In=En-Mi,Pn=Math.sqrt(ii*ii+In*In);e.moveTo(Lr+Pn,Mi),e.arc(Lr,Mi,Pn,0,2*Math.PI,!0),++M;break;case xt.CLOSE_PATH:e.closePath(),++M;break;case xt.CUSTOM:j=$e[1],Z=$e[2];let Wn=$e[3],Ee=$e[4],Zn=$e[5];dt.geometry=Wn,dt.feature=bt,M in Qe||(Qe[M]=[]);let ki=Qe[M];Zn?Zn(S,j,Z,2,ki):(ki[0]=S[j],ki[1]=S[j+1],ki.length=2),A&&(A.zIndex=$e[6]),Ee(ki,dt),++M;break;case xt.DRAW_IMAGE:j=$e[1],Z=$e[2],_e=$e[3],te=$e[4],q=$e[5];let Et=$e[6],ir=$e[7],Xn=$e[8],Tn=$e[9],Yi=$e[10],Cn=$e[11],Fi=$e[12],po=$e[13];H=$e[14]||"declutter";let Hn=$e[15];if(!_e&&$e.length>=20){Pe=$e[19],Re=$e[20],Ae=$e[21],ut=$e[22];let le=this.drawLabelWithPointPlacement_(Pe,Re,Ae,ut);_e=le.label,$e[3]=_e;let he=$e[23];te=(le.anchorX-he)*this.pixelRatio,$e[4]=te;let me=$e[24];q=(le.anchorY-me)*this.pixelRatio,$e[5]=q,Et=_e.height,$e[6]=Et,po=_e.width,$e[13]=po}let Be;$e.length>25&&(Be=$e[25]);let Ji,jr,Li;$e.length>17?(Ji=$e[16],jr=$e[17],Li=$e[18]):(Ji=sa,jr=!1,Li=!1),Yi&&yt?Cn+=nt:!Yi&&!yt&&(Cn-=nt);let fo=0;for(;j<Z;j+=2){if(Be&&Be[fo++]<po/this.pixelRatio)continue;let le=this.calculateImageOrLabelDimensions_(_e.width,_e.height,S[j],S[j+1],po,Et,te,q,Xn,Tn,Cn,Fi,o,Ji,jr||Li,bt),he=[e,t,_e,le,ir,jr?pt:null,Li?Tt:null];if(b){let me,se,Se;if(Hn){let De=Z-j;if(!Hn[De]){Hn[De]={args:he,declutterMode:H};continue}let Ke=Hn[De];me=Ke.args,se=Ke.declutterMode,delete Hn[De],Se=qI(me)}let Ce,be;if(me&&(se!=="declutter"||!b.collides(Se))&&(Ce=!0),(H!=="declutter"||!b.collides(le.declutterBox))&&(be=!0),se==="declutter"&&H==="declutter"){let De=Ce&&be;Ce=De,be=De}Ce&&(se!=="none"&&b.insert(Se),this.replayImageOrLabel_.apply(this,me)),be&&(H!=="none"&&b.insert(le.declutterBox),this.replayImageOrLabel_.apply(this,he))}else this.replayImageOrLabel_.apply(this,he)}++M;break;case xt.DRAW_CHARS:let je=$e[1],Ct=$e[2],ft=$e[3],ci=$e[4];ut=$e[5];let dn=$e[6],wt=$e[7],fn=$e[8];Ae=$e[9];let mn=$e[10];Pe=$e[11],Re=$e[12];let Kn=[$e[13],$e[13]];H=$e[14]||"declutter";let Qi=this.textStates[Re],ie=Qi.font,N=[Qi.scale[0]*wt,Qi.scale[1]*wt],B;ie in this.widths_?B=this.widths_[ie]:(B={},this.widths_[ie]=B);let $=Ym(S,je,Ct,2),Q=Math.abs(N[0])*q0(ie,Pe,B);if(ci||Q<=$){let le=this.textStates[Re].textAlign,he=($-Q)*Sv(Pe,le),me=VI(S,je,Ct,2,Pe,he,dn,Math.abs(N[0]),q0,ie,B,yt?0:this.viewRotation_);e:if(me){let se=[],Se,Ce,be,De,Ke;if(Ae)for(Se=0,Ce=me.length;Se<Ce;++Se){Ke=me[Se],be=Ke[4],De=this.createLabel(be,Re,"",Ae),te=Ke[2]+(N[0]<0?-mn:mn),q=ft*De.height+(.5-ft)*2*mn*N[1]/N[0]-fn;let ot=this.calculateImageOrLabelDimensions_(De.width,De.height,Ke[0],Ke[1],De.width,De.height,te,q,0,0,Ke[3],Kn,!1,sa,!1,bt);if(b&&H==="declutter"&&b.collides(ot.declutterBox))break e;se.push([e,t,De,ot,1,null,null])}if(ut)for(Se=0,Ce=me.length;Se<Ce;++Se){Ke=me[Se],be=Ke[4],De=this.createLabel(be,Re,ut,""),te=Ke[2],q=ft*De.height-fn;let ot=this.calculateImageOrLabelDimensions_(De.width,De.height,Ke[0],Ke[1],De.width,De.height,te,q,0,0,Ke[3],Kn,!1,sa,!1,bt);if(b&&H==="declutter"&&b.collides(ot.declutterBox))break e;se.push([e,t,De,ot,1,null,null])}b&&H!=="none"&&b.load(se.map(qI));for(let ot=0,At=se.length;ot<At;++ot)this.replayImageOrLabel_.apply(this,se[ot])}}++M;break;case xt.END_GEOMETRY:if(m!==void 0){bt=$e[1];let le=m(bt,Pr,H);if(le)return le}++M;break;case xt.FILL:Rt?Ve++:this.fill_(e),++M;break;case xt.MOVE_TO_LINE_TO:for(j=$e[1],Z=$e[2],Bt=S[j],jt=S[j+1],e.moveTo(Bt,jt),ae=Bt+.5|0,pe=jt+.5|0,j+=2;j<Z;j+=2)Bt=S[j],jt=S[j+1],ve=Bt+.5|0,de=jt+.5|0,(j==Z-2||ve!==ae||de!==pe)&&(e.lineTo(Bt,jt),ae=ve,pe=de);++M;break;case xt.SET_FILL_STYLE:pt=$e,this.alignAndScaleFill_=$e[2],Ve&&(this.fill_(e),Ve=0,Ue&&(e.stroke(),Ue=0)),e.fillStyle=$e[1],++M;break;case xt.SET_STROKE_STYLE:Tt=$e,Ue&&(e.stroke(),Ue=0),this.setStrokeStyle_(e,$e),++M;break;case xt.STROKE:Rt?Ue++:e.stroke(),++M;break;default:++M;break}}Ve&&this.fill_(e),Ue&&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)}},WI=Av;var Yl=["Polygon","Circle","LineString","Image","Text","Default"],Pv=["Image","Text"],ZI=Yl.filter(s=>!Pv.includes(s)),Iv=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_=wi(),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 WI(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=ln(this.hitDetectionTransform_,l+.5,l+.5,1/t,-1/t,-a,-e[0],-e[1]),A=!this.hitDetectionContext_;A&&(this.hitDetectionContext_=Xr(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(),Cx(M,e),Ln(M,t*(this.renderBuffer_+l),M));let k=xB(l),j;function Z(de,_e,Pe){let Re=S.getImageData(0,0,g,g).data;for(let Ae=0,ut=k.length;Ae<ut;Ae++)if(Re[k[Ae]]>0){if(!m||Pe==="none"||j!=="Image"&&j!=="Text"||m.includes(de)){let Ve=(k[Ae]-3)/4,Ue=l-Ve%g,pt=l-(Ve/g|0),Tt=o(de,_e,Ue*Ue+pt*pt);if(Tt)return Tt}S.clearRect(0,0,g,g);break}}let te=Object.keys(this.executorsByZIndex_).map(Number);te.sort(Bo);let q,H,ae,pe,ve;for(q=te.length-1;q>=0;--q){let de=te[q].toString();for(ae=this.executorsByZIndex_[de],H=Yl.length-1;H>=0;--H)if(j=Yl[H],pe=ae[j],pe!==void 0&&(ve=pe.executeHitDetection(S,b,a,Z,M),ve))return ve}}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 lo(this.executorsByZIndex_)}execute(e,t,a,l,o,m,g){let b=Object.keys(this.executorsByZIndex_).map(Number);b.sort(Bo),m=m||Yl;let A=Yl.length,S,M,k,j,Z;for(g&&b.reverse(),S=0,M=b.length;S<M;++S){let te=b[S].toString();for(Z=this.executorsByZIndex_[te],k=0,j=m.length;k<j;++k){let q=m[k],H=Z[q];if(H!==void 0){let ae=g===null?void 0:H.getZIndexContext(),pe=ae?ae.getContext():e,ve=this.maxExtent_&&q!=="Image"&&q!=="Text";if(ve&&(pe.save(),this.clip(pe,a)),!ae||q==="Text"||q==="Image"?H.execute(pe,t,a,l,o,g):ae.pushFunction(de=>H.execute(de,t,a,l,o,g)),ve&&pe.restore(),ae){ae.offset();let de=b[S]*A+k;this.deferredZIndexContexts_[de]||(this.deferredZIndexContexts_[de]=[]),this.deferredZIndexContexts_[de].push(ae)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(Bo);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}},Ev={};function xB(s){if(Ev[s]!==void 0)return Ev[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 Ev[s]=l,l}var XI=Iv;var Tv=class extends yg{constructor(e,t,a,l,o,m,g){super(),this.context_=e,this.pixelRatio_=t,this.extent_=a,this.transform_=l,this.transformRotation_=l?cE(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_=wi()}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 k=o[S]-this.imageAnchorX_,j=o[S+1]-this.imageAnchorY_;if(A!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let Z=k+this.imageAnchorX_,te=j+this.imageAnchorY_;ln(g,Z,te,1,1,A,-Z,-te),m.save(),m.transform.apply(m,g),m.translate(Z,te),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_,k,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_)),!!ei(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=AE(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_)),!!ei(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(ei(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_)),!!ei(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_)),!!ei(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:Xa;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:jn(a||li)}}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:ys,lineDash:this.pixelRatio_===1?S:S.map(M=>M*this.pixelRatio_),lineDashOffset:(m||Gn)*this.pixelRatio_,lineJoin:g!==void 0?g:_s,lineWidth:(b!==void 0?b:aa)*this.pixelRatio_,miterLimit:A!==void 0?A:na,strokeStyle:jn(a||oa)}}}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:jn(j||li)}}let a=e.getStroke();if(!a)this.textStrokeState_=null;else{let j=a.getColor(),Z=a.getLineCap(),te=a.getLineDash(),q=a.getLineDashOffset(),H=a.getLineJoin(),ae=a.getWidth(),pe=a.getMiterLimit();this.textStrokeState_={lineCap:Z!==void 0?Z:ys,lineDash:te||Un,lineDashOffset:q||Gn,lineJoin:H!==void 0?H:_s,lineWidth:ae!==void 0?ae:aa,miterLimit:pe!==void 0?pe:na,strokeStyle:jn(j||oa)}}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(),k=e.getTextBaseline();this.textState_={font:l!==void 0?l:ug,textAlign:M!==void 0?M:Xa,textBaseline:k!==void 0?k:Hl},this.text_=S!==void 0?Array.isArray(S)?S.reduce((j,Z,te)=>j+=te%2?" ":Z,""):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]]}}},HI=Tv;var Ko=.5;function KI(s,e,t,a,l,o,m,g,b){let A=b?ds(l,b):l,S=s[0]*Ko,M=s[1]*Ko,k=Xr(S,M);k.imageSmoothingEnabled=!1;let j=k.canvas,Z=new HI(k,Ko,l,null,m,g,b?Au(co(),b):null),te=t.length,q=Math.floor((256*256*256-1)/te),H={};for(let pe=1;pe<=te;++pe){let ve=t[pe-1],de=ve.getStyleFunction()||a;if(!de)continue;let _e=de(ve,o);if(!_e)continue;Array.isArray(_e)||(_e=[_e]);let Re=(pe*q).toString(16).padStart(7,"#00000");for(let Ae=0,ut=_e.length;Ae<ut;++Ae){let Ve=_e[Ae],Ue=Ve.getGeometryFunction()(ve);if(!Ue||!ei(A,Ue.getExtent()))continue;let pt=Ve.clone(),Tt=pt.getFill();Tt&&Tt.setColor(Re);let Qe=pt.getStroke();Qe&&(Qe.setColor(Re),Qe.setLineDash(null)),pt.setText(void 0);let nt=Ve.getImage();if(nt){let bt=nt.getImageSize();if(!bt)continue;let Bt=Xr(bt[0],bt[1],void 0,{alpha:!1}),jt=Bt.canvas;Bt.fillStyle=Re,Bt.fillRect(0,0,jt.width,jt.height),pt.setImage(new Dd({img:jt,anchor:nt.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:nt.getOrigin(),opacity:1,size:nt.getSize(),scale:nt.getScale(),rotation:nt.getRotation(),rotateWithView:nt.getRotateWithView()}))}let yt=pt.getZIndex()||0,dt=H[yt];dt||(dt={},H[yt]=dt,dt.Polygon=[],dt.Circle=[],dt.LineString=[],dt.Point=[]);let Rt=Ue.getType();if(Rt==="GeometryCollection"){let bt=Ue.getGeometriesArrayRecursive();for(let Bt=0,jt=bt.length;Bt<jt;++Bt){let Pr=bt[Bt];dt[Pr.getType().replace("Multi","")].push(Pr,pt)}}else dt[Rt.replace("Multi","")].push(Ue,pt)}}let ae=Object.keys(H).map(Number).sort(Bo);for(let pe=0,ve=ae.length;pe<ve;++pe){let de=H[ae[pe]];for(let _e in de){let Pe=de[_e];for(let Re=0,Ae=Pe.length;Re<Ae;Re+=2){Z.setStyle(Pe[Re+1]);for(let ut=0,Ve=e.length;ut<Ve;++ut)Z.setTransform(e[ut]),Z.drawGeometry(Pe[Re])}}}return k.getImageData(0,0,j.width,j.height)}function YI(s,e,t){let a=[];if(t){let l=Math.floor(Math.round(s[0])*Ko),o=Math.floor(Math.round(s[1])*Ko),m=(Br(l,0,t.width-1)+Br(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 vB=.5,JI={Point:PB,LineString:AB,Polygon:CB,MultiPoint:TB,MultiLineString:EB,MultiPolygon:IB,GeometryCollection:SB,Circle:bB};function QI(s,e){return parseInt(Ut(s),10)-parseInt(Ut(e),10)}function Cv(s,e){let t=Mv(s,e);return t*t}function Mv(s,e){return vB*s/e}function bB(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 Rv(s,e,t,a,l,o,m,g){let b=[],A=t.getImage();if(A){let k=!0,j=A.getImageState();j==Mt.LOADED||j==Mt.ERROR?k=!1:j==Mt.IDLE&&A.load(),k&&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)),wB(s,e,t,a,o,m,g),M}function wB(s,e,t,a,l,o,m){let g=t.getGeometryFunction()(e);if(!g)return;let b=g.simplifyTransformed(a,l);if(t.getRenderer())e2(s,b,t,e,m);else{let S=JI[b.getType()];S(s,b,t,e,m,o)}}function e2(s,e,t,a,l){if(e.getType()=="GeometryCollection"){let m=e.getGeometries();for(let g=0,b=m.length;g<b;++g)e2(s,m[g],t,a,l);return}s.getBuilder(t.getZIndex(),"Default").drawCustom(e,a,t.getRenderer(),t.getHitDetectionRenderer(),l)}function SB(s,e,t,a,l,o){let m=e.getGeometriesArray(),g,b;for(g=0,b=m.length;g<b;++g){let A=JI[m[g].getType()];A(s,m[g],t,a,l,o)}}function AB(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 EB(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 IB(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 PB(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()!=Mt.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 TB(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()!=Mt.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 CB(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 kv=class extends xg{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(),k=this.getLayer().getDeclutter(),j=t.pixelRatio,Z=t.viewHints,te=!(Z[Bn.ANIMATING]||Z[Bn.INTERACTING]),q=this.context,H=Math.round(kr(l)/g*j),ae=Math.round(si(l)/g*j),pe=M.getWrapX()&&b.canWrapX(),ve=pe?kr(S):null,de=pe?Math.ceil((l[2]-S[2])/ve)+1:1,_e=pe?Math.floor((l[0]-S[0])/ve):0;do{let Pe=this.getRenderTransform(m,g,0,j,H,ae,_e*ve);t.declutter&&(Pe=Pe.slice(0)),e.execute(q,[q.canvas.width,q.canvas.height],Pe,A,te,a===void 0?Yl:a?Pv:ZI,a?k&&t.declutter[k]:void 0)}while(++_e<de)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Xr(this.context.canvas.width,this.context.canvas.height,wv))}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,JE(this.context),wv.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(ms.PRERENDER)||this.getLayer().hasListener(ms.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(o,e);let b=l.projection;if(this.clipped_=!1,g&&a.extent&&this.clipping){let A=fs(a.extent,b);g=ei(A,e.extent),this.clipped_=g&&!Qs(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]*Ko,k=a[1]*Ko;S.push(this.getRenderTransform(l,o,m,Ko,M,k,0).slice());let j=A.getSource(),Z=g.getExtent();if(j.getWrapX()&&g.canWrapX()&&!Qs(Z,b)){let q=b[0],H=kr(Z),ae=0,pe;for(;q<Z[0];)--ae,pe=H*ae,S.push(this.getRenderTransform(l,o,m,Ko,M,k,pe).slice()),q+=H;for(ae=0,q=b[2];q>Z[2];)++ae,pe=H*ae,S.push(this.getRenderTransform(l,o,m,Ko,M,k,pe).slice()),q-=H}let te=co();this.hitDetectionImageData_=KI(a,S,this.renderedFeatures_,A.getStyleFunction(),b,o,m,Cv(o,this.renderedPixelRatio_),te?g:null)}t(YI(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(Z,te,q){let H=Ut(Z),ae=A[H];if(ae){if(ae!==!0&&q<ae.distanceSq){if(q===0)return A[H]=!0,o.splice(o.lastIndexOf(ae),1),l(Z,b,te);ae.geometry=te,ae.distanceSq=q}}else{if(q===0)return A[H]=!0,l(Z,b,te);o.push(A[H]={feature:Z,layer:b,geometry:te,distanceSq:q,callback:l})}},M,k=[this.replayGroup_],j=this.getLayer().getDeclutter();return k.some(Z=>M=Z.forEachFeatureAtCoordinate(e,m,g,a,S,j&&t.declutter[j]?t.declutter[j].all().map(te=>te.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,k=e.pixelRatio,j=t.getRevision(),Z=t.getRenderBuffer(),te=t.getRenderOrder();te===void 0&&(te=QI);let q=A.center.slice(),H=Ln(b,Z*M),ae=H.slice(),pe=[H.slice()],ve=S.getExtent();if(a.getWrapX()&&S.canWrapX()&&!Qs(ve,e.extent)){let Qe=kr(ve),nt=Math.max(kr(H)/2,Qe);H[0]=ve[0]-nt,H[2]=ve[2]+nt,dE(q,S);let yt=Dx(pe[0],S);yt[0]<ve[0]&&yt[2]<ve[2]?pe.push([yt[0]+Qe,yt[1],yt[2]+Qe,yt[3]]):yt[0]>ve[0]&&yt[2]>ve[2]&&pe.push([yt[0]-Qe,yt[1],yt[2]-Qe,yt[3]])}if(this.ready&&this.renderedResolution_==M&&this.renderedRevision_==j&&this.renderedRenderOrder_==te&&this.renderedFrameDeclutter_===!!e.declutter&&Qs(this.wrappedRenderedExtent_,H))return Fn(this.renderedExtent_,ae)||(this.hitDetectionImageData_=null,this.renderedExtent_=ae),this.renderedCenter_=q,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let de=new UI(Mv(M,k),H,M,k),_e=co(),Pe;if(_e){for(let Qe=0,nt=pe.length;Qe<nt;++Qe){let yt=pe[Qe],dt=ds(yt,S);a.loadFeatures(dt,xE(M,S),_e)}Pe=Au(_e,S)}else for(let Qe=0,nt=pe.length;Qe<nt;++Qe)a.loadFeatures(pe[Qe],M,S);let Re=Cv(M,k),Ae=!0,ut=(Qe,nt)=>{let yt,dt=Qe.getStyleFunction()||t.getStyleFunction();if(dt&&(yt=dt(Qe,M)),yt){let Rt=this.renderFeature(Qe,Re,yt,de,Pe,this.getLayer().getDeclutter(),nt);Ae=Ae&&!Rt}},Ve=ds(H,S),Ue=a.getFeaturesInExtent(Ve);te&&Ue.sort(te);for(let Qe=0,nt=Ue.length;Qe<nt;++Qe)ut(Ue[Qe],Qe);this.renderedFeatures_=Ue,this.ready=Ae;let pt=de.finish(),Tt=new XI(H,M,k,a.getOverlaps(),pt,t.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=M,this.renderedRevision_=j,this.renderedRenderOrder_=te,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=ae,this.wrappedRenderedExtent_=H,this.renderedCenter_=q,this.renderedProjection_=S,this.renderedPixelRatio_=k,this.replayGroup_=Tt,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=Rv(l,e,a[A],t,this.boundHandleStyleImageChange_,o,m,g)||b;else b=Rv(l,e,a,t,this.boundHandleStyleImageChange_,o,m,g);return b}},t2=kv;var Fv=class extends DI{constructor(e){super(e)}createRenderer(){return new t2(this)}},Jl=Fv;var r2=ao(J0(),1);var Lv=class{constructor(e){this.rbush_=new r2.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_[Ut(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_[Ut(g)]=b}this.rbush_.load(a)}remove(e){let t=Ut(e),a=this.items_[t];return delete this.items_[t],this.rbush_.remove(a)!==null}update(e,t){let a=this.items_[Ut(t)],l=[a.minX,a.minY,a.maxX,a.maxY];jm(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 lo(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let t=this.rbush_.toJSON();return ea(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]}},Wd=Lv;var i2=wi(),Zd=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_):vu(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=bo(this.getExtent());this.flatInteriorPoints_=Sd(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=zE(this.flatCoordinates_,this.ends_),t=eg(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Jm(this.flatCoordinates_,0,e,2,t)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Zl(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=Zl(e,t,m,2,.5);ji(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=Zr(e);let t=e.getExtent(),a=e.getWorldExtent();if(t&&a){let l=si(a)/si(t);ln(i2,a[0],a[3],l,-l,0,0,0),zn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,i2,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=Dm((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=Wl(a,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,a,0),l=[a.length];break;case"MultiLineString":l=[],a.length=Xm(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,a,0,l);break;case"Polygon":l=[],a.length=_d(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}};Zd.prototype.getFlatCoordinates=Zd.prototype.getOrientedFlatCoordinates;var Eo=Zd;var Dv=class extends Si{constructor(e){super(),this.projection=Zr(e.projection),this.attributions_=n2(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_=n2(e),this.changed()}setState(e){this.state_=e,this.changed()}};function n2(s){return s?Array.isArray(s)?function(e){return s}:typeof s=="function"?s:function(e){return[s]}:null}var pa=Dv;var hn={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function o2(s,e){return[[-1/0,-1/0,1/0,1/0]]}var MB=!1;function RB(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=MB,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 Ov(s,e){return function(t,a,l,o,m){let g=this;RB(s,e,t,a,l,function(b,A){g.addFeatures(b),o!==void 0&&o(b)},m||No)}}var ws=class extends zr{constructor(e,t,a){super(e),this.feature=t,this.features=a}},zv=class extends pa{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_=No,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&&(Ar(this.format_,"`format` must be set when `url` is set"),this.loader_=Ov(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:o2;let t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Wd:null,this.loadedExtentsRtree_=new Wd,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 Rd(l)),l!==void 0&&this.addFeaturesInternal(l),a!==void 0&&this.bindFeaturesCollection_(a)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let t=Ut(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 ws(hn.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof Eo||(this.featureChangeKeys_[e]=[Ui(t,Ir.CHANGE,this.handleFeatureChange_,this),Ui(t,km.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 Eo){let o=this.idIndex_[l];o instanceof Eo?Array.isArray(o)?o.push(t):this.idIndex_[l]=[o,t]:a=!1}else a=!1}return a&&(Ar(!(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=Ut(g);this.addToIndex_(b,g)&&a.push(g)}for(let o=0,m=a.length;o<m;o++){let g=a[o],b=Ut(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(hn.ADDFEATURE))for(let o=0,m=a.length;o<m;o++)this.dispatchEvent(new ws(hn.ADDFEATURE,a[o]))}bindFeaturesCollection_(e){let t=!1;this.addEventListener(hn.ADDFEATURE,function(a){t||(t=!0,e.push(a.feature),t=!1)}),this.addEventListener(hn.REMOVEFEATURE,function(a){t||(t=!0,e.remove(a.feature),t=!1)}),e.addEventListener($o.ADD,a=>{t||(t=!0,this.addFeature(a.element),t=!1)}),e.addEventListener($o.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(cn);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 ws(hn.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 Eo||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 Eo||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(),lo(this.nullGeometryFeatures_)||ji(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=QA(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||Lm,this.featuresRtree_.forEachInExtent(b,function(A){if(t(A)){let S=A.getGeometry(),M=g;if(g=S instanceof Eo?0:S.closestPointXY(a,l,m,g),g<M){o=A;let k=Math.sqrt(g);b[0]=a-k,b[1]=l-k,b[2]=a+k,b[3]=l+k}}}),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=Ut(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 ws(hn.CHANGEFEATURE,t))}hasFeature(e){let t=e.getId();return t!==void 0?t in this.idIndex_:Ut(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&lo(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 Qs(S.extent,b)})||(++this.loadingExtentsCount_,this.dispatchEvent(new ws(hn.FEATURESLOADSTART)),this.loader_.call(this,b,t,a,S=>{--this.loadingExtentsCount_,this.dispatchEvent(new ws(hn.FEATURESLOADEND,void 0,S))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new ws(hn.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(jm(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=Ut(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(cn),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(hn.REMOVEFEATURE)&&this.dispatchEvent(new ws(hn.REMOVEFEATURE,e)),e}removeFromIdIndex_(e){let t=!1;for(let a in this.idIndex_){let l=this.idIndex_[a];if(e instanceof Eo&&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){Ar(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(Ov(e,this.format_))}},Ql=zv;var uo={SINGLECLICK:"singleclick",CLICK:Ir.CLICK,DBLCLICK:Ir.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var Bv={ACTIVE:"active"};var Nv=class extends Si{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(Bv.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(Bv.ACTIVE,e)}setMap(e){this.map_=e}};var s2=Nv;var jv=class extends s2{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==uo.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==uo.POINTERUP){let a=this.handleUpEvent(e);this.handlingDownUpSequence=a&&this.targetPointers.length>0}}else if(e.type==uo.POINTERDOWN){let a=this.handleDownEvent(e);this.handlingDownUpSequence=a,t=this.stopDown(a)}else e.type==uo.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 a2=jv;var l2=function(s){let e=s.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var c2=Lm,u2=function(s){return s.type==uo.CLICK};var h2=function(s){return s.type==uo.SINGLECLICK};var p2=function(s){let e=s.originalEvent;return Ar(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var Uv=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=Ao,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let a=t.dataProjection?Zr(t.dataProjection):this.readProjection(e);t.extent&&a&&a.getUnits()==="tile-pixels"&&(a=Zr(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 Pt()}readFeature(e,t){return Pt()}readFeatures(e,t){return Pt()}readGeometry(e,t){return Pt()}readProjection(e){return Pt()}writeFeature(e,t){return Pt()}writeFeatures(e,t){return Pt()}writeGeometry(e,t){return Pt()}},d2=Uv;function vg(s,e,t){let a=t?Zr(t.featureProjection):null,l=t?Zr(t.dataProjection):null,o=s;if(a&&l&&!_E(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(Vl(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 kB={Point:Ei,LineString:Go,Polygon:Iu,MultiPoint:wd,MultiLineString:i0,MultiPolygon:u0};function FB(s,e,t){return Array.isArray(e[0])?(Qm(s,0,e,t)||(s=s.slice(),Ed(s,0,e,t)),s):(Ad(s,0,e,t)||(s=s.slice(),Eu(s,0,e,t)),s)}function Gv(s,e){let t=s.geometry;if(!t)return[];if(Array.isArray(t))return t.map(o=>Gv({...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 vg(new Eo(a,a==="Polygon"?FB(t.flatCoordinates,t.ends,l):t.flatCoordinates,t.ends?.flat(),l,s.properties||{},s.id).enableSimplifyTransformed(),!1,e)}function bg(s,e){if(!s)return null;if(Array.isArray(s)){let a=s.map(l=>bg(l,e));return new Hx(a)}let t=kB[s.type];return vg(new t(s.flatCoordinates,s.layout,s.ends),!1,e)}var Vv=class extends d2{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(wg(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(wg(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return Pt()}readFeaturesFromObject(e,t){return Pt()}readGeometry(e,t){return this.readGeometryFromObject(wg(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return Pt()}readProjection(e){return this.readProjectionFromObject(wg(e))}readProjectionFromObject(e){return Pt()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return Pt()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return Pt()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return Pt()}};function wg(s){if(typeof s=="string"){let e=JSON.parse(s);return e||null}return s!==null?s:null}var f2=Vv;var qv=class extends f2{constructor(e){e=e||{},super(),this.dataProjection=Zr(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=Zr(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=Wv(a.geometry,t);if(this.featureClass===Eo)return Gv({geometry:l,id:a.id,properties:a.properties},t);let o=new Ao;return this.geometryName_?o.setGeometryName(this.geometryName_):this.extractGeometryName_&&a.geometry_name&&o.setGeometryName(a.geometry_name),o.setGeometry(bg(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 LB(e,t)}readProjectionFromObject(e){let t=e.crs,a;if(t)if(t.type=="name")a=Zr(t.properties.name);else if(t.type==="EPSG")a=Zr("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=$v(m,t),delete o[e.getGeometryName()]),lo(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 $v(e,this.adaptOptions(t))}};function Wv(s,e){if(!s)return null;let t;switch(s.type){case"Point":{t=OB(s);break}case"LineString":{t=zB(s);break}case"Polygon":{t=UB(s);break}case"MultiPoint":{t=NB(s);break}case"MultiLineString":{t=BB(s);break}case"MultiPolygon":{t=jB(s);break}case"GeometryCollection":{t=DB(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return t}function LB(s,e){let t=Wv(s,e);return bg(t,e)}function DB(s,e){return s.geometries.map(function(a){return Wv(a,e)})}function OB(s){let e=s.coordinates;return{type:"Point",flatCoordinates:e,layout:ja(e.length)}}function zB(s){let e=s.coordinates,t=e.flat();return{type:"LineString",flatCoordinates:t,ends:[t.length],layout:ja(e[0]?.length||2)}}function BB(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:ja(t)}}function NB(s){let e=s.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:ja(e[0]?.length||2)}}function jB(s){let e=s.coordinates,t=[],a=e[0]?.[0]?.[0].length||2,l=Zm(t,0,e,a);return{type:"MultiPolygon",flatCoordinates:t,ends:l,layout:ja(a)}}function UB(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:ja(a)}}function $v(s,e){s=vg(s,!0,e);let t=s.getType(),a;switch(t){case"Point":{a=ZB(s,e);break}case"LineString":{a=VB(s,e);break}case"Polygon":{a=XB(s,e);break}case"MultiPoint":{a=$B(s,e);break}case"MultiLineString":{a=qB(s,e);break}case"MultiPolygon":{a=WB(s,e);break}case"GeometryCollection":{a=GB(s,e);break}case"Circle":{a={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+t)}return a}function GB(s,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(a){return $v(a,e)})}}function VB(s,e){return{type:"LineString",coordinates:s.getCoordinates()}}function qB(s,e){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function $B(s,e){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function WB(s,e){let t;return e&&(t=e.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(t)}}function ZB(s,e){return{type:"Point",coordinates:s.getCoordinates()}}function XB(s,e){let t;return e&&(t=e.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(t)}}var Ii=qv;var m2=0,Xd=1,g2=[0,0,0,0],Bu=[],Zv={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},Hd=class extends zr{constructor(e,t,a){super(e),this.features=t,this.mapBrowserEvent=a}},Xv=class extends a2{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:p2,this.defaultDeleteCondition_=function(a){return l2(a)&&h2(a)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:c2,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Wd,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Jl({source:new Ql({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:KB(),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 Rd(this.source_.getFeatures()),this.source_.addEventListener(hn.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(hn.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($o.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener($o.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(Ir.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Rd;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 Hd(Zv.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(Ir.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(ps(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(ps(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(ps(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 k=A.slice(S,S+2),j={feature:e,geometry:t,depth:[g,l],index:S,segment:k};this.rBush_.insert(ps(k),j)}}}}writeCircleGeometry_(e,t){let a=t.getCenter(),l={feature:e,geometry:t,index:m2,segment:[a,a]},o={feature:e,geometry:t,index:Xd,segment:[a,a]},m=[l,o];l.featureSegments=m,o.featureSegments=m,this.rBush_.insert(Ba(a),l);let g=t,b=co();if(b&&this.getMap()){let A=this.getMap().getView().getProjection();g=g.clone().transform(b,A),g=l0(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 Ao(new Ei(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==uo.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=uo.SINGLECLICK||!this.ignoreNextSingleClick_?t=this.removePoint():t=!0),e.type==uo.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,k,j=b.segment,Z=g[1];for(;t.length<S.getStride();)t.push(j[Z][t.length]);switch(S.getType()){case"Point":k=t,j[0]=t,j[1]=t;break;case"MultiPoint":k=S.getCoordinates(),k[b.index]=t,j[0]=t,j[1]=t;break;case"LineString":k=S.getCoordinates(),k[b.index+Z]=t,j[Z]=t;break;case"MultiLineString":k=S.getCoordinates(),k[M[0]][b.index+Z]=t,j[Z]=t;break;case"Polygon":k=S.getCoordinates(),k[M[0]][b.index+Z]=t,j[Z]=t;break;case"MultiPolygon":k=S.getCoordinates(),k[M[1]][M[0]][b.index+Z]=t,j[Z]=t;break;case"Circle":if(j[0]=t,j[1]=t,b.index===m2)this.changingFeature_=!0,S.setCenter(t),this.changingFeature_=!1;else{this.changingFeature_=!0;let te=e.map.getView().getProjection(),q=Ux(ti(S.getCenter(),te),ti(t,te)),H=co();if(H){let ae=S.clone().transform(H,te);ae.setRadius(q),q=ae.transform(te,H).getRadius()}S.setRadius(q),this.changingFeature_=!1}break;default:}k&&this.setGeometryCoordinates_(S,k)}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=ps([m]),b=this.rBush_.getInExtent(g),A={};b.sort(HB);for(let S=0,M=b.length;S<M;++S){let k=b[S],j=k.segment,Z=Ut(k.geometry),te=k.depth;if(te&&(Z+="-"+te.join("-")),A[Z]||(A[Z]=new Array(2)),k.geometry.getType()==="Circle"&&k.index===Xd){let q=_2(t,k,l);An(q,m)&&!A[Z][0]&&(this.dragSegments_.push([k,0]),A[Z][0]=k);continue}if(An(j[0],m)&&!A[Z][0]){this.dragSegments_.push([k,0]),A[Z][0]=k;continue}if(An(j[1],m)&&!A[Z][1]){if(A[Z][0]&&A[Z][0].index===0){let q=k.geometry.getCoordinates();switch(k.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":q=q[te[1]];case"Polygon":if(k.index!==q[te[0]].length-2)continue;break;default:}}this.dragSegments_.push([k,1]),A[Z][1]=k;continue}Ut(j)in this.vertexSegments_&&!A[Z][0]&&!A[Z][1]&&this.insertVertexCondition_(e)&&o.push(k)}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=co();if(A){let S=e.map.getView().getProjection();b=b.clone().transform(A,S),b=l0(b).transform(S,A)}this.rBush_.update(b.getExtent(),g)}else this.rBush_.update(ps(a.segment),a)}return this.featuresBeingModified_&&(this.dispatchEvent(new Hd(Zv.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 y2(l,A,o)-y2(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,k)=>{k&&k.getType()==="Point"&&(k=new Ei(ql(k.getCoordinates(),o)));let j=k||S.getGeometry();if(S instanceof Ao&&this.features_.getArray().includes(S)){b=j;let Z=S.getGeometry().getFlatCoordinates().slice(0,2);g=[{feature:S,geometry:b,segment:[Z,Z]}]}return!0},{layerFilter:A})}if(!g){let A=fs(Ba(l,g2),o),S=t.getView().getResolution()*this.pixelTolerance_,M=ds(Ln(A,S,g2),o);g=this.rBush_.getInExtent(M)}if(g&&g.length>0){let A=g.sort(m)[0],S=A.segment,M=_2(l,A,o),k=t.getPixelFromCoordinate(M),j=Ux(e,k);if(b||j<=this.pixelTolerance_){let Z={};if(Z[Ut(S)]=!0,this.snapToPointer_||(this.delta_[0]=M[0]-l[0],this.delta_[1]=M[1]-l[1]),A.geometry.getType()==="Circle"&&A.index===Xd)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(M,[A.feature],[A.geometry]);else{let te=t.getPixelFromCoordinate(S[0]),q=t.getPixelFromCoordinate(S[1]),H=Su(k,te),ae=Su(k,q);j=Math.sqrt(Math.min(H,ae)),this.snappedToVertex_=j<=this.pixelTolerance_,this.snappedToVertex_&&(M=H>ae?S[1]:S[0]),this.createOrUpdateVertexFeature_(M,[A.feature],[A.geometry]);let pe={};pe[Ut(A.geometry)]=!0;for(let ve=1,de=g.length;ve<de;++ve){let _e=g[ve].segment;if(An(S[0],_e[0])&&An(S[1],_e[1])||An(S[0],_e[1])&&An(S[1],_e[0])){let Pe=Ut(g[ve].geometry);Pe in pe||(pe[Pe]=!0,Z[Ut(_e)]=!0)}else break}}this.vertexSegments_=Z;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(ps(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(ps(M.segment),M),this.dragSegments_.push([M,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=uo.POINTERDRAG){let e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_);let t=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Hd(Zv.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,k,j,Z;for(b=e.length-1;b>=0;--b)m=e[b],j=m[0],Z=Ut(j.feature),j.depth&&(Z+="-"+j.depth.join("-")),Z in t||(t[Z]={}),m[1]===0?(t[Z].right=j,t[Z].index=j.index):m[1]==1&&(t[Z].left=j,t[Z].index=j.index+1);for(Z in t){switch(k=t[Z].right,S=t[Z].left,A=t[Z].index,M=A-1,S!==void 0?j=S:j=k,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 te=[];if(S!==void 0&&(this.rBush_.remove(S),te.push(S.segment[0])),k!==void 0&&(this.rBush_.remove(k),te.push(k.segment[1])),S!==void 0&&k!==void 0){let q={depth:j.depth,feature:j.feature,geometry:j.geometry,index:M,segment:te};this.rBush_.insert(ps(q.segment),q)}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 HB(s,e){return s.index-e.index}function y2(s,e,t){let a=e.geometry;if(a.getType()==="Circle"){let o=a;if(e.index===Xd){let m=co();m&&(o=o.clone().transform(m,t));let g=Su(o.getCenter(),ti(s,t)),b=Math.sqrt(g)-o.getRadius();return b*b}}let l=ti(s,t);return Bu[0]=ti(e.segment[0],t),Bu[1]=ti(e.segment[1],t),pE(l,Bu)}function _2(s,e,t){let a=e.geometry;if(a.getType()==="Circle"&&e.index===Xd){let o=a,m=co();return m&&(o=o.clone().transform(m,t)),ql(o.getClosestPoint(ti(s,t)),t)}let l=ti(s,t);return Bu[0]=ti(e.segment[0],t),Bu[1]=ti(e.segment[1],t),ql(jx(l,Bu),t)}function KB(){let s=vI();return function(e,t){return s.Point}}var Hv=Xv;var YB=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,x2=/^([\d.]+),([\d.]+)$/,v2=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,Sg="stop-fetch",b2=s=>{let e=[];return s.forEach(t=>{let a=t.getGeometry()?.getCoordinates();a?.length&&e.push(...a)}),e},Kv=class s extends Mu{constructor(t={}){super(t);this.abortControllers={};this.cacheStationData={};this.format=new Ii({featureProjection:"EPSG:3857"});this.graphs=[];this.initialRouteDrag={};this.segments=[];this.snapToClosestStation=!1;this.useRawViaPoints=!1;this.viaPoints=[];this.element||this.createDefaultElement(),this.loading=!1,this.active=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 od({...t}),this.routingLayer=t.routingLayer||new Jl({source:new Ql,style:t.style}),this.onRouteError=t.onRouteError||(a=>{this.dispatchEvent(new zr("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()})}static getGraphsResolutions(t,a){let l=a.getView();return t.map(([,o,m])=>[l.getResolutionForZoom(o),l.getResolutionForZoom(m||o+1)])}abortRequests(){this.graphs.forEach(t=>{let a=t[0];this.abortControllers[a]&&this.abortControllers[a].abort(),this.abortControllers[a]=new AbortController}),this.abortControllers[Sg]?.abort(),this.abortControllers[Sg]=new AbortController,this.loading=!1}activate(){let t=this.getMap();t&&(this.format=new Ii({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())}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}addViaPoint(t,a=-1,l=0){this.viaPoints.splice(a===-1?this.viaPoints.length:a,l,t),this.drawRoute(),this.dispatchEvent(new zr("change:route"))}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new Hv({deleteCondition:t=>{let l=(t.target?.getFeaturesAtPixel(t.pixel,{hitTolerance:5})).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("index"));return u2(t)&&l?(this.removeViaPoint(l.get("index")),!0):!1},pixelTolerance:6,source:this.routingLayer?.getSource()||void 0}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}deactivate(){let t=this.getMap();t&&(this.modifyInteraction&&t.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(!0),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[Sg]);let t=this.viaPoints.map(a=>{if(Array.isArray(a)){let l=this.getMap()?.getView().getProjection(),[o,m]=Gl(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[Sg])),Promise.all(this.graphs.map(([a],l)=>{let{signal:o}=this.abortControllers[a];return this.api?this.api.route({"coord-punish":1e3,"coord-radius":100,elevation:!1,graph:a,mot:this.mot,"resolve-hops":!1,via:`${t.join("|")}`,...this.routingApiParams||{}},{signal:o}).then(m=>{if(this.segments=this.format.readFeatures(m),this.mot==="foot"){let A=this.segments.reduce((S,M)=>{let k=M.get("trg");return S.find(j=>j[0]===k[0]&&j[1]===k[1])?S:[...S,k]},[]);this.segments=A.map(S=>{let M=this.segments.filter(j=>{let Z=j.get("trg");return Z[0]===S[0]&&Z[1]===S[1]}),k=b2(M);return new Ao({geometry:new Go(k)})})}let g=b2(this.segments),b=new Ao({geometry:new Go(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 zr("error")),this.onRouteError(m,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(t,a,l){let o=new Ao;if(o.set("viaPointIdx",a),Array.isArray(t))return o.setGeometry(new Ei(t)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o);if(!this.useRawViaPoints||v2.test(t)){let S,M;return this.useRawViaPoints?[,S,,M]=v2.exec(t)||[]:[S,M]=t.split("$"),fetch(`${this.stopsApiUrl}lookup/${S}?key=${this.stopsApiKey}`,{signal:l.signal}).then(k=>k.json()).then(k=>{let{coordinates:j}=k.features[0].geometry;return this.cacheStationData[t]=Ai(j),o.set("viaPointTrack",M),o.setGeometry(new Ei(Ai(j))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(k=>{/AbortError/.test(k.message)||(this.dispatchEvent(new zr("error")),this.onRouteError(k,this),this.loading=!1)})}if(this.useRawViaPoints&&x2.test(t)){let[S,M]=x2.exec(t)||[];if(M&&S){let k=parseFloat(M),j=parseFloat(S),Z=Ai([k,j],this.getMap()?.getView().getProjection());return o.setGeometry(new Ei(Z)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}}let[,m,,g,b,,A]=YB.exec(t)||[];if(b&&g){let S=Ai([parseFloat(b),parseFloat(g)],this.getMap()?.getView().getProjection());return o.set("viaPointTrack",A),o.setGeometry(new Ei(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]=Ai(M),o.set("viaPointTrack",A),o.setGeometry(new Ei(Ai(M))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(S=>(this.dispatchEvent(new zr("error")),this.onRouteError(S,this),this.loading=!1,null)):Promise.resolve(null)}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}onMapClick(t){let l=t.target.getFeaturesAtPixel(t.pixel,{hitTolerance:5,layerFilter:o=>o===this.routingLayer}).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("viaPointIdx")!==void 0);if(l){this.removeViaPoint(l.get("viaPointIdx"));return}this.addViaPoint(t.coordinate)}onModifyEnd(t){let a=t.mapBrowserEvent.coordinate,{oldRoute:l,segmentIndex:o,viaPoint:m}=this.initialRouteDrag||{};return m?this.addViaPoint(a,m.get("viaPointIdx"),1):l?o===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(a,(o||0)+1):this.addViaPoint(a,0,1)}onModifyStart(t){let a=-1,l=t.features.getArray().find(m=>m.getGeometry()?.getType()==="LineString");if(l?.getGeometry()&&t.mapBrowserEvent.coordinate){let m=Ln(new Ei(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={oldRoute:l&&l.clone(),segmentIndex:a,viaPoint:o}}removeListeners(){this.onMapClickKey&&jl(this.onMapClickKey)}removeViaPoint(t=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[t]&&this.viaPoints.splice(t,1),this.drawRoute(),this.dispatchEvent(new zr("change:route"))}render(){}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new zr("change:route"))}setMap(t){super.setMap(t),t&&this.active?this.activate():t||(this.active=!1)}setViaPoints(t){this.viaPoints=[...t],this.drawRoute(),this.dispatchEvent(new zr("change:route"))}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)}},w2=Kv;var Yv=class{constructor(e){let{apiKey:t,apiParams:a,placeholder:l,url:o}=e||{};this.apiParams={limit:20,...a||{}},this.placeholder=l||"Search for a stop...";let m={apiKey:t};o&&(m.url=o),this.api=new sd(m),this.abortController=new AbortController,this.createElement(e),this.options=e}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=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",cursor:"pointer",overflowY:"auto"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{cursor:"pointer",display:"none",fontSize:"200%",padding:"0 10px",position:"absolute",right:"0"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}render(e){let 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)}))}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()})}},S2=Yv;var JB=()=>{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},A2=JB;var Jv=class extends Mu{constructor(e){let t=A2();t.className=e?.className||"mbt-stop-finder";let a={element:t,...e||{}};super(a),this.controller=new S2({onSuggestionClick:this.onSuggestionClick.bind(this),...a})}onSuggestionClick(e){let t=Ai(e.geometry.coordinates);this.getMap()?.getView().setCenter(t)}search(e,t){return this.controller.search(e,t)}},E2=Jv;var P2=ao(tb(),1);var QB="vectorTileFeature",rb={"EPSG:3857":new Ii({featureProjection:"EPSG:3857"})},Nu=class extends Du{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:Gl(m.center),zoom:m.zoom-1,bearing:aE(-m.rotation)});let g=t.getOpacity().toString();return o&&g!==o.style.opacity&&(o.style.opacity=g),o.isConnected?e3(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 Vi&&l(m,this.layer_,g)}),o?.[0]}getMapLibrePixels(e,t){if(!e)return;let a=this.getLayer().mapLibreMap?.project(Gl(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";rb[l]||(rb[l]=new Ii({featureProjection:l}));let o=rb[l].readFeature(e);return o&&o.set(QB,e,!0),o}};function e3(s,e){return s.width===Math.floor(e.size[0]*e.pixelRatio)&&s.height===Math.floor(e.size[1]*e.pixelRatio)}var t3=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(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),r3(a)},r3=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))},ib=t3;var ju=class extends qo{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(e){super({source:new pa({attributions:()=>ib(this.mapLibreMap)}),...e})}disposeInternal(){jl(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 P2.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 zr("load"))})}createRenderer(){return new Nu(this)}};var lb=ao(ec());var R2=ao(ec());var Pi=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Pi=(0,R2.default)(s=>{console.warn(s)},1e3));function v3(s){return class extends s{constructor(...a){let l=a[0];super(l);this.olEventsKeys=[];this.options={};l.properties&&(Pi("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||[])}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 Pi("Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead."),Nl(this)}onChildrenChange(a){(a||[]).forEach(l=>{l.set("parent",void 0)}),(this.get("children")||[]).forEach(l=>{l.set("parent",this)})}setMapInternal(a){super.setMapInternal(a),a?this.attachToMap(a):this.detachFromMap()}get children(){return Pi("Layer.children is deprecated. Use the Layer.get('children') method instead."),this.get("children")||[]}set children(a){Pi("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),this.set("children",a||[])}get copyrights(){return Pi("Layer.copyrights is deprecated. Get the attributions from the source object"),this.get("copyrights")}set copyrights(a){Pi("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 Pi("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),this.get("disabled")}set disabled(a){Pi("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),this.set("disabled",a)}get group(){return Pi("Layer.group is deprecated. Use the Layer.get('group') method instead."),this.get("group")}get hitTolerance(){return Pi("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")||Ut(this)}get map(){return this.getMapInternal()}get name(){return Pi("Layer.name is deprecated. Use the Layer.get('name') method instead."),this.get("name")}get olLayer(){return Pi("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){Pi("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.")}get parent(){return Pi("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),this.get("parent")}set parent(a){Pi("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),this.set("parent",a)}get visible(){return Pi("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),this.getVisible()}set visible(a){Pi("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),this.setVisible(a)}}}var k2=v3;function b3(s){return class extends k2(s){}}var Ss=b3;var F2=(s,e,t,a)=>Ol(`${s}/styles/${e}/style.json`,{[a]:t}).toString(),sb=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(sb=(0,lb.default)(s=>{console.warn(s)},1e3));var ab=class s extends Ss(ju){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&&typeof t.style=="string"&&(t.mapLibreOptions.style=F2(t.url,t.style,t.apiKey,t.apiKeyName)),super(t)}attachToMap(e){super.attachToMap(e);let t=(0,lb.default)(this.updateMaplibreMap.bind(this),150);t(),this.olEventsKeys.push(this.on("propertychange",a=>{/(url|style)/.test(a.key)&&t()}))}clone(e){return new s({...this.options||{},...e||{}})}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:F2(this.url,this.style,this.get("apiKey"),this.get("apiKeyName"))}updateMaplibreMap(){try{this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}catch(e){console.error("Error while updating MaplibreMap",e)}}get maplibreMap(){return sb("MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap."),this.mapLibreMap}get mbMap(){return sb("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get style(){return this.get("style")}set style(e){this.set("style",e)}get url(){return this.get("url")}set url(e){this.set("url",e)}},L2=ab;var D2=ao(ec());var cb={"EPSG:3857":new Ii({featureProjection:"EPSG:3857"})},Kd=class extends Du{forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{l(m,this.layer_,m.getGeometry())}),o?.[0]}getFeatures(e){let t=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(t))}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(cb[m]||(cb[m]=new Ii({featureProjection:m})),o?.isStyleLoaded()){let b=e&&o.project(Gl(e));if(b?.x&&b?.y){let A=[b.x,b.y];if(t){let[M,k]=A;A=[[M-t,k-t],[M+t,k+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 k=cb[m].readFeature(M);return k&&k.set(Tu,M),k})}}return g}prepareFrame(){return!0}renderFrame(){return null}};var Io=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Io=(0,D2.default)((...s)=>{console.warn(...s)},1e3));var ub=class s extends Ss(qo){constructor(t={mapLibreOptions:{style:{layers:[],sources:{},version:8}}}){t.mapboxLayer&&(Io("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),t.maplibreLayer=t.mapboxLayer,delete t.mapboxLayer);super({source:new pa({}),...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))}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())}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)})}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))}}}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))}))}clone(t){return new s({...this.options,...t})}createRenderer(){return new Kd(this)}detachFromMap(){this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources()),super.detachFromMap()}getFeatureInfoAtCoordinate(t){if(Io("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({coordinate:t,features:[],layer:this})}highlight(t=[]){Io("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)}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()}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)})}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)})}select(t=[]){Io("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=t,this.setHoverState(this.selectedFeatures||[],!0)}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(Tu)||{};if(!m&&!g||!o.getId()){o.getId()||Io("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",o.getProperties());return}l.setFeatureState({id:o.getId(),source:m,sourceLayer:g},a)})}setHoverState(t,a){Io(`Deprecated. Use layer.setFeatureState(features, {hover: ${a}}) instead.`),this.setFeatureState(t,{hover:a})}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 Io("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 Io("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(t){Io("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[t]}get styleLayers(){return Io("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(t){Io("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=t}},O2=ub;var fb=ao(ec());var pb=ao(ec()),db=ao(U2());function N3(s){return class extends s{constructor(t){super({hitTolerance:10,...t}),this.defineProperties(t),this.debug=t.debug||!1,this.mode=t.mode||Jr.TOPOGRAPHIC,this.api=t.api||new nd(t),this.tenant=t.tenant||"",this.minZoomInterpolation=t.minZoomInterpolation||8,this.format=new Ii,this.onStart=t.onStart,this.onStop=t.onStop,this.motsByZoom=t.motsByZoom||[Vo,Vo,Vo,Vo,Vo,Vo,Vo,Vo,Vo,tg,tg],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,db.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,pb.default)(this.renderTrajectoriesInternal,50,{leading:!0,maxWait:5e3,trailing:!0}),this.renderTrajectoriesInternal=this.renderTrajectoriesInternal.bind(this),this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}addTrajectory(t){this.trajectories||(this.trajectories={});let a=t.properties.train_id;a!==void 0&&(this.trajectories[a]=t),this.renderTrajectories()}attachToMap(t){super.attachToMap(t),document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}defineProperties(t){(super.defineProperties||(()=>{}))(t);let{bboxParameters:a,canvas:l,filter:o,hoverVehicleId:m,live:g,mode:b,pixelRatio:A,selectedVehicleId:S,sort:M,speed:k,style:j,styleOptions:Z,time:te}=t,q=l,H=k||1,ae=te||new Date,pe=b||Jr.TOPOGRAPHIC,ve=j||zl;Object.defineProperties(this,{bboxParameters:{value:a,writable:!0},canvas:{get:()=>(q||(q=document.createElement("canvas")),q),set:de=>{q=de}},filter:{value:o,writable:!0},hoverVehicleId:{value:m,writable:!0},isTrackerLayer:{value:!0},live:{value:g===!1?g:!0,writable:!0},mode:{get:()=>pe,set:de=>{de!==pe&&(pe=de,this.api?.wsApi?.open&&(this.stop(),this.start()))}},pixelRatio:{value:A||(typeof window<"u"?window.devicePixelRatio:1),writable:!0},selectedVehicleId:{value:S,writable:!0},sort:{value:M,writable:!0},speed:{get:()=>H,set:de=>{H=de,this.start()}},style:{get:()=>ve,set:de=>{ve=de,this.renderTrajectories()}},styleOptions:{value:{...Pu,...Z||{}}},time:{get:()=>ae,set:de=>{ae=de?.getTime?de:new Date(de),this.renderTrajectories()}},trajectories:{value:{},writable:!0},useDebounce:{value:t.useDebounce||!1,writable:!0},useRequestAnimationFrame:{value:t.useRequestAnimationFrame||!1,writable:!0},useThrottle:{value:t.useThrottle!==!1,writable:!0}})}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),jl(this.visibilityRef),this.canvas){let t=this.canvas.getContext("2d");t&&t.clearRect(0,0,this.canvas.width,this.canvas.height),super.detachFromMap()}}getFeatureInfoAtCoordinate(t,a){let{nb:l,resolution:o}=a,m=Ln([...t,...t],this.hitTolerance*o),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&&Js(m,S)&&b.push(g[A]),b.length===l)break}return Promise.resolve({coordinate:t,features:b.map(A=>this.format.readFeature(A)),layer:this})}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,db.default)(this.renderTrajectoriesInternal,m,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,pb.default)(this.renderTrajectoriesInternal,m,{leading:!0,maxWait:5e3,trailing:!0})),this.api?.buffer){let[,g]=this.api.buffer;this.api.buffer=[m,g]}return o}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])=>({fullTrajectory:o,stopSequence:l}))}getVehicle(t){return this.trajectories&&Object.values(this.trajectories).filter(t)||[]}highlightVehicle(t){this.hoverVehicleId!==t&&(this.hoverVehicleId=t,this.renderTrajectories(!0))}onDeleteTrajectoryMessage(t){t.content&&this.removeTrajectory(t.content)}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(this.getVisible()===!1)return;this.start()}}onTrajectoryMessage(t){if(!t.content)return;let a=t.content,{geometry:l,properties:{raw_coordinates:o,time_since_update:m,train_id:g}}=a;m<0||this.purgeTrajectory(a)||(this.debug&&this.mode===Jr.TOPOGRAPHIC&&o?a.properties.olGeometry=this.format.readGeometry({coordinates:Ai(o,this.map.getView().getProjection()),type:"Point"}):a.properties.olGeometry=this.format.readGeometry(l),a.properties.timeOffset=Date.now()-t.timestamp,this.addTrajectory(a))}onZoomEnd(){this.startUpdateTime()}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{bounds:o,type:m}=t.properties;return this.isUpdateBboxOnMoveEnd&&!ei(a,o)||this.mots&&!this.mots.includes(m)?(this.removeTrajectory(t),!0):!1}removeTrajectory(t){let a;typeof t!="string"?a=t?.properties?.train_id:a=t,a!==void 0&&this.trajectories&&delete this.trajectories[a]}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))}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=Td(this.canvas,o,this.style,{...t,pixelRatio:this.pixelRatio||1,time:l},{filter:this.filter,hoverVehicleId:this.hoverVehicleId,noInterpolate:(t.zoom||0)<this.minZoomInterpolation?!0:a,selectedVehicleId:this.selectedVehicleId,...this.styleOptions})),!0}selectVehicle(t){this.selectedVehicleId!==t&&(this.selectedVehicleId=t,this.renderTrajectories(!0))}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}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)}}}var Eg=N3;var j3=new Ii,Yd=class extends xg{forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{l(m,this.layer_,m.getGeometry())}),o?.[0]}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))}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 k=A[M];if(k.properties.coordinate&&Js(g,k.properties.coordinate)&&S.push(A[M]),S.length===m)break}return b=S.map(M=>j3.readFeature(M)),b}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){let S=t?.getContext("2d");t?.width&&t?.height&&S?.clearRect(0,0,t.width,t.height)}else{let S=this.getLayer().getMapInternal(),M=S?.getPixelFromCoordinate(g),k=S?.getPixelFromCoordinate(l);M&&k&&(this.container.style.transform=UA(M[0]-k[0],M[1]-k[1],b/o,b/o,m-A,0,0))}}return this.container}};var U3=new $i({zIndex:2,image:new Vn({radius:5,fill:new qi({color:"#000000"})}),stroke:new ai({color:"#000000",width:6})}),G3=(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,[U3,new $i({zIndex:3,image:new Vn({radius:4,fill:new qi({color:a})}),stroke:new ai({color:a,width:4})})]},Ig=G3;var V3=new $i({zIndex:2,image:new Vn({radius:5,fill:new qi({color:"#000000"})}),stroke:new ai({color:"#000000",width:6})}),q3=new $i({zIndex:3,image:new Vn({radius:4,fill:new qi({color:"#a0a0a0"})}),stroke:new ai({color:"#a0a0a0",width:4})}),$3=()=>[V3,q3],G2=$3;var V2=new Vn({radius:6,fill:new qi({color:[255,0,0,1]}),stroke:new ai({color:[0,0,0,1],width:1})}),W3=new $i({stroke:new ai({color:[0,0,0,1],width:5})}),Z3=new $i({image:V2,stroke:new ai({color:[255,0,0,1],width:3})}),X3=new $i({image:V2,stroke:new ai({color:[255,0,0,1],width:3,lineDash:[1,10]})}),H3=(s,e)=>{let t=s.get("minResolution"),a=s.get("maxResolution"),l=e<=t&&e>a;return t&&a&&!l?[]:s.get("mot")!=="foot"?[W3,Z3]:[X3]},q2=H3;var K3=new Ii,mb=class s extends Eg(Ss(qo)){constructor(t){super({source:new pa({}),...t});this.allowRenderWhenAnimating=!1;this.allowRenderWhenAnimating=!!t.allowRenderWhenAnimating,this.vectorLayer=new Jl({source:new Ql({features:[]}),style:(a,l)=>(t.fullTrajectoryStyle||Ig)(a,l,this.styleOptions),updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0}),this.renderState={center:[0,0],rotation:0,zoom:void 0},this.onZoomEndDebounced=(0,fb.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,fb.default)(this.onMoveEnd,100)}attachToMap(t){if(super.attachToMap(t),this.map){this.getVisible()&&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||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.getVisible()?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))}))}}clone(t){return new s({...this.options,...t})}createRenderer(){return new Yd(this)}detachFromMap(){this.map?.removeLayer(this.vectorLayer),super.detachFromMap()}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getView()?.getZoom()||0)}highlight(t){this.highlightVehicle(t?.get("train_id"))}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=K3.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([]))}onMoveEnd(t){!this.isUpdateBboxOnMoveEnd||!this.getVisible()||this.setBbox()}onZoomEnd(){super.onZoomEnd(),!(!this.isUpdateBboxOnMoveEnd||!this.getVisible())&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}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)}renderTrajectories(t){if(!this.map)return;let a=this.map.getView();a?.getCenter()&&super.renderTrajectories({center:a.getCenter(),extent:a.calculateExtent(),pixelRatio:this.pixelRatio,resolution:a.getResolution(),rotation:a.getRotation(),size:this.map.getSize(),zoom:a.getZoom()},t)}renderTrajectoriesInternal(t,a){if(!this.map?.getView())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}select(t){this.selectVehicle(t?.get("train_id")),this.highlightTrajectory(t?.get("train_id"))}setBbox(t,a){let l=t||this.map?.getView()?.calculateExtent();l&&super.setBbox(l,a||this.map?.getView()?.getZoom()||0)}},$2=mb;var W2=ao(ec());var Z2=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Z2=(0,W2.default)(s=>{console.warn(s)},1e3));var gb=class s extends Ss(qo){constructor(e){super(e),Z2("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(e){return new s({...this.options||{},...e||{}})}},Pg=gb;var yb=class s extends Pg{clone(e){return new s({...this.options,...e})}getFeatureInfoAtCoordinate(e){let t=[];if(this.map){let a=this.map.getPixelFromCoordinate(e);t=this.map.getFeaturesAtPixel(a,{hitTolerance:this.hitTolerance||5,layerFilter:l=>l===this.olLayer})||[]}return Promise.resolve({coordinate:e,features:t,layer:this})}},X2=yb;var Y3=new Ii,J3=(s,e,t)=>{let a,{coordinate:l,params:o,projection:m,resolution:g}=e;return s&&g&&m&&(a=s.getFeatureInfoUrl(l,g,m,{info_format:"application/json",query_layers:s.getParams().layers,...o})),fetch(a,{signal:t.signal}).then(b=>b.json()).then(b=>Y3.readFeatures(b)).catch(()=>[])},Jd={},Q3=async(s,e,t=5)=>{Object.values(Jd).forEach(o=>{o?.abort()}),Jd={};let l=Nl(e).map(o=>{let m=o.getMapInternal(),g=m?.getView()?.getProjection()?.getCode(),b={coordinate:s,features:[],layer:o};if(!g)return Promise.resolve(b);if(o.getFeatureInfoAtCoordinate)return o.getFeatureInfoAtCoordinate(s);let A=o?.getSource();if(A?.getFeatureInfoUrl){let k=Ut(o);Jd[k]?.abort(),Jd[k]=new AbortController;let j=m?.getView()?.getResolution();return J3(A,{coordinate:s,params:{info_format:"application/json",query_layers:A.getParams().layers},projection:g,resolution:j},Jd[k]).then(Z=>({coordinate:s,features:Z,layer:o})).catch(()=>({coordinate:s,features:[],layer:o}))}let S=m?.getPixelFromCoordinate(s);if(!S)return Promise.resolve(b);let M=m?.getFeaturesAtPixel(S,{hitTolerance:o.get("hitTolerance")||t||5,layerFilter:k=>k===o});return Promise.resolve({coordinate:s,features:M,layer:o})});return Promise.all(l)},H2=Q3;var Wy={};nx(Wy,{CopyrightControl:()=>K2,Layer:()=>Rg,RealtimeAPI:()=>nd,RealtimeLayer:()=>IL,RealtimeModes:()=>Jr,RoutingAPI:()=>od,StopsAPI:()=>sd,VECTOR_TILE_FEATURE_PROPERTY:()=>Tu,compareDepartures:()=>Cd,createCanvas:()=>zo,createRealtimeFilters:()=>bx,debounceDeparturesMessages:()=>h0,debounceWebsocketMessages:()=>id,getCircleCanvas:()=>yx,getDelayBgCanvas:()=>mx,getDelayTextCanvas:()=>gx,getHoursAndMinutes:()=>BA,getLayersAsFlatArray:()=>Nl,getMapGlCopyrights:()=>ad,getMercatorResolution:()=>EL,getSourceCoordinates:()=>$y,getTextCanvas:()=>_x,getUTCDateString:()=>OA,getUTCTimeString:()=>zA,getUrlWithParams:()=>Ol,getVehiclePosition:()=>Pd,pad:()=>Rm,realtimeConfig:()=>Pu,realtimeDefaultStyle:()=>zl,realtimeDelayStyle:()=>xx,realtimeSimpleStyle:()=>vx,removeDuplicate:()=>Bl,renderTrajectories:()=>Td,sortAndFilterDepartures:()=>Md,sortByDelay:()=>wx});var e5=" | ",_b=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||e5,t=this.options?.customAttribution||ad(this.map),a=(Array.isArray(t)?t:[t]).join(e);this.container.innerHTML!==a&&(this.content=a,this.container.innerHTML=this.content)}}},K2=_b;var Zi=[];for(Cg=0;Cg<256;++Cg)Zi.push((Cg+256).toString(16).slice(1));var Cg;function Y2(s,e=0){return(Zi[s[e+0]]+Zi[s[e+1]]+Zi[s[e+2]]+Zi[s[e+3]]+"-"+Zi[s[e+4]]+Zi[s[e+5]]+"-"+Zi[s[e+6]]+Zi[s[e+7]]+"-"+Zi[s[e+8]]+Zi[s[e+9]]+"-"+Zi[s[e+10]]+Zi[s[e+11]]+Zi[s[e+12]]+Zi[s[e+13]]+Zi[s[e+14]]+Zi[s[e+15]]).toLowerCase()}var Mg,t5=new Uint8Array(16);function xb(){if(!Mg&&(Mg=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Mg))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Mg(t5)}var r5=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),vb={randomUUID:r5};function i5(s,e,t){if(vb.randomUUID&&!e&&!s)return vb.randomUUID();s=s||{};var a=s.random||(s.rng||xb)();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 Y2(a)}var bb=i5;var J2=ao(tb()),wb=class extends J2.Evented{constructor(t={}){super();this.options={};this.type="custom";this.options=t,this.id=t.id||bb(),this.type="custom"}onAdd(t,a){this.map=t}onRemove(t,a){this.map=void 0}render(t){}},Rg=wb;var aL=ao(oL(),1),$G=Object.defineProperty,mr=(s,e)=>$G(s,"name",{value:e,configurable:!0}),WG=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||!bf(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=kw(e),l=kw(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(!bf(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 bf(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,aL.default)(e.properties,t.properties):!0)&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return bf(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)}};mr(WG,"GeojsonEquality");function bf(s,e){return s.coordinates?s.coordinates.length===e.coordinates.length:s.length===e.length}mr(bf,"sameLength");function kw(s){return s.coordinates.map(e=>({type:s.type.replace("Multi",""),coordinates:e}))}mr(kw,"explode");var Xi=63710088e-1,lL={centimeters:Xi*100,centimetres:Xi*100,degrees:360/(2*Math.PI),feet:Xi*3.28084,inches:Xi*39.37,kilometers:Xi/1e3,kilometres:Xi/1e3,meters:Xi,metres:Xi,miles:Xi/1609.344,millimeters:Xi*1e3,millimetres:Xi*1e3,nauticalmiles:Xi/1852,radians:1,yards:Xi*1.0936},sL={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 Jo(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}mr(Jo,"feature");function ZG(s,e,t={}){switch(s){case"Point":return Hi(e).geometry;case"LineString":return Ds(e).geometry;case"Polygon":return Fw(e).geometry;case"MultiPoint":return uL(e).geometry;case"MultiLineString":return cL(e).geometry;case"MultiPolygon":return hL(e).geometry;default:throw new Error(s+" is invalid")}}mr(ZG,"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(!Sc(s[0])||!Sc(s[1]))throw new Error("coordinates must contain numbers");return Jo({type:"Point",coordinates:s},e,t)}mr(Hi,"point");function XG(s,e,t={}){return Uy(s.map(a=>Hi(a,e)),t)}mr(XG,"points");function Fw(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 Jo({type:"Polygon",coordinates:s},e,t)}mr(Fw,"polygon");function HG(s,e,t={}){return Uy(s.map(a=>Fw(a,e)),t)}mr(HG,"polygons");function Ds(s,e,t={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return Jo({type:"LineString",coordinates:s},e,t)}mr(Ds,"lineString");function KG(s,e,t={}){return Uy(s.map(a=>Ds(a,e)),t)}mr(KG,"lineStrings");function Uy(s,e={}){let t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=s,t}mr(Uy,"featureCollection");function cL(s,e,t={}){return Jo({type:"MultiLineString",coordinates:s},e,t)}mr(cL,"multiLineString");function uL(s,e,t={}){return Jo({type:"MultiPoint",coordinates:s},e,t)}mr(uL,"multiPoint");function hL(s,e,t={}){return Jo({type:"MultiPolygon",coordinates:s},e,t)}mr(hL,"multiPolygon");function YG(s,e,t={}){return Jo({type:"GeometryCollection",geometries:s},e,t)}mr(YG,"geometryCollection");function JG(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}mr(JG,"round");function pL(s,e="kilometers"){let t=lL[e];if(!t)throw new Error(e+" units is invalid");return s*t}mr(pL,"radiansToLength");function Lw(s,e="kilometers"){let t=lL[e];if(!t)throw new Error(e+" units is invalid");return s/t}mr(Lw,"lengthToRadians");function QG(s,e){return Gy(Lw(s,e))}mr(QG,"lengthToDegrees");function eV(s){let e=s%360;return e<0&&(e+=360),e}mr(eV,"bearingToAzimuth");function Gy(s){return s%(2*Math.PI)*180/Math.PI}mr(Gy,"radiansToDegrees");function nl(s){return s%360*Math.PI/180}mr(nl,"degreesToRadians");function wf(s,e="kilometers",t="kilometers"){if(!(s>=0))throw new Error("length must be a positive number");return pL(Lw(s,e),t)}mr(wf,"convertLength");function tV(s,e="meters",t="kilometers"){if(!(s>=0))throw new Error("area must be a positive number");let a=sL[e];if(!a)throw new Error("invalid original units");let l=sL[t];if(!l)throw new Error("invalid final units");return s/a*l}mr(tV,"convertArea");function Sc(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}mr(Sc,"isNumber");function jh(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}mr(jh,"isObject");function rV(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(!Sc(e))throw new Error("bbox must only contain numbers")})}mr(rV,"validateBBox");function iV(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")}mr(iV,"validateId");var nV=Object.defineProperty,Ki=(s,e)=>nV(s,"name",{value:e,configurable:!0});function ma(s,e,t){if(s!==null)for(var a,l,o,m,g,b,A,S=0,M=0,k,j=s.type,Z=j==="FeatureCollection",te=j==="Feature",q=Z?s.features.length:1,H=0;H<q;H++){A=Z?s.features[H].geometry:te?s.geometry:s,k=A?A.type==="GeometryCollection":!1,g=k?A.geometries.length:1;for(var ae=0;ae<g;ae++){var pe=0,ve=0;if(m=k?A.geometries[ae]:A,m!==null){b=m.coordinates;var de=m.type;switch(S=t&&(de==="Polygon"||de==="MultiPolygon")?1:0,de){case null:break;case"Point":if(e(b,M,H,pe,ve)===!1)return!1;M++,pe++;break;case"LineString":case"MultiPoint":for(a=0;a<b.length;a++){if(e(b[a],M,H,pe,ve)===!1)return!1;M++,de==="MultiPoint"&&pe++}de==="LineString"&&pe++;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,H,pe,ve)===!1)return!1;M++}de==="MultiLineString"&&pe++,de==="Polygon"&&ve++}de==="Polygon"&&pe++;break;case"MultiPolygon":for(a=0;a<b.length;a++){for(ve=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,H,pe,ve)===!1)return!1;M++}ve++}pe++}break;case"GeometryCollection":for(a=0;a<m.geometries.length;a++)if(ma(m.geometries[a],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}Ki(ma,"coordEach");function oV(s,e,t,a){var l=t;return ma(s,function(o,m,g,b,A){m===0&&t===void 0?l=o:l=e(l,o,m,g,b,A)},a),l}Ki(oV,"coordReduce");function dL(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}}Ki(dL,"propEach");function sV(s,e,t){var a=t;return dL(s,function(l,o){o===0&&t===void 0?a=l:a=e(a,l,o)}),a}Ki(sV,"propReduce");function fL(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++);}Ki(fL,"featureEach");function aV(s,e,t){var a=t;return fL(s,function(l,o){o===0&&t===void 0?a=l:a=e(a,l,o)}),a}Ki(aV,"featureReduce");function lV(s){var e=[];return ma(s,function(t){e.push(t)}),e}Ki(lV,"coordAll");function Dw(s,e){var t,a,l,o,m,g,b,A,S,M,k=0,j=s.type==="FeatureCollection",Z=s.type==="Feature",te=j?s.features.length:1;for(t=0;t<te;t++){for(g=j?s.features[t].geometry:Z?s.geometry:s,A=j?s.features[t].properties:Z?s.properties:{},S=j?s.features[t].bbox:Z?s.bbox:void 0,M=j?s.features[t].id:Z?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,k,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,k,A,S,M)===!1)return!1;break}case"GeometryCollection":{for(a=0;a<o.geometries.length;a++)if(e(o.geometries[a],k,A,S,M)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}k++}}Ki(Dw,"geomEach");function cV(s,e,t){var a=t;return Dw(s,function(l,o,m,g,b){o===0&&t===void 0?a=l:a=e(a,l,o,m,g,b)}),a}Ki(cV,"geomReduce");function Vy(s,e){Dw(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(Jo(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(Jo(M,l),a,A)===!1)return!1}})}Ki(Vy,"flattenEach");function uV(s,e,t){var a=t;return Vy(s,function(l,o,m){o===0&&m===0&&t===void 0?a=l:a=e(a,l,o,m)}),a}Ki(uV,"flattenReduce");function mL(s,e){Vy(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(ma(t,function(M,k,j,Z,te){if(g===void 0||a>b||Z>A||te>S){g=M,b=a,A=Z,S=te,o=0;return}var q=Ds([g,M],t.properties);if(e(q,a,l,te,o)===!1)return!1;o++,g=M})===!1)return!1}}})}Ki(mL,"segmentEach");function hV(s,e,t){var a=t,l=!1;return mL(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}Ki(hV,"segmentReduce");function gL(s,e){if(!s)throw new Error("geojson is required");Vy(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(Ds(m[g],t.properties),a,l,g)===!1)return!1;break}}})}Ki(gL,"lineEach");function pV(s,e,t){var a=t;return gL(s,function(l,o,m,g){o===0&&t===void 0?a=l:a=e(a,l,o,m,g)}),a}Ki(pV,"lineReduce");function dV(s,e){if(e=e||{},!jh(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),Ds([b[o],b[o+1]],m,e);case"Polygon":return l<0&&(l=b.length+l),o<0&&(o=b[l].length+o-1),Ds([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),Ds([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),Ds([b[a][l][o],b[a][l][o+1]],m,e)}throw new Error("geojson is invalid")}Ki(dV,"findSegment");function fV(s,e){if(e=e||{},!jh(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")}Ki(fV,"findPoint");var mV=Object.defineProperty,gV=(s,e)=>mV(s,"name",{value:e,configurable:!0});function Ow(s,e={}){let t=0,a=0,l=0;return ma(s,function(o){t+=o[0],a+=o[1],l++},!0),Hi([t/l,a/l],e.properties)}gV(Ow,"centroid");var yV=Object.defineProperty,ol=(s,e)=>yV(s,"name",{value:e,configurable:!0});function Qo(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(Qo,"getCoord");function zw(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(zw,"getCoords");function yL(s){if(s.length>1&&Sc(s[0])&&Sc(s[1]))return!0;if(Array.isArray(s[0])&&s[0].length)return yL(s[0]);throw new Error("coordinates must only contain numbers")}ol(yL,"containsNumber");function _V(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(_V,"geojsonType");function xV(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(xV,"featureOf");function vV(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(vV,"collectionOf");function bV(s){return s.type==="Feature"?s.geometry:s}ol(bV,"getGeom");function wV(s,e){return s.type==="FeatureCollection"?"FeatureCollection":s.type==="GeometryCollection"?"GeometryCollection":s.type==="Feature"&&s.geometry!==null?s.geometry.type:s.type}ol(wV,"getType");var SV=Object.defineProperty,_L=(s,e)=>SV(s,"name",{value:e,configurable:!0});function Nw(s,e,t={}){let a;return t.final?a=Bw(Qo(e),Qo(s)):a=Bw(Qo(s),Qo(e)),a>180?-(360-a):a}_L(Nw,"rhumbBearing");function Bw(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(Gy(m)+360)%360}_L(Bw,"calculateRhumbBearing");var AV=Object.defineProperty,xL=(s,e)=>AV(s,"name",{value:e,configurable:!0});function jw(s,e,t={}){let a=Qo(s),l=Qo(e);l[0]+=l[0]-a[0]>180?-360:a[0]-l[0]>180?360:0;let o=vL(a,l);return wf(o,"meters",t.units)}xL(jw,"rhumbDistance");function vL(s,e,t){t=t===void 0?Xi: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}xL(vL,"calculateRhumbDistance");var EV=Object.defineProperty,bL=(s,e)=>EV(s,"name",{value:e,configurable:!0});function Uw(s,e,t,a={}){let l=e<0,o=wf(Math.abs(e),a.units,"meters");l&&(o=-Math.abs(o));let m=Qo(s),g=wL(m,o,t);return g[0]+=g[0]-m[0]>180?-360:m[0]-g[0]>180?360:0,Hi(g,a.properties)}bL(Uw,"rhumbDestination");function wL(s,e,t,a){a=a===void 0?Xi: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),k=l*Math.sin(g)/M;return[((o+k)*180/Math.PI+540)%360-180,A*180/Math.PI]}bL(wL,"calculateRhumbDestination");var IV=Object.defineProperty,Uh=(s,e)=>IV(s,"name",{value:e,configurable:!0});function Gw(s){if(!s)throw new Error("geojson is required");switch(s.type){case"Feature":return Vw(s);case"FeatureCollection":return SL(s);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return qy(s);default:throw new Error("unknown GeoJSON type")}}Uh(Gw,"clone");function Vw(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=qw(s.properties),s.geometry==null?e.geometry=null:e.geometry=qy(s.geometry),e}Uh(Vw,"cloneFeature");function qw(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]=qw(a):e[t]=a}),e}Uh(qw,"cloneProperties");function SL(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=>Vw(t)),e}Uh(SL,"cloneFeatureCollection");function qy(s){let e={type:s.type};return s.bbox&&(e.bbox=s.bbox),s.type==="GeometryCollection"?(e.geometries=s.geometries.map(t=>qy(t)),e):(e.coordinates=$w(s.coordinates),e)}Uh(qy,"cloneGeometry");function $w(s){let e=s;return typeof e[0]!="object"?e.slice():e.map(t=>$w(t))}Uh($w,"deepSlice");var PV=Object.defineProperty,TV=(s,e)=>PV(s,"name",{value:e,configurable:!0});function AL(s,e,t){if(t=t||{},!jh(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=Ow(s)),(l===!1||l===void 0)&&(s=Gw(s)),ma(s,function(o){var m=Nw(a,o),g=m+e,b=jw(a,o),A=zw(Uw(a,b,g));o[0]=A[0],o[1]=A[1]})),s}TV(AL,"transformRotate");var Ww=AL;var CV=(s,e=1)=>{let{height:t,width:a}=s.getCanvas(),l=s.unproject({x:0,y:0}),o=s.unproject({x:0,y:t/e}),m=s.unproject({x:a/e,y:t/e}),g=s.unproject({x:a/e,y:0});return[[l.lng,l.lat],[g.lng,g.lat],[m.lng,m.lat],[o.lng,o.lat]]},$y=CV;var MV=s=>{let e=s.getBounds().toArray(),t=Ai(e[0]),a=Ai(e[1]),l=[...t,...a],{width:o,height:m}=s.getCanvas(),g=kr(l)/o,b=si(l)/m;return Math.max(g,b)},EL=MV;var RV=s=>dd(s.toArray().flat(),"EPSG:4326","EPSG:3857"),Zw=RV;var Xw=class extends Eg(Rg){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=Ww(Hi([o.lng,o.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,b=Ww(Hi([m.lng,m.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,A=[...Ai(g),...Ai(b)],S=kr(A)/(t/this.pixelRatio),M=si(A)/(a/this.pixelRatio),k=Math.max(S,M),j={size:[t/this.pixelRatio,a/this.pixelRatio],center:Ai([l.lng,l.lat]),extent:A,resolution:k,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||Zw(this.map.getBounds()),a||Math.floor(this.map.getZoom()-1))}setBbox(e,t){super.setBbox(e||Zw(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=$y(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()}},IL=Xw;var Hw={ol:Tg,maplibre:Wy};typeof window<"u"&&(window.mbt=Hw);var Ooe=Hw;})();
588
+ `){Tt+=pt,pt=0,ut=k*ve+Ae*j,++nt;continue}let Bt=Z[dt+1]||b.font;Bt!==yt&&(l&&Ve.push("font",Bt),a&&Ue.push("font",Bt),yt=Bt),pt=Math.max(pt,ae[Qe]);let jt=[bt,ut+Ae*H[Qe]+k*(H[Qe]-pe[nt]),.5*(j+pt)+Tt];ut+=H[Qe],l&&Ve.push("strokeText",jt),a&&Ue.push("fillText",jt),++Qe}return Array.prototype.push.apply(de,Ve),Array.prototype.push.apply(de,Ue),this.labels_[o]=Re,Re}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,k,j,Z,te,q){g*=k[0],b*=k[1];let H=a-g,ae=l-b,pe=o+A>e?e-A:o,ve=m+S>t?t-S:m,de=Z[3]+pe*k[0]+Z[1],_e=Z[0]+ve*k[1]+Z[2],Pe=H-Z[3],Re=ae-Z[0];(te||M!==0)&&(Ya[0]=Pe,Ja[0]=Pe,Ya[1]=Re,ua[1]=Re,ua[0]=Pe+de,ha[0]=ua[0],ha[1]=Re+_e,Ja[1]=ha[1]);let Ae;return M!==0?(Ae=ln(wi(),a,l,1,1,M,-a,-l),Ni(Ae,Ya),Ni(Ae,ua),Ni(Ae,ha),Ni(Ae,Ja),ea(Math.min(Ya[0],ua[0],ha[0],Ja[0]),Math.min(Ya[1],ua[1],ha[1],Ja[1]),Math.max(Ya[0],ua[0],ha[0],Ja[0]),Math.max(Ya[1],ua[1],ha[1],Ja[1]),zu)):ea(Math.min(Pe,Pe+de),Math.min(Re,Re+_e),Math.max(Pe,Pe+de),Math.max(Re,Re+_e),zu),j&&(H=Math.round(H),ae=Math.round(ae)),{drawImageX:H,drawImageY:ae,drawImageW:pe,drawImageH:ve,originX:A,originY:S,declutterBox:{minX:zu[0],minY:zu[1],maxX:zu[2],maxY:zu[3],value:q},canvasTransform:Ae,scale:k}}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,Ya,ua,ha,Ja,m,g),yI(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=Ni(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=Sv(Array.isArray(e)?e[0]:e,o.textAlign||Xa),S=$d[o.textBaseline||Hl],M=g&&g.lineWidth?g.lineWidth:0,k=m.width/b-2*o.scale[0],j=A*k+2*(.5-A)*M,Z=S*m.height/b+2*(.5-S)*M;return{label:m,anchorX:j,anchorY:Z}}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_),jA(this.renderedTransform_,a));let M=0,k=l.length,j=0,Z,te,q,H,ae,pe,ve,de,_e,Pe,Re,Ae,ut,Ve=0,Ue=0,pt=null,Tt=null,Qe=this.coordinateCache_,nt=this.viewRotation_,yt=Math.round(Math.atan2(-a[1],a[0])*1e12)/1e12,dt={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:nt},Rt=this.instructions!=l||this.overlaps?0:200,bt,Bt,jt,Pr;for(;M<k;){let $e=l[M];switch($e[0]){case xt.BEGIN_GEOMETRY:bt=$e[1],Pr=$e[3],bt.getGeometry()?g!==void 0&&!ei(g,Pr.getExtent())?M=$e[2]+1:++M:M=$e[2],A&&(A.zIndex=$e[4]);break;case xt.BEGIN_PATH:Ve>Rt&&(this.fill_(e),Ve=0),Ue>Rt&&(e.stroke(),Ue=0),!Ve&&!Ue&&(e.beginPath(),ae=NaN,pe=NaN),++M;break;case xt.CIRCLE:j=$e[1];let Lr=S[j],Mi=S[j+1],Ri=S[j+2],En=S[j+3],ii=Ri-Lr,In=En-Mi,Pn=Math.sqrt(ii*ii+In*In);e.moveTo(Lr+Pn,Mi),e.arc(Lr,Mi,Pn,0,2*Math.PI,!0),++M;break;case xt.CLOSE_PATH:e.closePath(),++M;break;case xt.CUSTOM:j=$e[1],Z=$e[2];let Wn=$e[3],Ee=$e[4],Zn=$e[5];dt.geometry=Wn,dt.feature=bt,M in Qe||(Qe[M]=[]);let ki=Qe[M];Zn?Zn(S,j,Z,2,ki):(ki[0]=S[j],ki[1]=S[j+1],ki.length=2),A&&(A.zIndex=$e[6]),Ee(ki,dt),++M;break;case xt.DRAW_IMAGE:j=$e[1],Z=$e[2],_e=$e[3],te=$e[4],q=$e[5];let Et=$e[6],ir=$e[7],Xn=$e[8],Tn=$e[9],Yi=$e[10],Cn=$e[11],Fi=$e[12],po=$e[13];H=$e[14]||"declutter";let Hn=$e[15];if(!_e&&$e.length>=20){Pe=$e[19],Re=$e[20],Ae=$e[21],ut=$e[22];let le=this.drawLabelWithPointPlacement_(Pe,Re,Ae,ut);_e=le.label,$e[3]=_e;let he=$e[23];te=(le.anchorX-he)*this.pixelRatio,$e[4]=te;let me=$e[24];q=(le.anchorY-me)*this.pixelRatio,$e[5]=q,Et=_e.height,$e[6]=Et,po=_e.width,$e[13]=po}let Be;$e.length>25&&(Be=$e[25]);let Ji,jr,Li;$e.length>17?(Ji=$e[16],jr=$e[17],Li=$e[18]):(Ji=sa,jr=!1,Li=!1),Yi&&yt?Cn+=nt:!Yi&&!yt&&(Cn-=nt);let fo=0;for(;j<Z;j+=2){if(Be&&Be[fo++]<po/this.pixelRatio)continue;let le=this.calculateImageOrLabelDimensions_(_e.width,_e.height,S[j],S[j+1],po,Et,te,q,Xn,Tn,Cn,Fi,o,Ji,jr||Li,bt),he=[e,t,_e,le,ir,jr?pt:null,Li?Tt:null];if(b){let me,se,Se;if(Hn){let De=Z-j;if(!Hn[De]){Hn[De]={args:he,declutterMode:H};continue}let Ke=Hn[De];me=Ke.args,se=Ke.declutterMode,delete Hn[De],Se=qI(me)}let Ce,be;if(me&&(se!=="declutter"||!b.collides(Se))&&(Ce=!0),(H!=="declutter"||!b.collides(le.declutterBox))&&(be=!0),se==="declutter"&&H==="declutter"){let De=Ce&&be;Ce=De,be=De}Ce&&(se!=="none"&&b.insert(Se),this.replayImageOrLabel_.apply(this,me)),be&&(H!=="none"&&b.insert(le.declutterBox),this.replayImageOrLabel_.apply(this,he))}else this.replayImageOrLabel_.apply(this,he)}++M;break;case xt.DRAW_CHARS:let je=$e[1],Ct=$e[2],ft=$e[3],ci=$e[4];ut=$e[5];let dn=$e[6],wt=$e[7],fn=$e[8];Ae=$e[9];let mn=$e[10];Pe=$e[11],Re=$e[12];let Kn=[$e[13],$e[13]];H=$e[14]||"declutter";let Qi=this.textStates[Re],ie=Qi.font,N=[Qi.scale[0]*wt,Qi.scale[1]*wt],B;ie in this.widths_?B=this.widths_[ie]:(B={},this.widths_[ie]=B);let $=Ym(S,je,Ct,2),Q=Math.abs(N[0])*q0(ie,Pe,B);if(ci||Q<=$){let le=this.textStates[Re].textAlign,he=($-Q)*Sv(Pe,le),me=VI(S,je,Ct,2,Pe,he,dn,Math.abs(N[0]),q0,ie,B,yt?0:this.viewRotation_);e:if(me){let se=[],Se,Ce,be,De,Ke;if(Ae)for(Se=0,Ce=me.length;Se<Ce;++Se){Ke=me[Se],be=Ke[4],De=this.createLabel(be,Re,"",Ae),te=Ke[2]+(N[0]<0?-mn:mn),q=ft*De.height+(.5-ft)*2*mn*N[1]/N[0]-fn;let ot=this.calculateImageOrLabelDimensions_(De.width,De.height,Ke[0],Ke[1],De.width,De.height,te,q,0,0,Ke[3],Kn,!1,sa,!1,bt);if(b&&H==="declutter"&&b.collides(ot.declutterBox))break e;se.push([e,t,De,ot,1,null,null])}if(ut)for(Se=0,Ce=me.length;Se<Ce;++Se){Ke=me[Se],be=Ke[4],De=this.createLabel(be,Re,ut,""),te=Ke[2],q=ft*De.height-fn;let ot=this.calculateImageOrLabelDimensions_(De.width,De.height,Ke[0],Ke[1],De.width,De.height,te,q,0,0,Ke[3],Kn,!1,sa,!1,bt);if(b&&H==="declutter"&&b.collides(ot.declutterBox))break e;se.push([e,t,De,ot,1,null,null])}b&&H!=="none"&&b.load(se.map(qI));for(let ot=0,At=se.length;ot<At;++ot)this.replayImageOrLabel_.apply(this,se[ot])}}++M;break;case xt.END_GEOMETRY:if(m!==void 0){bt=$e[1];let le=m(bt,Pr,H);if(le)return le}++M;break;case xt.FILL:Rt?Ve++:this.fill_(e),++M;break;case xt.MOVE_TO_LINE_TO:for(j=$e[1],Z=$e[2],Bt=S[j],jt=S[j+1],e.moveTo(Bt,jt),ae=Bt+.5|0,pe=jt+.5|0,j+=2;j<Z;j+=2)Bt=S[j],jt=S[j+1],ve=Bt+.5|0,de=jt+.5|0,(j==Z-2||ve!==ae||de!==pe)&&(e.lineTo(Bt,jt),ae=ve,pe=de);++M;break;case xt.SET_FILL_STYLE:pt=$e,this.alignAndScaleFill_=$e[2],Ve&&(this.fill_(e),Ve=0,Ue&&(e.stroke(),Ue=0)),e.fillStyle=$e[1],++M;break;case xt.SET_STROKE_STYLE:Tt=$e,Ue&&(e.stroke(),Ue=0),this.setStrokeStyle_(e,$e),++M;break;case xt.STROKE:Rt?Ue++:e.stroke(),++M;break;default:++M;break}}Ve&&this.fill_(e),Ue&&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)}},WI=Av;var Yl=["Polygon","Circle","LineString","Image","Text","Default"],Pv=["Image","Text"],ZI=Yl.filter(s=>!Pv.includes(s)),Iv=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_=wi(),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 WI(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=ln(this.hitDetectionTransform_,l+.5,l+.5,1/t,-1/t,-a,-e[0],-e[1]),A=!this.hitDetectionContext_;A&&(this.hitDetectionContext_=Xr(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(),Cx(M,e),Ln(M,t*(this.renderBuffer_+l),M));let k=xB(l),j;function Z(de,_e,Pe){let Re=S.getImageData(0,0,g,g).data;for(let Ae=0,ut=k.length;Ae<ut;Ae++)if(Re[k[Ae]]>0){if(!m||Pe==="none"||j!=="Image"&&j!=="Text"||m.includes(de)){let Ve=(k[Ae]-3)/4,Ue=l-Ve%g,pt=l-(Ve/g|0),Tt=o(de,_e,Ue*Ue+pt*pt);if(Tt)return Tt}S.clearRect(0,0,g,g);break}}let te=Object.keys(this.executorsByZIndex_).map(Number);te.sort(Bo);let q,H,ae,pe,ve;for(q=te.length-1;q>=0;--q){let de=te[q].toString();for(ae=this.executorsByZIndex_[de],H=Yl.length-1;H>=0;--H)if(j=Yl[H],pe=ae[j],pe!==void 0&&(ve=pe.executeHitDetection(S,b,a,Z,M),ve))return ve}}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 lo(this.executorsByZIndex_)}execute(e,t,a,l,o,m,g){let b=Object.keys(this.executorsByZIndex_).map(Number);b.sort(Bo),m=m||Yl;let A=Yl.length,S,M,k,j,Z;for(g&&b.reverse(),S=0,M=b.length;S<M;++S){let te=b[S].toString();for(Z=this.executorsByZIndex_[te],k=0,j=m.length;k<j;++k){let q=m[k],H=Z[q];if(H!==void 0){let ae=g===null?void 0:H.getZIndexContext(),pe=ae?ae.getContext():e,ve=this.maxExtent_&&q!=="Image"&&q!=="Text";if(ve&&(pe.save(),this.clip(pe,a)),!ae||q==="Text"||q==="Image"?H.execute(pe,t,a,l,o,g):ae.pushFunction(de=>H.execute(de,t,a,l,o,g)),ve&&pe.restore(),ae){ae.offset();let de=b[S]*A+k;this.deferredZIndexContexts_[de]||(this.deferredZIndexContexts_[de]=[]),this.deferredZIndexContexts_[de].push(ae)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(Bo);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}},Ev={};function xB(s){if(Ev[s]!==void 0)return Ev[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 Ev[s]=l,l}var XI=Iv;var Tv=class extends yg{constructor(e,t,a,l,o,m,g){super(),this.context_=e,this.pixelRatio_=t,this.extent_=a,this.transform_=l,this.transformRotation_=l?cE(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_=wi()}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 k=o[S]-this.imageAnchorX_,j=o[S+1]-this.imageAnchorY_;if(A!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let Z=k+this.imageAnchorX_,te=j+this.imageAnchorY_;ln(g,Z,te,1,1,A,-Z,-te),m.save(),m.transform.apply(m,g),m.translate(Z,te),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_,k,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_)),!!ei(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=AE(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_)),!!ei(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(ei(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_)),!!ei(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_)),!!ei(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:Xa;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:jn(a||li)}}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:ys,lineDash:this.pixelRatio_===1?S:S.map(M=>M*this.pixelRatio_),lineDashOffset:(m||Gn)*this.pixelRatio_,lineJoin:g!==void 0?g:_s,lineWidth:(b!==void 0?b:aa)*this.pixelRatio_,miterLimit:A!==void 0?A:na,strokeStyle:jn(a||oa)}}}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:jn(j||li)}}let a=e.getStroke();if(!a)this.textStrokeState_=null;else{let j=a.getColor(),Z=a.getLineCap(),te=a.getLineDash(),q=a.getLineDashOffset(),H=a.getLineJoin(),ae=a.getWidth(),pe=a.getMiterLimit();this.textStrokeState_={lineCap:Z!==void 0?Z:ys,lineDash:te||Un,lineDashOffset:q||Gn,lineJoin:H!==void 0?H:_s,lineWidth:ae!==void 0?ae:aa,miterLimit:pe!==void 0?pe:na,strokeStyle:jn(j||oa)}}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(),k=e.getTextBaseline();this.textState_={font:l!==void 0?l:ug,textAlign:M!==void 0?M:Xa,textBaseline:k!==void 0?k:Hl},this.text_=S!==void 0?Array.isArray(S)?S.reduce((j,Z,te)=>j+=te%2?" ":Z,""):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]]}}},HI=Tv;var Ko=.5;function KI(s,e,t,a,l,o,m,g,b){let A=b?ds(l,b):l,S=s[0]*Ko,M=s[1]*Ko,k=Xr(S,M);k.imageSmoothingEnabled=!1;let j=k.canvas,Z=new HI(k,Ko,l,null,m,g,b?Au(co(),b):null),te=t.length,q=Math.floor((256*256*256-1)/te),H={};for(let pe=1;pe<=te;++pe){let ve=t[pe-1],de=ve.getStyleFunction()||a;if(!de)continue;let _e=de(ve,o);if(!_e)continue;Array.isArray(_e)||(_e=[_e]);let Re=(pe*q).toString(16).padStart(7,"#00000");for(let Ae=0,ut=_e.length;Ae<ut;++Ae){let Ve=_e[Ae],Ue=Ve.getGeometryFunction()(ve);if(!Ue||!ei(A,Ue.getExtent()))continue;let pt=Ve.clone(),Tt=pt.getFill();Tt&&Tt.setColor(Re);let Qe=pt.getStroke();Qe&&(Qe.setColor(Re),Qe.setLineDash(null)),pt.setText(void 0);let nt=Ve.getImage();if(nt){let bt=nt.getImageSize();if(!bt)continue;let Bt=Xr(bt[0],bt[1],void 0,{alpha:!1}),jt=Bt.canvas;Bt.fillStyle=Re,Bt.fillRect(0,0,jt.width,jt.height),pt.setImage(new Dd({img:jt,anchor:nt.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:nt.getOrigin(),opacity:1,size:nt.getSize(),scale:nt.getScale(),rotation:nt.getRotation(),rotateWithView:nt.getRotateWithView()}))}let yt=pt.getZIndex()||0,dt=H[yt];dt||(dt={},H[yt]=dt,dt.Polygon=[],dt.Circle=[],dt.LineString=[],dt.Point=[]);let Rt=Ue.getType();if(Rt==="GeometryCollection"){let bt=Ue.getGeometriesArrayRecursive();for(let Bt=0,jt=bt.length;Bt<jt;++Bt){let Pr=bt[Bt];dt[Pr.getType().replace("Multi","")].push(Pr,pt)}}else dt[Rt.replace("Multi","")].push(Ue,pt)}}let ae=Object.keys(H).map(Number).sort(Bo);for(let pe=0,ve=ae.length;pe<ve;++pe){let de=H[ae[pe]];for(let _e in de){let Pe=de[_e];for(let Re=0,Ae=Pe.length;Re<Ae;Re+=2){Z.setStyle(Pe[Re+1]);for(let ut=0,Ve=e.length;ut<Ve;++ut)Z.setTransform(e[ut]),Z.drawGeometry(Pe[Re])}}}return k.getImageData(0,0,j.width,j.height)}function YI(s,e,t){let a=[];if(t){let l=Math.floor(Math.round(s[0])*Ko),o=Math.floor(Math.round(s[1])*Ko),m=(Br(l,0,t.width-1)+Br(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 vB=.5,JI={Point:PB,LineString:AB,Polygon:CB,MultiPoint:TB,MultiLineString:EB,MultiPolygon:IB,GeometryCollection:SB,Circle:bB};function QI(s,e){return parseInt(Ut(s),10)-parseInt(Ut(e),10)}function Cv(s,e){let t=Mv(s,e);return t*t}function Mv(s,e){return vB*s/e}function bB(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 Rv(s,e,t,a,l,o,m,g){let b=[],A=t.getImage();if(A){let k=!0,j=A.getImageState();j==Mt.LOADED||j==Mt.ERROR?k=!1:j==Mt.IDLE&&A.load(),k&&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)),wB(s,e,t,a,o,m,g),M}function wB(s,e,t,a,l,o,m){let g=t.getGeometryFunction()(e);if(!g)return;let b=g.simplifyTransformed(a,l);if(t.getRenderer())e2(s,b,t,e,m);else{let S=JI[b.getType()];S(s,b,t,e,m,o)}}function e2(s,e,t,a,l){if(e.getType()=="GeometryCollection"){let m=e.getGeometries();for(let g=0,b=m.length;g<b;++g)e2(s,m[g],t,a,l);return}s.getBuilder(t.getZIndex(),"Default").drawCustom(e,a,t.getRenderer(),t.getHitDetectionRenderer(),l)}function SB(s,e,t,a,l,o){let m=e.getGeometriesArray(),g,b;for(g=0,b=m.length;g<b;++g){let A=JI[m[g].getType()];A(s,m[g],t,a,l,o)}}function AB(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 EB(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 IB(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 PB(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()!=Mt.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 TB(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()!=Mt.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 CB(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 kv=class extends xg{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(),k=this.getLayer().getDeclutter(),j=t.pixelRatio,Z=t.viewHints,te=!(Z[Bn.ANIMATING]||Z[Bn.INTERACTING]),q=this.context,H=Math.round(kr(l)/g*j),ae=Math.round(si(l)/g*j),pe=M.getWrapX()&&b.canWrapX(),ve=pe?kr(S):null,de=pe?Math.ceil((l[2]-S[2])/ve)+1:1,_e=pe?Math.floor((l[0]-S[0])/ve):0;do{let Pe=this.getRenderTransform(m,g,0,j,H,ae,_e*ve);t.declutter&&(Pe=Pe.slice(0)),e.execute(q,[q.canvas.width,q.canvas.height],Pe,A,te,a===void 0?Yl:a?Pv:ZI,a?k&&t.declutter[k]:void 0)}while(++_e<de)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Xr(this.context.canvas.width,this.context.canvas.height,wv))}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,JE(this.context),wv.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(ms.PRERENDER)||this.getLayer().hasListener(ms.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(o,e);let b=l.projection;if(this.clipped_=!1,g&&a.extent&&this.clipping){let A=fs(a.extent,b);g=ei(A,e.extent),this.clipped_=g&&!Qs(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]*Ko,k=a[1]*Ko;S.push(this.getRenderTransform(l,o,m,Ko,M,k,0).slice());let j=A.getSource(),Z=g.getExtent();if(j.getWrapX()&&g.canWrapX()&&!Qs(Z,b)){let q=b[0],H=kr(Z),ae=0,pe;for(;q<Z[0];)--ae,pe=H*ae,S.push(this.getRenderTransform(l,o,m,Ko,M,k,pe).slice()),q+=H;for(ae=0,q=b[2];q>Z[2];)++ae,pe=H*ae,S.push(this.getRenderTransform(l,o,m,Ko,M,k,pe).slice()),q-=H}let te=co();this.hitDetectionImageData_=KI(a,S,this.renderedFeatures_,A.getStyleFunction(),b,o,m,Cv(o,this.renderedPixelRatio_),te?g:null)}t(YI(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(Z,te,q){let H=Ut(Z),ae=A[H];if(ae){if(ae!==!0&&q<ae.distanceSq){if(q===0)return A[H]=!0,o.splice(o.lastIndexOf(ae),1),l(Z,b,te);ae.geometry=te,ae.distanceSq=q}}else{if(q===0)return A[H]=!0,l(Z,b,te);o.push(A[H]={feature:Z,layer:b,geometry:te,distanceSq:q,callback:l})}},M,k=[this.replayGroup_],j=this.getLayer().getDeclutter();return k.some(Z=>M=Z.forEachFeatureAtCoordinate(e,m,g,a,S,j&&t.declutter[j]?t.declutter[j].all().map(te=>te.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,k=e.pixelRatio,j=t.getRevision(),Z=t.getRenderBuffer(),te=t.getRenderOrder();te===void 0&&(te=QI);let q=A.center.slice(),H=Ln(b,Z*M),ae=H.slice(),pe=[H.slice()],ve=S.getExtent();if(a.getWrapX()&&S.canWrapX()&&!Qs(ve,e.extent)){let Qe=kr(ve),nt=Math.max(kr(H)/2,Qe);H[0]=ve[0]-nt,H[2]=ve[2]+nt,dE(q,S);let yt=Dx(pe[0],S);yt[0]<ve[0]&&yt[2]<ve[2]?pe.push([yt[0]+Qe,yt[1],yt[2]+Qe,yt[3]]):yt[0]>ve[0]&&yt[2]>ve[2]&&pe.push([yt[0]-Qe,yt[1],yt[2]-Qe,yt[3]])}if(this.ready&&this.renderedResolution_==M&&this.renderedRevision_==j&&this.renderedRenderOrder_==te&&this.renderedFrameDeclutter_===!!e.declutter&&Qs(this.wrappedRenderedExtent_,H))return Fn(this.renderedExtent_,ae)||(this.hitDetectionImageData_=null,this.renderedExtent_=ae),this.renderedCenter_=q,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let de=new UI(Mv(M,k),H,M,k),_e=co(),Pe;if(_e){for(let Qe=0,nt=pe.length;Qe<nt;++Qe){let yt=pe[Qe],dt=ds(yt,S);a.loadFeatures(dt,xE(M,S),_e)}Pe=Au(_e,S)}else for(let Qe=0,nt=pe.length;Qe<nt;++Qe)a.loadFeatures(pe[Qe],M,S);let Re=Cv(M,k),Ae=!0,ut=(Qe,nt)=>{let yt,dt=Qe.getStyleFunction()||t.getStyleFunction();if(dt&&(yt=dt(Qe,M)),yt){let Rt=this.renderFeature(Qe,Re,yt,de,Pe,this.getLayer().getDeclutter(),nt);Ae=Ae&&!Rt}},Ve=ds(H,S),Ue=a.getFeaturesInExtent(Ve);te&&Ue.sort(te);for(let Qe=0,nt=Ue.length;Qe<nt;++Qe)ut(Ue[Qe],Qe);this.renderedFeatures_=Ue,this.ready=Ae;let pt=de.finish(),Tt=new XI(H,M,k,a.getOverlaps(),pt,t.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=M,this.renderedRevision_=j,this.renderedRenderOrder_=te,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=ae,this.wrappedRenderedExtent_=H,this.renderedCenter_=q,this.renderedProjection_=S,this.renderedPixelRatio_=k,this.replayGroup_=Tt,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=Rv(l,e,a[A],t,this.boundHandleStyleImageChange_,o,m,g)||b;else b=Rv(l,e,a,t,this.boundHandleStyleImageChange_,o,m,g);return b}},t2=kv;var Fv=class extends DI{constructor(e){super(e)}createRenderer(){return new t2(this)}},Jl=Fv;var r2=ao(J0(),1);var Lv=class{constructor(e){this.rbush_=new r2.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_[Ut(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_[Ut(g)]=b}this.rbush_.load(a)}remove(e){let t=Ut(e),a=this.items_[t];return delete this.items_[t],this.rbush_.remove(a)!==null}update(e,t){let a=this.items_[Ut(t)],l=[a.minX,a.minY,a.maxX,a.maxY];jm(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 lo(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let t=this.rbush_.toJSON();return ea(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]}},Wd=Lv;var i2=wi(),Zd=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_):vu(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=bo(this.getExtent());this.flatInteriorPoints_=Sd(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=zE(this.flatCoordinates_,this.ends_),t=eg(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Jm(this.flatCoordinates_,0,e,2,t)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Zl(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=Zl(e,t,m,2,.5);ji(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=Zr(e);let t=e.getExtent(),a=e.getWorldExtent();if(t&&a){let l=si(a)/si(t);ln(i2,a[0],a[3],l,-l,0,0,0),zn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,i2,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=Dm((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=Wl(a,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,a,0),l=[a.length];break;case"MultiLineString":l=[],a.length=Xm(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,a,0,l);break;case"Polygon":l=[],a.length=_d(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}};Zd.prototype.getFlatCoordinates=Zd.prototype.getOrientedFlatCoordinates;var Eo=Zd;var Dv=class extends Si{constructor(e){super(),this.projection=Zr(e.projection),this.attributions_=n2(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_=n2(e),this.changed()}setState(e){this.state_=e,this.changed()}};function n2(s){return s?Array.isArray(s)?function(e){return s}:typeof s=="function"?s:function(e){return[s]}:null}var pa=Dv;var hn={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function o2(s,e){return[[-1/0,-1/0,1/0,1/0]]}var MB=!1;function RB(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=MB,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 Ov(s,e){return function(t,a,l,o,m){let g=this;RB(s,e,t,a,l,function(b,A){g.addFeatures(b),o!==void 0&&o(b)},m||No)}}var ws=class extends zr{constructor(e,t,a){super(e),this.feature=t,this.features=a}},zv=class extends pa{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_=No,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&&(Ar(this.format_,"`format` must be set when `url` is set"),this.loader_=Ov(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:o2;let t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Wd:null,this.loadedExtentsRtree_=new Wd,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 Rd(l)),l!==void 0&&this.addFeaturesInternal(l),a!==void 0&&this.bindFeaturesCollection_(a)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let t=Ut(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 ws(hn.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof Eo||(this.featureChangeKeys_[e]=[Ui(t,Ir.CHANGE,this.handleFeatureChange_,this),Ui(t,km.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 Eo){let o=this.idIndex_[l];o instanceof Eo?Array.isArray(o)?o.push(t):this.idIndex_[l]=[o,t]:a=!1}else a=!1}return a&&(Ar(!(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=Ut(g);this.addToIndex_(b,g)&&a.push(g)}for(let o=0,m=a.length;o<m;o++){let g=a[o],b=Ut(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(hn.ADDFEATURE))for(let o=0,m=a.length;o<m;o++)this.dispatchEvent(new ws(hn.ADDFEATURE,a[o]))}bindFeaturesCollection_(e){let t=!1;this.addEventListener(hn.ADDFEATURE,function(a){t||(t=!0,e.push(a.feature),t=!1)}),this.addEventListener(hn.REMOVEFEATURE,function(a){t||(t=!0,e.remove(a.feature),t=!1)}),e.addEventListener($o.ADD,a=>{t||(t=!0,this.addFeature(a.element),t=!1)}),e.addEventListener($o.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(cn);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 ws(hn.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 Eo||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 Eo||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(),lo(this.nullGeometryFeatures_)||ji(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=QA(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||Lm,this.featuresRtree_.forEachInExtent(b,function(A){if(t(A)){let S=A.getGeometry(),M=g;if(g=S instanceof Eo?0:S.closestPointXY(a,l,m,g),g<M){o=A;let k=Math.sqrt(g);b[0]=a-k,b[1]=l-k,b[2]=a+k,b[3]=l+k}}}),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=Ut(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 ws(hn.CHANGEFEATURE,t))}hasFeature(e){let t=e.getId();return t!==void 0?t in this.idIndex_:Ut(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&lo(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 Qs(S.extent,b)})||(++this.loadingExtentsCount_,this.dispatchEvent(new ws(hn.FEATURESLOADSTART)),this.loader_.call(this,b,t,a,S=>{--this.loadingExtentsCount_,this.dispatchEvent(new ws(hn.FEATURESLOADEND,void 0,S))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new ws(hn.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(jm(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=Ut(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(cn),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(hn.REMOVEFEATURE)&&this.dispatchEvent(new ws(hn.REMOVEFEATURE,e)),e}removeFromIdIndex_(e){let t=!1;for(let a in this.idIndex_){let l=this.idIndex_[a];if(e instanceof Eo&&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){Ar(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(Ov(e,this.format_))}},Ql=zv;var uo={SINGLECLICK:"singleclick",CLICK:Ir.CLICK,DBLCLICK:Ir.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var Bv={ACTIVE:"active"};var Nv=class extends Si{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(Bv.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(Bv.ACTIVE,e)}setMap(e){this.map_=e}};var s2=Nv;var jv=class extends s2{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==uo.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==uo.POINTERUP){let a=this.handleUpEvent(e);this.handlingDownUpSequence=a&&this.targetPointers.length>0}}else if(e.type==uo.POINTERDOWN){let a=this.handleDownEvent(e);this.handlingDownUpSequence=a,t=this.stopDown(a)}else e.type==uo.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 a2=jv;var l2=function(s){let e=s.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var c2=Lm,u2=function(s){return s.type==uo.CLICK};var h2=function(s){return s.type==uo.SINGLECLICK};var p2=function(s){let e=s.originalEvent;return Ar(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var Uv=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=Ao,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let a=t.dataProjection?Zr(t.dataProjection):this.readProjection(e);t.extent&&a&&a.getUnits()==="tile-pixels"&&(a=Zr(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 Pt()}readFeature(e,t){return Pt()}readFeatures(e,t){return Pt()}readGeometry(e,t){return Pt()}readProjection(e){return Pt()}writeFeature(e,t){return Pt()}writeFeatures(e,t){return Pt()}writeGeometry(e,t){return Pt()}},d2=Uv;function vg(s,e,t){let a=t?Zr(t.featureProjection):null,l=t?Zr(t.dataProjection):null,o=s;if(a&&l&&!_E(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(Vl(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 kB={Point:Ei,LineString:Go,Polygon:Iu,MultiPoint:wd,MultiLineString:i0,MultiPolygon:u0};function FB(s,e,t){return Array.isArray(e[0])?(Qm(s,0,e,t)||(s=s.slice(),Ed(s,0,e,t)),s):(Ad(s,0,e,t)||(s=s.slice(),Eu(s,0,e,t)),s)}function Gv(s,e){let t=s.geometry;if(!t)return[];if(Array.isArray(t))return t.map(o=>Gv({...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 vg(new Eo(a,a==="Polygon"?FB(t.flatCoordinates,t.ends,l):t.flatCoordinates,t.ends?.flat(),l,s.properties||{},s.id).enableSimplifyTransformed(),!1,e)}function bg(s,e){if(!s)return null;if(Array.isArray(s)){let a=s.map(l=>bg(l,e));return new Hx(a)}let t=kB[s.type];return vg(new t(s.flatCoordinates,s.layout,s.ends),!1,e)}var Vv=class extends d2{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(wg(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(wg(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return Pt()}readFeaturesFromObject(e,t){return Pt()}readGeometry(e,t){return this.readGeometryFromObject(wg(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return Pt()}readProjection(e){return this.readProjectionFromObject(wg(e))}readProjectionFromObject(e){return Pt()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return Pt()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return Pt()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return Pt()}};function wg(s){if(typeof s=="string"){let e=JSON.parse(s);return e||null}return s!==null?s:null}var f2=Vv;var qv=class extends f2{constructor(e){e=e||{},super(),this.dataProjection=Zr(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=Zr(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=Wv(a.geometry,t);if(this.featureClass===Eo)return Gv({geometry:l,id:a.id,properties:a.properties},t);let o=new Ao;return this.geometryName_?o.setGeometryName(this.geometryName_):this.extractGeometryName_&&a.geometry_name&&o.setGeometryName(a.geometry_name),o.setGeometry(bg(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 LB(e,t)}readProjectionFromObject(e){let t=e.crs,a;if(t)if(t.type=="name")a=Zr(t.properties.name);else if(t.type==="EPSG")a=Zr("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=$v(m,t),delete o[e.getGeometryName()]),lo(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 $v(e,this.adaptOptions(t))}};function Wv(s,e){if(!s)return null;let t;switch(s.type){case"Point":{t=OB(s);break}case"LineString":{t=zB(s);break}case"Polygon":{t=UB(s);break}case"MultiPoint":{t=NB(s);break}case"MultiLineString":{t=BB(s);break}case"MultiPolygon":{t=jB(s);break}case"GeometryCollection":{t=DB(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return t}function LB(s,e){let t=Wv(s,e);return bg(t,e)}function DB(s,e){return s.geometries.map(function(a){return Wv(a,e)})}function OB(s){let e=s.coordinates;return{type:"Point",flatCoordinates:e,layout:ja(e.length)}}function zB(s){let e=s.coordinates,t=e.flat();return{type:"LineString",flatCoordinates:t,ends:[t.length],layout:ja(e[0]?.length||2)}}function BB(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:ja(t)}}function NB(s){let e=s.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:ja(e[0]?.length||2)}}function jB(s){let e=s.coordinates,t=[],a=e[0]?.[0]?.[0].length||2,l=Zm(t,0,e,a);return{type:"MultiPolygon",flatCoordinates:t,ends:l,layout:ja(a)}}function UB(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:ja(a)}}function $v(s,e){s=vg(s,!0,e);let t=s.getType(),a;switch(t){case"Point":{a=ZB(s,e);break}case"LineString":{a=VB(s,e);break}case"Polygon":{a=XB(s,e);break}case"MultiPoint":{a=$B(s,e);break}case"MultiLineString":{a=qB(s,e);break}case"MultiPolygon":{a=WB(s,e);break}case"GeometryCollection":{a=GB(s,e);break}case"Circle":{a={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+t)}return a}function GB(s,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(a){return $v(a,e)})}}function VB(s,e){return{type:"LineString",coordinates:s.getCoordinates()}}function qB(s,e){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function $B(s,e){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function WB(s,e){let t;return e&&(t=e.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(t)}}function ZB(s,e){return{type:"Point",coordinates:s.getCoordinates()}}function XB(s,e){let t;return e&&(t=e.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(t)}}var Ii=qv;var m2=0,Xd=1,g2=[0,0,0,0],Bu=[],Zv={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},Hd=class extends zr{constructor(e,t,a){super(e),this.features=t,this.mapBrowserEvent=a}},Xv=class extends a2{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:p2,this.defaultDeleteCondition_=function(a){return l2(a)&&h2(a)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:c2,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Wd,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Jl({source:new Ql({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:KB(),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 Rd(this.source_.getFeatures()),this.source_.addEventListener(hn.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(hn.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($o.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener($o.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(Ir.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Rd;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 Hd(Zv.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(Ir.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(ps(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(ps(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(ps(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 k=A.slice(S,S+2),j={feature:e,geometry:t,depth:[g,l],index:S,segment:k};this.rBush_.insert(ps(k),j)}}}}writeCircleGeometry_(e,t){let a=t.getCenter(),l={feature:e,geometry:t,index:m2,segment:[a,a]},o={feature:e,geometry:t,index:Xd,segment:[a,a]},m=[l,o];l.featureSegments=m,o.featureSegments=m,this.rBush_.insert(Ba(a),l);let g=t,b=co();if(b&&this.getMap()){let A=this.getMap().getView().getProjection();g=g.clone().transform(b,A),g=l0(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 Ao(new Ei(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==uo.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=uo.SINGLECLICK||!this.ignoreNextSingleClick_?t=this.removePoint():t=!0),e.type==uo.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,k,j=b.segment,Z=g[1];for(;t.length<S.getStride();)t.push(j[Z][t.length]);switch(S.getType()){case"Point":k=t,j[0]=t,j[1]=t;break;case"MultiPoint":k=S.getCoordinates(),k[b.index]=t,j[0]=t,j[1]=t;break;case"LineString":k=S.getCoordinates(),k[b.index+Z]=t,j[Z]=t;break;case"MultiLineString":k=S.getCoordinates(),k[M[0]][b.index+Z]=t,j[Z]=t;break;case"Polygon":k=S.getCoordinates(),k[M[0]][b.index+Z]=t,j[Z]=t;break;case"MultiPolygon":k=S.getCoordinates(),k[M[1]][M[0]][b.index+Z]=t,j[Z]=t;break;case"Circle":if(j[0]=t,j[1]=t,b.index===m2)this.changingFeature_=!0,S.setCenter(t),this.changingFeature_=!1;else{this.changingFeature_=!0;let te=e.map.getView().getProjection(),q=Ux(ti(S.getCenter(),te),ti(t,te)),H=co();if(H){let ae=S.clone().transform(H,te);ae.setRadius(q),q=ae.transform(te,H).getRadius()}S.setRadius(q),this.changingFeature_=!1}break;default:}k&&this.setGeometryCoordinates_(S,k)}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=ps([m]),b=this.rBush_.getInExtent(g),A={};b.sort(HB);for(let S=0,M=b.length;S<M;++S){let k=b[S],j=k.segment,Z=Ut(k.geometry),te=k.depth;if(te&&(Z+="-"+te.join("-")),A[Z]||(A[Z]=new Array(2)),k.geometry.getType()==="Circle"&&k.index===Xd){let q=_2(t,k,l);An(q,m)&&!A[Z][0]&&(this.dragSegments_.push([k,0]),A[Z][0]=k);continue}if(An(j[0],m)&&!A[Z][0]){this.dragSegments_.push([k,0]),A[Z][0]=k;continue}if(An(j[1],m)&&!A[Z][1]){if(A[Z][0]&&A[Z][0].index===0){let q=k.geometry.getCoordinates();switch(k.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":q=q[te[1]];case"Polygon":if(k.index!==q[te[0]].length-2)continue;break;default:}}this.dragSegments_.push([k,1]),A[Z][1]=k;continue}Ut(j)in this.vertexSegments_&&!A[Z][0]&&!A[Z][1]&&this.insertVertexCondition_(e)&&o.push(k)}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=co();if(A){let S=e.map.getView().getProjection();b=b.clone().transform(A,S),b=l0(b).transform(S,A)}this.rBush_.update(b.getExtent(),g)}else this.rBush_.update(ps(a.segment),a)}return this.featuresBeingModified_&&(this.dispatchEvent(new Hd(Zv.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 y2(l,A,o)-y2(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,k)=>{k&&k.getType()==="Point"&&(k=new Ei(ql(k.getCoordinates(),o)));let j=k||S.getGeometry();if(S instanceof Ao&&this.features_.getArray().includes(S)){b=j;let Z=S.getGeometry().getFlatCoordinates().slice(0,2);g=[{feature:S,geometry:b,segment:[Z,Z]}]}return!0},{layerFilter:A})}if(!g){let A=fs(Ba(l,g2),o),S=t.getView().getResolution()*this.pixelTolerance_,M=ds(Ln(A,S,g2),o);g=this.rBush_.getInExtent(M)}if(g&&g.length>0){let A=g.sort(m)[0],S=A.segment,M=_2(l,A,o),k=t.getPixelFromCoordinate(M),j=Ux(e,k);if(b||j<=this.pixelTolerance_){let Z={};if(Z[Ut(S)]=!0,this.snapToPointer_||(this.delta_[0]=M[0]-l[0],this.delta_[1]=M[1]-l[1]),A.geometry.getType()==="Circle"&&A.index===Xd)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(M,[A.feature],[A.geometry]);else{let te=t.getPixelFromCoordinate(S[0]),q=t.getPixelFromCoordinate(S[1]),H=Su(k,te),ae=Su(k,q);j=Math.sqrt(Math.min(H,ae)),this.snappedToVertex_=j<=this.pixelTolerance_,this.snappedToVertex_&&(M=H>ae?S[1]:S[0]),this.createOrUpdateVertexFeature_(M,[A.feature],[A.geometry]);let pe={};pe[Ut(A.geometry)]=!0;for(let ve=1,de=g.length;ve<de;++ve){let _e=g[ve].segment;if(An(S[0],_e[0])&&An(S[1],_e[1])||An(S[0],_e[1])&&An(S[1],_e[0])){let Pe=Ut(g[ve].geometry);Pe in pe||(pe[Pe]=!0,Z[Ut(_e)]=!0)}else break}}this.vertexSegments_=Z;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(ps(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(ps(M.segment),M),this.dragSegments_.push([M,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=uo.POINTERDRAG){let e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_);let t=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Hd(Zv.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,k,j,Z;for(b=e.length-1;b>=0;--b)m=e[b],j=m[0],Z=Ut(j.feature),j.depth&&(Z+="-"+j.depth.join("-")),Z in t||(t[Z]={}),m[1]===0?(t[Z].right=j,t[Z].index=j.index):m[1]==1&&(t[Z].left=j,t[Z].index=j.index+1);for(Z in t){switch(k=t[Z].right,S=t[Z].left,A=t[Z].index,M=A-1,S!==void 0?j=S:j=k,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 te=[];if(S!==void 0&&(this.rBush_.remove(S),te.push(S.segment[0])),k!==void 0&&(this.rBush_.remove(k),te.push(k.segment[1])),S!==void 0&&k!==void 0){let q={depth:j.depth,feature:j.feature,geometry:j.geometry,index:M,segment:te};this.rBush_.insert(ps(q.segment),q)}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 HB(s,e){return s.index-e.index}function y2(s,e,t){let a=e.geometry;if(a.getType()==="Circle"){let o=a;if(e.index===Xd){let m=co();m&&(o=o.clone().transform(m,t));let g=Su(o.getCenter(),ti(s,t)),b=Math.sqrt(g)-o.getRadius();return b*b}}let l=ti(s,t);return Bu[0]=ti(e.segment[0],t),Bu[1]=ti(e.segment[1],t),pE(l,Bu)}function _2(s,e,t){let a=e.geometry;if(a.getType()==="Circle"&&e.index===Xd){let o=a,m=co();return m&&(o=o.clone().transform(m,t)),ql(o.getClosestPoint(ti(s,t)),t)}let l=ti(s,t);return Bu[0]=ti(e.segment[0],t),Bu[1]=ti(e.segment[1],t),ql(jx(l,Bu),t)}function KB(){let s=vI();return function(e,t){return s.Point}}var Hv=Xv;var YB=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,x2=/^([\d.]+),([\d.]+)$/,v2=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,Sg="stop-fetch",b2=s=>{let e=[];return s.forEach(t=>{let a=t.getGeometry()?.getCoordinates();a?.length&&e.push(...a)}),e},Kv=class s extends Mu{constructor(t={}){super(t);this.abortControllers={};this.cacheStationData={};this.format=new Ii({featureProjection:"EPSG:3857"});this.graphs=[];this.initialRouteDrag={};this.segments=[];this.snapToClosestStation=!1;this.useRawViaPoints=!1;this.viaPoints=[];this.element||this.createDefaultElement(),this.loading=!1,this.active=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 od({...t}),this.routingLayer=t.routingLayer||new Jl({source:new Ql,style:t.style}),this.onRouteError=t.onRouteError||(a=>{this.dispatchEvent(new zr("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()})}static getGraphsResolutions(t,a){let l=a.getView();return t.map(([,o,m])=>[l.getResolutionForZoom(o),l.getResolutionForZoom(m||o+1)])}abortRequests(){this.graphs.forEach(t=>{let a=t[0];this.abortControllers[a]&&this.abortControllers[a].abort(),this.abortControllers[a]=new AbortController}),this.abortControllers[Sg]?.abort(),this.abortControllers[Sg]=new AbortController,this.loading=!1}activate(){let t=this.getMap();t&&(this.format=new Ii({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())}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}addViaPoint(t,a=-1,l=0){this.viaPoints.splice(a===-1?this.viaPoints.length:a,l,t),this.drawRoute(),this.dispatchEvent(new zr("change:route"))}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new Hv({deleteCondition:t=>{let l=(t.target?.getFeaturesAtPixel(t.pixel,{hitTolerance:5})).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("index"));return u2(t)&&l?(this.removeViaPoint(l.get("index")),!0):!1},pixelTolerance:6,source:this.routingLayer?.getSource()||void 0}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}deactivate(){let t=this.getMap();t&&(this.modifyInteraction&&t.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(!0),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[Sg]);let t=this.viaPoints.map(a=>{if(Array.isArray(a)){let l=this.getMap()?.getView().getProjection(),[o,m]=Gl(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[Sg])),Promise.all(this.graphs.map(([a],l)=>{let{signal:o}=this.abortControllers[a];return this.api?this.api.route({"coord-punish":1e3,"coord-radius":100,elevation:!1,graph:a,mot:this.mot,"resolve-hops":!1,via:`${t.join("|")}`,...this.routingApiParams||{}},{signal:o}).then(m=>{if(this.segments=this.format.readFeatures(m),this.mot==="foot"){let A=this.segments.reduce((S,M)=>{let k=M.get("trg");return S.find(j=>j[0]===k[0]&&j[1]===k[1])?S:[...S,k]},[]);this.segments=A.map(S=>{let M=this.segments.filter(j=>{let Z=j.get("trg");return Z[0]===S[0]&&Z[1]===S[1]}),k=b2(M);return new Ao({geometry:new Go(k)})})}let g=b2(this.segments),b=new Ao({geometry:new Go(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 zr("error")),this.onRouteError(m,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(t,a,l){let o=new Ao;if(o.set("viaPointIdx",a),Array.isArray(t))return o.setGeometry(new Ei(t)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o);if(!this.useRawViaPoints||v2.test(t)){let S,M;return this.useRawViaPoints?[,S,,M]=v2.exec(t)||[]:[S,M]=t.split("$"),fetch(`${this.stopsApiUrl}lookup/${S}?key=${this.stopsApiKey}`,{signal:l.signal}).then(k=>k.json()).then(k=>{let{coordinates:j}=k.features[0].geometry;return this.cacheStationData[t]=Ai(j),o.set("viaPointTrack",M),o.setGeometry(new Ei(Ai(j))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(k=>{/AbortError/.test(k.message)||(this.dispatchEvent(new zr("error")),this.onRouteError(k,this),this.loading=!1)})}if(this.useRawViaPoints&&x2.test(t)){let[S,M]=x2.exec(t)||[];if(M&&S){let k=parseFloat(M),j=parseFloat(S),Z=Ai([k,j],this.getMap()?.getView().getProjection());return o.setGeometry(new Ei(Z)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}}let[,m,,g,b,,A]=YB.exec(t)||[];if(b&&g){let S=Ai([parseFloat(b),parseFloat(g)],this.getMap()?.getView().getProjection());return o.set("viaPointTrack",A),o.setGeometry(new Ei(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]=Ai(M),o.set("viaPointTrack",A),o.setGeometry(new Ei(Ai(M))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(S=>(this.dispatchEvent(new zr("error")),this.onRouteError(S,this),this.loading=!1,null)):Promise.resolve(null)}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}onMapClick(t){let l=t.target.getFeaturesAtPixel(t.pixel,{hitTolerance:5,layerFilter:o=>o===this.routingLayer}).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("viaPointIdx")!==void 0);if(l){this.removeViaPoint(l.get("viaPointIdx"));return}this.addViaPoint(t.coordinate)}onModifyEnd(t){let a=t.mapBrowserEvent.coordinate,{oldRoute:l,segmentIndex:o,viaPoint:m}=this.initialRouteDrag||{};return m?this.addViaPoint(a,m.get("viaPointIdx"),1):l?o===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(a,(o||0)+1):this.addViaPoint(a,0,1)}onModifyStart(t){let a=-1,l=t.features.getArray().find(m=>m.getGeometry()?.getType()==="LineString");if(l?.getGeometry()&&t.mapBrowserEvent.coordinate){let m=Ln(new Ei(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={oldRoute:l&&l.clone(),segmentIndex:a,viaPoint:o}}removeListeners(){this.onMapClickKey&&jl(this.onMapClickKey)}removeViaPoint(t=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[t]&&this.viaPoints.splice(t,1),this.drawRoute(),this.dispatchEvent(new zr("change:route"))}render(){}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new zr("change:route"))}setMap(t){super.setMap(t),t&&this.active?this.activate():t||(this.active=!1)}setViaPoints(t){this.viaPoints=[...t],this.drawRoute(),this.dispatchEvent(new zr("change:route"))}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)}},w2=Kv;var Yv=class{constructor(e){let{apiKey:t,apiParams:a,placeholder:l,url:o}=e||{};this.apiParams={limit:20,...a||{}},this.placeholder=l||"Search for a stop...";let m={apiKey:t};o&&(m.url=o),this.api=new sd(m),this.abortController=new AbortController,this.createElement(e),this.options=e}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=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",cursor:"pointer",overflowY:"auto"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{cursor:"pointer",display:"none",fontSize:"200%",padding:"0 10px",position:"absolute",right:"0"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}render(e){let 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)}))}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()})}},S2=Yv;var JB=()=>{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},A2=JB;var Jv=class extends Mu{constructor(e){let t=A2();t.className=e?.className||"mbt-stop-finder";let a={element:t,...e||{}};super(a),this.controller=new S2({onSuggestionClick:this.onSuggestionClick.bind(this),...a})}onSuggestionClick(e){let t=Ai(e.geometry.coordinates);this.getMap()?.getView().setCenter(t)}search(e,t){return this.controller.search(e,t)}},E2=Jv;var P2=ao(tb(),1);var QB="vectorTileFeature",rb={"EPSG:3857":new Ii({featureProjection:"EPSG:3857"})},Nu=class extends Du{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:Gl(m.center),zoom:m.zoom-1,bearing:aE(-m.rotation)});let g=t.getOpacity().toString();return o&&g!==o.style.opacity&&(o.style.opacity=g),o.isConnected?e3(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 Vi&&l(m,this.layer_,g)}),o?.[0]}getMapLibrePixels(e,t){if(!e)return;let a=this.getLayer().mapLibreMap?.project(Gl(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";rb[l]||(rb[l]=new Ii({featureProjection:l}));let o=rb[l].readFeature(e);return o&&o.set(QB,e,!0),o}};function e3(s,e){return s.width===Math.floor(e.size[0]*e.pixelRatio)&&s.height===Math.floor(e.size[1]*e.pixelRatio)}var t3=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(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),r3(a)},r3=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))},ib=t3;var ju=class extends qo{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(e){super({source:new pa({attributions:()=>ib(this.mapLibreMap)}),...e})}disposeInternal(){jl(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 P2.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 zr("load"))})}createRenderer(){return new Nu(this)}};var lb=ao(ec());var R2=ao(ec());var Pi=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Pi=(0,R2.default)(s=>{console.warn(s)},1e3));function v3(s){return class extends s{constructor(...a){let l=a[0];super(l);this.olEventsKeys=[];this.options={};l.properties&&(Pi("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||[])}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 Pi("Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead."),Nl(this)}onChildrenChange(a){(a||[]).forEach(l=>{l.set("parent",void 0)}),(this.get("children")||[]).forEach(l=>{l.set("parent",this)})}setMapInternal(a){a?(super.setMapInternal(a),this.attachToMap(a)):(this.detachFromMap(),super.setMapInternal(a))}get children(){return Pi("Layer.children is deprecated. Use the Layer.get('children') method instead."),this.get("children")||[]}set children(a){Pi("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),this.set("children",a||[])}get copyrights(){return Pi("Layer.copyrights is deprecated. Get the attributions from the source object"),this.get("copyrights")}set copyrights(a){Pi("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 Pi("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),this.get("disabled")}set disabled(a){Pi("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),this.set("disabled",a)}get group(){return Pi("Layer.group is deprecated. Use the Layer.get('group') method instead."),this.get("group")}get hitTolerance(){return Pi("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")||Ut(this)}get map(){return this.getMapInternal()}get name(){return Pi("Layer.name is deprecated. Use the Layer.get('name') method instead."),this.get("name")}get olLayer(){return Pi("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){Pi("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.")}get parent(){return Pi("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),this.get("parent")}set parent(a){Pi("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),this.set("parent",a)}get visible(){return Pi("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),this.getVisible()}set visible(a){Pi("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),this.setVisible(a)}}}var k2=v3;function b3(s){return class extends k2(s){}}var Ss=b3;var F2=(s,e,t,a)=>Ol(`${s}/styles/${e}/style.json`,{[a]:t}).toString(),sb=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(sb=(0,lb.default)(s=>{console.warn(s)},1e3));var ab=class s extends Ss(ju){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&&typeof t.style=="string"&&(t.mapLibreOptions.style=F2(t.url,t.style,t.apiKey,t.apiKeyName)),super(t)}attachToMap(e){super.attachToMap(e);let t=(0,lb.default)(this.updateMaplibreMap.bind(this),150);t(),this.olEventsKeys.push(this.on("propertychange",a=>{/(url|style|apiKey|apiKeyName)/.test(a.key)&&t()}))}clone(e){return new s({...this.options||{},...e||{}})}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:F2(this.url,this.style,this.apiKey,this.apiKeyName)}updateMaplibreMap(){try{this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}catch(e){console.error("Error while updating MaplibreMap",e)}}set apiKey(e){this.set("apiKey",e)}get apiKey(){return this.get("apiKey")}set apiKeyName(e){this.set("apiKeyName",e)}get apiKeyName(){return this.get("apiKeyName")}get maplibreMap(){return sb("MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap."),this.mapLibreMap}get mbMap(){return sb("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get style(){return this.get("style")}set style(e){this.set("style",e)}get url(){return this.get("url")}set url(e){this.set("url",e)}},L2=ab;var D2=ao(ec());var cb={"EPSG:3857":new Ii({featureProjection:"EPSG:3857"})},Kd=class extends Du{forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{l(m,this.layer_,m.getGeometry())}),o?.[0]}getFeatures(e){let t=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(t))}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(cb[m]||(cb[m]=new Ii({featureProjection:m})),o?.isStyleLoaded()){let b=e&&o.project(Gl(e));if(b?.x&&b?.y){let A=[b.x,b.y];if(t){let[M,k]=A;A=[[M-t,k-t],[M+t,k+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 k=cb[m].readFeature(M);return k&&k.set(Tu,M),k})}}return g}prepareFrame(){return!0}renderFrame(){return null}};var Io=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Io=(0,D2.default)((...s)=>{console.warn(...s)},1e3));var ub=class s extends Ss(qo){constructor(t={mapLibreOptions:{style:{layers:[],sources:{},version:8}}}){t.mapboxLayer&&(Io("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),t.maplibreLayer=t.mapboxLayer,delete t.mapboxLayer);super({source:new pa({}),...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))}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())}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)})}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))}}}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))}))}clone(t){return new s({...this.options,...t})}createRenderer(){return new Kd(this)}detachFromMap(){this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources()),super.detachFromMap()}getFeatureInfoAtCoordinate(t){if(Io("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({coordinate:t,features:[],layer:this})}highlight(t=[]){Io("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)}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()}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)})}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)})}select(t=[]){Io("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=t,this.setHoverState(this.selectedFeatures||[],!0)}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(Tu)||{};if(!m&&!g||!o.getId()){o.getId()||Io("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",o.getProperties());return}l.setFeatureState({id:o.getId(),source:m,sourceLayer:g},a)})}setHoverState(t,a){Io(`Deprecated. Use layer.setFeatureState(features, {hover: ${a}}) instead.`),this.setFeatureState(t,{hover:a})}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 Io("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 Io("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(t){Io("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[t]}get styleLayers(){return Io("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(t){Io("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=t}},O2=ub;var fb=ao(ec());var pb=ao(ec()),db=ao(U2());function N3(s){return class extends s{constructor(t){super({hitTolerance:10,...t}),this.defineProperties(t),this.debug=t.debug||!1,this.mode=t.mode||Jr.TOPOGRAPHIC,this.api=t.api||new nd(t),this.tenant=t.tenant||"",this.minZoomInterpolation=t.minZoomInterpolation||8,this.format=new Ii,this.onStart=t.onStart,this.onStop=t.onStop,this.motsByZoom=t.motsByZoom||[Vo,Vo,Vo,Vo,Vo,Vo,Vo,Vo,Vo,tg,tg],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,db.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,pb.default)(this.renderTrajectoriesInternal,50,{leading:!0,maxWait:5e3,trailing:!0}),this.renderTrajectoriesInternal=this.renderTrajectoriesInternal.bind(this),this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}addTrajectory(t){this.trajectories||(this.trajectories={});let a=t.properties.train_id;a!==void 0&&(this.trajectories[a]=t),this.renderTrajectories()}attachToMap(t){super.attachToMap(t),document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}defineProperties(t){(super.defineProperties||(()=>{}))(t);let{bboxParameters:a,canvas:l,filter:o,hoverVehicleId:m,live:g,mode:b,pixelRatio:A,selectedVehicleId:S,sort:M,speed:k,style:j,styleOptions:Z,time:te}=t,q=l,H=k||1,ae=te||new Date,pe=b||Jr.TOPOGRAPHIC,ve=j||zl;Object.defineProperties(this,{bboxParameters:{value:a,writable:!0},canvas:{get:()=>(q||(q=document.createElement("canvas")),q),set:de=>{q=de}},filter:{value:o,writable:!0},hoverVehicleId:{value:m,writable:!0},isTrackerLayer:{value:!0},live:{value:g===!1?g:!0,writable:!0},mode:{get:()=>pe,set:de=>{de!==pe&&(pe=de,this.api?.wsApi?.open&&(this.stop(),this.start()))}},pixelRatio:{value:A||(typeof window<"u"?window.devicePixelRatio:1),writable:!0},selectedVehicleId:{value:S,writable:!0},sort:{value:M,writable:!0},speed:{get:()=>H,set:de=>{H=de,this.start()}},style:{get:()=>ve,set:de=>{ve=de,this.renderTrajectories()}},styleOptions:{value:{...Pu,...Z||{}}},time:{get:()=>ae,set:de=>{ae=de?.getTime?de:new Date(de),this.renderTrajectories()}},trajectories:{value:{},writable:!0},useDebounce:{value:t.useDebounce||!1,writable:!0},useRequestAnimationFrame:{value:t.useRequestAnimationFrame||!1,writable:!0},useThrottle:{value:t.useThrottle!==!1,writable:!0}})}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),jl(this.visibilityRef),this.canvas){let t=this.canvas.getContext("2d");t&&t.clearRect(0,0,this.canvas.width,this.canvas.height),super.detachFromMap()}}getFeatureInfoAtCoordinate(t,a){let{nb:l,resolution:o}=a,m=Ln([...t,...t],this.hitTolerance*o),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&&Js(m,S)&&b.push(g[A]),b.length===l)break}return Promise.resolve({coordinate:t,features:b.map(A=>this.format.readFeature(A)),layer:this})}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,db.default)(this.renderTrajectoriesInternal,m,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,pb.default)(this.renderTrajectoriesInternal,m,{leading:!0,maxWait:5e3,trailing:!0})),this.api?.buffer){let[,g]=this.api.buffer;this.api.buffer=[m,g]}return o}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])=>({fullTrajectory:o,stopSequence:l}))}getVehicle(t){return this.trajectories&&Object.values(this.trajectories).filter(t)||[]}highlightVehicle(t){this.hoverVehicleId!==t&&(this.hoverVehicleId=t,this.renderTrajectories(!0))}onDeleteTrajectoryMessage(t){t.content&&this.removeTrajectory(t.content)}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(this.getVisible()===!1)return;this.start()}}onTrajectoryMessage(t){if(!t.content)return;let a=t.content,{geometry:l,properties:{raw_coordinates:o,time_since_update:m,train_id:g}}=a;m<0||this.purgeTrajectory(a)||(this.debug&&this.mode===Jr.TOPOGRAPHIC&&o?a.properties.olGeometry=this.format.readGeometry({coordinates:Ai(o,this.map.getView().getProjection()),type:"Point"}):a.properties.olGeometry=this.format.readGeometry(l),a.properties.timeOffset=Date.now()-t.timestamp,this.addTrajectory(a))}onZoomEnd(){this.startUpdateTime()}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{bounds:o,type:m}=t.properties;return this.isUpdateBboxOnMoveEnd&&!ei(a,o)||this.mots&&!this.mots.includes(m)?(this.removeTrajectory(t),!0):!1}removeTrajectory(t){let a;typeof t!="string"?a=t?.properties?.train_id:a=t,a!==void 0&&this.trajectories&&delete this.trajectories[a]}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))}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=Td(this.canvas,o,this.style,{...t,pixelRatio:this.pixelRatio||1,time:l},{filter:this.filter,hoverVehicleId:this.hoverVehicleId,noInterpolate:(t.zoom||0)<this.minZoomInterpolation?!0:a,selectedVehicleId:this.selectedVehicleId,...this.styleOptions})),!0}selectVehicle(t){this.selectedVehicleId!==t&&(this.selectedVehicleId=t,this.renderTrajectories(!0))}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}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)}}}var Eg=N3;var j3=new Ii,Yd=class extends xg{forEachFeatureAtCoordinate(e,t,a,l){let o=this.getFeaturesAtCoordinate(e,a);return o.forEach(m=>{l(m,this.layer_,m.getGeometry())}),o?.[0]}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))}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 k=A[M];if(k.properties.coordinate&&Js(g,k.properties.coordinate)&&S.push(A[M]),S.length===m)break}return b=S.map(M=>j3.readFeature(M)),b}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){let S=t?.getContext("2d");t?.width&&t?.height&&S?.clearRect(0,0,t.width,t.height)}else{let S=this.getLayer().getMapInternal(),M=S?.getPixelFromCoordinate(g),k=S?.getPixelFromCoordinate(l);M&&k&&(this.container.style.transform=UA(M[0]-k[0],M[1]-k[1],b/o,b/o,m-A,0,0))}}return this.container}};var U3=new $i({zIndex:2,image:new Vn({radius:5,fill:new qi({color:"#000000"})}),stroke:new ai({color:"#000000",width:6})}),G3=(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,[U3,new $i({zIndex:3,image:new Vn({radius:4,fill:new qi({color:a})}),stroke:new ai({color:a,width:4})})]},Ig=G3;var V3=new $i({zIndex:2,image:new Vn({radius:5,fill:new qi({color:"#000000"})}),stroke:new ai({color:"#000000",width:6})}),q3=new $i({zIndex:3,image:new Vn({radius:4,fill:new qi({color:"#a0a0a0"})}),stroke:new ai({color:"#a0a0a0",width:4})}),$3=()=>[V3,q3],G2=$3;var V2=new Vn({radius:6,fill:new qi({color:[255,0,0,1]}),stroke:new ai({color:[0,0,0,1],width:1})}),W3=new $i({stroke:new ai({color:[0,0,0,1],width:5})}),Z3=new $i({image:V2,stroke:new ai({color:[255,0,0,1],width:3})}),X3=new $i({image:V2,stroke:new ai({color:[255,0,0,1],width:3,lineDash:[1,10]})}),H3=(s,e)=>{let t=s.get("minResolution"),a=s.get("maxResolution"),l=e<=t&&e>a;return t&&a&&!l?[]:s.get("mot")!=="foot"?[W3,Z3]:[X3]},q2=H3;var K3=new Ii,mb=class s extends Eg(Ss(qo)){constructor(t){super({source:new pa({}),...t});this.allowRenderWhenAnimating=!1;this.allowRenderWhenAnimating=!!t.allowRenderWhenAnimating,this.vectorLayer=new Jl({source:new Ql({features:[]}),style:(a,l)=>(t.fullTrajectoryStyle||Ig)(a,l,this.styleOptions),updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0}),this.renderState={center:[0,0],rotation:0,zoom:void 0},this.onZoomEndDebounced=(0,fb.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,fb.default)(this.onMoveEnd,100)}attachToMap(t){if(super.attachToMap(t),this.map){this.getVisible()&&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||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.getVisible()?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))}))}}clone(t){return new s({...this.options,...t})}createRenderer(){return new Yd(this)}detachFromMap(){this.map?.removeLayer(this.vectorLayer),super.detachFromMap()}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getView()?.getZoom()||0)}highlight(t){this.highlightVehicle(t?.get("train_id"))}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=K3.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([]))}onMoveEnd(t){!this.isUpdateBboxOnMoveEnd||!this.getVisible()||this.setBbox()}onZoomEnd(){super.onZoomEnd(),!(!this.isUpdateBboxOnMoveEnd||!this.getVisible())&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}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)}renderTrajectories(t){if(!this.map)return;let a=this.map.getView();a?.getCenter()&&super.renderTrajectories({center:a.getCenter(),extent:a.calculateExtent(),pixelRatio:this.pixelRatio,resolution:a.getResolution(),rotation:a.getRotation(),size:this.map.getSize(),zoom:a.getZoom()},t)}renderTrajectoriesInternal(t,a){if(!this.map?.getView())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}select(t){this.selectVehicle(t?.get("train_id")),this.highlightTrajectory(t?.get("train_id"))}setBbox(t,a){let l=t||this.map?.getView()?.calculateExtent();l&&super.setBbox(l,a||this.map?.getView()?.getZoom()||0)}},$2=mb;var W2=ao(ec());var Z2=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Z2=(0,W2.default)(s=>{console.warn(s)},1e3));var gb=class s extends Ss(qo){constructor(e){super(e),Z2("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(e){return new s({...this.options||{},...e||{}})}},Pg=gb;var yb=class s extends Pg{clone(e){return new s({...this.options,...e})}getFeatureInfoAtCoordinate(e){let t=[];if(this.map){let a=this.map.getPixelFromCoordinate(e);t=this.map.getFeaturesAtPixel(a,{hitTolerance:this.hitTolerance||5,layerFilter:l=>l===this.olLayer})||[]}return Promise.resolve({coordinate:e,features:t,layer:this})}},X2=yb;var Y3=new Ii,J3=(s,e,t)=>{let a,{coordinate:l,params:o,projection:m,resolution:g}=e;return s&&g&&m&&(a=s.getFeatureInfoUrl(l,g,m,{info_format:"application/json",query_layers:s.getParams().layers,...o})),fetch(a,{signal:t.signal}).then(b=>b.json()).then(b=>Y3.readFeatures(b)).catch(()=>[])},Jd={},Q3=async(s,e,t=5)=>{Object.values(Jd).forEach(o=>{o?.abort()}),Jd={};let l=Nl(e).map(o=>{let m=o.getMapInternal(),g=m?.getView()?.getProjection()?.getCode(),b={coordinate:s,features:[],layer:o};if(!g)return Promise.resolve(b);if(o.getFeatureInfoAtCoordinate)return o.getFeatureInfoAtCoordinate(s);let A=o?.getSource();if(A?.getFeatureInfoUrl){let k=Ut(o);Jd[k]?.abort(),Jd[k]=new AbortController;let j=m?.getView()?.getResolution();return J3(A,{coordinate:s,params:{info_format:"application/json",query_layers:A.getParams().layers},projection:g,resolution:j},Jd[k]).then(Z=>({coordinate:s,features:Z,layer:o})).catch(()=>({coordinate:s,features:[],layer:o}))}let S=m?.getPixelFromCoordinate(s);if(!S)return Promise.resolve(b);let M=m?.getFeaturesAtPixel(S,{hitTolerance:o.get("hitTolerance")||t||5,layerFilter:k=>k===o});return Promise.resolve({coordinate:s,features:M,layer:o})});return Promise.all(l)},H2=Q3;var Wy={};nx(Wy,{CopyrightControl:()=>K2,Layer:()=>Rg,RealtimeAPI:()=>nd,RealtimeLayer:()=>IL,RealtimeModes:()=>Jr,RoutingAPI:()=>od,StopsAPI:()=>sd,VECTOR_TILE_FEATURE_PROPERTY:()=>Tu,compareDepartures:()=>Cd,createCanvas:()=>zo,createRealtimeFilters:()=>bx,debounceDeparturesMessages:()=>h0,debounceWebsocketMessages:()=>id,getCircleCanvas:()=>yx,getDelayBgCanvas:()=>mx,getDelayTextCanvas:()=>gx,getHoursAndMinutes:()=>BA,getLayersAsFlatArray:()=>Nl,getMapGlCopyrights:()=>ad,getMercatorResolution:()=>EL,getSourceCoordinates:()=>$y,getTextCanvas:()=>_x,getUTCDateString:()=>OA,getUTCTimeString:()=>zA,getUrlWithParams:()=>Ol,getVehiclePosition:()=>Pd,pad:()=>Rm,realtimeConfig:()=>Pu,realtimeDefaultStyle:()=>zl,realtimeDelayStyle:()=>xx,realtimeSimpleStyle:()=>vx,removeDuplicate:()=>Bl,renderTrajectories:()=>Td,sortAndFilterDepartures:()=>Md,sortByDelay:()=>wx});var e5=" | ",_b=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||e5,t=this.options?.customAttribution||ad(this.map),a=(Array.isArray(t)?t:[t]).join(e);this.container.innerHTML!==a&&(this.content=a,this.container.innerHTML=this.content)}}},K2=_b;var Zi=[];for(Cg=0;Cg<256;++Cg)Zi.push((Cg+256).toString(16).slice(1));var Cg;function Y2(s,e=0){return(Zi[s[e+0]]+Zi[s[e+1]]+Zi[s[e+2]]+Zi[s[e+3]]+"-"+Zi[s[e+4]]+Zi[s[e+5]]+"-"+Zi[s[e+6]]+Zi[s[e+7]]+"-"+Zi[s[e+8]]+Zi[s[e+9]]+"-"+Zi[s[e+10]]+Zi[s[e+11]]+Zi[s[e+12]]+Zi[s[e+13]]+Zi[s[e+14]]+Zi[s[e+15]]).toLowerCase()}var Mg,t5=new Uint8Array(16);function xb(){if(!Mg&&(Mg=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Mg))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Mg(t5)}var r5=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),vb={randomUUID:r5};function i5(s,e,t){if(vb.randomUUID&&!e&&!s)return vb.randomUUID();s=s||{};var a=s.random||(s.rng||xb)();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 Y2(a)}var bb=i5;var J2=ao(tb()),wb=class extends J2.Evented{constructor(t={}){super();this.options={};this.type="custom";this.options=t,this.id=t.id||bb(),this.type="custom"}onAdd(t,a){this.map=t}onRemove(t,a){this.map=void 0}render(t){}},Rg=wb;var aL=ao(oL(),1),$G=Object.defineProperty,mr=(s,e)=>$G(s,"name",{value:e,configurable:!0}),WG=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||!bf(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=kw(e),l=kw(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(!bf(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 bf(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,aL.default)(e.properties,t.properties):!0)&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return bf(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)}};mr(WG,"GeojsonEquality");function bf(s,e){return s.coordinates?s.coordinates.length===e.coordinates.length:s.length===e.length}mr(bf,"sameLength");function kw(s){return s.coordinates.map(e=>({type:s.type.replace("Multi",""),coordinates:e}))}mr(kw,"explode");var Xi=63710088e-1,lL={centimeters:Xi*100,centimetres:Xi*100,degrees:360/(2*Math.PI),feet:Xi*3.28084,inches:Xi*39.37,kilometers:Xi/1e3,kilometres:Xi/1e3,meters:Xi,metres:Xi,miles:Xi/1609.344,millimeters:Xi*1e3,millimetres:Xi*1e3,nauticalmiles:Xi/1852,radians:1,yards:Xi*1.0936},sL={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 Jo(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}mr(Jo,"feature");function ZG(s,e,t={}){switch(s){case"Point":return Hi(e).geometry;case"LineString":return Ds(e).geometry;case"Polygon":return Fw(e).geometry;case"MultiPoint":return uL(e).geometry;case"MultiLineString":return cL(e).geometry;case"MultiPolygon":return hL(e).geometry;default:throw new Error(s+" is invalid")}}mr(ZG,"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(!Sc(s[0])||!Sc(s[1]))throw new Error("coordinates must contain numbers");return Jo({type:"Point",coordinates:s},e,t)}mr(Hi,"point");function XG(s,e,t={}){return Uy(s.map(a=>Hi(a,e)),t)}mr(XG,"points");function Fw(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 Jo({type:"Polygon",coordinates:s},e,t)}mr(Fw,"polygon");function HG(s,e,t={}){return Uy(s.map(a=>Fw(a,e)),t)}mr(HG,"polygons");function Ds(s,e,t={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return Jo({type:"LineString",coordinates:s},e,t)}mr(Ds,"lineString");function KG(s,e,t={}){return Uy(s.map(a=>Ds(a,e)),t)}mr(KG,"lineStrings");function Uy(s,e={}){let t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=s,t}mr(Uy,"featureCollection");function cL(s,e,t={}){return Jo({type:"MultiLineString",coordinates:s},e,t)}mr(cL,"multiLineString");function uL(s,e,t={}){return Jo({type:"MultiPoint",coordinates:s},e,t)}mr(uL,"multiPoint");function hL(s,e,t={}){return Jo({type:"MultiPolygon",coordinates:s},e,t)}mr(hL,"multiPolygon");function YG(s,e,t={}){return Jo({type:"GeometryCollection",geometries:s},e,t)}mr(YG,"geometryCollection");function JG(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}mr(JG,"round");function pL(s,e="kilometers"){let t=lL[e];if(!t)throw new Error(e+" units is invalid");return s*t}mr(pL,"radiansToLength");function Lw(s,e="kilometers"){let t=lL[e];if(!t)throw new Error(e+" units is invalid");return s/t}mr(Lw,"lengthToRadians");function QG(s,e){return Gy(Lw(s,e))}mr(QG,"lengthToDegrees");function eV(s){let e=s%360;return e<0&&(e+=360),e}mr(eV,"bearingToAzimuth");function Gy(s){return s%(2*Math.PI)*180/Math.PI}mr(Gy,"radiansToDegrees");function nl(s){return s%360*Math.PI/180}mr(nl,"degreesToRadians");function wf(s,e="kilometers",t="kilometers"){if(!(s>=0))throw new Error("length must be a positive number");return pL(Lw(s,e),t)}mr(wf,"convertLength");function tV(s,e="meters",t="kilometers"){if(!(s>=0))throw new Error("area must be a positive number");let a=sL[e];if(!a)throw new Error("invalid original units");let l=sL[t];if(!l)throw new Error("invalid final units");return s/a*l}mr(tV,"convertArea");function Sc(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}mr(Sc,"isNumber");function jh(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}mr(jh,"isObject");function rV(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(!Sc(e))throw new Error("bbox must only contain numbers")})}mr(rV,"validateBBox");function iV(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")}mr(iV,"validateId");var nV=Object.defineProperty,Ki=(s,e)=>nV(s,"name",{value:e,configurable:!0});function ma(s,e,t){if(s!==null)for(var a,l,o,m,g,b,A,S=0,M=0,k,j=s.type,Z=j==="FeatureCollection",te=j==="Feature",q=Z?s.features.length:1,H=0;H<q;H++){A=Z?s.features[H].geometry:te?s.geometry:s,k=A?A.type==="GeometryCollection":!1,g=k?A.geometries.length:1;for(var ae=0;ae<g;ae++){var pe=0,ve=0;if(m=k?A.geometries[ae]:A,m!==null){b=m.coordinates;var de=m.type;switch(S=t&&(de==="Polygon"||de==="MultiPolygon")?1:0,de){case null:break;case"Point":if(e(b,M,H,pe,ve)===!1)return!1;M++,pe++;break;case"LineString":case"MultiPoint":for(a=0;a<b.length;a++){if(e(b[a],M,H,pe,ve)===!1)return!1;M++,de==="MultiPoint"&&pe++}de==="LineString"&&pe++;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,H,pe,ve)===!1)return!1;M++}de==="MultiLineString"&&pe++,de==="Polygon"&&ve++}de==="Polygon"&&pe++;break;case"MultiPolygon":for(a=0;a<b.length;a++){for(ve=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,H,pe,ve)===!1)return!1;M++}ve++}pe++}break;case"GeometryCollection":for(a=0;a<m.geometries.length;a++)if(ma(m.geometries[a],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}Ki(ma,"coordEach");function oV(s,e,t,a){var l=t;return ma(s,function(o,m,g,b,A){m===0&&t===void 0?l=o:l=e(l,o,m,g,b,A)},a),l}Ki(oV,"coordReduce");function dL(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}}Ki(dL,"propEach");function sV(s,e,t){var a=t;return dL(s,function(l,o){o===0&&t===void 0?a=l:a=e(a,l,o)}),a}Ki(sV,"propReduce");function fL(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++);}Ki(fL,"featureEach");function aV(s,e,t){var a=t;return fL(s,function(l,o){o===0&&t===void 0?a=l:a=e(a,l,o)}),a}Ki(aV,"featureReduce");function lV(s){var e=[];return ma(s,function(t){e.push(t)}),e}Ki(lV,"coordAll");function Dw(s,e){var t,a,l,o,m,g,b,A,S,M,k=0,j=s.type==="FeatureCollection",Z=s.type==="Feature",te=j?s.features.length:1;for(t=0;t<te;t++){for(g=j?s.features[t].geometry:Z?s.geometry:s,A=j?s.features[t].properties:Z?s.properties:{},S=j?s.features[t].bbox:Z?s.bbox:void 0,M=j?s.features[t].id:Z?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,k,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,k,A,S,M)===!1)return!1;break}case"GeometryCollection":{for(a=0;a<o.geometries.length;a++)if(e(o.geometries[a],k,A,S,M)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}k++}}Ki(Dw,"geomEach");function cV(s,e,t){var a=t;return Dw(s,function(l,o,m,g,b){o===0&&t===void 0?a=l:a=e(a,l,o,m,g,b)}),a}Ki(cV,"geomReduce");function Vy(s,e){Dw(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(Jo(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(Jo(M,l),a,A)===!1)return!1}})}Ki(Vy,"flattenEach");function uV(s,e,t){var a=t;return Vy(s,function(l,o,m){o===0&&m===0&&t===void 0?a=l:a=e(a,l,o,m)}),a}Ki(uV,"flattenReduce");function mL(s,e){Vy(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(ma(t,function(M,k,j,Z,te){if(g===void 0||a>b||Z>A||te>S){g=M,b=a,A=Z,S=te,o=0;return}var q=Ds([g,M],t.properties);if(e(q,a,l,te,o)===!1)return!1;o++,g=M})===!1)return!1}}})}Ki(mL,"segmentEach");function hV(s,e,t){var a=t,l=!1;return mL(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}Ki(hV,"segmentReduce");function gL(s,e){if(!s)throw new Error("geojson is required");Vy(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(Ds(m[g],t.properties),a,l,g)===!1)return!1;break}}})}Ki(gL,"lineEach");function pV(s,e,t){var a=t;return gL(s,function(l,o,m,g){o===0&&t===void 0?a=l:a=e(a,l,o,m,g)}),a}Ki(pV,"lineReduce");function dV(s,e){if(e=e||{},!jh(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),Ds([b[o],b[o+1]],m,e);case"Polygon":return l<0&&(l=b.length+l),o<0&&(o=b[l].length+o-1),Ds([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),Ds([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),Ds([b[a][l][o],b[a][l][o+1]],m,e)}throw new Error("geojson is invalid")}Ki(dV,"findSegment");function fV(s,e){if(e=e||{},!jh(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")}Ki(fV,"findPoint");var mV=Object.defineProperty,gV=(s,e)=>mV(s,"name",{value:e,configurable:!0});function Ow(s,e={}){let t=0,a=0,l=0;return ma(s,function(o){t+=o[0],a+=o[1],l++},!0),Hi([t/l,a/l],e.properties)}gV(Ow,"centroid");var yV=Object.defineProperty,ol=(s,e)=>yV(s,"name",{value:e,configurable:!0});function Qo(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(Qo,"getCoord");function zw(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(zw,"getCoords");function yL(s){if(s.length>1&&Sc(s[0])&&Sc(s[1]))return!0;if(Array.isArray(s[0])&&s[0].length)return yL(s[0]);throw new Error("coordinates must only contain numbers")}ol(yL,"containsNumber");function _V(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(_V,"geojsonType");function xV(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(xV,"featureOf");function vV(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(vV,"collectionOf");function bV(s){return s.type==="Feature"?s.geometry:s}ol(bV,"getGeom");function wV(s,e){return s.type==="FeatureCollection"?"FeatureCollection":s.type==="GeometryCollection"?"GeometryCollection":s.type==="Feature"&&s.geometry!==null?s.geometry.type:s.type}ol(wV,"getType");var SV=Object.defineProperty,_L=(s,e)=>SV(s,"name",{value:e,configurable:!0});function Nw(s,e,t={}){let a;return t.final?a=Bw(Qo(e),Qo(s)):a=Bw(Qo(s),Qo(e)),a>180?-(360-a):a}_L(Nw,"rhumbBearing");function Bw(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(Gy(m)+360)%360}_L(Bw,"calculateRhumbBearing");var AV=Object.defineProperty,xL=(s,e)=>AV(s,"name",{value:e,configurable:!0});function jw(s,e,t={}){let a=Qo(s),l=Qo(e);l[0]+=l[0]-a[0]>180?-360:a[0]-l[0]>180?360:0;let o=vL(a,l);return wf(o,"meters",t.units)}xL(jw,"rhumbDistance");function vL(s,e,t){t=t===void 0?Xi: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}xL(vL,"calculateRhumbDistance");var EV=Object.defineProperty,bL=(s,e)=>EV(s,"name",{value:e,configurable:!0});function Uw(s,e,t,a={}){let l=e<0,o=wf(Math.abs(e),a.units,"meters");l&&(o=-Math.abs(o));let m=Qo(s),g=wL(m,o,t);return g[0]+=g[0]-m[0]>180?-360:m[0]-g[0]>180?360:0,Hi(g,a.properties)}bL(Uw,"rhumbDestination");function wL(s,e,t,a){a=a===void 0?Xi: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),k=l*Math.sin(g)/M;return[((o+k)*180/Math.PI+540)%360-180,A*180/Math.PI]}bL(wL,"calculateRhumbDestination");var IV=Object.defineProperty,Uh=(s,e)=>IV(s,"name",{value:e,configurable:!0});function Gw(s){if(!s)throw new Error("geojson is required");switch(s.type){case"Feature":return Vw(s);case"FeatureCollection":return SL(s);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return qy(s);default:throw new Error("unknown GeoJSON type")}}Uh(Gw,"clone");function Vw(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=qw(s.properties),s.geometry==null?e.geometry=null:e.geometry=qy(s.geometry),e}Uh(Vw,"cloneFeature");function qw(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]=qw(a):e[t]=a}),e}Uh(qw,"cloneProperties");function SL(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=>Vw(t)),e}Uh(SL,"cloneFeatureCollection");function qy(s){let e={type:s.type};return s.bbox&&(e.bbox=s.bbox),s.type==="GeometryCollection"?(e.geometries=s.geometries.map(t=>qy(t)),e):(e.coordinates=$w(s.coordinates),e)}Uh(qy,"cloneGeometry");function $w(s){let e=s;return typeof e[0]!="object"?e.slice():e.map(t=>$w(t))}Uh($w,"deepSlice");var PV=Object.defineProperty,TV=(s,e)=>PV(s,"name",{value:e,configurable:!0});function AL(s,e,t){if(t=t||{},!jh(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=Ow(s)),(l===!1||l===void 0)&&(s=Gw(s)),ma(s,function(o){var m=Nw(a,o),g=m+e,b=jw(a,o),A=zw(Uw(a,b,g));o[0]=A[0],o[1]=A[1]})),s}TV(AL,"transformRotate");var Ww=AL;var CV=(s,e=1)=>{let{height:t,width:a}=s.getCanvas(),l=s.unproject({x:0,y:0}),o=s.unproject({x:0,y:t/e}),m=s.unproject({x:a/e,y:t/e}),g=s.unproject({x:a/e,y:0});return[[l.lng,l.lat],[g.lng,g.lat],[m.lng,m.lat],[o.lng,o.lat]]},$y=CV;var MV=s=>{let e=s.getBounds().toArray(),t=Ai(e[0]),a=Ai(e[1]),l=[...t,...a],{width:o,height:m}=s.getCanvas(),g=kr(l)/o,b=si(l)/m;return Math.max(g,b)},EL=MV;var RV=s=>dd(s.toArray().flat(),"EPSG:4326","EPSG:3857"),Zw=RV;var Xw=class extends Eg(Rg){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=Ww(Hi([o.lng,o.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,b=Ww(Hi([m.lng,m.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,A=[...Ai(g),...Ai(b)],S=kr(A)/(t/this.pixelRatio),M=si(A)/(a/this.pixelRatio),k=Math.max(S,M),j={size:[t/this.pixelRatio,a/this.pixelRatio],center:Ai([l.lng,l.lat]),extent:A,resolution:k,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||Zw(this.map.getBounds()),a||Math.floor(this.map.getZoom()-1))}setBbox(e,t){super.setBbox(e||Zw(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=$y(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()}},IL=Xw;var Hw={ol:Tg,maplibre:Wy};typeof window<"u"&&(window.mbt=Hw);var Ooe=Hw;})();
589
589
  /*! Bundled license information:
590
590
 
591
591
  maplibre-gl/dist/maplibre-gl.js: