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>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:st?-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;n0?n-1:n}return i-1}if(e>0){for(let n=1;n0||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;h0:!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;r0;)this.pop()}extend(t){for(let e=0,i=t.length;ethis.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=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{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>1;){const l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=ht;){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;at.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_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;ir&&(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=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&&sf&&(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;en&&(l=l|Et.RIGHT),ar&&(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[2]&&(s[2]=t[2]),t[1]s[3]&&(s[3]=t[3]),s}function Fn(s,t){t[0]s[2]&&(s[2]=t[0]),t[1]s[3]&&(s[3]=t[1])}function mh(s,t,e,i,n){for(;et[0]?i[0]=s[0]:i[0]=t[0],s[1]>t[1]?i[1]=s[1]:i[1]=t[1],s[2]=t[0]&&s[1]<=t[3]&&s[3]>=t[1]}function un(s){return s[2]=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=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[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[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;i1?e:2,i=i??e,t===void 0&&(e>2?t=s.slice():t=new Array(n));for(let r=0;rfs?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;rgl&&(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=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{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().length1)u=e;else if(d>0){for(let f=0;fn&&(n=h),r=a,o=l}return n}function aa(s,t,e,i,n){for(let r=0,o=e.length;r0;){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;yf&&(c=y,f=E)}f>n&&(l[(c-t)/i]=1,d+i0&&m>f)&&(g<0&&_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;lr&&(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;op&&(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=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;r0}function ga(s,t,e,i,n){n=n!==void 0?n:!1;for(let r=0,o=e.length;rc&&d1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let n=0;for(;n0}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=0;--i){const n=this.animations_[i];let r=!0;for(let o=0,a=n.length;o0?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;ui.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;en.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;n0&&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]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;n0}}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;n0&&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{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.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);o0;)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 st?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=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=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=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.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<",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;rt){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;ri.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{for(let o=0;o{for(let o=0;o{const r=s.args;let o=n.properties[i];for(let a=1,l=r.length;an.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;ai(r)===n(r);case C.NotEqual:return r=>i(r)!==n(r);case C.LessThan:return r=>i(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{for(let o=0;o{for(let o=0;o{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!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{let o=1;for(let a=0;an[0](r)/n[1](r);case C.Add:return r=>{let o=0;for(let a=0;an[0](r)-n[1](r);case C.Clamp:return r=>{const o=n[0](r),a=n[1](r);if(ol?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{for(let r=0;r{const r=i[0](n);for(let o=1;o{const r=i[0](n),o=i[1](n);let a,l;for(let h=2;h=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{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;ithis.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{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;onull;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;i4)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=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;h0)&&(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;ithis.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=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(){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.minXthis.maxX&&(this.maxX=t.maxX),t.minYthis.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;ztct(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.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<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;ithis.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;l0&&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{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;al&&(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;ethis.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=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(a0&&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;us&&(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{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$[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;$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(;$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;$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$&&(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!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;n0){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;cp.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{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;ru*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;w0;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{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(;mg[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]])}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{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=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;o1?o:2,r=r||new Array(o);for(let c=0;c>1;n=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;rt.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{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;ns):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{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{--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;ir-n),"`resolutions` must be sorted in descending order");let e;if(!t.origins){for(let n=0,r=this.resolutions_.length-1;n{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||e0?i:Math.max(r/e[0],n/e[1]);const o=t+1,a=new Array(o);for(let l=0;lthis.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_='© OpenStreetMap 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;hOc({...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){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
`+this.createMarker("relative")+(c%2===0||o===2?this.createStepText(c,t,!1,e,i):"")+"")}return l.push(this.createStepText(o,t,!0,e,i)),(this.scaleBarText_?`
`+r+"
":"")+l.join("")}createMarker(t){return`
`}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`
`+a+"
"}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;_T.value):null;let y;t:for(let T=0,x=g.length;T{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=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{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=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{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{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.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;o4)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{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{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`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{const[e,...i]=t.args,n=i.length,r=new Uint8Array(n*4);for(let h=0;h0)return ti(s.value);if((s.type>)>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;i0?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;c0?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;h1){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;d0?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;r80*x){c=t[0],y=t[1];let e=c,n=y;for(let r=x;re&&(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;o0)for(let x=e;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;t0||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.x&&n.x>=u&&r!==n.x&&y(xo.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=(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;n0?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{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;t0?y=o+(n-1)*r:l&&(y=s-r);let h=null;n"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(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`${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_{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{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=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;ud.startIndex?md.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(fo){const l=Ji(s,i),h=Ji(s,n);return ws(l,h)}let a=0;if(i{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&&et.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(t0&&this.removeLastPoints_(i)}addTracedCoordinates_(t,e,i){if(e===i)return;const n=[];if(e=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.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=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=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=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;i0&&(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