pwaLUPMIS2/dist/assets/openlayers-D2I-bVN2.js
2026-03-04 12:59:40 +01:00

574 lines
465 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const ou="modulepreload",au=function(s){return"/"+s},rl={},Op=function(t,e,i){let n=Promise.resolve();if(e&&e.length>0){let o=function(h){return Promise.all(h.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");n=o(e.map(h=>{if(h=au(h),h in rl)return;rl[h]=!0;const c=h.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":ou,c||(d.as="script"),d.crossOrigin="",d.href=h,l&&d.setAttribute("nonce",l),document.head.appendChild(d),c)return new Promise((f,g)=>{d.addEventListener("load",f),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return n.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return t().catch(r)})},Tt={ADD:"add",REMOVE:"remove"},nn={PROPERTYCHANGE:"propertychange"},X={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class Zn{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function lu(s,t,e){let i,n;e=e||Ee;let r=0,o=s.length,a=!1;for(;r<o;)i=r+(o-r>>1),n=+e(s[i],t),n<0?r=i+1:(o=i,a=!n);return a?r:~r}function Ee(s,t){return s>t?1:s<t?-1:0}function hu(s,t){return s<t?1:s>t?-1:0}function Yo(s,t,e){if(s[0]<=t)return 0;const i=s.length;if(t<=s[i-1])return i-1;if(typeof e=="function"){for(let n=1;n<i;++n){const r=s[n];if(r===t)return n;if(r<t)return e(t,s[n-1],r)>0?n-1:n}return i-1}if(e>0){for(let n=1;n<i;++n)if(s[n]<t)return n-1;return i-1}if(e<0){for(let n=1;n<i;++n)if(s[n]<=t)return n;return i-1}for(let n=1;n<i;++n){if(s[n]==t)return n;if(s[n]<t)return s[n-1]-t<t-s[n]?n-1:n}return i-1}function cu(s,t,e){for(;t<e;){const i=s[t];s[t]=s[e],s[e]=i,++t,--e}}function Yt(s,t){const e=Array.isArray(t)?t:[t],i=e.length;for(let n=0;n<i;n++)s[s.length]=e[n]}function ze(s,t){const e=s.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(s[i]!==t[i])return!1;return!0}function uu(s,t,e){const i=t||Ee;return s.every(function(n,r){if(r===0)return!0;const o=i(s[r-1],n);return!(o>0||o===0)})}function ei(){return!0}function hn(){return!1}function Dn(){}function hh(s){let t,e,i;return function(){const n=Array.prototype.slice.call(arguments);return(!e||this!==i||!ze(n,e))&&(i=this,e=n,t=s.apply(this,arguments)),t}}function du(s){function t(){let e;try{e=s()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}function Pi(s){for(const t in s)delete s[t]}function Ei(s){let t;for(t in s)return!1;return!t}class se{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class lr extends Zn{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),n=i[t]||(i[t]=[]);n.includes(e)||n.push(e)}dispatchEvent(t){const e=typeof t=="string",i=e?t:t.type,n=this.listeners_&&this.listeners_[i];if(!n)return;const r=e?new se(t):t;r.target||(r.target=this.eventTarget_||this);const 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(r):l=n[h].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,Dn);delete o[i]}return l}disposeInternal(){this.listeners_&&Pi(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;const i=this.listeners_[t];if(!i)return;const n=i.indexOf(e);n!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[n]=Dn,++this.pendingRemovals_[t]):(i.splice(n,1),i.length===0&&delete this.listeners_[t]))}}function Z(s,t,e,i,n){if(n){const o=e;e=function(a){return s.removeEventListener(t,e),o.call(i??this,a)}}else i&&i!==s&&(e=e.bind(i));const r={target:s,type:t,listener:e};return s.addEventListener(t,e),r}function Ns(s,t,e,i){return Z(s,t,e,i,!0)}function st(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),Pi(s))}class Kn extends lr{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(X.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=Z(this,t[r],e);return n}return Z(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const n=t.length;i=new Array(n);for(let r=0;r<n;++r)i[r]=Ns(this,t[r],e)}else i=Ns(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)fu(i);else if(Array.isArray(t))for(let n=0,r=t.length;n<r;++n)this.removeEventListener(t[n],e);else this.removeEventListener(t,e)}}Kn.prototype.on;Kn.prototype.once;Kn.prototype.un;function fu(s){if(Array.isArray(s))for(let t=0,e=s.length;t<e;++t)st(s[t]);else st(s)}function B(){throw new Error("Unimplemented abstract method.")}let gu=0;function k(s){return s.ol_uid||(s.ol_uid=String(++gu))}class ol extends se{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class re extends Kn{constructor(t){super(),this.on,this.once,this.un,k(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 ol(i,t,e)),i=nn.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new ol(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const n=this.values_||(this.values_={});if(i)n[t]=e;else{const r=n[t];n[t]=e,r!==e&&this.notify(t,r)}}setProperties(t,e){for(const 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_){const i=this.values_[t];delete this.values_[t],Ei(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}const al={LENGTH:"length"};class hs extends se{constructor(t,e,i){super(t),this.element=e,this.index=i}}class Xt extends re{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,n=this.array_.length;i<n;++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){const e=this.array_;for(let i=0,n=e.length;i<n;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(al.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 hs(Tt.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,n=e.length;i<n;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new hs(Tt.REMOVE,e,t)),e}setAt(t,e){const 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);const n=this.array_[t];this.array_[t]=e,this.dispatchEvent(new hs(Tt.REMOVE,n,t)),this.dispatchEvent(new hs(Tt.ADD,e,t))}updateLength_(){this.set(al.LENGTH,this.array_.length)}assertUnique_(t,e){const i=this.array_;for(let n=0,r=i.length;n<r;++n)if(i[n]===t&&n!==e)throw new Error("Duplicate item added to a unique collection")}}class ji extends se{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}}class be extends ji{constructor(t,e,i,n,r,o){super(t,e,r),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(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()}}const J={SINGLECLICK:"singleclick",CLICK:X.CLICK,DBLCLICK:X.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},Ti=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",_u=Ti.includes("safari")&&!Ti.includes("chrom"),mu=_u&&(Ti.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Ti)),pu=Ti.includes("webkit")&&!Ti.includes("edge"),ch=Ti.includes("macintosh"),yu=typeof devicePixelRatio<"u"?devicePixelRatio:1,jt=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,uh=typeof Image<"u"&&Image.prototype.decode,dh=(function(){let s=!1;try{const t=Object.defineProperty({},"passive",{get:function(){s=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return s})(),yo={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class xu extends lr{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;const i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=Z(i,yo.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=Z(i,yo.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(X.TOUCHMOVE,this.boundHandleTouchMove_,dh?{passive:!1}:!1)}emulateClick_(t){let e=new be(J.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new be(J.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new be(J.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==J.POINTERUP||e.type==J.POINTERCANCEL){delete this.trackedTouches_[i];for(const n in this.trackedTouches_)if(this.trackedTouches_[n].target!==e.target){delete this.trackedTouches_[n];break}}else(e.type==J.POINTERDOWN||e.type==J.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new be(J.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(st),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);const e=new be(J.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){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(Z(i,J.POINTERMOVE,this.handlePointerMove_,this),Z(i,J.POINTERUP,this.handlePointerUp_,this),Z(this.element_,J.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(Z(this.element_.getRootNode(),J.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new be(J.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!!(this.down_&&this.isMoving_(t));this.dispatchEvent(new be(J.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const 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_&&(st(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(X.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(st(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(st),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Fe={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},It={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},N={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function H(s,t){if(!s)throw new Error(t)}const Gs=1/0;class Eu{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,Pi(this.queuedElements_)}dequeue(){const 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));const n=this.keyFunction_(i);return delete this.queuedElements_[n],i}enqueue(t){H(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=Gs?(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){const e=this.elements_,i=this.priorities_,n=e.length,r=e[t],o=i[t],a=t;for(;t<n>>1;){const l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=h<n&&i[h]<i[l]?h:l;e[t]=e[c],i[t]=i[c],t=c}e[t]=r,i[t]=o,this.siftDown_(a,t)}siftDown_(t,e){const i=this.elements_,n=this.priorities_,r=i[e],o=n[e];for(;e>t;){const a=this.getParentIndex_(e);if(n[a]>o)i[e]=i[a],n[e]=n[a],e=a;else break}i[e]=r,n[e]=o}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let n=0;const r=e.length;let o,a,l;for(a=0;a<r;++a)o=e[a],l=t(o),l==Gs?delete this.queuedElements_[this.keyFunction_(o)]:(i[n]=l,e[n++]=o);e.length=n,i.length=n,this.heapify_()}}class Tu extends Eu{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){const e=super.enqueue(t);return e&&t[0].addEventListener(X.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===N.LOADED||i===N.ERROR||i===N.EMPTY){i!==N.ERROR&&e.removeEventListener(X.CHANGE,this.boundHandleTileChange_);const n=e.getKey();n in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[n],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){const n=this.dequeue()[0],r=n.getKey();n.getState()===N.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,n.load())}}}function Cu(s,t,e,i,n){if(!s||!(e in s.wantedTiles)||!s.wantedTiles[e][t.getKey()])return Gs;const r=s.viewState.center,o=i[0]-r[0],a=i[1]-r[1];return 65536*Math.log(n)+Math.sqrt(o*o+a*a)/n}const rt={ANIMATING:0,INTERACTING:1},ae={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function ot(s,t,e){return Math.min(Math.max(s,t),e)}function vu(s,t,e,i,n,r){const o=n-e,a=r-i;if(o!==0||a!==0){const l=((s-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=n,i=r):l>0&&(e+=o*l,i+=a*l)}return ke(s,t,e,i)}function ke(s,t,e,i){const n=e-s,r=i-t;return n*n+r*r}function Ru(s){const t=s.length;for(let i=0;i<t;i++){let n=i,r=Math.abs(s[i][i]);for(let a=i+1;a<t;a++){const l=Math.abs(s[a][i]);l>r&&(r=l,n=a)}if(r===0)return null;const o=s[n];s[n]=s[i],s[i]=o;for(let a=i+1;a<t;a++){const l=-s[a][i]/s[i][i];for(let h=i;h<t+1;h++)i==h?s[a][h]=0:s[a][h]+=l*s[i][h]}}const e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=s[i][t]/s[i][i];for(let n=i-1;n>=0;n--)s[n][t]-=s[n][i]*e[i]}return e}function Bs(s){return s*180/Math.PI}function Nt(s){return s*Math.PI/180}function Qe(s,t){const e=s%t;return e*t<0?e+t:e}function Ut(s,t,e){return s+e*(t-s)}function Hn(s,t){const e=Math.pow(10,t);return Math.round(s*e)/e}function cs(s,t){return Math.floor(Hn(s,t))}function us(s,t){return Math.ceil(Hn(s,t))}function xo(s,t,e){if(s>=t&&s<e)return s;const i=e-t;return((s-t)%i+i)%i+t}function ll(s,t,e){return(function(i,n,r,o,a){if(!i)return;if(!n&&!t)return i;const l=t?0:r[0]*n,h=t?0:r[1]*n,c=a?a[0]:0,u=a?a[1]:0;let d=s[0]+l/2+c,f=s[2]-l/2+c,g=s[1]+h/2+u,m=s[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=ot(i[0],d,f),p=ot(i[1],g,m);if(o&&e&&n){const y=30*n;_+=-y*Math.log(1+Math.max(0,d-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-m)/y)}return[_,p]})}function Su(s){return s}const Et={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function zs(s){const t=Vt();for(let e=0,i=s.length;e<i;++e)Fn(t,s[e]);return t}function wu(s,t,e){const i=Math.min.apply(null,s),n=Math.min.apply(null,t),r=Math.max.apply(null,s),o=Math.max.apply(null,t);return ve(i,n,r,o,e)}function sn(s,t,e){return e?(e[0]=s[0]-t,e[1]=s[1]-t,e[2]=s[2]+t,e[3]=s[3]+t,e):[s[0]-t,s[1]-t,s[2]+t,s[3]+t]}function fh(s,t){return t?(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t):s.slice()}function Ii(s,t,e){let i,n;return t<s[0]?i=s[0]-t:s[2]<t?i=t-s[2]:i=0,e<s[1]?n=s[1]-e:s[3]<e?n=e-s[3]:n=0,i*i+n*n}function Ci(s,t){return Vo(s,t[0],t[1])}function Ze(s,t){return s[0]<=t[0]&&t[2]<=s[2]&&s[1]<=t[1]&&t[3]<=s[3]}function Vo(s,t,e){return s[0]<=t&&t<=s[2]&&s[1]<=e&&e<=s[3]}function Eo(s,t){const e=s[0],i=s[1],n=s[2],r=s[3],o=t[0],a=t[1];let l=Et.UNKNOWN;return o<e?l=l|Et.LEFT:o>n&&(l=l|Et.RIGHT),a<i?l=l|Et.BELOW:a>r&&(l=l|Et.ABOVE),l===Et.UNKNOWN&&(l=Et.INTERSECTING),l}function Vt(){return[1/0,1/0,-1/0,-1/0]}function ve(s,t,e,i,n){return n?(n[0]=s,n[1]=t,n[2]=e,n[3]=i,n):[s,t,e,i]}function cn(s){return ve(1/0,1/0,-1/0,-1/0,s)}function gh(s,t){const e=s[0],i=s[1];return ve(e,i,e,i,t)}function Zo(s,t,e,i,n){const r=cn(n);return mh(r,s,t,e,i)}function vi(s,t){return s[0]==t[0]&&s[2]==t[2]&&s[1]==t[1]&&s[3]==t[3]}function _h(s,t){return t[0]<s[0]&&(s[0]=t[0]),t[2]>s[2]&&(s[2]=t[2]),t[1]<s[1]&&(s[1]=t[1]),t[3]>s[3]&&(s[3]=t[3]),s}function Fn(s,t){t[0]<s[0]&&(s[0]=t[0]),t[0]>s[2]&&(s[2]=t[0]),t[1]<s[1]&&(s[1]=t[1]),t[1]>s[3]&&(s[3]=t[1])}function mh(s,t,e,i,n){for(;e<i;e+=n)Pu(s,t[e],t[e+1]);return s}function Pu(s,t,e){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}function Ko(s,t){let e;return e=t(hr(s)),e||(e=t(cr(s)),e)||(e=t(ur(s)),e)||(e=t(ri(s)),e)?e:!1}function To(s){let t=0;return un(s)||(t=it(s)*Lt(s)),t}function hr(s){return[s[0],s[1]]}function cr(s){return[s[2],s[1]]}function ii(s){return[(s[0]+s[2])/2,(s[1]+s[3])/2]}function Iu(s,t){let e;if(t==="bottom-left")e=hr(s);else if(t==="bottom-right")e=cr(s);else if(t==="top-left")e=ri(s);else if(t==="top-right")e=ur(s);else throw new Error("Invalid corner");return e}function Co(s,t,e,i,n){const[r,o,a,l,h,c,u,d]=ph(s,t,e,i);return ve(Math.min(r,a,h,u),Math.min(o,l,c,d),Math.max(r,a,h,u),Math.max(o,l,c,d),n)}function ph(s,t,e,i){const n=t*i[0]/2,r=t*i[1]/2,o=Math.cos(e),a=Math.sin(e),l=n*o,h=n*a,c=r*o,u=r*a,d=s[0],f=s[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 Lt(s){return s[3]-s[1]}function Ne(s,t,e){const i=e||Vt();return ft(s,t)?(s[0]>t[0]?i[0]=s[0]:i[0]=t[0],s[1]>t[1]?i[1]=s[1]:i[1]=t[1],s[2]<t[2]?i[2]=s[2]:i[2]=t[2],s[3]<t[3]?i[3]=s[3]:i[3]=t[3]):cn(i),i}function ri(s){return[s[0],s[3]]}function ur(s){return[s[2],s[3]]}function it(s){return s[2]-s[0]}function ft(s,t){return s[0]<=t[2]&&s[2]>=t[0]&&s[1]<=t[3]&&s[3]>=t[1]}function un(s){return s[2]<s[0]||s[3]<s[1]}function Au(s,t){return t?(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t):s}function Lu(s,t,e){let i=!1;const n=Eo(s,t),r=Eo(s,e);if(n===Et.INTERSECTING||r===Et.INTERSECTING)i=!0;else{const o=s[0],a=s[1],l=s[2],h=s[3],c=t[0],u=t[1],d=e[0],f=e[1],g=(f-u)/(d-c);let m,_;r&Et.ABOVE&&!(n&Et.ABOVE)&&(m=d-(f-h)/g,i=m>=o&&m<=l),!i&&r&Et.RIGHT&&!(n&Et.RIGHT)&&(_=f-(d-l)*g,i=_>=a&&_<=h),!i&&r&Et.BELOW&&!(n&Et.BELOW)&&(m=d-(f-a)/g,i=m>=o&&m<=l),!i&&r&Et.LEFT&&!(n&Et.LEFT)&&(_=f-(d-o)*g,i=_>=a&&_<=h)}return i}function bu(s,t,e,i){if(un(s))return cn(e);let n=[];{const a=s[2]-s[0],l=s[3]-s[1];for(let h=0;h<i;++h)n.push(s[0]+a*h/i,s[1],s[2],s[1]+l*h/i,s[2]-a*h/i,s[3],s[0],s[3]-l*h/i)}t(n,n,2);const r=[],o=[];for(let a=0,l=n.length;a<l;a+=2)r.push(n[a]),o.push(n[a+1]);return wu(r,o,e)}function yh(s,t){const e=t.getExtent(),i=ii(s);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){const n=it(e),o=Math.floor((i[0]-e[0])/n)*n;s[0]-=o,s[2]-=o}return s}function xh(s,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(s[0])||!isFinite(s[2]))return[[i[0],s[1],i[2],s[3]]];yh(s,t);const n=it(i);if(it(s)>n&&!e)return[[i[0],s[1],i[2],s[3]]];if(s[0]<i[0])return[[s[0]+n,s[1],i[2],s[3]],[i[0],s[1],s[2],s[3]]];if(s[2]>i[2])return[[s[0],s[1],i[2],s[3]],[i[0],s[1],s[2]-n,s[3]]]}return[s]}function Fu(s,t){return s[0]+=+t[0],s[1]+=+t[1],s}function Us(s,t){let e=!0;for(let i=s.length-1;i>=0;--i)if(s[i]!=t[i]){e=!1;break}return e}function Ho(s,t){const e=Math.cos(t),i=Math.sin(t),n=s[0]*e-s[1]*i,r=s[1]*e+s[0]*i;return s[0]=n,s[1]=r,s}function Mu(s,t){return s[0]*=t,s[1]*=t,s}function Eh(s,t){const e=s[0]-t[0],i=s[1]-t[1];return e*e+i*i}function Th(s,t){return Math.sqrt(Eh(s,t))}function qo(s,t){if(t.canWrapX()){const e=it(t.getExtent()),i=Ou(s,t,e);i&&(s[0]-=i*e)}return s}function Ou(s,t,e){const i=t.getExtent();let n=0;return t.canWrapX()&&(s[0]<i[0]||s[0]>i[2])&&(e=e||it(i),n=Math.floor((s[0]-i[0])/e)),n}function Ch(s){return Math.pow(s,3)}function dn(s){return 1-Ch(1-s)}function Du(s){return 3*s*s-2*s*s*s}function ku(s){return s}const dr=63710088e-1;function vo(s,t,e){e=e||dr;const i=Nt(s[1]),n=Nt(t[1]),r=(n-i)/2,o=Nt(t[0]-s[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(n);return 2*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function Dr(s,t){let e=0;for(let i=0,n=s.length;i<n-1;++i)e+=vo(s[i],s[i+1],t);return e}function Nu(s,t){t=t||{};const e=t.radius||dr,i=t.projection||"EPSG:3857",n=s.getType();n!=="GeometryCollection"&&(s=s.clone().transform(i,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(n){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":{o=s.getCoordinates(),r=Dr(o,e);break}case"MultiLineString":case"Polygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)r+=Dr(o[l],e);break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,u=a.length;c<u;++c)r+=Dr(a[c],e);break}case"GeometryCollection":{const d=s.getGeometries();for(l=0,h=d.length;l<h;++l)r+=Nu(d[l],t);break}default:throw new Error("Unsupported geometry type: "+n)}return r}function ds(s,t){let e=0;const i=s.length;let n=s[i-1][0],r=s[i-1][1];for(let o=0;o<i;o++){const a=s[o][0],l=s[o][1];e+=Nt(a-n)*(2+Math.sin(Nt(r))+Math.sin(Nt(l))),n=a,r=l}return e*t*t/2}function Gu(s,t){t=t||{};const e=t.radius||dr,i=t.projection||"EPSG:3857",n=s.getType();n!=="GeometryCollection"&&(s=s.clone().transform(i,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(n){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":{for(o=s.getCoordinates(),r=Math.abs(ds(o[0],e)),l=1,h=o.length;l<h;++l)r-=Math.abs(ds(o[l],e));break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],r+=Math.abs(ds(a[0],e)),c=1,u=a.length;c<u;++c)r-=Math.abs(ds(a[c],e));break}case"GeometryCollection":{const d=s.getGeometries();for(l=0,h=d.length;l<h;++l)r+=Gu(d[l],t);break}default:throw new Error("Unsupported geometry type: "+n)}return r}function Bu(s,t,e,i){i=i||dr;const n=Nt(s[1]),r=Nt(s[0]),o=t/i,a=Math.asin(Math.sin(n)*Math.cos(o)+Math.cos(n)*Math.sin(o)*Math.cos(e)),l=r+Math.atan2(Math.sin(e)*Math.sin(o)*Math.cos(n),Math.cos(o)-Math.sin(n)*Math.sin(a));return[Bs(l),Bs(a)]}function vh(...s){console.warn(...s)}const rn={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Jo{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_||rn[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_}}const qn=6378137,Ki=Math.PI*qn,zu=[-Ki,-Ki,Ki,Ki],Uu=[-180,-85,180,85],fs=qn*Math.log(Math.tan(Math.PI/2));class Di extends Jo{constructor(t){super({code:t,units:"m",extent:zu,global:!0,worldExtent:Uu,getPointResolution:function(e,i){return e/Math.cosh(i[1]/qn)}})}}const hl=[new Di("EPSG:3857"),new Di("EPSG:102100"),new Di("EPSG:102113"),new Di("EPSG:900913"),new Di("http://www.opengis.net/def/crs/EPSG/0/3857"),new Di("http://www.opengis.net/gml/srs/epsg.xml#3857")];function $u(s,t,e,i){const n=s.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=s.slice():t=new Array(n));for(let r=0;r<n;r+=i){t[r]=Ki*s[r]/180;let o=qn*Math.log(Math.tan(Math.PI*(+s[r+1]+90)/360));o>fs?o=fs:o<-fs&&(o=-fs),t[r+1]=o}return t}function Wu(s,t,e,i){const n=s.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=s.slice():t=new Array(n));for(let r=0;r<n;r+=i)t[r]=180*s[r]/Ki,t[r+1]=360*Math.atan(Math.exp(s[r+1]/qn))/Math.PI-90;return t}const Xu=6378137,cl=[-180,-90,180,90],ju=Math.PI*Xu/180;class ci extends Jo{constructor(t,e){super({code:t,units:"degrees",extent:cl,axisOrientation:e,global:!0,metersPerUnit:ju,worldExtent:cl})}}const ul=[new ci("CRS:84"),new ci("EPSG:4326","neu"),new ci("urn:ogc:def:crs:OGC:1.3:CRS84"),new ci("urn:ogc:def:crs:OGC:2:84"),new ci("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new ci("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new ci("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Ro={};function Yu(s){return Ro[s]||Ro[s.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function Vu(s,t){Ro[s]=t}let Qi={};function kn(s,t,e){const i=s.getCode(),n=t.getCode();i in Qi||(Qi[i]={}),Qi[i][n]=e}function kr(s,t){return s in Qi&&t in Qi[s]?Qi[s][t]:null}const $s=.9996,ie=.00669438,fr=ie*ie,gr=fr*ie,gi=ie/(1-ie),dl=Math.sqrt(1-ie),on=(1-dl)/(1+dl),Rh=on*on,Qo=Rh*on,ta=Qo*on,Sh=ta*on,wh=1-ie/4-3*fr/64-5*gr/256,Zu=3*ie/8+3*fr/32+45*gr/1024,Ku=15*fr/256+45*gr/1024,Hu=35*gr/3072,qu=3/2*on-27/32*Qo+269/512*Sh,Ju=21/16*Rh-55/32*ta,Qu=151/96*Qo-417/128*Sh,td=1097/512*ta,Ws=6378137;function ed(s,t,e){const i=s-5e5,o=(e.north?t:t-1e7)/$s/(Ws*wh),a=o+qu*Math.sin(2*o)+Ju*Math.sin(4*o)+Qu*Math.sin(6*o)+td*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-ie*h,m=Math.sqrt(1-ie*h),_=Ws/m,p=(1-ie)/g,y=gi*c**2,T=y*y,x=i/(_*$s),E=x*x,v=E*x,R=v*x,S=R*x,w=S*x,I=a-u/p*(E/2-R/24*(5+3*d+10*y-4*T-9*gi))+w/720*(61+90*d+298*y+45*f-252*gi-3*T);let b=(x-v/6*(1+2*d+y)+S/120*(5-2*y+28*d-3*T+8*gi+24*f))/c;return b=xo(b+Nt(Ph(e.number)),-Math.PI,Math.PI),[Bs(b),Bs(I)]}const fl=-80,gl=84,id=-180,nd=180;function sd(s,t,e){s=xo(s,id,nd),t<fl?t=fl:t>gl&&(t=gl);const i=Nt(t),n=Math.sin(i),r=Math.cos(i),o=n/r,a=o*o,l=a*a,h=Nt(s),c=Ph(e.number),u=Nt(c),d=Ws/Math.sqrt(1-ie*n**2),f=gi*r**2,g=r*xo(h-u,-Math.PI,Math.PI),m=g*g,_=m*g,p=_*g,y=p*g,T=y*g,x=Ws*(wh*i-Zu*Math.sin(2*i)+Ku*Math.sin(4*i)-Hu*Math.sin(6*i)),E=$s*d*(g+_/6*(1-a+f)+y/120*(5-18*a+l+72*f-58*gi))+5e5;let v=$s*(x+d*o*(m/2+p/24*(5-a+9*f+4*f**2)+T/720*(61-58*a+l+600*f-330*gi)));return e.north||(v+=1e7),[E,v]}function Ph(s){return(s-1)*6-180+3}const rd=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Ih(s){let t=0;for(const n of rd){const r=s.match(n);if(r){t=parseInt(r[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 _l(s,t){return function(e,i,n,r){const o=e.length;n=n>1?n:2,r=r??n,i||(n>2?i=e.slice():i=new Array(o));for(let a=0;a<o;a+=r){const l=e[a],h=e[a+1],c=s(l,h,t);i[a]=c[0],i[a+1]=c[1]}return i}}function od(s){return Ih(s)?new Jo({code:s,units:"m"}):null}function ad(s){const t=Ih(s.getCode());return t?{forward:_l(sd,t),inverse:_l(ed,t)}:null}const ld=[ad],hd=[od];let So=!0;function Ah(s){So=!1}function ea(s,t){if(t!==void 0){for(let e=0,i=s.length;e<i;++e)t[e]=s[e];t=t}else t=s.slice();return t}function cd(s,t){if(t!==void 0&&s!==t){for(let e=0,i=s.length;e<i;++e)t[e]=s[e];s=t}return s}function wo(s){Vu(s.getCode(),s),kn(s,s,ea)}function ud(s){s.forEach(wo)}function lt(s){if(typeof s!="string")return s;const t=Yu(s);if(t)return t;for(const e of hd){const i=e(s);if(i)return i}return null}function Xs(s,t,e,i){s=lt(s);let n;const r=s.getPointResolutionFunc();if(r){if(n=r(t,e),i&&i!==s.getUnits()){const o=s.getMetersPerUnit();o&&(n=n*o/rn[i])}}else{const o=s.getUnits();if(o=="degrees"&&!i||i=="degrees")n=t;else{const a=Jn(s,lt("EPSG:4326"));if(!a&&o!=="degrees")n=t*s.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);const c=vo(h.slice(0,2),h.slice(2,4)),u=vo(h.slice(4,6),h.slice(6,8));n=(c+u)/2}const l=i?rn[i]:s.getMetersPerUnit();l!==void 0&&(n/=l)}}return n}function ml(s){ud(s),s.forEach(function(t){s.forEach(function(e){t!==e&&kn(t,e,ea)})})}function dd(s,t,e,i){s.forEach(function(n){t.forEach(function(r){kn(n,r,e),kn(r,n,i)})})}function ia(s,t){return s?typeof s=="string"?lt(s):s:lt(t)}function fd(s){return(function(t,e,i,n){const r=t.length;i=i!==void 0?i:2,n=n??i,e=e!==void 0?e:new Array(r);for(let o=0;o<r;o+=n){const a=s(t.slice(o,o+i)),l=a.length;for(let h=0,c=n;h<c;++h)e[o+h]=h>=l?t[o+h]:a[h]}return e})}function Dp(s,t){return Ah(),_r(s,"EPSG:4326","EPSG:3857")}function kp(s,t){const e=_r(s,"EPSG:3857","EPSG:4326"),i=e[0];return(i<-180||i>180)&&(e[0]=Qe(i+180,360)-180),e}function yi(s,t){if(s===t)return!0;const e=s.getUnits()===t.getUnits();return(s.getCode()===t.getCode()||Jn(s,t)===ea)&&e}function Jn(s,t){const e=s.getCode(),i=t.getCode();let n=kr(e,i);if(n)return n;let r=null,o=null;for(const l of ld)r||(r=l(s)),o||(o=l(t));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)n=Nr(r.inverse,o.forward);else{const l=kr(e,a);l&&(n=Nr(l,o.forward))}else{const l=kr(a,i);l&&(n=Nr(r.inverse,l))}return n&&(wo(s),wo(t),kn(s,t,n)),n}function Nr(s,t){return function(e,i,n,r){return i=s(e,i,n,r),t(i,i,n,r)}}function Ri(s,t){const e=lt(s),i=lt(t);return Jn(e,i)}function _r(s,t,e){const i=Ri(t,e);if(!i){const n=lt(t).getCode(),r=lt(e).getCode();throw new Error(`No transform available between ${n} and ${r}`)}return i(s,void 0,s.length)}function gd(s,t,e,i){const n=Ri(t,e);return bu(s,n,void 0,i)}let _d=null;function md(){return _d}function Po(s,t){return s}function le(s,t){return So&&!Us(s,[0,0])&&s[0]>=-180&&s[0]<=180&&s[1]>=-90&&s[1]<=90&&(So=!1,vh("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),s}function na(s,t){return s}function ye(s,t){return s}function pd(){ml(hl),ml(ul),dd(ul,hl,$u,Wu)}pd();const Lh=new Array(6);function _t(){return[1,0,0,1,0,0]}function pl(s){return sa(s,1,0,0,1,0,0)}function mr(s,t){const e=s[0],i=s[1],n=s[2],r=s[3],o=s[4],a=s[5],l=t[0],h=t[1],c=t[2],u=t[3],d=t[4],f=t[5];return s[0]=e*l+n*h,s[1]=i*l+r*h,s[2]=e*c+n*u,s[3]=i*c+r*u,s[4]=e*d+n*f+o,s[5]=i*d+r*f+a,s}function sa(s,t,e,i,n,r,o){return s[0]=t,s[1]=e,s[2]=i,s[3]=n,s[4]=r,s[5]=o,s}function bh(s,t){return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=t[4],s[5]=t[5],s}function ct(s,t){const e=t[0],i=t[1];return t[0]=s[0]*e+s[2]*i+s[4],t[1]=s[1]*e+s[3]*i+s[5],t}function Gr(s,t,e){return mr(s,sa(Lh,t,0,0,e,0,0))}function Fh(s,t,e){return mr(s,sa(Lh,1,0,0,1,t,e))}function ne(s,t,e,i,n,r,o,a){const l=Math.sin(r),h=Math.cos(r);return s[0]=i*h,s[1]=n*l,s[2]=-i*l,s[3]=n*h,s[4]=o*i*h-a*i*l+t,s[5]=o*n*l+a*n*h+e,s}function Nn(s,t){const e=yd(t);H(e!==0,"Transformation matrix cannot be inverted");const i=t[0],n=t[1],r=t[2],o=t[3],a=t[4],l=t[5];return s[0]=o/e,s[1]=-n/e,s[2]=-r/e,s[3]=i/e,s[4]=(r*l-o*a)/e,s[5]=-(i*l-n*a)/e,s}function yd(s){return s[0]*s[3]-s[1]*s[2]}const xd=[1e5,1e5,1e5,1e5,2,2];function Ed(s){return"matrix("+s.join(", ")+")"}function Io(s){return s.substring(7,s.length-1).split(",").map(parseFloat)}function Td(s,t){const e=Io(s),i=Io(t);for(let n=0;n<6;++n)if(Math.round((e[n]-i[n])*xd[n])!==0)return!1;return!0}function Te(s,t,e,i,n,r,o){r=r||[],o=o||2;let a=0;for(let l=t;l<e;l+=i){const h=s[l],c=s[l+1];r[a++]=n[0]*h+n[2]*c+n[4],r[a++]=n[1]*h+n[3]*c+n[5];for(let u=2;u<o;u++)r[a++]=s[l+u]}return r&&r.length!=a&&(r.length=a),r}function ra(s,t,e,i,n,r,o){o=o||[];const a=Math.cos(n),l=Math.sin(n),h=r[0],c=r[1];let u=0;for(let d=t;d<e;d+=i){const f=s[d]-h,g=s[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++]=s[m]}return o&&o.length!=u&&(o.length=u),o}function Cd(s,t,e,i,n,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let u=t;u<e;u+=i){const d=s[u]-l,f=s[u+1]-h;a[c++]=l+n*d,a[c++]=h+r*f;for(let g=u+2;g<u+i;++g)a[c++]=s[g]}return a&&a.length!=c&&(a.length=c),a}function vd(s,t,e,i,n,r,o){o=o||[];let a=0;for(let l=t;l<e;l+=i){o[a++]=s[l]+n,o[a++]=s[l+1]+r;for(let h=l+2;h<l+i;++h)o[a++]=s[h]}return o&&o.length!=a&&(o.length=a),o}const yl=_t(),Rd=[NaN,NaN];class Mh extends re{constructor(){super(),this.extent_=Vt(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=hh((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);const n=this.clone();return n.applyTransform(i),n.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return B()}closestPointXY(t,e,i,n){return B()}containsXY(t,e){return this.closestPointXY(t,e,Rd,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 B()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&cn(e),this.extentRevision_=this.getRevision()}return Au(this.extent_,t)}rotate(t,e){B()}scale(t,e,i){B()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return B()}getType(){return B()}applyTransform(t){B()}intersectsExtent(t){return B()}translate(t,e){B()}transform(t,e){const i=lt(t),n=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=Lt(h)/Lt(l);ne(yl,h[0],h[3],c,-c,0,0,0);const u=Te(r,0,r.length,a,yl,o),d=Ri(i,e);return d?d(u,u,a):u}:Ri(i,e);return this.applyTransform(n),this}}class oi extends Mh{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Zo(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return B()}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;const 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=js(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){B()}setLayout(t,e,i){let n;if(t)n=js(t);else{for(let r=0;r<i;++r){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}n=e.length,t=Ai(n)}this.layout=t,this.stride=n}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();ra(i,0,i.length,n,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=ii(this.getExtent()));const n=this.getFlatCoordinates();if(n){const r=this.getStride();Cd(n,0,n.length,r,t,e,i,n),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();vd(i,0,i.length,n,t,e,i),this.changed()}}}function Ai(s){let t;return s==2?t="XY":s==3?t="XYZ":s==4&&(t="XYZM"),t}function js(s){let t;return s=="XY"?t=2:s=="XYZ"||s=="XYM"?t=3:s=="XYZM"&&(t=4),t}function Sd(s,t,e){const i=s.getFlatCoordinates();if(!i)return null;const n=s.getStride();return Te(i,0,i.length,n,t,e)}function Oh(s,t,e,i){let n=0;const r=s[e-i],o=s[e-i+1];let a=0,l=0;for(;t<e;t+=i){const h=s[t]-r,c=s[t+1]-o;n+=l*h-a*c,a=h,l=c}return n/2}function Dh(s,t,e,i){let n=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];n+=Oh(s,t,a,i),t=a}return n}function wd(s,t,e,i){let n=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];n+=Dh(s,t,a,i),t=a[a.length-1]}return n}function xl(s,t,e,i,n,r,o){const a=s[t],l=s[t+1],h=s[e]-a,c=s[e+1]-l;let u;if(h===0&&c===0)u=t;else{const d=((n-a)*h+(r-l)*c)/(h*h+c*c);if(d>1)u=e;else if(d>0){for(let f=0;f<i;++f)o[f]=Ut(s[t+f],s[e+f],d);o.length=i;return}else u=t}for(let d=0;d<i;++d)o[d]=s[u+d];o.length=i}function oa(s,t,e,i,n){let r=s[t],o=s[t+1];for(t+=i;t<e;t+=i){const a=s[t],l=s[t+1],h=ke(r,o,a,l);h>n&&(n=h),r=a,o=l}return n}function aa(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];n=oa(s,t,a,i,n),t=a}return n}function Pd(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];n=aa(s,t,a,i,n),t=a[a.length-1]}return n}function la(s,t,e,i,n,r,o,a,l,h,c){if(t==e)return h;let u,d;if(n===0){if(d=ke(o,a,s[t],s[t+1]),d<h){for(u=0;u<i;++u)l[u]=s[t+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=t+i;for(;f<e;)if(xl(s,f-i,f,i,o,a,c),d=ke(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(r&&(xl(s,e-i,t,i,o,a,c),d=ke(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 ha(s,t,e,i,n,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=la(s,t,f,i,n,r,o,a,l,h,c),t=f}return h}function Id(s,t,e,i,n,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=ha(s,t,f,i,n,r,o,a,l,h,c),t=f[f.length-1]}return h}function kh(s,t,e,i){for(let n=0,r=e.length;n<r;++n)s[t++]=e[n];return t}function pr(s,t,e,i){for(let n=0,r=e.length;n<r;++n){const o=e[n];for(let a=0;a<i;++a)s[t++]=o[a]}return t}function Qn(s,t,e,i,n){n=n||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=pr(s,t,e[o],i);n[r++]=l,t=l}return n.length=r,n}function Nh(s,t,e,i,n){n=n||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=Qn(s,t,e[o],i,n[r]);l.length===0&&(l[0]=t),n[r++]=l,t=l[l.length-1]}return n.length=r,n}function Ke(s,t,e,i,n){n=n!==void 0?n:[];let r=0;for(let o=t;o<e;o+=i)n[r++]=s.slice(o,o+i);return n.length=r,n}function Gn(s,t,e,i,n){n=n!==void 0?n:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];n[r++]=Ke(s,t,l,i,n[r]),t=l}return n.length=r,n}function Ao(s,t,e,i,n){n=n!==void 0?n:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];n[r++]=l.length===1&&l[0]===t?[]:Gn(s,t,l,i,n[r]),t=l[l.length-1]}return n.length=r,n}function yr(s,t,e,i,n,r,o){const a=(e-t)/i;if(a<3){for(;t<e;t+=i)r[o++]=s[t],r[o++]=s[t+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[t,e-i];let c=0;for(;h.length>0;){const u=h.pop(),d=h.pop();let f=0;const g=s[d],m=s[d+1],_=s[u],p=s[u+1];for(let y=d+i;y<u;y+=i){const T=s[y],x=s[y+1],E=vu(T,x,g,m,_,p);E>f&&(c=y,f=E)}f>n&&(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]&&(r[o++]=s[t+u*i],r[o++]=s[t+u*i+1]);return o}function Gh(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=yr(s,t,c,i,n,r,o),a.push(o),t=c}return o}function di(s,t){return t*Math.round(s/t)}function Ad(s,t,e,i,n,r,o){if(t==e)return o;let a=di(s[t],n),l=di(s[t+1],n);t+=i,r[o++]=a,r[o++]=l;let h,c;do if(h=di(s[t],n),c=di(s[t+1],n),t+=i,t==e)return r[o++]=h,r[o++]=c,o;while(h==a&&c==l);for(;t<e;){const u=di(s[t],n),d=di(s[t+1],n);if(t+=i,u==h&&d==c)continue;const f=h-a,g=c-l,m=u-a,_=d-l;if(f*_==g*m&&(f<0&&m<f||f==m||f>0&&m>f)&&(g<0&&_<g||g==_||g>0&&_>g)){h=u,c=d;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=u,c=d}return r[o++]=h,r[o++]=c,o}function ca(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=Ad(s,t,c,i,n,r,o),a.push(o),t=c}return o}function Ld(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l],u=[];o=ca(s,t,c,i,n,r,o,u),a.push(u),t=c[c.length-1]}return o}class Bn extends oi{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 Bn(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,n){return n<Ii(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(oa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),la(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,n))}getArea(){return Oh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Ke(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=yr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Bn(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=pr(this.flatCoordinates,0,t,this.stride),this.changed()}}class Ce extends oi{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new Ce(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){const r=this.flatCoordinates,o=ke(t,e,r[0],r[1]);if(o<n){const a=this.stride;for(let l=0;l<a;++l)i[l]=r[l];return i.length=a,o}return n}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return gh(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return Vo(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=kh(this.flatCoordinates,0,t,this.stride),this.changed()}}function bd(s,t,e,i,n){return!Ko(n,function(o){return!_i(s,t,e,i,o[0],o[1])})}function _i(s,t,e,i,n,r){let o=0,a=s[e-i],l=s[e-i+1];for(;t<e;t+=i){const h=s[t],c=s[t+1];l<=r?c>r&&(h-a)*(r-l)-(n-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(n-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function ua(s,t,e,i,n,r){if(e.length===0||!_i(s,t,e[0],i,n,r))return!1;for(let o=1,a=e.length;o<a;++o)if(_i(s,e[o-1],e[o],i,n,r))return!1;return!0}function Fd(s,t,e,i,n,r){if(e.length===0)return!1;for(let o=0,a=e.length;o<a;++o){const l=e[o];if(ua(s,t,l,i,n,r))return!0;t=l[l.length-1]}return!1}function da(s,t,e,i,n,r,o){let a,l,h,c,u,d,f;const g=n[r+1],m=[];for(let y=0,T=e.length;y<T;++y){const x=e[y];for(c=s[x-i],d=s[x-i+1],a=t;a<x;a+=i)u=s[a],f=s[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 _=NaN,p=-1/0;for(m.sort(Ee),c=m[0],a=1,l=m.length;a<l;++a){u=m[a];const y=Math.abs(u-c);y>p&&(h=(c+u)/2,ua(s,t,e,i,h,g)&&(_=h,p=y)),c=u}return isNaN(_)&&(_=n[r]),o?(o.push(_,g,p),o):[_,g,p]}function Bh(s,t,e,i,n){let r=[];for(let o=0,a=e.length;o<a;++o){const l=e[o];r=da(s,t,l,i,n,2*o,r),t=l[l.length-1]}return r}function zh(s,t,e,i,n){let r;for(t+=i;t<e;t+=i)if(r=n(s.slice(t-i,t),s.slice(t,t+i)),r)return r;return!1}function xr(s,t,e,i,n,r){return r=r??mh(Vt(),s,t,e,i),ft(n,r)?r[0]>=n[0]&&r[2]<=n[2]||r[1]>=n[1]&&r[3]<=n[3]?!0:zh(s,t,e,i,function(o,a){return Lu(n,o,a)}):!1}function Md(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){if(xr(s,t,e[r],i,n))return!0;t=e[r]}return!1}function Uh(s,t,e,i,n){return!!(xr(s,t,e,i,n)||_i(s,t,e,i,n[0],n[1])||_i(s,t,e,i,n[0],n[3])||_i(s,t,e,i,n[2],n[1])||_i(s,t,e,i,n[2],n[3]))}function $h(s,t,e,i,n){if(!Uh(s,t,e[0],i,n))return!1;if(e.length===1)return!0;for(let r=1,o=e.length;r<o;++r)if(bd(s,e[r-1],e[r],i,n)&&!xr(s,e[r-1],e[r],i,n))return!1;return!0}function Od(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];if($h(s,t,a,i,n))return!0;t=a[a.length-1]}return!1}function Dd(s,t,e,i){for(;t<e-i;){for(let n=0;n<i;++n){const r=s[t+n];s[t+n]=s[e-i+n],s[e-i+n]=r}t+=i,e-=i}}function fa(s,t,e,i){let n=0,r=s[e-i],o=s[e-i+1];for(;t<e;t+=i){const a=s[t],l=s[t+1];n+=(a-r)*(l+o),r=a,o=l}return n===0?void 0:n>0}function ga(s,t,e,i,n){n=n!==void 0?n:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=fa(s,t,a,i);if(r===0){if(n&&l||!n&&!l)return!1}else if(n&&!l||!n&&l)return!1;t=a}return!0}function Wh(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(!ga(s,t,a,i,n))return!1;a.length&&(t=a[a.length-1])}return!0}function Ys(s,t,e,i,n){n=n!==void 0?n:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=fa(s,t,a,i);(r===0?n&&l||!n&&!l:n&&!l||!n&&l)&&Dd(s,t,a,i),t=a}return t}function Lo(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r)t=Ys(s,t,e[r],i,n);return t}function Xh(s,t){const e=[];let i=0,n=0,r;for(let o=0,a=t.length;o<a;++o){const l=t[o],h=fa(s,i,l,2);if(r===void 0&&(r=h),h===r)e.push(t.slice(n,o+1));else{if(e.length===0)continue;e[e.length-1].push(t[n])}n=o+1,i=l}return e}class Zt extends oi{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?Yt(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Zt(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<Ii(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(aa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ha(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return ua(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return Dh(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Ys(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Gn(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=ii(this.getExtent());this.flatInteriorPoint_=da(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new Ce(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new Bn(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,i=this.ends_,n=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o],h=new Bn(e.slice(r,l),t);n.push(h),r=l}return n}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;ga(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Ys(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=ca(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new Zt(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return $h(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Qn(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function kd(s,t,e,i){e=e||32;const n=[];for(let r=0;r<e;++r)Yt(n,Bu(s,t,2*Math.PI*r/e,i));return n.push(n[0],n[1]),new Zt(n,"XY",[n.length])}function El(s){if(un(s))throw new Error("Cannot create polygon from empty extent");const t=s[0],e=s[1],i=s[2],n=s[3],r=[t,e,t,n,i,n,i,e,t,e];return new Zt(r,"XY",[r.length])}function Np(s,t,e){t=t||32;const i=s.getStride(),n=s.getLayout(),r=s.getCenter(),o=i*(t+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]=r[u]}const l=[a.length],h=new Zt(a,n,l);return Nd(h,r,s.getRadius(),e),h}function Nd(s,t,e,i){const n=s.getFlatCoordinates(),r=s.getStride(),o=n.length/r-1,a=i||0;for(let l=0;l<=o;++l){const h=l*r,c=a+Qe(l,o)*2*Math.PI/o;n[h]=t[0]+e*Math.cos(c),n[h+1]=t[1]+e*Math.sin(c)}s.changed()}function _a(s,t,e,i){const n=it(t)/e[0],r=Lt(t)/e[1];return i?Math.min(s,Math.max(n,r)):Math.min(s,Math.min(n,r))}function ma(s,t,e){let i=Math.min(s,t);const n=50;return i*=Math.log(1+n*Math.max(0,s/t-1))/n+1,e&&(i=Math.max(i,e),i/=Math.log(1+n*Math.max(0,e/s-1))/n+1),ot(i,e/2,t*2)}function Gd(s,t,e,i){return t=t!==void 0?t:!0,(function(n,r,o,a){if(n!==void 0){const l=s[0],h=s[s.length-1],c=e?_a(l,e,o,i):l;if(a)return t?ma(n,c,h):ot(n,h,c);const u=Math.min(c,n),d=Math.floor(Yo(s,u,r));return s[d]>c&&d<s.length-1?s[d+1]:s[d]}})}function Bd(s,t,e,i,n,r){return i=i!==void 0?i:!0,e=e!==void 0?e:0,(function(o,a,l,h){if(o!==void 0){const c=n?_a(t,n,l,r):t;if(h)return i?ma(o,c,e):ot(o,e,c);const u=1e-9,d=Math.ceil(Math.log(t/c)/Math.log(s)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),m=Math.floor(Math.log(t/g)/Math.log(s)+f),_=Math.max(d,m),p=t/Math.pow(s,_);return ot(p,e,c)}})}function Tl(s,t,e,i,n){return e=e!==void 0?e:!0,(function(r,o,a,l){if(r!==void 0){const h=i?_a(s,i,a,n):s;return!e||!l?ot(r,t,h):ma(r,h,t)}})}function pa(s){if(s!==void 0)return 0}function Cl(s){if(s!==void 0)return s}function zd(s){const t=2*Math.PI/s;return(function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e})}function Ud(s){const t=Nt(5);return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}const $d=42,ya=256,Br=0;class De extends re{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=ia(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&&Ah(),t.center&&(t.center=le(t.center,this.projection_)),t.extent&&(t.extent=ye(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const a in ae)delete e[a];this.setProperties(e,!0);const i=Xd(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;const n=Wd(t),r=i.constraint,o=jd(t);this.constraints_={center:n,resolution:r,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;const i=this.getCenterInternal();if(i){const n=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),o=r/2*(n[3]-e[3]+e[1]-n[1]),a=r/2*(n[0]-e[0]+e[2]-n[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(t){const 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);const e=new Array(arguments.length);for(let i=0;i<e.length;++i){let n=arguments[i];n.center&&(n=Object.assign({},n),n.center=le(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=le(n.anchor,this.getProjection())),e[i]=n}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 n=0;for(;n<e&&!this.isDef();++n){const 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===e){i&&gs(i,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const h=[];for(;n<e;++n){const c=arguments[n],u={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||Du,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;const d=Qe(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}Yd(u)?u.complete=!0:r+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(rt.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[rt.ANIMATING]>0}getInteracting(){return this.hints_[rt.INTERACTING]>0}cancelAnimations(){this.setHint(rt.ANIMATING,-this.hints_[rt.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){const n=this.animations_[e];if(n[0].callback&&gs(n[0].callback,!1),!t)for(let r=0,o=n.length;r<o;++r){const a=n[r];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;const t=Date.now();let e=!1;for(let i=this.animations_.length-1;i>=0;--i){const n=this.animations_[i];let r=!0;for(let o=0,a=n.length;o<a;++o){const l=n[o];if(l.complete)continue;const h=t-l.start;let c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],m=l.targetCenter[1];this.nextCenter_=l.targetCenter;const _=d+u*(g-d),p=f+u*(m-f);this.targetCenter_=[_,p]}if(l.sourceResolution&&l.targetResolution){const d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const 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){const d=u===1?Qe(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const 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(r){this.animations_[i]=null,this.setHint(rt.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=n[0].callback;o&&gs(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;const n=this.getCenterInternal();return n!==void 0&&(i=[n[0]-e[0],n[1]-e[1]],Ho(i,t-this.getRotation()),Fu(i,e)),i}calculateCenterZoom(t,e){let i;const n=this.getCenterInternal(),r=this.getResolution();if(n!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-n[0])/r,a=e[1]-t*(e[1]-n[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],n=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(n*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(n*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t&&Po(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){const e=this.calculateExtentInternal(t);return na(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();H(e,"The view center is not defined");const i=this.getResolution();H(i!==void 0,"The view resolution is not defined");const n=this.getRotation();return H(n!==void 0,"The view rotation is not defined"),Co(e,i,n,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(ye(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=it(t)/e[0],n=Lt(t)/e[1];return Math.max(i,n)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,n=Math.log(e/i)/Math.log(t);return(function(r){return e/Math.pow(t,r*n)})}getRotation(){return this.get(ae.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,r=Math.log(i/n)/e;return(function(o){return Math.log(i/o)/e/r})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let n=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();n=zr(n,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:n.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;const e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,n;if(this.resolutions_){const r=Yo(this.resolutions_,t,1);e=r,i=this.resolutions_[r],r==this.resolutions_.length-1?n=2:n=i/this.resolutions_[r+1]}else i=this.maxResolution_,n=this.zoomFactor_;return e+Math.log(i/t)/Math.log(n)}getResolutionForZoom(t){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const e=ot(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,ot(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(H(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){H(!un(t),"Cannot fit empty extent provided as `geometry`");const n=ye(t,this.getProjection());i=El(n)}else if(t.getType()==="Circle"){const n=ye(t.getExtent(),this.getProjection());i=El(n),i.rotate(this.getRotation(),ii(n))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),n=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*i-r[u+1]*n,g=r[u]*n+r[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_());const n=e.padding!==void 0?e.padding:[0,0,0,0],r=e.nearest!==void 0?e.nearest:!1;let o;e.minResolution!==void 0?o=e.minResolution:e.maxZoom!==void 0?o=this.getResolutionForZoom(e.maxZoom):o=0;const a=this.rotatedExtentForGeometry(t);let 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,r?0:1);const h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=ii(a);d[0]+=(n[1]-n[3])/2*l,d[1]+=(n[0]-n[2])/2*l;const f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,m=this.getConstrainedCenter([f,g],l),_=e.callback?e.callback:Dn;e.duration!==void 0?this.animateInternal({resolution:l,center:m,duration:e.duration,easing:e.easing},_):(this.targetResolution_=l,this.targetCenter_=m,this.applyTargetState_(!1,!0),gs(_,!0))}centerOn(t,e,i){this.centerOnInternal(le(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(zr(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,n){let r;const o=this.padding_;if(o&&t){const a=this.getViewportSizeMinusPadding_(-i),l=zr(t,n,[a[0]/2+o[3],a[1]/2+o[0]],e,i);r=[t[0]-l[0],t[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){const e=Po(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){const e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&le(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const i=this.getAnimating()||this.getInteracting(),n=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,n,i);e&&(this.targetCenter_=this.calculateCenterZoom(r,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=le(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const i=this.getAnimating()||this.getInteracting(),n=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(n,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&le(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){const i=this.getAnimating()||this.getInteracting()||e,n=this.constraints_.rotation(this.targetRotation_,i),r=this.getViewportSize_(n),o=this.constraints_.resolution(this.targetResolution_,0,r,i),a=this.constraints_.center(this.targetCenter_,o,r,i,this.calculateCenterShift(this.targetCenter_,o,n,r));this.get(ae.ROTATION)!==n&&this.set(ae.ROTATION,n),this.get(ae.RESOLUTION)!==o&&(this.set(ae.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(ae.CENTER)||!Us(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;const n=e||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,n,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!Us(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:t,easing:dn,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(rt.INTERACTING,1)}endInteraction(t,e,i){i=i&&le(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(rt.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){const i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){const i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;const i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}}function gs(s,t){setTimeout(function(){s(t)},0)}function Wd(s){if(s.extent!==void 0){const e=s.smoothExtentConstraint!==void 0?s.smoothExtentConstraint:!0;return ll(s.extent,s.constrainOnlyCenter,e)}const t=ia(s.projection,"EPSG:3857");if(s.multiWorld!==!0&&t.isGlobal()){const e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,ll(e,!1,!1)}return Su}function Xd(s){let t,e,i,o=s.minZoom!==void 0?s.minZoom:Br,a=s.maxZoom!==void 0?s.maxZoom:28;const l=s.zoomFactor!==void 0?s.zoomFactor:2,h=s.multiWorld!==void 0?s.multiWorld:!1,c=s.smoothResolutionConstraint!==void 0?s.smoothResolutionConstraint:!0,u=s.showFullExtent!==void 0?s.showFullExtent:!1,d=ia(s.projection,"EPSG:3857"),f=d.getExtent();let g=s.constrainOnlyCenter,m=s.extent;if(!h&&!m&&d.isGlobal()&&(g=!1,m=f),s.resolutions!==void 0){const _=s.resolutions;e=_[o],i=_[a]!==void 0?_[a]:_[_.length-1],s.constrainResolution?t=Gd(_,c,!g&&m,u):t=Tl(e,i,c,!g&&m,u)}else{const p=(f?Math.max(it(f),Lt(f)):360*rn.degrees/d.getMetersPerUnit())/ya/Math.pow(2,Br),y=p/Math.pow(2,28-Br);e=s.maxResolution,e!==void 0?o=0:e=p/Math.pow(l,o),i=s.minResolution,i===void 0&&(s.maxZoom!==void 0?s.maxResolution!==void 0?i=e/Math.pow(l,a):i=p/Math.pow(l,a):i=y),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),s.constrainResolution?t=Bd(l,e,i,c,!g&&m,u):t=Tl(e,i,c,!g&&m,u)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function jd(s){if(s.enableRotation!==void 0?s.enableRotation:!0){const e=s.constrainRotation;return e===void 0||e===!0?Ud():e===!1?Cl:typeof e=="number"?zd(e):Cl}return pa}function Yd(s){return!(s.sourceCenter&&s.targetCenter&&!Us(s.sourceCenter,s.targetCenter)||s.sourceResolution!==s.targetResolution||s.sourceRotation!==s.targetRotation)}function zr(s,t,e,i,n){const r=Math.cos(-n);let o=Math.sin(-n),a=s[0]*r-s[1]*o,l=s[1]*r+s[0]*o;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,o=-o;const h=a*r-l*o,c=l*r+a*o;return[h,c]}const _s="ol-hidden",Vd="ol-selectable",ts="ol-unselectable",xa="ol-control",vl="ol-collapsed",Zd=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"),Rl=["style","variant","weight","size","lineHeight","family"],bo={normal:400,bold:700},Fo=function(s){const t=s.match(Zd);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,n=Rl.length;i<n;++i){const r=t[i+1];r!==void 0&&(e[Rl[i]]=typeof r=="string"?r.trim():r)}return isNaN(Number(e.weight))&&e.weight in bo&&(e.weight=bo[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e};function mt(s,t,e,i){let n;return e&&e.length?n=e.shift():jt?n=new class extends OffscreenCanvas{style={}}(s??300,t??150):n=document.createElement("canvas"),s&&(n.width=s),t&&(n.height=t),n.getContext("2d",i)}let Ur;function Vs(){return Ur||(Ur=mt(1,1)),Ur}function Er(s){const t=s.canvas;t.width=1,t.height=1,s.clearRect(0,0,1,1)}function Kd(s){let t=s.offsetWidth;const e=getComputedStyle(s);return t+=parseInt(e.marginLeft,10)+parseInt(e.marginRight,10),t}function Hd(s){let t=s.offsetHeight;const e=getComputedStyle(s);return t+=parseInt(e.marginTop,10)+parseInt(e.marginBottom,10),t}function Sl(s,t){const e=t.parentNode;e&&e.replaceChild(s,t)}function jh(s){for(;s.lastChild;)s.lastChild.remove()}function qd(s,t){const e=s.childNodes;for(let i=0;;++i){const n=e[i],r=t[i];if(!n&&!r)break;if(n!==r){if(!n){s.appendChild(r);continue}if(!r){s.removeChild(n),--i;continue}s.insertBefore(r,n)}}}function Yh(){return new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){const 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){const 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 He(s){return typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}class Tr extends re{constructor(t){super();const 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)st(this.listenerKeys[e]);if(this.listenerKeys.length=0,this.map_=t,t){const e=this.target_??t.getOverlayContainerStopEvent();this.element&&e.appendChild(this.element),this.render!==Dn&&this.listenerKeys.push(Z(t,Fe.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}}class Jd extends Tr{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;const e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",n=t.expandClassName!==void 0?t.expandClassName:e+"-expand",r=t.collapseLabel!==void 0?t.collapseLabel:"",o=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=n):this.label_=a;const 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(X.CLICK,this.handleClick_.bind(this),!1);const h=e+" "+ts+" "+xa+(this.collapsed_&&this.collapsible_?" "+vl:"")+(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){const e=this.getMap().getAllLayers(),i=new Set(e.flatMap(n=>n.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(n=>i.add(n)):i.add(this.attributions_)),!this.overrideCollapsible_){const n=!e.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(n)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const e=await Promise.all(this.collectSourceAttributions_(t).map(n=>du(()=>n))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!ze(e,this.renderedAttributions_)){jh(this.ulElement_);for(let n=0,r=e.length;n<r;++n){const o=document.createElement("li");o.innerHTML=e[n],this.ulElement_.appendChild(o)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(vl),this.collapsed_?Sl(this.collapseLabel_,this.label_):Sl(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)}}class Qd extends Tr{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});const e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"⇧",n=t.compassClassName!==void 0?t.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));const r=t.tipLabel?t.tipLabel:"Reset rotation",o=document.createElement("button");o.className=e+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(X.CLICK,this.handleClick_.bind(this),!1);const a=e+" "+ts+" "+xa,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(_s)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const e=this.getMap().getView();if(!e)return;const i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:dn}):e.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const n="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(_s);!r&&i===0?this.element.classList.add(_s):r&&i!==0&&this.element.classList.remove(_s)}this.label_.style.transform=n}this.rotation_=i}}class tf extends Tr{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,n=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",r=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",o=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",h=t.zoomOutTipLabel!==void 0?t.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(X.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(X.CLICK,this.handleClick_.bind(this,-i),!1);const d=e+" "+ts+" "+xa,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){const i=this.getMap().getView();if(!i)return;const n=i.getZoom();if(n!==void 0){const r=i.getConstrainedZoom(n+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:dn})):i.setZoom(r)}}}function ef(s){s=s||{};const t=new Xt;return(s.zoom!==void 0?s.zoom:!0)&&t.push(new tf(s.zoomOptions)),(s.rotate!==void 0?s.rotate:!0)&&t.push(new Qd(s.rotateOptions)),(s.attribution!==void 0?s.attribution:!0)&&t.push(new Jd(s.attributionOptions)),t}class nf{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;const 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;const n=this.points_[e+2]-this.points_[i+2];if(n<1e3/60)return!1;const r=this.points_[e]-this.points_[i],o=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/n,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}const Mo={ACTIVE:"active"};class fn extends re{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(Mo.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Mo.ACTIVE,t)}setMap(t){this.map_=t}}function sf(s,t,e){const i=s.getCenterInternal();if(i){const n=[i[0]+t[0],i[1]+t[1]];s.animateInternal({duration:e!==void 0?e:250,easing:ku,center:s.getConstrainedCenter(n)})}}function Ea(s,t,e,i){const n=s.getZoom();if(n===void 0)return;const r=s.getConstrainedZoom(n+t),o=s.getResolutionForZoom(r);s.getAnimating()&&s.cancelAnimations(),s.animate({resolution:o,anchor:e,duration:i!==void 0?i:250,easing:dn})}class rf extends fn{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==J.DBLCLICK){const i=t.originalEvent,n=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=n.getView();Ea(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}function Oo(s){const t=arguments;return function(e){let i=!0;for(let n=0,r=t.length;n<r&&(i=i&&t[n](e),!!i);++n);return i}}const Gp=function(s){const t=s.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},of=function(s){const t=s.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},af=function(s){const t=s.map.getTargetElement(),e=t.getRootNode(),i=s.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},Vh=function(s){const t=s.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?af(s):!0},Os=ei,Bp=function(s){return s.type==J.CLICK},Zh=function(s){const t=s.originalEvent;return"pointerId"in t&&t.button==0&&!(pu&&ch&&t.ctrlKey)},Do=hn,lf=function(s){return s.type==J.SINGLECLICK},Ta=function(s){const t=s.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},hf=function(s){const t=s.originalEvent;return ch?t.metaKey:t.ctrlKey},Zs=function(s){const t=s.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Kh=function(s){const t=s.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},$r=function(s){const t=s.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"},cf=function(s){const t=s.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};class gn extends fn{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==J.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==J.POINTERUP){const i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==J.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==J.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 Ca(s){const t=s.length;let e=0,i=0;for(let n=0;n<t;n++)e+=s[n].clientX,i+=s[n].clientY;return{clientX:e/t,clientY:i/t}}class uf extends gn{constructor(t){super({stopDown:hn}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:Oo(Ta,cf);this.condition_=t.onFocusOnly?Oo(Vh,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const i=this.targetPointers,n=e.getEventPixel(Ca(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(n[0],n[1]),this.lastCentroid){const r=[this.lastCentroid[0]-n[0],n[1]-this.lastCentroid[1]],a=t.map.getView();Mu(r,a.getResolution()),Ho(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=n,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const n=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-n*Math.cos(r),a[1]-n*Math.sin(r)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:dn})}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)){const 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}}class df extends gn{constructor(t){t=t||{},super({stopDown:hn}),this.condition_=t.condition?t.condition:of,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!$r(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===pa)return;const n=e.getSize(),r=t.pixel,o=Math.atan2(n[1]/2-r[1],r[0]-n[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(t){return $r(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return $r(t)&&Zh(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class ff extends Zn{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_(){const t=this.startPixel_,e=this.endPixel_,i="px",n=this.element_.style;n.left=Math.min(t[0],e[0])+i,n.top=Math.min(t[1],e[1])+i,n.width=Math.abs(e[0]-t[0])+i,n.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const 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;const t=this.startPixel_,e=this.endPixel_,n=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);n[4]=n[0].slice(),this.geometry_?this.geometry_.setCoordinates([n]):this.geometry_=new Zt([n])}getGeometry(){return this.geometry_}}const ki={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class Cn extends se{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class gf extends gn{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new ff(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??Zh,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const n=i[0]-e[0],r=i[1]-e[1];return n*n+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new Cn(ki.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new Cn(e?ki.BOXEND:ki.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 Cn(ki.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Cn(ki.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Cn(ki.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class _f extends gf{constructor(t){t=t||{};const e=t.condition?t.condition:Zs;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){const i=this.getMap().getView();let n=this.getGeometry();if(this.out_){const r=i.rotatedExtentForGeometry(n),o=i.getResolutionForExtentInternal(r),a=i.getResolution()/o;n=n.clone(),n.scale(a*a)}i.fitInternal(n,{duration:this.duration_,easing:dn})}}const ui={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class mf extends fn{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return Ta(e)&&Kh(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==X.KEYDOWN){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==ui.DOWN||n==ui.LEFT||n==ui.RIGHT||n==ui.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;n==ui.DOWN?h=-a:n==ui.LEFT?l=-a:n==ui.RIGHT?l=a:h=a;const c=[l,h];Ho(c,o.getRotation()),sf(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}}class pf extends fn{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!hf(e)&&Kh(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==X.KEYDOWN||t.type==X.KEYPRESS){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==="+"||n==="-")){const r=t.map,o=n==="+"?this.delta_:-this.delta_,a=r.getView();Ea(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}const yf=40,xf=300;class Ef extends fn{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;const e=t.condition?t.condition:Os;this.condition_=t.onFocusOnly?Oo(Vh,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;const 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!==X.WHEEL)return!0;const i=t.map,n=t.originalEvent;n.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel);let r=n.deltaY;switch(n.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=yf;break;case WheelEvent.DOM_DELTA_PAGE:r*=xf;break}if(r===0)return!1;this.lastDelta_=r;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const 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(-r/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=o,!1;this.totalDelta_+=r;const 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){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-ot(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Ea(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)}}class Tf extends gn{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=hn),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;const i=this.targetPointers[0],n=this.targetPointers[1],r=Math.atan2(n.clientY-i.clientY,n.clientX-i.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=l}this.lastAngle_=r;const o=t.map,a=o.getView();a.getConstraints().rotation!==pa&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Ca(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){const 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}}class Cf extends gn{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=hn),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;const i=this.targetPointers[0],n=this.targetPointers[1],r=i.clientX-n.clientX,o=i.clientY-n.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(e=this.lastDistance_/a),this.lastDistance_=a;const l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Ca(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const i=t.map.getView(),n=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,n),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}function vf(s){s=s||{};const t=new Xt,e=new nf(-.005,.05,100);return(s.altShiftDragRotate!==void 0?s.altShiftDragRotate:!0)&&t.push(new df),(s.doubleClickZoom!==void 0?s.doubleClickZoom:!0)&&t.push(new rf({delta:s.zoomDelta,duration:s.zoomDuration})),(s.dragPan!==void 0?s.dragPan:!0)&&t.push(new uf({onFocusOnly:s.onFocusOnly,kinetic:e})),(s.pinchRotate!==void 0?s.pinchRotate:!0)&&t.push(new Tf),(s.pinchZoom!==void 0?s.pinchZoom:!0)&&t.push(new Cf({duration:s.zoomDuration})),(s.keyboard!==void 0?s.keyboard:!0)&&(t.push(new mf),t.push(new pf({delta:s.zoomDelta,duration:s.zoomDuration}))),(s.mouseWheelZoom!==void 0?s.mouseWheelZoom:!0)&&t.push(new Ef({onFocusOnly:s.onFocusOnly,duration:s.zoomDuration})),(s.shiftDragZoom!==void 0?s.shiftDragZoom:!0)&&t.push(new _f({duration:s.zoomDuration})),t}const et={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"};class Hh extends re{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[et.OPACITY]=t.opacity!==void 0?t.opacity:1,H(typeof e[et.OPACITY]=="number","Layer opacity must be a number"),e[et.VISIBLE]=t.visible!==void 0?t.visible:!0,e[et.Z_INDEX]=t.zIndex,e[et.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[et.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[et.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[et.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){const e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=ot(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 B()}getLayerStatesArray(t){return B()}getExtent(){return this.get(et.EXTENT)}getMaxResolution(){return this.get(et.MAX_RESOLUTION)}getMinResolution(){return this.get(et.MIN_RESOLUTION)}getMinZoom(){return this.get(et.MIN_ZOOM)}getMaxZoom(){return this.get(et.MAX_ZOOM)}getOpacity(){return this.get(et.OPACITY)}getSourceState(){return B()}getVisible(){return this.get(et.VISIBLE)}getZIndex(){return this.get(et.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(et.EXTENT,t)}setMaxResolution(t){this.set(et.MAX_RESOLUTION,t)}setMinResolution(t){this.set(et.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(et.MAX_ZOOM,t)}setMinZoom(t){this.set(et.MIN_ZOOM,t)}setOpacity(t){H(typeof t=="number","Layer opacity must be a number"),this.set(et.OPACITY,t)}setVisible(t){this.set(et.VISIBLE,t)}setZIndex(t){this.set(et.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}const $e={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class Ve extends se{constructor(t,e){super(t),this.layer=e}}const Wr={LAYERS:"layers"};class _n extends Hh{constructor(t){t=t||{};const 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(Wr.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new Xt(i.slice(),{unique:!0}):H(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new Xt(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(st),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(Z(t,Tt.ADD,this.handleLayersAdd_,this),Z(t,Tt.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(st);Pi(this.listenerKeys_);const e=t.getArray();for(let i=0,n=e.length;i<n;i++){const r=e[i];this.registerLayerListeners_(r),this.dispatchEvent(new Ve($e.ADDLAYER,r))}this.changed()}registerLayerListeners_(t){const e=[Z(t,nn.PROPERTYCHANGE,this.handleLayerChange_,this),Z(t,X.CHANGE,this.handleLayerChange_,this)];t instanceof _n&&e.push(Z(t,$e.ADDLAYER,this.handleLayerGroupAdd_,this),Z(t,$e.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[k(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new Ve($e.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Ve($e.REMOVELAYER,t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Ve($e.ADDLAYER,e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=k(e);this.listenerKeys_[i].forEach(st),delete this.listenerKeys_[i],this.dispatchEvent(new Ve($e.REMOVELAYER,e)),this.changed()}getLayers(){return this.get(Wr.LAYERS)}setLayers(t){const e=this.getLayers();if(e){const i=e.getArray();for(let n=0,r=i.length;n<r;++n)this.dispatchEvent(new Ve($e.REMOVELAYER,i[n]))}this.set(Wr.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){const e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(e)});const n=this.getLayerState();let r=n.zIndex;!t&&n.zIndex===void 0&&(r=0);for(let o=i,a=e.length;o<a;o++){const l=e[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=Ne(l.extent,n.extent):l.extent=n.extent),l.zIndex===void 0&&(l.zIndex=r)}return e}getSourceState(){return"ready"}}const Ct={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};class es extends Hh{constructor(t){const 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(et.SOURCE,this.handleSourcePropertyChange_);const 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(et.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const 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_&&(st(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=Z(t,X.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;const i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof De?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let n;if(e.layerStatesArray){if(n=e.layerStatesArray.find(o=>o.layer===this),!n)return!1}else n=this.getLayerState();const r=this.getExtent();return va(n,e.viewState)&&(!r||ft(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];const i=t instanceof De?t.getViewStateAndExtent():t;let n=e(i);return Array.isArray(n)||(n=[n]),n}render(t,e){const 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){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(et.MAP,t)}getMapInternal(){return this.get(et.MAP)}setMap(t){this.mapPrecomposeKey_&&(st(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(st(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=Z(t,Ct.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=Z(this,X.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);H(!e.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."),e.push(i)}setSource(t){this.set(et.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 va(s,t){if(!s.visible)return!1;const e=t.resolution;if(e<s.minResolution||e>=s.maxResolution)return!1;const i=t.zoom;return i>s.minZoom&&i<=s.maxZoom}function qh(s,t,e=0,i=s.length-1,n=Rf){for(;i>e;){if(i-e>600){const 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));qh(s,t,f,g,n)}const r=s[t];let o=e,a=i;for(vn(s,e,t),n(s[i],r)>0&&vn(s,e,i);o<a;){for(vn(s,o,a),o++,a--;n(s[o],r)<0;)o++;for(;n(s[a],r)>0;)a--}n(s[e],r)===0?vn(s,e,a):(a++,vn(s,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function vn(s,t,e){const i=s[t];s[t]=s[e],s[e]=i}function Rf(s,t){return s<t?-1:s>t?1:0}let Jh=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;const i=[];if(!ps(t,e))return i;const n=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?n(a):a;ps(t,l)&&(e.leaf?i.push(a):jr(t,l)?this._all(a,i):r.push(a))}e=r.pop()}return i}collides(t){let e=this.data;if(!ps(t,e))return!1;const i=[];for(;e;){for(let n=0;n<e.children.length;n++){const r=e.children[n],o=e.leaf?this.toBBox(r):r;if(ps(t,o)){if(e.leaf||jr(t,o))return!0;i.push(r)}}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){const 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=Yi([]),this}remove(t,e){if(!t)return this;let i=this.data;const n=this.toBBox(t),r=[],o=[];let a,l,h;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),i.leaf){const c=Sf(t,i.children,e);if(c!==-1)return i.children.splice(c,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&jr(i,n)?(r.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){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,n){const r=i-e+1;let o=this._maxEntries,a;if(r<=o)return a=Yi(t.slice(e,i+1)),Ni(a,this.toBBox),a;n||(n=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,n-1))),a=Yi([]),a.leaf=!1,a.height=n;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));wl(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);wl(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,n-1))}}return Ni(a,this.toBBox),a}_chooseSubtree(t,e,i,n){for(;n.push(e),!(e.leaf||n.length-1===i);){let r=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=Xr(h),u=If(t,h)-c;u<o?(o=u,r=c<r?c:r,a=h):u===o&&c<r&&(r=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const n=i?t:this.toBBox(t),r=[],o=this._chooseSubtree(n,this.data,e,r);for(o.children.push(t),An(o,n);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)}_split(t,e){const i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const o=this._chooseSplitIndex(i,r,n),a=Yi(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Ni(i,this.toBBox),Ni(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Yi([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Ni(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=In(t,0,a,this.toBBox),h=In(t,a,i,this.toBBox),c=Af(l,h),u=Xr(l)+Xr(h);c<r?(r=c,n=a,o=u<o?u:o):c===r&&u<o&&(o=u,n=a)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:wf,r=t.leaf?this.compareMinY:Pf,o=this._allDistMargin(t,e,i,n),a=this._allDistMargin(t,e,i,r);o<a&&t.children.sort(n)}_allDistMargin(t,e,i,n){t.children.sort(n);const r=this.toBBox,o=In(t,0,e,r),a=In(t,i-e,i,r);let l=ms(o)+ms(a);for(let h=e;h<i-e;h++){const c=t.children[h];An(o,t.leaf?r(c):c),l+=ms(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];An(a,t.leaf?r(c):c),l+=ms(a)}return l}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)An(e[n],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():Ni(t[e],this.toBBox)}};function Sf(s,t,e){if(!e)return t.indexOf(s);for(let i=0;i<t.length;i++)if(e(s,t[i]))return i;return-1}function Ni(s,t){In(s,0,s.children.length,t,s)}function In(s,t,e,i,n){n||(n=Yi(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(let r=t;r<e;r++){const o=s.children[r];An(n,s.leaf?i(o):o)}return n}function An(s,t){return s.minX=Math.min(s.minX,t.minX),s.minY=Math.min(s.minY,t.minY),s.maxX=Math.max(s.maxX,t.maxX),s.maxY=Math.max(s.maxY,t.maxY),s}function wf(s,t){return s.minX-t.minX}function Pf(s,t){return s.minY-t.minY}function Xr(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function ms(s){return s.maxX-s.minX+(s.maxY-s.minY)}function If(s,t){return(Math.max(t.maxX,s.maxX)-Math.min(t.minX,s.minX))*(Math.max(t.maxY,s.maxY)-Math.min(t.minY,s.minY))}function Af(s,t){const e=Math.max(s.minX,t.minX),i=Math.max(s.minY,t.minY),n=Math.min(s.maxX,t.maxX),r=Math.min(s.maxY,t.maxY);return Math.max(0,n-e)*Math.max(0,r-i)}function jr(s,t){return s.minX<=t.minX&&s.minY<=t.minY&&t.maxX<=s.maxX&&t.maxY<=s.maxY}function ps(s,t){return t.minX<=s.maxX&&t.minY<=s.maxY&&t.maxX>=s.minX&&t.maxY>=s.minY}function Yi(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function wl(s,t,e,i,n){const r=[t,e];for(;r.length;){if(e=r.pop(),t=r.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;qh(s,o,t,e,n),r.push(t,o,o,e)}}const Ra=[NaN,NaN,NaN,0];let Yr;function Lf(){return Yr||(Yr=mt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Yr}const bf=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Ff=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Mf=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Of=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function ys(s,t){return s.endsWith("%")?Number(s.substring(0,s.length-1))/t:Number(s)}function Mn(s){throw new Error('failed to parse "'+s+'" as color')}function Qh(s){if(s.toLowerCase().startsWith("rgb")){const r=s.match(Ff)||s.match(bf)||s.match(Mf);if(r){const o=r[4],a=100/255;return[ot(ys(r[1],a)+.5|0,0,255),ot(ys(r[2],a)+.5|0,0,255),ot(ys(r[3],a)+.5|0,0,255),o!==void 0?ot(ys(o,100),0,1):1]}Mn(s)}if(s.startsWith("#")){if(Of.test(s)){const r=s.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l<h;l+=o){let c=parseInt(r.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}Mn(s)}const t=Lf();t.fillStyle="#abcdef";let e=t.fillStyle;t.fillStyle=s,t.fillStyle===e&&(t.fillStyle="#fedcba",e=t.fillStyle,t.fillStyle=s,t.fillStyle===e&&Mn(s));const i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return Qh(i);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);const n=Array.from(t.getImageData(0,0,1,1).data);return n[3]=Hn(n[3]/255,3),n}function Df(s){return typeof s=="string"?s:wa(s)}const kf=1024,Rn={};let Vr=0;function Nf(s){if(s.length===4)return s;const t=s.slice();return t[3]=1,t}function Zr(s){return s>.0031308?Math.pow(s,1/2.4)*269.025-14.025:s*3294.6}function Kr(s){return s>.2068965?Math.pow(s,3):(s-4/29)*(108/841)}function Hr(s){return s>10.314724?Math.pow((s+14.025)/269.025,2.4):s/3294.6}function qr(s){return s>.0088564?Math.pow(s,1/3):s/(108/841)+4/29}function Pl(s){const t=Hr(s[0]),e=Hr(s[1]),i=Hr(s[2]),n=qr(t*.222488403+e*.716873169+i*.06060791),r=500*(qr(t*.452247074+e*.399439023+i*.148375274)-n),o=200*(n-qr(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*n-16,Math.sqrt(r*r+o*o),a<0?a+360:a,s[3]]}function Gf(s){const t=(s[0]+16)/116,e=s[1],i=s[2]*Math.PI/180,n=Kr(t),r=Kr(t+e/500*Math.cos(i)),o=Kr(t-e/200*Math.sin(i)),a=Zr(r*3.021973625-n*1.617392459-o*.404875592),l=Zr(r*-.943766287+n*1.916279586+o*.027607165),h=Zr(r*.069407491-n*.22898585+o*1.159737864);return[ot(a+.5|0,0,255),ot(l+.5|0,0,255),ot(h+.5|0,0,255),s[3]]}function Sa(s){if(s==="none")return Ra;if(Rn.hasOwnProperty(s))return Rn[s];if(Vr>=kf){let e=0;for(const i in Rn)(e++&3)===0&&(delete Rn[i],--Vr)}const t=Qh(s);t.length!==4&&Mn(s);for(const e of t)isNaN(e)&&Mn(s);return Rn[s]=t,++Vr,t}function ue(s){return Array.isArray(s)?s:Sa(s)}function wa(s){let t=s[0];t!=(t|0)&&(t=t+.5|0);let e=s[1];e!=(e|0)&&(e=e+.5|0);let i=s[2];i!=(i|0)&&(i=i+.5|0);const n=s[3]===void 0?1:Math.round(s[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+n+")"}function Il(s){return s[0]>0&&s[1]>0}function Bf(s,t,e){return e===void 0&&(e=[0,0]),e[0]=s[0]*t+.5|0,e[1]=s[1]*t+.5|0,e}function bt(s,t){return Array.isArray(s)?s:(t===void 0?t=[s,s]:(t[0]=s,t[1]=s),t)}let Li=0;const gt=1<<Li++,O=1<<Li++,yt=1<<Li++,at=1<<Li++,Gt=1<<Li++,te=1<<Li++,xs=Math.pow(2,Li)-1,Pa={[gt]:"boolean",[O]:"number",[yt]:"string",[at]:"color",[Gt]:"number[]",[te]:"size"},zf=Object.keys(Pa).map(Number).sort(Ee);function Uf(s){return s in Pa}function Hi(s){const t=[];for(const e of zf)Ln(s,e)&&t.push(Pa[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function Ln(s,t){return(s&t)===t}function pe(s,t){return s===t}class pt{constructor(t,e){if(!Uf(t))throw new Error(`literal expressions must have a specific type, got ${Hi(t)}`);this.type=t,this.value=e}}class tc{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function Ia(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function vt(s,t,e){switch(typeof s){case"boolean":{if(pe(t,yt))return new pt(yt,s?"true":"false");if(!Ln(t,gt))throw new Error(`got a boolean, but expected ${Hi(t)}`);return new pt(gt,s)}case"number":{if(pe(t,te))return new pt(te,bt(s));if(pe(t,gt))return new pt(gt,!!s);if(pe(t,yt))return new pt(yt,s.toString());if(!Ln(t,O))throw new Error(`got a number, but expected ${Hi(t)}`);return new pt(O,s)}case"string":{if(pe(t,at))return new pt(at,Sa(s));if(pe(t,gt))return new pt(gt,!!s);if(!Ln(t,yt))throw new Error(`got a string, but expected ${Hi(t)}`);return new pt(yt,s)}}if(!Array.isArray(s))throw new Error("expression must be an array or a primitive value");if(s.length===0)throw new Error("empty expression");if(typeof s[0]=="string")return Jf(s,t,e);for(const i of s)if(typeof i!="number")throw new Error("expected an array of numbers");if(pe(t,te)){if(s.length!==2)throw new Error(`expected an array of two values for a size, got ${s.length}`);return new pt(te,s)}if(pe(t,at)){if(s.length===3)return new pt(at,[...s,1]);if(s.length===4)return new pt(at,s);throw new Error(`expected an array of 3 or 4 values for a color, got ${s.length}`)}if(!Ln(t,Gt))throw new Error(`got an array of numbers, but expected ${Hi(t)}`);return new pt(Gt,s)}const 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"},$f={[C.Get]:z(V(1,1/0),Al),[C.Var]:z(V(1,1),Wf),[C.Has]:z(V(1,1/0),Al),[C.Id]:z(Xf,Gi),[C.Concat]:z(V(2,1/0),Q(yt)),[C.GeometryType]:z(jf,Gi),[C.LineMetric]:z(Gi),[C.Resolution]:z(Jr,Gi),[C.Zoom]:z(Jr,Gi),[C.Time]:z(Jr,Gi),[C.Any]:z(V(2,1/0),Q(gt)),[C.All]:z(V(2,1/0),Q(gt)),[C.Not]:z(V(1,1),Q(gt)),[C.Equal]:z(V(2,2),Q(xs)),[C.NotEqual]:z(V(2,2),Q(xs)),[C.GreaterThan]:z(V(2,2),Q(O)),[C.GreaterThanOrEqualTo]:z(V(2,2),Q(O)),[C.LessThan]:z(V(2,2),Q(O)),[C.LessThanOrEqualTo]:z(V(2,2),Q(O)),[C.Multiply]:z(V(2,1/0),Ll),[C.Coalesce]:z(V(2,1/0),Ll),[C.Divide]:z(V(2,2),Q(O)),[C.Add]:z(V(2,1/0),Q(O)),[C.Subtract]:z(V(2,2),Q(O)),[C.Clamp]:z(V(3,3),Q(O)),[C.Mod]:z(V(2,2),Q(O)),[C.Pow]:z(V(2,2),Q(O)),[C.Abs]:z(V(1,1),Q(O)),[C.Floor]:z(V(1,1),Q(O)),[C.Ceil]:z(V(1,1),Q(O)),[C.Round]:z(V(1,1),Q(O)),[C.Sin]:z(V(1,1),Q(O)),[C.Cos]:z(V(1,1),Q(O)),[C.Atan]:z(V(1,2),Q(O)),[C.Sqrt]:z(V(1,1),Q(O)),[C.Match]:z(V(4,1/0),bl,Vf),[C.Between]:z(V(3,3),Q(O)),[C.Interpolate]:z(V(6,1/0),bl,Zf),[C.Case]:z(V(3,1/0),Yf,Kf),[C.In]:z(V(2,2),Hf),[C.Number]:z(V(1,1/0),Q(xs)),[C.String]:z(V(1,1/0),Q(xs)),[C.Array]:z(V(1,1/0),Q(O)),[C.Color]:z(V(1,4),Q(O)),[C.Band]:z(V(1,3),Q(O)),[C.Palette]:z(V(2,2),qf),[C.ToString]:z(V(1,1),Q(gt|O|yt|at))};function Al(s,t,e){const i=s.length-1,n=new Array(i);for(let r=0;r<i;++r){const o=s[r+1];switch(typeof o){case"number":{n[r]=new pt(O,o);break}case"string":{n[r]=new pt(yt,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&e.properties.add(String(o))}return n}function Wf(s,t,e){const i=s[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return e.variables.add(i),[new pt(yt,i)]}function Xf(s,t,e){e.featureId=!0}function jf(s,t,e){e.geometryType=!0}function Jr(s,t,e){e.mapState=!0}function Gi(s,t,e){const i=s[0];if(s.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function V(s,t){return function(e,i,n){const r=e[0],o=e.length-1;if(s===t){if(o!==s){const a=s===1?"":"s";throw new Error(`expected ${s} argument${a} for ${r}, got ${o}`)}}else if(o<s||o>t){const a=t===1/0?`${s} or more`:`${s} to ${t}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function Ll(s,t,e){const i=s.length-1,n=new Array(i);for(let r=0;r<i;++r){const o=vt(s[r+1],t,e);n[r]=o}return n}function Q(s){return function(t,e,i){const n=t.length-1,r=new Array(n);for(let o=0;o<n;++o){const a=vt(t[o+1],s,i);r[o]=a}return r}}function Yf(s,t,e){const i=s[0],n=s.length-1;if(n%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${n} instead`)}function bl(s,t,e){const i=s[0],n=s.length-1;if(n%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${n} instead`)}function Vf(s,t,e){const i=s.length-1,n=yt|O|gt,r=vt(s[1],n,e),o=vt(s[s.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const h=vt(s[l+2],r.type,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{const h=vt(s[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[r,...a,o]}function Zf(s,t,e){const i=s[1];let n;switch(i[0]){case"linear":n=1;break;case"exponential":const 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)}`)}const r=new pt(O,n);let o;try{o=vt(s[2],O,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(s.length-3);for(let l=0;l<a.length;l+=2){try{const h=vt(s[l+3],O,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=vt(s[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[r,o,...a]}function Kf(s,t,e){const i=vt(s[s.length-1],t,e),n=new Array(s.length-1);for(let r=0;r<n.length-1;r+=2){try{const o=vt(s[r+1],gt,e);n[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=vt(s[r+2],i.type,e);n[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return n[n.length-1]=i,n}function Hf(s,t,e){let i=s[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=yt}else n=O;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=vt(i[a],n,e);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[vt(s[1],n,e),...r]}function qf(s,t,e){let i;try{i=vt(s[1],O,e)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const n=s[2];if(!Array.isArray(n))throw new Error("the second argument of palette must be an array");const r=new Array(n.length);for(let o=0;o<r.length;o++){let a;try{a=vt(n[o],at,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof pt))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function z(...s){return function(t,e,i){const n=t[0];let r;for(let o=0;o<s.length;o++){const a=s[o](t,e,i);if(o==s.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new tc(e,n,...r)}}function Jf(s,t,e){const i=s[0],n=$f[i];if(!n)throw new Error(`unknown operator: ${i}`);return n(s,t,e)}function Aa(s){if(!s)return"";const t=s.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 Aa(s.getGeometries()[0]);default:return""}}function ec(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Ue(s,t,e){const i=vt(s,t,e);return de(i)}function de(s,t){if(s instanceof pt){if(s.type===at&&typeof s.value=="string"){const i=Sa(s.value);return function(){return i}}return function(){return s.value}}const e=s.operator;switch(e){case C.Number:case C.String:case C.Coalesce:return Qf(s);case C.Get:case C.Var:case C.Has:return tg(s);case C.Id:return i=>i.featureId;case C.GeometryType:return i=>i.geometryType;case C.Concat:{const i=s.args.map(n=>de(n));return n=>"".concat(...i.map(r=>r(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 ig(s);case C.Equal:case C.NotEqual:case C.LessThan:case C.LessThanOrEqualTo:case C.GreaterThan:case C.GreaterThanOrEqualTo:return eg(s);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 ng(s);case C.Case:return sg(s);case C.Match:return rg(s);case C.Interpolate:return og(s);case C.ToString:return ag(s);default:throw new Error(`Unsupported operator ${e}`)}}function Qf(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=de(s.args[r]);switch(e){case C.Coalesce:return r=>{for(let o=0;o<i;++o){const a=n[o](r);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 r=>{for(let o=0;o<i;++o){const a=n[o](r);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 tg(s,t){const i=s.args[0].value;switch(s.operator){case C.Get:return n=>{const r=s.args;let o=n.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;o=o[c]}return o};case C.Var:return n=>n.variables[i];case C.Has:return n=>{const r=s.args;if(!(i in n.properties))return!1;let o=n.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${s.operator}`)}}function eg(s,t){const e=s.operator,i=de(s.args[0]),n=de(s.args[1]);switch(e){case C.Equal:return r=>i(r)===n(r);case C.NotEqual:return r=>i(r)!==n(r);case C.LessThan:return r=>i(r)<n(r);case C.LessThanOrEqualTo:return r=>i(r)<=n(r);case C.GreaterThan:return r=>i(r)>n(r);case C.GreaterThanOrEqualTo:return r=>i(r)>=n(r);default:throw new Error(`Unsupported comparison operator ${e}`)}}function ig(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=de(s.args[r]);switch(e){case C.Any:return r=>{for(let o=0;o<i;++o)if(n[o](r))return!0;return!1};case C.All:return r=>{for(let o=0;o<i;++o)if(!n[o](r))return!1;return!0};case C.Between:return r=>{const o=n[0](r),a=n[1](r),l=n[2](r);return o>=a&&o<=l};case C.In:return r=>{const o=n[0](r);for(let a=1;a<i;++a)if(o===n[a](r))return!0;return!1};case C.Not:return r=>!n[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function ng(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=de(s.args[r]);switch(e){case C.Multiply:return r=>{let o=1;for(let a=0;a<i;++a)o*=n[a](r);return o};case C.Divide:return r=>n[0](r)/n[1](r);case C.Add:return r=>{let o=0;for(let a=0;a<i;++a)o+=n[a](r);return o};case C.Subtract:return r=>n[0](r)-n[1](r);case C.Clamp:return r=>{const o=n[0](r),a=n[1](r);if(o<a)return a;const l=n[2](r);return o>l?l:o};case C.Mod:return r=>n[0](r)%n[1](r);case C.Pow:return r=>Math.pow(n[0](r),n[1](r));case C.Abs:return r=>Math.abs(n[0](r));case C.Floor:return r=>Math.floor(n[0](r));case C.Ceil:return r=>Math.ceil(n[0](r));case C.Round:return r=>Math.round(n[0](r));case C.Sin:return r=>Math.sin(n[0](r));case C.Cos:return r=>Math.cos(n[0](r));case C.Atan:return i===2?r=>Math.atan2(n[0](r),n[1](r)):r=>Math.atan(n[0](r));case C.Sqrt:return r=>Math.sqrt(n[0](r));default:throw new Error(`Unsupported numeric operator ${e}`)}}function sg(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=de(s.args[n]);return n=>{for(let r=0;r<e-1;r+=2)if(i[r](n))return i[r+1](n);return i[e-1](n)}}function rg(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=de(s.args[n]);return n=>{const r=i[0](n);for(let o=1;o<e-1;o+=2)if(r===i[o](n))return i[o+1](n);return i[e-1](n)}}function og(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=de(s.args[n]);return n=>{const r=i[0](n),o=i[1](n);let a,l;for(let h=2;h<e;h+=2){const c=i[h](n);let u=i[h+1](n);const d=Array.isArray(u);if(d&&(u=Nf(u)),c>=o)return h===2?u:d?lg(r,o,a,l,c,u):bn(r,o,a,l,c,u);a=c,l=u}return l}}function ag(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=de(s.args[r]);switch(e){case C.ToString:return r=>{const o=n[0](r);return s.args[0].type===at?wa(o):o.toString()};default:throw new Error(`Unsupported convert operator ${e}`)}}function bn(s,t,e,i,n,r){const o=n-e;if(o===0)return i;const a=t-e,l=s===1?a/o:(Math.pow(s,a)-1)/(Math.pow(s,o)-1);return i+l*(r-i)}function lg(s,t,e,i,n,r){if(n-e===0)return i;const a=Pl(i),l=Pl(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[bn(s,t,e,a[0],n,l[0]),bn(s,t,e,a[1],n,l[1]),a[2]+bn(s,t,e,0,n,h),bn(s,t,e,i[3],n,r[3])];return Gf(c)}const Y={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function hg(s,t,e){const i=s;let n=!0,r=!1,o=!1;const a=[Ns(i,X.LOAD,function(){o=!0,r||t()})];return i.src&&uh?(r=!0,i.decode().then(function(){n&&t()}).catch(function(l){n&&(o?t():e())})):a.push(Ns(i,X.ERROR,e)),function(){n=!1,a.forEach(st)}}function cg(s,t){return new Promise((e,i)=>{function n(){o(),e(s)}function r(){o(),i(new Error("Image load error"))}function o(){s.removeEventListener("load",n),s.removeEventListener("error",r)}s.addEventListener("load",n),s.addEventListener("error",r)})}function ug(s,t){return t&&(s.src=t),s.src&&uh?new Promise((e,i)=>s.decode().then(()=>e(s)).catch(n=>s.complete&&s.width?e(s):i(n))):cg(s)}class dg{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(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const n=Qr(t,e,i);return n in this.cache_?this.cache_[n]:null}getPattern(t,e,i){const n=Qr(t,e,i);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,i,n,r){const o=Qr(t,e,i),a=o in this.cache_;this.cache_[o]=n,r&&(n.getImageState()===Y.IDLE&&n.load(),n.getImageState()===Y.LOADING?n.ready().then(()=>{this.patternCache_[o]=Vs().createPattern(n.getImage(1),"repeat")}):this.patternCache_[o]=Vs().createPattern(n.getImage(1),"repeat")),a||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function Qr(s,t,e){const i=e?ue(e):"null";return t+":"+s+":"+i}const ee=new dg;let Sn=null;class ic extends lr{constructor(t,e,i,n,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=n===void 0?Y.IDLE:n,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_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===Y.LOADED){Sn||(Sn=mt(1,1,void 0,{willReadFrequently:!0})),Sn.drawImage(this.image_,0,0);try{Sn.getImageData(0,0,1,1),this.tainted_=!1}catch{Sn=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(X.CHANGE)}handleImageError_(){this.imageState_=Y.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=Y.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_}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_()){const t=this.size_[0],e=this.size_[1],i=mt(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_===Y.IDLE){this.image_||this.initializeImage_(),this.imageState_=Y.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&ug(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_!==Y.LOADED)return;const e=this.image_,i=mt(Math.ceil(e.width*t),Math.ceil(e.height*t)),n=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Df(this.color_),i.fillRect(0,0,n.width/t,n.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=n}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===Y.LOADED||this.imageState_===Y.ERROR)t();else{const e=()=>{(this.imageState_===Y.LOADED||this.imageState_===Y.ERROR)&&(this.removeEventListener(X.CHANGE,e),t())};this.addEventListener(X.CHANGE,e)}})),this.ready_}}function Ks(s,t,e,i,n,r){let o=t===void 0?void 0:ee.get(t,e,n);return o||(o=new ic(s,s&&"src"in s?s.src||void 0:t,e,i,n),ee.set(t,e,n,o,r)),r&&o&&!ee.getPattern(t,e,n)&&ee.set(t,e,n,o,r),o}function xe(s){return s?Array.isArray(s)?wa(s):typeof s=="object"&&"src"in s?fg(s):s:null}function fg(s){if(!s.offset||!s.size)return ee.getPattern(s.src,"anonymous",s.color);const t=s.src+":"+s.offset,e=ee.getPattern(t,void 0,s.color);if(e)return e;const i=ee.get(s.src,"anonymous",null);if(i.getImageState()!==Y.LOADED)return null;const n=mt(s.size[0],s.size[1]);return n.drawImage(i.getImage(1),s.offset[0],s.offset[1],s.size[0],s.size[1],0,0,s.size[0],s.size[1]),Ks(n.canvas,t,void 0,Y.LOADED,s.color,!0),ee.getPattern(t,void 0,s.color)}const nc="10px sans-serif",Ot="#000",an="round",Ge=[],Be=0,ln="round",zn=10,Un="#000",$n="center",Hs="middle",mi=[0,0,0,0],Wn=1,Vi=new re;let wn=null,Fl;const ko={},gg=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function _g(s,t,e){return`${s} ${t} 16px "${e}"`}const mg=(function(){let t,e;async function i(r){await e.ready;const o=await e.load(r);if(o.length===0)return!1;const a=Fo(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=bo[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function n(){await e.ready;let r=!0;const o=Vi.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await i(h)?(Pi(ko),Vi.set(h,100)):(c+=10,Vi.set(h,c,!0),c<100&&(r=!1)))}t=void 0,r||(t=setTimeout(n,100))}return async function(r){e||(e=jt?self.fonts:document.fonts);const o=Fo(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(gg.has(h))continue;const c=_g(o.style,o.weight,h);Vi.get(c)===void 0&&(Vi.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(n,100))}})(),pg=(function(){let s;return function(t){let e=ko[t];if(e==null){if(jt){const i=Fo(t),n=sc(t,"Žg");e=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent)}else s||(s=document.createElement("div"),s.innerHTML="M",s.style.minHeight="0",s.style.maxHeight="none",s.style.height="auto",s.style.padding="0",s.style.border="none",s.style.position="absolute",s.style.display="block",s.style.left="-99999px"),s.style.font=t,document.body.appendChild(s),e=s.offsetHeight,document.body.removeChild(s);ko[t]=e}return e}})();function sc(s,t){return wn||(wn=mt(1,1)),s!=Fl&&(wn.font=s,Fl=wn.font),wn.measureText(t)}function rc(s,t){return sc(s,t).width}function Ml(s,t,e){if(t in e)return e[t];const i=t.split(`
`).reduce((n,r)=>Math.max(n,rc(s,r)),0);return e[t]=i,i}function yg(s,t){const e=[],i=[],n=[];let r=0,o=0,a=0,l=0;for(let h=0,c=t.length;h<=c;h+=2){const u=t[h];if(u===`
`||h===c){r=Math.max(r,o),n.push(o),o=0,a+=l,l=0;continue}const d=t[h+1]||s.font,f=rc(d,u);e.push(f),o+=f;const g=pg(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:n}}function xg(s,t,e,i,n,r,o,a,l,h,c){s.save(),e!==1&&(s.globalAlpha===void 0?s.globalAlpha=u=>u.globalAlpha*=e:s.globalAlpha*=e),t&&s.transform.apply(s,t),i.contextInstructions?(s.translate(l,h),s.scale(c[0],c[1]),Eg(i,s)):c[0]<0||c[1]<0?(s.translate(l,h),s.scale(c[0],c[1]),s.drawImage(i,n,r,o,a,0,0,o,a)):s.drawImage(i,n,r,o,a,l,h,o*c[0],a*c[1]),s.restore()}function Eg(s,t){const e=s.contextInstructions;for(let i=0,n=e.length;i<n;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}class Cr{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=bt(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Cr({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 B()}getImage(t){return B()}getHitDetectionImage(){return B()}getPixelRatio(t){return 1}getImageState(){return B()}getImageSize(){return B()}getOrigin(){return B()}getSize(){return B()}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_=bt(t)}listenImageChange(t){B()}load(){B()}unlistenImageChange(t){B()}ready(){return Promise.resolve()}}class vr extends Cr{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()?Y.LOADING:Y.LOADED,this.imageState_===Y.LOADING&&this.ready().then(()=>this.imageState_=Y.LOADED),this.render()}clone(){const t=this.getScale(),e=new vr({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(){const 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){const e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let n=ee.get(i,null,null)?.getImage(1);if(!n){const r=this.renderOptions_,o=Math.ceil(r.size*t),a=mt(o,o);this.draw_(r,a,t),n=a.canvas,ee.set(i,null,null,new ic(n,void 0,null,Y.LOADED,null))}return n}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(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 n=this.radius,r=this.radius2_===void 0?n:this.radius2_;if(n<r){const v=n;n=r,r=v}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=n-h,u=Math.sqrt(l*l+c*c),d=u/l;if(t==="miter"&&d<=i)return d*e;const f=e/2/d,g=e/2*(c/u),_=Math.sqrt((n+f)*(n+f)+g*g)-n;if(this.radius2_===void 0||t==="bevel")return _*2;const p=n*Math.sin(a),y=Math.sqrt(n*n-p*p),T=r-y,E=Math.sqrt(p*p+T*T)/p;if(E<=i){const v=E*e/2-r-n;return 2*Math.max(_,v)}return _*2}createRenderOptions(){let t=an,e=ln,i=0,n=null,r=0,o,a=0;this.stroke_&&(o=xe(this.stroke_.getColor()??Un),a=this.stroke_.getWidth()??Wn,n=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??ln,t=this.stroke_.getLineCap()??an,i=this.stroke_.getMiterLimit()??zn);const 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:n,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const 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 n=this.fill_.getColor();n===null&&(n=Ot),e.fillStyle=xe(n),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(),n=0;typeof i=="string"&&(i=ue(i)),i===null?n=1:Array.isArray(i)&&(n=i.length===4?i[3]:1),n===0&&(e=mt(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{const n=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let a=0;a<e;a++){const l=r+a*o,h=a%2===0?i:n;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=Ot,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()}}class is extends vr{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(){const t=this.getScale(),e=new is({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}setRadius(t){this.radius=t,this.render()}}class ni{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){const t=this.getColor();return new ni({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){const e=Ks(null,t.src,"anonymous",void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===Y.IDLE&&e.load(),e.getImageState()===Y.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?k(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:ue(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function Ol(s,t,e,i){return e!==void 0&&i!==void 0?[e/s,i/t]:e!==void 0?e/s:i!==void 0?i/t:1}class Rr extends Cr{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,n=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:n,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:r,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;const o=t.img!==void 0?t.img:null;let a=t.src;H(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||k(o)),H(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),H(!((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=Y.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?Y.LOADED:Y.IDLE:l=Y.LOADING:l=Y.LOADED),this.color_=t.color!==void 0?ue(t.color):null,this.iconImage_=Ks(o,a,this.crossOrigin_,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{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(Ol(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(Ol(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 Rr({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale: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_;const n=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!n)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=n[0]),this.anchorYUnits_=="fraction"&&(t[1]*=n[1])}if(this.anchorOrigin_!="top-left"){if(!n)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+n[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+n[1])}this.normalizedAnchor_=t}const 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_}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"){const 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_=Ks(null,t,this.crossOrigin_,Y.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==Y.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){const t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==Y.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(X.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(X.CHANGE,t)}ready(){return this.iconImage_.ready()}}class xi{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.width_=t.width}clone(){const t=this.getColor();return new xi({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(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(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}setWidth(t){this.width_=t}}class he{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Dl,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 he({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_=Dl,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function Tg(s){let t;if(typeof s=="function")t=s;else{let e;Array.isArray(s)?e=s:(H(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[s]),t=function(){return e}}return t}let to=null;function oc(s,t){if(!to){const e=new ni({color:"rgba(255,255,255,0.4)"}),i=new xi({color:"#3399CC",width:1.25});to=[new he({image:new is({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return to}function ac(){const s={},t=[255,255,255,1],e=[0,153,255,1],i=3;return s.Polygon=[new he({fill:new ni({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new he({stroke:new xi({color:t,width:i+2})}),new he({stroke:new xi({color:e,width:i})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new he({image:new is({radius:i*2,fill:new ni({color:e}),stroke:new xi({color:t,width:i/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function Dl(s){return s.getGeometry()}const Cg="#333";class La{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_=bt(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 ni({color:Cg}),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(){const t=this.getScale();return new La({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 ni?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_=bt(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}}function vg(s){return!0}function Rg(s){const t=Ia(),e=Sg(s,t),i=ec();return function(n,r){if(i.properties=n.getPropertiesInternal(),i.resolution=r,t.featureId){const o=n.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=Aa(n.getGeometry())),e(i)}}function kl(s){const t=Ia(),e=s.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=No(s[o],t);const n=ec(),r=new Array(e);return function(o,a){if(n.properties=o.getPropertiesInternal(),n.resolution=a,t.featureId){const h=o.getId();h!==void 0?n.featureId=h:n.featureId=null}let l=0;for(let h=0;h<e;++h){const c=i[h](n);c&&(r[l]=c,l+=1)}return r.length=l,r}}function Sg(s,t){const e=s.length,i=new Array(e);for(let n=0;n<e;++n){const r=s[n],o="filter"in r?Ue(r.filter,gt,t):vg;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=No(r.style[h],t)}else a=[No(r.style,t)];i[n]={filter:o,styles:a}}return function(n){const r=[];let o=!1;for(let a=0;a<e;++a){const l=i[a].filter;if(l(n)&&!(s[a].else&&o)){o=!0;for(const h of i[a].styles){const c=h(n);c&&r.push(c)}}}return r}}function No(s,t){const e=Xn(s,"",t),i=jn(s,"",t),n=wg(s,t),r=Pg(s,t),o=kt(s,"z-index",t);if(!e&&!i&&!n&&!r&&!Ei(s))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(s));const a=new he;return function(l){let h=!0;if(e){const c=e(l);c&&(h=!1),a.setFill(c)}if(i){const c=i(l);c&&(h=!1),a.setStroke(c)}if(n){const c=n(l);c&&(h=!1),a.setText(c)}if(r){const c=r(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function Xn(s,t,e){let i;if(t+"fill-pattern-src"in s)i=bg(s,t+"fill-",e);else{if(s[t+"fill-color"]==="none")return r=>null;i=ba(s,t+"fill-color",e)}if(!i)return null;const n=new ni;return function(r){const o=i(r);return o===Ra?null:(n.setColor(o),n)}}function jn(s,t,e){const i=kt(s,t+"stroke-width",e),n=ba(s,t+"stroke-color",e);if(!i&&!n)return null;const r=Me(s,t+"stroke-line-cap",e),o=Me(s,t+"stroke-line-join",e),a=lc(s,t+"stroke-line-dash",e),l=kt(s,t+"stroke-line-dash-offset",e),h=kt(s,t+"stroke-miter-limit",e),c=new xi;return function(u){if(n){const d=n(u);if(d===Ra)return null;c.setColor(d)}if(i&&c.setWidth(i(u)),r){const d=r(u);if(d!=="butt"&&d!=="round"&&d!=="square")throw new Error("Expected butt, round, or square line cap");c.setLineCap(d)}if(o){const d=o(u);if(d!=="bevel"&&d!=="round"&&d!=="miter")throw new Error("Expected bevel, round, or miter line join");c.setLineJoin(d)}return a&&c.setLineDash(a(u)),l&&c.setLineDashOffset(l(u)),h&&c.setMiterLimit(h(u)),c}}function wg(s,t){const e="text-",i=Me(s,e+"value",t);if(!i)return null;const n=Xn(s,e,t),r=Xn(s,e+"background-",t),o=jn(s,e,t),a=jn(s,e+"background-",t),l=Me(s,e+"font",t),h=kt(s,e+"max-angle",t),c=kt(s,e+"offset-x",t),u=kt(s,e+"offset-y",t),d=tn(s,e+"overflow",t),f=Me(s,e+"placement",t),g=kt(s,e+"repeat",t),m=Sr(s,e+"scale",t),_=tn(s,e+"rotate-with-view",t),p=kt(s,e+"rotation",t),y=Me(s,e+"align",t),T=Me(s,e+"justify",t),x=Me(s,e+"baseline",t),E=tn(s,e+"keep-upright",t),v=lc(s,e+"padding",t),R=wr(s,e+"declutter-mode"),S=new La({declutterMode:R});return function(w){if(S.setText(i(w)),n&&S.setFill(n(w)),r&&S.setBackgroundFill(r(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){const I=f(w);if(I!=="point"&&I!=="line")throw new Error("Expected point or line for text-placement");S.setPlacement(I)}if(g&&S.setRepeat(g(w)),m&&S.setScale(m(w)),_&&S.setRotateWithView(_(w)),p&&S.setRotation(p(w)),y){const I=y(w);if(I!=="left"&&I!=="center"&&I!=="right"&&I!=="end"&&I!=="start")throw new Error("Expected left, right, center, start, or end for text-align");S.setTextAlign(I)}if(T){const I=T(w);if(I!=="left"&&I!=="right"&&I!=="center")throw new Error("Expected left, right, or center for text-justify");S.setJustify(I)}if(x){const I=x(w);if(I!=="bottom"&&I!=="top"&&I!=="middle"&&I!=="alphabetic"&&I!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");S.setTextBaseline(I)}return v&&S.setPadding(v(w)),E&&S.setKeepUpright(E(w)),S}}function Pg(s,t){return"icon-src"in s?Ig(s,t):"shape-points"in s?Ag(s,t):"circle-radius"in s?Lg(s,t):null}function Ig(s,t){const e="icon-",i=e+"src",n=hc(s[i],i),r=qs(s,e+"anchor",t),o=Sr(s,e+"scale",t),a=kt(s,e+"opacity",t),l=qs(s,e+"displacement",t),h=kt(s,e+"rotation",t),c=tn(s,e+"rotate-with-view",t),u=Gl(s,e+"anchor-origin"),d=Bl(s,e+"anchor-x-units"),f=Bl(s,e+"anchor-y-units"),g=Dg(s,e+"color"),m=Mg(s,e+"cross-origin"),_=Og(s,e+"offset"),p=Gl(s,e+"offset-origin"),y=Js(s,e+"width"),T=Js(s,e+"height"),x=Fg(s,e+"size"),E=wr(s,e+"declutter-mode"),v=new Rr({src:n,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:m,offset:_,offsetOrigin:p,height:T,width:y,size:x,declutterMode:E});return function(R){return a&&v.setOpacity(a(R)),l&&v.setDisplacement(l(R)),h&&v.setRotation(h(R)),c&&v.setRotateWithView(c(R)),o&&v.setScale(o(R)),r&&v.setAnchor(r(R)),v}}function Ag(s,t){const e="shape-",i=e+"points",n=e+"radius",r=Go(s[i],i),o=Go(s[n],n),a=Xn(s,e,t),l=jn(s,e,t),h=Sr(s,e+"scale",t),c=qs(s,e+"displacement",t),u=kt(s,e+"rotation",t),d=tn(s,e+"rotate-with-view",t),f=Js(s,e+"radius2"),g=Js(s,e+"angle"),m=wr(s,e+"declutter-mode"),_=new vr({points:r,radius:o,radius2:f,angle:g,declutterMode:m});return function(p){return a&&_.setFill(a(p)),l&&_.setStroke(l(p)),c&&_.setDisplacement(c(p)),u&&_.setRotation(u(p)),d&&_.setRotateWithView(d(p)),h&&_.setScale(h(p)),_}}function Lg(s,t){const e="circle-",i=Xn(s,e,t),n=jn(s,e,t),r=kt(s,e+"radius",t),o=Sr(s,e+"scale",t),a=qs(s,e+"displacement",t),l=kt(s,e+"rotation",t),h=tn(s,e+"rotate-with-view",t),c=wr(s,e+"declutter-mode"),u=new is({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(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 kt(s,t,e){if(!(t in s))return;const i=Ue(s[t],O,e);return function(n){return Go(i(n),t)}}function Me(s,t,e){if(!(t in s))return null;const i=Ue(s[t],yt,e);return function(n){return hc(i(n),t)}}function bg(s,t,e){const i=Me(s,t+"pattern-src",e),n=Nl(s,t+"pattern-offset",e),r=Nl(s,t+"pattern-size",e),o=ba(s,t+"color",e);return function(a){return{src:i(a),offset:n&&n(a),size:r&&r(a),color:o&&o(a)}}}function tn(s,t,e){if(!(t in s))return null;const i=Ue(s[t],gt,e);return function(n){const r=i(n);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${t}`);return r}}function ba(s,t,e){if(!(t in s))return null;const i=Ue(s[t],at,e);return function(n){return cc(i(n),t)}}function lc(s,t,e){if(!(t in s))return null;const i=Ue(s[t],Gt,e);return function(n){return ns(i(n),t)}}function qs(s,t,e){if(!(t in s))return null;const i=Ue(s[t],Gt,e);return function(n){const r=ns(i(n),t);if(r.length!==2)throw new Error(`Expected two numbers for ${t}`);return r}}function Nl(s,t,e){if(!(t in s))return null;const i=Ue(s[t],Gt,e);return function(n){return uc(i(n),t)}}function Sr(s,t,e){if(!(t in s))return null;const i=Ue(s[t],Gt|O,e);return function(n){return kg(i(n),t)}}function Js(s,t){const e=s[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function Fg(s,t){const e=s[t];if(e!==void 0){if(typeof e=="number")return bt(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 Mg(s,t){const e=s[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function Gl(s,t){const e=s[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 Bl(s,t){const e=s[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function Og(s,t){const e=s[t];if(e!==void 0)return ns(e,t)}function wr(s,t){const e=s[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 Dg(s,t){const e=s[t];if(e!==void 0)return cc(e,t)}function ns(s,t){if(!Array.isArray(s))throw new Error(`Expected an array for ${t}`);const e=s.length;for(let i=0;i<e;++i)if(typeof s[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return s}function hc(s,t){if(typeof s!="string")throw new Error(`Expected a string for ${t}`);return s}function Go(s,t){if(typeof s!="number")throw new Error(`Expected a number for ${t}`);return s}function cc(s,t){if(typeof s=="string")return s;const e=ns(s,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 uc(s,t){const e=ns(s,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function kg(s,t){return typeof s=="number"?s:uc(s,t)}const zl={RENDER_ORDER:"renderOrder"};class ss extends es{constructor(t){t=t||{};const 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(zl.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new Jh(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(zl.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?oc:t;const e=Ng(t);this.styleFunction_=t===null?void 0:Tg(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}function Ng(s){if(s===void 0)return oc;if(!s)return null;if(typeof s=="function"||s instanceof he)return s;if(!Array.isArray(s))return kl([s]);if(s.length===0)return[];const t=s.length,e=s[0];if(e instanceof he){const n=new Array(t);for(let r=0;r<t;++r){const o=s[r];if(!(o instanceof he))throw new Error("Expected a list of style instances");n[r]=o}return n}if("style"in e){const n=new Array(t);for(let r=0;r<t;++r){const o=s[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");n[r]=o}return Rg(n)}return kl(s)}class On extends se{constructor(t,e,i,n){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=n}}class Gg extends Zn{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){B()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,n=t.pixelToCoordinateTransform;ne(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Nn(n,i)}forEachFeatureAtCoordinate(t,e,i,n,r,o,a,l){let h;const c=e.viewState;function u(x,E,v,R){return r.call(o,E,x?v:null,R)}const d=c.projection,f=qo(t.slice(),d),g=[[0,0]];if(d.canWrapX()&&n){const x=d.getExtent(),E=it(x);g.push([-E,0],[E,0])}const m=e.layerStatesArray,_=m.length,p=[],y=[];for(let x=0;x<g.length;x++)for(let E=_-1;E>=0;--E){const v=m[E],R=v.layer;if(R.hasRenderer()&&va(v,c)&&a.call(l,R)){const S=R.getRenderer(),w=R.getSource();if(S&&w){const I=w.getWrapX()?f:t,b=u.bind(null,v.managed);y[0]=I[0]+g[x][0],y[1]=I[1]+g[x][1],h=S.forEachFeatureAtCoordinate(y,e,i,b,p)}if(h)return h}}if(p.length===0)return;const T=1/p.length;return p.forEach((x,E)=>x.distanceSq+=E*T),p.sort((x,E)=>x.distanceSq-E.distanceSq),p.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(t,e,i,n,r,o){return this.forEachFeatureAtCoordinate(t,e,i,n,ei,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){B()}scheduleExpireIconCache(t){ee.canExpireCache()&&t.postRenderFunctions.push(Bg)}}function Bg(s,t){ee.expire()}class zg extends Gg{constructor(t){super(t),this.fontChangeListenerKey_=Z(Vi,nn.PROPERTYCHANGE,t.redrawText,t),this.element_=jt?Yh():document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=ts+" ol-layers";const i=t.getViewport();i&&i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const n=new On(t,void 0,e);i.dispatchEvent(n)}}disposeInternal(){st(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(Ct.PRECOMPOSE,t);const e=t.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);e.some(h=>h.layer instanceof ss&&h.layer.getDeclutter())&&(t.declutter={});const n=t.viewState;this.children_.length=0;const r=[];let o=null;for(let h=0,c=e.length;h<c;++h){const u=e[h];t.layerIndex=h;const d=u.layer,f=d.getSourceState();if(!va(u,n)||f!="ready"&&f!="undefined"){d.unrender();continue}const g=d.render(t,o);g&&(g!==o&&(this.children_.push(g),o=g),r.push(u))}this.declutter(t,r),qd(this.element_,this.children_);const l=this.getMap().getTargetElement();if(He(l)){const h=l.getContext("2d");for(const c of this.children_){const u=c.firstElementChild||c,d=c.style.backgroundColor;if(d&&(!He(u)||u.width>0)&&(h.fillStyle=d,h.fillRect(0,0,l.width,l.height)),He(u)&&u.width>0){const f=c.style.opacity||u.style.opacity;h.globalAlpha=f===""?1:Number(f);const g=u.style.transform;if(g)h.setTransform(...Io(g));else{const m=parseFloat(u.style.width)/u.width,_=parseFloat(u.style.height)/u.height;h.setTransform(m,0,0,_,0,0)}h.drawImage(u,0,0)}}h.globalAlpha=1,h.setTransform(1,0,0,1,0,0)}this.dispatchRenderEvent(Ct.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){const n=e[i],r=n.layer;r.getDeclutter()&&r.renderDeclutter(t,n)}e.forEach(i=>i.layer.renderDeferred(t))}}}function dc(s){if(s instanceof es){s.setMapInternal(null);return}s instanceof _n&&s.getLayers().forEach(dc)}function fc(s,t){if(s instanceof es){s.setMapInternal(t);return}if(s instanceof _n){const e=s.getLayers().getArray();for(let i=0,n=e.length;i<n;++i)fc(e[i],t)}}let Up=class extends re{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=Ug(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:yu,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=_t(),this.pixelToCoordinateTransform_=_t(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,jt||(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,jt||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=e.controls||(jt?new Xt:ef()),this.interactions=e.interactions||(jt?new Xt:vf({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Tu(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(It.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(It.VIEW,this.handleViewChanged_),this.addChangeListener(It.SIZE,this.handleSizeChanged_),this.addChangeListener(It.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof De)&&t.view.then(function(n){i.setView(new De(n))}),this.controls.addEventListener(Tt.ADD,n=>{n.element.setMap(this)}),this.controls.addEventListener(Tt.REMOVE,n=>{n.element.setMap(null)}),this.interactions.addEventListener(Tt.ADD,n=>{n.element.setMap(this)}),this.interactions.addEventListener(Tt.REMOVE,n=>{n.element.setMap(null)}),this.overlays_.addEventListener(Tt.ADD,n=>{this.addOverlayInternal_(n.element)}),this.overlays_.addEventListener(Tt.REMOVE,n=>{const r=n.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.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(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){fc(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const 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;const n=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:ei,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(n,this.frameState_,r,a,e,null,o,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,function(n){i.push(n)},e),i}getAllLayers(){const t=[];function e(i){i.forEach(function(n){n instanceof _n?e(n.getLayers()):t.push(n)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};const n=e.layerFilter!==void 0?e.layerFilter:ei,r=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,n,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const i=this.viewport_.getBoundingClientRect(),n=this.getSize(),r=i.width/n[0],o=i.height/n[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(It.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Po(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?ct(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(It.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof Xt){e.setLayers(t);return}const i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const n=t[e];if(!n.visible)continue;const r=n.layer.getRenderer();if(r&&!r.ready)return!0;const o=n.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(t){const e=le(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?ct(e.coordinateToPixelTransform,t.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(It.SIZE)}getView(){return this.get(It.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,n){return Cu(this.frameState_,t,e,i,n)}handleBrowserEvent(t,e){e=e||t.type;const i=new be(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===yo.POINTERDOWN||i===X.WHEEL||i===X.KEYDOWN){const n=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():n,o=e.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===n?n.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){const n=this.getInteractions().getArray().slice();for(let r=n.length-1;r>=0;r--){const o=n[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let n=this.maxTilesLoading_,r=n;if(t){const o=t.viewHints;if(o[rt.ANIMATING]||o[rt.INTERACTING]){const a=Date.now()-t.time>8;n=a?0:8,r=a?0:2}}e.getTilesLoading()<n&&(e.reprioritize(),e.loadMoreTiles(n,r))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Ct.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Ct.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new ji(Fe.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new ji(Fe.LOADSTART,this,t))));const i=this.postRenderFunctions_;if(t)for(let n=0,r=i.length;n<r;++n)i[n](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,n=this.targetChangeHandlerKeys_.length;i<n;++i)st(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(X.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(X.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!He(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);const i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}const 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(He(e)||e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new zg(this)),!He(e)){this.mapBrowserEventHandler_=new xu(this,this.moveTolerance_);for(const n in J)this.mapBrowserEventHandler_.addEventListener(J[n],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(X.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(X.WHEEL,this.boundHandleBrowserEvent_,dh?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{const n=e.getRootNode();i=n instanceof ShadowRoot?n.host:e}if(this.targetChangeHandlerKeys_=[Z(i,X.KEYDOWN,this.handleBrowserEvent,this),Z(i,X.KEYPRESS,this.handleBrowserEvent,this)],e instanceof HTMLElement){const n=e.getRootNode();n instanceof ShadowRoot&&this.resizeObserver_.observe(n.host),this.resizeObserver_?.observe(e)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(st(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(st(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=Z(t,nn.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=Z(t,X.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(st),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new Ve("addlayer",t)),this.layerGroupPropertyListenerKeys_=[Z(t,nn.PROPERTYCHANGE,this.render,this),Z(t,X.CHANGE,this.render,this),Z(t,"addlayer",this.handleLayerAdd_,this),Z(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;const t=this.frameState_.layerStatesArray;for(let e=0,i=t.length;e<i;++e){const n=t[e].layer;n.hasRenderer()&&n.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){dc(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){const e=this.getSize(),i=this.getView(),n=this.frameState_;let r=null;if(e!==void 0&&Il(e)&&i&&i.isDef()){const o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:Co(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:k(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=Co(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),n&&(!this.previousExtent_||!un(this.previousExtent_)&&!vi(r.extent,this.previousExtent_))&&(this.dispatchEvent(new ji(Fe.MOVESTART,this,n)),this.previousExtent_=cn(this.previousExtent_)),this.previousExtent_&&!r.viewHints[rt.ANIMATING]&&!r.viewHints[rt.INTERACTING]&&!vi(r.extent,this.previousExtent_)&&(this.dispatchEvent(new ji(Fe.MOVEEND,this,r)),fh(r.extent,this.previousExtent_))),this.dispatchEvent(new ji(Fe.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(Fe.LOADSTART)||this.hasListener(Fe.LOADEND)||this.hasListener(Ct.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new Ve("removelayer",e)),this.set(It.LAYERGROUP,t)}setSize(t){this.set(It.SIZE,t)}setTarget(t){this.set(It.TARGET,t)}setView(t){if(!t||t instanceof De){this.set(It.VIEW,t);return}this.set(It.VIEW,new De);const e=this;t.then(function(i){e.setView(new De(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){let n,r;if(He(t))n=t.width,r=t.height;else{const o=getComputedStyle(t);n=t.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),r=t.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(n)&&!isNaN(r)&&(e=[Math.max(0,n),Math.max(0,r)],!Il(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&vh("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!ze(e,i))&&(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};function Ug(s){let t=null;s.keyboardEventTarget!==void 0&&(t=typeof s.keyboardEventTarget=="string"?document.getElementById(s.keyboardEventTarget):s.keyboardEventTarget);const e={},i=s.layers&&typeof s.layers.getLayers=="function"?s.layers:new _n({layers:s.layers});e[It.LAYERGROUP]=i,e[It.TARGET]=s.target,e[It.VIEW]=s.view instanceof De?s.view:new De;let n;s.controls!==void 0&&(Array.isArray(s.controls)?n=new Xt(s.controls.slice()):(H(typeof s.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),n=s.controls));let r;s.interactions!==void 0&&(Array.isArray(s.interactions)?r=new Xt(s.interactions.slice()):(H(typeof s.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=s.interactions));let o;return s.overlays!==void 0?Array.isArray(s.overlays)?o=new Xt(s.overlays.slice()):(H(typeof s.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=s.overlays):o=new Xt,{controls:n,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}const Pt={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class Wp extends re{constructor(t){super(),this.on,this.once,this.un,this.options=t,this.id=t.id,this.insertFirst=t.insertFirst!==void 0?t.insertFirst:!0,this.stopEvent=t.stopEvent!==void 0?t.stopEvent:!0,this.element=document.createElement("div"),this.element.className=t.className!==void 0?t.className:"ol-overlay-container "+Vd,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=t.autoPan===!0?{}:t.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(Pt.ELEMENT,this.handleElementChanged),this.addChangeListener(Pt.MAP,this.handleMapChanged),this.addChangeListener(Pt.OFFSET,this.handleOffsetChanged),this.addChangeListener(Pt.POSITION,this.handlePositionChanged),this.addChangeListener(Pt.POSITIONING,this.handlePositioningChanged),t.element!==void 0&&this.setElement(t.element),this.setOffset(t.offset!==void 0?t.offset:[0,0]),this.setPositioning(t.positioning||"top-left"),t.position!==void 0&&this.setPosition(t.position)}getElement(){return this.get(Pt.ELEMENT)}getId(){return this.id}getMap(){return this.get(Pt.MAP)||null}getOffset(){return this.get(Pt.OFFSET)}getPosition(){return this.get(Pt.POSITION)}getPositioning(){return this.get(Pt.POSITIONING)}handleElementChanged(){jh(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),st(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=Z(t,Fe.POSTRENDER,this.render,this),this.updatePixelPosition();const e=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?e.insertBefore(this.element,e.childNodes[0]||null):e.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(t){this.set(Pt.ELEMENT,t)}setMap(t){this.set(Pt.MAP,t)}setOffset(t){this.set(Pt.OFFSET,t)}setPosition(t){this.set(Pt.POSITION,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(Pt.POSITION))return;const i=this.getRect(e.getTargetElement(),e.getSize()),n=this.getElement(),r=this.getRect(n,[Kd(n),Hd(n)]);t=t||{};const o=t.margin===void 0?20:t.margin;if(!Ze(i,r)){const a=r[0]-i[0],l=i[2]-r[2],h=r[1]-i[1],c=i[3]-r[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){const d=e.getView().getCenterInternal(),f=e.getPixelFromCoordinateInternal(d);if(!f)return;const g=[f[0]+u[0],f[1]+u[1]],m=t.animation||{};e.getView().animateInternal({center:e.getCoordinateFromPixelInternal(g),duration:m.duration,easing:m.easing})}}}getRect(t,e){const i=t.getBoundingClientRect(),n=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[n,r,n+e[0],r+e[1]]}setPositioning(t){this.set(Pt.POSITIONING,t)}setVisible(t){this.rendered.visible!==t&&(this.element.style.display=t?"":"none",this.rendered.visible=t)}updatePixelPosition(){const t=this.getMap(),e=this.getPosition();if(!t||!t.isRendered()||!e){this.setVisible(!1);return}const i=t.getPixelFromCoordinate(e),n=t.getSize();this.updateRenderedPosition(i,n)}updateRenderedPosition(t,e){const i=this.element.style,n=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=`${t[0]+n[0]}px`,a=`${t[1]+n[1]}px`;let l="0%",h="0%";r=="bottom-right"||r=="center-right"||r=="top-right"?l="-100%":(r=="bottom-center"||r=="center-center"||r=="top-center")&&(l="-50%"),r=="bottom-left"||r=="bottom-center"||r=="bottom-right"?h="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(h="-50%");const c=`translate(${l}, ${h}) translate(${o}, ${a})`;this.rendered.transform_!=c&&(this.rendered.transform_=c,i.transform=c)}getOptions(){return this.options}}class Fa extends lr{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(X.CHANGE)}release(){this.setState(N.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==N.EMPTY){if(this.state!==N.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){B()}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;const n=e-i+1e3/60;return n>=this.transition_?1:Ch(n/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()}}function Bo(s){return s instanceof Image||s instanceof HTMLCanvasElement||s instanceof HTMLVideoElement||s instanceof ImageBitmap?s:null}const $g=new Error("disposed"),Wg=[256,256];class Ul extends Fa{constructor(t){const e=N.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_;const t=Bo(this.data_);return t?[t.width,t.height]:Wg}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==N.IDLE&&this.state!==N.ERROR)return;this.state=N.LOADING,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=N.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=N.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort($g),this.controller_=null),super.disposeInternal()}}class gc extends Fa{constructor(t,e,i,n,r,o){super(t,e,o),this.crossOrigin_=n,this.src_=i,this.key=i,this.image_,jt?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,n!==null&&(this.image_.crossOrigin=n)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=N.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}handleImageError_(){this.state=N.ERROR,this.unlistenImage_(),this.image_=Xg(),this.changed()}handleImageLoad_(){if(jt)this.state=N.LOADED;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=N.LOADED:this.state=N.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==N.ERROR&&(this.state=N.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==N.IDLE&&(this.state=N.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=hg(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 Xg(){const s=mt(1,1);return s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,1,1),s.canvas}class Ma{constructor(t,e,i,n){this.minX=t,this.maxX=e,this.minY=i,this.maxY=n}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 Bi(s,t,e,i,n){return n!==void 0?(n.minX=s,n.maxX=t,n.minY=e,n.maxY=i,n):new Ma(s,t,e,i)}let eo;const en=[];function $l(s,t,e,i,n){s.beginPath(),s.moveTo(0,0),s.lineTo(t,e),s.lineTo(i,n),s.closePath(),s.save(),s.clip(),s.fillRect(0,0,Math.max(t,i)+1,Math.max(e,n)),s.restore()}function io(s,t){return Math.abs(s[t*4]-210)>2||Math.abs(s[t*4+3]-.75*255)>2}function jg(){if(eo===void 0){const s=mt(6,6,en);s.globalCompositeOperation="lighter",s.fillStyle="rgba(210, 0, 0, 0.75)",$l(s,4,5,4,0),$l(s,4,5,0,5);const t=s.getImageData(0,0,3,3).data;eo=io(t,0)||io(t,4)||io(t,8),Er(s),en.push(s.canvas)}return eo}function Wl(s,t,e,i){const n=_r(e,t,s);let r=Xs(t,i,e);const o=t.getMetersPerUnit();o!==void 0&&(r*=o);const a=s.getMetersPerUnit();a!==void 0&&(r/=a);const l=s.getExtent();if(!l||Ci(l,n)){const h=Xs(s,r,n)/r;isFinite(h)&&h>0&&(r/=h)}return r}function Yg(s,t,e,i){const n=ii(e);let r=Wl(s,t,n,i);return(!isFinite(r)||r<=0)&&Ko(e,function(o){return r=Wl(s,t,o,i),isFinite(r)&&r>0}),r}function Vg(s,t,e,i,n,r,o,a,l,h,c,u,d,f){const g=mt(Math.round(e*s),Math.round(e*t),en);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function m(E){return Math.round(E*e)/e}g.globalCompositeOperation="lighter";const _=Vt();l.forEach(function(E,v,R){_h(_,E.extent)});let p;const y=e/i,T=(u?1:1+Math.pow(2,-24))/y;p=mt(Math.round(it(_)*y),Math.round(Lt(_)*y),en),u||(p.imageSmoothingEnabled=!1),l.forEach(function(E,v,R){if(E.image.width>0&&E.image.height>0){if(E.clipExtent){p.save();const L=(E.clipExtent[0]-_[0])*y,M=-(E.clipExtent[3]-_[3])*y,F=it(E.clipExtent)*y,W=Lt(E.clipExtent)*y;p.rect(u?L:Math.round(L),u?M:Math.round(M),u?F:Math.round(L+F)-Math.round(L),u?W:Math.round(M+W)-Math.round(M)),p.clip()}const S=(E.extent[0]-_[0])*y,w=-(E.extent[3]-_[3])*y,I=it(E.extent)*y,b=Lt(E.extent)*y;p.drawImage(E.image,h,h,E.image.width-2*h,E.image.height-2*h,u?S:Math.round(S),u?w:Math.round(w),u?I:Math.round(S+I)-Math.round(S),u?b:Math.round(w+b)-Math.round(w)),E.clipExtent&&p.restore()}});const x=ri(o);return a.getTriangles().forEach(function(E,v,R){const S=E.source,w=E.target;let I=S[0][0],b=S[0][1],L=S[1][0],M=S[1][1],F=S[2][0],W=S[2][1];const A=m((w[0][0]-x[0])/r),$=m(-(w[0][1]-x[1])/r),D=m((w[1][0]-x[0])/r),j=m(-(w[1][1]-x[1])/r),K=m((w[2][0]-x[0])/r),nt=m(-(w[2][1]-x[1])/r),P=I,St=b;I=0,b=0,L-=P,M-=St,F-=P,W-=St;const Ft=[[L,M,0,0,D-A],[F,W,0,0,K-A],[0,0,L,M,j-$],[0,0,F,W,nt-$]],dt=Ru(Ft);if(!dt)return;if(g.save(),g.beginPath(),jg()||!u){g.moveTo(D,j);const wt=4,fe=A-D,oe=$-j;for(let zt=0;zt<wt;zt++)g.lineTo(D+m((zt+1)*fe/wt),j+m(zt*oe/(wt-1))),zt!=wt-1&&g.lineTo(D+m((zt+1)*fe/wt),j+m((zt+1)*oe/(wt-1)));g.lineTo(K,nt)}else g.moveTo(D,j),g.lineTo(A,$),g.lineTo(K,nt);g.clip(),g.transform(dt[0],dt[2],dt[1],dt[3],A,$),g.translate(_[0]-P,_[3]-St);let Bt;if(p)Bt=p.canvas,g.scale(T,-T);else{const wt=l[0],fe=wt.extent;Bt=wt.image,g.scale(it(fe)/Bt.width,-Lt(fe)/Bt.height)}g.drawImage(Bt,0,0),g.restore()}),p&&(Er(p),en.push(p.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(E,v,R){const S=E.target,w=(S[0][0]-x[0])/r,I=-(S[0][1]-x[1])/r,b=(S[1][0]-x[0])/r,L=-(S[1][1]-x[1])/r,M=(S[2][0]-x[0])/r,F=-(S[2][1]-x[1])/r;g.beginPath(),g.moveTo(b,L),g.lineTo(w,I),g.lineTo(M,F),g.closePath(),g.stroke()}),g.restore()),g.canvas}const Zg=10,Xl=.25;class Kg{constructor(t,e,i,n,r,o,a){this.sourceProj_=t,this.targetProj_=e;let l={};const h=a?fd(T=>ct(a,_r(T,this.targetProj_,this.sourceProj_))):Ri(this.targetProj_,this.sourceProj_);this.transformInv_=function(T){const x=T[0]+"/"+T[1];return l[x]||(l[x]=h(T)),l[x]},this.maxSourceExtent_=n,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&it(n)>=it(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?it(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?it(this.targetProj_.getExtent()):null;const c=ri(i),u=ur(i),d=cr(i),f=hr(i),g=this.transformInv_(c),m=this.transformInv_(u),_=this.transformInv_(d),p=this.transformInv_(f),y=Zg+(o?Math.max(0,Math.ceil(Math.log2(To(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,m,_,p,y),this.wrapsXInSource_){let T=1/0;this.triangles_.forEach(function(x,E,v){T=Math.min(T,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])-T>this.sourceWorldWidth_/2){const E=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];E[0][0]-T>this.sourceWorldWidth_/2&&(E[0][0]-=this.sourceWorldWidth_),E[1][0]-T>this.sourceWorldWidth_/2&&(E[1][0]-=this.sourceWorldWidth_),E[2][0]-T>this.sourceWorldWidth_/2&&(E[2][0]-=this.sourceWorldWidth_);const v=Math.min(E[0][0],E[1][0],E[2][0]);Math.max(E[0][0],E[1][0],E[2][0])-v<this.sourceWorldWidth_/2&&(x.source=E)}})}l={}}addTriangle_(t,e,i,n,r,o){this.triangles_.push({source:[n,r,o],target:[t,e,i]})}addQuad_(t,e,i,n,r,o,a,l,h){const c=zs([r,o,a,l]),u=this.sourceWorldWidth_?it(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=zs([t,e,i,n]);g=it(_)/this.targetWorldWidth_>Xl||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>Xl||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!ft(c,this.maxSourceExtent_))return;let m=0;if(!g&&(!isFinite(r[0])||!isFinite(r[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(r[0])||!isFinite(r[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){const _=[(t[0]+i[0])/2,(t[1]+i[1])/2],p=this.transformInv_(_);let y;f?y=(Qe(r[0],d)+Qe(a[0],d))/2-Qe(p[0],d):y=(r[0]+a[0])/2-p[0];const T=(r[1]+a[1])/2-p[1];g=y*y+T*T>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const _=[(e[0]+i[0])/2,(e[1]+i[1])/2],p=this.transformInv_(_),y=[(n[0]+t[0])/2,(n[1]+t[1])/2],T=this.transformInv_(y);this.addQuad_(t,e,_,y,r,o,p,T,h-1),this.addQuad_(y,_,i,n,T,p,a,l,h-1)}else{const _=[(t[0]+e[0])/2,(t[1]+e[1])/2],p=this.transformInv_(_),y=[(i[0]+n[0])/2,(i[1]+n[1])/2],T=this.transformInv_(y);this.addQuad_(t,_,y,n,r,p,T,l,h-1),this.addQuad_(_,e,i,y,p,o,a,T,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(t,i,n,r,a,l),(m&14)==0&&this.addTriangle_(t,i,e,r,a,o),m&&((m&13)==0&&this.addTriangle_(e,n,t,o,l,r),(m&7)==0&&this.addTriangle_(e,n,i,o,l,a))}calculateSourceExtent(){const t=Vt();return this.triangles_.forEach(function(e,i,n){const r=e.source;Fn(t,r[0]),Fn(t,r[1]),Fn(t,r[2])}),t}getTriangles(){return this.triangles_}}const Hg=.5;class _c extends Fa{constructor(t,e,i,n,r,o,a,l,h,c,u,d){super(r,N.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=n,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const f=n.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let m=this.sourceTileGrid_.getExtent();const _=g?Ne(f,g):f;if(To(_)===0){this.state=N.EMPTY;return}const p=t.getExtent();p&&(m?m=Ne(m,p):m=p);const y=n.getResolution(this.wrappedTileCoord_[0]),T=Yg(t,i,_,y);if(!isFinite(T)||T<=0){this.state=N.EMPTY;return}const x=c!==void 0?c:Hg;if(this.triangulation_=new Kg(t,i,_,m,T*x,y),this.triangulation_.getTriangles().length===0){this.state=N.EMPTY;return}this.sourceZ_=e.getZForResolution(T);let E=this.triangulation_.calculateSourceExtent();if(m&&(t.canWrapX()?(E[1]=ot(E[1],m[1],m[3]),E[3]=ot(E[3],m[1],m[3])):E=Ne(E,m)),!To(E))this.state=N.EMPTY;else{let v=0,R=0;t.canWrapX()&&(v=it(p),R=Math.floor((E[0]-p[0])/v)),xh(E.slice(),t,!0).forEach(w=>{const I=e.getTileRangeForExtentAndZ(w,this.sourceZ_);for(let b=I.minX;b<=I.maxX;b++)for(let L=I.minY;L<=I.maxY;L++){const M=h(this.sourceZ_,b,L,a);if(M){const F=R*v;this.sourceTiles_.push({tile:M,offset:F})}}++R}),this.sourceTiles_.length===0&&(this.state=N.EMPTY)}}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const i=e.tile;if(i&&i.getState()==N.LOADED){const n=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);n[0]+=e.offset,n[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:n,clipExtent:r,image:i.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=N.ERROR;else{const e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),n=typeof i=="number"?i:i[0],r=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_=Vg(n,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=N.LOADED}this.changed()}load(){if(this.state==N.IDLE){this.state=N.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const i=e.getState();if(i==N.IDLE||i==N.LOADING){t++;const n=Z(e,X.CHANGE,r=>{const o=e.getState();(o==N.LOADED||o==N.ERROR||o==N.EMPTY)&&(st(n),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},i,n){e.getState()==N.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(st),this.sourcesListenerKeys_=null}release(){this.canvas_&&(Er(this.canvas_.getContext("2d")),en.push(this.canvas_),this.canvas_=null),super.release()}}class jl{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof Zn&&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){const i=this.entries_[t];return H(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){const e=this.entries_[t];return H(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(){const t=new Array(this.count_);let e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.key_;return t}getValues(){const t=new Array(this.count_);let 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(){const 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){H(!(t in this.entries_),"Tried to set a value for a key that is used already");const 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}}function Qs(s,t,e,i){return i!==void 0?(i[0]=s,i[1]=t,i[2]=e,i):[s,t,e]}function qg(s,t,e){return s+"/"+t+"/"+e}function Ds(s,t,e,i,n){return`${k(s)},${t},${qg(e,i,n)}`}function Jg(s){return Qg(s[0],s[1],s[2])}function Qg(s,t,e){return(t<<s)+e}function t_(s,t){const e=s[0],i=s[1],n=s[2];if(t.getMinZoom()>e||e>t.getMaxZoom())return!1;const r=t.getFullTileRange(e);return r?r.containsXY(i,n):!0}class Oa{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Vs(),{get:(t,e)=>{if(typeof Vs()[e]=="function")return this.push_(e),this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){const 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,n=e.length;i<n;++i){const r=e[i];if(typeof r=="function"){r(t);continue}const o=e[++i];if(typeof t[r]=="function")t[r](...o);else{if(typeof o=="function"){t[r]=o(t);continue}t[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const e_=5;class mc extends Kn{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=e_}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return B()}getData(t){return null}prepareFrame(t){return B()}renderFrame(t,e){return B()}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===Y.LOADED||e.getState()===Y.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=Y.LOADED&&e!=Y.ERROR&&t.addEventListener(X.CHANGE,this.boundHandleImageChange_),e==Y.IDLE&&(t.load(),e=t.getState()),e==Y.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Yl=[];let Zi=null;function i_(){Zi=mt(1,1,void 0,{willReadFrequently:!0})}class Da extends mc{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=_t(),this.pixelTransform=_t(),this.inversePixelTransform=_t(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){Zi||i_(),Zi.clearRect(0,0,1,1);let n;try{Zi.drawImage(t,e,i,1,1,0,0,1,1),n=Zi.getImageData(0,0,1,1).data}catch{return Zi=null,null}return n}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i){const n=this.getLayer().getClassName();let r,o;if(t&&t.className===n&&(!i||t&&t.style.backgroundColor&&ze(ue(t.style.backgroundColor),ue(i)))){const a=t.firstElementChild;He(a)&&(o=a.getContext("2d"))}if(o&&Td(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){r=jt?Yh():document.createElement("div"),r.className=n;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=mt();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){const n=ri(i),r=ur(i),o=cr(i),a=hr(i);ct(e.coordinateToPixelTransform,n),ct(e.coordinateToPixelTransform,r),ct(e.coordinateToPixelTransform,o),ct(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;ct(l,n),ct(l,r),ct(l,o),ct(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(n[0]),Math.round(n[1])),t.lineTo(Math.round(r[0]),Math.round(r[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){const i=t.extent,n=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,a=Math.round(it(i)/n*o),l=Math.round(Lt(i)/n*o);ne(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),Nn(this.inversePixelTransform,this.pixelTransform);const h=Ed(this.pixelTransform);if(this.useContainer(e,h,this.getBackground(t)),!this.containerReused){const 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){const n=this.getLayer();if(n.hasListener(t)){const r=new On(t,this.inversePixelTransform,i,e);n.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Ct.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Ct.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new Oa),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Ct.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Ct.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,n,r,o,a){const l=r/2,h=o/2,c=n/e,u=-c,d=-t[0]+a,f=-t[1];return ne(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function no(s,t,e){if(!(e in s))return s[e]=new Set([t]),!0;const i=s[e],n=i.has(t);return n||i.add(t),!n}function n_(s,t,e){const i=s[e];return i?i.delete(t):!1}function Vl(s,t){const e=s.layerStatesArray[s.layerIndex];e.extent&&(t=Ne(t,ye(e.extent,s.viewState.projection)));const i=e.layer.getRenderSource();if(!i.getWrapX()){const n=i.getTileGridForProjection(s.viewState.projection).getExtent();n&&(t=Ne(t,n))}return t}class pc extends Da{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=Vt(),this.tempTileRange_=new Ma(0,0,0,0),this.tempTileCoord_=Qs(0,0,0);const i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new jl(i),this.sourceTileCache_=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new jl(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,n){const r=this.tileCache_,a=this.getLayer().getSource(),l=Ds(a,a.getKey(),t,e,i);let h;if(r.containsKey(l))h=r.get(l);else{const c=n.viewState.projection,u=a.getProjection();if(h=a.getTile(t,e,i,n.pixelRatio,c,!u||yi(u,c)?void 0:this.getSourceTileCache()),!h)return null;r.set(l,h)}return h}getTile(t,e,i,n){const r=this.getOrCreateTile(t,e,i,n);return r||null}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),n=ct(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!Ci(r,n))return null;const 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){const u=l.getTileCoordForCoordAndZ(n,c),d=this.getTile(c,u[1],u[2],e);if(!d||d.getState()!==N.LOADED)continue;const f=l.getOrigin(c),g=bt(l.getTileSize(c)),m=l.getResolution(c);let _;if(d instanceof gc||d instanceof _c)_=d.getImage();else if(d instanceof Ul){if(_=Bo(d.getData()),!_)continue}else continue;const p=Math.floor(h*((n[0]-f[0])/m-u[1]*g[0])),y=Math.floor(h*((f[1]-n[1])/m-u[2]*g[1])),T=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(_,p+T,y+T)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const 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,n,r){const o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=k(l);c in t.wantedTiles||(t.wantedTiles[c]={});const u=t.wantedTiles[c],d=a.getMapInternal(),f=Math.max(i-r,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?ph(o.center,o.resolution,g,t.size):void 0;for(let _=i;_>=f;--_){const p=h.getTileRangeForExtentAndZ(e,_,this.tempTileRange_),y=h.getResolution(_);for(let T=p.minX;T<=p.maxX;++T)for(let x=p.minY;x<=p.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([_,T,x],m))continue;const E=this.getTile(_,T,x,t);if(!E||!no(n,E,_))continue;const R=E.getKey();if(u[R]=!0,E.getState()===N.IDLE&&!t.tileQueue.isKeyQueued(R)){const S=Qs(_,T,x,this.tempTileCoord_);t.tileQueue.enqueue([E,c,h.getTileCoordCenter(S),y])}}}}findStaleTile_(t,e){const i=this.tileCache_,n=t[0],r=t[1],o=t[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){const h=Ds(this.getLayer().getSource(),a[l],n,r,o);if(i.containsKey(h)){const c=i.peek(h);if(c.getState()===N.LOADED)return c.endTransition(k(this)),no(e,c,n),!0}}return!1}findAltTiles_(t,e,i,n){const r=t.getTileRangeForTileCoordAndZ(e,i,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=r.minX;c<=r.maxX;++c)for(let u=r.minY;u<=r.maxY;++u){const d=Ds(l,h,i,c,u);let f=!1;if(a.containsKey(d)){const g=a.peek(d);g.getState()===N.LOADED&&(no(n,g,i),f=!0)}f||(o=!1)}return o}renderFrame(t,e){this.renderComplete=!0;const i=t.layerStatesArray[t.layerIndex],n=t.viewState,r=n.projection,o=n.resolution,a=n.center,l=t.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(r),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=t.extent;const _=c.getTilePixelRatio(l);this.prepareContainer(t,e);const p=this.context.canvas.width,y=this.context.canvas.height,T=i.extent&&ye(i.extent);T&&(m=Ne(m,ye(i.extent)));const x=f*p/2/_,E=f*y/2/_,v=[a[0]-x,a[1]-E,a[0]+x,a[1]+E],R={};this.renderedTiles.length=0;const S=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){const D=u.getZForResolution(n.nextResolution,c.zDirection),j=Vl(t,t.nextExtent);this.enqueueTiles(t,j,D,R,S)}const w=Vl(t,m);if(this.enqueueTiles(t,w,d,R,0),S>0&&setTimeout(()=>{this.enqueueTiles(t,w,d-1,R,S-1)},0),!(d in R))return this.container;const I=k(this),b=t.time;for(const D of R[d]){const j=D.getState();if(j===N.EMPTY)continue;const K=D.tileCoord;if(j===N.LOADED&&D.getAlpha(I,b)===1){D.endTransition(I);continue}if(j!==N.ERROR&&(this.renderComplete=!1),this.findStaleTile_(K,R)){n_(R,D,d),t.animate=!0;continue}if(this.findAltTiles_(u,K,d+1,R))continue;const St=u.getMinZoom();for(let Ft=d-1;Ft>=St&&!this.findAltTiles_(u,K,Ft,R);--Ft);}const L=f/o*l/_,M=this.getRenderContext(t);ne(this.tempTransform,p/2,y/2,L,L,0,-p/2,-y/2),i.extent&&this.clipUnrotated(M,t,T),c.getInterpolate()||(M.imageSmoothingEnabled=!1),this.preRender(M,t);const F=Object.keys(R).map(Number);F.sort(Ee);let W;const A=[],$=[];for(let D=F.length-1;D>=0;--D){const j=F[D],K=c.getTilePixelSize(j,l,r),P=u.getResolution(j)/f,St=K[0]*P*L,Ft=K[1]*P*L,dt=u.getTileCoordForCoordAndZ(ri(v),j),Bt=u.getTileCoordExtent(dt),wt=ct(this.tempTransform,[_*(Bt[0]-v[0])/f,_*(v[3]-Bt[3])/f]),fe=_*c.getGutterForProjection(r);for(const oe of R[j]){if(oe.getState()!==N.LOADED)continue;const zt=oe.tileCoord,os=dt[1]-zt[1],Ar=Math.round(wt[0]-(os-1)*St),pn=dt[2]-zt[2],ai=Math.round(wt[1]-(pn-1)*Ft),Kt=Math.round(wt[0]-os*St),ge=Math.round(wt[1]-pn*Ft),bi=Ar-Kt,Fi=ai-ge,yn=F.length===1;let li=!1;W=[Kt,ge,Kt+bi,ge,Kt+bi,ge+Fi,Kt,ge+Fi];for(let Mi=0,Oi=A.length;Mi<Oi;++Mi)if(!yn&&j<$[Mi]){const xt=A[Mi];ft([Kt,ge,Kt+bi,ge+Fi],[xt[0],xt[3],xt[4],xt[7]])&&(li||(M.save(),li=!0),M.beginPath(),M.moveTo(W[0],W[1]),M.lineTo(W[2],W[3]),M.lineTo(W[4],W[5]),M.lineTo(W[6],W[7]),M.moveTo(xt[6],xt[7]),M.lineTo(xt[4],xt[5]),M.lineTo(xt[2],xt[3]),M.lineTo(xt[0],xt[1]),M.clip())}A.push(W),$.push(j),this.drawTile(oe,t,Kt,ge,bi,Fi,fe,yn),li&&M.restore(),this.renderedTiles.unshift(oe),this.updateUsedTiles(t.usedTiles,c,oe)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!vi(this.renderedExtent_,v),this.renderedExtent_=v,this.renderedPixelRatio=l,this.postRender(this.context,t),i.extent&&M.restore(),M.imageSmoothingEnabled=!0,this.renderComplete){const D=(j,K)=>{const nt=k(c),P=K.wantedTiles[nt],St=P?Object.keys(P).length:0;this.updateCacheSize(St),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(D)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,n,r,o,a,l){let h;if(t instanceof Ul){if(h=Bo(t.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(t);if(!h)return;const c=this.getRenderContext(e),u=k(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,n,r,o),g&&c.restore(),f!==d.opacity?e.animate=!0:l&&t.endTransition(u)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const n=k(e);n in t||(t[n]={}),t[n][i.getKey()]=!0}}const qe={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class s_ extends es{constructor(t){t=t||{};const 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(qe.PRELOAD)}setPreload(t){this.set(qe.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(qe.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(qe.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}class Xp extends s_{constructor(t){super(t)}createRenderer(){return new pc(this,{cacheSize:this.getCacheSize()})}}class yc{drawCustom(t,e,i,n,r){}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){}}const G={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},Es=[G.FILL],Je=[G.STROKE],pi=[G.BEGIN_PATH],Zl=[G.CLOSE_PATH];class rs extends yc{constructor(t,e,i,n){super(),this.tolerance=t,this.maxExtent=e,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(t){const e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){const i=this.getBufferedMaxExtent(),n=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=t.length;a<l;a+=e)n[0]=t[a],n[1]=t[a+1],Ci(i,n)&&(r[o++]=n[0],r[o++]=n[1]);return o}appendFlatLineCoordinates(t,e,i,n,r,o){const a=this.coordinates;let l=a.length;const h=this.getBufferedMaxExtent();o&&(e+=n);let c=t[e],u=t[e+1];const d=this.tmpCoordinate_;let f=!0,g,m,_;for(g=e+n;g<i;g+=n)d[0]=t[g],d[1]=t[g+1],_=Eo(h,d),_!==m?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):_===Et.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],m=_;return(r&&f||g===e+n)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(t,e,i,n,r){for(let o=0,a=i.length;o<a;++o){const l=i[o],h=this.appendFlatLineCoordinates(t,e,l,n,!1,!1);r.push(h),e=l}return e}drawCustom(t,e,i,n,r){this.beginGeometry(t,e,r);const o=t.getType(),a=t.getStride(),l=this.coordinates.length;let h,c,u,d,f;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),d=[];const g=t.getEndss();f=0;for(let m=0,_=g.length;m<_;++m){const p=[];f=this.drawCustomCoordinates_(h,f,g[m],a,p),d.push(p)}this.instructions.push([G.CUSTOM,l,d,t,i,Ao,r]),this.hitDetectionInstructions.push([G.CUSTOM,l,d,t,n||i,Ao,r]);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([G.CUSTOM,l,u,t,i,Gn,r]),this.hitDetectionInstructions.push([G.CUSTOM,l,u,t,n||i,Gn,r]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([G.CUSTOM,l,c,t,i,Ke,r]),this.hitDetectionInstructions.push([G.CUSTOM,l,c,t,n||i,Ke,r]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([G.CUSTOM,l,c,t,i,Ke,r]),this.hitDetectionInstructions.push([G.CUSTOM,l,c,t,n||i,Ke,r]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([G.CUSTOM,l,c,t,i,void 0,r]),this.hitDetectionInstructions.push([G.CUSTOM,l,c,t,n||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[G.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[G.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;t.reverse();let e;const i=t.length;let n,r,o=-1;for(e=0;e<i;++e)n=t[e],r=n[0],r==G.END_GEOMETRY?o=e:r==G.BEGIN_GEOMETRY&&(n[2]=e,cu(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=xe(i||Ot)}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const i=t.getColor();e.strokeStyle=xe(i||Un);const n=t.getLineCap();e.lineCap=n!==void 0?n:an;const r=t.getLineDash();e.lineDash=r?r.slice():Ge;const o=t.getLineDashOffset();e.lineDashOffset=o||Be;const a=t.getLineJoin();e.lineJoin=a!==void 0?a:ln;const l=t.getWidth();e.lineWidth=l!==void 0?l:Wn;const h=t.getMiterLimit();e.miterLimit=h!==void 0?h:zn,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;return e}setFillStrokeStyle(t,e){const i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){const e=t.fillStyle,i=[G.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[G.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){const i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,n=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=n||r!=t.currentLineDash&&!ze(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=n,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[G.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=fh(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;sn(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class r_ extends rs{constructor(t,e,i,n){super(t,e,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(t,e,i){if(!this.image_||this.maxExtent&&!Ci(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const n=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(n,r);this.instructions.push([G.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([G.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);const n=t.getFlatCoordinates(),r=[];for(let l=0,h=n.length;l<h;l+=t.getStride())(!this.maxExtent||Ci(this.maxExtent,n.slice(l,l+2)))&&r.push(n[l],n[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([G.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([G.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){const i=t.getAnchor(),n=t.getSize(),r=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_=n[1],this.opacity_=t.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=n[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}class o_ extends rs{constructor(t,e,i,n){super(t,e,i,n)}drawFlatCoordinates_(t,e,i,n){const r=this.coordinates.length,o=this.appendFlatLineCoordinates(t,e,i,n,!1,!1),a=[G.MOVE_TO_LINE_TO,r,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),i}drawLineString(t,e,i){const n=this.state,r=n.strokeStyle,o=n.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(n,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([G.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Ge,Be],pi);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l),this.hitDetectionInstructions.push(Je),this.endGeometry(e)}drawMultiLineString(t,e,i){const n=this.state,r=n.strokeStyle,o=n.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(n,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([G.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Ge,Be],pi);const a=t.getEnds(),l=t.getFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinates_(l,c,a[u],h);this.hitDetectionInstructions.push(Je),this.endGeometry(e)}finish(){const t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Je),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Je),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(pi)}}class Kl extends rs{constructor(t,e,i,n){super(t,e,i,n)}drawFlatCoordinatess_(t,e,i,n){const r=this.state,o=r.fillStyle!==void 0,a=r.strokeStyle!==void 0,l=i.length;this.instructions.push(pi),this.hitDetectionInstructions.push(pi);for(let h=0;h<l;++h){const c=i[h],u=this.coordinates.length,d=this.appendFlatLineCoordinates(t,e,c,n,!0,!a),f=[G.MOVE_TO_LINE_TO,u,d];this.instructions.push(f),this.hitDetectionInstructions.push(f),a&&(this.instructions.push(Zl),this.hitDetectionInstructions.push(Zl)),e=c}return o&&(this.instructions.push(Es),this.hitDetectionInstructions.push(Es)),a&&(this.instructions.push(Je),this.hitDetectionInstructions.push(Je)),e}drawCircle(t,e,i){const n=this.state,r=n.fillStyle,o=n.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([G.SET_FILL_STYLE,Ot]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([G.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Ge,Be]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[G.CIRCLE,h];this.instructions.push(pi,c),this.hitDetectionInstructions.push(pi,c),n.fillStyle!==void 0&&(this.instructions.push(Es),this.hitDetectionInstructions.push(Es)),n.strokeStyle!==void 0&&(this.instructions.push(Je),this.hitDetectionInstructions.push(Je)),this.endGeometry(e)}drawPolygon(t,e,i){const n=this.state,r=n.fillStyle,o=n.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([G.SET_FILL_STYLE,Ot]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([G.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Ge,Be]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),h=t.getStride();this.drawFlatCoordinatess_(l,0,a,h),this.endGeometry(e)}drawMultiPolygon(t,e,i){const n=this.state,r=n.fillStyle,o=n.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([G.SET_FILL_STYLE,Ot]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([G.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Ge,Be]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinatess_(l,c,a[u],h);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(t!==0){const e=this.coordinates;for(let i=0,n=e.length;i<n;++i)e[i]=di(e[i],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}}function a_(s,t,e,i,n){const r=[];let o=e,a=0,l=t.slice(e,2);for(;a<s&&o+n<i;){const[h,c]=l.slice(-2),u=t[o+n],d=t[o+n+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=s){const g=(s-a+f)/f,m=Ut(h,u,g),_=Ut(c,d,g);l.push(m,_),r.push(l),l=[m,_],a==s&&(o+=n),a=0}else if(a<s)l.push(t[o+n],t[o+n+1]),o+=n;else{const g=f-a,m=Ut(h,u,g/f),_=Ut(c,d,g/f);l.push(m,_),r.push(l),l=[m,_],a=0,o+=n}}return a>0&&r.push(l),r}function l_(s,t,e,i,n){let r=e,o=e,a=0,l=0,h=e,c,u,d,f,g,m,_,p,y,T;for(u=e;u<i;u+=n){const x=t[u],E=t[u+1];g!==void 0&&(y=x-g,T=E-m,f=Math.sqrt(y*y+T*T),_!==void 0&&(l+=d,c=Math.acos((_*y+p*T)/(d*f)),c>s&&(l>a&&(a=l,r=h,o=u),l=0,h=u-n)),d=f,_=y,p=T),g=x,m=E}return l+=f,l>a?[h,u]:[r,o]}const tr={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class h_ extends rs{constructor(t,e,i,n){super(t,e,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[Ot]={fillStyle:Ot},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const n=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!n&&!r)return;const a=this.coordinates;let l=a.length;const h=t.getType();let c=null,u=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!ft(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"){const _=t.getEndss();d=[];for(let p=0,y=_.length;p<y;++p)d.push(_[p][0])}this.beginGeometry(t,e,i);const f=o.repeat,g=f?void 0:o.textAlign;let m=0;for(let _=0,p=d.length;_<p;++_){let y;f?y=a_(f*this.resolution,c,m,d[_],u):y=[c.slice(m,d[_])];for(let T=0,x=y.length;T<x;++T){const E=y[T];let v=0,R=E.length;if(g==null){const w=l_(o.maxAngle,E,0,E.length,2);v=w[0],R=w[1]}for(let w=v;w<R;w+=u)a.push(E[w],E[w+1]);const S=a.length;m=d[_],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":const x=t.getFlatInteriorPoints();c=[];for(let E=0,v=x.length;E<v;E+=3)o.overflow||d.push(x[E+2]/this.resolution),c.push(x[E],x[E+1]);if(c.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((E,v)=>{const R=a[(x+v)*2]===c[v*u]&&a[(x+v)*2+1]===c[v*u+1];return R||--x,R})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,m=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let _=o.padding;if(_!=mi&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],E=o.padding[1],v=o.padding[2],R=o.padding[3];o.scale[0]<0&&(E=-E,R=-R),o.scale[1]<0&&(x=-x,v=-v),_=[x,E,v,R]}const p=this.pixelRatio;this.instructions.push([G.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,_==mi?mi:_.map(function(x){return x*p}),g,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const y=1/p,T=g?g.slice(0):null;T&&(T[1]=Ot),this.hitDetectionInstructions.push([G.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[y,y],NaN,this.declutterMode_,this.declutterImageWithText_,_,T,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Ot:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,n=this.strokeKey_;t&&(n in this.strokeStates||(this.strokeStates[n]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||$n,justify:e.justify,textBaseline:e.textBaseline||Hs,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,n=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=tr[n.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(n.scale[0])/2:0;this.instructions.push([G.DRAW_CHARS,t,e,h,n.overflow,a,n.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([G.DRAW_CHARS,t,e,h,n.overflow,a&&Ot,n.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,n,r;if(!t)this.text_="";else{const o=t.getFill();o?(n=this.textFillState_,n||(n={},this.textFillState_=n),n.fillStyle=xe(o.getColor()||Ot)):(n=null,this.textFillState_=n);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const m=a.getLineDash(),_=a.getLineDashOffset(),p=a.getWidth(),y=a.getMiterLimit();r.lineCap=a.getLineCap()||an,r.lineDash=m?m.slice():Ge,r.lineDashOffset=_===void 0?Be:_,r.lineJoin=a.getLineJoin()||ln,r.lineWidth=p===void 0?Wn:p,r.miterLimit=y===void 0?zn:y,r.strokeStyle=xe(a.getColor()||Un)}i=this.textState_;const l=t.getFont()||nc;mg(l);const 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()||Hs,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||mi,i.scale=h===void 0?[1,1]:h;const 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_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:k(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.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:"|"+k(n.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const c_={Circle:Kl,Default:rs,Image:r_,LineString:o_,Polygon:Kl,Text:h_};class xc{constructor(t,e,i,n){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=n,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const n in i){const r=i[n].finish();t[e][n]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let n=this.buildersByZIndex_[i];n===void 0&&(n={},this.buildersByZIndex_[i]=n);let r=n[e];if(r===void 0){const o=c_[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),n[e]=r}return r}}function ka(s,t,e,i){let n=s[t],r=s[t+1],o=0;for(let a=t+i;a<e;a+=i){const l=s[a],h=s[a+1];o+=Math.sqrt((l-n)*(l-n)+(h-r)*(h-r)),n=l,r=h}return o}function u_(s,t,e,i,n,r,o,a,l,h,c,u,d=!0){let f=s[t],g=s[t+1],m=0,_=0,p=0,y=0;function T(){m=f,_=g,t+=i,f=s[t],g=s[t+1],y+=p,p=Math.sqrt((f-m)*(f-m)+(g-_)*(g-_))}do T();while(t<e-i&&y+p<r);let x=p===0?0:(r-y)/p;const E=Ut(m,f,x),v=Ut(_,g,x),R=t-i,S=y,w=r+a*l(h,n,c);for(;t<e-i&&y+p<w;)T();x=p===0?0:(w-y)/p;const I=Ut(m,f,x),b=Ut(_,g,x);let L=!1;if(d)if(u){const $=[E,v,I,b];ra($,0,4,2,u,$,$),L=$[0]>$[2]}else L=E>I;const M=Math.PI,F=[],W=R+i===t;t=R,p=0,y=S,f=s[t],g=s[t+1];let A;if(W){T(),A=Math.atan2(g-_,f-m),L&&(A+=A>0?-M:M);const $=(I+E)/2,D=(b+v)/2;return F[0]=[$,D,(w-r)/2,A,n],F}n=n.replace(/\n/g," ");for(let $=0,D=n.length;$<D;){T();let j=Math.atan2(g-_,f-m);if(L&&(j+=j>0?-M:M),A!==void 0){let dt=j-A;if(dt+=dt>M?-2*M:dt<-M?2*M:0,Math.abs(dt)>o)return null}A=j;const K=$;let nt=0;for(;$<D;++$){const dt=L?D-$-1:$,Bt=a*l(h,n[dt],c);if(t+i<e&&y+p<r+nt+Bt/2)break;nt+=Bt}if($===K)continue;const P=L?n.substring(D-K,D-$):n.substring(K,$);x=p===0?0:(r+nt/2-y)/p;const St=Ut(m,f,x),Ft=Ut(_,g,x);F.push([St,Ft,nt/2,j,P]),r+=nt}return F}const zi=Vt(),We=[],Pe=[],Ie=[],Xe=[];function Hl(s){return s[3].declutterBox}const ql=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ-࿿-]");function so(s,t){return t==="start"?t=ql.test(s)?"right":"left":t==="end"&&(t=ql.test(s)?"left":"right"),tr[t]}function d_(s,t,e){return e>0&&s.push(`
`,""),s.push(t,""),s}function f_(s,t,e){return e%2===0&&(s+=t),s}class g_{constructor(t,e,i,n,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=n.instructions,this.coordinates=n.coordinates,this.coordinateCache_={},this.renderedTransform_=_t(),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_=r?new Oa:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,n){const r=t+e+i+n;if(this.labels_[r])return this.labels_[r];const o=n?this.strokeStates[n]: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?tr[l.justify]:so(Array.isArray(t)?t[0]:t,l.textAlign||$n),d=n&&o.lineWidth?o.lineWidth:0,f=Array.isArray(t)?t:String(t).split(`
`).reduce(d_,[]),{width:g,height:m,widths:_,heights:p,lineWidths:y}=yg(l,f),T=g+d,x=[],E=(T+2)*c[0],v=(m+d)*c[1],R={width:E<0?Math.floor(E):Math.ceil(E),height:v<0?Math.floor(v):Math.ceil(v),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),n&&(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");const S=.5-u;let w=u*T+S*d;const I=[],b=[];let L=0,M=0,F=0,W=0,A;for(let $=0,D=f.length;$<D;$+=2){const j=f[$];if(j===`
`){M+=L,L=0,w=u*T+S*d,++W;continue}const K=f[$+1]||l.font;K!==A&&(n&&I.push("font",K),i&&b.push("font",K),A=K),L=Math.max(L,p[F]);const nt=[j,w+S*_[F]+u*(_[F]-y[W]),.5*(d+L)+M];w+=_[F],n&&I.push("strokeText",nt),i&&b.push("fillText",nt),++F}return Array.prototype.push.apply(x,I),Array.prototype.push.apply(x,b),this.labels_[r]=R,R}replayTextBackground_(t,e,i,n,r,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,n),t.lineTo.apply(t,r),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,n,r,o,a,l,h,c,u,d,f,g,m,_){a*=d[0],l*=d[1];let p=i-a,y=n-l;const T=r+h>t?t-h:r,x=o+c>e?e-c:o,E=g[3]+T*d[0]+g[1],v=g[0]+x*d[1]+g[2],R=p-g[3],S=y-g[0];(m||u!==0)&&(We[0]=R,Xe[0]=R,We[1]=S,Pe[1]=S,Pe[0]=R+E,Ie[0]=Pe[0],Ie[1]=S+v,Xe[1]=Ie[1]);let w;return u!==0?(w=ne(_t(),i,n,1,1,u,-i,-n),ct(w,We),ct(w,Pe),ct(w,Ie),ct(w,Xe),ve(Math.min(We[0],Pe[0],Ie[0],Xe[0]),Math.min(We[1],Pe[1],Ie[1],Xe[1]),Math.max(We[0],Pe[0],Ie[0],Xe[0]),Math.max(We[1],Pe[1],Ie[1],Xe[1]),zi)):ve(Math.min(R,R+E),Math.min(S,S+v),Math.max(R,R+E),Math.max(S,S+v),zi),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:T,drawImageH:x,originX:h,originY:c,declutterBox:{minX:zi[0],minY:zi[1],maxX:zi[2],maxY:zi[3],value:_},canvasTransform:w,scale:d}}replayImageOrLabel_(t,e,i,n,r,o,a){const l=!!(o||a),h=n.declutterBox,c=a?a[2]*n.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,We,Pe,Ie,Xe,o,a),xg(t,n.canvasTransform,r,i,n.originX,n.originY,n.drawImageW,n.drawImageH,n.drawImageX,n.drawImageY,n.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=ct(this.renderedTransform_,[0,0]),n=512*this.pixelRatio;t.save(),t.translate(i[0]%n,i[1]%n),e!==1&&t.scale(e,e),t.rotate(this.viewRotation_)}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,n){const r=this.textStates[e],o=this.createLabel(t,e,n,i),a=this.strokeStates[i],l=this.pixelRatio,h=so(Array.isArray(t)?t[0]:t,r.textAlign||$n),c=tr[r.textBaseline||Hs],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.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,n,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&ze(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Te(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),bh(this.renderedTransform_,i));let u=0;const d=n.length;let f=0,g,m,_,p,y,T,x,E,v,R,S,w,I,b=0,L=0;const M=this.coordinateCache_,F=this.viewRotation_,W=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,A={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:F},$=this.instructions!=n||this.overlaps?0:200;let D,j,K,nt;for(;u<d;){const P=n[u];switch(P[0]){case G.BEGIN_GEOMETRY:D=P[1],nt=P[3],D.getGeometry()?a!==void 0&&!ft(a,nt.getExtent())?u=P[2]+1:++u:u=P[2],h&&(h.zIndex=P[4]);break;case G.BEGIN_PATH:b>$&&(this.fill_(t),b=0),L>$&&(t.stroke(),L=0),!b&&!L&&(t.beginPath(),y=NaN,T=NaN),++u;break;case G.CIRCLE:f=P[1];const Ft=c[f],dt=c[f+1],Bt=c[f+2],wt=c[f+3],fe=Bt-Ft,oe=wt-dt,zt=Math.sqrt(fe*fe+oe*oe);t.moveTo(Ft+zt,dt),t.arc(Ft,dt,zt,0,2*Math.PI,!0),++u;break;case G.CLOSE_PATH:t.closePath(),++u;break;case G.CUSTOM:f=P[1],g=P[2];const os=P[3],Ar=P[4],pn=P[5];A.geometry=os,A.feature=D,u in M||(M[u]=[]);const ai=M[u];pn?pn(c,f,g,2,ai):(ai[0]=c[f],ai[1]=c[f+1],ai.length=2),h&&(h.zIndex=P[6]),Ar(ai,A),++u;break;case G.DRAW_IMAGE:f=P[1],g=P[2],v=P[3],m=P[4],_=P[5];let Kt=P[6];const ge=P[7],bi=P[8],Fi=P[9],yn=P[10];let li=P[11];const Mi=P[12];let Oi=P[13];p=P[14]||"declutter";const xt=P[15];if(!v&&P.length>=20){R=P[19],S=P[20],w=P[21],I=P[22];const Ht=this.drawLabelWithPointPlacement_(R,S,w,I);v=Ht.label,P[3]=v;const hi=P[23];m=(Ht.anchorX-hi)*this.pixelRatio,P[4]=m;const qt=P[24];_=(Ht.anchorY-qt)*this.pixelRatio,P[5]=_,Kt=v.height,P[6]=Kt,Oi=v.width,P[13]=Oi}let Lr;P.length>25&&(Lr=P[25]);let br,as,ls;P.length>17?(br=P[16],as=P[17],ls=P[18]):(br=mi,as=null,ls=null),yn&&W?li+=F:!yn&&!W&&(li-=F);let eu=0;for(;f<g;f+=2){if(Lr&&Lr[eu++]<Oi/this.pixelRatio)continue;const Ht=this.calculateImageOrLabelDimensions_(v.width,v.height,c[f],c[f+1],Oi,Kt,m,_,bi,Fi,li,Mi,r,br,!!as||!!ls,D),hi=[t,e,v,Ht,ge,as,ls];if(l){let qt,_e,Jt;if(xt){const ut=g-f;if(!xt[ut]){xt[ut]={args:hi,declutterMode:p};continue}const Mt=xt[ut];qt=Mt.args,_e=Mt.declutterMode,delete xt[ut],Jt=Hl(qt)}let Re,Se;if(qt&&(_e!=="declutter"||!l.collides(Jt))&&(Re=!0),(p!=="declutter"||!l.collides(Ht.declutterBox))&&(Se=!0),_e==="declutter"&&p==="declutter"){const ut=Re&&Se;Re=ut,Se=ut}Re&&(_e!=="none"&&l.insert(Jt),this.replayImageOrLabel_.apply(this,qt)),Se&&(p!=="none"&&l.insert(Ht.declutterBox),this.replayImageOrLabel_.apply(this,hi))}else this.replayImageOrLabel_.apply(this,hi)}++u;break;case G.DRAW_CHARS:const Ja=P[1],Qa=P[2],Fr=P[3],iu=P[4];I=P[5];const nu=P[6],tl=P[7],el=P[8];w=P[9];const Mr=P[10];R=P[11],Array.isArray(R)&&(R=R.reduce(f_,"")),S=P[12];const il=[P[13],P[13]];p=P[14]||"declutter";const su=P[15],Or=this.textStates[S],xn=Or.font,En=[Or.scale[0]*tl,Or.scale[1]*tl];let Tn;xn in this.widths_?Tn=this.widths_[xn]:(Tn={},this.widths_[xn]=Tn);const nl=ka(c,Ja,Qa,2),sl=Math.abs(En[0])*Ml(xn,R,Tn);if(iu||sl<=nl){const Ht=this.textStates[S].textAlign,hi=(nl-sl)*so(R,Ht),qt=u_(c,Ja,Qa,2,R,hi,nu,Math.abs(En[0]),Ml,xn,Tn,W?0:this.viewRotation_,su);t:if(qt){const _e=[];let Jt,Re,Se,ut,Mt;if(w)for(Jt=0,Re=qt.length;Jt<Re;++Jt){Mt=qt[Jt],Se=Mt[4],ut=this.createLabel(Se,S,"",w),m=Mt[2]+(En[0]<0?-Mr:Mr),_=Fr*ut.height+(.5-Fr)*2*Mr*En[1]/En[0]-el;const we=this.calculateImageOrLabelDimensions_(ut.width,ut.height,Mt[0],Mt[1],ut.width,ut.height,m,_,0,0,Mt[3],il,!1,mi,!1,D);if(l&&p==="declutter"&&l.collides(we.declutterBox))break t;_e.push([t,e,ut,we,1,null,null])}if(I)for(Jt=0,Re=qt.length;Jt<Re;++Jt){Mt=qt[Jt],Se=Mt[4],ut=this.createLabel(Se,S,I,""),m=Mt[2],_=Fr*ut.height-el;const we=this.calculateImageOrLabelDimensions_(ut.width,ut.height,Mt[0],Mt[1],ut.width,ut.height,m,_,0,0,Mt[3],il,!1,mi,!1,D);if(l&&p==="declutter"&&l.collides(we.declutterBox))break t;_e.push([t,e,ut,we,1,null,null])}l&&p!=="none"&&l.load(_e.map(Hl));for(let we=0,ru=_e.length;we<ru;++we)this.replayImageOrLabel_.apply(this,_e[we])}}++u;break;case G.END_GEOMETRY:if(o!==void 0){D=P[1];const Ht=o(D,nt,p);if(Ht)return Ht}++u;break;case G.FILL:$?b++:this.fill_(t),++u;break;case G.MOVE_TO_LINE_TO:for(f=P[1],g=P[2],j=c[f],K=c[f+1],t.moveTo(j,K),y=j+.5|0,T=K+.5|0,f+=2;f<g;f+=2)j=c[f],K=c[f+1],x=j+.5|0,E=K+.5|0,(f==g-2||x!==y||E!==T)&&(t.lineTo(j,K),y=x,T=E);++u;break;case G.SET_FILL_STYLE:this.alignAndScaleFill_=P[2],b&&(this.fill_(t),b=0,L&&(t.stroke(),L=0)),t.fillStyle=P[1],++u;break;case G.SET_STROKE_STYLE:L&&(t.stroke(),L=0),this.setStrokeStyle_(t,P),++u;break;case G.STROKE:$?L++:t.stroke(),++u;break;default:++u;break}}b&&this.fill_(t),L&&t.stroke()}execute(t,e,i,n,r,o){this.viewRotation_=n,this.execute_(t,e,i,this.instructions,r,void 0,void 0,o)}executeHitDetection(t,e,i,n,r){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,n,r)}}const fi=["Polygon","Circle","LineString","Image","Text","Default"],er=["Image","Text"],__=fi.filter(s=>!er.includes(s));class Ec{constructor(t,e,i,n,r,o,a){this.maxExtent_=t,this.overlaps_=n,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=_t(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(t,e){const 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(const i in t){let n=this.executorsByZIndex_[i];n===void 0&&(n={},this.executorsByZIndex_[i]=n);const r=t[i];for(const o in r){const a=r[o];n[o]=new g_(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let n=0,r=t.length;n<r;++n)if(t[n]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,n,r,o){n=Math.round(n);const a=n*2+1,l=ne(this.hitDetectionTransform_,n+.5,n+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=mt(a,a));const 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=Vt(),Fn(u,t),sn(u,e*(this.renderBuffer_+n),u));const d=m_(n);let f;function g(E,v,R){const S=c.getImageData(0,0,a,a).data;for(let w=0,I=d.length;w<I;w++)if(S[d[w]]>0){if(!o||R==="none"||f!=="Image"&&f!=="Text"||o.includes(E)){const b=(d[w]-3)/4,L=n-b%a,M=n-(b/a|0),F=r(E,v,L*L+M*M);if(F)return F}c.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(Ee);let _,p,y,T,x;for(_=m.length-1;_>=0;--_){const E=m[_].toString();for(y=this.executorsByZIndex_[E],p=fi.length-1;p>=0;--p)if(f=fi[p],T=y[f],T!==void 0&&(x=T.executeHitDetection(c,l,i,g,u),x))return x}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],n=e[1],r=e[2],o=e[3],a=[i,n,i,o,r,o,r,n];return Te(a,0,8,2,t,a),a}isEmpty(){return Ei(this.executorsByZIndex_)}execute(t,e,i,n,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?hu:Ee),o=o||fi;const h=fi.length;for(let c=0,u=l.length;c<u;++c){const d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,m=o.length;g<m;++g){const _=o[g],p=f[_];if(p!==void 0){const y=a===null?void 0:p.getZIndexContext(),T=y?y.getContext():t,x=this.maxExtent_&&_!=="Image"&&_!=="Text";if(x&&(T.save(),this.clip(T,i)),!y||_==="Text"||_==="Image"?p.execute(T,e,i,n,r,a):y.pushFunction(E=>p.execute(E,e,i,n,r,a)),x&&T.restore(),y){y.offset();const E=l[c]*h+fi.indexOf(_);this.deferredZIndexContexts_[E]||(this.deferredZIndexContexts_[E]=[]),this.deferredZIndexContexts_[E].push(y)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(Ee);for(let i=0,n=e.length;i<n;++i)t[e[i]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const ro={};function m_(s){if(ro[s]!==void 0)return ro[s];const t=s*2+1,e=s*s,i=new Array(e+1);for(let r=0;r<=s;++r)for(let o=0;o<=s;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((s+r)*t+(s+o))*4+3),r>0&&l.push(((s-r)*t+(s+o))*4+3),o>0&&(l.push(((s+r)*t+(s-o))*4+3),r>0&&l.push(((s-r)*t+(s-o))*4+3))}const n=[];for(let r=0,o=i.length;r<o;++r)i[r]&&n.push(...i[r]);return ro[s]=n,n}class p_ extends yc{constructor(t,e,i,n,r,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=n,this.transformRotation_=n?Hn(Math.atan2(n[1],n[0]),10):0,this.viewRotation_=r,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_=_t()}drawImages_(t,e,i,n){if(!this.image_)return;const r=Te(t,e,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=r.length;c<u;c+=2){const d=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,m=f+this.imageAnchorY_;ne(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_(t,e,i,n){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Te(t,e,i,n,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=n){const l=r[e]+this.textOffsetX_,h=r[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,n,r){const o=this.context_,a=Te(t,e,i,n,this.transform_,this.pixelCoordinates_);o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let h=2;h<l;h+=2)o.lineTo(a[h],a[h+1]);return r&&o.closePath(),i}drawRings_(t,e,i,n){for(let r=0,o=i.length;r<o;++r)e=this.moveToLineTo_(t,e,i[r],n,!0);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ft(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=Sd(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],n=e[3]-e[1],r=Math.sqrt(i*i+n*n),o=this.context_;o.beginPath(),o.arc(e[0],e[1],r,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}}drawFeature(t,e){const i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let i=0,n=e.length;i<n;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const 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_));const 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_)),!!ft(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1),e.stroke()}if(this.text_!==""){const e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getExtent();if(ft(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const i=this.context_,n=t.getFlatCoordinates();let r=0;const o=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)r=this.moveToLineTo_(n,r,o[l],a,!1);i.stroke()}if(this.text_!==""){const i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ft(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride()),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!ft(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getOrientedFlatCoordinates();let n=0;const r=t.getEndss(),o=t.getStride();e.beginPath();for(let a=0,l=r.length;a<l;++a){const h=r[a];n=this.drawRings_(i,n,h,o)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){const 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){const e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),ze(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){const e=this.context_,i=this.contextTextState_,n=t.textAlign?t.textAlign:$n;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=n&&(i.textAlign=n,e.textAlign=n),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=n,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:n,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{const i=t.getColor();this.fillState_={fillStyle:xe(i||Ot)}}if(!e)this.strokeState_=null;else{const i=e.getColor(),n=e.getLineCap(),r=e.getLineDash(),o=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),h=e.getMiterLimit(),c=r||Ge;this.strokeState_={lineCap:n!==void 0?n:an,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||Be)*this.pixelRatio_,lineJoin:a!==void 0?a:ln,lineWidth:(l!==void 0?l:Wn)*this.pixelRatio_,miterLimit:h!==void 0?h:zn,strokeStyle:xe(i||Un)}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),n=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=n[0]*i,this.imageAnchorY_=n[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const 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{const e=t.getFill();if(!e)this.textFillState_=null;else{const f=e.getColor();this.textFillState_={fillStyle:xe(f||Ot)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),m=i.getLineDash(),_=i.getLineDashOffset(),p=i.getLineJoin(),y=i.getWidth(),T=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:an,lineDash:m||Ge,lineDashOffset:_||Be,lineJoin:p!==void 0?p:ln,lineWidth:y!==void 0?y:Wn,miterLimit:T!==void 0?T:zn,strokeStyle:xe(f||Un)}}const n=t.getFont(),r=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:n!==void 0?n:nc,textAlign:u!==void 0?u:$n,textBaseline:d!==void 0?d:Hs},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,m)=>f+=m%2?" ":g,""):c:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r: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]]}}}const $t=.5;function Tc(s,t,e,i,n,r,o,a,l){const h=l?na(n):n,c=s[0]*$t,u=s[1]*$t,d=mt(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new p_(d,$t,n,null,o,a,l?Jn(md(),l):null),m=e.length,_=Math.floor((256*256*256-1)/m),p={};for(let T=1;T<=m;++T){const x=e[T-1],E=x.getStyleFunction()||i;if(!E)continue;let v=E(x,r);if(!v)continue;Array.isArray(v)||(v=[v]);const S=(T*_).toString(16).padStart(7,"#00000");for(let w=0,I=v.length;w<I;++w){const b=v[w],L=b.getGeometryFunction()(x);if(!L||!ft(h,L.getExtent()))continue;const M=b.clone(),F=M.getFill();F&&F.setColor(S);const W=M.getStroke();W&&(W.setColor(S),W.setLineDash(null)),M.setText(void 0);const A=b.getImage();if(A){const K=A.getImageSize();if(!K)continue;const nt=mt(K[0],K[1],void 0,{alpha:!1}),P=nt.canvas;nt.fillStyle=S,nt.fillRect(0,0,P.width,P.height),M.setImage(new Rr({img:P,anchor:A.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:A.getOrigin(),opacity:1,size:A.getSize(),scale:A.getScale(),rotation:A.getRotation(),rotateWithView:A.getRotateWithView()}))}const $=M.getZIndex()||0;let D=p[$];D||(D={},p[$]=D,D.Polygon=[],D.Circle=[],D.LineString=[],D.Point=[]);const j=L.getType();if(j==="GeometryCollection"){const K=L.getGeometriesArrayRecursive();for(let nt=0,P=K.length;nt<P;++nt){const St=K[nt];D[St.getType().replace("Multi","")].push(St,M)}}else D[j.replace("Multi","")].push(L,M)}}const y=Object.keys(p).map(Number).sort(Ee);for(let T=0,x=y.length;T<x;++T){const E=p[y[T]];for(const v in E){const R=E[v];for(let S=0,w=R.length;S<w;S+=2){g.setStyle(R[S+1]);for(let I=0,b=t.length;I<b;++I)g.setTransform(t[I]),g.drawGeometry(R[S])}}}return d.getImageData(0,0,f.width,f.height)}function Cc(s,t,e){const i=[];if(e){const n=Math.floor(Math.round(s[0])*$t),r=Math.floor(Math.round(s[1])*$t),o=(ot(n,0,e.width-1)+ot(r,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}const y_=.5,vc={Point:w_,LineString:v_,Polygon:I_,MultiPoint:P_,MultiLineString:R_,MultiPolygon:S_,GeometryCollection:C_,Circle:E_};function x_(s,t){return parseInt(k(s),10)-parseInt(k(t),10)}function zo(s,t){const e=Rc(s,t);return e*e}function Rc(s,t){return y_*s/t}function E_(s,t,e,i,n){const r=e.getFill(),o=e.getStroke();if(r||o){const l=s.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(t,i,n)}const a=e.getText();if(a&&a.getText()){const l=s.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i)}}function ir(s,t,e,i,n,r,o,a){const l=[],h=e.getImage();if(h){let d=!0;const f=h.getImageState();f==Y.LOADED||f==Y.ERROR?d=!1:f==Y.IDLE&&h.load(),d&&l.push(h.ready())}const c=e.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>n(null)),T_(s,t,e,i,r,o,a),u}function T_(s,t,e,i,n,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,n);if(e.getRenderer())Sc(s,l,e,t,o);else{const c=vc[l.getType()];c(s,l,e,t,o,r)}}function Sc(s,t,e,i,n){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)Sc(s,o[a],e,i,n);return}s.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),n)}function C_(s,t,e,i,n,r){const o=t.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=vc[o[a].getType()];h(s,o[a],e,i,n,r)}}function v_(s,t,e,i,n){const r=e.getStroke();if(r){const a=s.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(t,i,n)}const o=e.getText();if(o&&o.getText()){const a=s.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,n)}}function R_(s,t,e,i,n){const r=e.getStroke();if(r){const a=s.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(t,i,n)}const o=e.getText();if(o&&o.getText()){const a=s.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,n)}}function S_(s,t,e,i,n){const r=e.getFill(),o=e.getStroke();if(o||r){const l=s.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(t,i,n)}const a=e.getText();if(a&&a.getText()){const l=s.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,n)}}function w_(s,t,e,i,n,r){const o=e.getImage(),a=e.getText(),l=a&&a.getText(),h=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=Y.LOADED)return;const c=s.getBuilder(e.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(t,i,n)}if(l){const c=s.getBuilder(e.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(t,i,n)}}function P_(s,t,e,i,n,r){const o=e.getImage(),a=o&&o.getOpacity()!==0,l=e.getText(),h=l&&l.getText(),c=r&&a&&h?{}:void 0;if(a){if(o.getImageState()!=Y.LOADED)return;const u=s.getBuilder(e.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(t,i,n)}if(h){const u=s.getBuilder(e.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(t,i,n)}}function I_(s,t,e,i,n){const r=e.getFill(),o=e.getStroke();if(r||o){const l=s.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(t,i,n)}const a=e.getText();if(a&&a.getText()){const l=s.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,n)}}class A_ extends Da{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Vt(),this.wrappedRenderedExtent_=Vt(),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){const n=e.extent,r=e.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,m=!(g[rt.ANIMATING]||g[rt.INTERACTING]),_=this.context,p=Math.round(it(n)/a*f),y=Math.round(Lt(n)/a*f),T=u.getWrapX()&&l.canWrapX(),x=T?it(c):null,E=T?Math.ceil((n[2]-c[2])/x)+1:1;let v=T?Math.floor((n[0]-c[0])/x):0;do{let R=this.getRenderTransform(o,a,0,f,p,y,v*x);e.declutter&&(R=R.slice(0)),t.execute(_,[_.canvas.width,_.canvas.height],R,h,m,i===void 0?fi:i?er:__,i?d&&e.declutter[d]:void 0)}while(++v<E)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=mt(this.context.canvas.width,this.context.canvas.height,Yl))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,Er(this.context),Yl.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.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(t,e){const i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;const n=t.viewState;this.prepareContainer(t,e);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Ct.PRERENDER)||this.getLayer().hasListener(Ct.POSTRENDER)))return this.container;if(this.setDrawContext_(),this.preRender(r,t),n.projection,this.clipped_=!1,a&&i.extent&&this.clipping){const l=ye(i.extent);a=ft(l,t.extent),this.clipped_=a&&!Ze(l,t.extent),this.clipped_&&this.clipUnrotated(r,t,l)}return a&&this.renderWorlds(o,t,this.getLayer().getDeclutter()?!1:void 0),!t.declutter&&this.clipped_&&r.restore(),this.postRender(r,t),this.renderedRotation_!==n.rotation&&(this.renderedRotation_=n.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),n=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*$t,d=i[1]*$t;c.push(this.getRenderTransform(n,r,o,$t,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!Ze(g,l)){let m=l[0];const _=it(g);let p=0,y;for(;m<g[0];)--p,y=_*p,c.push(this.getRenderTransform(n,r,o,$t,u,d,y).slice()),m+=_;for(p=0,m=l[2];m>g[2];)++p,y=_*p,c.push(this.getRenderTransform(n,r,o,$t,u,d,y).slice()),m-=_}this.hitDetectionImageData_=Tc(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,zo(r,this.renderedPixelRatio_),null)}e(Cc(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,n,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){const m=k(d),_=h[m];if(_){if(_!==!0&&g<_.distanceSq){if(g===0)return h[m]=!0,r.splice(r.lastIndexOf(_),1),n(d,l,f);_.geometry=f,_.distanceSq=g}}else{if(g===0)return h[m]=!0,n(d,l,f);r.push(h[m]={feature:d,layer:l,geometry:f,distanceSq:g,callback:n})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,u?e.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const n=t.viewHints[rt.ANIMATING],r=t.viewHints[rt.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&n||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,h=t.viewState,c=h.projection,u=h.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let m=e.getRenderOrder();m===void 0&&(m=x_);const _=h.center.slice(),p=sn(l,g*u),y=p.slice(),T=[p.slice()],x=c.getExtent();if(i.getWrapX()&&c.canWrapX()&&!Ze(x,t.extent)){const F=it(x),W=Math.max(it(p)/2,F);p[0]=x[0]-W,p[2]=x[2]+W,qo(_,c);const A=yh(T[0],c);A[0]<x[0]&&A[2]<x[2]?T.push([A[0]+F,A[1],A[2]+F,A[3]]):A[0]>x[0]&&A[2]>x[2]&&T.push([A[0]-F,A[1],A[2]-F,A[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!t.declutter&&Ze(this.wrappedRenderedExtent_,p))return ze(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const E=new xc(Rc(u,d),p,u,d);let v;for(let F=0,W=T.length;F<W;++F)i.loadFeatures(T[F],u,c);const R=zo(u,d);let S=!0;const w=(F,W)=>{let A;const $=F.getStyleFunction()||e.getStyleFunction();if($&&(A=$(F,u)),A){const D=this.renderFeature(F,R,A,E,v,this.getLayer().getDeclutter(),W);S=S&&!D}},I=na(p),b=i.getFeaturesInExtent(I);m&&b.sort(m);for(let F=0,W=b.length;F<W;++F)w(b[F],F);this.renderedFeatures_=b,this.ready=S;const L=E.finish(),M=new Ec(p,u,d,i.getOverlaps(),L,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=y,this.wrappedRenderedExtent_=p,this.renderedCenter_=_,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=M,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,n,r,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=ir(n,t,i[h],e,this.boundHandleStyleImageChange_,r,o,a)||l;else l=ir(n,t,i,e,this.boundHandleStyleImageChange_,r,o,a);return l}}class wc extends ss{constructor(t){super(t)}createRenderer(){return new A_(this)}}let L_=!1;function b_(s,t,e,i,n,r,o){const a=new XMLHttpRequest;a.open("GET",typeof s=="function"?s(e,i,n):s,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=L_,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const 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?r(t.readFeatures(c,{extent:e,featureProjection:n}),t.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function Jl(s,t){return function(e,i,n,r,o){b_(s,t,e,i,n,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function F_(s,t){return[[-1/0,-1/0,1/0,1/0]]}class Wt extends re{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"){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new Wt(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());const e=this.getGeometry();e&&t.setGeometry(e.clone());const 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_&&(st(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=Z(t,X.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?M_(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 M_(s){if(typeof s=="function")return s;let t;return Array.isArray(s)?t=s:(H(typeof s.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[s]),function(){return t}}function Pc(s,t,e,i){const n=[];let r=Vt();for(let o=0,a=e.length;o<a;++o){const l=e[o];r=Zo(s,t,l[0],i),n.push((r[0]+r[2])/2,(r[1]+r[3])/2),t=l[l.length-1]}return n}function nr(s,t,e,i,n,r,o){let a,l;const h=(e-t)/i;if(h===1)a=t;else if(h===2)a=t,l=n;else if(h!==0){let c=s[t],u=s[t+1],d=0;const f=[0];for(let _=t+i;_<e;_+=i){const p=s[_],y=s[_+1];d+=Math.sqrt((p-c)*(p-c)+(y-u)*(y-u)),f.push(d),c=p,u=y}const g=n*d,m=lu(f,g);m<0?(l=(g-f[-m-2])/(f[-m-1]-f[-m-2]),a=t+(-m-2)*i):a=t+m*i}o=o>1?o:2,r=r||new Array(o);for(let c=0;c<o;++c)r[c]=a===void 0?NaN:l===void 0?s[a+c]:Ut(s[a+c],s[a+i+c],l);return r}function Uo(s,t,e,i,n,r){if(e==t)return null;let o;if(n<s[t+i-1])return r?(o=s.slice(t,t+i),o[i-1]=n,o):null;if(s[e-1]<n)return r?(o=s.slice(e-i,e),o[i-1]=n,o):null;if(n==s[t+i-1])return s.slice(t,t+i);let a=t/i,l=e/i;for(;a<l;){const d=a+l>>1;n<s[(d+1)*i-1]?l=d:a=d+1}const h=s[a*i-1];if(n==h)return s.slice((a-1)*i,(a-1)*i+i);const c=s[(a+1)*i-1],u=(n-h)/(c-h);o=[];for(let d=0;d<i-1;++d)o.push(Ut(s[(a-1)*i+d],s[a*i+d],u));return o.push(n),o}function O_(s,t,e,i,n,r,o){if(o)return Uo(s,t,e[e.length-1],i,n,r);let a;if(n<s[i-1])return r?(a=s.slice(0,i),a[i-1]=n,a):null;if(s[s.length-1]<n)return r?(a=s.slice(s.length-i),a[i-1]=n,a):null;for(let l=0,h=e.length;l<h;++l){const c=e[l];if(t!=c){if(n<s[t+i-1])return null;if(n<=s[c-1])return Uo(s,t,c,i,n,!1);t=c}}return null}class Pr extends oi{constructor(t,e,i){super(),i!==void 0&&e===void 0?this.setFlatCoordinates(i,t):(e=e||0,this.setCenterAndRadius(t,e,i))}clone(){const t=new Pr(this.flatCoordinates.slice(),void 0,this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){const r=this.flatCoordinates,o=t-r[0],a=e-r[1],l=o*o+a*a;if(l<n){if(l===0)for(let h=0;h<this.stride;++h)i[h]=r[h];else{const h=this.getRadius()/Math.sqrt(l);i[0]=r[0]+h*o,i[1]=r[1]+h*a;for(let c=2;c<this.stride;++c)i[c]=r[c]}return i.length=this.stride,l}return n}containsXY(t,e){const i=this.flatCoordinates,n=t-i[0],r=e-i[1];return n*n+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(t){const e=this.flatCoordinates,i=e[this.stride]-e[0];return ve(e[0]-i,e[1]-i,e[0]+i,e[1]+i,t)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){const t=this.flatCoordinates[this.stride]-this.flatCoordinates[0],e=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return t*t+e*e}getType(){return"Circle"}intersectsExtent(t){const e=this.getExtent();if(ft(t,e)){const i=this.getCenter();return t[0]<=i[0]&&t[2]>=i[0]||t[1]<=i[1]&&t[3]>=i[1]?!0:Ko(t,this.intersectsCoordinate.bind(this))}return!1}setCenter(t){const e=this.stride,i=this.flatCoordinates[e]-this.flatCoordinates[0],n=t.slice();n[e]=n[0]+i;for(let r=1;r<e;++r)n[e+r]=t[r];this.setFlatCoordinates(this.layout,n),this.changed()}setCenterAndRadius(t,e,i){this.setLayout(i,t,0),this.flatCoordinates||(this.flatCoordinates=[]);const n=this.flatCoordinates;let r=kh(n,0,t,this.stride);n[r++]=n[0]+e;for(let o=1,a=this.stride;o<a;++o)n[r++]=n[o];n.length=r,this.changed()}getCoordinates(){return null}setCoordinates(t,e){}setRadius(t){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+t,this.changed()}rotate(t,e){const i=this.getCenter(),n=this.getStride();this.setCenter(ra(i,0,i.length,n,t,e,i)),this.changed()}}Pr.prototype.transform;class si extends Mh{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(st),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,i=t.length;e<i;++e)this.changeEventsKeys_.push(Z(t[e],X.CHANGE,this.changed,this))}clone(){const t=new si(oo(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<Ii(this.getExtent(),t,e))return n;const r=this.geometries_;for(let o=0,a=r.length;o<a;++o)n=r[o].closestPointXY(t,e,i,n);return n}containsXY(t,e){const i=this.geometries_;for(let n=0,r=i.length;n<r;++n)if(i[n].containsXY(t,e))return!0;return!1}computeExtent(t){cn(t);const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)_h(t,e[i].getExtent());return t}getGeometries(){return oo(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[];const e=this.geometries_;for(let i=0,n=e.length;i<n;++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;const e=[],i=this.geometries_;let n=!1;for(let r=0,o=i.length;r<o;++r){const a=i[r],l=a.getSimplifiedGeometry(t);e.push(l),l!==a&&(n=!0)}return n?new si(e):(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getType(){return"GeometryCollection"}intersectsExtent(t){const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)if(e[i].intersectsExtent(t))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(t,e){const i=this.geometries_;for(let n=0,r=i.length;n<r;++n)i[n].rotate(t,e);this.changed()}scale(t,e,i){i||(i=ii(this.getExtent()));const n=this.geometries_;for(let r=0,o=n.length;r<o;++r)n[r].scale(t,e,i);this.changed()}setGeometries(t){this.setGeometriesArray(oo(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)e[i].applyTransform(t);this.changed()}translate(t,e){const i=this.geometries_;for(let n=0,r=i.length;n<r;++n)i[n].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function oo(s){return s.map(t=>t.clone())}class ce extends oi{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){Yt(this.flatCoordinates,t),this.changed()}clone(){const t=new ce(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<Ii(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(oa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),la(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,n))}forEachSegment(t){return zh(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,Uo(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return Ke(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return nr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return ka(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){const e=[];return e.length=yr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new ce(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return xr(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=pr(this.flatCoordinates,0,t,this.stride),this.changed()}}class Si extends oi{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{const n=t,r=[],o=[];for(let l=0,h=n.length;l<h;++l){const c=n[l];Yt(r,c.getFlatCoordinates()),o.push(r.length)}const a=n.length===0?this.getLayout():n[0].getLayout();this.setFlatCoordinates(a,r),this.ends_=o}}appendLineString(t){Yt(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Si(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<Ii(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(aa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ha(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,i,n))}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,O_(this.flatCoordinates,0,this.ends_,this.stride,t,e,i))}getCoordinates(){return Gn(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new ce(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){const t=this.flatCoordinates,e=this.ends_,i=this.layout,n=[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o],h=new ce(t.slice(r,l),i);n.push(h),r=l}return n}getLength(){const t=this.ends_;let e=0,i=0;for(let n=0,r=t.length;n<r;++n)i+=ka(this.flatCoordinates,e,t[n],this.stride),e=t[n];return i}getFlatMidpoints(){const t=[],e=this.flatCoordinates;let i=0;const n=this.ends_,r=this.stride;for(let o=0,a=n.length;o<a;++o){const l=n[o],h=nr(e,i,l,r,.5);Yt(t,h),i=l}return t}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Gh(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,i),new Si(e,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(t){return Md(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Qn(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}class mn extends oi{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){Yt(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){const t=new mn(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<Ii(this.getExtent(),t,e))return n;const r=this.flatCoordinates,o=this.stride;for(let a=0,l=r.length;a<l;a+=o){const h=ke(t,e,r[a],r[a+1]);if(h<n){n=h;for(let c=0;c<o;++c)i[c]=r[a+c];i.length=o}}return n}getCoordinates(){return Ke(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new Ce(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){const t=this.flatCoordinates,e=this.layout,i=this.stride,n=[];for(let r=0,o=t.length;r<o;r+=i){const a=new Ce(t.slice(r,r+i),e);n.push(a)}return n}getType(){return"MultiPoint"}intersectsExtent(t){const e=this.flatCoordinates,i=this.stride;for(let n=0,r=e.length;n<r;n+=i){const o=e[n],a=e[n+1];if(Vo(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=pr(this.flatCoordinates,0,t,this.stride),this.changed()}}class wi extends oi{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])){const n=t,r=[],o=[];for(let a=0,l=n.length;a<l;++a){const h=n[a],c=r.length,u=h.getEnds();for(let d=0,f=u.length;d<f;++d)u[d]+=c;Yt(r,h.getFlatCoordinates()),o.push(u)}e=n.length===0?this.getLayout():n[0].getLayout(),t=r,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{const i=this.flatCoordinates.length;Yt(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let n=0,r=e.length;n<r;++n)e[n]+=i}this.endss_.push(e),this.changed()}clone(){const t=this.endss_.length,e=new Array(t);for(let n=0;n<t;++n)e[n]=this.endss_[n].slice();const i=new wi(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,n){return n<Ii(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Pd(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Id(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return Fd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return wd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Lo(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,Ao(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=Pc(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Bh(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new mn(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Wh(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Lo(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Ld(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new wi(e,"XY",i)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(t===0)e=0;else{const r=this.endss_[t-1];e=r[r.length-1]}const i=this.endss_[t].slice(),n=i[i.length-1];if(e!==0)for(let r=0,o=i.length;r<o;++r)i[r]-=e;return new Zt(this.flatCoordinates.slice(e,n),this.layout,i)}getPolygons(){const t=this.layout,e=this.flatCoordinates,i=this.endss_,n=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o].slice(),h=l[l.length-1];if(r!==0)for(let u=0,d=l.length;u<d;++u)l[u]-=r;const c=new Zt(e.slice(r,h),t,l);n.push(c),r=h}return n}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=[]);const i=Nh(this.flatCoordinates,0,t,this.stride,this.endss_);if(i.length===0)this.flatCoordinates.length=0;else{const n=i[i.length-1];this.flatCoordinates.length=n.length===0?0:n[n.length-1]}this.changed()}}const Ql=_t();class Dt{constructor(t,e,i,n,r,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_=r,this.squaredTolerance_,this.stride_=n,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?gh(this.flatCoordinates_):Zo(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=ii(this.getExtent());this.flatInteriorPoints_=da(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=Xh(this.flatCoordinates_,this.ends_),e=Pc(this.flatCoordinates_,0,t,2);this.flatInteriorPoints_=Bh(this.flatCoordinates_,0,t,2,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=nr(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const i=this.ends_;for(let n=0,r=i.length;n<r;++n){const o=i[n],a=nr(t,e,o,2,.5);Yt(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=lt(t);const e=t.getExtent(),i=t.getWorldExtent();if(e&&i){const n=Lt(i)/Lt(e);ne(Ql,i[0],i[3],n,-n,0,0,0),Te(this.flatCoordinates_,0,this.flatCoordinates_.length,2,Ql,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new Dt(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=hh((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let n;switch(this.type_){case"LineString":i.length=yr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=Gh(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,n);break;case"Polygon":n=[],i.length=ca(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,n);break}return n&&(this.simplifiedGeometry_=new Dt(this.type_,i,n,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Dt.prototype.getFlatCoordinates=Dt.prototype.getOrientedFlatCoordinates;class th{constructor(t){this.rbush_=new Jh(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[k(e)]=i}load(t,e){const i=new Array(e.length);for(let n=0,r=e.length;n<r;n++){const o=t[n],a=e[n],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[n]=l,this.items_[k(a)]=l}this.rbush_.load(i)}remove(t){const e=k(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){const i=this.items_[k(e)],n=[i.minX,i.minY,i.maxX,i.maxY];vi(n,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(n){return n.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 n=0,r=t.length;n<r;n++)if(i=e(t[n]),i)return i;return i}isEmpty(){return Ei(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return ve(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(const e in t.items_)this.items_[e]=t.items_[e]}}class Ic extends re{constructor(t){super(),this.projection=lt(t.projection),this.attributions_=eh(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;const e=this;this.viewPromise_=new Promise(function(i,n){e.viewResolver=i,e.viewRejector=n})}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_=eh(t),this.changed()}setState(t){this.state_=t,this.changed()}}function eh(s){return s?typeof s=="function"?s:(Array.isArray(s)||(s=[s]),t=>s):null}const At={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class je extends se{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class D_ extends Ic{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_=Dn,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&&(H(this.format_,"`format` must be set when `url` is set"),this.loader_=Jl(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:F_;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new th:null,this.loadedExtentsRtree_=new th,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,n;Array.isArray(t.features)?n=t.features:t.features&&(i=t.features,n=i.getArray()),!e&&i===void 0&&(i=new Xt(n)),n!==void 0&&this.addFeaturesInternal(n),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=k(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const n=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(n,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new je(At.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Dt||(this.featureChangeKeys_[t]=[Z(e,X.CHANGE,this.handleFeatureChange_,this),Z(e,nn.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const n=String(e.getId());if(!(n in this.idIndex_))this.idIndex_[n]=e;else if(e instanceof Dt){const r=this.idIndex_[n];r instanceof Dt?Array.isArray(r)?r.push(e):this.idIndex_[n]=[r,e]:i=!1}else i=!1}return i&&(H(!(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){const e=[],i=[],n=[];for(let r=0,o=t.length;r<o;r++){const a=t[r],l=k(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=k(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();e.push(c),n.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,n),this.hasListener(At.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new je(At.ADDFEATURE,i[r]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(At.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(At.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(Tt.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(Tt.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(st);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(const i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new je(At.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){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(n){const r=n.getGeometry();if(r instanceof Dt||r.intersectsCoordinate(t))return e(n)})}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){const n=i.getGeometry();if(n instanceof Dt||n.intersectsExtent(t)){const r=e(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),Ei(this.nullGeometryFeatures_)||Yt(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const 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);const n=xh(t,e);return[].concat(...n.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],n=t[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return e=e||ei,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){const c=h.getGeometry(),u=a;if(a=c instanceof Dt?0:c.closestPointXY(i,n,o,a),a<u){r=h;const d=Math.sqrt(a);l[0]=i-d,l[1]=n-d,l[2]=i+d,l[3]=n+d}}}),r}getExtent(t){return this.featuresRtree_.getExtent(t)}getFeatureById(t){const e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,i=k(e),n=e.getGeometry();if(!n)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{const o=n.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}const r=e.getId();if(r!==void 0){const o=r.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 je(At.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return e!==void 0?e in this.idIndex_:k(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Ei(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){const n=this.loadedExtentsRtree_,r=this.strategy_(t,e,i);for(let o=0,a=r.length;o<a;++o){const l=r[o];n.forEachInExtent(l,function(c){return Ze(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new je(At.FEATURESLOADSTART)),this.loader_.call(this,l,e,i,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new je(At.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new je(At.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(t){const e=this.loadedExtentsRtree_,i=e.forEachInExtent(t,function(n){if(vi(n.extent,t))return n});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,n=t.length;i<n;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=k(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(st),delete this.featureChangeKeys_[e];const n=t.getId();if(n!==void 0){const r=n.toString(),o=this.idIndex_[r];o===t?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[e],this.hasListener(At.REMOVEFEATURE)&&this.dispatchEvent(new je(At.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(const e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){H(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(Jl(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}}const Ui=[0,0,0],Ye=5;class Ac{constructor(t){this.minZoom=t.minZoom!==void 0?t.minZoom:0,this.resolutions_=t.resolutions,H(uu(this.resolutions_,(n,r)=>r-n),"`resolutions` must be sorted in descending order");let e;if(!t.origins){for(let n=0,r=this.resolutions_.length-1;n<r;++n)if(!e)e=this.resolutions_[n]/this.resolutions_[n+1];else if(this.resolutions_[n]/this.resolutions_[n+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,H(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const i=t.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=ri(i)),H(!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,H(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:ya,H(!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((n,r)=>{const o=new Ma(Math.min(0,n[0]),Math.max(n[0]-1,-1),Math.min(0,n[1]),Math.max(n[1]-1,-1));if(i){const a=this.getTileRangeForExtentAndZ(i,r);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){const n=this.getTileRangeForExtentAndZ(t,e);for(let r=n.minX,o=n.maxX;r<=o;++r)for(let a=n.minY,l=n.maxY;a<=l;++a)i([e,r,a])}forEachTileCoordParentTileRange(t,e,i,n){let r,o,a,l=null,h=t[0]-1;for(this.zoomFactor_===2?(o=t[1],a=t[2]):l=this.getTileCoordExtent(t,n);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=Bi(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,h,i),e(h,r))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]}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]<this.maxZoom){if(this.zoomFactor_===2){const r=t[1]*2,o=t[2]*2;return Bi(r,r+1,o,o+1,e)}const n=this.getTileCoordExtent(t,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(n,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,i){if(e>this.maxZoom||e<this.minZoom)return null;const n=t[0],r=t[1],o=t[2];if(e===n)return Bi(r,o,r,o,i);if(this.zoomFactor_){const l=Math.pow(this.zoomFactor_,e-n),h=Math.floor(r*l),c=Math.floor(o*l);if(e<n)return Bi(h,h,c,c,i);const u=Math.floor(l*(r+1))-1,d=Math.floor(l*(o+1))-1;return Bi(h,u,c,d,i)}const a=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,e,i)}getTileRangeForExtentAndZ(t,e,i){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,Ui);const n=Ui[1],r=Ui[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,Ui);const o=Ui[1],a=Ui[2];return Bi(n,o,r,a,i)}getTileCoordCenter(t){const e=this.getOrigin(t[0]),i=this.getResolution(t[0]),n=bt(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*n[0]*i,e[1]-(t[2]+.5)*n[1]*i]}getTileCoordExtent(t,e){const i=this.getOrigin(t[0]),n=this.getResolution(t[0]),r=bt(this.getTileSize(t[0]),this.tmpSize_),o=i[0]+t[1]*r[0]*n,a=i[1]-(t[2]+1)*r[1]*n,l=o+r[0]*n,h=a+r[1]*n;return ve(o,a,l,h,e)}getTileCoordForCoordAndResolution(t,e,i){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,i)}getTileCoordForXYAndResolution_(t,e,i,n,r){const o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),h=bt(this.getTileSize(o),this.tmpSize_);let c=a*(t-l[0])/i/h[0],u=a*(l[1]-e)/i/h[1];return n?(c=us(c,Ye)-1,u=us(u,Ye)-1):(c=cs(c,Ye),u=cs(u,Ye)),Qs(o,c,u,r)}getTileCoordForXYAndZ_(t,e,i,n,r){const o=this.getOrigin(i),a=this.getResolution(i),l=bt(this.getTileSize(i),this.tmpSize_);let h=(t-o[0])/a/l[0],c=(o[1]-e)/a/l[1];return n?(h=us(h,Ye)-1,c=us(c,Ye)-1):(h=cs(h,Ye),c=cs(c,Ye)),Qs(i,h,c,r)}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){const i=Yo(this.resolutions_,t,e||0);return ot(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return Uh(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){const e=this.resolutions_.length,i=new Array(e);for(let n=this.minZoom;n<e;++n)i[n]=this.getTileRangeForExtentAndZ(t,n);this.fullTileRanges_=i}}function Lc(s){let t=s.getDefaultTileGrid();return t||(t=B_(s),s.setDefaultTileGrid(t)),t}function k_(s,t,e){const i=t[0],n=s.getTileCoordCenter(t),r=Na(e);if(!Ci(r,n)){const o=it(r),a=Math.ceil((r[0]-n[0])/o);return n[0]+=o*a,s.getTileCoordForCoordAndZ(n,i)}return t}function N_(s,t,e,i){i=i!==void 0?i:"top-left";const n=bc(s,t,e);return new Ac({extent:s,origin:Iu(s,i),resolutions:n,tileSize:e})}function G_(s){const t=s||{},e=t.extent||lt("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:bc(e,t.maxZoom,t.tileSize,t.maxResolution)};return new Ac(i)}function bc(s,t,e,i){t=t!==void 0?t:$d,e=bt(e!==void 0?e:ya);const n=Lt(s),r=it(s);i=i>0?i:Math.max(r/e[0],n/e[1]);const o=t+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function B_(s,t,e,i){const n=Na(s);return N_(n,t,e,i)}function Na(s){s=lt(s);let t=s.getExtent();if(!t){const e=180*rn.degrees/s.getMetersPerUnit();t=ve(-e,-e,e,e)}return t}const z_=/\{z\}/g,U_=/\{x\}/g,$_=/\{y\}/g,W_=/\{-y\}/g;function X_(s,t,e,i,n){return s.replace(z_,t.toString()).replace(U_,e.toString()).replace($_,i.toString()).replace(W_,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 j_(s){const t=[];let e=/\{([a-z])-([a-z])\}/.exec(s);if(e){const i=e[1].charCodeAt(0),n=e[2].charCodeAt(0);let r;for(r=i;r<=n;++r)t.push(s.replace(e[0],String.fromCharCode(r)));return t}if(e=/\{(\d+)-(\d+)\}/.exec(s),e){const i=parseInt(e[2],10);for(let n=parseInt(e[1],10);n<=i;n++)t.push(s.replace(e[0],n.toString()));return t}return t.push(s),t}function Y_(s,t){return(function(e,i,n){if(!e)return;let r;const o=e[0];if(t){const a=t.getFullTileRange(o);a&&(r=a.getHeight()-1)}return X_(s,o,e[1],e[2],r)})}function V_(s,t){const e=s.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=Y_(s[n],t);return Z_(i)}function Z_(s){return s.length===1?s[0]:(function(t,e,i){if(!t)return;const n=Jg(t),r=Qe(n,s.length);return s[r](t,e,i)})}class K_ extends Ic{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;const e=[256,256];this.tileGrid&&bt(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||k(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){const e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,n,r,o){return B()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:Lc(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const n=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),o=bt(n.getTileSize(t),this.tmpSize);return r==1?o:Bf(o,r,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){const i=e!==void 0?e:this.getProjection(),n=e!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(t=k_(n,t,i)),t_(t,n)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class H_ extends se{constructor(t,e){super(t),this.tile=e}}const ao={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class Ga extends K_{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===Ga.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){const e=t.target,i=k(e),n=e.getState();let r;n==N.LOADING?(this.tileLoadingKeys_[i]=!0,r=ao.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==N.ERROR?ao.TILELOADERROR:n==N.LOADED?ao.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new H_(r,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,typeof e<"u"?this.setKey(e):this.changed()}setUrl(t){const e=j_(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join(`
`);this.generateTileUrlFunction_?this.setTileUrlFunction(V_(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}}class q_ extends Ga{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:Fc,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.tileClass=t.tileClass!==void 0?t.tileClass:gc,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!yi(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||yi(e,t)))return this.tileGrid;const i=k(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=Lc(t)),this.tileGridForProjection[i]}createTile_(t,e,i,n,r,o){const a=[t,e,i],l=this.getTileCoordForTileUrlFunction(a,r),h=l?this.tileUrlFunction(l,n,r):void 0,c=new this.tileClass(a,h!==void 0?N.IDLE:N.EMPTY,h!==void 0?h:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(X.CHANGE,this.handleTileChange.bind(this)),c}getTile(t,e,i,n,r,o){const a=this.getProjection();if(!a||!r||yi(a,r))return this.getTileInternal(t,e,i,n,a||r);const l=[t,e,i],h=this.getKey(),c=this.getTileGridForProjection(a),u=this.getTileGridForProjection(r),d=this.getTileCoordForTileUrlFunction(l,r),f=new _c(a,c,r,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(t,e,i,n,r,o){const a=this.getKey(),l=Ds(this,a,t,e,i);if(o&&o.containsKey(l))return o.get(l);const h=this.createTile_(t,e,i,n,r,a);return o?.set(l,h),h}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const i=lt(t);if(i){const n=k(i);n in this.tileGridForProjection||(this.tileGridForProjection[n]=e)}}}function Fc(s,t){if(jt){const e=s.getCrossOrigin();let i="same-origin",n="same-origin";e==="anonymous"||e===""?(i="cors",n="omit"):e==="use-credentials"&&(i="cors",n="include"),fetch(t,{mode:i,credentials:n}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.blob()}).then(r=>createImageBitmap(r)).then(r=>{const o=s.getImage();o.width=r.width,o.height=r.height,o.getContext("2d").drawImage(r,0,0),r.close?.(),o.dispatchEvent(new Event("load"))}).catch(()=>{s.getImage().dispatchEvent(new Event("error"))});return}s.getImage().src=t}class J_ extends q_{constructor(t){t=t||{};const e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:G_({extent:Na(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,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_}}const Q_='&#169; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class jp extends J_{constructor(t){t=t||{};let e;t.attributions!==void 0?e=t.attributions:e=[Q_];const i=t.crossOrigin!==void 0?t.crossOrigin:"anonymous",n=t.url!==void 0?t.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:e,attributionsCollapsible:!1,cacheSize:t.cacheSize,crossOrigin:i,interpolate:t.interpolate,maxZoom:t.maxZoom!==void 0?t.maxZoom:19,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:(r,o)=>{const a=r.getImage();!jt&&a instanceof HTMLImageElement&&(a.referrerPolicy="origin-when-cross-origin"),(t.tileLoadFunction||Fc)(r,o)},transition:t.transition,url:n,wrapX:t.wrapX,zDirection:t.zDirection})}}class Mc{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=Wt,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let i=e.dataProjection?lt(e.dataProjection):this.readProjection(t);e.extent&&i&&i.getUnits()==="tile-pixels"&&(i=lt(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 B()}readFeature(t,e){return B()}readFeatures(t,e){return B()}readGeometry(t,e){return B()}readProjection(t){return B()}writeFeature(t,e){return B()}writeFeatures(t,e){return B()}writeGeometry(t,e){return B()}}function Yn(s,t,e){const i=e?lt(e.featureProjection):null,n=e?lt(e.dataProjection):null;let r=s;if(i&&n&&!yi(i,n)){t&&(r=s.clone());const o=t?i:n,a=t?n:i;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(Ri(o,a))}if(t&&e&&e.decimals!==void 0){const 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};r===s&&(r=s.clone()),r.applyTransform(a)}return r}const tm={Point:Ce,LineString:ce,Polygon:Zt,MultiPoint:mn,MultiLineString:Si,MultiPolygon:wi};function em(s,t,e){return Array.isArray(t[0])?(Wh(s,0,t,e)||(s=s.slice(),Lo(s,0,t,e)),s):(ga(s,0,t,e)||(s=s.slice(),Ys(s,0,t,e)),s)}function Oc(s,t){const e=s.geometry;if(!e)return[];if(Array.isArray(e))return e.map(r=>Oc({...s,geometry:r})).flat();const i=e.type==="MultiPolygon"?"Polygon":e.type;if(i==="GeometryCollection"||i==="Circle")throw new Error("Unsupported geometry type: "+i);const n=e.layout.length;return Yn(new Dt(i,i==="Polygon"?em(e.flatCoordinates,e.ends,n):e.flatCoordinates,e.ends?.flat(),n,s.properties||{},s.id).enableSimplifyTransformed(),!1,t)}function Ba(s,t){if(!s)return null;if(Array.isArray(s)){const i=s.map(n=>Ba(n,t));return new si(i)}const e=tm[s.type];return Yn(new e(s.flatCoordinates,s.layout||"XY",s.ends),!1,t)}class im extends Mc{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Ts(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Ts(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return B()}readFeaturesFromObject(t,e){return B()}readGeometry(t,e){return this.readGeometryFromObject(Ts(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return B()}readProjection(t){return this.readProjectionFromObject(Ts(t))}readProjectionFromObject(t){return B()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return B()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return B()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return B()}}function Ts(s){if(typeof s=="string"){const t=JSON.parse(s);return t||null}return s!==null?s:null}class Yp extends im{constructor(t){t=t||{},super(),this.dataProjection=lt(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=lt(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};const n=za(i.geometry);if(this.featureClass===Dt)return Oc({geometry:n,id:i.id,properties:i.properties},e);const r=new Wt;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&r.setGeometryName(i.geometry_name),r.setGeometry(Ba(n,e)),"id"in i&&r.setId(i.id),i.properties&&r.setProperties(i.properties,!0),r}readFeaturesFromObject(t,e){const i=t;let n=null;if(i.type==="FeatureCollection"){const r=t;n=[];const o=r.features;for(let a=0,l=o.length;a<l;++a){const h=this.readFeatureFromObject(o[a],e);h&&n.push(h)}}else n=[this.readFeatureFromObject(t,e)];return n.flat()}readGeometryFromObject(t,e){return nm(t,e)}readProjectionFromObject(t){const e=t.crs;let i;if(e)if(e.type=="name")i=lt(e.properties.name);else if(e.type==="EPSG")i=lt("EPSG:"+e.properties.code);else throw new Error("Unknown SRS type");else i=this.dataProjection;return i}writeFeatureObject(t,e){e=this.adaptOptions(e);const i={type:"Feature",geometry:null,properties:null},n=t.getId();if(n!==void 0&&(i.id=n),!t.hasProperties())return i;const r=t.getProperties(),o=t.getGeometry();return o&&(i.geometry=$o(o,e),delete r[t.getGeometryName()]),Ei(r)||(i.properties=r),i}writeFeaturesObject(t,e){e=this.adaptOptions(e);const i=[];for(let n=0,r=t.length;n<r;++n)i.push(this.writeFeatureObject(t[n],e));return{type:"FeatureCollection",features:i}}writeGeometryObject(t,e){return $o(t,this.adaptOptions(e))}}function za(s,t){if(!s)return null;let e;switch(s.type){case"Point":{e=rm(s);break}case"LineString":{e=om(s);break}case"Polygon":{e=cm(s);break}case"MultiPoint":{e=lm(s);break}case"MultiLineString":{e=am(s);break}case"MultiPolygon":{e=hm(s);break}case"GeometryCollection":{e=sm(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return e}function nm(s,t){const e=za(s);return Ba(e,t)}function sm(s,t){return s.geometries.map(function(i){return za(i)})}function rm(s){const t=s.coordinates;return{type:"Point",flatCoordinates:t,layout:Ai(t.length)}}function om(s){const t=s.coordinates,e=t.flat();return{type:"LineString",flatCoordinates:e,ends:[e.length],layout:Ai(t[0]?.length||2)}}function am(s){const t=s.coordinates,e=t[0]?.[0]?.length||2,i=[],n=Qn(i,0,t,e);return{type:"MultiLineString",flatCoordinates:i,ends:n,layout:Ai(e)}}function lm(s){const t=s.coordinates;return{type:"MultiPoint",flatCoordinates:t.flat(),layout:Ai(t[0]?.length||2)}}function hm(s){const t=s.coordinates,e=[],i=t[0]?.[0]?.[0].length||2,n=Nh(e,0,t,i);return{type:"MultiPolygon",flatCoordinates:e,ends:n,layout:Ai(i)}}function cm(s){const t=s.coordinates,e=[],i=t[0]?.[0]?.length,n=Qn(e,0,t,i);return{type:"Polygon",flatCoordinates:e,ends:n,layout:Ai(i)}}function $o(s,t){s=Yn(s,!0,t);const e=s.getType();let i;switch(e){case"Point":{i=mm(s);break}case"LineString":{i=dm(s);break}case"Polygon":{i=pm(s,t);break}case"MultiPoint":{i=gm(s);break}case"MultiLineString":{i=fm(s);break}case"MultiPolygon":{i=_m(s,t);break}case"GeometryCollection":{i=um(s,t);break}case"Circle":{i={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+e)}return i}function um(s,t){return t=Object.assign({},t),delete t.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(i){return $o(i,t)})}}function dm(s,t){return{type:"LineString",coordinates:s.getCoordinates()}}function fm(s,t){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function gm(s,t){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function _m(s,t){let e;return t&&(e=t.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(e)}}function mm(s,t){return{type:"Point",coordinates:s.getCoordinates()}}function pm(s,t){let e;return t&&(e=t.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(e)}}const lo="units",ym=[1,2,5],Pn=25.4/.28;class Vp extends Tr{constructor(t){t=t||{};const e=document.createElement("div");e.style.pointerEvents="none",super({element:e,render:t.render,target:t.target}),this.on,this.once,this.un;const 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+" "+ts,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(lo,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(lo)}handleUnitsChanged_(){this.updateElement_()}setUnits(t){this.set(lo,t)}setDpi(t){this.dpi_=t}updateElement_(){const t=this.viewState_;if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const e=t.center,i=t.projection,n=this.getUnits(),r=n=="degrees"?"degrees":"m";let o=Xs(i,t.resolution,e,r);const a=this.minWidth_*(this.dpi_||Pn)/Pn,l=this.maxWidth_!==void 0?this.maxWidth_*(this.dpi_||Pn)/Pn:void 0;let h=a*o,c="";if(n=="degrees"){const T=rn.degrees;h*=T,h<T/60?(c="″",o*=3600):h<T?(c="",o*=60):c="°"}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="μm",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);const T=Math.pow(10,g);if(d=ym[(u%3+3)%3]*T,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=_,g=p;break}else if(f>=a)break;m=d,_=f,p=g,++u}const 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){const n=this.getScaleForResolution(),r=n<1?Math.round(1/n).toLocaleString()+" : 1":"1 : "+Math.round(n).toLocaleString(),o=this.scaleBarSteps_,a=t/o,l=[this.createMarker("absolute")];for(let c=0;c<o;++c){const 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;">`+r+"</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,n,r){const a=(t===0?0:Math.round(n/this.scaleBarSteps_*t*100)/100)+(t===0?"":" "+r),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(){const t=Xs(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m"),e=this.dpi_||Pn,i=1e3/25.4;return t*i*e}render(t){const e=t.frameState;e?this.viewState_=e.viewState:this.viewState_=null,this.updateElement_()}}const xm={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},ih={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};class Em extends pc{constructor(t,e){super(t,e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=_t(),this.tileClipContexts_=null}enqueueTilesForNextExtent(){return this.getLayer().getRenderMode()!=="vector"}drawTile(t,e,i,n,r,o,a,l){this.updateExecutorGroup_(t,e.pixelRatio,e.viewState.projection),this.tileImageNeedsRender_(t)&&this.renderTileImage_(t,e),super.drawTile(t,e,i,n,r,o,a,l)}getTile(t,e,i,n){const r=this.getOrCreateTile(t,e,i,n);if(!r)return null;const o=n.viewState,a=o.resolution,l=n.viewHints,h=this.getLayer().getSource(),c=h.getTileGridForProjection(o.projection),u=!(l[rt.ANIMATING]||l[rt.INTERACTING]),d=c.getZForResolution(a,h.zDirection)===t;return u&&d?r.wantedResolution=a:r.wantedResolution||(r.wantedResolution=c.getResolution(t)),r}prepareFrame(t){const e=this.getLayer().getRevision();return this.renderedLayerRevision_!==e&&(this.renderedLayerRevision_=e,this.renderedTiles.length=0),super.prepareFrame(t)}updateExecutorGroup_(t,e,i){const n=this.getLayer(),r=n.getRevision(),o=n.getRenderOrder()||null,a=t.wantedResolution,l=t.getReplayState(n);if(!l.dirty&&l.renderedResolution===a&&l.renderedRevision==r&&l.renderedRenderOrder==o)return;const h=n.getSource(),c=!!n.getDeclutter(),u=h.getTileGrid(),f=h.getTileGridForProjection(i).getTileCoordExtent(t.wrappedTileCoord),g=h.getSourceTiles(e,i,t),m=k(n);delete t.hitDetectionImageData[m],t.executorGroups[m]=[],l.dirty=!1;for(let _=0,p=g.length;_<p;++_){const y=g[_];if(y.getState()!=N.LOADED)continue;const T=h.getProjection(),x=y.tileCoord;let E=u.getTileCoordExtent(x);i&&T&&!yi(i,T)&&(E=gd(E,T,i,32));const v=Ne(f,E),R=sn(v,n.getRenderBuffer()*a,this.tempExtent),S=vi(E,v)?null:R,w=new xc(0,v,a,e),I=zo(a,e),b=function(A,$){let D;const j=A.getStyleFunction()||n.getStyleFunction();if(j&&(D=j(A,a)),D){const K=this.renderFeature(A,I,D,w,c,$);l.dirty=l.dirty||K}},L=y.getFeatures();o&&o!==l.renderedRenderOrder&&L.sort(o);for(let A=0,$=L.length;A<$;++A){let D=L[A];i&&y.projection&&!yi(i,y.projection)&&(D=D.clone(),D.getGeometry().applyTransform(Ri(y.projection,i))),(!S||ft(S,D.getGeometry().getExtent()))&&b.call(this,D,A)}const M=w.finish(),F=n.getRenderMode()!=="vector"&&c&&g.length===1?null:v,W=new Ec(F,a,e,h.getOverlaps(),M,n.getRenderBuffer(),!0);t.executorGroups[m].push(W)}l.renderedRevision=r,l.renderedRenderOrder=o,l.renderedResolution=a}forEachFeatureAtCoordinate(t,e,i,n,r){const o=e.viewState.resolution,a=e.viewState.rotation;i=i??0;const l=this.getLayer(),c=l.getSource().getTileGridForProjection(e.viewState.projection),u=zs([t]);sn(u,o*i,u);const d={},f=function(T,x,E){let v=T.getId();v===void 0&&(v=k(T));const R=d[v];if(R){if(R!==!0&&E<R.distanceSq){if(E===0)return d[v]=!0,r.splice(r.lastIndexOf(R),1),n(T,l,x);R.geometry=x,R.distanceSq=E}}else{if(E===0)return d[v]=!0,n(T,l,x);r.push(d[v]={feature:T,layer:l,geometry:x,distanceSq:E,callback:n})}},g=this.renderedTiles,m=k(l),_=l.getDeclutter(),p=_?e.declutter?.[_]?.all().map(T=>T.value):null;let y;t:for(let T=0,x=g.length;T<x;++T){const E=g[T],v=c.getTileCoordExtent(E.wrappedTileCoord);if(!ft(v,u))continue;const R=E.executorGroups[m];for(let S=0,w=R.length;S<w;++S)if(y=R[S].forEachFeatureAtCoordinate(t,o,a,i,f,p),y)break t}return y}getFeatures(t){return this.renderedTiles.length===0?Promise.resolve([]):new Promise((e,i)=>{const n=this.getLayer(),r=n.getSource(),o=this.renderedProjection,a=o.getExtent(),l=this.renderedResolution,h=r.getTileGridForProjection(o),c=ct(this.renderedPixelToCoordinateTransform_,t.slice()),u=h.getTileCoordForCoordAndResolution(c,l).toString(),d=this.renderedTiles.find(T=>T.tileCoord.toString()===u&&T.getState()===N.LOADED);if(!d||d.loadingSourceTiles>0){e([]);return}r.getWrapX()&&o.canWrapX()&&!Ze(a,h.getTileCoordExtent(d.tileCoord))&&qo(c,o);const f=k(n),g=h.getTileCoordExtent(d.wrappedTileCoord),m=ri(g),_=[(c[0]-m[0])/l,(m[1]-c[1])/l],p=d.getSourceTiles().reduce((T,x)=>T.concat(x.getFeatures()),[]);let y=d.hitDetectionImageData[f];if(!y){const T=bt(h.getTileSize(h.getZForResolution(l,r.zDirection))),x=this.renderedRotation_,E=[this.getRenderTransform(h.getTileCoordCenter(d.wrappedTileCoord),l,0,$t,T[0]*$t,T[1]*$t,0)];y=Tc(T,E,p,n.getStyleFunction(),h.getTileCoordExtent(d.wrappedTileCoord),d.getReplayState(n).renderedResolution,x),d.hitDetectionImageData[f]=y}e(Cc(_,p,y))})}getFeaturesInExtent(t){const e=[],i=this.getTileCache();if(i.getCount()===0)return e;const r=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),o=r.getZForResolution(this.renderedResolution),a={};return i.forEach(l=>{if(l.tileCoord[0]!==o||l.getState()!==N.LOADED)return;const h=l.getSourceTiles();for(let c=0,u=h.length;c<u;++c){const d=h[c],f=d.getKey();if(f in a)continue;a[f]=!0;const g=d.tileCoord;if(ft(t,r.getTileCoordExtent(g))){const m=d.getFeatures();if(m)for(let _=0,p=m.length;_<p;++_){const y=m[_],T=y.getGeometry();ft(t,T.getExtent())&&e.push(y)}}}}),e}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.renderedLayerRevision_!==void 0&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}renderDeclutter(t,e){const i=this.context,n=i.globalAlpha;i.globalAlpha=e.opacity;const r=t.viewHints,o=!(r[rt.ANIMATING]||r[rt.INTERACTING]),a=[this.context.canvas.width,this.context.canvas.height],l=this.getLayer().getDeclutter(),h=l?t.declutter?.[l]:void 0,c=k(this.getLayer()),u=this.renderedTiles;for(let d=0,f=u.length;d<f;++d){const g=u[d],m=g.executorGroups[c];if(m)for(let _=m.length-1;_>=0;--_)m[_].execute(this.context,a,this.getTileRenderTransform(g,t),t.viewState.rotation,o,er,h)}i.globalAlpha=n}renderDeferredInternal(t){const e=this.renderedTiles,i=k(this.getLayer()),n=e.reduce((l,h,c)=>(h.executorGroups[i].forEach(u=>l.push({executorGroup:u,index:c})),l),[]),r=n.map(({executorGroup:l})=>l.getDeferredZIndexContexts()),o={};for(let l=0,h=n.length;l<h;++l){const c=n[l].executorGroup.getDeferredZIndexContexts();for(const u in c)o[u]=!0}Object.keys(o).map(Number).sort(Ee).forEach(l=>{r.forEach((h,c)=>{h[l]&&(h[l].forEach(u=>{const{executorGroup:d,index:f}=n[c],g=d.getRenderedContext(),m=g.globalAlpha;g.globalAlpha=this.renderedOpacity_;const _=this.tileClipContexts_[f];_&&_.draw(g),u.draw(g),_&&g.restore(),g.globalAlpha=m,u.clear()}),h[l].length=0)})})}getTileRenderTransform(t,e){const i=e.pixelRatio,n=e.viewState,r=n.center,o=n.resolution,a=n.rotation,l=e.size,h=Math.round(l[0]*i),c=Math.round(l[1]*i),d=this.getLayer().getSource().getTileGridForProjection(e.viewState.projection),f=t.tileCoord,g=d.getTileCoordExtent(t.wrappedTileCoord),m=d.getTileCoordExtent(f,this.tempExtent)[0]-g[0];return mr(Gr(this.inversePixelTransform.slice(),1/i,1/i),this.getRenderTransform(r,o,a,i,h,c,m))}postRender(t,e){const i=e.viewHints,n=!(i[rt.ANIMATING]||i[rt.INTERACTING]);this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice(),this.renderedRotation_=e.viewState.rotation,this.renderedOpacity_=e.layerStatesArray[e.layerIndex].opacity;const r=this.getLayer(),o=r.getRenderMode(),a=t.globalAlpha;t.globalAlpha=this.renderedOpacity_;const l=r.getDeclutter(),h=l?ih[o].filter(E=>!er.includes(E)):ih[o],c=e.viewState,u=c.rotation,d=r.getSource(),g=d.getTileGridForProjection(c.projection).getZForResolution(c.resolution,d.zDirection),m=this.renderedTiles,_=[],p=[],y=[],T=k(r);let x=!0;for(let E=m.length-1;E>=0;--E){const v=m[E];x=x&&!v.getReplayState(r).dirty;const R=v.executorGroups[T].filter(F=>F.hasExecutors(h));if(R.length===0)continue;const S=this.getTileRenderTransform(v,e),w=v.tileCoord[0];let I=!1;const b=R[0].getClipCoords(S);let L=t,M;if(b){M=new Oa,L=M.getContext();for(let F=0,W=_.length;F<W;++F)if(g!==w&&w<p[F]){const A=_[F];ft([b[0],b[3],b[4],b[7]],[A[0],A[3],A[4],A[7]])&&(I||(L.save(),I=!0),L.beginPath(),L.moveTo(b[0],b[1]),L.lineTo(b[2],b[3]),L.lineTo(b[4],b[5]),L.lineTo(b[6],b[7]),L.moveTo(A[6],A[7]),L.lineTo(A[4],A[5]),L.lineTo(A[2],A[3]),L.lineTo(A[0],A[1]),L.clip())}_.push(b),p.push(w)}for(let F=0,W=R.length;F<W;++F)R[F].execute(t,[t.canvas.width,t.canvas.height],S,u,n,h,e.declutter?.[l]);I&&(L===t?L.restore():y[E]=M)}t.globalAlpha=a,this.ready=x,this.tileClipContexts_=y,e.declutter||this.renderDeferredInternal(e),super.postRender(t,e)}renderFeature(t,e,i,n,r,o){if(!i)return!1;let a=!1;if(Array.isArray(i))for(let l=0,h=i.length;l<h;++l)a=ir(n,t,i[l],e,this.boundHandleStyleImageChange_,void 0,r,o)||a;else a=ir(n,t,i,e,this.boundHandleStyleImageChange_,void 0,r,o);return a}tileImageNeedsRender_(t){const e=this.getLayer();if(e.getRenderMode()==="vector")return!1;const i=t.getReplayState(e),n=e.getRevision(),r=t.wantedResolution;return i.renderedTileResolution!==r||i.renderedTileRevision!==n}renderTileImage_(t,e){const i=this.getLayer(),n=t.getReplayState(i),r=i.getRevision(),o=t.executorGroups[k(i)];n.renderedTileRevision=r;const a=t.wrappedTileCoord,l=a[0],h=i.getSource();let c=e.pixelRatio;const d=e.viewState.projection,f=h.getTileGridForProjection(d),g=f.getResolution(t.tileCoord[0]),m=e.pixelRatio/t.wantedResolution*g,_=f.getResolution(l),p=t.getContext();c=Math.round(Math.max(c,m/c));const y=h.getTilePixelSize(l,c,d);p.canvas.width=y[0],p.canvas.height=y[1];const T=c/m;if(T!==1){const R=pl(this.tmpTransform_);Gr(R,T,T),p.setTransform.apply(p,R)}const x=f.getTileCoordExtent(a,this.tempExtent),E=m/_,v=pl(this.tmpTransform_);Gr(v,E,-E),Fh(v,-x[0],-x[3]);for(let R=0,S=o.length;R<S;++R)o[R].execute(p,[p.canvas.width*T,p.canvas.height*T],v,0,!0,xm[i.getRenderMode()],null);n.renderedTileResolution=t.wantedResolution}}class Zp extends ss{constructor(t){t=t||{};const e=Object.assign({},t);delete e.preload;const i=t.cacheSize===void 0?0:t.cacheSize;delete t.cacheSize,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i;const n=t.renderMode||"hybrid";H(n=="hybrid"||n=="vector","`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=n,this.setPreload(t.preload?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0),this.getBackground,this.setBackground}createRenderer(){return new Em(this,{cacheSize:this.cacheSize_})}getFeatures(t){return super.getFeatures(t)}getFeaturesInExtent(t){return this.getRenderer().getFeaturesInExtent(t)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(qe.PRELOAD)}getUseInterimTilesOnError(){return this.get(qe.USE_INTERIM_TILES_ON_ERROR)}setPreload(t){this.set(qe.PRELOAD,t)}setUseInterimTilesOnError(t){this.set(qe.USE_INTERIM_TILES_ON_ERROR,t)}}class Tm extends Da{constructor(t){super(t),this.image=null}getImage(){return this.image?this.image.getImage():null}prepareFrame(t){const e=t.layerStatesArray[t.layerIndex],i=t.pixelRatio,n=t.viewState,r=n.resolution,o=this.getLayer().getSource(),a=t.viewHints;let l=t.extent;if(e.extent!==void 0&&(l=Ne(l,ye(e.extent,n.projection))),!a[rt.ANIMATING]&&!a[rt.INTERACTING]&&!un(l))if(o){const h=n.projection,c=o.getImage(l,r,i,h);c&&(this.loadImage(c)?this.image=c:c.getState()===Y.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),n=ct(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!Ci(r,n))return null;const o=this.image.getExtent(),a=this.image.getImage(),l=it(o),h=Math.floor(a.width*((n[0]-o[0])/l));if(h<0||h>=a.width)return null;const c=Lt(o),u=Math.floor(a.height*((o[3]-n[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(t,e){const i=this.image,n=i.getExtent(),r=i.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],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),m=c*a/(f*l);this.prepareContainer(t,e);const _=this.context.canvas.width,p=this.context.canvas.height,y=this.getRenderContext(t);let T=!1,x=!0;if(h.extent){const w=ye(h.extent,u.projection);x=ft(w,t.extent),T=x&&!Ze(w,t.extent),T&&this.clipUnrotated(y,t,w)}const E=i.getImage(),v=ne(this.tempTransform,_/2,p/2,g,m,0,l*(n[0]-d[0])/o,l*(d[1]-n[3])/a);this.renderedResolution=a*c/l;const R=E.width*v[0],S=E.height*v[3];if(this.getLayer().getSource().getInterpolate()||(y.imageSmoothingEnabled=!1),this.preRender(y,t),x&&R>=.5&&S>=.5){const w=v[4],I=v[5],b=h.opacity;b!==1&&(y.save(),y.globalAlpha=b),y.drawImage(E,0,0,+E.width,+E.height,w,I,R,S),b!==1&&y.restore()}return this.postRender(this.context,t),T&&y.restore(),y.imageSmoothingEnabled=!0,this.container}}class Cm extends es{constructor(t){t=t||{},super(t)}}class Kp extends Cm{constructor(t){super(t)}createRenderer(){return new Tm(this)}getData(t){return super.getData(t)}}function Dc(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Wo(s,t){return s[0]=t[0],s[1]=t[1],s[4]=t[2],s[5]=t[3],s[12]=t[4],s[13]=t[5],s}const sr=34962,Ua=34963,vm=35044,ho=35048,Rm=5121,Sm=5123,wm=5125,kc=5126,nh=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function Pm(s,t){t=Object.assign({preserveDrawingBuffer:!0,antialias:!mu},t);const e=nh.length;for(let i=0;i<e;++i)try{const n=s.getContext(nh[i],t);if(n)return n}catch{}return null}const Im={STATIC_DRAW:vm};class co{constructor(t,e){this.array_=null,this.type_=t,H(t===sr||t===Ua,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=e!==void 0?e:Im.STATIC_DRAW}ofSize(t){return this.array_=new(Cs(this.type_))(t),this}fromArray(t){return this.array_=Cs(this.type_).from(t),this}fromArrayBuffer(t){return this.array_=new(Cs(this.type_))(t),this}getType(){return this.type_}getArray(){return this.array_}setArray(t){const e=Cs(this.type_);if(!(t instanceof e))throw new Error(`Expected ${e}`);this.array_=t}getUsage(){return this.usage_}getSize(){return this.array_?this.array_.length:0}}function Cs(s){switch(s){case sr:return Float32Array;case Ua:return Uint32Array;default:return Float32Array}}const vs={LOST:"webglcontextlost",RESTORED:"webglcontextrestored"},Am=`
precision mediump float;
attribute vec2 a_position;
varying vec2 v_texCoord;
varying vec2 v_screenCoord;
uniform vec2 u_screenSize;
void main() {
v_texCoord = a_position * 0.5 + 0.5;
v_screenCoord = v_texCoord * u_screenSize;
gl_Position = vec4(a_position, 0.0, 1.0);
}
`,Lm=`
precision mediump float;
uniform sampler2D u_image;
uniform float u_opacity;
varying vec2 v_texCoord;
void main() {
gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;
}
`;class sh{constructor(t){this.gl_=t.webGlContext;const e=this.gl_;this.scaleRatio_=t.scaleRatio||1,this.renderTargetTexture_=e.createTexture(),this.renderTargetTextureSize_=null,this.frameBuffer_=e.createFramebuffer(),this.depthBuffer_=e.createRenderbuffer();const i=e.createShader(e.VERTEX_SHADER);e.shaderSource(i,t.vertexShader||Am),e.compileShader(i);const n=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(n,t.fragmentShader||Lm),e.compileShader(n),this.renderTargetProgram_=e.createProgram(),e.attachShader(this.renderTargetProgram_,i),e.attachShader(this.renderTargetProgram_,n),e.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=e.createBuffer();const r=[-1,-1,1,-1,-1,1,1,-1,1,1,-1,1];e.bindBuffer(e.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),e.bufferData(e.ARRAY_BUFFER,new Float32Array(r),e.STATIC_DRAW),this.renderTargetAttribLocation_=e.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],t.uniforms&&Object.keys(t.uniforms).forEach(o=>{this.uniforms_.push({value:t.uniforms[o],location:e.getUniformLocation(this.renderTargetProgram_,o)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(t){const e=this.getGL(),i=[e.drawingBufferWidth*this.scaleRatio_,e.drawingBufferHeight*this.scaleRatio_];if(e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer()),e.bindRenderbuffer(e.RENDERBUFFER,this.getDepthBuffer()),e.viewport(0,0,i[0],i[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==i[0]||this.renderTargetTextureSize_[1]!==i[1]){this.renderTargetTextureSize_=i;const n=0,r=e.RGBA,o=0,a=e.RGBA,l=e.UNSIGNED_BYTE,h=null;e.bindTexture(e.TEXTURE_2D,this.renderTargetTexture_),e.texImage2D(e.TEXTURE_2D,n,r,i[0],i[1],o,a,l,h),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),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.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.renderTargetTexture_,0),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i[0],i[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthBuffer_)}}apply(t,e,i,n){const r=this.getGL(),o=t.size;if(r.bindFramebuffer(r.FRAMEBUFFER,e?e.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!e){const l=k(r.canvas);if(!t.renderTargets[l]){const h=r.getContextAttributes();h&&h.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),t.renderTargets[l]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,o[0],o[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const a=t.layerStatesArray[t.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(t),i&&i(r,t),r.drawArrays(r.TRIANGLES,0,6),n&&n(r,t)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(t){const e=this.getGL();let i,n=1;this.uniforms_.forEach(function(r){if(i=typeof r.value=="function"?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof ImageData)r.texture||(r.texture=e.createTexture()),e.activeTexture(e[`TEXTURE${n}`]),e.bindTexture(e.TEXTURE_2D,r.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),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),i instanceof ImageData?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,i.width,i.height,0,e.UNSIGNED_BYTE,new Uint8Array(i.data)):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i),e.uniform1i(r.location,n++);else if(Array.isArray(i))switch(i.length){case 2:e.uniform2f(r.location,i[0],i[1]);return;case 3:e.uniform3f(r.location,i[0],i[1],i[2]);return;case 4:e.uniform4f(r.location,i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&e.uniform1f(r.location,i)})}}const Le={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"},Rt={UNSIGNED_BYTE:Rm,UNSIGNED_SHORT:Sm,UNSIGNED_INT:wm,FLOAT:kc},rr={};function rh(s){return"shared/"+s}let oh=0;function bm(){const s="unique/"+oh;return oh+=1,s}function Fm(s){let t=rr[s];if(!t){const e=document.createElement("canvas");e.width=1,e.height=1,e.style.position="absolute",e.style.left="0",t={users:0,context:Pm(e)},rr[s]=t}return t.users+=1,t.context}function Mm(s){const t=rr[s];if(!t||(t.users-=1,t.users>0))return;const e=t.context,i=e.getExtension("WEBGL_lose_context");i&&i.loseContext();const n=e.canvas;n.width=1,n.height=1,delete rr[s]}class Om extends Zn{constructor(t){super(),t=t||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=t.canvasCacheKey?rh(t.canvasCacheKey):bm(),this.gl_=Fm(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const e=this.gl_.canvas;e.addEventListener(vs.LOST,this.boundHandleWebGLContextLost_),e.addEventListener(vs.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=_t(),this.offsetScaleMatrix_=_t(),this.tmpMat4_=Dc(),this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],t.uniforms&&this.setUniforms(t.uniforms),this.postProcessPasses_=t.postProcesses?t.postProcesses.map(i=>new sh({webGlContext:this.gl_,scaleRatio:i.scaleRatio,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,uniforms:i.uniforms})):[new sh({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now(),this.maxAttributeCount_=this.gl_.getParameter(this.gl_.MAX_VERTEX_ATTRIBS)}setUniforms(t){this.uniforms_=[],this.addUniforms(t)}addUniforms(t){for(const e in t)this.uniforms_.push({name:e,value:t[e]})}canvasCacheKeyMatches(t){return this.canvasCacheKey_===rh(t)}getExtension(t){if(t in this.extensionCache_)return this.extensionCache_[t];const e=this.gl_.getExtension(t);return this.extensionCache_[t]=e,e}getInstancedRenderingExtension_(){const t=this.getExtension("ANGLE_instanced_arrays");return H(!!t,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),t}bindBuffer(t){const e=this.gl_,i=k(t);let n=this.bufferCache_[i];if(!n){const r=e.createBuffer();n={buffer:t,webGlBuffer:r},this.bufferCache_[i]=n}e.bindBuffer(t.getType(),n.webGlBuffer)}flushBufferData(t){const e=this.gl_;this.bindBuffer(t),e.bufferData(t.getType(),t.getArray(),t.getUsage())}deleteBuffer(t){const e=k(t);delete this.bufferCache_[e]}disposeInternal(){const t=this.gl_.canvas;t.removeEventListener(vs.LOST,this.boundHandleWebGLContextLost_),t.removeEventListener(vs.RESTORED,this.boundHandleWebGLContextRestored_),Mm(this.canvasCacheKey_),delete this.gl_}prepareDraw(t,e,i){const n=this.gl_,r=this.getCanvas(),o=t.size,a=t.pixelRatio;(r.width!==o[0]*a||r.height!==o[1]*a)&&(r.width=o[0]*a,r.height=o[1]*a,r.style.width=o[0]+"px",r.style.height=o[1]+"px");for(let l=this.postProcessPasses_.length-1;l>=0;l--)this.postProcessPasses_[l].init(t);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,e?n.ZERO:n.ONE_MINUS_SRC_ALPHA),i?(n.enable(n.DEPTH_TEST),n.depthFunc(n.LEQUAL)):n.disable(n.DEPTH_TEST)}bindFrameBuffer(t,e){const i=this.getGL();i.bindFramebuffer(i.FRAMEBUFFER,t),e&&i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0)}bindInitialFrameBuffer(){const t=this.getGL(),e=this.postProcessPasses_[0].getFrameBuffer();t.bindFramebuffer(t.FRAMEBUFFER,e);const i=this.postProcessPasses_[0].getRenderTargetTexture();t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0)}bindTexture(t,e,i){const n=this.gl_;n.activeTexture(n.TEXTURE0+e),n.bindTexture(n.TEXTURE_2D,t),n.uniform1i(this.getUniformLocation(i),e)}bindAttribute(t,e,i){const n=this.getGL();this.bindBuffer(t);const r=this.getAttributeLocation(e);n.enableVertexAttribArray(r),n.vertexAttribPointer(r,i,n.FLOAT,!1,0,0)}prepareDrawToRenderTarget(t,e,i,n){const r=this.gl_,o=e.getSize();r.bindFramebuffer(r.FRAMEBUFFER,e.getFramebuffer()),r.bindRenderbuffer(r.RENDERBUFFER,e.getDepthbuffer()),r.viewport(0,0,o[0],o[1]),r.bindTexture(r.TEXTURE_2D,e.getTexture()),r.clearColor(0,0,0,0),r.depthRange(0,1),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),r.enable(r.BLEND),r.blendFunc(r.ONE,i?r.ZERO:r.ONE_MINUS_SRC_ALPHA),n?(r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL)):r.disable(r.DEPTH_TEST)}drawElements(t,e){const i=this.gl_;this.getExtension("OES_element_index_uint");const n=i.UNSIGNED_INT,r=4,o=e-t,a=t*r;i.drawElements(i.TRIANGLES,o,n,a)}drawElementsInstanced(t,e,i){const n=this.gl_;this.getExtension("OES_element_index_uint");const r=this.getInstancedRenderingExtension_(),o=n.UNSIGNED_INT,a=4,l=e-t,h=t*a;r.drawElementsInstancedANGLE(n.TRIANGLES,l,o,h,i);for(let c=0;c<this.maxAttributeCount_;c++)r.vertexAttribDivisorANGLE(c,0)}finalizeDraw(t,e,i){for(let n=0,r=this.postProcessPasses_.length;n<r;n++)n===r-1?this.postProcessPasses_[n].apply(t,null,e,i):this.postProcessPasses_[n].apply(t,this.postProcessPasses_[n+1])}getCanvas(){return this.gl_.canvas}getGL(){return this.gl_}applyFrameState(t){const e=t.size,i=t.viewState.rotation,n=t.pixelRatio;this.setUniformFloatValue(Le.TIME,(Date.now()-this.startTime_)*.001),this.setUniformFloatValue(Le.ZOOM,t.viewState.zoom),this.setUniformFloatValue(Le.RESOLUTION,t.viewState.resolution),this.setUniformFloatValue(Le.PIXEL_RATIO,n),this.setUniformFloatVec2(Le.VIEWPORT_SIZE_PX,[e[0],e[1]]),this.setUniformFloatValue(Le.ROTATION,i)}applyHitDetectionUniform(t){const e=this.getUniformLocation(Le.HIT_DETECTION);this.getGL().uniform1i(e,t?1:0),t&&this.setUniformFloatValue(Le.PIXEL_RATIO,.5)}applyUniforms(t){const e=this.gl_;let i,n=0;this.uniforms_.forEach(r=>{if(i=typeof r.value=="function"?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof ImageData||i instanceof WebGLTexture){i instanceof WebGLTexture&&!r.texture?(r.prevValue=void 0,r.texture=i):r.texture||(r.prevValue=void 0,r.texture=e.createTexture()),this.bindTexture(r.texture,n,r.name),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),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);const o=!(i instanceof HTMLImageElement)||i.complete;!(i instanceof WebGLTexture)&&o&&r.prevValue!==i&&(r.prevValue=i,e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i)),n++}else if(Array.isArray(i)&&i.length===6)this.setUniformMatrixValue(r.name,Wo(this.tmpMat4_,i));else if(Array.isArray(i)&&i.length<=4)switch(i.length){case 2:e.uniform2f(this.getUniformLocation(r.name),i[0],i[1]);return;case 3:e.uniform3f(this.getUniformLocation(r.name),i[0],i[1],i[2]);return;case 4:e.uniform4f(this.getUniformLocation(r.name),i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&e.uniform1f(this.getUniformLocation(r.name),i)})}useProgram(t,e){this.disableAllAttributes_(),this.gl_.useProgram(t),this.currentProgram_=t,e&&(this.applyFrameState(e),this.applyUniforms(e))}compileShader(t,e){const i=this.gl_,n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}getProgram(t,e){const i=this.gl_,n=this.compileShader(t,i.FRAGMENT_SHADER),r=this.compileShader(e,i.VERTEX_SHADER),o=i.createProgram();if(i.attachShader(o,n),i.attachShader(o,r),i.linkProgram(o),!i.getShaderParameter(n,i.COMPILE_STATUS)){const a=`Fragment shader compilation failed: ${i.getShaderInfoLog(n)}`;throw new Error(a)}if(i.deleteShader(n),!i.getShaderParameter(r,i.COMPILE_STATUS)){const a=`Vertex shader compilation failed: ${i.getShaderInfoLog(r)}`;throw new Error(a)}if(i.deleteShader(r),!i.getProgramParameter(o,i.LINK_STATUS)){const a=`GL program linking failed: ${i.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(t){const e=k(this.currentProgram_);return this.uniformLocationsByProgram_[e]===void 0&&(this.uniformLocationsByProgram_[e]={}),this.uniformLocationsByProgram_[e][t]===void 0&&(this.uniformLocationsByProgram_[e][t]=this.gl_.getUniformLocation(this.currentProgram_,t)),this.uniformLocationsByProgram_[e][t]}getAttributeLocation(t){const e=k(this.currentProgram_);return this.attribLocationsByProgram_[e]===void 0&&(this.attribLocationsByProgram_[e]={}),this.attribLocationsByProgram_[e][t]===void 0&&(this.attribLocationsByProgram_[e][t]=this.gl_.getAttribLocation(this.currentProgram_,t)),this.attribLocationsByProgram_[e][t]}makeProjectionTransform(t,e){const i=t.size,n=t.viewState.rotation,r=t.viewState.resolution,o=t.viewState.center;return ne(e,0,0,2/(r*i[0]),2/(r*i[1]),-n,-o[0],-o[1]),e}setUniformFloatValue(t,e){this.gl_.uniform1f(this.getUniformLocation(t),e)}setUniformFloatVec2(t,e){this.gl_.uniform2fv(this.getUniformLocation(t),e)}setUniformFloatVec4(t,e){this.gl_.uniform4fv(this.getUniformLocation(t),e)}setUniformMatrixValue(t,e){this.gl_.uniformMatrix4fv(this.getUniformLocation(t),!1,e)}disableAllAttributes_(){for(let t=0;t<this.maxAttributeCount_;t++)this.gl_.disableVertexAttribArray(t)}enableAttributeArray_(t,e,i,n,r,o){const a=this.getAttributeLocation(t);a<0||(this.gl_.enableVertexAttribArray(a),this.gl_.vertexAttribPointer(a,e,i,!1,n,r),o&&this.getInstancedRenderingExtension_().vertexAttribDivisorANGLE(a,1))}enableAttributes_(t,e){const i=Dm(t);let n=0;for(let r=0;r<t.length;r++){const o=t[r];o.name&&this.enableAttributeArray_(o.name,o.size,o.type||kc,i,n,e),n+=o.size*Nc(o.type)}}enableAttributes(t){this.enableAttributes_(t,!1)}enableAttributesInstanced(t){this.enableAttributes_(t,!0)}handleWebGLContextLost(t){Pi(this.bufferCache_),this.currentProgram_=null,t.preventDefault()}handleWebGLContextRestored(){this.needsToBeRecreated_=!0}needsToBeRecreated(){return this.needsToBeRecreated_}createTexture(t,e,i,n){const r=this.gl_;i=i||r.createTexture();const o=n?r.NEAREST:r.LINEAR;r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);const a=0,l=r.RGBA,h=0,c=r.RGBA,u=r.UNSIGNED_BYTE;return e instanceof Uint8Array?r.texImage2D(r.TEXTURE_2D,a,l,t[0],t[1],h,c,u,e):e?r.texImage2D(r.TEXTURE_2D,a,l,c,u,e):r.texImage2D(r.TEXTURE_2D,a,l,t[0],t[1],h,c,u,null),i}}function Dm(s){let t=0;for(let e=0;e<s.length;e++){const i=s[e];t+=i.size*Nc(i.type)}return t}function Nc(s){switch(s){case Rt.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case Rt.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case Rt.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case Rt.FLOAT:default:return Float32Array.BYTES_PER_ELEMENT}}class $a extends mc{constructor(t,e){super(t),e=e||{},this.inversePixelTransform_=_t(),this.postProcesses_=e.postProcesses,this.uniforms_=e.uniforms,this.helper,this.onMapChanged_=()=>{this.clearCache(),this.removeHelper()},t.addChangeListener(et.MAP,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Ct.PRECOMPOSE)){const n=new On(Ct.PRECOMPOSE,void 0,e,t);i.dispatchEvent(n)}}dispatchPostComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Ct.POSTCOMPOSE)){const n=new On(Ct.POSTCOMPOSE,void 0,e,t);i.dispatchEvent(n)}}reset(t){this.uniforms_=t.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(t){if(this.getLayer().getRenderSource()){let e=!0,i=-1,n;for(let o=0,a=t.layerStatesArray.length;o<a;o++){const l=t.layerStatesArray[o].layer,h=l.getRenderer();if(!(h instanceof $a)){e=!0;continue}const c=l.getClassName();if((e||c!==n)&&(i+=1,e=!1),n=c,h===this)break}const r="map/"+t.mapId+"/group/"+i;(!this.helper||!this.helper.canvasCacheKeyMatches(r)||this.helper.needsToBeRecreated())&&(this.removeHelper(),this.helper=new Om({postProcesses:this.postProcesses_,uniforms:this.uniforms_,canvasCacheKey:r}),n&&(this.helper.getCanvas().className=n),this.afterHelperCreated())}return this.prepareFrameInternal(t)}afterHelperCreated(){}prepareFrameInternal(t){return!0}clearCache(){}disposeInternal(){this.clearCache(),this.removeHelper(),this.getLayer()?.removeChangeListener(et.MAP,this.onMapChanged_),super.disposeInternal()}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){ne(this.inversePixelTransform_,0,0,i.pixelRatio,-i.pixelRatio,0,0,-i.size[1]);const r=new On(t,this.inversePixelTransform_,i,e);n.dispatchEvent(r)}}preRender(t,e){this.dispatchRenderEvent_(Ct.PRERENDER,t,e)}postRender(t,e){this.dispatchRenderEvent_(Ct.POSTRENDER,t,e)}}const uo={TILE_TEXTURE_ARRAY:"u_tileTextures",TEXTURE_PIXEL_WIDTH:"u_texturePixelWidth",TEXTURE_PIXEL_HEIGHT:"u_texturePixelHeight"};class km{constructor(t,e){this.name=t,this.data=e,this.texture_=null}getTexture(t){if(!this.texture_){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e),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.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.data.length/4,1,0,t.RGBA,t.UNSIGNED_BYTE,this.data),this.texture_=e}return this.texture_}delete(t){this.texture_&&t.deleteTexture(this.texture_),this.texture_=null}}function Nm(s,t){return`operator_${s}_${Object.keys(t.functions).length}`}function ti(s){const t=s.toString();return t.includes(".")?t:t+".0"}function Wa(s){if(s.length<2||s.length>4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${s.length}(${s.map(ti).join(", ")})`}function ks(s){const t=ue(s),e=t.length>3?t[3]:1;return Wa([t[0]/255,t[1]/255,t[2]/255,e])}function Gm(s){const t=bt(s);return Wa(t)}const fo={};let Bm=0;function Vn(s){return s in fo||(fo[s]=Bm++),fo[s]}function Oe(s){return ti(Vn(s))}function Xa(s){return"u_var_"+s}function Gc(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const go="getBandValue",zm="u_paletteTextures",Bc="featureId",zc="geometryType",Xo=-9999999;function Um(s,t,e,i){const n=vt(s,t,e);return ja(n,t,i)}function q(s){return(t,e,i)=>{const n=e.args.length,r=new Array(n);for(let o=0;o<n;++o)r[o]=ja(e.args[o],i,t);return s(r,t)}}const $m={[C.Get]:(s,t)=>{const i=t.args[0].value;i in s.properties||(s.properties[i]={name:i,type:t.type});let r="a_prop_"+i;return pe(t.type,gt)&&(r=`(${r} > 0.0)`),r},[C.Id]:s=>(s.featureId=!0,"a_"+Bc),[C.GeometryType]:s=>(s.geometryType=!0,"a_"+zc),[C.LineMetric]:()=>"currentLineMetric",[C.Var]:(s,t)=>{const i=t.args[0].value;i in s.variables||(s.variables[i]={name:i,type:t.type});let r=Xa(i);return pe(t.type,gt)&&(r=`(${r} > 0.0)`),r},[C.Has]:(s,t)=>{const i=t.args[0].value;return i in s.properties||(s.properties[i]={name:i,type:t.type}),`(a_prop_${i} != ${ti(Xo)})`},[C.Resolution]:()=>"u_resolution",[C.Zoom]:()=>"u_zoom",[C.Time]:()=>"u_time",[C.Any]:q(s=>`(${s.join(" || ")})`),[C.All]:q(s=>`(${s.join(" && ")})`),[C.Not]:q(([s])=>`(!${s})`),[C.Equal]:q(([s,t])=>`(${s} == ${t})`),[C.NotEqual]:q(([s,t])=>`(${s} != ${t})`),[C.GreaterThan]:q(([s,t])=>`(${s} > ${t})`),[C.GreaterThanOrEqualTo]:q(([s,t])=>`(${s} >= ${t})`),[C.LessThan]:q(([s,t])=>`(${s} < ${t})`),[C.LessThanOrEqualTo]:q(([s,t])=>`(${s} <= ${t})`),[C.Multiply]:q(s=>`(${s.join(" * ")})`),[C.Divide]:q(([s,t])=>`(${s} / ${t})`),[C.Add]:q(s=>`(${s.join(" + ")})`),[C.Subtract]:q(([s,t])=>`(${s} - ${t})`),[C.Clamp]:q(([s,t,e])=>`clamp(${s}, ${t}, ${e})`),[C.Mod]:q(([s,t])=>`mod(${s}, ${t})`),[C.Pow]:q(([s,t])=>`pow(${s}, ${t})`),[C.Abs]:q(([s])=>`abs(${s})`),[C.Floor]:q(([s])=>`floor(${s})`),[C.Ceil]:q(([s])=>`ceil(${s})`),[C.Round]:q(([s])=>`floor(${s} + 0.5)`),[C.Sin]:q(([s])=>`sin(${s})`),[C.Cos]:q(([s])=>`cos(${s})`),[C.Atan]:q(([s,t])=>t!==void 0?`atan(${s}, ${t})`:`atan(${s})`),[C.Sqrt]:q(([s])=>`sqrt(${s})`),[C.Match]:q(s=>{const t=s[0],e=s[s.length-1];let i=null;for(let n=s.length-3;n>=1;n-=2){const r=s[n],o=s[n+1];i=`(${t} == ${r} ? ${o} : ${i||e})`}return i}),[C.Between]:q(([s,t,e])=>`(${s} >= ${t} && ${s} <= ${e})`),[C.Interpolate]:q(([s,t,...e])=>{let i="";for(let n=0;n<e.length-2;n+=2){const r=e[n],o=i||e[n+1],a=e[n+2],l=e[n+3];let h;s===ti(1)?h=`(${t} - ${r}) / (${a} - ${r})`:h=`(pow(${s}, (${t} - ${r})) - 1.0) / (pow(${s}, (${a} - ${r})) - 1.0)`,i=`mix(${o}, ${l}, clamp(${h}, 0.0, 1.0))`}return i}),[C.Case]:q(s=>{const t=s[s.length-1];let e=null;for(let i=s.length-3;i>=0;i-=2){const n=s[i],r=s[i+1];e=`(${n} ? ${r} : ${e||t})`}return e}),[C.In]:q(([s,...t],e)=>{const i=Nm("in",e),n=[];for(let r=0;r<t.length;r+=1)n.push(` if (inputValue == ${t[r]}) { return true; }`);return e.functions[i]=`bool ${i}(float inputValue) {
${n.join(`
`)}
return false;
}`,`${i}(${s})`}),[C.Array]:q(s=>`vec${s.length}(${s.join(", ")})`),[C.Color]:q(s=>{if(s.length===1)return`vec4(vec3(${s[0]} / 255.0), 1.0)`;if(s.length===2)return`vec4(vec3(${s[0]} / 255.0), ${s[1]})`;const t=s.slice(0,3).map(i=>`${i} / 255.0`);if(s.length===3)return`vec4(${t.join(", ")}, 1.0)`;const e=s[3];return`vec4(${t.join(", ")}, ${e})`}),[C.Band]:q(([s,t,e],i)=>{if(!(go in i.functions)){let n="";const r=i.bandCount||1;for(let o=0;o<r;o++){const a=Math.floor(o/4);let l=o%4;o===r-1&&l===1&&(l=3);const h=`${uo.TILE_TEXTURE_ARRAY}[${a}]`;n+=` if (band == ${o+1}.0) {
return texture2D(${h}, v_textureCoord + vec2(dx, dy))[${l}];
}
`}i.functions[go]=`float getBandValue(float band, float xOffset, float yOffset) {
float dx = xOffset / ${uo.TEXTURE_PIXEL_WIDTH};
float dy = yOffset / ${uo.TEXTURE_PIXEL_HEIGHT};
${n}
}`}return`${go}(${s}, ${t??"0.0"}, ${e??"0.0"})`}),[C.Palette]:(s,t)=>{const[e,...i]=t.args,n=i.length,r=new Uint8Array(n*4);for(let h=0;h<i.length;h++){const c=i[h].value,u=ue(c),d=h*4;r[d]=u[0],r[d+1]=u[1],r[d+2]=u[2],r[d+3]=u[3]*255}s.paletteTextures||(s.paletteTextures=[]);const o=`${zm}[${s.paletteTextures.length}]`,a=new km(o,r);s.paletteTextures.push(a);const l=ja(e,O,s);return`texture2D(${o}, vec2((${l} + 0.5) / ${n}.0, 0.5))`}};function ja(s,t,e){if(s instanceof tc){const i=$m[s.operator];if(i===void 0)throw new Error(`No compiler defined for this operator: ${JSON.stringify(s.operator)}`);return i(e,s,t)}if((s.type&O)>0)return ti(s.value);if((s.type&gt)>0)return s.value.toString();if((s.type&yt)>0)return Oe(s.value.toString());if((s.type&at)>0)return ks(s.value);if((s.type&Gt)>0)return Wa(s.value);if((s.type&te)>0)return Gm(s.value);throw new Error(`Unexpected expression ${s.value} (expected type ${Hi(t)})`)}function Wm(){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"}}const ah=.985;function U(s,t,e){const i=Ia();return Um(t,e,i,s)}function Xm(s){const t=ue(s),e=t[0]*256,i=t[1],n=t[2]*256,r=Math.round(t[3]*255);return[e+i,n+r]}const jm=`vec4 unpackColor(vec2 packedColor) {
return vec4(
min(floor(packedColor[0] / 256.0) / 255.0, 1.0),
min(mod(packedColor[0], 256.0) / 255.0, 1.0),
min(floor(packedColor[1] / 256.0) / 255.0, 1.0),
min(mod(packedColor[1], 256.0) / 255.0, 1.0)
);
}`;function Ya(s){return s===at||s===te?2:s===Gt?4:1}function jo(s){const t=Ya(s);return t>1?`vec${t}`:"float"}function Uc(s,t){for(const e in t.variables){const i=t.variables[e],n=Xa(i.name);let r=jo(i.type);i.type===at&&(r="vec4"),s.addUniform(n,r)}for(const e in t.properties){const i=t.properties[e],n=jo(i.type),r=`a_prop_${i.name}`;i.type===at?s.addAttribute(r,n,`unpackColor(${r})`,"vec4"):s.addAttribute(r,n)}for(const e in t.functions)s.addVertexShaderFunction(t.functions[e]),s.addFragmentShaderFunction(t.functions[e])}function $c(s,t){const e={};for(const i in s.variables){const n=s.variables[i],r=Xa(n.name);e[r]=()=>{const o=t[n.name];if(typeof o=="number")return o;if(typeof o=="boolean")return o?1:0;if(n.type===at){const a=[...ue(o||"#eee")];return a[0]/=255,a[1]/=255,a[2]/=255,a[3]??=1,a}return typeof o=="string"?Vn(o):o}}return e}function Wc(s){const t={};for(const e in s.properties){const i=s.properties[e],n=r=>{const o=r.get(i.name);return i.type===at?Xm([...ue(o||"#eee")]):typeof o=="string"?Vn(o):typeof o=="boolean"?o?1:0:o};t[`prop_${i.name}`]={size:Ya(i.type),callback:n}}return t}const $i=`#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
uniform mat4 u_projectionMatrix;
uniform mat4 u_screenToWorldMatrix;
uniform vec2 u_viewportSizePx;
uniform float u_pixelRatio;
uniform float u_globalAlpha;
uniform float u_time;
uniform float u_zoom;
uniform float u_resolution;
uniform float u_rotation;
uniform vec4 u_renderExtent;
uniform vec2 u_patternOrigin;
uniform float u_depth;
uniform mediump int u_hitDetection;
const float PI = 3.141592653589793238;
const float TWO_PI = 2.0 * PI;
float currentLineMetric = 0.; // an actual value will be used in the stroke shaders
${jm}
`,Wi=Wm();class Xc{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${ti(Wi["circle-radius"])} + ${ti(Wi["circle-stroke-width"]*.5)})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=ks(Wi["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_=ti(Wi["stroke-width"]),this.strokeColorExpression_=ks(Wi["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=Oe("round"),this.strokeJoinExpression_=Oe("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=ks(Wi["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(t,e){return this.uniforms_.push({name:t,type:e}),this}addAttribute(t,e,i,n){return this.attributes_.push({name:t,type:e,varyingName:t.replace(/^a_/,"v_"),varyingType:n??e,varyingExpression:i??t}),this}setSymbolSizeExpression(t){return this.hasSymbol_=!0,this.symbolSizeExpression_=t,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(t){return this.symbolRotationExpression_=t,this}setSymbolOffsetExpression(t){return this.symbolOffsetExpression_=t,this}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}setSymbolColorExpression(t){return this.hasSymbol_=!0,this.symbolColorExpression_=t,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(t){return this.texCoordExpression_=t,this}setFragmentDiscardExpression(t){return this.discardExpression_=t,this}getFragmentDiscardExpression(){return this.discardExpression_}setSymbolRotateWithView(t){return this.symbolRotateWithView_=t,this}setStrokeWidthExpression(t){return this.hasStroke_=!0,this.strokeWidthExpression_=t,this}setStrokeColorExpression(t){return this.hasStroke_=!0,this.strokeColorExpression_=t,this}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(t){return this.strokeOffsetExpression_=t,this}setStrokeCapExpression(t){return this.strokeCapExpression_=t,this}setStrokeJoinExpression(t){return this.strokeJoinExpression_=t,this}setStrokeMiterLimitExpression(t){return this.strokeMiterLimitExpression_=t,this}setStrokeDistanceFieldExpression(t){return this.strokeDistanceFieldExpression_=t,this}setStrokePatternLengthExpression(t){return this.strokePatternLengthExpression_=t,this}getStrokePatternLengthExpression(){return this.strokePatternLengthExpression_}setFillColorExpression(t){return this.hasFill_=!0,this.fillColorExpression_=t,this}getFillColorExpression(){return this.fillColorExpression_}addVertexShaderFunction(t){return this.vertexShaderFunctions_.includes(t)?this:(this.vertexShaderFunctions_.push(t),this)}addFragmentShaderFunction(t){return this.fragmentShaderFunctions_.includes(t)?this:(this.fragmentShaderFunctions_.push(t),this)}getSymbolVertexShader(){return this.hasSymbol_?`${$i}
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
`)}
attribute vec2 a_position;
attribute vec2 a_localPosition;
attribute vec2 a_hitColor;
varying vec2 v_texCoord;
varying vec2 v_quadCoord;
varying vec4 v_hitColor;
varying vec2 v_centerPx;
varying float v_angle;
varying vec2 v_quadSizePx;
${this.attributes_.map(t=>`attribute ${t.type} ${t.name};
varying ${t.varyingType} ${t.varyingName};`).join(`
`)}
${this.vertexShaderFunctions_.join(`
`)}
vec2 pxToScreen(vec2 coordPx) {
vec2 scaled = coordPx / u_viewportSizePx / 0.5;
return scaled;
}
vec2 screenToPx(vec2 coordScreen) {
return (coordScreen * 0.5 + 0.5) * u_viewportSizePx;
}
void main(void) {
v_quadSizePx = ${this.symbolSizeExpression_};
vec2 halfSizePx = v_quadSizePx * 0.5;
vec2 centerOffsetPx = ${this.symbolOffsetExpression_};
vec2 offsetPx = centerOffsetPx + a_localPosition * halfSizePx * vec2(1., -1.);
float angle = ${this.symbolRotationExpression_}${this.symbolRotateWithView_?" + u_rotation":""};
float c = cos(-angle);
float s = sin(-angle);
offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);
vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);
gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);
vec4 texCoord = ${this.texCoordExpression_};
float u = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);
float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);
v_texCoord = vec2(u, v);
v_hitColor = unpackColor(a_hitColor);
v_angle = angle;
c = cos(-v_angle);
s = sin(-v_angle);
centerOffsetPx = vec2(c * centerOffsetPx.x - s * centerOffsetPx.y, s * centerOffsetPx.x + c * centerOffsetPx.y);
v_centerPx = screenToPx(center.xy) + centerOffsetPx;
${this.attributes_.map(t=>` ${t.varyingName} = ${t.varyingExpression};`).join(`
`)}
}`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${$i}
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
`)}
varying vec2 v_texCoord;
varying vec4 v_hitColor;
varying vec2 v_centerPx;
varying float v_angle;
varying vec2 v_quadSizePx;
${this.attributes_.map(t=>`varying ${t.varyingType} ${t.varyingName};`).join(`
`)}
${this.fragmentShaderFunctions_.join(`
`)}
void main(void) {
${this.attributes_.map(t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`).join(`
`)}
if (${this.discardExpression_}) { discard; }
vec2 coordsPx = gl_FragCoord.xy / u_pixelRatio - v_centerPx; // relative to center
float c = cos(v_angle);
float s = sin(v_angle);
coordsPx = vec2(c * coordsPx.x - s * coordsPx.y, s * coordsPx.x + c * coordsPx.y);
gl_FragColor = ${this.symbolColorExpression_};
gl_FragColor.rgb *= gl_FragColor.a;
if (u_hitDetection > 0) {
if (gl_FragColor.a < 0.05) { discard; };
gl_FragColor = v_hitColor;
}
}`:null}getStrokeVertexShader(){return this.hasStroke_?`${$i}
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
`)}
attribute vec2 a_segmentStart;
attribute vec2 a_segmentEnd;
attribute vec2 a_localPosition;
attribute float a_measureStart;
attribute float a_measureEnd;
attribute float a_angleTangentSum;
attribute float a_distanceLow;
attribute float a_distanceHigh;
attribute vec2 a_joinAngles;
attribute vec2 a_hitColor;
varying vec2 v_segmentStartPx;
varying vec2 v_segmentEndPx;
varying float v_angleStart;
varying float v_angleEnd;
varying float v_width;
varying vec4 v_hitColor;
varying float v_distancePx;
varying float v_measureStart;
varying float v_measureEnd;
${this.attributes_.map(t=>`attribute ${t.type} ${t.name};
varying ${t.varyingType} ${t.varyingName};`).join(`
`)}
${this.vertexShaderFunctions_.join(`
`)}
vec2 worldToPx(vec2 worldPos) {
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
}
vec4 pxToScreen(vec2 pxPos) {
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
return vec4(screenPos, u_depth, 1.0);
}
bool isCap(float joinAngle) {
return joinAngle < -0.1;
}
vec2 getJoinOffsetDirection(vec2 normalPx, float joinAngle) {
float halfAngle = joinAngle / 2.0;
float c = cos(halfAngle);
float s = sin(halfAngle);
vec2 angleBisectorNormal = vec2(s * normalPx.x + c * normalPx.y, -c * normalPx.x + s * normalPx.y);
float length = 1.0 / s;
return angleBisectorNormal * length;
}
vec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {
// if on a cap or the join angle is too high, offset the line along the segment normal
if (cos(joinAngle) > 0.998 || isCap(joinAngle)) {
return point - normal * offsetPx;
}
// offset is applied along the inverted normal (positive offset goes "right" relative to line direction)
return point - getJoinOffsetDirection(normal, joinAngle) * offsetPx;
}
void main(void) {
v_angleStart = a_joinAngles.x;
v_angleEnd = a_joinAngles.y;
float startEndRatio = a_localPosition.x * 0.5 + 0.5;
currentLineMetric = mix(a_measureStart, a_measureEnd, startEndRatio);
// we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)
float lineWidth = ${this.strokeWidthExpression_};
float lineOffsetPx = ${this.strokeOffsetExpression_};
// compute segment start/end in px with offset
vec2 segmentStartPx = worldToPx(a_segmentStart);
vec2 segmentEndPx = worldToPx(a_segmentEnd);
vec2 tangentPx = normalize(segmentEndPx - segmentStartPx);
vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);
segmentStartPx = getOffsetPoint(segmentStartPx, normalPx, v_angleStart, lineOffsetPx),
segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);
// compute current vertex position
float normalDir = -1. * a_localPosition.y;
float tangentDir = -1. * a_localPosition.x;
float angle = mix(v_angleStart, v_angleEnd, startEndRatio);
vec2 joinDirection;
vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);
// if angle is too high, do not make a proper join
if (cos(angle) > ${ah} || isCap(angle)) {
joinDirection = normalPx * normalDir - tangentPx * tangentDir;
} else {
joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);
}
positionPx = positionPx + joinDirection * (lineWidth * 0.5 + 1.); // adding 1 pixel for antialiasing
gl_Position = pxToScreen(positionPx);
v_segmentStartPx = segmentStartPx;
v_segmentEndPx = segmentEndPx;
v_width = lineWidth;
v_hitColor = unpackColor(a_hitColor);
v_distancePx = a_distanceLow / u_resolution - (lineOffsetPx * a_angleTangentSum);
float distanceHighPx = a_distanceHigh / u_resolution;
${this.strokePatternLengthExpression_!==null?`v_distancePx = mod(v_distancePx, ${this.strokePatternLengthExpression_});
distanceHighPx = mod(distanceHighPx, ${this.strokePatternLengthExpression_});
`:""}v_distancePx += distanceHighPx;
v_measureStart = a_measureStart;
v_measureEnd = a_measureEnd;
${this.attributes_.map(t=>` ${t.varyingName} = ${t.varyingExpression};`).join(`
`)}
}`:null}getStrokeFragmentShader(){return this.hasStroke_?`${$i}
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
`)}
varying vec2 v_segmentStartPx;
varying vec2 v_segmentEndPx;
varying float v_angleStart;
varying float v_angleEnd;
varying float v_width;
varying vec4 v_hitColor;
varying float v_distancePx;
varying float v_measureStart;
varying float v_measureEnd;
${this.attributes_.map(t=>`varying ${t.varyingType} ${t.varyingName};`).join(`
`)}
${this.fragmentShaderFunctions_.join(`
`)}
vec2 pxToWorld(vec2 pxPos) {
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
}
bool isCap(float joinAngle) {
return joinAngle < -0.1;
}
float segmentDistanceField(vec2 point, vec2 start, vec2 end, float width) {
vec2 tangent = normalize(end - start);
vec2 normal = vec2(-tangent.y, tangent.x);
vec2 startToPoint = point - start;
return abs(dot(startToPoint, normal)) - width * 0.5;
}
float buttCapDistanceField(vec2 point, vec2 start, vec2 end) {
vec2 startToPoint = point - start;
vec2 tangent = normalize(end - start);
return dot(startToPoint, -tangent);
}
float squareCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
return buttCapDistanceField(point, start, end) - width * 0.5;
}
float roundCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
float onSegment = max(0., 1000. * dot(point - start, end - start)); // this is very high when inside the segment
return length(point - start) - width * 0.5 - onSegment;
}
float roundJoinDistanceField(vec2 point, vec2 start, vec2 end, float width) {
return roundCapDistanceField(point, start, end, width);
}
float bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
vec2 startToPoint = point - start;
vec2 tangent = normalize(end - start);
float c = cos(joinAngle * 0.5);
float s = sin(joinAngle * 0.5);
float direction = -sign(sin(joinAngle));
vec2 bisector = vec2(c * tangent.x - s * tangent.y, s * tangent.x + c * tangent.y);
float radius = width * 0.5 * s;
return dot(startToPoint, bisector * direction) - radius;
}
float miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
if (cos(joinAngle) > ${ah}) { // avoid risking a division by zero
return bevelJoinField(point, start, end, width, joinAngle);
}
float miterLength = 1. / sin(joinAngle * 0.5);
float miterLimit = ${this.strokeMiterLimitExpression_};
if (miterLength > miterLimit) {
return bevelJoinField(point, start, end, width, joinAngle);
}
return -1000.;
}
float capDistanceField(vec2 point, vec2 start, vec2 end, float width, float capType) {
if (capType == ${Oe("butt")}) {
return buttCapDistanceField(point, start, end);
} else if (capType == ${Oe("square")}) {
return squareCapDistanceField(point, start, end, width);
}
return roundCapDistanceField(point, start, end, width);
}
float joinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float joinType) {
if (joinType == ${Oe("bevel")}) {
return bevelJoinField(point, start, end, width, joinAngle);
} else if (joinType == ${Oe("miter")}) {
return miterJoinDistanceField(point, start, end, width, joinAngle);
}
return roundJoinDistanceField(point, start, end, width);
}
float computeSegmentPointDistance(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float capType, float joinType) {
if (isCap(joinAngle)) {
return capDistanceField(point, start, end, width, capType);
}
return joinDistanceField(point, start, end, width, joinAngle, joinType);
}
float distanceFromSegment(vec2 point, vec2 start, vec2 end) {
vec2 tangent = end - start;
vec2 startToPoint = point - start;
// inspire by capsule fn in https://iquilezles.org/articles/distfunctions/
float h = clamp(dot(startToPoint, tangent) / dot(tangent, tangent), 0.0, 1.0);
return length(startToPoint - tangent * h);
}
void main(void) {
${this.attributes_.map(t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`).join(`
`)}
vec2 currentPointPx = gl_FragCoord.xy / u_pixelRatio;
#ifdef GL_FRAGMENT_PRECISION_HIGH
vec2 worldPos = pxToWorld(currentPointPx);
if (
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
worldPos[0] < u_renderExtent[0] ||
worldPos[1] < u_renderExtent[1] ||
worldPos[0] > u_renderExtent[2] ||
worldPos[1] > u_renderExtent[3]
)
) {
discard;
}
#endif
float segmentLengthPx = length(v_segmentEndPx - v_segmentStartPx);
segmentLengthPx = max(segmentLengthPx, 1.17549429e-38); // avoid divide by zero
vec2 segmentTangent = (v_segmentEndPx - v_segmentStartPx) / segmentLengthPx;
vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);
vec2 startToPointPx = currentPointPx - v_segmentStartPx;
float lengthToPointPx = max(0., min(dot(segmentTangent, startToPointPx), segmentLengthPx));
float currentLengthPx = lengthToPointPx + v_distancePx;
float currentRadiusPx = distanceFromSegment(currentPointPx, v_segmentStartPx, v_segmentEndPx);
float currentRadiusRatio = dot(segmentNormal, startToPointPx) * 2. / v_width;
currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPointPx / segmentLengthPx);
if (${this.discardExpression_}) { discard; }
float capType = ${this.strokeCapExpression_};
float joinType = ${this.strokeJoinExpression_};
float segmentStartDistance = computeSegmentPointDistance(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width, v_angleStart, capType, joinType);
float segmentEndDistance = computeSegmentPointDistance(currentPointPx, v_segmentEndPx, v_segmentStartPx, v_width, v_angleEnd, capType, joinType);
float distanceField = max(
segmentDistanceField(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width),
max(segmentStartDistance, segmentEndDistance)
);
distanceField = max(distanceField, ${this.strokeDistanceFieldExpression_});
vec4 color = ${this.strokeColorExpression_};
color.a *= smoothstep(0.5, -0.5, distanceField);
gl_FragColor = color;
gl_FragColor.a *= u_globalAlpha;
gl_FragColor.rgb *= gl_FragColor.a;
if (u_hitDetection > 0) {
if (gl_FragColor.a < 0.1) { discard; };
gl_FragColor = v_hitColor;
}
}`:null}getFillVertexShader(){return this.hasFill_?`${$i}
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
`)}
attribute vec2 a_position;
attribute vec2 a_hitColor;
varying vec4 v_hitColor;
${this.attributes_.map(t=>`attribute ${t.type} ${t.name};
varying ${t.varyingType} ${t.varyingName};`).join(`
`)}
${this.vertexShaderFunctions_.join(`
`)}
void main(void) {
gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);
v_hitColor = unpackColor(a_hitColor);
${this.attributes_.map(t=>` ${t.varyingName} = ${t.varyingExpression};`).join(`
`)}
}`:null}getFillFragmentShader(){return this.hasFill_?`${$i}
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
`)}
varying vec4 v_hitColor;
${this.attributes_.map(t=>`varying ${t.varyingType} ${t.varyingName};`).join(`
`)}
${this.fragmentShaderFunctions_.join(`
`)}
vec2 pxToWorld(vec2 pxPos) {
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
}
vec2 worldToPx(vec2 worldPos) {
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
}
void main(void) {
${this.attributes_.map(t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`).join(`
`)}
vec2 pxPos = gl_FragCoord.xy / u_pixelRatio;
vec2 pxOrigin = worldToPx(u_patternOrigin);
#ifdef GL_FRAGMENT_PRECISION_HIGH
vec2 worldPos = pxToWorld(pxPos);
if (
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
worldPos[0] < u_renderExtent[0] ||
worldPos[1] < u_renderExtent[1] ||
worldPos[0] > u_renderExtent[2] ||
worldPos[1] > u_renderExtent[3]
)
) {
discard;
}
#endif
if (${this.discardExpression_}) { discard; }
gl_FragColor = ${this.fillColorExpression_};
gl_FragColor.a *= u_globalAlpha;
gl_FragColor.rgb *= gl_FragColor.a;
if (u_hitDetection > 0) {
if (gl_FragColor.a < 0.1) { discard; };
gl_FragColor = v_hitColor;
}
}`:null}}class or{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(t,e){for(let i=0;i<t.length;i++)this.addFeature(t[i],e)}addFeature(t,e){let i=t.getGeometry();i&&(e&&(i=i.clone(),i.applyTransform(e)),this.addGeometry_(i,t))}clearFeatureEntryInPointBatch_(t){const e=k(t),i=this.pointBatch.entries[e];if(i)return this.pointBatch.geometriesCount-=i.flatCoordss.length,delete this.pointBatch.entries[e],i}clearFeatureEntryInLineStringBatch_(t){const e=k(t),i=this.lineStringBatch.entries[e];if(i)return this.lineStringBatch.verticesCount-=i.verticesCount,this.lineStringBatch.geometriesCount-=i.flatCoordss.length,delete this.lineStringBatch.entries[e],i}clearFeatureEntryInPolygonBatch_(t){const e=k(t),i=this.polygonBatch.entries[e];if(i)return this.polygonBatch.verticesCount-=i.verticesCount,this.polygonBatch.ringsCount-=i.ringsCount,this.polygonBatch.geometriesCount-=i.flatCoordss.length,delete this.polygonBatch.entries[e],i}addGeometry_(t,e){const i=t.getType();switch(i){case"GeometryCollection":{const n=t.getGeometriesArray();for(const r of n)this.addGeometry_(r,e);break}case"MultiPolygon":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEndss(),e,k(e),n.getStride());break}case"MultiLineString":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),e,k(e),n.getStride());break}case"MultiPoint":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),null,e,k(e),n.getStride());break}case"Polygon":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),e,k(e),n.getStride());break}case"Point":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),null,e,k(e),n.getStride());break}case"LineString":case"LinearRing":{const n=t,r=n.getStride();this.addCoordinates_(i,n.getFlatCoordinates(),null,e,k(e),r,n.getLayout?.());break}}}addCoordinates_(t,e,i,n,r,o,a){let l;switch(t){case"MultiPolygon":{const h=i;for(let c=0,u=h.length;c<u;c++){let d=h[c];const f=c>0?h[c-1]:null,g=f?f[f.length-1]:0,m=d[d.length-1];d=g>0?d.map(_=>_-g):d,this.addCoordinates_("Polygon",e.slice(g,m),d,n,r,o,a)}break}case"MultiLineString":{const h=i;for(let c=0,u=h.length;c<u;c++){const d=c>0?h[c-1]:0;this.addCoordinates_("LineString",e.slice(d,h[c]),null,n,r,o,a)}break}case"MultiPoint":for(let h=0,c=e.length;h<c;h+=o)this.addCoordinates_("Point",e.slice(h,h+2),null,n,r,null,null);break;case"Polygon":{const h=i;if(n instanceof Dt){const d=Xh(e,h);if(d.length>1){this.addCoordinates_("MultiPolygon",e,d,n,r,o,a);return}}this.polygonBatch.entries[r]||(this.polygonBatch.entries[r]=this.addRefToEntry_(r,{feature:n,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]})),l=e.length/o;const 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[r].flatCoordss.push(Ym(e,o)),this.polygonBatch.entries[r].ringsVerticesCounts.push(u),this.polygonBatch.entries[r].verticesCount+=l,this.polygonBatch.entries[r].ringsCount+=c;for(let d=0,f=h.length;d<f;d++){const g=d>0?h[d-1]:0;this.addCoordinates_("LinearRing",e.slice(g,h[d]),null,n,r,o,a)}break}case"Point":this.pointBatch.entries[r]||(this.pointBatch.entries[r]=this.addRefToEntry_(r,{feature:n,flatCoordss:[]})),this.pointBatch.geometriesCount++,this.pointBatch.entries[r].flatCoordss.push(e);break;case"LineString":case"LinearRing":this.lineStringBatch.entries[r]||(this.lineStringBatch.entries[r]=this.addRefToEntry_(r,{feature:n,flatCoordss:[],verticesCount:0})),l=e.length/o,this.lineStringBatch.verticesCount+=l,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[r].flatCoordss.push(Vm(e,o,a)),this.lineStringBatch.entries[r].verticesCount+=l;break}}addRefToEntry_(t,e){const i=this.uidToRef_.get(t),n=i||this.freeGlobalRef_.pop()||++this.globalCounter_;return e.ref=n,i||(this.refToFeature_.set(n,e.feature),this.uidToRef_.set(t,n)),e}removeRef_(t,e){if(!t)throw new Error("This feature has no ref: "+e);this.refToFeature_.delete(t),this.uidToRef_.delete(e),this.freeGlobalRef_.push(t)}changeFeature(t,e){if(!this.uidToRef_.get(k(t)))return;this.removeFeature(t);let i=t.getGeometry();i&&(e&&(i=i.clone(),i.applyTransform(e)),this.addGeometry_(i,t))}removeFeature(t){let e=this.clearFeatureEntryInPointBatch_(t);e=this.clearFeatureEntryInPolygonBatch_(t)||e,e=this.clearFeatureEntryInLineStringBatch_(t)||e,e&&this.removeRef_(e.ref,k(e.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(t){return this.refToFeature_.get(t)}isEmpty(){return this.globalCounter_===0}filter(t){const e=new or;e.globalCounter_=this.globalCounter_,e.uidToRef_=this.uidToRef_,e.refToFeature_=this.refToFeature_;let i=!0;for(const n of this.refToFeature_.values())t(n)&&(e.addFeature(n),i=!1);return i?new or:e}}function Ym(s,t){return t===2?s:s.filter((e,i)=>i%t<2)}function Vm(s,t,e){return t===3&&e==="XYM"?s:t===4?s.filter((i,n)=>n%t!==2):t===3?s.map((i,n)=>n%t!==2?i:0):new Array(s.length*1.5).fill(0).map((i,n)=>n%3===2?0:s[Math.round(n/1.5)])}function Zm(){const s='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){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 I(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 z=[],B={vertexAttributesPosition:0,instanceAttributesPosition:0,indicesPosition:0};function P(t,e,n,r,x){const o=t[e++],i=t[e++],f=z;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),B.instanceAttributesPosition=u,B}function N(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=E(f,[...l]),p=E(f,[...c]);function v(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}let b=-1,M=-1,m=s;const A=null!==x;if(null!==r){b=v(h,p,E(f,[...[t[r],t[r+1]]])),Math.cos(b)<=.985&&(m+=Math.tan((b-Math.PI)/2))}if(A){M=v(p,h,E(f,[...[t[x],t[x+1]]])),Math.cos(M)<=.985&&(m+=Math.tan((Math.PI-M)/2))}const g=Math.pow(2,24),Z=u%g,d=Math.floor(u/g)*g;return o.push(l[0],l[1],a,c[0],c[1],y,b,M,Z,d,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 R(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 S="GENERATE_POLYGON_BUFFERS",T="GENERATE_POINT_BUFFERS",_="GENERATE_LINE_STRING_BUFFERS",O=self;O.onmessage=t=>{const e=t.data;switch(e.type){case T:{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=P(o,t,s,r,l);const c=Object.assign({indicesBuffer:f.buffer,vertexAttributesBuffer:u.buffer,instanceAttributesBuffer:s.buffer,renderInstructions:o.buffer},e);O.postMessage(c,[u.buffer,s.buffer,f.buffer,o.buffer]);break}case _:{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(I(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=N(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);O.postMessage(a,[l.buffer,c.buffer,s.buffer,x.buffer]);break}case S:{const t=[],n=[],r=e.customAttributesSize,x=new Float32Array(e.renderInstructions);let o=0;for(;o<x.length;)o=R(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);O.postMessage(s,[f.buffer,u.buffer,i.buffer,x.buffer]);break}}};';return new Worker(typeof Blob>"u"?"data:application/javascript;base64,"+Buffer.from(s,"binary").toString("base64"):URL.createObjectURL(new Blob([s],{type:"application/javascript"})))}const _o={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function Km(s,t){t=t||[];const e=256,i=e-1,n=Math.floor(s/e/e/e)/i,r=Math.floor(s/e/e)%e/i,o=Math.floor(s/e)%e/i,a=s%e/i;return t[0]=n*256*255+r*255,t[1]=o*256*255+a*255,t}function Hm(s){let t=0;const e=256,i=e-1;return t+=Math.round(s[0]*e*e*e*i),t+=Math.round(s[1]*e*e*i),t+=Math.round(s[2]*e*i),t+=Math.round(s[3]*i),t}function Va(s,t,e,i){let n=0;for(const r in t){const o=t[r],a=o.callback.call(e,e.feature);let l=a?.[0]??a;l===Xo&&console.warn('The "has" operator might return false positives.'),l===void 0?l=Xo:l===null&&(l=0),s[i+n++]=l,!(!o.size||o.size===1)&&(s[i+n++]=a[1],!(o.size<3)&&(s[i+n++]=a[2],!(o.size<4)&&(s[i+n++]=a[3])))}return n}function Ir(s){return Object.keys(s).reduce((t,e)=>t+(s[e].size||1),0)}function qm(s,t,e,i){const n=(2+Ir(e))*s.geometriesCount;(!t||t.length!==n)&&(t=new Float32Array(n));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++)r[0]=l.flatCoordss[h][0],r[1]=l.flatCoordss[h][1],ct(i,r),t[o++]=r[0],t[o++]=r[1],o+=Va(t,e,l,o)}return t}function Jm(s,t,e,i){const n=3*s.verticesCount+(1+Ir(e))*s.geometriesCount;(!t||t.length!==n)&&(t=new Float32Array(n));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Te(l.flatCoordss[h],0,r.length,3,i,r,3),o+=Va(t,e,l,o),t[o++]=r.length/3;for(let u=0,d=r.length;u<d;u+=3)t[o++]=r[u],t[o++]=r[u+1],t[o++]=r[u+2]}}return t}function Qm(s,t,e,i){const n=2*s.verticesCount+(1+Ir(e))*s.geometriesCount+s.ringsCount;(!t||t.length!==n)&&(t=new Float32Array(n));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Te(l.flatCoordss[h],0,r.length,2,i,r),o+=Va(t,e,l,o),t[o++]=l.ringsVerticesCounts[h].length;for(let u=0,d=l.ringsVerticesCounts[h].length;u<d;u++)t[o++]=l.ringsVerticesCounts[h][u];for(let u=0,d=r.length;u<d;u+=2)t[o++]=r[u],t[o++]=r[u+1]}}return t}function ar(s){return(JSON.stringify(s).split("").reduce((e,i)=>(e<<5)-e+i.charCodeAt(0),0)>>>0).toString()}function Za(s,t,e,i){if(`${i}radius`in s&&i!=="icon-"){let n=U(e,s[`${i}radius`],O);if(`${i}radius2`in s){const r=U(e,s[`${i}radius2`],O);n=`max(${n}, ${r})`}`${i}stroke-width`in s&&(n=`(${n} + ${U(e,s[`${i}stroke-width`],O)} * 0.5)`),t.setSymbolSizeExpression(`vec2(${n} * 2. + 0.5)`)}if(`${i}scale`in s){const n=U(e,s[`${i}scale`],te);t.setSymbolSizeExpression(`${t.getSymbolSizeExpression()} * ${n}`)}`${i}displacement`in s&&t.setSymbolOffsetExpression(U(e,s[`${i}displacement`],Gt)),`${i}rotation`in s&&t.setSymbolRotationExpression(U(e,s[`${i}rotation`],O)),`${i}rotate-with-view`in s&&t.setSymbolRotateWithView(!!s[`${i}rotate-with-view`])}function jc(s,t,e,i,n){let r="vec4(0.)";if(t!==null&&(r=t),e!==null&&i!==null){const l=`smoothstep(-${i} + 0.63, -${i} - 0.58, ${s})`;r=`mix(${e}, ${r}, ${l})`}const o=`(1.0 - smoothstep(-0.63, 0.58, ${s}))`;let a=`${r} * vec4(1.0, 1.0, 1.0, ${o})`;return n!==null&&(a=`${a} * vec4(1.0, 1.0, 1.0, ${n})`),a}function Ka(s,t,e,i,n){const r=new Image;r.crossOrigin=s[`${i}cross-origin`]===void 0?"anonymous":s[`${i}cross-origin`],H(typeof s[`${i}src`]=="string",`WebGL layers do not support expressions for the ${i}src style property`),r.src=s[`${i}src`],e[`u_texture${n}_size`]=()=>r.complete?[r.width,r.height]:[0,0],t.addUniform(`u_texture${n}_size`,"vec2");const o=`u_texture${n}_size`;return e[`u_texture${n}`]=r,t.addUniform(`u_texture${n}`,"sampler2D"),o}function Ha(s,t,e,i,n){let r=U(e,s[`${t}offset`],te);if(`${t}offset-origin`in s)switch(s[`${t}offset-origin`]){case"top-right":r=`vec2(${i}.x, 0.) + ${n} * vec2(-1., 0.) + ${r} * vec2(-1., 1.)`;break;case"bottom-left":r=`vec2(0., ${i}.y) + ${n} * vec2(0., -1.) + ${r} * vec2(1., -1.)`;break;case"bottom-right":r=`${i} - ${n} - ${r}`;break}return r}function tp(s,t,e,i){i.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) {
return length(point) - radius;
}`,Za(s,t,i,"circle-");let n=null;"circle-opacity"in s&&(n=U(i,s["circle-opacity"],O));let r="coordsPx";"circle-scale"in s&&(r=`coordsPx / ${U(i,s["circle-scale"],te)}`);let o=null;"circle-fill-color"in s&&(o=U(i,s["circle-fill-color"],at));let a=null;"circle-stroke-color"in s&&(a=U(i,s["circle-stroke-color"],at));let l=U(i,s["circle-radius"],O),h=null;"circle-stroke-width"in s&&(h=U(i,s["circle-stroke-width"],O),l=`(${l} + ${h} * 0.5)`);const c=`circleDistanceField(${r}, ${l})`,u=jc(c,o,a,h,n);t.setSymbolColorExpression(u)}function ep(s,t,e,i){i.functions.round=`float round(float v) {
return sign(v) * floor(abs(v) + 0.5);
}`,i.functions.starDistanceField=`float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
float c = cos(startAngle);
float s = sin(startAngle);
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
float alpha = TWO_PI / numPoints; // the angle of one sector
float beta = atan(pointRotated.y, pointRotated.x);
float gamma = round(beta / alpha) * alpha; // angle in sector
c = cos(-gamma);
s = sin(-gamma);
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
vec2 tipToPoint = inSector + vec2(-radius, 0.);
vec2 edgeNormal = vec2(radius2 * sin(alpha * 0.5), -radius2 * cos(alpha * 0.5) + radius);
return dot(normalize(edgeNormal), tipToPoint);
}`,i.functions.regularDistanceField=`float regularDistanceField(vec2 point, float numPoints, float radius, float angle) {
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
float c = cos(startAngle);
float s = sin(startAngle);
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
float alpha = TWO_PI / numPoints; // the angle of one sector
float radiusIn = radius * cos(PI / numPoints);
float beta = atan(pointRotated.y, pointRotated.x);
float gamma = round((beta - alpha * 0.5) / alpha) * alpha + alpha * 0.5; // angle in sector from mid
c = cos(-gamma);
s = sin(-gamma);
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
return inSector.x - radiusIn;
}`,Za(s,t,i,"shape-");let n=null;"shape-opacity"in s&&(n=U(i,s["shape-opacity"],O));let r="coordsPx";"shape-scale"in s&&(r=`coordsPx / ${U(i,s["shape-scale"],te)}`);let o=null;"shape-fill-color"in s&&(o=U(i,s["shape-fill-color"],at));let a=null;"shape-stroke-color"in s&&(a=U(i,s["shape-stroke-color"],at));let l=null;"shape-stroke-width"in s&&(l=U(i,s["shape-stroke-width"],O));const h=U(i,s["shape-points"],O);let c="0.";"shape-angle"in s&&(c=U(i,s["shape-angle"],O));let u,d=U(i,s["shape-radius"],O);if(l!==null&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in s){let g=U(i,s["shape-radius2"],O);l!==null&&(g=`${g} + ${l} * 0.5`),u=`starDistanceField(${r}, ${h}, ${d}, ${g}, ${c})`}else u=`regularDistanceField(${r}, ${h}, ${d}, ${c})`;const f=jc(u,o,a,l,n);t.setSymbolColorExpression(f)}function ip(s,t,e,i){let n="vec4(1.0)";"icon-color"in s&&(n=U(i,s["icon-color"],at)),"icon-opacity"in s&&(n=`${n} * vec4(1.0, 1.0, 1.0, ${U(i,s["icon-opacity"],O)})`);const r=ar(s["icon-src"]),o=Ka(s,t,e,"icon-",r);if(t.setSymbolColorExpression(`${n} * texture2D(u_texture${r}, v_texCoord)`).setSymbolSizeExpression(o),"icon-width"in s&&"icon-height"in s&&t.setSymbolSizeExpression(`vec2(${U(i,s["icon-width"],O)}, ${U(i,s["icon-height"],O)})`),"icon-offset"in s&&"icon-size"in s){const a=U(i,s["icon-size"],Gt),l=t.getSymbolSizeExpression();t.setSymbolSizeExpression(a);const h=Ha(s,"icon-",i,"v_quadSizePx",a);t.setTextureCoordinateExpression(`(vec4((${h}).xyxy) + vec4(0., 0., ${a})) / (${l}).xyxy`)}if(Za(s,t,i,"icon-"),"icon-anchor"in s){const a=U(i,s["icon-anchor"],Gt);let l="1.0";"icon-scale"in s&&(l=U(i,s["icon-scale"],te));let h;s["icon-anchor-x-units"]==="pixels"&&s["icon-anchor-y-units"]==="pixels"?h=`${a} * ${l}`:s["icon-anchor-x-units"]==="pixels"?h=`${a} * vec2(vec2(${l}).x, v_quadSizePx.y)`:s["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 s)switch(s["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}t.setSymbolOffsetExpression(`${t.getSymbolOffsetExpression()} + ${c}`)}}function np(s,t,e,i){if("stroke-color"in s&&t.setStrokeColorExpression(U(i,s["stroke-color"],at)),"stroke-pattern-src"in s){const n=ar(s["stroke-pattern-src"]),r=Ka(s,t,e,"stroke-pattern-",n);let o=r,a="vec2(0.)";"stroke-pattern-offset"in s&&"stroke-pattern-size"in s&&(o=U(i,s["stroke-pattern-size"],Gt),a=Ha(s,"stroke-pattern-",i,r,o));let l="0.";"stroke-pattern-spacing"in s&&(l=U(i,s["stroke-pattern-spacing"],O));let h="0.";"stroke-pattern-start-offset"in s&&(h=U(i,s["stroke-pattern-start-offset"],O)),i.functions.sampleStrokePattern=`vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float startOffsetPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {
float currentLengthScaled = (currentLengthPx - startOffsetPx) * sampleSize.y / lineWidth;
float spacingScaled = spacingPx * sampleSize.y / lineWidth;
float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));
float isInsideOfPattern = step(uCoordPx, sampleSize.x);
float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;
// make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
uCoordPx = clamp(uCoordPx, 0.5, sampleSize.x - 0.5);
vCoordPx = clamp(vCoordPx, 0.5, sampleSize.y - 0.5);
vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;
return texture2D(texture, texCoord) * vec4(1.0, 1.0, 1.0, isInsideOfPattern);
}`;const c=`u_texture${n}`;let u="1.";"stroke-color"in s&&(u=t.getStrokeColorExpression()),t.setStrokeColorExpression(`${u} * sampleStrokePattern(${c}, ${r}, ${a}, ${o}, ${l}, ${h}, currentLengthPx, currentRadiusRatio, v_width)`),i.functions.computeStrokePatternLength=`float computeStrokePatternLength(vec2 sampleSize, float spacingPx, float lineWidth) {
float patternLengthPx = sampleSize.x / sampleSize.y * lineWidth;
return patternLengthPx + spacingPx;
}`,t.setStrokePatternLengthExpression(`computeStrokePatternLength(${o}, ${l}, v_width)`)}if("stroke-width"in s&&t.setStrokeWidthExpression(U(i,s["stroke-width"],O)),"stroke-offset"in s&&t.setStrokeOffsetExpression(U(i,s["stroke-offset"],O)),"stroke-line-cap"in s&&t.setStrokeCapExpression(U(i,s["stroke-line-cap"],yt)),"stroke-line-join"in s&&t.setStrokeJoinExpression(U(i,s["stroke-line-join"],yt)),"stroke-miter-limit"in s&&t.setStrokeMiterLimitExpression(U(i,s["stroke-miter-limit"],O)),"stroke-line-dash"in s){i.functions.getSingleDashDistance=`float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType, float lineWidth) {
float localDistance = mod(distance, dashLengthTotal);
float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;
distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);
if (capType == ${Oe("square")}) {
distanceSegment -= lineWidth * 0.5;
} else if (capType == ${Oe("round")}) {
distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);
}
return distanceSegment;
}`;let n=s["stroke-line-dash"].map(g=>U(i,g,O));n.length%2===1&&(n=[...n,...n]);let r="0.";"stroke-line-dash-offset"in s&&(r=U(i,s["stroke-line-dash-offset"],O));const a=`dashDistanceField_${ar(s["stroke-line-dash"])}`,l=n.map((g,m)=>`float dashLength${m}`).join(", "),h=n.map((g,m)=>`dashLength${m}`).join(" + ");let 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}) {
float totalDashLength = ${h};
return ${u};
}`;const d=n.map((g,m)=>`${g}`).join(", ");t.setStrokeDistanceFieldExpression(`${a}(currentLengthPx + ${r}, currentRadiusPx, capType, v_width, ${d})`);let f=n.join(" + ");t.getStrokePatternLengthExpression()&&(i.functions.combinePatternLengths=`float combinePatternLengths(float patternLength1, float patternLength2) {
return patternLength1 * patternLength2;
}`,f=`combinePatternLengths(${t.getStrokePatternLengthExpression()}, ${f})`),t.setStrokePatternLengthExpression(f)}}function sp(s,t,e,i){if("fill-color"in s&&t.setFillColorExpression(U(i,s["fill-color"],at)),"fill-pattern-src"in s){const n=ar(s["fill-pattern-src"]),r=Ka(s,t,e,"fill-pattern-",n);let o=r,a="vec2(0.)";"fill-pattern-offset"in s&&"fill-pattern-size"in s&&(o=U(i,s["fill-pattern-size"],Gt),a=Ha(s,"fill-pattern-",i,r,o)),i.functions.sampleFillPattern=`vec4 sampleFillPattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, vec2 pxOrigin, vec2 pxPosition) {
float scaleRatio = pow(2., mod(u_zoom + 0.5, 1.) - 0.5);
vec2 pxRelativePos = pxPosition - pxOrigin;
// rotate the relative position from origin by the current view rotation
pxRelativePos = vec2(pxRelativePos.x * cos(u_rotation) - pxRelativePos.y * sin(u_rotation), pxRelativePos.x * sin(u_rotation) + pxRelativePos.y * cos(u_rotation));
// sample position is computed according to the sample offset & size
vec2 samplePos = mod(pxRelativePos / scaleRatio, sampleSize);
// also make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
samplePos = clamp(samplePos, vec2(0.5), sampleSize - vec2(0.5));
samplePos.y = sampleSize.y - samplePos.y; // invert y axis so that images appear upright
return texture2D(texture, (samplePos + textureOffset) / textureSize);
}`;const l=`u_texture${n}`;let h="1.";"fill-color"in s&&(h=t.getFillColorExpression()),t.setFillColorExpression(`${h} * sampleFillPattern(${l}, ${r}, ${a}, ${o}, pxOrigin, pxPos)`)}}function lh(s,t,e){const i=Gc(),n=new Xc,r={};if("icon-src"in s?ip(s,n,r,i):"shape-points"in s?ep(s,n,r,i):"circle-radius"in s&&tp(s,n,r,i),np(s,n,r,i),sp(s,n,r,i),e){const l=U(i,e,gt);n.setFragmentDiscardExpression(`!${l}`)}const o={};function a(l,h,c,u){if(!i[l])return;const d=jo(c),f=Ya(c);n.addAttribute(`a_${h}`,d),o[h]={size:f,callback:u}}return a("geometryType",zc,yt,l=>Vn(Aa(l.getGeometry()))),a("featureId",Bc,yt|O,l=>{const h=l.getId()??null;return typeof h=="string"?Vn(h):h}),Uc(n,i),{builder:n,attributes:{...o,...Wc(i)},uniforms:{...r,...$c(i,t)}}}const rp=[];let mo;function op(){return mo||(mo=Zm()),mo}let ap=0;const Qt={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"};class lp{constructor(t,e,i,n){this.helper_,this.hitDetectionEnabled_=!!n,this.styleShaders=hp(t,e),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return Km(this.ref,rp)},size:2});for(const r of this.styleShaders){for(const o in r.attributes)o in this.customAttributes_||(this.customAttributes_[o]=r.attributes[o]);for(const o in r.uniforms)o in this.uniforms_||(this.uniforms_[o]=r.uniforms[o])}this.renderPasses_=this.styleShaders.map(r=>{const o={},a=Object.entries(this.customAttributes_).map(([l,h])=>({name:l in r.attributes||l==="hitColor"?`a_${l}`:null,size:h.size||1,type:Rt.FLOAT}));return r.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:r.builder.getFillVertexShader(),fragmentShader:r.builder.getFillFragmentShader(),attributesDesc:[{name:Qt.POSITION,size:2,type:Rt.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),r.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:r.builder.getStrokeVertexShader(),fragmentShader:r.builder.getStrokeFragmentShader(),attributesDesc:[{name:Qt.LOCAL_POSITION,size:2,type:Rt.FLOAT}],instancedAttributesDesc:[{name:Qt.SEGMENT_START,size:2,type:Rt.FLOAT},{name:Qt.MEASURE_START,size:1,type:Rt.FLOAT},{name:Qt.SEGMENT_END,size:2,type:Rt.FLOAT},{name:Qt.MEASURE_END,size:1,type:Rt.FLOAT},{name:Qt.JOIN_ANGLES,size:2,type:Rt.FLOAT},{name:Qt.DISTANCE_LOW,size:1,type:Rt.FLOAT},{name:Qt.DISTANCE_HIGH,size:1,type:Rt.FLOAT},{name:Qt.ANGLE_TANGENT_SUM,size:1,type:Rt.FLOAT},...a],instancePrimitiveVertexCount:6}),r.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:r.builder.getSymbolVertexShader(),fragmentShader:r.builder.getSymbolFragmentShader(),attributesDesc:[{name:Qt.LOCAL_POSITION,size:2,type:Rt.FLOAT}],instancedAttributesDesc:[{name:Qt.POSITION,size:2,type:Rt.FLOAT},...a],instancePrimitiveVertexCount:6}),o}),this.hasFill_=this.renderPasses_.some(r=>r.fillRenderPass),this.hasStroke_=this.renderPasses_.some(r=>r.strokeRenderPass),this.hasSymbol_=this.renderPasses_.some(r=>r.symbolRenderPass),this.setHelper(i)}async generateBuffers(t,e){if(t.isEmpty())return null;const i=this.generateRenderInstructions_(t,e),[n,r,o]=await Promise.all([this.generateBuffersForType_(i.polygonInstructions,"Polygon",e),this.generateBuffersForType_(i.lineStringInstructions,"LineString",e),this.generateBuffersForType_(i.pointInstructions,"Point",e)]),a=Nn(_t(),e);return{polygonBuffers:n,lineStringBuffers:r,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(t,e){const i=this.hasFill_?Qm(t.polygonBatch,new Float32Array(0),this.customAttributes_,e):null,n=this.hasStroke_?Jm(t.lineStringBatch,new Float32Array(0),this.customAttributes_,e):null,r=this.hasSymbol_?qm(t.pointBatch,new Float32Array(0),this.customAttributes_,e):null;return{polygonInstructions:i,lineStringInstructions:n,pointInstructions:r}}generateBuffersForType_(t,e,i){if(t===null)return null;const n=ap++;let r;switch(e){case"Polygon":r=_o.GENERATE_POLYGON_BUFFERS;break;case"LineString":r=_o.GENERATE_LINE_STRING_BUFFERS;break;case"Point":r=_o.GENERATE_POINT_BUFFERS;break}const o={id:n,type:r,renderInstructions:t.buffer,renderInstructionsTransform:i,customAttributesSize:Ir(this.customAttributes_)},a=op();return a.postMessage(o,[t.buffer]),t=null,new Promise(l=>{const h=c=>{const u=c.data;if(u.id!==n||(a.removeEventListener("message",h),!this.helper_.getGL()))return;const d=new co(Ua,ho).fromArrayBuffer(u.indicesBuffer),f=new co(sr,ho).fromArrayBuffer(u.vertexAttributesBuffer),g=new co(sr,ho).fromArrayBuffer(u.instanceAttributesBuffer);this.helper_.flushBufferData(d),this.helper_.flushBufferData(f),this.helper_.flushBufferData(g),l([d,f,g])};a.addEventListener("message",h)})}render(t,e,i){for(const n of this.renderPasses_)n.fillRenderPass&&this.renderInternal_(t.polygonBuffers[0],t.polygonBuffers[1],t.polygonBuffers[2],n.fillRenderPass,e,i),n.strokeRenderPass&&this.renderInternal_(t.lineStringBuffers[0],t.lineStringBuffers[1],t.lineStringBuffers[2],n.strokeRenderPass,e,i),n.symbolRenderPass&&this.renderInternal_(t.pointBuffers[0],t.pointBuffers[1],t.pointBuffers[2],n.symbolRenderPass,e,i)}renderInternal_(t,e,i,n,r,o){const a=t.getSize();if(a===0)return;const l=n.instancedAttributesDesc.length;if(this.helper_.useProgram(n.program,r),this.helper_.bindBuffer(e),this.helper_.bindBuffer(t),this.helper_.enableAttributes(n.attributesDesc),this.helper_.bindBuffer(i),this.helper_.enableAttributesInstanced(n.instancedAttributesDesc),o(),l){const 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(t,e=null){this.helper_=t;for(const 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_),e&&(e.polygonBuffers&&(this.helper_.flushBufferData(e.polygonBuffers[0]),this.helper_.flushBufferData(e.polygonBuffers[1]),this.helper_.flushBufferData(e.polygonBuffers[2])),e.lineStringBuffers&&(this.helper_.flushBufferData(e.lineStringBuffers[0]),this.helper_.flushBufferData(e.lineStringBuffers[1]),this.helper_.flushBufferData(e.lineStringBuffers[2])),e.pointBuffers&&(this.helper_.flushBufferData(e.pointBuffers[0]),this.helper_.flushBufferData(e.pointBuffers[1]),this.helper_.flushBufferData(e.pointBuffers[2])))}}function hp(s,t){const e=Array.isArray(s)?s:[s];if("style"in e[0]){const i=[],n=e,r=[];for(const o of n){const a=Array.isArray(o.style)?o.style:[o.style];let l=o.filter;o.else&&r.length&&(l=["all",...r.map(c=>["!",c])],o.filter&&l.push(o.filter),l.length<3&&(l=l[1])),o.filter&&r.push(o.filter);const h=a.map(c=>lh(c,t,l));i.push(...h)}return i}return"builder"in e[0]?e:e.map(i=>lh(i,t,null))}const me=new Uint8Array(4);class cp{constructor(t,e){this.helper_=t;const i=t.getGL();this.texture_=i.createTexture(),this.framebuffer_=i.createFramebuffer(),this.depthbuffer_=i.createRenderbuffer(),this.size_=e||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(t){ze(t,this.size_)||(this.size_[0]=t[0],this.size_[1]=t[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){const t=this.size_,e=this.helper_.getGL();e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.readPixels(0,0,t[0],t[1],e.RGBA,e.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(t,e){if(t<0||e<0||t>this.size_[0]||e>=this.size_[1])return me[0]=0,me[1]=0,me[2]=0,me[3]=0,me;this.readAll();const i=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return me[0]=this.data_[i*4],me[1]=this.data_[i*4+1],me[2]=this.data_[i*4+2],me[3]=this.data_[i*4+3],me}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){const t=this.size_,e=this.helper_.getGL();this.texture_=this.helper_.createTexture(t,null,this.texture_),e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.viewport(0,0,t[0],t[1]),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture_,0),e.bindRenderbuffer(e.RENDERBUFFER,this.depthbuffer_),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,t[0],t[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(t[0]*t[1]*4)}}function up(s,t){const e=s.viewState.projection,n=t.getSource().getWrapX()&&e.canWrapX(),r=e.getExtent(),o=s.extent,a=n?it(r):null,l=n?Math.ceil((o[2]-r[2])/a)+1:1;return[n?Math.floor((o[0]-r[0])/a):0,l,a]}const Xi={...Le,RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",GLOBAL_ALPHA:"u_globalAlpha"};class dp extends $a{constructor(t,e){const i={[Xi.RENDER_EXTENT]:[0,0,0,0],[Xi.PATTERN_ORIGIN]:[0,0],[Xi.GLOBAL_ALPHA]:1};super(t,{uniforms:i,postProcesses:e.postProcesses}),this.hitDetectionEnabled_=!e.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=Vt(),this.currentTransform_=_t(),this.tmpCoords_=[0,0],this.tmpTransform_=_t(),this.tmpMat4_=Dc(),this.currentFrameStateTransform_=_t(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(e),this.batch_=new or,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(t){const e=this.getLayer().getSource();let i;this.batch_.addFeatures(e.getFeatures(),i),this.sourceListenKeys_=[Z(e,At.ADDFEATURE,this.handleSourceFeatureAdded_.bind(this,i)),Z(e,At.CHANGEFEATURE,this.handleSourceFeatureChanged_.bind(this,i),this),Z(e,At.REMOVEFEATURE,this.handleSourceFeatureDelete_,this),Z(e,At.CLEAR,this.handleSourceFeatureClear_,this)]}applyOptions_(t){this.styleVariables_=t.variables,this.style_=t.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new lp(this.style_,this.styleVariables_,this.helper,this.hitDetectionEnabled_)}reset(t){this.applyOptions_(t),this.helper&&this.createRenderers_(),super.reset(t)}afterHelperCreated(){this.styleRenderer_?this.styleRenderer_.setHelper(this.helper,this.buffers_):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new cp(this.helper))}handleSourceFeatureAdded_(t,e){const i=e.feature;this.batch_.addFeature(i,t)}handleSourceFeatureChanged_(t,e){const i=e.feature;this.batch_.changeFeature(i,t)}handleSourceFeatureDelete_(t){const e=t.feature;this.batch_.removeFeature(e)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(t){bh(this.tmpTransform_,this.currentFrameStateTransform_),mr(this.tmpTransform_,t),this.helper.setUniformMatrixValue(Xi.PROJECTION_MATRIX,Wo(this.tmpMat4_,this.tmpTransform_)),Nn(this.tmpTransform_,this.tmpTransform_),this.helper.setUniformMatrixValue(Xi.SCREEN_TO_WORLD_MATRIX,Wo(this.tmpMat4_,this.tmpTransform_)),this.tmpCoords_[0]=0,this.tmpCoords_[1]=0,Nn(this.tmpTransform_,t),ct(this.tmpTransform_,this.tmpCoords_),this.helper.setUniformFloatVec2(Xi.PATTERN_ORIGIN,this.tmpCoords_)}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[i,n,r]=up(t,this.getLayer());this.helper.prepareDraw(t),this.renderWorlds(t,!1,i,n,r),this.helper.finalizeDraw(t,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const o=this.helper.getCanvas();return this.hitDetectionEnabled_&&(this.renderWorlds(t,!0,i,n,r),this.hitRenderTarget_.clearCachedData()),this.postRender(e,t),o}prepareFrameInternal(t){this.initialFeaturesAdded_||(this.addInitialFeatures_(t),this.initialFeaturesAdded_=!0);const e=this.getLayer(),i=e.getSource(),n=t.viewState,r=!t.viewHints[rt.ANIMATING]&&!t.viewHints[rt.INTERACTING],o=!vi(this.previousExtent_,t.extent),a=this.sourceRevision_<i.getRevision();if(a&&(this.sourceRevision_=i.getRevision()),r&&(o||a)){const l=n.projection,h=n.resolution,c=e instanceof ss?e.getRenderBuffer():0,u=sn(t.extent,c*h);i.loadFeatures(u,h,l),this.ready=!1;const d=this.helper.makeProjectionTransform(t,_t());this.styleRenderer_.generateBuffers(this.batch_,d).then(f=>{this.buffers_&&this.disposeBuffers(this.buffers_),this.buffers_=f,this.ready=!0,this.getLayer().changed()}),this.previousExtent_=t.extent.slice()}return!0}renderWorlds(t,e,i,n,r){let o=i;e&&(this.hitRenderTarget_.setSize([Math.floor(t.size[0]/2),Math.floor(t.size[1]/2)]),this.helper.prepareDrawToRenderTarget(t,this.hitRenderTarget_,!0));do this.helper.makeProjectionTransform(t,this.currentFrameStateTransform_),Fh(this.currentFrameStateTransform_,o*r,0),this.buffers_&&this.styleRenderer_.render(this.buffers_,t,()=>{this.applyUniforms_(this.buffers_.invertVerticesTransform),this.helper.applyHitDetectionUniform(e)});while(++o<n)}forEachFeatureAtCoordinate(t,e,i,n,r){if(H(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;const o=ct(e.coordinateToPixelTransform,t.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=Hm(l),c=this.batch_.getFeatureFromRef(h);if(c)return n(c,this.getLayer(),null)}disposeBuffers(t){const e=i=>{for(const n of i)n&&this.helper.deleteBuffer(n)};t.pointBuffers&&e(t.pointBuffers),t.lineStringBuffers&&e(t.lineStringBuffers),t.polygonBuffers&&e(t.polygonBuffers)}disposeInternal(){this.buffers_&&this.disposeBuffers(this.buffers_),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach(function(t){st(t)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const Ae={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},fp=["#00f","#0ff","#0f0","#ff0","#f00"];class Hp extends ss{constructor(t){t=t||{};const e=Object.assign({},t);delete e.gradient,delete e.radius,delete e.blur,delete e.weight,super(e),this.filter_=t.filter??!0,this.styleVariables_=t.variables||{},this.gradient_=null,this.addChangeListener(Ae.GRADIENT,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:fp),this.setBlur(t.blur!==void 0?t.blur:15),this.setRadius(t.radius!==void 0?t.radius:8);const i=t.weight?t.weight:"weight";this.weight_=i,this.setRenderOrder(null)}getBlur(){return this.get(Ae.BLUR)}getGradient(){return this.get(Ae.GRADIENT)}getRadius(){return this.get(Ae.RADIUS)}handleGradientChanged_(){this.gradient_=gp(this.getGradient())}setBlur(t){const e=this.get(Ae.BLUR);if(this.set(Ae.BLUR,t),typeof t=="number"&&typeof e=="number"){this.changed();return}this.clearRenderer()}setGradient(t){this.set(Ae.GRADIENT,t)}setRadius(t){const e=this.get(Ae.RADIUS);if(this.set(Ae.RADIUS,t),typeof t=="number"&&typeof e=="number"){this.changed();return}this.clearRenderer()}setFilter(t){this.filter_=t,this.changed(),this.clearRenderer()}setWeight(t){this.weight_=t,this.changed(),this.clearRenderer()}createRenderer(){const t=new Xc,e=Gc(),i=U(e,this.filter_,gt);let n=U(e,this.getRadius(),O),r=U(e,this.getBlur(),O);const o={};typeof this.getBlur()=="number"&&(r="a_blur",o.a_blur=()=>this.getBlur(),t.addUniform("a_blur","float")),typeof this.getRadius()=="number"&&(n="a_radius",o.a_radius=()=>this.getRadius(),t.addUniform("a_radius","float"));const a={};let l=null;if(typeof this.weight_=="string"||typeof this.weight_=="function"){const u=typeof this.weight_=="string"?d=>d.get(this.weight_):this.weight_;a.prop_weight={size:1,callback:d=>{const f=u(d);return f!==void 0?ot(f,0,1):1}},l="a_prop_weight",t.addAttribute("a_prop_weight","float")}else{const u=["clamp",this.weight_,0,1];l=U(e,u,O)}t.addFragmentShaderFunction(`float getBlurSlope() {
float blur = max(1., ${r});
float radius = ${n};
return radius / blur;
}`).setSymbolSizeExpression(`vec2(${n} + ${r}) * 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} + ${r}) * 2.`).setFillColorExpression(`vec4(${l})`).setFragmentDiscardExpression(`!${i}`),Uc(t,e);const h=Wc(e),c=$c(e,this.styleVariables_);return new dp(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:t,attributes:{...h,...a},uniforms:{...c,...o}},disableHitDetection:!1,postProcesses:[{fragmentShader:`
precision mediump float;
uniform sampler2D u_image;
uniform sampler2D u_gradientTexture;
uniform float u_opacity;
varying vec2 v_texCoord;
void main() {
vec4 color = texture2D(u_image, v_texCoord);
gl_FragColor.a = color.a * u_opacity;
gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;
gl_FragColor.rgb *= gl_FragColor.a;
}`,uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}renderDeclutter(){}}function gp(s){const i=mt(1,256),n=i.createLinearGradient(0,0,1,256),r=1/(s.length-1);for(let o=0,a=s.length;o<a;++o)n.addColorStop(o*r,s[o]);return i.fillStyle=n,i.fillRect(0,0,1,256),i.canvas}const ht={ACCURACY:"accuracy",ACCURACY_GEOMETRY:"accuracyGeometry",ALTITUDE:"altitude",ALTITUDE_ACCURACY:"altitudeAccuracy",HEADING:"heading",POSITION:"position",PROJECTION:"projection",SPEED:"speed",TRACKING:"tracking",TRACKING_OPTIONS:"trackingOptions"},_p={ERROR:"error"};class mp extends se{constructor(t){super(_p.ERROR),this.code=t.code,this.message=t.message}}class qp extends re{constructor(t){super(),this.on,this.once,this.un,t=t||{},this.position_=null,this.transform_=cd,this.watchId_=void 0,this.addChangeListener(ht.PROJECTION,this.handleProjectionChanged_),this.addChangeListener(ht.TRACKING,this.handleTrackingChanged_),t.projection!==void 0&&this.setProjection(t.projection),t.trackingOptions!==void 0&&this.setTrackingOptions(t.trackingOptions),this.setTracking(t.tracking!==void 0?t.tracking:!1)}disposeInternal(){this.setTracking(!1),super.disposeInternal()}handleProjectionChanged_(){const t=this.getProjection();t&&(this.transform_=Jn(lt("EPSG:4326"),t),this.position_&&this.set(ht.POSITION,this.transform_(this.position_)))}handleTrackingChanged_(){if("geolocation"in navigator){const t=this.getTracking();t&&this.watchId_===void 0?this.watchId_=navigator.geolocation.watchPosition(this.positionChange_.bind(this),this.positionError_.bind(this),this.getTrackingOptions()):!t&&this.watchId_!==void 0&&(navigator.geolocation.clearWatch(this.watchId_),this.watchId_=void 0)}}positionChange_(t){const e=t.coords;this.set(ht.ACCURACY,e.accuracy),this.set(ht.ALTITUDE,e.altitude===null?void 0:e.altitude),this.set(ht.ALTITUDE_ACCURACY,e.altitudeAccuracy===null?void 0:e.altitudeAccuracy),this.set(ht.HEADING,e.heading===null?void 0:Nt(e.heading)),this.position_?(this.position_[0]=e.longitude,this.position_[1]=e.latitude):this.position_=[e.longitude,e.latitude];const i=this.transform_(this.position_);this.set(ht.POSITION,i.slice()),this.set(ht.SPEED,e.speed===null?void 0:e.speed);const n=kd(this.position_,e.accuracy);n.applyTransform(this.transform_),this.set(ht.ACCURACY_GEOMETRY,n),this.changed()}positionError_(t){this.dispatchEvent(new mp(t))}getAccuracy(){return this.get(ht.ACCURACY)}getAccuracyGeometry(){return this.get(ht.ACCURACY_GEOMETRY)||null}getAltitude(){return this.get(ht.ALTITUDE)}getAltitudeAccuracy(){return this.get(ht.ALTITUDE_ACCURACY)}getHeading(){return this.get(ht.HEADING)}getPosition(){return this.get(ht.POSITION)}getProjection(){return this.get(ht.PROJECTION)}getSpeed(){return this.get(ht.SPEED)}getTracking(){return this.get(ht.TRACKING)}getTrackingOptions(){return this.get(ht.TRACKING_OPTIONS)}setProjection(t){this.set(ht.PROJECTION,lt(t))}setTracking(t){this.set(ht.TRACKING,t)}setTrackingOptions(t){this.set(ht.TRACKING_OPTIONS,t)}}function qi(s,t){const e=s.length;return t<0?s[t+e]:t>=e?s[t-e]:s[t]}function Ji(s,t){const e=s.length;let i=Math.floor(t);const n=t-i;i>=e?i-=e:i<0&&(i+=e);let r=i+1;r>=e&&(r-=e);const o=s[i],a=o[0],l=o[1],h=s[r],c=h[0]-a,u=h[1]-l;return[a+c*n,l+u*n]}const Rs={index:-1,endIndex:NaN,closestTargetDistance:1/0};function pp(s,t,e,i){const n=s[0],r=s[1];let o=1/0,a=-1,l=NaN;for(let u=0;u<t.targets.length;++u){const d=t.targets[u],f=d.coordinates;let g=1/0,m;for(let _=0;_<f.length-1;++_){const p=f[_],y=f[_+1],T=Vc(n,r,p,y);T.squaredDistance<g&&(g=T.squaredDistance,m=_+T.along)}g<o&&(o=g,d.ring&&t.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)}const h=t.targets[a];let c=h.ring;if(t.targetIndex===a&&c){const u=Ji(h.coordinates,l),d=e.getPixelFromCoordinate(u),f=e.getPixelFromCoordinate(t.startCoord);Th(d,f)>i&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(f<g){const m=Ps(u,f,g);Ps(u,f,g-d)<m&&(l-=d)}else{const m=Ps(u,f,g);Ps(u,f,g+d)<m&&(l+=d)}}return Rs.index=a,Rs.endIndex=l,Rs.closestTargetDistance=o,Rs}function yp(s,t){const e=[];for(let i=0;i<t.length;++i){const r=t[i].getGeometry();Yc(s,r,e)}return e}function Yc(s,t,e){if(t instanceof ce){Ss(s,t.getCoordinates(),!1,e);return}if(t instanceof Si){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n)Ss(s,i[n],!1,e);return}if(t instanceof Zt){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n)Ss(s,i[n],!0,e);return}if(t instanceof wi){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n){const o=i[n];for(let a=0,l=o.length;a<l;++a)Ss(s,o[a],!0,e)}return}if(t instanceof si){const i=t.getGeometries();for(let n=0;n<i.length;++n)Yc(s,i[n],e);return}}function Ss(s,t,e,i){const n=s[0],r=s[1];for(let o=0,a=t.length-1;o<a;++o){const l=t[o],h=t[o+1],c=Vc(n,r,l,h);if(c.squaredDistance===0){const u=o+c.along;i.push({coordinates:t,ring:e,startIndex:u,endIndex:u});return}}}function ws(s,t){return ke(s[0],s[1],t[0],t[1])}function Ps(s,t,e){let i,n;t<e?(i=t,n=e):(i=e,n=t);const r=Math.ceil(i),o=Math.floor(n);if(r>o){const l=Ji(s,i),h=Ji(s,n);return ws(l,h)}let a=0;if(i<r){const l=Ji(s,i),h=qi(s,r);a+=ws(l,h)}if(o<n){const l=qi(s,o),h=Ji(s,n);a+=ws(l,h)}for(let l=r;l<o-1;++l){const h=qi(s,l),c=qi(s,l+1);a+=ws(h,c)}return a}const po={along:0,squaredDistance:0};function Vc(s,t,e,i){const n=e[0],r=e[1],o=i[0],a=i[1],l=o-n,h=a-r;let c=0,u=n,d=r;return(l!==0||h!==0)&&(c=ot(((s-n)*l+(t-r)*h)/(l*l+h*h),0,1),u+=l*c,d+=h*c),po.along=c,po.squaredDistance=Hn(ke(s,t,u,d),10),po}const Is={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class As extends se{constructor(t,e){super(t),this.feature=e}}class Jp extends gn{constructor(t){const e=t;e.stopDown||(e.stopDown=hn),super(e),this.on,this.once,this.un,this.options_=t,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=t.source?t.source:null,this.features_=t.features?t.features:null,this.snapTolerance_=t.snapTolerance?t.snapTolerance:12,this.type_=t.type,this.mode_=Ep(this.type_),this.stopClick_=!!t.stopClick,this.ignoreNextUpEvent_=!1,this.minPoints_=t.minPoints?t.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:t.maxPoints?t.maxPoints:1/0,this.finishCondition_=t.finishCondition?t.finishCondition:ei,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let i=t.geometryFunction;if(!i){const n=this.mode_;if(n==="Circle")i=(r,o,a)=>{const l=o||new Pr([NaN,NaN]),h=le(r[0]),c=Eh(h,le(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;n==="Point"?r=Ce:n==="LineString"?r=ce:n==="Polygon"&&(r=Zt),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 r(o,this.geometryLayout_),a)}}this.geometryFunction_=i,this.dragVertexDelay_=t.dragVertexDelay!==void 0?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new wc({source:new D_({useSpatialIndex:!1,wrapX:t.wrapX?t.wrapX:!1}),style:t.style?t.style:xp(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:Ta,this.freehandCondition_,t.freehand?this.freehandCondition_=Os:this.freehandCondition_=t.freehandCondition?t.freehandCondition:Zs,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(Mo.ACTIVE,this.updateState_)}setTrace(t){let e;t?t===!0?e=Os:e=t:e=Do,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=Os:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Zs}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(t){t.originalEvent.type===X.CONTEXTMENU&&t.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(t);let e=t.type===J.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&t.type===J.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&t.type===J.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===J.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===J.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):(t.originalEvent.pointerType==="mouse"||t.type===J.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(t)):t.type===J.DBLCLICK&&(i=!1),super.handleEvent(t)&&i}handleDownEvent(t){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=t.pixel,this.finishCoordinate_||this.startDrawing_(t.coordinate),!0):this.condition_(t)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new be(J.POINTERMOVE,t.map,t.originalEvent,!1,t.frameState))},this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active){this.deactivateTrace_();return}const e=this.getMap(),i=e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),n=e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_]),r=zs([i,n]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=yp(t.coordinate,o);a.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const i=t.startIndex<=t.endIndex,n=t.startIndex<=e;i===n?i&&e>t.endIndex||!i&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(i&&e<t.endIndex||!i&&e>t.endIndex)&&this.removeTracedCoordinates_(e,t.endIndex):(this.removeTracedCoordinates_(t.startIndex,t.endIndex),this.addTracedCoordinates_(t,t.startIndex,e))}removeTracedCoordinates_(t,e){if(t===e)return;let i=0;if(t<e){const n=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),i=r-n+1}else{const n=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),i=n-r+1}i>0&&this.removeLastPoints_(i)}addTracedCoordinates_(t,e,i){if(e===i)return;const n=[];if(e<i){const r=Math.ceil(e);let o=Math.floor(i);o===i&&(o-=1);for(let a=r;a<=o;++a)n.push(qi(t.coordinates,a))}else{const r=Math.floor(e);let o=Math.ceil(i);o===i&&(o+=1);for(let a=r;a>=o;--a)n.push(qi(t.coordinates,a))}n.length&&this.appendCoordinates(n)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(e.targetIndex===-1){const a=t.map.getPixelFromCoordinate(e.startCoord);if(Th(a,t.pixel)<this.snapTolerance_)return}const i=pp(t.coordinate,e,this.getMap(),this.snapTolerance_);if(e.targetIndex!==i.index){if(e.targetIndex!==-1){const l=e.targets[e.targetIndex];this.removeTracedCoordinates_(l.startIndex,l.endIndex)}const a=e.targets[i.index];this.addTracedCoordinates_(a,a.startIndex,i.endIndex)}else{const a=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(a,i.endIndex)}e.targetIndex=i.index;const n=e.targets[e.targetIndex];n.endIndex=i.endIndex;const r=Ji(n.coordinates,n.endIndex),o=this.getMap().getPixelFromCoordinate(r);t.coordinate=r,t.pixel=[Math.round(o[0]),Math.round(o[1])]}handleDragEvent(t){this.ignoreNextUpEvent_=!0,super.handleDragEvent(t)}handleUpEvent(t){let e=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(t);const i=this.traceState_.active;if(this.ignoreNextUpEvent_||this.toggleTraceState_(t),this.shouldHandle_){const n=!this.finishCoordinate_;n&&this.startDrawing_(t.coordinate),!n&&this.freehand_?this.finishDrawing():!this.freehand_&&(!n||this.mode_==="Point")&&(this.atFinish_(t.pixel,i)?this.finishCondition_(t)&&this.finishDrawing():this.addToDrawing_(t.coordinate)),e=!1}else this.freehand_&&this.abortDrawing()}return this.ignoreNextUpEvent_=!1,!e&&this.stopClick_&&t.preventDefault(),e}handlePointerMove_(t){if(this.pointerType_=t.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const e=this.downPx_,i=t.pixel,n=e[0]-i[0],r=e[1]-i[1],o=n*n+r*r;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(t.coordinate.slice());return}this.updateTrace_(t),this.modifyDrawing_(t.coordinate)}atFinish_(t,e){let i=!1;if(this.sketchFeature_){let n=!1,r=[this.finishCoordinate_];const o=this.mode_;if(o==="Point")i=!0;else if(o==="Circle")i=this.sketchCoords_.length===2;else if(o==="LineString")n=!e&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){const a=this.sketchCoords_;n=a[0].length>this.minPoints_,r=[a[0][0],a[0][a[0].length-2]],e?r=[a[0][0]]:r=[a[0][0],a[0][a[0].length-2]]}if(n){const a=this.getMap();for(let l=0,h=r.length;l<h;l++){const c=r[l],u=a.getPixelFromCoordinate(c),d=t[0]-u[0],f=t[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_(t){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(t):(this.sketchPoint_=new Wt(new Ce(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new Wt);const e=t.getLinearRing(0);let i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),i.changed()):(i=new ce(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(t){const e=this.getMap().getView().getProjection(),i=js(this.geometryLayout_);for(;t.length<i;)t.push(0);this.finishCoordinate_=t,this.mode_==="Point"?this.sketchCoords_=t.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[t.slice(),t.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[t.slice(),t.slice()],this.sketchLineCoords_&&(this.sketchLine_=new Wt(new ce(this.sketchLineCoords_)));const n=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new Wt,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(n),this.updateSketchFeatures_(),this.dispatchEvent(new As(Is.DRAWSTART,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),i=this.sketchFeature_.getGeometry(),n=e.getView().getProjection(),r=js(this.geometryLayout_);let o,a;for(;t.length<r;)t.push(0);this.mode_==="Point"?a=this.sketchCoords_:this.mode_==="Polygon"?(o=this.sketchCoords_[0],a=o[o.length-1],this.atFinish_(e.getPixelFromCoordinate(t))&&(t=this.finishCoordinate_.slice())):(o=this.sketchCoords_,a=o[o.length-1]),a[0]=t[0],a[1]=t[1],this.geometryFunction_(this.sketchCoords_,i,n),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(t),i.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(i):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(t){const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection();let n,r;const o=this.mode_;return o==="LineString"||o==="Circle"?(this.finishCoordinate_=t.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),this.geometryFunction_(r,e,i)):o==="Polygon"&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),n&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,i)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),n?this.finishDrawing():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),n=this.mode_;for(let r=0;r<t;++r){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();const a=this.finishCoordinate_.slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}this.geometryFunction_(o,e,i),e.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if(n==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);const a=this.sketchLine_.getGeometry();if(o.length>=2){const l=o[o.length-2].slice();o[o.length-1]=l,this.createOrUpdateSketchPoint_(l)}a.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,e,i)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return null;let e=this.sketchCoords_;const i=t.getGeometry(),n=this.getMap().getView().getProjection();return this.mode_==="LineString"?(e.pop(),this.geometryFunction_(e,i,n)):this.mode_==="Polygon"&&(e[0].pop(),this.geometryFunction_(e,i,n),e=i.getCoordinates()),this.type_==="MultiPoint"?t.setGeometry(new mn([e])):this.type_==="MultiLineString"?t.setGeometry(new Si([e])):this.type_==="MultiPolygon"&&t.setGeometry(new wi([e])),this.dispatchEvent(new As(Is.DRAWEND,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t),t}abortDrawing_(){this.finishCoordinate_=null;const t=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),t}abortDrawing(){const t=this.abortDrawing_();t&&this.dispatchEvent(new As(Is.DRAWABORT,t))}appendCoordinates(t){const e=this.mode_,i=!this.sketchFeature_;i&&this.startDrawing_(t[0]);let n;if(e==="LineString"||e==="Circle")n=this.sketchCoords_;else if(e==="Polygon")n=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;i&&n.shift(),n.pop();for(let o=0;o<t.length;o++)this.addToDrawing_(t[o]);const r=t[t.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(t){const i=t.getGeometry();this.sketchFeature_=t,this.sketchCoords_=i.getCoordinates();const n=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=n.slice(),this.sketchCoords_.push(n.slice()),this.sketchPoint_=new Wt(new Ce(n)),this.updateSketchFeatures_(),this.dispatchEvent(new As(Is.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){const t=[];this.sketchFeature_&&t.push(this.sketchFeature_),this.sketchLine_&&t.push(this.sketchLine_),this.sketchPoint_&&t.push(this.sketchPoint_);const e=this.overlay_.getSource();e.clear(!0),e.addFeatures(t)}updateState_(){const t=this.getMap(),e=this.getActive();(!t||!e)&&this.abortDrawing(),this.overlay_.setMap(e?t:null)}}function xp(){const s=ac();return function(t,e){return s[t.getGeometry().getType()]}}function Ep(s){switch(s){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: "+s)}}const Ls={SELECT:"select"};class bs extends se{constructor(t,e,i,n){super(t),this.selected=e,this.deselected=i,this.mapBrowserEvent=n}}const Fs={};class Zc extends fn{constructor(t){super(),this.on,this.once,this.un,t=t||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=t.condition?t.condition:lf,this.addCondition_=t.addCondition?t.addCondition:Do,this.removeCondition_=t.removeCondition?t.removeCondition:Do,this.toggleCondition_=t.toggleCondition?t.toggleCondition:Zs,this.multi_=t.multi?t.multi:!1,this.filter_=t.filter?t.filter:ei,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.style_=t.style!==void 0?t.style:Tp(),this.features_=t.features||new Xt;let e;if(t.layers)if(typeof t.layers=="function")e=t.layers;else{const i=t.layers;e=function(n){return i.includes(n)}}else e=ei;this.layerFilter_=e,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(t,e){this.featureLayerAssociation_[k(t)]=e}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(t){return this.featureLayerAssociation_[k(t)]}setHitTolerance(t){this.hitTolerance_=t}setMap(t){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(t),t?(this.features_.addEventListener(Tt.ADD,this.boundAddFeature_),this.features_.addEventListener(Tt.REMOVE,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(Tt.ADD,this.boundAddFeature_),this.features_.removeEventListener(Tt.REMOVE,this.boundRemoveFeature_))}addFeature_(t){const e=t.element;if(this.style_&&this.applySelectedStyle_(e),!this.getLayer(e)){const i=this.findLayerOfFeature_(e);i&&this.addFeatureLayerAssociation_(e,i)}}removeFeature_(t){this.style_&&this.restorePreviousStyle_(t.element)}findLayerOfFeature_(t){return this.getMap().getAllLayers().find(function(i){if(i instanceof wc&&i.getSource()&&i.getSource().hasFeature(t))return i})}getStyle(){return this.style_}applySelectedStyle_(t){const e=k(t);e in Fs||(Fs[e]=t.getStyle()),t.setStyle(this.style_)}restorePreviousStyle_(t){const e=this.getMap().getInteractions().getArray();for(let n=e.length-1;n>=0;--n){const r=e[n];if(r!==this&&r instanceof Zc&&r.getStyle()&&r.getFeatures().getArray().lastIndexOf(t)!==-1){t.setStyle(r.getStyle());return}}const i=k(t);t.setStyle(Fs[i]),delete Fs[i]}removeFeatureLayerAssociation_(t){delete this.featureLayerAssociation_[k(t)]}selectFeatureInternal_(t,e,i){if(!(t instanceof Wt)||!this.filter_(t,e))return;const n=this.getFeatures();return n.getArray().includes(t)||(this.addFeatureLayerAssociation_(t,e),n.push(t),i?.push(t)),t}selectFeature(t){const e=this.findLayerOfFeature_(t);if(!this.layerFilter_(e))return!1;const i=this.selectFeatureInternal_(t,e);return i&&this.dispatchEvent(new bs(Ls.SELECT,[i],[],void 0)),!!i}removeFeatureInternal_(t,e){const i=this.getFeatures();if(!(!(t instanceof Wt)||!i.getArray().includes(t)))return i.remove(t),this.removeFeatureLayerAssociation_(t),e?.push(t),t}deselectFeature(t){const e=this.removeFeatureInternal_(t);return e&&this.dispatchEvent(new bs(Ls.SELECT,[],[e],void 0)),!!e}toggleFeature(t){this.deselectFeature(t)||this.selectFeature(t)}clearSelection(){Pi(this.featureLayerAssociation_);const t=this.getFeatures(),e=t.getArray().slice();t.clear(),e.length!==0&&this.dispatchEvent(new bs(Ls.SELECT,[],e,void 0))}handleEvent(t){if(!this.condition_(t))return!0;const e=this.addCondition_(t),i=this.removeCondition_(t),n=this.toggleCondition_(t),r=!e&&!i&&!n,o=t.map,a=this.getFeatures(),l=[],h=[];if(r){let c=!1;o.forEachFeatureAtPixel(t.pixel,(u,d)=>{if(c=!0,!!this.selectFeatureInternal_(u,d,h))return!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let u=a.getLength()-1;u>=0;--u){const d=a.item(u);(h.length>0&&!h.includes(d)||!c)&&this.removeFeatureInternal_(d,l)}}else o.forEachFeatureAtPixel(t.pixel,(c,u)=>{let d;if((i||n)&&(d=this.removeFeatureInternal_(c,l)),(e||n)&&!d&&(d=this.selectFeatureInternal_(c,u,h)),!!d)return!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});return(h.length>0||l.length>0)&&this.dispatchEvent(new bs(Ls.SELECT,h,l,t)),!0}}function Tp(){const s=ac();return Yt(s.Polygon,s.LineString),Yt(s.GeometryCollection,s.LineString),function(t){return t.getGeometry()?s[t.getGeometry().getType()]:null}}class Cp extends Mc{constructor(){super()}getType(){return"text"}readFeature(t,e){return this.readFeatureFromText(Ms(t),this.adaptOptions(e))}readFeatureFromText(t,e){return B()}readFeatures(t,e){return this.readFeaturesFromText(Ms(t),this.adaptOptions(e))}readFeaturesFromText(t,e){return B()}readGeometry(t,e){return this.readGeometryFromText(Ms(t),this.adaptOptions(e))}readGeometryFromText(t,e){return B()}readProjection(t){return this.readProjectionFromText(Ms(t))}readProjectionFromText(t){return this.dataProjection}writeFeature(t,e){return this.writeFeatureText(t,this.adaptOptions(e))}writeFeatureText(t,e){return B()}writeFeatures(t,e){return this.writeFeaturesText(t,this.adaptOptions(e))}writeFeaturesText(t,e){return B()}writeGeometry(t,e){return this.writeGeometryText(t,this.adaptOptions(e))}writeGeometryText(t,e){return B()}}function Ms(s){return typeof s=="string"?s:""}const vp={POINT:Ce,LINESTRING:ce,POLYGON:Zt,MULTIPOINT:mn,MULTILINESTRING:Si,MULTIPOLYGON:wi},Kc="EMPTY",Hc="Z",qc="M",Rp="ZM",tt={START:0,TEXT:1,LEFT_PAREN:2,RIGHT_PAREN:3,NUMBER:4,COMMA:5,EOF:6},Sp={Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION",Circle:"CIRCLE"};class wp{constructor(t){this.wkt=t,this.index_=-1}isAlpha_(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}isNumeric_(t,e){return e=e!==void 0?e:!1,t>="0"&&t<="9"||t=="."&&!e}isWhiteSpace_(t){return t==" "||t==" "||t=="\r"||t==`
`}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const t=this.nextChar_(),e=this.index_;let i=t,n;if(t=="(")n=tt.LEFT_PAREN;else if(t==",")n=tt.COMMA;else if(t==")")n=tt.RIGHT_PAREN;else if(this.isNumeric_(t)||t=="-")n=tt.NUMBER,i=this.readNumber_();else if(this.isAlpha_(t))n=tt.TEXT,i=this.readText_();else{if(this.isWhiteSpace_(t))return this.nextToken();if(t==="")n=tt.EOF;else throw new Error("Unexpected character: "+t)}return{position:e,value:i,type:n}}readNumber_(){let t;const e=this.index_;let i=!1,n=!1;do t=="."?i=!0:(t=="e"||t=="E")&&(n=!0),t=this.nextChar_();while(this.isNumeric_(t,i)||!n&&(t=="e"||t=="E")||n&&(t=="-"||t=="+"));return parseFloat(this.wkt.substring(e,this.index_--))}readText_(){let t;const e=this.index_;do t=this.nextChar_();while(this.isAlpha_(t));return this.wkt.substring(e,this.index_--).toUpperCase()}}class Pp{constructor(t){this.lexer_=t,this.token_={position:0,type:tt.START},this.layout_="XY"}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(t){return this.token_.type==t}match(t){const e=this.isTokenType(t);return e&&this.consume_(),e}parse(){return this.consume_(),this.parseGeometry_()}parseGeometryLayout_(){let t="XY";const e=this.token_;if(this.isTokenType(tt.TEXT)){const i=e.value;i===Hc?t="XYZ":i===qc?t="XYM":i===Rp&&(t="XYZM"),t!=="XY"&&this.consume_()}return t}parseGeometryCollectionText_(){if(this.match(tt.LEFT_PAREN)){const t=[];do t.push(this.parseGeometry_());while(this.match(tt.COMMA));if(this.match(tt.RIGHT_PAREN))return t}throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(tt.LEFT_PAREN)){const t=this.parsePoint_();if(this.match(tt.RIGHT_PAREN))return t}throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(tt.LEFT_PAREN)){const t=this.parsePointList_();if(this.match(tt.RIGHT_PAREN))return t}throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(tt.LEFT_PAREN)){const t=this.parseLineStringTextList_();if(this.match(tt.RIGHT_PAREN))return t}throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(tt.LEFT_PAREN)){let t;if(this.token_.type==tt.LEFT_PAREN?t=this.parsePointTextList_():t=this.parsePointList_(),this.match(tt.RIGHT_PAREN))return t}throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(tt.LEFT_PAREN)){const t=this.parseLineStringTextList_();if(this.match(tt.RIGHT_PAREN))return t}throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(tt.LEFT_PAREN)){const t=this.parsePolygonTextList_();if(this.match(tt.RIGHT_PAREN))return t}throw new Error(this.formatErrorMessage_())}parsePoint_(){const t=[],e=this.layout_.length;for(let i=0;i<e;++i){const n=this.token_;if(this.match(tt.NUMBER))t.push(n.value);else break}if(t.length==e)return t;throw new Error(this.formatErrorMessage_())}parsePointList_(){const t=[this.parsePoint_()];for(;this.match(tt.COMMA);)t.push(this.parsePoint_());return t}parsePointTextList_(){const t=[this.parsePointText_()];for(;this.match(tt.COMMA);)t.push(this.parsePointText_());return t}parseLineStringTextList_(){const t=[this.parseLineStringText_()];for(;this.match(tt.COMMA);)t.push(this.parseLineStringText_());return t}parsePolygonTextList_(){const t=[this.parsePolygonText_()];for(;this.match(tt.COMMA);)t.push(this.parsePolygonText_());return t}isEmptyGeometry_(){const t=this.isTokenType(tt.TEXT)&&this.token_.value==Kc;return t&&this.consume_(),t}formatErrorMessage_(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}parseGeometry_(){const t=this.token_;if(this.match(tt.TEXT)){const e=t.value;this.layout_=this.parseGeometryLayout_();const i=this.isEmptyGeometry_();if(e=="GEOMETRYCOLLECTION"){if(i)return new si([]);const o=this.parseGeometryCollectionText_();return new si(o)}const n=vp[e];if(!n)throw new Error("Invalid geometry type: "+e);let r;if(i)e=="POINT"?r=[NaN,NaN]:r=[];else switch(e){case"POINT":{r=this.parsePointText_();break}case"LINESTRING":{r=this.parseLineStringText_();break}case"POLYGON":{r=this.parsePolygonText_();break}case"MULTIPOINT":{r=this.parseMultiPointText_();break}case"MULTILINESTRING":{r=this.parseMultiLineStringText_();break}case"MULTIPOLYGON":{r=this.parseMultiPolygonText_();break}}return new n(r,this.layout_)}throw new Error(this.formatErrorMessage_())}}class Qp extends Cp{constructor(t){super(),t=t||{},this.splitCollection_=t.splitCollection!==void 0?t.splitCollection:!1}parse_(t){const e=new wp(t);return new Pp(e).parse()}readFeatureFromText(t,e){const i=this.readGeometryFromText(t,e),n=new Wt;return n.setGeometry(i),n}readFeaturesFromText(t,e){let i=[];const n=this.readGeometryFromText(t,e);this.splitCollection_&&n.getType()=="GeometryCollection"?i=n.getGeometriesArray():i=[n];const r=[];for(let o=0,a=i.length;o<a;++o){const l=new Wt;l.setGeometry(i[o]),r.push(l)}return r}readGeometryFromText(t,e){const i=this.parse_(t);return Yn(i,!1,e)}writeFeatureText(t,e){const i=t.getGeometry();return i?this.writeGeometryText(i,e):""}writeFeaturesText(t,e){if(t.length==1)return this.writeFeatureText(t[0],e);const i=[];for(let r=0,o=t.length;r<o;++r)i.push(t[r].getGeometry());const n=new si(i);return this.writeGeometryText(n,e)}writeGeometryText(t,e){return tu(Yn(t,!0,e))}}function Jc(s){const t=s.getCoordinates();return t.length===0?"":t.join(" ")}function Ip(s){const t=[],e=s.getPoints();for(let i=0,n=e.length;i<n;++i)t.push("("+Jc(e[i])+")");return t.join(",")}function Ap(s){const t=[],e=s.getGeometries();for(let i=0,n=e.length;i<n;++i)t.push(tu(e[i]));return t.join(",")}function qa(s){const t=s.getCoordinates(),e=[];for(let i=0,n=t.length;i<n;++i)e.push(t[i].join(" "));return e.join(",")}function Lp(s){const t=[],e=s.getLineStrings();for(let i=0,n=e.length;i<n;++i)t.push("("+qa(e[i])+")");return t.join(",")}function Qc(s){const t=[],e=s.getLinearRings();for(let i=0,n=e.length;i<n;++i)t.push("("+qa(e[i])+")");return t.join(",")}function bp(s){const t=[],e=s.getPolygons();for(let i=0,n=e.length;i<n;++i)t.push("("+Qc(e[i])+")");return t.join(",")}function Fp(s){const t=s.getLayout();let e="";return(t==="XYZ"||t==="XYZM")&&(e+=Hc),(t==="XYM"||t==="XYZM")&&(e+=qc),e}const Mp={Point:Jc,LineString:qa,Polygon:Qc,MultiPoint:Ip,MultiLineString:Lp,MultiPolygon:bp,GeometryCollection:Ap};function tu(s){const t=s.getType(),e=Mp[t],i=e(s);let n=Sp[t];if(typeof s.getFlatCoordinates=="function"){const r=Fp(s);r.length>0&&(n+=" "+r)}return i.length===0?n+" "+Kc:n+"("+i+")"}export{Vp as $,Vt as A,re as B,Tr as C,cf as D,Gp as E,ni as F,qp as G,Hp as H,Kp as I,Os as J,Jp as K,ce as L,Up as M,Bn as N,Bp as O,Zt as P,Zs as Q,vr as R,xi as S,Xp as T,Wp as U,wc as V,La as W,_n as X,De as Y,Dp as Z,Op as _,Zp as a,Gu as a0,Nu as a1,kp as a2,J_ as a3,jp as a4,Yp as a5,Qp as a6,fn as b,is as c,he as d,D_ as e,Wt as f,k as g,vo as h,ft as i,Pr as j,Np as k,Ci as l,Ze as m,Ce as n,Zc as o,Si as p,wi as q,sn as r,gn as s,_r as t,fu as u,Xt as v,_h as w,El as x,ii as y,zs as z};
//# sourceMappingURL=openlayers-D2I-bVN2.js.map