anymap-ts 0.10.1 → 0.12.0

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.
@@ -1,7 +1,602 @@
1
- var wt={ADD:"add",REMOVE:"remove"};var Ee={PROPERTYCHANGE:"propertychange"};var L={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};var ta=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},Ci=ta;function qc(n,t,e){let i,r;e=e||jt;let s=0,o=n.length,a=!1;for(;s<o;)i=s+(o-s>>1),r=+e(n[i],t),r<0?s=i+1:(o=i,a=!r);return a?s:~s}function jt(n,t){return n>t?1:n<t?-1:0}function $c(n,t){return n<t?1:n>t?-1:0}function Ri(n,t,e){if(n[0]<=t)return 0;let i=n.length;if(t<=n[i-1])return i-1;if(typeof e=="function"){for(let r=1;r<i;++r){let s=n[r];if(s===t)return r;if(s<t)return e(t,n[r-1],s)>0?r-1:r}return i-1}if(e>0){for(let r=1;r<i;++r)if(n[r]<t)return r-1;return i-1}if(e<0){for(let r=1;r<i;++r)if(n[r]<=t)return r;return i-1}for(let r=1;r<i;++r){if(n[r]==t)return r;if(n[r]<t)return n[r-1]-t<t-n[r]?r-1:r}return i-1}function Jc(n,t,e){for(;t<e;){let i=n[t];n[t]=n[e],n[e]=i,++t,--e}}function It(n,t){let e=Array.isArray(t)?t:[t],i=e.length;for(let r=0;r<i;r++)n[n.length]=e[r]}function Ot(n,t){let e=n.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(n[i]!==t[i])return!1;return!0}function Qc(n,t,e){let i=t||jt;return n.every(function(r,s){if(s===0)return!0;let o=i(n[s-1],r);return!(o>0||e&&o===0)})}function ei(){return!0}function ii(){return!1}function ni(){}function ms(n){let t,e,i;return function(){let r=Array.prototype.slice.call(arguments);return(!e||this!==i||!Ot(r,e))&&(i=this,e=r,t=n.apply(this,arguments)),t}}function ps(n){function t(){let e;try{e=n()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}function ze(n){for(let t in n)delete n[t]}function $t(n){let t;for(t in n)return!1;return!t}var ea=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};var mt=ea;var ia=class extends Ci{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;let i=this.listeners_||(this.listeners_={}),r=i[t]||(i[t]=[]);r.includes(e)||r.push(e)}dispatchEvent(t){let e=typeof t=="string",i=e?t:t.type,r=this.listeners_&&this.listeners_[i];if(!r)return;let s=e?new mt(t):t;s.target||(s.target=this.eventTarget_||this);let o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let h=0,c=r.length;h<c;++h)if("handleEvent"in r[h]?l=r[h].handleEvent(s):l=r[h].call(this,s),l===!1||s.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,ni);delete o[i]}return l}disposeInternal(){this.listeners_&&ze(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return this.listeners_?t?t in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(t,e){if(!this.listeners_)return;let i=this.listeners_[t];if(!i)return;let r=i.indexOf(e);r!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[r]=ni,++this.pendingRemovals_[t]):(i.splice(r,1),i.length===0&&delete this.listeners_[t]))}},je=ia;function G(n,t,e,i,r){if(r){let o=e;e=function(a){return n.removeEventListener(t,e),o.call(i??this,a)}}else i&&i!==n&&(e=e.bind(i));let s={target:n,type:t,listener:e};return n.addEventListener(t,e),s}function _n(n,t,e,i){return G(n,t,e,i,!0)}function B(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),ze(n))}var yn=class extends je{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(L.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){let i=t.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=G(this,t[s],e);return r}return G(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){let r=t.length;i=new Array(r);for(let s=0;s<r;++s)i[s]=_n(this,t[s],e)}else i=_n(this,t,e);return e.ol_key=i,i}unInternal(t,e){let i=e.ol_key;if(i)Ag(i);else if(Array.isArray(t))for(let r=0,s=t.length;r<s;++r)this.removeEventListener(t[r],e);else this.removeEventListener(t,e)}};yn.prototype.on;yn.prototype.once;yn.prototype.un;function Ag(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)B(n[t]);else B(n)}var _s=yn;function F(){throw new Error("Unimplemented abstract method.")}var Pg=0;function U(n){return n.ol_uid||(n.ol_uid=String(++Pg))}var ys=class extends mt{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}},na=class extends _s{constructor(t){super(),this.on,this.once,this.un,U(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}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(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new ys(i,t,e)),i=Ee.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new ys(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){let r=this.values_||(this.values_={});if(i)r[t]=e;else{let s=r[t];r[t]=e,s!==e&&this.notify(t,s)}}setProperties(t,e){for(let i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){let i=this.values_[t];delete this.values_[t],$t(this.values_)&&(this.values_=null),e||this.notify(t,i)}}},pt=na;var tu={LENGTH:"length"},xn=class extends mt{constructor(t,e,i){super(t),this.element=e,this.index=i}},ra=class extends pt{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t??[],this.unique_)for(let i=1,r=this.array_.length;i<r;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){let e=this.array_;for(let i=0,r=e.length;i<r;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(tu.LENGTH)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new xn(wt.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){let e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){let e=this.array_;for(let i=0,r=e.length;i<r;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;let e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new xn(wt.REMOVE,e,t)),e}setAt(t,e){let i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);let r=this.array_[t];this.array_[t]=e,this.dispatchEvent(new xn(wt.REMOVE,r,t)),this.dispatchEvent(new xn(wt.ADD,e,t))}updateLength_(){this.set(tu.LENGTH,this.array_.length)}assertUnique_(t,e){let i=this.array_;for(let r=0,s=i.length;r<s;++r)if(i[r]===t&&r!==e)throw new Error("Duplicate item added to a unique collection")}},Mt=ra;var sa=class extends mt{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}},wi=sa;var oa=class extends wi{constructor(t,e,i,r,s,o){super(t,e,s),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=r!==void 0?r:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}},We=oa;var at={SINGLECLICK:"singleclick",CLICK:L.CLICK,DBLCLICK:L.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var Ji=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",Og=Ji.includes("safari")&&!Ji.includes("chrom"),dy=Og&&(Ji.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Ji)),eu=Ji.includes("webkit")&&!Ji.includes("edge"),aa=Ji.includes("macintosh"),iu=typeof devicePixelRatio<"u"?devicePixelRatio:1,xt=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,xs=typeof Image<"u"&&Image.prototype.decode,la=typeof createImageBitmap=="function",Es=(function(){let n=!1;try{let t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n})();var Si={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var ha=class extends je{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=e===void 0?1:e,this.down_=null;let i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=G(i,Si.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=G(i,Si.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(L.TOUCHMOVE,this.boundHandleTouchMove_,Es?{passive:!1}:!1)}emulateClick_(t){let e=new We(at.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new We(at.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;let i=new We(at.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){let e=t,i=e.pointerId;if(e.type==at.POINTERUP||e.type==at.POINTERCANCEL){delete this.trackedTouches_[i];for(let r in this.trackedTouches_)if(this.trackedTouches_[r].target!==e.target){delete this.trackedTouches_[r];break}}else(e.type==at.POINTERDOWN||e.type==at.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);let e=new We(at.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(B),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return t.button===0}handlePointerDown_(t){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(t);let e=new We(at.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),this.dragListenerKeys_.length===0){let i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(G(i,at.POINTERMOVE,this.handlePointerMove_,this),G(i,at.POINTERUP,this.handlePointerUp_,this),G(this.element_,at.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(G(this.element_.getRootNode(),at.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;let e=new We(at.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;let e=!!(this.down_&&this.isMoving_(t));this.dispatchEvent(new We(at.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){let e=this.originalPointerMoveEvent_;(!e||e.defaultPrevented)&&(typeof t.cancelable!="boolean"||t.cancelable===!0)&&t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(B(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(L.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(B(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(B),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},nu=ha;var Xe={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var _t={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"};var O={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function V(n,t){if(!n)throw new Error(t)}var lr=1/0,ca=class{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,ze(this.queuedElements_)}dequeue(){let t=this.elements_,e=this.priorities_,i=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));let r=this.keyFunction_(i);return delete this.queuedElements_[r],i}enqueue(t){V(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");let e=this.priorityFunction_(t);return e!=lr?(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(t){return t*2+1}getRightChildIndex_(t){return t*2+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return this.elements_.length===0}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){let e=this.elements_,i=this.priorities_,r=e.length,s=e[t],o=i[t],a=t;for(;t<r>>1;){let l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=h<r&&i[h]<i[l]?h:l;e[t]=e[c],i[t]=i[c],t=c}e[t]=s,i[t]=o,this.siftDown_(a,t)}siftDown_(t,e){let i=this.elements_,r=this.priorities_,s=i[e],o=r[e];for(;e>t;){let a=this.getParentIndex_(e);if(r[a]>o)i[e]=i[a],r[e]=r[a],e=a;else break}i[e]=s,r[e]=o}reprioritize(){let t=this.priorityFunction_,e=this.elements_,i=this.priorities_,r=0,s=e.length,o,a,l;for(a=0;a<s;++a)o=e[a],l=t(o),l==lr?delete this.queuedElements_[this.keyFunction_(o)]:(i[r]=l,e[r++]=o);e.length=r,i.length=r,this.heapify_()}},ru=ca;var ua=class extends ru{constructor(t,e){super(i=>t.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){let e=super.enqueue(t);return e&&t[0].addEventListener(L.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){let e=t.target,i=e.getState();if(i===O.LOADED||i===O.ERROR||i===O.EMPTY){i!==O.ERROR&&e.removeEventListener(L.CHANGE,this.boundHandleTileChange_);let r=e.getKey();r in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[r],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){let r=this.dequeue()[0],s=r.getKey();r.getState()===O.IDLE&&!(s in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[s]=!0,++this.tilesLoading_,++i,r.load())}}},su=ua;function ou(n,t,e,i,r){if(!n||!(e in n.wantedTiles))return lr;if(!n.wantedTiles[e][t.getKey()])return lr;let s=n.viewState.center,o=i[0]-s[0],a=i[1]-s[1];return 65536*Math.log(r)+Math.sqrt(o*o+a*a)/r}var dt={ANIMATING:0,INTERACTING:1};var ae={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Q(n,t,e){return Math.min(Math.max(n,t),e)}function au(n,t,e,i,r,s){let o=r-e,a=s-i;if(o!==0||a!==0){let l=((n-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=r,i=s):l>0&&(e+=o*l,i+=a*l)}return Ce(n,t,e,i)}function Ce(n,t,e,i){let r=e-n,s=i-t;return r*r+s*s}function lu(n){let t=n.length;for(let i=0;i<t;i++){let r=i,s=Math.abs(n[i][i]);for(let a=i+1;a<t;a++){let l=Math.abs(n[a][i]);l>s&&(s=l,r=a)}if(s===0)return null;let o=n[r];n[r]=n[i],n[i]=o;for(let a=i+1;a<t;a++){let l=-n[a][i]/n[i][i];for(let h=i;h<t+1;h++)i==h?n[a][h]=0:n[a][h]+=l*n[i][h]}}let e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=n[i][t]/n[i][i];for(let r=i-1;r>=0;r--)n[r][t]-=n[r][i]*e[i]}return e}function Cs(n){return n*180/Math.PI}function Re(n){return n*Math.PI/180}function Wt(n,t){let e=n%t;return e*t<0?e+t:e}function bt(n,t,e){return n+e*(t-n)}function Ti(n,t){let e=Math.pow(10,t);return Math.round(n*e)/e}function da(n,t){return Math.round(Ti(n,t))}function vi(n,t){return Math.floor(Ti(n,t))}function Ue(n,t){return Math.ceil(Ti(n,t))}function Rs(n,t,e){if(n>=t&&n<e)return n;let i=e-t;return((n-t)%i+i)%i+t}function fa(n,t,e){return(function(i,r,s,o,a){if(!i)return;if(!r&&!t)return i;let l=t?0:s[0]*r,h=t?0:s[1]*r,c=a?a[0]:0,u=a?a[1]:0,d=n[0]+l/2+c,f=n[2]-l/2+c,g=n[1]+h/2+u,p=n[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>p&&(g=(p+g)/2,p=g);let m=Q(i[0],d,f),_=Q(i[1],g,p);if(o&&e&&r){let y=30*r;m+=-y*Math.log(1+Math.max(0,d-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-f)/y),_+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-p)/y)}return[m,_]})}function hu(n){return n}var yt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function ga(n){let t=ct();for(let e=0,i=n.length;e<i;++e)Qi(t,n[e]);return t}function Fg(n,t,e){let i=Math.min.apply(null,n),r=Math.min.apply(null,t),s=Math.max.apply(null,n),o=Math.max.apply(null,t);return Qt(i,r,s,o,e)}function ri(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function Ss(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function Xt(n,t,e){let i,r;return t<n[0]?i=n[0]-t:n[2]<t?i=t-n[2]:i=0,e<n[1]?r=n[1]-e:n[3]<e?r=e-n[3]:r=0,i*i+r*r}function Jt(n,t){return hr(n,t[0],t[1])}function le(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function hr(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function ws(n,t){let e=n[0],i=n[1],r=n[2],s=n[3],o=t[0],a=t[1],l=yt.UNKNOWN;return o<e?l=l|yt.LEFT:o>r&&(l=l|yt.RIGHT),a<i?l=l|yt.BELOW:a>s&&(l=l|yt.ABOVE),l===yt.UNKNOWN&&(l=yt.INTERSECTING),l}function ct(){return[1/0,1/0,-1/0,-1/0]}function Qt(n,t,e,i,r){return r?(r[0]=n,r[1]=t,r[2]=e,r[3]=i,r):[n,t,e,i]}function si(n){return Qt(1/0,1/0,-1/0,-1/0,n)}function Ts(n,t){let e=n[0],i=n[1];return Qt(e,i,e,i,t)}function En(n,t,e,i,r){let s=si(r);return ma(s,n,t,e,i)}function we(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function vs(n,t){return t[0]<n[0]&&(n[0]=t[0]),t[2]>n[2]&&(n[2]=t[2]),t[1]<n[1]&&(n[1]=t[1]),t[3]>n[3]&&(n[3]=t[3]),n}function Qi(n,t){t[0]<n[0]&&(n[0]=t[0]),t[0]>n[2]&&(n[2]=t[0]),t[1]<n[1]&&(n[1]=t[1]),t[1]>n[3]&&(n[3]=t[1])}function ma(n,t,e,i,r){for(;e<i;e+=r)Dg(n,t[e],t[e+1]);return n}function Dg(n,t,e){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}function Is(n,t){let e;return e=t(Cn(n)),e||(e=t(Rn(n)),e)||(e=t(wn(n)),e)||(e=t(he(n)),e)?e:!1}function cr(n){let t=0;return Yt(n)||(t=W(n)*et(n)),t}function Cn(n){return[n[0],n[1]]}function Rn(n){return[n[2],n[1]]}function St(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function cu(n,t){let e;if(t==="bottom-left")e=Cn(n);else if(t==="bottom-right")e=Rn(n);else if(t==="top-left")e=he(n);else if(t==="top-right")e=wn(n);else throw new Error("Invalid corner");return e}function oi(n,t,e,i,r){let[s,o,a,l,h,c,u,d]=pa(n,t,e,i);return Qt(Math.min(s,a,h,u),Math.min(o,l,c,d),Math.max(s,a,h,u),Math.max(o,l,c,d),r)}function pa(n,t,e,i){let r=t*i[0]/2,s=t*i[1]/2,o=Math.cos(e),a=Math.sin(e),l=r*o,h=r*a,c=s*o,u=s*a,d=n[0],f=n[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function et(n){return n[3]-n[1]}function Ut(n,t,e){let i=e||ct();return lt(n,t)?(n[0]>t[0]?i[0]=n[0]:i[0]=t[0],n[1]>t[1]?i[1]=n[1]:i[1]=t[1],n[2]<t[2]?i[2]=n[2]:i[2]=t[2],n[3]<t[3]?i[3]=n[3]:i[3]=t[3]):si(i),i}function he(n){return[n[0],n[3]]}function wn(n){return[n[2],n[3]]}function W(n){return n[2]-n[0]}function lt(n,t){return n[0]<=t[2]&&n[2]>=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function Yt(n){return n[2]<n[0]||n[3]<n[1]}function uu(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function du(n,t,e){let i=!1,r=ws(n,t),s=ws(n,e);if(r===yt.INTERSECTING||s===yt.INTERSECTING)i=!0;else{let o=n[0],a=n[1],l=n[2],h=n[3],c=t[0],u=t[1],d=e[0],f=e[1],g=(f-u)/(d-c),p,m;s&yt.ABOVE&&!(r&yt.ABOVE)&&(p=d-(f-h)/g,i=p>=o&&p<=l),!i&&s&yt.RIGHT&&!(r&yt.RIGHT)&&(m=f-(d-l)*g,i=m>=a&&m<=h),!i&&s&yt.BELOW&&!(r&yt.BELOW)&&(p=d-(f-a)/g,i=p>=o&&p<=l),!i&&s&yt.LEFT&&!(r&yt.LEFT)&&(m=f-(d-o)*g,i=m>=a&&m<=h)}return i}function fu(n,t,e,i){if(Yt(n))return si(e);let r=[];if(i>1){let a=n[2]-n[0],l=n[3]-n[1];for(let h=0;h<i;++h)r.push(n[0]+a*h/i,n[1],n[2],n[1]+l*h/i,n[2]-a*h/i,n[3],n[0],n[3]-l*h/i)}else r=[n[0],n[1],n[2],n[1],n[2],n[3],n[0],n[3]];t(r,r,2);let s=[],o=[];for(let a=0,l=r.length;a<l;a+=2)s.push(r[a]),o.push(r[a+1]);return Fg(s,o,e)}function _a(n,t){let e=t.getExtent(),i=St(n);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){let r=W(e),o=Math.floor((i[0]-e[0])/r)*r;n[0]-=o,n[2]-=o}return n}function Ms(n,t,e){if(t.canWrapX()){let i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];_a(n,t);let r=W(i);if(W(n)>r&&!e)return[[i[0],n[1],i[2],n[3]]];if(n[0]<i[0])return[[n[0]+r,n[1],i[2],n[3]],[i[0],n[1],n[2],n[3]]];if(n[2]>i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-r,n[3]]]}return[n]}function ur(n,t){let e=(""+n).split("."),i=(""+t).split(".");for(let r=0;r<Math.max(e.length,i.length);r++){let s=parseInt(e[r]||"0",10),o=parseInt(i[r]||"0",10);if(s>o)return 1;if(o>s)return-1}return 0}function gu(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function mu(n){return(function(t){return Ng(t,n)})}function kg(n,t,e){return n?t.replace("{x}",n[0].toFixed(e)).replace("{y}",n[1].toFixed(e)):""}function tn(n,t){let e=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Sn(n,t){let e=Math.cos(t),i=Math.sin(t),r=n[0]*e-n[1]*i,s=n[1]*e+n[0]*i;return n[0]=r,n[1]=s,n}function pu(n,t){return n[0]*=t,n[1]*=t,n}function Ng(n,t){return kg(n,"{x}, {y}",t)}function Tn(n,t){if(t.canWrapX()){let e=W(t.getExtent()),i=_u(n,t,e);i&&(n[0]-=i*e)}return n}function _u(n,t,e){let i=t.getExtent(),r=0;return t.canWrapX()&&(n[0]<i[0]||n[0]>i[2])&&(e=e||W(i),r=Math.floor((n[0]-i[0])/e)),r}function yu(n,t,e){let i=Math.sqrt((t[0]-n[0])*(t[0]-n[0])+(t[1]-n[1])*(t[1]-n[1])),r=[(t[0]-n[0])/i,(t[1]-n[1])/i],s=[-r[1],r[0]],o=Math.sqrt((e[0]-n[0])*(e[0]-n[0])+(e[1]-n[1])*(e[1]-n[1])),a=[(e[0]-n[0])/o,(e[1]-n[1])/o],l=i===0||o===0?0:Math.acos(Q(a[0]*r[0]+a[1]*r[1],-1,1));return l=Math.max(l,1e-5),a[0]*s[0]+a[1]*s[1]>0?l:Math.PI*2-l}function ya(n){return Math.pow(n,3)}function ce(n){return 1-ya(1-n)}function xu(n){return 3*n*n-2*n*n*n}function Eu(n){return n}var Gg=63710088e-1;function xa(n,t,e){e=e||Gg;let i=Re(n[1]),r=Re(t[1]),s=(r-i)/2,o=Re(t[0]-n[0])/2,a=Math.sin(s)*Math.sin(s)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(r);return 2*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}var Cu={info:1,warn:2,error:3,none:4},zg=Cu.info;function bs(...n){zg>Cu.warn||console.warn(...n)}var Se={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var Ea=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Se[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}},vn=Ea;var dr=6378137,In=Math.PI*dr,jg=[-In,-In,In,In],Wg=[-180,-85,180,85],Ls=dr*Math.log(Math.tan(Math.PI/2)),Ii=class extends vn{constructor(t){super({code:t,units:"m",extent:jg,global:!0,worldExtent:Wg,getPointResolution:function(e,i){return e/Math.cosh(i[1]/dr)}})}},Ca=[new Ii("EPSG:3857"),new Ii("EPSG:102100"),new Ii("EPSG:102113"),new Ii("EPSG:900913"),new Ii("http://www.opengis.net/def/crs/EPSG/0/3857"),new Ii("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Ru(n,t,e,i){let r=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(r));for(let s=0;s<r;s+=i){t[s]=In*n[s]/180;let o=dr*Math.log(Math.tan(Math.PI*(+n[s+1]+90)/360));o>Ls?o=Ls:o<-Ls&&(o=-Ls),t[s+1]=o}return t}function wu(n,t,e,i){let r=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(r));for(let s=0;s<r;s+=i)t[s]=180*n[s]/In,t[s+1]=360*Math.atan(Math.exp(n[s+1]/dr))/Math.PI-90;return t}var Xg=6378137,Su=[-180,-90,180,90],Ug=Math.PI*Xg/180,ai=class extends vn{constructor(t,e){super({code:t,units:"degrees",extent:Su,axisOrientation:e,global:!0,metersPerUnit:Ug,worldExtent:Su})}},Ra=[new ai("CRS:84"),new ai("EPSG:4326","neu"),new ai("urn:ogc:def:crs:OGC:1.3:CRS84"),new ai("urn:ogc:def:crs:OGC:2:84"),new ai("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new ai("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new ai("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];var wa={};function Tu(n){return wa[n]||wa[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function vu(n,t){wa[n]=t}var Mn={};function bn(n,t,e){let i=n.getCode(),r=t.getCode();i in Mn||(Mn[i]={}),Mn[i][r]=e}function As(n,t){return n in Mn&&t in Mn[n]?Mn[n][t]:null}var Ps=.9996,ue=.00669438,Fs=ue*ue,Ds=Fs*ue,en=ue/(1-ue),Iu=Math.sqrt(1-ue),Ln=(1-Iu)/(1+Iu),Au=Ln*Ln,Sa=Au*Ln,Ta=Sa*Ln,Pu=Ta*Ln,Ou=1-ue/4-3*Fs/64-5*Ds/256,Yg=3*ue/8+3*Fs/32+45*Ds/1024,Kg=15*Fs/256+45*Ds/1024,Vg=35*Ds/3072,Bg=3/2*Ln-27/32*Sa+269/512*Pu,Zg=21/16*Au-55/32*Ta,Hg=151/96*Sa-417/128*Pu,qg=1097/512*Ta,Os=6378137;function $g(n,t,e){let i=n-5e5,o=(e.north?t:t-1e7)/Ps/(Os*Ou),a=o+Bg*Math.sin(2*o)+Zg*Math.sin(4*o)+Hg*Math.sin(6*o)+qg*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-ue*h,p=Math.sqrt(1-ue*h),m=Os/p,_=(1-ue)/g,y=en*c**2,E=y*y,x=i/(m*Ps),C=x*x,T=C*x,I=T*x,S=I*x,w=S*x,M=a-u/_*(C/2-I/24*(5+3*d+10*y-4*E-9*en))+w/720*(61+90*d+298*y+45*f-252*en-3*E),N=(x-T/6*(1+2*d+y)+S/120*(5-2*y+28*d-3*E+8*en+24*f))/c;return N=Rs(N+Re(Fu(e.number)),-Math.PI,Math.PI),[Cs(N),Cs(M)]}var Mu=-80,bu=84,Jg=-180,Qg=180;function tm(n,t,e){n=Rs(n,Jg,Qg),t<Mu?t=Mu:t>bu&&(t=bu);let i=Re(t),r=Math.sin(i),s=Math.cos(i),o=r/s,a=o*o,l=a*a,h=Re(n),c=Fu(e.number),u=Re(c),d=Os/Math.sqrt(1-ue*r**2),f=en*s**2,g=s*Rs(h-u,-Math.PI,Math.PI),p=g*g,m=p*g,_=m*g,y=_*g,E=y*g,x=Os*(Ou*i-Yg*Math.sin(2*i)+Kg*Math.sin(4*i)-Vg*Math.sin(6*i)),C=Ps*d*(g+m/6*(1-a+f)+y/120*(5-18*a+l+72*f-58*en))+5e5,T=Ps*(x+d*o*(p/2+_/24*(5-a+9*f+4*f**2)+E/720*(61-58*a+l+600*f-330*en)));return e.north||(T+=1e7),[C,T]}function Fu(n){return(n-1)*6-180+3}var em=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Du(n){let t=0;for(let r of em){let s=n.match(r);if(s){t=parseInt(s[1]);break}}if(!t)return null;let e=0,i=!1;return t>32700&&t<32761?e=t-32700:t>32600&&t<32661&&(i=!0,e=t-32600),e?{number:e,north:i}:null}function Lu(n,t){return function(e,i,r,s){let o=e.length;r=r>1?r:2,s=s??r,i||(r>2?i=e.slice():i=new Array(o));for(let a=0;a<o;a+=s){let l=e[a],h=e[a+1],c=n(l,h,t);i[a]=c[0],i[a+1]=c[1]}return i}}function ku(n){return Du(n)?new vn({code:n,units:"m"}):null}function Nu(n){let t=Du(n.getCode());return t?{forward:Lu(tm,t),inverse:Lu($g,t)}:null}var im=[Nu],nm=[ku];var Ia=!0;function ba(n){Ia=!(n===void 0?!0:n)}function La(n,t){if(t!==void 0){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];t=t}else t=n.slice();return t}function zu(n,t){if(t!==void 0&&n!==t){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];n=t}return n}function Ma(n){vu(n.getCode(),n),bn(n,n,La)}function rm(n){n.forEach(Ma)}function q(n){if(typeof n!="string")return n;let t=Tu(n);if(t)return t;for(let e of nm){let i=e(n);if(i)return i}return null}function An(n,t,e,i){n=q(n);let r,s=n.getPointResolutionFunc();if(s){if(r=s(t,e),i&&i!==n.getUnits()){let o=n.getMetersPerUnit();o&&(r=r*o/Se[i])}}else{let o=n.getUnits();if(o=="degrees"&&!i||i=="degrees")r=t;else{let a=Ye(n,q("EPSG:4326"));if(!a&&o!=="degrees")r=t*n.getMetersPerUnit();else{let h=[e[0]-t/2,e[1],e[0]+t/2,e[1],e[0],e[1]-t/2,e[0],e[1]+t/2];h=a(h,h,2);let c=xa(h.slice(0,2),h.slice(2,4)),u=xa(h.slice(4,6),h.slice(6,8));r=(c+u)/2}let l=i?Se[i]:n.getMetersPerUnit();l!==void 0&&(r/=l)}}return r}function Gu(n){rm(n),n.forEach(function(t){n.forEach(function(e){t!==e&&bn(t,e,La)})})}function sm(n,t,e,i){n.forEach(function(r){t.forEach(function(s){bn(r,s,e),bn(s,r,i)})})}function ks(n,t){return n?typeof n=="string"?q(n):n:q(t)}function ju(n){return(function(t,e,i,r){let s=t.length;i=i!==void 0?i:2,r=r??i,e=e!==void 0?e:new Array(s);for(let o=0;o<s;o+=r){let a=n(t.slice(o,o+i)),l=a.length;for(let h=0,c=r;h<c;++h)e[o+h]=h>=l?t[o+h]:a[h]}return e})}function nn(n,t){return ba(),de(n,"EPSG:4326",t!==void 0?t:"EPSG:3857")}function Wu(n,t){let e=de(n,t!==void 0?t:"EPSG:3857","EPSG:4326"),i=e[0];return(i<-180||i>180)&&(e[0]=Wt(i+180,360)-180),e}function ve(n,t){if(n===t)return!0;let e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||Ye(n,t)===La)&&e}function Ye(n,t){let e=n.getCode(),i=t.getCode(),r=As(e,i);if(r)return r;let s=null,o=null;for(let l of im)s||(s=l(n)),o||(o=l(t));if(!s&&!o)return null;let a="EPSG:4326";if(o)if(s)r=va(s.inverse,o.forward);else{let l=As(e,a);l&&(r=va(l,o.forward))}else{let l=As(a,i);l&&(r=va(s.inverse,l))}return r&&(Ma(n),Ma(t),bn(n,t,r)),r}function va(n,t){return function(e,i,r,s){return i=n(e,i,r,s),t(i,i,r,s)}}function li(n,t){let e=q(n),i=q(t);return Ye(e,i)}function de(n,t,e){let i=li(t,e);if(!i){let r=q(t).getCode(),s=q(e).getCode();throw new Error(`No transform available between ${r} and ${s}`)}return i(n,void 0,n.length)}function fr(n,t,e,i){let r=li(t,e);return fu(n,r,void 0,i)}var Te=null;function hi(){return Te}function gr(n,t){return Te?de(n,t,Te):n}function Ie(n,t){return Te?de(n,Te,t):(Ia&&!tn(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(Ia=!1,bs("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n)}function Mi(n,t){return Te?fr(n,t,Te):n}function Gt(n,t){return Te?fr(n,Te,t):n}function Xu(n,t){if(!Te)return n;let e=q(t).getMetersPerUnit(),i=Te.getMetersPerUnit();return e&&i?n*e/i:n}function om(){Gu(Ca),Gu(Ra),sm(Ra,Ca,Ru,wu)}om();var wx=new Array(6);function Tt(){return[1,0,0,1,0,0]}function Uu(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n}function ht(n,t){let e=t[0],i=t[1];return t[0]=n[0]*e+n[2]*i+n[4],t[1]=n[1]*e+n[3]*i+n[5],t}function Et(n,t,e,i,r,s,o,a){let l=Math.sin(s),h=Math.cos(s);return n[0]=i*h,n[1]=r*l,n[2]=-i*l,n[3]=r*h,n[4]=o*i*h-a*i*l+t,n[5]=o*r*l+a*r*h+e,n}function Gs(n,t){let e=am(t);V(e!==0,"Transformation matrix cannot be inverted");let i=t[0],r=t[1],s=t[2],o=t[3],a=t[4],l=t[5];return n[0]=o/e,n[1]=-r/e,n[2]=-s/e,n[3]=i/e,n[4]=(s*l-o*a)/e,n[5]=-(i*l-r*a)/e,n}function am(n){return n[0]*n[3]-n[1]*n[2]}var lm=[1e5,1e5,1e5,1e5,2,2];function Yu(n){return"matrix("+n.join(", ")+")"}function Ns(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function Ku(n,t){let e=Ns(n),i=Ns(t);for(let r=0;r<6;++r)if(Math.round((e[r]-i[r])*lm[r])!==0)return!1;return!0}function Kt(n,t,e,i,r,s,o){s=s||[],o=o||2;let a=0;for(let l=t;l<e;l+=i){let h=n[l],c=n[l+1];s[a++]=r[0]*h+r[2]*c+r[4],s[a++]=r[1]*h+r[3]*c+r[5];for(let u=2;u<o;u++)s[a++]=n[l+u]}return s&&s.length!=a&&(s.length=a),s}function zs(n,t,e,i,r,s,o){o=o||[];let a=Math.cos(r),l=Math.sin(r),h=s[0],c=s[1],u=0;for(let d=t;d<e;d+=i){let f=n[d]-h,g=n[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let p=d+2;p<d+i;++p)o[u++]=n[p]}return o&&o.length!=u&&(o.length=u),o}function Vu(n,t,e,i,r,s,o,a){a=a||[];let l=o[0],h=o[1],c=0;for(let u=t;u<e;u+=i){let d=n[u]-l,f=n[u+1]-h;a[c++]=l+r*d,a[c++]=h+s*f;for(let g=u+2;g<u+i;++g)a[c++]=n[g]}return a&&a.length!=c&&(a.length=c),a}function Bu(n,t,e,i,r,s,o){o=o||[];let a=0;for(let l=t;l<e;l+=i){o[a++]=n[l]+r,o[a++]=n[l+1]+s;for(let h=l+2;h<l+i;++h)o[a++]=n[h]}return o&&o.length!=a&&(o.length=a),o}var Zu=Tt(),hm=[NaN,NaN],Aa=class extends pt{constructor(){super(),this.extent_=ct(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=ms((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);let r=this.clone();return r.applyTransform(i),r.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return F()}closestPointXY(t,e,i,r){return F()}containsXY(t,e){return this.closestPointXY(t,e,hm,Number.MIN_VALUE)===0}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return F()}getExtent(t){if(this.extentRevision_!=this.getRevision()){let e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&si(e),this.extentRevision_=this.getRevision()}return uu(this.extent_,t)}rotate(t,e){F()}scale(t,e,i){F()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return F()}getType(){return F()}applyTransform(t){F()}intersectsExtent(t){return F()}translate(t,e){F()}transform(t,e){let i=q(t),r=i.getUnits()=="tile-pixels"?function(s,o,a){let l=i.getExtent(),h=i.getWorldExtent(),c=et(h)/et(l);Et(Zu,h[0],h[3],c,-c,0,0,0);let u=Kt(s,0,s.length,a,Zu,o),d=li(i,e);return d?d(u,u,a):u}:li(i,e);return this.applyTransform(r),this}},js=Aa;var Pa=class extends js{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return En(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return F()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=Hu(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){F()}setLayout(t,e,i){let r;if(t)r=Hu(t);else{for(let s=0;s<i;++s){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}r=e.length,t=bi(r)}this.layout=t,this.stride=r}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){let i=this.getFlatCoordinates();if(i){let r=this.getStride();zs(i,0,i.length,r,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=St(this.getExtent()));let r=this.getFlatCoordinates();if(r){let s=this.getStride();Vu(r,0,r.length,s,t,e,i,r),this.changed()}}translate(t,e){let i=this.getFlatCoordinates();if(i){let r=this.getStride();Bu(i,0,i.length,r,t,e,i),this.changed()}}};function bi(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function Hu(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function qu(n,t,e){let i=n.getFlatCoordinates();if(!i)return null;let r=n.getStride();return Kt(i,0,i.length,r,t,e)}var Vt=Pa;function Oa(n,t,e,i){let r=0,s=n[e-i],o=n[e-i+1],a=0,l=0;for(;t<e;t+=i){let h=n[t]-s,c=n[t+1]-o;r+=l*h-a*c,a=h,l=c}return r/2}function Fa(n,t,e,i){let r=0;for(let s=0,o=e.length;s<o;++s){let a=e[s];r+=Oa(n,t,a,i),t=a}return r}function $u(n,t,e,i){let r=0;for(let s=0,o=e.length;s<o;++s){let a=e[s];r+=Fa(n,t,a,i),t=a[a.length-1]}return r}function Ju(n,t,e,i,r,s,o){let a=n[t],l=n[t+1],h=n[e]-a,c=n[e+1]-l,u;if(h===0&&c===0)u=t;else{let d=((r-a)*h+(s-l)*c)/(h*h+c*c);if(d>1)u=e;else if(d>0){for(let f=0;f<i;++f)o[f]=bt(n[t+f],n[e+f],d);o.length=i;return}else u=t}for(let d=0;d<i;++d)o[d]=n[u+d];o.length=i}function mr(n,t,e,i,r){let s=n[t],o=n[t+1];for(t+=i;t<e;t+=i){let a=n[t],l=n[t+1],h=Ce(s,o,a,l);h>r&&(r=h),s=a,o=l}return r}function pr(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];r=mr(n,t,a,i,r),t=a}return r}function Qu(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];r=pr(n,t,a,i,r),t=a[a.length-1]}return r}function _r(n,t,e,i,r,s,o,a,l,h,c){if(t==e)return h;let u,d;if(r===0){if(d=Ce(o,a,n[t],n[t+1]),d<h){for(u=0;u<i;++u)l[u]=n[t+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=t+i;for(;f<e;)if(Ju(n,f-i,f,i,o,a,c),d=Ce(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/r|0,1);if(s&&(Ju(n,e-i,t,i,o,a,c),d=Ce(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function yr(n,t,e,i,r,s,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){let f=e[u];h=_r(n,t,f,i,r,s,o,a,l,h,c),t=f}return h}function td(n,t,e,i,r,s,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){let f=e[u];h=yr(n,t,f,i,r,s,o,a,l,h,c),t=f[f.length-1]}return h}function ed(n,t,e,i){for(let r=0,s=e.length;r<s;++r)n[t++]=e[r];return t}function rn(n,t,e,i){for(let r=0,s=e.length;r<s;++r){let o=e[r];for(let a=0;a<i;++a)n[t++]=o[a]}return t}function Li(n,t,e,i,r){r=r||[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=rn(n,t,e[o],i);r[s++]=l,t=l}return r.length=s,r}function Ws(n,t,e,i,r){r=r||[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=Li(n,t,e[o],i,r[s]);l.length===0&&(l[0]=t),r[s++]=l,t=l[l.length-1]}return r.length=s,r}function fe(n,t,e,i,r){r=r!==void 0?r:[];let s=0;for(let o=t;o<e;o+=i)r[s++]=n.slice(o,o+i);return r.length=s,r}function Ai(n,t,e,i,r){r=r!==void 0?r:[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=e[o];r[s++]=fe(n,t,l,i,r[s]),t=l}return r.length=s,r}function xr(n,t,e,i,r){r=r!==void 0?r:[];let s=0;for(let o=0,a=e.length;o<a;++o){let l=e[o];r[s++]=l.length===1&&l[0]===t?[]:Ai(n,t,l,i,r[s]),t=l[l.length-1]}return r.length=s,r}function sn(n,t,e,i,r,s,o){let a=(e-t)/i;if(a<3){for(;t<e;t+=i)s[o++]=n[t],s[o++]=n[t+1];return o}let l=new Array(a);l[0]=1,l[a-1]=1;let h=[t,e-i],c=0;for(;h.length>0;){let u=h.pop(),d=h.pop(),f=0,g=n[d],p=n[d+1],m=n[u],_=n[u+1];for(let y=d+i;y<u;y+=i){let E=n[y],x=n[y+1],C=au(E,x,g,p,m,_);C>f&&(c=y,f=C)}f>r&&(l[(c-t)/i]=1,d+i<c&&h.push(d,c),c+i<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(s[o++]=n[t+u*i],s[o++]=n[t+u*i+1]);return o}function Xs(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];o=sn(n,t,c,i,r,s,o),a.push(o),t=c}return o}function Pi(n,t){return t*Math.round(n/t)}function cm(n,t,e,i,r,s,o){if(t==e)return o;let a=Pi(n[t],r),l=Pi(n[t+1],r);t+=i,s[o++]=a,s[o++]=l;let h,c;do if(h=Pi(n[t],r),c=Pi(n[t+1],r),t+=i,t==e)return s[o++]=h,s[o++]=c,o;while(h==a&&c==l);for(;t<e;){let u=Pi(n[t],r),d=Pi(n[t+1],r);if(t+=i,u==h&&d==c)continue;let f=h-a,g=c-l,p=u-a,m=d-l;if(f*m==g*p&&(f<0&&p<f||f==p||f>0&&p>f)&&(g<0&&m<g||g==m||g>0&&m>g)){h=u,c=d;continue}s[o++]=h,s[o++]=c,a=h,l=c,h=u,c=d}return s[o++]=h,s[o++]=c,o}function Er(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l];o=cm(n,t,c,i,r,s,o),a.push(o),t=c}return o}function id(n,t,e,i,r,s,o,a){for(let l=0,h=e.length;l<h;++l){let c=e[l],u=[];o=Er(n,t,c,i,r,s,o,u),a.push(u),t=c[c.length-1]}return o}var Da=class n extends Vt{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}clone(){return new n(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,r){return r<Xt(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(mr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),_r(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,r))}getArea(){return Oa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return fe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){let e=[];return e.length=sn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new n(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=rn(this.flatCoordinates,0,t,this.stride),this.changed()}},ka=Da;var Na=class n extends Vt{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){let t=new n(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,r){let s=this.flatCoordinates,o=Ce(t,e,s[0],s[1]);if(o<r){let a=this.stride;for(let l=0;l<a;++l)i[l]=s[l];return i.length=a,o}return r}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return Ts(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return hr(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ed(this.flatCoordinates,0,t,this.stride),this.changed()}},Oi=Na;function nd(n,t,e,i,r){return!Is(r,function(o){return!Fi(n,t,e,i,o[0],o[1])})}function Fi(n,t,e,i,r,s){let o=0,a=n[e-i],l=n[e-i+1];for(;t<e;t+=i){let h=n[t],c=n[t+1];l<=s?c>s&&(h-a)*(s-l)-(r-a)*(c-l)>0&&o++:c<=s&&(h-a)*(s-l)-(r-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function Cr(n,t,e,i,r,s){if(e.length===0||!Fi(n,t,e[0],i,r,s))return!1;for(let o=1,a=e.length;o<a;++o)if(Fi(n,e[o-1],e[o],i,r,s))return!1;return!0}function rd(n,t,e,i,r,s){if(e.length===0)return!1;for(let o=0,a=e.length;o<a;++o){let l=e[o];if(Cr(n,t,l,i,r,s))return!0;t=l[l.length-1]}return!1}function Rr(n,t,e,i,r,s,o){let a,l,h,c,u,d,f,g=r[s+1],p=[];for(let y=0,E=e.length;y<E;++y){let x=e[y];for(c=n[x-i],d=n[x-i+1],a=t;a<x;a+=i)u=n[a],f=n[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,p.push(h)),c=u,d=f}let m=NaN,_=-1/0;for(p.sort(jt),c=p[0],a=1,l=p.length;a<l;++a){u=p[a];let y=Math.abs(u-c);y>_&&(h=(c+u)/2,Cr(n,t,e,i,h,g)&&(m=h,_=y)),c=u}return isNaN(m)&&(m=r[s]),o?(o.push(m,g,_),o):[m,g,_]}function Us(n,t,e,i,r){let s=[];for(let o=0,a=e.length;o<a;++o){let l=e[o];s=Rr(n,t,l,i,r,2*o,s),t=l[l.length-1]}return s}function Ys(n,t,e,i,r){let s;for(t+=i;t<e;t+=i)if(s=r(n.slice(t-i,t),n.slice(t,t+i)),s)return s;return!1}function wr(n,t,e,i,r,s){return s=s??ma(ct(),n,t,e,i),lt(r,s)?s[0]>=r[0]&&s[2]<=r[2]||s[1]>=r[1]&&s[3]<=r[3]?!0:Ys(n,t,e,i,function(o,a){return du(r,o,a)}):!1}function sd(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){if(wr(n,t,e[s],i,r))return!0;t=e[s]}return!1}function Ga(n,t,e,i,r){return!!(wr(n,t,e,i,r)||Fi(n,t,e,i,r[0],r[1])||Fi(n,t,e,i,r[0],r[3])||Fi(n,t,e,i,r[2],r[1])||Fi(n,t,e,i,r[2],r[3]))}function za(n,t,e,i,r){if(!Ga(n,t,e[0],i,r))return!1;if(e.length===1)return!0;for(let s=1,o=e.length;s<o;++s)if(nd(n,e[s-1],e[s],i,r)&&!wr(n,e[s-1],e[s],i,r))return!1;return!0}function od(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];if(za(n,t,a,i,r))return!0;t=a[a.length-1]}return!1}function ad(n,t,e,i){for(;t<e-i;){for(let r=0;r<i;++r){let s=n[t+r];n[t+r]=n[e-i+r],n[e-i+r]=s}t+=i,e-=i}}function ja(n,t,e,i){let r=0,s=n[e-i],o=n[e-i+1];for(;t<e;t+=i){let a=n[t],l=n[t+1];r+=(a-s)*(l+o),s=a,o=l}return r===0?void 0:r>0}function Sr(n,t,e,i,r){r=r!==void 0?r:!1;for(let s=0,o=e.length;s<o;++s){let a=e[s],l=ja(n,t,a,i);if(s===0){if(r&&l||!r&&!l)return!1}else if(r&&!l||!r&&l)return!1;t=a}return!0}function Ks(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s){let a=e[s];if(!Sr(n,t,a,i,r))return!1;a.length&&(t=a[a.length-1])}return!0}function Pn(n,t,e,i,r){r=r!==void 0?r:!1;for(let s=0,o=e.length;s<o;++s){let a=e[s],l=ja(n,t,a,i);(s===0?r&&l||!r&&!l:r&&!l||!r&&l)&&ad(n,t,a,i),t=a}return t}function Tr(n,t,e,i,r){for(let s=0,o=e.length;s<o;++s)t=Pn(n,t,e[s],i,r);return t}function ld(n,t){let e=[],i=0,r=0,s;for(let o=0,a=t.length;o<a;++o){let l=t[o],h=ja(n,i,l,2);if(s===void 0&&(s=h),h===s)e.push(t.slice(r,o+1));else{if(e.length===0)continue;e[e.length-1].push(t[r])}r=o+1,i=l}return e}var Vs=class n extends Vt{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,e!==void 0&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?It(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let t=new n(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,r){return r<Xt(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(pr(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),yr(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return Cr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return Fa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Pn(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Ai(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let t=St(this.getExtent());this.flatInteriorPoint_=Rr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new Oi(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new ka(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){let t=this.layout,e=this.flatCoordinates,i=this.ends_,r=[],s=0;for(let o=0,a=i.length;o<a;++o){let l=i[o],h=new ka(e.slice(s,l),t);r.push(h),s=l}return r}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;Sr(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Pn(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=Er(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new n(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return za(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);let i=Li(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}},Di=Vs;function Wa(n){if(Yt(n))throw new Error("Cannot create polygon from empty extent");let t=n[0],e=n[1],i=n[2],r=n[3],s=[t,e,t,r,i,r,i,e,t,e];return new Vs(s,"XY",[s.length])}function Xa(n,t,e,i){let r=W(t)/e[0],s=et(t)/e[1];return i?Math.min(n,Math.max(r,s)):Math.min(n,Math.min(r,s))}function Ua(n,t,e){let i=Math.min(n,t),r=50;return i*=Math.log(1+r*Math.max(0,n/t-1))/r+1,e&&(i=Math.max(i,e),i/=Math.log(1+r*Math.max(0,e/n-1))/r+1),Q(i,e/2,t*2)}function hd(n,t,e,i){return t=t!==void 0?t:!0,(function(r,s,o,a){if(r!==void 0){let l=n[0],h=n[n.length-1],c=e?Xa(l,e,o,i):l;if(a)return t?Ua(r,c,h):Q(r,h,c);let u=Math.min(c,r),d=Math.floor(Ri(n,u,s));return n[d]>c&&d<n.length-1?n[d+1]:n[d]}})}function cd(n,t,e,i,r,s){return i=i!==void 0?i:!0,e=e!==void 0?e:0,(function(o,a,l,h){if(o!==void 0){let c=r?Xa(t,r,l,s):t;if(h)return i?Ua(o,c,e):Q(o,e,c);let u=1e-9,d=Math.ceil(Math.log(t/c)/Math.log(n)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),p=Math.floor(Math.log(t/g)/Math.log(n)+f),m=Math.max(d,p),_=t/Math.pow(n,m);return Q(_,e,c)}})}function Ya(n,t,e,i,r){return e=e!==void 0?e:!0,(function(s,o,a,l){if(s!==void 0){let h=i?Xa(n,i,a,r):n;return!e||!l?Q(s,t,h):Ua(s,h,t)}})}function On(n){if(n!==void 0)return 0}function Ka(n){if(n!==void 0)return n}function ud(n){let t=2*Math.PI/n;return(function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e})}function dd(n){let t=n===void 0?Re(5):n;return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}var Va=0,Za=class extends pt{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=ks(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&ba(),t.center&&(t.center=Ie(t.center,this.projection_)),t.extent&&(t.extent=Gt(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){let e=Object.assign({},t);for(let a in ae)delete e[a];this.setProperties(e,!0);let i=dm(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;let r=um(t),s=i.constraint,o=fm(t);this.constraints_={center:r,resolution:s,rotation:o},this.setRotation(t.rotation!==void 0?t.rotation:0),this.setCenterInternal(t.center!==void 0?t.center:null),t.resolution!==void 0?this.setResolution(t.resolution):t.zoom!==void 0&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;let i=this.getCenterInternal();if(i){let r=t||[0,0,0,0];e=e||[0,0,0,0];let s=this.getResolution(),o=s/2*(r[3]-e[3]+e[1]-r[1]),a=s/2*(r[0]-e[0]+e[2]-r[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(t){let e=this.getProperties();return e.resolution!==void 0?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);let e=new Array(arguments.length);for(let i=0;i<e.length;++i){let r=arguments[i];r.center&&(r=Object.assign({},r),r.center=Ie(r.center,this.getProjection())),r.anchor&&(r=Object.assign({},r),r.anchor=Ie(r.anchor,this.getProjection())),e[i]=r}this.animateInternal.apply(this,e)}animateInternal(t){let e=arguments.length,i;e>1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let r=0;for(;r<e&&!this.isDef();++r){let c=arguments[r];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(r===e){i&&Bs(i,!0);return}let s=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_,h=[];for(;r<e;++r){let c=arguments[r],u={start:s,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||xu,callback:i};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;let d=Wt(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}gm(u)?u.complete=!0:s+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(dt.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[dt.ANIMATING]>0}getInteracting(){return this.hints_[dt.INTERACTING]>0}cancelAnimations(){this.setHint(dt.ANIMATING,-this.hints_[dt.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){let r=this.animations_[e];if(r[0].callback&&Bs(r[0].callback,!1),!t)for(let s=0,o=r.length;s<o;++s){let a=r[s];if(!a.complete){t=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;let t=Date.now(),e=!1;for(let i=this.animations_.length-1;i>=0;--i){let r=this.animations_[i],s=!0;for(let o=0,a=r.length;o<a;++o){let l=r[o];if(l.complete)continue;let h=t-l.start,c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):s=!1;let u=l.easing(c);if(l.sourceCenter){let d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],p=l.targetCenter[1];this.nextCenter_=l.targetCenter;let m=d+u*(g-d),_=f+u*(p-f);this.targetCenter_=[m,_]}if(l.sourceResolution&&l.targetResolution){let d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){let f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){let d=u===1?Wt(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){let f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(s){this.animations_[i]=null,this.setHint(dt.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let o=r[0].callback;o&&Bs(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i,r=this.getCenterInternal();return r!==void 0&&(i=[r[0]-e[0],r[1]-e[1]],Sn(i,t-this.getRotation()),gu(i,e)),i}calculateCenterZoom(t,e){let i,r=this.getCenterInternal(),s=this.getResolution();if(r!==void 0&&s!==void 0){let o=e[0]-t*(e[0]-r[0])/s,a=e[1]-t*(e[1]-r[1])/s;i=[o,a]}return i}getViewportSize_(t){let e=this.viewportSize_;if(t){let i=e[0],r=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(r*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(r*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let t=this.getCenterInternal();return t&&gr(t,this.getProjection())}getCenterInternal(){return this.get(ae.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){let e=this.calculateExtentInternal(t);return Mi(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();let e=this.getCenterInternal();V(e,"The view center is not defined");let i=this.getResolution();V(i!==void 0,"The view resolution is not defined");let r=this.getRotation();return V(r!==void 0,"The view rotation is not defined"),oi(e,i,r,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(ae.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Gt(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();let i=W(t)/e[0],r=et(t)/e[1];return Math.max(i,r)}getResolutionForValueFunction(t){t=t||2;let e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(e/i)/Math.log(t);return(function(s){return e/Math.pow(t,s*r)})}getRotation(){return this.get(ae.ROTATION)}getValueForResolutionFunction(t){let e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),r=this.minResolution_,s=Math.log(i/r)/e;return(function(o){return Math.log(i/o)/e/s})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t),i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){let t=this.getProjection(),e=this.getResolution(),i=this.getRotation(),r=this.getCenterInternal(),s=this.padding_;if(s){let o=this.getViewportSizeMinusPadding_();r=Ba(r,this.getViewportSize_(),[o[0]/2+s[3],o[1]/2+s[0]],e,i)}return{center:r.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t,e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,r;if(this.resolutions_){let s=Ri(this.resolutions_,t,1);e=s,i=this.resolutions_[s],s==this.resolutions_.length-1?r=2:r=i/this.resolutions_[s+1]}else i=this.maxResolution_,r=this.zoomFactor_;return e+Math.log(i/t)/Math.log(r)}getResolutionForZoom(t){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];let e=Q(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,Q(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(V(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){V(!Yt(t),"Cannot fit empty extent provided as `geometry`");let r=Gt(t,this.getProjection());i=Wa(r)}else if(t.getType()==="Circle"){let r=Gt(t.getExtent(),this.getProjection());i=Wa(r),i.rotate(this.getRotation(),St(r))}else{let r=hi();r?i=t.clone().transform(r,this.getProjection()):i=t}this.fitInternal(i,e)}rotatedExtentForGeometry(t){let e=this.getRotation(),i=Math.cos(e),r=Math.sin(-e),s=t.getFlatCoordinates(),o=t.getStride(),a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=s.length;u<d;u+=o){let f=s[u]*i-s[u+1]*r,g=s[u]*r+s[u+1]*i;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(t,e){e=e||{};let i=e.size;i||(i=this.getViewportSizeMinusPadding_());let r=e.padding!==void 0?e.padding:[0,0,0,0],s=e.nearest!==void 0?e.nearest:!1,o;e.minResolution!==void 0?o=e.minResolution:e.maxZoom!==void 0?o=this.getResolutionForZoom(e.maxZoom):o=0;let a=this.rotatedExtentForGeometry(t),l=this.getResolutionForExtentInternal(a,[i[0]-r[1]-r[3],i[1]-r[0]-r[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,s?0:1);let h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=St(a);d[0]+=(r[1]-r[3])/2*l,d[1]+=(r[0]-r[2])/2*l;let f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,p=this.getConstrainedCenter([f,g],l),m=e.callback?e.callback:ni;e.duration!==void 0?this.animateInternal({resolution:l,center:p,duration:e.duration,easing:e.easing},m):(this.targetResolution_=l,this.targetCenter_=p,this.applyTargetState_(!1,!0),Bs(m,!0))}centerOn(t,e,i){this.centerOnInternal(Ie(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(Ba(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,r){let s,o=this.padding_;if(o&&t){let a=this.getViewportSizeMinusPadding_(-i),l=Ba(t,r,[a[0]/2+o[3],a[1]/2+o[0]],e,i);s=[t[0]-l[0],t[1]-l[1]]}return s}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){let e=gr(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){let e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&Ie(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){let i=this.getAnimating()||this.getInteracting(),r=this.getViewportSize_(this.getRotation()),s=this.constraints_.resolution(this.targetResolution_*t,0,r,i);e&&(this.targetCenter_=this.calculateCenterZoom(s,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=Ie(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){let i=this.getAnimating()||this.getInteracting(),r=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(r,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&Ie(t,this.getProjection()))}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){let i=this.getAnimating()||this.getInteracting()||e,r=this.constraints_.rotation(this.targetRotation_,i),s=this.getViewportSize_(r),o=this.constraints_.resolution(this.targetResolution_,0,s,i),a=this.constraints_.center(this.targetCenter_,o,s,i,this.calculateCenterShift(this.targetCenter_,o,r,s));this.get(ae.ROTATION)!==r&&this.set(ae.ROTATION,r),this.get(ae.RESOLUTION)!==o&&(this.set(ae.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(ae.CENTER)||!tn(this.get(ae.CENTER),a))&&this.set(ae.CENTER,a),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=t!==void 0?t:200;let r=e||0,s=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(s),a=this.constraints_.resolution(this.targetResolution_,r,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,s,o));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=s,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==s||!this.getCenterInternal()||!tn(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:s,center:l,resolution:a,duration:t,easing:ce,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(dt.INTERACTING,1)}endInteraction(t,e,i){i=i&&Ie(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(dt.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){let i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){let i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;let i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}};function Bs(n,t){setTimeout(function(){n(t)},0)}function um(n){if(n.extent!==void 0){let e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return fa(n.extent,n.constrainOnlyCenter,e)}let t=ks(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){let e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,fa(e,!1,!1)}return hu}function dm(n){let t,e,i,o=n.minZoom!==void 0?n.minZoom:Va,a=n.maxZoom!==void 0?n.maxZoom:28,l=n.zoomFactor!==void 0?n.zoomFactor:2,h=n.multiWorld!==void 0?n.multiWorld:!1,c=n.smoothResolutionConstraint!==void 0?n.smoothResolutionConstraint:!0,u=n.showFullExtent!==void 0?n.showFullExtent:!1,d=ks(n.projection,"EPSG:3857"),f=d.getExtent(),g=n.constrainOnlyCenter,p=n.extent;if(!h&&!p&&d.isGlobal()&&(g=!1,p=f),n.resolutions!==void 0){let m=n.resolutions;e=m[o],i=m[a]!==void 0?m[a]:m[m.length-1],n.constrainResolution?t=hd(m,c,!g&&p,u):t=Ya(e,i,c,!g&&p,u)}else{let _=(f?Math.max(W(f),et(f)):360*Se.degrees/d.getMetersPerUnit())/256/Math.pow(2,Va),y=_/Math.pow(2,28-Va);e=n.maxResolution,e!==void 0?o=0:e=_/Math.pow(l,o),i=n.minResolution,i===void 0&&(n.maxZoom!==void 0?n.maxResolution!==void 0?i=e/Math.pow(l,a):i=_/Math.pow(l,a):i=y),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),n.constrainResolution?t=cd(l,e,i,c,!g&&p,u):t=Ya(e,i,c,!g&&p,u)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function fm(n){if(n.enableRotation!==void 0?n.enableRotation:!0){let e=n.constrainRotation;return e===void 0||e===!0?dd():e===!1?Ka:typeof e=="number"?ud(e):Ka}return On}function gm(n){return!(n.sourceCenter&&n.targetCenter&&!tn(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function Ba(n,t,e,i,r){let s=Math.cos(-r),o=Math.sin(-r),a=n[0]*s-n[1]*o,l=n[1]*s+n[0]*o;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,o=-o;let h=a*s-l*o,c=l*s+a*o;return[h,c]}var Bt=Za;var vr="ol-hidden";var ge="ol-unselectable",Ha="ol-unsupported",ki="ol-control",qa="ol-collapsed",mm=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),gd=["style","variant","weight","size","lineHeight","family"],Zs={normal:400,bold:700},Hs=function(n){let t=n.match(mm);if(!t)return null;let e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,r=gd.length;i<r;++i){let s=t[i+1];s!==void 0&&(e[gd[i]]=typeof s=="string"?s.trim():s)}return isNaN(Number(e.weight))&&e.weight in Zs&&(e.weight=Zs[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e};function nt(n,t,e,i){let r;return e&&e.length?r=e.shift():xt?r=new class extends OffscreenCanvas{style={}}(n??300,t??150):r=document.createElement("canvas"),n&&(r.width=n),t&&(r.height=t),r.getContext("2d",i)}var $a;function Fn(){return $a||($a=nt(1,1)),$a}function on(n){let t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function Dn(n,t){let e=t.parentNode;e&&e.replaceChild(n,t)}function md(n){for(;n.lastChild;)n.lastChild.remove()}function pd(n,t){let e=n.childNodes;for(let i=0;;++i){let r=e[i],s=t[i];if(!r&&!s)break;if(r!==s){if(!r){n.appendChild(s);continue}if(!s){n.removeChild(r),--i;continue}n.insertBefore(s,r)}}}function qs(){return new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){let e=this.childNodes.indexOf(t);if(e===-1)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){let i=this.childNodes.indexOf(e);if(i===-1)throw new Error("Reference node not found");return this.childNodes.splice(i,0,t),t},style:{}},{get(t,e,i){return e==="firstElementChild"?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,i)}})}function Me(n){return typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas}var Ja=class extends pt{constructor(t){super();let e=t.element;e&&!t.target&&!e.style.pointerEvents&&(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let e=0,i=this.listenerKeys.length;e<i;++e)B(this.listenerKeys[e]);if(this.listenerKeys.length=0,this.map_=t,t){let e=this.target_??t.getOverlayContainerStopEvent();this.element&&e.appendChild(this.element),this.render!==ni&&this.listenerKeys.push(G(t,Xe.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}},me=Ja;var Qa=class extends me{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=t.collapsed!==void 0?t.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=t.collapsible!==void 0,this.collapsible_=t.collapsible!==void 0?t.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;let e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",r=t.expandClassName!==void 0?t.expandClassName:e+"-expand",s=t.collapseLabel!==void 0?t.collapseLabel:"\u203A",o=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof s=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=s,this.collapseLabel_.className=o):this.collapseLabel_=s;let a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=r):this.label_=a;let l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(L.CLICK,this.handleClick_.bind(this),!1);let h=e+" "+ge+" "+ki+(this.collapsed_&&this.collapsible_?" "+qa:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){let e=this.getMap().getAllLayers(),i=new Set(e.flatMap(r=>r.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(r=>i.add(r)):i.add(this.attributions_)),!this.overrideCollapsible_){let r=!e.some(s=>s.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(r)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}let e=await Promise.all(this.collectSourceAttributions_(t).map(r=>ps(()=>r))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Ot(e,this.renderedAttributions_)){md(this.ulElement_);for(let r=0,s=e.length;r<s;++r){let o=document.createElement("li");o.innerHTML=e[r],this.ulElement_.appendChild(o)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(qa),this.collapsed_?Dn(this.collapseLabel_,this.label_):Dn(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,!(!this.collapsible_||this.collapsed_===t)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}},Ir=Qa;var tl=class extends me{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});let e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"\u21E7",r=t.compassClassName!==void 0?t.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=r,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(r));let s=t.tipLabel?t.tipLabel:"Reset rotation",o=document.createElement("button");o.className=e+"-reset",o.setAttribute("type","button"),o.title=s,o.appendChild(this.label_),o.addEventListener(L.CLICK,this.handleClick_.bind(this),!1);let a=e+" "+ge+" "+ki,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(vr)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){let e=this.getMap().getView();if(!e)return;let i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:ce}):e.setRotation(0))}render(t){let e=t.frameState;if(!e)return;let i=e.viewState.rotation;if(i!=this.rotation_){let r="rotate("+i+"rad)";if(this.autoHide_){let s=this.element.classList.contains(vr);!s&&i===0?this.element.classList.add(vr):s&&i!==0&&this.element.classList.remove(vr)}this.label_.style.transform=r}this.rotation_=i}},Mr=tl;var el=class extends me{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});let e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,r=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",s=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",o=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"\u2013",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",h=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=r,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(L.CLICK,this.handleClick_.bind(this,i),!1);let u=document.createElement("button");u.className=s,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(L.CLICK,this.handleClick_.bind(this,-i),!1);let d=e+" "+ge+" "+ki,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){let i=this.getMap().getView();if(!i)return;let r=i.getZoom();if(r!==void 0){let s=i.getConstrainedZoom(r+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:s,duration:this.duration_,easing:ce})):i.setZoom(s)}}},br=el;function kn(n){n=n||{};let t=new Mt;return(n.zoom===void 0||n.zoom)&&t.push(new br(n.zoomOptions)),(n.rotate===void 0||n.rotate)&&t.push(new Mr(n.rotateOptions)),(n.attribution===void 0||n.attribution)&&t.push(new Ir(n.attributionOptions)),t}var il=class{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;let t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;let r=this.points_[e+2]-this.points_[i+2];if(r<1e3/60)return!1;let s=this.points_[e]-this.points_[i],o=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(o,s),this.initialVelocity_=Math.sqrt(s*s+o*o)/r,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}},_d=il;var nl={ACTIVE:"active"};var rl=class extends pt{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(nl.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(nl.ACTIVE,t)}setMap(t){this.map_=t}};function yd(n,t,e){let i=n.getCenterInternal();if(i){let r=[i[0]+t[0],i[1]+t[1]];n.animateInternal({duration:e!==void 0?e:250,easing:Eu,center:n.getConstrainedCenter(r)})}}function Nn(n,t,e,i){let r=n.getZoom();if(r===void 0)return;let s=n.getConstrainedZoom(r+t),o=n.getResolutionForZoom(s);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:e,duration:i!==void 0?i:250,easing:ce})}var Ke=rl;var sl=class extends Ke{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:250}handleEvent(t){let e=!1;if(t.type==at.DBLCLICK){let i=t.originalEvent,r=t.map,s=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=r.getView();Nn(a,o,s,this.duration_),i.preventDefault(),e=!0}return!e}},xd=sl;function Lr(n){let t=arguments;return function(e){let i=!0;for(let r=0,s=t.length;r<s&&(i=i&&t[r](e),!!i);++r);return i}}var Ed=function(n){let t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},pm=function(n){let t=n.map.getTargetElement(),e=t.getRootNode(),i=n.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},$s=function(n){let t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?pm(n):!0},Cd=ei;var Js=function(n){let t=n.originalEvent;return"pointerId"in t&&t.button==0&&!(eu&&aa&&t.ctrlKey)};var Qs=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey};var Rd=function(n){let t=n.originalEvent;return aa?t.metaKey:t.ctrlKey},to=function(n){let t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},eo=function(n){let t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},Ni=function(n){let t=n.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"};var wd=function(n){let t=n.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};var ol=class extends Ke{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==at.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==at.POINTERUP){let i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==at.POINTERDOWN){let i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==at.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function Gn(n){let t=n.length,e=0,i=0;for(let r=0;r<t;r++)e+=n[r].clientX,i+=n[r].clientY;return{clientX:e/t,clientY:i/t}}var pe=ol;var al=class extends pe{constructor(t){super({stopDown:ii}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;let e=t.condition?t.condition:Lr(Qs,wd);this.condition_=t.onFocusOnly?Lr($s,e):e,this.noKinetic_=!1}handleDragEvent(t){let e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());let i=this.targetPointers,r=e.getEventPixel(Gn(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(r[0],r[1]),this.lastCentroid){let s=[this.lastCentroid[0]-r[0],r[1]-this.lastCentroid[1]],a=t.map.getView();pu(s,a.getResolution()),Sn(s,a.getRotation()),a.adjustCenterInternal(s)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=r,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){let e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){let r=this.kinetic_.getDistance(),s=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-r*Math.cos(s),a[1]-r*Math.sin(s)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:ce})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){let i=t.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}},Sd=al;var ll=class extends pe{constructor(t){t=t||{},super({stopDown:ii}),this.condition_=t.condition?t.condition:Ed,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Ni(t))return;let e=t.map,i=e.getView();if(i.getConstraints().rotation===On)return;let r=e.getSize(),s=t.pixel,o=Math.atan2(r[1]/2-s[1],s[0]-r[0]/2);if(this.lastAngle_!==void 0){let a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(t){return Ni(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Ni(t)&&Js(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}},Td=ll;var hl=class extends Ci{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){let t=this.startPixel_,e=this.endPixel_,i="px",r=this.element_.style;r.left=Math.min(t[0],e[0])+i,r.top=Math.min(t[1],e[1])+i,r.width=Math.abs(e[0]-t[0])+i,r.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);let e=this.element_.style;e.left="inherit",e.top="inherit",e.width="inherit",e.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;let t=this.startPixel_,e=this.endPixel_,r=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);r[4]=r[0].slice(),this.geometry_?this.geometry_.setCoordinates([r]):this.geometry_=new Di([r])}getGeometry(){return this.geometry_}},vd=hl;var zn={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"},an=class extends mt{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}},cl=class extends pe{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new vd(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??Js,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){let r=i[0]-e[0],s=i[1]-e[1];return r*r+s*s>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new an(zn.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;let e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new an(e?zn.BOXEND:zn.BOXCANCEL,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return this.condition_(t)?(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new an(zn.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new an(zn.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new an(zn.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}},Id=cl;var ul=class extends Id{constructor(t){t=t||{};let e=t.condition?t.condition:to;super({condition:e,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=t.duration!==void 0?t.duration:200,this.out_=t.out!==void 0?t.out:!1}onBoxEnd(t){let i=this.getMap().getView(),r=this.getGeometry();if(this.out_){let s=i.rotatedExtentForGeometry(r),o=i.getResolutionForExtentInternal(s),a=i.getResolution()/o;r=r.clone(),r.scale(a*a)}i.fitInternal(r,{duration:this.duration_,easing:ce})}},Md=ul;var Gi={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};var dl=class extends Ke{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return Qs(e)&&eo(e)},this.condition_=t.condition!==void 0?t.condition:this.defaultCondition_,this.duration_=t.duration!==void 0?t.duration:100,this.pixelDelta_=t.pixelDelta!==void 0?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==L.KEYDOWN){let i=t.originalEvent,r=i.key;if(this.condition_(t)&&(r==Gi.DOWN||r==Gi.LEFT||r==Gi.RIGHT||r==Gi.UP)){let o=t.map.getView(),a=o.getResolution()*this.pixelDelta_,l=0,h=0;r==Gi.DOWN?h=-a:r==Gi.LEFT?l=-a:r==Gi.RIGHT?l=a:h=a;let c=[l,h];Sn(c,o.getRotation()),yd(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}},bd=dl;var fl=class extends Ke{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!Rd(e)&&eo(e)},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:100}handleEvent(t){let e=!1;if(t.type==L.KEYDOWN||t.type==L.KEYPRESS){let i=t.originalEvent,r=i.key;if(this.condition_(t)&&(r==="+"||r==="-")){let s=t.map,o=r==="+"?this.delta_:-this.delta_,a=s.getView();Nn(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}},Ld=fl;var _m=40,ym=300,gl=class extends Ke{constructor(t){t=t||{},super(t),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=t.maxDelta!==void 0?t.maxDelta:1,this.duration_=t.duration!==void 0?t.duration:250,this.timeout_=t.timeout!==void 0?t.timeout:80,this.useAnchor_=t.useAnchor!==void 0?t.useAnchor:!0,this.constrainResolution_=t.constrainResolution!==void 0?t.constrainResolution:!1;let e=t.condition?t.condition:Cd;this.condition_=t.onFocusOnly?Lr($s,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;let t=this.getMap();if(!t)return;t.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t)||t.type!==L.WHEEL)return!0;let i=t.map,r=t.originalEvent;r.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel);let s=r.deltaY;switch(r.deltaMode){case WheelEvent.DOM_DELTA_LINE:s*=_m;break;case WheelEvent.DOM_DELTA_PAGE:s*=ym;break;default:}if(s===0)return!1;this.lastDelta_=s;let o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(s)<4?"trackpad":"wheel");let a=i.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-s/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=o,!1;this.totalDelta_+=s;let l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),l),!1}handleWheelZoom_(t){let e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-Q(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Nn(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}},Ad=gl;var ml=class extends pe{constructor(t){t=t||{};let e=t;e.stopDown||(e.stopDown=ii),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=t.threshold!==void 0?t.threshold:.3,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){let e=0,i=this.targetPointers[0],r=this.targetPointers[1],s=Math.atan2(r.clientY-i.clientY,r.clientX-i.clientX);if(this.lastAngle_!==void 0){let l=s-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=l}this.lastAngle_=s;let o=t.map,a=o.getView();a.getConstraints().rotation!==On&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Gn(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return this.targetPointers.length<2?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){if(this.targetPointers.length>=2){let e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}},Pd=ml;var pl=class extends pe{constructor(t){t=t||{};let e=t;e.stopDown||(e.stopDown=ii),super(e),this.anchor_=null,this.duration_=t.duration!==void 0?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1,i=this.targetPointers[0],r=this.targetPointers[1],s=i.clientX-r.clientX,o=i.clientY-r.clientY,a=Math.sqrt(s*s+o*o);this.lastDistance_!==void 0&&(e=this.lastDistance_/a),this.lastDistance_=a;let l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Gn(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){let i=t.map.getView(),r=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,r),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){let e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}},Od=pl;function jn(n){n=n||{};let t=new Mt,e=new _d(-.005,.05,100);return(n.altShiftDragRotate===void 0||n.altShiftDragRotate)&&t.push(new Td),(n.doubleClickZoom===void 0||n.doubleClickZoom)&&t.push(new xd({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan===void 0||n.dragPan)&&t.push(new Sd({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate===void 0||n.pinchRotate)&&t.push(new Pd),(n.pinchZoom===void 0||n.pinchZoom)&&t.push(new Od({duration:n.zoomDuration})),(n.keyboard===void 0||n.keyboard)&&(t.push(new bd),t.push(new Ld({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom===void 0||n.mouseWheelZoom)&&t.push(new Ad({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom===void 0||n.shiftDragZoom)&&t.push(new Md({duration:n.zoomDuration})),t}var rt={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};var _l=class extends pt{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;let e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[rt.OPACITY]=t.opacity!==void 0?t.opacity:1,V(typeof e[rt.OPACITY]=="number","Layer opacity must be a number"),e[rt.VISIBLE]=t.visible!==void 0?t.visible:!0,e[rt.Z_INDEX]=t.zIndex,e[rt.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[rt.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[rt.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[rt.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){let e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=Q(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return F()}getLayerStatesArray(t){return F()}getExtent(){return this.get(rt.EXTENT)}getMaxResolution(){return this.get(rt.MAX_RESOLUTION)}getMinResolution(){return this.get(rt.MIN_RESOLUTION)}getMinZoom(){return this.get(rt.MIN_ZOOM)}getMaxZoom(){return this.get(rt.MAX_ZOOM)}getOpacity(){return this.get(rt.OPACITY)}getSourceState(){return F()}getVisible(){return this.get(rt.VISIBLE)}getZIndex(){return this.get(rt.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(rt.EXTENT,t)}setMaxResolution(t){this.set(rt.MAX_RESOLUTION,t)}setMinResolution(t){this.set(rt.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(rt.MAX_ZOOM,t)}setMinZoom(t){this.set(rt.MIN_ZOOM,t)}setOpacity(t){V(typeof t=="number","Layer opacity must be a number"),this.set(rt.OPACITY,t)}setVisible(t){this.set(rt.VISIBLE,t)}setZIndex(t){this.set(rt.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},io=_l;var zi={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"},be=class extends mt{constructor(t,e){super(t),this.layer=e}},yl={LAYERS:"layers"},xl=class n extends io{constructor(t){t=t||{};let e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(yl.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new Mt(i.slice(),{unique:!0}):V(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new Mt(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(B),this.layersListenerKeys_.length=0;let t=this.getLayers();this.layersListenerKeys_.push(G(t,wt.ADD,this.handleLayersAdd_,this),G(t,wt.REMOVE,this.handleLayersRemove_,this));for(let i in this.listenerKeys_)this.listenerKeys_[i].forEach(B);ze(this.listenerKeys_);let e=t.getArray();for(let i=0,r=e.length;i<r;i++){let s=e[i];this.registerLayerListeners_(s),this.dispatchEvent(new be(zi.ADDLAYER,s))}this.changed()}registerLayerListeners_(t){let e=[G(t,Ee.PROPERTYCHANGE,this.handleLayerChange_,this),G(t,L.CHANGE,this.handleLayerChange_,this)];t instanceof n&&e.push(G(t,zi.ADDLAYER,this.handleLayerGroupAdd_,this),G(t,zi.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[U(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new be(zi.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new be(zi.REMOVELAYER,t.layer))}handleLayersAdd_(t){let e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new be(zi.ADDLAYER,e)),this.changed()}handleLayersRemove_(t){let e=t.element,i=U(e);this.listenerKeys_[i].forEach(B),delete this.listenerKeys_[i],this.dispatchEvent(new be(zi.REMOVELAYER,e)),this.changed()}getLayers(){return this.get(yl.LAYERS)}setLayers(t){let e=this.getLayers();if(e){let i=e.getArray();for(let r=0,s=i.length;r<s;++r)this.dispatchEvent(new be(zi.REMOVELAYER,i[r]))}this.set(yl.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){let e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(e)});let r=this.getLayerState(),s=r.zIndex;!t&&r.zIndex===void 0&&(s=0);for(let o=i,a=e.length;o<a;o++){let l=e[o];l.opacity*=r.opacity,l.visible=l.visible&&r.visible,l.maxResolution=Math.min(l.maxResolution,r.maxResolution),l.minResolution=Math.max(l.minResolution,r.minResolution),l.minZoom=Math.max(l.minZoom,r.minZoom),l.maxZoom=Math.min(l.maxZoom,r.maxZoom),r.extent!==void 0&&(l.extent!==void 0?l.extent=Ut(l.extent,r.extent):l.extent=r.extent),l.zIndex===void 0&&(l.zIndex=s)}return e}getSourceState(){return"ready"}},Ar=xl;var Lt={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var El=class extends io{constructor(t){let e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(rt.SOURCE,this.handleSourcePropertyChange_);let i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return t=t||[],t.push(this),t}getLayerStatesArray(t){return t=t||[],t.push(this.getLayerState()),t}getSource(){return this.get(rt.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){let t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(B(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;let t=this.getSource();t&&(this.sourceChangeKey_=G(t,L.CHANGE,this.handleSourceChange_,this),t.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e,i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof Bt?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let r;if(e.layerStatesArray){if(r=e.layerStatesArray.find(o=>o.layer===this),!r)return!1}else r=this.getLayerState();let s=this.getExtent();return Pr(r,e.viewState)&&(!s||lt(s,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];let e=this.getSource()?.getAttributions();if(!e)return[];let i=t instanceof Bt?t.getViewStateAndExtent():t,r=e(i);return Array.isArray(r)||(r=[r]),r}render(t,e){let i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){let e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(rt.MAP,t)}getMapInternal(){return this.get(rt.MAP)}setMap(t){this.mapPrecomposeKey_&&(B(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(B(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=G(t,Lt.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=G(this,L.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){let e=t.frameState.layerStatesArray,i=this.getLayerState(!1);V(!e.some(r=>r.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)}setSource(t){this.set(rt.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function Pr(n,t){if(!n.visible)return!1;let e=t.resolution;if(e<n.minResolution||e>=n.maxResolution)return!1;let i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}var ci=El;function no(n,t,e=0,i=n.length-1,r=xm){for(;i>e;){if(i-e>600){let l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),g=Math.min(i,Math.floor(t+(l-h)*u/l+d));no(n,t,f,g,r)}let s=n[t],o=e,a=i;for(Or(n,e,t),r(n[i],s)>0&&Or(n,e,i);o<a;){for(Or(n,o,a),o++,a--;r(n[o],s)<0;)o++;for(;r(n[a],s)>0;)a--}r(n[e],s)===0?Or(n,e,a):(a++,Or(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function Or(n,t,e){let i=n[t];n[t]=n[e],n[e]=i}function xm(n,t){return n<t?-1:n>t?1:0}var ln=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data,i=[];if(!so(t,e))return i;let r=this.toBBox,s=[];for(;e;){for(let o=0;o<e.children.length;o++){let a=e.children[o],l=e.leaf?r(a):a;so(t,l)&&(e.leaf?i.push(a):Rl(t,l)?this._all(a,i):s.push(a))}e=s.pop()}return i}collides(t){let e=this.data;if(!so(t,e))return!1;let i=[];for(;e;){for(let r=0;r<e.children.length;r++){let s=e.children[r],o=e.leaf?this.toBBox(s):s;if(so(t,o)){if(e.leaf||Rl(t,o))return!0;i.push(s)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){let i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Xn([]),this}remove(t,e){if(!t)return this;let i=this.data,r=this.toBBox(t),s=[],o=[],a,l,h;for(;i||s.length;){if(i||(i=s.pop(),l=s[s.length-1],a=o.pop(),h=!0),i.leaf){let c=Em(t,i.children,e);if(c!==-1)return i.children.splice(c,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&Rl(i,r)?(s.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){let i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,r){let s=i-e+1,o=this._maxEntries,a;if(s<=o)return a=Xn(t.slice(e,i+1)),Wn(a,this.toBBox),a;r||(r=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,r-1))),a=Xn([]),a.leaf=!1,a.height=r;let l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));Fd(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){let u=Math.min(c+h-1,i);Fd(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){let f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,r-1))}}return Wn(a,this.toBBox),a}_chooseSubtree(t,e,i,r){for(;r.push(e),!(e.leaf||r.length-1===i);){let s=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){let h=e.children[l],c=Cl(h),u=wm(t,h)-c;u<o?(o=u,s=c<s?c:s,a=h):u===o&&c<s&&(s=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){let r=i?t:this.toBBox(t),s=[],o=this._chooseSubtree(r,this.data,e,s);for(o.children.push(t),Dr(o,r);e>=0&&s[e].children.length>this._maxEntries;)this._split(s,e),e--;this._adjustParentBBoxes(r,s,e)}_split(t,e){let i=t[e],r=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,r);let o=this._chooseSplitIndex(i,s,r),a=Xn(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Wn(i,this.toBBox),Wn(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Xn([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Wn(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let r,s=1/0,o=1/0;for(let a=e;a<=i-e;a++){let l=Fr(t,0,a,this.toBBox),h=Fr(t,a,i,this.toBBox),c=Sm(l,h),u=Cl(l)+Cl(h);c<s?(s=c,r=a,o=u<o?u:o):c===s&&u<o&&(o=u,r=a)}return r||i-e}_chooseSplitAxis(t,e,i){let r=t.leaf?this.compareMinX:Cm,s=t.leaf?this.compareMinY:Rm,o=this._allDistMargin(t,e,i,r),a=this._allDistMargin(t,e,i,s);o<a&&t.children.sort(r)}_allDistMargin(t,e,i,r){t.children.sort(r);let s=this.toBBox,o=Fr(t,0,e,s),a=Fr(t,i-e,i,s),l=ro(o)+ro(a);for(let h=e;h<i-e;h++){let c=t.children[h];Dr(o,t.leaf?s(c):c),l+=ro(o)}for(let h=i-e-1;h>=e;h--){let c=t.children[h];Dr(a,t.leaf?s(c):c),l+=ro(a)}return l}_adjustParentBBoxes(t,e,i){for(let r=i;r>=0;r--)Dr(e[r],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():Wn(t[e],this.toBBox)}};function Em(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i<t.length;i++)if(e(n,t[i]))return i;return-1}function Wn(n,t){Fr(n,0,n.children.length,t,n)}function Fr(n,t,e,i,r){r||(r=Xn(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=t;s<e;s++){let o=n.children[s];Dr(r,n.leaf?i(o):o)}return r}function Dr(n,t){return n.minX=Math.min(n.minX,t.minX),n.minY=Math.min(n.minY,t.minY),n.maxX=Math.max(n.maxX,t.maxX),n.maxY=Math.max(n.maxY,t.maxY),n}function Cm(n,t){return n.minX-t.minX}function Rm(n,t){return n.minY-t.minY}function Cl(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function ro(n){return n.maxX-n.minX+(n.maxY-n.minY)}function wm(n,t){return(Math.max(t.maxX,n.maxX)-Math.min(t.minX,n.minX))*(Math.max(t.maxY,n.maxY)-Math.min(t.minY,n.minY))}function Sm(n,t){let e=Math.max(n.minX,t.minX),i=Math.max(n.minY,t.minY),r=Math.min(n.maxX,t.maxX),s=Math.min(n.maxY,t.maxY);return Math.max(0,r-e)*Math.max(0,s-i)}function Rl(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function so(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function Xn(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Fd(n,t,e,i,r){let s=[t,e];for(;s.length;){if(e=s.pop(),t=s.pop(),e-t<=i)continue;let o=t+Math.ceil((e-t)/i/2)*i;no(n,o,t,e,r),s.push(t,o,o,e)}}var ao=[NaN,NaN,NaN,0],wl;function Tm(){return wl||(wl=nt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),wl}var vm=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Im=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Mm=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,bm=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function oo(n,t){return n.endsWith("%")?Number(n.substring(0,n.length-1))/t:Number(n)}function Nr(n){throw new Error('failed to parse "'+n+'" as color')}function Dd(n){if(n.toLowerCase().startsWith("rgb")){let s=n.match(Im)||n.match(vm)||n.match(Mm);if(s){let o=s[4],a=100/255;return[Q(oo(s[1],a)+.5|0,0,255),Q(oo(s[2],a)+.5|0,0,255),Q(oo(s[3],a)+.5|0,0,255),o!==void 0?Q(oo(o,100),0,1):1]}Nr(n)}if(n.startsWith("#")){if(bm.test(n)){let s=n.substring(1),o=s.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=s.length;l<h;l+=o){let c=parseInt(s.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}Nr(n)}let t=Tm();t.fillStyle="#abcdef";let e=t.fillStyle;t.fillStyle=n,t.fillStyle===e&&(t.fillStyle="#fedcba",e=t.fillStyle,t.fillStyle=n,t.fillStyle===e&&Nr(n));let i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return Dd(i);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);let r=Array.from(t.getImageData(0,0,1,1).data);return r[3]=Ti(r[3]/255,3),r}function kd(n){return typeof n=="string"?n:zr(n)}var Lm=1024,kr={},Sl=0;function Nd(n){if(n.length===4)return n;let t=n.slice();return t[3]=1,t}function Tl(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function vl(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function Il(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function Ml(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function bl(n){let t=Il(n[0]),e=Il(n[1]),i=Il(n[2]),r=Ml(t*.222488403+e*.716873169+i*.06060791),s=500*(Ml(t*.452247074+e*.399439023+i*.148375274)-r),o=200*(r-Ml(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(o,s)*(180/Math.PI);return[116*r-16,Math.sqrt(s*s+o*o),a<0?a+360:a,n[3]]}function Gd(n){let t=(n[0]+16)/116,e=n[1],i=n[2]*Math.PI/180,r=vl(t),s=vl(t+e/500*Math.cos(i)),o=vl(t-e/200*Math.sin(i)),a=Tl(s*3.021973625-r*1.617392459-o*.404875592),l=Tl(s*-.943766287+r*1.916279586+o*.027607165),h=Tl(s*.069407491-r*.22898585+o*1.159737864);return[Q(a+.5|0,0,255),Q(l+.5|0,0,255),Q(h+.5|0,0,255),n[3]]}function Gr(n){if(n==="none")return ao;if(kr.hasOwnProperty(n))return kr[n];if(Sl>=Lm){let e=0;for(let i in kr)(e++&3)===0&&(delete kr[i],--Sl)}let t=Dd(n);t.length!==4&&Nr(n);for(let e of t)isNaN(e)&&Nr(n);return kr[n]=t,++Sl,t}function _e(n){return Array.isArray(n)?n:Gr(n)}function zr(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);let r=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+r+")"}function Ll(n){return n[0]>0&&n[1]>0}function zd(n,t,e){return e===void 0&&(e=[0,0]),e[0]=n[0]*t+.5|0,e[1]=n[1]*t+.5|0,e}function ft(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}var hn=0;var Ft=1<<hn++,J=1<<hn++,zt=1<<hn++,te=1<<hn++,Wi=1<<hn++,jr=1<<hn++,lo=Math.pow(2,hn)-1,Ol={[Ft]:"boolean",[J]:"number",[zt]:"string",[te]:"color",[Wi]:"number[]",[jr]:"size"},Am=Object.keys(Ol).map(Number).sort(jt);function Pm(n){return n in Ol}function Wr(n){let t=[];for(let e of Am)Xr(n,e)&&t.push(Ol[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function Xr(n,t){return(n&t)===t}function ji(n,t){return n===t}var gt=class{constructor(t,e){if(!Pm(t))throw new Error(`literal expressions must have a specific type, got ${Wr(t)}`);this.type=t,this.value=e}},Pl=class{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}};function Fl(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function vt(n,t,e){switch(typeof n){case"boolean":{if(ji(t,zt))return new gt(zt,n?"true":"false");if(!Xr(t,Ft))throw new Error(`got a boolean, but expected ${Wr(t)}`);return new gt(Ft,n)}case"number":{if(ji(t,jr))return new gt(jr,ft(n));if(ji(t,Ft))return new gt(Ft,!!n);if(ji(t,zt))return new gt(zt,n.toString());if(!Xr(t,J))throw new Error(`got a number, but expected ${Wr(t)}`);return new gt(J,n)}case"string":{if(ji(t,te))return new gt(te,Gr(n));if(ji(t,Ft))return new gt(Ft,!!n);if(!Xr(t,zt))throw new Error(`got a string, but expected ${Wr(t)}`);return new gt(zt,n)}default:}if(!Array.isArray(n))throw new Error("expression must be an array or a primitive value");if(n.length===0)throw new Error("empty expression");if(typeof n[0]=="string")return Um(n,t,e);for(let i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(ji(t,jr)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new gt(jr,n)}if(ji(t,te)){if(n.length===3)return new gt(te,[...n,1]);if(n.length===4)return new gt(te,n);throw new Error(`expected an array of 3 or 4 values for a color, got ${n.length}`)}if(!Xr(t,Wi))throw new Error(`got an array of numbers, but expected ${Wr(t)}`);return new gt(Wi,n)}var R={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},Om={[R.Get]:Y(Z(1,1/0),jd),[R.Var]:Y(Z(1,1),Fm),[R.Has]:Y(Z(1,1/0),jd),[R.Id]:Y(Dm,Un),[R.Concat]:Y(Z(2,1/0),st(zt)),[R.GeometryType]:Y(km,Un),[R.LineMetric]:Y(Un),[R.Resolution]:Y(Al,Un),[R.Zoom]:Y(Al,Un),[R.Time]:Y(Al,Un),[R.Any]:Y(Z(2,1/0),st(Ft)),[R.All]:Y(Z(2,1/0),st(Ft)),[R.Not]:Y(Z(1,1),st(Ft)),[R.Equal]:Y(Z(2,2),st(lo)),[R.NotEqual]:Y(Z(2,2),st(lo)),[R.GreaterThan]:Y(Z(2,2),st(J)),[R.GreaterThanOrEqualTo]:Y(Z(2,2),st(J)),[R.LessThan]:Y(Z(2,2),st(J)),[R.LessThanOrEqualTo]:Y(Z(2,2),st(J)),[R.Multiply]:Y(Z(2,1/0),Wd),[R.Coalesce]:Y(Z(2,1/0),Wd),[R.Divide]:Y(Z(2,2),st(J)),[R.Add]:Y(Z(2,1/0),st(J)),[R.Subtract]:Y(Z(2,2),st(J)),[R.Clamp]:Y(Z(3,3),st(J)),[R.Mod]:Y(Z(2,2),st(J)),[R.Pow]:Y(Z(2,2),st(J)),[R.Abs]:Y(Z(1,1),st(J)),[R.Floor]:Y(Z(1,1),st(J)),[R.Ceil]:Y(Z(1,1),st(J)),[R.Round]:Y(Z(1,1),st(J)),[R.Sin]:Y(Z(1,1),st(J)),[R.Cos]:Y(Z(1,1),st(J)),[R.Atan]:Y(Z(1,2),st(J)),[R.Sqrt]:Y(Z(1,1),st(J)),[R.Match]:Y(Z(4,1/0),Xd,Gm),[R.Between]:Y(Z(3,3),st(J)),[R.Interpolate]:Y(Z(6,1/0),Xd,zm),[R.Case]:Y(Z(3,1/0),Nm,jm),[R.In]:Y(Z(2,2),Wm),[R.Number]:Y(Z(1,1/0),st(lo)),[R.String]:Y(Z(1,1/0),st(lo)),[R.Array]:Y(Z(1,1/0),st(J)),[R.Color]:Y(Z(1,4),st(J)),[R.Band]:Y(Z(1,3),st(J)),[R.Palette]:Y(Z(2,2),Xm),[R.ToString]:Y(Z(1,1),st(Ft|J|zt|te))};function jd(n,t,e){let i=n.length-1,r=new Array(i);for(let s=0;s<i;++s){let o=n[s+1];switch(typeof o){case"number":{r[s]=new gt(J,o);break}case"string":{r[s]=new gt(zt,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}s===0&&e.properties.add(String(o))}return r}function Fm(n,t,e){let i=n[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return e.variables.add(i),[new gt(zt,i)]}function Dm(n,t,e){e.featureId=!0}function km(n,t,e){e.geometryType=!0}function Al(n,t,e){e.mapState=!0}function Un(n,t,e){let i=n[0];if(n.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function Z(n,t){return function(e,i,r){let s=e[0],o=e.length-1;if(n===t){if(o!==n){let a=n===1?"":"s";throw new Error(`expected ${n} argument${a} for ${s}, got ${o}`)}}else if(o<n||o>t){let a=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`expected ${a} arguments for ${s}, got ${o}`)}}}function Wd(n,t,e){let i=n.length-1,r=new Array(i);for(let s=0;s<i;++s){let o=vt(n[s+1],t,e);r[s]=o}return r}function st(n){return function(t,e,i){let r=t.length-1,s=new Array(r);for(let o=0;o<r;++o){let a=vt(t[o+1],n,i);s[o]=a}return s}}function Nm(n,t,e){let i=n[0],r=n.length-1;if(r%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${r} instead`)}function Xd(n,t,e){let i=n[0],r=n.length-1;if(r%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${r} instead`)}function Gm(n,t,e){let i=n.length-1,r=zt|J|Ft,s=vt(n[1],r,e),o=vt(n[n.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{let h=vt(n[l+2],s.type,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{let h=vt(n[l+3],o.type,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[s,...a,o]}function zm(n,t,e){let i=n[1],r;switch(i[0]){case"linear":r=1;break;case"exponential":let l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);r=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}let s=new gt(J,r),o;try{o=vt(n[2],J,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}let a=new Array(n.length-3);for(let l=0;l<a.length;l+=2){try{let h=vt(n[l+3],J,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{let h=vt(n[l+4],t,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[s,o,...a]}function jm(n,t,e){let i=vt(n[n.length-1],t,e),r=new Array(n.length-1);for(let s=0;s<r.length-1;s+=2){try{let o=vt(n[s+1],Ft,e);r[s]=o}catch(o){throw new Error(`failed to parse argument ${s} of case expression: ${o.message}`)}try{let o=vt(n[s+2],i.type,e);r[s+1]=o}catch(o){throw new Error(`failed to parse argument ${s+1} of case expression: ${o.message}`)}}return r[r.length-1]=i,r}function Wm(n,t,e){let i=n[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let r;if(typeof i[0]=="string"){if(i[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(i[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');i=i[1],r=zt}else r=J;let s=new Array(i.length);for(let a=0;a<s.length;a++)try{let l=vt(i[a],r,e);s[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[vt(n[1],r,e),...s]}function Xm(n,t,e){let i;try{i=vt(n[1],J,e)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}let r=n[2];if(!Array.isArray(r))throw new Error("the second argument of palette must be an array");let s=new Array(r.length);for(let o=0;o<s.length;o++){let a;try{a=vt(r[o],te,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof gt))throw new Error(`the palette color at index ${o} must be a literal value`);s[o]=a}return[i,...s]}function Y(...n){return function(t,e,i){let r=t[0],s;for(let o=0;o<n.length;o++){let a=n[o](t,e,i);if(o==n.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");s=a}}return new Pl(e,r,...s)}}function Um(n,t,e){let i=n[0],r=Om[i];if(!r)throw new Error(`unknown operator: ${i}`);return r(n,t,e)}function Dl(n){if(!n)return"";let t=n.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Dl(n.getGeometries()[0]);default:return""}}function kl(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Ae(n,t,e){let i=vt(n,t,e);return Le(i,e)}function Le(n,t){if(n instanceof gt){if(n.type===te&&typeof n.value=="string"){let i=Gr(n.value);return function(){return i}}return function(){return n.value}}let e=n.operator;switch(e){case R.Number:case R.String:case R.Coalesce:return Ym(n,t);case R.Get:case R.Var:case R.Has:return Km(n,t);case R.Id:return i=>i.featureId;case R.GeometryType:return i=>i.geometryType;case R.Concat:{let i=n.args.map(r=>Le(r,t));return r=>"".concat(...i.map(s=>s(r).toString()))}case R.Resolution:return i=>i.resolution;case R.Any:case R.All:case R.Between:case R.In:case R.Not:return Bm(n,t);case R.Equal:case R.NotEqual:case R.LessThan:case R.LessThanOrEqualTo:case R.GreaterThan:case R.GreaterThanOrEqualTo:return Vm(n,t);case R.Multiply:case R.Divide:case R.Add:case R.Subtract:case R.Clamp:case R.Mod:case R.Pow:case R.Abs:case R.Floor:case R.Ceil:case R.Round:case R.Sin:case R.Cos:case R.Atan:case R.Sqrt:return Zm(n,t);case R.Case:return Hm(n,t);case R.Match:return qm(n,t);case R.Interpolate:return $m(n,t);case R.ToString:return Jm(n,t);default:throw new Error(`Unsupported operator ${e}`)}}function Ym(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Le(n.args[s],t);switch(e){case R.Coalesce:return s=>{for(let o=0;o<i;++o){let a=r[o](s);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case R.Number:case R.String:return s=>{for(let o=0;o<i;++o){let a=r[o](s);if(typeof a===e)return a}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}function Km(n,t){let i=n.args[0].value;switch(n.operator){case R.Get:return r=>{let s=n.args,o=r.properties[i];for(let a=1,l=s.length;a<l;++a){let c=s[a].value;o=o[c]}return o};case R.Var:return r=>r.variables[i];case R.Has:return r=>{let s=n.args;if(!(i in r.properties))return!1;let o=r.properties[i];for(let a=1,l=s.length;a<l;++a){let c=s[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function Vm(n,t){let e=n.operator,i=Le(n.args[0],t),r=Le(n.args[1],t);switch(e){case R.Equal:return s=>i(s)===r(s);case R.NotEqual:return s=>i(s)!==r(s);case R.LessThan:return s=>i(s)<r(s);case R.LessThanOrEqualTo:return s=>i(s)<=r(s);case R.GreaterThan:return s=>i(s)>r(s);case R.GreaterThanOrEqualTo:return s=>i(s)>=r(s);default:throw new Error(`Unsupported comparison operator ${e}`)}}function Bm(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Le(n.args[s],t);switch(e){case R.Any:return s=>{for(let o=0;o<i;++o)if(r[o](s))return!0;return!1};case R.All:return s=>{for(let o=0;o<i;++o)if(!r[o](s))return!1;return!0};case R.Between:return s=>{let o=r[0](s),a=r[1](s),l=r[2](s);return o>=a&&o<=l};case R.In:return s=>{let o=r[0](s);for(let a=1;a<i;++a)if(o===r[a](s))return!0;return!1};case R.Not:return s=>!r[0](s);default:throw new Error(`Unsupported logical operator ${e}`)}}function Zm(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Le(n.args[s],t);switch(e){case R.Multiply:return s=>{let o=1;for(let a=0;a<i;++a)o*=r[a](s);return o};case R.Divide:return s=>r[0](s)/r[1](s);case R.Add:return s=>{let o=0;for(let a=0;a<i;++a)o+=r[a](s);return o};case R.Subtract:return s=>r[0](s)-r[1](s);case R.Clamp:return s=>{let o=r[0](s),a=r[1](s);if(o<a)return a;let l=r[2](s);return o>l?l:o};case R.Mod:return s=>r[0](s)%r[1](s);case R.Pow:return s=>Math.pow(r[0](s),r[1](s));case R.Abs:return s=>Math.abs(r[0](s));case R.Floor:return s=>Math.floor(r[0](s));case R.Ceil:return s=>Math.ceil(r[0](s));case R.Round:return s=>Math.round(r[0](s));case R.Sin:return s=>Math.sin(r[0](s));case R.Cos:return s=>Math.cos(r[0](s));case R.Atan:return i===2?s=>Math.atan2(r[0](s),r[1](s)):s=>Math.atan(r[0](s));case R.Sqrt:return s=>Math.sqrt(r[0](s));default:throw new Error(`Unsupported numeric operator ${e}`)}}function Hm(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Le(n.args[r],t);return r=>{for(let s=0;s<e-1;s+=2)if(i[s](r))return i[s+1](r);return i[e-1](r)}}function qm(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Le(n.args[r],t);return r=>{let s=i[0](r);for(let o=1;o<e-1;o+=2)if(s===i[o](r))return i[o+1](r);return i[e-1](r)}}function $m(n,t){let e=n.args.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=Le(n.args[r],t);return r=>{let s=i[0](r),o=i[1](r),a,l;for(let h=2;h<e;h+=2){let c=i[h](r),u=i[h+1](r),d=Array.isArray(u);if(d&&(u=Nd(u)),c>=o)return h===2?u:d?Qm(s,o,a,l,c,u):Ur(s,o,a,l,c,u);a=c,l=u}return l}}function Jm(n,t){let e=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s<i;++s)r[s]=Le(n.args[s],t);if(e===R.ToString)return s=>{let o=r[0](s);return n.args[0].type===te?zr(o):o.toString()};throw new Error(`Unsupported convert operator ${e}`)}function Ur(n,t,e,i,r,s){let o=r-e;if(o===0)return i;let a=t-e,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(s-i)}function Qm(n,t,e,i,r,s){if(r-e===0)return i;let a=bl(i),l=bl(s),h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);let c=[Ur(n,t,e,a[0],r,l[0]),Ur(n,t,e,a[1],r,l[1]),a[2]+Ur(n,t,e,0,r,h),Ur(n,t,e,i[3],r,s[3])];return Gd(c)}var b={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};var Nl=class extends je{constructor(t,e,i,r){super(),this.extent=t,this.pixelRatio_=i,this.resolution=e,this.state=typeof r=="function"?b.IDLE:r,this.image_=null,this.loader=typeof r=="function"?r:null}changed(){this.dispatchEvent(L.CHANGE)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==b.IDLE&&this.loader){this.state=b.LOADING,this.changed();let t=this.getResolution(),e=Array.isArray(t)?t[0]:t;ps(()=>this.loader(this.getExtent(),e,this.getPixelRatio())).then(i=>{"image"in i&&(this.image_=i.image),"extent"in i&&(this.extent=i.extent),"resolution"in i&&(this.resolution=i.resolution),"pixelRatio"in i&&(this.pixelRatio_=i.pixelRatio),(i instanceof HTMLImageElement||la&&i instanceof ImageBitmap||i instanceof HTMLCanvasElement||i instanceof HTMLVideoElement)&&(this.image_=i),this.state=b.LOADED}).catch(i=>{this.state=b.ERROR,console.error(i)}).finally(()=>this.changed())}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}};function Ud(n,t,e){let i=n,r=!0,s=!1,o=!1,a=[_n(i,L.LOAD,function(){o=!0,s||t()})];return i.src&&xs?(s=!0,i.decode().then(function(){r&&t()}).catch(function(l){r&&(o?t():e())})):a.push(_n(i,L.ERROR,e)),function(){r=!1,a.forEach(B)}}function tp(n,t){return new Promise((e,i)=>{function r(){o(),e(n)}function s(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",r),n.removeEventListener("error",s)}n.addEventListener("load",r),n.addEventListener("error",s),t&&(n.src=t)})}function Gl(n,t){return t&&(n.src=t),n.src&&xs?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(r=>n.complete&&n.width?e(n):i(r))):tp(n)}function ho(n,t){return t&&(n.src=t),n.src&&xs&&la?n.decode().then(()=>createImageBitmap(n)).catch(e=>{if(n.complete&&n.width)return n;throw e}):Gl(n)}var co=Nl;var jl=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(let e in this.cache_){let i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){let i=zl(t,e);return i in this.cache_?this.cache_[i]:null}getPattern(t,e){let i=zl(t,e);return i in this.patternCache_?this.patternCache_[i]:null}set(t,e,i,r){let s=zl(t,e),o=s in this.cache_;this.cache_[s]=i,r&&(i.getImageState()===b.IDLE&&i.load(),i.getImageState()===b.LOADING?i.ready().then(()=>{this.patternCache_[s]=Fn().createPattern(i.getImage(1),"repeat")}):this.patternCache_[s]=Fn().createPattern(i.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};function zl(n,t){let e=t?_e(t):"null";return n+":"+e}var Dt=new jl;var Yr=null,uo=class extends je{constructor(t,e,i,r,s){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.canvas_={},this.color_=s,this.imageState_=r===void 0?b.IDLE:r,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===b.LOADED){Yr||(Yr=nt(1,1,void 0,{willReadFrequently:!0})),Yr.drawImage(this.image_,0,0);try{Yr.getImageData(0,0,1,1),this.tainted_=!1}catch{Yr=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(L.CHANGE)}handleImageError_(){this.imageState_=b.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=b.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}setImage(t){this.image_=t}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let t=this.size_[0],e=this.size_[1],i=nt(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===b.IDLE){this.image_||this.initializeImage_(),this.imageState_=b.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Gl(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==b.LOADED)return;let e=this.image_,i=nt(Math.ceil(e.width*t),Math.ceil(e.height*t)),r=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=kd(this.color_),i.fillRect(0,0,r.width/t,r.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=r}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===b.LOADED||this.imageState_===b.ERROR)t();else{let e=()=>{(this.imageState_===b.LOADED||this.imageState_===b.ERROR)&&(this.removeEventListener(L.CHANGE,e),t())};this.addEventListener(L.CHANGE,e)}})),this.ready_}};function Xi(n,t,e,i,r,s){let o=t===void 0?void 0:Dt.get(t,r);return o||(o=new uo(n,n&&"src"in n?n.src||void 0:t,e,i,r),Dt.set(t,r,o,s)),s&&o&&!Dt.getPattern(t,r)&&Dt.set(t,r,o,s),o}var Yd=uo;function Zt(n){return n?Array.isArray(n)?zr(n):typeof n=="object"&&"src"in n?ep(n):n:null}function ep(n){if(!n.offset||!n.size)return Dt.getPattern(n.src,n.color);let t=n.src+":"+n.offset,e=Dt.getPattern(t,n.color);if(e)return e;let i=Dt.get(n.src,null);if(i.getImageState()!==b.LOADED)return null;let r=nt(n.size[0],n.size[1]);return r.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Xi(r.canvas,t,void 0,b.LOADED,n.color,!0),Dt.getPattern(t,n.color)}var fo="10px sans-serif",Ct="#000",Ve="round",Ht=[],qt=0,Be="round",ui=10,Vd=0,di="#000",Ui="center",un="middle",fi=[0,0,0,0],gi=1,cn=new pt,Kr=null,Kd,Wl={},ip=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function np(n,t,e){return`${n} ${t} 16px "${e}"`}var Bd=(function(){let t,e;async function i(s){await e.ready;let o=await e.load(s);if(o.length===0)return!1;let a=Hs(s),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{let u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=Zs[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function r(){await e.ready;let s=!0,o=cn.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){let h=a[l],c=o[h];c<100&&(await i(h)?(ze(Wl),cn.set(h,100)):(c+=10,cn.set(h,c,!0),c<100&&(s=!1)))}t=void 0,s||(t=setTimeout(r,100))}return async function(s){e||(e=xt?self.fonts:document.fonts);let o=Hs(s);if(!o)return;let a=o.families,l=!1;for(let h of a){if(ip.has(h))continue;let c=np(o.style,o.weight,h);cn.get(c)===void 0&&(cn.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(r,100))}})(),rp=(function(){let n;return function(t){let e=Wl[t];if(e==null){if(xt){let i=Hs(t),r=Zd(t,"\u017Dg");e=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(r.actualBoundingBoxAscent+r.actualBoundingBoxDescent)}else n||(n=document.createElement("div"),n.innerHTML="M",n.style.minHeight="0",n.style.maxHeight="none",n.style.height="auto",n.style.padding="0",n.style.border="none",n.style.position="absolute",n.style.display="block",n.style.left="-99999px"),n.style.font=t,document.body.appendChild(n),e=n.offsetHeight,document.body.removeChild(n);Wl[t]=e}return e}})();function Zd(n,t){return Kr||(Kr=nt(1,1)),n!=Kd&&(Kr.font=n,Kd=Kr.font),Kr.measureText(t)}function Hd(n,t){return Zd(n,t).width}function Xl(n,t,e){if(t in e)return e[t];let i=t.split(`
2
- `).reduce((r,s)=>Math.max(r,Hd(n,s)),0);return e[t]=i,i}function qd(n,t){let e=[],i=[],r=[],s=0,o=0,a=0,l=0;for(let h=0,c=t.length;h<=c;h+=2){let u=t[h];if(u===`
3
- `||h===c){s=Math.max(s,o),r.push(o),o=0,a+=l,l=0;continue}let d=t[h+1]||n.font,f=Hd(d,u);e.push(f),o+=f;let g=rp(d);i.push(g),l=Math.max(l,g)}return{width:s,height:a,widths:e,heights:i,lineWidths:r}}function $d(n,t,e,i,r,s,o,a,l,h,c){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,h),n.scale(c[0],c[1]),sp(i,n)):c[0]<0||c[1]<0?(n.translate(l,h),n.scale(c[0],c[1]),n.drawImage(i,r,s,o,a,0,0,o,a)):n.drawImage(i,r,s,o,a,l,h,o*c[0],a*c[1]),n.restore()}function sp(n,t){let e=n.contextInstructions;for(let i=0,r=e.length;i<r;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}var Ul=class n{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=ft(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new n({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,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 F()}getImage(t){return F()}getHitDetectionImage(){return F()}getPixelRatio(t){return 1}getImageState(){return F()}getImageSize(){return F()}getOrigin(){return F()}getSize(){return F()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=ft(t)}listenImageChange(t){F()}load(){F()}unlistenImageChange(t){F()}ready(){return Promise.resolve()}},go=Ul;var Yl=class n extends go{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?b.LOADING:b.LOADED,this.imageState_===b.LOADING&&this.ready().then(()=>this.imageState_=b.LOADED),this.render()}clone(){let t=this.getScale(),e=new n({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(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){let t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){let e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(","),r=Dt.get(i,null)?.getImage(1);if(!r){let s=this.renderOptions_,o=Math.ceil(s.size*t),a=nt(o,o);this.draw_(s,a,t),r=a.canvas;let l=new Yd(r,void 0,null,b.LOADED,null);Dt.set(i,null,l),createImageBitmap(r).then(h=>{l.setImage(h)})}return r}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let r=this.radius,s=this.radius2_===void 0?r:this.radius2_;if(r<s){let T=r;r=s,s=T}let o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=s*Math.sin(a),h=Math.sqrt(s*s-l*l),c=r-h,u=Math.sqrt(l*l+c*c),d=u/l;if(t==="miter"&&d<=i)return d*e;let f=e/2/d,g=e/2*(c/u),m=Math.sqrt((r+f)*(r+f)+g*g)-r;if(this.radius2_===void 0||t==="bevel")return m*2;let _=r*Math.sin(a),y=Math.sqrt(r*r-_*_),E=s-y,C=Math.sqrt(_*_+E*E)/_;if(C<=i){let T=C*e/2-s-r;return 2*Math.max(m,T)}return m*2}createRenderOptions(){let t=Ve,e=Be,i=0,r=null,s=0,o,a=0;this.stroke_&&(o=Zt(this.stroke_.getColor()??di),a=this.stroke_.getWidth()??gi,r=this.stroke_.getLineDash(),s=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??Be,t=this.stroke_.getLineCap()??Ve,i=this.stroke_.getMiterLimit()??ui);let l=this.calculateLineJoinSize_(e,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:t,lineDash:r,lineDashOffset:s,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();let t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let r=this.fill_.getColor();r===null&&(r=Ct),e.fillStyle=Zt(r),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),r=0;typeof i=="string"&&(i=_e(i)),i===null?r=1:Array.isArray(i)&&(r=i.length===4?i[3]:1),r===0&&(e=nt(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_,i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{let r=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);let s=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let a=0;a<e;a++){let l=s+a*o,h=a%2===0?i:r;t.lineTo(h*Math.cos(l),h*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Ct,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}},mo=Yl;var Kl=class n extends mo{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){let t=this.getScale(),e=new n({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}},Yi=Kl;var Vl=class n{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){let t=this.getColor();return new n({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){let e=Xi(null,t.src,{crossOrigin:"anonymous"},void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===b.IDLE&&e.load(),e.getImageState()===b.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){let t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?U(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:_e(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},Pe=Vl;function Jd(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}var Bl=class n extends go{constructor(t){t=t||{};let e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,r=t.scale!==void 0?t.scale:1,s=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:r,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:s,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy;let o=t.img!==void 0?t.img:null,a=t.src;V(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||U(o)),V(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),V(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=b.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?b.LOADED:b.IDLE:l=b.LOADING:l=b.LOADED),this.color_=t.color!==void 0?_e(t.color):null,this.iconImage_=Xi(o,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let h,c;if(t.size)[h,c]=t.size;else{let u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;let d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;let f=this.iconImage_.getSize();this.setScale(Jd(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(Jd(h,c,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new n({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_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;let r=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!r)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=r[0]),this.anchorYUnits_=="fraction"&&(t[1]*=r[1])}if(this.anchorOrigin_!="top-left"){if(!r)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+r[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+r[1])}this.normalizedAnchor_=t}let e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){let e=t?_e(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((o,a)=>o===e[a]))return;this.color_=e;let i=this.getSrc(),r=i!==void 0?null:this.getHitDetectionImage(),s=i!==void 0?b.IDLE:this.iconImage_.getImageState();this.iconImage_=Xi(r,i,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},s,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){let e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=Xi(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},b.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==b.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){let t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==b.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(L.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(L.CHANGE,t)}ready(){return this.iconImage_.ready()}},Vr=Bl;var Zl=class n{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){let t=this.getColor();return new n({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),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_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}},Ki=Zl;var po=class n{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Qd,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new n({geometry:t??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(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=Qd,this.geometry_=t}setZIndex(t){this.zIndex_=t}};function tf(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(V(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}var Hl=null;function ql(n,t){if(!Hl){let e=new Pe({color:"rgba(255,255,255,0.4)"}),i=new Ki({color:"#3399CC",width:1.25});Hl=[new po({image:new Yi({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return Hl}function Qd(n){return n.getGeometry()}var Ze=po;var op="#333",$l=class n{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=ft(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new Pe({color:op}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new n({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof Pe?this.getFill().clone():this.getFill(),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_}getKeepUpright(){return this.keepUpright_}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(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=ft(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}},ef=$l;function ap(n){return!0}function of(n){let t=Fl(),e=lp(n,t),i=kl();return function(r,s){if(i.properties=r.getPropertiesInternal(),i.resolution=s,t.featureId){let o=r.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=Dl(r.getGeometry())),e(i)}}function th(n){let t=Fl(),e=n.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=Jl(n[o],t);let r=kl(),s=new Array(e);return function(o,a){if(r.properties=o.getPropertiesInternal(),r.resolution=a,t.featureId){let h=o.getId();h!==void 0?r.featureId=h:r.featureId=null}let l=0;for(let h=0;h<e;++h){let c=i[h](r);c&&(s[l]=c,l+=1)}return s.length=l,s}}function lp(n,t){let e=n.length,i=new Array(e);for(let r=0;r<e;++r){let s=n[r],o="filter"in s?Ae(s.filter,Ft,t):ap,a;if(Array.isArray(s.style)){let l=s.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=Jl(s.style[h],t)}else a=[Jl(s.style,t)];i[r]={filter:o,styles:a}}return function(r){let s=[],o=!1;for(let a=0;a<e;++a){let l=i[a].filter;if(l(r)&&!(n[a].else&&o)){o=!0;for(let h of i[a].styles){let c=h(r);c&&s.push(c)}}}return s}}function Jl(n,t){let e=Br(n,"",t),i=Zr(n,"",t),r=hp(n,t),s=cp(n,t),o=At(n,"z-index",t);if(!e&&!i&&!r&&!s&&!$t(n))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(n));let a=new Ze;return function(l){let h=!0;if(e){let c=e(l);c&&(h=!1),a.setFill(c)}if(i){let c=i(l);c&&(h=!1),a.setStroke(c)}if(r){let c=r(l);c&&(h=!1),a.setText(c)}if(s){let c=s(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function Br(n,t,e){let i;if(t+"fill-pattern-src"in n)i=gp(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return s=>null;i=yo(n,t+"fill-color",e)}if(!i)return null;let r=new Pe;return function(s){let o=i(s);return o===ao?null:(r.setColor(o),r)}}function Zr(n,t,e){let i=At(n,t+"stroke-width",e),r=yo(n,t+"stroke-color",e);if(!i&&!r)return null;let s=mi(n,t+"stroke-line-cap",e),o=mi(n,t+"stroke-line-join",e),a=af(n,t+"stroke-line-dash",e),l=At(n,t+"stroke-line-dash-offset",e),h=At(n,t+"stroke-miter-limit",e),c=At(n,t+"stroke-offset",e),u=new Ki;return function(d){if(r){let f=r(d);if(f===ao)return null;u.setColor(f)}if(i&&u.setWidth(i(d)),s){let f=s(d);if(f!=="butt"&&f!=="round"&&f!=="square")throw new Error("Expected butt, round, or square line cap");u.setLineCap(f)}if(o){let f=o(d);if(f!=="bevel"&&f!=="round"&&f!=="miter")throw new Error("Expected bevel, round, or miter line join");u.setLineJoin(f)}return a&&u.setLineDash(a(d)),l&&u.setLineDashOffset(l(d)),h&&u.setMiterLimit(h(d)),c&&u.setOffset(c(d)),u}}function hp(n,t){let e="text-",i=mi(n,e+"value",t);if(!i)return null;let r=Br(n,e,t),s=Br(n,e+"background-",t),o=Zr(n,e,t),a=Zr(n,e+"background-",t),l=mi(n,e+"font",t),h=At(n,e+"max-angle",t),c=At(n,e+"offset-x",t),u=At(n,e+"offset-y",t),d=Yn(n,e+"overflow",t),f=mi(n,e+"placement",t),g=At(n,e+"repeat",t),p=xo(n,e+"scale",t),m=Yn(n,e+"rotate-with-view",t),_=At(n,e+"rotation",t),y=mi(n,e+"align",t),E=mi(n,e+"justify",t),x=mi(n,e+"baseline",t),C=Yn(n,e+"keep-upright",t),T=af(n,e+"padding",t),I=Eo(n,e+"declutter-mode"),S=new ef({declutterMode:I});return function(w){if(S.setText(i(w)),r&&S.setFill(r(w)),s&&S.setBackgroundFill(s(w)),o&&S.setStroke(o(w)),a&&S.setBackgroundStroke(a(w)),l&&S.setFont(l(w)),h&&S.setMaxAngle(h(w)),c&&S.setOffsetX(c(w)),u&&S.setOffsetY(u(w)),d&&S.setOverflow(d(w)),f){let M=f(w);if(M!=="point"&&M!=="line")throw new Error("Expected point or line for text-placement");S.setPlacement(M)}if(g&&S.setRepeat(g(w)),p&&S.setScale(p(w)),m&&S.setRotateWithView(m(w)),_&&S.setRotation(_(w)),y){let M=y(w);if(M!=="left"&&M!=="center"&&M!=="right"&&M!=="end"&&M!=="start")throw new Error("Expected left, right, center, start, or end for text-align");S.setTextAlign(M)}if(E){let M=E(w);if(M!=="left"&&M!=="right"&&M!=="center")throw new Error("Expected left, right, or center for text-justify");S.setJustify(M)}if(x){let M=x(w);if(M!=="bottom"&&M!=="top"&&M!=="middle"&&M!=="alphabetic"&&M!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");S.setTextBaseline(M)}return T&&S.setPadding(T(w)),C&&S.setKeepUpright(C(w)),S}}function cp(n,t){return"icon-src"in n?up(n,t):"shape-points"in n?dp(n,t):"circle-radius"in n?fp(n,t):null}function up(n,t){let e="icon-",i=e+"src",r=lf(n[i],i),s=_o(n,e+"anchor",t),o=xo(n,e+"scale",t),a=At(n,e+"opacity",t),l=_o(n,e+"displacement",t),h=At(n,e+"rotation",t),c=Yn(n,e+"rotate-with-view",t),u=rf(n,e+"anchor-origin"),d=sf(n,e+"anchor-x-units"),f=sf(n,e+"anchor-y-units"),g=pi(n,e+"color"),p,m=null;g!==void 0&&(Array.isArray(g)&&g.length>0&&typeof g[0]=="string"?m=yo(n,e+"color",t):p=hf(g,e+"color"));let _=pp(n,e+"cross-origin"),y=_p(n,e+"offset"),E=rf(n,e+"offset-origin"),x=Ql(n,e+"width"),C=Ql(n,e+"height"),T=mp(n,e+"size"),I=Eo(n,e+"declutter-mode"),S={src:r,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,crossOrigin:_,offset:y,offsetOrigin:E,height:C,width:x,size:T,declutterMode:I},w=null;return function(M){if(w)m&&w.setColor(m(M));else{let N=m?m(M):p;w=new Vr(N!==void 0?Object.assign({},S,{color:N}):Object.assign({},S))}return a&&w.setOpacity(a(M)),l&&w.setDisplacement(l(M)),h&&w.setRotation(h(M)),c&&w.setRotateWithView(c(M)),o&&w.setScale(o(M)),s&&w.setAnchor(s(M)),w}}function dp(n,t){let e="shape-",i=e+"points",r=e+"radius",s=eh(n[i],i);if(!(r in n))throw new Error(`Expected a number for ${r}`);let o=At(n,r,t),a=typeof n[r]=="number"?n[r]:5,l=e+"radius2",h=At(n,l,t),c=typeof n[l]=="number"?n[l]:void 0,u=Br(n,e,t),d=Zr(n,e,t),f=xo(n,e+"scale",t),g=_o(n,e+"displacement",t),p=At(n,e+"rotation",t),m=Yn(n,e+"rotate-with-view",t),_=Ql(n,e+"angle"),y=Eo(n,e+"declutter-mode"),E=new mo({points:s,radius:a,radius2:c,angle:_,declutterMode:y});return function(x){return o&&E.setRadius(o(x)),h&&E.setRadius2(h(x)),u&&E.setFill(u(x)),d&&E.setStroke(d(x)),g&&E.setDisplacement(g(x)),p&&E.setRotation(p(x)),m&&E.setRotateWithView(m(x)),f&&E.setScale(f(x)),E}}function fp(n,t){let e="circle-",i=Br(n,e,t),r=Zr(n,e,t),s=At(n,e+"radius",t),o=xo(n,e+"scale",t),a=_o(n,e+"displacement",t),l=At(n,e+"rotation",t),h=Yn(n,e+"rotate-with-view",t),c=Eo(n,e+"declutter-mode"),u=new Yi({radius:5,declutterMode:c});return function(d){return s&&u.setRadius(s(d)),i&&u.setFill(i(d)),r&&u.setStroke(r(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function pi(n,t){if(!(t in n))return;let e=n[t];return e===void 0?void 0:e}function At(n,t,e){let i=pi(n,t);if(i===void 0)return;let r=Ae(i,J,e);return function(s){return eh(r(s),t)}}function mi(n,t,e){let i=pi(n,t);if(i===void 0)return null;let r=Ae(i,zt,e);return function(s){return lf(r(s),t)}}function gp(n,t,e){let i=mi(n,t+"pattern-src",e),r=nf(n,t+"pattern-offset",e),s=nf(n,t+"pattern-size",e),o=yo(n,t+"color",e);return function(a){return{src:i(a),offset:r&&r(a),size:s&&s(a),color:o&&o(a)}}}function Yn(n,t,e){let i=pi(n,t);if(i===void 0)return null;let r=Ae(i,Ft,e);return function(s){let o=r(s);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${t}`);return o}}function yo(n,t,e){let i=pi(n,t);if(i===void 0)return null;let r=Ae(i,te,e);return function(s){return hf(r(s),t)}}function af(n,t,e){let i=pi(n,t);if(i===void 0)return null;if(Array.isArray(i)&&(i.length===0||typeof i[0]!="string")){let s=i.map((o,a)=>{if(typeof o=="number")return()=>o;let l=Ae(o,J,e);return function(h){return eh(l(h),`${t}[${a}]`)}});return function(o){let a=new Array(s.length);for(let l=0;l<s.length;++l)a[l]=s[l](o);return a}}let r=Ae(i,Wi,e);return function(s){return Hr(r(s),t)}}function _o(n,t,e){let i=pi(n,t);if(i===void 0)return null;let r=Ae(i,Wi,e);return function(s){let o=Hr(r(s),t);if(o.length!==2)throw new Error(`Expected two numbers for ${t}`);return o}}function nf(n,t,e){let i=pi(n,t);if(i===void 0)return null;let r=Ae(i,Wi,e);return function(s){return cf(r(s),t)}}function xo(n,t,e){let i=pi(n,t);if(i===void 0)return null;let r=Ae(i,Wi|J,e);return function(s){return yp(r(s),t)}}function Ql(n,t){let e=n[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function mp(n,t){let e=n[t];if(e!==void 0){if(typeof e=="number")return ft(e);if(!Array.isArray(e))throw new Error(`Expected a number or size array for ${t}`);if(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return e}}function pp(n,t){let e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function rf(n,t){let e=n[t];if(e!==void 0){if(e!=="bottom-left"&&e!=="bottom-right"&&e!=="top-left"&&e!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return e}}function sf(n,t){let e=n[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function _p(n,t){let e=n[t];if(e!==void 0)return Hr(e,t)}function Eo(n,t){let e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);if(e!=="declutter"&&e!=="obstacle"&&e!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return e}}function Hr(n,t){if(!Array.isArray(n))throw new Error(`Expected an array for ${t}`);let e=n.length;for(let i=0;i<e;++i)if(typeof n[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return n}function lf(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function eh(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function hf(n,t){if(typeof n=="string")return n;let e=Hr(n,t),i=e.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function cf(n,t){let e=Hr(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function yp(n,t){return typeof n=="number"?n:cf(n,t)}var uf={RENDER_ORDER:"renderOrder"},ih=class extends ci{constructor(t){t=t||{};let e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(uf.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){let i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new ln(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(uf.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?ql:t;let e=xp(t);this.styleFunction_=t===null?void 0:tf(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}};function xp(n){if(n===void 0)return ql;if(!n)return null;if(typeof n=="function"||n instanceof Ze)return n;if(!Array.isArray(n))return th([n]);if(n.length===0)return[];let t=n.length,e=n[0];if(e instanceof Ze){let r=new Array(t);for(let s=0;s<t;++s){let o=n[s];if(!(o instanceof Ze))throw new Error("Expected a list of style instances");r[s]=o}return r}if("style"in e){let r=new Array(t);for(let s=0;s<t;++s){let o=n[s];if(!("style"in o))throw new Error("Expected a list of rules with a style property");r[s]=o}return of(r)}return th(n)}var Co=ih;var nh=class extends mt{constructor(t,e,i,r){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=r}},Ro=nh;var rh=class extends Ci{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){F()}calculateMatrices2D(t){let e=t.viewState,i=t.coordinateToPixelTransform,r=t.pixelToCoordinateTransform;Et(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Gs(r,i)}forEachFeatureAtCoordinate(t,e,i,r,s,o,a,l){let h,c=e.viewState;function u(x,C,T,I){return s.call(o,C,x?T:null,I)}let d=c.projection,f=Tn(t.slice(),d),g=[[0,0]];if(d.canWrapX()&&r){let x=d.getExtent(),C=W(x);g.push([-C,0],[C,0])}let p=e.layerStatesArray,m=p.length,_=[],y=[];for(let x=0;x<g.length;x++)for(let C=m-1;C>=0;--C){let T=p[C],I=T.layer;if(I.hasRenderer()&&Pr(T,c)&&a.call(l,I)){let S=I.getRenderer(),w=I.getSource();if(S&&w){let M=w.getWrapX()?f:t,N=u.bind(null,T.managed);y[0]=M[0]+g[x][0],y[1]=M[1]+g[x][1],h=S.forEachFeatureAtCoordinate(y,e,i,N,_)}if(h)return h}}if(_.length===0)return;let E=1/_.length;return _.forEach((x,C)=>x.distanceSq+=C*E),_.sort((x,C)=>x.distanceSq-C.distanceSq),_.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(t,e,i,r,s,o){return this.forEachFeatureAtCoordinate(t,e,i,r,ei,this,s,o)!==void 0}getMap(){return this.map_}renderFrame(t){F()}scheduleExpireIconCache(t){Dt.canExpireCache()&&t.postRenderFunctions.push(Ep)}};function Ep(n,t){Dt.expire()}var df=rh;var sh=class extends df{constructor(t){super(t),this.fontChangeListenerKey_=G(cn,Ee.PROPERTYCHANGE,t.redrawText,t),this.element_=xt?qs():document.createElement("div");let e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=ge+" ol-layers";let i=t.getViewport();i&&i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){let i=this.getMap();if(i.hasListener(t)){let r=new Ro(t,void 0,e);i.dispatchEvent(r)}}disposeInternal(){B(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(Lt.PRECOMPOSE,t);let e=t.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);e.some(h=>h.layer instanceof Co&&h.layer.getDeclutter())&&(t.declutter={});let r=t.viewState;this.children_.length=0;let s=[],o=null;for(let h=0,c=e.length;h<c;++h){let u=e[h];t.layerIndex=h;let d=u.layer,f=d.getSourceState();if(!Pr(u,r)||f!="ready"&&f!="undefined"){d.unrender();continue}let g=d.render(t,o);g&&(g!==o&&(this.children_.push(g),o=g),s.push(u))}this.declutter(t,s),pd(this.element_,this.children_);let l=this.getMap().getTargetElement();if(Me(l)){let h=l.getContext("2d");for(let c of this.children_){let u=c.firstElementChild||c,d=c.style.backgroundColor;if(d&&(!Me(u)||u.width>0)&&(h.fillStyle=d,h.fillRect(0,0,l.width,l.height)),Me(u)&&u.width>0){h.save();let f=c.style.opacity||u.style.opacity;h.globalAlpha=f===""?1:Number(f);let g=u.style.transform;if(g)h.transform(...Ns(g));else{let p=parseFloat(u.style.width)/u.width,m=parseFloat(u.style.height)/u.height;h.transform(p,0,0,m,0,0)}h.drawImage(u,0,0),h.restore()}}}this.dispatchRenderEvent(Lt.POSTCOMPOSE,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let i=e.length-1;i>=0;--i){let r=e[i],s=r.layer;s.getDeclutter()&&s.renderDeclutter(t,r)}e.forEach(i=>i.layer.renderDeferred(t))}}},ff=sh;function gf(n){if(n instanceof ci){n.setMapInternal(null);return}n instanceof Ar&&n.getLayers().forEach(gf)}function mf(n,t){if(n instanceof ci){n.setMapInternal(t);return}if(n instanceof Ar){let e=n.getLayers().getArray();for(let i=0,r=e.length;i<r;++i)mf(e[i],t)}}var oh=class extends pt{constructor(t){super(),t=t||{},this.on,this.once,this.un;let e=Cp(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=t.maxTilesLoading!==void 0?t.maxTilesLoading:16,this.pixelRatio_=t.pixelRatio!==void 0?t.pixelRatio:iu,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Tt(),this.pixelToCoordinateTransform_=Tt(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,xt||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,xt||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=e.controls||(xt?new Mt:kn()),this.interactions=e.interactions||(xt?new Mt:jn({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new su(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(_t.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(_t.VIEW,this.handleViewChanged_),this.addChangeListener(_t.SIZE,this.handleSizeChanged_),this.addChangeListener(_t.TARGET,this.handleTargetChanged_),this.setProperties(e.values);let i=this;t.view&&!(t.view instanceof Bt)&&t.view.then(function(r){i.setView(new Bt(r))}),this.controls.addEventListener(wt.ADD,r=>{r.element.setMap(this)}),this.controls.addEventListener(wt.REMOVE,r=>{r.element.setMap(null)}),this.interactions.addEventListener(wt.ADD,r=>{r.element.setMap(this)}),this.interactions.addEventListener(wt.REMOVE,r=>{r.element.setMap(null)}),this.overlays_.addEventListener(wt.ADD,r=>{this.addOverlayInternal_(r.element)}),this.overlays_.addEventListener(wt.REMOVE,r=>{let s=r.element.getId();s!==void 0&&delete this.overlayIdIndex_[s.toString()],r.element.setMap(null)}),this.controls.forEach(r=>{r.setMap(this)}),this.interactions.forEach(r=>{r.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){mf(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){let e=t.getId();e!==void 0&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;let r=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};let s=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:ei,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(r,this.frameState_,s,a,e,null,o,null)}getFeaturesAtPixel(t,e){let i=[];return this.forEachFeatureAtPixel(t,function(r){i.push(r)},e),i}getAllLayers(){let t=[];function e(i){i.forEach(function(r){r instanceof Ar?e(r.getLayers()):t.push(r)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;let i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};let r=e.layerFilter!==void 0?e.layerFilter:ei,s=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,s,o,r,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){let i=this.viewport_.getBoundingClientRect(),r=this.getSize(),s=i.width/r[0],o=i.height/r[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/s,(a.clientY-i.top)/o]}getTarget(){return this.get(_t.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return gr(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){let e=this.frameState_;return e?ht(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){let e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(_t.LAYERGROUP)}setLayers(t){let e=this.getLayerGroup();if(t instanceof Mt){e.setLayers(t);return}let i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){let t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){let r=t[e];if(!r.visible)continue;let s=r.layer.getRenderer();if(s&&!s.ready)return!0;let o=r.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(t){let e=Ie(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){let e=this.frameState_;return e?ht(e.coordinateToPixelTransform,t.slice(0,2)):null}getPixelRatio(){return this.pixelRatio_}setPixelRatio(t){this.pixelRatio_!==t&&(this.pixelRatio_=t,this.render())}getRenderer(){return this.renderer_}getSize(){return this.get(_t.SIZE)}getView(){return this.get(_t.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){let t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,r){return ou(this.frameState_,t,e,i,r)}handleBrowserEvent(t,e){e=e||t.type;let i=new We(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;let e=t.originalEvent,i=e.type;if(i===Si.POINTERDOWN||i===L.WHEEL||i===L.KEYDOWN){let r=this.getOwnerDocument(),s=this.viewport_.getRootNode?this.viewport_.getRootNode():r,o=e.target,a=s instanceof ShadowRoot?s.host===o?s.host.ownerDocument:s:s===r?r.documentElement:s;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){let r=this.getInteractions().getArray().slice();for(let s=r.length-1;s>=0;s--){let o=r[s];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){let t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let r=this.maxTilesLoading_,s=r;if(t){let o=t.viewHints;if(o[dt.ANIMATING]||o[dt.INTERACTING]){let a=Date.now()-t.time>8;r=a?0:8,s=a?0:2}}e.getTilesLoading()<r&&(e.reprioritize(),e.loadMoreTiles(r,s))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Lt.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Lt.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new wi(Xe.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new wi(Xe.LOADSTART,this,t))));let i=this.postRenderFunctions_;if(t)for(let r=0,s=i.length;r<s;++r)i[r](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,r=this.targetChangeHandlerKeys_.length;i<r;++i)B(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(L.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(L.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!Me(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);let i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}let t=this.getTarget(),e=typeof t=="string"?document.getElementById(t):t;if(this.targetElement_=e,!e)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{if(Me(e)||e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new ff(this)),!Me(e)){this.mapBrowserEventHandler_=new nu(this,this.moveTolerance_);for(let r in at)this.mapBrowserEventHandler_.addEventListener(at[r],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(L.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(L.WHEEL,this.boundHandleBrowserEvent_,Es?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{let r=e.getRootNode();i=r instanceof ShadowRoot?r.host:e}if(this.targetChangeHandlerKeys_=[G(i,L.KEYDOWN,this.handleBrowserEvent,this),G(i,L.KEYPRESS,this.handleBrowserEvent,this)],e instanceof HTMLElement){let r=e.getRootNode();r instanceof ShadowRoot&&this.resizeObserver_.observe(r.host),this.resizeObserver_?.observe(e)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(B(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(B(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);let t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=G(t,Ee.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=G(t,L.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(B),this.layerGroupPropertyListenerKeys_=null);let t=this.getLayerGroup();t&&(this.handleLayerAdd_(new be("addlayer",t)),this.layerGroupPropertyListenerKeys_=[G(t,Ee.PROPERTYCHANGE,this.render,this),G(t,L.CHANGE,this.render,this),G(t,"addlayer",this.handleLayerAdd_,this),G(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;let t=this.frameState_.layerStatesArray;for(let e=0,i=t.length;e<i;++e){let r=t[e].layer;r.hasRenderer()&&r.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){gf(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){let e=this.getSize(),i=this.getView(),r=this.frameState_,s=null;if(e!==void 0&&Ll(e)&&i&&i.isDef()){let o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(s={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:oi(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:U(this),renderTargets:{}},a.nextCenter&&a.nextResolution){let l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;s.nextExtent=oi(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=s,this.renderer_.renderFrame(s),s&&(s.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,s.postRenderFunctions),r&&(!this.previousExtent_||!Yt(this.previousExtent_)&&!we(s.extent,this.previousExtent_))&&(this.dispatchEvent(new wi(Xe.MOVESTART,this,r)),this.previousExtent_=si(this.previousExtent_)),this.previousExtent_&&!s.viewHints[dt.ANIMATING]&&!s.viewHints[dt.INTERACTING]&&!we(s.extent,this.previousExtent_)&&(this.dispatchEvent(new wi(Xe.MOVEEND,this,s)),Ss(s.extent,this.previousExtent_))),this.dispatchEvent(new wi(Xe.POSTRENDER,this,s)),this.renderComplete_=(this.hasListener(Xe.LOADSTART)||this.hasListener(Xe.LOADEND)||this.hasListener(Lt.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){let e=this.getLayerGroup();e&&this.handleLayerRemove_(new be("removelayer",e)),this.set(_t.LAYERGROUP,t)}setSize(t){this.set(_t.SIZE,t)}setTarget(t){this.set(_t.TARGET,t)}setView(t){if(!t||t instanceof Bt){this.set(_t.VIEW,t);return}this.set(_t.VIEW,new Bt);let e=this;t.then(function(i){e.setView(new Bt(i))})}updateSize(){let t=this.getTargetElement(),e;if(t){let r,s;if(Me(t)){let o=t.getContext("2d").getTransform();r=t.width/o.a,s=t.height/o.d}else{let o=getComputedStyle(t);r=t.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),s=t.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(r)&&!isNaN(s)&&(e=[Math.max(0,r),Math.max(0,s)],!Ll(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&bs("No map visible because the map container's width or height are 0."))}let i=this.getSize();e&&(!i||!Ot(e,i))&&(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){let e=this.getView();e&&e.setViewportSize(t)}};function Cp(n){let t=null;n.keyboardEventTarget!==void 0&&(t=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);let e={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new Ar({layers:n.layers});e[_t.LAYERGROUP]=i,e[_t.TARGET]=n.target,e[_t.VIEW]=n.view instanceof Bt?n.view:new Bt;let r;n.controls!==void 0&&(Array.isArray(n.controls)?r=new Mt(n.controls.slice()):(V(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),r=n.controls));let s;n.interactions!==void 0&&(Array.isArray(n.interactions)?s=new Mt(n.interactions.slice()):(V(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),s=n.interactions));let o;return n.overlays!==void 0?Array.isArray(n.overlays)?o=new Mt(n.overlays.slice()):(V(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new Mt,{controls:r,interactions:s,keyboardEventTarget:t,overlays:o,values:e}}var ah=oh;var lh=class extends je{constructor(t,e,i){super(),i=i||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(L.CHANGE)}release(){this.setState(O.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==O.EMPTY){if(this.state!==O.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){F()}getAlpha(t,e){if(!this.transition_)return 1;let i=this.transitionStarts_[t];if(!i)i=e,this.transitionStarts_[t]=i;else if(i===-1)return 1;let r=e-i+1e3/60;return r>=this.transition_?1:ya(r/this.transition_)}inTransition(t){return this.transition_?this.transitionStarts_[t]!==-1:!1}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}},Kn=lh;function wo(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}var Rp=new Error("disposed");var wp=[256,256],hh=class extends Kn{constructor(t){let e=O.IDLE;super(t.tileCoord,e,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;let t=wo(this.data_);return t?[t.width,t.height]:wp}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==O.IDLE&&this.state!==O.ERROR)return;this.state=O.LOADING,this.changed();let t=this;this.loader_().then(function(e){t.data_=e,t.state=O.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=O.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(Rp),this.controller_=null),super.disposeInternal()}},ch=hh;var uh=class extends Kn{constructor(t,e,i,r,s,o){super(t,e,o),this.crossOrigin_=r?.crossOrigin,this.referrerPolicy_=r?.referrerPolicy,this.src_=i,this.key=i,this.image_,xt?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=s}getImage(){return this.image_}setImage(t){this.image_=t,this.state=O.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=O.ERROR,this.unlistenImage_(),this.image_=Sp(),this.changed()}handleImageLoad_(){if(xt)this.state=O.LOADED;else{let t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=O.LOADED:this.state=O.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==O.ERROR&&(this.state=O.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==O.IDLE&&(this.state=O.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=Ud(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}};function Sp(){let n=nt(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}var So=uh;var To=class{constructor(t,e,i,r){this.minX=t,this.maxX=e,this.minY=i,this.maxY=r}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}};function dn(n,t,e,i,r){return r!==void 0?(r.minX=n,r.maxX=t,r.minY=e,r.maxY=i,r):new To(n,t,e,i)}var vo=To;var dh,fn=[];function pf(n,t,e,i,r){n.beginPath(),n.moveTo(0,0),n.lineTo(t,e),n.lineTo(i,r),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(t,i)+1,Math.max(e,r)),n.restore()}function fh(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function Tp(){if(dh===void 0){let n=nt(6,6,fn);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",pf(n,4,5,4,0),pf(n,4,5,0,5);let t=n.getImageData(0,0,3,3).data;dh=fh(t,0)||fh(t,4)||fh(t,8),on(n),fn.push(n.canvas)}return dh}function Vi(n,t,e,i){let r=de(e,t,n),s=An(t,i,e),o=t.getMetersPerUnit();o!==void 0&&(s*=o);let a=n.getMetersPerUnit();a!==void 0&&(s/=a);let l=n.getExtent();if(!l||Jt(l,r)){let h=An(n,s,r)/s;isFinite(h)&&h>0&&(s/=h)}return s}function _f(n,t,e,i){let r=St(e),s=Vi(n,t,r,i);return(!isFinite(s)||s<=0)&&Is(e,function(o){return s=Vi(n,t,o,i),isFinite(s)&&s>0}),s}function Io(n,t,e,i,r,s,o,a,l,h,c,u,d,f){let g=nt(Math.round(e*n),Math.round(e*t),fn);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function p(C){return Math.round(C*e)/e}g.globalCompositeOperation="lighter";let m=ct();l.forEach(function(C,T,I){vs(m,C.extent)});let _,y=e/i,E=(u?1:1+Math.pow(2,-24))/y;if(!d||l.length!==1||h!==0){if(_=nt(Math.round(W(m)*y),Math.round(et(m)*y),fn),u||(_.imageSmoothingEnabled=!1),r&&f){let C=(r[0]-m[0])*y,T=-(r[3]-m[3])*y,I=W(r)*y,S=et(r)*y;_.rect(C,T,I,S),_.clip()}l.forEach(function(C,T,I){if(C.image.width>0&&C.image.height>0){if(C.clipExtent){_.save();let z=(C.clipExtent[0]-m[0])*y,A=-(C.clipExtent[3]-m[3])*y,H=W(C.clipExtent)*y,$=et(C.clipExtent)*y;_.rect(u?z:Math.round(z),u?A:Math.round(A),u?H:Math.round(z+H)-Math.round(z),u?$:Math.round(A+$)-Math.round(A)),_.clip()}let S=(C.extent[0]-m[0])*y,w=-(C.extent[3]-m[3])*y,M=W(C.extent)*y,N=et(C.extent)*y;_.drawImage(C.image,h,h,C.image.width-2*h,C.image.height-2*h,u?S:Math.round(S),u?w:Math.round(w),u?M:Math.round(S+M)-Math.round(S),u?N:Math.round(w+N)-Math.round(w)),C.clipExtent&&_.restore()}})}let x=he(o);return a.getTriangles().forEach(function(C,T,I){let S=C.source,w=C.target,M=S[0][0],N=S[0][1],z=S[1][0],A=S[1][1],H=S[2][0],$=S[2][1],P=p((w[0][0]-x[0])/s),j=p(-(w[0][1]-x[1])/s),k=p((w[1][0]-x[0])/s),K=p(-(w[1][1]-x[1])/s),X=p((w[2][0]-x[0])/s),tt=p(-(w[2][1]-x[1])/s),it=M,ot=N;M=0,N=0,z-=it,A-=ot,H-=it,$-=ot;let kt=[[z,A,0,0,k-P],[H,$,0,0,X-P],[0,0,z,A,K-j],[0,0,H,$,tt-j]],v=lu(kt);if(!v)return;if(g.save(),g.beginPath(),Tp()||!u){g.moveTo(k,K);let Rt=4,ye=P-k,De=j-K;for(let ne=0;ne<Rt;ne++)g.lineTo(k+p((ne+1)*ye/Rt),K+p(ne*De/(Rt-1))),ne!=Rt-1&&g.lineTo(k+p((ne+1)*ye/Rt),K+p((ne+1)*De/(Rt-1)));g.lineTo(X,tt)}else g.moveTo(k,K),g.lineTo(P,j),g.lineTo(X,tt);g.clip(),g.transform(v[0],v[2],v[1],v[3],P,j),g.translate(m[0]-it,m[3]-ot);let ie;if(_)ie=_.canvas,g.scale(E,-E);else{let Rt=l[0],ye=Rt.extent;ie=Rt.image,g.scale(W(ye)/ie.width,-et(ye)/ie.height)}g.drawImage(ie,0,0),g.restore()}),_&&(on(_),fn.push(_.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(C,T,I){let S=C.target,w=(S[0][0]-x[0])/s,M=-(S[0][1]-x[1])/s,N=(S[1][0]-x[0])/s,z=-(S[1][1]-x[1])/s,A=(S[2][0]-x[0])/s,H=-(S[2][1]-x[1])/s;g.beginPath(),g.moveTo(N,z),g.lineTo(w,M),g.lineTo(A,H),g.closePath(),g.stroke()}),g.restore()),g.canvas}var vp=10,yf=.25,gh=class{constructor(t,e,i,r,s,o,a){this.sourceProj_=t,this.targetProj_=e;let l={},h=a?ju(E=>ht(a,de(E,this.targetProj_,this.sourceProj_))):li(this.targetProj_,this.sourceProj_);this.transformInv_=function(E){let x=E[0]+"/"+E[1];return l[x]||(l[x]=h(E)),l[x]},this.maxSourceExtent_=r,this.errorThresholdSquared_=s*s,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!r&&!!this.sourceProj_.getExtent()&&W(r)>=W(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?W(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?W(this.targetProj_.getExtent()):null;let c=he(i),u=wn(i),d=Rn(i),f=Cn(i),g=this.transformInv_(c),p=this.transformInv_(u),m=this.transformInv_(d),_=this.transformInv_(f),y=vp+(o?Math.max(0,Math.ceil(Math.log2(cr(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,p,m,_,y),this.wrapsXInSource_){let E=1/0;this.triangles_.forEach(function(x,C,T){E=Math.min(E,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-E>this.sourceWorldWidth_/2){let C=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];C[0][0]-E>this.sourceWorldWidth_/2&&(C[0][0]-=this.sourceWorldWidth_),C[1][0]-E>this.sourceWorldWidth_/2&&(C[1][0]-=this.sourceWorldWidth_),C[2][0]-E>this.sourceWorldWidth_/2&&(C[2][0]-=this.sourceWorldWidth_);let T=Math.min(C[0][0],C[1][0],C[2][0]);Math.max(C[0][0],C[1][0],C[2][0])-T<this.sourceWorldWidth_/2&&(x.source=C)}})}l={}}addTriangle_(t,e,i,r,s,o){this.triangles_.push({source:[r,s,o],target:[t,e,i]})}addQuad_(t,e,i,r,s,o,a,l,h){let c=ga([s,o,a,l]),u=this.sourceWorldWidth_?W(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1,g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){let m=ga([t,e,i,r]);g=W(m)/this.targetWorldWidth_>yf||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>yf||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!lt(c,this.maxSourceExtent_))return;let p=0;if(!g&&(!isFinite(s[0])||!isFinite(s[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(h>0)g=!0;else if(p=(!isFinite(s[0])||!isFinite(s[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),p!=1&&p!=2&&p!=4&&p!=8)return}if(h>0){if(!g){let m=[(t[0]+i[0])/2,(t[1]+i[1])/2],_=this.transformInv_(m),y;f?y=(Wt(s[0],d)+Wt(a[0],d))/2-Wt(_[0],d):y=(s[0]+a[0])/2-_[0];let E=(s[1]+a[1])/2-_[1];g=y*y+E*E>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){let m=[(e[0]+i[0])/2,(e[1]+i[1])/2],_=this.transformInv_(m),y=[(r[0]+t[0])/2,(r[1]+t[1])/2],E=this.transformInv_(y);this.addQuad_(t,e,m,y,s,o,_,E,h-1),this.addQuad_(y,m,i,r,E,_,a,l,h-1)}else{let m=[(t[0]+e[0])/2,(t[1]+e[1])/2],_=this.transformInv_(m),y=[(i[0]+r[0])/2,(i[1]+r[1])/2],E=this.transformInv_(y);this.addQuad_(t,m,y,r,s,_,E,l,h-1),this.addQuad_(m,e,i,y,_,o,a,E,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(p&11)==0&&this.addTriangle_(t,i,r,s,a,l),(p&14)==0&&this.addTriangle_(t,i,e,s,a,o),p&&((p&13)==0&&this.addTriangle_(e,r,t,o,l,s),(p&7)==0&&this.addTriangle_(e,r,i,o,l,a))}calculateSourceExtent(){let t=ct();return this.triangles_.forEach(function(e,i,r){let s=e.source;Qi(t,s[0]),Qi(t,s[1]),Qi(t,s[2])}),t}getTriangles(){return this.triangles_}},Mo=gh;var mh=class extends Kn{constructor(t,e,i,r,s,o,a,l,h,c,u,d){super(s,O.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=r,this.wrappedTileCoord_=o||s,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;let f=r.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent(),p=this.sourceTileGrid_.getExtent(),m=g?Ut(f,g):f;if(cr(m)===0){this.state=O.EMPTY;return}let _=t.getExtent();_&&(p?p=Ut(p,_):p=_);let y=r.getResolution(this.wrappedTileCoord_[0]),E=_f(t,i,m,y);if(!isFinite(E)||E<=0){this.state=O.EMPTY;return}let x=c!==void 0?c:.5;if(this.triangulation_=new Mo(t,i,m,p,E*x,y),this.triangulation_.getTriangles().length===0){this.state=O.EMPTY;return}this.sourceZ_=e.getZForResolution(E);let C=this.triangulation_.calculateSourceExtent();if(p&&(t.canWrapX()?(C[1]=Q(C[1],p[1],p[3]),C[3]=Q(C[3],p[1],p[3])):C=Ut(C,p)),!cr(C))this.state=O.EMPTY;else{let T=0,I=0;t.canWrapX()&&(T=W(_),I=Math.floor((C[0]-_[0])/T)),Ms(C.slice(),t,!0).forEach(w=>{let M=e.getTileRangeForExtentAndZ(w,this.sourceZ_);for(let N=M.minX;N<=M.maxX;N++)for(let z=M.minY;z<=M.maxY;z++){let A=I*T;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,N,z,a),offset:A})}++I}),this.sourceTiles_.length===0&&(this.state=O.EMPTY)}}getImage(){return this.canvas_}reproject_(){let t=[];if(this.sourceTiles_.forEach(e=>{let i=e.tile;if(i&&i.getState()==O.LOADED){let r=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);r[0]+=e.offset,r[2]+=e.offset;let s=this.clipExtent_?.slice();s&&(s[0]+=e.offset,s[2]+=e.offset),t.push({extent:r,clipExtent:s,image:i.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=O.ERROR;else{let e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),r=typeof i=="number"?i:i[0],s=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(e),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=Io(r,s,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=O.LOADED}this.changed()}load(){for(let t of this.sourceTiles_)t.tile=t.getTile();if(this.state==O.IDLE){this.state=O.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{let i=e.getState();if(i==O.IDLE||i==O.LOADING){t++;let r=G(e,L.CHANGE,s=>{let o=e.getState();(o==O.LOADED||o==O.ERROR||o==O.EMPTY)&&(B(r),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(r)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},i,r){e.getState()==O.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(B),this.sourcesListenerKeys_=null}release(){this.canvas_&&(on(this.canvas_.getContext("2d")),fn.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},bo=mh;var ph=class{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){let t=this.pop();t instanceof Ci&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){let i=this.entries_[t];return V(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(t){let e=this.entries_[t];return V(e!==void 0,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){let t=new Array(this.count_),e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.key_;return t}getValues(){let t=new Array(this.count_),e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){let t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){V(!(t in this.entries_),"Tried to set a value for a key that is used already");let i={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[t]=i,++this.count_}setSize(t){this.highWaterMark=t}},_h=ph;function Vn(n,t,e,i){return i!==void 0?(i[0]=n,i[1]=t,i[2]=e,i):[n,t,e]}function Mp(n,t,e){return n+"/"+t+"/"+e}function Bn(n,t,e,i,r){return`${U(n)},${t},${Mp(e,i,r)}`}function Lo(n){return bp(n[0],n[1],n[2])}function bp(n,t,e){return(t<<n)+e}function xf(n,t){let e=n[0],i=n[1],r=n[2];if(t.getMinZoom()>e||e>t.getMaxZoom())return!1;let s=t.getFullTileRange(e);return s?s.containsXY(i,r):!0}var yh=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Fn(),{get:(t,e)=>{if(typeof Fn()[e]=="function")return this.push_(e),this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){let e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushMethodArgs_=(...t)=>(this.push_(t),this);pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,r=e.length;i<r;++i){let s=e[i];if(typeof s=="function"){s(t);continue}let o=e[++i];if(typeof t[s]=="function")t[s](...o);else{if(typeof o=="function"){t[s]=o(t);continue}t[s]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},Ao=yh;var Lp=5,xh=class extends _s{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=Lp}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return F()}getData(t){return null}prepareFrame(t){return F()}renderFrame(t,e){return F()}forEachFeatureAtCoordinate(t,e,i,r,s){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){let e=t.target;(e.getState()===b.LOADED||e.getState()===b.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=b.LOADED&&e!=b.ERROR&&t.addEventListener(L.CHANGE,this.boundHandleImageChange_),e==b.IDLE&&(t.load(),e=t.getState()),e==b.LOADED}renderIfReadyAndVisible(){let t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}},Ef=xh;var Ch=[],Zn=null;function Ap(){Zn=nt(1,1,void 0,{willReadFrequently:!0})}var Eh=class extends Ef{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=Tt(),this.pixelTransform=Tt(),this.inversePixelTransform=Tt(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){Zn||Ap(),Zn.clearRect(0,0,1,1);let r;try{Zn.drawImage(t,e,i,1,1,0,0,1,1),r=Zn.getImageData(0,0,1,1).data}catch{return Zn=null,null}return r}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i){let r=this.getLayer().getClassName(),s,o;if(t&&t.className===r&&(!i||t&&t.style.backgroundColor&&Ot(_e(t.style.backgroundColor),_e(i)))){let a=t.firstElementChild;Me(a)&&(o=a.getContext("2d"))}if(o&&Ku(o.canvas.style.transform,e)?(this.container=t,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){s=xt?qs():document.createElement("div"),s.className=r;let a=s.style;a.position="absolute",a.width="100%",a.height="100%",o=nt();let l=o.canvas;s.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=s,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){let r=he(i),s=wn(i),o=Rn(i),a=Cn(i);ht(e.coordinateToPixelTransform,r),ht(e.coordinateToPixelTransform,s),ht(e.coordinateToPixelTransform,o),ht(e.coordinateToPixelTransform,a);let l=this.inversePixelTransform;ht(l,r),ht(l,s),ht(l,o),ht(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()}prepareContainer(t,e){let i=t.extent,r=t.viewState.resolution,s=t.viewState.rotation,o=t.pixelRatio,a=Math.round(W(i)/r*o),l=Math.round(et(i)/r*o);Et(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,s,-a/2,-l/2),Gs(this.inversePixelTransform,this.pixelTransform);let h=Yu(this.pixelTransform);if(this.useContainer(e,h,this.getBackground(t)),!this.containerReused){let c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(t,e,i){let r=this.getLayer();if(r.hasListener(t)){let s=new Ro(t,this.inversePixelTransform,i,e);r.dispatchEvent(s)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Lt.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Lt.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new Ao),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Lt.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Lt.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,r,s,o,a){let l=s/2,h=o/2,c=r/e,u=-c,d=-t[0]+a,f=-t[1];return Et(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}},Hn=Eh;function Rh(n,t,e){if(!(e in n))return n[e]=new Set([t]),!0;let i=n[e],r=i.has(t);return r||i.add(t),!r}function Pp(n,t,e){let i=n[e];return i?i.delete(t):!1}function Cf(n,t){let e=n.layerStatesArray[n.layerIndex];e.extent&&(t=Ut(t,Gt(e.extent,n.viewState.projection)));let i=e.layer.getRenderSource();if(!i.getWrapX()){let r=i.getTileGridForProjection(n.viewState.projection).getExtent();r&&(t=Ut(t,r))}return t}var wh=class extends Hn{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=ct(),this.tempTileRange_=new vo(0,0,0,0),this.tempTileCoord_=Vn(0,0,0);let i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new _h(i),this.sourceTileCache_=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new _h(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,r){let s=this.tileCache_,a=this.getLayer().getSource(),l=Bn(a,a.getKey(),t,e,i),h;if(s.containsKey(l))h=s.get(l);else{let c=r.viewState.projection,u=a.getProjection();if(h=a.getTile(t,e,i,r.pixelRatio,c,!u||ve(u,c)?void 0:this.getSourceTileCache()),!h)return null;s.set(l,h)}return h}getTile(t,e,i,r){let s=this.getOrCreateTile(t,e,i,r);return s||null}getData(t){let e=this.frameState;if(!e)return null;let i=this.getLayer(),r=ht(e.pixelToCoordinateTransform,t.slice()),s=i.getExtent();if(s&&!Jt(s,r))return null;let o=e.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(e.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){let u=l.getTileCoordForCoordAndZ(r,c),d=this.getTile(c,u[1],u[2],e);if(!d||d.getState()!==O.LOADED)continue;let f=l.getOrigin(c),g=ft(l.getTileSize(c)),p=l.getResolution(c),m;if(d instanceof So||d instanceof bo)m=d.getImage();else if(d instanceof ch){if(m=wo(d.getData()),!m)continue}else continue;let _=Math.floor(h*((r[0]-f[0])/p-u[1]*g[0])),y=Math.floor(h*((f[1]-r[1])/p-u[2]*g[1])),E=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(m,_+E,y+E)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;let e=this.getLayer().getSource();if(!e)return!1;let i=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,i,r,s){let o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=U(l);c in t.wantedTiles||(t.wantedTiles[c]={});let u=t.wantedTiles[c],d=a.getMapInternal(),f=Math.max(i-s,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,p=g?pa(o.center,o.resolution,g,t.size):void 0;for(let m=i;m>=f;--m){let _=h.getTileRangeForExtentAndZ(e,m,this.tempTileRange_),y=h.getResolution(m);for(let E=_.minX;E<=_.maxX;++E)for(let x=_.minY;x<=_.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([m,E,x],p))continue;let C=this.getTile(m,E,x,t);if(!C||!Rh(r,C,m))continue;let I=C.getKey();if(u[I]=!0,C.getState()===O.IDLE&&!t.tileQueue.isKeyQueued(I)){let S=Vn(m,E,x,this.tempTileCoord_);t.tileQueue.enqueue([C,c,h.getTileCoordCenter(S),y])}}}}findStaleTile_(t,e){let i=this.tileCache_,r=t[0],s=t[1],o=t[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){let h=Bn(this.getLayer().getSource(),a[l],r,s,o);if(i.containsKey(h)){let c=i.peek(h);if(c.getState()===O.LOADED)return c.endTransition(U(this)),Rh(e,c,r),!0}}return!1}findAltTiles_(t,e,i,r){let s=t.getTileRangeForTileCoordAndZ(e,i,this.tempTileRange_);if(!s)return!1;let o=!0,a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=s.minX;c<=s.maxX;++c)for(let u=s.minY;u<=s.maxY;++u){let d=Bn(l,h,i,c,u),f=!1;if(a.containsKey(d)){let g=a.peek(d);g.getState()===O.LOADED&&(Rh(r,g,i),f=!0)}f||(o=!1)}return o}renderFrame(t,e){this.renderComplete=!0;let i=t.layerStatesArray[t.layerIndex],r=t.viewState,s=r.projection,o=r.resolution,a=r.center,l=t.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(s),d=u.getZForResolution(o,c.zDirection),f=u.getResolution(d),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let p=t.extent,m=c.getTilePixelRatio(l);this.prepareContainer(t,e);let _=this.context.canvas.width,y=this.context.canvas.height,E=i.extent&&Gt(i.extent,s);E&&(p=Ut(p,Gt(i.extent,s)));let x=f*_/2/m,C=f*y/2/m,T=[a[0]-x,a[1]-C,a[0]+x,a[1]+C],I={};this.renderedTiles.length=0;let S=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){let k=u.getZForResolution(r.nextResolution,c.zDirection),K=Cf(t,t.nextExtent);this.enqueueTiles(t,K,k,I,S)}let w=Cf(t,p);if(this.enqueueTiles(t,w,d,I,0),S>0&&setTimeout(()=>{this.enqueueTiles(t,w,d-1,I,S-1)},0),!(d in I))return this.container;let M=U(this),N=t.time;for(let k of I[d]){let K=k.getState();if(K===O.EMPTY)continue;let X=k.tileCoord;if(K===O.LOADED&&k.getAlpha(M,N)===1){k.endTransition(M);continue}if(K!==O.ERROR&&(this.renderComplete=!1),this.findStaleTile_(X,I)){Pp(I,k,d),t.animate=!0;continue}if(this.findAltTiles_(u,X,d+1,I))continue;let ot=u.getMinZoom();for(let kt=d-1;kt>=ot&&!this.findAltTiles_(u,X,kt,I);--kt);}let z=f/o*l/m,A=this.getRenderContext(t);Et(this.tempTransform,_/2,y/2,z,z,0,-_/2,-y/2),i.extent&&this.clipUnrotated(A,t,E),c.getInterpolate()||(A.imageSmoothingEnabled=!1),this.preRender(A,t);let H=Object.keys(I).map(Number);H.sort(jt);let $,P=[],j=[];for(let k=H.length-1;k>=0;--k){let K=H[k],X=c.getTilePixelSize(K,l,s),it=u.getResolution(K)/f,ot=X[0]*it*z,kt=X[1]*it*z,v=u.getTileCoordForCoordAndZ(he(T),K),ie=u.getTileCoordExtent(v),Rt=ht(this.tempTransform,[m*(ie[0]-T[0])/f,m*(T[3]-ie[3])/f]),ye=m*c.getGutterForProjection(s);for(let De of I[K]){if(De.getState()!==O.LOADED)continue;let ne=De.tileCoord,er=v[1]-ne[1],hs=Math.round(Rt[0]-(er-1)*ot),ir=v[2]-ne[2],Zo=Math.round(Rt[1]-(ir-1)*kt),ke=Math.round(Rt[0]-er*ot),xe=Math.round(Rt[1]-ir*kt),Ne=hs-ke,Ei=Zo-xe,cs=H.length===1,nr=!1;$=[ke,xe,ke+Ne,xe,ke+Ne,xe+Ei,ke,xe+Ei];for(let pn=0,us=P.length;pn<us;++pn)if(!cs&&K<j[pn]){let Pt=P[pn];lt([ke,xe,ke+Ne,xe+Ei],[Pt[0],Pt[3],Pt[4],Pt[7]])&&(nr||(A.save(),nr=!0),A.beginPath(),A.moveTo($[0],$[1]),A.lineTo($[2],$[3]),A.lineTo($[4],$[5]),A.lineTo($[6],$[7]),A.moveTo(Pt[6],Pt[7]),A.lineTo(Pt[4],Pt[5]),A.lineTo(Pt[2],Pt[3]),A.lineTo(Pt[0],Pt[1]),A.clip())}P.push($),j.push(K),this.drawTile(De,t,ke,xe,Ne,Ei,ye,cs),nr&&A.restore(),this.renderedTiles.unshift(De),this.updateUsedTiles(t.usedTiles,c,De)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!we(this.renderedExtent_,T),this.renderedExtent_=T,this.renderedPixelRatio=l,this.postRender(this.context,t),i.extent&&A.restore(),A.imageSmoothingEnabled=!0,this.renderComplete){let k=(K,X)=>{let tt=U(c),it=X.wantedTiles[tt],ot=it?Object.keys(it).length:0;this.updateCacheSize(ot),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(k)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,r,s,o,a,l){let h;if(t instanceof ch){if(h=wo(t.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(t);if(!h)return;let c=this.getRenderContext(e),u=U(this),d=e.layerStatesArray[e.layerIndex],f=d.opacity*(l?t.getAlpha(u,e.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,i,r,s,o),g&&c.restore(),f!==d.opacity?e.animate=!0:l&&t.endTransition(u)}getImage(){let t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){let r=U(e);r in t||(t[r]={}),t[r][i.getKey()]=!0}},Rf=wh;var qr={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};var Sh=class extends ci{constructor(t){t=t||{};let e=Object.assign({},t),i=t.cacheSize;delete t.cacheSize,delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(t.preload!==void 0?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(qr.PRELOAD)}setPreload(t){this.set(qr.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(qr.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(qr.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}},wf=Sh;var Th=class extends wf{constructor(t){super(t)}createRenderer(){return new Rf(this,{cacheSize:this.getCacheSize()})}},Po=Th;var vh=class{drawCustom(t,e,i,r,s){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}},Oo=vh;var $r={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},Jr=[$r.FILL],He=[$r.STROKE],_i=[$r.BEGIN_PATH],Ih=[$r.CLOSE_PATH],D=$r;var Mh=class extends Oo{constructor(t,e,i,r){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=r,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){let e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){let i=this.getBufferedMaxExtent(),r=this.tmpCoordinate_,s=this.coordinates,o=s.length;for(let a=0,l=t.length;a<l;a+=e)r[0]=t[a],r[1]=t[a+1],Jt(i,r)&&(s[o++]=r[0],s[o++]=r[1]);return o}appendFlatLineCoordinates(t,e,i,r,s,o){let a=this.coordinates,l=a.length,h=this.getBufferedMaxExtent();o&&(e+=r);let c=t[e],u=t[e+1],d=this.tmpCoordinate_,f=!0,g,p,m;for(g=e+r;g<i;g+=r)d[0]=t[g],d[1]=t[g+1],m=ws(h,d),m!==p?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):m===yt.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],p=m;return(s&&f||g===e+r)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(t,e,i,r,s){for(let o=0,a=i.length;o<a;++o){let l=i[o],h=this.appendFlatLineCoordinates(t,e,l,r,!1,!1);s.push(h),e=l}return e}drawCustom(t,e,i,r,s){this.beginGeometry(t,e,s);let o=t.getType(),a=t.getStride(),l=this.coordinates.length,h,c,u,d,f;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),d=[];let g=t.getEndss();f=0;for(let p=0,m=g.length;p<m;++p){let _=[];f=this.drawCustomCoordinates_(h,f,g[p],a,_),d.push(_)}this.instructions.push([D.CUSTOM,l,d,t,i,xr,s]),this.hitDetectionInstructions.push([D.CUSTOM,l,d,t,r||i,xr,s]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,t.getEnds(),a,u),this.instructions.push([D.CUSTOM,l,u,t,i,Ai,s]),this.hitDetectionInstructions.push([D.CUSTOM,l,u,t,r||i,Ai,s]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([D.CUSTOM,l,c,t,i,fe,s]),this.hitDetectionInstructions.push([D.CUSTOM,l,c,t,r||i,fe,s]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([D.CUSTOM,l,c,t,i,fe,s]),this.hitDetectionInstructions.push([D.CUSTOM,l,c,t,r||i,fe,s]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([D.CUSTOM,l,c,t,i,void 0,s]),this.hitDetectionInstructions.push([D.CUSTOM,l,c,t,r||i,void 0,s]);break;default:}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[D.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[D.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let t=this.hitDetectionInstructions;t.reverse();let e,i=t.length,r,s,o=-1;for(e=0;e<i;++e)r=t[e],s=r[0],s==D.END_GEOMETRY?o=e:s==D.BEGIN_GEOMETRY&&(r[2]=e,Jc(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){let i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=Zt(i||Ct)}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){let i=t.getColor();e.strokeStyle=Zt(i||di);let r=t.getLineCap();e.lineCap=r!==void 0?r:Ve;let s=t.getLineDash();e.lineDash=s?s.slice():Ht;let o=t.getLineDashOffset();e.lineDashOffset=o||qt;let a=t.getLineJoin();e.lineJoin=a!==void 0?a:Be;let l=t.getWidth();e.lineWidth=l!==void 0?l:gi;let h=t.getMiterLimit();e.miterLimit=h!==void 0?h:ui;let c=t.getOffset();e.strokeOffset=c??Vd,e.lineWidth>this.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){let i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){let e=t.fillStyle,i=[D.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[D.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){let i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){let i=t.strokeStyle,r=t.lineCap,s=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit,c=t.strokeOffset;(t.currentStrokeStyle!=i||t.currentLineCap!=r||s!=t.currentLineDash&&!Ot(t.currentLineDash,s)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h||t.currentStrokeOffset!=c)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=r,t.currentLineDash=s,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h,t.currentStrokeOffset=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let e=[D.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Ss(this.maxExtent),this.maxLineWidth>0)){let t=this.resolution*(this.maxLineWidth+1)/2;ri(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},qe=Mh;var bh=class extends qe{constructor(t,e,i,r){super(t,e,i,r),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(t,e,i){if(!this.image_||this.maxExtent&&!Jt(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);let r=t.getFlatCoordinates(),s=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,s);this.instructions.push([D.DRAW_IMAGE,o,a,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([D.DRAW_IMAGE,o,a,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(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);let r=t.getFlatCoordinates(),s=[];for(let l=0,h=r.length;l<h;l+=t.getStride())(!this.maxExtent||Jt(this.maxExtent,r.slice(l,l+2)))&&s.push(r[l],r[l+1]);let o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,2);this.instructions.push([D.DRAW_IMAGE,o,a,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([D.DRAW_IMAGE,o,a,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(e)}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(t,e){let i=t.getAnchor(),r=t.getSize(),s=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=r[1],this.opacity_=t.getOpacity(),this.originX_=s[0],this.originY_=s[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=r[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}},Sf=bh;var Lh=class extends qe{constructor(t,e,i,r){super(t,e,i,r)}drawFlatCoordinates_(t,e,i,r,s){let o=this.coordinates.length,a=this.appendFlatLineCoordinates(t,e,i,r,!1,!1);return this.instructions.push([D.MOVE_TO_LINE_TO,o,a,s*this.pixelRatio]),this.hitDetectionInstructions.push([D.MOVE_TO_LINE_TO,o,a,s]),i}drawLineString(t,e,i){let r=this.state,s=r.strokeStyle,o=r.lineWidth,a=r.strokeOffset;if(s===void 0||o===void 0)return;this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,r.strokeStyle,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Ht,qt],_i);let l=t.getFlatCoordinates(),h=t.getStride();this.drawFlatCoordinates_(l,0,l.length,h,a),this.hitDetectionInstructions.push(He),this.endGeometry(e)}drawMultiLineString(t,e,i){let r=this.state,s=r.strokeStyle,o=r.lineWidth,a=r.strokeOffset;if(s===void 0||o===void 0)return;this.updateStrokeStyle(r,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,r.strokeStyle,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Ht,qt],_i);let l=t.getEnds(),h=t.getFlatCoordinates(),c=t.getStride(),u=0;for(let d=0,f=l.length;d<f;++d)u=this.drawFlatCoordinates_(h,u,l[d],c,a);this.hitDetectionInstructions.push(He),this.endGeometry(e)}finish(){let t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(He),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(He),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(_i)}},Tf=Lh;var Ah=class extends qe{constructor(t,e,i,r){super(t,e,i,r)}drawFlatCoordinatess_(t,e,i,r,s){let o=this.state,a=o.fillStyle!==void 0,l=o.strokeStyle!==void 0,h=i.length;this.instructions.push(_i),this.hitDetectionInstructions.push(_i);for(let c=0;c<h;++c){let u=i[c],d=this.coordinates.length,f=this.appendFlatLineCoordinates(t,e,u,r,!0,!l);this.instructions.push([D.MOVE_TO_LINE_TO,d,f,s*this.pixelRatio,!0]),this.hitDetectionInstructions.push([D.MOVE_TO_LINE_TO,d,f,s,!0]),l&&(this.instructions.push(Ih),this.hitDetectionInstructions.push(Ih)),e=u}return a&&(this.instructions.push(Jr),this.hitDetectionInstructions.push(Jr)),l&&(this.instructions.push(He),this.hitDetectionInstructions.push(He)),e}drawCircle(t,e,i){let r=this.state,s=r.fillStyle,o=r.strokeStyle,a=r.strokeOffset;if(s===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawCircle(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_FILL_STYLE,Ct]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,r.strokeStyle,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Ht,qt]);let l=t.getFlatCoordinates(),h=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(l,0,l.length,h,!1,!1);let u=[D.CIRCLE,c,a];this.instructions.push(_i,u),this.hitDetectionInstructions.push(_i,u),r.fillStyle!==void 0&&(this.instructions.push(Jr),this.hitDetectionInstructions.push(Jr)),r.strokeStyle!==void 0&&(this.instructions.push(He),this.hitDetectionInstructions.push(He)),this.endGeometry(e)}drawPolygon(t,e,i){let r=this.state,s=r.fillStyle,o=r.strokeStyle,a=r.strokeOffset;if(s===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_FILL_STYLE,Ct]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,r.strokeStyle,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Ht,qt]);let l=t.getEnds(),h=t.getOrientedFlatCoordinates(),c=t.getStride();this.drawFlatCoordinatess_(h,0,l,c,a),this.endGeometry(e)}drawMultiPolygon(t,e,i){let r=this.state,s=r.fillStyle,o=r.strokeStyle,a=r.strokeOffset;if(s===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),r.fillStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_FILL_STYLE,Ct]),r.strokeStyle!==void 0&&this.hitDetectionInstructions.push([D.SET_STROKE_STYLE,r.strokeStyle,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,Ht,qt]);let l=t.getEndss(),h=t.getOrientedFlatCoordinates(),c=t.getStride(),u=0;for(let d=0,f=l.length;d<f;++d)u=this.drawFlatCoordinatess_(h,u,l[d],c,a);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let t=this.tolerance;if(t!==0){let e=this.coordinates;for(let i=0,r=e.length;i<r;++i)e[i]=Pi(e[i],t)}return super.finish()}setFillStrokeStyles_(){let t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}handleStrokeOffset_(t){let e=this.state,i=e.fillStyle,r=e.strokeStyle,s=e.strokeOffset;return Math.abs(s)>0&&i!==void 0&&r!==void 0?(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=r,e.strokeOffset=s,t(),e.fillStyle=i,!0):!1}},Ph=Ah;function vf(n,t,e,i,r){let s=[],o=e,a=0,l=t.slice(e,2);for(;a<n&&o+r<i;){let[h,c]=l.slice(-2),u=t[o+r],d=t[o+r+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=n){let g=(n-a+f)/f,p=bt(h,u,g),m=bt(c,d,g);l.push(p,m),s.push(l),l=[p,m],a==n&&(o+=r),a=0}else if(a<n)l.push(t[o+r],t[o+r+1]),o+=r;else{let g=f-a,p=bt(h,u,g/f),m=bt(c,d,g/f);l.push(p,m),s.push(l),l=[p,m],a=0,o+=r}}return a>0&&s.push(l),s}function If(n,t,e,i,r){let s=e,o=e,a=0,l=0,h=e,c,u,d,f,g,p,m,_,y,E;for(u=e;u<i;u+=r){let x=t[u],C=t[u+1];g!==void 0&&(y=x-g,E=C-p,f=Math.sqrt(y*y+E*E),m!==void 0&&(l+=d,c=Math.acos((m*y+_*E)/(d*f)),c>n&&(l>a&&(a=l,s=h,o=u),l=0,h=u-r)),d=f,m=y,_=E),g=x,p=C}return l+=f,l>a?[h,u]:[s,o]}var Qr={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Oh=class extends qe{constructor(t,e,i,r){super(t,e,i,r),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Ct]={fillStyle:Ct},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 t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){let r=this.textFillState_,s=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!r&&!s)return;let a=this.coordinates,l=a.length,h=t.getType(),c=null,u=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!lt(this.maxExtent,t.getExtent()))return;let d;if(c=t.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=t.getEnds();else if(h=="Polygon")d=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){let m=t.getEndss();d=[];for(let _=0,y=m.length;_<y;++_)d.push(m[_][0])}this.beginGeometry(t,e,i);let f=o.repeat,g=f?void 0:o.textAlign,p=0;for(let m=0,_=d.length;m<_;++m){let y;f?y=vf(f*this.resolution,c,p,d[m],u):y=[c.slice(p,d[m])];for(let E=0,x=y.length;E<x;++E){let C=y[E],T=0,I=C.length;if(g==null){let w=If(o.maxAngle,C,0,C.length,2);T=w[0],I=w[1]}for(let w=T;w<I;w+=u)a.push(C[w],C[w+1]);let S=a.length;p=d[m],this.drawChars_(l,S),l=S}}this.endGeometry(e)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=t.getFlatCoordinates();break;case"LineString":c=t.getFlatMidpoint();break;case"Circle":c=t.getCenter();break;case"MultiLineString":c=t.getFlatMidpoints(),u=2;break;case"Polygon":c=t.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":let x=t.getFlatInteriorPoints();c=[];for(let C=0,T=x.length;C<T;C+=3)o.overflow||d.push(x[C+2]/this.resolution),c.push(x[C],x[C+1]);if(c.length===0)return;u=2;break;default:}let f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((C,T)=>{let I=a[(x+T)*2]===c[T*u]&&a[(x+T)*2+1]===c[T*u+1];return I||--x,I})}this.saveTextStates_();let g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,p=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let m=o.padding;if(m!=fi&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],C=o.padding[1],T=o.padding[2],I=o.padding[3];o.scale[0]<0&&(C=-C,I=-I),o.scale[1]<0&&(x=-x,T=-T),m=[x,C,T,I]}let _=this.pixelRatio;this.instructions.push([D.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,m==fi?fi:m.map(function(x){return x*_}),g,p,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);let y=1/_,E=g?g.slice(0):null;E&&(E[1]=Ct),this.hitDetectionInstructions.push([D.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[y,y],NaN,this.declutterMode_,this.declutterImageWithText_,m,E,p,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Ct:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(e)}}saveTextStates_(){let t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,r=this.strokeKey_;t&&(r in this.strokeStates||(this.strokeStates[r]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));let s=this.textKey_;s in this.textStates||(this.textStates[s]={font:e.font,textAlign:e.textAlign||Ui,justify:e.justify,textBaseline:e.textBaseline||un,scale:e.scale});let o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){let i=this.textStrokeState_,r=this.textState_,s=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();let l=this.pixelRatio,h=Qr[r.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(r.scale[0])/2:0;this.instructions.push([D.DRAW_CHARS,t,e,h,r.overflow,a,r.maxAngle,l,c,s,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([D.DRAW_CHARS,t,e,h,r.overflow,a&&Ct,r.maxAngle,l,c,s,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,r,s;if(!t)this.text_="";else{let o=t.getFill();o?(r=this.textFillState_,r||(r={},this.textFillState_=r),r.fillStyle=Zt(o.getColor()||Ct)):(r=null,this.textFillState_=r);let a=t.getStroke();if(!a)s=null,this.textStrokeState_=s;else{s=this.textStrokeState_,s||(s={},this.textStrokeState_=s);let p=a.getLineDash(),m=a.getLineDashOffset(),_=a.getWidth(),y=a.getMiterLimit();s.lineCap=a.getLineCap()||Ve,s.lineDash=p?p.slice():Ht,s.lineDashOffset=m===void 0?qt:m,s.lineJoin=a.getLineJoin()||Be,s.lineWidth=_===void 0?gi:_,s.miterLimit=y===void 0?ui:y,s.strokeStyle=Zt(a.getColor()||di)}i=this.textState_;let l=t.getFont()||fo;Bd(l);let h=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||un,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||fi,i.scale=h===void 0?[1,1]:h;let c=t.getOffsetX(),u=t.getOffsetY(),d=t.getRotateWithView(),f=t.getKeepUpright(),g=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=s?(typeof s.strokeStyle=="string"?s.strokeStyle:U(s.strokeStyle))+s.lineCap+s.lineDashOffset+"|"+s.lineWidth+s.lineJoin+s.miterLimit+"["+s.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=r&&r.fillStyle?typeof r.fillStyle=="string"?r.fillStyle:"|"+U(r.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}},Mf=Oh;var Op={Circle:Ph,Default:qe,Image:Sf,LineString:Tf,Polygon:Ph,Text:Mf},Fh=class{constructor(t,e,i,r){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=r,this.resolution_=i,this.buildersByZIndex_={}}finish(){let t={};for(let e in this.buildersByZIndex_){t[e]=t[e]||{};let i=this.buildersByZIndex_[e];for(let r in i){let s=i[r].finish();t[e][r]=s}}return t}getBuilder(t,e){let i=t!==void 0?t.toString():"0",r=this.buildersByZIndex_[i];r===void 0&&(r={},this.buildersByZIndex_[i]=r);let s=r[e];if(s===void 0){let o=Op[e];s=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),r[e]=s}return s}},bf=Fh;function qn(n,t,e,i){let r=n[t],s=n[t+1],o=0;for(let a=t+i;a<e;a+=i){let l=n[a],h=n[a+1];o+=Math.sqrt((l-r)*(l-r)+(h-s)*(h-s)),r=l,s=h}return o}function Lf(n,t,e,i,r,s){r=r??[],s=s??t;let o=n[0],a=n[1],l=n[n.length-4],h=n[n.length-3],c,u,d,f,g,p,m,_,y=0;for(let E=0;E<n.length;E+=t){d=c,f=u,g=void 0,p=void 0,E+t<n.length&&(g=n[E+t],p=n[E+t+1]),i&&E===0&&(d=l,f=h),i&&E===n.length-2&&(g=o,p=a),c=n[E],u=n[E+1],[m,_]=ts(c,u,d,f,g,p,e),r[y++]=m,r[y++]=_;for(let x=2;x<s;x++)r[y++]=n[E+x]}return r.length!=y&&(r.length=y),r}function ts(n,t,e,i,r,s,o){let a,l;e!==void 0&&i!==void 0?(a=n-e,l=t-i):r!==void 0&&s!==void 0?(a=r-n,l=s-t):(a=1,l=0);let h=Math.hypot(a,l),c=a/h,u=l/h;if(a=-u,l=c,e===void 0||i===void 0)return[n+a*o,t+l*o];if(r===void 0||s===void 0)return[n+a*o,t+l*o];let d=yu([n,t],[e,i],[r,s]);if(Math.cos(d)>.998)return[n+c*o,t+u*o];let f=Math.cos(d/2),g=Math.sin(d/2),p=g*a+f*l,m=-f*a+g*l,_=p*(1/g),y=m*(1/g);return[n+_*o,t+y*o]}function Af(n,t,e,i,r,s,o,a,l,h,c,u,d=!0){let f=n[t],g=n[t+1],p=0,m=0,_=0,y=0;function E(){p=f,m=g,t+=i,f=n[t],g=n[t+1],y+=_,_=Math.sqrt((f-p)*(f-p)+(g-m)*(g-m))}do E();while(t<e-i&&y+_<s);let x=_===0?0:(s-y)/_,C=bt(p,f,x),T=bt(m,g,x),I=t-i,S=y,w=s+a*l(h,r,c);for(;t<e-i&&y+_<w;)E();x=_===0?0:(w-y)/_;let M=bt(p,f,x),N=bt(m,g,x),z=!1;if(d)if(u){let j=[C,T,M,N];zs(j,0,4,2,u,j,j),z=j[0]>j[2]}else z=C>M;let A=Math.PI,H=[],$=I+i===t;t=I,_=0,y=S,f=n[t],g=n[t+1];let P;if($){E(),P=Math.atan2(g-m,f-p),z&&(P+=P>0?-A:A);let j=(M+C)/2,k=(N+T)/2;return H[0]=[j,k,(w-s)/2,P,r],H}r=r.replace(/\n/g," ");for(let j=0,k=r.length;j<k;){E();let K=Math.atan2(g-m,f-p);if(z&&(K+=K>0?-A:A),P!==void 0){let v=K-P;if(v+=v>A?-2*A:v<-A?2*A:0,Math.abs(v)>o)return null}P=K;let X=j,tt=0;for(;j<k;++j){let v=z?k-j-1:j,ie=a*l(h,r[v],c);if(t+i<e&&y+_<s+tt+ie/2)break;tt+=ie}if(j===X)continue;let it=z?r.substring(k-X,k-j):r.substring(X,j);x=_===0?0:(s+tt/2-y)/_;let ot=bt(p,f,x),kt=bt(m,g,x);H.push([ot,kt,tt/2,K,it]),s+=tt}return H}var $n=ct(),Bi=[],yi=[],xi=[],Zi=[];function Pf(n){return n[3].declutterBox}var Of=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function Dh(n,t){return t==="start"?t=Of.test(n)?"right":"left":t==="end"&&(t=Of.test(n)?"left":"right"),Qr[t]}function Fp(n,t,e){return e>0&&n.push(`
4
- `,""),n.push(t,""),n}function Dp(n,t,e){return e%2===0&&(n+=t),n}var kh=class{constructor(t,e,i,r,s){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=r.instructions,this.coordinates=r.coordinates,this.coordinateCache_={},this.renderedTransform_=Tt(),this.hitDetectionInstructions=r.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=r.fillStates||{},this.strokeStates=r.strokeStates||{},this.textStates=r.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=s?new Ao:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,r){let s=t+e+i+r;if(this.labels_[s])return this.labels_[s];let o=r?this.strokeStates[r]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?Qr[l.justify]:Dh(Array.isArray(t)?t[0]:t,l.textAlign||Ui),d=r&&o.lineWidth?o.lineWidth:0,f=Array.isArray(t)?t:String(t).split(`
5
- `).reduce(Fp,[]),{width:g,height:p,widths:m,heights:_,lineWidths:y}=qd(l,f),E=g+d,x=[],C=(E+2)*c[0],T=(p+d)*c[1],I={width:C<0?Math.floor(C):Math.ceil(C),height:T<0?Math.floor(T):Math.ceil(T),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),r&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",d),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),i&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");let S=.5-u,w=u*E+S*d,M=[],N=[],z=0,A=0,H=0,$=0,P;for(let j=0,k=f.length;j<k;j+=2){let K=f[j];if(K===`
6
- `){A+=z,z=0,w=u*E+S*d,++$;continue}let X=f[j+1]||l.font;X!==P&&(r&&M.push("font",X),i&&N.push("font",X),P=X),z=Math.max(z,_[H]);let tt=[K,w+S*m[H]+u*(m[H]-y[$]),.5*(d+z)+A];w+=m[H],r&&M.push("strokeText",tt),i&&N.push("fillText",tt),++H}return Array.prototype.push.apply(x,M),Array.prototype.push.apply(x,N),this.labels_[s]=I,I}replayTextBackground_(t,e,i,r,s,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,r),t.lineTo.apply(t,s),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,r,s,o,a,l,h,c,u,d,f,g,p,m){a*=d[0],l*=d[1];let _=i-a,y=r-l,E=s+h>t?t-h:s,x=o+c>e?e-c:o,C=g[3]+E*d[0]+g[1],T=g[0]+x*d[1]+g[2],I=_-g[3],S=y-g[0];(p||u!==0)&&(Bi[0]=I,Zi[0]=I,Bi[1]=S,yi[1]=S,yi[0]=I+C,xi[0]=yi[0],xi[1]=S+T,Zi[1]=xi[1]);let w;return u!==0?(w=Et(Tt(),i,r,1,1,u,-i,-r),ht(w,Bi),ht(w,yi),ht(w,xi),ht(w,Zi),Qt(Math.min(Bi[0],yi[0],xi[0],Zi[0]),Math.min(Bi[1],yi[1],xi[1],Zi[1]),Math.max(Bi[0],yi[0],xi[0],Zi[0]),Math.max(Bi[1],yi[1],xi[1],Zi[1]),$n)):Qt(Math.min(I,I+C),Math.min(S,S+T),Math.max(I,I+C),Math.max(S,S+T),$n),f&&(_=Math.round(_),y=Math.round(y)),{drawImageX:_,drawImageY:y,drawImageW:E,drawImageH:x,originX:h,originY:c,declutterBox:{minX:$n[0],minY:$n[1],maxX:$n[2],maxY:$n[3],value:m},canvasTransform:w,scale:d}}replayImageOrLabel_(t,e,i,r,s,o,a){let l=!!(o||a),h=r.declutterBox,c=a?a[2]*r.scale[0]/2:0;return h.minX-c<=e[0]&&h.maxX+c>=0&&h.minY-c<=e[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(t,Bi,yi,xi,Zi,o,a),$d(t,r.canvasTransform,s,i,r.originX,r.originY,r.drawImageW,r.drawImageH,r.drawImageX,r.drawImageY,r.scale)),!0}fill_(t){let e=this.alignAndScaleFill_;if(e){let i=ht(this.renderedTransform_,[0,0]),r=512*this.pixelRatio;t.save(),t.translate(i[0]%r,i[1]%r),e!==1&&t.scale(e,e)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,r){let s=this.textStates[e],o=this.createLabel(t,e,r,i),a=this.strokeStates[i],l=this.pixelRatio,h=Dh(Array.isArray(t)?t[0]:t,s.textAlign||Ui),c=Qr[s.textBaseline||un],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*s.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,r,s,o,a,l){let h=this.zIndexContext_,c;this.pixelCoordinates_&&Ot(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Kt(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Uu(this.renderedTransform_,i));let u=0,d=r.length,f=0,g,p,m,_,y,E,x,C,T,I,S,w,M,N,z,A,H=0,$=0,P=this.coordinateCache_,j=this.viewRotation_,k=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,K={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:j},X=this.instructions!=r||this.overlaps?0:200,tt,it,ot,kt;for(;u<d;){let v=r[u];switch(v[0]){case D.BEGIN_GEOMETRY:tt=v[1],kt=v[3],tt.getGeometry()?a!==void 0&&!lt(a,kt.getExtent())?u=v[2]+1:++u:u=v[2],h&&(h.zIndex=v[4]);break;case D.BEGIN_PATH:H>X&&(this.fill_(t),H=0),$>X&&(t.stroke(),$=0),!H&&!$&&(t.beginPath(),C=NaN,T=NaN),++u;break;case D.CIRCLE:f=v[1],_=v[2]??0;let Rt=c[f],ye=c[f+1],De=c[f+2]-_,ne=c[f+3]-_,er=De-Rt,hs=ne-ye,ir=Math.sqrt(er*er+hs*hs);t.moveTo(Rt+ir,ye),t.arc(Rt,ye,ir,0,2*Math.PI,!0),++u;break;case D.CLOSE_PATH:t.closePath(),++u;break;case D.CUSTOM:f=v[1],g=v[2];let Zo=v[3],ke=v[4],xe=v[5];K.geometry=Zo,K.feature=tt,u in P||(P[u]=[]);let Ne=P[u];xe?xe(c,f,g,2,Ne):(Ne[0]=c[f],Ne[1]=c[f+1],Ne.length=2),h&&(h.zIndex=v[6]),ke(Ne,K),++u;break;case D.DRAW_IMAGE:f=v[1],g=v[2],w=v[3],p=v[4],m=v[5];let Ei=v[6],cs=v[7],nr=v[8],pn=v[9],us=v[10],Pt=v[11],Tg=v[12],ds=v[13];x=v[14]||"declutter";let rr=v[15];if(!w&&v.length>=20){M=v[19],N=v[20],z=v[21],A=v[22];let re=this.drawLabelWithPointPlacement_(M,N,z,A);w=re.label,v[3]=w;let $i=v[23];p=(re.anchorX-$i)*this.pixelRatio,v[4]=p;let se=v[24];m=(re.anchorY-se)*this.pixelRatio,v[5]=m,Ei=w.height,v[6]=Ei,ds=w.width,v[13]=ds}let Ho;v.length>25&&(Ho=v[25]);let qo,fs,gs;v.length>17?(qo=v[16],fs=v[17],gs=v[18]):(qo=fi,fs=null,gs=null),us&&k?Pt+=j:!us&&!k&&(Pt-=j);let vg=0;for(;f<g;f+=2){if(Ho&&Ho[vg++]<ds/this.pixelRatio)continue;let re=this.calculateImageOrLabelDimensions_(w.width,w.height,c[f],c[f+1],ds,Ei,p,m,nr,pn,Pt,Tg,s,qo,!!fs||!!gs,tt),$i=[t,e,w,re,cs,fs,gs];if(l){let se,Ge,oe;if(rr){let ut=g-f;if(!rr[ut]){rr[ut]={args:$i,declutterMode:x};continue}let Nt=rr[ut];se=Nt.args,Ge=Nt.declutterMode,delete rr[ut],oe=Pf(se)}let Je,Qe;if(se&&(Ge!=="declutter"||!l.collides(oe))&&(Je=!0),(x!=="declutter"||!l.collides(re.declutterBox))&&(Qe=!0),Ge==="declutter"&&x==="declutter"){let ut=Je&&Qe;Je=ut,Qe=ut}Je&&(Ge!=="none"&&l.insert(oe),this.replayImageOrLabel_.apply(this,se)),Qe&&(x!=="none"&&l.insert(re.declutterBox),this.replayImageOrLabel_.apply(this,$i))}else this.replayImageOrLabel_.apply(this,$i)}++u;break;case D.DRAW_CHARS:let Uc=v[1],Yc=v[2],$o=v[3],Ig=v[4];A=v[5];let Mg=v[6],Kc=v[7],Vc=v[8];z=v[9];let Jo=v[10];M=v[11],Array.isArray(M)&&(M=M.reduce(Dp,"")),N=v[12];let Bc=[v[13],v[13]];x=v[14]||"declutter";let bg=v[15],Qo=this.textStates[N],sr=Qo.font,or=[Qo.scale[0]*Kc,Qo.scale[1]*Kc],ar;sr in this.widths_?ar=this.widths_[sr]:(ar={},this.widths_[sr]=ar);let Zc=qn(c,Uc,Yc,2),Hc=Math.abs(or[0])*Xl(sr,M,ar);if(Ig||Hc<=Zc){let re=this.textStates[N].textAlign,$i=(Zc-Hc)*Dh(M,re),se=Af(c,Uc,Yc,2,M,$i,Mg,Math.abs(or[0]),Xl,sr,ar,k?0:this.viewRotation_,bg);t:if(se){let Ge=[],oe,Je,Qe,ut,Nt;if(z)for(oe=0,Je=se.length;oe<Je;++oe){Nt=se[oe],Qe=Nt[4],ut=this.createLabel(Qe,N,"",z),p=Nt[2]+(or[0]<0?-Jo:Jo),m=$o*ut.height+(.5-$o)*2*Jo*or[1]/or[0]-Vc;let ti=this.calculateImageOrLabelDimensions_(ut.width,ut.height,Nt[0],Nt[1],ut.width,ut.height,p,m,0,0,Nt[3],Bc,!1,fi,!1,tt);if(l&&x==="declutter"&&l.collides(ti.declutterBox))break t;Ge.push([t,e,ut,ti,1,null,null])}if(A)for(oe=0,Je=se.length;oe<Je;++oe){Nt=se[oe],Qe=Nt[4],ut=this.createLabel(Qe,N,A,""),p=Nt[2],m=$o*ut.height-Vc;let ti=this.calculateImageOrLabelDimensions_(ut.width,ut.height,Nt[0],Nt[1],ut.width,ut.height,p,m,0,0,Nt[3],Bc,!1,fi,!1,tt);if(l&&x==="declutter"&&l.collides(ti.declutterBox))break t;Ge.push([t,e,ut,ti,1,null,null])}l&&x!=="none"&&l.load(Ge.map(Pf));for(let ti=0,Lg=Ge.length;ti<Lg;++ti)this.replayImageOrLabel_.apply(this,Ge[ti])}}++u;break;case D.END_GEOMETRY:if(o!==void 0){tt=v[1];let re=o(tt,kt,x);if(re)return re}++u;break;case D.FILL:X?H++:this.fill_(t),++u;break;case D.MOVE_TO_LINE_TO:for(f=v[1],g=v[2],_=v[3],y=v[4]??!1,it=c[f],ot=c[f+1],_&&(E=f,[it,ot]=ts(it,ot,y?c[g-4]:void 0,y?c[g-3]:void 0,c[f+2],c[f+3],_)),t.moveTo(it,ot),C=it+.5|0,T=ot+.5|0,f+=2;f<g;f+=2)it=c[f],ot=c[f+1],I=it+.5|0,S=ot+.5|0,(f==g-2||I!==C||S!==T)&&(_&&(f==g-2?[it,ot]=ts(it,ot,c[f-2],c[f-1],y?c[E+2]:void 0,y?c[E+3]:void 0,_):[it,ot]=ts(it,ot,c[f-2],c[f-1],c[f+2],c[f+3],_)),t.lineTo(it,ot),C=I,T=S);++u;break;case D.SET_FILL_STYLE:this.alignAndScaleFill_=v[2],H&&(this.fill_(t),H=0,$&&(t.stroke(),$=0)),t.fillStyle=v[1],++u;break;case D.SET_STROKE_STYLE:$&&(t.stroke(),$=0),this.setStrokeStyle_(t,v),++u;break;case D.STROKE:X?$++:t.stroke(),++u;break;default:++u;break}}H&&this.fill_(t),$&&t.stroke()}execute(t,e,i,r,s,o){this.viewRotation_=r,this.execute_(t,e,i,this.instructions,s,void 0,void 0,o)}executeHitDetection(t,e,i,r,s){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,r,s)}},Ff=kh;var Hi=["Polygon","Circle","LineString","Image","Text","Default"],zh=["Image","Text"],Df=Hi.filter(n=>!zh.includes(n)),kf=!1,Nf=!1;function kp(){let n=0,t=i=>{let r=nt(1,1,null,{willReadFrequently:i}),s=0,o=performance.now();for(;performance.now()-o<50;++s)r.fillStyle=`rgba(255,0,${s%256},1)`,r.fillRect(0,0,1,1),r.getImageData(0,0,1,1);return n=s>n?s:n,s};kf={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[n],Nf=!0}var Gh=class{constructor(t,e,i,r,s,o,a){this.maxExtent_=t,this.overlaps_=r,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Tt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(s,a)}clip(t,e){let i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(let i in t){let r=this.executorsByZIndex_[i];r===void 0&&(r={},this.executorsByZIndex_[i]=r);let s=t[i];for(let o in s){let a=s[o];r[o]=new Ff(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(let e in this.executorsByZIndex_){let i=this.executorsByZIndex_[e];for(let r=0,s=t.length;r<s;++r)if(t[r]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,r,s,o){Nf===!1&&kp(),r=Math.round(r);let a=r*2+1,l=Et(this.hitDetectionTransform_,r+.5,r+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=nt(a,a,null,{willReadFrequently:kf}));let c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=ct(),Qi(u,t),ri(u,e*(this.renderBuffer_+r),u));let d=Np(r),f;function g(C,T,I){let S=c.getImageData(0,0,a,a).data;for(let w=0,M=d.length;w<M;w++)if(S[d[w]]>0){if(!o||I==="none"||f!=="Image"&&f!=="Text"||o.includes(C)){let N=(d[w]-3)/4,z=r-N%a,A=r-(N/a|0),H=s(C,T,z*z+A*A);if(H)return H}c.clearRect(0,0,a,a);break}}let p=Object.keys(this.executorsByZIndex_).map(Number);p.sort(jt);let m,_,y,E,x;for(m=p.length-1;m>=0;--m){let C=p[m].toString();for(y=this.executorsByZIndex_[C],_=Hi.length-1;_>=0;--_)if(f=Hi[_],E=y[f],E!==void 0&&(x=E.executeHitDetection(c,l,i,g,u),x))return x}}getClipCoords(t){let e=this.maxExtent_;if(!e)return null;let i=e[0],r=e[1],s=e[2],o=e[3],a=[i,r,i,o,s,o,s,r];return Kt(a,0,8,2,t,a),a}isEmpty(){return $t(this.executorsByZIndex_)}execute(t,e,i,r,s,o,a){let l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?$c:jt),o=o||Hi;let h=Hi.length;for(let c=0,u=l.length;c<u;++c){let d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,p=o.length;g<p;++g){let m=o[g],_=f[m];if(_!==void 0){let y=a===null?void 0:_.getZIndexContext(),E=y?y.getContext():t,x=this.maxExtent_&&m!=="Image"&&m!=="Text";if(x&&(E.save(),this.clip(E,i)),!y||m==="Text"||m==="Image"?_.execute(E,e,i,r,s,a):y.pushFunction(C=>_.execute(C,e,i,r,s,a)),x&&E.restore(),y){y.offset();let C=l[c]*h+Hi.indexOf(m);this.deferredZIndexContexts_[C]||(this.deferredZIndexContexts_[C]=[]),this.deferredZIndexContexts_[C].push(y)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(jt);for(let i=0,r=e.length;i<r;++i)t[e[i]].forEach(s=>{s.draw(this.renderedContext_),s.clear()}),t[e[i]].length=0}},Nh={};function Np(n){if(Nh[n]!==void 0)return Nh[n];let t=n*2+1,e=n*n,i=new Array(e+1);for(let s=0;s<=n;++s)for(let o=0;o<=n;++o){let a=s*s+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+s)*t+(n+o))*4+3),s>0&&l.push(((n-s)*t+(n+o))*4+3),o>0&&(l.push(((n+s)*t+(n-o))*4+3),s>0&&l.push(((n-s)*t+(n-o))*4+3))}let r=[];for(let s=0,o=i.length;s<o;++s)i[s]&&r.push(...i[s]);return Nh[n]=r,r}var Gf=Gh;var jh=class extends Oo{constructor(t,e,i,r,s,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=r,this.transformRotation_=r?Ti(Math.atan2(r[1],r[0]),10):0,this.viewRotation_=s,this.squaredTolerance_=o,this.userTransform_=a,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_=Tt()}drawImages_(t,e,i,r){if(!this.image_)return;let s=Kt(t,e,i,r,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=s.length;c<u;c+=2){let d=s[c]-this.imageAnchorX_,f=s[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let g=d+this.imageAnchorX_,p=f+this.imageAnchorY_;Et(a,g,p,1,1,h,-g,-p),o.save(),o.transform.apply(o,a),o.translate(g,p),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(t,e,i,r){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let s=Kt(t,e,i,r,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=r){let l=s[e]+this.textOffsetX_,h=s[e+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(t,e,i,r,s,o){let a=this.context_,l=Kt(t,e,i,r,this.transform_,this.pixelCoordinates_);Math.abs(o)>0&&(l=Lf(l,r,o,s,l)),a.moveTo(l[0],l[1]);let h=l.length;s&&(h-=2);for(let c=2;c<h;c+=2)a.lineTo(l[c],l[c+1]);return s&&a.closePath(),i}drawRings_(t,e,i,r,s){for(let o=0,a=i.length;o<a;++o)e=this.moveToLineTo_(t,e,i[o],r,!0,s);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!lt(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let e=qu(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],r=e[3]-e[1],s=Math.sqrt(i*i+r*r),o=this.context_;o.beginPath(),o.arc(e[0],e[1],s,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break;default:}}drawFeature(t,e){let i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){let e=t.getGeometriesArray();for(let i=0,r=e.length;i<r;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!lt(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1,this.strokeState_.strokeOffset),e.stroke()}if(this.text_!==""){let e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let e=t.getExtent();if(lt(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let i=this.context_,r=t.getFlatCoordinates(),s=0,o=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)s=this.moveToLineTo_(r,s,o[l],a,!1,this.strokeState_.strokeOffset);i.stroke()}if(this.text_!==""){let i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!lt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride(),this.strokeState_?.strokeOffset),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){let e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!lt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let e=this.context_,i=t.getOrientedFlatCoordinates(),r=0,s=t.getEndss(),o=t.getStride();e.beginPath();for(let a=0,l=s.length;a<l;++a){let h=s[a];r=this.drawRings_(i,r,h,o,this.strokeState_?.strokeOffset)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){let e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){let e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){let e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),Ot(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){let e=this.context_,i=this.contextTextState_,r=t.textAlign?t.textAlign:Ui;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=r&&(i.textAlign=r,e.textAlign=r),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=r,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:r,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{let i=t.getColor();this.fillState_={fillStyle:Zt(i||Ct)}}if(!e)this.strokeState_=null;else{let i=e.getColor(),r=e.getLineCap(),s=e.getLineDash(),o=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),h=e.getMiterLimit(),c=s||Ht,u=e.getOffset();this.strokeState_={lineCap:r!==void 0?r:Ve,lineDash:this.pixelRatio_===1?c:c.map(d=>d*this.pixelRatio_),lineDashOffset:(o||qt)*this.pixelRatio_,lineJoin:a!==void 0?a:Be,lineWidth:(l!==void 0?l:gi)*this.pixelRatio_,miterLimit:h!==void 0?h:ui,strokeStyle:Zt(i||di),strokeOffset:(u??0)*this.pixelRatio_}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}let i=t.getPixelRatio(this.pixelRatio_),r=t.getAnchor(),s=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=r[0]*i,this.imageAnchorY_=r[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=s[0],this.imageOriginY_=s[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();let o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{let e=t.getFill();if(!e)this.textFillState_=null;else{let f=e.getColor();this.textFillState_={fillStyle:Zt(f||Ct)}}let i=t.getStroke();if(!i)this.textStrokeState_=null;else{let f=i.getColor(),g=i.getLineCap(),p=i.getLineDash(),m=i.getLineDashOffset(),_=i.getLineJoin(),y=i.getWidth(),E=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Ve,lineDash:p||Ht,lineDashOffset:m||qt,lineJoin:_!==void 0?_:Be,lineWidth:y!==void 0?y:gi,miterLimit:E!==void 0?E:ui,strokeStyle:Zt(f||di)}}let r=t.getFont(),s=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:r!==void 0?r:fo,textAlign:u!==void 0?u:Ui,textBaseline:d!==void 0?d:un},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,p)=>f+=p%2?" ":g,""):c:"",this.textOffsetX_=s!==void 0?this.pixelRatio_*s:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*h[0],this.pixelRatio_*h[1]]}}},zf=jh;var Oe=.5;function jf(n,t,e,i,r,s,o,a,l){let h=l?Mi(r,l):r,c=n[0]*Oe,u=n[1]*Oe,d=nt(c,u);d.imageSmoothingEnabled=!1;let f=d.canvas,g=new zf(d,Oe,r,null,o,a,l?Ye(hi(),l):null),p=e.length,m=Math.floor((256*256*256-1)/p),_={};for(let E=1;E<=p;++E){let x=e[E-1],C=x.getStyleFunction()||i;if(!C)continue;let T=C(x,s);if(!T)continue;Array.isArray(T)||(T=[T]);let S=(E*m).toString(16).padStart(7,"#00000");for(let w=0,M=T.length;w<M;++w){let N=T[w],z=N.getGeometryFunction()(x);if(!z||!lt(h,z.getExtent()))continue;let A=N.clone(),H=A.getFill();H&&H.setColor(S);let $=A.getStroke();$&&($.setColor(S),$.setLineDash(null)),A.setText(void 0);let P=N.getImage();if(P){let X=P.getImageSize();if(!X)continue;let tt=nt(X[0],X[1],void 0,{alpha:!1}),it=tt.canvas;tt.fillStyle=S,tt.fillRect(0,0,it.width,it.height),A.setImage(new Vr({img:it,anchor:P.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:P.getOrigin(),opacity:1,size:P.getSize(),scale:P.getScale(),rotation:P.getRotation(),rotateWithView:P.getRotateWithView()}))}let j=A.getZIndex()||0,k=_[j];k||(k={},_[j]=k,k.Polygon=[],k.Circle=[],k.LineString=[],k.Point=[]);let K=z.getType();if(K==="GeometryCollection"){let X=z.getGeometriesArrayRecursive();for(let tt=0,it=X.length;tt<it;++tt){let ot=X[tt];k[ot.getType().replace("Multi","")].push(ot,A)}}else k[K.replace("Multi","")].push(z,A)}}let y=Object.keys(_).map(Number).sort(jt);for(let E=0,x=y.length;E<x;++E){let C=_[y[E]];for(let T in C){let I=C[T];for(let S=0,w=I.length;S<w;S+=2){g.setStyle(I[S+1]);for(let M=0,N=t.length;M<N;++M)g.setTransform(t[M]),g.drawGeometry(I[S])}}}return d.getImageData(0,0,f.width,f.height)}function Wf(n,t,e){let i=[];if(e){let r=Math.floor(Math.round(n[0])*Oe),s=Math.floor(Math.round(n[1])*Oe),o=(Q(r,0,e.width-1)+Q(s,0,e.height-1)*e.width)*4,a=e.data[o],l=e.data[o+1],c=e.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/t.length);c&&c%u===0&&i.push(t[c/u-1])}return i}var Gp=.5,Xf={Point:Kp,LineString:Xp,Polygon:Bp,MultiPoint:Vp,MultiLineString:Up,MultiPolygon:Yp,GeometryCollection:Wp,Circle:zp};function Uf(n,t){return parseInt(U(n),10)-parseInt(U(t),10)}function Wh(n,t){let e=Xh(n,t);return e*e}function Xh(n,t){return Gp*n/t}function zp(n,t,e,i,r){let s=e.getFill(),o=e.getStroke();if(s||o){let l=n.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(s,o),l.drawCircle(t,i,r)}let a=e.getText();if(a&&a.getText()){let l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i)}}function Uh(n,t,e,i,r,s,o,a){let l=[],h=e.getImage();if(h){let d=!0,f=h.getImageState();f==b.LOADED||f==b.ERROR?d=!1:f==b.IDLE&&h.load(),d&&l.push(h.ready())}let c=e.getFill();c&&c.loading()&&l.push(c.ready());let u=l.length>0;return u&&Promise.all(l).then(()=>r(null)),jp(n,t,e,i,s,o,a),u}function jp(n,t,e,i,r,s,o){let a=e.getGeometryFunction()(t);if(!a)return;let l=a.simplifyTransformed(i,r);if(e.getRenderer())Yf(n,l,e,t,o);else{let c=Xf[l.getType()];c(n,l,e,t,o,s)}}function Yf(n,t,e,i,r){if(t.getType()=="GeometryCollection"){let o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)Yf(n,o[a],e,i,r);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),r)}function Wp(n,t,e,i,r,s){let o=t.getGeometriesArray(),a,l;for(a=0,l=o.length;a<l;++a){let h=Xf[o[a].getType()];h(n,o[a],e,i,r,s)}}function Xp(n,t,e,i,r){let s=e.getStroke();if(s){let a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,s),a.drawLineString(t,i,r)}let o=e.getText();if(o&&o.getText()){let a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,r)}}function Up(n,t,e,i,r){let s=e.getStroke();if(s){let a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,s),a.drawMultiLineString(t,i,r)}let o=e.getText();if(o&&o.getText()){let a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,r)}}function Yp(n,t,e,i,r){let s=e.getFill(),o=e.getStroke();if(o||s){let l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(s,o),l.drawMultiPolygon(t,i,r)}let a=e.getText();if(a&&a.getText()){let l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,r)}}function Kp(n,t,e,i,r,s){let o=e.getImage(),a=e.getText(),l=a&&a.getText(),h=s&&o&&l?{}:void 0;if(o){if(o.getImageState()!=b.LOADED)return;let c=n.getBuilder(e.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(t,i,r)}if(l){let c=n.getBuilder(e.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(t,i,r)}}function Vp(n,t,e,i,r,s){let o=e.getImage(),a=o&&o.getOpacity()!==0,l=e.getText(),h=l&&l.getText(),c=s&&a&&h?{}:void 0;if(a){if(o.getImageState()!=b.LOADED)return;let u=n.getBuilder(e.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(t,i,r)}if(h){let u=n.getBuilder(e.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(t,i,r)}}function Bp(n,t,e,i,r){let s=e.getFill(),o=e.getStroke();if(s||o){let l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(s,o),l.drawPolygon(t,i,r)}let a=e.getText();if(a&&a.getText()){let l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,r)}}var Yh=class extends Hn{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=ct(),this.wrappedRenderedExtent_=ct(),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(t,e,i){let r=e.extent,s=e.viewState,o=s.center,a=s.resolution,l=s.projection,h=s.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,p=!(g[dt.ANIMATING]||g[dt.INTERACTING]),m=this.context,_=Math.round(W(r)/a*f),y=Math.round(et(r)/a*f),E=u.getWrapX()&&l.canWrapX(),x=E?W(c):null,C=E?Math.ceil((r[2]-c[2])/x)+(this.extendX_?2:1):1,T=E?Math.floor((r[0]-c[0])/x)-(this.extendX_?1:0):0;do{let I=this.getRenderTransform(o,a,0,f,_,y,T*x);e.declutter&&(I=I.slice(0)),t.execute(m,[m.canvas.width,m.canvas.height],I,h,p,i===void 0?Hi:i?zh:Df,i?d&&e.declutter[d]:void 0)}while(++T<C)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=nt(this.context.canvas.width,this.context.canvas.height,Ch))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){let t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,on(this.context),Ch.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.clipExtent_&&this.clipUnrotated(this.context,t,this.clipExtent_),this.replayGroup_.renderDeferred(),this.clipExtent_&&(this.context.restore(),this.clipExtent_=null),this.resetDrawContext_())}renderFrame(t,e){let i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;let r=t.viewState;this.prepareContainer(t,e);let s=this.context,o=this.replayGroup_,a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Lt.PRERENDER)||this.getLayer().hasListener(Lt.POSTRENDER)))return this.container;this.setDrawContext_(),this.preRender(s,t);let l=r.projection;this.clipExtent_=null;let h=!1;if(a&&i.extent&&this.clipping){let c=Gt(i.extent,l);a=lt(c,t.extent),a&&!le(c,t.extent)&&(t.declutter?this.clipExtent_=c:(this.clipUnrotated(s,t,c),h=!0))}return a&&this.renderWorlds(o,t,this.getLayer().getDeclutter()?!1:void 0),h&&s.restore(),this.postRender(s,t),this.renderedRotation_!==r.rotation&&(this.renderedRotation_=r.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let i=this.frameState.size.slice(),r=this.renderedCenter_,s=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*Oe,d=i[1]*Oe;c.push(this.getRenderTransform(r,s,o,Oe,u,d,0).slice());let f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!le(g,l)){let m=l[0],_=W(g),y=0,E;for(;m<g[0];)--y,E=_*y,c.push(this.getRenderTransform(r,s,o,Oe,u,d,E).slice()),m+=_;for(y=0,m=l[2];m>g[2];)++y,E=_*y,c.push(this.getRenderTransform(r,s,o,Oe,u,d,E).slice()),m-=_}let p=hi();this.hitDetectionImageData_=jf(i,c,this.renderedFeatures_,h.getStyleFunction(),l,s,o,Wh(s,this.renderedPixelRatio_),p?a:null)}e(Wf(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,r,s){if(!this.replayGroup_)return;let o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){let p=U(d),m=h[p];if(m){if(m!==!0&&g<m.distanceSq){if(g===0)return h[p]=!0,s.splice(s.lastIndexOf(m),1),r(d,l,f);m.geometry=f,m.distanceSq=g}}else{if(g===0)return h[p]=!0,r(d,l,f);s.push(h[p]={feature:d,layer:l,geometry:f,distanceSq:g,callback:r})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,u?e.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){let t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){let e=this.getLayer(),i=e.getSource();if(!i)return!1;let r=t.viewHints[dt.ANIMATING],s=t.viewHints[dt.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&r||!a&&s)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let l=t.extent,h=t.viewState,c=h.projection,u=h.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer(),p=e.getRenderOrder();p===void 0&&(p=Uf);let m=h.center.slice(),_=ri(l,g*u),y=_.slice(),E=[_.slice()],x=c.getExtent(),C=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,C){let P=i.getExtent();P&&!Yt(P)&&(this.extendX_=P[0]<x[0]||P[2]>x[2])}if(C&&(!le(x,t.extent)||this.extendX_)){let P=W(x),j=Math.max(W(_)/2,P),k=x[0],K=x[2];this.extendX_&&(k-=P,K+=P),_[0]=k-j,_[2]=K+j,Tn(m,c);let X=_a(E[0],c);X[0]<x[0]&&X[2]<x[2]?E.push([X[0]+P,X[1],X[2]+P,X[3]]):X[0]>x[0]&&X[2]>x[2]&&E.push([X[0]-P,X[1],X[2]-P,X[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedPixelRatio_===d&&this.renderedRevision_==f&&this.renderedRenderOrder_==p&&this.renderedFrameDeclutter_===!!t.declutter&&le(this.wrappedRenderedExtent_,_))return Ot(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let T=new bf(Xh(u,d),_,u,d),I=hi(),S;if(I){for(let P=0,j=E.length;P<j;++P){let k=E[P],K=Mi(k,c);i.loadFeatures(K,Xu(u,c),I)}S=Ye(I,c)}else for(let P=0,j=E.length;P<j;++P)i.loadFeatures(E[P],u,c);let w=Wh(u,d),M=!0,N=(P,j)=>{let k,K=P.getStyleFunction()||e.getStyleFunction();if(K&&(k=K(P,u)),k){let X=this.renderFeature(P,w,k,T,S,this.getLayer().getDeclutter(),j);M=M&&!X}},z=Mi(_,c),A=i.getFeaturesInExtent(z);p&&A.sort(p);for(let P=0,j=A.length;P<j;++P)N(A[P],P);this.renderedFeatures_=A,this.ready=M;let H=T.finish(),$=new Gf(_,u,d,i.getOverlaps(),H,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=p,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=y,this.wrappedRenderedExtent_=_,this.renderedCenter_=m,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=$,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,r,s,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=Uh(r,t,i[h],e,this.boundHandleStyleImageChange_,s,o,a)||l;else l=Uh(r,t,i,e,this.boundHandleStyleImageChange_,s,o,a);return l}},Kf=Yh;var Kh=class extends Co{constructor(t){super(t)}createRenderer(){return new Kf(this)}},Vh=Kh;var Bh=class extends Hn{constructor(t){super(t),this.image=null,this.renderedSourceRevision_=0}getImage(){return this.image?this.image.getImage():null}prepareFrame(t){let e=t.layerStatesArray[t.layerIndex],i=t.pixelRatio,r=t.viewState,s=r.resolution,o=this.getLayer().getSource(),a=t.viewHints,l=t.extent;if(e.extent!==void 0&&(l=Ut(l,Gt(e.extent,r.projection))),!a[dt.ANIMATING]&&!a[dt.INTERACTING]&&!Yt(l))if(o){!this.getLayer().rendered&&this.renderedSourceRevision_!==o.getRevision()&&(this.image=null),this.renderedSourceRevision_=o.getRevision();let h=r.projection,c=o.getImage(l,s,i,h);c&&(this.loadImage(c)?this.image=c:c.getState()===b.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(t){let e=this.frameState;if(!e)return null;let i=this.getLayer(),r=ht(e.pixelToCoordinateTransform,t.slice()),s=i.getExtent();if(s&&!Jt(s,r))return null;let o=this.image.getExtent(),a=this.image.getImage(),l=W(o),h=Math.floor(a.width*((r[0]-o[0])/l));if(h<0||h>=a.width)return null;let c=et(o),u=Math.floor(a.height*((o[3]-r[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(t,e){let i=this.image,r=i.getExtent(),s=i.getResolution(),[o,a]=Array.isArray(s)?s:[s,s],l=i.getPixelRatio(),h=t.layerStatesArray[t.layerIndex],c=t.pixelRatio,u=t.viewState,d=u.center,f=u.resolution,g=c*o/(f*l),p=c*a/(f*l);this.prepareContainer(t,e);let m=this.context.canvas.width,_=this.context.canvas.height,y=this.getRenderContext(t),E=!1,x=!0;if(h.extent){let w=Gt(h.extent,u.projection);x=lt(w,t.extent),E=x&&!le(w,t.extent),E&&this.clipUnrotated(y,t,w)}let C=i.getImage(),T=Et(this.tempTransform,m/2,_/2,g,p,0,l*(r[0]-d[0])/o,l*(d[1]-r[3])/a);this.renderedResolution=a*c/l;let I=C.width*T[0],S=C.height*T[3];if(this.getLayer().getSource().getInterpolate()||(y.imageSmoothingEnabled=!1),this.preRender(y,t),x&&I>=.5&&S>=.5){let w=T[4],M=T[5],N=h.opacity;N!==1&&(y.save(),y.globalAlpha=N),y.drawImage(C,0,0,+C.width,+C.height,w,M,I,S),N!==1&&y.restore()}return this.postRender(this.context,t),E&&y.restore(),y.imageSmoothingEnabled=!0,this.container}},Vf=Bh;var Zh=class extends ci{constructor(t){t=t||{},super(t)}},Bf=Zh;var Hh=class extends Bf{constructor(t){super(t)}createRenderer(){return new Vf(this)}getData(t){return super.getData(t)}},Zf=Hh;var Jn=[0,0,0],qi=5,qh=class{constructor(t){this.minZoom=t.minZoom!==void 0?t.minZoom:0,this.resolutions_=t.resolutions,V(Qc(this.resolutions_,(r,s)=>s-r,!0),"`resolutions` must be sorted in descending order");let e;if(!t.origins){for(let r=0,s=this.resolutions_.length-1;r<s;++r)if(!e)e=this.resolutions_[r]/this.resolutions_[r+1];else if(this.resolutions_[r]/this.resolutions_[r+1]!==e){e=void 0;break}}this.zoomFactor_=e,this.maxZoom=this.resolutions_.length-1,this.origin_=t.origin!==void 0?t.origin:null,this.origins_=null,t.origins!==void 0&&(this.origins_=t.origins,V(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));let i=t.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=he(i)),V(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,t.tileSizes!==void 0&&(this.tileSizes_=t.tileSizes,V(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=t.tileSize!==void 0?t.tileSize:this.tileSizes_?null:256,V(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=i!==void 0?i:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],t.sizes!==void 0?this.fullTileRanges_=t.sizes.map((r,s)=>{let o=new vo(Math.min(0,r[0]),Math.max(r[0]-1,-1),Math.min(0,r[1]),Math.max(r[1]-1,-1));if(i){let a=this.getTileRangeForExtentAndZ(i,s);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(t,e,i){let r=this.getTileRangeForExtentAndZ(t,e);for(let s=r.minX,o=r.maxX;s<=o;++s)for(let a=r.minY,l=r.maxY;a<=l;++a)i([e,s,a])}forEachTileCoordParentTileRange(t,e,i,r){let s,o,a,l=null,h=t[0]-1;for(this.zoomFactor_===2?(o=t[1],a=t[2]):l=this.getTileCoordExtent(t,r);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),s=dn(o,o,a,a,i)):s=this.getTileRangeForExtentAndZ(l,h,i),e(h,s))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getOrigins(){return this.origins_}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]<this.maxZoom){if(this.zoomFactor_===2){let s=t[1]*2,o=t[2]*2;return dn(s,s+1,o,o+1,e)}let r=this.getTileCoordExtent(t,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(r,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,i){if(e>this.maxZoom||e<this.minZoom)return null;let r=t[0],s=t[1],o=t[2];if(e===r)return dn(s,o,s,o,i);if(this.zoomFactor_){let l=Math.pow(this.zoomFactor_,e-r),h=Math.floor(s*l),c=Math.floor(o*l);if(e<r)return dn(h,h,c,c,i);let u=Math.floor(l*(s+1))-1,d=Math.floor(l*(o+1))-1;return dn(h,u,c,d,i)}let a=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,e,i)}getTileRangeForExtentAndZ(t,e,i){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,Jn);let r=Jn[1],s=Jn[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,Jn);let o=Jn[1],a=Jn[2];return dn(r,o,s,a,i)}getTileCoordCenter(t){let e=this.getOrigin(t[0]),i=this.getResolution(t[0]),r=ft(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*r[0]*i,e[1]-(t[2]+.5)*r[1]*i]}getTileCoordExtent(t,e){let i=this.getOrigin(t[0]),r=this.getResolution(t[0]),s=ft(this.getTileSize(t[0]),this.tmpSize_),o=i[0]+t[1]*s[0]*r,a=i[1]-(t[2]+1)*s[1]*r,l=o+s[0]*r,h=a+s[1]*r;return Qt(o,a,l,h,e)}getTileCoordForCoordAndResolution(t,e,i){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,i)}getTileCoordForXYAndResolution_(t,e,i,r,s){let o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),h=ft(this.getTileSize(o),this.tmpSize_),c=a*(t-l[0])/i/h[0],u=a*(l[1]-e)/i/h[1];return r?(c=Ue(c,qi)-1,u=Ue(u,qi)-1):(c=vi(c,qi),u=vi(u,qi)),Vn(o,c,u,s)}getTileCoordForXYAndZ_(t,e,i,r,s){let o=this.getOrigin(i),a=this.getResolution(i),l=ft(this.getTileSize(i),this.tmpSize_),h=(t-o[0])/a/l[0],c=(o[1]-e)/a/l[1];return r?(h=Ue(h,qi)-1,c=Ue(c,qi)-1):(h=vi(h,qi),c=vi(c,qi)),Vn(i,h,c,s)}getTileCoordForCoordAndZ(t,e,i){return this.getTileCoordForXYAndZ_(t[0],t[1],e,!1,i)}getTileCoordResolution(t){return this.resolutions_[t[0]]}getTileSize(t){return this.tileSize_?this.tileSize_:this.tileSizes_[t]}getFullTileRange(t){return this.fullTileRanges_?this.fullTileRanges_[t]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,t):null}getZForResolution(t,e){let i=Ri(this.resolutions_,t,e||0);return Q(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return Ga(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){let e=this.resolutions_.length,i=new Array(e);for(let r=this.minZoom;r<e;++r)i[r]=this.getTileRangeForExtentAndZ(t,r);this.fullTileRanges_=i}},$h=qh;function Fo(n){let t=n.getDefaultTileGrid();return t||(t=Hp(n),n.setDefaultTileGrid(t)),t}function Hf(n,t,e){let i=t[0],r=n.getTileCoordCenter(t),s=Do(e);if(!Jt(s,r)){let o=W(s),a=Math.ceil((s[0]-r[0])/o);return r[0]+=o*a,n.getTileCoordForCoordAndZ(r,i)}return t}function Zp(n,t,e,i){i=i!==void 0?i:"top-left";let r=$f(n,t,e);return new $h({extent:n,origin:cu(n,i),resolutions:r,tileSize:e})}function qf(n){let t=n||{},e=t.extent||q("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:$f(e,t.maxZoom,t.tileSize,t.maxResolution)};return new $h(i)}function $f(n,t,e,i){t=t!==void 0?t:42,e=ft(e!==void 0?e:256);let r=et(n),s=W(n);i=i>0?i:Math.max(s/e[0],r/e[1]);let o=t+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function Hp(n,t,e,i){let r=Do(n);return Zp(r,t,e,i)}function Do(n){n=q(n);let t=n.getExtent();if(!t){let e=180*Se.degrees/n.getMetersPerUnit();t=Qt(-e,-e,e,e)}return t}function es(n,t){let e=[];Object.keys(t).forEach(function(r){t[r]!==null&&t[r]!==void 0&&e.push(r+"="+encodeURIComponent(t[r]))});let i=e.join("&");return n=n.replace(/[?&]$/,""),n+=n.includes("?")?"&":"?",n+i}var qp=/\{z\}/g,$p=/\{x\}/g,Jp=/\{y\}/g,Qp=/\{-y\}/g;function Jf(n,t,e,i,r){return n.replace(qp,t.toString()).replace($p,e.toString()).replace(Jp,i.toString()).replace(Qp,function(){if(r===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(r-i).toString()})}function Qf(n){let t=[],e=/\{([a-z])-([a-z])\}/.exec(n);if(e){let i=e[1].charCodeAt(0),r=e[2].charCodeAt(0),s;for(s=i;s<=r;++s)t.push(n.replace(e[0],String.fromCharCode(s)));return t}if(e=/\{(\d+)-(\d+)\}/.exec(n),e){let i=parseInt(e[2],10);for(let r=parseInt(e[1],10);r<=i;r++)t.push(n.replace(e[0],r.toString()));return t}return t.push(n),t}function t_(n,t){return(function(e,i,r){if(!e)return;let s,o=e[0];if(t){let a=t.getFullTileRange(o);a&&(s=a.getHeight()-1)}return Jf(n,o,e[1],e[2],s)})}function tg(n,t){let e=n.length,i=new Array(e);for(let r=0;r<e;++r)i[r]=t_(n[r],t);return e_(i)}function e_(n){return n.length===1?n[0]:(function(t,e,i){if(!t)return;let r=Lo(t),s=Wt(r,n.length);return n[s](t,e,i)})}var Jh=class extends pt{constructor(t){super(),this.projection=q(t.projection),this.attributions_=eg(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;let e=this;this.viewPromise_=new Promise(function(i,r){e.viewResolver=i,e.viewRejector=r})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=eg(t),this.changed()}setState(t){this.state_=t,this.changed()}};function eg(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}var Qn=Jh;var Qh=class extends Qn{constructor(t){super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:t.projection,state:t.state,wrapX:t.wrapX,interpolate:t.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=t.tilePixelRatio!==void 0?t.tilePixelRatio:1,this.tileGrid=t.tileGrid!==void 0?t.tileGrid:null;let e=[256,256];this.tileGrid&&ft(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||U(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){let e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,r,s,o){return F()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:Fo(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){let r=this.getTileGridForProjection(i),s=this.getTilePixelRatio(e),o=ft(r.getTileSize(t),this.tmpSize);return s==1?o:zd(o,s,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){let i=e!==void 0?e:this.getProjection(),r=e!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(t=Hf(r,t,i)),xf(t,r)?t:null}clear(){}refresh(){this.clear(),super.refresh()}},ko=class extends mt{constructor(t,e){super(t),this.tile=e}},ig=Qh;var No={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};var tc=class n extends ig{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===n.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){let e=t.target,i=U(e),r=e.getState(),s;r==O.LOADING?(this.tileLoadingKeys_[i]=!0,s=No.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],s=r==O.ERROR?No.TILELOADERROR:r==O.LOADED?No.TILELOADEND:void 0),s!=null&&this.dispatchEvent(new ko(s,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,typeof e<"u"?this.setKey(e):this.changed()}setUrl(t){let e=Qf(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;let e=t.join(`
7
- `);this.generateTileUrlFunction_?this.setTileUrlFunction(tg(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}},ng=tc;var ec=class extends ng{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:i_,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate!==void 0?t.interpolate:!0,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=t.crossOrigin!==void 0?t.crossOrigin:null,this.referrerPolicy=t.referrerPolicy,this.tileClass=t.tileClass!==void 0?t.tileClass:So,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!ve(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){let e=this.getProjection();if(this.tileGrid&&(!e||ve(e,t)))return this.tileGrid;let i=U(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=Fo(t)),this.tileGridForProjection[i]}createTile_(t,e,i,r,s,o){let a=[t,e,i],l=this.getTileCoordForTileUrlFunction(a,s),h=l?this.tileUrlFunction(l,r,s):void 0,c=new this.tileClass(a,h!==void 0?O.IDLE:O.EMPTY,h!==void 0?h:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(L.CHANGE,this.handleTileChange.bind(this)),c}getTile(t,e,i,r,s,o){let a=this.getProjection();if(!a||!s||ve(a,s))return this.getTileInternal(t,e,i,r,a||s);let l=[t,e,i],h=this.getKey(),c=this.getTileGridForProjection(a),u=this.getTileGridForProjection(s),d=this.getTileCoordForTileUrlFunction(l,s),f=new bo(a,c,s,u,l,d,this.getTilePixelRatio(r),this.getGutter(),(g,p,m,_)=>this.getTileInternal(g,p,m,_,a,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return f.key=h,f}getTileInternal(t,e,i,r,s,o){let a=this.getKey(),l=Bn(this,a,t,e,i);if(o&&o.containsKey(l))return o.get(l);let h=this.createTile_(t,e,i,r,s,a);return o?.set(l,h),h}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){let i=q(t);if(i){let r=U(i);r in this.tileGridForProjection||(this.tileGridForProjection[r]=e)}}};function i_(n,t){if(xt){let e=n.getCrossOrigin(),i="same-origin",r="same-origin";e==="anonymous"||e===""?(i="cors",r="omit"):e==="use-credentials"&&(i="cors",r="include");let s={mode:i,credentials:r,referrerPolicy:n.getReferrerPolicy()};fetch(t,s).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.blob()}).then(o=>createImageBitmap(o)).then(o=>{let a=n.getImage();a.width=o.width,a.height=o.height,a.getContext("2d").drawImage(o,0,0),o.close?.(),a.dispatchEvent(new Event("load"))}).catch(()=>{n.getImage().dispatchEvent(new Event("error"))});return}n.getImage().src=t}var Go=ec;var ic=class extends Go{constructor(t){t=t||{};let e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:qf({extent:Do(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,referrerPolicy:t.referrerPolicy,interpolate:t.interpolate,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX!==void 0?t.wrapX:!0,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=t.gutter!==void 0?t.gutter:0}getGutter(){return this.gutter_}},nc=ic;function is(n){return Array.isArray(n)?Math.min(...n):n}var rc=class extends co{constructor(t,e,i,r,s,o,a){let l=t.getExtent();l&&t.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);let h=e.getExtent();h&&e.canWrapX()&&(h=h.slice(),h[0]=-1/0,h[2]=1/0);let c=h?Ut(i,h):i,u=St(c),d=Vi(t,e,u,r),f=.5,g=new Mo(t,e,c,l,d*f,r),p=g.calculateSourceExtent(),m=Yt(p)?null:o(p,d,s),_=m?b.IDLE:b.EMPTY,y=m?m.getPixelRatio():1;super(i,r,y,_),this.targetProj_=e,this.maxSourceExtent_=l,this.triangulation_=g,this.targetResolution_=r,this.targetExtent_=i,this.sourceImage_=m,this.sourcePixelRatio_=y,this.interpolate_=a,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==b.LOADING&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){let t=this.sourceImage_.getState();if(t==b.LOADED){let e=W(this.targetExtent_)/this.targetResolution_,i=et(this.targetExtent_)/this.targetResolution_;this.canvas_=Io(e,i,this.sourcePixelRatio_,is(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_,!0)}this.state=t,this.changed()}load(){if(this.state==b.IDLE){this.state=b.LOADING,this.changed();let t=this.sourceImage_.getState();t==b.LOADED||t==b.ERROR?this.reproject_():(this.sourceListenerKey_=G(this.sourceImage_,L.CHANGE,e=>{let i=this.sourceImage_.getState();(i==b.LOADED||i==b.ERROR)&&(this.unlistenSource_(),this.reproject_())}),this.sourceImage_.load())}}unlistenSource_(){B(this.sourceListenerKey_),this.sourceListenerKey_=null}},rg=rc;var sc={IMAGELOADSTART:"imageloadstart",IMAGELOADEND:"imageloadend",IMAGELOADERROR:"imageloaderror"},oc=class extends mt{constructor(t,e){super(t),this.image=e}},ac=class extends Qn{constructor(t){super({attributions:t.attributions,projection:t.projection,state:t.state,interpolate:t.interpolate!==void 0?t.interpolate:!0}),this.on,this.once,this.un,this.loader=t.loader||null,this.resolutions_=t.resolutions!==void 0?t.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=t.loader?t.loader.length===0:!1,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(t){this.resolutions_=t}findNearestResolution(t){let e=this.getResolutions();if(e){let i=Ri(e,t,0);t=e[i]}return t}getImage(t,e,i,r){let s=this.getProjection();if(!s||!r||ve(s,r))return s&&(r=s),this.getImageInternal(t,e,i,r);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&ve(this.reprojectedImage_.getProjection(),r)&&this.reprojectedImage_.getResolution()==e&&we(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new rg(s,r,t,e,i,(o,a,l)=>this.getImageInternal(o,a,l,s),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(t,e,i,r){if(this.loader){let s=lc(t,e,i,1),o=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===r&&(this.wantedExtent_&&le(this.wantedExtent_,s)||le(this.image.getExtent(),s))&&(this.wantedResolution_&&is(this.wantedResolution_)===o||is(this.image.getResolution())===o)))return this.image;this.wantedProjection_=r,this.wantedExtent_=s,this.wantedResolution_=o,this.image=new co(s,o,i,this.loader),this.image.addEventListener(L.CHANGE,this.handleImageChange.bind(this))}return this.image}handleImageChange(t){let e=t.target,i;switch(e.getState()){case b.LOADING:this.loading=!0,i=sc.IMAGELOADSTART;break;case b.LOADED:this.loading=!1,i=sc.IMAGELOADEND;break;case b.ERROR:this.loading=!1,i=sc.IMAGELOADERROR;break;default:return}this.hasListener(i)&&this.dispatchEvent(new oc(i,e))}};function sg(n,t){n.getImage().src=t}function lc(n,t,e,i){let r=t/e,s=St(n),o=Ue(W(n)/r,4),a=Ue(et(n)/r,4),l=Ue((i-1)*o/2,4),h=o+2*l,c=Ue((i-1)*a/2,4),u=a+2*c;return oi(s,r,0,[h,u])}var og=ac;var ns="1.3.0",ag=[101,101];function lg(n,t,e,i,r){r.WIDTH=e[0],r.HEIGHT=e[1];let s=i.getAxisOrientation(),o=ur(r.VERSION,"1.3")>=0;r[o?"CRS":"SRS"]=i.getCode();let a=o&&s.startsWith("ne")?[t[1],t[0],t[3],t[2]]:t;return r.BBOX=a.join(","),es(n,r)}function hc(n,t,e,i,r,s,o){s=Object.assign({REQUEST:"GetMap"},s);let a=t/e,l=[da(W(n)/a,4),da(et(n)/a,4)];if(e!=1)switch(o){case"geoserver":let c=90*e+.5|0;"FORMAT_OPTIONS"in s?s.FORMAT_OPTIONS+=";dpi:"+c:s.FORMAT_OPTIONS="dpi:"+c;break;case"mapserver":s.MAP_RESOLUTION=90*e;break;case"carmentaserver":case"qgis":s.DPI=90*e;break;default:throw new Error("Unknown `serverType` configured")}return lg(r,n,l,i,s)}function rs(n,t){return Object.assign({REQUEST:t,SERVICE:"WMS",VERSION:ns,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},n)}function hg(n){let t=n.hidpi===void 0?!0:n.hidpi,e=q(n.projection||"EPSG:3857"),i=n.ratio||1.5,r=n.load||ho,s=n.crossOrigin??null,o=n.referrerPolicy;return(a,l,h)=>{a=lc(a,l,h,i),h!=1&&(!t||n.serverType===void 0)&&(h=1);let c=hc(a,l,h,e,n.url,rs(n.params,"GetMap"),n.serverType),u=new Image;return u.crossOrigin=s,o!==void 0&&(u.referrerPolicy=o),r(u,c).then(d=>({image:d,extent:a,pixelRatio:h}))}}function cg(n,t,e){if(n.url===void 0)return;let i=q(n.projection||"EPSG:3857"),r=oi(t,e,0,ag),s={QUERY_LAYERS:n.params.LAYERS,INFO_FORMAT:"application/json"};Object.assign(s,rs(n.params,"GetFeatureInfo"),n.params);let o=vi((t[0]-r[0])/e,4),a=vi((r[3]-t[1])/e,4),l=ur(s.VERSION,"1.3")>=0;return s[l?"I":"X"]=o,s[l?"J":"Y"]=a,lg(n.url,r,ag,i,s)}function ug(n,t){if(n.url===void 0)return;let e={SERVICE:"WMS",VERSION:ns,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(t!==void 0){let i=q(n.projection||"EPSG:3857").getMetersPerUnit()||1,r=28e-5;e.SCALE=t*i/r}if(Object.assign(e,n.params),n.params!==void 0&&e.LAYER===void 0){let i=e.LAYERS;if(!(!Array.isArray(i)||i.length!==1))return;e.LAYER=i}return es(n.url,e)}var cc=class extends Go{constructor(t){t=t||{};let e=Object.assign({},t.params);super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:t.projection,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileClass:t.tileClass,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction,url:t.url,urls:t.urls,wrapX:t.wrapX!==void 0?t.wrapX:!0,transition:t.transition,zDirection:t.zDirection}),this.gutter_=t.gutter!==void 0?t.gutter:0,this.params_=e,this.v13_=!0,this.serverType_=t.serverType,this.hidpi_=t.hidpi!==void 0?t.hidpi:!0,this.tmpExtent_=ct(),this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(t,e,i,r){let s=q(i),o=this.getProjection()||s,a=this.getTileGrid();a||(a=this.getTileGridForProjection(o));let l=de(t,s,o),h=Vi(o,s,t,e),c=a.getZForResolution(h,this.zDirection),u=a.getResolution(c),d=a.getTileCoordForCoordAndZ(l,c);if(a.getResolutions().length<=d[0])return;let f=a.getTileCoordExtent(d,this.tmpExtent_),g=this.gutter_;g!==0&&(f=ri(f,u*g,f));let p={QUERY_LAYERS:this.params_.LAYERS};Object.assign(p,rs(this.params_,"GetFeatureInfo"),r);let m=Math.floor((l[0]-f[0])/u),_=Math.floor((f[3]-l[1])/u);return p[this.v13_?"I":"X"]=m,p[this.v13_?"J":"Y"]=_,this.getRequestUrl_(d,f,1,o||s,p)}getLegendUrl(t,e){if(this.urls[0]===void 0)return;let i={SERVICE:"WMS",VERSION:ns,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(e===void 0||e.LAYER===void 0){let r=this.params_.LAYERS;if(!(!Array.isArray(r)||r.length===1))return;i.LAYER=r}if(t!==void 0){let r=this.getProjection()?this.getProjection().getMetersPerUnit():1,s=28e-5;i.SCALE=t*r/s}return Object.assign(i,e),es(this.urls[0],i)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(t,e,i,r,s){let o=this.urls;if(!o)return;let a;if(o.length==1)a=o[0];else{let l=Wt(Lo(t),o.length);a=o[l]}return hc(e,(this.tileGrid||this.getTileGridForProjection(r)).getResolution(t[0]),i,r,a,s,this.serverType_)}getTilePixelRatio(t){return!this.hidpi_||this.serverType_===void 0?1:t}getKeyForParams_(){let t=0,e=[];for(let i in this.params_)e[t++]=i+"-"+this.params_[i];return e.join("/")}setParams_(t){this.params_=t,this.updateV13_(),this.setKey(this.getKeyForParams_())}setParams(t){this.setParams_(Object.assign({},t))}updateParams(t){this.setParams_(Object.assign(this.params_,t))}updateV13_(){let t=this.params_.VERSION||ns;this.v13_=ur(t,"1.3")>=0}tileUrlFunction(t,e,i){let r=this.getTileGrid();if(r||(r=this.getTileGridForProjection(i)),r.getResolutions().length<=t[0])return;e!=1&&(!this.hidpi_||this.serverType_===void 0)&&(e=1);let s=r.getResolution(t[0]),o=r.getTileCoordExtent(t,this.tmpExtent_),a=this.gutter_;a!==0&&(o=ri(o,s*a,o));let l=Object.assign({},rs(this.params_,"GetMap"));return this.getRequestUrl_(t,o,e,i,l)}},dg=cc;var uc=class extends og{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions}),this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy,this.url_=t.url,this.imageLoadFunction_=t.imageLoadFunction!==void 0?t.imageLoadFunction:sg,this.params_=Object.assign({},t.params),this.serverType_=t.serverType,this.hidpi_=t.hidpi!==void 0?t.hidpi:!0,this.renderedRevision_=0,this.ratio_=t.ratio!==void 0?t.ratio:1.5,this.loaderProjection_=null}getFeatureInfoUrl(t,e,i,r){let s=q(i),o=this.getProjection();o&&o!==s&&(e=Vi(o,s,t,e),t=de(t,s,o));let a={url:this.url_,params:{...this.params_,...r},projection:o||s};return cg(a,t,e)}getLegendUrl(t,e){return ug({url:this.url_,params:{...this.params_,...e}},t)}getParams(){return this.params_}getImageInternal(t,e,i,r){return this.url_===void 0?null:((!this.loader||this.loaderProjection_!==r)&&(this.loaderProjection_=r,this.loader=hg({crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,params:this.params_,projection:r,serverType:this.serverType_,hidpi:this.hidpi_,url:this.url_,ratio:this.ratio_,load:(s,o)=>(this.image.setImage(s),this.imageLoadFunction_(this.image,o),ho(s))})),super.getImageInternal(t,e,i,r))}getImageLoadFunction(){return this.imageLoadFunction_}getUrl(){return this.url_}setImageLoadFunction(t){this.imageLoadFunction_=t,this.changed()}setUrl(t){t!=this.url_&&(this.url_=t,this.loader=null,this.changed())}setParams(t){this.params_=Object.assign({},t),this.loader=null,this.changed()}updateParams(t){Object.assign(this.params_,t),this.changed()}changed(){this.image=null,super.changed()}},fg=uc;var n_=!1;function r_(n,t,e,i,r,s,o){let a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,r):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=n_,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){let h=t.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?s(t.readFeatures(c,{extent:e,featureProjection:r}),t.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function dc(n,t){return function(e,i,r,s,o){r_(n,t,e,i,r,(a,l)=>{this.addFeatures(a),s!==void 0&&s(a)},()=>{this.changed(),o!==void 0&&o()})}}function gg(n,t){return[[-1/0,-1/0,1/0,1/0]]}var fc=class n extends pt{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if(typeof t.getSimplifiedGeometry=="function"){let e=t;this.setGeometry(e)}else{let e=t;this.setProperties(e)}}clone(){let t=new n(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());let e=this.getGeometry();e&&t.setGeometry(e.clone());let i=this.getStyle();return i&&t.setStyle(i),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(B(this.geometryChangeKey_),this.geometryChangeKey_=null);let t=this.getGeometry();t&&(this.geometryChangeKey_=G(t,L.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?s_(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}};function s_(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(V(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}var zo=fc;function jo(n,t,e,i){let r=[],s=ct();for(let o=0,a=e.length;o<a;++o){let l=e[o];s=En(n,t,l[0],i),r.push((s[0]+s[2])/2,(s[1]+s[3])/2),t=l[l.length-1]}return r}function mn(n,t,e,i,r,s,o){let a,l,h=(e-t)/i;if(h===1)a=t;else if(h===2)a=t,l=r;else if(h!==0){let c=n[t],u=n[t+1],d=0,f=[0];for(let m=t+i;m<e;m+=i){let _=n[m],y=n[m+1];d+=Math.sqrt((_-c)*(_-c)+(y-u)*(y-u)),f.push(d),c=_,u=y}let g=r*d,p=qc(f,g);p<0?(l=(g-f[-p-2])/(f[-p-1]-f[-p-2]),a=t+(-p-2)*i):a=t+p*i}o=o>1?o:2,s=s||new Array(o);for(let c=0;c<o;++c)s[c]=a===void 0?NaN:l===void 0?n[a+c]:bt(n[a+c],n[a+i+c],l);return s}function Wo(n,t,e,i,r,s){if(e==t)return null;let o;if(r<n[t+i-1])return s?(o=n.slice(t,t+i),o[i-1]=r,o):null;if(n[e-1]<r)return s?(o=n.slice(e-i,e),o[i-1]=r,o):null;if(r==n[t+i-1])return n.slice(t,t+i);let a=t/i,l=e/i;for(;a<l;){let d=a+l>>1;r<n[(d+1)*i-1]?l=d:a=d+1}let h=n[a*i-1];if(r==h)return n.slice((a-1)*i,(a-1)*i+i);let c=n[(a+1)*i-1],u=(r-h)/(c-h);o=[];for(let d=0;d<i-1;++d)o.push(bt(n[(a-1)*i+d],n[a*i+d],u));return o.push(r),o}function mg(n,t,e,i,r,s,o){if(o)return Wo(n,t,e[e.length-1],i,r,s);let a;if(r<n[i-1])return s?(a=n.slice(0,i),a[i-1]=r,a):null;if(n[n.length-1]<r)return s?(a=n.slice(n.length-i),a[i-1]=r,a):null;for(let l=0,h=e.length;l<h;++l){let c=e[l];if(t!=c){if(r<n[t+i-1])return null;if(r<=n[c-1])return Wo(n,t,c,i,r,!1);t=c}}return null}var mc=class n extends js{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(B),this.changeEventsKeys_.length=0}listenGeometriesChange_(){let t=this.geometries_;for(let e=0,i=t.length;e<i;++e)this.changeEventsKeys_.push(G(t[e],L.CHANGE,this.changed,this))}clone(){let t=new n(gc(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,i,r){if(r<Xt(this.getExtent(),t,e))return r;let s=this.geometries_;for(let o=0,a=s.length;o<a;++o)r=s[o].closestPointXY(t,e,i,r);return r}containsXY(t,e){let i=this.geometries_;for(let r=0,s=i.length;r<s;++r)if(i[r].containsXY(t,e))return!0;return!1}computeExtent(t){si(t);let e=this.geometries_;for(let i=0,r=e.length;i<r;++i)vs(t,e[i].getExtent());return t}getGeometries(){return gc(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[],e=this.geometries_;for(let i=0,r=e.length;i<r;++i)e[i].getType()===this.getType()?t=t.concat(e[i].getGeometriesArrayRecursive()):t.push(e[i]);return t}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<this.simplifiedGeometryMaxMinSquaredTolerance)return this;let e=[],i=this.geometries_,r=!1;for(let s=0,o=i.length;s<o;++s){let a=i[s],l=a.getSimplifiedGeometry(t);e.push(l),l!==a&&(r=!0)}return r?new n(e):(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getType(){return"GeometryCollection"}intersectsExtent(t){let e=this.geometries_;for(let i=0,r=e.length;i<r;++i)if(e[i].intersectsExtent(t))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(t,e){let i=this.geometries_;for(let r=0,s=i.length;r<s;++r)i[r].rotate(t,e);this.changed()}scale(t,e,i){i||(i=St(this.getExtent()));let r=this.geometries_;for(let s=0,o=r.length;s<o;++s)r[s].scale(t,e,i);this.changed()}setGeometries(t){this.setGeometriesArray(gc(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){let e=this.geometries_;for(let i=0,r=e.length;i<r;++i)e[i].applyTransform(t);this.changed()}translate(t,e){let i=this.geometries_;for(let r=0,s=i.length;r<s;++r)i[r].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}};function gc(n){return n.map(t=>t.clone())}var pc=mc;var _c=class n extends Vt{constructor(t,e){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendCoordinate(t){It(this.flatCoordinates,t),this.changed()}clone(){let t=new n(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,r){return r<Xt(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(mr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),_r(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,r))}forEachSegment(t){return Ys(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){return this.layout!="XYM"&&this.layout!="XYZM"?null:(e=e!==void 0?e:!1,Wo(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return fe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return mn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return qn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(t){let e=[];return e.length=sn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new n(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return wr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,this.getExtent())}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=rn(this.flatCoordinates,0,t,this.stride),this.changed()}},tr=_c;var yc=class n extends Vt{constructor(t,e,i){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(e!==void 0&&i)this.setFlatCoordinates(e,t),this.ends_=i;else{let r=t,s=[],o=[];for(let l=0,h=r.length;l<h;++l){let c=r[l];It(s,c.getFlatCoordinates()),o.push(s.length)}let a=r.length===0?this.getLayout():r[0].getLayout();this.setFlatCoordinates(a,s),this.ends_=o}}appendLineString(t){It(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let t=new n(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,r){return r<Xt(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(pr(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),yr(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,i,r))}getCoordinateAtM(t,e,i){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(e=e!==void 0?e:!1,i=i!==void 0?i:!1,mg(this.flatCoordinates,0,this.ends_,this.stride,t,e,i))}getCoordinates(){return Ai(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new tr(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){let t=this.flatCoordinates,e=this.ends_,i=this.layout,r=[],s=0;for(let o=0,a=e.length;o<a;++o){let l=e[o],h=new tr(t.slice(s,l),i);r.push(h),s=l}return r}getLength(){let t=this.ends_,e=0,i=0;for(let r=0,s=t.length;r<s;++r)i+=qn(this.flatCoordinates,e,t[r],this.stride),e=t[r];return i}getFlatMidpoints(){let t=[],e=this.flatCoordinates,i=0,r=this.ends_,s=this.stride;for(let o=0,a=r.length;o<a;++o){let l=r[o],h=mn(e,i,l,s,.5);It(t,h),i=l}return t}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=Xs(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,i),new n(e,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(t){return sd(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);let i=Li(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}},xc=yc;var Ec=class n extends Vt{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){It(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){let t=new n(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,r){if(r<Xt(this.getExtent(),t,e))return r;let s=this.flatCoordinates,o=this.stride;for(let a=0,l=s.length;a<l;a+=o){let h=Ce(t,e,s[a],s[a+1]);if(h<r){r=h;for(let c=0;c<o;++c)i[c]=s[a+c];i.length=o}}return r}getCoordinates(){return fe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){let e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new Oi(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){let t=this.flatCoordinates,e=this.layout,i=this.stride,r=[];for(let s=0,o=t.length;s<o;s+=i){let a=new Oi(t.slice(s,s+i),e);r.push(a)}return r}getType(){return"MultiPoint"}intersectsExtent(t){let e=this.flatCoordinates,i=this.stride;for(let r=0,s=e.length;r<s;r+=i){let o=e[r],a=e[r+1];if(hr(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=rn(this.flatCoordinates,0,t,this.stride),this.changed()}},ss=Ec;var Cc=class n extends Vt{constructor(t,e,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(t[0])){let r=t,s=[],o=[];for(let a=0,l=r.length;a<l;++a){let h=r[a],c=s.length,u=h.getEnds();for(let d=0,f=u.length;d<f;++d)u[d]+=c;It(s,h.getFlatCoordinates()),o.push(u)}e=r.length===0?this.getLayout():r[0].getLayout(),t=s,i=o}e!==void 0&&i?(this.setFlatCoordinates(e,t),this.endss_=i):this.setCoordinates(t,e)}appendPolygon(t){let e;if(!this.flatCoordinates)this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();else{let i=this.flatCoordinates.length;It(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let r=0,s=e.length;r<s;++r)e[r]+=i}this.endss_.push(e),this.changed()}clone(){let t=this.endss_.length,e=new Array(t);for(let r=0;r<t;++r)e[r]=this.endss_[r].slice();let i=new n(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,r){return r<Xt(this.getExtent(),t,e)?r:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Qu(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),td(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,r))}containsXY(t,e){return rd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return $u(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Tr(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,xr(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let t=jo(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Us(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new ss(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let t=this.flatCoordinates;Ks(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Tr(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){let e=[],i=[];return e.length=id(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new n(e,"XY",i)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(t===0)e=0;else{let s=this.endss_[t-1];e=s[s.length-1]}let i=this.endss_[t].slice(),r=i[i.length-1];if(e!==0)for(let s=0,o=i.length;s<o;++s)i[s]-=e;return new Di(this.flatCoordinates.slice(e,r),this.layout,i)}getPolygons(){let t=this.layout,e=this.flatCoordinates,i=this.endss_,r=[],s=0;for(let o=0,a=i.length;o<a;++o){let l=i[o].slice(),h=l[l.length-1];if(s!==0)for(let u=0,d=l.length;u<d;++u)l[u]-=s;let c=new Di(e.slice(s,h),t,l);r.push(c),s=h}return r}getType(){return"MultiPolygon"}intersectsExtent(t){return od(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);let i=Ws(this.flatCoordinates,0,t,this.stride,this.endss_);if(i.length===0)this.flatCoordinates.length=0;else{let r=i[i.length-1];this.flatCoordinates.length=r.length===0?0:r[r.length-1]}this.changed()}},Rc=Cc;var pg=Tt(),os=class n{constructor(t,e,i,r,s,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=s,this.squaredTolerance_,this.stride_=r,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Ts(this.flatCoordinates_):En(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let t=St(this.getExtent());this.flatInteriorPoints_=Rr(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let t=ld(this.flatCoordinates_,this.ends_),e=jo(this.flatCoordinates_,0,t,2);this.flatInteriorPoints_=Us(this.flatCoordinates_,0,t,2,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=mn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let t=this.flatCoordinates_,e=0,i=this.ends_;for(let r=0,s=i.length;r<s;++r){let o=i[r],a=mn(t,e,o,2,.5);It(this.flatMidpoints_,a),e=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=q(t);let e=t.getExtent(),i=t.getWorldExtent();if(e&&i){let r=et(i)/et(e);Et(pg,i[0],i[3],r,-r,0,0,0),Kt(this.flatCoordinates_,0,this.flatCoordinates_.length,2,pg,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new n(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=ms((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);let i=this.simplifiedGeometry_.getFlatCoordinates(),r;switch(this.type_){case"LineString":i.length=sn(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),r=[i.length];break;case"MultiLineString":r=[],i.length=Xs(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,r);break;case"Polygon":r=[],i.length=Er(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,r);break;default:}return r&&(this.simplifiedGeometry_=new n(this.type_,i,r,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}};os.prototype.getFlatCoordinates=os.prototype.getOrientedFlatCoordinates;var Fe=os;var wc=class{constructor(t){this.rbush_=new ln(t),this.items_={}}insert(t,e){let i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[U(e)]=i}load(t,e){let i=new Array(e.length);for(let r=0,s=e.length;r<s;r++){let o=t[r],a=e[r],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[r]=l,this.items_[U(a)]=l}this.rbush_.load(i)}remove(t){let e=U(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){let i=this.items_[U(e)],r=[i.minX,i.minY,i.maxX,i.maxY];we(r,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){let e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(r){return r.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let r=0,s=t.length;r<s;r++)if(i=e(t[r]),i)return i;return i}isEmpty(){return $t(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){let e=this.rbush_.toJSON();return Qt(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(let e in t.items_)this.items_[e]=t.items_[e]}},Sc=wc;var ee={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};var $e=class extends mt{constructor(t,e,i){super(t),this.feature=e,this.features=i}},Tc=class extends Qn{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=ni,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(V(this.format_,"`format` must be set when `url` is set"),this.loader_=dc(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:gg;let e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new Sc:null,this.loadedExtentsRtree_=new Sc,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,r;Array.isArray(t.features)?r=t.features:t.features&&(i=t.features,r=i.getArray()),!e&&i===void 0&&(i=new Mt(r)),r!==void 0&&this.addFeaturesInternal(r),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){let e=U(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);let i=t.getGeometry();if(i){let r=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(r,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new $e(ee.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Fe||(this.featureChangeKeys_[t]=[G(e,L.CHANGE,this.handleFeatureChange_,this),G(e,Ee.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){let r=String(e.getId());if(!(r in this.idIndex_))this.idIndex_[r]=e;else if(e instanceof Fe){let s=this.idIndex_[r];s instanceof Fe?Array.isArray(s)?s.push(e):this.idIndex_[r]=[s,e]:i=!1}else i=!1}return i&&(V(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){let e=[],i=[],r=[];for(let s=0,o=t.length;s<o;s++){let a=t[s],l=U(a);this.addToIndex_(l,a)&&i.push(a)}for(let s=0,o=i.length;s<o;s++){let a=i[s],l=U(a);this.setupChangeEvents_(l,a);let h=a.getGeometry();if(h){let c=h.getExtent();e.push(c),r.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,r),this.hasListener(ee.ADDFEATURE))for(let s=0,o=i.length;s<o;s++)this.dispatchEvent(new $e(ee.ADDFEATURE,i[s]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(ee.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(ee.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(wt.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(wt.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(let i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(B);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(let i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let e=new $e(ee.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){let i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(r){let s=r.getGeometry();if(s instanceof Fe||s.intersectsCoordinate(t))return e(r)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){let r=i.getGeometry();if(r instanceof Fe||r.intersectsExtent(t)){let s=e(i);if(s)return s}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),$t(this.nullGeometryFeatures_)||It(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){let e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);let r=Ms(t,e);return[].concat(...r.map(s=>this.featuresRtree_.getInExtent(s)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){let i=t[0],r=t[1],s=null,o=[NaN,NaN],a=1/0,l=[-1/0,-1/0,1/0,1/0];return e=e||ei,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){let c=h.getGeometry(),u=a;if(a=c instanceof Fe?0:c.closestPointXY(i,r,o,a),a<u){s=h;let d=Math.sqrt(a);l[0]=i-d,l[1]=r-d,l[2]=i+d,l[3]=r+d}}}),s}getExtent(t){return this.featuresRtree_?.getExtent(t)??null}getFeatureById(t){let e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){let e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){let e=t.target,i=U(e),r=e.getGeometry();if(!r)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{let o=r.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}let s=e.getId();if(s!==void 0){let o=s.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new $e(ee.CHANGEFEATURE,e))}hasFeature(t){let e=t.getId();return e!==void 0?e in this.idIndex_:U(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&$t(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){let r=this.loadedExtentsRtree_,s=this.strategy_(t,e,i);for(let o=0,a=s.length;o<a;++o){let l=s[o];r.forEachInExtent(l,function(c){return le(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new $e(ee.FEATURESLOADSTART)),this.loader_.call(this,l,e,i,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new $e(ee.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new $e(ee.FEATURESLOADERROR))}),r.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){let e=this.loadedExtentsRtree_,i=e.forEachInExtent(t,function(r){if(we(r.extent,t))return r});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,r=t.length;i<r;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){let e=U(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(B),delete this.featureChangeKeys_[e];let r=t.getId();if(r!==void 0){let s=r.toString(),o=this.idIndex_[s];o===t?delete this.idIndex_[s]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[s]=o[0]))}return delete this.uidIndex_[e],this.hasListener(ee.REMOVEFEATURE)&&this.dispatchEvent(new $e(ee.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(let e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){V(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(dc(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}},vc=Tc;var Ic=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=zo,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let i=e.dataProjection?q(e.dataProjection):this.readProjection(t);e.extent&&i&&i.getUnits()==="tile-pixels"&&(i=q(i),i.setWorldExtent(e.extent)),e={dataProjection:i,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return F()}readFeature(t,e){return F()}readFeatures(t,e){return F()}readGeometry(t,e){return F()}readProjection(t){return F()}writeFeature(t,e){return F()}writeFeatures(t,e){return F()}writeGeometry(t,e){return F()}},_g=Ic;function Xo(n,t,e){let i=e?q(e.featureProjection):null,r=e?q(e.dataProjection):null,s=n;if(i&&r&&!ve(i,r)){t&&(s=n.clone());let o=t?i:r,a=t?r:i;o.getUnits()==="tile-pixels"?s.transform(o,a):s.applyTransform(li(o,a))}if(t&&e&&e.decimals!==void 0){let o=Math.pow(10,e.decimals),a=function(l){for(let h=0,c=l.length;h<c;++h)l[h]=Math.round(l[h]*o)/o;return l};s===n&&(s=n.clone()),s.applyTransform(a)}return s}var o_={Point:Oi,LineString:tr,Polygon:Di,MultiPoint:ss,MultiLineString:xc,MultiPolygon:Rc};function a_(n,t,e){return Array.isArray(t[0])?(Ks(n,0,t,e)||(n=n.slice(),Tr(n,0,t,e)),n):(Sr(n,0,t,e)||(n=n.slice(),Pn(n,0,t,e)),n)}function Mc(n,t){let e=n.geometry;if(!e)return[];if(Array.isArray(e))return e.map(s=>Mc({...n,geometry:s})).flat();let i=e.type==="MultiPolygon"?"Polygon":e.type;if(i==="GeometryCollection"||i==="Circle")throw new Error("Unsupported geometry type: "+i);let r=e.layout.length;return Xo(new Fe(i,i==="Polygon"?a_(e.flatCoordinates,e.ends,r):e.flatCoordinates,e.ends?.flat(),r,n.properties||{},n.id).enableSimplifyTransformed(),!1,t)}function Uo(n,t){if(!n)return null;if(Array.isArray(n)){let i=n.map(r=>Uo(r,t));return new pc(i)}let e=o_[n.type];return Xo(new e(n.flatCoordinates,n.layout||"XY",n.ends),!1,t)}var bc=class extends _g{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Yo(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Yo(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return F()}readFeaturesFromObject(t,e){return F()}readGeometry(t,e){return this.readGeometryFromObject(Yo(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return F()}readProjection(t){return this.readProjectionFromObject(Yo(t))}readProjectionFromObject(t){return F()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return F()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return F()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return F()}};function Yo(n){if(typeof n=="string"){let t=JSON.parse(n);return t||null}return n!==null?n:null}var yg=bc;var Lc=class extends yg{constructor(t){t=t||{},super(),this.dataProjection=q(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=q(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let i=null;t.type==="Feature"?i=t:i={type:"Feature",geometry:t,properties:null};let r=Pc(i.geometry,e);if(this.featureClass===Fe)return Mc({geometry:r,id:i.id,properties:i.properties},e);let s=new zo;return this.geometryName_?s.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&s.setGeometryName(i.geometry_name),s.setGeometry(Uo(r,e)),"id"in i&&s.setId(i.id),i.properties&&s.setProperties(i.properties,!0),s}readFeaturesFromObject(t,e){let i=t,r=null;if(i.type==="FeatureCollection"){let s=t;r=[];let o=s.features;for(let a=0,l=o.length;a<l;++a){let h=this.readFeatureFromObject(o[a],e);h&&r.push(h)}}else r=[this.readFeatureFromObject(t,e)];return r.flat()}readGeometryFromObject(t,e){return l_(t,e)}readProjectionFromObject(t){let e=t.crs,i;if(e)if(e.type=="name")i=q(e.properties.name);else if(e.type==="EPSG")i=q("EPSG:"+e.properties.code);else throw new Error("Unknown SRS type");else i=this.dataProjection;return i}writeFeatureObject(t,e){e=this.adaptOptions(e);let i={type:"Feature",geometry:null,properties:null},r=t.getId();if(r!==void 0&&(i.id=r),!t.hasProperties())return i;let s=t.getProperties(),o=t.getGeometry();return o&&(i.geometry=Ac(o,e),delete s[t.getGeometryName()]),$t(s)||(i.properties=s),i}writeFeaturesObject(t,e){e=this.adaptOptions(e);let i=[];for(let r=0,s=t.length;r<s;++r)i.push(this.writeFeatureObject(t[r],e));return{type:"FeatureCollection",features:i}}writeGeometryObject(t,e){return Ac(t,this.adaptOptions(e))}};function Pc(n,t){if(!n)return null;let e;switch(n.type){case"Point":{e=c_(n);break}case"LineString":{e=u_(n);break}case"Polygon":{e=m_(n);break}case"MultiPoint":{e=f_(n);break}case"MultiLineString":{e=d_(n);break}case"MultiPolygon":{e=g_(n);break}case"GeometryCollection":{e=h_(n);break}default:throw new Error("Unsupported GeoJSON type: "+n.type)}return e}function l_(n,t){let e=Pc(n,t);return Uo(e,t)}function h_(n,t){return n.geometries.map(function(i){return Pc(i,t)})}function c_(n){let t=n.coordinates;return{type:"Point",flatCoordinates:t,layout:bi(t.length)}}function u_(n){let t=n.coordinates,e=t.flat();return{type:"LineString",flatCoordinates:e,ends:[e.length],layout:bi(t[0]?.length||2)}}function d_(n){let t=n.coordinates,e=t[0]?.[0]?.length||2,i=[],r=Li(i,0,t,e);return{type:"MultiLineString",flatCoordinates:i,ends:r,layout:bi(e)}}function f_(n){let t=n.coordinates;return{type:"MultiPoint",flatCoordinates:t.flat(),layout:bi(t[0]?.length||2)}}function g_(n){let t=n.coordinates,e=[],i=t[0]?.[0]?.[0].length||2,r=Ws(e,0,t,i);return{type:"MultiPolygon",flatCoordinates:e,ends:r,layout:bi(i)}}function m_(n){let t=n.coordinates,e=[],i=t[0]?.[0]?.length,r=Li(e,0,t,i);return{type:"Polygon",flatCoordinates:e,ends:r,layout:bi(i)}}function Ac(n,t){n=Xo(n,!0,t);let e=n.getType(),i;switch(e){case"Point":{i=C_(n,t);break}case"LineString":{i=__(n,t);break}case"Polygon":{i=R_(n,t);break}case"MultiPoint":{i=x_(n,t);break}case"MultiLineString":{i=y_(n,t);break}case"MultiPolygon":{i=E_(n,t);break}case"GeometryCollection":{i=p_(n,t);break}case"Circle":{i={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+e)}return i}function p_(n,t){return t=Object.assign({},t),delete t.featureProjection,{type:"GeometryCollection",geometries:n.getGeometriesArray().map(function(i){return Ac(i,t)})}}function __(n,t){return{type:"LineString",coordinates:n.getCoordinates()}}function y_(n,t){return{type:"MultiLineString",coordinates:n.getCoordinates()}}function x_(n,t){return{type:"MultiPoint",coordinates:n.getCoordinates()}}function E_(n,t){let e;return t&&(e=t.rightHanded),{type:"MultiPolygon",coordinates:n.getCoordinates(e)}}function C_(n,t){return{type:"Point",coordinates:n.getCoordinates()}}function R_(n,t){let e;return t&&(e=t.rightHanded),{type:"Polygon",coordinates:n.getCoordinates(e)}}var Oc=Lc;var xg=["fullscreenchange","webkitfullscreenchange"],Eg={ENTERFULLSCREEN:"enterfullscreen",LEAVEFULLSCREEN:"leavefullscreen"},Fc=class extends me{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target}),this.on,this.once,this.un,this.keys_=t.keys!==void 0?t.keys:!1,this.source_=t.source,this.isInFullscreen_=!1,this.boundHandleMapTargetChange_=this.handleMapTargetChange_.bind(this),this.cssClassName_=t.className!==void 0?t.className:"ol-full-screen",this.documentListeners_=[],this.activeClassName_=t.activeClassName!==void 0?t.activeClassName.split(" "):[this.cssClassName_+"-true"],this.inactiveClassName_=t.inactiveClassName!==void 0?t.inactiveClassName.split(" "):[this.cssClassName_+"-false"];let e=t.label!==void 0?t.label:"\u2922";this.labelNode_=typeof e=="string"?document.createTextNode(e):e;let i=t.labelActive!==void 0?t.labelActive:"\xD7";this.labelActiveNode_=typeof i=="string"?document.createTextNode(i):i;let r=t.tipLabel?t.tipLabel:"Toggle full-screen";this.button_=document.createElement("button"),this.button_.title=r,this.button_.setAttribute("type","button"),this.button_.appendChild(this.labelNode_),this.button_.addEventListener(L.CLICK,this.handleClick_.bind(this),!1),this.setClassName_(this.button_,this.isInFullscreen_),this.element.className=`${this.cssClassName_} ${ge} ${ki}`,this.element.appendChild(this.button_)}handleClick_(t){t.preventDefault(),this.handleFullScreen_()}handleFullScreen_(){let t=this.getMap();if(!t)return;let e=t.getOwnerDocument();if(Cg(e))if(Rg(e))S_(e);else{let i;this.source_?i=typeof this.source_=="string"?e.getElementById(this.source_):this.source_:i=t.getTargetElement(),this.keys_?w_(i):wg(i)}}handleFullScreenChange_(){let t=this.getMap();if(!t)return;let e=this.isInFullscreen_;this.isInFullscreen_=Rg(t.getOwnerDocument()),e!==this.isInFullscreen_&&(this.setClassName_(this.button_,this.isInFullscreen_),this.isInFullscreen_?(Dn(this.labelActiveNode_,this.labelNode_),this.dispatchEvent(Eg.ENTERFULLSCREEN)):(Dn(this.labelNode_,this.labelActiveNode_),this.dispatchEvent(Eg.LEAVEFULLSCREEN)),t.updateSize())}setClassName_(t,e){e?(t.classList.remove(...this.inactiveClassName_),t.classList.add(...this.activeClassName_)):(t.classList.remove(...this.activeClassName_),t.classList.add(...this.inactiveClassName_))}setMap(t){let e=this.getMap();e&&e.removeChangeListener(_t.TARGET,this.boundHandleMapTargetChange_),super.setMap(t),this.handleMapTargetChange_(),t&&t.addChangeListener(_t.TARGET,this.boundHandleMapTargetChange_)}handleMapTargetChange_(){let t=this.documentListeners_;for(let i=0,r=t.length;i<r;++i)B(t[i]);t.length=0;let e=this.getMap();if(e){let i=e.getOwnerDocument();Cg(i)?this.element.classList.remove(Ha):this.element.classList.add(Ha);for(let r=0,s=xg.length;r<s;++r)t.push(G(i,xg[r],this.handleFullScreenChange_,this));this.handleFullScreenChange_()}}};function Cg(n){let t=n.body;return!!(t.webkitRequestFullscreen||t.requestFullscreen&&n.fullscreenEnabled)}function Rg(n){return!!(n.webkitIsFullScreen||n.fullscreenElement)}function wg(n){n.requestFullscreen?n.requestFullscreen():n.webkitRequestFullscreen&&n.webkitRequestFullscreen()}function w_(n){n.webkitRequestFullscreen?n.webkitRequestFullscreen():wg(n)}function S_(n){n.exitFullscreen?n.exitFullscreen():n.webkitExitFullscreen&&n.webkitExitFullscreen()}var Dc=Fc;var kc="projection",Sg="coordinateFormat",Nc=class extends me{constructor(t){t=t||{};let e=document.createElement("div");e.className=t.className!==void 0?t.className:"ol-mouse-position",super({element:e,render:t.render,target:t.target}),this.on,this.once,this.un,this.addChangeListener(kc,this.handleProjectionChanged_),t.coordinateFormat&&this.setCoordinateFormat(t.coordinateFormat),t.projection&&this.setProjection(t.projection),this.renderOnMouseOut_=t.placeholder!==void 0,this.placeholder_=this.renderOnMouseOut_?t.placeholder:"&#160;",this.renderedHTML_=e.innerHTML,this.mapProjection_=null,this.transform_=null,this.wrapX_=t.wrapX!==!1}handleProjectionChanged_(){this.transform_=null}getCoordinateFormat(){return this.get(Sg)}getProjection(){return this.get(kc)}handleMouseMove(t){let e=this.getMap();this.updateHTML_(e.getEventPixel(t))}handleMouseOut(t){this.updateHTML_(null)}setMap(t){if(super.setMap(t),t){let e=t.getViewport();this.listenerKeys.push(G(e,Si.POINTERMOVE,this.handleMouseMove,this)),this.renderOnMouseOut_&&this.listenerKeys.push(G(e,Si.POINTEROUT,this.handleMouseOut,this)),this.updateHTML_(null)}}setCoordinateFormat(t){this.set(Sg,t)}setProjection(t){this.set(kc,q(t))}updateHTML_(t){let e=this.placeholder_;if(t&&this.mapProjection_){if(!this.transform_){let s=this.getProjection();s?this.transform_=Ye(this.mapProjection_,s):this.transform_=zu}let r=this.getMap().getCoordinateFromPixelInternal(t);if(r){let s=hi();if(s&&(this.transform_=Ye(this.mapProjection_,s)),this.transform_(r,r),this.wrapX_){let a=s||this.getProjection()||this.mapProjection_;Tn(r,a)}let o=this.getCoordinateFormat();o?e=o(r):e=r.toString()}}(!this.renderedHTML_||e!==this.renderedHTML_)&&(this.element.innerHTML=e,this.renderedHTML_=e)}render(t){let e=t.frameState;e?this.mapProjection_!=e.viewState.projection&&(this.mapProjection_=e.viewState.projection,this.transform_=null):this.mapProjection_=null}},Gc=Nc;var zc="units",T_=[1,2,5],as=25.4/.28,jc=class extends me{constructor(t){t=t||{};let e=document.createElement("div");e.style.pointerEvents="none",super({element:e,render:t.render,target:t.target}),this.on,this.once,this.un;let i=t.className!==void 0?t.className:t.bar?"ol-scale-bar":"ol-scale-line";this.innerElement_=document.createElement("div"),this.innerElement_.className=i+"-inner",this.element.className=i+" "+ge,this.element.appendChild(this.innerElement_),this.viewState_=null,this.minWidth_=t.minWidth!==void 0?t.minWidth:64,this.maxWidth_=t.maxWidth,this.renderedVisible_=!1,this.renderedWidth_=void 0,this.renderedHTML_="",this.addChangeListener(zc,this.handleUnitsChanged_),this.setUnits(t.units||"metric"),this.scaleBar_=t.bar||!1,this.scaleBarSteps_=t.steps||4,this.scaleBarText_=t.text||!1,this.dpi_=t.dpi||void 0}getUnits(){return this.get(zc)}handleUnitsChanged_(){this.updateElement_()}setUnits(t){this.set(zc,t)}setDpi(t){this.dpi_=t}updateElement_(){let t=this.viewState_;if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}let e=t.center,i=t.projection,r=this.getUnits(),s=r=="degrees"?"degrees":"m",o=An(i,t.resolution,e,s),a=this.minWidth_*(this.dpi_||as)/as,l=this.maxWidth_!==void 0?this.maxWidth_*(this.dpi_||as)/as:void 0,h=a*o,c="";if(r=="degrees"){let E=Se.degrees;h*=E,h<E/60?(c="\u2033",o*=3600):h<E?(c="\u2032",o*=60):c="\xB0"}else if(r=="imperial")h<.9144?(c="in",o/=.0254):h<1609.344?(c="ft",o/=.3048):(c="mi",o/=1609.344);else if(r=="nautical")o/=1852,c="NM";else if(r=="metric")h<1e-6?(c="nm",o*=1e9):h<.001?(c="\u03BCm",o*=1e6):h<1?(c="mm",o*=1e3):h<1e3?c="m":(c="km",o/=1e3);else if(r=="us")h<.9144?(c="in",o*=39.37):h<1609.344?(c="ft",o/=.30480061):(c="mi",o/=1609.3472);else throw new Error("Invalid units");let u=3*Math.floor(Math.log(a*o)/Math.log(10)),d,f,g,p=0,m,_;for(;;){g=Math.floor(u/3);let E=Math.pow(10,g);if(d=T_[(u%3+3)%3]*E,f=Math.round(d/o),isNaN(f)){this.element.style.display="none",this.renderedVisible_=!1;return}if(l!==void 0&&f>=l){d=p,f=m,g=_;break}else if(f>=a)break;p=d,m=f,_=g,++u}let y=this.scaleBar_?this.createScaleBar(f,d,c):d.toFixed(g<0?-g:0)+" "+c;this.renderedHTML_!=y&&(this.innerElement_.innerHTML=y,this.renderedHTML_=y),this.renderedWidth_!=f&&(this.innerElement_.style.width=f+"px",this.renderedWidth_=f),this.renderedVisible_||(this.element.style.display="",this.renderedVisible_=!0)}createScaleBar(t,e,i){let r=this.getScaleForResolution(),s=r<1?Math.round(1/r).toLocaleString()+" : 1":"1 : "+Math.round(r).toLocaleString(),o=this.scaleBarSteps_,a=t/o,l=[this.createMarker("absolute")];for(let c=0;c<o;++c){let u=c%2===0?"ol-scale-singlebar-odd":"ol-scale-singlebar-even";l.push(`<div><div class="ol-scale-singlebar ${u}" style="width: ${a}px;"></div>`+this.createMarker("relative")+(c%2===0||o===2?this.createStepText(c,t,!1,e,i):"")+"</div>")}return l.push(this.createStepText(o,t,!0,e,i)),(this.scaleBarText_?`<div class="ol-scale-text" style="width: ${t}px;">`+s+"</div>":"")+l.join("")}createMarker(t){return`<div class="ol-scale-step-marker" style="position: ${t}; top: ${t==="absolute"?3:-10}px;"></div>`}createStepText(t,e,i,r,s){let a=(t===0?0:Math.round(r/this.scaleBarSteps_*t*100)/100)+(t===0?"":" "+s),l=t===0?-3:e/this.scaleBarSteps_*-1,h=t===0?0:e/this.scaleBarSteps_*2;return`<div class="ol-scale-step-text" style="margin-left: ${l}px;text-align: ${t===0?"left":"center"};min-width: ${h}px;left: ${i?e+"px":"unset"};">`+a+"</div>"}getScaleForResolution(){let t=An(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m"),e=this.dpi_||as,i=1e3/25.4;return t*i*e}render(t){let e=t.frameState;e?this.viewState_=e.viewState:this.viewState_=null,this.updateElement_()}},Wc=jc;var Xc=class extends pe{constructor(t){t=t||{},super(t),this.condition_=t.condition?t.condition:to,this.lastAngle_=void 0,this.lastMagnitude_=void 0,this.lastScaleDelta_=0,this.duration_=t.duration!==void 0?t.duration:400}handleDragEvent(t){if(!Ni(t))return;let e=t.map,i=e.getSize(),r=t.pixel,s=r[0]-i[0]/2,o=i[1]/2-r[1],a=Math.atan2(o,s),l=Math.sqrt(s*s+o*o),h=e.getView();if(this.lastAngle_!==void 0){let c=this.lastAngle_-a;h.adjustRotationInternal(c)}this.lastAngle_=a,this.lastMagnitude_!==void 0&&h.adjustResolutionInternal(this.lastMagnitude_/l),this.lastMagnitude_!==void 0&&(this.lastScaleDelta_=this.lastMagnitude_/l),this.lastMagnitude_=l}handleUpEvent(t){if(!Ni(t))return!0;let i=t.map.getView(),r=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,r),this.lastScaleDelta_=0,!1}handleDownEvent(t){return Ni(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,this.lastMagnitude_=void 0,!0):!1}},Ko=Xc;var Vo=class{model;el;map=null;mapContainer=null;lastProcessedCallId=0;pendingCalls=[];eventQueue=[];isMapReady=!1;methodHandlers=new Map;modelListeners=[];constructor(t,e){this.model=t,this.el=e}createMapContainer(){let t=this.model.get("width")||"100%",e=this.model.get("height")||"400px";this.el.style.width="100%",this.el.style.display="block",e.endsWith("%")&&(this.el.style.height="100%");let i=document.createElement("div");return i.style.width=t,i.style.height=e,i.style.position="relative",i.style.minWidth="200px",this.el.appendChild(i),this.mapContainer=i,i}setupModelListeners(){let t=()=>this.processJsCalls(),e=()=>this.onCenterChange(),i=()=>this.onZoomChange(),r=()=>this.onStyleChange();this.model.on("change:_js_calls",t),this.model.on("change:center",e),this.model.on("change:zoom",i),this.model.on("change:style",r),this.modelListeners.push(()=>this.model.off("change:_js_calls",t),()=>this.model.off("change:center",e),()=>this.model.off("change:zoom",i),()=>this.model.off("change:style",r))}removeModelListeners(){this.modelListeners.forEach(t=>t()),this.modelListeners=[]}registerMethod(t,e){this.methodHandlers.set(t,e)}executeMethod(t,e,i){let r=this.methodHandlers.get(t);if(r)try{r(e,i)}catch(s){console.error(`Error executing method ${t}:`,s)}else console.warn(`Unknown method: ${t}`)}processJsCalls(){let e=(this.model.get("_js_calls")||[]).filter(i=>i.id>this.lastProcessedCallId);for(let i of e)this.isMapReady?this.executeMethod(i.method,i.args,i.kwargs):this.pendingCalls.push(i),this.lastProcessedCallId=i.id}processPendingCalls(){for(let t of this.pendingCalls)this.executeMethod(t.method,t.args,t.kwargs);this.pendingCalls=[]}sendEvent(t,e){let i={type:t,data:e,timestamp:Date.now()};this.eventQueue.push(i),this.model.set("_js_events",[...this.eventQueue]),this.model.save_changes()}restoreState(){let t=this.model.get("_sources")||{};for(let[l,h]of Object.entries(t))this.executeMethod("addSource",[l],h);let e=new Set(["fill","line","symbol","circle","heatmap","fill-extrusion","raster","hillshade","color-relief","background"]),i=this.model.get("_layers")||{},r=Object.entries(i).filter(([,l])=>e.has(l.type)),s=r.filter(([l,h])=>l.startsWith("basemap-")||h.type==="raster"),o=r.filter(([l,h])=>!(l.startsWith("basemap-")||h.type==="raster")),a=[...s,...o];for(let[l,h]of a)this.executeMethod("addLayer",[],h)}getMap(){return this.map}getIsMapReady(){return this.isMapReady}getModel(){return this.model}};var Bo=class extends Vo{map=null;olMethodHandlers={};layersMap=new globalThis.Map;controlsMap=new globalThis.Map;constructor(t,e){super(t,e),this.registerDefaultMethods()}registerMethod(t,e){this.olMethodHandlers[t]=e}registerDefaultMethods(){this.registerMethod("addBasemap",this.handleAddBasemap.bind(this)),this.registerMethod("addTileLayer",this.handleAddTileLayer.bind(this)),this.registerMethod("addGeoJSON",this.handleAddGeoJSON.bind(this)),this.registerMethod("addWMSLayer",this.handleAddWMSLayer.bind(this)),this.registerMethod("addImageWMSLayer",this.handleAddImageWMSLayer.bind(this)),this.registerMethod("removeLayer",this.handleRemoveLayer.bind(this)),this.registerMethod("setVisibility",this.handleSetVisibility.bind(this)),this.registerMethod("setOpacity",this.handleSetOpacity.bind(this)),this.registerMethod("addControl",this.handleAddControl.bind(this)),this.registerMethod("removeControl",this.handleRemoveControl.bind(this)),this.registerMethod("setCenter",this.handleSetCenter.bind(this)),this.registerMethod("setZoom",this.handleSetZoom.bind(this)),this.registerMethod("flyTo",this.handleFlyTo.bind(this)),this.registerMethod("fitBounds",this.handleFitBounds.bind(this)),this.registerMethod("fitExtent",this.handleFitExtent.bind(this)),this.registerMethod("addMarker",this.handleAddMarker.bind(this))}async initialize(){let t=this.model.get("center")||[0,0],e=this.model.get("zoom")||2;this.el.style.width="100%",this.el.style.display="block";let i=document.createElement("div");i.style.width=this.model.get("width")||"100%",i.style.height=this.model.get("height")||"600px",i.style.position="relative",i.style.minWidth="200px",this.el.appendChild(i),this.map=new ah({target:i,view:new Bt({center:nn(t),zoom:e}),controls:kn({attribution:!1}),interactions:jn().extend([new Ko])});let r=this.model.get("_js_calls");if(r&&r.length>0)for(let s of r)await this.executeOLMethod(s);this.model.on("change:_js_calls",()=>{this.handleJsCallsChange()}),this.model.on("change:center",()=>{let s=this.model.get("center");this.map&&this.map.getView().setCenter(nn(s))}),this.model.on("change:zoom",()=>{let s=this.model.get("zoom");this.map&&this.map.getView().setZoom(s)}),this.map.getView().on("change:center",()=>{if(this.map){let s=Wu(this.map.getView().getCenter()||[0,0]);this.model.set("center",s),this.model.save_changes()}}),this.map.getView().on("change:resolution",()=>{if(this.map){let s=this.map.getView().getZoom();this.model.set("zoom",s),this.model.save_changes()}})}handleJsCallsChange(){let t=this.model.get("_js_calls");if(t&&t.length>0){let e=t[t.length-1];this.executeOLMethod(e)}}async executeOLMethod(t){let{method:e,args:i,kwargs:r}=t,s=this.olMethodHandlers[e];if(s)try{s(i,r)}catch(o){console.error(`Error executing method ${e}:`,o)}else console.warn(`Unknown method: ${e}`)}createMap(){let t=this.model.get("center")||[0,0],e=this.model.get("zoom")||2,i=this.createMapContainer();return new ah({target:i,view:new Bt({center:nn(t),zoom:e}),controls:kn({attribution:!1}),interactions:jn().extend([new Ko])})}onCenterChange(){let t=this.model.get("center");this.map&&this.map.getView().setCenter(nn(t))}onZoomChange(){let t=this.model.get("zoom");this.map&&this.map.getView().setZoom(t)}onStyleChange(){}handleAddBasemap(t,e){if(!this.map)return;let i=t[0],r=e.name||"basemap",s=e.attribution||"",o=this.layersMap.get("basemap-"+r);o&&this.map.removeLayer(o);let a=new Po({source:new nc({url:i,attributions:s?[s]:void 0}),zIndex:0});this.map.getLayers().insertAt(0,a),this.layersMap.set("basemap-"+r,a)}handleAddTileLayer(t,e){if(!this.map)return;let i=t[0],r=e.name||`tiles-${this.layersMap.size}`,s=e.attribution||"",o=e.opacity??1,a=e.minZoom??0,l=e.maxZoom??22,h=new Po({source:new nc({url:i,attributions:s?[s]:void 0,minZoom:a,maxZoom:l}),opacity:o});this.map.addLayer(h),this.layersMap.set(r,h)}handleAddGeoJSON(t,e){if(!this.map)return;let i=e.data,r=e.name||`geojson-${this.layersMap.size}`,s=e.fitBounds!==!1,o=e.style||{},a=new vc({features:new Oc().readFeatures(i,{featureProjection:"EPSG:3857"})}),l=new Vh({source:a,style:this.createVectorStyle(o)});if(this.map.addLayer(l),this.layersMap.set(r,l),s){let h=a.getExtent();h&&h.every(c=>isFinite(c))&&this.map.getView().fit(h,{padding:[50,50,50,50],duration:500})}}createVectorStyle(t){let e=new Pe({color:t.fillColor||"rgba(51, 136, 255, 0.5)"}),i=new Ki({color:t.strokeColor||"#3388ff",width:t.strokeWidth??2}),r=new Yi({radius:t.radius??6,fill:e,stroke:i});return new Ze({fill:e,stroke:i,image:r})}handleAddWMSLayer(t,e){if(!this.map)return;let i=e.url,r=e.name||`wms-${this.layersMap.size}`,s=e.layers,o=e.format||"image/png",a=e.transparent!==!1,l=e.attribution||"",h=new Po({source:new dg({url:i,params:{LAYERS:s,FORMAT:o,TRANSPARENT:a},serverType:e.serverType||void 0,attributions:l?[l]:void 0})});this.map.addLayer(h),this.layersMap.set(r,h)}handleAddImageWMSLayer(t,e){if(!this.map)return;let i=e.url,r=e.name||`imagewms-${this.layersMap.size}`,s=e.layers,o=e.format||"image/png",a=e.transparent!==!1,l=e.attribution||"",h=new Zf({source:new fg({url:i,params:{LAYERS:s,FORMAT:o,TRANSPARENT:a},serverType:e.serverType||void 0,attributions:l?[l]:void 0})});this.map.addLayer(h),this.layersMap.set(r,h)}handleRemoveLayer(t,e){if(!this.map)return;let[i]=t,r=this.layersMap.get(i);r&&(this.map.removeLayer(r),this.layersMap.delete(i))}handleSetVisibility(t,e){let[i,r]=t,s=this.layersMap.get(i);s&&s.setVisible(r)}handleSetOpacity(t,e){let[i,r]=t,s=this.layersMap.get(i);s&&s.setOpacity(r)}handleAddControl(t,e){if(!this.map)return;let i=t[0],r=e.position||"top-right",s;switch(i){case"zoom":case"navigation":s=new br;break;case"scale":s=new Wc({units:e.units||"metric"});break;case"fullscreen":s=new Dc;break;case"attribution":s=new Ir({collapsible:e.collapsible!==!1});break;case"rotate":s=new Mr({autoHide:e.autoHide!==!1});break;case"mousePosition":s=new Gc({coordinateFormat:mu(4),projection:"EPSG:4326"});break}s&&(this.map.addControl(s),this.controlsMap.set(i,s))}handleRemoveControl(t,e){if(!this.map)return;let[i]=t,r=this.controlsMap.get(i);r&&(this.map.removeControl(r),this.controlsMap.delete(i))}handleSetCenter(t,e){if(!this.map)return;let[i,r]=t;this.map.getView().setCenter(nn([i,r]))}handleSetZoom(t,e){if(!this.map)return;let[i]=t;this.map.getView().setZoom(i)}handleFlyTo(t,e){if(!this.map)return;let[i,r]=t,s=e.zoom,o=e.duration||2e3;this.map.getView().animate({center:nn([i,r]),zoom:s,duration:o})}handleFitBounds(t,e){if(!this.map)return;let i=t[0],r=e.padding||50,s=e.duration||1e3,o=fr([i[0],i[1],i[2],i[3]],"EPSG:4326","EPSG:3857");this.map.getView().fit(o,{padding:[r,r,r,r],duration:s})}handleFitExtent(t,e){if(!this.map)return;let i=t[0],r=e.padding||50,s=e.duration||1e3;this.map.getView().fit(i,{padding:[r,r,r,r],duration:s})}handleAddMarker(t,e){if(!this.map)return;let[i,r]=t,s=e.id||e.name||`marker-${this.layersMap.size}`,o=e.popup,a=e.color||"#3388ff",l=new Oc().readFeature({type:"Feature",geometry:{type:"Point",coordinates:[i,r]},properties:{popup:o}},{featureProjection:"EPSG:3857"}),h=Array.isArray(l)?l:[l],c=new vc({features:h}),u=new Ze({image:new Yi({radius:8,fill:new Pe({color:a}),stroke:new Ki({color:"#ffffff",width:2})})}),d=new Vh({source:c,style:u});this.map.addLayer(d),this.layersMap.set(s,d)}destroy(){this.removeModelListeners(),this.map&&(this.map.setTarget(void 0),this.map=null),this.layersMap.clear(),this.controlsMap.clear()}};var ls=null;function v_({model:n,el:t}){return ls=new Bo(n,t),ls.initialize().catch(e=>{console.error("Failed to initialize OpenLayers map:",e)}),()=>{ls&&(ls.destroy(),ls=null)}}var vO={render:v_};export{vO as default,v_ as render};
1
+ var fe={ADD:"add",REMOVE:"remove"};var He={PROPERTYCHANGE:"propertychange"};var L={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};var vh=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},Ci=vh;function hg(r,e,t){let i,n;t=t||_t;let s=0,o=r.length,a=!1;for(;s<o;)i=s+(o-s>>1),n=+t(r[i],e),n<0?s=i+1:(o=i,a=!n);return a?s:~s}function _t(r,e){return r>e?1:r<e?-1:0}function cg(r,e){return r<e?1:r>e?-1:0}function pn(r,e,t){if(r[0]<=e)return 0;let i=r.length;if(e<=r[i-1])return i-1;if(typeof t=="function"){for(let n=1;n<i;++n){let s=r[n];if(s===e)return n;if(s<e)return t(e,r[n-1],s)>0?n-1:n}return i-1}if(t>0){for(let n=1;n<i;++n)if(r[n]<e)return n-1;return i-1}if(t<0){for(let n=1;n<i;++n)if(r[n]<=e)return n;return i-1}for(let n=1;n<i;++n){if(r[n]==e)return n;if(r[n]<e)return r[n-1]-e<e-r[n]?n-1:n}return i-1}function ug(r,e,t){for(;e<t;){let i=r[e];r[e]=r[t],r[t]=i,++e,--t}}function je(r,e){let t=Array.isArray(e)?e:[e],i=t.length;for(let n=0;n<i;n++)r[r.length]=t[n]}function Ve(r,e){let t=r.length;if(t!==e.length)return!1;for(let i=0;i<t;i++)if(r[i]!==e[i])return!1;return!0}function dg(r,e,t){let i=e||_t;return r.every(function(n,s){if(s===0)return!0;let o=i(r[s-1],n);return!(o>0||t&&o===0)})}function xt(){return!0}function Ot(){return!1}function Bi(){}function Qo(r){let e,t,i;return function(){let n=Array.prototype.slice.call(arguments);return(!t||this!==i||!Ve(n,t))&&(i=this,t=n,e=r.apply(this,arguments)),e}}function ea(r){function e(){let t;try{t=r()}catch(i){return Promise.reject(i)}return t instanceof Promise?t:Promise.resolve(t)}return e()}function Dt(r){for(let e in r)delete r[e]}function wt(r){let e;for(e in r)return!1;return!e}var Sh=class{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};function fg(r){r.stopPropagation()}var ye=Sh;var Rh=class extends Ci{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;let i=this.listeners_||(this.listeners_={}),n=i[e]||(i[e]=[]);n.includes(t)||n.push(t)}dispatchEvent(e){let t=typeof e=="string",i=t?e:e.type,n=this.listeners_&&this.listeners_[i];if(!n)return;let s=t?new ye(e):e;s.target||(s.target=this.eventTarget_||this);let o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let h=0,c=n.length;h<c;++h)if("handleEvent"in n[h]?l=n[h].handleEvent(s):l=n[h].call(this,s),l===!1||s.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,Bi);delete o[i]}return l}disposeInternal(){this.listeners_&&Dt(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,t){if(!this.listeners_)return;let i=this.listeners_[e];if(!i)return;let n=i.indexOf(t);n!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(i[n]=Bi,++this.pendingRemovals_[e]):(i.splice(n,1),i.length===0&&delete this.listeners_[e]))}},vi=Rh;function k(r,e,t,i,n){if(n){let o=t;t=function(a){return r.removeEventListener(e,t),o.call(i??this,a)}}else i&&i!==r&&(t=t.bind(i));let s={target:r,type:e,listener:t};return r.addEventListener(e,t),s}function _n(r,e,t,i){return k(r,e,t,i,!0)}function K(r){r&&r.target&&(r.target.removeEventListener(r.type,r.listener),Dt(r))}var _r=class extends vi{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(L.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){let i=e.length,n=new Array(i);for(let s=0;s<i;++s)n[s]=k(this,e[s],t);return n}return k(this,e,t)}onceInternal(e,t){let i;if(Array.isArray(e)){let n=e.length;i=new Array(n);for(let s=0;s<n;++s)i[s]=_n(this,e[s],t)}else i=_n(this,e,t);return t.ol_key=i,i}unInternal(e,t){let i=t.ol_key;if(i)kx(i);else if(Array.isArray(e))for(let n=0,s=e.length;n<s;++n)this.removeEventListener(e[n],t);else this.removeEventListener(e,t)}};_r.prototype.on;_r.prototype.once;_r.prototype.un;function kx(r){if(Array.isArray(r))for(let e=0,t=r.length;e<t;++e)K(r[e]);else K(r)}var ta=_r;function j(){throw new Error("Unimplemented abstract method.")}var Nx=0;function P(r){return r.ol_uid||(r.ol_uid=String(++Nx))}var ia=class extends ye{constructor(e,t,i){super(e),this.key=t,this.oldValue=i}},wh=class extends ta{constructor(e){super(),this.on,this.once,this.un,P(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let t;return this.values_&&this.values_.hasOwnProperty(e)&&(t=this.values_[e]),t}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(e,t){let i;i=`change:${e}`,this.hasListener(i)&&this.dispatchEvent(new ia(i,e,t)),i=He.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new ia(i,e,t))}addChangeListener(e,t){this.addEventListener(`change:${e}`,t)}removeChangeListener(e,t){this.removeEventListener(`change:${e}`,t)}set(e,t,i){let n=this.values_||(this.values_={});if(i)n[e]=t;else{let s=n[e];n[e]=t,s!==t&&this.notify(e,s)}}setProperties(e,t){for(let i in e)this.set(i,e[i],t)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,t){if(this.values_&&e in this.values_){let i=this.values_[e];delete this.values_[e],wt(this.values_)&&(this.values_=null),t||this.notify(e,i)}}},De=wh;var gg={LENGTH:"length"},xr=class extends ye{constructor(e,t,i){super(e),this.element=t,this.index=i}},Ph=class extends De{constructor(e,t){if(super(),this.on,this.once,this.un,t=t||{},this.unique_=!!t.unique,this.array_=e??[],this.unique_)for(let i=1,n=this.array_.length;i<n;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let t=0,i=e.length;t<i;++t)this.push(e[t]);return this}forEach(e){let t=this.array_;for(let i=0,n=t.length;i<n;++i)e(t[i],i,t)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(gg.LENGTH)}insertAt(e,t){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new xr(fe.ADD,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){let t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){let t=this.array_;for(let i=0,n=t.length;i<n;++i)if(t[i]===e)return this.removeAt(i)}removeAt(e){if(e<0||e>=this.getLength())return;let t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new xr(fe.REMOVE,t,e)),t}setAt(e,t){let i=this.getLength();if(e>=i){this.insertAt(e,t);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);let n=this.array_[e];this.array_[e]=t,this.dispatchEvent(new xr(fe.REMOVE,n,e)),this.dispatchEvent(new xr(fe.ADD,t,e))}updateLength_(){this.set(gg.LENGTH,this.array_.length)}assertUnique_(e,t){let i=this.array_;for(let n=0,s=i.length;n<s;++n)if(i[n]===e&&n!==t)throw new Error("Duplicate item added to a unique collection")}},Ce=Ph;var Lh=class extends ye{constructor(e,t,i){super(e),this.map=t,this.frameState=i!==void 0?i:null}},xn=Lh;var bh=class extends xn{constructor(e,t,i,n,s,o){super(e,t,s),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=n!==void 0?n:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(e){this.pixel_=e}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(e){this.coordinate_=e}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}},Qt=bh;var ee={SINGLECLICK:"singleclick",CLICK:L.CLICK,DBLCLICK:L.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var Xn=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",Gx=Xn.includes("safari")&&!Xn.includes("chrom"),mg=Gx&&(Xn.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Xn)),pg=Xn.includes("webkit")&&!Xn.includes("edge"),Ih=Xn.includes("macintosh"),_g=typeof devicePixelRatio<"u"?devicePixelRatio:1,Ze=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,na=typeof Image<"u"&&Image.prototype.decode,Fh=typeof createImageBitmap=="function",ra=(function(){let r=!1;try{let e=Object.defineProperty({},"passive",{get:function(){r=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return r})();var kt={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var Mh=class extends vi{constructor(e,t){super(e),this.map_=e,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=t===void 0?1:t,this.down_=null;let i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=k(i,kt.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=k(i,kt.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(L.TOUCHMOVE,this.boundHandleTouchMove_,ra?{passive:!1}:!1)}emulateClick_(e){let t=new Qt(ee.CLICK,this.map_,e);this.dispatchEvent(t),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,t=new Qt(ee.DBLCLICK,this.map_,e),this.dispatchEvent(t)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;let i=new Qt(ee.SINGLECLICK,this.map_,e);this.dispatchEvent(i)},250)}updateActivePointers_(e){let t=e,i=t.pointerId;if(t.type==ee.POINTERUP||t.type==ee.POINTERCANCEL){delete this.trackedTouches_[i];for(let n in this.trackedTouches_)if(this.trackedTouches_[n].target!==t.target){delete this.trackedTouches_[n];break}}else(t.type==ee.POINTERDOWN||t.type==ee.POINTERMOVE)&&(this.trackedTouches_[i]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);let t=new Qt(ee.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(K),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);let t=new Qt(ee.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,"target",{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){let i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(k(i,ee.POINTERMOVE,this.handlePointerMove_,this),k(i,ee.POINTERUP,this.handlePointerUp_,this),k(this.element_,ee.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(k(this.element_.getRootNode(),ee.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;let t=new Qt(ee.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;let t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new Qt(ee.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){let t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!="boolean"||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(K(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(L.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(K(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(K),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},xg=Mh;var Nt={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var Pe={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"};var F={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function W(r,e){if(!r)throw new Error(e)}var Ls=1/0,Ah=class{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,Dt(this.queuedElements_)}dequeue(){let e=this.elements_,t=this.priorities_,i=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));let n=this.keyFunction_(i);return delete this.queuedElements_[n],i}enqueue(e){W(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");let t=this.priorityFunction_(e);return t!=Ls?(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){let t=this.elements_,i=this.priorities_,n=t.length,s=t[e],o=i[e],a=e;for(;e<n>>1;){let l=this.getLeftChildIndex_(e),h=this.getRightChildIndex_(e),c=h<n&&i[h]<i[l]?h:l;t[e]=t[c],i[e]=i[c],e=c}t[e]=s,i[e]=o,this.siftDown_(a,e)}siftDown_(e,t){let i=this.elements_,n=this.priorities_,s=i[t],o=n[t];for(;t>e;){let a=this.getParentIndex_(t);if(n[a]>o)i[t]=i[a],n[t]=n[a],t=a;else break}i[t]=s,n[t]=o}reprioritize(){let e=this.priorityFunction_,t=this.elements_,i=this.priorities_,n=0,s=t.length,o,a,l;for(a=0;a<s;++a)o=t[a],l=e(o),l==Ls?delete this.queuedElements_[this.keyFunction_(o)]:(i[n]=l,t[n++]=o);t.length=n,i.length=n,this.heapify_()}},yg=Ah;var Oh=class extends yg{constructor(e,t){super(i=>e.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=t,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(e){let t=super.enqueue(e);return t&&e[0].addEventListener(L.CHANGE,this.boundHandleTileChange_),t}getTilesLoading(){return this.tilesLoading_}handleTileChange(e){let t=e.target,i=t.getState();if(i===F.LOADED||i===F.ERROR||i===F.EMPTY){i!==F.ERROR&&t.removeEventListener(L.CHANGE,this.boundHandleTileChange_);let n=t.getKey();n in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[n],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(e,t){let i=0;for(;this.tilesLoading_<e&&i<t&&this.getCount()>0;){let n=this.dequeue()[0],s=n.getKey();n.getState()===F.IDLE&&!(s in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[s]=!0,++this.tilesLoading_,++i,n.load())}}},Eg=Oh;function Tg(r,e,t,i,n){if(!r||!(t in r.wantedTiles))return Ls;if(!r.wantedTiles[t][e.getKey()])return Ls;let s=r.viewState.center,o=i[0]-s[0],a=i[1]-s[1];return 65536*Math.log(n)+Math.sqrt(o*o+a*a)/n}var he={ANIMATING:0,INTERACTING:1};var Pt={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function B(r,e,t){return Math.min(Math.max(r,e),t)}function sa(r,e,t,i,n,s){let o=n-t,a=s-i;if(o!==0||a!==0){let l=((r-t)*o+(e-i)*a)/(o*o+a*a);l>1?(t=n,i=s):l>0&&(t+=o*l,i+=a*l)}return Gt(r,e,t,i)}function Gt(r,e,t,i){let n=t-r,s=i-e;return n*n+s*s}function Cg(r){let e=r.length;for(let i=0;i<e;i++){let n=i,s=Math.abs(r[i][i]);for(let a=i+1;a<e;a++){let l=Math.abs(r[a][i]);l>s&&(s=l,n=a)}if(s===0)return null;let o=r[n];r[n]=r[i],r[i]=o;for(let a=i+1;a<e;a++){let l=-r[a][i]/r[i][i];for(let h=i;h<e+1;h++)i==h?r[a][h]=0:r[a][h]+=l*r[i][h]}}let t=new Array(e);for(let i=e-1;i>=0;i--){t[i]=r[i][e]/r[i][i];for(let n=i-1;n>=0;n--)r[n][e]-=r[n][i]*t[i]}return t}function bs(r){return r*180/Math.PI}function Lt(r){return r*Math.PI/180}function lt(r,e){let t=r%e;return t*e<0?t+e:t}function ht(r,e,t){return r+t*(e-r)}function hi(r,e){let t=Math.pow(10,e);return Math.round(r*t)/t}function Dh(r,e){return Math.round(hi(r,e))}function yn(r,e){return Math.floor(hi(r,e))}function Si(r,e){return Math.ceil(hi(r,e))}function oa(r,e,t){if(r>=e&&r<t)return r;let i=t-e;return((r-e)%i+i)%i+e}function kh(r,e,t){return(function(i,n,s,o,a){if(!i)return;if(!n&&!e)return i;let l=e?0:s[0]*n,h=e?0:s[1]*n,c=a?a[0]:0,u=a?a[1]:0,d=r[0]+l/2+c,f=r[2]-l/2+c,g=r[1]+h/2+u,m=r[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let p=B(i[0],d,f),_=B(i[1],g,m);if(o&&t&&n){let x=30*n;p+=-x*Math.log(1+Math.max(0,d-i[0])/x)+x*Math.log(1+Math.max(0,i[0]-f)/x),_+=-x*Math.log(1+Math.max(0,g-i[1])/x)+x*Math.log(1+Math.max(0,i[1]-m)/x)}return[p,_]})}function vg(r){return r}var We={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Re(r){let e=me();for(let t=0,i=r.length;t<i;++t)Yn(e,r[t]);return e}function Ux(r,e,t){let i=Math.min.apply(null,r),n=Math.min.apply(null,e),s=Math.max.apply(null,r),o=Math.max.apply(null,e);return bt(i,n,s,o,t)}function Le(r,e,t){return t?(t[0]=r[0]-e,t[1]=r[1]-e,t[2]=r[2]+e,t[3]=r[3]+e,t):[r[0]-e,r[1]-e,r[2]+e,r[3]+e]}function la(r,e){return e?(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e):r.slice()}function Ut(r,e,t){let i,n;return e<r[0]?i=r[0]-e:r[2]<e?i=e-r[2]:i=0,t<r[1]?n=r[1]-t:r[3]<t?n=t-r[3]:n=0,i*i+n*n}function rt(r,e){return Is(r,e[0],e[1])}function Ue(r,e){return r[0]<=e[0]&&e[2]<=r[2]&&r[1]<=e[1]&&e[3]<=r[3]}function Is(r,e,t){return r[0]<=e&&e<=r[2]&&r[1]<=t&&t<=r[3]}function aa(r,e){let t=r[0],i=r[1],n=r[2],s=r[3],o=e[0],a=e[1],l=We.UNKNOWN;return o<t?l=l|We.LEFT:o>n&&(l=l|We.RIGHT),a<i?l=l|We.BELOW:a>s&&(l=l|We.ABOVE),l===We.UNKNOWN&&(l=We.INTERSECTING),l}function me(){return[1/0,1/0,-1/0,-1/0]}function bt(r,e,t,i,n){return n?(n[0]=r,n[1]=e,n[2]=t,n[3]=i,n):[r,e,t,i]}function zi(r){return bt(1/0,1/0,-1/0,-1/0,r)}function Ri(r,e){let t=r[0],i=r[1];return bt(t,i,t,i,e)}function yr(r,e,t,i,n){let s=zi(n);return Nh(s,r,e,t,i)}function qe(r,e){return r[0]==e[0]&&r[2]==e[2]&&r[1]==e[1]&&r[3]==e[3]}function Sg(r,e,t){return Math.abs(r[0]-e[0])<t&&Math.abs(r[2]-e[2])<t&&Math.abs(r[1]-e[1])<t&&Math.abs(r[3]-e[3])<t}function ha(r,e){return e[0]<r[0]&&(r[0]=e[0]),e[2]>r[2]&&(r[2]=e[2]),e[1]<r[1]&&(r[1]=e[1]),e[3]>r[3]&&(r[3]=e[3]),r}function Yn(r,e){e[0]<r[0]&&(r[0]=e[0]),e[0]>r[2]&&(r[2]=e[0]),e[1]<r[1]&&(r[1]=e[1]),e[1]>r[3]&&(r[3]=e[1])}function Nh(r,e,t,i,n){for(;t<i;t+=n)Bx(r,e[t],e[t+1]);return r}function Bx(r,e,t){r[0]=Math.min(r[0],e),r[1]=Math.min(r[1],t),r[2]=Math.max(r[2],e),r[3]=Math.max(r[3],t)}function Er(r,e){let t;return t=e($n(r)),t||(t=e(ji(r)),t)||(t=e(Kn(r)),t)||(t=e(Je(r)),t)?t:!1}function Fs(r){let e=0;return yt(r)||(e=z(r)*re(r)),e}function $n(r){return[r[0],r[1]]}function ji(r){return[r[2],r[1]]}function be(r){return[(r[0]+r[2])/2,(r[1]+r[3])/2]}function Rg(r,e){let t;if(e==="bottom-left")t=$n(r);else if(e==="bottom-right")t=ji(r);else if(e==="top-left")t=Je(r);else if(e==="top-right")t=Kn(r);else throw new Error("Invalid corner");return t}function Vi(r,e,t,i,n){let[s,o,a,l,h,c,u,d]=Gh(r,e,t,i);return bt(Math.min(s,a,h,u),Math.min(o,l,c,d),Math.max(s,a,h,u),Math.max(o,l,c,d),n)}function Gh(r,e,t,i){let n=e*i[0]/2,s=e*i[1]/2,o=Math.cos(t),a=Math.sin(t),l=n*o,h=n*a,c=s*o,u=s*a,d=r[0],f=r[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function re(r){return r[3]-r[1]}function Xe(r,e,t){let i=t||me();return te(r,e)?(r[0]>e[0]?i[0]=r[0]:i[0]=e[0],r[1]>e[1]?i[1]=r[1]:i[1]=e[1],r[2]<e[2]?i[2]=r[2]:i[2]=e[2],r[3]<e[3]?i[3]=r[3]:i[3]=e[3]):zi(i),i}function Je(r){return[r[0],r[3]]}function Kn(r){return[r[2],r[3]]}function z(r){return r[2]-r[0]}function te(r,e){return r[0]<=e[2]&&r[2]>=e[0]&&r[1]<=e[3]&&r[3]>=e[1]}function yt(r){return r[2]<r[0]||r[3]<r[1]}function wg(r,e){return e?(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e):r}function Pg(r,e){let t=(r[2]-r[0])/2*(e-1),i=(r[3]-r[1])/2*(e-1);r[0]-=t,r[2]+=t,r[1]-=i,r[3]+=i}function Lg(r,e,t){let i=!1,n=aa(r,e),s=aa(r,t);if(n===We.INTERSECTING||s===We.INTERSECTING)i=!0;else{let o=r[0],a=r[1],l=r[2],h=r[3],c=e[0],u=e[1],d=t[0],f=t[1],g=(f-u)/(d-c),m,p;s&We.ABOVE&&!(n&We.ABOVE)&&(m=d-(f-h)/g,i=m>=o&&m<=l),!i&&s&We.RIGHT&&!(n&We.RIGHT)&&(p=f-(d-l)*g,i=p>=a&&p<=h),!i&&s&We.BELOW&&!(n&We.BELOW)&&(m=d-(f-a)/g,i=m>=o&&m<=l),!i&&s&We.LEFT&&!(n&We.LEFT)&&(p=f-(d-o)*g,i=p>=a&&p<=h)}return i}function Ms(r,e,t,i){if(yt(r))return zi(t);let n=[];if(i>1){let a=r[2]-r[0],l=r[3]-r[1];for(let h=0;h<i;++h)n.push(r[0]+a*h/i,r[1],r[2],r[1]+l*h/i,r[2]-a*h/i,r[3],r[0],r[3]-l*h/i)}else n=[r[0],r[1],r[2],r[1],r[2],r[3],r[0],r[3]];e(n,n,2);let s=[],o=[];for(let a=0,l=n.length;a<l;a+=2)s.push(n[a]),o.push(n[a+1]);return Ux(s,o,t)}function As(r,e){let t=e.getExtent(),i=be(r);if(e.canWrapX()&&(i[0]<t[0]||i[0]>=t[2])){let n=z(t),o=Math.floor((i[0]-t[0])/n)*n;r[0]-=o,r[2]-=o}return r}function ca(r,e,t){if(e.canWrapX()){let i=e.getExtent();if(!isFinite(r[0])||!isFinite(r[2]))return[[i[0],r[1],i[2],r[3]]];As(r,e);let n=z(i);if(z(r)>n&&!t)return[[i[0],r[1],i[2],r[3]]];if(r[0]<i[0])return[[r[0]+n,r[1],i[2],r[3]],[i[0],r[1],r[2],r[3]]];if(r[2]>i[2])return[[r[0],r[1],i[2],r[3]],[i[0],r[1],r[2]-n,r[3]]]}return[r]}function Uh(r,e,t){let i=t!==void 0?r.toFixed(t):""+r,n=i.indexOf(".");return n=n===-1?i.length:n,n>e?i:new Array(1+e-n).join("0")+i}function Os(r,e){let t=(""+r).split("."),i=(""+e).split(".");for(let n=0;n<Math.max(t.length,i.length);n++){let s=parseInt(t[n]||"0",10),o=parseInt(i[n]||"0",10);if(s>o)return 1;if(o>s)return-1}return 0}function ua(r,e){return r[0]+=+e[0],r[1]+=+e[1],r}function bg(r,e){let t=e.getRadius(),i=e.getCenter(),n=i[0],s=i[1],o=r[0],a=r[1],l=o-n,h=a-s;l===0&&h===0&&(l=1);let c=Math.sqrt(l*l+h*h),u=n+t*l/c,d=s+t*h/c;return[u,d]}function Tr(r,e){let t=r[0],i=r[1],n=e[0],s=e[1],o=n[0],a=n[1],l=s[0],h=s[1],c=l-o,u=h-a,d=c===0&&u===0?0:(c*(t-o)+u*(i-a))/(c*c+u*u||0),f,g;return d<=0?(f=o,g=a):d>=1?(f=l,g=h):(f=o+d*c,g=a+d*u),[f,g]}function Ig(r){return(function(e){return jx(e,r)})}function Bh(r,e,t){let i=lt(e+180,360)-180,n=Math.abs(3600*i),s=t||0,o=Math.floor(n/3600),a=Math.floor((n-o*3600)/60),l=hi(n-o*3600-a*60,s);l>=60&&(l=0,a+=1),a>=60&&(a=0,o+=1);let h=o+"\xB0";return(a!==0||l!==0)&&(h+=" "+Uh(a,2)+"\u2032"),l!==0&&(h+=" "+Uh(l,2,s)+"\u2033"),i!==0&&(h+=" "+r.charAt(i<0?1:0)),h}function zx(r,e,t){return r?e.replace("{x}",r[0].toFixed(t)).replace("{y}",r[1].toFixed(t)):""}function Qe(r,e){let t=!0;for(let i=r.length-1;i>=0;--i)if(r[i]!=e[i]){t=!1;break}return t}function Cr(r,e){let t=Math.cos(e),i=Math.sin(e),n=r[0]*t-r[1]*i,s=r[1]*t+r[0]*i;return r[0]=n,r[1]=s,r}function da(r,e){return r[0]*=e,r[1]*=e,r}function ei(r,e){let t=r[0]-e[0],i=r[1]-e[1];return t*t+i*i}function Wi(r,e){return Math.sqrt(ei(r,e))}function Fg(r,e){return ei(r,Tr(r,e))}function jx(r,e){return zx(r,"{x}, {y}",e)}function En(r,e){if(e.canWrapX()){let t=z(e.getExtent()),i=Mg(r,e,t);i&&(r[0]-=i*t)}return r}function Mg(r,e,t){let i=e.getExtent(),n=0;return e.canWrapX()&&(r[0]<i[0]||r[0]>i[2])&&(t=t||z(i),n=Math.floor((r[0]-i[0])/t)),n}function Ag(r,e,t){let i=Math.sqrt((e[0]-r[0])*(e[0]-r[0])+(e[1]-r[1])*(e[1]-r[1])),n=[(e[0]-r[0])/i,(e[1]-r[1])/i],s=[-n[1],n[0]],o=Math.sqrt((t[0]-r[0])*(t[0]-r[0])+(t[1]-r[1])*(t[1]-r[1])),a=[(t[0]-r[0])/o,(t[1]-r[1])/o],l=i===0||o===0?0:Math.acos(B(a[0]*n[0]+a[1]*n[1],-1,1));return l=Math.max(l,1e-5),a[0]*s[0]+a[1]*s[1]>0?l:Math.PI*2-l}function zh(r){return Math.pow(r,3)}function Bt(r){return 1-zh(1-r)}function Og(r){return 3*r*r-2*r*r*r}function Dg(r){return r}var Vh=63710088e-1;function ga(r,e,t){t=t||Vh;let i=Lt(r[1]),n=Lt(e[1]),s=(n-i)/2,o=Lt(e[0]-r[0])/2,a=Math.sin(s)*Math.sin(s)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(n);return 2*t*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function jh(r,e){let t=0;for(let i=0,n=r.length;i<n-1;++i)t+=ga(r[i],r[i+1],e);return t}function ma(r,e){e=e||{};let t=e.radius||Vh,i=e.projection||"EPSG:3857",n=r.getType();n!=="GeometryCollection"&&(r=r.clone().transform(i,"EPSG:4326"));let s=0,o,a,l,h,c,u;switch(n){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":{o=r.getCoordinates(),s=jh(o,t);break}case"MultiLineString":case"Polygon":{for(o=r.getCoordinates(),l=0,h=o.length;l<h;++l)s+=jh(o[l],t);break}case"MultiPolygon":{for(o=r.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,u=a.length;c<u;++c)s+=jh(a[c],t);break}case"GeometryCollection":{let d=r.getGeometries();for(l=0,h=d.length;l<h;++l)s+=ma(d[l],e);break}default:throw new Error("Unsupported geometry type: "+n)}return s}function fa(r,e){let t=0,i=r.length,n=r[i-1][0],s=r[i-1][1];for(let o=0;o<i;o++){let a=r[o][0],l=r[o][1];t+=Lt(a-n)*(2+Math.sin(Lt(s))+Math.sin(Lt(l))),n=a,s=l}return t*e*e/2}function pa(r,e){e=e||{};let t=e.radius||Vh,i=e.projection||"EPSG:3857",n=r.getType();n!=="GeometryCollection"&&(r=r.clone().transform(i,"EPSG:4326"));let s=0,o,a,l,h,c,u;switch(n){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":{for(o=r.getCoordinates(),s=Math.abs(fa(o[0],t)),l=1,h=o.length;l<h;++l)s-=Math.abs(fa(o[l],t));break}case"MultiPolygon":{for(o=r.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],s+=Math.abs(fa(a[0],t)),c=1,u=a.length;c<u;++c)s-=Math.abs(fa(a[c],t));break}case"GeometryCollection":{let d=r.getGeometries();for(l=0,h=d.length;l<h;++l)s+=pa(d[l],e);break}default:throw new Error("Unsupported geometry type: "+n)}return s}var kg={info:1,warn:2,error:3,none:4},Vx=kg.info;function _a(...r){Vx>kg.warn||console.warn(...r)}var ci={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var Wh=class{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||ci[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}},Tn=Wh;var Ds=6378137,vr=Math.PI*Ds,Wx=[-vr,-vr,vr,vr],Xx=[-180,-85,180,85],xa=Ds*Math.log(Math.tan(Math.PI/2)),Cn=class extends Tn{constructor(e){super({code:e,units:"m",extent:Wx,global:!0,worldExtent:Xx,getPointResolution:function(t,i){return t/Math.cosh(i[1]/Ds)}})}},Xh=[new Cn("EPSG:3857"),new Cn("EPSG:102100"),new Cn("EPSG:102113"),new Cn("EPSG:900913"),new Cn("http://www.opengis.net/def/crs/EPSG/0/3857"),new Cn("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Ng(r,e,t,i){let n=r.length;t=t>1?t:2,i=i??t,e===void 0&&(t>2?e=r.slice():e=new Array(n));for(let s=0;s<n;s+=i){e[s]=vr*r[s]/180;let o=Ds*Math.log(Math.tan(Math.PI*(+r[s+1]+90)/360));o>xa?o=xa:o<-xa&&(o=-xa),e[s+1]=o}return e}function Gg(r,e,t,i){let n=r.length;t=t>1?t:2,i=i??t,e===void 0&&(t>2?e=r.slice():e=new Array(n));for(let s=0;s<n;s+=i)e[s]=180*r[s]/vr,e[s+1]=360*Math.atan(Math.exp(r[s+1]/Ds))/Math.PI-90;return e}var Yx=6378137,Ug=[-180,-90,180,90],$x=Math.PI*Yx/180,Xi=class extends Tn{constructor(e,t){super({code:e,units:"degrees",extent:Ug,axisOrientation:t,global:!0,metersPerUnit:$x,worldExtent:Ug})}},Yh=[new Xi("CRS:84"),new Xi("EPSG:4326","neu"),new Xi("urn:ogc:def:crs:OGC:1.3:CRS84"),new Xi("urn:ogc:def:crs:OGC:2:84"),new Xi("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Xi("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Xi("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];var $h={};function Bg(r){return $h[r]||$h[r.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function zg(r,e){$h[r]=e}var Sr={};function Rr(r,e,t){let i=r.getCode(),n=e.getCode();i in Sr||(Sr[i]={}),Sr[i][n]=t}function ya(r,e){return r in Sr&&e in Sr[r]?Sr[r][e]:null}var Ea=.9996,ti=.00669438,Ca=ti*ti,va=Ca*ti,Hn=ti/(1-ti),jg=Math.sqrt(1-ti),wr=(1-jg)/(1+jg),Yg=wr*wr,Kh=Yg*wr,Hh=Kh*wr,$g=Hh*wr,Kg=1-ti/4-3*Ca/64-5*va/256,Kx=3*ti/8+3*Ca/32+45*va/1024,Hx=15*Ca/256+45*va/1024,Zx=35*va/3072,qx=3/2*wr-27/32*Kh+269/512*$g,Jx=21/16*Yg-55/32*Hh,Qx=151/96*Kh-417/128*$g,ey=1097/512*Hh,Ta=6378137;function ty(r,e,t){let i=r-5e5,o=(t.north?e:e-1e7)/Ea/(Ta*Kg),a=o+qx*Math.sin(2*o)+Jx*Math.sin(4*o)+Qx*Math.sin(6*o)+ey*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-ti*h,m=Math.sqrt(1-ti*h),p=Ta/m,_=(1-ti)/g,x=Hn*c**2,y=x*x,E=i/(p*Ea),T=E*E,v=T*E,S=v*E,w=S*E,R=w*E,b=a-u/_*(T/2-S/24*(5+3*d+10*x-4*y-9*Hn))+R/720*(61+90*d+298*x+45*f-252*Hn-3*y),D=(E-v/6*(1+2*d+x)+w/120*(5-2*x+28*d-3*y+8*Hn+24*f))/c;return D=oa(D+Lt(Hg(t.number)),-Math.PI,Math.PI),[bs(D),bs(b)]}var Vg=-80,Wg=84,iy=-180,ny=180;function ry(r,e,t){r=oa(r,iy,ny),e<Vg?e=Vg:e>Wg&&(e=Wg);let i=Lt(e),n=Math.sin(i),s=Math.cos(i),o=n/s,a=o*o,l=a*a,h=Lt(r),c=Hg(t.number),u=Lt(c),d=Ta/Math.sqrt(1-ti*n**2),f=Hn*s**2,g=s*oa(h-u,-Math.PI,Math.PI),m=g*g,p=m*g,_=p*g,x=_*g,y=x*g,E=Ta*(Kg*i-Kx*Math.sin(2*i)+Hx*Math.sin(4*i)-Zx*Math.sin(6*i)),T=Ea*d*(g+p/6*(1-a+f)+x/120*(5-18*a+l+72*f-58*Hn))+5e5,v=Ea*(E+d*o*(m/2+_/24*(5-a+9*f+4*f**2)+y/720*(61-58*a+l+600*f-330*Hn)));return t.north||(v+=1e7),[T,v]}function Hg(r){return(r-1)*6-180+3}var sy=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Zg(r){let e=0;for(let n of sy){let s=r.match(n);if(s){e=parseInt(s[1]);break}}if(!e)return null;let t=0,i=!1;return e>32700&&e<32761?t=e-32700:e>32600&&e<32661&&(i=!0,t=e-32600),t?{number:t,north:i}:null}function Xg(r,e){return function(t,i,n,s){let o=t.length;n=n>1?n:2,s=s??n,i||(n>2?i=t.slice():i=new Array(o));for(let a=0;a<o;a+=s){let l=t[a],h=t[a+1],c=r(l,h,e);i[a]=c[0],i[a+1]=c[1]}return i}}function qg(r){return Zg(r)?new Tn({code:r,units:"m"}):null}function Jg(r){let e=Zg(r.getCode());return e?{forward:Xg(ry,e),inverse:Xg(ty,e)}:null}var oy=[Jg],ay=[qg];var qh=!0;function Qh(r){qh=!(r===void 0?!0:r)}function ec(r,e){if(e!==void 0){for(let t=0,i=r.length;t<i;++t)e[t]=r[t];e=e}else e=r.slice();return e}function em(r,e){if(e!==void 0&&r!==e){for(let t=0,i=r.length;t<i;++t)e[t]=r[t];r=e}return r}function Jh(r){zg(r.getCode(),r),Rr(r,r,ec)}function ly(r){r.forEach(Jh)}function $(r){if(typeof r!="string")return r;let e=Bg(r);if(e)return e;for(let t of ay){let i=t(r);if(i)return i}return null}function Pr(r,e,t,i){r=$(r);let n,s=r.getPointResolutionFunc();if(s){if(n=s(e,t),i&&i!==r.getUnits()){let o=r.getMetersPerUnit();o&&(n=n*o/ci[i])}}else{let o=r.getUnits();if(o=="degrees"&&!i||i=="degrees")n=e;else{let a=zt(r,$("EPSG:4326"));if(!a&&o!=="degrees")n=e*r.getMetersPerUnit();else{let h=[t[0]-e/2,t[1],t[0]+e/2,t[1],t[0],t[1]-e/2,t[0],t[1]+e/2];h=a(h,h,2);let c=ga(h.slice(0,2),h.slice(2,4)),u=ga(h.slice(4,6),h.slice(6,8));n=(c+u)/2}let l=i?ci[i]:r.getMetersPerUnit();l!==void 0&&(n/=l)}}return n}function Qg(r){ly(r),r.forEach(function(e){r.forEach(function(t){e!==t&&Rr(e,t,ec)})})}function hy(r,e,t,i){r.forEach(function(n){e.forEach(function(s){Rr(n,s,t),Rr(s,n,i)})})}function Sa(r,e){return r?typeof r=="string"?$(r):r:$(e)}function tm(r){return(function(e,t,i,n){let s=e.length;i=i!==void 0?i:2,n=n??i,t=t!==void 0?t:new Array(s);for(let o=0;o<s;o+=n){let a=r(e.slice(o,o+i)),l=a.length;for(let h=0,c=n;h<c;++h)t[o+h]=h>=l?e[o+h]:a[h]}return t})}function vn(r,e){return Qh(),ii(r,"EPSG:4326",e!==void 0?e:"EPSG:3857")}function ks(r,e){let t=ii(r,e!==void 0?e:"EPSG:3857","EPSG:4326"),i=t[0];return(i<-180||i>180)&&(t[0]=lt(i+180,360)-180),t}function Ie(r,e){if(r===e)return!0;let t=r.getUnits()===e.getUnits();return(r.getCode()===e.getCode()||zt(r,e)===ec)&&t}function zt(r,e){let t=r.getCode(),i=e.getCode(),n=ya(t,i);if(n)return n;let s=null,o=null;for(let l of oy)s||(s=l(r)),o||(o=l(e));if(!s&&!o)return null;let a="EPSG:4326";if(o)if(s)n=Zh(s.inverse,o.forward);else{let l=ya(t,a);l&&(n=Zh(l,o.forward))}else{let l=ya(a,i);l&&(n=Zh(s.inverse,l))}return n&&(Jh(r),Jh(e),Rr(r,e,n)),n}function Zh(r,e){return function(t,i,n,s){return i=r(t,i,n,s),e(i,i,n,s)}}function ct(r,e){let t=$(r),i=$(e);return zt(t,i)}function ii(r,e,t){let i=ct(e,t);if(!i){let n=$(e).getCode(),s=$(t).getCode();throw new Error(`No transform available between ${n} and ${s}`)}return i(r,void 0,r.length)}function jt(r,e,t,i){let n=ct(e,t);return Ms(r,n,void 0,i)}var ui=null;function we(){return ui}function ni(r,e){return ui?ii(r,e,ui):r}function ce(r,e){return ui?ii(r,ui,e):(qh&&!Qe(r,[0,0])&&r[0]>=-180&&r[0]<=180&&r[1]>=-90&&r[1]<=90&&(qh=!1,_a("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),r)}function Vt(r,e){return ui?jt(r,e,ui):r}function Be(r,e){return ui?jt(r,ui,e):r}function Ra(r,e){if(!ui)return r;let t=$(e).getMetersPerUnit(),i=ui.getMetersPerUnit();return t&&i?r*t/i:r}function cy(){Qg(Xh),Qg(Yh),hy(Yh,Xh,Ng,Gg)}cy();var im=new Array(6);function ae(){return[1,0,0,1,0,0]}function tc(r){return ic(r,1,0,0,1,0,0)}function Sn(r,e){let t=r[0],i=r[1],n=r[2],s=r[3],o=r[4],a=r[5],l=e[0],h=e[1],c=e[2],u=e[3],d=e[4],f=e[5];return r[0]=t*l+n*h,r[1]=i*l+s*h,r[2]=t*c+n*u,r[3]=i*c+s*u,r[4]=t*d+n*f+o,r[5]=i*d+s*f+a,r}function ic(r,e,t,i,n,s,o){return r[0]=e,r[1]=t,r[2]=i,r[3]=n,r[4]=s,r[5]=o,r}function Pa(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r}function le(r,e){let t=e[0],i=e[1];return e[0]=r[0]*t+r[2]*i+r[4],e[1]=r[1]*t+r[3]*i+r[5],e}function Lr(r,e,t){return Sn(r,ic(im,e,0,0,t,0,0))}function La(r,e,t){return Sn(r,ic(im,1,0,0,1,e,t))}function Ae(r,e,t,i,n,s,o,a){let l=Math.sin(s),h=Math.cos(s);return r[0]=i*h,r[1]=n*l,r[2]=-i*l,r[3]=n*h,r[4]=o*i*h-a*i*l+e,r[5]=o*n*l+a*n*h+t,r}function Yi(r,e){let t=uy(e);W(t!==0,"Transformation matrix cannot be inverted");let i=e[0],n=e[1],s=e[2],o=e[3],a=e[4],l=e[5];return r[0]=o/t,r[1]=-n/t,r[2]=-s/t,r[3]=i/t,r[4]=(s*l-o*a)/t,r[5]=-(i*l-n*a)/t,r}function uy(r){return r[0]*r[3]-r[1]*r[2]}var dy=[1e5,1e5,1e5,1e5,2,2];function nm(r){return"matrix("+r.join(", ")+")"}function wa(r){return r.substring(7,r.length-1).split(",").map(parseFloat)}function rm(r,e){let t=wa(r),i=wa(e);for(let n=0;n<6;++n)if(Math.round((t[n]-i[n])*dy[n])!==0)return!1;return!0}function ut(r,e,t,i,n,s,o){s=s||[],o=o||2;let a=0;for(let l=e;l<t;l+=i){let h=r[l],c=r[l+1];s[a++]=n[0]*h+n[2]*c+n[4],s[a++]=n[1]*h+n[3]*c+n[5];for(let u=2;u<o;u++)s[a++]=r[l+u]}return s&&s.length!=a&&(s.length=a),s}function br(r,e,t,i,n,s,o){o=o||[];let a=Math.cos(n),l=Math.sin(n),h=s[0],c=s[1],u=0;for(let d=e;d<t;d+=i){let f=r[d]-h,g=r[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let m=d+2;m<d+i;++m)o[u++]=r[m]}return o&&o.length!=u&&(o.length=u),o}function sm(r,e,t,i,n,s,o,a){a=a||[];let l=o[0],h=o[1],c=0;for(let u=e;u<t;u+=i){let d=r[u]-l,f=r[u+1]-h;a[c++]=l+n*d,a[c++]=h+s*f;for(let g=u+2;g<u+i;++g)a[c++]=r[g]}return a&&a.length!=c&&(a.length=c),a}function om(r,e,t,i,n,s,o){o=o||[];let a=0;for(let l=e;l<t;l+=i){o[a++]=r[l]+n,o[a++]=r[l+1]+s;for(let h=l+2;h<l+i;++h)o[a++]=r[h]}return o&&o.length!=a&&(o.length=a),o}var am=ae(),fy=[NaN,NaN],nc=class extends De{constructor(){super(),this.extent_=me(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Qo((e,t,i)=>{if(!i)return this.getSimplifiedGeometry(t);let n=this.clone();return n.applyTransform(i),n.getSimplifiedGeometry(t)})}simplifyTransformed(e,t){return this.simplifyTransformedInternal(this.getRevision(),e,t)}clone(){return j()}closestPointXY(e,t,i,n){return j()}containsXY(e,t){return this.closestPointXY(e,t,fy,Number.MIN_VALUE)===0}getClosestPoint(e,t){return t=t||[NaN,NaN],this.closestPointXY(e[0],e[1],t,1/0),t}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return j()}getExtent(e){if(this.extentRevision_!=this.getRevision()){let t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&zi(t),this.extentRevision_=this.getRevision()}return wg(this.extent_,e)}rotate(e,t){j()}scale(e,t,i){j()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return j()}getType(){return j()}applyTransform(e){j()}intersectsExtent(e){return j()}translate(e,t){j()}transform(e,t){let i=$(e),n=i.getUnits()=="tile-pixels"?function(s,o,a){let l=i.getExtent(),h=i.getWorldExtent(),c=re(h)/re(l);Ae(am,h[0],h[3],c,-c,0,0,0);let u=ut(s,0,s.length,a,am,o),d=ct(i,t);return d?d(u,u,a):u}:ct(i,t);return this.applyTransform(n),this}},ba=nc;var rc=class extends ba{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return yr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return j()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let t=this.getSimplifiedGeometryInternal(e);return t.getFlatCoordinates().length<this.flatCoordinates.length?t:(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getSimplifiedGeometryInternal(e){return this}getStride(){return this.stride}setFlatCoordinates(e,t){this.stride=Ns(e),this.layout=e,this.flatCoordinates=t}setCoordinates(e,t){j()}setLayout(e,t,i){let n;if(e)n=Ns(e);else{for(let s=0;s<i;++s){if(t.length===0){this.layout="XY",this.stride=2;return}t=t[0]}n=t.length,e=Rn(n)}this.layout=e,this.stride=n}applyTransform(e){this.flatCoordinates&&(e(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(e,t){let i=this.getFlatCoordinates();if(i){let n=this.getStride();br(i,0,i.length,n,e,t,i),this.changed()}}scale(e,t,i){t===void 0&&(t=e),i||(i=be(this.getExtent()));let n=this.getFlatCoordinates();if(n){let s=this.getStride();sm(n,0,n.length,s,e,t,i,n),this.changed()}}translate(e,t){let i=this.getFlatCoordinates();if(i){let n=this.getStride();om(i,0,i.length,n,e,t,i),this.changed()}}};function Rn(r){let e;return r==2?e="XY":r==3?e="XYZ":r==4&&(e="XYZM"),e}function Ns(r){let e;return r=="XY"?e=2:r=="XYZ"||r=="XYM"?e=3:r=="XYZM"&&(e=4),e}function lm(r,e,t){let i=r.getFlatCoordinates();if(!i)return null;let n=r.getStride();return ut(i,0,i.length,n,e,t)}var Et=rc;function sc(r,e,t,i){let n=0,s=r[t-i],o=r[t-i+1],a=0,l=0;for(;e<t;e+=i){let h=r[e]-s,c=r[e+1]-o;n+=l*h-a*c,a=h,l=c}return n/2}function oc(r,e,t,i){let n=0;for(let s=0,o=t.length;s<o;++s){let a=t[s];n+=sc(r,e,a,i),e=a}return n}function hm(r,e,t,i){let n=0;for(let s=0,o=t.length;s<o;++s){let a=t[s];n+=oc(r,e,a,i),e=a[a.length-1]}return n}function cm(r,e,t,i,n,s,o){let a=r[e],l=r[e+1],h=r[t]-a,c=r[t+1]-l,u;if(h===0&&c===0)u=e;else{let d=((n-a)*h+(s-l)*c)/(h*h+c*c);if(d>1)u=t;else if(d>0){for(let f=0;f<i;++f)o[f]=ht(r[e+f],r[t+f],d);o.length=i;return}else u=e}for(let d=0;d<i;++d)o[d]=r[u+d];o.length=i}function Gs(r,e,t,i,n){let s=r[e],o=r[e+1];for(e+=i;e<t;e+=i){let a=r[e],l=r[e+1],h=Gt(s,o,a,l);h>n&&(n=h),s=a,o=l}return n}function Us(r,e,t,i,n){for(let s=0,o=t.length;s<o;++s){let a=t[s];n=Gs(r,e,a,i,n),e=a}return n}function um(r,e,t,i,n){for(let s=0,o=t.length;s<o;++s){let a=t[s];n=Us(r,e,a,i,n),e=a[a.length-1]}return n}function Bs(r,e,t,i,n,s,o,a,l,h,c){if(e==t)return h;let u,d;if(n===0){if(d=Gt(o,a,r[e],r[e+1]),d<h){for(u=0;u<i;++u)l[u]=r[e+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=e+i;for(;f<t;)if(cm(r,f-i,f,i,o,a,c),d=Gt(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/n|0,1);if(s&&(cm(r,t-i,e,i,o,a,c),d=Gt(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function zs(r,e,t,i,n,s,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=t.length;u<d;++u){let f=t[u];h=Bs(r,e,f,i,n,s,o,a,l,h,c),e=f}return h}function dm(r,e,t,i,n,s,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=t.length;u<d;++u){let f=t[u];h=zs(r,e,f,i,n,s,o,a,l,h,c),e=f[f.length-1]}return h}function Ia(r,e,t,i){for(let n=0,s=t.length;n<s;++n)r[e++]=t[n];return e}function Zn(r,e,t,i){for(let n=0,s=t.length;n<s;++n){let o=t[n];for(let a=0;a<i;++a)r[e++]=o[a]}return e}function wn(r,e,t,i,n){n=n||[];let s=0;for(let o=0,a=t.length;o<a;++o){let l=Zn(r,e,t[o],i);n[s++]=l,e=l}return n.length=s,n}function Fa(r,e,t,i,n){n=n||[];let s=0;for(let o=0,a=t.length;o<a;++o){let l=wn(r,e,t[o],i,n[s]);l.length===0&&(l[0]=e),n[s++]=l,e=l[l.length-1]}return n.length=s,n}function ri(r,e,t,i,n){n=n!==void 0?n:[];let s=0;for(let o=e;o<t;o+=i)n[s++]=r.slice(o,o+i);return n.length=s,n}function Pn(r,e,t,i,n){n=n!==void 0?n:[];let s=0;for(let o=0,a=t.length;o<a;++o){let l=t[o];n[s++]=ri(r,e,l,i,n[s]),e=l}return n.length=s,n}function js(r,e,t,i,n){n=n!==void 0?n:[];let s=0;for(let o=0,a=t.length;o<a;++o){let l=t[o];n[s++]=l.length===1&&l[0]===e?[]:Pn(r,e,l,i,n[s]),e=l[l.length-1]}return n.length=s,n}function qn(r,e,t,i,n,s,o){let a=(t-e)/i;if(a<3){for(;e<t;e+=i)s[o++]=r[e],s[o++]=r[e+1];return o}let l=new Array(a);l[0]=1,l[a-1]=1;let h=[e,t-i],c=0;for(;h.length>0;){let u=h.pop(),d=h.pop(),f=0,g=r[d],m=r[d+1],p=r[u],_=r[u+1];for(let x=d+i;x<u;x+=i){let y=r[x],E=r[x+1],T=sa(y,E,g,m,p,_);T>f&&(c=x,f=T)}f>n&&(l[(c-e)/i]=1,d+i<c&&h.push(d,c),c+i<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(s[o++]=r[e+u*i],s[o++]=r[e+u*i+1]);return o}function Ma(r,e,t,i,n,s,o,a){for(let l=0,h=t.length;l<h;++l){let c=t[l];o=qn(r,e,c,i,n,s,o),a.push(o),e=c}return o}function Ln(r,e){return e*Math.round(r/e)}function gy(r,e,t,i,n,s,o){if(e==t)return o;let a=Ln(r[e],n),l=Ln(r[e+1],n);e+=i,s[o++]=a,s[o++]=l;let h,c;do if(h=Ln(r[e],n),c=Ln(r[e+1],n),e+=i,e==t)return s[o++]=h,s[o++]=c,o;while(h==a&&c==l);for(;e<t;){let u=Ln(r[e],n),d=Ln(r[e+1],n);if(e+=i,u==h&&d==c)continue;let f=h-a,g=c-l,m=u-a,p=d-l;if(f*p==g*m&&(f<0&&m<f||f==m||f>0&&m>f)&&(g<0&&p<g||g==p||g>0&&p>g)){h=u,c=d;continue}s[o++]=h,s[o++]=c,a=h,l=c,h=u,c=d}return s[o++]=h,s[o++]=c,o}function Vs(r,e,t,i,n,s,o,a){for(let l=0,h=t.length;l<h;++l){let c=t[l];o=gy(r,e,c,i,n,s,o),a.push(o),e=c}return o}function fm(r,e,t,i,n,s,o,a){for(let l=0,h=t.length;l<h;++l){let c=t[l],u=[];o=Vs(r,e,c,i,n,s,o,u),a.push(u),e=c[c.length-1]}return o}var ac=class r extends Et{constructor(e,t){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,t!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}clone(){return new r(this.flatCoordinates.slice(),this.layout)}closestPointXY(e,t,i,n){return n<Ut(this.getExtent(),e,t)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Gs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Bs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,e,t,i,n))}getArea(){return sc(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return ri(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(e){let t=[];return t.length=qn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,0),new r(t,"XY")}getType(){return"LinearRing"}intersectsExtent(e){return!1}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Zn(this.flatCoordinates,0,e,this.stride),this.changed()}},lc=ac;var hc=class r extends Et{constructor(e,t){super(),this.setCoordinates(e,t)}clone(){let e=new r(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,i,n){let s=this.flatCoordinates,o=Gt(e,t,s[0],s[1]);if(o<n){let a=this.stride;for(let l=0;l<a;++l)i[l]=s[l];return i.length=a,o}return n}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(e){return Ri(this.flatCoordinates,e)}getType(){return"Point"}intersectsExtent(e){return Is(e,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(e,t){this.setLayout(t,e,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Ia(this.flatCoordinates,0,e,this.stride),this.changed()}},Fe=hc;function gm(r,e,t,i,n){return!Er(n,function(o){return!bn(r,e,t,i,o[0],o[1])})}function bn(r,e,t,i,n,s){let o=0,a=r[t-i],l=r[t-i+1];for(;e<t;e+=i){let h=r[e],c=r[e+1];l<=s?c>s&&(h-a)*(s-l)-(n-a)*(c-l)>0&&o++:c<=s&&(h-a)*(s-l)-(n-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function Ws(r,e,t,i,n,s){if(t.length===0||!bn(r,e,t[0],i,n,s))return!1;for(let o=1,a=t.length;o<a;++o)if(bn(r,t[o-1],t[o],i,n,s))return!1;return!0}function mm(r,e,t,i,n,s){if(t.length===0)return!1;for(let o=0,a=t.length;o<a;++o){let l=t[o];if(Ws(r,e,l,i,n,s))return!0;e=l[l.length-1]}return!1}function Xs(r,e,t,i,n,s,o){let a,l,h,c,u,d,f,g=n[s+1],m=[];for(let x=0,y=t.length;x<y;++x){let E=t[x];for(c=r[E-i],d=r[E-i+1],a=e;a<E;a+=i)u=r[a],f=r[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,m.push(h)),c=u,d=f}let p=NaN,_=-1/0;for(m.sort(_t),c=m[0],a=1,l=m.length;a<l;++a){u=m[a];let x=Math.abs(u-c);x>_&&(h=(c+u)/2,Ws(r,e,t,i,h,g)&&(p=h,_=x)),c=u}return isNaN(p)&&(p=n[s]),o?(o.push(p,g,_),o):[p,g,_]}function Aa(r,e,t,i,n){let s=[];for(let o=0,a=t.length;o<a;++o){let l=t[o];s=Xs(r,e,l,i,n,2*o,s),e=l[l.length-1]}return s}function Oa(r,e,t,i,n){let s;for(e+=i;e<t;e+=i)if(s=n(r.slice(e-i,e),r.slice(e,e+i)),s)return s;return!1}function cc(r,e){let[t,i]=r,[n,s]=e,o=((t[0]-n[0])*(n[1]-s[1])-(t[1]-n[1])*(n[0]-s[0]))/((t[0]-i[0])*(n[1]-s[1])-(t[1]-i[1])*(n[0]-s[0])),a=((t[0]-n[0])*(t[1]-i[1])-(t[1]-n[1])*(t[0]-i[0]))/((t[0]-i[0])*(n[1]-s[1])-(t[1]-i[1])*(n[0]-s[0]));if(0<=o&&o<=1&&0<=a&&a<=1)return[t[0]+o*(i[0]-t[0]),t[1]+o*(i[1]-t[1])]}function Ys(r,e,t,i,n,s){return s=s??Nh(me(),r,e,t,i),te(n,s)?s[0]>=n[0]&&s[2]<=n[2]||s[1]>=n[1]&&s[3]<=n[3]?!0:Oa(r,e,t,i,function(o,a){return Lg(n,o,a)}):!1}function pm(r,e,t,i,n){for(let s=0,o=t.length;s<o;++s){if(Ys(r,e,t[s],i,n))return!0;e=t[s]}return!1}function uc(r,e,t,i,n){return!!(Ys(r,e,t,i,n)||bn(r,e,t,i,n[0],n[1])||bn(r,e,t,i,n[0],n[3])||bn(r,e,t,i,n[2],n[1])||bn(r,e,t,i,n[2],n[3]))}function dc(r,e,t,i,n){if(!uc(r,e,t[0],i,n))return!1;if(t.length===1)return!0;for(let s=1,o=t.length;s<o;++s)if(gm(r,t[s-1],t[s],i,n)&&!Ys(r,t[s-1],t[s],i,n))return!1;return!0}function _m(r,e,t,i,n){for(let s=0,o=t.length;s<o;++s){let a=t[s];if(dc(r,e,a,i,n))return!0;e=a[a.length-1]}return!1}function xm(r,e,t,i){for(;e<t-i;){for(let n=0;n<i;++n){let s=r[e+n];r[e+n]=r[t-i+n],r[t-i+n]=s}e+=i,t-=i}}function fc(r,e,t,i){let n=0,s=r[t-i],o=r[t-i+1];for(;e<t;e+=i){let a=r[e],l=r[e+1];n+=(a-s)*(l+o),s=a,o=l}return n===0?void 0:n>0}function $s(r,e,t,i,n){n=n!==void 0?n:!1;for(let s=0,o=t.length;s<o;++s){let a=t[s],l=fc(r,e,a,i);if(s===0){if(n&&l||!n&&!l)return!1}else if(n&&!l||!n&&l)return!1;e=a}return!0}function Da(r,e,t,i,n){for(let s=0,o=t.length;s<o;++s){let a=t[s];if(!$s(r,e,a,i,n))return!1;a.length&&(e=a[a.length-1])}return!0}function Ir(r,e,t,i,n){n=n!==void 0?n:!1;for(let s=0,o=t.length;s<o;++s){let a=t[s],l=fc(r,e,a,i);(s===0?n&&l||!n&&!l:n&&!l||!n&&l)&&xm(r,e,a,i),e=a}return e}function Ks(r,e,t,i,n){for(let s=0,o=t.length;s<o;++s)e=Ir(r,e,t[s],i,n);return e}function Fr(r,e){let t=[],i=0,n=0,s;for(let o=0,a=e.length;o<a;++o){let l=e[o],h=fc(r,i,l,2);if(s===void 0&&(s=h),h===s)t.push(e.slice(n,o+1));else{if(t.length===0)continue;t[t.length-1].push(e[n])}n=o+1,i=l}return t}var Hs=class r extends Et{constructor(e,t,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,t!==void 0&&i?(this.setFlatCoordinates(t,e),this.ends_=i):this.setCoordinates(e,t)}appendLinearRing(e){this.flatCoordinates?je(this.flatCoordinates,e.getFlatCoordinates()):this.flatCoordinates=e.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new r(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,t,i,n){return n<Ut(this.getExtent(),e,t)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Us(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zs(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,e,t,i,n))}containsXY(e,t){return Ws(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,t)}getArea(){return oc(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(e){let t;return e!==void 0?(t=this.getOrientedFlatCoordinates().slice(),Ir(t,0,this.ends_,this.stride,e)):t=this.flatCoordinates,Pn(t,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let e=be(this.getExtent());this.flatInteriorPoint_=Xs(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new Fe(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(e){return e<0||this.ends_.length<=e?null:new lc(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLinearRings(){let e=this.layout,t=this.flatCoordinates,i=this.ends_,n=[],s=0;for(let o=0,a=i.length;o<a;++o){let l=i[o],h=new lc(t.slice(s,l),e);n.push(h),s=l}return n}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;$s(e,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Ir(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let t=[],i=[];return t.length=Vs(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(e),t,0,i),new r(t,"XY",i)}getType(){return"Polygon"}intersectsExtent(e){return dc(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let i=wn(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}},dt=Hs;function Jn(r){if(yt(r))throw new Error("Cannot create polygon from empty extent");let e=r[0],t=r[1],i=r[2],n=r[3],s=[e,t,e,n,i,n,i,t,e,t];return new Hs(s,"XY",[s.length])}function Mr(r,e,t){e=e||32;let i=r.getStride(),n=r.getLayout(),s=r.getCenter(),o=i*(e+1),a=new Array(o);for(let c=0;c<o;c+=i){a[c]=0,a[c+1]=0;for(let u=2;u<i;u++)a[c+u]=s[u]}let l=[a.length],h=new Hs(a,n,l);return ym(h,s,r.getRadius(),t),h}function ym(r,e,t,i){let n=r.getFlatCoordinates(),s=r.getStride(),o=n.length/s-1,a=i||0;for(let l=0;l<=o;++l){let h=l*s,c=a+lt(l,o)*2*Math.PI/o;n[h]=e[0]+t*Math.cos(c),n[h+1]=e[1]+t*Math.sin(c)}r.changed()}function gc(r,e,t,i){let n=z(e)/t[0],s=re(e)/t[1];return i?Math.min(r,Math.max(n,s)):Math.min(r,Math.min(n,s))}function mc(r,e,t){let i=Math.min(r,e),n=50;return i*=Math.log(1+n*Math.max(0,r/e-1))/n+1,t&&(i=Math.max(i,t),i/=Math.log(1+n*Math.max(0,t/r-1))/n+1),B(i,t/2,e*2)}function Em(r,e,t,i){return e=e!==void 0?e:!0,(function(n,s,o,a){if(n!==void 0){let l=r[0],h=r[r.length-1],c=t?gc(l,t,o,i):l;if(a)return e?mc(n,c,h):B(n,h,c);let u=Math.min(c,n),d=Math.floor(pn(r,u,s));return r[d]>c&&d<r.length-1?r[d+1]:r[d]}})}function Tm(r,e,t,i,n,s){return i=i!==void 0?i:!0,t=t!==void 0?t:0,(function(o,a,l,h){if(o!==void 0){let c=n?gc(e,n,l,s):e;if(h)return i?mc(o,c,t):B(o,t,c);let u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(r)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),m=Math.floor(Math.log(e/g)/Math.log(r)+f),p=Math.max(d,m),_=e/Math.pow(r,p);return B(_,t,c)}})}function pc(r,e,t,i,n){return t=t!==void 0?t:!0,(function(s,o,a,l){if(s!==void 0){let h=i?gc(r,i,a,n):r;return!t||!l?B(s,e,h):mc(s,h,e)}})}function Ar(r){if(r!==void 0)return 0}function _c(r){if(r!==void 0)return r}function Cm(r){let e=2*Math.PI/r;return(function(t,i){if(i)return t;if(t!==void 0)return t=Math.floor(t/e+.5)*e,t})}function vm(r){let e=r===void 0?Lt(5):r;return(function(t,i){return i||t===void 0?t:Math.abs(t)<=e?0:t})}var xc=0,Ec=class extends De{constructor(e){super(),this.on,this.once,this.un,e=Object.assign({},e),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Sa(e.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,e.projection&&Qh(),e.center&&(e.center=ce(e.center,this.projection_)),e.extent&&(e.extent=Be(e.extent,this.projection_)),this.applyOptions_(e)}applyOptions_(e){let t=Object.assign({},e);for(let a in Pt)delete t[a];this.setProperties(t,!0);let i=py(e);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=e.resolutions,this.padding_=e.padding,this.minZoom_=i.minZoom;let n=my(e),s=i.constraint,o=_y(e);this.constraints_={center:n,resolution:s,rotation:o},this.setRotation(e.rotation!==void 0?e.rotation:0),this.setCenterInternal(e.center!==void 0?e.center:null),e.resolution!==void 0?this.setResolution(e.resolution):e.zoom!==void 0&&this.setZoom(e.zoom)}get padding(){return this.padding_}set padding(e){let t=this.padding_;this.padding_=e;let i=this.getCenterInternal();if(i){let n=e||[0,0,0,0];t=t||[0,0,0,0];let s=this.getResolution(),o=s/2*(n[3]-t[3]+t[1]-n[1]),a=s/2*(n[0]-t[0]+t[2]-n[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(e){let t=this.getProperties();return t.resolution!==void 0?t.resolution=this.getResolution():t.zoom=this.getZoom(),t.center=this.getCenterInternal(),t.rotation=this.getRotation(),Object.assign({},t,e)}animate(e){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);let t=new Array(arguments.length);for(let i=0;i<t.length;++i){let n=arguments[i];n.center&&(n=Object.assign({},n),n.center=ce(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=ce(n.anchor,this.getProjection())),t[i]=n}this.animateInternal.apply(this,t)}animateInternal(e){let t=arguments.length,i;t>1&&typeof arguments[t-1]=="function"&&(i=arguments[t-1],--t);let n=0;for(;n<t&&!this.isDef();++n){let c=arguments[n];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(n===t){i&&ka(i,!0);return}let s=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_,h=[];for(;n<t;++n){let c=arguments[n],u={start:s,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||Og,callback:i};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;let d=lt(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}xy(u)?u.complete=!0:s+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(he.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[he.ANIMATING]>0}getInteracting(){return this.hints_[he.INTERACTING]>0}cancelAnimations(){this.setHint(he.ANIMATING,-this.hints_[he.ANIMATING]);let e;for(let t=0,i=this.animations_.length;t<i;++t){let n=this.animations_[t];if(n[0].callback&&ka(n[0].callback,!1),!e)for(let s=0,o=n.length;s<o;++s){let a=n[s];if(!a.complete){e=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=e,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;let e=Date.now(),t=!1;for(let i=this.animations_.length-1;i>=0;--i){let n=this.animations_[i],s=!0;for(let o=0,a=n.length;o<a;++o){let l=n[o];if(l.complete)continue;let h=e-l.start,c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):s=!1;let u=l.easing(c);if(l.sourceCenter){let d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],m=l.targetCenter[1];this.nextCenter_=l.targetCenter;let p=d+u*(g-d),_=f+u*(m-f);this.targetCenter_=[p,_]}if(l.sourceResolution&&l.targetResolution){let d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){let f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){let d=u===1?lt(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){let f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),t=!0,!l.complete)break}if(s){this.animations_[i]=null,this.setHint(he.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let o=n[0].callback;o&&ka(o,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let i,n=this.getCenterInternal();return n!==void 0&&(i=[n[0]-t[0],n[1]-t[1]],Cr(i,e-this.getRotation()),ua(i,t)),i}calculateCenterZoom(e,t){let i,n=this.getCenterInternal(),s=this.getResolution();if(n!==void 0&&s!==void 0){let o=t[0]-e*(t[0]-n[0])/s,a=t[1]-e*(t[1]-n[1])/s;i=[o,a]}return i}getViewportSize_(e){let t=this.viewportSize_;if(e){let i=t[0],n=t[1];return[Math.abs(i*Math.cos(e))+Math.abs(n*Math.sin(e)),Math.abs(i*Math.sin(e))+Math.abs(n*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let e=this.getCenterInternal();return e&&ni(e,this.getProjection())}getCenterInternal(){return this.get(Pt.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){let t=this.calculateExtentInternal(e);return Vt(t,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();let t=this.getCenterInternal();W(t,"The view center is not defined");let i=this.getResolution();W(i!==void 0,"The view resolution is not defined");let n=this.getRotation();return W(n!==void 0,"The view rotation is not defined"),Vi(t,i,n,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(Pt.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(Be(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t=t||this.getViewportSizeMinusPadding_();let i=z(e)/t[0],n=re(e)/t[1];return Math.max(i,n)}getResolutionForValueFunction(e){e=e||2;let t=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,n=Math.log(t/i)/Math.log(e);return(function(s){return t/Math.pow(e,s*n)})}getRotation(){return this.get(Pt.ROTATION)}getValueForResolutionFunction(e){let t=Math.log(e||2),i=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,s=Math.log(i/n)/t;return(function(o){return Math.log(i/o)/t/s})}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e),i=this.padding_;return i&&(t=[t[0]-i[1]-i[3],t[1]-i[0]-i[2]]),t}getState(){let e=this.getProjection(),t=this.getResolution(),i=this.getRotation(),n=this.getCenterInternal(),s=this.padding_;if(s){let o=this.getViewportSizeMinusPadding_();n=yc(n,this.getViewportSize_(),[o[0]/2+s[3],o[1]/2+s[0]],t,i)}return{center:n.slice(0),projection:e!==void 0?e:null,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e,t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,i,n;if(this.resolutions_){let s=pn(this.resolutions_,e,1);t=s,i=this.resolutions_[s],s==this.resolutions_.length-1?n=2:n=i/this.resolutions_[s+1]}else i=this.maxResolution_,n=this.zoomFactor_;return t+Math.log(i/e)/Math.log(n)}getResolutionForZoom(e){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];let t=B(Math.floor(e),0,this.resolutions_.length-2),i=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/Math.pow(i,B(e-t,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,t){let i;if(W(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){W(!yt(e),"Cannot fit empty extent provided as `geometry`");let n=Be(e,this.getProjection());i=Jn(n)}else if(e.getType()==="Circle"){let n=Be(e.getExtent(),this.getProjection());i=Jn(n),i.rotate(this.getRotation(),be(n))}else{let n=we();n?i=e.clone().transform(n,this.getProjection()):i=e}this.fitInternal(i,t)}rotatedExtentForGeometry(e){let t=this.getRotation(),i=Math.cos(t),n=Math.sin(-t),s=e.getFlatCoordinates(),o=e.getStride(),a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=s.length;u<d;u+=o){let f=s[u]*i-s[u+1]*n,g=s[u]*n+s[u+1]*i;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(e,t){t=t||{};let i=t.size;i||(i=this.getViewportSizeMinusPadding_());let n=t.padding!==void 0?t.padding:[0,0,0,0],s=t.nearest!==void 0?t.nearest:!1,o;t.minResolution!==void 0?o=t.minResolution:t.maxZoom!==void 0?o=this.getResolutionForZoom(t.maxZoom):o=0;let a=this.rotatedExtentForGeometry(e),l=this.getResolutionForExtentInternal(a,[i[0]-n[1]-n[3],i[1]-n[0]-n[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,s?0:1);let h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=be(a);d[0]+=(n[1]-n[3])/2*l,d[1]+=(n[0]-n[2])/2*l;let f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,m=this.getConstrainedCenter([f,g],l),p=t.callback?t.callback:Bi;t.duration!==void 0?this.animateInternal({resolution:l,center:m,duration:t.duration,easing:t.easing},p):(this.targetResolution_=l,this.targetCenter_=m,this.applyTargetState_(!1,!0),ka(p,!0))}centerOn(e,t,i){this.centerOnInternal(ce(e,this.getProjection()),t,i)}centerOnInternal(e,t,i){this.setCenterInternal(yc(e,t,i,this.getResolution(),this.getRotation()))}calculateCenterShift(e,t,i,n){let s,o=this.padding_;if(o&&e){let a=this.getViewportSizeMinusPadding_(-i),l=yc(e,n,[a[0]/2+o[3],a[1]/2+o[0]],t,i);s=[e[0]-l[0],e[1]-l[1]]}return s}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(e){let t=ni(this.targetCenter_,this.getProjection());this.setCenter([t[0]+e[0],t[1]+e[1]])}adjustCenterInternal(e){let t=this.targetCenter_;this.setCenterInternal([t[0]+e[0],t[1]+e[1]])}adjustResolution(e,t){t=t&&ce(t,this.getProjection()),this.adjustResolutionInternal(e,t)}adjustResolutionInternal(e,t){let i=this.getAnimating()||this.getInteracting(),n=this.getViewportSize_(this.getRotation()),s=this.constraints_.resolution(this.targetResolution_*e,0,n,i);t&&(this.targetCenter_=this.calculateCenterZoom(s,t)),this.targetResolution_*=e,this.applyTargetState_()}adjustZoom(e,t){this.adjustResolution(Math.pow(this.zoomFactor_,-e),t)}adjustRotation(e,t){t&&(t=ce(t,this.getProjection())),this.adjustRotationInternal(e,t)}adjustRotationInternal(e,t){let i=this.getAnimating()||this.getInteracting(),n=this.constraints_.rotation(this.targetRotation_+e,i);t&&(this.targetCenter_=this.calculateCenterRotate(n,t)),this.targetRotation_+=e,this.applyTargetState_()}setCenter(e){this.setCenterInternal(e&&ce(e,this.getProjection()))}setCenterInternal(e){this.targetCenter_=e,this.applyTargetState_()}setHint(e,t){return this.hints_[e]+=t,this.changed(),this.hints_[e]}setResolution(e){this.targetResolution_=e,this.applyTargetState_()}setRotation(e){this.targetRotation_=e,this.applyTargetState_()}setZoom(e){this.setResolution(this.getResolutionForZoom(e))}applyTargetState_(e,t){let i=this.getAnimating()||this.getInteracting()||t,n=this.constraints_.rotation(this.targetRotation_,i),s=this.getViewportSize_(n),o=this.constraints_.resolution(this.targetResolution_,0,s,i),a=this.constraints_.center(this.targetCenter_,o,s,i,this.calculateCenterShift(this.targetCenter_,o,n,s));this.get(Pt.ROTATION)!==n&&this.set(Pt.ROTATION,n),this.get(Pt.RESOLUTION)!==o&&(this.set(Pt.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(Pt.CENTER)||!Qe(this.get(Pt.CENTER),a))&&this.set(Pt.CENTER,a),this.getAnimating()&&!e&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(e,t,i){e=e!==void 0?e:200;let n=t||0,s=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(s),a=this.constraints_.resolution(this.targetResolution_,n,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,s,o));if(e===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=s,this.targetCenter_=l,this.applyTargetState_();return}i=i||(e===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==s||!this.getCenterInternal()||!Qe(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:s,center:l,resolution:a,duration:e,easing:Bt,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(he.INTERACTING,1)}endInteraction(e,t,i){i=i&&ce(i,this.getProjection()),this.endInteractionInternal(e,t,i)}endInteractionInternal(e,t,i){this.getInteracting()&&(this.setHint(he.INTERACTING,-1),this.resolveConstraints(e,t,i))}getConstrainedCenter(e,t){let i=this.getViewportSize_(this.getRotation());return this.constraints_.center(e,t||this.getResolution(),i)}getConstrainedZoom(e,t){let i=this.getResolutionForZoom(e);return this.getZoomForResolution(this.getConstrainedResolution(i,t))}getConstrainedResolution(e,t){t=t||0;let i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(e,t,i)}};function ka(r,e){setTimeout(function(){r(e)},0)}function my(r){if(r.extent!==void 0){let t=r.smoothExtentConstraint!==void 0?r.smoothExtentConstraint:!0;return kh(r.extent,r.constrainOnlyCenter,t)}let e=Sa(r.projection,"EPSG:3857");if(r.multiWorld!==!0&&e.isGlobal()){let t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,kh(t,!1,!1)}return vg}function py(r){let e,t,i,o=r.minZoom!==void 0?r.minZoom:xc,a=r.maxZoom!==void 0?r.maxZoom:28,l=r.zoomFactor!==void 0?r.zoomFactor:2,h=r.multiWorld!==void 0?r.multiWorld:!1,c=r.smoothResolutionConstraint!==void 0?r.smoothResolutionConstraint:!0,u=r.showFullExtent!==void 0?r.showFullExtent:!1,d=Sa(r.projection,"EPSG:3857"),f=d.getExtent(),g=r.constrainOnlyCenter,m=r.extent;if(!h&&!m&&d.isGlobal()&&(g=!1,m=f),r.resolutions!==void 0){let p=r.resolutions;t=p[o],i=p[a]!==void 0?p[a]:p[p.length-1],r.constrainResolution?e=Em(p,c,!g&&m,u):e=pc(t,i,c,!g&&m,u)}else{let _=(f?Math.max(z(f),re(f)):360*ci.degrees/d.getMetersPerUnit())/256/Math.pow(2,xc),x=_/Math.pow(2,28-xc);t=r.maxResolution,t!==void 0?o=0:t=_/Math.pow(l,o),i=r.minResolution,i===void 0&&(r.maxZoom!==void 0?r.maxResolution!==void 0?i=t/Math.pow(l,a):i=_/Math.pow(l,a):i=x),a=o+Math.floor(Math.log(t/i)/Math.log(l)),i=t/Math.pow(l,a-o),r.constrainResolution?e=Tm(l,t,i,c,!g&&m,u):e=pc(t,i,c,!g&&m,u)}return{constraint:e,maxResolution:t,minResolution:i,minZoom:o,zoomFactor:l}}function _y(r){if(r.enableRotation!==void 0?r.enableRotation:!0){let t=r.constrainRotation;return t===void 0||t===!0?vm():t===!1?_c:typeof t=="number"?Cm(t):_c}return Ar}function xy(r){return!(r.sourceCenter&&r.targetCenter&&!Qe(r.sourceCenter,r.targetCenter)||r.sourceResolution!==r.targetResolution||r.sourceRotation!==r.targetRotation)}function yc(r,e,t,i,n){let s=Math.cos(-n),o=Math.sin(-n),a=r[0]*s-r[1]*o,l=r[1]*s+r[0]*o;a+=(e[0]/2-t[0])*i,l+=(t[1]-e[1]/2)*i,o=-o;let h=a*s-l*o,c=l*s+a*o;return[h,c]}var It=Ec;var Zs="ol-hidden",wm="ol-selectable",et="ol-unselectable",Tc="ol-unsupported",Wt="ol-control",Or="ol-collapsed",yy=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),Rm=["style","variant","weight","size","lineHeight","family"],Na={normal:400,bold:700},Ga=function(r){let e=r.match(yy);if(!e)return null;let t={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,n=Rm.length;i<n;++i){let s=e[i+1];s!==void 0&&(t[Rm[i]]=typeof s=="string"?s.trim():s)}return isNaN(Number(t.weight))&&t.weight in Na&&(t.weight=Na[t.weight]),t.families=t.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),t};function ne(r,e,t,i){let n;return t&&t.length?n=t.shift():Ze?n=new class extends OffscreenCanvas{style={}}(r??300,e??150):n=document.createElement("canvas"),r&&(n.width=r),e&&(n.height=e),n.getContext("2d",i)}var Cc;function Dr(){return Cc||(Cc=ne(1,1)),Cc}function $i(r){let e=r.canvas;e.width=1,e.height=1,r.clearRect(0,0,1,1)}function Pm(r){let e=r.offsetWidth,t=getComputedStyle(r);return e+=parseInt(t.marginLeft,10)+parseInt(t.marginRight,10),e}function Lm(r){let e=r.offsetHeight,t=getComputedStyle(r);return e+=parseInt(t.marginTop,10)+parseInt(t.marginBottom,10),e}function Ki(r,e){let t=e.parentNode;t&&t.replaceChild(r,e)}function Ua(r){for(;r.lastChild;)r.lastChild.remove()}function bm(r,e){let t=r.childNodes;for(let i=0;;++i){let n=t[i],s=e[i];if(!n&&!s)break;if(n!==s){if(!n){r.appendChild(s);continue}if(!s){r.removeChild(n),--i;continue}r.insertBefore(s,n)}}}function Ba(){return new Proxy({childNodes:[],appendChild:function(e){return this.childNodes.push(e),e},remove:function(){},removeChild:function(e){let t=this.childNodes.indexOf(e);if(t===-1)throw new Error("Node to remove was not found");return this.childNodes.splice(t,1),e},insertBefore:function(e,t){let i=this.childNodes.indexOf(t);if(i===-1)throw new Error("Reference node not found");return this.childNodes.splice(i,0,e),e},style:{}},{get(e,t,i){return t==="firstElementChild"?e.childNodes.length>0?e.childNodes[0]:null:Reflect.get(e,t,i)}})}function di(r){return typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas}var vc=class extends De{constructor(e){super();let t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&this.element?.remove();for(let t=0,i=this.listenerKeys.length;t<i;++t)K(this.listenerKeys[t]);if(this.listenerKeys.length=0,this.map_=e,e){let t=this.target_??e.getOverlayContainerStopEvent();this.element&&t.appendChild(this.element),this.render!==Bi&&this.listenerKeys.push(k(e,Nt.POSTRENDER,this.render,this)),e.render()}}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}},st=vc;var Sc=class extends st{constructor(e){e=e||{},super({element:document.createElement("div"),render:e.render,target:e.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=e.collapsed!==void 0?e.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=e.collapsible!==void 0,this.collapsible_=e.collapsible!==void 0?e.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=e.attributions;let t=e.className!==void 0?e.className:"ol-attribution",i=e.tipLabel!==void 0?e.tipLabel:"Attributions",n=e.expandClassName!==void 0?e.expandClassName:t+"-expand",s=e.collapseLabel!==void 0?e.collapseLabel:"\u203A",o=e.collapseClassName!==void 0?e.collapseClassName:t+"-collapse";typeof s=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=s,this.collapseLabel_.className=o):this.collapseLabel_=s;let a=e.label!==void 0?e.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=n):this.label_=a;let l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(L.CLICK,this.handleClick_.bind(this),!1);let h=t+" "+et+" "+Wt+(this.collapsed_&&this.collapsible_?" "+Or:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(e){let t=this.getMap().getAllLayers(),i=new Set(t.flatMap(n=>n.getAttributions(e)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(n=>i.add(n)):i.add(this.attributions_)),!this.overrideCollapsible_){let n=!t.some(s=>s.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(n)}return Array.from(i)}async updateElement_(e){if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}let t=await Promise.all(this.collectSourceAttributions_(e).map(n=>ea(()=>n))),i=t.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Ve(t,this.renderedAttributions_)){Ua(this.ulElement_);for(let n=0,s=t.length;n<s;++n){let o=document.createElement("li");o.innerHTML=t[n],this.ulElement_.appendChild(o)}this.renderedAttributions_=t}}handleClick_(e){e.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(Or),this.collapsed_?Ki(this.collapseLabel_,this.label_):Ki(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(e){this.collapsible_!==e&&(this.collapsible_=e,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(e){this.userCollapsed_=e,!(!this.collapsible_||this.collapsed_===e)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(e){this.updateElement_(e.frameState)}},qs=Sc;var Rc=class extends st{constructor(e){e=e||{},super({element:document.createElement("div"),render:e.render,target:e.target});let t=e.className!==void 0?e.className:"ol-rotate",i=e.label!==void 0?e.label:"\u21E7",n=e.compassClassName!==void 0?e.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=n,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(n));let s=e.tipLabel?e.tipLabel:"Reset rotation",o=document.createElement("button");o.className=t+"-reset",o.setAttribute("type","button"),o.title=s,o.appendChild(this.label_),o.addEventListener(L.CLICK,this.handleClick_.bind(this),!1);let a=t+" "+et+" "+Wt,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=e.resetNorth?e.resetNorth:void 0,this.duration_=e.duration!==void 0?e.duration:250,this.autoHide_=e.autoHide!==void 0?e.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(Zs)}handleClick_(e){e.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){let t=this.getMap().getView();if(!t)return;let i=t.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?t.animate({rotation:0,duration:this.duration_,easing:Bt}):t.setRotation(0))}render(e){let t=e.frameState;if(!t)return;let i=t.viewState.rotation;if(i!=this.rotation_){let n="rotate("+i+"rad)";if(this.autoHide_){let s=this.element.classList.contains(Zs);!s&&i===0?this.element.classList.add(Zs):s&&i!==0&&this.element.classList.remove(Zs)}this.label_.style.transform=n}this.rotation_=i}},Js=Rc;var wc=class extends st{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target});let t=e.className!==void 0?e.className:"ol-zoom",i=e.delta!==void 0?e.delta:1,n=e.zoomInClassName!==void 0?e.zoomInClassName:t+"-in",s=e.zoomOutClassName!==void 0?e.zoomOutClassName:t+"-out",o=e.zoomInLabel!==void 0?e.zoomInLabel:"+",a=e.zoomOutLabel!==void 0?e.zoomOutLabel:"\u2013",l=e.zoomInTipLabel!==void 0?e.zoomInTipLabel:"Zoom in",h=e.zoomOutTipLabel!==void 0?e.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=n,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(L.CLICK,this.handleClick_.bind(this,i),!1);let u=document.createElement("button");u.className=s,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(L.CLICK,this.handleClick_.bind(this,-i),!1);let d=t+" "+et+" "+Wt,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=e.duration!==void 0?e.duration:250}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){let i=this.getMap().getView();if(!i)return;let n=i.getZoom();if(n!==void 0){let s=i.getConstrainedZoom(n+e);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:s,duration:this.duration_,easing:Bt})):i.setZoom(s)}}},Qs=wc;function Im(r){r=r||{};let e=new Ce;return(r.zoom===void 0||r.zoom)&&e.push(new Qs(r.zoomOptions)),(r.rotate===void 0||r.rotate)&&e.push(new Js(r.rotateOptions)),(r.attribution===void 0||r.attribution)&&e.push(new qs(r.attributionOptions)),e}var Pc=class{constructor(e,t,i){this.decay_=e,this.minVelocity_=t,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;let e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]<e)return!1;let i=t-3;for(;i>0&&this.points_[i+2]>e;)i-=3;let n=this.points_[t+2]-this.points_[i+2];if(n<1e3/60)return!1;let s=this.points_[t]-this.points_[i],o=this.points_[t+1]-this.points_[i+1];return this.angle_=Math.atan2(o,s),this.initialVelocity_=Math.sqrt(s*s+o*o)/n,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}},Fm=Pc;var eo={ACTIVE:"active"};var Lc=class extends De{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(eo.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(eo.ACTIVE,e)}setMap(e){this.map_=e}};function Mm(r,e,t){let i=r.getCenterInternal();if(i){let n=[i[0]+e[0],i[1]+e[1]];r.animateInternal({duration:t!==void 0?t:250,easing:Dg,center:r.getConstrainedCenter(n)})}}function kr(r,e,t,i){let n=r.getZoom();if(n===void 0)return;let s=r.getConstrainedZoom(n+e),o=r.getResolutionForZoom(s);r.getAnimating()&&r.cancelAnimations(),r.animate({resolution:o,anchor:t,duration:i!==void 0?i:250,easing:Bt})}var si=Lc;var bc=class extends si{constructor(e){super(),e=e||{},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:250}handleEvent(e){let t=!1;if(e.type==ee.DBLCLICK){let i=e.originalEvent,n=e.map,s=e.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=n.getView();kr(a,o,s,this.duration_),i.preventDefault(),t=!0}return!t}},Am=bc;function to(r){let e=arguments;return function(t){let i=!0;for(let n=0,s=e.length;n<s&&(i=i&&e[n](t),!!i);++n);return i}}var Om=function(r){let e=r.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},Dm=function(r){let e=r.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Ey=function(r){let e=r.map.getTargetElement(),t=e.getRootNode(),i=r.map.getOwnerDocument().activeElement;return t instanceof ShadowRoot?t.host.contains(i):e.contains(i)},za=function(r){let e=r.map.getTargetElement(),t=e.getRootNode();return(t instanceof ShadowRoot?t.host:e).hasAttribute("tabindex")?Ey(r):!0},Hi=xt,km=function(r){return r.type==ee.CLICK},ja=function(r){let e=r.originalEvent;return"pointerId"in e&&e.button==0&&!(pg&&Ih&&e.ctrlKey)},Qn=Ot;var Va=function(r){return r.type==ee.SINGLECLICK};var Nr=function(r){let e=r.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var Nm=function(r){let e=r.originalEvent;return Ih?e.metaKey:e.ctrlKey},Zi=function(r){let e=r.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Wa=function(r){let e=r.originalEvent,t=e.target.tagName;return t!=="INPUT"&&t!=="SELECT"&&t!=="TEXTAREA"&&!e.target.isContentEditable},In=function(r){let e=r.originalEvent;return"pointerId"in e&&e.pointerType=="mouse"};var Xa=function(r){let e=r.originalEvent;return"pointerId"in e&&e.isPrimary&&e.button===0};var Ic=class extends si{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==ee.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==ee.POINTERUP){let i=this.handleUpEvent(e);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(e.type==ee.POINTERDOWN){let i=this.handleDownEvent(e);this.handlingDownUpSequence=i,t=this.stopDown(i)}else e.type==ee.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};function Gr(r){let e=r.length,t=0,i=0;for(let n=0;n<e;n++)t+=r[n].clientX,i+=r[n].clientY;return{clientX:t/e,clientY:i/e}}var ot=Ic;var Fc=class extends ot{constructor(e){super({stopDown:Ot}),e=e||{},this.kinetic_=e.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;let t=e.condition?e.condition:to(Nr,Xa);this.condition_=e.onFocusOnly?to(za,t):t,this.noKinetic_=!1}handleDragEvent(e){let t=e.map;this.panning_||(this.panning_=!0,t.getView().beginInteraction());let i=this.targetPointers,n=t.getEventPixel(Gr(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(n[0],n[1]),this.lastCentroid){let s=[this.lastCentroid[0]-n[0],n[1]-this.lastCentroid[1]],a=e.map.getView();da(s,a.getResolution()),Cr(s,a.getRotation()),a.adjustCenterInternal(s)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=n,this.lastPointersCount_=i.length,e.originalEvent.preventDefault()}handleUpEvent(e){let t=e.map,i=t.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){let n=this.kinetic_.getDistance(),s=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=t.getPixelFromCoordinateInternal(o),l=t.getCoordinateFromPixelInternal([a[0]-n*Math.cos(s),a[1]-n*Math.sin(s)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:Bt})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(e){if(this.targetPointers.length>0&&this.condition_(e)){let i=e.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}},Gm=Fc;var Mc=class extends ot{constructor(e){e=e||{},super({stopDown:Ot}),this.condition_=e.condition?e.condition:Dm,this.lastAngle_=void 0,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){if(!In(e))return;let t=e.map,i=t.getView();if(i.getConstraints().rotation===Ar)return;let n=t.getSize(),s=e.pixel,o=Math.atan2(n[1]/2-s[1],s[0]-n[0]/2);if(this.lastAngle_!==void 0){let a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(e){return In(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return In(e)&&ja(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}},Um=Mc;var Ac=class extends Ci{constructor(e){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){let e=this.startPixel_,t=this.endPixel_,i="px",n=this.element_.style;n.left=Math.min(e[0],t[0])+i,n.top=Math.min(e[1],t[1])+i,n.width=Math.abs(t[0]-e[0])+i,n.height=Math.abs(t[1]-e[1])+i}setMap(e){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);let t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;let e=this.startPixel_,t=this.endPixel_,n=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);n[4]=n[0].slice(),this.geometry_?this.geometry_.setCoordinates([n]):this.geometry_=new dt([n])}getGeometry(){return this.geometry_}},Bm=Ac;var Ur={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"},er=class extends ye{constructor(e,t,i){super(e),this.coordinate=t,this.mapBrowserEvent=i}},Oc=class extends ot{constructor(e){super(),this.on,this.once,this.un,e=e??{},this.box_=new Bm(e.className||"ol-dragbox"),this.minArea_=e.minArea??64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition??ja,this.boxEndCondition_=e.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,i){let n=i[0]-t[0],s=i[1]-t[1];return n*n+s*s>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.startPixel_&&(this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new er(Ur.BOXDRAG,e.coordinate,e)))}handleUpEvent(e){if(!this.startPixel_)return!1;let t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new er(t?Ur.BOXEND:Ur.BOXCANCEL,e.coordinate,e)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new er(Ur.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}setActive(e){e||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new er(Ur.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(e)}setMap(e){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new er(Ur.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(e)}},zm=Oc;var Dc=class extends zm{constructor(e){e=e||{};let t=e.condition?e.condition:Zi;super({condition:t,className:e.className||"ol-dragzoom",minArea:e.minArea}),this.duration_=e.duration!==void 0?e.duration:200,this.out_=e.out!==void 0?e.out:!1}onBoxEnd(e){let i=this.getMap().getView(),n=this.getGeometry();if(this.out_){let s=i.rotatedExtentForGeometry(n),o=i.getResolutionForExtentInternal(s),a=i.getResolution()/o;n=n.clone(),n.scale(a*a)}i.fitInternal(n,{duration:this.duration_,easing:Bt})}},jm=Dc;var Fn={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};var kc=class extends si{constructor(e){super(),e=e||{},this.defaultCondition_=function(t){return Nr(t)&&Wa(t)},this.condition_=e.condition!==void 0?e.condition:this.defaultCondition_,this.duration_=e.duration!==void 0?e.duration:100,this.pixelDelta_=e.pixelDelta!==void 0?e.pixelDelta:128}handleEvent(e){let t=!1;if(e.type==L.KEYDOWN){let i=e.originalEvent,n=i.key;if(this.condition_(e)&&(n==Fn.DOWN||n==Fn.LEFT||n==Fn.RIGHT||n==Fn.UP)){let o=e.map.getView(),a=o.getResolution()*this.pixelDelta_,l=0,h=0;n==Fn.DOWN?h=-a:n==Fn.LEFT?l=-a:n==Fn.RIGHT?l=a:h=a;let c=[l,h];Cr(c,o.getRotation()),Mm(o,c,this.duration_),i.preventDefault(),t=!0}}return!t}},Vm=kc;var Nc=class extends si{constructor(e){super(),e=e||{},this.condition_=e.condition?e.condition:function(t){return!Nm(t)&&Wa(t)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:100}handleEvent(e){let t=!1;if(e.type==L.KEYDOWN||e.type==L.KEYPRESS){let i=e.originalEvent,n=i.key;if(this.condition_(e)&&(n==="+"||n==="-")){let s=e.map,o=n==="+"?this.delta_:-this.delta_,a=s.getView();kr(a,o,void 0,this.duration_),i.preventDefault(),t=!0}}return!t}},Wm=Nc;var Ty=40,Cy=300,Gc=class extends si{constructor(e){e=e||{},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta!==void 0?e.maxDelta:1,this.duration_=e.duration!==void 0?e.duration:250,this.timeout_=e.timeout!==void 0?e.timeout:80,this.useAnchor_=e.useAnchor!==void 0?e.useAnchor:!0,this.constrainResolution_=e.constrainResolution!==void 0?e.constrainResolution:!1;let t=e.condition?e.condition:Hi;this.condition_=e.onFocusOnly?to(za,t):t,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;let e=this.getMap();if(!e)return;e.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(e){if(!this.condition_(e)||e.type!==L.WHEEL)return!0;let i=e.map,n=e.originalEvent;n.preventDefault(),this.useAnchor_&&(this.lastAnchor_=e.pixel);let s=n.deltaY;switch(n.deltaMode){case WheelEvent.DOM_DELTA_LINE:s*=Ty;break;case WheelEvent.DOM_DELTA_PAGE:s*=Cy;break;default:}if(s===0)return!1;this.lastDelta_=s;let o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(s)<4?"trackpad":"wheel");let a=i.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-s/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=o,!1;this.totalDelta_+=s;let l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),l),!1}handleWheelZoom_(e){let t=e.getView();t.getAnimating()&&t.cancelAnimations();let i=-B(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),kr(t,i,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}},Xm=Gc;var Uc=class extends ot{constructor(e){e=e||{};let t=e;t.stopDown||(t.stopDown=Ot),super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold!==void 0?e.threshold:.3,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){let t=0,i=this.targetPointers[0],n=this.targetPointers[1],s=Math.atan2(n.clientY-i.clientY,n.clientX-i.clientX);if(this.lastAngle_!==void 0){let l=s-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),t=l}this.lastAngle_=s;let o=e.map,a=o.getView();a.getConstraints().rotation!==Ar&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Gr(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){let t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}},Ym=Uc;var Bc=class extends ot{constructor(e){e=e||{};let t=e;t.stopDown||(t.stopDown=Ot),super(t),this.anchor_=null,this.duration_=e.duration!==void 0?e.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1,i=this.targetPointers[0],n=this.targetPointers[1],s=i.clientX-n.clientX,o=i.clientY-n.clientY,a=Math.sqrt(s*s+o*o);this.lastDistance_!==void 0&&(t=this.lastDistance_/a),this.lastDistance_=a;let l=e.map,h=l.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Gr(this.targetPointers))),l.render(),h.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){let i=e.map.getView(),n=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,n),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){let t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}},$m=Bc;function io(r){r=r||{};let e=new Ce,t=new Fm(-.005,.05,100);return(r.altShiftDragRotate===void 0||r.altShiftDragRotate)&&e.push(new Um),(r.doubleClickZoom===void 0||r.doubleClickZoom)&&e.push(new Am({delta:r.zoomDelta,duration:r.zoomDuration})),(r.dragPan===void 0||r.dragPan)&&e.push(new Gm({onFocusOnly:r.onFocusOnly,kinetic:t})),(r.pinchRotate===void 0||r.pinchRotate)&&e.push(new Ym),(r.pinchZoom===void 0||r.pinchZoom)&&e.push(new $m({duration:r.zoomDuration})),(r.keyboard===void 0||r.keyboard)&&(e.push(new Vm),e.push(new Wm({delta:r.zoomDelta,duration:r.zoomDuration}))),(r.mouseWheelZoom===void 0||r.mouseWheelZoom)&&e.push(new Xm({onFocusOnly:r.onFocusOnly,duration:r.zoomDuration})),(r.shiftDragZoom===void 0||r.shiftDragZoom)&&e.push(new jm({duration:r.zoomDuration})),e}var se={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};var zc=class extends De{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;let t=Object.assign({},e);typeof e.properties=="object"&&(delete t.properties,Object.assign(t,e.properties)),t[se.OPACITY]=e.opacity!==void 0?e.opacity:1,W(typeof t[se.OPACITY]=="number","Layer opacity must be a number"),t[se.VISIBLE]=e.visible!==void 0?e.visible:!0,t[se.Z_INDEX]=e.zIndex,t[se.MAX_RESOLUTION]=e.maxResolution!==void 0?e.maxResolution:1/0,t[se.MIN_RESOLUTION]=e.minResolution!==void 0?e.minResolution:0,t[se.MIN_ZOOM]=e.minZoom!==void 0?e.minZoom:-1/0,t[se.MAX_ZOOM]=e.maxZoom!==void 0?e.maxZoom:1/0,this.className_=t.className!==void 0?t.className:"ol-layer",delete t.className,this.setProperties(t),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){let t=this.state_||{layer:this,managed:e===void 0?!0:e},i=this.getZIndex();return t.opacity=B(Math.round(this.getOpacity()*100)/100,0,1),t.visible=this.getVisible(),t.extent=this.getExtent(),t.zIndex=i===void 0&&!t.managed?1/0:i,t.maxResolution=this.getMaxResolution(),t.minResolution=Math.max(this.getMinResolution(),0),t.minZoom=this.getMinZoom(),t.maxZoom=this.getMaxZoom(),this.state_=t,t}getLayersArray(e){return j()}getLayerStatesArray(e){return j()}getExtent(){return this.get(se.EXTENT)}getMaxResolution(){return this.get(se.MAX_RESOLUTION)}getMinResolution(){return this.get(se.MIN_RESOLUTION)}getMinZoom(){return this.get(se.MIN_ZOOM)}getMaxZoom(){return this.get(se.MAX_ZOOM)}getOpacity(){return this.get(se.OPACITY)}getSourceState(){return j()}getVisible(){return this.get(se.VISIBLE)}getZIndex(){return this.get(se.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(se.EXTENT,e)}setMaxResolution(e){this.set(se.MAX_RESOLUTION,e)}setMinResolution(e){this.set(se.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(se.MAX_ZOOM,e)}setMinZoom(e){this.set(se.MIN_ZOOM,e)}setOpacity(e){W(typeof e=="number","Layer opacity must be a number"),this.set(se.OPACITY,e)}setVisible(e){this.set(se.VISIBLE,e)}setZIndex(e){this.set(se.Z_INDEX,e)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},Ya=zc;var Mn={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"},fi=class extends ye{constructor(e,t){super(e),this.layer=t}},jc={LAYERS:"layers"},Vc=class r extends Ya{constructor(e){e=e||{};let t=Object.assign({},e);delete t.layers;let i=e.layers;super(t),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(jc.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new Ce(i.slice(),{unique:!0}):W(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new Ce(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(K),this.layersListenerKeys_.length=0;let e=this.getLayers();this.layersListenerKeys_.push(k(e,fe.ADD,this.handleLayersAdd_,this),k(e,fe.REMOVE,this.handleLayersRemove_,this));for(let i in this.listenerKeys_)this.listenerKeys_[i].forEach(K);Dt(this.listenerKeys_);let t=e.getArray();for(let i=0,n=t.length;i<n;i++){let s=t[i];this.registerLayerListeners_(s),this.dispatchEvent(new fi(Mn.ADDLAYER,s))}this.changed()}registerLayerListeners_(e){let t=[k(e,He.PROPERTYCHANGE,this.handleLayerChange_,this),k(e,L.CHANGE,this.handleLayerChange_,this)];e instanceof r&&t.push(k(e,Mn.ADDLAYER,this.handleLayerGroupAdd_,this),k(e,Mn.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[P(e)]=t}handleLayerGroupAdd_(e){this.dispatchEvent(new fi(Mn.ADDLAYER,e.layer))}handleLayerGroupRemove_(e){this.dispatchEvent(new fi(Mn.REMOVELAYER,e.layer))}handleLayersAdd_(e){let t=e.element;this.registerLayerListeners_(t),this.dispatchEvent(new fi(Mn.ADDLAYER,t)),this.changed()}handleLayersRemove_(e){let t=e.element,i=P(t);this.listenerKeys_[i].forEach(K),delete this.listenerKeys_[i],this.dispatchEvent(new fi(Mn.REMOVELAYER,t)),this.changed()}getLayers(){return this.get(jc.LAYERS)}setLayers(e){let t=this.getLayers();if(t){let i=t.getArray();for(let n=0,s=i.length;n<s;++n)this.dispatchEvent(new fi(Mn.REMOVELAYER,i[n]))}this.set(jc.LAYERS,e)}getLayersArray(e){return e=e!==void 0?e:[],this.getLayers().forEach(function(t){t.getLayersArray(e)}),e}getLayerStatesArray(e){let t=e!==void 0?e:[],i=t.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(t)});let n=this.getLayerState(),s=n.zIndex;!e&&n.zIndex===void 0&&(s=0);for(let o=i,a=t.length;o<a;o++){let l=t[o];l.opacity*=n.opacity,l.visible=l.visible&&n.visible,l.maxResolution=Math.min(l.maxResolution,n.maxResolution),l.minResolution=Math.max(l.minResolution,n.minResolution),l.minZoom=Math.max(l.minZoom,n.minZoom),l.maxZoom=Math.min(l.maxZoom,n.maxZoom),n.extent!==void 0&&(l.extent!==void 0?l.extent=Xe(l.extent,n.extent):l.extent=n.extent),l.zIndex===void 0&&(l.zIndex=s)}return t}getSourceState(){return"ready"}},no=Vc;var ve={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var Wc=class extends Ya{constructor(e){let t=Object.assign({},e);delete t.source,super(t),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,e.render&&(this.render=e.render),e.map&&this.setMap(e.map),this.addChangeListener(se.SOURCE,this.handleSourcePropertyChange_);let i=e.source?e.source:null;this.setSource(i)}getLayersArray(e){return e=e||[],e.push(this),e}getLayerStatesArray(e){return e=e||[],e.push(this.getLayerState()),e}getSource(){return this.get(se.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){let e=this.getSource();return e?e.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(K(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;let e=this.getSource();e&&(this.sourceChangeKey_=k(e,L.CHANGE,this.handleSourceChange_,this),e.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t,i=this.getMapInternal();!e&&i&&(e=i.getView()),e instanceof It?t={viewState:e.getState(),extent:e.calculateExtent()}:t=e,!t.layerStatesArray&&i&&(t.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let n;if(t.layerStatesArray){if(n=t.layerStatesArray.find(o=>o.layer===this),!n)return!1}else n=this.getLayerState();let s=this.getExtent();return ro(n,t.viewState)&&(!s||te(s,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];let t=this.getSource()?.getAttributions();if(!t)return[];let i=e instanceof It?e.getViewStateAndExtent():e,n=t(i);return Array.isArray(n)||(n=[n]),n}render(e,t){let i=this.getRenderer();return i.prepareFrame(e)?(this.rendered=!0,i.renderFrame(e,t)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,t){}renderDeferred(e){let t=this.getRenderer();t&&t.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(se.MAP,e)}getMapInternal(){return this.get(se.MAP)}setMap(e){this.mapPrecomposeKey_&&(K(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(K(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=k(e,ve.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=k(this,L.CHANGE,e.render,e),this.changed())}handlePrecompose_(e){let t=e.frameState.layerStatesArray,i=this.getLayerState(!1);W(!t.some(n=>n.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),t.push(i)}setSource(e){this.set(se.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function ro(r,e){if(!r.visible)return!1;let t=e.resolution;if(t<r.minResolution||t>=r.maxResolution)return!1;let i=e.zoom;return i>r.minZoom&&i<=r.maxZoom}var qi=Wc;function $a(r,e,t=0,i=r.length-1,n=vy){for(;i>t;){if(i-t>600){let l=i-t+1,h=e-t+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(t,Math.floor(e-h*u/l+d)),g=Math.min(i,Math.floor(e+(l-h)*u/l+d));$a(r,e,f,g,n)}let s=r[e],o=t,a=i;for(so(r,t,e),n(r[i],s)>0&&so(r,t,i);o<a;){for(so(r,o,a),o++,a--;n(r[o],s)<0;)o++;for(;n(r[a],s)>0;)a--}n(r[t],s)===0?so(r,t,a):(a++,so(r,a,i)),a<=e&&(t=a+1),e<=a&&(i=a-1)}}function so(r,e,t){let i=r[e];r[e]=r[t],r[t]=i}function vy(r,e){return r<e?-1:r>e?1:0}var tr=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data,i=[];if(!Ha(e,t))return i;let n=this.toBBox,s=[];for(;t;){for(let o=0;o<t.children.length;o++){let a=t.children[o],l=t.leaf?n(a):a;Ha(e,l)&&(t.leaf?i.push(a):Yc(e,l)?this._all(a,i):s.push(a))}t=s.pop()}return i}collides(e){let t=this.data;if(!Ha(e,t))return!1;let i=[];for(;t;){for(let n=0;n<t.children.length;n++){let s=t.children[n],o=t.leaf?this.toBBox(s):s;if(Ha(e,o)){if(t.leaf||Yc(e,o))return!0;i.push(s)}}t=i.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let i=0;i<e.length;i++)this.insert(e[i]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){let i=this.data;this.data=t,t=i}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=zr([]),this}remove(e,t){if(!e)return this;let i=this.data,n=this.toBBox(e),s=[],o=[],a,l,h;for(;i||s.length;){if(i||(i=s.pop(),l=s[s.length-1],a=o.pop(),h=!0),i.leaf){let c=Sy(e,i.children,t);if(c!==-1)return i.children.splice(c,1),s.push(i),this._condense(s),this}!h&&!i.leaf&&Yc(i,n)?(s.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){let i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,n){let s=i-t+1,o=this._maxEntries,a;if(s<=o)return a=zr(e.slice(t,i+1)),Br(a,this.toBBox),a;n||(n=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,n-1))),a=zr([]),a.leaf=!1,a.height=n;let l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));Km(e,t,i,h,this.compareMinX);for(let c=t;c<=i;c+=h){let u=Math.min(c+h-1,i);Km(e,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){let f=Math.min(d+l-1,u);a.children.push(this._build(e,d,f,n-1))}}return Br(a,this.toBBox),a}_chooseSubtree(e,t,i,n){for(;n.push(t),!(t.leaf||n.length-1===i);){let s=1/0,o=1/0,a;for(let l=0;l<t.children.length;l++){let h=t.children[l],c=Xc(h),u=Py(e,h)-c;u<o?(o=u,s=c<s?c:s,a=h):u===o&&c<s&&(s=c,a=h)}t=a||t.children[0]}return t}_insert(e,t,i){let n=i?e:this.toBBox(e),s=[],o=this._chooseSubtree(n,this.data,t,s);for(o.children.push(e),ao(o,n);t>=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(n,s,t)}_split(e,t){let i=e[t],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);let o=this._chooseSplitIndex(i,s,n),a=zr(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Br(i,this.toBBox),Br(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=zr([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Br(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let n,s=1/0,o=1/0;for(let a=t;a<=i-t;a++){let l=oo(e,0,a,this.toBBox),h=oo(e,a,i,this.toBBox),c=Ly(l,h),u=Xc(l)+Xc(h);c<s?(s=c,n=a,o=u<o?u:o):c===s&&u<o&&(o=u,n=a)}return n||i-t}_chooseSplitAxis(e,t,i){let n=e.leaf?this.compareMinX:Ry,s=e.leaf?this.compareMinY:wy,o=this._allDistMargin(e,t,i,n),a=this._allDistMargin(e,t,i,s);o<a&&e.children.sort(n)}_allDistMargin(e,t,i,n){e.children.sort(n);let s=this.toBBox,o=oo(e,0,t,s),a=oo(e,i-t,i,s),l=Ka(o)+Ka(a);for(let h=t;h<i-t;h++){let c=e.children[h];ao(o,e.leaf?s(c):c),l+=Ka(o)}for(let h=i-t-1;h>=t;h--){let c=e.children[h];ao(a,e.leaf?s(c):c),l+=Ka(a)}return l}_adjustParentBBoxes(e,t,i){for(let n=i;n>=0;n--)ao(t[n],e)}_condense(e){for(let t=e.length-1,i;t>=0;t--)e[t].children.length===0?t>0?(i=e[t-1].children,i.splice(i.indexOf(e[t]),1)):this.clear():Br(e[t],this.toBBox)}};function Sy(r,e,t){if(!t)return e.indexOf(r);for(let i=0;i<e.length;i++)if(t(r,e[i]))return i;return-1}function Br(r,e){oo(r,0,r.children.length,e,r)}function oo(r,e,t,i,n){n||(n=zr(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(let s=e;s<t;s++){let o=r.children[s];ao(n,r.leaf?i(o):o)}return n}function ao(r,e){return r.minX=Math.min(r.minX,e.minX),r.minY=Math.min(r.minY,e.minY),r.maxX=Math.max(r.maxX,e.maxX),r.maxY=Math.max(r.maxY,e.maxY),r}function Ry(r,e){return r.minX-e.minX}function wy(r,e){return r.minY-e.minY}function Xc(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Ka(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Py(r,e){return(Math.max(e.maxX,r.maxX)-Math.min(e.minX,r.minX))*(Math.max(e.maxY,r.maxY)-Math.min(e.minY,r.minY))}function Ly(r,e){let t=Math.max(r.minX,e.minX),i=Math.max(r.minY,e.minY),n=Math.min(r.maxX,e.maxX),s=Math.min(r.maxY,e.maxY);return Math.max(0,n-t)*Math.max(0,s-i)}function Yc(r,e){return r.minX<=e.minX&&r.minY<=e.minY&&e.maxX<=r.maxX&&e.maxY<=r.maxY}function Ha(r,e){return e.minX<=r.maxX&&e.minY<=r.maxY&&e.maxX>=r.minX&&e.maxY>=r.minY}function zr(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Km(r,e,t,i,n){let s=[e,t];for(;s.length;){if(t=s.pop(),e=s.pop(),t-e<=i)continue;let o=e+Math.ceil((t-e)/i/2)*i;$a(r,o,e,t,n),s.push(e,o,o,t)}}var qa=[NaN,NaN,NaN,0],$c;function by(){return $c||($c=ne(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),$c}var Iy=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Fy=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,My=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Ay=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Za(r,e){return r.endsWith("%")?Number(r.substring(0,r.length-1))/e:Number(r)}function ho(r){throw new Error('failed to parse "'+r+'" as color')}function Hm(r){if(r.toLowerCase().startsWith("rgb")){let s=r.match(Fy)||r.match(Iy)||r.match(My);if(s){let o=s[4],a=100/255;return[B(Za(s[1],a)+.5|0,0,255),B(Za(s[2],a)+.5|0,0,255),B(Za(s[3],a)+.5|0,0,255),o!==void 0?B(Za(o,100),0,1):1]}ho(r)}if(r.startsWith("#")){if(Ay.test(r)){let s=r.substring(1),o=s.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=s.length;l<h;l+=o){let c=parseInt(s.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}ho(r)}let e=by();e.fillStyle="#abcdef";let t=e.fillStyle;e.fillStyle=r,e.fillStyle===t&&(e.fillStyle="#fedcba",t=e.fillStyle,e.fillStyle=r,e.fillStyle===t&&ho(r));let i=e.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return Hm(i);e.clearRect(0,0,1,1),e.fillRect(0,0,1,1);let n=Array.from(e.getImageData(0,0,1,1).data);return n[3]=hi(n[3]/255,3),n}function Zm(r){return typeof r=="string"?r:uo(r)}var Oy=1024,lo={},Kc=0;function qm(r){if(r.length===4)return r;let e=r.slice();return e[3]=1,e}function Hc(r){return r>.0031308?Math.pow(r,1/2.4)*269.025-14.025:r*3294.6}function Zc(r){return r>.2068965?Math.pow(r,3):(r-4/29)*(108/841)}function qc(r){return r>10.314724?Math.pow((r+14.025)/269.025,2.4):r/3294.6}function Jc(r){return r>.0088564?Math.pow(r,1/3):r/(108/841)+4/29}function Qc(r){let e=qc(r[0]),t=qc(r[1]),i=qc(r[2]),n=Jc(e*.222488403+t*.716873169+i*.06060791),s=500*(Jc(e*.452247074+t*.399439023+i*.148375274)-n),o=200*(n-Jc(e*.016863605+t*.117638439+i*.865350722)),a=Math.atan2(o,s)*(180/Math.PI);return[116*n-16,Math.sqrt(s*s+o*o),a<0?a+360:a,r[3]]}function Jm(r){let e=(r[0]+16)/116,t=r[1],i=r[2]*Math.PI/180,n=Zc(e),s=Zc(e+t/500*Math.cos(i)),o=Zc(e-t/200*Math.sin(i)),a=Hc(s*3.021973625-n*1.617392459-o*.404875592),l=Hc(s*-.943766287+n*1.916279586+o*.027607165),h=Hc(s*.069407491-n*.22898585+o*1.159737864);return[B(a+.5|0,0,255),B(l+.5|0,0,255),B(h+.5|0,0,255),r[3]]}function co(r){if(r==="none")return qa;if(lo.hasOwnProperty(r))return lo[r];if(Kc>=Oy){let t=0;for(let i in lo)(t++&3)===0&&(delete lo[i],--Kc)}let e=Hm(r);e.length!==4&&ho(r);for(let t of e)isNaN(t)&&ho(r);return lo[r]=e,++Kc,e}function tt(r){return Array.isArray(r)?r:co(r)}function uo(r){let e=r[0];e!=(e|0)&&(e=e+.5|0);let t=r[1];t!=(t|0)&&(t=t+.5|0);let i=r[2];i!=(i|0)&&(i=i+.5|0);let n=r[3]===void 0?1:Math.round(r[3]*1e3)/1e3;return"rgba("+e+","+t+","+i+","+n+")"}function eu(r){return r[0]>0&&r[1]>0}function Qm(r,e,t){return t===void 0&&(t=[0,0]),t[0]=r[0]*e+.5|0,t[1]=r[1]*e+.5|0,t}function Ee(r,e){return Array.isArray(r)?r:(e===void 0?e=[r,r]:(e[0]=r,e[1]=r),e)}var nr=0;var Me=1<<nr++,N=1<<nr++,Ne=1<<nr++,pe=1<<nr++,at=1<<nr++,Ft=1<<nr++,Ja=Math.pow(2,nr)-1,iu={[Me]:"boolean",[N]:"number",[Ne]:"string",[pe]:"color",[at]:"number[]",[Ft]:"size"},Dy=Object.keys(iu).map(Number).sort(_t);function ky(r){return r in iu}function ir(r){let e=[];for(let t of Dy)fo(r,t)&&e.push(iu[t]);return e.length===0?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function fo(r,e){return(r&e)===e}function gi(r,e){return r===e}var ke=class{constructor(e,t){if(!ky(e))throw new Error(`literal expressions must have a specific type, got ${ir(e)}`);this.type=e,this.value=t}},go=class{constructor(e,t,...i){this.type=e,this.operator=t,this.args=i}};function mo(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function Ye(r,e,t){switch(typeof r){case"boolean":{if(gi(e,Ne))return new ke(Ne,r?"true":"false");if(!fo(e,Me))throw new Error(`got a boolean, but expected ${ir(e)}`);return new ke(Me,r)}case"number":{if(gi(e,Ft))return new ke(Ft,Ee(r));if(gi(e,Me))return new ke(Me,!!r);if(gi(e,Ne))return new ke(Ne,r.toString());if(!fo(e,N))throw new Error(`got a number, but expected ${ir(e)}`);return new ke(N,r)}case"string":{if(gi(e,pe))return new ke(pe,co(r));if(gi(e,Me))return new ke(Me,!!r);if(!fo(e,Ne))throw new Error(`got a string, but expected ${ir(e)}`);return new ke(Ne,r)}default:}if(!Array.isArray(r))throw new Error("expression must be an array or a primitive value");if(r.length===0)throw new Error("empty expression");if(typeof r[0]=="string")return $y(r,e,t);for(let i of r)if(typeof i!="number")throw new Error("expected an array of numbers");if(gi(e,Ft)){if(r.length!==2)throw new Error(`expected an array of two values for a size, got ${r.length}`);return new ke(Ft,r)}if(gi(e,pe)){if(r.length===3)return new ke(pe,[...r,1]);if(r.length===4)return new ke(pe,r);throw new Error(`expected an array of 3 or 4 values for a color, got ${r.length}`)}if(!fo(e,at))throw new Error(`got an array of numbers, but expected ${ir(e)}`);return new ke(at,r)}var C={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},Ny={[C.Get]:J(ie(1,1/0),ep),[C.Var]:J(ie(1,1),Gy),[C.Has]:J(ie(1,1/0),ep),[C.Id]:J(Uy,jr),[C.Concat]:J(ie(2,1/0),ge(Ne)),[C.GeometryType]:J(By,jr),[C.LineMetric]:J(jr),[C.Resolution]:J(tu,jr),[C.Zoom]:J(tu,jr),[C.Time]:J(tu,jr),[C.Any]:J(ie(2,1/0),ge(Me)),[C.All]:J(ie(2,1/0),ge(Me)),[C.Not]:J(ie(1,1),ge(Me)),[C.Equal]:J(ie(2,2),ge(Ja)),[C.NotEqual]:J(ie(2,2),ge(Ja)),[C.GreaterThan]:J(ie(2,2),ge(N)),[C.GreaterThanOrEqualTo]:J(ie(2,2),ge(N)),[C.LessThan]:J(ie(2,2),ge(N)),[C.LessThanOrEqualTo]:J(ie(2,2),ge(N)),[C.Multiply]:J(ie(2,1/0),tp),[C.Coalesce]:J(ie(2,1/0),tp),[C.Divide]:J(ie(2,2),ge(N)),[C.Add]:J(ie(2,1/0),ge(N)),[C.Subtract]:J(ie(2,2),ge(N)),[C.Clamp]:J(ie(3,3),ge(N)),[C.Mod]:J(ie(2,2),ge(N)),[C.Pow]:J(ie(2,2),ge(N)),[C.Abs]:J(ie(1,1),ge(N)),[C.Floor]:J(ie(1,1),ge(N)),[C.Ceil]:J(ie(1,1),ge(N)),[C.Round]:J(ie(1,1),ge(N)),[C.Sin]:J(ie(1,1),ge(N)),[C.Cos]:J(ie(1,1),ge(N)),[C.Atan]:J(ie(1,2),ge(N)),[C.Sqrt]:J(ie(1,1),ge(N)),[C.Match]:J(ie(4,1/0),ip,jy),[C.Between]:J(ie(3,3),ge(N)),[C.Interpolate]:J(ie(6,1/0),ip,Vy),[C.Case]:J(ie(3,1/0),zy,Wy),[C.In]:J(ie(2,2),Xy),[C.Number]:J(ie(1,1/0),ge(Ja)),[C.String]:J(ie(1,1/0),ge(Ja)),[C.Array]:J(ie(1,1/0),ge(N)),[C.Color]:J(ie(1,4),ge(N)),[C.Band]:J(ie(1,3),ge(N)),[C.Palette]:J(ie(2,2),Yy),[C.ToString]:J(ie(1,1),ge(Me|N|Ne|pe))};function ep(r,e,t){let i=r.length-1,n=new Array(i);for(let s=0;s<i;++s){let o=r[s+1];switch(typeof o){case"number":{n[s]=new ke(N,o);break}case"string":{n[s]=new ke(Ne,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}s===0&&t.properties.add(String(o))}return n}function Gy(r,e,t){let i=r[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return t.variables.add(i),[new ke(Ne,i)]}function Uy(r,e,t){t.featureId=!0}function By(r,e,t){t.geometryType=!0}function tu(r,e,t){t.mapState=!0}function jr(r,e,t){let i=r[0];if(r.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function ie(r,e){return function(t,i,n){let s=t[0],o=t.length-1;if(r===e){if(o!==r){let a=r===1?"":"s";throw new Error(`expected ${r} argument${a} for ${s}, got ${o}`)}}else if(o<r||o>e){let a=e===1/0?`${r} or more`:`${r} to ${e}`;throw new Error(`expected ${a} arguments for ${s}, got ${o}`)}}}function tp(r,e,t){let i=r.length-1,n=new Array(i);for(let s=0;s<i;++s){let o=Ye(r[s+1],e,t);n[s]=o}return n}function ge(r){return function(e,t,i){let n=e.length-1,s=new Array(n);for(let o=0;o<n;++o){let a=Ye(e[o+1],r,i);s[o]=a}return s}}function zy(r,e,t){let i=r[0],n=r.length-1;if(n%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${n} instead`)}function ip(r,e,t){let i=r[0],n=r.length-1;if(n%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${n} instead`)}function jy(r,e,t){let i=r.length-1,n=Ne|N|Me,s=Ye(r[1],n,t),o=Ye(r[r.length-1],e,t),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{let h=Ye(r[l+2],s.type,t);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{let h=Ye(r[l+3],o.type,t);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[s,...a,o]}function Vy(r,e,t){let i=r[1],n;switch(i[0]){case"linear":n=1;break;case"exponential":let l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);n=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}let s=new ke(N,n),o;try{o=Ye(r[2],N,t)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}let a=new Array(r.length-3);for(let l=0;l<a.length;l+=2){try{let h=Ye(r[l+3],N,t);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{let h=Ye(r[l+4],e,t);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[s,o,...a]}function Wy(r,e,t){let i=Ye(r[r.length-1],e,t),n=new Array(r.length-1);for(let s=0;s<n.length-1;s+=2){try{let o=Ye(r[s+1],Me,t);n[s]=o}catch(o){throw new Error(`failed to parse argument ${s} of case expression: ${o.message}`)}try{let o=Ye(r[s+2],i.type,t);n[s+1]=o}catch(o){throw new Error(`failed to parse argument ${s+1} of case expression: ${o.message}`)}}return n[n.length-1]=i,n}function Xy(r,e,t){let i=r[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let n;if(typeof i[0]=="string"){if(i[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(i[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');i=i[1],n=Ne}else n=N;let s=new Array(i.length);for(let a=0;a<s.length;a++)try{let l=Ye(i[a],n,t);s[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[Ye(r[1],n,t),...s]}function Yy(r,e,t){let i;try{i=Ye(r[1],N,t)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}let n=r[2];if(!Array.isArray(n))throw new Error("the second argument of palette must be an array");let s=new Array(n.length);for(let o=0;o<s.length;o++){let a;try{a=Ye(n[o],pe,t)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof ke))throw new Error(`the palette color at index ${o} must be a literal value`);s[o]=a}return[i,...s]}function J(...r){return function(e,t,i){let n=e[0],s;for(let o=0;o<r.length;o++){let a=r[o](e,t,i);if(o==r.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");s=a}}return new go(t,n,...s)}}function $y(r,e,t){let i=r[0],n=Ny[i];if(!n)throw new Error(`unknown operator: ${i}`);return n(r,e,t)}function po(r){if(!r)return"";let e=r.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 po(r.getGeometries()[0]);default:return""}}function nu(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function pi(r,e,t){let i=Ye(r,e,t);return mi(i,t)}function mi(r,e){if(r instanceof ke){if(r.type===pe&&typeof r.value=="string"){let i=co(r.value);return function(){return i}}return function(){return r.value}}let t=r.operator;switch(t){case C.Number:case C.String:case C.Coalesce:return Ky(r,e);case C.Get:case C.Var:case C.Has:return Hy(r,e);case C.Id:return i=>i.featureId;case C.GeometryType:return i=>i.geometryType;case C.Concat:{let i=r.args.map(n=>mi(n,e));return n=>"".concat(...i.map(s=>s(n).toString()))}case C.Resolution:return i=>i.resolution;case C.Any:case C.All:case C.Between:case C.In:case C.Not:return qy(r,e);case C.Equal:case C.NotEqual:case C.LessThan:case C.LessThanOrEqualTo:case C.GreaterThan:case C.GreaterThanOrEqualTo:return Zy(r,e);case C.Multiply:case C.Divide:case C.Add:case C.Subtract:case C.Clamp:case C.Mod:case C.Pow:case C.Abs:case C.Floor:case C.Ceil:case C.Round:case C.Sin:case C.Cos:case C.Atan:case C.Sqrt:return Jy(r,e);case C.Case:return Qy(r,e);case C.Match:return e0(r,e);case C.Interpolate:return t0(r,e);case C.ToString:return i0(r,e);default:throw new Error(`Unsupported operator ${t}`)}}function Ky(r,e){let t=r.operator,i=r.args.length,n=new Array(i);for(let s=0;s<i;++s)n[s]=mi(r.args[s],e);switch(t){case C.Coalesce:return s=>{for(let o=0;o<i;++o){let a=n[o](s);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case C.Number:case C.String:return s=>{for(let o=0;o<i;++o){let a=n[o](s);if(typeof a===t)return a}throw new Error(`Expected one of the values to be a ${t}`)};default:throw new Error(`Unsupported assertion operator ${t}`)}}function Hy(r,e){let i=r.args[0].value;switch(r.operator){case C.Get:return n=>{let s=r.args,o=n.properties[i];for(let a=1,l=s.length;a<l;++a){let c=s[a].value;o=o[c]}return o};case C.Var:return n=>n.variables[i];case C.Has:return n=>{let s=r.args;if(!(i in n.properties))return!1;let o=n.properties[i];for(let a=1,l=s.length;a<l;++a){let c=s[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${r.operator}`)}}function Zy(r,e){let t=r.operator,i=mi(r.args[0],e),n=mi(r.args[1],e);switch(t){case C.Equal:return s=>i(s)===n(s);case C.NotEqual:return s=>i(s)!==n(s);case C.LessThan:return s=>i(s)<n(s);case C.LessThanOrEqualTo:return s=>i(s)<=n(s);case C.GreaterThan:return s=>i(s)>n(s);case C.GreaterThanOrEqualTo:return s=>i(s)>=n(s);default:throw new Error(`Unsupported comparison operator ${t}`)}}function qy(r,e){let t=r.operator,i=r.args.length,n=new Array(i);for(let s=0;s<i;++s)n[s]=mi(r.args[s],e);switch(t){case C.Any:return s=>{for(let o=0;o<i;++o)if(n[o](s))return!0;return!1};case C.All:return s=>{for(let o=0;o<i;++o)if(!n[o](s))return!1;return!0};case C.Between:return s=>{let o=n[0](s),a=n[1](s),l=n[2](s);return o>=a&&o<=l};case C.In:return s=>{let o=n[0](s);for(let a=1;a<i;++a)if(o===n[a](s))return!0;return!1};case C.Not:return s=>!n[0](s);default:throw new Error(`Unsupported logical operator ${t}`)}}function Jy(r,e){let t=r.operator,i=r.args.length,n=new Array(i);for(let s=0;s<i;++s)n[s]=mi(r.args[s],e);switch(t){case C.Multiply:return s=>{let o=1;for(let a=0;a<i;++a)o*=n[a](s);return o};case C.Divide:return s=>n[0](s)/n[1](s);case C.Add:return s=>{let o=0;for(let a=0;a<i;++a)o+=n[a](s);return o};case C.Subtract:return s=>n[0](s)-n[1](s);case C.Clamp:return s=>{let o=n[0](s),a=n[1](s);if(o<a)return a;let l=n[2](s);return o>l?l:o};case C.Mod:return s=>n[0](s)%n[1](s);case C.Pow:return s=>Math.pow(n[0](s),n[1](s));case C.Abs:return s=>Math.abs(n[0](s));case C.Floor:return s=>Math.floor(n[0](s));case C.Ceil:return s=>Math.ceil(n[0](s));case C.Round:return s=>Math.round(n[0](s));case C.Sin:return s=>Math.sin(n[0](s));case C.Cos:return s=>Math.cos(n[0](s));case C.Atan:return i===2?s=>Math.atan2(n[0](s),n[1](s)):s=>Math.atan(n[0](s));case C.Sqrt:return s=>Math.sqrt(n[0](s));default:throw new Error(`Unsupported numeric operator ${t}`)}}function Qy(r,e){let t=r.args.length,i=new Array(t);for(let n=0;n<t;++n)i[n]=mi(r.args[n],e);return n=>{for(let s=0;s<t-1;s+=2)if(i[s](n))return i[s+1](n);return i[t-1](n)}}function e0(r,e){let t=r.args.length,i=new Array(t);for(let n=0;n<t;++n)i[n]=mi(r.args[n],e);return n=>{let s=i[0](n);for(let o=1;o<t-1;o+=2)if(s===i[o](n))return i[o+1](n);return i[t-1](n)}}function t0(r,e){let t=r.args.length,i=new Array(t);for(let n=0;n<t;++n)i[n]=mi(r.args[n],e);return n=>{let s=i[0](n),o=i[1](n),a,l;for(let h=2;h<t;h+=2){let c=i[h](n),u=i[h+1](n),d=Array.isArray(u);if(d&&(u=qm(u)),c>=o)return h===2?u:d?n0(s,o,a,l,c,u):_o(s,o,a,l,c,u);a=c,l=u}return l}}function i0(r,e){let t=r.operator,i=r.args.length,n=new Array(i);for(let s=0;s<i;++s)n[s]=mi(r.args[s],e);if(t===C.ToString)return s=>{let o=n[0](s);return r.args[0].type===pe?uo(o):o.toString()};throw new Error(`Unsupported convert operator ${t}`)}function _o(r,e,t,i,n,s){let o=n-t;if(o===0)return i;let a=e-t,l=r===1?a/o:(Math.pow(r,a)-1)/(Math.pow(r,o)-1);return i+l*(s-i)}function n0(r,e,t,i,n,s){if(n-t===0)return i;let a=Qc(i),l=Qc(s),h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);let c=[_o(r,e,t,a[0],n,l[0]),_o(r,e,t,a[1],n,l[1]),a[2]+_o(r,e,t,0,n,h),_o(r,e,t,i[3],n,s[3])];return Jm(c)}var A={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};var ru=class extends vi{constructor(e,t,i,n){super(),this.extent=e,this.pixelRatio_=i,this.resolution=t,this.state=typeof n=="function"?A.IDLE:n,this.image_=null,this.loader=typeof n=="function"?n:null}changed(){this.dispatchEvent(L.CHANGE)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==A.IDLE&&this.loader){this.state=A.LOADING,this.changed();let e=this.getResolution(),t=Array.isArray(e)?e[0]:e;ea(()=>this.loader(this.getExtent(),t,this.getPixelRatio())).then(i=>{"image"in i&&(this.image_=i.image),"extent"in i&&(this.extent=i.extent),"resolution"in i&&(this.resolution=i.resolution),"pixelRatio"in i&&(this.pixelRatio_=i.pixelRatio),(i instanceof HTMLImageElement||Fh&&i instanceof ImageBitmap||i instanceof HTMLCanvasElement||i instanceof HTMLVideoElement)&&(this.image_=i),this.state=A.LOADED}).catch(i=>{this.state=A.ERROR,console.error(i)}).finally(()=>this.changed())}}setImage(e){this.image_=e}setResolution(e){this.resolution=e}};function np(r,e,t){let i=r,n=!0,s=!1,o=!1,a=[_n(i,L.LOAD,function(){o=!0,s||e()})];return i.src&&na?(s=!0,i.decode().then(function(){n&&e()}).catch(function(l){n&&(o?e():t())})):a.push(_n(i,L.ERROR,t)),function(){n=!1,a.forEach(K)}}function r0(r,e){return new Promise((t,i)=>{function n(){o(),t(r)}function s(){o(),i(new Error("Image load error"))}function o(){r.removeEventListener("load",n),r.removeEventListener("error",s)}r.addEventListener("load",n),r.addEventListener("error",s),e&&(r.src=e)})}function su(r,e){return e&&(r.src=e),r.src&&na?new Promise((t,i)=>r.decode().then(()=>t(r)).catch(n=>r.complete&&r.width?t(r):i(n))):r0(r)}function An(r,e){return e&&(r.src=e),r.src&&na&&Fh?r.decode().then(()=>createImageBitmap(r)).catch(t=>{if(r.complete&&r.width)return r;throw t}):su(r)}var Vr=ru;var au=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(let t in this.cache_){let i=this.cache_[t];(e++&3)===0&&!i.hasListener()&&(delete this.cache_[t],delete this.patternCache_[t],--this.cacheSize_)}}}get(e,t){let i=ou(e,t);return i in this.cache_?this.cache_[i]:null}getPattern(e,t){let i=ou(e,t);return i in this.patternCache_?this.patternCache_[i]:null}set(e,t,i,n){let s=ou(e,t),o=s in this.cache_;this.cache_[s]=i,n&&(i.getImageState()===A.IDLE&&i.load(),i.getImageState()===A.LOADING?i.ready().then(()=>{this.patternCache_[s]=Dr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[s]=Dr().createPattern(i.getImage(1),"repeat")),o||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}};function ou(r,e){let t=e?tt(e):"null";return r+":"+t}var Tt=new au;var xo=null,Qa=class extends vi{constructor(e,t,i,n,s){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.canvas_={},this.color_=s,this.imageState_=n===void 0?A.IDLE:n,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===A.LOADED){xo||(xo=ne(1,1,void 0,{willReadFrequently:!0})),xo.drawImage(this.image_,0,0);try{xo.getImageData(0,0,1,1),this.tainted_=!1}catch{xo=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(L.CHANGE)}handleImageError_(){this.imageState_=A.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=A.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}setImage(e){this.image_=e}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let e=this.size_[0],t=this.size_[1],i=ne(e,t);i.fillRect(0,0,e,t),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===A.IDLE){this.image_||this.initializeImage_(),this.imageState_=A.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&su(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==A.LOADED)return;let t=this.image_,i=ne(Math.ceil(t.width*e),Math.ceil(t.height*e)),n=i.canvas;i.scale(e,e),i.drawImage(t,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Zm(this.color_),i.fillRect(0,0,n.width/e,n.height/e),i.globalCompositeOperation="destination-in",i.drawImage(t,0,0),this.canvas_[e]=n}ready(){return this.ready_||(this.ready_=new Promise(e=>{if(this.imageState_===A.LOADED||this.imageState_===A.ERROR)e();else{let t=()=>{(this.imageState_===A.LOADED||this.imageState_===A.ERROR)&&(this.removeEventListener(L.CHANGE,t),e())};this.addEventListener(L.CHANGE,t)}})),this.ready_}};function On(r,e,t,i,n,s){let o=e===void 0?void 0:Tt.get(e,n);return o||(o=new Qa(r,r&&"src"in r?r.src||void 0:e,t,i,n),Tt.set(e,n,o,s)),s&&o&&!Tt.getPattern(e,n)&&Tt.set(e,n,o,s),o}var rp=Qa;function Xt(r){return r?Array.isArray(r)?uo(r):typeof r=="object"&&"src"in r?s0(r):r:null}function s0(r){if(!r.offset||!r.size)return Tt.getPattern(r.src,r.color);let e=r.src+":"+r.offset,t=Tt.getPattern(e,r.color);if(t)return t;let i=Tt.get(r.src,null);if(i.getImageState()!==A.LOADED)return null;let n=ne(r.size[0],r.size[1]);return n.drawImage(i.getImage(1),r.offset[0],r.offset[1],r.size[0],r.size[1],0,0,r.size[0],r.size[1]),On(n.canvas,e,void 0,A.LOADED,r.color,!0),Tt.getPattern(e,r.color)}var el="10px sans-serif",it="#000",wi="round",Yt=[],$t=0,Pi="round",Ji=10,op=0,Qi="#000",Dn="center",sr="middle",en=[0,0,0,0],tn=1,rr=new De,yo=null,sp,lu={},o0=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function a0(r,e,t){return`${r} ${e} 16px "${t}"`}var ap=(function(){let e,t;async function i(s){await t.ready;let o=await t.load(s);if(o.length===0)return!1;let a=Ga(s),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{let u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=Na[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function n(){await t.ready;let s=!0,o=rr.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){let h=a[l],c=o[h];c<100&&(await i(h)?(Dt(lu),rr.set(h,100)):(c+=10,rr.set(h,c,!0),c<100&&(s=!1)))}e=void 0,s||(e=setTimeout(n,100))}return async function(s){t||(t=Ze?self.fonts:document.fonts);let o=Ga(s);if(!o)return;let a=o.families,l=!1;for(let h of a){if(o0.has(h))continue;let c=a0(o.style,o.weight,h);rr.get(c)===void 0&&(rr.set(c,0,!0),l=!0)}l&&(clearTimeout(e),e=setTimeout(n,100))}})(),l0=(function(){let r;return function(e){let t=lu[e];if(t==null){if(Ze){let i=Ga(e),n=lp(e,"\u017Dg");t=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent)}else r||(r=document.createElement("div"),r.innerHTML="M",r.style.minHeight="0",r.style.maxHeight="none",r.style.height="auto",r.style.padding="0",r.style.border="none",r.style.position="absolute",r.style.display="block",r.style.left="-99999px"),r.style.font=e,document.body.appendChild(r),t=r.offsetHeight,document.body.removeChild(r);lu[e]=t}return t}})();function lp(r,e){return yo||(yo=ne(1,1)),r!=sp&&(yo.font=r,sp=yo.font),yo.measureText(e)}function hp(r,e){return lp(r,e).width}function hu(r,e,t){if(e in t)return t[e];let i=e.split(`
2
+ `).reduce((n,s)=>Math.max(n,hp(r,s)),0);return t[e]=i,i}function cp(r,e){let t=[],i=[],n=[],s=0,o=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){let u=e[h];if(u===`
3
+ `||h===c){s=Math.max(s,o),n.push(o),o=0,a+=l,l=0;continue}let d=e[h+1]||r.font,f=hp(d,u);t.push(f),o+=f;let g=l0(d);i.push(g),l=Math.max(l,g)}return{width:s,height:a,widths:t,heights:i,lineWidths:n}}function up(r,e,t,i,n,s,o,a,l,h,c){r.save(),t!==1&&(r.globalAlpha===void 0?r.globalAlpha=u=>u.globalAlpha*=t:r.globalAlpha*=t),e&&r.transform.apply(r,e),i.contextInstructions?(r.translate(l,h),r.scale(c[0],c[1]),h0(i,r)):c[0]<0||c[1]<0?(r.translate(l,h),r.scale(c[0],c[1]),r.drawImage(i,n,s,o,a,0,0,o,a)):r.drawImage(i,n,s,o,a,l,h,o*c[0],a*c[1]),r.restore()}function h0(r,e){let t=r.contextInstructions;for(let i=0,n=t.length;i<n;i+=2)Array.isArray(t[i+1])?e[t[i]].apply(e,t[i+1]):e[t[i]]=t[i+1]}var cu=class r{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=Ee(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){let e=this.getScale();return new r({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,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 j()}getImage(e){return j()}getHitDetectionImage(){return j()}getPixelRatio(e){return 1}getImageState(){return j()}getImageSize(){return j()}getOrigin(){return j()}getSize(){return j()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Ee(e)}listenImageChange(e){j()}load(){j()}unlistenImageChange(e){j()}ready(){return Promise.resolve()}},tl=cu;var uu=class r extends tl{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.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()?A.LOADING:A.LOADED,this.imageState_===A.LOADING&&this.ready().then(()=>this.imageState_=A.LOADED),this.render()}clone(){let e=this.getScale(),t=new r({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(),i=this.getScaleArray();return[e[0]/2-t[0]/i[0],e[1]/2+t[1]/i[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.fill_?.getKey(),i=`${e},${this.angle_},${this.radius},${this.radius2_},${this.points_},${t}`+Object.values(this.renderOptions_).join(","),n=Tt.get(i,null)?.getImage(1);if(!n){let s=this.renderOptions_,o=Math.ceil(s.size*e),a=ne(o,o);this.draw_(s,a,e),n=a.canvas;let l=new rp(n,void 0,null,A.LOADED,null);Tt.set(i,null,l),createImageBitmap(n).then(h=>{l.setImage(h)})}return n}getPixelRatio(e){return e}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(e){this.radius!==e&&(this.radius=e,this.render())}getRadius2(){return this.radius2_}setRadius2(e){this.radius2_!==e&&(this.radius2_=e,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,t,i){if(t===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return t;let n=this.radius,s=this.radius2_===void 0?n:this.radius2_;if(n<s){let v=n;n=s,s=v}let o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=s*Math.sin(a),h=Math.sqrt(s*s-l*l),c=n-h,u=Math.sqrt(l*l+c*c),d=u/l;if(e==="miter"&&d<=i)return d*t;let f=t/2/d,g=t/2*(c/u),p=Math.sqrt((n+f)*(n+f)+g*g)-n;if(this.radius2_===void 0||e==="bevel")return p*2;let _=n*Math.sin(a),x=Math.sqrt(n*n-_*_),y=s-x,T=Math.sqrt(_*_+y*y)/_;if(T<=i){let v=T*t/2-s-n;return 2*Math.max(p,v)}return p*2}createRenderOptions(){let e=wi,t=Pi,i=0,n=null,s=0,o,a=0;this.stroke_&&(o=Xt(this.stroke_.getColor()??Qi),a=this.stroke_.getWidth()??tn,n=this.stroke_.getLineDash(),s=this.stroke_.getLineDashOffset()??0,t=this.stroke_.getLineJoin()??Pi,e=this.stroke_.getLineCap()??wi,i=this.stroke_.getMiterLimit()??Ji);let l=this.calculateLineJoinSize_(t,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:e,lineDash:n,lineDashOffset:s,lineJoin:t,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();let e=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[e,e]}draw_(e,t,i){if(t.scale(i,i),t.translate(e.size/2,e.size/2),this.createPath_(t),this.fill_){let n=this.fill_.getColor();n===null&&(n=it),t.fillStyle=Xt(n),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 i=this.fill_.getColor(),n=0;typeof i=="string"&&(i=tt(i)),i===null?n=1:Array.isArray(i)&&(n=i.length===4?i[3]:1),n===0&&(t=ne(e.size,e.size),this.drawHitDetectionCanvas_(e,t))}return t?t.canvas:this.getImage(1)}createPath_(e){let t=this.points_,i=this.radius;if(t===1/0)e.arc(0,0,i,0,2*Math.PI);else{let n=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(t*=2);let s=this.angle_-Math.PI/2,o=2*Math.PI/t;for(let a=0;a<t;a++){let l=s+a*o,h=a%2===0?i:n;e.lineTo(h*Math.cos(l),h*Math.sin(l))}e.closePath()}}drawHitDetectionCanvas_(e,t){t.translate(e.size/2,e.size/2),this.createPath_(t),t.fillStyle=it,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()}},il=uu;var du=class r extends il{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 r({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}},Mt=du;var fu=class r{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){let e=this.getColor();return new r({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){let t=On(null,e.src,{crossOrigin:"anonymous"},void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));t.ready().then(()=>{this.patternImage_=null}),t.getImageState()===A.IDLE&&t.load(),t.getImageState()===A.LOADING&&(this.patternImage_=t)}this.color_=e}getKey(){let e=this.getColor();return e?e instanceof CanvasPattern||e instanceof CanvasGradient?P(e):typeof e=="object"&&"src"in e?e.src+":"+e.offset:tt(e).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},_e=fu;function dp(r,e,t,i){return t!==void 0&&i!==void 0?[t/r,i/e]:t!==void 0?t/r:i!==void 0?i/e:1}var gu=class r extends tl{constructor(e){e=e||{};let t=e.opacity!==void 0?e.opacity:1,i=e.rotation!==void 0?e.rotation:0,n=e.scale!==void 0?e.scale:1,s=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:t,rotation:i,scale:n,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:s,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,this.referrerPolicy_=e.referrerPolicy;let o=e.img!==void 0?e.img:null,a=e.src;W(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||P(o)),W(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),W(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(e.src!==void 0?l=A.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?A.LOADED:A.IDLE:l=A.LOADING:l=A.LOADED),this.color_=e.color!==void 0?tt(e.color):null,this.iconImage_=On(o,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},l,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,this.initialOptions_,e.width!==void 0||e.height!==void 0){let h,c;if(e.size)[h,c]=e.size;else{let u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=e;let d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;let f=this.iconImage_.getSize();this.setScale(dp(f[0],f[1],e.width,e.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(dp(h,c,e.width,e.height))}}clone(){let e,t,i;return this.initialOptions_?(t=this.initialOptions_.width,i=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new r({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_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:t,height:i,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 n=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!n)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=n[0]),this.anchorYUnits_=="fraction"&&(e[1]*=n[1])}if(this.anchorOrigin_!="top-left"){if(!n)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+n[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+n[1])}this.normalizedAnchor_=e}let t=this.getDisplacement(),i=this.getScaleArray();return[e[0]-t[0]/i[0],e[1]+t[1]/i[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(e){let t=e?tt(e):null;if(this.color_===t||this.color_&&t&&this.color_.length===t.length&&this.color_.every((o,a)=>o===t[a]))return;this.color_=t;let i=this.getSrc(),n=i!==void 0?null:this.getHitDetectionImage(),s=i!==void 0?A.IDLE:this.iconImage_.getImageState();this.iconImage_=On(n,i,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},s,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(),i=this.iconImage_.getSize();if(!t||!i)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=i[0]-t[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=i[1]-t[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(e){this.iconImage_=On(null,e,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},A.IDLE,this.color_)}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()==A.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()==A.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(L.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(L.CHANGE,e)}ready(){return this.iconImage_.ready()}},Eo=gu;var mu=class r{constructor(e){e=e||{},this.color_=e.color!==void 0?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash!==void 0?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.offset_=e.offset,this.width_=e.width}clone(){let e=this.getColor();return new r({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),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_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setOffset(e){this.offset_=e}setWidth(e){this.width_=e}},Te=mu;var kn=class r{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=fp,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 r({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_=fp,this.geometry_=e}setZIndex(e){this.zIndex_=e}};function gp(r){let e;if(typeof r=="function")e=r;else{let t;Array.isArray(r)?t=r:(W(typeof r.getZIndex=="function","Expected an `Style` or an array of `Style`"),t=[r]),e=function(){return t}}return e}var pu=null;function _u(r,e){if(!pu){let t=new _e({color:"rgba(255,255,255,0.4)"}),i=new Te({color:"#3399CC",width:1.25});pu=[new kn({image:new Mt({fill:t,stroke:i,radius:5}),fill:t,stroke:i})]}return pu}function Wr(){let r={},e=[255,255,255,1],t=[0,153,255,1],i=3;return r.Polygon=[new kn({fill:new _e({color:[255,255,255,.5]})})],r.MultiPolygon=r.Polygon,r.LineString=[new kn({stroke:new Te({color:e,width:i+2})}),new kn({stroke:new Te({color:t,width:i})})],r.MultiLineString=r.LineString,r.Circle=r.Polygon.concat(r.LineString),r.Point=[new kn({image:new Mt({radius:i*2,fill:new _e({color:t}),stroke:new Te({color:e,width:i/2})}),zIndex:1/0})],r.MultiPoint=r.Point,r.GeometryCollection=r.Polygon.concat(r.LineString,r.Point),r}function fp(r){return r.getGeometry()}var ze=kn;var c0="#333",xu=class r{constructor(e){e=e||{},this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.keepUpright_=e.keepUpright,this.scale_=e.scale,this.scaleArray_=Ee(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 _e({color:c0}),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 r({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof _e?this.getFill().clone():this.getFill(),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_}getKeepUpright(){return this.keepUpright_}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}setKeepUpright(e){this.keepUpright_=e}setFill(e){this.fill_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Ee(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}},nn=xu;function u0(r){return!0}function xp(r){let e=mo(),t=d0(r,e),i=nu();return function(n,s){if(i.properties=n.getPropertiesInternal(),i.resolution=s,e.featureId){let o=n.getId();o!==void 0?i.featureId=o:i.featureId=null}return e.geometryType&&(i.geometryType=po(n.getGeometry())),t(i)}}function Tu(r){let e=mo(),t=r.length,i=new Array(t);for(let o=0;o<t;++o)i[o]=yu(r[o],e);let n=nu(),s=new Array(t);return function(o,a){if(n.properties=o.getPropertiesInternal(),n.resolution=a,e.featureId){let h=o.getId();h!==void 0?n.featureId=h:n.featureId=null}let l=0;for(let h=0;h<t;++h){let c=i[h](n);c&&(s[l]=c,l+=1)}return s.length=l,s}}function d0(r,e){let t=r.length,i=new Array(t);for(let n=0;n<t;++n){let s=r[n],o="filter"in s?pi(s.filter,Me,e):u0,a;if(Array.isArray(s.style)){let l=s.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=yu(s.style[h],e)}else a=[yu(s.style,e)];i[n]={filter:o,styles:a}}return function(n){let s=[],o=!1;for(let a=0;a<t;++a){let l=i[a].filter;if(l(n)&&!(r[a].else&&o)){o=!0;for(let h of i[a].styles){let c=h(n);c&&s.push(c)}}}return s}}function yu(r,e){let t=To(r,"",e),i=Co(r,"",e),n=f0(r,e),s=g0(r,e),o=ft(r,"z-index",e);if(!t&&!i&&!n&&!s&&!wt(r))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(r));let a=new ze;return function(l){let h=!0;if(t){let c=t(l);c&&(h=!1),a.setFill(c)}if(i){let c=i(l);c&&(h=!1),a.setStroke(c)}if(n){let c=n(l);c&&(h=!1),a.setText(c)}if(s){let c=s(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function To(r,e,t){let i;if(e+"fill-pattern-src"in r)i=x0(r,e+"fill-",t);else{if(r[e+"fill-color"]==="none")return s=>null;i=rl(r,e+"fill-color",t)}if(!i)return null;let n=new _e;return function(s){let o=i(s);return o===qa?null:(n.setColor(o),n)}}function Co(r,e,t){let i=ft(r,e+"stroke-width",t),n=rl(r,e+"stroke-color",t);if(!i&&!n)return null;let s=rn(r,e+"stroke-line-cap",t),o=rn(r,e+"stroke-line-join",t),a=yp(r,e+"stroke-line-dash",t),l=ft(r,e+"stroke-line-dash-offset",t),h=ft(r,e+"stroke-miter-limit",t),c=ft(r,e+"stroke-offset",t),u=new Te;return function(d){if(n){let f=n(d);if(f===qa)return null;u.setColor(f)}if(i&&u.setWidth(i(d)),s){let f=s(d);if(f!=="butt"&&f!=="round"&&f!=="square")throw new Error("Expected butt, round, or square line cap");u.setLineCap(f)}if(o){let f=o(d);if(f!=="bevel"&&f!=="round"&&f!=="miter")throw new Error("Expected bevel, round, or miter line join");u.setLineJoin(f)}return a&&u.setLineDash(a(d)),l&&u.setLineDashOffset(l(d)),h&&u.setMiterLimit(h(d)),c&&u.setOffset(c(d)),u}}function f0(r,e){let t="text-",i=rn(r,t+"value",e);if(!i)return null;let n=To(r,t,e),s=To(r,t+"background-",e),o=Co(r,t,e),a=Co(r,t+"background-",e),l=rn(r,t+"font",e),h=ft(r,t+"max-angle",e),c=ft(r,t+"offset-x",e),u=ft(r,t+"offset-y",e),d=Xr(r,t+"overflow",e),f=rn(r,t+"placement",e),g=ft(r,t+"repeat",e),m=sl(r,t+"scale",e),p=Xr(r,t+"rotate-with-view",e),_=ft(r,t+"rotation",e),x=rn(r,t+"align",e),y=rn(r,t+"justify",e),E=rn(r,t+"baseline",e),T=Xr(r,t+"keep-upright",e),v=yp(r,t+"padding",e),S=ol(r,t+"declutter-mode"),w=new nn({declutterMode:S});return function(R){if(w.setText(i(R)),n&&w.setFill(n(R)),s&&w.setBackgroundFill(s(R)),o&&w.setStroke(o(R)),a&&w.setBackgroundStroke(a(R)),l&&w.setFont(l(R)),h&&w.setMaxAngle(h(R)),c&&w.setOffsetX(c(R)),u&&w.setOffsetY(u(R)),d&&w.setOverflow(d(R)),f){let b=f(R);if(b!=="point"&&b!=="line")throw new Error("Expected point or line for text-placement");w.setPlacement(b)}if(g&&w.setRepeat(g(R)),m&&w.setScale(m(R)),p&&w.setRotateWithView(p(R)),_&&w.setRotation(_(R)),x){let b=x(R);if(b!=="left"&&b!=="center"&&b!=="right"&&b!=="end"&&b!=="start")throw new Error("Expected left, right, center, start, or end for text-align");w.setTextAlign(b)}if(y){let b=y(R);if(b!=="left"&&b!=="right"&&b!=="center")throw new Error("Expected left, right, or center for text-justify");w.setJustify(b)}if(E){let b=E(R);if(b!=="bottom"&&b!=="top"&&b!=="middle"&&b!=="alphabetic"&&b!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");w.setTextBaseline(b)}return v&&w.setPadding(v(R)),T&&w.setKeepUpright(T(R)),w}}function g0(r,e){return"icon-src"in r?m0(r,e):"shape-points"in r?p0(r,e):"circle-radius"in r?_0(r,e):null}function m0(r,e){let t="icon-",i=t+"src",n=Ep(r[i],i),s=nl(r,t+"anchor",e),o=sl(r,t+"scale",e),a=ft(r,t+"opacity",e),l=nl(r,t+"displacement",e),h=ft(r,t+"rotation",e),c=Xr(r,t+"rotate-with-view",e),u=pp(r,t+"anchor-origin"),d=_p(r,t+"anchor-x-units"),f=_p(r,t+"anchor-y-units"),g=sn(r,t+"color"),m,p=null;g!==void 0&&(Array.isArray(g)&&g.length>0&&typeof g[0]=="string"?p=rl(r,t+"color",e):m=Tp(g,t+"color"));let _=E0(r,t+"cross-origin"),x=T0(r,t+"offset"),y=pp(r,t+"offset-origin"),E=Eu(r,t+"width"),T=Eu(r,t+"height"),v=y0(r,t+"size"),S=ol(r,t+"declutter-mode"),w={src:n,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,crossOrigin:_,offset:x,offsetOrigin:y,height:T,width:E,size:v,declutterMode:S},R=null;return function(b){if(R)p&&R.setColor(p(b));else{let D=p?p(b):m;R=new Eo(D!==void 0?Object.assign({},w,{color:D}):Object.assign({},w))}return a&&R.setOpacity(a(b)),l&&R.setDisplacement(l(b)),h&&R.setRotation(h(b)),c&&R.setRotateWithView(c(b)),o&&R.setScale(o(b)),s&&R.setAnchor(s(b)),R}}function p0(r,e){let t="shape-",i=t+"points",n=t+"radius",s=Cu(r[i],i);if(!(n in r))throw new Error(`Expected a number for ${n}`);let o=ft(r,n,e),a=typeof r[n]=="number"?r[n]:5,l=t+"radius2",h=ft(r,l,e),c=typeof r[l]=="number"?r[l]:void 0,u=To(r,t,e),d=Co(r,t,e),f=sl(r,t+"scale",e),g=nl(r,t+"displacement",e),m=ft(r,t+"rotation",e),p=Xr(r,t+"rotate-with-view",e),_=Eu(r,t+"angle"),x=ol(r,t+"declutter-mode"),y=new il({points:s,radius:a,radius2:c,angle:_,declutterMode:x});return function(E){return o&&y.setRadius(o(E)),h&&y.setRadius2(h(E)),u&&y.setFill(u(E)),d&&y.setStroke(d(E)),g&&y.setDisplacement(g(E)),m&&y.setRotation(m(E)),p&&y.setRotateWithView(p(E)),f&&y.setScale(f(E)),y}}function _0(r,e){let t="circle-",i=To(r,t,e),n=Co(r,t,e),s=ft(r,t+"radius",e),o=sl(r,t+"scale",e),a=nl(r,t+"displacement",e),l=ft(r,t+"rotation",e),h=Xr(r,t+"rotate-with-view",e),c=ol(r,t+"declutter-mode"),u=new Mt({radius:5,declutterMode:c});return function(d){return s&&u.setRadius(s(d)),i&&u.setFill(i(d)),n&&u.setStroke(n(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function sn(r,e){if(!(e in r))return;let t=r[e];return t===void 0?void 0:t}function ft(r,e,t){let i=sn(r,e);if(i===void 0)return;let n=pi(i,N,t);return function(s){return Cu(n(s),e)}}function rn(r,e,t){let i=sn(r,e);if(i===void 0)return null;let n=pi(i,Ne,t);return function(s){return Ep(n(s),e)}}function x0(r,e,t){let i=rn(r,e+"pattern-src",t),n=mp(r,e+"pattern-offset",t),s=mp(r,e+"pattern-size",t),o=rl(r,e+"color",t);return function(a){return{src:i(a),offset:n&&n(a),size:s&&s(a),color:o&&o(a)}}}function Xr(r,e,t){let i=sn(r,e);if(i===void 0)return null;let n=pi(i,Me,t);return function(s){let o=n(s);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${e}`);return o}}function rl(r,e,t){let i=sn(r,e);if(i===void 0)return null;let n=pi(i,pe,t);return function(s){return Tp(n(s),e)}}function yp(r,e,t){let i=sn(r,e);if(i===void 0)return null;if(Array.isArray(i)&&(i.length===0||typeof i[0]!="string")){let s=i.map((o,a)=>{if(typeof o=="number")return()=>o;let l=pi(o,N,t);return function(h){return Cu(l(h),`${e}[${a}]`)}});return function(o){let a=new Array(s.length);for(let l=0;l<s.length;++l)a[l]=s[l](o);return a}}let n=pi(i,at,t);return function(s){return vo(n(s),e)}}function nl(r,e,t){let i=sn(r,e);if(i===void 0)return null;let n=pi(i,at,t);return function(s){let o=vo(n(s),e);if(o.length!==2)throw new Error(`Expected two numbers for ${e}`);return o}}function mp(r,e,t){let i=sn(r,e);if(i===void 0)return null;let n=pi(i,at,t);return function(s){return Cp(n(s),e)}}function sl(r,e,t){let i=sn(r,e);if(i===void 0)return null;let n=pi(i,at|N,t);return function(s){return C0(n(s),e)}}function Eu(r,e){let t=r[e];if(t!==void 0){if(typeof t!="number")throw new Error(`Expected a number for ${e}`);return t}}function y0(r,e){let t=r[e];if(t!==void 0){if(typeof t=="number")return Ee(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 E0(r,e){let t=r[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);return t}}function pp(r,e){let t=r[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 _p(r,e){let t=r[e];if(t!==void 0){if(t!=="pixels"&&t!=="fraction")throw new Error(`Expected pixels or fraction for ${e}`);return t}}function T0(r,e){let t=r[e];if(t!==void 0)return vo(t,e)}function ol(r,e){let t=r[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 vo(r,e){if(!Array.isArray(r))throw new Error(`Expected an array for ${e}`);let t=r.length;for(let i=0;i<t;++i)if(typeof r[i]!="number")throw new Error(`Expected an array of numbers for ${e}`);return r}function Ep(r,e){if(typeof r!="string")throw new Error(`Expected a string for ${e}`);return r}function Cu(r,e){if(typeof r!="number")throw new Error(`Expected a number for ${e}`);return r}function Tp(r,e){if(typeof r=="string")return r;let t=vo(r,e),i=t.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return t}function Cp(r,e){let t=vo(r,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function C0(r,e){return typeof r=="number"?r:Cp(r,e)}var vp={RENDER_ORDER:"renderOrder"},vu=class extends qi{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(vp.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){let i=this.getDeclutter();i in e.declutter||(e.declutter[i]=new tr(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(vp.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?_u:e;let t=v0(e);this.styleFunction_=e===null?void 0:gp(t),this.changed()}setDeclutter(e){this.declutter_=e?String(e):void 0,this.changed()}};function v0(r){if(r===void 0)return _u;if(!r)return null;if(typeof r=="function"||r instanceof ze)return r;if(!Array.isArray(r))return Tu([r]);if(r.length===0)return[];let e=r.length,t=r[0];if(t instanceof ze){let n=new Array(e);for(let s=0;s<e;++s){let o=r[s];if(!(o instanceof ze))throw new Error("Expected a list of style instances");n[s]=o}return n}if("style"in t){let n=new Array(e);for(let s=0;s<e;++s){let o=r[s];if(!("style"in o))throw new Error("Expected a list of rules with a style property");n[s]=o}return xp(n)}return Tu(r)}var Li=vu;var Su=class extends ye{constructor(e,t,i,n){super(e),this.inversePixelTransform=t,this.frameState=i,this.context=n}},Nn=Su;var Ru=class extends Ci{constructor(e){super(),this.map_=e}dispatchRenderEvent(e,t){j()}calculateMatrices2D(e){let t=e.viewState,i=e.coordinateToPixelTransform,n=e.pixelToCoordinateTransform;Ae(i,e.size[0]/2,e.size[1]/2,1/t.resolution,-1/t.resolution,-t.rotation,-t.center[0],-t.center[1]),Yi(n,i)}forEachFeatureAtCoordinate(e,t,i,n,s,o,a,l){let h,c=t.viewState;function u(E,T,v,S){return s.call(o,T,E?v:null,S)}let d=c.projection,f=En(e.slice(),d),g=[[0,0]];if(d.canWrapX()&&n){let E=d.getExtent(),T=z(E);g.push([-T,0],[T,0])}let m=t.layerStatesArray,p=m.length,_=[],x=[];for(let E=0;E<g.length;E++)for(let T=p-1;T>=0;--T){let v=m[T],S=v.layer;if(S.hasRenderer()&&ro(v,c)&&a.call(l,S)){let w=S.getRenderer(),R=S.getSource();if(w&&R){let b=R.getWrapX()?f:e,D=u.bind(null,v.managed);x[0]=b[0]+g[E][0],x[1]=b[1]+g[E][1],h=w.forEachFeatureAtCoordinate(x,t,i,D,_)}if(h)return h}}if(_.length===0)return;let y=1/_.length;return _.forEach((E,T)=>E.distanceSq+=T*y),_.sort((E,T)=>E.distanceSq-T.distanceSq),_.some(E=>h=E.callback(E.feature,E.layer,E.geometry)),h}hasFeatureAtCoordinate(e,t,i,n,s,o){return this.forEachFeatureAtCoordinate(e,t,i,n,xt,this,s,o)!==void 0}getMap(){return this.map_}renderFrame(e){j()}scheduleExpireIconCache(e){Tt.canExpireCache()&&e.postRenderFunctions.push(S0)}};function S0(r,e){Tt.expire()}var Sp=Ru;var wu=class extends Sp{constructor(e){super(e),this.fontChangeListenerKey_=k(rr,He.PROPERTYCHANGE,e.redrawText,e),this.element_=Ze?Ba():document.createElement("div");let t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=et+" ol-layers";let i=e.getViewport();i&&i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(e,t){let i=this.getMap();if(i.hasListener(e)){let n=new Nn(e,void 0,t);i.dispatchEvent(n)}}disposeInternal(){K(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(ve.PRECOMPOSE,e);let t=e.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);t.some(h=>h.layer instanceof Li&&h.layer.getDeclutter())&&(e.declutter={});let n=e.viewState;this.children_.length=0;let s=[],o=null;for(let h=0,c=t.length;h<c;++h){let u=t[h];e.layerIndex=h;let d=u.layer,f=d.getSourceState();if(!ro(u,n)||f!="ready"&&f!="undefined"){d.unrender();continue}let g=d.render(e,o);g&&(g!==o&&(this.children_.push(g),o=g),s.push(u))}this.declutter(e,s),bm(this.element_,this.children_);let l=this.getMap().getTargetElement();if(di(l)){let h=l.getContext("2d");for(let c of this.children_){let u=c.firstElementChild||c,d=c.style.backgroundColor;if(d&&(!di(u)||u.width>0)&&(h.fillStyle=d,h.fillRect(0,0,l.width,l.height)),di(u)&&u.width>0){h.save();let f=c.style.opacity||u.style.opacity;h.globalAlpha=f===""?1:Number(f);let g=u.style.transform;if(g)h.transform(...wa(g));else{let m=parseFloat(u.style.width)/u.width,p=parseFloat(u.style.height)/u.height;h.transform(m,0,0,p,0,0)}h.drawImage(u,0,0),h.restore()}}}this.dispatchRenderEvent(ve.POSTCOMPOSE,e),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(e)}declutter(e,t){if(e.declutter){for(let i=t.length-1;i>=0;--i){let n=t[i],s=n.layer;s.getDeclutter()&&s.renderDeclutter(e,n)}t.forEach(i=>i.layer.renderDeferred(e))}}},Rp=wu;function wp(r){if(r instanceof qi){r.setMapInternal(null);return}r instanceof no&&r.getLayers().forEach(wp)}function Pp(r,e){if(r instanceof qi){r.setMapInternal(e);return}if(r instanceof no){let t=r.getLayers().getArray();for(let i=0,n=t.length;i<n;++i)Pp(t[i],e)}}var Pu=class extends De{constructor(e){super(),e=e||{},this.on,this.once,this.un;let t=R0(e);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=e.maxTilesLoading!==void 0?e.maxTilesLoading:16,this.pixelRatio_=e.pixelRatio!==void 0?e.pixelRatio:_g,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=ae(),this.pixelToCoordinateTransform_=ae(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,Ze||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=e.moveTolerance,this.keyboardEventTarget_=t.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,Ze||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=t.controls||(Ze?new Ce:Im()),this.interactions=t.interactions||(Ze?new Ce:io({onFocusOnly:!0})),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Eg(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Pe.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Pe.VIEW,this.handleViewChanged_),this.addChangeListener(Pe.SIZE,this.handleSizeChanged_),this.addChangeListener(Pe.TARGET,this.handleTargetChanged_),this.setProperties(t.values);let i=this;e.view&&!(e.view instanceof It)&&e.view.then(function(n){i.setView(new It(n))}),this.controls.addEventListener(fe.ADD,n=>{n.element.setMap(this)}),this.controls.addEventListener(fe.REMOVE,n=>{n.element.setMap(null)}),this.interactions.addEventListener(fe.ADD,n=>{n.element.setMap(this)}),this.interactions.addEventListener(fe.REMOVE,n=>{n.element.setMap(null)}),this.overlays_.addEventListener(fe.ADD,n=>{this.addOverlayInternal_(n.element)}),this.overlays_.addEventListener(fe.REMOVE,n=>{let s=n.element.getId();s!==void 0&&delete this.overlayIdIndex_[s.toString()],n.element.setMap(null)}),this.controls.forEach(n=>{n.setMap(this)}),this.interactions.forEach(n=>{n.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){Pp(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){let t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,i){if(!this.frameState_||!this.renderer_)return;let n=this.getCoordinateFromPixelInternal(e);i=i!==void 0?i:{};let s=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:xt,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(n,this.frameState_,s,a,t,null,o,null)}getFeaturesAtPixel(e,t){let i=[];return this.forEachFeatureAtPixel(e,function(n){i.push(n)},t),i}getAllLayers(){let e=[];function t(i){i.forEach(function(n){n instanceof no?t(n.getLayers()):e.push(n)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;let i=this.getCoordinateFromPixelInternal(e);t=t!==void 0?t:{};let n=t.layerFilter!==void 0?t.layerFilter:xt,s=t.hitTolerance!==void 0?t.hitTolerance:0,o=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,s,o,n,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){let i=this.viewport_.getBoundingClientRect(),n=this.getSize(),s=i.width/n[0],o=i.height/n[1],a="changedTouches"in e?e.changedTouches[0]:e;return[(a.clientX-i.left)/s,(a.clientY-i.top)/o]}getTarget(){return this.get(Pe.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return ni(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){let t=this.frameState_;return t?le(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){let t=this.overlayIdIndex_[e.toString()];return t!==void 0?t:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Pe.LAYERGROUP)}setLayers(e){let t=this.getLayerGroup();if(e instanceof Ce){t.setLayers(e);return}let i=t.getLayers();i.clear(),i.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){let e=this.getLayerGroup().getLayerStatesArray();for(let t=0,i=e.length;t<i;++t){let n=e[t];if(!n.visible)continue;let s=n.layer.getRenderer();if(s&&!s.ready)return!0;let o=n.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(e){let t=ce(e,this.getView().getProjection());return this.getPixelFromCoordinateInternal(t)}getPixelFromCoordinateInternal(e){let t=this.frameState_;return t?le(t.coordinateToPixelTransform,e.slice(0,2)):null}getPixelRatio(){return this.pixelRatio_}setPixelRatio(e){this.pixelRatio_!==e&&(this.pixelRatio_=e,this.render())}getRenderer(){return this.renderer_}getSize(){return this.get(Pe.SIZE)}getView(){return this.get(Pe.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){let e=this.getTargetElement();return e?e.ownerDocument:document}getTilePriority(e,t,i,n){return Tg(this.frameState_,e,t,i,n)}handleBrowserEvent(e,t){t=t||e.type;let i=new Qt(t,this,e);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(e){if(!this.frameState_)return;let t=e.originalEvent,i=t.type;if(i===kt.POINTERDOWN||i===L.WHEEL||i===L.KEYDOWN){let n=this.getOwnerDocument(),s=this.viewport_.getRootNode?this.viewport_.getRootNode():n,o=t.target,a=s instanceof ShadowRoot?s.host===o?s.host.ownerDocument:s:s===n?n.documentElement:s;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(e.frameState=this.frameState_,this.dispatchEvent(e)!==!1){let n=this.getInteractions().getArray().slice();for(let s=n.length-1;s>=0;s--){let o=n[s];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(e)||e.propagationStopped)break}}}handlePostRender(){let e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let n=this.maxTilesLoading_,s=n;if(e){let o=e.viewHints;if(o[he.ANIMATING]||o[he.INTERACTING]){let a=Date.now()-e.time>8;n=a?0:8,s=a?0:2}}t.getTilesLoading()<n&&(t.reprioritize(),t.loadMoreTiles(n,s))}e&&this.renderer_&&!e.animate&&(this.renderComplete_?(this.hasListener(ve.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(ve.RENDERCOMPLETE,e),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new xn(Nt.LOADEND,this,e)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new xn(Nt.LOADSTART,this,e))));let i=this.postRenderFunctions_;if(e)for(let n=0,s=i.length;n<s;++n)i[n](this,e);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,n=this.targetChangeHandlerKeys_.length;i<n;++i)K(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(L.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(L.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!di(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);let i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}let e=this.getTarget(),t=typeof e=="string"?document.getElementById(e):e;if(this.targetElement_=t,!t)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{if(di(t)||t.appendChild(this.viewport_),this.renderer_||(this.renderer_=new Rp(this)),!di(t)){this.mapBrowserEventHandler_=new xg(this,this.moveTolerance_);for(let n in ee)this.mapBrowserEventHandler_.addEventListener(ee[n],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(L.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(L.WHEEL,this.boundHandleBrowserEvent_,ra?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{let n=t.getRootNode();i=n instanceof ShadowRoot?n.host:t}if(this.targetChangeHandlerKeys_=[k(i,L.KEYDOWN,this.handleBrowserEvent,this),k(i,L.KEYPRESS,this.handleBrowserEvent,this)],t instanceof HTMLElement){let n=t.getRootNode();n instanceof ShadowRoot&&this.resizeObserver_.observe(n.host),this.resizeObserver_?.observe(t)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(K(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(K(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);let e=this.getView();e&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=k(e,He.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=k(e,L.CHANGE,this.handleViewPropertyChanged_,this),e.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(K),this.layerGroupPropertyListenerKeys_=null);let e=this.getLayerGroup();e&&(this.handleLayerAdd_(new fi("addlayer",e)),this.layerGroupPropertyListenerKeys_=[k(e,He.PROPERTYCHANGE,this.render,this),k(e,L.CHANGE,this.render,this),k(e,"addlayer",this.handleLayerAdd_,this),k(e,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;let e=this.frameState_.layerStatesArray;for(let t=0,i=e.length;t<i;++t){let n=e[t].layer;n.hasRenderer()&&n.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(e){return this.getControls().remove(e)}removeInteraction(e){return this.getInteractions().remove(e)}removeLayer(e){return this.getLayerGroup().getLayers().remove(e)}handleLayerRemove_(e){wp(e.layer)}removeOverlay(e){return this.getOverlays().remove(e)}renderFrame_(e){let t=this.getSize(),i=this.getView(),n=this.frameState_,s=null;if(t!==void 0&&eu(t)&&i&&i.isDef()){let o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(s={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:Vi(a.center,a.resolution,a.rotation,t),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:t,tileQueue:this.tileQueue_,time:e,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:P(this),renderTargets:{}},a.nextCenter&&a.nextResolution){let l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;s.nextExtent=Vi(a.nextCenter,a.nextResolution,l,t)}}this.frameState_=s,this.renderer_.renderFrame(s),s&&(s.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,s.postRenderFunctions),n&&(!this.previousExtent_||!yt(this.previousExtent_)&&!qe(s.extent,this.previousExtent_))&&(this.dispatchEvent(new xn(Nt.MOVESTART,this,n)),this.previousExtent_=zi(this.previousExtent_)),this.previousExtent_&&!s.viewHints[he.ANIMATING]&&!s.viewHints[he.INTERACTING]&&!qe(s.extent,this.previousExtent_)&&(this.dispatchEvent(new xn(Nt.MOVEEND,this,s)),la(s.extent,this.previousExtent_))),this.dispatchEvent(new xn(Nt.POSTRENDER,this,s)),this.renderComplete_=(this.hasListener(Nt.LOADSTART)||this.hasListener(Nt.LOADEND)||this.hasListener(ve.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(e){let t=this.getLayerGroup();t&&this.handleLayerRemove_(new fi("removelayer",t)),this.set(Pe.LAYERGROUP,e)}setSize(e){this.set(Pe.SIZE,e)}setTarget(e){this.set(Pe.TARGET,e)}setView(e){if(!e||e instanceof It){this.set(Pe.VIEW,e);return}this.set(Pe.VIEW,new It);let t=this;e.then(function(i){t.setView(new It(i))})}updateSize(){let e=this.getTargetElement(),t;if(e){let n,s;if(di(e)){let o=e.getContext("2d").getTransform();n=e.width/o.a,s=e.height/o.d}else{let o=getComputedStyle(e);n=e.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),s=e.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(n)&&!isNaN(s)&&(t=[Math.max(0,n),Math.max(0,s)],!eu(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&_a("No map visible because the map container's width or height are 0."))}let i=this.getSize();t&&(!i||!Ve(t,i))&&(this.setSize(t),this.updateViewportSize_(t))}updateViewportSize_(e){let t=this.getView();t&&t.setViewportSize(e)}};function R0(r){let e=null;r.keyboardEventTarget!==void 0&&(e=typeof r.keyboardEventTarget=="string"?document.getElementById(r.keyboardEventTarget):r.keyboardEventTarget);let t={},i=r.layers&&typeof r.layers.getLayers=="function"?r.layers:new no({layers:r.layers});t[Pe.LAYERGROUP]=i,t[Pe.TARGET]=r.target,t[Pe.VIEW]=r.view instanceof It?r.view:new It;let n;r.controls!==void 0&&(Array.isArray(r.controls)?n=new Ce(r.controls.slice()):(W(typeof r.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),n=r.controls));let s;r.interactions!==void 0&&(Array.isArray(r.interactions)?s=new Ce(r.interactions.slice()):(W(typeof r.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),s=r.interactions));let o;return r.overlays!==void 0?Array.isArray(r.overlays)?o=new Ce(r.overlays.slice()):(W(typeof r.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=r.overlays):o=new Ce,{controls:n,interactions:s,keyboardEventTarget:e,overlays:o,values:t}}var al=Pu;var Lu=class extends vi{constructor(e,t,i){super(),i=i||{},this.tileCoord=e,this.state=t,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(L.CHANGE)}release(){this.setState(F.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==F.EMPTY){if(this.state!==F.ERROR&&this.state>e)throw new Error("Tile load sequence violation");this.state=e,this.changed()}}load(){j()}getAlpha(e,t){if(!this.transition_)return 1;let i=this.transitionStarts_[e];if(!i)i=t,this.transitionStarts_[e]=i;else if(i===-1)return 1;let n=t-i+1e3/60;return n>=this.transition_?1:zh(n/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}disposeInternal(){this.release(),super.disposeInternal()}},bi=Lu;function ll(r){return r instanceof Image||r instanceof HTMLCanvasElement||r instanceof HTMLVideoElement||r instanceof ImageBitmap?r:null}var w0=new Error("disposed");var P0=[256,256],bu=class extends bi{constructor(e){let t=F.IDLE;super(e.tileCoord,t,{transition:e.transition,interpolate:e.interpolate}),this.loader_=e.loader,this.data_=null,this.error_=null,this.size_=e.size||null,this.controller_=e.controller||null}getSize(){if(this.size_)return this.size_;let e=ll(this.data_);return e?[e.width,e.height]:P0}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==F.IDLE&&this.state!==F.ERROR)return;this.state=F.LOADING,this.changed();let e=this;this.loader_().then(function(t){e.data_=t,e.state=F.LOADED,e.changed()}).catch(function(t){e.error_=t,e.state=F.ERROR,e.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(w0),this.controller_=null),super.disposeInternal()}},Iu=bu;var Fu=class extends bi{constructor(e,t,i,n,s,o){super(e,t,o),this.crossOrigin_=n?.crossOrigin,this.referrerPolicy_=n?.referrerPolicy,this.src_=i,this.key=i,this.image_,Ze?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=s}getImage(){return this.image_}setImage(e){this.image_=e,this.state=F.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=F.ERROR,this.unlistenImage_(),this.image_=L0(),this.changed()}handleImageLoad_(){if(Ze)this.state=F.LOADED;else{let e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=F.LOADED:this.state=F.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==F.ERROR&&(this.state=F.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==F.IDLE&&(this.state=F.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=np(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}};function L0(){let r=ne(1,1);return r.fillStyle="rgba(0,0,0,0)",r.fillRect(0,0,1,1),r.canvas}var hl=Fu;var cl=class{constructor(e,t,i,n){this.minX=e,this.maxX=t,this.minY=i,this.maxY=n}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minX<this.minX&&(this.minX=e.minX),e.maxX>this.maxX&&(this.maxX=e.maxX),e.minY<this.minY&&(this.minY=e.minY),e.maxY>this.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}};function or(r,e,t,i,n){return n!==void 0?(n.minX=r,n.maxX=e,n.minY=t,n.maxY=i,n):new cl(r,e,t,i)}var ul=cl;var Mu,ar=[];function Lp(r,e,t,i,n){r.beginPath(),r.moveTo(0,0),r.lineTo(e,t),r.lineTo(i,n),r.closePath(),r.save(),r.clip(),r.fillRect(0,0,Math.max(e,i)+1,Math.max(t,n)),r.restore()}function Au(r,e){return Math.abs(r[e*4]-210)>2||Math.abs(r[e*4+3]-.75*255)>2}function b0(){if(Mu===void 0){let r=ne(6,6,ar);r.globalCompositeOperation="lighter",r.fillStyle="rgba(210, 0, 0, 0.75)",Lp(r,4,5,4,0),Lp(r,4,5,0,5);let e=r.getImageData(0,0,3,3).data;Mu=Au(e,0)||Au(e,4)||Au(e,8),$i(r),ar.push(r.canvas)}return Mu}function Gn(r,e,t,i){let n=ii(t,e,r),s=Pr(e,i,t),o=e.getMetersPerUnit();o!==void 0&&(s*=o);let a=r.getMetersPerUnit();a!==void 0&&(s/=a);let l=r.getExtent();if(!l||rt(l,n)){let h=Pr(r,s,n)/s;isFinite(h)&&h>0&&(s/=h)}return s}function bp(r,e,t,i){let n=be(t),s=Gn(r,e,n,i);return(!isFinite(s)||s<=0)&&Er(t,function(o){return s=Gn(r,e,o,i),isFinite(s)&&s>0}),s}function dl(r,e,t,i,n,s,o,a,l,h,c,u,d,f){let g=ne(Math.round(t*r),Math.round(t*e),ar);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(t,t);function m(T){return Math.round(T*t)/t}g.globalCompositeOperation="lighter";let p=me();l.forEach(function(T,v,S){ha(p,T.extent)});let _,x=t/i,y=(u?1:1+Math.pow(2,-24))/x;if(!d||l.length!==1||h!==0){if(_=ne(Math.round(z(p)*x),Math.round(re(p)*x),ar),u||(_.imageSmoothingEnabled=!1),n&&f){let T=(n[0]-p[0])*x,v=-(n[3]-p[3])*x,S=z(n)*x,w=re(n)*x;_.rect(T,v,S,w),_.clip()}l.forEach(function(T,v,S){if(T.image.width>0&&T.image.height>0){if(T.clipExtent){_.save();let G=(T.clipExtent[0]-p[0])*x,O=-(T.clipExtent[3]-p[3])*x,X=z(T.clipExtent)*x,Q=re(T.clipExtent)*x;_.rect(u?G:Math.round(G),u?O:Math.round(O),u?X:Math.round(G+X)-Math.round(G),u?Q:Math.round(O+Q)-Math.round(O)),_.clip()}let w=(T.extent[0]-p[0])*x,R=-(T.extent[3]-p[3])*x,b=z(T.extent)*x,D=re(T.extent)*x;_.drawImage(T.image,h,h,T.image.width-2*h,T.image.height-2*h,u?w:Math.round(w),u?R:Math.round(R),u?b:Math.round(w+b)-Math.round(w),u?D:Math.round(R+D)-Math.round(R)),T.clipExtent&&_.restore()}})}let E=Je(o);return a.getTriangles().forEach(function(T,v,S){let w=T.source,R=T.target,b=w[0][0],D=w[0][1],G=w[1][0],O=w[1][1],X=w[2][0],Q=w[2][1],M=m((R[0][0]-E[0])/s),Y=m(-(R[0][1]-E[1])/s),U=m((R[1][0]-E[0])/s),q=m(-(R[1][1]-E[1])/s),H=m((R[2][0]-E[0])/s),oe=m(-(R[2][1]-E[1])/s),de=b,xe=D;b=0,D=0,G-=de,O-=xe,X-=de,Q-=xe;let St=[[G,O,0,0,U-M],[X,Q,0,0,H-M],[0,0,G,O,q-Y],[0,0,X,Q,oe-Y]],I=Cg(St);if(!I)return;if(g.save(),g.beginPath(),b0()||!u){g.moveTo(U,q);let nt=4,ai=M-U,xi=Y-q;for(let Ht=0;Ht<nt;Ht++)g.lineTo(U+m((Ht+1)*ai/nt),q+m(Ht*xi/(nt-1))),Ht!=nt-1&&g.lineTo(U+m((Ht+1)*ai/nt),q+m((Ht+1)*xi/(nt-1)));g.lineTo(H,oe)}else g.moveTo(U,q),g.lineTo(M,Y),g.lineTo(H,oe);g.clip(),g.transform(I[0],I[2],I[1],I[3],M,Y),g.translate(p[0]-de,p[3]-xe);let Kt;if(_)Kt=_.canvas,g.scale(y,-y);else{let nt=l[0],ai=nt.extent;Kt=nt.image,g.scale(z(ai)/Kt.width,-re(ai)/Kt.height)}g.drawImage(Kt,0,0),g.restore()}),_&&($i(_),ar.push(_.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(T,v,S){let w=T.target,R=(w[0][0]-E[0])/s,b=-(w[0][1]-E[1])/s,D=(w[1][0]-E[0])/s,G=-(w[1][1]-E[1])/s,O=(w[2][0]-E[0])/s,X=-(w[2][1]-E[1])/s;g.beginPath(),g.moveTo(D,G),g.lineTo(R,b),g.lineTo(O,X),g.closePath(),g.stroke()}),g.restore()),g.canvas}var I0=10,Ip=.25,Ou=class{constructor(e,t,i,n,s,o,a){this.sourceProj_=e,this.targetProj_=t;let l={},h=a?tm(y=>le(a,ii(y,this.targetProj_,this.sourceProj_))):ct(this.targetProj_,this.sourceProj_);this.transformInv_=function(y){let E=y[0]+"/"+y[1];return l[E]||(l[E]=h(y)),l[E]},this.maxSourceExtent_=n,this.errorThresholdSquared_=s*s,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&z(n)>=z(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?z(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?z(this.targetProj_.getExtent()):null;let c=Je(i),u=Kn(i),d=ji(i),f=$n(i),g=this.transformInv_(c),m=this.transformInv_(u),p=this.transformInv_(d),_=this.transformInv_(f),x=I0+(o?Math.max(0,Math.ceil(Math.log2(Fs(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,m,p,_,x),this.wrapsXInSource_){let y=1/0;this.triangles_.forEach(function(E,T,v){y=Math.min(y,E.source[0][0],E.source[1][0],E.source[2][0])}),this.triangles_.forEach(E=>{if(Math.max(E.source[0][0],E.source[1][0],E.source[2][0])-y>this.sourceWorldWidth_/2){let T=[[E.source[0][0],E.source[0][1]],[E.source[1][0],E.source[1][1]],[E.source[2][0],E.source[2][1]]];T[0][0]-y>this.sourceWorldWidth_/2&&(T[0][0]-=this.sourceWorldWidth_),T[1][0]-y>this.sourceWorldWidth_/2&&(T[1][0]-=this.sourceWorldWidth_),T[2][0]-y>this.sourceWorldWidth_/2&&(T[2][0]-=this.sourceWorldWidth_);let v=Math.min(T[0][0],T[1][0],T[2][0]);Math.max(T[0][0],T[1][0],T[2][0])-v<this.sourceWorldWidth_/2&&(E.source=T)}})}l={}}addTriangle_(e,t,i,n,s,o){this.triangles_.push({source:[n,s,o],target:[e,t,i]})}addQuad_(e,t,i,n,s,o,a,l,h){let c=Re([s,o,a,l]),u=this.sourceWorldWidth_?z(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1,g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){let p=Re([e,t,i,n]);g=z(p)/this.targetWorldWidth_>Ip||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>Ip||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!te(c,this.maxSourceExtent_))return;let m=0;if(!g&&(!isFinite(s[0])||!isFinite(s[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(h>0)g=!0;else if(m=(!isFinite(s[0])||!isFinite(s[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),m!=1&&m!=2&&m!=4&&m!=8)return}if(h>0){if(!g){let p=[(e[0]+i[0])/2,(e[1]+i[1])/2],_=this.transformInv_(p),x;f?x=(lt(s[0],d)+lt(a[0],d))/2-lt(_[0],d):x=(s[0]+a[0])/2-_[0];let y=(s[1]+a[1])/2-_[1];g=x*x+y*y>this.errorThresholdSquared_}if(g){if(Math.abs(e[0]-i[0])<=Math.abs(e[1]-i[1])){let p=[(t[0]+i[0])/2,(t[1]+i[1])/2],_=this.transformInv_(p),x=[(n[0]+e[0])/2,(n[1]+e[1])/2],y=this.transformInv_(x);this.addQuad_(e,t,p,x,s,o,_,y,h-1),this.addQuad_(x,p,i,n,y,_,a,l,h-1)}else{let p=[(e[0]+t[0])/2,(e[1]+t[1])/2],_=this.transformInv_(p),x=[(i[0]+n[0])/2,(i[1]+n[1])/2],y=this.transformInv_(x);this.addQuad_(e,p,x,n,s,_,y,l,h-1),this.addQuad_(p,t,i,x,_,o,a,y,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(e,i,n,s,a,l),(m&14)==0&&this.addTriangle_(e,i,t,s,a,o),m&&((m&13)==0&&this.addTriangle_(t,n,e,o,l,s),(m&7)==0&&this.addTriangle_(t,n,i,o,l,a))}calculateSourceExtent(){let e=me();return this.triangles_.forEach(function(t,i,n){let s=t.source;Yn(e,s[0]),Yn(e,s[1]),Yn(e,s[2])}),e}getTriangles(){return this.triangles_}},fl=Ou;var Du=class extends bi{constructor(e,t,i,n,s,o,a,l,h,c,u,d){super(s,F.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=t,this.targetTileGrid_=n,this.wrappedTileCoord_=o||s,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=e.canWrapX()?e.getExtent():void 0;let f=n.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent(),m=this.sourceTileGrid_.getExtent(),p=g?Xe(f,g):f;if(Fs(p)===0){this.state=F.EMPTY;return}let _=e.getExtent();_&&(m?m=Xe(m,_):m=_);let x=n.getResolution(this.wrappedTileCoord_[0]),y=bp(e,i,p,x);if(!isFinite(y)||y<=0){this.state=F.EMPTY;return}let E=c!==void 0?c:.5;if(this.triangulation_=new fl(e,i,p,m,y*E,x),this.triangulation_.getTriangles().length===0){this.state=F.EMPTY;return}this.sourceZ_=t.getZForResolution(y);let T=this.triangulation_.calculateSourceExtent();if(m&&(e.canWrapX()?(T[1]=B(T[1],m[1],m[3]),T[3]=B(T[3],m[1],m[3])):T=Xe(T,m)),!Fs(T))this.state=F.EMPTY;else{let v=0,S=0;e.canWrapX()&&(v=z(_),S=Math.floor((T[0]-_[0])/v)),ca(T.slice(),e,!0).forEach(R=>{let b=t.getTileRangeForExtentAndZ(R,this.sourceZ_);for(let D=b.minX;D<=b.maxX;D++)for(let G=b.minY;G<=b.maxY;G++){let O=S*v;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,D,G,a),offset:O})}++S}),this.sourceTiles_.length===0&&(this.state=F.EMPTY)}}getImage(){return this.canvas_}reproject_(){let e=[];if(this.sourceTiles_.forEach(t=>{let i=t.tile;if(i&&i.getState()==F.LOADED){let n=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);n[0]+=t.offset,n[2]+=t.offset;let s=this.clipExtent_?.slice();s&&(s[0]+=t.offset,s[2]+=t.offset),e.push({extent:n,clipExtent:s,image:i.getImage()})}}),this.sourceTiles_.length=0,e.length===0)this.state=F.ERROR;else{let t=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(t),n=typeof i=="number"?i:i[0],s=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=dl(n,s,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=F.LOADED}this.changed()}load(){for(let e of this.sourceTiles_)e.tile=e.getTile();if(this.state==F.IDLE){this.state=F.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:t})=>{let i=t.getState();if(i==F.IDLE||i==F.LOADING){e++;let n=k(t,L.CHANGE,s=>{let o=t.getState();(o==F.LOADED||o==F.ERROR||o==F.EMPTY)&&(K(n),e--,e===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},i,n){t.getState()==F.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(K),this.sourcesListenerKeys_=null}release(){this.canvas_&&($i(this.canvas_.getContext("2d")),ar.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},gl=Du;var ku=class{constructor(e){this.highWaterMark=e!==void 0?e:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){let e=this.pop();e instanceof Ci&&e.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){let i=this.entries_[e];return W(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(e){let t=this.entries_[e];return W(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){let e=new Array(this.count_),t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.key_;return e}getValues(){let e=new Array(this.count_),t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){return this.entries_[e]?.value_}pop(){let e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){W(!(e in this.entries_),"Tried to set a value for a key that is used already");let i={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[e]=i,++this.count_}setSize(e){this.highWaterMark=e}},Nu=ku;function Yr(r,e,t,i){return i!==void 0?(i[0]=r,i[1]=e,i[2]=t,i):[r,e,t]}function M0(r,e,t){return r+"/"+e+"/"+t}function $r(r,e,t,i,n){return`${P(r)},${e},${M0(t,i,n)}`}function ml(r){return A0(r[0],r[1],r[2])}function A0(r,e,t){return(e<<r)+t}function Fp(r,e){let t=r[0],i=r[1],n=r[2];if(e.getMinZoom()>t||t>e.getMaxZoom())return!1;let s=e.getFullTileRange(t);return s?s.containsXY(i,n):!0}var Gu=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Dr(),{get:(e,t)=>{if(typeof Dr()[t]=="function")return this.push_(t),this.pushMethodArgs_},set:(e,t,i)=>(this.push_(t,i),!0)})}push_(...e){let t=this.instructions_,i=this.zIndex+this.offset_;t[i]||(t[i]=[]),t[i].push(...e)}pushMethodArgs_=(...e)=>(this.push_(e),this);pushFunction(e){this.push_(e)}getContext(){return this.context_}draw(e){this.instructions_.forEach(t=>{for(let i=0,n=t.length;i<n;++i){let s=t[i];if(typeof s=="function"){s(e);continue}let o=t[++i];if(typeof e[s]=="function")e[s](...o);else{if(typeof o=="function"){e[s]=o(e);continue}e[s]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},Kr=Gu;var O0=5,Uu=class extends ta{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.staleKeys_=new Array,this.maxStaleKeys=O0}getStaleKeys(){return this.staleKeys_}prependStaleKey(e){this.staleKeys_.unshift(e),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return j()}getData(e){return null}prepareFrame(e){return j()}renderFrame(e,t){return j()}forEachFeatureAtCoordinate(e,t,i,n,s){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){let t=e.target;(t.getState()===A.LOADED||t.getState()===A.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=A.LOADED&&t!=A.ERROR&&e.addEventListener(L.CHANGE,this.boundHandleImageChange_),t==A.IDLE&&(e.load(),t=e.getState()),t==A.LOADED}renderIfReadyAndVisible(){let e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}},pl=Uu;var zu=[],Hr=null;function D0(){Hr=ne(1,1,void 0,{willReadFrequently:!0})}var Bu=class extends pl{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=ae(),this.pixelTransform=ae(),this.inversePixelTransform=ae(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,t,i){Hr||D0(),Hr.clearRect(0,0,1,1);let n;try{Hr.drawImage(e,t,i,1,1,0,0,1,1),n=Hr.getImageData(0,0,1,1).data}catch{return Hr=null,null}return n}getBackground(e){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(e.viewState.resolution)),i||void 0}useContainer(e,t,i){let n=this.getLayer().getClassName(),s,o;if(e&&e.className===n&&(!i||e&&e.style.backgroundColor&&Ve(tt(e.style.backgroundColor),tt(i)))){let a=e.firstElementChild;di(a)&&(o=a.getContext("2d"))}if(o&&rm(o.canvas.style.transform,t)?(this.container=e,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){s=Ze?Ba():document.createElement("div"),s.className=n;let a=s.style;a.position="absolute",a.width="100%",a.height="100%",o=ne();let l=o.canvas;s.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=s,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(e,t,i){let n=Je(i),s=Kn(i),o=ji(i),a=$n(i);le(t.coordinateToPixelTransform,n),le(t.coordinateToPixelTransform,s),le(t.coordinateToPixelTransform,o),le(t.coordinateToPixelTransform,a);let l=this.inversePixelTransform;le(l,n),le(l,s),le(l,o),le(l,a),e.save(),e.beginPath(),e.moveTo(Math.round(n[0]),Math.round(n[1])),e.lineTo(Math.round(s[0]),Math.round(s[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(a[0]),Math.round(a[1])),e.clip()}prepareContainer(e,t){let i=e.extent,n=e.viewState.resolution,s=e.viewState.rotation,o=e.pixelRatio,a=Math.round(z(i)/n*o),l=Math.round(re(i)/n*o);Ae(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/o,1/o,s,-a/2,-l/2),Yi(this.inversePixelTransform,this.pixelTransform);let h=nm(this.pixelTransform);if(this.useContainer(t,h,this.getBackground(e)),!this.containerReused){let c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(e,t,i){let n=this.getLayer();if(n.hasListener(e)){let s=new Nn(e,this.inversePixelTransform,i,t);n.dispatchEvent(s)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(ve.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(ve.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new Kr),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(ve.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(ve.POSTRENDER,this.context,e))}getRenderTransform(e,t,i,n,s,o,a){let l=s/2,h=o/2,c=n/t,u=-c,d=-e[0]+a,f=-e[1];return Ae(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}},Zr=Bu;function ju(r,e,t){if(!(t in r))return r[t]=new Set([e]),!0;let i=r[t],n=i.has(e);return n||i.add(e),!n}function k0(r,e,t){let i=r[t];return i?i.delete(e):!1}function Mp(r,e){let t=r.layerStatesArray[r.layerIndex];t.extent&&(e=Xe(e,Be(t.extent,r.viewState.projection)));let i=t.layer.getRenderSource();if(!i.getWrapX()){let n=i.getTileGridForProjection(r.viewState.projection).getExtent();n&&(e=Xe(e,n))}return e}var Vu=class extends Zr{constructor(e,t){super(e),t=t||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=me(),this.tempTileRange_=new ul(0,0,0,0),this.tempTileCoord_=Yr(0,0,0);let i=t.cacheSize!==void 0?t.cacheSize:512;this.tileCache_=new Nu(i),this.sourceTileCache_=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new Nu(512)),this.sourceTileCache_}getOrCreateTile(e,t,i,n){let s=this.tileCache_,a=this.getLayer().getSource(),l=$r(a,a.getKey(),e,t,i),h;if(s.containsKey(l))h=s.get(l);else{let c=n.viewState.projection,u=a.getProjection();if(h=a.getTile(e,t,i,n.pixelRatio,c,!u||Ie(u,c)?void 0:this.getSourceTileCache()),!h)return null;s.set(l,h)}return h}getTile(e,t,i,n){let s=this.getOrCreateTile(e,t,i,n);return s||null}getData(e){let t=this.frameState;if(!t)return null;let i=this.getLayer(),n=le(t.pixelToCoordinateTransform,e.slice()),s=i.getExtent();if(s&&!rt(s,n))return null;let o=t.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(t.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){let u=l.getTileCoordForCoordAndZ(n,c),d=this.getTile(c,u[1],u[2],t);if(!d||d.getState()!==F.LOADED)continue;let f=l.getOrigin(c),g=Ee(l.getTileSize(c)),m=l.getResolution(c),p;if(d instanceof hl||d instanceof gl)p=d.getImage();else if(d instanceof Iu){if(p=ll(d.getData()),!p)continue}else continue;let _=Math.floor(h*((n[0]-f[0])/m-u[1]*g[0])),x=Math.floor(h*((f[1]-n[1])/m-u[2]*g[1])),y=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(p,_+y,x+y)}return null}prepareFrame(e){this.renderedProjection?e.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=e.viewState.projection):this.renderedProjection=e.viewState.projection;let t=this.getLayer().getSource();if(!t)return!1;let i=t.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===t.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(e,t,i,n,s){let o=e.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=P(l);c in e.wantedTiles||(e.wantedTiles[c]={});let u=e.wantedTiles[c],d=a.getMapInternal(),f=Math.max(i-s,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,m=g?Gh(o.center,o.resolution,g,e.size):void 0;for(let p=i;p>=f;--p){let _=h.getTileRangeForExtentAndZ(t,p,this.tempTileRange_),x=h.getResolution(p);for(let y=_.minX;y<=_.maxX;++y)for(let E=_.minY;E<=_.maxY;++E){if(g&&!h.tileCoordIntersectsViewport([p,y,E],m))continue;let T=this.getTile(p,y,E,e);if(!T||!ju(n,T,p))continue;let S=T.getKey();if(u[S]=!0,T.getState()===F.IDLE&&!e.tileQueue.isKeyQueued(S)){let w=Yr(p,y,E,this.tempTileCoord_);e.tileQueue.enqueue([T,c,h.getTileCoordCenter(w),x])}}}}findStaleTile_(e,t){let i=this.tileCache_,n=e[0],s=e[1],o=e[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){let h=$r(this.getLayer().getSource(),a[l],n,s,o);if(i.containsKey(h)){let c=i.peek(h);if(c.getState()===F.LOADED)return c.endTransition(P(this)),ju(t,c,n),!0}}return!1}findAltTiles_(e,t,i,n){let s=e.getTileRangeForTileCoordAndZ(t,i,this.tempTileRange_);if(!s)return!1;let o=!0,a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=s.minX;c<=s.maxX;++c)for(let u=s.minY;u<=s.maxY;++u){let d=$r(l,h,i,c,u),f=!1;if(a.containsKey(d)){let g=a.peek(d);g.getState()===F.LOADED&&(ju(n,g,i),f=!0)}f||(o=!1)}return o}renderFrame(e,t){this.renderComplete=!0;let i=e.layerStatesArray[e.layerIndex],n=e.viewState,s=n.projection,o=n.resolution,a=n.center,l=e.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(s),d=u.getZForResolution(o,c.zDirection),f=u.getResolution(d),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let m=e.extent,p=c.getTilePixelRatio(l);this.prepareContainer(e,t);let _=this.context.canvas.width,x=this.context.canvas.height,y=i.extent&&Be(i.extent,s);y&&(m=Xe(m,Be(i.extent,s)));let E=f*_/2/p,T=f*x/2/p,v=[a[0]-E,a[1]-T,a[0]+E,a[1]+T],S={};this.renderedTiles.length=0;let w=h.getPreload();if(e.nextExtent&&this.enqueueTilesForNextExtent()){let U=u.getZForResolution(n.nextResolution,c.zDirection),q=Mp(e,e.nextExtent);this.enqueueTiles(e,q,U,S,w)}let R=Mp(e,m);if(this.enqueueTiles(e,R,d,S,0),w>0&&setTimeout(()=>{this.enqueueTiles(e,R,d-1,S,w-1)},0),!(d in S))return this.container;let b=P(this),D=e.time;for(let U of S[d]){let q=U.getState();if(q===F.EMPTY)continue;let H=U.tileCoord;if(q===F.LOADED&&U.getAlpha(b,D)===1){U.endTransition(b);continue}if(q!==F.ERROR&&(this.renderComplete=!1),this.findStaleTile_(H,S)){k0(S,U,d),e.animate=!0;continue}if(this.findAltTiles_(u,H,d+1,S))continue;let xe=u.getMinZoom();for(let St=d-1;St>=xe&&!this.findAltTiles_(u,H,St,S);--St);}let G=f/o*l/p,O=this.getRenderContext(e);Ae(this.tempTransform,_/2,x/2,G,G,0,-_/2,-x/2),i.extent&&this.clipUnrotated(O,e,y),c.getInterpolate()||(O.imageSmoothingEnabled=!1),this.preRender(O,e);let X=Object.keys(S).map(Number);X.sort(_t);let Q,M=[],Y=[];for(let U=X.length-1;U>=0;--U){let q=X[U],H=c.getTilePixelSize(q,l,s),de=u.getResolution(q)/f,xe=H[0]*de*G,St=H[1]*de*G,I=u.getTileCoordForCoordAndZ(Je(v),q),Kt=u.getTileCoordExtent(I),nt=le(this.tempTransform,[p*(Kt[0]-v[0])/f,p*(v[3]-Kt[3])/f]),ai=p*c.getGutterForProjection(s);for(let xi of S[q]){if(xi.getState()!==F.LOADED)continue;let Ht=xi.tileCoord,Ts=I[1]-Ht[1],$o=Math.round(nt[0]-(Ts-1)*xe),Cs=I[2]-Ht[2],_h=Math.round(nt[1]-(Cs-1)*St),yi=Math.round(nt[0]-Ts*xe),li=Math.round(nt[1]-Cs*St),Ei=$o-yi,mn=_h-li,Ko=X.length===1,vs=!1;Q=[yi,li,yi+Ei,li,yi+Ei,li+mn,yi,li+mn];for(let pr=0,Ho=M.length;pr<Ho;++pr)if(!Ko&&q<Y[pr]){let pt=M[pr];te([yi,li,yi+Ei,li+mn],[pt[0],pt[3],pt[4],pt[7]])&&(vs||(O.save(),vs=!0),O.beginPath(),O.moveTo(Q[0],Q[1]),O.lineTo(Q[2],Q[3]),O.lineTo(Q[4],Q[5]),O.lineTo(Q[6],Q[7]),O.moveTo(pt[6],pt[7]),O.lineTo(pt[4],pt[5]),O.lineTo(pt[2],pt[3]),O.lineTo(pt[0],pt[1]),O.clip())}M.push(Q),Y.push(q),this.drawTile(xi,e,yi,li,Ei,mn,ai,Ko),vs&&O.restore(),this.renderedTiles.unshift(xi),this.updateUsedTiles(e.usedTiles,c,xi)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!qe(this.renderedExtent_,v),this.renderedExtent_=v,this.renderedPixelRatio=l,this.postRender(this.context,e),i.extent&&O.restore(),O.imageSmoothingEnabled=!0,this.renderComplete){let U=(q,H)=>{let oe=P(c),de=H.wantedTiles[oe],xe=de?Object.keys(de).length:0;this.updateCacheSize(xe),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};e.postRenderFunctions.push(U)}return this.container}updateCacheSize(e){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,e*2)}drawTile(e,t,i,n,s,o,a,l){let h;if(e instanceof Iu){if(h=ll(e.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(e);if(!h)return;let c=this.getRenderContext(t),u=P(this),d=t.layerStatesArray[t.layerIndex],f=d.opacity*(l?e.getAlpha(u,t.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,i,n,s,o),g&&c.restore(),f!==d.opacity?t.animate=!0:l&&e.endTransition(u)}getImage(){let e=this.context;return e?e.canvas:null}getTileImage(e){return e.getImage()}updateUsedTiles(e,t,i){let n=P(t);n in e||(e[n]={}),e[n][i.getKey()]=!0}},_l=Vu;var Ii={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};var Wu=class extends qi{constructor(e){e=e||{};let t=Object.assign({},e),i=e.cacheSize;delete e.cacheSize,delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(e.preload!==void 0?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Ii.PRELOAD)}setPreload(e){this.set(Ii.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(Ii.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(Ii.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}},Ap=Wu;var Xu=class extends Ap{constructor(e){super(e)}createRenderer(){return new _l(this,{cacheSize:this.getCacheSize()})}},qr=Xu;var Yu=class{drawCustom(e,t,i,n,s){}drawGeometry(e){}setStyle(e){}drawCircle(e,t,i){}drawFeature(e,t,i){}drawGeometryCollection(e,t,i){}drawLineString(e,t,i){}drawMultiLineString(e,t,i){}drawMultiPoint(e,t,i){}drawMultiPolygon(e,t,i){}drawPoint(e,t,i){}drawPolygon(e,t,i){}drawText(e,t,i){}setFillStrokeStyle(e,t){}setImageStyle(e,t){}setTextStyle(e,t){}},xl=Yu;var So={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},Ro=[So.FILL],Fi=[So.STROKE],on=[So.BEGIN_PATH],$u=[So.CLOSE_PATH],V=So;var Ku=class extends xl{constructor(e,t,i,n){super(),this.tolerance=e,this.maxExtent=t,this.pixelRatio=n,this.maxLineWidth=0,this.resolution=i,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(i){return i*t})}appendFlatPointCoordinates(e,t){let i=this.getBufferedMaxExtent(),n=this.tmpCoordinate_,s=this.coordinates,o=s.length;for(let a=0,l=e.length;a<l;a+=t)n[0]=e[a],n[1]=e[a+1],rt(i,n)&&(s[o++]=n[0],s[o++]=n[1]);return o}appendFlatLineCoordinates(e,t,i,n,s,o){let a=this.coordinates,l=a.length,h=this.getBufferedMaxExtent();o&&(t+=n);let c=e[t],u=e[t+1],d=this.tmpCoordinate_,f=!0,g,m,p;for(g=t+n;g<i;g+=n)d[0]=e[g],d[1]=e[g+1],p=aa(h,d),p!==m?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):p===We.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],m=p;return(s&&f||g===t+n)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(e,t,i,n,s){for(let o=0,a=i.length;o<a;++o){let l=i[o],h=this.appendFlatLineCoordinates(e,t,l,n,!1,!1);s.push(h),t=l}return t}drawCustom(e,t,i,n,s){this.beginGeometry(e,t,s);let o=e.getType(),a=e.getStride(),l=this.coordinates.length,h,c,u,d,f;switch(o){case"MultiPolygon":h=e.getOrientedFlatCoordinates(),d=[];let g=e.getEndss();f=0;for(let m=0,p=g.length;m<p;++m){let _=[];f=this.drawCustomCoordinates_(h,f,g[m],a,_),d.push(_)}this.instructions.push([V.CUSTOM,l,d,e,i,js,s]),this.hitDetectionInstructions.push([V.CUSTOM,l,d,e,n||i,js,s]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?e.getOrientedFlatCoordinates():e.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,e.getEnds(),a,u),this.instructions.push([V.CUSTOM,l,u,e,i,Pn,s]),this.hitDetectionInstructions.push([V.CUSTOM,l,u,e,n||i,Pn,s]);break;case"LineString":case"Circle":h=e.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([V.CUSTOM,l,c,e,i,ri,s]),this.hitDetectionInstructions.push([V.CUSTOM,l,c,e,n||i,ri,s]);break;case"MultiPoint":h=e.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([V.CUSTOM,l,c,e,i,ri,s]),this.hitDetectionInstructions.push([V.CUSTOM,l,c,e,n||i,ri,s]));break;case"Point":h=e.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([V.CUSTOM,l,c,e,i,void 0,s]),this.hitDetectionInstructions.push([V.CUSTOM,l,c,e,n||i,void 0,s]);break;default:}this.endGeometry(t)}beginGeometry(e,t,i){this.beginGeometryInstruction1_=[V.BEGIN_GEOMETRY,t,0,e,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[V.BEGIN_GEOMETRY,t,0,e,i],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,i=e.length,n,s,o=-1;for(t=0;t<i;++t)n=e[t],s=n[0],s==V.END_GEOMETRY?o=t:s==V.BEGIN_GEOMETRY&&(n[2]=t,ug(this.hitDetectionInstructions,o,t),o=-1)}fillStyleToState(e,t={}){if(e){let i=e.getColor();t.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,t.fillStyle=Xt(i||it)}else t.fillStyle=void 0;return t}strokeStyleToState(e,t={}){if(e){let i=e.getColor();t.strokeStyle=Xt(i||Qi);let n=e.getLineCap();t.lineCap=n!==void 0?n:wi;let s=e.getLineDash();t.lineDash=s?s.slice():Yt;let o=e.getLineDashOffset();t.lineDashOffset=o||$t;let a=e.getLineJoin();t.lineJoin=a!==void 0?a:Pi;let l=e.getWidth();t.lineWidth=l!==void 0?l:tn;let h=e.getMiterLimit();t.miterLimit=h!==void 0?h:Ji;let c=e.getOffset();t.strokeOffset=c??op,t.lineWidth>this.maxLineWidth&&(this.maxLineWidth=t.lineWidth,this.bufferedMaxExtent_=null)}else t.strokeStyle=void 0,t.lineCap=void 0,t.lineDash=null,t.lineDashOffset=void 0,t.lineJoin=void 0,t.lineWidth=void 0,t.miterLimit=void 0,t.strokeOffset=void 0;return t}setFillStrokeStyle(e,t){let i=this.state;this.fillStyleToState(e,i),this.strokeStyleToState(t,i)}createFill(e){let t=e.fillStyle,i=[V.SET_FILL_STYLE,t];return typeof t!="string"&&i.push(e.fillPatternScale),i}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[V.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,e.lineDash?this.applyPixelRatio(e.lineDash):null,e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){let i=e.fillStyle;(typeof i!="string"||e.currentFillStyle!=i)&&(this.instructions.push(t.call(this,e)),e.currentFillStyle=i)}updateStrokeStyle(e,t){let i=e.strokeStyle,n=e.lineCap,s=e.lineDash,o=e.lineDashOffset,a=e.lineJoin,l=e.lineWidth,h=e.miterLimit,c=e.strokeOffset;(e.currentStrokeStyle!=i||e.currentLineCap!=n||s!=e.currentLineDash&&!Ve(e.currentLineDash,s)||e.currentLineDashOffset!=o||e.currentLineJoin!=a||e.currentLineWidth!=l||e.currentMiterLimit!=h||e.currentStrokeOffset!=c)&&(t.call(this,e),e.currentStrokeStyle=i,e.currentLineCap=n,e.currentLineDash=s,e.currentLineDashOffset=o,e.currentLineJoin=a,e.currentLineWidth=l,e.currentMiterLimit=h,e.currentStrokeOffset=c)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let t=[V.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=la(this.maxExtent),this.maxLineWidth>0)){let e=this.resolution*(this.maxLineWidth+1)/2;Le(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},Mi=Ku;var Hu=class extends Mi{constructor(e,t,i,n){super(e,t,i,n),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,i){if(!this.image_||this.maxExtent&&!rt(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,i);let n=e.getFlatCoordinates(),s=e.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(n,s);this.instructions.push([V.DRAW_IMAGE,o,a,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([V.DRAW_IMAGE,o,a,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,i){if(!this.image_)return;this.beginGeometry(e,t,i);let n=e.getFlatCoordinates(),s=[];for(let l=0,h=n.length;l<h;l+=e.getStride())(!this.maxExtent||rt(this.maxExtent,n.slice(l,l+2)))&&s.push(n[l],n[l+1]);let o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,2);this.instructions.push([V.DRAW_IMAGE,o,a,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([V.DRAW_IMAGE,o,a,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 i=e.getAnchor(),n=e.getSize(),s=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=n[1],this.opacity_=e.getOpacity(),this.originX_=s[0],this.originY_=s[1],this.rotateWithView_=e.getRotateWithView(),this.rotation_=e.getRotation(),this.scale_=e.getScaleArray(),this.width_=n[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}},Op=Hu;var Zu=class extends Mi{constructor(e,t,i,n){super(e,t,i,n)}drawFlatCoordinates_(e,t,i,n,s){let o=this.coordinates.length,a=this.appendFlatLineCoordinates(e,t,i,n,!1,!1);return this.instructions.push([V.MOVE_TO_LINE_TO,o,a,s*this.pixelRatio]),this.hitDetectionInstructions.push([V.MOVE_TO_LINE_TO,o,a,s]),i}drawLineString(e,t,i){let n=this.state,s=n.strokeStyle,o=n.lineWidth,a=n.strokeOffset;if(s===void 0||o===void 0)return;this.updateStrokeStyle(n,this.applyStroke),this.beginGeometry(e,t,i),this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Yt,$t],on);let l=e.getFlatCoordinates(),h=e.getStride();this.drawFlatCoordinates_(l,0,l.length,h,a),this.hitDetectionInstructions.push(Fi),this.endGeometry(t)}drawMultiLineString(e,t,i){let n=this.state,s=n.strokeStyle,o=n.lineWidth,a=n.strokeOffset;if(s===void 0||o===void 0)return;this.updateStrokeStyle(n,this.applyStroke),this.beginGeometry(e,t,i),this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Yt,$t],on);let l=e.getEnds(),h=e.getFlatCoordinates(),c=e.getStride(),u=0;for(let d=0,f=l.length;d<f;++d)u=this.drawFlatCoordinates_(h,u,l[d],c,a);this.hitDetectionInstructions.push(Fi),this.endGeometry(t)}finish(){let e=this.state;return e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&this.instructions.push(Fi),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(e){e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&(this.instructions.push(Fi),e.lastStroke=this.coordinates.length),e.lastStroke=0,super.applyStroke(e),this.instructions.push(on)}},Dp=Zu;var qu=class extends Mi{constructor(e,t,i,n){super(e,t,i,n)}drawFlatCoordinatess_(e,t,i,n,s){let o=this.state,a=o.fillStyle!==void 0,l=o.strokeStyle!==void 0,h=i.length;this.instructions.push(on),this.hitDetectionInstructions.push(on);for(let c=0;c<h;++c){let u=i[c],d=this.coordinates.length,f=this.appendFlatLineCoordinates(e,t,u,n,!0,!l);this.instructions.push([V.MOVE_TO_LINE_TO,d,f,s*this.pixelRatio,!0]),this.hitDetectionInstructions.push([V.MOVE_TO_LINE_TO,d,f,s,!0]),l&&(this.instructions.push($u),this.hitDetectionInstructions.push($u)),t=u}return a&&(this.instructions.push(Ro),this.hitDetectionInstructions.push(Ro)),l&&(this.instructions.push(Fi),this.hitDetectionInstructions.push(Fi)),t}drawCircle(e,t,i){let n=this.state,s=n.fillStyle,o=n.strokeStyle,a=n.strokeOffset;if(s===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawCircle(e,t,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_FILL_STYLE,it]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Yt,$t]);let l=e.getFlatCoordinates(),h=e.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(l,0,l.length,h,!1,!1);let u=[V.CIRCLE,c,a];this.instructions.push(on,u),this.hitDetectionInstructions.push(on,u),n.fillStyle!==void 0&&(this.instructions.push(Ro),this.hitDetectionInstructions.push(Ro)),n.strokeStyle!==void 0&&(this.instructions.push(Fi),this.hitDetectionInstructions.push(Fi)),this.endGeometry(t)}drawPolygon(e,t,i){let n=this.state,s=n.fillStyle,o=n.strokeStyle,a=n.strokeOffset;if(s===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawPolygon(e,t,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_FILL_STYLE,it]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Yt,$t]);let l=e.getEnds(),h=e.getOrientedFlatCoordinates(),c=e.getStride();this.drawFlatCoordinatess_(h,0,l,c,a),this.endGeometry(t)}drawMultiPolygon(e,t,i){let n=this.state,s=n.fillStyle,o=n.strokeStyle,a=n.strokeOffset;if(s===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawMultiPolygon(e,t,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_FILL_STYLE,it]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([V.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Yt,$t]);let l=e.getEndss(),h=e.getOrientedFlatCoordinates(),c=e.getStride(),u=0;for(let d=0,f=l.length;d<f;++d)u=this.drawFlatCoordinatess_(h,u,l[d],c,a);this.endGeometry(t)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let e=this.tolerance;if(e!==0){let t=this.coordinates;for(let i=0,n=t.length;i<n;++i)t[i]=Ln(t[i],e)}return super.finish()}setFillStrokeStyles_(){let e=this.state;this.updateFillStyle(e,this.createFill),this.updateStrokeStyle(e,this.applyStroke)}handleStrokeOffset_(e){let t=this.state,i=t.fillStyle,n=t.strokeStyle,s=t.strokeOffset;return Math.abs(s)>0&&i!==void 0&&n!==void 0?(t.strokeStyle=void 0,t.strokeOffset=0,e(),t.fillStyle=void 0,t.strokeStyle=n,t.strokeOffset=s,e(),t.fillStyle=i,!0):!1}},Ju=qu;function kp(r,e,t,i,n){let s=[],o=t,a=0,l=e.slice(t,2);for(;a<r&&o+n<i;){let[h,c]=l.slice(-2),u=e[o+n],d=e[o+n+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=r){let g=(r-a+f)/f,m=ht(h,u,g),p=ht(c,d,g);l.push(m,p),s.push(l),l=[m,p],a==r&&(o+=n),a=0}else if(a<r)l.push(e[o+n],e[o+n+1]),o+=n;else{let g=f-a,m=ht(h,u,g/f),p=ht(c,d,g/f);l.push(m,p),s.push(l),l=[m,p],a=0,o+=n}}return a>0&&s.push(l),s}function Np(r,e,t,i,n){let s=t,o=t,a=0,l=0,h=t,c,u,d,f,g,m,p,_,x,y;for(u=t;u<i;u+=n){let E=e[u],T=e[u+1];g!==void 0&&(x=E-g,y=T-m,f=Math.sqrt(x*x+y*y),p!==void 0&&(l+=d,c=Math.acos((p*x+_*y)/(d*f)),c>r&&(l>a&&(a=l,s=h,o=u),l=0,h=u-n)),d=f,p=x,_=y),g=E,m=T}return l+=f,l>a?[h,u]:[s,o]}var wo={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Qu=class extends Mi{constructor(e,t,i,n){super(e,t,i,n),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[it]={fillStyle:it},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,i){let n=this.textFillState_,s=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!n&&!s)return;let a=this.coordinates,l=a.length,h=e.getType(),c=null,u=e.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!te(this.maxExtent,e.getExtent()))return;let d;if(c=e.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=e.getEnds();else if(h=="Polygon")d=e.getEnds().slice(0,1);else if(h=="MultiPolygon"){let p=e.getEndss();d=[];for(let _=0,x=p.length;_<x;++_)d.push(p[_][0])}this.beginGeometry(e,t,i);let f=o.repeat,g=f?void 0:o.textAlign,m=0;for(let p=0,_=d.length;p<_;++p){let x;f?x=kp(f*this.resolution,c,m,d[p],u):x=[c.slice(m,d[p])];for(let y=0,E=x.length;y<E;++y){let T=x[y],v=0,S=T.length;if(g==null){let R=Np(o.maxAngle,T,0,T.length,2);v=R[0],S=R[1]}for(let R=v;R<S;R+=u)a.push(T[R],T[R+1]);let w=a.length;m=d[p],this.drawChars_(l,w),l=w}}this.endGeometry(t)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=e.getFlatCoordinates();break;case"LineString":c=e.getFlatMidpoint();break;case"Circle":c=e.getCenter();break;case"MultiLineString":c=e.getFlatMidpoints(),u=2;break;case"Polygon":c=e.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":let E=e.getFlatInteriorPoints();c=[];for(let T=0,v=E.length;T<v;T+=3)o.overflow||d.push(E[T+2]/this.resolution),c.push(E[T],E[T+1]);if(c.length===0)return;u=2;break;default:}let f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let E=l/2;d=d.filter((T,v)=>{let S=a[(E+v)*2]===c[v*u]&&a[(E+v)*2+1]===c[v*u+1];return S||--E,S})}this.saveTextStates_();let g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,m=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(e,t,i);let p=o.padding;if(p!=en&&(o.scale[0]<0||o.scale[1]<0)){let E=o.padding[0],T=o.padding[1],v=o.padding[2],S=o.padding[3];o.scale[0]<0&&(T=-T,S=-S),o.scale[1]<0&&(E=-E,v=-v),p=[E,T,v,S]}let _=this.pixelRatio;this.instructions.push([V.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,p==en?en:p.map(function(E){return E*_}),g,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);let x=1/_,y=g?g.slice(0):null;y&&(y[1]=it),this.hitDetectionInstructions.push([V.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[x,x],NaN,this.declutterMode_,this.declutterImageWithText_,p,y,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?it:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(t)}}saveTextStates_(){let e=this.textStrokeState_,t=this.textState_,i=this.textFillState_,n=this.strokeKey_;e&&(n in this.strokeStates||(this.strokeStates[n]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));let s=this.textKey_;s in this.textStates||(this.textStates[s]={font:t.font,textAlign:t.textAlign||Dn,justify:t.justify,textBaseline:t.textBaseline||sr,scale:t.scale});let o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(e,t){let i=this.textStrokeState_,n=this.textState_,s=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();let l=this.pixelRatio,h=wo[n.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(n.scale[0])/2:0;this.instructions.push([V.DRAW_CHARS,e,t,h,n.overflow,a,n.maxAngle,l,c,s,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([V.DRAW_CHARS,e,t,h,n.overflow,a&&it,n.maxAngle,l,c,s,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(e,t){let i,n,s;if(!e)this.text_="";else{let o=e.getFill();o?(n=this.textFillState_,n||(n={},this.textFillState_=n),n.fillStyle=Xt(o.getColor()||it)):(n=null,this.textFillState_=n);let a=e.getStroke();if(!a)s=null,this.textStrokeState_=s;else{s=this.textStrokeState_,s||(s={},this.textStrokeState_=s);let m=a.getLineDash(),p=a.getLineDashOffset(),_=a.getWidth(),x=a.getMiterLimit();s.lineCap=a.getLineCap()||wi,s.lineDash=m?m.slice():Yt,s.lineDashOffset=p===void 0?$t:p,s.lineJoin=a.getLineJoin()||Pi,s.lineWidth=_===void 0?tn:_,s.miterLimit=x===void 0?Ji:x,s.strokeStyle=Xt(a.getColor()||Qi)}i=this.textState_;let l=e.getFont()||el;ap(l);let h=e.getScaleArray();i.overflow=e.getOverflow(),i.font=l,i.maxAngle=e.getMaxAngle(),i.placement=e.getPlacement(),i.textAlign=e.getTextAlign(),i.repeat=e.getRepeat(),i.justify=e.getJustify(),i.textBaseline=e.getTextBaseline()||sr,i.backgroundFill=e.getBackgroundFill(),i.backgroundStroke=e.getBackgroundStroke(),i.padding=e.getPadding()||en,i.scale=h===void 0?[1,1]:h;let c=e.getOffsetX(),u=e.getOffsetY(),d=e.getRotateWithView(),f=e.getKeepUpright(),g=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=s?(typeof s.strokeStyle=="string"?s.strokeStyle:P(s.strokeStyle))+s.lineCap+s.lineDashOffset+"|"+s.lineWidth+s.lineJoin+s.miterLimit+"["+s.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=n&&n.fillStyle?typeof n.fillStyle=="string"?n.fillStyle:"|"+P(n.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}},Gp=Qu;var N0={Circle:Ju,Default:Mi,Image:Op,LineString:Dp,Polygon:Ju,Text:Gp},ed=class{constructor(e,t,i,n){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=n,this.resolution_=i,this.buildersByZIndex_={}}finish(){let e={};for(let t in this.buildersByZIndex_){e[t]=e[t]||{};let i=this.buildersByZIndex_[t];for(let n in i){let s=i[n].finish();e[t][n]=s}}return e}getBuilder(e,t){let i=e!==void 0?e.toString():"0",n=this.buildersByZIndex_[i];n===void 0&&(n={},this.buildersByZIndex_[i]=n);let s=n[t];if(s===void 0){let o=N0[t];s=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),n[t]=s}return s}},yl=ed;function Jr(r,e,t,i){let n=r[e],s=r[e+1],o=0;for(let a=e+i;a<t;a+=i){let l=r[a],h=r[a+1];o+=Math.sqrt((l-n)*(l-n)+(h-s)*(h-s)),n=l,s=h}return o}function Up(r,e,t,i,n,s){n=n??[],s=s??e;let o=r[0],a=r[1],l=r[r.length-4],h=r[r.length-3],c,u,d,f,g,m,p,_,x=0;for(let y=0;y<r.length;y+=e){d=c,f=u,g=void 0,m=void 0,y+e<r.length&&(g=r[y+e],m=r[y+e+1]),i&&y===0&&(d=l,f=h),i&&y===r.length-2&&(g=o,m=a),c=r[y],u=r[y+1],[p,_]=Po(c,u,d,f,g,m,t),n[x++]=p,n[x++]=_;for(let E=2;E<s;E++)n[x++]=r[y+E]}return n.length!=x&&(n.length=x),n}function Po(r,e,t,i,n,s,o){let a,l;t!==void 0&&i!==void 0?(a=r-t,l=e-i):n!==void 0&&s!==void 0?(a=n-r,l=s-e):(a=1,l=0);let h=Math.hypot(a,l),c=a/h,u=l/h;if(a=-u,l=c,t===void 0||i===void 0)return[r+a*o,e+l*o];if(n===void 0||s===void 0)return[r+a*o,e+l*o];let d=Ag([r,e],[t,i],[n,s]);if(Math.cos(d)>.998)return[r+c*o,e+u*o];let f=Math.cos(d/2),g=Math.sin(d/2),m=g*a+f*l,p=-f*a+g*l,_=m*(1/g),x=p*(1/g);return[r+_*o,e+x*o]}function Bp(r,e,t,i,n,s,o,a,l,h,c,u,d=!0){let f=r[e],g=r[e+1],m=0,p=0,_=0,x=0;function y(){m=f,p=g,e+=i,f=r[e],g=r[e+1],x+=_,_=Math.sqrt((f-m)*(f-m)+(g-p)*(g-p))}do y();while(e<t-i&&x+_<s);let E=_===0?0:(s-x)/_,T=ht(m,f,E),v=ht(p,g,E),S=e-i,w=x,R=s+a*l(h,n,c);for(;e<t-i&&x+_<R;)y();E=_===0?0:(R-x)/_;let b=ht(m,f,E),D=ht(p,g,E),G=!1;if(d)if(u){let Y=[T,v,b,D];br(Y,0,4,2,u,Y,Y),G=Y[0]>Y[2]}else G=T>b;let O=Math.PI,X=[],Q=S+i===e;e=S,_=0,x=w,f=r[e],g=r[e+1];let M;if(Q){y(),M=Math.atan2(g-p,f-m),G&&(M+=M>0?-O:O);let Y=(b+T)/2,U=(D+v)/2;return X[0]=[Y,U,(R-s)/2,M,n],X}n=n.replace(/\n/g," ");for(let Y=0,U=n.length;Y<U;){y();let q=Math.atan2(g-p,f-m);if(G&&(q+=q>0?-O:O),M!==void 0){let I=q-M;if(I+=I>O?-2*O:I<-O?2*O:0,Math.abs(I)>o)return null}M=q;let H=Y,oe=0;for(;Y<U;++Y){let I=G?U-Y-1:Y,Kt=a*l(h,n[I],c);if(e+i<t&&x+_<s+oe+Kt/2)break;oe+=Kt}if(Y===H)continue;let de=G?n.substring(U-H,U-Y):n.substring(H,Y);E=_===0?0:(s+oe/2-x)/_;let xe=ht(m,f,E),St=ht(p,g,E);X.push([xe,St,oe/2,q,de]),s+=oe}return X}var Qr=me(),Un=[],an=[],ln=[],Bn=[];function zp(r){return r[3].declutterBox}var jp=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function td(r,e){return e==="start"?e=jp.test(r)?"right":"left":e==="end"&&(e=jp.test(r)?"left":"right"),wo[e]}function G0(r,e,t){return t>0&&r.push(`
4
+ `,""),r.push(e,""),r}function U0(r,e,t){return t%2===0&&(r+=e),r}var id=class{constructor(e,t,i,n,s){this.overlaps=i,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=n.instructions,this.coordinates=n.coordinates,this.coordinateCache_={},this.renderedTransform_=ae(),this.hitDetectionInstructions=n.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=n.fillStates||{},this.strokeStates=n.strokeStates||{},this.textStates=n.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=s?new Kr:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,i,n){let s=e+t+i+n;if(this.labels_[s])return this.labels_[s];let o=n?this.strokeStates[n]:null,a=i?this.fillStates[i]:null,l=this.textStates[t],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?wo[l.justify]:td(Array.isArray(e)?e[0]:e,l.textAlign||Dn),d=n&&o.lineWidth?o.lineWidth:0,f=Array.isArray(e)?e:String(e).split(`
5
+ `).reduce(G0,[]),{width:g,height:m,widths:p,heights:_,lineWidths:x}=cp(l,f),y=g+d,E=[],T=(y+2)*c[0],v=(m+d)*c[1],S={width:T<0?Math.floor(T):Math.ceil(T),height:v<0?Math.floor(v):Math.ceil(v),contextInstructions:E};(c[0]!=1||c[1]!=1)&&E.push("scale",c),n&&(E.push("strokeStyle",o.strokeStyle),E.push("lineWidth",d),E.push("lineCap",o.lineCap),E.push("lineJoin",o.lineJoin),E.push("miterLimit",o.miterLimit),E.push("setLineDash",[o.lineDash]),E.push("lineDashOffset",o.lineDashOffset)),i&&E.push("fillStyle",a.fillStyle),E.push("textBaseline","middle"),E.push("textAlign","center");let w=.5-u,R=u*y+w*d,b=[],D=[],G=0,O=0,X=0,Q=0,M;for(let Y=0,U=f.length;Y<U;Y+=2){let q=f[Y];if(q===`
6
+ `){O+=G,G=0,R=u*y+w*d,++Q;continue}let H=f[Y+1]||l.font;H!==M&&(n&&b.push("font",H),i&&D.push("font",H),M=H),G=Math.max(G,_[X]);let oe=[q,R+w*p[X]+u*(p[X]-x[Q]),.5*(d+G)+O];R+=p[X],n&&b.push("strokeText",oe),i&&D.push("fillText",oe),++X}return Array.prototype.push.apply(E,b),Array.prototype.push.apply(E,D),this.labels_[s]=S,S}replayTextBackground_(e,t,i,n,s,o,a){e.beginPath(),e.moveTo.apply(e,t),e.lineTo.apply(e,i),e.lineTo.apply(e,n),e.lineTo.apply(e,s),e.lineTo.apply(e,t),o&&(this.alignAndScaleFill_=o[2],e.fillStyle=o[1],this.fill_(e)),a&&(this.setStrokeStyle_(e,a),e.stroke())}calculateImageOrLabelDimensions_(e,t,i,n,s,o,a,l,h,c,u,d,f,g,m,p){a*=d[0],l*=d[1];let _=i-a,x=n-l,y=s+h>e?e-h:s,E=o+c>t?t-c:o,T=g[3]+y*d[0]+g[1],v=g[0]+E*d[1]+g[2],S=_-g[3],w=x-g[0];(m||u!==0)&&(Un[0]=S,Bn[0]=S,Un[1]=w,an[1]=w,an[0]=S+T,ln[0]=an[0],ln[1]=w+v,Bn[1]=ln[1]);let R;return u!==0?(R=Ae(ae(),i,n,1,1,u,-i,-n),le(R,Un),le(R,an),le(R,ln),le(R,Bn),bt(Math.min(Un[0],an[0],ln[0],Bn[0]),Math.min(Un[1],an[1],ln[1],Bn[1]),Math.max(Un[0],an[0],ln[0],Bn[0]),Math.max(Un[1],an[1],ln[1],Bn[1]),Qr)):bt(Math.min(S,S+T),Math.min(w,w+v),Math.max(S,S+T),Math.max(w,w+v),Qr),f&&(_=Math.round(_),x=Math.round(x)),{drawImageX:_,drawImageY:x,drawImageW:y,drawImageH:E,originX:h,originY:c,declutterBox:{minX:Qr[0],minY:Qr[1],maxX:Qr[2],maxY:Qr[3],value:p},canvasTransform:R,scale:d}}replayImageOrLabel_(e,t,i,n,s,o,a){let l=!!(o||a),h=n.declutterBox,c=a?a[2]*n.scale[0]/2:0;return h.minX-c<=t[0]&&h.maxX+c>=0&&h.minY-c<=t[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(e,Un,an,ln,Bn,o,a),up(e,n.canvasTransform,s,i,n.originX,n.originY,n.drawImageW,n.drawImageH,n.drawImageX,n.drawImageY,n.scale)),!0}fill_(e){let t=this.alignAndScaleFill_;if(t){let i=le(this.renderedTransform_,[0,0]),n=512*this.pixelRatio;e.save(),e.translate(i[0]%n,i[1]%n),t!==1&&e.scale(t,t)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],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,i,n){let s=this.textStates[t],o=this.createLabel(e,t,n,i),a=this.strokeStates[i],l=this.pixelRatio,h=td(Array.isArray(e)?e[0]:e,s.textAlign||Dn),c=wo[s.textBaseline||sr],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*s.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(e,t,i,n,s,o,a,l){let h=this.zIndexContext_,c;this.pixelCoordinates_&&Ve(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=ut(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Pa(this.renderedTransform_,i));let u=0,d=n.length,f=0,g,m,p,_,x,y,E,T,v,S,w,R,b,D,G,O,X=0,Q=0,M=this.coordinateCache_,Y=this.viewRotation_,U=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,q={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:Y},H=this.instructions!=n||this.overlaps?0:200,oe,de,xe,St;for(;u<d;){let I=n[u];switch(I[0]){case V.BEGIN_GEOMETRY:oe=I[1],St=I[3],oe.getGeometry()?a!==void 0&&!te(a,St.getExtent())?u=I[2]+1:++u:u=I[2],h&&(h.zIndex=I[4]);break;case V.BEGIN_PATH:X>H&&(this.fill_(e),X=0),Q>H&&(e.stroke(),Q=0),!X&&!Q&&(e.beginPath(),T=NaN,v=NaN),++u;break;case V.CIRCLE:f=I[1],_=I[2]??0;let nt=c[f],ai=c[f+1],xi=c[f+2]-_,Ht=c[f+3]-_,Ts=xi-nt,$o=Ht-ai,Cs=Math.sqrt(Ts*Ts+$o*$o);e.moveTo(nt+Cs,ai),e.arc(nt,ai,Cs,0,2*Math.PI,!0),++u;break;case V.CLOSE_PATH:e.closePath(),++u;break;case V.CUSTOM:f=I[1],g=I[2];let _h=I[3],yi=I[4],li=I[5];q.geometry=_h,q.feature=oe,u in M||(M[u]=[]);let Ei=M[u];li?li(c,f,g,2,Ei):(Ei[0]=c[f],Ei[1]=c[f+1],Ei.length=2),h&&(h.zIndex=I[6]),yi(Ei,q),++u;break;case V.DRAW_IMAGE:f=I[1],g=I[2],R=I[3],m=I[4],p=I[5];let mn=I[6],Ko=I[7],vs=I[8],pr=I[9],Ho=I[10],pt=I[11],Ix=I[12],Zo=I[13];E=I[14]||"declutter";let Ss=I[15];if(!R&&I.length>=20){b=I[19],D=I[20],G=I[21],O=I[22];let Zt=this.drawLabelWithPointPlacement_(b,D,G,O);R=Zt.label,I[3]=R;let Wn=I[23];m=(Zt.anchorX-Wn)*this.pixelRatio,I[4]=m;let qt=I[24];p=(Zt.anchorY-qt)*this.pixelRatio,I[5]=p,mn=R.height,I[6]=mn,Zo=R.width,I[13]=Zo}let xh;I.length>25&&(xh=I[25]);let yh,qo,Jo;I.length>17?(yh=I[16],qo=I[17],Jo=I[18]):(yh=en,qo=null,Jo=null),Ho&&U?pt+=Y:!Ho&&!U&&(pt-=Y);let Fx=0;for(;f<g;f+=2){if(xh&&xh[Fx++]<Zo/this.pixelRatio)continue;let Zt=this.calculateImageOrLabelDimensions_(R.width,R.height,c[f],c[f+1],Zo,mn,m,p,vs,pr,pt,Ix,s,yh,!!qo||!!Jo,oe),Wn=[e,t,R,Zt,Ko,qo,Jo];if(l){let qt,Ti,Jt;if(Ss){let Oe=g-f;if(!Ss[Oe]){Ss[Oe]={args:Wn,declutterMode:E};continue}let Rt=Ss[Oe];qt=Rt.args,Ti=Rt.declutterMode,delete Ss[Oe],Jt=zp(qt)}let Ni,Gi;if(qt&&(Ti!=="declutter"||!l.collides(Jt))&&(Ni=!0),(E!=="declutter"||!l.collides(Zt.declutterBox))&&(Gi=!0),Ti==="declutter"&&E==="declutter"){let Oe=Ni&&Gi;Ni=Oe,Gi=Oe}Ni&&(Ti!=="none"&&l.insert(Jt),this.replayImageOrLabel_.apply(this,qt)),Gi&&(E!=="none"&&l.insert(Zt.declutterBox),this.replayImageOrLabel_.apply(this,Wn))}else this.replayImageOrLabel_.apply(this,Wn)}++u;break;case V.DRAW_CHARS:let ig=I[1],ng=I[2],Eh=I[3],Mx=I[4];O=I[5];let Ax=I[6],rg=I[7],sg=I[8];G=I[9];let Th=I[10];b=I[11],Array.isArray(b)&&(b=b.reduce(U0,"")),D=I[12];let og=[I[13],I[13]];E=I[14]||"declutter";let Ox=I[15],Ch=this.textStates[D],Rs=Ch.font,ws=[Ch.scale[0]*rg,Ch.scale[1]*rg],Ps;Rs in this.widths_?Ps=this.widths_[Rs]:(Ps={},this.widths_[Rs]=Ps);let ag=Jr(c,ig,ng,2),lg=Math.abs(ws[0])*hu(Rs,b,Ps);if(Mx||lg<=ag){let Zt=this.textStates[D].textAlign,Wn=(ag-lg)*td(b,Zt),qt=Bp(c,ig,ng,2,b,Wn,Ax,Math.abs(ws[0]),hu,Rs,Ps,U?0:this.viewRotation_,Ox);e:if(qt){let Ti=[],Jt,Ni,Gi,Oe,Rt;if(G)for(Jt=0,Ni=qt.length;Jt<Ni;++Jt){Rt=qt[Jt],Gi=Rt[4],Oe=this.createLabel(Gi,D,"",G),m=Rt[2]+(ws[0]<0?-Th:Th),p=Eh*Oe.height+(.5-Eh)*2*Th*ws[1]/ws[0]-sg;let Ui=this.calculateImageOrLabelDimensions_(Oe.width,Oe.height,Rt[0],Rt[1],Oe.width,Oe.height,m,p,0,0,Rt[3],og,!1,en,!1,oe);if(l&&E==="declutter"&&l.collides(Ui.declutterBox))break e;Ti.push([e,t,Oe,Ui,1,null,null])}if(O)for(Jt=0,Ni=qt.length;Jt<Ni;++Jt){Rt=qt[Jt],Gi=Rt[4],Oe=this.createLabel(Gi,D,O,""),m=Rt[2],p=Eh*Oe.height-sg;let Ui=this.calculateImageOrLabelDimensions_(Oe.width,Oe.height,Rt[0],Rt[1],Oe.width,Oe.height,m,p,0,0,Rt[3],og,!1,en,!1,oe);if(l&&E==="declutter"&&l.collides(Ui.declutterBox))break e;Ti.push([e,t,Oe,Ui,1,null,null])}l&&E!=="none"&&l.load(Ti.map(zp));for(let Ui=0,Dx=Ti.length;Ui<Dx;++Ui)this.replayImageOrLabel_.apply(this,Ti[Ui])}}++u;break;case V.END_GEOMETRY:if(o!==void 0){oe=I[1];let Zt=o(oe,St,E);if(Zt)return Zt}++u;break;case V.FILL:H?X++:this.fill_(e),++u;break;case V.MOVE_TO_LINE_TO:for(f=I[1],g=I[2],_=I[3],x=I[4]??!1,de=c[f],xe=c[f+1],_&&(y=f,[de,xe]=Po(de,xe,x?c[g-4]:void 0,x?c[g-3]:void 0,c[f+2],c[f+3],_)),e.moveTo(de,xe),T=de+.5|0,v=xe+.5|0,f+=2;f<g;f+=2)de=c[f],xe=c[f+1],S=de+.5|0,w=xe+.5|0,(f==g-2||S!==T||w!==v)&&(_&&(f==g-2?[de,xe]=Po(de,xe,c[f-2],c[f-1],x?c[y+2]:void 0,x?c[y+3]:void 0,_):[de,xe]=Po(de,xe,c[f-2],c[f-1],c[f+2],c[f+3],_)),e.lineTo(de,xe),T=S,v=w);++u;break;case V.SET_FILL_STYLE:this.alignAndScaleFill_=I[2],X&&(this.fill_(e),X=0,Q&&(e.stroke(),Q=0)),e.fillStyle=I[1],++u;break;case V.SET_STROKE_STYLE:Q&&(e.stroke(),Q=0),this.setStrokeStyle_(e,I),++u;break;case V.STROKE:H?Q++:e.stroke(),++u;break;default:++u;break}}X&&this.fill_(e),Q&&e.stroke()}execute(e,t,i,n,s,o){this.viewRotation_=n,this.execute_(e,t,i,this.instructions,s,void 0,void 0,o)}executeHitDetection(e,t,i,n,s){return this.viewRotation_=i,this.execute_(e,[e.canvas.width,e.canvas.height],t,this.hitDetectionInstructions,!0,n,s)}},Vp=id;var zn=["Polygon","Circle","LineString","Image","Text","Default"],es=["Image","Text"],Wp=zn.filter(r=>!es.includes(r)),Xp=!1,Yp=!1;function B0(){let r=0,e=i=>{let n=ne(1,1,null,{willReadFrequently:i}),s=0,o=performance.now();for(;performance.now()-o<50;++s)n.fillStyle=`rgba(255,0,${s%256},1)`,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1);return r=s>r?s:r,s};Xp={[e(!0)]:!0,[e(!1)]:!1,[e(void 0)]:void 0}[r],Yp=!0}var rd=class{constructor(e,t,i,n,s,o,a){this.maxExtent_=e,this.overlaps_=n,this.pixelRatio_=i,this.resolution_=t,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=ae(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(s,a)}clip(e,t){let i=this.getClipCoords(t);e.beginPath(),e.moveTo(i[0],i[1]),e.lineTo(i[2],i[3]),e.lineTo(i[4],i[5]),e.lineTo(i[6],i[7]),e.clip()}createExecutors_(e,t){for(let i in e){let n=this.executorsByZIndex_[i];n===void 0&&(n={},this.executorsByZIndex_[i]=n);let s=e[i];for(let o in s){let a=s[o];n[o]=new Vp(this.resolution_,this.pixelRatio_,this.overlaps_,a,t)}}}hasExecutors(e){for(let t in this.executorsByZIndex_){let i=this.executorsByZIndex_[t];for(let n=0,s=e.length;n<s;++n)if(e[n]in i)return!0}return!1}forEachFeatureAtCoordinate(e,t,i,n,s,o){Yp===!1&&B0(),n=Math.round(n);let a=n*2+1,l=Ae(this.hitDetectionTransform_,n+.5,n+.5,1/t,-1/t,-i,-e[0],-e[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=ne(a,a,null,{willReadFrequently:Xp}));let c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=me(),Yn(u,e),Le(u,t*(this.renderBuffer_+n),u));let d=z0(n),f;function g(T,v,S){let w=c.getImageData(0,0,a,a).data;for(let R=0,b=d.length;R<b;R++)if(w[d[R]]>0){if(!o||S==="none"||f!=="Image"&&f!=="Text"||o.includes(T)){let D=(d[R]-3)/4,G=n-D%a,O=n-(D/a|0),X=s(T,v,G*G+O*O);if(X)return X}c.clearRect(0,0,a,a);break}}let m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(_t);let p,_,x,y,E;for(p=m.length-1;p>=0;--p){let T=m[p].toString();for(x=this.executorsByZIndex_[T],_=zn.length-1;_>=0;--_)if(f=zn[_],y=x[f],y!==void 0&&(E=y.executeHitDetection(c,l,i,g,u),E))return E}}getClipCoords(e){let t=this.maxExtent_;if(!t)return null;let i=t[0],n=t[1],s=t[2],o=t[3],a=[i,n,i,o,s,o,s,n];return ut(a,0,8,2,e,a),a}isEmpty(){return wt(this.executorsByZIndex_)}execute(e,t,i,n,s,o,a){let l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?cg:_t),o=o||zn;let h=zn.length;for(let c=0,u=l.length;c<u;++c){let d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,m=o.length;g<m;++g){let p=o[g],_=f[p];if(_!==void 0){let x=a===null?void 0:_.getZIndexContext(),y=x?x.getContext():e,E=this.maxExtent_&&p!=="Image"&&p!=="Text";if(E&&(y.save(),this.clip(y,i)),!x||p==="Text"||p==="Image"?_.execute(y,t,i,n,s,a):x.pushFunction(T=>_.execute(T,t,i,n,s,a)),E&&y.restore(),x){x.offset();let T=l[c]*h+zn.indexOf(p);this.deferredZIndexContexts_[T]||(this.deferredZIndexContexts_[T]=[]),this.deferredZIndexContexts_[T].push(x)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(_t);for(let i=0,n=t.length;i<n;++i)e[t[i]].forEach(s=>{s.draw(this.renderedContext_),s.clear()}),e[t[i]].length=0}},nd={};function z0(r){if(nd[r]!==void 0)return nd[r];let e=r*2+1,t=r*r,i=new Array(t+1);for(let s=0;s<=r;++s)for(let o=0;o<=r;++o){let a=s*s+o*o;if(a>t)break;let l=i[a];l||(l=[],i[a]=l),l.push(((r+s)*e+(r+o))*4+3),s>0&&l.push(((r-s)*e+(r+o))*4+3),o>0&&(l.push(((r+s)*e+(r-o))*4+3),s>0&&l.push(((r-s)*e+(r-o))*4+3))}let n=[];for(let s=0,o=i.length;s<o;++s)i[s]&&n.push(...i[s]);return nd[r]=n,n}var El=rd;var sd=class extends xl{constructor(e,t,i,n,s,o,a){super(),this.context_=e,this.pixelRatio_=t,this.extent_=i,this.transform_=n,this.transformRotation_=n?hi(Math.atan2(n[1],n[0]),10):0,this.viewRotation_=s,this.squaredTolerance_=o,this.userTransform_=a,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_=ae()}drawImages_(e,t,i,n){if(!this.image_)return;let s=ut(e,t,i,n,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=s.length;c<u;c+=2){let d=s[c]-this.imageAnchorX_,f=s[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let g=d+this.imageAnchorX_,m=f+this.imageAnchorY_;Ae(a,g,m,1,1,h,-g,-m),o.save(),o.transform.apply(o,a),o.translate(g,m),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(e,t,i,n){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let s=ut(e,t,i,n,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);t<i;t+=n){let l=s[t]+this.textOffsetX_,h=s[t+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(e,t,i,n,s,o){let a=this.context_,l=ut(e,t,i,n,this.transform_,this.pixelCoordinates_);Math.abs(o)>0&&(l=Up(l,n,o,s,l)),a.moveTo(l[0],l[1]);let h=l.length;s&&(h-=2);for(let c=2;c<h;c+=2)a.lineTo(l[c],l[c+1]);return s&&a.closePath(),i}drawRings_(e,t,i,n,s){for(let o=0,a=i.length;o<a;++o)t=this.moveToLineTo_(e,t,i[o],n,!0,s);return t}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!te(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let t=lm(e,this.transform_,this.pixelCoordinates_),i=t[2]-t[0],n=t[3]-t[1],s=Math.sqrt(i*i+n*n),o=this.context_;o.beginPath(),o.arc(t[0],t[1],s,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.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 i=t.getGeometryFunction()(e);i&&(this.setStyle(t),this.drawGeometry(i))}drawGeometryCollection(e){let t=e.getGeometriesArray();for(let i=0,n=t.length;i<n;++i)this.drawGeometry(t[i])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getFlatCoordinates(),i=e.getStride();this.image_&&this.drawImages_(t,0,t.length,i),this.text_!==""&&this.drawText_(t,0,t.length,i)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let t=e.getFlatCoordinates(),i=e.getStride();this.image_&&this.drawImages_(t,0,t.length,i),this.text_!==""&&this.drawText_(t,0,t.length,i)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!te(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let t=this.context_,i=e.getFlatCoordinates();t.beginPath(),this.moveToLineTo_(i,0,i.length,e.getStride(),!1,this.strokeState_.strokeOffset),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(te(this.extent_,t)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let i=this.context_,n=e.getFlatCoordinates(),s=0,o=e.getEnds(),a=e.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)s=this.moveToLineTo_(n,s,o[l],a,!1,this.strokeState_.strokeOffset);i.stroke()}if(this.text_!==""){let i=e.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!te(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.strokeState_?.strokeOffset),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_)),!!te(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_,i=e.getOrientedFlatCoordinates(),n=0,s=e.getEndss(),o=e.getStride();t.beginPath();for(let a=0,l=s.length;a<l;++a){let h=s[a];n=this.drawRings_(i,n,h,o,this.strokeState_?.strokeOffset)}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_,i=this.contextFillState_;i?i.fillStyle!=e.fillStyle&&(i.fillStyle=e.fillStyle,t.fillStyle=e.fillStyle):(t.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let t=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=e.lineCap&&(i.lineCap=e.lineCap,t.lineCap=e.lineCap),Ve(i.lineDash,e.lineDash)||t.setLineDash(i.lineDash=e.lineDash),i.lineDashOffset!=e.lineDashOffset&&(i.lineDashOffset=e.lineDashOffset,t.lineDashOffset=e.lineDashOffset),i.lineJoin!=e.lineJoin&&(i.lineJoin=e.lineJoin,t.lineJoin=e.lineJoin),i.lineWidth!=e.lineWidth&&(i.lineWidth=e.lineWidth,t.lineWidth=e.lineWidth),i.miterLimit!=e.miterLimit&&(i.miterLimit=e.miterLimit,t.miterLimit=e.miterLimit),i.strokeStyle!=e.strokeStyle&&(i.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_,i=this.contextTextState_,n=e.textAlign?e.textAlign:Dn;i?(i.font!=e.font&&(i.font=e.font,t.font=e.font),i.textAlign!=n&&(i.textAlign=n,t.textAlign=n),i.textBaseline!=e.textBaseline&&(i.textBaseline=e.textBaseline,t.textBaseline=e.textBaseline)):(t.font=e.font,t.textAlign=n,t.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:n,textBaseline:e.textBaseline})}setFillStrokeStyle(e,t){if(!e)this.fillState_=null;else{let i=e.getColor();this.fillState_={fillStyle:Xt(i||it)}}if(!t)this.strokeState_=null;else{let i=t.getColor(),n=t.getLineCap(),s=t.getLineDash(),o=t.getLineDashOffset(),a=t.getLineJoin(),l=t.getWidth(),h=t.getMiterLimit(),c=s||Yt,u=t.getOffset();this.strokeState_={lineCap:n!==void 0?n:wi,lineDash:this.pixelRatio_===1?c:c.map(d=>d*this.pixelRatio_),lineDashOffset:(o||$t)*this.pixelRatio_,lineJoin:a!==void 0?a:Pi,lineWidth:(l!==void 0?l:tn)*this.pixelRatio_,miterLimit:h!==void 0?h:Ji,strokeStyle:Xt(i||Qi),strokeOffset:(u??0)*this.pixelRatio_}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}let i=e.getPixelRatio(this.pixelRatio_),n=e.getAnchor(),s=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=n[0]*i,this.imageAnchorY_=n[1]*i,this.imageHeight_=t[1]*i,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=s[0],this.imageOriginY_=s[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let o=e.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=t[0]*i}setTextStyle(e){if(!e)this.text_="";else{let t=e.getFill();if(!t)this.textFillState_=null;else{let f=t.getColor();this.textFillState_={fillStyle:Xt(f||it)}}let i=e.getStroke();if(!i)this.textStrokeState_=null;else{let f=i.getColor(),g=i.getLineCap(),m=i.getLineDash(),p=i.getLineDashOffset(),_=i.getLineJoin(),x=i.getWidth(),y=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:wi,lineDash:m||Yt,lineDashOffset:p||$t,lineJoin:_!==void 0?_:Pi,lineWidth:x!==void 0?x:tn,miterLimit:y!==void 0?y:Ji,strokeStyle:Xt(f||Qi)}}let n=e.getFont(),s=e.getOffsetX(),o=e.getOffsetY(),a=e.getRotateWithView(),l=e.getRotation(),h=e.getScaleArray(),c=e.getText(),u=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:n!==void 0?n:el,textAlign:u!==void 0?u:Dn,textBaseline:d!==void 0?d:sr},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,m)=>f+=m%2?" ":g,""):c:"",this.textOffsetX_=s!==void 0?this.pixelRatio_*s:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*h[0],this.pixelRatio_*h[1]]}}},Tl=sd;var At=.5;function Cl(r,e,t,i,n,s,o,a,l){let h=l?Vt(n,l):n,c=r[0]*At,u=r[1]*At,d=ne(c,u);d.imageSmoothingEnabled=!1;let f=d.canvas,g=new Tl(d,At,n,null,o,a,l?zt(we(),l):null),m=t.length,p=Math.floor((256*256*256-1)/m),_={};for(let y=1;y<=m;++y){let E=t[y-1],T=E.getStyleFunction()||i;if(!T)continue;let v=T(E,s);if(!v)continue;Array.isArray(v)||(v=[v]);let w=(y*p).toString(16).padStart(7,"#00000");for(let R=0,b=v.length;R<b;++R){let D=v[R],G=D.getGeometryFunction()(E);if(!G||!te(h,G.getExtent()))continue;let O=D.clone(),X=O.getFill();X&&X.setColor(w);let Q=O.getStroke();Q&&(Q.setColor(w),Q.setLineDash(null)),O.setText(void 0);let M=D.getImage();if(M){let H=M.getImageSize();if(!H)continue;let oe=ne(H[0],H[1],void 0,{alpha:!1}),de=oe.canvas;oe.fillStyle=w,oe.fillRect(0,0,de.width,de.height),O.setImage(new Eo({img:de,anchor:M.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:M.getOrigin(),opacity:1,size:M.getSize(),scale:M.getScale(),rotation:M.getRotation(),rotateWithView:M.getRotateWithView()}))}let Y=O.getZIndex()||0,U=_[Y];U||(U={},_[Y]=U,U.Polygon=[],U.Circle=[],U.LineString=[],U.Point=[]);let q=G.getType();if(q==="GeometryCollection"){let H=G.getGeometriesArrayRecursive();for(let oe=0,de=H.length;oe<de;++oe){let xe=H[oe];U[xe.getType().replace("Multi","")].push(xe,O)}}else U[q.replace("Multi","")].push(G,O)}}let x=Object.keys(_).map(Number).sort(_t);for(let y=0,E=x.length;y<E;++y){let T=_[x[y]];for(let v in T){let S=T[v];for(let w=0,R=S.length;w<R;w+=2){g.setStyle(S[w+1]);for(let b=0,D=e.length;b<D;++b)g.setTransform(e[b]),g.drawGeometry(S[w])}}}return d.getImageData(0,0,f.width,f.height)}function vl(r,e,t){let i=[];if(t){let n=Math.floor(Math.round(r[0])*At),s=Math.floor(Math.round(r[1])*At),o=(B(n,0,t.width-1)+B(s,0,t.height-1)*t.width)*4,a=t.data[o],l=t.data[o+1],c=t.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/e.length);c&&c%u===0&&i.push(e[c/u-1])}return i}var j0=.5,$p={Point:H0,LineString:Y0,Polygon:q0,MultiPoint:Z0,MultiLineString:$0,MultiPolygon:K0,GeometryCollection:X0,Circle:V0};function Kp(r,e){return parseInt(P(r),10)-parseInt(P(e),10)}function lr(r,e){let t=od(r,e);return t*t}function od(r,e){return j0*r/e}function V0(r,e,t,i,n){let s=t.getFill(),o=t.getStroke();if(s||o){let l=r.getBuilder(t.getZIndex(),"Circle");l.setFillStrokeStyle(s,o),l.drawCircle(e,i,n)}let a=t.getText();if(a&&a.getText()){let l=r.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,i)}}function ts(r,e,t,i,n,s,o,a){let l=[],h=t.getImage();if(h){let d=!0,f=h.getImageState();f==A.LOADED||f==A.ERROR?d=!1:f==A.IDLE&&h.load(),d&&l.push(h.ready())}let c=t.getFill();c&&c.loading()&&l.push(c.ready());let u=l.length>0;return u&&Promise.all(l).then(()=>n(null)),W0(r,e,t,i,s,o,a),u}function W0(r,e,t,i,n,s,o){let a=t.getGeometryFunction()(e);if(!a)return;let l=a.simplifyTransformed(i,n);if(t.getRenderer())Hp(r,l,t,e,o);else{let c=$p[l.getType()];c(r,l,t,e,o,s)}}function Hp(r,e,t,i,n){if(e.getType()=="GeometryCollection"){let o=e.getGeometries();for(let a=0,l=o.length;a<l;++a)Hp(r,o[a],t,i,n);return}r.getBuilder(t.getZIndex(),"Default").drawCustom(e,i,t.getRenderer(),t.getHitDetectionRenderer(),n)}function X0(r,e,t,i,n,s){let o=e.getGeometriesArray(),a,l;for(a=0,l=o.length;a<l;++a){let h=$p[o[a].getType()];h(r,o[a],t,i,n,s)}}function Y0(r,e,t,i,n){let s=t.getStroke();if(s){let a=r.getBuilder(t.getZIndex(),"LineString");a.setFillStrokeStyle(null,s),a.drawLineString(e,i,n)}let o=t.getText();if(o&&o.getText()){let a=r.getBuilder(t.getZIndex(),"Text");a.setTextStyle(o),a.drawText(e,i,n)}}function $0(r,e,t,i,n){let s=t.getStroke();if(s){let a=r.getBuilder(t.getZIndex(),"LineString");a.setFillStrokeStyle(null,s),a.drawMultiLineString(e,i,n)}let o=t.getText();if(o&&o.getText()){let a=r.getBuilder(t.getZIndex(),"Text");a.setTextStyle(o),a.drawText(e,i,n)}}function K0(r,e,t,i,n){let s=t.getFill(),o=t.getStroke();if(o||s){let l=r.getBuilder(t.getZIndex(),"Polygon");l.setFillStrokeStyle(s,o),l.drawMultiPolygon(e,i,n)}let a=t.getText();if(a&&a.getText()){let l=r.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,i,n)}}function H0(r,e,t,i,n,s){let o=t.getImage(),a=t.getText(),l=a&&a.getText(),h=s&&o&&l?{}:void 0;if(o){if(o.getImageState()!=A.LOADED)return;let c=r.getBuilder(t.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(e,i,n)}if(l){let c=r.getBuilder(t.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(e,i,n)}}function Z0(r,e,t,i,n,s){let o=t.getImage(),a=o&&o.getOpacity()!==0,l=t.getText(),h=l&&l.getText(),c=s&&a&&h?{}:void 0;if(a){if(o.getImageState()!=A.LOADED)return;let u=r.getBuilder(t.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(e,i,n)}if(h){let u=r.getBuilder(t.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(e,i,n)}}function q0(r,e,t,i,n){let s=t.getFill(),o=t.getStroke();if(s||o){let l=r.getBuilder(t.getZIndex(),"Polygon");l.setFillStrokeStyle(s,o),l.drawPolygon(e,i,n)}let a=t.getText();if(a&&a.getText()){let l=r.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,i,n)}}var ad=class extends Zr{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=me(),this.wrappedRenderedExtent_=me(),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,i){let n=t.extent,s=t.viewState,o=s.center,a=s.resolution,l=s.projection,h=s.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=t.pixelRatio,g=t.viewHints,m=!(g[he.ANIMATING]||g[he.INTERACTING]),p=this.context,_=Math.round(z(n)/a*f),x=Math.round(re(n)/a*f),y=u.getWrapX()&&l.canWrapX(),E=y?z(c):null,T=y?Math.ceil((n[2]-c[2])/E)+(this.extendX_?2:1):1,v=y?Math.floor((n[0]-c[0])/E)-(this.extendX_?1:0):0;do{let S=this.getRenderTransform(o,a,0,f,_,x,v*E);t.declutter&&(S=S.slice(0)),e.execute(p,[p.canvas.width,p.canvas.height],S,h,m,i===void 0?zn:i?es:Wp,i?d&&t.declutter[d]:void 0)}while(++v<T)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=ne(this.context.canvas.width,this.context.canvas.height,zu))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){let e=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=e,$i(this.context),zu.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.clipExtent_&&this.clipUnrotated(this.context,e,this.clipExtent_),this.replayGroup_.renderDeferred(),this.clipExtent_&&(this.context.restore(),this.clipExtent_=null),this.resetDrawContext_())}renderFrame(e,t){let i=e.layerStatesArray[e.layerIndex];this.opacity_=i.opacity;let n=e.viewState;this.prepareContainer(e,t);let s=this.context,o=this.replayGroup_,a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(ve.PRERENDER)||this.getLayer().hasListener(ve.POSTRENDER)))return this.container;this.setDrawContext_(),this.preRender(s,e);let l=n.projection;this.clipExtent_=null;let h=!1;if(a&&i.extent&&this.clipping){let c=Be(i.extent,l);a=te(c,e.extent),a&&!Ue(c,e.extent)&&(e.declutter?this.clipExtent_=c:(this.clipUnrotated(s,e,c),h=!0))}return a&&this.renderWorlds(o,e,this.getLayer().getDeclutter()?!1:void 0),h&&s.restore(),this.postRender(s,e),this.renderedRotation_!==n.rotation&&(this.renderedRotation_=n.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(t=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let i=this.frameState.size.slice(),n=this.renderedCenter_,s=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*At,d=i[1]*At;c.push(this.getRenderTransform(n,s,o,At,u,d,0).slice());let f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!Ue(g,l)){let p=l[0],_=z(g),x=0,y;for(;p<g[0];)--x,y=_*x,c.push(this.getRenderTransform(n,s,o,At,u,d,y).slice()),p+=_;for(x=0,p=l[2];p>g[2];)++x,y=_*x,c.push(this.getRenderTransform(n,s,o,At,u,d,y).slice()),p-=_}let m=we();this.hitDetectionImageData_=Cl(i,c,this.renderedFeatures_,h.getStyleFunction(),l,s,o,lr(s,this.renderedPixelRatio_),m?a:null)}t(vl(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,i,n,s){if(!this.replayGroup_)return;let o=t.viewState.resolution,a=t.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){let m=P(d),p=h[m];if(p){if(p!==!0&&g<p.distanceSq){if(g===0)return h[m]=!0,s.splice(s.lastIndexOf(p),1),n(d,l,f);p.geometry=f,p.distanceSq=g}}else{if(g===0)return h[m]=!0,n(d,l,f);s.push(h[m]={feature:d,layer:l,geometry:f,distanceSq:g,callback:n})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(e,o,a,i,c,u?t.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let t=this.getLayer(),i=t.getSource();if(!i)return!1;let n=e.viewHints[he.ANIMATING],s=e.viewHints[he.INTERACTING],o=t.getUpdateWhileAnimating(),a=t.getUpdateWhileInteracting();if(this.ready&&!o&&n||!a&&s)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let l=e.extent,h=e.viewState,c=h.projection,u=h.resolution,d=e.pixelRatio,f=t.getRevision(),g=t.getRenderBuffer(),m=t.getRenderOrder();m===void 0&&(m=Kp);let p=h.center.slice(),_=Le(l,g*u),x=_.slice(),y=[_.slice()],E=c.getExtent(),T=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,T){let M=i.getExtent();M&&!yt(M)&&(this.extendX_=M[0]<E[0]||M[2]>E[2])}if(T&&(!Ue(E,e.extent)||this.extendX_)){let M=z(E),Y=Math.max(z(_)/2,M),U=E[0],q=E[2];this.extendX_&&(U-=M,q+=M),_[0]=U-Y,_[2]=q+Y,En(p,c);let H=As(y[0],c);H[0]<E[0]&&H[2]<E[2]?y.push([H[0]+M,H[1],H[2]+M,H[3]]):H[0]>E[0]&&H[2]>E[2]&&y.push([H[0]-M,H[1],H[2]-M,H[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedPixelRatio_===d&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!e.declutter&&Ue(this.wrappedRenderedExtent_,_))return Ve(this.renderedExtent_,x)||(this.hitDetectionImageData_=null,this.renderedExtent_=x),this.renderedCenter_=p,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let v=new yl(od(u,d),_,u,d),S=we(),w;if(S){for(let M=0,Y=y.length;M<Y;++M){let U=y[M],q=Vt(U,c);i.loadFeatures(q,Ra(u,c),S)}w=zt(S,c)}else for(let M=0,Y=y.length;M<Y;++M)i.loadFeatures(y[M],u,c);let R=lr(u,d),b=!0,D=(M,Y)=>{let U,q=M.getStyleFunction()||t.getStyleFunction();if(q&&(U=q(M,u)),U){let H=this.renderFeature(M,R,U,v,w,this.getLayer().getDeclutter(),Y);b=b&&!H}},G=Vt(_,c),O=i.getFeaturesInExtent(G);m&&O.sort(m);for(let M=0,Y=O.length;M<Y;++M)D(O[M],M);this.renderedFeatures_=O,this.ready=b;let X=v.finish(),Q=new El(_,u,d,i.getOverlaps(),X,t.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=x,this.wrappedRenderedExtent_=_,this.renderedCenter_=p,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=Q,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,t,i,n,s,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=ts(n,e,i[h],t,this.boundHandleStyleImageChange_,s,o,a)||l;else l=ts(n,e,i,t,this.boundHandleStyleImageChange_,s,o,a);return l}},Zp=ad;var ld=class extends Li{constructor(e){super(e)}createRenderer(){return new Zp(this)}},gt=ld;var hd=class extends Zr{constructor(e){super(e),this.image=null,this.renderedSourceRevision_=0}getImage(){return this.image?this.image.getImage():null}prepareFrame(e){let t=e.layerStatesArray[e.layerIndex],i=e.pixelRatio,n=e.viewState,s=n.resolution,o=this.getLayer().getSource(),a=e.viewHints,l=e.extent;if(t.extent!==void 0&&(l=Xe(l,Be(t.extent,n.projection))),!a[he.ANIMATING]&&!a[he.INTERACTING]&&!yt(l))if(o){!this.getLayer().rendered&&this.renderedSourceRevision_!==o.getRevision()&&(this.image=null),this.renderedSourceRevision_=o.getRevision();let h=n.projection,c=o.getImage(l,s,i,h);c&&(this.loadImage(c)?this.image=c:c.getState()===A.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(e){let t=this.frameState;if(!t)return null;let i=this.getLayer(),n=le(t.pixelToCoordinateTransform,e.slice()),s=i.getExtent();if(s&&!rt(s,n))return null;let o=this.image.getExtent(),a=this.image.getImage(),l=z(o),h=Math.floor(a.width*((n[0]-o[0])/l));if(h<0||h>=a.width)return null;let c=re(o),u=Math.floor(a.height*((o[3]-n[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(e,t){let i=this.image,n=i.getExtent(),s=i.getResolution(),[o,a]=Array.isArray(s)?s:[s,s],l=i.getPixelRatio(),h=e.layerStatesArray[e.layerIndex],c=e.pixelRatio,u=e.viewState,d=u.center,f=u.resolution,g=c*o/(f*l),m=c*a/(f*l);this.prepareContainer(e,t);let p=this.context.canvas.width,_=this.context.canvas.height,x=this.getRenderContext(e),y=!1,E=!0;if(h.extent){let R=Be(h.extent,u.projection);E=te(R,e.extent),y=E&&!Ue(R,e.extent),y&&this.clipUnrotated(x,e,R)}let T=i.getImage(),v=Ae(this.tempTransform,p/2,_/2,g,m,0,l*(n[0]-d[0])/o,l*(d[1]-n[3])/a);this.renderedResolution=a*c/l;let S=T.width*v[0],w=T.height*v[3];if(this.getLayer().getSource().getInterpolate()||(x.imageSmoothingEnabled=!1),this.preRender(x,e),E&&S>=.5&&w>=.5){let R=v[4],b=v[5],D=h.opacity;D!==1&&(x.save(),x.globalAlpha=D),x.drawImage(T,0,0,+T.width,+T.height,R,b,S,w),D!==1&&x.restore()}return this.postRender(this.context,e),y&&x.restore(),x.imageSmoothingEnabled=!0,this.container}},qp=hd;var cd=class extends qi{constructor(e){e=e||{},super(e)}},Jp=cd;var ud=class extends Jp{constructor(e){super(e)}createRenderer(){return new qp(this)}getData(e){return super.getData(e)}},dd=ud;function Sl(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Lo(r,e){return r[0]=e[0],r[1]=e[1],r[4]=e[2],r[5]=e[3],r[12]=e[4],r[13]=e[5],r}var is=34962,bo=34963,e_=35040,t_=35044,ns=35048,i_=5121,n_=5123,r_=5125,fd=5126,Qp=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function s_(r,e){e=Object.assign({preserveDrawingBuffer:!0,antialias:!mg},e);let t=Qp.length;for(let i=0;i<t;++i)try{let n=r.getContext(Qp[i],e);if(n)return n}catch{}return null}var J0={STATIC_DRAW:t_,STREAM_DRAW:e_,DYNAMIC_DRAW:ns},gd=class{constructor(e,t){this.array_=null,this.type_=e,W(e===is||e===bo,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=t!==void 0?t:J0.STATIC_DRAW}ofSize(e){return this.array_=new(Rl(this.type_))(e),this}fromArray(e){return this.array_=Rl(this.type_).from(e),this}fromArrayBuffer(e){return this.array_=new(Rl(this.type_))(e),this}getType(){return this.type_}getArray(){return this.array_}setArray(e){let t=Rl(this.type_);if(!(e instanceof t))throw new Error(`Expected ${t}`);this.array_=e}getUsage(){return this.usage_}getSize(){return this.array_?this.array_.length:0}};function Rl(r){switch(r){case is:return Float32Array;case bo:return Uint32Array;default:return Float32Array}}var wl=gd;var Io={LOST:"webglcontextlost",RESTORED:"webglcontextrestored"};var Q0=`
7
+ precision mediump float;
8
+
9
+ attribute vec2 a_position;
10
+ varying vec2 v_texCoord;
11
+ varying vec2 v_screenCoord;
12
+
13
+ uniform vec2 u_screenSize;
14
+
15
+ void main() {
16
+ v_texCoord = a_position * 0.5 + 0.5;
17
+ v_screenCoord = v_texCoord * u_screenSize;
18
+ gl_Position = vec4(a_position, 0.0, 1.0);
19
+ }
20
+ `,eE=`
21
+ precision mediump float;
22
+
23
+ uniform sampler2D u_image;
24
+ uniform float u_opacity;
25
+
26
+ varying vec2 v_texCoord;
27
+
28
+ void main() {
29
+ gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;
30
+ }
31
+ `,md=class{constructor(e){this.gl_=e.webGlContext;let t=this.gl_;this.scaleRatio_=e.scaleRatio||1,this.renderTargetTexture_=t.createTexture(),this.renderTargetTextureSize_=null,this.frameBuffer_=t.createFramebuffer(),this.depthBuffer_=t.createRenderbuffer();let i=t.createShader(t.VERTEX_SHADER);t.shaderSource(i,e.vertexShader||Q0),t.compileShader(i);let n=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(n,e.fragmentShader||eE),t.compileShader(n),this.renderTargetProgram_=t.createProgram(),t.attachShader(this.renderTargetProgram_,i),t.attachShader(this.renderTargetProgram_,n),t.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=t.createBuffer();let s=[-1,-1,1,-1,-1,1,1,-1,1,1,-1,1];t.bindBuffer(t.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),t.bufferData(t.ARRAY_BUFFER,new Float32Array(s),t.STATIC_DRAW),this.renderTargetAttribLocation_=t.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],e.uniforms&&Object.keys(e.uniforms).forEach(o=>{this.uniforms_.push({value:e.uniforms[o],location:t.getUniformLocation(this.renderTargetProgram_,o)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(e){let t=this.getGL(),i=[t.drawingBufferWidth*this.scaleRatio_,t.drawingBufferHeight*this.scaleRatio_];if(t.bindFramebuffer(t.FRAMEBUFFER,this.getFrameBuffer()),t.bindRenderbuffer(t.RENDERBUFFER,this.getDepthBuffer()),t.viewport(0,0,i[0],i[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==i[0]||this.renderTargetTextureSize_[1]!==i[1]){this.renderTargetTextureSize_=i;let n=0,s=t.RGBA,o=0,a=t.RGBA,l=t.UNSIGNED_BYTE,h=null;t.bindTexture(t.TEXTURE_2D,this.renderTargetTexture_),t.texImage2D(t.TEXTURE_2D,n,s,i[0],i[1],o,a,l,h),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.renderTargetTexture_,0),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,i[0],i[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthBuffer_)}}apply(e,t,i,n){let s=this.getGL(),o=e.size;if(s.bindFramebuffer(s.FRAMEBUFFER,t?t.getFrameBuffer():null),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.renderTargetTexture_),!t){let l=P(s.canvas);if(!e.renderTargets[l]){let h=s.getContextAttributes();h&&h.preserveDrawingBuffer&&(s.clearColor(0,0,0,0),s.clearDepth(1),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT)),e.renderTargets[l]=!0}}s.disable(s.DEPTH_TEST),s.enable(s.BLEND),s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA),s.viewport(0,0,s.drawingBufferWidth,s.drawingBufferHeight),s.bindBuffer(s.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),s.useProgram(this.renderTargetProgram_),s.enableVertexAttribArray(this.renderTargetAttribLocation_),s.vertexAttribPointer(this.renderTargetAttribLocation_,2,s.FLOAT,!1,0,0),s.uniform2f(this.renderTargetUniformLocation_,o[0],o[1]),s.uniform1i(this.renderTargetTextureLocation_,0);let a=e.layerStatesArray[e.layerIndex].opacity;s.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(e),i&&i(s,e),s.drawArrays(s.TRIANGLES,0,6),n&&n(s,e)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(e){let t=this.getGL(),i,n=1;this.uniforms_.forEach(function(s){if(i=typeof s.value=="function"?s.value(e):s.value,i instanceof HTMLCanvasElement||i instanceof ImageData)s.texture||(s.texture=t.createTexture()),t.activeTexture(t[`TEXTURE${n}`]),t.bindTexture(t.TEXTURE_2D,s.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),i instanceof ImageData?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,i.width,i.height,0,t.UNSIGNED_BYTE,new Uint8Array(i.data)):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,i),t.uniform1i(s.location,n++);else if(Array.isArray(i))switch(i.length){case 2:t.uniform2f(s.location,i[0],i[1]);return;case 3:t.uniform3f(s.location,i[0],i[1],i[2]);return;case 4:t.uniform4f(s.location,i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&t.uniform1f(s.location,i)})}},pd=md;var Ai={PROJECTION_MATRIX:"u_projectionMatrix",SCREEN_TO_WORLD_MATRIX:"u_screenToWorldMatrix",TIME:"u_time",ZOOM:"u_zoom",RESOLUTION:"u_resolution",ROTATION:"u_rotation",VIEWPORT_SIZE_PX:"u_viewportSizePx",PIXEL_RATIO:"u_pixelRatio",HIT_DETECTION:"u_hitDetection"},$e={UNSIGNED_BYTE:i_,UNSIGNED_SHORT:n_,UNSIGNED_INT:r_,FLOAT:fd},Pl={};function o_(r){return"shared/"+r}var a_=0;function tE(){let r="unique/"+a_;return a_+=1,r}function iE(r){let e=Pl[r];if(!e){let t=document.createElement("canvas");t.width=1,t.height=1,t.style.position="absolute",t.style.left="0",e={users:0,context:s_(t)},Pl[r]=e}return e.users+=1,e.context}function nE(r){let e=Pl[r];if(!e||(e.users-=1,e.users>0))return;let t=e.context,i=t.getExtension("WEBGL_lose_context");i&&i.loseContext();let n=t.canvas;n.width=1,n.height=1,delete Pl[r]}var _d=class extends Ci{constructor(e){super(),e=e||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=e.canvasCacheKey?o_(e.canvasCacheKey):tE(),this.gl_=iE(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;let t=this.gl_.canvas;t.addEventListener(Io.LOST,this.boundHandleWebGLContextLost_),t.addEventListener(Io.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=ae(),this.offsetScaleMatrix_=ae(),this.tmpMat4_=Sl(),this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],e.uniforms&&this.setUniforms(e.uniforms),this.postProcessPasses_=e.postProcesses?e.postProcesses.map(i=>new pd({webGlContext:this.gl_,scaleRatio:i.scaleRatio,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,uniforms:i.uniforms})):[new pd({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now(),this.maxAttributeCount_=this.gl_.getParameter(this.gl_.MAX_VERTEX_ATTRIBS)}setUniforms(e){this.uniforms_=[],this.addUniforms(e)}addUniforms(e){for(let t in e)this.uniforms_.push({name:t,value:e[t]})}canvasCacheKeyMatches(e){return this.canvasCacheKey_===o_(e)}getExtension(e){if(e in this.extensionCache_)return this.extensionCache_[e];let t=this.gl_.getExtension(e);return this.extensionCache_[e]=t,t}getInstancedRenderingExtension_(){let e=this.getExtension("ANGLE_instanced_arrays");return W(!!e,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),e}bindBuffer(e){let t=this.gl_,i=P(e),n=this.bufferCache_[i];if(!n){let s=t.createBuffer();n={buffer:e,webGlBuffer:s},this.bufferCache_[i]=n}t.bindBuffer(e.getType(),n.webGlBuffer)}flushBufferData(e){let t=this.gl_;this.bindBuffer(e),t.bufferData(e.getType(),e.getArray(),e.getUsage())}deleteBuffer(e){let t=P(e);delete this.bufferCache_[t]}disposeInternal(){let e=this.gl_.canvas;e.removeEventListener(Io.LOST,this.boundHandleWebGLContextLost_),e.removeEventListener(Io.RESTORED,this.boundHandleWebGLContextRestored_),nE(this.canvasCacheKey_),delete this.gl_}prepareDraw(e,t,i){let n=this.gl_,s=this.getCanvas(),o=e.size,a=e.pixelRatio;(s.width!==o[0]*a||s.height!==o[1]*a)&&(s.width=o[0]*a,s.height=o[1]*a,s.style.width=o[0]+"px",s.style.height=o[1]+"px");for(let l=this.postProcessPasses_.length-1;l>=0;l--)this.postProcessPasses_[l].init(e);n.bindTexture(n.TEXTURE_2D,null),n.clearColor(0,0,0,0),n.depthRange(0,1),n.clearDepth(1),n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.ONE,t?n.ZERO:n.ONE_MINUS_SRC_ALPHA),i?(n.enable(n.DEPTH_TEST),n.depthFunc(n.LEQUAL)):n.disable(n.DEPTH_TEST)}bindFrameBuffer(e,t){let i=this.getGL();i.bindFramebuffer(i.FRAMEBUFFER,e),t&&i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0)}bindInitialFrameBuffer(){let e=this.getGL(),t=this.postProcessPasses_[0].getFrameBuffer();e.bindFramebuffer(e.FRAMEBUFFER,t);let i=this.postProcessPasses_[0].getRenderTargetTexture();e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,i,0)}bindTexture(e,t,i){let n=this.gl_;n.activeTexture(n.TEXTURE0+t),n.bindTexture(n.TEXTURE_2D,e),n.uniform1i(this.getUniformLocation(i),t)}bindAttribute(e,t,i){let n=this.getGL();this.bindBuffer(e);let s=this.getAttributeLocation(t);n.enableVertexAttribArray(s),n.vertexAttribPointer(s,i,n.FLOAT,!1,0,0)}prepareDrawToRenderTarget(e,t,i,n){let s=this.gl_,o=t.getSize();s.bindFramebuffer(s.FRAMEBUFFER,t.getFramebuffer()),s.bindRenderbuffer(s.RENDERBUFFER,t.getDepthbuffer()),s.viewport(0,0,o[0],o[1]),s.bindTexture(s.TEXTURE_2D,t.getTexture()),s.clearColor(0,0,0,0),s.depthRange(0,1),s.clearDepth(1),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT),s.enable(s.BLEND),s.blendFunc(s.ONE,i?s.ZERO:s.ONE_MINUS_SRC_ALPHA),n?(s.enable(s.DEPTH_TEST),s.depthFunc(s.LEQUAL)):s.disable(s.DEPTH_TEST)}drawElements(e,t){let i=this.gl_;this.getExtension("OES_element_index_uint");let n=i.UNSIGNED_INT,s=4,o=t-e,a=e*s;i.drawElements(i.TRIANGLES,o,n,a)}drawElementsInstanced(e,t,i){let n=this.gl_;this.getExtension("OES_element_index_uint");let s=this.getInstancedRenderingExtension_(),o=n.UNSIGNED_INT,a=4,l=t-e,h=e*a;s.drawElementsInstancedANGLE(n.TRIANGLES,l,o,h,i);for(let c=0;c<this.maxAttributeCount_;c++)s.vertexAttribDivisorANGLE(c,0)}finalizeDraw(e,t,i){for(let n=0,s=this.postProcessPasses_.length;n<s;n++)n===s-1?this.postProcessPasses_[n].apply(e,null,t,i):this.postProcessPasses_[n].apply(e,this.postProcessPasses_[n+1])}getCanvas(){return this.gl_.canvas}getGL(){return this.gl_}applyFrameState(e){let t=e.size,i=e.viewState.rotation,n=e.pixelRatio;this.setUniformFloatValue(Ai.TIME,(Date.now()-this.startTime_)*.001),this.setUniformFloatValue(Ai.ZOOM,e.viewState.zoom),this.setUniformFloatValue(Ai.RESOLUTION,e.viewState.resolution),this.setUniformFloatValue(Ai.PIXEL_RATIO,n),this.setUniformFloatVec2(Ai.VIEWPORT_SIZE_PX,[t[0],t[1]]),this.setUniformFloatValue(Ai.ROTATION,i)}applyHitDetectionUniform(e){let t=this.getUniformLocation(Ai.HIT_DETECTION);this.getGL().uniform1i(t,e?1:0),e&&this.setUniformFloatValue(Ai.PIXEL_RATIO,.5)}applyUniforms(e){let t=this.gl_,i,n=0;this.uniforms_.forEach(s=>{if(i=typeof s.value=="function"?s.value(e):s.value,i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof ImageData||i instanceof WebGLTexture){i instanceof WebGLTexture&&!s.texture?(s.prevValue=void 0,s.texture=i):s.texture||(s.prevValue=void 0,s.texture=t.createTexture()),this.bindTexture(s.texture,n,s.name),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE);let o=!(i instanceof HTMLImageElement)||i.complete;!(i instanceof WebGLTexture)&&o&&s.prevValue!==i&&(s.prevValue=i,t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,i)),n++}else if(Array.isArray(i)&&i.length===6)this.setUniformMatrixValue(s.name,Lo(this.tmpMat4_,i));else if(Array.isArray(i)&&i.length<=4)switch(i.length){case 2:t.uniform2f(this.getUniformLocation(s.name),i[0],i[1]);return;case 3:t.uniform3f(this.getUniformLocation(s.name),i[0],i[1],i[2]);return;case 4:t.uniform4f(this.getUniformLocation(s.name),i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&t.uniform1f(this.getUniformLocation(s.name),i)})}useProgram(e,t){this.disableAllAttributes_(),this.gl_.useProgram(e),this.currentProgram_=e,t&&(this.applyFrameState(t),this.applyUniforms(t))}compileShader(e,t){let i=this.gl_,n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}getProgram(e,t){let i=this.gl_,n=this.compileShader(e,i.FRAGMENT_SHADER),s=this.compileShader(t,i.VERTEX_SHADER),o=i.createProgram();if(i.attachShader(o,n),i.attachShader(o,s),i.linkProgram(o),!i.getShaderParameter(n,i.COMPILE_STATUS)){let a=`Fragment shader compilation failed: ${i.getShaderInfoLog(n)}`;throw new Error(a)}if(i.deleteShader(n),!i.getShaderParameter(s,i.COMPILE_STATUS)){let a=`Vertex shader compilation failed: ${i.getShaderInfoLog(s)}`;throw new Error(a)}if(i.deleteShader(s),!i.getProgramParameter(o,i.LINK_STATUS)){let a=`GL program linking failed: ${i.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(e){let t=P(this.currentProgram_);return this.uniformLocationsByProgram_[t]===void 0&&(this.uniformLocationsByProgram_[t]={}),this.uniformLocationsByProgram_[t][e]===void 0&&(this.uniformLocationsByProgram_[t][e]=this.gl_.getUniformLocation(this.currentProgram_,e)),this.uniformLocationsByProgram_[t][e]}getAttributeLocation(e){let t=P(this.currentProgram_);return this.attribLocationsByProgram_[t]===void 0&&(this.attribLocationsByProgram_[t]={}),this.attribLocationsByProgram_[t][e]===void 0&&(this.attribLocationsByProgram_[t][e]=this.gl_.getAttribLocation(this.currentProgram_,e)),this.attribLocationsByProgram_[t][e]}makeProjectionTransform(e,t){let i=e.size,n=e.viewState.rotation,s=e.viewState.resolution,o=e.viewState.center;return Ae(t,0,0,2/(s*i[0]),2/(s*i[1]),-n,-o[0],-o[1]),t}setUniformFloatValue(e,t){this.gl_.uniform1f(this.getUniformLocation(e),t)}setUniformFloatVec2(e,t){this.gl_.uniform2fv(this.getUniformLocation(e),t)}setUniformFloatVec4(e,t){this.gl_.uniform4fv(this.getUniformLocation(e),t)}setUniformMatrixValue(e,t){this.gl_.uniformMatrix4fv(this.getUniformLocation(e),!1,t)}disableAllAttributes_(){for(let e=0;e<this.maxAttributeCount_;e++)this.gl_.disableVertexAttribArray(e)}enableAttributeArray_(e,t,i,n,s,o){let a=this.getAttributeLocation(e);a<0||(this.gl_.enableVertexAttribArray(a),this.gl_.vertexAttribPointer(a,t,i,!1,n,s),o&&this.getInstancedRenderingExtension_().vertexAttribDivisorANGLE(a,1))}enableAttributes_(e,t){let i=rE(e),n=0;for(let s=0;s<e.length;s++){let o=e[s];o.name&&this.enableAttributeArray_(o.name,o.size,o.type||fd,i,n,t),n+=o.size*l_(o.type)}}enableAttributes(e){this.enableAttributes_(e,!1)}enableAttributesInstanced(e){this.enableAttributes_(e,!0)}handleWebGLContextLost(e){Dt(this.bufferCache_),this.currentProgram_=null,e.preventDefault()}handleWebGLContextRestored(){this.needsToBeRecreated_=!0}needsToBeRecreated(){return this.needsToBeRecreated_}createTexture(e,t,i,n){let s=this.gl_;i=i||s.createTexture();let o=n?s.NEAREST:s.LINEAR;s.bindTexture(s.TEXTURE_2D,i),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,o),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,o),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE);let a=0,l=s.RGBA,h=0,c=s.RGBA,u=s.UNSIGNED_BYTE;return t instanceof Uint8Array?s.texImage2D(s.TEXTURE_2D,a,l,e[0],e[1],h,c,u,t):t?s.texImage2D(s.TEXTURE_2D,a,l,c,u,t):s.texImage2D(s.TEXTURE_2D,a,l,e[0],e[1],h,c,u,null),i}};function rE(r){let e=0;for(let t=0;t<r.length;t++){let i=r[t];e+=i.size*l_(i.type)}return e}function l_(r){switch(r){case $e.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case $e.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case $e.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case $e.FLOAT:default:return Float32Array.BYTES_PER_ELEMENT}}var h_=_d;var xd=class r extends pl{constructor(e,t){super(e),t=t||{},this.inversePixelTransform_=ae(),this.postProcesses_=t.postProcesses,this.uniforms_=t.uniforms,this.helper,this.onMapChanged_=()=>{this.clearCache(),this.removeHelper()},e.addChangeListener(se.MAP,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(e,t){let i=this.getLayer();if(i.hasListener(ve.PRECOMPOSE)){let n=new Nn(ve.PRECOMPOSE,void 0,t,e);i.dispatchEvent(n)}}dispatchPostComposeEvent(e,t){let i=this.getLayer();if(i.hasListener(ve.POSTCOMPOSE)){let n=new Nn(ve.POSTCOMPOSE,void 0,t,e);i.dispatchEvent(n)}}reset(e){this.uniforms_=e.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(e){if(this.getLayer().getRenderSource()){let t=!0,i=-1,n;for(let o=0,a=e.layerStatesArray.length;o<a;o++){let l=e.layerStatesArray[o].layer,h=l.getRenderer();if(!(h instanceof r)){t=!0;continue}let c=l.getClassName();if((t||c!==n)&&(i+=1,t=!1),n=c,h===this)break}let s="map/"+e.mapId+"/group/"+i;(!this.helper||!this.helper.canvasCacheKeyMatches(s)||this.helper.needsToBeRecreated())&&(this.removeHelper(),this.helper=new h_({postProcesses:this.postProcesses_,uniforms:this.uniforms_,canvasCacheKey:s}),n&&(this.helper.getCanvas().className=n),this.afterHelperCreated())}return this.prepareFrameInternal(e)}afterHelperCreated(){}prepareFrameInternal(e){return!0}clearCache(){}disposeInternal(){this.clearCache(),this.removeHelper(),this.getLayer()?.removeChangeListener(se.MAP,this.onMapChanged_),super.disposeInternal()}dispatchRenderEvent_(e,t,i){let n=this.getLayer();if(n.hasListener(e)){Ae(this.inversePixelTransform_,0,0,i.pixelRatio,-i.pixelRatio,0,0,-i.size[1]);let s=new Nn(e,this.inversePixelTransform_,i,t);n.dispatchEvent(s)}}preRender(e,t){this.dispatchRenderEvent_(ve.PRERENDER,e,t)}postRender(e,t){this.dispatchRenderEvent_(ve.POSTRENDER,e,t)}},c_=xd;var u_={TILE_TRANSFORM:"u_tileTransform",TRANSITION_ALPHA:"u_transitionAlpha",DEPTH:"u_depth",RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",RESOLUTION:"u_resolution",ZOOM:"u_zoom",GLOBAL_ALPHA:"u_globalAlpha",PROJECTION_MATRIX:"u_projectionMatrix",SCREEN_TO_WORLD_MATRIX:"u_screenToWorldMatrix"};var Ll={...u_,TILE_TEXTURE_ARRAY:"u_tileTextures",TEXTURE_PIXEL_WIDTH:"u_texturePixelWidth",TEXTURE_PIXEL_HEIGHT:"u_texturePixelHeight",TEXTURE_RESOLUTION:"u_textureResolution",TEXTURE_ORIGIN_X:"u_textureOriginX",TEXTURE_ORIGIN_Y:"u_textureOriginY"},sE={TEXTURE_COORD:"a_textureCoord"},iO=[{name:sE.TEXTURE_COORD,size:2,type:$e.FLOAT}];var yd=class{constructor(e,t){this.name=e,this.data=t,this.texture_=null}getTexture(e){if(!this.texture_){let t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.data.length/4,1,0,e.RGBA,e.UNSIGNED_BYTE,this.data),this.texture_=t}return this.texture_}delete(e){this.texture_&&e.deleteTexture(this.texture_),this.texture_=null}},d_=yd;function oE(r,e){return`operator_${r}_${Object.keys(e.functions).length}`}function hn(r){let e=r.toString();return e.includes(".")?e:e+".0"}function Cd(r){if(r.length<2||r.length>4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${r.length}(${r.map(hn).join(", ")})`}function Fo(r){let e=tt(r),t=e.length>3?e[3]:1;return Cd([e[0]/255,e[1]/255,e[2]/255,t])}function aE(r){let e=Ee(r);return Cd(e)}var Ed={},lE=0;function hr(r){return r in Ed||(Ed[r]=lE++),Ed[r]}function _i(r){return hn(hr(r))}function bl(r){return"u_var_"+r}function Il(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}var Td="getBandValue",hE="u_paletteTextures",vd="featureId",Sd="geometryType",Fl=-9999999;function f_(r,e,t,i){let n=Ye(r,e,t);return Rd(n,e,i)}function ue(r){return(e,t,i)=>{let n=t.args.length,s=new Array(n);for(let o=0;o<n;++o)s[o]=Rd(t.args[o],i,e);return r(s,e)}}var cE={[C.Get]:(r,e)=>{let i=e.args[0].value;i in r.properties||(r.properties[i]={name:i,type:e.type});let s="a_prop_"+i;return gi(e.type,Me)&&(s=`(${s} > 0.0)`),s},[C.Id]:r=>(r.featureId=!0,"a_"+vd),[C.GeometryType]:r=>(r.geometryType=!0,"a_"+Sd),[C.LineMetric]:()=>"currentLineMetric",[C.Var]:(r,e)=>{let i=e.args[0].value;i in r.variables||(r.variables[i]={name:i,type:e.type});let s=bl(i);return gi(e.type,Me)&&(s=`(${s} > 0.0)`),s},[C.Has]:(r,e)=>{let i=e.args[0].value;return i in r.properties||(r.properties[i]={name:i,type:e.type}),`(a_prop_${i} != ${hn(Fl)})`},[C.Resolution]:()=>"u_resolution",[C.Zoom]:()=>"u_zoom",[C.Time]:()=>"u_time",[C.Any]:ue(r=>`(${r.join(" || ")})`),[C.All]:ue(r=>`(${r.join(" && ")})`),[C.Not]:ue(([r])=>`(!${r})`),[C.Equal]:ue(([r,e])=>`(${r} == ${e})`),[C.NotEqual]:ue(([r,e])=>`(${r} != ${e})`),[C.GreaterThan]:ue(([r,e])=>`(${r} > ${e})`),[C.GreaterThanOrEqualTo]:ue(([r,e])=>`(${r} >= ${e})`),[C.LessThan]:ue(([r,e])=>`(${r} < ${e})`),[C.LessThanOrEqualTo]:ue(([r,e])=>`(${r} <= ${e})`),[C.Multiply]:ue(r=>`(${r.join(" * ")})`),[C.Divide]:ue(([r,e])=>`(${r} / ${e})`),[C.Add]:ue(r=>`(${r.join(" + ")})`),[C.Subtract]:ue(([r,e])=>`(${r} - ${e})`),[C.Clamp]:ue(([r,e,t])=>`clamp(${r}, ${e}, ${t})`),[C.Mod]:ue(([r,e])=>`mod(${r}, ${e})`),[C.Pow]:ue(([r,e])=>`pow(${r}, ${e})`),[C.Abs]:ue(([r])=>`abs(${r})`),[C.Floor]:ue(([r])=>`floor(${r})`),[C.Ceil]:ue(([r])=>`ceil(${r})`),[C.Round]:ue(([r])=>`floor(${r} + 0.5)`),[C.Sin]:ue(([r])=>`sin(${r})`),[C.Cos]:ue(([r])=>`cos(${r})`),[C.Atan]:ue(([r,e])=>e!==void 0?`atan(${r}, ${e})`:`atan(${r})`),[C.Sqrt]:ue(([r])=>`sqrt(${r})`),[C.Match]:ue(r=>{let e=r[0],t=r[r.length-1],i=null;for(let n=r.length-3;n>=1;n-=2){let s=r[n],o=r[n+1];i=`(${e} == ${s} ? ${o} : ${i||t})`}return i}),[C.Between]:ue(([r,e,t])=>`(${r} >= ${e} && ${r} <= ${t})`),[C.Interpolate]:ue(([r,e,...t])=>{let i="";for(let n=0;n<t.length-2;n+=2){let s=t[n],o=i||t[n+1],a=t[n+2],l=t[n+3],h;r===hn(1)?h=`(${e} - ${s}) / (${a} - ${s})`:h=`(pow(${r}, (${e} - ${s})) - 1.0) / (pow(${r}, (${a} - ${s})) - 1.0)`,i=`mix(${o}, ${l}, clamp(${h}, 0.0, 1.0))`}return i}),[C.Case]:ue(r=>{let e=r[r.length-1],t=null;for(let i=r.length-3;i>=0;i-=2){let n=r[i],s=r[i+1];t=`(${n} ? ${s} : ${t||e})`}return t}),[C.In]:ue(([r,...e],t)=>{let i=oE("in",t),n=[];for(let s=0;s<e.length;s+=1)n.push(` if (inputValue == ${e[s]}) { return true; }`);return t.functions[i]=`bool ${i}(float inputValue) {
32
+ ${n.join(`
33
+ `)}
34
+ return false;
35
+ }`,`${i}(${r})`}),[C.Array]:ue(r=>`vec${r.length}(${r.join(", ")})`),[C.Color]:ue(r=>{if(r.length===1)return`vec4(vec3(${r[0]} / 255.0), 1.0)`;if(r.length===2)return`vec4(vec3(${r[0]} / 255.0), ${r[1]})`;let e=r.slice(0,3).map(i=>`${i} / 255.0`);if(r.length===3)return`vec4(${e.join(", ")}, 1.0)`;let t=r[3];return`vec4(${e.join(", ")}, ${t})`}),[C.Band]:ue(([r,e,t],i)=>{if(!(Td in i.functions)){let n="",s=i.bandCount||1;for(let o=0;o<s;o++){let a=Math.floor(o/4),l=o%4;o===s-1&&l===1&&(l=3);let h=`${Ll.TILE_TEXTURE_ARRAY}[${a}]`;n+=` if (band == ${o+1}.0) {
36
+ return texture2D(${h}, v_textureCoord + vec2(dx, dy))[${l}];
37
+ }
38
+ `}i.functions[Td]=`float getBandValue(float band, float xOffset, float yOffset) {
39
+ float dx = xOffset / ${Ll.TEXTURE_PIXEL_WIDTH};
40
+ float dy = yOffset / ${Ll.TEXTURE_PIXEL_HEIGHT};
41
+ ${n}
42
+ }`}return`${Td}(${r}, ${e??"0.0"}, ${t??"0.0"})`}),[C.Palette]:(r,e)=>{let[t,...i]=e.args,n=i.length,s=new Uint8Array(n*4);for(let h=0;h<i.length;h++){let c=i[h].value,u=tt(c),d=h*4;s[d]=u[0],s[d+1]=u[1],s[d+2]=u[2],s[d+3]=u[3]*255}r.paletteTextures||(r.paletteTextures=[]);let o=`${hE}[${r.paletteTextures.length}]`,a=new d_(o,s);r.paletteTextures.push(a);let l=Rd(t,N,r);return`texture2D(${o}, vec2((${l} + 0.5) / ${n}.0, 0.5))`}};function Rd(r,e,t){if(r instanceof go){let i=cE[r.operator];if(i===void 0)throw new Error(`No compiler defined for this operator: ${JSON.stringify(r.operator)}`);return i(t,r,e)}if((r.type&N)>0)return hn(r.value);if((r.type&Me)>0)return r.value.toString();if((r.type&Ne)>0)return _i(r.value.toString());if((r.type&pe)>0)return Fo(r.value);if((r.type&at)>0)return Cd(r.value);if((r.type&Ft)>0)return aE(r.value);throw new Error(`Unexpected expression ${r.value} (expected type ${ir(e)})`)}function g_(){return{"fill-color":"rgba(255,255,255,0.4)","stroke-color":"#3399CC","stroke-width":1.25,"circle-radius":5,"circle-fill-color":"rgba(255,255,255,0.4)","circle-stroke-width":1.25,"circle-stroke-color":"#3399CC"}}var wd=.985;function Z(r,e,t){let i=mo();return f_(e,t,i,r)}function uE(r){let e=tt(r),t=e[0]*256,i=e[1],n=e[2]*256,s=Math.round(e[3]*255);return[t+i,n+s]}var m_=`vec4 unpackColor(vec2 packedColor) {
43
+ return vec4(
44
+ min(floor(packedColor[0] / 256.0) / 255.0, 1.0),
45
+ min(mod(packedColor[0], 256.0) / 255.0, 1.0),
46
+ min(floor(packedColor[1] / 256.0) / 255.0, 1.0),
47
+ min(mod(packedColor[1], 256.0) / 255.0, 1.0)
48
+ );
49
+ }`;function Al(r){return r===pe||r===Ft?2:r===at?4:1}function Ml(r){let e=Al(r);return e>1?`vec${e}`:"float"}function Ol(r,e){for(let t in e.variables){let i=e.variables[t],n=bl(i.name),s=Ml(i.type);i.type===pe&&(s="vec4"),r.addUniform(n,s)}for(let t in e.properties){let i=e.properties[t],n=Ml(i.type),s=`a_prop_${i.name}`;i.type===pe?r.addAttribute(s,n,`unpackColor(${s})`,"vec4"):r.addAttribute(s,n)}for(let t in e.functions)r.addVertexShaderFunction(e.functions[t]),r.addFragmentShaderFunction(e.functions[t])}function Dl(r,e){let t={};for(let i in r.variables){let n=r.variables[i],s=bl(n.name);t[s]=()=>{let o=e[n.name];if(typeof o=="number")return o;if(typeof o=="boolean")return o?1:0;if(n.type===pe){let a=[...tt(o||"#eee")];return a[0]/=255,a[1]/=255,a[2]/=255,a[3]??=1,a}return typeof o=="string"?hr(o):o}}return t}function kl(r){let e={};for(let t in r.properties){let i=r.properties[t],n=s=>{let o=s.get(i.name);return i.type===pe?uE([...tt(o||"#eee")]):typeof o=="string"?hr(o):typeof o=="boolean"?o?1:0:o};e[`prop_${i.name}`]={size:Al(i.type),callback:n}}return e}var rs=`#ifdef GL_FRAGMENT_PRECISION_HIGH
50
+ precision highp float;
51
+ #else
52
+ precision mediump float;
53
+ #endif
54
+ uniform mat4 u_projectionMatrix;
55
+ uniform mat4 u_screenToWorldMatrix;
56
+ uniform vec2 u_viewportSizePx;
57
+ uniform float u_pixelRatio;
58
+ uniform float u_globalAlpha;
59
+ uniform float u_time;
60
+ uniform float u_zoom;
61
+ uniform float u_resolution;
62
+ uniform float u_rotation;
63
+ uniform vec4 u_renderExtent;
64
+ uniform vec2 u_patternOrigin;
65
+ uniform float u_depth;
66
+ uniform mediump int u_hitDetection;
67
+
68
+ const float PI = 3.141592653589793238;
69
+ const float TWO_PI = 2.0 * PI;
70
+ float currentLineMetric = 0.; // an actual value will be used in the stroke shaders
71
+
72
+ ${m_}
73
+ `,ss=g_(),os=class{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${hn(ss["circle-radius"])} + ${hn(ss["circle-stroke-width"]*.5)})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=Fo(ss["circle-fill-color"]),this.texCoordExpression_="vec4(0.0, 0.0, 1.0, 1.0)",this.discardExpression_="false",this.symbolRotateWithView_=!1,this.hasStroke_=!1,this.strokeWidthExpression_=hn(ss["stroke-width"]),this.strokeColorExpression_=Fo(ss["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=_i("round"),this.strokeJoinExpression_=_i("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=Fo(ss["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(e,t){return this.uniforms_.push({name:e,type:t}),this}addAttribute(e,t,i,n){return this.attributes_.push({name:e,type:t,varyingName:e.replace(/^a_/,"v_"),varyingType:n??t,varyingExpression:i??e}),this}setSymbolSizeExpression(e){return this.hasSymbol_=!0,this.symbolSizeExpression_=e,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(e){return this.symbolRotationExpression_=e,this}setSymbolOffsetExpression(e){return this.symbolOffsetExpression_=e,this}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}setSymbolColorExpression(e){return this.hasSymbol_=!0,this.symbolColorExpression_=e,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(e){return this.texCoordExpression_=e,this}setFragmentDiscardExpression(e){return this.discardExpression_=e,this}getFragmentDiscardExpression(){return this.discardExpression_}setSymbolRotateWithView(e){return this.symbolRotateWithView_=e,this}setStrokeWidthExpression(e){return this.hasStroke_=!0,this.strokeWidthExpression_=e,this}setStrokeColorExpression(e){return this.hasStroke_=!0,this.strokeColorExpression_=e,this}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(e){return this.strokeOffsetExpression_=e,this}setStrokeCapExpression(e){return this.strokeCapExpression_=e,this}setStrokeJoinExpression(e){return this.strokeJoinExpression_=e,this}setStrokeMiterLimitExpression(e){return this.strokeMiterLimitExpression_=e,this}setStrokeDistanceFieldExpression(e){return this.strokeDistanceFieldExpression_=e,this}setStrokePatternLengthExpression(e){return this.strokePatternLengthExpression_=e,this}getStrokePatternLengthExpression(){return this.strokePatternLengthExpression_}setFillColorExpression(e){return this.hasFill_=!0,this.fillColorExpression_=e,this}getFillColorExpression(){return this.fillColorExpression_}addVertexShaderFunction(e){return this.vertexShaderFunctions_.includes(e)?this:(this.vertexShaderFunctions_.push(e),this)}addFragmentShaderFunction(e){return this.fragmentShaderFunctions_.includes(e)?this:(this.fragmentShaderFunctions_.push(e),this)}getSymbolVertexShader(){return this.hasSymbol_?`${rs}
74
+ ${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
75
+ `)}
76
+ attribute vec2 a_position;
77
+ attribute vec2 a_localPosition;
78
+ attribute vec2 a_hitColor;
79
+
80
+ varying vec2 v_texCoord;
81
+ varying vec2 v_quadCoord;
82
+ varying vec4 v_hitColor;
83
+ varying vec2 v_centerPx;
84
+ varying float v_angle;
85
+ varying vec2 v_quadSizePx;
86
+
87
+ ${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
88
+ varying ${e.varyingType} ${e.varyingName};`).join(`
89
+ `)}
90
+ ${this.vertexShaderFunctions_.join(`
91
+ `)}
92
+ vec2 pxToScreen(vec2 coordPx) {
93
+ vec2 scaled = coordPx / u_viewportSizePx / 0.5;
94
+ return scaled;
95
+ }
96
+
97
+ vec2 screenToPx(vec2 coordScreen) {
98
+ return (coordScreen * 0.5 + 0.5) * u_viewportSizePx;
99
+ }
100
+
101
+ void main(void) {
102
+ v_quadSizePx = ${this.symbolSizeExpression_};
103
+ vec2 halfSizePx = v_quadSizePx * 0.5;
104
+ vec2 centerOffsetPx = ${this.symbolOffsetExpression_};
105
+ vec2 offsetPx = centerOffsetPx + a_localPosition * halfSizePx * vec2(1., -1.);
106
+ float angle = ${this.symbolRotationExpression_}${this.symbolRotateWithView_?" + u_rotation":""};
107
+ float c = cos(-angle);
108
+ float s = sin(-angle);
109
+ offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);
110
+ vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);
111
+ gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);
112
+ vec4 texCoord = ${this.texCoordExpression_};
113
+ float u = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);
114
+ float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);
115
+ v_texCoord = vec2(u, v);
116
+ v_hitColor = unpackColor(a_hitColor);
117
+ v_angle = angle;
118
+ c = cos(-v_angle);
119
+ s = sin(-v_angle);
120
+ centerOffsetPx = vec2(c * centerOffsetPx.x - s * centerOffsetPx.y, s * centerOffsetPx.x + c * centerOffsetPx.y);
121
+ v_centerPx = screenToPx(center.xy) + centerOffsetPx;
122
+ ${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
123
+ `)}
124
+ }`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${rs}
125
+ ${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
126
+ `)}
127
+ varying vec2 v_texCoord;
128
+ varying vec4 v_hitColor;
129
+ varying vec2 v_centerPx;
130
+ varying float v_angle;
131
+ varying vec2 v_quadSizePx;
132
+ ${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
133
+ `)}
134
+ ${this.fragmentShaderFunctions_.join(`
135
+ `)}
136
+
137
+ void main(void) {
138
+ ${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
139
+ `)}
140
+ if (${this.discardExpression_}) { discard; }
141
+ vec2 coordsPx = gl_FragCoord.xy / u_pixelRatio - v_centerPx; // relative to center
142
+ float c = cos(v_angle);
143
+ float s = sin(v_angle);
144
+ coordsPx = vec2(c * coordsPx.x - s * coordsPx.y, s * coordsPx.x + c * coordsPx.y);
145
+ gl_FragColor = ${this.symbolColorExpression_};
146
+ gl_FragColor.rgb *= gl_FragColor.a;
147
+ if (u_hitDetection > 0) {
148
+ if (gl_FragColor.a < 0.05) { discard; };
149
+ gl_FragColor = v_hitColor;
150
+ }
151
+ }`:null}getStrokeVertexShader(){return this.hasStroke_?`${rs}
152
+ ${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
153
+ `)}
154
+ attribute vec2 a_segmentStart;
155
+ attribute vec2 a_segmentEnd;
156
+ attribute vec2 a_localPosition;
157
+ attribute float a_measureStart;
158
+ attribute float a_measureEnd;
159
+ attribute float a_angleTangentSum;
160
+ attribute float a_distanceLow;
161
+ attribute float a_distanceHigh;
162
+ attribute vec2 a_joinAngles;
163
+ attribute vec2 a_hitColor;
164
+
165
+ varying vec2 v_segmentStartPx;
166
+ varying vec2 v_segmentEndPx;
167
+ varying float v_angleStart;
168
+ varying float v_angleEnd;
169
+ varying float v_width;
170
+ varying vec4 v_hitColor;
171
+ varying float v_distancePx;
172
+ varying float v_measureStart;
173
+ varying float v_measureEnd;
174
+
175
+ ${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
176
+ varying ${e.varyingType} ${e.varyingName};`).join(`
177
+ `)}
178
+ ${this.vertexShaderFunctions_.join(`
179
+ `)}
180
+ vec2 worldToPx(vec2 worldPos) {
181
+ vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
182
+ return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
183
+ }
184
+
185
+ vec4 pxToScreen(vec2 pxPos) {
186
+ vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
187
+ return vec4(screenPos, u_depth, 1.0);
188
+ }
189
+
190
+ bool isCap(float joinAngle) {
191
+ return joinAngle < -0.1;
192
+ }
193
+
194
+ vec2 getJoinOffsetDirection(vec2 normalPx, float joinAngle) {
195
+ float halfAngle = joinAngle / 2.0;
196
+ float c = cos(halfAngle);
197
+ float s = sin(halfAngle);
198
+ vec2 angleBisectorNormal = vec2(s * normalPx.x + c * normalPx.y, -c * normalPx.x + s * normalPx.y);
199
+ float length = 1.0 / s;
200
+ return angleBisectorNormal * length;
201
+ }
202
+
203
+ vec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {
204
+ // if on a cap or the join angle is too high, offset the line along the segment normal
205
+ if (cos(joinAngle) > 0.998 || isCap(joinAngle)) {
206
+ return point - normal * offsetPx;
207
+ }
208
+ // offset is applied along the inverted normal (positive offset goes "right" relative to line direction)
209
+ return point - getJoinOffsetDirection(normal, joinAngle) * offsetPx;
210
+ }
211
+
212
+ void main(void) {
213
+ v_angleStart = a_joinAngles.x;
214
+ v_angleEnd = a_joinAngles.y;
215
+ float startEndRatio = a_localPosition.x * 0.5 + 0.5;
216
+ currentLineMetric = mix(a_measureStart, a_measureEnd, startEndRatio);
217
+ // we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)
218
+
219
+ float lineWidth = ${this.strokeWidthExpression_};
220
+ float lineOffsetPx = ${this.strokeOffsetExpression_};
221
+
222
+ // compute segment start/end in px with offset
223
+ vec2 segmentStartPx = worldToPx(a_segmentStart);
224
+ vec2 segmentEndPx = worldToPx(a_segmentEnd);
225
+ vec2 tangentPx = normalize(segmentEndPx - segmentStartPx);
226
+ vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);
227
+ segmentStartPx = getOffsetPoint(segmentStartPx, normalPx, v_angleStart, lineOffsetPx),
228
+ segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);
229
+
230
+ // compute current vertex position
231
+ float normalDir = -1. * a_localPosition.y;
232
+ float tangentDir = -1. * a_localPosition.x;
233
+ float angle = mix(v_angleStart, v_angleEnd, startEndRatio);
234
+ vec2 joinDirection;
235
+ vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);
236
+ // if angle is too high, do not make a proper join
237
+ if (cos(angle) > ${wd} || isCap(angle)) {
238
+ joinDirection = normalPx * normalDir - tangentPx * tangentDir;
239
+ } else {
240
+ joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);
241
+ }
242
+ positionPx = positionPx + joinDirection * (lineWidth * 0.5 + 1.); // adding 1 pixel for antialiasing
243
+ gl_Position = pxToScreen(positionPx);
244
+
245
+ v_segmentStartPx = segmentStartPx;
246
+ v_segmentEndPx = segmentEndPx;
247
+ v_width = lineWidth;
248
+ v_hitColor = unpackColor(a_hitColor);
249
+
250
+ v_distancePx = a_distanceLow / u_resolution - (lineOffsetPx * a_angleTangentSum);
251
+ float distanceHighPx = a_distanceHigh / u_resolution;
252
+ ${this.strokePatternLengthExpression_!==null?`v_distancePx = mod(v_distancePx, ${this.strokePatternLengthExpression_});
253
+ distanceHighPx = mod(distanceHighPx, ${this.strokePatternLengthExpression_});
254
+ `:""}v_distancePx += distanceHighPx;
255
+
256
+ v_measureStart = a_measureStart;
257
+ v_measureEnd = a_measureEnd;
258
+ ${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
259
+ `)}
260
+ }`:null}getStrokeFragmentShader(){return this.hasStroke_?`${rs}
261
+ ${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
262
+ `)}
263
+ varying vec2 v_segmentStartPx;
264
+ varying vec2 v_segmentEndPx;
265
+ varying float v_angleStart;
266
+ varying float v_angleEnd;
267
+ varying float v_width;
268
+ varying vec4 v_hitColor;
269
+ varying float v_distancePx;
270
+ varying float v_measureStart;
271
+ varying float v_measureEnd;
272
+ ${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
273
+ `)}
274
+ ${this.fragmentShaderFunctions_.join(`
275
+ `)}
276
+
277
+ vec2 pxToWorld(vec2 pxPos) {
278
+ vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
279
+ return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
280
+ }
281
+
282
+ bool isCap(float joinAngle) {
283
+ return joinAngle < -0.1;
284
+ }
285
+
286
+ float segmentDistanceField(vec2 point, vec2 start, vec2 end, float width) {
287
+ vec2 tangent = normalize(end - start);
288
+ vec2 normal = vec2(-tangent.y, tangent.x);
289
+ vec2 startToPoint = point - start;
290
+ return abs(dot(startToPoint, normal)) - width * 0.5;
291
+ }
292
+
293
+ float buttCapDistanceField(vec2 point, vec2 start, vec2 end) {
294
+ vec2 startToPoint = point - start;
295
+ vec2 tangent = normalize(end - start);
296
+ return dot(startToPoint, -tangent);
297
+ }
298
+
299
+ float squareCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
300
+ return buttCapDistanceField(point, start, end) - width * 0.5;
301
+ }
302
+
303
+ float roundCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
304
+ float onSegment = max(0., 1000. * dot(point - start, end - start)); // this is very high when inside the segment
305
+ return length(point - start) - width * 0.5 - onSegment;
306
+ }
307
+
308
+ float roundJoinDistanceField(vec2 point, vec2 start, vec2 end, float width) {
309
+ return roundCapDistanceField(point, start, end, width);
310
+ }
311
+
312
+ float bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
313
+ vec2 startToPoint = point - start;
314
+ vec2 tangent = normalize(end - start);
315
+ float c = cos(joinAngle * 0.5);
316
+ float s = sin(joinAngle * 0.5);
317
+ float direction = -sign(sin(joinAngle));
318
+ vec2 bisector = vec2(c * tangent.x - s * tangent.y, s * tangent.x + c * tangent.y);
319
+ float radius = width * 0.5 * s;
320
+ return dot(startToPoint, bisector * direction) - radius;
321
+ }
322
+
323
+ float miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
324
+ if (cos(joinAngle) > ${wd}) { // avoid risking a division by zero
325
+ return bevelJoinField(point, start, end, width, joinAngle);
326
+ }
327
+ float miterLength = 1. / sin(joinAngle * 0.5);
328
+ float miterLimit = ${this.strokeMiterLimitExpression_};
329
+ if (miterLength > miterLimit) {
330
+ return bevelJoinField(point, start, end, width, joinAngle);
331
+ }
332
+ return -1000.;
333
+ }
334
+
335
+ float capDistanceField(vec2 point, vec2 start, vec2 end, float width, float capType) {
336
+ if (capType == ${_i("butt")}) {
337
+ return buttCapDistanceField(point, start, end);
338
+ } else if (capType == ${_i("square")}) {
339
+ return squareCapDistanceField(point, start, end, width);
340
+ }
341
+ return roundCapDistanceField(point, start, end, width);
342
+ }
343
+
344
+ float joinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float joinType) {
345
+ if (joinType == ${_i("bevel")}) {
346
+ return bevelJoinField(point, start, end, width, joinAngle);
347
+ } else if (joinType == ${_i("miter")}) {
348
+ return miterJoinDistanceField(point, start, end, width, joinAngle);
349
+ }
350
+ return roundJoinDistanceField(point, start, end, width);
351
+ }
352
+
353
+ float computeSegmentPointDistance(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float capType, float joinType) {
354
+ if (isCap(joinAngle)) {
355
+ return capDistanceField(point, start, end, width, capType);
356
+ }
357
+ return joinDistanceField(point, start, end, width, joinAngle, joinType);
358
+ }
359
+
360
+ float distanceFromSegment(vec2 point, vec2 start, vec2 end) {
361
+ vec2 tangent = end - start;
362
+ vec2 startToPoint = point - start;
363
+ // inspire by capsule fn in https://iquilezles.org/articles/distfunctions/
364
+ float h = clamp(dot(startToPoint, tangent) / dot(tangent, tangent), 0.0, 1.0);
365
+ return length(startToPoint - tangent * h);
366
+ }
367
+
368
+ void main(void) {
369
+ ${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
370
+ `)}
371
+
372
+ vec2 currentPointPx = gl_FragCoord.xy / u_pixelRatio;
373
+ #ifdef GL_FRAGMENT_PRECISION_HIGH
374
+ vec2 worldPos = pxToWorld(currentPointPx);
375
+ if (
376
+ abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
377
+ worldPos[0] < u_renderExtent[0] ||
378
+ worldPos[1] < u_renderExtent[1] ||
379
+ worldPos[0] > u_renderExtent[2] ||
380
+ worldPos[1] > u_renderExtent[3]
381
+ )
382
+ ) {
383
+ discard;
384
+ }
385
+ #endif
386
+
387
+ float segmentLengthPx = length(v_segmentEndPx - v_segmentStartPx);
388
+ segmentLengthPx = max(segmentLengthPx, 1.17549429e-38); // avoid divide by zero
389
+ vec2 segmentTangent = (v_segmentEndPx - v_segmentStartPx) / segmentLengthPx;
390
+ vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);
391
+ vec2 startToPointPx = currentPointPx - v_segmentStartPx;
392
+ float lengthToPointPx = max(0., min(dot(segmentTangent, startToPointPx), segmentLengthPx));
393
+ float currentLengthPx = lengthToPointPx + v_distancePx;
394
+ float currentRadiusPx = distanceFromSegment(currentPointPx, v_segmentStartPx, v_segmentEndPx);
395
+ float currentRadiusRatio = dot(segmentNormal, startToPointPx) * 2. / v_width;
396
+ currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPointPx / segmentLengthPx);
397
+
398
+ if (${this.discardExpression_}) { discard; }
399
+
400
+ float capType = ${this.strokeCapExpression_};
401
+ float joinType = ${this.strokeJoinExpression_};
402
+ float segmentStartDistance = computeSegmentPointDistance(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width, v_angleStart, capType, joinType);
403
+ float segmentEndDistance = computeSegmentPointDistance(currentPointPx, v_segmentEndPx, v_segmentStartPx, v_width, v_angleEnd, capType, joinType);
404
+ float distanceField = max(
405
+ segmentDistanceField(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width),
406
+ max(segmentStartDistance, segmentEndDistance)
407
+ );
408
+ distanceField = max(distanceField, ${this.strokeDistanceFieldExpression_});
409
+
410
+ vec4 color = ${this.strokeColorExpression_};
411
+ color.a *= smoothstep(0.5, -0.5, distanceField);
412
+ gl_FragColor = color;
413
+ gl_FragColor.a *= u_globalAlpha;
414
+ gl_FragColor.rgb *= gl_FragColor.a;
415
+ if (u_hitDetection > 0) {
416
+ if (gl_FragColor.a < 0.1) { discard; };
417
+ gl_FragColor = v_hitColor;
418
+ }
419
+ }`:null}getFillVertexShader(){return this.hasFill_?`${rs}
420
+ ${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
421
+ `)}
422
+ attribute vec2 a_position;
423
+ attribute vec2 a_hitColor;
424
+
425
+ varying vec4 v_hitColor;
426
+
427
+ ${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
428
+ varying ${e.varyingType} ${e.varyingName};`).join(`
429
+ `)}
430
+ ${this.vertexShaderFunctions_.join(`
431
+ `)}
432
+ void main(void) {
433
+ gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);
434
+ v_hitColor = unpackColor(a_hitColor);
435
+ ${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
436
+ `)}
437
+ }`:null}getFillFragmentShader(){return this.hasFill_?`${rs}
438
+ ${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
439
+ `)}
440
+ varying vec4 v_hitColor;
441
+ ${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
442
+ `)}
443
+ ${this.fragmentShaderFunctions_.join(`
444
+ `)}
445
+ vec2 pxToWorld(vec2 pxPos) {
446
+ vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
447
+ return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
448
+ }
449
+
450
+ vec2 worldToPx(vec2 worldPos) {
451
+ vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
452
+ return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
453
+ }
454
+
455
+ void main(void) {
456
+ ${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
457
+ `)}
458
+ vec2 pxPos = gl_FragCoord.xy / u_pixelRatio;
459
+ vec2 pxOrigin = worldToPx(u_patternOrigin);
460
+ #ifdef GL_FRAGMENT_PRECISION_HIGH
461
+ vec2 worldPos = pxToWorld(pxPos);
462
+ if (
463
+ abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
464
+ worldPos[0] < u_renderExtent[0] ||
465
+ worldPos[1] < u_renderExtent[1] ||
466
+ worldPos[0] > u_renderExtent[2] ||
467
+ worldPos[1] > u_renderExtent[3]
468
+ )
469
+ ) {
470
+ discard;
471
+ }
472
+ #endif
473
+ if (${this.discardExpression_}) { discard; }
474
+ gl_FragColor = ${this.fillColorExpression_};
475
+ gl_FragColor.a *= u_globalAlpha;
476
+ gl_FragColor.rgb *= gl_FragColor.a;
477
+ if (u_hitDetection > 0) {
478
+ if (gl_FragColor.a < 0.1) { discard; };
479
+ gl_FragColor = v_hitColor;
480
+ }
481
+ }`:null}};var Pd=class r extends De{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if(typeof e.getSimplifiedGeometry=="function"){let t=e;this.setGeometry(t)}else{let t=e;this.setProperties(t)}}clone(){let e=new r(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());let t=this.getGeometry();t&&e.setGeometry(t.clone());let i=this.getStyle();return i&&e.setStyle(i),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(K(this.geometryChangeKey_),this.geometryChangeKey_=null);let e=this.getGeometry();e&&(this.geometryChangeKey_=k(e,L.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?dE(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}};function dE(r){if(typeof r=="function")return r;let e;return Array.isArray(r)?e=r:(W(typeof r.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[r]),function(){return e}}var Ge=Pd;function Nl(r,e,t,i){let n=[],s=me();for(let o=0,a=t.length;o<a;++o){let l=t[o];s=yr(r,e,l[0],i),n.push((s[0]+s[2])/2,(s[1]+s[3])/2),e=l[l.length-1]}return n}function cr(r,e,t,i,n,s,o){let a,l,h=(t-e)/i;if(h===1)a=e;else if(h===2)a=e,l=n;else if(h!==0){let c=r[e],u=r[e+1],d=0,f=[0];for(let p=e+i;p<t;p+=i){let _=r[p],x=r[p+1];d+=Math.sqrt((_-c)*(_-c)+(x-u)*(x-u)),f.push(d),c=_,u=x}let g=n*d,m=hg(f,g);m<0?(l=(g-f[-m-2])/(f[-m-1]-f[-m-2]),a=e+(-m-2)*i):a=e+m*i}o=o>1?o:2,s=s||new Array(o);for(let c=0;c<o;++c)s[c]=a===void 0?NaN:l===void 0?r[a+c]:ht(r[a+c],r[a+i+c],l);return s}function Gl(r,e,t,i,n,s){if(t==e)return null;let o;if(n<r[e+i-1])return s?(o=r.slice(e,e+i),o[i-1]=n,o):null;if(r[t-1]<n)return s?(o=r.slice(t-i,t),o[i-1]=n,o):null;if(n==r[e+i-1])return r.slice(e,e+i);let a=e/i,l=t/i;for(;a<l;){let d=a+l>>1;n<r[(d+1)*i-1]?l=d:a=d+1}let h=r[a*i-1];if(n==h)return r.slice((a-1)*i,(a-1)*i+i);let c=r[(a+1)*i-1],u=(n-h)/(c-h);o=[];for(let d=0;d<i-1;++d)o.push(ht(r[(a-1)*i+d],r[a*i+d],u));return o.push(n),o}function p_(r,e,t,i,n,s,o){if(o)return Gl(r,e,t[t.length-1],i,n,s);let a;if(n<r[i-1])return s?(a=r.slice(0,i),a[i-1]=n,a):null;if(r[r.length-1]<n)return s?(a=r.slice(r.length-i),a[i-1]=n,a):null;for(let l=0,h=t.length;l<h;++l){let c=t[l];if(e!=c){if(n<r[e+i-1])return null;if(n<=r[c-1])return Gl(r,e,c,i,n,!1);e=c}}return null}var Ul=class r extends Et{constructor(e,t,i){super(),i!==void 0&&t===void 0?this.setFlatCoordinates(i,e):(t=t||0,this.setCenterAndRadius(e,t,i))}clone(){let e=new r(this.flatCoordinates.slice(),void 0,this.layout);return e.applyProperties(this),e}closestPointXY(e,t,i,n){let s=this.flatCoordinates,o=e-s[0],a=t-s[1],l=o*o+a*a;if(l<n){if(l===0)for(let h=0;h<this.stride;++h)i[h]=s[h];else{let h=this.getRadius()/Math.sqrt(l);i[0]=s[0]+h*o,i[1]=s[1]+h*a;for(let c=2;c<this.stride;++c)i[c]=s[c]}return i.length=this.stride,l}return n}containsXY(e,t){let i=this.flatCoordinates,n=e-i[0],s=t-i[1];return n*n+s*s<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(e){let t=this.flatCoordinates,i=t[this.stride]-t[0];return bt(t[0]-i,t[1]-i,t[0]+i,t[1]+i,e)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){let e=this.flatCoordinates[this.stride]-this.flatCoordinates[0],t=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return e*e+t*t}getType(){return"Circle"}intersectsExtent(e){let t=this.getExtent();if(te(e,t)){let i=this.getCenter();return e[0]<=i[0]&&e[2]>=i[0]||e[1]<=i[1]&&e[3]>=i[1]?!0:Er(e,this.intersectsCoordinate.bind(this))}return!1}setCenter(e){let t=this.stride,i=this.flatCoordinates[t]-this.flatCoordinates[0],n=e.slice();n[t]=n[0]+i;for(let s=1;s<t;++s)n[t+s]=e[s];this.setFlatCoordinates(this.layout,n),this.changed()}setCenterAndRadius(e,t,i){this.setLayout(i,e,0),this.flatCoordinates||(this.flatCoordinates=[]);let n=this.flatCoordinates,s=Ia(n,0,e,this.stride);n[s++]=n[0]+t;for(let o=1,a=this.stride;o<a;++o)n[s++]=n[o];n.length=s,this.changed()}getCoordinates(){return null}setCoordinates(e,t){}setRadius(e){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+e,this.changed()}rotate(e,t){let i=this.getCenter(),n=this.getStride();this.setCenter(br(i,0,i.length,n,e,t,i)),this.changed()}};Ul.prototype.transform;var __=Ul;var bd=class r extends ba{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(K),this.changeEventsKeys_.length=0}listenGeometriesChange_(){let e=this.geometries_;for(let t=0,i=e.length;t<i;++t)this.changeEventsKeys_.push(k(e[t],L.CHANGE,this.changed,this))}clone(){let e=new r(Ld(this.geometries_));return e.applyProperties(this),e}closestPointXY(e,t,i,n){if(n<Ut(this.getExtent(),e,t))return n;let s=this.geometries_;for(let o=0,a=s.length;o<a;++o)n=s[o].closestPointXY(e,t,i,n);return n}containsXY(e,t){let i=this.geometries_;for(let n=0,s=i.length;n<s;++n)if(i[n].containsXY(e,t))return!0;return!1}computeExtent(e){zi(e);let t=this.geometries_;for(let i=0,n=t.length;i<n;++i)ha(e,t[i].getExtent());return e}getGeometries(){return Ld(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let e=[],t=this.geometries_;for(let i=0,n=t.length;i<n;++i)t[i].getType()===this.getType()?e=e.concat(t[i].getGeometriesArrayRecursive()):e.push(t[i]);return e}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<this.simplifiedGeometryMaxMinSquaredTolerance)return this;let t=[],i=this.geometries_,n=!1;for(let s=0,o=i.length;s<o;++s){let a=i[s],l=a.getSimplifiedGeometry(e);t.push(l),l!==a&&(n=!0)}return n?new r(t):(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getType(){return"GeometryCollection"}intersectsExtent(e){let t=this.geometries_;for(let i=0,n=t.length;i<n;++i)if(t[i].intersectsExtent(e))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(e,t){let i=this.geometries_;for(let n=0,s=i.length;n<s;++n)i[n].rotate(e,t);this.changed()}scale(e,t,i){i||(i=be(this.getExtent()));let n=this.geometries_;for(let s=0,o=n.length;s<o;++s)n[s].scale(e,t,i);this.changed()}setGeometries(e){this.setGeometriesArray(Ld(e))}setGeometriesArray(e){this.unlistenGeometriesChange_(),this.geometries_=e,this.listenGeometriesChange_(),this.changed()}applyTransform(e){let t=this.geometries_;for(let i=0,n=t.length;i<n;++i)t[i].applyTransform(e);this.changed()}translate(e,t){let i=this.geometries_;for(let n=0,s=i.length;n<s;++n)i[n].translate(e,t);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}};function Ld(r){return r.map(e=>e.clone())}var Mo=bd;var Id=class r extends Et{constructor(e,t){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,t!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}appendCoordinate(e){je(this.flatCoordinates,e),this.changed()}clone(){let e=new r(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,i,n){return n<Ut(this.getExtent(),e,t)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Gs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Bs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,e,t,i,n))}forEachSegment(e){return Oa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinateAtM(e,t){return this.layout!="XYM"&&this.layout!="XYZM"?null:(t=t!==void 0?t:!1,Gl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t))}getCoordinates(){return ri(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(e,t){return cr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,this.stride)}getLength(){return Jr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(e){let t=[];return t.length=qn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,0),new r(t,"XY")}getType(){return"LineString"}intersectsExtent(e){return Ys(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,this.getExtent())}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Zn(this.flatCoordinates,0,e,this.stride),this.changed()}},Ke=Id;var Fd=class r extends Et{constructor(e,t,i){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(e[0]))this.setCoordinates(e,t);else if(t!==void 0&&i)this.setFlatCoordinates(t,e),this.ends_=i;else{let n=e,s=[],o=[];for(let l=0,h=n.length;l<h;++l){let c=n[l];je(s,c.getFlatCoordinates()),o.push(s.length)}let a=n.length===0?this.getLayout():n[0].getLayout();this.setFlatCoordinates(a,s),this.ends_=o}}appendLineString(e){je(this.flatCoordinates,e.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new r(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,t,i,n){return n<Ut(this.getExtent(),e,t)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Us(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zs(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,e,t,i,n))}getCoordinateAtM(e,t,i){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(t=t!==void 0?t:!1,i=i!==void 0?i:!1,p_(this.flatCoordinates,0,this.ends_,this.stride,e,t,i))}getCoordinates(){return Pn(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(e){return e<0||this.ends_.length<=e?null:new Ke(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLineStrings(){let e=this.flatCoordinates,t=this.ends_,i=this.layout,n=[],s=0;for(let o=0,a=t.length;o<a;++o){let l=t[o],h=new Ke(e.slice(s,l),i);n.push(h),s=l}return n}getLength(){let e=this.ends_,t=0,i=0;for(let n=0,s=e.length;n<s;++n)i+=Jr(this.flatCoordinates,t,e[n],this.stride),t=e[n];return i}getFlatMidpoints(){let e=[],t=this.flatCoordinates,i=0,n=this.ends_,s=this.stride;for(let o=0,a=n.length;o<a;++o){let l=n[o],h=cr(t,i,l,s,.5);je(e,h),i=l}return e}getSimplifiedGeometryInternal(e){let t=[],i=[];return t.length=Ma(this.flatCoordinates,0,this.ends_,this.stride,e,t,0,i),new r(t,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(e){return pm(this.flatCoordinates,0,this.ends_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let i=wn(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}},cn=Fd;var Md=class r extends Et{constructor(e,t){super(),t&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}appendPoint(e){je(this.flatCoordinates,e.getFlatCoordinates()),this.changed()}clone(){let e=new r(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,i,n){if(n<Ut(this.getExtent(),e,t))return n;let s=this.flatCoordinates,o=this.stride;for(let a=0,l=s.length;a<l;a+=o){let h=Gt(e,t,s[a],s[a+1]);if(h<n){n=h;for(let c=0;c<o;++c)i[c]=s[a+c];i.length=o}}return n}getCoordinates(){return ri(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(e){let t=this.flatCoordinates.length/this.stride;return e<0||t<=e?null:new Fe(this.flatCoordinates.slice(e*this.stride,(e+1)*this.stride),this.layout)}getPoints(){let e=this.flatCoordinates,t=this.layout,i=this.stride,n=[];for(let s=0,o=e.length;s<o;s+=i){let a=new Fe(e.slice(s,s+i),t);n.push(a)}return n}getType(){return"MultiPoint"}intersectsExtent(e){let t=this.flatCoordinates,i=this.stride;for(let n=0,s=t.length;n<s;n+=i){let o=t[n],a=t[n+1];if(Is(e,o,a))return!0}return!1}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Zn(this.flatCoordinates,0,e,this.stride),this.changed()}},un=Md;var Ad=class r extends Et{constructor(e,t,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(e[0])){let n=e,s=[],o=[];for(let a=0,l=n.length;a<l;++a){let h=n[a],c=s.length,u=h.getEnds();for(let d=0,f=u.length;d<f;++d)u[d]+=c;je(s,h.getFlatCoordinates()),o.push(u)}t=n.length===0?this.getLayout():n[0].getLayout(),e=s,i=o}t!==void 0&&i?(this.setFlatCoordinates(t,e),this.endss_=i):this.setCoordinates(e,t)}appendPolygon(e){let t;if(!this.flatCoordinates)this.flatCoordinates=e.getFlatCoordinates().slice(),t=e.getEnds().slice(),this.endss_.push();else{let i=this.flatCoordinates.length;je(this.flatCoordinates,e.getFlatCoordinates()),t=e.getEnds().slice();for(let n=0,s=t.length;n<s;++n)t[n]+=i}this.endss_.push(t),this.changed()}clone(){let e=this.endss_.length,t=new Array(e);for(let n=0;n<e;++n)t[n]=this.endss_[n].slice();let i=new r(this.flatCoordinates.slice(),this.layout,t);return i.applyProperties(this),i}closestPointXY(e,t,i,n){return n<Ut(this.getExtent(),e,t)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(um(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),dm(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,e,t,i,n))}containsXY(e,t){return mm(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e,t)}getArea(){return hm(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(e){let t;return e!==void 0?(t=this.getOrientedFlatCoordinates().slice(),Ks(t,0,this.endss_,this.stride,e)):t=this.flatCoordinates,js(t,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let e=Nl(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Aa(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new un(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;Da(e,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Ks(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let t=[],i=[];return t.length=fm(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(e),t,0,i),new r(t,"XY",i)}getPolygon(e){if(e<0||this.endss_.length<=e)return null;let t;if(e===0)t=0;else{let s=this.endss_[e-1];t=s[s.length-1]}let i=this.endss_[e].slice(),n=i[i.length-1];if(t!==0)for(let s=0,o=i.length;s<o;++s)i[s]-=t;return new dt(this.flatCoordinates.slice(t,n),this.layout,i)}getPolygons(){let e=this.layout,t=this.flatCoordinates,i=this.endss_,n=[],s=0;for(let o=0,a=i.length;o<a;++o){let l=i[o].slice(),h=l[l.length-1];if(s!==0)for(let u=0,d=l.length;u<d;++u)l[u]-=s;let c=new dt(t.slice(s,h),e,l);n.push(c),s=h}return n}getType(){return"MultiPolygon"}intersectsExtent(e){return _m(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,3),this.flatCoordinates||(this.flatCoordinates=[]);let i=Fa(this.flatCoordinates,0,e,this.stride,this.endss_);if(i.length===0)this.flatCoordinates.length=0;else{let n=i[i.length-1];this.flatCoordinates.length=n.length===0?0:n[n.length-1]}this.changed()}},dn=Ad;var x_=ae(),Ao=class r{constructor(e,t,i,n,s,o){this.styleFunction,this.extent_,this.id_=o,this.type_=e,this.flatCoordinates_=t,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=s,this.squaredTolerance_,this.stride_=n,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Ri(this.flatCoordinates_):yr(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=be(this.getExtent());this.flatInteriorPoints_=Xs(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=Fr(this.flatCoordinates_,this.ends_),t=Nl(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Aa(this.flatCoordinates_,0,e,2,t)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=cr(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let e=this.flatCoordinates_,t=0,i=this.ends_;for(let n=0,s=i.length;n<s;++n){let o=i[n],a=cr(e,t,o,2,.5);je(this.flatMidpoints_,a),t=o}}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=$(e);let t=e.getExtent(),i=e.getWorldExtent();if(t&&i){let n=re(i)/re(t);Ae(x_,i[0],i[3],n,-n,0,0,0),ut(this.flatCoordinates_,0,this.flatCoordinates_.length,2,x_,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new r(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Qo((e,t)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),t&&this.simplifiedGeometry_.applyTransform(t);let i=this.simplifiedGeometry_.getFlatCoordinates(),n;switch(this.type_){case"LineString":i.length=qn(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=Ma(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,i,0,n);break;case"Polygon":n=[],i.length=Vs(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),i,0,n);break;default:}return n&&(this.simplifiedGeometry_=new r(this.type_,i,n,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};Ao.prototype.getFlatCoordinates=Ao.prototype.getOrientedFlatCoordinates;var Ct=Ao;var Od=class r{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(e,t){for(let i=0;i<e.length;i++)this.addFeature(e[i],t)}addFeature(e,t){let i=e.getGeometry();i&&(t&&(i=i.clone(),i.applyTransform(t)),this.addGeometry_(i,e))}clearFeatureEntryInPointBatch_(e){let t=P(e),i=this.pointBatch.entries[t];if(i)return this.pointBatch.geometriesCount-=i.flatCoordss.length,delete this.pointBatch.entries[t],i}clearFeatureEntryInLineStringBatch_(e){let t=P(e),i=this.lineStringBatch.entries[t];if(i)return this.lineStringBatch.verticesCount-=i.verticesCount,this.lineStringBatch.geometriesCount-=i.flatCoordss.length,delete this.lineStringBatch.entries[t],i}clearFeatureEntryInPolygonBatch_(e){let t=P(e),i=this.polygonBatch.entries[t];if(i)return this.polygonBatch.verticesCount-=i.verticesCount,this.polygonBatch.ringsCount-=i.ringsCount,this.polygonBatch.geometriesCount-=i.flatCoordss.length,delete this.polygonBatch.entries[t],i}addGeometry_(e,t){let i=e.getType();switch(i){case"GeometryCollection":{let n=e.getGeometriesArray();for(let s of n)this.addGeometry_(s,t);break}case"MultiPolygon":{let n=e;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEndss(),t,P(t),n.getStride());break}case"MultiLineString":{let n=e;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),t,P(t),n.getStride());break}case"MultiPoint":{let n=e;this.addCoordinates_(i,n.getFlatCoordinates(),null,t,P(t),n.getStride());break}case"Polygon":{let n=e;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),t,P(t),n.getStride());break}case"Point":{let n=e;this.addCoordinates_(i,n.getFlatCoordinates(),null,t,P(t),n.getStride());break}case"LineString":case"LinearRing":{let n=e,s=n.getStride();this.addCoordinates_(i,n.getFlatCoordinates(),null,t,P(t),s,n.getLayout?.());break}default:}}addCoordinates_(e,t,i,n,s,o,a){let l;switch(e){case"MultiPolygon":{let h=i;for(let c=0,u=h.length;c<u;c++){let d=h[c],f=c>0?h[c-1]:null,g=f?f[f.length-1]:0,m=d[d.length-1];d=g>0?d.map(p=>p-g):d,this.addCoordinates_("Polygon",t.slice(g,m),d,n,s,o,a)}break}case"MultiLineString":{let h=i;for(let c=0,u=h.length;c<u;c++){let d=c>0?h[c-1]:0;this.addCoordinates_("LineString",t.slice(d,h[c]),null,n,s,o,a)}break}case"MultiPoint":for(let h=0,c=t.length;h<c;h+=o)this.addCoordinates_("Point",t.slice(h,h+2),null,n,s,null,null);break;case"Polygon":{let h=i;if(n instanceof Ct){let d=Fr(t,h);if(d.length>1){this.addCoordinates_("MultiPolygon",t,d,n,s,o,a);return}}this.polygonBatch.entries[s]||(this.polygonBatch.entries[s]=this.addRefToEntry_(s,{feature:n,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]})),l=t.length/o;let c=i.length,u=i.map((d,f,g)=>f>0?(d-g[f-1])/o:d/o);this.polygonBatch.verticesCount+=l,this.polygonBatch.ringsCount+=c,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[s].flatCoordss.push(fE(t,o)),this.polygonBatch.entries[s].ringsVerticesCounts.push(u),this.polygonBatch.entries[s].verticesCount+=l,this.polygonBatch.entries[s].ringsCount+=c;for(let d=0,f=h.length;d<f;d++){let g=d>0?h[d-1]:0;this.addCoordinates_("LinearRing",t.slice(g,h[d]),null,n,s,o,a)}break}case"Point":this.pointBatch.entries[s]||(this.pointBatch.entries[s]=this.addRefToEntry_(s,{feature:n,flatCoordss:[]})),this.pointBatch.geometriesCount++,this.pointBatch.entries[s].flatCoordss.push(t);break;case"LineString":case"LinearRing":this.lineStringBatch.entries[s]||(this.lineStringBatch.entries[s]=this.addRefToEntry_(s,{feature:n,flatCoordss:[],verticesCount:0})),l=t.length/o,this.lineStringBatch.verticesCount+=l,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[s].flatCoordss.push(gE(t,o,a)),this.lineStringBatch.entries[s].verticesCount+=l;break;default:}}addRefToEntry_(e,t){let i=this.uidToRef_.get(e),n=i||this.freeGlobalRef_.pop()||++this.globalCounter_;return t.ref=n,i||(this.refToFeature_.set(n,t.feature),this.uidToRef_.set(e,n)),t}removeRef_(e,t){if(!e)throw new Error("This feature has no ref: "+t);this.refToFeature_.delete(e),this.uidToRef_.delete(t),this.freeGlobalRef_.push(e)}changeFeature(e,t){if(!this.uidToRef_.get(P(e)))return;this.removeFeature(e);let i=e.getGeometry();i&&(t&&(i=i.clone(),i.applyTransform(t)),this.addGeometry_(i,e))}removeFeature(e){let t=this.clearFeatureEntryInPointBatch_(e);t=this.clearFeatureEntryInPolygonBatch_(e)||t,t=this.clearFeatureEntryInLineStringBatch_(e)||t,t&&this.removeRef_(t.ref,P(t.feature))}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(e){return this.refToFeature_.get(e)}isEmpty(){return this.globalCounter_===0}filter(e){let t=new r;t.globalCounter_=this.globalCounter_,t.uidToRef_=this.uidToRef_,t.refToFeature_=this.refToFeature_;let i=!0;for(let n of this.refToFeature_.values())e(n)&&(t.addFeature(n),i=!1);return i?new r:t}};function fE(r,e){return e===2?r:r.filter((t,i)=>i%e<2)}function gE(r,e,t){return e===3&&t==="XYM"?r:e===4?r.filter((i,n)=>n%e!==2):e===3?r.map((i,n)=>n%e!==2?i:0):new Array(r.length*1.5).fill(0).map((i,n)=>n%3===2?0:r[Math.round(n/1.5)])}var y_=Od;function E_(){let r='function t(t,n,x=2){const o=n&&n.length,i=o?n[0]*x:t.length;let f=e(t,0,i,x,!0);const l=[];if(!f||f.next===f.prev)return l;let c,y,h;if(o&&(f=function(t,n,r,x){const o=[];for(let r=0,i=n.length;r<i;r++){const f=e(t,n[r]*x,r<i-1?n[r+1]*x:t.length,x,!1);f===f.next&&(f.steiner=!0),o.push(a(f))}o.sort(u);for(let t=0;t<o.length;t++)r=s(o[t],r);return r}(t,n,f,x)),t.length>80*x){c=t[0],y=t[1];let e=c,n=y;for(let r=x;r<i;r+=x){const x=t[r],o=t[r+1];x<c&&(c=x),o<y&&(y=o),x>e&&(e=x),o>n&&(n=o)}h=Math.max(e-c,n-y),h=0!==h?32767/h:0}return r(f,l,x,c,y,h,0),l}function e(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,i=n-r;o<n;o+=r)x+=(t[i]-t[o])*(t[o+1]+t[i+1]),i=o;return x}(t,e,n,r)>0)for(let x=e;x<n;x+=r)o=d(x/r|0,t[x],t[x+1],o);else for(let x=n-r;x>=e;x-=r)o=d(x/r|0,t[x],t[x+1],o);return o&&b(o,o.next)&&(w(o),o=o.next),o}function n(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!b(r,r.next)&&0!==v(r.prev,r,r.next))r=r.next;else{if(w(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function r(t,e,u,s,l,a,y){if(!t)return;!y&&a&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=c(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let i=x,f=0;for(let t=0;t<n&&(f++,i=i.nextZ,i);t++);let u=n;for(;f>0||u>0&&i;)0!==f&&(0===u||!i||x.z<=i.z)?(r=x,x=x.nextZ,f--):(r=i,i=i.nextZ,u--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=i}o.nextZ=null,n*=2}while(e>1)}(x)}(t,s,l,a);let h=t;for(;t.prev!==t.next;){const c=t.prev,p=t.next;if(a?o(t,s,l,a):x(t))e.push(c.i,t.i,p.i),w(t),t=p.next,h=p.next;else if((t=p)===h){y?1===y?r(t=i(n(t),e),e,u,s,l,a,2):2===y&&f(t,e,u,s,l,a):r(n(t),e,u,s,l,a,1);break}}}function x(t){const e=t.prev,n=t,r=t.next;if(v(e,n,r)>=0)return!1;const x=e.x,o=n.x,i=r.x,f=e.y,u=n.y,s=r.y,l=Math.min(x,o,i),c=Math.min(f,u,s),a=Math.max(x,o,i),y=Math.max(f,u,s);let p=r.next;for(;p!==e;){if(p.x>=l&&p.x<=a&&p.y>=c&&p.y<=y&&h(x,f,o,u,i,s,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function o(t,e,n,r){const x=t.prev,o=t,i=t.next;if(v(x,o,i)>=0)return!1;const f=x.x,u=o.x,s=i.x,l=x.y,a=o.y,y=i.y,p=Math.min(f,u,s),b=Math.min(l,a,y),M=Math.max(f,u,s),m=Math.max(l,a,y),A=c(p,b,e,n,r),g=c(M,m,e,n,r);let Z=t.prevZ,d=t.nextZ;for(;Z&&Z.z>=A&&d&&d.z<=g;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;if(Z=Z.prevZ,d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;Z&&Z.z>=A;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;Z=Z.prevZ}for(;d&&d.z<=g;){if(d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function i(t,e){let r=t;do{const n=r.prev,x=r.next.next;!b(n,x)&&M(n,r,r.next,x)&&g(n,x)&&g(x,n)&&(e.push(n.i,r.i,x.i),w(r),w(r.next),r=t=x),r=r.next}while(r!==t);return n(r)}function f(t,e,x,o,i,f){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&p(u,t)){let s=Z(u,t);return u=n(u,u.next),s=n(s,s.next),r(u,e,x,o,i,f,0),void r(s,e,x,o,i,f,0)}t=t.next}u=u.next}while(u!==t)}function u(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function s(t,e){const r=function(t,e){let n=e;const r=t.x,x=t.y;let o,i=-1/0;if(b(t,n))return n;do{if(b(t,n.next))return n.next;if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>i&&(i=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const f=o,u=o.x,s=o.y;let c=1/0;n=o;do{if(r>=n.x&&n.x>=u&&r!==n.x&&y(x<s?r:i,x,u,s,x<s?i:r,x,n.x,n.y)){const e=Math.abs(x-n.y)/(r-n.x);g(n,t)&&(e<c||e===c&&(n.x>o.x||n.x===o.x&&l(o,n)))&&(o=n,c=e)}n=n.next}while(n!==f);return o}(t,e);if(!r)return e;const x=Z(r,t);return n(x,x.next),n(r,r.next)}function l(t,e){return v(t.prev,t,e.prev)<0&&v(e.next,t,t.next)<0}function c(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function a(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function y(t,e,n,r,x,o,i,f){return(x-i)*(e-f)>=(t-i)*(o-f)&&(t-i)*(r-f)>=(n-i)*(e-f)&&(n-i)*(o-f)>=(x-i)*(r-f)}function h(t,e,n,r,x,o,i,f){return!(t===i&&e===f)&&y(t,e,n,r,x,o,i,f)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&M(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(g(t,e)&&g(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(v(t.prev,t,e.prev)||v(t,e.prev,e))||b(t,e)&&v(t.prev,t,t.next)>0&&v(e.prev,e,e.next)>0)}function v(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function b(t,e){return t.x===e.x&&t.y===e.y}function M(t,e,n,r){const x=A(v(t,e,n)),o=A(v(t,e,r)),i=A(v(n,r,t)),f=A(v(n,r,e));return x!==o&&i!==f||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==i||!m(n,t,r))||!(0!==f||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function g(t,e){return v(t.prev,t,t.next)<0?v(t,e,t.next)>=0&&v(t,t.prev,e)>=0:v(t,e,t.prev)<0||v(t,t.next,e)<0}function Z(t,e){const n=F(t.i,t.x,t.y),r=F(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function d(t,e,n,r){const x=F(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function w(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function F(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function E(t,e,n){const r=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),x=[(e[0]-t[0])/r,(e[1]-t[1])/r],o=[-x[1],x[0]],i=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),f=[(n[0]-t[0])/i,(n[1]-t[1])/i];let u=0===r||0===i?0:Math.acos((s=f[0]*x[0]+f[1]*x[1],l=-1,c=1,Math.min(Math.max(s,l),c)));var s,l,c;u=Math.max(u,1e-5);return f[0]*o[0]+f[1]*o[1]>0?u:2*Math.PI-u}function I(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function z(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,"Transformation matrix cannot be inverted");const x=e[0],o=e[1],i=e[2],f=e[3],u=e[4],s=e[5];return t[0]=f/n,t[1]=-o/n,t[2]=-i/n,t[3]=x/n,t[4]=(i*s-f*u)/n,t[5]=-(x*s-o*u)/n,t}new Array(6);const B=[],P={vertexAttributesPosition:0,instanceAttributesPosition:0,indicesPosition:0};function N(t,e,n,r,x){const o=t[e++],i=t[e++],f=B;f.length=r;for(let n=0;n<f.length;n++)f[n]=t[e+n];let u=x?x.instanceAttributesPosition:0;return n[u++]=o,n[u++]=i,f.length&&(n.set(f,u),u+=f.length),P.instanceAttributesPosition=u,P}function R(t,e,n,r,x,o,i,f,u,s){const l=[t[e],t[e+1]],c=[t[n],t[n+1]],a=t[e+2],y=t[n+2],h=I(f,[...l]),p=I(f,[...c]);let v=-1,b=-1,M=s;const m=null!==x;if(null!==r){v=E(h,p,I(f,[...[t[r],t[r+1]]])),Math.cos(v)<=.985&&(M+=Math.tan((v-Math.PI)/2))}if(m){b=E(p,h,I(f,[...[t[x],t[x+1]]])),Math.cos(b)<=.985&&(M+=Math.tan((Math.PI-b)/2))}const A=Math.pow(2,24),g=u%A,Z=Math.floor(u/A)*A;return o.push(l[0],l[1],a,c[0],c[1],y,v,b,g,Z,s),o.push(...i),{length:u+Math.sqrt((p[0]-h[0])*(p[0]-h[0])+(p[1]-h[1])*(p[1]-h[1])),angle:M}}function S(e,n,r,x,o){const i=2+o;let f=n;const u=e.slice(f,f+o);f+=o;const s=e[f++];let l=0;const c=new Array(s-1);for(let t=0;t<s;t++)l+=e[f++],t<s-1&&(c[t]=l);const a=e.slice(f,f+2*l),y=t(a,c,2);for(let t=0;t<y.length;t++)x.push(y[t]+r.length/i);for(let t=0;t<a.length;t+=2)r.push(a[t],a[t+1],...u);return f+2*l}const T="GENERATE_POLYGON_BUFFERS",_="GENERATE_POINT_BUFFERS",O="GENERATE_LINE_STRING_BUFFERS",U=self;U.onmessage=t=>{const e=t.data;switch(e.type){case _:{const t=2,n=2,r=e.customAttributesSize,x=n+r,o=new Float32Array(e.renderInstructions),i=o.length/x*(t+r),f=Uint32Array.from([0,1,3,1,2,3]),u=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),s=new Float32Array(i);let l;for(let t=0;t<o.length;t+=x)l=N(o,t,s,r,l);const c=Object.assign({indicesBuffer:f.buffer,vertexAttributesBuffer:u.buffer,instanceAttributesBuffer:s.buffer,renderInstructions:o.buffer},e);U.postMessage(c,[u.buffer,s.buffer,f.buffer,o.buffer]);break}case O:{const t=[],n=e.customAttributesSize,r=3,x=new Float32Array(e.renderInstructions);let o=0;const i=[1,0,0,1,0,0];let f,u;for(z(i,e.renderInstructionsTransform);o<x.length;){u=Array.from(x.slice(o,o+n)),o+=n,f=x[o++];const e=o,s=o+(f-1)*r,l=x[e]===x[s]&&x[e+1]===x[s+1];let c=0,a=0;for(let n=0;n<f-1;n++){let y=null;n>0?y=o+(n-1)*r:l&&(y=s-r);let h=null;n<f-2?h=o+(n+2)*r:l&&(h=e+r);const p=R(x,o+n*r,o+(n+1)*r,y,h,t,u,i,c,a);c=p.length,a=p.angle}o+=f*r}const s=Uint32Array.from([0,1,3,1,2,3]),l=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),c=Float32Array.from(t),a=Object.assign({indicesBuffer:s.buffer,vertexAttributesBuffer:l.buffer,instanceAttributesBuffer:c.buffer,renderInstructions:x.buffer},e);U.postMessage(a,[l.buffer,c.buffer,s.buffer,x.buffer]);break}case T:{const t=[],n=[],r=e.customAttributesSize,x=new Float32Array(e.renderInstructions);let o=0;for(;o<x.length;)o=S(x,o,t,n,r);const i=Uint32Array.from(n),f=Float32Array.from(t),u=Float32Array.from([]),s=Object.assign({indicesBuffer:i.buffer,vertexAttributesBuffer:f.buffer,instanceAttributesBuffer:u.buffer,renderInstructions:x.buffer},e);U.postMessage(s,[f.buffer,u.buffer,i.buffer,x.buffer]);break}}};';return new Worker(typeof Blob>"u"?"data:application/javascript;base64,"+Buffer.from(r,"binary").toString("base64"):URL.createObjectURL(new Blob([r],{type:"application/javascript"})))}var Bl={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function T_(r,e){e=e||[];let t=256,i=t-1,n=Math.floor(r/t/t/t)/i,s=Math.floor(r/t/t)%t/i,o=Math.floor(r/t)%t/i,a=r%t/i;return e[0]=n*256*255+s*255,e[1]=o*256*255+a*255,e}function C_(r){let e=0,t=256,i=t-1;return e+=Math.round(r[0]*t*t*t*i),e+=Math.round(r[1]*t*t*i),e+=Math.round(r[2]*t*i),e+=Math.round(r[3]*i),e}function Dd(r,e,t,i){let n=0;for(let s in e){let o=e[s],a=o.callback.call(t,t.feature),l=a?.[0]??a;l===Fl&&console.warn('The "has" operator might return false positives.'),l===void 0?l=Fl:l===null&&(l=0),r[i+n++]=l,!(!o.size||o.size===1)&&(r[i+n++]=a[1],!(o.size<3)&&(r[i+n++]=a[2],!(o.size<4)&&(r[i+n++]=a[3])))}return n}function Oo(r){return Object.keys(r).reduce((e,t)=>e+(r[t].size||1),0)}function v_(r,e,t,i){let n=(2+Oo(t))*r.geometriesCount;(!e||e.length!==n)&&(e=new Float32Array(n));let s=[],o=0;for(let a in r.entries){let l=r.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++)s[0]=l.flatCoordss[h][0],s[1]=l.flatCoordss[h][1],le(i,s),e[o++]=s[0],e[o++]=s[1],o+=Dd(e,t,l,o)}return e}function S_(r,e,t,i){let n=3*r.verticesCount+(1+Oo(t))*r.geometriesCount;(!e||e.length!==n)&&(e=new Float32Array(n));let s=[],o=0;for(let a in r.entries){let l=r.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){s.length=l.flatCoordss[h].length,ut(l.flatCoordss[h],0,s.length,3,i,s,3),o+=Dd(e,t,l,o),e[o++]=s.length/3;for(let u=0,d=s.length;u<d;u+=3)e[o++]=s[u],e[o++]=s[u+1],e[o++]=s[u+2]}}return e}function R_(r,e,t,i){let n=2*r.verticesCount+(1+Oo(t))*r.geometriesCount+r.ringsCount;(!e||e.length!==n)&&(e=new Float32Array(n));let s=[],o=0;for(let a in r.entries){let l=r.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){s.length=l.flatCoordss[h].length,ut(l.flatCoordss[h],0,s.length,2,i,s),o+=Dd(e,t,l,o),e[o++]=l.ringsVerticesCounts[h].length;for(let u=0,d=l.ringsVerticesCounts[h].length;u<d;u++)e[o++]=l.ringsVerticesCounts[h][u];for(let u=0,d=s.length;u<d;u+=2)e[o++]=s[u],e[o++]=s[u+1]}}return e}function zl(r){return(JSON.stringify(r).split("").reduce((t,i)=>(t<<5)-t+i.charCodeAt(0),0)>>>0).toString()}function kd(r,e,t,i){if(`${i}radius`in r&&i!=="icon-"){let n=Z(t,r[`${i}radius`],N);if(`${i}radius2`in r){let s=Z(t,r[`${i}radius2`],N);n=`max(${n}, ${s})`}`${i}stroke-width`in r&&(n=`(${n} + ${Z(t,r[`${i}stroke-width`],N)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${n} * 2. + 0.5)`)}if(`${i}scale`in r){let n=Z(t,r[`${i}scale`],Ft);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${n}`)}`${i}displacement`in r&&e.setSymbolOffsetExpression(Z(t,r[`${i}displacement`],at)),`${i}rotation`in r&&e.setSymbolRotationExpression(Z(t,r[`${i}rotation`],N)),`${i}rotate-with-view`in r&&e.setSymbolRotateWithView(!!r[`${i}rotate-with-view`])}function w_(r,e,t,i,n){let s="vec4(0.)";if(e!==null&&(s=e),t!==null&&i!==null){let l=`smoothstep(-${i} + 0.63, -${i} - 0.58, ${r})`;s=`mix(${t}, ${s}, ${l})`}let o=`(1.0 - smoothstep(-0.63, 0.58, ${r}))`,a=`${s} * vec4(1.0, 1.0, 1.0, ${o})`;return n!==null&&(a=`${a} * vec4(1.0, 1.0, 1.0, ${n})`),a}function Nd(r,e,t,i,n){let s=new Image;s.crossOrigin=r[`${i}cross-origin`]===void 0?"anonymous":r[`${i}cross-origin`],W(typeof r[`${i}src`]=="string",`WebGL layers do not support expressions for the ${i}src style property`),s.src=r[`${i}src`],t[`u_texture${n}_size`]=()=>s.complete?[s.width,s.height]:[0,0],e.addUniform(`u_texture${n}_size`,"vec2");let o=`u_texture${n}_size`;return t[`u_texture${n}`]=s,e.addUniform(`u_texture${n}`,"sampler2D"),o}function Gd(r,e,t,i,n){let s=Z(t,r[`${e}offset`],Ft);if(`${e}offset-origin`in r)switch(r[`${e}offset-origin`]){case"top-right":s=`vec2(${i}.x, 0.) + ${n} * vec2(-1., 0.) + ${s} * vec2(-1., 1.)`;break;case"bottom-left":s=`vec2(0., ${i}.y) + ${n} * vec2(0., -1.) + ${s} * vec2(1., -1.)`;break;case"bottom-right":s=`${i} - ${n} - ${s}`;break;default:}return s}function mE(r,e,t,i){i.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) {
482
+ return length(point) - radius;
483
+ }`,kd(r,e,i,"circle-");let n=null;"circle-opacity"in r&&(n=Z(i,r["circle-opacity"],N));let s="coordsPx";"circle-scale"in r&&(s=`coordsPx / ${Z(i,r["circle-scale"],Ft)}`);let o=null;"circle-fill-color"in r&&(o=Z(i,r["circle-fill-color"],pe));let a=null;"circle-stroke-color"in r&&(a=Z(i,r["circle-stroke-color"],pe));let l=Z(i,r["circle-radius"],N),h=null;"circle-stroke-width"in r&&(h=Z(i,r["circle-stroke-width"],N),l=`(${l} + ${h} * 0.5)`);let c=`circleDistanceField(${s}, ${l})`,u=w_(c,o,a,h,n);e.setSymbolColorExpression(u)}function pE(r,e,t,i){i.functions.round=`float round(float v) {
484
+ return sign(v) * floor(abs(v) + 0.5);
485
+ }`,i.functions.starDistanceField=`float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {
486
+ float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
487
+ float c = cos(startAngle);
488
+ float s = sin(startAngle);
489
+ vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
490
+ float alpha = TWO_PI / numPoints; // the angle of one sector
491
+ float beta = atan(pointRotated.y, pointRotated.x);
492
+ float gamma = round(beta / alpha) * alpha; // angle in sector
493
+ c = cos(-gamma);
494
+ s = sin(-gamma);
495
+ vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
496
+ vec2 tipToPoint = inSector + vec2(-radius, 0.);
497
+ vec2 edgeNormal = vec2(radius2 * sin(alpha * 0.5), -radius2 * cos(alpha * 0.5) + radius);
498
+ return dot(normalize(edgeNormal), tipToPoint);
499
+ }`,i.functions.regularDistanceField=`float regularDistanceField(vec2 point, float numPoints, float radius, float angle) {
500
+ float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
501
+ float c = cos(startAngle);
502
+ float s = sin(startAngle);
503
+ vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
504
+ float alpha = TWO_PI / numPoints; // the angle of one sector
505
+ float radiusIn = radius * cos(PI / numPoints);
506
+ float beta = atan(pointRotated.y, pointRotated.x);
507
+ float gamma = round((beta - alpha * 0.5) / alpha) * alpha + alpha * 0.5; // angle in sector from mid
508
+ c = cos(-gamma);
509
+ s = sin(-gamma);
510
+ vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
511
+ return inSector.x - radiusIn;
512
+ }`,kd(r,e,i,"shape-");let n=null;"shape-opacity"in r&&(n=Z(i,r["shape-opacity"],N));let s="coordsPx";"shape-scale"in r&&(s=`coordsPx / ${Z(i,r["shape-scale"],Ft)}`);let o=null;"shape-fill-color"in r&&(o=Z(i,r["shape-fill-color"],pe));let a=null;"shape-stroke-color"in r&&(a=Z(i,r["shape-stroke-color"],pe));let l=null;"shape-stroke-width"in r&&(l=Z(i,r["shape-stroke-width"],N));let h=Z(i,r["shape-points"],N),c="0.";"shape-angle"in r&&(c=Z(i,r["shape-angle"],N));let u,d=Z(i,r["shape-radius"],N);if(l!==null&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in r){let g=Z(i,r["shape-radius2"],N);l!==null&&(g=`${g} + ${l} * 0.5`),u=`starDistanceField(${s}, ${h}, ${d}, ${g}, ${c})`}else u=`regularDistanceField(${s}, ${h}, ${d}, ${c})`;let f=w_(u,o,a,l,n);e.setSymbolColorExpression(f)}function _E(r,e,t,i){let n="vec4(1.0)";"icon-color"in r&&(n=Z(i,r["icon-color"],pe)),"icon-opacity"in r&&(n=`${n} * vec4(1.0, 1.0, 1.0, ${Z(i,r["icon-opacity"],N)})`);let s=zl(r["icon-src"]),o=Nd(r,e,t,"icon-",s);if(e.setSymbolColorExpression(`${n} * texture2D(u_texture${s}, v_texCoord)`).setSymbolSizeExpression(o),"icon-width"in r&&"icon-height"in r&&e.setSymbolSizeExpression(`vec2(${Z(i,r["icon-width"],N)}, ${Z(i,r["icon-height"],N)})`),"icon-offset"in r&&"icon-size"in r){let a=Z(i,r["icon-size"],at),l=e.getSymbolSizeExpression();e.setSymbolSizeExpression(a);let h=Gd(r,"icon-",i,"v_quadSizePx",a);e.setTextureCoordinateExpression(`(vec4((${h}).xyxy) + vec4(0., 0., ${a})) / (${l}).xyxy`)}if(kd(r,e,i,"icon-"),"icon-anchor"in r){let a=Z(i,r["icon-anchor"],at),l="1.0";"icon-scale"in r&&(l=Z(i,r["icon-scale"],Ft));let h;r["icon-anchor-x-units"]==="pixels"&&r["icon-anchor-y-units"]==="pixels"?h=`${a} * ${l}`:r["icon-anchor-x-units"]==="pixels"?h=`${a} * vec2(vec2(${l}).x, v_quadSizePx.y)`:r["icon-anchor-y-units"]==="pixels"?h=`${a} * vec2(v_quadSizePx.x, vec2(${l}).x)`:h=`${a} * v_quadSizePx`;let c=`v_quadSizePx * vec2(0.5, -0.5) + ${h} * vec2(-1., 1.)`;if("icon-anchor-origin"in r)switch(r["icon-anchor-origin"]){case"top-right":c=`v_quadSizePx * -0.5 + ${h}`;break;case"bottom-left":c=`v_quadSizePx * 0.5 - ${h}`;break;case"bottom-right":c=`v_quadSizePx * vec2(-0.5, 0.5) + ${h} * vec2(1., -1.)`;break;default:}e.setSymbolOffsetExpression(`${e.getSymbolOffsetExpression()} + ${c}`)}}function xE(r,e,t,i){if("stroke-color"in r&&e.setStrokeColorExpression(Z(i,r["stroke-color"],pe)),"stroke-pattern-src"in r){let n=zl(r["stroke-pattern-src"]),s=Nd(r,e,t,"stroke-pattern-",n),o=s,a="vec2(0.)";"stroke-pattern-offset"in r&&"stroke-pattern-size"in r&&(o=Z(i,r["stroke-pattern-size"],at),a=Gd(r,"stroke-pattern-",i,s,o));let l="0.";"stroke-pattern-spacing"in r&&(l=Z(i,r["stroke-pattern-spacing"],N));let h="0.";"stroke-pattern-start-offset"in r&&(h=Z(i,r["stroke-pattern-start-offset"],N)),i.functions.sampleStrokePattern=`vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float startOffsetPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {
513
+ float currentLengthScaled = (currentLengthPx - startOffsetPx) * sampleSize.y / lineWidth;
514
+ float spacingScaled = spacingPx * sampleSize.y / lineWidth;
515
+ float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));
516
+ float isInsideOfPattern = step(uCoordPx, sampleSize.x);
517
+ float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;
518
+ // make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
519
+ uCoordPx = clamp(uCoordPx, 0.5, sampleSize.x - 0.5);
520
+ vCoordPx = clamp(vCoordPx, 0.5, sampleSize.y - 0.5);
521
+ vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;
522
+ return texture2D(texture, texCoord) * vec4(1.0, 1.0, 1.0, isInsideOfPattern);
523
+ }`;let c=`u_texture${n}`,u="1.";"stroke-color"in r&&(u=e.getStrokeColorExpression()),e.setStrokeColorExpression(`${u} * sampleStrokePattern(${c}, ${s}, ${a}, ${o}, ${l}, ${h}, currentLengthPx, currentRadiusRatio, v_width)`),i.functions.computeStrokePatternLength=`float computeStrokePatternLength(vec2 sampleSize, float spacingPx, float lineWidth) {
524
+ float patternLengthPx = sampleSize.x / sampleSize.y * lineWidth;
525
+ return patternLengthPx + spacingPx;
526
+ }`,e.setStrokePatternLengthExpression(`computeStrokePatternLength(${o}, ${l}, v_width)`)}if("stroke-width"in r&&e.setStrokeWidthExpression(Z(i,r["stroke-width"],N)),"stroke-offset"in r&&e.setStrokeOffsetExpression(Z(i,r["stroke-offset"],N)),"stroke-line-cap"in r&&e.setStrokeCapExpression(Z(i,r["stroke-line-cap"],Ne)),"stroke-line-join"in r&&e.setStrokeJoinExpression(Z(i,r["stroke-line-join"],Ne)),"stroke-miter-limit"in r&&e.setStrokeMiterLimitExpression(Z(i,r["stroke-miter-limit"],N)),"stroke-line-dash"in r){i.functions.getSingleDashDistance=`float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType, float lineWidth) {
527
+ float localDistance = mod(distance, dashLengthTotal);
528
+ float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;
529
+ distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);
530
+ if (capType == ${_i("square")}) {
531
+ distanceSegment -= lineWidth * 0.5;
532
+ } else if (capType == ${_i("round")}) {
533
+ distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);
534
+ }
535
+ return distanceSegment;
536
+ }`;let n=r["stroke-line-dash"].map(g=>Z(i,g,N));n.length%2===1&&(n=[...n,...n]);let s="0.";"stroke-line-dash-offset"in r&&(s=Z(i,r["stroke-line-dash-offset"],N));let a=`dashDistanceField_${zl(r["stroke-line-dash"])}`,l=n.map((g,m)=>`float dashLength${m}`).join(", "),h=n.map((g,m)=>`dashLength${m}`).join(" + "),c="0.",u=`getSingleDashDistance(distance, radius, ${c}, dashLength0, totalDashLength, capType, lineWidth)`;for(let g=2;g<n.length;g+=2)c=`${c} + dashLength${g-2} + dashLength${g-1}`,u=`min(${u}, getSingleDashDistance(distance, radius, ${c}, dashLength${g}, totalDashLength, capType, lineWidth))`;i.functions[a]=`float ${a}(float distance, float radius, float capType, float lineWidth, ${l}) {
537
+ float totalDashLength = ${h};
538
+ return ${u};
539
+ }`;let d=n.map((g,m)=>`${g}`).join(", ");e.setStrokeDistanceFieldExpression(`${a}(currentLengthPx + ${s}, currentRadiusPx, capType, v_width, ${d})`);let f=n.join(" + ");e.getStrokePatternLengthExpression()&&(i.functions.combinePatternLengths=`float combinePatternLengths(float patternLength1, float patternLength2) {
540
+ return patternLength1 * patternLength2;
541
+ }`,f=`combinePatternLengths(${e.getStrokePatternLengthExpression()}, ${f})`),e.setStrokePatternLengthExpression(f)}}function yE(r,e,t,i){if("fill-color"in r&&e.setFillColorExpression(Z(i,r["fill-color"],pe)),"fill-pattern-src"in r){let n=zl(r["fill-pattern-src"]),s=Nd(r,e,t,"fill-pattern-",n),o=s,a="vec2(0.)";"fill-pattern-offset"in r&&"fill-pattern-size"in r&&(o=Z(i,r["fill-pattern-size"],at),a=Gd(r,"fill-pattern-",i,s,o)),i.functions.sampleFillPattern=`vec4 sampleFillPattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, vec2 pxOrigin, vec2 pxPosition) {
542
+ float scaleRatio = pow(2., mod(u_zoom + 0.5, 1.) - 0.5);
543
+ vec2 pxRelativePos = pxPosition - pxOrigin;
544
+ // rotate the relative position from origin by the current view rotation
545
+ pxRelativePos = vec2(pxRelativePos.x * cos(u_rotation) - pxRelativePos.y * sin(u_rotation), pxRelativePos.x * sin(u_rotation) + pxRelativePos.y * cos(u_rotation));
546
+ // sample position is computed according to the sample offset & size
547
+ vec2 samplePos = mod(pxRelativePos / scaleRatio, sampleSize);
548
+ // also make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
549
+ samplePos = clamp(samplePos, vec2(0.5), sampleSize - vec2(0.5));
550
+ samplePos.y = sampleSize.y - samplePos.y; // invert y axis so that images appear upright
551
+ return texture2D(texture, (samplePos + textureOffset) / textureSize);
552
+ }`;let l=`u_texture${n}`,h="1.";"fill-color"in r&&(h=e.getFillColorExpression()),e.setFillColorExpression(`${h} * sampleFillPattern(${l}, ${s}, ${a}, ${o}, pxOrigin, pxPos)`)}}function Ud(r,e,t){let i=Il(),n=new os,s={};if("icon-src"in r?_E(r,n,s,i):"shape-points"in r?pE(r,n,s,i):"circle-radius"in r&&mE(r,n,s,i),xE(r,n,s,i),yE(r,n,s,i),t){let l=Z(i,t,Me);n.setFragmentDiscardExpression(`!${l}`)}let o={};function a(l,h,c,u){if(!i[l])return;let d=Ml(c),f=Al(c);n.addAttribute(`a_${h}`,d),o[h]={size:f,callback:u}}return a("geometryType",Sd,Ne,l=>hr(po(l.getGeometry()))),a("featureId",vd,Ne|N,l=>{let h=l.getId()??null;return typeof h=="string"?hr(h):h}),Ol(n,i),{builder:n,attributes:{...o,...kl(i)},uniforms:{...s,...Dl(i,e)}}}var EE=[],Bd;function TE(){return Bd||(Bd=E_()),Bd}var CE=0,oi={POSITION:"a_position",LOCAL_POSITION:"a_localPosition",SEGMENT_START:"a_segmentStart",SEGMENT_END:"a_segmentEnd",MEASURE_START:"a_measureStart",MEASURE_END:"a_measureEnd",ANGLE_TANGENT_SUM:"a_angleTangentSum",JOIN_ANGLES:"a_joinAngles",DISTANCE_LOW:"a_distanceLow",DISTANCE_HIGH:"a_distanceHigh"},zd=class{constructor(e,t,i,n){this.helper_,this.hitDetectionEnabled_=!!n,this.styleShaders=vE(e,t),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return T_(this.ref,EE)},size:2});for(let s of this.styleShaders){for(let o in s.attributes)o in this.customAttributes_||(this.customAttributes_[o]=s.attributes[o]);for(let o in s.uniforms)o in this.uniforms_||(this.uniforms_[o]=s.uniforms[o])}this.renderPasses_=this.styleShaders.map(s=>{let o={},a=Object.entries(this.customAttributes_).map(([l,h])=>({name:l in s.attributes||l==="hitColor"?`a_${l}`:null,size:h.size||1,type:$e.FLOAT}));return s.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:s.builder.getFillVertexShader(),fragmentShader:s.builder.getFillFragmentShader(),attributesDesc:[{name:oi.POSITION,size:2,type:$e.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),s.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:s.builder.getStrokeVertexShader(),fragmentShader:s.builder.getStrokeFragmentShader(),attributesDesc:[{name:oi.LOCAL_POSITION,size:2,type:$e.FLOAT}],instancedAttributesDesc:[{name:oi.SEGMENT_START,size:2,type:$e.FLOAT},{name:oi.MEASURE_START,size:1,type:$e.FLOAT},{name:oi.SEGMENT_END,size:2,type:$e.FLOAT},{name:oi.MEASURE_END,size:1,type:$e.FLOAT},{name:oi.JOIN_ANGLES,size:2,type:$e.FLOAT},{name:oi.DISTANCE_LOW,size:1,type:$e.FLOAT},{name:oi.DISTANCE_HIGH,size:1,type:$e.FLOAT},{name:oi.ANGLE_TANGENT_SUM,size:1,type:$e.FLOAT},...a],instancePrimitiveVertexCount:6}),s.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:s.builder.getSymbolVertexShader(),fragmentShader:s.builder.getSymbolFragmentShader(),attributesDesc:[{name:oi.LOCAL_POSITION,size:2,type:$e.FLOAT}],instancedAttributesDesc:[{name:oi.POSITION,size:2,type:$e.FLOAT},...a],instancePrimitiveVertexCount:6}),o}),this.hasFill_=this.renderPasses_.some(s=>s.fillRenderPass),this.hasStroke_=this.renderPasses_.some(s=>s.strokeRenderPass),this.hasSymbol_=this.renderPasses_.some(s=>s.symbolRenderPass),this.setHelper(i)}async generateBuffers(e,t){if(e.isEmpty())return null;let i=this.generateRenderInstructions_(e,t),[n,s,o]=await Promise.all([this.generateBuffersForType_(i.polygonInstructions,"Polygon",t),this.generateBuffersForType_(i.lineStringInstructions,"LineString",t),this.generateBuffersForType_(i.pointInstructions,"Point",t)]),a=Yi(ae(),t);return{polygonBuffers:n,lineStringBuffers:s,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(e,t){let i=this.hasFill_?R_(e.polygonBatch,new Float32Array(0),this.customAttributes_,t):null,n=this.hasStroke_?S_(e.lineStringBatch,new Float32Array(0),this.customAttributes_,t):null,s=this.hasSymbol_?v_(e.pointBatch,new Float32Array(0),this.customAttributes_,t):null;return{polygonInstructions:i,lineStringInstructions:n,pointInstructions:s}}generateBuffersForType_(e,t,i){if(e===null)return null;let n=CE++,s;switch(t){case"Polygon":s=Bl.GENERATE_POLYGON_BUFFERS;break;case"LineString":s=Bl.GENERATE_LINE_STRING_BUFFERS;break;case"Point":s=Bl.GENERATE_POINT_BUFFERS;break;default:}let o={id:n,type:s,renderInstructions:e.buffer,renderInstructionsTransform:i,customAttributesSize:Oo(this.customAttributes_)},a=TE();return a.postMessage(o,[e.buffer]),e=null,new Promise(l=>{let h=c=>{let u=c.data;if(u.id!==n||(a.removeEventListener("message",h),!this.helper_.getGL()))return;let d=new wl(bo,ns).fromArrayBuffer(u.indicesBuffer),f=new wl(is,ns).fromArrayBuffer(u.vertexAttributesBuffer),g=new wl(is,ns).fromArrayBuffer(u.instanceAttributesBuffer);this.helper_.flushBufferData(d),this.helper_.flushBufferData(f),this.helper_.flushBufferData(g),l([d,f,g])};a.addEventListener("message",h)})}render(e,t,i){for(let n of this.renderPasses_)n.fillRenderPass&&this.renderInternal_(e.polygonBuffers[0],e.polygonBuffers[1],e.polygonBuffers[2],n.fillRenderPass,t,i),n.strokeRenderPass&&this.renderInternal_(e.lineStringBuffers[0],e.lineStringBuffers[1],e.lineStringBuffers[2],n.strokeRenderPass,t,i),n.symbolRenderPass&&this.renderInternal_(e.pointBuffers[0],e.pointBuffers[1],e.pointBuffers[2],n.symbolRenderPass,t,i)}renderInternal_(e,t,i,n,s,o){let a=e.getSize();if(a===0)return;let l=n.instancedAttributesDesc.length;if(this.helper_.useProgram(n.program,s),this.helper_.bindBuffer(t),this.helper_.bindBuffer(e),this.helper_.enableAttributes(n.attributesDesc),this.helper_.bindBuffer(i),this.helper_.enableAttributesInstanced(n.instancedAttributesDesc),o(),l){let h=n.instancedAttributesDesc.reduce((u,d)=>u+(d.size||1),0),c=i.getSize()/h;this.helper_.drawElementsInstanced(0,a,c)}else this.helper_.drawElements(0,a)}setHelper(e,t=null){this.helper_=e;for(let i of this.renderPasses_)i.fillRenderPass&&(i.fillRenderPass.program=this.helper_.getProgram(i.fillRenderPass.fragmentShader,i.fillRenderPass.vertexShader)),i.strokeRenderPass&&(i.strokeRenderPass.program=this.helper_.getProgram(i.strokeRenderPass.fragmentShader,i.strokeRenderPass.vertexShader)),i.symbolRenderPass&&(i.symbolRenderPass.program=this.helper_.getProgram(i.symbolRenderPass.fragmentShader,i.symbolRenderPass.vertexShader));this.helper_.addUniforms(this.uniforms_),t&&(t.polygonBuffers&&(this.helper_.flushBufferData(t.polygonBuffers[0]),this.helper_.flushBufferData(t.polygonBuffers[1]),this.helper_.flushBufferData(t.polygonBuffers[2])),t.lineStringBuffers&&(this.helper_.flushBufferData(t.lineStringBuffers[0]),this.helper_.flushBufferData(t.lineStringBuffers[1]),this.helper_.flushBufferData(t.lineStringBuffers[2])),t.pointBuffers&&(this.helper_.flushBufferData(t.pointBuffers[0]),this.helper_.flushBufferData(t.pointBuffers[1]),this.helper_.flushBufferData(t.pointBuffers[2])))}},P_=zd;function vE(r,e){let t=Array.isArray(r)?r:[r];if("style"in t[0]){let i=[],n=t,s=[];for(let o of n){let a=Array.isArray(o.style)?o.style:[o.style],l=o.filter;o.else&&s.length&&(l=["all",...s.map(c=>["!",c])],o.filter&&l.push(o.filter),l.length<3&&(l=l[1])),o.filter&&s.push(o.filter);let h=a.map(c=>Ud(c,e,l));i.push(...h)}return i}return"builder"in t[0]?t:t.map(i=>Ud(i,e,null))}var Se={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};var Oi=new Uint8Array(4),jd=class{constructor(e,t){this.helper_=e;let i=e.getGL();this.texture_=i.createTexture(),this.framebuffer_=i.createFramebuffer(),this.depthbuffer_=i.createRenderbuffer(),this.size_=t||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(e){Ve(e,this.size_)||(this.size_[0]=e[0],this.size_[1]=e[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){let e=this.size_,t=this.helper_.getGL();t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.readPixels(0,0,e[0],e[1],t.RGBA,t.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(e,t){if(e<0||t<0||e>this.size_[0]||t>=this.size_[1])return Oi[0]=0,Oi[1]=0,Oi[2]=0,Oi[3]=0,Oi;this.readAll();let i=Math.floor(e)+(this.size_[1]-Math.floor(t)-1)*this.size_[0];return Oi[0]=this.data_[i*4],Oi[1]=this.data_[i*4+1],Oi[2]=this.data_[i*4+2],Oi[3]=this.data_[i*4+3],Oi}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){let e=this.size_,t=this.helper_.getGL();this.texture_=this.helper_.createTexture(e,null,this.texture_),t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.viewport(0,0,e[0],e[1]),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture_,0),t.bindRenderbuffer(t.RENDERBUFFER,this.depthbuffer_),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e[0],e[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(e[0]*e[1]*4)}},L_=jd;function b_(r,e){let t=r.viewState.projection,n=e.getSource().getWrapX()&&t.canWrapX(),s=t.getExtent(),o=r.extent,a=n?z(s):null,l=n?Math.ceil((o[2]-s[2])/a)+1:1;return[n?Math.floor((o[0]-s[0])/a):0,l,a]}var as={...Ai,RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",GLOBAL_ALPHA:"u_globalAlpha"},Vd=class extends c_{constructor(e,t){let i={[as.RENDER_EXTENT]:[0,0,0,0],[as.PATTERN_ORIGIN]:[0,0],[as.GLOBAL_ALPHA]:1};super(e,{uniforms:i,postProcesses:t.postProcesses}),this.hitDetectionEnabled_=!t.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=me(),this.currentTransform_=ae(),this.tmpCoords_=[0,0],this.tmpTransform_=ae(),this.tmpMat4_=Sl(),this.currentFrameStateTransform_=ae(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(t),this.batch_=new y_,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(e){let t=this.getLayer().getSource(),i=we(),n;i&&(n=zt(i,e.viewState.projection)),this.batch_.addFeatures(t.getFeatures(),n),this.sourceListenKeys_=[k(t,Se.ADDFEATURE,this.handleSourceFeatureAdded_.bind(this,n)),k(t,Se.CHANGEFEATURE,this.handleSourceFeatureChanged_.bind(this,n),this),k(t,Se.REMOVEFEATURE,this.handleSourceFeatureDelete_,this),k(t,Se.CLEAR,this.handleSourceFeatureClear_,this)]}applyOptions_(e){this.styleVariables_=e.variables,this.style_=e.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new P_(this.style_,this.styleVariables_,this.helper,this.hitDetectionEnabled_)}reset(e){this.applyOptions_(e),this.helper&&this.createRenderers_(),super.reset(e)}afterHelperCreated(){this.styleRenderer_?this.styleRenderer_.setHelper(this.helper,this.buffers_):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new L_(this.helper))}handleSourceFeatureAdded_(e,t){let i=t.feature;this.batch_.addFeature(i,e)}handleSourceFeatureChanged_(e,t){let i=t.feature;this.batch_.changeFeature(i,e)}handleSourceFeatureDelete_(e){let t=e.feature;this.batch_.removeFeature(t)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(e){Pa(this.tmpTransform_,this.currentFrameStateTransform_),Sn(this.tmpTransform_,e),this.helper.setUniformMatrixValue(as.PROJECTION_MATRIX,Lo(this.tmpMat4_,this.tmpTransform_)),Yi(this.tmpTransform_,this.tmpTransform_),this.helper.setUniformMatrixValue(as.SCREEN_TO_WORLD_MATRIX,Lo(this.tmpMat4_,this.tmpTransform_)),this.tmpCoords_[0]=0,this.tmpCoords_[1]=0,Yi(this.tmpTransform_,e),le(this.tmpTransform_,this.tmpCoords_),this.helper.setUniformFloatVec2(as.PATTERN_ORIGIN,this.tmpCoords_)}renderFrame(e){let t=this.helper.getGL();this.preRender(t,e);let[i,n,s]=b_(e,this.getLayer());this.helper.prepareDraw(e),this.renderWorlds(e,!1,i,n,s),this.helper.finalizeDraw(e,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);let o=this.helper.getCanvas();return this.hitDetectionEnabled_&&(this.renderWorlds(e,!0,i,n,s),this.hitRenderTarget_.clearCachedData()),this.postRender(t,e),o}prepareFrameInternal(e){this.initialFeaturesAdded_||(this.addInitialFeatures_(e),this.initialFeaturesAdded_=!0);let t=this.getLayer(),i=t.getSource(),n=e.viewState,s=!e.viewHints[he.ANIMATING]&&!e.viewHints[he.INTERACTING],o=!qe(this.previousExtent_,e.extent),a=this.sourceRevision_<i.getRevision();if(a&&(this.sourceRevision_=i.getRevision()),s&&(o||a)){let l=n.projection,h=n.resolution,c=t instanceof Li?t.getRenderBuffer():0,u=Le(e.extent,c*h),d=we();d?i.loadFeatures(Vt(u,d),Ra(h,l),d):i.loadFeatures(u,h,l),this.ready=!1;let f=this.helper.makeProjectionTransform(e,ae());this.styleRenderer_.generateBuffers(this.batch_,f).then(g=>{this.buffers_&&this.disposeBuffers(this.buffers_),this.buffers_=g,this.ready=!0,this.getLayer().changed()}),this.previousExtent_=e.extent.slice()}return!0}renderWorlds(e,t,i,n,s){let o=i;t&&(this.hitRenderTarget_.setSize([Math.floor(e.size[0]/2),Math.floor(e.size[1]/2)]),this.helper.prepareDrawToRenderTarget(e,this.hitRenderTarget_,!0));do this.helper.makeProjectionTransform(e,this.currentFrameStateTransform_),La(this.currentFrameStateTransform_,o*s,0),this.buffers_&&this.styleRenderer_.render(this.buffers_,e,()=>{this.applyUniforms_(this.buffers_.invertVerticesTransform),this.helper.applyHitDetectionUniform(t)});while(++o<n)}forEachFeatureAtCoordinate(e,t,i,n,s){if(W(this.hitDetectionEnabled_,"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has been disabled using the `disableHitDetection: true` option."),!this.styleRenderer_||!this.hitDetectionEnabled_)return;let o=le(t.coordinateToPixelTransform,e.slice()),a=this.hitRenderTarget_.readPixel(o[0]/2,o[1]/2),l=[a[0]/255,a[1]/255,a[2]/255,a[3]/255],h=C_(l),c=this.batch_.getFeatureFromRef(h);if(c)return n(c,this.getLayer(),null)}disposeBuffers(e){let t=i=>{for(let n of i)n&&this.helper.deleteBuffer(n)};e.pointBuffers&&t(e.pointBuffers),e.lineStringBuffers&&t(e.lineStringBuffers),e.polygonBuffers&&t(e.polygonBuffers)}disposeInternal(){this.buffers_&&this.disposeBuffers(this.buffers_),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach(function(e){K(e)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}},I_=Vd;var fn={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},SE=["#00f","#0ff","#0f0","#ff0","#f00"],Wd=class extends Li{constructor(e){e=e||{};let t=Object.assign({},e);delete t.gradient,delete t.radius,delete t.blur,delete t.weight,super(t),this.on,this.once,this.un,this.filter_=e.filter??!0,this.styleVariables_=e.variables||{},this.gradient_=null,this.addChangeListener(fn.GRADIENT,this.handleGradientChanged_),this.setGradient(e.gradient?e.gradient:SE),this.setBlur(e.blur!==void 0?e.blur:15),this.setRadius(e.radius!==void 0?e.radius:8);let i=e.weight?e.weight:"weight";this.weight_=i,this.setRenderOrder(null)}getBlur(){return this.get(fn.BLUR)}getGradient(){return this.get(fn.GRADIENT)}getRadius(){return this.get(fn.RADIUS)}handleGradientChanged_(){this.gradient_=RE(this.getGradient())}setBlur(e){let t=this.get(fn.BLUR);if(this.set(fn.BLUR,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setGradient(e){this.set(fn.GRADIENT,e)}setRadius(e){let t=this.get(fn.RADIUS);if(this.set(fn.RADIUS,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setFilter(e){this.filter_=e,this.changed(),this.clearRenderer()}setWeight(e){this.weight_=e,this.changed(),this.clearRenderer()}createRenderer(){let e=new os,t=Il(),i=Z(t,this.filter_,Me),n=Z(t,this.getRadius(),N),s=Z(t,this.getBlur(),N),o={};typeof this.getBlur()=="number"&&(s="a_blur",o.a_blur=()=>this.getBlur(),e.addUniform("a_blur","float")),typeof this.getRadius()=="number"&&(n="a_radius",o.a_radius=()=>this.getRadius(),e.addUniform("a_radius","float"));let a={},l=null;if(typeof this.weight_=="string"||typeof this.weight_=="function"){let u=typeof this.weight_=="string"?d=>d.get(this.weight_):this.weight_;a.prop_weight={size:1,callback:d=>{let f=u(d);return f!==void 0?B(f,0,1):1}},l="a_prop_weight",e.addAttribute("a_prop_weight","float")}else{let u=["clamp",this.weight_,0,1];l=Z(t,u,N)}e.addFragmentShaderFunction(`float getBlurSlope() {
553
+ float blur = max(1., ${s});
554
+ float radius = ${n};
555
+ return radius / blur;
556
+ }`).setSymbolSizeExpression(`vec2(${n} + ${s}) * 2.`).setSymbolColorExpression(`vec4(smoothstep(0., 1., (1. - length(coordsPx * 2. / v_quadSizePx)) * getBlurSlope()) * ${l})`).setStrokeColorExpression(`vec4(smoothstep(0., 1., (1. - length(currentRadiusPx * 2. / v_width)) * getBlurSlope()) * ${l})`).setStrokeWidthExpression(`(${n} + ${s}) * 2.`).setFillColorExpression(`vec4(${l})`).setFragmentDiscardExpression(`!${i}`),Ol(e,t);let h=kl(t),c=Dl(t,this.styleVariables_);return new I_(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:e,attributes:{...h,...a},uniforms:{...c,...o}},disableHitDetection:!1,postProcesses:[{fragmentShader:`
557
+ precision mediump float;
558
+
559
+ uniform sampler2D u_image;
560
+ uniform sampler2D u_gradientTexture;
561
+ uniform float u_opacity;
562
+
563
+ varying vec2 v_texCoord;
564
+
565
+ void main() {
566
+ vec4 color = texture2D(u_image, v_texCoord);
567
+ gl_FragColor.a = color.a * u_opacity;
568
+ gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;
569
+ gl_FragColor.rgb *= gl_FragColor.a;
570
+ }`,uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}updateStyleVariables(e){Object.assign(this.styleVariables_,e),this.changed()}renderDeclutter(){}};function RE(r){let i=ne(1,256),n=i.createLinearGradient(0,0,1,256),s=1/(r.length-1);for(let o=0,a=r.length;o<a;++o)n.addColorStop(o*s,r[o]);return i.fillStyle=n,i.fillRect(0,0,1,256),i.canvas}var F_=Wd;var wE={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},M_={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]},Xd=class extends _l{constructor(e,t){super(e,t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=ae(),this.tileClipContexts_=null}enqueueTilesForNextExtent(){return this.getLayer().getRenderMode()!=="vector"}drawTile(e,t,i,n,s,o,a,l){this.updateExecutorGroup_(e,t.pixelRatio,t.viewState.projection),this.tileImageNeedsRender_(e)&&this.renderTileImage_(e,t),super.drawTile(e,t,i,n,s,o,a,l)}getTile(e,t,i,n){let s=this.getOrCreateTile(e,t,i,n);if(!s)return null;let o=n.viewState,a=o.resolution,l=n.viewHints,h=this.getLayer().getSource(),c=h.getTileGridForProjection(o.projection),u=!(l[he.ANIMATING]||l[he.INTERACTING]),d=c.getZForResolution(a,h.zDirection)===e;return u&&d?s.wantedResolution=a:s.wantedResolution||(s.wantedResolution=c.getResolution(e)),s}prepareFrame(e){let t=this.getLayer().getRevision();return this.renderedLayerRevision_!==t&&(this.renderedLayerRevision_=t,this.renderedTiles.length=0),super.prepareFrame(e)}updateExecutorGroup_(e,t,i){let n=this.getLayer(),s=n.getRevision(),o=n.getRenderOrder()||null,a=e.wantedResolution,l=e.getReplayState(n);if(!l.dirty&&l.renderedResolution===a&&l.renderedRevision==s&&l.renderedPixelRatio===t&&l.renderedRenderOrder==o)return;let h=n.getSource(),c=!!n.getDeclutter(),u=h.getTileGrid(),f=h.getTileGridForProjection(i).getTileCoordExtent(e.wrappedTileCoord),g=h.getSourceTiles(t,i,e),m=P(n);delete e.hitDetectionImageData[m],e.executorGroups[m]=[],l.dirty=!1;for(let p=0,_=g.length;p<_;++p){let x=g[p];if(x.getState()!=F.LOADED)continue;let y=h.getProjection(),E=x.tileCoord,T=u.getTileCoordExtent(E);i&&y&&!Ie(i,y)&&(T=jt(T,y,i,32));let v=Xe(f,T),S=Le(v,n.getRenderBuffer()*a,this.tempExtent),w=qe(T,v)?null:S,R=new yl(0,v,a,t),b=lr(a,t),D=function(M,Y){let U,q=M.getStyleFunction()||n.getStyleFunction();if(q&&(U=q(M,a)),U){let H=this.renderFeature(M,b,U,R,c,Y);l.dirty=l.dirty||H}},G=x.getFeatures();o&&o!==l.renderedRenderOrder&&G.sort(o);for(let M=0,Y=G.length;M<Y;++M){let U=G[M];i&&x.projection&&!Ie(i,x.projection)&&(U=U.clone(),U.getGeometry().applyTransform(ct(x.projection,i))),(!w||te(w,U.getGeometry().getExtent()))&&D.call(this,U,M)}let O=R.finish(),X=n.getRenderMode()!=="vector"&&c&&g.length===1?null:v,Q=new El(X,a,t,h.getOverlaps(),O,n.getRenderBuffer(),!0);e.executorGroups[m].push(Q)}l.renderedRevision=s,l.renderedPixelRatio=t,l.renderedRenderOrder=o,l.renderedResolution=a}forEachFeatureAtCoordinate(e,t,i,n,s){let o=t.viewState.resolution,a=t.viewState.rotation;i=i??0;let l=this.getLayer(),c=l.getSource().getTileGridForProjection(t.viewState.projection),u=Re([e]);Le(u,o*i,u);let d={},f=function(y,E,T){let v=y.getId();v===void 0&&(v=P(y));let S=d[v];if(S){if(S!==!0&&T<S.distanceSq){if(T===0)return d[v]=!0,s.splice(s.lastIndexOf(S),1),n(y,l,E);S.geometry=E,S.distanceSq=T}}else{if(T===0)return d[v]=!0,n(y,l,E);s.push(d[v]={feature:y,layer:l,geometry:E,distanceSq:T,callback:n})}},g=this.renderedTiles,m=P(l),p=l.getDeclutter(),_=p?t.declutter?.[p]?.all().map(y=>y.value):null,x;e:for(let y=0,E=g.length;y<E;++y){let T=g[y],v=c.getTileCoordExtent(T.wrappedTileCoord);if(!te(v,u))continue;let S=T.executorGroups[m];for(let w=0,R=S.length;w<R;++w)if(x=S[w].forEachFeatureAtCoordinate(e,o,a,i,f,_),x)break e}return x}getFeatures(e){return this.renderedTiles.length===0?Promise.resolve([]):new Promise((t,i)=>{let n=this.getLayer(),s=n.getSource(),o=this.renderedProjection,a=o.getExtent(),l=this.renderedResolution,h=s.getTileGridForProjection(o),c=le(this.renderedPixelToCoordinateTransform_,e.slice()),u=h.getTileCoordForCoordAndResolution(c,l).toString(),d=this.renderedTiles.find(y=>y.tileCoord.toString()===u&&y.getState()===F.LOADED);if(!d||d.loadingSourceTiles>0){t([]);return}s.getWrapX()&&o.canWrapX()&&!Ue(a,h.getTileCoordExtent(d.tileCoord))&&En(c,o);let f=P(n),g=h.getTileCoordExtent(d.wrappedTileCoord),m=Je(g),p=[(c[0]-m[0])/l,(m[1]-c[1])/l],_=d.getSourceTiles().reduce((y,E)=>y.concat(E.getFeatures()),[]),x=d.hitDetectionImageData[f];if(!x){let y=Ee(h.getTileSize(h.getZForResolution(l,s.zDirection))),E=this.renderedRotation_,T=[this.getRenderTransform(h.getTileCoordCenter(d.wrappedTileCoord),l,0,At,y[0]*At,y[1]*At,0)];x=Cl(y,T,_,n.getStyleFunction(),h.getTileCoordExtent(d.wrappedTileCoord),d.getReplayState(n).renderedResolution,E),d.hitDetectionImageData[f]=x}t(vl(p,_,x))})}getFeaturesInExtent(e){let t=[],i=this.getTileCache();if(i.getCount()===0)return t;let s=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),o=s.getZForResolution(this.renderedResolution),a={};return i.forEach(l=>{if(l.tileCoord[0]!==o||l.getState()!==F.LOADED)return;let h=l.getSourceTiles();for(let c=0,u=h.length;c<u;++c){let d=h[c],f=d.getKey();if(f in a)continue;a[f]=!0;let g=d.tileCoord;if(te(e,s.getTileCoordExtent(g))){let m=d.getFeatures();if(m)for(let p=0,_=m.length;p<_;++p){let x=m[p],y=x.getGeometry();te(e,y.getExtent())&&t.push(x)}}}}),t}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.renderedLayerRevision_!==void 0&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}renderDeclutter(e,t){let i=this.context,n=i.globalAlpha;i.globalAlpha=t.opacity;let s=e.viewHints,o=!(s[he.ANIMATING]||s[he.INTERACTING]),a=[this.context.canvas.width,this.context.canvas.height],l=this.getLayer().getDeclutter(),h=l?e.declutter?.[l]:void 0,c=P(this.getLayer()),u=this.renderedTiles;for(let d=0,f=u.length;d<f;++d){let g=u[d],m=g.executorGroups[c];if(m)for(let p=m.length-1;p>=0;--p)m[p].execute(this.context,a,this.getTileRenderTransform(g,e),e.viewState.rotation,o,es,h)}i.globalAlpha=n}renderDeferredInternal(e){let t=this.renderedTiles,i=P(this.getLayer()),n=t.reduce((l,h,c)=>(h.executorGroups[i].forEach(u=>l.push({executorGroup:u,index:c})),l),[]),s=n.map(({executorGroup:l})=>l.getDeferredZIndexContexts()),o={};for(let l=0,h=n.length;l<h;++l){let c=n[l].executorGroup.getDeferredZIndexContexts();for(let u in c)o[u]=!0}Object.keys(o).map(Number).sort(_t).forEach(l=>{s.forEach((h,c)=>{h[l]&&(h[l].forEach(u=>{let{executorGroup:d,index:f}=n[c],g=d.getRenderedContext(),m=g.globalAlpha;g.globalAlpha=this.renderedOpacity_;let p=this.tileClipContexts_[f];p&&p.draw(g),u.draw(g),p&&g.restore(),g.globalAlpha=m,u.clear()}),h[l].length=0)})})}getTileRenderTransform(e,t){let i=t.pixelRatio,n=t.viewState,s=n.center,o=n.resolution,a=n.rotation,l=t.size,h=Math.round(l[0]*i),c=Math.round(l[1]*i),d=this.getLayer().getSource().getTileGridForProjection(t.viewState.projection),f=e.tileCoord,g=d.getTileCoordExtent(e.wrappedTileCoord),m=d.getTileCoordExtent(f,this.tempExtent)[0]-g[0];return Sn(Lr(this.inversePixelTransform.slice(),1/i,1/i),this.getRenderTransform(s,o,a,i,h,c,m))}postRender(e,t){let i=t.viewHints,n=!(i[he.ANIMATING]||i[he.INTERACTING]);this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice(),this.renderedRotation_=t.viewState.rotation,this.renderedOpacity_=t.layerStatesArray[t.layerIndex].opacity;let s=this.getLayer(),o=s.getRenderMode(),a=e.globalAlpha;e.globalAlpha=this.renderedOpacity_;let l=s.getDeclutter(),h=l?M_[o].filter(T=>!es.includes(T)):M_[o],c=t.viewState,u=c.rotation,d=s.getSource(),g=d.getTileGridForProjection(c.projection).getZForResolution(c.resolution,d.zDirection),m=this.renderedTiles,p=[],_=[],x=[],y=P(s),E=!0;for(let T=m.length-1;T>=0;--T){let v=m[T];E=E&&!v.getReplayState(s).dirty;let S=v.executorGroups[y].filter(X=>X.hasExecutors(h));if(S.length===0)continue;let w=this.getTileRenderTransform(v,t),R=v.tileCoord[0],b=!1,D=S[0].getClipCoords(w),G=e,O;if(D){O=new Kr,G=O.getContext();for(let X=0,Q=p.length;X<Q;++X)if(g!==R&&R<_[X]){let M=p[X];te([D[0],D[3],D[4],D[7]],[M[0],M[3],M[4],M[7]])&&(b||(G.save(),b=!0),G.beginPath(),G.moveTo(D[0],D[1]),G.lineTo(D[2],D[3]),G.lineTo(D[4],D[5]),G.lineTo(D[6],D[7]),G.moveTo(M[6],M[7]),G.lineTo(M[4],M[5]),G.lineTo(M[2],M[3]),G.lineTo(M[0],M[1]),G.clip())}p.push(D),_.push(R)}for(let X=0,Q=S.length;X<Q;++X)S[X].execute(e,[e.canvas.width,e.canvas.height],w,u,n,h,t.declutter?.[l]);b&&(G===e?G.restore():x[T]=O)}e.globalAlpha=a,this.ready=E,this.tileClipContexts_=x,t.declutter||this.renderDeferredInternal(t),super.postRender(e,t)}renderFeature(e,t,i,n,s,o){if(!i)return!1;let a=!1;if(Array.isArray(i))for(let l=0,h=i.length;l<h;++l)a=ts(n,e,i[l],t,this.boundHandleStyleImageChange_,void 0,s,o)||a;else a=ts(n,e,i,t,this.boundHandleStyleImageChange_,void 0,s,o);return a}tileImageNeedsRender_(e){let t=this.getLayer();if(t.getRenderMode()==="vector")return!1;let i=e.getReplayState(t),n=t.getRevision(),s=e.wantedResolution;return i.renderedTileResolution!==s||i.renderedTileRevision!==n}renderTileImage_(e,t){let i=this.getLayer(),n=e.getReplayState(i),s=i.getRevision(),o=e.executorGroups[P(i)];n.renderedTileRevision=s;let a=e.wrappedTileCoord,l=a[0],h=i.getSource(),c=t.pixelRatio,d=t.viewState.projection,f=h.getTileGridForProjection(d),g=f.getResolution(e.tileCoord[0]),m=t.pixelRatio/e.wantedResolution*g,p=f.getResolution(l),_=e.getContext();c=Math.round(Math.max(c,m/c));let x=h.getTilePixelSize(l,c,d);_.canvas.width=x[0],_.canvas.height=x[1];let y=c/m;if(y!==1){let S=tc(this.tmpTransform_);Lr(S,y,y),_.setTransform.apply(_,S)}let E=f.getTileCoordExtent(a,this.tempExtent),T=m/p,v=tc(this.tmpTransform_);Lr(v,T,-T),La(v,-E[0],-E[3]);for(let S=0,w=o.length;S<w;++S)o[S].execute(_,[_.canvas.width*y,_.canvas.height*y],v,0,!0,wE[i.getRenderMode()],null);n.renderedTileResolution=e.wantedResolution}},A_=Xd;var Yd=class extends Li{constructor(e){e=e||{};let t=Object.assign({},e);delete t.preload;let i=e.cacheSize===void 0?0:e.cacheSize;delete e.cacheSize,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=i;let n=e.renderMode||"hybrid";W(n=="hybrid"||n=="vector","`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=n,this.setPreload(e.preload?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0),this.getBackground,this.setBackground}createRenderer(){return new A_(this,{cacheSize:this.cacheSize_})}getFeatures(e){return super.getFeatures(e)}getFeaturesInExtent(e){return this.getRenderer().getFeaturesInExtent(e)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(Ii.PRELOAD)}getUseInterimTilesOnError(){return this.get(Ii.USE_INTERIM_TILES_ON_ERROR)}setPreload(e){this.set(Ii.PRELOAD,e)}setUseInterimTilesOnError(e){this.set(Ii.USE_INTERIM_TILES_ON_ERROR,e)}},O_=Yd;var ls=[0,0,0],jn=5,$d=class{constructor(e){this.minZoom=e.minZoom!==void 0?e.minZoom:0,this.resolutions_=e.resolutions,W(dg(this.resolutions_,(n,s)=>s-n,!0),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let n=0,s=this.resolutions_.length-1;n<s;++n)if(!t)t=this.resolutions_[n]/this.resolutions_[n+1];else if(this.resolutions_[n]/this.resolutions_[n+1]!==t){t=void 0;break}}this.zoomFactor_=t,this.maxZoom=this.resolutions_.length-1,this.origin_=e.origin!==void 0?e.origin:null,this.origins_=null,e.origins!==void 0&&(this.origins_=e.origins,W(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));let i=e.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=Je(i)),W(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,e.tileSizes!==void 0&&(this.tileSizes_=e.tileSizes,W(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=e.tileSize!==void 0?e.tileSize:this.tileSizes_?null:256,W(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=i!==void 0?i:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],e.sizes!==void 0?this.fullTileRanges_=e.sizes.map((n,s)=>{let o=new ul(Math.min(0,n[0]),Math.max(n[0]-1,-1),Math.min(0,n[1]),Math.max(n[1]-1,-1));if(i){let a=this.getTileRangeForExtentAndZ(i,s);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(e,t,i){let n=this.getTileRangeForExtentAndZ(e,t);for(let s=n.minX,o=n.maxX;s<=o;++s)for(let a=n.minY,l=n.maxY;a<=l;++a)i([t,s,a])}forEachTileCoordParentTileRange(e,t,i,n){let s,o,a,l=null,h=e[0]-1;for(this.zoomFactor_===2?(o=e[1],a=e[2]):l=this.getTileCoordExtent(e,n);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),s=or(o,o,a,a,i)):s=this.getTileRangeForExtentAndZ(l,h,i),t(h,s))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getOrigins(){return this.origins_}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,i){if(e[0]<this.maxZoom){if(this.zoomFactor_===2){let s=e[1]*2,o=e[2]*2;return or(s,s+1,o,o+1,t)}let n=this.getTileCoordExtent(e,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(n,e[0]+1,t)}return null}getTileRangeForTileCoordAndZ(e,t,i){if(t>this.maxZoom||t<this.minZoom)return null;let n=e[0],s=e[1],o=e[2];if(t===n)return or(s,o,s,o,i);if(this.zoomFactor_){let l=Math.pow(this.zoomFactor_,t-n),h=Math.floor(s*l),c=Math.floor(o*l);if(t<n)return or(h,h,c,c,i);let u=Math.floor(l*(s+1))-1,d=Math.floor(l*(o+1))-1;return or(h,u,c,d,i)}let a=this.getTileCoordExtent(e,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,t,i)}getTileRangeForExtentAndZ(e,t,i){this.getTileCoordForXYAndZ_(e[0],e[3],t,!1,ls);let n=ls[1],s=ls[2];this.getTileCoordForXYAndZ_(e[2],e[1],t,!0,ls);let o=ls[1],a=ls[2];return or(n,o,s,a,i)}getTileCoordCenter(e){let t=this.getOrigin(e[0]),i=this.getResolution(e[0]),n=Ee(this.getTileSize(e[0]),this.tmpSize_);return[t[0]+(e[1]+.5)*n[0]*i,t[1]-(e[2]+.5)*n[1]*i]}getTileCoordExtent(e,t){let i=this.getOrigin(e[0]),n=this.getResolution(e[0]),s=Ee(this.getTileSize(e[0]),this.tmpSize_),o=i[0]+e[1]*s[0]*n,a=i[1]-(e[2]+1)*s[1]*n,l=o+s[0]*n,h=a+s[1]*n;return bt(o,a,l,h,t)}getTileCoordForCoordAndResolution(e,t,i){return this.getTileCoordForXYAndResolution_(e[0],e[1],t,!1,i)}getTileCoordForXYAndResolution_(e,t,i,n,s){let o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),h=Ee(this.getTileSize(o),this.tmpSize_),c=a*(e-l[0])/i/h[0],u=a*(l[1]-t)/i/h[1];return n?(c=Si(c,jn)-1,u=Si(u,jn)-1):(c=yn(c,jn),u=yn(u,jn)),Yr(o,c,u,s)}getTileCoordForXYAndZ_(e,t,i,n,s){let o=this.getOrigin(i),a=this.getResolution(i),l=Ee(this.getTileSize(i),this.tmpSize_),h=(e-o[0])/a/l[0],c=(o[1]-t)/a/l[1];return n?(h=Si(h,jn)-1,c=Si(c,jn)-1):(h=yn(h,jn),c=yn(c,jn)),Yr(i,h,c,s)}getTileCoordForCoordAndZ(e,t,i){return this.getTileCoordForXYAndZ_(e[0],e[1],t,!1,i)}getTileCoordResolution(e){return this.resolutions_[e[0]]}getTileSize(e){return this.tileSize_?this.tileSize_:this.tileSizes_[e]}getFullTileRange(e){return this.fullTileRanges_?this.fullTileRanges_[e]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,e):null}getZForResolution(e,t){let i=pn(this.resolutions_,e,t||0);return B(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(e,t){return uc(t,0,t.length,2,this.getTileCoordExtent(e))}calculateTileRanges_(e){let t=this.resolutions_.length,i=new Array(t);for(let n=this.minZoom;n<t;++n)i[n]=this.getTileRangeForExtentAndZ(e,n);this.fullTileRanges_=i}},ur=$d;var Kd=class extends ur{constructor(e){super({extent:e.extent,origin:e.origin,origins:e.origins,resolutions:e.resolutions,tileSize:e.tileSize,tileSizes:e.tileSizes,sizes:e.sizes}),this.matrixIds_=e.matrixIds}getMatrixId(e){return this.matrixIds_[e]}getMatrixIds(){return this.matrixIds_}},D_=Kd;function hs(r){let e=r.getDefaultTileGrid();return e||(e=bE(r),r.setDefaultTileGrid(e)),e}function k_(r,e,t){let i=e[0],n=r.getTileCoordCenter(e),s=cs(t);if(!rt(s,n)){let o=z(s),a=Math.ceil((s[0]-n[0])/o);return n[0]+=o*a,r.getTileCoordForCoordAndZ(n,i)}return e}function LE(r,e,t,i){i=i!==void 0?i:"top-left";let n=N_(r,e,t);return new ur({extent:r,origin:Rg(r,i),resolutions:n,tileSize:t})}function jl(r){let e=r||{},t=e.extent||$("EPSG:3857").getExtent(),i={extent:t,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:N_(t,e.maxZoom,e.tileSize,e.maxResolution)};return new ur(i)}function N_(r,e,t,i){e=e!==void 0?e:42,t=Ee(t!==void 0?t:256);let n=re(r),s=z(r);i=i>0?i:Math.max(s/t[0],n/t[1]);let o=e+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function bE(r,e,t,i){let n=cs(r);return LE(n,e,t,i)}function cs(r){r=$(r);let e=r.getExtent();if(!e){let t=180*ci.degrees/r.getMetersPerUnit();e=bt(-t,-t,t,t)}return e}function Vn(r,e){let t=[];Object.keys(e).forEach(function(n){e[n]!==null&&e[n]!==void 0&&t.push(n+"="+encodeURIComponent(e[n]))});let i=t.join("&");return r=r.replace(/[?&]$/,""),r+=r.includes("?")?"&":"?",r+i}var IE=/\{z\}/g,FE=/\{x\}/g,ME=/\{y\}/g,AE=/\{-y\}/g;function G_(r,e,t,i,n){return r.replace(IE,e.toString()).replace(FE,t.toString()).replace(ME,i.toString()).replace(AE,function(){if(n===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(n-i).toString()})}function Vl(r){let e=[],t=/\{([a-z])-([a-z])\}/.exec(r);if(t){let i=t[1].charCodeAt(0),n=t[2].charCodeAt(0),s;for(s=i;s<=n;++s)e.push(r.replace(t[0],String.fromCharCode(s)));return e}if(t=/\{(\d+)-(\d+)\}/.exec(r),t){let i=parseInt(t[2],10);for(let n=parseInt(t[1],10);n<=i;n++)e.push(r.replace(t[0],n.toString()));return e}return e.push(r),e}function OE(r,e){return(function(t,i,n){if(!t)return;let s,o=t[0];if(e){let a=e.getFullTileRange(o);a&&(s=a.getHeight()-1)}return G_(r,o,t[1],t[2],s)})}function U_(r,e){let t=r.length,i=new Array(t);for(let n=0;n<t;++n)i[n]=OE(r[n],e);return Wl(i)}function Wl(r){return r.length===1?r[0]:(function(e,t,i){if(!e)return;let n=ml(e),s=lt(n,r.length);return r[s](e,t,i)})}var Hd=class extends De{constructor(e){super(),this.projection=$(e.projection),this.attributions_=B_(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible??!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;let t=this;this.viewPromise_=new Promise(function(i,n){t.viewResolver=i,t.viewRejector=n})}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_=B_(e),this.changed()}setState(e){this.state_=e,this.changed()}};function B_(r){return r?typeof r=="function"?r:(Array.isArray(r)||(r=[r]),e=>r):null}var us=Hd;var Zd=class extends us{constructor(e){super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,projection:e.projection,state:e.state,wrapX:e.wrapX,interpolate:e.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=e.tilePixelRatio!==void 0?e.tilePixelRatio:1,this.tileGrid=e.tileGrid!==void 0?e.tileGrid:null;let t=[256,256];this.tileGrid&&Ee(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),t),this.tmpSize=[0,0],this.key_=e.key||P(this),this.tileOptions={transition:e.transition,interpolate:e.interpolate},this.zDirection=e.zDirection?e.zDirection:0}getGutterForProjection(e){return 0}getKey(){return this.key_}setKey(e){this.key_!==e&&(this.key_=e,this.changed())}getResolutions(e){let t=e?this.getTileGridForProjection(e):this.tileGrid;return t?t.getResolutions():null}getTile(e,t,i,n,s,o){return j()}getTileGrid(){return this.tileGrid}getTileGridForProjection(e){return this.tileGrid?this.tileGrid:hs(e)}getTilePixelRatio(e){return this.tilePixelRatio_}getTilePixelSize(e,t,i){let n=this.getTileGridForProjection(i),s=this.getTilePixelRatio(t),o=Ee(n.getTileSize(e),this.tmpSize);return s==1?o:Qm(o,s,this.tmpSize)}getTileCoordForTileUrlFunction(e,t){let i=t!==void 0?t:this.getProjection(),n=t!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(e=k_(n,e,i)),Fp(e,n)?e:null}clear(){}refresh(){this.clear(),super.refresh()}},Xl=class extends ye{constructor(e,t){super(e),this.tile=t}},z_=Zd;var Yl={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};var qd=class r extends z_{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tilePixelRatio:e.tilePixelRatio,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===r.prototype.tileUrlFunction,this.tileLoadFunction=e.tileLoadFunction,e.tileUrlFunction&&(this.tileUrlFunction=e.tileUrlFunction),this.urls=null,e.urls?this.setUrls(e.urls):e.url&&this.setUrl(e.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(e){let t=e.target,i=P(t),n=t.getState(),s;n==F.LOADING?(this.tileLoadingKeys_[i]=!0,s=Yl.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],s=n==F.ERROR?Yl.TILELOADERROR:n==F.LOADED?Yl.TILELOADEND:void 0),s!=null&&this.dispatchEvent(new Xl(s,t))}setTileLoadFunction(e){this.tileLoadFunction=e,this.changed()}setTileUrlFunction(e,t){this.tileUrlFunction=e,typeof t<"u"?this.setKey(t):this.changed()}setUrl(e){let t=Vl(e);this.urls=t,this.setUrls(t)}setUrls(e){this.urls=e;let t=e.join(`
571
+ `);this.generateTileUrlFunction_?this.setTileUrlFunction(U_(e,this.tileGrid),t):this.setKey(t)}tileUrlFunction(e,t,i){}},$l=qd;var Jd=class extends $l{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:DE,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate!==void 0?e.interpolate:!0,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.crossOrigin=e.crossOrigin!==void 0?e.crossOrigin:null,this.referrerPolicy=e.referrerPolicy,this.tileClass=e.tileClass!==void 0?e.tileClass:hl,this.tileGridForProjection={},this.reprojectionErrorThreshold_=e.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(e){return this.getProjection()&&e&&!Ie(this.getProjection(),e)?0:this.getGutter()}getGutter(){return 0}getKey(){let e=super.getKey();return this.getInterpolate()||(e+=":disable-interpolation"),e}getTileGridForProjection(e){let t=this.getProjection();if(this.tileGrid&&(!t||Ie(t,e)))return this.tileGrid;let i=P(e);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=hs(e)),this.tileGridForProjection[i]}createTile_(e,t,i,n,s,o){let a=[e,t,i],l=this.getTileCoordForTileUrlFunction(a,s),h=l?this.tileUrlFunction(l,n,s):void 0,c=new this.tileClass(a,h!==void 0?F.IDLE:F.EMPTY,h!==void 0?h:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(L.CHANGE,this.handleTileChange.bind(this)),c}getTile(e,t,i,n,s,o){let a=this.getProjection();if(!a||!s||Ie(a,s))return this.getTileInternal(e,t,i,n,a||s);let l=[e,t,i],h=this.getKey(),c=this.getTileGridForProjection(a),u=this.getTileGridForProjection(s),d=this.getTileCoordForTileUrlFunction(l,s),f=new gl(a,c,s,u,l,d,this.getTilePixelRatio(n),this.getGutter(),(g,m,p,_)=>this.getTileInternal(g,m,p,_,a,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return f.key=h,f}getTileInternal(e,t,i,n,s,o){let a=this.getKey(),l=$r(this,a,e,t,i);if(o&&o.containsKey(l))return o.get(l);let h=this.createTile_(e,t,i,n,s,a);return o?.set(l,h),h}setRenderReprojectionEdges(e){this.renderReprojectionEdges_!=e&&(this.renderReprojectionEdges_=e,this.changed())}setTileGridForProjection(e,t){let i=$(e);if(i){let n=P(i);n in this.tileGridForProjection||(this.tileGridForProjection[n]=t)}}};function DE(r,e){if(Ze){let t=r.getCrossOrigin(),i="same-origin",n="same-origin";t==="anonymous"||t===""?(i="cors",n="omit"):t==="use-credentials"&&(i="cors",n="include");let s={mode:i,credentials:n,referrerPolicy:r.getReferrerPolicy()};fetch(e,s).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.blob()}).then(o=>createImageBitmap(o)).then(o=>{let a=r.getImage();a.width=o.width,a.height=o.height,a.getContext("2d").drawImage(o,0,0),o.close?.(),a.dispatchEvent(new Event("load"))}).catch(()=>{r.getImage().dispatchEvent(new Event("error"))});return}r.getImage().src=e}var ds=Jd;var Qd=class extends ds{constructor(e){e=e||{};let t=e.projection!==void 0?e.projection:"EPSG:3857",i=e.tileGrid!==void 0?e.tileGrid:jl({extent:cs(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,referrerPolicy:e.referrerPolicy,interpolate:e.interpolate,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}},Do=Qd;var kE='&#169; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.',ef=class extends Do{constructor(e){e=e||{};let t;e.attributions!==void 0?t=e.attributions:t=[kE];let i=e.url!==void 0?e.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:t,attributionsCollapsible:!1,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin!==void 0?e.crossOrigin:"anonymous",referrerPolicy:e.referrerPolicy||"origin-when-cross-origin",interpolate:e.interpolate,maxZoom:e.maxZoom!==void 0?e.maxZoom:19,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:e.tileLoadFunction,transition:e.transition,url:i,wrapX:e.wrapX,zDirection:e.zDirection})}},j_=ef;function ko(r){return Array.isArray(r)?Math.min(...r):r}var tf=class extends Vr{constructor(e,t,i,n,s,o,a){let l=e.getExtent();l&&e.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);let h=t.getExtent();h&&t.canWrapX()&&(h=h.slice(),h[0]=-1/0,h[2]=1/0);let c=h?Xe(i,h):i,u=be(c),d=Gn(e,t,u,n),f=.5,g=new fl(e,t,c,l,d*f,n),m=g.calculateSourceExtent(),p=yt(m)?null:o(m,d,s),_=p?A.IDLE:A.EMPTY,x=p?p.getPixelRatio():1;super(i,n,x,_),this.targetProj_=t,this.maxSourceExtent_=l,this.triangulation_=g,this.targetResolution_=n,this.targetExtent_=i,this.sourceImage_=p,this.sourcePixelRatio_=x,this.interpolate_=a,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==A.LOADING&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){let e=this.sourceImage_.getState();if(e==A.LOADED){let t=z(this.targetExtent_)/this.targetResolution_,i=re(this.targetExtent_)/this.targetResolution_;this.canvas_=dl(t,i,this.sourcePixelRatio_,ko(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_,!0)}this.state=e,this.changed()}load(){if(this.state==A.IDLE){this.state=A.LOADING,this.changed();let e=this.sourceImage_.getState();e==A.LOADED||e==A.ERROR?this.reproject_():(this.sourceListenerKey_=k(this.sourceImage_,L.CHANGE,t=>{let i=this.sourceImage_.getState();(i==A.LOADED||i==A.ERROR)&&(this.unlistenSource_(),this.reproject_())}),this.sourceImage_.load())}}unlistenSource_(){K(this.sourceListenerKey_),this.sourceListenerKey_=null}},V_=tf;var nf={IMAGELOADSTART:"imageloadstart",IMAGELOADEND:"imageloadend",IMAGELOADERROR:"imageloaderror"},rf=class extends ye{constructor(e,t){super(e),this.image=t}},sf=class extends us{constructor(e){super({attributions:e.attributions,projection:e.projection,state:e.state,interpolate:e.interpolate!==void 0?e.interpolate:!0}),this.on,this.once,this.un,this.loader=e.loader||null,this.resolutions_=e.resolutions!==void 0?e.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=e.loader?e.loader.length===0:!1,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(e){this.resolutions_=e}findNearestResolution(e){let t=this.getResolutions();if(t){let i=pn(t,e,0);e=t[i]}return e}getImage(e,t,i,n){let s=this.getProjection();if(!s||!n||Ie(s,n))return s&&(n=s),this.getImageInternal(e,t,i,n);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&Ie(this.reprojectedImage_.getProjection(),n)&&this.reprojectedImage_.getResolution()==t&&qe(this.reprojectedImage_.getExtent(),e))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new V_(s,n,e,t,i,(o,a,l)=>this.getImageInternal(o,a,l,s),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(e,t,i,n){if(this.loader){let s=of(e,t,i,1),o=this.findNearestResolution(t);if(this.image&&(this.static_||this.wantedProjection_===n&&(this.wantedExtent_&&Ue(this.wantedExtent_,s)||Ue(this.image.getExtent(),s))&&(this.wantedResolution_&&ko(this.wantedResolution_)===o||ko(this.image.getResolution())===o)))return this.image;this.wantedProjection_=n,this.wantedExtent_=s,this.wantedResolution_=o,this.image=new Vr(s,o,i,this.loader),this.image.addEventListener(L.CHANGE,this.handleImageChange.bind(this))}return this.image}handleImageChange(e){let t=e.target,i;switch(t.getState()){case A.LOADING:this.loading=!0,i=nf.IMAGELOADSTART;break;case A.LOADED:this.loading=!1,i=nf.IMAGELOADEND;break;case A.ERROR:this.loading=!1,i=nf.IMAGELOADERROR;break;default:return}this.hasListener(i)&&this.dispatchEvent(new rf(i,t))}};function Kl(r,e){r.getImage().src=e}function of(r,e,t,i){let n=e/t,s=be(r),o=Si(z(r)/n,4),a=Si(re(r)/n,4),l=Si((i-1)*o/2,4),h=o+2*l,c=Si((i-1)*a/2,4),u=a+2*c;return Vi(s,n,0,[h,u])}var Hl=sf;var No="1.3.0",W_=[101,101];function X_(r,e,t,i,n){n.WIDTH=t[0],n.HEIGHT=t[1];let s=i.getAxisOrientation(),o=Os(n.VERSION,"1.3")>=0;n[o?"CRS":"SRS"]=i.getCode();let a=o&&s.startsWith("ne")?[e[1],e[0],e[3],e[2]]:e;return n.BBOX=a.join(","),Vn(r,n)}function af(r,e,t,i,n,s,o){s=Object.assign({REQUEST:"GetMap"},s);let a=e/t,l=[Dh(z(r)/a,4),Dh(re(r)/a,4)];if(t!=1)switch(o){case"geoserver":let c=90*t+.5|0;"FORMAT_OPTIONS"in s?s.FORMAT_OPTIONS+=";dpi:"+c:s.FORMAT_OPTIONS="dpi:"+c;break;case"mapserver":s.MAP_RESOLUTION=90*t;break;case"carmentaserver":case"qgis":s.DPI=90*t;break;default:throw new Error("Unknown `serverType` configured")}return X_(n,r,l,i,s)}function Go(r,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:No,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},r)}function Y_(r){let e=r.hidpi===void 0?!0:r.hidpi,t=$(r.projection||"EPSG:3857"),i=r.ratio||1.5,n=r.load||An,s=r.crossOrigin??null,o=r.referrerPolicy;return(a,l,h)=>{a=of(a,l,h,i),h!=1&&(!e||r.serverType===void 0)&&(h=1);let c=af(a,l,h,t,r.url,Go(r.params,"GetMap"),r.serverType),u=new Image;return u.crossOrigin=s,o!==void 0&&(u.referrerPolicy=o),n(u,c).then(d=>({image:d,extent:a,pixelRatio:h}))}}function $_(r,e,t){if(r.url===void 0)return;let i=$(r.projection||"EPSG:3857"),n=Vi(e,t,0,W_),s={QUERY_LAYERS:r.params.LAYERS,INFO_FORMAT:"application/json"};Object.assign(s,Go(r.params,"GetFeatureInfo"),r.params);let o=yn((e[0]-n[0])/t,4),a=yn((n[3]-e[1])/t,4),l=Os(s.VERSION,"1.3")>=0;return s[l?"I":"X"]=o,s[l?"J":"Y"]=a,X_(r.url,n,W_,i,s)}function K_(r,e){if(r.url===void 0)return;let t={SERVICE:"WMS",VERSION:No,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(e!==void 0){let i=$(r.projection||"EPSG:3857").getMetersPerUnit()||1,n=28e-5;t.SCALE=e*i/n}if(Object.assign(t,r.params),r.params!==void 0&&t.LAYER===void 0){let i=t.LAYERS;if(!(!Array.isArray(i)||i.length!==1))return;t.LAYER=i}return Vn(r.url,t)}var lf=class extends ds{constructor(e){e=e||{};let t=Object.assign({},e.params);super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:e.projection,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileClass:e.tileClass,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0,this.params_=t,this.v13_=!0,this.serverType_=e.serverType,this.hidpi_=e.hidpi!==void 0?e.hidpi:!0,this.tmpExtent_=me(),this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(e,t,i,n){let s=$(i),o=this.getProjection()||s,a=this.getTileGrid();a||(a=this.getTileGridForProjection(o));let l=ii(e,s,o),h=Gn(o,s,e,t),c=a.getZForResolution(h,this.zDirection),u=a.getResolution(c),d=a.getTileCoordForCoordAndZ(l,c);if(a.getResolutions().length<=d[0])return;let f=a.getTileCoordExtent(d,this.tmpExtent_),g=this.gutter_;g!==0&&(f=Le(f,u*g,f));let m={QUERY_LAYERS:this.params_.LAYERS};Object.assign(m,Go(this.params_,"GetFeatureInfo"),n);let p=Math.floor((l[0]-f[0])/u),_=Math.floor((f[3]-l[1])/u);return m[this.v13_?"I":"X"]=p,m[this.v13_?"J":"Y"]=_,this.getRequestUrl_(d,f,1,o||s,m)}getLegendUrl(e,t){if(this.urls[0]===void 0)return;let i={SERVICE:"WMS",VERSION:No,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(t===void 0||t.LAYER===void 0){let n=this.params_.LAYERS;if(!(!Array.isArray(n)||n.length===1))return;i.LAYER=n}if(e!==void 0){let n=this.getProjection()?this.getProjection().getMetersPerUnit():1,s=28e-5;i.SCALE=e*n/s}return Object.assign(i,t),Vn(this.urls[0],i)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(e,t,i,n,s){let o=this.urls;if(!o)return;let a;if(o.length==1)a=o[0];else{let l=lt(ml(e),o.length);a=o[l]}return af(t,(this.tileGrid||this.getTileGridForProjection(n)).getResolution(e[0]),i,n,a,s,this.serverType_)}getTilePixelRatio(e){return!this.hidpi_||this.serverType_===void 0?1:e}getKeyForParams_(){let e=0,t=[];for(let i in this.params_)t[e++]=i+"-"+this.params_[i];return t.join("/")}setParams_(e){this.params_=e,this.updateV13_(),this.setKey(this.getKeyForParams_())}setParams(e){this.setParams_(Object.assign({},e))}updateParams(e){this.setParams_(Object.assign(this.params_,e))}updateV13_(){let e=this.params_.VERSION||No;this.v13_=Os(e,"1.3")>=0}tileUrlFunction(e,t,i){let n=this.getTileGrid();if(n||(n=this.getTileGridForProjection(i)),n.getResolutions().length<=e[0])return;t!=1&&(!this.hidpi_||this.serverType_===void 0)&&(t=1);let s=n.getResolution(e[0]),o=n.getTileCoordExtent(e,this.tmpExtent_),a=this.gutter_;a!==0&&(o=Le(o,s*a,o));let l=Object.assign({},Go(this.params_,"GetMap"));return this.getRequestUrl_(e,o,t,i,l)}},H_=lf;var hf=class extends Hl{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:e.interpolate,projection:e.projection,resolutions:e.resolutions}),this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null,this.referrerPolicy_=e.referrerPolicy,this.url_=e.url,this.imageLoadFunction_=e.imageLoadFunction!==void 0?e.imageLoadFunction:Kl,this.params_=Object.assign({},e.params),this.serverType_=e.serverType,this.hidpi_=e.hidpi!==void 0?e.hidpi:!0,this.renderedRevision_=0,this.ratio_=e.ratio!==void 0?e.ratio:1.5,this.loaderProjection_=null}getFeatureInfoUrl(e,t,i,n){let s=$(i),o=this.getProjection();o&&o!==s&&(t=Gn(o,s,e,t),e=ii(e,s,o));let a={url:this.url_,params:{...this.params_,...n},projection:o||s};return $_(a,e,t)}getLegendUrl(e,t){return K_({url:this.url_,params:{...this.params_,...t}},e)}getParams(){return this.params_}getImageInternal(e,t,i,n){return this.url_===void 0?null:((!this.loader||this.loaderProjection_!==n)&&(this.loaderProjection_=n,this.loader=Y_({crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,params:this.params_,projection:n,serverType:this.serverType_,hidpi:this.hidpi_,url:this.url_,ratio:this.ratio_,load:(s,o)=>(this.image.setImage(s),this.imageLoadFunction_(this.image,o),An(s))})),super.getImageInternal(e,t,i,n))}getImageLoadFunction(){return this.imageLoadFunction_}getUrl(){return this.url_}setImageLoadFunction(e){this.imageLoadFunction_=e,this.changed()}setUrl(e){e!=this.url_&&(this.url_=e,this.loader=null,this.changed())}setParams(e){this.params_=Object.assign({},e),this.loader=null,this.changed()}updateParams(e){Object.assign(this.params_,e),this.changed()}changed(){this.image=null,super.changed()}},Z_=hf;var cf=class extends ds{constructor(e){let t=e.requestEncoding!==void 0?e.requestEncoding:"KVP",i=e.tileGrid,n=e.urls;n===void 0&&e.url!==void 0&&(n=Vl(e.url)),super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,referrerPolicy:e.referrerPolicy,interpolate:e.interpolate,projection:e.projection,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileClass:e.tileClass,tileGrid:i,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,urls:n,wrapX:e.wrapX!==void 0?e.wrapX:!1,transition:e.transition,zDirection:e.zDirection}),this.version_=e.version!==void 0?e.version:"1.0.0",this.format_=e.format!==void 0?e.format:"image/jpeg",this.dimensions_=e.dimensions!==void 0?e.dimensions:{},this.layer_=e.layer,this.matrixSet_=e.matrixSet,this.style_=e.style,this.requestEncoding_=t,this.setKey(this.getKeyForDimensions_()),n&&n.length>0&&(this.tileUrlFunction=Wl(n.map(this.createFromWMTSTemplate.bind(this))))}setUrls(e){this.urls=e;let t=e.join(`
572
+ `);this.setTileUrlFunction(Wl(e.map(this.createFromWMTSTemplate.bind(this))),t)}getDimensions(){return this.dimensions_}getFormat(){return this.format_}getLayer(){return this.layer_}getMatrixSet(){return this.matrixSet_}getRequestEncoding(){return this.requestEncoding_}getStyle(){return this.style_}getVersion(){return this.version_}getKeyForDimensions_(){let e=this.urls?this.urls.slice(0):[];for(let t in this.dimensions_)e.push(t+"-"+this.dimensions_[t]);return e.join("/")}updateDimensions(e){Object.assign(this.dimensions_,e),this.setKey(this.getKeyForDimensions_())}createFromWMTSTemplate(e){let t=this.requestEncoding_,i={layer:this.layer_,style:this.style_,tilematrixset:this.matrixSet_};t=="KVP"&&Object.assign(i,{Service:"WMTS",Request:"GetTile",Version:this.version_,Format:this.format_}),e=t=="KVP"?Vn(e,i):e.replace(/\{(\w+?)\}/g,function(o,a){return a.toLowerCase()in i?i[a.toLowerCase()]:o});let n=this.tileGrid,s=this.dimensions_;return(function(o,a,l){if(!o)return;let h={TileMatrix:n.getMatrixId(o[0]),TileCol:o[1],TileRow:o[2]};Object.assign(h,s);let c=e;return t=="KVP"?c=Vn(c,h):c=c.replace(/\{(\w+?)\}/g,function(u,d){return encodeURIComponent(h[d])}),c})}},q_=cf;var NE=!1;function uf(r,e,t,i,n,s,o){let a=new XMLHttpRequest;a.open("GET",typeof r=="function"?r(t,i,n):r,!0),e.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=NE,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){let h=e.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?s(e.readFeatures(c,{extent:t,featureProjection:n}),e.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function df(r,e){return function(t,i,n,s,o){uf(r,e,t,i,n,(a,l)=>{this.addFeatures(a),s!==void 0&&s(a)},()=>{this.changed(),o!==void 0&&o()})}}function J_(r,e){return[[-1/0,-1/0,1/0,1/0]]}var ff=class{constructor(e){this.rbush_=new tr(e),this.items_={}}insert(e,t){let i={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:t};this.rbush_.insert(i),this.items_[P(t)]=i}load(e,t){let i=new Array(t.length);for(let n=0,s=t.length;n<s;n++){let o=e[n],a=t[n],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[n]=l,this.items_[P(a)]=l}this.rbush_.load(i)}remove(e){let t=P(e),i=this.items_[t];return delete this.items_[t],this.rbush_.remove(i)!==null}update(e,t){let i=this.items_[P(t)],n=[i.minX,i.minY,i.maxX,i.maxY];qe(n,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(n){return n.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,t){return this.forEach_(this.getInExtent(e),t)}forEach_(e,t){let i;for(let n=0,s=e.length;n<s;n++)if(i=t(e[n]),i)return i;return i}isEmpty(){return wt(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let t=this.rbush_.toJSON();return bt(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]}},fr=ff;var Di=class extends ye{constructor(e,t,i){super(e),this.feature=t,this.features=i}},gf=class extends us{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_=Bi,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(W(this.format_,"`format` must be set when `url` is set"),this.loader_=df(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:J_;let t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new fr:null,this.loadedExtentsRtree_=new fr,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,n;Array.isArray(e.features)?n=e.features:e.features&&(i=e.features,n=i.getArray()),!t&&i===void 0&&(i=new Ce(n)),n!==void 0&&this.addFeaturesInternal(n),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let t=P(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);let i=e.getGeometry();if(i){let n=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(n,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new Di(Se.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof Ct||(this.featureChangeKeys_[e]=[k(t,L.CHANGE,this.handleFeatureChange_,this),k(t,He.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let i=!0;if(t.getId()!==void 0){let n=String(t.getId());if(!(n in this.idIndex_))this.idIndex_[n]=t;else if(t instanceof Ct){let s=this.idIndex_[n];s instanceof Ct?Array.isArray(s)?s.push(t):this.idIndex_[n]=[s,t]:i=!1}else i=!1}return i&&(W(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),i}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let t=[],i=[],n=[];for(let s=0,o=e.length;s<o;s++){let a=e[s],l=P(a);this.addToIndex_(l,a)&&i.push(a)}for(let s=0,o=i.length;s<o;s++){let a=i[s],l=P(a);this.setupChangeEvents_(l,a);let h=a.getGeometry();if(h){let c=h.getExtent();t.push(c),n.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(t,n),this.hasListener(Se.ADDFEATURE))for(let s=0,o=i.length;s<o;s++)this.dispatchEvent(new Di(Se.ADDFEATURE,i[s]))}bindFeaturesCollection_(e){let t=!1;this.addEventListener(Se.ADDFEATURE,function(i){t||(t=!0,e.push(i.feature),t=!1)}),this.addEventListener(Se.REMOVEFEATURE,function(i){t||(t=!0,e.remove(i.feature),t=!1)}),e.addEventListener(fe.ADD,i=>{t||(t=!0,this.addFeature(i.element),t=!1)}),e.addEventListener(fe.REMOVE,i=>{t||(t=!0,this.removeFeature(i.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(let i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(K);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(let i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let t=new Di(Se.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 i=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(i,function(n){let s=n.getGeometry();if(s instanceof Ct||s.intersectsCoordinate(e))return t(n)})}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(i){let n=i.getGeometry();if(n instanceof Ct||n.intersectsExtent(e)){let s=t(i);if(s)return s}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),wt(this.nullGeometryFeatures_)||je(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let t=[];return this.forEachFeatureAtCoordinateDirect(e,function(i){t.push(i)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let n=ca(e,t);return[].concat(...n.map(s=>this.featuresRtree_.getInExtent(s)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){let i=e[0],n=e[1],s=null,o=[NaN,NaN],a=1/0,l=[-1/0,-1/0,1/0,1/0];return t=t||xt,this.featuresRtree_.forEachInExtent(l,function(h){if(t(h)){let c=h.getGeometry(),u=a;if(a=c instanceof Ct?0:c.closestPointXY(i,n,o,a),a<u){s=h;let d=Math.sqrt(a);l[0]=i-d,l[1]=n-d,l[2]=i+d,l[3]=n+d}}}),s}getExtent(e){return this.featuresRtree_?.getExtent(e)??null}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,i=P(t),n=t.getGeometry();if(!n)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(t),this.nullGeometryFeatures_[i]=t);else{let o=n.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,t)):this.featuresRtree_&&this.featuresRtree_.update(o,t)}let s=t.getId();if(s!==void 0){let o=s.toString();this.idIndex_[o]!==t&&(this.removeFromIdIndex_(t),this.idIndex_[o]=t)}else this.removeFromIdIndex_(t),this.uidIndex_[i]=t;this.changed(),this.dispatchEvent(new Di(Se.CHANGEFEATURE,t))}hasFeature(e){let t=e.getId();return t!==void 0?t in this.idIndex_:P(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&wt(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,t,i){let n=this.loadedExtentsRtree_,s=this.strategy_(e,t,i);for(let o=0,a=s.length;o<a;++o){let l=s[o];n.forEachInExtent(l,function(c){return Ue(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Di(Se.FEATURESLOADSTART)),this.loader_.call(this,l,t,i,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new Di(Se.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Di(Se.FEATURESLOADERROR))}),n.insert(l,{extent:l.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_,i=t.forEachInExtent(e,function(n){if(qe(n.extent,e))return n});i&&t.remove(i)}removeFeatures(e){let t=!1;for(let i=0,n=e.length;i<n;++i)t=this.removeFeatureInternal(e[i])||t;t&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){let t=P(e);if(!(t in this.uidIndex_))return!1;t in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[t]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[t]?.forEach(K),delete this.featureChangeKeys_[t];let n=e.getId();if(n!==void 0){let s=n.toString(),o=this.idIndex_[s];o===e?delete this.idIndex_[s]:Array.isArray(o)&&(o.splice(o.indexOf(e),1),o.length===1&&(this.idIndex_[s]=o[0]))}return delete this.uidIndex_[t],this.hasListener(Se.REMOVEFEATURE)&&this.dispatchEvent(new Di(Se.REMOVEFEATURE,e)),!0}removeFromIdIndex_(e){for(let t in this.idIndex_)if(this.idIndex_[t]===e){delete this.idIndex_[t];break}}setLoader(e){this.loader_=e}setUrl(e){W(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(df(e,this.format_))}setOverlaps(e){this.overlaps_=e,this.changed()}},mt=gf;var Q_=[],mf=class extends bi{constructor(e,t,i,n,s){super(e,t,{transition:0}),this.context_=null,this.executorGroups={},this.loadingSourceTiles=0,this.hitDetectionImageData={},this.replayState_={},this.sourceTiles=[],this.errorTileKeys={},this.wantedResolution,this.getSourceTiles=n.bind(void 0,this),this.removeSourceTiles_=s,this.wrappedTileCoord=i}getContext(){return this.context_||(this.context_=ne(1,1,Q_)),this.context_}hasContext(){return!!this.context_}getImage(){return this.hasContext()?this.getContext().canvas:null}getReplayState(e){let t=P(e);return t in this.replayState_||(this.replayState_[t]={dirty:!1,renderedRenderOrder:null,renderedResolution:NaN,renderedPixelRatio:NaN,renderedRevision:-1,renderedTileResolution:NaN,renderedTileRevision:-1,renderedTileZ:-1}),this.replayState_[t]}load(){this.getSourceTiles()}release(){this.context_&&($i(this.context_),Q_.push(this.context_.canvas),this.context_=null),this.removeSourceTiles_(this),this.sourceTiles.length=0,super.release()}},ex=mf;var pf=class extends bi{constructor(e,t,i,n,s,o){super(e,t,o),this.extent=null,this.format_=n,this.features_=null,this.loader_,this.projection=null,this.resolution,this.tileLoadFunction_=s,this.url_=i,this.key=i}getTileUrl(){return this.url_}getFormat(){return this.format_}getFeatures(){return this.features_}load(){this.state==F.IDLE&&(this.setState(F.LOADING),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))}onLoad(e,t){this.setFeatures(e)}onError(){this.setState(F.ERROR)}setFeatures(e){this.features_=e,this.setState(F.LOADED)}setLoader(e){this.loader_=e}},tx=pf;var _f=class extends $l{constructor(e){let t=e.projection||"EPSG:3857",i=e.extent||cs(t),n=e.tileGrid||jl({extent:i,maxResolution:e.maxResolution,maxZoom:e.maxZoom!==void 0?e.maxZoom:22,minZoom:e.minZoom,tileSize:e.tileSize||512});super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,interpolate:!0,projection:t,state:e.state,tileGrid:n,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:GE,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX===void 0?!0:e.wrapX,transition:e.transition,zDirection:e.zDirection===void 0?1:e.zDirection}),this.format_=e.format?e.format:null,this.tileKeysBySourceTileUrl_={},this.sourceTiles_={},this.overlaps_=e.overlaps==null?!0:e.overlaps,this.tileClass=e.tileClass?e.tileClass:tx,this.tileGrids_={}}getOverlaps(){return this.overlaps_}getSourceTiles(e,t,i){if(i.getState()===F.IDLE){i.setState(F.LOADING);let n=i.wrappedTileCoord,s=this.getTileGridForProjection(t),o=s.getTileCoordExtent(n),a=n[0],l=s.getResolution(a);Le(o,-l,o);let h=this.projection;t&&this.projection&&!Ie(t,h)&&(o=jt(o,t,h));let c=this.tileGrid,u=c.getExtent();u&&Xe(o,u,o);let d=l;t&&h&&!Ie(t,h)&&(d=l/h.getMetersPerUnit()/t.getMetersPerUnit());let f=c.getZForResolution(d,this.zDirection);c.forEachTileCoord(o,f,g=>{let m=this.tileUrlFunction(g,e,t);this.sourceTiles_[m]||(this.sourceTiles_[m]=new this.tileClass(g,m?F.IDLE:F.EMPTY,m,this.format_,this.tileLoadFunction));let p=this.sourceTiles_[m];i.sourceTiles.push(p),this.tileKeysBySourceTileUrl_[m]||(this.tileKeysBySourceTileUrl_[m]=[]),this.tileKeysBySourceTileUrl_[m].push(i.getKey());let _=p.getState();if(_<F.LOADED){let x=y=>{this.handleTileChange(y);let E=p.getState();if(E===F.LOADED||E===F.ERROR){let T=p.getKey();T in i.errorTileKeys?p.getState()===F.LOADED&&delete i.errorTileKeys[T]:i.loadingSourceTiles--,E===F.ERROR?i.errorTileKeys[T]=!0:p.removeEventListener(L.CHANGE,x),i.loadingSourceTiles===0&&i.setState(wt(i.errorTileKeys)?F.LOADED:F.ERROR)}};p.addEventListener(L.CHANGE,x),i.loadingSourceTiles++}_===F.IDLE&&(p.extent=c.getTileCoordExtent(g),p.projection=this.projection,p.resolution=c.getResolution(g[0]),p.load())}),i.loadingSourceTiles||i.setState(i.sourceTiles.some(g=>g.getState()===F.ERROR)?F.ERROR:F.LOADED)}return i.sourceTiles}removeSourceTiles(e){let t=e.getKey(),i=e.sourceTiles;for(let n=0,s=i.length;n<s;++n){let o=i[n].getTileUrl();if(!this.tileKeysBySourceTileUrl_[o])return;let a=this.tileKeysBySourceTileUrl_[o].indexOf(t);a!==-1&&(this.tileKeysBySourceTileUrl_[o].splice(a,1),this.tileKeysBySourceTileUrl_[o].length===0&&(delete this.tileKeysBySourceTileUrl_[o],delete this.sourceTiles_[o]))}}getTile(e,t,i,n,s){let o=[e,t,i],a=this.getTileCoordForTileUrlFunction(o,s),l=this.getTileGrid().getExtent(),h=this.projection,c=this.getTileGridForProjection(s);if(a&&l){let f=c.getTileCoordExtent(a);Le(f,-c.getResolution(e),f),te(l,!s||!h||Ie(s,h)?f:jt(f,s,h))||(a=null)}let u=!0;if(a!==null){let f=this.tileGrid,g=c.getResolution(e),m=g;s&&h&&!Ie(s,h)&&(m=g/h.getMetersPerUnit()/s.getMetersPerUnit());let p=f.getZForResolution(m,1),_=c.getTileCoordExtent(a);Le(_,-g,_),f.forEachTileCoord(!s||!h||Ie(s,h)?_:jt(_,s,h),p,x=>{u=u&&!this.tileUrlFunction(x,n,h)})}let d=new ex(o,u?F.EMPTY:F.IDLE,a,this.getSourceTiles.bind(this,n,s),this.removeSourceTiles.bind(this));return d.key=this.getKey(),d}getTileGridForProjection(e){let t=e.getCode(),i=this.tileGrids_[t];if(!i){let n=this.projection;if(n!==null&&!Ie(n,e))return hs(e);let s=this.tileGrid,o=s.getResolutions().slice(),a=o.map(function(c,u){return s.getOrigin(u)}),l=o.map(function(c,u){return s.getTileSize(u)}),h=43;for(let c=o.length;c<h;++c)o.push(o[c-1]/2),a.push(a[c-1]),l.push(l[c-1]);i=new ur({extent:s.getExtent(),origins:a,resolutions:o,tileSizes:l}),this.tileGrids_[t]=i}return i}getTilePixelRatio(e){return e}getTilePixelSize(e,t,i){let n=this.getTileGridForProjection(i),s=Ee(n.getTileSize(e),this.tmpSize);return[Math.round(s[0]*t),Math.round(s[1]*t)]}setOverlaps(e){this.overlaps_=e,this.changed()}},ix=_f;function GE(r,e){r.setLoader(function(t,i,n){uf(e,r.getFormat(),t,i,n,r.onLoad.bind(r),r.onError.bind(r))})}var xf=class extends mt{constructor(e){e=e||{},super({attributions:e.attributions,wrapX:e.wrapX}),this.resolution=void 0,this.distance=e.distance!==void 0?e.distance:20,this.minDistance=e.minDistance||0,this.interpolationRatio=0,this.features=[],this.geometryFunction=e.geometryFunction||function(t){let i=t.getGeometry();return W(!i||i.getType()==="Point","The default `geometryFunction` can only handle `Point` or null geometries"),i},this.createCustomCluster_=e.createCluster,this.source=null,this.boundRefresh_=this.refresh.bind(this),this.updateDistance(this.distance,this.minDistance),this.setSource(e.source||null)}clear(e){this.features.length=0,super.clear(e)}getDistance(){return this.distance}getSource(){return this.source}loadFeatures(e,t,i){this.source?.loadFeatures(e,t,i),t!==this.resolution&&(this.resolution=t,this.refresh())}setDistance(e){this.updateDistance(e,this.minDistance)}setMinDistance(e){this.updateDistance(this.distance,e)}getMinDistance(){return this.minDistance}setSource(e){this.source&&this.source.removeEventListener(L.CHANGE,this.boundRefresh_),this.source=e,e&&e.addEventListener(L.CHANGE,this.boundRefresh_),this.refresh()}refresh(){this.clear(),this.cluster(),this.addFeatures(this.features)}updateDistance(e,t){let i=e===0?0:Math.min(t,e)/e,n=e!==this.distance||this.interpolationRatio!==i;this.distance=e,this.minDistance=t,this.interpolationRatio=i,n&&this.refresh()}cluster(){if(this.resolution===void 0||!this.source)return;let e=me(),t=this.distance*this.resolution,i=this.source.getFeatures(),n={};for(let s=0,o=i.length;s<o;s++){let a=i[s];if(!(P(a)in n)){let l=this.geometryFunction(a);if(l){let h=l.getCoordinates();Ri(h,e),Le(e,t,e);let c=this.source.getFeaturesInExtent(e).filter(function(u){let d=P(u);return d in n?!1:(n[d]=!0,!0)});this.features.push(this.createCluster(c,e))}}}}createCluster(e,t){let i=[0,0];for(let a=e.length-1;a>=0;--a){let l=this.geometryFunction(e[a]);l?ua(i,l.getCoordinates()):e.splice(a,1)}da(i,1/e.length);let n=be(t),s=this.interpolationRatio,o=new Fe([i[0]*(1-s)+n[0]*s,i[1]*(1-s)+n[1]*s]);return this.createCustomCluster_?this.createCustomCluster_(o,e):new Ge({geometry:o,features:e})}},nx=xf;function rx(r){let e=r.load||An,t=r.imageExtent,i=r.crossOrigin??null;return()=>{let n=new Image;return n.crossOrigin=i,r.referrerPolicy!==void 0&&(n.referrerPolicy=r.referrerPolicy),e(n,r.url).then(s=>{let o=z(t)/s.width,a=re(t)/s.height;return{image:s,extent:t,resolution:o!==a?[o,a]:a,pixelRatio:1}})}}var yf=class extends Hl{constructor(e){let t=e.crossOrigin!==void 0?e.crossOrigin:null,i=e.imageLoadFunction!==void 0?e.imageLoadFunction:Kl;super({attributions:e.attributions,interpolate:e.interpolate,projection:$(e.projection)}),this.url_=e.url,this.imageExtent_=e.imageExtent,this.image=null,this.image=new Vr(this.imageExtent_,void 0,1,rx({url:e.url,imageExtent:e.imageExtent,crossOrigin:t,referrerPolicy:e.referrerPolicy,load:(n,s)=>(this.image.setImage(n),i(this.image,s),An(n))})),this.image.addEventListener(L.CHANGE,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(e,t,i,n){return te(e,this.image.getExtent())?this.image:null}getUrl(){return this.url_}},sx=yf;var Ef=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=Ge,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let i=t.dataProjection?$(t.dataProjection):this.readProjection(e);t.extent&&i&&i.getUnits()==="tile-pixels"&&(i=$(i),i.setWorldExtent(t.extent)),t={dataProjection:i,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return j()}readFeature(e,t){return j()}readFeatures(e,t){return j()}readGeometry(e,t){return j()}readProjection(e){return j()}writeFeature(e,t){return j()}writeFeatures(e,t){return j()}writeGeometry(e,t){return j()}},Zl=Ef;function fs(r,e,t){let i=t?$(t.featureProjection):null,n=t?$(t.dataProjection):null,s=r;if(i&&n&&!Ie(i,n)){e&&(s=r.clone());let o=e?i:n,a=e?n:i;o.getUnits()==="tile-pixels"?s.transform(o,a):s.applyTransform(ct(o,a))}if(e&&t&&t.decimals!==void 0){let o=Math.pow(10,t.decimals),a=function(l){for(let h=0,c=l.length;h<c;++h)l[h]=Math.round(l[h]*o)/o;return l};s===r&&(s=r.clone()),s.applyTransform(a)}return s}var UE={Point:Fe,LineString:Ke,Polygon:dt,MultiPoint:un,MultiLineString:cn,MultiPolygon:dn};function BE(r,e,t){return Array.isArray(e[0])?(Da(r,0,e,t)||(r=r.slice(),Ks(r,0,e,t)),r):($s(r,0,e,t)||(r=r.slice(),Ir(r,0,e,t)),r)}function Tf(r,e){let t=r.geometry;if(!t)return[];if(Array.isArray(t))return t.map(s=>Tf({...r,geometry:s})).flat();let i=t.type==="MultiPolygon"?"Polygon":t.type;if(i==="GeometryCollection"||i==="Circle")throw new Error("Unsupported geometry type: "+i);let n=t.layout.length;return fs(new Ct(i,i==="Polygon"?BE(t.flatCoordinates,t.ends,n):t.flatCoordinates,t.ends?.flat(),n,r.properties||{},r.id).enableSimplifyTransformed(),!1,e)}function ql(r,e){if(!r)return null;if(Array.isArray(r)){let i=r.map(n=>ql(n,e));return new Mo(i)}let t=UE[r.type];return fs(new t(r.flatCoordinates,r.layout||"XY",r.ends),!1,e)}var Cf=class extends Zl{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(Jl(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(Jl(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return j()}readFeaturesFromObject(e,t){return j()}readGeometry(e,t){return this.readGeometryFromObject(Jl(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return j()}readProjection(e){return this.readProjectionFromObject(Jl(e))}readProjectionFromObject(e){return j()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return j()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return j()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return j()}};function Jl(r){if(typeof r=="string"){let e=JSON.parse(r);return e||null}return r!==null?r:null}var ox=Cf;var vf=class extends ox{constructor(e){e=e||{},super(),this.dataProjection=$(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=$(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 i=null;e.type==="Feature"?i=e:i={type:"Feature",geometry:e,properties:null};let n=Rf(i.geometry,t);if(this.featureClass===Ct)return Tf({geometry:n,id:i.id,properties:i.properties},t);let s=new Ge;return this.geometryName_?s.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&s.setGeometryName(i.geometry_name),s.setGeometry(ql(n,t)),"id"in i&&s.setId(i.id),i.properties&&s.setProperties(i.properties,!0),s}readFeaturesFromObject(e,t){let i=e,n=null;if(i.type==="FeatureCollection"){let s=e;n=[];let o=s.features;for(let a=0,l=o.length;a<l;++a){let h=this.readFeatureFromObject(o[a],t);h&&n.push(h)}}else n=[this.readFeatureFromObject(e,t)];return n.flat()}readGeometryFromObject(e,t){return zE(e,t)}readProjectionFromObject(e){let t=e.crs,i;if(t)if(t.type=="name")i=$(t.properties.name);else if(t.type==="EPSG")i=$("EPSG:"+t.properties.code);else throw new Error("Unknown SRS type");else i=this.dataProjection;return i}writeFeatureObject(e,t){t=this.adaptOptions(t);let i={type:"Feature",geometry:null,properties:null},n=e.getId();if(n!==void 0&&(i.id=n),!e.hasProperties())return i;let s=e.getProperties(),o=e.getGeometry();return o&&(i.geometry=Sf(o,t),delete s[e.getGeometryName()]),wt(s)||(i.properties=s),i}writeFeaturesObject(e,t){t=this.adaptOptions(t);let i=[];for(let n=0,s=e.length;n<s;++n)i.push(this.writeFeatureObject(e[n],t));return{type:"FeatureCollection",features:i}}writeGeometryObject(e,t){return Sf(e,this.adaptOptions(t))}};function Rf(r,e){if(!r)return null;let t;switch(r.type){case"Point":{t=VE(r);break}case"LineString":{t=WE(r);break}case"Polygon":{t=KE(r);break}case"MultiPoint":{t=YE(r);break}case"MultiLineString":{t=XE(r);break}case"MultiPolygon":{t=$E(r);break}case"GeometryCollection":{t=jE(r);break}default:throw new Error("Unsupported GeoJSON type: "+r.type)}return t}function zE(r,e){let t=Rf(r,e);return ql(t,e)}function jE(r,e){return r.geometries.map(function(i){return Rf(i,e)})}function VE(r){let e=r.coordinates;return{type:"Point",flatCoordinates:e,layout:Rn(e.length)}}function WE(r){let e=r.coordinates,t=e.flat();return{type:"LineString",flatCoordinates:t,ends:[t.length],layout:Rn(e[0]?.length||2)}}function XE(r){let e=r.coordinates,t=e[0]?.[0]?.length||2,i=[],n=wn(i,0,e,t);return{type:"MultiLineString",flatCoordinates:i,ends:n,layout:Rn(t)}}function YE(r){let e=r.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:Rn(e[0]?.length||2)}}function $E(r){let e=r.coordinates,t=[],i=e[0]?.[0]?.[0].length||2,n=Fa(t,0,e,i);return{type:"MultiPolygon",flatCoordinates:t,ends:n,layout:Rn(i)}}function KE(r){let e=r.coordinates,t=[],i=e[0]?.[0]?.length,n=wn(t,0,e,i);return{type:"Polygon",flatCoordinates:t,ends:n,layout:Rn(i)}}function Sf(r,e){r=fs(r,!0,e);let t=r.getType(),i;switch(t){case"Point":{i=eT(r,e);break}case"LineString":{i=ZE(r,e);break}case"Polygon":{i=tT(r,e);break}case"MultiPoint":{i=JE(r,e);break}case"MultiLineString":{i=qE(r,e);break}case"MultiPolygon":{i=QE(r,e);break}case"GeometryCollection":{i=HE(r,e);break}case"Circle":{i={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+t)}return i}function HE(r,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:r.getGeometriesArray().map(function(i){return Sf(i,e)})}}function ZE(r,e){return{type:"LineString",coordinates:r.getCoordinates()}}function qE(r,e){return{type:"MultiLineString",coordinates:r.getCoordinates()}}function JE(r,e){return{type:"MultiPoint",coordinates:r.getCoordinates()}}function QE(r,e){let t;return e&&(t=e.rightHanded),{type:"MultiPolygon",coordinates:r.getCoordinates(t)}}function eT(r,e){return{type:"Point",coordinates:r.getCoordinates()}}function tT(r,e){let t;return e&&(t=e.rightHanded),{type:"Polygon",coordinates:r.getCoordinates(t)}}var gr=vf;var ax=23283064365386963e-26,iT=12,lx=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),wf=0,Ql=1,Uo=2,eh=5,Bo=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos<i;){let n=this.readVarint(),s=n>>3,o=this.pos;this.type=n&7,e(s,t,this),this.pos===o&&this.skip(n)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*4294967296;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*4294967296;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,i,n;return n=t[this.pos++],i=n&127,n<128||(n=t[this.pos++],i|=(n&127)<<7,n<128)||(n=t[this.pos++],i|=(n&127)<<14,n<128)||(n=t[this.pos++],i|=(n&127)<<21,n<128)?i:(n=t[this.pos],i|=(n&15)<<28,nT(i,e,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){let e=this.readVarint();return e%2===1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=iT&&lx?lx.decode(this.buf.subarray(t,e)):pT(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){let t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===Uo?this.readVarint()+this.pos:this.pos+1}skip(e){let t=e&7;if(t===wf)for(;this.buf[this.pos++]>127;);else if(t===Uo)this.pos=this.readVarint()+this.pos;else if(t===eh)this.pos+=4;else if(t===Ql)this.pos+=8;else throw new Error(`Unimplemented type: ${t}`)}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){let i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.dataView=new DataView(i.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,e&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*ax),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,e&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*ax),!0),this.pos+=8}writeVarint(e){if(e=+e||0,e>268435455||e<0){rT(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))}writeSVarint(e){this.writeVarint(e<0?-e*2-1:e*2)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(e.length*4),this.pos++;let t=this.pos;this.pos=_T(this.buf,e,this.pos);let i=this.pos-t;i>=128&&hx(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){let t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i<t;i++)this.buf[this.pos++]=e[i]}writeRawMessage(e,t){this.pos++;let i=this.pos;e(t,this);let n=this.pos-i;n>=128&&hx(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,i){this.writeTag(e,Uo),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,aT,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,lT,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,uT,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,hT,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,cT,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,dT,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,fT,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,gT,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,mT,t)}writeBytesField(e,t){this.writeTag(e,Uo),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,eh),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,eh),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,Ql),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,Ql),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,wf),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,wf),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,Uo),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,eh),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,Ql),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}};function nT(r,e,t){let i=t.buf,n,s;if(s=i[t.pos++],n=(s&112)>>4,s<128||(s=i[t.pos++],n|=(s&127)<<3,s<128)||(s=i[t.pos++],n|=(s&127)<<10,s<128)||(s=i[t.pos++],n|=(s&127)<<17,s<128)||(s=i[t.pos++],n|=(s&127)<<24,s<128)||(s=i[t.pos++],n|=(s&1)<<31,s<128))return gs(r,n,e);throw new Error("Expected varint not more than 10 bytes")}function gs(r,e,t){return t?e*4294967296+(r>>>0):(e>>>0)*4294967296+(r>>>0)}function rT(r,e){let t,i;if(r>=0?(t=r%4294967296|0,i=r/4294967296|0):(t=~(-r%4294967296),i=~(-r/4294967296),t^4294967295?t=t+1|0:(t=0,i=i+1|0)),r>=18446744073709552e3||r<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),sT(t,i,e),oT(i,e)}function sT(r,e,t){t.buf[t.pos++]=r&127|128,r>>>=7,t.buf[t.pos++]=r&127|128,r>>>=7,t.buf[t.pos++]=r&127|128,r>>>=7,t.buf[t.pos++]=r&127|128,r>>>=7,t.buf[t.pos]=r&127}function oT(r,e){let t=(r&7)<<4;e.buf[e.pos++]|=t|((r>>>=3)?128:0),r&&(e.buf[e.pos++]=r&127|((r>>>=7)?128:0),r&&(e.buf[e.pos++]=r&127|((r>>>=7)?128:0),r&&(e.buf[e.pos++]=r&127|((r>>>=7)?128:0),r&&(e.buf[e.pos++]=r&127|((r>>>=7)?128:0),r&&(e.buf[e.pos++]=r&127)))))}function hx(r,e,t){let i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));t.realloc(i);for(let n=t.pos-1;n>=r;n--)t.buf[n+i]=t.buf[n]}function aT(r,e){for(let t=0;t<r.length;t++)e.writeVarint(r[t])}function lT(r,e){for(let t=0;t<r.length;t++)e.writeSVarint(r[t])}function hT(r,e){for(let t=0;t<r.length;t++)e.writeFloat(r[t])}function cT(r,e){for(let t=0;t<r.length;t++)e.writeDouble(r[t])}function uT(r,e){for(let t=0;t<r.length;t++)e.writeBoolean(r[t])}function dT(r,e){for(let t=0;t<r.length;t++)e.writeFixed32(r[t])}function fT(r,e){for(let t=0;t<r.length;t++)e.writeSFixed32(r[t])}function gT(r,e){for(let t=0;t<r.length;t++)e.writeFixed64(r[t])}function mT(r,e){for(let t=0;t<r.length;t++)e.writeSFixed64(r[t])}function pT(r,e,t){let i="",n=e;for(;n<t;){let s=r[n],o=null,a=s>239?4:s>223?3:s>191?2:1;if(n+a>t)break;let l,h,c;a===1?s<128&&(o=s):a===2?(l=r[n+1],(l&192)===128&&(o=(s&31)<<6|l&63,o<=127&&(o=null))):a===3?(l=r[n+1],h=r[n+2],(l&192)===128&&(h&192)===128&&(o=(s&15)<<12|(l&63)<<6|h&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(l=r[n+1],h=r[n+2],c=r[n+3],(l&192)===128&&(h&192)===128&&(c&192)===128&&(o=(s&15)<<18|(l&63)<<12|(h&63)<<6|c&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,a=1):o>65535&&(o-=65536,i+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),i+=String.fromCharCode(o),n+=a}return i}function _T(r,e,t){for(let i=0,n,s;i<e.length;i++){if(n=e.charCodeAt(i),n>55295&&n<57344)if(s)if(n<56320){r[t++]=239,r[t++]=191,r[t++]=189,s=n;continue}else n=s-55296<<10|n-56320|65536,s=null;else{n>56319||i+1===e.length?(r[t++]=239,r[t++]=191,r[t++]=189):s=n;continue}else s&&(r[t++]=239,r[t++]=191,r[t++]=189,s=null);n<128?r[t++]=n:(n<2048?r[t++]=n>>6|192:(n<65536?r[t++]=n>>12|224:(r[t++]=n>>18|240,r[t++]=n>>12&63|128),r[t++]=n>>6&63|128),r[t++]=n&63|128)}return t}var Pf=class extends Zl{constructor(e){super(),e=e||{},this.dataProjection=new Tn({code:"",units:"tile-pixels"}),this.featureClass=e.featureClass?e.featureClass:Ct,this.geometryName_=e.geometryName,this.layerName_=e.layerName?e.layerName:"layer",this.layers_=e.layers?e.layers:null,this.idProperty_=e.idProperty,this.supportedMediaTypes=["application/vnd.mapbox-vector-tile","application/x-protobuf"]}readRawGeometry_(e,t,i,n){e.pos=t.geometry;let s=e.readVarint()+e.pos,o=1,a=0,l=0,h=0,c=0,u=0;for(;e.pos<s;){if(!a){let d=e.readVarint();o=d&7,a=d>>3}if(a--,o===1||o===2)l+=e.readSVarint(),h+=e.readSVarint(),o===1&&c>u&&(n.push(c),u=c),i.push(l,h),c+=2;else if(o===7)c>u&&(i.push(i[u],i[u+1]),c+=2);else throw new Error("Invalid command found in the PBF")}c>u&&(n.push(c),u=c)}createFeature_(e,t,i){let n=t.type;if(n===0)return null;let s,o=t.properties,a;this.idProperty_?(a=o[this.idProperty_],delete o[this.idProperty_]):a=t.id,o[this.layerName_]=t.layer.name;let l=[],h=[];this.readRawGeometry_(e,t,l,h);let c=CT(n,h.length);if(this.featureClass===Ct)s=new this.featureClass(c,l,h,2,o,a),s.transform(i.dataProjection);else{let u;if(c=="Polygon"){let g=Fr(l,h);u=g.length>1?new dn(l,"XY",g):new dt(l,"XY",h)}else u=c==="Point"?new Fe(l,"XY"):c==="LineString"?new Ke(l,"XY"):c==="MultiPoint"?new un(l,"XY"):c==="MultiLineString"?new cn(l,"XY",h):null;let d=this.featureClass;s=new d,this.geometryName_&&s.setGeometryName(this.geometryName_);let f=fs(u,!1,i);s.setGeometry(f),a!==void 0&&s.setId(a),s.setProperties(o,!0)}return s}getType(){return"arraybuffer"}readFeatures(e,t){let i=this.layers_;t=this.adaptOptions(t);let n=$(t.dataProjection);n.setWorldExtent(t.extent),t.dataProjection=n;let s=new Bo(e),o=s.readFields(xT,{}),a=[];for(let l in o){if(i&&!i.includes(l))continue;let h=o[l],c=h?[0,0,h.extent,h.extent]:null;n.setExtent(c);for(let u=0,d=h.length;u<d;++u){let f=TT(s,h,u),g=this.createFeature_(s,f,t);g!==null&&a.push(g)}}return a}readProjection(e){return this.dataProjection}setLayers(e){this.layers_=e}};function xT(r,e,t){if(r===3){let i={keys:[],values:[],features:[]},n=t.readVarint()+t.pos;t.readFields(yT,i,n),i.length=i.features.length,i.length&&(e[i.name]=i)}}function yT(r,e,t){if(r===15)e.version=t.readVarint();else if(r===1)e.name=t.readString();else if(r===5)e.extent=t.readVarint();else if(r===2)e.features.push(t.pos);else if(r===3)e.keys.push(t.readString());else if(r===4){let i=null,n=t.readVarint()+t.pos;for(;t.pos<n;)r=t.readVarint()>>3,i=r===1?t.readString():r===2?t.readFloat():r===3?t.readDouble():r===4?t.readVarint64():r===5?t.readVarint():r===6?t.readSVarint():r===7?t.readBoolean():null;e.values.push(i)}}function ET(r,e,t){if(r==1)e.id=t.readVarint();else if(r==2){let i=t.readVarint()+t.pos;for(;t.pos<i;){let n=e.layer.keys[t.readVarint()],s=e.layer.values[t.readVarint()];e.properties[n]=s}}else r==3?e.type=t.readVarint():r==4&&(e.geometry=t.pos)}function TT(r,e,t){r.pos=e.features[t];let i=r.readVarint()+r.pos,n={layer:e,type:0,properties:{}};return r.readFields(ET,n,i),n}function CT(r,e){let t;return r===1?t=e===1?"Point":"MultiPoint":r===2?t=e===1?"LineString":"MultiLineString":r===3&&(t="Polygon"),t}var cx=Pf;var ux=["fullscreenchange","webkitfullscreenchange"],dx={ENTERFULLSCREEN:"enterfullscreen",LEAVEFULLSCREEN:"leavefullscreen"},Lf=class extends st{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target}),this.on,this.once,this.un,this.keys_=e.keys!==void 0?e.keys:!1,this.source_=e.source,this.isInFullscreen_=!1,this.boundHandleMapTargetChange_=this.handleMapTargetChange_.bind(this),this.cssClassName_=e.className!==void 0?e.className:"ol-full-screen",this.documentListeners_=[],this.activeClassName_=e.activeClassName!==void 0?e.activeClassName.split(" "):[this.cssClassName_+"-true"],this.inactiveClassName_=e.inactiveClassName!==void 0?e.inactiveClassName.split(" "):[this.cssClassName_+"-false"];let t=e.label!==void 0?e.label:"\u2922";this.labelNode_=typeof t=="string"?document.createTextNode(t):t;let i=e.labelActive!==void 0?e.labelActive:"\xD7";this.labelActiveNode_=typeof i=="string"?document.createTextNode(i):i;let n=e.tipLabel?e.tipLabel:"Toggle full-screen";this.button_=document.createElement("button"),this.button_.title=n,this.button_.setAttribute("type","button"),this.button_.appendChild(this.labelNode_),this.button_.addEventListener(L.CLICK,this.handleClick_.bind(this),!1),this.setClassName_(this.button_,this.isInFullscreen_),this.element.className=`${this.cssClassName_} ${et} ${Wt}`,this.element.appendChild(this.button_)}handleClick_(e){e.preventDefault(),this.handleFullScreen_()}handleFullScreen_(){let e=this.getMap();if(!e)return;let t=e.getOwnerDocument();if(fx(t))if(gx(t))ST(t);else{let i;this.source_?i=typeof this.source_=="string"?t.getElementById(this.source_):this.source_:i=e.getTargetElement(),this.keys_?vT(i):mx(i)}}handleFullScreenChange_(){let e=this.getMap();if(!e)return;let t=this.isInFullscreen_;this.isInFullscreen_=gx(e.getOwnerDocument()),t!==this.isInFullscreen_&&(this.setClassName_(this.button_,this.isInFullscreen_),this.isInFullscreen_?(Ki(this.labelActiveNode_,this.labelNode_),this.dispatchEvent(dx.ENTERFULLSCREEN)):(Ki(this.labelNode_,this.labelActiveNode_),this.dispatchEvent(dx.LEAVEFULLSCREEN)),e.updateSize())}setClassName_(e,t){t?(e.classList.remove(...this.inactiveClassName_),e.classList.add(...this.activeClassName_)):(e.classList.remove(...this.activeClassName_),e.classList.add(...this.inactiveClassName_))}setMap(e){let t=this.getMap();t&&t.removeChangeListener(Pe.TARGET,this.boundHandleMapTargetChange_),super.setMap(e),this.handleMapTargetChange_(),e&&e.addChangeListener(Pe.TARGET,this.boundHandleMapTargetChange_)}handleMapTargetChange_(){let e=this.documentListeners_;for(let i=0,n=e.length;i<n;++i)K(e[i]);e.length=0;let t=this.getMap();if(t){let i=t.getOwnerDocument();fx(i)?this.element.classList.remove(Tc):this.element.classList.add(Tc);for(let n=0,s=ux.length;n<s;++n)e.push(k(i,ux[n],this.handleFullScreenChange_,this));this.handleFullScreenChange_()}}};function fx(r){let e=r.body;return!!(e.webkitRequestFullscreen||e.requestFullscreen&&r.fullscreenEnabled)}function gx(r){return!!(r.webkitIsFullScreen||r.fullscreenElement)}function mx(r){r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen&&r.webkitRequestFullscreen()}function vT(r){r.webkitRequestFullscreen?r.webkitRequestFullscreen():mx(r)}function ST(r){r.exitFullscreen?r.exitFullscreen():r.webkitExitFullscreen&&r.webkitExitFullscreen()}var bf=Lf;var If="projection",px="coordinateFormat",Ff=class extends st{constructor(e){e=e||{};let t=document.createElement("div");t.className=e.className!==void 0?e.className:"ol-mouse-position",super({element:t,render:e.render,target:e.target}),this.on,this.once,this.un,this.addChangeListener(If,this.handleProjectionChanged_),e.coordinateFormat&&this.setCoordinateFormat(e.coordinateFormat),e.projection&&this.setProjection(e.projection),this.renderOnMouseOut_=e.placeholder!==void 0,this.placeholder_=this.renderOnMouseOut_?e.placeholder:"&#160;",this.renderedHTML_=t.innerHTML,this.mapProjection_=null,this.transform_=null,this.wrapX_=e.wrapX!==!1}handleProjectionChanged_(){this.transform_=null}getCoordinateFormat(){return this.get(px)}getProjection(){return this.get(If)}handleMouseMove(e){let t=this.getMap();this.updateHTML_(t.getEventPixel(e))}handleMouseOut(e){this.updateHTML_(null)}setMap(e){if(super.setMap(e),e){let t=e.getViewport();this.listenerKeys.push(k(t,kt.POINTERMOVE,this.handleMouseMove,this)),this.renderOnMouseOut_&&this.listenerKeys.push(k(t,kt.POINTEROUT,this.handleMouseOut,this)),this.updateHTML_(null)}}setCoordinateFormat(e){this.set(px,e)}setProjection(e){this.set(If,$(e))}updateHTML_(e){let t=this.placeholder_;if(e&&this.mapProjection_){if(!this.transform_){let s=this.getProjection();s?this.transform_=zt(this.mapProjection_,s):this.transform_=em}let n=this.getMap().getCoordinateFromPixelInternal(e);if(n){let s=we();if(s&&(this.transform_=zt(this.mapProjection_,s)),this.transform_(n,n),this.wrapX_){let a=s||this.getProjection()||this.mapProjection_;En(n,a)}let o=this.getCoordinateFormat();o?t=o(n):t=n.toString()}}(!this.renderedHTML_||t!==this.renderedHTML_)&&(this.element.innerHTML=t,this.renderedHTML_=t)}render(e){let t=e.frameState;t?this.mapProjection_!=t.viewState.projection&&(this.mapProjection_=t.viewState.projection,this.transform_=null):this.mapProjection_=null}},Mf=Ff;var vt={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"},Af=class extends De{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=e.insertFirst!==void 0?e.insertFirst:!0,this.stopEvent=e.stopEvent!==void 0?e.stopEvent:!0,this.element=document.createElement("div"),this.element.className=e.className!==void 0?e.className:"ol-overlay-container "+wm,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=e.autoPan===!0?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(vt.ELEMENT,this.handleElementChanged),this.addChangeListener(vt.MAP,this.handleMapChanged),this.addChangeListener(vt.OFFSET,this.handleOffsetChanged),this.addChangeListener(vt.POSITION,this.handlePositionChanged),this.addChangeListener(vt.POSITIONING,this.handlePositioningChanged),e.element!==void 0&&this.setElement(e.element),this.setOffset(e.offset!==void 0?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),e.position!==void 0&&this.setPosition(e.position)}getElement(){return this.get(vt.ELEMENT)}getId(){return this.id}getMap(){return this.get(vt.MAP)||null}getOffset(){return this.get(vt.OFFSET)}getPosition(){return this.get(vt.POSITION)}getPositioning(){return this.get(vt.POSITIONING)}handleElementChanged(){Ua(this.element);let e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),K(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);let e=this.getMap();if(e){this.mapPostrenderListenerKey=k(e,Nt.POSTRENDER,this.render,this),this.updatePixelPosition();let t=this.stopEvent?e.getOverlayContainerStopEvent():e.getOverlayContainer();this.insertFirst?t.insertBefore(this.element,t.childNodes[0]||null):t.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(vt.ELEMENT,e)}setMap(e){this.set(vt.MAP,e)}setOffset(e){this.set(vt.OFFSET,e)}setPosition(e){this.set(vt.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){let t=this.getMap();if(!t||!t.getTargetElement()||!this.get(vt.POSITION))return;let i=this.getRect(t.getTargetElement(),t.getSize()),n=this.getElement(),s=this.getRect(n,[Pm(n),Lm(n)]);e=e||{};let o=e.margin===void 0?20:e.margin;if(!Ue(i,s)){let a=s[0]-i[0],l=i[2]-s[2],h=s[1]-i[1],c=i[3]-s[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),h<0?u[1]=h-o:c<0&&(u[1]=Math.abs(c)+o),u[0]!==0||u[1]!==0){let d=t.getView().getCenterInternal(),f=t.getPixelFromCoordinateInternal(d);if(!f)return;let g=[f[0]+u[0],f[1]+u[1]],m=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(g),duration:m.duration,easing:m.easing})}}}getRect(e,t){let i=e.getBoundingClientRect(),n=i.left+window.pageXOffset,s=i.top+window.pageYOffset;return[n,s,n+t[0],s+t[1]]}setPositioning(e){this.set(vt.POSITIONING,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){let e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t){this.setVisible(!1);return}let i=e.getPixelFromCoordinate(t),n=e.getSize();this.updateRenderedPosition(i,n)}updateRenderedPosition(e,t){let i=this.element.style,n=this.getOffset(),s=this.getPositioning();this.setVisible(!0);let o=`${e[0]+n[0]}px`,a=`${e[1]+n[1]}px`,l="0%",h="0%";s=="bottom-right"||s=="center-right"||s=="top-right"?l="-100%":(s=="bottom-center"||s=="center-center"||s=="top-center")&&(l="-50%"),s=="bottom-left"||s=="bottom-center"||s=="bottom-right"?h="-100%":(s=="center-left"||s=="center-center"||s=="center-right")&&(h="-50%");let c=`translate(${l}, ${h}) translate(${o}, ${a})`;this.rendered.transform_!=c&&(this.rendered.transform_=c,i.transform=c)}getOptions(){return this.options}},ms=Af;var th=.75,zo=.1,Of=class extends st{constructor(e){e=e||{},super({element:document.createElement("div"),render:e.render,target:e.target}),this.boundHandleRotationChanged_=this.handleRotationChanged_.bind(this),this.collapsed_=e.collapsed!==void 0?e.collapsed:!0,this.collapsible_=e.collapsible!==void 0?e.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.rotateWithView_=e.rotateWithView!==void 0?e.rotateWithView:!1,this.viewExtent_=void 0;let t=e.className!==void 0?e.className:"ol-overviewmap",i=e.tipLabel!==void 0?e.tipLabel:"Overview map",n=e.collapseLabel!==void 0?e.collapseLabel:"\u2039";typeof n=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=n):this.collapseLabel_=n;let s=e.label!==void 0?e.label:"\u203A";typeof s=="string"?(this.label_=document.createElement("span"),this.label_.textContent=s):this.label_=s;let o=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_,a=document.createElement("button");a.setAttribute("type","button"),a.title=i,a.appendChild(o),a.addEventListener(L.CLICK,this.handleClick_.bind(this),!1),this.ovmapDiv_=document.createElement("div"),this.ovmapDiv_.className="ol-overviewmap-map",this.view_=e.view;let l=new al({view:e.view,controls:new Ce,interactions:new Ce});this.ovmap_=l,e.layers&&e.layers.forEach(function(_){l.addLayer(_)});let h=document.createElement("div");h.className="ol-overviewmap-box",h.style.boxSizing="border-box",this.boxOverlay_=new ms({position:[0,0],positioning:"center-center",element:h}),this.ovmap_.addOverlay(this.boxOverlay_);let c=t+" "+et+" "+Wt+(this.collapsed_&&this.collapsible_?" "+Or:"")+(this.collapsible_?"":" ol-uncollapsible"),u=this.element;u.className=c,u.appendChild(this.ovmapDiv_),u.appendChild(a);let d=this.boxOverlay_,f=this.boxOverlay_.getElement(),g=_=>({clientX:_.clientX,clientY:_.clientY}),m=function(_){let x=g(_),y=l.getEventCoordinate(x);d.setPosition(y)},p=_=>{let x=l.getEventCoordinateInternal(_),y=this.getMap();y.getView().setCenterInternal(x);let E=y.getOwnerDocument();E.removeEventListener("pointermove",m),E.removeEventListener("pointerup",p)};this.ovmapDiv_.addEventListener("pointerdown",_=>{let x=this.getMap().getOwnerDocument();_.target===f&&x.addEventListener("pointermove",m),x.addEventListener("pointerup",p)})}setMap(e){let t=this.getMap();if(e!==t){if(t){let i=t.getView();i&&this.unbindView_(i),this.ovmap_.setTarget(null)}if(super.setMap(e),e){this.ovmap_.setTarget(this.ovmapDiv_),this.listenerKeys.push(k(e,He.PROPERTYCHANGE,this.handleMapPropertyChange_,this));let i=e.getView();i&&this.bindView_(i),this.ovmap_.isRendered()||this.updateBoxAfterOvmapIsRendered_()}}}handleMapPropertyChange_(e){if(e.key===Pe.VIEW){let t=e.oldValue;t&&this.unbindView_(t);let i=this.getMap().getView();this.bindView_(i)}else!this.ovmap_.isRendered()&&(e.key===Pe.TARGET||e.key===Pe.SIZE)&&this.ovmap_.updateSize()}bindView_(e){if(!this.view_){let t=new It({projection:e.getProjection()});this.ovmap_.setView(t)}e.addChangeListener(Pt.ROTATION,this.boundHandleRotationChanged_),this.handleRotationChanged_(),e.isDef()&&(this.ovmap_.updateSize(),this.resetExtent_())}unbindView_(e){e.removeChangeListener(Pt.ROTATION,this.boundHandleRotationChanged_)}handleRotationChanged_(){this.rotateWithView_&&this.ovmap_.getView().setRotation(this.getMap().getView().getRotation())}validateExtent_(){let e=this.getMap(),t=this.ovmap_;if(!e.isRendered()||!t.isRendered())return;let i=e.getSize(),s=e.getView().calculateExtentInternal(i);if(this.viewExtent_&&qe(s,this.viewExtent_))return;this.viewExtent_=s;let o=t.getSize(),l=t.getView().calculateExtentInternal(o),h=t.getPixelFromCoordinateInternal(Je(s)),c=t.getPixelFromCoordinateInternal(ji(s)),u=Math.abs(h[0]-c[0]),d=Math.abs(h[1]-c[1]),f=o[0],g=o[1];u<f*zo||d<g*zo||u>f*th||d>g*th?this.resetExtent_():Ue(l,s)||this.recenter_()}resetExtent_(){if(th===0||zo===0)return;let e=this.getMap(),t=this.ovmap_,i=e.getSize(),s=e.getView().calculateExtentInternal(i),o=t.getView(),a=Math.log(th/zo)/Math.LN2,l=1/(Math.pow(2,a/2)*zo);Pg(s,l),o.fitInternal(Jn(s))}recenter_(){let e=this.getMap(),t=this.ovmap_,i=e.getView();t.getView().setCenterInternal(i.getCenterInternal())}updateBox_(){let e=this.getMap(),t=this.ovmap_;if(!e.isRendered()||!t.isRendered())return;let i=e.getSize(),n=e.getView(),s=t.getView(),o=this.rotateWithView_?0:-n.getRotation(),a=this.boxOverlay_,l=this.boxOverlay_.getElement(),h=n.getCenter(),c=n.getResolution(),u=s.getResolution(),d=i[0]*c/u,f=i[1]*c/u;if(a.setPosition(h),l){l.style.width=d+"px",l.style.height=f+"px";let g="rotate("+o+"rad)";l.style.transform=g}}updateBoxAfterOvmapIsRendered_(){this.ovmapPostrenderKey_||(this.ovmapPostrenderKey_=_n(this.ovmap_,Nt.POSTRENDER,e=>{delete this.ovmapPostrenderKey_,this.updateBox_()}))}handleClick_(e){e.preventDefault(),this.handleToggle_()}handleToggle_(){this.element.classList.toggle(Or),this.collapsed_?Ki(this.collapseLabel_,this.label_):Ki(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_;let e=this.ovmap_;if(!this.collapsed_){if(e.isRendered()){this.viewExtent_=void 0,e.render();return}e.updateSize(),this.resetExtent_(),this.updateBoxAfterOvmapIsRendered_()}}getCollapsible(){return this.collapsible_}setCollapsible(e){this.collapsible_!==e&&(this.collapsible_=e,this.element.classList.toggle("ol-uncollapsible"),!e&&this.collapsed_&&this.handleToggle_())}setCollapsed(e){!this.collapsible_||this.collapsed_===e||this.handleToggle_()}getCollapsed(){return this.collapsed_}getRotateWithView(){return this.rotateWithView_}setRotateWithView(e){this.rotateWithView_!==e&&(this.rotateWithView_=e,this.getMap().getView().getRotation()!==0&&(this.rotateWithView_?this.handleRotationChanged_():this.ovmap_.getView().setRotation(0),this.viewExtent_=void 0,this.validateExtent_(),this.updateBox_()))}getOverviewMap(){return this.ovmap_}render(e){this.validateExtent_(),this.updateBox_()}},Df=Of;var kf="units",RT=[1,2,5],jo=25.4/.28,Nf=class extends st{constructor(e){e=e||{};let t=document.createElement("div");t.style.pointerEvents="none",super({element:t,render:e.render,target:e.target}),this.on,this.once,this.un;let i=e.className!==void 0?e.className:e.bar?"ol-scale-bar":"ol-scale-line";this.innerElement_=document.createElement("div"),this.innerElement_.className=i+"-inner",this.element.className=i+" "+et,this.element.appendChild(this.innerElement_),this.viewState_=null,this.minWidth_=e.minWidth!==void 0?e.minWidth:64,this.maxWidth_=e.maxWidth,this.renderedVisible_=!1,this.renderedWidth_=void 0,this.renderedHTML_="",this.addChangeListener(kf,this.handleUnitsChanged_),this.setUnits(e.units||"metric"),this.scaleBar_=e.bar||!1,this.scaleBarSteps_=e.steps||4,this.scaleBarText_=e.text||!1,this.dpi_=e.dpi||void 0}getUnits(){return this.get(kf)}handleUnitsChanged_(){this.updateElement_()}setUnits(e){this.set(kf,e)}setDpi(e){this.dpi_=e}updateElement_(){let e=this.viewState_;if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}let t=e.center,i=e.projection,n=this.getUnits(),s=n=="degrees"?"degrees":"m",o=Pr(i,e.resolution,t,s),a=this.minWidth_*(this.dpi_||jo)/jo,l=this.maxWidth_!==void 0?this.maxWidth_*(this.dpi_||jo)/jo:void 0,h=a*o,c="";if(n=="degrees"){let y=ci.degrees;h*=y,h<y/60?(c="\u2033",o*=3600):h<y?(c="\u2032",o*=60):c="\xB0"}else if(n=="imperial")h<.9144?(c="in",o/=.0254):h<1609.344?(c="ft",o/=.3048):(c="mi",o/=1609.344);else if(n=="nautical")o/=1852,c="NM";else if(n=="metric")h<1e-6?(c="nm",o*=1e9):h<.001?(c="\u03BCm",o*=1e6):h<1?(c="mm",o*=1e3):h<1e3?c="m":(c="km",o/=1e3);else if(n=="us")h<.9144?(c="in",o*=39.37):h<1609.344?(c="ft",o/=.30480061):(c="mi",o/=1609.3472);else throw new Error("Invalid units");let u=3*Math.floor(Math.log(a*o)/Math.log(10)),d,f,g,m=0,p,_;for(;;){g=Math.floor(u/3);let y=Math.pow(10,g);if(d=RT[(u%3+3)%3]*y,f=Math.round(d/o),isNaN(f)){this.element.style.display="none",this.renderedVisible_=!1;return}if(l!==void 0&&f>=l){d=m,f=p,g=_;break}else if(f>=a)break;m=d,p=f,_=g,++u}let x=this.scaleBar_?this.createScaleBar(f,d,c):d.toFixed(g<0?-g:0)+" "+c;this.renderedHTML_!=x&&(this.innerElement_.innerHTML=x,this.renderedHTML_=x),this.renderedWidth_!=f&&(this.innerElement_.style.width=f+"px",this.renderedWidth_=f),this.renderedVisible_||(this.element.style.display="",this.renderedVisible_=!0)}createScaleBar(e,t,i){let n=this.getScaleForResolution(),s=n<1?Math.round(1/n).toLocaleString()+" : 1":"1 : "+Math.round(n).toLocaleString(),o=this.scaleBarSteps_,a=e/o,l=[this.createMarker("absolute")];for(let c=0;c<o;++c){let u=c%2===0?"ol-scale-singlebar-odd":"ol-scale-singlebar-even";l.push(`<div><div class="ol-scale-singlebar ${u}" style="width: ${a}px;"></div>`+this.createMarker("relative")+(c%2===0||o===2?this.createStepText(c,e,!1,t,i):"")+"</div>")}return l.push(this.createStepText(o,e,!0,t,i)),(this.scaleBarText_?`<div class="ol-scale-text" style="width: ${e}px;">`+s+"</div>":"")+l.join("")}createMarker(e){return`<div class="ol-scale-step-marker" style="position: ${e}; top: ${e==="absolute"?3:-10}px;"></div>`}createStepText(e,t,i,n,s){let a=(e===0?0:Math.round(n/this.scaleBarSteps_*e*100)/100)+(e===0?"":" "+s),l=e===0?-3:t/this.scaleBarSteps_*-1,h=e===0?0:t/this.scaleBarSteps_*2;return`<div class="ol-scale-step-text" style="margin-left: ${l}px;text-align: ${e===0?"left":"center"};min-width: ${h}px;left: ${i?t+"px":"unset"};">`+a+"</div>"}getScaleForResolution(){let e=Pr(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m"),t=this.dpi_||jo,i=1e3/25.4;return e*i*t}render(e){let t=e.frameState;t?this.viewState_=t.viewState:this.viewState_=null,this.updateElement_()}},Gf=Nf;var Vo={VERTICAL:0,HORIZONTAL:1},Uf=class extends st{constructor(e){e=e||{},super({target:e.target,element:document.createElement("div"),render:e.render}),this.dragListenerKeys_=[],this.currentResolution_=void 0,this.direction_=Vo.VERTICAL,this.dragging_,this.heightLimit_=0,this.widthLimit_=0,this.startX_,this.startY_,this.thumbSize_=null,this.sliderInitialized_=!1,this.duration_=e.duration!==void 0?e.duration:200;let t=e.className!==void 0?e.className:"ol-zoomslider",i=document.createElement("button");i.setAttribute("type","button"),i.className=t+"-thumb "+et;let n=this.element;n.className=t+" "+et+" "+Wt,n.appendChild(i),n.addEventListener(kt.POINTERDOWN,this.handleDraggerStart_.bind(this),!1),n.addEventListener(kt.POINTERMOVE,this.handleDraggerDrag_.bind(this),!1),n.addEventListener(kt.POINTERUP,this.handleDraggerEnd_.bind(this),!1),n.addEventListener(L.CLICK,this.handleContainerClick_.bind(this),!1),i.addEventListener(L.CLICK,fg,!1)}setMap(e){super.setMap(e),e&&e.render()}initSlider_(){let e=this.element,t=e.offsetWidth,i=e.offsetHeight;if(t===0&&i===0)return this.sliderInitialized_=!1;let n=getComputedStyle(e);t-=parseFloat(n.paddingRight)+parseFloat(n.paddingLeft),i-=parseFloat(n.paddingTop)+parseFloat(n.paddingBottom);let s=e.firstElementChild,o=getComputedStyle(s),a=s.offsetWidth+parseFloat(o.marginRight)+parseFloat(o.marginLeft),l=s.offsetHeight+parseFloat(o.marginTop)+parseFloat(o.marginBottom);return this.thumbSize_=[a,l],t>i?(this.direction_=Vo.HORIZONTAL,this.widthLimit_=t-a):(this.direction_=Vo.VERTICAL,this.heightLimit_=i-l),this.sliderInitialized_=!0}handleContainerClick_(e){let t=this.getMap().getView(),i=this.getRelativePosition_(e.offsetX-this.thumbSize_[0]/2,e.offsetY-this.thumbSize_[1]/2),n=this.getResolutionForPosition_(i),s=t.getConstrainedZoom(t.getZoomForResolution(n));t.animateInternal({zoom:s,duration:this.duration_,easing:Bt})}handleDraggerStart_(e){if(!this.dragging_&&e.target===this.element.firstElementChild){let t=this.element.firstElementChild;if(this.getMap().getView().beginInteraction(),this.startX_=e.clientX-parseFloat(t.style.left),this.startY_=e.clientY-parseFloat(t.style.top),this.dragging_=!0,this.dragListenerKeys_.length===0){let i=this.handleDraggerDrag_,n=this.handleDraggerEnd_,s=this.getMap().getOwnerDocument();this.dragListenerKeys_.push(k(s,kt.POINTERMOVE,i,this),k(s,kt.POINTERUP,n,this))}}}handleDraggerDrag_(e){if(this.dragging_){let t=e.clientX-this.startX_,i=e.clientY-this.startY_,n=this.getRelativePosition_(t,i);this.currentResolution_=this.getResolutionForPosition_(n),this.getMap().getView().setResolution(this.currentResolution_)}}handleDraggerEnd_(e){this.dragging_&&(this.getMap().getView().endInteraction(),this.dragging_=!1,this.startX_=void 0,this.startY_=void 0,this.dragListenerKeys_.forEach(K),this.dragListenerKeys_.length=0)}setThumbPosition_(e){let t=this.getPositionForResolution_(e),i=this.element.firstElementChild;this.direction_==Vo.HORIZONTAL?i.style.left=this.widthLimit_*t+"px":i.style.top=this.heightLimit_*t+"px"}getRelativePosition_(e,t){let i;return this.direction_===Vo.HORIZONTAL?i=e/this.widthLimit_:i=t/this.heightLimit_,B(i,0,1)}getResolutionForPosition_(e){return this.getMap().getView().getResolutionForValueFunction()(1-e)}getPositionForResolution_(e){let t=this.getMap().getView().getValueForResolutionFunction();return B(1-t(e),0,1)}render(e){if(!e.frameState||!this.sliderInitialized_&&!this.initSlider_())return;let t=e.frameState.viewState.resolution;this.currentResolution_=t,this.setThumbPosition_(t)}},Bf=Uf;var zf=class extends st{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target}),this.extent=e.extent?e.extent:null,this.fitOptions=e.fitOptions||{};let t=e.className!==void 0?e.className:"ol-zoom-extent",i=e.label!==void 0?e.label:"E",n=e.tipLabel!==void 0?e.tipLabel:"Fit to extent",s=document.createElement("button");s.setAttribute("type","button"),s.title=n,s.appendChild(typeof i=="string"?document.createTextNode(i):i),s.addEventListener(L.CLICK,this.handleClick_.bind(this),!1);let o=t+" "+et+" "+Wt,a=this.element;a.className=o,a.appendChild(s)}handleClick_(e){e.preventDefault(),this.handleZoomToExtent()}handleZoomToExtent(){let t=this.getMap().getView(),i=this.extent?Be(this.extent,t.getProjection()):t.getProjection().getExtent();t.fitInternal(Jn(i),this.fitOptions)}},jf=zf;var Vf=class extends ot{constructor(e){e=e||{},super(e),this.condition_=e.condition?e.condition:Zi,this.lastAngle_=void 0,this.lastMagnitude_=void 0,this.lastScaleDelta_=0,this.duration_=e.duration!==void 0?e.duration:400}handleDragEvent(e){if(!In(e))return;let t=e.map,i=t.getSize(),n=e.pixel,s=n[0]-i[0]/2,o=i[1]/2-n[1],a=Math.atan2(o,s),l=Math.sqrt(s*s+o*o),h=t.getView();if(this.lastAngle_!==void 0){let c=this.lastAngle_-a;h.adjustRotationInternal(c)}this.lastAngle_=a,this.lastMagnitude_!==void 0&&h.adjustResolutionInternal(this.lastMagnitude_/l),this.lastMagnitude_!==void 0&&(this.lastScaleDelta_=this.lastMagnitude_/l),this.lastMagnitude_=l}handleUpEvent(e){if(!In(e))return!0;let i=e.map.getView(),n=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,n),this.lastScaleDelta_=0,!1}handleDownEvent(e){return In(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,this.lastMagnitude_=void 0,!0):!1}},Wf=Vf;function ki(r,e){let t=r.length;return e<0?r[e+t]:e>=t?r[e-t]:r[e]}function mr(r,e){let t=r.length,i=Math.floor(e),n=e-i;i>=t?i-=t:i<0&&(i+=t);let s=i+1;s>=t&&(s-=t);let o=r[i],a=o[0],l=o[1],h=r[s],c=h[0]-a,u=h[1]-l;return[a+c*n,l+u*n]}var ih={index:-1,endIndex:NaN,closestTargetDistance:1/0};function oh(r,e,t,i){let n=r[0],s=r[1],o=1/0,a=-1,l=NaN;for(let u=0;u<e.targets.length;++u){let d=e.targets[u],f=d.coordinates,g=1/0,m;for(let p=0;p<f.length-1;++p){let _=f[p],x=f[p+1],y=xx(n,s,_,x);y.squaredDistance<g&&(g=y.squaredDistance,m=p+y.along)}g<o&&(o=g,d.ring&&e.targetIndex===u&&(d.endIndex>d.startIndex?m<d.startIndex&&(m+=f.length):d.endIndex<d.startIndex&&m>d.startIndex&&(m-=f.length)),l=m,a=u)}let h=e.targets[a],c=h.ring;if(e.targetIndex===a&&c){let u=mr(h.coordinates,l),d=t.getPixelFromCoordinate(u),f=t.getPixelFromCoordinate(e.startCoord);Wi(d,f)>i&&(c=!1)}if(c){let u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(f<g){let m=sh(u,f,g);sh(u,f,g-d)<m&&(l-=d)}else{let m=sh(u,f,g);sh(u,f,g+d)<m&&(l+=d)}}return ih.index=a,ih.endIndex=l,ih.closestTargetDistance=o,ih}function ah(r,e){let t=[];for(let i=0;i<e.length;++i){let s=e[i].getGeometry();_x(r,s,t)}return t}function _x(r,e,t){if(e instanceof Ke){nh(r,e.getCoordinates(),!1,t);return}if(e instanceof cn){let i=e.getCoordinates();for(let n=0,s=i.length;n<s;++n)nh(r,i[n],!1,t);return}if(e instanceof dt){let i=e.getCoordinates();for(let n=0,s=i.length;n<s;++n)nh(r,i[n],!0,t);return}if(e instanceof dn){let i=e.getCoordinates();for(let n=0,s=i.length;n<s;++n){let o=i[n];for(let a=0,l=o.length;a<l;++a)nh(r,o[a],!0,t)}return}if(e instanceof Mo){let i=e.getGeometries();for(let n=0;n<i.length;++n)_x(r,i[n],t);return}}function nh(r,e,t,i){let n=r[0],s=r[1];for(let o=0,a=e.length-1;o<a;++o){let l=e[o],h=e[o+1],c=xx(n,s,l,h);if(c.squaredDistance===0){let u=o+c.along;i.push({coordinates:e,ring:t,startIndex:u,endIndex:u});return}}}function rh(r,e){return Gt(r[0],r[1],e[0],e[1])}function sh(r,e,t){let i,n;e<t?(i=e,n=t):(i=t,n=e);let s=Math.ceil(i),o=Math.floor(n);if(s>o){let l=mr(r,i),h=mr(r,n);return rh(l,h)}let a=0;if(i<s){let l=mr(r,i),h=ki(r,s);a+=rh(l,h)}if(o<n){let l=ki(r,o),h=mr(r,n);a+=rh(l,h)}for(let l=s;l<o-1;++l){let h=ki(r,l),c=ki(r,l+1);a+=rh(h,c)}return a}var Xf={along:0,squaredDistance:0};function xx(r,e,t,i){let n=t[0],s=t[1],o=i[0],a=i[1],l=o-n,h=a-s,c=0,u=n,d=s;return(l!==0||h!==0)&&(c=B(((r-n)*l+(e-s)*h)/(l*l+h*h),0,1),u+=l*c,d+=h*c),Xf.along=c,Xf.squaredDistance=hi(Gt(r,e,u,d),10),Xf}var lh={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"},ps=class extends ye{constructor(e,t){super(e),this.feature=t}},Yf=class extends ot{constructor(e){let t=e;t.stopDown||(t.stopDown=Ot),super(t),this.on,this.once,this.un,this.options_=e,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=e.source?e.source:null,this.features_=e.features?e.features:null,this.snapTolerance_=e.snapTolerance?e.snapTolerance:12,this.type_=e.type,this.mode_=PT(this.type_),this.stopClick_=!!e.stopClick,this.ignoreNextUpEvent_=!1,this.minPoints_=e.minPoints?e.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:e.maxPoints?e.maxPoints:1/0,this.finishCondition_=e.finishCondition?e.finishCondition:xt,this.geometryLayout_=e.geometryLayout?e.geometryLayout:"XY";let i=e.geometryFunction;if(!i){let n=this.mode_;if(n==="Circle")i=(s,o,a)=>{let l=o||new __([NaN,NaN]),h=ce(s[0],a),c=ei(h,ce(s[s.length-1],a));l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_);let u=we();return u&&l.transform(a,u),l};else{let s;n==="Point"?s=Fe:n==="LineString"?s=Ke:n==="Polygon"&&(s=dt),i=(o,a,l)=>(a?n==="Polygon"?o[0].length?a.setCoordinates([o[0].concat([o[0][0]])],this.geometryLayout_):a.setCoordinates([],this.geometryLayout_):a.setCoordinates(o,this.geometryLayout_):a=new s(o,this.geometryLayout_),a)}}this.geometryFunction_=i,this.dragVertexDelay_=e.dragVertexDelay!==void 0?e.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=e.clickTolerance?e.clickTolerance*e.clickTolerance:36,this.overlay_=new gt({source:new mt({useSpatialIndex:!1,wrapX:e.wrapX?e.wrapX:!1}),style:e.style?e.style:wT(),updateWhileInteracting:!0}),this.geometryName_=e.geometryName,this.condition_=e.condition?e.condition:Nr,this.freehandCondition_,e.freehand?this.freehandCondition_=Hi:this.freehandCondition_=e.freehandCondition?e.freehandCondition:Zi,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSource_=e.traceSource||e.source||null,this.addChangeListener(eo.ACTIVE,this.updateState_)}setTrace(e){let t;e?e===!0?t=Hi:t=e:t=Qn,this.traceCondition_=t}setMap(e){super.setMap(e),this.updateState_()}setFreehand(e){this.freehand_=e,this.freehand_?this.freehandCondition_=Hi:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Zi}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(e){e.originalEvent.type===L.CONTEXTMENU&&e.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(e);let t=e.type===ee.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&e.type===ee.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=e.pixel,this.shouldHandle_=!this.freehand_,t=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&e.type===ee.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(e.coordinate),i=!1):this.freehand_&&e.type===ee.POINTERDOWN?i=!1:t&&this.getPointerCount()<2?(i=e.type===ee.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(e),this.shouldHandle_&&e.originalEvent.preventDefault()):(e.originalEvent.pointerType==="mouse"||e.type===ee.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(e)):e.type===ee.DBLCLICK&&(i=!1),super.handleEvent(e)&&i}handleDownEvent(e){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=e.pixel,this.finishCoordinate_||this.startDrawing_(e.coordinate),!0):this.condition_(e)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new Qt(ee.POINTERMOVE,e.map,e.originalEvent,!1,e.frameState))},this.dragVertexDelay_),this.downPx_=e.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_();return}let t=this.getMap(),i=t.getCoordinateFromPixel([e.pixel[0]-this.snapTolerance_,e.pixel[1]+this.snapTolerance_]),n=t.getCoordinateFromPixel([e.pixel[0]+this.snapTolerance_,e.pixel[1]-this.snapTolerance_]),s=Re([i,n]),o=this.traceSource_.getFeaturesInExtent(s);if(o.length===0)return;let a=ah(e.coordinate,o);a.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){let i=e.startIndex<=e.endIndex,n=e.startIndex<=t;i===n?i&&t>e.endIndex||!i&&t<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,t):(i&&t<e.endIndex||!i&&t>e.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let i=0;if(e<t){let n=Math.ceil(e),s=Math.floor(t);s===t&&(s-=1),i=s-n+1}else{let n=Math.floor(e),s=Math.ceil(t);s===t&&(s+=1),i=n-s+1}i>0&&this.removeLastPoints_(i)}addTracedCoordinates_(e,t,i){if(t===i)return;let n=[];if(t<i){let s=Math.ceil(t),o=Math.floor(i);o===i&&(o-=1);for(let a=s;a<=o;++a)n.push(ki(e.coordinates,a))}else{let s=Math.floor(t),o=Math.ceil(i);o===i&&(o+=1);for(let a=s;a>=o;--a)n.push(ki(e.coordinates,a))}n.length&&this.appendCoordinates(n)}updateTrace_(e){let t=this.traceState_;if(!t.active)return;if(t.targetIndex===-1){let a=e.map.getPixelFromCoordinate(t.startCoord);if(Wi(a,e.pixel)<this.snapTolerance_)return}let i=oh(e.coordinate,t,this.getMap(),this.snapTolerance_);if(t.targetIndex!==i.index){if(t.targetIndex!==-1){let l=t.targets[t.targetIndex];this.removeTracedCoordinates_(l.startIndex,l.endIndex)}let a=t.targets[i.index];this.addTracedCoordinates_(a,a.startIndex,i.endIndex)}else{let a=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(a,i.endIndex)}t.targetIndex=i.index;let n=t.targets[t.targetIndex];n.endIndex=i.endIndex;let s=mr(n.coordinates,n.endIndex),o=this.getMap().getPixelFromCoordinate(s);e.coordinate=s,e.pixel=[Math.round(o[0]),Math.round(o[1])]}handleDragEvent(e){this.ignoreNextUpEvent_=!0,super.handleDragEvent(e)}handleUpEvent(e){let t=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(e);let i=this.traceState_.active;if(this.ignoreNextUpEvent_||this.toggleTraceState_(e),this.shouldHandle_){let n=!this.finishCoordinate_;n&&this.startDrawing_(e.coordinate),!n&&this.freehand_?this.finishDrawing():!this.freehand_&&(!n||this.mode_==="Point")&&(this.atFinish_(e.pixel,i)?this.finishCondition_(e)&&this.finishDrawing():this.addToDrawing_(e.coordinate)),t=!1}else this.freehand_&&this.abortDrawing()}return this.ignoreNextUpEvent_=!1,!t&&this.stopClick_&&e.preventDefault(),t}handlePointerMove_(e){if(this.pointerType_=e.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){let t=this.downPx_,i=e.pixel,n=t[0]-i[0],s=t[1]-i[1],o=n*n+s*s;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(e.coordinate.slice());return}this.updateTrace_(e),this.modifyDrawing_(e.coordinate)}atFinish_(e,t){let i=!1;if(this.sketchFeature_){let n=!1,s=[this.finishCoordinate_],o=this.mode_;if(o==="Point")i=!0;else if(o==="Circle")i=this.sketchCoords_.length===2;else if(o==="LineString")n=!t&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){let a=this.sketchCoords_;n=a[0].length>this.minPoints_,s=[a[0][0],a[0][a[0].length-2]],t?s=[a[0][0]]:s=[a[0][0],a[0][a[0].length-2]]}if(n){let a=this.getMap();for(let l=0,h=s.length;l<h;l++){let c=s[l],u=a.getPixelFromCoordinate(c),d=e[0]-u[0],f=e[1]-u[1],g=this.freehand_?1:this.snapTolerance_;if(i=Math.sqrt(d*d+f*f)<=g,i){this.finishCoordinate_=c;break}}}}return i}createOrUpdateSketchPoint_(e){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(e):(this.sketchPoint_=new Ge(new Fe(e)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(e){this.sketchLine_||(this.sketchLine_=new Ge);let t=e.getLinearRing(0),i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(t.getLayout(),t.getFlatCoordinates()),i.changed()):(i=new Ke(t.getFlatCoordinates(),t.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(e){let t=this.getMap().getView().getProjection(),i=Ns(this.geometryLayout_);for(;e.length<i;)e.push(0);this.finishCoordinate_=e,this.mode_==="Point"?this.sketchCoords_=e.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[e.slice(),e.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[e.slice(),e.slice()],this.sketchLineCoords_&&(this.sketchLine_=new Ge(new Ke(this.sketchLineCoords_)));let n=this.geometryFunction_(this.sketchCoords_,void 0,t);this.sketchFeature_=new Ge,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(n),this.updateSketchFeatures_(),this.dispatchEvent(new ps(lh.DRAWSTART,this.sketchFeature_))}modifyDrawing_(e){let t=this.getMap(),i=this.sketchFeature_.getGeometry(),n=t.getView().getProjection(),s=Ns(this.geometryLayout_),o,a;for(;e.length<s;)e.push(0);this.mode_==="Point"?a=this.sketchCoords_:this.mode_==="Polygon"?(o=this.sketchCoords_[0],a=o[o.length-1],this.atFinish_(t.getPixelFromCoordinate(e))&&(e=this.finishCoordinate_.slice())):(o=this.sketchCoords_,a=o[o.length-1]),a[0]=e[0],a[1]=e[1],this.geometryFunction_(this.sketchCoords_,i,n),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(e),i.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(i):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(e){let t=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),n,s,o=this.mode_;return o==="LineString"||o==="Circle"?(this.finishCoordinate_=e.slice(),s=this.sketchCoords_,s.length>=this.maxPoints_&&(this.freehand_?s.pop():n=!0),s.push(e.slice()),this.geometryFunction_(s,t,i)):o==="Polygon"&&(s=this.sketchCoords_[0],s.length>=this.maxPoints_&&(this.freehand_?s.pop():n=!0),s.push(e.slice()),n&&(this.finishCoordinate_=s[0]),this.geometryFunction_(this.sketchCoords_,t,i)),this.createOrUpdateSketchPoint_(e.slice()),this.updateSketchFeatures_(),n?this.finishDrawing():this.sketchFeature_}removeLastPoints_(e){if(!this.sketchFeature_)return;let t=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),n=this.mode_;for(let s=0;s<e;++s){let o;if(n==="LineString"||n==="Circle"){if(o=this.sketchCoords_,o.splice(-2,1),o.length>=2){this.finishCoordinate_=o[o.length-2].slice();let a=this.finishCoordinate_.slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}this.geometryFunction_(o,t,i),t.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(t)}else if(n==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);let a=this.sketchLine_.getGeometry();if(o.length>=2){let l=o[o.length-2].slice();o[o.length-1]=l,this.createOrUpdateSketchPoint_(l)}a.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,t,i)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){let e=this.abortDrawing_();if(!e)return null;let t=this.sketchCoords_,i=e.getGeometry(),n=this.getMap().getView().getProjection();return this.mode_==="LineString"?(t.pop(),this.geometryFunction_(t,i,n)):this.mode_==="Polygon"&&(t[0].pop(),this.geometryFunction_(t,i,n),t=i.getCoordinates()),this.type_==="MultiPoint"?e.setGeometry(new un([t])):this.type_==="MultiLineString"?e.setGeometry(new cn([t])):this.type_==="MultiPolygon"&&e.setGeometry(new dn([t])),this.dispatchEvent(new ps(lh.DRAWEND,e)),this.features_&&this.features_.push(e),this.source_&&this.source_.addFeature(e),e}abortDrawing_(){this.finishCoordinate_=null;let e=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),e}abortDrawing(){let e=this.abortDrawing_();e&&this.dispatchEvent(new ps(lh.DRAWABORT,e))}appendCoordinates(e){let t=this.mode_,i=!this.sketchFeature_;i&&this.startDrawing_(e[0]);let n;if(t==="LineString"||t==="Circle")n=this.sketchCoords_;else if(t==="Polygon")n=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;i&&n.shift(),n.pop();for(let o=0;o<e.length;o++)this.addToDrawing_(e[o]);let s=e[e.length-1];this.sketchFeature_=this.addToDrawing_(s),this.modifyDrawing_(s)}extend(e){let i=e.getGeometry();this.sketchFeature_=e,this.sketchCoords_=i.getCoordinates();let n=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=n.slice(),this.sketchCoords_.push(n.slice()),this.sketchPoint_=new Ge(new Fe(n)),this.updateSketchFeatures_(),this.dispatchEvent(new ps(lh.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){let e=[];this.sketchFeature_&&e.push(this.sketchFeature_),this.sketchLine_&&e.push(this.sketchLine_),this.sketchPoint_&&e.push(this.sketchPoint_);let t=this.overlay_.getSource();t.clear(!0),t.addFeatures(e)}updateState_(){let e=this.getMap(),t=this.getActive();(!e||!t)&&this.abortDrawing(),this.overlay_.setMap(t?e:null)}};function wT(){let r=Wr();return function(e,t){return r[e.getGeometry().getType()]}}function PT(r){switch(r){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+r)}}var hh=Yf;var yx=0,Wo=1,Ex=[0,0,0,0],_s=[],$f={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"};function Kf(r,e,t){let i;switch(e){case"LineString":i=r;break;case"MultiLineString":case"Polygon":i=r[t[0]];break;case"MultiPolygon":i=r[t[1]][t[0]];break;default:}return i}var Xo=class extends ye{constructor(e,t,i){super(e),this.features=t,this.mapBrowserEvent=i}},Hf=class extends ot{constructor(e){if(super(e),this.handleSourceAdd_=this.handleSourceAdd_.bind(this),this.handleSourceRemove_=this.handleSourceRemove_.bind(this),this.handleExternalCollectionAdd_=this.handleExternalCollectionAdd_.bind(this),this.handleExternalCollectionRemove_=this.handleExternalCollectionRemove_.bind(this),this.handleFeatureChange_=this.handleFeatureChange_.bind(this),this.on,this.once,this.un,this.condition_=e.condition?e.condition:Xa,this.defaultDeleteCondition_=function(i){return Om(i)&&Va(i)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:Hi,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new fr,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new gt({source:new mt({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:bT(),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.traceSource_=e.traceSource||e.source||null,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSegments_=null,this.hitDetection_=null,this.filterFunctionWasSupplied_=e.filter!=null,this.filter_=e.filter?e.filter:()=>!0,!(e.features||e.source))throw new Error("The modify interaction requires features collection or a source");let t;e.features?(t=e.features.getArray(),e.features.addEventListener(fe.ADD,this.handleExternalCollectionAdd_),e.features.addEventListener(fe.REMOVE,this.handleExternalCollectionRemove_),this.featuresCollection_=e.features):e.source&&(t=e.source.getFeatures(),e.source.addEventListener(Se.ADDFEATURE,this.handleSourceAdd_),e.source.addEventListener(Se.REMOVEFEATURE,this.handleSourceRemove_),this.source_=e.source),t.forEach(i=>{i.addEventListener(L.CHANGE,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&i.addEventListener(He.PROPERTYCHANGE,this.handleFeatureChange_)}),e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=[],t.filter(this.filter_).forEach(i=>this.addFeature_(i)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}setTrace(e){let t;e?e===!0?t=Hi:t=e:t=Qn,this.traceCondition_=t}addFeature_(e){this.features_.push(e);let t=e.getGeometry();if(t){let n=this.SEGMENT_WRITERS_[t.getType()];n&&n(e,t)}let i=this.getMap();i&&i.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastCoordinate_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Ce;let i=this.featuresBeingModified_.getArray();for(let n=0,s=t.length;n<s;++n){let o=t[n].feature;o&&!i.includes(o)&&this.featuresBeingModified_.push(o)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new Xo($f.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){let t=this.features_.indexOf(e);this.features_.splice(t,1),this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.length===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}removeFeatureSegmentData_(e){let t=this.rBush_,i=[];t.forEach(function(n){e===n.feature&&i.push(n)});for(let n=i.length-1;n>=0;--n){let s=i[n];for(let o=this.dragSegments_.length-1;o>=0;--o)this.dragSegments_[o][0]===s&&this.dragSegments_.splice(o,1);t.remove(s)}}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){let t=e.feature;t&&this.externalAddFeatureHandler_(t)}handleSourceRemove_(e){let t=e.feature;t&&this.externalRemoveFeatureHandler_(t)}handleExternalCollectionAdd_(e){let t=e.element;t&&this.externalAddFeatureHandler_(t)}handleExternalCollectionRemove_(e){let t=e.element;t&&this.externalRemoveFeatureHandler_(t)}externalAddFeatureHandler_(e){e.addEventListener(L.CHANGE,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&e.addEventListener(He.PROPERTYCHANGE,this.handleFeatureChange_),this.filter_(e)&&this.addFeature_(e)}externalRemoveFeatureHandler_(e){e.removeEventListener(L.CHANGE,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&e.removeEventListener(He.PROPERTYCHANGE,this.handleFeatureChange_),this.removeFeature_(e)}handleFeatureChange_(e){if(!this.changingFeature_){let t=e.target;this.removeFeature_(t),this.filter_(t)&&this.addFeature_(t)}}writePointGeometry_(e,t){let i=t.getCoordinates(),n={feature:e,geometry:t,segment:[i,i]};this.rBush_.insert(t.getExtent(),n)}writeMultiPointGeometry_(e,t){let i=t.getCoordinates();for(let n=0,s=i.length;n<s;++n){let o=i[n],a={feature:e,geometry:t,depth:[n],index:n,segment:[o,o]};this.rBush_.insert(t.getExtent(),a)}}writeLineStringGeometry_(e,t){let i=t.getCoordinates();for(let n=0,s=i.length-1;n<s;++n){let o=i.slice(n,n+2),a={feature:e,geometry:t,index:n,segment:o};this.rBush_.insert(Re(o),a)}}writeMultiLineStringGeometry_(e,t){let i=t.getCoordinates();for(let n=0,s=i.length;n<s;++n){let o=i[n];for(let a=0,l=o.length-1;a<l;++a){let h=o.slice(a,a+2),c={feature:e,geometry:t,depth:[n],index:a,segment:h};this.rBush_.insert(Re(h),c)}}}writePolygonGeometry_(e,t){let i=t.getCoordinates();for(let n=0,s=i.length;n<s;++n){let o=i[n];for(let a=0,l=o.length-1;a<l;++a){let h=o.slice(a,a+2),c={feature:e,geometry:t,depth:[n],index:a,segment:h};this.rBush_.insert(Re(h),c)}}}writeMultiPolygonGeometry_(e,t){let i=t.getCoordinates();for(let n=0,s=i.length;n<s;++n){let o=i[n];for(let a=0,l=o.length;a<l;++a){let h=o[a];for(let c=0,u=h.length-1;c<u;++c){let d=h.slice(c,c+2),f={feature:e,geometry:t,depth:[a,n],index:c,segment:d};this.rBush_.insert(Re(d),f)}}}}writeCircleGeometry_(e,t){let i=t.getCenter(),n={feature:e,geometry:t,index:yx,segment:[i,i]},s={feature:e,geometry:t,index:Wo,segment:[i,i]},o=[n,s];n.featureSegments=o,s.featureSegments=o,this.rBush_.insert(Ri(i),n);let a=t,l=we();if(l&&this.getMap()){let h=this.getMap().getView().getProjection();a=a.clone().transform(l,h),a=Mr(a).transform(h,l)}this.rBush_.insert(a.getExtent(),s)}writeGeometryCollectionGeometry_(e,t){let i=t.getGeometriesArray();for(let n=0;n<i.length;++n){let s=i[n],o=this.SEGMENT_WRITERS_[s.getType()];o(e,s)}}createOrUpdateVertexFeature_(e,t,i,n){let s=this.vertexFeature_;return s?s.getGeometry().setCoordinates(e):(s=new Ge(new Fe(e)),this.vertexFeature_=s,this.overlay_.getSource().addFeature(s)),s.set("features",t),s.set("geometries",i),s.set("existing",n),s}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let t;return!e.map.getView().getInteracting()&&e.type==ee.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=ee.SINGLECLICK||!this.ignoreNextSingleClick_?t=this.removePoint():t=!0),e.type==ee.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!t}findInsertVerticesAndUpdateDragSegments_(e){if(this.handlePointerAtPixel_(e),this.dragSegments_.length=0,this.featuresBeingModified_=null,!this.vertexFeature_)return;let i=this.getMap().getView().getProjection(),n=[],s=this.vertexFeature_.getGeometry().getCoordinates(),o=Re([s]),a=this.rBush_.getInExtent(o),l={};a.sort(LT);for(let h=0,c=a.length;h<c;++h){let u=a[h],d=u.segment,f=P(u.geometry),g=u.depth;if(g&&(f+="-"+g.join("-")),l[f]||(l[f]=new Array(2)),u.geometry.getType()==="Circle"&&u.index===Wo){let m=Cx(e,u,i);Qe(m,s)&&!l[f][0]&&(this.dragSegments_.push([u,0]),l[f][0]=u);continue}if(Qe(d[0],s)&&!l[f][0]){this.dragSegments_.push([u,0]),l[f][0]=u;continue}if(Qe(d[1],s)&&!l[f][1]){if(l[f][0]&&l[f][0].index===0){let m=u.geometry.getCoordinates();switch(u.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":m=m[g[1]];case"Polygon":if(u.index!==m[g[0]].length-2)continue;break;default:}}this.dragSegments_.push([u,1]),l[f][1]=u;continue}P(d)in this.vertexSegments_&&!l[f][0]&&!l[f][1]&&n.push(u)}return n}deactivateTrace_(){this.traceState_={active:!1}}updateTrace_(e){let t=this.traceState_;if(!t.active)return;if(t.targetIndex===-1){let s=e.map.getPixelFromCoordinate(t.startCoord);if(Wi(s,e.pixel)<this.pixelTolerance_)return}let i=oh(e.coordinate,t,e.map,this.pixelTolerance_);if(t.targetIndex===-1&&Math.sqrt(i.closestTargetDistance)/e.map.getView().getResolution()>this.pixelTolerance_)return;if(t.targetIndex!==i.index){if(t.targetIndex!==-1){let o=t.targets[t.targetIndex];this.removeTracedCoordinates_(o.startIndex,o.endIndex)}else for(let o of this.traceSegments_){let a=o[0],l=a.geometry,h=o[1],c=l.getCoordinates();Kf(c,l.getType(),a.depth).splice(a.index+h,1),l.setCoordinates(c),h===0&&(a.index-=1)}let s=t.targets[i.index];this.addTracedCoordinates_(s,s.startIndex,i.endIndex)}else{let s=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(s,i.endIndex)}t.targetIndex=i.index;let n=t.targets[t.targetIndex];n.endIndex=i.endIndex}getTraceCandidates_(e){let t=this.getMap(),i=this.pixelTolerance_,n=t.getCoordinateFromPixel([e.pixel[0]-i,e.pixel[1]+i]),s=t.getCoordinateFromPixel([e.pixel[0]+i,e.pixel[1]-i]),o=Re([n,s]);return this.traceSource_.getFeaturesInExtent(o)}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_(),this.traceSegments_=null;return}let t=this.getTraceCandidates_(e);if(t.length===0)return;let i=ah(e.coordinate,t);i.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:i,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){let i=e.startIndex<=e.endIndex,n=e.startIndex<=t;i===n?i&&t>e.endIndex||!i&&t<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,t):(i&&t<e.endIndex||!i&&t>e.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let i=0;if(e<t){let n=Math.ceil(e),s=Math.floor(t);s===t&&(s-=1),i=s-n+1}else{let n=Math.floor(e),s=Math.ceil(t);s===t&&(s+=1),i=n-s+1}if(i>0)for(let n of this.traceSegments_){let s=n[0],o=s.geometry,a=n[1],l=n[0].index+1;a===1&&(l-=i);let h=o.getCoordinates();Kf(h,o.getType(),s.depth).splice(l,i),o.setCoordinates(h),a===1&&(s.index-=i)}}addTracedCoordinates_(e,t,i){if(t===i)return;let n=[];if(t<i){let s=Math.ceil(t),o=Math.floor(i);o===i&&(o-=1);for(let a=s;a<=o;++a)n.push(ki(e.coordinates,a))}else{let s=Math.floor(t),o=Math.ceil(i);o===i&&(o+=1);for(let a=s;a>=o;--a)n.push(ki(e.coordinates,a))}if(n.length)for(let s of this.traceSegments_){let o=s[0],a=o.geometry,l=s[1],h=o.index+1;l===0&&n.reverse();let c=a.getCoordinates();Kf(c,a.getType(),o.depth).splice(h,0,...n),a.setCoordinates(c),l===1&&(o.index+=n.length)}}updateGeometry_(e,t){let i=t[0],n=i.depth,s,o=i.segment,a=i.geometry,l=t[1];for(;e.length<a.getStride();)e.push(o[l][e.length]);switch(a.getType()){case"Point":s=e,o[0]=e,o[1]=e;break;case"MultiPoint":s=a.getCoordinates(),s[i.index]=e,o[0]=e,o[1]=e;break;case"LineString":s=a.getCoordinates(),s[i.index+l]=e,o[l]=e;break;case"MultiLineString":s=a.getCoordinates(),s[n[0]][i.index+l]=e,o[l]=e;break;case"Polygon":{s=a.getCoordinates();let c=s[n[0]],u=i.index+l;c[u][0]===e[0]&&c[u][1]===e[1]?s=null:(c[u]=e,u===0?c[c.length-1]=e:u===c.length-1&&(c[0]=e)),o[l]=e;break}case"MultiPolygon":{s=a.getCoordinates();let c=s[n[1]][n[0]],u=i.index+l;c[u][0]===e[0]&&c[u][1]===e[1]?s=null:(c[u]=e,u===0?c[c.length-1]=e:u===c.length-1&&(c[0]=e)),o[l]=e;break}case"Circle":let h=a;if(o[0]=e,o[1]=e,i.index===yx)this.changingFeature_=!0,h.setCenter(e),this.changingFeature_=!1;else{this.changingFeature_=!0;let c=this.getMap().getView().getProjection(),u=Wi(ce(h.getCenter(),c),ce(e,c)),d=we();if(d){let f=h.clone().transform(d,c);f.setRadius(u),u=f.transform(c,d).getRadius()}h.setRadius(u),this.changingFeature_=!1}break;default:}s&&this.setGeometryCoordinates_(a,s)}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_.map(([o])=>o));let t=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],i=[],n=[],s=this.traceState_.active&&!this.traceSegments_?this.traceState_.startCoord:null;if(s){this.traceSegments_=[];for(let o of this.dragSegments_){let a=o[0];Wi(Tr(s,a.segment),s)/e.map.getView().getResolution()<1&&this.traceSegments_.push(o)}}for(let o=0,a=this.dragSegments_.length;o<a;++o){let l=this.dragSegments_[o],h=l[0],c=h.feature;i.includes(c)||i.push(c);let u=h.geometry;n.includes(u)||n.push(u),this.updateGeometry_(t,l)}this.updateTrace_(e),this.createOrUpdateVertexFeature_(t,i,n,!0)}handleDownEvent(e){if(!this.condition_(e))return!1;let t=e.coordinate,i=this.findInsertVerticesAndUpdateDragSegments_(t);if(i?.length&&this.insertVertexCondition_(e)&&(this.willModifyFeatures_(e,i),this.vertexFeature_)){let n=this.vertexFeature_.getGeometry().getCoordinates();for(let s=i.length-1;s>=0;--s)this.insertVertex_(i[s],n);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(e){for(let t=this.dragSegments_.length-1;t>=0;--t){let i=this.dragSegments_[t][0],n=i.geometry;if(n.getType()==="Circle"){let s=n,o=s.getCenter(),a=i.featureSegments[0],l=i.featureSegments[1];a.segment[0]=o,a.segment[1]=o,l.segment[0]=o,l.segment[1]=o,this.rBush_.update(Ri(o),a);let h=s,c=we();if(c){let u=e.map.getView().getProjection();h=h.clone().transform(c,u),h=Mr(h).transform(u,c)}this.rBush_.update(h.getExtent(),l)}else this.rBush_.update(Re(i.segment),i)}return this.featuresBeingModified_&&(this.toggleTraceState_(e),this.dispatchEvent(new Xo($f.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastCoordinate_=e.coordinate,this.handlePointerAtPixel_(this.lastCoordinate_)}handlePointerAtPixel_(e){let t=this.getMap(),i=t.getPixelFromCoordinate(e),n=t.getView().getProjection(),s=function(l,h){return Tx(e,l,n)-Tx(e,h,n)},o,a;if(this.hitDetection_){let l=typeof this.hitDetection_=="object"?h=>h===this.hitDetection_:void 0;t.forEachFeatureAtPixel(i,(h,c,u)=>{u&&u.getType()==="Point"&&(u=new Fe(ni(u.getCoordinates(),n)));let d=u||h.getGeometry();if(d&&d.getType()==="Point"&&h instanceof Ge&&this.features_.includes(h)){a=d;let f=h.getGeometry().getFlatCoordinates().slice(0,2);o=[{feature:h,geometry:a,segment:[f,f]}]}return!0},{layerFilter:l})}if(!o){let l=Be(Ri(e,Ex),n),h=t.getView().getResolution()*this.pixelTolerance_,c=Vt(Le(l,h,Ex),n);o=this.rBush_.getInExtent(c)}if(o&&o.length>0){let l=o.sort(s)[0],h=l.segment,c=Cx(e,l,n),u=t.getPixelFromCoordinate(c),d=Wi(i,u);if(a||d<=this.pixelTolerance_){let f={};if(f[P(h)]=!0,this.snapToPointer_||(this.delta_[0]=c[0]-e[0],this.delta_[1]=c[1]-e[1]),l.geometry.getType()==="Circle"&&l.index===Wo)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(c,[l.feature],[l.geometry],this.snappedToVertex_);else{let g=t.getPixelFromCoordinate(h[0]),m=t.getPixelFromCoordinate(h[1]),p=ei(u,g),_=ei(u,m);if(d=Math.sqrt(Math.min(p,_)),this.snappedToVertex_=d<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_)){this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null);return}this.snappedToVertex_&&(c=p>_?h[1]:h[0]),this.createOrUpdateVertexFeature_(c,[l.feature],[l.geometry],this.snappedToVertex_);let x={};x[P(l.geometry)]=!0;for(let y=1,E=o.length;y<E;++y){let T=o[y].segment;if(Qe(h[0],T[0])&&Qe(h[1],T[1])||Qe(h[0],T[1])&&Qe(h[1],T[0])){let v=P(o[y].geometry);v in x||(x[v]=!0,f[P(T)]=!0)}else break}}this.vertexSegments_=f;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,t){let i=e.segment,n=e.feature,s=e.geometry,o=e.depth,a=e.index,l;for(;t.length<s.getStride();)t.push(0);switch(s.getType()){case"MultiLineString":l=s.getCoordinates(),l[o[0]].splice(a+1,0,t);break;case"Polygon":l=s.getCoordinates(),l[o[0]].splice(a+1,0,t);break;case"MultiPolygon":l=s.getCoordinates(),l[o[1]][o[0]].splice(a+1,0,t);break;case"LineString":l=s.getCoordinates(),l.splice(a+1,0,t);break;default:return!1}this.setGeometryCoordinates_(s,l);let h=this.rBush_;h.remove(e),this.updateSegmentIndices_(s,a,o,1);let c={segment:[i[0],t],feature:n,geometry:s,depth:o,index:a};h.insert(Re(c.segment),c),this.dragSegments_.push([c,1]);let u={segment:[t,i[1]],feature:n,geometry:s,depth:o,index:a+1};return h.insert(Re(u.segment),u),this.dragSegments_.push([u,0]),!0}updatePointer_(e){return e&&this.findInsertVerticesAndUpdateDragSegments_(e),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){let e=this.vertexFeature_?.getGeometry().getCoordinates();return e?ni(e,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(i=>i.getType()==="Circle"||i.getType().endsWith("Point")))return!1;let e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Re([e])).some(({segment:i})=>Qe(i[0],e)||Qe(i[1],e))}removePoint(e){if(e&&(e=ce(e,this.getMap().getView().getProjection()),this.updatePointer_(e)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=ee.POINTERDRAG){let t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([n])=>n));let i=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Xo($f.MODIFYEND,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,i}return!1}removeVertex_(){let e=this.dragSegments_,t={},i=!1,n,s,o,a,l,h,c,u,d,f,g;for(l=e.length-1;l>=0;--l)o=e[l],f=o[0],g=P(f.feature),f.depth&&(g+="-"+f.depth.join("-")),g in t||(t[g]={}),o[1]===0?(t[g].right=f,t[g].index=f.index):o[1]==1&&(t[g].left=f,t[g].index=f.index+1);for(g in t){switch(d=t[g].right,c=t[g].left,h=t[g].index,u=h-1,c!==void 0?f=c:f=d,u<0&&(u=0),a=f.geometry,s=a.getCoordinates(),n=s,i=!1,a.getType()){case"MultiLineString":s[f.depth[0]].length>2&&(s[f.depth[0]].splice(h,1),i=!0);break;case"LineString":s.length>2&&(s.splice(h,1),i=!0);break;case"MultiPolygon":n=n[f.depth[1]];case"Polygon":n=n[f.depth[0]],n.length>4&&(h==n.length-1&&(h=0),n.splice(h,1),i=!0,h===0&&(n.pop(),n.push(n[0]),u=n.length-1));break;default:}if(i){this.setGeometryCoordinates_(a,s);let m=[];if(c!==void 0&&(this.rBush_.remove(c),m.push(c.segment[0])),d!==void 0&&(this.rBush_.remove(d),m.push(d.segment[1])),c!==void 0&&d!==void 0){let p={depth:f.depth,feature:f.feature,geometry:f.geometry,index:u,segment:m};this.rBush_.insert(Re(p.segment),p)}this.updateSegmentIndices_(a,h,f.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return i}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(i=>i.getType()==="Circle"||i.getType().endsWith("Point")))return!1;let e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Re([e])).some(({segment:i})=>!(Qe(i[0],e)||Qe(i[1],e)))}insertPoint(e){let t=e?ce(e,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return t?this.findInsertVerticesAndUpdateDragSegments_(t).reduce((n,s)=>n||this.insertVertex_(s,t),!1):!1}setGeometryCoordinates_(e,t){this.changingFeature_=!0,e.setCoordinates(t),this.changingFeature_=!1}updateSegmentIndices_(e,t,i,n){this.rBush_.forEachInExtent(e.getExtent(),function(s){s.geometry===e&&(i===void 0||s.depth===void 0||Ve(s.depth,i))&&s.index>t&&(s.index+=n)})}disposeInternal(){if(super.disposeInternal(),this.featuresCollection_){this.featuresCollection_.removeEventListener(fe.ADD,this.handleExternalCollectionAdd_),this.featuresCollection_.removeEventListener(fe.REMOVE,this.handleExternalCollectionRemove_);for(let e of this.featuresCollection_.getArray())e.removeEventListener(L.CHANGE,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&e.removeEventListener(He.PROPERTYCHANGE,this.handleFeatureChange_)}else if(this.source_){this.source_.removeEventListener(Se.ADDFEATURE,this.handleSourceAdd_),this.source_.removeEventListener(Se.REMOVEFEATURE,this.handleSourceRemove_);for(let e of this.source_.getFeatures())e.removeEventListener(L.CHANGE,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&e.removeEventListener(He.PROPERTYCHANGE,this.handleFeatureChange_)}}};function LT(r,e){return r.index-e.index}function Tx(r,e,t){let i=e.geometry;if(i.getType()==="Circle"){let s=i;if(e.index===Wo){let o=we();o&&(s=s.clone().transform(o,t));let a=ei(s.getCenter(),ce(r,t)),l=Math.sqrt(a)-s.getRadius();return l*l}}let n=ce(r,t);return _s[0]=ce(e.segment[0],t),_s[1]=ce(e.segment[1],t),Fg(n,_s)}function Cx(r,e,t){let i=e.geometry;if(i.getType()==="Circle"&&e.index===Wo){let s=i,o=we();return o&&(s=s.clone().transform(o,t)),ni(s.getClosestPoint(ce(r,t)),t)}let n=ce(r,t);return _s[0]=ce(e.segment[0],t),_s[1]=ce(e.segment[1],t),ni(Tr(n,_s),t)}function bT(){let r=Wr();return function(e,t){return r.Point}}var ch=Hf;var uh={SELECT:"select"},xs=class extends ye{constructor(e,t,i,n){super(e),this.selected=t,this.deselected=i,this.mapBrowserEvent=n}},dh={},Zf=class r extends si{constructor(e){super(),this.on,this.once,this.un,e=e||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=e.condition?e.condition:Va,this.addCondition_=e.addCondition?e.addCondition:Qn,this.removeCondition_=e.removeCondition?e.removeCondition:Qn,this.toggleCondition_=e.toggleCondition?e.toggleCondition:Zi,this.multi_=e.multi?e.multi:!1,this.filter_=e.filter?e.filter:xt,this.hitTolerance_=e.hitTolerance?e.hitTolerance:0,this.style_=e.style!==void 0?e.style:IT(),this.features_=e.features||new Ce;let t;if(e.layers)if(typeof e.layers=="function")t=e.layers;else{let i=e.layers;t=function(n){return i.includes(n)}}else t=xt;this.layerFilter_=t,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(e,t){this.featureLayerAssociation_[P(e)]=t}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(e){return this.featureLayerAssociation_[P(e)]}setHitTolerance(e){this.hitTolerance_=e}setMap(e){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(e),e?(this.features_.addEventListener(fe.ADD,this.boundAddFeature_),this.features_.addEventListener(fe.REMOVE,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(fe.ADD,this.boundAddFeature_),this.features_.removeEventListener(fe.REMOVE,this.boundRemoveFeature_))}addFeature_(e){let t=e.element;if(this.style_&&this.applySelectedStyle_(t),!this.getLayer(t)){let i=this.findLayerOfFeature_(t);i&&this.addFeatureLayerAssociation_(t,i)}}removeFeature_(e){this.style_&&this.restorePreviousStyle_(e.element),this.removeFeatureLayerAssociation_(e.element)}findLayerOfFeature_(e){return this.getMap().getAllLayers().find(function(i){if(i instanceof gt&&i.getSource()&&i.getSource().hasFeature(e))return i})}getStyle(){return this.style_}applySelectedStyle_(e){let t=P(e);t in dh||(dh[t]=e.getStyle()),e.setStyle(this.style_)}restorePreviousStyle_(e){let t=this.getMap().getInteractions().getArray();for(let n=t.length-1;n>=0;--n){let s=t[n];if(s!==this&&s instanceof r&&s.getStyle()&&s.getFeatures().getArray().lastIndexOf(e)!==-1){e.setStyle(s.getStyle());return}}let i=P(e);e.setStyle(dh[i]),delete dh[i]}removeFeatureLayerAssociation_(e){delete this.featureLayerAssociation_[P(e)]}selectFeature(e){let t=this.findLayerOfFeature_(e);if(!this.layerFilter_(t)||!this.filter_(e,t))return!1;let i=this.getFeatures();return i.getArray().includes(e)?!1:(this.addFeatureLayerAssociation_(e,t),i.push(e),this.dispatchEvent(new xs(uh.SELECT,[e],[],void 0)),!0)}deselectFeature(e){let t=this.getFeatures(),i=t.getArray().indexOf(e);return i===-1?!1:(t.removeAt(i),this.dispatchEvent(new xs(uh.SELECT,[],[e],void 0)),!0)}toggleFeature(e){this.deselectFeature(e)||this.selectFeature(e)}clearSelection(){let e=this.getFeatures();if(e.getLength()!==0){let t=e.getArray().slice();e.clear(),this.dispatchEvent(new xs(uh.SELECT,[],t,void 0))}}handleEvent(e){if(!this.condition_(e))return!0;let t=this.addCondition_(e),i=this.removeCondition_(e),n=this.toggleCondition_(e),s=!t&&!i&&!n,o=e.map,a=this.getFeatures(),l=[],h=[];if(s){o.forEachFeatureAtPixel(e.pixel,(c,u)=>{if(!(!(c instanceof Ge)||!this.filter_(c,u)))return this.addFeatureLayerAssociation_(c,u),h.push(c),!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let c=a.getLength()-1;c>=0;--c){let u=a.item(c),d=h.indexOf(u);d===-1?(a.removeAt(c),l.push(u)):h.splice(d,1)}h.length!==0&&a.extend(h)}else{o.forEachFeatureAtPixel(e.pixel,(c,u)=>{if(!(c instanceof Ge)||!this.filter_(c,u))return;let d=a.getArray().includes(c);return d&&(i||n)?l.push(c):!d&&(t||n)&&(this.addFeatureLayerAssociation_(c,u),h.push(c)),!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let c=l.length-1;c>=0;--c)a.remove(l[c]);a.extend(h)}return(h.length>0||l.length>0)&&this.dispatchEvent(new xs(uh.SELECT,h,l,e)),!0}};function IT(){let r=Wr();return je(r.Polygon,r.LineString),je(r.GeometryCollection,r.LineString),function(e){return e.getGeometry()?r[e.getGeometry().getType()]:null}}var qf=Zf;var fh={SNAP:"snap",UNSNAP:"unsnap"},ys=class extends ye{constructor(e,t){super(e),this.vertex=t.vertex,this.vertexPixel=t.vertexPixel,this.feature=t.feature,this.segment=t.segment}};var Sx={Circle(r,e){let t=r,i=we();i&&(t=t.clone().transform(i,e));let n=Mr(t);return i&&n.transform(e,i),Sx.Polygon(n)},GeometryCollection(r,e){let t=[],i=r.getGeometriesArray();for(let n=0;n<i.length;++n){let s=this[i[n].getType()];s&&t.push(s(i[n],e))}return t.flat()},LineString(r){let e=[],t=r.getFlatCoordinates(),i=r.getStride();for(let n=0,s=t.length-i;n<s;n+=i)e.push([t.slice(n,n+2),t.slice(n+i,n+i+2)]);return e},MultiLineString(r){let e=[],t=r.getFlatCoordinates(),i=r.getStride(),n=r.getEnds(),s=0;for(let o=0,a=n.length;o<a;++o){let l=n[o];for(let h=s,c=l-i;h<c;h+=i)e.push([t.slice(h,h+2),t.slice(h+i,h+i+2)]);s=l}return e},MultiPoint(r){let e=[],t=r.getFlatCoordinates(),i=r.getStride();for(let n=0,s=t.length;n<s;n+=i)e.push([t.slice(n,n+2)]);return e},MultiPolygon(r){let e=[],t=r.getFlatCoordinates(),i=r.getStride(),n=r.getEndss(),s=0;for(let o=0,a=n.length;o<a;++o){let l=n[o];for(let h=0,c=l.length;h<c;++h){let u=l[h];for(let d=s,f=u-i;d<f;d+=i)e.push([t.slice(d,d+2),t.slice(d+i,d+i+2)]);s=u}}return e},Point(r){return[[r.getFlatCoordinates().slice(0,2)]]},Polygon(r){let e=[],t=r.getFlatCoordinates(),i=r.getStride(),n=r.getEnds(),s=0;for(let o=0,a=n.length;o<a;++o){let l=n[o];for(let h=s,c=l-i;h<c;h+=i)e.push([t.slice(h,h+2),t.slice(h+i,h+i+2)]);s=l}return e}};function vx(r){return r.feature?r.feature:r.element?r.element:null}var Jf=[],gn=[],Es=[],Qf=class extends ot{constructor(e){e=e||{},super({handleDownEvent:xt,stopDown:Ot}),this.on,this.once,this.un,this.source_=e.source?e.source:null,this.vertex_=e.vertex!==void 0?e.vertex:!0,this.edge_=e.edge!==void 0?e.edge:!0,this.intersection_=e.intersection!==void 0?e.intersection:!1,this.features_=e.features?e.features:null,this.featuresListenerKeys_=[],this.featureChangeListenerKeys_={},this.indexedFeaturesExtents_={},this.pendingFeatures_={},this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.rBush_=new fr,this.snapped_=null,this.segmenters_=Object.assign({},Sx,e.segmenters)}addFeature(e,t){t=t!==void 0?t:!0;let i=P(e),n=e.getGeometry();if(n){let s=this.segmenters_[n.getType()];if(s){this.indexedFeaturesExtents_[i]=n.getExtent(me());let o=s.call(this.segmenters_,n,this.getMap().getView().getProjection()),a=o.length;for(let l=0;l<a;++l){let h=o[l];gn[l]=Re(h),Es[l]={feature:e,segment:h}}if(this.intersection_)for(let l=0,h=o.length;l<h;++l){let c=o[l];if(c.length===1)continue;let u=gn[l];for(let f=0,g=l-1;f<g;++f){let m=o[f];if(!te(u,gn[f]))continue;let p=cc(c,m);if(!p)continue;let _=[p];gn[a]=Re(_),Es[a++]={feature:e,intersectionFeature:e,segment:_}}let d=this.rBush_.getInExtent(gn[l]);for(let f=0,g=d.length;f<g;++f){let m=d[f].segment;if(m.length===1)continue;let p=cc(c,m);if(!p)continue;let _=[p];gn[a]=Re(_),Es[a++]={feature:e,intersectionFeature:d[f].feature,segment:_}}}a===1?this.rBush_.insert(gn[0],Es[0]):(gn.length=a,Es.length=a,this.rBush_.load(gn,Es))}}t&&(this.featureChangeListenerKeys_[i]&&K(this.featureChangeListenerKeys_[i]),this.featureChangeListenerKeys_[i]=k(e,L.CHANGE,this.handleFeatureChange_,this))}getFeatures_(){let e;return this.features_?e=this.features_:this.source_&&(e=this.source_.getFeatures()),e}areSnapDataEqual_(e,t){return e.segment===t.segment&&e.feature===t.feature}handleEvent(e){let t=this.snapTo(e.pixel,e.coordinate,e.map);return t?(e.coordinate=t.vertex.slice(0,2),e.pixel=t.vertexPixel,this.snapped_&&!this.areSnapDataEqual_(this.snapped_,t)&&this.dispatchEvent(new ys(fh.UNSNAP,this.snapped_)),this.snapped_={vertex:e.coordinate,vertexPixel:e.pixel,feature:t.feature,segment:t.segment},this.dispatchEvent(new ys(fh.SNAP,this.snapped_))):this.snapped_&&(this.dispatchEvent(new ys(fh.UNSNAP,this.snapped_)),this.snapped_=null),super.handleEvent(e)}handleFeatureAdd_(e){let t=vx(e);t&&this.addFeature(t)}handleFeatureRemove_(e){let t=vx(e);t&&(this.removeFeature(t),delete this.pendingFeatures_[P(t)])}handleFeatureChange_(e){let t=e.target;this.handlingDownUpSequence?this.pendingFeatures_[P(t)]=t:this.updateFeature_(t)}handleUpEvent(e){let t=Object.values(this.pendingFeatures_);if(t.length){for(let i of t)this.updateFeature_(i);Dt(this.pendingFeatures_)}return!1}removeFeature(e,t){let i=t!==void 0?t:!0,n=P(e),s=this.indexedFeaturesExtents_[n];if(s){let o=this.rBush_;o.getInExtent(s).forEach(a=>{(e===a.feature||e===a.intersectionFeature)&&o.remove(a)})}i&&(K(this.featureChangeListenerKeys_[n]),delete this.featureChangeListenerKeys_[n])}setMap(e){let t=this.getMap(),i=this.featuresListenerKeys_,n=this.getFeatures_();if(Array.isArray(n)||(n=n.getArray()),t&&(i.forEach(K),i.length=0,this.rBush_.clear(),Object.values(this.featureChangeListenerKeys_).forEach(K),this.featureChangeListenerKeys_={}),super.setMap(e),e){this.features_?i.push(k(this.features_,fe.ADD,this.handleFeatureAdd_,this),k(this.features_,fe.REMOVE,this.handleFeatureRemove_,this)):this.source_&&i.push(k(this.source_,Se.ADDFEATURE,this.handleFeatureAdd_,this),k(this.source_,Se.REMOVEFEATURE,this.handleFeatureRemove_,this));for(let s of n)this.addFeature(s)}}snapTo(e,t,i){let n=i.getView().getProjection(),s=ce(t,n),o=Vt(Le(Re([s]),i.getView().getResolution()*this.pixelTolerance_),n),a=this.rBush_.getInExtent(o),l=a.length;if(l===0)return null;let h,c=1/0,u,d=null,f=this.pixelTolerance_*this.pixelTolerance_,g=()=>{if(!h)return null;let m=i.getPixelFromCoordinate(h);return ei(e,m)>f?null:{vertex:h,vertexPixel:[Math.round(m[0]),Math.round(m[1])],feature:u,segment:d}};if(this.vertex_||this.intersection_){for(let p=0;p<l;++p){let _=a[p];if(_.feature.getGeometry().getType()!=="Circle")for(let x of _.segment){let y=ce(x,n),E=ei(s,y);E<c&&(this.intersection_&&_.intersectionFeature||this.vertex_&&!_.intersectionFeature)&&(h=x,c=E,u=_.feature)}}let m=g();if(m)return m}if(this.edge_){for(let p=0;p<l;++p){let _=null,x=a[p];if(x.feature.getGeometry().getType()==="Circle"){let y=x.feature.getGeometry(),E=we();E&&(y=y.clone().transform(E,n)),_=bg(s,y)}else{let[y,E]=x.segment;E&&(Jf[0]=ce(y,n),Jf[1]=ce(E,n),_=Tr(s,Jf))}if(_){let y=ei(s,_);y<c&&(h=ni(_,n),d=x.feature.getGeometry().getType()==="Circle"?null:x.segment,c=y,u=x.feature)}}let m=g();if(m)return m}return null}updateFeature_(e){this.removeFeature(e,!1),this.addFeature(e,!1)}},eg=Qf;function Rx(r,e,t){let i=[],n=r(0),s=r(1),o=e(n),a=e(s),l=[s,n],h=[a,o],c=[1,0],u={},d=1e5,f,g,m,p,_,x;for(;--d>0&&c.length>0;)m=c.pop(),n=l.pop(),o=h.pop(),x=m.toString(),x in u||(i.push(o[0],o[1]),u[x]=!0),p=c.pop(),s=l.pop(),a=h.pop(),_=(m+p)/2,f=r(_),g=e(f),sa(g[0],g[1],o[0],o[1],a[0],a[1])<t?(i.push(a[0],a[1]),x=p.toString(),u[x]=!0):(c.push(p,_,_,m),h.push(a,g,g,o),l.push(s,f,f,n));return i}function wx(r,e,t,i,n){let s=$("EPSG:4326");return Rx(function(o){return[r,e+(t-e)*o]},ct(s,i),n)}function Px(r,e,t,i,n){let s=$("EPSG:4326");return Rx(function(o){return[e+(t-e)*o,r]},ct(s,i),n)}function Lx(r){if(!(r.context instanceof CanvasRenderingContext2D))throw new Error("Only works for render events from Canvas 2D layers");let e=r.inversePixelTransform[0],t=r.inversePixelTransform[1],i=Math.sqrt(e*e+t*t),n=r.frameState,s=Sn(r.inversePixelTransform.slice(),n.coordinateToPixelTransform),o=lr(n.viewState.resolution,i),a,l=we();return l&&(a=zt(l,n.viewState.projection)),new Tl(r.context,i,n.extent,s,n.viewState.rotation,o,a)}var FT=new Te({color:"rgba(0,0,0,0.2)"}),MT=[90,45,30,20,10,5,2,1,30/60,20/60,10/60,5/60,2/60,1/60,30/3600,20/3600,10/3600,5/3600,2/3600,1/3600],tg=class extends gt{constructor(e){e=e||{};let t=Object.assign({updateWhileAnimating:!0,updateWhileInteracting:!0,renderBuffer:0},e);delete t.maxLines,delete t.strokeStyle,delete t.targetSize,delete t.showLabels,delete t.lonLabelFormatter,delete t.latLabelFormatter,delete t.lonLabelPosition,delete t.latLabelPosition,delete t.lonLabelStyle,delete t.latLabelStyle,delete t.intervals,super(t),this.projection_=null,this.maxLat_=1/0,this.maxLon_=1/0,this.minLat_=-1/0,this.minLon_=-1/0,this.maxX_=1/0,this.maxY_=1/0,this.minX_=-1/0,this.minY_=-1/0,this.targetSize_=e.targetSize!==void 0?e.targetSize:100,this.maxLines_=e.maxLines!==void 0?e.maxLines:100,this.meridians_=[],this.parallels_=[],this.strokeStyle_=e.strokeStyle!==void 0?e.strokeStyle:FT,this.fromLonLatTransform_=void 0,this.toLonLatTransform_=void 0,this.projectionCenterLonLat_=null,this.bottomLeft_=null,this.bottomRight_=null,this.topLeft_=null,this.topRight_=null,this.meridiansLabels_=null,this.parallelsLabels_=null,e.showLabels&&(this.lonLabelFormatter_=e.lonLabelFormatter==null?Bh.bind(this,"EW"):e.lonLabelFormatter,this.latLabelFormatter_=e.latLabelFormatter==null?Bh.bind(this,"NS"):e.latLabelFormatter,this.lonLabelPosition_=e.lonLabelPosition==null?0:e.lonLabelPosition,this.latLabelPosition_=e.latLabelPosition==null?1:e.latLabelPosition,this.lonLabelStyleBase_=new ze({text:e.lonLabelStyle!==void 0?e.lonLabelStyle.clone():new nn({font:"12px Calibri,sans-serif",textBaseline:"bottom",fill:new _e({color:"rgba(0,0,0,1)"}),stroke:new Te({color:"rgba(255,255,255,1)",width:3})})}),this.lonLabelStyle_=i=>{let n=i.get("graticule_label");return this.lonLabelStyleBase_.getText().setText(n),this.lonLabelStyleBase_},this.latLabelStyleBase_=new ze({text:e.latLabelStyle!==void 0?e.latLabelStyle.clone():new nn({font:"12px Calibri,sans-serif",textAlign:"right",fill:new _e({color:"rgba(0,0,0,1)"}),stroke:new Te({color:"rgba(255,255,255,1)",width:3})})}),this.latLabelStyle_=i=>{let n=i.get("graticule_label");return this.latLabelStyleBase_.getText().setText(n),this.latLabelStyleBase_},this.meridiansLabels_=[],this.parallelsLabels_=[],this.addEventListener(ve.POSTRENDER,this.drawLabels_.bind(this))),this.intervals_=e.intervals!==void 0?e.intervals:MT,this.setSource(new mt({loader:this.loaderFunction.bind(this),strategy:this.strategyFunction.bind(this),features:new Ce,overlaps:!1,useSpatialIndex:!1,wrapX:e.wrapX})),this.featurePool_=[],this.lineStyle_=new ze({stroke:this.strokeStyle_}),this.loadedExtent_=null,this.renderedExtent_=null,this.renderedResolution_=null,this.setRenderOrder(null)}strategyFunction(e,t){let i=e.slice();return this.projection_&&this.getSource().getWrapX()&&As(i,this.projection_),this.loadedExtent_&&(Sg(this.loadedExtent_,i,t)?i=this.loadedExtent_.slice():this.getSource().removeLoadedExtent(this.loadedExtent_)),[i]}loaderFunction(e,t,i){this.loadedExtent_=e;let n=this.getSource(),s=this.getExtent()||[-1/0,-1/0,1/0,1/0],o=Xe(s,e);if(this.renderedExtent_&&qe(this.renderedExtent_,o)&&this.renderedResolution_===t||(this.renderedExtent_=o,this.renderedResolution_=t,yt(o)))return;let a=be(o),l=t*t/4;(!this.projection_||!Ie(this.projection_,i))&&this.updateProjectionInfo_(i),this.createGraticule_(o,a,t,l);let c=this.meridians_.length+this.parallels_.length;this.meridiansLabels_&&(c+=this.meridians_.length),this.parallelsLabels_&&(c+=this.parallels_.length);let u;for(;c>this.featurePool_.length;)u=new Ge,this.featurePool_.push(u);let d=n.getFeaturesCollection();d.clear();let f=0,g,m;for(g=0,m=this.meridians_.length;g<m;++g)u=this.featurePool_[f++],u.setGeometry(this.meridians_[g]),u.setStyle(this.lineStyle_),d.push(u);for(g=0,m=this.parallels_.length;g<m;++g)u=this.featurePool_[f++],u.setGeometry(this.parallels_[g]),u.setStyle(this.lineStyle_),d.push(u)}addMeridian_(e,t,i,n,s,o){let a=this.getMeridian_(e,t,i,n,o);if(te(a.getExtent(),s)){if(this.meridiansLabels_){let l=this.lonLabelFormatter_(e);o in this.meridiansLabels_?this.meridiansLabels_[o].text=l:this.meridiansLabels_[o]={geom:new Fe([]),text:l}}this.meridians_[o++]=a}return o}addParallel_(e,t,i,n,s,o){let a=this.getParallel_(e,t,i,n,o);if(te(a.getExtent(),s)){if(this.parallelsLabels_){let l=this.latLabelFormatter_(e);o in this.parallelsLabels_?this.parallelsLabels_[o].text=l:this.parallelsLabels_[o]={geom:new Fe([]),text:l}}this.parallels_[o++]=a}return o}drawLabels_(e){let t=e.frameState.viewState.rotation,i=e.frameState.viewState.resolution,n=e.frameState.size,s=e.frameState.extent,o=be(s),a=s;if(t){let g=n[0]*i,m=n[1]*i;a=[o[0]-g/2,o[1]-m/2,o[0]+g/2,o[1]+m/2]}let l=0,h=0,c=this.latLabelPosition_<.5,u=this.projection_.getExtent(),d=z(u);if(this.getSource().getWrapX()&&this.projection_.canWrapX()&&!Ue(u,s)){l=Math.floor((s[0]-u[0])/d),h=Math.ceil((s[2]-u[2])/d);let g=Math.abs(t)>Math.PI/2;c=c!==g}let f=Lx(e);for(let g=l;g<=h;++g){let m=this.meridians_.length+this.parallels_.length,p,_,x,y;if(this.meridiansLabels_)for(_=0,x=this.meridiansLabels_.length;_<x;++_){let E=this.meridians_[_];if(!t&&g===0)y=this.getMeridianPoint_(E,s,_);else{let T=E.clone();T.translate(g*d,0),T.rotate(-t,o),y=this.getMeridianPoint_(T,a,_),y.rotate(t,o)}p=this.featurePool_[m++],p.setGeometry(y),p.set("graticule_label",this.meridiansLabels_[_].text),f.drawFeature(p,this.lonLabelStyle_(p))}if(this.parallelsLabels_&&(g===l&&c||g===h&&!c))for(_=0,x=this.parallels_.length;_<x;++_){let E=this.parallels_[_];if(!t&&g===0)y=this.getParallelPoint_(E,s,_);else{let T=E.clone();T.translate(g*d,0),T.rotate(-t,o),y=this.getParallelPoint_(T,a,_),y.rotate(t,o)}p=this.featurePool_[m++],p.setGeometry(y),p.set("graticule_label",this.parallelsLabels_[_].text),f.drawFeature(p,this.latLabelStyle_(p))}}}createGraticule_(e,t,i,n){let s=this.getInterval_(i);if(s==-1){this.meridians_.length=0,this.parallels_.length=0,this.meridiansLabels_&&(this.meridiansLabels_.length=0),this.parallelsLabels_&&(this.parallelsLabels_.length=0);return}let o=!1,a=this.projection_.getExtent(),l=z(a);this.getSource().getWrapX()&&this.projection_.canWrapX()&&!Ue(a,e)&&(z(e)>=l?(e[0]=a[0],e[2]=a[2]):o=!0);let h=[B(t[0],this.minX_,this.maxX_),B(t[1],this.minY_,this.maxY_)],c=this.toLonLatTransform_(h);isNaN(c[1])&&(c[1]=Math.abs(this.maxLat_)>=Math.abs(this.minLat_)?this.maxLat_:this.minLat_);let u=B(c[0],this.minLon_,this.maxLon_),d=B(c[1],this.minLat_,this.maxLat_),f=this.maxLines_,g,m,p,_,x=e;o||(x=[B(e[0],this.minX_,this.maxX_),B(e[1],this.minY_,this.maxY_),B(e[2],this.minX_,this.maxX_),B(e[3],this.minY_,this.maxY_)]);let y=Ms(x,this.toLonLatTransform_,void 0,8),E=y[3],T=y[2],v=y[1],S=y[0];if(o||(rt(x,this.bottomLeft_)&&(S=this.minLon_,v=this.minLat_),rt(x,this.bottomRight_)&&(T=this.maxLon_,v=this.minLat_),rt(x,this.topLeft_)&&(S=this.minLon_,E=this.maxLat_),rt(x,this.topRight_)&&(T=this.maxLon_,E=this.maxLat_),E=B(E,d,this.maxLat_),T=B(T,u,this.maxLon_),v=B(v,this.minLat_,d),S=B(S,this.minLon_,u)),u=Math.floor(u/s)*s,_=B(u,this.minLon_,this.maxLon_),m=this.addMeridian_(_,v,E,n,e,0),g=0,o)for(;(_-=s)>=S&&g++<f;)m=this.addMeridian_(_,v,E,n,e,m);else for(;_!=this.minLon_&&g++<f;)_=Math.max(_-s,this.minLon_),m=this.addMeridian_(_,v,E,n,e,m);if(_=B(u,this.minLon_,this.maxLon_),g=0,o)for(;(_+=s)<=T&&g++<f;)m=this.addMeridian_(_,v,E,n,e,m);else for(;_!=this.maxLon_&&g++<f;)_=Math.min(_+s,this.maxLon_),m=this.addMeridian_(_,v,E,n,e,m);for(this.meridians_.length=m,this.meridiansLabels_&&(this.meridiansLabels_.length=m),d=Math.floor(d/s)*s,p=B(d,this.minLat_,this.maxLat_),m=this.addParallel_(p,S,T,n,e,0),g=0;p!=this.minLat_&&g++<f;)p=Math.max(p-s,this.minLat_),m=this.addParallel_(p,S,T,n,e,m);for(p=B(d,this.minLat_,this.maxLat_),g=0;p!=this.maxLat_&&g++<f;)p=Math.min(p+s,this.maxLat_),m=this.addParallel_(p,S,T,n,e,m);this.parallels_.length=m,this.parallelsLabels_&&(this.parallelsLabels_.length=m)}getInterval_(e){let t=this.projectionCenterLonLat_[0],i=this.projectionCenterLonLat_[1],n=-1,s=Math.pow(this.targetSize_*e,2),o=[],a=[];for(let l=0,h=this.intervals_.length;l<h;++l){let c=B(this.intervals_[l]/2,0,90),u=B(i,-90+c,90-c);if(o[0]=t-c,o[1]=u-c,a[0]=t+c,a[1]=u+c,this.fromLonLatTransform_(o,o),this.fromLonLatTransform_(a,a),Math.pow(a[0]-o[0],2)+Math.pow(a[1]-o[1],2)<=s)break;n=this.intervals_[l]}return n}getMeridian_(e,t,i,n,s){let o=wx(e,t,i,this.projection_,n),a=this.meridians_[s];return a?(a.setFlatCoordinates("XY",o),a.changed()):(a=new Ke(o,"XY"),this.meridians_[s]=a),a}getMeridianPoint_(e,t,i){let n=e.getFlatCoordinates(),s=1,o=n.length-1;n[s]>n[o]&&(s=o,o=1);let a=Math.max(t[1],n[s]),l=Math.min(t[3],n[o]),h=B(t[1]+Math.abs(t[1]-t[3])*this.lonLabelPosition_,a,l),u=[n[s-1]+(n[o-1]-n[s-1])*(h-n[s])/(n[o]-n[s]),h],d=this.meridiansLabels_[i].geom;return d.setCoordinates(u),d}getMeridians(){return this.meridians_}getParallel_(e,t,i,n,s){let o=Px(e,t,i,this.projection_,n),a=this.parallels_[s];return a?(a.setFlatCoordinates("XY",o),a.changed()):a=new Ke(o,"XY"),a}getParallelPoint_(e,t,i){let n=e.getFlatCoordinates(),s=0,o=n.length-2;n[s]>n[o]&&(s=o,o=0);let a=Math.max(t[0],n[s]),l=Math.min(t[2],n[o]),h=B(t[0]+Math.abs(t[0]-t[2])*this.latLabelPosition_,a,l),c=n[s+1]+(n[o+1]-n[s+1])*(h-n[s])/(n[o]-n[s]),u=[h,c],d=this.parallelsLabels_[i].geom;return d.setCoordinates(u),d}getParallels(){return this.parallels_}updateProjectionInfo_(e){let t=$("EPSG:4326"),i=e.getWorldExtent();this.maxLat_=i[3],this.maxLon_=i[2],this.minLat_=i[1],this.minLon_=i[0];let n=ct(e,t);if(this.minLon_<this.maxLon_)this.toLonLatTransform_=n;else{let o=this.minLon_+this.maxLon_/2;this.maxLon_+=360,this.toLonLatTransform_=function(a,l,h){h=h||2;let c=n(a,l,h);for(let u=0,d=c.length;u<d;u+=h)c[u]<o&&(c[u]+=360);return c}}this.fromLonLatTransform_=ct(t,e);let s=Ms([this.minLon_,this.minLat_,this.maxLon_,this.maxLat_],this.fromLonLatTransform_,void 0,8);this.minX_=s[0],this.maxX_=s[2],this.minY_=s[1],this.maxY_=s[3],this.bottomLeft_=this.fromLonLatTransform_([this.minLon_,this.minLat_]),this.bottomRight_=this.fromLonLatTransform_([this.maxLon_,this.minLat_]),this.topLeft_=this.fromLonLatTransform_([this.minLon_,this.maxLat_]),this.topRight_=this.fromLonLatTransform_([this.maxLon_,this.maxLat_]),this.projectionCenterLonLat_=this.toLonLatTransform_(be(e.getExtent())),isNaN(this.projectionCenterLonLat_[1])&&(this.projectionCenterLonLat_[1]=Math.abs(this.maxLat_)>=Math.abs(this.minLat_)?this.maxLat_:this.minLat_),this.projection_=e}},bx=tg;var gh=class{model;el;map=null;mapContainer=null;lastProcessedCallId=0;pendingCalls=[];eventQueue=[];isMapReady=!1;methodHandlers=new Map;modelListeners=[];constructor(e,t){this.model=e,this.el=t}createMapContainer(){let e=this.model.get("width")||"100%",t=this.model.get("height")||"400px";this.el.style.width="100%",this.el.style.display="block",t.endsWith("%")&&(this.el.style.height="100%");let i=document.createElement("div");return i.style.width=e,i.style.height=t,i.style.position="relative",i.style.minWidth="200px",this.el.appendChild(i),this.mapContainer=i,i}setupModelListeners(){let e=()=>this.processJsCalls(),t=()=>this.onCenterChange(),i=()=>this.onZoomChange(),n=()=>this.onStyleChange();this.model.on("change:_js_calls",e),this.model.on("change:center",t),this.model.on("change:zoom",i),this.model.on("change:style",n),this.modelListeners.push(()=>this.model.off("change:_js_calls",e),()=>this.model.off("change:center",t),()=>this.model.off("change:zoom",i),()=>this.model.off("change:style",n))}removeModelListeners(){this.modelListeners.forEach(e=>e()),this.modelListeners=[]}registerMethod(e,t){this.methodHandlers.set(e,t)}executeMethod(e,t,i){let n=this.methodHandlers.get(e);if(n)try{n(t,i)}catch(s){console.error(`Error executing method ${e}:`,s)}else console.warn(`Unknown method: ${e}`)}processJsCalls(){let t=(this.model.get("_js_calls")||[]).filter(i=>i.id>this.lastProcessedCallId);for(let i of t)this.isMapReady?this.executeMethod(i.method,i.args,i.kwargs):this.pendingCalls.push(i),this.lastProcessedCallId=i.id}processPendingCalls(){for(let e of this.pendingCalls)this.executeMethod(e.method,e.args,e.kwargs);this.pendingCalls=[]}sendEvent(e,t){let i={type:e,data:t,timestamp:Date.now()};this.eventQueue.push(i),this.model.set("_js_events",[...this.eventQueue]),this.model.save_changes()}restoreState(){let e=this.model.get("_sources")||{};for(let[l,h]of Object.entries(e))this.executeMethod("addSource",[l],h);let t=new Set(["fill","line","symbol","circle","heatmap","fill-extrusion","raster","hillshade","color-relief","background"]),i=this.model.get("_layers")||{},n=Object.entries(i).filter(([,l])=>t.has(l.type)),s=n.filter(([l,h])=>l.startsWith("basemap-")||h.type==="raster"),o=n.filter(([l,h])=>!(l.startsWith("basemap-")||h.type==="raster")),a=[...s,...o];for(let[l,h]of a)this.executeMethod("addLayer",[],h)}getMap(){return this.map}getIsMapReady(){return this.isMapReady}getModel(){return this.model}};var mh=class{model;constructor(e){this.model=e}addLayer(e,t){let i=this.model.get("_layers")||{},n={id:t.id,type:t.type,source:t.source,paint:t.paint,layout:t.layout,visible:!0,opacity:1};this.model.set("_layers",{...i,[e]:n}),this.model.save_changes()}removeLayer(e){let t={...this.model.get("_layers")};delete t[e],this.model.set("_layers",t),this.model.save_changes()}setLayerVisibility(e,t){let i={...this.model.get("_layers")};i[e]&&(i[e]={...i[e],visible:t},this.model.set("_layers",i),this.model.save_changes())}setLayerOpacity(e,t){let i={...this.model.get("_layers")};i[e]&&(i[e]={...i[e],opacity:t},this.model.set("_layers",i),this.model.save_changes())}setLayerFilter(e,t){let i={...this.model.get("_layers")};if(i[e]){let{filter:n,...s}=i[e];i[e]=t?{...s,filter:t}:{...s},this.model.set("_layers",i),this.model.save_changes()}}getLayer(e){return this.model.get("_layers")?.[e]}getLayers(){return this.model.get("_layers")||{}}addSource(e,t){let i=this.model.get("_sources")||{},n={type:t.type,data:t.data,url:t.url,urls:t.urls,tiles:t.tiles,tileSize:t.tileSize,attribution:t.attribution,coordinates:t.coordinates};this.model.set("_sources",{...i,[e]:n}),this.model.save_changes()}removeSource(e){let t={...this.model.get("_sources")};delete t[e],this.model.set("_sources",t),this.model.save_changes()}getSource(e){return this.model.get("_sources")?.[e]}getSources(){return this.model.get("_sources")||{}}addControl(e,t,i,n){let s=this.model.get("_controls")||{},o={type:t,position:i,options:n};this.model.set("_controls",{...s,[e]:o}),this.model.save_changes()}removeControl(e){let t={...this.model.get("_controls")};delete t[e],this.model.set("_controls",t),this.model.save_changes()}getControl(e){return this.model.get("_controls")?.[e]}getControls(){return this.model.get("_controls")||{}}};var ph=class extends gh{stateManager;layersMap=new globalThis.Map;controlsMap=new globalThis.Map;markersMap=new globalThis.Map;overlaysMap=new globalThis.Map;interactionsMap=new globalThis.Map;resizeObserver=null;resizeDebounceTimer=null;isSyncingFromView=!1;popupElement=null;popupCloser=null;popupContent=null;popupOverlay=null;measureTooltipElement=null;measureTooltip=null;drawSource=null;drawLayer=null;measureSource=null;measureLayer=null;layerControlElement=null;constructor(e,t){super(e,t),this.stateManager=new mh(e),this.registerMethods()}registerMethods(){this.registerMethod("addBasemap",this.handleAddBasemap.bind(this)),this.registerMethod("addTileLayer",this.handleAddTileLayer.bind(this)),this.registerMethod("addGeoJSON",this.handleAddGeoJSON.bind(this)),this.registerMethod("addGeoJSONFromURL",this.handleAddGeoJSONFromURL.bind(this)),this.registerMethod("addWMSLayer",this.handleAddWMSLayer.bind(this)),this.registerMethod("addImageWMSLayer",this.handleAddImageWMSLayer.bind(this)),this.registerMethod("addWMTSLayer",this.handleAddWMTSLayer.bind(this)),this.registerMethod("addHeatmap",this.handleAddHeatmap.bind(this)),this.registerMethod("addClusterLayer",this.handleAddClusterLayer.bind(this)),this.registerMethod("removeClusterLayer",this.handleRemoveClusterLayer.bind(this)),this.registerMethod("addVectorTileLayer",this.handleAddVectorTileLayer.bind(this)),this.registerMethod("addImageLayer",this.handleAddImageLayer.bind(this)),this.registerMethod("addChoropleth",this.handleAddChoropleth.bind(this)),this.registerMethod("removeLayer",this.handleRemoveLayer.bind(this)),this.registerMethod("setVisibility",this.handleSetVisibility.bind(this)),this.registerMethod("setOpacity",this.handleSetOpacity.bind(this)),this.registerMethod("setLayerStyle",this.handleSetLayerStyle.bind(this)),this.registerMethod("setLayerZIndex",this.handleSetLayerZIndex.bind(this)),this.registerMethod("addControl",this.handleAddControl.bind(this)),this.registerMethod("removeControl",this.handleRemoveControl.bind(this)),this.registerMethod("addLayerControl",this.handleAddLayerControl.bind(this)),this.registerMethod("removeLayerControl",this.handleRemoveLayerControl.bind(this)),this.registerMethod("setCenter",this.handleSetCenter.bind(this)),this.registerMethod("setZoom",this.handleSetZoom.bind(this)),this.registerMethod("flyTo",this.handleFlyTo.bind(this)),this.registerMethod("fitBounds",this.handleFitBounds.bind(this)),this.registerMethod("fitExtent",this.handleFitExtent.bind(this)),this.registerMethod("setRotation",this.handleSetRotation.bind(this)),this.registerMethod("addMarker",this.handleAddMarker.bind(this)),this.registerMethod("removeMarker",this.handleRemoveMarker.bind(this)),this.registerMethod("addPopup",this.handleAddPopup.bind(this)),this.registerMethod("removePopup",this.handleRemovePopup.bind(this)),this.registerMethod("showPopup",this.handleShowPopup.bind(this)),this.registerMethod("addDrawControl",this.handleAddDrawControl.bind(this)),this.registerMethod("removeDrawControl",this.handleRemoveDrawControl.bind(this)),this.registerMethod("clearDrawData",this.handleClearDrawData.bind(this)),this.registerMethod("addMeasureControl",this.handleAddMeasureControl.bind(this)),this.registerMethod("removeMeasureControl",this.handleRemoveMeasureControl.bind(this)),this.registerMethod("addSelectInteraction",this.handleAddSelectInteraction.bind(this)),this.registerMethod("removeSelectInteraction",this.handleRemoveSelectInteraction.bind(this)),this.registerMethod("addGraticule",this.handleAddGraticule.bind(this)),this.registerMethod("removeGraticule",this.handleRemoveGraticule.bind(this))}async initialize(){this.createMapContainer(),this.map=this.createMap(),this.createPopupOverlay(),this.setupModelListeners(),this.setupMapEvents(),this.setupResizeObserver(),this.processJsCalls(),this.isMapReady=!0,this.processPendingCalls()}createMap(){let e=this.model.get("center")||[0,0],t=this.model.get("zoom")||2;return new al({target:this.mapContainer,view:new It({center:vn(e),zoom:t}),controls:[],interactions:io().extend([new Wf])})}setupMapEvents(){this.map&&(this.map.on("click",e=>{let t=ks(e.coordinate);this.model.set("clicked",{lng:t[0],lat:t[1],point:[e.pixel[0],e.pixel[1]]}),this.sendEvent("click",{lngLat:t,point:e.pixel}),this.model.save_changes();let i=[];if(this.map.forEachFeatureAtPixel(e.pixel,n=>{i.push(n)}),i.length>0){let n=i[0].getProperties();delete n.geometry,this.sendEvent("featureClick",{properties:n,lngLat:t})}}),this.map.getView().on("change:center",()=>{if(this.map&&!this.isSyncingFromView){this.isSyncingFromView=!0;let e=ks(this.map.getView().getCenter()||[0,0]);this.model.set("center",e),this.model.set("current_center",e),this.model.save_changes(),this.isSyncingFromView=!1}}),this.map.getView().on("change:resolution",()=>{if(this.map&&!this.isSyncingFromView){this.isSyncingFromView=!0;let e=this.map.getView().getZoom()||0;this.model.set("zoom",e),this.model.set("current_zoom",e),this.model.save_changes(),this.isSyncingFromView=!1}}),this.map.on("moveend",()=>{if(!this.map)return;let e=this.map.getView(),t=e.calculateExtent(this.map.getSize()),i=jt(t,"EPSG:3857","EPSG:4326");this.model.set("current_bounds",[i[0],i[1],i[2],i[3]]),this.sendEvent("moveend",{center:ks(e.getCenter()||[0,0]),zoom:e.getZoom(),bounds:i}),this.model.save_changes()}))}setupResizeObserver(){!this.mapContainer||!this.map||(this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounceTimer!==null&&window.clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.map&&this.map.updateSize(),this.resizeDebounceTimer=null},100)}),this.resizeObserver.observe(this.mapContainer),this.resizeObserver.observe(this.el))}createPopupOverlay(){this.map&&(this.popupElement=document.createElement("div"),this.popupElement.className="ol-popup",this.popupElement.style.cssText=`
573
+ position: absolute; background-color: white; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
574
+ padding: 12px; border-radius: 8px; border: 1px solid #ccc; bottom: 12px;
575
+ left: -50px; min-width: 200px; font-size: 13px; max-width: 300px; color: #333;
576
+ `,this.popupCloser=document.createElement("a"),this.popupCloser.href="#",this.popupCloser.className="ol-popup-closer",this.popupCloser.style.cssText=`
577
+ text-decoration: none; position: absolute; top: 4px; right: 8px;
578
+ font-size: 16px; color: #999; cursor: pointer;
579
+ `,this.popupCloser.textContent="\u2715",this.popupElement.appendChild(this.popupCloser),this.popupContent=document.createElement("div"),this.popupContent.className="ol-popup-content",this.popupElement.appendChild(this.popupContent),this.popupOverlay=new ms({element:this.popupElement,autoPan:{animation:{duration:250}}}),this.popupCloser.onclick=()=>(this.popupOverlay.setPosition(void 0),this.popupCloser.blur(),!1),this.map.addOverlay(this.popupOverlay))}onCenterChange(){if(this.isSyncingFromView)return;let e=this.model.get("center");this.map&&this.map.getView().setCenter(vn(e))}onZoomChange(){if(this.isSyncingFromView)return;let e=this.model.get("zoom");this.map&&this.map.getView().setZoom(e)}onStyleChange(){}handleAddBasemap(e,t){if(!this.map)return;let i=e[0],n=t.name||"basemap",s=t.attribution||"",o=this.layersMap.get("basemap-"+n);o&&this.map.removeLayer(o);let a=new qr({source:new Do({url:i,attributions:s?[s]:void 0}),zIndex:0});this.map.getLayers().insertAt(0,a),this.layersMap.set("basemap-"+n,a)}handleAddTileLayer(e,t){if(!this.map)return;let i=e[0],n=t.name||`tiles-${this.layersMap.size}`,s=t.attribution||"",o=t.opacity??1,a=t.minZoom??0,l=t.maxZoom??22,h=new qr({source:new Do({url:i,attributions:s?[s]:void 0,minZoom:a,maxZoom:l}),opacity:o});this.map.addLayer(h),this.layersMap.set(n,h),this.updateLayerControl()}handleAddGeoJSON(e,t){if(!this.map)return;let i=t.data,n=t.name||`geojson-${this.layersMap.size}`,s=t.fitBounds!==!1,o=t.style||{},a=t.popup,l=t.popupProperties,h=new mt({features:new gr().readFeatures(i,{featureProjection:"EPSG:3857"})}),c=new gt({source:h,style:this.createVectorStyle(o)});if(this.map.addLayer(c),this.layersMap.set(n,c),this.updateLayerControl(),(a||l)&&this.setupFeaturePopup(n,a,l),s){let u=h.getExtent();u&&u.every(d=>isFinite(d))&&this.map.getView().fit(u,{padding:[50,50,50,50],duration:500})}}handleAddGeoJSONFromURL(e,t){if(!this.map)return;let i=t.url,n=t.name||`geojson-url-${this.layersMap.size}`,s=t.fitBounds!==!1,o=t.style||{},a=new mt({url:i,format:new gr}),l=new gt({source:a,style:this.createVectorStyle(o)});this.map.addLayer(l),this.layersMap.set(n,l),this.updateLayerControl(),s&&a.once("change",()=>{if(a.getState()==="ready"){let h=a.getExtent();h&&h.every(c=>isFinite(c))&&this.map&&this.map.getView().fit(h,{padding:[50,50,50,50],duration:500})}})}setupFeaturePopup(e,t,i){this.map&&this.map.on("click",n=>{let s=!1;this.map.forEachFeatureAtPixel(n.pixel,(o,a)=>{if(s)return;let l=this.layersMap.get(e);if(a===l){s=!0;let h=o.getProperties();delete h.geometry;let c="";if(t){c=t;for(let[u,d]of Object.entries(h))c=c.replace(`{${u}}`,String(d))}else if(i){c='<table style="border-collapse:collapse;">';for(let u of i)h[u]!==void 0&&(c+=`<tr><td style="padding:2px 8px;font-weight:bold;">${u}</td><td style="padding:2px 8px;">${h[u]}</td></tr>`);c+="</table>"}else{c='<table style="border-collapse:collapse;">';for(let[u,d]of Object.entries(h))c+=`<tr><td style="padding:2px 8px;font-weight:bold;">${u}</td><td style="padding:2px 8px;">${d}</td></tr>`;c+="</table>"}this.popupContent.innerHTML=c,this.popupOverlay.setPosition(n.coordinate)}})})}createVectorStyle(e){if(e.styleFunction)return e.styleFunction;let t=new _e({color:e.fillColor||"rgba(51, 136, 255, 0.5)"}),i=new Te({color:e.strokeColor||"#3388ff",width:e.strokeWidth??2,lineDash:e.lineDash||void 0}),n=new Mt({radius:e.radius??6,fill:t,stroke:i}),s={fill:t,stroke:i,image:n};return e.text&&(s.text=new nn({text:e.text,fill:new _e({color:e.textColor||"#000"}),stroke:new Te({color:"#fff",width:3}),font:e.font||"12px sans-serif",offsetY:e.textOffsetY||-15})),new ze(s)}handleAddHeatmap(e,t){if(!this.map)return;let i=t.data,n=t.name||`heatmap-${this.layersMap.size}`,s=t.blur??15,o=t.radius??8,a=t.weight||void 0,l=t.gradient||void 0,h=t.opacity??.8,c=t.fitBounds!==!1,u=new mt({features:new gr().readFeatures(i,{featureProjection:"EPSG:3857"})}),d=new F_({source:u,blur:s,radius:o,opacity:h,weight:a?f=>{let g=f.get(a);return g!==void 0?Number(g):1}:void 0,gradient:l||void 0});if(this.map.addLayer(d),this.layersMap.set(n,d),this.updateLayerControl(),c){let f=u.getExtent();f&&f.every(g=>isFinite(g))&&this.map.getView().fit(f,{padding:[50,50,50,50],duration:500})}}handleAddClusterLayer(e,t){if(!this.map)return;let i=t.data,n=t.name||`cluster-${this.layersMap.size}`,s=t.distance??40,o=t.minDistance??20,a=t.fitBounds!==!1,l=t.clusterColor||"rgba(51, 136, 255, 0.7)",h=t.pointColor||"rgba(51, 136, 255, 0.9)",c=t.textColor||"#fff",u=new gr().readFeatures(i,{featureProjection:"EPSG:3857"}),d=new mt({features:u}),f=new nx({distance:s,minDistance:o,source:d}),g={},m=new gt({source:f,style:p=>{let x=p.get("features").length,y=g[x];if(!y){if(x===1)y=new ze({image:new Mt({radius:8,fill:new _e({color:h}),stroke:new Te({color:"#fff",width:2})})});else{let E=Math.min(8+Math.sqrt(x)*3,30);y=new ze({image:new Mt({radius:E,fill:new _e({color:l}),stroke:new Te({color:"#fff",width:2})}),text:new nn({text:x.toString(),fill:new _e({color:c}),font:"bold 12px sans-serif"})})}g[x]=y}return y}});if(this.map.addLayer(m),this.layersMap.set(n,m),this.updateLayerControl(),a){let p=d.getExtent();p&&p.every(_=>isFinite(_))&&this.map.getView().fit(p,{padding:[50,50,50,50],duration:500})}}handleRemoveClusterLayer(e,t){let[i]=e;this.handleRemoveLayer([i],t)}handleAddWMSLayer(e,t){if(!this.map)return;let i=t.url,n=t.name||`wms-${this.layersMap.size}`,s=t.layers,o=t.format||"image/png",a=t.transparent!==!1,l=t.attribution||"",h=new qr({source:new H_({url:i,params:{LAYERS:s,FORMAT:o,TRANSPARENT:a},serverType:t.serverType||void 0,attributions:l?[l]:void 0})});this.map.addLayer(h),this.layersMap.set(n,h),this.updateLayerControl()}handleAddImageWMSLayer(e,t){if(!this.map)return;let i=t.url,n=t.name||`imagewms-${this.layersMap.size}`,s=t.layers,o=t.format||"image/png",a=t.transparent!==!1,l=t.attribution||"",h=new dd({source:new Z_({url:i,params:{LAYERS:s,FORMAT:o,TRANSPARENT:a},serverType:t.serverType||void 0,attributions:l?[l]:void 0})});this.map.addLayer(h),this.layersMap.set(n,h),this.updateLayerControl()}handleAddWMTSLayer(e,t){if(!this.map)return;let i=t.url,n=t.name||`wmts-${this.layersMap.size}`,s=t.layer,o=t.matrixSet||"EPSG:3857",a=t.format||"image/png",l=t.attribution||"",h=t.style||"default",c=t.opacity??1,d=$(o).getExtent(),f=z(d)/256,g=new Array(19),m=new Array(19);for(let _=0;_<19;++_)g[_]=f/Math.pow(2,_),m[_]=_.toString();let p=new qr({opacity:c,source:new q_({url:i,layer:s,matrixSet:o,format:a,style:h,attributions:l?[l]:void 0,tileGrid:new D_({origin:Je(d),resolutions:g,matrixIds:m})})});this.map.addLayer(p),this.layersMap.set(n,p),this.updateLayerControl()}handleAddVectorTileLayer(e,t){if(!this.map)return;let i=t.url,n=t.name||`vectortile-${this.layersMap.size}`,s=t.style||{},o=t.attribution||"",a=t.minZoom??0,l=t.maxZoom??22,h=new O_({source:new ix({format:new cx,url:i,attributions:o?[o]:void 0,minZoom:a,maxZoom:l}),style:Object.keys(s).length>0?this.createVectorStyle(s):void 0});this.map.addLayer(h),this.layersMap.set(n,h),this.updateLayerControl()}handleAddImageLayer(e,t){if(!this.map)return;let i=t.url,n=t.name||`image-${this.layersMap.size}`,s=t.bounds,o=t.opacity??1,a=jt([s[0],s[1],s[2],s[3]],"EPSG:4326","EPSG:3857"),l=new dd({source:new sx({url:i,imageExtent:a}),opacity:o});this.map.addLayer(l),this.layersMap.set(n,l),this.updateLayerControl()}handleAddChoropleth(e,t){if(!this.map)return;let i=t.data,n=t.name||`choropleth-${this.layersMap.size}`,s=t.column,o=t.breaks,a=t.colors,l=t.strokeColor||"#333",h=t.strokeWidth??1,c=t.opacity??.7,u=t.fitBounds!==!1,d=t.legend??!0,f=new mt({features:new gr().readFeatures(i,{featureProjection:"EPSG:3857"})}),g=p=>{for(let _=0;_<o.length-1;_++)if(p<=o[_+1])return a[Math.min(_,a.length-1)];return a[a.length-1]},m=new gt({source:f,style:p=>{let _=p.get(s),x=_!==void 0?g(Number(_)):a[0];return new ze({fill:new _e({color:x}),stroke:new Te({color:l,width:h})})},opacity:c});if(this.map.addLayer(m),this.layersMap.set(n,m),this.updateLayerControl(),d&&this.addChoroplethLegend(n,s,o,a),u){let p=f.getExtent();p&&p.every(_=>isFinite(_))&&this.map.getView().fit(p,{padding:[50,50,50,50],duration:500})}}addChoroplethLegend(e,t,i,n){if(!this.mapContainer)return;let s=document.createElement("div");s.className=`ol-legend ol-legend-${e}`,s.style.cssText=`
580
+ position: absolute; bottom: 30px; right: 10px; background: rgba(255,255,255,0.9);
581
+ padding: 10px 14px; border-radius: 6px; font-size: 12px; z-index: 1000;
582
+ box-shadow: 0 1px 4px rgba(0,0,0,0.15); max-height: 300px; overflow-y: auto;
583
+ color: #333;
584
+ `;let o=`<div style="font-weight:bold;margin-bottom:6px;color:#333;">${t}</div>`;for(let a=0;a<n.length;a++){let l=i[a]!==void 0?i[a].toFixed(1):"",h=i[a+1]!==void 0?i[a+1].toFixed(1):"";o+=`
585
+ <div style="display:flex;align-items:center;margin:2px 0;">
586
+ <div style="width:18px;height:18px;background:${n[a]};border:1px solid #ccc;margin-right:6px;border-radius:2px;"></div>
587
+ <span style="color:#333;">${l} \u2013 ${h}</span>
588
+ </div>`}s.innerHTML=o,this.mapContainer.appendChild(s)}handleRemoveLayer(e,t){if(!this.map)return;let[i]=e,n=this.layersMap.get(i);n&&(this.map.removeLayer(n),this.layersMap.delete(i),this.updateLayerControl());let s=this.mapContainer?.querySelector(`.ol-legend-${i}`);s&&s.remove()}handleSetVisibility(e,t){let[i,n]=e,s=this.layersMap.get(i);s&&s.setVisible(n)}handleSetOpacity(e,t){let[i,n]=e,s=this.layersMap.get(i);s&&s.setOpacity(n)}handleSetLayerStyle(e,t){let[i]=e,n=t.style,s=this.layersMap.get(i);s&&s instanceof gt&&s.setStyle(this.createVectorStyle(n))}handleSetLayerZIndex(e,t){let[i,n]=e,s=this.layersMap.get(i);s&&s.setZIndex(n)}handleAddControl(e,t){if(!this.map)return;let i=e[0],n;switch(i){case"zoom":case"navigation":n=new Qs;break;case"scale":n=new Gf({units:t.units||"metric"});break;case"fullscreen":n=new bf;break;case"attribution":n=new qs({collapsible:t.collapsible!==!1});break;case"rotate":n=new Js({autoHide:t.autoHide!==!1});break;case"mousePosition":n=new Mf({coordinateFormat:Ig(t.precision??4),projection:"EPSG:4326"});break;case"overviewMap":n=new Df({collapsed:t.collapsed!==!1,layers:[new qr({source:new j_})]});break;case"zoomSlider":n=new Bf;break;case"zoomToExtent":n=new jf({extent:t.extent||void 0});break}n&&(this.map.addControl(n),this.controlsMap.set(i,n))}handleRemoveControl(e,t){if(!this.map)return;let[i]=e,n=this.controlsMap.get(i);n&&(this.map.removeControl(n),this.controlsMap.delete(i))}handleAddLayerControl(e,t){if(!this.mapContainer)return;this.handleRemoveLayerControl([],{});let i=t.collapsed??!0,n=document.createElement("div");n.className="ol-layer-control",n.style.cssText=`
589
+ position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,0.95);
590
+ padding: 8px 12px; border-radius: 6px; font-size: 13px; z-index: 1000;
591
+ box-shadow: 0 1px 4px rgba(0,0,0,0.15); max-height: 400px; overflow-y: auto;
592
+ min-width: 150px; color: #333;
593
+ `;let s=document.createElement("div");s.style.cssText="font-weight:bold;margin-bottom:6px;cursor:pointer;user-select:none;",s.textContent="\u2630 Layers",n.appendChild(s);let o=document.createElement("div");o.className="ol-layer-list",i&&(o.style.display="none"),n.appendChild(o),s.onclick=()=>{o.style.display=o.style.display==="none"?"block":"none"},this.layerControlElement=n,this.mapContainer.appendChild(n),this.updateLayerControl()}handleRemoveLayerControl(e,t){this.layerControlElement&&(this.layerControlElement.remove(),this.layerControlElement=null)}updateLayerControl(){if(!this.layerControlElement)return;let e=this.layerControlElement.querySelector(".ol-layer-list");e&&(e.innerHTML="",this.layersMap.forEach((t,i)=>{if(i.startsWith("basemap-"))return;let n=document.createElement("div");n.style.cssText="display:flex;align-items:center;margin:3px 0;";let s=document.createElement("input");s.type="checkbox",s.checked=t.getVisible(),s.style.marginRight="6px",s.onchange=()=>{t.setVisible(s.checked)};let o=document.createElement("span");o.textContent=i,o.style.cssText="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;",n.appendChild(s),n.appendChild(o),e.appendChild(n)}))}handleSetCenter(e,t){if(!this.map)return;let[i,n]=e;this.map.getView().setCenter(vn([i,n]))}handleSetZoom(e,t){if(!this.map)return;let[i]=e;this.map.getView().setZoom(i)}handleFlyTo(e,t){if(!this.map)return;let[i,n]=e,s=t.zoom,o=t.duration||2e3;this.map.getView().animate({center:vn([i,n]),zoom:s,duration:o})}handleFitBounds(e,t){if(!this.map)return;let i=e[0],n=t.padding||50,s=t.duration||1e3,o=jt([i[0],i[1],i[2],i[3]],"EPSG:4326","EPSG:3857");this.map.getView().fit(o,{padding:[n,n,n,n],duration:s})}handleFitExtent(e,t){if(!this.map)return;let i=e[0],n=t.padding||50,s=t.duration||1e3;this.map.getView().fit(i,{padding:[n,n,n,n],duration:s})}handleSetRotation(e,t){if(!this.map)return;let[i]=e;this.map.getView().setRotation(i)}handleAddMarker(e,t){if(!this.map)return;let[i,n]=e,s=t.id||t.name||`marker-${this.markersMap.size}`,o=t.popup,a=t.color||"#3388ff",l=t.radius??8,h=t.draggable??!1,c=new Ge({geometry:new Fe(vn([i,n])),popup:o,name:s}),u=new mt({features:[c]}),d=new ze({image:new Mt({radius:l,fill:new _e({color:a}),stroke:new Te({color:"#ffffff",width:2})})}),f=new gt({source:u,style:d});if(this.map.addLayer(f),this.markersMap.set(s,f),o&&this.map.on("click",g=>{this.map.forEachFeatureAtPixel(g.pixel,m=>{m===c&&o&&(this.popupContent.innerHTML=o,this.popupOverlay.setPosition(g.coordinate))})}),h){let g=new ch({source:u});g.on("modifyend",()=>{let m=c.getGeometry().getCoordinates(),p=ks(m);this.sendEvent("markerDrag",{id:s,lngLat:p})}),this.map.addInteraction(g)}}handleRemoveMarker(e,t){if(!this.map)return;let[i]=e,n=this.markersMap.get(i);n&&(this.map.removeLayer(n),this.markersMap.delete(i))}handleAddPopup(e,t){if(!this.map)return;let i=t.name||`popup-${this.overlaysMap.size}`,n=t.content||"",s=t.lng,o=t.lat;this.popupContent.innerHTML=n,this.popupOverlay.setPosition(vn([s,o]))}handleRemovePopup(e,t){this.popupOverlay&&this.popupOverlay.setPosition(void 0)}handleShowPopup(e,t){if(!this.map)return;let i=t.content||"",n=t.lng,s=t.lat;this.popupContent.innerHTML=i,this.popupOverlay.setPosition(vn([n,s]))}handleAddDrawControl(e,t){if(!this.map)return;this.handleRemoveDrawControl([],{});let i=t.type||"Polygon";this.drawSource=new mt,this.drawLayer=new gt({source:this.drawSource,style:new ze({fill:new _e({color:"rgba(255, 255, 255, 0.3)"}),stroke:new Te({color:"#ffcc33",width:2}),image:new Mt({radius:7,fill:new _e({color:"#ffcc33"})})})}),this.map.addLayer(this.drawLayer);let n=new hh({source:this.drawSource,type:i}),s=new ch({source:this.drawSource}),o=new eg({source:this.drawSource});n.on("drawend",()=>{setTimeout(()=>this.syncDrawData(),100)}),s.on("modifyend",()=>{this.syncDrawData()}),this.map.addInteraction(n),this.map.addInteraction(s),this.map.addInteraction(o),this.interactionsMap.set("draw",n),this.interactionsMap.set("draw-modify",s),this.interactionsMap.set("draw-snap",o)}handleRemoveDrawControl(e,t){this.map&&(["draw","draw-modify","draw-snap"].forEach(i=>{let n=this.interactionsMap.get(i);n&&(this.map.removeInteraction(n),this.interactionsMap.delete(i))}),this.drawLayer&&(this.map.removeLayer(this.drawLayer),this.drawLayer=null,this.drawSource=null))}handleClearDrawData(e,t){this.drawSource&&(this.drawSource.clear(),this.syncDrawData())}syncDrawData(){if(!this.drawSource)return;let e=this.drawSource.getFeatures(),t=new gr().writeFeaturesObject(e,{featureProjection:"EPSG:3857"});this.model.set("_draw_data",t),this.model.save_changes(),this.sendEvent("drawChange",t)}handleAddMeasureControl(e,t){if(!this.map)return;this.handleRemoveMeasureControl([],{});let i=t.type||"LineString";this.measureSource=new mt,this.measureLayer=new gt({source:this.measureSource,style:new ze({fill:new _e({color:"rgba(255, 255, 255, 0.2)"}),stroke:new Te({color:"#e74c3c",width:3,lineDash:[10,10]}),image:new Mt({radius:5,fill:new _e({color:"#e74c3c"}),stroke:new Te({color:"#fff",width:2})})})}),this.map.addLayer(this.measureLayer),this.measureTooltipElement=document.createElement("div"),this.measureTooltipElement.className="ol-measure-tooltip",this.measureTooltipElement.style.cssText=`
594
+ position: relative; background: rgba(0,0,0,0.7); color: #fff;
595
+ border-radius: 4px; padding: 4px 8px; font-size: 12px; white-space: nowrap;
596
+ `,this.measureTooltip=new ms({element:this.measureTooltipElement,offset:[0,-15],positioning:"bottom-center"}),this.map.addOverlay(this.measureTooltip);let n=new hh({source:this.measureSource,type:i,style:new ze({fill:new _e({color:"rgba(255, 255, 255, 0.2)"}),stroke:new Te({color:"rgba(231, 76, 60, 0.5)",width:2,lineDash:[10,10]}),image:new Mt({radius:5,stroke:new Te({color:"rgba(231, 76, 60, 0.7)"}),fill:new _e({color:"rgba(255, 255, 255, 0.2)"})})})});n.on("drawstart",s=>{s.feature.getGeometry().on("change",a=>{let l=a.target,h="",c;if(l instanceof dt){let u=pa(l);h=u>1e4?`${(u/1e6).toFixed(2)} km\xB2`:`${u.toFixed(2)} m\xB2`,c=l.getInteriorPoint().getCoordinates()}else if(l instanceof Ke){let u=ma(l);h=u>1e3?`${(u/1e3).toFixed(2)} km`:`${u.toFixed(2)} m`,c=l.getLastCoordinate()}this.measureTooltipElement&&(this.measureTooltipElement.textContent=h),this.measureTooltip&&this.measureTooltip.setPosition(c)})}),n.on("drawend",s=>{let o=s.feature.getGeometry(),a={};o instanceof dt?a={type:"area",value:pa(o),unit:"m\xB2"}:o instanceof Ke&&(a={type:"distance",value:ma(o),unit:"m"}),this.sendEvent("measureResult",a);let l=document.createElement("div");l.style.cssText=`
597
+ background: rgba(0,0,0,0.7); color: #fff; border-radius: 4px;
598
+ padding: 3px 6px; font-size: 11px; white-space: nowrap;
599
+ `,l.textContent=this.measureTooltipElement?.textContent||"";let h=new ms({element:l,offset:[0,-10],positioning:"bottom-center",position:this.measureTooltip?.getPosition()});this.map.addOverlay(h),this.measureTooltipElement=document.createElement("div"),this.measureTooltipElement.className="ol-measure-tooltip",this.measureTooltipElement.style.cssText=`
600
+ position: relative; background: rgba(0,0,0,0.7); color: #fff;
601
+ border-radius: 4px; padding: 4px 8px; font-size: 12px; white-space: nowrap;
602
+ `,this.measureTooltip.setElement(this.measureTooltipElement)}),this.map.addInteraction(n),this.interactionsMap.set("measure",n)}handleRemoveMeasureControl(e,t){if(!this.map)return;let i=this.interactionsMap.get("measure");i&&(this.map.removeInteraction(i),this.interactionsMap.delete("measure")),this.measureLayer&&(this.map.removeLayer(this.measureLayer),this.measureLayer=null,this.measureSource=null),this.measureTooltip&&(this.map.removeOverlay(this.measureTooltip),this.measureTooltip=null,this.measureTooltipElement=null)}handleAddSelectInteraction(e,t){if(!this.map)return;this.handleRemoveSelectInteraction([],{});let i=t.multi??!1,n=new ze({fill:new _e({color:"rgba(255, 200, 0, 0.4)"}),stroke:new Te({color:"#ff8800",width:3}),image:new Mt({radius:8,fill:new _e({color:"rgba(255, 200, 0, 0.6)"}),stroke:new Te({color:"#ff8800",width:2})})}),s=new qf({condition:km,multi:i,style:n});s.on("select",o=>{let a=o.selected.map(l=>{let h=l.getProperties();return delete h.geometry,h});this.sendEvent("featureSelect",{selected:a}),this.model.set("_queried_features",{selected:a}),this.model.save_changes()}),this.map.addInteraction(s),this.interactionsMap.set("select",s)}handleRemoveSelectInteraction(e,t){if(!this.map)return;let i=this.interactionsMap.get("select");i&&(this.map.removeInteraction(i),this.interactionsMap.delete("select"))}handleAddGraticule(e,t){if(!this.map)return;this.handleRemoveGraticule([],{});let i=t.strokeColor||"rgba(0, 0, 0, 0.2)",n=t.strokeWidth??1,s=t.showLabels!==!1,o=new bx({strokeStyle:new Te({color:i,width:n,lineDash:[4,4]}),showLabels:s,wrapX:!1});this.map.addLayer(o),this.layersMap.set("graticule",o)}handleRemoveGraticule(e,t){if(!this.map)return;let i=this.layersMap.get("graticule");i&&(this.map.removeLayer(i),this.layersMap.delete("graticule"))}destroy(){this.removeModelListeners(),this.resizeDebounceTimer!==null&&(window.clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.interactionsMap.forEach(e=>{this.map&&this.map.removeInteraction(e)}),this.interactionsMap.clear(),this.overlaysMap.forEach(e=>{this.map&&this.map.removeOverlay(e)}),this.overlaysMap.clear(),this.markersMap.forEach(e=>{this.map&&this.map.removeLayer(e)}),this.markersMap.clear(),this.layersMap.forEach(e=>{this.map&&this.map.removeLayer(e)}),this.layersMap.clear(),this.controlsMap.forEach(e=>{this.map&&this.map.removeControl(e)}),this.controlsMap.clear(),this.layerControlElement&&(this.layerControlElement.remove(),this.layerControlElement=null),this.map&&(this.map.setTarget(void 0),this.map=null),this.mapContainer&&(this.mapContainer.remove(),this.mapContainer=null)}};var Yo=null;function AT({model:r,el:e}){return Yo=new ph(r,e),Yo.initialize().catch(t=>{console.error("Failed to initialize OpenLayers map:",t)}),()=>{Yo&&(Yo.destroy(),Yo=null)}}var OV={render:AT};export{OV as default,AT as render};