dumbymap
Version:
Generate interactive maps from Semantic HTML
1 lines • 976 kB
JavaScript
!function(c,g){"object"==typeof exports&&"undefined"!=typeof module?g(exports):"function"==typeof define&&define.amd?define(["exports"],g):g((c="undefined"!=typeof globalThis?globalThis:c||self).openlayers={})}(this,(function(c){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(c){for(var g=1;g<arguments.length;g++){var p=arguments[g];for(var m in p)Object.prototype.hasOwnProperty.call(p,m)&&(c[m]=p[m])}return c},t.apply(this,arguments)}function e(c,g=9){const p=Math.pow(10,g);return Math.round(c*p)/p}const i=(c,g)=>{const{x:p,y:m}=c,{x:f,y:_}=g,y=f-p,x=_-m;return Math.sqrt(x*x+y*y)};class o{constructor({name:c,callback:g,unregister:p,register:m}){this.name=void 0,this.callback=void 0,this.registered=!1,this.register=void 0,this.unregister=void 0,this.name=c,this.register=()=>{this.registered||(this.registered=!0,m(g))},this.unregister=()=>{this.register&&(this.registered=!1,p(g))},this.callback=g}}class s{constructor(c){this._minPixelDragDistance=void 0,this._minPixelDragDistanceDrawing=void 0,this._minPixelDragDistanceSelecting=void 0,this._lastDrawEvent=void 0,this._coordinatePrecision=void 0,this._heldKeys=new Set,this._listeners=[],this._dragState="not-dragging",this._currentModeCallbacks=void 0,this._minPixelDragDistance="number"==typeof c.minPixelDragDistance?c.minPixelDragDistance:1,this._minPixelDragDistanceSelecting="number"==typeof c.minPixelDragDistanceSelecting?c.minPixelDragDistanceSelecting:1,this._minPixelDragDistanceDrawing="number"==typeof c.minPixelDragDistanceDrawing?c.minPixelDragDistanceDrawing:8,this._coordinatePrecision="number"==typeof c.coordinatePrecision?c.coordinatePrecision:9}getButton(c){return-1===c.button?"neither":0===c.button?"left":1===c.button?"middle":2===c.button?"right":"neither"}getMapElementXYPosition(c){const g=this.getMapEventElement(),{left:p,top:m}=g.getBoundingClientRect();return{containerX:c.clientX-p,containerY:c.clientY-m}}getDrawEventFromEvent(c){const g=this.getLngLatFromEvent(c);if(!g)return null;const{lng:p,lat:m}=g,{containerX:f,containerY:_}=this.getMapElementXYPosition(c),y=this.getButton(c),x=Array.from(this._heldKeys);return{lng:e(p,this._coordinatePrecision),lat:e(m,this._coordinatePrecision),containerX:f,containerY:_,button:y,heldKeys:x}}register(c){this._currentModeCallbacks=c,this._listeners=this.getAdapterListeners(),this._listeners.forEach((c=>{c.register()}))}getCoordinatePrecision(){return this._coordinatePrecision}getAdapterListeners(){return[new o({name:"pointerdown",callback:c=>{if(!this._currentModeCallbacks)return;if(!c.isPrimary)return;const g=this.getDrawEventFromEvent(c);g&&(this._dragState="pre-dragging",this._lastDrawEvent=g)},register:c=>{this.getMapEventElement().addEventListener("pointerdown",c)},unregister:c=>{this.getMapEventElement().removeEventListener("pointerdown",c)}}),new o({name:"pointermove",callback:c=>{if(!this._currentModeCallbacks)return;if(!c.isPrimary)return;c.preventDefault();const g=this.getDrawEventFromEvent(c);if(g)if("not-dragging"===this._dragState)this._currentModeCallbacks.onMouseMove(g),this._lastDrawEvent=g;else if("pre-dragging"===this._dragState){if(!this._lastDrawEvent)return;const c={x:this._lastDrawEvent.containerX,y:this._lastDrawEvent.containerY},p={x:g.containerX,y:g.containerY},m=this._currentModeCallbacks.getState(),f=i(c,p);let _=!1;if(_="drawing"===m?f<this._minPixelDragDistanceDrawing:"selecting"===m?f<this._minPixelDragDistanceSelecting:f<this._minPixelDragDistance,_)return;this._dragState="dragging",this._currentModeCallbacks.onDragStart(g,(c=>{this.setDraggability.bind(this)(c)}))}else"dragging"===this._dragState&&this._currentModeCallbacks.onDrag(g,(c=>{this.setDraggability.bind(this)(c)}))},register:c=>{this.getMapEventElement().addEventListener("pointermove",c)},unregister:c=>{this.getMapEventElement().removeEventListener("pointermove",c)}}),new o({name:"contextmenu",callback:c=>{this._currentModeCallbacks&&c.preventDefault()},register:c=>{this.getMapEventElement().addEventListener("contextmenu",c)},unregister:c=>{this.getMapEventElement().removeEventListener("contextmenu",c)}}),new o({name:"pointerup",callback:c=>{if(!this._currentModeCallbacks)return;if(c.target!==this.getMapEventElement())return;if(!c.isPrimary)return;const g=this.getDrawEventFromEvent(c);g&&("dragging"===this._dragState?this._currentModeCallbacks.onDragEnd(g,(c=>{this.setDraggability.bind(this)(c)})):"not-dragging"!==this._dragState&&"pre-dragging"!==this._dragState||this._currentModeCallbacks.onClick(g),this._dragState="not-dragging",this.setDraggability(!0))},register:c=>{this.getMapEventElement().addEventListener("pointerup",c)},unregister:c=>{this.getMapEventElement().removeEventListener("pointerup",c)}}),new o({name:"keyup",callback:c=>{this._currentModeCallbacks&&(this._heldKeys.delete(c.key),this._currentModeCallbacks.onKeyUp({key:c.key,heldKeys:Array.from(this._heldKeys),preventDefault:()=>c.preventDefault()}))},register:c=>{this.getMapEventElement().addEventListener("keyup",c)},unregister:c=>{this.getMapEventElement().removeEventListener("keyup",c)}}),new o({name:"keydown",callback:c=>{this._currentModeCallbacks&&(this._heldKeys.add(c.key),this._currentModeCallbacks.onKeyDown({key:c.key,heldKeys:Array.from(this._heldKeys),preventDefault:()=>c.preventDefault()}))},register:c=>{this.getMapEventElement().addEventListener("keydown",c)},unregister:c=>{this.getMapEventElement().removeEventListener("keydown",c)}})]}unregister(){this._listeners.forEach((c=>{c.unregister()})),this.clear()}}function h(){throw new Error("Unimplemented abstract method.")}let g=0;function d(c,g){return Array.isArray(c)?c:(void 0===g?g=[c,c]:(g[0]=c,g[1]=c),g)}class u{constructor(c){this.opacity_=c.opacity,this.rotateWithView_=c.rotateWithView,this.rotation_=c.rotation,this.scale_=c.scale,this.scaleArray_=d(c.scale),this.displacement_=c.displacement,this.declutterMode_=c.declutterMode}clone(){const c=this.getScale();return new u({opacity:this.getOpacity(),scale:Array.isArray(c)?c.slice():c,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return h()}getImage(c){return h()}getHitDetectionImage(){return h()}getPixelRatio(c){return 1}getImageState(){return h()}getImageSize(){return h()}getOrigin(){return h()}getSize(){return h()}setDisplacement(c){this.displacement_=c}setOpacity(c){this.opacity_=c}setRotateWithView(c){this.rotateWithView_=c}setRotation(c){this.rotation_=c}setScale(c){this.scale_=c,this.scaleArray_=d(c)}listenImageChange(c){h()}load(){h()}unlistenImageChange(c){h()}ready(){return Promise.resolve()}}var p=u,m={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]},f={name:"xyz",min:[0,0,0],channel:["X","Y","Z"],alias:["XYZ","ciexyz","cie1931"],whitepoint:{2:{A:[109.85,100,35.585],C:[98.074,100,118.232],D50:[96.422,100,82.521],D55:[95.682,100,92.149],D65:[95.045592705167,100,108.9057750759878],D75:[94.972,100,122.638],F2:[99.187,100,67.395],F7:[95.044,100,108.755],F11:[100.966,100,64.37],E:[100,100,100]},10:{A:[111.144,100,35.2],C:[97.285,100,116.145],D50:[96.72,100,81.427],D55:[95.799,100,90.926],D65:[94.811,100,107.304],D75:[94.416,100,120.641],F2:[103.28,100,69.026],F7:[95.792,100,107.687],F11:[103.866,100,65.627],E:[100,100,100]}}};f.max=f.whitepoint[2].D65,f.rgb=function(c,g){var p,m,_,y=c[0]/(g=g||f.whitepoint[2].E)[0],x=c[1]/g[1],v=c[2]/g[2];return m=-.96924363628087*y+1.87596750150772*x+.041555057407175*v,_=.055630079696993*y+-.20397695888897*x+1.056971514242878*v,p=(p=3.240969941904521*y+-1.537383177570093*x+-.498610760293*v)>.0031308?1.055*Math.pow(p,1/2.4)-.055:p*=12.92,m=m>.0031308?1.055*Math.pow(m,1/2.4)-.055:m*=12.92,_=_>.0031308?1.055*Math.pow(_,1/2.4)-.055:_*=12.92,[255*(p=Math.min(Math.max(0,p),1)),255*(m=Math.min(Math.max(0,m),1)),255*(_=Math.min(Math.max(0,_),1))]},m.xyz=function(c,g){var p=c[0]/255,m=c[1]/255,_=c[2]/255;return[(.41239079926595*(p=p>.04045?Math.pow((p+.055)/1.055,2.4):p/12.92)+.35758433938387*(m=m>.04045?Math.pow((m+.055)/1.055,2.4):m/12.92)+.18048078840183*(_=_>.04045?Math.pow((_+.055)/1.055,2.4):_/12.92))*(g=g||f.whitepoint[2].E)[0],(.21263900587151*p+.71516867876775*m+.072192315360733*_)*g[1],(.019330818715591*p+.11919477979462*m+.95053215224966*_)*g[2]]};var _={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(c,g,p){var m,_,y,x,v,P,E;return 0===(y=c[0])?[0,0,0]:(m=c[1]/(13*y)+4*(v=f.whitepoint[p=p||2][g=g||"D65"][0])/(v+15*(P=f.whitepoint[p][g][1])+3*(E=f.whitepoint[p][g][2]))||0,_=c[2]/(13*y)+9*P/(v+15*P+3*E)||0,[9*(x=y>8?P*Math.pow((y+16)/116,3):P*y*.0011070564598794539)*m/(4*_)||0,x,x*(12-3*m-20*_)/(4*_)||0])}};f.luv=function(c,g,p){var m,_,y,x,v,P,E,b,M,T,R;T=4*(E=f.whitepoint[p=p||2][g=g||"D65"][0])/(E+15*(b=f.whitepoint[p][g][1])+3*(M=f.whitepoint[p][g][2])),R=9*b/(E+15*b+3*M),m=4*(x=c[0])/(x+15*(v=c[1])+3*(P=c[2]))||0,_=9*v/(x+15*v+3*P)||0;var L=v/b;return[y=L<=.008856451679035631?903.2962962962961*L:116*Math.pow(L,1/3)-16,13*y*(m-T),13*y*(_-R)]},_.lchuv=function(c){var g=c[0],p=c[1],m=c[2],f=Math.sqrt(p*p+m*m),_=360*Math.atan2(m,p)/2/Math.PI;return _<0&&(_+=360),[g,f,_]},f.lchuv=function(c){return _.lchuv(f.luv(c))};var y={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},x={red:0,orange:60,yellow:120,green:180,blue:240,purple:300},v={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(c){var g,p,m,f,_,y=c[0]/360,x=c[1]/100,v=c[2]/100,P=0;if(0===x)return[_=255*v,_,_];for(g=2*v-(p=v<.5?v*(1+x):v+x-v*x),f=[0,0,0];P<3;)(m=y+1/3*-(P-1))<0?m++:m>1&&m--,f[P++]=255*(_=6*m<1?g+6*(p-g)*m:2*m<1?p:3*m<2?g+(p-g)*(2/3-m)*6:g);return f}};function C(c,g,p){return Math.min(Math.max(c,g),p)}m.hsl=function(c){var g,p,m=c[0]/255,f=c[1]/255,_=c[2]/255,y=Math.min(m,f,_),x=Math.max(m,f,_),v=x-y;return x===y?g=0:m===x?g=(f-_)/v:f===x?g=2+(_-m)/v:_===x&&(g=4+(m-f)/v),(g=Math.min(60*g,360))<0&&(g+=360),p=(y+x)/2,[g,100*(x===y?0:p<=.5?v/(x+y):v/(2-x-y)),100*p]};const P={};let E=0;function w(c){return Array.isArray(c)?c:function(c){if(P.hasOwnProperty(c))return P[c];if(E>=1024){let c=0;for(const g in P)3&c++||(delete P[g],--E)}const g=function(c){var g;Array.isArray(c)&&c.raw&&(c=String.raw(...arguments)),c instanceof Number&&(c=+c);var p=function(c){var g,p,m=[],f=1;if("number"==typeof c)return{space:"rgb",values:[c>>>16,(65280&c)>>>8,255&c],alpha:1};if("number"==typeof c)return{space:"rgb",values:[c>>>16,(65280&c)>>>8,255&c],alpha:1};if(c=String(c).toLowerCase(),y[c])m=y[c].slice(),p="rgb";else if("transparent"===c)f=0,p="rgb",m=[0,0,0];else if("#"===c[0]){var _=c.slice(1),v=_.length;f=1,v<=4?(m=[parseInt(_[0]+_[0],16),parseInt(_[1]+_[1],16),parseInt(_[2]+_[2],16)],4===v&&(f=parseInt(_[3]+_[3],16)/255)):(m=[parseInt(_[0]+_[1],16),parseInt(_[2]+_[3],16),parseInt(_[4]+_[5],16)],8===v&&(f=parseInt(_[6]+_[7],16)/255)),m[0]||(m[0]=0),m[1]||(m[1]=0),m[2]||(m[2]=0),p="rgb"}else if(g=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(c)){var P="cmyk"===(p=g[1].replace(/a$/,""))?4:"gray"===p?1:3;m=g[2].trim().split(/\s*[,\/]\s*|\s+/),"color"===p&&(p=m.shift()),f=(m=m.map((function(c,g){if("%"===c[c.length-1])return c=parseFloat(c)/100,3===g?c:"rgb"===p?255*c:"h"===p[0]?100*c:"l"!==p[0]||g?"lab"===p?125*c:"lch"===p?g<2?150*c:360*c:"o"!==p[0]||g?"oklab"===p?.4*c:"oklch"===p?g<2?.4*c:360*c:c:c:100*c;if("h"===p[g]||2===g&&"h"===p[p.length-1]){if(void 0!==x[c])return x[c];if(c.endsWith("deg"))return parseFloat(c);if(c.endsWith("turn"))return 360*parseFloat(c);if(c.endsWith("grad"))return 360*parseFloat(c)/400;if(c.endsWith("rad"))return 180*parseFloat(c)/Math.PI}return"none"===c?0:parseFloat(c)}))).length>P?m.pop():1}else/[0-9](?:\s|\/|,)/.test(c)&&(m=c.match(/([0-9]+)/g).map((function(c){return parseFloat(c)})),p=c.match(/([a-z])/gi)?.join("")?.toLowerCase()||"rgb");return{space:p,values:m,alpha:f}}(c);if(!p.space)return[];const f="h"===p.space[0]?v.min:m.min,_="h"===p.space[0]?v.max:m.max;return(g=Array(3))[0]=Math.min(Math.max(p.values[0],f[0]),_[0]),g[1]=Math.min(Math.max(p.values[1],f[1]),_[1]),g[2]=Math.min(Math.max(p.values[2],f[2]),_[2]),"h"===p.space[0]&&(g=v.rgb(g)),g.push(Math.min(Math.max(p.alpha,0),1)),g}(c);if(4!==g.length)throw new Error('failed to parse "'+c+'" as color');for(const p of g)if(isNaN(p))throw new Error('failed to parse "'+c+'" as color');return function(c){c[0]=C(c[0]+.5|0,0,255),c[1]=C(c[1]+.5|0,0,255),c[2]=C(c[2]+.5|0,0,255),c[3]=C(c[3],0,1)}(g),P[c]=g,++E,g}(c)}function S(c){let g=c[0];g!=(0|g)&&(g=g+.5|0);let p=c[1];p!=(0|p)&&(p=p+.5|0);let m=c[2];return m!=(0|m)&&(m=m+.5|0),"rgba("+g+","+p+","+m+","+(void 0===c[3]?1:Math.round(1e3*c[3])/1e3)+")"}const b="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"";b.includes("firefox"),b.includes("safari")&&!b.includes("chrom")&&(b.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(b)),b.includes("webkit")&&b.includes("edge"),b.includes("macintosh");const M="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope,T="undefined"!=typeof Image&&Image.prototype.decode;function D(c,g,p,m){let f;return f=M?new OffscreenCanvas(c||300,g||300):document.createElement("canvas"),c&&(f.width=c),g&&(f.height=g),f.getContext("2d",m)}let R;function F(){return R||(R=D(1,1)),R}!function(){let c=!1;try{const g=Object.defineProperty({},"passive",{get:function(){c=!0}});window.addEventListener("_",null,g),window.removeEventListener("_",null,g)}catch(c){}}();var L=class O{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},I=class{constructor(c){this.type=c,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};function W(){}function j(c){for(const g in c)delete c[g]}var A=class extends L{constructor(c){super(),this.eventTarget_=c,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(c,g){if(!c||!g)return;const p=this.listeners_||(this.listeners_={}),m=p[c]||(p[c]=[]);m.includes(g)||m.push(g)}dispatchEvent(c){const g="string"==typeof c,p=g?c:c.type,m=this.listeners_&&this.listeners_[p];if(!m)return;const f=g?new I(c):c;f.target||(f.target=this.eventTarget_||this);const _=this.dispatching_||(this.dispatching_={}),y=this.pendingRemovals_||(this.pendingRemovals_={});let x;p in _||(_[p]=0,y[p]=0),++_[p];for(let c=0,g=m.length;c<g;++c)if(x="handleEvent"in m[c]?m[c].handleEvent(f):m[c].call(this,f),!1===x||f.propagationStopped){x=!1;break}if(0==--_[p]){let c=y[p];for(delete y[p];c--;)this.removeEventListener(p,W);delete _[p]}return x}disposeInternal(){this.listeners_&&j(this.listeners_)}getListeners(c){return this.listeners_&&this.listeners_[c]||void 0}hasListener(c){return!!this.listeners_&&(c?c in this.listeners_:Object.keys(this.listeners_).length>0)}removeEventListener(c,g){if(!this.listeners_)return;const p=this.listeners_[c];if(!p)return;const m=p.indexOf(g);-1!==m&&(this.pendingRemovals_&&c in this.pendingRemovals_?(p[m]=W,++this.pendingRemovals_[c]):(p.splice(m,1),0===p.length&&delete this.listeners_[c]))}},k="change";function N(c,g,p,m,f){if(f){const m=p;p=function(){c.removeEventListener(g,p),m.apply(this,arguments)}}const _={target:c,type:g,listener:p};return c.addEventListener(g,p),_}function A$1(c,g,p,m){return N(c,g,p,0,!0)}function R$1(c){c&&c.target&&(c.target.removeEventListener(c.type,c.listener),j(c))}function V$1(c,g,p){return g+":"+c+":"+(p?w(p):"null")}const G=new class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let c=0;for(const g in this.cache_)3&c++||this.cache_[g].hasListener()||(delete this.cache_[g],delete this.patternCache_[g],--this.cacheSize_)}}get(c,g,p){const m=V$1(c,g,p);return m in this.cache_?this.cache_[m]:null}getPattern(c,g,p){const m=V$1(c,g,p);return m in this.patternCache_?this.patternCache_[m]:null}set(c,g,p,m,f){const _=V$1(c,g,p),y=_ in this.cache_;this.cache_[_]=m,f&&(0===m.getImageState()&&m.load(),1===m.getImageState()?m.ready().then((()=>{this.patternCache_[_]=F().createPattern(m.getImage(1),"repeat")})):this.patternCache_[_]=F().createPattern(m.getImage(1),"repeat")),y||++this.cacheSize_}setSize(c){this.maxCacheSize_=c,this.expire()}};let B=null;class X extends A{constructor(c,g,p,m,f){super(),this.hitDetectionImage_=null,this.image_=c,this.crossOrigin_=p,this.canvas_={},this.color_=f,this.imageState_=void 0===m?0:m,this.size_=c&&c.width&&c.height?[c.width,c.height]:null,this.src_=g,this.ready_=null}initializeImage_(){this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(void 0===this.tainted_&&2===this.imageState_){B||(B=D(1,1,0,{willReadFrequently:!0})),B.drawImage(this.image_,0,0);try{B.getImageData(0,0,1,1),this.tainted_=!1}catch(c){B=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(k)}handleImageError_(){this.imageState_=3,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=2,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(c){return this.image_||this.initializeImage_(),this.replaceColor_(c),this.canvas_[c]?this.canvas_[c]:this.image_}getPixelRatio(c){return this.replaceColor_(c),this.canvas_[c]?c:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const c=this.size_[0],g=this.size_[1],p=D(c,g);p.fillRect(0,0,c,g),this.hitDetectionImage_=p.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(0===this.imageState_){this.image_||this.initializeImage_(),this.imageState_=1;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch(c){this.handleImageError_()}this.image_ instanceof HTMLImageElement&&(c=this.image_,g=this.src_,g&&(c.src=g),c.src&&T?new Promise(((g,p)=>c.decode().then((()=>g(c))).catch((m=>c.complete&&c.width?g(c):p(m))))):function(c){return new Promise(((g,p)=>{function o(){r(),g(c)}function s(){r(),p(new Error("Image load error"))}function r(){c.removeEventListener("load",o),c.removeEventListener("error",s)}c.addEventListener("load",o),c.addEventListener("error",s)}))}(c)).then((c=>{this.image_=c,this.handleImageLoad_()})).catch(this.handleImageError_.bind(this))}var c,g}replaceColor_(c){if(!this.color_||this.canvas_[c]||2!==this.imageState_)return;const g=this.image_,p=document.createElement("canvas");p.width=Math.ceil(g.width*c),p.height=Math.ceil(g.height*c);const m=p.getContext("2d");var f;m.scale(c,c),m.drawImage(g,0,0),m.globalCompositeOperation="multiply",m.fillStyle="string"==typeof(f=this.color_)?f:S(f),m.fillRect(0,0,p.width/c,p.height/c),m.globalCompositeOperation="destination-in",m.drawImage(g,0,0),this.canvas_[c]=p}ready(){return this.ready_||(this.ready_=new Promise((c=>{if(2===this.imageState_||3===this.imageState_)c();else{const e=()=>{2!==this.imageState_&&3!==this.imageState_||(this.removeEventListener(k,e),c())};this.addEventListener(k,e)}}))),this.ready_}}function U(c,g,p,m,f,_){let y=void 0===g?void 0:G.get(g,p,f);return y||(y=new X(c,c&&"src"in c?c.src||void 0:g,p,m,f),G.set(g,p,f,y,_)),_&&y&&!G.getPattern(g,p,f)&&G.set(g,p,f,y,_),y}function Y(c){return c?Array.isArray(c)?S(c):"object"==typeof c&&"src"in c?function(c){if(!c.offset||!c.size)return G.getPattern(c.src,"anonymous",c.color);const g=c.src+":"+c.offset,p=G.getPattern(g,void 0,c.color);if(p)return p;const m=G.get(c.src,"anonymous",null);if(2!==m.getImageState())return null;const f=D(c.size[0],c.size[1]);return f.drawImage(m.getImage(1),c.offset[0],c.offset[1],c.size[0],c.size[1],0,0,c.size[0],c.size[1]),U(f.canvas,g,void 0,2,c.color,!0),G.getPattern(g,void 0,c.color)}(c):c:null}var z=class extends A{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(k)}getRevision(){return this.revision_}onInternal(c,g){if(Array.isArray(c)){const p=c.length,m=new Array(p);for(let f=0;f<p;++f)m[f]=N(this,c[f],g);return m}return N(this,c,g)}onceInternal(c,g){let p;if(Array.isArray(c)){const m=c.length;p=new Array(m);for(let f=0;f<m;++f)p[f]=A$1(this,c[f],g)}else p=A$1(this,c,g);return g.ol_key=p,p}unInternal(c,g){const p=g.ol_key;if(p)!function(c){if(Array.isArray(c))for(let g=0,p=c.length;g<p;++g)R$1(c[g]);else R$1(c)}(p);else if(Array.isArray(c))for(let p=0,m=c.length;p<m;++p)this.removeEventListener(c[p],g);else this.removeEventListener(c,g)}};class K extends I{constructor(c,g,p){super(c),this.key=g,this.oldValue=p}}const $="#000",V="round",q="round";new class extends z{constructor(c){super(),this.ol_uid||(this.ol_uid=String(++g)),this.values_=null,void 0!==c&&this.setProperties(c)}get(c){let g;return this.values_&&this.values_.hasOwnProperty(c)&&(g=this.values_[c]),g}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(c,g){let p;p=`change:${c}`,this.hasListener(p)&&this.dispatchEvent(new K(p,c,g)),p="propertychange",this.hasListener(p)&&this.dispatchEvent(new K(p,c,g))}addChangeListener(c,g){this.addEventListener(`change:${c}`,g)}removeChangeListener(c,g){this.removeEventListener(`change:${c}`,g)}set(c,g,p){const m=this.values_||(this.values_={});if(p)m[c]=g;else{const p=m[c];m[c]=g,p!==g&&this.notify(c,p)}}setProperties(c,g){for(const p in c)this.set(p,c[p],g)}applyProperties(c){c.values_&&Object.assign(this.values_||(this.values_={}),c.values_)}unset(c,g){if(this.values_&&c in this.values_){const p=this.values_[c];delete this.values_[c],function(c){let g;for(g in c)return!1;return!g}(this.values_)&&(this.values_=null),g||this.notify(c,p)}}};var H=class Z extends p{constructor(c){super({opacity:1,rotateWithView:void 0!==c.rotateWithView&&c.rotateWithView,rotation:void 0!==c.rotation?c.rotation:0,scale:void 0!==c.scale?c.scale:1,displacement:void 0!==c.displacement?c.displacement:[0,0],declutterMode:c.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=void 0!==c.fill?c.fill:null,this.origin_=[0,0],this.points_=c.points,this.radius=c.radius,this.radius2_=c.radius2,this.angle_=void 0!==c.angle?c.angle:0,this.stroke_=void 0!==c.stroke?c.stroke:null,this.imageState_=this.fill_&&this.fill_.loading()?1:2,1===this.imageState_&&this.ready().then((()=>this.imageState_=2)),this.render()}clone(){const c=this.getScale(),g=new Z({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(c)?c.slice():c,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return g.setOpacity(this.getOpacity()),g}getAnchor(){const c=this.size_,g=this.getDisplacement(),p=this.getScaleArray();return[c[0]/2-g[0]/p[0],c[1]/2+g[1]/p[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(c){this.fill_=c,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(c){let g=this.canvases_[c];if(!g){const p=this.renderOptions_,m=D(p.size*c,p.size*c);this.draw_(p,m,c),g=m.canvas,this.canvases_[c]=g}return g}getPixelRatio(c){return c}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(c){this.stroke_=c,this.render()}listenImageChange(c){}load(){}unlistenImageChange(c){}calculateLineJoinSize_(c,g,p){if(0===g||1/0===this.points_||"bevel"!==c&&"miter"!==c)return g;let m=this.radius,f=void 0===this.radius2_?m:this.radius2_;if(m<f){const c=m;m=f,f=c}const _=2*Math.PI/(void 0===this.radius2_?this.points_:2*this.points_),y=f*Math.sin(_),x=m-Math.sqrt(f*f-y*y),v=Math.sqrt(y*y+x*x),P=v/y;if("miter"===c&&P<=p)return P*g;const E=g/2/P,b=g/2*(x/v),M=Math.sqrt((m+E)*(m+E)+b*b)-m;if(void 0===this.radius2_||"bevel"===c)return 2*M;const T=m*Math.sin(_),R=f-Math.sqrt(m*m-T*T),L=Math.sqrt(T*T+R*R)/T;return L<=p?2*Math.max(M,L*g/2-f-m):2*M}createRenderOptions(){let c,g=V,p=q,m=0,f=null,_=0,y=0;this.stroke_&&(c=Y(this.stroke_.getColor()??"#000"),y=this.stroke_.getWidth()??1,f=this.stroke_.getLineDash(),_=this.stroke_.getLineDashOffset()??0,p=this.stroke_.getLineJoin()??q,g=this.stroke_.getLineCap()??V,m=this.stroke_.getMiterLimit()??10);const x=this.calculateLineJoinSize_(p,y,m),v=Math.max(this.radius,this.radius2_||0);return{strokeStyle:c,strokeWidth:y,size:Math.ceil(2*v+x),lineCap:g,lineDash:f,lineDashOffset:_,lineJoin:p,miterLimit:m}}render(){this.renderOptions_=this.createRenderOptions();const c=this.renderOptions_.size;this.canvases_={},this.hitDetectionCanvas_=null,this.size_=[c,c]}draw_(c,g,p){if(g.scale(p,p),g.translate(c.size/2,c.size/2),this.createPath_(g),this.fill_){let c=this.fill_.getColor();null===c&&(c=$),g.fillStyle=Y(c),g.fill()}c.strokeStyle&&(g.strokeStyle=c.strokeStyle,g.lineWidth=c.strokeWidth,c.lineDash&&(g.setLineDash(c.lineDash),g.lineDashOffset=c.lineDashOffset),g.lineCap=c.lineCap,g.lineJoin=c.lineJoin,g.miterLimit=c.miterLimit,g.stroke())}createHitDetectionCanvas_(c){let g;if(this.fill_){let p=this.fill_.getColor(),m=0;"string"==typeof p&&(p=w(p)),null===p?m=1:Array.isArray(p)&&(m=4===p.length?p[3]:1),0===m&&(g=D(c.size,c.size),this.drawHitDetectionCanvas_(c,g))}return g?g.canvas:this.getImage(1)}createPath_(c){let g=this.points_;const p=this.radius;if(1/0===g)c.arc(0,0,p,0,2*Math.PI);else{const m=void 0===this.radius2_?p:this.radius2_;void 0!==this.radius2_&&(g*=2);const f=this.angle_-Math.PI/2,_=2*Math.PI/g;for(let y=0;y<g;y++){const g=f+y*_,x=y%2==0?p:m;c.lineTo(x*Math.cos(g),x*Math.sin(g))}c.closePath()}}drawHitDetectionCanvas_(c,g){g.translate(c.size/2,c.size/2),this.createPath_(g),g.fillStyle=$,g.fill(),c.strokeStyle&&(g.strokeStyle=c.strokeStyle,g.lineWidth=c.strokeWidth,c.lineDash&&(g.setLineDash(c.lineDash),g.lineDashOffset=c.lineDashOffset),g.lineJoin=c.lineJoin,g.miterLimit=c.miterLimit,g.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}};class tt extends H{constructor(c){super({points:1/0,fill:(c=c||{radius:5}).fill,radius:c.radius,stroke:c.stroke,scale:void 0!==c.scale?c.scale:1,rotation:void 0!==c.rotation?c.rotation:0,rotateWithView:void 0!==c.rotateWithView&&c.rotateWithView,displacement:void 0!==c.displacement?c.displacement:[0,0],declutterMode:c.declutterMode})}clone(){const c=this.getScale(),g=new tt({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(c)?c.slice():c,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return g.setOpacity(this.getOpacity()),g}setRadius(c){this.radius=c,this.render()}}var J=tt;class it{constructor(c){c=c||{},this.patternImage_=null,this.color_=null,void 0!==c.color&&this.setColor(c.color)}clone(){const c=this.getColor();return new it({color:Array.isArray(c)?c.slice():c||void 0})}getColor(){return this.color_}setColor(c){if(null!==c&&"object"==typeof c&&"src"in c){const g=U(null,c.src,"anonymous",void 0,c.offset?null:c.color?c.color:null,!(c.offset&&c.size));g.ready().then((()=>{this.patternImage_=null})),0===g.getImageState()&&g.load(),1===g.getImageState()&&(this.patternImage_=g)}this.color_=c}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}var Q=it;class st{constructor(c){this.color_=void 0!==(c=c||{}).color?c.color:null,this.lineCap_=c.lineCap,this.lineDash_=void 0!==c.lineDash?c.lineDash:null,this.lineDashOffset_=c.lineDashOffset,this.lineJoin_=c.lineJoin,this.miterLimit_=c.miterLimit,this.width_=c.width}clone(){const c=this.getColor();return new st({color:Array.isArray(c)?c.slice():c||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(c){this.color_=c}setLineCap(c){this.lineCap_=c}setLineDash(c){this.lineDash_=c}setLineDashOffset(c){this.lineDashOffset_=c}setLineJoin(c){this.lineJoin_=c}setMiterLimit(c){this.miterLimit_=c}setWidth(c){this.width_=c}}var et=st;class nt{constructor(c){c=c||{},this.geometry_=null,this.geometryFunction_=at,void 0!==c.geometry&&this.setGeometry(c.geometry),this.fill_=void 0!==c.fill?c.fill:null,this.image_=void 0!==c.image?c.image:null,this.renderer_=void 0!==c.renderer?c.renderer:null,this.hitDetectionRenderer_=void 0!==c.hitDetectionRenderer?c.hitDetectionRenderer:null,this.stroke_=void 0!==c.stroke?c.stroke:null,this.text_=void 0!==c.text?c.text:null,this.zIndex_=c.zIndex}clone(){let c=this.getGeometry();return c&&"object"==typeof c&&(c=c.clone()),new nt({geometry:c??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(c){this.renderer_=c}setHitDetectionRenderer(c){this.hitDetectionRenderer_=c}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(c){this.fill_=c}getImage(){return this.image_}setImage(c){this.image_=c}getStroke(){return this.stroke_}setStroke(c){this.stroke_=c}getText(){return this.text_}setText(c){this.text_=c}getZIndex(){return this.zIndex_}setGeometry(c){"function"==typeof c?this.geometryFunction_=c:"string"==typeof c?this.geometryFunction_=function(g){return g.get(c)}:c?void 0!==c&&(this.geometryFunction_=function(){return c}):this.geometryFunction_=at,this.geometry_=c}setZIndex(c){this.zIndex_=c}}function at(c){return c.getGeometry()}var rt=nt;const ot={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var lt=class{constructor(c){this.code_=c.code,this.units_=c.units,this.extent_=void 0!==c.extent?c.extent:null,this.worldExtent_=void 0!==c.worldExtent?c.worldExtent:null,this.axisOrientation_=void 0!==c.axisOrientation?c.axisOrientation:"enu",this.global_=void 0!==c.global&&c.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=c.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=c.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||ot[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(c){this.global_=c,this.canWrapX_=!(!c||!this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(c){this.defaultTileGrid_=c}setExtent(c){this.extent_=c,this.canWrapX_=!(!this.global_||!c)}setWorldExtent(c){this.worldExtent_=c}setGetPointResolution(c){this.getPointResolutionFunc_=c}getPointResolutionFunc(){return this.getPointResolutionFunc_}};const ht=6378137,ct=Math.PI*ht,ut=[-ct,-ct,ct,ct],dt=[-180,-85,180,85],gt=ht*Math.log(Math.tan(Math.PI/2));class mt extends lt{constructor(c){super({code:c,units:"m",extent:ut,global:!0,worldExtent:dt,getPointResolution:function(c,g){return c/Math.cosh(g[1]/ht)}})}}const pt=[new mt("EPSG:3857"),new mt("EPSG:102100"),new mt("EPSG:102113"),new mt("EPSG:900913"),new mt("http://www.opengis.net/def/crs/EPSG/0/3857"),new mt("http://www.opengis.net/gml/srs/epsg.xml#3857")],ft=[-180,-90,180,90],_t=6378137*Math.PI/180;class Ct extends lt{constructor(c,g){super({code:c,units:"degrees",extent:ft,axisOrientation:g,global:!0,metersPerUnit:_t,worldExtent:ft})}}const yt=[new Ct("CRS:84"),new Ct("EPSG:4326","neu"),new Ct("urn:ogc:def:crs:OGC:1.3:CRS84"),new Ct("urn:ogc:def:crs:OGC:2:84"),new Ct("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Ct("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Ct("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let xt={},vt={};function wt(c,g,p){const m=c.getCode(),f=g.getCode();m in vt||(vt[m]={}),vt[m][f]=p}function St(c,g){if(void 0!==g)for(let p=0,m=c.length;p<m;++p)g[p]=c[p];else g=c.slice();return g}function bt(c,g){if(void 0!==g&&c!==g){for(let p=0,m=c.length;p<m;++p)g[p]=c[p];c=g}return c}function Et(c){!function(c,g){xt[c]=g}(c.getCode(),c),wt(c,c,St)}function It(c){return"string"==typeof c?xt[g=c]||xt[g.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null:c||null;var g}function Dt(c){!function(c){c.forEach(Et)}(c),c.forEach((function(g){c.forEach((function(c){g!==c&&wt(g,c,St)}))}))}function kt(c,g,p){const m=function(c,g){return function(c,g){let p=function(c,g){let p;return c in vt&&g in vt[c]&&(p=vt[c][g]),p}(c.getCode(),g.getCode());return p||(p=bt),p}(It(c),It(g))}(g,p);return m(c,void 0,c.length)}var Pt,Mt,Lt,Ft;Dt(pt),Dt(yt),Pt=pt,Mt=function(c,g,p){const m=c.length;p=p>1?p:2,void 0===g&&(g=p>2?c.slice():new Array(m));for(let f=0;f<m;f+=p){g[f]=ct*c[f]/180;let p=ht*Math.log(Math.tan(Math.PI*(+c[f+1]+90)/360));p>gt?p=gt:p<-gt&&(p=-gt),g[f+1]=p}return g},Lt=function(c,g,p){const m=c.length;p=p>1?p:2,void 0===g&&(g=p>2?c.slice():new Array(m));for(let f=0;f<m;f+=p)g[f]=180*c[f]/ct,g[f+1]=360*Math.atan(Math.exp(c[f+1]/ht))/Math.PI-90;return g},yt.forEach((function(c){Pt.forEach((function(g){wt(c,g,Mt),wt(g,c,Lt)}))}));class jt extends s{constructor(c){super(c),this.stylingFunction=()=>({}),this._lib=void 0,this._map=void 0,this._container=void 0,this._projection="EPSG:3857",this._vectorSource=void 0,this._geoJSONReader=void 0,this._map=c.map,this._lib=c.lib,this._geoJSONReader=new this._lib.GeoJSON,this._container=this._map.getViewport(),this._container.setAttribute("tabindex","0");const g=new this._lib.VectorSource({features:[]});this._vectorSource=g;const p=new this._lib.VectorLayer({source:g,style:c=>this.getStyles(c,this.stylingFunction())});this._map.addLayer(p)}hexToRGB(c){return{r:parseInt(c.slice(1,3),16),g:parseInt(c.slice(3,5),16),b:parseInt(c.slice(5,7),16)}}getStyles(c,g){const p=c.getGeometry();if(p)return{Point:c=>{const p=c.getProperties(),m=g[p.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:p});return new this._lib.Style({image:new J({radius:m.pointWidth,fill:new Q({color:m.pointColor}),stroke:new et({color:m.pointOutlineColor,width:m.pointOutlineWidth})})})},LineString:c=>{const p=c.getProperties(),m=g[p.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:p});return new this._lib.Style({stroke:new this._lib.Stroke({color:m.lineStringColor,width:m.lineStringWidth})})},Polygon:c=>{const p=c.getProperties(),m=g[p.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:p}),{r:f,g:_,b:y}=this.hexToRGB(m.polygonFillColor);return new rt({stroke:new et({color:m.polygonOutlineColor,width:m.polygonOutlineWidth}),fill:new Q({color:`rgba(${f},${_},${y},${m.polygonFillOpacity})`})})}}[p.getType()](c)}clearLayers(){this._vectorSource&&this._vectorSource.clear()}addFeature(c){if(!this._vectorSource||!this._geoJSONReader)throw new Error("Vector Source not initalised");{const g=this._geoJSONReader.readFeature(c,{featureProjection:this._projection});this._vectorSource.addFeature(g)}}removeFeature(c){if(!this._vectorSource)throw new Error("Vector Source not initalised");{const g=this._vectorSource.getFeatureById(c);if(!g)return;this._vectorSource.removeFeature(g)}}getLngLatFromEvent(c){const{containerX:g,containerY:p}=this.getMapElementXYPosition(c);try{return this.unproject(g,p)}catch(c){return null}}getMapEventElement(){const c=this._container.querySelectorAll("canvas");if(c.length>1)throw Error("Terra Draw currently only supports 1 canvas with OpenLayers");return c[0]}setDraggability(c){this._map.getInteractions().forEach((g=>{"DragPan"===g.constructor.name&&g.setActive(c)}))}project(c,g){const[p,m]=this._map.getPixelFromCoordinate(kt([c,g],"EPSG:4326","EPSG:3857"));return{x:p,y:m}}unproject(c,g){const[p,m]=function(c){const g=kt(c,"EPSG:3857","EPSG:4326"),p=g[0];return(p<-180||p>180)&&(g[0]=function(c){const g=c%360;return 360*g<0?g+360:g}(p+180)-180),g}(this._map.getCoordinateFromPixel([c,g]));return{lng:p,lat:m}}setCursor(c){"unset"===c?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=c}setDoubleClickToZoom(c){this._map.getInteractions().forEach((function(g){"DoubleClickZoom"===g.constructor.name&&g.setActive(c)}))}render(c,g){if(this.stylingFunction=()=>g,!this._vectorSource)throw new Error("Vector Layer source has disappeared");c.deletedIds.forEach((c=>{this.removeFeature(c)})),c.updated.forEach((c=>{this.removeFeature(c.id),this.addFeature(c)})),c.created.forEach((c=>{this.addFeature(c)}))}clear(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())}register(c){super.register(c),this._currentModeCallbacks&&this._currentModeCallbacks.onReady&&this._currentModeCallbacks.onReady()}getCoordinatePrecision(){return super.getCoordinatePrecision()}unregister(){return super.unregister()}}!function(c){c.Commit="commit",c.Provisional="provisional",c.Finish="finish"}(Ft||(Ft={}));const At="selected",Ot="midPoint",Nt="closingPoint";function Rt(c){return Boolean(c&&"object"==typeof c&&null!==c&&!Array.isArray(c))}function Vt(c){if(!function(c){return"number"==typeof c&&!isNaN(new Date(c).valueOf())}(c))throw new Error("updatedAt and createdAt are not valid timestamps");return!0}var Gt;!function(c){c.Drawing="drawing",c.Select="select",c.Static="static",c.Render="render"}(Gt||(Gt={}));class Tt{get state(){return this._state}set state(c){throw new Error("Please use the modes lifecycle methods")}get styles(){return this._styles}set styles(c){if("object"!=typeof c)throw new Error("Styling must be an object");this.onStyleChange([],"styling"),this._styles=c}registerBehaviors(c){}constructor(c){this._state=void 0,this._styles=void 0,this.behaviors=[],this.validate=void 0,this.pointerDistance=void 0,this.coordinatePrecision=void 0,this.onStyleChange=void 0,this.store=void 0,this.setDoubleClickToZoom=void 0,this.unproject=void 0,this.project=void 0,this.setCursor=void 0,this.projection=void 0,this.type=Gt.Drawing,this.mode="base",this._state="unregistered",this._styles=c&&c.styles?t({},c.styles):{},this.pointerDistance=c&&c.pointerDistance||40,this.validate=c&&c.validation,this.projection=c&&c.projection||"web-mercator"}setDrawing(){if("started"!==this._state)throw new Error("Mode must be unregistered or stopped to start");this._state="drawing"}setStarted(){if("stopped"!==this._state&&"registered"!==this._state&&"drawing"!==this._state&&"selecting"!==this._state)throw new Error("Mode must be unregistered or stopped to start");this._state="started",this.setDoubleClickToZoom(!1)}setStopped(){if("started"!==this._state)throw new Error("Mode must be started to be stopped");this._state="stopped",this.setDoubleClickToZoom(!0)}register(c){if("unregistered"!==this._state)throw new Error("Can not register unless mode is unregistered");this._state="registered",this.store=c.store,this.store.registerOnChange(c.onChange),this.setDoubleClickToZoom=c.setDoubleClickToZoom,this.project=c.project,this.unproject=c.unproject,this.onSelect=c.onSelect,this.onDeselect=c.onDeselect,this.setCursor=c.setCursor,this.onStyleChange=c.onChange,this.onFinish=c.onFinish,this.coordinatePrecision=c.coordinatePrecision,this.registerBehaviors({mode:c.mode,store:this.store,project:this.project,unproject:this.unproject,pointerDistance:this.pointerDistance,coordinatePrecision:c.coordinatePrecision,projection:this.projection})}validateFeature(c){if("unregistered"===this._state)throw new Error("Mode must be registered");const g=function(c,g){let p;if(Rt(c))if(null==c.id)p="Feature has no id";else if("string"!=typeof c.id&&"number"!=typeof c.id)p="Feature must be string or number as per GeoJSON spec";else if(g(c.id))if(Rt(c.geometry))if(Rt(c.properties))if("string"==typeof c.geometry.type&&["Polygon","LineString","Point"].includes(c.geometry.type))if(Array.isArray(c.geometry.coordinates)){if(!c.properties.mode||"string"!=typeof c.properties.mode)throw new Error("Feature does not have a valid mode property")}else p="Feature coordinates is not an array";else p="Feature is not Point, LineString or Polygon";else p="Feature has no properties";else p="Feature has no geometry";else p="Feature must match the id strategy (default is UUID4)";else p="Feature is not object";if(p)throw new Error(p);return!0}(c,this.store.idStrategy.isValidId);return this.validate?this.validate(c,{project:this.project,unproject:this.unproject,coordinatePrecision:this.coordinatePrecision,updateType:Ft.Provisional}):g}onFinish(c,g){}onDeselect(c){}onSelect(c){}onKeyDown(c){}onKeyUp(c){}onMouseMove(c){}onClick(c){}onDragStart(c,g){}onDrag(c,g){}onDragEnd(c,g){}getHexColorStylingValue(c,g,p){return this.getStylingValue(c,g,p)}getNumericStylingValue(c,g,p){return this.getStylingValue(c,g,p)}getStylingValue(c,g,p){return void 0===c?g:"function"==typeof c?c(p):c}}class Xt extends Tt{constructor(...c){super(...c),this.type=Gt.Select}}function Ut(c,g){const i=c=>c*Math.PI/180,p=i(c[1]),m=i(c[0]),f=i(g[1]),_=f-p,y=i(g[0])-m,x=Math.sin(_/2)*Math.sin(_/2)+Math.cos(p)*Math.cos(f)*Math.sin(y/2)*Math.sin(y/2);return 2*Math.atan2(Math.sqrt(x),Math.sqrt(1-x))*6371e3/1e3}const Bt=6371008.8;function Ht(c){return c%360*Math.PI/180}function Kt(c){return c/(Bt/1e3)}function Jt(c){return c%(2*Math.PI)*180/Math.PI}const zt=57.29577951308232,$t=.017453292519943295,Wt=6378137,Qt=(c,g)=>({x:0===c?0:c*$t*Wt,y:0===g?0:Math.log(Math.tan(Math.PI/4+g*$t/2))*Wt}),te=(c,g)=>({lng:0===c?0:zt*(c/Wt),lat:0===g?0:(2*Math.atan(Math.exp(g/Wt))-Math.PI/2)*zt});function ee(c,g,p){const m=Ht(c[0]),f=Ht(c[1]),_=Ht(p),y=Kt(g),x=Math.asin(Math.sin(f)*Math.cos(y)+Math.cos(f)*Math.sin(y)*Math.cos(_));return[Jt(m+Math.atan2(Math.sin(_)*Math.sin(y)*Math.cos(f),Math.cos(y)-Math.sin(f)*Math.sin(x))),Jt(x)]}function ie(c){const{center:g,radiusKilometers:p,coordinatePrecision:m}=c,f=c.steps?c.steps:64,_=[];for(let c=0;c<f;c++){const y=ee(g,p,-360*c/f);_.push([e(y[0],m),e(y[1],m)])}return _.push(_[0]),{type:"Feature",geometry:{type:"Polygon",coordinates:[_]},properties:{}}}function oe(c){const g=0;let p;if("Polygon"===c.geometry.type)p=c.geometry.coordinates;else{if("LineString"!==c.geometry.type)throw new Error("Self intersects only accepts Polygons and LineStrings");p=[c.geometry.coordinates]}const m=[];for(let c=0;c<p.length;c++)for(let g=0;g<p[c].length-1;g++)for(let m=0;m<p.length;m++)for(let f=0;f<p[m].length-1;f++)r(c,g,m,f);return m.length>0;function s(c){return c<0-g||c>1+g}function r(c,g,f,_){const y=p[c][g],x=p[c][g+1],v=p[f][_],P=p[f][_+1],E=function(c,g,p,m){if(se(c,p)||se(c,m)||se(g,p)||se(m,p))return null;const f=c[0],_=c[1],y=g[0],x=g[1],v=p[0],P=p[1],E=m[0],b=m[1],M=(f-y)*(P-b)-(_-x)*(v-E);return 0===M?null:[((f*x-_*y)*(v-E)-(f-y)*(v*b-P*E))/M,((f*x-_*y)*(P-b)-(_-x)*(v*b-P*E))/M]}(y,x,v,P);if(null===E)return;let b,M;b=x[0]!==y[0]?(E[0]-y[0])/(x[0]-y[0]):(E[1]-y[1])/(x[1]-y[1]),M=P[0]!==v[0]?(E[0]-v[0])/(P[0]-v[0]):(E[1]-v[1])/(P[1]-v[1]),s(b)||s(M)||(E.toString(),m.push(E))}}function se(c,g){return c[0]===g[0]&&c[1]===g[1]}function re(c,g){return 2===c.length&&"number"==typeof c[0]&&"number"==typeof c[1]&&1/0!==c[0]&&1/0!==c[1]&&(m=c[0])>=-180&&m<=180&&(p=c[1])>=-90&&p<=90&&ne(c[0])<=g&&ne(c[1])<=g;var p,m}function ne(c){let g=1,p=0;for(;Math.round(c*g)/g!==c;)g*=10,p++;return p}function ae(c,g){return"Polygon"===c.geometry.type&&1===c.geometry.coordinates.length&&c.geometry.coordinates[0].length>=4&&c.geometry.coordinates[0].every((c=>re(c,g)))&&(p=c.geometry.coordinates[0][0])[0]===(m=c.geometry.coordinates[0][c.geometry.coordinates[0].length-1])[0]&&p[1]===m[1];var p,m}function le(c,g){return ae(c,g)&&!oe(c)}class he extends Tt{constructor(c){var g;super(c),this.mode="circle",this.center=void 0,this.clickCount=0,this.currentCircleId=void 0,this.keyEvents=void 0,this.cursors=void 0,this.startingRadiusKilometers=1e-5;const p={start:"crosshair"};if(this.cursors=c&&c.cursors?t({},p,c.cursors):p,null===(null==c?void 0:c.keyEvents))this.keyEvents={cancel:null,finish:null};else{const g={cancel:"Escape",finish:"Enter"};this.keyEvents=c&&c.keyEvents?t({},g,c.keyEvents):g}this.startingRadiusKilometers=null!=(g=null==c?void 0:c.startingRadiusKilometers)?g:1e-5,this.validate=null==c?void 0:c.validation}close(){if(void 0===this.currentCircleId)return;const c=this.currentCircleId;if(this.validate&&c){const g=this.store.getGeometryCopy(c);if(!this.validate({type:"Feature",id:c,geometry:g,properties:{}},{project:this.project,unproject:this.unproject,coordinatePrecision:this.coordinatePrecision,updateType:Ft.Finish}))return}this.center=void 0,this.currentCircleId=void 0,this.clickCount=0,"drawing"===this.state&&this.setStarted(),this.onFinish(c,{mode:this.mode,action:"draw"})}start(){this.setStarted(),this.setCursor(this.cursors.start)}stop(){this.cleanUp(),this.setStopped(),this.setCursor("unset")}onClick(c){if(0===this.clickCount){this.center=[c.lng,c.lat];const g=ie({center:this.center,radiusKilometers:this.startingRadiusKilometers,coordinatePrecision:this.coordinatePrecision}),[p]=this.store.create([{geometry:g.geometry,properties:{mode:this.mode,radiusKilometers:this.s