const sf="modulepreload",rf=function(s){return"/"+s},_h={},E0=function(e,t,n){let i=Promise.resolve();if(t&&t.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");i=o(t.map(h=>{if(h=rf(h),h in _h)return;_h[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":sf,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 i.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})},Re={ADD:"add",REMOVE:"remove"},Oi={PROPERTYCHANGE:"propertychange"},V={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class bs{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function of(s,e,t){let n,i;t=t||Ot;let r=0,o=s.length,a=!1;for(;r>1),i=+t(s[n],e),i<0?r=n+1:(o=n,a=!i);return a?r:~r}function Ot(s,e){return s>e?1:se?-1:0}function Za(s,e,t){if(s[0]<=e)return 0;const n=s.length;if(e<=s[n-1])return n-1;if(typeof t=="function"){for(let i=1;i0?i-1:i}return n-1}if(t>0){for(let i=1;i0||o===0)})}function wn(){return!0}function $i(){return!1}function Es(){}function Mc(s){let e,t,n;return function(){const i=Array.prototype.slice.call(arguments);return(!t||this!==n||!Ut(i,t))&&(n=this,t=i,e=s.apply(this,arguments)),e}}function Dc(s){function e(){let t;try{t=s()}catch(n){return Promise.reject(n)}return t instanceof Promise?t:Promise.resolve(t)}return e()}function Qn(s){for(const e in s)delete s[e]}function jn(s){let e;for(e in s)return!1;return!e}class Tt{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Ms extends bs{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const n=this.listeners_||(this.listeners_={}),i=n[e]||(n[e]=[]);i.includes(t)||i.push(t)}dispatchEvent(e){const t=typeof e=="string",n=t?e:e.type,i=this.listeners_&&this.listeners_[n];if(!i)return;const r=t?new Tt(e):e;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});n in o||(o[n]=0,a[n]=0),++o[n];let l;for(let h=0,c=i.length;h0:!1}removeEventListener(e,t){if(!this.listeners_)return;const n=this.listeners_[e];if(!n)return;const i=n.indexOf(t);i!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(n[i]=Es,++this.pendingRemovals_[e]):(n.splice(i,1),n.length===0&&delete this.listeners_[e]))}}function J(s,e,t,n,i){if(i){const o=t;t=function(a){return s.removeEventListener(e,t),o.call(n??this,a)}}else n&&n!==s&&(t=t.bind(n));const r={target:s,type:e,listener:t};return s.addEventListener(e,t),r}function Sr(s,e,t,n){return J(s,e,t,n,!0)}function ue(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),Qn(s))}class Ds extends Ms{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(V.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const n=e.length,i=new Array(n);for(let r=0;r0;)this.pop()}extend(e){for(let t=0,n=e.length;tthis.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new Zs(Re.ADD,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){const t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){const t=this.array_;for(let n=0,i=t.length;n=this.getLength())return;const t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new Zs(Re.REMOVE,t,e)),t}setAt(e,t){const n=this.getLength();if(e>=n){this.insertAt(e,t);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);const i=this.array_[e];this.array_[e]=t,this.dispatchEvent(new Zs(Re.REMOVE,i,e)),this.dispatchEvent(new Zs(Re.ADD,t,e))}updateLength_(){this.set(ph.LENGTH,this.array_.length)}assertUnique_(e,t){const n=this.array_;for(let i=0,r=n.length;i{this.clickTimeoutId_=void 0;const n=new Vt(ee.SINGLECLICK,this.map_,e);this.dispatchEvent(n)},250)}updateActivePointers_(e){const t=e,n=t.pointerId;if(t.type==ee.POINTERUP||t.type==ee.POINTERCANCEL){delete this.trackedTouches_[n];for(const i in this.trackedTouches_)if(this.trackedTouches_[i].target!==t.target){delete this.trackedTouches_[i];break}}else(t.type==ee.POINTERDOWN||t.type==ee.POINTERMOVE)&&(this.trackedTouches_[n]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);const t=new Vt(ee.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(ue),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);const t=new Vt(ee.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,"target",{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){const n=this.map_.getOwnerDocument();this.dragListenerKeys_.push(J(n,ee.POINTERMOVE,this.handlePointerMove_,this),J(n,ee.POINTERUP,this.handlePointerUp_,this),J(this.element_,ee.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==n&&this.dragListenerKeys_.push(J(this.element_.getRootNode(),ee.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;const t=new Vt(ee.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;const t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new Vt(ee.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){const t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!="boolean"||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(ue(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(V.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(ue(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(ue),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Zt={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Ue={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},B={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function te(s,e){if(!s)throw new Error(e)}const vr=1/0;class yf{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,Qn(this.queuedElements_)}dequeue(){const e=this.elements_,t=this.priorities_,n=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));const i=this.keyFunction_(n);return delete this.queuedElements_[i],n}enqueue(e){te(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const t=this.priorityFunction_(e);return t!=vr?(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){const t=this.elements_,n=this.priorities_,i=t.length,r=t[e],o=n[e],a=e;for(;e>1;){const l=this.getLeftChildIndex_(e),h=this.getRightChildIndex_(e),c=he;){const a=this.getParentIndex_(t);if(i[a]>o)n[t]=n[a],i[t]=i[a],t=a;else break}n[t]=r,i[t]=o}reprioritize(){const e=this.priorityFunction_,t=this.elements_,n=this.priorities_;let i=0;const r=t.length;let o,a,l;for(a=0;ae.apply(null,n),n=>n[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=t,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(e){const t=super.enqueue(e);return t&&e[0].addEventListener(V.CHANGE,this.boundHandleTileChange_),t}getTilesLoading(){return this.tilesLoading_}handleTileChange(e){const t=e.target,n=t.getState();if(n===B.LOADED||n===B.ERROR||n===B.EMPTY){n!==B.ERROR&&t.removeEventListener(V.CHANGE,this.boundHandleTileChange_);const i=t.getKey();i in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[i],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(e,t){let n=0;for(;this.tilesLoading_0;){const i=this.dequeue()[0],r=i.getKey();i.getState()===B.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++n,i.load())}}}function Ef(s,e,t,n,i){if(!s||!(t in s.wantedTiles)||!s.wantedTiles[t][e.getKey()])return vr;const r=s.viewState.center,o=n[0]-r[0],a=n[1]-r[1];return 65536*Math.log(i)+Math.sqrt(o*o+a*a)/i}const he={ANIMATING:0,INTERACTING:1},Rt={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function fe(s,e,t){return Math.min(Math.max(s,e),t)}function Tf(s,e,t,n,i,r){const o=i-t,a=r-n;if(o!==0||a!==0){const l=((s-t)*o+(e-n)*a)/(o*o+a*a);l>1?(t=i,n=r):l>0&&(t+=o*l,n+=a*l)}return Jt(s,e,t,n)}function Jt(s,e,t,n){const i=t-s,r=n-e;return i*i+r*r}function Cf(s){const e=s.length;for(let n=0;nr&&(r=l,i=a)}if(r===0)return null;const o=s[i];s[i]=s[n],s[n]=o;for(let a=n+1;a=0;n--){t[n]=s[n][e]/s[n][n];for(let i=n-1;i>=0;i--)s[i][e]-=s[i][n]*t[n]}return t}function yh(s){return s*180/Math.PI}function pt(s){return s*Math.PI/180}function Qt(s,e){const t=s%e;return t*e<0?t+e:t}function it(s,e,t){return s+t*(e-s)}function Xi(s,e){const t=Math.pow(10,e);return Math.round(s*t)/t}function xh(s,e){return Math.round(Xi(s,e))}function Ks(s,e){return Math.floor(Xi(s,e))}function Hs(s,e){return Math.ceil(Xi(s,e))}function _a(s,e,t){if(s>=e&&sf&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=fe(n[0],d,f),p=fe(n[1],g,m);if(o&&t&&i){const y=30*i;_+=-y*Math.log(1+Math.max(0,d-n[0])/y)+y*Math.log(1+Math.max(0,n[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-n[1])/y)+y*Math.log(1+Math.max(0,n[1]-m)/y)}return[_,p]})}function Rf(s){return s}const Ae={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Be(s){const e=Je();for(let t=0,n=s.length;ti&&(l=l|Ae.RIGHT),ar&&(l=l|Ae.ABOVE),l===Ae.UNKNOWN&&(l=Ae.INTERSECTING),l}function Je(){return[1/0,1/0,-1/0,-1/0]}function kt(s,e,t,n,i){return i?(i[0]=s,i[1]=e,i[2]=t,i[3]=n,i):[s,e,t,n]}function Wi(s){return kt(1/0,1/0,-1/0,-1/0,s)}function ds(s,e){const t=s[0],n=s[1];return kt(t,n,t,n,e)}function Ha(s,e,t,n,i){const r=Wi(i);return Bc(r,s,e,t,n)}function Kn(s,e){return s[0]==e[0]&&s[2]==e[2]&&s[1]==e[1]&&s[3]==e[3]}function Uc(s,e){return e[0]s[2]&&(s[2]=e[2]),e[1]s[3]&&(s[3]=e[3]),s}function fs(s,e){e[0]s[2]&&(s[2]=e[0]),e[1]s[3]&&(s[3]=e[1])}function Bc(s,e,t,n,i){for(;te[0]?n[0]=s[0]:n[0]=e[0],s[1]>e[1]?n[1]=s[1]:n[1]=e[1],s[2]=e[0]&&s[1]<=e[3]&&s[3]>=e[1]}function ti(s){return s[2]=o&&m<=l),!n&&r&Ae.RIGHT&&!(i&Ae.RIGHT)&&(_=f-(d-l)*g,n=_>=a&&_<=h),!n&&r&Ae.BELOW&&!(i&Ae.BELOW)&&(m=d-(f-a)/g,n=m>=o&&m<=l),!n&&r&Ae.LEFT&&!(i&Ae.LEFT)&&(_=f-(d-o)*g,n=_>=a&&_<=h)}return n}function Af(s,e,t,n){if(ti(s))return Wi(t);let i=[];{const a=s[2]-s[0],l=s[3]-s[1];for(let h=0;h=t[2])){const i=ne(t),o=Math.floor((n[0]-t[0])/i)*i;s[0]-=o,s[2]-=o}return s}function Xc(s,e,t){if(e.canWrapX()){const n=e.getExtent();if(!isFinite(s[0])||!isFinite(s[2]))return[[n[0],s[1],n[2],s[3]]];$c(s,e);const i=ne(n);if(ne(s)>i&&!t)return[[n[0],s[1],n[2],s[3]]];if(s[0]n[2])return[[s[0],s[1],n[2],s[3]],[n[0],s[1],s[2]-i,s[3]]]}return[s]}function Wc(s,e){const t=(""+s).split("."),n=(""+e).split(".");for(let i=0;io)return 1;if(o>r)return-1}return 0}function Ff(s,e){return s[0]+=+e[0],s[1]+=+e[1],s}function Ja(s,e){const t=s[0],n=s[1],i=e[0],r=e[1],o=i[0],a=i[1],l=r[0],h=r[1],c=l-o,u=h-a,d=c===0&&u===0?0:(c*(t-o)+u*(n-a))/(c*c+u*u||0);let f,g;return d<=0?(f=o,g=a):d>=1?(f=l,g=h):(f=o+d*c,g=a+d*u),[f,g]}function je(s,e){let t=!0;for(let n=s.length-1;n>=0;--n)if(s[n]!=e[n]){t=!1;break}return t}function Qa(s,e){const t=Math.cos(e),n=Math.sin(e),i=s[0]*t-s[1]*n,r=s[1]*t+s[0]*n;return s[0]=i,s[1]=r,s}function bf(s,e){return s[0]*=e,s[1]*=e,s}function Ni(s,e){const t=s[0]-e[0],n=s[1]-e[1];return t*t+n*n}function Si(s,e){return Math.sqrt(Ni(s,e))}function Mf(s,e){return Ni(s,Ja(s,e))}function el(s,e){if(e.canWrapX()){const t=ne(e.getExtent()),n=Df(s,e,t);n&&(s[0]-=n*t)}return s}function Df(s,e,t){const n=e.getExtent();let i=0;return e.canWrapX()&&(s[0]n[2])&&(t=t||ne(n),i=Math.floor((s[0]-n[0])/t)),i}function Yc(s){return Math.pow(s,3)}function Yi(s){return 1-Yc(1-s)}function Of(s){return 3*s*s-2*s*s*s}function Nf(s){return s}const tl=63710088e-1;function xa(s,e,t){t=t||tl;const n=pt(s[1]),i=pt(e[1]),r=(i-n)/2,o=pt(e[0]-s[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(n)*Math.cos(i);return 2*t*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function vo(s,e){let t=0;for(let n=0,i=s.length;n1?t:2,n=n??t,e===void 0&&(t>2?e=s.slice():e=new Array(i));for(let r=0;rJs?o=Js:o<-Js&&(o=-Js),e[r+1]=o}return e}function $f(s,e,t,n){const i=s.length;t=t>1?t:2,n=n??t,e===void 0&&(t>2?e=s.slice():e=new Array(i));for(let r=0;rwh&&(e=wh);const n=pt(e),i=Math.sin(n),r=Math.cos(n),o=i/r,a=o*o,l=a*a,h=pt(s),c=Hc(t.number),u=pt(c),d=Pr/Math.sqrt(1-yt*i**2),f=Un*r**2,g=r*_a(h-u,-Math.PI,Math.PI),m=g*g,_=m*g,p=_*g,y=p*g,E=y*g,x=Pr*(Kc*n-Vf*Math.sin(2*n)+Zf*Math.sin(4*n)-Kf*Math.sin(6*n)),T=wr*d*(g+_/6*(1-a+f)+y/120*(5-18*a+l+72*f-58*Un))+5e5;let R=wr*(x+d*o*(m/2+p/24*(5-a+9*f+4*f**2)+E/720*(61-58*a+l+600*f-330*Un)));return t.north||(R+=1e7),[T,R]}function Hc(s){return(s-1)*6-180+3}const sg=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function qc(s){let e=0;for(const i of sg){const r=s.match(i);if(r){e=parseInt(r[1]);break}}if(!e)return null;let t=0,n=!1;return e>32700&&e<32761?t=e-32700:e>32600&&e<32661&&(n=!0,t=e-32600),t?{number:t,north:n}:null}function Ph(s,e){return function(t,n,i,r){const o=t.length;i=i>1?i:2,r=r??i,n||(i>2?n=t.slice():n=new Array(o));for(let a=0;a=l?e[o+h]:a[h]}return t})}function T0(s,e){return Jc(),Ns(s,"EPSG:4326","EPSG:3857")}function C0(s,e){const t=Ns(s,"EPSG:3857","EPSG:4326"),n=t[0];return(n<-180||n>180)&&(t[0]=Qt(n+180,360)-180),t}function Yn(s,e){if(s===e)return!0;const t=s.getUnits()===e.getUnits();return(s.getCode()===e.getCode()||eo(s,e)===rl)&&t}function eo(s,e){const t=s.getCode(),n=e.getCode();let i=wo(t,n);if(i)return i;let r=null,o=null;for(const l of ag)r||(r=l(s)),o||(o=l(e));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)i=Po(r.inverse,o.forward);else{const l=wo(t,a);l&&(i=Po(l,o.forward))}else{const l=wo(a,n);l&&(i=Po(r.inverse,l))}return i&&(Ca(s),Ca(e),Ts(s,e,i)),i}function Po(s,e){return function(t,n,i,r){return n=s(t,n,i,r),e(n,n,i,r)}}function Hn(s,e){const t=_e(s),n=_e(e);return eo(t,n)}function Ns(s,e,t){const n=Hn(e,t);if(!n){const i=_e(e).getCode(),r=_e(t).getCode();throw new Error(`No transform available between ${i} and ${r}`)}return n(s,void 0,s.length)}function dg(s,e,t,n){const i=Hn(e,t);return Af(s,i,void 0,n)}let fg=null;function gg(){return fg}function qn(s,e){return s}function me(s,e){return Ta&&!je(s,[0,0])&&s[0]>=-180&&s[0]<=180&&s[1]>=-90&&s[1]<=90&&(Ta=!1,jc("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),s}function to(s,e){return s}function St(s,e){return s}function _g(){Ih(Th),Ih(Rh),cg(Rh,Th,zf,$f)}_g();const Qc=new Array(6);function Te(){return[1,0,0,1,0,0]}function Lh(s){return al(s,1,0,0,1,0,0)}function no(s,e){const t=s[0],n=s[1],i=s[2],r=s[3],o=s[4],a=s[5],l=e[0],h=e[1],c=e[2],u=e[3],d=e[4],f=e[5];return s[0]=t*l+i*h,s[1]=n*l+r*h,s[2]=t*c+i*u,s[3]=n*c+r*u,s[4]=t*d+i*f+o,s[5]=n*d+r*f+a,s}function al(s,e,t,n,i,r,o){return s[0]=e,s[1]=t,s[2]=n,s[3]=i,s[4]=r,s[5]=o,s}function eu(s,e){return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s}function de(s,e){const t=e[0],n=e[1];return e[0]=s[0]*t+s[2]*n+s[4],e[1]=s[1]*t+s[3]*n+s[5],e}function Io(s,e,t){return no(s,al(Qc,e,0,0,t,0,0))}function tu(s,e,t){return no(s,al(Qc,1,0,0,1,e,t))}function lt(s,e,t,n,i,r,o,a){const l=Math.sin(r),h=Math.cos(r);return s[0]=n*h,s[1]=i*l,s[2]=-n*l,s[3]=i*h,s[4]=o*n*h-a*n*l+e,s[5]=o*i*l+a*i*h+t,s}function Cs(s,e){const t=mg(e);te(t!==0,"Transformation matrix cannot be inverted");const n=e[0],i=e[1],r=e[2],o=e[3],a=e[4],l=e[5];return s[0]=o/t,s[1]=-i/t,s[2]=-r/t,s[3]=n/t,s[4]=(r*l-o*a)/t,s[5]=-(n*l-i*a)/t,s}function mg(s){return s[0]*s[3]-s[1]*s[2]}const pg=[1e5,1e5,1e5,1e5,2,2];function yg(s){return"matrix("+s.join(", ")+")"}function Ra(s){return s.substring(7,s.length-1).split(",").map(parseFloat)}function xg(s,e){const t=Ra(s),n=Ra(e);for(let i=0;i<6;++i)if(Math.round((t[i]-n[i])*pg[i])!==0)return!1;return!0}function Nt(s,e,t,n,i,r,o){r=r||[],o=o||2;let a=0;for(let l=e;l{if(!n)return this.getSimplifiedGeometry(t);const i=this.clone();return i.applyTransform(n),i.getSimplifiedGeometry(t)})}simplifyTransformed(e,t){return this.simplifyTransformedInternal(this.getRevision(),e,t)}clone(){return $()}closestPointXY(e,t,n,i){return $()}containsXY(e,t){return this.closestPointXY(e,t,Cg,Number.MIN_VALUE)===0}getClosestPoint(e,t){return t=t||[NaN,NaN],this.closestPointXY(e[0],e[1],t,1/0),t}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return $()}getExtent(e){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&Wi(t),this.extentRevision_=this.getRevision()}return Pf(this.extent_,e)}rotate(e,t){$()}scale(e,t,n){$()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return $()}getType(){return $()}applyTransform(e){$()}intersectsExtent(e){return $()}translate(e,t){$()}transform(e,t){const n=_e(e),i=n.getUnits()=="tile-pixels"?function(r,o,a){const l=n.getExtent(),h=n.getWorldExtent(),c=be(h)/be(l);lt(Ah,h[0],h[3],c,-c,0,0,0);const u=Nt(r,0,r.length,a,Ah,o),d=Hn(n,t);return d?d(u,u,a):u}:Hn(n,t);return this.applyTransform(i),this}}class Fn extends nu{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return Ha(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return $()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const t=this.getSimplifiedGeometryInternal(e);return t.getFlatCoordinates().length1)u=t;else if(d>0){for(let f=0;fi&&(i=h),r=a,o=l}return i}function cl(s,e,t,n,i){for(let r=0,o=t.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+n;yf&&(c=y,f=T)}f>i&&(l[(c-e)/n]=1,d+n0&&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 fl(s,e,t,n,i,r,o,a){for(let l=0,h=t.length;lr&&(h-a)*(r-l)-(i-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(i-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function gl(s,e,t,n,i,r){if(t.length===0||!Bn(s,e,t[0],n,i,r))return!1;for(let o=1,a=t.length;op&&(h=(c+u)/2,gl(s,e,t,n,h,g)&&(_=h,p=y)),c=u}return isNaN(_)&&(_=i[r]),o?(o.push(_,g,p),o):[_,g,p]}function lu(s,e,t,n,i){let r=[];for(let o=0,a=t.length;o=i[0]&&r[2]<=i[2]||r[1]>=i[1]&&r[3]<=i[3]?!0:hu(s,e,t,n,function(o,a){return Lf(i,o,a)}):!1}function Fg(s,e,t,n,i){for(let r=0,o=t.length;r0}function pl(s,e,t,n,i){i=i!==void 0?i:!1;for(let r=0,o=t.length;rc&&d1&&typeof arguments[t-1]=="function"&&(n=arguments[t-1],--t);let i=0;for(;i0}getInteracting(){return this.hints_[he.INTERACTING]>0}cancelAnimations(){this.setHint(he.ANIMATING,-this.hints_[he.ANIMATING]);let e;for(let t=0,n=this.animations_.length;t=0;--n){const i=this.animations_[n];let r=!0;for(let o=0,a=i.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?Qt(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),t=!0,!l.complete)break}if(r){this.animations_[n]=null,this.setHint(he.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=i[0].callback;o&&Qs(o,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let n;const i=this.getCenterInternal();return i!==void 0&&(n=[i[0]-t[0],i[1]-t[1]],Qa(n,e-this.getRotation()),Ff(n,t)),n}calculateCenterZoom(e,t){let n;const i=this.getCenterInternal(),r=this.getResolution();if(i!==void 0&&r!==void 0){const o=t[0]-e*(t[0]-i[0])/r,a=t[1]-e*(t[1]-i[1])/r;n=[o,a]}return n}getViewportSize_(e){const t=this.viewportSize_;if(e){const n=t[0],i=t[1];return[Math.abs(n*Math.cos(e))+Math.abs(i*Math.sin(e)),Math.abs(n*Math.sin(e))+Math.abs(i*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const e=this.getCenterInternal();return e&&qn(e,this.getProjection())}getCenterInternal(){return this.get(Rt.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){const t=this.calculateExtentInternal(e);return to(t,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();const t=this.getCenterInternal();te(t,"The view center is not defined");const n=this.getResolution();te(n!==void 0,"The view resolution is not defined");const i=this.getRotation();return te(i!==void 0,"The view rotation is not defined"),ya(t,n,i,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(Rt.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(St(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t=t||this.getViewportSizeMinusPadding_();const n=ne(e)/t[0],i=be(e)/t[1];return Math.max(n,i)}getResolutionForValueFunction(e){e=e||2;const t=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,i=Math.log(t/n)/Math.log(e);return(function(r){return t/Math.pow(e,r*i)})}getRotation(){return this.get(Rt.ROTATION)}getValueForResolutionFunction(e){const t=Math.log(e||2),n=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(n/i)/t;return(function(o){return Math.log(n/o)/t/r})}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e);const n=this.padding_;return n&&(t=[t[0]-n[1]-n[3],t[1]-n[0]-n[2]]),t}getState(){const e=this.getProjection(),t=this.getResolution(),n=this.getRotation();let i=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();i=Ao(i,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],t,n)}return{center:i.slice(0),projection:e!==void 0?e:null,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e;const t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,n,i;if(this.resolutions_){const r=Za(this.resolutions_,e,1);t=r,n=this.resolutions_[r],r==this.resolutions_.length-1?i=2:i=n/this.resolutions_[r+1]}else n=this.maxResolution_,i=this.zoomFactor_;return t+Math.log(n/e)/Math.log(i)}getResolutionForZoom(e){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const t=fe(Math.floor(e),0,this.resolutions_.length-2),n=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/Math.pow(n,fe(e-t,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,t){let n;if(te(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){te(!ti(e),"Cannot fit empty extent provided as `geometry`");const i=St(e,this.getProjection());n=bh(i)}else if(e.getType()==="Circle"){const i=St(e.getExtent(),this.getProjection());n=bh(i),n.rotate(this.getRotation(),Pn(i))}else n=e;this.fitInternal(n,t)}rotatedExtentForGeometry(e){const t=this.getRotation(),n=Math.cos(t),i=Math.sin(-t),r=e.getFlatCoordinates(),o=e.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;un.trim().replace(/^['"]|['"]$/g,"")),t};function ve(s,e,t,n){let i;return t&&t.length?i=t.shift():rt?i=new class extends OffscreenCanvas{style={}}(s??300,e??150):i=document.createElement("canvas"),s&&(i.width=s),e&&(i.height=e),i.getContext("2d",n)}let Fo;function Fr(){return Fo||(Fo=ve(1,1)),Fo}function oo(s){const e=s.canvas;e.width=1,e.height=1,s.clearRect(0,0,1,1)}function jg(s){let e=s.offsetWidth;const t=getComputedStyle(s);return e+=parseInt(t.marginLeft,10)+parseInt(t.marginRight,10),e}function Vg(s){let e=s.offsetHeight;const t=getComputedStyle(s);return e+=parseInt(t.marginTop,10)+parseInt(t.marginBottom,10),e}function Gh(s,e){const t=e.parentNode;t&&t.replaceChild(s,e)}function gu(s){for(;s.lastChild;)s.lastChild.remove()}function Zg(s,e){const t=s.childNodes;for(let n=0;;++n){const i=t[n],r=e[n];if(!i&&!r)break;if(i!==r){if(!i){s.appendChild(r);continue}if(!r){s.removeChild(i),--n;continue}s.insertBefore(r,i)}}}function _u(){return new Proxy({childNodes:[],appendChild:function(e){return this.childNodes.push(e),e},remove:function(){},removeChild:function(e){const t=this.childNodes.indexOf(e);if(t===-1)throw new Error("Node to remove was not found");return this.childNodes.splice(t,1),e},insertBefore:function(e,t){const n=this.childNodes.indexOf(t);if(n===-1)throw new Error("Reference node not found");return this.childNodes.splice(n,0,e),e},style:{}},{get(e,t,n){return t==="firstElementChild"?e.childNodes.length>0?e.childNodes[0]:null:Reflect.get(e,t,n)}})}function xn(s){return typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}class ao extends It{constructor(e){super();const t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&this.element?.remove();for(let t=0,n=this.listenerKeys.length;ti.getAttributions(e)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(i=>n.add(i)):n.add(this.attributions_)),!this.overrideCollapsible_){const i=!t.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(i)}return Array.from(n)}async updateElement_(e){if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=await Promise.all(this.collectSourceAttributions_(e).map(i=>Dc(()=>i))),n=t.length>0;if(this.renderedVisible_!=n&&(this.element.style.display=n?"":"none",this.renderedVisible_=n),!Ut(t,this.renderedAttributions_)){gu(this.ulElement_);for(let i=0,r=t.length;i0&&n%(2*Math.PI)!==0?t.animate({rotation:0,duration:this.duration_,easing:Yi}):t.setRotation(0))}render(e){const t=e.frameState;if(!t)return;const n=t.viewState.rotation;if(n!=this.rotation_){const i="rotate("+n+"rad)";if(this.autoHide_){const r=this.element.classList.contains(er);!r&&n===0?this.element.classList.add(er):r&&n!==0&&this.element.classList.remove(er)}this.label_.style.transform=i}this.rotation_=n}}class qg extends ao{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target});const t=e.className!==void 0?e.className:"ol-zoom",n=e.delta!==void 0?e.delta:1,i=e.zoomInClassName!==void 0?e.zoomInClassName:t+"-in",r=e.zoomOutClassName!==void 0?e.zoomOutClassName:t+"-out",o=e.zoomInLabel!==void 0?e.zoomInLabel:"+",a=e.zoomOutLabel!==void 0?e.zoomOutLabel:"–",l=e.zoomInTipLabel!==void 0?e.zoomInTipLabel:"Zoom in",h=e.zoomOutTipLabel!==void 0?e.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=i,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(V.CLICK,this.handleClick_.bind(this,n),!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(V.CLICK,this.handleClick_.bind(this,-n),!1);const d=t+" "+ks+" "+Cl,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=e.duration!==void 0?e.duration:250}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){const n=this.getMap().getView();if(!n)return;const i=n.getZoom();if(i!==void 0){const r=n.getConstrainedZoom(i+e);this.duration_>0?(n.getAnimating()&&n.cancelAnimations(),n.animate({zoom:r,duration:this.duration_,easing:Yi})):n.setZoom(r)}}}function Jg(s){s=s||{};const e=new Ve;return(s.zoom!==void 0?s.zoom:!0)&&e.push(new qg(s.zoomOptions)),(s.rotate!==void 0?s.rotate:!0)&&e.push(new Hg(s.rotateOptions)),(s.attribution!==void 0?s.attribution:!0)&&e.push(new Kg(s.attributionOptions)),e}class Qg{constructor(e,t,n){this.decay_=e,this.minVelocity_=t,this.delay_=n,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;const e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]0&&this.points_[n+2]>e;)n-=3;const i=this.points_[t+2]-this.points_[n+2];if(i<1e3/60)return!1;const r=this.points_[t]-this.points_[n],o=this.points_[t+1]-this.points_[n+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/i,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}const Ia={ACTIVE:"active"};class ji extends It{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(Ia.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(Ia.ACTIVE,e)}setMap(e){this.map_=e}}function e_(s,e,t){const n=s.getCenterInternal();if(n){const i=[n[0]+e[0],n[1]+e[1]];s.animateInternal({duration:t!==void 0?t:250,easing:Nf,center:s.getConstrainedCenter(i)})}}function Rl(s,e,t,n){const i=s.getZoom();if(i===void 0)return;const r=s.getConstrainedZoom(i+e),o=s.getResolutionForZoom(r);s.getAnimating()&&s.cancelAnimations(),s.animate({resolution:o,anchor:t,duration:n!==void 0?n:250,easing:Yi})}class t_ extends ji{constructor(e){super(),e=e||{},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:250}handleEvent(e){let t=!1;if(e.type==ee.DBLCLICK){const n=e.originalEvent,i=e.map,r=e.coordinate,o=n.shiftKey?-this.delta_:this.delta_,a=i.getView();Rl(a,o,r,this.duration_),n.preventDefault(),t=!0}return!t}}function La(s){const e=arguments;return function(t){let n=!0;for(let i=0,r=e.length;i0}}else if(e.type==ee.POINTERDOWN){const n=this.handleDownEvent(e);this.handlingDownUpSequence=n,t=this.stopDown(n)}else e.type==ee.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}}function vl(s){const e=s.length;let t=0,n=0;for(let i=0;i0&&this.condition_(e)){const n=e.map.getView();return this.lastCentroid=null,n.getAnimating()&&n.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class a_ extends ii{constructor(e){e=e||{},super({stopDown:$i}),this.condition_=e.condition?e.condition:i_,this.lastAngle_=void 0,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){if(!bo(e))return;const t=e.map,n=t.getView();if(n.getConstraints().rotation===El)return;const i=t.getSize(),r=e.pixel,o=Math.atan2(i[1]/2-r[1],r[0]-i[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;n.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(e){return bo(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return bo(e)&&pu(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class l_ extends bs{constructor(e){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const e=this.startPixel_,t=this.endPixel_,n="px",i=this.element_.style;i.left=Math.min(e[0],t[0])+n,i.top=Math.min(e[1],t[1])+n,i.width=Math.abs(t[0]-e[0])+n,i.height=Math.abs(t[1]-e[1])+n}setMap(e){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const e=this.startPixel_,t=this.endPixel_,i=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);i[4]=i[0].slice(),this.geometry_?this.geometry_.setCoordinates([i]):this.geometry_=new Qe([i])}getGeometry(){return this.geometry_}}const ui={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class ns extends Tt{constructor(e,t,n){super(e),this.coordinate=t,this.mapBrowserEvent=n}}class h_ extends ii{constructor(e){super(),this.on,this.once,this.un,e=e??{},this.box_=new l_(e.className||"ol-dragbox"),this.minArea_=e.minArea??64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition??pu,this.boxEndCondition_=e.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,n){const i=n[0]-t[0],r=n[1]-t[1];return i*i+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.startPixel_&&(this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new ns(ui.BOXDRAG,e.coordinate,e)))}handleUpEvent(e){if(!this.startPixel_)return!1;const t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new ns(t?ui.BOXEND:ui.BOXCANCEL,e.coordinate,e)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new ns(ui.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}setActive(e){e||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new ns(ui.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(e)}setMap(e){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new ns(ui.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(e)}}class c_ extends h_{constructor(e){e=e||{};const t=e.condition?e.condition:Mr;super({condition:t,className:e.className||"ol-dragzoom",minArea:e.minArea}),this.duration_=e.duration!==void 0?e.duration:200,this.out_=e.out!==void 0?e.out:!1}onBoxEnd(e){const n=this.getMap().getView();let i=this.getGeometry();if(this.out_){const r=n.rotatedExtentForGeometry(i),o=n.getResolutionForExtentInternal(r),a=n.getResolution()/o;i=i.clone(),i.scale(a*a)}n.fitInternal(i,{duration:this.duration_,easing:Yi})}}const Nn={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class u_ extends ji{constructor(e){super(),e=e||{},this.defaultCondition_=function(t){return Sl(t)&&xu(t)},this.condition_=e.condition!==void 0?e.condition:this.defaultCondition_,this.duration_=e.duration!==void 0?e.duration:100,this.pixelDelta_=e.pixelDelta!==void 0?e.pixelDelta:128}handleEvent(e){let t=!1;if(e.type==V.KEYDOWN){const n=e.originalEvent,i=n.key;if(this.condition_(e)&&(i==Nn.DOWN||i==Nn.LEFT||i==Nn.RIGHT||i==Nn.UP)){const o=e.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;i==Nn.DOWN?h=-a:i==Nn.LEFT?l=-a:i==Nn.RIGHT?l=a:h=a;const c=[l,h];Qa(c,o.getRotation()),e_(o,c,this.duration_),n.preventDefault(),t=!0}}return!t}}class d_ extends ji{constructor(e){super(),e=e||{},this.condition_=e.condition?e.condition:function(t){return!r_(t)&&xu(t)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:100}handleEvent(e){let t=!1;if(e.type==V.KEYDOWN||e.type==V.KEYPRESS){const n=e.originalEvent,i=n.key;if(this.condition_(e)&&(i==="+"||i==="-")){const r=e.map,o=i==="+"?this.delta_:-this.delta_,a=r.getView();Rl(a,o,void 0,this.duration_),n.preventDefault(),t=!0}}return!t}}const f_=40,g_=300;class __ extends ji{constructor(e){e=e||{},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta!==void 0?e.maxDelta:1,this.duration_=e.duration!==void 0?e.duration:250,this.timeout_=e.timeout!==void 0?e.timeout:80,this.useAnchor_=e.useAnchor!==void 0?e.useAnchor:!0,this.constrainResolution_=e.constrainResolution!==void 0?e.constrainResolution:!1;const t=e.condition?e.condition:Li;this.condition_=e.onFocusOnly?La(mu,t):t,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const e=this.getMap();if(!e)return;e.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(e){if(!this.condition_(e)||e.type!==V.WHEEL)return!0;const n=e.map,i=e.originalEvent;i.preventDefault(),this.useAnchor_&&(this.lastAnchor_=e.pixel);let r=i.deltaY;switch(i.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=f_;break;case WheelEvent.DOM_DELTA_PAGE:r*=g_;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=n.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_?n.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,n),l),!1}handleWheelZoom_(e){const t=e.getView();t.getAnimating()&&t.cancelAnimations();let n=-fe(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(n=n?n>0?1:-1:0),Rl(t,n,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}}class m_ extends ii{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=$i),super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold!==void 0?e.threshold:.3,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){let t=0;const n=this.targetPointers[0],i=this.targetPointers[1],r=Math.atan2(i.clientY-n.clientY,i.clientX-n.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),t=l}this.lastAngle_=r;const o=e.map,a=o.getView();a.getConstraints().rotation!==El&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(vl(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}class p_ extends ii{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=$i),super(t),this.anchor_=null,this.duration_=e.duration!==void 0?e.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1;const n=this.targetPointers[0],i=this.targetPointers[1],r=n.clientX-i.clientX,o=n.clientY-i.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(t=this.lastDistance_/a),this.lastDistance_=a;const l=e.map,h=l.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(vl(this.targetPointers))),l.render(),h.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){const n=e.map.getView(),i=this.lastScaleDelta_>1?1:-1;return n.endInteraction(this.duration_,i),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}function y_(s){s=s||{};const e=new Ve,t=new Qg(-.005,.05,100);return(s.altShiftDragRotate!==void 0?s.altShiftDragRotate:!0)&&e.push(new a_),(s.doubleClickZoom!==void 0?s.doubleClickZoom:!0)&&e.push(new t_({delta:s.zoomDelta,duration:s.zoomDuration})),(s.dragPan!==void 0?s.dragPan:!0)&&e.push(new o_({onFocusOnly:s.onFocusOnly,kinetic:t})),(s.pinchRotate!==void 0?s.pinchRotate:!0)&&e.push(new m_),(s.pinchZoom!==void 0?s.pinchZoom:!0)&&e.push(new p_({duration:s.zoomDuration})),(s.keyboard!==void 0?s.keyboard:!0)&&(e.push(new u_),e.push(new d_({delta:s.zoomDelta,duration:s.zoomDuration}))),(s.mouseWheelZoom!==void 0?s.mouseWheelZoom:!0)&&e.push(new __({onFocusOnly:s.onFocusOnly,duration:s.zoomDuration})),(s.shiftDragZoom!==void 0?s.shiftDragZoom:!0)&&e.push(new c_({duration:s.zoomDuration})),e}const ae={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 Tu extends It{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;const t=Object.assign({},e);typeof e.properties=="object"&&(delete t.properties,Object.assign(t,e.properties)),t[ae.OPACITY]=e.opacity!==void 0?e.opacity:1,te(typeof t[ae.OPACITY]=="number","Layer opacity must be a number"),t[ae.VISIBLE]=e.visible!==void 0?e.visible:!0,t[ae.Z_INDEX]=e.zIndex,t[ae.MAX_RESOLUTION]=e.maxResolution!==void 0?e.maxResolution:1/0,t[ae.MIN_RESOLUTION]=e.minResolution!==void 0?e.minResolution:0,t[ae.MIN_ZOOM]=e.minZoom!==void 0?e.minZoom:-1/0,t[ae.MAX_ZOOM]=e.maxZoom!==void 0?e.maxZoom:1/0,this.className_=t.className!==void 0?t.className:"ol-layer",delete t.className,this.setProperties(t),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){const t=this.state_||{layer:this,managed:e===void 0?!0:e},n=this.getZIndex();return t.opacity=fe(Math.round(this.getOpacity()*100)/100,0,1),t.visible=this.getVisible(),t.extent=this.getExtent(),t.zIndex=n===void 0&&!t.managed?1/0:n,t.maxResolution=this.getMaxResolution(),t.minResolution=Math.max(this.getMinResolution(),0),t.minZoom=this.getMinZoom(),t.maxZoom=this.getMaxZoom(),this.state_=t,t}getLayersArray(e){return $()}getLayerStatesArray(e){return $()}getExtent(){return this.get(ae.EXTENT)}getMaxResolution(){return this.get(ae.MAX_RESOLUTION)}getMinResolution(){return this.get(ae.MIN_RESOLUTION)}getMinZoom(){return this.get(ae.MIN_ZOOM)}getMaxZoom(){return this.get(ae.MAX_ZOOM)}getOpacity(){return this.get(ae.OPACITY)}getSourceState(){return $()}getVisible(){return this.get(ae.VISIBLE)}getZIndex(){return this.get(ae.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(ae.EXTENT,e)}setMaxResolution(e){this.set(ae.MAX_RESOLUTION,e)}setMinResolution(e){this.set(ae.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(ae.MAX_ZOOM,e)}setMinZoom(e){this.set(ae.MIN_ZOOM,e)}setOpacity(e){te(typeof e=="number","Layer opacity must be a number"),this.set(ae.OPACITY,e)}setVisible(e){this.set(ae.VISIBLE,e)}setZIndex(e){this.set(ae.Z_INDEX,e)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}const cn={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class _n extends Tt{constructor(e,t){super(e),this.layer=t}}const Mo={LAYERS:"layers"};class Vi extends Tu{constructor(e){e=e||{};const t=Object.assign({},e);delete t.layers;let n=e.layers;super(t),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Mo.LAYERS,this.handleLayersChanged_),n?Array.isArray(n)?n=new Ve(n.slice(),{unique:!0}):te(typeof n.getArray=="function","Expected `layers` to be an array or a `Collection`"):n=new Ve(void 0,{unique:!0}),this.setLayers(n)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(ue),this.layersListenerKeys_.length=0;const e=this.getLayers();this.layersListenerKeys_.push(J(e,Re.ADD,this.handleLayersAdd_,this),J(e,Re.REMOVE,this.handleLayersRemove_,this));for(const n in this.listenerKeys_)this.listenerKeys_[n].forEach(ue);Qn(this.listenerKeys_);const t=e.getArray();for(let n=0,i=t.length;n{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t;const n=this.getMapInternal();!e&&n&&(e=n.getView()),e instanceof qt?t={viewState:e.getState(),extent:e.calculateExtent()}:t=e,!t.layerStatesArray&&n&&(t.layerStatesArray=n.getLayerGroup().getLayerStatesArray());let i;if(t.layerStatesArray){if(i=t.layerStatesArray.find(o=>o.layer===this),!i)return!1}else i=this.getLayerState();const r=this.getExtent();return wl(i,t.viewState)&&(!r||Ee(r,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];const t=this.getSource()?.getAttributions();if(!t)return[];const n=e instanceof qt?e.getViewStateAndExtent():e;let i=t(n);return Array.isArray(i)||(i=[i]),i}render(e,t){const n=this.getRenderer();return n.prepareFrame(e)?(this.rendered=!0,n.renderFrame(e,t)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,t){}renderDeferred(e){const t=this.getRenderer();t&&t.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(ae.MAP,e)}getMapInternal(){return this.get(ae.MAP)}setMap(e){this.mapPrecomposeKey_&&(ue(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(ue(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=J(e,Fe.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=J(this,V.CHANGE,e.render,e),this.changed())}handlePrecompose_(e){const t=e.frameState.layerStatesArray,n=this.getLayerState(!1);te(!t.some(i=>i.layer===n.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),t.push(n)}setSource(e){this.set(ae.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function wl(s,e){if(!s.visible)return!1;const t=e.resolution;if(t=s.maxResolution)return!1;const n=e.zoom;return n>s.minZoom&&n<=s.maxZoom}function Cu(s,e,t=0,n=s.length-1,i=x_){for(;n>t;){if(n-t>600){const l=n-t+1,h=e-t+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(t,Math.floor(e-h*u/l+d)),g=Math.min(n,Math.floor(e+(l-h)*u/l+d));Cu(s,e,f,g,i)}const r=s[e];let o=t,a=n;for(is(s,t,e),i(s[n],r)>0&&is(s,t,n);o0;)a--}i(s[t],r)===0?is(s,t,a):(a++,is(s,a,n)),a<=e&&(t=a+1),e<=a&&(n=a-1)}}function is(s,e,t){const n=s[e];s[e]=s[t],s[t]=n}function x_(s,e){return se?1:0}let Pl=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const n=[];if(!nr(e,t))return n;const i=this.toBBox,r=[];for(;t;){for(let o=0;o=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(i,r,t)}_split(e,t){const n=e[t],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const o=this._chooseSplitIndex(n,r,i),a=Ti(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,di(n,this.toBBox),di(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(n,a)}_splitRoot(e,t){this.data=Ti([e,t]),this.data.height=e.height+1,this.data.leaf=!1,di(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let i,r=1/0,o=1/0;for(let a=t;a<=n-t;a++){const l=ls(e,0,a,this.toBBox),h=ls(e,a,n,this.toBBox),c=S_(l,h),u=Do(l)+Do(h);c=t;h--){const c=e.children[h];hs(a,e.leaf?r(c):c),l+=tr(a)}return l}_adjustParentBBoxes(e,t,n){for(let i=n;i>=0;i--)hs(t[i],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():di(e[t],this.toBBox)}};function E_(s,e,t){if(!t)return e.indexOf(s);for(let n=0;n=s.minX&&e.maxY>=s.minY}function Ti(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function kh(s,e,t,n,i){const r=[e,t];for(;r.length;){if(t=r.pop(),e=r.pop(),t-e<=n)continue;const o=e+Math.ceil((t-e)/n/2)*n;Cu(s,o,e,t,i),r.push(e,o,o,t)}}const Il=[NaN,NaN,NaN,0];let No;function v_(){return No||(No=ve(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),No}const w_=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,P_=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,I_=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,L_=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function ir(s,e){return s.endsWith("%")?Number(s.substring(0,s.length-1))/e:Number(s)}function gs(s){throw new Error('failed to parse "'+s+'" as color')}function Ru(s){if(s.toLowerCase().startsWith("rgb")){const r=s.match(P_)||s.match(w_)||s.match(I_);if(r){const o=r[4],a=100/255;return[fe(ir(r[1],a)+.5|0,0,255),fe(ir(r[2],a)+.5|0,0,255),fe(ir(r[3],a)+.5|0,0,255),o!==void 0?fe(ir(o,100),0,1):1]}gs(s)}if(s.startsWith("#")){if(L_.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 Uo(s){return s>.2068965?Math.pow(s,3):(s-4/29)*(108/841)}function Bo(s){return s>10.314724?Math.pow((s+14.025)/269.025,2.4):s/3294.6}function zo(s){return s>.0088564?Math.pow(s,1/3):s/(108/841)+4/29}function Uh(s){const e=Bo(s[0]),t=Bo(s[1]),n=Bo(s[2]),i=zo(e*.222488403+t*.716873169+n*.06060791),r=500*(zo(e*.452247074+t*.399439023+n*.148375274)-i),o=200*(i-zo(e*.016863605+t*.117638439+n*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*i-16,Math.sqrt(r*r+o*o),a<0?a+360:a,s[3]]}function M_(s){const e=(s[0]+16)/116,t=s[1],n=s[2]*Math.PI/180,i=Uo(e),r=Uo(e+t/500*Math.cos(n)),o=Uo(e-t/200*Math.sin(n)),a=ko(r*3.021973625-i*1.617392459-o*.404875592),l=ko(r*-.943766287+i*1.916279586+o*.027607165),h=ko(r*.069407491-i*.22898585+o*1.159737864);return[fe(a+.5|0,0,255),fe(l+.5|0,0,255),fe(h+.5|0,0,255),s[3]]}function Ll(s){if(s==="none")return Il;if(ss.hasOwnProperty(s))return ss[s];if(Go>=F_){let t=0;for(const n in ss)(t++&3)===0&&(delete ss[n],--Go)}const e=Ru(s);e.length!==4&&gs(s);for(const t of e)isNaN(t)&&gs(s);return ss[s]=e,++Go,e}function Et(s){return Array.isArray(s)?s:Ll(s)}function Al(s){let e=s[0];e!=(e|0)&&(e=e+.5|0);let t=s[1];t!=(t|0)&&(t=t+.5|0);let n=s[2];n!=(n|0)&&(n=n+.5|0);const i=s[3]===void 0?1:Math.round(s[3]*1e3)/1e3;return"rgba("+e+","+t+","+n+","+i+")"}function Bh(s){return s[0]>0&&s[1]>0}function D_(s,e,t){return t===void 0&&(t=[0,0]),t[0]=s[0]*e+.5|0,t[1]=s[1]*e+.5|0,t}function $e(s,e){return Array.isArray(s)?s:(e===void 0?e=[s,s]:(e[0]=s,e[1]=s),e)}let si=0;const Se=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"},G_={[C.Get]:Y(q(1,1/0),zh),[C.Var]:Y(q(1,1),k_),[C.Has]:Y(q(1,1/0),zh),[C.Id]:Y(U_,fi),[C.Concat]:Y(q(2,1/0),re(Pe)),[C.GeometryType]:Y(B_,fi),[C.LineMetric]:Y(fi),[C.Resolution]:Y($o,fi),[C.Zoom]:Y($o,fi),[C.Time]:Y($o,fi),[C.Any]:Y(q(2,1/0),re(Se)),[C.All]:Y(q(2,1/0),re(Se)),[C.Not]:Y(q(1,1),re(Se)),[C.Equal]:Y(q(2,2),re(sr)),[C.NotEqual]:Y(q(2,2),re(sr)),[C.GreaterThan]:Y(q(2,2),re(N)),[C.GreaterThanOrEqualTo]:Y(q(2,2),re(N)),[C.LessThan]:Y(q(2,2),re(N)),[C.LessThanOrEqualTo]:Y(q(2,2),re(N)),[C.Multiply]:Y(q(2,1/0),$h),[C.Coalesce]:Y(q(2,1/0),$h),[C.Divide]:Y(q(2,2),re(N)),[C.Add]:Y(q(2,1/0),re(N)),[C.Subtract]:Y(q(2,2),re(N)),[C.Clamp]:Y(q(3,3),re(N)),[C.Mod]:Y(q(2,2),re(N)),[C.Pow]:Y(q(2,2),re(N)),[C.Abs]:Y(q(1,1),re(N)),[C.Floor]:Y(q(1,1),re(N)),[C.Ceil]:Y(q(1,1),re(N)),[C.Round]:Y(q(1,1),re(N)),[C.Sin]:Y(q(1,1),re(N)),[C.Cos]:Y(q(1,1),re(N)),[C.Atan]:Y(q(1,2),re(N)),[C.Sqrt]:Y(q(1,1),re(N)),[C.Match]:Y(q(4,1/0),Xh,$_),[C.Between]:Y(q(3,3),re(N)),[C.Interpolate]:Y(q(6,1/0),Xh,X_),[C.Case]:Y(q(3,1/0),z_,W_),[C.In]:Y(q(2,2),Y_),[C.Number]:Y(q(1,1/0),re(sr)),[C.String]:Y(q(1,1/0),re(sr)),[C.Array]:Y(q(1,1/0),re(N)),[C.Color]:Y(q(1,4),re(N)),[C.Band]:Y(q(1,3),re(N)),[C.Palette]:Y(q(2,2),j_),[C.ToString]:Y(q(1,1),re(Se|N|Pe|ge))};function zh(s,e,t){const n=s.length-1,i=new Array(n);for(let r=0;re){const a=e===1/0?`${s} or more`:`${s} to ${e}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function $h(s,e,t){const n=s.length-1,i=new Array(n);for(let r=0;rn.featureId;case C.GeometryType:return n=>n.geometryType;case C.Concat:{const n=s.args.map(i=>vt(i));return i=>"".concat(...n.map(r=>r(i).toString()))}case C.Resolution:return n=>n.resolution;case C.Any:case C.All:case C.Between:case C.In:case C.Not:return q_(s);case C.Equal:case C.NotEqual:case C.LessThan:case C.LessThanOrEqualTo:case C.GreaterThan:case C.GreaterThanOrEqualTo:return H_(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 J_(s);case C.Case:return Q_(s);case C.Match:return em(s);case C.Interpolate:return tm(s);case C.ToString:return nm(s);default:throw new Error(`Unsupported operator ${t}`)}}function Z_(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r{for(let o=0;o{for(let o=0;o{const r=s.args;let o=i.properties[n];for(let a=1,l=r.length;ai.variables[n];case C.Has:return i=>{const r=s.args;if(!(n in i.properties))return!1;let o=i.properties[n];for(let a=1,l=r.length;an(r)===i(r);case C.NotEqual:return r=>n(r)!==i(r);case C.LessThan:return r=>n(r)n(r)<=i(r);case C.GreaterThan:return r=>n(r)>i(r);case C.GreaterThanOrEqualTo:return r=>n(r)>=i(r);default:throw new Error(`Unsupported comparison operator ${t}`)}}function q_(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r{for(let o=0;o{for(let o=0;o{const o=i[0](r),a=i[1](r),l=i[2](r);return o>=a&&o<=l};case C.In:return r=>{const o=i[0](r);for(let a=1;a!i[0](r);default:throw new Error(`Unsupported logical operator ${t}`)}}function J_(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r{let o=1;for(let a=0;ai[0](r)/i[1](r);case C.Add:return r=>{let o=0;for(let a=0;ai[0](r)-i[1](r);case C.Clamp:return r=>{const o=i[0](r),a=i[1](r);if(ol?l:o};case C.Mod:return r=>i[0](r)%i[1](r);case C.Pow:return r=>Math.pow(i[0](r),i[1](r));case C.Abs:return r=>Math.abs(i[0](r));case C.Floor:return r=>Math.floor(i[0](r));case C.Ceil:return r=>Math.ceil(i[0](r));case C.Round:return r=>Math.round(i[0](r));case C.Sin:return r=>Math.sin(i[0](r));case C.Cos:return r=>Math.cos(i[0](r));case C.Atan:return n===2?r=>Math.atan2(i[0](r),i[1](r)):r=>Math.atan(i[0](r));case C.Sqrt:return r=>Math.sqrt(i[0](r));default:throw new Error(`Unsupported numeric operator ${t}`)}}function Q_(s,e){const t=s.args.length,n=new Array(t);for(let i=0;i{for(let r=0;r{const r=n[0](i);for(let o=1;o{const r=n[0](i),o=n[1](i);let a,l;for(let h=2;h=o)return h===2?u:d?im(r,o,a,l,c,u):us(r,o,a,l,c,u);a=c,l=u}return l}}function nm(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r{const o=i[0](r);return s.args[0].type===ge?Al(o):o.toString()};default:throw new Error(`Unsupported convert operator ${t}`)}}function us(s,e,t,n,i,r){const o=i-t;if(o===0)return n;const a=e-t,l=s===1?a/o:(Math.pow(s,a)-1)/(Math.pow(s,o)-1);return n+l*(r-n)}function im(s,e,t,n,i,r){if(i-t===0)return n;const a=Uh(n),l=Uh(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[us(s,e,t,a[0],i,l[0]),us(s,e,t,a[1],i,l[1]),a[2]+us(s,e,t,0,i,h),us(s,e,t,n[3],i,r[3])];return M_(c)}const U={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};class sm extends Ms{constructor(e,t,n,i){super(),this.extent=e,this.pixelRatio_=n,this.resolution=t,this.state=typeof i=="function"?U.IDLE:i,this.image_=null,this.loader=typeof i=="function"?i:null}changed(){this.dispatchEvent(V.CHANGE)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==U.IDLE&&this.loader){this.state=U.LOADING,this.changed();const e=this.getResolution(),t=Array.isArray(e)?e[0]:e;Dc(()=>this.loader(this.getExtent(),t,this.getPixelRatio())).then(n=>{"image"in n&&(this.image_=n.image),"extent"in n&&(this.extent=n.extent),"resolution"in n&&(this.resolution=n.resolution),"pixelRatio"in n&&(this.pixelRatio_=n.pixelRatio),(n instanceof HTMLImageElement||mf&&n instanceof ImageBitmap||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement)&&(this.image_=n),this.state=U.LOADED}).catch(n=>{this.state=U.ERROR,console.error(n)}).finally(()=>this.changed())}}setImage(e){this.image_=e}setResolution(e){this.resolution=e}}function rm(s,e,t){const n=s;let i=!0,r=!1,o=!1;const a=[Sr(n,V.LOAD,function(){o=!0,r||e()})];return n.src&&Nc?(r=!0,n.decode().then(function(){i&&e()}).catch(function(l){i&&(o?e():t())})):a.push(Sr(n,V.ERROR,t)),function(){i=!1,a.forEach(ue)}}function om(s,e){return new Promise((t,n)=>{function i(){o(),t(s)}function r(){o(),n(new Error("Image load error"))}function o(){s.removeEventListener("load",i),s.removeEventListener("error",r)}s.addEventListener("load",i),s.addEventListener("error",r)})}function am(s,e){return e&&(s.src=e),s.src&&Nc?new Promise((t,n)=>s.decode().then(()=>t(s)).catch(i=>s.complete&&s.width?t(s):n(i))):om(s)}class lm{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(const t in this.cache_){const n=this.cache_[t];(e++&3)===0&&!n.hasListener()&&(delete this.cache_[t],delete this.patternCache_[t],--this.cacheSize_)}}}get(e,t,n){const i=Xo(e,t,n);return i in this.cache_?this.cache_[i]:null}getPattern(e,t,n){const i=Xo(e,t,n);return i in this.patternCache_?this.patternCache_[i]:null}set(e,t,n,i,r){const o=Xo(e,t,n),a=o in this.cache_;this.cache_[o]=i,r&&(i.getImageState()===U.IDLE&&i.load(),i.getImageState()===U.LOADING?i.ready().then(()=>{this.patternCache_[o]=Fr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[o]=Fr().createPattern(i.getImage(1),"repeat")),a||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}}function Xo(s,e,t){const n=t?Et(t):"null";return e+":"+s+":"+n}const mt=new lm;let rs=null;class wu extends Ms{constructor(e,t,n,i,r){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=n,this.canvas_={},this.color_=r,this.imageState_=i===void 0?U.IDLE:i,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===U.LOADED){rs||(rs=ve(1,1,void 0,{willReadFrequently:!0})),rs.drawImage(this.image_,0,0);try{rs.getImageData(0,0,1,1),this.tainted_=!1}catch{rs=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(V.CHANGE)}handleImageError_(){this.imageState_=U.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=U.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const e=this.size_[0],t=this.size_[1],n=ve(e,t);n.fillRect(0,0,e,t),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===U.IDLE){this.image_||this.initializeImage_(),this.imageState_=U.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&am(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==U.LOADED)return;const t=this.image_,n=ve(Math.ceil(t.width*e),Math.ceil(t.height*e)),i=n.canvas;n.scale(e,e),n.drawImage(t,0,0),n.globalCompositeOperation="multiply",n.fillStyle=A_(this.color_),n.fillRect(0,0,i.width/e,i.height/e),n.globalCompositeOperation="destination-in",n.drawImage(t,0,0),this.canvas_[e]=i}ready(){return this.ready_||(this.ready_=new Promise(e=>{if(this.imageState_===U.LOADED||this.imageState_===U.ERROR)e();else{const t=()=>{(this.imageState_===U.LOADED||this.imageState_===U.ERROR)&&(this.removeEventListener(V.CHANGE,t),e())};this.addEventListener(V.CHANGE,t)}})),this.ready_}}function Dr(s,e,t,n,i,r){let o=e===void 0?void 0:mt.get(e,t,i);return o||(o=new wu(s,s&&"src"in s?s.src||void 0:e,t,n,i),mt.set(e,t,i,o,r)),r&&o&&!mt.getPattern(e,t,i)&&mt.set(e,t,i,o,r),o}function Dt(s){return s?Array.isArray(s)?Al(s):typeof s=="object"&&"src"in s?hm(s):s:null}function hm(s){if(!s.offset||!s.size)return mt.getPattern(s.src,"anonymous",s.color);const e=s.src+":"+s.offset,t=mt.getPattern(e,void 0,s.color);if(t)return t;const n=mt.get(s.src,"anonymous",null);if(n.getImageState()!==U.LOADED)return null;const i=ve(s.size[0],s.size[1]);return i.drawImage(n.getImage(1),s.offset[0],s.offset[1],s.size[0],s.size[1],0,0,s.size[0],s.size[1]),Dr(i.canvas,e,void 0,U.LOADED,s.color,!0),mt.getPattern(e,void 0,s.color)}const Pu="10px sans-serif",Ke="#000",Ui="round",tn=[],nn=0,Bi="round",vs=10,ws="#000",Ps="center",Or="middle",zn=[0,0,0,0],Is=1,Ci=new It;let os=null,Wh;const Aa={},cm=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function um(s,e,t){return`${s} ${e} 16px "${t}"`}const dm=(function(){let e,t;async function n(r){await t.ready;const o=await t.load(r);if(o.length===0)return!1;const a=Pa(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=wa[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function i(){await t.ready;let r=!0;const o=Ci.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 n(h)?(Qn(Aa),Ci.set(h,100)):(c+=10,Ci.set(h,c,!0),c<100&&(r=!1)))}e=void 0,r||(e=setTimeout(i,100))}return async function(r){t||(t=rt?self.fonts:document.fonts);const o=Pa(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(cm.has(h))continue;const c=um(o.style,o.weight,h);Ci.get(c)===void 0&&(Ci.set(c,0,!0),l=!0)}l&&(clearTimeout(e),e=setTimeout(i,100))}})(),fm=(function(){let s;return function(e){let t=Aa[e];if(t==null){if(rt){const n=Pa(e),i=Iu(e,"Žg");t=(isNaN(Number(n.lineHeight))?1.2:Number(n.lineHeight))*(i.actualBoundingBoxAscent+i.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=e,document.body.appendChild(s),t=s.offsetHeight,document.body.removeChild(s);Aa[e]=t}return t}})();function Iu(s,e){return os||(os=ve(1,1)),s!=Wh&&(os.font=s,Wh=os.font),os.measureText(e)}function Lu(s,e){return Iu(s,e).width}function Yh(s,e,t){if(e in t)return t[e];const n=e.split(` `).reduce((i,r)=>Math.max(i,Lu(s,r)),0);return t[e]=n,n}function gm(s,e){const t=[],n=[],i=[];let r=0,o=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){const u=e[h];if(u===` `||h===c){r=Math.max(r,o),i.push(o),o=0,a+=l,l=0;continue}const d=e[h+1]||s.font,f=Lu(d,u);t.push(f),o+=f;const g=fm(d);n.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:t,heights:n,lineWidths:i}}function _m(s,e,t,n,i,r,o,a,l,h,c){s.save(),t!==1&&(s.globalAlpha===void 0?s.globalAlpha=u=>u.globalAlpha*=t:s.globalAlpha*=t),e&&s.transform.apply(s,e),n.contextInstructions?(s.translate(l,h),s.scale(c[0],c[1]),mm(n,s)):c[0]<0||c[1]<0?(s.translate(l,h),s.scale(c[0],c[1]),s.drawImage(n,i,r,o,a,0,0,o,a)):s.drawImage(n,i,r,o,a,l,h,o*c[0],a*c[1]),s.restore()}function mm(s,e){const t=s.contextInstructions;for(let n=0,i=t.length;nthis.imageState_=U.LOADED),this.render()}clone(){const e=this.getScale(),t=new ho({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return t.setOpacity(this.getOpacity()),t}getAnchor(){const e=this.size_,t=this.getDisplacement(),n=this.getScaleArray();return[e[0]/2-t[0]/n[0],e[1]/2+t[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(e){const t=this.fill_?.getKey(),n=`${e},${this.angle_},${this.radius},${this.radius2_},${this.points_},${t}`+Object.values(this.renderOptions_).join(",");let i=mt.get(n,null,null)?.getImage(1);if(!i){const r=this.renderOptions_,o=Math.ceil(r.size*e),a=ve(o,o);this.draw_(r,a,e),i=a.canvas,mt.set(n,null,null,new wu(i,void 0,null,U.LOADED,null))}return i}getPixelRatio(e){return e}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,t,n){if(t===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return t;let i=this.radius,r=this.radius2_===void 0?i:this.radius2_;if(i{this.patternImage_=null}),t.getImageState()===U.IDLE&&t.load(),t.getImageState()===U.LOADING&&(this.patternImage_=t)}this.color_=e}getKey(){const e=this.getColor();return e?e instanceof CanvasPattern||e instanceof CanvasGradient?D(e):typeof e=="object"&&"src"in e?e.src+":"+e.offset:Et(e).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function jh(s,e,t,n){return t!==void 0&&n!==void 0?[t/s,n/e]:t!==void 0?t/s:n!==void 0?n/e:1}class Zi extends lo{constructor(e){e=e||{};const t=e.opacity!==void 0?e.opacity:1,n=e.rotation!==void 0?e.rotation:0,i=e.scale!==void 0?e.scale:1,r=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:t,rotation:n,scale:i,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:r,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;const o=e.img!==void 0?e.img:null;let a=e.src;te(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||D(o)),te(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),te(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(e.src!==void 0?l=U.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?U.LOADED:U.IDLE:l=U.LOADING:l=U.LOADED),this.color_=e.color!==void 0?Et(e.color):null,this.iconImage_=Dr(o,a,this.crossOrigin_,l,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,this.initialOptions_,e.width!==void 0||e.height!==void 0){let h,c;if(e.size)[h,c]=e.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=e;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(jh(f[0],f[1],e.width,e.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(jh(h,c,e.width,e.height))}}clone(){let e,t,n;return this.initialOptions_?(t=this.initialOptions_.width,n=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new Zi({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:t,height:n,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;const i=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!i)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=i[0]),this.anchorYUnits_=="fraction"&&(e[1]*=i[1])}if(this.anchorOrigin_!="top-left"){if(!i)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+i[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+i[1])}this.normalizedAnchor_=e}const t=this.getDisplacement(),n=this.getScaleArray();return[e[0]-t[0]/n[0],e[1]+t[1]/n[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){const t=this.getSize(),n=this.iconImage_.getSize();if(!t||!n)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=n[0]-t[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=n[1]-t[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(e){this.iconImage_=Dr(null,e,this.crossOrigin_,U.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==U.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){const e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==U.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(V.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(V.CHANGE,e)}ready(){return this.iconImage_.ready()}}class Gt{constructor(e){e=e||{},this.color_=e.color!==void 0?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash!==void 0?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}clone(){const e=this.getColor();return new Gt({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),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(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setWidth(e){this.width_=e}}class Oe{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=Vh,e.geometry!==void 0&&this.setGeometry(e.geometry),this.fill_=e.fill!==void 0?e.fill:null,this.image_=e.image!==void 0?e.image:null,this.renderer_=e.renderer!==void 0?e.renderer:null,this.hitDetectionRenderer_=e.hitDetectionRenderer!==void 0?e.hitDetectionRenderer:null,this.stroke_=e.stroke!==void 0?e.stroke:null,this.text_=e.text!==void 0?e.text:null,this.zIndex_=e.zIndex}clone(){let e=this.getGeometry();return e&&typeof e=="object"&&(e=e.clone()),new Oe({geometry:e??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(e){this.renderer_=e}setHitDetectionRenderer(e){this.hitDetectionRenderer_=e}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(e){this.fill_=e}getImage(){return this.image_}setImage(e){this.image_=e}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e}getText(){return this.text_}setText(e){this.text_=e}getZIndex(){return this.zIndex_}setGeometry(e){typeof e=="function"?this.geometryFunction_=e:typeof e=="string"?this.geometryFunction_=function(t){return t.get(e)}:e?e!==void 0&&(this.geometryFunction_=function(){return e}):this.geometryFunction_=Vh,this.geometry_=e}setZIndex(e){this.zIndex_=e}}function pm(s){let e;if(typeof s=="function")e=s;else{let t;Array.isArray(s)?t=s:(te(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),t=[s]),e=function(){return t}}return e}let Wo=null;function Au(s,e){if(!Wo){const t=new wt({color:"rgba(255,255,255,0.4)"}),n=new Gt({color:"#3399CC",width:1.25});Wo=[new Oe({image:new Bs({fill:t,stroke:n,radius:5}),fill:t,stroke:n})]}return Wo}function Dl(){const s={},e=[255,255,255,1],t=[0,153,255,1],n=3;return s.Polygon=[new Oe({fill:new wt({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new Oe({stroke:new Gt({color:e,width:n+2})}),new Oe({stroke:new Gt({color:t,width:n})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new Oe({image:new Bs({radius:n*2,fill:new wt({color:t}),stroke:new Gt({color:e,width:n/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function Vh(s){return s.getGeometry()}const ym="#333";class zs{constructor(e){e=e||{},this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.keepUpright_=e.keepUpright,this.scale_=e.scale,this.scaleArray_=$e(e.scale!==void 0?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.justify_=e.justify,this.repeat_=e.repeat,this.textBaseline_=e.textBaseline,this.fill_=e.fill!==void 0?e.fill:new wt({color:ym}),this.maxAngle_=e.maxAngle!==void 0?e.maxAngle:Math.PI/4,this.placement_=e.placement!==void 0?e.placement:"point",this.overflow_=!!e.overflow,this.stroke_=e.stroke!==void 0?e.stroke:null,this.offsetX_=e.offsetX!==void 0?e.offsetX:0,this.offsetY_=e.offsetY!==void 0?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=e.padding===void 0?null:e.padding,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new zs({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof wt?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(e){this.overflow_=e}setFont(e){this.font_=e}setMaxAngle(e){this.maxAngle_=e}setOffsetX(e){this.offsetX_=e}setOffsetY(e){this.offsetY_=e}setPlacement(e){this.placement_=e}setRepeat(e){this.repeat_=e}setRotateWithView(e){this.rotateWithView_=e}setKeepUpright(e){this.keepUpright_=e}setFill(e){this.fill_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=$e(e!==void 0?e:1)}setStroke(e){this.stroke_=e}setText(e){this.text_=e}setTextAlign(e){this.textAlign_=e}setJustify(e){this.justify_=e}setTextBaseline(e){this.textBaseline_=e}setBackgroundFill(e){this.backgroundFill_=e}setBackgroundStroke(e){this.backgroundStroke_=e}setPadding(e){this.padding_=e}}function xm(s){return!0}function Em(s){const e=bl(),t=Tm(s,e),n=vu();return function(i,r){if(n.properties=i.getPropertiesInternal(),n.resolution=r,e.featureId){const o=i.getId();o!==void 0?n.featureId=o:n.featureId=null}return e.geometryType&&(n.geometryType=Ml(i.getGeometry())),t(n)}}function Zh(s){const e=bl(),t=s.length,n=new Array(t);for(let o=0;onull;n=Ol(s,e+"fill-color",t)}if(!n)return null;const i=new wt;return function(r){const o=n(r);return o===Il?null:(i.setColor(o),i)}}function As(s,e,t){const n=qe(s,e+"stroke-width",t),i=Ol(s,e+"stroke-color",t);if(!n&&!i)return null;const r=Kt(s,e+"stroke-line-cap",t),o=Kt(s,e+"stroke-line-join",t),a=Fu(s,e+"stroke-line-dash",t),l=qe(s,e+"stroke-line-dash-offset",t),h=qe(s,e+"stroke-miter-limit",t),c=new Gt;return function(u){if(i){const d=i(u);if(d===Il)return null;c.setColor(d)}if(n&&c.setWidth(n(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 Cm(s,e){const t="text-",n=Kt(s,t+"value",e);if(!n)return null;const i=Ls(s,t,e),r=Ls(s,t+"background-",e),o=As(s,t,e),a=As(s,t+"background-",e),l=Kt(s,t+"font",e),h=qe(s,t+"max-angle",e),c=qe(s,t+"offset-x",e),u=qe(s,t+"offset-y",e),d=Ai(s,t+"overflow",e),f=Kt(s,t+"placement",e),g=qe(s,t+"repeat",e),m=co(s,t+"scale",e),_=Ai(s,t+"rotate-with-view",e),p=qe(s,t+"rotation",e),y=Kt(s,t+"align",e),E=Kt(s,t+"justify",e),x=Kt(s,t+"baseline",e),T=Ai(s,t+"keep-upright",e),R=Fu(s,t+"padding",e),S=uo(s,t+"declutter-mode"),v=new zs({declutterMode:S});return function(w){if(v.setText(n(w)),i&&v.setFill(i(w)),r&&v.setBackgroundFill(r(w)),o&&v.setStroke(o(w)),a&&v.setBackgroundStroke(a(w)),l&&v.setFont(l(w)),h&&v.setMaxAngle(h(w)),c&&v.setOffsetX(c(w)),u&&v.setOffsetY(u(w)),d&&v.setOverflow(d(w)),f){const I=f(w);if(I!=="point"&&I!=="line")throw new Error("Expected point or line for text-placement");v.setPlacement(I)}if(g&&v.setRepeat(g(w)),m&&v.setScale(m(w)),_&&v.setRotateWithView(_(w)),p&&v.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");v.setTextAlign(I)}if(E){const I=E(w);if(I!=="left"&&I!=="right"&&I!=="center")throw new Error("Expected left, right, or center for text-justify");v.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");v.setTextBaseline(I)}return R&&v.setPadding(R(w)),T&&v.setKeepUpright(T(w)),v}}function Rm(s,e){return"icon-src"in s?Sm(s,e):"shape-points"in s?vm(s,e):"circle-radius"in s?wm(s,e):null}function Sm(s,e){const t="icon-",n=t+"src",i=bu(s[n],n),r=Nr(s,t+"anchor",e),o=co(s,t+"scale",e),a=qe(s,t+"opacity",e),l=Nr(s,t+"displacement",e),h=qe(s,t+"rotation",e),c=Ai(s,t+"rotate-with-view",e),u=Hh(s,t+"anchor-origin"),d=qh(s,t+"anchor-x-units"),f=qh(s,t+"anchor-y-units"),g=Fm(s,t+"color"),m=Lm(s,t+"cross-origin"),_=Am(s,t+"offset"),p=Hh(s,t+"offset-origin"),y=Gr(s,t+"width"),E=Gr(s,t+"height"),x=Im(s,t+"size"),T=uo(s,t+"declutter-mode"),R=new Zi({src:i,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:m,offset:_,offsetOrigin:p,height:E,width:y,size:x,declutterMode:T});return function(S){return a&&R.setOpacity(a(S)),l&&R.setDisplacement(l(S)),h&&R.setRotation(h(S)),c&&R.setRotateWithView(c(S)),o&&R.setScale(o(S)),r&&R.setAnchor(r(S)),R}}function vm(s,e){const t="shape-",n=t+"points",i=t+"radius",r=ba(s[n],n),o=ba(s[i],i),a=Ls(s,t,e),l=As(s,t,e),h=co(s,t+"scale",e),c=Nr(s,t+"displacement",e),u=qe(s,t+"rotation",e),d=Ai(s,t+"rotate-with-view",e),f=Gr(s,t+"radius2"),g=Gr(s,t+"angle"),m=uo(s,t+"declutter-mode"),_=new ho({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 wm(s,e){const t="circle-",n=Ls(s,t,e),i=As(s,t,e),r=qe(s,t+"radius",e),o=co(s,t+"scale",e),a=Nr(s,t+"displacement",e),l=qe(s,t+"rotation",e),h=Ai(s,t+"rotate-with-view",e),c=uo(s,t+"declutter-mode"),u=new Bs({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),n&&u.setFill(n(d)),i&&u.setStroke(i(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function qe(s,e,t){if(!(e in s))return;const n=on(s[e],N,t);return function(i){return ba(n(i),e)}}function Kt(s,e,t){if(!(e in s))return null;const n=on(s[e],Pe,t);return function(i){return bu(n(i),e)}}function Pm(s,e,t){const n=Kt(s,e+"pattern-src",t),i=Kh(s,e+"pattern-offset",t),r=Kh(s,e+"pattern-size",t),o=Ol(s,e+"color",t);return function(a){return{src:n(a),offset:i&&i(a),size:r&&r(a),color:o&&o(a)}}}function Ai(s,e,t){if(!(e in s))return null;const n=on(s[e],Se,t);return function(i){const r=n(i);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${e}`);return r}}function Ol(s,e,t){if(!(e in s))return null;const n=on(s[e],ge,t);return function(i){return Mu(n(i),e)}}function Fu(s,e,t){if(!(e in s))return null;const n=on(s[e],et,t);return function(i){return $s(n(i),e)}}function Nr(s,e,t){if(!(e in s))return null;const n=on(s[e],et,t);return function(i){const r=$s(n(i),e);if(r.length!==2)throw new Error(`Expected two numbers for ${e}`);return r}}function Kh(s,e,t){if(!(e in s))return null;const n=on(s[e],et,t);return function(i){return Du(n(i),e)}}function co(s,e,t){if(!(e in s))return null;const n=on(s[e],et|N,t);return function(i){return bm(n(i),e)}}function Gr(s,e){const t=s[e];if(t!==void 0){if(typeof t!="number")throw new Error(`Expected a number for ${e}`);return t}}function Im(s,e){const t=s[e];if(t!==void 0){if(typeof t=="number")return $e(t);if(!Array.isArray(t))throw new Error(`Expected a number or size array for ${e}`);if(t.length!==2||typeof t[0]!="number"||typeof t[1]!="number")throw new Error(`Expected a number or size array for ${e}`);return t}}function Lm(s,e){const t=s[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);return t}}function Hh(s,e){const t=s[e];if(t!==void 0){if(t!=="bottom-left"&&t!=="bottom-right"&&t!=="top-left"&&t!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return t}}function qh(s,e){const t=s[e];if(t!==void 0){if(t!=="pixels"&&t!=="fraction")throw new Error(`Expected pixels or fraction for ${e}`);return t}}function Am(s,e){const t=s[e];if(t!==void 0)return $s(t,e)}function uo(s,e){const t=s[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);if(t!=="declutter"&&t!=="obstacle"&&t!=="none")throw new Error(`Expected declutter, obstacle, or none for ${e}`);return t}}function Fm(s,e){const t=s[e];if(t!==void 0)return Mu(t,e)}function $s(s,e){if(!Array.isArray(s))throw new Error(`Expected an array for ${e}`);const t=s.length;for(let n=0;n4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return t}function Du(s,e){const t=$s(s,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function bm(s,e){return typeof s=="number"?s:Du(s,e)}const Jh={RENDER_ORDER:"renderOrder"};class Ki extends Us{constructor(e){e=e||{};const t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Jh.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){const n=this.getDeclutter();n in e.declutter||(e.declutter[n]=new Pl(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(Jh.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?Au:e;const t=Mm(e);this.styleFunction_=e===null?void 0:pm(t),this.changed()}setDeclutter(e){this.declutter_=e?String(e):void 0,this.changed()}}function Mm(s){if(s===void 0)return Au;if(!s)return null;if(typeof s=="function"||s instanceof Oe)return s;if(!Array.isArray(s))return Zh([s]);if(s.length===0)return[];const e=s.length,t=s[0];if(t instanceof Oe){const i=new Array(e);for(let r=0;r=0;--T){const R=m[T],S=R.layer;if(S.hasRenderer()&&wl(R,c)&&a.call(l,S)){const v=S.getRenderer(),w=S.getSource();if(v&&w){const I=w.getWrapX()?f:e,F=u.bind(null,R.managed);y[0]=I[0]+g[x][0],y[1]=I[1]+g[x][1],h=v.forEachFeatureAtCoordinate(y,t,n,F,p)}if(h)return h}}if(p.length===0)return;const E=1/p.length;return p.forEach((x,T)=>x.distanceSq+=T*E),p.sort((x,T)=>x.distanceSq-T.distanceSq),p.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(e,t,n,i,r,o){return this.forEachFeatureAtCoordinate(e,t,n,i,wn,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(e){$()}scheduleExpireIconCache(e){mt.canExpireCache()&&e.postRenderFunctions.push(Om)}}function Om(s,e){mt.expire()}class Nm extends Dm{constructor(e){super(e),this.fontChangeListenerKey_=J(Ci,Oi.PROPERTYCHANGE,e.redrawText,e),this.element_=rt?_u():document.createElement("div");const t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=ks+" ol-layers";const n=e.getViewport();n&&n.insertBefore(this.element_,n.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(e,t){const n=this.getMap();if(n.hasListener(e)){const i=new _s(e,void 0,t);n.dispatchEvent(i)}}disposeInternal(){ue(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(Fe.PRECOMPOSE,e);const t=e.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);t.some(h=>h.layer instanceof Ki&&h.layer.getDeclutter())&&(e.declutter={});const i=e.viewState;this.children_.length=0;const r=[];let o=null;for(let h=0,c=t.length;h0)&&(h.fillStyle=d,h.fillRect(0,0,l.width,l.height)),xn(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(...Ra(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(Fe.POSTCOMPOSE,e),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(e)}declutter(e,t){if(e.declutter){for(let n=t.length-1;n>=0;--n){const i=t[n],r=i.layer;r.getDeclutter()&&r.renderDeclutter(e,i)}t.forEach(n=>n.layer.renderDeferred(e))}}}function Ou(s){if(s instanceof Us){s.setMapInternal(null);return}s instanceof Vi&&s.getLayers().forEach(Ou)}function Nu(s,e){if(s instanceof Us){s.setMapInternal(e);return}if(s instanceof Vi){const t=s.getLayers().getArray();for(let n=0,i=t.length;nthis.updateSize())),this.controls=t.controls||(rt?new Ve:Jg()),this.interactions=t.interactions||(rt?new Ve:y_({onFocusOnly:!0})),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new xf(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Ue.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Ue.VIEW,this.handleViewChanged_),this.addChangeListener(Ue.SIZE,this.handleSizeChanged_),this.addChangeListener(Ue.TARGET,this.handleTargetChanged_),this.setProperties(t.values);const n=this;e.view&&!(e.view instanceof qt)&&e.view.then(function(i){n.setView(new qt(i))}),this.controls.addEventListener(Re.ADD,i=>{i.element.setMap(this)}),this.controls.addEventListener(Re.REMOVE,i=>{i.element.setMap(null)}),this.interactions.addEventListener(Re.ADD,i=>{i.element.setMap(this)}),this.interactions.addEventListener(Re.REMOVE,i=>{i.element.setMap(null)}),this.overlays_.addEventListener(Re.ADD,i=>{this.addOverlayInternal_(i.element)}),this.overlays_.addEventListener(Re.REMOVE,i=>{const r=i.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],i.element.setMap(null)}),this.controls.forEach(i=>{i.setMap(this)}),this.interactions.forEach(i=>{i.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){Nu(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){const t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,n){if(!this.frameState_||!this.renderer_)return;const i=this.getCoordinateFromPixelInternal(e);n=n!==void 0?n:{};const r=n.hitTolerance!==void 0?n.hitTolerance:0,o=n.layerFilter!==void 0?n.layerFilter:wn,a=n.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(i,this.frameState_,r,a,t,null,o,null)}getFeaturesAtPixel(e,t){const n=[];return this.forEachFeatureAtPixel(e,function(i){n.push(i)},t),n}getAllLayers(){const e=[];function t(n){n.forEach(function(i){i instanceof Vi?t(i.getLayers()):e.push(i)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;const n=this.getCoordinateFromPixelInternal(e);t=t!==void 0?t:{};const i=t.layerFilter!==void 0?t.layerFilter:wn,r=t.hitTolerance!==void 0?t.hitTolerance:0,o=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(n,this.frameState_,r,o,i,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){const n=this.viewport_.getBoundingClientRect(),i=this.getSize(),r=n.width/i[0],o=n.height/i[1],a="changedTouches"in e?e.changedTouches[0]:e;return[(a.clientX-n.left)/r,(a.clientY-n.top)/o]}getTarget(){return this.get(Ue.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return qn(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){const t=this.frameState_;return t?de(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){const t=this.overlayIdIndex_[e.toString()];return t!==void 0?t:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Ue.LAYERGROUP)}setLayers(e){const t=this.getLayerGroup();if(e instanceof Ve){t.setLayers(e);return}const n=t.getLayers();n.clear(),n.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const e=this.getLayerGroup().getLayerStatesArray();for(let t=0,n=e.length;t=0;r--){const o=i[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(e)||e.propagationStopped)break}}}handlePostRender(){const e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let i=this.maxTilesLoading_,r=i;if(e){const o=e.viewHints;if(o[he.ANIMATING]||o[he.INTERACTING]){const a=Date.now()-e.time>8;i=a?0:8,r=a?0:2}}t.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(e){const t=this.getLayerGroup();t&&this.handleLayerRemove_(new _n("removelayer",t)),this.set(Ue.LAYERGROUP,e)}setSize(e){this.set(Ue.SIZE,e)}setTarget(e){this.set(Ue.TARGET,e)}setView(e){if(!e||e instanceof qt){this.set(Ue.VIEW,e);return}this.set(Ue.VIEW,new qt);const t=this;e.then(function(n){t.setView(new qt(n))})}updateSize(){const e=this.getTargetElement();let t;if(e){let i,r;if(xn(e))i=e.width,r=e.height;else{const o=getComputedStyle(e);i=e.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),r=e.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(i)&&!isNaN(r)&&(t=[Math.max(0,i),Math.max(0,r)],!Bh(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&jc("No map visible because the map container's width or height are 0."))}const n=this.getSize();t&&(!n||!Ut(t,n))&&(this.setSize(t),this.updateViewportSize_(t))}updateViewportSize_(e){const t=this.getView();t&&t.setViewportSize(e)}};function Gm(s){let e=null;s.keyboardEventTarget!==void 0&&(e=typeof s.keyboardEventTarget=="string"?document.getElementById(s.keyboardEventTarget):s.keyboardEventTarget);const t={},n=s.layers&&typeof s.layers.getLayers=="function"?s.layers:new Vi({layers:s.layers});t[Ue.LAYERGROUP]=n,t[Ue.TARGET]=s.target,t[Ue.VIEW]=s.view instanceof qt?s.view:new qt;let i;s.controls!==void 0&&(Array.isArray(s.controls)?i=new Ve(s.controls.slice()):(te(typeof s.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),i=s.controls));let r;s.interactions!==void 0&&(Array.isArray(s.interactions)?r=new Ve(s.interactions.slice()):(te(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 Ve(s.overlays.slice()):(te(typeof s.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=s.overlays):o=new Ve,{controls:i,interactions:r,keyboardEventTarget:e,overlays:o,values:t}}const ke={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class I0 extends It{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=e.insertFirst!==void 0?e.insertFirst:!0,this.stopEvent=e.stopEvent!==void 0?e.stopEvent:!0,this.element=document.createElement("div"),this.element.className=e.className!==void 0?e.className:"ol-overlay-container "+Wg,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=e.autoPan===!0?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(ke.ELEMENT,this.handleElementChanged),this.addChangeListener(ke.MAP,this.handleMapChanged),this.addChangeListener(ke.OFFSET,this.handleOffsetChanged),this.addChangeListener(ke.POSITION,this.handlePositionChanged),this.addChangeListener(ke.POSITIONING,this.handlePositioningChanged),e.element!==void 0&&this.setElement(e.element),this.setOffset(e.offset!==void 0?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),e.position!==void 0&&this.setPosition(e.position)}getElement(){return this.get(ke.ELEMENT)}getId(){return this.id}getMap(){return this.get(ke.MAP)||null}getOffset(){return this.get(ke.OFFSET)}getPosition(){return this.get(ke.POSITION)}getPositioning(){return this.get(ke.POSITIONING)}handleElementChanged(){gu(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),ue(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const e=this.getMap();if(e){this.mapPostrenderListenerKey=J(e,Zt.POSTRENDER,this.render,this),this.updatePixelPosition();const t=this.stopEvent?e.getOverlayContainerStopEvent():e.getOverlayContainer();this.insertFirst?t.insertBefore(this.element,t.childNodes[0]||null):t.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(ke.ELEMENT,e)}setMap(e){this.set(ke.MAP,e)}setOffset(e){this.set(ke.OFFSET,e)}setPosition(e){this.set(ke.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(ke.POSITION))return;const n=this.getRect(t.getTargetElement(),t.getSize()),i=this.getElement(),r=this.getRect(i,[jg(i),Vg(i)]);e=e||{};const o=e.margin===void 0?20:e.margin;if(!pn(n,r)){const a=r[0]-n[0],l=n[2]-r[2],h=r[1]-n[1],c=n[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=t.getView().getCenterInternal(),f=t.getPixelFromCoordinateInternal(d);if(!f)return;const g=[f[0]+u[0],f[1]+u[1]],m=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(g),duration:m.duration,easing:m.easing})}}}getRect(e,t){const n=e.getBoundingClientRect(),i=n.left+window.pageXOffset,r=n.top+window.pageYOffset;return[i,r,i+t[0],r+t[1]]}setPositioning(e){this.set(ke.POSITIONING,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t){this.setVisible(!1);return}const n=e.getPixelFromCoordinate(t),i=e.getSize();this.updateRenderedPosition(n,i)}updateRenderedPosition(e,t){const n=this.element.style,i=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=`${e[0]+i[0]}px`,a=`${e[1]+i[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,n.transform=c)}getOptions(){return this.options}}class Nl extends Ms{constructor(e,t,n){super(),n=n||{},this.tileCoord=e,this.state=t,this.key="",this.transition_=n.transition===void 0?250:n.transition,this.transitionStarts_={},this.interpolate=!!n.interpolate}changed(){this.dispatchEvent(V.CHANGE)}release(){this.setState(B.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==B.EMPTY){if(this.state!==B.ERROR&&this.state>e)throw new Error("Tile load sequence violation");this.state=e,this.changed()}}load(){$()}getAlpha(e,t){if(!this.transition_)return 1;let n=this.transitionStarts_[e];if(!n)n=t,this.transitionStarts_[e]=n;else if(n===-1)return 1;const i=t-n+1e3/60;return i>=this.transition_?1:Yc(i/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}function Ma(s){return s instanceof Image||s instanceof HTMLCanvasElement||s instanceof HTMLVideoElement||s instanceof ImageBitmap?s:null}const km=new Error("disposed"),Um=[256,256];class Qh extends Nl{constructor(e){const t=B.IDLE;super(e.tileCoord,t,{transition:e.transition,interpolate:e.interpolate}),this.loader_=e.loader,this.data_=null,this.error_=null,this.size_=e.size||null,this.controller_=e.controller||null}getSize(){if(this.size_)return this.size_;const e=Ma(this.data_);return e?[e.width,e.height]:Um}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==B.IDLE&&this.state!==B.ERROR)return;this.state=B.LOADING,this.changed();const e=this;this.loader_().then(function(t){e.data_=t,e.state=B.LOADED,e.changed()}).catch(function(t){e.error_=t,e.state=B.ERROR,e.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(km),this.controller_=null),super.disposeInternal()}}class Gu extends Nl{constructor(e,t,n,i,r,o){super(e,t,o),this.crossOrigin_=i,this.src_=n,this.key=n,this.image_,rt?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,i!==null&&(this.image_.crossOrigin=i)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(e){this.image_=e,this.state=B.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}handleImageError_(){this.state=B.ERROR,this.unlistenImage_(),this.image_=Bm(),this.changed()}handleImageLoad_(){if(rt)this.state=B.LOADED;else{const e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=B.LOADED:this.state=B.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==B.ERROR&&(this.state=B.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==B.IDLE&&(this.state=B.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=rm(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 Bm(){const s=ve(1,1);return s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,1,1),s.canvas}class Gl{constructor(e,t,n,i){this.minX=e,this.maxX=t,this.minY=n,this.maxY=i}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minXthis.maxX&&(this.maxX=e.maxX),e.minYthis.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}}function gi(s,e,t,n,i){return i!==void 0?(i.minX=s,i.maxX=e,i.minY=t,i.maxY=n,i):new Gl(s,e,t,n)}let Yo;const Fi=[];function ec(s,e,t,n,i){s.beginPath(),s.moveTo(0,0),s.lineTo(e,t),s.lineTo(n,i),s.closePath(),s.save(),s.clip(),s.fillRect(0,0,Math.max(e,n)+1,Math.max(t,i)),s.restore()}function jo(s,e){return Math.abs(s[e*4]-210)>2||Math.abs(s[e*4+3]-.75*255)>2}function zm(){if(Yo===void 0){const s=ve(6,6,Fi);s.globalCompositeOperation="lighter",s.fillStyle="rgba(210, 0, 0, 0.75)",ec(s,4,5,4,0),ec(s,4,5,0,5);const e=s.getImageData(0,0,3,3).data;Yo=jo(e,0)||jo(e,4)||jo(e,8),oo(s),Fi.push(s.canvas)}return Yo}function Da(s,e,t,n){const i=Ns(t,e,s);let r=Ir(e,n,t);const o=e.getMetersPerUnit();o!==void 0&&(r*=o);const a=s.getMetersPerUnit();a!==void 0&&(r/=a);const l=s.getExtent();if(!l||Zn(l,i)){const h=Ir(s,r,i)/r;isFinite(h)&&h>0&&(r/=h)}return r}function $m(s,e,t,n){const i=Pn(t);let r=Da(s,e,i,n);return(!isFinite(r)||r<=0)&&qa(t,function(o){return r=Da(s,e,o,n),isFinite(r)&&r>0}),r}function Xm(s,e,t,n,i,r,o,a,l,h,c,u,d,f){const g=ve(Math.round(t*s),Math.round(t*e),Fi);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(t,t);function m(T){return Math.round(T*t)/t}g.globalCompositeOperation="lighter";const _=Je();l.forEach(function(T,R,S){Uc(_,T.extent)});let p;const y=t/n,E=(u?1:1+Math.pow(2,-24))/y;p=ve(Math.round(ne(_)*y),Math.round(be(_)*y),Fi),u||(p.imageSmoothingEnabled=!1),l.forEach(function(T,R,S){if(T.image.width>0&&T.image.height>0){if(T.clipExtent){p.save();const L=(T.clipExtent[0]-_[0])*y,b=-(T.clipExtent[3]-_[3])*y,M=ne(T.clipExtent)*y,K=be(T.clipExtent)*y;p.rect(u?L:Math.round(L),u?b:Math.round(b),u?M:Math.round(L+M)-Math.round(L),u?K:Math.round(b+K)-Math.round(b)),p.clip()}const v=(T.extent[0]-_[0])*y,w=-(T.extent[3]-_[3])*y,I=ne(T.extent)*y,F=be(T.extent)*y;p.drawImage(T.image,h,h,T.image.width-2*h,T.image.height-2*h,u?v:Math.round(v),u?w:Math.round(w),u?I:Math.round(v+I)-Math.round(v),u?F:Math.round(w+F)-Math.round(w)),T.clipExtent&&p.restore()}});const x=An(o);return a.getTriangles().forEach(function(T,R,S){const v=T.source,w=T.target;let I=v[0][0],F=v[0][1],L=v[1][0],b=v[1][1],M=v[2][0],K=v[2][1];const A=m((w[0][0]-x[0])/r),Z=m(-(w[0][1]-x[1])/r),G=m((w[1][0]-x[0])/r),H=m(-(w[1][1]-x[1])/r),Q=m((w[2][0]-x[0])/r),le=m(-(w[2][1]-x[1])/r),P=I,Ne=F;I=0,F=0,L-=P,b-=Ne,M-=P,K-=Ne;const We=[[L,b,0,0,G-A],[M,K,0,0,Q-A],[0,0,L,b,H-Z],[0,0,M,K,le-Z]],xe=Cf(We);if(!xe)return;if(g.save(),g.beginPath(),zm()||!u){g.moveTo(G,H);const Ge=4,Lt=A-G,Ct=Z-H;for(let nt=0;ntde(a,Ns(E,this.targetProj_,this.sourceProj_))):Hn(this.targetProj_,this.sourceProj_);this.transformInv_=function(E){const x=E[0]+"/"+E[1];return l[x]||(l[x]=h(E)),l[x]},this.maxSourceExtent_=i,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!i&&!!this.sourceProj_.getExtent()&&ne(i)>=ne(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?ne(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?ne(this.targetProj_.getExtent()):null;const c=An(n),u=qr(n),d=Hr(n),f=Kr(n),g=this.transformInv_(c),m=this.transformInv_(u),_=this.transformInv_(d),p=this.transformInv_(f),y=Wm+(o?Math.max(0,Math.ceil(Math.log2(pa(n)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,m,_,p,y),this.wrapsXInSource_){let E=1/0;this.triangles_.forEach(function(x,T,R){E=Math.min(E,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-E>this.sourceWorldWidth_/2){const T=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];T[0][0]-E>this.sourceWorldWidth_/2&&(T[0][0]-=this.sourceWorldWidth_),T[1][0]-E>this.sourceWorldWidth_/2&&(T[1][0]-=this.sourceWorldWidth_),T[2][0]-E>this.sourceWorldWidth_/2&&(T[2][0]-=this.sourceWorldWidth_);const R=Math.min(T[0][0],T[1][0],T[2][0]);Math.max(T[0][0],T[1][0],T[2][0])-R.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=Be([e,t,n,i]);g=ne(_)/this.targetWorldWidth_>tc||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>tc||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!Ee(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 _=[(e[0]+n[0])/2,(e[1]+n[1])/2],p=this.transformInv_(_);let y;f?y=(Qt(r[0],d)+Qt(a[0],d))/2-Qt(p[0],d):y=(r[0]+a[0])/2-p[0];const E=(r[1]+a[1])/2-p[1];g=y*y+E*E>this.errorThresholdSquared_}if(g){if(Math.abs(e[0]-n[0])<=Math.abs(e[1]-n[1])){const _=[(t[0]+n[0])/2,(t[1]+n[1])/2],p=this.transformInv_(_),y=[(i[0]+e[0])/2,(i[1]+e[1])/2],E=this.transformInv_(y);this.addQuad_(e,t,_,y,r,o,p,E,h-1),this.addQuad_(y,_,n,i,E,p,a,l,h-1)}else{const _=[(e[0]+t[0])/2,(e[1]+t[1])/2],p=this.transformInv_(_),y=[(n[0]+i[0])/2,(n[1]+i[1])/2],E=this.transformInv_(y);this.addQuad_(e,_,y,i,r,p,E,l,h-1),this.addQuad_(_,t,n,y,p,o,a,E,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(e,n,i,r,a,l),(m&14)==0&&this.addTriangle_(e,n,t,r,a,o),m&&((m&13)==0&&this.addTriangle_(t,i,e,o,l,r),(m&7)==0&&this.addTriangle_(t,i,n,o,l,a))}calculateSourceExtent(){const e=Je();return this.triangles_.forEach(function(t,n,i){const r=t.source;fs(e,r[0]),fs(e,r[1]),fs(e,r[2])}),e}getTriangles(){return this.triangles_}}const jm=.5;class ku extends Nl{constructor(e,t,n,i,r,o,a,l,h,c,u,d){super(r,B.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=t,this.targetTileGrid_=i,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=e.canWrapX()?e.getExtent():void 0;const f=i.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let m=this.sourceTileGrid_.getExtent();const _=g?en(f,g):f;if(pa(_)===0){this.state=B.EMPTY;return}const p=e.getExtent();p&&(m?m=en(m,p):m=p);const y=i.getResolution(this.wrappedTileCoord_[0]),E=$m(e,n,_,y);if(!isFinite(E)||E<=0){this.state=B.EMPTY;return}const x=c!==void 0?c:jm;if(this.triangulation_=new Ym(e,n,_,m,E*x,y),this.triangulation_.getTriangles().length===0){this.state=B.EMPTY;return}this.sourceZ_=t.getZForResolution(E);let T=this.triangulation_.calculateSourceExtent();if(m&&(e.canWrapX()?(T[1]=fe(T[1],m[1],m[3]),T[3]=fe(T[3],m[1],m[3])):T=en(T,m)),!pa(T))this.state=B.EMPTY;else{let R=0,S=0;e.canWrapX()&&(R=ne(p),S=Math.floor((T[0]-p[0])/R)),Xc(T.slice(),e,!0).forEach(w=>{const I=t.getTileRangeForExtentAndZ(w,this.sourceZ_);for(let F=I.minX;F<=I.maxX;F++)for(let L=I.minY;L<=I.maxY;L++){const b=h(this.sourceZ_,F,L,a);if(b){const M=S*R;this.sourceTiles_.push({tile:b,offset:M})}}++S}),this.sourceTiles_.length===0&&(this.state=B.EMPTY)}}getImage(){return this.canvas_}reproject_(){const e=[];if(this.sourceTiles_.forEach(t=>{const n=t.tile;if(n&&n.getState()==B.LOADED){const i=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);i[0]+=t.offset,i[2]+=t.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=t.offset,r[2]+=t.offset),e.push({extent:i,clipExtent:r,image:n.getImage()})}}),this.sourceTiles_.length=0,e.length===0)this.state=B.ERROR;else{const t=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(t),i=typeof n=="number"?n:n[0],r=typeof n=="number"?n:n[1],o=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=Xm(i,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=B.LOADED}this.changed()}load(){if(this.state==B.IDLE){this.state=B.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:t})=>{const n=t.getState();if(n==B.IDLE||n==B.LOADING){e++;const i=J(t,V.CHANGE,r=>{const o=t.getState();(o==B.LOADED||o==B.ERROR||o==B.EMPTY)&&(ue(i),e--,e===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(i)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},n,i){t.getState()==B.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(ue),this.sourcesListenerKeys_=null}release(){this.canvas_&&(oo(this.canvas_.getContext("2d")),Fi.push(this.canvas_),this.canvas_=null),super.release()}}class nc{constructor(e){this.highWaterMark=e!==void 0?e:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const e=this.pop();e instanceof bs&&e.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){const n=this.entries_[e];return te(n!==void 0,"Tried to get a value for a key that does not exist in the cache"),n===this.newest_||(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n),n.value_}remove(e){const t=this.entries_[e];return te(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){const e=new Array(this.count_);let t=0,n;for(n=this.newest_;n;n=n.older)e[t++]=n.key_;return e}getValues(){const e=new Array(this.count_);let t=0,n;for(n=this.newest_;n;n=n.older)e[t++]=n.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){return this.entries_[e]?.value_}pop(){const e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){te(!(e in this.entries_),"Tried to set a value for a key that is used already");const n={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[e]=n,++this.count_}setSize(e){this.highWaterMark=e}}function kr(s,e,t,n){return n!==void 0?(n[0]=s,n[1]=e,n[2]=t,n):[s,e,t]}function Vm(s,e,t){return s+"/"+e+"/"+t}function Er(s,e,t,n,i){return`${D(s)},${e},${Vm(t,n,i)}`}function Uu(s){return Zm(s[0],s[1],s[2])}function Zm(s,e,t){return(e<t||t>e.getMaxZoom())return!1;const r=e.getFullTileRange(t);return r?r.containsXY(n,i):!0}class kl{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Fr(),{get:(e,t)=>{if(typeof Fr()[t]=="function")return this.push_(t),this.pushMethodArgs_},set:(e,t,n)=>(this.push_(t,n),!0)})}push_(...e){const t=this.instructions_,n=this.zIndex+this.offset_;t[n]||(t[n]=[]),t[n].push(...e)}pushMethodArgs_=(...e)=>(this.push_(e),this);pushFunction(e){this.push_(e)}getContext(){return this.context_}draw(e){this.instructions_.forEach(t=>{for(let n=0,i=t.length;nthis.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return $()}getData(e){return null}prepareFrame(e){return $()}renderFrame(e,t){return $()}forEachFeatureAtCoordinate(e,t,n,i,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){const t=e.target;(t.getState()===U.LOADED||t.getState()===U.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=U.LOADED&&t!=U.ERROR&&e.addEventListener(V.CHANGE,this.boundHandleImageChange_),t==U.IDLE&&(e.load(),t=e.getState()),t==U.LOADED}renderIfReadyAndVisible(){const e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const ic=[];let Ri=null;function qm(){Ri=ve(1,1,void 0,{willReadFrequently:!0})}class Ul extends Bu{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=Te(),this.pixelTransform=Te(),this.inversePixelTransform=Te(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,t,n){Ri||qm(),Ri.clearRect(0,0,1,1);let i;try{Ri.drawImage(e,t,n,1,1,0,0,1,1),i=Ri.getImageData(0,0,1,1).data}catch{return Ri=null,null}return i}getBackground(e){let n=this.getLayer().getBackground();return typeof n=="function"&&(n=n(e.viewState.resolution)),n||void 0}useContainer(e,t,n){const i=this.getLayer().getClassName();let r,o;if(e&&e.className===i&&(!n||e&&e.style.backgroundColor&&Ut(Et(e.style.backgroundColor),Et(n)))){const a=e.firstElementChild;xn(a)&&(o=a.getContext("2d"))}if(o&&xg(o.canvas.style.transform,t)?(this.container=e,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=rt?_u():document.createElement("div"),r.className=i;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=ve();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&&n&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=n)}clipUnrotated(e,t,n){const i=An(n),r=qr(n),o=Hr(n),a=Kr(n);de(t.coordinateToPixelTransform,i),de(t.coordinateToPixelTransform,r),de(t.coordinateToPixelTransform,o),de(t.coordinateToPixelTransform,a);const l=this.inversePixelTransform;de(l,i),de(l,r),de(l,o),de(l,a),e.save(),e.beginPath(),e.moveTo(Math.round(i[0]),Math.round(i[1])),e.lineTo(Math.round(r[0]),Math.round(r[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(a[0]),Math.round(a[1])),e.clip()}prepareContainer(e,t){const n=e.extent,i=e.viewState.resolution,r=e.viewState.rotation,o=e.pixelRatio,a=Math.round(ne(n)/i*o),l=Math.round(be(n)/i*o);lt(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/o,1/o,r,-a/2,-l/2),Cs(this.inversePixelTransform,this.pixelTransform);const h=yg(this.pixelTransform);if(this.useContainer(t,h,this.getBackground(e)),!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_(e,t,n){const i=this.getLayer();if(i.hasListener(e)){const r=new _s(e,this.inversePixelTransform,n,t);i.dispatchEvent(r)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(Fe.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(Fe.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new kl),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(Fe.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(Fe.POSTRENDER,this.context,e))}getRenderTransform(e,t,n,i,r,o,a){const l=r/2,h=o/2,c=i/t,u=-c,d=-e[0]+a,f=-e[1];return lt(this.tempTransform,l,h,c,u,-n,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function Vo(s,e,t){if(!(t in s))return s[t]=new Set([e]),!0;const n=s[t],i=n.has(e);return i||n.add(e),!i}function Jm(s,e,t){const n=s[t];return n?n.delete(e):!1}function sc(s,e){const t=s.layerStatesArray[s.layerIndex];t.extent&&(e=en(e,St(t.extent,s.viewState.projection)));const n=t.layer.getRenderSource();if(!n.getWrapX()){const i=n.getTileGridForProjection(s.viewState.projection).getExtent();i&&(e=en(e,i))}return e}class zu extends Ul{constructor(e,t){super(e),t=t||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=Je(),this.tempTileRange_=new Gl(0,0,0,0),this.tempTileCoord_=kr(0,0,0);const n=t.cacheSize!==void 0?t.cacheSize:512;this.tileCache_=new nc(n),this.sourceTileCache_=null,this.maxStaleKeys=n*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new nc(512)),this.sourceTileCache_}getOrCreateTile(e,t,n,i){const r=this.tileCache_,a=this.getLayer().getSource(),l=Er(a,a.getKey(),e,t,n);let h;if(r.containsKey(l))h=r.get(l);else{const c=i.viewState.projection,u=a.getProjection();if(h=a.getTile(e,t,n,i.pixelRatio,c,!u||Yn(u,c)?void 0:this.getSourceTileCache()),!h)return null;r.set(l,h)}return h}getTile(e,t,n,i){const r=this.getOrCreateTile(e,t,n,i);return r||null}getData(e){const t=this.frameState;if(!t)return null;const n=this.getLayer(),i=de(t.pixelToCoordinateTransform,e.slice()),r=n.getExtent();if(r&&!Zn(r,i))return null;const o=t.viewState,a=n.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(t.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){const u=l.getTileCoordForCoordAndZ(i,c),d=this.getTile(c,u[1],u[2],t);if(!d||d.getState()!==B.LOADED)continue;const f=l.getOrigin(c),g=$e(l.getTileSize(c)),m=l.getResolution(c);let _;if(d instanceof Gu||d instanceof ku)_=d.getImage();else if(d instanceof Qh){if(_=Ma(d.getData()),!_)continue}else continue;const p=Math.floor(h*((i[0]-f[0])/m-u[1]*g[0])),y=Math.floor(h*((f[1]-i[1])/m-u[2]*g[1])),E=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(_,p+E,y+E)}return null}prepareFrame(e){this.renderedProjection?e.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=e.viewState.projection):this.renderedProjection=e.viewState.projection;const t=this.getLayer().getSource();if(!t)return!1;const n=t.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==n&&(this.renderedSourceRevision_=n,this.renderedSourceKey_===t.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=n,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(e,t,n,i,r){const o=e.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=D(l);c in e.wantedTiles||(e.wantedTiles[c]={});const u=e.wantedTiles[c],d=a.getMapInternal(),f=Math.max(n-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?zc(o.center,o.resolution,g,e.size):void 0;for(let _=n;_>=f;--_){const p=h.getTileRangeForExtentAndZ(t,_,this.tempTileRange_),y=h.getResolution(_);for(let E=p.minX;E<=p.maxX;++E)for(let x=p.minY;x<=p.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([_,E,x],m))continue;const T=this.getTile(_,E,x,e);if(!T||!Vo(i,T,_))continue;const S=T.getKey();if(u[S]=!0,T.getState()===B.IDLE&&!e.tileQueue.isKeyQueued(S)){const v=kr(_,E,x,this.tempTileCoord_);e.tileQueue.enqueue([T,c,h.getTileCoordCenter(v),y])}}}}findStaleTile_(e,t){const n=this.tileCache_,i=e[0],r=e[1],o=e[2],a=this.getStaleKeys();for(let l=0;l0&&setTimeout(()=>{this.enqueueTiles(e,w,d-1,S,v-1)},0),!(d in S))return this.container;const I=D(this),F=e.time;for(const G of S[d]){const H=G.getState();if(H===B.EMPTY)continue;const Q=G.tileCoord;if(H===B.LOADED&&G.getAlpha(I,F)===1){G.endTransition(I);continue}if(H!==B.ERROR&&(this.renderComplete=!1),this.findStaleTile_(Q,S)){Jm(S,G,d),e.animate=!0;continue}if(this.findAltTiles_(u,Q,d+1,S))continue;const Ne=u.getMinZoom();for(let We=d-1;We>=Ne&&!this.findAltTiles_(u,Q,We,S);--We);}const L=f/o*l/_,b=this.getRenderContext(e);lt(this.tempTransform,p/2,y/2,L,L,0,-p/2,-y/2),n.extent&&this.clipUnrotated(b,e,E),c.getInterpolate()||(b.imageSmoothingEnabled=!1),this.preRender(b,e);const M=Object.keys(S).map(Number);M.sort(Ot);let K;const A=[],Z=[];for(let G=M.length-1;G>=0;--G){const H=M[G],Q=c.getTilePixelSize(H,l,r),P=u.getResolution(H)/f,Ne=Q[0]*P*L,We=Q[1]*P*L,xe=u.getTileCoordForCoordAndZ(An(R),H),tt=u.getTileCoordExtent(xe),Ge=de(this.tempTransform,[_*(tt[0]-R[0])/f,_*(R[3]-tt[3])/f]),Lt=_*c.getGutterForProjection(r);for(const Ct of S[H]){if(Ct.getState()!==B.LOADED)continue;const nt=Ct.tileCoord,Ys=xe[1]-nt[1],xo=Math.round(Ge[0]-(Ys-1)*Ne),qi=xe[2]-nt[2],bn=Math.round(Ge[1]-(qi-1)*We),ht=Math.round(Ge[0]-Ys*Ne),At=Math.round(Ge[1]-qi*We),oi=xo-ht,ai=bn-At,Ji=M.length===1;let Mn=!1;K=[ht,At,ht+oi,At,ht+oi,At+ai,ht,At+ai];for(let li=0,hi=A.length;li{const le=D(c),P=Q.wantedTiles[le],Ne=P?Object.keys(P).length:0;this.updateCacheSize(Ne),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};e.postRenderFunctions.push(G)}return this.container}updateCacheSize(e){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,e*2)}drawTile(e,t,n,i,r,o,a,l){let h;if(e instanceof Qh){if(h=Ma(e.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(e);if(!h)return;const c=this.getRenderContext(t),u=D(this),d=t.layerStatesArray[t.layerIndex],f=d.opacity*(l?e.getAlpha(u,t.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,n,i,r,o),g&&c.restore(),f!==d.opacity?t.animate=!0:l&&e.endTransition(u)}getImage(){const e=this.context;return e?e.canvas:null}getTileImage(e){return e.getImage()}updateUsedTiles(e,t,n){const i=D(t);i in e||(e[i]={}),e[i][n.getKey()]=!0}}const En={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class Qm extends Us{constructor(e){e=e||{};const t=Object.assign({},e),n=e.cacheSize;delete e.cacheSize,delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=n,this.setPreload(e.preload!==void 0?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(En.PRELOAD)}setPreload(e){this.set(En.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(En.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(En.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}}class L0 extends Qm{constructor(e){super(e)}createRenderer(){return new zu(this,{cacheSize:this.getCacheSize()})}}class $u extends Ul{constructor(e){super(e),this.image=null}getImage(){return this.image?this.image.getImage():null}prepareFrame(e){const t=e.layerStatesArray[e.layerIndex],n=e.pixelRatio,i=e.viewState,r=i.resolution,o=this.getLayer().getSource(),a=e.viewHints;let l=e.extent;if(t.extent!==void 0&&(l=en(l,St(t.extent,i.projection))),!a[he.ANIMATING]&&!a[he.INTERACTING]&&!ti(l))if(o){const h=i.projection,c=o.getImage(l,r,n,h);c&&(this.loadImage(c)?this.image=c:c.getState()===U.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(e){const t=this.frameState;if(!t)return null;const n=this.getLayer(),i=de(t.pixelToCoordinateTransform,e.slice()),r=n.getExtent();if(r&&!Zn(r,i))return null;const o=this.image.getExtent(),a=this.image.getImage(),l=ne(o),h=Math.floor(a.width*((i[0]-o[0])/l));if(h<0||h>=a.width)return null;const c=be(o),u=Math.floor(a.height*((o[3]-i[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(e,t){const n=this.image,i=n.getExtent(),r=n.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],l=n.getPixelRatio(),h=e.layerStatesArray[e.layerIndex],c=e.pixelRatio,u=e.viewState,d=u.center,f=u.resolution,g=c*o/(f*l),m=c*a/(f*l);this.prepareContainer(e,t);const _=this.context.canvas.width,p=this.context.canvas.height,y=this.getRenderContext(e);let E=!1,x=!0;if(h.extent){const w=St(h.extent,u.projection);x=Ee(w,e.extent),E=x&&!pn(w,e.extent),E&&this.clipUnrotated(y,e,w)}const T=n.getImage(),R=lt(this.tempTransform,_/2,p/2,g,m,0,l*(i[0]-d[0])/o,l*(d[1]-i[3])/a);this.renderedResolution=a*c/l;const S=T.width*R[0],v=T.height*R[3];if(this.getLayer().getSource().getInterpolate()||(y.imageSmoothingEnabled=!1),this.preRender(y,e),x&&S>=.5&&v>=.5){const w=R[4],I=R[5],F=h.opacity;F!==1&&(y.save(),y.globalAlpha=F),y.drawImage(T,0,0,+T.width,+T.height,w,I,S,v),F!==1&&y.restore()}return this.postRender(this.context,e),E&&y.restore(),y.imageSmoothingEnabled=!0,this.container}}class ep extends Us{constructor(e){e=e||{},super(e)}}class A0 extends ep{constructor(e){super(e)}createRenderer(){return new $u(this)}getData(e){return super.getData(e)}}class Xu{drawCustom(e,t,n,i,r){}drawGeometry(e){}setStyle(e){}drawCircle(e,t,n){}drawFeature(e,t,n){}drawGeometryCollection(e,t,n){}drawLineString(e,t,n){}drawMultiLineString(e,t,n){}drawMultiPoint(e,t,n){}drawMultiPolygon(e,t,n){}drawPoint(e,t,n){}drawPolygon(e,t,n){}drawText(e,t,n){}setFillStrokeStyle(e,t){}setImageStyle(e,t){}setTextStyle(e,t){}}const X={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},rr=[X.FILL],Tn=[X.STROKE],$n=[X.BEGIN_PATH],rc=[X.CLOSE_PATH];class Xs extends Xu{constructor(e,t,n,i){super(),this.tolerance=e,this.maxExtent=t,this.pixelRatio=i,this.maxLineWidth=0,this.resolution=n,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){const t=this.pixelRatio;return t==1?e:e.map(function(n){return n*t})}appendFlatPointCoordinates(e,t){const n=this.getBufferedMaxExtent(),i=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=e.length;al&&(this.instructions.push([X.CUSTOM,l,c,e,n,yn,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,c,e,i||n,yn,r]));break;case"Point":h=e.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([X.CUSTOM,l,c,e,n,void 0,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,c,e,i||n,void 0,r]);break}this.endGeometry(t)}beginGeometry(e,t,n){this.beginGeometryInstruction1_=[X.BEGIN_GEOMETRY,t,0,e,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[X.BEGIN_GEOMETRY,t,0,e,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const e=this.hitDetectionInstructions;e.reverse();let t;const n=e.length;let i,r,o=-1;for(t=0;tthis.maxLineWidth&&(this.maxLineWidth=t.lineWidth,this.bufferedMaxExtent_=null)}else t.strokeStyle=void 0,t.lineCap=void 0,t.lineDash=null,t.lineDashOffset=void 0,t.lineJoin=void 0,t.lineWidth=void 0,t.miterLimit=void 0;return t}setFillStrokeStyle(e,t){const n=this.state;this.fillStyleToState(e,n),this.strokeStyleToState(t,n)}createFill(e){const t=e.fillStyle,n=[X.SET_FILL_STYLE,t];return typeof t!="string"&&n.push(e.fillPatternScale),n}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[X.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,e.lineDash?this.applyPixelRatio(e.lineDash):null,e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){const n=e.fillStyle;(typeof n!="string"||e.currentFillStyle!=n)&&(this.instructions.push(t.call(this,e)),e.currentFillStyle=n)}updateStrokeStyle(e,t){const n=e.strokeStyle,i=e.lineCap,r=e.lineDash,o=e.lineDashOffset,a=e.lineJoin,l=e.lineWidth,h=e.miterLimit;(e.currentStrokeStyle!=n||e.currentLineCap!=i||r!=e.currentLineDash&&!Ut(e.currentLineDash,r)||e.currentLineDashOffset!=o||e.currentLineJoin!=a||e.currentLineWidth!=l||e.currentMiterLimit!=h)&&(t.call(this,e),e.currentStrokeStyle=n,e.currentLineCap=i,e.currentLineDash=r,e.currentLineDashOffset=o,e.currentLineJoin=a,e.currentLineWidth=l,e.currentMiterLimit=h)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const t=[X.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=kc(this.maxExtent),this.maxLineWidth>0)){const e=this.resolution*(this.maxLineWidth+1)/2;sn(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class tp extends Xs{constructor(e,t,n,i){super(e,t,n,i),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,t,n){if(!this.image_||this.maxExtent&&!Zn(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,n);const i=e.getFlatCoordinates(),r=e.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(i,r);this.instructions.push([X.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([X.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}drawMultiPoint(e,t,n){if(!this.image_)return;this.beginGeometry(e,t,n);const i=e.getFlatCoordinates(),r=[];for(let l=0,h=i.length;l=s){const g=(s-a+f)/f,m=it(h,u,g),_=it(c,d,g);l.push(m,_),r.push(l),l=[m,_],a==s&&(o+=i),a=0}else if(a0&&r.push(l),r}function sp(s,e,t,n,i){let r=t,o=t,a=0,l=0,h=t,c,u,d,f,g,m,_,p,y,E;for(u=t;us&&(l>a&&(a=l,r=h,o=u),l=0,h=u-i)),d=f,_=y,p=E),g=x,m=T}return l+=f,l>a?[h,u]:[r,o]}const Ur={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class rp extends Xs{constructor(e,t,n,i){super(e,t,n,i),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[Ke]={fillStyle:Ke},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 e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,t,n){const i=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!i&&!r)return;const a=this.coordinates;let l=a.length;const h=e.getType();let c=null,u=e.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!Ee(this.maxExtent,e.getExtent()))return;let d;if(c=e.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=e.getEnds();else if(h=="Polygon")d=e.getEnds().slice(0,1);else if(h=="MultiPolygon"){const _=e.getEndss();d=[];for(let p=0,y=_.length;p{const S=a[(x+R)*2]===c[R*u]&&a[(x+R)*2+1]===c[R*u+1];return S||--x,S})}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(e,t,n);let _=o.padding;if(_!=zn&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],T=o.padding[1],R=o.padding[2],S=o.padding[3];o.scale[0]<0&&(T=-T,S=-S),o.scale[1]<0&&(x=-x,R=-R),_=[x,T,R,S]}const p=this.pixelRatio;this.instructions.push([X.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,_==zn?zn:_.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,E=g?g.slice(0):null;E&&(E[1]=Ke),this.hitDetectionInstructions.push([X.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[y,y],NaN,this.declutterMode_,this.declutterImageWithText_,_,E,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Ke:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(t)}}saveTextStates_(){const e=this.textStrokeState_,t=this.textState_,n=this.textFillState_,i=this.strokeKey_;e&&(i in this.strokeStates||(this.strokeStates[i]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:t.font,textAlign:t.textAlign||Ps,justify:t.justify,textBaseline:t.textBaseline||Or,scale:t.scale});const o=this.fillKey_;n&&(o in this.fillStates||(this.fillStates[o]={fillStyle:n.fillStyle}))}drawChars_(e,t){const n=this.textStrokeState_,i=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=Ur[i.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=n?n.lineWidth*Math.abs(i.scale[0])/2:0;this.instructions.push([X.DRAW_CHARS,e,t,h,i.overflow,a,i.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([X.DRAW_CHARS,e,t,h,i.overflow,a&&Ke,i.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(e,t){let n,i,r;if(!e)this.text_="";else{const o=e.getFill();o?(i=this.textFillState_,i||(i={},this.textFillState_=i),i.fillStyle=Dt(o.getColor()||Ke)):(i=null,this.textFillState_=i);const a=e.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()||Ui,r.lineDash=m?m.slice():tn,r.lineDashOffset=_===void 0?nn:_,r.lineJoin=a.getLineJoin()||Bi,r.lineWidth=p===void 0?Is:p,r.miterLimit=y===void 0?vs:y,r.strokeStyle=Dt(a.getColor()||ws)}n=this.textState_;const l=e.getFont()||Pu;dm(l);const h=e.getScaleArray();n.overflow=e.getOverflow(),n.font=l,n.maxAngle=e.getMaxAngle(),n.placement=e.getPlacement(),n.textAlign=e.getTextAlign(),n.repeat=e.getRepeat(),n.justify=e.getJustify(),n.textBaseline=e.getTextBaseline()||Or,n.backgroundFill=e.getBackgroundFill(),n.backgroundStroke=e.getBackgroundStroke(),n.padding=e.getPadding()||zn,n.scale=h===void 0?[1,1]:h;const c=e.getOffsetX(),u=e.getOffsetY(),d=e.getRotateWithView(),f=e.getKeepUpright(),g=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:D(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=n.font+n.scale+(n.textAlign||"?")+(n.repeat||"?")+(n.justify||"?")+(n.textBaseline||"?"),this.fillKey_=i&&i.fillStyle?typeof i.fillStyle=="string"?i.fillStyle:"|"+D(i.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}const op={Circle:oc,Default:Xs,Image:tp,LineString:np,Polygon:oc,Text:rp};class Wu{constructor(e,t,n,i){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=i,this.resolution_=n,this.buildersByZIndex_={}}finish(){const e={};for(const t in this.buildersByZIndex_){e[t]=e[t]||{};const n=this.buildersByZIndex_[t];for(const i in n){const r=n[i].finish();e[t][i]=r}}return e}getBuilder(e,t){const n=e!==void 0?e.toString():"0";let i=this.buildersByZIndex_[n];i===void 0&&(i={},this.buildersByZIndex_[n]=i);let r=i[t];if(r===void 0){const o=op[t];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),i[t]=r}return r}}function Bl(s,e,t,n){let i=s[e],r=s[e+1],o=0;for(let a=e+n;aZ[2]}else L=T>I;const b=Math.PI,M=[],K=S+n===e;e=S,p=0,y=v,f=s[e],g=s[e+1];let A;if(K){E(),A=Math.atan2(g-_,f-m),L&&(A+=A>0?-b:b);const Z=(I+T)/2,G=(F+R)/2;return M[0]=[Z,G,(w-r)/2,A,i],M}i=i.replace(/\n/g," ");for(let Z=0,G=i.length;Z0?-b:b),A!==void 0){let xe=H-A;if(xe+=xe>b?-2*b:xe<-b?2*b:0,Math.abs(xe)>o)return null}A=H;const Q=Z;let le=0;for(;Z0&&s.push(` `,""),s.push(e,""),s}function hp(s,e,t){return t%2===0&&(s+=e),s}class cp{constructor(e,t,n,i,r){this.overlaps=n,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=i.instructions,this.coordinates=i.coordinates,this.coordinateCache_={},this.renderedTransform_=Te(),this.hitDetectionInstructions=i.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=i.fillStates||{},this.strokeStates=i.strokeStates||{},this.textStates=i.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new kl:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,n,i){const r=e+t+n+i;if(this.labels_[r])return this.labels_[r];const o=i?this.strokeStates[i]:null,a=n?this.fillStates[n]:null,l=this.textStates[t],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?Ur[l.justify]:Zo(Array.isArray(e)?e[0]:e,l.textAlign||Ps),d=i&&o.lineWidth?o.lineWidth:0,f=Array.isArray(e)?e:String(e).split(` `).reduce(lp,[]),{width:g,height:m,widths:_,heights:p,lineWidths:y}=gm(l,f),E=g+d,x=[],T=(E+2)*c[0],R=(m+d)*c[1],S={width:T<0?Math.floor(T):Math.ceil(T),height:R<0?Math.floor(R):Math.ceil(R),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),i&&(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)),n&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const v=.5-u;let w=u*E+v*d;const I=[],F=[];let L=0,b=0,M=0,K=0,A;for(let Z=0,G=f.length;Ze?e-h:r,x=o+c>t?t-c:o,T=g[3]+E*d[0]+g[1],R=g[0]+x*d[1]+g[2],S=p-g[3],v=y-g[0];(m||u!==0)&&(un[0]=S,dn[0]=S,un[1]=v,Xt[1]=v,Xt[0]=S+T,Wt[0]=Xt[0],Wt[1]=v+R,dn[1]=Wt[1]);let w;return u!==0?(w=lt(Te(),n,i,1,1,u,-n,-i),de(w,un),de(w,Xt),de(w,Wt),de(w,dn),kt(Math.min(un[0],Xt[0],Wt[0],dn[0]),Math.min(un[1],Xt[1],Wt[1],dn[1]),Math.max(un[0],Xt[0],Wt[0],dn[0]),Math.max(un[1],Xt[1],Wt[1],dn[1]),_i)):kt(Math.min(S,S+T),Math.min(v,v+R),Math.max(S,S+T),Math.max(v,v+R),_i),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:E,drawImageH:x,originX:h,originY:c,declutterBox:{minX:_i[0],minY:_i[1],maxX:_i[2],maxY:_i[3],value:_},canvasTransform:w,scale:d}}replayImageOrLabel_(e,t,n,i,r,o,a){const l=!!(o||a),h=i.declutterBox,c=a?a[2]*i.scale[0]/2:0;return h.minX-c<=t[0]&&h.maxX+c>=0&&h.minY-c<=t[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(e,un,Xt,Wt,dn,o,a),_m(e,i.canvasTransform,r,n,i.originX,i.originY,i.drawImageW,i.drawImageH,i.drawImageX,i.drawImageY,i.scale)),!0}fill_(e){const t=this.alignAndScaleFill_;if(t){const n=de(this.renderedTransform_,[0,0]),i=512*this.pixelRatio;e.save(),e.translate(n[0]%i,n[1]%i),t!==1&&e.scale(t,t),e.rotate(this.viewRotation_)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],t[1]&&(e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6]))}drawLabelWithPointPlacement_(e,t,n,i){const r=this.textStates[t],o=this.createLabel(e,t,i,n),a=this.strokeStates[n],l=this.pixelRatio,h=Zo(Array.isArray(e)?e[0]:e,r.textAlign||Ps),c=Ur[r.textBaseline||Or],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_(e,t,n,i,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&Ut(n,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Nt(this.coordinates,0,this.coordinates.length,2,n,this.pixelCoordinates_),eu(this.renderedTransform_,n));let u=0;const d=i.length;let f=0,g,m,_,p,y,E,x,T,R,S,v,w,I,F=0,L=0;const b=this.coordinateCache_,M=this.viewRotation_,K=Math.round(Math.atan2(-n[1],n[0])*1e12)/1e12,A={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:M},Z=this.instructions!=i||this.overlaps?0:200;let G,H,Q,le;for(;uZ&&(this.fill_(e),F=0),L>Z&&(e.stroke(),L=0),!F&&!L&&(e.beginPath(),y=NaN,E=NaN),++u;break;case X.CIRCLE:f=P[1];const We=c[f],xe=c[f+1],tt=c[f+2],Ge=c[f+3],Lt=tt-We,Ct=Ge-xe,nt=Math.sqrt(Lt*Lt+Ct*Ct);e.moveTo(We+nt,xe),e.arc(We,xe,nt,0,2*Math.PI,!0),++u;break;case X.CLOSE_PATH:e.closePath(),++u;break;case X.CUSTOM:f=P[1],g=P[2];const Ys=P[3],xo=P[4],qi=P[5];A.geometry=Ys,A.feature=G,u in b||(b[u]=[]);const bn=b[u];qi?qi(c,f,g,2,bn):(bn[0]=c[f],bn[1]=c[f+1],bn.length=2),h&&(h.zIndex=P[6]),xo(bn,A),++u;break;case X.DRAW_IMAGE:f=P[1],g=P[2],R=P[3],m=P[4],_=P[5];let ht=P[6];const At=P[7],oi=P[8],ai=P[9],Ji=P[10];let Mn=P[11];const li=P[12];let hi=P[13];p=P[14]||"declutter";const Ie=P[15];if(!R&&P.length>=20){S=P[19],v=P[20],w=P[21],I=P[22];const ct=this.drawLabelWithPointPlacement_(S,v,w,I);R=ct.label,P[3]=R;const Dn=P[23];m=(ct.anchorX-Dn)*this.pixelRatio,P[4]=m;const ut=P[24];_=(ct.anchorY-ut)*this.pixelRatio,P[5]=_,ht=R.height,P[6]=ht,hi=R.width,P[13]=hi}let Eo;P.length>25&&(Eo=P[25]);let To,js,Vs;P.length>17?(To=P[16],js=P[17],Vs=P[18]):(To=zn,js=null,Vs=null),Ji&&K?Mn+=M:!Ji&&!K&&(Mn-=M);let Jd=0;for(;f!Br.includes(s));class Yu{constructor(e,t,n,i,r,o,a){this.maxExtent_=e,this.overlaps_=i,this.pixelRatio_=n,this.resolution_=t,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Te(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(e,t){const n=this.getClipCoords(t);e.beginPath(),e.moveTo(n[0],n[1]),e.lineTo(n[2],n[3]),e.lineTo(n[4],n[5]),e.lineTo(n[6],n[7]),e.clip()}createExecutors_(e,t){for(const n in e){let i=this.executorsByZIndex_[n];i===void 0&&(i={},this.executorsByZIndex_[n]=i);const r=e[n];for(const o in r){const a=r[o];i[o]=new cp(this.resolution_,this.pixelRatio_,this.overlaps_,a,t)}}}hasExecutors(e){for(const t in this.executorsByZIndex_){const n=this.executorsByZIndex_[t];for(let i=0,r=e.length;i0){if(!o||S==="none"||f!=="Image"&&f!=="Text"||o.includes(T)){const F=(d[w]-3)/4,L=i-F%a,b=i-(F/a|0),M=r(T,R,L*L+b*b);if(M)return M}c.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(Ot);let _,p,y,E,x;for(_=m.length-1;_>=0;--_){const T=m[_].toString();for(y=this.executorsByZIndex_[T],p=kn.length-1;p>=0;--p)if(f=kn[p],E=y[f],E!==void 0&&(x=E.executeHitDetection(c,l,n,g,u),x))return x}}getClipCoords(e){const t=this.maxExtent_;if(!t)return null;const n=t[0],i=t[1],r=t[2],o=t[3],a=[n,i,n,o,r,o,r,i];return Nt(a,0,8,2,e,a),a}isEmpty(){return jn(this.executorsByZIndex_)}execute(e,t,n,i,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?af:Ot),o=o||kn;const h=kn.length;for(let c=0,u=l.length;cp.execute(T,t,n,i,r,a)),x&&E.restore(),y){y.offset();const T=l[c]*h+kn.indexOf(_);this.deferredZIndexContexts_[T]||(this.deferredZIndexContexts_[T]=[]),this.deferredZIndexContexts_[T].push(y)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(Ot);for(let n=0,i=t.length;n{r.draw(this.renderedContext_),r.clear()}),e[t[n]].length=0}}const Ko={};function dp(s){if(Ko[s]!==void 0)return Ko[s];const e=s*2+1,t=s*s,n=new Array(t+1);for(let r=0;r<=s;++r)for(let o=0;o<=s;++o){const a=r*r+o*o;if(a>t)break;let l=n[a];l||(l=[],n[a]=l),l.push(((s+r)*e+(s+o))*4+3),r>0&&l.push(((s-r)*e+(s+o))*4+3),o>0&&(l.push(((s+r)*e+(s-o))*4+3),r>0&&l.push(((s-r)*e+(s-o))*4+3))}const i=[];for(let r=0,o=n.length;ru*this.pixelRatio_),lineDashOffset:(o||nn)*this.pixelRatio_,lineJoin:a!==void 0?a:Bi,lineWidth:(l!==void 0?l:Is)*this.pixelRatio_,miterLimit:h!==void 0?h:vs,strokeStyle:Dt(n||ws)}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}const n=e.getPixelRatio(this.pixelRatio_),i=e.getAnchor(),r=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=i[0]*n,this.imageAnchorY_=i[1]*n,this.imageHeight_=t[1]*n,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();const o=e.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/n,o[1]*this.pixelRatio_/n],this.imageWidth_=t[0]*n}setTextStyle(e){if(!e)this.text_="";else{const t=e.getFill();if(!t)this.textFillState_=null;else{const f=t.getColor();this.textFillState_={fillStyle:Dt(f||Ke)}}const n=e.getStroke();if(!n)this.textStrokeState_=null;else{const f=n.getColor(),g=n.getLineCap(),m=n.getLineDash(),_=n.getLineDashOffset(),p=n.getLineJoin(),y=n.getWidth(),E=n.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Ui,lineDash:m||tn,lineDashOffset:_||nn,lineJoin:p!==void 0?p:Bi,lineWidth:y!==void 0?y:Is,miterLimit:E!==void 0?E:vs,strokeStyle:Dt(f||ws)}}const i=e.getFont(),r=e.getOffsetX(),o=e.getOffsetY(),a=e.getRotateWithView(),l=e.getRotation(),h=e.getScaleArray(),c=e.getText(),u=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:i!==void 0?i:Pu,textAlign:u!==void 0?u:Ps,textBaseline:d!==void 0?d:Or},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 st=.5;function ju(s,e,t,n,i,r,o,a,l){const h=l?to(i):i,c=s[0]*st,u=s[1]*st,d=ve(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new fp(d,st,i,null,o,a,l?eo(gg(),l):null),m=t.length,_=Math.floor((256*256*256-1)/m),p={};for(let E=1;E<=m;++E){const x=t[E-1],T=x.getStyleFunction()||n;if(!T)continue;let R=T(x,r);if(!R)continue;Array.isArray(R)||(R=[R]);const v=(E*_).toString(16).padStart(7,"#00000");for(let w=0,I=R.length;w0;return u&&Promise.all(l).then(()=>i(null)),pp(s,e,t,n,r,o,a),u}function pp(s,e,t,n,i,r,o){const a=t.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(n,i);if(t.getRenderer())Hu(s,l,t,e,o);else{const c=Zu[l.getType()];c(s,l,t,e,o,r)}}function Hu(s,e,t,n,i){if(e.getType()=="GeometryCollection"){const o=e.getGeometries();for(let a=0,l=o.length;a{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const n=this.frameState.size.slice(),i=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=n[0]*st,d=n[1]*st;c.push(this.getRenderTransform(i,r,o,st,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!pn(g,l)){let m=l[0];const _=ne(g);let p=0,y;for(;mg[2];)++p,y=_*p,c.push(this.getRenderTransform(i,r,o,st,u,d,y).slice()),m-=_}this.hitDetectionImageData_=ju(n,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,Oa(r,this.renderedPixelRatio_),null)}t(Vu(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,n,i,r){if(!this.replayGroup_)return;const o=t.viewState.resolution,a=t.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){const m=D(d),_=h[m];if(_){if(_!==!0&&g<_.distanceSq){if(g===0)return h[m]=!0,r.splice(r.lastIndexOf(_),1),i(d,l,f);_.geometry=f,_.distanceSq=g}}else{if(g===0)return h[m]=!0,i(d,l,f);r.push(h[m]={feature:d,layer:l,geometry:f,distanceSq:g,callback:i})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(e,o,a,n,c,u?t.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){const t=this.getLayer(),n=t.getSource();if(!n)return!1;const i=e.viewHints[he.ANIMATING],r=e.viewHints[he.INTERACTING],o=t.getUpdateWhileAnimating(),a=t.getUpdateWhileInteracting();if(this.ready&&!o&&i||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=e.extent,h=e.viewState,c=h.projection,u=h.resolution,d=e.pixelRatio,f=t.getRevision(),g=t.getRenderBuffer();let m=t.getRenderOrder();m===void 0&&(m=_p);const _=h.center.slice(),p=sn(l,g*u),y=p.slice(),E=[p.slice()],x=c.getExtent();if(n.getWrapX()&&c.canWrapX()&&!pn(x,e.extent)){const M=ne(x),K=Math.max(ne(p)/2,M);p[0]=x[0]-K,p[2]=x[2]+K,el(_,c);const A=$c(E[0],c);A[0]x[0]&&A[2]>x[2]&&E.push([A[0]-M,A[1],A[2]-M,A[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!e.declutter&&pn(this.wrappedRenderedExtent_,p))return Ut(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const T=new Wu(Ku(u,d),p,u,d);let R;for(let M=0,K=E.length;M{let A;const Z=M.getStyleFunction()||t.getStyleFunction();if(Z&&(A=Z(M,u)),A){const G=this.renderFeature(M,S,A,T,R,this.getLayer().getDeclutter(),K);v=v&&!G}},I=to(p),F=n.getFeaturesInExtent(I);m&&F.sort(m);for(let M=0,K=F.length;M{if(m.getState()!==U.LOADED)return;this.image=m;const _=m.getPixelRatio(),p=wp(m.getResolution())*t/_;this.renderedResolution=p,this.coordinateToVectorPixelTransform_=lt(this.coordinateToVectorPixelTransform_,l/2,h/2,1/p,-1/p,0,-n.center[0],-n.center[1])}),m.load()}return this.image&&(this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice()),!this.getLayer().getSource()?.loading&&!!this.image}preRender(){}postRender(){}renderDeclutter(){}forEachFeatureAtCoordinate(e,t,n,i,r){return this.vectorRenderer_?this.vectorRenderer_.forEachFeatureAtCoordinate(e,t,n,i,r):super.forEachFeatureAtCoordinate(e,t,n,i,r)}}class F0 extends Ki{constructor(e){e=e||{};const t=Object.assign({},e);delete t.imageRatio,super(t),this.imageRatio_=e.imageRatio!==void 0?e.imageRatio:1}getImageRatio(){return this.imageRatio_}createRenderer(){return new Pp(this)}}let Ip=!1;function Lp(s,e,t,n,i,r,o){const a=new XMLHttpRequest;a.open("GET",typeof s=="function"?s(t,n,i):s,!0),e.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=Ip,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const h=e.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(e.readFeatures(c,{extent:t,featureProjection:i}),e.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function hc(s,e){return function(t,n,i,r,o){Lp(s,e,t,n,i,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function Ap(s,e){return[[-1/0,-1/0,1/0,1/0]]}class ze extends It{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if(typeof e.getSimplifiedGeometry=="function"){const t=e;this.setGeometry(t)}else{const t=e;this.setProperties(t)}}clone(){const e=new ze(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());const t=this.getGeometry();t&&e.setGeometry(t.clone());const n=this.getStyle();return n&&e.setStyle(n),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(ue(this.geometryChangeKey_),this.geometryChangeKey_=null);const e=this.getGeometry();e&&(this.geometryChangeKey_=J(e,V.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?Fp(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function Fp(s){if(typeof s=="function")return s;let e;return Array.isArray(s)?e=s:(te(typeof s.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[s]),function(){return e}}function Ju(s,e,t,n){const i=[];let r=Je();for(let o=0,a=t.length;o1?o:2,r=r||new Array(o);for(let c=0;c>1;i=n[0]||e[1]<=n[1]&&e[3]>=n[1]?!0:qa(e,this.intersectsCoordinate.bind(this))}return!1}setCenter(e){const t=this.stride,n=this.flatCoordinates[t]-this.flatCoordinates[0],i=e.slice();i[t]=i[0]+n;for(let r=1;re.clone())}class at extends Fn{constructor(e,t){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,t!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}appendCoordinate(e){se(this.flatCoordinates,e),this.changed()}clone(){const e=new at(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,n,i){return i{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),t&&this.simplifiedGeometry_.applyTransform(t);const n=this.simplifiedGeometry_.getFlatCoordinates();let i;switch(this.type_){case"LineString":n.length=so(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,n,0),i=[n.length];break;case"MultiLineString":i=[],n.length=au(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,n,0,i);break;case"Polygon":i=[],n.length=fl(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),n,0,i);break}return i&&(this.simplifiedGeometry_=new He(this.type_,n,i,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}}He.prototype.getFlatCoordinates=He.prototype.getOrientedFlatCoordinates;class Ga{constructor(e){this.rbush_=new Pl(e),this.items_={}}insert(e,t){const n={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:t};this.rbush_.insert(n),this.items_[D(t)]=n}load(e,t){const n=new Array(t.length);for(let i=0,r=t.length;is):null}const Le={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class fn extends Tt{constructor(e,t,n){super(e),this.feature=t,this.features=n}}class ed extends Qu{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=Es,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(te(this.format_,"`format` must be set when `url` is set"),this.loader_=hc(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:Ap;const t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Ga:null,this.loadedExtentsRtree_=new Ga,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let n,i;Array.isArray(e.features)?i=e.features:e.features&&(n=e.features,i=n.getArray()),!t&&n===void 0&&(n=new Ve(i)),i!==void 0&&this.addFeaturesInternal(i),n!==void 0&&this.bindFeaturesCollection_(n)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){const t=D(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);const n=e.getGeometry();if(n){const i=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(i,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new fn(Le.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof He||(this.featureChangeKeys_[e]=[J(t,V.CHANGE,this.handleFeatureChange_,this),J(t,Oi.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let n=!0;if(t.getId()!==void 0){const i=String(t.getId());if(!(i in this.idIndex_))this.idIndex_[i]=t;else if(t instanceof He){const r=this.idIndex_[i];r instanceof He?Array.isArray(r)?r.push(t):this.idIndex_[i]=[r,t]:n=!1}else n=!1}return n&&(te(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),n}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){const t=[],n=[],i=[];for(let r=0,o=e.length;r{t||(t=!0,this.addFeature(n.element),t=!1)}),e.addEventListener(Re.REMOVE,n=>{t||(t=!0,this.removeFeature(n.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(const n in this.featureChangeKeys_)this.featureChangeKeys_[n].forEach(ue);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(n=>{this.removeFeatureInternal(n)});for(const n in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[n])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const t=new fn(Le.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){const n=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(n,function(i){const r=i.getGeometry();if(r instanceof He||r.intersectsCoordinate(e))return t(i)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(n){const i=n.getGeometry();if(i instanceof He||i.intersectsExtent(e)){const r=t(n);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),jn(this.nullGeometryFeatures_)||se(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){const t=[];return this.forEachFeatureAtCoordinateDirect(e,function(n){t.push(n)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);const i=Xc(e,t);return[].concat(...i.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){const n=e[0],i=e[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return t=t||wn,this.featuresRtree_.forEachInExtent(l,function(h){if(t(h)){const c=h.getGeometry(),u=a;if(a=c instanceof He?0:c.closestPointXY(n,i,o,a),a{--this.loadingExtentsCount_,this.dispatchEvent(new fn(Le.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new fn(Le.FEATURESLOADERROR))}),i.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){const t=this.loadedExtentsRtree_,n=t.forEachInExtent(e,function(i){if(Kn(i.extent,e))return i});n&&t.remove(n)}removeFeatures(e){let t=!1;for(let n=0,i=e.length;n=0;i[o?"CRS":"SRS"]=n.getCode();const a=o&&r.startsWith("ne")?[e[1],e[0],e[3],e[2]]:e;return i.BBOX=a.join(","),td(s,i)}function Bp(s,e,t,n,i,r,o){r=Object.assign({REQUEST:"GetMap"},r);const a=e/t,l=[xh(ne(s)/a,dc),xh(be(s)/a,dc)];if(t!=1)switch(o){case"geoserver":const c=90*t+.5|0;"FORMAT_OPTIONS"in r?r.FORMAT_OPTIONS+=";dpi:"+c:r.FORMAT_OPTIONS="dpi:"+c;break;case"mapserver":r.MAP_RESOLUTION=90*t;break;case"carmentaserver":case"qgis":r.DPI=90*t;break;default:throw new Error("Unknown `serverType` configured")}return Up(i,s,l,n,r)}function fc(s,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:ka,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},s)}const mi=[0,0,0],gn=5;class nd{constructor(e){this.minZoom=e.minZoom!==void 0?e.minZoom:0,this.resolutions_=e.resolutions,te(hf(this.resolutions_,(i,r)=>r-i),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let i=0,r=this.resolutions_.length-1;i{const o=new Gl(Math.min(0,i[0]),Math.max(i[0]-1,-1),Math.min(0,i[1]),Math.max(i[1]-1,-1));if(n){const a=this.getTileRangeForExtentAndZ(n,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}):n&&this.calculateTileRanges_(n)}forEachTileCoord(e,t,n){const i=this.getTileRangeForExtentAndZ(e,t);for(let r=i.minX,o=i.maxX;r<=o;++r)for(let a=i.minY,l=i.maxY;a<=l;++a)n([t,r,a])}forEachTileCoordParentTileRange(e,t,n,i){let r,o,a,l=null,h=e[0]-1;for(this.zoomFactor_===2?(o=e[1],a=e[2]):l=this.getTileCoordExtent(e,i);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=gi(o,o,a,a,n)):r=this.getTileRangeForExtentAndZ(l,h,n),t(h,r))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,n){if(e[0]this.maxZoom||t0?n:Math.max(r/t[0],i/t[1]);const o=e+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(e,t,n,i,r,o){const a=this.getKey(),l=Er(this,a,e,t,n);if(o&&o.containsKey(l))return o.get(l);const h=this.createTile_(e,t,n,i,r,a);return o?.set(l,h),h}setRenderReprojectionEdges(e){this.renderReprojectionEdges_!=e&&(this.renderReprojectionEdges_=e,this.changed())}setTileGridForProjection(e,t){const n=_e(e);if(n){const i=D(n);i in this.tileGridForProjection||(this.tileGridForProjection[i]=t)}}}function od(s,e){if(rt){const t=s.getCrossOrigin();let n="same-origin",i="same-origin";t==="anonymous"||t===""?(n="cors",i="omit"):t==="use-credentials"&&(n="cors",i="include"),fetch(e,{mode:n,credentials:i}).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=e}class b0 extends rd{constructor(e){e=e||{};const t=Object.assign({},e.params);super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:e.projection,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileClass:e.tileClass,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0,this.params_=t,this.v13_=!0,this.serverType_=e.serverType,this.hidpi_=e.hidpi!==void 0?e.hidpi:!0,this.tmpExtent_=Je(),this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(e,t,n,i){const r=_e(n),o=this.getProjection()||r;let a=this.getTileGrid();a||(a=this.getTileGridForProjection(o));const l=Ns(e,r,o),h=Da(o,r,e,t),c=a.getZForResolution(h,this.zDirection),u=a.getResolution(c),d=a.getTileCoordForCoordAndZ(l,c);if(a.getResolutions().length<=d[0])return;let f=a.getTileCoordExtent(d,this.tmpExtent_);const g=this.gutter_;g!==0&&(f=sn(f,u*g,f));const m={QUERY_LAYERS:this.params_.LAYERS};Object.assign(m,fc(this.params_,"GetFeatureInfo"),i);const _=Math.floor((l[0]-f[0])/u),p=Math.floor((f[3]-l[1])/u);return m[this.v13_?"I":"X"]=_,m[this.v13_?"J":"Y"]=p,this.getRequestUrl_(d,f,1,o||r,m)}getLegendUrl(e,t){if(this.urls[0]===void 0)return;const n={SERVICE:"WMS",VERSION:ka,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(t===void 0||t.LAYER===void 0){const i=this.params_.LAYERS;if(!(!Array.isArray(i)||i.length===1))return;n.LAYER=i}if(e!==void 0){const i=this.getProjection()?this.getProjection().getMetersPerUnit():1,r=28e-5;n.SCALE=e*i/r}return Object.assign(n,t),td(this.urls[0],n)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(e,t,n,i,r){const o=this.urls;if(!o)return;let a;if(o.length==1)a=o[0];else{const l=Qt(Uu(e),o.length);a=o[l]}return Bp(t,(this.tileGrid||this.getTileGridForProjection(i)).getResolution(e[0]),n,i,a,r,this.serverType_)}getTilePixelRatio(e){return!this.hidpi_||this.serverType_===void 0?1:e}getKeyForParams_(){let e=0;const t=[];for(const n in this.params_)t[e++]=n+"-"+this.params_[n];return t.join("/")}setParams_(e){this.params_=e,this.updateV13_(),this.setKey(this.getKeyForParams_())}setParams(e){this.setParams_(Object.assign({},e))}updateParams(e){this.setParams_(Object.assign(this.params_,e))}updateV13_(){const e=this.params_.VERSION||ka;this.v13_=Wc(e,"1.3")>=0}tileUrlFunction(e,t,n){let i=this.getTileGrid();if(i||(i=this.getTileGridForProjection(n)),i.getResolutions().length<=e[0])return;t!=1&&(!this.hidpi_||this.serverType_===void 0)&&(t=1);const r=i.getResolution(e[0]);let o=i.getTileCoordExtent(e,this.tmpExtent_);const a=this.gutter_;a!==0&&(o=sn(o,r*a,o));const l=Object.assign({},fc(this.params_,"GetMap"));return this.getRequestUrl_(e,o,t,n,l)}}class Hp extends rd{constructor(e){e=e||{};const t=e.projection!==void 0?e.projection:"EPSG:3857",n=e.tileGrid!==void 0?e.tileGrid:Xp({extent:$l(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:n,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}}const qp='© OpenStreetMap contributors.';class M0 extends Hp{constructor(e){e=e||{};let t;e.attributions!==void 0?t=e.attributions:t=[qp];const n=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",i=e.url!==void 0?e.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:t,attributionsCollapsible:!1,cacheSize:e.cacheSize,crossOrigin:n,interpolate:e.interpolate,maxZoom:e.maxZoom!==void 0?e.maxZoom:19,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:(r,o)=>{const a=r.getImage();!rt&&a instanceof HTMLImageElement&&(a.referrerPolicy="origin-when-cross-origin"),(e.tileLoadFunction||od)(r,o)},transition:e.transition,url:i,wrapX:e.wrapX,zDirection:e.zDirection})}}class Wl{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=ze,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let n=t.dataProjection?_e(t.dataProjection):this.readProjection(e);t.extent&&n&&n.getUnits()==="tile-pixels"&&(n=_e(n),n.setWorldExtent(t.extent)),t={dataProjection:n,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return $()}readFeature(e,t){return $()}readFeatures(e,t){return $()}readGeometry(e,t){return $()}readProjection(e){return $()}writeFeature(e,t){return $()}writeFeatures(e,t){return $()}writeGeometry(e,t){return $()}}function Jn(s,e,t){const n=t?_e(t.featureProjection):null,i=t?_e(t.dataProjection):null;let r=s;if(n&&i&&!Yn(n,i)){e&&(r=s.clone());const o=e?n:i,a=e?i:n;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(Hn(o,a))}if(e&&t&&t.decimals!==void 0){const o=Math.pow(10,t.decimals),a=function(l){for(let h=0,c=l.length;had({...s,geometry:r})).flat();const n=t.type==="MultiPolygon"?"Polygon":t.type;if(n==="GeometryCollection"||n==="Circle")throw new Error("Unsupported geometry type: "+n);const i=t.layout.length;return Jn(new He(n,n==="Polygon"?Qp(t.flatCoordinates,t.ends,i):t.flatCoordinates,t.ends?.flat(),i,s.properties||{},s.id).enableSimplifyTransformed(),!1,e)}function Yl(s,e){if(!s)return null;if(Array.isArray(s)){const n=s.map(i=>Yl(i,e));return new Ze(n)}const t=Jp[s.type];return Jn(new t(s.flatCoordinates,s.layout||"XY",s.ends),!1,e)}class ey extends Wl{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(or(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(or(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return $()}readFeaturesFromObject(e,t){return $()}readGeometry(e,t){return this.readGeometryFromObject(or(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return $()}readProjection(e){return this.readProjectionFromObject(or(e))}readProjectionFromObject(e){return $()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return $()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return $()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return $()}}function or(s){if(typeof s=="string"){const e=JSON.parse(s);return e||null}return s!==null?s:null}class D0 extends ey{constructor(e){e=e||{},super(),this.dataProjection=_e(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=_e(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,t){let n=null;e.type==="Feature"?n=e:n={type:"Feature",geometry:e,properties:null};const i=jl(n.geometry);if(this.featureClass===He)return ad({geometry:i,id:n.id,properties:n.properties},t);const r=new ze;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&r.setGeometryName(n.geometry_name),r.setGeometry(Yl(i,t)),"id"in n&&r.setId(n.id),n.properties&&r.setProperties(n.properties,!0),r}readFeaturesFromObject(e,t){const n=e;let i=null;if(n.type==="FeatureCollection"){const r=e;i=[];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(e,t,n){const i=this.getScaleForResolution(),r=i<1?Math.round(1/i).toLocaleString()+" : 1":"1 : "+Math.round(i).toLocaleString(),o=this.scaleBarSteps_,a=e/o,l=[this.createMarker("absolute")];for(let c=0;c
`+this.createMarker("relative")+(c%2===0||o===2?this.createStepText(c,e,!1,t,n):"")+"")}return l.push(this.createStepText(o,e,!0,t,n)),(this.scaleBarText_?`
`+r+"
":"")+l.join("")}createMarker(e){return`
`}createStepText(e,t,n,i,r){const a=(e===0?0:Math.round(i/this.scaleBarSteps_*e*100)/100)+(e===0?"":" "+r),l=e===0?-3:t/this.scaleBarSteps_*-1,h=e===0?0:t/this.scaleBarSteps_*2;return`
`+a+"
"}getScaleForResolution(){const e=Ir(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m"),t=this.dpi_||as,n=1e3/25.4;return e*n*t}render(e){const t=e.frameState;t?this.viewState_=t.viewState:this.viewState_=null,this.updateElement_()}}const py={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},gc={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};class yy extends zu{constructor(e,t){super(e,t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=Te(),this.tileClipContexts_=null}enqueueTilesForNextExtent(){return this.getLayer().getRenderMode()!=="vector"}drawTile(e,t,n,i,r,o,a,l){this.updateExecutorGroup_(e,t.pixelRatio,t.viewState.projection),this.tileImageNeedsRender_(e)&&this.renderTileImage_(e,t),super.drawTile(e,t,n,i,r,o,a,l)}getTile(e,t,n,i){const r=this.getOrCreateTile(e,t,n,i);if(!r)return null;const o=i.viewState,a=o.resolution,l=i.viewHints,h=this.getLayer().getSource(),c=h.getTileGridForProjection(o.projection),u=!(l[he.ANIMATING]||l[he.INTERACTING]),d=c.getZForResolution(a,h.zDirection)===e;return u&&d?r.wantedResolution=a:r.wantedResolution||(r.wantedResolution=c.getResolution(e)),r}prepareFrame(e){const t=this.getLayer().getRevision();return this.renderedLayerRevision_!==t&&(this.renderedLayerRevision_=t,this.renderedTiles.length=0),super.prepareFrame(e)}updateExecutorGroup_(e,t,n){const i=this.getLayer(),r=i.getRevision(),o=i.getRenderOrder()||null,a=e.wantedResolution,l=e.getReplayState(i);if(!l.dirty&&l.renderedResolution===a&&l.renderedRevision==r&&l.renderedRenderOrder==o)return;const h=i.getSource(),c=!!i.getDeclutter(),u=h.getTileGrid(),f=h.getTileGridForProjection(n).getTileCoordExtent(e.wrappedTileCoord),g=h.getSourceTiles(t,n,e),m=D(i);delete e.hitDetectionImageData[m],e.executorGroups[m]=[],l.dirty=!1;for(let _=0,p=g.length;_E.value):null;let y;e:for(let E=0,x=g.length;E{const i=this.getLayer(),r=i.getSource(),o=this.renderedProjection,a=o.getExtent(),l=this.renderedResolution,h=r.getTileGridForProjection(o),c=de(this.renderedPixelToCoordinateTransform_,e.slice()),u=h.getTileCoordForCoordAndResolution(c,l).toString(),d=this.renderedTiles.find(E=>E.tileCoord.toString()===u&&E.getState()===B.LOADED);if(!d||d.loadingSourceTiles>0){t([]);return}r.getWrapX()&&o.canWrapX()&&!pn(a,h.getTileCoordExtent(d.tileCoord))&&el(c,o);const f=D(i),g=h.getTileCoordExtent(d.wrappedTileCoord),m=An(g),_=[(c[0]-m[0])/l,(m[1]-c[1])/l],p=d.getSourceTiles().reduce((E,x)=>E.concat(x.getFeatures()),[]);let y=d.hitDetectionImageData[f];if(!y){const E=$e(h.getTileSize(h.getZForResolution(l,r.zDirection))),x=this.renderedRotation_,T=[this.getRenderTransform(h.getTileCoordCenter(d.wrappedTileCoord),l,0,st,E[0]*st,E[1]*st,0)];y=ju(E,T,p,i.getStyleFunction(),h.getTileCoordExtent(d.wrappedTileCoord),d.getReplayState(i).renderedResolution,x),d.hitDetectionImageData[f]=y}t(Vu(_,p,y))})}getFeaturesInExtent(e){const t=[],n=this.getTileCache();if(n.getCount()===0)return t;const r=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),o=r.getZForResolution(this.renderedResolution),a={};return n.forEach(l=>{if(l.tileCoord[0]!==o||l.getState()!==B.LOADED)return;const h=l.getSourceTiles();for(let c=0,u=h.length;c=0;--_)m[_].execute(this.context,a,this.getTileRenderTransform(g,e),e.viewState.rotation,o,Br,h)}n.globalAlpha=i}renderDeferredInternal(e){const t=this.renderedTiles,n=D(this.getLayer()),i=t.reduce((l,h,c)=>(h.executorGroups[n].forEach(u=>l.push({executorGroup:u,index:c})),l),[]),r=i.map(({executorGroup:l})=>l.getDeferredZIndexContexts()),o={};for(let l=0,h=i.length;l{r.forEach((h,c)=>{h[l]&&(h[l].forEach(u=>{const{executorGroup:d,index:f}=i[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(e,t){const n=t.pixelRatio,i=t.viewState,r=i.center,o=i.resolution,a=i.rotation,l=t.size,h=Math.round(l[0]*n),c=Math.round(l[1]*n),d=this.getLayer().getSource().getTileGridForProjection(t.viewState.projection),f=e.tileCoord,g=d.getTileCoordExtent(e.wrappedTileCoord),m=d.getTileCoordExtent(f,this.tempExtent)[0]-g[0];return no(Io(this.inversePixelTransform.slice(),1/n,1/n),this.getRenderTransform(r,o,a,n,h,c,m))}postRender(e,t){const n=t.viewHints,i=!(n[he.ANIMATING]||n[he.INTERACTING]);this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice(),this.renderedRotation_=t.viewState.rotation,this.renderedOpacity_=t.layerStatesArray[t.layerIndex].opacity;const r=this.getLayer(),o=r.getRenderMode(),a=e.globalAlpha;e.globalAlpha=this.renderedOpacity_;const l=r.getDeclutter(),h=l?gc[o].filter(T=>!Br.includes(T)):gc[o],c=t.viewState,u=c.rotation,d=r.getSource(),g=d.getTileGridForProjection(c.projection).getZForResolution(c.resolution,d.zDirection),m=this.renderedTiles,_=[],p=[],y=[],E=D(r);let x=!0;for(let T=m.length-1;T>=0;--T){const R=m[T];x=x&&!R.getReplayState(r).dirty;const S=R.executorGroups[E].filter(M=>M.hasExecutors(h));if(S.length===0)continue;const v=this.getTileRenderTransform(R,t),w=R.tileCoord[0];let I=!1;const F=S[0].getClipCoords(v);let L=e,b;if(F){b=new kl,L=b.getContext();for(let M=0,K=_.length;M{this.uniforms_.push({value:e.uniforms[o],location:t.getUniformLocation(this.renderTargetProgram_,o)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(e){const t=this.getGL(),n=[t.drawingBufferWidth*this.scaleRatio_,t.drawingBufferHeight*this.scaleRatio_];if(t.bindFramebuffer(t.FRAMEBUFFER,this.getFrameBuffer()),t.bindRenderbuffer(t.RENDERBUFFER,this.getDepthBuffer()),t.viewport(0,0,n[0],n[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==n[0]||this.renderTargetTextureSize_[1]!==n[1]){this.renderTargetTextureSize_=n;const i=0,r=t.RGBA,o=0,a=t.RGBA,l=t.UNSIGNED_BYTE,h=null;t.bindTexture(t.TEXTURE_2D,this.renderTargetTexture_),t.texImage2D(t.TEXTURE_2D,i,r,n[0],n[1],o,a,l,h),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.renderTargetTexture_,0),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,n[0],n[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthBuffer_)}}apply(e,t,n,i){const r=this.getGL(),o=e.size;if(r.bindFramebuffer(r.FRAMEBUFFER,t?t.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!t){const l=D(r.canvas);if(!e.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)),e.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=e.layerStatesArray[e.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(e),n&&n(r,e),r.drawArrays(r.TRIANGLES,0,6),i&&i(r,e)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(e){const t=this.getGL();let n,i=1;this.uniforms_.forEach(function(r){if(n=typeof r.value=="function"?r.value(e):r.value,n instanceof HTMLCanvasElement||n instanceof ImageData)r.texture||(r.texture=t.createTexture()),t.activeTexture(t[`TEXTURE${i}`]),t.bindTexture(t.TEXTURE_2D,r.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n instanceof ImageData?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,n.width,n.height,0,t.UNSIGNED_BYTE,new Uint8Array(n.data)):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n),t.uniform1i(r.location,i++);else if(Array.isArray(n))switch(n.length){case 2:t.uniform2f(r.location,n[0],n[1]);return;case 3:t.uniform3f(r.location,n[0],n[1],n[2]);return;case 4:t.uniform4f(r.location,n[0],n[1],n[2],n[3]);return;default:return}else typeof n=="number"&&t.uniform1f(r.location,n)})}}const jt={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"},De={UNSIGNED_BYTE:Ey,UNSIGNED_SHORT:Ty,UNSIGNED_INT:Cy,FLOAT:hd},Wr={};function pc(s){return"shared/"+s}let yc=0;function Py(){const s="unique/"+yc;return yc+=1,s}function Iy(s){let e=Wr[s];if(!e){const t=document.createElement("canvas");t.width=1,t.height=1,t.style.position="absolute",t.style.left="0",e={users:0,context:Ry(t)},Wr[s]=e}return e.users+=1,e.context}function Ly(s){const e=Wr[s];if(!e||(e.users-=1,e.users>0))return;const t=e.context,n=t.getExtension("WEBGL_lose_context");n&&n.loseContext();const i=t.canvas;i.width=1,i.height=1,delete Wr[s]}class Ay extends bs{constructor(e){super(),e=e||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=e.canvasCacheKey?pc(e.canvasCacheKey):Py(),this.gl_=Iy(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const t=this.gl_.canvas;t.addEventListener(lr.LOST,this.boundHandleWebGLContextLost_),t.addEventListener(lr.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=Te(),this.offsetScaleMatrix_=Te(),this.tmpMat4_=ld(),this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],e.uniforms&&this.setUniforms(e.uniforms),this.postProcessPasses_=e.postProcesses?e.postProcesses.map(n=>new mc({webGlContext:this.gl_,scaleRatio:n.scaleRatio,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,uniforms:n.uniforms})):[new mc({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now(),this.maxAttributeCount_=this.gl_.getParameter(this.gl_.MAX_VERTEX_ATTRIBS)}setUniforms(e){this.uniforms_=[],this.addUniforms(e)}addUniforms(e){for(const t in e)this.uniforms_.push({name:t,value:e[t]})}canvasCacheKeyMatches(e){return this.canvasCacheKey_===pc(e)}getExtension(e){if(e in this.extensionCache_)return this.extensionCache_[e];const t=this.gl_.getExtension(e);return this.extensionCache_[e]=t,t}getInstancedRenderingExtension_(){const e=this.getExtension("ANGLE_instanced_arrays");return te(!!e,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),e}bindBuffer(e){const t=this.gl_,n=D(e);let i=this.bufferCache_[n];if(!i){const r=t.createBuffer();i={buffer:e,webGlBuffer:r},this.bufferCache_[n]=i}t.bindBuffer(e.getType(),i.webGlBuffer)}flushBufferData(e){const t=this.gl_;this.bindBuffer(e),t.bufferData(e.getType(),e.getArray(),e.getUsage())}deleteBuffer(e){const t=D(e);delete this.bufferCache_[t]}disposeInternal(){const e=this.gl_.canvas;e.removeEventListener(lr.LOST,this.boundHandleWebGLContextLost_),e.removeEventListener(lr.RESTORED,this.boundHandleWebGLContextRestored_),Ly(this.canvasCacheKey_),delete this.gl_}prepareDraw(e,t,n){const i=this.gl_,r=this.getCanvas(),o=e.size,a=e.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(e);i.bindTexture(i.TEXTURE_2D,null),i.clearColor(0,0,0,0),i.depthRange(0,1),i.clearDepth(1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.enable(i.BLEND),i.blendFunc(i.ONE,t?i.ZERO:i.ONE_MINUS_SRC_ALPHA),n?(i.enable(i.DEPTH_TEST),i.depthFunc(i.LEQUAL)):i.disable(i.DEPTH_TEST)}bindFrameBuffer(e,t){const n=this.getGL();n.bindFramebuffer(n.FRAMEBUFFER,e),t&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0)}bindInitialFrameBuffer(){const e=this.getGL(),t=this.postProcessPasses_[0].getFrameBuffer();e.bindFramebuffer(e.FRAMEBUFFER,t);const n=this.postProcessPasses_[0].getRenderTargetTexture();e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0)}bindTexture(e,t,n){const i=this.gl_;i.activeTexture(i.TEXTURE0+t),i.bindTexture(i.TEXTURE_2D,e),i.uniform1i(this.getUniformLocation(n),t)}bindAttribute(e,t,n){const i=this.getGL();this.bindBuffer(e);const r=this.getAttributeLocation(t);i.enableVertexAttribArray(r),i.vertexAttribPointer(r,n,i.FLOAT,!1,0,0)}prepareDrawToRenderTarget(e,t,n,i){const r=this.gl_,o=t.getSize();r.bindFramebuffer(r.FRAMEBUFFER,t.getFramebuffer()),r.bindRenderbuffer(r.RENDERBUFFER,t.getDepthbuffer()),r.viewport(0,0,o[0],o[1]),r.bindTexture(r.TEXTURE_2D,t.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,n?r.ZERO:r.ONE_MINUS_SRC_ALPHA),i?(r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL)):r.disable(r.DEPTH_TEST)}drawElements(e,t){const n=this.gl_;this.getExtension("OES_element_index_uint");const i=n.UNSIGNED_INT,r=4,o=t-e,a=e*r;n.drawElements(n.TRIANGLES,o,i,a)}drawElementsInstanced(e,t,n){const i=this.gl_;this.getExtension("OES_element_index_uint");const r=this.getInstancedRenderingExtension_(),o=i.UNSIGNED_INT,a=4,l=t-e,h=e*a;r.drawElementsInstancedANGLE(i.TRIANGLES,l,o,h,n);for(let c=0;c{if(n=typeof r.value=="function"?r.value(e):r.value,n instanceof HTMLCanvasElement||n instanceof HTMLImageElement||n instanceof ImageData||n instanceof WebGLTexture){n instanceof WebGLTexture&&!r.texture?(r.prevValue=void 0,r.texture=n):r.texture||(r.prevValue=void 0,r.texture=t.createTexture()),this.bindTexture(r.texture,i,r.name),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE);const o=!(n instanceof HTMLImageElement)||n.complete;!(n instanceof WebGLTexture)&&o&&r.prevValue!==n&&(r.prevValue=n,t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n)),i++}else if(Array.isArray(n)&&n.length===6)this.setUniformMatrixValue(r.name,Ba(this.tmpMat4_,n));else if(Array.isArray(n)&&n.length<=4)switch(n.length){case 2:t.uniform2f(this.getUniformLocation(r.name),n[0],n[1]);return;case 3:t.uniform3f(this.getUniformLocation(r.name),n[0],n[1],n[2]);return;case 4:t.uniform4f(this.getUniformLocation(r.name),n[0],n[1],n[2],n[3]);return;default:return}else typeof n=="number"&&t.uniform1f(this.getUniformLocation(r.name),n)})}useProgram(e,t){this.disableAllAttributes_(),this.gl_.useProgram(e),this.currentProgram_=e,t&&(this.applyFrameState(t),this.applyUniforms(t))}compileShader(e,t){const n=this.gl_,i=n.createShader(t);return n.shaderSource(i,e),n.compileShader(i),i}getProgram(e,t){const n=this.gl_,i=this.compileShader(e,n.FRAGMENT_SHADER),r=this.compileShader(t,n.VERTEX_SHADER),o=n.createProgram();if(n.attachShader(o,i),n.attachShader(o,r),n.linkProgram(o),!n.getShaderParameter(i,n.COMPILE_STATUS)){const a=`Fragment shader compilation failed: ${n.getShaderInfoLog(i)}`;throw new Error(a)}if(n.deleteShader(i),!n.getShaderParameter(r,n.COMPILE_STATUS)){const a=`Vertex shader compilation failed: ${n.getShaderInfoLog(r)}`;throw new Error(a)}if(n.deleteShader(r),!n.getProgramParameter(o,n.LINK_STATUS)){const a=`GL program linking failed: ${n.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(e){const t=D(this.currentProgram_);return this.uniformLocationsByProgram_[t]===void 0&&(this.uniformLocationsByProgram_[t]={}),this.uniformLocationsByProgram_[t][e]===void 0&&(this.uniformLocationsByProgram_[t][e]=this.gl_.getUniformLocation(this.currentProgram_,e)),this.uniformLocationsByProgram_[t][e]}getAttributeLocation(e){const t=D(this.currentProgram_);return this.attribLocationsByProgram_[t]===void 0&&(this.attribLocationsByProgram_[t]={}),this.attribLocationsByProgram_[t][e]===void 0&&(this.attribLocationsByProgram_[t][e]=this.gl_.getAttribLocation(this.currentProgram_,e)),this.attribLocationsByProgram_[t][e]}makeProjectionTransform(e,t){const n=e.size,i=e.viewState.rotation,r=e.viewState.resolution,o=e.viewState.center;return lt(t,0,0,2/(r*n[0]),2/(r*n[1]),-i,-o[0],-o[1]),t}setUniformFloatValue(e,t){this.gl_.uniform1f(this.getUniformLocation(e),t)}setUniformFloatVec2(e,t){this.gl_.uniform2fv(this.getUniformLocation(e),t)}setUniformFloatVec4(e,t){this.gl_.uniform4fv(this.getUniformLocation(e),t)}setUniformMatrixValue(e,t){this.gl_.uniformMatrix4fv(this.getUniformLocation(e),!1,t)}disableAllAttributes_(){for(let e=0;e{this.clearCache(),this.removeHelper()},e.addChangeListener(ae.MAP,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(e,t){const n=this.getLayer();if(n.hasListener(Fe.PRECOMPOSE)){const i=new _s(Fe.PRECOMPOSE,void 0,t,e);n.dispatchEvent(i)}}dispatchPostComposeEvent(e,t){const n=this.getLayer();if(n.hasListener(Fe.POSTCOMPOSE)){const i=new _s(Fe.POSTCOMPOSE,void 0,t,e);n.dispatchEvent(i)}}reset(e){this.uniforms_=e.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(e){if(this.getLayer().getRenderSource()){let t=!0,n=-1,i;for(let o=0,a=e.layerStatesArray.length;o4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${s.length}(${s.map(vn).join(", ")})`}function Tr(s){const e=Et(s),t=e.length>3?e[3]:1;return Kl([e[0]/255,e[1]/255,e[2]/255,t])}function Dy(s){const e=$e(s);return Kl(e)}const na={};let Oy=0;function Fs(s){return s in na||(na[s]=Oy++),na[s]}function Ht(s){return vn(Fs(s))}function Hl(s){return"u_var_"+s}function ud(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const ia="getBandValue",Ny="u_paletteTextures",dd="featureId",fd="geometryType",za=-9999999;function Gy(s,e,t,n){const i=Me(s,e,t);return ql(i,e,n)}function ie(s){return(e,t,n)=>{const i=t.args.length,r=new Array(i);for(let o=0;o{const n=e.args[0].value;n in s.properties||(s.properties[n]={name:n,type:e.type});let r="a_prop_"+n;return Mt(e.type,Se)&&(r=`(${r} > 0.0)`),r},[C.Id]:s=>(s.featureId=!0,"a_"+dd),[C.GeometryType]:s=>(s.geometryType=!0,"a_"+fd),[C.LineMetric]:()=>"currentLineMetric",[C.Var]:(s,e)=>{const n=e.args[0].value;n in s.variables||(s.variables[n]={name:n,type:e.type});let r=Hl(n);return Mt(e.type,Se)&&(r=`(${r} > 0.0)`),r},[C.Has]:(s,e)=>{const n=e.args[0].value;return n in s.properties||(s.properties[n]={name:n,type:e.type}),`(a_prop_${n} != ${vn(za)})`},[C.Resolution]:()=>"u_resolution",[C.Zoom]:()=>"u_zoom",[C.Time]:()=>"u_time",[C.Any]:ie(s=>`(${s.join(" || ")})`),[C.All]:ie(s=>`(${s.join(" && ")})`),[C.Not]:ie(([s])=>`(!${s})`),[C.Equal]:ie(([s,e])=>`(${s} == ${e})`),[C.NotEqual]:ie(([s,e])=>`(${s} != ${e})`),[C.GreaterThan]:ie(([s,e])=>`(${s} > ${e})`),[C.GreaterThanOrEqualTo]:ie(([s,e])=>`(${s} >= ${e})`),[C.LessThan]:ie(([s,e])=>`(${s} < ${e})`),[C.LessThanOrEqualTo]:ie(([s,e])=>`(${s} <= ${e})`),[C.Multiply]:ie(s=>`(${s.join(" * ")})`),[C.Divide]:ie(([s,e])=>`(${s} / ${e})`),[C.Add]:ie(s=>`(${s.join(" + ")})`),[C.Subtract]:ie(([s,e])=>`(${s} - ${e})`),[C.Clamp]:ie(([s,e,t])=>`clamp(${s}, ${e}, ${t})`),[C.Mod]:ie(([s,e])=>`mod(${s}, ${e})`),[C.Pow]:ie(([s,e])=>`pow(${s}, ${e})`),[C.Abs]:ie(([s])=>`abs(${s})`),[C.Floor]:ie(([s])=>`floor(${s})`),[C.Ceil]:ie(([s])=>`ceil(${s})`),[C.Round]:ie(([s])=>`floor(${s} + 0.5)`),[C.Sin]:ie(([s])=>`sin(${s})`),[C.Cos]:ie(([s])=>`cos(${s})`),[C.Atan]:ie(([s,e])=>e!==void 0?`atan(${s}, ${e})`:`atan(${s})`),[C.Sqrt]:ie(([s])=>`sqrt(${s})`),[C.Match]:ie(s=>{const e=s[0],t=s[s.length-1];let n=null;for(let i=s.length-3;i>=1;i-=2){const r=s[i],o=s[i+1];n=`(${e} == ${r} ? ${o} : ${n||t})`}return n}),[C.Between]:ie(([s,e,t])=>`(${s} >= ${e} && ${s} <= ${t})`),[C.Interpolate]:ie(([s,e,...t])=>{let n="";for(let i=0;i{const e=s[s.length-1];let t=null;for(let n=s.length-3;n>=0;n-=2){const i=s[n],r=s[n+1];t=`(${i} ? ${r} : ${t||e})`}return t}),[C.In]:ie(([s,...e],t)=>{const n=My("in",t),i=[];for(let r=0;r`vec${s.length}(${s.join(", ")})`),[C.Color]:ie(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 e=s.slice(0,3).map(n=>`${n} / 255.0`);if(s.length===3)return`vec4(${e.join(", ")}, 1.0)`;const t=s[3];return`vec4(${e.join(", ")}, ${t})`}),[C.Band]:ie(([s,e,t],n)=>{if(!(ia in n.functions)){let i="";const r=n.bandCount||1;for(let o=0;o{const[t,...n]=e.args,i=n.length,r=new Uint8Array(i*4);for(let h=0;h0)return vn(s.value);if((s.type&Se)>0)return s.value.toString();if((s.type&Pe)>0)return Ht(s.value.toString());if((s.type&ge)>0)return Tr(s.value);if((s.type&et)>0)return Kl(s.value);if((s.type&_t)>0)return Dy(s.value);throw new Error(`Unexpected expression ${s.value} (expected type ${wi(e)})`)}function Uy(){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 xc=.985;function j(s,e,t){const n=bl();return Gy(e,t,n,s)}function By(s){const e=Et(s),t=e[0]*256,n=e[1],i=e[2]*256,r=Math.round(e[3]*255);return[t+n,i+r]}const zy=`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 Jl(s){return s===ge||s===_t?2:s===et?4:1}function $a(s){const e=Jl(s);return e>1?`vec${e}`:"float"}function gd(s,e){for(const t in e.variables){const n=e.variables[t],i=Hl(n.name);let r=$a(n.type);n.type===ge&&(r="vec4"),s.addUniform(i,r)}for(const t in e.properties){const n=e.properties[t],i=$a(n.type),r=`a_prop_${n.name}`;n.type===ge?s.addAttribute(r,i,`unpackColor(${r})`,"vec4"):s.addAttribute(r,i)}for(const t in e.functions)s.addVertexShaderFunction(e.functions[t]),s.addFragmentShaderFunction(e.functions[t])}function _d(s,e){const t={};for(const n in s.variables){const i=s.variables[n],r=Hl(i.name);t[r]=()=>{const o=e[i.name];if(typeof o=="number")return o;if(typeof o=="boolean")return o?1:0;if(i.type===ge){const a=[...Et(o||"#eee")];return a[0]/=255,a[1]/=255,a[2]/=255,a[3]??=1,a}return typeof o=="string"?Fs(o):o}}return t}function md(s){const e={};for(const t in s.properties){const n=s.properties[t],i=r=>{const o=r.get(n.name);return n.type===ge?By([...Et(o||"#eee")]):typeof o=="string"?Fs(o):typeof o=="boolean"?o?1:0:o};e[`prop_${n.name}`]={size:Jl(n.type),callback:i}}return e}const pi=`#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 ${zy} `,yi=Uy();class pd{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${vn(yi["circle-radius"])} + ${vn(yi["circle-stroke-width"]*.5)})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=Tr(yi["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_=vn(yi["stroke-width"]),this.strokeColorExpression_=Tr(yi["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=Ht("round"),this.strokeJoinExpression_=Ht("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=Tr(yi["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(e,t){return this.uniforms_.push({name:e,type:t}),this}addAttribute(e,t,n,i){return this.attributes_.push({name:e,type:t,varyingName:e.replace(/^a_/,"v_"),varyingType:i??t,varyingExpression:n??e}),this}setSymbolSizeExpression(e){return this.hasSymbol_=!0,this.symbolSizeExpression_=e,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(e){return this.symbolRotationExpression_=e,this}setSymbolOffsetExpression(e){return this.symbolOffsetExpression_=e,this}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}setSymbolColorExpression(e){return this.hasSymbol_=!0,this.symbolColorExpression_=e,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(e){return this.texCoordExpression_=e,this}setFragmentDiscardExpression(e){return this.discardExpression_=e,this}getFragmentDiscardExpression(){return this.discardExpression_}setSymbolRotateWithView(e){return this.symbolRotateWithView_=e,this}setStrokeWidthExpression(e){return this.hasStroke_=!0,this.strokeWidthExpression_=e,this}setStrokeColorExpression(e){return this.hasStroke_=!0,this.strokeColorExpression_=e,this}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(e){return this.strokeOffsetExpression_=e,this}setStrokeCapExpression(e){return this.strokeCapExpression_=e,this}setStrokeJoinExpression(e){return this.strokeJoinExpression_=e,this}setStrokeMiterLimitExpression(e){return this.strokeMiterLimitExpression_=e,this}setStrokeDistanceFieldExpression(e){return this.strokeDistanceFieldExpression_=e,this}setStrokePatternLengthExpression(e){return this.strokePatternLengthExpression_=e,this}getStrokePatternLengthExpression(){return this.strokePatternLengthExpression_}setFillColorExpression(e){return this.hasFill_=!0,this.fillColorExpression_=e,this}getFillColorExpression(){return this.fillColorExpression_}addVertexShaderFunction(e){return this.vertexShaderFunctions_.includes(e)?this:(this.vertexShaderFunctions_.push(e),this)}addFragmentShaderFunction(e){return this.fragmentShaderFunctions_.includes(e)?this:(this.fragmentShaderFunctions_.push(e),this)}getSymbolVertexShader(){return this.hasSymbol_?`${pi} ${this.uniforms_.map(e=>`uniform ${e.type} ${e.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(e=>`attribute ${e.type} ${e.name}; varying ${e.varyingType} ${e.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(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(` `)} }`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${pi} ${this.uniforms_.map(e=>`uniform ${e.type} ${e.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(e=>`varying ${e.varyingType} ${e.varyingName};`).join(` `)} ${this.fragmentShaderFunctions_.join(` `)} void main(void) { ${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.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_?`${pi} ${this.uniforms_.map(e=>`uniform ${e.type} ${e.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(e=>`attribute ${e.type} ${e.name}; varying ${e.varyingType} ${e.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) > ${xc} || 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(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(` `)} }`:null}getStrokeFragmentShader(){return this.hasStroke_?`${pi} ${this.uniforms_.map(e=>`uniform ${e.type} ${e.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(e=>`varying ${e.varyingType} ${e.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) > ${xc}) { // 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 == ${Ht("butt")}) { return buttCapDistanceField(point, start, end); } else if (capType == ${Ht("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 == ${Ht("bevel")}) { return bevelJoinField(point, start, end, width, joinAngle); } else if (joinType == ${Ht("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(e=>` ${e.varyingType} ${e.name} = ${e.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_?`${pi} ${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(` `)} attribute vec2 a_position; attribute vec2 a_hitColor; varying vec4 v_hitColor; ${this.attributes_.map(e=>`attribute ${e.type} ${e.name}; varying ${e.varyingType} ${e.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(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(` `)} }`:null}getFillFragmentShader(){return this.hasFill_?`${pi} ${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(` `)} varying vec4 v_hitColor; ${this.attributes_.map(e=>`varying ${e.varyingType} ${e.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(e=>` ${e.varyingType} ${e.name} = ${e.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 Yr{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(e,t){for(let n=0;n0?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",t.slice(g,m),d,i,r,o,a)}break}case"MultiLineString":{const h=n;for(let c=0,u=h.length;c0?h[c-1]:0;this.addCoordinates_("LineString",t.slice(d,h[c]),null,i,r,o,a)}break}case"MultiPoint":for(let h=0,c=t.length;h1){this.addCoordinates_("MultiPolygon",t,d,i,r,o,a);return}}this.polygonBatch.entries[r]||(this.polygonBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]})),l=t.length/o;const c=n.length,u=n.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($y(t,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",t.slice(g,h[d]),null,i,r,o,a)}break}case"Point":this.pointBatch.entries[r]||(this.pointBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[]})),this.pointBatch.geometriesCount++,this.pointBatch.entries[r].flatCoordss.push(t);break;case"LineString":case"LinearRing":this.lineStringBatch.entries[r]||(this.lineStringBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[],verticesCount:0})),l=t.length/o,this.lineStringBatch.verticesCount+=l,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[r].flatCoordss.push(Xy(t,o,a)),this.lineStringBatch.entries[r].verticesCount+=l;break}}addRefToEntry_(e,t){const n=this.uidToRef_.get(e),i=n||this.freeGlobalRef_.pop()||++this.globalCounter_;return t.ref=i,n||(this.refToFeature_.set(i,t.feature),this.uidToRef_.set(e,i)),t}removeRef_(e,t){if(!e)throw new Error("This feature has no ref: "+t);this.refToFeature_.delete(e),this.uidToRef_.delete(t),this.freeGlobalRef_.push(e)}changeFeature(e,t){if(!this.uidToRef_.get(D(e)))return;this.removeFeature(e);let n=e.getGeometry();n&&(t&&(n=n.clone(),n.applyTransform(t)),this.addGeometry_(n,e))}removeFeature(e){let t=this.clearFeatureEntryInPointBatch_(e);t=this.clearFeatureEntryInPolygonBatch_(e)||t,t=this.clearFeatureEntryInLineStringBatch_(e)||t,t&&this.removeRef_(t.ref,D(t.feature))}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(e){return this.refToFeature_.get(e)}isEmpty(){return this.globalCounter_===0}filter(e){const t=new Yr;t.globalCounter_=this.globalCounter_,t.uidToRef_=this.uidToRef_,t.refToFeature_=this.refToFeature_;let n=!0;for(const i of this.refToFeature_.values())e(i)&&(t.addFeature(i),n=!1);return n?new Yr:t}}function $y(s,e){return e===2?s:s.filter((t,n)=>n%e<2)}function Xy(s,e,t){return e===3&&t==="XYM"?s:e===4?s.filter((n,i)=>i%e!==2):e===3?s.map((n,i)=>i%e!==2?n:0):new Array(s.length*1.5).fill(0).map((n,i)=>i%3===2?0:s[Math.round(i/1.5)])}function Wy(){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 sa={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function Yy(s,e){e=e||[];const t=256,n=t-1,i=Math.floor(s/t/t/t)/n,r=Math.floor(s/t/t)%t/n,o=Math.floor(s/t)%t/n,a=s%t/n;return e[0]=i*256*255+r*255,e[1]=o*256*255+a*255,e}function jy(s){let e=0;const t=256,n=t-1;return e+=Math.round(s[0]*t*t*t*n),e+=Math.round(s[1]*t*t*n),e+=Math.round(s[2]*t*n),e+=Math.round(s[3]*n),e}function Ql(s,e,t,n){let i=0;for(const r in e){const o=e[r],a=o.callback.call(t,t.feature);let l=a?.[0]??a;l===za&&console.warn('The "has" operator might return false positives.'),l===void 0?l=za:l===null&&(l=0),s[n+i++]=l,!(!o.size||o.size===1)&&(s[n+i++]=a[1],!(o.size<3)&&(s[n+i++]=a[2],!(o.size<4)&&(s[n+i++]=a[3])))}return i}function go(s){return Object.keys(s).reduce((e,t)=>e+(s[t].size||1),0)}function Vy(s,e,t,n){const i=(2+go(t))*s.geometriesCount;(!e||e.length!==i)&&(e=new Float32Array(i));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(t<<5)-t+n.charCodeAt(0),0)>>>0).toString()}function eh(s,e,t,n){if(`${n}radius`in s&&n!=="icon-"){let i=j(t,s[`${n}radius`],N);if(`${n}radius2`in s){const r=j(t,s[`${n}radius2`],N);i=`max(${i}, ${r})`}`${n}stroke-width`in s&&(i=`(${i} + ${j(t,s[`${n}stroke-width`],N)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${i} * 2. + 0.5)`)}if(`${n}scale`in s){const i=j(t,s[`${n}scale`],_t);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${i}`)}`${n}displacement`in s&&e.setSymbolOffsetExpression(j(t,s[`${n}displacement`],et)),`${n}rotation`in s&&e.setSymbolRotationExpression(j(t,s[`${n}rotation`],N)),`${n}rotate-with-view`in s&&e.setSymbolRotateWithView(!!s[`${n}rotate-with-view`])}function yd(s,e,t,n,i){let r="vec4(0.)";if(e!==null&&(r=e),t!==null&&n!==null){const l=`smoothstep(-${n} + 0.63, -${n} - 0.58, ${s})`;r=`mix(${t}, ${r}, ${l})`}const o=`(1.0 - smoothstep(-0.63, 0.58, ${s}))`;let a=`${r} * vec4(1.0, 1.0, 1.0, ${o})`;return i!==null&&(a=`${a} * vec4(1.0, 1.0, 1.0, ${i})`),a}function th(s,e,t,n,i){const r=new Image;r.crossOrigin=s[`${n}cross-origin`]===void 0?"anonymous":s[`${n}cross-origin`],te(typeof s[`${n}src`]=="string",`WebGL layers do not support expressions for the ${n}src style property`),r.src=s[`${n}src`],t[`u_texture${i}_size`]=()=>r.complete?[r.width,r.height]:[0,0],e.addUniform(`u_texture${i}_size`,"vec2");const o=`u_texture${i}_size`;return t[`u_texture${i}`]=r,e.addUniform(`u_texture${i}`,"sampler2D"),o}function nh(s,e,t,n,i){let r=j(t,s[`${e}offset`],_t);if(`${e}offset-origin`in s)switch(s[`${e}offset-origin`]){case"top-right":r=`vec2(${n}.x, 0.) + ${i} * vec2(-1., 0.) + ${r} * vec2(-1., 1.)`;break;case"bottom-left":r=`vec2(0., ${n}.y) + ${i} * vec2(0., -1.) + ${r} * vec2(1., -1.)`;break;case"bottom-right":r=`${n} - ${i} - ${r}`;break}return r}function Hy(s,e,t,n){n.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) { return length(point) - radius; }`,eh(s,e,n,"circle-");let i=null;"circle-opacity"in s&&(i=j(n,s["circle-opacity"],N));let r="coordsPx";"circle-scale"in s&&(r=`coordsPx / ${j(n,s["circle-scale"],_t)}`);let o=null;"circle-fill-color"in s&&(o=j(n,s["circle-fill-color"],ge));let a=null;"circle-stroke-color"in s&&(a=j(n,s["circle-stroke-color"],ge));let l=j(n,s["circle-radius"],N),h=null;"circle-stroke-width"in s&&(h=j(n,s["circle-stroke-width"],N),l=`(${l} + ${h} * 0.5)`);const c=`circleDistanceField(${r}, ${l})`,u=yd(c,o,a,h,i);e.setSymbolColorExpression(u)}function qy(s,e,t,n){n.functions.round=`float round(float v) { return sign(v) * floor(abs(v) + 0.5); }`,n.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); }`,n.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; }`,eh(s,e,n,"shape-");let i=null;"shape-opacity"in s&&(i=j(n,s["shape-opacity"],N));let r="coordsPx";"shape-scale"in s&&(r=`coordsPx / ${j(n,s["shape-scale"],_t)}`);let o=null;"shape-fill-color"in s&&(o=j(n,s["shape-fill-color"],ge));let a=null;"shape-stroke-color"in s&&(a=j(n,s["shape-stroke-color"],ge));let l=null;"shape-stroke-width"in s&&(l=j(n,s["shape-stroke-width"],N));const h=j(n,s["shape-points"],N);let c="0.";"shape-angle"in s&&(c=j(n,s["shape-angle"],N));let u,d=j(n,s["shape-radius"],N);if(l!==null&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in s){let g=j(n,s["shape-radius2"],N);l!==null&&(g=`${g} + ${l} * 0.5`),u=`starDistanceField(${r}, ${h}, ${d}, ${g}, ${c})`}else u=`regularDistanceField(${r}, ${h}, ${d}, ${c})`;const f=yd(u,o,a,l,i);e.setSymbolColorExpression(f)}function Jy(s,e,t,n){let i="vec4(1.0)";"icon-color"in s&&(i=j(n,s["icon-color"],ge)),"icon-opacity"in s&&(i=`${i} * vec4(1.0, 1.0, 1.0, ${j(n,s["icon-opacity"],N)})`);const r=jr(s["icon-src"]),o=th(s,e,t,"icon-",r);if(e.setSymbolColorExpression(`${i} * texture2D(u_texture${r}, v_texCoord)`).setSymbolSizeExpression(o),"icon-width"in s&&"icon-height"in s&&e.setSymbolSizeExpression(`vec2(${j(n,s["icon-width"],N)}, ${j(n,s["icon-height"],N)})`),"icon-offset"in s&&"icon-size"in s){const a=j(n,s["icon-size"],et),l=e.getSymbolSizeExpression();e.setSymbolSizeExpression(a);const h=nh(s,"icon-",n,"v_quadSizePx",a);e.setTextureCoordinateExpression(`(vec4((${h}).xyxy) + vec4(0., 0., ${a})) / (${l}).xyxy`)}if(eh(s,e,n,"icon-"),"icon-anchor"in s){const a=j(n,s["icon-anchor"],et);let l="1.0";"icon-scale"in s&&(l=j(n,s["icon-scale"],_t));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}e.setSymbolOffsetExpression(`${e.getSymbolOffsetExpression()} + ${c}`)}}function Qy(s,e,t,n){if("stroke-color"in s&&e.setStrokeColorExpression(j(n,s["stroke-color"],ge)),"stroke-pattern-src"in s){const i=jr(s["stroke-pattern-src"]),r=th(s,e,t,"stroke-pattern-",i);let o=r,a="vec2(0.)";"stroke-pattern-offset"in s&&"stroke-pattern-size"in s&&(o=j(n,s["stroke-pattern-size"],et),a=nh(s,"stroke-pattern-",n,r,o));let l="0.";"stroke-pattern-spacing"in s&&(l=j(n,s["stroke-pattern-spacing"],N));let h="0.";"stroke-pattern-start-offset"in s&&(h=j(n,s["stroke-pattern-start-offset"],N)),n.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${i}`;let u="1.";"stroke-color"in s&&(u=e.getStrokeColorExpression()),e.setStrokeColorExpression(`${u} * sampleStrokePattern(${c}, ${r}, ${a}, ${o}, ${l}, ${h}, currentLengthPx, currentRadiusRatio, v_width)`),n.functions.computeStrokePatternLength=`float computeStrokePatternLength(vec2 sampleSize, float spacingPx, float lineWidth) { float patternLengthPx = sampleSize.x / sampleSize.y * lineWidth; return patternLengthPx + spacingPx; }`,e.setStrokePatternLengthExpression(`computeStrokePatternLength(${o}, ${l}, v_width)`)}if("stroke-width"in s&&e.setStrokeWidthExpression(j(n,s["stroke-width"],N)),"stroke-offset"in s&&e.setStrokeOffsetExpression(j(n,s["stroke-offset"],N)),"stroke-line-cap"in s&&e.setStrokeCapExpression(j(n,s["stroke-line-cap"],Pe)),"stroke-line-join"in s&&e.setStrokeJoinExpression(j(n,s["stroke-line-join"],Pe)),"stroke-miter-limit"in s&&e.setStrokeMiterLimitExpression(j(n,s["stroke-miter-limit"],N)),"stroke-line-dash"in s){n.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 == ${Ht("square")}) { distanceSegment -= lineWidth * 0.5; } else if (capType == ${Ht("round")}) { distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5); } return distanceSegment; }`;let i=s["stroke-line-dash"].map(g=>j(n,g,N));i.length%2===1&&(i=[...i,...i]);let r="0.";"stroke-line-dash-offset"in s&&(r=j(n,s["stroke-line-dash-offset"],N));const a=`dashDistanceField_${jr(s["stroke-line-dash"])}`,l=i.map((g,m)=>`float dashLength${m}`).join(", "),h=i.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(", ");e.setStrokeDistanceFieldExpression(`${a}(currentLengthPx + ${r}, currentRadiusPx, capType, v_width, ${d})`);let f=i.join(" + ");e.getStrokePatternLengthExpression()&&(n.functions.combinePatternLengths=`float combinePatternLengths(float patternLength1, float patternLength2) { return patternLength1 * patternLength2; }`,f=`combinePatternLengths(${e.getStrokePatternLengthExpression()}, ${f})`),e.setStrokePatternLengthExpression(f)}}function ex(s,e,t,n){if("fill-color"in s&&e.setFillColorExpression(j(n,s["fill-color"],ge)),"fill-pattern-src"in s){const i=jr(s["fill-pattern-src"]),r=th(s,e,t,"fill-pattern-",i);let o=r,a="vec2(0.)";"fill-pattern-offset"in s&&"fill-pattern-size"in s&&(o=j(n,s["fill-pattern-size"],et),a=nh(s,"fill-pattern-",n,r,o)),n.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${i}`;let h="1.";"fill-color"in s&&(h=e.getFillColorExpression()),e.setFillColorExpression(`${h} * sampleFillPattern(${l}, ${r}, ${a}, ${o}, pxOrigin, pxPos)`)}}function Ec(s,e,t){const n=ud(),i=new pd,r={};if("icon-src"in s?Jy(s,i,r,n):"shape-points"in s?qy(s,i,r,n):"circle-radius"in s&&Hy(s,i,r,n),Qy(s,i,r,n),ex(s,i,r,n),t){const l=j(n,t,Se);i.setFragmentDiscardExpression(`!${l}`)}const o={};function a(l,h,c,u){if(!n[l])return;const d=$a(c),f=Jl(c);i.addAttribute(`a_${h}`,d),o[h]={size:f,callback:u}}return a("geometryType",fd,Pe,l=>Fs(Ml(l.getGeometry()))),a("featureId",dd,Pe|N,l=>{const h=l.getId()??null;return typeof h=="string"?Fs(h):h}),gd(i,n),{builder:i,attributes:{...o,...md(n)},uniforms:{...r,..._d(n,e)}}}const tx=[];let ra;function nx(){return ra||(ra=Wy()),ra}let ix=0;const ft={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 sx{constructor(e,t,n,i){this.helper_,this.hitDetectionEnabled_=!!i,this.styleShaders=rx(e,t),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return Yy(this.ref,tx)},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:De.FLOAT}));return r.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:r.builder.getFillVertexShader(),fragmentShader:r.builder.getFillFragmentShader(),attributesDesc:[{name:ft.POSITION,size:2,type:De.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),r.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:r.builder.getStrokeVertexShader(),fragmentShader:r.builder.getStrokeFragmentShader(),attributesDesc:[{name:ft.LOCAL_POSITION,size:2,type:De.FLOAT}],instancedAttributesDesc:[{name:ft.SEGMENT_START,size:2,type:De.FLOAT},{name:ft.MEASURE_START,size:1,type:De.FLOAT},{name:ft.SEGMENT_END,size:2,type:De.FLOAT},{name:ft.MEASURE_END,size:1,type:De.FLOAT},{name:ft.JOIN_ANGLES,size:2,type:De.FLOAT},{name:ft.DISTANCE_LOW,size:1,type:De.FLOAT},{name:ft.DISTANCE_HIGH,size:1,type:De.FLOAT},{name:ft.ANGLE_TANGENT_SUM,size:1,type:De.FLOAT},...a],instancePrimitiveVertexCount:6}),r.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:r.builder.getSymbolVertexShader(),fragmentShader:r.builder.getSymbolFragmentShader(),attributesDesc:[{name:ft.LOCAL_POSITION,size:2,type:De.FLOAT}],instancedAttributesDesc:[{name:ft.POSITION,size:2,type:De.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(n)}async generateBuffers(e,t){if(e.isEmpty())return null;const n=this.generateRenderInstructions_(e,t),[i,r,o]=await Promise.all([this.generateBuffersForType_(n.polygonInstructions,"Polygon",t),this.generateBuffersForType_(n.lineStringInstructions,"LineString",t),this.generateBuffersForType_(n.pointInstructions,"Point",t)]),a=Cs(Te(),t);return{polygonBuffers:i,lineStringBuffers:r,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(e,t){const n=this.hasFill_?Ky(e.polygonBatch,new Float32Array(0),this.customAttributes_,t):null,i=this.hasStroke_?Zy(e.lineStringBatch,new Float32Array(0),this.customAttributes_,t):null,r=this.hasSymbol_?Vy(e.pointBatch,new Float32Array(0),this.customAttributes_,t):null;return{polygonInstructions:n,lineStringInstructions:i,pointInstructions:r}}generateBuffersForType_(e,t,n){if(e===null)return null;const i=ix++;let r;switch(t){case"Polygon":r=sa.GENERATE_POLYGON_BUFFERS;break;case"LineString":r=sa.GENERATE_LINE_STRING_BUFFERS;break;case"Point":r=sa.GENERATE_POINT_BUFFERS;break}const o={id:i,type:r,renderInstructions:e.buffer,renderInstructionsTransform:n,customAttributesSize:go(this.customAttributes_)},a=nx();return a.postMessage(o,[e.buffer]),e=null,new Promise(l=>{const h=c=>{const u=c.data;if(u.id!==i||(a.removeEventListener("message",h),!this.helper_.getGL()))return;const d=new ea(Vl,Qo).fromArrayBuffer(u.indicesBuffer),f=new ea(Xr,Qo).fromArrayBuffer(u.vertexAttributesBuffer),g=new ea(Xr,Qo).fromArrayBuffer(u.instanceAttributesBuffer);this.helper_.flushBufferData(d),this.helper_.flushBufferData(f),this.helper_.flushBufferData(g),l([d,f,g])};a.addEventListener("message",h)})}render(e,t,n){for(const i of this.renderPasses_)i.fillRenderPass&&this.renderInternal_(e.polygonBuffers[0],e.polygonBuffers[1],e.polygonBuffers[2],i.fillRenderPass,t,n),i.strokeRenderPass&&this.renderInternal_(e.lineStringBuffers[0],e.lineStringBuffers[1],e.lineStringBuffers[2],i.strokeRenderPass,t,n),i.symbolRenderPass&&this.renderInternal_(e.pointBuffers[0],e.pointBuffers[1],e.pointBuffers[2],i.symbolRenderPass,t,n)}renderInternal_(e,t,n,i,r,o){const a=e.getSize();if(a===0)return;const l=i.instancedAttributesDesc.length;if(this.helper_.useProgram(i.program,r),this.helper_.bindBuffer(t),this.helper_.bindBuffer(e),this.helper_.enableAttributes(i.attributesDesc),this.helper_.bindBuffer(n),this.helper_.enableAttributesInstanced(i.instancedAttributesDesc),o(),l){const h=i.instancedAttributesDesc.reduce((u,d)=>u+(d.size||1),0),c=n.getSize()/h;this.helper_.drawElementsInstanced(0,a,c)}else this.helper_.drawElements(0,a)}setHelper(e,t=null){this.helper_=e;for(const n of this.renderPasses_)n.fillRenderPass&&(n.fillRenderPass.program=this.helper_.getProgram(n.fillRenderPass.fragmentShader,n.fillRenderPass.vertexShader)),n.strokeRenderPass&&(n.strokeRenderPass.program=this.helper_.getProgram(n.strokeRenderPass.fragmentShader,n.strokeRenderPass.vertexShader)),n.symbolRenderPass&&(n.symbolRenderPass.program=this.helper_.getProgram(n.symbolRenderPass.fragmentShader,n.symbolRenderPass.vertexShader));this.helper_.addUniforms(this.uniforms_),t&&(t.polygonBuffers&&(this.helper_.flushBufferData(t.polygonBuffers[0]),this.helper_.flushBufferData(t.polygonBuffers[1]),this.helper_.flushBufferData(t.polygonBuffers[2])),t.lineStringBuffers&&(this.helper_.flushBufferData(t.lineStringBuffers[0]),this.helper_.flushBufferData(t.lineStringBuffers[1]),this.helper_.flushBufferData(t.lineStringBuffers[2])),t.pointBuffers&&(this.helper_.flushBufferData(t.pointBuffers[0]),this.helper_.flushBufferData(t.pointBuffers[1]),this.helper_.flushBufferData(t.pointBuffers[2])))}}function rx(s,e){const t=Array.isArray(s)?s:[s];if("style"in t[0]){const n=[],i=t,r=[];for(const o of i){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=>Ec(c,e,l));n.push(...h)}return n}return"builder"in t[0]?t:t.map(n=>Ec(n,e,null))}const bt=new Uint8Array(4);class ox{constructor(e,t){this.helper_=e;const n=e.getGL();this.texture_=n.createTexture(),this.framebuffer_=n.createFramebuffer(),this.depthbuffer_=n.createRenderbuffer(),this.size_=t||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(e){Ut(e,this.size_)||(this.size_[0]=e[0],this.size_[1]=e[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){const e=this.size_,t=this.helper_.getGL();t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.readPixels(0,0,e[0],e[1],t.RGBA,t.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(e,t){if(e<0||t<0||e>this.size_[0]||t>=this.size_[1])return bt[0]=0,bt[1]=0,bt[2]=0,bt[3]=0,bt;this.readAll();const n=Math.floor(e)+(this.size_[1]-Math.floor(t)-1)*this.size_[0];return bt[0]=this.data_[n*4],bt[1]=this.data_[n*4+1],bt[2]=this.data_[n*4+2],bt[3]=this.data_[n*4+3],bt}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){const e=this.size_,t=this.helper_.getGL();this.texture_=this.helper_.createTexture(e,null,this.texture_),t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.viewport(0,0,e[0],e[1]),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture_,0),t.bindRenderbuffer(t.RENDERBUFFER,this.depthbuffer_),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e[0],e[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(e[0]*e[1]*4)}}function ax(s,e){const t=s.viewState.projection,i=e.getSource().getWrapX()&&t.canWrapX(),r=t.getExtent(),o=s.extent,a=i?ne(r):null,l=i?Math.ceil((o[2]-r[2])/a)+1:1;return[i?Math.floor((o[0]-r[0])/a):0,l,a]}const xi={...jt,RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",GLOBAL_ALPHA:"u_globalAlpha"};class lx extends Zl{constructor(e,t){const n={[xi.RENDER_EXTENT]:[0,0,0,0],[xi.PATTERN_ORIGIN]:[0,0],[xi.GLOBAL_ALPHA]:1};super(e,{uniforms:n,postProcesses:t.postProcesses}),this.hitDetectionEnabled_=!t.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=Je(),this.currentTransform_=Te(),this.tmpCoords_=[0,0],this.tmpTransform_=Te(),this.tmpMat4_=ld(),this.currentFrameStateTransform_=Te(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(t),this.batch_=new Yr,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(e){const t=this.getLayer().getSource();let n;this.batch_.addFeatures(t.getFeatures(),n),this.sourceListenKeys_=[J(t,Le.ADDFEATURE,this.handleSourceFeatureAdded_.bind(this,n)),J(t,Le.CHANGEFEATURE,this.handleSourceFeatureChanged_.bind(this,n),this),J(t,Le.REMOVEFEATURE,this.handleSourceFeatureDelete_,this),J(t,Le.CLEAR,this.handleSourceFeatureClear_,this)]}applyOptions_(e){this.styleVariables_=e.variables,this.style_=e.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new sx(this.style_,this.styleVariables_,this.helper,this.hitDetectionEnabled_)}reset(e){this.applyOptions_(e),this.helper&&this.createRenderers_(),super.reset(e)}afterHelperCreated(){this.styleRenderer_?this.styleRenderer_.setHelper(this.helper,this.buffers_):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new ox(this.helper))}handleSourceFeatureAdded_(e,t){const n=t.feature;this.batch_.addFeature(n,e)}handleSourceFeatureChanged_(e,t){const n=t.feature;this.batch_.changeFeature(n,e)}handleSourceFeatureDelete_(e){const t=e.feature;this.batch_.removeFeature(t)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(e){eu(this.tmpTransform_,this.currentFrameStateTransform_),no(this.tmpTransform_,e),this.helper.setUniformMatrixValue(xi.PROJECTION_MATRIX,Ba(this.tmpMat4_,this.tmpTransform_)),Cs(this.tmpTransform_,this.tmpTransform_),this.helper.setUniformMatrixValue(xi.SCREEN_TO_WORLD_MATRIX,Ba(this.tmpMat4_,this.tmpTransform_)),this.tmpCoords_[0]=0,this.tmpCoords_[1]=0,Cs(this.tmpTransform_,e),de(this.tmpTransform_,this.tmpCoords_),this.helper.setUniformFloatVec2(xi.PATTERN_ORIGIN,this.tmpCoords_)}renderFrame(e){const t=this.helper.getGL();this.preRender(t,e);const[n,i,r]=ax(e,this.getLayer());this.helper.prepareDraw(e),this.renderWorlds(e,!1,n,i,r),this.helper.finalizeDraw(e,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const o=this.helper.getCanvas();return this.hitDetectionEnabled_&&(this.renderWorlds(e,!0,n,i,r),this.hitRenderTarget_.clearCachedData()),this.postRender(t,e),o}prepareFrameInternal(e){this.initialFeaturesAdded_||(this.addInitialFeatures_(e),this.initialFeaturesAdded_=!0);const t=this.getLayer(),n=t.getSource(),i=e.viewState,r=!e.viewHints[he.ANIMATING]&&!e.viewHints[he.INTERACTING],o=!Kn(this.previousExtent_,e.extent),a=this.sourceRevision_{this.buffers_&&this.disposeBuffers(this.buffers_),this.buffers_=f,this.ready=!0,this.getLayer().changed()}),this.previousExtent_=e.extent.slice()}return!0}renderWorlds(e,t,n,i,r){let o=n;t&&(this.hitRenderTarget_.setSize([Math.floor(e.size[0]/2),Math.floor(e.size[1]/2)]),this.helper.prepareDrawToRenderTarget(e,this.hitRenderTarget_,!0));do this.helper.makeProjectionTransform(e,this.currentFrameStateTransform_),tu(this.currentFrameStateTransform_,o*r,0),this.buffers_&&this.styleRenderer_.render(this.buffers_,e,()=>{this.applyUniforms_(this.buffers_.invertVerticesTransform),this.helper.applyHitDetectionUniform(t)});while(++o{for(const i of n)i&&this.helper.deleteBuffer(i)};e.pointBuffers&&t(e.pointBuffers),e.lineStringBuffers&&t(e.lineStringBuffers),e.polygonBuffers&&t(e.polygonBuffers)}disposeInternal(){this.buffers_&&this.disposeBuffers(this.buffers_),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach(function(e){ue(e)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const Yt={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},hx=["#00f","#0ff","#0f0","#ff0","#f00"];class G0 extends Ki{constructor(e){e=e||{};const t=Object.assign({},e);delete t.gradient,delete t.radius,delete t.blur,delete t.weight,super(t),this.filter_=e.filter??!0,this.styleVariables_=e.variables||{},this.gradient_=null,this.addChangeListener(Yt.GRADIENT,this.handleGradientChanged_),this.setGradient(e.gradient?e.gradient:hx),this.setBlur(e.blur!==void 0?e.blur:15),this.setRadius(e.radius!==void 0?e.radius:8);const n=e.weight?e.weight:"weight";this.weight_=n,this.setRenderOrder(null)}getBlur(){return this.get(Yt.BLUR)}getGradient(){return this.get(Yt.GRADIENT)}getRadius(){return this.get(Yt.RADIUS)}handleGradientChanged_(){this.gradient_=cx(this.getGradient())}setBlur(e){const t=this.get(Yt.BLUR);if(this.set(Yt.BLUR,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setGradient(e){this.set(Yt.GRADIENT,e)}setRadius(e){const t=this.get(Yt.RADIUS);if(this.set(Yt.RADIUS,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setFilter(e){this.filter_=e,this.changed(),this.clearRenderer()}setWeight(e){this.weight_=e,this.changed(),this.clearRenderer()}createRenderer(){const e=new pd,t=ud(),n=j(t,this.filter_,Se);let i=j(t,this.getRadius(),N),r=j(t,this.getBlur(),N);const o={};typeof this.getBlur()=="number"&&(r="a_blur",o.a_blur=()=>this.getBlur(),e.addUniform("a_blur","float")),typeof this.getRadius()=="number"&&(i="a_radius",o.a_radius=()=>this.getRadius(),e.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?fe(f,0,1):1}},l="a_prop_weight",e.addAttribute("a_prop_weight","float")}else{const u=["clamp",this.weight_,0,1];l=j(t,u,N)}e.addFragmentShaderFunction(`float getBlurSlope() { float blur = max(1., ${r}); float radius = ${i}; return radius / blur; }`).setSymbolSizeExpression(`vec2(${i} + ${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(`(${i} + ${r}) * 2.`).setFillColorExpression(`vec4(${l})`).setFragmentDiscardExpression(`!${n}`),gd(e,t);const h=md(t),c=_d(t,this.styleVariables_);return new lx(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:e,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(e){Object.assign(this.styleVariables_,e),this.changed()}renderDeclutter(){}}function cx(s){const n=ve(1,256),i=n.createLinearGradient(0,0,1,256),r=1/(s.length-1);for(let o=0,a=s.length;o=t?s[e-t]:s[e]}function Pi(s,e){const t=s.length;let n=Math.floor(e);const i=e-n;n>=t?n-=t:n<0&&(n+=t);let r=n+1;r>=t&&(r-=t);const o=s[n],a=o[0],l=o[1],h=s[r],c=h[0]-a,u=h[1]-l;return[a+c*i,l+u*i]}const hr={index:-1,endIndex:NaN,closestTargetDistance:1/0};function xd(s,e,t,n){const i=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=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const u=Pi(h.coordinates,l),d=t.getPixelFromCoordinate(u),f=t.getPixelFromCoordinate(e.startCoord);Si(d,f)>n&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(fo){const l=Pi(s,n),h=Pi(s,i);return ur(l,h)}let a=0;if(n{const l=o||new fo([NaN,NaN]),h=me(r[0]),c=Ni(h,me(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;i==="Point"?r=ot:i==="LineString"?r=at:i==="Polygon"&&(r=Qe),n=(o,a,l)=>(a?i==="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_=n,this.dragVertexDelay_=e.dragVertexDelay!==void 0?e.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=e.clickTolerance?e.clickTolerance*e.clickTolerance:36,this.overlay_=new zl({source:new ed({useSpatialIndex:!1,wrapX:e.wrapX?e.wrapX:!1}),style:e.style?e.style:ux(),updateWhileInteracting:!0}),this.geometryName_=e.geometryName,this.condition_=e.condition?e.condition:Sl,this.freehandCondition_,e.freehand?this.freehandCondition_=Li:this.freehandCondition_=e.freehandCondition?e.freehandCondition:Mr,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSource_=e.traceSource||e.source||null,this.addChangeListener(Ia.ACTIVE,this.updateState_)}setTrace(e){let t;e?e===!0?t=Li:t=e:t=br,this.traceCondition_=t}setMap(e){super.setMap(e),this.updateState_()}setFreehand(e){this.freehand_=e,this.freehand_?this.freehandCondition_=Li:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Mr}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(e){e.originalEvent.type===V.CONTEXTMENU&&e.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(e);let t=e.type===ee.POINTERMOVE,n=!0;return!this.freehand_&&this.lastDragTime_&&e.type===ee.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=e.pixel,this.shouldHandle_=!this.freehand_,t=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&e.type===ee.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(e.coordinate),n=!1):this.freehand_&&e.type===ee.POINTERDOWN?n=!1:t&&this.getPointerCount()<2?(n=e.type===ee.POINTERMOVE,n&&this.freehand_?(this.handlePointerMove_(e),this.shouldHandle_&&e.originalEvent.preventDefault()):(e.originalEvent.pointerType==="mouse"||e.type===ee.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(e)):e.type===ee.DBLCLICK&&(n=!1),super.handleEvent(e)&&n}handleDownEvent(e){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=e.pixel,this.finishCoordinate_||this.startDrawing_(e.coordinate),!0):this.condition_(e)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new Vt(ee.POINTERMOVE,e.map,e.originalEvent,!1,e.frameState))},this.dragVertexDelay_),this.downPx_=e.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_();return}const t=this.getMap(),n=t.getCoordinateFromPixel([e.pixel[0]-this.snapTolerance_,e.pixel[1]+this.snapTolerance_]),i=t.getCoordinateFromPixel([e.pixel[0]+this.snapTolerance_,e.pixel[1]-this.snapTolerance_]),r=Be([n,i]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=Ed(e.coordinate,o);a.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){const n=e.startIndex<=e.endIndex,i=e.startIndex<=t;n===i?n&&t>e.endIndex||!n&&te.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let n=0;if(e0&&this.removeLastPoints_(n)}addTracedCoordinates_(e,t,n){if(t===n)return;const i=[];if(t=o;--a)i.push(Cn(e.coordinates,a))}i.length&&this.appendCoordinates(i)}updateTrace_(e){const t=this.traceState_;if(!t.active)return;if(t.targetIndex===-1){const a=e.map.getPixelFromCoordinate(t.startCoord);if(Si(a,e.pixel)this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(e.coordinate.slice());return}this.updateTrace_(e),this.modifyDrawing_(e.coordinate)}atFinish_(e,t){let n=!1;if(this.sketchFeature_){let i=!1,r=[this.finishCoordinate_];const o=this.mode_;if(o==="Point")n=!0;else if(o==="Circle")n=this.sketchCoords_.length===2;else if(o==="LineString")i=!t&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){const a=this.sketchCoords_;i=a[0].length>this.minPoints_,r=[a[0][0],a[0][a[0].length-2]],t?r=[a[0][0]]:r=[a[0][0],a[0][a[0].length-2]]}if(i){const a=this.getMap();for(let l=0,h=r.length;l=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(e.slice()),this.geometryFunction_(r,t,n)):o==="Polygon"&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(e.slice()),i&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,t,n)),this.createOrUpdateSketchPoint_(e.slice()),this.updateSketchFeatures_(),i?this.finishDrawing():this.sketchFeature_}removeLastPoints_(e){if(!this.sketchFeature_)return;const t=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection(),i=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,t,n),t.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(t)}else if(i==="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_,t,n)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const e=this.abortDrawing_();if(!e)return null;let t=this.sketchCoords_;const n=e.getGeometry(),i=this.getMap().getView().getProjection();return this.mode_==="LineString"?(t.pop(),this.geometryFunction_(t,n,i)):this.mode_==="Polygon"&&(t[0].pop(),this.geometryFunction_(t,n,i),t=n.getCoordinates()),this.type_==="MultiPoint"?e.setGeometry(new ri([t])):this.type_==="MultiLineString"?e.setGeometry(new rn([t])):this.type_==="MultiPolygon"&&e.setGeometry(new In([t])),this.dispatchEvent(new gr(fr.DRAWEND,e)),this.features_&&this.features_.push(e),this.source_&&this.source_.addFeature(e),e}abortDrawing_(){this.finishCoordinate_=null;const e=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),e}abortDrawing(){const e=this.abortDrawing_();e&&this.dispatchEvent(new gr(fr.DRAWABORT,e))}appendCoordinates(e){const t=this.mode_,n=!this.sketchFeature_;n&&this.startDrawing_(e[0]);let i;if(t==="LineString"||t==="Circle")i=this.sketchCoords_;else if(t==="Polygon")i=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;n&&i.shift(),i.pop();for(let o=0;o=0;--i){const r=t[i];if(r!==this&&r instanceof Rd&&r.getStyle()&&r.getFeatures().getArray().lastIndexOf(e)!==-1){e.setStyle(r.getStyle());return}}const n=D(e);e.setStyle(pr[n]),delete pr[n]}removeFeatureLayerAssociation_(e){delete this.featureLayerAssociation_[D(e)]}selectFeatureInternal_(e,t,n){if(!(e instanceof ze)||!this.filter_(e,t))return;const i=this.getFeatures();return i.getArray().includes(e)||(this.addFeatureLayerAssociation_(e,t),i.push(e),n?.push(e)),e}selectFeature(e){const t=this.findLayerOfFeature_(e);if(!this.layerFilter_(t))return!1;const n=this.selectFeatureInternal_(e,t);return n&&this.dispatchEvent(new mr(_r.SELECT,[n],[],void 0)),!!n}removeFeatureInternal_(e,t){const n=this.getFeatures();if(!(!(e instanceof ze)||!n.getArray().includes(e)))return n.remove(e),this.removeFeatureLayerAssociation_(e),t?.push(e),e}deselectFeature(e){const t=this.removeFeatureInternal_(e);return t&&this.dispatchEvent(new mr(_r.SELECT,[],[t],void 0)),!!t}toggleFeature(e){this.deselectFeature(e)||this.selectFeature(e)}clearSelection(){Qn(this.featureLayerAssociation_);const e=this.getFeatures(),t=e.getArray().slice();e.clear(),t.length!==0&&this.dispatchEvent(new mr(_r.SELECT,[],t,void 0))}handleEvent(e){if(!this.condition_(e))return!0;const t=this.addCondition_(e),n=this.removeCondition_(e),i=this.toggleCondition_(e),r=!t&&!n&&!i,o=e.map,a=this.getFeatures(),l=[],h=[];if(r){let c=!1;o.forEachFeatureAtPixel(e.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(e.pixel,(c,u)=>{let d;if((n||i)&&(d=this.removeFeatureInternal_(c,l)),(t||i)&&!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 mr(_r.SELECT,h,l,e)),!0}}function fx(){const s=Dl();return se(s.Polygon,s.LineString),se(s.GeometryCollection,s.LineString),function(e){return e.getGeometry()?s[e.getGeometry().getType()]:null}}const Tc=0,ms=1,Cc=[0,0,0,0],bi=[],aa={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"};function la(s,e,t){let n;switch(e){case"LineString":n=s;break;case"MultiLineString":case"Polygon":n=s[t[0]];break;case"MultiPolygon":n=s[t[1]][t[0]];break}return n}class ha extends Tt{constructor(e,t,n){super(e),this.features=t,this.mapBrowserEvent=n}}class U0 extends ii{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:Eu,this.defaultDeleteCondition_=function(n){return n_(n)&&yu(n)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:Li,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Ga,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new zl({source:new ed({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:_x(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.traceSource_=e.traceSource||e.source||null,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSegments_=null,this.hitDetection_=null;let t;if(e.features?t=e.features:e.source&&(this.source_=e.source,t=new Ve(this.source_.getFeatures()),this.source_.addEventListener(Le.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Le.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!t)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=t,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Re.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Re.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}setTrace(e){let t;e?e===!0?t=Li:t=e:t=br,this.traceCondition_=t}addFeature_(e){const t=e.getGeometry();if(t){const i=this.SEGMENT_WRITERS_[t.getType()];i&&i(e,t)}const n=this.getMap();n&&n.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastCoordinate_),e.addEventListener(V.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Ve;const n=this.featuresBeingModified_.getArray();for(let i=0,r=t.length;i=0;--i){const r=n[i];for(let o=this.dragSegments_.length-1;o>=0;--o)this.dragSegments_[o][0]===r&&this.dragSegments_.splice(o,1);t.remove(r)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){const t=e.target;this.removeFeature_(t),this.addFeature_(t)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,t){const n=t.getCoordinates(),i={feature:e,geometry:t,segment:[n,n]};this.rBush_.insert(t.getExtent(),i)}writeMultiPointGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length;ithis.pixelTolerance_)return;if(t.targetIndex!==n.index){if(t.targetIndex!==-1){const o=t.targets[t.targetIndex];this.removeTracedCoordinates_(o.startIndex,o.endIndex)}else for(const o of this.traceSegments_){const a=o[0],l=a.geometry,h=o[1],c=l.getCoordinates();la(c,l.getType(),a.depth).splice(a.index+h,1),l.setCoordinates(c),h===0&&(a.index-=1)}const r=t.targets[n.index];this.addTracedCoordinates_(r,r.startIndex,n.endIndex)}else{const r=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(r,n.endIndex)}t.targetIndex=n.index;const i=t.targets[t.targetIndex];i.endIndex=n.endIndex}getTraceCandidates_(e){const t=this.getMap(),n=this.pixelTolerance_,i=t.getCoordinateFromPixel([e.pixel[0]-n,e.pixel[1]+n]),r=t.getCoordinateFromPixel([e.pixel[0]+n,e.pixel[1]-n]),o=Be([i,r]);return this.traceSource_.getFeaturesInExtent(o)}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_(),this.traceSegments_=null;return}const t=this.getTraceCandidates_(e);if(t.length===0)return;const n=Ed(e.coordinate,t);n.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:n,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){const n=e.startIndex<=e.endIndex,i=e.startIndex<=t;n===i?n&&t>e.endIndex||!n&&te.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let n=0;if(e0)for(const i of this.traceSegments_){const r=i[0],o=r.geometry,a=i[1];let l=i[0].index+1;a===1&&(l-=n);const h=o.getCoordinates();la(h,o.getType(),r.depth).splice(l,n),o.setCoordinates(h),a===1&&(r.index-=n)}}addTracedCoordinates_(e,t,n){if(t===n)return;const i=[];if(t=o;--a)i.push(Cn(e.coordinates,a))}if(i.length)for(const r of this.traceSegments_){const o=r[0],a=o.geometry,l=r[1],h=o.index+1;l===0&&i.reverse();const c=a.getCoordinates();la(c,a.getType(),o.depth).splice(h,0,...i),a.setCoordinates(c),l===1&&(o.index+=i.length)}}updateGeometry_(e,t){const n=t[0],i=n.depth;let r;const o=n.segment,a=n.geometry,l=t[1];for(;e.lengtho));const t=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],n=[],i=[],r=this.traceState_.active&&!this.traceSegments_?this.traceState_.startCoord:null;if(r){this.traceSegments_=[];for(const o of this.dragSegments_){const a=o[0];Si(Ja(r,a.segment),r)/e.map.getView().getResolution()<1&&this.traceSegments_.push(o)}}for(let o=0,a=this.dragSegments_.length;o=0;--r)this.insertVertex_(n[r],i);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(e){for(let t=this.dragSegments_.length-1;t>=0;--t){const n=this.dragSegments_[t][0],i=n.geometry;if(i.getType()==="Circle"){const r=i,o=r.getCenter(),a=n.featureSegments[0],l=n.featureSegments[1];a.segment[0]=o,a.segment[1]=o,l.segment[0]=o,l.segment[1]=o,this.rBush_.update(ds(o),a);let h=r;this.rBush_.update(h.getExtent(),l)}else this.rBush_.update(Be(n.segment),n)}return this.featuresBeingModified_&&(this.toggleTraceState_(e),this.dispatchEvent(new ha(aa.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastCoordinate_=e.coordinate,this.handlePointerAtPixel_(this.lastCoordinate_)}handlePointerAtPixel_(e){const t=this.getMap(),n=t.getPixelFromCoordinate(e);t.getView().getProjection();const i=function(a,l){return Rc(e,a)-Rc(e,l)};let r,o;if(this.hitDetection_){const a=typeof this.hitDetection_=="object"?l=>l===this.hitDetection_:void 0;t.forEachFeatureAtPixel(n,(l,h,c)=>{c&&c.getType()==="Point"&&(c=new ot(qn(c.getCoordinates())));const u=c||l.getGeometry();if(u&&u.getType()==="Point"&&l instanceof ze&&this.features_.getArray().includes(l)){o=u;const d=l.getGeometry().getFlatCoordinates().slice(0,2);r=[{feature:l,geometry:o,segment:[d,d]}]}return!0},{layerFilter:a})}if(!r){const a=St(ds(e,Cc)),l=t.getView().getResolution()*this.pixelTolerance_,h=to(sn(a,l,Cc));r=this.rBush_.getInExtent(h)}if(r&&r.length>0){const a=r.sort(i)[0],l=a.segment;let h=Sc(e,a);const c=t.getPixelFromCoordinate(h);let u=Si(n,c);if(o||u<=this.pixelTolerance_){const d={};if(d[D(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-e[0],this.delta_[1]=h[1]-e[1]),a.geometry.getType()==="Circle"&&a.index===ms)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const f=t.getPixelFromCoordinate(l[0]),g=t.getPixelFromCoordinate(l[1]),m=Ni(c,f),_=Ni(c,g);if(u=Math.sqrt(Math.min(m,_)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_)){this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null);return}this.snappedToVertex_&&(h=m>_?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const p={};p[D(a.geometry)]=!0;for(let y=1,E=r.length;yn.getType()==="Circle"||n.getType().endsWith("Point")))return!1;const e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Be([e])).some(({segment:n})=>je(n[0],e)||je(n[1],e))}removePoint(e){if(e&&(e=me(e,this.getMap().getView().getProjection()),this.updatePointer_(e)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=ee.POINTERDRAG){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([i])=>i));const n=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new ha(aa.MODIFYEND,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,n}return!1}removeVertex_(){const e=this.dragSegments_,t={};let n=!1,i,r,o,a,l,h,c,u,d,f,g;for(l=e.length-1;l>=0;--l)o=e[l],f=o[0],g=D(f.feature),f.depth&&(g+="-"+f.depth.join("-")),g in t||(t[g]={}),o[1]===0?(t[g].right=f,t[g].index=f.index):o[1]==1&&(t[g].left=f,t[g].index=f.index+1);for(g in t){switch(d=t[g].right,c=t[g].left,h=t[g].index,u=h-1,c!==void 0?f=c:f=d,u<0&&(u=0),a=f.geometry,r=a.getCoordinates(),i=r,n=!1,a.getType()){case"MultiLineString":r[f.depth[0]].length>2&&(r[f.depth[0]].splice(h,1),n=!0);break;case"LineString":r.length>2&&(r.splice(h,1),n=!0);break;case"MultiPolygon":i=i[f.depth[1]];case"Polygon":i=i[f.depth[0]],i.length>4&&(h==i.length-1&&(h=0),i.splice(h,1),n=!0,h===0&&(i.pop(),i.push(i[0]),u=i.length-1));break}if(n){this.setGeometryCoordinates_(a,r);const m=[];if(c!==void 0&&(this.rBush_.remove(c),m.push(c.segment[0])),d!==void 0&&(this.rBush_.remove(d),m.push(d.segment[1])),c!==void 0&&d!==void 0){const _={depth:f.depth,feature:f.feature,geometry:f.geometry,index:u,segment:m};this.rBush_.insert(Be(_.segment),_)}this.updateSegmentIndices_(a,h,f.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return n}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(n=>n.getType()==="Circle"||n.getType().endsWith("Point")))return!1;const e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Be([e])).some(({segment:n})=>!(je(n[0],e)||je(n[1],e)))}insertPoint(e){const t=e?me(e,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return t?this.findInsertVerticesAndUpdateDragSegments_(t).reduce((i,r)=>i||this.insertVertex_(r,t),!1):!1}setGeometryCoordinates_(e,t){this.changingFeature_=!0,e.setCoordinates(t),this.changingFeature_=!1}updateSegmentIndices_(e,t,n,i){this.rBush_.forEachInExtent(e.getExtent(),function(r){r.geometry===e&&(n===void 0||r.depth===void 0||Ut(r.depth,n))&&r.index>t&&(r.index+=i)})}}function gx(s,e){return s.index-e.index}function Rc(s,e,t){const n=e.geometry;if(n.getType()==="Circle"){let r=n;if(e.index===ms){const o=Ni(r.getCenter(),me(s)),a=Math.sqrt(o)-r.getRadius();return a*a}}const i=me(s);return bi[0]=me(e.segment[0]),bi[1]=me(e.segment[1]),Mf(i,bi)}function Sc(s,e,t){const n=e.geometry;if(n.getType()==="Circle"&&e.index===ms)return qn(n.getClosestPoint(me(s)));const i=me(s);return bi[0]=me(e.segment[0]),bi[1]=me(e.segment[1]),qn(Ja(i,bi))}function _x(){const s=Dl();return function(e,t){return s.Point}}class mx extends Wl{constructor(){super()}getType(){return"text"}readFeature(e,t){return this.readFeatureFromText(yr(e),this.adaptOptions(t))}readFeatureFromText(e,t){return $()}readFeatures(e,t){return this.readFeaturesFromText(yr(e),this.adaptOptions(t))}readFeaturesFromText(e,t){return $()}readGeometry(e,t){return this.readGeometryFromText(yr(e),this.adaptOptions(t))}readGeometryFromText(e,t){return $()}readProjection(e){return this.readProjectionFromText(yr(e))}readProjectionFromText(e){return this.dataProjection}writeFeature(e,t){return this.writeFeatureText(e,this.adaptOptions(t))}writeFeatureText(e,t){return $()}writeFeatures(e,t){return this.writeFeaturesText(e,this.adaptOptions(t))}writeFeaturesText(e,t){return $()}writeGeometry(e,t){return this.writeGeometryText(e,this.adaptOptions(t))}writeGeometryText(e,t){return $()}}function yr(s){return typeof s=="string"?s:""}const px={POINT:ot,LINESTRING:at,POLYGON:Qe,MULTIPOINT:ri,MULTILINESTRING:rn,MULTIPOLYGON:In},Sd="EMPTY",vd="Z",wd="M",yx="ZM",oe={START:0,TEXT:1,LEFT_PAREN:2,RIGHT_PAREN:3,NUMBER:4,COMMA:5,EOF:6},xx={Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION",Circle:"CIRCLE"};class Ex{constructor(e){this.wkt=e,this.index_=-1}isAlpha_(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isNumeric_(e,t){return t=t!==void 0?t:!1,e>="0"&&e<="9"||e=="."&&!t}isWhiteSpace_(e){return e==" "||e==" "||e=="\r"||e==` `}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const e=this.nextChar_(),t=this.index_;let n=e,i;if(e=="(")i=oe.LEFT_PAREN;else if(e==",")i=oe.COMMA;else if(e==")")i=oe.RIGHT_PAREN;else if(this.isNumeric_(e)||e=="-")i=oe.NUMBER,n=this.readNumber_();else if(this.isAlpha_(e))i=oe.TEXT,n=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(e==="")i=oe.EOF;else throw new Error("Unexpected character: "+e)}return{position:t,value:n,type:i}}readNumber_(){let e;const t=this.index_;let n=!1,i=!1;do e=="."?n=!0:(e=="e"||e=="E")&&(i=!0),e=this.nextChar_();while(this.isNumeric_(e,n)||!i&&(e=="e"||e=="E")||i&&(e=="-"||e=="+"));return parseFloat(this.wkt.substring(t,this.index_--))}readText_(){let e;const t=this.index_;do e=this.nextChar_();while(this.isAlpha_(e));return this.wkt.substring(t,this.index_--).toUpperCase()}}class Tx{constructor(e){this.lexer_=e,this.token_={position:0,type:oe.START},this.layout_="XY"}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(e){return this.token_.type==e}match(e){const t=this.isTokenType(e);return t&&this.consume_(),t}parse(){return this.consume_(),this.parseGeometry_()}parseGeometryLayout_(){let e="XY";const t=this.token_;if(this.isTokenType(oe.TEXT)){const n=t.value;n===vd?e="XYZ":n===wd?e="XYM":n===yx&&(e="XYZM"),e!=="XY"&&this.consume_()}return e}parseGeometryCollectionText_(){if(this.match(oe.LEFT_PAREN)){const e=[];do e.push(this.parseGeometry_());while(this.match(oe.COMMA));if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parsePoint_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parsePointList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(oe.LEFT_PAREN)){let e;if(this.token_.type==oe.LEFT_PAREN?e=this.parsePointTextList_():e=this.parsePointList_(),this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parsePolygonTextList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePoint_(){const e=[],t=this.layout_.length;for(let n=0;n0&&(i+=" "+r)}return n.length===0?i+" "+Sd:i+"("+n+")"}const vc="http://www.w3.org/2001/XMLSchema-instance";function Ws(s,e){return _o().createElementNS(s,e)}function an(s,e){return Ad(s,e,[]).join("")}function Ad(s,e,t){if(s.nodeType==Node.CDATA_SECTION_NODE||s.nodeType==Node.TEXT_NODE)t.push(s.nodeValue);else{let n;for(n=s.firstChild;n;n=n.nextSibling)Ad(n,e,t)}return t}function Rn(s){return"documentElement"in s}function Sn(s){return new DOMParser().parseFromString(s,"application/xml")}function wc(s,e){return(function(t,n){const i=s.call(e??this,t,n);if(i!==void 0){const r=n[n.length-1];se(r,i)}})}function mn(s,e){return(function(t,n){const i=s.call(e??this,t,n);i!==void 0&&n[n.length-1].push(i)})}function sh(s,e){return(function(t,n){const i=s.call(this,t,n);i!==void 0&&(n[n.length-1]=i)})}function O(s,e,t){return(function(n,i){const r=s.call(this,n,i);if(r!==void 0){const o=i[i.length-1],a=e!==void 0?e:n.localName;o[a]=r}})}function W(s,e){return(function(t,n,i){s.call(this,t,n,i),i[i.length-1].node.appendChild(t)})}function ln(s,e){return(function(t,n,i){const o=n[n.length-1].node;let a=s;a===void 0&&(a=i);const l=o.namespaceURI;return Ws(l,a)})}const xt=ln();function Pt(s,e){const t=e.length,n=new Array(t);for(let i=0;i0?n[0]:null}readFeatureFromNode(e,t){return null}readFeatures(e,t){if(!e)return[];if(typeof e=="string"){const n=Sn(e);return this.readFeaturesFromDocument(n,t)}return Rn(e)?this.readFeaturesFromDocument(e,t):this.readFeaturesFromNode(e,t)}readFeaturesFromDocument(e,t){const n=[];for(let i=e.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&se(n,this.readFeaturesFromNode(i,t));return n}readFeaturesFromNode(e,t){return $()}readGeometry(e,t){if(!e)return null;if(typeof e=="string"){const n=Sn(e);return this.readGeometryFromDocument(n,t)}return Rn(e)?this.readGeometryFromDocument(e,t):this.readGeometryFromNode(e,t)}readGeometryFromDocument(e,t){return null}readGeometryFromNode(e,t){return null}readProjection(e){if(!e)return null;if(typeof e=="string"){const t=Sn(e);return this.readProjectionFromDocument(t)}return Rn(e)?this.readProjectionFromDocument(e):this.readProjectionFromNode(e)}readProjectionFromDocument(e){return this.dataProjection}readProjectionFromNode(e){return this.dataProjection}writeFeature(e,t){const n=this.writeFeatureNode(e,t);return this.xmlSerializer_.serializeToString(n)}writeFeatureNode(e,t){return null}writeFeatures(e,t){const n=this.writeFeaturesNode(e,t);return this.xmlSerializer_.serializeToString(n)}writeFeaturesNode(e,t){return null}writeGeometry(e,t){const n=this.writeGeometryNode(e,t);return this.xmlSerializer_.serializeToString(n)}writeGeometryNode(e,t){return null}}function Ln(s){const e=an(s,!1);return Fx(e)}function Fx(s){const e=/^\s*(true|1)|(false|0)\s*$/.exec(s);if(e)return e[1]!==void 0||!1}function pe(s){const e=an(s,!1);return bx(e)}function bx(s){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(s);if(e)return parseFloat(e[1])}function Xe(s){return an(s,!1).trim()}function zi(s,e){gt(s,e?"1":"0")}function Mx(s,e){s.appendChild(_o().createCDATASection(e))}function Xn(s,e){const t=e.toPrecision();s.appendChild(_o().createTextNode(t))}const Dx=/^\s/,Ox=/\s$/,Nx=/(\n|\t|\r|<|&| {2})/;function gt(s,e){typeof e=="string"&&(Dx.test(e)||Ox.test(e)||Nx.test(e))?e.split("]]>").forEach((t,n,i)=>{n0&&(t=">"+t),Mx(s,t)}):s.appendChild(_o().createTextNode(e))}const hn=["http://www.google.com/kml/ext/2.2"],k=[null,"http://earth.google.com/kml/2.0","http://earth.google.com/kml/2.1","http://earth.google.com/kml/2.2","http://www.opengis.net/kml/2.2"],Gx="http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd",Pc={fraction:"fraction",pixels:"pixels",insetPixels:"pixels"},kx=z(k,{ExtendedData:Yd,Region:jd,MultiGeometry:O($d,"geometry"),LineString:O(Bd,"geometry"),LinearRing:O(zd,"geometry"),Point:O(Xd,"geometry"),Polygon:O(Wd,"geometry"),Style:O(ah),StyleMap:EE,address:O(Xe),description:O(Xe),name:O(Xe),open:O(Ln),phoneNumber:O(Xe),styleUrl:O(Od),visibility:O(Ln)},z(hn,{MultiTrack:O(aE,"geometry"),Track:O(Ud,"geometry")})),Ux=z(k,{ExtendedData:Yd,Region:jd,Link:bE,address:O(Xe),description:O(Xe),name:O(Xe),open:O(Ln),phoneNumber:O(Xe),visibility:O(Ln)}),Bx=z(k,{href:O(Dd)}),zx=z(k,{Altitude:O(pe),Longitude:O(pe),Latitude:O(pe),Tilt:O(pe),AltitudeMode:O(Xe),Heading:O(pe),Roll:O(pe)}),Fd=z(k,{LatLonAltBox:vE,Lod:PE}),$x=z(k,["Document","Placemark"]),Xx=z(k,{Document:W(BE),Placemark:W(Kd)});let Mi,Cr=null,Xa,ps,ys,xs,Vr,Wa=null,rh,Ya=null,ja,Wn=null,Ic=null,Va=null;function Zr(s){return 32/Math.min(s[0],s[1])}function Wx(){Mi=[255,255,255,1],Cr=new wt({color:Mi}),Xa=[20,2],ps="pixels",ys="pixels",xs=[64,64],Vr="https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png",Wa=new Zi({anchor:Xa,anchorOrigin:"bottom-left",anchorXUnits:ps,anchorYUnits:ys,crossOrigin:"anonymous",rotation:0,scale:Zr(xs),size:xs,src:Vr}),rh="NO_IMAGE",Ya=new Gt({color:Mi,width:1}),ja=new Gt({color:[51,51,51,1],width:2}),Wn=new zs({font:"bold 16px Helvetica",fill:Cr,stroke:ja,scale:.8}),Ic=new Oe({fill:Cr,image:Wa,text:Wn,stroke:Ya,zIndex:0}),Va=[Ic]}let xr;function Yx(s){return s}class z0 extends Ax{constructor(e){super(),e=e||{},Va||Wx(),this.dataProjection=_e("EPSG:4326"),this.defaultStyle_=e.defaultStyle?e.defaultStyle:Va,this.extractStyles_=e.extractStyles!==void 0?e.extractStyles:!0,this.writeStyles_=e.writeStyles!==void 0?e.writeStyles:!0,this.sharedStyles_={},this.showPointNames_=e.showPointNames!==void 0?e.showPointNames:!0,this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",this.iconUrlFunction_=e.iconUrlFunction?e.iconUrlFunction:Yx,this.supportedMediaTypes=["application/vnd.google-earth.kml+xml"]}readDocumentOrFolder_(e,t){const n=z(k,{Document:wc(this.readDocumentOrFolder_,this),Folder:wc(this.readDocumentOrFolder_,this),Placemark:mn(this.readPlacemark_,this),Style:this.readSharedStyle_.bind(this),StyleMap:this.readSharedStyleMap_.bind(this)}),i=ce([],n,e,t,this);if(i)return i}readPlacemark_(e,t){const n=ce({geometry:null},kx,e,t,this);if(!n)return;const i=new ze,r=e.getAttribute("id");r!==null&&i.setId(r);const o=t[0],a=n.geometry;if(a&&Jn(a,!1,o),i.setGeometry(a),delete n.geometry,this.extractStyles_){const l=n.Style,h=n.styleUrl,c=Vx(l,h,this.defaultStyle_,this.sharedStyles_,this.showPointNames_);i.setStyle(c)}return delete n.Style,i.setProperties(n,!0),i}readSharedStyle_(e,t){const n=e.getAttribute("id");if(n!==null){const i=ah.call(this,e,t);if(i){let r,o=e.baseURI;(!o||o=="about:blank")&&(o=window.location.href),o?r=new URL("#"+n,o).href:r="#"+n,this.sharedStyles_[r]=i}}}readSharedStyleMap_(e,t){const n=e.getAttribute("id");if(n===null)return;const i=Gd.call(this,e,t);if(!i)return;let r,o=e.baseURI;(!o||o=="about:blank")&&(o=window.location.href),o?r=new URL("#"+n,o).href:r="#"+n,this.sharedStyles_[r]=i}readFeatureFromNode(e,t){if(!k.includes(e.namespaceURI))return null;const n=this.readPlacemark_(e,[this.getReadOptions(e,t)]);return n||null}readFeaturesFromNode(e,t){if(!k.includes(e.namespaceURI))return[];let n;const i=e.localName;if(i=="Document"||i=="Folder")return n=this.readDocumentOrFolder_(e,[this.getReadOptions(e,t)]),n||[];if(i=="Placemark"){const r=this.readPlacemark_(e,[this.getReadOptions(e,t)]);return r?[r]:[]}if(i=="kml"){n=[];for(let r=e.firstElementChild;r;r=r.nextElementSibling){const o=this.readFeaturesFromNode(r,t);o&&se(n,o)}return n}return[]}readName(e){if(e){if(typeof e=="string"){const t=Sn(e);return this.readNameFromDocument(t)}return Rn(e)?this.readNameFromDocument(e):this.readNameFromNode(e)}}readNameFromDocument(e){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType==Node.ELEMENT_NODE){const n=this.readNameFromNode(t);if(n)return n}}readNameFromNode(e){for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(k.includes(t.namespaceURI)&&t.localName=="name")return Xe(t);for(let t=e.firstElementChild;t;t=t.nextElementSibling){const n=t.localName;if(k.includes(t.namespaceURI)&&(n=="Document"||n=="Folder"||n=="Placemark"||n=="kml")){const i=this.readNameFromNode(t);if(i)return i}}}readNetworkLinks(e){const t=[];if(typeof e=="string"){const n=Sn(e);se(t,this.readNetworkLinksFromDocument(n))}else Rn(e)?se(t,this.readNetworkLinksFromDocument(e)):se(t,this.readNetworkLinksFromNode(e));return t}readNetworkLinksFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&se(t,this.readNetworkLinksFromNode(n));return t}readNetworkLinksFromNode(e){const t=[];for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(k.includes(n.namespaceURI)&&n.localName=="NetworkLink"){const i=ce({},Ux,n,[]);t.push(i)}for(let n=e.firstElementChild;n;n=n.nextElementSibling){const i=n.localName;k.includes(n.namespaceURI)&&(i=="Document"||i=="Folder"||i=="kml")&&se(t,this.readNetworkLinksFromNode(n))}return t}readRegion(e){const t=[];if(typeof e=="string"){const n=Sn(e);se(t,this.readRegionFromDocument(n))}else Rn(e)?se(t,this.readRegionFromDocument(e)):se(t,this.readRegionFromNode(e));return t}readRegionFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&se(t,this.readRegionFromNode(n));return t}readRegionFromNode(e){const t=[];for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(k.includes(n.namespaceURI)&&n.localName=="Region"){const i=ce({},Fd,n,[]);t.push(i)}for(let n=e.firstElementChild;n;n=n.nextElementSibling){const i=n.localName;k.includes(n.namespaceURI)&&(i=="Document"||i=="Folder"||i=="kml")&&se(t,this.readRegionFromNode(n))}return t}readCamera(e){const t=[];if(typeof e=="string"){const n=Sn(e);se(t,this.readCameraFromDocument(n))}else Rn(e)?se(t,this.readCameraFromDocument(e)):se(t,this.readCameraFromNode(e));return t}readCameraFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType===Node.ELEMENT_NODE&&se(t,this.readCameraFromNode(n));return t}readCameraFromNode(e){const t=[];for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(k.includes(n.namespaceURI)&&n.localName==="Camera"){const i=ce({},zx,n,[]);t.push(i)}for(let n=e.firstElementChild;n;n=n.nextElementSibling){const i=n.localName;k.includes(n.namespaceURI)&&(i==="Document"||i==="Folder"||i==="Placemark"||i==="kml")&&se(t,this.readCameraFromNode(n))}return t}writeFeaturesNode(e,t){t=this.adaptOptions(t);const n=Ws(k[4],"kml"),i="http://www.w3.org/2000/xmlns/";n.setAttributeNS(i,"xmlns:gx",hn[0]),n.setAttributeNS(i,"xmlns:xsi",vc),n.setAttributeNS(vc,"xsi:schemaLocation",Gx);const r={node:n},o={};e.length>1?o.Document=e:e.length==1&&(o.Placemark=e[0]);const a=$x[n.namespaceURI],l=Pt(o,a);return Ce(r,Xx,xt,l,[t],a,this),n}}function jx(s,e){const t=[0,0];let n="start";const i=s.getImage();if(i){const a=i.getSize();if(a&&a.length==2){const l=i.getScaleArray(),h=i.getAnchor();t[0]=l[0]*(a[0]-h[0]),t[1]=l[1]*(a[1]/2-h[1]),n="left"}}let r=s.getText();return r?(r=r.clone(),r.setFont(r.getFont()||Wn.getFont()),r.setScale(r.getScale()||Wn.getScale()),r.setFill(r.getFill()||Wn.getFill()),r.setStroke(r.getStroke()||ja)):r=Wn.clone(),r.setText(e),r.setOffsetX(t[0]),r.setOffsetY(t[1]),r.setTextAlign(n),new Oe({image:i,text:r})}function Vx(s,e,t,n,i){return(function(r,o){let a=i,l="",h=[];if(a){const u=r.getGeometry();if(u)if(u instanceof Ze)h=u.getGeometriesArrayRecursive().filter(function(d){const f=d.getType();return f==="Point"||f==="MultiPoint"}),a=h.length>0;else{const d=u.getType();a=d==="Point"||d==="MultiPoint"}}a&&(l=r.get("name"),a=a&&!!l,a&&/&[^&]+;/.test(l)&&(xr||(xr=document.createElement("textarea")),xr.innerHTML=l,l=xr.value));let c=t;if(s?c=s:e&&(c=bd(e,t,n)),a){const u=jx(c[0],l);if(h.length>0){u.setGeometry(new Ze(h));const d=new Oe({geometry:c[0].getGeometry(),image:null,fill:c[0].getFill(),stroke:c[0].getStroke(),text:null});return[u,d].concat(c.slice(1))}return u}return c})}function bd(s,e,t){return Array.isArray(s)?s:typeof s=="string"?bd(t[s],e,t):e}function mo(s){const e=an(s,!1),t=/^\s*#?\s*([0-9A-Fa-f]{8})\s*$/.exec(e);if(t){const n=t[1];return[parseInt(n.substr(6,2),16),parseInt(n.substr(4,2),16),parseInt(n.substr(2,2),16),parseInt(n.substr(0,2),16)/255]}}function Md(s){let e=an(s,!1);const t=[];e=e.replace(/\s*,\s*/g,",");const n=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?),([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|,|$)(?:([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|$))?\s*/i;let i;for(;i=n.exec(e);){const r=parseFloat(i[1]),o=parseFloat(i[2]),a=i[3]?parseFloat(i[3]):0;t.push(r,o,a),e=e.substr(i[0].length)}if(e==="")return t}function Dd(s){const e=an(s,!1).trim();let t=s.baseURI;return(!t||t=="about:blank")&&(t=window.location.href),t?new URL(e,t).href:e}function Od(s){const e=an(s,!1).trim().replace(/^(?!.*#)/,"#");let t=s.baseURI;return(!t||t=="about:blank")&&(t=window.location.href),t?new URL(e,t).href:e}function Zx(s){const e=s.getAttribute("xunits"),t=s.getAttribute("yunits");let n;return e!=="insetPixels"?t!=="insetPixels"?n="bottom-left":n="top-left":t!=="insetPixels"?n="bottom-right":n="top-right",{x:parseFloat(s.getAttribute("x")),xunits:Pc[e],y:parseFloat(s.getAttribute("y")),yunits:Pc[t],origin:n}}function Nd(s){return pe(s)}const Kx=z(k,{Pair:xE});function Gd(s,e){return ce(void 0,Kx,s,e,this)}const Hx=z(k,{Icon:O(cE),color:O(mo),heading:O(pe),hotSpot:O(Zx),scale:O(Nd)});function qx(s,e){const t=ce({},Hx,s,e);if(!t)return;const n=e[e.length-1],i="Icon"in t?t.Icon:{},r=!("Icon"in t)||Object.keys(i).length>0;let o;const a=i.href;a?o=a:r&&(o=Vr);let l,h,c,u="bottom-left";const d=t.hotSpot;d?(l=[d.x,d.y],h=d.xunits,c=d.yunits,u=d.origin):/^https?:\/\/maps\.(?:google|gstatic)\.com\//.test(o)&&(o.includes("pushpin")?(l=Xa,h=ps,c=ys):o.includes("arrow-reverse")?(l=[54,42],h=ps,c=ys):o.includes("paddle")&&(l=[32,1],h=ps,c=ys));let f;const g=i.x,m=i.y;g!==void 0&&m!==void 0&&(f=[g,m]);let _;const p=i.w,y=i.h;p!==void 0&&y!==void 0&&(_=[p,y]);let E;const x=t.heading;x!==void 0&&(E=pt(x));const T=t.scale,R=t.color;if(r){o==Vr&&(_=xs);const S=new Zi({anchor:l,anchorOrigin:u,anchorXUnits:h,anchorYUnits:c,crossOrigin:this.crossOrigin_,offset:f,offsetOrigin:"bottom-left",rotation:E,scale:T,size:_,src:this.iconUrlFunction_(o),color:R}),v=S.getScaleArray()[0],w=S.getSize();if(w===null){const I=S.getImageState();if(I===U.IDLE||I===U.LOADING){const F=function(){const L=S.getImageState();if(!(L===U.IDLE||L===U.LOADING)){const b=S.getSize();if(b&&b.length==2){const M=Zr(b);S.setScale(v*M)}S.unlistenImageChange(F)}};S.listenImageChange(F),I===U.IDLE&&S.load()}}else if(w.length==2){const I=Zr(w);S.setScale(v*I)}n.imageStyle=S}else n.imageStyle=rh}const Jx=z(k,{color:O(mo),scale:O(Nd)});function Qx(s,e){const t=ce({},Jx,s,e);if(!t)return;const n=e[e.length-1],i=new zs({fill:new wt({color:"color"in t?t.color:Mi}),scale:t.scale});n.textStyle=i}const eE=z(k,{color:O(mo),width:O(pe)});function tE(s,e){const t=ce({},eE,s,e);if(!t)return;const n=e[e.length-1],i=new Gt({color:"color"in t?t.color:Mi,width:"width"in t?t.width:1});n.strokeStyle=i}const nE=z(k,{color:O(mo),fill:O(Ln),outline:O(Ln)});function iE(s,e){const t=ce({},nE,s,e);if(!t)return;const n=e[e.length-1],i=new wt({color:"color"in t?t.color:Mi});n.fillStyle=i;const r=t.fill;r!==void 0&&(n.fill=r);const o=t.outline;o!==void 0&&(n.outline=o)}const sE=z(k,{coordinates:sh(Md)});function kd(s,e){return ce(null,sE,s,e)}function rE(s,e){const n=e[e.length-1].coordinates,i=an(s,!1),o=/^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*$/i.exec(i);if(o){const a=parseFloat(o[1]),l=parseFloat(o[2]),h=parseFloat(o[3]);n.push([a,l,h])}else n.push([])}const oE=z(hn,{Track:mn(Ud)});function aE(s,e){const t=ce([],oE,s,e);if(t)return new rn(t)}const lE=z(k,{when:ME},z(hn,{coord:rE}));function Ud(s,e){const t=ce({coordinates:[],whens:[]},lE,s,e);if(!t)return;const n=[],i=t.coordinates,r=t.whens;for(let o=0,a=Math.min(i.length,r.length);o0&&e[e.length-1].push(...t)}const AE=z(k,{LinearRing:sh(kd)});function FE(s,e){const t=ce(void 0,AE,s,e);if(t){const n=e[e.length-1];n[0]=t}}function bE(s,e){Hi(Bx,s,e)}function ME(s,e){const n=e[e.length-1].whens,i=an(s,!1),r=Date.parse(i);n.push(isNaN(r)?0:r)}function yo(s,e){const t=Et(e),i=[(t.length==4?t[3]:1)*255,t[2],t[1],t[0]];for(let r=0;r<4;++r){const o=Math.floor(i[r]).toString(16);i[r]=o.length==1?"0"+o:o}gt(s,i.join(""))}function DE(s,e,t){const n=t[t.length-1],i=n.layout,r=n.stride;let o;if(i=="XY"||i=="XYM")o=2;else if(i=="XYZ"||i=="XYZM")o=3;else throw new Error("Invalid geometry layout");const a=e.length;let l="";if(a>0){l+=e[0];for(let h=1;h0){const f=Pt(i,o);Ce(n,fa,l0,[{names:o,values:f}],t)}const u=t[0];let d=e.getGeometry();d&&(d=Jn(d,!0,u)),Ce(n,fa,Vd,[d],t)}const h0=z(k,["extrude","tessellate","altitudeMode","coordinates"]),c0=z(k,{extrude:W(zi),tessellate:W(zi),altitudeMode:W(gt),coordinates:W(DE)});function Di(s,e,t){const n=e.getFlatCoordinates(),i={node:s};i.layout=e.getLayout(),i.stride=e.getStride();const r=e.getProperties();r.coordinates=n;const o=t[t.length-1].node,a=h0[o.namespaceURI],l=Pt(r,a);Ce(i,c0,xt,l,t,a)}const u0=z(k,["color","fill","outline"]),bc=z(k,{outerBoundaryIs:W(Fc),innerBoundaryIs:W(Fc)}),d0=ln("innerBoundaryIs"),f0=ln("outerBoundaryIs");function Hd(s,e,t){const n=e.getLinearRings(),i=n.shift(),r={node:s};Ce(r,bc,d0,n,t),Ce(r,bc,f0,[i],t)}const g0=z(k,{color:W(yo),fill:W(zi),outline:W(zi)});function _0(s,e,t){const n={node:s},i=e.getFill(),r=e.getStroke(),o={color:i?i.getColor():void 0,fill:i?void 0:!1,outline:r?void 0:!1},a=t[t.length-1].node,l=u0[a.namespaceURI],h=Pt(o,l);Ce(n,g0,xt,h,t,l)}function qd(s,e){Xn(s,Math.round(e*1e6)/1e6)}const m0=z(k,["IconStyle","LabelStyle","LineStyle","PolyStyle"]),p0=z(k,{IconStyle:W(VE),LabelStyle:W(HE),LineStyle:W(QE),PolyStyle:W(_0)});function y0(s,e,t){const n={node:s},i={};if(e.pointStyles.length){const l=e.pointStyles[0].getText();l&&(i.LabelStyle=l);const h=e.pointStyles[0].getImage();h&&typeof h.getSrc=="function"&&(i.IconStyle=h)}if(e.lineStyles.length){const l=e.lineStyles[0].getStroke();l&&(i.LineStyle=l)}if(e.polyStyles.length){const l=e.polyStyles[0].getStroke();l&&!i.LineStyle&&(i.LineStyle=l),i.PolyStyle=e.polyStyles[0]}const r=t[t.length-1].node,o=m0[r.namespaceURI],a=Pt(i,o);Ce(n,p0,xt,a,t,o)}function x0(s,e){s.setAttribute("x",String(e.x)),s.setAttribute("y",String(e.y)),s.setAttribute("xunits",e.xunits),s.setAttribute("yunits",e.yunits)}var $0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function X0(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}export{kf as $,R0 as A,It as B,ao as C,k0 as D,Ss as E,wt as F,S0 as G,G0 as H,A0 as I,Mr as J,U0 as K,at as L,w0 as M,Zn as N,I0 as O,Qe as P,zs as Q,ho as R,Rd as S,L0 as T,Vi as U,zl as V,qt as W,T0 as X,O0 as Y,F0 as Z,E0 as _,N0 as a,Gf as a0,C0 as a1,Hp as a2,M0 as a3,D0 as a4,b0 as a5,z0 as a6,B0 as a7,$0 as a8,X0 as a9,ed as b,rn as c,In as d,fo as e,sn as f,D as g,Oe as h,Ee as i,Gt as j,Bs as k,ii as l,ji as m,ze as n,ot as o,Ve as p,Uc as q,bh as r,Pn as s,Ns as t,cf as u,Be as v,Je as w,Eu as x,n_ as y,Li as z}; //# sourceMappingURL=openlayers-D8ReJJOp.js.map