const rf="modulepreload",of=function(s){return"/"+s},ph={},w0=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=of(h),h in ph)return;ph[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":rf,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)})},Se={ADD:"add",REMOVE:"remove"},Ni={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 af(s,e,t){let n,i;t=t||Nt;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 Nt(s,e){return s>e?1:se?-1:0}function qa(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 Pn(){return!0}function Xi(){return!1}function Ts(){}function Dc(s){let e,t,n;return function(){const i=Array.prototype.slice.call(arguments);return(!t||this!==n||!Bt(i,t))&&(n=this,t=i,e=s.apply(this,arguments)),e}}function Oc(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 ei(s){for(const e in s)delete s[e]}function Vn(s){let e;for(e in s)return!1;return!e}class ut{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Ds 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 ut(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]=Ts,++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 wr(s,e,t,n){return J(s,e,t,n,!0)}function ue(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),ei(s))}class Os extends Ds{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 Hs(Se.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 Hs(Se.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 Hs(Se.REMOVE,i,e)),this.dispatchEvent(new Hs(Se.ADD,t,e))}updateLength_(){this.set(xh.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 Zt(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 Zt(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 Zt(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 Zt(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 Zt(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 Kt={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Be={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 Pr=1/0;class xf{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,ei(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!=Pr?(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 Tf(s,e,t,n,i){if(!s||!(t in s.wantedTiles)||!s.wantedTiles[t][e.getKey()])return Pr;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},vt={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function ge(s,e,t){return Math.min(Math.max(s,e),t)}function Cf(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 Qt(s,e,t,n)}function Qt(s,e,t,n){const i=t-s,r=n-e;return i*i+r*r}function Rf(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 Ir(s){return s*180/Math.PI}function Ke(s){return s*Math.PI/180}function en(s,e){const t=s%e;return t*e<0?t+e:t}function rt(s,e,t){return s+t*(e-s)}function Yi(s,e){const t=Math.pow(10,e);return Math.round(s*t)/t}function Eh(s,e){return Math.round(Yi(s,e))}function qs(s,e){return Math.floor(Yi(s,e))}function Js(s,e){return Math.ceil(Yi(s,e))}function ya(s,e,t){if(s>=e&&sf&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=ge(n[0],d,f),p=ge(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 Sf(s){return s}const Fe={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function ze(s){const e=tt();for(let t=0,n=s.length;ti&&(l=l|Fe.RIGHT),ar&&(l=l|Fe.ABOVE),l===Fe.UNKNOWN&&(l=Fe.INTERSECTING),l}function tt(){return[1/0,1/0,-1/0,-1/0]}function Ut(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 ji(s){return Ut(1/0,1/0,-1/0,-1/0,s)}function fs(s,e){const t=s[0],n=s[1];return Ut(t,n,t,n,e)}function Qa(s,e,t,n,i){const r=ji(i);return zc(r,s,e,t,n)}function Hn(s,e){return s[0]==e[0]&&s[2]==e[2]&&s[1]==e[1]&&s[3]==e[3]}function Bc(s,e){return e[0]s[2]&&(s[2]=e[2]),e[1]s[3]&&(s[3]=e[3]),s}function gs(s,e){e[0]s[2]&&(s[2]=e[0]),e[1]s[3]&&(s[3]=e[1])}function zc(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 ni(s){return s[2]=o&&m<=l),!n&&r&Fe.RIGHT&&!(i&Fe.RIGHT)&&(_=f-(d-l)*g,n=_>=a&&_<=h),!n&&r&Fe.BELOW&&!(i&Fe.BELOW)&&(m=d-(f-a)/g,n=m>=o&&m<=l),!n&&r&Fe.LEFT&&!(i&Fe.LEFT)&&(_=f-(d-o)*g,n=_>=a&&_<=h)}return n}function Ff(s,e,t,n){if(ni(s))return ji(t);let i=[];{const a=s[2]-s[0],l=s[3]-s[1];for(let h=0;h=t[2])){const i=ie(t),o=Math.floor((n[0]-t[0])/i)*i;s[0]-=o,s[2]-=o}return s}function Yc(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]]];Xc(s,e);const i=ie(n);if(ie(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 jc(s,e){const t=(""+s).split("."),n=(""+e).split(".");for(let i=0;io)return 1;if(o>r)return-1}return 0}function Mf(s,e){return s[0]+=+e[0],s[1]+=+e[1],s}function tl(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 Ve(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 nl(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 Gi(s,e){const t=s[0]-e[0],n=s[1]-e[1];return t*t+n*n}function vi(s,e){return Math.sqrt(Gi(s,e))}function Df(s,e){return Gi(s,tl(s,e))}function il(s,e){if(e.canWrapX()){const t=ie(e.getExtent()),n=Of(s,e,t);n&&(s[0]-=n*t)}return s}function Of(s,e,t){const n=e.getExtent();let i=0;return e.canWrapX()&&(s[0]n[2])&&(t=t||ie(n),i=Math.floor((s[0]-n[0])/t)),i}function Wc(s){return Math.pow(s,3)}function Wi(s){return 1-Wc(1-s)}function Nf(s){return 3*s*s-2*s*s*s}function Gf(s){return s}const to=63710088e-1;function Ca(s,e,t){t=t||to;const n=Ke(s[1]),i=Ke(e[1]),r=(i-n)/2,o=Ke(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 Io(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;rer?o=er:o<-er&&(o=-er),e[r+1]=o}return e}function Yf(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;rPh&&(e=Ph);const n=Ke(e),i=Math.sin(n),r=Math.cos(n),o=i/r,a=o*o,l=a*a,h=Ke(s),c=qc(t.number),u=Ke(c),d=Lr/Math.sqrt(1-Et*i**2),f=Bn*r**2,g=r*ya(h-u,-Math.PI,Math.PI),m=g*g,_=m*g,p=_*g,y=p*g,E=y*g,x=Lr*(Hc*n-Kf*Math.sin(2*n)+Hf*Math.sin(4*n)-qf*Math.sin(6*n)),T=Ar*d*(g+_/6*(1-a+f)+y/120*(5-18*a+l+72*f-58*Bn))+5e5;let R=Ar*(x+d*o*(m/2+p/24*(5-a+9*f+4*f**2)+E/720*(61-58*a+l+600*f-330*Bn)));return t.north||(R+=1e7),[T,R]}function qc(s){return(s-1)*6-180+3}const og=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Jc(s){let e=0;for(const i of og){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 Ih(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 P0(s,e){return Qc(),ks(s,"EPSG:4326","EPSG:3857")}function I0(s,e){const t=ks(s,"EPSG:3857","EPSG:4326"),n=t[0];return(n<-180||n>180)&&(t[0]=en(n+180,360)-180),t}function Wn(s,e){if(s===e)return!0;const t=s.getUnits()===e.getUnits();return(s.getCode()===e.getCode()||Gs(s,e)===al)&&t}function Gs(s,e){const t=s.getCode(),n=e.getCode();let i=Ao(t,n);if(i)return i;let r=null,o=null;for(const l of hg)r||(r=l(s)),o||(o=l(e));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)i=Lo(r.inverse,o.forward);else{const l=Ao(t,a);l&&(i=Lo(l,o.forward))}else{const l=Ao(a,n);l&&(i=Lo(r.inverse,l))}return i&&(va(s),va(e),Cs(s,e,i)),i}function Lo(s,e){return function(t,n,i,r){return n=s(t,n,i,r),e(n,n,i,r)}}function qn(s,e){const t=de(s),n=de(e);return Gs(t,n)}function ks(s,e,t){const n=qn(e,t);if(!n){const i=de(e).getCode(),r=de(t).getCode();throw new Error(`No transform available between ${i} and ${r}`)}return n(s,void 0,s.length)}function _g(s,e,t,n){const i=qn(e,t);return Ff(s,i,void 0,n)}let mg=null;function pg(){return mg}function Jn(s,e){return s}function pe(s,e){return Sa&&!Ve(s,[0,0])&&s[0]>=-180&&s[0]<=180&&s[1]>=-90&&s[1]<=90&&(Sa=!1,Vc("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),s}function so(s,e){return s}function wt(s,e){return s}function yg(){Ah(Ch),Ah(Sh),fg(Sh,Ch,Xf,Yf)}yg();const eu=new Array(6);function Ce(){return[1,0,0,1,0,0]}function Lh(s){return hl(s,1,0,0,1,0,0)}function ro(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 hl(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 tu(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 fe(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 Fo(s,e,t){return ro(s,hl(eu,e,0,0,t,0,0))}function nu(s,e,t){return ro(s,hl(eu,1,0,0,1,e,t))}function ct(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 Rs(s,e){const t=xg(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 xg(s){return s[0]*s[3]-s[1]*s[2]}const Eg=[1e5,1e5,1e5,1e5,2,2];function Tg(s){return"matrix("+s.join(", ")+")"}function wa(s){return s.substring(7,s.length-1).split(",").map(parseFloat)}function Cg(s,e){const t=wa(s),n=wa(e);for(let i=0;i<6;++i)if(Math.round((t[i]-n[i])*Eg[i])!==0)return!1;return!0}function Gt(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,vg,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]))&&ji(t),this.extentRevision_=this.getRevision()}return If(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=de(e),i=n.getUnits()=="tile-pixels"?function(r,o,a){const l=n.getExtent(),h=n.getWorldExtent(),c=be(h)/be(l);ct(Fh,h[0],h[3],c,-c,0,0,0);const u=Gt(r,0,r.length,a,Fh,o),d=qn(n,t);return d?d(u,u,a):u}:qn(n,t);return this.applyTransform(i),this}}class Mn extends iu{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return Qa(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 dl(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 _l(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 ml(s,e,t,n,i,r){if(t.length===0||!zn(s,e,t[0],n,i,r))return!1;for(let o=1,a=t.length;op&&(h=(c+u)/2,ml(s,e,t,n,h,g)&&(_=h,p=y)),c=u}return isNaN(_)&&(_=i[r]),o?(o.push(_,g,p),o):[_,g,p]}function hu(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:cu(s,e,t,n,function(o,a){return Lf(i,o,a)}):!1}function Dg(s,e,t,n,i){for(let r=0,o=t.length;r0}function xl(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?en(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&&tr(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]],nl(n,e-this.getRotation()),Mf(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&&Jn(e,this.getProjection())}getCenterInternal(){return this.get(vt.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 so(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"),Ta(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(vt.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(wt(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t=t||this.getViewportSizeMinusPadding_();const n=ie(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(vt.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=bo(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=qa(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=ge(Math.floor(e),0,this.resolutions_.length-2),n=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/Math.pow(n,ge(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(!ni(e),"Cannot fit empty extent provided as `geometry`");const i=wt(e,this.getProjection());n=bh(i)}else if(e.getType()==="Circle"){const i=wt(e.getExtent(),this.getProjection());n=bh(i),n.rotate(this.getRotation(),In(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 we(s,e,t,n){let i;return t&&t.length?i=t.shift():at?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 Do;function Dr(){return Do||(Do=we(1,1)),Do}function ho(s){const e=s.canvas;e.width=1,e.height=1,s.clearRect(0,0,1,1)}function Hg(s){let e=s.offsetWidth;const t=getComputedStyle(s);return e+=parseInt(t.marginLeft,10)+parseInt(t.marginRight,10),e}function qg(s){let e=s.offsetHeight;const t=getComputedStyle(s);return e+=parseInt(t.marginTop,10)+parseInt(t.marginBottom,10),e}function kh(s,e){const t=e.parentNode;t&&t.replaceChild(s,e)}function _u(s){for(;s.lastChild;)s.lastChild.remove()}function Jg(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 mu(){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 En(s){return typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}class co extends Rt{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=>Oc(()=>i))),n=t.length>0;if(this.renderedVisible_!=n&&(this.element.style.display=n?"":"none",this.renderedVisible_=n),!Bt(t,this.renderedAttributions_)){_u(this.ulElement_);for(let i=0,r=t.length;i0&&n%(2*Math.PI)!==0?t.animate({rotation:0,duration:this.duration_,easing:Wi}):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(nr);!r&&n===0?this.element.classList.add(nr):r&&n!==0&&this.element.classList.remove(nr)}this.label_.style.transform=i}this.rotation_=n}}class t_ extends co{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+" "+Bs+" "+Sl,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:Wi})):n.setZoom(r)}}}function n_(s){s=s||{};const e=new Ze;return(s.zoom!==void 0?s.zoom:!0)&&e.push(new t_(s.zoomOptions)),(s.rotate!==void 0?s.rotate:!0)&&e.push(new e_(s.rotateOptions)),(s.attribution!==void 0?s.attribution:!0)&&e.push(new Qg(s.attributionOptions)),e}class i_{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 Fa={ACTIVE:"active"};class Vi extends Rt{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(Fa.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(Fa.ACTIVE,e)}setMap(e){this.map_=e}}function s_(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:Gf,center:s.getConstrainedCenter(i)})}}function vl(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:Wi})}class r_ extends Vi{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();vl(a,o,r,this.duration_),n.preventDefault(),t=!0}return!t}}function Ma(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 Pl(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 u_ extends si{constructor(e){e=e||{},super({stopDown:Xi}),this.condition_=e.condition?e.condition:a_,this.lastAngle_=void 0,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){if(!Oo(e))return;const t=e.map,n=t.getView();if(n.getConstraints().rotation===Cl)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 Oo(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return Oo(e)&&yu(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class d_ 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 di={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class is extends ut{constructor(e,t,n){super(e),this.coordinate=t,this.mapBrowserEvent=n}}class f_ extends si{constructor(e){super(),this.on,this.once,this.un,e=e??{},this.box_=new d_(e.className||"ol-dragbox"),this.minArea_=e.minArea??64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition??yu,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 is(di.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 is(t?di.BOXEND:di.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 is(di.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}setActive(e){e||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new is(di.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(e)}setMap(e){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new is(di.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(e)}}class g_ extends f_{constructor(e){e=e||{};const t=e.condition?e.condition:Nr;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:Wi})}}const Gn={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class __ extends Vi{constructor(e){super(),e=e||{},this.defaultCondition_=function(t){return wl(t)&&Eu(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==Gn.DOWN||i==Gn.LEFT||i==Gn.RIGHT||i==Gn.UP)){const o=e.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;i==Gn.DOWN?h=-a:i==Gn.LEFT?l=-a:i==Gn.RIGHT?l=a:h=a;const c=[l,h];nl(c,o.getRotation()),s_(o,c,this.duration_),n.preventDefault(),t=!0}}return!t}}class m_ extends Vi{constructor(e){super(),e=e||{},this.condition_=e.condition?e.condition:function(t){return!h_(t)&&Eu(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();vl(a,o,void 0,this.duration_),n.preventDefault(),t=!0}}return!t}}const p_=40,y_=300;class x_ extends Vi{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?Ma(pu,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*=p_;break;case WheelEvent.DOM_DELTA_PAGE:r*=y_;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=-ge(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(n=n?n>0?1:-1:0),vl(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 E_ extends si{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Xi),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!==Cl&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Pl(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 T_ extends si{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Xi),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(Pl(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 C_(s){s=s||{};const e=new Ze,t=new i_(-.005,.05,100);return(s.altShiftDragRotate!==void 0?s.altShiftDragRotate:!0)&&e.push(new u_),(s.doubleClickZoom!==void 0?s.doubleClickZoom:!0)&&e.push(new r_({delta:s.zoomDelta,duration:s.zoomDuration})),(s.dragPan!==void 0?s.dragPan:!0)&&e.push(new c_({onFocusOnly:s.onFocusOnly,kinetic:t})),(s.pinchRotate!==void 0?s.pinchRotate:!0)&&e.push(new E_),(s.pinchZoom!==void 0?s.pinchZoom:!0)&&e.push(new T_({duration:s.zoomDuration})),(s.keyboard!==void 0?s.keyboard:!0)&&(e.push(new __),e.push(new m_({delta:s.zoomDelta,duration:s.zoomDuration}))),(s.mouseWheelZoom!==void 0?s.mouseWheelZoom:!0)&&e.push(new x_({onFocusOnly:s.onFocusOnly,duration:s.zoomDuration})),(s.shiftDragZoom!==void 0?s.shiftDragZoom:!0)&&e.push(new g_({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 Cu extends Rt{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=ge(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 un={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class mn extends ut{constructor(e,t){super(e),this.layer=t}}const No={LAYERS:"layers"};class Zi extends Cu{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(No.LAYERS,this.handleLayersChanged_),n?Array.isArray(n)?n=new Ze(n.slice(),{unique:!0}):te(typeof n.getArray=="function","Expected `layers` to be an array or a `Collection`"):n=new Ze(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,Se.ADD,this.handleLayersAdd_,this),J(e,Se.REMOVE,this.handleLayersRemove_,this));for(const n in this.listenerKeys_)this.listenerKeys_[n].forEach(ue);ei(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 Jt?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 Il(i,t.viewState)&&(!r||Te(r,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];const t=this.getSource()?.getAttributions();if(!t)return[];const n=e instanceof Jt?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,Me.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 Il(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 Ru(s,e,t=0,n=s.length-1,i=R_){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));Ru(s,e,f,g,i)}const r=s[e];let o=t,a=n;for(ss(s,t,e),i(s[n],r)>0&&ss(s,t,n);o0;)a--}i(s[t],r)===0?ss(s,t,a):(a++,ss(s,a,n)),a<=e&&(t=a+1),e<=a&&(n=a-1)}}function ss(s,e,t){const n=s[e];s[e]=s[t],s[t]=n}function R_(s,e){return se?1:0}let Al=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(!sr(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=Ci(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,fi(n,this.toBBox),fi(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(n,a)}_splitRoot(e,t){this.data=Ci([e,t]),this.data.height=e.height+1,this.data.leaf=!1,fi(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=hs(e,0,a,this.toBBox),h=hs(e,a,n,this.toBBox),c=I_(l,h),u=Go(l)+Go(h);c=t;h--){const c=e.children[h];cs(a,e.leaf?r(c):c),l+=ir(a)}return l}_adjustParentBBoxes(e,t,n){for(let i=n;i>=0;i--)cs(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():fi(e[t],this.toBBox)}};function S_(s,e,t){if(!t)return e.indexOf(s);for(let n=0;n=s.minX&&e.maxY>=s.minY}function Ci(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Uh(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;Ru(s,o,e,t,i),r.push(e,o,o,t)}}const Ll=[NaN,NaN,NaN,0];let Uo;function A_(){return Uo||(Uo=we(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Uo}const L_=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,F_=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,M_=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,b_=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function rr(s,e){return s.endsWith("%")?Number(s.substring(0,s.length-1))/e:Number(s)}function _s(s){throw new Error('failed to parse "'+s+'" as color')}function Su(s){if(s.toLowerCase().startsWith("rgb")){const r=s.match(F_)||s.match(L_)||s.match(M_);if(r){const o=r[4],a=100/255;return[ge(rr(r[1],a)+.5|0,0,255),ge(rr(r[2],a)+.5|0,0,255),ge(rr(r[3],a)+.5|0,0,255),o!==void 0?ge(rr(o,100),0,1):1]}_s(s)}if(s.startsWith("#")){if(b_.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 $o(s){return s>.2068965?Math.pow(s,3):(s-4/29)*(108/841)}function Xo(s){return s>10.314724?Math.pow((s+14.025)/269.025,2.4):s/3294.6}function Yo(s){return s>.0088564?Math.pow(s,1/3):s/(108/841)+4/29}function Bh(s){const e=Xo(s[0]),t=Xo(s[1]),n=Xo(s[2]),i=Yo(e*.222488403+t*.716873169+n*.06060791),r=500*(Yo(e*.452247074+t*.399439023+n*.148375274)-i),o=200*(i-Yo(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 G_(s){const e=(s[0]+16)/116,t=s[1],n=s[2]*Math.PI/180,i=$o(e),r=$o(e+t/500*Math.cos(n)),o=$o(e-t/200*Math.sin(n)),a=zo(r*3.021973625-i*1.617392459-o*.404875592),l=zo(r*-.943766287+i*1.916279586+o*.027607165),h=zo(r*.069407491-i*.22898585+o*1.159737864);return[ge(a+.5|0,0,255),ge(l+.5|0,0,255),ge(h+.5|0,0,255),s[3]]}function Fl(s){if(s==="none")return Ll;if(rs.hasOwnProperty(s))return rs[s];if(Bo>=O_){let t=0;for(const n in rs)(t++&3)===0&&(delete rs[n],--Bo)}const e=Su(s);e.length!==4&&_s(s);for(const t of e)isNaN(t)&&_s(s);return rs[s]=e,++Bo,e}function Ct(s){return Array.isArray(s)?s:Fl(s)}function Ml(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 zh(s){return s[0]>0&&s[1]>0}function k_(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 Xe(s,e){return Array.isArray(s)?s:(e===void 0?e=[s,s]:(e[0]=s,e[1]=s),e)}let ri=0;const ve=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"},z_={[C.Get]:j(q(1,1/0),$h),[C.Var]:j(q(1,1),$_),[C.Has]:j(q(1,1/0),$h),[C.Id]:j(X_,gi),[C.Concat]:j(q(2,1/0),re(Ie)),[C.GeometryType]:j(Y_,gi),[C.LineMetric]:j(gi),[C.Resolution]:j(jo,gi),[C.Zoom]:j(jo,gi),[C.Time]:j(jo,gi),[C.Any]:j(q(2,1/0),re(ve)),[C.All]:j(q(2,1/0),re(ve)),[C.Not]:j(q(1,1),re(ve)),[C.Equal]:j(q(2,2),re(or)),[C.NotEqual]:j(q(2,2),re(or)),[C.GreaterThan]:j(q(2,2),re(N)),[C.GreaterThanOrEqualTo]:j(q(2,2),re(N)),[C.LessThan]:j(q(2,2),re(N)),[C.LessThanOrEqualTo]:j(q(2,2),re(N)),[C.Multiply]:j(q(2,1/0),Xh),[C.Coalesce]:j(q(2,1/0),Xh),[C.Divide]:j(q(2,2),re(N)),[C.Add]:j(q(2,1/0),re(N)),[C.Subtract]:j(q(2,2),re(N)),[C.Clamp]:j(q(3,3),re(N)),[C.Mod]:j(q(2,2),re(N)),[C.Pow]:j(q(2,2),re(N)),[C.Abs]:j(q(1,1),re(N)),[C.Floor]:j(q(1,1),re(N)),[C.Ceil]:j(q(1,1),re(N)),[C.Round]:j(q(1,1),re(N)),[C.Sin]:j(q(1,1),re(N)),[C.Cos]:j(q(1,1),re(N)),[C.Atan]:j(q(1,2),re(N)),[C.Sqrt]:j(q(1,1),re(N)),[C.Match]:j(q(4,1/0),Yh,W_),[C.Between]:j(q(3,3),re(N)),[C.Interpolate]:j(q(6,1/0),Yh,V_),[C.Case]:j(q(3,1/0),j_,Z_),[C.In]:j(q(2,2),K_),[C.Number]:j(q(1,1/0),re(or)),[C.String]:j(q(1,1/0),re(or)),[C.Array]:j(q(1,1/0),re(N)),[C.Color]:j(q(1,4),re(N)),[C.Band]:j(q(1,3),re(N)),[C.Palette]:j(q(2,2),H_),[C.ToString]:j(q(1,1),re(ve|N|Ie|_e))};function $h(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 Xh(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=>Pt(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 tm(s);case C.Equal:case C.NotEqual:case C.LessThan:case C.LessThanOrEqualTo:case C.GreaterThan:case C.GreaterThanOrEqualTo:return em(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 nm(s);case C.Case:return im(s);case C.Match:return sm(s);case C.Interpolate:return rm(s);case C.ToString:return om(s);default:throw new Error(`Unsupported operator ${t}`)}}function J_(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 tm(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 nm(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 im(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?am(r,o,a,l,c,u):ds(r,o,a,l,c,u);a=c,l=u}return l}}function om(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===_e?Ml(o):o.toString()};default:throw new Error(`Unsupported convert operator ${t}`)}}function ds(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 am(s,e,t,n,i,r){if(i-t===0)return n;const a=Bh(n),l=Bh(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[ds(s,e,t,a[0],i,l[0]),ds(s,e,t,a[1],i,l[1]),a[2]+ds(s,e,t,0,i,h),ds(s,e,t,n[3],i,r[3])];return G_(c)}const U={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};class lm extends Ds{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;Oc(()=>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||pf&&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 hm(s,e,t){const n=s;let i=!0,r=!1,o=!1;const a=[wr(n,V.LOAD,function(){o=!0,r||e()})];return n.src&&Gc?(r=!0,n.decode().then(function(){i&&e()}).catch(function(l){i&&(o?e():t())})):a.push(wr(n,V.ERROR,t)),function(){i=!1,a.forEach(ue)}}function cm(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 um(s,e){return e&&(s.src=e),s.src&&Gc?new Promise((t,n)=>s.decode().then(()=>t(s)).catch(i=>s.complete&&s.width?t(s):n(i))):cm(s)}class dm{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=Wo(e,t,n);return i in this.cache_?this.cache_[i]:null}getPattern(e,t,n){const i=Wo(e,t,n);return i in this.patternCache_?this.patternCache_[i]:null}set(e,t,n,i,r){const o=Wo(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]=Dr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[o]=Dr().createPattern(i.getImage(1),"repeat")),a||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}}function Wo(s,e,t){const n=t?Ct(t):"null";return e+":"+s+":"+n}const xt=new dm;let os=null;class Pu extends Ds{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){os||(os=we(1,1,void 0,{willReadFrequently:!0})),os.drawImage(this.image_,0,0);try{os.getImageData(0,0,1,1),this.tainted_=!1}catch{os=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=we(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&&um(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=we(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=D_(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 Gr(s,e,t,n,i,r){let o=e===void 0?void 0:xt.get(e,t,i);return o||(o=new Pu(s,s&&"src"in s?s.src||void 0:e,t,n,i),xt.set(e,t,i,o,r)),r&&o&&!xt.getPattern(e,t,i)&&xt.set(e,t,i,o,r),o}function Ot(s){return s?Array.isArray(s)?Ml(s):typeof s=="object"&&"src"in s?fm(s):s:null}function fm(s){if(!s.offset||!s.size)return xt.getPattern(s.src,"anonymous",s.color);const e=s.src+":"+s.offset,t=xt.getPattern(e,void 0,s.color);if(t)return t;const n=xt.get(s.src,"anonymous",null);if(n.getImageState()!==U.LOADED)return null;const i=we(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]),Gr(i.canvas,e,void 0,U.LOADED,s.color,!0),xt.getPattern(e,void 0,s.color)}const Iu="10px sans-serif",Je="#000",Bi="round",nn=[],sn=0,zi="round",ws=10,Ps="#000",Is="center",kr="middle",$n=[0,0,0,0],As=1,Ri=new Rt;let as=null,jh;const ba={},gm=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function _m(s,e,t){return`${s} ${e} 16px "${t}"`}const mm=(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=La(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=Aa[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function i(){await t.ready;let r=!0;const o=Ri.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)?(ei(ba),Ri.set(h,100)):(c+=10,Ri.set(h,c,!0),c<100&&(r=!1)))}e=void 0,r||(e=setTimeout(i,100))}return async function(r){t||(t=at?self.fonts:document.fonts);const o=La(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(gm.has(h))continue;const c=_m(o.style,o.weight,h);Ri.get(c)===void 0&&(Ri.set(c,0,!0),l=!0)}l&&(clearTimeout(e),e=setTimeout(i,100))}})(),pm=(function(){let s;return function(e){let t=ba[e];if(t==null){if(at){const n=La(e),i=Au(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);ba[e]=t}return t}})();function Au(s,e){return as||(as=we(1,1)),s!=jh&&(as.font=s,jh=as.font),as.measureText(e)}function Lu(s,e){return Au(s,e).width}function Wh(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 ym(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=pm(d);n.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:t,heights:n,lineWidths:i}}function xm(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]),Em(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 Em(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 fo({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=xt.get(n,null,null)?.getImage(1);if(!i){const r=this.renderOptions_,o=Math.ceil(r.size*e),a=we(o,o);this.draw_(r,a,e),i=a.canvas,xt.set(n,null,null,new Pu(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:Ct(e).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function Vh(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 Ki extends uo{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?Ct(e.color):null,this.iconImage_=Gr(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(Vh(f[0],f[1],e.width,e.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(Vh(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 Ki({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_=Gr(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 kt{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 kt({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 Ne{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=Zh,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 Ne({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_=Zh,this.geometry_=e}setZIndex(e){this.zIndex_=e}}function Tm(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 Vo=null;function Fu(s,e){if(!Vo){const t=new It({color:"rgba(255,255,255,0.4)"}),n=new kt({color:"#3399CC",width:1.25});Vo=[new Ne({image:new $s({fill:t,stroke:n,radius:5}),fill:t,stroke:n})]}return Vo}function Nl(){const s={},e=[255,255,255,1],t=[0,153,255,1],n=3;return s.Polygon=[new Ne({fill:new It({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new Ne({stroke:new kt({color:e,width:n+2})}),new Ne({stroke:new kt({color:t,width:n})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new Ne({image:new $s({radius:n*2,fill:new It({color:t}),stroke:new kt({color:e,width:n/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function Zh(s){return s.getGeometry()}const Cm="#333";class Xs{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_=Xe(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 It({color:Cm}),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 Xs({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 It?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_=Xe(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 Rm(s){return!0}function Sm(s){const e=Dl(),t=vm(s,e),n=wu();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=Ol(i.getGeometry())),t(n)}}function Kh(s){const e=Dl(),t=s.length,n=new Array(t);for(let o=0;onull;n=Gl(s,e+"fill-color",t)}if(!n)return null;const i=new It;return function(r){const o=n(r);return o===Ll?null:(i.setColor(o),i)}}function Fs(s,e,t){const n=et(s,e+"stroke-width",t),i=Gl(s,e+"stroke-color",t);if(!n&&!i)return null;const r=Ht(s,e+"stroke-line-cap",t),o=Ht(s,e+"stroke-line-join",t),a=Mu(s,e+"stroke-line-dash",t),l=et(s,e+"stroke-line-dash-offset",t),h=et(s,e+"stroke-miter-limit",t),c=new kt;return function(u){if(i){const d=i(u);if(d===Ll)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 wm(s,e){const t="text-",n=Ht(s,t+"value",e);if(!n)return null;const i=Ls(s,t,e),r=Ls(s,t+"background-",e),o=Fs(s,t,e),a=Fs(s,t+"background-",e),l=Ht(s,t+"font",e),h=et(s,t+"max-angle",e),c=et(s,t+"offset-x",e),u=et(s,t+"offset-y",e),d=Fi(s,t+"overflow",e),f=Ht(s,t+"placement",e),g=et(s,t+"repeat",e),m=go(s,t+"scale",e),_=Fi(s,t+"rotate-with-view",e),p=et(s,t+"rotation",e),y=Ht(s,t+"align",e),E=Ht(s,t+"justify",e),x=Ht(s,t+"baseline",e),T=Fi(s,t+"keep-upright",e),R=Mu(s,t+"padding",e),S=_o(s,t+"declutter-mode"),v=new Xs({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 Pm(s,e){return"icon-src"in s?Im(s,e):"shape-points"in s?Am(s,e):"circle-radius"in s?Lm(s,e):null}function Im(s,e){const t="icon-",n=t+"src",i=bu(s[n],n),r=Ur(s,t+"anchor",e),o=go(s,t+"scale",e),a=et(s,t+"opacity",e),l=Ur(s,t+"displacement",e),h=et(s,t+"rotation",e),c=Fi(s,t+"rotate-with-view",e),u=qh(s,t+"anchor-origin"),d=Jh(s,t+"anchor-x-units"),f=Jh(s,t+"anchor-y-units"),g=Om(s,t+"color"),m=bm(s,t+"cross-origin"),_=Dm(s,t+"offset"),p=qh(s,t+"offset-origin"),y=Br(s,t+"width"),E=Br(s,t+"height"),x=Mm(s,t+"size"),T=_o(s,t+"declutter-mode"),R=new Ki({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 Am(s,e){const t="shape-",n=t+"points",i=t+"radius",r=Oa(s[n],n),o=Oa(s[i],i),a=Ls(s,t,e),l=Fs(s,t,e),h=go(s,t+"scale",e),c=Ur(s,t+"displacement",e),u=et(s,t+"rotation",e),d=Fi(s,t+"rotate-with-view",e),f=Br(s,t+"radius2"),g=Br(s,t+"angle"),m=_o(s,t+"declutter-mode"),_=new fo({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 Lm(s,e){const t="circle-",n=Ls(s,t,e),i=Fs(s,t,e),r=et(s,t+"radius",e),o=go(s,t+"scale",e),a=Ur(s,t+"displacement",e),l=et(s,t+"rotation",e),h=Fi(s,t+"rotate-with-view",e),c=_o(s,t+"declutter-mode"),u=new $s({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 et(s,e,t){if(!(e in s))return;const n=an(s[e],N,t);return function(i){return Oa(n(i),e)}}function Ht(s,e,t){if(!(e in s))return null;const n=an(s[e],Ie,t);return function(i){return bu(n(i),e)}}function Fm(s,e,t){const n=Ht(s,e+"pattern-src",t),i=Hh(s,e+"pattern-offset",t),r=Hh(s,e+"pattern-size",t),o=Gl(s,e+"color",t);return function(a){return{src:n(a),offset:i&&i(a),size:r&&r(a),color:o&&o(a)}}}function Fi(s,e,t){if(!(e in s))return null;const n=an(s[e],ve,t);return function(i){const r=n(i);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${e}`);return r}}function Gl(s,e,t){if(!(e in s))return null;const n=an(s[e],_e,t);return function(i){return Du(n(i),e)}}function Mu(s,e,t){if(!(e in s))return null;const n=an(s[e],nt,t);return function(i){return Ys(n(i),e)}}function Ur(s,e,t){if(!(e in s))return null;const n=an(s[e],nt,t);return function(i){const r=Ys(n(i),e);if(r.length!==2)throw new Error(`Expected two numbers for ${e}`);return r}}function Hh(s,e,t){if(!(e in s))return null;const n=an(s[e],nt,t);return function(i){return Ou(n(i),e)}}function go(s,e,t){if(!(e in s))return null;const n=an(s[e],nt|N,t);return function(i){return Nm(n(i),e)}}function Br(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 Mm(s,e){const t=s[e];if(t!==void 0){if(typeof t=="number")return Xe(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 bm(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 qh(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 Jh(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 Dm(s,e){const t=s[e];if(t!==void 0)return Ys(t,e)}function _o(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 Om(s,e){const t=s[e];if(t!==void 0)return Du(t,e)}function Ys(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 Ou(s,e){const t=Ys(s,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function Nm(s,e){return typeof s=="number"?s:Ou(s,e)}const Qh={RENDER_ORDER:"renderOrder"};class Hi extends zs{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(Qh.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 Al(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(Qh.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?Fu:e;const t=Gm(e);this.styleFunction_=e===null?void 0:Tm(t),this.changed()}setDeclutter(e){this.declutter_=e?String(e):void 0,this.changed()}}function Gm(s){if(s===void 0)return Fu;if(!s)return null;if(typeof s=="function"||s instanceof Ne)return s;if(!Array.isArray(s))return Kh([s]);if(s.length===0)return[];const e=s.length,t=s[0];if(t instanceof Ne){const i=new Array(e);for(let r=0;r=0;--T){const R=m[T],S=R.layer;if(S.hasRenderer()&&Il(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,Pn,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(e){$()}scheduleExpireIconCache(e){xt.canExpireCache()&&e.postRenderFunctions.push(Um)}}function Um(s,e){xt.expire()}class Bm extends km{constructor(e){super(e),this.fontChangeListenerKey_=J(Ri,Ni.PROPERTYCHANGE,e.redrawText,e),this.element_=at?mu():document.createElement("div");const t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=Bs+" 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 ms(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(Me.PRECOMPOSE,e);const t=e.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);t.some(h=>h.layer instanceof Hi&&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)),En(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(...wa(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(Me.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 Nu(s){if(s instanceof zs){s.setMapInternal(null);return}s instanceof Zi&&s.getLayers().forEach(Nu)}function Gu(s,e){if(s instanceof zs){s.setMapInternal(e);return}if(s instanceof Zi){const t=s.getLayers().getArray();for(let n=0,i=t.length;nthis.updateSize())),this.controls=t.controls||(at?new Ze:n_()),this.interactions=t.interactions||(at?new Ze:C_({onFocusOnly:!0})),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Ef(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Be.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Be.VIEW,this.handleViewChanged_),this.addChangeListener(Be.SIZE,this.handleSizeChanged_),this.addChangeListener(Be.TARGET,this.handleTargetChanged_),this.setProperties(t.values);const n=this;e.view&&!(e.view instanceof Jt)&&e.view.then(function(i){n.setView(new Jt(i))}),this.controls.addEventListener(Se.ADD,i=>{i.element.setMap(this)}),this.controls.addEventListener(Se.REMOVE,i=>{i.element.setMap(null)}),this.interactions.addEventListener(Se.ADD,i=>{i.element.setMap(this)}),this.interactions.addEventListener(Se.REMOVE,i=>{i.element.setMap(null)}),this.overlays_.addEventListener(Se.ADD,i=>{this.addOverlayInternal_(i.element)}),this.overlays_.addEventListener(Se.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){Gu(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:Pn,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 Zi?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:Pn,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(Be.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return Jn(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){const t=this.frameState_;return t?fe(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(Be.LAYERGROUP)}setLayers(e){const t=this.getLayerGroup();if(e instanceof Ze){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 mn("removelayer",t)),this.set(Be.LAYERGROUP,e)}setSize(e){this.set(Be.SIZE,e)}setTarget(e){this.set(Be.TARGET,e)}setView(e){if(!e||e instanceof Jt){this.set(Be.VIEW,e);return}this.set(Be.VIEW,new Jt);const t=this;e.then(function(n){t.setView(new Jt(n))})}updateSize(){const e=this.getTargetElement();let t;if(e){let i,r;if(En(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)],!zh(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&Vc("No map visible because the map container's width or height are 0."))}const n=this.getSize();t&&(!n||!Bt(t,n))&&(this.setSize(t),this.updateViewportSize_(t))}updateViewportSize_(e){const t=this.getView();t&&t.setViewportSize(e)}};function zm(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 Zi({layers:s.layers});t[Be.LAYERGROUP]=n,t[Be.TARGET]=s.target,t[Be.VIEW]=s.view instanceof Jt?s.view:new Jt;let i;s.controls!==void 0&&(Array.isArray(s.controls)?i=new Ze(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 Ze(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 Ze(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 Ze,{controls:i,interactions:r,keyboardEventTarget:e,overlays:o,values:t}}const Ue={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class D0 extends Rt{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 "+Zg,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(Ue.ELEMENT,this.handleElementChanged),this.addChangeListener(Ue.MAP,this.handleMapChanged),this.addChangeListener(Ue.OFFSET,this.handleOffsetChanged),this.addChangeListener(Ue.POSITION,this.handlePositionChanged),this.addChangeListener(Ue.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(Ue.ELEMENT)}getId(){return this.id}getMap(){return this.get(Ue.MAP)||null}getOffset(){return this.get(Ue.OFFSET)}getPosition(){return this.get(Ue.POSITION)}getPositioning(){return this.get(Ue.POSITIONING)}handleElementChanged(){_u(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,Kt.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(Ue.ELEMENT,e)}setMap(e){this.set(Ue.MAP,e)}setOffset(e){this.set(Ue.OFFSET,e)}setPosition(e){this.set(Ue.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(Ue.POSITION))return;const n=this.getRect(t.getTargetElement(),t.getSize()),i=this.getElement(),r=this.getRect(i,[Hg(i),qg(i)]);e=e||{};const o=e.margin===void 0?20:e.margin;if(!yn(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(Ue.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 kl extends Ds{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:Wc(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 Na(s){return s instanceof Image||s instanceof HTMLCanvasElement||s instanceof HTMLVideoElement||s instanceof ImageBitmap?s:null}const $m=new Error("disposed"),Xm=[256,256];class ec extends kl{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=Na(this.data_);return e?[e.width,e.height]:Xm}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($m),this.controller_=null),super.disposeInternal()}}class ku extends kl{constructor(e,t,n,i,r,o){super(e,t,o),this.crossOrigin_=i,this.src_=n,this.key=n,this.image_,at?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_=Ym(),this.changed()}handleImageLoad_(){if(at)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_=hm(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 Ym(){const s=we(1,1);return s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,1,1),s.canvas}class Ul{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 _i(s,e,t,n,i){return i!==void 0?(i.minX=s,i.maxX=e,i.minY=t,i.maxY=n,i):new Ul(s,e,t,n)}let Zo;const Mi=[];function tc(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 Ko(s,e){return Math.abs(s[e*4]-210)>2||Math.abs(s[e*4+3]-.75*255)>2}function jm(){if(Zo===void 0){const s=we(6,6,Mi);s.globalCompositeOperation="lighter",s.fillStyle="rgba(210, 0, 0, 0.75)",tc(s,4,5,4,0),tc(s,4,5,0,5);const e=s.getImageData(0,0,3,3).data;Zo=Ko(e,0)||Ko(e,4)||Ko(e,8),ho(s),Mi.push(s.canvas)}return Zo}function Ga(s,e,t,n){const i=ks(t,e,s);let r=Fr(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||Kn(l,i)){const h=Fr(s,r,i)/r;isFinite(h)&&h>0&&(r/=h)}return r}function Wm(s,e,t,n){const i=In(t);let r=Ga(s,e,i,n);return(!isFinite(r)||r<=0)&&el(t,function(o){return r=Ga(s,e,o,n),isFinite(r)&&r>0}),r}function Vm(s,e,t,n,i,r,o,a,l,h,c,u,d,f){const g=we(Math.round(t*s),Math.round(t*e),Mi);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 _=tt();l.forEach(function(T,R,S){Bc(_,T.extent)});let p;const y=t/n,E=(u?1:1+Math.pow(2,-24))/y;p=we(Math.round(ie(_)*y),Math.round(be(_)*y),Mi),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 A=(T.clipExtent[0]-_[0])*y,M=-(T.clipExtent[3]-_[3])*y,b=ie(T.clipExtent)*y,K=be(T.clipExtent)*y;p.rect(u?A:Math.round(A),u?M:Math.round(M),u?b:Math.round(A+b)-Math.round(A),u?K:Math.round(M+K)-Math.round(M)),p.clip()}const v=(T.extent[0]-_[0])*y,w=-(T.extent[3]-_[3])*y,I=ie(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=Fn(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],A=v[1][0],M=v[1][1],b=v[2][0],K=v[2][1];const L=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,Ge=F;I=0,F=0,A-=P,M-=Ge,b-=P,K-=Ge;const je=[[A,M,0,0,G-L],[b,K,0,0,Q-L],[0,0,A,M,H-Z],[0,0,b,K,le-Z]],Ee=Rf(je);if(!Ee)return;if(g.save(),g.beginPath(),jm()||!u){g.moveTo(G,H);const ke=4,Lt=L-G,St=Z-H;for(let st=0;stfe(a,ks(E,this.targetProj_,this.sourceProj_))):qn(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()&&ie(i)>=ie(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?ie(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?ie(this.targetProj_.getExtent()):null;const c=Fn(n),u=eo(n),d=Qr(n),f=Jr(n),g=this.transformInv_(c),m=this.transformInv_(u),_=this.transformInv_(d),p=this.transformInv_(f),y=Zm+(o?Math.max(0,Math.ceil(Math.log2(Ea(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 _=ze([e,t,n,i]);g=ie(_)/this.targetWorldWidth_>nc||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>nc||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!Te(c,this.maxSourceExtent_))return;let m=0;if(!g&&(!isFinite(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=(en(r[0],d)+en(a[0],d))/2-en(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=tt();return this.triangles_.forEach(function(t,n,i){const r=t.source;gs(e,r[0]),gs(e,r[1]),gs(e,r[2])}),e}getTriangles(){return this.triangles_}}const Hm=.5;class Uu extends kl{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?tn(f,g):f;if(Ea(_)===0){this.state=B.EMPTY;return}const p=e.getExtent();p&&(m?m=tn(m,p):m=p);const y=i.getResolution(this.wrappedTileCoord_[0]),E=Wm(e,n,_,y);if(!isFinite(E)||E<=0){this.state=B.EMPTY;return}const x=c!==void 0?c:Hm;if(this.triangulation_=new Km(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]=ge(T[1],m[1],m[3]),T[3]=ge(T[3],m[1],m[3])):T=tn(T,m)),!Ea(T))this.state=B.EMPTY;else{let R=0,S=0;e.canWrapX()&&(R=ie(p),S=Math.floor((T[0]-p[0])/R)),Yc(T.slice(),e,!0).forEach(w=>{const I=t.getTileRangeForExtentAndZ(w,this.sourceZ_);for(let F=I.minX;F<=I.maxX;F++)for(let A=I.minY;A<=I.maxY;A++){const M=h(this.sourceZ_,F,A,a);if(M){const b=S*R;this.sourceTiles_.push({tile:M,offset:b})}}++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_=Vm(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_&&(ho(this.canvas_.getContext("2d")),Mi.push(this.canvas_),this.canvas_=null),super.release()}}class ic{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 zr(s,e,t,n){return n!==void 0?(n[0]=s,n[1]=e,n[2]=t,n):[s,e,t]}function qm(s,e,t){return s+"/"+e+"/"+t}function Cr(s,e,t,n,i){return`${D(s)},${e},${qm(t,n,i)}`}function Bu(s){return Jm(s[0],s[1],s[2])}function Jm(s,e,t){return(e<t||t>e.getMaxZoom())return!1;const r=e.getFullTileRange(t);return r?r.containsXY(n,i):!0}class Bl{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Dr(),{get:(e,t)=>{if(typeof Dr()[t]=="function")return this.push_(t),this.pushMethodArgs_},set:(e,t,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 sc=[];let Si=null;function tp(){Si=we(1,1,void 0,{willReadFrequently:!0})}class zl extends zu{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=Ce(),this.pixelTransform=Ce(),this.inversePixelTransform=Ce(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,t,n){Si||tp(),Si.clearRect(0,0,1,1);let i;try{Si.drawImage(e,t,n,1,1,0,0,1,1),i=Si.getImageData(0,0,1,1).data}catch{return Si=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&&Bt(Ct(e.style.backgroundColor),Ct(n)))){const a=e.firstElementChild;En(a)&&(o=a.getContext("2d"))}if(o&&Cg(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=at?mu():document.createElement("div"),r.className=i;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=we();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=Fn(n),r=eo(n),o=Qr(n),a=Jr(n);fe(t.coordinateToPixelTransform,i),fe(t.coordinateToPixelTransform,r),fe(t.coordinateToPixelTransform,o),fe(t.coordinateToPixelTransform,a);const l=this.inversePixelTransform;fe(l,i),fe(l,r),fe(l,o),fe(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(ie(n)/i*o),l=Math.round(be(n)/i*o);ct(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/o,1/o,r,-a/2,-l/2),Rs(this.inversePixelTransform,this.pixelTransform);const h=Tg(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 ms(e,this.inversePixelTransform,n,t);i.dispatchEvent(r)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(Me.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(Me.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new Bl),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(Me.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(Me.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 ct(this.tempTransform,l,h,c,u,-n,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function Ho(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 np(s,e,t){const n=s[t];return n?n.delete(e):!1}function rc(s,e){const t=s.layerStatesArray[s.layerIndex];t.extent&&(e=tn(e,wt(t.extent,s.viewState.projection)));const n=t.layer.getRenderSource();if(!n.getWrapX()){const i=n.getTileGridForProjection(s.viewState.projection).getExtent();i&&(e=tn(e,i))}return e}class $u extends zl{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=tt(),this.tempTileRange_=new Ul(0,0,0,0),this.tempTileCoord_=zr(0,0,0);const n=t.cacheSize!==void 0?t.cacheSize:512;this.tileCache_=new ic(n),this.sourceTileCache_=null,this.maxStaleKeys=n*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new ic(512)),this.sourceTileCache_}getOrCreateTile(e,t,n,i){const r=this.tileCache_,a=this.getLayer().getSource(),l=Cr(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||Wn(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=fe(t.pixelToCoordinateTransform,e.slice()),r=n.getExtent();if(r&&!Kn(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=Xe(l.getTileSize(c)),m=l.getResolution(c);let _;if(d instanceof ku||d instanceof Uu)_=d.getImage();else if(d instanceof ec){if(_=Na(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?$c(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||!Ho(i,T,_))continue;const S=T.getKey();if(u[S]=!0,T.getState()===B.IDLE&&!e.tileQueue.isKeyQueued(S)){const v=zr(_,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)){np(S,G,d),e.animate=!0;continue}if(this.findAltTiles_(u,Q,d+1,S))continue;const Ge=u.getMinZoom();for(let je=d-1;je>=Ge&&!this.findAltTiles_(u,Q,je,S);--je);}const A=f/o*l/_,M=this.getRenderContext(e);ct(this.tempTransform,p/2,y/2,A,A,0,-p/2,-y/2),n.extent&&this.clipUnrotated(M,e,E),c.getInterpolate()||(M.imageSmoothingEnabled=!1),this.preRender(M,e);const b=Object.keys(S).map(Number);b.sort(Nt);let K;const L=[],Z=[];for(let G=b.length-1;G>=0;--G){const H=b[G],Q=c.getTilePixelSize(H,l,r),P=u.getResolution(H)/f,Ge=Q[0]*P*A,je=Q[1]*P*A,Ee=u.getTileCoordForCoordAndZ(Fn(R),H),it=u.getTileCoordExtent(Ee),ke=fe(this.tempTransform,[_*(it[0]-R[0])/f,_*(R[3]-it[3])/f]),Lt=_*c.getGutterForProjection(r);for(const St of S[H]){if(St.getState()!==B.LOADED)continue;const st=St.tileCoord,Vs=Ee[1]-st[1],Co=Math.round(ke[0]-(Vs-1)*Ge),Ji=Ee[2]-st[2],bn=Math.round(ke[1]-(Ji-1)*je),dt=Math.round(ke[0]-Vs*Ge),Ft=Math.round(ke[1]-Ji*je),ai=Co-dt,li=bn-Ft,Qi=b.length===1;let Dn=!1;K=[dt,Ft,dt+ai,Ft,dt+ai,Ft+li,dt,Ft+li];for(let hi=0,ci=L.length;hi{const le=D(c),P=Q.wantedTiles[le],Ge=P?Object.keys(P).length:0;this.updateCacheSize(Ge),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 ec){if(h=Na(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 Tn={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class ip extends zs{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(Tn.PRELOAD)}setPreload(e){this.set(Tn.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(Tn.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(Tn.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}}class O0 extends ip{constructor(e){super(e)}createRenderer(){return new $u(this,{cacheSize:this.getCacheSize()})}}class Xu extends zl{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=tn(l,wt(t.extent,i.projection))),!a[he.ANIMATING]&&!a[he.INTERACTING]&&!ni(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=fe(t.pixelToCoordinateTransform,e.slice()),r=n.getExtent();if(r&&!Kn(r,i))return null;const o=this.image.getExtent(),a=this.image.getImage(),l=ie(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=wt(h.extent,u.projection);x=Te(w,e.extent),E=x&&!yn(w,e.extent),E&&this.clipUnrotated(y,e,w)}const T=n.getImage(),R=ct(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 sp extends zs{constructor(e){e=e||{},super(e)}}class N0 extends sp{constructor(e){super(e)}createRenderer(){return new Xu(this)}getData(e){return super.getData(e)}}class Yu{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},ar=[X.FILL],Cn=[X.STROKE],Xn=[X.BEGIN_PATH],oc=[X.CLOSE_PATH];class js extends Yu{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,xn,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,c,e,i||n,xn,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&&!Bt(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_=Uc(this.maxExtent),this.maxLineWidth>0)){const e=this.resolution*(this.maxLineWidth+1)/2;rn(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class rp extends js{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&&!Kn(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=rt(h,u,g),_=rt(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 lp(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 $r={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class hp extends js{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[Je]={fillStyle:Je},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(!Te(this.maxExtent,e.getExtent()))return;let d;if(c=e.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=e.getEnds();else if(h=="Polygon")d=e.getEnds().slice(0,1);else if(h=="MultiPolygon"){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(_!=$n&&(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_,_==$n?$n:_.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]=Je),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_?Je: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||Is,justify:t.justify,textBaseline:t.textBaseline||kr,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=$r[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&&Je,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=Ot(o.getColor()||Je)):(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()||Bi,r.lineDash=m?m.slice():nn,r.lineDashOffset=_===void 0?sn:_,r.lineJoin=a.getLineJoin()||zi,r.lineWidth=p===void 0?As:p,r.miterLimit=y===void 0?ws:y,r.strokeStyle=Ot(a.getColor()||Ps)}n=this.textState_;const l=e.getFont()||Iu;mm(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()||kr,n.backgroundFill=e.getBackgroundFill(),n.backgroundStroke=e.getBackgroundStroke(),n.padding=e.getPadding()||$n,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 cp={Circle:ac,Default:js,Image:rp,LineString:op,Polygon:ac,Text:hp};class ju{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=cp[t];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),i[t]=r}return r}}function $l(s,e,t,n){let i=s[e],r=s[e+1],o=0;for(let a=e+n;aZ[2]}else A=T>I;const M=Math.PI,b=[],K=S+n===e;e=S,p=0,y=v,f=s[e],g=s[e+1];let L;if(K){E(),L=Math.atan2(g-_,f-m),A&&(L+=L>0?-M:M);const Z=(I+T)/2,G=(F+R)/2;return b[0]=[Z,G,(w-r)/2,L,i],b}i=i.replace(/\n/g," ");for(let Z=0,G=i.length;Z0?-M:M),L!==void 0){let Ee=H-L;if(Ee+=Ee>M?-2*M:Ee<-M?2*M:0,Math.abs(Ee)>o)return null}L=H;const Q=Z;let le=0;for(;Z0&&s.push(` `,""),s.push(e,""),s}function fp(s,e,t){return t%2===0&&(s+=e),s}class gp{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_=Ce(),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 Bl: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?$r[l.justify]:qo(Array.isArray(e)?e[0]:e,l.textAlign||Is),d=i&&o.lineWidth?o.lineWidth:0,f=Array.isArray(e)?e:String(e).split(` `).reduce(dp,[]),{width:g,height:m,widths:_,heights:p,lineWidths:y}=ym(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 A=0,M=0,b=0,K=0,L;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)&&(dn[0]=S,fn[0]=S,dn[1]=v,Yt[1]=v,Yt[0]=S+T,jt[0]=Yt[0],jt[1]=v+R,fn[1]=jt[1]);let w;return u!==0?(w=ct(Ce(),n,i,1,1,u,-n,-i),fe(w,dn),fe(w,Yt),fe(w,jt),fe(w,fn),Ut(Math.min(dn[0],Yt[0],jt[0],fn[0]),Math.min(dn[1],Yt[1],jt[1],fn[1]),Math.max(dn[0],Yt[0],jt[0],fn[0]),Math.max(dn[1],Yt[1],jt[1],fn[1]),mi)):Ut(Math.min(S,S+T),Math.min(v,v+R),Math.max(S,S+T),Math.max(v,v+R),mi),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:E,drawImageH:x,originX:h,originY:c,declutterBox:{minX:mi[0],minY:mi[1],maxX:mi[2],maxY:mi[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,dn,Yt,jt,fn,o,a),xm(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=fe(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=qo(Array.isArray(e)?e[0]:e,r.textAlign||Is),c=$r[r.textBaseline||kr],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_&&Bt(n,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Gt(this.coordinates,0,this.coordinates.length,2,n,this.pixelCoordinates_),tu(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,A=0;const M=this.coordinateCache_,b=this.viewRotation_,K=Math.round(Math.atan2(-n[1],n[0])*1e12)/1e12,L={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:b},Z=this.instructions!=i||this.overlaps?0:200;let G,H,Q,le;for(;uZ&&(this.fill_(e),F=0),A>Z&&(e.stroke(),A=0),!F&&!A&&(e.beginPath(),y=NaN,E=NaN),++u;break;case X.CIRCLE:f=P[1];const je=c[f],Ee=c[f+1],it=c[f+2],ke=c[f+3],Lt=it-je,St=ke-Ee,st=Math.sqrt(Lt*Lt+St*St);e.moveTo(je+st,Ee),e.arc(je,Ee,st,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 Vs=P[3],Co=P[4],Ji=P[5];L.geometry=Vs,L.feature=G,u in M||(M[u]=[]);const bn=M[u];Ji?Ji(c,f,g,2,bn):(bn[0]=c[f],bn[1]=c[f+1],bn.length=2),h&&(h.zIndex=P[6]),Co(bn,L),++u;break;case X.DRAW_IMAGE:f=P[1],g=P[2],R=P[3],m=P[4],_=P[5];let dt=P[6];const Ft=P[7],ai=P[8],li=P[9],Qi=P[10];let Dn=P[11];const hi=P[12];let ci=P[13];p=P[14]||"declutter";const Ae=P[15];if(!R&&P.length>=20){S=P[19],v=P[20],w=P[21],I=P[22];const ft=this.drawLabelWithPointPlacement_(S,v,w,I);R=ft.label,P[3]=R;const On=P[23];m=(ft.anchorX-On)*this.pixelRatio,P[4]=m;const gt=P[24];_=(ft.anchorY-gt)*this.pixelRatio,P[5]=_,dt=R.height,P[6]=dt,ci=R.width,P[13]=ci}let Ro;P.length>25&&(Ro=P[25]);let So,Zs,Ks;P.length>17?(So=P[16],Zs=P[17],Ks=P[18]):(So=$n,Zs=null,Ks=null),Qi&&K?Dn+=b:!Qi&&!K&&(Dn-=b);let Qd=0;for(;f!Xr.includes(s));class Wu{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_=Ce(),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 gp(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,A=i-F%a,M=i-(F/a|0),b=r(T,R,A*A+M*M);if(b)return b}c.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(Nt);let _,p,y,E,x;for(_=m.length-1;_>=0;--_){const T=m[_].toString();for(y=this.executorsByZIndex_[T],p=Un.length-1;p>=0;--p)if(f=Un[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 Gt(a,0,8,2,e,a),a}isEmpty(){return Vn(this.executorsByZIndex_)}execute(e,t,n,i,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?lf:Nt),o=o||Un;const h=Un.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+Un.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(Nt);for(let n=0,i=t.length;n{r.draw(this.renderedContext_),r.clear()}),e[t[n]].length=0}}const Jo={};function mp(s){if(Jo[s]!==void 0)return Jo[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||sn)*this.pixelRatio_,lineJoin:a!==void 0?a:zi,lineWidth:(l!==void 0?l:As)*this.pixelRatio_,miterLimit:h!==void 0?h:ws,strokeStyle:Ot(n||Ps)}}}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:Ot(f||Je)}}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:Bi,lineDash:m||nn,lineDashOffset:_||sn,lineJoin:p!==void 0?p:zi,lineWidth:y!==void 0?y:As,miterLimit:E!==void 0?E:ws,strokeStyle:Ot(f||Ps)}}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:Iu,textAlign:u!==void 0?u:Is,textBaseline:d!==void 0?d:kr},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 ot=.5;function Vu(s,e,t,n,i,r,o,a,l){const h=l?so(i):i,c=s[0]*ot,u=s[1]*ot,d=we(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new pp(d,ot,i,null,o,a,l?Gs(pg(),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)),Tp(s,e,t,n,r,o,a),u}function Tp(s,e,t,n,i,r,o){const a=t.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(n,i);if(t.getRenderer())qu(s,l,t,e,o);else{const c=Ku[l.getType()];c(s,l,t,e,o,r)}}function qu(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]*ot,d=n[1]*ot;c.push(this.getRenderTransform(i,r,o,ot,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!yn(g,l)){let m=l[0];const _=ie(g);let p=0,y;for(;mg[2];)++p,y=_*p,c.push(this.getRenderTransform(i,r,o,ot,u,d,y).slice()),m-=_}this.hitDetectionImageData_=Vu(n,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,ka(r,this.renderedPixelRatio_),null)}t(Zu(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=xp);const _=h.center.slice(),p=rn(l,g*u),y=p.slice(),E=[p.slice()],x=c.getExtent();if(n.getWrapX()&&c.canWrapX()&&!yn(x,e.extent)){const b=ie(x),K=Math.max(ie(p)/2,b);p[0]=x[0]-K,p[2]=x[2]+K,il(_,c);const L=Xc(E[0],c);L[0]x[0]&&L[2]>x[2]&&E.push([L[0]-b,L[1],L[2]-b,L[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!e.declutter&&yn(this.wrappedRenderedExtent_,p))return Bt(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const T=new ju(Hu(u,d),p,u,d);let R;for(let b=0,K=E.length;b{let L;const Z=b.getStyleFunction()||t.getStyleFunction();if(Z&&(L=Z(b,u)),L){const G=this.renderFeature(b,S,L,T,R,this.getLayer().getDeclutter(),K);v=v&&!G}},I=so(p),F=n.getFeaturesInExtent(I);m&&F.sort(m);for(let b=0,K=F.length;b{if(m.getState()!==U.LOADED)return;this.image=m;const _=m.getPixelRatio(),p=Lp(m.getResolution())*t/_;this.renderedResolution=p,this.coordinateToVectorPixelTransform_=ct(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 G0 extends Hi{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 Fp(this)}}let Mp=!1;function bp(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=Mp,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 cc(s,e){return function(t,n,i,r,o){bp(s,e,t,n,i,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function Dp(s,e){return[[-1/0,-1/0,1/0,1/0]]}class $e extends Rt{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 $e(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?Op(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 Op(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 Qu(s,e,t,n){const i=[];let r=tt();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:el(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 ht extends Mn{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){ne(this.flatCoordinates,e),this.changed()}clone(){const e=new ht(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=ao(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,n,0),i=[n.length];break;case"MultiLineString":i=[],n.length=lu(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,n,0,i);break;case"Polygon":i=[],n.length=_l(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),n,0,i);break}return i&&(this.simplifiedGeometry_=new Qe(this.type_,n,i,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}}Qe.prototype.getFlatCoordinates=Qe.prototype.getOrientedFlatCoordinates;class Ba{constructor(e){this.rbush_=new Al(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 gn extends ut{constructor(e,t,n){super(e),this.feature=t,this.features=n}}class td extends ed{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_=Ts,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_=cc(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:Dp;const t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Ba:null,this.loadedExtentsRtree_=new Ba,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 Ze(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 gn(Le.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof Qe||(this.featureChangeKeys_[e]=[J(t,V.CHANGE,this.handleFeatureChange_,this),J(t,Ni.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 Qe){const r=this.idIndex_[i];r instanceof Qe?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(Se.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 gn(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 Qe||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 Qe||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(),Vn(this.nullGeometryFeatures_)||ne(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=Yc(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||Pn,this.featuresRtree_.forEachInExtent(l,function(h){if(t(h)){const c=h.getGeometry(),u=a;if(a=c instanceof Qe?0:c.closestPointXY(n,i,o,a),a{--this.loadingExtentsCount_,this.dispatchEvent(new gn(Le.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new gn(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(Hn(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(","),nd(s,i)}function Yp(s,e,t,n,i,r,o){r=Object.assign({REQUEST:"GetMap"},r);const a=e/t,l=[Eh(ie(s)/a,fc),Eh(be(s)/a,fc)];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 Xp(i,s,l,n,r)}function gc(s,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:za,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},s)}const pi=[0,0,0],_n=5;class id{constructor(e){this.minZoom=e.minZoom!==void 0?e.minZoom:0,this.resolutions_=e.resolutions,te(cf(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 Ul(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=_i(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=Cr(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=de(e);if(n){const i=D(n);i in this.tileGridForProjection||(this.tileGridForProjection[i]=t)}}}function ad(s,e){if(at){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 k0 extends od{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_=tt(),this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(e,t,n,i){const r=de(n),o=this.getProjection()||r;let a=this.getTileGrid();a||(a=this.getTileGridForProjection(o));const l=ks(e,r,o),h=Ga(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=rn(f,u*g,f));const m={QUERY_LAYERS:this.params_.LAYERS};Object.assign(m,gc(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:za,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),nd(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=en(Bu(e),o.length);a=o[l]}return Yp(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||za;this.v13_=jc(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=rn(o,r*a,o));const l=Object.assign({},gc(this.params_,"GetMap"));return this.getRequestUrl_(e,o,t,n,l)}}class ey extends od{constructor(e){e=e||{};const t=e.projection!==void 0?e.projection:"EPSG:3857",n=e.tileGrid!==void 0?e.tileGrid:Vp({extent:Yl(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 ty='© OpenStreetMap contributors.';class U0 extends ey{constructor(e){e=e||{};let t;e.attributions!==void 0?t=e.attributions:t=[ty];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();!at&&a instanceof HTMLImageElement&&(a.referrerPolicy="origin-when-cross-origin"),(e.tileLoadFunction||ad)(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=$e,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let n=t.dataProjection?de(t.dataProjection):this.readProjection(e);t.extent&&n&&n.getUnits()==="tile-pixels"&&(n=de(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 Qn(s,e,t){const n=t?de(t.featureProjection):null,i=t?de(t.dataProjection):null;let r=s;if(n&&i&&!Wn(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(qn(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;hld({...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 Qn(new Qe(n,n==="Polygon"?iy(t.flatCoordinates,t.ends,i):t.flatCoordinates,t.ends?.flat(),i,s.properties||{},s.id).enableSimplifyTransformed(),!1,e)}function Vl(s,e){if(!s)return null;if(Array.isArray(s)){const n=s.map(i=>Vl(i,e));return new He(n)}const t=ny[s.type];return Qn(new t(s.flatCoordinates,s.layout||"XY",s.ends),!1,e)}class sy extends Wl{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(lr(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(lr(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return $()}readFeaturesFromObject(e,t){return $()}readGeometry(e,t){return this.readGeometryFromObject(lr(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return $()}readProjection(e){return this.readProjectionFromObject(lr(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 lr(s){if(typeof s=="string"){const e=JSON.parse(s);return e||null}return s!==null?s:null}class B0 extends sy{constructor(e){e=e||{},super(),this.dataProjection=de(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=de(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=Zl(n.geometry);if(this.featureClass===Qe)return ld({geometry:i,id:n.id,properties:n.properties},t);const r=new $e;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&r.setGeometryName(n.geometry_name),r.setGeometry(Vl(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=Fr(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m"),t=this.dpi_||ls,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 Ty={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},_c={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};class Cy extends $u{constructor(e,t){super(e,t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=Ce(),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=fe(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()&&!yn(a,h.getTileCoordExtent(d.tileCoord))&&il(c,o);const f=D(i),g=h.getTileCoordExtent(d.wrappedTileCoord),m=Fn(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=Xe(h.getTileSize(h.getZForResolution(l,r.zDirection))),x=this.renderedRotation_,T=[this.getRenderTransform(h.getTileCoordCenter(d.wrappedTileCoord),l,0,ot,E[0]*ot,E[1]*ot,0)];y=Vu(E,T,p,i.getStyleFunction(),h.getTileCoordExtent(d.wrappedTileCoord),d.getReplayState(i).renderedResolution,x),d.hitDetectionImageData[f]=y}t(Zu(_,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,Xr,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 ro(Fo(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?_c[o].filter(T=>!Xr.includes(T)):_c[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(b=>b.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 A=e,M;if(F){M=new Bl,A=M.getContext();for(let b=0,K=_.length;b{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 Vt={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"},Oe={UNSIGNED_BYTE:Sy,UNSIGNED_SHORT:vy,UNSIGNED_INT:wy,FLOAT:cd},Vr={};function yc(s){return"shared/"+s}let xc=0;function Fy(){const s="unique/"+xc;return xc+=1,s}function My(s){let e=Vr[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:Py(t)},Vr[s]=e}return e.users+=1,e.context}function by(s){const e=Vr[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 Vr[s]}class Dy extends bs{constructor(e){super(),e=e||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=e.canvasCacheKey?yc(e.canvasCacheKey):Fy(),this.gl_=My(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const t=this.gl_.canvas;t.addEventListener(cr.LOST,this.boundHandleWebGLContextLost_),t.addEventListener(cr.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=Ce(),this.offsetScaleMatrix_=Ce(),this.tmpMat4_=hd(),this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],e.uniforms&&this.setUniforms(e.uniforms),this.postProcessPasses_=e.postProcesses?e.postProcesses.map(n=>new pc({webGlContext:this.gl_,scaleRatio:n.scaleRatio,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,uniforms:n.uniforms})):[new pc({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_===yc(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(cr.LOST,this.boundHandleWebGLContextLost_),e.removeEventListener(cr.RESTORED,this.boundHandleWebGLContextRestored_),by(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,Xa(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 ct(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(Me.PRECOMPOSE)){const i=new ms(Me.PRECOMPOSE,void 0,t,e);n.dispatchEvent(i)}}dispatchPostComposeEvent(e,t){const n=this.getLayer();if(n.hasListener(Me.POSTCOMPOSE)){const i=new ms(Me.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(wn).join(", ")})`}function Rr(s){const e=Ct(s),t=e.length>3?e[3]:1;return ql([e[0]/255,e[1]/255,e[2]/255,t])}function ky(s){const e=Xe(s);return ql(e)}const ra={};let Uy=0;function Ms(s){return s in ra||(ra[s]=Uy++),ra[s]}function qt(s){return wn(Ms(s))}function Jl(s){return"u_var_"+s}function dd(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const oa="getBandValue",By="u_paletteTextures",fd="featureId",gd="geometryType",Ya=-9999999;function zy(s,e,t,n){const i=De(s,e,t);return Ql(i,e,n)}function se(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 Dt(e.type,ve)&&(r=`(${r} > 0.0)`),r},[C.Id]:s=>(s.featureId=!0,"a_"+fd),[C.GeometryType]:s=>(s.geometryType=!0,"a_"+gd),[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=Jl(n);return Dt(e.type,ve)&&(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} != ${wn(Ya)})`},[C.Resolution]:()=>"u_resolution",[C.Zoom]:()=>"u_zoom",[C.Time]:()=>"u_time",[C.Any]:se(s=>`(${s.join(" || ")})`),[C.All]:se(s=>`(${s.join(" && ")})`),[C.Not]:se(([s])=>`(!${s})`),[C.Equal]:se(([s,e])=>`(${s} == ${e})`),[C.NotEqual]:se(([s,e])=>`(${s} != ${e})`),[C.GreaterThan]:se(([s,e])=>`(${s} > ${e})`),[C.GreaterThanOrEqualTo]:se(([s,e])=>`(${s} >= ${e})`),[C.LessThan]:se(([s,e])=>`(${s} < ${e})`),[C.LessThanOrEqualTo]:se(([s,e])=>`(${s} <= ${e})`),[C.Multiply]:se(s=>`(${s.join(" * ")})`),[C.Divide]:se(([s,e])=>`(${s} / ${e})`),[C.Add]:se(s=>`(${s.join(" + ")})`),[C.Subtract]:se(([s,e])=>`(${s} - ${e})`),[C.Clamp]:se(([s,e,t])=>`clamp(${s}, ${e}, ${t})`),[C.Mod]:se(([s,e])=>`mod(${s}, ${e})`),[C.Pow]:se(([s,e])=>`pow(${s}, ${e})`),[C.Abs]:se(([s])=>`abs(${s})`),[C.Floor]:se(([s])=>`floor(${s})`),[C.Ceil]:se(([s])=>`ceil(${s})`),[C.Round]:se(([s])=>`floor(${s} + 0.5)`),[C.Sin]:se(([s])=>`sin(${s})`),[C.Cos]:se(([s])=>`cos(${s})`),[C.Atan]:se(([s,e])=>e!==void 0?`atan(${s}, ${e})`:`atan(${s})`),[C.Sqrt]:se(([s])=>`sqrt(${s})`),[C.Match]:se(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]:se(([s,e,t])=>`(${s} >= ${e} && ${s} <= ${t})`),[C.Interpolate]:se(([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]:se(([s,...e],t)=>{const n=Gy("in",t),i=[];for(let r=0;r`vec${s.length}(${s.join(", ")})`),[C.Color]:se(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]:se(([s,e,t],n)=>{if(!(oa 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 wn(s.value);if((s.type&ve)>0)return s.value.toString();if((s.type&Ie)>0)return qt(s.value.toString());if((s.type&_e)>0)return Rr(s.value);if((s.type&nt)>0)return ql(s.value);if((s.type&yt)>0)return ky(s.value);throw new Error(`Unexpected expression ${s.value} (expected type ${Pi(e)})`)}function Xy(){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 Ec=.985;function W(s,e,t){const n=Dl();return zy(e,t,n,s)}function Yy(s){const e=Ct(s),t=e[0]*256,n=e[1],i=e[2]*256,r=Math.round(e[3]*255);return[t+n,i+r]}const jy=`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 eh(s){return s===_e||s===yt?2:s===nt?4:1}function ja(s){const e=eh(s);return e>1?`vec${e}`:"float"}function _d(s,e){for(const t in e.variables){const n=e.variables[t],i=Jl(n.name);let r=ja(n.type);n.type===_e&&(r="vec4"),s.addUniform(i,r)}for(const t in e.properties){const n=e.properties[t],i=ja(n.type),r=`a_prop_${n.name}`;n.type===_e?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 md(s,e){const t={};for(const n in s.variables){const i=s.variables[n],r=Jl(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===_e){const a=[...Ct(o||"#eee")];return a[0]/=255,a[1]/=255,a[2]/=255,a[3]??=1,a}return typeof o=="string"?Ms(o):o}}return t}function pd(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===_e?Yy([...Ct(o||"#eee")]):typeof o=="string"?Ms(o):typeof o=="boolean"?o?1:0:o};e[`prop_${n.name}`]={size:eh(n.type),callback:i}}return e}const yi=`#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 ${jy} `,xi=Xy();class yd{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${wn(xi["circle-radius"])} + ${wn(xi["circle-stroke-width"]*.5)})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=Rr(xi["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_=wn(xi["stroke-width"]),this.strokeColorExpression_=Rr(xi["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=qt("round"),this.strokeJoinExpression_=qt("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=Rr(xi["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_?`${yi} ${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_?`${yi} ${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_?`${yi} ${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) > ${Ec} || 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_?`${yi} ${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) > ${Ec}) { // 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 == ${qt("butt")}) { return buttCapDistanceField(point, start, end); } else if (capType == ${qt("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 == ${qt("bevel")}) { return bevelJoinField(point, start, end, width, joinAngle); } else if (joinType == ${qt("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_?`${yi} ${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_?`${yi} ${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 Zr{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(Wy(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(Vy(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 Zr;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 Zr:t}}function Wy(s,e){return e===2?s:s.filter((t,n)=>n%e<2)}function Vy(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 Zy(){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 aa={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function Ky(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 Hy(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 th(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===Ya&&console.warn('The "has" operator might return false positives.'),l===void 0?l=Ya: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 po(s){return Object.keys(s).reduce((e,t)=>e+(s[t].size||1),0)}function qy(s,e,t,n){const i=(2+po(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 nh(s,e,t,n){if(`${n}radius`in s&&n!=="icon-"){let i=W(t,s[`${n}radius`],N);if(`${n}radius2`in s){const r=W(t,s[`${n}radius2`],N);i=`max(${i}, ${r})`}`${n}stroke-width`in s&&(i=`(${i} + ${W(t,s[`${n}stroke-width`],N)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${i} * 2. + 0.5)`)}if(`${n}scale`in s){const i=W(t,s[`${n}scale`],yt);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${i}`)}`${n}displacement`in s&&e.setSymbolOffsetExpression(W(t,s[`${n}displacement`],nt)),`${n}rotation`in s&&e.setSymbolRotationExpression(W(t,s[`${n}rotation`],N)),`${n}rotate-with-view`in s&&e.setSymbolRotateWithView(!!s[`${n}rotate-with-view`])}function xd(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 ih(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 sh(s,e,t,n,i){let r=W(t,s[`${e}offset`],yt);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 ex(s,e,t,n){n.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) { return length(point) - radius; }`,nh(s,e,n,"circle-");let i=null;"circle-opacity"in s&&(i=W(n,s["circle-opacity"],N));let r="coordsPx";"circle-scale"in s&&(r=`coordsPx / ${W(n,s["circle-scale"],yt)}`);let o=null;"circle-fill-color"in s&&(o=W(n,s["circle-fill-color"],_e));let a=null;"circle-stroke-color"in s&&(a=W(n,s["circle-stroke-color"],_e));let l=W(n,s["circle-radius"],N),h=null;"circle-stroke-width"in s&&(h=W(n,s["circle-stroke-width"],N),l=`(${l} + ${h} * 0.5)`);const c=`circleDistanceField(${r}, ${l})`,u=xd(c,o,a,h,i);e.setSymbolColorExpression(u)}function tx(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; }`,nh(s,e,n,"shape-");let i=null;"shape-opacity"in s&&(i=W(n,s["shape-opacity"],N));let r="coordsPx";"shape-scale"in s&&(r=`coordsPx / ${W(n,s["shape-scale"],yt)}`);let o=null;"shape-fill-color"in s&&(o=W(n,s["shape-fill-color"],_e));let a=null;"shape-stroke-color"in s&&(a=W(n,s["shape-stroke-color"],_e));let l=null;"shape-stroke-width"in s&&(l=W(n,s["shape-stroke-width"],N));const h=W(n,s["shape-points"],N);let c="0.";"shape-angle"in s&&(c=W(n,s["shape-angle"],N));let u,d=W(n,s["shape-radius"],N);if(l!==null&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in s){let g=W(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=xd(u,o,a,l,i);e.setSymbolColorExpression(f)}function nx(s,e,t,n){let i="vec4(1.0)";"icon-color"in s&&(i=W(n,s["icon-color"],_e)),"icon-opacity"in s&&(i=`${i} * vec4(1.0, 1.0, 1.0, ${W(n,s["icon-opacity"],N)})`);const r=Kr(s["icon-src"]),o=ih(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(${W(n,s["icon-width"],N)}, ${W(n,s["icon-height"],N)})`),"icon-offset"in s&&"icon-size"in s){const a=W(n,s["icon-size"],nt),l=e.getSymbolSizeExpression();e.setSymbolSizeExpression(a);const h=sh(s,"icon-",n,"v_quadSizePx",a);e.setTextureCoordinateExpression(`(vec4((${h}).xyxy) + vec4(0., 0., ${a})) / (${l}).xyxy`)}if(nh(s,e,n,"icon-"),"icon-anchor"in s){const a=W(n,s["icon-anchor"],nt);let l="1.0";"icon-scale"in s&&(l=W(n,s["icon-scale"],yt));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 ix(s,e,t,n){if("stroke-color"in s&&e.setStrokeColorExpression(W(n,s["stroke-color"],_e)),"stroke-pattern-src"in s){const i=Kr(s["stroke-pattern-src"]),r=ih(s,e,t,"stroke-pattern-",i);let o=r,a="vec2(0.)";"stroke-pattern-offset"in s&&"stroke-pattern-size"in s&&(o=W(n,s["stroke-pattern-size"],nt),a=sh(s,"stroke-pattern-",n,r,o));let l="0.";"stroke-pattern-spacing"in s&&(l=W(n,s["stroke-pattern-spacing"],N));let h="0.";"stroke-pattern-start-offset"in s&&(h=W(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(W(n,s["stroke-width"],N)),"stroke-offset"in s&&e.setStrokeOffsetExpression(W(n,s["stroke-offset"],N)),"stroke-line-cap"in s&&e.setStrokeCapExpression(W(n,s["stroke-line-cap"],Ie)),"stroke-line-join"in s&&e.setStrokeJoinExpression(W(n,s["stroke-line-join"],Ie)),"stroke-miter-limit"in s&&e.setStrokeMiterLimitExpression(W(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 == ${qt("square")}) { distanceSegment -= lineWidth * 0.5; } else if (capType == ${qt("round")}) { distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5); } return distanceSegment; }`;let i=s["stroke-line-dash"].map(g=>W(n,g,N));i.length%2===1&&(i=[...i,...i]);let r="0.";"stroke-line-dash-offset"in s&&(r=W(n,s["stroke-line-dash-offset"],N));const a=`dashDistanceField_${Kr(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 sx(s,e,t,n){if("fill-color"in s&&e.setFillColorExpression(W(n,s["fill-color"],_e)),"fill-pattern-src"in s){const i=Kr(s["fill-pattern-src"]),r=ih(s,e,t,"fill-pattern-",i);let o=r,a="vec2(0.)";"fill-pattern-offset"in s&&"fill-pattern-size"in s&&(o=W(n,s["fill-pattern-size"],nt),a=sh(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 Tc(s,e,t){const n=dd(),i=new yd,r={};if("icon-src"in s?nx(s,i,r,n):"shape-points"in s?tx(s,i,r,n):"circle-radius"in s&&ex(s,i,r,n),ix(s,i,r,n),sx(s,i,r,n),t){const l=W(n,t,ve);i.setFragmentDiscardExpression(`!${l}`)}const o={};function a(l,h,c,u){if(!n[l])return;const d=ja(c),f=eh(c);i.addAttribute(`a_${h}`,d),o[h]={size:f,callback:u}}return a("geometryType",gd,Ie,l=>Ms(Ol(l.getGeometry()))),a("featureId",fd,Ie|N,l=>{const h=l.getId()??null;return typeof h=="string"?Ms(h):h}),_d(i,n),{builder:i,attributes:{...o,...pd(n)},uniforms:{...r,...md(n,e)}}}const rx=[];let la;function ox(){return la||(la=Zy()),la}let ax=0;const mt={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 lx{constructor(e,t,n,i){this.helper_,this.hitDetectionEnabled_=!!i,this.styleShaders=hx(e,t),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return Ky(this.ref,rx)},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:Oe.FLOAT}));return r.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:r.builder.getFillVertexShader(),fragmentShader:r.builder.getFillFragmentShader(),attributesDesc:[{name:mt.POSITION,size:2,type:Oe.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),r.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:r.builder.getStrokeVertexShader(),fragmentShader:r.builder.getStrokeFragmentShader(),attributesDesc:[{name:mt.LOCAL_POSITION,size:2,type:Oe.FLOAT}],instancedAttributesDesc:[{name:mt.SEGMENT_START,size:2,type:Oe.FLOAT},{name:mt.MEASURE_START,size:1,type:Oe.FLOAT},{name:mt.SEGMENT_END,size:2,type:Oe.FLOAT},{name:mt.MEASURE_END,size:1,type:Oe.FLOAT},{name:mt.JOIN_ANGLES,size:2,type:Oe.FLOAT},{name:mt.DISTANCE_LOW,size:1,type:Oe.FLOAT},{name:mt.DISTANCE_HIGH,size:1,type:Oe.FLOAT},{name:mt.ANGLE_TANGENT_SUM,size:1,type:Oe.FLOAT},...a],instancePrimitiveVertexCount:6}),r.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:r.builder.getSymbolVertexShader(),fragmentShader:r.builder.getSymbolFragmentShader(),attributesDesc:[{name:mt.LOCAL_POSITION,size:2,type:Oe.FLOAT}],instancedAttributesDesc:[{name:mt.POSITION,size:2,type:Oe.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=Rs(Ce(),t);return{polygonBuffers:i,lineStringBuffers:r,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(e,t){const n=this.hasFill_?Qy(e.polygonBatch,new Float32Array(0),this.customAttributes_,t):null,i=this.hasStroke_?Jy(e.lineStringBatch,new Float32Array(0),this.customAttributes_,t):null,r=this.hasSymbol_?qy(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=ax++;let r;switch(t){case"Polygon":r=aa.GENERATE_POLYGON_BUFFERS;break;case"LineString":r=aa.GENERATE_LINE_STRING_BUFFERS;break;case"Point":r=aa.GENERATE_POINT_BUFFERS;break}const o={id:i,type:r,renderInstructions:e.buffer,renderInstructionsTransform:n,customAttributesSize:po(this.customAttributes_)},a=ox();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 ia(Kl,na).fromArrayBuffer(u.indicesBuffer),f=new ia(Wr,na).fromArrayBuffer(u.vertexAttributesBuffer),g=new ia(Wr,na).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 hx(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=>Tc(c,e,l));n.push(...h)}return n}return"builder"in t[0]?t:t.map(n=>Tc(n,e,null))}const bt=new Uint8Array(4);class cx{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){Bt(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 ux(s,e){const t=s.viewState.projection,i=e.getSource().getWrapX()&&t.canWrapX(),r=t.getExtent(),o=s.extent,a=i?ie(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 Ei={...Vt,RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",GLOBAL_ALPHA:"u_globalAlpha"};class dx extends Hl{constructor(e,t){const n={[Ei.RENDER_EXTENT]:[0,0,0,0],[Ei.PATTERN_ORIGIN]:[0,0],[Ei.GLOBAL_ALPHA]:1};super(e,{uniforms:n,postProcesses:t.postProcesses}),this.hitDetectionEnabled_=!t.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=tt(),this.currentTransform_=Ce(),this.tmpCoords_=[0,0],this.tmpTransform_=Ce(),this.tmpMat4_=hd(),this.currentFrameStateTransform_=Ce(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(t),this.batch_=new Zr,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 lx(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 cx(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){tu(this.tmpTransform_,this.currentFrameStateTransform_),ro(this.tmpTransform_,e),this.helper.setUniformMatrixValue(Ei.PROJECTION_MATRIX,Xa(this.tmpMat4_,this.tmpTransform_)),Rs(this.tmpTransform_,this.tmpTransform_),this.helper.setUniformMatrixValue(Ei.SCREEN_TO_WORLD_MATRIX,Xa(this.tmpMat4_,this.tmpTransform_)),this.tmpCoords_[0]=0,this.tmpCoords_[1]=0,Rs(this.tmpTransform_,e),fe(this.tmpTransform_,this.tmpCoords_),this.helper.setUniformFloatVec2(Ei.PATTERN_ORIGIN,this.tmpCoords_)}renderFrame(e){const t=this.helper.getGL();this.preRender(t,e);const[n,i,r]=ux(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=!Hn(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_),nu(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 Wt={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},fx=["#00f","#0ff","#0f0","#ff0","#f00"];class X0 extends Hi{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(Wt.GRADIENT,this.handleGradientChanged_),this.setGradient(e.gradient?e.gradient:fx),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(Wt.BLUR)}getGradient(){return this.get(Wt.GRADIENT)}getRadius(){return this.get(Wt.RADIUS)}handleGradientChanged_(){this.gradient_=gx(this.getGradient())}setBlur(e){const t=this.get(Wt.BLUR);if(this.set(Wt.BLUR,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setGradient(e){this.set(Wt.GRADIENT,e)}setRadius(e){const t=this.get(Wt.RADIUS);if(this.set(Wt.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 yd,t=dd(),n=W(t,this.filter_,ve);let i=W(t,this.getRadius(),N),r=W(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?ge(f,0,1):1}},l="a_prop_weight",e.addAttribute("a_prop_weight","float")}else{const u=["clamp",this.weight_,0,1];l=W(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}`),_d(e,t);const h=pd(t),c=md(t,this.styleVariables_);return new dx(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 gx(s){const n=we(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 Ii(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 ur={index:-1,endIndex:NaN,closestTargetDistance:1/0};function Ed(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=Ii(h.coordinates,l),d=t.getPixelFromCoordinate(u),f=t.getPixelFromCoordinate(e.startCoord);vi(d,f)>n&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(fo){const l=Ii(s,n),h=Ii(s,i);return fr(l,h)}let a=0;if(n{const l=o||new mo([NaN,NaN]),h=pe(r[0]),c=Gi(h,pe(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;i==="Point"?r=lt:i==="LineString"?r=ht: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 Xl({source:new td({useSpatialIndex:!1,wrapX:e.wrapX?e.wrapX:!1}),style:e.style?e.style:px(),updateWhileInteracting:!0}),this.geometryName_=e.geometryName,this.condition_=e.condition?e.condition:wl,this.freehandCondition_,e.freehand?this.freehandCondition_=Li:this.freehandCondition_=e.freehandCondition?e.freehandCondition:Nr,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSource_=e.traceSource||e.source||null,this.addChangeListener(Fa.ACTIVE,this.updateState_)}setTrace(e){let t;e?e===!0?t=Li:t=e:t=Or,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:Nr}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 Zt(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=ze([n,i]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=Td(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(Rn(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(vi(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 oi([t])):this.type_==="MultiLineString"?e.setGeometry(new on([t])):this.type_==="MultiPolygon"&&e.setGeometry(new An([t])),this.dispatchEvent(new mr(_r.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 mr(_r.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 Sd&&r.getStyle()&&r.getFeatures().getArray().lastIndexOf(e)!==-1){e.setStyle(r.getStyle());return}}const n=D(e);e.setStyle(xr[n]),delete xr[n]}removeFeatureLayerAssociation_(e){delete this.featureLayerAssociation_[D(e)]}selectFeatureInternal_(e,t,n){if(!(e instanceof $e)||!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 yr(pr.SELECT,[n],[],void 0)),!!n}removeFeatureInternal_(e,t){const n=this.getFeatures();if(!(!(e instanceof $e)||!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 yr(pr.SELECT,[],[t],void 0)),!!t}toggleFeature(e){this.deselectFeature(e)||this.selectFeature(e)}clearSelection(){ei(this.featureLayerAssociation_);const e=this.getFeatures(),t=e.getArray().slice();e.clear(),t.length!==0&&this.dispatchEvent(new yr(pr.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 yr(pr.SELECT,h,l,e)),!0}}function xx(){const s=Nl();return ne(s.Polygon,s.LineString),ne(s.GeometryCollection,s.LineString),function(e){return e.getGeometry()?s[e.getGeometry().getType()]:null}}const Cc=0,ps=1,Rc=[0,0,0,0],bi=[],ca={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"};function ua(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 da extends ut{constructor(e,t,n){super(e),this.features=t,this.mapBrowserEvent=n}}class W0 extends si{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:Tu,this.defaultDeleteCondition_=function(n){return o_(n)&&xu(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 Ba,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Xl({source:new td({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:Tx(),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 Ze(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(Se.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Se.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=Or,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 Ze;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();ua(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=ze([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=Td(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();ua(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(Rn(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();ua(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];vi(tl(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(fs(o),a);let h=r;this.rBush_.update(h.getExtent(),l)}else this.rBush_.update(ze(n.segment),n)}return this.featuresBeingModified_&&(this.toggleTraceState_(e),this.dispatchEvent(new da(ca.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 Sc(e,a)-Sc(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 lt(Jn(c.getCoordinates())));const u=c||l.getGeometry();if(u&&u.getType()==="Point"&&l instanceof $e&&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=wt(fs(e,Rc)),l=t.getView().getResolution()*this.pixelTolerance_,h=so(rn(a,l,Rc));r=this.rBush_.getInExtent(h)}if(r&&r.length>0){const a=r.sort(i)[0],l=a.segment;let h=vc(e,a);const c=t.getPixelFromCoordinate(h);let u=vi(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===ps)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=Gi(c,f),_=Gi(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(ze([e])).some(({segment:n})=>Ve(n[0],e)||Ve(n[1],e))}removePoint(e){if(e&&(e=pe(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 da(ca.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(ze(_.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(ze([e])).some(({segment:n})=>!(Ve(n[0],e)||Ve(n[1],e)))}insertPoint(e){const t=e?pe(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||Bt(r.depth,n))&&r.index>t&&(r.index+=i)})}}function Ex(s,e){return s.index-e.index}function Sc(s,e,t){const n=e.geometry;if(n.getType()==="Circle"){let r=n;if(e.index===ps){const o=Gi(r.getCenter(),pe(s)),a=Math.sqrt(o)-r.getRadius();return a*a}}const i=pe(s);return bi[0]=pe(e.segment[0]),bi[1]=pe(e.segment[1]),Df(i,bi)}function vc(s,e,t){const n=e.geometry;if(n.getType()==="Circle"&&e.index===ps)return Jn(n.getClosestPoint(pe(s)));const i=pe(s);return bi[0]=pe(e.segment[0]),bi[1]=pe(e.segment[1]),Jn(tl(i,bi))}function Tx(){const s=Nl();return function(e,t){return s.Point}}class Cx extends Wl{constructor(){super()}getType(){return"text"}readFeature(e,t){return this.readFeatureFromText(Er(e),this.adaptOptions(t))}readFeatureFromText(e,t){return $()}readFeatures(e,t){return this.readFeaturesFromText(Er(e),this.adaptOptions(t))}readFeaturesFromText(e,t){return $()}readGeometry(e,t){return this.readGeometryFromText(Er(e),this.adaptOptions(t))}readGeometryFromText(e,t){return $()}readProjection(e){return this.readProjectionFromText(Er(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 Er(s){return typeof s=="string"?s:""}const Rx={POINT:lt,LINESTRING:ht,POLYGON:qe,MULTIPOINT:oi,MULTILINESTRING:on,MULTIPOLYGON:An},vd="EMPTY",wd="Z",Pd="M",Sx="ZM",oe={START:0,TEXT:1,LEFT_PAREN:2,RIGHT_PAREN:3,NUMBER:4,COMMA:5,EOF:6},vx={Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION",Circle:"CIRCLE"};class wx{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 Px{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===wd?e="XYZ":n===Pd?e="XYM":n===Sx&&(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+" "+vd:i+"("+n+")"}const wc="http://www.w3.org/2001/XMLSchema-instance";function Ws(s,e){return yo().createElementNS(s,e)}function ln(s,e){return Fd(s,e,[]).join("")}function Fd(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)Fd(n,e,t)}return t}function Sn(s){return"documentElement"in s}function vn(s){return new DOMParser().parseFromString(s,"application/xml")}function Pc(s,e){return(function(t,n){const i=s.call(e??this,t,n);if(i!==void 0){const r=n[n.length-1];ne(r,i)}})}function pn(s,e){return(function(t,n){const i=s.call(e??this,t,n);i!==void 0&&n[n.length-1].push(i)})}function oh(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 Y(s,e){return(function(t,n,i){s.call(this,t,n,i),i[i.length-1].node.appendChild(t)})}function hn(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 Tt=hn();function At(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=vn(e);return this.readFeaturesFromDocument(n,t)}return Sn(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&&ne(n,this.readFeaturesFromNode(i,t));return n}readFeaturesFromNode(e,t){return $()}readGeometry(e,t){if(!e)return null;if(typeof e=="string"){const n=vn(e);return this.readGeometryFromDocument(n,t)}return Sn(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=vn(e);return this.readProjectionFromDocument(t)}return Sn(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=ln(s,!1);return Gx(e)}function Gx(s){const e=/^\s*(true|1)|(false|0)\s*$/.exec(s);if(e)return e[1]!==void 0||!1}function ye(s){const e=ln(s,!1);return kx(e)}function kx(s){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(s);if(e)return parseFloat(e[1])}function Ye(s){return ln(s,!1).trim()}function $i(s,e){pt(s,e?"1":"0")}function Ux(s,e){s.appendChild(yo().createCDATASection(e))}function Yn(s,e){const t=e.toPrecision();s.appendChild(yo().createTextNode(t))}const Bx=/^\s/,zx=/\s$/,$x=/(\n|\t|\r|<|&| {2})/;function pt(s,e){typeof e=="string"&&(Bx.test(e)||zx.test(e)||$x.test(e))?e.split("]]>").forEach((t,n,i)=>{n0&&(t=">"+t),Ux(s,t)}):s.appendChild(yo().createTextNode(e))}const cn=["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"],Xx="http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd",Ic={fraction:"fraction",pixels:"pixels",insetPixels:"pixels"},Yx=z(k,{ExtendedData:Wd,Region:Vd,MultiGeometry:O(Xd,"geometry"),LineString:O(zd,"geometry"),LinearRing:O($d,"geometry"),Point:O(Yd,"geometry"),Polygon:O(jd,"geometry"),Style:O(hh),StyleMap:wE,address:O(Ye),description:O(Ye),name:O(Ye),open:O(Ln),phoneNumber:O(Ye),styleUrl:O(Nd),visibility:O(Ln)},z(cn,{MultiTrack:O(fE,"geometry"),Track:O(Bd,"geometry")})),jx=z(k,{ExtendedData:Wd,Region:Vd,Link:kE,address:O(Ye),description:O(Ye),name:O(Ye),open:O(Ln),phoneNumber:O(Ye),visibility:O(Ln)}),Wx=z(k,{href:O(Od)}),Vx=z(k,{Altitude:O(ye),Longitude:O(ye),Latitude:O(ye),Tilt:O(ye),AltitudeMode:O(Ye),Heading:O(ye),Roll:O(ye)}),Md=z(k,{LatLonAltBox:FE,Lod:bE}),Zx=z(k,["Document","Placemark"]),Kx=z(k,{Document:Y(WE),Placemark:Y(Hd)});let Di,Sr=null,Wa,ys,xs,Es,Hr,Va=null,ah,Za=null,Ka,jn=null,Ac=null,Ha=null;function qr(s){return 32/Math.min(s[0],s[1])}function Hx(){Di=[255,255,255,1],Sr=new It({color:Di}),Wa=[20,2],ys="pixels",xs="pixels",Es=[64,64],Hr="https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png",Va=new Ki({anchor:Wa,anchorOrigin:"bottom-left",anchorXUnits:ys,anchorYUnits:xs,crossOrigin:"anonymous",rotation:0,scale:qr(Es),size:Es,src:Hr}),ah="NO_IMAGE",Za=new kt({color:Di,width:1}),Ka=new kt({color:[51,51,51,1],width:2}),jn=new Xs({font:"bold 16px Helvetica",fill:Sr,stroke:Ka,scale:.8}),Ac=new Ne({fill:Sr,image:Va,text:jn,stroke:Za,zIndex:0}),Ha=[Ac]}let Tr;function qx(s){return s}class Z0 extends Nx{constructor(e){super(),e=e||{},Ha||Hx(),this.dataProjection=de("EPSG:4326"),this.defaultStyle_=e.defaultStyle?e.defaultStyle:Ha,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:qx,this.supportedMediaTypes=["application/vnd.google-earth.kml+xml"]}readDocumentOrFolder_(e,t){const n=z(k,{Document:Pc(this.readDocumentOrFolder_,this),Folder:Pc(this.readDocumentOrFolder_,this),Placemark:pn(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},Yx,e,t,this);if(!n)return;const i=new $e,r=e.getAttribute("id");r!==null&&i.setId(r);const o=t[0],a=n.geometry;if(a&&Qn(a,!1,o),i.setGeometry(a),delete n.geometry,this.extractStyles_){const l=n.Style,h=n.styleUrl,c=Qx(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=hh.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=kd.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&&ne(n,o)}return n}return[]}readName(e){if(e){if(typeof e=="string"){const t=vn(e);return this.readNameFromDocument(t)}return Sn(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 Ye(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=vn(e);ne(t,this.readNetworkLinksFromDocument(n))}else Sn(e)?ne(t,this.readNetworkLinksFromDocument(e)):ne(t,this.readNetworkLinksFromNode(e));return t}readNetworkLinksFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&ne(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({},jx,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")&&ne(t,this.readNetworkLinksFromNode(n))}return t}readRegion(e){const t=[];if(typeof e=="string"){const n=vn(e);ne(t,this.readRegionFromDocument(n))}else Sn(e)?ne(t,this.readRegionFromDocument(e)):ne(t,this.readRegionFromNode(e));return t}readRegionFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&ne(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({},Md,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")&&ne(t,this.readRegionFromNode(n))}return t}readCamera(e){const t=[];if(typeof e=="string"){const n=vn(e);ne(t,this.readCameraFromDocument(n))}else Sn(e)?ne(t,this.readCameraFromDocument(e)):ne(t,this.readCameraFromNode(e));return t}readCameraFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType===Node.ELEMENT_NODE&&ne(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({},Vx,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")&&ne(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",cn[0]),n.setAttributeNS(i,"xmlns:xsi",wc),n.setAttributeNS(wc,"xsi:schemaLocation",Xx);const r={node:n},o={};e.length>1?o.Document=e:e.length==1&&(o.Placemark=e[0]);const a=Zx[n.namespaceURI],l=At(o,a);return Re(r,Kx,Tt,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()||jn.getFont()),r.setScale(r.getScale()||jn.getScale()),r.setFill(r.getFill()||jn.getFill()),r.setStroke(r.getStroke()||Ka)):r=jn.clone(),r.setText(e),r.setOffsetX(t[0]),r.setOffsetY(t[1]),r.setTextAlign(n),new Ne({image:i,text:r})}function Qx(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 He)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)&&(Tr||(Tr=document.createElement("textarea")),Tr.innerHTML=l,l=Tr.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 He(h));const d=new Ne({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 xo(s){const e=ln(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 Dd(s){let e=ln(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 Od(s){const e=ln(s,!1).trim();let t=s.baseURI;return(!t||t=="about:blank")&&(t=window.location.href),t?new URL(e,t).href:e}function Nd(s){const e=ln(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 eE(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:Ic[e],y:parseFloat(s.getAttribute("y")),yunits:Ic[t],origin:n}}function Gd(s){return ye(s)}const tE=z(k,{Pair:vE});function kd(s,e){return ce(void 0,tE,s,e,this)}const nE=z(k,{Icon:O(mE),color:O(xo),heading:O(ye),hotSpot:O(eE),scale:O(Gd)});function iE(s,e){const t=ce({},nE,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=Hr);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=Wa,h=ys,c=xs):o.includes("arrow-reverse")?(l=[54,42],h=ys,c=xs):o.includes("paddle")&&(l=[32,1],h=ys,c=xs));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=Ke(x));const T=t.scale,R=t.color;if(r){o==Hr&&(_=Es);const S=new Ki({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 A=S.getImageState();if(!(A===U.IDLE||A===U.LOADING)){const M=S.getSize();if(M&&M.length==2){const b=qr(M);S.setScale(v*b)}S.unlistenImageChange(F)}};S.listenImageChange(F),I===U.IDLE&&S.load()}}else if(w.length==2){const I=qr(w);S.setScale(v*I)}n.imageStyle=S}else n.imageStyle=ah}const sE=z(k,{color:O(xo),scale:O(Gd)});function rE(s,e){const t=ce({},sE,s,e);if(!t)return;const n=e[e.length-1],i=new Xs({fill:new It({color:"color"in t?t.color:Di}),scale:t.scale});n.textStyle=i}const oE=z(k,{color:O(xo),width:O(ye)});function aE(s,e){const t=ce({},oE,s,e);if(!t)return;const n=e[e.length-1],i=new kt({color:"color"in t?t.color:Di,width:"width"in t?t.width:1});n.strokeStyle=i}const lE=z(k,{color:O(xo),fill:O(Ln),outline:O(Ln)});function hE(s,e){const t=ce({},lE,s,e);if(!t)return;const n=e[e.length-1],i=new It({color:"color"in t?t.color:Di});n.fillStyle=i;const r=t.fill;r!==void 0&&(n.fill=r);const o=t.outline;o!==void 0&&(n.outline=o)}const cE=z(k,{coordinates:oh(Dd)});function Ud(s,e){return ce(null,cE,s,e)}function uE(s,e){const n=e[e.length-1].coordinates,i=ln(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 dE=z(cn,{Track:pn(Bd)});function fE(s,e){const t=ce([],dE,s,e);if(t)return new on(t)}const gE=z(k,{when:UE},z(cn,{coord:uE}));function Bd(s,e){const t=ce({coordinates:[],whens:[]},gE,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 NE=z(k,{LinearRing:oh(Ud)});function GE(s,e){const t=ce(void 0,NE,s,e);if(t){const n=e[e.length-1];n[0]=t}}function kE(s,e){qi(Wx,s,e)}function UE(s,e){const n=e[e.length-1].whens,i=ln(s,!1),r=Date.parse(i);n.push(isNaN(r)?0:r)}function To(s,e){const t=Ct(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}pt(s,i.join(""))}function BE(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=At(i,o);Re(n,ma,g0,[{names:o,values:f}],t)}const u=t[0];let d=e.getGeometry();d&&(d=Qn(d,!0,u)),Re(n,ma,Zd,[d],t)}const _0=z(k,["extrude","tessellate","altitudeMode","coordinates"]),m0=z(k,{extrude:Y($i),tessellate:Y($i),altitudeMode:Y(pt),coordinates:Y(BE)});function Oi(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=_0[o.namespaceURI],l=At(r,a);Re(i,m0,Tt,l,t,a)}const p0=z(k,["color","fill","outline"]),bc=z(k,{outerBoundaryIs:Y(Mc),innerBoundaryIs:Y(Mc)}),y0=hn("innerBoundaryIs"),x0=hn("outerBoundaryIs");function qd(s,e,t){const n=e.getLinearRings(),i=n.shift(),r={node:s};Re(r,bc,y0,n,t),Re(r,bc,x0,[i],t)}const E0=z(k,{color:Y(To),fill:Y($i),outline:Y($i)});function T0(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=p0[a.namespaceURI],h=At(o,l);Re(n,E0,Tt,h,t,l)}function Jd(s,e){Yn(s,Math.round(e*1e6)/1e6)}const C0=z(k,["IconStyle","LabelStyle","LineStyle","PolyStyle"]),R0=z(k,{IconStyle:Y(QE),LabelStyle:Y(n0),LineStyle:Y(r0),PolyStyle:Y(T0)});function S0(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=C0[r.namespaceURI],a=At(i,o);Re(n,R0,Tt,a,t,o)}function v0(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 K0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function H0(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}export{P0 as $,tt as A,Rt as B,co as C,Tu as D,o_ as E,It as F,Y0 as G,X0 as H,N0 as I,Li as J,j0 as K,ht as L,M0 as M,vs as N,L0 as O,qe as P,Nr as Q,fo as R,kt as S,O0 as T,D0 as U,Xl as V,W0 as W,Xs as X,Zi as Y,Jt as Z,w0 as _,$0 as a,z0 as a0,G0 as a1,Uf as a2,kf as a3,I0 as a4,ey as a5,U0 as a6,B0 as a7,k0 as a8,V0 as a9,Z0 as aa,K0 as ab,H0 as ac,Vi as b,$s as c,Ne as d,td as e,$e as f,D as g,Ca as h,Te as i,mo as j,A0 as k,Kn as l,yn as m,lt as n,Sd as o,on as p,An as q,rn as r,si as s,ks as t,uf as u,Ze as v,Bc as w,bh as x,In as y,ze as z}; //# sourceMappingURL=openlayers-CUDtI0S3.js.map