@earthview/core 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +9 -0
- package/dist/index.d.ts +767 -0
- package/dist/index.js +1074 -0
- package/dist/index.mjs +33616 -0
- package/package.json +66 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1074 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Ph{constructor(t){this.layers=new Map,this.layerOrder=[],this.map=t}addLayer(t,e){if(this.layers.has(t.id)){console.warn(`Layer with id ${t.id} already exists`);return}const i=t.getLayer();if(i&&this.map.getLayers().getArray().includes(i)){console.warn(`Layer ${t.id} already added to map`);return}this.layers.set(t.id,t),e!==void 0&&e>=0&&e<=this.layerOrder.length?this.layerOrder.splice(e,0,t.id):this.layerOrder.push(t.id);let n=t.getLayer();n?n&&!this.map.getLayers().getArray().includes(n)&&this.map.addLayer(n):n=t.createLayer(this.map),n&&t.setZIndex(this.getZIndexForLayer(t.id))}getZIndexForLayer(t){return this.layerOrder.indexOf(t)}getLayerOrderIndex(t){const e=this.layerOrder.indexOf(t);if(e===-1)return this.map.getLayers().getLength();let i=0;for(let n=0;n<e;n++){const r=this.layerOrder[n],o=this.layers.get(r);o&&o.getLayer()&&this.map.getLayers().getArray().includes(o.getLayer())&&i++}return i}removeLayer(t){const e=this.layers.get(t);if(e){e.destroy(),this.layers.delete(t);const i=this.layerOrder.indexOf(t);i!==-1&&this.layerOrder.splice(i,1)}}getLayer(t){return this.layers.get(t)}getAllLayers(){return this.layerOrder.map(t=>this.layers.get(t))}moveLayer(t,e){const i=this.layerOrder.indexOf(t);i===-1||e<0||e>=this.layerOrder.length||(this.layerOrder.splice(i,1),this.layerOrder.splice(e,0,t),this.reorderLayers())}bringToTop(t){const e=this.layerOrder.indexOf(t);e!==-1&&(this.layerOrder.splice(e,1),this.layerOrder.push(t),this.reorderLayers())}sendToBottom(t){const e=this.layerOrder.indexOf(t);e!==-1&&(this.layerOrder.splice(e,1),this.layerOrder.unshift(t),this.reorderLayers())}reorderLayers(){this.layerOrder.forEach((t,e)=>{const i=this.layers.get(t);i&&i.getLayer()&&i.setZIndex(e)})}clearAll(){this.layers.forEach(t=>{t&&typeof t.destroy=="function"&&t.destroy()}),this.layers.clear(),this.layerOrder=[]}getLayerCount(){return this.layers.size}}let Ut=class{constructor(t,e,i,n){this.layer=null,this.source=null,this.id=t,this.name=e,this.type=i,this.visible=n?.visible??!0,this.opacity=n?.opacity??1,this.zIndex=n?.zIndex??0}getLayer(){return this.layer}setVisible(t){this.visible=t,this.layer&&this.layer.setVisible(t)}setOpacity(t){this.opacity=t,this.layer&&this.layer.setOpacity(t)}setZIndex(t){this.zIndex=t,this.layer&&this.layer.setZIndex(t)}clear(){this.source&&this.source.clear()}destroy(){if(this.layer){const t=typeof this.layer.getMap=="function"?this.layer.getMap():null;t&&typeof t.removeLayer=="function"&&t.removeLayer(this.layer),typeof this.layer.dispose=="function"&&this.layer.dispose()}this.layer=null,this.source=null}};const hn={PROPERTYCHANGE:"propertychange"};function yn(s){for(const t in s)delete s[t]}function Ai(s){let t;for(t in s)return!1;return!t}function H(s,t,e,i,n){if(n){const o=e;e=function(a){return s.removeEventListener(t,e),o.call(i??this,a)}}else i&&i!==s&&(e=e.bind(i));const r={target:s,type:t,listener:e};return s.addEventListener(t,e),r}function tr(s,t,e,i){return H(s,t,e,i,!0)}function dt(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),yn(s))}const j={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class rs{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function Mu(s,t,e){let i,n;e=e||Ke;let r=0,o=s.length,a=!1;for(;r<o;)i=r+(o-r>>1),n=+e(s[i],t),n<0?r=i+1:(o=i,a=!n);return a?r:~r}function Ke(s,t){return s>t?1:s<t?-1:0}function Au(s,t){return s<t?1:s>t?-1:0}function aa(s,t,e){if(s[0]<=t)return 0;const i=s.length;if(t<=s[i-1])return i-1;if(typeof e=="function"){for(let n=1;n<i;++n){const r=s[n];if(r===t)return n;if(r<t)return e(t,s[n-1],r)>0?n-1:n}return i-1}if(e>0){for(let n=1;n<i;++n)if(s[n]<t)return n-1;return i-1}if(e<0){for(let n=1;n<i;++n)if(s[n]<=t)return n;return i-1}for(let n=1;n<i;++n){if(s[n]==t)return n;if(s[n]<t)return s[n-1]-t<t-s[n]?n-1:n}return i-1}function Du(s,t,e){for(;t<e;){const i=s[t];s[t]=s[e],s[e]=i,++t,--e}}function Fe(s,t){const e=Array.isArray(t)?t:[t],i=e.length;for(let n=0;n<i;n++)s[s.length]=e[n]}function ei(s,t){const e=s.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(s[i]!==t[i])return!1;return!0}function ku(s,t,e){const i=t||Ke;return s.every(function(n,r){if(r===0)return!0;const o=i(s[r-1],n);return!(o>0||o===0)})}function cn(){return!0}function xn(){return!1}function Yn(){}function Lh(s){let t,e,i;return function(){const n=Array.prototype.slice.call(arguments);return(!e||this!==i||!ei(n,e))&&(i=this,e=n,t=s.apply(this,arguments)),t}}function Fu(s){function t(){let e;try{e=s()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}class $e{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Er extends rs{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),n=i[t]||(i[t]=[]);n.includes(e)||n.push(e)}dispatchEvent(t){const e=typeof t=="string",i=e?t:t.type,n=this.listeners_&&this.listeners_[i];if(!n)return;const r=e?new $e(t):t;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let h=0,c=n.length;h<c;++h)if("handleEvent"in n[h]?l=n[h].handleEvent(r):l=n[h].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,Yn);delete o[i]}return l}disposeInternal(){this.listeners_&&yn(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return this.listeners_?t?t in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const n=i.indexOf(e);n!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[n]=Yn,++this.pendingRemovals_[t]):(i.splice(n,1),i.length===0&&delete this.listeners_[t]))}}class os extends Er{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(j.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=H(this,t[r],e);return n}return H(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const n=t.length;i=new Array(n);for(let r=0;r<n;++r)i[r]=tr(this,t[r],e)}else i=tr(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)Ih(i);else if(Array.isArray(t))for(let n=0,r=t.length;n<r;++n)this.removeEventListener(t[n],e);else this.removeEventListener(t,e)}}os.prototype.on;os.prototype.once;os.prototype.un;function Ih(s){if(Array.isArray(s))for(let t=0,e=s.length;t<e;++t)dt(s[t]);else dt(s)}function X(){throw new Error("Unimplemented abstract method.")}let Ou=0;function $(s){return s.ol_uid||(s.ol_uid=String(++Ou))}class Cl extends $e{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class Te extends os{constructor(t){super(),this.on,this.once,this.un,$(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new Cl(i,t,e)),i=hn.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new Cl(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const n=this.values_||(this.values_={});if(i)n[t]=e;else{const r=n[t];n[t]=e,r!==e&&this.notify(t,r)}}setProperties(t,e){for(const i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const i=this.values_[t];delete this.values_[t],Ai(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}function Q(s,t){if(!s)throw new Error(t)}class ot extends Te{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if(typeof t.getSimplifiedGeometry=="function"){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new ot,e=this.geometryName_;t.setGeometryName(e);const i=this.getPropertiesInternal();if(i){const r=this.getGeometry();for(const o in i)o===e&&r?t.set(o,r.clone()):t.set(o,i[o],!0)}const n=this.getStyle();return n&&t.setStyle(n),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(dt(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=H(t,j.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?Nu(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){t!==this.geometryName_&&(this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_())}}function Nu(s){if(typeof s=="function")return s;let t;return Array.isArray(s)?t=s:(Q(typeof s.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[s]),function(){return t}}const At={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function er(s){const t=Wt();for(let e=0,i=s.length;e<i;++e)Wn(t,s[e]);return t}function En(s,t,e){return e?(e[0]=s[0]-t,e[1]=s[1]-t,e[2]=s[2]+t,e[3]=s[3]+t,e):[s[0]-t,s[1]-t,s[2]+t,s[3]+t]}function Mh(s,t){return t?(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t):s.slice()}function ki(s,t,e){let i,n;return t<s[0]?i=s[0]-t:s[2]<t?i=t-s[2]:i=0,e<s[1]?n=s[1]-e:s[3]<e?n=e-s[3]:n=0,i*i+n*n}function un(s,t){return la(s,t[0],t[1])}function On(s,t){return s[0]<=t[0]&&t[2]<=s[2]&&s[1]<=t[1]&&t[3]<=s[3]}function la(s,t,e){return s[0]<=t&&t<=s[2]&&s[1]<=e&&e<=s[3]}function Ao(s,t){const e=s[0],i=s[1],n=s[2],r=s[3],o=t[0],a=t[1];let l=At.UNKNOWN;return o<e?l=l|At.LEFT:o>n&&(l=l|At.RIGHT),a<i?l=l|At.BELOW:a>r&&(l=l|At.ABOVE),l===At.UNKNOWN&&(l=At.INTERSECTING),l}function Wt(){return[1/0,1/0,-1/0,-1/0]}function ti(s,t,e,i,n){return n?(n[0]=s,n[1]=t,n[2]=e,n[3]=i,n):[s,t,e,i]}function as(s){return ti(1/0,1/0,-1/0,-1/0,s)}function ha(s,t){const e=s[0],i=s[1];return ti(e,i,e,i,t)}function ca(s,t,e,i,n){const r=as(n);return Ah(r,s,t,e,i)}function dn(s,t){return s[0]==t[0]&&s[2]==t[2]&&s[1]==t[1]&&s[3]==t[3]}function Bn(s,t){return t[0]<s[0]&&(s[0]=t[0]),t[2]>s[2]&&(s[2]=t[2]),t[1]<s[1]&&(s[1]=t[1]),t[3]>s[3]&&(s[3]=t[3]),s}function Wn(s,t){t[0]<s[0]&&(s[0]=t[0]),t[0]>s[2]&&(s[2]=t[0]),t[1]<s[1]&&(s[1]=t[1]),t[1]>s[3]&&(s[3]=t[1])}function Ah(s,t,e,i,n){for(;e<i;e+=n)Gu(s,t[e],t[e+1]);return s}function Gu(s,t,e){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}function ua(s,t){let e;return e=t(vr(s)),e||(e=t(Cr(s)),e)||(e=t(wr(s)),e)||(e=t(Fi(s)),e)?e:!1}function Do(s){let t=0;return ls(s)||(t=at(s)*Yt(s)),t}function vr(s){return[s[0],s[1]]}function Cr(s){return[s[2],s[1]]}function ue(s){return[(s[0]+s[2])/2,(s[1]+s[3])/2]}function zu(s,t){let e;if(t==="bottom-left")e=vr(s);else if(t==="bottom-right")e=Cr(s);else if(t==="top-left")e=Fi(s);else if(t==="top-right")e=wr(s);else throw new Error("Invalid corner");return e}function ko(s,t,e,i,n){const[r,o,a,l,h,c,u,d]=Dh(s,t,e,i);return ti(Math.min(r,a,h,u),Math.min(o,l,c,d),Math.max(r,a,h,u),Math.max(o,l,c,d),n)}function Dh(s,t,e,i){const n=t*i[0]/2,r=t*i[1]/2,o=Math.cos(e),a=Math.sin(e),l=n*o,h=n*a,c=r*o,u=r*a,d=s[0],f=s[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function Yt(s){return s[3]-s[1]}function Li(s,t,e){const i=e||Wt();return Vt(s,t)?(s[0]>t[0]?i[0]=s[0]:i[0]=t[0],s[1]>t[1]?i[1]=s[1]:i[1]=t[1],s[2]<t[2]?i[2]=s[2]:i[2]=t[2],s[3]<t[3]?i[3]=s[3]:i[3]=t[3]):as(i),i}function Fi(s){return[s[0],s[3]]}function wr(s){return[s[2],s[3]]}function at(s){return s[2]-s[0]}function Vt(s,t){return s[0]<=t[2]&&s[2]>=t[0]&&s[1]<=t[3]&&s[3]>=t[1]}function ls(s){return s[2]<s[0]||s[3]<s[1]}function $u(s,t){return t?(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t):s}function Bu(s,t,e){let i=!1;const n=Ao(s,t),r=Ao(s,e);if(n===At.INTERSECTING||r===At.INTERSECTING)i=!0;else{const o=s[0],a=s[1],l=s[2],h=s[3],c=t[0],u=t[1],d=e[0],f=e[1],g=(f-u)/(d-c);let _,p;r&At.ABOVE&&!(n&At.ABOVE)&&(_=d-(f-h)/g,i=_>=o&&_<=l),!i&&r&At.RIGHT&&!(n&At.RIGHT)&&(p=f-(d-l)*g,i=p>=a&&p<=h),!i&&r&At.BELOW&&!(n&At.BELOW)&&(_=d-(f-a)/g,i=_>=o&&_<=l),!i&&r&At.LEFT&&!(n&At.LEFT)&&(p=f-(d-o)*g,i=p>=a&&p<=h)}return i}function kh(s,t){const e=t.getExtent(),i=ue(s);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){const n=at(e),o=Math.floor((i[0]-e[0])/n)*n;s[0]-=o,s[2]-=o}return s}function Fh(s,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(s[0])||!isFinite(s[2]))return[[i[0],s[1],i[2],s[3]]];kh(s,t);const n=at(i);if(at(s)>n&&!e)return[[i[0],s[1],i[2],s[3]]];if(s[0]<i[0])return[[s[0]+n,s[1],i[2],s[3]],[i[0],s[1],s[2],s[3]]];if(s[2]>i[2])return[[s[0],s[1],i[2],s[3]],[i[0],s[1],s[2]-n,s[3]]]}return[s]}function pt(s,t,e){return Math.min(Math.max(s,t),e)}function Wu(s,t,e,i,n,r){const o=n-e,a=r-i;if(o!==0||a!==0){const l=((s-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=n,i=r):l>0&&(e+=o*l,i+=a*l)}return qe(s,t,e,i)}function qe(s,t,e,i){const n=e-s,r=i-t;return n*n+r*r}function Uu(s){const t=s.length;for(let i=0;i<t;i++){let n=i,r=Math.abs(s[i][i]);for(let a=i+1;a<t;a++){const l=Math.abs(s[a][i]);l>r&&(r=l,n=a)}if(r===0)return null;const o=s[n];s[n]=s[i],s[i]=o;for(let a=i+1;a<t;a++){const l=-s[a][i]/s[i][i];for(let h=i;h<t+1;h++)i==h?s[a][h]=0:s[a][h]+=l*s[i][h]}}const e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=s[i][t]/s[i][i];for(let n=i-1;n>=0;n--)s[n][t]-=s[n][i]*e[i]}return e}function wl(s){return s*180/Math.PI}function ve(s){return s*Math.PI/180}function Ii(s,t){const e=s%t;return e*t<0?e+t:e}function se(s,t,e){return s+e*(t-s)}function hs(s,t){const e=Math.pow(10,t);return Math.round(s*e)/e}function Rs(s,t){return Math.floor(hs(s,t))}function bs(s,t){return Math.ceil(hs(s,t))}function Fo(s,t,e){if(s>=t&&s<e)return s;const i=e-t;return((s-t)%i+i)%i+t}function Oh(...s){console.warn(...s)}function Nh(s,t){return s[0]+=+t[0],s[1]+=+t[1],s}function ir(s,t){let e=!0;for(let i=s.length-1;i>=0;--i)if(s[i]!=t[i]){e=!1;break}return e}function da(s,t){const e=Math.cos(t),i=Math.sin(t),n=s[0]*e-s[1]*i,r=s[1]*e+s[0]*i;return s[0]=n,s[1]=r,s}function Gh(s,t){return s[0]*=t,s[1]*=t,s}function zh(s,t){const e=s[0]-t[0],i=s[1]-t[1];return e*e+i*i}function $h(s,t){return Math.sqrt(zh(s,t))}function Bh(s,t){if(t.canWrapX()){const e=at(t.getExtent()),i=Xu(s,t,e);i&&(s[0]-=i*e)}return s}function Xu(s,t,e){const i=t.getExtent();let n=0;return t.canWrapX()&&(s[0]<i[0]||s[0]>i[2])&&(e=e||at(i),n=Math.floor((s[0]-i[0])/e)),n}function ju(s,t,e){const i=Math.sqrt((t[0]-s[0])*(t[0]-s[0])+(t[1]-s[1])*(t[1]-s[1])),n=[(t[0]-s[0])/i,(t[1]-s[1])/i],r=[-n[1],n[0]],o=Math.sqrt((e[0]-s[0])*(e[0]-s[0])+(e[1]-s[1])*(e[1]-s[1])),a=[(e[0]-s[0])/o,(e[1]-s[1])/o];let l=i===0||o===0?0:Math.acos(pt(a[0]*n[0]+a[1]*n[1],-1,1));return l=Math.max(l,1e-5),a[0]*r[0]+a[1]*r[1]>0?l:Math.PI*2-l}const fa={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class ga{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||fa[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const cs=6378137,tn=Math.PI*cs,Vu=[-tn,-tn,tn,tn],Yu=[-180,-85,180,85],Ps=cs*Math.log(Math.tan(Math.PI/2));class $i extends ga{constructor(t){super({code:t,units:"m",extent:Vu,global:!0,worldExtent:Yu,getPointResolution:function(e,i){return e/Math.cosh(i[1]/cs)}})}}const Tl=[new $i("EPSG:3857"),new $i("EPSG:102100"),new $i("EPSG:102113"),new $i("EPSG:900913"),new $i("http://www.opengis.net/def/crs/EPSG/0/3857"),new $i("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Zu(s,t,e,i){const n=s.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=s.slice():t=new Array(n));for(let r=0;r<n;r+=i){t[r]=tn*s[r]/180;let o=cs*Math.log(Math.tan(Math.PI*(+s[r+1]+90)/360));o>Ps?o=Ps:o<-Ps&&(o=-Ps),t[r+1]=o}return t}function Hu(s,t,e,i){const n=s.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=s.slice():t=new Array(n));for(let r=0;r<n;r+=i)t[r]=180*s[r]/tn,t[r+1]=360*Math.atan(Math.exp(s[r+1]/cs))/Math.PI-90;return t}const Ku=6378137,Sl=[-180,-90,180,90],qu=Math.PI*Ku/180;class Ei extends ga{constructor(t,e){super({code:t,units:"degrees",extent:Sl,axisOrientation:e,global:!0,metersPerUnit:qu,worldExtent:Sl})}}const Rl=[new Ei("CRS:84"),new Ei("EPSG:4326","neu"),new Ei("urn:ogc:def:crs:OGC:1.3:CRS84"),new Ei("urn:ogc:def:crs:OGC:2:84"),new Ei("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Ei("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Ei("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Oo={};function Ju(s){return Oo[s]||Oo[s.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function Qu(s,t){Oo[s]=t}let on={};function Zn(s,t,e){const i=s.getCode(),n=t.getCode();i in on||(on[i]={}),on[i][n]=e}function Zr(s,t){return s in on&&t in on[s]?on[s][t]:null}const nr=.9996,de=.00669438,Tr=de*de,Sr=Tr*de,Ti=de/(1-de),bl=Math.sqrt(1-de),fn=(1-bl)/(1+bl),Wh=fn*fn,pa=Wh*fn,_a=pa*fn,Uh=_a*fn,Xh=1-de/4-3*Tr/64-5*Sr/256,td=3*de/8+3*Tr/32+45*Sr/1024,ed=15*Tr/256+45*Sr/1024,id=35*Sr/3072,nd=3/2*fn-27/32*pa+269/512*Uh,sd=21/16*Wh-55/32*_a,rd=151/96*pa-417/128*Uh,od=1097/512*_a,sr=6378137;function ad(s,t,e){const i=s-5e5,o=(e.north?t:t-1e7)/nr/(sr*Xh),a=o+nd*Math.sin(2*o)+sd*Math.sin(4*o)+rd*Math.sin(6*o)+od*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-de*h,_=Math.sqrt(1-de*h),p=sr/_,m=(1-de)/g,y=Ti*c**2,C=y*y,x=i/(p*nr),E=x*x,S=E*x,w=S*x,T=w*x,R=T*x,b=a-u/m*(E/2-w/24*(5+3*d+10*y-4*C-9*Ti))+R/720*(61+90*d+298*y+45*f-252*Ti-3*C);let L=(x-S/6*(1+2*d+y)+T/120*(5-2*y+28*d-3*C+8*Ti+24*f))/c;return L=Fo(L+ve(jh(e.number)),-Math.PI,Math.PI),[wl(L),wl(b)]}const Pl=-80,Ll=84,ld=-180,hd=180;function cd(s,t,e){s=Fo(s,ld,hd),t<Pl?t=Pl:t>Ll&&(t=Ll);const i=ve(t),n=Math.sin(i),r=Math.cos(i),o=n/r,a=o*o,l=a*a,h=ve(s),c=jh(e.number),u=ve(c),d=sr/Math.sqrt(1-de*n**2),f=Ti*r**2,g=r*Fo(h-u,-Math.PI,Math.PI),_=g*g,p=_*g,m=p*g,y=m*g,C=y*g,x=sr*(Xh*i-td*Math.sin(2*i)+ed*Math.sin(4*i)-id*Math.sin(6*i)),E=nr*d*(g+p/6*(1-a+f)+y/120*(5-18*a+l+72*f-58*Ti))+5e5;let S=nr*(x+d*o*(_/2+m/24*(5-a+9*f+4*f**2)+C/720*(61-58*a+l+600*f-330*Ti)));return e.north||(S+=1e7),[E,S]}function jh(s){return(s-1)*6-180+3}const ud=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Vh(s){let t=0;for(const n of ud){const r=s.match(n);if(r){t=parseInt(r[1]);break}}if(!t)return null;let e=0,i=!1;return t>32700&&t<32761?e=t-32700:t>32600&&t<32661&&(i=!0,e=t-32600),e?{number:e,north:i}:null}function Il(s,t){return function(e,i,n,r){const o=e.length;n=n>1?n:2,r=r??n,i||(n>2?i=e.slice():i=new Array(o));for(let a=0;a<o;a+=r){const l=e[a],h=e[a+1],c=s(l,h,t);i[a]=c[0],i[a+1]=c[1]}return i}}function dd(s){return Vh(s)?new ga({code:s,units:"m"}):null}function fd(s){const t=Vh(s.getCode());return t?{forward:Il(cd,t),inverse:Il(ad,t)}:null}const ma=63710088e-1;function No(s,t,e){e=e||ma;const i=ve(s[1]),n=ve(t[1]),r=(n-i)/2,o=ve(t[0]-s[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(n);return 2*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function Hr(s,t){let e=0;for(let i=0,n=s.length;i<n-1;++i)e+=No(s[i],s[i+1],t);return e}function Yh(s,t){t=t||{};const e=t.radius||ma,i=t.projection||"EPSG:3857",n=s.getType();n!=="GeometryCollection"&&(s=s.clone().transform(i,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(n){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":{o=s.getCoordinates(),r=Hr(o,e);break}case"MultiLineString":case"Polygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)r+=Hr(o[l],e);break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,u=a.length;c<u;++c)r+=Hr(a[c],e);break}case"GeometryCollection":{const d=s.getGeometries();for(l=0,h=d.length;l<h;++l)r+=Yh(d[l],t);break}default:throw new Error("Unsupported geometry type: "+n)}return r}function Ls(s,t){let e=0;const i=s.length;let n=s[i-1][0],r=s[i-1][1];for(let o=0;o<i;o++){const a=s[o][0],l=s[o][1];e+=ve(a-n)*(2+Math.sin(ve(r))+Math.sin(ve(l))),n=a,r=l}return e*t*t/2}function Zh(s,t){t=t||{};const e=t.radius||ma,i=t.projection||"EPSG:3857",n=s.getType();n!=="GeometryCollection"&&(s=s.clone().transform(i,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(n){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":{for(o=s.getCoordinates(),r=Math.abs(Ls(o[0],e)),l=1,h=o.length;l<h;++l)r-=Math.abs(Ls(o[l],e));break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],r+=Math.abs(Ls(a[0],e)),c=1,u=a.length;c<u;++c)r-=Math.abs(Ls(a[c],e));break}case"GeometryCollection":{const d=s.getGeometries();for(l=0,h=d.length;l<h;++l)r+=Zh(d[l],t);break}default:throw new Error("Unsupported geometry type: "+n)}return r}const gd=[fd],pd=[dd];let Go=!0;function Hh(s){Go=!1}function ya(s,t){if(t!==void 0){for(let e=0,i=s.length;e<i;++e)t[e]=s[e];t=t}else t=s.slice();return t}function zo(s){Qu(s.getCode(),s),Zn(s,s,ya)}function _d(s){s.forEach(zo)}function Ct(s){if(typeof s!="string")return s;const t=Ju(s);if(t)return t;for(const e of pd){const i=e(s);if(i)return i}return null}function Ml(s,t,e,i){s=Ct(s);let n;const r=s.getPointResolutionFunc();if(r)n=r(t,e);else{const o=s.getUnits();if(o=="degrees"&&!i||i=="degrees")n=t;else{const a=Ea(s,Ct("EPSG:4326"));if(!a&&o!=="degrees")n=t*s.getMetersPerUnit();else{let h=[e[0]-t/2,e[1],e[0]+t/2,e[1],e[0],e[1]-t/2,e[0],e[1]+t/2];h=a(h,h,2);const c=No(h.slice(0,2),h.slice(2,4)),u=No(h.slice(4,6),h.slice(6,8));n=(c+u)/2}const l=s.getMetersPerUnit();l!==void 0&&(n/=l)}}return n}function Al(s){_d(s),s.forEach(function(t){s.forEach(function(e){t!==e&&Zn(t,e,ya)})})}function md(s,t,e,i){s.forEach(function(n){t.forEach(function(r){Zn(n,r,e),Zn(r,n,i)})})}function xa(s,t){return s?typeof s=="string"?Ct(s):s:Ct(t)}function yd(s){return(function(t,e,i,n){const r=t.length;i=i!==void 0?i:2,n=n??i,e=e!==void 0?e:new Array(r);for(let o=0;o<r;o+=n){const a=s(t.slice(o,o+i)),l=a.length;for(let h=0,c=n;h<c;++h)e[o+h]=h>=l?t[o+h]:a[h]}return e})}function te(s,t){return Hh(),Rr(s,"EPSG:4326","EPSG:3857")}function Pt(s,t){const e=Rr(s,"EPSG:3857","EPSG:4326"),i=e[0];return(i<-180||i>180)&&(e[0]=Ii(i+180,360)-180),e}function Un(s,t){if(s===t)return!0;const e=s.getUnits()===t.getUnits();return(s.getCode()===t.getCode()||Ea(s,t)===ya)&&e}function Ea(s,t){const e=s.getCode(),i=t.getCode();let n=Zr(e,i);if(n)return n;let r=null,o=null;for(const l of gd)r||(r=l(s)),o||(o=l(t));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)n=Kr(r.inverse,o.forward);else{const l=Zr(e,a);l&&(n=Kr(l,o.forward))}else{const l=Zr(a,i);l&&(n=Kr(r.inverse,l))}return n&&(zo(s),zo(t),Zn(s,t,n)),n}function Kr(s,t){return function(e,i,n,r){return i=s(e,i,n,r),t(i,i,n,r)}}function Hn(s,t){const e=Ct(s),i=Ct(t);return Ea(e,i)}function Rr(s,t,e){const i=Hn(t,e);if(!i){const n=Ct(t).getCode(),r=Ct(e).getCode();throw new Error(`No transform available between ${n} and ${r}`)}return i(s,void 0,s.length)}function $o(s,t){return s}function ye(s,t){return Go&&!ir(s,[0,0])&&s[0]>=-180&&s[0]<=180&&s[1]>=-90&&s[1]<=90&&(Go=!1,Oh("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),s}function Kh(s,t){return s}function Si(s,t){return s}function xd(){Al(Tl),Al(Rl),md(Rl,Tl,Zu,Hu)}xd();const Ed=new Array(6);function Mt(){return[1,0,0,1,0,0]}function qh(s,t){const e=s[0],i=s[1],n=s[2],r=s[3],o=s[4],a=s[5],l=t[0],h=t[1],c=t[2],u=t[3],d=t[4],f=t[5];return s[0]=e*l+n*h,s[1]=i*l+r*h,s[2]=e*c+n*u,s[3]=i*c+r*u,s[4]=e*d+n*f+o,s[5]=i*d+r*f+a,s}function vd(s,t,e,i,n,r,o){return s[0]=t,s[1]=e,s[2]=i,s[3]=n,s[4]=r,s[5]=o,s}function Jh(s,t){return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=t[4],s[5]=t[5],s}function wt(s,t){const e=t[0],i=t[1];return t[0]=s[0]*e+s[2]*i+s[4],t[1]=s[1]*e+s[3]*i+s[5],t}function Cd(s,t,e){return qh(s,vd(Ed,1,0,0,1,t,e))}function ge(s,t,e,i,n,r,o,a){const l=Math.sin(r),h=Math.cos(r);return s[0]=i*h,s[1]=n*l,s[2]=-i*l,s[3]=n*h,s[4]=o*i*h-a*i*l+t,s[5]=o*n*l+a*n*h+e,s}function br(s,t){const e=wd(t);Q(e!==0,"Transformation matrix cannot be inverted");const i=t[0],n=t[1],r=t[2],o=t[3],a=t[4],l=t[5];return s[0]=o/e,s[1]=-n/e,s[2]=-r/e,s[3]=i/e,s[4]=(r*l-o*a)/e,s[5]=-(i*l-n*a)/e,s}function wd(s){return s[0]*s[3]-s[1]*s[2]}const Td=[1e5,1e5,1e5,1e5,2,2];function Sd(s){return"matrix("+s.join(", ")+")"}function Bo(s){return s.substring(7,s.length-1).split(",").map(parseFloat)}function Rd(s,t){const e=Bo(s),i=Bo(t);for(let n=0;n<6;++n)if(Math.round((e[n]-i[n])*Td[n])!==0)return!1;return!0}function Oe(s,t,e,i,n,r,o){r=r||[],o=o||2;let a=0;for(let l=t;l<e;l+=i){const h=s[l],c=s[l+1];r[a++]=n[0]*h+n[2]*c+n[4],r[a++]=n[1]*h+n[3]*c+n[5];for(let u=2;u<o;u++)r[a++]=s[l+u]}return r&&r.length!=a&&(r.length=a),r}function va(s,t,e,i,n,r,o){o=o||[];const a=Math.cos(n),l=Math.sin(n),h=r[0],c=r[1];let u=0;for(let d=t;d<e;d+=i){const f=s[d]-h,g=s[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let _=d+2;_<d+i;++_)o[u++]=s[_]}return o&&o.length!=u&&(o.length=u),o}function bd(s,t,e,i,n,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let u=t;u<e;u+=i){const d=s[u]-l,f=s[u+1]-h;a[c++]=l+n*d,a[c++]=h+r*f;for(let g=u+2;g<u+i;++g)a[c++]=s[g]}return a&&a.length!=c&&(a.length=c),a}function Pd(s,t,e,i,n,r,o){o=o||[];let a=0;for(let l=t;l<e;l+=i){o[a++]=s[l]+n,o[a++]=s[l+1]+r;for(let h=l+2;h<l+i;++h)o[a++]=s[h]}return o&&o.length!=a&&(o.length=a),o}const Dl=Mt(),Ld=[NaN,NaN];class Qh extends Te{constructor(){super(),this.extent_=Wt(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Lh((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);const n=this.clone();return n.applyTransform(i),n.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return X()}closestPointXY(t,e,i,n){return X()}containsXY(t,e){return this.closestPointXY(t,e,Ld,Number.MIN_VALUE)===0}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return X()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&as(e),this.extentRevision_=this.getRevision()}return $u(this.extent_,t)}rotate(t,e){X()}scale(t,e,i){X()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return X()}getType(){return X()}applyTransform(t){X()}intersectsExtent(t){return X()}translate(t,e){X()}transform(t,e){const i=Ct(t),n=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=Yt(h)/Yt(l);ge(Dl,h[0],h[3],c,-c,0,0,0);const u=Oe(r,0,r.length,a,Dl,o),d=Hn(i,e);return d?d(u,u,a):u}:Hn(i,e);return this.applyTransform(n),this}}class _i extends Qh{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return ca(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return X()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=rr(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){X()}setLayout(t,e,i){let n;if(t)n=rr(t);else{for(let r=0;r<i;++r){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}n=e.length,t=Oi(n)}this.layout=t,this.stride=n}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();va(i,0,i.length,n,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=ue(this.getExtent()));const n=this.getFlatCoordinates();if(n){const r=this.getStride();bd(n,0,n.length,r,t,e,i,n),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();Pd(i,0,i.length,n,t,e,i),this.changed()}}}function Oi(s){let t;return s==2?t="XY":s==3?t="XYZ":s==4&&(t="XYZM"),t}function rr(s){let t;return s=="XY"?t=2:s=="XYZ"||s=="XYM"?t=3:s=="XYZM"&&(t=4),t}function Id(s,t,e){const i=s.getFlatCoordinates();if(!i)return null;const n=s.getStride();return Oe(i,0,i.length,n,t,e)}function tc(s,t,e,i){for(let n=0,r=e.length;n<r;++n)s[t++]=e[n];return t}function Pr(s,t,e,i){for(let n=0,r=e.length;n<r;++n){const o=e[n];for(let a=0;a<i;++a)s[t++]=o[a]}return t}function us(s,t,e,i,n){n=n||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=Pr(s,t,e[o],i);n[r++]=l,t=l}return n.length=r,n}function ec(s,t,e,i,n){n=n||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=us(s,t,e[o],i,n[r]);l.length===0&&(l[0]=t),n[r++]=l,t=l[l.length-1]}return n.length=r,n}class gt extends _i{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new gt(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){const r=this.flatCoordinates,o=qe(t,e,r[0],r[1]);if(o<n){const a=this.stride;for(let l=0;l<a;++l)i[l]=r[l];return i.length=a,o}return n}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return ha(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return la(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=tc(this.flatCoordinates,0,t,this.stride),this.changed()}}const Dt={ANIMATING:0,INTERACTING:1},Di=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",Md=Di.includes("safari")&&!Di.includes("chrom"),Ad=Md&&(Di.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Di)),Dd=Di.includes("webkit")&&!Di.includes("edge"),ic=Di.includes("macintosh"),kd=typeof devicePixelRatio<"u"?devicePixelRatio:1,le=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,nc=typeof Image<"u"&&Image.prototype.decode,sc=(function(){let s=!1;try{const t=Object.defineProperty({},"passive",{get:function(){s=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return s})();function Tt(s,t,e,i){let n;return e&&e.length?n=e.shift():le?n=new class extends OffscreenCanvas{style={}}(s??300,t??150):n=document.createElement("canvas"),s&&(n.width=s),t&&(n.height=t),n.getContext("2d",i)}let qr;function or(){return qr||(qr=Tt(1,1)),qr}function Lr(s){const t=s.canvas;t.width=1,t.height=1,s.clearRect(0,0,1,1)}function kl(s,t){const e=t.parentNode;e&&e.replaceChild(s,t)}function Fd(s){for(;s.lastChild;)s.lastChild.remove()}function Od(s,t){const e=s.childNodes;for(let i=0;;++i){const n=e[i],r=t[i];if(!n&&!r)break;if(n!==r){if(!n){s.appendChild(r);continue}if(!r){s.removeChild(n),--i;continue}s.insertBefore(r,n)}}}function rc(){return new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){const e=this.childNodes.indexOf(t);if(e===-1)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){const i=this.childNodes.indexOf(e);if(i===-1)throw new Error("Reference node not found");return this.childNodes.splice(i,0,t),t},style:{}},{get(t,e,i){return e==="firstElementChild"?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,i)}})}function di(s){return typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}const kt={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"},Y={IDLE:0,LOADING:1,LOADED:2,ERROR:3},Ca=[NaN,NaN,NaN,0];let Jr;function Nd(){return Jr||(Jr=Tt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Jr}const Gd=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,zd=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,$d=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Bd=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Is(s,t){return s.endsWith("%")?Number(s.substring(0,s.length-1))/t:Number(s)}function Xn(s){throw new Error('failed to parse "'+s+'" as color')}function oc(s){if(s.toLowerCase().startsWith("rgb")){const r=s.match(zd)||s.match(Gd)||s.match($d);if(r){const o=r[4],a=100/255;return[pt(Is(r[1],a)+.5|0,0,255),pt(Is(r[2],a)+.5|0,0,255),pt(Is(r[3],a)+.5|0,0,255),o!==void 0?pt(Is(o,100),0,1):1]}Xn(s)}if(s.startsWith("#")){if(Bd.test(s)){const r=s.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l<h;l+=o){let c=parseInt(r.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}Xn(s)}const t=Nd();t.fillStyle="#abcdef";let e=t.fillStyle;t.fillStyle=s,t.fillStyle===e&&(t.fillStyle="#fedcba",e=t.fillStyle,t.fillStyle=s,t.fillStyle===e&&Xn(s));const i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return oc(i);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);const n=Array.from(t.getImageData(0,0,1,1).data);return n[3]=hs(n[3]/255,3),n}function Wd(s){return typeof s=="string"?s:Ta(s)}const Ud=1024,Mn={};let Qr=0;function Xd(s){if(s.length===4)return s;const t=s.slice();return t[3]=1,t}function to(s){return s>.0031308?Math.pow(s,1/2.4)*269.025-14.025:s*3294.6}function eo(s){return s>.2068965?Math.pow(s,3):(s-4/29)*(108/841)}function io(s){return s>10.314724?Math.pow((s+14.025)/269.025,2.4):s/3294.6}function no(s){return s>.0088564?Math.pow(s,1/3):s/(108/841)+4/29}function Fl(s){const t=io(s[0]),e=io(s[1]),i=io(s[2]),n=no(t*.222488403+e*.716873169+i*.06060791),r=500*(no(t*.452247074+e*.399439023+i*.148375274)-n),o=200*(n-no(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*n-16,Math.sqrt(r*r+o*o),a<0?a+360:a,s[3]]}function jd(s){const t=(s[0]+16)/116,e=s[1],i=s[2]*Math.PI/180,n=eo(t),r=eo(t+e/500*Math.cos(i)),o=eo(t-e/200*Math.sin(i)),a=to(r*3.021973625-n*1.617392459-o*.404875592),l=to(r*-.943766287+n*1.916279586+o*.027607165),h=to(r*.069407491-n*.22898585+o*1.159737864);return[pt(a+.5|0,0,255),pt(l+.5|0,0,255),pt(h+.5|0,0,255),s[3]]}function wa(s){if(s==="none")return Ca;if(Mn.hasOwnProperty(s))return Mn[s];if(Qr>=Ud){let e=0;for(const i in Mn)(e++&3)===0&&(delete Mn[i],--Qr)}const t=oc(s);t.length!==4&&Xn(s);for(const e of t)isNaN(e)&&Xn(s);return Mn[s]=t,++Qr,t}function pe(s){return Array.isArray(s)?s:wa(s)}function Ta(s){let t=s[0];t!=(t|0)&&(t=t+.5|0);let e=s[1];e!=(e|0)&&(e=e+.5|0);let i=s[2];i!=(i|0)&&(i=i+.5|0);const n=s[3]===void 0?1:Math.round(s[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+n+")"}function Vd(s,t,e){const i=s;let n=!0,r=!1,o=!1;const a=[tr(i,j.LOAD,function(){o=!0,r||t()})];return i.src&&nc?(r=!0,i.decode().then(function(){n&&t()}).catch(function(l){n&&(o?t():e())})):a.push(tr(i,j.ERROR,e)),function(){n=!1,a.forEach(dt)}}function Yd(s,t){return new Promise((e,i)=>{function n(){o(),e(s)}function r(){o(),i(new Error("Image load error"))}function o(){s.removeEventListener("load",n),s.removeEventListener("error",r)}s.addEventListener("load",n),s.addEventListener("error",r)})}function Zd(s,t){return t&&(s.src=t),s.src&&nc?new Promise((e,i)=>s.decode().then(()=>e(s)).catch(n=>s.complete&&s.width?e(s):i(n))):Yd(s)}class Hd{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){const i=so(t,e);return i in this.cache_?this.cache_[i]:null}getPattern(t,e){const i=so(t,e);return i in this.patternCache_?this.patternCache_[i]:null}set(t,e,i,n){const r=so(t,e),o=r in this.cache_;this.cache_[r]=i,n&&(i.getImageState()===Y.IDLE&&i.load(),i.getImageState()===Y.LOADING?i.ready().then(()=>{this.patternCache_[r]=or().createPattern(i.getImage(1),"repeat")}):this.patternCache_[r]=or().createPattern(i.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function so(s,t){const e=t?pe(t):"null";return s+":"+e}const he=new Hd;let An=null;class ac extends Er{constructor(t,e,i,n,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.canvas_={},this.color_=r,this.imageState_=n===void 0?Y.IDLE:n,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===Y.LOADED){An||(An=Tt(1,1,void 0,{willReadFrequently:!0})),An.drawImage(this.image_,0,0);try{An.getImageData(0,0,1,1),this.tainted_=!1}catch{An=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(j.CHANGE)}handleImageError_(){this.imageState_=Y.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=Y.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}setImage(t){this.image_=t}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=Tt(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===Y.IDLE){this.image_||this.initializeImage_(),this.imageState_=Y.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Zd(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==Y.LOADED)return;const e=this.image_,i=Tt(Math.ceil(e.width*t),Math.ceil(e.height*t)),n=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Wd(this.color_),i.fillRect(0,0,n.width/t,n.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=n}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===Y.LOADED||this.imageState_===Y.ERROR)t();else{const e=()=>{(this.imageState_===Y.LOADED||this.imageState_===Y.ERROR)&&(this.removeEventListener(j.CHANGE,e),t())};this.addEventListener(j.CHANGE,e)}})),this.ready_}}function jn(s,t,e,i,n,r){let o=t===void 0?void 0:he.get(t,n);return o||(o=new ac(s,s&&"src"in s?s.src||void 0:t,e,i,n),he.set(t,n,o,r)),r&&o&&!he.getPattern(t,n)&&he.set(t,n,o,r),o}function ke(s){return s?Array.isArray(s)?Ta(s):typeof s=="object"&&"src"in s?Kd(s):s:null}function Kd(s){if(!s.offset||!s.size)return he.getPattern(s.src,s.color);const t=s.src+":"+s.offset,e=he.getPattern(t,s.color);if(e)return e;const i=he.get(s.src,null);if(i.getImageState()!==Y.LOADED)return null;const n=Tt(s.size[0],s.size[1]);return n.drawImage(i.getImage(1),s.offset[0],s.offset[1],s.size[0],s.size[1],0,0,s.size[0],s.size[1]),jn(n.canvas,t,void 0,Y.LOADED,s.color,!0),he.getPattern(t,s.color)}function fi(s,t,e,i,n){n=n!==void 0?n:[];let r=0;for(let o=t;o<e;o+=i)n[r++]=s.slice(o,o+i);return n.length=r,n}function Kn(s,t,e,i,n){n=n!==void 0?n:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];n[r++]=fi(s,t,l,i,n[r]),t=l}return n.length=r,n}function Wo(s,t,e,i,n){n=n!==void 0?n:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];n[r++]=l.length===1&&l[0]===t?[]:Kn(s,t,l,i,n[r]),t=l[l.length-1]}return n.length=r,n}class lc{drawCustom(t,e,i,n,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}const Ms="ol-hidden",Ir="ol-unselectable",Sa="ol-control",Ol="ol-collapsed",qd=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),Nl=["style","variant","weight","size","lineHeight","family"],Uo={normal:400,bold:700},Xo=function(s){const t=s.match(qd);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,n=Nl.length;i<n;++i){const r=t[i+1];r!==void 0&&(e[Nl[i]]=typeof r=="string"?r.trim():r)}return isNaN(Number(e.weight))&&e.weight in Uo&&(e.weight=Uo[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e},hc="10px sans-serif",Kt="#000",gn="round",Je=[],Qe=0,pn="round",qn=10,Jd=0,Ne="#000",Jn="center",ar="middle",Ri=[0,0,0,0],Qn=1,Ki=new Te;let Dn=null,Gl;const jo={},Qd=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function tf(s,t,e){return`${s} ${t} 16px "${e}"`}const ef=(function(){let t,e;async function i(r){await e.ready;const o=await e.load(r);if(o.length===0)return!1;const a=Xo(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=Uo[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function n(){await e.ready;let r=!0;const o=Ki.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await i(h)?(yn(jo),Ki.set(h,100)):(c+=10,Ki.set(h,c,!0),c<100&&(r=!1)))}t=void 0,r||(t=setTimeout(n,100))}return async function(r){e||(e=le?self.fonts:document.fonts);const o=Xo(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(Qd.has(h))continue;const c=tf(o.style,o.weight,h);Ki.get(c)===void 0&&(Ki.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(n,100))}})(),nf=(function(){let s;return function(t){let e=jo[t];if(e==null){if(le){const i=Xo(t),n=cc(t,"Žg");e=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent)}else s||(s=document.createElement("div"),s.innerHTML="M",s.style.minHeight="0",s.style.maxHeight="none",s.style.height="auto",s.style.padding="0",s.style.border="none",s.style.position="absolute",s.style.display="block",s.style.left="-99999px"),s.style.font=t,document.body.appendChild(s),e=s.offsetHeight,document.body.removeChild(s);jo[t]=e}return e}})();function cc(s,t){return Dn||(Dn=Tt(1,1)),s!=Gl&&(Dn.font=s,Gl=Dn.font),Dn.measureText(t)}function uc(s,t){return cc(s,t).width}function zl(s,t,e){if(t in e)return e[t];const i=t.split(`
|
|
2
|
+
`).reduce((n,r)=>Math.max(n,uc(s,r)),0);return e[t]=i,i}function sf(s,t){const e=[],i=[],n=[];let r=0,o=0,a=0,l=0;for(let h=0,c=t.length;h<=c;h+=2){const u=t[h];if(u===`
|
|
3
|
+
`||h===c){r=Math.max(r,o),n.push(o),o=0,a+=l,l=0;continue}const d=t[h+1]||s.font,f=uc(d,u);e.push(f),o+=f;const g=nf(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:n}}function rf(s,t,e,i,n,r,o,a,l,h,c){s.save(),e!==1&&(s.globalAlpha===void 0?s.globalAlpha=u=>u.globalAlpha*=e:s.globalAlpha*=e),t&&s.transform.apply(s,t),i.contextInstructions?(s.translate(l,h),s.scale(c[0],c[1]),of(i,s)):c[0]<0||c[1]<0?(s.translate(l,h),s.scale(c[0],c[1]),s.drawImage(i,n,r,o,a,0,0,o,a)):s.drawImage(i,n,r,o,a,l,h,o*c[0],a*c[1]),s.restore()}function of(s,t){const e=s.contextInstructions;for(let i=0,n=e.length;i<n;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}const O={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},As=[O.FILL],gi=[O.STROKE],bi=[O.BEGIN_PATH],$l=[O.CLOSE_PATH];class ds extends lc{constructor(t,e,i,n){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=n,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){const e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){const i=this.getBufferedMaxExtent(),n=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=t.length;a<l;a+=e)n[0]=t[a],n[1]=t[a+1],un(i,n)&&(r[o++]=n[0],r[o++]=n[1]);return o}appendFlatLineCoordinates(t,e,i,n,r,o){const a=this.coordinates;let l=a.length;const h=this.getBufferedMaxExtent();o&&(e+=n);let c=t[e],u=t[e+1];const d=this.tmpCoordinate_;let f=!0,g,_,p;for(g=e+n;g<i;g+=n)d[0]=t[g],d[1]=t[g+1],p=Ao(h,d),p!==_?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):p===At.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],_=p;return(r&&f||g===e+n)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(t,e,i,n,r){for(let o=0,a=i.length;o<a;++o){const l=i[o],h=this.appendFlatLineCoordinates(t,e,l,n,!1,!1);r.push(h),e=l}return e}drawCustom(t,e,i,n,r){this.beginGeometry(t,e,r);const o=t.getType(),a=t.getStride(),l=this.coordinates.length;let h,c,u,d,f;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),d=[];const g=t.getEndss();f=0;for(let _=0,p=g.length;_<p;++_){const m=[];f=this.drawCustomCoordinates_(h,f,g[_],a,m),d.push(m)}this.instructions.push([O.CUSTOM,l,d,t,i,Wo,r]),this.hitDetectionInstructions.push([O.CUSTOM,l,d,t,n||i,Wo,r]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,t.getEnds(),a,u),this.instructions.push([O.CUSTOM,l,u,t,i,Kn,r]),this.hitDetectionInstructions.push([O.CUSTOM,l,u,t,n||i,Kn,r]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([O.CUSTOM,l,c,t,i,fi,r]),this.hitDetectionInstructions.push([O.CUSTOM,l,c,t,n||i,fi,r]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([O.CUSTOM,l,c,t,i,fi,r]),this.hitDetectionInstructions.push([O.CUSTOM,l,c,t,n||i,fi,r]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([O.CUSTOM,l,c,t,i,void 0,r]),this.hitDetectionInstructions.push([O.CUSTOM,l,c,t,n||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[O.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[O.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;t.reverse();let e;const i=t.length;let n,r,o=-1;for(e=0;e<i;++e)n=t[e],r=n[0],r==O.END_GEOMETRY?o=e:r==O.BEGIN_GEOMETRY&&(n[2]=e,Du(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=ke(i||Kt)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const i=t.getColor();e.strokeStyle=ke(i||Ne);const n=t.getLineCap();e.lineCap=n!==void 0?n:gn;const r=t.getLineDash();e.lineDash=r?r.slice():Je;const o=t.getLineDashOffset();e.lineDashOffset=o||Qe;const a=t.getLineJoin();e.lineJoin=a!==void 0?a:pn;const l=t.getWidth();e.lineWidth=l!==void 0?l:Qn;const h=t.getMiterLimit();e.miterLimit=h!==void 0?h:qn;const c=t.getOffset();e.strokeOffset=c??Jd,e.lineWidth>this.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){const i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){const e=t.fillStyle,i=[O.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[O.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;(i!==void 0&&typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,n=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit,c=t.strokeOffset;(t.currentStrokeStyle!=i||t.currentLineCap!=n||r!=t.currentLineDash&&!ei(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h||t.currentStrokeOffset!=c)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=n,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h,t.currentStrokeOffset=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[O.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Mh(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;En(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class af extends ds{constructor(t,e,i,n){super(t,e,i,n),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,i){if(!this.image_||this.maxExtent&&!un(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const n=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(n,r);this.instructions.push([O.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([O.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);const n=t.getFlatCoordinates(),r=[];for(let l=0,h=n.length;l<h;l+=t.getStride())(!this.maxExtent||un(this.maxExtent,n.slice(l,l+2)))&&r.push(n[l],n[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([O.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([O.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){const i=t.getAnchor(),n=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=n[1],this.opacity_=t.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=n[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}class lf extends ds{constructor(t,e,i,n){super(t,e,i,n)}drawFlatCoordinates_(t,e,i,n,r){const o=this.coordinates.length,a=this.appendFlatLineCoordinates(t,e,i,n,!1,!1);return this.instructions.push([O.MOVE_TO_LINE_TO,o,a,r*this.pixelRatio]),this.hitDetectionInstructions.push([O.MOVE_TO_LINE_TO,o,a,r]),i}drawLineString(t,e,i){const n=this.state,r=n.strokeStyle,o=n.lineWidth,a=n.strokeOffset;if(r===void 0||o===void 0)return;this.updateStrokeStyle(n,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([O.SET_STROKE_STYLE,Ne,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Je,Qe],bi);const l=t.getFlatCoordinates(),h=t.getStride();this.drawFlatCoordinates_(l,0,l.length,h,a),this.hitDetectionInstructions.push(gi),this.endGeometry(e)}drawMultiLineString(t,e,i){const n=this.state,r=n.strokeStyle,o=n.lineWidth,a=n.strokeOffset;if(r===void 0||o===void 0)return;this.updateStrokeStyle(n,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([O.SET_STROKE_STYLE,Ne,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Je,Qe],bi);const l=t.getEnds(),h=t.getFlatCoordinates(),c=t.getStride();let u=0;for(let d=0,f=l.length;d<f;++d)u=this.drawFlatCoordinates_(h,u,l[d],c,a);this.hitDetectionInstructions.push(gi),this.endGeometry(e)}finish(){const t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(gi),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(gi),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(bi)}}function Mr(s,t,e,i,n,r,o){const a=(e-t)/i;if(a<3){for(;t<e;t+=i)r[o++]=s[t],r[o++]=s[t+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[t,e-i];let c=0;for(;h.length>0;){const u=h.pop(),d=h.pop();let f=0;const g=s[d],_=s[d+1],p=s[u],m=s[u+1];for(let y=d+i;y<u;y+=i){const C=s[y],x=s[y+1],E=Wu(C,x,g,_,p,m);E>f&&(c=y,f=E)}f>n&&(l[(c-t)/i]=1,d+i<c&&h.push(d,c),c+i<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(r[o++]=s[t+u*i],r[o++]=s[t+u*i+1]);return o}function dc(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=Mr(s,t,c,i,n,r,o),a.push(o),t=c}return o}function Ci(s,t){return t*Math.round(s/t)}function hf(s,t,e,i,n,r,o){if(t==e)return o;let a=Ci(s[t],n),l=Ci(s[t+1],n);t+=i,r[o++]=a,r[o++]=l;let h,c;do if(h=Ci(s[t],n),c=Ci(s[t+1],n),t+=i,t==e)return r[o++]=h,r[o++]=c,o;while(h==a&&c==l);for(;t<e;){const u=Ci(s[t],n),d=Ci(s[t+1],n);if(t+=i,u==h&&d==c)continue;const f=h-a,g=c-l,_=u-a,p=d-l;if(f*p==g*_&&(f<0&&_<f||f==_||f>0&&_>f)&&(g<0&&p<g||g==p||g>0&&p>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 Ra(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=hf(s,t,c,i,n,r,o),a.push(o),t=c}return o}function cf(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l],u=[];o=Ra(s,t,c,i,n,r,o,u),a.push(u),t=c[c.length-1]}return o}class Bl extends ds{constructor(t,e,i,n){super(t,e,i,n)}drawFlatCoordinatess_(t,e,i,n,r){const o=this.state,a=o.fillStyle!==void 0,l=o.strokeStyle!==void 0,h=i.length;this.instructions.push(bi),this.hitDetectionInstructions.push(bi);for(let c=0;c<h;++c){const u=i[c],d=this.coordinates.length,f=this.appendFlatLineCoordinates(t,e,u,n,!0,!l);this.instructions.push([O.MOVE_TO_LINE_TO,d,f,r*this.pixelRatio,!0]),this.hitDetectionInstructions.push([O.MOVE_TO_LINE_TO,d,f,r,!0]),l&&(this.instructions.push($l),this.hitDetectionInstructions.push($l)),e=u}return a&&(this.instructions.push(As),this.hitDetectionInstructions.push(As)),l&&(this.instructions.push(gi),this.hitDetectionInstructions.push(gi)),e}drawCircle(t,e,i){const n=this.state,r=n.fillStyle,o=n.strokeStyle,a=n.strokeOffset;if(r===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawCircle(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([O.SET_FILL_STYLE,Kt]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([O.SET_STROKE_STYLE,Ne,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Je,Qe]);const l=t.getFlatCoordinates(),h=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(l,0,l.length,h,!1,!1);const u=[O.CIRCLE,c,a];this.instructions.push(bi,u),this.hitDetectionInstructions.push(bi,u),n.fillStyle!==void 0&&(this.instructions.push(As),this.hitDetectionInstructions.push(As)),n.strokeStyle!==void 0&&(this.instructions.push(gi),this.hitDetectionInstructions.push(gi)),this.endGeometry(e)}drawPolygon(t,e,i){const n=this.state,r=n.fillStyle,o=n.strokeStyle,a=n.strokeOffset;if(r===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([O.SET_FILL_STYLE,Kt]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([O.SET_STROKE_STYLE,Ne,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Je,Qe]);const l=t.getEnds(),h=t.getOrientedFlatCoordinates(),c=t.getStride();this.drawFlatCoordinatess_(h,0,l,c,a),this.endGeometry(e)}drawMultiPolygon(t,e,i){const n=this.state,r=n.fillStyle,o=n.strokeStyle,a=n.strokeOffset;if(r===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([O.SET_FILL_STYLE,Kt]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([O.SET_STROKE_STYLE,Ne,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Je,Qe]);const l=t.getEndss(),h=t.getOrientedFlatCoordinates(),c=t.getStride();let u=0;for(let d=0,f=l.length;d<f;++d)u=this.drawFlatCoordinatess_(h,u,l[d],c,a);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(t!==0){const e=this.coordinates;for(let i=0,n=e.length;i<n;++i)e[i]=Ci(e[i],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}handleStrokeOffset_(t){const e=this.state,i=e.fillStyle,n=e.strokeStyle,r=e.strokeOffset;return Math.abs(r)>0&&i!==void 0&&n!==void 0?(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=n,e.strokeOffset=r,t(),e.fillStyle=i,!0):!1}}function uf(s,t,e,i,n){const r=[];let o=e,a=0,l=t.slice(e,2);for(;a<s&&o+n<i;){const[h,c]=l.slice(-2),u=t[o+n],d=t[o+n+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=s){const g=(s-a+f)/f,_=se(h,u,g),p=se(c,d,g);l.push(_,p),r.push(l),l=[_,p],a==s&&(o+=n),a=0}else if(a<s)l.push(t[o+n],t[o+n+1]),o+=n;else{const g=f-a,_=se(h,u,g/f),p=se(c,d,g/f);l.push(_,p),r.push(l),l=[_,p],a=0,o+=n}}return a>0&&r.push(l),r}function df(s,t,e,i,n){let r=e,o=e,a=0,l=0,h=e,c,u,d,f,g,_,p,m,y,C;for(u=e;u<i;u+=n){const x=t[u],E=t[u+1];g!==void 0&&(y=x-g,C=E-_,f=Math.sqrt(y*y+C*C),p!==void 0&&(l+=d,c=Math.acos((p*y+m*C)/(d*f)),c>s&&(l>a&&(a=l,r=h,o=u),l=0,h=u-n)),d=f,p=y,m=C),g=x,_=E}return l+=f,l>a?[h,u]:[r,o]}const lr={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class ff extends ds{constructor(t,e,i,n){super(t,e,i,n),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Kt]={fillStyle:Kt},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const n=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!n&&!r)return;const a=this.coordinates;let l=a.length;const h=t.getType();let c=null,u=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!Vt(this.maxExtent,t.getExtent()))return;let d;if(c=t.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=t.getEnds();else if(h=="Polygon")d=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){const p=t.getEndss();d=[];for(let m=0,y=p.length;m<y;++m)d.push(p[m][0])}this.beginGeometry(t,e,i);const f=o.repeat,g=f?void 0:o.textAlign;let _=0;for(let p=0,m=d.length;p<m;++p){let y;f?y=uf(f*this.resolution,c,_,d[p],u):y=[c.slice(_,d[p])];for(let C=0,x=y.length;C<x;++C){const E=y[C];let S=0,w=E.length;if(g==null){const R=df(o.maxAngle,E,0,E.length,2);S=R[0],w=R[1]}for(let R=S;R<w;R+=u)a.push(E[R],E[R+1]);const T=a.length;_=d[p],this.drawChars_(l,T),l=T}}this.endGeometry(e)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=t.getFlatCoordinates();break;case"LineString":c=t.getFlatMidpoint();break;case"Circle":c=t.getCenter();break;case"MultiLineString":c=t.getFlatMidpoints(),u=2;break;case"Polygon":c=t.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":const x=t.getFlatInteriorPoints();c=[];for(let E=0,S=x.length;E<S;E+=3)o.overflow||d.push(x[E+2]/this.resolution),c.push(x[E],x[E+1]);if(c.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((E,S)=>{const w=a[(x+S)*2]===c[S*u]&&a[(x+S)*2+1]===c[S*u+1];return w||--x,w})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,_=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let p=o.padding;if(p!=Ri&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],E=o.padding[1],S=o.padding[2],w=o.padding[3];o.scale[0]<0&&(E=-E,w=-w),o.scale[1]<0&&(x=-x,S=-S),p=[x,E,S,w]}const m=this.pixelRatio;this.instructions.push([O.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,p==Ri?Ri:p.map(function(x){return x*m}),g,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const y=1/m,C=g?g.slice(0):null;C&&(C[1]=Kt),this.hitDetectionInstructions.push([O.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[y,y],NaN,this.declutterMode_,this.declutterImageWithText_,p,C,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Kt:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,n=this.strokeKey_;t&&(n in this.strokeStates||(this.strokeStates[n]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||Jn,justify:e.justify,textBaseline:e.textBaseline||ar,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,n=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=lr[n.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(n.scale[0])/2:0;this.instructions.push([O.DRAW_CHARS,t,e,h,n.overflow,a,n.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([O.DRAW_CHARS,t,e,h,n.overflow,a&&Kt,n.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,n,r;if(!t)this.text_="";else{const o=t.getFill();o?(n=this.textFillState_,n||(n={},this.textFillState_=n),n.fillStyle=ke(o.getColor()||Kt)):(n=null,this.textFillState_=n);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const _=a.getLineDash(),p=a.getLineDashOffset(),m=a.getWidth(),y=a.getMiterLimit();r.lineCap=a.getLineCap()||gn,r.lineDash=_?_.slice():Je,r.lineDashOffset=p===void 0?Qe:p,r.lineJoin=a.getLineJoin()||pn,r.lineWidth=m===void 0?Qn:m,r.miterLimit=y===void 0?qn:y,r.strokeStyle=ke(a.getColor()||Ne)}i=this.textState_;const l=t.getFont()||hc;ef(l);const h=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||ar,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||Ri,i.scale=h===void 0?[1,1]:h;const c=t.getOffsetX(),u=t.getOffsetY(),d=t.getRotateWithView(),f=t.getKeepUpright(),g=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:$(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=n&&n.fillStyle?typeof n.fillStyle=="string"?n.fillStyle:"|"+$(n.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const gf={Circle:Bl,Default:ds,Image:af,LineString:lf,Polygon:Bl,Text:ff};class pf{constructor(t,e,i,n){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=n,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const n in i){const r=i[n].finish();t[e][n]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let n=this.buildersByZIndex_[i];n===void 0&&(n={},this.buildersByZIndex_[i]=n);let r=n[e];if(r===void 0){const o=gf[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),n[e]=r}return r}}function ba(s,t,e,i){let n=s[t],r=s[t+1],o=0;for(let a=t+i;a<e;a+=i){const l=s[a],h=s[a+1];o+=Math.sqrt((l-n)*(l-n)+(h-r)*(h-r)),n=l,r=h}return o}function fc(s,t,e,i,n,r,o,a){o=o??[],a=a??i;const l=s[t+i],h=s[t+i+1],c=s[e-2*i],u=s[e-2*i+1];let d,f,g,_,p,m,y,C,x=0;for(let E=t;E<e;E+=i){g=d,_=f,p=void 0,m=void 0,E+i<e&&(p=s[E+i],m=s[E+i+1]),r&&E===t&&(g=c,_=u),r&&E===e-i&&(p=l,m=h),d=s[E],f=s[E+1],[y,C]=_f(d,f,g,_,p,m,n),o[x++]=y,o[x++]=C;for(let S=2;S<a;S++)o[x++]=s[E+S]}return o.length!=x&&(o.length=x),o}function _f(s,t,e,i,n,r,o){let a,l;e!==void 0&&i!==void 0?(a=s-e,l=t-i):n!==void 0&&r!==void 0?(a=n-s,l=r-t):(a=1,l=0);const h=Math.hypot(a,l),c=a/h,u=l/h;if(a=-u,l=c,e===void 0||i===void 0)return[s+a*o,t+l*o];if(n===void 0||r===void 0)return[s+a*o,t+l*o];const d=ju([s,t],[e,i],[n,r]);if(Math.cos(d)>.998)return[s+c*o,t+u*o];const f=Math.cos(d/2),g=Math.sin(d/2),_=g*a+f*l,p=-f*a+g*l,m=_*(1/g),y=p*(1/g);return[s+m*o,t+y*o]}function gc(s,t){for(let e=0,i=s.length-2;e<i;e+=t)for(let n=s.length-2*t;n>e+t;n-=t){const r=s[e],o=s[e+1],a=s[e+t],l=s[e+t+1],h=s[n],c=s[n+1],u=s[n+t],d=s[n+t+1],f=(d-c)*(a-r)-(u-h)*(l-o);if(f===0)continue;const g=((u-h)*(o-c)-(d-c)*(r-h))/f,_=((a-r)*(o-c)-(l-o)*(r-h))/f;if(g>0&&g<1&&_>0&&_<1){const p=r+g*(a-r),m=o+g*(l-o);s[e+t]=p,s[e+t+1]=m,s.splice(e+2*t,n-e-t);break}}return s}function mf(s,t,e,i,n,r,o,a,l,h,c,u,d=!0){let f=s[t],g=s[t+1],_=0,p=0,m=0,y=0;function C(){_=f,p=g,t+=i,f=s[t],g=s[t+1],y+=m,m=Math.sqrt((f-_)*(f-_)+(g-p)*(g-p))}do C();while(t<e-i&&y+m<r);let x=m===0?0:(r-y)/m;const E=se(_,f,x),S=se(p,g,x),w=t-i,T=y,R=r+a*l(h,n,c);for(;t<e-i&&y+m<R;)C();x=m===0?0:(R-y)/m;const b=se(_,f,x),L=se(p,g,x);let I=!1;if(d)if(u){const M=[E,S,b,L];va(M,0,4,2,u,M,M),I=M[0]>M[2]}else I=E>b;const F=Math.PI,D=[],k=w+i===t;t=w,m=0,y=T,f=s[t],g=s[t+1];let G;if(k){C(),G=Math.atan2(g-p,f-_),I&&(G+=G>0?-F:F);const M=(b+E)/2,N=(L+S)/2;return D[0]=[M,N,(R-r)/2,G,n],D}n=n.replace(/\n/g," ");for(let M=0,N=n.length;M<N;){C();let B=Math.atan2(g-p,f-_);if(I&&(B+=B>0?-F:F),G!==void 0){let mt=B-G;if(mt+=mt>F?-2*F:mt<-F?2*F:0,Math.abs(mt)>o)return null}G=B;const q=M;let K=0;for(;M<N;++M){const mt=I?N-M-1:M,Ot=a*l(h,n[mt],c);if(t+i<e&&y+m<r+K+Ot/2)break;K+=Ot}if(M===q)continue;const ct=I?n.substring(N-q,N-M):n.substring(q,M);x=m===0?0:(r+K/2-y)/m;const st=se(_,f,x),P=se(p,g,x);D.push([st,P,K/2,B,ct]),r+=K}return D}class pc{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(or(),{get:(t,e)=>{if(typeof or()[e]=="function")return this.push_(e),this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){const e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushMethodArgs_=(...t)=>(this.push_(t),this);pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,n=e.length;i<n;++i){const r=e[i];if(typeof r=="function"){r(t);continue}const o=e[++i];if(typeof t[r]=="function")t[r](...o);else{if(typeof o=="function"){t[r]=o(t);continue}t[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const Bi=Wt(),si=[],Xe=[],je=[],ri=[];function Wl(s){return s[3].declutterBox}const Ul=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function ro(s,t){return t==="start"?t=Ul.test(s)?"right":"left":t==="end"&&(t=Ul.test(s)?"left":"right"),lr[t]}function yf(s,t,e){return e>0&&s.push(`
|
|
4
|
+
`,""),s.push(t,""),s}function xf(s,t,e){return e%2===0&&(s+=t),s}class Ef{constructor(t,e,i,n,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=n.instructions,this.coordinates=n.coordinates,this.coordinateCache_={},this.renderedTransform_=Mt(),this.hitDetectionInstructions=n.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=n.fillStates||{},this.strokeStates=n.strokeStates||{},this.textStates=n.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new pc:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,n){const r=t+e+i+n;if(this.labels_[r])return this.labels_[r];const o=n?this.strokeStates[n]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?lr[l.justify]:ro(Array.isArray(t)?t[0]:t,l.textAlign||Jn),d=n&&o.lineWidth?o.lineWidth:0,f=Array.isArray(t)?t:String(t).split(`
|
|
5
|
+
`).reduce(yf,[]),{width:g,height:_,widths:p,heights:m,lineWidths:y}=sf(l,f),C=g+d,x=[],E=(C+2)*c[0],S=(_+d)*c[1],w={width:E<0?Math.floor(E):Math.ceil(E),height:S<0?Math.floor(S):Math.ceil(S),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),n&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",d),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),i&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const T=.5-u;let R=u*C+T*d;const b=[],L=[];let I=0,F=0,D=0,k=0,G;for(let M=0,N=f.length;M<N;M+=2){const B=f[M];if(B===`
|
|
6
|
+
`){F+=I,I=0,R=u*C+T*d,++k;continue}const q=f[M+1]||l.font;q!==G&&(n&&b.push("font",q),i&&L.push("font",q),G=q),I=Math.max(I,m[D]);const K=[B,R+T*p[D]+u*(p[D]-y[k]),.5*(d+I)+F];R+=p[D],n&&b.push("strokeText",K),i&&L.push("fillText",K),++D}return Array.prototype.push.apply(x,b),Array.prototype.push.apply(x,L),this.labels_[r]=w,w}replayTextBackground_(t,e,i,n,r,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,n),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,n,r,o,a,l,h,c,u,d,f,g,_,p){a*=d[0],l*=d[1];let m=i-a,y=n-l;const C=r+h>t?t-h:r,x=o+c>e?e-c:o,E=g[3]+C*d[0]+g[1],S=g[0]+x*d[1]+g[2],w=m-g[3],T=y-g[0];(_||u!==0)&&(si[0]=w,ri[0]=w,si[1]=T,Xe[1]=T,Xe[0]=w+E,je[0]=Xe[0],je[1]=T+S,ri[1]=je[1]);let R;return u!==0?(R=ge(Mt(),i,n,1,1,u,-i,-n),wt(R,si),wt(R,Xe),wt(R,je),wt(R,ri),ti(Math.min(si[0],Xe[0],je[0],ri[0]),Math.min(si[1],Xe[1],je[1],ri[1]),Math.max(si[0],Xe[0],je[0],ri[0]),Math.max(si[1],Xe[1],je[1],ri[1]),Bi)):ti(Math.min(w,w+E),Math.min(T,T+S),Math.max(w,w+E),Math.max(T,T+S),Bi),f&&(m=Math.round(m),y=Math.round(y)),{drawImageX:m,drawImageY:y,drawImageW:C,drawImageH:x,originX:h,originY:c,declutterBox:{minX:Bi[0],minY:Bi[1],maxX:Bi[2],maxY:Bi[3],value:p},canvasTransform:R,scale:d}}replayImageOrLabel_(t,e,i,n,r,o,a){const l=!!(o||a),h=n.declutterBox,c=a?a[2]*n.scale[0]/2:0;return h.minX-c<=e[0]&&h.maxX+c>=0&&h.minY-c<=e[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(t,si,Xe,je,ri,o,a),rf(t,n.canvasTransform,r,i,n.originX,n.originY,n.drawImageW,n.drawImageH,n.drawImageX,n.drawImageY,n.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=wt(this.renderedTransform_,[0,0]),n=512*this.pixelRatio;t.save(),t.translate(i[0]%n,i[1]%n),e!==1&&t.scale(e,e)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,n){const r=this.textStates[e],o=this.createLabel(t,e,n,i),a=this.strokeStates[i],l=this.pixelRatio,h=ro(Array.isArray(t)?t[0]:t,r.textAlign||Jn),c=lr[r.textBaseline||ar],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,n,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&ei(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Oe(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Jh(this.renderedTransform_,i));let u=0;const d=n.length;let f=0,g;const _=[];let p,m,y,C,x,E,S,w,T,R,b,L,I,F=0,D=0;const k=this.coordinateCache_,G=this.viewRotation_,M=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,N={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:G},B=this.instructions!=n||this.overlaps?0:200;let q,K,ct,st;for(;u<d;){const P=n[u];switch(P[0]){case O.BEGIN_GEOMETRY:q=P[1],st=P[3],q.getGeometry()?a!==void 0&&!Vt(a,st.getExtent())?u=P[2]+1:++u:u=P[2],h&&(h.zIndex=P[4]);break;case O.BEGIN_PATH:F>B&&(this.fill_(t),F=0),D>B&&(t.stroke(),D=0),!F&&!D&&(t.beginPath(),x=NaN,E=NaN),++u;break;case O.CIRCLE:f=P[1],y=P[2]??0;const Ot=c[f],Xt=c[f+1],ie=c[f+2]-y,mi=c[f+3]-y,ne=ie-Ot,xs=mi-Xt,Tn=Math.sqrt(ne*ne+xs*xs);t.moveTo(Ot+Tn,Xt),t.arc(Ot,Xt,Tn,0,2*Math.PI,!0),++u;break;case O.CLOSE_PATH:t.closePath(),++u;break;case O.CUSTOM:f=P[1],g=P[2];const Wr=P[3],Se=P[4],_e=P[5];N.geometry=Wr,N.feature=q,u in k||(k[u]=[]);const Re=k[u];_e?_e(c,f,g,2,Re):(Re[0]=c[f],Re[1]=c[f+1],Re.length=2),h&&(h.zIndex=P[6]),Se(Re,N),++u;break;case O.DRAW_IMAGE:f=P[1],g=P[2],T=P[3],p=P[4],m=P[5];let ni=P[6];const Es=P[7],Sn=P[8],zi=P[9],vs=P[10];let zt=P[11];const Su=P[12];let Cs=P[13];C=P[14]||"declutter";const Rn=P[15];if(!T&&P.length>=20){R=P[19],b=P[20],L=P[21],I=P[22];const Rt=this.drawLabelWithPointPlacement_(R,b,L,I);T=Rt.label,P[3]=T;const xi=P[23];p=(Rt.anchorX-xi)*this.pixelRatio,P[4]=p;const re=P[24];m=(Rt.anchorY-re)*this.pixelRatio,P[5]=m,ni=T.height,P[6]=ni,Cs=T.width,P[13]=Cs}let Ur;P.length>25&&(Ur=P[25]);let Xr,ws,Ts;P.length>17?(Xr=P[16],ws=P[17],Ts=P[18]):(Xr=Ri,ws=null,Ts=null),vs&&M?zt+=G:!vs&&!M&&(zt-=G);let Ru=0;for(;f<g;f+=2){if(Ur&&Ur[Ru++]<Cs/this.pixelRatio)continue;const Rt=this.calculateImageOrLabelDimensions_(T.width,T.height,c[f],c[f+1],Cs,ni,p,m,Sn,zi,zt,Su,r,Xr,!!ws||!!Ts,q),xi=[t,e,T,Rt,Es,ws,Ts];if(l){let re,be,oe;if(Rn){const Et=g-f;if(!Rn[Et]){Rn[Et]={args:xi,declutterMode:C};continue}const jt=Rn[Et];re=jt.args,be=jt.declutterMode,delete Rn[Et],oe=Wl(re)}let Be,We;if(re&&(be!=="declutter"||!l.collides(oe))&&(Be=!0),(C!=="declutter"||!l.collides(Rt.declutterBox))&&(We=!0),be==="declutter"&&C==="declutter"){const Et=Be&&We;Be=Et,We=Et}Be&&(be!=="none"&&l.insert(oe),this.replayImageOrLabel_.apply(this,re)),We&&(C!=="none"&&l.insert(Rt.declutterBox),this.replayImageOrLabel_.apply(this,xi))}else this.replayImageOrLabel_.apply(this,xi)}++u;break;case O.DRAW_CHARS:const pl=P[1],_l=P[2],jr=P[3],bu=P[4];I=P[5];const Pu=P[6],ml=P[7],yl=P[8];L=P[9];const Vr=P[10];R=P[11],Array.isArray(R)&&(R=R.reduce(xf,"")),b=P[12];const xl=[P[13],P[13]];C=P[14]||"declutter";const Lu=P[15],Yr=this.textStates[b],bn=Yr.font,Pn=[Yr.scale[0]*ml,Yr.scale[1]*ml];let Ln;bn in this.widths_?Ln=this.widths_[bn]:(Ln={},this.widths_[bn]=Ln);const El=ba(c,pl,_l,2),vl=Math.abs(Pn[0])*zl(bn,R,Ln);if(bu||vl<=El){const Rt=this.textStates[b].textAlign,xi=(El-vl)*ro(R,Rt),re=mf(c,pl,_l,2,R,xi,Pu,Math.abs(Pn[0]),zl,bn,Ln,M?0:this.viewRotation_,Lu);t:if(re){const be=[];let oe,Be,We,Et,jt;if(L)for(oe=0,Be=re.length;oe<Be;++oe){jt=re[oe],We=jt[4],Et=this.createLabel(We,b,"",L),p=jt[2]+(Pn[0]<0?-Vr:Vr),m=jr*Et.height+(.5-jr)*2*Vr*Pn[1]/Pn[0]-yl;const Ue=this.calculateImageOrLabelDimensions_(Et.width,Et.height,jt[0],jt[1],Et.width,Et.height,p,m,0,0,jt[3],xl,!1,Ri,!1,q);if(l&&C==="declutter"&&l.collides(Ue.declutterBox))break t;be.push([t,e,Et,Ue,1,null,null])}if(I)for(oe=0,Be=re.length;oe<Be;++oe){jt=re[oe],We=jt[4],Et=this.createLabel(We,b,I,""),p=jt[2],m=jr*Et.height-yl;const Ue=this.calculateImageOrLabelDimensions_(Et.width,Et.height,jt[0],jt[1],Et.width,Et.height,p,m,0,0,jt[3],xl,!1,Ri,!1,q);if(l&&C==="declutter"&&l.collides(Ue.declutterBox))break t;be.push([t,e,Et,Ue,1,null,null])}l&&C!=="none"&&l.load(be.map(Wl));for(let Ue=0,Iu=be.length;Ue<Iu;++Ue)this.replayImageOrLabel_.apply(this,be[Ue])}}++u;break;case O.END_GEOMETRY:if(o!==void 0){q=P[1];const Rt=o(q,st,C);if(Rt)return Rt}++u;break;case O.FILL:B?F++:this.fill_(t),++u;break;case O.MOVE_TO_LINE_TO:f=P[1],g=P[2],y=P[3];let yi,In,Ss;if(y){const Rt=P[4]??!1;fc(c,f,g,2,y,Rt,_),gc(_,2),yi=_,In=0,Ss=yi.length}else yi=c,In=f,Ss=g;K=yi[In],ct=yi[In+1],t.moveTo(K,ct),x=K+.5|0,E=ct+.5|0;for(let Rt=In+2;Rt<Ss;Rt+=2)K=yi[Rt],ct=yi[Rt+1],S=K+.5|0,w=ct+.5|0,(Rt==Ss-2||S!==x||w!==E)&&(t.lineTo(K,ct),x=S,E=w);++u;break;case O.SET_FILL_STYLE:this.alignAndScaleFill_=P[2],F?(this.fill_(t),F=0,D&&(t.stroke(),D=0)):D&&P[1]&&(t.stroke(),D=0),t.fillStyle=P[1],++u;break;case O.SET_STROKE_STYLE:F&&P[1]&&(this.fill_(t),F=0),D&&(t.stroke(),D=0),this.setStrokeStyle_(t,P),++u;break;case O.STROKE:B?D++:t.stroke(),++u;break;default:++u;break}}F&&this.fill_(t),D&&t.stroke()}execute(t,e,i,n,r,o){this.viewRotation_=n,this.execute_(t,e,i,this.instructions,r,void 0,void 0,o)}executeHitDetection(t,e,i,n,r){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,n,r)}}const wi=["Polygon","Circle","LineString","Image","Text","Default"],_c=["Image","Text"],vf=wi.filter(s=>!_c.includes(s));let mc=!1,yc=!1;function Cf(){let s=0;const t=i=>{const n=Tt(1,1,null,{willReadFrequently:i});let r=0;const o=performance.now();for(;performance.now()-o<50;++r)n.fillStyle=`rgba(255,0,${r%256},1)`,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1);return s=r>s?r:s,r};mc={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[s],yc=!0}class wf{constructor(t,e,i,n,r,o,a){this.maxExtent_=t,this.overlaps_=n,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Mt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(const i in t){let n=this.executorsByZIndex_[i];n===void 0&&(n={},this.executorsByZIndex_[i]=n);const r=t[i];for(const o in r){const a=r[o];n[o]=new Ef(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let n=0,r=t.length;n<r;++n)if(t[n]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,n,r,o){yc===!1&&Cf(),n=Math.round(n);const a=n*2+1,l=ge(this.hitDetectionTransform_,n+.5,n+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=Tt(a,a,null,{willReadFrequently:mc}));const c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=Wt(),Wn(u,t),En(u,e*(this.renderBuffer_+n),u));const d=Tf(n);let f;function g(E,S,w){const T=c.getImageData(0,0,a,a).data;for(let R=0,b=d.length;R<b;R++)if(T[d[R]]>0){if(!o||w==="none"||f!=="Image"&&f!=="Text"||o.includes(E)){const L=(d[R]-3)/4,I=n-L%a,F=n-(L/a|0),D=r(E,S,I*I+F*F);if(D)return D}c.clearRect(0,0,a,a);break}}const _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(Ke);let p,m,y,C,x;for(p=_.length-1;p>=0;--p){const E=_[p].toString();for(y=this.executorsByZIndex_[E],m=wi.length-1;m>=0;--m)if(f=wi[m],C=y[f],C!==void 0&&(x=C.executeHitDetection(c,l,i,g,u),x))return x}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],n=e[1],r=e[2],o=e[3],a=[i,n,i,o,r,o,r,n];return Oe(a,0,8,2,t,a),a}isEmpty(){return Ai(this.executorsByZIndex_)}execute(t,e,i,n,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?Au:Ke),o=o||wi;const h=wi.length;for(let c=0,u=l.length;c<u;++c){const d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,_=o.length;g<_;++g){const p=o[g],m=f[p];if(m!==void 0){const y=a===null?void 0:m.getZIndexContext(),C=y?y.getContext():t,x=this.maxExtent_&&p!=="Image"&&p!=="Text";if(x&&(C.save(),this.clip(C,i)),!y||p==="Text"||p==="Image"?m.execute(C,e,i,n,r,a):y.pushFunction(E=>m.execute(E,e,i,n,r,a)),x&&C.restore(),y){y.offset();const E=l[c]*h+wi.indexOf(p);this.deferredZIndexContexts_[E]||(this.deferredZIndexContexts_[E]=[]),this.deferredZIndexContexts_[E].push(y)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(Ke);for(let i=0,n=e.length;i<n;++i)t[e[i]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const oo={};function Tf(s){if(oo[s]!==void 0)return oo[s];const t=s*2+1,e=s*s,i=new Array(e+1);for(let r=0;r<=s;++r)for(let o=0;o<=s;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((s+r)*t+(s+o))*4+3),r>0&&l.push(((s-r)*t+(s+o))*4+3),o>0&&(l.push(((s+r)*t+(s-o))*4+3),r>0&&l.push(((s-r)*t+(s-o))*4+3))}const n=[];for(let r=0,o=i.length;r<o;++r)i[r]&&n.push(...i[r]);return oo[s]=n,n}function Xl(s){return s[0]>0&&s[1]>0}function Sf(s,t,e){return e===void 0&&(e=[0,0]),e[0]=s[0]*t+.5|0,e[1]=s[1]*t+.5|0,e}function Zt(s,t){return Array.isArray(s)?s:(t===void 0?t=[s,s]:(t[0]=s,t[1]=s),t)}class Ar{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=Zt(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Ar({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return X()}getImage(t){return X()}getHitDetectionImage(){return X()}getPixelRatio(t){return 1}getImageState(){return X()}getImageSize(){return X()}getOrigin(){return X()}getSize(){return X()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=Zt(t)}listenImageChange(t){X()}load(){X()}unlistenImageChange(t){X()}ready(){return Promise.resolve()}}function jl(s,t,e,i){return e!==void 0&&i!==void 0?[e/s,i/t]:e!==void 0?e/s:i!==void 0?i/t:1}class Dr extends Ar{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,n=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:n,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy;const o=t.img!==void 0?t.img:null;let a=t.src;Q(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||$(o)),Q(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),Q(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=Y.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?Y.LOADED:Y.IDLE:l=Y.LOADING:l=Y.LOADED),this.color_=t.color!==void 0?pe(t.color):null,this.iconImage_=jn(o,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let h,c;if(t.size)[h,c]=t.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(jl(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(jl(h,c,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new Dr({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const n=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!n)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=n[0]),this.anchorYUnits_=="fraction"&&(t[1]*=n[1])}if(this.anchorOrigin_!="top-left"){if(!n)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+n[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+n[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){const e=t?pe(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((o,a)=>o===e[a]))return;this.color_=e;const i=this.getSrc(),n=i!==void 0?null:this.getHitDetectionImage(),r=i!==void 0?Y.IDLE:this.iconImage_.getImageState();this.iconImage_=jn(n,i,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},r,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=jn(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},Y.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==Y.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){const t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==Y.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(j.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(j.CHANGE,t)}ready(){return this.iconImage_.ready()}}class Rf extends lc{constructor(t,e,i,n,r,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=n,this.transformRotation_=n?hs(Math.atan2(n[1],n[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=Mt()}drawImages_(t,e,i,n){if(!this.image_)return;const r=Oe(t,e,i,n,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=r.length;c<u;c+=2){const d=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,_=f+this.imageAnchorY_;ge(a,g,_,1,1,h,-g,-_),o.save(),o.transform.apply(o,a),o.translate(g,_),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(t,e,i,n){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Oe(t,e,i,n,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=n){const l=r[e]+this.textOffsetX_,h=r[e+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(t,e,i,n,r,o){const a=this.context_;let l=Oe(t,e,i,n,this.transform_,this.pixelCoordinates_);Math.abs(o)>0&&(l=fc(l,0,l.length,2,o,r,l),gc(l,2)),a.moveTo(l[0],l[1]);let h=l.length;r&&(h-=2);for(let c=2;c<h;c+=2)a.lineTo(l[c],l[c+1]);return r&&a.closePath(),i}drawRings_(t,e,i,n,r){for(let o=0,a=i.length;o<a;++o)e=this.moveToLineTo_(t,e,i[o],n,!0,r);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vt(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=Id(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],n=e[3]-e[1],r=Math.sqrt(i*i+n*n),o=this.context_;o.beginPath(),o.arc(e[0],e[1],r,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break}}drawFeature(t,e){const i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let i=0,n=e.length;i<n;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vt(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1,this.strokeState_.strokeOffset),e.stroke()}if(this.text_!==""){const e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getExtent();if(Vt(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const i=this.context_,n=t.getFlatCoordinates();let r=0;const o=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)r=this.moveToLineTo_(n,r,o[l],a,!1,this.strokeState_.strokeOffset);i.stroke()}if(this.text_!==""){const i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride(),this.strokeState_?.strokeOffset),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getOrientedFlatCoordinates();let n=0;const r=t.getEndss(),o=t.getStride();e.beginPath();for(let a=0,l=r.length;a<l;++a){const h=r[a];n=this.drawRings_(i,n,h,o,this.strokeState_?.strokeOffset)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){const e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),ei(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){const e=this.context_,i=this.contextTextState_,n=t.textAlign?t.textAlign:Jn;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=n&&(i.textAlign=n,e.textAlign=n),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=n,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:n,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{const i=t.getColor();this.fillState_={fillStyle:ke(i||Kt)}}if(!e)this.strokeState_=null;else{const i=e.getColor(),n=e.getLineCap(),r=e.getLineDash(),o=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),h=e.getMiterLimit(),c=r||Je,u=e.getOffset();this.strokeState_={lineCap:n!==void 0?n:gn,lineDash:this.pixelRatio_===1?c:c.map(d=>d*this.pixelRatio_),lineDashOffset:(o||Qe)*this.pixelRatio_,lineJoin:a!==void 0?a:pn,lineWidth:(l!==void 0?l:Qn)*this.pixelRatio_,miterLimit:h!==void 0?h:qn,strokeStyle:ke(i||Ne),strokeOffset:(u??0)*this.pixelRatio_}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),n=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=n[0]*i,this.imageAnchorY_=n[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{const e=t.getFill();if(!e)this.textFillState_=null;else{const f=e.getColor();this.textFillState_={fillStyle:ke(f||Kt)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),_=i.getLineDash(),p=i.getLineDashOffset(),m=i.getLineJoin(),y=i.getWidth(),C=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:gn,lineDash:_||Je,lineDashOffset:p||Qe,lineJoin:m!==void 0?m:pn,lineWidth:y!==void 0?y:Qn,miterLimit:C!==void 0?C:qn,strokeStyle:ke(f||Ne)}}const n=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:n!==void 0?n:hc,textAlign:u!==void 0?u:Jn,textBaseline:d!==void 0?d:ar},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,_)=>f+=_%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 Ae=.5;function bf(s,t,e,i,n,r,o,a,l){const h=n,c=s[0]*Ae,u=s[1]*Ae,d=Tt(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new Rf(d,Ae,n,null,o,a,null),_=e.length,p=Math.floor((256*256*256-1)/_),m={};for(let C=1;C<=_;++C){const x=e[C-1],E=x.getStyleFunction()||i;if(!E)continue;let S=E(x,r);if(!S)continue;Array.isArray(S)||(S=[S]);const T=(C*p).toString(16).padStart(7,"#00000");for(let R=0,b=S.length;R<b;++R){const L=S[R],I=L.getGeometryFunction()(x);if(!I||!Vt(h,I.getExtent()))continue;const F=L.clone(),D=F.getFill();D&&D.setColor(T);const k=F.getStroke();k&&(k.setColor(T),k.setLineDash(null)),F.setText(void 0);const G=L.getImage();if(G){const q=G.getImageSize();if(!q)continue;const K=Tt(q[0],q[1],void 0,{alpha:!1}),ct=K.canvas;K.fillStyle=T,K.fillRect(0,0,ct.width,ct.height),F.setImage(new Dr({img:ct,anchor:G.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:G.getOrigin(),opacity:1,size:G.getSize(),scale:G.getScale(),rotation:G.getRotation(),rotateWithView:G.getRotateWithView()}))}const M=F.getZIndex()||0;let N=m[M];N||(N={},m[M]=N,N.Polygon=[],N.Circle=[],N.LineString=[],N.Point=[]);const B=I.getType();if(B==="GeometryCollection"){const q=I.getGeometriesArrayRecursive();for(let K=0,ct=q.length;K<ct;++K){const st=q[K];N[st.getType().replace("Multi","")].push(st,F)}}else N[B.replace("Multi","")].push(I,F)}}const y=Object.keys(m).map(Number).sort(Ke);for(let C=0,x=y.length;C<x;++C){const E=m[y[C]];for(const S in E){const w=E[S];for(let T=0,R=w.length;T<R;T+=2){g.setStyle(w[T+1]);for(let b=0,L=t.length;b<L;++b)g.setTransform(t[b]),g.drawGeometry(w[T])}}}return d.getImageData(0,0,f.width,f.height)}function Pf(s,t,e){const i=[];if(e){const n=Math.floor(Math.round(s[0])*Ae),r=Math.floor(Math.round(s[1])*Ae),o=(pt(n,0,e.width-1)+pt(r,0,e.height-1)*e.width)*4,a=e.data[o],l=e.data[o+1],c=e.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/t.length);c&&c%u===0&&i.push(t[c/u-1])}return i}const Lf=.5,xc={Point:Nf,LineString:kf,Polygon:zf,MultiPoint:Gf,MultiLineString:Ff,MultiPolygon:Of,GeometryCollection:Df,Circle:Mf};function If(s,t){return parseInt($(s),10)-parseInt($(t),10)}function Vl(s,t){const e=Ec(s,t);return e*e}function Ec(s,t){return Lf*s/t}function Mf(s,t,e,i,n){const r=e.getFill(),o=e.getStroke();if(r||o){const l=s.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(t,i,n)}const a=e.getText();if(a&&a.getText()){const l=s.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,n)}}function Yl(s,t,e,i,n,r,o,a){const l=[],h=e.getImage();if(h){let d=!0;const f=h.getImageState();f==Y.LOADED||f==Y.ERROR?d=!1:f==Y.IDLE&&h.load(),d&&l.push(h.ready())}const c=e.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>n(null)),Af(s,t,e,i,r,o,a),u}function Af(s,t,e,i,n,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,n);if(e.getRenderer())vc(s,l,e,t,o);else{const c=xc[l.getType()];c(s,l,e,t,o,r)}}function vc(s,t,e,i,n){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)vc(s,o[a],e,i,n);return}s.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),n)}function Df(s,t,e,i,n,r){const o=t.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=xc[o[a].getType()];h(s,o[a],e,i,n,r)}}function kf(s,t,e,i,n){const r=e.getStroke();if(r){const a=s.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(t,i,n)}const o=e.getText();if(o&&o.getText()){const a=s.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,n)}}function Ff(s,t,e,i,n){const r=e.getStroke();if(r){const a=s.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(t,i,n)}const o=e.getText();if(o&&o.getText()){const a=s.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,n)}}function Of(s,t,e,i,n){const r=e.getFill(),o=e.getStroke();if(o||r){const l=s.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(t,i,n)}const a=e.getText();if(a&&a.getText()){const l=s.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,n)}}function Nf(s,t,e,i,n,r){const o=e.getImage(),a=e.getText(),l=a&&a.getText(),h=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=Y.LOADED)return;const c=s.getBuilder(e.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(t,i,n)}if(l){const c=s.getBuilder(e.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(t,i,n)}}function Gf(s,t,e,i,n,r){const o=e.getImage(),a=o&&o.getOpacity()!==0,l=e.getText(),h=l&&l.getText(),c=r&&a&&h?{}:void 0;if(a){if(o.getImageState()!=Y.LOADED)return;const u=s.getBuilder(e.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(t,i,n)}if(h){const u=s.getBuilder(e.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(t,i,n)}}function zf(s,t,e,i,n){const r=e.getFill(),o=e.getStroke();if(r||o){const l=s.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(t,i,n)}const a=e.getText();if(a&&a.getText()){const l=s.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,n)}}class Vn extends $e{constructor(t,e,i,n){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=n}}const $f=5;class Cc extends os{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=$f}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return X()}getData(t){return null}prepareFrame(t){return X()}renderFrame(t,e){return X()}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===Y.LOADED||e.getState()===Y.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=Y.LOADED&&e!=Y.ERROR&&t.addEventListener(j.CHANGE,this.boundHandleImageChange_),e==Y.IDLE&&(t.load(),e=t.getState()),e==Y.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Zl=[];let qi=null;function Bf(){qi=Tt(1,1,void 0,{willReadFrequently:!0})}class wc extends Cc{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=Mt(),this.pixelTransform=Mt(),this.inversePixelTransform=Mt(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){qi||Bf(),qi.clearRect(0,0,1,1);let n;try{qi.drawImage(t,e,i,1,1,0,0,1,1),n=qi.getImageData(0,0,1,1).data}catch{return qi=null,null}return n}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i){const n=this.getLayer().getClassName();let r,o;if(t&&t.className===n&&(!i||t&&t.style.backgroundColor&&ei(pe(t.style.backgroundColor),pe(i)))){const a=t.firstElementChild;di(a)&&(o=a.getContext("2d"))}if(o&&Rd(o.canvas.style.transform,e)?(this.container=t,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=le?rc():document.createElement("div"),r.className=n;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=Tt();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){const n=Fi(i),r=wr(i),o=Cr(i),a=vr(i);wt(e.coordinateToPixelTransform,n),wt(e.coordinateToPixelTransform,r),wt(e.coordinateToPixelTransform,o),wt(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;wt(l,n),wt(l,r),wt(l,o),wt(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(n[0]),Math.round(n[1])),t.lineTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()}prepareContainer(t,e){const i=t.extent,n=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,a=Math.round(at(i)/n*o),l=Math.round(Yt(i)/n*o);ge(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),br(this.inversePixelTransform,this.pixelTransform);const h=Sd(this.pixelTransform);if(this.useContainer(e,h,this.getBackground(t)),!this.containerReused){const c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){const r=new Vn(t,this.inversePixelTransform,i,e);n.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(kt.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(kt.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new pc),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(kt.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(kt.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,n,r,o,a){const l=r/2,h=o/2,c=n/e,u=-c,d=-t[0]+a,f=-t[1];return ge(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class Wf extends wc{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Wt(),this.wrappedRenderedExtent_=Wt(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,i){const n=e.extent,r=e.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,_=!(g[Dt.ANIMATING]||g[Dt.INTERACTING]),p=this.context,m=Math.round(at(n)/a*f),y=Math.round(Yt(n)/a*f),C=u.getWrapX()&&l.canWrapX(),x=C?at(c):null,E=C?Math.ceil((n[2]-c[2])/x)+(this.extendX_?2:1):1;let S=C?Math.floor((n[0]-c[0])/x)-(this.extendX_?1:0):0;do{let w=this.getRenderTransform(o,a,0,f,m,y,S*x);e.declutter&&(w=w.slice(0)),t.execute(p,[p.canvas.width,p.canvas.height],w,h,_,i===void 0?wi:i?_c:vf,i?d&&e.declutter[d]:void 0)}while(++S<E)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Tt(this.context.canvas.width,this.context.canvas.height,Zl))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,Lr(this.context),Zl.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.clipExtent_&&this.clipUnrotated(this.context,t,this.clipExtent_),this.replayGroup_.renderDeferred(),this.clipExtent_&&(this.context.restore(),this.clipExtent_=null),this.resetDrawContext_())}renderFrame(t,e){const i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;const n=t.viewState;this.prepareContainer(t,e);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(kt.PRERENDER)||this.getLayer().hasListener(kt.POSTRENDER)))return this.container;this.setDrawContext_(),this.preRender(r,t),n.projection,this.clipExtent_=null;let l=!1;if(a&&i.extent&&this.clipping){const h=Si(i.extent);a=Vt(h,t.extent),a&&!On(h,t.extent)&&(t.declutter?this.clipExtent_=h:(this.clipUnrotated(r,t,h),l=!0))}return a&&this.renderWorlds(o,t,this.getLayer().getDeclutter()?!1:void 0),l&&r.restore(),this.postRender(r,t),this.renderedRotation_!==n.rotation&&(this.renderedRotation_=n.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),n=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*Ae,d=i[1]*Ae;c.push(this.getRenderTransform(n,r,o,Ae,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!On(g,l)){let _=l[0];const p=at(g);let m=0,y;for(;_<g[0];)--m,y=p*m,c.push(this.getRenderTransform(n,r,o,Ae,u,d,y).slice()),_+=p;for(m=0,_=l[2];_>g[2];)++m,y=p*m,c.push(this.getRenderTransform(n,r,o,Ae,u,d,y).slice()),_-=p}this.hitDetectionImageData_=bf(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,Vl(r,this.renderedPixelRatio_))}e(Pf(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,n,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){const _=$(d),p=h[_];if(p){if(p!==!0&&g<p.distanceSq){if(g===0)return h[_]=!0,r.splice(r.lastIndexOf(p),1),n(d,l,f);p.geometry=f,p.distanceSq=g}}else{if(g===0)return h[_]=!0,n(d,l,f);r.push(h[_]={feature:d,layer:l,geometry:f,distanceSq:g,callback:n})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,u?e.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const n=t.viewHints[Dt.ANIMATING],r=t.viewHints[Dt.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&n||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,h=t.viewState,c=h.projection,u=h.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let _=e.getRenderOrder();_===void 0&&(_=If);const p=h.center.slice(),m=En(l,g*u),y=m.slice(),C=[m.slice()],x=c.getExtent(),E=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,E){const k=i.getExtent();k&&!ls(k)&&(this.extendX_=k[0]<x[0]||k[2]>x[2])}if(E&&(!On(x,t.extent)||this.extendX_)){const k=at(x),G=Math.max(at(m)/2,k);let M=x[0],N=x[2];this.extendX_&&(M-=k,N+=k),m[0]=M-G,m[2]=N+G,Bh(p,c);const B=kh(C[0],c);B[0]<x[0]&&B[2]<x[2]?C.push([B[0]+k,B[1],B[2]+k,B[3]]):B[0]>x[0]&&B[2]>x[2]&&C.push([B[0]-k,B[1],B[2]-k,B[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedPixelRatio_===d&&this.renderedRevision_==f&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!t.declutter&&On(this.wrappedRenderedExtent_,m))return ei(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=p,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const S=new pf(Ec(u,d),m,u,d);let w;for(let k=0,G=C.length;k<G;++k)i.loadFeatures(C[k],u,c);const T=Vl(u,d);let R=!0;const b=(k,G)=>{let M;const N=k.getStyleFunction()||e.getStyleFunction();if(N&&(M=N(k,u)),M){const B=this.renderFeature(k,T,M,S,w,this.getLayer().getDeclutter(),G);R=R&&!B}},L=Kh(m),I=i.getFeaturesInExtent(L);_&&I.sort(_);for(let k=0,G=I.length;k<G;++k)b(I[k],k);this.renderedFeatures_=I,this.ready=R;const F=S.finish(),D=new wf(m,u,d,i.getOverlaps(),F,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=_,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=y,this.wrappedRenderedExtent_=m,this.renderedCenter_=p,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=D,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,n,r,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=Yl(n,t,i[h],e,this.boundHandleStyleImageChange_,r,o,a)||l;else l=Yl(n,t,i,e,this.boundHandleStyleImageChange_,r,o,a);return l}}function Tc(s,t,e=0,i=s.length-1,n=Uf){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),g=Math.min(i,Math.floor(t+(l-h)*u/l+d));Tc(s,t,f,g,n)}const r=s[t];let o=e,a=i;for(kn(s,e,t),n(s[i],r)>0&&kn(s,e,i);o<a;){for(kn(s,o,a),o++,a--;n(s[o],r)<0;)o++;for(;n(s[a],r)>0;)a--}n(s[e],r)===0?kn(s,e,a):(a++,kn(s,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function kn(s,t,e){const i=s[t];s[t]=s[e],s[e]=i}function Uf(s,t){return s<t?-1:s>t?1:0}let Sc=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!ks(t,e))return i;const n=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?n(a):a;ks(t,l)&&(e.leaf?i.push(a):lo(t,l)?this._all(a,i):r.push(a))}e=r.pop()}return i}collides(t){let e=this.data;if(!ks(t,e))return!1;const i=[];for(;e;){for(let n=0;n<e.children.length;n++){const r=e.children[n],o=e.leaf?this.toBBox(r):r;if(ks(t,o)){if(e.leaf||lo(t,o))return!0;i.push(r)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Ji([]),this}remove(t,e){if(!t)return this;let i=this.data;const n=this.toBBox(t),r=[],o=[];let a,l,h;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),i.leaf){const c=Xf(t,i.children,e);if(c!==-1)return i.children.splice(c,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&lo(i,n)?(r.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,n){const r=i-e+1;let o=this._maxEntries,a;if(r<=o)return a=Ji(t.slice(e,i+1)),Wi(a,this.toBBox),a;n||(n=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,n-1))),a=Ji([]),a.leaf=!1,a.height=n;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));Hl(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);Hl(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,n-1))}}return Wi(a,this.toBBox),a}_chooseSubtree(t,e,i,n){for(;n.push(e),!(e.leaf||n.length-1===i);){let r=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=ao(h),u=Yf(t,h)-c;u<o?(o=u,r=c<r?c:r,a=h):u===o&&c<r&&(r=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const n=i?t:this.toBBox(t),r=[],o=this._chooseSubtree(n,this.data,e,r);for(o.children.push(t),Gn(o,n);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)}_split(t,e){const i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const o=this._chooseSplitIndex(i,r,n),a=Ji(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Wi(i,this.toBBox),Wi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Ji([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Wi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Nn(t,0,a,this.toBBox),h=Nn(t,a,i,this.toBBox),c=Zf(l,h),u=ao(l)+ao(h);c<r?(r=c,n=a,o=u<o?u:o):c===r&&u<o&&(o=u,n=a)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:jf,r=t.leaf?this.compareMinY:Vf,o=this._allDistMargin(t,e,i,n),a=this._allDistMargin(t,e,i,r);o<a&&t.children.sort(n)}_allDistMargin(t,e,i,n){t.children.sort(n);const r=this.toBBox,o=Nn(t,0,e,r),a=Nn(t,i-e,i,r);let l=Ds(o)+Ds(a);for(let h=e;h<i-e;h++){const c=t.children[h];Gn(o,t.leaf?r(c):c),l+=Ds(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];Gn(a,t.leaf?r(c):c),l+=Ds(a)}return l}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)Gn(e[n],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():Wi(t[e],this.toBBox)}};function Xf(s,t,e){if(!e)return t.indexOf(s);for(let i=0;i<t.length;i++)if(e(s,t[i]))return i;return-1}function Wi(s,t){Nn(s,0,s.children.length,t,s)}function Nn(s,t,e,i,n){n||(n=Ji(null)),n.minX=1/0,n.minY=1/0,n.maxX=-1/0,n.maxY=-1/0;for(let r=t;r<e;r++){const o=s.children[r];Gn(n,s.leaf?i(o):o)}return n}function Gn(s,t){return s.minX=Math.min(s.minX,t.minX),s.minY=Math.min(s.minY,t.minY),s.maxX=Math.max(s.maxX,t.maxX),s.maxY=Math.max(s.maxY,t.maxY),s}function jf(s,t){return s.minX-t.minX}function Vf(s,t){return s.minY-t.minY}function ao(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function Ds(s){return s.maxX-s.minX+(s.maxY-s.minY)}function Yf(s,t){return(Math.max(t.maxX,s.maxX)-Math.min(t.minX,s.minX))*(Math.max(t.maxY,s.maxY)-Math.min(t.minY,s.minY))}function Zf(s,t){const e=Math.max(s.minX,t.minX),i=Math.max(s.minY,t.minY),n=Math.min(s.maxX,t.maxX),r=Math.min(s.maxY,t.maxY);return Math.max(0,n-e)*Math.max(0,r-i)}function lo(s,t){return s.minX<=t.minX&&s.minY<=t.minY&&t.maxX<=s.maxX&&t.maxY<=s.maxY}function ks(s,t){return t.minX<=s.maxX&&t.minY<=s.maxY&&t.maxX>=s.minX&&t.maxY>=s.minY}function Ji(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Hl(s,t,e,i,n){const r=[t,e];for(;r.length;){if(e=r.pop(),t=r.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;Tc(s,o,t,e,n),r.push(t,o,o,e)}}let Ni=0;const bt=1<<Ni++,A=1<<Ni++,It=1<<Ni++,yt=1<<Ni++,ee=1<<Ni++,ce=1<<Ni++,Fs=Math.pow(2,Ni)-1,Pa={[bt]:"boolean",[A]:"number",[It]:"string",[yt]:"color",[ee]:"number[]",[ce]:"size"},Hf=Object.keys(Pa).map(Number).sort(Ke);function Kf(s){return s in Pa}function en(s){const t=[];for(const e of Hf)zn(s,e)&&t.push(Pa[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function zn(s,t){return(s&t)===t}function Ie(s,t){return s===t}class Lt{constructor(t,e){if(!Kf(t))throw new Error(`literal expressions must have a specific type, got ${en(t)}`);this.type=t,this.value=e}}class Rc{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function fs(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1}}function Ft(s,t,e){switch(typeof s){case"boolean":{if(Ie(t,It))return new Lt(It,s?"true":"false");if(!zn(t,bt))throw new Error(`got a boolean, but expected ${en(t)}`);return new Lt(bt,s)}case"number":{if(Ie(t,ce))return new Lt(ce,Zt(s));if(Ie(t,bt))return new Lt(bt,!!s);if(Ie(t,It))return new Lt(It,s.toString());if(!zn(t,A))throw new Error(`got a number, but expected ${en(t)}`);return new Lt(A,s)}case"string":{if(Ie(t,yt))return new Lt(yt,wa(s));if(Ie(t,bt))return new Lt(bt,!!s);if(!zn(t,It))throw new Error(`got a string, but expected ${en(t)}`);return new Lt(It,s)}}if(!Array.isArray(s))throw new Error("expression must be an array or a primitive value");if(s.length===0)throw new Error("empty expression");if(typeof s[0]=="string")return lg(s,t,e);for(const i of s)if(typeof i!="number")throw new Error("expected an array of numbers");if(Ie(t,ce)){if(s.length!==2)throw new Error(`expected an array of two values for a size, got ${s.length}`);return new Lt(ce,s)}if(Ie(t,yt)){if(s.length===3)return new Lt(yt,[...s,1]);if(s.length===4)return new Lt(yt,s);throw new Error(`expected an array of 3 or 4 values for a color, got ${s.length}`)}if(!zn(t,ee))throw new Error(`got an array of numbers, but expected ${en(t)}`);return new Lt(ee,s)}const v={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},qf={[v.Get]:W(Z(1,1/0),Kl),[v.Var]:W(Z(1,1),Jf),[v.Has]:W(Z(1,1/0),Kl),[v.Id]:W(Qf,Ui),[v.Concat]:W(Z(2,1/0),et(It)),[v.GeometryType]:W(tg,Ui),[v.LineMetric]:W(eg,Ui),[v.Resolution]:W(ho,Ui),[v.Zoom]:W(ho,Ui),[v.Time]:W(ho,Ui),[v.Any]:W(Z(2,1/0),et(bt)),[v.All]:W(Z(2,1/0),et(bt)),[v.Not]:W(Z(1,1),et(bt)),[v.Equal]:W(Z(2,2),et(Fs)),[v.NotEqual]:W(Z(2,2),et(Fs)),[v.GreaterThan]:W(Z(2,2),et(A)),[v.GreaterThanOrEqualTo]:W(Z(2,2),et(A)),[v.LessThan]:W(Z(2,2),et(A)),[v.LessThanOrEqualTo]:W(Z(2,2),et(A)),[v.Multiply]:W(Z(2,1/0),ql),[v.Coalesce]:W(Z(2,1/0),ql),[v.Divide]:W(Z(2,2),et(A)),[v.Add]:W(Z(2,1/0),et(A)),[v.Subtract]:W(Z(2,2),et(A)),[v.Clamp]:W(Z(3,3),et(A)),[v.Mod]:W(Z(2,2),et(A)),[v.Pow]:W(Z(2,2),et(A)),[v.Abs]:W(Z(1,1),et(A)),[v.Floor]:W(Z(1,1),et(A)),[v.Ceil]:W(Z(1,1),et(A)),[v.Round]:W(Z(1,1),et(A)),[v.Sin]:W(Z(1,1),et(A)),[v.Cos]:W(Z(1,1),et(A)),[v.Atan]:W(Z(1,2),et(A)),[v.Sqrt]:W(Z(1,1),et(A)),[v.Match]:W(Z(4,1/0),Jl,ng),[v.Between]:W(Z(3,3),et(A)),[v.Interpolate]:W(Z(6,1/0),Jl,sg),[v.Case]:W(Z(3,1/0),ig,rg),[v.In]:W(Z(2,2),og),[v.Number]:W(Z(1,1/0),et(Fs)),[v.String]:W(Z(1,1/0),et(Fs)),[v.Array]:W(Z(1,1/0),et(A)),[v.Color]:W(Z(1,4),et(A)),[v.Band]:W(Z(1,3),et(A)),[v.Palette]:W(Z(2,2),ag),[v.ToString]:W(Z(1,1),et(bt|A|It|yt))};function Kl(s,t,e){const i=s.length-1,n=new Array(i);for(let r=0;r<i;++r){const o=s[r+1];switch(typeof o){case"number":{n[r]=new Lt(A,o);break}case"string":{n[r]=new Lt(It,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&e.properties.add(String(o))}return n}function Jf(s,t,e){const i=s[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return e.variables.add(i),[new Lt(It,i)]}function Qf(s,t,e){e.featureId=!0}function tg(s,t,e){e.geometryType=!0}function eg(s,t,e){e.mCoordinate=!0}function ho(s,t,e){e.mapState=!0}function Ui(s,t,e){const i=s[0];if(s.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function Z(s,t){return function(e,i,n){const r=e[0],o=e.length-1;if(s===t){if(o!==s){const a=s===1?"":"s";throw new Error(`expected ${s} argument${a} for ${r}, got ${o}`)}}else if(o<s||o>t){const a=t===1/0?`${s} or more`:`${s} to ${t}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function ql(s,t,e){const i=s.length-1,n=new Array(i);for(let r=0;r<i;++r){const o=Ft(s[r+1],t,e);n[r]=o}return n}function et(s){return function(t,e,i){const n=t.length-1,r=new Array(n);for(let o=0;o<n;++o){const a=Ft(t[o+1],s,i);r[o]=a}return r}}function ig(s,t,e){const i=s[0],n=s.length-1;if(n%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${n} instead`)}function Jl(s,t,e){const i=s[0],n=s.length-1;if(n%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${n} instead`)}function ng(s,t,e){const i=s.length-1,n=It|A|bt,r=Ft(s[1],n,e),o=Ft(s[s.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const h=Ft(s[l+2],r.type,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{const h=Ft(s[l+3],o.type,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[r,...a,o]}function sg(s,t,e){const i=s[1];let n;switch(i[0]){case"linear":n=1;break;case"exponential":const l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);n=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const r=new Lt(A,n);let o;try{o=Ft(s[2],A,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(s.length-3);for(let l=0;l<a.length;l+=2){try{const h=Ft(s[l+3],A,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=Ft(s[l+4],t,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[r,o,...a]}function rg(s,t,e){const i=Ft(s[s.length-1],t,e),n=new Array(s.length-1);for(let r=0;r<n.length-1;r+=2){try{const o=Ft(s[r+1],bt,e);n[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=Ft(s[r+2],i.type,e);n[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return n[n.length-1]=i,n}function og(s,t,e){let i=s[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let n;if(i[0]==="literal"){if(i=i[1],!Array.isArray(i))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array')}else if(typeof i[0]=="string")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');typeof i[0]=="string"?n=It:n=A;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=Ft(i[a],n,e);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[Ft(s[1],n,e),...r]}function ag(s,t,e){let i;try{i=Ft(s[1],A,e)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const n=s[2];if(!Array.isArray(n))throw new Error("the second argument of palette must be an array");const r=new Array(n.length);for(let o=0;o<r.length;o++){let a;try{a=Ft(n[o],yt,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof Lt))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function W(...s){return function(t,e,i){const n=t[0];let r;for(let o=0;o<s.length;o++){const a=s[o](t,e,i);if(o==s.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new Rc(e,n,...r)}}function lg(s,t,e){const i=s[0],n=qf[i];if(!n)throw new Error(`unknown operator: ${i}`);return n(s,t,e)}function La(s){if(!s)return"";const t=s.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return La(s.getGeometries()[0]);default:return""}}function bc(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Ge(s,t,e){const i=Ft(s,t,e);return we(i)}function we(s,t){if(s instanceof Lt){if(s.type===yt&&typeof s.value=="string"){const i=wa(s.value);return function(){return i}}return function(){return s.value}}const e=s.operator;switch(e){case v.Number:case v.String:case v.Coalesce:return hg(s);case v.Get:case v.Var:case v.Has:return cg(s);case v.Id:return i=>i.featureId;case v.GeometryType:return i=>i.geometryType;case v.Concat:{const i=s.args.map(n=>we(n));return n=>"".concat(...i.map(r=>r(n).toString()))}case v.Resolution:return i=>i.resolution;case v.Any:case v.All:case v.Between:case v.In:case v.Not:return dg(s);case v.Equal:case v.NotEqual:case v.LessThan:case v.LessThanOrEqualTo:case v.GreaterThan:case v.GreaterThanOrEqualTo:return ug(s);case v.Multiply:case v.Divide:case v.Add:case v.Subtract:case v.Clamp:case v.Mod:case v.Pow:case v.Abs:case v.Floor:case v.Ceil:case v.Round:case v.Sin:case v.Cos:case v.Atan:case v.Sqrt:return fg(s);case v.Case:return gg(s);case v.Match:return pg(s);case v.Interpolate:return _g(s);case v.ToString:return mg(s);default:throw new Error(`Unsupported operator ${e}`)}}function hg(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=we(s.args[r]);switch(e){case v.Coalesce:return r=>{for(let o=0;o<i;++o){const a=n[o](r);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case v.Number:case v.String:return r=>{for(let o=0;o<i;++o){const a=n[o](r);if(typeof a===e)return a}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}function cg(s,t){const i=s.args[0].value;switch(s.operator){case v.Get:return n=>{const r=s.args;let o=n.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;o=o[c]}return o};case v.Var:return n=>n.variables[i];case v.Has:return n=>{const r=s.args;if(!(i in n.properties))return!1;let o=n.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${s.operator}`)}}function ug(s,t){const e=s.operator,i=we(s.args[0]),n=we(s.args[1]);switch(e){case v.Equal:return r=>i(r)===n(r);case v.NotEqual:return r=>i(r)!==n(r);case v.LessThan:return r=>i(r)<n(r);case v.LessThanOrEqualTo:return r=>i(r)<=n(r);case v.GreaterThan:return r=>i(r)>n(r);case v.GreaterThanOrEqualTo:return r=>i(r)>=n(r);default:throw new Error(`Unsupported comparison operator ${e}`)}}function dg(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=we(s.args[r]);switch(e){case v.Any:return r=>{for(let o=0;o<i;++o)if(n[o](r))return!0;return!1};case v.All:return r=>{for(let o=0;o<i;++o)if(!n[o](r))return!1;return!0};case v.Between:return r=>{const o=n[0](r),a=n[1](r),l=n[2](r);return o>=a&&o<=l};case v.In:return r=>{const o=n[0](r);for(let a=1;a<i;++a)if(o===n[a](r))return!0;return!1};case v.Not:return r=>!n[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function fg(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=we(s.args[r]);switch(e){case v.Multiply:return r=>{let o=1;for(let a=0;a<i;++a)o*=n[a](r);return o};case v.Divide:return r=>n[0](r)/n[1](r);case v.Add:return r=>{let o=0;for(let a=0;a<i;++a)o+=n[a](r);return o};case v.Subtract:return r=>n[0](r)-n[1](r);case v.Clamp:return r=>{const o=n[0](r),a=n[1](r);if(o<a)return a;const l=n[2](r);return o>l?l:o};case v.Mod:return r=>n[0](r)%n[1](r);case v.Pow:return r=>Math.pow(n[0](r),n[1](r));case v.Abs:return r=>Math.abs(n[0](r));case v.Floor:return r=>Math.floor(n[0](r));case v.Ceil:return r=>Math.ceil(n[0](r));case v.Round:return r=>Math.round(n[0](r));case v.Sin:return r=>Math.sin(n[0](r));case v.Cos:return r=>Math.cos(n[0](r));case v.Atan:return i===2?r=>Math.atan2(n[0](r),n[1](r)):r=>Math.atan(n[0](r));case v.Sqrt:return r=>Math.sqrt(n[0](r));default:throw new Error(`Unsupported numeric operator ${e}`)}}function gg(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=we(s.args[n]);return n=>{for(let r=0;r<e-1;r+=2)if(i[r](n))return i[r+1](n);return i[e-1](n)}}function pg(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=we(s.args[n]);return n=>{const r=i[0](n);for(let o=1;o<e-1;o+=2)if(r===i[o](n))return i[o+1](n);return i[e-1](n)}}function _g(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=we(s.args[n]);return n=>{const r=i[0](n),o=i[1](n);let a,l;for(let h=2;h<e;h+=2){const c=i[h](n);let u=i[h+1](n);const d=Array.isArray(u);if(d&&(u=Xd(u)),c>=o)return h===2?u:d?yg(r,o,a,l,c,u):$n(r,o,a,l,c,u);a=c,l=u}return l}}function mg(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=we(s.args[r]);if(e===v.ToString)return r=>{const o=n[0](r);return s.args[0].type===yt?Ta(o):o.toString()};throw new Error(`Unsupported convert operator ${e}`)}function $n(s,t,e,i,n,r){const o=n-e;if(o===0)return i;const a=t-e,l=s===1?a/o:(Math.pow(s,a)-1)/(Math.pow(s,o)-1);return i+l*(r-i)}function yg(s,t,e,i,n,r){if(n-e===0)return i;const a=Fl(i),l=Fl(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[$n(s,t,e,a[0],n,l[0]),$n(s,t,e,a[1],n,l[1]),a[2]+$n(s,t,e,0,n,h),$n(s,t,e,i[3],n,r[3])];return jd(c)}class Mi extends Ar{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?Y.LOADING:Y.LOADED,this.imageState_===Y.LOADING&&this.ready().then(()=>this.imageState_=Y.LOADED),this.render()}clone(){const t=this.getScale(),e=new Mi({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let n=he.get(i,null)?.getImage(1);if(!n){const r=this.renderOptions_,o=Math.ceil(r.size*t),a=Tt(o,o);this.draw_(r,a,t),n=a.canvas;const l=new ac(n,void 0,null,Y.LOADED,null);he.set(i,null,l),createImageBitmap(n).then(h=>{l.setImage(h)})}return n}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let n=this.radius,r=this.radius2_===void 0?n:this.radius2_;if(n<r){const S=n;n=r,r=S}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=n-h,u=Math.sqrt(l*l+c*c),d=u/l;if(t==="miter"&&d<=i)return d*e;const f=e/2/d,g=e/2*(c/u),p=Math.sqrt((n+f)*(n+f)+g*g)-n;if(this.radius2_===void 0||t==="bevel")return p*2;const m=n*Math.sin(a),y=Math.sqrt(n*n-m*m),C=r-y,E=Math.sqrt(m*m+C*C)/m;if(E<=i){const S=E*e/2-r-n;return 2*Math.max(p,S)}return p*2}createRenderOptions(){let t=gn,e=pn,i=0,n=null,r=0,o,a=0;this.stroke_&&(o=ke(this.stroke_.getColor()??Ne),a=this.stroke_.getWidth()??Qn,n=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??pn,t=this.stroke_.getLineCap()??gn,i=this.stroke_.getMiterLimit()??qn);const l=this.calculateLineJoinSize_(e,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:t,lineDash:n,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let n=this.fill_.getColor();n===null&&(n=Kt),e.fillStyle=ke(n),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),n=0;typeof i=="string"&&(i=pe(i)),i===null?n=1:Array.isArray(i)&&(n=i.length===4?i[3]:1),n===0&&(e=Tt(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{const n=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let a=0;a<e;a++){const l=r+a*o,h=a%2===0?i:n;t.lineTo(h*Math.cos(l),h*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Kt,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class ze extends Mi{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new ze({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}}class ut{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){const t=this.getColor();return new ut({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){const e=jn(null,t.src,{crossOrigin:"anonymous"},void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===Y.IDLE&&e.load(),e.getImageState()===Y.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?$(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:pe(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}class _t{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){const t=this.getColor();return new _t({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}}class lt{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Ql,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new lt({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=Ql,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function xg(s){let t;if(typeof s=="function")t=s;else{let e;Array.isArray(s)?e=s:(Q(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[s]),t=function(){return e}}return t}let co=null;function Pc(s,t){if(!co){const e=new ut({color:"rgba(255,255,255,0.4)"}),i=new _t({color:"#3399CC",width:1.25});co=[new lt({image:new ze({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return co}function Eg(){const s={},t=[255,255,255,1],e=[0,153,255,1],i=3;return s.Polygon=[new lt({fill:new ut({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new lt({stroke:new _t({color:t,width:i+2})}),new lt({stroke:new _t({color:e,width:i})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new lt({image:new ze({radius:i*2,fill:new ut({color:e}),stroke:new _t({color:t,width:i/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function Ql(s){return s.getGeometry()}const vg="#333";class vn{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=Zt(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new ut({color:vg}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new vn({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof ut?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=Zt(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}function Cg(s){return!0}function wg(s){const t=fs(),e=Tg(s,t),i=bc();return function(n,r){if(i.properties=n.getPropertiesInternal(),i.resolution=r,t.featureId){const o=n.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=La(n.getGeometry())),e(i)}}function th(s){const t=fs(),e=s.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=Vo(s[o],t);const n=bc(),r=new Array(e);return function(o,a){if(n.properties=o.getPropertiesInternal(),n.resolution=a,t.featureId){const h=o.getId();h!==void 0?n.featureId=h:n.featureId=null}let l=0;for(let h=0;h<e;++h){const c=i[h](n);c&&(r[l]=c,l+=1)}return r.length=l,r}}function Tg(s,t){const e=s.length,i=new Array(e);for(let n=0;n<e;++n){const r=s[n],o="filter"in r?Ge(r.filter,bt,t):Cg;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=Vo(r.style[h],t)}else a=[Vo(r.style,t)];i[n]={filter:o,styles:a}}return function(n){const r=[];let o=!1;for(let a=0;a<e;++a){const l=i[a].filter;if(l(n)&&!(s[a].else&&o)){o=!0;for(const h of i[a].styles){const c=h(n);c&&r.push(c)}}}return r}}function Vo(s,t){const e=ts(s,"",t),i=es(s,"",t),n=Sg(s,t),r=Rg(s,t),o=Gt(s,"z-index",t);if(!e&&!i&&!n&&!r&&!Ai(s))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(s));const a=new lt;return function(l){let h=!0;if(e){const c=e(l);c&&(h=!1),a.setFill(c)}if(i){const c=i(l);c&&(h=!1),a.setStroke(c)}if(n){const c=n(l);c&&(h=!1),a.setText(c)}if(r){const c=r(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function ts(s,t,e){let i;if(t+"fill-pattern-src"in s)i=Ig(s,t+"fill-",e);else{if(s[t+"fill-color"]==="none")return r=>null;i=kr(s,t+"fill-color",e)}if(!i)return null;const n=new ut;return function(r){const o=i(r);return o===Ca?null:(n.setColor(o),n)}}function es(s,t,e){const i=Gt(s,t+"stroke-width",e),n=kr(s,t+"stroke-color",e);if(!i&&!n)return null;const r=Ze(s,t+"stroke-line-cap",e),o=Ze(s,t+"stroke-line-join",e),a=Lc(s,t+"stroke-line-dash",e),l=Gt(s,t+"stroke-line-dash-offset",e),h=Gt(s,t+"stroke-miter-limit",e),c=Gt(s,t+"stroke-offset",e),u=new _t;return function(d){if(n){const f=n(d);if(f===Ca)return null;u.setColor(f)}if(i&&u.setWidth(i(d)),r){const f=r(d);if(f!=="butt"&&f!=="round"&&f!=="square")throw new Error("Expected butt, round, or square line cap");u.setLineCap(f)}if(o){const f=o(d);if(f!=="bevel"&&f!=="round"&&f!=="miter")throw new Error("Expected bevel, round, or miter line join");u.setLineJoin(f)}return a&&u.setLineDash(a(d)),l&&u.setLineDashOffset(l(d)),h&&u.setMiterLimit(h(d)),c&&u.setOffset(c(d)),u}}function Sg(s,t){const e="text-",i=Ze(s,e+"value",t);if(!i)return null;const n=ts(s,e,t),r=ts(s,e+"background-",t),o=es(s,e,t),a=es(s,e+"background-",t),l=Ze(s,e+"font",t),h=Gt(s,e+"max-angle",t),c=Gt(s,e+"offset-x",t),u=Gt(s,e+"offset-y",t),d=an(s,e+"overflow",t),f=Ze(s,e+"placement",t),g=Gt(s,e+"repeat",t),_=Fr(s,e+"scale",t),p=an(s,e+"rotate-with-view",t),m=Gt(s,e+"rotation",t),y=Ze(s,e+"align",t),C=Ze(s,e+"justify",t),x=Ze(s,e+"baseline",t),E=an(s,e+"keep-upright",t),S=Lc(s,e+"padding",t),w=Or(s,e+"declutter-mode"),T=new vn({declutterMode:w});return function(R){if(T.setText(i(R)),n&&T.setFill(n(R)),r&&T.setBackgroundFill(r(R)),o&&T.setStroke(o(R)),a&&T.setBackgroundStroke(a(R)),l&&T.setFont(l(R)),h&&T.setMaxAngle(h(R)),c&&T.setOffsetX(c(R)),u&&T.setOffsetY(u(R)),d&&T.setOverflow(d(R)),f){const b=f(R);if(b!=="point"&&b!=="line")throw new Error("Expected point or line for text-placement");T.setPlacement(b)}if(g&&T.setRepeat(g(R)),_&&T.setScale(_(R)),p&&T.setRotateWithView(p(R)),m&&T.setRotation(m(R)),y){const b=y(R);if(b!=="left"&&b!=="center"&&b!=="right"&&b!=="end"&&b!=="start")throw new Error("Expected left, right, center, start, or end for text-align");T.setTextAlign(b)}if(C){const b=C(R);if(b!=="left"&&b!=="right"&&b!=="center")throw new Error("Expected left, right, or center for text-justify");T.setJustify(b)}if(x){const b=x(R);if(b!=="bottom"&&b!=="top"&&b!=="middle"&&b!=="alphabetic"&&b!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");T.setTextBaseline(b)}return S&&T.setPadding(S(R)),E&&T.setKeepUpright(E(R)),T}}function Rg(s,t){return"icon-src"in s?bg(s,t):"shape-points"in s?Pg(s,t):"circle-radius"in s?Lg(s,t):null}function bg(s,t){const e="icon-",i=e+"src",n=Ic(s[i],i),r=hr(s,e+"anchor",t),o=Fr(s,e+"scale",t),a=Gt(s,e+"opacity",t),l=hr(s,e+"displacement",t),h=Gt(s,e+"rotation",t),c=an(s,e+"rotate-with-view",t),u=ih(s,e+"anchor-origin"),d=nh(s,e+"anchor-x-units"),f=nh(s,e+"anchor-y-units"),g=ii(s,e+"color");let _,p=null;g!==void 0&&(Array.isArray(g)&&g.length>0&&typeof g[0]=="string"?p=kr(s,e+"color",t):_=Mc(g,e+"color"));const m=Ag(s,e+"cross-origin"),y=Dg(s,e+"offset"),C=ih(s,e+"offset-origin"),x=Yo(s,e+"width"),E=Yo(s,e+"height"),S=Mg(s,e+"size"),w=Or(s,e+"declutter-mode"),T={src:n,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,crossOrigin:m,offset:y,offsetOrigin:C,height:E,width:x,size:S,declutterMode:w};let R=null;return function(b){if(R)p&&R.setColor(p(b));else{const L=p?p(b):_;R=new Dr(L!==void 0?Object.assign({},T,{color:L}):Object.assign({},T))}return a&&R.setOpacity(a(b)),l&&R.setDisplacement(l(b)),h&&R.setRotation(h(b)),c&&R.setRotateWithView(c(b)),o&&R.setScale(o(b)),r&&R.setAnchor(r(b)),R}}function Pg(s,t){const e="shape-",i=e+"points",n=e+"radius",r=Ia(s[i],i);if(!(n in s))throw new Error(`Expected a number for ${n}`);const o=Gt(s,n,t),a=typeof s[n]=="number"?s[n]:5,l=e+"radius2",h=Gt(s,l,t),c=typeof s[l]=="number"?s[l]:void 0,u=ts(s,e,t),d=es(s,e,t),f=Fr(s,e+"scale",t),g=hr(s,e+"displacement",t),_=Gt(s,e+"rotation",t),p=an(s,e+"rotate-with-view",t),m=Yo(s,e+"angle"),y=Or(s,e+"declutter-mode"),C=new Mi({points:r,radius:a,radius2:c,angle:m,declutterMode:y});return function(x){return o&&C.setRadius(o(x)),h&&C.setRadius2(h(x)),u&&C.setFill(u(x)),d&&C.setStroke(d(x)),g&&C.setDisplacement(g(x)),_&&C.setRotation(_(x)),p&&C.setRotateWithView(p(x)),f&&C.setScale(f(x)),C}}function Lg(s,t){const e="circle-",i=ts(s,e,t),n=es(s,e,t),r=Gt(s,e+"radius",t),o=Fr(s,e+"scale",t),a=hr(s,e+"displacement",t),l=Gt(s,e+"rotation",t),h=an(s,e+"rotate-with-view",t),c=Or(s,e+"declutter-mode"),u=new ze({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),i&&u.setFill(i(d)),n&&u.setStroke(n(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function ii(s,t){if(!(t in s))return;const e=s[t];return e===void 0?void 0:e}function Gt(s,t,e){const i=ii(s,t);if(i===void 0)return;const n=Ge(i,A,e);return function(r){return Ia(n(r),t)}}function Ze(s,t,e){const i=ii(s,t);if(i===void 0)return null;const n=Ge(i,It,e);return function(r){return Ic(n(r),t)}}function Ig(s,t,e){const i=Ze(s,t+"pattern-src",e),n=eh(s,t+"pattern-offset",e),r=eh(s,t+"pattern-size",e),o=kr(s,t+"color",e);return function(a){return{src:i(a),offset:n&&n(a),size:r&&r(a),color:o&&o(a)}}}function an(s,t,e){const i=ii(s,t);if(i===void 0)return null;const n=Ge(i,bt,e);return function(r){const o=n(r);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${t}`);return o}}function kr(s,t,e){const i=ii(s,t);if(i===void 0)return null;const n=Ge(i,yt,e);return function(r){return Mc(n(r),t)}}function Lc(s,t,e){const i=ii(s,t);if(i===void 0)return null;if(Array.isArray(i)&&(i.length===0||typeof i[0]!="string")){const r=i.map((o,a)=>{if(typeof o=="number")return()=>o;const l=Ge(o,A,e);return function(h){return Ia(l(h),`${t}[${a}]`)}});return function(o){const a=new Array(r.length);for(let l=0;l<r.length;++l)a[l]=r[l](o);return a}}const n=Ge(i,ee,e);return function(r){return gs(n(r),t)}}function hr(s,t,e){const i=ii(s,t);if(i===void 0)return null;const n=Ge(i,ee,e);return function(r){const o=gs(n(r),t);if(o.length!==2)throw new Error(`Expected two numbers for ${t}`);return o}}function eh(s,t,e){const i=ii(s,t);if(i===void 0)return null;const n=Ge(i,ee,e);return function(r){return Ac(n(r),t)}}function Fr(s,t,e){const i=ii(s,t);if(i===void 0)return null;const n=Ge(i,ee|A,e);return function(r){return kg(n(r),t)}}function Yo(s,t){const e=s[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function Mg(s,t){const e=s[t];if(e!==void 0){if(typeof e=="number")return Zt(e);if(!Array.isArray(e))throw new Error(`Expected a number or size array for ${t}`);if(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return e}}function Ag(s,t){const e=s[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function ih(s,t){const e=s[t];if(e!==void 0){if(e!=="bottom-left"&&e!=="bottom-right"&&e!=="top-left"&&e!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return e}}function nh(s,t){const e=s[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function Dg(s,t){const e=s[t];if(e!==void 0)return gs(e,t)}function Or(s,t){const e=s[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);if(e!=="declutter"&&e!=="obstacle"&&e!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return e}}function gs(s,t){if(!Array.isArray(s))throw new Error(`Expected an array for ${t}`);const e=s.length;for(let i=0;i<e;++i)if(typeof s[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return s}function Ic(s,t){if(typeof s!="string")throw new Error(`Expected a string for ${t}`);return s}function Ia(s,t){if(typeof s!="number")throw new Error(`Expected a number for ${t}`);return s}function Mc(s,t){if(typeof s=="string")return s;const e=gs(s,t),i=e.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function Ac(s,t){const e=gs(s,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function kg(s,t){return typeof s=="number"?s:Ac(s,t)}const me={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function sh(s,t,e){return(function(i,n,r,o,a){if(!i)return;if(!n&&!t)return i;const l=t?0:r[0]*n,h=t?0:r[1]*n,c=a?a[0]:0,u=a?a[1]:0;let d=s[0]+l/2+c,f=s[2]-l/2+c,g=s[1]+h/2+u,_=s[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>_&&(g=(_+g)/2,_=g);let p=pt(i[0],d,f),m=pt(i[1],g,_);if(o&&e&&n){const y=30*n;p+=-y*Math.log(1+Math.max(0,d-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-f)/y),m+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-_)/y)}return[p,m]})}function Fg(s){return s}function Dc(s){return Math.pow(s,3)}function Cn(s){return 1-Dc(1-s)}function Og(s){return 3*s*s-2*s*s*s}function Ng(s){return s}function kc(s,t,e,i){let n=0;const r=s[e-i],o=s[e-i+1];let a=0,l=0;for(;t<e;t+=i){const h=s[t]-r,c=s[t+1]-o;n+=l*h-a*c,a=h,l=c}return n/2}function Fc(s,t,e,i){let n=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];n+=kc(s,t,a,i),t=a}return n}function Gg(s,t,e,i){let n=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];n+=Fc(s,t,a,i),t=a[a.length-1]}return n}function rh(s,t,e,i,n,r,o){const a=s[t],l=s[t+1],h=s[e]-a,c=s[e+1]-l;let u;if(h===0&&c===0)u=t;else{const d=((n-a)*h+(r-l)*c)/(h*h+c*c);if(d>1)u=e;else if(d>0){for(let f=0;f<i;++f)o[f]=se(s[t+f],s[e+f],d);o.length=i;return}else u=t}for(let d=0;d<i;++d)o[d]=s[u+d];o.length=i}function Ma(s,t,e,i,n){let r=s[t],o=s[t+1];for(t+=i;t<e;t+=i){const a=s[t],l=s[t+1],h=qe(r,o,a,l);h>n&&(n=h),r=a,o=l}return n}function Aa(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];n=Ma(s,t,a,i,n),t=a}return n}function zg(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];n=Aa(s,t,a,i,n),t=a[a.length-1]}return n}function Da(s,t,e,i,n,r,o,a,l,h,c){if(t==e)return h;let u,d;if(n===0){if(d=qe(o,a,s[t],s[t+1]),d<h){for(u=0;u<i;++u)l[u]=s[t+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=t+i;for(;f<e;)if(rh(s,f-i,f,i,o,a,c),d=qe(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/n|0,1);if(r&&(rh(s,e-i,t,i,o,a,c),d=qe(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function ka(s,t,e,i,n,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=Da(s,t,f,i,n,r,o,a,l,h,c),t=f}return h}function $g(s,t,e,i,n,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=ka(s,t,f,i,n,r,o,a,l,h,c),t=f[f.length-1]}return h}class is extends _i{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}clone(){return new is(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,n){return n<ki(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ma(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Da(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,n))}getArea(){return kc(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return fi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=Mr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new is(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Pr(this.flatCoordinates,0,t,this.stride),this.changed()}}function Bg(s,t,e,i,n){return!ua(n,function(o){return!Pi(s,t,e,i,o[0],o[1])})}function Pi(s,t,e,i,n,r){let o=0,a=s[e-i],l=s[e-i+1];for(;t<e;t+=i){const h=s[t],c=s[t+1];l<=r?c>r&&(h-a)*(r-l)-(n-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(n-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function Fa(s,t,e,i,n,r){if(e.length===0||!Pi(s,t,e[0],i,n,r))return!1;for(let o=1,a=e.length;o<a;++o)if(Pi(s,e[o-1],e[o],i,n,r))return!1;return!0}function Wg(s,t,e,i,n,r){if(e.length===0)return!1;for(let o=0,a=e.length;o<a;++o){const l=e[o];if(Fa(s,t,l,i,n,r))return!0;t=l[l.length-1]}return!1}function Oa(s,t,e,i,n,r,o){let a,l,h,c,u,d,f;const g=n[r+1],_=[];for(let y=0,C=e.length;y<C;++y){const x=e[y];for(c=s[x-i],d=s[x-i+1],a=t;a<x;a+=i)u=s[a],f=s[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,_.push(h)),c=u,d=f}let p=NaN,m=-1/0;for(_.sort(Ke),c=_[0],a=1,l=_.length;a<l;++a){u=_[a];const y=Math.abs(u-c);y>m&&(h=(c+u)/2,Fa(s,t,e,i,h,g)&&(p=h,m=y)),c=u}return isNaN(p)&&(p=n[r]),o?(o.push(p,g,m),o):[p,g,m]}function Oc(s,t,e,i,n){let r=[];for(let o=0,a=e.length;o<a;++o){const l=e[o];r=Oa(s,t,l,i,n,2*o,r),t=l[l.length-1]}return r}function Nc(s,t,e,i,n){let r;for(t+=i;t<e;t+=i)if(r=n(s.slice(t-i,t),s.slice(t,t+i)),r)return r;return!1}function Nr(s,t,e,i,n,r){return r=r??Ah(Wt(),s,t,e,i),Vt(n,r)?r[0]>=n[0]&&r[2]<=n[2]||r[1]>=n[1]&&r[3]<=n[3]?!0:Nc(s,t,e,i,function(o,a){return Bu(n,o,a)}):!1}function Ug(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){if(Nr(s,t,e[r],i,n))return!0;t=e[r]}return!1}function Gc(s,t,e,i,n){return!!(Nr(s,t,e,i,n)||Pi(s,t,e,i,n[0],n[1])||Pi(s,t,e,i,n[0],n[3])||Pi(s,t,e,i,n[2],n[1])||Pi(s,t,e,i,n[2],n[3]))}function zc(s,t,e,i,n){if(!Gc(s,t,e[0],i,n))return!1;if(e.length===1)return!0;for(let r=1,o=e.length;r<o;++r)if(Bg(s,e[r-1],e[r],i,n)&&!Nr(s,e[r-1],e[r],i,n))return!1;return!0}function Xg(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(zc(s,t,a,i,n))return!0;t=a[a.length-1]}return!1}function jg(s,t,e,i){for(;t<e-i;){for(let n=0;n<i;++n){const r=s[t+n];s[t+n]=s[e-i+n],s[e-i+n]=r}t+=i,e-=i}}function Na(s,t,e,i){let n=0,r=s[e-i],o=s[e-i+1];for(;t<e;t+=i){const a=s[t],l=s[t+1];n+=(a-r)*(l+o),r=a,o=l}return n===0?void 0:n>0}function Ga(s,t,e,i,n){n=n!==void 0?n:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=Na(s,t,a,i);if(r===0){if(n&&l||!n&&!l)return!1}else if(n&&!l||!n&&l)return!1;t=a}return!0}function $c(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(!Ga(s,t,a,i,n))return!1;a.length&&(t=a[a.length-1])}return!0}function cr(s,t,e,i,n){n=n!==void 0?n:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=Na(s,t,a,i);(r===0?n&&l||!n&&!l:n&&!l||!n&&l)&&jg(s,t,a,i),t=a}return t}function Zo(s,t,e,i,n){for(let r=0,o=e.length;r<o;++r)t=cr(s,t,e[r],i,n);return t}function Bc(s,t){const e=[];let i=0,n=0,r;for(let o=0,a=t.length;o<a;++o){const l=t[o],h=Na(s,i,l,2);if(r===void 0&&(r=h),h===r)e.push(t.slice(n,o+1));else{if(e.length===0)continue;e[e.length-1].push(t[n])}n=o+1,i=l}return e}class ht extends _i{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,e!==void 0&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?Fe(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new ht(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<ki(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Aa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ka(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return Fa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return Fc(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),cr(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Kn(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=ue(this.getExtent());this.flatInteriorPoint_=Oa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new gt(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new is(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,i=this.ends_,n=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o],h=new is(e.slice(r,l),t);n.push(h),r=l}return n}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Ga(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=cr(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Ra(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new ht(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return zc(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=us(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function nn(s){if(ls(s))throw new Error("Cannot create polygon from empty extent");const t=s[0],e=s[1],i=s[2],n=s[3],r=[t,e,t,n,i,n,i,e,t,e];return new ht(r,"XY",[r.length])}function za(s,t,e,i){const n=at(t)/e[0],r=Yt(t)/e[1];return i?Math.min(s,Math.max(n,r)):Math.min(s,Math.min(n,r))}function $a(s,t,e){let i=Math.min(s,t);const n=50;return i*=Math.log(1+n*Math.max(0,s/t-1))/n+1,e&&(i=Math.max(i,e),i/=Math.log(1+n*Math.max(0,e/s-1))/n+1),pt(i,e/2,t*2)}function Vg(s,t,e,i){return t=t!==void 0?t:!0,(function(n,r,o,a){if(n!==void 0){const l=s[0],h=s[s.length-1],c=e?za(l,e,o,i):l;if(a)return t?$a(n,c,h):pt(n,h,c);const u=Math.min(c,n),d=Math.floor(aa(s,u,r));return s[d]>c&&d<s.length-1?s[d+1]:s[d]}})}function Yg(s,t,e,i,n,r){return i=i!==void 0?i:!0,e=e!==void 0?e:0,(function(o,a,l,h){if(o!==void 0){const c=n?za(t,n,l,r):t;if(h)return i?$a(o,c,e):pt(o,e,c);const u=1e-9,d=Math.ceil(Math.log(t/c)/Math.log(s)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),_=Math.floor(Math.log(t/g)/Math.log(s)+f),p=Math.max(d,_),m=t/Math.pow(s,p);return pt(m,e,c)}})}function oh(s,t,e,i,n){return e=e!==void 0?e:!0,(function(r,o,a,l){if(r!==void 0){const h=i?za(s,i,a,n):s;return!e||!l?pt(r,t,h):$a(r,h,t)}})}function Ba(s){if(s!==void 0)return 0}function ah(s){if(s!==void 0)return s}function Zg(s){const t=2*Math.PI/s;return(function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e})}function Hg(s){const t=ve(5);return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}const Kg=42,Wa=256,uo=0;class De extends Te{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=xa(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&Hh(),t.center&&(t.center=ye(t.center,this.projection_)),t.extent&&(t.extent=Si(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const a in me)delete e[a];this.setProperties(e,!0);const i=Jg(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;const n=qg(t),r=i.constraint,o=Qg(t);this.constraints_={center:n,resolution:r,rotation:o},this.setRotation(t.rotation!==void 0?t.rotation:0),this.setCenterInternal(t.center!==void 0?t.center:null),t.resolution!==void 0?this.setResolution(t.resolution):t.zoom!==void 0&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const i=this.getCenterInternal();if(i){const n=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),o=r/2*(n[3]-e[3]+e[1]-n[1]),a=r/2*(n[0]-e[0]+e[2]-n[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(t){const e=this.getProperties();return e.resolution!==void 0?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const e=new Array(arguments.length);for(let i=0;i<e.length;++i){let n=arguments[i];n.center&&(n=Object.assign({},n),n.center=ye(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=ye(n.anchor,this.getProjection())),e[i]=n}this.animateInternal.apply(this,e)}animateInternal(t){let e=arguments.length,i;e>1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let n=0;for(;n<e&&!this.isDef();++n){const c=arguments[n];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(n===e){i&&Os(i,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const h=[];for(;n<e;++n){const c=arguments[n],u={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||Og,callback:i};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;const d=Ii(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}tp(u)?u.complete=!0:r+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(Dt.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[Dt.ANIMATING]>0}getInteracting(){return this.hints_[Dt.INTERACTING]>0}cancelAnimations(){this.setHint(Dt.ANIMATING,-this.hints_[Dt.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){const n=this.animations_[e];if(n[0].callback&&Os(n[0].callback,!1),!t)for(let r=0,o=n.length;r<o;++r){const a=n[r];if(!a.complete){t=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let i=this.animations_.length-1;i>=0;--i){const n=this.animations_[i];let r=!0;for(let o=0,a=n.length;o<a;++o){const l=n[o];if(l.complete)continue;const h=t-l.start;let c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],_=l.targetCenter[1];this.nextCenter_=l.targetCenter;const p=d+u*(g-d),m=f+u*(_-f);this.targetCenter_=[p,m]}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?Ii(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(Dt.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=n[0].callback;o&&Os(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const n=this.getCenterInternal();return n!==void 0&&(i=[n[0]-e[0],n[1]-e[1]],da(i,t-this.getRotation()),Nh(i,e)),i}calculateCenterZoom(t,e){let i;const n=this.getCenterInternal(),r=this.getResolution();if(n!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-n[0])/r,a=e[1]-t*(e[1]-n[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],n=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(n*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(n*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t&&$o(t,this.getProjection())}getCenterInternal(){return this.get(me.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){const e=this.calculateExtentInternal(t);return Kh(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();Q(e,"The view center is not defined");const i=this.getResolution();Q(i!==void 0,"The view resolution is not defined");const n=this.getRotation();return Q(n!==void 0,"The view rotation is not defined"),ko(e,i,n,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(me.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Si(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=at(t)/e[0],n=Yt(t)/e[1];return Math.max(i,n)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,n=Math.log(e/i)/Math.log(t);return(function(r){return e/Math.pow(t,r*n)})}getRotation(){return this.get(me.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,r=Math.log(i/n)/e;return(function(o){return Math.log(i/o)/e/r})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let n=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();n=fo(n,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:n.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,n;if(this.resolutions_){const r=aa(this.resolutions_,t,1);e=r,i=this.resolutions_[r],r==this.resolutions_.length-1?n=2:n=i/this.resolutions_[r+1]}else i=this.maxResolution_,n=this.zoomFactor_;return e+Math.log(i/t)/Math.log(n)}getResolutionForZoom(t){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const e=pt(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,pt(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(Q(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){Q(!ls(t),"Cannot fit empty extent provided as `geometry`");const n=Si(t,this.getProjection());i=nn(n)}else if(t.getType()==="Circle"){const n=Si(t.getExtent(),this.getProjection());i=nn(n),i.rotate(this.getRotation(),ue(n))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),n=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*i-r[u+1]*n,g=r[u]*n+r[u+1]*i;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(t,e){e=e||{};let i=e.size;i||(i=this.getViewportSizeMinusPadding_());const n=e.padding!==void 0?e.padding:[0,0,0,0],r=e.nearest!==void 0?e.nearest:!1;let o;e.minResolution!==void 0?o=e.minResolution:e.maxZoom!==void 0?o=this.getResolutionForZoom(e.maxZoom):o=0;const a=this.rotatedExtentForGeometry(t);let l=this.getResolutionForExtentInternal(a,[i[0]-n[1]-n[3],i[1]-n[0]-n[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,r?0:1);const h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=ue(a);d[0]+=(n[1]-n[3])/2*l,d[1]+=(n[0]-n[2])/2*l;const f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,_=this.getConstrainedCenter([f,g],l),p=e.callback?e.callback:Yn;e.duration!==void 0?this.animateInternal({resolution:l,center:_,duration:e.duration,easing:e.easing},p):(this.targetResolution_=l,this.targetCenter_=_,this.applyTargetState_(!1,!0),Os(p,!0))}centerOn(t,e,i){this.centerOnInternal(ye(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(fo(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,n){let r;const o=this.padding_;if(o&&t){const a=this.getViewportSizeMinusPadding_(-i),l=fo(t,n,[a[0]/2+o[3],a[1]/2+o[0]],e,i);r=[t[0]-l[0],t[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){const e=$o(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){const e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&ye(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const i=this.getAnimating()||this.getInteracting(),n=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,n,i);e&&(this.targetCenter_=this.calculateCenterZoom(r,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=ye(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const i=this.getAnimating()||this.getInteracting(),n=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(n,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&ye(t,this.getProjection()))}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){const i=this.getAnimating()||this.getInteracting()||e,n=this.constraints_.rotation(this.targetRotation_,i),r=this.getViewportSize_(n),o=this.constraints_.resolution(this.targetResolution_,0,r,i),a=this.constraints_.center(this.targetCenter_,o,r,i,this.calculateCenterShift(this.targetCenter_,o,n,r));this.get(me.ROTATION)!==n&&this.set(me.ROTATION,n),this.get(me.RESOLUTION)!==o&&(this.set(me.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(me.CENTER)||!ir(this.get(me.CENTER),a))&&this.set(me.CENTER,a),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=t!==void 0?t:200;const n=e||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,n,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!ir(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:t,easing:Cn,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(Dt.INTERACTING,1)}endInteraction(t,e,i){i=i&&ye(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(Dt.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){const i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){const i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;const i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}}function Os(s,t){setTimeout(function(){s(t)},0)}function qg(s){if(s.extent!==void 0){const e=s.smoothExtentConstraint!==void 0?s.smoothExtentConstraint:!0;return sh(s.extent,s.constrainOnlyCenter,e)}const t=xa(s.projection,"EPSG:3857");if(s.multiWorld!==!0&&t.isGlobal()){const e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,sh(e,!1,!1)}return Fg}function Jg(s){let t,e,i,o=s.minZoom!==void 0?s.minZoom:uo,a=s.maxZoom!==void 0?s.maxZoom:28;const l=s.zoomFactor!==void 0?s.zoomFactor:2,h=s.multiWorld!==void 0?s.multiWorld:!1,c=s.smoothResolutionConstraint!==void 0?s.smoothResolutionConstraint:!0,u=s.showFullExtent!==void 0?s.showFullExtent:!1,d=xa(s.projection,"EPSG:3857"),f=d.getExtent();let g=s.constrainOnlyCenter,_=s.extent;if(!h&&!_&&d.isGlobal()&&(g=!1,_=f),s.resolutions!==void 0){const p=s.resolutions;e=p[o],i=p[a]!==void 0?p[a]:p[p.length-1],s.constrainResolution?t=Vg(p,c,!g&&_,u):t=oh(e,i,c,!g&&_,u)}else{const m=(f?Math.max(at(f),Yt(f)):360*fa.degrees/d.getMetersPerUnit())/Wa/Math.pow(2,uo),y=m/Math.pow(2,28-uo);e=s.maxResolution,e!==void 0?o=0:e=m/Math.pow(l,o),i=s.minResolution,i===void 0&&(s.maxZoom!==void 0?s.maxResolution!==void 0?i=e/Math.pow(l,a):i=m/Math.pow(l,a):i=y),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),s.constrainResolution?t=Yg(l,e,i,c,!g&&_,u):t=oh(e,i,c,!g&&_,u)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function Qg(s){if(s.enableRotation!==void 0?s.enableRotation:!0){const e=s.constrainRotation;return e===void 0||e===!0?Hg():e===!1?ah:typeof e=="number"?Zg(e):ah}return Ba}function tp(s){return!(s.sourceCenter&&s.targetCenter&&!ir(s.sourceCenter,s.targetCenter)||s.sourceResolution!==s.targetResolution||s.sourceRotation!==s.targetRotation)}function fo(s,t,e,i,n){const r=Math.cos(-n);let o=Math.sin(-n),a=s[0]*r-s[1]*o,l=s[1]*r+s[0]*o;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,o=-o;const h=a*r-l*o,c=l*r+a*o;return[h,c]}const it={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 Wc extends Te{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[it.OPACITY]=t.opacity!==void 0?t.opacity:1,Q(typeof e[it.OPACITY]=="number","Layer opacity must be a number"),e[it.VISIBLE]=t.visible!==void 0?t.visible:!0,e[it.Z_INDEX]=t.zIndex,e[it.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[it.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[it.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[it.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=pt(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return X()}getLayerStatesArray(t){return X()}getExtent(){return this.get(it.EXTENT)}getMaxResolution(){return this.get(it.MAX_RESOLUTION)}getMinResolution(){return this.get(it.MIN_RESOLUTION)}getMinZoom(){return this.get(it.MIN_ZOOM)}getMaxZoom(){return this.get(it.MAX_ZOOM)}getOpacity(){return this.get(it.OPACITY)}getSourceState(){return X()}getVisible(){return this.get(it.VISIBLE)}getZIndex(){return this.get(it.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(it.EXTENT,t)}setMaxResolution(t){this.set(it.MAX_RESOLUTION,t)}setMinResolution(t){this.set(it.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(it.MAX_ZOOM,t)}setMinZoom(t){this.set(it.MIN_ZOOM,t)}setOpacity(t){Q(typeof t=="number","Layer opacity must be a number"),this.set(it.OPACITY,t)}setVisible(t){this.set(it.VISIBLE,t)}setZIndex(t){this.set(it.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}class Gr extends Wc{constructor(t){const e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(it.SOURCE,this.handleSourcePropertyChange_);const i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return t=t||[],t.push(this),t}getLayerStatesArray(t){return t=t||[],t.push(this.getLayerState()),t}getSource(){return this.get(it.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(dt(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=H(t,j.CHANGE,this.handleSourceChange_,this),t.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e;const i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof De?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let n;if(e.layerStatesArray){if(n=e.layerStatesArray.find(o=>o.layer===this),!n)return!1}else n=this.getLayerState();const r=this.getExtent();return Ua(n,e.viewState)&&(!r||Vt(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];const i=t instanceof De?t.getViewStateAndExtent():t;let n=e(i);return Array.isArray(n)||(n=[n]),n}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(it.MAP,t)}getMapInternal(){return this.get(it.MAP)}setMap(t){this.mapPrecomposeKey_&&(dt(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(dt(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=H(t,kt.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=H(this,j.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);Q(!e.some(n=>n.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)}setSource(t){this.set(it.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function Ua(s,t){if(!s.visible)return!1;const e=t.resolution;if(e<s.minResolution||e>=s.maxResolution)return!1;const i=t.zoom;return i>s.minZoom&&i<=s.maxZoom}const lh={RENDER_ORDER:"renderOrder"};class zr extends Gr{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(lh.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new Sc(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(lh.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Pc:t;const e=ep(t);this.styleFunction_=t===null?void 0:xg(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}function ep(s){if(s===void 0)return Pc;if(!s)return null;if(typeof s=="function"||s instanceof lt)return s;if(!Array.isArray(s))return th([s]);if(s.length===0)return[];const t=s.length,e=s[0];if(e instanceof lt){const n=new Array(t);for(let r=0;r<t;++r){const o=s[r];if(!(o instanceof lt))throw new Error("Expected a list of style instances");n[r]=o}return n}if("style"in e){const n=new Array(t);for(let r=0;r<t;++r){const o=s[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");n[r]=o}return wg(n)}return th(s)}class Ht extends zr{constructor(t){super(t)}createRenderer(){return new Wf(this)}}const qt={ADD:"add",REMOVE:"remove"},hh={LENGTH:"length"};class Ns extends $e{constructor(t,e,i){super(t),this.element=e,this.index=i}}class Qt extends Te{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t??[],this.unique_)for(let i=1,n=this.array_.length;i<n;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let i=0,n=e.length;i<n;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(hh.LENGTH)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new Ns(qt.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,n=e.length;i<n;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new Ns(qt.REMOVE,e,t)),e}setAt(t,e){const i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const n=this.array_[t];this.array_[t]=e,this.dispatchEvent(new Ns(qt.REMOVE,n,t)),this.dispatchEvent(new Ns(qt.ADD,e,t))}updateLength_(){this.set(hh.LENGTH,this.array_.length)}assertUnique_(t,e){const i=this.array_;for(let n=0,r=i.length;n<r;++n)if(i[n]===t&&n!==e)throw new Error("Duplicate item added to a unique collection")}}let ip=!1;function np(s,t,e,i,n,r,o){const a=new XMLHttpRequest;a.open("GET",typeof s=="function"?s(e,i,n):s,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=ip,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const h=t.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(t.readFeatures(c,{extent:e,featureProjection:n}),t.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function ch(s,t){return function(e,i,n,r,o){np(s,t,e,i,n,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function sp(s,t){return[[-1/0,-1/0,1/0,1/0]]}function ur(s,t,e,i,n,r,o){let a,l;const h=(e-t)/i;if(h===1)a=t;else if(h===2)a=t,l=n;else if(h!==0){let c=s[t],u=s[t+1],d=0;const f=[0];for(let p=t+i;p<e;p+=i){const m=s[p],y=s[p+1];d+=Math.sqrt((m-c)*(m-c)+(y-u)*(y-u)),f.push(d),c=m,u=y}const g=n*d,_=Mu(f,g);_<0?(l=(g-f[-_-2])/(f[-_-1]-f[-_-2]),a=t+(-_-2)*i):a=t+_*i}o=o>1?o:2,r=r||new Array(o);for(let c=0;c<o;++c)r[c]=a===void 0?NaN:l===void 0?s[a+c]:se(s[a+c],s[a+i+c],l);return r}function Ho(s,t,e,i,n,r){if(e==t)return null;let o;if(n<s[t+i-1])return r?(o=s.slice(t,t+i),o[i-1]=n,o):null;if(s[e-1]<n)return r?(o=s.slice(e-i,e),o[i-1]=n,o):null;if(n==s[t+i-1])return s.slice(t,t+i);let a=t/i,l=e/i;for(;a<l;){const d=a+l>>1;n<s[(d+1)*i-1]?l=d:a=d+1}const h=s[a*i-1];if(n==h)return s.slice((a-1)*i,(a-1)*i+i);const c=s[(a+1)*i-1],u=(n-h)/(c-h);o=[];for(let d=0;d<i-1;++d)o.push(se(s[(a-1)*i+d],s[a*i+d],u));return o.push(n),o}function rp(s,t,e,i,n,r,o){if(o)return Ho(s,t,e[e.length-1],i,n,r);let a;if(n<s[i-1])return r?(a=s.slice(0,i),a[i-1]=n,a):null;if(s[s.length-1]<n)return r?(a=s.slice(s.length-i),a[i-1]=n,a):null;for(let l=0,h=e.length;l<h;++l){const c=e[l];if(t!=c){if(n<s[t+i-1])return null;if(n<=s[c-1])return Ho(s,t,c,i,n,!1);t=c}}return null}class fe extends _i{constructor(t,e){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendCoordinate(t){Fe(this.flatCoordinates,t),this.changed()}clone(){const t=new fe(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<ki(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ma(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Da(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,n))}forEachSegment(t){return Nc(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){return this.layout!="XYM"&&this.layout!="XYZM"?null:(e=e!==void 0?e:!1,Ho(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return fi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return ur(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return ba(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(t){const e=[];return e.length=Mr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new fe(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return Nr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,this.getExtent())}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Pr(this.flatCoordinates,0,t,this.stride),this.changed()}}class _n extends _i{constructor(t,e,i){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(e!==void 0&&i)this.setFlatCoordinates(e,t),this.ends_=i;else{const n=t,r=[],o=[];for(let l=0,h=n.length;l<h;++l){const c=n[l];Fe(r,c.getFlatCoordinates()),o.push(r.length)}const a=n.length===0?this.getLayout():n[0].getLayout();this.setFlatCoordinates(a,r),this.ends_=o}}appendLineString(t){Fe(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new _n(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<ki(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Aa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ka(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,i,n))}getCoordinateAtM(t,e,i){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(e=e!==void 0?e:!1,i=i!==void 0?i:!1,rp(this.flatCoordinates,0,this.ends_,this.stride,t,e,i))}getCoordinates(){return Kn(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new fe(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){const t=this.flatCoordinates,e=this.ends_,i=this.layout,n=[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o],h=new fe(t.slice(r,l),i);n.push(h),r=l}return n}getLength(){const t=this.ends_;let e=0,i=0;for(let n=0,r=t.length;n<r;++n)i+=ba(this.flatCoordinates,e,t[n],this.stride),e=t[n];return i}getFlatMidpoints(){const t=[],e=this.flatCoordinates;let i=0;const n=this.ends_,r=this.stride;for(let o=0,a=n.length;o<a;++o){const l=n[o],h=ur(e,i,l,r,.5);Fe(t,h),i=l}return t}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=dc(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,i),new _n(e,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(t){return Ug(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=us(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}class ps extends _i{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){Fe(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){const t=new ps(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<ki(this.getExtent(),t,e))return n;const r=this.flatCoordinates,o=this.stride;for(let a=0,l=r.length;a<l;a+=o){const h=qe(t,e,r[a],r[a+1]);if(h<n){n=h;for(let c=0;c<o;++c)i[c]=r[a+c];i.length=o}}return n}getCoordinates(){return fi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new gt(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){const t=this.flatCoordinates,e=this.layout,i=this.stride,n=[];for(let r=0,o=t.length;r<o;r+=i){const a=new gt(t.slice(r,r+i),e);n.push(a)}return n}getType(){return"MultiPoint"}intersectsExtent(t){const e=this.flatCoordinates,i=this.stride;for(let n=0,r=e.length;n<r;n+=i){const o=e[n],a=e[n+1];if(la(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Pr(this.flatCoordinates,0,t,this.stride),this.changed()}}function Uc(s,t,e,i){const n=[];let r=Wt();for(let o=0,a=e.length;o<a;++o){const l=e[o];r=ca(s,t,l[0],i),n.push((r[0]+r[2])/2,(r[1]+r[3])/2),t=l[l.length-1]}return n}class mn extends _i{constructor(t,e,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(t[0])){const n=t,r=[],o=[];for(let a=0,l=n.length;a<l;++a){const h=n[a],c=r.length,u=h.getEnds();for(let d=0,f=u.length;d<f;++d)u[d]+=c;Fe(r,h.getFlatCoordinates()),o.push(u)}e=n.length===0?this.getLayout():n[0].getLayout(),t=r,i=o}e!==void 0&&i?(this.setFlatCoordinates(e,t),this.endss_=i):this.setCoordinates(t,e)}appendPolygon(t){let e;if(!this.flatCoordinates)this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();else{const i=this.flatCoordinates.length;Fe(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let n=0,r=e.length;n<r;++n)e[n]+=i}this.endss_.push(e),this.changed()}clone(){const t=this.endss_.length,e=new Array(t);for(let n=0;n<t;++n)e[n]=this.endss_[n].slice();const i=new mn(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,n){return n<ki(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(zg(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),$g(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return Wg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return Gg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Zo(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,Wo(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=Uc(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Oc(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new ps(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;$c(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Zo(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=cf(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new mn(e,"XY",i)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(t===0)e=0;else{const r=this.endss_[t-1];e=r[r.length-1]}const i=this.endss_[t].slice(),n=i[i.length-1];if(e!==0)for(let r=0,o=i.length;r<o;++r)i[r]-=e;return new ht(this.flatCoordinates.slice(e,n),this.layout,i)}getPolygons(){const t=this.layout,e=this.flatCoordinates,i=this.endss_,n=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o].slice(),h=l[l.length-1];if(r!==0)for(let u=0,d=l.length;u<d;++u)l[u]-=r;const c=new ht(e.slice(r,h),t,l);n.push(c),r=h}return n}getType(){return"MultiPolygon"}intersectsExtent(t){return Xg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const i=ec(this.flatCoordinates,0,t,this.stride,this.endss_);if(i.length===0)this.flatCoordinates.length=0;else{const n=i[i.length-1];this.flatCoordinates.length=n.length===0?0:n[n.length-1]}this.changed()}}const uh=Mt();class Jt{constructor(t,e,i,n,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=r,this.squaredTolerance_,this.stride_=n,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?ha(this.flatCoordinates_):ca(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=ue(this.getExtent());this.flatInteriorPoints_=Oa(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=Bc(this.flatCoordinates_,this.ends_),e=Uc(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=Oc(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=ur(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const i=this.ends_;for(let n=0,r=i.length;n<r;++n){const o=i[n],a=ur(t,e,o,this.stride_,.5);Fe(this.flatMidpoints_,a),e=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=Ct(t);const e=t.getExtent(),i=t.getWorldExtent();if(e&&i){const n=Yt(i)/Yt(e);ge(uh,i[0],i[3],n,-n,0,0,0),Oe(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,uh,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new Jt(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Lh((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let n;switch(this.type_){case"LineString":i.length=Mr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=dc(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,n);break;case"Polygon":n=[],i.length=Ra(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,n);break}return n&&(this.simplifiedGeometry_=new Jt(this.type_,i,n,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Jt.prototype.getFlatCoordinates=Jt.prototype.getOrientedFlatCoordinates;class dh{constructor(t){this.rbush_=new Sc(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[$(e)]=i}load(t,e){const i=new Array(e.length);for(let n=0,r=e.length;n<r;n++){const o=t[n],a=e[n],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[n]=l,this.items_[$(a)]=l}this.rbush_.load(i)}remove(t){const e=$(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){const i=this.items_[$(e)],n=[i.minX,i.minY,i.maxX,i.maxY];dn(n,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(n){return n.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let n=0,r=t.length;n<r;n++)if(i=e(t[n]),i)return i;return i}isEmpty(){return Ai(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return ti(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(const e in t.items_)this.items_[e]=t.items_[e]}}class Xc extends Te{constructor(t){super(),this.projection=Ct(t.projection),this.attributions_=fh(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(i,n){e.viewResolver=i,e.viewRejector=n})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=fh(t),this.changed()}setState(t){this.state_=t,this.changed()}}function fh(s){return s?typeof s=="function"?s:(Array.isArray(s)||(s=[s]),t=>s):null}const Bt={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class oi extends $e{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class St extends Xc{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=Yn,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(Q(this.format_,"`format` must be set when `url` is set"),this.loader_=ch(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:sp;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new dh:null,this.loadedExtentsRtree_=new dh,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,n;Array.isArray(t.features)?n=t.features:t.features&&(i=t.features,n=i.getArray()),!e&&i===void 0&&(i=new Qt(n)),n!==void 0&&this.addFeaturesInternal(n),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=$(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const n=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(n,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new oi(Bt.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Jt||(this.featureChangeKeys_[t]=[H(e,j.CHANGE,this.handleFeatureChange_,this),H(e,hn.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const n=String(e.getId());if(!(n in this.idIndex_))this.idIndex_[n]=e;else if(e instanceof Jt){const r=this.idIndex_[n];r instanceof Jt?Array.isArray(r)?r.push(e):this.idIndex_[n]=[r,e]:i=!1}else i=!1}return i&&(Q(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],n=[];for(let r=0,o=t.length;r<o;r++){const a=t[r],l=$(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=$(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();e.push(c),n.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,n),this.hasListener(Bt.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new oi(Bt.ADDFEATURE,i[r]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(Bt.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(Bt.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(qt.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(qt.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(dt);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(const i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new oi(Bt.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(n){const r=n.getGeometry();if(r instanceof Jt||r.intersectsCoordinate(t))return e(n)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){const n=i.getGeometry();if(n instanceof Jt||n.intersectsExtent(t)){const r=e(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),Ai(this.nullGeometryFeatures_)||Fe(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const n=Fh(t,e);return[].concat(...n.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],n=t[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return e=e||cn,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){const c=h.getGeometry(),u=a;if(a=c instanceof Jt?0:c.closestPointXY(i,n,o,a),a<u){r=h;const d=Math.sqrt(a);l[0]=i-d,l[1]=n-d,l[2]=i+d,l[3]=n+d}}}),r}getExtent(t){return this.featuresRtree_?.getExtent(t)??null}getFeatureById(t){const e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,i=$(e),n=e.getGeometry();if(!n)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{const o=n.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}const r=e.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new oi(Bt.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return e!==void 0?e in this.idIndex_:$(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Ai(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){const n=this.loadedExtentsRtree_,r=this.strategy_(t,e,i);for(let o=0,a=r.length;o<a;++o){const l=r[o];if(!n.forEachInExtent(l,function(c){return On(c.extent,l)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new oi(Bt.FEATURESLOADSTART));const c=g=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new oi(Bt.FEATURESLOADEND,void 0,g))},u=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new oi(Bt.FEATURESLOADERROR))};let d=!1;const f=this.loader_.call(this,l,e,i,g=>d||c(g),()=>d||u());f instanceof Promise?(d=!0,f.then(g=>{this.addFeatures(g),c(g)}).catch(u)):this.loader_.length<4&&(this.loading=!1),n.insert(l,{extent:l.slice()})}}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_,i=e.forEachInExtent(t,function(n){if(dn(n.extent,t))return n});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,n=t.length;i<n;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=$(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(dt),delete this.featureChangeKeys_[e];const n=t.getId();if(n!==void 0){const r=n.toString(),o=this.idIndex_[r];o===t?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[e],this.hasListener(Bt.REMOVEFEATURE)&&this.dispatchEvent(new oi(Bt.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(const e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){Q(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(ch(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}}var Ce=(s=>(s.WGS84="wgs84",s.GCJ02="gcj02",s.BD09="bd09",s.WEB_MERCATOR="web_mercator",s))(Ce||{}),J=(s=>(s.SATELLITE="satellite",s.STREETS="streets",s.TOPO="topo",s.OCEANS="oceans",s.GRAY="gray",s.DARK_GRAY="dark-gray",s.NATIONAL_GEOGRAPHIC="national-geographic",s.TERRAIN="terrain",s.HYBRID="hybrid",s.LIGHT_GRAY="light-gray",s.IMAGERY="imagery",s.PHYSICAL="physical",s.AMAP_STREETS="amap-streets",s.AMAP_SATELLITE="amap-satellite",s.GOOGLE_STREETS="google-streets",s.GOOGLE_SATELLITE="google-satellite",s))(J||{}),nt=(s=>(s.MARKER="marker",s.POLYGON="polygon",s.POLYLINE="polyline",s.CIRCLE="circle",s.HEATMAP="heatmap",s.CLUSTER="cluster",s.GEOJSON="geojson",s.TILE="tile",s.BARCHART="barchart",s.CIRCLE_DRAW="circle-draw",s.RECTANGLE_DRAW="rectangle-draw",s.TRIANGLE_DRAW="triangle-draw",s.DISTANCE_MEASUREMENT="distance-measurement",s.AREA_MEASUREMENT="area-measurement",s))(nt||{});function _s(s=""){return`${s}${Date.now()}_${Math.random().toString(36).substr(2,8)}`}function ft(s){return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${s[3]??1})`}class jc extends Ut{constructor(t,e,i){super(t,e,nt.MARKER,{...i,zIndex:i?.zIndex??15}),this.features=new Map,this.defaultColor=i?.defaultColor||[255,0,0,.8],this.defaultSize=i?.defaultSize||12,this.source=new St,this.layer=new Ht({source:this.source,properties:{id:t,name:e,type:nt.MARKER},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createLayer(t){return t.addLayer(this.layer),this.layer}addMarker(t){const e=new ot({geometry:new gt(te([t.longitude,t.latitude])),id:t.id,title:t.title,popupContent:t.popupContent}),i=t.color||this.defaultColor,n=t.size||this.defaultSize;e.setStyle(new lt({image:new ze({radius:n/2,fill:new ut({color:ft(i)}),stroke:new _t({color:"#fff",width:2})})})),this.source?.addFeature(e),this.features.set(t.id,e)}removeMarker(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t))}updateMarkerPosition(t,e,i){const n=this.features.get(t);n&&n.setGeometry(new gt(te([e,i])))}getAllMarkers(){const t=[];return this.features.forEach((e,i)=>{const n=e.getGeometry(),r=Pt(n.getCoordinates());t.push({id:i,longitude:r[0],latitude:r[1],title:e.get("title"),popupContent:e.get("popupContent")})}),t}updateData(t){t.markers&&(this.clear(),t.markers.forEach(e=>this.addMarker(e)))}}class op extends Ut{constructor(t,e,i){super(t,e,nt.POLYGON,{...i,zIndex:i?.zIndex??10}),this.features=new Map,this.defaultFillColor=i?.defaultFillColor||[255,0,0,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[255,0,0,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||2,this.source=new St,this.layer=new Ht({source:this.source,properties:{id:t,name:e,type:nt.POLYGON},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createLayer(t){return t.addLayer(this.layer),this.layer}addPolygon(t){const e=[t.points.map(([r,o])=>te([r,o]))],i=new ht(e),n=new ot({geometry:i,id:t.id,title:t.title});n.setStyle(new lt({fill:new ut({color:ft(t.fillColor||this.defaultFillColor)}),stroke:new _t({color:ft(t.outlineColor||this.defaultOutlineColor),width:t.outlineWidth||this.defaultOutlineWidth})})),this.source?.addFeature(n),this.features.set(t.id,n)}removePolygon(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t))}updateData(t){t.polygons&&(this.clear(),t.polygons.forEach(e=>this.addPolygon(e)))}}class ap extends Ut{constructor(t,e,i){super(t,e,nt.POLYLINE,{...i,zIndex:i?.zIndex??10}),this.features=new Map,this.defaultColor=i?.defaultColor||[0,0,255,1],this.defaultWidth=i?.defaultWidth||3,this.source=new St,this.layer=new Ht({source:this.source,properties:{id:t,name:e,type:nt.POLYLINE},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createLayer(t){return t.addLayer(this.layer),this.layer}addPolyline(t){const e=t.points.map(([r,o])=>te([r,o])),i=new fe(e),n=new ot({geometry:i,id:t.id,title:t.title});n.setStyle(new lt({stroke:new _t({color:ft(t.color||this.defaultColor),width:t.width||this.defaultWidth})})),this.source?.addFeature(n),this.features.set(t.id,n)}removePolyline(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t))}updateData(t){t.polylines&&(this.clear(),t.polylines.forEach(e=>this.addPolyline(e)))}}class Ee extends _i{constructor(t,e,i){super(),i!==void 0&&e===void 0?this.setFlatCoordinates(i,t):(e=e||0,this.setCenterAndRadius(t,e,i))}clone(){const t=new Ee(this.flatCoordinates.slice(),void 0,this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){const r=this.flatCoordinates,o=t-r[0],a=e-r[1],l=o*o+a*a;if(l<n){if(l===0)for(let h=0;h<this.stride;++h)i[h]=r[h];else{const h=this.getRadius()/Math.sqrt(l);i[0]=r[0]+h*o,i[1]=r[1]+h*a;for(let c=2;c<this.stride;++c)i[c]=r[c]}return i.length=this.stride,l}return n}containsXY(t,e){const i=this.flatCoordinates,n=t-i[0],r=e-i[1];return n*n+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(t){const e=this.flatCoordinates,i=e[this.stride]-e[0];return ti(e[0]-i,e[1]-i,e[0]+i,e[1]+i,t)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){const t=this.flatCoordinates[this.stride]-this.flatCoordinates[0],e=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return t*t+e*e}getType(){return"Circle"}intersectsExtent(t){const e=this.getExtent();if(Vt(t,e)){const i=this.getCenter();return t[0]<=i[0]&&t[2]>=i[0]||t[1]<=i[1]&&t[3]>=i[1]?!0:ua(t,this.intersectsCoordinate.bind(this))}return!1}setCenter(t){const e=this.stride,i=this.flatCoordinates[e]-this.flatCoordinates[0],n=t.slice();n[e]=n[0]+i;for(let r=1;r<e;++r)n[e+r]=t[r];this.setFlatCoordinates(this.layout,n),this.changed()}setCenterAndRadius(t,e,i){this.setLayout(i,t,0),this.flatCoordinates||(this.flatCoordinates=[]);const n=this.flatCoordinates;let r=tc(n,0,t,this.stride);n[r++]=n[0]+e;for(let o=1,a=this.stride;o<a;++o)n[r++]=n[o];n.length=r,this.changed()}getCoordinates(){return null}setCoordinates(t,e){}setRadius(t){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+t,this.changed()}rotate(t,e){const i=this.getCenter(),n=this.getStride();this.setCenter(va(i,0,i.length,n,t,e,i)),this.changed()}}Ee.prototype.transform;class lp extends Ut{constructor(t,e,i){super(t,e,nt.CIRCLE,{...i,zIndex:i?.zIndex??15}),this.features=new Map,this.defaultFillColor=i?.defaultFillColor||[0,255,0,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[0,255,0,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||2,this.source=new St,this.layer=new Ht({source:this.source,properties:{id:t,name:e,type:nt.CIRCLE},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createLayer(t){return t.addLayer(this.layer),this.layer}addCircle(t){const e=te(t.center),i=new Ee(e,t.radius),n=new ot({geometry:i,id:t.id,title:t.title});n.setStyle(new lt({fill:new ut({color:ft(t.fillColor||this.defaultFillColor)}),stroke:new _t({color:ft(t.outlineColor||this.defaultOutlineColor),width:t.outlineWidth||this.defaultOutlineWidth})})),this.source?.addFeature(n),this.features.set(t.id,n)}removeCircle(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t))}updateData(t){t.circles&&(this.clear(),t.circles.forEach(e=>this.addCircle(e)))}}const z={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function Vc(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ko(s,t){return s[0]=t[0],s[1]=t[1],s[4]=t[2],s[5]=t[3],s[12]=t[4],s[13]=t[5],s}const dr=34962,Xa=34963,hp=35044,go=35048,cp=5121,up=5123,dp=5125,Yc=5126,gh=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function fp(s,t){t=Object.assign({preserveDrawingBuffer:!0,antialias:!Ad},t);const e=gh.length;for(let i=0;i<e;++i)try{const n=s.getContext(gh[i],t);if(n)return n}catch{}return null}const gp={STATIC_DRAW:hp};class po{constructor(t,e){this.array_=null,this.type_=t,Q(t===dr||t===Xa,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=e!==void 0?e:gp.STATIC_DRAW}ofSize(t){return this.array_=new(Gs(this.type_))(t),this}fromArray(t){return this.array_=Gs(this.type_).from(t),this}fromArrayBuffer(t){return this.array_=new(Gs(this.type_))(t),this}getType(){return this.type_}getArray(){return this.array_}setArray(t){const e=Gs(this.type_);if(!(t instanceof e))throw new Error(`Expected ${e}`);this.array_=t}getUsage(){return this.usage_}getSize(){return this.array_?this.array_.length:0}}function Gs(s){switch(s){case dr:return Float32Array;case Xa:return Uint32Array;default:return Float32Array}}const zs={LOST:"webglcontextlost",RESTORED:"webglcontextrestored"},pp=`
|
|
7
|
+
precision mediump float;
|
|
8
|
+
|
|
9
|
+
attribute vec2 a_position;
|
|
10
|
+
varying vec2 v_texCoord;
|
|
11
|
+
varying vec2 v_screenCoord;
|
|
12
|
+
|
|
13
|
+
uniform vec2 u_screenSize;
|
|
14
|
+
|
|
15
|
+
void main() {
|
|
16
|
+
v_texCoord = a_position * 0.5 + 0.5;
|
|
17
|
+
v_screenCoord = v_texCoord * u_screenSize;
|
|
18
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
19
|
+
}
|
|
20
|
+
`,_p=`
|
|
21
|
+
precision mediump float;
|
|
22
|
+
|
|
23
|
+
uniform sampler2D u_image;
|
|
24
|
+
uniform float u_opacity;
|
|
25
|
+
|
|
26
|
+
varying vec2 v_texCoord;
|
|
27
|
+
|
|
28
|
+
void main() {
|
|
29
|
+
gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;
|
|
30
|
+
}
|
|
31
|
+
`;class ph{constructor(t){this.gl_=t.webGlContext;const e=this.gl_;this.scaleRatio_=t.scaleRatio||1,this.renderTargetTexture_=e.createTexture(),this.renderTargetTextureSize_=null,this.frameBuffer_=e.createFramebuffer(),this.depthBuffer_=e.createRenderbuffer();const i=e.createShader(e.VERTEX_SHADER);e.shaderSource(i,t.vertexShader||pp),e.compileShader(i);const n=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(n,t.fragmentShader||_p),e.compileShader(n),this.renderTargetProgram_=e.createProgram(),e.attachShader(this.renderTargetProgram_,i),e.attachShader(this.renderTargetProgram_,n),e.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=e.createBuffer();const r=[-1,-1,1,-1,-1,1,1,-1,1,1,-1,1];e.bindBuffer(e.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),e.bufferData(e.ARRAY_BUFFER,new Float32Array(r),e.STATIC_DRAW),this.renderTargetAttribLocation_=e.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],t.uniforms&&Object.keys(t.uniforms).forEach(o=>{this.uniforms_.push({value:t.uniforms[o],location:e.getUniformLocation(this.renderTargetProgram_,o)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(t){const e=this.getGL(),i=[e.drawingBufferWidth*this.scaleRatio_,e.drawingBufferHeight*this.scaleRatio_];if(e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer()),e.bindRenderbuffer(e.RENDERBUFFER,this.getDepthBuffer()),e.viewport(0,0,i[0],i[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==i[0]||this.renderTargetTextureSize_[1]!==i[1]){this.renderTargetTextureSize_=i;const n=0,r=e.RGBA,o=0,a=e.RGBA,l=e.UNSIGNED_BYTE,h=null;e.bindTexture(e.TEXTURE_2D,this.renderTargetTexture_),e.texImage2D(e.TEXTURE_2D,n,r,i[0],i[1],o,a,l,h),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.renderTargetTexture_,0),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i[0],i[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthBuffer_)}}apply(t,e,i,n){const r=this.getGL(),o=t.size;if(r.bindFramebuffer(r.FRAMEBUFFER,e?e.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!e){const l=$(r.canvas);if(!t.renderTargets[l]){const h=r.getContextAttributes();h&&h.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),t.renderTargets[l]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,o[0],o[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const a=t.layerStatesArray[t.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(t),i&&i(r,t),r.drawArrays(r.TRIANGLES,0,6),n&&n(r,t)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(t){const e=this.getGL();let i,n=1;this.uniforms_.forEach(function(r){if(i=typeof r.value=="function"?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof ImageData)r.texture||(r.texture=e.createTexture()),e.activeTexture(e[`TEXTURE${n}`]),e.bindTexture(e.TEXTURE_2D,r.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),i instanceof ImageData?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,i.width,i.height,0,e.UNSIGNED_BYTE,new Uint8Array(i.data)):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i),e.uniform1i(r.location,n++);else if(Array.isArray(i))switch(i.length){case 2:e.uniform2f(r.location,i[0],i[1]);return;case 3:e.uniform3f(r.location,i[0],i[1],i[2]);return;case 4:e.uniform4f(r.location,i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&e.uniform1f(r.location,i)})}}const xe={PROJECTION_MATRIX:"u_projectionMatrix",INVERT_PROJECTION_MATRIX:"u_invertProjectionMatrix",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"},Nt={UNSIGNED_BYTE:cp,UNSIGNED_SHORT:up,UNSIGNED_INT:dp,FLOAT:Yc},fr={};function _h(s){return"shared/"+s}let mh=0;function mp(){const s="unique/"+mh;return mh+=1,s}function yp(s){let t=fr[s];if(!t){const e=document.createElement("canvas");e.width=1,e.height=1,e.style.position="absolute",e.style.left="0",t={users:0,context:fp(e)},fr[s]=t}return t.users+=1,t.context}function xp(s){const t=fr[s];if(!t||(t.users-=1,t.users>0))return;const e=t.context,i=e.getExtension("WEBGL_lose_context");i&&i.loseContext();const n=e.canvas;n.width=1,n.height=1,delete fr[s]}class Ep extends rs{constructor(t){super(),t=t||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=t.canvasCacheKey?_h(t.canvasCacheKey):mp(),this.gl_=yp(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const e=this.gl_.canvas;e.addEventListener(zs.LOST,this.boundHandleWebGLContextLost_),e.addEventListener(zs.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=Mt(),this.offsetScaleMatrix_=Mt(),this.tmpMat4_=Vc(),this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],t.uniforms&&this.setUniforms(t.uniforms),this.postProcessPasses_=t.postProcesses?t.postProcesses.map(i=>new ph({webGlContext:this.gl_,scaleRatio:i.scaleRatio,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,uniforms:i.uniforms})):[new ph({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now(),this.maxAttributeCount_=this.gl_.getParameter(this.gl_.MAX_VERTEX_ATTRIBS)}setUniforms(t){this.uniforms_=[],this.addUniforms(t)}addUniforms(t){for(const e in t)this.uniforms_.push({name:e,value:t[e]})}canvasCacheKeyMatches(t){return this.canvasCacheKey_===_h(t)}getExtension(t){if(t in this.extensionCache_)return this.extensionCache_[t];const e=this.gl_.getExtension(t);return this.extensionCache_[t]=e,e}getInstancedRenderingExtension_(){const t=this.getExtension("ANGLE_instanced_arrays");return Q(!!t,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),t}bindBuffer(t){const e=this.gl_,i=$(t);let n=this.bufferCache_[i];if(!n){const r=e.createBuffer();n={buffer:t,webGlBuffer:r},this.bufferCache_[i]=n}e.bindBuffer(t.getType(),n.webGlBuffer)}flushBufferData(t){const e=this.gl_;this.bindBuffer(t),e.bufferData(t.getType(),t.getArray(),t.getUsage())}deleteBuffer(t){const e=$(t);delete this.bufferCache_[e]}disposeInternal(){const t=this.gl_.canvas;t.removeEventListener(zs.LOST,this.boundHandleWebGLContextLost_),t.removeEventListener(zs.RESTORED,this.boundHandleWebGLContextRestored_),xp(this.canvasCacheKey_),delete this.gl_}prepareDraw(t,e,i){const n=this.gl_,r=this.getCanvas(),o=t.size,a=t.pixelRatio;(r.width!==o[0]*a||r.height!==o[1]*a)&&(r.width=o[0]*a,r.height=o[1]*a,r.style.width=o[0]+"px",r.style.height=o[1]+"px");for(let l=this.postProcessPasses_.length-1;l>=0;l--)this.postProcessPasses_[l].init(t);n.bindTexture(n.TEXTURE_2D,null),n.clearColor(0,0,0,0),n.depthRange(0,1),n.clearDepth(1),n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.ONE,e?n.ZERO:n.ONE_MINUS_SRC_ALPHA),i?(n.enable(n.DEPTH_TEST),n.depthFunc(n.LEQUAL)):n.disable(n.DEPTH_TEST)}bindFrameBuffer(t,e){const i=this.getGL();i.bindFramebuffer(i.FRAMEBUFFER,t),e&&i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0)}bindInitialFrameBuffer(){const t=this.getGL(),e=this.postProcessPasses_[0].getFrameBuffer();t.bindFramebuffer(t.FRAMEBUFFER,e);const i=this.postProcessPasses_[0].getRenderTargetTexture();t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0)}bindTexture(t,e,i){const n=this.gl_;n.activeTexture(n.TEXTURE0+e),n.bindTexture(n.TEXTURE_2D,t),n.uniform1i(this.getUniformLocation(i),e)}bindAttribute(t,e,i){const n=this.getGL();this.bindBuffer(t);const r=this.getAttributeLocation(e);n.enableVertexAttribArray(r),n.vertexAttribPointer(r,i,n.FLOAT,!1,0,0)}prepareDrawToRenderTarget(t,e,i,n){const r=this.gl_,o=e.getSize();r.bindFramebuffer(r.FRAMEBUFFER,e.getFramebuffer()),r.bindRenderbuffer(r.RENDERBUFFER,e.getDepthbuffer()),r.viewport(0,0,o[0],o[1]),r.bindTexture(r.TEXTURE_2D,e.getTexture()),r.clearColor(0,0,0,0),r.depthRange(0,1),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),r.enable(r.BLEND),r.blendFunc(r.ONE,i?r.ZERO:r.ONE_MINUS_SRC_ALPHA),n?(r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL)):r.disable(r.DEPTH_TEST)}drawElements(t,e){const i=this.gl_;this.getExtension("OES_element_index_uint");const n=i.UNSIGNED_INT,r=4,o=e-t,a=t*r;i.drawElements(i.TRIANGLES,o,n,a)}drawElementsInstanced(t,e,i){const n=this.gl_;this.getExtension("OES_element_index_uint");const r=this.getInstancedRenderingExtension_(),o=n.UNSIGNED_INT,a=4,l=e-t,h=t*a;r.drawElementsInstancedANGLE(n.TRIANGLES,l,o,h,i);for(let c=0;c<this.maxAttributeCount_;c++)r.vertexAttribDivisorANGLE(c,0)}finalizeDraw(t,e,i){for(let n=0,r=this.postProcessPasses_.length;n<r;n++)n===r-1?this.postProcessPasses_[n].apply(t,null,e,i):this.postProcessPasses_[n].apply(t,this.postProcessPasses_[n+1])}getCanvas(){return this.gl_.canvas}getGL(){return this.gl_}applyFrameState(t){const e=t.size,i=t.viewState.rotation,n=t.pixelRatio;this.setUniformFloatValue(xe.TIME,(Date.now()-this.startTime_)*.001),this.setUniformFloatValue(xe.ZOOM,t.viewState.zoom),this.setUniformFloatValue(xe.RESOLUTION,t.viewState.resolution),this.setUniformFloatValue(xe.PIXEL_RATIO,n),this.setUniformFloatVec2(xe.VIEWPORT_SIZE_PX,[e[0],e[1]]),this.setUniformFloatValue(xe.ROTATION,i)}applyHitDetectionUniform(t){const e=this.getUniformLocation(xe.HIT_DETECTION);this.getGL().uniform1i(e,t?1:0),t&&this.setUniformFloatValue(xe.PIXEL_RATIO,.5)}applyUniforms(t){const e=this.gl_;let i,n=0;this.uniforms_.forEach(r=>{if(i=typeof r.value=="function"?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof ImageData||i instanceof WebGLTexture){i instanceof WebGLTexture&&!r.texture?(r.prevValue=void 0,r.texture=i):r.texture||(r.prevValue=void 0,r.texture=e.createTexture()),this.bindTexture(r.texture,n,r.name),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);const o=!(i instanceof HTMLImageElement)||i.complete;!(i instanceof WebGLTexture)&&o&&r.prevValue!==i&&(r.prevValue=i,e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i)),n++}else if(Array.isArray(i)&&i.length===6)this.setUniformMatrixValue(r.name,Ko(this.tmpMat4_,i));else if(Array.isArray(i)&&i.length<=4)switch(i.length){case 2:e.uniform2f(this.getUniformLocation(r.name),i[0],i[1]);return;case 3:e.uniform3f(this.getUniformLocation(r.name),i[0],i[1],i[2]);return;case 4:e.uniform4f(this.getUniformLocation(r.name),i[0],i[1],i[2],i[3]);return;default:return}else typeof i=="number"&&e.uniform1f(this.getUniformLocation(r.name),i)})}useProgram(t,e){this.disableAllAttributes_(),this.gl_.useProgram(t),this.currentProgram_=t,e&&(this.applyFrameState(e),this.applyUniforms(e))}compileShader(t,e){const i=this.gl_,n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}getProgram(t,e){const i=this.gl_,n=this.compileShader(t,i.FRAGMENT_SHADER),r=this.compileShader(e,i.VERTEX_SHADER),o=i.createProgram();if(i.attachShader(o,n),i.attachShader(o,r),i.linkProgram(o),!i.getShaderParameter(n,i.COMPILE_STATUS)){const a=`Fragment shader compilation failed: ${i.getShaderInfoLog(n)}`;throw new Error(a)}if(i.deleteShader(n),!i.getShaderParameter(r,i.COMPILE_STATUS)){const a=`Vertex shader compilation failed: ${i.getShaderInfoLog(r)}`;throw new Error(a)}if(i.deleteShader(r),!i.getProgramParameter(o,i.LINK_STATUS)){const a=`GL program linking failed: ${i.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(t){const e=$(this.currentProgram_);return this.uniformLocationsByProgram_[e]===void 0&&(this.uniformLocationsByProgram_[e]={}),this.uniformLocationsByProgram_[e][t]===void 0&&(this.uniformLocationsByProgram_[e][t]=this.gl_.getUniformLocation(this.currentProgram_,t)),this.uniformLocationsByProgram_[e][t]}getAttributeLocation(t){const e=$(this.currentProgram_);return this.attribLocationsByProgram_[e]===void 0&&(this.attribLocationsByProgram_[e]={}),this.attribLocationsByProgram_[e][t]===void 0&&(this.attribLocationsByProgram_[e][t]=this.gl_.getAttribLocation(this.currentProgram_,t)),this.attribLocationsByProgram_[e][t]}makeProjectionTransform(t,e){const i=t.size,n=t.viewState.rotation,r=t.viewState.resolution,o=t.viewState.center;return ge(e,0,0,2/(r*i[0]),2/(r*i[1]),-n,-o[0],-o[1]),e}setUniformFloatValue(t,e){this.gl_.uniform1f(this.getUniformLocation(t),e)}setUniformFloatVec2(t,e){this.gl_.uniform2fv(this.getUniformLocation(t),e)}setUniformFloatVec4(t,e){this.gl_.uniform4fv(this.getUniformLocation(t),e)}setUniformMatrixValue(t,e){this.gl_.uniformMatrix4fv(this.getUniformLocation(t),!1,e)}disableAllAttributes_(){for(let t=0;t<this.maxAttributeCount_;t++)this.gl_.disableVertexAttribArray(t)}enableAttributeArray_(t,e,i,n,r,o){const a=this.getAttributeLocation(t);a<0||(this.gl_.enableVertexAttribArray(a),this.gl_.vertexAttribPointer(a,e,i,!1,n,r),o&&this.getInstancedRenderingExtension_().vertexAttribDivisorANGLE(a,1))}enableAttributes_(t,e){const i=vp(t);let n=0;for(let r=0;r<t.length;r++){const o=t[r];o.name&&this.enableAttributeArray_(o.name,o.size,o.type||Yc,i,n,e),n+=o.size*Zc(o.type)}}enableAttributes(t){this.enableAttributes_(t,!1)}enableAttributesInstanced(t){this.enableAttributes_(t,!0)}handleWebGLContextLost(t){yn(this.bufferCache_),this.currentProgram_=null,t.preventDefault()}handleWebGLContextRestored(){this.needsToBeRecreated_=!0}needsToBeRecreated(){return this.needsToBeRecreated_}createTexture(t,e,i,n){const r=this.gl_;i=i||r.createTexture();const o=n?r.NEAREST:r.LINEAR;r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);const a=0,l=r.RGBA,h=0,c=r.RGBA,u=r.UNSIGNED_BYTE;return e instanceof Uint8Array?r.texImage2D(r.TEXTURE_2D,a,l,t[0],t[1],h,c,u,e):e?r.texImage2D(r.TEXTURE_2D,a,l,c,u,e):r.texImage2D(r.TEXTURE_2D,a,l,t[0],t[1],h,c,u,null),i}}function vp(s){let t=0;for(let e=0;e<s.length;e++){const i=s[e];t+=i.size*Zc(i.type)}return t}function Zc(s){switch(s){case Nt.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case Nt.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case Nt.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case Nt.FLOAT:default:return Float32Array.BYTES_PER_ELEMENT}}class ja extends Er{constructor(t,e,i){super(),i=i||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(j.CHANGE)}release(){this.setState(z.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==z.EMPTY){if(this.state!==z.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){X()}getAlpha(t,e){if(!this.transition_)return 1;let i=this.transitionStarts_[t];if(!i)i=e,this.transitionStarts_[t]=i;else if(i===-1)return 1;const n=e-i+1e3/60;return n>=this.transition_?1:Dc(n/this.transition_)}inTransition(t){return this.transition_?this.transitionStarts_[t]!==-1:!1}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}function qo(s){return s instanceof Image||s instanceof HTMLCanvasElement||s instanceof HTMLVideoElement||s instanceof ImageBitmap?s:null}const Cp=new Error("disposed"),wp=[256,256];class yh extends ja{constructor(t){const e=z.IDLE;super(t.tileCoord,e,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=qo(this.data_);return t?[t.width,t.height]:wp}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==z.IDLE&&this.state!==z.ERROR)return;this.state=z.LOADING,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=z.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=z.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(Cp),this.controller_=null),super.disposeInternal()}}class Hc extends ja{constructor(t,e,i,n,r,o){super(t,e,o),this.crossOrigin_=n?.crossOrigin,this.referrerPolicy_=n?.referrerPolicy,this.src_=i,this.key=i,this.image_,le?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=z.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=z.ERROR,this.unlistenImage_(),this.image_=Tp(),this.changed()}handleImageLoad_(){if(le)this.state=z.LOADED;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=z.LOADED:this.state=z.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==z.ERROR&&(this.state=z.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==z.IDLE&&(this.state=z.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=Vd(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 Tp(){const s=Tt(1,1);return s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,1,1),s.canvas}let _o;const ln=[];function xh(s,t,e,i,n){s.beginPath(),s.moveTo(0,0),s.lineTo(t,e),s.lineTo(i,n),s.closePath(),s.save(),s.clip(),s.fillRect(0,0,Math.max(t,i)+1,Math.max(e,n)),s.restore()}function mo(s,t){return Math.abs(s[t*4]-210)>2||Math.abs(s[t*4+3]-.75*255)>2}function Sp(){if(_o===void 0){const s=Tt(6,6,ln);s.globalCompositeOperation="lighter",s.fillStyle="rgba(210, 0, 0, 0.75)",xh(s,4,5,4,0),xh(s,4,5,0,5);const t=s.getImageData(0,0,3,3).data;_o=mo(t,0)||mo(t,4)||mo(t,8),Lr(s),ln.push(s.canvas)}return _o}function Eh(s,t,e,i){const n=Rr(e,t,s);let r=Ml(t,i,e);const o=t.getMetersPerUnit();o!==void 0&&(r*=o);const a=s.getMetersPerUnit();a!==void 0&&(r/=a);const l=s.getExtent();if(!l||un(l,n)){const h=Ml(s,r,n)/r;isFinite(h)&&h>0&&(r/=h)}return r}function Rp(s,t,e,i){const n=ue(e);let r=Eh(s,t,n,i);return(!isFinite(r)||r<=0)&&ua(e,function(o){return r=Eh(s,t,o,i),isFinite(r)&&r>0}),r}function bp(s,t,e,i,n,r,o,a,l,h,c,u,d,f){const g=Tt(Math.round(e*s),Math.round(e*t),ln);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function _(E){return Math.round(E*e)/e}g.globalCompositeOperation="lighter";const p=Wt();l.forEach(function(E,S,w){Bn(p,E.extent)});let m;const y=e/i,C=(u?1:1+Math.pow(2,-24))/y;m=Tt(Math.round(at(p)*y),Math.round(Yt(p)*y),ln),u||(m.imageSmoothingEnabled=!1),l.forEach(function(E,S,w){if(E.image.width>0&&E.image.height>0){if(E.clipExtent){m.save();const I=(E.clipExtent[0]-p[0])*y,F=-(E.clipExtent[3]-p[3])*y,D=at(E.clipExtent)*y,k=Yt(E.clipExtent)*y;m.rect(u?I:Math.round(I),u?F:Math.round(F),u?D:Math.round(I+D)-Math.round(I),u?k:Math.round(F+k)-Math.round(F)),m.clip()}const T=(E.extent[0]-p[0])*y,R=-(E.extent[3]-p[3])*y,b=at(E.extent)*y,L=Yt(E.extent)*y;m.drawImage(E.image,h,h,E.image.width-2*h,E.image.height-2*h,u?T:Math.round(T),u?R:Math.round(R),u?b:Math.round(T+b)-Math.round(T),u?L:Math.round(R+L)-Math.round(R)),E.clipExtent&&m.restore()}});const x=Fi(o);return a.getTriangles().forEach(function(E,S,w){const T=E.source,R=E.target;let b=T[0][0],L=T[0][1],I=T[1][0],F=T[1][1],D=T[2][0],k=T[2][1];const G=_((R[0][0]-x[0])/r),M=_(-(R[0][1]-x[1])/r),N=_((R[1][0]-x[0])/r),B=_(-(R[1][1]-x[1])/r),q=_((R[2][0]-x[0])/r),K=_(-(R[2][1]-x[1])/r),ct=b,st=L;b=0,L=0,I-=ct,F-=st,D-=ct,k-=st;const P=[[I,F,0,0,N-G],[D,k,0,0,q-G],[0,0,I,F,B-M],[0,0,D,k,K-M]],mt=Uu(P);if(!mt)return;if(g.save(),g.beginPath(),Sp()||!u){g.moveTo(N,B);const Xt=4,ie=G-N,mi=M-B;for(let ne=0;ne<Xt;ne++)g.lineTo(N+_((ne+1)*ie/Xt),B+_(ne*mi/(Xt-1))),ne!=Xt-1&&g.lineTo(N+_((ne+1)*ie/Xt),B+_((ne+1)*mi/(Xt-1)));g.lineTo(q,K)}else g.moveTo(N,B),g.lineTo(G,M),g.lineTo(q,K);g.clip(),g.transform(mt[0],mt[2],mt[1],mt[3],G,M),g.translate(p[0]-ct,p[3]-st);let Ot;if(m)Ot=m.canvas,g.scale(C,-C);else{const Xt=l[0],ie=Xt.extent;Ot=Xt.image,g.scale(at(ie)/Ot.width,-Yt(ie)/Ot.height)}g.drawImage(Ot,0,0),g.restore()}),m&&(Lr(m),ln.push(m.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(E,S,w){const T=E.target,R=(T[0][0]-x[0])/r,b=-(T[0][1]-x[1])/r,L=(T[1][0]-x[0])/r,I=-(T[1][1]-x[1])/r,F=(T[2][0]-x[0])/r,D=-(T[2][1]-x[1])/r;g.beginPath(),g.moveTo(L,I),g.lineTo(R,b),g.lineTo(F,D),g.closePath(),g.stroke()}),g.restore()),g.canvas}const Pp=10,vh=.25;class Lp{constructor(t,e,i,n,r,o,a){this.sourceProj_=t,this.targetProj_=e;let l={};const h=a?yd(C=>wt(a,Rr(C,this.targetProj_,this.sourceProj_))):Hn(this.targetProj_,this.sourceProj_);this.transformInv_=function(C){const x=C[0]+"/"+C[1];return l[x]||(l[x]=h(C)),l[x]},this.maxSourceExtent_=n,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&at(n)>=at(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?at(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?at(this.targetProj_.getExtent()):null;const c=Fi(i),u=wr(i),d=Cr(i),f=vr(i),g=this.transformInv_(c),_=this.transformInv_(u),p=this.transformInv_(d),m=this.transformInv_(f),y=Pp+(o?Math.max(0,Math.ceil(Math.log2(Do(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,_,p,m,y),this.wrapsXInSource_){let C=1/0;this.triangles_.forEach(function(x,E,S){C=Math.min(C,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])-C>this.sourceWorldWidth_/2){const E=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];E[0][0]-C>this.sourceWorldWidth_/2&&(E[0][0]-=this.sourceWorldWidth_),E[1][0]-C>this.sourceWorldWidth_/2&&(E[1][0]-=this.sourceWorldWidth_),E[2][0]-C>this.sourceWorldWidth_/2&&(E[2][0]-=this.sourceWorldWidth_);const S=Math.min(E[0][0],E[1][0],E[2][0]);Math.max(E[0][0],E[1][0],E[2][0])-S<this.sourceWorldWidth_/2&&(x.source=E)}})}l={}}addTriangle_(t,e,i,n,r,o){this.triangles_.push({source:[n,r,o],target:[t,e,i]})}addQuad_(t,e,i,n,r,o,a,l,h){const c=er([r,o,a,l]),u=this.sourceWorldWidth_?at(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const p=er([t,e,i,n]);g=at(p)/this.targetWorldWidth_>vh||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>vh||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!Vt(c,this.maxSourceExtent_))return;let _=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(_=(!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),_!=1&&_!=2&&_!=4&&_!=8)return}if(h>0){if(!g){const p=[(t[0]+i[0])/2,(t[1]+i[1])/2],m=this.transformInv_(p);let y;f?y=(Ii(r[0],d)+Ii(a[0],d))/2-Ii(m[0],d):y=(r[0]+a[0])/2-m[0];const C=(r[1]+a[1])/2-m[1];g=y*y+C*C>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const p=[(e[0]+i[0])/2,(e[1]+i[1])/2],m=this.transformInv_(p),y=[(n[0]+t[0])/2,(n[1]+t[1])/2],C=this.transformInv_(y);this.addQuad_(t,e,p,y,r,o,m,C,h-1),this.addQuad_(y,p,i,n,C,m,a,l,h-1)}else{const p=[(t[0]+e[0])/2,(t[1]+e[1])/2],m=this.transformInv_(p),y=[(i[0]+n[0])/2,(i[1]+n[1])/2],C=this.transformInv_(y);this.addQuad_(t,p,y,n,r,m,C,l,h-1),this.addQuad_(p,e,i,y,m,o,a,C,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(_&11)==0&&this.addTriangle_(t,i,n,r,a,l),(_&14)==0&&this.addTriangle_(t,i,e,r,a,o),_&&((_&13)==0&&this.addTriangle_(e,n,t,o,l,r),(_&7)==0&&this.addTriangle_(e,n,i,o,l,a))}calculateSourceExtent(){const t=Wt();return this.triangles_.forEach(function(e,i,n){const r=e.source;Wn(t,r[0]),Wn(t,r[1]),Wn(t,r[2])}),t}getTriangles(){return this.triangles_}}const Ip=.5;class Kc extends ja{constructor(t,e,i,n,r,o,a,l,h,c,u,d){super(r,z.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=n,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const f=n.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let _=this.sourceTileGrid_.getExtent();const p=g?Li(f,g):f;if(Do(p)===0){this.state=z.EMPTY;return}const m=t.getExtent();m&&(_?_=Li(_,m):_=m);const y=n.getResolution(this.wrappedTileCoord_[0]),C=Rp(t,i,p,y);if(!isFinite(C)||C<=0){this.state=z.EMPTY;return}const x=c!==void 0?c:Ip;if(this.triangulation_=new Lp(t,i,p,_,C*x,y),this.triangulation_.getTriangles().length===0){this.state=z.EMPTY;return}this.sourceZ_=e.getZForResolution(C);let E=this.triangulation_.calculateSourceExtent();if(_&&(t.canWrapX()?(E[1]=pt(E[1],_[1],_[3]),E[3]=pt(E[3],_[1],_[3])):E=Li(E,_)),!Do(E))this.state=z.EMPTY;else{let S=0,w=0;t.canWrapX()&&(S=at(m),w=Math.floor((E[0]-m[0])/S)),Fh(E.slice(),t,!0).forEach(R=>{const b=e.getTileRangeForExtentAndZ(R,this.sourceZ_);for(let L=b.minX;L<=b.maxX;L++)for(let I=b.minY;I<=b.maxY;I++){const F=w*S;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,L,I,a),offset:F})}++w}),this.sourceTiles_.length===0&&(this.state=z.EMPTY)}}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const i=e.tile;if(i&&i.getState()==z.LOADED){const n=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);n[0]+=e.offset,n[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:n,clipExtent:r,image:i.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=z.ERROR;else{const e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),n=typeof i=="number"?i:i[0],r=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(e),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=bp(n,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=z.LOADED}this.changed()}load(){for(const t of this.sourceTiles_)t.tile=t.getTile();if(this.state==z.IDLE){this.state=z.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const i=e.getState();if(i==z.IDLE||i==z.LOADING){t++;const n=H(e,j.CHANGE,r=>{const o=e.getState();(o==z.LOADED||o==z.ERROR||o==z.EMPTY)&&(dt(n),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},i,n){e.getState()==z.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(dt),this.sourcesListenerKeys_=null}release(){this.canvas_&&(Lr(this.canvas_.getContext("2d")),ln.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}}class Va{constructor(t,e,i,n){this.minX=t,this.maxX=e,this.minY=i,this.maxY=n}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}}function Xi(s,t,e,i,n){return n!==void 0?(n.minX=s,n.maxX=t,n.minY=e,n.maxY=i,n):new Va(s,t,e,i)}class Ch{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof rs&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const i=this.entries_[t];return Q(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(t){const e=this.entries_[t];return Q(e!==void 0,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.key_;return t}getValues(){const t=new Array(this.count_);let e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){Q(!(t in this.entries_),"Tried to set a value for a key that is used already");const i={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[t]=i,++this.count_}setSize(t){this.highWaterMark=t}}function gr(s,t,e,i){return i!==void 0?(i[0]=s,i[1]=t,i[2]=e,i):[s,t,e]}function Mp(s,t,e){return s+"/"+t+"/"+e}function Hs(s,t,e,i,n){return`${$(s)},${t},${Mp(e,i,n)}`}function Ap(s){return Dp(s[0],s[1],s[2])}function Dp(s,t,e){return(t<<s)+e}function kp(s,t){const e=s[0],i=s[1],n=s[2];if(t.getMinZoom()>e||e>t.getMaxZoom())return!1;const r=t.getFullTileRange(e);return r?r.containsXY(i,n):!0}class Ya extends Cc{constructor(t,e){super(t),e=e||{},this.inversePixelTransform_=Mt(),this.postProcesses_=e.postProcesses,this.uniforms_=e.uniforms,this.helper,this.onMapChanged_=()=>{this.clearCache(),this.removeHelper()},t.addChangeListener(it.MAP,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(kt.PRECOMPOSE)){const n=new Vn(kt.PRECOMPOSE,void 0,e,t);i.dispatchEvent(n)}}dispatchPostComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(kt.POSTCOMPOSE)){const n=new Vn(kt.POSTCOMPOSE,void 0,e,t);i.dispatchEvent(n)}}reset(t){this.uniforms_=t.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(t){if(this.getLayer().getRenderSource()){let e=!0,i=-1,n;for(let o=0,a=t.layerStatesArray.length;o<a;o++){const l=t.layerStatesArray[o].layer,h=l.getRenderer();if(!(h instanceof Ya)){e=!0;continue}const c=l.getClassName();if((e||c!==n)&&(i+=1,e=!1),n=c,h===this)break}const r="map/"+t.mapId+"/group/"+i;(!this.helper||!this.helper.canvasCacheKeyMatches(r)||this.helper.needsToBeRecreated())&&(this.removeHelper(),this.helper=new Ep({postProcesses:this.postProcesses_,uniforms:this.uniforms_,canvasCacheKey:r}),n&&(this.helper.getCanvas().className=n),this.afterHelperCreated())}return this.prepareFrameInternal(t)}afterHelperCreated(){}prepareFrameInternal(t){return!0}clearCache(){}disposeInternal(){this.clearCache(),this.removeHelper(),this.getLayer()?.removeChangeListener(it.MAP,this.onMapChanged_),super.disposeInternal()}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){ge(this.inversePixelTransform_,0,0,i.pixelRatio,-i.pixelRatio,0,0,-i.size[1]);const r=new Vn(t,this.inversePixelTransform_,i,e);n.dispatchEvent(r)}}preRender(t,e){this.dispatchRenderEvent_(kt.PRERENDER,t,e)}postRender(t,e){this.dispatchRenderEvent_(kt.POSTRENDER,t,e)}}const yo={TILE_TEXTURE_ARRAY:"u_tileTextures",TEXTURE_PIXEL_WIDTH:"u_texturePixelWidth",TEXTURE_PIXEL_HEIGHT:"u_texturePixelHeight"};class Fp{constructor(t,e){this.name=t,this.data=e,this.texture_=null}getTexture(t){if(!this.texture_){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.data.length/4,1,0,t.RGBA,t.UNSIGNED_BYTE,this.data),this.texture_=e}return this.texture_}delete(t){this.texture_&&t.deleteTexture(this.texture_),this.texture_=null}}function Op(s,t){return`operator_${s}_${Object.keys(t.functions).length}`}function pi(s){const t=s.toString();return t.includes(".")?t:t+".0"}function Za(s){if(s.length<2||s.length>4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${s.length}(${s.map(pi).join(", ")})`}function Ks(s){const t=pe(s),e=t.length>3?t[3]:1;return Za([t[0]/255,t[1]/255,t[2]/255,e])}function Np(s){const t=Zt(s);return Za(t)}const xo={};let Gp=0;function ns(s){return s in xo||(xo[s]=Gp++),xo[s]}function He(s){return pi(ns(s))}function Ha(s){return"u_var_"+s}function qc(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const Eo="getBandValue",zp="u_paletteTextures",Jc="featureId",Qc="geometryType",Jo=-9999999;function $p(s,t,e,i){const n=Ft(s,t,e);return Ka(n,t,i)}function tt(s){return(t,e,i)=>{const n=e.args.length,r=new Array(n);for(let o=0;o<n;++o)r[o]=Ka(e.args[o],i,t);return s(r,t)}}const Bp={[v.Get]:(s,t)=>{const i=t.args[0].value;i in s.properties||(s.properties[i]={name:i,type:t.type});let r="a_prop_"+i;return Ie(t.type,bt)&&(r=`(${r} > 0.0)`),r},[v.Id]:s=>(s.featureId=!0,"a_"+Jc),[v.GeometryType]:s=>(s.geometryType=!0,"a_"+Qc),[v.LineMetric]:()=>"currentLineMetric",[v.Var]:(s,t)=>{const i=t.args[0].value;i in s.variables||(s.variables[i]={name:i,type:t.type});let r=Ha(i);return Ie(t.type,bt)&&(r=`(${r} > 0.0)`),r},[v.Has]:(s,t)=>{const i=t.args[0].value;return i in s.properties||(s.properties[i]={name:i,type:t.type}),`(a_prop_${i} != ${pi(Jo)})`},[v.Resolution]:()=>"u_resolution",[v.Zoom]:()=>"u_zoom",[v.Time]:()=>"u_time",[v.Any]:tt(s=>`(${s.join(" || ")})`),[v.All]:tt(s=>`(${s.join(" && ")})`),[v.Not]:tt(([s])=>`(!${s})`),[v.Equal]:tt(([s,t])=>`(${s} == ${t})`),[v.NotEqual]:tt(([s,t])=>`(${s} != ${t})`),[v.GreaterThan]:tt(([s,t])=>`(${s} > ${t})`),[v.GreaterThanOrEqualTo]:tt(([s,t])=>`(${s} >= ${t})`),[v.LessThan]:tt(([s,t])=>`(${s} < ${t})`),[v.LessThanOrEqualTo]:tt(([s,t])=>`(${s} <= ${t})`),[v.Multiply]:tt(s=>`(${s.join(" * ")})`),[v.Divide]:tt(([s,t])=>`(${s} / ${t})`),[v.Add]:tt(s=>`(${s.join(" + ")})`),[v.Subtract]:tt(([s,t])=>`(${s} - ${t})`),[v.Clamp]:tt(([s,t,e])=>`clamp(${s}, ${t}, ${e})`),[v.Mod]:tt(([s,t])=>`mod(${s}, ${t})`),[v.Pow]:tt(([s,t])=>`pow(${s}, ${t})`),[v.Abs]:tt(([s])=>`abs(${s})`),[v.Floor]:tt(([s])=>`floor(${s})`),[v.Ceil]:tt(([s])=>`ceil(${s})`),[v.Round]:tt(([s])=>`floor(${s} + 0.5)`),[v.Sin]:tt(([s])=>`sin(${s})`),[v.Cos]:tt(([s])=>`cos(${s})`),[v.Atan]:tt(([s,t])=>t!==void 0?`atan(${s}, ${t})`:`atan(${s})`),[v.Sqrt]:tt(([s])=>`sqrt(${s})`),[v.Match]:tt(s=>{const t=s[0],e=s[s.length-1];let i=null;for(let n=s.length-3;n>=1;n-=2){const r=s[n],o=s[n+1];i=`(${t} == ${r} ? ${o} : ${i||e})`}return i}),[v.Between]:tt(([s,t,e])=>`(${s} >= ${t} && ${s} <= ${e})`),[v.Interpolate]:tt(([s,t,...e])=>{let i="";for(let n=0;n<e.length-2;n+=2){const r=e[n],o=i||e[n+1],a=e[n+2],l=e[n+3];let h;s===pi(1)?h=`(${t} - ${r}) / (${a} - ${r})`:h=`(pow(${s}, (${t} - ${r})) - 1.0) / (pow(${s}, (${a} - ${r})) - 1.0)`,i=`mix(${o}, ${l}, clamp(${h}, 0.0, 1.0))`}return i}),[v.Case]:tt(s=>{const t=s[s.length-1];let e=null;for(let i=s.length-3;i>=0;i-=2){const n=s[i],r=s[i+1];e=`(${n} ? ${r} : ${e||t})`}return e}),[v.In]:tt(([s,...t],e)=>{const i=Op("in",e),n=[];for(let r=0;r<t.length;r+=1)n.push(` if (inputValue == ${t[r]}) { return true; }`);return e.functions[i]=`bool ${i}(float inputValue) {
|
|
32
|
+
${n.join(`
|
|
33
|
+
`)}
|
|
34
|
+
return false;
|
|
35
|
+
}`,`${i}(${s})`}),[v.Array]:tt(s=>`vec${s.length}(${s.join(", ")})`),[v.Color]:tt(s=>{if(s.length===1)return`vec4(vec3(${s[0]} / 255.0), 1.0)`;if(s.length===2)return`vec4(vec3(${s[0]} / 255.0), ${s[1]})`;const t=s.slice(0,3).map(i=>`${i} / 255.0`);if(s.length===3)return`vec4(${t.join(", ")}, 1.0)`;const e=s[3];return`vec4(${t.join(", ")}, ${e})`}),[v.Band]:tt(([s,t,e],i)=>{if(!(Eo in i.functions)){let n="";const r=i.bandCount||1;for(let o=0;o<r;o++){const a=Math.floor(o/4);let l=o%4;o===r-1&&l===1&&(l=3);const h=`${yo.TILE_TEXTURE_ARRAY}[${a}]`;n+=` if (band == ${o+1}.0) {
|
|
36
|
+
return texture2D(${h}, v_textureCoord + vec2(dx, dy))[${l}];
|
|
37
|
+
}
|
|
38
|
+
`}i.functions[Eo]=`float getBandValue(float band, float xOffset, float yOffset) {
|
|
39
|
+
float dx = xOffset / ${yo.TEXTURE_PIXEL_WIDTH};
|
|
40
|
+
float dy = yOffset / ${yo.TEXTURE_PIXEL_HEIGHT};
|
|
41
|
+
${n}
|
|
42
|
+
}`}return`${Eo}(${s}, ${t??"0.0"}, ${e??"0.0"})`}),[v.Palette]:(s,t)=>{const[e,...i]=t.args,n=i.length,r=new Uint8Array(n*4);for(let h=0;h<i.length;h++){const c=i[h].value,u=pe(c),d=h*4;r[d]=u[0],r[d+1]=u[1],r[d+2]=u[2],r[d+3]=u[3]*255}s.paletteTextures||(s.paletteTextures=[]);const o=`${zp}[${s.paletteTextures.length}]`,a=new Fp(o,r);s.paletteTextures.push(a);const l=Ka(e,A,s);return`texture2D(${o}, vec2((${l} + 0.5) / ${n}.0, 0.5))`}};function Ka(s,t,e){if(s instanceof Rc){const i=Bp[s.operator];if(i===void 0)throw new Error(`No compiler defined for this operator: ${JSON.stringify(s.operator)}`);return i(e,s,t)}if((s.type&A)>0)return pi(s.value);if((s.type&bt)>0)return s.value.toString();if((s.type&It)>0)return He(s.value.toString());if((s.type&yt)>0)return Ks(s.value);if((s.type&ee)>0)return Za(s.value);if((s.type&ce)>0)return Np(s.value);throw new Error(`Unexpected expression ${s.value} (expected type ${en(t)})`)}function Wp(){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 wh=.985;function U(s,t,e,i){return $p(t,e,i??fs(),s)}function Up(s){const t=pe(s),e=t[0]*256,i=t[1],n=t[2]*256,r=Math.round(t[3]*255);return[e+i,n+r]}const Xp=`vec4 unpackColor(vec2 packedColor) {
|
|
43
|
+
return vec4(
|
|
44
|
+
min(floor(packedColor[0] / 256.0) / 255.0, 1.0),
|
|
45
|
+
min(mod(packedColor[0], 256.0) / 255.0, 1.0),
|
|
46
|
+
min(floor(packedColor[1] / 256.0) / 255.0, 1.0),
|
|
47
|
+
min(mod(packedColor[1], 256.0) / 255.0, 1.0)
|
|
48
|
+
);
|
|
49
|
+
}`;function qa(s){return s===yt||s===ce?2:s===ee?4:1}function Qo(s){const t=qa(s);return t>1?`vec${t}`:"float"}function tu(s,t){for(const e in t.variables){const i=t.variables[e],n=Ha(i.name);let r=Qo(i.type);i.type===yt&&(r="vec4"),s.addUniform(n,r)}for(const e in t.properties){const i=t.properties[e],n=Qo(i.type),r=`a_prop_${i.name}`;i.type===yt?s.addAttribute(r,n,`unpackColor(${r})`,"vec4"):s.addAttribute(r,n)}for(const e in t.functions)s.addVertexShaderFunction(t.functions[e]),s.addFragmentShaderFunction(t.functions[e])}function eu(s,t){const e={};for(const i in s.variables){const n=s.variables[i],r=Ha(n.name);e[r]=()=>{const o=t[n.name];if(typeof o=="number")return o;if(typeof o=="boolean")return o?1:0;if(n.type===yt){const a=[...pe(o||"#eee")];return a[0]/=255,a[1]/=255,a[2]/=255,a[3]??=1,a}return typeof o=="string"?ns(o):o}}return e}function iu(s){const t={};for(const e in s.properties){const i=s.properties[e],n=r=>{const o=r.get(i.name);return i.type===yt?Up([...pe(o||"#eee")]):typeof o=="string"?ns(o):typeof o=="boolean"?o?1:0:o};t[`prop_${i.name}`]={size:qa(i.type),callback:n}}return t}function vo(s){return s-qs(s)}function qs(s){return Math.fround(s)}const jp=`
|
|
50
|
+
vec2 df_from(float value) {
|
|
51
|
+
return vec2(value, 0.);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
float df_float(vec2 df) {
|
|
55
|
+
return df.x;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
vec2 df_add(vec2 dfa, vec2 dfb) {
|
|
59
|
+
vec2 dfc;
|
|
60
|
+
float t1, t2, e;
|
|
61
|
+
|
|
62
|
+
t1 = dfa.x * u_one + dfb.x * u_one;
|
|
63
|
+
e = t1 * u_one - dfa.x * u_one;
|
|
64
|
+
t2 = ((dfb.x - e) + (dfa.x - (t1 - e))) * u_one + dfa.y + dfb.y * u_one;
|
|
65
|
+
|
|
66
|
+
dfc.x = t1 * u_one + t2 * u_one;
|
|
67
|
+
dfc.y = t2 - (dfc.x - t1) * u_one;
|
|
68
|
+
return dfc;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
vec2 df_sub(vec2 dfa, vec2 dfb) {
|
|
72
|
+
vec2 dfc;
|
|
73
|
+
float e, t1, t2;
|
|
74
|
+
|
|
75
|
+
t1 = dfa.x - dfb.x;
|
|
76
|
+
e = t1 - dfa.x;
|
|
77
|
+
t2 = ((-dfb.x - e) + (dfa.x - (t1 - e))) + dfa.y - dfb.y;
|
|
78
|
+
|
|
79
|
+
dfc.x = t1 + t2;
|
|
80
|
+
dfc.y = t2 - (dfc.x - t1);
|
|
81
|
+
return dfc;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
vec2 df_mul(vec2 dfa, vec2 dfb) {
|
|
85
|
+
vec2 dfc;
|
|
86
|
+
float c11, c21, c2, e, t1, t2;
|
|
87
|
+
float a1, a2, b1, b2, cona, conb, split = 4097.;
|
|
88
|
+
|
|
89
|
+
cona = dfa.x * split * u_one;
|
|
90
|
+
conb = dfb.x * split * u_one;
|
|
91
|
+
a1 = cona * u_one - (cona - dfa.x);
|
|
92
|
+
b1 = conb * u_one - (conb - dfb.x);
|
|
93
|
+
a2 = dfa.x * u_one - a1;
|
|
94
|
+
b2 = dfb.x * u_one - b1 * u_one;
|
|
95
|
+
|
|
96
|
+
c11 = dfa.x * u_one * dfb.x * u_one;
|
|
97
|
+
c21 = a2 * b2 * u_one + (a2 * b1 + (a1 * b2 + (a1 * b1 - c11))) * u_one;
|
|
98
|
+
|
|
99
|
+
c2 = dfa.x * dfb.y * u_one + dfa.y * dfb.x * u_one;
|
|
100
|
+
|
|
101
|
+
t1 = c11 + c2 * u_one;
|
|
102
|
+
e = t1 - c11 * u_one;
|
|
103
|
+
t2 = dfa.y * dfb.y * u_one + ((c2 - e) + (c11 - (t1 - e))) + c21 * u_one;
|
|
104
|
+
|
|
105
|
+
dfc.x = t1 * u_one + t2 * u_one;
|
|
106
|
+
dfc.y = t2 - (dfc.x - t1) * u_one;
|
|
107
|
+
|
|
108
|
+
return dfc;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
vec2 df_div(vec2 dfa, vec2 dfb) {
|
|
112
|
+
vec2 dfc;
|
|
113
|
+
float c11, c21, c2, e, t1, t2, t11, t12, t21, t22;
|
|
114
|
+
float a1, a2, b1, b2, cona, conb, split = 4097.;
|
|
115
|
+
float s1, s2;
|
|
116
|
+
|
|
117
|
+
s1 = dfa.x / dfb.x * u_one;
|
|
118
|
+
cona = s1 * split * u_one;
|
|
119
|
+
conb = dfb.x * split * u_one;
|
|
120
|
+
a1 = cona - (cona - s1) * u_one;
|
|
121
|
+
b1 = conb - (conb - dfb.x) * u_one;
|
|
122
|
+
a2 = s1 - a1 * u_one;
|
|
123
|
+
b2 = dfb.x - b1 * u_one;
|
|
124
|
+
|
|
125
|
+
c11 = s1 * dfb.x * u_one;
|
|
126
|
+
c21 = (((a1 * b1 - c11) + a1 * b2) + a2 * b1) + a2 * b2 * u_one;
|
|
127
|
+
|
|
128
|
+
c2 = s1 * dfb.y * u_one;
|
|
129
|
+
|
|
130
|
+
t1 = c11 + c2 * u_one;
|
|
131
|
+
e = t1 - c11 * u_one;
|
|
132
|
+
t2 = ((c2 - e) + (c11 - (t1 - e))) + c21 * u_one;
|
|
133
|
+
|
|
134
|
+
t12 = t1 + t2 * u_one;
|
|
135
|
+
t22 = t2 - (t12 - t1) * u_one;
|
|
136
|
+
|
|
137
|
+
t11 = dfa.x - t12 * u_one;
|
|
138
|
+
e = t11 - dfa.x * u_one;
|
|
139
|
+
t21 = ((-t12 - e) + (dfa.x - (t11 - e))) + dfa.y - t22 * u_one;
|
|
140
|
+
|
|
141
|
+
s2 = (t11 + t21) / dfb.x * u_one;
|
|
142
|
+
|
|
143
|
+
dfc.x = s1 + s2 * u_one;
|
|
144
|
+
dfc.y = s2 - (dfc.x - s1) * u_one;
|
|
145
|
+
|
|
146
|
+
return dfc;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
float df_mod(vec2 df, vec2 m) {
|
|
150
|
+
vec2 q = df_div(df, m) * u_one;
|
|
151
|
+
float qf = floor(q.x);
|
|
152
|
+
float frac = q.x - qf + q.y * u_one;
|
|
153
|
+
if (frac < 0.0) qf -= 1.0;
|
|
154
|
+
if (frac >= 1.0) qf += 1.0;
|
|
155
|
+
vec2 prod = df_mul(df_from(qf), m);
|
|
156
|
+
vec2 rem = df_add(df_from(df.x), df_from(-prod.x)) * u_one;
|
|
157
|
+
rem.y += df.y - prod.y;
|
|
158
|
+
return rem.x + rem.y * u_one;
|
|
159
|
+
}
|
|
160
|
+
`,ji=`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
161
|
+
precision highp float;
|
|
162
|
+
#else
|
|
163
|
+
precision mediump float;
|
|
164
|
+
#endif
|
|
165
|
+
uniform float u_one;
|
|
166
|
+
uniform mat4 u_projectionMatrix;
|
|
167
|
+
uniform mat4 u_invertProjectionMatrix;
|
|
168
|
+
uniform vec2 u_viewportSizePx;
|
|
169
|
+
uniform float u_pixelRatio;
|
|
170
|
+
uniform float u_globalAlpha;
|
|
171
|
+
uniform float u_time;
|
|
172
|
+
uniform float u_zoom;
|
|
173
|
+
uniform float u_resolution;
|
|
174
|
+
uniform float u_rotation;
|
|
175
|
+
uniform vec4 u_renderExtent;
|
|
176
|
+
uniform float u_depth;
|
|
177
|
+
uniform mediump int u_hitDetection;
|
|
178
|
+
|
|
179
|
+
// these 64-bits floats are split into high/low
|
|
180
|
+
uniform vec2 u_df_patternOriginX;
|
|
181
|
+
uniform vec2 u_df_patternOriginY;
|
|
182
|
+
uniform vec2 u_df_patternScaleRatio;
|
|
183
|
+
|
|
184
|
+
const float PI = 3.141592653589793238;
|
|
185
|
+
const float TWO_PI = 2.0 * PI;
|
|
186
|
+
float currentLineMetric = 0.; // an actual value will be used in the stroke shaders
|
|
187
|
+
|
|
188
|
+
vec2 pxToWorld(vec2 pxPos) {
|
|
189
|
+
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
|
190
|
+
return (u_invertProjectionMatrix * vec4(screenPos, 0.0, 1.0)).xy;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
vec2 worldToPx(vec2 worldPos) {
|
|
194
|
+
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
|
|
195
|
+
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
|
|
196
|
+
}
|
|
197
|
+
${Xp}
|
|
198
|
+
${jp}
|
|
199
|
+
`,Vi=Wp();class nu{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${pi(Vi["circle-radius"])} + ${pi(Vi["circle-stroke-width"]*.5)})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=Ks(Vi["circle-fill-color"]),this.texCoordExpression_="vec4(0.0, 0.0, 1.0, 1.0)",this.fragmentDiscardExpression_=null,this.shapeDiscardExpression_=null,this.symbolRotateWithView_=!1,this.hasStroke_=!1,this.strokeWidthExpression_=pi(Vi["stroke-width"]),this.strokeColorExpression_=Ks(Vi["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=He("round"),this.strokeJoinExpression_=He("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=Ks(Vi["fill-color"]),this.fillPatternSizeExpression_=null,this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(t,e){return this.uniforms_.push({name:t,type:e}),this}addAttribute(t,e,i,n){return this.attributes_.push({name:t,type:e,varyingName:t.replace(/^a_/,"v_"),varyingType:n??e,varyingExpression:i??t}),this}setSymbolSizeExpression(t){return this.hasSymbol_=!0,this.symbolSizeExpression_=t,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(t){return this.symbolRotationExpression_=t,this}setSymbolOffsetExpression(t){return this.symbolOffsetExpression_=t,this}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}setSymbolColorExpression(t){return this.hasSymbol_=!0,this.symbolColorExpression_=t,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(t){return this.texCoordExpression_=t,this}setFragmentDiscardExpression(t){return this.fragmentDiscardExpression_=t,this}getFragmentDiscardExpression(){return this.fragmentDiscardExpression_}setShapeDiscardExpression(t){return this.shapeDiscardExpression_=t,this}getShapeDiscardExpression(){return this.shapeDiscardExpression_}setSymbolRotateWithView(t){return this.symbolRotateWithView_=t,this}setStrokeWidthExpression(t){return this.hasStroke_=!0,this.strokeWidthExpression_=t,this}setStrokeColorExpression(t){return this.hasStroke_=!0,this.strokeColorExpression_=t,this}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(t){return this.strokeOffsetExpression_=t,this}setStrokeCapExpression(t){return this.strokeCapExpression_=t,this}setStrokeJoinExpression(t){return this.strokeJoinExpression_=t,this}setStrokeMiterLimitExpression(t){return this.strokeMiterLimitExpression_=t,this}setStrokeDistanceFieldExpression(t){return this.strokeDistanceFieldExpression_=t,this}setStrokePatternLengthExpression(t){return this.strokePatternLengthExpression_=t,this}getStrokePatternLengthExpression(){return this.strokePatternLengthExpression_}setFillColorExpression(t){return this.hasFill_=!0,this.fillColorExpression_=t,this}getFillColorExpression(){return this.fillColorExpression_}setFillPatternSizeExpression(t){return this.fillPatternSizeExpression_=t,this}getFillPatternSizeExpression(){return this.fillPatternSizeExpression_}addVertexShaderFunction(t){return this.vertexShaderFunctions_.includes(t)?this:(this.vertexShaderFunctions_.push(t),this)}addFragmentShaderFunction(t){return this.fragmentShaderFunctions_.includes(t)?this:(this.fragmentShaderFunctions_.push(t),this)}getSymbolVertexShader(){return this.hasSymbol_?`${ji}
|
|
200
|
+
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
|
|
201
|
+
`)}
|
|
202
|
+
attribute vec2 a_position;
|
|
203
|
+
attribute vec2 a_localPosition;
|
|
204
|
+
attribute vec2 a_hitColor;
|
|
205
|
+
|
|
206
|
+
varying vec2 v_texCoord;
|
|
207
|
+
varying vec2 v_quadCoord;
|
|
208
|
+
varying vec4 v_hitColor;
|
|
209
|
+
varying vec2 v_centerPx;
|
|
210
|
+
varying float v_angle;
|
|
211
|
+
varying vec2 v_quadSizePx;
|
|
212
|
+
|
|
213
|
+
${this.attributes_.map(t=>`attribute ${t.type} ${t.name};
|
|
214
|
+
varying ${t.varyingType} ${t.varyingName};`).join(`
|
|
215
|
+
`)}
|
|
216
|
+
${this.vertexShaderFunctions_.join(`
|
|
217
|
+
`)}
|
|
218
|
+
vec2 pxToScreen(vec2 coordPx) {
|
|
219
|
+
vec2 scaled = coordPx / u_viewportSizePx / 0.5;
|
|
220
|
+
return scaled;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
vec2 screenToPx(vec2 coordScreen) {
|
|
224
|
+
return (coordScreen * 0.5 + 0.5) * u_viewportSizePx;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
void main(void) {
|
|
228
|
+
v_quadSizePx = ${this.symbolSizeExpression_};
|
|
229
|
+
vec2 halfSizePx = v_quadSizePx * 0.5;
|
|
230
|
+
vec2 centerOffsetPx = ${this.symbolOffsetExpression_};
|
|
231
|
+
vec2 offsetPx = centerOffsetPx + a_localPosition * halfSizePx * vec2(1., -1.);
|
|
232
|
+
float angle = ${this.symbolRotationExpression_}${this.symbolRotateWithView_?" + u_rotation":""};
|
|
233
|
+
float c = cos(-angle);
|
|
234
|
+
float s = sin(-angle);
|
|
235
|
+
offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);
|
|
236
|
+
vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);
|
|
237
|
+
gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);
|
|
238
|
+
vec4 texCoord = ${this.texCoordExpression_};
|
|
239
|
+
float u = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);
|
|
240
|
+
float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);
|
|
241
|
+
v_texCoord = vec2(u, v);
|
|
242
|
+
v_hitColor = unpackColor(a_hitColor);
|
|
243
|
+
v_angle = angle;
|
|
244
|
+
c = cos(-v_angle);
|
|
245
|
+
s = sin(-v_angle);
|
|
246
|
+
centerOffsetPx = vec2(c * centerOffsetPx.x - s * centerOffsetPx.y, s * centerOffsetPx.x + c * centerOffsetPx.y);
|
|
247
|
+
v_centerPx = screenToPx(center.xy) + centerOffsetPx;
|
|
248
|
+
${this.attributes_.map(t=>` ${t.varyingName} = ${t.varyingExpression};`).join(`
|
|
249
|
+
`)}
|
|
250
|
+
${this.shapeDiscardExpression_?` if (${this.shapeDiscardExpression_}) { gl_Position = vec4(2.0, 2.0, 0.0, 0.0); }`:""}
|
|
251
|
+
}`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${ji}
|
|
252
|
+
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
|
|
253
|
+
`)}
|
|
254
|
+
varying vec2 v_texCoord;
|
|
255
|
+
varying vec4 v_hitColor;
|
|
256
|
+
varying vec2 v_centerPx;
|
|
257
|
+
varying float v_angle;
|
|
258
|
+
varying vec2 v_quadSizePx;
|
|
259
|
+
${this.attributes_.map(t=>`varying ${t.varyingType} ${t.varyingName};`).join(`
|
|
260
|
+
`)}
|
|
261
|
+
${this.fragmentShaderFunctions_.join(`
|
|
262
|
+
`)}
|
|
263
|
+
|
|
264
|
+
void main(void) {
|
|
265
|
+
${this.attributes_.map(t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`).join(`
|
|
266
|
+
`)}
|
|
267
|
+
${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { discard; }`:""}
|
|
268
|
+
vec2 coordsPx = gl_FragCoord.xy / u_pixelRatio - v_centerPx; // relative to center
|
|
269
|
+
float c = cos(v_angle);
|
|
270
|
+
float s = sin(v_angle);
|
|
271
|
+
coordsPx = vec2(c * coordsPx.x - s * coordsPx.y, s * coordsPx.x + c * coordsPx.y);
|
|
272
|
+
gl_FragColor = ${this.symbolColorExpression_};
|
|
273
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
274
|
+
if (u_hitDetection > 0) {
|
|
275
|
+
if (gl_FragColor.a < 0.05) { discard; };
|
|
276
|
+
gl_FragColor = v_hitColor;
|
|
277
|
+
}
|
|
278
|
+
}`:null}getStrokeVertexShader(){return this.hasStroke_?`${ji}
|
|
279
|
+
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
|
|
280
|
+
`)}
|
|
281
|
+
attribute vec2 a_segmentStart;
|
|
282
|
+
attribute vec2 a_segmentEnd;
|
|
283
|
+
attribute vec2 a_localPosition;
|
|
284
|
+
attribute float a_measureStart;
|
|
285
|
+
attribute float a_measureEnd;
|
|
286
|
+
attribute float a_angleTangentSum;
|
|
287
|
+
attribute float a_distanceLow;
|
|
288
|
+
attribute float a_distanceHigh;
|
|
289
|
+
attribute vec2 a_joinAngles;
|
|
290
|
+
attribute vec2 a_hitColor;
|
|
291
|
+
|
|
292
|
+
varying vec2 v_segmentStartPx;
|
|
293
|
+
varying vec2 v_segmentEndPx;
|
|
294
|
+
varying float v_angleStart;
|
|
295
|
+
varying float v_angleEnd;
|
|
296
|
+
varying float v_width;
|
|
297
|
+
varying vec4 v_hitColor;
|
|
298
|
+
varying float v_distancePx;
|
|
299
|
+
varying float v_measureStart;
|
|
300
|
+
varying float v_measureEnd;
|
|
301
|
+
|
|
302
|
+
${this.attributes_.map(t=>`attribute ${t.type} ${t.name};
|
|
303
|
+
varying ${t.varyingType} ${t.varyingName};`).join(`
|
|
304
|
+
`)}
|
|
305
|
+
${this.vertexShaderFunctions_.join(`
|
|
306
|
+
`)}
|
|
307
|
+
|
|
308
|
+
vec4 pxToScreen(vec2 pxPos) {
|
|
309
|
+
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
|
310
|
+
return vec4(screenPos, u_depth, 1.0);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
bool isCap(float joinAngle) {
|
|
314
|
+
return joinAngle < -0.1;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
vec2 getJoinOffsetDirection(vec2 normalPx, float joinAngle) {
|
|
318
|
+
float halfAngle = joinAngle / 2.0;
|
|
319
|
+
float c = cos(halfAngle);
|
|
320
|
+
float s = sin(halfAngle);
|
|
321
|
+
vec2 angleBisectorNormal = vec2(s * normalPx.x + c * normalPx.y, -c * normalPx.x + s * normalPx.y);
|
|
322
|
+
float length = 1.0 / s;
|
|
323
|
+
return angleBisectorNormal * length;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
vec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {
|
|
327
|
+
// if on a cap or the join angle is too high, offset the line along the segment normal
|
|
328
|
+
if (cos(joinAngle) > 0.998 || isCap(joinAngle)) {
|
|
329
|
+
return point - normal * offsetPx;
|
|
330
|
+
}
|
|
331
|
+
// offset is applied along the inverted normal (positive offset goes "right" relative to line direction)
|
|
332
|
+
return point - getJoinOffsetDirection(normal, joinAngle) * offsetPx;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
void main(void) {
|
|
336
|
+
v_angleStart = a_joinAngles.x;
|
|
337
|
+
v_angleEnd = a_joinAngles.y;
|
|
338
|
+
float startEndRatio = a_localPosition.x * 0.5 + 0.5;
|
|
339
|
+
currentLineMetric = mix(a_measureStart, a_measureEnd, startEndRatio);
|
|
340
|
+
// we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)
|
|
341
|
+
|
|
342
|
+
float lineWidth = ${this.strokeWidthExpression_};
|
|
343
|
+
float lineOffsetPx = ${this.strokeOffsetExpression_};
|
|
344
|
+
|
|
345
|
+
// compute segment start/end in px with offset
|
|
346
|
+
vec2 segmentStartPx = worldToPx(a_segmentStart);
|
|
347
|
+
vec2 segmentEndPx = worldToPx(a_segmentEnd);
|
|
348
|
+
vec2 tangentPx = normalize(segmentEndPx - segmentStartPx);
|
|
349
|
+
vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);
|
|
350
|
+
segmentStartPx = getOffsetPoint(segmentStartPx, normalPx, v_angleStart, lineOffsetPx),
|
|
351
|
+
segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);
|
|
352
|
+
|
|
353
|
+
// compute current vertex position
|
|
354
|
+
float normalDir = -1. * a_localPosition.y;
|
|
355
|
+
float tangentDir = -1. * a_localPosition.x;
|
|
356
|
+
float angle = mix(v_angleStart, v_angleEnd, startEndRatio);
|
|
357
|
+
vec2 joinDirection;
|
|
358
|
+
vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);
|
|
359
|
+
// if angle is too high, do not make a proper join
|
|
360
|
+
if (cos(angle) > ${wh} || isCap(angle)) {
|
|
361
|
+
joinDirection = normalPx * normalDir - tangentPx * tangentDir;
|
|
362
|
+
} else {
|
|
363
|
+
joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);
|
|
364
|
+
}
|
|
365
|
+
positionPx = positionPx + joinDirection * (lineWidth * 0.5 + 1.); // adding 1 pixel for antialiasing
|
|
366
|
+
gl_Position = pxToScreen(positionPx);
|
|
367
|
+
|
|
368
|
+
v_segmentStartPx = segmentStartPx;
|
|
369
|
+
v_segmentEndPx = segmentEndPx;
|
|
370
|
+
v_width = lineWidth;
|
|
371
|
+
v_hitColor = unpackColor(a_hitColor);
|
|
372
|
+
|
|
373
|
+
v_distancePx = a_distanceLow / u_resolution - (lineOffsetPx * a_angleTangentSum);
|
|
374
|
+
float distanceHighPx = a_distanceHigh / u_resolution;
|
|
375
|
+
${this.strokePatternLengthExpression_!==null?`v_distancePx = mod(v_distancePx, ${this.strokePatternLengthExpression_});
|
|
376
|
+
distanceHighPx = mod(distanceHighPx, ${this.strokePatternLengthExpression_});
|
|
377
|
+
`:""}v_distancePx += distanceHighPx;
|
|
378
|
+
|
|
379
|
+
v_measureStart = a_measureStart;
|
|
380
|
+
v_measureEnd = a_measureEnd;
|
|
381
|
+
${this.attributes_.map(t=>` ${t.varyingName} = ${t.varyingExpression};`).join(`
|
|
382
|
+
`)}
|
|
383
|
+
${this.shapeDiscardExpression_?` if (${this.shapeDiscardExpression_}) { gl_Position = vec4(2.0, 2.0, 0.0, 0.0); }`:""}
|
|
384
|
+
}`:null}getStrokeFragmentShader(){return this.hasStroke_?`${ji}
|
|
385
|
+
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
|
|
386
|
+
`)}
|
|
387
|
+
varying vec2 v_segmentStartPx;
|
|
388
|
+
varying vec2 v_segmentEndPx;
|
|
389
|
+
varying float v_angleStart;
|
|
390
|
+
varying float v_angleEnd;
|
|
391
|
+
varying float v_width;
|
|
392
|
+
varying vec4 v_hitColor;
|
|
393
|
+
varying float v_distancePx;
|
|
394
|
+
varying float v_measureStart;
|
|
395
|
+
varying float v_measureEnd;
|
|
396
|
+
${this.attributes_.map(t=>`varying ${t.varyingType} ${t.varyingName};`).join(`
|
|
397
|
+
`)}
|
|
398
|
+
${this.fragmentShaderFunctions_.join(`
|
|
399
|
+
`)}
|
|
400
|
+
|
|
401
|
+
bool isCap(float joinAngle) {
|
|
402
|
+
return joinAngle < -0.1;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
float segmentDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
|
406
|
+
vec2 tangent = normalize(end - start);
|
|
407
|
+
vec2 normal = vec2(-tangent.y, tangent.x);
|
|
408
|
+
vec2 startToPoint = point - start;
|
|
409
|
+
return abs(dot(startToPoint, normal)) - width * 0.5;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
float buttCapDistanceField(vec2 point, vec2 start, vec2 end) {
|
|
413
|
+
vec2 startToPoint = point - start;
|
|
414
|
+
vec2 tangent = normalize(end - start);
|
|
415
|
+
return dot(startToPoint, -tangent);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
float squareCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
|
419
|
+
return buttCapDistanceField(point, start, end) - width * 0.5;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
float roundCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
|
423
|
+
float onSegment = max(0., 1000. * dot(point - start, end - start)); // this is very high when inside the segment
|
|
424
|
+
return length(point - start) - width * 0.5 - onSegment;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
float roundJoinDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
|
428
|
+
return roundCapDistanceField(point, start, end, width);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
float bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
|
|
432
|
+
vec2 startToPoint = point - start;
|
|
433
|
+
vec2 tangent = normalize(end - start);
|
|
434
|
+
float c = cos(joinAngle * 0.5);
|
|
435
|
+
float s = sin(joinAngle * 0.5);
|
|
436
|
+
float direction = -sign(sin(joinAngle));
|
|
437
|
+
vec2 bisector = vec2(c * tangent.x - s * tangent.y, s * tangent.x + c * tangent.y);
|
|
438
|
+
float radius = width * 0.5 * s;
|
|
439
|
+
return dot(startToPoint, bisector * direction) - radius;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
float miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
|
|
443
|
+
if (cos(joinAngle) > ${wh}) { // avoid risking a division by zero
|
|
444
|
+
return bevelJoinField(point, start, end, width, joinAngle);
|
|
445
|
+
}
|
|
446
|
+
float miterLength = 1. / sin(joinAngle * 0.5);
|
|
447
|
+
float miterLimit = ${this.strokeMiterLimitExpression_};
|
|
448
|
+
if (miterLength > miterLimit) {
|
|
449
|
+
return bevelJoinField(point, start, end, width, joinAngle);
|
|
450
|
+
}
|
|
451
|
+
return -1000.;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
float capDistanceField(vec2 point, vec2 start, vec2 end, float width, float capType) {
|
|
455
|
+
if (capType == ${He("butt")}) {
|
|
456
|
+
return buttCapDistanceField(point, start, end);
|
|
457
|
+
} else if (capType == ${He("square")}) {
|
|
458
|
+
return squareCapDistanceField(point, start, end, width);
|
|
459
|
+
}
|
|
460
|
+
return roundCapDistanceField(point, start, end, width);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
float joinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float joinType) {
|
|
464
|
+
if (joinType == ${He("bevel")}) {
|
|
465
|
+
return bevelJoinField(point, start, end, width, joinAngle);
|
|
466
|
+
} else if (joinType == ${He("miter")}) {
|
|
467
|
+
return miterJoinDistanceField(point, start, end, width, joinAngle);
|
|
468
|
+
}
|
|
469
|
+
return roundJoinDistanceField(point, start, end, width);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
float computeSegmentPointDistance(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float capType, float joinType) {
|
|
473
|
+
if (isCap(joinAngle)) {
|
|
474
|
+
return capDistanceField(point, start, end, width, capType);
|
|
475
|
+
}
|
|
476
|
+
return joinDistanceField(point, start, end, width, joinAngle, joinType);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
float distanceFromSegment(vec2 point, vec2 start, vec2 end) {
|
|
480
|
+
vec2 tangent = end - start;
|
|
481
|
+
vec2 startToPoint = point - start;
|
|
482
|
+
// inspire by capsule fn in https://iquilezles.org/articles/distfunctions/
|
|
483
|
+
float h = clamp(dot(startToPoint, tangent) / dot(tangent, tangent), 0.0, 1.0);
|
|
484
|
+
return length(startToPoint - tangent * h);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
void main(void) {
|
|
488
|
+
${this.attributes_.map(t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`).join(`
|
|
489
|
+
`)}
|
|
490
|
+
|
|
491
|
+
vec2 currentPointPx = gl_FragCoord.xy / u_pixelRatio;
|
|
492
|
+
vec2 worldPos = pxToWorld(currentPointPx);
|
|
493
|
+
if (
|
|
494
|
+
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
|
495
|
+
worldPos[0] < u_renderExtent[0] ||
|
|
496
|
+
worldPos[1] < u_renderExtent[1] ||
|
|
497
|
+
worldPos[0] > u_renderExtent[2] ||
|
|
498
|
+
worldPos[1] > u_renderExtent[3]
|
|
499
|
+
)
|
|
500
|
+
) {
|
|
501
|
+
discard;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
float segmentLengthPx = length(v_segmentEndPx - v_segmentStartPx);
|
|
505
|
+
segmentLengthPx = max(segmentLengthPx, 1.17549429e-38); // avoid divide by zero
|
|
506
|
+
vec2 segmentTangent = (v_segmentEndPx - v_segmentStartPx) / segmentLengthPx;
|
|
507
|
+
vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);
|
|
508
|
+
vec2 startToPointPx = currentPointPx - v_segmentStartPx;
|
|
509
|
+
float lengthToPointPx = max(0., min(dot(segmentTangent, startToPointPx), segmentLengthPx));
|
|
510
|
+
float currentLengthPx = lengthToPointPx + v_distancePx;
|
|
511
|
+
float currentRadiusPx = distanceFromSegment(currentPointPx, v_segmentStartPx, v_segmentEndPx);
|
|
512
|
+
float currentRadiusRatio = dot(segmentNormal, startToPointPx) * 2. / v_width;
|
|
513
|
+
currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPointPx / segmentLengthPx);
|
|
514
|
+
|
|
515
|
+
${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { discard; }`:""}
|
|
516
|
+
|
|
517
|
+
float capType = ${this.strokeCapExpression_};
|
|
518
|
+
float joinType = ${this.strokeJoinExpression_};
|
|
519
|
+
float segmentStartDistance = computeSegmentPointDistance(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width, v_angleStart, capType, joinType);
|
|
520
|
+
float segmentEndDistance = computeSegmentPointDistance(currentPointPx, v_segmentEndPx, v_segmentStartPx, v_width, v_angleEnd, capType, joinType);
|
|
521
|
+
float distanceField = max(
|
|
522
|
+
segmentDistanceField(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width),
|
|
523
|
+
max(segmentStartDistance, segmentEndDistance)
|
|
524
|
+
);
|
|
525
|
+
distanceField = max(distanceField, ${this.strokeDistanceFieldExpression_});
|
|
526
|
+
|
|
527
|
+
vec4 color = ${this.strokeColorExpression_};
|
|
528
|
+
color.a *= smoothstep(0.5, -0.5, distanceField);
|
|
529
|
+
gl_FragColor = color;
|
|
530
|
+
gl_FragColor.a *= u_globalAlpha;
|
|
531
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
532
|
+
if (u_hitDetection > 0) {
|
|
533
|
+
if (gl_FragColor.a < 0.1) { discard; };
|
|
534
|
+
gl_FragColor = v_hitColor;
|
|
535
|
+
}
|
|
536
|
+
}`:null}getFillVertexShader(){return this.hasFill_?`${ji}
|
|
537
|
+
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
|
|
538
|
+
`)}
|
|
539
|
+
attribute vec2 a_position;
|
|
540
|
+
attribute vec2 a_hitColor;
|
|
541
|
+
|
|
542
|
+
varying vec4 v_hitColor;
|
|
543
|
+
varying vec2 v_patternOriginPx;
|
|
544
|
+
varying vec2 v_patternSizePx;
|
|
545
|
+
|
|
546
|
+
${this.attributes_.map(t=>`attribute ${t.type} ${t.name};
|
|
547
|
+
varying ${t.varyingType} ${t.varyingName};`).join(`
|
|
548
|
+
`)}
|
|
549
|
+
${this.vertexShaderFunctions_.join(`
|
|
550
|
+
`)}
|
|
551
|
+
void main(void) {
|
|
552
|
+
gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);
|
|
553
|
+
v_hitColor = unpackColor(a_hitColor);
|
|
554
|
+
${this.fillPatternSizeExpression_!==null?`
|
|
555
|
+
// this computes the pattern offset in screenspace using double-float arithmetics
|
|
556
|
+
v_patternSizePx = ${this.fillPatternSizeExpression_};
|
|
557
|
+
vec2 patternSizeScaledX = df_mul(df_from(v_patternSizePx.x), u_df_patternScaleRatio);
|
|
558
|
+
vec2 patternSizeScaledY = df_mul(df_from(v_patternSizePx.y), u_df_patternScaleRatio);
|
|
559
|
+
v_patternOriginPx = vec2(
|
|
560
|
+
df_mod(u_df_patternOriginX, patternSizeScaledX),
|
|
561
|
+
df_mod(u_df_patternOriginY, patternSizeScaledY)
|
|
562
|
+
);
|
|
563
|
+
|
|
564
|
+
// reapply rotation to the pattern origin
|
|
565
|
+
v_patternOriginPx -= u_viewportSizePx / 2.; // translate to viewport center
|
|
566
|
+
v_patternOriginPx = vec2(
|
|
567
|
+
cos(-u_rotation) * v_patternOriginPx.x - sin(-u_rotation) * v_patternOriginPx.y,
|
|
568
|
+
sin(-u_rotation) * v_patternOriginPx.x + cos(-u_rotation) * v_patternOriginPx.y
|
|
569
|
+
);
|
|
570
|
+
v_patternOriginPx += u_viewportSizePx / 2.; // translate back
|
|
571
|
+
`:" v_patternOriginPx = vec2(0.);"}
|
|
572
|
+
${this.attributes_.map(t=>` ${t.varyingName} = ${t.varyingExpression};`).join(`
|
|
573
|
+
`)}
|
|
574
|
+
${this.shapeDiscardExpression_?` if (${this.shapeDiscardExpression_}) { gl_Position = vec4(2.0, 2.0, 0.0, 0.0); }`:""}
|
|
575
|
+
}`:null}getFillFragmentShader(){return this.hasFill_?`${ji}
|
|
576
|
+
${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join(`
|
|
577
|
+
`)}
|
|
578
|
+
varying vec4 v_hitColor;
|
|
579
|
+
varying vec2 v_patternOriginPx;
|
|
580
|
+
varying vec2 v_patternSizePx;
|
|
581
|
+
${this.attributes_.map(t=>`varying ${t.varyingType} ${t.varyingName};`).join(`
|
|
582
|
+
`)}
|
|
583
|
+
${this.fragmentShaderFunctions_.join(`
|
|
584
|
+
`)}
|
|
585
|
+
|
|
586
|
+
void main(void) {
|
|
587
|
+
${this.attributes_.map(t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`).join(`
|
|
588
|
+
`)}
|
|
589
|
+
vec2 pxPos = gl_FragCoord.xy / u_pixelRatio;
|
|
590
|
+
vec2 worldPos = pxToWorld(pxPos);
|
|
591
|
+
if (
|
|
592
|
+
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
|
593
|
+
worldPos[0] < u_renderExtent[0] ||
|
|
594
|
+
worldPos[1] < u_renderExtent[1] ||
|
|
595
|
+
worldPos[0] > u_renderExtent[2] ||
|
|
596
|
+
worldPos[1] > u_renderExtent[3]
|
|
597
|
+
)
|
|
598
|
+
) {
|
|
599
|
+
discard;
|
|
600
|
+
}
|
|
601
|
+
${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { discard; }`:""}
|
|
602
|
+
gl_FragColor = ${this.fillColorExpression_};
|
|
603
|
+
gl_FragColor.a *= u_globalAlpha;
|
|
604
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
605
|
+
if (u_hitDetection > 0) {
|
|
606
|
+
if (gl_FragColor.a < 0.1) { discard; };
|
|
607
|
+
gl_FragColor = v_hitColor;
|
|
608
|
+
}
|
|
609
|
+
}`:null}}class pr{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(t,e){for(let i=0;i<t.length;i++)this.addFeature(t[i],e)}addFeature(t,e){let i=t.getGeometry();i&&(e&&(i=i.clone(),i.applyTransform(e)),this.addGeometry_(i,t))}clearFeatureEntryInPointBatch_(t){const e=$(t),i=this.pointBatch.entries[e];if(i)return this.pointBatch.geometriesCount-=i.flatCoordss.length,delete this.pointBatch.entries[e],i}clearFeatureEntryInLineStringBatch_(t){const e=$(t),i=this.lineStringBatch.entries[e];if(i)return this.lineStringBatch.verticesCount-=i.verticesCount,this.lineStringBatch.geometriesCount-=i.flatCoordss.length,delete this.lineStringBatch.entries[e],i}clearFeatureEntryInPolygonBatch_(t){const e=$(t),i=this.polygonBatch.entries[e];if(i)return this.polygonBatch.verticesCount-=i.verticesCount,this.polygonBatch.ringsCount-=i.ringsCount,this.polygonBatch.geometriesCount-=i.flatCoordss.length,delete this.polygonBatch.entries[e],i}addGeometry_(t,e){const i=t.getType();switch(i){case"GeometryCollection":{const n=t.getGeometriesArray();for(const r of n)this.addGeometry_(r,e);break}case"MultiPolygon":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEndss(),e,$(e),n.getStride());break}case"MultiLineString":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),e,$(e),n.getStride());break}case"MultiPoint":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),null,e,$(e),n.getStride());break}case"Polygon":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),n.getEnds(),e,$(e),n.getStride());break}case"Point":{const n=t;this.addCoordinates_(i,n.getFlatCoordinates(),null,e,$(e),n.getStride());break}case"LineString":case"LinearRing":{const n=t,r=n.getStride();this.addCoordinates_(i,n.getFlatCoordinates(),null,e,$(e),r,n.getLayout?.());break}}}addCoordinates_(t,e,i,n,r,o,a){let l;switch(t){case"MultiPolygon":{const h=i;for(let c=0,u=h.length;c<u;c++){let d=h[c];const f=c>0?h[c-1]:null,g=f?f[f.length-1]:0,_=d[d.length-1];d=g>0?d.map(p=>p-g):d,this.addCoordinates_("Polygon",e.slice(g,_),d,n,r,o,a)}break}case"MultiLineString":{const h=i;for(let c=0,u=h.length;c<u;c++){const d=c>0?h[c-1]:0;this.addCoordinates_("LineString",e.slice(d,h[c]),null,n,r,o,a)}break}case"MultiPoint":for(let h=0,c=e.length;h<c;h+=o)this.addCoordinates_("Point",e.slice(h,h+2),null,n,r,null,null);break;case"Polygon":{const h=i;if(n instanceof Jt){const d=Bc(e,h);if(d.length>1){this.addCoordinates_("MultiPolygon",e,d,n,r,o,a);return}}this.polygonBatch.entries[r]||(this.polygonBatch.entries[r]=this.addRefToEntry_(r,{feature:n,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]})),l=e.length/o;const c=i.length,u=i.map((d,f,g)=>f>0?(d-g[f-1])/o:d/o);this.polygonBatch.verticesCount+=l,this.polygonBatch.ringsCount+=c,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[r].flatCoordss.push(Vp(e,o)),this.polygonBatch.entries[r].ringsVerticesCounts.push(u),this.polygonBatch.entries[r].verticesCount+=l,this.polygonBatch.entries[r].ringsCount+=c;for(let d=0,f=h.length;d<f;d++){const g=d>0?h[d-1]:0;this.addCoordinates_("LinearRing",e.slice(g,h[d]),null,n,r,o,a)}break}case"Point":this.pointBatch.entries[r]||(this.pointBatch.entries[r]=this.addRefToEntry_(r,{feature:n,flatCoordss:[]})),this.pointBatch.geometriesCount++,this.pointBatch.entries[r].flatCoordss.push(e);break;case"LineString":case"LinearRing":this.lineStringBatch.entries[r]||(this.lineStringBatch.entries[r]=this.addRefToEntry_(r,{feature:n,flatCoordss:[],verticesCount:0})),l=e.length/o,this.lineStringBatch.verticesCount+=l,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[r].flatCoordss.push(Yp(e,o,a)),this.lineStringBatch.entries[r].verticesCount+=l;break}}addRefToEntry_(t,e){const i=this.uidToRef_.get(t),n=i||this.freeGlobalRef_.pop()||++this.globalCounter_;return e.ref=n,i||(this.refToFeature_.set(n,e.feature),this.uidToRef_.set(t,n)),e}removeRef_(t,e){if(!t)throw new Error("This feature has no ref: "+e);this.refToFeature_.delete(t),this.uidToRef_.delete(e),this.freeGlobalRef_.push(t)}changeFeature(t,e){if(!this.uidToRef_.get($(t)))return;this.removeFeature(t);let i=t.getGeometry();i&&(e&&(i=i.clone(),i.applyTransform(e)),this.addGeometry_(i,t))}removeFeature(t){let e=this.clearFeatureEntryInPointBatch_(t);e=this.clearFeatureEntryInPolygonBatch_(t)||e,e=this.clearFeatureEntryInLineStringBatch_(t)||e,e&&this.removeRef_(e.ref,$(e.feature))}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(t){return this.refToFeature_.get(t)}isEmpty(){return this.globalCounter_===0}filter(t){const e=new pr;e.globalCounter_=this.globalCounter_,e.uidToRef_=this.uidToRef_,e.refToFeature_=this.refToFeature_;let i=!0;for(const n of this.refToFeature_.values())t(n)&&(e.addFeature(n),i=!1);return i?new pr:e}}function Vp(s,t){return t===2?s:s.filter((e,i)=>i%t<2)}function Yp(s,t,e){return t===3&&e==="XYM"?s:t===4?s.filter((i,n)=>n%t!==2):t===3?s.map((i,n)=>n%t!==2?i:0):new Array(s.length*1.5).fill(0).map((i,n)=>n%3===2?0:s[Math.round(n/1.5)])}function Zp(){const s='function t(t,n,x=2){const o=n&&n.length,i=o?n[0]*x:t.length;let f=e(t,0,i,x,!0);const l=[];if(!f||f.next===f.prev)return l;let c,y,h;if(o&&(f=function(t,n,r,x){const o=[];for(let r=0,i=n.length;r<i;r++){const f=e(t,n[r]*x,r<i-1?n[r+1]*x:t.length,x,!1);f===f.next&&(f.steiner=!0),o.push(a(f))}o.sort(u);for(let t=0;t<o.length;t++)r=s(o[t],r);return r}(t,n,f,x)),t.length>80*x){c=t[0],y=t[1];let e=c,n=y;for(let r=x;r<i;r+=x){const x=t[r],o=t[r+1];x<c&&(c=x),o<y&&(y=o),x>e&&(e=x),o>n&&(n=o)}h=Math.max(e-c,n-y),h=0!==h?32767/h:0}return r(f,l,x,c,y,h,0),l}function e(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,i=n-r;o<n;o+=r)x+=(t[i]-t[o])*(t[o+1]+t[i+1]),i=o;return x}(t,e,n,r)>0)for(let x=e;x<n;x+=r)o=d(x/r|0,t[x],t[x+1],o);else for(let x=n-r;x>=e;x-=r)o=d(x/r|0,t[x],t[x+1],o);return o&&b(o,o.next)&&(w(o),o=o.next),o}function n(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!b(r,r.next)&&0!==v(r.prev,r,r.next))r=r.next;else{if(w(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function r(t,e,u,s,l,a,y){if(!t)return;!y&&a&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=c(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let i=x,f=0;for(let t=0;t<n&&(f++,i=i.nextZ,i);t++);let u=n;for(;f>0||u>0&&i;)0!==f&&(0===u||!i||x.z<=i.z)?(r=x,x=x.nextZ,f--):(r=i,i=i.nextZ,u--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=i}o.nextZ=null,n*=2}while(e>1)}(x)}(t,s,l,a);let h=t;for(;t.prev!==t.next;){const c=t.prev,p=t.next;if(a?o(t,s,l,a):x(t))e.push(c.i,t.i,p.i),w(t),t=p.next,h=p.next;else if((t=p)===h){y?1===y?r(t=i(n(t),e),e,u,s,l,a,2):2===y&&f(t,e,u,s,l,a):r(n(t),e,u,s,l,a,1);break}}}function x(t){const e=t.prev,n=t,r=t.next;if(v(e,n,r)>=0)return!1;const x=e.x,o=n.x,i=r.x,f=e.y,u=n.y,s=r.y,l=Math.min(x,o,i),c=Math.min(f,u,s),a=Math.max(x,o,i),y=Math.max(f,u,s);let p=r.next;for(;p!==e;){if(p.x>=l&&p.x<=a&&p.y>=c&&p.y<=y&&h(x,f,o,u,i,s,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function o(t,e,n,r){const x=t.prev,o=t,i=t.next;if(v(x,o,i)>=0)return!1;const f=x.x,u=o.x,s=i.x,l=x.y,a=o.y,y=i.y,p=Math.min(f,u,s),b=Math.min(l,a,y),M=Math.max(f,u,s),m=Math.max(l,a,y),A=c(p,b,e,n,r),g=c(M,m,e,n,r);let Z=t.prevZ,d=t.nextZ;for(;Z&&Z.z>=A&&d&&d.z<=g;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;if(Z=Z.prevZ,d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;Z&&Z.z>=A;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;Z=Z.prevZ}for(;d&&d.z<=g;){if(d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function i(t,e){let r=t;do{const n=r.prev,x=r.next.next;!b(n,x)&&M(n,r,r.next,x)&&g(n,x)&&g(x,n)&&(e.push(n.i,r.i,x.i),w(r),w(r.next),r=t=x),r=r.next}while(r!==t);return n(r)}function f(t,e,x,o,i,f){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&p(u,t)){let s=Z(u,t);return u=n(u,u.next),s=n(s,s.next),r(u,e,x,o,i,f,0),void r(s,e,x,o,i,f,0)}t=t.next}u=u.next}while(u!==t)}function u(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function s(t,e){const r=function(t,e){let n=e;const r=t.x,x=t.y;let o,i=-1/0;if(b(t,n))return n;do{if(b(t,n.next))return n.next;if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>i&&(i=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const f=o,u=o.x,s=o.y;let c=1/0;n=o;do{if(r>=n.x&&n.x>=u&&r!==n.x&&y(x<s?r:i,x,u,s,x<s?i:r,x,n.x,n.y)){const e=Math.abs(x-n.y)/(r-n.x);g(n,t)&&(e<c||e===c&&(n.x>o.x||n.x===o.x&&l(o,n)))&&(o=n,c=e)}n=n.next}while(n!==f);return o}(t,e);if(!r)return e;const x=Z(r,t);return n(x,x.next),n(r,r.next)}function l(t,e){return v(t.prev,t,e.prev)<0&&v(e.next,t,t.next)<0}function c(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function a(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function y(t,e,n,r,x,o,i,f){return(x-i)*(e-f)>=(t-i)*(o-f)&&(t-i)*(r-f)>=(n-i)*(e-f)&&(n-i)*(o-f)>=(x-i)*(r-f)}function h(t,e,n,r,x,o,i,f){return!(t===i&&e===f)&&y(t,e,n,r,x,o,i,f)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&M(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(g(t,e)&&g(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(v(t.prev,t,e.prev)||v(t,e.prev,e))||b(t,e)&&v(t.prev,t,t.next)>0&&v(e.prev,e,e.next)>0)}function v(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function b(t,e){return t.x===e.x&&t.y===e.y}function M(t,e,n,r){const x=A(v(t,e,n)),o=A(v(t,e,r)),i=A(v(n,r,t)),f=A(v(n,r,e));return x!==o&&i!==f||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==i||!m(n,t,r))||!(0!==f||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function g(t,e){return v(t.prev,t,t.next)<0?v(t,e,t.next)>=0&&v(t,t.prev,e)>=0:v(t,e,t.prev)<0||v(t,t.next,e)<0}function Z(t,e){const n=F(t.i,t.x,t.y),r=F(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function d(t,e,n,r){const x=F(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function w(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function F(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function E(t,e,n){const r=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),x=[(e[0]-t[0])/r,(e[1]-t[1])/r],o=[-x[1],x[0]],i=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),f=[(n[0]-t[0])/i,(n[1]-t[1])/i];let u=0===r||0===i?0:Math.acos((s=f[0]*x[0]+f[1]*x[1],l=-1,c=1,Math.min(Math.max(s,l),c)));var s,l,c;u=Math.max(u,1e-5);return f[0]*o[0]+f[1]*o[1]>0?u:2*Math.PI-u}function I(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function z(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,"Transformation matrix cannot be inverted");const x=e[0],o=e[1],i=e[2],f=e[3],u=e[4],s=e[5];return t[0]=f/n,t[1]=-o/n,t[2]=-i/n,t[3]=x/n,t[4]=(i*s-f*u)/n,t[5]=-(x*s-o*u)/n,t}new Array(6);const B=[],P={vertexAttributesPosition:0,instanceAttributesPosition:0,indicesPosition:0};function N(t,e,n,r,x){const o=t[e++],i=t[e++],f=B;f.length=r;for(let n=0;n<f.length;n++)f[n]=t[e+n];let u=x?x.instanceAttributesPosition:0;return n[u++]=o,n[u++]=i,f.length&&(n.set(f,u),u+=f.length),P.instanceAttributesPosition=u,P}function R(t,e,n,r,x,o,i,f,u,s){const l=[t[e],t[e+1]],c=[t[n],t[n+1]],a=t[e+2],y=t[n+2],h=I(f,[...l]),p=I(f,[...c]);let v=-1,b=-1,M=s;const m=null!==x;if(null!==r){v=E(h,p,I(f,[...[t[r],t[r+1]]])),Math.cos(v)<=.985&&(M+=Math.tan((v-Math.PI)/2))}if(m){b=E(p,h,I(f,[...[t[x],t[x+1]]])),Math.cos(b)<=.985&&(M+=Math.tan((Math.PI-b)/2))}const A=Math.pow(2,24),g=u%A,Z=Math.floor(u/A)*A;return o.push(l[0],l[1],a,c[0],c[1],y,v,b,g,Z,s),o.push(...i),{length:u+Math.sqrt((p[0]-h[0])*(p[0]-h[0])+(p[1]-h[1])*(p[1]-h[1])),angle:M}}function S(e,n,r,x,o){const i=2+o;let f=n;const u=e.slice(f,f+o);f+=o;const s=e[f++];let l=0;const c=new Array(s-1);for(let t=0;t<s;t++)l+=e[f++],t<s-1&&(c[t]=l);const a=e.slice(f,f+2*l),y=t(a,c,2);for(let t=0;t<y.length;t++)x.push(y[t]+r.length/i);for(let t=0;t<a.length;t+=2)r.push(a[t],a[t+1],...u);return f+2*l}const T="GENERATE_POLYGON_BUFFERS",_="GENERATE_POINT_BUFFERS",O="GENERATE_LINE_STRING_BUFFERS",U=self;U.onmessage=t=>{const e=t.data;switch(e.type){case _:{const t=2,n=2,r=e.customAttributesSize,x=n+r,o=new Float32Array(e.renderInstructions),i=o.length/x*(t+r),f=Uint32Array.from([0,1,3,1,2,3]),u=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),s=new Float32Array(i);let l;for(let t=0;t<o.length;t+=x)l=N(o,t,s,r,l);const c=Object.assign({indicesBuffer:f.buffer,vertexAttributesBuffer:u.buffer,instanceAttributesBuffer:s.buffer,renderInstructions:o.buffer},e);U.postMessage(c,[u.buffer,s.buffer,f.buffer,o.buffer]);break}case O:{const t=[],n=e.customAttributesSize,r=3,x=new Float32Array(e.renderInstructions);let o=0;const i=[1,0,0,1,0,0];let f,u;for(z(i,e.renderInstructionsTransform);o<x.length;){u=Array.from(x.slice(o,o+n)),o+=n,f=x[o++];const e=o,s=o+(f-1)*r,l=x[e]===x[s]&&x[e+1]===x[s+1];let c=0,a=0;for(let n=0;n<f-1;n++){let y=null;n>0?y=o+(n-1)*r:l&&(y=s-r);let h=null;n<f-2?h=o+(n+2)*r:l&&(h=e+r);const p=R(x,o+n*r,o+(n+1)*r,y,h,t,u,i,c,a);c=p.length,a=p.angle}o+=f*r}const s=Uint32Array.from([0,1,3,1,2,3]),l=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),c=Float32Array.from(t),a=Object.assign({indicesBuffer:s.buffer,vertexAttributesBuffer:l.buffer,instanceAttributesBuffer:c.buffer,renderInstructions:x.buffer},e);U.postMessage(a,[l.buffer,c.buffer,s.buffer,x.buffer]);break}case T:{const t=[],n=[],r=e.customAttributesSize,x=new Float32Array(e.renderInstructions);let o=0;for(;o<x.length;)o=S(x,o,t,n,r);const i=Uint32Array.from(n),f=Float32Array.from(t),u=Float32Array.from([]),s=Object.assign({indicesBuffer:i.buffer,vertexAttributesBuffer:f.buffer,instanceAttributesBuffer:u.buffer,renderInstructions:x.buffer},e);U.postMessage(s,[f.buffer,u.buffer,i.buffer,x.buffer]);break}}};';return new Worker(typeof Blob>"u"?"data:application/javascript;base64,"+Buffer.from(s,"binary").toString("base64"):URL.createObjectURL(new Blob([s],{type:"application/javascript"})))}const Co={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function Hp(s,t){t=t||[];const e=256,i=e-1,n=Math.floor(s/e/e/e)/i,r=Math.floor(s/e/e)%e/i,o=Math.floor(s/e)%e/i,a=s%e/i;return t[0]=n*256*255+r*255,t[1]=o*256*255+a*255,t}function Kp(s){let t=0;const e=256,i=e-1;return t+=Math.round(s[0]*e*e*e*i),t+=Math.round(s[1]*e*e*i),t+=Math.round(s[2]*e*i),t+=Math.round(s[3]*i),t}function Ja(s,t,e,i){let n=0;for(const r in t){const o=t[r],a=o.callback.call(e,e.feature);let l=a?.[0]??a;l===Jo&&console.warn('The "has" operator might return false positives.'),l===void 0?l=Jo:l===null&&(l=0),s[i+n++]=l,!(!o.size||o.size===1)&&(s[i+n++]=a[1],!(o.size<3)&&(s[i+n++]=a[2],!(o.size<4)&&(s[i+n++]=a[3])))}return n}function $r(s){return Object.keys(s).reduce((t,e)=>t+(s[e].size||1),0)}function qp(s,t,e,i){const n=(2+$r(e))*s.geometriesCount;(!t||t.length!==n)&&(t=new Float32Array(n));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++)r[0]=l.flatCoordss[h][0],r[1]=l.flatCoordss[h][1],wt(i,r),t[o++]=r[0],t[o++]=r[1],o+=Ja(t,e,l,o)}return t}function Jp(s,t,e,i){const n=3*s.verticesCount+(1+$r(e))*s.geometriesCount;(!t||t.length!==n)&&(t=new Float32Array(n));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Oe(l.flatCoordss[h],0,r.length,3,i,r,3),o+=Ja(t,e,l,o),t[o++]=r.length/3;for(let u=0,d=r.length;u<d;u+=3)t[o++]=r[u],t[o++]=r[u+1],t[o++]=r[u+2]}}return t}function Qp(s,t,e,i){const n=2*s.verticesCount+(1+$r(e))*s.geometriesCount+s.ringsCount;(!t||t.length!==n)&&(t=new Float32Array(n));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Oe(l.flatCoordss[h],0,r.length,2,i,r),o+=Ja(t,e,l,o),t[o++]=l.ringsVerticesCounts[h].length;for(let u=0,d=l.ringsVerticesCounts[h].length;u<d;u++)t[o++]=l.ringsVerticesCounts[h][u];for(let u=0,d=r.length;u<d;u+=2)t[o++]=r[u],t[o++]=r[u+1]}}return t}function _r(s){return(JSON.stringify(s).split("").reduce((e,i)=>(e<<5)-e+i.charCodeAt(0),0)>>>0).toString()}function Qa(s,t,e,i){if(`${i}radius`in s&&i!=="icon-"){let n=U(e,s[`${i}radius`],A);if(`${i}radius2`in s){const r=U(e,s[`${i}radius2`],A);n=`max(${n}, ${r})`}`${i}stroke-width`in s&&(n=`(${n} + ${U(e,s[`${i}stroke-width`],A)} * 0.5)`),t.setSymbolSizeExpression(`vec2(${n} * 2. + 0.5)`)}if(`${i}scale`in s){const n=U(e,s[`${i}scale`],ce);t.setSymbolSizeExpression(`${t.getSymbolSizeExpression()} * ${n}`)}`${i}displacement`in s&&t.setSymbolOffsetExpression(U(e,s[`${i}displacement`],ee)),`${i}rotation`in s&&t.setSymbolRotationExpression(U(e,s[`${i}rotation`],A)),`${i}rotate-with-view`in s&&t.setSymbolRotateWithView(!!s[`${i}rotate-with-view`])}function su(s,t,e,i,n){let r="vec4(0.)";if(t!==null&&(r=t),e!==null&&i!==null){const l=`smoothstep(-${i} + 0.63, -${i} - 0.58, ${s})`;r=`mix(${e}, ${r}, ${l})`}const o=`(1.0 - smoothstep(-0.63, 0.58, ${s}))`;let a=`${r} * vec4(1.0, 1.0, 1.0, ${o})`;return n!==null&&(a=`${a} * vec4(1.0, 1.0, 1.0, ${n})`),a}function tl(s,t,e,i,n){const r=new Image;r.crossOrigin=s[`${i}cross-origin`]===void 0?"anonymous":s[`${i}cross-origin`],Q(typeof s[`${i}src`]=="string",`WebGL layers do not support expressions for the ${i}src style property`),r.src=s[`${i}src`],e[`u_texture${n}_size`]=()=>r.complete?[r.width,r.height]:[0,0],t.addUniform(`u_texture${n}_size`,"vec2");const o=`u_texture${n}_size`;return e[`u_texture${n}`]=r,t.addUniform(`u_texture${n}`,"sampler2D"),o}function el(s,t,e,i,n){let r=U(e,s[`${t}offset`],ce);if(`${t}offset-origin`in s)switch(s[`${t}offset-origin`]){case"top-right":r=`vec2(${i}.x, 0.) + ${n} * vec2(-1., 0.) + ${r} * vec2(-1., 1.)`;break;case"bottom-left":r=`vec2(0., ${i}.y) + ${n} * vec2(0., -1.) + ${r} * vec2(1., -1.)`;break;case"bottom-right":r=`${i} - ${n} - ${r}`;break}return r}function t_(s,t,e,i){i.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) {
|
|
610
|
+
return length(point) - radius;
|
|
611
|
+
}`,Qa(s,t,i,"circle-");let n=null;"circle-opacity"in s&&(n=U(i,s["circle-opacity"],A));let r="coordsPx";"circle-scale"in s&&(r=`coordsPx / ${U(i,s["circle-scale"],ce)}`);let o=null;"circle-fill-color"in s&&(o=U(i,s["circle-fill-color"],yt));let a=null;"circle-stroke-color"in s&&(a=U(i,s["circle-stroke-color"],yt));let l=U(i,s["circle-radius"],A),h=null;"circle-stroke-width"in s&&(h=U(i,s["circle-stroke-width"],A),l=`(${l} + ${h} * 0.5)`);const c=`circleDistanceField(${r}, ${l})`,u=su(c,o,a,h,n);t.setSymbolColorExpression(u)}function e_(s,t,e,i){i.functions.round=`float round(float v) {
|
|
612
|
+
return sign(v) * floor(abs(v) + 0.5);
|
|
613
|
+
}`,i.functions.starDistanceField=`float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {
|
|
614
|
+
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
|
|
615
|
+
float c = cos(startAngle);
|
|
616
|
+
float s = sin(startAngle);
|
|
617
|
+
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
|
|
618
|
+
float alpha = TWO_PI / numPoints; // the angle of one sector
|
|
619
|
+
float beta = atan(pointRotated.y, pointRotated.x);
|
|
620
|
+
float gamma = round(beta / alpha) * alpha; // angle in sector
|
|
621
|
+
c = cos(-gamma);
|
|
622
|
+
s = sin(-gamma);
|
|
623
|
+
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
|
|
624
|
+
vec2 tipToPoint = inSector + vec2(-radius, 0.);
|
|
625
|
+
vec2 edgeNormal = vec2(radius2 * sin(alpha * 0.5), -radius2 * cos(alpha * 0.5) + radius);
|
|
626
|
+
return dot(normalize(edgeNormal), tipToPoint);
|
|
627
|
+
}`,i.functions.regularDistanceField=`float regularDistanceField(vec2 point, float numPoints, float radius, float angle) {
|
|
628
|
+
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
|
|
629
|
+
float c = cos(startAngle);
|
|
630
|
+
float s = sin(startAngle);
|
|
631
|
+
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
|
|
632
|
+
float alpha = TWO_PI / numPoints; // the angle of one sector
|
|
633
|
+
float radiusIn = radius * cos(PI / numPoints);
|
|
634
|
+
float beta = atan(pointRotated.y, pointRotated.x);
|
|
635
|
+
float gamma = round((beta - alpha * 0.5) / alpha) * alpha + alpha * 0.5; // angle in sector from mid
|
|
636
|
+
c = cos(-gamma);
|
|
637
|
+
s = sin(-gamma);
|
|
638
|
+
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
|
|
639
|
+
return inSector.x - radiusIn;
|
|
640
|
+
}`,Qa(s,t,i,"shape-");let n=null;"shape-opacity"in s&&(n=U(i,s["shape-opacity"],A));let r="coordsPx";"shape-scale"in s&&(r=`coordsPx / ${U(i,s["shape-scale"],ce)}`);let o=null;"shape-fill-color"in s&&(o=U(i,s["shape-fill-color"],yt));let a=null;"shape-stroke-color"in s&&(a=U(i,s["shape-stroke-color"],yt));let l=null;"shape-stroke-width"in s&&(l=U(i,s["shape-stroke-width"],A));const h=U(i,s["shape-points"],A);let c="0.";"shape-angle"in s&&(c=U(i,s["shape-angle"],A));let u,d=U(i,s["shape-radius"],A);if(l!==null&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in s){let g=U(i,s["shape-radius2"],A);l!==null&&(g=`${g} + ${l} * 0.5`),u=`starDistanceField(${r}, ${h}, ${d}, ${g}, ${c})`}else u=`regularDistanceField(${r}, ${h}, ${d}, ${c})`;const f=su(u,o,a,l,n);t.setSymbolColorExpression(f)}function i_(s,t,e,i){let n="vec4(1.0)";"icon-color"in s&&(n=U(i,s["icon-color"],yt)),"icon-opacity"in s&&(n=`${n} * vec4(1.0, 1.0, 1.0, ${U(i,s["icon-opacity"],A)})`);const r=_r(s["icon-src"]),o=tl(s,t,e,"icon-",r);if(t.setSymbolColorExpression(`${n} * texture2D(u_texture${r}, v_texCoord)`).setSymbolSizeExpression(o),"icon-width"in s&&"icon-height"in s&&t.setSymbolSizeExpression(`vec2(${U(i,s["icon-width"],A)}, ${U(i,s["icon-height"],A)})`),"icon-offset"in s&&"icon-size"in s){const a=U(i,s["icon-size"],ee),l=t.getSymbolSizeExpression();t.setSymbolSizeExpression(a);const h=el(s,"icon-",i,"v_quadSizePx",a);t.setTextureCoordinateExpression(`(vec4((${h}).xyxy) + vec4(0., 0., ${a})) / (${l}).xyxy`)}if(Qa(s,t,i,"icon-"),"icon-anchor"in s){const a=U(i,s["icon-anchor"],ee);let l="1.0";"icon-scale"in s&&(l=U(i,s["icon-scale"],ce));let h;s["icon-anchor-x-units"]==="pixels"&&s["icon-anchor-y-units"]==="pixels"?h=`${a} * ${l}`:s["icon-anchor-x-units"]==="pixels"?h=`${a} * vec2(vec2(${l}).x, v_quadSizePx.y)`:s["icon-anchor-y-units"]==="pixels"?h=`${a} * vec2(v_quadSizePx.x, vec2(${l}).x)`:h=`${a} * v_quadSizePx`;let c=`v_quadSizePx * vec2(0.5, -0.5) + ${h} * vec2(-1., 1.)`;if("icon-anchor-origin"in s)switch(s["icon-anchor-origin"]){case"top-right":c=`v_quadSizePx * -0.5 + ${h}`;break;case"bottom-left":c=`v_quadSizePx * 0.5 - ${h}`;break;case"bottom-right":c=`v_quadSizePx * vec2(-0.5, 0.5) + ${h} * vec2(1., -1.)`;break}t.setSymbolOffsetExpression(`${t.getSymbolOffsetExpression()} + ${c}`)}}function n_(s,t,e,i){if("stroke-color"in s&&t.setStrokeColorExpression(U(i,s["stroke-color"],yt)),"stroke-pattern-src"in s){const n=_r(s["stroke-pattern-src"]),r=tl(s,t,e,"stroke-pattern-",n);let o=r,a="vec2(0.)";"stroke-pattern-offset"in s&&"stroke-pattern-size"in s&&(o=U(i,s["stroke-pattern-size"],ee),a=el(s,"stroke-pattern-",i,r,o));let l="0.";"stroke-pattern-spacing"in s&&(l=U(i,s["stroke-pattern-spacing"],A));let h="0.";"stroke-pattern-start-offset"in s&&(h=U(i,s["stroke-pattern-start-offset"],A)),i.functions.sampleStrokePattern=`vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float startOffsetPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {
|
|
641
|
+
float currentLengthScaled = (currentLengthPx - startOffsetPx) * sampleSize.y / lineWidth;
|
|
642
|
+
float spacingScaled = spacingPx * sampleSize.y / lineWidth;
|
|
643
|
+
float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));
|
|
644
|
+
float isInsideOfPattern = step(uCoordPx, sampleSize.x);
|
|
645
|
+
float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;
|
|
646
|
+
// make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
|
|
647
|
+
uCoordPx = clamp(uCoordPx, 0.5, sampleSize.x - 0.5);
|
|
648
|
+
vCoordPx = clamp(vCoordPx, 0.5, sampleSize.y - 0.5);
|
|
649
|
+
vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;
|
|
650
|
+
return texture2D(texture, texCoord) * vec4(1.0, 1.0, 1.0, isInsideOfPattern);
|
|
651
|
+
}`;const c=`u_texture${n}`;let u="1.";"stroke-color"in s&&(u=t.getStrokeColorExpression()),t.setStrokeColorExpression(`${u} * sampleStrokePattern(${c}, ${r}, ${a}, ${o}, ${l}, ${h}, currentLengthPx, currentRadiusRatio, v_width)`),i.functions.computeStrokePatternLength=`float computeStrokePatternLength(vec2 sampleSize, float spacingPx, float lineWidth) {
|
|
652
|
+
float patternLengthPx = sampleSize.x / sampleSize.y * lineWidth;
|
|
653
|
+
return patternLengthPx + spacingPx;
|
|
654
|
+
}`,t.setStrokePatternLengthExpression(`computeStrokePatternLength(${o}, ${l}, v_width)`)}if("stroke-width"in s&&t.setStrokeWidthExpression(U(i,s["stroke-width"],A)),"stroke-offset"in s&&t.setStrokeOffsetExpression(U(i,s["stroke-offset"],A)),"stroke-line-cap"in s&&t.setStrokeCapExpression(U(i,s["stroke-line-cap"],It)),"stroke-line-join"in s&&t.setStrokeJoinExpression(U(i,s["stroke-line-join"],It)),"stroke-miter-limit"in s&&t.setStrokeMiterLimitExpression(U(i,s["stroke-miter-limit"],A)),"stroke-line-dash"in s){i.functions.getSingleDashDistance=`float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType, float lineWidth) {
|
|
655
|
+
float localDistance = mod(distance, dashLengthTotal);
|
|
656
|
+
float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;
|
|
657
|
+
distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);
|
|
658
|
+
if (capType == ${He("square")}) {
|
|
659
|
+
distanceSegment -= lineWidth * 0.5;
|
|
660
|
+
} else if (capType == ${He("round")}) {
|
|
661
|
+
distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);
|
|
662
|
+
}
|
|
663
|
+
return distanceSegment;
|
|
664
|
+
}`;let n=s["stroke-line-dash"].map(g=>U(i,g,A));n.length%2===1&&(n=[...n,...n]);let r="0.";"stroke-line-dash-offset"in s&&(r=U(i,s["stroke-line-dash-offset"],A));const a=`dashDistanceField_${_r(s["stroke-line-dash"])}`,l=n.map((g,_)=>`float dashLength${_}`).join(", "),h=n.map((g,_)=>`dashLength${_}`).join(" + ");let c="0.",u=`getSingleDashDistance(distance, radius, ${c}, dashLength0, totalDashLength, capType, lineWidth)`;for(let g=2;g<n.length;g+=2)c=`${c} + dashLength${g-2} + dashLength${g-1}`,u=`min(${u}, getSingleDashDistance(distance, radius, ${c}, dashLength${g}, totalDashLength, capType, lineWidth))`;i.functions[a]=`float ${a}(float distance, float radius, float capType, float lineWidth, ${l}) {
|
|
665
|
+
float totalDashLength = ${h};
|
|
666
|
+
return ${u};
|
|
667
|
+
}`;const d=n.map((g,_)=>`${g}`).join(", ");t.setStrokeDistanceFieldExpression(`${a}(currentLengthPx + ${r}, currentRadiusPx, capType, v_width, ${d})`);let f=n.join(" + ");t.getStrokePatternLengthExpression()&&(i.functions.combinePatternLengths=`float combinePatternLengths(float patternLength1, float patternLength2) {
|
|
668
|
+
return patternLength1 * patternLength2;
|
|
669
|
+
}`,f=`combinePatternLengths(${t.getStrokePatternLengthExpression()}, ${f})`),t.setStrokePatternLengthExpression(f)}}function s_(s,t,e,i){if("fill-color"in s&&t.setFillColorExpression(U(i,s["fill-color"],yt)),"fill-pattern-src"in s){const n=_r(s["fill-pattern-src"]),r=tl(s,t,e,"fill-pattern-",n);t.setFillPatternSizeExpression(r);let o="vec2(0.)";if("fill-pattern-offset"in s&&"fill-pattern-size"in s){const h=U(i,s["fill-pattern-size"],ee);t.setFillPatternSizeExpression(h),o=el(s,"fill-pattern-",i,r,"v_patternSizePx")}i.functions.sampleFillPattern=`vec4 sampleFillPattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, vec2 patternOriginPx, vec2 pxPosition, float sampleScaleRatio) {
|
|
670
|
+
vec2 pxRelativePos = pxPosition - patternOriginPx;
|
|
671
|
+
|
|
672
|
+
// rotate the relative position from origin by the current view rotation
|
|
673
|
+
pxRelativePos = vec2(pxRelativePos.x * cos(u_rotation) - pxRelativePos.y * sin(u_rotation), pxRelativePos.x * sin(u_rotation) + pxRelativePos.y * cos(u_rotation));
|
|
674
|
+
// sample position is computed according to the sample offset & size
|
|
675
|
+
vec2 samplePos = mod(pxRelativePos / sampleScaleRatio, sampleSize);
|
|
676
|
+
// also make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
|
|
677
|
+
samplePos = clamp(samplePos, vec2(0.5), sampleSize - vec2(0.5));
|
|
678
|
+
samplePos.y = sampleSize.y - samplePos.y; // invert y axis so that images appear upright
|
|
679
|
+
return texture2D(texture, (samplePos + textureOffset) / textureSize);
|
|
680
|
+
}`;const a=`u_texture${n}`;let l="1.";"fill-color"in s&&(l=t.getFillColorExpression()),t.setFillColorExpression(`${l} * sampleFillPattern(${a}, ${r}, ${o}, v_patternSizePx, v_patternOriginPx, pxPos, df_float(u_df_patternScaleRatio))`)}}function Th(s,t,e){const i=qc(),n=new nu,r={};if("icon-src"in s?i_(s,n,r,i):"shape-points"in s?e_(s,n,r,i):"circle-radius"in s&&t_(s,n,r,i),n_(s,n,r,i),s_(s,n,r,i),e){const l=fs(),h=U(i,e,bt,l);l.mCoordinate?n.setFragmentDiscardExpression(`!${h}`):n.setShapeDiscardExpression(`!${h}`)}const o={};function a(l,h,c,u){if(!i[l])return;const d=Qo(c),f=qa(c);n.addAttribute(`a_${h}`,d),o[h]={size:f,callback:u}}return a("geometryType",Qc,It,l=>ns(La(l.getGeometry()))),a("featureId",Jc,It|A,l=>{const h=l.getId()??null;return typeof h=="string"?ns(h):h}),tu(n,i),{builder:n,attributes:{...o,...iu(i)},uniforms:{...r,...eu(i,t)}}}const r_=[];let wo;function o_(){return wo||(wo=Zp()),wo}let a_=0;const ae={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 l_{constructor(t,e,i,n){this.helper_,this.hitDetectionEnabled_=!!n,this.styleShaders=h_(t,e),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return Hp(this.ref,r_)},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:Nt.FLOAT}));return r.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:r.builder.getFillVertexShader(),fragmentShader:r.builder.getFillFragmentShader(),attributesDesc:[{name:ae.POSITION,size:2,type:Nt.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),r.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:r.builder.getStrokeVertexShader(),fragmentShader:r.builder.getStrokeFragmentShader(),attributesDesc:[{name:ae.LOCAL_POSITION,size:2,type:Nt.FLOAT}],instancedAttributesDesc:[{name:ae.SEGMENT_START,size:2,type:Nt.FLOAT},{name:ae.MEASURE_START,size:1,type:Nt.FLOAT},{name:ae.SEGMENT_END,size:2,type:Nt.FLOAT},{name:ae.MEASURE_END,size:1,type:Nt.FLOAT},{name:ae.JOIN_ANGLES,size:2,type:Nt.FLOAT},{name:ae.DISTANCE_LOW,size:1,type:Nt.FLOAT},{name:ae.DISTANCE_HIGH,size:1,type:Nt.FLOAT},{name:ae.ANGLE_TANGENT_SUM,size:1,type:Nt.FLOAT},...a],instancePrimitiveVertexCount:6}),r.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:r.builder.getSymbolVertexShader(),fragmentShader:r.builder.getSymbolFragmentShader(),attributesDesc:[{name:ae.LOCAL_POSITION,size:2,type:Nt.FLOAT}],instancedAttributesDesc:[{name:ae.POSITION,size:2,type:Nt.FLOAT},...a],instancePrimitiveVertexCount:6}),o}),this.hasFill_=this.renderPasses_.some(r=>r.fillRenderPass),this.hasStroke_=this.renderPasses_.some(r=>r.strokeRenderPass),this.hasSymbol_=this.renderPasses_.some(r=>r.symbolRenderPass),this.setHelper(i)}async generateBuffers(t,e){if(t.isEmpty())return null;const i=this.generateRenderInstructions_(t,e),[n,r,o]=await Promise.all([this.generateBuffersForType_(i.polygonInstructions,"Polygon",e),this.generateBuffersForType_(i.lineStringInstructions,"LineString",e),this.generateBuffersForType_(i.pointInstructions,"Point",e)]),a=br(Mt(),e);return{polygonBuffers:n,lineStringBuffers:r,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(t,e){const i=this.hasFill_?Qp(t.polygonBatch,new Float32Array(0),this.customAttributes_,e):null,n=this.hasStroke_?Jp(t.lineStringBatch,new Float32Array(0),this.customAttributes_,e):null,r=this.hasSymbol_?qp(t.pointBatch,new Float32Array(0),this.customAttributes_,e):null;return{polygonInstructions:i,lineStringInstructions:n,pointInstructions:r}}generateBuffersForType_(t,e,i){if(t===null)return null;const n=a_++;let r;switch(e){case"Polygon":r=Co.GENERATE_POLYGON_BUFFERS;break;case"LineString":r=Co.GENERATE_LINE_STRING_BUFFERS;break;case"Point":r=Co.GENERATE_POINT_BUFFERS;break}const o={id:n,type:r,renderInstructions:t.buffer,renderInstructionsTransform:i,customAttributesSize:$r(this.customAttributes_)},a=o_();return a.postMessage(o,[t.buffer]),t=null,new Promise(l=>{const h=c=>{const u=c.data;if(u.id!==n||(a.removeEventListener("message",h),!this.helper_.getGL()))return;const d=new po(Xa,go).fromArrayBuffer(u.indicesBuffer),f=new po(dr,go).fromArrayBuffer(u.vertexAttributesBuffer),g=new po(dr,go).fromArrayBuffer(u.instanceAttributesBuffer);this.helper_.flushBufferData(d),this.helper_.flushBufferData(f),this.helper_.flushBufferData(g),l([d,f,g])};a.addEventListener("message",h)})}render(t,e,i){for(const n of this.renderPasses_)n.fillRenderPass&&this.renderInternal_(t.polygonBuffers[0],t.polygonBuffers[1],t.polygonBuffers[2],n.fillRenderPass,e,i),n.strokeRenderPass&&this.renderInternal_(t.lineStringBuffers[0],t.lineStringBuffers[1],t.lineStringBuffers[2],n.strokeRenderPass,e,i),n.symbolRenderPass&&this.renderInternal_(t.pointBuffers[0],t.pointBuffers[1],t.pointBuffers[2],n.symbolRenderPass,e,i)}renderInternal_(t,e,i,n,r,o){const a=t.getSize();if(a===0)return;const l=n.instancedAttributesDesc.length;if(this.helper_.useProgram(n.program,r),this.helper_.bindBuffer(e),this.helper_.bindBuffer(t),this.helper_.enableAttributes(n.attributesDesc),this.helper_.bindBuffer(i),this.helper_.enableAttributesInstanced(n.instancedAttributesDesc),o(),l){const h=n.instancedAttributesDesc.reduce((u,d)=>u+(d.size||1),0),c=i.getSize()/h;this.helper_.drawElementsInstanced(0,a,c)}else this.helper_.drawElements(0,a)}setHelper(t,e=null){this.helper_=t;for(const i of this.renderPasses_)i.fillRenderPass&&(i.fillRenderPass.program=this.helper_.getProgram(i.fillRenderPass.fragmentShader,i.fillRenderPass.vertexShader)),i.strokeRenderPass&&(i.strokeRenderPass.program=this.helper_.getProgram(i.strokeRenderPass.fragmentShader,i.strokeRenderPass.vertexShader)),i.symbolRenderPass&&(i.symbolRenderPass.program=this.helper_.getProgram(i.symbolRenderPass.fragmentShader,i.symbolRenderPass.vertexShader));this.helper_.addUniforms(this.uniforms_),e&&(e.polygonBuffers&&(this.helper_.flushBufferData(e.polygonBuffers[0]),this.helper_.flushBufferData(e.polygonBuffers[1]),this.helper_.flushBufferData(e.polygonBuffers[2])),e.lineStringBuffers&&(this.helper_.flushBufferData(e.lineStringBuffers[0]),this.helper_.flushBufferData(e.lineStringBuffers[1]),this.helper_.flushBufferData(e.lineStringBuffers[2])),e.pointBuffers&&(this.helper_.flushBufferData(e.pointBuffers[0]),this.helper_.flushBufferData(e.pointBuffers[1]),this.helper_.flushBufferData(e.pointBuffers[2])))}}function h_(s,t){const e=Array.isArray(s)?s:[s];if("style"in e[0]){const i=[],n=e,r=[];for(const o of n){const a=Array.isArray(o.style)?o.style:[o.style];let l=o.filter;o.else&&r.length&&(l=["all",...r.map(c=>["!",c])],o.filter&&l.push(o.filter),l.length<3&&(l=l[1])),o.filter&&r.push(o.filter);const h=a.map(c=>Th(c,t,l));i.push(...h)}return i}return"builder"in e[0]?e:e.map(i=>Th(i,t,null))}const Pe=new Uint8Array(4);class c_{constructor(t,e){this.helper_=t;const i=t.getGL();this.texture_=i.createTexture(),this.framebuffer_=i.createFramebuffer(),this.depthbuffer_=i.createRenderbuffer(),this.size_=e||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(t){ei(t,this.size_)||(this.size_[0]=t[0],this.size_[1]=t[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){const t=this.size_,e=this.helper_.getGL();e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.readPixels(0,0,t[0],t[1],e.RGBA,e.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(t,e){if(t<0||e<0||t>this.size_[0]||e>=this.size_[1])return Pe[0]=0,Pe[1]=0,Pe[2]=0,Pe[3]=0,Pe;this.readAll();const i=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return Pe[0]=this.data_[i*4],Pe[1]=this.data_[i*4+1],Pe[2]=this.data_[i*4+2],Pe[3]=this.data_[i*4+3],Pe}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){const t=this.size_,e=this.helper_.getGL();this.texture_=this.helper_.createTexture(t,null,this.texture_),e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.viewport(0,0,t[0],t[1]),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture_,0),e.bindRenderbuffer(e.RENDERBUFFER,this.depthbuffer_),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,t[0],t[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(t[0]*t[1]*4)}}const Js={PATTERN_ORIGIN_X_DOUBLE:"u_df_patternOriginX",PATTERN_ORIGIN_Y_DOUBLE:"u_df_patternOriginY",PATTERN_SCALE_RATIO_DOUBLE:"u_df_patternScaleRatio",ONE:"u_one"},Le=[0,0],Yi=[0,0],ai=Mt(),Sh=Vc();function u_(s,t,e,i){Jh(ai,t),qh(ai,e),s.setUniformMatrixValue(xe.PROJECTION_MATRIX,Ko(Sh,ai)),br(ai,ai),s.setUniformMatrixValue(xe.INVERT_PROJECTION_MATRIX,Ko(Sh,ai)),Le[0]=0,Le[1]=0;const n=i.size,r=i.viewState.resolution,o=i.viewState.center;ge(ai,n[0]/2,n[1]/2,1/r,1/r,0,-o[0],-o[1]),wt(ai,Le),Yi[0]=qs(Le[0]),Yi[1]=vo(Le[0]),s.setUniformFloatVec2(Js.PATTERN_ORIGIN_X_DOUBLE,Yi),Yi[0]=qs(Le[1]),Yi[1]=vo(Le[1]),s.setUniformFloatVec2(Js.PATTERN_ORIGIN_Y_DOUBLE,Yi);const a=Math.pow(2,(i.viewState.zoom+.5)%1-.5);Le[0]=qs(a),Le[1]=vo(a),s.setUniformFloatVec2(Js.PATTERN_SCALE_RATIO_DOUBLE,Le)}function d_(s,t){const e=s.viewState.projection,n=t.getSource().getWrapX()&&e.canWrapX(),r=e.getExtent(),o=s.extent,a=n?at(r):null,l=n?Math.ceil((o[2]-r[2])/a)+1:1;return[n?Math.floor((o[0]-r[0])/a):0,l,a]}const To={...xe,...Js,RENDER_EXTENT:"u_renderExtent",GLOBAL_ALPHA:"u_globalAlpha"};class f_ extends Ya{constructor(t,e){const i={[To.RENDER_EXTENT]:[0,0,0,0],[To.GLOBAL_ALPHA]:1,[To.ONE]:1};super(t,{uniforms:i,postProcesses:e.postProcesses}),this.hitDetectionEnabled_=!e.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=Wt(),this.currentTransform_=Mt(),this.currentFrameStateTransform_=Mt(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(e),this.batch_=new pr,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(t){const e=this.getLayer().getSource();let i;this.batch_.addFeatures(e.getFeatures(),i),this.sourceListenKeys_=[H(e,Bt.ADDFEATURE,this.handleSourceFeatureAdded_.bind(this,i)),H(e,Bt.CHANGEFEATURE,this.handleSourceFeatureChanged_.bind(this,i),this),H(e,Bt.REMOVEFEATURE,this.handleSourceFeatureDelete_,this),H(e,Bt.CLEAR,this.handleSourceFeatureClear_,this)]}applyOptions_(t){this.styleVariables_=t.variables,this.style_=t.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new l_(this.style_,this.styleVariables_,this.helper,this.hitDetectionEnabled_)}reset(t){this.applyOptions_(t),this.helper&&this.createRenderers_(),super.reset(t)}afterHelperCreated(){this.styleRenderer_?this.styleRenderer_.setHelper(this.helper,this.buffers_):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new c_(this.helper))}handleSourceFeatureAdded_(t,e){const i=e.feature;this.batch_.addFeature(i,t)}handleSourceFeatureChanged_(t,e){const i=e.feature;this.batch_.changeFeature(i,t)}handleSourceFeatureDelete_(t){const e=t.feature;this.batch_.removeFeature(e)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(t,e){u_(this.helper,this.currentFrameStateTransform_,t,e)}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[i,n,r]=d_(t,this.getLayer());this.helper.prepareDraw(t),this.renderWorlds(t,!1,i,n,r),this.helper.finalizeDraw(t,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const o=this.helper.getCanvas();return this.hitDetectionEnabled_&&(this.renderWorlds(t,!0,i,n,r),this.hitRenderTarget_.clearCachedData()),this.postRender(e,t),o}prepareFrameInternal(t){this.initialFeaturesAdded_||(this.addInitialFeatures_(t),this.initialFeaturesAdded_=!0);const e=this.getLayer(),i=e.getSource(),n=t.viewState,r=!t.viewHints[Dt.ANIMATING]&&!t.viewHints[Dt.INTERACTING],o=!dn(this.previousExtent_,t.extent),a=this.sourceRevision_<i.getRevision();if(a&&(this.sourceRevision_=i.getRevision()),r&&(o||a)){const l=n.projection,h=n.resolution,c=e instanceof zr?e.getRenderBuffer():0,u=En(t.extent,c*h);i.loadFeatures(u,h,l),this.ready=!1;const d=this.helper.makeProjectionTransform(t,Mt());this.styleRenderer_.generateBuffers(this.batch_,d).then(f=>{this.buffers_&&this.disposeBuffers(this.buffers_),this.buffers_=f,this.ready=!0,this.getLayer().changed()}),this.previousExtent_=t.extent.slice()}return!0}renderWorlds(t,e,i,n,r){let o=i;e&&(this.hitRenderTarget_.setSize([Math.floor(t.size[0]/2),Math.floor(t.size[1]/2)]),this.helper.prepareDrawToRenderTarget(t,this.hitRenderTarget_,!0));do this.helper.makeProjectionTransform(t,this.currentFrameStateTransform_),Cd(this.currentFrameStateTransform_,o*r,0),this.buffers_&&this.styleRenderer_.render(this.buffers_,t,()=>{this.applyUniforms_(this.buffers_.invertVerticesTransform,t),this.helper.applyHitDetectionUniform(e)});while(++o<n)}forEachFeatureAtCoordinate(t,e,i,n,r){if(Q(this.hitDetectionEnabled_,"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has been disabled using the `disableHitDetection: true` option."),!this.styleRenderer_||!this.hitDetectionEnabled_)return;const o=wt(e.coordinateToPixelTransform,t.slice()),a=this.hitRenderTarget_.readPixel(o[0]/2,o[1]/2),l=[a[0]/255,a[1]/255,a[2]/255,a[3]/255],h=Kp(l),c=this.batch_.getFeatureFromRef(h);if(c)return n(c,this.getLayer(),null)}disposeBuffers(t){const e=i=>{for(const n of i)n&&this.helper.deleteBuffer(n)};t.pointBuffers&&e(t.pointBuffers),t.lineStringBuffers&&e(t.lineStringBuffers),t.polygonBuffers&&e(t.polygonBuffers)}disposeInternal(){this.buffers_&&this.disposeBuffers(this.buffers_),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach(function(t){dt(t)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const Ve={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},g_=["#00f","#0ff","#0f0","#ff0","#f00"];class p_ extends zr{constructor(t){t=t||{};const e=Object.assign({},t);delete e.gradient,delete e.radius,delete e.blur,delete e.weight,super(e),this.on,this.once,this.un,this.filter_=t.filter??!0,this.styleVariables_=t.variables||{},this.gradient_=null,this.addChangeListener(Ve.GRADIENT,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:g_),this.setBlur(t.blur!==void 0?t.blur:15),this.setRadius(t.radius!==void 0?t.radius:8);const i=t.weight?t.weight:"weight";this.weight_=i,this.setRenderOrder(null)}getBlur(){return this.get(Ve.BLUR)}getGradient(){return this.get(Ve.GRADIENT)}getRadius(){return this.get(Ve.RADIUS)}handleGradientChanged_(){this.gradient_=__(this.getGradient())}setBlur(t){const e=this.get(Ve.BLUR);if(this.set(Ve.BLUR,t),typeof t=="number"&&typeof e=="number"){this.changed();return}this.clearRenderer()}setGradient(t){this.set(Ve.GRADIENT,t)}setRadius(t){const e=this.get(Ve.RADIUS);if(this.set(Ve.RADIUS,t),typeof t=="number"&&typeof e=="number"){this.changed();return}this.clearRenderer()}setFilter(t){this.filter_=t,this.changed(),this.clearRenderer()}setWeight(t){this.weight_=t,this.changed(),this.clearRenderer()}createRenderer(){const t=new nu,e=qc(),i=fs(),n=U(e,this.filter_,bt,i);let r=U(e,this.getRadius(),A),o=U(e,this.getBlur(),A);const a={};typeof this.getBlur()=="number"&&(o="a_blur",a.a_blur=()=>this.getBlur(),t.addUniform("a_blur","float")),typeof this.getRadius()=="number"&&(r="a_radius",a.a_radius=()=>this.getRadius(),t.addUniform("a_radius","float"));const l={};let h=null;if(typeof this.weight_=="string"||typeof this.weight_=="function"){const f=typeof this.weight_=="string"?g=>g.get(this.weight_):this.weight_;l.prop_weight={size:1,callback:g=>{const _=f(g);return _!==void 0?pt(_,0,1):1}},h="a_prop_weight",t.addAttribute("a_prop_weight","float")}else{const f=["clamp",this.weight_,0,1];h=U(e,f,A)}const c=`(${r} / max(1., ${o}))`;t.setSymbolSizeExpression(`vec2(${r} + ${o}) * 2.`).setSymbolColorExpression(`vec4(smoothstep(0., 1., (1. - length(coordsPx * 2. / v_quadSizePx)) * ${c}) * ${h})`).setStrokeColorExpression(`vec4(smoothstep(0., 1., (1. - length(currentRadiusPx * 2. / v_width)) * ${c}) * ${h})`).setStrokeWidthExpression(`(${r} + ${o}) * 2.`).setFillColorExpression(`vec4(${h})`),i.mCoordinate?t.setFragmentDiscardExpression(`!${n}`):t.setShapeDiscardExpression(`!${n}`),tu(t,e);const u=iu(e),d=eu(e,this.styleVariables_);return new f_(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:t,attributes:{...u,...l},uniforms:{...d,...a}},disableHitDetection:!1,postProcesses:[{fragmentShader:`
|
|
681
|
+
precision mediump float;
|
|
682
|
+
|
|
683
|
+
uniform sampler2D u_image;
|
|
684
|
+
uniform sampler2D u_gradientTexture;
|
|
685
|
+
uniform float u_opacity;
|
|
686
|
+
|
|
687
|
+
varying vec2 v_texCoord;
|
|
688
|
+
|
|
689
|
+
void main() {
|
|
690
|
+
vec4 color = texture2D(u_image, v_texCoord);
|
|
691
|
+
gl_FragColor.a = color.a * u_opacity;
|
|
692
|
+
gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;
|
|
693
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
694
|
+
}`,uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}renderDeclutter(){}}function __(s){const i=Tt(1,256),n=i.createLinearGradient(0,0,1,256),r=1/(s.length-1);for(let o=0,a=s.length;o<a;++o)n.addColorStop(o*r,s[o]);return i.fillStyle=n,i.fillRect(0,0,1,256),i.canvas}class m_ extends Ut{constructor(t,e,i){super(t,e,nt.HEATMAP,{...i,zIndex:i?.zIndex??20}),this.heatmapLayer=null,this.data=[],this.source=new St,this.heatmapLayer=new p_({source:this.source,blur:i?.blur||15,radius:i?.radius||8,weight:"weight",visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.layer=this.heatmapLayer,i?.colorStops&&this.heatmapLayer.setGradient(i.colorStops)}createLayer(t){if(!this.heatmapLayer)throw new Error("HeatmapLayer not initialized");return this.heatmapLayer.setBlur(15),this.heatmapLayer.setRadius(10),t.addLayer(this.heatmapLayer),this.heatmapLayer}setData(t){this.data=t,this.clear(),this.source&&t.forEach(e=>{const i=new ot({geometry:new gt(te([e.longitude,e.latitude])),weight:e.value||1});this.source?.addFeature(i)})}updateData(t){this.setData(t)}getLayer(){return this.heatmapLayer}}class y_ extends St{constructor(t){t=t||{},super({attributions:t.attributions,wrapX:t.wrapX}),this.resolution=void 0,this.distance=t.distance!==void 0?t.distance:20,this.minDistance=t.minDistance||0,this.interpolationRatio=0,this.features=[],this.geometryFunction=t.geometryFunction||function(e){const i=e.getGeometry();return Q(!i||i.getType()==="Point","The default `geometryFunction` can only handle `Point` or null geometries"),i},this.createCustomCluster_=t.createCluster,this.source=null,this.boundRefresh_=this.refresh.bind(this),this.updateDistance(this.distance,this.minDistance),this.setSource(t.source||null)}clear(t){this.features.length=0,super.clear(t)}getDistance(){return this.distance}getSource(){return this.source}loadFeatures(t,e,i){this.source?.loadFeatures(t,e,i),e!==this.resolution&&(this.resolution=e,this.refresh())}setDistance(t){this.updateDistance(t,this.minDistance)}setMinDistance(t){this.updateDistance(this.distance,t)}getMinDistance(){return this.minDistance}setSource(t){this.source&&this.source.removeEventListener(j.CHANGE,this.boundRefresh_),this.source=t,t&&t.addEventListener(j.CHANGE,this.boundRefresh_),this.refresh()}refresh(){this.clear(),this.cluster(),this.addFeatures(this.features)}updateDistance(t,e){const i=t===0?0:Math.min(e,t)/t,n=t!==this.distance||this.interpolationRatio!==i;this.distance=t,this.minDistance=e,this.interpolationRatio=i,n&&this.refresh()}cluster(){if(this.resolution===void 0||!this.source)return;const t=Wt(),e=this.distance*this.resolution,i=this.source.getFeatures(),n={};for(let r=0,o=i.length;r<o;r++){const a=i[r];if(!($(a)in n)){const l=this.geometryFunction(a);if(l){const h=l.getCoordinates();ha(h,t),En(t,e,t);const c=this.source.getFeaturesInExtent(t).filter(function(u){const d=$(u);return d in n?!1:(n[d]=!0,!0)});this.features.push(this.createCluster(c,t))}}}}createCluster(t,e){const i=[0,0];for(let a=t.length-1;a>=0;--a){const l=this.geometryFunction(t[a]);l?Nh(i,l.getCoordinates()):t.splice(a,1)}Gh(i,1/t.length);const n=ue(e),r=this.interpolationRatio,o=new gt([i[0]*(1-r)+n[0]*r,i[1]*(1-r)+n[1]*r]);return this.createCustomCluster_?this.createCustomCluster_(o,t):new ot({geometry:o,features:t})}}class x_ extends Ut{constructor(t,e,i){super(t,e,nt.CLUSTER,{...i,zIndex:i?.zIndex??15}),this.clusterSource=null,this.clusterLayer=null,this.source=new St,this.clusterSource=new y_({distance:i?.distance||60,source:this.source}),this.clusterLayer=new Ht({source:this.clusterSource,style:n=>this.createStyle(n),properties:{id:t,name:e,type:nt.CLUSTER},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.layer=this.clusterLayer}createStyle(t){const e=t.get("features"),i=e?e.length:1,n=i>1,r=[255,0,0,.8],o=[0,112,255,.8];if(n){const a=Math.min(40,20+i/10);return new lt({image:new ze({radius:a,fill:new ut({color:ft(o)}),stroke:new _t({color:"#fff",width:2})}),text:new vn({text:i.toString(),fill:new ut({color:"#fff"}),font:"bold 14px sans-serif"})})}return new lt({image:new ze({radius:8,fill:new ut({color:ft(r)}),stroke:new _t({color:"#fff",width:2})})})}createLayer(t){if(!this.clusterLayer)throw new Error("ClusterLayer not initialized");return t.addLayer(this.clusterLayer),this.clusterLayer}setData(t){this.clear(),this.source&&t.forEach(e=>{const i=new ot({geometry:new gt(te([e.longitude,e.latitude])),id:e.id,title:e.title,popupContent:e.popupContent});this.source?.addFeature(i)})}updateData(t){this.setData(t)}getLayer(){return this.clusterLayer}destroy(){if(this.clusterLayer){const t=this.clusterLayer.getMap?.();t&&typeof t.removeLayer=="function"&&t.removeLayer(this.clusterLayer),typeof this.clusterLayer.dispose=="function"&&this.clusterLayer.dispose(),this.clusterLayer=null}this.clusterSource=null,super.destroy()}}class ss extends Qh{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(dt),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,i=t.length;e<i;++e)this.changeEventsKeys_.push(H(t[e],j.CHANGE,this.changed,this))}clone(){const t=new ss(So(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<ki(this.getExtent(),t,e))return n;const r=this.geometries_;for(let o=0,a=r.length;o<a;++o)n=r[o].closestPointXY(t,e,i,n);return n}containsXY(t,e){const i=this.geometries_;for(let n=0,r=i.length;n<r;++n)if(i[n].containsXY(t,e))return!0;return!1}computeExtent(t){as(t);const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)Bn(t,e[i].getExtent());return t}getGeometries(){return So(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[];const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)e[i].getType()===this.getType()?t=t.concat(e[i].getGeometriesArrayRecursive()):t.push(e[i]);return t}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=[],i=this.geometries_;let n=!1;for(let r=0,o=i.length;r<o;++r){const a=i[r],l=a.getSimplifiedGeometry(t);e.push(l),l!==a&&(n=!0)}return n?new ss(e):(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getType(){return"GeometryCollection"}intersectsExtent(t){const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)if(e[i].intersectsExtent(t))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(t,e){const i=this.geometries_;for(let n=0,r=i.length;n<r;++n)i[n].rotate(t,e);this.changed()}scale(t,e,i){i||(i=ue(this.getExtent()));const n=this.geometries_;for(let r=0,o=n.length;r<o;++r)n[r].scale(t,e,i);this.changed()}setGeometries(t){this.setGeometriesArray(So(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)e[i].applyTransform(t);this.changed()}translate(t,e){const i=this.geometries_;for(let n=0,r=i.length;n<r;++n)i[n].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function So(s){return s.map(t=>t.clone())}class E_{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=ot,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let i=e.dataProjection?Ct(e.dataProjection):this.readProjection(t);e.extent&&i&&i.getUnits()==="tile-pixels"&&(i=Ct(i),i.setWorldExtent(e.extent)),e={dataProjection:i,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return X()}readFeature(t,e){return X()}readFeatures(t,e){return X()}readGeometry(t,e){return X()}readProjection(t){return X()}writeFeature(t,e){return X()}writeFeatures(t,e){return X()}writeGeometry(t,e){return X()}}function il(s,t,e){const i=e?Ct(e.featureProjection):null,n=e?Ct(e.dataProjection):null;let r=s;if(i&&n&&!Un(i,n)){t&&(r=s.clone());const o=t?i:n,a=t?n:i;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(Hn(o,a))}if(t&&e&&e.decimals!==void 0){const o=Math.pow(10,e.decimals),a=function(l){for(let h=0,c=l.length;h<c;++h)l[h]=Math.round(l[h]*o)/o;return l};r===s&&(r=s.clone()),r.applyTransform(a)}return r}const v_={Point:gt,LineString:fe,Polygon:ht,MultiPoint:ps,MultiLineString:_n,MultiPolygon:mn};function C_(s,t,e){return Array.isArray(t[0])?($c(s,0,t,e)||(s=s.slice(),Zo(s,0,t,e)),s):(Ga(s,0,t,e)||(s=s.slice(),cr(s,0,t,e)),s)}function ru(s,t){const e=s.geometry;if(!e)return[];if(Array.isArray(e))return e.map(r=>ru({...s,geometry:r})).flat();const i=e.type==="MultiPolygon"?"Polygon":e.type;if(i==="GeometryCollection"||i==="Circle")throw new Error("Unsupported geometry type: "+i);const n=e.layout.length;return il(new Jt(i,i==="Polygon"?C_(e.flatCoordinates,e.ends,n):e.flatCoordinates,e.ends?.flat(),n,s.properties||{},s.id).enableSimplifyTransformed(),!1,t)}function nl(s,t){if(!s)return null;if(Array.isArray(s)){const i=s.map(n=>nl(n,t));return new ss(i)}const e=v_[s.type];return il(new e(s.flatCoordinates,s.layout||"XY",s.ends),!1,t)}class w_ extends E_{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject($s(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject($s(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return X()}readFeaturesFromObject(t,e){return X()}readGeometry(t,e){return this.readGeometryFromObject($s(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return X()}readProjection(t){return this.readProjectionFromObject($s(t))}readProjectionFromObject(t){return X()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return X()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return X()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return X()}}function $s(s){if(typeof s=="string"){const t=JSON.parse(s);return t||null}return s!==null?s:null}class T_ extends w_{constructor(t){t=t||{},super(),this.dataProjection=Ct(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=Ct(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let i=null;t.type==="Feature"?i=t:i={type:"Feature",geometry:t,properties:null};const n=sl(i.geometry);if(this.featureClass===Jt)return ru({geometry:n,id:i.id,properties:i.properties},e);const r=new ot;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&r.setGeometryName(i.geometry_name),r.setGeometry(nl(n,e)),"id"in i&&r.setId(i.id),i.properties&&r.setProperties(i.properties,!0),r}readFeaturesFromObject(t,e){const i=t;let n=null;if(i.type==="FeatureCollection"){const r=t;n=[];const o=r.features;for(let a=0,l=o.length;a<l;++a){const h=this.readFeatureFromObject(o[a],e);h&&n.push(h)}}else n=[this.readFeatureFromObject(t,e)];return n.flat()}readGeometryFromObject(t,e){return S_(t,e)}readProjectionFromObject(t){const e=t.crs;let i;if(e)if(e.type=="name")i=Ct(e.properties.name);else if(e.type==="EPSG")i=Ct("EPSG:"+e.properties.code);else throw new Error("Unknown SRS type");else i=this.dataProjection;return i}writeFeatureObject(t,e){e=this.adaptOptions(e);const i={type:"Feature",geometry:null,properties:null},n=t.getId();if(n!==void 0&&(i.id=n),!t.hasProperties())return i;const r=t.getProperties(),o=t.getGeometry();return o&&(i.geometry=ta(o,e),delete r[t.getGeometryName()]),Ai(r)||(i.properties=r),i}writeFeaturesObject(t,e){e=this.adaptOptions(e);const i=[];for(let n=0,r=t.length;n<r;++n)i.push(this.writeFeatureObject(t[n],e));return{type:"FeatureCollection",features:i}}writeGeometryObject(t,e){return ta(t,this.adaptOptions(e))}}function sl(s,t){if(!s)return null;let e;switch(s.type){case"Point":{e=b_(s);break}case"LineString":{e=P_(s);break}case"Polygon":{e=A_(s);break}case"MultiPoint":{e=I_(s);break}case"MultiLineString":{e=L_(s);break}case"MultiPolygon":{e=M_(s);break}case"GeometryCollection":{e=R_(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return e}function S_(s,t){const e=sl(s);return nl(e,t)}function R_(s,t){return s.geometries.map(function(i){return sl(i)})}function b_(s){const t=s.coordinates;return{type:"Point",flatCoordinates:t,layout:Oi(t.length)}}function P_(s){const t=s.coordinates,e=t.flat();return{type:"LineString",flatCoordinates:e,ends:[e.length],layout:Oi(t[0]?.length||2)}}function L_(s){const t=s.coordinates,e=t[0]?.[0]?.length||2,i=[],n=us(i,0,t,e);return{type:"MultiLineString",flatCoordinates:i,ends:n,layout:Oi(e)}}function I_(s){const t=s.coordinates;return{type:"MultiPoint",flatCoordinates:t.flat(),layout:Oi(t[0]?.length||2)}}function M_(s){const t=s.coordinates,e=[],i=t[0]?.[0]?.[0].length||2,n=ec(e,0,t,i);return{type:"MultiPolygon",flatCoordinates:e,ends:n,layout:Oi(i)}}function A_(s){const t=s.coordinates,e=[],i=t[0]?.[0]?.length,n=us(e,0,t,i);return{type:"Polygon",flatCoordinates:e,ends:n,layout:Oi(i)}}function ta(s,t){s=il(s,!0,t);const e=s.getType();let i;switch(e){case"Point":{i=G_(s);break}case"LineString":{i=k_(s);break}case"Polygon":{i=z_(s,t);break}case"MultiPoint":{i=O_(s);break}case"MultiLineString":{i=F_(s);break}case"MultiPolygon":{i=N_(s,t);break}case"GeometryCollection":{i=D_(s,t);break}case"Circle":{i={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+e)}return i}function D_(s,t){return t=Object.assign({},t),delete t.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(i){return ta(i,t)})}}function k_(s,t){return{type:"LineString",coordinates:s.getCoordinates()}}function F_(s,t){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function O_(s,t){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function N_(s,t){let e;return t&&(e=t.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(e)}}function G_(s,t){return{type:"Point",coordinates:s.getCoordinates()}}function z_(s,t){let e;return t&&(e=t.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(e)}}class $_ extends Ut{constructor(t,e,i){super(t,e,nt.GEOJSON,{...i,zIndex:i?.zIndex??15}),this.source=new St,this.layer=new Ht({source:this.source,properties:{id:t,name:e,type:nt.GEOJSON},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.geoJsonFormat=new T_}createLayer(t){return t.addLayer(this.layer),this.layer}loadGeoJSON(t){this.clear();const e=this.geoJsonFormat.readFeatures(t,{dataProjection:"EPSG:4326",featureProjection:"EPSG:3857"});this.source?.addFeatures(e)}async loadFromUrl(t){const i=await(await fetch(t)).json();this.loadGeoJSON(i)}updateData(t){t.url?this.loadFromUrl(t.url):t.geojson&&this.loadGeoJSON(t.geojson)}getLayer(){return this.layer}}class B_ extends Ut{constructor(t,e,i){super(t,e,nt.BARCHART,{...i,zIndex:i?.zIndex??15}),this.features=new Map,this.maxValue=1,this.maxHeight=i?.maxHeight||100,this.defaultColor=i?.defaultColor||[255,0,0,.8],this.unit=i?.unit||"",this.source=new St,this.layer=new Ht({source:this.source,properties:{id:t,name:e,type:nt.BARCHART},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createLayer(t){return t.addLayer(this.layer),this.layer}calcMaxValue(t){this.maxValue=1;for(const e of t)e.value>this.maxValue&&(this.maxValue=e.value)}getHeight(t){return t/this.maxValue*this.maxHeight}getColor(t){const e=t/this.maxValue;return e<.2?[0,255,0,.8]:e<.4?[100,255,0,.8]:e<.6?[255,255,0,.8]:e<.8?[255,150,0,.8]:[255,0,0,.8]}setData(t){this.calcMaxValue(t),this.clear(),t.forEach(e=>{const i=this.getHeight(e.value),n=e.color||this.getColor(e.value),r=new ot({geometry:new gt(te([e.longitude,e.latitude])),id:e.id,title:e.title,value:e.value,height:i,color:ft(n)});r.setStyle(new lt({fill:new ut({color:ft(n)}),image:new ze({radius:Math.sqrt(i)/2,fill:new ut({color:ft(n)})})})),this.source?.addFeature(r),this.features.set(e.id,r)})}updateData(t){this.setData(t)}}class W_ extends Ut{constructor(t,e,i){super(t,e,nt.MARKER,i),this.moveHandler=null,this.features=new Map,this.view=null,this.currentPopup=null,this.currentFeature=null,this.needsUpdate=!1,this.animationFrameId=null,this.postRenderHandler=null,this.updateFrame=null,this.defaultColor=i?.defaultColor||[255,0,0,.8],this.defaultSize=i?.defaultSize||12,this.popupWidth=i?.popupWidth||260,this.coverImageHeight=i?.coverImageHeight||120,this.source=new St,this.layer=new Ht({source:this.source,properties:{id:t,name:e,type:nt.MARKER},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setView(t){this.view=t,this.attachClickEvent(),this.postRenderHandler=()=>{this.updatePopupPosition()},this.view.on("postrender",this.postRenderHandler)}scheduleUpdate(){this.animationFrameId===null&&(this.animationFrameId=requestAnimationFrame(()=>{this.needsUpdate&&(this.updatePopupPosition(),this.needsUpdate=!1),this.animationFrameId=null}))}createLayer(t){return t.addLayer(this.layer),this.layer}attachClickEvent(){this.view&&this.view.on("click",t=>{const i=this.view.getFeaturesAtPixel(t.pixel)?.find(n=>n.get("_popupLayer")===this.id);i?this.showPopup(i,t):this.hidePopup()})}addMarker(t){const e=new ot({geometry:new gt(te([t.longitude,t.latitude])),id:t.id,title:t.title,description:t.description,coverImage:t.coverImage,_popupLayer:this.id}),i=t.color||this.defaultColor,n=t.size||this.defaultSize;e.setStyle(new lt({image:new ze({radius:n/2,fill:new ut({color:ft(i)}),stroke:new _t({color:"#fff",width:2})})})),this.source?.addFeature(e),this.features.set(t.id,e)}removeMarker(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.currentFeature===e&&this.hidePopup())}showPopup(t,e){this.hidePopup(),this.currentFeature=t;const i=t.getProperties(),n=i.coverImage&&i.coverImage.trim()!=="",r=i.title&&i.title.trim()!=="",o=i.description&&i.description.trim()!=="",l=(document.body.getAttribute("data-theme")||"dark")==="dark",h=l?"#1e1e1e":"#ffffff",c=l?"#333":"#e0e0e0",u=l?"#fff":"#333",d=l?"#aaa":"#666",f=document.createElement("div");f.style.position="absolute",f.style.zIndex="10000",f.style.background=h,f.style.border=`1px solid ${c}`,f.style.borderRadius="8px",f.style.boxShadow="0 4px 12px rgba(0,0,0,0.3)",f.style.width=`${this.popupWidth}px`,f.style.maxWidth=`${this.popupWidth}px`,f.style.overflow="hidden";let g="";n&&(g+=`<div style="height: ${this.coverImageHeight}px; overflow: hidden;">
|
|
695
|
+
<img src="${i.coverImage}" style="width: 100%; height: 100%; object-fit: cover;" />
|
|
696
|
+
</div>`),g+='<div style="padding: 12px;">',r&&(g+=`<div style="font-size: 14px; font-weight: 600; color: ${u}; margin-bottom: 8px;">${i.title}</div>`),o&&(g+=`<div style="font-size: 12px; color: ${d}; line-height: 1.5;">${i.description}</div>`),g+="</div>",f.innerHTML=g;const _=this.view.getTargetElement();getComputedStyle(_).position==="static"&&(_.style.position="relative"),_.appendChild(f);const p=t.getGeometry(),m=this.view.getPixelFromCoordinate(p.getCoordinates()),y=_.getBoundingClientRect(),C=f.offsetWidth,x=f.offsetHeight;if(!(m[0]>=0&&m[0]<=y.width&&m[1]>=0&&m[1]<=y.height)){f.style.display="none",this.currentPopup=f;return}let S=m[0]-y.left-C/2,w=m[1]-y.top-x-15;w<5&&(w=m[1]-y.top+15),S=Math.max(5,Math.min(S,y.width-C-5)),w=Math.max(5,Math.min(w,y.height-x-5)),f.style.left=`${S}px`,f.style.top=`${w}px`,f.style.display="block",this.currentPopup=f}hidePopup(){this.currentPopup&&(this.currentPopup.remove(),this.currentPopup=null),this.currentFeature=null}clearAllMarkers(){this.clear(),this.features.clear(),this.hidePopup()}getAllMarkers(){const t=[];return this.features.forEach((e,i)=>{const n=e.getGeometry(),r=Pt(n.getCoordinates());t.push({id:i,longitude:r[0],latitude:r[1],title:e.get("title"),description:e.get("description"),coverImage:e.get("coverImage")})}),t}updateData(t){t.markers&&(this.clearAllMarkers(),t.markers.forEach(e=>this.addMarker(e)))}updatePopupPosition(){!this.currentPopup||!this.currentFeature||(this.updateFrame&&cancelAnimationFrame(this.updateFrame),this.updateFrame=requestAnimationFrame(()=>{if(!this.currentPopup||!this.currentFeature)return;const t=this.currentFeature.getGeometry(),e=this.view.getPixelFromCoordinate(t.getCoordinates()),n=this.view.getTargetElement().getBoundingClientRect(),r=this.currentPopup.offsetWidth,o=this.currentPopup.offsetHeight;if(!(e[0]>=0&&e[0]<=n.width&&e[1]>=0&&e[1]<=n.height)){this.currentPopup.style.display="none";return}this.currentPopup.style.display="block";let l=e[0]-n.left-r/2,h=e[1]-n.top-o-15;l=Math.max(5,Math.min(l,n.width-r-5)),h=Math.max(5,Math.min(h,n.height-o-5)),this.currentPopup.style.left=`${l}px`,this.currentPopup.style.top=`${h}px`}))}destroy(){this.updateFrame&&cancelAnimationFrame(this.updateFrame),this.view&&this.postRenderHandler&&(this.view.un("postrender",this.postRenderHandler),this.postRenderHandler=null),super.destroy()}}function Ro(s,t,e){if(!(e in s))return s[e]=new Set([t]),!0;const i=s[e],n=i.has(t);return n||i.add(t),!n}function U_(s,t,e){const i=s[e];return i?i.delete(t):!1}function Rh(s,t){const e=s.layerStatesArray[s.layerIndex];e.extent&&(t=Li(t,Si(e.extent,s.viewState.projection)));const i=e.layer.getRenderSource();if(!i.getWrapX()){const n=i.getTileGridForProjection(s.viewState.projection).getExtent();n&&(t=Li(t,n))}return t}class X_ extends wc{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=Wt(),this.tempTileRange_=new Va(0,0,0,0),this.tempTileCoord_=gr(0,0,0);const i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new Ch(i),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new Ch(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,n){const r=this.tileCache_,a=this.getLayer().getSource(),l=Hs(a,a.getKey(),t,e,i);let h;if(r.containsKey(l))h=r.get(l);else{const c=n.viewState.projection,u=a.getProjection();if(h=a.getTile(t,e,i,n.pixelRatio,c,!u||Un(u,c)?void 0:this.getSourceTileCache()),!h)return null;r.set(l,h)}return h}getTile(t,e,i,n){const r=this.getOrCreateTile(t,e,i,n);return r||null}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),n=wt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!un(r,n))return null;const o=e.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(e.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){const u=l.getTileCoordForCoordAndZ(n,c),d=this.getTile(c,u[1],u[2],e);if(!d||d.getState()!==z.LOADED)continue;const f=l.getOrigin(c),g=Zt(l.getTileSize(c)),_=l.getResolution(c);let p;if(d instanceof Hc||d instanceof Kc)p=d.getImage();else if(d instanceof yh){if(p=qo(d.getData()),!p)continue}else continue;const m=Math.floor(h*((n[0]-f[0])/_-u[1]*g[0])),y=Math.floor(h*((f[1]-n[1])/_-u[2]*g[1])),C=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(p,m+C,y+C)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const i=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,i,n,r){const o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=$(l);c in t.wantedTiles||(t.wantedTiles[c]={});const u=t.wantedTiles[c],d=a.getMapInternal(),f=Math.max(i-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,_=g?Dh(o.center,o.resolution,g,t.size):void 0;for(let p=i;p>=f;--p){const m=h.getTileRangeForExtentAndZ(e,p,this.tempTileRange_),y=h.getResolution(p);for(let C=m.minX;C<=m.maxX;++C)for(let x=m.minY;x<=m.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([p,C,x],_))continue;const E=this.getTile(p,C,x,t);if(!E||!Ro(n,E,p))continue;const w=E.getKey();if(u[w]=!0,E.getState()===z.IDLE&&!t.tileQueue.isKeyQueued(w)){const T=gr(p,C,x,this.tempTileCoord_);t.tileQueue.enqueue([E,c,h.getTileCoordCenter(T),y])}}}}findStaleTile_(t,e){const i=this.tileCache_,n=t[0],r=t[1],o=t[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){const h=Hs(this.getLayer().getSource(),a[l],n,r,o);if(i.containsKey(h)){const c=i.peek(h);if(c.getState()===z.LOADED)return c.endTransition($(this)),Ro(e,c,n),!0}}return!1}findAltTiles_(t,e,i,n){const r=t.getTileRangeForTileCoordAndZ(e,i,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=r.minX;c<=r.maxX;++c)for(let u=r.minY;u<=r.maxY;++u){const d=Hs(l,h,i,c,u);let f=!1;if(a.containsKey(d)){const g=a.peek(d);g.getState()===z.LOADED&&(Ro(n,g,i),f=!0)}f||(o=!1)}return o}renderFrame(t,e){this.renderComplete=!0;const i=t.layerStatesArray[t.layerIndex],n=t.viewState,r=n.projection,o=n.resolution,a=n.center,l=t.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(r),d=u.getZForResolution(o,c.zDirection),f=u.getResolution(d),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let _=t.extent;const p=c.getTilePixelRatio(l);this.prepareContainer(t,e);const m=this.context.canvas.width,y=this.context.canvas.height;this.layerExtent=i.extent?Si(i.extent):null,this.layerExtent&&(_=Li(_,this.layerExtent));const C=f*m/2/p,x=f*y/2/p,E=[a[0]-C,a[1]-x,a[0]+C,a[1]+x],S={};this.renderedTiles.length=0;const w=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){const M=u.getZForResolution(n.nextResolution,c.zDirection),N=Rh(t,t.nextExtent);this.enqueueTiles(t,N,M,S,w)}const T=Rh(t,_);if(this.enqueueTiles(t,T,d,S,0),w>0&&setTimeout(()=>{this.enqueueTiles(t,T,d-1,S,w-1)},0),!(d in S))return this.container;const R=$(this),b=t.time;for(const M of S[d]){const N=M.getState();if(N===z.EMPTY)continue;const B=M.tileCoord;if(N===z.LOADED&&M.getAlpha(R,b)===1){M.endTransition(R);continue}if(N!==z.ERROR&&(this.renderComplete=!1),this.findStaleTile_(B,S)){U_(S,M,d),t.animate=!0;continue}if(this.findAltTiles_(u,B,d+1,S))continue;const ct=u.getMinZoom();for(let st=d-1;st>=ct&&!this.findAltTiles_(u,B,st,S);--st);}const L=f/o*l/p,I=this.getRenderContext(t);ge(this.tempTransform,m/2,y/2,L,L,0,-m/2,-y/2),this.layerExtent&&this.clipUnrotated(I,t,this.layerExtent),c.getInterpolate()||(I.imageSmoothingEnabled=!1),this.preRender(I,t);const F=Object.keys(S).map(Number);F.sort(Ke);let D;const k=[],G=[];for(let M=F.length-1;M>=0;--M){const N=F[M],B=c.getTilePixelSize(N,l,r),K=u.getResolution(N)/f,ct=B[0]*K*L,st=B[1]*K*L,P=u.getTileCoordForCoordAndZ(Fi(E),N),mt=u.getTileCoordExtent(P),Ot=wt(this.tempTransform,[p*(mt[0]-E[0])/f,p*(E[3]-mt[3])/f]),Xt=p*c.getGutterForProjection(r);for(const ie of S[N]){if(ie.getState()!==z.LOADED)continue;const mi=ie.tileCoord,ne=P[1]-mi[1],xs=Math.round(Ot[0]-(ne-1)*ct),Tn=P[2]-mi[2],Wr=Math.round(Ot[1]-(Tn-1)*st),Se=Math.round(Ot[0]-ne*ct),_e=Math.round(Ot[1]-Tn*st),Re=xs-Se,ni=Wr-_e,Es=F.length===1;let Sn=!1;D=[Se,_e,Se+Re,_e,Se+Re,_e+ni,Se,_e+ni];for(let zi=0,vs=k.length;zi<vs;++zi)if(!Es&&N<G[zi]){const zt=k[zi];Vt([Se,_e,Se+Re,_e+ni],[zt[0],zt[3],zt[4],zt[7]])&&(Sn||(I.save(),Sn=!0),I.beginPath(),I.moveTo(D[0],D[1]),I.lineTo(D[2],D[3]),I.lineTo(D[4],D[5]),I.lineTo(D[6],D[7]),I.moveTo(zt[6],zt[7]),I.lineTo(zt[4],zt[5]),I.lineTo(zt[2],zt[3]),I.lineTo(zt[0],zt[1]),I.clip())}k.push(D),G.push(N),this.drawTile(ie,t,Se,_e,Re,ni,Xt,Es),Sn&&I.restore(),this.renderedTiles.unshift(ie),this.updateUsedTiles(t.usedTiles,c,ie)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!dn(this.renderedExtent_,E),this.renderedExtent_=E,this.renderedPixelRatio=l,this.postRender(this.context,t),this.layerExtent&&I.restore(),I.imageSmoothingEnabled=!0,this.renderComplete){const M=(N,B)=>{const q=$(c),K=B.wantedTiles[q],ct=K?Object.keys(K).length:0;this.updateCacheSize(ct),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(M)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,n,r,o,a,l){let h;if(t instanceof yh){if(h=qo(t.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(t);if(!h)return;const c=this.getRenderContext(e),u=$(this),d=e.layerStatesArray[e.layerIndex],f=d.opacity*(l?t.getAlpha(u,e.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,i,n,r,o),g&&c.restore(),f!==d.opacity?e.animate=!0:l&&t.endTransition(u)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const n=$(e);n in t||(t[n]={}),t[n][i.getKey()]=!0}}const Bs={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class j_ extends Gr{constructor(t){t=t||{};const e=Object.assign({},t),i=t.cacheSize;delete t.cacheSize,delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(t.preload!==void 0?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Bs.PRELOAD)}setPreload(t){this.set(Bs.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(Bs.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(Bs.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}class ou extends j_{constructor(t){super(t)}createRenderer(){return new X_(this,{cacheSize:this.getCacheSize()})}}const Zi=[0,0,0],li=5;class au{constructor(t){this.minZoom=t.minZoom!==void 0?t.minZoom:0,this.resolutions_=t.resolutions,Q(ku(this.resolutions_,(n,r)=>r-n),"`resolutions` must be sorted in descending order");let e;if(!t.origins){for(let n=0,r=this.resolutions_.length-1;n<r;++n)if(!e)e=this.resolutions_[n]/this.resolutions_[n+1];else if(this.resolutions_[n]/this.resolutions_[n+1]!==e){e=void 0;break}}this.zoomFactor_=e,this.maxZoom=this.resolutions_.length-1,this.origin_=t.origin!==void 0?t.origin:null,this.origins_=null,t.origins!==void 0&&(this.origins_=t.origins,Q(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const i=t.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=Fi(i)),Q(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,t.tileSizes!==void 0&&(this.tileSizes_=t.tileSizes,Q(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=t.tileSize!==void 0?t.tileSize:this.tileSizes_?null:Wa,Q(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=i!==void 0?i:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],t.sizes!==void 0?this.fullTileRanges_=t.sizes.map((n,r)=>{const o=new Va(Math.min(0,n[0]),Math.max(n[0]-1,-1),Math.min(0,n[1]),Math.max(n[1]-1,-1));if(i){const a=this.getTileRangeForExtentAndZ(i,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(t,e,i){const n=this.getTileRangeForExtentAndZ(t,e);for(let r=n.minX,o=n.maxX;r<=o;++r)for(let a=n.minY,l=n.maxY;a<=l;++a)i([e,r,a])}forEachTileCoordParentTileRange(t,e,i,n){let r,o,a,l=null,h=t[0]-1;for(this.zoomFactor_===2?(o=t[1],a=t[2]):l=this.getTileCoordExtent(t,n);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=Xi(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,h,i),e(h,r))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getOrigins(){return this.origins_}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]<this.maxZoom){if(this.zoomFactor_===2){const r=t[1]*2,o=t[2]*2;return Xi(r,r+1,o,o+1,e)}const n=this.getTileCoordExtent(t,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(n,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,i){if(e>this.maxZoom||e<this.minZoom)return null;const n=t[0],r=t[1],o=t[2];if(e===n)return Xi(r,o,r,o,i);if(this.zoomFactor_){const l=Math.pow(this.zoomFactor_,e-n),h=Math.floor(r*l),c=Math.floor(o*l);if(e<n)return Xi(h,h,c,c,i);const u=Math.floor(l*(r+1))-1,d=Math.floor(l*(o+1))-1;return Xi(h,u,c,d,i)}const a=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,e,i)}getTileRangeForExtentAndZ(t,e,i){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,Zi);const n=Zi[1],r=Zi[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,Zi);const o=Zi[1],a=Zi[2];return Xi(n,o,r,a,i)}getTileCoordCenter(t){const e=this.getOrigin(t[0]),i=this.getResolution(t[0]),n=Zt(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*n[0]*i,e[1]-(t[2]+.5)*n[1]*i]}getTileCoordExtent(t,e){const i=this.getOrigin(t[0]),n=this.getResolution(t[0]),r=Zt(this.getTileSize(t[0]),this.tmpSize_),o=i[0]+t[1]*r[0]*n,a=i[1]-(t[2]+1)*r[1]*n,l=o+r[0]*n,h=a+r[1]*n;return ti(o,a,l,h,e)}getTileCoordForCoordAndResolution(t,e,i){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,i)}getTileCoordForXYAndResolution_(t,e,i,n,r){const o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),h=Zt(this.getTileSize(o),this.tmpSize_);let c=a*(t-l[0])/i/h[0],u=a*(l[1]-e)/i/h[1];return n?(c=bs(c,li)-1,u=bs(u,li)-1):(c=Rs(c,li),u=Rs(u,li)),gr(o,c,u,r)}getTileCoordForXYAndZ_(t,e,i,n,r){const o=this.getOrigin(i),a=this.getResolution(i),l=Zt(this.getTileSize(i),this.tmpSize_);let h=(t-o[0])/a/l[0],c=(o[1]-e)/a/l[1];return n?(h=bs(h,li)-1,c=bs(c,li)-1):(h=Rs(h,li),c=Rs(c,li)),gr(i,h,c,r)}getTileCoordForCoordAndZ(t,e,i){return this.getTileCoordForXYAndZ_(t[0],t[1],e,!1,i)}getTileCoordResolution(t){return this.resolutions_[t[0]]}getTileSize(t){return this.tileSize_?this.tileSize_:this.tileSizes_[t]}getFullTileRange(t){return this.fullTileRanges_?this.fullTileRanges_[t]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,t):null}getZForResolution(t,e){const i=aa(this.resolutions_,t,e||0);return pt(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return Gc(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){const e=this.resolutions_.length,i=new Array(e);for(let n=this.minZoom;n<e;++n)i[n]=this.getTileRangeForExtentAndZ(t,n);this.fullTileRanges_=i}}function lu(s){let t=s.getDefaultTileGrid();return t||(t=H_(s),s.setDefaultTileGrid(t)),t}function V_(s,t,e){const i=t[0],n=s.getTileCoordCenter(t),r=rl(e);if(!un(r,n)){const o=at(r),a=Math.ceil((r[0]-n[0])/o);return n[0]+=o*a,s.getTileCoordForCoordAndZ(n,i)}return t}function Y_(s,t,e,i){i=i!==void 0?i:"top-left";const n=hu(s,t,e);return new au({extent:s,origin:zu(s,i),resolutions:n,tileSize:e})}function Z_(s){const t=s||{},e=t.extent||Ct("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:hu(e,t.maxZoom,t.tileSize,t.maxResolution)};return new au(i)}function hu(s,t,e,i){t=t!==void 0?t:Kg,e=Zt(e!==void 0?e:Wa);const n=Yt(s),r=at(s);i=i>0?i:Math.max(r/e[0],n/e[1]);const o=t+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function H_(s,t,e,i){const n=rl(s);return Y_(n,t,e,i)}function rl(s){s=Ct(s);let t=s.getExtent();if(!t){const e=180*fa.degrees/s.getMetersPerUnit();t=ti(-e,-e,e,e)}return t}const K_=/\{z\}/g,q_=/\{x\}/g,J_=/\{y\}/g,Q_=/\{-y\}/g;function tm(s,t,e,i,n){return s.replace(K_,t.toString()).replace(q_,e.toString()).replace(J_,i.toString()).replace(Q_,function(){if(n===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(n-i).toString()})}function em(s){const t=[];let e=/\{([a-z])-([a-z])\}/.exec(s);if(e){const i=e[1].charCodeAt(0),n=e[2].charCodeAt(0);let r;for(r=i;r<=n;++r)t.push(s.replace(e[0],String.fromCharCode(r)));return t}if(e=/\{(\d+)-(\d+)\}/.exec(s),e){const i=parseInt(e[2],10);for(let n=parseInt(e[1],10);n<=i;n++)t.push(s.replace(e[0],n.toString()));return t}return t.push(s),t}function im(s,t){return(function(e,i,n){if(!e)return;let r;const o=e[0];if(t){const a=t.getFullTileRange(o);a&&(r=a.getHeight()-1)}return tm(s,o,e[1],e[2],r)})}function nm(s,t){const e=s.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=im(s[n],t);return sm(i)}function sm(s){return s.length===1?s[0]:(function(t,e,i){if(!t)return;const n=Ap(t),r=Ii(n,s.length);return s[r](t,e,i)})}class rm extends Xc{constructor(t){super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:t.projection,state:t.state,wrapX:t.wrapX,interpolate:t.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=t.tilePixelRatio!==void 0?t.tilePixelRatio:1,this.tileGrid=t.tileGrid!==void 0?t.tileGrid:null;const e=[256,256];this.tileGrid&&Zt(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||$(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){const e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,n,r,o){return X()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:lu(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const n=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),o=Zt(n.getTileSize(t),this.tmpSize);return r==1?o:Sf(o,r,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){const i=e!==void 0?e:this.getProjection(),n=e!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(t=V_(n,t,i)),kp(t,n)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class om extends $e{constructor(t,e){super(t),this.tile=e}}const bo={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class ol extends rm{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===ol.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,i=$(e),n=e.getState();let r;n==z.LOADING?(this.tileLoadingKeys_[i]=!0,r=bo.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==z.ERROR?bo.TILELOADERROR:n==z.LOADED?bo.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new om(r,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,typeof e<"u"?this.setKey(e):this.changed()}setUrl(t){const e=em(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join(`
|
|
697
|
+
`);this.generateTileUrlFunction_?this.setTileUrlFunction(nm(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}}class am extends ol{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:lm,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate!==void 0?t.interpolate:!0,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=t.crossOrigin!==void 0?t.crossOrigin:null,this.referrerPolicy=t.referrerPolicy,this.tileClass=t.tileClass!==void 0?t.tileClass:Hc,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!Un(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||Un(e,t)))return this.tileGrid;const i=$(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=lu(t)),this.tileGridForProjection[i]}createTile_(t,e,i,n,r,o){const a=[t,e,i],l=this.getTileCoordForTileUrlFunction(a,r),h=l?this.tileUrlFunction(l,n,r):void 0,c=new this.tileClass(a,h!==void 0?z.IDLE:z.EMPTY,h!==void 0?h:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(j.CHANGE,this.handleTileChange.bind(this)),c}getTile(t,e,i,n,r,o){const a=this.getProjection();if(!a||!r||Un(a,r))return this.getTileInternal(t,e,i,n,a||r);const l=[t,e,i],h=this.getKey(),c=this.getTileGridForProjection(a),u=this.getTileGridForProjection(r),d=this.getTileCoordForTileUrlFunction(l,r),f=new Kc(a,c,r,u,l,d,this.getTilePixelRatio(n),this.getGutter(),(g,_,p,m)=>this.getTileInternal(g,_,p,m,a,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return f.key=h,f}getTileInternal(t,e,i,n,r,o){const a=this.getKey(),l=Hs(this,a,t,e,i);if(o&&o.containsKey(l))return o.get(l);const h=this.createTile_(t,e,i,n,r,a);return o?.set(l,h),h}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const i=Ct(t);if(i){const n=$(i);n in this.tileGridForProjection||(this.tileGridForProjection[n]=e)}}}function lm(s,t){if(le){const e=s.getCrossOrigin();let i="same-origin",n="same-origin";e==="anonymous"||e===""?(i="cors",n="omit"):e==="use-credentials"&&(i="cors",n="include");const r={mode:i,credentials:n,referrerPolicy:s.getReferrerPolicy()};fetch(t,r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.blob()}).then(o=>createImageBitmap(o)).then(o=>{const a=s.getImage();a.width=o.width,a.height=o.height,a.getContext("2d").drawImage(o,0,0),o.close?.(),a.dispatchEvent(new Event("load"))}).catch(()=>{s.getImage().dispatchEvent(new Event("error"))});return}s.getImage().src=t}class al extends am{constructor(t){t=t||{};const e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:Z_({extent:rl(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,referrerPolicy:t.referrerPolicy,interpolate:t.interpolate,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX!==void 0?t.wrapX:!0,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=t.gutter!==void 0?t.gutter:0}getGutter(){return this.gutter_}}class hm extends Ut{constructor(t,e,i){super(t,e,nt.TILE,{...i,zIndex:i?.zIndex??0}),this.tileLayer=null,this.urlTemplate=i.urlTemplate,this.subDomains=i.subDomains||["a","b","c"],this.attribution=i.attribution||"",this.minZoom=i.minZoom||0,this.maxZoom=i.maxZoom||19}createLayer(t){let e=this.urlTemplate;const i=this.subDomains[Math.floor(Math.random()*this.subDomains.length)];return e=e.replace(/\{s\}/g,i),this.tileLayer=new ou({source:new al({url:e,attributions:this.attribution,minZoom:this.minZoom,maxZoom:this.maxZoom}),properties:{id:this.id,name:this.name,type:nt.TILE},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex}),this.layer=this.tileLayer,t.addLayer(this.tileLayer),this.tileLayer}updateData(t){if(t.urlTemplate&&(this.urlTemplate=t.urlTemplate,this.tileLayer)){const e=this.tileLayer.getSource();e&&e.setUrl(this.urlTemplate)}}getLayer(){return this.tileLayer}destroy(){if(this.tileLayer){const t=typeof this.tileLayer.getMap=="function"?this.tileLayer.getMap():null;t&&typeof t.removeLayer=="function"&&t.removeLayer(this.tileLayer),typeof this.tileLayer.dispose=="function"&&this.tileLayer.dispose(),this.tileLayer=null}super.destroy()}}class Qi extends $e{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}}class Ye extends Qi{constructor(t,e,i,n,r,o){super(t,e,r),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=n!==void 0?n:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const rt={SINGLECLICK:"singleclick",CLICK:j.CLICK,DBLCLICK:j.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};function ea(s){const t=arguments;return function(e){let i=!0;for(let n=0,r=t.length;n<r&&(i=i&&t[n](e),!!i);++n);return i}}const cm=function(s){const t=s.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},um=function(s){const t=s.map.getTargetElement(),e=t.getRootNode(),i=s.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},cu=function(s){const t=s.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?um(s):!0},Qs=cn,uu=function(s){const t=s.originalEvent;return"pointerId"in t&&t.button==0&&!(Dd&&ic&&t.ctrlKey)},dm=xn,ll=function(s){const t=s.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},fm=function(s){const t=s.originalEvent;return ic?t.metaKey:t.ctrlKey},ia=function(s){const t=s.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},du=function(s){const t=s.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},Po=function(s){const t=s.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"},gm=function(s){const t=s.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0},na={ACTIVE:"active"};class ms extends Te{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(na.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(na.ACTIVE,t)}setMap(t){this.map_=t}}function pm(s,t,e){const i=s.getCenterInternal();if(i){const n=[i[0]+t[0],i[1]+t[1]];s.animateInternal({duration:e!==void 0?e:250,easing:Ng,center:s.getConstrainedCenter(n)})}}function hl(s,t,e,i){const n=s.getZoom();if(n===void 0)return;const r=s.getConstrainedZoom(n+t),o=s.getResolutionForZoom(r);s.getAnimating()&&s.cancelAnimations(),s.animate({resolution:o,anchor:e,duration:i!==void 0?i:250,easing:Cn})}class Gi extends ms{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==rt.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==rt.POINTERUP){const i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==rt.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==rt.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}}function cl(s){const t=s.length;let e=0,i=0;for(let n=0;n<t;n++)e+=s[n].clientX,i+=s[n].clientY;return{clientX:e/t,clientY:i/t}}function sn(s,t){const e=s.length;return t<0?s[t+e]:t>=e?s[t-e]:s[t]}function rn(s,t){const e=s.length;let i=Math.floor(t);const n=t-i;i>=e?i-=e:i<0&&(i+=e);let r=i+1;r>=e&&(r-=e);const o=s[i],a=o[0],l=o[1],h=s[r],c=h[0]-a,u=h[1]-l;return[a+c*n,l+u*n]}const Ws={index:-1,endIndex:NaN,closestTargetDistance:1/0};function _m(s,t,e,i){const n=s[0],r=s[1];let o=1/0,a=-1,l=NaN;for(let u=0;u<t.targets.length;++u){const d=t.targets[u],f=d.coordinates;let g=1/0,_;for(let p=0;p<f.length-1;++p){const m=f[p],y=f[p+1],C=gu(n,r,m,y);C.squaredDistance<g&&(g=C.squaredDistance,_=p+C.along)}g<o&&(o=g,d.ring&&t.targetIndex===u&&(d.endIndex>d.startIndex?_<d.startIndex&&(_+=f.length):d.endIndex<d.startIndex&&_>d.startIndex&&(_-=f.length)),l=_,a=u)}const h=t.targets[a];let c=h.ring;if(t.targetIndex===a&&c){const u=rn(h.coordinates,l),d=e.getPixelFromCoordinate(u),f=e.getPixelFromCoordinate(t.startCoord);$h(d,f)>i&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(f<g){const _=js(u,f,g);js(u,f,g-d)<_&&(l-=d)}else{const _=js(u,f,g);js(u,f,g+d)<_&&(l+=d)}}return Ws.index=a,Ws.endIndex=l,Ws.closestTargetDistance=o,Ws}function mm(s,t){const e=[];for(let i=0;i<t.length;++i){const r=t[i].getGeometry();fu(s,r,e)}return e}function fu(s,t,e){if(t instanceof fe){Us(s,t.getCoordinates(),!1,e);return}if(t instanceof _n){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n)Us(s,i[n],!1,e);return}if(t instanceof ht){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n)Us(s,i[n],!0,e);return}if(t instanceof mn){const i=t.getCoordinates();for(let n=0,r=i.length;n<r;++n){const o=i[n];for(let a=0,l=o.length;a<l;++a)Us(s,o[a],!0,e)}return}if(t instanceof ss){const i=t.getGeometries();for(let n=0;n<i.length;++n)fu(s,i[n],e);return}}function Us(s,t,e,i){const n=s[0],r=s[1];for(let o=0,a=t.length-1;o<a;++o){const l=t[o],h=t[o+1],c=gu(n,r,l,h);if(c.squaredDistance===0){const u=o+c.along;i.push({coordinates:t,ring:e,startIndex:u,endIndex:u});return}}}function Xs(s,t){return qe(s[0],s[1],t[0],t[1])}function js(s,t,e){let i,n;t<e?(i=t,n=e):(i=e,n=t);const r=Math.ceil(i),o=Math.floor(n);if(r>o){const l=rn(s,i),h=rn(s,n);return Xs(l,h)}let a=0;if(i<r){const l=rn(s,i),h=sn(s,r);a+=Xs(l,h)}if(o<n){const l=sn(s,o),h=rn(s,n);a+=Xs(l,h)}for(let l=r;l<o-1;++l){const h=sn(s,l),c=sn(s,l+1);a+=Xs(h,c)}return a}const Lo={along:0,squaredDistance:0};function gu(s,t,e,i){const n=e[0],r=e[1],o=i[0],a=i[1],l=o-n,h=a-r;let c=0,u=n,d=r;return(l!==0||h!==0)&&(c=pt(((s-n)*l+(t-r)*h)/(l*l+h*h),0,1),u+=l*c,d+=h*c),Lo.along=c,Lo.squaredDistance=hs(qe(s,t,u,d),10),Lo}const Vs={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class Ys extends $e{constructor(t,e){super(t),this.feature=e}}class ys extends Gi{constructor(t){const e=t;e.stopDown||(e.stopDown=xn),super(e),this.on,this.once,this.un,this.options_=t,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=t.source?t.source:null,this.features_=t.features?t.features:null,this.snapTolerance_=t.snapTolerance?t.snapTolerance:12,this.type_=t.type,this.mode_=xm(this.type_),this.stopClick_=!!t.stopClick,this.ignoreNextUpEvent_=!1,this.minPoints_=t.minPoints?t.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:t.maxPoints?t.maxPoints:1/0,this.finishCondition_=t.finishCondition?t.finishCondition:cn,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let i=t.geometryFunction;if(!i){const n=this.mode_;if(n==="Circle")i=(r,o,a)=>{const l=o||new Ee([NaN,NaN]),h=ye(r[0]),c=zh(h,ye(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;n==="Point"?r=gt:n==="LineString"?r=fe:n==="Polygon"&&(r=ht),i=(o,a,l)=>(a?n==="Polygon"?o[0].length?a.setCoordinates([o[0].concat([o[0][0]])],this.geometryLayout_):a.setCoordinates([],this.geometryLayout_):a.setCoordinates(o,this.geometryLayout_):a=new r(o,this.geometryLayout_),a)}}this.geometryFunction_=i,this.dragVertexDelay_=t.dragVertexDelay!==void 0?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new Ht({source:new St({useSpatialIndex:!1,wrapX:t.wrapX?t.wrapX:!1}),style:t.style?t.style:ym(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:ll,this.freehandCondition_,t.freehand?this.freehandCondition_=Qs:this.freehandCondition_=t.freehandCondition?t.freehandCondition:ia,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(na.ACTIVE,this.updateState_)}setTrace(t){let e;t?t===!0?e=Qs:e=t:e=dm,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=Qs:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:ia}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(t){t.originalEvent.type===j.CONTEXTMENU&&t.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(t);let e=t.type===rt.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&t.type===rt.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&t.type===rt.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===rt.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===rt.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):(t.originalEvent.pointerType==="mouse"||t.type===rt.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(t)):t.type===rt.DBLCLICK&&(i=!1),super.handleEvent(t)&&i}handleDownEvent(t){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=t.pixel,this.finishCoordinate_||this.startDrawing_(t.coordinate),!0):this.condition_(t)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new Ye(rt.POINTERMOVE,t.map,t.originalEvent,!1,t.frameState))},this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active){this.deactivateTrace_();return}const e=this.getMap(),i=e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),n=e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_]),r=er([i,n]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=mm(t.coordinate,o);a.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const i=t.startIndex<=t.endIndex,n=t.startIndex<=e;i===n?i&&e>t.endIndex||!i&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(i&&e<t.endIndex||!i&&e>t.endIndex)&&this.removeTracedCoordinates_(e,t.endIndex):(this.removeTracedCoordinates_(t.startIndex,t.endIndex),this.addTracedCoordinates_(t,t.startIndex,e))}removeTracedCoordinates_(t,e){if(t===e)return;let i=0;if(t<e){const n=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),i=r-n+1}else{const n=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),i=n-r+1}i>0&&this.removeLastPoints_(i)}addTracedCoordinates_(t,e,i){if(e===i)return;const n=[];if(e<i){const r=Math.ceil(e);let o=Math.floor(i);o===i&&(o-=1);for(let a=r;a<=o;++a)n.push(sn(t.coordinates,a))}else{const r=Math.floor(e);let o=Math.ceil(i);o===i&&(o+=1);for(let a=r;a>=o;--a)n.push(sn(t.coordinates,a))}n.length&&this.appendCoordinates(n)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(e.targetIndex===-1){const a=t.map.getPixelFromCoordinate(e.startCoord);if($h(a,t.pixel)<this.snapTolerance_)return}const i=_m(t.coordinate,e,this.getMap(),this.snapTolerance_);if(e.targetIndex!==i.index){if(e.targetIndex!==-1){const l=e.targets[e.targetIndex];this.removeTracedCoordinates_(l.startIndex,l.endIndex)}const a=e.targets[i.index];this.addTracedCoordinates_(a,a.startIndex,i.endIndex)}else{const a=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(a,i.endIndex)}e.targetIndex=i.index;const n=e.targets[e.targetIndex];n.endIndex=i.endIndex;const r=rn(n.coordinates,n.endIndex),o=this.getMap().getPixelFromCoordinate(r);t.coordinate=r,t.pixel=[Math.round(o[0]),Math.round(o[1])]}handleDragEvent(t){this.ignoreNextUpEvent_=!0,super.handleDragEvent(t)}handleUpEvent(t){let e=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(t);const i=this.traceState_.active;if(this.ignoreNextUpEvent_||this.toggleTraceState_(t),this.shouldHandle_){const n=!this.finishCoordinate_;n&&this.startDrawing_(t.coordinate),!n&&this.freehand_?this.finishDrawing():!this.freehand_&&(!n||this.mode_==="Point")&&(this.atFinish_(t.pixel,i)?this.finishCondition_(t)&&this.finishDrawing():this.addToDrawing_(t.coordinate)),e=!1}else this.freehand_&&this.abortDrawing()}return this.ignoreNextUpEvent_=!1,!e&&this.stopClick_&&t.preventDefault(),e}handlePointerMove_(t){if(this.pointerType_=t.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const e=this.downPx_,i=t.pixel,n=e[0]-i[0],r=e[1]-i[1],o=n*n+r*r;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(t.coordinate.slice());return}this.updateTrace_(t),this.modifyDrawing_(t.coordinate)}atFinish_(t,e){let i=!1;if(this.sketchFeature_){let n=!1,r=[this.finishCoordinate_];const o=this.mode_;if(o==="Point")i=!0;else if(o==="Circle")i=this.sketchCoords_.length===2;else if(o==="LineString")n=!e&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){const a=this.sketchCoords_;n=a[0].length>this.minPoints_,r=[a[0][0],a[0][a[0].length-2]],e?r=[a[0][0]]:r=[a[0][0],a[0][a[0].length-2]]}if(n){const a=this.getMap();for(let l=0,h=r.length;l<h;l++){const c=r[l],u=a.getPixelFromCoordinate(c),d=t[0]-u[0],f=t[1]-u[1],g=this.freehand_?1:this.snapTolerance_;if(i=Math.sqrt(d*d+f*f)<=g,i){this.finishCoordinate_=c;break}}}}return i}createOrUpdateSketchPoint_(t){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(t):(this.sketchPoint_=new ot(new gt(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new ot);const e=t.getLinearRing(0);let i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),i.changed()):(i=new fe(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(t){const e=this.getMap().getView().getProjection(),i=rr(this.geometryLayout_);for(;t.length<i;)t.push(0);this.finishCoordinate_=t,this.mode_==="Point"?this.sketchCoords_=t.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[t.slice(),t.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[t.slice(),t.slice()],this.sketchLineCoords_&&(this.sketchLine_=new ot(new fe(this.sketchLineCoords_)));const n=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new ot,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(n),this.updateSketchFeatures_(),this.dispatchEvent(new Ys(Vs.DRAWSTART,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),i=this.sketchFeature_.getGeometry(),n=e.getView().getProjection(),r=rr(this.geometryLayout_);let o,a;for(;t.length<r;)t.push(0);this.mode_==="Point"?a=this.sketchCoords_:this.mode_==="Polygon"?(o=this.sketchCoords_[0],a=o[o.length-1],this.atFinish_(e.getPixelFromCoordinate(t))&&(t=this.finishCoordinate_.slice())):(o=this.sketchCoords_,a=o[o.length-1]),a[0]=t[0],a[1]=t[1],this.geometryFunction_(this.sketchCoords_,i,n),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(t),i.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(i):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(t){const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection();let n,r;const o=this.mode_;return o==="LineString"||o==="Circle"?(this.finishCoordinate_=t.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),this.geometryFunction_(r,e,i)):o==="Polygon"&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),n&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,i)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),n?this.finishDrawing():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),n=this.mode_;for(let r=0;r<t;++r){let o;if(n==="LineString"||n==="Circle"){if(o=this.sketchCoords_,o.splice(-2,1),o.length>=2){this.finishCoordinate_=o[o.length-2].slice();const a=this.finishCoordinate_.slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}this.geometryFunction_(o,e,i),e.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if(n==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);const a=this.sketchLine_.getGeometry();if(o.length>=2){const l=o[o.length-2].slice();o[o.length-1]=l,this.createOrUpdateSketchPoint_(l)}a.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,e,i)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return null;let e=this.sketchCoords_;const i=t.getGeometry(),n=this.getMap().getView().getProjection();return this.mode_==="LineString"?(e.pop(),this.geometryFunction_(e,i,n)):this.mode_==="Polygon"&&(e[0].pop(),this.geometryFunction_(e,i,n),e=i.getCoordinates()),this.type_==="MultiPoint"?t.setGeometry(new ps([e])):this.type_==="MultiLineString"?t.setGeometry(new _n([e])):this.type_==="MultiPolygon"&&t.setGeometry(new mn([e])),this.dispatchEvent(new Ys(Vs.DRAWEND,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t),t}abortDrawing_(){this.finishCoordinate_=null;const t=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),t}abortDrawing(){const t=this.abortDrawing_();t&&this.dispatchEvent(new Ys(Vs.DRAWABORT,t))}appendCoordinates(t){const e=this.mode_,i=!this.sketchFeature_;i&&this.startDrawing_(t[0]);let n;if(e==="LineString"||e==="Circle")n=this.sketchCoords_;else if(e==="Polygon")n=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;i&&n.shift(),n.pop();for(let o=0;o<t.length;o++)this.addToDrawing_(t[o]);const r=t[t.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(t){const i=t.getGeometry();this.sketchFeature_=t,this.sketchCoords_=i.getCoordinates();const n=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=n.slice(),this.sketchCoords_.push(n.slice()),this.sketchPoint_=new ot(new gt(n)),this.updateSketchFeatures_(),this.dispatchEvent(new Ys(Vs.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){const t=[];this.sketchFeature_&&t.push(this.sketchFeature_),this.sketchLine_&&t.push(this.sketchLine_),this.sketchPoint_&&t.push(this.sketchPoint_);const e=this.overlay_.getSource();e.clear(!0),e.addFeatures(t)}updateState_(){const t=this.getMap(),e=this.getActive();(!t||!e)&&this.abortDrawing(),this.overlay_.setMap(e?t:null)}}function ym(){const s=Eg();return function(t,e){return s[t.getGeometry().getType()]}}function xm(s){switch(s){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+s)}}const sa={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class Em extends Er{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=e===void 0?1:e,this.down_=null;const i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=H(i,sa.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=H(i,sa.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(j.TOUCHMOVE,this.boundHandleTouchMove_,sc?{passive:!1}:!1)}emulateClick_(t){let e=new Ye(rt.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new Ye(rt.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new Ye(rt.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==rt.POINTERUP||e.type==rt.POINTERCANCEL){delete this.trackedTouches_[i];for(const n in this.trackedTouches_)if(this.trackedTouches_[n].target!==e.target){delete this.trackedTouches_[n];break}}else(e.type==rt.POINTERDOWN||e.type==rt.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new Ye(rt.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(dt),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return t.button===0}handlePointerDown_(t){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(t);const e=new Ye(rt.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(H(i,rt.POINTERMOVE,this.handlePointerMove_,this),H(i,rt.POINTERUP,this.handlePointerUp_,this),H(this.element_,rt.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(H(this.element_.getRootNode(),rt.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new Ye(rt.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!!(this.down_&&this.isMoving_(t));this.dispatchEvent(new Ye(rt.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;(!e||e.defaultPrevented)&&(typeof t.cancelable!="boolean"||t.cancelable===!0)&&t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(dt(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(j.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(dt(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(dt),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const ci={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},$t={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},mr=1/0;class vm{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,yn(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,i=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const n=this.keyFunction_(i);return delete this.queuedElements_[n],i}enqueue(t){Q(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=mr?(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(t){return t*2+1}getRightChildIndex_(t){return t*2+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return this.elements_.length===0}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,i=this.priorities_,n=e.length,r=e[t],o=i[t],a=t;for(;t<n>>1;){const l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=h<n&&i[h]<i[l]?h:l;e[t]=e[c],i[t]=i[c],t=c}e[t]=r,i[t]=o,this.siftDown_(a,t)}siftDown_(t,e){const i=this.elements_,n=this.priorities_,r=i[e],o=n[e];for(;e>t;){const a=this.getParentIndex_(e);if(n[a]>o)i[e]=i[a],n[e]=n[a],e=a;else break}i[e]=r,n[e]=o}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let n=0;const r=e.length;let o,a,l;for(a=0;a<r;++a)o=e[a],l=t(o),l==mr?delete this.queuedElements_[this.keyFunction_(o)]:(i[n]=l,e[n++]=o);e.length=n,i.length=n,this.heapify_()}}class Cm extends vm{constructor(t,e){super(i=>t.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);return e&&t[0].addEventListener(j.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===z.LOADED||i===z.ERROR||i===z.EMPTY){i!==z.ERROR&&e.removeEventListener(j.CHANGE,this.boundHandleTileChange_);const n=e.getKey();n in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[n],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){const n=this.dequeue()[0],r=n.getKey();n.getState()===z.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,n.load())}}}function wm(s,t,e,i,n){if(!s||!(e in s.wantedTiles)||!s.wantedTiles[e][t.getKey()])return mr;const r=s.viewState.center,o=i[0]-r[0],a=i[1]-r[1];return 65536*Math.log(n)+Math.sqrt(o*o+a*a)/n}class ul extends Te{constructor(t){super();const e=t.element;e&&!t.target&&!e.style.pointerEvents&&(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let e=0,i=this.listenerKeys.length;e<i;++e)dt(this.listenerKeys[e]);if(this.listenerKeys.length=0,this.map_=t,t){const e=this.target_??t.getOverlayContainerStopEvent();this.element&&e.appendChild(this.element),this.render!==Yn&&this.listenerKeys.push(H(t,ci.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}}class Tm extends ul{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=t.collapsed!==void 0?t.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=t.collapsible!==void 0,this.collapsible_=t.collapsible!==void 0?t.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;const e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",n=t.expandClassName!==void 0?t.expandClassName:e+"-expand",r=t.collapseLabel!==void 0?t.collapseLabel:"›",o=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=n):this.label_=a;const l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(j.CLICK,this.handleClick_.bind(this),!1);const h=e+" "+Ir+" "+Sa+(this.collapsed_&&this.collapsible_?" "+Ol:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){const e=this.getMap().getAllLayers(),i=new Set(e.flatMap(n=>n.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(n=>i.add(n)):i.add(this.attributions_)),!this.overrideCollapsible_){const n=!e.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(n)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const e=await Promise.all(this.collectSourceAttributions_(t).map(n=>Fu(()=>n))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!ei(e,this.renderedAttributions_)){Fd(this.ulElement_);for(let n=0,r=e.length;n<r;++n){const o=document.createElement("li");o.innerHTML=e[n],this.ulElement_.appendChild(o)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(Ol),this.collapsed_?kl(this.collapseLabel_,this.label_):kl(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,!(!this.collapsible_||this.collapsed_===t)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}}class Sm extends ul{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});const e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"⇧",n=t.compassClassName!==void 0?t.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=n,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(n));const r=t.tipLabel?t.tipLabel:"Reset rotation",o=document.createElement("button");o.className=e+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(j.CLICK,this.handleClick_.bind(this),!1);const a=e+" "+Ir+" "+Sa,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(Ms)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const e=this.getMap().getView();if(!e)return;const i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:Cn}):e.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const n="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(Ms);!r&&i===0?this.element.classList.add(Ms):r&&i!==0&&this.element.classList.remove(Ms)}this.label_.style.transform=n}this.rotation_=i}}class Rm extends ul{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,n=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",r=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",o=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"–",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",h=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=n,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(j.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(j.CLICK,this.handleClick_.bind(this,-i),!1);const d=e+" "+Ir+" "+Sa,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const i=this.getMap().getView();if(!i)return;const n=i.getZoom();if(n!==void 0){const r=i.getConstrainedZoom(n+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:Cn})):i.setZoom(r)}}}function bm(s){s=s||{};const t=new Qt;return(s.zoom===void 0||s.zoom)&&t.push(new Rm(s.zoomOptions)),(s.rotate===void 0||s.rotate)&&t.push(new Sm(s.rotateOptions)),(s.attribution===void 0||s.attribution)&&t.push(new Tm(s.attributionOptions)),t}class Pm{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;const n=this.points_[e+2]-this.points_[i+2];if(n<1e3/60)return!1;const r=this.points_[e]-this.points_[i],o=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/n,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}class Lm extends ms{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:250}handleEvent(t){let e=!1;if(t.type==rt.DBLCLICK){const i=t.originalEvent,n=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=n.getView();hl(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}class Im extends Gi{constructor(t){super({stopDown:xn}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:ea(ll,gm);this.condition_=t.onFocusOnly?ea(cu,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const i=this.targetPointers,n=e.getEventPixel(cl(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(n[0],n[1]),this.lastCentroid){const r=[this.lastCentroid[0]-n[0],n[1]-this.lastCentroid[1]],a=t.map.getView();Gh(r,a.getResolution()),da(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=n,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const n=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-n*Math.cos(r),a[1]-n*Math.sin(r)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:Cn})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){const i=t.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class Mm extends Gi{constructor(t){t=t||{},super({stopDown:xn}),this.condition_=t.condition?t.condition:cm,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Po(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===Ba)return;const n=e.getSize(),r=t.pixel,o=Math.atan2(n[1]/2-r[1],r[0]-n[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(t){return Po(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Po(t)&&uu(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class Am extends rs{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,i="px",n=this.element_.style;n.left=Math.min(t[0],e[0])+i,n.top=Math.min(t[1],e[1])+i,n.width=Math.abs(e[0]-t[0])+i,n.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const e=this.element_.style;e.left="inherit",e.top="inherit",e.width="inherit",e.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const t=this.startPixel_,e=this.endPixel_,n=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);n[4]=n[0].slice(),this.geometry_?this.geometry_.setCoordinates([n]):this.geometry_=new ht([n])}getGeometry(){return this.geometry_}}const Hi={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class Fn extends $e{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class Dm extends Gi{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new Am(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??uu,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const n=i[0]-e[0],r=i[1]-e[1];return n*n+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new Fn(Hi.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new Fn(e?Hi.BOXEND:Hi.BOXCANCEL,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return this.condition_(t)?(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new Fn(Hi.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Fn(Hi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Fn(Hi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class km extends Dm{constructor(t){t=t||{};const e=t.condition?t.condition:ia;super({condition:e,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=t.duration!==void 0?t.duration:200,this.out_=t.out!==void 0?t.out:!1}onBoxEnd(t){const i=this.getMap().getView();let n=this.getGeometry();if(this.out_){const r=i.rotatedExtentForGeometry(n),o=i.getResolutionForExtentInternal(r),a=i.getResolution()/o;n=n.clone(),n.scale(a*a)}i.fitInternal(n,{duration:this.duration_,easing:Cn})}}const vi={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class Fm extends ms{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return ll(e)&&du(e)},this.condition_=t.condition!==void 0?t.condition:this.defaultCondition_,this.duration_=t.duration!==void 0?t.duration:100,this.pixelDelta_=t.pixelDelta!==void 0?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==j.KEYDOWN){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==vi.DOWN||n==vi.LEFT||n==vi.RIGHT||n==vi.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;n==vi.DOWN?h=-a:n==vi.LEFT?l=-a:n==vi.RIGHT?l=a:h=a;const c=[l,h];da(c,o.getRotation()),pm(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}}class Om extends ms{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!fm(e)&&du(e)},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:100}handleEvent(t){let e=!1;if(t.type==j.KEYDOWN||t.type==j.KEYPRESS){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==="+"||n==="-")){const r=t.map,o=n==="+"?this.delta_:-this.delta_,a=r.getView();hl(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}const Nm=40,Gm=300,zm=3;class $m extends ms{constructor(t){t=t||{},super(t),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=t.maxDelta!==void 0?t.maxDelta:1,this.duration_=t.duration!==void 0?t.duration:250,this.timeout_=t.timeout!==void 0?t.timeout:80,this.useAnchor_=t.useAnchor!==void 0?t.useAnchor:!0,this.constrainResolution_=t.constrainResolution!==void 0?t.constrainResolution:!1;const e=t.condition?t.condition:Qs;this.condition_=t.onFocusOnly?ea(cu,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300,this.ctrlKeyPressed_=!1,this.ctrlKeyListenerKeys_=[]}setMap(t){if(this.ctrlKeyListenerKeys_.forEach(dt),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(t),t){const e=t.getOwnerDocument();this.ctrlKeyListenerKeys_.push(H(e,"keydown",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!0)}),H(e,"keyup",i=>{i.key==="Control"&&(this.ctrlKeyPressed_=!1)}))}}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;const e=t.getView(),i=this.lastDelta_?this.lastDelta_>0?1:-1:0;e.endInteraction(this.constrainResolution_||e.getConstrainResolution()?100:void 0,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t)||t.type!==j.WHEEL)return!0;const i=t.map,n=t.originalEvent;n.preventDefault();const r=n.ctrlKey&&!this.ctrlKeyPressed_;n.ctrlKey||(this.ctrlKeyPressed_=!1),this.useAnchor_&&(this.lastAnchor_=t.pixel);let o=n.deltaY;switch(n.deltaMode){case WheelEvent.DOM_DELTA_LINE:o*=Nm;break;case WheelEvent.DOM_DELTA_PAGE:o*=Gm;break}if(o===0)return!1;this.lastDelta_=o;const a=Date.now();this.startTime_===void 0&&(this.startTime_=a),(!this.mode_||a-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(o)<4?"trackpad":"wheel");const l=i.getView();if(this.mode_==="trackpad")return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(l.getAnimating()&&l.cancelAnimations(),l.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),r&&(o=o*zm),l.adjustZoom(-o/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=a,!1;this.totalDelta_+=o;const h=Math.max(this.timeout_-(a-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),h),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-pt(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),hl(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}}class Bm extends Gi{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=xn),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=t.threshold!==void 0?t.threshold:.3,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){let e=0;const i=this.targetPointers[0],n=this.targetPointers[1],r=Math.atan2(n.clientY-i.clientY,n.clientX-i.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=l}this.lastAngle_=r;const o=t.map,a=o.getView();a.getConstraints().rotation!==Ba&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(cl(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return this.targetPointers.length<2?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}class Wm extends Gi{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=xn),super(e),this.anchor_=null,this.duration_=t.duration!==void 0?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1;const i=this.targetPointers[0],n=this.targetPointers[1],r=i.clientX-n.clientX,o=i.clientY-n.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(e=this.lastDistance_/a),this.lastDistance_=a;const l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(cl(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const i=t.map.getView(),n=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,n),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}function pu(s){s=s||{};const t=new Qt,e=new Pm(-.005,.05,100);return(s.altShiftDragRotate===void 0||s.altShiftDragRotate)&&t.push(new Mm),(s.doubleClickZoom===void 0||s.doubleClickZoom)&&t.push(new Lm({delta:s.zoomDelta,duration:s.zoomDuration})),(s.dragPan===void 0||s.dragPan)&&t.push(new Im({onFocusOnly:s.onFocusOnly,kinetic:e})),(s.pinchRotate===void 0||s.pinchRotate)&&t.push(new Bm),(s.pinchZoom===void 0||s.pinchZoom)&&t.push(new Wm({duration:s.zoomDuration})),(s.keyboard===void 0||s.keyboard)&&(t.push(new Fm),t.push(new Om({delta:s.zoomDelta,duration:s.zoomDuration}))),(s.mouseWheelZoom===void 0||s.mouseWheelZoom)&&t.push(new $m({onFocusOnly:s.onFocusOnly,duration:s.zoomDuration})),(s.shiftDragZoom===void 0||s.shiftDragZoom)&&t.push(new km({duration:s.zoomDuration})),t}const hi={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class ui extends $e{constructor(t,e){super(t),this.layer=e}}const Io={LAYERS:"layers"};class wn extends Wc{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Io.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new Qt(i.slice(),{unique:!0}):Q(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new Qt(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(dt),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(H(t,qt.ADD,this.handleLayersAdd_,this),H(t,qt.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(dt);yn(this.listenerKeys_);const e=t.getArray();for(let i=0,n=e.length;i<n;i++){const r=e[i];this.registerLayerListeners_(r),this.dispatchEvent(new ui(hi.ADDLAYER,r))}this.changed()}registerLayerListeners_(t){const e=[H(t,hn.PROPERTYCHANGE,this.handleLayerChange_,this),H(t,j.CHANGE,this.handleLayerChange_,this)];t instanceof wn&&e.push(H(t,hi.ADDLAYER,this.handleLayerGroupAdd_,this),H(t,hi.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[$(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new ui(hi.ADDLAYER,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new ui(hi.REMOVELAYER,t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new ui(hi.ADDLAYER,e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=$(e);this.listenerKeys_[i].forEach(dt),delete this.listenerKeys_[i],this.dispatchEvent(new ui(hi.REMOVELAYER,e)),this.changed()}getLayers(){return this.get(Io.LAYERS)}setLayers(t){const e=this.getLayers();if(e){const i=e.getArray();for(let n=0,r=i.length;n<r;++n)this.dispatchEvent(new ui(hi.REMOVELAYER,i[n]))}this.set(Io.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){const e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(e)});const n=this.getLayerState();let r=n.zIndex;!t&&n.zIndex===void 0&&(r=0);for(let o=i,a=e.length;o<a;o++){const l=e[o];l.opacity*=n.opacity,l.visible=l.visible&&n.visible,l.maxResolution=Math.min(l.maxResolution,n.maxResolution),l.minResolution=Math.max(l.minResolution,n.minResolution),l.minZoom=Math.max(l.minZoom,n.minZoom),l.maxZoom=Math.min(l.maxZoom,n.maxZoom),n.extent!==void 0&&(l.extent!==void 0?l.extent=Li(l.extent,n.extent):l.extent=n.extent),l.zIndex===void 0&&(l.zIndex=r)}return e}getSourceState(){return"ready"}}class Um extends rs{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){X()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,n=t.pixelToCoordinateTransform;ge(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),br(n,i)}forEachFeatureAtCoordinate(t,e,i,n,r,o,a,l){let h;const c=e.viewState;function u(x,E,S,w){return r.call(o,E,x?S:null,w)}const d=c.projection,f=Bh(t.slice(),d),g=[[0,0]];if(d.canWrapX()&&n){const x=d.getExtent(),E=at(x);g.push([-E,0],[E,0])}const _=e.layerStatesArray,p=_.length,m=[],y=[];for(let x=0;x<g.length;x++)for(let E=p-1;E>=0;--E){const S=_[E],w=S.layer;if(w.hasRenderer()&&Ua(S,c)&&a.call(l,w)){const T=w.getRenderer(),R=w.getSource();if(T&&R){const b=R.getWrapX()?f:t,L=u.bind(null,S.managed);y[0]=b[0]+g[x][0],y[1]=b[1]+g[x][1],h=T.forEachFeatureAtCoordinate(y,e,i,L,m)}if(h)return h}}if(m.length===0)return;const C=1/m.length;return m.forEach((x,E)=>x.distanceSq+=E*C),m.sort((x,E)=>x.distanceSq-E.distanceSq),m.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(t,e,i,n,r,o){return this.forEachFeatureAtCoordinate(t,e,i,n,cn,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){X()}scheduleExpireIconCache(t){he.canExpireCache()&&t.postRenderFunctions.push(Xm)}}function Xm(s,t){he.expire()}class jm extends Um{constructor(t){super(t),this.fontChangeListenerKey_=H(Ki,hn.PROPERTYCHANGE,t.redrawText,t),this.element_=le?rc():document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=Ir+" ol-layers";const i=t.getViewport();i&&i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const n=new Vn(t,void 0,e);i.dispatchEvent(n)}}disposeInternal(){dt(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(kt.PRECOMPOSE,t);const e=t.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);e.some(h=>h.layer instanceof zr&&h.layer.getDeclutter())&&(t.declutter={});const n=t.viewState;this.children_.length=0;const r=[];let o=null;for(let h=0,c=e.length;h<c;++h){const u=e[h];t.layerIndex=h;const d=u.layer,f=d.getSourceState();if(!Ua(u,n)||f!="ready"&&f!="undefined"){d.unrender();continue}const g=d.render(t,o);g&&(g!==o&&(this.children_.push(g),o=g),r.push(u))}this.declutter(t,r),Od(this.element_,this.children_);const l=this.getMap().getTargetElement();if(di(l)){const h=l.getContext("2d");for(const c of this.children_){const u=c.firstElementChild||c,d=c.style.backgroundColor;if(d&&(!di(u)||u.width>0)&&(h.fillStyle=d,h.fillRect(0,0,l.width,l.height)),di(u)&&u.width>0){h.save();const f=c.style.opacity||u.style.opacity;h.globalAlpha=f===""?1:Number(f);const g=u.style.transform;if(g)h.transform(...Bo(g));else{const _=parseFloat(u.style.width)/u.width,p=parseFloat(u.style.height)/u.height;h.transform(_,0,0,p,0,0)}h.drawImage(u,0,0),h.restore()}}}this.dispatchRenderEvent(kt.POSTCOMPOSE,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let i=e.length-1;i>=0;--i){const n=e[i],r=n.layer;r.getDeclutter()&&r.renderDeclutter(t,n)}e.forEach(i=>i.layer.renderDeferred(t))}}}function _u(s){if(s instanceof Gr){s.setMapInternal(null);return}s instanceof wn&&s.getLayers().forEach(_u)}function mu(s,t){if(s instanceof Gr){s.setMapInternal(t);return}if(s instanceof wn){const e=s.getLayers().getArray();for(let i=0,n=e.length;i<n;++i)mu(e[i],t)}}let yu=class extends Te{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=Vm(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=t.maxTilesLoading!==void 0?t.maxTilesLoading:16,this.pixelRatio_=t.pixelRatio!==void 0?t.pixelRatio:kd,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Mt(),this.pixelToCoordinateTransform_=Mt(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,le||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,le||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=e.controls||(le?new Qt:bm()),this.interactions=e.interactions||(le?new Qt:pu({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Cm(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener($t.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener($t.VIEW,this.handleViewChanged_),this.addChangeListener($t.SIZE,this.handleSizeChanged_),this.addChangeListener($t.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof De)&&t.view.then(function(n){i.setView(new De(n))}),this.controls.addEventListener(qt.ADD,n=>{n.element.setMap(this)}),this.controls.addEventListener(qt.REMOVE,n=>{n.element.setMap(null)}),this.interactions.addEventListener(qt.ADD,n=>{n.element.setMap(this)}),this.interactions.addEventListener(qt.REMOVE,n=>{n.element.setMap(null)}),this.overlays_.addEventListener(qt.ADD,n=>{this.addOverlayInternal_(n.element)}),this.overlays_.addEventListener(qt.REMOVE,n=>{const r=n.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],n.element.setMap(null)}),this.controls.forEach(n=>{n.setMap(this)}),this.interactions.forEach(n=>{n.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){mu(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();e!==void 0&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;const n=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:cn,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(n,this.frameState_,r,a,e,null,o,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,function(n){i.push(n)},e),i}getAllLayers(){const t=[];function e(i){i.forEach(function(n){n instanceof wn?e(n.getLayers()):t.push(n)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};const n=e.layerFilter!==void 0?e.layerFilter:cn,r=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,n,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const i=this.viewport_.getBoundingClientRect(),n=this.getSize(),r=i.width/n[0],o=i.height/n[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get($t.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return $o(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?wt(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get($t.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof Qt){e.setLayers(t);return}const i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const n=t[e];if(!n.visible)continue;const r=n.layer.getRenderer();if(r&&!r.ready)return!0;const o=n.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(t){const e=ye(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?wt(e.coordinateToPixelTransform,t.slice(0,2)):null}getPixelRatio(){return this.pixelRatio_}setPixelRatio(t){this.pixelRatio_!==t&&(this.pixelRatio_=t,this.render())}getRenderer(){return this.renderer_}getSize(){return this.get($t.SIZE)}getView(){return this.get($t.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,n){return wm(this.frameState_,t,e,i,n)}handleBrowserEvent(t,e){e=e||t.type;const i=new Ye(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===sa.POINTERDOWN||i===j.WHEEL||i===j.KEYDOWN){const n=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():n,o=e.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===n?n.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){const n=this.getInteractions().getArray().slice();for(let r=n.length-1;r>=0;r--){const o=n[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let n=this.maxTilesLoading_,r=n;const o=t?t.viewHints:void 0,a=o?o[Dt.ANIMATING]||o[Dt.INTERACTING]:!1;if(a){const l=Date.now()-t.time>8;n=l?0:8,r=l?0:2}e.getTilesLoading()<n&&(a&&e.reprioritize(),e.loadMoreTiles(n,r))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(kt.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(kt.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new Qi(ci.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new Qi(ci.LOADSTART,this,t))));const i=this.postRenderFunctions_;if(t)for(let n=0,r=i.length;n<r;++n)i[n](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,n=this.targetChangeHandlerKeys_.length;i<n;++i)dt(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(j.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(j.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!di(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);const i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}const t=this.getTarget(),e=typeof t=="string"?document.getElementById(t):t;if(this.targetElement_=e,!e)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{if(di(e)||e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new jm(this)),!di(e)){this.mapBrowserEventHandler_=new Em(this,this.moveTolerance_);for(const n in rt)this.mapBrowserEventHandler_.addEventListener(rt[n],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(j.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(j.WHEEL,this.boundHandleBrowserEvent_,sc?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{const n=e.getRootNode();i=n instanceof ShadowRoot?n.host:e}if(this.targetChangeHandlerKeys_=[H(i,j.KEYDOWN,this.handleBrowserEvent,this),H(i,j.KEYPRESS,this.handleBrowserEvent,this)],e instanceof HTMLElement){const n=e.getRootNode();n instanceof ShadowRoot&&this.resizeObserver_.observe(n.host),this.resizeObserver_?.observe(e)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(dt(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(dt(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=H(t,hn.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=H(t,j.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(dt),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new ui("addlayer",t)),this.layerGroupPropertyListenerKeys_=[H(t,hn.PROPERTYCHANGE,this.render,this),H(t,j.CHANGE,this.render,this),H(t,"addlayer",this.handleLayerAdd_,this),H(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;const t=this.frameState_.layerStatesArray;for(let e=0,i=t.length;e<i;++e){const n=t[e].layer;n.hasRenderer()&&n.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){_u(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){const e=this.getSize(),i=this.getView(),n=this.frameState_;let r=null;if(e!==void 0&&Xl(e)&&i&&i.isDef()){const o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:ko(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:$(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=ko(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),n&&(!this.previousExtent_||!ls(this.previousExtent_)&&!dn(r.extent,this.previousExtent_))&&(this.dispatchEvent(new Qi(ci.MOVESTART,this,n)),this.previousExtent_=as(this.previousExtent_)),this.previousExtent_&&!r.viewHints[Dt.ANIMATING]&&!r.viewHints[Dt.INTERACTING]&&!dn(r.extent,this.previousExtent_)&&(this.dispatchEvent(new Qi(ci.MOVEEND,this,r)),Mh(r.extent,this.previousExtent_))),this.dispatchEvent(new Qi(ci.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(ci.LOADSTART)||this.hasListener(ci.LOADEND)||this.hasListener(kt.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new ui("removelayer",e)),this.set($t.LAYERGROUP,t)}setSize(t){this.set($t.SIZE,t)}setTarget(t){this.set($t.TARGET,t)}setView(t){if(!t||t instanceof De){this.set($t.VIEW,t);return}this.set($t.VIEW,new De);const e=this;t.then(function(i){e.setView(new De(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){let n,r;if(di(t)){const o=t.getContext("2d").getTransform();n=t.width/o.a,r=t.height/o.d}else{const o=getComputedStyle(t);n=t.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),r=t.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(n)&&!isNaN(r)&&(e=[Math.max(0,n),Math.max(0,r)],!Xl(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Oh("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!ei(e,i))&&(this.updateViewportSize_(e),this.setSize(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};function Vm(s){let t=null;s.keyboardEventTarget!==void 0&&(t=typeof s.keyboardEventTarget=="string"?document.getElementById(s.keyboardEventTarget):s.keyboardEventTarget);const e={},i=s.layers&&typeof s.layers.getLayers=="function"?s.layers:new wn({layers:s.layers});e[$t.LAYERGROUP]=i,e[$t.TARGET]=s.target,e[$t.VIEW]=s.view instanceof De?s.view:new De;let n;s.controls!==void 0&&(Array.isArray(s.controls)?n=new Qt(s.controls.slice()):(Q(typeof s.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),n=s.controls));let r;s.interactions!==void 0&&(Array.isArray(s.interactions)?r=new Qt(s.interactions.slice()):(Q(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 Qt(s.overlays.slice()):(Q(typeof s.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=s.overlays):o=new Qt,{controls:n,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}var Ym=class extends Te{constructor(t){t=t||{},super();var e=this.input=t.input;e||(e=this.input=document.createElement("input"),t.type&&e.setAttribute("type",t.type),t.min!==void 0&&e.setAttribute("min",t.min),t.max!==void 0&&e.setAttribute("max",t.max),t.step!==void 0&&e.setAttribute("step",t.step),t.parent&&t.parent.appendChild(e)),t.disabled&&(e.disabled=!0),t.checked!==void 0&&(e.checked=!!t.checked),t.val!==void 0&&(e.value=t.val),t.hidden&&e.classList.add("ol-input-hidden"),e.addEventListener("focus",(function(){this.element&&this.element.classList.add("ol-focus")}).bind(this));var i;e.addEventListener("focusout",(function(){this.element&&(i&&clearTimeout(i),i=setTimeout((function(){this.element.classList.remove("ol-focus")}).bind(this),0))}).bind(this))}_listenDrag(t,e){var i=(function(n){this.moving=!0,this.element.classList.add("ol-moving");var r=(function(o){o.type==="pointerup"&&(document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",r),document.removeEventListener("pointercancel",r),setTimeout((function(){this.moving=!1,this.element.classList.remove("ol-moving")}).bind(this))),o.target===t&&e(o),o.stopPropagation(),o.preventDefault()}).bind(this);document.addEventListener("pointermove",r,!1),document.addEventListener("pointerup",r,!1),document.addEventListener("pointercancel",r,!1),n.stopPropagation(),n.preventDefault()}).bind(this);t.addEventListener("mousedown",i,!1),t.addEventListener("touchstart",i,!1)}setValue(t){t!==void 0&&(this.input.value=t),this.input.dispatchEvent(new Event("change"))}getValue(){return this.input.value}getInputElement(){return this.input}},dl=class extends Ym{constructor(t){t=t||{},super(t);var e=this.element=document.createElement("label");t.html instanceof Element?e.appendChild(t.html):t.html!==void 0&&(e.innerHTML=t.html),e.className=("ol-ext-check ol-ext-checkbox "+(t.className||"")).trim(),this.input.parentNode&&this.input.parentNode.insertBefore(e,this.input),e.appendChild(this.input),e.appendChild(document.createElement("span")),t.after&&e.appendChild(document.createTextNode(t.after)),this.input.addEventListener("change",(function(){this.dispatchEvent({type:"check",checked:this.input.checked,value:this.input.value})}).bind(this))}isChecked(){return this.input.checked}},Zm=class extends dl{constructor(t){t=t||{},super(t),this.element.className=("ol-ext-toggle-switch "+(t.className||"")).trim()}},Hm=class extends dl{constructor(t){t=t||{},super(t),this.element.className=("ol-ext-check ol-ext-radio "+(t.className||"")).trim()}},V={};V.create=function(s,t){t=t||{};var e;if(s==="TEXT")e=document.createTextNode(t.html||""),t.parent&&t.parent.appendChild(e);else{e=document.createElement(s.toLowerCase()),/button/i.test(s)&&e.setAttribute("type","button");for(var i in t)switch(i){case"className":{t.className&&t.className.trim&&e.setAttribute("class",t.className.trim());break}case"text":{e.innerText=t.text;break}case"html":{t.html instanceof Element?e.appendChild(t.html):t.html!==void 0&&(e.innerHTML=t.html);break}case"parent":{t.parent&&t.parent.appendChild(e);break}case"options":{if(/select/i.test(s))for(var n in t.options)V.create("OPTION",{html:n,value:t.options[n],parent:e});break}case"style":{V.setStyle(e,t.style);break}case"change":case"click":{V.addListener(e,i,t[i]);break}case"on":{for(var r in t.on)V.addListener(e,r,t.on[r]);break}case"checked":{e.checked=!!t.checked;break}default:{e.setAttribute(i,t[i]);break}}}return e};V.createSwitch=function(s){var t=V.create("INPUT",{type:"checkbox",on:s.on,click:s.click,change:s.change,parent:s.parent}),e=Object.assign({input:t},s||{});return new Zm(e),t};V.createCheck=function(s){var t=V.create("INPUT",{name:s.name,type:s.type==="radio"?"radio":"checkbox",on:s.on,parent:s.parent}),e=Object.assign({input:t},s||{});return s.type==="radio"?new Hm(e):new dl(e),t};V.setHTML=function(s,t){t instanceof Element?s.appendChild(t):t!==void 0&&(s.innerHTML=t)};V.appendText=function(s,t){s.appendChild(document.createTextNode(t||""))};V.addListener=function(s,t,e,i){typeof t=="string"&&(t=t.split(" ")),t.forEach(function(n){s.addEventListener(n,e,i)})};V.removeListener=function(s,t,e){typeof t=="string"&&(t=t.split(" ")),t.forEach(function(i){s.removeEventListener(i,e)})};V.show=function(s){s.style.display=""};V.hide=function(s){s.style.display="none"};V.hidden=function(s){return V.getStyle(s,"display")==="none"};V.toggle=function(s){s.style.display=s.style.display==="none"?"":"none"};V.setStyle=function(s,t){for(var e in t)switch(e){case"top":case"left":case"bottom":case"right":case"minWidth":case"maxWidth":case"width":case"height":{typeof t[e]=="number"?s.style[e]=t[e]+"px":s.style[e]=t[e];break}default:s.style[e]=t[e]}};V.getStyle=function(s,t){var e,i=(s.ownerDocument||document).defaultView;if(i&&i.getComputedStyle)t=t.replace(/([A-Z])/g,"-$1").toLowerCase(),e=i.getComputedStyle(s,null).getPropertyValue(t);else if(s.currentStyle&&(t=t.replace(/-(\w)/g,function(n,r){return r.toUpperCase()}),e=s.currentStyle[t],/^\d+(em|pt|%|ex)?$/i.test(e)))return(function(n){var r=s.style.left,o=s.runtimeStyle.left;return s.runtimeStyle.left=s.currentStyle.left,s.style.left=n||0,n=s.style.pixelLeft+"px",s.style.left=r,s.runtimeStyle.left=o,n})(e);return/px$/.test(e)?parseInt(e):e};V.outerHeight=function(s){return s.offsetHeight+V.getStyle(s,"marginBottom")};V.outerWidth=function(s){return s.offsetWidth+V.getStyle(s,"marginLeft")};V.offsetRect=function(s){var t=s.getBoundingClientRect();return{top:t.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),left:t.left+(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0),height:t.height||t.bottom-t.top,width:t.width||t.right-t.left}};V.getFixedOffset=function(s){var t={left:0,top:0},e=function(i){if(!i)return t;if(V.getStyle(i,"position")==="absolute"&&V.getStyle(i,"transform")!=="none"){var n=i.getBoundingClientRect();return t.left+=n.left,t.top+=n.top,t}return e(i.offsetParent)};return e(s.offsetParent)};V.positionRect=function(s,t){var e=0,i=0,n=function(r){if(r)return e+=r.offsetLeft,i+=r.offsetTop,n(r.offsetParent);var o={top:s.offsetTop+i,left:s.offsetLeft+e};return t&&(o.top-=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,o.left-=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0),o.bottom=o.top+s.offsetHeight,o.right=o.top+s.offsetWidth,o};return n(s.offsetParent)};V.scrollDiv=function(s,t){t=t||{};var e=!1,i=0,n,r=0,o=typeof t.onmove=="function"?t.onmove:function(){},a=t.vertical?"screenY":"screenX",l=t.vertical?"scrollTop":"scrollLeft",h=!1,c,u,d=0,f=function(){C&&(d++,setTimeout(g))},g=function(){if(C){if(d--,d)return;var w=s.clientHeight,T=s.scrollHeight;c=w/T,C.style.height=c*100+"%",C.style.top=s.scrollTop/T*100+"%",y.style.height=w+"px",w>T-.5?y.classList.add("ol-100pc"):y.classList.remove("ol-100pc")}},_=function(w){w.target.classList.contains("ol-noscroll")||(h=!1,e=w[a],r=new Date,s.classList.add("ol-move"),w.preventDefault(),window.addEventListener("pointermove",p),V.addListener(window,["pointerup","pointercancel"],E))},p=function(w){if(e!==!1){var T=(u?-1/c:1)*(e-w[a]);h=h||Math.round(T),s[l]+=T,n=new Date,n-r&&(i=(i+T/(n-r))/2),e=w[a],r=n,T&&o(!0)}else h=!0},m=function(w){var T=w>0?Math.min(100,w/2):Math.max(-100,w/2);w-=T,s[l]+=T,-1<w&&w<1?(h?setTimeout(function(){s.classList.remove("ol-move")}):s.classList.remove("ol-move"),h=!1,o(!1)):setTimeout(function(){m(w)},40)},y,C;if(t.vertical&&t.minibar){var x=function(w){s.removeEventListener("pointermove",x),s.parentNode.classList.add("ol-miniscroll"),C=V.create("DIV"),y=V.create("DIV",{className:"ol-scroll",html:C}),s.parentNode.insertBefore(y,s),C.addEventListener("pointerdown",function(T){u=!0,_(T)}),t.mousewheel&&(V.addListener(y,["mousewheel","DOMMouseScroll","onmousewheel"],function(T){S(T)}),V.addListener(C,["mousewheel","DOMMouseScroll","onmousewheel"],function(T){S(T)})),s.parentNode.addEventListener("pointerenter",f),window.addEventListener("resize",f),w!==!1&&f()};s.parentNode?x(!1):s.addEventListener("pointermove",x),s.addEventListener("scroll",function(){f()})}s.style["touch-action"]="none",s.style.overflow="hidden",s.classList.add("ol-scrolldiv"),V.addListener(s,["pointerdown"],function(w){u=!1,_(w)}),s.addEventListener("click",function(w){s.classList.contains("ol-move")&&(w.preventDefault(),w.stopPropagation())},!0);var E=function(w){r=new Date-r,r>100||u?i=0:r>0&&(i=((i||0)+(e-w[a])/r)/2),m(t.animate===!1?0:i*200),e=!1,i=0,r=0,s.classList.contains("ol-move")?s.classList.remove("ol-hasClick"):(s.classList.add("ol-hasClick"),setTimeout(function(){s.classList.remove("ol-hasClick")},500)),u=!1,window.removeEventListener("pointermove",p),V.removeListener(window,["pointerup","pointercancel"],E)},S=function(w){var T=Math.max(-1,Math.min(1,w.wheelDelta||-w.detail));return s.classList.add("ol-move"),s[l]-=T*30,s.classList.remove("ol-move"),!1};return t.mousewheel&&V.addListener(s,["mousewheel","DOMMouseScroll","onmousewheel"],S),{refresh:f}};V.dispatchEvent=function(s,t){var e;try{e=new CustomEvent(s)}catch{e=document.createEvent("CustomEvent"),e.initCustomEvent(s,!0,!0,{})}t.dispatchEvent(e)};V.setCursor=function(s,t){s instanceof yu&&(s=s.getTargetElement()),!("ontouchstart"in window)&&s instanceof Element&&(s.style.cursor=t)};var Br=class extends Gi{constructor(t){t=t||{},super({handleDownEvent:function(i){return e.handleDownEvent_(i)},handleDragEvent:function(i){return this.handleDragEvent_(i)},handleMoveEvent:function(i){return this.handleMoveEvent_(i)},handleUpEvent:function(i){return this.handleUpEvent_(i)}});var e=this;this.selection_=new Qt,this.handles_=new Qt,this.overlayLayer_=new Ht({source:new St({features:this.handles_,useSpatialIndex:!1,wrapX:!1}),name:"Transform overlay",displayInLayerSwitcher:!1,style:function(i){return e.style[(i.get("handle")||"default")+(i.get("constraint")||"")+(i.get("option")||"")]},updateWhileAnimating:!0,updateWhileInteracting:!0}),this.features_=t.features,typeof t.filter=="function"&&(this._filter=t.filter),this.layers_=t.layers?t.layers instanceof Array?t.layers:[t.layers]:null,this._handleEvent=t.condition||function(){return!0},this.addFn_=t.addCondition||function(){return!1},this.setPointRadius(t.pointRadius),this.set("translateFeature",t.translateFeature!==!1),this.set("translate",t.translate!==!1),this.set("translateBBox",t.translateBBox===!0),this.set("stretch",t.stretch!==!1),this.set("scale",t.scale!==!1),this.set("rotate",t.rotate!==!1),this.set("keepAspectRatio",t.keepAspectRatio||function(i){return i.originalEvent.shiftKey}),this.set("modifyCenter",t.modifyCenter||function(i){return i.originalEvent.metaKey||i.originalEvent.ctrlKey}),this.set("noFlip",t.noFlip||!1),this.set("selection",t.selection!==!1),this.set("hitTolerance",t.hitTolerance||0),this.set("enableRotatedTransform",t.enableRotatedTransform||!1),this.set("keepRectangle",t.keepRectangle||!1),this.set("buffer",t.buffer||0),this.on("propertychange",function(){this.drawSketch_()}),this.setDefaultStyle(),t.select?this.on("change:active",(function(i){this.getActive()?this.setSelection(t.select.getFeatures().getArray()):(t.select.getFeatures().extend(this.selection_),this.selection_.forEach(function(n){t.select.getFeatures().push(n)}),this.select(null))}).bind(this)):this.on("change:active",(function(i){this.select(null)}).bind(this))}setMap(t){var e=this.getMap();e&&(e.removeLayer(this.overlayLayer_),this.previousCursor_&&V.setCursor(e,this.previousCursor_),this.previousCursor_=void 0),super.setMap(t),this.overlayLayer_.setMap(t),t===null&&this.select(null),t!==null&&(this.isTouch=/touch/.test(t.getViewport().className),this.setDefaultStyle())}setActive(t){this.overlayLayer_&&this.overlayLayer_.setVisible(t),super.setActive(t)}setDefaultStyle(t){t=t||{};var e=t.pointStroke||new _t({color:[255,0,0,1],width:1}),i=t.stroke||new _t({color:[255,0,0,1],width:1,lineDash:[4,4]}),n=t.fill||new ut({color:[255,0,0,.01]}),r=t.pointFill||new ut({color:[255,255,255,.8]}),o=new Mi({fill:r,stroke:e,radius:this.isTouch?12:6,displacement:this.isTouch?[24,-24]:[12,-12],points:15});o.setDisplacement||(o.getAnchor()[0]=this.isTouch?-10:-5);var a=new Mi({fill:r,stroke:e,radius:this.isTouch?16:8,points:4,angle:Math.PI/4}),l=new Mi({fill:r,stroke:e,radius:this.isTouch?12:6,points:4,angle:Math.PI/4});function h(c,u,d){return[new lt({image:c,stroke:u,fill:d})]}this.style={default:h(a,i,n),translate:h(a,e,r),rotate:h(o,e,r),rotate0:h(a,e,r),scale:h(a,e,r),scale1:h(a,e,r),scale2:h(a,e,r),scale3:h(a,e,r),scalev:h(l,e,r),scaleh1:h(l,e,r),scalev2:h(l,e,r),scaleh3:h(l,e,r)},this.drawSketch_()}setStyle(t,e){if(e){e instanceof Array?this.style[t]=e:this.style[t]=[e];for(var i=0;i<this.style[t].length;i++){var n=this.style[t][i].getImage();n&&(t=="rotate"&&(n.getAnchor()[0]=-5),this.isTouch&&n.setScale(1.8));var r=this.style[t][i].getText();r&&(t=="rotate"&&r.setOffsetX(this.isTouch?14:7),this.isTouch&&r.setScale(1.8))}this.drawSketch_()}}getFeatureAtPixel_(t){var e=this;return this.getMap().forEachFeatureAtPixel(t,function(i,n){var r=!1;if(!n){if(i===e.bbox_)return e.get("translateBBox")?{feature:i,handle:"translate",constraint:"",option:""}:!1;if(e.handles_.forEach(function(a){a===i&&(r=!0)}),r)return{feature:i,handle:i.get("handle"),constraint:i.get("constraint"),option:i.get("option")}}if(!e.get("selection"))return e.selection_.getArray().some(function(a){return i===a})?{feature:i}:null;if(e._filter)return e._filter(i,n)?{feature:i}:null;if(e.layers_){for(var o=0;o<e.layers_.length;o++)if(e.layers_[o]===n)return{feature:i};return null}else return e.features_?(e.features_.forEach(function(a){a===i&&(r=!0)}),r?{feature:i}:null):{feature:i}},{hitTolerance:this.get("hitTolerance")})||{}}getGeometryRotateToZero_(t,e){var i=t.getGeometry(),n=this.getMap().getView().getRotation();if(n===0||!this.get("enableRotatedTransform"))return e?i.clone():i;var r=i.clone();return r.rotate(n*-1,this.getMap().getView().getCenter()),r}_isRectangle(t){if(this.get("keepRectangle")&&t.getType()==="Polygon"){var e=t.getCoordinates()[0];return e.length===5}return!1}drawSketch_(t){var e,i,n,r=this.selection_.item(0)&&this._isRectangle(this.selection_.item(0).getGeometry());if(this.overlayLayer_.getSource().clear(),!(!this.selection_.getLength()||!this.selection_.item(0).getGeometry())){var o=this.getMap().getView().getRotation(),a=this.getGeometryRotateToZero_(this.selection_.item(0)).getExtent(),l;r&&(l=this.getGeometryRotateToZero_(this.selection_.item(0)).getCoordinates()[0].slice(0,4),l.unshift(l[3])),a=En(a,this.get("buffer")),this.selection_.forEach((function(_){var p=this.getGeometryRotateToZero_(_).getExtent();Bn(a,p)}).bind(this));var h=this.selection_.getLength()===1?this._pointRadius(this.selection_.item(0)):0;if(h&&!(h instanceof Array)&&(h=[h,h]),t===!0)this.ispt_||(this.overlayLayer_.getSource().addFeature(new ot({geometry:new gt(this.center_),handle:"rotate0"})),n=nn(a),this.get("enableRotatedTransform")&&o!==0&&n.rotate(o,this.getMap().getView().getCenter()),i=this.bbox_=new ot(n),this.overlayLayer_.getSource().addFeature(i));else{if(this.ispt_){var c=this.getMap().getPixelFromCoordinate(ue(a));if(c){var u=h&&h[0]||10,d=h&&h[1]||10;a=er([this.getMap().getCoordinateFromPixel([c[0]-u,c[1]-d]),this.getMap().getCoordinateFromPixel([c[0]+u,c[1]+d])])}}n=r?new ht([l]):nn(a),this.get("enableRotatedTransform")&&o!==0&&n.rotate(o,this.getMap().getView().getCenter()),i=this.bbox_=new ot(n);var f=[],g=n.getCoordinates()[0];if(!this.ispt_||h){if(f.push(i),!this.iscircle_&&!this.ispt_&&this.get("stretch")&&this.get("scale"))for(e=0;e<g.length-1;e++)i=new ot({geometry:new gt([(g[e][0]+g[e+1][0])/2,(g[e][1]+g[e+1][1])/2]),handle:"scale",constraint:e%2?"h":"v",option:e}),f.push(i);if(this.get("scale"))for(e=0;e<g.length-1;e++)i=new ot({geometry:new gt(g[e]),handle:"scale",option:e}),f.push(i);this.get("translate")&&!this.get("translateFeature")&&(i=new ot({geometry:new gt([(g[0][0]+g[2][0])/2,(g[0][1]+g[2][1])/2]),handle:"translate"}),f.push(i))}!this.iscircle_&&this.get("rotate")&&(i=new ot({geometry:new gt(g[3]),handle:"rotate"}),f.push(i)),this.overlayLayer_.getSource().addFeatures(f)}}}select(t,e){if(!t){this.selection_&&(this.selection_.clear(),this.drawSketch_());return}if(!(!t.getGeometry||!t.getGeometry())){if(e)this.selection_.push(t);else{var i=this.selection_.getArray().indexOf(t);this.selection_.removeAt(i)}this.ispt_=this.selection_.getLength()===1?this.selection_.item(0).getGeometry().getType()=="Point":!1,this.iscircle_=this.selection_.getLength()===1?this.selection_.item(0).getGeometry().getType()=="Circle":!1,this.drawSketch_(),this.watchFeatures_(),this.dispatchEvent({type:"select",feature:t,features:this.selection_})}}setSelection(t){this.selection_.clear(),t.forEach((function(e){this.selection_.push(e)}).bind(this)),this.ispt_=this.selection_.getLength()===1?this.selection_.item(0).getGeometry().getType()=="Point":!1,this.iscircle_=this.selection_.getLength()===1?this.selection_.item(0).getGeometry().getType()=="Circle":!1,this.drawSketch_(),this.watchFeatures_(),this.dispatchEvent({type:"select",features:this.selection_})}watchFeatures_(){this._featureListeners&&this._featureListeners.forEach(function(t){Ih(t)}),this._featureListeners=[],this.selection_.forEach((function(t){this._featureListeners.push(t.on("change",(function(){this.isUpdating_||this.drawSketch_()}).bind(this)))}).bind(this))}handleDownEvent_(t){if(this._handleEvent(t,this.selection_)){var e=this.getFeatureAtPixel_(t.pixel),i=e.feature;if(this.selection_.getLength()&&this.selection_.getArray().indexOf(i)>=0&&(this.ispt_&&this.get("translate")||this.get("translateFeature"))&&(e.handle="translate"),e.handle){this.mode_=e.handle,this.opt_=e.option,this.constraint_=e.constraint;var n=this.getMap().getView().getRotation();this.coordinate_=i.get("handle")?i.getGeometry().getCoordinates():t.coordinate,this.pixel_=this.getMap().getCoordinateFromPixel(this.coordinate_),this.geoms_=[],this.rotatedGeoms_=[];var r=Wt(),o=Wt();this.hasChanged_=!1;for(var a=0,l;l=this.selection_.item(a);a++)if(this.geoms_.push(l.getGeometry().clone()),r=Bn(r,l.getGeometry().getExtent()),this.get("enableRotatedTransform")&&n!==0){var h=this.getGeometryRotateToZero_(l,!0);this.rotatedGeoms_.push(h),o=Bn(o,h.getExtent())}if(this.extent_=nn(r).getCoordinates()[0],this.get("enableRotatedTransform")&&n!==0&&(this.rotatedExtent_=nn(o).getCoordinates()[0]),this.mode_==="rotate"){this.center_=this.getCenter()||ue(r);var c=t.map.getTargetElement();V.setCursor(c,this.Cursors.rotate0),this.previousCursor_=c.style.cursor}else this.center_=ue(r);return this.angle_=Math.atan2(this.center_[1]-t.coordinate[1],this.center_[0]-t.coordinate[0]),this.dispatchEvent({type:this.mode_+"start",feature:this.selection_.item(0),features:this.selection_,pixel:t.pixel,coordinate:t.coordinate}),!0}else if(this.get("selection")){if(i){this.addFn_(t)||this.selection_.clear();var u=this.selection_.getArray().indexOf(i);u<0?this.selection_.push(i):this.selection_.removeAt(u)}else this.selection_.clear();return this.ispt_=this.selection_.getLength()===1?this.selection_.item(0).getGeometry().getType()=="Point":!1,this.iscircle_=this.selection_.getLength()===1?this.selection_.item(0).getGeometry().getType()=="Circle":!1,this.drawSketch_(),this.watchFeatures_(),this.dispatchEvent({type:"select",feature:i,features:this.selection_,pixel:t.pixel,coordinate:t.coordinate}),!1}}}getCenter(){return this.get("center")}setCenter(t){return this.set("center",t)}handleDragEvent_(t){if(this._handleEvent(t,this.features_)){var e=this.getMap().getView().getRotation(),i,n,r,o,a=[this.coordinate_[0],this.coordinate_[1]],l=[t.coordinate[0],t.coordinate[1]];switch(this.isUpdating_=!0,this.hasChanged_=!0,this.mode_){case"rotate":{var h=Math.atan2(this.center_[1]-l[1],this.center_[0]-l[0]);if(!this.ispt)for(i=0,r;r=this.selection_.item(i);i++)o=this.geoms_[i].clone(),o.rotate(h-this.angle_,this.center_),o.getType()=="Circle"&&o.setCenterAndRadius(o.getCenter(),o.getRadius()),r.setGeometry(o);this.drawSketch_(!0),this.dispatchEvent({type:"rotating",feature:this.selection_.item(0),features:this.selection_,angle:h-this.angle_,pixel:t.pixel,coordinate:t.coordinate});break}case"translate":{var c=l[0]-a[0],u=l[1]-a[1];for(i=0,r;r=this.selection_.item(i);i++)r.getGeometry().translate(c,u);this.handles_.forEach(function(b){b.getGeometry().translate(c,u)}),this.coordinate_=t.coordinate,this.dispatchEvent({type:"translating",feature:this.selection_.item(0),features:this.selection_,delta:[c,u],pixel:t.pixel,coordinate:t.coordinate});break}case"scale":{var d=this.center_;if(this.get("modifyCenter")(t)){var f=this.extent_;this.get("enableRotatedTransform")&&e!==0&&(f=this.rotatedExtent_),d=f[(Number(this.opt_)+2)%4]}var g=this.geoms_.length==1&&this._isRectangle(this.geoms_[0]),_=this.constraint_,p=this.opt_,m=this.coordinate_,y=t.coordinate;if(this.get("enableRotatedTransform")&&e!==0){var C=new gt(this.coordinate_);C.rotate(e*-1,d),m=C.getCoordinates();var x=new gt(t.coordinate);x.rotate(e*-1,d),y=x.getCoordinates()}var E=(y[0]-d[0])/(m[0]-d[0]),S=(y[1]-d[1])/(m[1]-d[1]),w=[y[0]-m[0],y[1]-m[1]];if(this.get("enableRotatedTransform")&&e!==0){var T=new gt(d);T.rotate(e*-1,this.getMap().getView().getCenter()),d=T.getCoordinates()}this.get("noFlip")&&(E<0&&(E=-E),S<0&&(S=-S)),this.constraint_?this.constraint_=="h"?E=1:S=1:this.get("keepAspectRatio")(t)&&(E=S=Math.min(E,S));var R=this.get("keepAspectRatio")(t);for(i=0,r;r=this.selection_.item(i);i++)o=e===0||!this.get("enableRotatedTransform")?this.geoms_[i].clone():this.rotatedGeoms_[i].clone(),o.applyTransform((function(b,L,I){if(I<2)return L;if(g){var F=[[6],[0,8],[2],[4]],D=[b[0],b[1]],k=[b[2],b[3]],G=[b[4],b[5]],M=[b[6],b[7]],N=[b[8],b[9]];if(_){var B=p%2===0?this._countVector(D,k):this._countVector(M,D),q=this._projectVectorOnVector(w,B),K=p+1<F.length?p+1:0,ct=[...F[p],...F[K]];for(n=0;n<b.length;n+=I)L[n]=ct.includes(n)?b[n]+q[0]:b[n],L[n+1]=ct.includes(n)?b[n+1]+q[1]:b[n+1]}else{var st,P,mt;switch(p){case 0:R?(mt=this._snapToDiagonal(M,k,y),w=this._countVector(M,mt)):w=this._countVector(M,y),st=this._projectVectorOnVector(w,this._countVector(G,M)),P=this._projectVectorOnVector(w,this._countVector(D,M)),[L[0],L[1]]=this._movePoint(D,st),[L[4],L[5]]=this._movePoint(G,P),[L[6],L[7]]=this._movePoint(M,w),[L[8],L[9]]=this._movePoint(N,st);break;case 1:R?(mt=this._snapToDiagonal(D,G,y),w=this._countVector(D,mt)):w=this._countVector(D,y),st=this._projectVectorOnVector(w,this._countVector(M,D)),P=this._projectVectorOnVector(w,this._countVector(k,D)),[L[0],L[1]]=this._movePoint(D,w),[L[2],L[3]]=this._movePoint(k,st),[L[6],L[7]]=this._movePoint(M,P),[L[8],L[9]]=this._movePoint(N,w);break;case 2:R?(mt=this._snapToDiagonal(k,M,y),w=this._countVector(k,mt)):w=this._countVector(k,y),st=this._projectVectorOnVector(w,this._countVector(D,k)),P=this._projectVectorOnVector(w,this._countVector(G,k)),[L[0],L[1]]=this._movePoint(D,P),[L[2],L[3]]=this._movePoint(k,w),[L[4],L[5]]=this._movePoint(G,st),[L[8],L[9]]=this._movePoint(N,P);break;case 3:R?(mt=this._snapToDiagonal(G,D,y),w=this._countVector(G,mt)):w=this._countVector(G,y),st=this._projectVectorOnVector(w,this._countVector(k,G)),P=this._projectVectorOnVector(w,this._countVector(M,G)),[L[2],L[3]]=this._movePoint(k,P),[L[4],L[5]]=this._movePoint(G,w),[L[6],L[7]]=this._movePoint(M,st);break}}}else for(n=0;n<b.length;n+=I)E!=1&&(L[n]=d[0]+(b[n]-d[0])*E),S!=1&&(L[n+1]=d[1]+(b[n+1]-d[1])*S);return o.getType()=="Circle"&&o.setCenterAndRadius(o.getCenter(),o.getRadius()),L}).bind(this)),this.get("enableRotatedTransform")&&e!==0&&o.rotate(e,this.getMap().getView().getCenter()),r.setGeometry(o);this.drawSketch_(),this.dispatchEvent({type:"scaling",feature:this.selection_.item(0),features:this.selection_,scale:[E,S],pixel:t.pixel,coordinate:t.coordinate});break}}this.isUpdating_=!1}}handleMoveEvent_(t){if(this._handleEvent(t,this.features_)&&!this.mode_){var e=this.getFeatureAtPixel_(t.pixel),i=t.map.getTargetElement();if(e.feature){var n=e.handle?this.Cursors[(e.handle||"default")+(e.constraint||"")+(e.option||"")]:this.Cursors.select;this.previousCursor_===void 0&&(this.previousCursor_=i.style.cursor),V.setCursor(i,n)}else this.previousCursor_!==void 0&&V.setCursor(i,this.previousCursor_),this.previousCursor_=void 0}}handleUpEvent_(t){if(this.mode_==="rotate"){var e=t.map.getTargetElement();V.setCursor(e,this.Cursors.default),this.previousCursor_=void 0}return this.dispatchEvent({type:this.mode_+"end",feature:this.selection_.item(0),features:this.selection_,oldgeom:this.geoms_[0],oldgeoms:this.geoms_,transformed:this.hasChanged_}),this.drawSketch_(),this.hasChanged_=!1,this.mode_=null,!1}setPointRadius(t){typeof t=="function"?this._pointRadius=t:this._pointRadius=function(){return t}}getFeatures(){return this.selection_}_projectVectorOnVector(t,e){var i=(t[0]*e[0]+t[1]*e[1])/(e[0]*e[0]+e[1]*e[1]);return[e[0]*i,e[1]*i]}_countVector(t,e){return[e[0]-t[0],e[1]-t[1]]}_movePoint(t,e){return[t[0]+e[0],t[1]+e[1]]}_snapToDiagonal(t,e,i){var n=[t[0]-e[0],t[1]-e[1]],r=[i[0]-e[0],i[1]-e[1]],o=r[0]*n[0]+r[1]*n[1],a=n[0]*n[0]+n[1]*n[1],l=o/a;return[e[0]+n[0]*l,e[1]+n[1]*l]}};Br.prototype.Cursors={default:"auto",select:"pointer",translate:"move",rotate:"move",rotate0:"move",scale:"nesw-resize",scale1:"nwse-resize",scale2:"nesw-resize",scale3:"nwse-resize",scalev:"ew-resize",scaleh1:"ns-resize",scalev2:"ew-resize",scaleh3:"ns-resize"};class xu extends Ut{constructor(t,e,i){super(t,e,nt.CIRCLE_DRAW,{...i,zIndex:i?.zIndex??100}),this.drawInteraction=null,this.transformInteraction=null,this.features=new Map,this.onDrawCompleteCallback=null,this.onEditCompleteCallback=null,this.editingFeature=null,this.mapView=null,this.defaultFillColor=i?.defaultFillColor||[255,0,0,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[255,0,0,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||1,this.source=new St,this.layer=new Ht({source:this.source,style:this.createStyle.bind(this),properties:{id:t,name:e,type:nt.CIRCLE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createStyle(){return new lt({fill:new ut({color:ft(this.defaultFillColor)}),stroke:new _t({color:ft(this.defaultOutlineColor),width:this.defaultOutlineWidth})})}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startDraw(t){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=t||null;const e=new St;this.drawInteraction=new ys({source:e,type:"Circle",style:this.createStyle()}),this.drawInteraction.on("drawend",i=>{const n=i.feature.clone(),r=n.getGeometry(),o=_s("circle_");if(r instanceof Ee){const a=Pt(r.getCenter());n.set("id",o),n.setStyle(this.createStyle()),this.source?.addFeature(n),this.features.set(o,n),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:o,center:[a[0],a[1]],radius:r.getRadius(),fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth})}e.clear(),this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null,this.onDrawCompleteCallback=null,this.mapView?.render()}),this.mapView?.addInteraction(this.drawInteraction)}startEdit(t,e){this.stopEdit();const i=this.features.get(t);if(!i){console.error(`Circle with id ${t} not found`);return}this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new St;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new Br({features:r,translate:!0,scale:!0,rotate:!1,keepAspectRatio:()=>!0}),this.transformInteraction.setActive(!0),this.transformInteraction.on("select",()=>{this.transformInteraction?.setActive(!0)}),this.transformInteraction.on("scaleend",()=>{const o=i.getGeometry();if(o instanceof Ee){const a=Pt(o.getCenter()),l=i.get("id");this.onEditCompleteCallback&&l&&this.onEditCompleteCallback({id:l,center:[a[0],a[1]],radius:o.getRadius()})}}),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof Ee){const a=Pt(o.getCenter()),l=i.get("id");this.onEditCompleteCallback&&l&&this.onEditCompleteCallback({id:l,center:[a[0],a[1]],radius:o.getRadius()})}}),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addCircle(t){const e=te(t.center),i=new Ee(e,t.radius),n=new ot({geometry:i,id:t.id});n.setStyle(this.createStyle()),this.source?.addFeature(n),this.features.set(t.id,n)}removeCircle(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllCircles(){const t=[];return this.features.forEach((e,i)=>{const n=e.getGeometry();if(n instanceof Ee){const r=Pt(n.getCenter());t.push({id:i,center:[r[0],r[1]],radius:n.getRadius()})}}),t}getCircle(t){const e=this.features.get(t);if(!e)return;const i=e.getGeometry();if(i instanceof Ee){const n=Pt(i.getCenter());return{id:t,center:[n[0],n[1]],radius:i.getRadius()}}}updateCircleStyle(t,e,i,n,r){const o=this.features.get(t);if(!o)return;const a=r==="dashed"?[10,10]:void 0;o.setStyle(new lt({fill:new ut({color:ft(e)}),stroke:new _t({color:ft(i),width:n,lineDash:a})})),o.changed(),this.mapView?.render()}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAllCircles(){this.clear(),this.features.clear(),this.stopEdit()}updateData(t){t.circles&&(this.clearAllCircles(),t.circles.forEach(e=>this.addCircle(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}isDrawActive(){return this.drawInteraction!==null}isEditActive(){return this.transformInteraction!==null}setEditable(t){t?this.layer.set("pointer-events",!0):(this.stopEdit(),this.stopDraw())}getEditingId(){return this.editingFeature?.get("id")||null}cancelDraw(){this.stopDraw()}cancelEdit(){this.stopEdit()}}class Km extends Ut{constructor(t,e,i){super(t,e,nt.RECTANGLE_DRAW,{...i,zIndex:i?.zIndex??100}),this.drawInteraction=null,this.transformInteraction=null,this.features=new Map,this.onDrawCompleteCallback=null,this.onEditCompleteCallback=null,this.editingFeature=null,this.mapView=null,this.defaultFillColor=i?.defaultFillColor||[0,0,255,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[0,0,255,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||1,this.source=new St,this.layer=new Ht({source:this.source,style:this.createStyle.bind(this),properties:{id:t,name:e,type:nt.RECTANGLE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createStyle(){return new lt({fill:new ut({color:ft(this.defaultFillColor)}),stroke:new _t({color:ft(this.defaultOutlineColor),width:this.defaultOutlineWidth})})}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startDraw(t){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=t||null,this.drawInteraction=new ys({source:this.source,type:"Circle",geometryFunction:(e,i)=>{if(i||(i=new ht([[[0,0],[0,0],[0,0],[0,0]]])),e&&e.length>=2){const n=e[0],r=e[1],o=Math.min(n[0],r[0]),a=Math.max(n[0],r[0]),l=Math.min(n[1],r[1]),h=Math.max(n[1],r[1]),c=[[o,l],[a,l],[a,h],[o,h],[o,l]];i.setCoordinates([c])}return i},style:this.createStyle()}),this.drawInteraction.on("drawend",e=>{const i=e.feature,n=i.getGeometry(),r=_s("rectangle_");if(n instanceof ht){const o=n.getExtent(),a=(o[0]+o[2])/2,l=(o[1]+o[3])/2,h=o[2]-o[0],c=o[3]-o[1],[u,d]=Pt([a,l]);i.set("id",r),i.set("center",[u,d]),i.set("width",h),i.set("height",c),i.setStyle(this.createStyle()),this.features.set(r,i),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:r,center:[u,d],width:h,height:c,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth})}this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null,this.onDrawCompleteCallback=null,this.mapView?.render()}),this.mapView?.addInteraction(this.drawInteraction)}startEdit(t,e){this.stopEdit();const i=this.features.get(t);if(!i){console.error(`Rectangle with id ${t} not found`);return}this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new St;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new Br({features:r,translate:!0,scale:!0,rotate:!1,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0),this.transformInteraction.on("select",()=>{this.transformInteraction?.setActive(!0)}),this.transformInteraction.on("scaleend",()=>{const o=i.getGeometry();if(o instanceof ht){const a=o.getExtent(),l=(a[0]+a[2])/2,h=(a[1]+a[3])/2,c=a[2]-a[0],u=a[3]-a[1],[d,f]=Pt([l,h]),g=i.get("id");this.onEditCompleteCallback&&g&&this.onEditCompleteCallback({id:g,center:[d,f],width:c,height:u})}}),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof ht){const a=o.getExtent(),l=(a[0]+a[2])/2,h=(a[1]+a[3])/2,c=a[2]-a[0],u=a[3]-a[1],[d,f]=Pt([l,h]),g=i.get("id");this.onEditCompleteCallback&&g&&this.onEditCompleteCallback({id:g,center:[d,f],width:c,height:u})}}),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addRectangle(t){const e=te(t.center),i=t.width/2,n=t.height/2,r=[[[e[0]-i,e[1]-n],[e[0]+i,e[1]-n],[e[0]+i,e[1]+n],[e[0]-i,e[1]+n],[e[0]-i,e[1]-n]]],o=new ht(r),a=new ot({geometry:o,id:t.id,center:t.center,width:t.width,height:t.height});a.setStyle(this.createStyle()),this.source?.addFeature(a),this.features.set(t.id,a)}removeRectangle(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllRectangles(){const t=[];return this.features.forEach((e,i)=>{const n=e.getGeometry();if(n instanceof ht){const r=n.getExtent(),o=(r[0]+r[2])/2,a=(r[1]+r[3])/2,l=r[2]-r[0],h=r[3]-r[1],[c,u]=Pt([o,a]);t.push({id:i,center:[c,u],width:l,height:h})}}),t}getRectangle(t){const e=this.features.get(t);if(!e)return;const i=e.getGeometry();if(i instanceof ht){const n=i.getExtent(),r=(n[0]+n[2])/2,o=(n[1]+n[3])/2,a=n[2]-n[0],l=n[3]-n[1],[h,c]=Pt([r,o]);return{id:t,center:[h,c],width:a,height:l}}}updateRectangleStyle(t,e,i,n,r){const o=this.features.get(t);if(!o)return;const a=r==="dashed"?[10,10]:void 0;o.setStyle(new lt({fill:new ut({color:ft(e)}),stroke:new _t({color:ft(i),width:n,lineDash:a})})),o.changed(),this.mapView?.render()}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAllRectangles(){this.clear(),this.features.clear(),this.stopEdit()}updateData(t){t.rectangles&&(this.clearAllRectangles(),t.rectangles.forEach(e=>this.addRectangle(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}isDrawActive(){return this.drawInteraction!==null}isEditActive(){return this.transformInteraction!==null}setEditable(t){t?this.layer.set("pointer-events",!0):(this.stopEdit(),this.stopDraw())}getEditingId(){return this.editingFeature?.get("id")||null}cancelDraw(){this.stopDraw()}cancelEdit(){this.stopEdit()}}class qm extends Ut{constructor(t,e,i){super(t,e,nt.TRIANGLE_DRAW,{...i,zIndex:i?.zIndex??100}),this.drawInteraction=null,this.transformInteraction=null,this.features=new Map,this.onDrawCompleteCallback=null,this.onEditCompleteCallback=null,this.editingFeature=null,this.mapView=null,this.defaultFillColor=i?.defaultFillColor||[255,255,0,.3],this.defaultOutlineColor=i?.defaultOutlineColor||[255,255,0,1],this.defaultOutlineWidth=i?.defaultOutlineWidth||1,this.source=new St,this.layer=new Ht({source:this.source,style:this.createStyle.bind(this),properties:{id:t,name:e,type:nt.TRIANGLE_DRAW},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}createStyle(){return new lt({fill:new ut({color:ft(this.defaultFillColor)}),stroke:new _t({color:ft(this.defaultOutlineColor),width:this.defaultOutlineWidth})})}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}createEquilateralTriangle(t,e){const i=e*Math.sqrt(3)/2;return[[t[0],t[1]+i/2],[t[0]-e/2,t[1]-i/2],[t[0]+e/2,t[1]-i/2],[t[0],t[1]+i/2]]}startDraw(t){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=t||null;let e=[];this.drawInteraction=new ys({source:this.source,type:"LineString",maxPoints:2,geometryFunction:(i,n)=>{if(e=i,e.length<2)return n||(n=new ht([[[0,0],[0,0],[0,0],[0,0]]])),n;const r=e[0],o=e[1],a=o[0]-r[0],l=o[1]-r[1],h=Math.sqrt(a*a+l*l);if(h<.001)return n||(n=new ht([[[0,0],[0,0],[0,0],[0,0]]])),n;const c=(r[0]+o[0])/2,u=(r[1]+o[1])/2,d=h*Math.sqrt(3)/2;let f=-l,g=a;const _=Math.sqrt(f*f+g*g);_>0&&(f/=_,g/=_);const p=c+f*d,m=u+g*d,y=[[p,m],[r[0],r[1]],[o[0],o[1]],[p,m]];return n?n.setCoordinates([y]):n=new ht([y]),n},style:this.createStyle()}),this.drawInteraction.on("drawend",i=>{const n=i.feature,r=n.getGeometry(),o=_s("triangle_");if(r instanceof ht){const a=r.getExtent(),l=(a[0]+a[2])/2,h=(a[1]+a[3])/2,c=Math.max(a[2]-a[0],a[3]-a[1]),[u,d]=Pt([l,h]);n.set("id",o),n.set("center",[u,d]),n.set("size",c),n.setStyle(this.createStyle()),this.features.set(o,n),this.layer?.setZIndex(999),this.onDrawCompleteCallback&&this.onDrawCompleteCallback({id:o,center:[u,d],size:c,fillColor:this.defaultFillColor,outlineColor:this.defaultOutlineColor,outlineWidth:this.defaultOutlineWidth})}this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null,this.onDrawCompleteCallback=null,this.mapView?.render()}),this.mapView?.addInteraction(this.drawInteraction)}startEdit(t,e){this.stopEdit();const i=this.features.get(t);if(!i){console.error(`Triangle with id ${t} not found`);return}this.editingFeature=i,this.onEditCompleteCallback=e||null;const n=new St;n.addFeature(i);const r=n.getFeaturesCollection();this.transformInteraction=new Br({features:r,translate:!0,scale:!0,rotate:!1,keepAspectRatio:()=>!1}),this.transformInteraction.setActive(!0),this.transformInteraction.on("select",()=>{this.transformInteraction?.setActive(!0)}),this.transformInteraction.on("scaleend",()=>{const o=i.getGeometry();if(o instanceof ht){const a=o.getExtent(),l=(a[0]+a[2])/2,h=(a[1]+a[3])/2,c=Math.max(a[2]-a[0],a[3]-a[1]),[u,d]=Pt([l,h]),f=i.get("id"),g=this.createEquilateralTriangle([l,h],c),_=new ht([g]);i.setGeometry(_),this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,center:[u,d],size:c})}}),this.transformInteraction.on("translateend",()=>{const o=i.getGeometry();if(o instanceof ht){const a=o.getExtent(),l=(a[0]+a[2])/2,h=(a[1]+a[3])/2,c=Math.max(a[2]-a[0],a[3]-a[1]),[u,d]=Pt([l,h]),f=i.get("id");this.onEditCompleteCallback&&f&&this.onEditCompleteCallback({id:f,center:[u,d],size:c})}}),this.mapView?.addInteraction(this.transformInteraction)}stopEdit(){this.transformInteraction&&(this.mapView?.removeInteraction(this.transformInteraction),this.transformInteraction=null),this.editingFeature=null,this.onEditCompleteCallback=null}addTriangle(t){const e=te(t.center),i=this.createEquilateralTriangle(e,t.size),n=new ht([i]),r=new ot({geometry:n,id:t.id,center:t.center,size:t.size});r.setStyle(this.createStyle()),this.source?.addFeature(r),this.features.set(t.id,r)}removeTriangle(t){const e=this.features.get(t);e&&(this.source?.removeFeature(e),this.features.delete(t),this.editingFeature===e&&this.stopEdit())}getAllTriangles(){const t=[];return this.features.forEach((e,i)=>{const n=e.getGeometry();if(n instanceof ht){const r=n.getExtent(),o=(r[0]+r[2])/2,a=(r[1]+r[3])/2,l=Math.max(r[2]-r[0],r[3]-r[1]),[h,c]=Pt([o,a]);t.push({id:i,center:[h,c],size:l})}}),t}getTriangle(t){const e=this.features.get(t);if(!e)return;const i=e.getGeometry();if(i instanceof ht){const n=i.getExtent(),r=(n[0]+n[2])/2,o=(n[1]+n[3])/2,a=Math.max(n[2]-n[0],n[3]-n[1]),[l,h]=Pt([r,o]);return{id:t,center:[l,h],size:a}}}updateTriangleStyle(t,e,i,n,r){const o=this.features.get(t);if(!o)return;const a=r==="dashed"?[10,10]:void 0;o.setStyle(new lt({fill:new ut({color:ft(e)}),stroke:new _t({color:ft(i),width:n,lineDash:a})})),o.changed(),this.mapView?.render()}stopDraw(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onDrawCompleteCallback=null}clearAllTriangles(){this.clear(),this.features.clear(),this.stopEdit()}updateData(t){t.triangles&&(this.clearAllTriangles(),t.triangles.forEach(e=>this.addTriangle(e)))}destroy(){this.stopDraw(),this.stopEdit(),super.destroy()}isDrawActive(){return this.drawInteraction!==null}isEditActive(){return this.transformInteraction!==null}setEditable(t){t?this.layer.set("pointer-events",!0):(this.stopEdit(),this.stopDraw())}getEditingId(){return this.editingFeature?.get("id")||null}cancelDraw(){this.stopDraw()}cancelEdit(){this.stopEdit()}}class Eu extends Ut{constructor(t,e,i){super(t,e,nt.DISTANCE_MEASUREMENT,{...i,zIndex:i?.zIndex??50}),this.drawInteraction=null,this.measurements=new Map,this.onCompleteCallback=null,this.mapView=null,this.lineColor=i?.lineColor||[0,170,255,1],this.lineWidth=i?.lineWidth||2,this.source=new St,this.layer=new Ht({source:this.source,properties:{id:t,name:e,type:nt.DISTANCE_MEASUREMENT},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startMeasure(t){this.stopMeasure(),this.onCompleteCallback=t||null,this.drawInteraction=new ys({source:this.source,type:"LineString"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,r=i.getGeometry().getCoordinates(),o=r.map(d=>{const[f,g]=Pt(d);return{longitude:f,latitude:g}});let a=0;for(let d=0;d<o.length-1;d++)a+=this.calculateDistance(o[d],o[d+1]);const l=_s("dist_"),h=Math.floor(o.length/2),c=a>=1e3?`${(a/1e3).toFixed(2)} km`:`${a.toFixed(0)} m`,u=new ot({geometry:new gt([r[h][0],r[h][1]]),measurementId:l});u.setStyle(new lt({text:new vn({text:c,font:"14px sans-serif",fill:new ut({color:"#ffffff"}),stroke:new _t({color:"#000000",width:2}),offsetY:-10,textAlign:"center"})})),this.measurements.set(l,{id:l,points:o,distance:a}),i.set("measurementId",l),i.set("type","distance"),i.setStyle(new lt({stroke:new _t({color:ft(this.lineColor),width:this.lineWidth})})),this.source?.addFeature(u),this.onCompleteCallback&&this.onCompleteCallback({points:o,distance:a,id:l,isDrawing:!1}),this.stopMeasure()}),this.mapView?.addInteraction(this.drawInteraction)}calculateDistance(t,e){const i=new fe([[t.longitude,t.latitude],[e.longitude,e.latitude]]);return Yh(i,{projection:"EPSG:4326"})}stopMeasure(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onCompleteCallback=null}deleteMeasurement(t){if(this.measurements.get(t)){let i=[];return this.source?.forEachFeature(n=>{n.get("measurementId")===t&&i.push(n)}),i.forEach(n=>this.source?.removeFeature(n)),this.measurements.delete(t),!0}return!1}findMeasurementIdByGraphic(t){return t.get("measurementId")||null}clearAllMeasurements(){this.clear(),this.measurements.clear(),this.stopMeasure()}getAllMeasurements(){return Array.from(this.measurements.values())}isCurrentlyMeasuring(){return this.drawInteraction!==null}updateData(t){}}class vu extends Ut{constructor(t,e,i){super(t,e,nt.AREA_MEASUREMENT,{...i,zIndex:i?.zIndex??50}),this.drawInteraction=null,this.measurements=new Map,this.onCompleteCallback=null,this.mapView=null,this.fillColor=i?.fillColor||[0,170,255,.2],this.lineColor=i?.lineColor||[0,170,255,1],this.lineWidth=i?.lineWidth||2,this.source=new St,this.layer=new Ht({source:this.source,properties:{id:t,name:e,type:nt.AREA_MEASUREMENT},visible:this.visible,opacity:this.opacity,zIndex:this.zIndex})}setView(t){this.mapView=t}createLayer(t){return t.addLayer(this.layer),this.layer}startMeasure(t){this.stopMeasure(),this.onCompleteCallback=t||null,this.drawInteraction=new ys({source:this.source,type:"Polygon"}),this.drawInteraction.on("drawend",e=>{const i=e.feature,n=i.getGeometry(),r=n.getCoordinates()[0],o=r.map(f=>{const[g,_]=Pt(f);return{longitude:g,latitude:_}}).slice(0,-1),a=Zh(n),l=_s("area_");let h=0,c=0;for(const f of r.slice(0,-1))h+=f[0],c+=f[1];h/=r.length-1,c/=r.length-1;const u=a>=1e6?`${(a/1e6).toFixed(2)} km²`:`${a.toFixed(0)} m²`,d=new ot({geometry:new gt([h,c]),measurementId:l});d.setStyle(new lt({text:new vn({text:u,font:"14px sans-serif",fill:new ut({color:"#ffffff"}),stroke:new _t({color:"#000000",width:2}),textAlign:"center"})})),this.measurements.set(l,{id:l,points:o,area:a}),i.set("measurementId",l),i.set("type","area"),i.setStyle(new lt({fill:new ut({color:ft(this.fillColor)}),stroke:new _t({color:ft(this.lineColor),width:this.lineWidth})})),this.source?.addFeature(d),this.onCompleteCallback&&this.onCompleteCallback({id:l,points:o,area:a}),this.stopMeasure()}),this.mapView?.addInteraction(this.drawInteraction)}stopMeasure(){this.drawInteraction&&(this.mapView?.removeInteraction(this.drawInteraction),this.drawInteraction=null),this.onCompleteCallback=null}deleteMeasurement(t){if(this.measurements.get(t)){let i=[];return this.source?.forEachFeature(n=>{n.get("measurementId")===t&&i.push(n)}),i.forEach(n=>this.source?.removeFeature(n)),this.measurements.delete(t),!0}return!1}findMeasurementIdByGraphic(t){return t.get("measurementId")||null}clearAllMeasurements(){this.clear(),this.measurements.clear(),this.stopMeasure()}getAllMeasurements(){return Array.from(this.measurements.values())}isCurrentlyMeasuring(){return this.drawInteraction!==null}updateData(t){}}const xt={Layers:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 2 7 12 12 22 7 12 2"/><polyline points="2 17 12 22 22 17"/><polyline points="2 12 12 17 22 12"/></svg>',Basemap:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>',Draw:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="M2 2l7.586 7.586"/><circle cx="11" cy="11" r="2"/></svg>',Tools:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>',ZoomIn:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>',ZoomOut:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="8" y1="11" x2="14" y2="11"/></svg>',Locate:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 2v4M12 22v-4M2 12h4M22 12h-4"/><circle cx="12" cy="12" r="3"/></svg>',Eye:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',EyeOff:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>',Delete:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',Close:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',Check:'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',Circle:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/></svg>',Ruler:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 2v20M8 2v20M12 2v20M16 2v20M20 2v20"/><line x1="4" y1="6" x2="20" y2="6"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>',Area:'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="3 3 21 3 21 21 3 21 3 3"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>',DragHandle:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="8" r="1"/><circle cx="9" cy="16" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="8" r="1"/><circle cx="15" cy="16" r="1"/></svg>',StrokeWidth:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12" stroke-width="3"/><line x1="3" y1="18" x2="21" y2="18" stroke-width="4"/></svg>',StrokeStyle:'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="12" x2="21" y2="12" stroke-dasharray="4 4"/></svg>'};class Jm{constructor(t){this.buttons=new Map,this.options=t,this.element=this.createElement(),t.container.appendChild(this.element)}createElement(){const t=this.options.theme==="dark",e=document.createElement("div");e.style.cssText=`
|
|
698
|
+
position: absolute;
|
|
699
|
+
top: 10px;
|
|
700
|
+
right: 10px;
|
|
701
|
+
z-index: 100;
|
|
702
|
+
display: flex;
|
|
703
|
+
flex-direction: column;
|
|
704
|
+
gap: 8px;
|
|
705
|
+
background: ${t?"rgba(0,0,0,0.7)":"rgba(255,255,255,0.9)"};
|
|
706
|
+
padding: 8px;
|
|
707
|
+
border-radius: 8px;
|
|
708
|
+
backdrop-filter: blur(4px);
|
|
709
|
+
`;const i=d=>`
|
|
710
|
+
width: 30px;
|
|
711
|
+
height: 30px;
|
|
712
|
+
background: ${d?"#00aaff":t?"#2d2d2d":"#f0f0f0"};
|
|
713
|
+
border: 1px solid ${t?"#444":"#ddd"};
|
|
714
|
+
border-radius: 6px;
|
|
715
|
+
color: ${d?"white":t?"#ccc":"#666"};
|
|
716
|
+
cursor: pointer;
|
|
717
|
+
display: flex;
|
|
718
|
+
align-items: center;
|
|
719
|
+
justify-content: center;
|
|
720
|
+
transition: all 0.2s;
|
|
721
|
+
`,n=this.createButton(xt.Layers,"layers",i);n.title=this.options.t.layersTitle,e.appendChild(n),this.buttons.set("layers",n);const r=this.createButton(xt.Basemap,"basemap",i);r.title=this.options.t.basemapTitle,e.appendChild(r),this.buttons.set("basemap",r);const o=this.createButton(xt.Draw,"draw",i);o.title=this.options.t.drawToolsTitle,e.appendChild(o),this.buttons.set("draw",o);const a=this.createButton(xt.Tools,"tools",i);a.title=this.options.t.toolsTitle,e.appendChild(a),this.buttons.set("tools",a);const l=document.createElement("div");l.style.cssText=`height: 1px; background: ${t?"#444":"#ddd"}; margin: 4px 0;`,e.appendChild(l);const h=this.createButton(xt.ZoomIn,null,i);h.title=this.options.t.zoomInTitle,h.onclick=()=>this.options.onZoomIn(),e.appendChild(h);const c=this.createButton(xt.ZoomOut,null,i);c.title=this.options.t.zoomOutTitle,c.onclick=()=>this.options.onZoomOut(),e.appendChild(c);const u=this.createButton(xt.Locate,null,i);return u.title=this.options.t.locateMe,u.onclick=()=>this.options.onLocate(),e.appendChild(u),e}createButton(t,e,i){const n=document.createElement("button"),r=e!==null&&this.options.activePopup===e;return n.style.cssText=i(r),n.innerHTML=t,e!==null&&(n.onclick=()=>{const o=this.options.activePopup===e?null:e;this.options.onTogglePopup(o)}),n}updateActivePopup(t){const e=this.options.theme==="dark",i=n=>`
|
|
722
|
+
width: 30px;
|
|
723
|
+
height: 30px;
|
|
724
|
+
background: ${n?"#00aaff":e?"#2d2d2d":"#f0f0f0"};
|
|
725
|
+
border: 1px solid ${e?"#444":"#ddd"};
|
|
726
|
+
border-radius: 6px;
|
|
727
|
+
color: ${n?"white":e?"#ccc":"#666"};
|
|
728
|
+
cursor: pointer;
|
|
729
|
+
display: flex;
|
|
730
|
+
align-items: center;
|
|
731
|
+
justify-content: center;
|
|
732
|
+
transition: all 0.2s;
|
|
733
|
+
`;this.buttons.forEach((n,r)=>{const o=r===t;n.style.cssText=i(o)})}updateTheme(t){this.options.theme=t;const e=t==="dark";this.element.style.background=e?"rgba(0,0,0,0.7)":"rgba(255,255,255,0.9)";const i=n=>`
|
|
734
|
+
width: 30px;
|
|
735
|
+
height: 30px;
|
|
736
|
+
background: ${n?"#00aaff":e?"#2d2d2d":"#f0f0f0"};
|
|
737
|
+
border: 1px solid ${e?"#444":"#ddd"};
|
|
738
|
+
border-radius: 6px;
|
|
739
|
+
color: ${n?"white":e?"#ccc":"#666"};
|
|
740
|
+
cursor: pointer;
|
|
741
|
+
display: flex;
|
|
742
|
+
align-items: center;
|
|
743
|
+
justify-content: center;
|
|
744
|
+
transition: all 0.2s;
|
|
745
|
+
`;this.buttons.forEach((n,r)=>{const o=r===this.options.activePopup;n.style.cssText=i(o)})}destroy(){this.element.remove()}}class Zs{constructor(t){this.options=t,this.element=this.createElement()}createElement(){const t=this.options.theme==="dark",e=document.createElement("div");e.style.cssText=`
|
|
746
|
+
position: absolute;
|
|
747
|
+
top: 10px;
|
|
748
|
+
right: 60px;
|
|
749
|
+
width: 200px;
|
|
750
|
+
max-height: 260px;
|
|
751
|
+
background: ${t?"#1e1e1e":"#ffffff"};
|
|
752
|
+
border: 1px solid ${t?"#333":"#e0e0e0"};
|
|
753
|
+
border-radius: 8px;
|
|
754
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
755
|
+
z-index: 200;
|
|
756
|
+
overflow: hidden;
|
|
757
|
+
`;const i=document.createElement("div");i.style.cssText=`
|
|
758
|
+
display: flex;
|
|
759
|
+
justify-content: space-between;
|
|
760
|
+
align-items: center;
|
|
761
|
+
padding: 8px 10px;
|
|
762
|
+
border-bottom: 1px solid ${t?"#333":"#e0e0e0"};
|
|
763
|
+
background: ${t?"#2d2d2d":"#f5f5f5"};
|
|
764
|
+
`;const n=document.createElement("span");n.style.cssText=`color: ${t?"#fff":"#333"}; font-size: 12px; font-weight: 500;`,n.textContent=this.options.title,i.appendChild(n);const r=document.createElement("button");return r.style.cssText=`
|
|
765
|
+
background: none;
|
|
766
|
+
border: none;
|
|
767
|
+
cursor: pointer;
|
|
768
|
+
display: flex;
|
|
769
|
+
align-items: center;
|
|
770
|
+
justify-content: center;
|
|
771
|
+
padding: 2px;
|
|
772
|
+
color: ${t?"#ccc":"#666"};
|
|
773
|
+
`,r.innerHTML=xt.Close,r.title=this.options.t.close,r.onclick=()=>this.options.onClose(),i.appendChild(r),e.appendChild(i),this.contentContainer=document.createElement("div"),this.contentContainer.style.cssText=`
|
|
774
|
+
max-height: 210px;
|
|
775
|
+
overflow-y: auto;
|
|
776
|
+
padding: 4px 0;
|
|
777
|
+
`,this.contentContainer.className="earthview-popup-scroll",e.appendChild(this.contentContainer),this.injectScrollbarStyles(t),e}injectScrollbarStyles(t){if(document.getElementById("earthview-popup-scroll-styles")){const i=document.getElementById("earthview-popup-scroll-styles");i&&(i.textContent=this.getScrollbarStyles(t));return}const e=document.createElement("style");e.id="earthview-popup-scroll-styles",e.textContent=this.getScrollbarStyles(t),document.head.appendChild(e)}getScrollbarStyles(t){const e=t?"#555":"#ccc",i=t?"#2d2d2d":"#f0f0f0";return`
|
|
778
|
+
.earthview-popup-scroll {
|
|
779
|
+
scrollbar-width: thin;
|
|
780
|
+
scrollbar-color: ${e} ${i};
|
|
781
|
+
}
|
|
782
|
+
.earthview-popup-scroll::-webkit-scrollbar {
|
|
783
|
+
width: 4px;
|
|
784
|
+
}
|
|
785
|
+
.earthview-popup-scroll::-webkit-scrollbar-track {
|
|
786
|
+
background: ${i};
|
|
787
|
+
border-radius: 4px;
|
|
788
|
+
}
|
|
789
|
+
.earthview-popup-scroll::-webkit-scrollbar-thumb {
|
|
790
|
+
background: ${e};
|
|
791
|
+
border-radius: 4px;
|
|
792
|
+
}
|
|
793
|
+
.earthview-popup-scroll::-webkit-scrollbar-thumb:hover {
|
|
794
|
+
background: ${t?"#777":"#aaa"};
|
|
795
|
+
}
|
|
796
|
+
`}getContentContainer(){return this.contentContainer}appendChild(t){this.contentContainer.appendChild(t)}updateTheme(t){const e=t==="dark";this.element.style.background=e?"#1e1e1e":"#ffffff",this.element.style.borderColor=e?"#333":"#e0e0e0";const i=this.element.querySelector("div:first-child");if(i){i.style.borderBottomColor=e?"#333":"#e0e0e0",i.style.background=e?"#2d2d2d":"#f5f5f5";const r=i.querySelector("span");r&&(r.style.color=e?"#fff":"#333");const o=i.querySelector("button");o&&(o.style.color=e?"#ccc":"#666")}const n=document.getElementById("earthview-popup-scroll-styles");n&&(n.textContent=this.getScrollbarStyles(e))}destroy(){this.element.remove()}getElement(){return this.element}}class Qm{constructor(t){this.options=t,this.element=this.createElement(),this.render()}createElement(){const t=document.createElement("div");return t.style.cssText=`
|
|
797
|
+
width: 100%;
|
|
798
|
+
height: 100%;
|
|
799
|
+
`,t}render(){if(this.element.innerHTML="",this.options.layerList.length===0){const e=document.createElement("div");e.style.cssText=`
|
|
800
|
+
padding: 16px;
|
|
801
|
+
text-align: center;
|
|
802
|
+
color: ${this.options.theme==="dark"?"#888":"#999"};
|
|
803
|
+
font-size: 12px;
|
|
804
|
+
`,e.textContent=this.options.t.noLayers,this.element.appendChild(e);return}const t=this.options.theme==="dark";for(const e of this.options.layerList){const i=document.createElement("div");i.style.cssText=`
|
|
805
|
+
display: flex;
|
|
806
|
+
align-items: center;
|
|
807
|
+
justify-content: space-between;
|
|
808
|
+
padding: 6px 12px;
|
|
809
|
+
border-bottom: 1px solid ${t?"#333":"#eee"};
|
|
810
|
+
`;const n=document.createElement("div");n.style.cssText="display: flex; align-items: center; gap: 8px; flex: 1;";const r=document.createElement("button");r.style.cssText=`
|
|
811
|
+
background: none;
|
|
812
|
+
border: none;
|
|
813
|
+
cursor: pointer;
|
|
814
|
+
display: flex;
|
|
815
|
+
align-items: center;
|
|
816
|
+
justify-content: center;
|
|
817
|
+
padding: 2px;
|
|
818
|
+
color: ${e.visible?t?"#00aaff":"#0077cc":t?"#888":"#ccc"};
|
|
819
|
+
`,r.innerHTML=e.visible?xt.Eye:xt.EyeOff,r.title=e.visible?this.options.t.hideLayer:this.options.t.showLayer,r.onclick=()=>this.options.onToggleVisibility(e.id),n.appendChild(r);const o=document.createElement("span");if(o.style.cssText=`color: ${t?"#fff":"#333"}; font-size: 12px; flex: 1;`,o.textContent=e.name,n.appendChild(o),i.appendChild(n),e.id!=="circle-draw"&&e.id!=="distance-measurement"&&e.id!=="area-measurement"){const a=document.createElement("button");a.style.cssText=`
|
|
820
|
+
background: none;
|
|
821
|
+
border: none;
|
|
822
|
+
cursor: pointer;
|
|
823
|
+
display: flex;
|
|
824
|
+
align-items: center;
|
|
825
|
+
justify-content: center;
|
|
826
|
+
padding: 2px;
|
|
827
|
+
color: #f44336;
|
|
828
|
+
`,a.innerHTML=xt.Delete,a.title=this.options.t.deleteLayerTitle,a.onclick=()=>this.options.onRemoveLayer(e.id),i.appendChild(a)}this.element.appendChild(i)}}updateData(t){this.options.layerList=t,this.render()}updateTheme(t){this.options.theme=t,this.render()}getElement(){return this.element}}class ty{constructor(t){this.props=t,this.element=this.createElement(),this.render()}createElement(){const t=document.createElement("div");return t.style.cssText=`
|
|
829
|
+
width: 100%;
|
|
830
|
+
height: 100%;
|
|
831
|
+
`,t}render(){this.element.innerHTML="";const t=this.props.theme==="dark";for(const e of this.props.options){const i=document.createElement("div");i.style.cssText=`
|
|
832
|
+
display: flex;
|
|
833
|
+
align-items: center;
|
|
834
|
+
gap: 10px;
|
|
835
|
+
padding: 8px 12px;
|
|
836
|
+
cursor: pointer;
|
|
837
|
+
background: ${this.props.currentBasemap===e.value?t?"#2a2a2a":"#f0f0f0":"transparent"};
|
|
838
|
+
border-left: ${this.props.currentBasemap===e.value?"3px solid #00aaff":"3px solid transparent"};
|
|
839
|
+
transition: all 0.2s;
|
|
840
|
+
`,i.onmouseenter=()=>{this.props.currentBasemap!==e.value&&(i.style.background=t?"#2a2a2a":"#f5f5f5")},i.onmouseleave=()=>{this.props.currentBasemap!==e.value&&(i.style.background="transparent")},i.onclick=()=>this.props.onSelect(e.value);const n=document.createElement("span");n.style.cssText="font-size: 14px;",n.textContent=e.icon,i.appendChild(n);const r=document.createElement("span");if(r.style.cssText=`color: ${t?"#fff":"#333"}; font-size: 12px; flex: 1;`,r.textContent=e.label,i.appendChild(r),this.props.currentBasemap===e.value){const o=document.createElement("span");o.innerHTML=xt.Check,o.style.cssText="color: #00aaff;",i.appendChild(o)}this.element.appendChild(i)}}updateCurrentBasemap(t){this.props.currentBasemap=t,this.render()}updateTheme(t){this.props.theme=t,this.render()}getElement(){return this.element}}class ey{constructor(t){this.props=t,this.element=this.createElement(),this.render()}createElement(){const t=document.createElement("div");return t.style.cssText=`
|
|
841
|
+
width: 100%;
|
|
842
|
+
height: 100%;
|
|
843
|
+
`,t}render(){this.element.innerHTML="",this.props.theme;const t=this.createToolRow(xt.Circle,this.props.t.drawCircle,this.props.onDrawCircle);this.element.appendChild(t);const e=this.createToolRow(this.createRectangleIcon(),"绘制矩形",this.props.onDrawRectangle);this.element.appendChild(e);const i=this.createToolRow(this.createTriangleIcon(),"绘制三角形",this.props.onDrawTriangle);this.element.appendChild(i)}createToolRow(t,e,i){const n=this.props.theme==="dark",r=document.createElement("div");r.style.cssText=`
|
|
844
|
+
display: flex;
|
|
845
|
+
align-items: center;
|
|
846
|
+
gap: 10px;
|
|
847
|
+
padding: 8px 12px;
|
|
848
|
+
cursor: pointer;
|
|
849
|
+
border-bottom: 1px solid ${n?"#333":"#eee"};
|
|
850
|
+
transition: all 0.2s;
|
|
851
|
+
`,r.onmouseenter=()=>{r.style.background=n?"#2a2a2a":"#f5f5f5"},r.onmouseleave=()=>{r.style.background="transparent"},r.onclick=i;const o=document.createElement("span");o.innerHTML=t,r.appendChild(o);const a=document.createElement("span");return a.style.cssText=`color: ${n?"#fff":"#333"}; font-size: 12px;`,a.textContent=e,r.appendChild(a),r}createRectangleIcon(){return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
852
|
+
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
|
|
853
|
+
</svg>`}createTriangleIcon(){return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
854
|
+
<polygon points="12 2 22 22 2 22 12 2"/>
|
|
855
|
+
</svg>`}createEditIcon(){return`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
856
|
+
<path d="M17 3l4 4-7 7-4 1 1-4 7-7z"/>
|
|
857
|
+
<path d="M12 7L4 15v4h4l8-8"/>
|
|
858
|
+
</svg>`}updateTheme(t){this.props.theme=t,this.render()}getElement(){return this.element}}class iy{constructor(t){this.props=t,this.element=this.createElement(),this.render()}createElement(){const t=document.createElement("div");return t.style.cssText=`
|
|
859
|
+
width: 100%;
|
|
860
|
+
height: 100%;
|
|
861
|
+
`,t}render(){this.element.innerHTML="",this.props.theme;const t=this.createMeasureRow(xt.Ruler,this.props.t.distanceMeasure,"distance",this.props.onDistanceMeasure);this.element.appendChild(t);const e=this.createMeasureRow(xt.Area,this.props.t.areaMeasure,"area",this.props.onAreaMeasure);this.element.appendChild(e)}createMeasureRow(t,e,i,n){const r=this.props.theme==="dark",o=this.props.isMeasuring&&this.props.currentMeasureType===i,a=document.createElement("div");a.style.cssText=`
|
|
862
|
+
display: flex;
|
|
863
|
+
align-items: center;
|
|
864
|
+
gap: 10px;
|
|
865
|
+
padding: 8px 12px;
|
|
866
|
+
cursor: pointer;
|
|
867
|
+
border-bottom: 1px solid ${r?"#333":"#eee"};
|
|
868
|
+
background: ${o?r?"#2a4a6a":"#e3f2fd":"transparent"};
|
|
869
|
+
transition: all 0.2s;
|
|
870
|
+
`,a.onmouseenter=()=>{o||(a.style.background=r?"#2a2a2a":"#f5f5f5")},a.onmouseleave=()=>{o||(a.style.background="transparent")},a.onclick=n;const l=document.createElement("span");l.innerHTML=t,a.appendChild(l);const h=document.createElement("span");if(h.style.cssText=`color: ${r?"#fff":"#333"}; font-size: 12px; flex: 1;`,h.textContent=e,a.appendChild(h),o&&this.props.measurePreview){const c=this.props.measurePreview;let u="";if(i==="distance"&&c.distance!==void 0?u=c.distance>=1e3?`${(c.distance/1e3).toFixed(1)}km`:`${c.distance.toFixed(0)}m`:i==="area"&&c.area!==void 0&&(u=c.area>=1e6?`${(c.area/1e6).toFixed(1)}km²`:`${c.area.toFixed(0)}m²`),u){const d=document.createElement("span");d.style.cssText="color: #00aaff; font-size: 10px;",d.textContent=u,a.appendChild(d)}}if(o){const c=document.createElement("span");c.style.cssText="color: #00aaff; font-size: 10px;",c.textContent="●",a.appendChild(c)}return a}updateData(t){Object.assign(this.props,t),this.render()}updateTheme(t){this.props.theme=t,this.render()}getElement(){return this.element}}class Mo{constructor(t){this.isDragging=!1,this.dragStart={x:0,y:0},this.positionStart={x:0,y:0},this.colorPickerPanel=null,this.strokeStylePanel=null,this.strokeWidthPanel=null,this.activePicker=null,this.options=t,this.position=t.position||{x:100,y:100},this.element=this.createElement(),t.containerRef.appendChild(this.element),this.element.style.visibility="hidden",this.position=this.constrainPosition(this.position),this.element.style.left=`${this.position.x}px`,this.element.style.top=`${this.position.y}px`,this.element.style.visibility="visible",this.attachDragEvents()}createElement(){const t=this.options.theme==="dark",e=document.createElement("div");e.style.cssText=`
|
|
871
|
+
position: absolute;
|
|
872
|
+
left: ${this.position.x}px;
|
|
873
|
+
top: ${this.position.y}px;
|
|
874
|
+
z-index: 200;
|
|
875
|
+
display: flex;
|
|
876
|
+
align-items: center;
|
|
877
|
+
gap: 6px;
|
|
878
|
+
background: ${t?"rgba(30,30,30,0.95)":"rgba(255,255,255,0.95)"};
|
|
879
|
+
border: 1px solid ${t?"#444":"#ddd"};
|
|
880
|
+
border-radius: 8px;
|
|
881
|
+
padding: 6px 8px;
|
|
882
|
+
backdrop-filter: blur(8px);
|
|
883
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
884
|
+
cursor: default;
|
|
885
|
+
`;const i=`
|
|
886
|
+
width: 28px;
|
|
887
|
+
height: 28px;
|
|
888
|
+
background: ${t?"#2d2d2d":"#f0f0f0"};
|
|
889
|
+
border: 1px solid ${t?"#444":"#ddd"};
|
|
890
|
+
border-radius: 6px;
|
|
891
|
+
color: ${t?"#ccc":"#666"};
|
|
892
|
+
cursor: pointer;
|
|
893
|
+
display: flex;
|
|
894
|
+
align-items: center;
|
|
895
|
+
justify-content: center;
|
|
896
|
+
transition: all 0.2s;
|
|
897
|
+
flex-shrink: 0;
|
|
898
|
+
`,n=document.createElement("div");n.style.cssText=`
|
|
899
|
+
${i}
|
|
900
|
+
width: 20px;
|
|
901
|
+
cursor: grab;
|
|
902
|
+
background: ${t?"#3d3d3d":"#e8e8e8"};
|
|
903
|
+
`,n.innerHTML=xt.DragHandle,n.onmousedown=this.onMouseDown.bind(this),e.appendChild(n);const r=document.createElement("button");r.style.cssText=`${i} background: transparent; padding: 2px;`,r.innerHTML=`<div style="width: 20px; height: 20px; background: rgba(${this.options.currentColor[0]}, ${this.options.currentColor[1]}, ${this.options.currentColor[2]}, ${this.options.currentColor[3]||1}); border-radius: 4px; border: 1px solid ${t?"#666":"#ccc"};"></div>`,r.title=this.options.t.colorTitle,r.onclick=()=>this.showColorPicker(r),e.appendChild(r);const o=document.createElement("button");o.style.cssText=i,o.innerHTML=xt.StrokeWidth,o.title=this.options.t.strokeWidthTitle,o.onclick=()=>this.showStrokeWidthPicker(o),e.appendChild(o);const a=document.createElement("button");a.style.cssText=`${i} border-style: ${this.options.currentStrokeStyle==="dashed"?"dashed":"solid"};`,a.innerHTML=xt.StrokeStyle,a.title=this.options.t.strokeStyleTitle,a.onclick=()=>this.showStrokeStylePicker(a),e.appendChild(a);const l=document.createElement("button");l.style.cssText=i,l.innerHTML=xt.Delete,l.title=this.options.t.deleteTitle,l.onclick=()=>this.options.onDelete(),e.appendChild(l);const h=document.createElement("button");return h.style.cssText=i,h.innerHTML=xt.Close,h.title=this.options.t.closeTitle,h.onclick=()=>this.options.onClose(),e.appendChild(h),e}onMouseDown(t){t.preventDefault(),this.isDragging=!0,this.dragStart={x:t.clientX,y:t.clientY},this.positionStart={x:this.position.x,y:this.position.y},document.addEventListener("mousemove",this.onMouseMove.bind(this)),document.addEventListener("mouseup",this.onMouseUp.bind(this)),document.body.style.userSelect="none"}onMouseMove(t){if(!this.isDragging)return;const e=t.clientX-this.dragStart.x,i=t.clientY-this.dragStart.y;let n=this.positionStart.x+e,r=this.positionStart.y+i;this.position=this.constrainPosition({x:n,y:r}),this.element.style.left=`${this.position.x}px`,this.element.style.top=`${this.position.y}px`,this.options.onPositionChange(this.position)}constrainPosition(t){const e=this.options.containerRef.getBoundingClientRect(),i=this.element.getBoundingClientRect();let n=i.width,r=i.height;(n===0||r===0)&&(n=200,r=48);const o=0,a=0,l=Math.max(0,e.width-n),h=Math.max(0,e.height-r);return{x:Math.max(o,Math.min(t.x,l)),y:Math.max(a,Math.min(t.y,h))}}showAtPosition(t){this.element.style.opacity="0",this.element.style.display="flex",requestAnimationFrame(()=>{const e=this.constrainPosition(t);this.position=e,this.element.style.left=`${e.x}px`,this.element.style.top=`${e.y}px`,this.element.style.opacity="1"})}onMouseUp(){this.isDragging=!1,document.removeEventListener("mousemove",this.onMouseMove.bind(this)),document.removeEventListener("mouseup",this.onMouseUp.bind(this)),document.body.style.userSelect=""}showColorPicker(t){this.hideAllPickers(),this.activePicker="color";const e=t.getBoundingClientRect(),i=this.options.containerRef.getBoundingClientRect();this.colorPickerPanel=this.createColorPicker(),this.colorPickerPanel.style.position="absolute",this.colorPickerPanel.style.left=`${e.left-i.left-110}px`,this.colorPickerPanel.style.top=`${e.top-i.top-200}px`,this.options.containerRef.appendChild(this.colorPickerPanel)}showStrokeWidthPicker(t){this.hideAllPickers(),this.activePicker="width";const e=t.getBoundingClientRect(),i=this.options.containerRef.getBoundingClientRect();this.strokeWidthPanel=this.createStrokeWidthPicker(),this.strokeWidthPanel.style.position="absolute",this.strokeWidthPanel.style.left=`${e.left-i.left-65}px`,this.strokeWidthPanel.style.top=`${e.top-i.top-200}px`,this.options.containerRef.appendChild(this.strokeWidthPanel)}showStrokeStylePicker(t){this.hideAllPickers(),this.activePicker="style";const e=t.getBoundingClientRect(),i=this.options.containerRef.getBoundingClientRect();this.strokeStylePanel=this.createStrokeStylePicker(),this.strokeStylePanel.style.position="absolute",this.strokeStylePanel.style.left=`${e.left-i.left-80}px`,this.strokeStylePanel.style.top=`${e.top-i.top-80}px`,this.options.containerRef.appendChild(this.strokeStylePanel)}createColorPicker(){const t=this.options.theme==="dark",e=[[255,0,0,1],[255,50,50,1],[255,100,100,1],[220,20,60,1],[255,165,0,1],[255,140,0,1],[255,120,0,1],[255,100,0,1],[255,255,0,1],[255,235,0,1],[255,215,0,1],[240,230,140,1],[0,255,0,1],[0,200,0,1],[0,150,0,1],[34,139,34,1],[0,255,255,1],[0,200,200,1],[0,150,150,1],[64,224,208,1],[0,0,255,1],[0,0,200,1],[0,0,150,1],[25,25,112,1],[128,0,128,1],[138,43,226,1],[153,50,204,1],[186,85,211,1],[255,192,203,1],[255,105,180,1],[255,20,147,1],[219,112,147,1],[139,69,19,1],[160,82,45,1],[210,105,30,1],[205,133,63,1],[255,255,255,1],[211,211,211,1],[128,128,128,1],[64,64,64,1],[0,0,0,1],[30,30,30,1],[50,50,50,1],[80,80,80,1]],i=document.createElement("div");i.style.cssText=`
|
|
904
|
+
background: ${t?"#2d2d2d":"#ffffff"};
|
|
905
|
+
border: 1px solid ${t?"#444":"#ddd"};
|
|
906
|
+
border-radius: 8px;
|
|
907
|
+
padding: 8px;
|
|
908
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
909
|
+
width: 220px;
|
|
910
|
+
z-index: 300;
|
|
911
|
+
`;const n=document.createElement("div");n.style.cssText=`
|
|
912
|
+
display: grid;
|
|
913
|
+
grid-template-columns: repeat(8, 1fr);
|
|
914
|
+
gap: 4px;
|
|
915
|
+
`;for(const r of e){const o=document.createElement("button");o.style.cssText=`
|
|
916
|
+
width: 22px;
|
|
917
|
+
height: 22px;
|
|
918
|
+
background: rgba(${r[0]}, ${r[1]}, ${r[2]}, ${r[3]});
|
|
919
|
+
border: 1px solid ${t?"#555":"#ccc"};
|
|
920
|
+
border-radius: 4px;
|
|
921
|
+
cursor: pointer;
|
|
922
|
+
transition: all 0.2s;
|
|
923
|
+
`,o.onclick=()=>{this.options.onColorChange(r),this.hideAllPickers()},o.onmouseenter=()=>{o.style.transform="scale(1.1)"},o.onmouseleave=()=>{o.style.transform="scale(1)"},n.appendChild(o)}return i.appendChild(n),i}createStrokeWidthPicker(){const t=this.options.theme==="dark",e=[1,2,3,4,5,6,8,10,12,14,16,20],i=document.createElement("div");i.style.cssText=`
|
|
924
|
+
background: ${t?"#2d2d2d":"#ffffff"};
|
|
925
|
+
border: 1px solid ${t?"#444":"#ddd"};
|
|
926
|
+
border-radius: 8px;
|
|
927
|
+
padding: 6px 0;
|
|
928
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
929
|
+
width: 130px;
|
|
930
|
+
max-height: 200px;
|
|
931
|
+
overflow-y: auto;
|
|
932
|
+
z-index: 300;
|
|
933
|
+
`,i.className="earthview-stroke-width-scroll",this.injectStrokeWidthScrollbarStyles(t);const n=document.createElement("div");n.style.cssText="display: flex; flex-direction: column; gap: 2px;";for(const r of e){const o=document.createElement("div");o.style.cssText=`
|
|
934
|
+
display: flex;
|
|
935
|
+
align-items: center;
|
|
936
|
+
gap: 10px;
|
|
937
|
+
padding: 6px 12px;
|
|
938
|
+
cursor: pointer;
|
|
939
|
+
background: ${this.options.currentStrokeWidth===r?t?"#3d3d3d":"#e8e8e8":"transparent"};
|
|
940
|
+
transition: all 0.2s;
|
|
941
|
+
`,o.onmouseenter=()=>{this.options.currentStrokeWidth!==r&&(o.style.background=t?"#3a3a3a":"#f0f0f0")},o.onmouseleave=()=>{this.options.currentStrokeWidth!==r&&(o.style.background="transparent")},o.onclick=()=>{this.options.onStrokeWidthChange(r),this.hideAllPickers()};const a=document.createElement("div");a.style.cssText=`
|
|
942
|
+
width: 35px;
|
|
943
|
+
height: ${Math.min(r,8)}px;
|
|
944
|
+
background: ${t?"#fff":"#333"};
|
|
945
|
+
border-radius: 2px;
|
|
946
|
+
`,o.appendChild(a);const l=document.createElement("span");if(l.style.cssText=`color: ${t?"#fff":"#333"}; font-size: 11px; flex: 1;`,l.textContent=`${r}px`,o.appendChild(l),this.options.currentStrokeWidth===r){const h=document.createElement("span");h.style.cssText="color: #00aaff; font-size: 12px;",h.textContent="✓",o.appendChild(h)}n.appendChild(o)}return i.appendChild(n),i}injectStrokeWidthScrollbarStyles(t){const e="earthview-stroke-width-scroll-styles",i=t?"#555":"#ccc",n=t?"#2d2d2d":"#f0f0f0",o=`
|
|
947
|
+
.earthview-stroke-width-scroll {
|
|
948
|
+
scrollbar-width: thin;
|
|
949
|
+
scrollbar-color: ${i} ${n};
|
|
950
|
+
}
|
|
951
|
+
.earthview-stroke-width-scroll::-webkit-scrollbar {
|
|
952
|
+
width: 4px;
|
|
953
|
+
}
|
|
954
|
+
.earthview-stroke-width-scroll::-webkit-scrollbar-track {
|
|
955
|
+
background: ${n};
|
|
956
|
+
border-radius: 4px;
|
|
957
|
+
}
|
|
958
|
+
.earthview-stroke-width-scroll::-webkit-scrollbar-thumb {
|
|
959
|
+
background: ${i};
|
|
960
|
+
border-radius: 4px;
|
|
961
|
+
}
|
|
962
|
+
.earthview-stroke-width-scroll::-webkit-scrollbar-thumb:hover {
|
|
963
|
+
background: ${t?"#777":"#aaa"};
|
|
964
|
+
}
|
|
965
|
+
`;let a=document.getElementById(e);a||(a=document.createElement("style"),a.id=e,document.head.appendChild(a)),a.textContent=o}createStrokeStylePicker(){const t=this.options.theme==="dark",e=document.createElement("div");e.style.cssText=`
|
|
966
|
+
background: ${t?"#2d2d2d":"#ffffff"};
|
|
967
|
+
border: 1px solid ${t?"#444":"#ddd"};
|
|
968
|
+
border-radius: 8px;
|
|
969
|
+
padding: 6px 0;
|
|
970
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
971
|
+
width: 160px;
|
|
972
|
+
z-index: 300;
|
|
973
|
+
`;const i=[{value:"solid",label:this.options.t.solidLine},{value:"dashed",label:this.options.t.dashedLine}];for(const n of i){const r=document.createElement("div");r.style.cssText=`
|
|
974
|
+
display: flex;
|
|
975
|
+
align-items: center;
|
|
976
|
+
gap: 10px;
|
|
977
|
+
padding: 8px 12px;
|
|
978
|
+
cursor: pointer;
|
|
979
|
+
background: ${this.options.currentStrokeStyle===n.value?t?"#3d3d3d":"#e8e8e8":"transparent"};
|
|
980
|
+
transition: all 0.2s;
|
|
981
|
+
`,r.onmouseenter=()=>{this.options.currentStrokeStyle!==n.value&&(r.style.background=t?"#3a3a3a":"#f0f0f0")},r.onmouseleave=()=>{this.options.currentStrokeStyle!==n.value&&(r.style.background="transparent")},r.onclick=()=>{this.options.onStrokeStyleChange(n.value),this.hideAllPickers()};const o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("width","40"),o.setAttribute("height","4"),o.setAttribute("viewBox","0 0 40 4");const a=document.createElementNS("http://www.w3.org/2000/svg","line");a.setAttribute("x1","0"),a.setAttribute("y1","2"),a.setAttribute("x2","40"),a.setAttribute("y2","2"),a.setAttribute("stroke",t?"#fff":"#333"),a.setAttribute("stroke-width","2"),n.value==="dashed"&&a.setAttribute("stroke-dasharray","4 4"),o.appendChild(a),r.appendChild(o);const l=document.createElement("span");if(l.style.cssText=`color: ${t?"#fff":"#333"}; font-size: 12px; flex: 1;`,l.textContent=n.label,r.appendChild(l),this.options.currentStrokeStyle===n.value){const h=document.createElement("span");h.style.cssText="color: #00aaff; font-size: 12px;",h.textContent="✓",r.appendChild(h)}e.appendChild(r)}return e}hideAllPickers(){this.colorPickerPanel&&(this.colorPickerPanel.remove(),this.colorPickerPanel=null),this.strokeWidthPanel&&(this.strokeWidthPanel.remove(),this.strokeWidthPanel=null),this.strokeStylePanel&&(this.strokeStylePanel.remove(),this.strokeStylePanel=null),this.activePicker=null}attachDragEvents(){document.addEventListener("click",t=>{this.activePicker&&!this.element.contains(t.target)&&this.hideAllPickers()})}updatePosition(t){this.position=this.constrainPosition(t),this.element.style.left=`${this.position.x}px`,this.element.style.top=`${this.position.y}px`}setVisible(t){this.element.style.display=t?"flex":"none",t||this.hideAllPickers()}updateColor(t){this.options.currentColor=t;const e=this.element.querySelector("button:nth-child(2)");if(e){const i=e.querySelector("div");i&&(i.style.background=`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]||1})`)}}updateStrokeStyle(t){this.options.currentStrokeStyle=t;const e=this.element.querySelector("button:nth-child(4)");e&&(e.style.borderStyle=t==="dashed"?"dashed":"solid")}updateTheme(t){this.options.theme=t;const e=t==="dark";this.element.style.background=e?"rgba(30,30,30,0.95)":"rgba(255,255,255,0.95)",this.element.style.borderColor=e?"#444":"#ddd",this.element.querySelectorAll("button").forEach((n,r)=>{const o=r===0;n.style.background=o?e?"#3d3d3d":"#e8e8e8":e?"#2d2d2d":"#f0f0f0",n.style.borderColor=e?"#444":"#ddd",n.style.color=e?"#ccc":"#666"})}destroy(){this.hideAllPickers(),this.element.remove()}}class ny{constructor(t){this.isDragging=!1,this.dragStart={x:0,y:0},this.positionStart={x:0,y:0},this.options=t,this.position=t.position||{x:100,y:100},this.element=this.createElement(),t.containerRef.appendChild(this.element),this.element.style.visibility="hidden",this.position=this.constrainPosition(this.position),this.element.style.left=`${this.position.x}px`,this.element.style.top=`${this.position.y}px`,this.element.style.visibility="visible",this.attachDragEvents()}createElement(){const t=this.options.theme==="dark",e=document.createElement("div");e.style.cssText=`
|
|
982
|
+
position: absolute;
|
|
983
|
+
left: ${this.position.x}px;
|
|
984
|
+
top: ${this.position.y}px;
|
|
985
|
+
z-index: 200;
|
|
986
|
+
display: flex;
|
|
987
|
+
align-items: center;
|
|
988
|
+
gap: 6px;
|
|
989
|
+
background: ${t?"rgba(30,30,30,0.95)":"rgba(255,255,255,0.95)"};
|
|
990
|
+
border: 1px solid ${t?"#444":"#ddd"};
|
|
991
|
+
border-radius: 8px;
|
|
992
|
+
padding: 6px 8px;
|
|
993
|
+
backdrop-filter: blur(8px);
|
|
994
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
995
|
+
cursor: default;
|
|
996
|
+
`;const i=`
|
|
997
|
+
width: 28px;
|
|
998
|
+
height: 28px;
|
|
999
|
+
background: ${t?"#2d2d2d":"#f0f0f0"};
|
|
1000
|
+
border: 1px solid ${t?"#444":"#ddd"};
|
|
1001
|
+
border-radius: 6px;
|
|
1002
|
+
color: ${t?"#ccc":"#666"};
|
|
1003
|
+
cursor: pointer;
|
|
1004
|
+
display: flex;
|
|
1005
|
+
align-items: center;
|
|
1006
|
+
justify-content: center;
|
|
1007
|
+
transition: all 0.2s;
|
|
1008
|
+
flex-shrink: 0;
|
|
1009
|
+
`,n=document.createElement("div");n.style.cssText=`
|
|
1010
|
+
${i}
|
|
1011
|
+
width: 20px;
|
|
1012
|
+
cursor: grab;
|
|
1013
|
+
background: ${t?"#3d3d3d":"#e8e8e8"};
|
|
1014
|
+
`,n.innerHTML=xt.DragHandle,n.onmousedown=this.onMouseDown.bind(this),e.appendChild(n);const r=document.createElement("button");r.style.cssText=i,r.innerHTML=xt.Delete,r.title=this.options.t.delete,r.onclick=()=>this.options.onDelete(),e.appendChild(r);const o=document.createElement("button");return o.style.cssText=i,o.innerHTML=xt.Close,o.title=this.options.t.cancel,o.onclick=()=>this.options.onClose(),e.appendChild(o),e}constrainPosition(t){const e=this.options.containerRef.getBoundingClientRect(),i=this.element.getBoundingClientRect();let n=i.width,r=i.height;(n===0||r===0)&&(n=100,r=40);const o=0,a=0,l=Math.max(0,e.width-n),h=Math.max(0,e.height-r);return{x:Math.max(o,Math.min(t.x,l)),y:Math.max(a,Math.min(t.y,h))}}attachDragEvents(){}onMouseDown(t){t.target.closest('[style*="cursor: grab"]')&&(t.preventDefault(),this.isDragging=!0,this.dragStart={x:t.clientX,y:t.clientY},this.positionStart={x:this.position.x,y:this.position.y},window.addEventListener("mousemove",this.onMouseMove.bind(this)),window.addEventListener("mouseup",this.onMouseUp.bind(this)),document.body.style.userSelect="none")}onMouseMove(t){if(!this.isDragging)return;const e=t.clientX-this.dragStart.x,i=t.clientY-this.dragStart.y;let n=this.positionStart.x+e,r=this.positionStart.y+i;this.position=this.constrainPosition({x:n,y:r}),this.element.style.left=`${this.position.x}px`,this.element.style.top=`${this.position.y}px`,this.options.onPositionChange(this.position)}onMouseUp(){this.isDragging=!1,window.removeEventListener("mousemove",this.onMouseMove.bind(this)),window.removeEventListener("mouseup",this.onMouseUp.bind(this)),document.body.style.userSelect=""}showAtPosition(t){this.element.style.opacity="0",this.element.style.display="flex",requestAnimationFrame(()=>{const e=this.constrainPosition(t);this.position=e,this.element.style.left=`${e.x}px`,this.element.style.top=`${e.y}px`,this.element.style.opacity="1"})}updatePosition(t){this.position=this.constrainPosition(t),this.element.style.left=`${this.position.x}px`,this.element.style.top=`${this.position.y}px`}setVisible(t){this.element.style.display=t?"flex":"none"}updateTheme(t){this.options.theme=t;const e=t==="dark";this.element.style.background=e?"rgba(30,30,30,0.95)":"rgba(255,255,255,0.95)",this.element.style.borderColor=e?"#444":"#ddd";const i=this.element.querySelectorAll("button"),n=this.element.querySelector("div");n&&(n.style.background=e?"#3d3d3d":"#e8e8e8",n.style.borderColor=e?"#444":"#ddd"),i.forEach(r=>{r.style.background=e?"#2d2d2d":"#f0f0f0",r.style.borderColor=e?"#444":"#ddd",r.style.color=e?"#ccc":"#666"})}destroy(){window.removeEventListener("mousemove",this.onMouseMove.bind(this)),window.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.element.remove()}}class sy{constructor(t,e){this.element=this.createElement(e),t.appendChild(this.element)}createElement(t){const e=t==="dark",i=document.createElement("div");return i.style.cssText=`
|
|
1015
|
+
position: absolute;
|
|
1016
|
+
bottom: 10px;
|
|
1017
|
+
right: 10px;
|
|
1018
|
+
z-index: 100;
|
|
1019
|
+
background: ${e?"rgba(0,0,0,0.7)":"rgba(255,255,255,0.9)"};
|
|
1020
|
+
padding: 4px 8px;
|
|
1021
|
+
border-radius: 4px;
|
|
1022
|
+
backdrop-filter: blur(4px);
|
|
1023
|
+
font-family: monospace;
|
|
1024
|
+
font-size: 11px;
|
|
1025
|
+
color: ${e?"#fff":"#333"};
|
|
1026
|
+
pointer-events: none;
|
|
1027
|
+
`,i.textContent="",i}updateScale(t){this.element.textContent=t}updateTheme(t){const e=t==="dark";this.element.style.background=e?"rgba(0,0,0,0.7)":"rgba(255,255,255,0.9)",this.element.style.color=e?"#fff":"#333"}destroy(){this.element.remove()}}class ry{constructor(t,e){this.element=this.createElement(e),t.appendChild(this.element)}createElement(t){const e=document.createElement("div");e.style.cssText=`
|
|
1028
|
+
position: absolute;
|
|
1029
|
+
top: 0;
|
|
1030
|
+
left: 0;
|
|
1031
|
+
right: 0;
|
|
1032
|
+
bottom: 0;
|
|
1033
|
+
z-index: 1000;
|
|
1034
|
+
background: rgba(0,0,0,0.7);
|
|
1035
|
+
backdrop-filter: blur(4px);
|
|
1036
|
+
display: flex;
|
|
1037
|
+
align-items: center;
|
|
1038
|
+
justify-content: center;
|
|
1039
|
+
flex-direction: column;
|
|
1040
|
+
gap: 12px;
|
|
1041
|
+
display: none;
|
|
1042
|
+
`;const i=document.createElement("div");i.style.cssText=`
|
|
1043
|
+
width: 40px;
|
|
1044
|
+
height: 40px;
|
|
1045
|
+
border: 3px solid #444;
|
|
1046
|
+
border-top: 3px solid #00aaff;
|
|
1047
|
+
border-radius: 50%;
|
|
1048
|
+
animation: spin 1s linear infinite;
|
|
1049
|
+
`,e.appendChild(i);const n=document.createElement("span");n.style.cssText=`
|
|
1050
|
+
color: #fff;
|
|
1051
|
+
font-size: 13px;
|
|
1052
|
+
background: rgba(0,0,0,0.5);
|
|
1053
|
+
padding: 4px 12px;
|
|
1054
|
+
border-radius: 4px;
|
|
1055
|
+
`,n.textContent="",e.appendChild(n);const r=document.createElement("style");return r.textContent=`
|
|
1056
|
+
@keyframes spin {
|
|
1057
|
+
0% { transform: rotate(0deg); }
|
|
1058
|
+
100% { transform: rotate(360deg); }
|
|
1059
|
+
}
|
|
1060
|
+
`,document.head.appendChild(r),e}show(t){const e=this.element.querySelector("span:last-child");e&&(e.textContent=t),this.element.style.display="flex"}hide(){this.element.style.display="none"}updateTheme(t){}destroy(){this.element.remove()}}const oy={colorTitle:"切换颜色",strokeWidthTitle:"调整线宽",strokeStyleTitle:"切换线型",deleteTitle:"删除图形",closeTitle:"关闭",solidLine:"实线",dashedLine:"虚线",loading:"加载地图中...",changingBasemap:"切换底图中...",layers:"图层管理",layersTitle:"图层管理",noLayers:"暂无图层",hideLayer:"隐藏",showLayer:"显示",deleteLayerTitle:"删除图层",cannotRemoveDrawingLayer:"无法删除绘图图层",basemap:"切换底图",basemapTitle:"切换底图",satellite:"卫星图",streets:"街道图",topographic:"地形图",oceans:"海洋图",lightGray:"浅灰图",darkGray:"深色图",nationalGeographic:"国家地理",terrain:"地形阴影",hybrid:"混合图",imagery:"纯影像",physical:"物理地形",amapStreets:"高德街道图",amapSatellite:"高德卫星图",googleStreets:"谷歌街道图",googleSatellite:"谷歌卫星图",drawTools:"绘图工具",drawToolsTitle:"绘图工具",drawCircle:"绘制圆形",editCircle:"编辑圆形",noCirclesToEdit:"没有可编辑的圆形,请先绘制一个圆形",close:"关闭",zoomInTitle:"放大",zoomOutTitle:"缩小",drawingCircle:"正在绘制圆形...",editingCircle:"正在编辑圆形...",editingRectangle:"正在绘制矩形...",editingTriangle:"正在绘制三角形...",locateMe:"定位到我",tools:"工具",toolsTitle:"测量工具",distanceMeasure:"距离测量",areaMeasure:"面积测量",clearMeasurements:"清除测量",measureDistance:"测量距离",measureArea:"测量面积",measuring:"测量中...",distance:"距离",area:"面积",squareMeters:"平方米",squareKilometers:"平方公里",meters:"米",kilometers:"公里",clickToStartMeasure:"点击开始测量",doubleClickToFinish:"双击完成测量",measurementLayer:"测量图层",noMeasurements:"暂无测量数据",delete:"删除",cancel:"取消",drawRectangle:"绘制矩形",drawTriangle:"绘制三角形",editShape:"编辑图形"},ay={colorTitle:"Change Color",strokeWidthTitle:"Stroke Width",strokeStyleTitle:"Stroke Style",deleteTitle:"Delete",closeTitle:"Close",solidLine:"Solid",dashedLine:"Dashed",loading:"Loading Map...",changingBasemap:"Changing basemap...",layers:"Layers",layersTitle:"Layers",noLayers:"No layers",hideLayer:"Hide",showLayer:"Show",deleteLayerTitle:"Delete Layer",cannotRemoveDrawingLayer:"Cannot remove drawing layer",basemap:"Basemap",basemapTitle:"Basemap",satellite:"Satellite",streets:"Streets",topographic:"Topographic",oceans:"Oceans",lightGray:"Light Gray",darkGray:"Dark Gray",nationalGeographic:"National Geographic",terrain:"Terrain",hybrid:"Hybrid",imagery:"Imagery",physical:"Physical",amapStreets:"AMap Streets",amapSatellite:"AMap Satellite",googleStreets:"Google Streets",googleSatellite:"Google Satellite",drawTools:"Draw Tools",drawToolsTitle:"Draw Tools",drawCircle:"Draw Circle",editCircle:"Edit Circle",noCirclesToEdit:"No circles to edit. Please draw a circle first.",close:"Close",zoomInTitle:"Zoom In",zoomOutTitle:"Zoom Out",drawingCircle:"Drawing Circle...",editingCircle:"Editing circle...",editingRectangle:"Drawing Rectangle...",editingTriangle:"Drawing Triangle...",locateMe:"Locate Me",tools:"Tools",toolsTitle:"Measure Tools",distanceMeasure:"Distance Measure",areaMeasure:"Area Measure",clearMeasurements:"Clear Measurements",measureDistance:"Measure Distance",measureArea:"Measure Area",measuring:"Measuring...",distance:"Distance",area:"Area",squareMeters:"m²",squareKilometers:"km²",meters:"m",kilometers:"km",clickToStartMeasure:"Click to start measuring",doubleClickToFinish:"Double click to finish",measurementLayer:"Measurement Layer",noMeasurements:"No measurements",delete:"Delete",cancel:"Cancel",drawRectangle:"Draw Rectangle",drawTriangle:"Draw Triangle",editShape:"Edit Shape"},ra=s=>s==="zh"?oy:ay;class ly{constructor(){this.tools=new Map,this.activeTool=null,this.eventHandlers=new Map}registerTool(t){if(this.tools.has(t.id)){console.warn(`Tool with id ${t.id} already registered`);return}this.tools.set(t.id,t)}unregisterTool(t){const e=this.tools.get(t);e&&this.activeTool===e&&this.deactivateCurrent(),this.tools.delete(t)}getTool(t){return this.tools.get(t)}activateTool(t){this.activeTool&&this.activeTool.deactivate();const e=this.tools.get(t);e&&(this.activeTool=e,e.activate(),this.emit("tool-activated",{toolId:t,name:e.name}))}deactivateCurrent(){this.activeTool&&(this.activeTool.deactivate(),this.activeTool=null,this.emit("tool-deactivated",null))}getActiveTool(){return this.activeTool}getActiveToolId(){return this.activeTool?.id||null}isToolActive(t){return this.activeTool?.id===t}on(t,e){this.eventHandlers.has(t)||this.eventHandlers.set(t,[]),this.eventHandlers.get(t).push(e)}off(t,e){const i=this.eventHandlers.get(t);if(i){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}}emit(t,e){const i=this.eventHandlers.get(t);i&&i.forEach(n=>n(e))}destroy(){this.tools.forEach(t=>t.destroy()),this.tools.clear(),this.eventHandlers.clear(),this.activeTool=null}}class hy{constructor(t,e){this.id="circle-draw",this.name="圆形绘制",this.icon="⭕",this.circleDrawLayer=t,this.name=e.drawCircle||"圆形绘制"}activate(){this.circleDrawLayer.setEditable(!0)}deactivate(){this.circleDrawLayer.stopDraw(),this.circleDrawLayer.stopEdit()}isActive(){return this.circleDrawLayer.isDrawActive()||this.circleDrawLayer.isEditActive()}startDraw(){this.circleDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.circleDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getCircleLayer(){return this.circleDrawLayer}destroy(){this.circleDrawLayer.destroy()}}class cy{constructor(t,e){this.id="rectangle-draw",this.name="矩形绘制",this.icon="◻️",this.rectangleDrawLayer=t,this.name=e.drawRectangle||"矩形绘制"}activate(){this.rectangleDrawLayer.setEditable(!0)}deactivate(){this.rectangleDrawLayer.stopDraw(),this.rectangleDrawLayer.stopEdit()}isActive(){return this.rectangleDrawLayer.isDrawActive()||this.rectangleDrawLayer.isEditActive()}startDraw(){this.rectangleDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.rectangleDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getRectangleLayer(){return this.rectangleDrawLayer}destroy(){this.rectangleDrawLayer.destroy()}}class uy{constructor(t,e){this.id="triangle-draw",this.name="三角形绘制",this.icon="▲",this.triangleDrawLayer=t,this.name=e.drawTriangle||"三角形绘制"}activate(){this.triangleDrawLayer.setEditable(!0)}deactivate(){this.triangleDrawLayer.stopDraw(),this.triangleDrawLayer.stopEdit()}isActive(){return this.triangleDrawLayer.isDrawActive()||this.triangleDrawLayer.isEditActive()}startDraw(){this.triangleDrawLayer.startDraw(t=>{this.onDrawComplete&&this.onDrawComplete(t)})}startEdit(t){this.triangleDrawLayer.startEdit(t,e=>{this.onEditComplete&&this.onEditComplete(e)})}setOnDrawComplete(t){this.onDrawComplete=t}setOnEditComplete(t){this.onEditComplete=t}getTriangleLayer(){return this.triangleDrawLayer}destroy(){this.triangleDrawLayer.destroy()}}const dy='© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class fy extends al{constructor(t){t=t||{};let e;t.attributions!==void 0?e=t.attributions:e=[dy];const i=t.url!==void 0?t.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:e,attributionsCollapsible:!1,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin!==void 0?t.crossOrigin:"anonymous",referrerPolicy:t.referrerPolicy||"origin-when-cross-origin",interpolate:t.interpolate,maxZoom:t.maxZoom!==void 0?t.maxZoom:19,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:i,wrapX:t.wrapX,zDirection:t.zDirection})}}const vt=Math.PI,yr=6378245,xr=.006693421622965943;function fl(s,t){return s<72.004||s>137.8347||t<.8293||t>55.8271}function Cu(s,t){let e=-100+2*s+3*t+.2*t*t+.1*s*t+.2*Math.sqrt(Math.abs(s));return e+=(20*Math.sin(6*s*vt)+20*Math.sin(2*s*vt))*(2/3),e+=(20*Math.sin(t*vt)+40*Math.sin(t/3*vt))*(2/3),e+=(160*Math.sin(t/12*vt)+320*Math.sin(t*vt/30))*(2/3),e}function wu(s,t){let e=300+s+2*t+.1*s*s+.1*s*t+.1*Math.sqrt(Math.abs(s));return e+=(20*Math.sin(6*s*vt)+20*Math.sin(2*s*vt))*(2/3),e+=(20*Math.sin(s*vt)+40*Math.sin(s/3*vt))*(2/3),e+=(150*Math.sin(s/12*vt)+300*Math.sin(s*vt/30))*(2/3),e}function gl(s,t){if(fl(s,t))return[s,t];let e=Cu(s-105,t-35),i=wu(s-105,t-35);const n=t/180*vt;let r=Math.sin(n);r=1-xr*r*r;const o=Math.sqrt(r);return e=e*180/(yr*(1-xr)/(r*o)*vt),i=i*180/(yr/o*Math.cos(n)*vt),[s-i,t-e]}function bh(s,t){if(fl(s,t))return[s,t];let e=Cu(s-105,t-35),i=wu(s-105,t-35);const n=t/180*vt;let r=Math.sin(n);r=1-xr*r*r;const o=Math.sqrt(r);return e=e*180/(yr*(1-xr)/(r*o)*vt),i=i*180/(yr/o*Math.cos(n)*vt),[s+i,t+e]}function gy(s,t){const e=s,i=t,n=Math.sqrt(e*e+i*i)+2e-5*Math.sin(i*vt),r=Math.atan2(i,e)+3e-6*Math.cos(e*vt),o=n*Math.cos(r)+.0065,a=n*Math.sin(r)+.006;return[o,a]}function py(s,t){const e=s-.0065,i=t-.006,n=Math.sqrt(e*e+i*i)-2e-5*Math.sin(i*vt),r=Math.atan2(i,e)-3e-6*Math.cos(e*vt),o=n*Math.cos(r),a=n*Math.sin(r);return[o,a]}function Tu(s,t){const[e,i]=py(s,t);return gl(e,i)}function oa(s,t,e){switch(e){case Ce.WGS84:return[s,t];case Ce.GCJ02:return gl(s,t);case Ce.BD09:return Tu(s,t);default:return[s,t]}}function _y(s,t,e){switch(e){case Ce.WGS84:return[s,t];case Ce.GCJ02:return bh(s,t);case Ce.BD09:return gy(...bh(s,t));default:return[s,t]}}function my(s,t){return!fl(s,t)}const yy={[J.SATELLITE]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.STREETS]:{url:"https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"OpenStreetMap"},[J.TOPO]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.OCEANS]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.GRAY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.DARK_GRAY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.NATIONAL_GEOGRAPHIC]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.TERRAIN]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.HYBRID]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.LIGHT_GRAY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.IMAGERY]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.PHYSICAL]:{url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",attribution:"Esri"},[J.AMAP_STREETS]:{url:"https://webrd01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",attribution:"高德地图"},[J.AMAP_SATELLITE]:{url:"https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",attribution:"高德地图"},[J.GOOGLE_STREETS]:{url:"http://www.google.cn/maps/vt?lyrs=m&x={x}&y={y}&z={z}",attribution:"Google"},[J.GOOGLE_SATELLITE]:{url:"http://www.google.cn/maps/vt?lyrs=s&x={x}&y={y}&z={z}",attribution:"Google"}};class xy{constructor(t,e,i,n,r){getComputedStyle(t).position==="static"&&(t.style.position="relative");let o=i;r!==Ce.WGS84&&(o=oa(i[0],i[1],r)),this.currentBasemap=e,this.basemapLayer=this.createBasemapLayer(e),this.view=new De({center:te(o),zoom:n,minZoom:1,maxZoom:19}),this.map=new yu({target:t,layers:[this.basemapLayer],view:this.view,controls:[],interactions:pu({doubleClickZoom:!1})})}createBasemapLayer(t){const e=yy[t];let i;if(t===J.STREETS)i=new fy;else{let n=e.url;i=new al({url:n,attributions:e.attribution})}return new ou({source:i})}getMap(){return this.map}getView(){return this.view}getCenter(){const t=Pt(this.view.getCenter()||[0,0]);return[t[0],t[1]]}getZoom(){return this.view.getZoom()||0}setCenter(t,e){let i=t;e&&e!==Ce.WGS84&&(i=oa(t[0],t[1],e)),this.view.setCenter(te(i))}setZoom(t){this.view.setZoom(t)}setBasemap(t){this.map.removeLayer(this.basemapLayer),this.basemapLayer=this.createBasemapLayer(t),this.map.addLayer(this.basemapLayer),this.currentBasemap=t}getCurrentBasemap(){return this.currentBasemap}setRotation(t){this.view.setRotation(t)}destroy(){this.map.setTarget(void 0),this.map.dispose()}}var Me=(s=>(s.CIRCLE="circle-draw",s.RECTANGLE="rectangle-draw",s.TRIANGLE="triangle-draw",s.POLYGON="polygon-draw",s.LINE="line-draw",s.POINT="point-draw",s))(Me||{});class Ey{constructor(t,e,i,n,r,o){this.toolbar=null,this.scaleBar=null,this.loadingOverlay=null,this.activePopupPanel=null,this.activePopupType=null,this.container=t,this.theme=e,this.t=i,this.callbacks=n,this.getLayerListFn=r,this.getCurrentBasemapFn=o,this.init()}init(){this.toolbar=new Jm({container:this.container,t:this.t,theme:this.theme,activePopup:this.activePopupType,onTogglePopup:this.handleTogglePopup.bind(this),onZoomIn:()=>this.callbacks.onZoomIn(),onZoomOut:()=>this.callbacks.onZoomOut(),onLocate:()=>this.callbacks.onLocate()}),this.scaleBar=new sy(this.container,this.theme),this.loadingOverlay=new ry(this.container,this.theme)}handleTogglePopup(t){if(this.activePopupPanel&&(this.activePopupPanel.destroy(),this.activePopupPanel=null),this.activePopupType=t,this.toolbar?.updateActivePopup(t),t===null)return;let e;switch(t){case"layers":e=new Zs({title:this.t.layers,theme:this.theme,t:this.t,onClose:()=>this.handleTogglePopup(null)});const i=new Qm({layerList:this.getLayerListFn(),onToggleVisibility:a=>this.callbacks.onToggleLayerVisibility(a),onRemoveLayer:a=>this.callbacks.onRemoveLayer(a),theme:this.theme,t:this.t});e.appendChild(i.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement());break;case"basemap":e=new Zs({title:this.t.basemap,theme:this.theme,t:this.t,onClose:()=>this.handleTogglePopup(null)});const n=new ty({currentBasemap:this.getCurrentBasemapFn(),onSelect:a=>this.callbacks.onSetBasemap(a),theme:this.theme,t:this.t,options:[{value:J.SATELLITE,label:this.t.satellite,icon:"🛰️"},{value:J.STREETS,label:this.t.streets,icon:"🗺️"},{value:J.TOPO,label:this.t.topographic,icon:"⛰️"},{value:J.HYBRID,label:this.t.hybrid,icon:"🔄"},{value:J.TERRAIN,label:this.t.terrain,icon:"🗻"},{value:J.OCEANS,label:this.t.oceans,icon:"🌊"},{value:J.DARK_GRAY,label:this.t.darkGray,icon:"🌙"},{value:J.LIGHT_GRAY,label:this.t.lightGray,icon:"☀️"},{value:J.NATIONAL_GEOGRAPHIC,label:this.t.nationalGeographic,icon:"📰"},{value:J.IMAGERY,label:this.t.imagery,icon:"📷"},{value:J.PHYSICAL,label:this.t.physical,icon:"🌎"},{value:J.AMAP_STREETS,label:this.t.amapStreets,icon:"🗺️"},{value:J.AMAP_SATELLITE,label:this.t.amapSatellite,icon:"🛰️"},{value:J.GOOGLE_STREETS,label:this.t.googleStreets,icon:"🗺️"},{value:J.GOOGLE_SATELLITE,label:this.t.googleSatellite,icon:"🛰️"}]});e.appendChild(n.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement());break;case"draw":e=new Zs({title:this.t.drawTools,theme:this.theme,t:this.t,onClose:()=>this.handleTogglePopup(null)});const r=new ey({onDrawCircle:()=>this.callbacks.onDrawCircle(),onDrawRectangle:()=>this.callbacks.onDrawRectangle(),onDrawTriangle:()=>this.callbacks.onDrawTriangle(),onEditShape:()=>this.callbacks.onEditShape(),theme:this.theme,t:this.t});e.appendChild(r.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement());break;case"tools":e=new Zs({title:this.t.tools,theme:this.theme,t:this.t,onClose:()=>{this.handleTogglePopup(null),this.callbacks.onClearMeasurements()}});const o=new iy({onDistanceMeasure:()=>this.callbacks.onDistanceMeasure(),onAreaMeasure:()=>this.callbacks.onAreaMeasure(),onClearMeasurements:()=>this.callbacks.onClearMeasurements(),isMeasuring:!1,currentMeasureType:null,measurePreview:null,theme:this.theme,t:this.t});e.appendChild(o.getElement()),this.activePopupPanel=e,this.container.appendChild(e.getElement());break}}updateLayerList(t){this.activePopupType==="layers"&&this.activePopupPanel&&this.handleTogglePopup("layers")}showLoading(t){this.loadingOverlay?.show(t)}hideLoading(){this.loadingOverlay?.hide()}updateScale(t){this.scaleBar?.updateScale(t)}updateTheme(t){if(this.theme=t,this.toolbar?.updateTheme(t),this.scaleBar?.updateTheme(t),this.activePopupType){const e=this.activePopupType;this.handleTogglePopup(null),this.handleTogglePopup(e)}}updateLocale(t){this.t=t,this.toolbar?.destroy(),this.activePopupPanel&&(this.activePopupPanel.destroy(),this.activePopupPanel=null),this.init(),this.activePopupType&&this.handleTogglePopup(this.activePopupType)}destroy(){this.toolbar?.destroy(),this.scaleBar?.destroy(),this.loadingOverlay?.destroy(),this.activePopupPanel&&this.activePopupPanel.destroy()}getContainer(){return this.container}}class vy{constructor(){this.activeToolType=null,this.circleTool=null,this.rectangleTool=null,this.triangleTool=null}registerTools(t,e,i){this.circleTool=t,this.rectangleTool=e,this.triangleTool=i,this.circleTool?.setOnDrawComplete(()=>{this.endDrawing()}),this.rectangleTool?.setOnDrawComplete(()=>{this.endDrawing()}),this.triangleTool?.setOnDrawComplete(()=>{this.endDrawing()}),this.circleTool?.setOnEditComplete(()=>{this.endDrawing()}),this.rectangleTool?.setOnEditComplete(()=>{this.endDrawing()}),this.triangleTool?.setOnEditComplete(()=>{this.endDrawing()})}setCallbacks(t,e){this.onDrawingStartCallback=t,this.onDrawingEndCallback=e}startDrawingCircle(){this.deactivateAll(),this.activeToolType=Me.CIRCLE,this.circleTool?.startDraw(),this.onDrawingStartCallback?.(Me.CIRCLE)}startDrawingRectangle(){this.deactivateAll(),this.activeToolType=Me.RECTANGLE,this.rectangleTool?.startDraw(),this.onDrawingStartCallback?.(Me.RECTANGLE)}startDrawingTriangle(){this.deactivateAll(),this.activeToolType=Me.TRIANGLE,this.triangleTool?.startDraw(),this.onDrawingStartCallback?.(Me.TRIANGLE)}cancelDrawing(){this.deactivateAll()}deactivateAll(){const t=this.activeToolType!==null;this.circleTool?.deactivate(),this.rectangleTool?.deactivate(),this.triangleTool?.deactivate(),this.activeToolType=null,t&&this.onDrawingEndCallback?.()}endDrawing(){this.activeToolType!==null&&(this.activeToolType=null,this.onDrawingEndCallback?.())}getActiveTool(){return this.activeToolType}isDrawing(){return this.activeToolType!==null}destroy(){this.deactivateAll(),this.circleTool=null,this.rectangleTool=null,this.triangleTool=null}}class Cy{constructor(t){this.circleDrawLayer=null,this.rectangleDrawLayer=null,this.triangleDrawLayer=null,this.distanceMeasureLayer=null,this.areaMeasureLayer=null,this.circleDrawTool=null,this.rectangleDrawTool=null,this.triangleDrawTool=null,this.floatingToolbar=null,this.measurementFloatingToolbar=null,this.drawingStatusDiv=null,this.measureStatusDiv=null,this.theme="dark",this.locale="zh",this.isDestroyed=!1,this.enableDrawing=!0,this.showFloatingToolbar=!1,this.floatingToolbarPosition={x:100,y:100},this.showMeasurementToolbar=!1,this.measurementToolbarPosition={x:100,y:100},this.selectedCircleId=null,this.selectedRectangleId=null,this.selectedTriangleId=null,this.selectedMeasurementId=null,this.currentColor=[255,0,0,1],this.currentStrokeWidth=3,this.currentStrokeStyle="solid",this.currentScale="",this.isLoading=!0,this.isChangingBasemap=!1,this.drawingStatusText=null,this.measureStatusText=null;const{container:e,basemap:i=J.SATELLITE,center:n=[0,0],zoom:r=12,coordinateSystem:o=Ce.WGS84,onLoad:a,onMoveEnd:l,onMapClick:h,onCircleDrawn:c,theme:u="dark",i18n:d="zh",enableDrawing:f=!0}=t;this.container=e,this.theme=u,this.locale=d,this.t=ra(this.locale),this.onLoadCallback=a,this.onMoveEndCallback=l,this.onMapClickCallback=h,this.onCircleDrawnCallback=c,this.enableDrawing=f,e.setAttribute("data-theme",u),document.body.setAttribute("data-theme",u),e.style.overflow="hidden",this.mapManager=new xy(e,i,n,r,o),this.layerManager=new Ph(this.mapManager.getMap()),this.drawToolManager=new ly,this.drawingManager=new vy,this.initUI(),this.initLayers(),this.initDrawingManager(),this.bindEvents(),this.initRightClickMenu(),this.onLoadCallback&&setTimeout(()=>this.onLoadCallback?.(this),100),setTimeout(()=>this.hideLoading(),500)}initUI(){this.uiManager=new Ey(this.container,this.theme,this.t,{onTogglePopup:t=>this.handleTogglePopup(t),onZoomIn:()=>this.zoomIn(),onZoomOut:()=>this.zoomOut(),onLocate:()=>this.locateUser(),onDrawCircle:()=>this.startDrawCircle(),onDrawRectangle:()=>this.startDrawRectangle(),onDrawTriangle:()=>this.startDrawTriangle(),onEditShape:()=>this.startEditShape(),onDistanceMeasure:()=>this.startMeasureDistance(),onAreaMeasure:()=>this.startMeasureArea(),onClearMeasurements:()=>this.clearAllMeasurements(),onSetBasemap:t=>this.setBasemap(t),onToggleLayerVisibility:t=>this.setLayerVisibility(t,!this.getLayerVisibility(t)),onRemoveLayer:t=>this.removeLayer(t)},()=>this.getLayerList(),()=>this.getBasemap()),this.createStatusIndicators()}handleTogglePopup(t){}createStatusIndicators(){const t=this.theme==="dark";this.drawingStatusDiv=document.createElement("div"),this.drawingStatusDiv.style.cssText=`
|
|
1061
|
+
position: absolute; top: 10px; left: 10px; z-index: 200;
|
|
1062
|
+
background: ${t?"rgba(0,0,0,0.8)":"rgba(255,255,255,0.9)"};
|
|
1063
|
+
border: 1px solid ${t?"#444":"#ddd"}; border-radius: 8px;
|
|
1064
|
+
padding: 8px 16px; backdrop-filter: blur(4px);
|
|
1065
|
+
display: flex; align-items: center; gap: 10px;
|
|
1066
|
+
display: none;
|
|
1067
|
+
`;const e=document.createElement("div");e.style.cssText=`width:16px;height:16px;border:2px solid ${t?"#555":"#ccc"};border-top:2px solid #00aaff;border-radius:50%;animation:spin 0.8s linear infinite;`,this.drawingStatusDiv.appendChild(e);const i=document.createElement("span");i.style.cssText=`color:${t?"#fff":"#333"};font-size:12px;`,i.id="drawing-status-text",this.drawingStatusDiv.appendChild(i),this.container.appendChild(this.drawingStatusDiv),this.measureStatusDiv=document.createElement("div"),this.measureStatusDiv.style.cssText=`
|
|
1068
|
+
position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
|
|
1069
|
+
z-index: 200; background: ${t?"rgba(0,0,0,0.85)":"rgba(255,255,255,0.95)"};
|
|
1070
|
+
border: 1px solid ${t?"#444":"#ddd"}; border-radius: 8px;
|
|
1071
|
+
padding: 6px 12px; backdrop-filter: blur(4px);
|
|
1072
|
+
display: flex; align-items: center; gap: 8px; pointer-events: none;
|
|
1073
|
+
display: none;
|
|
1074
|
+
`;const n=document.createElement("div");n.style.cssText="width:8px;height:8px;background:#00aaff;border-radius:50%;animation:pulse 1s infinite;",this.measureStatusDiv.appendChild(n);const r=document.createElement("span");r.style.cssText=`color:${t?"#fff":"#333"};font-size:12px;`,r.id="measure-status-text",this.measureStatusDiv.appendChild(r),this.container.appendChild(this.measureStatusDiv);const o=document.createElement("style");o.textContent="@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:0.5;transform:scale(1.2)}}",document.head.appendChild(o)}initLayers(){this.enableDrawing&&(this.circleDrawLayer=new xu("circle-draw","Circle Draw"),this.circleDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.circleDrawLayer),this.rectangleDrawLayer=new Km("rectangle-draw","Rectangle Draw"),this.rectangleDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.rectangleDrawLayer),this.triangleDrawLayer=new qm("triangle-draw","Triangle Draw"),this.triangleDrawLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.triangleDrawLayer),this.distanceMeasureLayer=new Eu("distance-measurement","Distance Measurement"),this.distanceMeasureLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.distanceMeasureLayer),this.areaMeasureLayer=new vu("area-measurement","Area Measurement"),this.areaMeasureLayer.setView(this.mapManager.getMap()),this.layerManager.addLayer(this.areaMeasureLayer),this.circleDrawTool=new hy(this.circleDrawLayer,this.t),this.rectangleDrawTool=new cy(this.rectangleDrawLayer,this.t),this.triangleDrawTool=new uy(this.triangleDrawLayer,this.t),this.circleDrawTool.setOnDrawComplete(()=>{this.onDrawingEnd()}),this.rectangleDrawTool.setOnDrawComplete(()=>{this.onDrawingEnd()}),this.triangleDrawTool.setOnDrawComplete(()=>{this.onDrawingEnd()}),this.drawingManager.registerTools(this.circleDrawTool,this.rectangleDrawTool,this.triangleDrawTool),this.drawingManager.setCallbacks(t=>this.onDrawingStart(t),()=>this.onDrawingEnd()),this.setupSelections())}onDrawingStart(t){let e="";t===Me.CIRCLE?e=this.t.drawingCircle:t===Me.RECTANGLE?e="正在绘制矩形...":t===Me.TRIANGLE&&(e="正在绘制三角形..."),this.setDrawingStatus(e)}onDrawingEnd(){this.setDrawingStatus(null)}setupSelections(){const t=this.mapManager.getMap();t.on("click",e=>{const i=t.getFeaturesAtPixel(e.pixel),n=i?.find(a=>a.get("id")?.startsWith("circle_"));if(n&&this.circleDrawTool){this.circleDrawTool.startEdit(n.get("id"));return}const r=i?.find(a=>a.get("id")?.startsWith("rectangle_"));if(r&&this.rectangleDrawTool){this.rectangleDrawTool.startEdit(r.get("id"));return}const o=i?.find(a=>a.get("id")?.startsWith("triangle_"));if(o&&this.triangleDrawTool){this.triangleDrawTool.startEdit(o.get("id"));return}this.stopAllEditing()})}initDrawingManager(){}bindEvents(){this.mapManager.getView().on("moveend",()=>{this.onMoveEndCallback&&!this.isDestroyed&&this.onMoveEndCallback(this.getCenter(),this.getZoom()),this.updateScale()}),this.onMapClickCallback&&this.mapManager.getMap().on("click",t=>{const[e,i]=this.mapManager.getMap().getCoordinateFromPixel(t.pixel);this.onMapClickCallback?.({longitude:e,latitude:i})}),this.mapManager.getMap().on("click",()=>{this.hideFloatingToolbar(),this.hideMeasurementToolbar()})}initRightClickMenu(){this.container.addEventListener("contextmenu",t=>{t.preventDefault();const e=this.container.getBoundingClientRect(),i=t.clientX-e.left,n=t.clientY-e.top,r=[i,n],o=this.mapManager.getMap().getFeaturesAtPixel(r),a=o?.find(u=>u.get("id")?.startsWith("circle_"));if(a&&this.circleDrawLayer){const u=this.circleDrawLayer.getCircle(a.get("id"));if(u){this.selectedCircleId=u.id,this.showFloatingToolbarForCircle({x:i,y:n},u);return}}const l=o?.find(u=>u.get("id")?.startsWith("rectangle_"));if(l&&this.rectangleDrawLayer){const u=this.rectangleDrawLayer.getRectangle(l.get("id"));if(u){this.selectedRectangleId=u.id,this.showFloatingToolbarForRectangle({x:i,y:n},u);return}}const h=o?.find(u=>u.get("id")?.startsWith("triangle_"));if(h&&this.triangleDrawLayer){const u=this.triangleDrawLayer.getTriangle(h.get("id"));if(u){this.selectedTriangleId=u.id,this.showFloatingToolbarForTriangle({x:i,y:n},u);return}}const c=o?.find(u=>u.get("measurementId"));if(c){this.selectedMeasurementId=c.get("measurementId"),this.showMeasurementToolbarForFeature({x:i,y:n});return}this.hideFloatingToolbar(),this.hideMeasurementToolbar()})}startDrawCircle(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingCircle()}startDrawRectangle(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingRectangle()}startDrawTriangle(){this.drawingManager.isDrawing()&&this.drawingManager.cancelDrawing(),this.drawingManager.startDrawingTriangle()}startEditShape(){const t=this.circleDrawLayer?.getAllCircles()||[];if(t.length>0){this.circleDrawTool?.startEdit(t[t.length-1].id);return}const e=this.rectangleDrawLayer?.getAllRectangles()||[];if(e.length>0){this.rectangleDrawTool?.startEdit(e[e.length-1].id);return}const i=this.triangleDrawLayer?.getAllTriangles()||[];if(i.length>0){this.triangleDrawTool?.startEdit(i[i.length-1].id);return}alert(this.t.noCirclesToEdit)}stopAllEditing(){this.circleDrawLayer?.stopEdit(),this.rectangleDrawLayer?.stopEdit(),this.triangleDrawLayer?.stopEdit()}showFloatingToolbarForCircle(t,e){this.floatingToolbarPosition=t,this.showFloatingToolbar=!0,this.currentColor=e.fillColor||[255,0,0,1],this.currentStrokeWidth=e.outlineWidth||3,this.floatingToolbar?(this.floatingToolbar.updatePosition(t),this.floatingToolbar.setVisible(!0)):this.floatingToolbar=new Mo({onColorChange:i=>{this.currentColor=i,this.selectedCircleId&&this.circleDrawLayer&&this.circleDrawLayer.updateCircleStyle(this.selectedCircleId,[i[0],i[1],i[2],.3],[i[0],i[1],i[2],1],this.currentStrokeWidth,this.currentStrokeStyle)},onStrokeWidthChange:i=>{this.currentStrokeWidth=i,this.selectedCircleId&&this.circleDrawLayer&&this.circleDrawLayer.updateCircleStyle(this.selectedCircleId,[this.currentColor[0],this.currentColor[1],this.currentColor[2],.3],[this.currentColor[0],this.currentColor[1],this.currentColor[2],1],i,this.currentStrokeStyle)},onStrokeStyleChange:i=>{this.currentStrokeStyle=i,this.selectedCircleId&&this.circleDrawLayer&&this.circleDrawLayer.updateCircleStyle(this.selectedCircleId,[this.currentColor[0],this.currentColor[1],this.currentColor[2],.3],[this.currentColor[0],this.currentColor[1],this.currentColor[2],1],this.currentStrokeWidth,i)},onDelete:()=>{this.selectedCircleId&&this.circleDrawLayer&&(this.circleDrawLayer.removeCircle(this.selectedCircleId),this.selectedCircleId=null),this.hideFloatingToolbar()},onClose:()=>this.hideFloatingToolbar(),onPositionChange:i=>{this.floatingToolbarPosition=i},theme:this.theme,t:this.t,containerRef:this.container,currentColor:this.currentColor,currentStrokeWidth:this.currentStrokeWidth,currentStrokeStyle:this.currentStrokeStyle,position:t})}showFloatingToolbarForRectangle(t,e){this.floatingToolbarPosition=t,this.showFloatingToolbar=!0,this.currentColor=e.fillColor||[0,0,255,1],this.currentStrokeWidth=e.outlineWidth||3,this.floatingToolbar?(this.floatingToolbar.updatePosition(t),this.floatingToolbar.setVisible(!0)):this.floatingToolbar=new Mo({onColorChange:i=>{this.currentColor=i,this.selectedRectangleId&&this.rectangleDrawLayer&&this.rectangleDrawLayer.updateRectangleStyle(this.selectedRectangleId,[i[0],i[1],i[2],.3],[i[0],i[1],i[2],1],this.currentStrokeWidth,this.currentStrokeStyle)},onStrokeWidthChange:i=>{this.currentStrokeWidth=i,this.selectedRectangleId&&this.rectangleDrawLayer&&this.rectangleDrawLayer.updateRectangleStyle(this.selectedRectangleId,[this.currentColor[0],this.currentColor[1],this.currentColor[2],.3],[this.currentColor[0],this.currentColor[1],this.currentColor[2],1],i,this.currentStrokeStyle)},onStrokeStyleChange:i=>{this.currentStrokeStyle=i,this.selectedRectangleId&&this.rectangleDrawLayer&&this.rectangleDrawLayer.updateRectangleStyle(this.selectedRectangleId,[this.currentColor[0],this.currentColor[1],this.currentColor[2],.3],[this.currentColor[0],this.currentColor[1],this.currentColor[2],1],this.currentStrokeWidth,i)},onDelete:()=>{this.selectedRectangleId&&this.rectangleDrawLayer&&(this.rectangleDrawLayer.removeRectangle(this.selectedRectangleId),this.selectedRectangleId=null),this.hideFloatingToolbar()},onClose:()=>this.hideFloatingToolbar(),onPositionChange:i=>{this.floatingToolbarPosition=i},theme:this.theme,t:this.t,containerRef:this.container,currentColor:this.currentColor,currentStrokeWidth:this.currentStrokeWidth,currentStrokeStyle:this.currentStrokeStyle,position:t})}showFloatingToolbarForTriangle(t,e){this.floatingToolbarPosition=t,this.showFloatingToolbar=!0,this.currentColor=e.fillColor||[255,255,0,1],this.currentStrokeWidth=e.outlineWidth||3,this.floatingToolbar?(this.floatingToolbar.updatePosition(t),this.floatingToolbar.setVisible(!0)):this.floatingToolbar=new Mo({onColorChange:i=>{this.currentColor=i,this.selectedTriangleId&&this.triangleDrawLayer&&this.triangleDrawLayer.updateTriangleStyle(this.selectedTriangleId,[i[0],i[1],i[2],.3],[i[0],i[1],i[2],1],this.currentStrokeWidth,this.currentStrokeStyle)},onStrokeWidthChange:i=>{this.currentStrokeWidth=i,this.selectedTriangleId&&this.triangleDrawLayer&&this.triangleDrawLayer.updateTriangleStyle(this.selectedTriangleId,[this.currentColor[0],this.currentColor[1],this.currentColor[2],.3],[this.currentColor[0],this.currentColor[1],this.currentColor[2],1],i,this.currentStrokeStyle)},onStrokeStyleChange:i=>{this.currentStrokeStyle=i,this.selectedTriangleId&&this.triangleDrawLayer&&this.triangleDrawLayer.updateTriangleStyle(this.selectedTriangleId,[this.currentColor[0],this.currentColor[1],this.currentColor[2],.3],[this.currentColor[0],this.currentColor[1],this.currentColor[2],1],this.currentStrokeWidth,i)},onDelete:()=>{this.selectedTriangleId&&this.triangleDrawLayer&&(this.triangleDrawLayer.removeTriangle(this.selectedTriangleId),this.selectedTriangleId=null),this.hideFloatingToolbar()},onClose:()=>this.hideFloatingToolbar(),onPositionChange:i=>{this.floatingToolbarPosition=i},theme:this.theme,t:this.t,containerRef:this.container,currentColor:this.currentColor,currentStrokeWidth:this.currentStrokeWidth,currentStrokeStyle:this.currentStrokeStyle,position:t})}showMeasurementToolbarForFeature(t){this.measurementToolbarPosition=t,this.showMeasurementToolbar=!0,this.measurementFloatingToolbar?(this.measurementFloatingToolbar.showAtPosition(t),this.measurementFloatingToolbar.setVisible(!0)):this.measurementFloatingToolbar=new ny({onDelete:()=>{this.selectedMeasurementId&&this.deleteMeasurement(this.selectedMeasurementId),this.hideMeasurementToolbar()},onClose:()=>this.hideMeasurementToolbar(),onPositionChange:e=>{this.measurementToolbarPosition=e},theme:this.theme,t:this.t,containerRef:this.container,position:t})}hideFloatingToolbar(){this.showFloatingToolbar=!1,this.selectedCircleId=null,this.selectedRectangleId=null,this.selectedTriangleId=null,this.floatingToolbar?.setVisible(!1)}hideMeasurementToolbar(){this.showMeasurementToolbar=!1,this.selectedMeasurementId=null,this.measurementFloatingToolbar?.setVisible(!1)}getLayerList(){return this.layerManager.getAllLayers().map(t=>({id:t.id,name:t.name,visible:t.visible}))}getLayerVisibility(t){return this.layerManager.getLayer(t)?.visible||!1}updateScale(){const t=this.getZoom();t&&(this.currentScale=t>=10?`1:${Math.round(1e6/Math.pow(2,t))}`:`1:${Math.round(1e7/Math.pow(2,t))}`,this.uiManager.updateScale(this.currentScale))}setDrawingStatus(t){if(this.drawingStatusText=t,this.drawingStatusDiv){const e=this.drawingStatusDiv.querySelector("#drawing-status-text");e&&(e.textContent=t||""),this.drawingStatusDiv.style.display=t?"flex":"none"}}setMeasureStatus(t){if(this.measureStatusText=t,this.measureStatusDiv){const e=this.measureStatusDiv.querySelector("#measure-status-text");e&&(e.textContent=t||""),this.measureStatusDiv.style.display=t?"flex":"none"}}showLoading(t){this.isLoading=!0,this.uiManager.showLoading(t)}hideLoading(){this.isLoading=!1,this.uiManager.hideLoading()}getCenter(){return this.mapManager.getCenter()}getZoom(){return this.mapManager.getZoom()}setCenter(t,e){this.mapManager.setCenter(t,e)}setZoom(t){this.mapManager.setZoom(t),this.updateScale()}setBasemap(t){this.showLoading(this.t.changingBasemap),this.mapManager.setBasemap(t),setTimeout(()=>this.hideLoading(),500)}getBasemap(){return this.mapManager.getCurrentBasemap()}setTheme(t){this.theme=t,this.container.setAttribute("data-theme",t),document.body.setAttribute("data-theme",t),this.uiManager.updateTheme(t)}getTheme(){return this.theme}setLocale(t){this.locale=t,this.t=ra(t),this.uiManager.updateLocale(this.t)}getContainer(){return this.container}getLayerManager(){return this.layerManager}getMap(){return this.mapManager.getMap()}addMarkerLayer(t,e,i){const n=new jc(t,e,{...i,visible:!0,opacity:1});return this.layerManager.addLayer(n),n}removeLayer(t){this.layerManager.removeLayer(t)}setLayerVisibility(t,e){this.layerManager.getLayer(t)?.setVisible(e)}startMeasureDistance(){this.setMeasureStatus(this.t.clickToStartMeasure),this.distanceMeasureLayer?.startMeasure(t=>{if(t.isDrawing){const e=t.distance>=1e3?`${(t.distance/1e3).toFixed(2)} ${this.t.kilometers}`:`${t.distance.toFixed(0)} ${this.t.meters}`;this.setMeasureStatus(`${this.t.distance}: ${e} | ${this.t.doubleClickToFinish}`)}else this.setMeasureStatus(null)})}startMeasureArea(){this.setMeasureStatus(this.t.clickToStartMeasure),this.areaMeasureLayer?.startMeasure(t=>{const e=t.area>=1e6?`${(t.area/1e6).toFixed(2)} ${this.t.squareKilometers}`:`${t.area.toFixed(0)} ${this.t.squareMeters}`;this.setMeasureStatus(`${this.t.area}: ${e}`),setTimeout(()=>this.setMeasureStatus(null),2e3)})}clearAllMeasurements(){this.distanceMeasureLayer?.clearAllMeasurements(),this.areaMeasureLayer?.clearAllMeasurements(),this.setMeasureStatus(null)}deleteMeasurement(t){return this.distanceMeasureLayer?.deleteMeasurement(t)||this.areaMeasureLayer?.deleteMeasurement(t)||!1}zoomIn(){this.setZoom(this.getZoom()+1)}zoomOut(){this.setZoom(this.getZoom()-1)}locateUser(){navigator.geolocation&&(this.showLoading(this.t.locateMe),navigator.geolocation.getCurrentPosition(t=>{this.setCenter([t.coords.longitude,t.coords.latitude]),this.setZoom(15),this.hideLoading()},()=>this.hideLoading()))}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.uiManager.destroy(),this.drawingManager.destroy(),this.floatingToolbar?.destroy(),this.measurementFloatingToolbar?.destroy(),this.drawingStatusDiv?.remove(),this.measureStatusDiv?.remove(),this.layerManager.clearAll(),this.mapManager.destroy())}}exports.AreaMeasurementLayer=vu;exports.BarChartLayer=B_;exports.BaseLayer=Ut;exports.BasemapTypeEnum=J;exports.CircleDrawLayer=xu;exports.CircleLayer=lp;exports.ClusterLayer=x_;exports.CoordinateSystemTypeEnum=Ce;exports.CustomTileLayer=hm;exports.DistanceMeasurementLayer=Eu;exports.EarthViewCore=Cy;exports.GeoJSONLayer=$_;exports.HeatmapLayer=m_;exports.LayerManager=Ph;exports.LayerTypeEnum=nt;exports.MarkerLayer=jc;exports.PolygonLayer=op;exports.PolylineLayer=ap;exports.PopupMarkerLayer=W_;exports.bd09ToWgs84=Tu;exports.fromWGS84=_y;exports.gcj02ToWgs84=gl;exports.getTranslation=ra;exports.isInChina=my;exports.toWGS84=oa;
|